diff --git a/Taskfile.yml b/Taskfile.yml index be1c0e72146..5fb6f965e18 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -778,6 +778,7 @@ tasks: # Runs first: regenerates CLI command stubs from the checked-in # .codegen/cli.json (no universe checkout needed). Refreshing cli.json # itself from the OpenAPI spec is the separate `generate-clijson` task. + - task: generate-sdktypes - task: generate-cligen # Refreshes acceptance/bundle/refschema/out.fields.txt, which feeds # generate-direct-apitypes and generate-direct-resources below. @@ -798,6 +799,7 @@ tasks: generate-check: desc: Run the reproducible generators (CI drift subset of `generate`) cmds: + - task: generate-sdktypes - task: generate-cligen - task: generate-refschema - task: generate-schema @@ -812,6 +814,21 @@ tasks: # templates derived from genkit's cli_v0 generator and formats the output # in-process (whitespace normalization, unused-import pruning, gofmt), so # the result matches the committed files byte-for-byte. + # Regenerates the JSON-tagged mirrors of sdk-go types (libs/sdktypes) and the + # oneof registry used by libs/sdktypes/sdkconv, for the sdk-go packages listed + # in libs/sdktypes/packages.txt (" " per line). Inputs are + # the sdk-go sources pinned in go.mod. + generate-sdktypes: + desc: Regenerate libs/sdktypes from the sdk-go packages in go.mod + sources: + - go.mod + - libs/sdktypes/packages.txt + - internal/sdktypesgen/*.go + - internal/sdkconvgen/*.go + cmds: + - "sh -c 'sed \"s|^\\([^ ]*\\).*|github.com/databricks/sdk-go/\\1|\" libs/sdktypes/packages.txt | xargs go run ./internal/sdktypesgen libs/sdktypes'" + - "sh -c 'sed \"s|^\\([^ ]*\\).*|github.com/databricks/sdk-go/\\1|\" libs/sdktypes/packages.txt | xargs go run ./internal/sdkconvgen libs/sdktypes/sdkconv/oneofs.generated.go'" + generate-cligen: desc: Regenerate CLI command stubs from .codegen/cli.json sources: @@ -819,6 +836,10 @@ tasks: - .gitattributes.manual - internal/cligen/**/*.go - internal/cligen/templates/*.tmpl + - internal/cligen/http_verbs.json + - libs/sdkclients/services.go + - libs/sdktypes/**/types.generated.go + - go.mod generates: - cmd/workspace/**/*.go - cmd/account/**/*.go @@ -962,6 +983,7 @@ tasks: - "**/*.go" - .codegen/cli.json - bundle/internal/schema/annotations.yml + - bundle/internal/sdkmeta/legacy.json - exclude: "**/*_test.go" - go.mod - go.sum @@ -976,6 +998,8 @@ tasks: desc: Generate enum and required field validation code sources: - "**/*.go" + - .codegen/cli.json + - bundle/internal/sdkmeta/legacy.json - exclude: "**/*_test.go" - go.mod - go.sum diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index fb1013a424a..0872d2efe9d 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -26,6 +26,8 @@ import ( "time" "unicode/utf8" + "github.com/databricks/cli/libs/utils" + "github.com/google/uuid" "github.com/databricks/cli/acceptance/internal" @@ -1013,7 +1015,7 @@ func runTest(t *testing.T, // output) are stable across OSes and don't need per-test slash replacements. cmd.Env = append(cmd.Env, "TESTDIR="+filepath.ToSlash(absDir)) cmd.Env = append(cmd.Env, "CLOUD_ENV="+cloudEnv) - cmd.Env = append(cmd.Env, "CURRENT_USER_NAME="+user.UserName) + cmd.Env = append(cmd.Env, "CURRENT_USER_NAME="+utils.Deref(user.UserName)) if !isRunningOnCloud { // Expose a guest token for the as-test-sp helper: the guest prefix plus // the primary identity's uuid suffix make it share the same fake diff --git a/acceptance/air/run-submit/output.txt b/acceptance/air/run-submit/output.txt index 516c4f122d7..0faaedfea27 100644 --- a/acceptance/air/run-submit/output.txt +++ b/acceptance/air/run-submit/output.txt @@ -43,7 +43,9 @@ Stream logs after submission using: "permission_level": "CAN_EDIT", "service_principal_name": "training-sp" } - ] + ], + "request_object_id": "42", + "request_object_type": "experiments" } } { @@ -63,7 +65,9 @@ Stream logs after submission using: "permission_level": "CAN_MANAGE_RUN", "service_principal_name": "training-sp" } - ] + ], + "request_object_id": "123", + "request_object_type": "jobs" } } { diff --git a/acceptance/bundle/artifacts/whl_dynamic/databricks.yml b/acceptance/bundle/artifacts/whl_dynamic/databricks.yml index c407804bf42..82799d4f4ee 100644 --- a/acceptance/bundle/artifacts/whl_dynamic/databricks.yml +++ b/acceptance/bundle/artifacts/whl_dynamic/databricks.yml @@ -21,9 +21,6 @@ resources: tasks: - task_key: TestTask existing_cluster_id: "0717-132531-5opeqon1" - python_wheel_task: - package_name: "my_test_code" - entry_point: "run" libraries: - whl: ./my_test_code/dist/*.whl - whl: prebuilt/other_test_code-0.0.1-py3-none-any.whl diff --git a/acceptance/bundle/artifacts/whl_dynamic/out.plan_create.json b/acceptance/bundle/artifacts/whl_dynamic/out.plan_create.json index 15e1b903b6d..49f952f3c7e 100644 --- a/acceptance/bundle/artifacts/whl_dynamic/out.plan_create.json +++ b/acceptance/bundle/artifacts/whl_dynamic/out.plan_create.json @@ -63,10 +63,6 @@ "whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/other_test_code-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl" } ], - "python_wheel_task": { - "entry_point": "run", - "package_name": "my_test_code" - }, "task_key": "TestTask" } ] diff --git a/acceptance/bundle/artifacts/whl_dynamic/out.plan_update.json b/acceptance/bundle/artifacts/whl_dynamic/out.plan_update.json index 9b81021ae27..380cdd08ddc 100644 --- a/acceptance/bundle/artifacts/whl_dynamic/out.plan_update.json +++ b/acceptance/bundle/artifacts/whl_dynamic/out.plan_update.json @@ -65,18 +65,12 @@ "whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/other_test_code-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl" } ], - "python_wheel_task": { - "entry_point": "run", - "package_name": "my_test_code" - }, "task_key": "TestTask" } ] } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -95,13 +89,11 @@ } ], "format": "MULTI_TASK", - "job_id": [TEST_JOB_ID], "max_concurrent_runs": 1, "name": "[default] My Wheel Job", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -141,17 +133,17 @@ "whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/other_test_code-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl" } ], - "python_wheel_task": { - "entry_point": "run", - "package_name": "my_test_code" - }, "run_if": "ALL_SUCCESS", "task_key": "TestTask", "timeout_seconds": 0 } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [TEST_JOB_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/deploy/experimental-python/output.txt b/acceptance/bundle/deploy/experimental-python/output.txt index e66bb4ef967..b8f1977833b 100644 --- a/acceptance/bundle/deploy/experimental-python/output.txt +++ b/acceptance/bundle/deploy/experimental-python/output.txt @@ -11,6 +11,7 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged "created_time": [UNIX_TIME_MILLIS], "creator_user_name": "[USERNAME]", "job_id": [JOB1_ID], + "run_as_user_name": "[USERNAME]", "settings": { "deployment": { "kind": "BUNDLE", diff --git a/acceptance/bundle/deploy/python-notebook/output.txt b/acceptance/bundle/deploy/python-notebook/output.txt index 95a09e78d58..9aa739aafb8 100644 --- a/acceptance/bundle/deploy/python-notebook/output.txt +++ b/acceptance/bundle/deploy/python-notebook/output.txt @@ -11,6 +11,7 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged "created_time": [UNIX_TIME_MILLIS], "creator_user_name": "[USERNAME]", "job_id": [MY_JOB_ID], + "run_as_user_name": "[USERNAME]", "settings": { "deployment": { "kind": "BUNDLE", diff --git a/acceptance/bundle/deploy/readplan/basic/out.plan_skip.json b/acceptance/bundle/deploy/readplan/basic/out.plan_skip.json index 8982add5d75..7d96f187bf6 100644 --- a/acceptance/bundle/deploy/readplan/basic/out.plan_skip.json +++ b/acceptance/bundle/deploy/readplan/basic/out.plan_skip.json @@ -7,8 +7,6 @@ "resources.jobs.job": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -16,15 +14,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [JOB_ID], "max_concurrent_runs": 1, "name": "test-job", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [JOB_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/deploy/readplan/grants-remove-principal/output.txt b/acceptance/bundle/deploy/readplan/grants-remove-principal/output.txt index 948a497f7e9..2b518aebbaf 100644 --- a/acceptance/bundle/deploy/readplan/grants-remove-principal/output.txt +++ b/acceptance/bundle/deploy/readplan/grants-remove-principal/output.txt @@ -30,7 +30,9 @@ Resources: 2 created, 0 changed, 0 deleted, 0 unchanged "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.myschema", + "securable_type": "schema" } } @@ -67,7 +69,9 @@ Resources: 0 created, 1 changed, 0 deleted, 1 unchanged "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.myschema", + "securable_type": "schema" } } The following resources will be deleted: diff --git a/acceptance/bundle/deploy/readplan/postgres_role/out.plan.role.json b/acceptance/bundle/deploy/readplan/postgres_role/out.plan.role.json index c236b61882a..ff4ed289e7a 100644 --- a/acceptance/bundle/deploy/readplan/postgres_role/out.plan.role.json +++ b/acceptance/bundle/deploy/readplan/postgres_role/out.plan.role.json @@ -8,9 +8,9 @@ "action": "create", "new_state": { "value": { - "parent": "${resources.postgres_branches.branch.name}", "postgres_role": "app_role", - "role_id": "test-role" + "role_id": "test-role", + "parent": "${resources.postgres_branches.branch.name}" }, "vars": { "parent": "${resources.postgres_branches.branch.name}" diff --git a/acceptance/bundle/deployment/bind/dashboard/recreation/out.state_after_bind.json b/acceptance/bundle/deployment/bind/dashboard/recreation/out.state_after_bind.json index 05614d798bf..b992ff8faec 100644 --- a/acceptance/bundle/deployment/bind/dashboard/recreation/out.state_after_bind.json +++ b/acceptance/bundle/deployment/bind/dashboard/recreation/out.state_after_bind.json @@ -8,12 +8,12 @@ "__id__": "[DASHBOARD_ID]", "state": { "display_name": "test dashboard [UNIQUE_NAME]", - "embed_credentials": true, "etag": [ETAG], "parent_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/default/resources", - "published": true, + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Page One\",\"name\":\"02724bf2\"}]}", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "embed_credentials": true, + "published": true } } } diff --git a/acceptance/bundle/deployment/bind/pipelines/update/out.deploy.requests.json b/acceptance/bundle/deployment/bind/pipelines/update/out.deploy.requests.json index 78f256ba442..664cb92bdd4 100644 --- a/acceptance/bundle/deployment/bind/pipelines/update/out.deploy.requests.json +++ b/acceptance/bundle/deployment/bind/pipelines/update/out.deploy.requests.json @@ -30,6 +30,7 @@ } } ], - "name": "test-pipeline" + "name": "test-pipeline", + "pipeline_id": "[NEW_PIPELINE_ID]" } } diff --git a/acceptance/bundle/dms/no-drift/output.txt b/acceptance/bundle/dms/no-drift/output.txt index c0b7a35688e..c5f295f36cf 100644 --- a/acceptance/bundle/dms/no-drift/output.txt +++ b/acceptance/bundle/dms/no-drift/output.txt @@ -139,6 +139,7 @@ Resources: 0 created, 1 changed, 0 deleted, 1 unchanged } ], "name": "bar-[UNIQUE_NAME]", + "pipeline_id": "[UUID]", "schema": "default", "serverless": true } diff --git a/acceptance/bundle/generate/dashboard-inplace/output.txt b/acceptance/bundle/generate/dashboard-inplace/output.txt index 52e5822e308..ace8562a428 100644 --- a/acceptance/bundle/generate/dashboard-inplace/output.txt +++ b/acceptance/bundle/generate/dashboard-inplace/output.txt @@ -20,8 +20,7 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged "parent_path": "/Users/[USERNAME]/.bundle/dashboard update inplace/default/resources", "path": "/Users/[USERNAME]/.bundle/dashboard update inplace/default/resources/test dashboard.lvdash.json", "serialized_dashboard": "{\"a\":\"b\"}\n", - "update_time": "[TIMESTAMP]", - "warehouse_id": "" + "update_time": "[TIMESTAMP]" } === update the dashboard file using bundle generate diff --git a/acceptance/bundle/generate/git_job/out.job.yml b/acceptance/bundle/generate/git_job/out.job.yml index 7142a074428..b46cb46b23b 100644 --- a/acceptance/bundle/generate/git_job/out.job.yml +++ b/acceptance/bundle/generate/git_job/out.job.yml @@ -12,6 +12,5 @@ resources: source: WORKSPACE git_source: git_branch: main - git_commit: abcdef git_provider: github git_url: https://git.databricks.com diff --git a/acceptance/bundle/generate/git_job/test.toml b/acceptance/bundle/generate/git_job/test.toml index c432342647d..bdfacb9a59c 100644 --- a/acceptance/bundle/generate/git_job/test.toml +++ b/acceptance/bundle/generate/git_job/test.toml @@ -8,8 +8,7 @@ Response.Body = ''' "git_source": { "git_url": "https://git.databricks.com", "git_provider": "github", - "git_branch": "main", - "git_commit": "abcdef" + "git_branch": "main" }, "tasks": [ { diff --git a/acceptance/bundle/generate/include_warning/test.toml b/acceptance/bundle/generate/include_warning/test.toml index 3a137df700c..2b605934ecd 100644 --- a/acceptance/bundle/generate/include_warning/test.toml +++ b/acceptance/bundle/generate/include_warning/test.toml @@ -8,8 +8,7 @@ Response.Body = ''' "git_source": { "git_url": "https://git.databricks.com", "git_provider": "github", - "git_branch": "main", - "git_commit": "abcdef" + "git_branch": "main" }, "tasks": [ { diff --git a/acceptance/bundle/generate/pipeline/test.toml b/acceptance/bundle/generate/pipeline/test.toml index ecb5b791a3c..51a701dcb0c 100644 --- a/acceptance/bundle/generate/pipeline/test.toml +++ b/acceptance/bundle/generate/pipeline/test.toml @@ -2,7 +2,7 @@ Pattern = "GET /api/2.0/pipelines/1234" Response.Body = ''' { - "pipeline_id": 1234, + "pipeline_id": "1234", "spec": { "name": "generate-pipeline", "development": true, diff --git a/acceptance/bundle/generate/pipeline_with_glob/test.toml b/acceptance/bundle/generate/pipeline_with_glob/test.toml index 0abe427b555..740bb576e33 100644 --- a/acceptance/bundle/generate/pipeline_with_glob/test.toml +++ b/acceptance/bundle/generate/pipeline_with_glob/test.toml @@ -2,7 +2,7 @@ Pattern = "GET /api/2.0/pipelines/1234" Response.Body = ''' { - "pipeline_id": 1234, + "pipeline_id": "1234", "spec": { "name": "generate-pipeline", "libraries": [ diff --git a/acceptance/bundle/generate/pipeline_with_sql/test.toml b/acceptance/bundle/generate/pipeline_with_sql/test.toml index a7d46647194..9f35f2a2e64 100644 --- a/acceptance/bundle/generate/pipeline_with_sql/test.toml +++ b/acceptance/bundle/generate/pipeline_with_sql/test.toml @@ -2,7 +2,7 @@ Pattern = "GET /api/2.0/pipelines/1234" Response.Body = ''' { - "pipeline_id": 1234, + "pipeline_id": "1234", "spec": { "name": "generate-pipeline", "clusters": [ diff --git a/acceptance/bundle/migrate/auto/clean/out.plan_update.json b/acceptance/bundle/migrate/auto/clean/out.plan_update.json index 1f79fdd0cb3..28c59fd7919 100644 --- a/acceptance/bundle/migrate/auto/clean/out.plan_update.json +++ b/acceptance/bundle/migrate/auto/clean/out.plan_update.json @@ -22,8 +22,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -31,15 +29,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [TEST_JOB_ID], "max_concurrent_runs": 1, "name": "Test Auto-Migrate Job", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [TEST_JOB_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/migrate/command/basic/out.plan_update.json b/acceptance/bundle/migrate/command/basic/out.plan_update.json index b873a52a785..a3c993598ef 100644 --- a/acceptance/bundle/migrate/command/basic/out.plan_update.json +++ b/acceptance/bundle/migrate/command/basic/out.plan_update.json @@ -30,8 +30,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS][0], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/migrate-basic-test/dev/state/metadata.json" @@ -39,13 +37,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [TEST_JOB_ID], "max_concurrent_runs": 1, "name": "Test Migration Job", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -59,7 +55,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][0], + "creator_user_name": "[USERNAME]", + "job_id": [TEST_JOB_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { @@ -164,15 +164,12 @@ }, "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/migrate-basic-test/dev/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[UUID]", - "last_modified": [UNIX_TIME_MILLIS][1], "libraries": [ { "notebook": { @@ -181,9 +178,6 @@ } ], "name": "Test Migration Pipeline", - "pipeline_id": "[UUID]", - "run_as_user_name": "[USERNAME]", - "state": "IDLE", "storage": "dbfs:/pipelines/[UUID]", "tags": { "myjob_id": "[TEST_JOB_ID]", @@ -192,7 +186,13 @@ "myvolume_id": "mycat.myschema.myvol", "volume_catalog_name": "mycat", "volume_storage_location": "s3://[METASTORE_NAME]/metastore/[UUID]/volumes/[UUID]" - } + }, + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS][1], + "pipeline_id": "[UUID]", + "run_as_user_name": "[USERNAME]", + "state": "IDLE" }, "changes": { "name": { diff --git a/acceptance/bundle/migrate/command/dashboards/out.new_state.json b/acceptance/bundle/migrate/command/dashboards/out.new_state.json index c710e449216..9e507e5d109 100644 --- a/acceptance/bundle/migrate/command/dashboards/out.new_state.json +++ b/acceptance/bundle/migrate/command/dashboards/out.new_state.json @@ -8,12 +8,12 @@ "__id__": "[DASHBOARD1_ID]", "state": { "display_name": "my dashboard", - "embed_credentials": true, "etag": "80611980", "parent_path": "/Workspace/Users/[USERNAME]", - "published": true, + "warehouse_id": "123456", "serialized_dashboard": "sha256:[HASH]", - "warehouse_id": "123456" + "embed_credentials": true, + "published": true } } } diff --git a/acceptance/bundle/migrate/command/dashboards/out.plan_after_migrate.json b/acceptance/bundle/migrate/command/dashboards/out.plan_after_migrate.json index 3d9a600d1d8..8772876d570 100644 --- a/acceptance/bundle/migrate/command/dashboards/out.plan_after_migrate.json +++ b/acceptance/bundle/migrate/command/dashboards/out.plan_after_migrate.json @@ -10,15 +10,15 @@ "create_time": "[TIMESTAMP]", "dashboard_id": "[DASHBOARD1_ID]", "display_name": "my dashboard", - "embed_credentials": true, "etag": "80611980", "lifecycle_state": "ACTIVE", "parent_path": "/Workspace/Users/[USERNAME]", "path": "/Users/[USERNAME]/my dashboard.lvdash.json", - "published": true, - "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"name\":\"02724bf2\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}\n", "update_time": "[TIMESTAMP]", - "warehouse_id": "123456" + "warehouse_id": "123456", + "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"name\":\"02724bf2\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}\n", + "embed_credentials": true, + "published": true }, "changes": { "create_time": { diff --git a/acceptance/bundle/migrate/command/default-python/out.plan_after_deploy.json b/acceptance/bundle/migrate/command/default-python/out.plan_after_deploy.json deleted file mode 100644 index 5f9270249fa..00000000000 --- a/acceptance/bundle/migrate/command/default-python/out.plan_after_deploy.json +++ /dev/null @@ -1,352 +0,0 @@ -{ - "plan_version": [PLAN_VERSION], - "cli_version": "[CLI_VERSION]", - "lineage": "[UUID]", - "serial": 6, - "plan": { - "resources.jobs.sample_job": { - "depends_on": [ - { - "node": "resources.pipelines.my_default_python_etl", - "label": "${resources.pipelines.my_default_python_etl.id}" - } - ], - "action": "update", - "new_state": { - "value": { - "deployment": { - "kind": "BUNDLE", - "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/state/metadata.json" - }, - "edit_mode": "UI_LOCKED", - "format": "MULTI_TASK", - "job_clusters": [ - { - "job_cluster_key": "job_cluster", - "new_cluster": { - "autoscale": { - "max_workers": 4, - "min_workers": 1 - }, - "data_security_mode": "DATA_SECURITY_MODE_AUTO", - "node_type_id": "[NODE_TYPE_ID]", - "spark_version": "16.4.x-scala2.12" - } - } - ], - "max_concurrent_runs": 4, - "name": "[dev [USERNAME]] sample_job", - "parameters": [ - { - "default": "hive_metastore", - "name": "catalog" - }, - { - "default": "[USERNAME]", - "name": "schema" - } - ], - "queue": { - "enabled": true - }, - "tags": { - "dev": "[USERNAME]" - }, - "tasks": [ - { - "job_cluster_key": "job_cluster", - "libraries": [ - { - "whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl" - } - ], - "notebook_task": { - "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files/src/sample_notebook" - }, - "task_key": "notebook_task" - }, - { - "depends_on": [ - { - "task_key": "notebook_task" - } - ], - "job_cluster_key": "job_cluster", - "libraries": [ - { - "whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl" - } - ], - "python_wheel_task": { - "entry_point": "main", - "package_name": "my_default_python", - "parameters": [ - "--catalog", - "hive_metastore", - "--schema", - "[USERNAME]" - ] - }, - "task_key": "python_wheel_task" - }, - { - "depends_on": [ - { - "task_key": "notebook_task" - } - ], - "pipeline_task": { - "pipeline_id": "[MY_DEFAULT_PYTHON_ETL_ID]" - }, - "task_key": "refresh_pipeline" - } - ], - "trigger": { - "pause_status": "PAUSED", - "periodic": { - "interval": 1, - "unit": "DAYS" - } - } - } - }, - "remote_state": { - "created_time": [UNIX_TIME_MILLIS][0], - "creator_user_name": "[USERNAME]", - "deployment": { - "kind": "BUNDLE", - "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/state/metadata.json" - }, - "edit_mode": "UI_LOCKED", - "email_notifications": {}, - "format": "MULTI_TASK", - "job_clusters": [ - { - "job_cluster_key": "job_cluster", - "new_cluster": { - "autoscale": { - "max_workers": 4, - "min_workers": 1 - }, - "data_security_mode": "DATA_SECURITY_MODE_AUTO", - "node_type_id": "[NODE_TYPE_ID]", - "spark_version": "16.4.x-scala2.12" - } - } - ], - "job_id": [SAMPLE_JOB_ID], - "max_concurrent_runs": 4, - "name": "[dev [USERNAME]] sample_job", - "parameters": [ - { - "default": "hive_metastore", - "name": "catalog" - }, - { - "default": "[USERNAME]", - "name": "schema" - } - ], - "queue": { - "enabled": true - }, - "run_as_user_name": "[USERNAME]", - "tags": { - "dev": "[USERNAME]" - }, - "tasks": [ - { - "email_notifications": {}, - "job_cluster_key": "job_cluster", - "libraries": [ - { - "whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl" - } - ], - "notebook_task": { - "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files/src/sample_notebook", - "source": "WORKSPACE" - }, - "run_if": "ALL_SUCCESS", - "task_key": "notebook_task", - "timeout_seconds": 0 - }, - { - "depends_on": [ - { - "task_key": "notebook_task" - } - ], - "email_notifications": {}, - "job_cluster_key": "job_cluster", - "libraries": [ - { - "whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl" - } - ], - "python_wheel_task": { - "entry_point": "main", - "package_name": "my_default_python", - "parameters": [ - "--catalog", - "hive_metastore", - "--schema", - "[USERNAME]" - ] - }, - "run_if": "ALL_SUCCESS", - "task_key": "python_wheel_task", - "timeout_seconds": 0 - }, - { - "depends_on": [ - { - "task_key": "notebook_task" - } - ], - "email_notifications": {}, - "pipeline_task": { - "pipeline_id": "[MY_DEFAULT_PYTHON_ETL_ID]" - }, - "run_if": "ALL_SUCCESS", - "task_key": "refresh_pipeline", - "timeout_seconds": 0 - } - ], - "timeout_seconds": 0, - "trigger": { - "pause_status": "PAUSED", - "periodic": { - "interval": 1, - "unit": "DAYS" - } - }, - "webhook_notifications": {} - }, - "changes": { - "email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='notebook_task'].email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='notebook_task'].libraries[0].whl": { - "action": "update", - "old": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl", - "new": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl", - "remote": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl" - }, - "tasks[task_key='notebook_task'].notebook_task.source": { - "action": "skip", - "reason": "backend_default", - "remote": "WORKSPACE" - }, - "tasks[task_key='notebook_task'].run_if": { - "action": "skip", - "reason": "backend_default", - "remote": "ALL_SUCCESS" - }, - "tasks[task_key='notebook_task'].timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "tasks[task_key='python_wheel_task'].email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='python_wheel_task'].libraries[0].whl": { - "action": "update", - "old": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl", - "new": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl", - "remote": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl" - }, - "tasks[task_key='python_wheel_task'].run_if": { - "action": "skip", - "reason": "backend_default", - "remote": "ALL_SUCCESS" - }, - "tasks[task_key='python_wheel_task'].timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "tasks[task_key='refresh_pipeline'].email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='refresh_pipeline'].run_if": { - "action": "skip", - "reason": "backend_default", - "remote": "ALL_SUCCESS" - }, - "tasks[task_key='refresh_pipeline'].timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "webhook_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - } - } - }, - "resources.pipelines.my_default_python_etl": { - "action": "skip", - "remote_state": { - "channel": "CURRENT", - "creator_user_name": "[USERNAME]", - "deployment": { - "kind": "BUNDLE", - "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/state/metadata.json" - }, - "development": true, - "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", - "environment": { - "dependencies": [ - "--editable /Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files" - ] - }, - "id": "[MY_DEFAULT_PYTHON_ETL_ID]", - "last_modified": [UNIX_TIME_MILLIS][1], - "libraries": [ - { - "glob": { - "include": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files/src/my_default_python_etl/transformations/**" - } - } - ], - "name": "[dev [USERNAME]] my_default_python_etl", - "pipeline_id": "[MY_DEFAULT_PYTHON_ETL_ID]", - "root_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files/src/my_default_python_etl", - "run_as_user_name": "[USERNAME]", - "schema": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/[MY_DEFAULT_PYTHON_ETL_ID]", - "tags": { - "dev": "[USERNAME]" - } - }, - "changes": { - "storage": { - "action": "skip", - "reason": "immutable_backend_value", - "remote": "dbfs:/pipelines/[MY_DEFAULT_PYTHON_ETL_ID]" - } - } - } - } -} diff --git a/acceptance/bundle/migrate/command/default-python/out.plan_after_migration.json b/acceptance/bundle/migrate/command/default-python/out.plan_after_migration.json deleted file mode 100644 index 8df5a4684a9..00000000000 --- a/acceptance/bundle/migrate/command/default-python/out.plan_after_migration.json +++ /dev/null @@ -1,352 +0,0 @@ -{ - "plan_version": [PLAN_VERSION], - "cli_version": "[CLI_VERSION]", - "lineage": "[UUID]", - "serial": 5, - "plan": { - "resources.jobs.sample_job": { - "depends_on": [ - { - "node": "resources.pipelines.my_default_python_etl", - "label": "${resources.pipelines.my_default_python_etl.id}" - } - ], - "action": "update", - "new_state": { - "value": { - "deployment": { - "kind": "BUNDLE", - "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/state/metadata.json" - }, - "edit_mode": "UI_LOCKED", - "format": "MULTI_TASK", - "job_clusters": [ - { - "job_cluster_key": "job_cluster", - "new_cluster": { - "autoscale": { - "max_workers": 4, - "min_workers": 1 - }, - "data_security_mode": "DATA_SECURITY_MODE_AUTO", - "node_type_id": "[NODE_TYPE_ID]", - "spark_version": "16.4.x-scala2.12" - } - } - ], - "max_concurrent_runs": 4, - "name": "[dev [USERNAME]] sample_job", - "parameters": [ - { - "default": "hive_metastore", - "name": "catalog" - }, - { - "default": "[USERNAME]", - "name": "schema" - } - ], - "queue": { - "enabled": true - }, - "tags": { - "dev": "[USERNAME]" - }, - "tasks": [ - { - "job_cluster_key": "job_cluster", - "libraries": [ - { - "whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl" - } - ], - "notebook_task": { - "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files/src/sample_notebook" - }, - "task_key": "notebook_task" - }, - { - "depends_on": [ - { - "task_key": "notebook_task" - } - ], - "job_cluster_key": "job_cluster", - "libraries": [ - { - "whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl" - } - ], - "python_wheel_task": { - "entry_point": "main", - "package_name": "my_default_python", - "parameters": [ - "--catalog", - "hive_metastore", - "--schema", - "[USERNAME]" - ] - }, - "task_key": "python_wheel_task" - }, - { - "depends_on": [ - { - "task_key": "notebook_task" - } - ], - "pipeline_task": { - "pipeline_id": "[MY_DEFAULT_PYTHON_ETL_ID]" - }, - "task_key": "refresh_pipeline" - } - ], - "trigger": { - "pause_status": "PAUSED", - "periodic": { - "interval": 1, - "unit": "DAYS" - } - } - } - }, - "remote_state": { - "created_time": [UNIX_TIME_MILLIS][0], - "creator_user_name": "[USERNAME]", - "deployment": { - "kind": "BUNDLE", - "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/state/metadata.json" - }, - "edit_mode": "UI_LOCKED", - "email_notifications": {}, - "format": "MULTI_TASK", - "job_clusters": [ - { - "job_cluster_key": "job_cluster", - "new_cluster": { - "autoscale": { - "max_workers": 4, - "min_workers": 1 - }, - "data_security_mode": "DATA_SECURITY_MODE_AUTO", - "node_type_id": "[NODE_TYPE_ID]", - "spark_version": "16.4.x-scala2.12" - } - } - ], - "job_id": [SAMPLE_JOB_ID], - "max_concurrent_runs": 4, - "name": "[dev [USERNAME]] sample_job", - "parameters": [ - { - "default": "hive_metastore", - "name": "catalog" - }, - { - "default": "[USERNAME]", - "name": "schema" - } - ], - "queue": { - "enabled": true - }, - "run_as_user_name": "[USERNAME]", - "tags": { - "dev": "[USERNAME]" - }, - "tasks": [ - { - "email_notifications": {}, - "job_cluster_key": "job_cluster", - "libraries": [ - { - "whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl" - } - ], - "notebook_task": { - "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files/src/sample_notebook", - "source": "WORKSPACE" - }, - "run_if": "ALL_SUCCESS", - "task_key": "notebook_task", - "timeout_seconds": 0 - }, - { - "depends_on": [ - { - "task_key": "notebook_task" - } - ], - "email_notifications": {}, - "job_cluster_key": "job_cluster", - "libraries": [ - { - "whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl" - } - ], - "python_wheel_task": { - "entry_point": "main", - "package_name": "my_default_python", - "parameters": [ - "--catalog", - "hive_metastore", - "--schema", - "[USERNAME]" - ] - }, - "run_if": "ALL_SUCCESS", - "task_key": "python_wheel_task", - "timeout_seconds": 0 - }, - { - "depends_on": [ - { - "task_key": "notebook_task" - } - ], - "email_notifications": {}, - "pipeline_task": { - "pipeline_id": "[MY_DEFAULT_PYTHON_ETL_ID]" - }, - "run_if": "ALL_SUCCESS", - "task_key": "refresh_pipeline", - "timeout_seconds": 0 - } - ], - "timeout_seconds": 0, - "trigger": { - "pause_status": "PAUSED", - "periodic": { - "interval": 1, - "unit": "DAYS" - } - }, - "webhook_notifications": {} - }, - "changes": { - "email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='notebook_task'].email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='notebook_task'].libraries[0].whl": { - "action": "update", - "old": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][2]-py3-none-any.whl", - "new": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl", - "remote": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl" - }, - "tasks[task_key='notebook_task'].notebook_task.source": { - "action": "skip", - "reason": "backend_default", - "remote": "WORKSPACE" - }, - "tasks[task_key='notebook_task'].run_if": { - "action": "skip", - "reason": "backend_default", - "remote": "ALL_SUCCESS" - }, - "tasks[task_key='notebook_task'].timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "tasks[task_key='python_wheel_task'].email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='python_wheel_task'].libraries[0].whl": { - "action": "update", - "old": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][2]-py3-none-any.whl", - "new": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl", - "remote": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl" - }, - "tasks[task_key='python_wheel_task'].run_if": { - "action": "skip", - "reason": "backend_default", - "remote": "ALL_SUCCESS" - }, - "tasks[task_key='python_wheel_task'].timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "tasks[task_key='refresh_pipeline'].email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='refresh_pipeline'].run_if": { - "action": "skip", - "reason": "backend_default", - "remote": "ALL_SUCCESS" - }, - "tasks[task_key='refresh_pipeline'].timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "webhook_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - } - } - }, - "resources.pipelines.my_default_python_etl": { - "action": "skip", - "remote_state": { - "channel": "CURRENT", - "creator_user_name": "[USERNAME]", - "deployment": { - "kind": "BUNDLE", - "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/state/metadata.json" - }, - "development": true, - "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", - "environment": { - "dependencies": [ - "--editable /Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files" - ] - }, - "id": "[MY_DEFAULT_PYTHON_ETL_ID]", - "last_modified": [UNIX_TIME_MILLIS][1], - "libraries": [ - { - "glob": { - "include": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files/src/my_default_python_etl/transformations/**" - } - } - ], - "name": "[dev [USERNAME]] my_default_python_etl", - "pipeline_id": "[MY_DEFAULT_PYTHON_ETL_ID]", - "root_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files/src/my_default_python_etl", - "run_as_user_name": "[USERNAME]", - "schema": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/[MY_DEFAULT_PYTHON_ETL_ID]", - "tags": { - "dev": "[USERNAME]" - } - }, - "changes": { - "storage": { - "action": "skip", - "reason": "immutable_backend_value", - "remote": "dbfs:/pipelines/[MY_DEFAULT_PYTHON_ETL_ID]" - } - } - } - } -} diff --git a/acceptance/bundle/migrate/command/default-python/out.state_after_migration.json b/acceptance/bundle/migrate/command/default-python/out.state_after_migration.json deleted file mode 100644 index 007548bcee5..00000000000 --- a/acceptance/bundle/migrate/command/default-python/out.state_after_migration.json +++ /dev/null @@ -1,143 +0,0 @@ -{ - "state_version": 3, - "cli_version": "[CLI_VERSION]", - "lineage": "[UUID]", - "serial": 5, - "state": { - "resources.jobs.sample_job": { - "__id__": "[SAMPLE_JOB_ID]", - "state": { - "deployment": { - "kind": "BUNDLE", - "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/state/metadata.json" - }, - "edit_mode": "UI_LOCKED", - "format": "MULTI_TASK", - "job_clusters": [ - { - "job_cluster_key": "job_cluster", - "new_cluster": { - "autoscale": { - "max_workers": 4, - "min_workers": 1 - }, - "data_security_mode": "DATA_SECURITY_MODE_AUTO", - "node_type_id": "[NODE_TYPE_ID]", - "spark_version": "16.4.x-scala2.12" - } - } - ], - "max_concurrent_runs": 4, - "name": "[dev [USERNAME]] sample_job", - "parameters": [ - { - "default": "hive_metastore", - "name": "catalog" - }, - { - "default": "[USERNAME]", - "name": "schema" - } - ], - "queue": { - "enabled": true - }, - "tags": { - "dev": "[USERNAME]" - }, - "tasks": [ - { - "job_cluster_key": "job_cluster", - "libraries": [ - { - "whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl" - } - ], - "notebook_task": { - "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files/src/sample_notebook" - }, - "task_key": "notebook_task" - }, - { - "depends_on": [ - { - "task_key": "notebook_task" - } - ], - "job_cluster_key": "job_cluster", - "libraries": [ - { - "whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl" - } - ], - "python_wheel_task": { - "entry_point": "main", - "package_name": "my_default_python", - "parameters": [ - "--catalog", - "hive_metastore", - "--schema", - "[USERNAME]" - ] - }, - "task_key": "python_wheel_task" - }, - { - "depends_on": [ - { - "task_key": "notebook_task" - } - ], - "pipeline_task": { - "pipeline_id": "[MY_DEFAULT_PYTHON_ETL_ID]" - }, - "task_key": "refresh_pipeline" - } - ], - "trigger": { - "pause_status": "PAUSED", - "periodic": { - "interval": 1, - "unit": "DAYS" - } - } - }, - "depends_on": [ - { - "node": "resources.pipelines.my_default_python_etl", - "label": "${resources.pipelines.my_default_python_etl.id}" - } - ] - }, - "resources.pipelines.my_default_python_etl": { - "__id__": "[MY_DEFAULT_PYTHON_ETL_ID]", - "state": { - "channel": "CURRENT", - "deployment": { - "kind": "BUNDLE", - "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/state/metadata.json" - }, - "development": true, - "edition": "ADVANCED", - "environment": { - "dependencies": [ - "--editable /Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files" - ] - }, - "libraries": [ - { - "glob": { - "include": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files/src/my_default_python_etl/transformations/**" - } - } - ], - "name": "[dev [USERNAME]] my_default_python_etl", - "root_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files/src/my_default_python_etl", - "schema": "[USERNAME]", - "tags": { - "dev": "[USERNAME]" - } - } - } - } -} diff --git a/acceptance/bundle/migrate/command/default-python/output.txt b/acceptance/bundle/migrate/command/default-python/output.txt index 8212f47a6c9..b78910d2103 100644 --- a/acceptance/bundle/migrate/command/default-python/output.txt +++ b/acceptance/bundle/migrate/command/default-python/output.txt @@ -18,248 +18,37 @@ To get started, refer to the project README.md file and the documentation at htt >>> [CLI] bundle deployment migrate Building python_artifact... -Success! Migrated 2 resources to direct engine state file: [TEST_TMP_DIR]/my_default_python/.databricks/bundle/dev/resources.json - -Validate the migration by running "databricks bundle plan", there should be no actions planned. - -The state file is not synchronized to the workspace yet. To do that and finalize the migration, run "bundle deploy". - -To undo the migration, remove [TEST_TMP_DIR]/my_default_python/.databricks/bundle/dev/resources.json and rename [TEST_TMP_DIR]/my_default_python/.databricks/bundle/dev/terraform/terraform.tfstate.backup to [TEST_TMP_DIR]/my_default_python/.databricks/bundle/dev/terraform/terraform.tfstate - - ->>> print_state.py - ->>> jq .. | .libraries? | select(.) ../out.state_after_migration.json -[ - { - "whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl" - } -] -[ - { - "whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl" - } -] -[ - { - "glob": { - "include": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files/src/my_default_python_etl/transformations/**" - } - } -] - ->>> DATABRICKS_BUNDLE_ENGINE=direct [CLI] bundle plan -Building python_artifact... -update jobs.sample_job - -Plan: 0 to add, 1 to change, 0 to delete, 1 unchanged - ->>> DATABRICKS_BUNDLE_ENGINE=direct [CLI] bundle plan -o json -Building python_artifact... - ->>> jq .plan[] | .changes ../out.plan_after_migration.json -{ - "email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='notebook_task'].email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='notebook_task'].libraries[0].whl": { - "action": "update", - "old": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl", - "new": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl", - "remote": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][2]-py3-none-any.whl" - }, - "tasks[task_key='notebook_task'].notebook_task.source": { - "action": "skip", - "reason": "backend_default", - "remote": "WORKSPACE" - }, - "tasks[task_key='notebook_task'].run_if": { - "action": "skip", - "reason": "backend_default", - "remote": "ALL_SUCCESS" - }, - "tasks[task_key='notebook_task'].timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "tasks[task_key='python_wheel_task'].email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='python_wheel_task'].libraries[0].whl": { - "action": "update", - "old": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl", - "new": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl", - "remote": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][2]-py3-none-any.whl" - }, - "tasks[task_key='python_wheel_task'].run_if": { - "action": "skip", - "reason": "backend_default", - "remote": "ALL_SUCCESS" - }, - "tasks[task_key='python_wheel_task'].timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "tasks[task_key='refresh_pipeline'].email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='refresh_pipeline'].run_if": { - "action": "skip", - "reason": "backend_default", - "remote": "ALL_SUCCESS" - }, - "tasks[task_key='refresh_pipeline'].timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "webhook_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - } -} -{ - "storage": { - "action": "skip", - "reason": "immutable_backend_value", - "remote": "dbfs:/pipelines/[MY_DEFAULT_PYTHON_ETL_ID]" - } -} - ->>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle deploy -Building python_artifact... -Uploading .databricks/bundle/dev/patched_wheels/python_artifact_my_default_python/my_default_python-0.0.1+[UNIX_TIME_NANOS][3]-py3-none-any.whl... -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/files... -Updated jobs.sample_job -Files: 20 uploaded, 0 deleted -Resources: 0 created, 1 changed, 0 deleted, 1 unchanged - ->>> print_state.py - ->>> diff.py ../out.state_after_migration.json ../out.state_after_deploy.json ---- ../out.state_after_migration.json -+++ ../out.state_after_deploy.json -@@ -3,5 +3,5 @@ - "cli_version": "[CLI_VERSION]", - "lineage": "[UUID]", -- "serial": 5, -+ "serial": 6, - "state": { - "resources.jobs.sample_job": { - -=== Extra plan: should have no drift ->>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle plan -Building python_artifact... -update jobs.sample_job - -Plan: 0 to add, 1 to change, 0 to delete, 1 unchanged - ->>> DATABRICKS_BUNDLE_ENGINE=direct [CLI] bundle plan -o json -Building python_artifact... - ->>> jq .plan[] | .changes ../out.plan_after_migration.json -{ - "email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='notebook_task'].email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='notebook_task'].libraries[0].whl": { - "action": "update", - "old": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl", - "new": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl", - "remote": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][2]-py3-none-any.whl" - }, - "tasks[task_key='notebook_task'].notebook_task.source": { - "action": "skip", - "reason": "backend_default", - "remote": "WORKSPACE" - }, - "tasks[task_key='notebook_task'].run_if": { - "action": "skip", - "reason": "backend_default", - "remote": "ALL_SUCCESS" - }, - "tasks[task_key='notebook_task'].timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "tasks[task_key='python_wheel_task'].email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='python_wheel_task'].libraries[0].whl": { - "action": "update", - "old": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][0]-py3-none-any.whl", - "new": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][1]-py3-none-any.whl", - "remote": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/dev/artifacts/.internal/my_default_python-0.0.1+[UNIX_TIME_NANOS][2]-py3-none-any.whl" - }, - "tasks[task_key='python_wheel_task'].run_if": { - "action": "skip", - "reason": "backend_default", - "remote": "ALL_SUCCESS" - }, - "tasks[task_key='python_wheel_task'].timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "tasks[task_key='refresh_pipeline'].email_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - }, - "tasks[task_key='refresh_pipeline'].run_if": { - "action": "skip", - "reason": "backend_default", - "remote": "ALL_SUCCESS" - }, - "tasks[task_key='refresh_pipeline'].timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "timeout_seconds": { - "action": "skip", - "reason": "empty", - "remote": 0 - }, - "webhook_notifications": { - "action": "skip", - "reason": "empty", - "remote": {} - } -} -{ - "storage": { - "action": "skip", - "reason": "immutable_backend_value", - "remote": "dbfs:/pipelines/[MY_DEFAULT_PYTHON_ETL_ID]" - } -} +Error: build failed python_artifact, error: exit status 2, output: Building wheel... + × Failed to build + │ `[TEST_TMP_DIR]/my_default_python` + ├─▶ Failed to resolve requirements from `build-system.requires` + ├─▶ No solution found when resolving: `hatchling` + ╰─▶ Because only the following versions of tomli{python_full_version < + '3.11'} are available: + tomli{python_full_version < '3.11'}<=1.2.2 + tomli{python_full_version < '3.11'}==1.2.3 + tomli{python_full_version < '3.11'}==2.0.0 + tomli{python_full_version < '3.11'}==2.0.1 + tomli{python_full_version < '3.11'}==2.0.2 + tomli{python_full_version < '3.11'}==2.1.0 + tomli{python_full_version < '3.11'}==2.2.1 + tomli{python_full_version < '3.11'}==2.3.0 + tomli{python_full_version < '3.11'}==2.3.1 + tomli{python_full_version < '3.11'}==2.3.2 + tomli{python_full_version < '3.11'}==2.4.0 + tomli{python_full_version < '3.11'}==2.4.1 + tomli{python_full_version < '3.11'}==2.5.0 + and tomli>=1.2.2 needs to be downloaded from a registry, we can conclude + that tomli{python_full_version < '3.11'}>=1.2.2,<1.2.3 cannot be used. + And because hatchling==1.27.0 depends on tomli{python_full_version < + '3.11'}>=1.2.2, we can conclude that hatchling==1.27.0 cannot be used. + And because only hatchling==1.27.0 is available and you require + hatchling, we can conclude that your requirements are unsatisfiable. + + hint: Packages were unavailable because the network was disabled. When + the network is disabled, registry packages may only be read from the + cache. + + + +Exit code: 1 diff --git a/acceptance/bundle/migrate/command/runas/out.plan.json b/acceptance/bundle/migrate/command/runas/out.plan.json index 3c6a3717007..74a159ce561 100644 --- a/acceptance/bundle/migrate/command/runas/out.plan.json +++ b/acceptance/bundle/migrate/command/runas/out.plan.json @@ -9,15 +9,12 @@ "remote_state": { "catalog": "main", "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/dabs_revenue-[UNIQUE_NAME]/production/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[UUID]", - "last_modified": [UNIX_TIME_MILLIS], "libraries": [ { "notebook": { @@ -26,14 +23,17 @@ } ], "name": "DABs Revenue Pipeline", - "pipeline_id": "[UUID]", "run_as": { "service_principal_name": "[UUID]" }, - "run_as_user_name": "[USERNAME]", "serverless": true, - "state": "IDLE", - "target": "team_eng_deco" + "target": "team_eng_deco", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], + "pipeline_id": "[UUID]", + "run_as_user_name": "[USERNAME]", + "state": "IDLE" } }, "resources.pipelines.foo.permissions": { diff --git a/acceptance/bundle/override/clusters/output.txt b/acceptance/bundle/override/clusters/output.txt index 1c26581d399..9e258c8fb79 100644 --- a/acceptance/bundle/override/clusters/output.txt +++ b/acceptance/bundle/override/clusters/output.txt @@ -1,5 +1,9 @@ >>> [CLI] bundle validate -o json -t default +Warning: num_workers is ignored because autoscale is set + at resources.clusters.foo.num_workers + in databricks.yml:8:20 + { "autoscale": { "max_workers": 7, @@ -8,7 +12,6 @@ "autotermination_minutes": 60, "cluster_name": "foo", "node_type_id": "[NODE_TYPE_ID]", - "num_workers": 2, "spark_conf": { "spark.executor.memory": "2g" }, @@ -16,6 +19,11 @@ } >>> [CLI] bundle validate -o json -t development +Warning: num_workers is ignored because autoscale is set + at resources.clusters.foo.num_workers + in databricks.yml:25:24 + databricks.yml:8:20 + { "autoscale": { "max_workers": 3, @@ -24,7 +32,6 @@ "autotermination_minutes": 60, "cluster_name": "foo-override", "node_type_id": "m5.xlarge", - "num_workers": 3, "spark_conf": { "spark.executor.memory": "4g", "spark.executor.memory2": "4g" diff --git a/acceptance/bundle/python/pipeline-development-mutator/output.txt b/acceptance/bundle/python/pipeline-development-mutator/output.txt index c281946ba91..6efa8a68468 100644 --- a/acceptance/bundle/python/pipeline-development-mutator/output.txt +++ b/acceptance/bundle/python/pipeline-development-mutator/output.txt @@ -50,6 +50,7 @@ Update ID: [UUID] "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", "body": { - "development": true + "development": true, + "pipeline_id": "[UUID]" } } diff --git a/acceptance/bundle/refschema/out.fields.txt b/acceptance/bundle/refschema/out.fields.txt index 2c8056be91c..19ee3cca9b8 100644 --- a/acceptance/bundle/refschema/out.fields.txt +++ b/acceptance/bundle/refschema/out.fields.txt @@ -1,112 +1,113 @@ -resources.alerts.*.create_time string ALL -resources.alerts.*.custom_description string ALL -resources.alerts.*.custom_summary string ALL -resources.alerts.*.custom_template_format sql.CustomTemplateFormat ALL -resources.alerts.*.display_name string ALL -resources.alerts.*.effective_run_as *sql.AlertV2RunAs ALL -resources.alerts.*.effective_run_as.service_principal_name string ALL -resources.alerts.*.effective_run_as.user_name string ALL -resources.alerts.*.evaluation sql.AlertV2Evaluation ALL -resources.alerts.*.evaluation.comparison_operator sql.ComparisonOperator ALL -resources.alerts.*.evaluation.empty_result_state sql.AlertEvaluationState ALL -resources.alerts.*.evaluation.last_evaluated_at string ALL -resources.alerts.*.evaluation.notification *sql.AlertV2Notification ALL -resources.alerts.*.evaluation.notification.notify_on_ok bool ALL -resources.alerts.*.evaluation.notification.retrigger_seconds int ALL -resources.alerts.*.evaluation.notification.subscriptions []sql.AlertV2Subscription ALL -resources.alerts.*.evaluation.notification.subscriptions[*] sql.AlertV2Subscription ALL -resources.alerts.*.evaluation.notification.subscriptions[*].destination_id string ALL -resources.alerts.*.evaluation.notification.subscriptions[*].user_email string ALL -resources.alerts.*.evaluation.source sql.AlertV2OperandColumn ALL -resources.alerts.*.evaluation.source.aggregation sql.Aggregation ALL -resources.alerts.*.evaluation.source.display string ALL -resources.alerts.*.evaluation.source.name string ALL -resources.alerts.*.evaluation.state sql.AlertEvaluationState ALL -resources.alerts.*.evaluation.threshold *sql.AlertV2Operand ALL -resources.alerts.*.evaluation.threshold.column *sql.AlertV2OperandColumn ALL -resources.alerts.*.evaluation.threshold.column.aggregation sql.Aggregation ALL -resources.alerts.*.evaluation.threshold.column.display string ALL -resources.alerts.*.evaluation.threshold.column.name string ALL -resources.alerts.*.evaluation.threshold.value *sql.AlertV2OperandValue ALL -resources.alerts.*.evaluation.threshold.value.bool_value bool ALL -resources.alerts.*.evaluation.threshold.value.double_value float64 ALL -resources.alerts.*.evaluation.threshold.value.string_value string ALL +resources.alerts.*.create_time *types.Time ALL +resources.alerts.*.custom_description *string ALL +resources.alerts.*.custom_summary *string ALL +resources.alerts.*.custom_template_format alerts.CustomTemplateFormat ALL +resources.alerts.*.display_name *string ALL +resources.alerts.*.effective_run_as *alerts.AlertRunAs ALL +resources.alerts.*.effective_run_as.service_principal_name *string ALL +resources.alerts.*.effective_run_as.user_name *string ALL +resources.alerts.*.evaluation *alerts.AlertEvaluation ALL +resources.alerts.*.evaluation.comparison_operator alerts.ComparisonOperator ALL +resources.alerts.*.evaluation.empty_result_state alerts.AlertEvaluationState ALL +resources.alerts.*.evaluation.last_evaluated_at *types.Time ALL +resources.alerts.*.evaluation.notification *alerts.AlertNotification ALL +resources.alerts.*.evaluation.notification.notify_on_ok *bool ALL +resources.alerts.*.evaluation.notification.retrigger_seconds *int ALL +resources.alerts.*.evaluation.notification.subscriptions []alerts.AlertSubscription ALL +resources.alerts.*.evaluation.notification.subscriptions[*] alerts.AlertSubscription ALL +resources.alerts.*.evaluation.notification.subscriptions[*].destination_id *string ALL +resources.alerts.*.evaluation.notification.subscriptions[*].user_email *string ALL +resources.alerts.*.evaluation.source *alerts.AlertOperandColumn ALL +resources.alerts.*.evaluation.source.aggregation alerts.Aggregation ALL +resources.alerts.*.evaluation.source.display *string ALL +resources.alerts.*.evaluation.source.name *string ALL +resources.alerts.*.evaluation.state alerts.AlertEvaluationState ALL +resources.alerts.*.evaluation.threshold *alerts.AlertOperand ALL +resources.alerts.*.evaluation.threshold.column *alerts.AlertOperandColumn ALL +resources.alerts.*.evaluation.threshold.column.aggregation alerts.Aggregation ALL +resources.alerts.*.evaluation.threshold.column.display *string ALL +resources.alerts.*.evaluation.threshold.column.name *string ALL +resources.alerts.*.evaluation.threshold.value *alerts.AlertOperandValue ALL +resources.alerts.*.evaluation.threshold.value.bool_value *bool ALL +resources.alerts.*.evaluation.threshold.value.double_value *float64 ALL +resources.alerts.*.evaluation.threshold.value.string_value *string ALL resources.alerts.*.file_path string INPUT -resources.alerts.*.id string ALL +resources.alerts.*.id *string ALL +resources.alerts.*.id string INPUT resources.alerts.*.lifecycle resources.Lifecycle INPUT resources.alerts.*.lifecycle.prevent_destroy bool INPUT -resources.alerts.*.lifecycle_state sql.AlertLifecycleState ALL +resources.alerts.*.lifecycle_state alerts.AlertLifecycleState ALL resources.alerts.*.modified_status string INPUT -resources.alerts.*.owner_user_name string ALL -resources.alerts.*.parameters []sql.AlertStatementParameter ALL -resources.alerts.*.parameters[*] sql.AlertStatementParameter ALL -resources.alerts.*.parameters[*].name string ALL -resources.alerts.*.parameters[*].type string ALL -resources.alerts.*.parameters[*].value string ALL -resources.alerts.*.parent_path string ALL -resources.alerts.*.query_text string ALL -resources.alerts.*.run_as *sql.AlertV2RunAs ALL -resources.alerts.*.run_as.service_principal_name string ALL -resources.alerts.*.run_as.user_name string ALL -resources.alerts.*.run_as_user_name string ALL -resources.alerts.*.schedule sql.CronSchedule ALL -resources.alerts.*.schedule.pause_status sql.SchedulePauseStatus ALL -resources.alerts.*.schedule.quartz_cron_schedule string ALL -resources.alerts.*.schedule.timezone_id string ALL -resources.alerts.*.update_time string ALL +resources.alerts.*.owner_user_name *string ALL +resources.alerts.*.parameters []alerts.AlertStatementParameter ALL +resources.alerts.*.parameters[*] alerts.AlertStatementParameter ALL +resources.alerts.*.parameters[*].name *string ALL +resources.alerts.*.parameters[*].type *string ALL +resources.alerts.*.parameters[*].value *string ALL +resources.alerts.*.parent_path *string ALL +resources.alerts.*.query_text *string ALL +resources.alerts.*.run_as *alerts.AlertRunAs ALL +resources.alerts.*.run_as.service_principal_name *string ALL +resources.alerts.*.run_as.user_name *string ALL +resources.alerts.*.run_as_user_name *string ALL +resources.alerts.*.schedule *alerts.CronSchedule ALL +resources.alerts.*.schedule.pause_status alerts.SchedulePauseStatus ALL +resources.alerts.*.schedule.quartz_cron_schedule *string ALL +resources.alerts.*.schedule.timezone_id *string ALL +resources.alerts.*.update_time *types.Time ALL resources.alerts.*.url string INPUT -resources.alerts.*.warehouse_id string ALL +resources.alerts.*.warehouse_id *string ALL resources.alerts.*.permissions.object_id string ALL resources.alerts.*.permissions[*] dresources.StatePermission ALL resources.alerts.*.permissions[*].group_name string ALL -resources.alerts.*.permissions[*].level iam.PermissionLevel ALL +resources.alerts.*.permissions[*].level resources.PermissionLevel ALL resources.alerts.*.permissions[*].service_principal_name string ALL resources.alerts.*.permissions[*].user_name string ALL resources.apps.*.active_deployment *apps.AppDeployment ALL resources.apps.*.active_deployment.command []string ALL resources.apps.*.active_deployment.command[*] string ALL -resources.apps.*.active_deployment.create_time string ALL -resources.apps.*.active_deployment.creator string ALL +resources.apps.*.active_deployment.create_time *types.Time ALL +resources.apps.*.active_deployment.creator *string ALL resources.apps.*.active_deployment.deployment_artifacts *apps.AppDeploymentArtifacts ALL -resources.apps.*.active_deployment.deployment_artifacts.source_code_path string ALL -resources.apps.*.active_deployment.deployment_id string ALL +resources.apps.*.active_deployment.deployment_artifacts.source_code_path *string ALL +resources.apps.*.active_deployment.deployment_id *string ALL resources.apps.*.active_deployment.env_vars []apps.EnvVar ALL resources.apps.*.active_deployment.env_vars[*] apps.EnvVar ALL -resources.apps.*.active_deployment.env_vars[*].name string ALL -resources.apps.*.active_deployment.env_vars[*].value string ALL -resources.apps.*.active_deployment.env_vars[*].value_from string ALL +resources.apps.*.active_deployment.env_vars[*].name *string ALL +resources.apps.*.active_deployment.env_vars[*].value *string ALL +resources.apps.*.active_deployment.env_vars[*].value_from *string ALL resources.apps.*.active_deployment.git_source *apps.GitSource ALL -resources.apps.*.active_deployment.git_source.branch string ALL -resources.apps.*.active_deployment.git_source.commit string ALL +resources.apps.*.active_deployment.git_source.branch *string ALL +resources.apps.*.active_deployment.git_source.commit *string ALL resources.apps.*.active_deployment.git_source.git_repository *apps.GitRepository ALL -resources.apps.*.active_deployment.git_source.git_repository.auto_deploy bool ALL -resources.apps.*.active_deployment.git_source.git_repository.caller_credential_id int64 ALL -resources.apps.*.active_deployment.git_source.git_repository.provider string ALL -resources.apps.*.active_deployment.git_source.git_repository.url string ALL -resources.apps.*.active_deployment.git_source.resolved_commit string ALL -resources.apps.*.active_deployment.git_source.source_code_path string ALL -resources.apps.*.active_deployment.git_source.tag string ALL +resources.apps.*.active_deployment.git_source.git_repository.auto_deploy *bool ALL +resources.apps.*.active_deployment.git_source.git_repository.caller_credential_id *int64 ALL +resources.apps.*.active_deployment.git_source.git_repository.provider *string ALL +resources.apps.*.active_deployment.git_source.git_repository.url *string ALL +resources.apps.*.active_deployment.git_source.resolved_commit *string ALL +resources.apps.*.active_deployment.git_source.source_code_path *string ALL +resources.apps.*.active_deployment.git_source.tag *string ALL resources.apps.*.active_deployment.health_check *apps.AppHealthCheck ALL -resources.apps.*.active_deployment.health_check.path string ALL -resources.apps.*.active_deployment.health_check.timeout *duration.Duration ALL -resources.apps.*.active_deployment.mode apps.AppDeploymentMode ALL -resources.apps.*.active_deployment.source_code_path string ALL +resources.apps.*.active_deployment.health_check.path *string ALL +resources.apps.*.active_deployment.health_check.timeout *types.Duration ALL +resources.apps.*.active_deployment.mode apps.AppDeployment_Mode ALL +resources.apps.*.active_deployment.source_code_path *string ALL resources.apps.*.active_deployment.status *apps.AppDeploymentStatus ALL -resources.apps.*.active_deployment.status.message string ALL -resources.apps.*.active_deployment.status.state apps.AppDeploymentState ALL -resources.apps.*.active_deployment.update_time string ALL +resources.apps.*.active_deployment.status.message *string ALL +resources.apps.*.active_deployment.status.state apps.AppDeployment_State ALL +resources.apps.*.active_deployment.update_time *types.Time ALL resources.apps.*.app_status *apps.ApplicationStatus ALL -resources.apps.*.app_status.message string ALL -resources.apps.*.app_status.running_instances int ALL -resources.apps.*.app_status.state apps.ApplicationState ALL -resources.apps.*.budget_policy_id string ALL -resources.apps.*.compute_max_instances int ALL -resources.apps.*.compute_min_instances int ALL +resources.apps.*.app_status.message *string ALL +resources.apps.*.app_status.running_instances *int ALL +resources.apps.*.app_status.state apps.ApplicationStatus_ApplicationState ALL +resources.apps.*.budget_policy_id *string ALL +resources.apps.*.compute_max_instances *int ALL +resources.apps.*.compute_min_instances *int ALL resources.apps.*.compute_size apps.ComputeSize ALL resources.apps.*.compute_status *apps.ComputeStatus ALL -resources.apps.*.compute_status.active_instances int ALL -resources.apps.*.compute_status.message string ALL -resources.apps.*.compute_status.state apps.ComputeState ALL +resources.apps.*.compute_status.active_instances *int ALL +resources.apps.*.compute_status.message *string ALL +resources.apps.*.compute_status.state apps.ComputeStatus_ComputeState ALL resources.apps.*.config *resources.AppConfig ALL resources.apps.*.config.command []string ALL resources.apps.*.config.command[*] string ALL @@ -115,533 +116,536 @@ resources.apps.*.config.env[*] resources.AppEnvVar ALL resources.apps.*.config.env[*].name string ALL resources.apps.*.config.env[*].value string ALL resources.apps.*.config.env[*].value_from string ALL -resources.apps.*.create_time string ALL -resources.apps.*.creator string ALL +resources.apps.*.create_time *types.Time ALL +resources.apps.*.creator *string ALL resources.apps.*.default_git_source *apps.GitSource ALL -resources.apps.*.default_git_source.branch string ALL -resources.apps.*.default_git_source.commit string ALL +resources.apps.*.default_git_source.branch *string ALL +resources.apps.*.default_git_source.commit *string ALL resources.apps.*.default_git_source.git_repository *apps.GitRepository ALL -resources.apps.*.default_git_source.git_repository.auto_deploy bool ALL -resources.apps.*.default_git_source.git_repository.caller_credential_id int64 ALL -resources.apps.*.default_git_source.git_repository.provider string ALL -resources.apps.*.default_git_source.git_repository.url string ALL -resources.apps.*.default_git_source.resolved_commit string ALL -resources.apps.*.default_git_source.source_code_path string ALL -resources.apps.*.default_git_source.tag string ALL -resources.apps.*.default_source_code_path string ALL -resources.apps.*.description string ALL -resources.apps.*.effective_budget_policy_id string ALL -resources.apps.*.effective_usage_policy_id string ALL +resources.apps.*.default_git_source.git_repository.auto_deploy *bool ALL +resources.apps.*.default_git_source.git_repository.caller_credential_id *int64 ALL +resources.apps.*.default_git_source.git_repository.provider *string ALL +resources.apps.*.default_git_source.git_repository.url *string ALL +resources.apps.*.default_git_source.resolved_commit *string ALL +resources.apps.*.default_git_source.source_code_path *string ALL +resources.apps.*.default_git_source.tag *string ALL +resources.apps.*.default_source_code_path *string ALL +resources.apps.*.description *string ALL +resources.apps.*.effective_budget_policy_id *string ALL +resources.apps.*.effective_usage_policy_id *string ALL resources.apps.*.effective_user_api_scopes []string ALL resources.apps.*.effective_user_api_scopes[*] string ALL -resources.apps.*.forward_user_access_token bool ALL +resources.apps.*.forward_user_access_token *bool ALL resources.apps.*.git_repository *apps.GitRepository ALL -resources.apps.*.git_repository.auto_deploy bool ALL -resources.apps.*.git_repository.caller_credential_id int64 ALL -resources.apps.*.git_repository.provider string ALL -resources.apps.*.git_repository.url string ALL +resources.apps.*.git_repository.auto_deploy *bool ALL +resources.apps.*.git_repository.caller_credential_id *int64 ALL +resources.apps.*.git_repository.provider *string ALL +resources.apps.*.git_repository.url *string ALL resources.apps.*.git_source *apps.GitSource ALL -resources.apps.*.git_source.branch string ALL -resources.apps.*.git_source.commit string ALL +resources.apps.*.git_source.branch *string ALL +resources.apps.*.git_source.commit *string ALL resources.apps.*.git_source.git_repository *apps.GitRepository ALL -resources.apps.*.git_source.git_repository.auto_deploy bool ALL -resources.apps.*.git_source.git_repository.caller_credential_id int64 ALL -resources.apps.*.git_source.git_repository.provider string ALL -resources.apps.*.git_source.git_repository.url string ALL -resources.apps.*.git_source.resolved_commit string ALL -resources.apps.*.git_source.source_code_path string ALL -resources.apps.*.git_source.tag string ALL -resources.apps.*.id string ALL +resources.apps.*.git_source.git_repository.auto_deploy *bool ALL +resources.apps.*.git_source.git_repository.caller_credential_id *int64 ALL +resources.apps.*.git_source.git_repository.provider *string ALL +resources.apps.*.git_source.git_repository.url *string ALL +resources.apps.*.git_source.resolved_commit *string ALL +resources.apps.*.git_source.source_code_path *string ALL +resources.apps.*.git_source.tag *string ALL +resources.apps.*.id *string ALL +resources.apps.*.id string INPUT resources.apps.*.lifecycle *dresources.StateLifecycle REMOTE STATE resources.apps.*.lifecycle *resources.LifecycleWithStarted INPUT resources.apps.*.lifecycle resources.Lifecycle INPUT resources.apps.*.lifecycle.prevent_destroy bool INPUT resources.apps.*.lifecycle.started *bool ALL resources.apps.*.modified_status string INPUT -resources.apps.*.name string ALL -resources.apps.*.oauth2_app_client_id string ALL -resources.apps.*.oauth2_app_integration_id string ALL +resources.apps.*.name *string ALL +resources.apps.*.oauth2_app_client_id *string ALL +resources.apps.*.oauth2_app_integration_id *string ALL resources.apps.*.pending_deployment *apps.AppDeployment ALL resources.apps.*.pending_deployment.command []string ALL resources.apps.*.pending_deployment.command[*] string ALL -resources.apps.*.pending_deployment.create_time string ALL -resources.apps.*.pending_deployment.creator string ALL +resources.apps.*.pending_deployment.create_time *types.Time ALL +resources.apps.*.pending_deployment.creator *string ALL resources.apps.*.pending_deployment.deployment_artifacts *apps.AppDeploymentArtifacts ALL -resources.apps.*.pending_deployment.deployment_artifacts.source_code_path string ALL -resources.apps.*.pending_deployment.deployment_id string ALL +resources.apps.*.pending_deployment.deployment_artifacts.source_code_path *string ALL +resources.apps.*.pending_deployment.deployment_id *string ALL resources.apps.*.pending_deployment.env_vars []apps.EnvVar ALL resources.apps.*.pending_deployment.env_vars[*] apps.EnvVar ALL -resources.apps.*.pending_deployment.env_vars[*].name string ALL -resources.apps.*.pending_deployment.env_vars[*].value string ALL -resources.apps.*.pending_deployment.env_vars[*].value_from string ALL +resources.apps.*.pending_deployment.env_vars[*].name *string ALL +resources.apps.*.pending_deployment.env_vars[*].value *string ALL +resources.apps.*.pending_deployment.env_vars[*].value_from *string ALL resources.apps.*.pending_deployment.git_source *apps.GitSource ALL -resources.apps.*.pending_deployment.git_source.branch string ALL -resources.apps.*.pending_deployment.git_source.commit string ALL +resources.apps.*.pending_deployment.git_source.branch *string ALL +resources.apps.*.pending_deployment.git_source.commit *string ALL resources.apps.*.pending_deployment.git_source.git_repository *apps.GitRepository ALL -resources.apps.*.pending_deployment.git_source.git_repository.auto_deploy bool ALL -resources.apps.*.pending_deployment.git_source.git_repository.caller_credential_id int64 ALL -resources.apps.*.pending_deployment.git_source.git_repository.provider string ALL -resources.apps.*.pending_deployment.git_source.git_repository.url string ALL -resources.apps.*.pending_deployment.git_source.resolved_commit string ALL -resources.apps.*.pending_deployment.git_source.source_code_path string ALL -resources.apps.*.pending_deployment.git_source.tag string ALL +resources.apps.*.pending_deployment.git_source.git_repository.auto_deploy *bool ALL +resources.apps.*.pending_deployment.git_source.git_repository.caller_credential_id *int64 ALL +resources.apps.*.pending_deployment.git_source.git_repository.provider *string ALL +resources.apps.*.pending_deployment.git_source.git_repository.url *string ALL +resources.apps.*.pending_deployment.git_source.resolved_commit *string ALL +resources.apps.*.pending_deployment.git_source.source_code_path *string ALL +resources.apps.*.pending_deployment.git_source.tag *string ALL resources.apps.*.pending_deployment.health_check *apps.AppHealthCheck ALL -resources.apps.*.pending_deployment.health_check.path string ALL -resources.apps.*.pending_deployment.health_check.timeout *duration.Duration ALL -resources.apps.*.pending_deployment.mode apps.AppDeploymentMode ALL -resources.apps.*.pending_deployment.source_code_path string ALL +resources.apps.*.pending_deployment.health_check.path *string ALL +resources.apps.*.pending_deployment.health_check.timeout *types.Duration ALL +resources.apps.*.pending_deployment.mode apps.AppDeployment_Mode ALL +resources.apps.*.pending_deployment.source_code_path *string ALL resources.apps.*.pending_deployment.status *apps.AppDeploymentStatus ALL -resources.apps.*.pending_deployment.status.message string ALL -resources.apps.*.pending_deployment.status.state apps.AppDeploymentState ALL -resources.apps.*.pending_deployment.update_time string ALL +resources.apps.*.pending_deployment.status.message *string ALL +resources.apps.*.pending_deployment.status.state apps.AppDeployment_State ALL +resources.apps.*.pending_deployment.update_time *types.Time ALL resources.apps.*.resources []apps.AppResource ALL resources.apps.*.resources[*] apps.AppResource ALL resources.apps.*.resources[*].app *apps.AppResourceApp ALL -resources.apps.*.resources[*].app.name string ALL -resources.apps.*.resources[*].app.permission apps.AppResourceAppAppPermission ALL +resources.apps.*.resources[*].app.name *string ALL +resources.apps.*.resources[*].app.permission apps.AppResourceApp_AppPermission ALL resources.apps.*.resources[*].database *apps.AppResourceDatabase ALL -resources.apps.*.resources[*].database.database_name string ALL -resources.apps.*.resources[*].database.instance_name string ALL -resources.apps.*.resources[*].database.permission apps.AppResourceDatabaseDatabasePermission ALL -resources.apps.*.resources[*].description string ALL +resources.apps.*.resources[*].database.database_name *string ALL +resources.apps.*.resources[*].database.instance_name *string ALL +resources.apps.*.resources[*].database.permission apps.AppResourceDatabase_DatabasePermission ALL +resources.apps.*.resources[*].description *string ALL resources.apps.*.resources[*].experiment *apps.AppResourceExperiment ALL -resources.apps.*.resources[*].experiment.experiment_id string ALL -resources.apps.*.resources[*].experiment.permission apps.AppResourceExperimentExperimentPermission ALL +resources.apps.*.resources[*].experiment.experiment_id *string ALL +resources.apps.*.resources[*].experiment.permission apps.AppResourceExperiment_ExperimentPermission ALL resources.apps.*.resources[*].genie_space *apps.AppResourceGenieSpace ALL -resources.apps.*.resources[*].genie_space.name string ALL -resources.apps.*.resources[*].genie_space.permission apps.AppResourceGenieSpaceGenieSpacePermission ALL -resources.apps.*.resources[*].genie_space.space_id string ALL +resources.apps.*.resources[*].genie_space.name *string ALL +resources.apps.*.resources[*].genie_space.permission apps.AppResourceGenieSpace_GenieSpacePermission ALL +resources.apps.*.resources[*].genie_space.space_id *string ALL resources.apps.*.resources[*].job *apps.AppResourceJob ALL -resources.apps.*.resources[*].job.id string ALL -resources.apps.*.resources[*].job.permission apps.AppResourceJobJobPermission ALL -resources.apps.*.resources[*].name string ALL +resources.apps.*.resources[*].job.id *string ALL +resources.apps.*.resources[*].job.permission apps.AppResourceJob_JobPermission ALL +resources.apps.*.resources[*].name *string ALL resources.apps.*.resources[*].postgres *apps.AppResourcePostgres ALL -resources.apps.*.resources[*].postgres.branch string ALL -resources.apps.*.resources[*].postgres.database string ALL -resources.apps.*.resources[*].postgres.permission apps.AppResourcePostgresPostgresPermission ALL +resources.apps.*.resources[*].postgres.branch *string ALL +resources.apps.*.resources[*].postgres.database *string ALL +resources.apps.*.resources[*].postgres.permission apps.AppResourcePostgres_PostgresPermission ALL resources.apps.*.resources[*].secret *apps.AppResourceSecret ALL -resources.apps.*.resources[*].secret.key string ALL -resources.apps.*.resources[*].secret.permission apps.AppResourceSecretSecretPermission ALL -resources.apps.*.resources[*].secret.scope string ALL +resources.apps.*.resources[*].secret.key *string ALL +resources.apps.*.resources[*].secret.permission apps.AppResourceSecret_SecretPermission ALL +resources.apps.*.resources[*].secret.scope *string ALL resources.apps.*.resources[*].serving_endpoint *apps.AppResourceServingEndpoint ALL -resources.apps.*.resources[*].serving_endpoint.name string ALL -resources.apps.*.resources[*].serving_endpoint.permission apps.AppResourceServingEndpointServingEndpointPermission ALL +resources.apps.*.resources[*].serving_endpoint.name *string ALL +resources.apps.*.resources[*].serving_endpoint.permission apps.AppResourceServingEndpoint_ServingEndpointPermission ALL resources.apps.*.resources[*].sql_warehouse *apps.AppResourceSqlWarehouse ALL -resources.apps.*.resources[*].sql_warehouse.id string ALL -resources.apps.*.resources[*].sql_warehouse.permission apps.AppResourceSqlWarehouseSqlWarehousePermission ALL +resources.apps.*.resources[*].sql_warehouse.id *string ALL +resources.apps.*.resources[*].sql_warehouse.permission apps.AppResourceSqlWarehouse_SqlWarehousePermission ALL resources.apps.*.resources[*].uc_securable *apps.AppResourceUcSecurable ALL -resources.apps.*.resources[*].uc_securable.permission apps.AppResourceUcSecurableUcSecurablePermission ALL -resources.apps.*.resources[*].uc_securable.securable_full_name string ALL -resources.apps.*.resources[*].uc_securable.securable_kind string ALL -resources.apps.*.resources[*].uc_securable.securable_type apps.AppResourceUcSecurableUcSecurableType ALL -resources.apps.*.service_principal_client_id string ALL -resources.apps.*.service_principal_id int64 ALL -resources.apps.*.service_principal_name string ALL -resources.apps.*.source_code_path string ALL -resources.apps.*.space string ALL +resources.apps.*.resources[*].uc_securable.permission apps.AppResourceUcSecurable_UcSecurablePermission ALL +resources.apps.*.resources[*].uc_securable.securable_full_name *string ALL +resources.apps.*.resources[*].uc_securable.securable_kind *string ALL +resources.apps.*.resources[*].uc_securable.securable_type apps.AppResourceUcSecurable_UcSecurableType ALL +resources.apps.*.service_principal_client_id *string ALL +resources.apps.*.service_principal_id *int64 ALL +resources.apps.*.service_principal_name *string ALL +resources.apps.*.source_code_path *string ALL +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.*.thumbnail_url string ALL -resources.apps.*.update_time string ALL -resources.apps.*.updater string ALL -resources.apps.*.url string ALL -resources.apps.*.usage_policy_id string 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.*.thumbnail_url *string ALL +resources.apps.*.update_time *types.Time ALL +resources.apps.*.updater *string ALL +resources.apps.*.url *string ALL +resources.apps.*.url string INPUT +resources.apps.*.usage_policy_id *string ALL resources.apps.*.user_api_scopes []string ALL resources.apps.*.user_api_scopes[*] string ALL resources.apps.*.permissions.object_id string ALL resources.apps.*.permissions[*] dresources.StatePermission ALL resources.apps.*.permissions[*].group_name string ALL -resources.apps.*.permissions[*].level iam.PermissionLevel ALL +resources.apps.*.permissions[*].level resources.PermissionLevel ALL resources.apps.*.permissions[*].service_principal_name string ALL resources.apps.*.permissions[*].user_name string ALL -resources.catalogs.*.browse_only bool REMOTE -resources.catalogs.*.catalog_type catalog.CatalogType REMOTE -resources.catalogs.*.comment string ALL -resources.catalogs.*.connection_name string ALL -resources.catalogs.*.created_at int64 REMOTE -resources.catalogs.*.created_by string REMOTE -resources.catalogs.*.custom_max_retention_hours int64 ALL -resources.catalogs.*.effective_predictive_optimization_flag *catalog.EffectivePredictiveOptimizationFlag REMOTE -resources.catalogs.*.effective_predictive_optimization_flag.inherited_from_name string REMOTE -resources.catalogs.*.effective_predictive_optimization_flag.inherited_from_type catalog.EffectivePredictiveOptimizationFlagInheritedFromType REMOTE -resources.catalogs.*.effective_predictive_optimization_flag.value catalog.EnablePredictiveOptimization REMOTE -resources.catalogs.*.enable_predictive_optimization catalog.EnablePredictiveOptimization REMOTE -resources.catalogs.*.full_name string REMOTE +resources.catalogs.*.browse_only *bool REMOTE +resources.catalogs.*.catalog_type catalogs.CatalogType REMOTE +resources.catalogs.*.comment *string ALL +resources.catalogs.*.connection_name *string ALL +resources.catalogs.*.created_at *int64 REMOTE +resources.catalogs.*.created_by *string REMOTE +resources.catalogs.*.custom_max_retention_hours *int64 ALL +resources.catalogs.*.effective_predictive_optimization_flag *catalogs.EffectivePredictiveOptimizationFlag REMOTE +resources.catalogs.*.effective_predictive_optimization_flag.inherited_from_name *string REMOTE +resources.catalogs.*.effective_predictive_optimization_flag.inherited_from_type *string REMOTE +resources.catalogs.*.effective_predictive_optimization_flag.value *string REMOTE +resources.catalogs.*.enable_predictive_optimization *string REMOTE +resources.catalogs.*.full_name *string REMOTE resources.catalogs.*.id string INPUT -resources.catalogs.*.isolation_mode catalog.CatalogIsolationMode REMOTE +resources.catalogs.*.isolation_mode catalogs.CatalogIsolationMode REMOTE resources.catalogs.*.lifecycle resources.Lifecycle INPUT resources.catalogs.*.lifecycle.prevent_destroy bool INPUT -resources.catalogs.*.managed_encryption_settings *catalog.EncryptionSettings ALL -resources.catalogs.*.managed_encryption_settings.azure_encryption_settings *catalog.AzureEncryptionSettings ALL -resources.catalogs.*.managed_encryption_settings.azure_encryption_settings.azure_cmk_access_connector_id string ALL -resources.catalogs.*.managed_encryption_settings.azure_encryption_settings.azure_cmk_managed_identity_id string ALL -resources.catalogs.*.managed_encryption_settings.azure_encryption_settings.azure_tenant_id string ALL -resources.catalogs.*.managed_encryption_settings.azure_key_vault_key_id string ALL -resources.catalogs.*.managed_encryption_settings.customer_managed_key_id string ALL -resources.catalogs.*.metastore_id string REMOTE +resources.catalogs.*.managed_encryption_settings *catalogs.EncryptionSettings ALL +resources.catalogs.*.managed_encryption_settings.azure_encryption_settings *catalogs.AzureEncryptionSettings ALL +resources.catalogs.*.managed_encryption_settings.azure_encryption_settings.azure_cmk_access_connector_id *string ALL +resources.catalogs.*.managed_encryption_settings.azure_encryption_settings.azure_cmk_managed_identity_id *string ALL +resources.catalogs.*.managed_encryption_settings.azure_encryption_settings.azure_tenant_id *string ALL +resources.catalogs.*.managed_encryption_settings.azure_key_vault_key_id *string ALL +resources.catalogs.*.managed_encryption_settings.customer_managed_key_id *string ALL +resources.catalogs.*.metastore_id *string REMOTE resources.catalogs.*.modified_status string INPUT -resources.catalogs.*.name string ALL +resources.catalogs.*.name *string ALL resources.catalogs.*.options map[string]string ALL resources.catalogs.*.options.* string ALL -resources.catalogs.*.owner string REMOTE +resources.catalogs.*.owner *string REMOTE resources.catalogs.*.properties map[string]string ALL resources.catalogs.*.properties.* string ALL -resources.catalogs.*.provider_name string ALL -resources.catalogs.*.provisioning_info *catalog.ProvisioningInfo REMOTE -resources.catalogs.*.provisioning_info.state catalog.ProvisioningInfoState REMOTE -resources.catalogs.*.securable_type catalog.SecurableType REMOTE -resources.catalogs.*.share_name string ALL -resources.catalogs.*.storage_location string REMOTE -resources.catalogs.*.storage_root string ALL -resources.catalogs.*.updated_at int64 REMOTE -resources.catalogs.*.updated_by string REMOTE +resources.catalogs.*.provider_name *string ALL +resources.catalogs.*.provisioning_info *catalogs.ProvisioningInfo REMOTE +resources.catalogs.*.provisioning_info.state catalogs.ProvisioningInfo_State REMOTE +resources.catalogs.*.securable_type catalogs.SecurableType REMOTE +resources.catalogs.*.share_name *string ALL +resources.catalogs.*.storage_location *string REMOTE +resources.catalogs.*.storage_root *string ALL +resources.catalogs.*.updated_at *int64 REMOTE +resources.catalogs.*.updated_by *string REMOTE resources.catalogs.*.url string INPUT resources.catalogs.*.grants.full_name string ALL resources.catalogs.*.grants.securable_type string ALL -resources.catalogs.*.grants[*] catalog.PrivilegeAssignment ALL -resources.catalogs.*.grants[*].principal string ALL -resources.catalogs.*.grants[*].privileges []catalog.Privilege ALL -resources.catalogs.*.grants[*].privileges[*] catalog.Privilege ALL -resources.cluster_policies.*.created_at_timestamp int64 REMOTE -resources.cluster_policies.*.creator_user_name string REMOTE +resources.catalogs.*.grants[*] grants.PrivilegeAssignment ALL +resources.catalogs.*.grants[*].principal *string ALL +resources.catalogs.*.grants[*].privileges []string ALL +resources.catalogs.*.grants[*].privileges[*] string ALL +resources.cluster_policies.*.created_at_timestamp *int64 REMOTE +resources.cluster_policies.*.creator_user_name *string REMOTE +resources.cluster_policies.*.definition *string ALL resources.cluster_policies.*.definition any INPUT -resources.cluster_policies.*.definition string ALL -resources.cluster_policies.*.description string ALL +resources.cluster_policies.*.description *string ALL resources.cluster_policies.*.id string INPUT -resources.cluster_policies.*.is_default bool REMOTE -resources.cluster_policies.*.libraries []compute.Library ALL -resources.cluster_policies.*.libraries[*] compute.Library ALL -resources.cluster_policies.*.libraries[*].cran *compute.RCranLibrary ALL -resources.cluster_policies.*.libraries[*].cran.package string ALL -resources.cluster_policies.*.libraries[*].cran.repo string ALL -resources.cluster_policies.*.libraries[*].egg string ALL -resources.cluster_policies.*.libraries[*].jar string ALL -resources.cluster_policies.*.libraries[*].maven *compute.MavenLibrary ALL -resources.cluster_policies.*.libraries[*].maven.coordinates string ALL +resources.cluster_policies.*.is_default *bool REMOTE +resources.cluster_policies.*.libraries []clusterpolicies.Library ALL +resources.cluster_policies.*.libraries[*] clusterpolicies.Library ALL +resources.cluster_policies.*.libraries[*].cran *clusterpolicies.RCranLibrary ALL +resources.cluster_policies.*.libraries[*].cran.package *string ALL +resources.cluster_policies.*.libraries[*].cran.repo *string ALL +resources.cluster_policies.*.libraries[*].egg *string ALL +resources.cluster_policies.*.libraries[*].jar *string ALL +resources.cluster_policies.*.libraries[*].maven *clusterpolicies.MavenLibrary ALL +resources.cluster_policies.*.libraries[*].maven.coordinates *string ALL resources.cluster_policies.*.libraries[*].maven.exclusions []string ALL resources.cluster_policies.*.libraries[*].maven.exclusions[*] string ALL -resources.cluster_policies.*.libraries[*].maven.repo string ALL -resources.cluster_policies.*.libraries[*].pypi *compute.PythonPyPiLibrary ALL -resources.cluster_policies.*.libraries[*].pypi.package string ALL -resources.cluster_policies.*.libraries[*].pypi.repo string ALL -resources.cluster_policies.*.libraries[*].requirements string ALL -resources.cluster_policies.*.libraries[*].whl string ALL +resources.cluster_policies.*.libraries[*].maven.repo *string ALL +resources.cluster_policies.*.libraries[*].pypi *clusterpolicies.PythonPyPiLibrary ALL +resources.cluster_policies.*.libraries[*].pypi.package *string ALL +resources.cluster_policies.*.libraries[*].pypi.repo *string ALL +resources.cluster_policies.*.libraries[*].requirements *string ALL +resources.cluster_policies.*.libraries[*].whl *string ALL resources.cluster_policies.*.lifecycle resources.Lifecycle INPUT resources.cluster_policies.*.lifecycle.prevent_destroy bool INPUT -resources.cluster_policies.*.max_clusters_per_user int64 ALL +resources.cluster_policies.*.max_clusters_per_user *int64 ALL resources.cluster_policies.*.modified_status string INPUT -resources.cluster_policies.*.name string ALL +resources.cluster_policies.*.name *string ALL +resources.cluster_policies.*.policy_family_definition_overrides *string ALL resources.cluster_policies.*.policy_family_definition_overrides any INPUT -resources.cluster_policies.*.policy_family_definition_overrides string ALL -resources.cluster_policies.*.policy_family_id string ALL -resources.cluster_policies.*.policy_id string REMOTE +resources.cluster_policies.*.policy_family_id *string ALL +resources.cluster_policies.*.policy_id *string REMOTE resources.cluster_policies.*.url string INPUT resources.cluster_policies.*.permissions.object_id string ALL resources.cluster_policies.*.permissions[*] dresources.StatePermission ALL resources.cluster_policies.*.permissions[*].group_name string ALL -resources.cluster_policies.*.permissions[*].level iam.PermissionLevel ALL +resources.cluster_policies.*.permissions[*].level resources.PermissionLevel ALL resources.cluster_policies.*.permissions[*].service_principal_name string ALL resources.cluster_policies.*.permissions[*].user_name string ALL -resources.clusters.*.apply_policy_default_values bool ALL -resources.clusters.*.autoscale *compute.AutoScale ALL -resources.clusters.*.autoscale.max_workers int ALL -resources.clusters.*.autoscale.min_workers int ALL -resources.clusters.*.autotermination_minutes int ALL -resources.clusters.*.aws_attributes *compute.AwsAttributes ALL -resources.clusters.*.aws_attributes.availability compute.AwsAvailability ALL -resources.clusters.*.aws_attributes.ebs_volume_count int ALL -resources.clusters.*.aws_attributes.ebs_volume_iops int ALL -resources.clusters.*.aws_attributes.ebs_volume_size int ALL -resources.clusters.*.aws_attributes.ebs_volume_throughput int ALL -resources.clusters.*.aws_attributes.ebs_volume_type compute.EbsVolumeType ALL -resources.clusters.*.aws_attributes.first_on_demand int ALL -resources.clusters.*.aws_attributes.instance_profile_arn string ALL -resources.clusters.*.aws_attributes.spot_bid_price_percent int ALL -resources.clusters.*.aws_attributes.zone_id string ALL -resources.clusters.*.azure_attributes *compute.AzureAttributes ALL -resources.clusters.*.azure_attributes.availability compute.AzureAvailability ALL -resources.clusters.*.azure_attributes.capacity_reservation_group string ALL -resources.clusters.*.azure_attributes.first_on_demand int ALL -resources.clusters.*.azure_attributes.log_analytics_info *compute.LogAnalyticsInfo ALL -resources.clusters.*.azure_attributes.log_analytics_info.log_analytics_primary_key string ALL -resources.clusters.*.azure_attributes.log_analytics_info.log_analytics_workspace_id string ALL -resources.clusters.*.azure_attributes.spot_bid_max_price float64 ALL -resources.clusters.*.cluster_cores float64 REMOTE -resources.clusters.*.cluster_id string REMOTE -resources.clusters.*.cluster_log_conf *compute.ClusterLogConf ALL -resources.clusters.*.cluster_log_conf.dbfs *compute.DbfsStorageInfo ALL -resources.clusters.*.cluster_log_conf.dbfs.destination string ALL -resources.clusters.*.cluster_log_conf.s3 *compute.S3StorageInfo ALL -resources.clusters.*.cluster_log_conf.s3.canned_acl string ALL -resources.clusters.*.cluster_log_conf.s3.destination string ALL -resources.clusters.*.cluster_log_conf.s3.enable_encryption bool ALL -resources.clusters.*.cluster_log_conf.s3.encryption_type string ALL -resources.clusters.*.cluster_log_conf.s3.endpoint string ALL -resources.clusters.*.cluster_log_conf.s3.kms_key string ALL -resources.clusters.*.cluster_log_conf.s3.region string ALL -resources.clusters.*.cluster_log_conf.volumes *compute.VolumesStorageInfo ALL -resources.clusters.*.cluster_log_conf.volumes.destination string ALL -resources.clusters.*.cluster_log_status *compute.LogSyncStatus REMOTE -resources.clusters.*.cluster_log_status.last_attempted int64 REMOTE -resources.clusters.*.cluster_log_status.last_exception string REMOTE -resources.clusters.*.cluster_memory_mb int64 REMOTE -resources.clusters.*.cluster_name string ALL -resources.clusters.*.cluster_source compute.ClusterSource REMOTE -resources.clusters.*.creator_user_name string REMOTE +resources.clusters.*.apply_policy_default_values *bool ALL +resources.clusters.*.autoscale *clusters.AutoScale ALL +resources.clusters.*.autoscale.max_workers *int ALL +resources.clusters.*.autoscale.min_workers *int ALL +resources.clusters.*.autotermination_minutes *int ALL +resources.clusters.*.aws_attributes *clusters.AwsAttributes ALL +resources.clusters.*.aws_attributes.availability clusters.AwsAvailability ALL +resources.clusters.*.aws_attributes.ebs_volume_count *int ALL +resources.clusters.*.aws_attributes.ebs_volume_iops *int ALL +resources.clusters.*.aws_attributes.ebs_volume_size *int ALL +resources.clusters.*.aws_attributes.ebs_volume_throughput *int ALL +resources.clusters.*.aws_attributes.ebs_volume_type clusters.EbsVolumeType ALL +resources.clusters.*.aws_attributes.first_on_demand *int ALL +resources.clusters.*.aws_attributes.instance_profile_arn *string ALL +resources.clusters.*.aws_attributes.spot_bid_price_percent *int ALL +resources.clusters.*.aws_attributes.zone_id *string ALL +resources.clusters.*.azure_attributes *clusters.AzureAttributes ALL +resources.clusters.*.azure_attributes.availability clusters.AzureAvailability ALL +resources.clusters.*.azure_attributes.capacity_reservation_group *string ALL +resources.clusters.*.azure_attributes.first_on_demand *int ALL +resources.clusters.*.azure_attributes.log_analytics_info *clusters.LogAnalyticsInfo ALL +resources.clusters.*.azure_attributes.log_analytics_info.log_analytics_primary_key *string ALL +resources.clusters.*.azure_attributes.log_analytics_info.log_analytics_workspace_id *string ALL +resources.clusters.*.azure_attributes.spot_bid_max_price *float64 ALL +resources.clusters.*.clone_from *clusters.CloneCluster INPUT STATE +resources.clusters.*.clone_from.source_cluster_id *string INPUT STATE +resources.clusters.*.cluster_cores *float32 REMOTE +resources.clusters.*.cluster_id *string REMOTE +resources.clusters.*.cluster_log_conf *clusters.ClusterLogConf ALL +resources.clusters.*.cluster_log_conf.dbfs *clusters.DbfsStorageInfo ALL +resources.clusters.*.cluster_log_conf.dbfs.destination *string ALL +resources.clusters.*.cluster_log_conf.s3 *clusters.S3StorageInfo ALL +resources.clusters.*.cluster_log_conf.s3.canned_acl *string ALL +resources.clusters.*.cluster_log_conf.s3.destination *string ALL +resources.clusters.*.cluster_log_conf.s3.enable_encryption *bool ALL +resources.clusters.*.cluster_log_conf.s3.encryption_type *string ALL +resources.clusters.*.cluster_log_conf.s3.endpoint *string ALL +resources.clusters.*.cluster_log_conf.s3.kms_key *string ALL +resources.clusters.*.cluster_log_conf.s3.region *string ALL +resources.clusters.*.cluster_log_conf.volumes *clusters.VolumesStorageInfo ALL +resources.clusters.*.cluster_log_conf.volumes.destination *string ALL +resources.clusters.*.cluster_log_status *clusters.LogSyncStatus REMOTE +resources.clusters.*.cluster_log_status.last_attempted *int64 REMOTE +resources.clusters.*.cluster_log_status.last_exception *string REMOTE +resources.clusters.*.cluster_memory_mb *int64 REMOTE +resources.clusters.*.cluster_name *string ALL +resources.clusters.*.creator_user_name *string REMOTE resources.clusters.*.custom_tags map[string]string ALL resources.clusters.*.custom_tags.* string ALL -resources.clusters.*.data_security_mode compute.DataSecurityMode ALL +resources.clusters.*.data_security_mode clusters.DataSecurityMode ALL resources.clusters.*.default_tags map[string]string REMOTE resources.clusters.*.default_tags.* string REMOTE -resources.clusters.*.dependency_mode compute.DependencyMode ALL -resources.clusters.*.docker_image *compute.DockerImage ALL -resources.clusters.*.docker_image.basic_auth *compute.DockerBasicAuth ALL -resources.clusters.*.docker_image.basic_auth.password string ALL -resources.clusters.*.docker_image.basic_auth.username string ALL -resources.clusters.*.docker_image.url string ALL -resources.clusters.*.driver *compute.SparkNode REMOTE -resources.clusters.*.driver.host_private_ip string REMOTE -resources.clusters.*.driver.instance_id string REMOTE -resources.clusters.*.driver.node_aws_attributes *compute.SparkNodeAwsAttributes REMOTE -resources.clusters.*.driver.node_aws_attributes.is_spot bool REMOTE -resources.clusters.*.driver.node_id string REMOTE -resources.clusters.*.driver.private_ip string REMOTE -resources.clusters.*.driver.public_dns string REMOTE -resources.clusters.*.driver.start_timestamp int64 REMOTE -resources.clusters.*.driver_instance_pool_id string ALL -resources.clusters.*.driver_node_type_flexibility *compute.NodeTypeFlexibility ALL +resources.clusters.*.dependency_mode clusters.DependencyMode ALL +resources.clusters.*.docker_image *clusters.DockerImage ALL +resources.clusters.*.docker_image.basic_auth *clusters.DockerBasicAuth ALL +resources.clusters.*.docker_image.basic_auth.password *string ALL +resources.clusters.*.docker_image.basic_auth.username *string ALL +resources.clusters.*.docker_image.url *string ALL +resources.clusters.*.driver *clusters.SparkInfo_SparkNode REMOTE +resources.clusters.*.driver.host_private_ip *string REMOTE +resources.clusters.*.driver.instance_id *string REMOTE +resources.clusters.*.driver.node_aws_attributes *clusters.SparkInfo_SparkNode_SparkNodeAwsAttributes REMOTE +resources.clusters.*.driver.node_aws_attributes.is_spot *bool REMOTE +resources.clusters.*.driver.node_id *string REMOTE +resources.clusters.*.driver.private_ip *string REMOTE +resources.clusters.*.driver.public_dns *string REMOTE +resources.clusters.*.driver.start_timestamp *int64 REMOTE +resources.clusters.*.driver_instance_pool_id *string ALL +resources.clusters.*.driver_node_type_flexibility *clusters.NodeTypeFlexibility ALL resources.clusters.*.driver_node_type_flexibility.alternate_node_type_ids []string ALL resources.clusters.*.driver_node_type_flexibility.alternate_node_type_ids[*] string ALL -resources.clusters.*.driver_node_type_flexibility.aws_context_id string ALL -resources.clusters.*.driver_node_type_id string ALL -resources.clusters.*.enable_elastic_disk bool ALL -resources.clusters.*.enable_local_disk_encryption bool ALL -resources.clusters.*.executors []compute.SparkNode REMOTE -resources.clusters.*.executors[*] compute.SparkNode REMOTE -resources.clusters.*.executors[*].host_private_ip string REMOTE -resources.clusters.*.executors[*].instance_id string REMOTE -resources.clusters.*.executors[*].node_aws_attributes *compute.SparkNodeAwsAttributes REMOTE -resources.clusters.*.executors[*].node_aws_attributes.is_spot bool REMOTE -resources.clusters.*.executors[*].node_id string REMOTE -resources.clusters.*.executors[*].private_ip string REMOTE -resources.clusters.*.executors[*].public_dns string REMOTE -resources.clusters.*.executors[*].start_timestamp int64 REMOTE -resources.clusters.*.gcp_attributes *compute.GcpAttributes ALL -resources.clusters.*.gcp_attributes.availability compute.GcpAvailability ALL -resources.clusters.*.gcp_attributes.boot_disk_size int ALL -resources.clusters.*.gcp_attributes.confidential_compute_type compute.ConfidentialComputeType ALL -resources.clusters.*.gcp_attributes.first_on_demand int ALL -resources.clusters.*.gcp_attributes.google_service_account string ALL -resources.clusters.*.gcp_attributes.local_ssd_count int ALL -resources.clusters.*.gcp_attributes.use_preemptible_executors bool ALL -resources.clusters.*.gcp_attributes.zone_id string ALL +resources.clusters.*.driver_node_type_flexibility.aws_context_id *string ALL +resources.clusters.*.driver_node_type_id *string ALL +resources.clusters.*.enable_elastic_disk *bool ALL +resources.clusters.*.enable_local_disk_encryption *bool ALL +resources.clusters.*.executors []clusters.SparkInfo_SparkNode REMOTE +resources.clusters.*.executors[*] clusters.SparkInfo_SparkNode REMOTE +resources.clusters.*.executors[*].host_private_ip *string REMOTE +resources.clusters.*.executors[*].instance_id *string REMOTE +resources.clusters.*.executors[*].node_aws_attributes *clusters.SparkInfo_SparkNode_SparkNodeAwsAttributes REMOTE +resources.clusters.*.executors[*].node_aws_attributes.is_spot *bool REMOTE +resources.clusters.*.executors[*].node_id *string REMOTE +resources.clusters.*.executors[*].private_ip *string REMOTE +resources.clusters.*.executors[*].public_dns *string REMOTE +resources.clusters.*.executors[*].start_timestamp *int64 REMOTE +resources.clusters.*.gcp_attributes *clusters.GcpAttributes ALL +resources.clusters.*.gcp_attributes.availability clusters.GcpAvailability ALL +resources.clusters.*.gcp_attributes.boot_disk_size *int ALL +resources.clusters.*.gcp_attributes.confidential_compute_type clusters.ConfidentialComputeType ALL +resources.clusters.*.gcp_attributes.first_on_demand *int ALL +resources.clusters.*.gcp_attributes.google_service_account *string ALL +resources.clusters.*.gcp_attributes.local_ssd_count *int ALL +resources.clusters.*.gcp_attributes.use_preemptible_executors *bool ALL +resources.clusters.*.gcp_attributes.zone_id *string ALL resources.clusters.*.id string INPUT -resources.clusters.*.init_scripts []compute.InitScriptInfo ALL -resources.clusters.*.init_scripts[*] compute.InitScriptInfo ALL -resources.clusters.*.init_scripts[*].abfss *compute.Adlsgen2Info ALL -resources.clusters.*.init_scripts[*].abfss.destination string ALL -resources.clusters.*.init_scripts[*].dbfs *compute.DbfsStorageInfo ALL -resources.clusters.*.init_scripts[*].dbfs.destination string ALL -resources.clusters.*.init_scripts[*].file *compute.LocalFileInfo ALL -resources.clusters.*.init_scripts[*].file.destination string ALL -resources.clusters.*.init_scripts[*].gcs *compute.GcsStorageInfo ALL -resources.clusters.*.init_scripts[*].gcs.destination string ALL -resources.clusters.*.init_scripts[*].s3 *compute.S3StorageInfo ALL -resources.clusters.*.init_scripts[*].s3.canned_acl string ALL -resources.clusters.*.init_scripts[*].s3.destination string ALL -resources.clusters.*.init_scripts[*].s3.enable_encryption bool ALL -resources.clusters.*.init_scripts[*].s3.encryption_type string ALL -resources.clusters.*.init_scripts[*].s3.endpoint string ALL -resources.clusters.*.init_scripts[*].s3.kms_key string ALL -resources.clusters.*.init_scripts[*].s3.region string ALL -resources.clusters.*.init_scripts[*].volumes *compute.VolumesStorageInfo ALL -resources.clusters.*.init_scripts[*].volumes.destination string ALL -resources.clusters.*.init_scripts[*].workspace *compute.WorkspaceStorageInfo ALL -resources.clusters.*.init_scripts[*].workspace.destination string ALL -resources.clusters.*.instance_pool_id string ALL -resources.clusters.*.is_single_node bool ALL -resources.clusters.*.jdbc_port int REMOTE -resources.clusters.*.kind compute.Kind ALL -resources.clusters.*.last_restarted_time int64 REMOTE -resources.clusters.*.last_state_loss_time int64 REMOTE -resources.clusters.*.libraries []compute.Library ALL -resources.clusters.*.libraries[*] compute.Library ALL -resources.clusters.*.libraries[*].cran *compute.RCranLibrary ALL -resources.clusters.*.libraries[*].cran.package string ALL -resources.clusters.*.libraries[*].cran.repo string ALL -resources.clusters.*.libraries[*].egg string ALL -resources.clusters.*.libraries[*].jar string ALL -resources.clusters.*.libraries[*].maven *compute.MavenLibrary ALL -resources.clusters.*.libraries[*].maven.coordinates string ALL +resources.clusters.*.init_scripts []clusters.InitScriptInfo ALL +resources.clusters.*.init_scripts[*] clusters.InitScriptInfo ALL +resources.clusters.*.init_scripts[*].abfss *clusters.Adlsgen2Info ALL +resources.clusters.*.init_scripts[*].abfss.destination *string ALL +resources.clusters.*.init_scripts[*].dbfs *clusters.DbfsStorageInfo ALL +resources.clusters.*.init_scripts[*].dbfs.destination *string ALL +resources.clusters.*.init_scripts[*].file *clusters.LocalFileInfo ALL +resources.clusters.*.init_scripts[*].file.destination *string ALL +resources.clusters.*.init_scripts[*].gcs *clusters.GcsStorageInfo ALL +resources.clusters.*.init_scripts[*].gcs.destination *string ALL +resources.clusters.*.init_scripts[*].s3 *clusters.S3StorageInfo ALL +resources.clusters.*.init_scripts[*].s3.canned_acl *string ALL +resources.clusters.*.init_scripts[*].s3.destination *string ALL +resources.clusters.*.init_scripts[*].s3.enable_encryption *bool ALL +resources.clusters.*.init_scripts[*].s3.encryption_type *string ALL +resources.clusters.*.init_scripts[*].s3.endpoint *string ALL +resources.clusters.*.init_scripts[*].s3.kms_key *string ALL +resources.clusters.*.init_scripts[*].s3.region *string ALL +resources.clusters.*.init_scripts[*].volumes *clusters.VolumesStorageInfo ALL +resources.clusters.*.init_scripts[*].volumes.destination *string ALL +resources.clusters.*.init_scripts[*].workspace *clusters.WorkspaceStorageInfo ALL +resources.clusters.*.init_scripts[*].workspace.destination *string ALL +resources.clusters.*.instance_pool_id *string ALL +resources.clusters.*.is_single_node *bool ALL +resources.clusters.*.jdbc_port *int REMOTE +resources.clusters.*.kind clusters.ComputeKind ALL +resources.clusters.*.last_restarted_time *int64 REMOTE +resources.clusters.*.last_state_loss_time *int64 REMOTE +resources.clusters.*.libraries []clusterlibraries.Library ALL +resources.clusters.*.libraries[*] clusterlibraries.Library ALL +resources.clusters.*.libraries[*].cran *clusterlibraries.RCranLibrary ALL +resources.clusters.*.libraries[*].cran.package *string ALL +resources.clusters.*.libraries[*].cran.repo *string ALL +resources.clusters.*.libraries[*].egg *string ALL +resources.clusters.*.libraries[*].jar *string ALL +resources.clusters.*.libraries[*].maven *clusterlibraries.MavenLibrary ALL +resources.clusters.*.libraries[*].maven.coordinates *string ALL resources.clusters.*.libraries[*].maven.exclusions []string ALL resources.clusters.*.libraries[*].maven.exclusions[*] string ALL -resources.clusters.*.libraries[*].maven.repo string ALL -resources.clusters.*.libraries[*].pypi *compute.PythonPyPiLibrary ALL -resources.clusters.*.libraries[*].pypi.package string ALL -resources.clusters.*.libraries[*].pypi.repo string ALL -resources.clusters.*.libraries[*].requirements string ALL -resources.clusters.*.libraries[*].whl string ALL +resources.clusters.*.libraries[*].maven.repo *string ALL +resources.clusters.*.libraries[*].pypi *clusterlibraries.PythonPyPiLibrary ALL +resources.clusters.*.libraries[*].pypi.package *string ALL +resources.clusters.*.libraries[*].pypi.repo *string ALL +resources.clusters.*.libraries[*].requirements *string ALL +resources.clusters.*.libraries[*].whl *string ALL resources.clusters.*.lifecycle *dresources.StateLifecycle REMOTE STATE resources.clusters.*.lifecycle *resources.LifecycleWithStarted INPUT resources.clusters.*.lifecycle resources.Lifecycle INPUT resources.clusters.*.lifecycle.prevent_destroy bool INPUT resources.clusters.*.lifecycle.started *bool ALL resources.clusters.*.modified_status string INPUT -resources.clusters.*.node_type_id string ALL -resources.clusters.*.num_workers int ALL -resources.clusters.*.policy_id string ALL -resources.clusters.*.remote_disk_throughput int ALL -resources.clusters.*.runtime_engine compute.RuntimeEngine ALL -resources.clusters.*.single_user_name string ALL +resources.clusters.*.node_type_id *string ALL +resources.clusters.*.num_workers *int ALL +resources.clusters.*.policy_id *string ALL +resources.clusters.*.remote_disk_throughput *int ALL +resources.clusters.*.runtime_engine clusters.RuntimeEngine ALL +resources.clusters.*.single_user_name *string ALL resources.clusters.*.spark_conf map[string]string ALL resources.clusters.*.spark_conf.* string ALL -resources.clusters.*.spark_context_id int64 REMOTE +resources.clusters.*.spark_context_id *int64 REMOTE resources.clusters.*.spark_env_vars map[string]string ALL resources.clusters.*.spark_env_vars.* string ALL -resources.clusters.*.spark_version string ALL -resources.clusters.*.spec *compute.ClusterSpec REMOTE -resources.clusters.*.spec.apply_policy_default_values bool REMOTE -resources.clusters.*.spec.autoscale *compute.AutoScale REMOTE -resources.clusters.*.spec.autoscale.max_workers int REMOTE -resources.clusters.*.spec.autoscale.min_workers int REMOTE -resources.clusters.*.spec.autotermination_minutes int REMOTE -resources.clusters.*.spec.aws_attributes *compute.AwsAttributes REMOTE -resources.clusters.*.spec.aws_attributes.availability compute.AwsAvailability REMOTE -resources.clusters.*.spec.aws_attributes.ebs_volume_count int REMOTE -resources.clusters.*.spec.aws_attributes.ebs_volume_iops int REMOTE -resources.clusters.*.spec.aws_attributes.ebs_volume_size int REMOTE -resources.clusters.*.spec.aws_attributes.ebs_volume_throughput int REMOTE -resources.clusters.*.spec.aws_attributes.ebs_volume_type compute.EbsVolumeType REMOTE -resources.clusters.*.spec.aws_attributes.first_on_demand int REMOTE -resources.clusters.*.spec.aws_attributes.instance_profile_arn string REMOTE -resources.clusters.*.spec.aws_attributes.spot_bid_price_percent int REMOTE -resources.clusters.*.spec.aws_attributes.zone_id string REMOTE -resources.clusters.*.spec.azure_attributes *compute.AzureAttributes REMOTE -resources.clusters.*.spec.azure_attributes.availability compute.AzureAvailability REMOTE -resources.clusters.*.spec.azure_attributes.capacity_reservation_group string REMOTE -resources.clusters.*.spec.azure_attributes.first_on_demand int REMOTE -resources.clusters.*.spec.azure_attributes.log_analytics_info *compute.LogAnalyticsInfo REMOTE -resources.clusters.*.spec.azure_attributes.log_analytics_info.log_analytics_primary_key string REMOTE -resources.clusters.*.spec.azure_attributes.log_analytics_info.log_analytics_workspace_id string REMOTE -resources.clusters.*.spec.azure_attributes.spot_bid_max_price float64 REMOTE -resources.clusters.*.spec.cluster_log_conf *compute.ClusterLogConf REMOTE -resources.clusters.*.spec.cluster_log_conf.dbfs *compute.DbfsStorageInfo REMOTE -resources.clusters.*.spec.cluster_log_conf.dbfs.destination string REMOTE -resources.clusters.*.spec.cluster_log_conf.s3 *compute.S3StorageInfo REMOTE -resources.clusters.*.spec.cluster_log_conf.s3.canned_acl string REMOTE -resources.clusters.*.spec.cluster_log_conf.s3.destination string REMOTE -resources.clusters.*.spec.cluster_log_conf.s3.enable_encryption bool REMOTE -resources.clusters.*.spec.cluster_log_conf.s3.encryption_type string REMOTE -resources.clusters.*.spec.cluster_log_conf.s3.endpoint string REMOTE -resources.clusters.*.spec.cluster_log_conf.s3.kms_key string REMOTE -resources.clusters.*.spec.cluster_log_conf.s3.region string REMOTE -resources.clusters.*.spec.cluster_log_conf.volumes *compute.VolumesStorageInfo REMOTE -resources.clusters.*.spec.cluster_log_conf.volumes.destination string REMOTE -resources.clusters.*.spec.cluster_name string REMOTE +resources.clusters.*.spark_version *string ALL +resources.clusters.*.spec *clusters.ClusterInfo_ComputeSpec REMOTE +resources.clusters.*.spec.apply_policy_default_values *bool REMOTE +resources.clusters.*.spec.autoscale *clusters.AutoScale REMOTE +resources.clusters.*.spec.autoscale.max_workers *int REMOTE +resources.clusters.*.spec.autoscale.min_workers *int REMOTE +resources.clusters.*.spec.autotermination_minutes *int REMOTE +resources.clusters.*.spec.aws_attributes *clusters.AwsAttributes REMOTE +resources.clusters.*.spec.aws_attributes.availability clusters.AwsAvailability REMOTE +resources.clusters.*.spec.aws_attributes.ebs_volume_count *int REMOTE +resources.clusters.*.spec.aws_attributes.ebs_volume_iops *int REMOTE +resources.clusters.*.spec.aws_attributes.ebs_volume_size *int REMOTE +resources.clusters.*.spec.aws_attributes.ebs_volume_throughput *int REMOTE +resources.clusters.*.spec.aws_attributes.ebs_volume_type clusters.EbsVolumeType REMOTE +resources.clusters.*.spec.aws_attributes.first_on_demand *int REMOTE +resources.clusters.*.spec.aws_attributes.instance_profile_arn *string REMOTE +resources.clusters.*.spec.aws_attributes.spot_bid_price_percent *int REMOTE +resources.clusters.*.spec.aws_attributes.zone_id *string REMOTE +resources.clusters.*.spec.azure_attributes *clusters.AzureAttributes REMOTE +resources.clusters.*.spec.azure_attributes.availability clusters.AzureAvailability REMOTE +resources.clusters.*.spec.azure_attributes.capacity_reservation_group *string REMOTE +resources.clusters.*.spec.azure_attributes.first_on_demand *int REMOTE +resources.clusters.*.spec.azure_attributes.log_analytics_info *clusters.LogAnalyticsInfo REMOTE +resources.clusters.*.spec.azure_attributes.log_analytics_info.log_analytics_primary_key *string REMOTE +resources.clusters.*.spec.azure_attributes.log_analytics_info.log_analytics_workspace_id *string REMOTE +resources.clusters.*.spec.azure_attributes.spot_bid_max_price *float64 REMOTE +resources.clusters.*.spec.cluster_log_conf *clusters.ClusterLogConf REMOTE +resources.clusters.*.spec.cluster_log_conf.dbfs *clusters.DbfsStorageInfo REMOTE +resources.clusters.*.spec.cluster_log_conf.dbfs.destination *string REMOTE +resources.clusters.*.spec.cluster_log_conf.s3 *clusters.S3StorageInfo REMOTE +resources.clusters.*.spec.cluster_log_conf.s3.canned_acl *string REMOTE +resources.clusters.*.spec.cluster_log_conf.s3.destination *string REMOTE +resources.clusters.*.spec.cluster_log_conf.s3.enable_encryption *bool REMOTE +resources.clusters.*.spec.cluster_log_conf.s3.encryption_type *string REMOTE +resources.clusters.*.spec.cluster_log_conf.s3.endpoint *string REMOTE +resources.clusters.*.spec.cluster_log_conf.s3.kms_key *string REMOTE +resources.clusters.*.spec.cluster_log_conf.s3.region *string REMOTE +resources.clusters.*.spec.cluster_log_conf.volumes *clusters.VolumesStorageInfo REMOTE +resources.clusters.*.spec.cluster_log_conf.volumes.destination *string REMOTE +resources.clusters.*.spec.cluster_name *string REMOTE resources.clusters.*.spec.custom_tags map[string]string REMOTE resources.clusters.*.spec.custom_tags.* string REMOTE -resources.clusters.*.spec.data_security_mode compute.DataSecurityMode REMOTE -resources.clusters.*.spec.dependency_mode compute.DependencyMode REMOTE -resources.clusters.*.spec.docker_image *compute.DockerImage REMOTE -resources.clusters.*.spec.docker_image.basic_auth *compute.DockerBasicAuth REMOTE -resources.clusters.*.spec.docker_image.basic_auth.password string REMOTE -resources.clusters.*.spec.docker_image.basic_auth.username string REMOTE -resources.clusters.*.spec.docker_image.url string REMOTE -resources.clusters.*.spec.driver_instance_pool_id string REMOTE -resources.clusters.*.spec.driver_node_type_flexibility *compute.NodeTypeFlexibility REMOTE +resources.clusters.*.spec.data_security_mode clusters.DataSecurityMode REMOTE +resources.clusters.*.spec.dependency_mode clusters.DependencyMode REMOTE +resources.clusters.*.spec.docker_image *clusters.DockerImage REMOTE +resources.clusters.*.spec.docker_image.basic_auth *clusters.DockerBasicAuth REMOTE +resources.clusters.*.spec.docker_image.basic_auth.password *string REMOTE +resources.clusters.*.spec.docker_image.basic_auth.username *string REMOTE +resources.clusters.*.spec.docker_image.url *string REMOTE +resources.clusters.*.spec.driver_instance_pool_id *string REMOTE +resources.clusters.*.spec.driver_node_type_flexibility *clusters.NodeTypeFlexibility REMOTE resources.clusters.*.spec.driver_node_type_flexibility.alternate_node_type_ids []string REMOTE resources.clusters.*.spec.driver_node_type_flexibility.alternate_node_type_ids[*] string REMOTE -resources.clusters.*.spec.driver_node_type_flexibility.aws_context_id string REMOTE -resources.clusters.*.spec.driver_node_type_id string REMOTE -resources.clusters.*.spec.enable_elastic_disk bool REMOTE -resources.clusters.*.spec.enable_local_disk_encryption bool REMOTE -resources.clusters.*.spec.gcp_attributes *compute.GcpAttributes REMOTE -resources.clusters.*.spec.gcp_attributes.availability compute.GcpAvailability REMOTE -resources.clusters.*.spec.gcp_attributes.boot_disk_size int REMOTE -resources.clusters.*.spec.gcp_attributes.confidential_compute_type compute.ConfidentialComputeType REMOTE -resources.clusters.*.spec.gcp_attributes.first_on_demand int REMOTE -resources.clusters.*.spec.gcp_attributes.google_service_account string REMOTE -resources.clusters.*.spec.gcp_attributes.local_ssd_count int REMOTE -resources.clusters.*.spec.gcp_attributes.use_preemptible_executors bool REMOTE -resources.clusters.*.spec.gcp_attributes.zone_id string REMOTE -resources.clusters.*.spec.init_scripts []compute.InitScriptInfo REMOTE -resources.clusters.*.spec.init_scripts[*] compute.InitScriptInfo REMOTE -resources.clusters.*.spec.init_scripts[*].abfss *compute.Adlsgen2Info REMOTE -resources.clusters.*.spec.init_scripts[*].abfss.destination string REMOTE -resources.clusters.*.spec.init_scripts[*].dbfs *compute.DbfsStorageInfo REMOTE -resources.clusters.*.spec.init_scripts[*].dbfs.destination string REMOTE -resources.clusters.*.spec.init_scripts[*].file *compute.LocalFileInfo REMOTE -resources.clusters.*.spec.init_scripts[*].file.destination string REMOTE -resources.clusters.*.spec.init_scripts[*].gcs *compute.GcsStorageInfo REMOTE -resources.clusters.*.spec.init_scripts[*].gcs.destination string REMOTE -resources.clusters.*.spec.init_scripts[*].s3 *compute.S3StorageInfo REMOTE -resources.clusters.*.spec.init_scripts[*].s3.canned_acl string REMOTE -resources.clusters.*.spec.init_scripts[*].s3.destination string REMOTE -resources.clusters.*.spec.init_scripts[*].s3.enable_encryption bool REMOTE -resources.clusters.*.spec.init_scripts[*].s3.encryption_type string REMOTE -resources.clusters.*.spec.init_scripts[*].s3.endpoint string REMOTE -resources.clusters.*.spec.init_scripts[*].s3.kms_key string REMOTE -resources.clusters.*.spec.init_scripts[*].s3.region string REMOTE -resources.clusters.*.spec.init_scripts[*].volumes *compute.VolumesStorageInfo REMOTE -resources.clusters.*.spec.init_scripts[*].volumes.destination string REMOTE -resources.clusters.*.spec.init_scripts[*].workspace *compute.WorkspaceStorageInfo REMOTE -resources.clusters.*.spec.init_scripts[*].workspace.destination string REMOTE -resources.clusters.*.spec.instance_pool_id string REMOTE -resources.clusters.*.spec.is_single_node bool REMOTE -resources.clusters.*.spec.kind compute.Kind REMOTE -resources.clusters.*.spec.node_type_id string REMOTE -resources.clusters.*.spec.num_workers int REMOTE -resources.clusters.*.spec.policy_id string REMOTE -resources.clusters.*.spec.remote_disk_throughput int REMOTE -resources.clusters.*.spec.runtime_engine compute.RuntimeEngine REMOTE -resources.clusters.*.spec.single_user_name string REMOTE +resources.clusters.*.spec.driver_node_type_flexibility.aws_context_id *string REMOTE +resources.clusters.*.spec.driver_node_type_id *string REMOTE +resources.clusters.*.spec.enable_elastic_disk *bool REMOTE +resources.clusters.*.spec.enable_local_disk_encryption *bool REMOTE +resources.clusters.*.spec.gcp_attributes *clusters.GcpAttributes REMOTE +resources.clusters.*.spec.gcp_attributes.availability clusters.GcpAvailability REMOTE +resources.clusters.*.spec.gcp_attributes.boot_disk_size *int REMOTE +resources.clusters.*.spec.gcp_attributes.confidential_compute_type clusters.ConfidentialComputeType REMOTE +resources.clusters.*.spec.gcp_attributes.first_on_demand *int REMOTE +resources.clusters.*.spec.gcp_attributes.google_service_account *string REMOTE +resources.clusters.*.spec.gcp_attributes.local_ssd_count *int REMOTE +resources.clusters.*.spec.gcp_attributes.use_preemptible_executors *bool REMOTE +resources.clusters.*.spec.gcp_attributes.zone_id *string REMOTE +resources.clusters.*.spec.init_scripts []clusters.InitScriptInfo REMOTE +resources.clusters.*.spec.init_scripts[*] clusters.InitScriptInfo REMOTE +resources.clusters.*.spec.init_scripts[*].abfss *clusters.Adlsgen2Info REMOTE +resources.clusters.*.spec.init_scripts[*].abfss.destination *string REMOTE +resources.clusters.*.spec.init_scripts[*].dbfs *clusters.DbfsStorageInfo REMOTE +resources.clusters.*.spec.init_scripts[*].dbfs.destination *string REMOTE +resources.clusters.*.spec.init_scripts[*].file *clusters.LocalFileInfo REMOTE +resources.clusters.*.spec.init_scripts[*].file.destination *string REMOTE +resources.clusters.*.spec.init_scripts[*].gcs *clusters.GcsStorageInfo REMOTE +resources.clusters.*.spec.init_scripts[*].gcs.destination *string REMOTE +resources.clusters.*.spec.init_scripts[*].s3 *clusters.S3StorageInfo REMOTE +resources.clusters.*.spec.init_scripts[*].s3.canned_acl *string REMOTE +resources.clusters.*.spec.init_scripts[*].s3.destination *string REMOTE +resources.clusters.*.spec.init_scripts[*].s3.enable_encryption *bool REMOTE +resources.clusters.*.spec.init_scripts[*].s3.encryption_type *string REMOTE +resources.clusters.*.spec.init_scripts[*].s3.endpoint *string REMOTE +resources.clusters.*.spec.init_scripts[*].s3.kms_key *string REMOTE +resources.clusters.*.spec.init_scripts[*].s3.region *string REMOTE +resources.clusters.*.spec.init_scripts[*].volumes *clusters.VolumesStorageInfo REMOTE +resources.clusters.*.spec.init_scripts[*].volumes.destination *string REMOTE +resources.clusters.*.spec.init_scripts[*].workspace *clusters.WorkspaceStorageInfo REMOTE +resources.clusters.*.spec.init_scripts[*].workspace.destination *string REMOTE +resources.clusters.*.spec.instance_pool_id *string REMOTE +resources.clusters.*.spec.is_single_node *bool REMOTE +resources.clusters.*.spec.kind clusters.ComputeKind REMOTE +resources.clusters.*.spec.node_type_id *string REMOTE +resources.clusters.*.spec.num_workers *int REMOTE +resources.clusters.*.spec.policy_id *string REMOTE +resources.clusters.*.spec.remote_disk_throughput *int REMOTE +resources.clusters.*.spec.runtime_engine clusters.RuntimeEngine REMOTE +resources.clusters.*.spec.single_user_name *string REMOTE resources.clusters.*.spec.spark_conf map[string]string REMOTE resources.clusters.*.spec.spark_conf.* string REMOTE resources.clusters.*.spec.spark_env_vars map[string]string REMOTE resources.clusters.*.spec.spark_env_vars.* string REMOTE -resources.clusters.*.spec.spark_version string REMOTE +resources.clusters.*.spec.spark_version *string REMOTE resources.clusters.*.spec.ssh_public_keys []string REMOTE resources.clusters.*.spec.ssh_public_keys[*] string REMOTE -resources.clusters.*.spec.total_initial_remote_disk_size int REMOTE -resources.clusters.*.spec.use_ml_runtime bool REMOTE -resources.clusters.*.spec.worker_node_type_flexibility *compute.NodeTypeFlexibility REMOTE +resources.clusters.*.spec.total_initial_remote_disk_size *int REMOTE +resources.clusters.*.spec.use_ml_runtime *bool REMOTE +resources.clusters.*.spec.worker_node_type_flexibility *clusters.NodeTypeFlexibility REMOTE resources.clusters.*.spec.worker_node_type_flexibility.alternate_node_type_ids []string REMOTE resources.clusters.*.spec.worker_node_type_flexibility.alternate_node_type_ids[*] string REMOTE -resources.clusters.*.spec.worker_node_type_flexibility.aws_context_id string REMOTE -resources.clusters.*.spec.workload_type *compute.WorkloadType REMOTE -resources.clusters.*.spec.workload_type.clients compute.ClientsTypes REMOTE -resources.clusters.*.spec.workload_type.clients.jobs bool REMOTE -resources.clusters.*.spec.workload_type.clients.notebooks bool REMOTE +resources.clusters.*.spec.worker_node_type_flexibility.aws_context_id *string REMOTE +resources.clusters.*.spec.workload_type *clusters.WorkloadType REMOTE +resources.clusters.*.spec.workload_type.clients *clusters.WorkloadType_ClientsTypes REMOTE +resources.clusters.*.spec.workload_type.clients.jobs *bool REMOTE +resources.clusters.*.spec.workload_type.clients.notebooks *bool REMOTE resources.clusters.*.ssh_public_keys []string ALL resources.clusters.*.ssh_public_keys[*] string ALL -resources.clusters.*.start_time int64 REMOTE -resources.clusters.*.state compute.State REMOTE -resources.clusters.*.state_message string REMOTE -resources.clusters.*.terminated_time int64 REMOTE -resources.clusters.*.termination_reason *compute.TerminationReason REMOTE -resources.clusters.*.termination_reason.code compute.TerminationReasonCode REMOTE +resources.clusters.*.start_time *int64 REMOTE +resources.clusters.*.state clusters.ClusterState_ClusterState REMOTE +resources.clusters.*.state_message *string REMOTE +resources.clusters.*.terminated_time *int64 REMOTE +resources.clusters.*.termination_reason *clusters.TerminationReason REMOTE +resources.clusters.*.termination_reason.code clusters.TerminationCode REMOTE resources.clusters.*.termination_reason.parameters map[string]string REMOTE resources.clusters.*.termination_reason.parameters.* string REMOTE -resources.clusters.*.termination_reason.type compute.TerminationReasonType REMOTE -resources.clusters.*.total_initial_remote_disk_size int ALL +resources.clusters.*.termination_reason.type clusters.TerminationType REMOTE +resources.clusters.*.total_initial_remote_disk_size *int ALL resources.clusters.*.url string INPUT -resources.clusters.*.use_ml_runtime bool ALL -resources.clusters.*.worker_node_type_flexibility *compute.NodeTypeFlexibility ALL +resources.clusters.*.use_ml_runtime *bool ALL +resources.clusters.*.worker_node_type_flexibility *clusters.NodeTypeFlexibility ALL resources.clusters.*.worker_node_type_flexibility.alternate_node_type_ids []string ALL resources.clusters.*.worker_node_type_flexibility.alternate_node_type_ids[*] string ALL -resources.clusters.*.worker_node_type_flexibility.aws_context_id string ALL -resources.clusters.*.workload_type *compute.WorkloadType ALL -resources.clusters.*.workload_type.clients compute.ClientsTypes ALL -resources.clusters.*.workload_type.clients.jobs bool ALL -resources.clusters.*.workload_type.clients.notebooks bool ALL +resources.clusters.*.worker_node_type_flexibility.aws_context_id *string ALL +resources.clusters.*.workload_type *clusters.WorkloadType ALL +resources.clusters.*.workload_type.clients *clusters.WorkloadType_ClientsTypes ALL +resources.clusters.*.workload_type.clients.jobs *bool ALL +resources.clusters.*.workload_type.clients.notebooks *bool ALL resources.clusters.*.permissions.object_id string ALL resources.clusters.*.permissions[*] dresources.StatePermission ALL resources.clusters.*.permissions[*].group_name string ALL -resources.clusters.*.permissions[*].level iam.PermissionLevel ALL +resources.clusters.*.permissions[*].level resources.PermissionLevel ALL resources.clusters.*.permissions[*].service_principal_name string ALL resources.clusters.*.permissions[*].user_name string ALL resources.dashboards.*.create_time string ALL @@ -655,7 +659,7 @@ resources.dashboards.*.file_path string INPUT resources.dashboards.*.id string INPUT resources.dashboards.*.lifecycle resources.Lifecycle INPUT resources.dashboards.*.lifecycle.prevent_destroy bool INPUT -resources.dashboards.*.lifecycle_state dashboards.LifecycleState ALL +resources.dashboards.*.lifecycle_state lakeview.LifecycleState ALL resources.dashboards.*.modified_status string INPUT resources.dashboards.*.parent_path string ALL resources.dashboards.*.path string ALL @@ -667,178 +671,178 @@ resources.dashboards.*.warehouse_id string ALL resources.dashboards.*.permissions.object_id string ALL resources.dashboards.*.permissions[*] dresources.StatePermission ALL resources.dashboards.*.permissions[*].group_name string ALL -resources.dashboards.*.permissions[*].level iam.PermissionLevel ALL +resources.dashboards.*.permissions[*].level resources.PermissionLevel ALL resources.dashboards.*.permissions[*].service_principal_name string ALL resources.dashboards.*.permissions[*].user_name string ALL -resources.database_catalogs.*.create_database_if_not_exists bool ALL -resources.database_catalogs.*.database_instance_name string ALL -resources.database_catalogs.*.database_name string ALL +resources.database_catalogs.*.create_database_if_not_exists *bool ALL +resources.database_catalogs.*.database_instance_name *string ALL +resources.database_catalogs.*.database_name *string ALL resources.database_catalogs.*.id string INPUT resources.database_catalogs.*.lifecycle resources.Lifecycle INPUT resources.database_catalogs.*.lifecycle.prevent_destroy bool INPUT resources.database_catalogs.*.modified_status string INPUT -resources.database_catalogs.*.name string ALL -resources.database_catalogs.*.uid string ALL +resources.database_catalogs.*.name *string ALL +resources.database_catalogs.*.uid *string ALL resources.database_catalogs.*.url string INPUT -resources.database_instances.*.capacity string ALL +resources.database_instances.*.capacity *string ALL resources.database_instances.*.child_instance_refs []database.DatabaseInstanceRef ALL resources.database_instances.*.child_instance_refs[*] database.DatabaseInstanceRef ALL -resources.database_instances.*.child_instance_refs[*].branch_time string ALL -resources.database_instances.*.child_instance_refs[*].effective_lsn string ALL -resources.database_instances.*.child_instance_refs[*].lsn string ALL -resources.database_instances.*.child_instance_refs[*].name string ALL -resources.database_instances.*.child_instance_refs[*].uid string ALL -resources.database_instances.*.creation_time string ALL -resources.database_instances.*.creator string ALL +resources.database_instances.*.child_instance_refs[*].branch_time *types.Time ALL +resources.database_instances.*.child_instance_refs[*].effective_lsn *string ALL +resources.database_instances.*.child_instance_refs[*].lsn *string ALL +resources.database_instances.*.child_instance_refs[*].name *string ALL +resources.database_instances.*.child_instance_refs[*].uid *string ALL +resources.database_instances.*.creation_time *types.Time ALL +resources.database_instances.*.creator *string ALL resources.database_instances.*.custom_tags []database.CustomTag ALL resources.database_instances.*.custom_tags[*] database.CustomTag ALL -resources.database_instances.*.custom_tags[*].key string ALL -resources.database_instances.*.custom_tags[*].value string ALL -resources.database_instances.*.effective_capacity string ALL +resources.database_instances.*.custom_tags[*].key *string ALL +resources.database_instances.*.custom_tags[*].value *string ALL +resources.database_instances.*.effective_capacity *string ALL resources.database_instances.*.effective_custom_tags []database.CustomTag ALL resources.database_instances.*.effective_custom_tags[*] database.CustomTag ALL -resources.database_instances.*.effective_custom_tags[*].key string ALL -resources.database_instances.*.effective_custom_tags[*].value string ALL -resources.database_instances.*.effective_enable_pg_native_login bool ALL -resources.database_instances.*.effective_enable_readable_secondaries bool ALL -resources.database_instances.*.effective_node_count int ALL -resources.database_instances.*.effective_retention_window_in_days int ALL -resources.database_instances.*.effective_stopped bool ALL -resources.database_instances.*.effective_usage_policy_id string ALL -resources.database_instances.*.enable_pg_native_login bool ALL -resources.database_instances.*.enable_readable_secondaries bool ALL +resources.database_instances.*.effective_custom_tags[*].key *string ALL +resources.database_instances.*.effective_custom_tags[*].value *string ALL +resources.database_instances.*.effective_enable_pg_native_login *bool ALL +resources.database_instances.*.effective_enable_readable_secondaries *bool ALL +resources.database_instances.*.effective_node_count *int ALL +resources.database_instances.*.effective_retention_window_in_days *int ALL +resources.database_instances.*.effective_stopped *bool ALL +resources.database_instances.*.effective_usage_policy_id *string ALL +resources.database_instances.*.enable_pg_native_login *bool ALL +resources.database_instances.*.enable_readable_secondaries *bool ALL resources.database_instances.*.id string INPUT resources.database_instances.*.lifecycle resources.Lifecycle INPUT resources.database_instances.*.lifecycle.prevent_destroy bool INPUT resources.database_instances.*.modified_status string INPUT -resources.database_instances.*.name string ALL -resources.database_instances.*.node_count int ALL +resources.database_instances.*.name *string ALL +resources.database_instances.*.node_count *int ALL resources.database_instances.*.parent_instance_ref *database.DatabaseInstanceRef ALL -resources.database_instances.*.parent_instance_ref.branch_time string ALL -resources.database_instances.*.parent_instance_ref.effective_lsn string ALL -resources.database_instances.*.parent_instance_ref.lsn string ALL -resources.database_instances.*.parent_instance_ref.name string ALL -resources.database_instances.*.parent_instance_ref.uid string ALL -resources.database_instances.*.pg_version string ALL -resources.database_instances.*.read_only_dns string ALL -resources.database_instances.*.read_write_dns string ALL -resources.database_instances.*.retention_window_in_days int ALL -resources.database_instances.*.state database.DatabaseInstanceState ALL -resources.database_instances.*.stopped bool ALL -resources.database_instances.*.uid string ALL +resources.database_instances.*.parent_instance_ref.branch_time *types.Time ALL +resources.database_instances.*.parent_instance_ref.effective_lsn *string ALL +resources.database_instances.*.parent_instance_ref.lsn *string ALL +resources.database_instances.*.parent_instance_ref.name *string ALL +resources.database_instances.*.parent_instance_ref.uid *string ALL +resources.database_instances.*.pg_version *string ALL +resources.database_instances.*.read_only_dns *string ALL +resources.database_instances.*.read_write_dns *string ALL +resources.database_instances.*.retention_window_in_days *int ALL +resources.database_instances.*.state database.DatabaseInstance_State ALL +resources.database_instances.*.stopped *bool ALL +resources.database_instances.*.uid *string ALL resources.database_instances.*.url string INPUT -resources.database_instances.*.usage_policy_id string ALL +resources.database_instances.*.usage_policy_id *string ALL resources.database_instances.*.permissions.object_id string ALL resources.database_instances.*.permissions[*] dresources.StatePermission ALL resources.database_instances.*.permissions[*].group_name string ALL -resources.database_instances.*.permissions[*].level iam.PermissionLevel ALL +resources.database_instances.*.permissions[*].level resources.PermissionLevel ALL resources.database_instances.*.permissions[*].service_principal_name string ALL resources.database_instances.*.permissions[*].user_name string ALL -resources.experiments.*.artifact_location string ALL -resources.experiments.*.creation_time int64 REMOTE -resources.experiments.*.experiment_id string REMOTE +resources.experiments.*.artifact_location *string ALL +resources.experiments.*.creation_time *int64 REMOTE +resources.experiments.*.experiment_id *string REMOTE resources.experiments.*.id string INPUT -resources.experiments.*.last_update_time int64 REMOTE +resources.experiments.*.last_update_time *int64 REMOTE resources.experiments.*.lifecycle resources.Lifecycle INPUT resources.experiments.*.lifecycle.prevent_destroy bool INPUT -resources.experiments.*.lifecycle_stage string REMOTE +resources.experiments.*.lifecycle_stage *string REMOTE resources.experiments.*.modified_status string INPUT -resources.experiments.*.name string ALL -resources.experiments.*.tags []ml.ExperimentTag ALL -resources.experiments.*.tags[*] ml.ExperimentTag ALL -resources.experiments.*.tags[*].key string ALL -resources.experiments.*.tags[*].value string ALL -resources.experiments.*.trace_location *ml.ExperimentTraceLocation ALL -resources.experiments.*.trace_location.uc_trace_location *ml.UcTraceLocation ALL -resources.experiments.*.trace_location.uc_trace_location.catalog string ALL -resources.experiments.*.trace_location.uc_trace_location.effective_table_prefix string ALL -resources.experiments.*.trace_location.uc_trace_location.schema string ALL -resources.experiments.*.trace_location.uc_trace_location.table_prefix string ALL +resources.experiments.*.name *string ALL +resources.experiments.*.tags []experiments.ExperimentTag ALL +resources.experiments.*.tags[*] experiments.ExperimentTag ALL +resources.experiments.*.tags[*].key *string ALL +resources.experiments.*.tags[*].value *string ALL +resources.experiments.*.trace_location *experiments.ExperimentTraceLocation ALL +resources.experiments.*.trace_location.uc_trace_location *experiments.UcTraceLocation ALL +resources.experiments.*.trace_location.uc_trace_location.catalog *string ALL +resources.experiments.*.trace_location.uc_trace_location.effective_table_prefix *string ALL +resources.experiments.*.trace_location.uc_trace_location.schema *string ALL +resources.experiments.*.trace_location.uc_trace_location.table_prefix *string ALL resources.experiments.*.url string INPUT resources.experiments.*.permissions.object_id string ALL resources.experiments.*.permissions[*] dresources.StatePermission ALL resources.experiments.*.permissions[*].group_name string ALL -resources.experiments.*.permissions[*].level iam.PermissionLevel ALL +resources.experiments.*.permissions[*].level resources.PermissionLevel ALL resources.experiments.*.permissions[*].service_principal_name string ALL resources.experiments.*.permissions[*].user_name string ALL -resources.external_locations.*.browse_only bool REMOTE -resources.external_locations.*.comment string ALL -resources.external_locations.*.created_at int64 REMOTE -resources.external_locations.*.created_by string REMOTE -resources.external_locations.*.credential_id string REMOTE -resources.external_locations.*.credential_name string ALL -resources.external_locations.*.effective_enable_file_events bool ALL -resources.external_locations.*.effective_file_event_queue *catalog.FileEventQueue ALL -resources.external_locations.*.effective_file_event_queue.managed_aqs *catalog.AzureQueueStorage ALL -resources.external_locations.*.effective_file_event_queue.managed_aqs.managed_resource_id string ALL -resources.external_locations.*.effective_file_event_queue.managed_aqs.queue_url string ALL -resources.external_locations.*.effective_file_event_queue.managed_aqs.resource_group string ALL -resources.external_locations.*.effective_file_event_queue.managed_aqs.subscription_id string ALL -resources.external_locations.*.effective_file_event_queue.managed_pubsub *catalog.GcpPubsub ALL -resources.external_locations.*.effective_file_event_queue.managed_pubsub.managed_resource_id string ALL -resources.external_locations.*.effective_file_event_queue.managed_pubsub.subscription_name string ALL -resources.external_locations.*.effective_file_event_queue.managed_sqs *catalog.AwsSqsQueue ALL -resources.external_locations.*.effective_file_event_queue.managed_sqs.managed_resource_id string ALL -resources.external_locations.*.effective_file_event_queue.managed_sqs.queue_url string ALL -resources.external_locations.*.effective_file_event_queue.provided_aqs *catalog.AzureQueueStorage ALL -resources.external_locations.*.effective_file_event_queue.provided_aqs.managed_resource_id string ALL -resources.external_locations.*.effective_file_event_queue.provided_aqs.queue_url string ALL -resources.external_locations.*.effective_file_event_queue.provided_aqs.resource_group string ALL -resources.external_locations.*.effective_file_event_queue.provided_aqs.subscription_id string ALL -resources.external_locations.*.effective_file_event_queue.provided_pubsub *catalog.GcpPubsub ALL -resources.external_locations.*.effective_file_event_queue.provided_pubsub.managed_resource_id string ALL -resources.external_locations.*.effective_file_event_queue.provided_pubsub.subscription_name string ALL -resources.external_locations.*.effective_file_event_queue.provided_sqs *catalog.AwsSqsQueue ALL -resources.external_locations.*.effective_file_event_queue.provided_sqs.managed_resource_id string ALL -resources.external_locations.*.effective_file_event_queue.provided_sqs.queue_url string ALL -resources.external_locations.*.enable_file_events bool ALL -resources.external_locations.*.encryption_details *catalog.EncryptionDetails ALL -resources.external_locations.*.encryption_details.sse_encryption_details *catalog.SseEncryptionDetails ALL -resources.external_locations.*.encryption_details.sse_encryption_details.algorithm catalog.SseEncryptionDetailsAlgorithm ALL -resources.external_locations.*.encryption_details.sse_encryption_details.aws_kms_key_arn string ALL -resources.external_locations.*.fallback bool ALL -resources.external_locations.*.file_event_queue *catalog.FileEventQueue ALL -resources.external_locations.*.file_event_queue.managed_aqs *catalog.AzureQueueStorage ALL -resources.external_locations.*.file_event_queue.managed_aqs.managed_resource_id string ALL -resources.external_locations.*.file_event_queue.managed_aqs.queue_url string ALL -resources.external_locations.*.file_event_queue.managed_aqs.resource_group string ALL -resources.external_locations.*.file_event_queue.managed_aqs.subscription_id string ALL -resources.external_locations.*.file_event_queue.managed_pubsub *catalog.GcpPubsub ALL -resources.external_locations.*.file_event_queue.managed_pubsub.managed_resource_id string ALL -resources.external_locations.*.file_event_queue.managed_pubsub.subscription_name string ALL -resources.external_locations.*.file_event_queue.managed_sqs *catalog.AwsSqsQueue ALL -resources.external_locations.*.file_event_queue.managed_sqs.managed_resource_id string ALL -resources.external_locations.*.file_event_queue.managed_sqs.queue_url string ALL -resources.external_locations.*.file_event_queue.provided_aqs *catalog.AzureQueueStorage ALL -resources.external_locations.*.file_event_queue.provided_aqs.managed_resource_id string ALL -resources.external_locations.*.file_event_queue.provided_aqs.queue_url string ALL -resources.external_locations.*.file_event_queue.provided_aqs.resource_group string ALL -resources.external_locations.*.file_event_queue.provided_aqs.subscription_id string ALL -resources.external_locations.*.file_event_queue.provided_pubsub *catalog.GcpPubsub ALL -resources.external_locations.*.file_event_queue.provided_pubsub.managed_resource_id string ALL -resources.external_locations.*.file_event_queue.provided_pubsub.subscription_name string ALL -resources.external_locations.*.file_event_queue.provided_sqs *catalog.AwsSqsQueue ALL -resources.external_locations.*.file_event_queue.provided_sqs.managed_resource_id string ALL -resources.external_locations.*.file_event_queue.provided_sqs.queue_url string ALL +resources.external_locations.*.browse_only *bool REMOTE +resources.external_locations.*.comment *string ALL +resources.external_locations.*.created_at *int64 REMOTE +resources.external_locations.*.created_by *string REMOTE +resources.external_locations.*.credential_id *string REMOTE +resources.external_locations.*.credential_name *string ALL +resources.external_locations.*.effective_enable_file_events *bool ALL +resources.external_locations.*.effective_file_event_queue *externallocations.FileEventQueue ALL +resources.external_locations.*.effective_file_event_queue.managed_aqs *externallocations.AzureQueueStorage ALL +resources.external_locations.*.effective_file_event_queue.managed_aqs.managed_resource_id *string ALL +resources.external_locations.*.effective_file_event_queue.managed_aqs.queue_url *string ALL +resources.external_locations.*.effective_file_event_queue.managed_aqs.resource_group *string ALL +resources.external_locations.*.effective_file_event_queue.managed_aqs.subscription_id *string ALL +resources.external_locations.*.effective_file_event_queue.managed_pubsub *externallocations.GcpPubsub ALL +resources.external_locations.*.effective_file_event_queue.managed_pubsub.managed_resource_id *string ALL +resources.external_locations.*.effective_file_event_queue.managed_pubsub.subscription_name *string ALL +resources.external_locations.*.effective_file_event_queue.managed_sqs *externallocations.AwsSqsQueue ALL +resources.external_locations.*.effective_file_event_queue.managed_sqs.managed_resource_id *string ALL +resources.external_locations.*.effective_file_event_queue.managed_sqs.queue_url *string ALL +resources.external_locations.*.effective_file_event_queue.provided_aqs *externallocations.AzureQueueStorage ALL +resources.external_locations.*.effective_file_event_queue.provided_aqs.managed_resource_id *string ALL +resources.external_locations.*.effective_file_event_queue.provided_aqs.queue_url *string ALL +resources.external_locations.*.effective_file_event_queue.provided_aqs.resource_group *string ALL +resources.external_locations.*.effective_file_event_queue.provided_aqs.subscription_id *string ALL +resources.external_locations.*.effective_file_event_queue.provided_pubsub *externallocations.GcpPubsub ALL +resources.external_locations.*.effective_file_event_queue.provided_pubsub.managed_resource_id *string ALL +resources.external_locations.*.effective_file_event_queue.provided_pubsub.subscription_name *string ALL +resources.external_locations.*.effective_file_event_queue.provided_sqs *externallocations.AwsSqsQueue ALL +resources.external_locations.*.effective_file_event_queue.provided_sqs.managed_resource_id *string ALL +resources.external_locations.*.effective_file_event_queue.provided_sqs.queue_url *string ALL +resources.external_locations.*.enable_file_events *bool ALL +resources.external_locations.*.encryption_details *externallocations.EncryptionDetails ALL +resources.external_locations.*.encryption_details.sse_encryption_details *externallocations.SseEncryptionDetails ALL +resources.external_locations.*.encryption_details.sse_encryption_details.algorithm externallocations.SseEncryptionAlgorithm ALL +resources.external_locations.*.encryption_details.sse_encryption_details.aws_kms_key_arn *string ALL +resources.external_locations.*.fallback *bool ALL +resources.external_locations.*.file_event_queue *externallocations.FileEventQueue ALL +resources.external_locations.*.file_event_queue.managed_aqs *externallocations.AzureQueueStorage ALL +resources.external_locations.*.file_event_queue.managed_aqs.managed_resource_id *string ALL +resources.external_locations.*.file_event_queue.managed_aqs.queue_url *string ALL +resources.external_locations.*.file_event_queue.managed_aqs.resource_group *string ALL +resources.external_locations.*.file_event_queue.managed_aqs.subscription_id *string ALL +resources.external_locations.*.file_event_queue.managed_pubsub *externallocations.GcpPubsub ALL +resources.external_locations.*.file_event_queue.managed_pubsub.managed_resource_id *string ALL +resources.external_locations.*.file_event_queue.managed_pubsub.subscription_name *string ALL +resources.external_locations.*.file_event_queue.managed_sqs *externallocations.AwsSqsQueue ALL +resources.external_locations.*.file_event_queue.managed_sqs.managed_resource_id *string ALL +resources.external_locations.*.file_event_queue.managed_sqs.queue_url *string ALL +resources.external_locations.*.file_event_queue.provided_aqs *externallocations.AzureQueueStorage ALL +resources.external_locations.*.file_event_queue.provided_aqs.managed_resource_id *string ALL +resources.external_locations.*.file_event_queue.provided_aqs.queue_url *string ALL +resources.external_locations.*.file_event_queue.provided_aqs.resource_group *string ALL +resources.external_locations.*.file_event_queue.provided_aqs.subscription_id *string ALL +resources.external_locations.*.file_event_queue.provided_pubsub *externallocations.GcpPubsub ALL +resources.external_locations.*.file_event_queue.provided_pubsub.managed_resource_id *string ALL +resources.external_locations.*.file_event_queue.provided_pubsub.subscription_name *string ALL +resources.external_locations.*.file_event_queue.provided_sqs *externallocations.AwsSqsQueue ALL +resources.external_locations.*.file_event_queue.provided_sqs.managed_resource_id *string ALL +resources.external_locations.*.file_event_queue.provided_sqs.queue_url *string ALL resources.external_locations.*.id string INPUT -resources.external_locations.*.isolation_mode catalog.IsolationMode REMOTE +resources.external_locations.*.isolation_mode externallocations.IsolationMode REMOTE resources.external_locations.*.lifecycle resources.Lifecycle INPUT resources.external_locations.*.lifecycle.prevent_destroy bool INPUT -resources.external_locations.*.metastore_id string REMOTE +resources.external_locations.*.metastore_id *string REMOTE resources.external_locations.*.modified_status string INPUT -resources.external_locations.*.name string ALL -resources.external_locations.*.owner string REMOTE -resources.external_locations.*.read_only bool ALL -resources.external_locations.*.skip_validation bool INPUT STATE -resources.external_locations.*.updated_at int64 REMOTE -resources.external_locations.*.updated_by string REMOTE -resources.external_locations.*.url string ALL +resources.external_locations.*.name *string ALL +resources.external_locations.*.owner *string REMOTE +resources.external_locations.*.read_only *bool ALL +resources.external_locations.*.skip_validation *bool INPUT STATE +resources.external_locations.*.updated_at *int64 REMOTE +resources.external_locations.*.updated_by *string REMOTE +resources.external_locations.*.url *string ALL resources.external_locations.*.grants.full_name string ALL resources.external_locations.*.grants.securable_type string ALL -resources.external_locations.*.grants[*] catalog.PrivilegeAssignment ALL -resources.external_locations.*.grants[*].principal string ALL -resources.external_locations.*.grants[*].privileges []catalog.Privilege ALL -resources.external_locations.*.grants[*].privileges[*] catalog.Privilege ALL +resources.external_locations.*.grants[*] grants.PrivilegeAssignment ALL +resources.external_locations.*.grants[*].principal *string ALL +resources.external_locations.*.grants[*].privileges []string ALL +resources.external_locations.*.grants[*].privileges[*] string ALL resources.genie_spaces.*.description string ALL resources.genie_spaces.*.etag string ALL resources.genie_spaces.*.file_path string INPUT @@ -854,75 +858,75 @@ resources.genie_spaces.*.warehouse_id string ALL resources.genie_spaces.*.permissions.object_id string ALL resources.genie_spaces.*.permissions[*] dresources.StatePermission ALL resources.genie_spaces.*.permissions[*].group_name string ALL -resources.genie_spaces.*.permissions[*].level iam.PermissionLevel ALL +resources.genie_spaces.*.permissions[*].level resources.PermissionLevel ALL resources.genie_spaces.*.permissions[*].service_principal_name string ALL resources.genie_spaces.*.permissions[*].user_name string ALL -resources.instance_pools.*.aws_attributes *compute.InstancePoolAwsAttributes ALL -resources.instance_pools.*.aws_attributes.availability compute.InstancePoolAwsAttributesAvailability ALL -resources.instance_pools.*.aws_attributes.instance_profile_arn string ALL -resources.instance_pools.*.aws_attributes.spot_bid_price_percent int ALL -resources.instance_pools.*.aws_attributes.zone_id string ALL -resources.instance_pools.*.azure_attributes *compute.InstancePoolAzureAttributes ALL -resources.instance_pools.*.azure_attributes.availability compute.InstancePoolAzureAttributesAvailability ALL -resources.instance_pools.*.azure_attributes.capacity_reservation_group string ALL -resources.instance_pools.*.azure_attributes.spot_bid_max_price float64 ALL +resources.instance_pools.*.aws_attributes *instancepools.InstancePoolAwsAttributes ALL +resources.instance_pools.*.aws_attributes.availability instancepools.AwsAvailability ALL +resources.instance_pools.*.aws_attributes.instance_profile_arn *string ALL +resources.instance_pools.*.aws_attributes.spot_bid_price_percent *int ALL +resources.instance_pools.*.aws_attributes.zone_id *string ALL +resources.instance_pools.*.azure_attributes *instancepools.InstancePoolAzureAttributes ALL +resources.instance_pools.*.azure_attributes.availability instancepools.AzureAvailability ALL +resources.instance_pools.*.azure_attributes.capacity_reservation_group *string ALL +resources.instance_pools.*.azure_attributes.spot_bid_max_price *float64 ALL resources.instance_pools.*.custom_tags map[string]string ALL resources.instance_pools.*.custom_tags.* string ALL resources.instance_pools.*.default_tags map[string]string REMOTE resources.instance_pools.*.default_tags.* string REMOTE -resources.instance_pools.*.disk_spec *compute.DiskSpec ALL -resources.instance_pools.*.disk_spec.disk_count int ALL -resources.instance_pools.*.disk_spec.disk_iops int ALL -resources.instance_pools.*.disk_spec.disk_size int ALL -resources.instance_pools.*.disk_spec.disk_throughput int ALL -resources.instance_pools.*.disk_spec.disk_type *compute.DiskType ALL -resources.instance_pools.*.disk_spec.disk_type.azure_disk_volume_type compute.DiskTypeAzureDiskVolumeType ALL -resources.instance_pools.*.disk_spec.disk_type.ebs_volume_type compute.DiskTypeEbsVolumeType ALL -resources.instance_pools.*.enable_elastic_disk bool ALL -resources.instance_pools.*.gcp_attributes *compute.InstancePoolGcpAttributes ALL -resources.instance_pools.*.gcp_attributes.gcp_availability compute.GcpAvailability ALL -resources.instance_pools.*.gcp_attributes.local_ssd_count int ALL -resources.instance_pools.*.gcp_attributes.zone_id string ALL +resources.instance_pools.*.disk_spec *instancepools.DiskSpec ALL +resources.instance_pools.*.disk_spec.disk_count *int ALL +resources.instance_pools.*.disk_spec.disk_iops *int ALL +resources.instance_pools.*.disk_spec.disk_size *int ALL +resources.instance_pools.*.disk_spec.disk_throughput *int ALL +resources.instance_pools.*.disk_spec.disk_type *instancepools.DiskType ALL +resources.instance_pools.*.disk_spec.disk_type.azure_disk_volume_type instancepools.AzureDiskVolumeType ALL +resources.instance_pools.*.disk_spec.disk_type.ebs_volume_type instancepools.EbsVolumeType ALL +resources.instance_pools.*.enable_elastic_disk *bool ALL +resources.instance_pools.*.gcp_attributes *instancepools.InstancePoolGcpAttributes ALL +resources.instance_pools.*.gcp_attributes.gcp_availability instancepools.GcpAvailability ALL +resources.instance_pools.*.gcp_attributes.local_ssd_count *int ALL +resources.instance_pools.*.gcp_attributes.zone_id *string ALL resources.instance_pools.*.id string INPUT -resources.instance_pools.*.idle_instance_autotermination_minutes int ALL -resources.instance_pools.*.instance_pool_id string REMOTE -resources.instance_pools.*.instance_pool_name string ALL +resources.instance_pools.*.idle_instance_autotermination_minutes *int ALL +resources.instance_pools.*.instance_pool_id *string REMOTE +resources.instance_pools.*.instance_pool_name *string ALL resources.instance_pools.*.lifecycle resources.Lifecycle INPUT resources.instance_pools.*.lifecycle.prevent_destroy bool INPUT -resources.instance_pools.*.max_capacity int ALL -resources.instance_pools.*.min_idle_instances int ALL +resources.instance_pools.*.max_capacity *int ALL +resources.instance_pools.*.min_idle_instances *int ALL resources.instance_pools.*.modified_status string INPUT -resources.instance_pools.*.node_type_flexibility *compute.NodeTypeFlexibility ALL +resources.instance_pools.*.node_type_flexibility *instancepools.NodeTypeFlexibility ALL resources.instance_pools.*.node_type_flexibility.alternate_node_type_ids []string ALL resources.instance_pools.*.node_type_flexibility.alternate_node_type_ids[*] string ALL -resources.instance_pools.*.node_type_flexibility.aws_context_id string ALL -resources.instance_pools.*.node_type_id string ALL -resources.instance_pools.*.preloaded_docker_images []compute.DockerImage ALL -resources.instance_pools.*.preloaded_docker_images[*] compute.DockerImage ALL -resources.instance_pools.*.preloaded_docker_images[*].basic_auth *compute.DockerBasicAuth ALL -resources.instance_pools.*.preloaded_docker_images[*].basic_auth.password string ALL -resources.instance_pools.*.preloaded_docker_images[*].basic_auth.username string ALL -resources.instance_pools.*.preloaded_docker_images[*].url string ALL +resources.instance_pools.*.node_type_flexibility.aws_context_id *string ALL +resources.instance_pools.*.node_type_id *string ALL +resources.instance_pools.*.preloaded_docker_images []instancepools.DockerImage ALL +resources.instance_pools.*.preloaded_docker_images[*] instancepools.DockerImage ALL +resources.instance_pools.*.preloaded_docker_images[*].basic_auth *instancepools.DockerBasicAuth ALL +resources.instance_pools.*.preloaded_docker_images[*].basic_auth.password *string ALL +resources.instance_pools.*.preloaded_docker_images[*].basic_auth.username *string ALL +resources.instance_pools.*.preloaded_docker_images[*].url *string ALL resources.instance_pools.*.preloaded_spark_versions []string ALL resources.instance_pools.*.preloaded_spark_versions[*] string ALL -resources.instance_pools.*.remote_disk_throughput int ALL -resources.instance_pools.*.state compute.InstancePoolState REMOTE -resources.instance_pools.*.stats *compute.InstancePoolStats REMOTE -resources.instance_pools.*.stats.idle_count int REMOTE -resources.instance_pools.*.stats.pending_idle_count int REMOTE -resources.instance_pools.*.stats.pending_used_count int REMOTE -resources.instance_pools.*.stats.used_count int REMOTE -resources.instance_pools.*.status *compute.InstancePoolStatus REMOTE -resources.instance_pools.*.status.pending_instance_errors []compute.PendingInstanceError REMOTE -resources.instance_pools.*.status.pending_instance_errors[*] compute.PendingInstanceError REMOTE -resources.instance_pools.*.status.pending_instance_errors[*].instance_id string REMOTE -resources.instance_pools.*.status.pending_instance_errors[*].message string REMOTE -resources.instance_pools.*.total_initial_remote_disk_size int ALL +resources.instance_pools.*.remote_disk_throughput *int ALL +resources.instance_pools.*.state instancepools.InstancePoolState REMOTE +resources.instance_pools.*.stats *instancepools.InstancePoolStats REMOTE +resources.instance_pools.*.stats.idle_count *int REMOTE +resources.instance_pools.*.stats.pending_idle_count *int REMOTE +resources.instance_pools.*.stats.pending_used_count *int REMOTE +resources.instance_pools.*.stats.used_count *int REMOTE +resources.instance_pools.*.status *instancepools.InstancePoolStatus REMOTE +resources.instance_pools.*.status.pending_instance_errors []instancepools.PendingInstanceError REMOTE +resources.instance_pools.*.status.pending_instance_errors[*] instancepools.PendingInstanceError REMOTE +resources.instance_pools.*.status.pending_instance_errors[*].instance_id *string REMOTE +resources.instance_pools.*.status.pending_instance_errors[*].message *string REMOTE +resources.instance_pools.*.total_initial_remote_disk_size *int ALL resources.instance_pools.*.url string INPUT resources.instance_pools.*.permissions.object_id string ALL resources.instance_pools.*.permissions[*] dresources.StatePermission ALL resources.instance_pools.*.permissions[*].group_name string ALL -resources.instance_pools.*.permissions[*].level iam.PermissionLevel ALL +resources.instance_pools.*.permissions[*].level resources.PermissionLevel ALL resources.instance_pools.*.permissions[*].service_principal_name string ALL resources.instance_pools.*.permissions[*].user_name string ALL resources.internal_immutable_snapshots.*.acl []snapshot.ACLEntry INPUT STATE @@ -939,10 +943,10 @@ resources.internal_immutable_snapshots.*.zip_path string INPUT STATE resources.job_runs.*.dbt_commands []string ALL resources.job_runs.*.dbt_commands[*] string ALL resources.job_runs.*.id string INPUT -resources.job_runs.*.idempotency_token string ALL +resources.job_runs.*.idempotency_token *string ALL resources.job_runs.*.jar_params []string ALL resources.job_runs.*.jar_params[*] string ALL -resources.job_runs.*.job_id int64 ALL +resources.job_runs.*.job_id *int64 ALL resources.job_runs.*.job_parameters map[string]string ALL resources.job_runs.*.job_parameters.* string ALL resources.job_runs.*.lifecycle *dresources.JobRunLifecycleState STATE @@ -962,9 +966,9 @@ resources.job_runs.*.notebook_params map[string]string ALL resources.job_runs.*.notebook_params.* string ALL resources.job_runs.*.only []string ALL resources.job_runs.*.only[*] string ALL -resources.job_runs.*.performance_target jobs.PerformanceTarget ALL -resources.job_runs.*.pipeline_params *jobs.PipelineParams ALL -resources.job_runs.*.pipeline_params.full_refresh bool ALL +resources.job_runs.*.performance_target jobs.PerformanceTarget_PerformanceTarget ALL +resources.job_runs.*.pipeline_params *jobs.PipelineParameters ALL +resources.job_runs.*.pipeline_params.full_refresh *bool ALL resources.job_runs.*.pipeline_params.full_refresh_selection []string ALL resources.job_runs.*.pipeline_params.full_refresh_selection[*] string ALL resources.job_runs.*.pipeline_params.refresh_flow_selection []string ALL @@ -978,9 +982,9 @@ resources.job_runs.*.python_named_params.* string ALL resources.job_runs.*.python_params []string ALL resources.job_runs.*.python_params[*] string ALL resources.job_runs.*.queue *jobs.QueueSettings ALL -resources.job_runs.*.queue.enabled bool ALL +resources.job_runs.*.queue.enabled *bool ALL resources.job_runs.*.resolved_job_id int64 INPUT -resources.job_runs.*.result_state jobs.RunResultState REMOTE STATE +resources.job_runs.*.result_state jobs.RunResultState_RunResultState REMOTE STATE resources.job_runs.*.run_id int64 REMOTE resources.job_runs.*.run_name string REMOTE resources.job_runs.*.run_page_url string REMOTE @@ -990,33 +994,34 @@ resources.job_runs.*.spark_submit_params[*] string ALL resources.job_runs.*.sql_params map[string]string ALL resources.job_runs.*.sql_params.* string ALL resources.job_runs.*.state *jobs.RunState REMOTE -resources.job_runs.*.state.life_cycle_state jobs.RunLifeCycleState REMOTE -resources.job_runs.*.state.queue_reason string REMOTE -resources.job_runs.*.state.result_state jobs.RunResultState REMOTE -resources.job_runs.*.state.state_message string REMOTE -resources.job_runs.*.state.user_cancelled_or_timedout bool REMOTE +resources.job_runs.*.state.life_cycle_state jobs.RunLifeCycleState_RunLifeCycleState REMOTE +resources.job_runs.*.state.queue_reason *string REMOTE +resources.job_runs.*.state.result_state jobs.RunResultState_RunResultState REMOTE +resources.job_runs.*.state.state_message *string REMOTE +resources.job_runs.*.state.user_cancelled_or_timedout *bool REMOTE resources.job_runs.*.url string INPUT -resources.jobs.*.budget_policy_id string ALL -resources.jobs.*.continuous *jobs.Continuous ALL +resources.jobs.*.budget_policy_id *string ALL +resources.jobs.*.continuous *jobs.ContinuousSettings ALL resources.jobs.*.continuous.maintenance_window *jobs.MaintenanceWindow ALL resources.jobs.*.continuous.maintenance_window.day_of_week jobs.DayOfWeek ALL -resources.jobs.*.continuous.maintenance_window.start_hour int ALL -resources.jobs.*.continuous.maintenance_window.timezone_id string ALL -resources.jobs.*.continuous.pause_status jobs.PauseStatus ALL +resources.jobs.*.continuous.maintenance_window.start_hour *int ALL +resources.jobs.*.continuous.maintenance_window.timezone_id *string ALL +resources.jobs.*.continuous.pause_status jobs.SchedulePauseStatus ALL resources.jobs.*.continuous.task_retry_mode jobs.TaskRetryMode ALL -resources.jobs.*.created_time int64 REMOTE -resources.jobs.*.creator_user_name string REMOTE +resources.jobs.*.created_time *int64 REMOTE +resources.jobs.*.creator_user_name *string REMOTE resources.jobs.*.deployment *jobs.JobDeployment ALL -resources.jobs.*.deployment.deployment_id string ALL -resources.jobs.*.deployment.kind jobs.JobDeploymentKind ALL -resources.jobs.*.deployment.metadata_file_path string ALL -resources.jobs.*.deployment.version_id string ALL -resources.jobs.*.description string ALL +resources.jobs.*.deployment.deployment_id *string ALL +resources.jobs.*.deployment.kind jobs.JobDeployment_DeploymentKind ALL +resources.jobs.*.deployment.metadata_file_path *string ALL +resources.jobs.*.deployment.version_id *string ALL +resources.jobs.*.description *string ALL +resources.jobs.*.disable_auto_optimization *bool ALL resources.jobs.*.edit_mode jobs.JobEditMode ALL -resources.jobs.*.effective_budget_policy_id string REMOTE -resources.jobs.*.effective_usage_policy_id string REMOTE +resources.jobs.*.effective_budget_policy_id *string REMOTE +resources.jobs.*.effective_usage_policy_id *string REMOTE resources.jobs.*.email_notifications *jobs.JobEmailNotifications ALL -resources.jobs.*.email_notifications.no_alert_for_skipped_runs bool ALL +resources.jobs.*.email_notifications.no_alert_for_skipped_runs *bool ALL resources.jobs.*.email_notifications.on_duration_warning_threshold_exceeded []string ALL resources.jobs.*.email_notifications.on_duration_warning_threshold_exceeded[*] string ALL resources.jobs.*.email_notifications.on_failure []string ALL @@ -1033,7 +1038,7 @@ resources.jobs.*.email_notifications.on_success []string ALL resources.jobs.*.email_notifications.on_success[*] string ALL resources.jobs.*.environment_variables []jobs.JobEnvironmentVariables ALL resources.jobs.*.environment_variables[*] jobs.JobEnvironmentVariables ALL -resources.jobs.*.environment_variables[*].environment_variables_key string ALL +resources.jobs.*.environment_variables[*].environment_variables_key *string ALL resources.jobs.*.environment_variables[*].spec *jobs.JobEnvironmentVariablesSpec ALL resources.jobs.*.environment_variables[*].spec.files []string ALL resources.jobs.*.environment_variables[*].spec.files[*] string ALL @@ -1041,29 +1046,29 @@ resources.jobs.*.environment_variables[*].spec.variables map[string]string ALL resources.jobs.*.environment_variables[*].spec.variables.* string ALL resources.jobs.*.environments []jobs.JobEnvironment ALL resources.jobs.*.environments[*] jobs.JobEnvironment ALL -resources.jobs.*.environments[*].environment_key string ALL -resources.jobs.*.environments[*].spec *compute.Environment ALL -resources.jobs.*.environments[*].spec.base_environment string ALL -resources.jobs.*.environments[*].spec.client string ALL +resources.jobs.*.environments[*].environment_key *string ALL +resources.jobs.*.environments[*].spec *jobs.Environment ALL +resources.jobs.*.environments[*].spec.base_environment *string ALL +resources.jobs.*.environments[*].spec.client *string ALL resources.jobs.*.environments[*].spec.dependencies []string ALL resources.jobs.*.environments[*].spec.dependencies[*] string ALL -resources.jobs.*.environments[*].spec.environment_version string ALL +resources.jobs.*.environments[*].spec.environment_version *string ALL resources.jobs.*.environments[*].spec.java_dependencies []string ALL resources.jobs.*.environments[*].spec.java_dependencies[*] string ALL -resources.jobs.*.environments[*].spec.project_environment string ALL +resources.jobs.*.environments[*].spec.project_environment *string ALL resources.jobs.*.format jobs.Format ALL resources.jobs.*.git_source *jobs.GitSource ALL -resources.jobs.*.git_source.git_branch string ALL -resources.jobs.*.git_source.git_commit string ALL -resources.jobs.*.git_source.git_provider jobs.GitProvider ALL -resources.jobs.*.git_source.git_snapshot *jobs.GitSnapshot ALL -resources.jobs.*.git_source.git_snapshot.used_commit string ALL -resources.jobs.*.git_source.git_tag string ALL -resources.jobs.*.git_source.git_url string ALL +resources.jobs.*.git_source.git_branch *string ALL +resources.jobs.*.git_source.git_commit *string ALL +resources.jobs.*.git_source.git_provider *string ALL +resources.jobs.*.git_source.git_snapshot *jobs.GitMetadataSnapshot ALL +resources.jobs.*.git_source.git_snapshot.used_commit *string ALL +resources.jobs.*.git_source.git_tag *string ALL +resources.jobs.*.git_source.git_url *string ALL resources.jobs.*.git_source.job_source *jobs.JobSource ALL -resources.jobs.*.git_source.job_source.dirty_state jobs.JobSourceDirtyState ALL -resources.jobs.*.git_source.job_source.import_from_git_branch string ALL -resources.jobs.*.git_source.job_source.job_config_path string ALL +resources.jobs.*.git_source.job_source.dirty_state jobs.JobSource_DirtyState ALL +resources.jobs.*.git_source.job_source.import_from_git_branch *string ALL +resources.jobs.*.git_source.job_source.job_config_path *string ALL resources.jobs.*.git_source.sparse_checkout *jobs.SparseCheckout ALL resources.jobs.*.git_source.sparse_checkout.patterns []string ALL resources.jobs.*.git_source.sparse_checkout.patterns[*] string ALL @@ -1072,234 +1077,239 @@ resources.jobs.*.health.rules []jobs.JobsHealthRule ALL resources.jobs.*.health.rules[*] jobs.JobsHealthRule ALL resources.jobs.*.health.rules[*].metric jobs.JobsHealthMetric ALL resources.jobs.*.health.rules[*].op jobs.JobsHealthOperator ALL -resources.jobs.*.health.rules[*].value int64 ALL +resources.jobs.*.health.rules[*].value *int64 ALL resources.jobs.*.id string INPUT resources.jobs.*.job_clusters []jobs.JobCluster ALL resources.jobs.*.job_clusters[*] jobs.JobCluster ALL -resources.jobs.*.job_clusters[*].job_cluster_key string ALL -resources.jobs.*.job_clusters[*].new_cluster *compute.ClusterSpec ALL -resources.jobs.*.job_clusters[*].new_cluster.apply_policy_default_values bool ALL -resources.jobs.*.job_clusters[*].new_cluster.autoscale *compute.AutoScale ALL -resources.jobs.*.job_clusters[*].new_cluster.autoscale.max_workers int ALL -resources.jobs.*.job_clusters[*].new_cluster.autoscale.min_workers int ALL -resources.jobs.*.job_clusters[*].new_cluster.autotermination_minutes int ALL -resources.jobs.*.job_clusters[*].new_cluster.aws_attributes *compute.AwsAttributes ALL -resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.availability compute.AwsAvailability ALL -resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.ebs_volume_count int ALL -resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.ebs_volume_iops int ALL -resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.ebs_volume_size int ALL -resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.ebs_volume_throughput int ALL -resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.ebs_volume_type compute.EbsVolumeType ALL -resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.first_on_demand int ALL -resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.instance_profile_arn string ALL -resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.spot_bid_price_percent int ALL -resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.zone_id string ALL -resources.jobs.*.job_clusters[*].new_cluster.azure_attributes *compute.AzureAttributes ALL -resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.availability compute.AzureAvailability ALL -resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.capacity_reservation_group string ALL -resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.first_on_demand int ALL -resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.log_analytics_info *compute.LogAnalyticsInfo ALL -resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.log_analytics_info.log_analytics_primary_key string ALL -resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.log_analytics_info.log_analytics_workspace_id string ALL -resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.spot_bid_max_price float64 ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf *compute.ClusterLogConf ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.dbfs *compute.DbfsStorageInfo ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.dbfs.destination string ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3 *compute.S3StorageInfo ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.canned_acl string ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.destination string ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.enable_encryption bool ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.encryption_type string ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.endpoint string ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.kms_key string ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.region string ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.volumes *compute.VolumesStorageInfo ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.volumes.destination string ALL -resources.jobs.*.job_clusters[*].new_cluster.cluster_name string ALL +resources.jobs.*.job_clusters[*].job_cluster_key *string ALL +resources.jobs.*.job_clusters[*].new_cluster *jobs.ClusterSpec_NewCluster ALL +resources.jobs.*.job_clusters[*].new_cluster.apply_policy_default_values *bool ALL +resources.jobs.*.job_clusters[*].new_cluster.autoscale *jobs.AutoScale ALL +resources.jobs.*.job_clusters[*].new_cluster.autoscale.max_workers *int ALL +resources.jobs.*.job_clusters[*].new_cluster.autoscale.min_workers *int ALL +resources.jobs.*.job_clusters[*].new_cluster.autotermination_minutes *int ALL +resources.jobs.*.job_clusters[*].new_cluster.aws_attributes *jobs.AwsAttributes ALL +resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.availability jobs.AwsAvailability ALL +resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.ebs_volume_count *int ALL +resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.ebs_volume_iops *int ALL +resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.ebs_volume_size *int ALL +resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.ebs_volume_throughput *int ALL +resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.ebs_volume_type jobs.EbsVolumeType ALL +resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.first_on_demand *int ALL +resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.instance_profile_arn *string ALL +resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.spot_bid_price_percent *int ALL +resources.jobs.*.job_clusters[*].new_cluster.aws_attributes.zone_id *string ALL +resources.jobs.*.job_clusters[*].new_cluster.azure_attributes *jobs.AzureAttributes ALL +resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.availability jobs.AzureAvailability ALL +resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.capacity_reservation_group *string ALL +resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.first_on_demand *int ALL +resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.log_analytics_info *jobs.LogAnalyticsInfo ALL +resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.log_analytics_info.log_analytics_primary_key *string ALL +resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.log_analytics_info.log_analytics_workspace_id *string ALL +resources.jobs.*.job_clusters[*].new_cluster.azure_attributes.spot_bid_max_price *float64 ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf *jobs.ClusterLogConf ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.dbfs *jobs.DbfsStorageInfo ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.dbfs.destination *string ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3 *jobs.S3StorageInfo ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.canned_acl *string ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.destination *string ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.enable_encryption *bool ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.encryption_type *string ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.endpoint *string ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.kms_key *string ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.s3.region *string ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.volumes *jobs.VolumesStorageInfo ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_log_conf.volumes.destination *string ALL +resources.jobs.*.job_clusters[*].new_cluster.cluster_name *string ALL resources.jobs.*.job_clusters[*].new_cluster.custom_tags map[string]string ALL resources.jobs.*.job_clusters[*].new_cluster.custom_tags.* string ALL -resources.jobs.*.job_clusters[*].new_cluster.data_security_mode compute.DataSecurityMode ALL -resources.jobs.*.job_clusters[*].new_cluster.dependency_mode compute.DependencyMode ALL -resources.jobs.*.job_clusters[*].new_cluster.docker_image *compute.DockerImage ALL -resources.jobs.*.job_clusters[*].new_cluster.docker_image.basic_auth *compute.DockerBasicAuth ALL -resources.jobs.*.job_clusters[*].new_cluster.docker_image.basic_auth.password string ALL -resources.jobs.*.job_clusters[*].new_cluster.docker_image.basic_auth.username string ALL -resources.jobs.*.job_clusters[*].new_cluster.docker_image.url string ALL -resources.jobs.*.job_clusters[*].new_cluster.driver_instance_pool_id string ALL -resources.jobs.*.job_clusters[*].new_cluster.driver_node_type_flexibility *compute.NodeTypeFlexibility ALL +resources.jobs.*.job_clusters[*].new_cluster.data_security_mode jobs.DataSecurityMode ALL +resources.jobs.*.job_clusters[*].new_cluster.dependency_mode jobs.DependencyMode ALL +resources.jobs.*.job_clusters[*].new_cluster.docker_image *jobs.DockerImage ALL +resources.jobs.*.job_clusters[*].new_cluster.docker_image.basic_auth *jobs.DockerBasicAuth ALL +resources.jobs.*.job_clusters[*].new_cluster.docker_image.basic_auth.password *string ALL +resources.jobs.*.job_clusters[*].new_cluster.docker_image.basic_auth.username *string ALL +resources.jobs.*.job_clusters[*].new_cluster.docker_image.url *string ALL +resources.jobs.*.job_clusters[*].new_cluster.driver_instance_pool_id *string ALL +resources.jobs.*.job_clusters[*].new_cluster.driver_node_type_flexibility *jobs.NodeTypeFlexibility ALL resources.jobs.*.job_clusters[*].new_cluster.driver_node_type_flexibility.alternate_node_type_ids []string ALL resources.jobs.*.job_clusters[*].new_cluster.driver_node_type_flexibility.alternate_node_type_ids[*] string ALL -resources.jobs.*.job_clusters[*].new_cluster.driver_node_type_flexibility.aws_context_id string ALL -resources.jobs.*.job_clusters[*].new_cluster.driver_node_type_id string ALL -resources.jobs.*.job_clusters[*].new_cluster.enable_elastic_disk bool ALL -resources.jobs.*.job_clusters[*].new_cluster.enable_local_disk_encryption bool ALL -resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes *compute.GcpAttributes ALL -resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.availability compute.GcpAvailability ALL -resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.boot_disk_size int ALL -resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.confidential_compute_type compute.ConfidentialComputeType ALL -resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.first_on_demand int ALL -resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.google_service_account string ALL -resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.local_ssd_count int ALL -resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.use_preemptible_executors bool ALL -resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.zone_id string ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts []compute.InitScriptInfo ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*] compute.InitScriptInfo ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].abfss *compute.Adlsgen2Info ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].abfss.destination string ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].dbfs *compute.DbfsStorageInfo ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].dbfs.destination string ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].file *compute.LocalFileInfo ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].file.destination string ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].gcs *compute.GcsStorageInfo ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].gcs.destination string ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3 *compute.S3StorageInfo ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.canned_acl string ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.destination string ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.enable_encryption bool ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.encryption_type string ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.endpoint string ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.kms_key string ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.region string ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].volumes *compute.VolumesStorageInfo ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].volumes.destination string ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].workspace *compute.WorkspaceStorageInfo ALL -resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].workspace.destination string ALL -resources.jobs.*.job_clusters[*].new_cluster.instance_pool_id string ALL -resources.jobs.*.job_clusters[*].new_cluster.is_single_node bool ALL -resources.jobs.*.job_clusters[*].new_cluster.kind compute.Kind ALL -resources.jobs.*.job_clusters[*].new_cluster.node_type_id string ALL -resources.jobs.*.job_clusters[*].new_cluster.num_workers int ALL -resources.jobs.*.job_clusters[*].new_cluster.policy_id string ALL -resources.jobs.*.job_clusters[*].new_cluster.remote_disk_throughput int ALL -resources.jobs.*.job_clusters[*].new_cluster.runtime_engine compute.RuntimeEngine ALL -resources.jobs.*.job_clusters[*].new_cluster.single_user_name string ALL +resources.jobs.*.job_clusters[*].new_cluster.driver_node_type_flexibility.aws_context_id *string ALL +resources.jobs.*.job_clusters[*].new_cluster.driver_node_type_id *string ALL +resources.jobs.*.job_clusters[*].new_cluster.enable_elastic_disk *bool ALL +resources.jobs.*.job_clusters[*].new_cluster.enable_local_disk_encryption *bool ALL +resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes *jobs.GcpAttributes ALL +resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.availability jobs.GcpAvailability ALL +resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.boot_disk_size *int ALL +resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.confidential_compute_type jobs.ConfidentialComputeType ALL +resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.first_on_demand *int ALL +resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.google_service_account *string ALL +resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.local_ssd_count *int ALL +resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.use_preemptible_executors *bool ALL +resources.jobs.*.job_clusters[*].new_cluster.gcp_attributes.zone_id *string ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts []jobs.InitScriptInfo ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*] jobs.InitScriptInfo ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].abfss *jobs.Adlsgen2Info ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].abfss.destination *string ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].dbfs *jobs.DbfsStorageInfo ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].dbfs.destination *string ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].file *jobs.LocalFileInfo ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].file.destination *string ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].gcs *jobs.GcsStorageInfo ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].gcs.destination *string ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3 *jobs.S3StorageInfo ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.canned_acl *string ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.destination *string ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.enable_encryption *bool ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.encryption_type *string ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.endpoint *string ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.kms_key *string ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].s3.region *string ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].volumes *jobs.VolumesStorageInfo ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].volumes.destination *string ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].workspace *jobs.WorkspaceStorageInfo ALL +resources.jobs.*.job_clusters[*].new_cluster.init_scripts[*].workspace.destination *string ALL +resources.jobs.*.job_clusters[*].new_cluster.instance_pool_id *string ALL +resources.jobs.*.job_clusters[*].new_cluster.is_single_node *bool ALL +resources.jobs.*.job_clusters[*].new_cluster.kind jobs.ComputeKind ALL +resources.jobs.*.job_clusters[*].new_cluster.node_type_id *string ALL +resources.jobs.*.job_clusters[*].new_cluster.num_workers *int ALL +resources.jobs.*.job_clusters[*].new_cluster.policy_id *string ALL +resources.jobs.*.job_clusters[*].new_cluster.remote_disk_throughput *int ALL +resources.jobs.*.job_clusters[*].new_cluster.runtime_engine jobs.RuntimeEngine ALL +resources.jobs.*.job_clusters[*].new_cluster.single_user_name *string ALL resources.jobs.*.job_clusters[*].new_cluster.spark_conf map[string]string ALL resources.jobs.*.job_clusters[*].new_cluster.spark_conf.* string ALL resources.jobs.*.job_clusters[*].new_cluster.spark_env_vars map[string]string ALL resources.jobs.*.job_clusters[*].new_cluster.spark_env_vars.* string ALL -resources.jobs.*.job_clusters[*].new_cluster.spark_version string ALL +resources.jobs.*.job_clusters[*].new_cluster.spark_version *string ALL resources.jobs.*.job_clusters[*].new_cluster.ssh_public_keys []string ALL resources.jobs.*.job_clusters[*].new_cluster.ssh_public_keys[*] string ALL -resources.jobs.*.job_clusters[*].new_cluster.total_initial_remote_disk_size int ALL -resources.jobs.*.job_clusters[*].new_cluster.use_ml_runtime bool ALL -resources.jobs.*.job_clusters[*].new_cluster.worker_node_type_flexibility *compute.NodeTypeFlexibility ALL +resources.jobs.*.job_clusters[*].new_cluster.total_initial_remote_disk_size *int ALL +resources.jobs.*.job_clusters[*].new_cluster.use_ml_runtime *bool ALL +resources.jobs.*.job_clusters[*].new_cluster.worker_node_type_flexibility *jobs.NodeTypeFlexibility ALL resources.jobs.*.job_clusters[*].new_cluster.worker_node_type_flexibility.alternate_node_type_ids []string ALL resources.jobs.*.job_clusters[*].new_cluster.worker_node_type_flexibility.alternate_node_type_ids[*] string ALL -resources.jobs.*.job_clusters[*].new_cluster.worker_node_type_flexibility.aws_context_id string ALL -resources.jobs.*.job_clusters[*].new_cluster.workload_type *compute.WorkloadType ALL -resources.jobs.*.job_clusters[*].new_cluster.workload_type.clients compute.ClientsTypes ALL -resources.jobs.*.job_clusters[*].new_cluster.workload_type.clients.jobs bool ALL -resources.jobs.*.job_clusters[*].new_cluster.workload_type.clients.notebooks bool ALL -resources.jobs.*.job_clusters[*].serverless_compute_id string ALL -resources.jobs.*.job_id int64 REMOTE +resources.jobs.*.job_clusters[*].new_cluster.worker_node_type_flexibility.aws_context_id *string ALL +resources.jobs.*.job_clusters[*].new_cluster.workload_type *jobs.WorkloadType ALL +resources.jobs.*.job_clusters[*].new_cluster.workload_type.clients *jobs.WorkloadType_ClientsTypes ALL +resources.jobs.*.job_clusters[*].new_cluster.workload_type.clients.jobs *bool ALL +resources.jobs.*.job_clusters[*].new_cluster.workload_type.clients.notebooks *bool ALL +resources.jobs.*.job_clusters[*].serverless_compute_id *string ALL +resources.jobs.*.job_id *int64 REMOTE resources.jobs.*.lifecycle resources.Lifecycle INPUT resources.jobs.*.lifecycle.prevent_destroy bool INPUT -resources.jobs.*.max_concurrent_runs int ALL +resources.jobs.*.max_concurrent_runs *int ALL +resources.jobs.*.max_retries *int ALL +resources.jobs.*.min_retry_interval_millis *int ALL resources.jobs.*.modified_status string INPUT -resources.jobs.*.name string ALL -resources.jobs.*.notification_settings *jobs.JobNotificationSettings ALL -resources.jobs.*.notification_settings.no_alert_for_canceled_runs bool ALL -resources.jobs.*.notification_settings.no_alert_for_skipped_runs bool ALL -resources.jobs.*.parameters []jobs.JobParameterDefinition ALL -resources.jobs.*.parameters[*] jobs.JobParameterDefinition ALL -resources.jobs.*.parameters[*].default string ALL -resources.jobs.*.parameters[*].name string ALL -resources.jobs.*.parent_path string ALL -resources.jobs.*.performance_target jobs.PerformanceTarget ALL +resources.jobs.*.name *string ALL +resources.jobs.*.notification_settings *jobs.NotificationSettings ALL +resources.jobs.*.notification_settings.alert_on_last_attempt *bool ALL +resources.jobs.*.notification_settings.no_alert_for_canceled_runs *bool ALL +resources.jobs.*.notification_settings.no_alert_for_skipped_runs *bool ALL +resources.jobs.*.parameters []jobs.JobLevelParameter ALL +resources.jobs.*.parameters[*] jobs.JobLevelParameter ALL +resources.jobs.*.parameters[*].default *string ALL +resources.jobs.*.parameters[*].name *string ALL +resources.jobs.*.parent_path *string ALL +resources.jobs.*.performance_target jobs.PerformanceTarget_PerformanceTarget ALL resources.jobs.*.queue *jobs.QueueSettings ALL -resources.jobs.*.queue.enabled bool ALL +resources.jobs.*.queue.enabled *bool ALL +resources.jobs.*.retry_on_timeout *bool ALL resources.jobs.*.run_as *jobs.JobRunAs ALL -resources.jobs.*.run_as.group_name string ALL -resources.jobs.*.run_as.service_principal_name string ALL -resources.jobs.*.run_as.user_name string ALL -resources.jobs.*.run_as_user_name string REMOTE +resources.jobs.*.run_as.group_name *string ALL +resources.jobs.*.run_as.service_principal_name *string ALL +resources.jobs.*.run_as.user_name *string ALL +resources.jobs.*.run_as_user_name *string REMOTE resources.jobs.*.schedule *jobs.CronSchedule ALL -resources.jobs.*.schedule.pause_status jobs.PauseStatus ALL -resources.jobs.*.schedule.quartz_cron_expression string ALL +resources.jobs.*.schedule.pause_status jobs.SchedulePauseStatus ALL +resources.jobs.*.schedule.quartz_cron_expression *string ALL resources.jobs.*.schedule.sql_condition *jobs.SqlConditionConfiguration ALL -resources.jobs.*.schedule.sql_condition.sql_query_id string ALL +resources.jobs.*.schedule.sql_condition.sql_query_id *string ALL resources.jobs.*.schedule.sql_condition.trigger_mode jobs.SqlConditionTriggerMode ALL -resources.jobs.*.schedule.sql_condition.warehouse_id string ALL -resources.jobs.*.schedule.timezone_id string ALL +resources.jobs.*.schedule.sql_condition.warehouse_id *string ALL +resources.jobs.*.schedule.timezone_id *string ALL resources.jobs.*.tags map[string]string ALL resources.jobs.*.tags.* string ALL -resources.jobs.*.tasks []jobs.Task ALL -resources.jobs.*.tasks[*] jobs.Task ALL +resources.jobs.*.tasks []jobs.TaskSettings ALL +resources.jobs.*.tasks[*] jobs.TaskSettings ALL resources.jobs.*.tasks[*].ai_runtime_task *jobs.AiRuntimeTask ALL -resources.jobs.*.tasks[*].ai_runtime_task.code_source_path string ALL +resources.jobs.*.tasks[*].ai_runtime_task.code_source_path *string ALL resources.jobs.*.tasks[*].ai_runtime_task.deployments []jobs.DeploymentSpec ALL resources.jobs.*.tasks[*].ai_runtime_task.deployments[*] jobs.DeploymentSpec ALL -resources.jobs.*.tasks[*].ai_runtime_task.deployments[*].command_path string ALL -resources.jobs.*.tasks[*].ai_runtime_task.deployments[*].compute jobs.ComputeSpec ALL -resources.jobs.*.tasks[*].ai_runtime_task.deployments[*].compute.accelerator_count int ALL -resources.jobs.*.tasks[*].ai_runtime_task.deployments[*].compute.accelerator_type jobs.ComputeSpecAcceleratorType ALL -resources.jobs.*.tasks[*].ai_runtime_task.deployments[*].compute.provisioned_capacity_id string ALL -resources.jobs.*.tasks[*].ai_runtime_task.deployments[*].name string ALL -resources.jobs.*.tasks[*].ai_runtime_task.docker_image_url string ALL -resources.jobs.*.tasks[*].ai_runtime_task.experiment string ALL -resources.jobs.*.tasks[*].ai_runtime_task.mlflow_artifact_location string ALL -resources.jobs.*.tasks[*].ai_runtime_task.mlflow_experiment_directory string ALL -resources.jobs.*.tasks[*].ai_runtime_task.mlflow_run string ALL -resources.jobs.*.tasks[*].ai_runtime_task.priority_class jobs.AiRuntimeTaskPriorityClass ALL -resources.jobs.*.tasks[*].ai_runtime_task.unity_catalog_image_path string ALL +resources.jobs.*.tasks[*].ai_runtime_task.deployments[*].command_path *string ALL +resources.jobs.*.tasks[*].ai_runtime_task.deployments[*].compute *jobs.ComputeSpec ALL +resources.jobs.*.tasks[*].ai_runtime_task.deployments[*].compute.accelerator_count *int ALL +resources.jobs.*.tasks[*].ai_runtime_task.deployments[*].compute.accelerator_type jobs.ComputeSpec_AcceleratorType ALL +resources.jobs.*.tasks[*].ai_runtime_task.deployments[*].compute.provisioned_capacity_id *string ALL +resources.jobs.*.tasks[*].ai_runtime_task.deployments[*].name *string ALL +resources.jobs.*.tasks[*].ai_runtime_task.docker_image_url *string ALL +resources.jobs.*.tasks[*].ai_runtime_task.experiment *string ALL +resources.jobs.*.tasks[*].ai_runtime_task.mlflow_artifact_location *string ALL +resources.jobs.*.tasks[*].ai_runtime_task.mlflow_experiment_directory *string ALL +resources.jobs.*.tasks[*].ai_runtime_task.mlflow_run *string ALL +resources.jobs.*.tasks[*].ai_runtime_task.priority_class jobs.AiRuntimeTask_PriorityClass ALL +resources.jobs.*.tasks[*].ai_runtime_task.unity_catalog_image_path *string ALL resources.jobs.*.tasks[*].alert_task *jobs.AlertTask ALL -resources.jobs.*.tasks[*].alert_task.alert_id string ALL +resources.jobs.*.tasks[*].alert_task.alert_id *string ALL resources.jobs.*.tasks[*].alert_task.parameters map[string]string ALL resources.jobs.*.tasks[*].alert_task.parameters.* string ALL resources.jobs.*.tasks[*].alert_task.subscribers []jobs.AlertTaskSubscriber ALL resources.jobs.*.tasks[*].alert_task.subscribers[*] jobs.AlertTaskSubscriber ALL -resources.jobs.*.tasks[*].alert_task.subscribers[*].destination_id string ALL -resources.jobs.*.tasks[*].alert_task.subscribers[*].user_name string ALL -resources.jobs.*.tasks[*].alert_task.warehouse_id string ALL -resources.jobs.*.tasks[*].alert_task.workspace_path string ALL +resources.jobs.*.tasks[*].alert_task.subscribers[*].destination_id *string ALL +resources.jobs.*.tasks[*].alert_task.subscribers[*].user_name *string ALL +resources.jobs.*.tasks[*].alert_task.warehouse_id *string ALL +resources.jobs.*.tasks[*].alert_task.workspace_path *string ALL resources.jobs.*.tasks[*].clean_rooms_notebook_task *jobs.CleanRoomsNotebookTask ALL -resources.jobs.*.tasks[*].clean_rooms_notebook_task.clean_room_name string ALL -resources.jobs.*.tasks[*].clean_rooms_notebook_task.etag string ALL +resources.jobs.*.tasks[*].clean_rooms_notebook_task.clean_room_name *string ALL +resources.jobs.*.tasks[*].clean_rooms_notebook_task.etag *string ALL resources.jobs.*.tasks[*].clean_rooms_notebook_task.notebook_base_parameters map[string]string ALL resources.jobs.*.tasks[*].clean_rooms_notebook_task.notebook_base_parameters.* string ALL -resources.jobs.*.tasks[*].clean_rooms_notebook_task.notebook_name string ALL +resources.jobs.*.tasks[*].clean_rooms_notebook_task.notebook_name *string ALL resources.jobs.*.tasks[*].compute *jobs.Compute ALL -resources.jobs.*.tasks[*].compute.hardware_accelerator compute.HardwareAcceleratorType ALL +resources.jobs.*.tasks[*].compute.hardware_accelerator jobs.HardwareAcceleratorType ALL resources.jobs.*.tasks[*].condition_task *jobs.ConditionTask ALL -resources.jobs.*.tasks[*].condition_task.left string ALL -resources.jobs.*.tasks[*].condition_task.op jobs.ConditionTaskOp ALL -resources.jobs.*.tasks[*].condition_task.right string ALL +resources.jobs.*.tasks[*].condition_task.left *string ALL +resources.jobs.*.tasks[*].condition_task.op jobs.ConditionTask_ConditionTaskOperator ALL +resources.jobs.*.tasks[*].condition_task.outcome *string ALL +resources.jobs.*.tasks[*].condition_task.right *string ALL resources.jobs.*.tasks[*].dashboard_task *jobs.DashboardTask ALL -resources.jobs.*.tasks[*].dashboard_task.dashboard_id string ALL +resources.jobs.*.tasks[*].dashboard_task.dashboard_id *string ALL resources.jobs.*.tasks[*].dashboard_task.filters map[string]string ALL resources.jobs.*.tasks[*].dashboard_task.filters.* string ALL resources.jobs.*.tasks[*].dashboard_task.subscription *jobs.Subscription ALL -resources.jobs.*.tasks[*].dashboard_task.subscription.custom_subject string ALL -resources.jobs.*.tasks[*].dashboard_task.subscription.paused bool ALL -resources.jobs.*.tasks[*].dashboard_task.subscription.subscribers []jobs.SubscriptionSubscriber ALL -resources.jobs.*.tasks[*].dashboard_task.subscription.subscribers[*] jobs.SubscriptionSubscriber ALL -resources.jobs.*.tasks[*].dashboard_task.subscription.subscribers[*].destination_id string ALL -resources.jobs.*.tasks[*].dashboard_task.subscription.subscribers[*].user_name string ALL -resources.jobs.*.tasks[*].dashboard_task.warehouse_id string ALL +resources.jobs.*.tasks[*].dashboard_task.subscription.custom_subject *string ALL +resources.jobs.*.tasks[*].dashboard_task.subscription.paused *bool ALL +resources.jobs.*.tasks[*].dashboard_task.subscription.subscribers []jobs.Subscription_Subscriber ALL +resources.jobs.*.tasks[*].dashboard_task.subscription.subscribers[*] jobs.Subscription_Subscriber ALL +resources.jobs.*.tasks[*].dashboard_task.subscription.subscribers[*].destination_id *string ALL +resources.jobs.*.tasks[*].dashboard_task.subscription.subscribers[*].user_name *string ALL +resources.jobs.*.tasks[*].dashboard_task.warehouse_id *string ALL resources.jobs.*.tasks[*].dbt_cloud_task *jobs.DbtCloudTask ALL -resources.jobs.*.tasks[*].dbt_cloud_task.connection_resource_name string ALL -resources.jobs.*.tasks[*].dbt_cloud_task.dbt_cloud_job_id int64 ALL +resources.jobs.*.tasks[*].dbt_cloud_task.connection_resource_name *string ALL +resources.jobs.*.tasks[*].dbt_cloud_task.dbt_cloud_job_id *int64 ALL resources.jobs.*.tasks[*].dbt_platform_task *jobs.DbtPlatformTask ALL -resources.jobs.*.tasks[*].dbt_platform_task.connection_resource_name string ALL -resources.jobs.*.tasks[*].dbt_platform_task.dbt_platform_job_id string ALL +resources.jobs.*.tasks[*].dbt_platform_task.connection_resource_name *string ALL +resources.jobs.*.tasks[*].dbt_platform_task.dbt_platform_job_id *string ALL resources.jobs.*.tasks[*].dbt_task *jobs.DbtTask ALL -resources.jobs.*.tasks[*].dbt_task.catalog string ALL +resources.jobs.*.tasks[*].dbt_task.catalog *string ALL resources.jobs.*.tasks[*].dbt_task.commands []string ALL resources.jobs.*.tasks[*].dbt_task.commands[*] string ALL -resources.jobs.*.tasks[*].dbt_task.profiles_directory string ALL -resources.jobs.*.tasks[*].dbt_task.project_directory string ALL -resources.jobs.*.tasks[*].dbt_task.schema string ALL +resources.jobs.*.tasks[*].dbt_task.profiles_directory *string ALL +resources.jobs.*.tasks[*].dbt_task.project_directory *string ALL +resources.jobs.*.tasks[*].dbt_task.schema *string ALL resources.jobs.*.tasks[*].dbt_task.source jobs.Source ALL -resources.jobs.*.tasks[*].dbt_task.warehouse_id string ALL +resources.jobs.*.tasks[*].dbt_task.warehouse_id *string ALL resources.jobs.*.tasks[*].depends_on []jobs.TaskDependency ALL resources.jobs.*.tasks[*].depends_on[*] jobs.TaskDependency ALL -resources.jobs.*.tasks[*].depends_on[*].outcome string ALL -resources.jobs.*.tasks[*].depends_on[*].task_key string ALL -resources.jobs.*.tasks[*].description string ALL -resources.jobs.*.tasks[*].disable_auto_optimization bool ALL -resources.jobs.*.tasks[*].disabled bool ALL -resources.jobs.*.tasks[*].email_notifications *jobs.TaskEmailNotifications ALL -resources.jobs.*.tasks[*].email_notifications.no_alert_for_skipped_runs bool ALL +resources.jobs.*.tasks[*].depends_on[*].outcome *string ALL +resources.jobs.*.tasks[*].depends_on[*].task_key *string ALL +resources.jobs.*.tasks[*].description *string ALL +resources.jobs.*.tasks[*].disable_auto_optimization *bool ALL +resources.jobs.*.tasks[*].disabled *bool ALL +resources.jobs.*.tasks[*].email_notifications *jobs.JobEmailNotifications ALL +resources.jobs.*.tasks[*].email_notifications.no_alert_for_skipped_runs *bool ALL resources.jobs.*.tasks[*].email_notifications.on_duration_warning_threshold_exceeded []string ALL resources.jobs.*.tasks[*].email_notifications.on_duration_warning_threshold_exceeded[*] string ALL resources.jobs.*.tasks[*].email_notifications.on_failure []string ALL @@ -1314,88 +1324,89 @@ resources.jobs.*.tasks[*].email_notifications.on_streaming_backlog_exceeded []st resources.jobs.*.tasks[*].email_notifications.on_streaming_backlog_exceeded[*] string ALL resources.jobs.*.tasks[*].email_notifications.on_success []string ALL resources.jobs.*.tasks[*].email_notifications.on_success[*] string ALL -resources.jobs.*.tasks[*].environment_key string ALL -resources.jobs.*.tasks[*].environment_variables_key string ALL -resources.jobs.*.tasks[*].existing_cluster_id string ALL +resources.jobs.*.tasks[*].environment_key *string ALL +resources.jobs.*.tasks[*].environment_variables_key *string ALL +resources.jobs.*.tasks[*].existing_cluster_id *string ALL resources.jobs.*.tasks[*].for_each_task *jobs.ForEachTask ALL -resources.jobs.*.tasks[*].for_each_task.concurrency int ALL -resources.jobs.*.tasks[*].for_each_task.inputs string ALL -resources.jobs.*.tasks[*].for_each_task.task jobs.Task ALL +resources.jobs.*.tasks[*].for_each_task.concurrency *int ALL +resources.jobs.*.tasks[*].for_each_task.inputs *string ALL +resources.jobs.*.tasks[*].for_each_task.task *jobs.TaskSettings ALL resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task *jobs.AiRuntimeTask ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.code_source_path string ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.code_source_path *string ALL resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments []jobs.DeploymentSpec ALL resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*] jobs.DeploymentSpec ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*].command_path string ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*].compute jobs.ComputeSpec ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*].compute.accelerator_count int ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*].compute.accelerator_type jobs.ComputeSpecAcceleratorType ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*].compute.provisioned_capacity_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*].name string ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.docker_image_url string ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.experiment string ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.mlflow_artifact_location string ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.mlflow_experiment_directory string ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.mlflow_run string ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.priority_class jobs.AiRuntimeTaskPriorityClass ALL -resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.unity_catalog_image_path string ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*].command_path *string ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*].compute *jobs.ComputeSpec ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*].compute.accelerator_count *int ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*].compute.accelerator_type jobs.ComputeSpec_AcceleratorType ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*].compute.provisioned_capacity_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.deployments[*].name *string ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.docker_image_url *string ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.experiment *string ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.mlflow_artifact_location *string ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.mlflow_experiment_directory *string ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.mlflow_run *string ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.priority_class jobs.AiRuntimeTask_PriorityClass ALL +resources.jobs.*.tasks[*].for_each_task.task.ai_runtime_task.unity_catalog_image_path *string ALL resources.jobs.*.tasks[*].for_each_task.task.alert_task *jobs.AlertTask ALL -resources.jobs.*.tasks[*].for_each_task.task.alert_task.alert_id string ALL +resources.jobs.*.tasks[*].for_each_task.task.alert_task.alert_id *string ALL resources.jobs.*.tasks[*].for_each_task.task.alert_task.parameters map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.alert_task.parameters.* string ALL resources.jobs.*.tasks[*].for_each_task.task.alert_task.subscribers []jobs.AlertTaskSubscriber ALL resources.jobs.*.tasks[*].for_each_task.task.alert_task.subscribers[*] jobs.AlertTaskSubscriber ALL -resources.jobs.*.tasks[*].for_each_task.task.alert_task.subscribers[*].destination_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.alert_task.subscribers[*].user_name string ALL -resources.jobs.*.tasks[*].for_each_task.task.alert_task.warehouse_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.alert_task.workspace_path string ALL +resources.jobs.*.tasks[*].for_each_task.task.alert_task.subscribers[*].destination_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.alert_task.subscribers[*].user_name *string ALL +resources.jobs.*.tasks[*].for_each_task.task.alert_task.warehouse_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.alert_task.workspace_path *string ALL resources.jobs.*.tasks[*].for_each_task.task.clean_rooms_notebook_task *jobs.CleanRoomsNotebookTask ALL -resources.jobs.*.tasks[*].for_each_task.task.clean_rooms_notebook_task.clean_room_name string ALL -resources.jobs.*.tasks[*].for_each_task.task.clean_rooms_notebook_task.etag string ALL +resources.jobs.*.tasks[*].for_each_task.task.clean_rooms_notebook_task.clean_room_name *string ALL +resources.jobs.*.tasks[*].for_each_task.task.clean_rooms_notebook_task.etag *string ALL resources.jobs.*.tasks[*].for_each_task.task.clean_rooms_notebook_task.notebook_base_parameters map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.clean_rooms_notebook_task.notebook_base_parameters.* string ALL -resources.jobs.*.tasks[*].for_each_task.task.clean_rooms_notebook_task.notebook_name string ALL +resources.jobs.*.tasks[*].for_each_task.task.clean_rooms_notebook_task.notebook_name *string ALL resources.jobs.*.tasks[*].for_each_task.task.compute *jobs.Compute ALL -resources.jobs.*.tasks[*].for_each_task.task.compute.hardware_accelerator compute.HardwareAcceleratorType ALL +resources.jobs.*.tasks[*].for_each_task.task.compute.hardware_accelerator jobs.HardwareAcceleratorType ALL resources.jobs.*.tasks[*].for_each_task.task.condition_task *jobs.ConditionTask ALL -resources.jobs.*.tasks[*].for_each_task.task.condition_task.left string ALL -resources.jobs.*.tasks[*].for_each_task.task.condition_task.op jobs.ConditionTaskOp ALL -resources.jobs.*.tasks[*].for_each_task.task.condition_task.right string ALL +resources.jobs.*.tasks[*].for_each_task.task.condition_task.left *string ALL +resources.jobs.*.tasks[*].for_each_task.task.condition_task.op jobs.ConditionTask_ConditionTaskOperator ALL +resources.jobs.*.tasks[*].for_each_task.task.condition_task.outcome *string ALL +resources.jobs.*.tasks[*].for_each_task.task.condition_task.right *string ALL resources.jobs.*.tasks[*].for_each_task.task.dashboard_task *jobs.DashboardTask ALL -resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.dashboard_id string ALL +resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.dashboard_id *string ALL resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.filters map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.filters.* string ALL resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription *jobs.Subscription ALL -resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription.custom_subject string ALL -resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription.paused bool ALL -resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription.subscribers []jobs.SubscriptionSubscriber ALL -resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription.subscribers[*] jobs.SubscriptionSubscriber ALL -resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription.subscribers[*].destination_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription.subscribers[*].user_name string ALL -resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.warehouse_id string ALL +resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription.custom_subject *string ALL +resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription.paused *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription.subscribers []jobs.Subscription_Subscriber ALL +resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription.subscribers[*] jobs.Subscription_Subscriber ALL +resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription.subscribers[*].destination_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.subscription.subscribers[*].user_name *string ALL +resources.jobs.*.tasks[*].for_each_task.task.dashboard_task.warehouse_id *string ALL resources.jobs.*.tasks[*].for_each_task.task.dbt_cloud_task *jobs.DbtCloudTask ALL -resources.jobs.*.tasks[*].for_each_task.task.dbt_cloud_task.connection_resource_name string ALL -resources.jobs.*.tasks[*].for_each_task.task.dbt_cloud_task.dbt_cloud_job_id int64 ALL +resources.jobs.*.tasks[*].for_each_task.task.dbt_cloud_task.connection_resource_name *string ALL +resources.jobs.*.tasks[*].for_each_task.task.dbt_cloud_task.dbt_cloud_job_id *int64 ALL resources.jobs.*.tasks[*].for_each_task.task.dbt_platform_task *jobs.DbtPlatformTask ALL -resources.jobs.*.tasks[*].for_each_task.task.dbt_platform_task.connection_resource_name string ALL -resources.jobs.*.tasks[*].for_each_task.task.dbt_platform_task.dbt_platform_job_id string ALL +resources.jobs.*.tasks[*].for_each_task.task.dbt_platform_task.connection_resource_name *string ALL +resources.jobs.*.tasks[*].for_each_task.task.dbt_platform_task.dbt_platform_job_id *string ALL resources.jobs.*.tasks[*].for_each_task.task.dbt_task *jobs.DbtTask ALL -resources.jobs.*.tasks[*].for_each_task.task.dbt_task.catalog string ALL +resources.jobs.*.tasks[*].for_each_task.task.dbt_task.catalog *string ALL resources.jobs.*.tasks[*].for_each_task.task.dbt_task.commands []string ALL resources.jobs.*.tasks[*].for_each_task.task.dbt_task.commands[*] string ALL -resources.jobs.*.tasks[*].for_each_task.task.dbt_task.profiles_directory string ALL -resources.jobs.*.tasks[*].for_each_task.task.dbt_task.project_directory string ALL -resources.jobs.*.tasks[*].for_each_task.task.dbt_task.schema string ALL +resources.jobs.*.tasks[*].for_each_task.task.dbt_task.profiles_directory *string ALL +resources.jobs.*.tasks[*].for_each_task.task.dbt_task.project_directory *string ALL +resources.jobs.*.tasks[*].for_each_task.task.dbt_task.schema *string ALL resources.jobs.*.tasks[*].for_each_task.task.dbt_task.source jobs.Source ALL -resources.jobs.*.tasks[*].for_each_task.task.dbt_task.warehouse_id string ALL +resources.jobs.*.tasks[*].for_each_task.task.dbt_task.warehouse_id *string ALL resources.jobs.*.tasks[*].for_each_task.task.depends_on []jobs.TaskDependency ALL resources.jobs.*.tasks[*].for_each_task.task.depends_on[*] jobs.TaskDependency ALL -resources.jobs.*.tasks[*].for_each_task.task.depends_on[*].outcome string ALL -resources.jobs.*.tasks[*].for_each_task.task.depends_on[*].task_key string ALL -resources.jobs.*.tasks[*].for_each_task.task.description string ALL -resources.jobs.*.tasks[*].for_each_task.task.disable_auto_optimization bool ALL -resources.jobs.*.tasks[*].for_each_task.task.disabled bool ALL -resources.jobs.*.tasks[*].for_each_task.task.email_notifications *jobs.TaskEmailNotifications ALL -resources.jobs.*.tasks[*].for_each_task.task.email_notifications.no_alert_for_skipped_runs bool ALL +resources.jobs.*.tasks[*].for_each_task.task.depends_on[*].outcome *string ALL +resources.jobs.*.tasks[*].for_each_task.task.depends_on[*].task_key *string ALL +resources.jobs.*.tasks[*].for_each_task.task.description *string ALL +resources.jobs.*.tasks[*].for_each_task.task.disable_auto_optimization *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.disabled *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.email_notifications *jobs.JobEmailNotifications ALL +resources.jobs.*.tasks[*].for_each_task.task.email_notifications.no_alert_for_skipped_runs *bool ALL resources.jobs.*.tasks[*].for_each_task.task.email_notifications.on_duration_warning_threshold_exceeded []string ALL resources.jobs.*.tasks[*].for_each_task.task.email_notifications.on_duration_warning_threshold_exceeded[*] string ALL resources.jobs.*.tasks[*].for_each_task.task.email_notifications.on_failure []string ALL @@ -1410,181 +1421,181 @@ resources.jobs.*.tasks[*].for_each_task.task.email_notifications.on_streaming_ba resources.jobs.*.tasks[*].for_each_task.task.email_notifications.on_streaming_backlog_exceeded[*] string ALL resources.jobs.*.tasks[*].for_each_task.task.email_notifications.on_success []string ALL resources.jobs.*.tasks[*].for_each_task.task.email_notifications.on_success[*] string ALL -resources.jobs.*.tasks[*].for_each_task.task.environment_key string ALL -resources.jobs.*.tasks[*].for_each_task.task.environment_variables_key string ALL -resources.jobs.*.tasks[*].for_each_task.task.existing_cluster_id string ALL +resources.jobs.*.tasks[*].for_each_task.task.environment_key *string ALL +resources.jobs.*.tasks[*].for_each_task.task.environment_variables_key *string ALL +resources.jobs.*.tasks[*].for_each_task.task.existing_cluster_id *string ALL resources.jobs.*.tasks[*].for_each_task.task.for_each_task *jobs.ForEachTask ALL -resources.jobs.*.tasks[*].for_each_task.task.for_each_task.concurrency int ALL -resources.jobs.*.tasks[*].for_each_task.task.for_each_task.inputs string ALL -resources.jobs.*.tasks[*].for_each_task.task.for_each_task.task jobs.Task ALL +resources.jobs.*.tasks[*].for_each_task.task.for_each_task.concurrency *int ALL +resources.jobs.*.tasks[*].for_each_task.task.for_each_task.inputs *string ALL +resources.jobs.*.tasks[*].for_each_task.task.for_each_task.task *jobs.TaskSettings ALL resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task *jobs.GenAiComputeTask ALL -resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.command string ALL +resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.command *string ALL resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.compute *jobs.ComputeConfig ALL -resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.compute.gpu_node_pool_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.compute.gpu_type string ALL -resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.compute.num_gpus int ALL -resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.dl_runtime_image string ALL -resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.mlflow_experiment_name string ALL +resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.compute.gpu_node_pool_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.compute.gpu_type *string ALL +resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.compute.num_gpus *int ALL +resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.dl_runtime_image *string ALL +resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.mlflow_experiment_name *string ALL resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.source jobs.Source ALL -resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.training_script_path string ALL -resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.yaml_parameters string ALL -resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.yaml_parameters_file_path string ALL +resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.training_script_path *string ALL +resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.yaml_parameters *string ALL +resources.jobs.*.tasks[*].for_each_task.task.gen_ai_compute_task.yaml_parameters_file_path *string ALL resources.jobs.*.tasks[*].for_each_task.task.health *jobs.JobsHealthRules ALL resources.jobs.*.tasks[*].for_each_task.task.health.rules []jobs.JobsHealthRule ALL resources.jobs.*.tasks[*].for_each_task.task.health.rules[*] jobs.JobsHealthRule ALL resources.jobs.*.tasks[*].for_each_task.task.health.rules[*].metric jobs.JobsHealthMetric ALL resources.jobs.*.tasks[*].for_each_task.task.health.rules[*].op jobs.JobsHealthOperator ALL -resources.jobs.*.tasks[*].for_each_task.task.health.rules[*].value int64 ALL -resources.jobs.*.tasks[*].for_each_task.task.job_cluster_key string ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries []compute.Library ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*] compute.Library ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].cran *compute.RCranLibrary ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].cran.package string ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].cran.repo string ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].egg string ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].jar string ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].maven *compute.MavenLibrary ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].maven.coordinates string ALL +resources.jobs.*.tasks[*].for_each_task.task.health.rules[*].value *int64 ALL +resources.jobs.*.tasks[*].for_each_task.task.job_cluster_key *string ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries []jobs.Library ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*] jobs.Library ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].cran *jobs.RCranLibrary ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].cran.package *string ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].cran.repo *string ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].egg *string ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].jar *string ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].maven *jobs.MavenLibrary ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].maven.coordinates *string ALL resources.jobs.*.tasks[*].for_each_task.task.libraries[*].maven.exclusions []string ALL resources.jobs.*.tasks[*].for_each_task.task.libraries[*].maven.exclusions[*] string ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].maven.repo string ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].pypi *compute.PythonPyPiLibrary ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].pypi.package string ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].pypi.repo string ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].requirements string ALL -resources.jobs.*.tasks[*].for_each_task.task.libraries[*].whl string ALL -resources.jobs.*.tasks[*].for_each_task.task.max_retries int ALL -resources.jobs.*.tasks[*].for_each_task.task.min_retry_interval_millis int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster *compute.ClusterSpec ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.apply_policy_default_values bool ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.autoscale *compute.AutoScale ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.autoscale.max_workers int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.autoscale.min_workers int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.autotermination_minutes int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes *compute.AwsAttributes ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.availability compute.AwsAvailability ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.ebs_volume_count int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.ebs_volume_iops int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.ebs_volume_size int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.ebs_volume_throughput int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.ebs_volume_type compute.EbsVolumeType ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.first_on_demand int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.instance_profile_arn string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.spot_bid_price_percent int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.zone_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes *compute.AzureAttributes ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.availability compute.AzureAvailability ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.capacity_reservation_group string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.first_on_demand int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.log_analytics_info *compute.LogAnalyticsInfo ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.log_analytics_info.log_analytics_primary_key string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.log_analytics_info.log_analytics_workspace_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.spot_bid_max_price float64 ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf *compute.ClusterLogConf ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.dbfs *compute.DbfsStorageInfo ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.dbfs.destination string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3 *compute.S3StorageInfo ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.canned_acl string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.destination string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.enable_encryption bool ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.encryption_type string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.endpoint string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.kms_key string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.region string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.volumes *compute.VolumesStorageInfo ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.volumes.destination string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_name string ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].maven.repo *string ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].pypi *jobs.PythonPyPiLibrary ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].pypi.package *string ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].pypi.repo *string ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].requirements *string ALL +resources.jobs.*.tasks[*].for_each_task.task.libraries[*].whl *string ALL +resources.jobs.*.tasks[*].for_each_task.task.max_retries *int ALL +resources.jobs.*.tasks[*].for_each_task.task.min_retry_interval_millis *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster *jobs.ClusterSpec_NewCluster ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.apply_policy_default_values *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.autoscale *jobs.AutoScale ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.autoscale.max_workers *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.autoscale.min_workers *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.autotermination_minutes *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes *jobs.AwsAttributes ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.availability jobs.AwsAvailability ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.ebs_volume_count *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.ebs_volume_iops *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.ebs_volume_size *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.ebs_volume_throughput *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.ebs_volume_type jobs.EbsVolumeType ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.first_on_demand *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.instance_profile_arn *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.spot_bid_price_percent *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.aws_attributes.zone_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes *jobs.AzureAttributes ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.availability jobs.AzureAvailability ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.capacity_reservation_group *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.first_on_demand *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.log_analytics_info *jobs.LogAnalyticsInfo ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.log_analytics_info.log_analytics_primary_key *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.log_analytics_info.log_analytics_workspace_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.azure_attributes.spot_bid_max_price *float64 ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf *jobs.ClusterLogConf ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.dbfs *jobs.DbfsStorageInfo ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.dbfs.destination *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3 *jobs.S3StorageInfo ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.canned_acl *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.destination *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.enable_encryption *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.encryption_type *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.endpoint *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.kms_key *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.s3.region *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.volumes *jobs.VolumesStorageInfo ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_log_conf.volumes.destination *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.cluster_name *string ALL resources.jobs.*.tasks[*].for_each_task.task.new_cluster.custom_tags map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.new_cluster.custom_tags.* string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.data_security_mode compute.DataSecurityMode ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.dependency_mode compute.DependencyMode ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.docker_image *compute.DockerImage ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.docker_image.basic_auth *compute.DockerBasicAuth ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.docker_image.basic_auth.password string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.docker_image.basic_auth.username string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.docker_image.url string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.driver_instance_pool_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.driver_node_type_flexibility *compute.NodeTypeFlexibility ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.data_security_mode jobs.DataSecurityMode ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.dependency_mode jobs.DependencyMode ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.docker_image *jobs.DockerImage ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.docker_image.basic_auth *jobs.DockerBasicAuth ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.docker_image.basic_auth.password *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.docker_image.basic_auth.username *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.docker_image.url *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.driver_instance_pool_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.driver_node_type_flexibility *jobs.NodeTypeFlexibility ALL resources.jobs.*.tasks[*].for_each_task.task.new_cluster.driver_node_type_flexibility.alternate_node_type_ids []string ALL resources.jobs.*.tasks[*].for_each_task.task.new_cluster.driver_node_type_flexibility.alternate_node_type_ids[*] string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.driver_node_type_flexibility.aws_context_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.driver_node_type_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.enable_elastic_disk bool ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.enable_local_disk_encryption bool ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes *compute.GcpAttributes ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.availability compute.GcpAvailability ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.boot_disk_size int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.confidential_compute_type compute.ConfidentialComputeType ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.first_on_demand int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.google_service_account string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.local_ssd_count int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.use_preemptible_executors bool ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.zone_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts []compute.InitScriptInfo ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*] compute.InitScriptInfo ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].abfss *compute.Adlsgen2Info ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].abfss.destination string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].dbfs *compute.DbfsStorageInfo ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].dbfs.destination string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].file *compute.LocalFileInfo ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].file.destination string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].gcs *compute.GcsStorageInfo ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].gcs.destination string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3 *compute.S3StorageInfo ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.canned_acl string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.destination string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.enable_encryption bool ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.encryption_type string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.endpoint string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.kms_key string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.region string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].volumes *compute.VolumesStorageInfo ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].volumes.destination string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].workspace *compute.WorkspaceStorageInfo ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].workspace.destination string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.instance_pool_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.is_single_node bool ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.kind compute.Kind ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.node_type_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.num_workers int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.policy_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.remote_disk_throughput int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.runtime_engine compute.RuntimeEngine ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.single_user_name string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.driver_node_type_flexibility.aws_context_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.driver_node_type_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.enable_elastic_disk *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.enable_local_disk_encryption *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes *jobs.GcpAttributes ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.availability jobs.GcpAvailability ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.boot_disk_size *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.confidential_compute_type jobs.ConfidentialComputeType ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.first_on_demand *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.google_service_account *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.local_ssd_count *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.use_preemptible_executors *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.gcp_attributes.zone_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts []jobs.InitScriptInfo ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*] jobs.InitScriptInfo ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].abfss *jobs.Adlsgen2Info ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].abfss.destination *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].dbfs *jobs.DbfsStorageInfo ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].dbfs.destination *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].file *jobs.LocalFileInfo ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].file.destination *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].gcs *jobs.GcsStorageInfo ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].gcs.destination *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3 *jobs.S3StorageInfo ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.canned_acl *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.destination *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.enable_encryption *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.encryption_type *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.endpoint *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.kms_key *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].s3.region *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].volumes *jobs.VolumesStorageInfo ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].volumes.destination *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].workspace *jobs.WorkspaceStorageInfo ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.init_scripts[*].workspace.destination *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.instance_pool_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.is_single_node *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.kind jobs.ComputeKind ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.node_type_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.num_workers *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.policy_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.remote_disk_throughput *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.runtime_engine jobs.RuntimeEngine ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.single_user_name *string ALL resources.jobs.*.tasks[*].for_each_task.task.new_cluster.spark_conf map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.new_cluster.spark_conf.* string ALL resources.jobs.*.tasks[*].for_each_task.task.new_cluster.spark_env_vars map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.new_cluster.spark_env_vars.* string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.spark_version string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.spark_version *string ALL resources.jobs.*.tasks[*].for_each_task.task.new_cluster.ssh_public_keys []string ALL resources.jobs.*.tasks[*].for_each_task.task.new_cluster.ssh_public_keys[*] string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.total_initial_remote_disk_size int ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.use_ml_runtime bool ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.worker_node_type_flexibility *compute.NodeTypeFlexibility ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.total_initial_remote_disk_size *int ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.use_ml_runtime *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.worker_node_type_flexibility *jobs.NodeTypeFlexibility ALL resources.jobs.*.tasks[*].for_each_task.task.new_cluster.worker_node_type_flexibility.alternate_node_type_ids []string ALL resources.jobs.*.tasks[*].for_each_task.task.new_cluster.worker_node_type_flexibility.alternate_node_type_ids[*] string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.worker_node_type_flexibility.aws_context_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.workload_type *compute.WorkloadType ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.workload_type.clients compute.ClientsTypes ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.workload_type.clients.jobs bool ALL -resources.jobs.*.tasks[*].for_each_task.task.new_cluster.workload_type.clients.notebooks bool ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.worker_node_type_flexibility.aws_context_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.workload_type *jobs.WorkloadType ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.workload_type.clients *jobs.WorkloadType_ClientsTypes ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.workload_type.clients.jobs *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.new_cluster.workload_type.clients.notebooks *bool ALL resources.jobs.*.tasks[*].for_each_task.task.notebook_task *jobs.NotebookTask ALL resources.jobs.*.tasks[*].for_each_task.task.notebook_task.base_parameters map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.notebook_task.base_parameters.* string ALL -resources.jobs.*.tasks[*].for_each_task.task.notebook_task.notebook_path string ALL +resources.jobs.*.tasks[*].for_each_task.task.notebook_task.notebook_path *string ALL resources.jobs.*.tasks[*].for_each_task.task.notebook_task.source jobs.Source ALL -resources.jobs.*.tasks[*].for_each_task.task.notebook_task.warehouse_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.notification_settings *jobs.TaskNotificationSettings ALL -resources.jobs.*.tasks[*].for_each_task.task.notification_settings.alert_on_last_attempt bool ALL -resources.jobs.*.tasks[*].for_each_task.task.notification_settings.no_alert_for_canceled_runs bool ALL -resources.jobs.*.tasks[*].for_each_task.task.notification_settings.no_alert_for_skipped_runs bool ALL +resources.jobs.*.tasks[*].for_each_task.task.notebook_task.warehouse_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.notification_settings *jobs.NotificationSettings ALL +resources.jobs.*.tasks[*].for_each_task.task.notification_settings.alert_on_last_attempt *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.notification_settings.no_alert_for_canceled_runs *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.notification_settings.no_alert_for_skipped_runs *bool ALL resources.jobs.*.tasks[*].for_each_task.task.pipeline_task *jobs.PipelineTask ALL -resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.full_refresh bool ALL +resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.full_refresh *bool ALL resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.full_refresh_selection []string ALL resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.full_refresh_selection[*] string ALL resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.parameters map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.parameters.* string ALL -resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.pipeline_id string ALL +resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.pipeline_id *string ALL resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.refresh_flow_selection []string ALL resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.refresh_flow_selection[*] string ALL resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.refresh_selection []string ALL @@ -1592,48 +1603,48 @@ resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.refresh_selection[*] resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.reset_checkpoint_selection []string ALL resources.jobs.*.tasks[*].for_each_task.task.pipeline_task.reset_checkpoint_selection[*] string ALL resources.jobs.*.tasks[*].for_each_task.task.power_bi_task *jobs.PowerBiTask ALL -resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.connection_resource_name string ALL +resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.connection_resource_name *string ALL resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.power_bi_model *jobs.PowerBiModel ALL resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.power_bi_model.authentication_method jobs.AuthenticationMethod ALL -resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.power_bi_model.model_name string ALL -resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.power_bi_model.overwrite_existing bool ALL +resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.power_bi_model.model_name *string ALL +resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.power_bi_model.overwrite_existing *bool ALL resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.power_bi_model.storage_mode jobs.StorageMode ALL -resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.power_bi_model.workspace_name string ALL -resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.refresh_after_update bool ALL +resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.power_bi_model.workspace_name *string ALL +resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.refresh_after_update *bool ALL resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.tables []jobs.PowerBiTable ALL resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.tables[*] jobs.PowerBiTable ALL -resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.tables[*].catalog string ALL -resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.tables[*].name string ALL -resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.tables[*].schema string ALL +resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.tables[*].catalog *string ALL +resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.tables[*].name *string ALL +resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.tables[*].schema *string ALL resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.tables[*].storage_mode jobs.StorageMode ALL -resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.warehouse_id string ALL +resources.jobs.*.tasks[*].for_each_task.task.power_bi_task.warehouse_id *string ALL resources.jobs.*.tasks[*].for_each_task.task.python_operator_task *jobs.PythonOperatorTask ALL -resources.jobs.*.tasks[*].for_each_task.task.python_operator_task.main string ALL -resources.jobs.*.tasks[*].for_each_task.task.python_operator_task.parameters []jobs.PythonOperatorTaskParameter ALL -resources.jobs.*.tasks[*].for_each_task.task.python_operator_task.parameters[*] jobs.PythonOperatorTaskParameter ALL -resources.jobs.*.tasks[*].for_each_task.task.python_operator_task.parameters[*].name string ALL -resources.jobs.*.tasks[*].for_each_task.task.python_operator_task.parameters[*].value string ALL +resources.jobs.*.tasks[*].for_each_task.task.python_operator_task.main *string ALL +resources.jobs.*.tasks[*].for_each_task.task.python_operator_task.parameters []jobs.PythonOperatorTask_Parameter ALL +resources.jobs.*.tasks[*].for_each_task.task.python_operator_task.parameters[*] jobs.PythonOperatorTask_Parameter ALL +resources.jobs.*.tasks[*].for_each_task.task.python_operator_task.parameters[*].name *string ALL +resources.jobs.*.tasks[*].for_each_task.task.python_operator_task.parameters[*].value *string ALL resources.jobs.*.tasks[*].for_each_task.task.python_wheel_task *jobs.PythonWheelTask ALL -resources.jobs.*.tasks[*].for_each_task.task.python_wheel_task.entry_point string ALL +resources.jobs.*.tasks[*].for_each_task.task.python_wheel_task.entry_point *string ALL resources.jobs.*.tasks[*].for_each_task.task.python_wheel_task.named_parameters map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.python_wheel_task.named_parameters.* string ALL -resources.jobs.*.tasks[*].for_each_task.task.python_wheel_task.package_name string ALL +resources.jobs.*.tasks[*].for_each_task.task.python_wheel_task.package_name *string ALL resources.jobs.*.tasks[*].for_each_task.task.python_wheel_task.parameters []string ALL resources.jobs.*.tasks[*].for_each_task.task.python_wheel_task.parameters[*] string ALL -resources.jobs.*.tasks[*].for_each_task.task.retry_on_timeout bool ALL -resources.jobs.*.tasks[*].for_each_task.task.run_if jobs.RunIf ALL +resources.jobs.*.tasks[*].for_each_task.task.retry_on_timeout *bool ALL +resources.jobs.*.tasks[*].for_each_task.task.run_if jobs.TaskDependencyType ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task *jobs.RunJobTask ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task.dbt_commands []string ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task.dbt_commands[*] string ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task.jar_params []string ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task.jar_params[*] string ALL -resources.jobs.*.tasks[*].for_each_task.task.run_job_task.job_id int64 ALL +resources.jobs.*.tasks[*].for_each_task.task.run_job_task.job_id *int64 ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task.job_parameters map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task.job_parameters.* string ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task.notebook_params map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task.notebook_params.* string ALL -resources.jobs.*.tasks[*].for_each_task.task.run_job_task.pipeline_params *jobs.PipelineParams ALL -resources.jobs.*.tasks[*].for_each_task.task.run_job_task.pipeline_params.full_refresh bool ALL +resources.jobs.*.tasks[*].for_each_task.task.run_job_task.pipeline_params *jobs.PipelineParameters ALL +resources.jobs.*.tasks[*].for_each_task.task.run_job_task.pipeline_params.full_refresh *bool ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task.pipeline_params.full_refresh_selection []string ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task.pipeline_params.full_refresh_selection[*] string ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task.pipeline_params.refresh_flow_selection []string ALL @@ -1651,235 +1662,235 @@ resources.jobs.*.tasks[*].for_each_task.task.run_job_task.spark_submit_params[*] resources.jobs.*.tasks[*].for_each_task.task.run_job_task.sql_params map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.run_job_task.sql_params.* string ALL resources.jobs.*.tasks[*].for_each_task.task.spark_jar_task *jobs.SparkJarTask ALL -resources.jobs.*.tasks[*].for_each_task.task.spark_jar_task.jar_uri string ALL -resources.jobs.*.tasks[*].for_each_task.task.spark_jar_task.main_class_name string ALL +resources.jobs.*.tasks[*].for_each_task.task.spark_jar_task.jar_uri *string ALL +resources.jobs.*.tasks[*].for_each_task.task.spark_jar_task.main_class_name *string ALL resources.jobs.*.tasks[*].for_each_task.task.spark_jar_task.parameters []string ALL resources.jobs.*.tasks[*].for_each_task.task.spark_jar_task.parameters[*] string ALL -resources.jobs.*.tasks[*].for_each_task.task.spark_jar_task.run_as_repl bool ALL +resources.jobs.*.tasks[*].for_each_task.task.spark_jar_task.run_as_repl *bool ALL resources.jobs.*.tasks[*].for_each_task.task.spark_python_task *jobs.SparkPythonTask ALL resources.jobs.*.tasks[*].for_each_task.task.spark_python_task.parameters []string ALL resources.jobs.*.tasks[*].for_each_task.task.spark_python_task.parameters[*] string ALL -resources.jobs.*.tasks[*].for_each_task.task.spark_python_task.python_file string ALL +resources.jobs.*.tasks[*].for_each_task.task.spark_python_task.python_file *string ALL resources.jobs.*.tasks[*].for_each_task.task.spark_python_task.source jobs.Source ALL resources.jobs.*.tasks[*].for_each_task.task.spark_submit_task *jobs.SparkSubmitTask ALL resources.jobs.*.tasks[*].for_each_task.task.spark_submit_task.parameters []string ALL resources.jobs.*.tasks[*].for_each_task.task.spark_submit_task.parameters[*] string ALL resources.jobs.*.tasks[*].for_each_task.task.sql_task *jobs.SqlTask ALL resources.jobs.*.tasks[*].for_each_task.task.sql_task.alert *jobs.SqlTaskAlert ALL -resources.jobs.*.tasks[*].for_each_task.task.sql_task.alert.alert_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.sql_task.alert.pause_subscriptions bool ALL +resources.jobs.*.tasks[*].for_each_task.task.sql_task.alert.alert_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.sql_task.alert.pause_subscriptions *bool ALL resources.jobs.*.tasks[*].for_each_task.task.sql_task.alert.subscriptions []jobs.SqlTaskSubscription ALL resources.jobs.*.tasks[*].for_each_task.task.sql_task.alert.subscriptions[*] jobs.SqlTaskSubscription ALL -resources.jobs.*.tasks[*].for_each_task.task.sql_task.alert.subscriptions[*].destination_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.sql_task.alert.subscriptions[*].user_name string ALL +resources.jobs.*.tasks[*].for_each_task.task.sql_task.alert.subscriptions[*].destination_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.sql_task.alert.subscriptions[*].user_name *string ALL resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard *jobs.SqlTaskDashboard ALL -resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard.custom_subject string ALL -resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard.dashboard_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard.pause_subscriptions bool ALL +resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard.custom_subject *string ALL +resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard.dashboard_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard.pause_subscriptions *bool ALL resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard.subscriptions []jobs.SqlTaskSubscription ALL resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard.subscriptions[*] jobs.SqlTaskSubscription ALL -resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard.subscriptions[*].destination_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard.subscriptions[*].user_name string ALL +resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard.subscriptions[*].destination_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.sql_task.dashboard.subscriptions[*].user_name *string ALL resources.jobs.*.tasks[*].for_each_task.task.sql_task.file *jobs.SqlTaskFile ALL -resources.jobs.*.tasks[*].for_each_task.task.sql_task.file.path string ALL +resources.jobs.*.tasks[*].for_each_task.task.sql_task.file.path *string ALL resources.jobs.*.tasks[*].for_each_task.task.sql_task.file.source jobs.Source ALL resources.jobs.*.tasks[*].for_each_task.task.sql_task.parameters map[string]string ALL resources.jobs.*.tasks[*].for_each_task.task.sql_task.parameters.* string ALL resources.jobs.*.tasks[*].for_each_task.task.sql_task.query *jobs.SqlTaskQuery ALL -resources.jobs.*.tasks[*].for_each_task.task.sql_task.query.query_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.sql_task.warehouse_id string ALL -resources.jobs.*.tasks[*].for_each_task.task.task_key string ALL -resources.jobs.*.tasks[*].for_each_task.task.timeout_seconds int ALL +resources.jobs.*.tasks[*].for_each_task.task.sql_task.query.query_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.sql_task.warehouse_id *string ALL +resources.jobs.*.tasks[*].for_each_task.task.task_key *string ALL +resources.jobs.*.tasks[*].for_each_task.task.timeout_seconds *int ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications *jobs.WebhookNotifications ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_duration_warning_threshold_exceeded []jobs.Webhook ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_duration_warning_threshold_exceeded[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_duration_warning_threshold_exceeded[*].id string ALL +resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_duration_warning_threshold_exceeded[*].id *string ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_failure []jobs.Webhook ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_failure[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_failure[*].id string ALL +resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_failure[*].id *string ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_maintenance_complete []jobs.Webhook ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_maintenance_complete[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_maintenance_complete[*].id string ALL +resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_maintenance_complete[*].id *string ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_maintenance_start []jobs.Webhook ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_maintenance_start[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_maintenance_start[*].id string ALL +resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_maintenance_start[*].id *string ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_start []jobs.Webhook ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_start[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_start[*].id string ALL +resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_start[*].id *string ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_streaming_backlog_exceeded []jobs.Webhook ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_streaming_backlog_exceeded[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_streaming_backlog_exceeded[*].id string ALL +resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_streaming_backlog_exceeded[*].id *string ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_success []jobs.Webhook ALL resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_success[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_success[*].id string ALL +resources.jobs.*.tasks[*].for_each_task.task.webhook_notifications.on_success[*].id *string ALL resources.jobs.*.tasks[*].gen_ai_compute_task *jobs.GenAiComputeTask ALL -resources.jobs.*.tasks[*].gen_ai_compute_task.command string ALL +resources.jobs.*.tasks[*].gen_ai_compute_task.command *string ALL resources.jobs.*.tasks[*].gen_ai_compute_task.compute *jobs.ComputeConfig ALL -resources.jobs.*.tasks[*].gen_ai_compute_task.compute.gpu_node_pool_id string ALL -resources.jobs.*.tasks[*].gen_ai_compute_task.compute.gpu_type string ALL -resources.jobs.*.tasks[*].gen_ai_compute_task.compute.num_gpus int ALL -resources.jobs.*.tasks[*].gen_ai_compute_task.dl_runtime_image string ALL -resources.jobs.*.tasks[*].gen_ai_compute_task.mlflow_experiment_name string ALL +resources.jobs.*.tasks[*].gen_ai_compute_task.compute.gpu_node_pool_id *string ALL +resources.jobs.*.tasks[*].gen_ai_compute_task.compute.gpu_type *string ALL +resources.jobs.*.tasks[*].gen_ai_compute_task.compute.num_gpus *int ALL +resources.jobs.*.tasks[*].gen_ai_compute_task.dl_runtime_image *string ALL +resources.jobs.*.tasks[*].gen_ai_compute_task.mlflow_experiment_name *string ALL resources.jobs.*.tasks[*].gen_ai_compute_task.source jobs.Source ALL -resources.jobs.*.tasks[*].gen_ai_compute_task.training_script_path string ALL -resources.jobs.*.tasks[*].gen_ai_compute_task.yaml_parameters string ALL -resources.jobs.*.tasks[*].gen_ai_compute_task.yaml_parameters_file_path string ALL +resources.jobs.*.tasks[*].gen_ai_compute_task.training_script_path *string ALL +resources.jobs.*.tasks[*].gen_ai_compute_task.yaml_parameters *string ALL +resources.jobs.*.tasks[*].gen_ai_compute_task.yaml_parameters_file_path *string ALL resources.jobs.*.tasks[*].health *jobs.JobsHealthRules ALL resources.jobs.*.tasks[*].health.rules []jobs.JobsHealthRule ALL resources.jobs.*.tasks[*].health.rules[*] jobs.JobsHealthRule ALL resources.jobs.*.tasks[*].health.rules[*].metric jobs.JobsHealthMetric ALL resources.jobs.*.tasks[*].health.rules[*].op jobs.JobsHealthOperator ALL -resources.jobs.*.tasks[*].health.rules[*].value int64 ALL -resources.jobs.*.tasks[*].job_cluster_key string ALL -resources.jobs.*.tasks[*].libraries []compute.Library ALL -resources.jobs.*.tasks[*].libraries[*] compute.Library ALL -resources.jobs.*.tasks[*].libraries[*].cran *compute.RCranLibrary ALL -resources.jobs.*.tasks[*].libraries[*].cran.package string ALL -resources.jobs.*.tasks[*].libraries[*].cran.repo string ALL -resources.jobs.*.tasks[*].libraries[*].egg string ALL -resources.jobs.*.tasks[*].libraries[*].jar string ALL -resources.jobs.*.tasks[*].libraries[*].maven *compute.MavenLibrary ALL -resources.jobs.*.tasks[*].libraries[*].maven.coordinates string ALL +resources.jobs.*.tasks[*].health.rules[*].value *int64 ALL +resources.jobs.*.tasks[*].job_cluster_key *string ALL +resources.jobs.*.tasks[*].libraries []jobs.Library ALL +resources.jobs.*.tasks[*].libraries[*] jobs.Library ALL +resources.jobs.*.tasks[*].libraries[*].cran *jobs.RCranLibrary ALL +resources.jobs.*.tasks[*].libraries[*].cran.package *string ALL +resources.jobs.*.tasks[*].libraries[*].cran.repo *string ALL +resources.jobs.*.tasks[*].libraries[*].egg *string ALL +resources.jobs.*.tasks[*].libraries[*].jar *string ALL +resources.jobs.*.tasks[*].libraries[*].maven *jobs.MavenLibrary ALL +resources.jobs.*.tasks[*].libraries[*].maven.coordinates *string ALL resources.jobs.*.tasks[*].libraries[*].maven.exclusions []string ALL resources.jobs.*.tasks[*].libraries[*].maven.exclusions[*] string ALL -resources.jobs.*.tasks[*].libraries[*].maven.repo string ALL -resources.jobs.*.tasks[*].libraries[*].pypi *compute.PythonPyPiLibrary ALL -resources.jobs.*.tasks[*].libraries[*].pypi.package string ALL -resources.jobs.*.tasks[*].libraries[*].pypi.repo string ALL -resources.jobs.*.tasks[*].libraries[*].requirements string ALL -resources.jobs.*.tasks[*].libraries[*].whl string ALL -resources.jobs.*.tasks[*].max_retries int ALL -resources.jobs.*.tasks[*].min_retry_interval_millis int ALL -resources.jobs.*.tasks[*].new_cluster *compute.ClusterSpec ALL -resources.jobs.*.tasks[*].new_cluster.apply_policy_default_values bool ALL -resources.jobs.*.tasks[*].new_cluster.autoscale *compute.AutoScale ALL -resources.jobs.*.tasks[*].new_cluster.autoscale.max_workers int ALL -resources.jobs.*.tasks[*].new_cluster.autoscale.min_workers int ALL -resources.jobs.*.tasks[*].new_cluster.autotermination_minutes int ALL -resources.jobs.*.tasks[*].new_cluster.aws_attributes *compute.AwsAttributes ALL -resources.jobs.*.tasks[*].new_cluster.aws_attributes.availability compute.AwsAvailability ALL -resources.jobs.*.tasks[*].new_cluster.aws_attributes.ebs_volume_count int ALL -resources.jobs.*.tasks[*].new_cluster.aws_attributes.ebs_volume_iops int ALL -resources.jobs.*.tasks[*].new_cluster.aws_attributes.ebs_volume_size int ALL -resources.jobs.*.tasks[*].new_cluster.aws_attributes.ebs_volume_throughput int ALL -resources.jobs.*.tasks[*].new_cluster.aws_attributes.ebs_volume_type compute.EbsVolumeType ALL -resources.jobs.*.tasks[*].new_cluster.aws_attributes.first_on_demand int ALL -resources.jobs.*.tasks[*].new_cluster.aws_attributes.instance_profile_arn string ALL -resources.jobs.*.tasks[*].new_cluster.aws_attributes.spot_bid_price_percent int ALL -resources.jobs.*.tasks[*].new_cluster.aws_attributes.zone_id string ALL -resources.jobs.*.tasks[*].new_cluster.azure_attributes *compute.AzureAttributes ALL -resources.jobs.*.tasks[*].new_cluster.azure_attributes.availability compute.AzureAvailability ALL -resources.jobs.*.tasks[*].new_cluster.azure_attributes.capacity_reservation_group string ALL -resources.jobs.*.tasks[*].new_cluster.azure_attributes.first_on_demand int ALL -resources.jobs.*.tasks[*].new_cluster.azure_attributes.log_analytics_info *compute.LogAnalyticsInfo ALL -resources.jobs.*.tasks[*].new_cluster.azure_attributes.log_analytics_info.log_analytics_primary_key string ALL -resources.jobs.*.tasks[*].new_cluster.azure_attributes.log_analytics_info.log_analytics_workspace_id string ALL -resources.jobs.*.tasks[*].new_cluster.azure_attributes.spot_bid_max_price float64 ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf *compute.ClusterLogConf ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.dbfs *compute.DbfsStorageInfo ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.dbfs.destination string ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3 *compute.S3StorageInfo ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.canned_acl string ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.destination string ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.enable_encryption bool ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.encryption_type string ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.endpoint string ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.kms_key string ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.region string ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.volumes *compute.VolumesStorageInfo ALL -resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.volumes.destination string ALL -resources.jobs.*.tasks[*].new_cluster.cluster_name string ALL +resources.jobs.*.tasks[*].libraries[*].maven.repo *string ALL +resources.jobs.*.tasks[*].libraries[*].pypi *jobs.PythonPyPiLibrary ALL +resources.jobs.*.tasks[*].libraries[*].pypi.package *string ALL +resources.jobs.*.tasks[*].libraries[*].pypi.repo *string ALL +resources.jobs.*.tasks[*].libraries[*].requirements *string ALL +resources.jobs.*.tasks[*].libraries[*].whl *string ALL +resources.jobs.*.tasks[*].max_retries *int ALL +resources.jobs.*.tasks[*].min_retry_interval_millis *int ALL +resources.jobs.*.tasks[*].new_cluster *jobs.ClusterSpec_NewCluster ALL +resources.jobs.*.tasks[*].new_cluster.apply_policy_default_values *bool ALL +resources.jobs.*.tasks[*].new_cluster.autoscale *jobs.AutoScale ALL +resources.jobs.*.tasks[*].new_cluster.autoscale.max_workers *int ALL +resources.jobs.*.tasks[*].new_cluster.autoscale.min_workers *int ALL +resources.jobs.*.tasks[*].new_cluster.autotermination_minutes *int ALL +resources.jobs.*.tasks[*].new_cluster.aws_attributes *jobs.AwsAttributes ALL +resources.jobs.*.tasks[*].new_cluster.aws_attributes.availability jobs.AwsAvailability ALL +resources.jobs.*.tasks[*].new_cluster.aws_attributes.ebs_volume_count *int ALL +resources.jobs.*.tasks[*].new_cluster.aws_attributes.ebs_volume_iops *int ALL +resources.jobs.*.tasks[*].new_cluster.aws_attributes.ebs_volume_size *int ALL +resources.jobs.*.tasks[*].new_cluster.aws_attributes.ebs_volume_throughput *int ALL +resources.jobs.*.tasks[*].new_cluster.aws_attributes.ebs_volume_type jobs.EbsVolumeType ALL +resources.jobs.*.tasks[*].new_cluster.aws_attributes.first_on_demand *int ALL +resources.jobs.*.tasks[*].new_cluster.aws_attributes.instance_profile_arn *string ALL +resources.jobs.*.tasks[*].new_cluster.aws_attributes.spot_bid_price_percent *int ALL +resources.jobs.*.tasks[*].new_cluster.aws_attributes.zone_id *string ALL +resources.jobs.*.tasks[*].new_cluster.azure_attributes *jobs.AzureAttributes ALL +resources.jobs.*.tasks[*].new_cluster.azure_attributes.availability jobs.AzureAvailability ALL +resources.jobs.*.tasks[*].new_cluster.azure_attributes.capacity_reservation_group *string ALL +resources.jobs.*.tasks[*].new_cluster.azure_attributes.first_on_demand *int ALL +resources.jobs.*.tasks[*].new_cluster.azure_attributes.log_analytics_info *jobs.LogAnalyticsInfo ALL +resources.jobs.*.tasks[*].new_cluster.azure_attributes.log_analytics_info.log_analytics_primary_key *string ALL +resources.jobs.*.tasks[*].new_cluster.azure_attributes.log_analytics_info.log_analytics_workspace_id *string ALL +resources.jobs.*.tasks[*].new_cluster.azure_attributes.spot_bid_max_price *float64 ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf *jobs.ClusterLogConf ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.dbfs *jobs.DbfsStorageInfo ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.dbfs.destination *string ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3 *jobs.S3StorageInfo ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.canned_acl *string ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.destination *string ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.enable_encryption *bool ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.encryption_type *string ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.endpoint *string ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.kms_key *string ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.s3.region *string ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.volumes *jobs.VolumesStorageInfo ALL +resources.jobs.*.tasks[*].new_cluster.cluster_log_conf.volumes.destination *string ALL +resources.jobs.*.tasks[*].new_cluster.cluster_name *string ALL resources.jobs.*.tasks[*].new_cluster.custom_tags map[string]string ALL resources.jobs.*.tasks[*].new_cluster.custom_tags.* string ALL -resources.jobs.*.tasks[*].new_cluster.data_security_mode compute.DataSecurityMode ALL -resources.jobs.*.tasks[*].new_cluster.dependency_mode compute.DependencyMode ALL -resources.jobs.*.tasks[*].new_cluster.docker_image *compute.DockerImage ALL -resources.jobs.*.tasks[*].new_cluster.docker_image.basic_auth *compute.DockerBasicAuth ALL -resources.jobs.*.tasks[*].new_cluster.docker_image.basic_auth.password string ALL -resources.jobs.*.tasks[*].new_cluster.docker_image.basic_auth.username string ALL -resources.jobs.*.tasks[*].new_cluster.docker_image.url string ALL -resources.jobs.*.tasks[*].new_cluster.driver_instance_pool_id string ALL -resources.jobs.*.tasks[*].new_cluster.driver_node_type_flexibility *compute.NodeTypeFlexibility ALL +resources.jobs.*.tasks[*].new_cluster.data_security_mode jobs.DataSecurityMode ALL +resources.jobs.*.tasks[*].new_cluster.dependency_mode jobs.DependencyMode ALL +resources.jobs.*.tasks[*].new_cluster.docker_image *jobs.DockerImage ALL +resources.jobs.*.tasks[*].new_cluster.docker_image.basic_auth *jobs.DockerBasicAuth ALL +resources.jobs.*.tasks[*].new_cluster.docker_image.basic_auth.password *string ALL +resources.jobs.*.tasks[*].new_cluster.docker_image.basic_auth.username *string ALL +resources.jobs.*.tasks[*].new_cluster.docker_image.url *string ALL +resources.jobs.*.tasks[*].new_cluster.driver_instance_pool_id *string ALL +resources.jobs.*.tasks[*].new_cluster.driver_node_type_flexibility *jobs.NodeTypeFlexibility ALL resources.jobs.*.tasks[*].new_cluster.driver_node_type_flexibility.alternate_node_type_ids []string ALL resources.jobs.*.tasks[*].new_cluster.driver_node_type_flexibility.alternate_node_type_ids[*] string ALL -resources.jobs.*.tasks[*].new_cluster.driver_node_type_flexibility.aws_context_id string ALL -resources.jobs.*.tasks[*].new_cluster.driver_node_type_id string ALL -resources.jobs.*.tasks[*].new_cluster.enable_elastic_disk bool ALL -resources.jobs.*.tasks[*].new_cluster.enable_local_disk_encryption bool ALL -resources.jobs.*.tasks[*].new_cluster.gcp_attributes *compute.GcpAttributes ALL -resources.jobs.*.tasks[*].new_cluster.gcp_attributes.availability compute.GcpAvailability ALL -resources.jobs.*.tasks[*].new_cluster.gcp_attributes.boot_disk_size int ALL -resources.jobs.*.tasks[*].new_cluster.gcp_attributes.confidential_compute_type compute.ConfidentialComputeType ALL -resources.jobs.*.tasks[*].new_cluster.gcp_attributes.first_on_demand int ALL -resources.jobs.*.tasks[*].new_cluster.gcp_attributes.google_service_account string ALL -resources.jobs.*.tasks[*].new_cluster.gcp_attributes.local_ssd_count int ALL -resources.jobs.*.tasks[*].new_cluster.gcp_attributes.use_preemptible_executors bool ALL -resources.jobs.*.tasks[*].new_cluster.gcp_attributes.zone_id string ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts []compute.InitScriptInfo ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*] compute.InitScriptInfo ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].abfss *compute.Adlsgen2Info ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].abfss.destination string ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].dbfs *compute.DbfsStorageInfo ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].dbfs.destination string ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].file *compute.LocalFileInfo ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].file.destination string ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].gcs *compute.GcsStorageInfo ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].gcs.destination string ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3 *compute.S3StorageInfo ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.canned_acl string ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.destination string ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.enable_encryption bool ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.encryption_type string ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.endpoint string ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.kms_key string ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.region string ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].volumes *compute.VolumesStorageInfo ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].volumes.destination string ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].workspace *compute.WorkspaceStorageInfo ALL -resources.jobs.*.tasks[*].new_cluster.init_scripts[*].workspace.destination string ALL -resources.jobs.*.tasks[*].new_cluster.instance_pool_id string ALL -resources.jobs.*.tasks[*].new_cluster.is_single_node bool ALL -resources.jobs.*.tasks[*].new_cluster.kind compute.Kind ALL -resources.jobs.*.tasks[*].new_cluster.node_type_id string ALL -resources.jobs.*.tasks[*].new_cluster.num_workers int ALL -resources.jobs.*.tasks[*].new_cluster.policy_id string ALL -resources.jobs.*.tasks[*].new_cluster.remote_disk_throughput int ALL -resources.jobs.*.tasks[*].new_cluster.runtime_engine compute.RuntimeEngine ALL -resources.jobs.*.tasks[*].new_cluster.single_user_name string ALL +resources.jobs.*.tasks[*].new_cluster.driver_node_type_flexibility.aws_context_id *string ALL +resources.jobs.*.tasks[*].new_cluster.driver_node_type_id *string ALL +resources.jobs.*.tasks[*].new_cluster.enable_elastic_disk *bool ALL +resources.jobs.*.tasks[*].new_cluster.enable_local_disk_encryption *bool ALL +resources.jobs.*.tasks[*].new_cluster.gcp_attributes *jobs.GcpAttributes ALL +resources.jobs.*.tasks[*].new_cluster.gcp_attributes.availability jobs.GcpAvailability ALL +resources.jobs.*.tasks[*].new_cluster.gcp_attributes.boot_disk_size *int ALL +resources.jobs.*.tasks[*].new_cluster.gcp_attributes.confidential_compute_type jobs.ConfidentialComputeType ALL +resources.jobs.*.tasks[*].new_cluster.gcp_attributes.first_on_demand *int ALL +resources.jobs.*.tasks[*].new_cluster.gcp_attributes.google_service_account *string ALL +resources.jobs.*.tasks[*].new_cluster.gcp_attributes.local_ssd_count *int ALL +resources.jobs.*.tasks[*].new_cluster.gcp_attributes.use_preemptible_executors *bool ALL +resources.jobs.*.tasks[*].new_cluster.gcp_attributes.zone_id *string ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts []jobs.InitScriptInfo ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*] jobs.InitScriptInfo ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].abfss *jobs.Adlsgen2Info ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].abfss.destination *string ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].dbfs *jobs.DbfsStorageInfo ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].dbfs.destination *string ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].file *jobs.LocalFileInfo ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].file.destination *string ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].gcs *jobs.GcsStorageInfo ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].gcs.destination *string ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3 *jobs.S3StorageInfo ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.canned_acl *string ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.destination *string ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.enable_encryption *bool ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.encryption_type *string ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.endpoint *string ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.kms_key *string ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].s3.region *string ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].volumes *jobs.VolumesStorageInfo ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].volumes.destination *string ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].workspace *jobs.WorkspaceStorageInfo ALL +resources.jobs.*.tasks[*].new_cluster.init_scripts[*].workspace.destination *string ALL +resources.jobs.*.tasks[*].new_cluster.instance_pool_id *string ALL +resources.jobs.*.tasks[*].new_cluster.is_single_node *bool ALL +resources.jobs.*.tasks[*].new_cluster.kind jobs.ComputeKind ALL +resources.jobs.*.tasks[*].new_cluster.node_type_id *string ALL +resources.jobs.*.tasks[*].new_cluster.num_workers *int ALL +resources.jobs.*.tasks[*].new_cluster.policy_id *string ALL +resources.jobs.*.tasks[*].new_cluster.remote_disk_throughput *int ALL +resources.jobs.*.tasks[*].new_cluster.runtime_engine jobs.RuntimeEngine ALL +resources.jobs.*.tasks[*].new_cluster.single_user_name *string ALL resources.jobs.*.tasks[*].new_cluster.spark_conf map[string]string ALL resources.jobs.*.tasks[*].new_cluster.spark_conf.* string ALL resources.jobs.*.tasks[*].new_cluster.spark_env_vars map[string]string ALL resources.jobs.*.tasks[*].new_cluster.spark_env_vars.* string ALL -resources.jobs.*.tasks[*].new_cluster.spark_version string ALL +resources.jobs.*.tasks[*].new_cluster.spark_version *string ALL resources.jobs.*.tasks[*].new_cluster.ssh_public_keys []string ALL resources.jobs.*.tasks[*].new_cluster.ssh_public_keys[*] string ALL -resources.jobs.*.tasks[*].new_cluster.total_initial_remote_disk_size int ALL -resources.jobs.*.tasks[*].new_cluster.use_ml_runtime bool ALL -resources.jobs.*.tasks[*].new_cluster.worker_node_type_flexibility *compute.NodeTypeFlexibility ALL +resources.jobs.*.tasks[*].new_cluster.total_initial_remote_disk_size *int ALL +resources.jobs.*.tasks[*].new_cluster.use_ml_runtime *bool ALL +resources.jobs.*.tasks[*].new_cluster.worker_node_type_flexibility *jobs.NodeTypeFlexibility ALL resources.jobs.*.tasks[*].new_cluster.worker_node_type_flexibility.alternate_node_type_ids []string ALL resources.jobs.*.tasks[*].new_cluster.worker_node_type_flexibility.alternate_node_type_ids[*] string ALL -resources.jobs.*.tasks[*].new_cluster.worker_node_type_flexibility.aws_context_id string ALL -resources.jobs.*.tasks[*].new_cluster.workload_type *compute.WorkloadType ALL -resources.jobs.*.tasks[*].new_cluster.workload_type.clients compute.ClientsTypes ALL -resources.jobs.*.tasks[*].new_cluster.workload_type.clients.jobs bool ALL -resources.jobs.*.tasks[*].new_cluster.workload_type.clients.notebooks bool ALL +resources.jobs.*.tasks[*].new_cluster.worker_node_type_flexibility.aws_context_id *string ALL +resources.jobs.*.tasks[*].new_cluster.workload_type *jobs.WorkloadType ALL +resources.jobs.*.tasks[*].new_cluster.workload_type.clients *jobs.WorkloadType_ClientsTypes ALL +resources.jobs.*.tasks[*].new_cluster.workload_type.clients.jobs *bool ALL +resources.jobs.*.tasks[*].new_cluster.workload_type.clients.notebooks *bool ALL resources.jobs.*.tasks[*].notebook_task *jobs.NotebookTask ALL resources.jobs.*.tasks[*].notebook_task.base_parameters map[string]string ALL resources.jobs.*.tasks[*].notebook_task.base_parameters.* string ALL -resources.jobs.*.tasks[*].notebook_task.notebook_path string ALL +resources.jobs.*.tasks[*].notebook_task.notebook_path *string ALL resources.jobs.*.tasks[*].notebook_task.source jobs.Source ALL -resources.jobs.*.tasks[*].notebook_task.warehouse_id string ALL -resources.jobs.*.tasks[*].notification_settings *jobs.TaskNotificationSettings ALL -resources.jobs.*.tasks[*].notification_settings.alert_on_last_attempt bool ALL -resources.jobs.*.tasks[*].notification_settings.no_alert_for_canceled_runs bool ALL -resources.jobs.*.tasks[*].notification_settings.no_alert_for_skipped_runs bool ALL +resources.jobs.*.tasks[*].notebook_task.warehouse_id *string ALL +resources.jobs.*.tasks[*].notification_settings *jobs.NotificationSettings ALL +resources.jobs.*.tasks[*].notification_settings.alert_on_last_attempt *bool ALL +resources.jobs.*.tasks[*].notification_settings.no_alert_for_canceled_runs *bool ALL +resources.jobs.*.tasks[*].notification_settings.no_alert_for_skipped_runs *bool ALL resources.jobs.*.tasks[*].pipeline_task *jobs.PipelineTask ALL -resources.jobs.*.tasks[*].pipeline_task.full_refresh bool ALL +resources.jobs.*.tasks[*].pipeline_task.full_refresh *bool ALL resources.jobs.*.tasks[*].pipeline_task.full_refresh_selection []string ALL resources.jobs.*.tasks[*].pipeline_task.full_refresh_selection[*] string ALL resources.jobs.*.tasks[*].pipeline_task.parameters map[string]string ALL resources.jobs.*.tasks[*].pipeline_task.parameters.* string ALL -resources.jobs.*.tasks[*].pipeline_task.pipeline_id string ALL +resources.jobs.*.tasks[*].pipeline_task.pipeline_id *string ALL resources.jobs.*.tasks[*].pipeline_task.refresh_flow_selection []string ALL resources.jobs.*.tasks[*].pipeline_task.refresh_flow_selection[*] string ALL resources.jobs.*.tasks[*].pipeline_task.refresh_selection []string ALL @@ -1887,48 +1898,48 @@ resources.jobs.*.tasks[*].pipeline_task.refresh_selection[*] string ALL resources.jobs.*.tasks[*].pipeline_task.reset_checkpoint_selection []string ALL resources.jobs.*.tasks[*].pipeline_task.reset_checkpoint_selection[*] string ALL resources.jobs.*.tasks[*].power_bi_task *jobs.PowerBiTask ALL -resources.jobs.*.tasks[*].power_bi_task.connection_resource_name string ALL +resources.jobs.*.tasks[*].power_bi_task.connection_resource_name *string ALL resources.jobs.*.tasks[*].power_bi_task.power_bi_model *jobs.PowerBiModel ALL resources.jobs.*.tasks[*].power_bi_task.power_bi_model.authentication_method jobs.AuthenticationMethod ALL -resources.jobs.*.tasks[*].power_bi_task.power_bi_model.model_name string ALL -resources.jobs.*.tasks[*].power_bi_task.power_bi_model.overwrite_existing bool ALL +resources.jobs.*.tasks[*].power_bi_task.power_bi_model.model_name *string ALL +resources.jobs.*.tasks[*].power_bi_task.power_bi_model.overwrite_existing *bool ALL resources.jobs.*.tasks[*].power_bi_task.power_bi_model.storage_mode jobs.StorageMode ALL -resources.jobs.*.tasks[*].power_bi_task.power_bi_model.workspace_name string ALL -resources.jobs.*.tasks[*].power_bi_task.refresh_after_update bool ALL +resources.jobs.*.tasks[*].power_bi_task.power_bi_model.workspace_name *string ALL +resources.jobs.*.tasks[*].power_bi_task.refresh_after_update *bool ALL resources.jobs.*.tasks[*].power_bi_task.tables []jobs.PowerBiTable ALL resources.jobs.*.tasks[*].power_bi_task.tables[*] jobs.PowerBiTable ALL -resources.jobs.*.tasks[*].power_bi_task.tables[*].catalog string ALL -resources.jobs.*.tasks[*].power_bi_task.tables[*].name string ALL -resources.jobs.*.tasks[*].power_bi_task.tables[*].schema string ALL +resources.jobs.*.tasks[*].power_bi_task.tables[*].catalog *string ALL +resources.jobs.*.tasks[*].power_bi_task.tables[*].name *string ALL +resources.jobs.*.tasks[*].power_bi_task.tables[*].schema *string ALL resources.jobs.*.tasks[*].power_bi_task.tables[*].storage_mode jobs.StorageMode ALL -resources.jobs.*.tasks[*].power_bi_task.warehouse_id string ALL +resources.jobs.*.tasks[*].power_bi_task.warehouse_id *string ALL resources.jobs.*.tasks[*].python_operator_task *jobs.PythonOperatorTask ALL -resources.jobs.*.tasks[*].python_operator_task.main string ALL -resources.jobs.*.tasks[*].python_operator_task.parameters []jobs.PythonOperatorTaskParameter ALL -resources.jobs.*.tasks[*].python_operator_task.parameters[*] jobs.PythonOperatorTaskParameter ALL -resources.jobs.*.tasks[*].python_operator_task.parameters[*].name string ALL -resources.jobs.*.tasks[*].python_operator_task.parameters[*].value string ALL +resources.jobs.*.tasks[*].python_operator_task.main *string ALL +resources.jobs.*.tasks[*].python_operator_task.parameters []jobs.PythonOperatorTask_Parameter ALL +resources.jobs.*.tasks[*].python_operator_task.parameters[*] jobs.PythonOperatorTask_Parameter ALL +resources.jobs.*.tasks[*].python_operator_task.parameters[*].name *string ALL +resources.jobs.*.tasks[*].python_operator_task.parameters[*].value *string ALL resources.jobs.*.tasks[*].python_wheel_task *jobs.PythonWheelTask ALL -resources.jobs.*.tasks[*].python_wheel_task.entry_point string ALL +resources.jobs.*.tasks[*].python_wheel_task.entry_point *string ALL resources.jobs.*.tasks[*].python_wheel_task.named_parameters map[string]string ALL resources.jobs.*.tasks[*].python_wheel_task.named_parameters.* string ALL -resources.jobs.*.tasks[*].python_wheel_task.package_name string ALL +resources.jobs.*.tasks[*].python_wheel_task.package_name *string ALL resources.jobs.*.tasks[*].python_wheel_task.parameters []string ALL resources.jobs.*.tasks[*].python_wheel_task.parameters[*] string ALL -resources.jobs.*.tasks[*].retry_on_timeout bool ALL -resources.jobs.*.tasks[*].run_if jobs.RunIf ALL +resources.jobs.*.tasks[*].retry_on_timeout *bool ALL +resources.jobs.*.tasks[*].run_if jobs.TaskDependencyType ALL resources.jobs.*.tasks[*].run_job_task *jobs.RunJobTask ALL resources.jobs.*.tasks[*].run_job_task.dbt_commands []string ALL resources.jobs.*.tasks[*].run_job_task.dbt_commands[*] string ALL resources.jobs.*.tasks[*].run_job_task.jar_params []string ALL resources.jobs.*.tasks[*].run_job_task.jar_params[*] string ALL -resources.jobs.*.tasks[*].run_job_task.job_id int64 ALL +resources.jobs.*.tasks[*].run_job_task.job_id *int64 ALL resources.jobs.*.tasks[*].run_job_task.job_parameters map[string]string ALL resources.jobs.*.tasks[*].run_job_task.job_parameters.* string ALL resources.jobs.*.tasks[*].run_job_task.notebook_params map[string]string ALL resources.jobs.*.tasks[*].run_job_task.notebook_params.* string ALL -resources.jobs.*.tasks[*].run_job_task.pipeline_params *jobs.PipelineParams ALL -resources.jobs.*.tasks[*].run_job_task.pipeline_params.full_refresh bool ALL +resources.jobs.*.tasks[*].run_job_task.pipeline_params *jobs.PipelineParameters ALL +resources.jobs.*.tasks[*].run_job_task.pipeline_params.full_refresh *bool ALL resources.jobs.*.tasks[*].run_job_task.pipeline_params.full_refresh_selection []string ALL resources.jobs.*.tasks[*].run_job_task.pipeline_params.full_refresh_selection[*] string ALL resources.jobs.*.tasks[*].run_job_task.pipeline_params.refresh_flow_selection []string ALL @@ -1946,225 +1957,225 @@ resources.jobs.*.tasks[*].run_job_task.spark_submit_params[*] string ALL resources.jobs.*.tasks[*].run_job_task.sql_params map[string]string ALL resources.jobs.*.tasks[*].run_job_task.sql_params.* string ALL resources.jobs.*.tasks[*].spark_jar_task *jobs.SparkJarTask ALL -resources.jobs.*.tasks[*].spark_jar_task.jar_uri string ALL -resources.jobs.*.tasks[*].spark_jar_task.main_class_name string ALL +resources.jobs.*.tasks[*].spark_jar_task.jar_uri *string ALL +resources.jobs.*.tasks[*].spark_jar_task.main_class_name *string ALL resources.jobs.*.tasks[*].spark_jar_task.parameters []string ALL resources.jobs.*.tasks[*].spark_jar_task.parameters[*] string ALL -resources.jobs.*.tasks[*].spark_jar_task.run_as_repl bool ALL +resources.jobs.*.tasks[*].spark_jar_task.run_as_repl *bool ALL resources.jobs.*.tasks[*].spark_python_task *jobs.SparkPythonTask ALL resources.jobs.*.tasks[*].spark_python_task.parameters []string ALL resources.jobs.*.tasks[*].spark_python_task.parameters[*] string ALL -resources.jobs.*.tasks[*].spark_python_task.python_file string ALL +resources.jobs.*.tasks[*].spark_python_task.python_file *string ALL resources.jobs.*.tasks[*].spark_python_task.source jobs.Source ALL resources.jobs.*.tasks[*].spark_submit_task *jobs.SparkSubmitTask ALL resources.jobs.*.tasks[*].spark_submit_task.parameters []string ALL resources.jobs.*.tasks[*].spark_submit_task.parameters[*] string ALL resources.jobs.*.tasks[*].sql_task *jobs.SqlTask ALL resources.jobs.*.tasks[*].sql_task.alert *jobs.SqlTaskAlert ALL -resources.jobs.*.tasks[*].sql_task.alert.alert_id string ALL -resources.jobs.*.tasks[*].sql_task.alert.pause_subscriptions bool ALL +resources.jobs.*.tasks[*].sql_task.alert.alert_id *string ALL +resources.jobs.*.tasks[*].sql_task.alert.pause_subscriptions *bool ALL resources.jobs.*.tasks[*].sql_task.alert.subscriptions []jobs.SqlTaskSubscription ALL resources.jobs.*.tasks[*].sql_task.alert.subscriptions[*] jobs.SqlTaskSubscription ALL -resources.jobs.*.tasks[*].sql_task.alert.subscriptions[*].destination_id string ALL -resources.jobs.*.tasks[*].sql_task.alert.subscriptions[*].user_name string ALL +resources.jobs.*.tasks[*].sql_task.alert.subscriptions[*].destination_id *string ALL +resources.jobs.*.tasks[*].sql_task.alert.subscriptions[*].user_name *string ALL resources.jobs.*.tasks[*].sql_task.dashboard *jobs.SqlTaskDashboard ALL -resources.jobs.*.tasks[*].sql_task.dashboard.custom_subject string ALL -resources.jobs.*.tasks[*].sql_task.dashboard.dashboard_id string ALL -resources.jobs.*.tasks[*].sql_task.dashboard.pause_subscriptions bool ALL +resources.jobs.*.tasks[*].sql_task.dashboard.custom_subject *string ALL +resources.jobs.*.tasks[*].sql_task.dashboard.dashboard_id *string ALL +resources.jobs.*.tasks[*].sql_task.dashboard.pause_subscriptions *bool ALL resources.jobs.*.tasks[*].sql_task.dashboard.subscriptions []jobs.SqlTaskSubscription ALL resources.jobs.*.tasks[*].sql_task.dashboard.subscriptions[*] jobs.SqlTaskSubscription ALL -resources.jobs.*.tasks[*].sql_task.dashboard.subscriptions[*].destination_id string ALL -resources.jobs.*.tasks[*].sql_task.dashboard.subscriptions[*].user_name string ALL +resources.jobs.*.tasks[*].sql_task.dashboard.subscriptions[*].destination_id *string ALL +resources.jobs.*.tasks[*].sql_task.dashboard.subscriptions[*].user_name *string ALL resources.jobs.*.tasks[*].sql_task.file *jobs.SqlTaskFile ALL -resources.jobs.*.tasks[*].sql_task.file.path string ALL +resources.jobs.*.tasks[*].sql_task.file.path *string ALL resources.jobs.*.tasks[*].sql_task.file.source jobs.Source ALL resources.jobs.*.tasks[*].sql_task.parameters map[string]string ALL resources.jobs.*.tasks[*].sql_task.parameters.* string ALL resources.jobs.*.tasks[*].sql_task.query *jobs.SqlTaskQuery ALL -resources.jobs.*.tasks[*].sql_task.query.query_id string ALL -resources.jobs.*.tasks[*].sql_task.warehouse_id string ALL -resources.jobs.*.tasks[*].task_key string ALL -resources.jobs.*.tasks[*].timeout_seconds int ALL +resources.jobs.*.tasks[*].sql_task.query.query_id *string ALL +resources.jobs.*.tasks[*].sql_task.warehouse_id *string ALL +resources.jobs.*.tasks[*].task_key *string ALL +resources.jobs.*.tasks[*].timeout_seconds *int ALL resources.jobs.*.tasks[*].webhook_notifications *jobs.WebhookNotifications ALL resources.jobs.*.tasks[*].webhook_notifications.on_duration_warning_threshold_exceeded []jobs.Webhook ALL resources.jobs.*.tasks[*].webhook_notifications.on_duration_warning_threshold_exceeded[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].webhook_notifications.on_duration_warning_threshold_exceeded[*].id string ALL +resources.jobs.*.tasks[*].webhook_notifications.on_duration_warning_threshold_exceeded[*].id *string ALL resources.jobs.*.tasks[*].webhook_notifications.on_failure []jobs.Webhook ALL resources.jobs.*.tasks[*].webhook_notifications.on_failure[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].webhook_notifications.on_failure[*].id string ALL +resources.jobs.*.tasks[*].webhook_notifications.on_failure[*].id *string ALL resources.jobs.*.tasks[*].webhook_notifications.on_maintenance_complete []jobs.Webhook ALL resources.jobs.*.tasks[*].webhook_notifications.on_maintenance_complete[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].webhook_notifications.on_maintenance_complete[*].id string ALL +resources.jobs.*.tasks[*].webhook_notifications.on_maintenance_complete[*].id *string ALL resources.jobs.*.tasks[*].webhook_notifications.on_maintenance_start []jobs.Webhook ALL resources.jobs.*.tasks[*].webhook_notifications.on_maintenance_start[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].webhook_notifications.on_maintenance_start[*].id string ALL +resources.jobs.*.tasks[*].webhook_notifications.on_maintenance_start[*].id *string ALL resources.jobs.*.tasks[*].webhook_notifications.on_start []jobs.Webhook ALL resources.jobs.*.tasks[*].webhook_notifications.on_start[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].webhook_notifications.on_start[*].id string ALL +resources.jobs.*.tasks[*].webhook_notifications.on_start[*].id *string ALL resources.jobs.*.tasks[*].webhook_notifications.on_streaming_backlog_exceeded []jobs.Webhook ALL resources.jobs.*.tasks[*].webhook_notifications.on_streaming_backlog_exceeded[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].webhook_notifications.on_streaming_backlog_exceeded[*].id string ALL +resources.jobs.*.tasks[*].webhook_notifications.on_streaming_backlog_exceeded[*].id *string ALL resources.jobs.*.tasks[*].webhook_notifications.on_success []jobs.Webhook ALL resources.jobs.*.tasks[*].webhook_notifications.on_success[*] jobs.Webhook ALL -resources.jobs.*.tasks[*].webhook_notifications.on_success[*].id string ALL -resources.jobs.*.timeout_seconds int ALL +resources.jobs.*.tasks[*].webhook_notifications.on_success[*].id *string ALL +resources.jobs.*.timeout_seconds *int ALL resources.jobs.*.trigger *jobs.TriggerSettings ALL resources.jobs.*.trigger.file_arrival *jobs.FileArrivalTriggerConfiguration ALL -resources.jobs.*.trigger.file_arrival.min_time_between_triggers_seconds int ALL -resources.jobs.*.trigger.file_arrival.url string ALL -resources.jobs.*.trigger.file_arrival.wait_after_last_change_seconds int ALL +resources.jobs.*.trigger.file_arrival.min_time_between_triggers_seconds *int ALL +resources.jobs.*.trigger.file_arrival.url *string ALL +resources.jobs.*.trigger.file_arrival.wait_after_last_change_seconds *int ALL resources.jobs.*.trigger.model *jobs.ModelTriggerConfiguration ALL resources.jobs.*.trigger.model.aliases []string ALL resources.jobs.*.trigger.model.aliases[*] string ALL -resources.jobs.*.trigger.model.condition jobs.ModelTriggerConfigurationCondition ALL -resources.jobs.*.trigger.model.min_time_between_triggers_seconds int ALL -resources.jobs.*.trigger.model.securable_name string ALL -resources.jobs.*.trigger.model.wait_after_last_change_seconds int ALL -resources.jobs.*.trigger.pause_status jobs.PauseStatus ALL +resources.jobs.*.trigger.model.condition jobs.ModelTriggerConfiguration_ModelTriggerCondition ALL +resources.jobs.*.trigger.model.min_time_between_triggers_seconds *int ALL +resources.jobs.*.trigger.model.securable_name *string ALL +resources.jobs.*.trigger.model.wait_after_last_change_seconds *int ALL +resources.jobs.*.trigger.pause_status jobs.SchedulePauseStatus ALL resources.jobs.*.trigger.periodic *jobs.PeriodicTriggerConfiguration ALL -resources.jobs.*.trigger.periodic.interval int ALL -resources.jobs.*.trigger.periodic.unit jobs.PeriodicTriggerConfigurationTimeUnit ALL +resources.jobs.*.trigger.periodic.interval *int ALL +resources.jobs.*.trigger.periodic.unit jobs.PeriodicTriggerConfiguration_TimeUnit ALL resources.jobs.*.trigger.sql_condition *jobs.SqlConditionConfiguration ALL -resources.jobs.*.trigger.sql_condition.sql_query_id string ALL +resources.jobs.*.trigger.sql_condition.sql_query_id *string ALL resources.jobs.*.trigger.sql_condition.trigger_mode jobs.SqlConditionTriggerMode ALL -resources.jobs.*.trigger.sql_condition.warehouse_id string ALL -resources.jobs.*.trigger.table_update *jobs.TableUpdateTriggerConfiguration ALL -resources.jobs.*.trigger.table_update.condition jobs.Condition ALL -resources.jobs.*.trigger.table_update.min_time_between_triggers_seconds int ALL +resources.jobs.*.trigger.sql_condition.warehouse_id *string ALL +resources.jobs.*.trigger.table_update *jobs.TableTriggerConfiguration ALL +resources.jobs.*.trigger.table_update.condition jobs.TableTriggerConfiguration_Condition ALL +resources.jobs.*.trigger.table_update.min_time_between_triggers_seconds *int ALL resources.jobs.*.trigger.table_update.table_names []string ALL resources.jobs.*.trigger.table_update.table_names[*] string ALL -resources.jobs.*.trigger.table_update.wait_after_last_change_seconds int ALL +resources.jobs.*.trigger.table_update.wait_after_last_change_seconds *int ALL resources.jobs.*.trigger_details []jobs.TriggerDetails REMOTE resources.jobs.*.trigger_details[*] jobs.TriggerDetails REMOTE resources.jobs.*.trigger_details[*].history *jobs.TriggerHistory REMOTE resources.jobs.*.trigger_details[*].history.last_failed *jobs.TriggerEvaluation REMOTE -resources.jobs.*.trigger_details[*].history.last_failed.description string REMOTE -resources.jobs.*.trigger_details[*].history.last_failed.run_id int64 REMOTE -resources.jobs.*.trigger_details[*].history.last_failed.timestamp int64 REMOTE +resources.jobs.*.trigger_details[*].history.last_failed.description *string REMOTE +resources.jobs.*.trigger_details[*].history.last_failed.run_id *int64 REMOTE +resources.jobs.*.trigger_details[*].history.last_failed.timestamp *int64 REMOTE resources.jobs.*.trigger_details[*].history.last_not_triggered *jobs.TriggerEvaluation REMOTE -resources.jobs.*.trigger_details[*].history.last_not_triggered.description string REMOTE -resources.jobs.*.trigger_details[*].history.last_not_triggered.run_id int64 REMOTE -resources.jobs.*.trigger_details[*].history.last_not_triggered.timestamp int64 REMOTE +resources.jobs.*.trigger_details[*].history.last_not_triggered.description *string REMOTE +resources.jobs.*.trigger_details[*].history.last_not_triggered.run_id *int64 REMOTE +resources.jobs.*.trigger_details[*].history.last_not_triggered.timestamp *int64 REMOTE resources.jobs.*.trigger_details[*].history.last_triggered *jobs.TriggerEvaluation REMOTE -resources.jobs.*.trigger_details[*].history.last_triggered.description string REMOTE -resources.jobs.*.trigger_details[*].history.last_triggered.run_id int64 REMOTE -resources.jobs.*.trigger_details[*].history.last_triggered.timestamp int64 REMOTE +resources.jobs.*.trigger_details[*].history.last_triggered.description *string REMOTE +resources.jobs.*.trigger_details[*].history.last_triggered.run_id *int64 REMOTE +resources.jobs.*.trigger_details[*].history.last_triggered.timestamp *int64 REMOTE resources.jobs.*.trigger_details[*].state *jobs.PerTriggerState REMOTE resources.jobs.*.trigger_details[*].state.continuous *jobs.ContinuousTriggerState REMOTE -resources.jobs.*.trigger_details[*].state.continuous.consecutive_failures int REMOTE -resources.jobs.*.trigger_details[*].state.continuous.is_backing_off bool REMOTE -resources.jobs.*.trigger_details[*].state.continuous.next_attempt_ms int64 REMOTE +resources.jobs.*.trigger_details[*].state.continuous.consecutive_failures *int REMOTE +resources.jobs.*.trigger_details[*].state.continuous.is_backing_off *bool REMOTE +resources.jobs.*.trigger_details[*].state.continuous.next_attempt_ms *int64 REMOTE resources.jobs.*.trigger_details[*].state.file_arrival *jobs.FileArrivalTriggerState REMOTE -resources.jobs.*.trigger_details[*].state.file_arrival.using_file_events bool REMOTE +resources.jobs.*.trigger_details[*].state.file_arrival.using_file_events *bool REMOTE resources.jobs.*.trigger_details[*].state.model *jobs.ModelTriggerState REMOTE -resources.jobs.*.trigger_details[*].state.pause_status jobs.PauseStatus REMOTE +resources.jobs.*.trigger_details[*].state.pause_status jobs.SchedulePauseStatus REMOTE resources.jobs.*.trigger_details[*].state.periodic *jobs.PeriodicTriggerState REMOTE -resources.jobs.*.trigger_details[*].state.periodic.next_run_time int64 REMOTE +resources.jobs.*.trigger_details[*].state.periodic.next_run_time *int64 REMOTE resources.jobs.*.trigger_details[*].state.schedule *jobs.ScheduleTriggerState REMOTE resources.jobs.*.trigger_details[*].state.sql_condition *jobs.SqlConditionState REMOTE -resources.jobs.*.trigger_details[*].state.sql_condition.latest_condition_evaluation_satisfied bool REMOTE -resources.jobs.*.trigger_details[*].state.sql_condition.latest_condition_evaluation_sql_session_id string REMOTE -resources.jobs.*.trigger_details[*].state.sql_condition.latest_condition_evaluation_sql_statement_id string REMOTE +resources.jobs.*.trigger_details[*].state.sql_condition.latest_condition_evaluation_satisfied *bool REMOTE +resources.jobs.*.trigger_details[*].state.sql_condition.latest_condition_evaluation_sql_session_id *string REMOTE +resources.jobs.*.trigger_details[*].state.sql_condition.latest_condition_evaluation_sql_statement_id *string REMOTE resources.jobs.*.trigger_details[*].state.table_update *jobs.TableTriggerState REMOTE resources.jobs.*.trigger_details[*].state.table_update.last_seen_table_states []jobs.TableState REMOTE resources.jobs.*.trigger_details[*].state.table_update.last_seen_table_states[*] jobs.TableState REMOTE -resources.jobs.*.trigger_details[*].state.table_update.last_seen_table_states[*].has_seen_updates bool REMOTE -resources.jobs.*.trigger_details[*].state.table_update.last_seen_table_states[*].table_name string REMOTE -resources.jobs.*.trigger_details[*].state.table_update.using_scalable_monitoring bool REMOTE -resources.jobs.*.trigger_state *jobs.TriggerStateProto REMOTE +resources.jobs.*.trigger_details[*].state.table_update.last_seen_table_states[*].has_seen_updates *bool REMOTE +resources.jobs.*.trigger_details[*].state.table_update.last_seen_table_states[*].table_name *string REMOTE +resources.jobs.*.trigger_details[*].state.table_update.using_scalable_monitoring *bool REMOTE +resources.jobs.*.trigger_state *jobs.TriggerState REMOTE resources.jobs.*.trigger_state.file_arrival *jobs.FileArrivalTriggerState REMOTE -resources.jobs.*.trigger_state.file_arrival.using_file_events bool REMOTE -resources.jobs.*.trigger_state.pause_status jobs.PauseStatus REMOTE +resources.jobs.*.trigger_state.file_arrival.using_file_events *bool REMOTE +resources.jobs.*.trigger_state.pause_status jobs.SchedulePauseStatus REMOTE resources.jobs.*.trigger_state.sql_condition *jobs.SqlConditionState REMOTE -resources.jobs.*.trigger_state.sql_condition.latest_condition_evaluation_satisfied bool REMOTE -resources.jobs.*.trigger_state.sql_condition.latest_condition_evaluation_sql_session_id string REMOTE -resources.jobs.*.trigger_state.sql_condition.latest_condition_evaluation_sql_statement_id string REMOTE +resources.jobs.*.trigger_state.sql_condition.latest_condition_evaluation_satisfied *bool REMOTE +resources.jobs.*.trigger_state.sql_condition.latest_condition_evaluation_sql_session_id *string REMOTE +resources.jobs.*.trigger_state.sql_condition.latest_condition_evaluation_sql_statement_id *string REMOTE resources.jobs.*.trigger_state.table *jobs.TableTriggerState REMOTE resources.jobs.*.trigger_state.table.last_seen_table_states []jobs.TableState REMOTE resources.jobs.*.trigger_state.table.last_seen_table_states[*] jobs.TableState REMOTE -resources.jobs.*.trigger_state.table.last_seen_table_states[*].has_seen_updates bool REMOTE -resources.jobs.*.trigger_state.table.last_seen_table_states[*].table_name string REMOTE -resources.jobs.*.trigger_state.table.using_scalable_monitoring bool REMOTE +resources.jobs.*.trigger_state.table.last_seen_table_states[*].has_seen_updates *bool REMOTE +resources.jobs.*.trigger_state.table.last_seen_table_states[*].table_name *string REMOTE +resources.jobs.*.trigger_state.table.using_scalable_monitoring *bool REMOTE resources.jobs.*.triggers []jobs.TriggerConfiguration ALL resources.jobs.*.triggers[*] jobs.TriggerConfiguration ALL resources.jobs.*.triggers[*].continuous *jobs.ContinuousTriggerConfiguration ALL resources.jobs.*.triggers[*].continuous.maintenance_window *jobs.MaintenanceWindow ALL resources.jobs.*.triggers[*].continuous.maintenance_window.day_of_week jobs.DayOfWeek ALL -resources.jobs.*.triggers[*].continuous.maintenance_window.start_hour int ALL -resources.jobs.*.triggers[*].continuous.maintenance_window.timezone_id string ALL +resources.jobs.*.triggers[*].continuous.maintenance_window.start_hour *int ALL +resources.jobs.*.triggers[*].continuous.maintenance_window.timezone_id *string ALL resources.jobs.*.triggers[*].continuous.task_retry_mode jobs.TaskRetryMode ALL resources.jobs.*.triggers[*].file_arrival *jobs.FileArrivalTriggerConfiguration ALL -resources.jobs.*.triggers[*].file_arrival.min_time_between_triggers_seconds int ALL -resources.jobs.*.triggers[*].file_arrival.url string ALL -resources.jobs.*.triggers[*].file_arrival.wait_after_last_change_seconds int ALL +resources.jobs.*.triggers[*].file_arrival.min_time_between_triggers_seconds *int ALL +resources.jobs.*.triggers[*].file_arrival.url *string ALL +resources.jobs.*.triggers[*].file_arrival.wait_after_last_change_seconds *int ALL resources.jobs.*.triggers[*].model *jobs.ModelTriggerConfiguration ALL resources.jobs.*.triggers[*].model.aliases []string ALL resources.jobs.*.triggers[*].model.aliases[*] string ALL -resources.jobs.*.triggers[*].model.condition jobs.ModelTriggerConfigurationCondition ALL -resources.jobs.*.triggers[*].model.min_time_between_triggers_seconds int ALL -resources.jobs.*.triggers[*].model.securable_name string ALL -resources.jobs.*.triggers[*].model.wait_after_last_change_seconds int ALL -resources.jobs.*.triggers[*].pause_status jobs.PauseStatus ALL +resources.jobs.*.triggers[*].model.condition jobs.ModelTriggerConfiguration_ModelTriggerCondition ALL +resources.jobs.*.triggers[*].model.min_time_between_triggers_seconds *int ALL +resources.jobs.*.triggers[*].model.securable_name *string ALL +resources.jobs.*.triggers[*].model.wait_after_last_change_seconds *int ALL +resources.jobs.*.triggers[*].pause_status jobs.SchedulePauseStatus ALL resources.jobs.*.triggers[*].periodic *jobs.PeriodicTriggerConfiguration ALL -resources.jobs.*.triggers[*].periodic.interval int ALL -resources.jobs.*.triggers[*].periodic.unit jobs.PeriodicTriggerConfigurationTimeUnit ALL +resources.jobs.*.triggers[*].periodic.interval *int ALL +resources.jobs.*.triggers[*].periodic.unit jobs.PeriodicTriggerConfiguration_TimeUnit ALL resources.jobs.*.triggers[*].schedule *jobs.CronTriggerConfiguration ALL -resources.jobs.*.triggers[*].schedule.quartz_cron_expression string ALL -resources.jobs.*.triggers[*].schedule.timezone_id string ALL +resources.jobs.*.triggers[*].schedule.quartz_cron_expression *string ALL +resources.jobs.*.triggers[*].schedule.timezone_id *string ALL resources.jobs.*.triggers[*].sql_condition *jobs.SqlConditionConfiguration ALL -resources.jobs.*.triggers[*].sql_condition.sql_query_id string ALL +resources.jobs.*.triggers[*].sql_condition.sql_query_id *string ALL resources.jobs.*.triggers[*].sql_condition.trigger_mode jobs.SqlConditionTriggerMode ALL -resources.jobs.*.triggers[*].sql_condition.warehouse_id string ALL -resources.jobs.*.triggers[*].table_update *jobs.TableUpdateTriggerConfiguration ALL -resources.jobs.*.triggers[*].table_update.condition jobs.Condition ALL -resources.jobs.*.triggers[*].table_update.min_time_between_triggers_seconds int ALL +resources.jobs.*.triggers[*].sql_condition.warehouse_id *string ALL +resources.jobs.*.triggers[*].table_update *jobs.TableTriggerConfiguration ALL +resources.jobs.*.triggers[*].table_update.condition jobs.TableTriggerConfiguration_Condition ALL +resources.jobs.*.triggers[*].table_update.min_time_between_triggers_seconds *int ALL resources.jobs.*.triggers[*].table_update.table_names []string ALL resources.jobs.*.triggers[*].table_update.table_names[*] string ALL -resources.jobs.*.triggers[*].table_update.wait_after_last_change_seconds int ALL +resources.jobs.*.triggers[*].table_update.wait_after_last_change_seconds *int ALL resources.jobs.*.url string INPUT -resources.jobs.*.usage_policy_id string ALL +resources.jobs.*.usage_policy_id *string ALL resources.jobs.*.webhook_notifications *jobs.WebhookNotifications ALL resources.jobs.*.webhook_notifications.on_duration_warning_threshold_exceeded []jobs.Webhook ALL resources.jobs.*.webhook_notifications.on_duration_warning_threshold_exceeded[*] jobs.Webhook ALL -resources.jobs.*.webhook_notifications.on_duration_warning_threshold_exceeded[*].id string ALL +resources.jobs.*.webhook_notifications.on_duration_warning_threshold_exceeded[*].id *string ALL resources.jobs.*.webhook_notifications.on_failure []jobs.Webhook ALL resources.jobs.*.webhook_notifications.on_failure[*] jobs.Webhook ALL -resources.jobs.*.webhook_notifications.on_failure[*].id string ALL +resources.jobs.*.webhook_notifications.on_failure[*].id *string ALL resources.jobs.*.webhook_notifications.on_maintenance_complete []jobs.Webhook ALL resources.jobs.*.webhook_notifications.on_maintenance_complete[*] jobs.Webhook ALL -resources.jobs.*.webhook_notifications.on_maintenance_complete[*].id string ALL +resources.jobs.*.webhook_notifications.on_maintenance_complete[*].id *string ALL resources.jobs.*.webhook_notifications.on_maintenance_start []jobs.Webhook ALL resources.jobs.*.webhook_notifications.on_maintenance_start[*] jobs.Webhook ALL -resources.jobs.*.webhook_notifications.on_maintenance_start[*].id string ALL +resources.jobs.*.webhook_notifications.on_maintenance_start[*].id *string ALL resources.jobs.*.webhook_notifications.on_start []jobs.Webhook ALL resources.jobs.*.webhook_notifications.on_start[*] jobs.Webhook ALL -resources.jobs.*.webhook_notifications.on_start[*].id string ALL +resources.jobs.*.webhook_notifications.on_start[*].id *string ALL resources.jobs.*.webhook_notifications.on_streaming_backlog_exceeded []jobs.Webhook ALL resources.jobs.*.webhook_notifications.on_streaming_backlog_exceeded[*] jobs.Webhook ALL -resources.jobs.*.webhook_notifications.on_streaming_backlog_exceeded[*].id string ALL +resources.jobs.*.webhook_notifications.on_streaming_backlog_exceeded[*].id *string ALL resources.jobs.*.webhook_notifications.on_success []jobs.Webhook ALL resources.jobs.*.webhook_notifications.on_success[*] jobs.Webhook ALL -resources.jobs.*.webhook_notifications.on_success[*].id string ALL +resources.jobs.*.webhook_notifications.on_success[*].id *string ALL resources.jobs.*.permissions.object_id string ALL resources.jobs.*.permissions[*] dresources.StatePermission ALL resources.jobs.*.permissions[*].group_name string ALL -resources.jobs.*.permissions[*].level iam.PermissionLevel ALL +resources.jobs.*.permissions[*].level resources.PermissionLevel ALL resources.jobs.*.permissions[*].service_principal_name string ALL resources.jobs.*.permissions[*].user_name string ALL resources.mcp_services.*.comment string ALL -resources.mcp_services.*.config *catalog.McpServiceConfig ALL +resources.mcp_services.*.config *aigateway.McpServiceConfig ALL resources.mcp_services.*.config.include_tool_selectors []string ALL resources.mcp_services.*.config.include_tool_selectors[*] string ALL -resources.mcp_services.*.config.rate_limits []catalog.RateLimit ALL -resources.mcp_services.*.config.rate_limits[*] catalog.RateLimit ALL -resources.mcp_services.*.config.rate_limits[*].key catalog.RateLimitRateLimitKey ALL -resources.mcp_services.*.config.rate_limits[*].principal string ALL -resources.mcp_services.*.config.rate_limits[*].renewal_period catalog.RateLimitRateLimitRenewalPeriod ALL -resources.mcp_services.*.config.rate_limits[*].requests int64 ALL -resources.mcp_services.*.config.rate_limits[*].tokens int64 ALL -resources.mcp_services.*.config.source_connection *catalog.McpServiceConfigSourceConnection ALL -resources.mcp_services.*.config.source_connection.is_deleted bool ALL -resources.mcp_services.*.config.source_connection.name string ALL +resources.mcp_services.*.config.rate_limits []aigateway.RateLimit ALL +resources.mcp_services.*.config.rate_limits[*] aigateway.RateLimit ALL +resources.mcp_services.*.config.rate_limits[*].key aigateway.RateLimit_RateLimitKey ALL +resources.mcp_services.*.config.rate_limits[*].principal *string ALL +resources.mcp_services.*.config.rate_limits[*].renewal_period aigateway.RateLimit_RateLimitRenewalPeriod ALL +resources.mcp_services.*.config.rate_limits[*].requests *int64 ALL +resources.mcp_services.*.config.rate_limits[*].tokens *int64 ALL +resources.mcp_services.*.config.source_connection *aigateway.McpServiceConfig_SourceConnection ALL +resources.mcp_services.*.config.source_connection.is_deleted *bool ALL +resources.mcp_services.*.config.source_connection.name *string ALL resources.mcp_services.*.config.source_connection.options map[string]string ALL resources.mcp_services.*.config.source_connection.options.* string ALL resources.mcp_services.*.id string INPUT @@ -2176,127 +2187,127 @@ resources.mcp_services.*.parent string ALL resources.mcp_services.*.url string INPUT resources.mcp_services.*.grants.full_name string ALL resources.mcp_services.*.grants.securable_type string ALL -resources.mcp_services.*.grants[*] catalog.PrivilegeAssignment ALL -resources.mcp_services.*.grants[*].principal string ALL -resources.mcp_services.*.grants[*].privileges []catalog.Privilege ALL -resources.mcp_services.*.grants[*].privileges[*] catalog.Privilege ALL +resources.mcp_services.*.grants[*] grants.PrivilegeAssignment ALL +resources.mcp_services.*.grants[*].principal *string ALL +resources.mcp_services.*.grants[*].privileges []string ALL +resources.mcp_services.*.grants[*].privileges[*] string ALL resources.model_provider_services.*.comment string ALL -resources.model_provider_services.*.config *catalog.ModelProviderServiceConfig ALL -resources.model_provider_services.*.config.allow_all_targets bool ALL -resources.model_provider_services.*.config.amazon_bedrock *catalog.ModelProviderServiceConfigAmazonBedrockProviderConfig ALL -resources.model_provider_services.*.config.amazon_bedrock.direct *catalog.ModelProviderServiceConfigAmazonBedrockProviderDirectConfig ALL -resources.model_provider_services.*.config.amazon_bedrock.direct.aws_access_key *catalog.ModelProviderServiceConfigAwsAccessKey ALL -resources.model_provider_services.*.config.amazon_bedrock.direct.aws_access_key.access_key_id string ALL -resources.model_provider_services.*.config.amazon_bedrock.direct.aws_access_key.secret_access_key *catalog.ModelProviderServiceConfigProviderSecret ALL -resources.model_provider_services.*.config.amazon_bedrock.direct.aws_access_key.secret_access_key.plaintext string ALL -resources.model_provider_services.*.config.amazon_bedrock.direct.aws_access_key.secret_access_key.secret_reference *catalog.ModelProviderServiceConfigSecretReference ALL -resources.model_provider_services.*.config.amazon_bedrock.direct.aws_access_key.secret_access_key.secret_reference.name string ALL -resources.model_provider_services.*.config.amazon_bedrock.direct.region string ALL -resources.model_provider_services.*.config.amazon_bedrock.direct.service_credential *catalog.ModelProviderServiceConfigServiceCredential ALL -resources.model_provider_services.*.config.amazon_bedrock.direct.service_credential.name string ALL -resources.model_provider_services.*.config.anthropic *catalog.ModelProviderServiceConfigAnthropicProviderConfig ALL -resources.model_provider_services.*.config.anthropic.direct *catalog.ModelProviderServiceConfigAnthropicProviderDirectConfig ALL -resources.model_provider_services.*.config.anthropic.direct.api_key *catalog.ModelProviderServiceConfigProviderSecret ALL -resources.model_provider_services.*.config.anthropic.direct.api_key.plaintext string ALL -resources.model_provider_services.*.config.anthropic.direct.api_key.secret_reference *catalog.ModelProviderServiceConfigSecretReference ALL -resources.model_provider_services.*.config.anthropic.direct.api_key.secret_reference.name string ALL -resources.model_provider_services.*.config.anthropic.relayed *catalog.ModelProviderServiceConfigAnthropicProviderRelayedConfig ALL -resources.model_provider_services.*.config.azure_openai *catalog.ModelProviderServiceConfigAzureOpenAiProviderConfig ALL -resources.model_provider_services.*.config.azure_openai.direct *catalog.ModelProviderServiceConfigAzureOpenAiProviderDirectConfig ALL -resources.model_provider_services.*.config.azure_openai.direct.api_key *catalog.ModelProviderServiceConfigProviderSecret ALL -resources.model_provider_services.*.config.azure_openai.direct.api_key.plaintext string ALL -resources.model_provider_services.*.config.azure_openai.direct.api_key.secret_reference *catalog.ModelProviderServiceConfigSecretReference ALL -resources.model_provider_services.*.config.azure_openai.direct.api_key.secret_reference.name string ALL -resources.model_provider_services.*.config.azure_openai.direct.base_url string ALL -resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal *catalog.ModelProviderServiceConfigEntraServicePrincipal ALL -resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal.client_id string ALL -resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal.client_secret *catalog.ModelProviderServiceConfigProviderSecret ALL -resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal.client_secret.plaintext string ALL -resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal.client_secret.secret_reference *catalog.ModelProviderServiceConfigSecretReference ALL -resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal.client_secret.secret_reference.name string ALL -resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal.tenant_id string ALL -resources.model_provider_services.*.config.azure_openai.direct.service_credential *catalog.ModelProviderServiceConfigServiceCredential ALL -resources.model_provider_services.*.config.azure_openai.direct.service_credential.name string ALL -resources.model_provider_services.*.config.bedrock_mantle *catalog.ModelProviderServiceConfigAmazonBedrockProviderConfig ALL -resources.model_provider_services.*.config.bedrock_mantle.direct *catalog.ModelProviderServiceConfigAmazonBedrockProviderDirectConfig ALL -resources.model_provider_services.*.config.bedrock_mantle.direct.aws_access_key *catalog.ModelProviderServiceConfigAwsAccessKey ALL -resources.model_provider_services.*.config.bedrock_mantle.direct.aws_access_key.access_key_id string ALL -resources.model_provider_services.*.config.bedrock_mantle.direct.aws_access_key.secret_access_key *catalog.ModelProviderServiceConfigProviderSecret ALL -resources.model_provider_services.*.config.bedrock_mantle.direct.aws_access_key.secret_access_key.plaintext string ALL -resources.model_provider_services.*.config.bedrock_mantle.direct.aws_access_key.secret_access_key.secret_reference *catalog.ModelProviderServiceConfigSecretReference ALL -resources.model_provider_services.*.config.bedrock_mantle.direct.aws_access_key.secret_access_key.secret_reference.name string ALL -resources.model_provider_services.*.config.bedrock_mantle.direct.region string ALL -resources.model_provider_services.*.config.bedrock_mantle.direct.service_credential *catalog.ModelProviderServiceConfigServiceCredential ALL -resources.model_provider_services.*.config.bedrock_mantle.direct.service_credential.name string ALL -resources.model_provider_services.*.config.custom *catalog.ModelProviderServiceConfigCustomProviderConfig ALL -resources.model_provider_services.*.config.custom.direct *catalog.ModelProviderServiceConfigCustomProviderDirectConfig ALL -resources.model_provider_services.*.config.custom.direct.api_key *catalog.ModelProviderServiceConfigProviderSecret ALL -resources.model_provider_services.*.config.custom.direct.api_key.plaintext string ALL -resources.model_provider_services.*.config.custom.direct.api_key.secret_reference *catalog.ModelProviderServiceConfigSecretReference ALL -resources.model_provider_services.*.config.custom.direct.api_key.secret_reference.name string ALL -resources.model_provider_services.*.config.custom.direct.base_url string ALL -resources.model_provider_services.*.config.custom.direct.header_auth *catalog.ModelProviderServiceConfigCustomProviderApiKeyHeaderAuth ALL -resources.model_provider_services.*.config.custom.direct.header_auth.api_key_name string ALL -resources.model_provider_services.*.config.custom.direct.header_auth.api_key_value *catalog.ModelProviderServiceConfigProviderSecret ALL -resources.model_provider_services.*.config.custom.direct.header_auth.api_key_value.plaintext string ALL -resources.model_provider_services.*.config.custom.direct.header_auth.api_key_value.secret_reference *catalog.ModelProviderServiceConfigSecretReference ALL -resources.model_provider_services.*.config.custom.direct.header_auth.api_key_value.secret_reference.name string ALL -resources.model_provider_services.*.config.forward_headers bool ALL -resources.model_provider_services.*.config.forward_query_parameters bool ALL -resources.model_provider_services.*.config.forward_unmanaged_paths bool ALL -resources.model_provider_services.*.config.gemini_enterprise *catalog.ModelProviderServiceConfigGeminiEnterpriseProviderConfig ALL -resources.model_provider_services.*.config.gemini_enterprise.direct *catalog.ModelProviderServiceConfigGeminiEnterpriseProviderDirectConfig ALL -resources.model_provider_services.*.config.gemini_enterprise.direct.api_key *catalog.ModelProviderServiceConfigProviderSecret ALL -resources.model_provider_services.*.config.gemini_enterprise.direct.api_key.plaintext string ALL -resources.model_provider_services.*.config.gemini_enterprise.direct.api_key.secret_reference *catalog.ModelProviderServiceConfigSecretReference ALL -resources.model_provider_services.*.config.gemini_enterprise.direct.api_key.secret_reference.name string ALL -resources.model_provider_services.*.config.gemini_enterprise.direct.project_id string ALL -resources.model_provider_services.*.config.gemini_enterprise.direct.region string ALL -resources.model_provider_services.*.config.gemini_enterprise.direct.service_credential *catalog.ModelProviderServiceConfigServiceCredential ALL -resources.model_provider_services.*.config.gemini_enterprise.direct.service_credential.name string ALL -resources.model_provider_services.*.config.inference_table *catalog.InferenceTableConfig ALL -resources.model_provider_services.*.config.inference_table.is_deleted bool ALL -resources.model_provider_services.*.config.inference_table.parent string ALL -resources.model_provider_services.*.config.inference_table.table string ALL -resources.model_provider_services.*.config.inference_table.table_name_prefix string ALL -resources.model_provider_services.*.config.microsoft_foundry *catalog.ModelProviderServiceConfigMicrosoftFoundryProviderConfig ALL -resources.model_provider_services.*.config.microsoft_foundry.direct *catalog.ModelProviderServiceConfigMicrosoftFoundryProviderDirectConfig ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.api_key *catalog.ModelProviderServiceConfigProviderSecret ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.api_key.plaintext string ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.api_key.secret_reference *catalog.ModelProviderServiceConfigSecretReference ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.api_key.secret_reference.name string ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.base_url string ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal *catalog.ModelProviderServiceConfigEntraServicePrincipal ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal.client_id string ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal.client_secret *catalog.ModelProviderServiceConfigProviderSecret ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal.client_secret.plaintext string ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal.client_secret.secret_reference *catalog.ModelProviderServiceConfigSecretReference ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal.client_secret.secret_reference.name string ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal.tenant_id string ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.service_credential *catalog.ModelProviderServiceConfigServiceCredential ALL -resources.model_provider_services.*.config.microsoft_foundry.direct.service_credential.name string ALL -resources.model_provider_services.*.config.openai *catalog.ModelProviderServiceConfigOpenAiProviderConfig ALL -resources.model_provider_services.*.config.openai.direct *catalog.ModelProviderServiceConfigOpenAiProviderDirectConfig ALL -resources.model_provider_services.*.config.openai.direct.api_key *catalog.ModelProviderServiceConfigProviderSecret ALL -resources.model_provider_services.*.config.openai.direct.api_key.plaintext string ALL -resources.model_provider_services.*.config.openai.direct.api_key.secret_reference *catalog.ModelProviderServiceConfigSecretReference ALL -resources.model_provider_services.*.config.openai.direct.api_key.secret_reference.name string ALL -resources.model_provider_services.*.config.openai.direct.base_url string ALL -resources.model_provider_services.*.config.openai.direct.organization string ALL -resources.model_provider_services.*.config.pricing *catalog.ModelProviderServiceConfigProviderPricingConfig ALL -resources.model_provider_services.*.config.pricing.default_discount_basis_points int ALL -resources.model_provider_services.*.config.provider_type catalog.ModelProviderServiceConfigExternalModelProviderType ALL -resources.model_provider_services.*.config.rate_limits []catalog.RateLimit ALL -resources.model_provider_services.*.config.rate_limits[*] catalog.RateLimit ALL -resources.model_provider_services.*.config.rate_limits[*].key catalog.RateLimitRateLimitKey ALL -resources.model_provider_services.*.config.rate_limits[*].principal string ALL -resources.model_provider_services.*.config.rate_limits[*].renewal_period catalog.RateLimitRateLimitRenewalPeriod ALL -resources.model_provider_services.*.config.rate_limits[*].requests int64 ALL -resources.model_provider_services.*.config.rate_limits[*].tokens int64 ALL -resources.model_provider_services.*.config.targets []catalog.ModelProviderServiceConfigModelTargetConfig ALL -resources.model_provider_services.*.config.targets[*] catalog.ModelProviderServiceConfigModelTargetConfig ALL -resources.model_provider_services.*.config.targets[*].endpoint_route string ALL -resources.model_provider_services.*.config.targets[*].model string ALL +resources.model_provider_services.*.config *aigateway.ModelProviderServiceConfig ALL +resources.model_provider_services.*.config.allow_all_targets *bool ALL +resources.model_provider_services.*.config.amazon_bedrock *aigateway.ModelProviderServiceConfig_AmazonBedrockProviderConfig ALL +resources.model_provider_services.*.config.amazon_bedrock.direct *aigateway.ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig ALL +resources.model_provider_services.*.config.amazon_bedrock.direct.aws_access_key *aigateway.ModelProviderServiceConfig_AwsAccessKey ALL +resources.model_provider_services.*.config.amazon_bedrock.direct.aws_access_key.access_key_id *string ALL +resources.model_provider_services.*.config.amazon_bedrock.direct.aws_access_key.secret_access_key *aigateway.ModelProviderServiceConfig_ProviderSecret ALL +resources.model_provider_services.*.config.amazon_bedrock.direct.aws_access_key.secret_access_key.plaintext *string ALL +resources.model_provider_services.*.config.amazon_bedrock.direct.aws_access_key.secret_access_key.secret_reference *aigateway.ModelProviderServiceConfig_SecretReference ALL +resources.model_provider_services.*.config.amazon_bedrock.direct.aws_access_key.secret_access_key.secret_reference.name *string ALL +resources.model_provider_services.*.config.amazon_bedrock.direct.region *string ALL +resources.model_provider_services.*.config.amazon_bedrock.direct.service_credential *aigateway.ModelProviderServiceConfig_ServiceCredential ALL +resources.model_provider_services.*.config.amazon_bedrock.direct.service_credential.name *string ALL +resources.model_provider_services.*.config.anthropic *aigateway.ModelProviderServiceConfig_AnthropicProviderConfig ALL +resources.model_provider_services.*.config.anthropic.direct *aigateway.ModelProviderServiceConfig_AnthropicProviderDirectConfig ALL +resources.model_provider_services.*.config.anthropic.direct.api_key *aigateway.ModelProviderServiceConfig_ProviderSecret ALL +resources.model_provider_services.*.config.anthropic.direct.api_key.plaintext *string ALL +resources.model_provider_services.*.config.anthropic.direct.api_key.secret_reference *aigateway.ModelProviderServiceConfig_SecretReference ALL +resources.model_provider_services.*.config.anthropic.direct.api_key.secret_reference.name *string ALL +resources.model_provider_services.*.config.anthropic.relayed *aigateway.ModelProviderServiceConfig_AnthropicProviderRelayedConfig ALL +resources.model_provider_services.*.config.azure_openai *aigateway.ModelProviderServiceConfig_AzureOpenAiProviderConfig ALL +resources.model_provider_services.*.config.azure_openai.direct *aigateway.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig ALL +resources.model_provider_services.*.config.azure_openai.direct.api_key *aigateway.ModelProviderServiceConfig_ProviderSecret ALL +resources.model_provider_services.*.config.azure_openai.direct.api_key.plaintext *string ALL +resources.model_provider_services.*.config.azure_openai.direct.api_key.secret_reference *aigateway.ModelProviderServiceConfig_SecretReference ALL +resources.model_provider_services.*.config.azure_openai.direct.api_key.secret_reference.name *string ALL +resources.model_provider_services.*.config.azure_openai.direct.base_url *string ALL +resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal *aigateway.ModelProviderServiceConfig_EntraServicePrincipal ALL +resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal.client_id *string ALL +resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal.client_secret *aigateway.ModelProviderServiceConfig_ProviderSecret ALL +resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal.client_secret.plaintext *string ALL +resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal.client_secret.secret_reference *aigateway.ModelProviderServiceConfig_SecretReference ALL +resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal.client_secret.secret_reference.name *string ALL +resources.model_provider_services.*.config.azure_openai.direct.entra_service_principal.tenant_id *string ALL +resources.model_provider_services.*.config.azure_openai.direct.service_credential *aigateway.ModelProviderServiceConfig_ServiceCredential ALL +resources.model_provider_services.*.config.azure_openai.direct.service_credential.name *string ALL +resources.model_provider_services.*.config.bedrock_mantle *aigateway.ModelProviderServiceConfig_AmazonBedrockProviderConfig ALL +resources.model_provider_services.*.config.bedrock_mantle.direct *aigateway.ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig ALL +resources.model_provider_services.*.config.bedrock_mantle.direct.aws_access_key *aigateway.ModelProviderServiceConfig_AwsAccessKey ALL +resources.model_provider_services.*.config.bedrock_mantle.direct.aws_access_key.access_key_id *string ALL +resources.model_provider_services.*.config.bedrock_mantle.direct.aws_access_key.secret_access_key *aigateway.ModelProviderServiceConfig_ProviderSecret ALL +resources.model_provider_services.*.config.bedrock_mantle.direct.aws_access_key.secret_access_key.plaintext *string ALL +resources.model_provider_services.*.config.bedrock_mantle.direct.aws_access_key.secret_access_key.secret_reference *aigateway.ModelProviderServiceConfig_SecretReference ALL +resources.model_provider_services.*.config.bedrock_mantle.direct.aws_access_key.secret_access_key.secret_reference.name *string ALL +resources.model_provider_services.*.config.bedrock_mantle.direct.region *string ALL +resources.model_provider_services.*.config.bedrock_mantle.direct.service_credential *aigateway.ModelProviderServiceConfig_ServiceCredential ALL +resources.model_provider_services.*.config.bedrock_mantle.direct.service_credential.name *string ALL +resources.model_provider_services.*.config.custom *aigateway.ModelProviderServiceConfig_CustomProviderConfig ALL +resources.model_provider_services.*.config.custom.direct *aigateway.ModelProviderServiceConfig_CustomProviderDirectConfig ALL +resources.model_provider_services.*.config.custom.direct.api_key *aigateway.ModelProviderServiceConfig_ProviderSecret ALL +resources.model_provider_services.*.config.custom.direct.api_key.plaintext *string ALL +resources.model_provider_services.*.config.custom.direct.api_key.secret_reference *aigateway.ModelProviderServiceConfig_SecretReference ALL +resources.model_provider_services.*.config.custom.direct.api_key.secret_reference.name *string ALL +resources.model_provider_services.*.config.custom.direct.base_url *string ALL +resources.model_provider_services.*.config.custom.direct.header_auth *aigateway.ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuth ALL +resources.model_provider_services.*.config.custom.direct.header_auth.api_key_name *string ALL +resources.model_provider_services.*.config.custom.direct.header_auth.api_key_value *aigateway.ModelProviderServiceConfig_ProviderSecret ALL +resources.model_provider_services.*.config.custom.direct.header_auth.api_key_value.plaintext *string ALL +resources.model_provider_services.*.config.custom.direct.header_auth.api_key_value.secret_reference *aigateway.ModelProviderServiceConfig_SecretReference ALL +resources.model_provider_services.*.config.custom.direct.header_auth.api_key_value.secret_reference.name *string ALL +resources.model_provider_services.*.config.forward_headers *bool ALL +resources.model_provider_services.*.config.forward_query_parameters *bool ALL +resources.model_provider_services.*.config.forward_unmanaged_paths *bool ALL +resources.model_provider_services.*.config.gemini_enterprise *aigateway.ModelProviderServiceConfig_GeminiEnterpriseProviderConfig ALL +resources.model_provider_services.*.config.gemini_enterprise.direct *aigateway.ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig ALL +resources.model_provider_services.*.config.gemini_enterprise.direct.api_key *aigateway.ModelProviderServiceConfig_ProviderSecret ALL +resources.model_provider_services.*.config.gemini_enterprise.direct.api_key.plaintext *string ALL +resources.model_provider_services.*.config.gemini_enterprise.direct.api_key.secret_reference *aigateway.ModelProviderServiceConfig_SecretReference ALL +resources.model_provider_services.*.config.gemini_enterprise.direct.api_key.secret_reference.name *string ALL +resources.model_provider_services.*.config.gemini_enterprise.direct.project_id *string ALL +resources.model_provider_services.*.config.gemini_enterprise.direct.region *string ALL +resources.model_provider_services.*.config.gemini_enterprise.direct.service_credential *aigateway.ModelProviderServiceConfig_ServiceCredential ALL +resources.model_provider_services.*.config.gemini_enterprise.direct.service_credential.name *string ALL +resources.model_provider_services.*.config.inference_table *aigateway.InferenceTableConfig ALL +resources.model_provider_services.*.config.inference_table.is_deleted *bool ALL +resources.model_provider_services.*.config.inference_table.parent *string ALL +resources.model_provider_services.*.config.inference_table.table *string ALL +resources.model_provider_services.*.config.inference_table.table_name_prefix *string ALL +resources.model_provider_services.*.config.microsoft_foundry *aigateway.ModelProviderServiceConfig_MicrosoftFoundryProviderConfig ALL +resources.model_provider_services.*.config.microsoft_foundry.direct *aigateway.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.api_key *aigateway.ModelProviderServiceConfig_ProviderSecret ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.api_key.plaintext *string ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.api_key.secret_reference *aigateway.ModelProviderServiceConfig_SecretReference ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.api_key.secret_reference.name *string ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.base_url *string ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal *aigateway.ModelProviderServiceConfig_EntraServicePrincipal ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal.client_id *string ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal.client_secret *aigateway.ModelProviderServiceConfig_ProviderSecret ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal.client_secret.plaintext *string ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal.client_secret.secret_reference *aigateway.ModelProviderServiceConfig_SecretReference ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal.client_secret.secret_reference.name *string ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.entra_service_principal.tenant_id *string ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.service_credential *aigateway.ModelProviderServiceConfig_ServiceCredential ALL +resources.model_provider_services.*.config.microsoft_foundry.direct.service_credential.name *string ALL +resources.model_provider_services.*.config.openai *aigateway.ModelProviderServiceConfig_OpenAiProviderConfig ALL +resources.model_provider_services.*.config.openai.direct *aigateway.ModelProviderServiceConfig_OpenAiProviderDirectConfig ALL +resources.model_provider_services.*.config.openai.direct.api_key *aigateway.ModelProviderServiceConfig_ProviderSecret ALL +resources.model_provider_services.*.config.openai.direct.api_key.plaintext *string ALL +resources.model_provider_services.*.config.openai.direct.api_key.secret_reference *aigateway.ModelProviderServiceConfig_SecretReference ALL +resources.model_provider_services.*.config.openai.direct.api_key.secret_reference.name *string ALL +resources.model_provider_services.*.config.openai.direct.base_url *string ALL +resources.model_provider_services.*.config.openai.direct.organization *string ALL +resources.model_provider_services.*.config.pricing *aigateway.ModelProviderServiceConfig_ProviderPricingConfig ALL +resources.model_provider_services.*.config.pricing.default_discount_basis_points *int ALL +resources.model_provider_services.*.config.provider_type aigateway.ModelProviderServiceConfig_ExternalModelProviderType ALL +resources.model_provider_services.*.config.rate_limits []aigateway.RateLimit ALL +resources.model_provider_services.*.config.rate_limits[*] aigateway.RateLimit ALL +resources.model_provider_services.*.config.rate_limits[*].key aigateway.RateLimit_RateLimitKey ALL +resources.model_provider_services.*.config.rate_limits[*].principal *string ALL +resources.model_provider_services.*.config.rate_limits[*].renewal_period aigateway.RateLimit_RateLimitRenewalPeriod ALL +resources.model_provider_services.*.config.rate_limits[*].requests *int64 ALL +resources.model_provider_services.*.config.rate_limits[*].tokens *int64 ALL +resources.model_provider_services.*.config.targets []aigateway.ModelProviderServiceConfig_ModelTargetConfig ALL +resources.model_provider_services.*.config.targets[*] aigateway.ModelProviderServiceConfig_ModelTargetConfig ALL +resources.model_provider_services.*.config.targets[*].endpoint_route *string ALL +resources.model_provider_services.*.config.targets[*].model *string ALL resources.model_provider_services.*.config.targets[*].native_api_types []string ALL resources.model_provider_services.*.config.targets[*].native_api_types[*] string ALL resources.model_provider_services.*.id string INPUT @@ -2308,62 +2319,62 @@ resources.model_provider_services.*.parent string ALL resources.model_provider_services.*.url string INPUT resources.model_provider_services.*.grants.full_name string ALL resources.model_provider_services.*.grants.securable_type string ALL -resources.model_provider_services.*.grants[*] catalog.PrivilegeAssignment ALL -resources.model_provider_services.*.grants[*].principal string ALL -resources.model_provider_services.*.grants[*].privileges []catalog.Privilege ALL -resources.model_provider_services.*.grants[*].privileges[*] catalog.Privilege ALL +resources.model_provider_services.*.grants[*] grants.PrivilegeAssignment ALL +resources.model_provider_services.*.grants[*].principal *string ALL +resources.model_provider_services.*.grants[*].privileges []string ALL +resources.model_provider_services.*.grants[*].privileges[*] string ALL resources.model_services.*.comment string ALL -resources.model_services.*.config *catalog.ModelServiceConfig ALL -resources.model_services.*.config.inference_table *catalog.InferenceTableConfig ALL -resources.model_services.*.config.inference_table.is_deleted bool ALL -resources.model_services.*.config.inference_table.parent string ALL -resources.model_services.*.config.inference_table.table string ALL -resources.model_services.*.config.inference_table.table_name_prefix string ALL -resources.model_services.*.config.rate_limits []catalog.RateLimit ALL -resources.model_services.*.config.rate_limits[*] catalog.RateLimit ALL -resources.model_services.*.config.rate_limits[*].key catalog.RateLimitRateLimitKey ALL -resources.model_services.*.config.rate_limits[*].principal string ALL -resources.model_services.*.config.rate_limits[*].renewal_period catalog.RateLimitRateLimitRenewalPeriod ALL -resources.model_services.*.config.rate_limits[*].requests int64 ALL -resources.model_services.*.config.rate_limits[*].tokens int64 ALL -resources.model_services.*.config.routing *catalog.ModelServiceConfigRoutingConfig ALL -resources.model_services.*.config.routing.destinations []catalog.ModelServiceConfigDestinationConfig ALL -resources.model_services.*.config.routing.destinations[*] catalog.ModelServiceConfigDestinationConfig ALL -resources.model_services.*.config.routing.destinations[*].destination_type catalog.ModelServiceConfigDestinationConfigDestinationType ALL -resources.model_services.*.config.routing.destinations[*].external_model_config *catalog.ModelServiceConfigExternalModelConfig ALL -resources.model_services.*.config.routing.destinations[*].external_model_config.model_provider_service string ALL -resources.model_services.*.config.routing.destinations[*].external_model_config.target catalog.ModelProviderServiceConfigModelTargetConfig ALL -resources.model_services.*.config.routing.destinations[*].external_model_config.target.endpoint_route string ALL -resources.model_services.*.config.routing.destinations[*].external_model_config.target.model string ALL +resources.model_services.*.config *aigateway.ModelServiceConfig ALL +resources.model_services.*.config.inference_table *aigateway.InferenceTableConfig ALL +resources.model_services.*.config.inference_table.is_deleted *bool ALL +resources.model_services.*.config.inference_table.parent *string ALL +resources.model_services.*.config.inference_table.table *string ALL +resources.model_services.*.config.inference_table.table_name_prefix *string ALL +resources.model_services.*.config.rate_limits []aigateway.RateLimit ALL +resources.model_services.*.config.rate_limits[*] aigateway.RateLimit ALL +resources.model_services.*.config.rate_limits[*].key aigateway.RateLimit_RateLimitKey ALL +resources.model_services.*.config.rate_limits[*].principal *string ALL +resources.model_services.*.config.rate_limits[*].renewal_period aigateway.RateLimit_RateLimitRenewalPeriod ALL +resources.model_services.*.config.rate_limits[*].requests *int64 ALL +resources.model_services.*.config.rate_limits[*].tokens *int64 ALL +resources.model_services.*.config.routing *aigateway.ModelServiceConfig_RoutingConfig ALL +resources.model_services.*.config.routing.destinations []aigateway.ModelServiceConfig_DestinationConfig ALL +resources.model_services.*.config.routing.destinations[*] aigateway.ModelServiceConfig_DestinationConfig ALL +resources.model_services.*.config.routing.destinations[*].destination_type aigateway.ModelServiceConfig_DestinationConfig_DestinationType ALL +resources.model_services.*.config.routing.destinations[*].external_model_config *aigateway.ModelServiceConfig_ExternalModelConfig ALL +resources.model_services.*.config.routing.destinations[*].external_model_config.model_provider_service *string ALL +resources.model_services.*.config.routing.destinations[*].external_model_config.target *aigateway.ModelProviderServiceConfig_ModelTargetConfig ALL +resources.model_services.*.config.routing.destinations[*].external_model_config.target.endpoint_route *string ALL +resources.model_services.*.config.routing.destinations[*].external_model_config.target.model *string ALL resources.model_services.*.config.routing.destinations[*].external_model_config.target.native_api_types []string ALL resources.model_services.*.config.routing.destinations[*].external_model_config.target.native_api_types[*] string ALL -resources.model_services.*.config.routing.destinations[*].is_deleted bool ALL -resources.model_services.*.config.routing.destinations[*].name string ALL -resources.model_services.*.config.routing.destinations[*].pay_per_token_config *catalog.ModelServiceConfigPayPerTokenConfig ALL -resources.model_services.*.config.routing.destinations[*].pay_per_token_config.model string ALL -resources.model_services.*.config.routing.destinations[*].provisioned_throughput_config *catalog.ModelServiceConfigProvisionedThroughputConfig ALL -resources.model_services.*.config.routing.destinations[*].provisioned_throughput_config.model string ALL -resources.model_services.*.config.routing.destinations[*].provisioned_throughput_config.model_serving_endpoint string ALL -resources.model_services.*.config.routing.destinations[*].traffic_percentage int ALL -resources.model_services.*.config.routing.fallback *catalog.ModelServiceConfigFallbackConfig ALL -resources.model_services.*.config.routing.fallback.destinations []catalog.ModelServiceConfigDestinationConfig ALL -resources.model_services.*.config.routing.fallback.destinations[*] catalog.ModelServiceConfigDestinationConfig ALL -resources.model_services.*.config.routing.fallback.destinations[*].destination_type catalog.ModelServiceConfigDestinationConfigDestinationType ALL -resources.model_services.*.config.routing.fallback.destinations[*].external_model_config *catalog.ModelServiceConfigExternalModelConfig ALL -resources.model_services.*.config.routing.fallback.destinations[*].external_model_config.model_provider_service string ALL -resources.model_services.*.config.routing.fallback.destinations[*].external_model_config.target catalog.ModelProviderServiceConfigModelTargetConfig ALL -resources.model_services.*.config.routing.fallback.destinations[*].external_model_config.target.endpoint_route string ALL -resources.model_services.*.config.routing.fallback.destinations[*].external_model_config.target.model string ALL +resources.model_services.*.config.routing.destinations[*].is_deleted *bool ALL +resources.model_services.*.config.routing.destinations[*].name *string ALL +resources.model_services.*.config.routing.destinations[*].pay_per_token_config *aigateway.ModelServiceConfig_PayPerTokenConfig ALL +resources.model_services.*.config.routing.destinations[*].pay_per_token_config.model *string ALL +resources.model_services.*.config.routing.destinations[*].provisioned_throughput_config *aigateway.ModelServiceConfig_ProvisionedThroughputConfig ALL +resources.model_services.*.config.routing.destinations[*].provisioned_throughput_config.model *string ALL +resources.model_services.*.config.routing.destinations[*].provisioned_throughput_config.model_serving_endpoint *string ALL +resources.model_services.*.config.routing.destinations[*].traffic_percentage *int ALL +resources.model_services.*.config.routing.fallback *aigateway.ModelServiceConfig_FallbackConfig ALL +resources.model_services.*.config.routing.fallback.destinations []aigateway.ModelServiceConfig_DestinationConfig ALL +resources.model_services.*.config.routing.fallback.destinations[*] aigateway.ModelServiceConfig_DestinationConfig ALL +resources.model_services.*.config.routing.fallback.destinations[*].destination_type aigateway.ModelServiceConfig_DestinationConfig_DestinationType ALL +resources.model_services.*.config.routing.fallback.destinations[*].external_model_config *aigateway.ModelServiceConfig_ExternalModelConfig ALL +resources.model_services.*.config.routing.fallback.destinations[*].external_model_config.model_provider_service *string ALL +resources.model_services.*.config.routing.fallback.destinations[*].external_model_config.target *aigateway.ModelProviderServiceConfig_ModelTargetConfig ALL +resources.model_services.*.config.routing.fallback.destinations[*].external_model_config.target.endpoint_route *string ALL +resources.model_services.*.config.routing.fallback.destinations[*].external_model_config.target.model *string ALL resources.model_services.*.config.routing.fallback.destinations[*].external_model_config.target.native_api_types []string ALL resources.model_services.*.config.routing.fallback.destinations[*].external_model_config.target.native_api_types[*] string ALL -resources.model_services.*.config.routing.fallback.destinations[*].is_deleted bool ALL -resources.model_services.*.config.routing.fallback.destinations[*].name string ALL -resources.model_services.*.config.routing.fallback.destinations[*].pay_per_token_config *catalog.ModelServiceConfigPayPerTokenConfig ALL -resources.model_services.*.config.routing.fallback.destinations[*].pay_per_token_config.model string ALL -resources.model_services.*.config.routing.fallback.destinations[*].provisioned_throughput_config *catalog.ModelServiceConfigProvisionedThroughputConfig ALL -resources.model_services.*.config.routing.fallback.destinations[*].provisioned_throughput_config.model string ALL -resources.model_services.*.config.routing.fallback.destinations[*].provisioned_throughput_config.model_serving_endpoint string ALL -resources.model_services.*.config.routing.fallback.destinations[*].traffic_percentage int ALL +resources.model_services.*.config.routing.fallback.destinations[*].is_deleted *bool ALL +resources.model_services.*.config.routing.fallback.destinations[*].name *string ALL +resources.model_services.*.config.routing.fallback.destinations[*].pay_per_token_config *aigateway.ModelServiceConfig_PayPerTokenConfig ALL +resources.model_services.*.config.routing.fallback.destinations[*].pay_per_token_config.model *string ALL +resources.model_services.*.config.routing.fallback.destinations[*].provisioned_throughput_config *aigateway.ModelServiceConfig_ProvisionedThroughputConfig ALL +resources.model_services.*.config.routing.fallback.destinations[*].provisioned_throughput_config.model *string ALL +resources.model_services.*.config.routing.fallback.destinations[*].provisioned_throughput_config.model_serving_endpoint *string ALL +resources.model_services.*.config.routing.fallback.destinations[*].traffic_percentage *int ALL resources.model_services.*.id string INPUT resources.model_services.*.lifecycle resources.Lifecycle INPUT resources.model_services.*.lifecycle.prevent_destroy bool INPUT @@ -2373,632 +2384,819 @@ resources.model_services.*.parent string ALL resources.model_services.*.url string INPUT resources.model_services.*.grants.full_name string ALL resources.model_services.*.grants.securable_type string ALL -resources.model_services.*.grants[*] catalog.PrivilegeAssignment ALL -resources.model_services.*.grants[*].principal string ALL -resources.model_services.*.grants[*].privileges []catalog.Privilege ALL -resources.model_services.*.grants[*].privileges[*] catalog.Privilege ALL -resources.model_serving_endpoints.*.ai_gateway *serving.AiGatewayConfig ALL -resources.model_serving_endpoints.*.ai_gateway.fallback_config *serving.FallbackConfig ALL -resources.model_serving_endpoints.*.ai_gateway.fallback_config.enabled bool ALL -resources.model_serving_endpoints.*.ai_gateway.guardrails *serving.AiGatewayGuardrails ALL -resources.model_serving_endpoints.*.ai_gateway.guardrails.input *serving.AiGatewayGuardrailParameters ALL +resources.model_services.*.grants[*] grants.PrivilegeAssignment ALL +resources.model_services.*.grants[*].principal *string ALL +resources.model_services.*.grants[*].privileges []string ALL +resources.model_services.*.grants[*].privileges[*] string ALL +resources.model_serving_endpoints.*.ai_gateway *modelserving.AiGatewayConfig ALL +resources.model_serving_endpoints.*.ai_gateway.fallback_config *modelserving.FallbackConfig ALL +resources.model_serving_endpoints.*.ai_gateway.fallback_config.enabled *bool ALL +resources.model_serving_endpoints.*.ai_gateway.guardrails *modelserving.AiGuardrails ALL +resources.model_serving_endpoints.*.ai_gateway.guardrails.input *modelserving.AiGuardrailParameters ALL resources.model_serving_endpoints.*.ai_gateway.guardrails.input.invalid_keywords []string ALL resources.model_serving_endpoints.*.ai_gateway.guardrails.input.invalid_keywords[*] string ALL -resources.model_serving_endpoints.*.ai_gateway.guardrails.input.pii *serving.AiGatewayGuardrailPiiBehavior ALL -resources.model_serving_endpoints.*.ai_gateway.guardrails.input.pii.behavior serving.AiGatewayGuardrailPiiBehaviorBehavior ALL -resources.model_serving_endpoints.*.ai_gateway.guardrails.input.safety bool ALL +resources.model_serving_endpoints.*.ai_gateway.guardrails.input.pii *modelserving.PiiSettings ALL +resources.model_serving_endpoints.*.ai_gateway.guardrails.input.pii.behavior modelserving.Behavior ALL +resources.model_serving_endpoints.*.ai_gateway.guardrails.input.safety *bool ALL resources.model_serving_endpoints.*.ai_gateway.guardrails.input.valid_topics []string ALL resources.model_serving_endpoints.*.ai_gateway.guardrails.input.valid_topics[*] string ALL -resources.model_serving_endpoints.*.ai_gateway.guardrails.output *serving.AiGatewayGuardrailParameters ALL +resources.model_serving_endpoints.*.ai_gateway.guardrails.output *modelserving.AiGuardrailParameters ALL resources.model_serving_endpoints.*.ai_gateway.guardrails.output.invalid_keywords []string ALL resources.model_serving_endpoints.*.ai_gateway.guardrails.output.invalid_keywords[*] string ALL -resources.model_serving_endpoints.*.ai_gateway.guardrails.output.pii *serving.AiGatewayGuardrailPiiBehavior ALL -resources.model_serving_endpoints.*.ai_gateway.guardrails.output.pii.behavior serving.AiGatewayGuardrailPiiBehaviorBehavior ALL -resources.model_serving_endpoints.*.ai_gateway.guardrails.output.safety bool ALL +resources.model_serving_endpoints.*.ai_gateway.guardrails.output.pii *modelserving.PiiSettings ALL +resources.model_serving_endpoints.*.ai_gateway.guardrails.output.pii.behavior modelserving.Behavior ALL +resources.model_serving_endpoints.*.ai_gateway.guardrails.output.safety *bool ALL resources.model_serving_endpoints.*.ai_gateway.guardrails.output.valid_topics []string ALL resources.model_serving_endpoints.*.ai_gateway.guardrails.output.valid_topics[*] string ALL -resources.model_serving_endpoints.*.ai_gateway.inference_table_config *serving.AiGatewayInferenceTableConfig ALL -resources.model_serving_endpoints.*.ai_gateway.inference_table_config.catalog_name string ALL -resources.model_serving_endpoints.*.ai_gateway.inference_table_config.enabled bool ALL -resources.model_serving_endpoints.*.ai_gateway.inference_table_config.schema_name string ALL -resources.model_serving_endpoints.*.ai_gateway.inference_table_config.table_name_prefix string ALL -resources.model_serving_endpoints.*.ai_gateway.rate_limits []serving.AiGatewayRateLimit ALL -resources.model_serving_endpoints.*.ai_gateway.rate_limits[*] serving.AiGatewayRateLimit ALL -resources.model_serving_endpoints.*.ai_gateway.rate_limits[*].calls int64 ALL -resources.model_serving_endpoints.*.ai_gateway.rate_limits[*].key serving.AiGatewayRateLimitKey ALL -resources.model_serving_endpoints.*.ai_gateway.rate_limits[*].principal string ALL -resources.model_serving_endpoints.*.ai_gateway.rate_limits[*].renewal_period serving.AiGatewayRateLimitRenewalPeriod ALL -resources.model_serving_endpoints.*.ai_gateway.rate_limits[*].tokens int64 ALL -resources.model_serving_endpoints.*.ai_gateway.usage_tracking_config *serving.AiGatewayUsageTrackingConfig ALL -resources.model_serving_endpoints.*.ai_gateway.usage_tracking_config.enabled bool ALL -resources.model_serving_endpoints.*.budget_policy_id string ALL -resources.model_serving_endpoints.*.config *serving.EndpointCoreConfigInput ALL -resources.model_serving_endpoints.*.config.auto_capture_config *serving.AutoCaptureConfigInput ALL -resources.model_serving_endpoints.*.config.auto_capture_config.catalog_name string ALL -resources.model_serving_endpoints.*.config.auto_capture_config.enabled bool ALL -resources.model_serving_endpoints.*.config.auto_capture_config.schema_name string ALL -resources.model_serving_endpoints.*.config.auto_capture_config.table_name_prefix string ALL -resources.model_serving_endpoints.*.config.served_entities []serving.ServedEntityInput ALL -resources.model_serving_endpoints.*.config.served_entities[*] serving.ServedEntityInput ALL -resources.model_serving_endpoints.*.config.served_entities[*].burst_scaling_enabled bool ALL -resources.model_serving_endpoints.*.config.served_entities[*].entity_name string ALL -resources.model_serving_endpoints.*.config.served_entities[*].entity_version string ALL +resources.model_serving_endpoints.*.ai_gateway.inference_table_config *modelserving.InferenceTableConfig ALL +resources.model_serving_endpoints.*.ai_gateway.inference_table_config.catalog_name *string ALL +resources.model_serving_endpoints.*.ai_gateway.inference_table_config.enabled *bool ALL +resources.model_serving_endpoints.*.ai_gateway.inference_table_config.schema_name *string ALL +resources.model_serving_endpoints.*.ai_gateway.inference_table_config.table_name_prefix *string ALL +resources.model_serving_endpoints.*.ai_gateway.rate_limits []modelserving.AiGatewayRateLimit ALL +resources.model_serving_endpoints.*.ai_gateway.rate_limits[*] modelserving.AiGatewayRateLimit ALL +resources.model_serving_endpoints.*.ai_gateway.rate_limits[*].calls *int64 ALL +resources.model_serving_endpoints.*.ai_gateway.rate_limits[*].key *string ALL +resources.model_serving_endpoints.*.ai_gateway.rate_limits[*].principal *string ALL +resources.model_serving_endpoints.*.ai_gateway.rate_limits[*].renewal_period *string ALL +resources.model_serving_endpoints.*.ai_gateway.rate_limits[*].tokens *int64 ALL +resources.model_serving_endpoints.*.ai_gateway.usage_tracking_config *modelserving.UsageTrackingConfig ALL +resources.model_serving_endpoints.*.ai_gateway.usage_tracking_config.enabled *bool ALL +resources.model_serving_endpoints.*.budget_policy_id *string ALL +resources.model_serving_endpoints.*.config *modelserving.EndpointCoreConfig ALL +resources.model_serving_endpoints.*.config.auto_capture_config *modelserving.AutoCaptureConfig ALL +resources.model_serving_endpoints.*.config.auto_capture_config.catalog_name *string ALL +resources.model_serving_endpoints.*.config.auto_capture_config.enabled *bool ALL +resources.model_serving_endpoints.*.config.auto_capture_config.schema_name *string ALL +resources.model_serving_endpoints.*.config.auto_capture_config.state *modelserving.AutoCaptureState ALL +resources.model_serving_endpoints.*.config.auto_capture_config.state.payload_table *modelserving.PayloadTable ALL +resources.model_serving_endpoints.*.config.auto_capture_config.state.payload_table.name *string ALL +resources.model_serving_endpoints.*.config.auto_capture_config.state.payload_table.status *string ALL +resources.model_serving_endpoints.*.config.auto_capture_config.state.payload_table.status_message *string ALL +resources.model_serving_endpoints.*.config.auto_capture_config.table_name_prefix *string ALL +resources.model_serving_endpoints.*.config.served_entities []modelserving.ServedModel ALL +resources.model_serving_endpoints.*.config.served_entities[*] modelserving.ServedModel ALL +resources.model_serving_endpoints.*.config.served_entities[*].burst_scaling_enabled *bool ALL +resources.model_serving_endpoints.*.config.served_entities[*].creation_timestamp *int64 ALL +resources.model_serving_endpoints.*.config.served_entities[*].creator *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].entity_name *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].entity_version *string ALL resources.model_serving_endpoints.*.config.served_entities[*].environment_vars map[string]string ALL resources.model_serving_endpoints.*.config.served_entities[*].environment_vars.* string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model *serving.ExternalModel ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.ai21labs_config *serving.Ai21LabsConfig ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.ai21labs_config.ai21labs_api_key string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.ai21labs_config.ai21labs_api_key_plaintext string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config *serving.AmazonBedrockConfig ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.aws_access_key_id string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.aws_access_key_id_plaintext string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.aws_region string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.aws_secret_access_key string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.aws_secret_access_key_plaintext string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.bedrock_provider serving.AmazonBedrockConfigBedrockProvider ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.instance_profile_arn string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.uc_service_credential_name string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.anthropic_config *serving.AnthropicConfig ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.anthropic_config.anthropic_api_key string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.anthropic_config.anthropic_api_key_plaintext string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.cohere_config *serving.CohereConfig ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.cohere_config.cohere_api_base string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.cohere_config.cohere_api_key string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.cohere_config.cohere_api_key_plaintext string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config *serving.CustomProviderConfig ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.api_key_auth *serving.ApiKeyAuth ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.api_key_auth.key string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.api_key_auth.value string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.api_key_auth.value_plaintext string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.bearer_token_auth *serving.BearerTokenAuth ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.bearer_token_auth.token string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.bearer_token_auth.token_plaintext string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.custom_provider_url string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.databricks_model_serving_config *serving.DatabricksModelServingConfig ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.databricks_model_serving_config.databricks_api_token string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.databricks_model_serving_config.databricks_api_token_plaintext string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.databricks_model_serving_config.databricks_workspace_url string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.google_cloud_vertex_ai_config *serving.GoogleCloudVertexAiConfig ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.google_cloud_vertex_ai_config.private_key string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.google_cloud_vertex_ai_config.private_key_plaintext string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.google_cloud_vertex_ai_config.project_id string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.google_cloud_vertex_ai_config.region string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.name string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config *serving.OpenAiConfig ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.microsoft_entra_client_id string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.microsoft_entra_client_secret string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.microsoft_entra_client_secret_plaintext string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.microsoft_entra_tenant_id string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_api_base string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_api_key string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_api_key_plaintext string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_api_type string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_api_version string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_deployment_name string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_organization string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.palm_config *serving.PaLmConfig ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.palm_config.palm_api_key string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.palm_config.palm_api_key_plaintext string ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.provider serving.ExternalModelProvider ALL -resources.model_serving_endpoints.*.config.served_entities[*].external_model.task string ALL -resources.model_serving_endpoints.*.config.served_entities[*].instance_profile_arn string ALL -resources.model_serving_endpoints.*.config.served_entities[*].max_provisioned_concurrency int ALL -resources.model_serving_endpoints.*.config.served_entities[*].max_provisioned_throughput int ALL -resources.model_serving_endpoints.*.config.served_entities[*].min_provisioned_concurrency int ALL -resources.model_serving_endpoints.*.config.served_entities[*].min_provisioned_throughput int ALL -resources.model_serving_endpoints.*.config.served_entities[*].name string ALL -resources.model_serving_endpoints.*.config.served_entities[*].provisioned_model_units int64 ALL -resources.model_serving_endpoints.*.config.served_entities[*].scale_to_zero_enabled bool ALL -resources.model_serving_endpoints.*.config.served_entities[*].workload_size string ALL -resources.model_serving_endpoints.*.config.served_entities[*].workload_type serving.ServingModelWorkloadType ALL -resources.model_serving_endpoints.*.config.served_models []serving.ServedModelInput ALL -resources.model_serving_endpoints.*.config.served_models[*] serving.ServedModelInput ALL -resources.model_serving_endpoints.*.config.served_models[*].burst_scaling_enabled bool ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model *modelserving.ExternalModel ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.ai21labs_config *modelserving.Ai21LabsConfig ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.ai21labs_config.ai21labs_api_key *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.ai21labs_config.ai21labs_api_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config *modelserving.AmazonBedrockConfig ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.aws_access_key_id *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.aws_access_key_id_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.aws_region *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.aws_secret_access_key *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.aws_secret_access_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.bedrock_provider *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.instance_profile_arn *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.uc_service_credential_name *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.anthropic_config *modelserving.AnthropicConfig ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.anthropic_config.anthropic_api_key *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.anthropic_config.anthropic_api_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.cohere_config *modelserving.CohereConfig ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.cohere_config.cohere_api_base *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.cohere_config.cohere_api_key *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.cohere_config.cohere_api_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config *modelserving.CustomProviderConfig ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.api_key_auth *modelserving.ApiKeyAuth ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.api_key_auth.key *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.api_key_auth.value *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.api_key_auth.value_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.bearer_token_auth *modelserving.BearerTokenAuth ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.bearer_token_auth.token *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.bearer_token_auth.token_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.custom_provider_config.custom_provider_url *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.databricks_model_serving_config *modelserving.DatabricksModelServingConfig ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.databricks_model_serving_config.databricks_api_token *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.databricks_model_serving_config.databricks_api_token_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.databricks_model_serving_config.databricks_workspace_url *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.google_cloud_vertex_ai_config *modelserving.GoogleCloudVertexAiConfig ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.google_cloud_vertex_ai_config.private_key *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.google_cloud_vertex_ai_config.private_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.google_cloud_vertex_ai_config.project_id *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.google_cloud_vertex_ai_config.region *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.name *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config *modelserving.OpenAiConfig ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.microsoft_entra_client_id *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.microsoft_entra_client_secret *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.microsoft_entra_client_secret_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.microsoft_entra_tenant_id *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_api_base *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_api_key *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_api_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_api_type *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_api_version *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_deployment_name *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.openai_config.openai_organization *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.palm_config *modelserving.PaLmConfig ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.palm_config.palm_api_key *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.palm_config.palm_api_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.provider *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].external_model.task *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].foundation_model *modelserving.FoundationModel ALL +resources.model_serving_endpoints.*.config.served_entities[*].foundation_model.description *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].foundation_model.display_name *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].foundation_model.docs *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].foundation_model.name *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].instance_profile_arn *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].max_provisioned_concurrency *int ALL +resources.model_serving_endpoints.*.config.served_entities[*].max_provisioned_throughput *int ALL +resources.model_serving_endpoints.*.config.served_entities[*].min_provisioned_concurrency *int ALL +resources.model_serving_endpoints.*.config.served_entities[*].min_provisioned_throughput *int ALL +resources.model_serving_endpoints.*.config.served_entities[*].model_name *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].model_version *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].name *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].provisioned_model_units *int64 ALL +resources.model_serving_endpoints.*.config.served_entities[*].scale_to_zero_enabled *bool ALL +resources.model_serving_endpoints.*.config.served_entities[*].state *modelserving.ServedModelState ALL +resources.model_serving_endpoints.*.config.served_entities[*].state.deployment modelserving.ServedModelDeploymentState ALL +resources.model_serving_endpoints.*.config.served_entities[*].state.deployment_state_message *string ALL +resources.model_serving_endpoints.*.config.served_entities[*].workload_size *string ALL +resources.model_serving_endpoints.*.config.served_models []modelserving.ServedModel ALL +resources.model_serving_endpoints.*.config.served_models[*] modelserving.ServedModel ALL +resources.model_serving_endpoints.*.config.served_models[*].burst_scaling_enabled *bool ALL +resources.model_serving_endpoints.*.config.served_models[*].creation_timestamp *int64 ALL +resources.model_serving_endpoints.*.config.served_models[*].creator *string ALL +resources.model_serving_endpoints.*.config.served_models[*].entity_name *string ALL +resources.model_serving_endpoints.*.config.served_models[*].entity_version *string ALL resources.model_serving_endpoints.*.config.served_models[*].environment_vars map[string]string ALL resources.model_serving_endpoints.*.config.served_models[*].environment_vars.* string ALL -resources.model_serving_endpoints.*.config.served_models[*].instance_profile_arn string ALL -resources.model_serving_endpoints.*.config.served_models[*].max_provisioned_concurrency int ALL -resources.model_serving_endpoints.*.config.served_models[*].max_provisioned_throughput int ALL -resources.model_serving_endpoints.*.config.served_models[*].min_provisioned_concurrency int ALL -resources.model_serving_endpoints.*.config.served_models[*].min_provisioned_throughput int ALL -resources.model_serving_endpoints.*.config.served_models[*].model_name string ALL -resources.model_serving_endpoints.*.config.served_models[*].model_version string ALL -resources.model_serving_endpoints.*.config.served_models[*].name string ALL -resources.model_serving_endpoints.*.config.served_models[*].provisioned_model_units int64 ALL -resources.model_serving_endpoints.*.config.served_models[*].scale_to_zero_enabled bool ALL -resources.model_serving_endpoints.*.config.served_models[*].workload_size string ALL -resources.model_serving_endpoints.*.config.served_models[*].workload_type serving.ServedModelInputWorkloadType ALL -resources.model_serving_endpoints.*.config.traffic_config *serving.TrafficConfig ALL -resources.model_serving_endpoints.*.config.traffic_config.routes []serving.Route ALL -resources.model_serving_endpoints.*.config.traffic_config.routes[*] serving.Route ALL -resources.model_serving_endpoints.*.config.traffic_config.routes[*].served_entity_name string ALL -resources.model_serving_endpoints.*.config.traffic_config.routes[*].served_model_name string ALL -resources.model_serving_endpoints.*.config.traffic_config.routes[*].traffic_percentage int ALL -resources.model_serving_endpoints.*.description string ALL -resources.model_serving_endpoints.*.email_notifications *serving.EmailNotifications ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model *modelserving.ExternalModel ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.ai21labs_config *modelserving.Ai21LabsConfig ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.ai21labs_config.ai21labs_api_key *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.ai21labs_config.ai21labs_api_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.amazon_bedrock_config *modelserving.AmazonBedrockConfig ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.amazon_bedrock_config.aws_access_key_id *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.amazon_bedrock_config.aws_access_key_id_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.amazon_bedrock_config.aws_region *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.amazon_bedrock_config.aws_secret_access_key *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.amazon_bedrock_config.aws_secret_access_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.amazon_bedrock_config.bedrock_provider *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.amazon_bedrock_config.instance_profile_arn *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.amazon_bedrock_config.uc_service_credential_name *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.anthropic_config *modelserving.AnthropicConfig ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.anthropic_config.anthropic_api_key *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.anthropic_config.anthropic_api_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.cohere_config *modelserving.CohereConfig ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.cohere_config.cohere_api_base *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.cohere_config.cohere_api_key *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.cohere_config.cohere_api_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.custom_provider_config *modelserving.CustomProviderConfig ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.custom_provider_config.api_key_auth *modelserving.ApiKeyAuth ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.custom_provider_config.api_key_auth.key *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.custom_provider_config.api_key_auth.value *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.custom_provider_config.api_key_auth.value_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.custom_provider_config.bearer_token_auth *modelserving.BearerTokenAuth ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.custom_provider_config.bearer_token_auth.token *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.custom_provider_config.bearer_token_auth.token_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.custom_provider_config.custom_provider_url *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.databricks_model_serving_config *modelserving.DatabricksModelServingConfig ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.databricks_model_serving_config.databricks_api_token *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.databricks_model_serving_config.databricks_api_token_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.databricks_model_serving_config.databricks_workspace_url *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.google_cloud_vertex_ai_config *modelserving.GoogleCloudVertexAiConfig ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.google_cloud_vertex_ai_config.private_key *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.google_cloud_vertex_ai_config.private_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.google_cloud_vertex_ai_config.project_id *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.google_cloud_vertex_ai_config.region *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.name *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.openai_config *modelserving.OpenAiConfig ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.openai_config.microsoft_entra_client_id *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.openai_config.microsoft_entra_client_secret *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.openai_config.microsoft_entra_client_secret_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.openai_config.microsoft_entra_tenant_id *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.openai_config.openai_api_base *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.openai_config.openai_api_key *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.openai_config.openai_api_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.openai_config.openai_api_type *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.openai_config.openai_api_version *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.openai_config.openai_deployment_name *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.openai_config.openai_organization *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.palm_config *modelserving.PaLmConfig ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.palm_config.palm_api_key *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.palm_config.palm_api_key_plaintext *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.provider *string ALL +resources.model_serving_endpoints.*.config.served_models[*].external_model.task *string ALL +resources.model_serving_endpoints.*.config.served_models[*].foundation_model *modelserving.FoundationModel ALL +resources.model_serving_endpoints.*.config.served_models[*].foundation_model.description *string ALL +resources.model_serving_endpoints.*.config.served_models[*].foundation_model.display_name *string ALL +resources.model_serving_endpoints.*.config.served_models[*].foundation_model.docs *string ALL +resources.model_serving_endpoints.*.config.served_models[*].foundation_model.name *string ALL +resources.model_serving_endpoints.*.config.served_models[*].instance_profile_arn *string ALL +resources.model_serving_endpoints.*.config.served_models[*].max_provisioned_concurrency *int ALL +resources.model_serving_endpoints.*.config.served_models[*].max_provisioned_throughput *int ALL +resources.model_serving_endpoints.*.config.served_models[*].min_provisioned_concurrency *int ALL +resources.model_serving_endpoints.*.config.served_models[*].min_provisioned_throughput *int ALL +resources.model_serving_endpoints.*.config.served_models[*].model_name *string ALL +resources.model_serving_endpoints.*.config.served_models[*].model_version *string ALL +resources.model_serving_endpoints.*.config.served_models[*].name *string ALL +resources.model_serving_endpoints.*.config.served_models[*].provisioned_model_units *int64 ALL +resources.model_serving_endpoints.*.config.served_models[*].scale_to_zero_enabled *bool ALL +resources.model_serving_endpoints.*.config.served_models[*].state *modelserving.ServedModelState ALL +resources.model_serving_endpoints.*.config.served_models[*].state.deployment modelserving.ServedModelDeploymentState ALL +resources.model_serving_endpoints.*.config.served_models[*].state.deployment_state_message *string ALL +resources.model_serving_endpoints.*.config.served_models[*].workload_size *string ALL +resources.model_serving_endpoints.*.config.traffic_config *modelserving.TrafficConfig ALL +resources.model_serving_endpoints.*.config.traffic_config.routes []modelserving.Route ALL +resources.model_serving_endpoints.*.config.traffic_config.routes[*] modelserving.Route ALL +resources.model_serving_endpoints.*.config.traffic_config.routes[*].served_entity_name *string ALL +resources.model_serving_endpoints.*.config.traffic_config.routes[*].served_model_name *string ALL +resources.model_serving_endpoints.*.config.traffic_config.routes[*].traffic_percentage *int ALL +resources.model_serving_endpoints.*.description *string ALL +resources.model_serving_endpoints.*.email_notifications *modelserving.EmailNotifications ALL resources.model_serving_endpoints.*.email_notifications.on_update_failure []string ALL resources.model_serving_endpoints.*.email_notifications.on_update_failure[*] string ALL resources.model_serving_endpoints.*.email_notifications.on_update_success []string ALL resources.model_serving_endpoints.*.email_notifications.on_update_success[*] string ALL -resources.model_serving_endpoints.*.endpoint_details *serving.ServingEndpointDetailed REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway *serving.AiGatewayConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.fallback_config *serving.FallbackConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.fallback_config.enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails *serving.AiGatewayGuardrails REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.input *serving.AiGatewayGuardrailParameters REMOTE +resources.model_serving_endpoints.*.endpoint_details *modelserving.InferenceEndpointDetailed REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway *modelserving.AiGatewayConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.fallback_config *modelserving.FallbackConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.fallback_config.enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails *modelserving.AiGuardrails REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.input *modelserving.AiGuardrailParameters REMOTE resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.input.invalid_keywords []string REMOTE resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.input.invalid_keywords[*] string REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.input.pii *serving.AiGatewayGuardrailPiiBehavior REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.input.pii.behavior serving.AiGatewayGuardrailPiiBehaviorBehavior REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.input.safety bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.input.pii *modelserving.PiiSettings REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.input.pii.behavior modelserving.Behavior REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.input.safety *bool REMOTE resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.input.valid_topics []string REMOTE resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.input.valid_topics[*] string REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.output *serving.AiGatewayGuardrailParameters REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.output *modelserving.AiGuardrailParameters REMOTE resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.output.invalid_keywords []string REMOTE resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.output.invalid_keywords[*] string REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.output.pii *serving.AiGatewayGuardrailPiiBehavior REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.output.pii.behavior serving.AiGatewayGuardrailPiiBehaviorBehavior REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.output.safety bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.output.pii *modelserving.PiiSettings REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.output.pii.behavior modelserving.Behavior REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.output.safety *bool REMOTE resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.output.valid_topics []string REMOTE resources.model_serving_endpoints.*.endpoint_details.ai_gateway.guardrails.output.valid_topics[*] string REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.inference_table_config *serving.AiGatewayInferenceTableConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.inference_table_config.catalog_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.inference_table_config.enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.inference_table_config.schema_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.inference_table_config.table_name_prefix string REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits []serving.AiGatewayRateLimit REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits[*] serving.AiGatewayRateLimit REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits[*].calls int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits[*].key serving.AiGatewayRateLimitKey REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits[*].principal string REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits[*].renewal_period serving.AiGatewayRateLimitRenewalPeriod REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits[*].tokens int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.usage_tracking_config *serving.AiGatewayUsageTrackingConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.ai_gateway.usage_tracking_config.enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.budget_policy_id string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config *serving.EndpointCoreConfigOutput REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config *serving.AutoCaptureConfigOutput REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.catalog_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.schema_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.state *serving.AutoCaptureState REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.state.payload_table *serving.PayloadTable REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.state.payload_table.name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.state.payload_table.status string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.state.payload_table.status_message string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.table_name_prefix string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.config_version int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities []serving.ServedEntityOutput REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*] serving.ServedEntityOutput REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].burst_scaling_enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].creation_timestamp int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].creator string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].entity_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].entity_version string REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.inference_table_config *modelserving.InferenceTableConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.inference_table_config.catalog_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.inference_table_config.enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.inference_table_config.schema_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.inference_table_config.table_name_prefix *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits []modelserving.AiGatewayRateLimit REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits[*] modelserving.AiGatewayRateLimit REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits[*].calls *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits[*].key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits[*].principal *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits[*].renewal_period *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.rate_limits[*].tokens *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.usage_tracking_config *modelserving.UsageTrackingConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.ai_gateway.usage_tracking_config.enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.budget_policy_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config *modelserving.EndpointCoreConfigOutput REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config *modelserving.AutoCaptureConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.catalog_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.schema_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.state *modelserving.AutoCaptureState REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.state.payload_table *modelserving.PayloadTable REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.state.payload_table.name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.state.payload_table.status *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.state.payload_table.status_message *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.auto_capture_config.table_name_prefix *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.config_version *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities []modelserving.ServedModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*] modelserving.ServedModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].burst_scaling_enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].creation_timestamp *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].creator *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].entity_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].entity_version *string REMOTE resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].environment_vars map[string]string REMOTE resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].environment_vars.* string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model *serving.ExternalModel REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.ai21labs_config *serving.Ai21LabsConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.ai21labs_config.ai21labs_api_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.ai21labs_config.ai21labs_api_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config *serving.AmazonBedrockConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.aws_access_key_id string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.aws_access_key_id_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.aws_region string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.aws_secret_access_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.aws_secret_access_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.bedrock_provider serving.AmazonBedrockConfigBedrockProvider REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.instance_profile_arn string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.uc_service_credential_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.anthropic_config *serving.AnthropicConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.anthropic_config.anthropic_api_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.anthropic_config.anthropic_api_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.cohere_config *serving.CohereConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.cohere_config.cohere_api_base string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.cohere_config.cohere_api_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.cohere_config.cohere_api_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config *serving.CustomProviderConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.api_key_auth *serving.ApiKeyAuth REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.api_key_auth.key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.api_key_auth.value string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.api_key_auth.value_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.bearer_token_auth *serving.BearerTokenAuth REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.bearer_token_auth.token string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.bearer_token_auth.token_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.custom_provider_url string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.databricks_model_serving_config *serving.DatabricksModelServingConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.databricks_model_serving_config.databricks_api_token string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.databricks_model_serving_config.databricks_api_token_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.databricks_model_serving_config.databricks_workspace_url string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.google_cloud_vertex_ai_config *serving.GoogleCloudVertexAiConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.google_cloud_vertex_ai_config.private_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.google_cloud_vertex_ai_config.private_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.google_cloud_vertex_ai_config.project_id string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.google_cloud_vertex_ai_config.region string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config *serving.OpenAiConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.microsoft_entra_client_id string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.microsoft_entra_client_secret string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.microsoft_entra_client_secret_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.microsoft_entra_tenant_id string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_api_base string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_api_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_api_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_api_type string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_api_version string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_deployment_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_organization string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.palm_config *serving.PaLmConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.palm_config.palm_api_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.palm_config.palm_api_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.provider serving.ExternalModelProvider REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.task string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].foundation_model *serving.FoundationModel REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].foundation_model.description string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].foundation_model.display_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].foundation_model.docs string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].foundation_model.name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].instance_profile_arn string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].max_provisioned_concurrency int REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].max_provisioned_throughput int REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].min_provisioned_concurrency int REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].min_provisioned_throughput int REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].provisioned_model_units int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].scale_to_zero_enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].state *serving.ServedModelState REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].state.deployment serving.ServedModelStateDeployment REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].state.deployment_state_message string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].workload_size string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].workload_type serving.ServingModelWorkloadType REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models []serving.ServedModelOutput REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*] serving.ServedModelOutput REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].burst_scaling_enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].creation_timestamp int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].creator string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model *modelserving.ExternalModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.ai21labs_config *modelserving.Ai21LabsConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.ai21labs_config.ai21labs_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.ai21labs_config.ai21labs_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config *modelserving.AmazonBedrockConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.aws_access_key_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.aws_access_key_id_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.aws_region *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.aws_secret_access_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.aws_secret_access_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.bedrock_provider *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.instance_profile_arn *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.amazon_bedrock_config.uc_service_credential_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.anthropic_config *modelserving.AnthropicConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.anthropic_config.anthropic_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.anthropic_config.anthropic_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.cohere_config *modelserving.CohereConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.cohere_config.cohere_api_base *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.cohere_config.cohere_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.cohere_config.cohere_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config *modelserving.CustomProviderConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.api_key_auth *modelserving.ApiKeyAuth REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.api_key_auth.key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.api_key_auth.value *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.api_key_auth.value_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.bearer_token_auth *modelserving.BearerTokenAuth REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.bearer_token_auth.token *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.bearer_token_auth.token_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.custom_provider_config.custom_provider_url *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.databricks_model_serving_config *modelserving.DatabricksModelServingConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.databricks_model_serving_config.databricks_api_token *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.databricks_model_serving_config.databricks_api_token_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.databricks_model_serving_config.databricks_workspace_url *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.google_cloud_vertex_ai_config *modelserving.GoogleCloudVertexAiConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.google_cloud_vertex_ai_config.private_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.google_cloud_vertex_ai_config.private_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.google_cloud_vertex_ai_config.project_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.google_cloud_vertex_ai_config.region *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config *modelserving.OpenAiConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.microsoft_entra_client_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.microsoft_entra_client_secret *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.microsoft_entra_client_secret_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.microsoft_entra_tenant_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_api_base *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_api_type *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_api_version *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_deployment_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.openai_config.openai_organization *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.palm_config *modelserving.PaLmConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.palm_config.palm_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.palm_config.palm_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.provider *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].external_model.task *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].foundation_model *modelserving.FoundationModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].foundation_model.description *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].foundation_model.display_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].foundation_model.docs *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].foundation_model.name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].instance_profile_arn *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].max_provisioned_concurrency *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].max_provisioned_throughput *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].min_provisioned_concurrency *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].min_provisioned_throughput *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].model_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].model_version *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].provisioned_model_units *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].scale_to_zero_enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].state *modelserving.ServedModelState REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].state.deployment modelserving.ServedModelDeploymentState REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].state.deployment_state_message *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_entities[*].workload_size *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models []modelserving.ServedModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*] modelserving.ServedModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].burst_scaling_enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].creation_timestamp *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].creator *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].entity_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].entity_version *string REMOTE resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].environment_vars map[string]string REMOTE resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].environment_vars.* string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].instance_profile_arn string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].max_provisioned_concurrency int REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].min_provisioned_concurrency int REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].model_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].model_version string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].provisioned_model_units int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].scale_to_zero_enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].state *serving.ServedModelState REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].state.deployment serving.ServedModelStateDeployment REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].state.deployment_state_message string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].workload_size string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].workload_type serving.ServingModelWorkloadType REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.traffic_config *serving.TrafficConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.traffic_config.routes []serving.Route REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.traffic_config.routes[*] serving.Route REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.traffic_config.routes[*].served_entity_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.traffic_config.routes[*].served_model_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.config.traffic_config.routes[*].traffic_percentage int REMOTE -resources.model_serving_endpoints.*.endpoint_details.creation_timestamp int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.creator string REMOTE -resources.model_serving_endpoints.*.endpoint_details.data_plane_info *serving.ModelDataPlaneInfo REMOTE -resources.model_serving_endpoints.*.endpoint_details.data_plane_info.query_info *serving.DataPlaneInfo REMOTE -resources.model_serving_endpoints.*.endpoint_details.data_plane_info.query_info.authorization_details string REMOTE -resources.model_serving_endpoints.*.endpoint_details.data_plane_info.query_info.endpoint_url string REMOTE -resources.model_serving_endpoints.*.endpoint_details.description string REMOTE -resources.model_serving_endpoints.*.endpoint_details.email_notifications *serving.EmailNotifications REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model *modelserving.ExternalModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.ai21labs_config *modelserving.Ai21LabsConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.ai21labs_config.ai21labs_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.ai21labs_config.ai21labs_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.amazon_bedrock_config *modelserving.AmazonBedrockConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.amazon_bedrock_config.aws_access_key_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.amazon_bedrock_config.aws_access_key_id_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.amazon_bedrock_config.aws_region *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.amazon_bedrock_config.aws_secret_access_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.amazon_bedrock_config.aws_secret_access_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.amazon_bedrock_config.bedrock_provider *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.amazon_bedrock_config.instance_profile_arn *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.amazon_bedrock_config.uc_service_credential_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.anthropic_config *modelserving.AnthropicConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.anthropic_config.anthropic_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.anthropic_config.anthropic_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.cohere_config *modelserving.CohereConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.cohere_config.cohere_api_base *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.cohere_config.cohere_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.cohere_config.cohere_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.custom_provider_config *modelserving.CustomProviderConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.custom_provider_config.api_key_auth *modelserving.ApiKeyAuth REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.custom_provider_config.api_key_auth.key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.custom_provider_config.api_key_auth.value *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.custom_provider_config.api_key_auth.value_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.custom_provider_config.bearer_token_auth *modelserving.BearerTokenAuth REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.custom_provider_config.bearer_token_auth.token *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.custom_provider_config.bearer_token_auth.token_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.custom_provider_config.custom_provider_url *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.databricks_model_serving_config *modelserving.DatabricksModelServingConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.databricks_model_serving_config.databricks_api_token *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.databricks_model_serving_config.databricks_api_token_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.databricks_model_serving_config.databricks_workspace_url *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.google_cloud_vertex_ai_config *modelserving.GoogleCloudVertexAiConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.google_cloud_vertex_ai_config.private_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.google_cloud_vertex_ai_config.private_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.google_cloud_vertex_ai_config.project_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.google_cloud_vertex_ai_config.region *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.openai_config *modelserving.OpenAiConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.openai_config.microsoft_entra_client_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.openai_config.microsoft_entra_client_secret *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.openai_config.microsoft_entra_client_secret_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.openai_config.microsoft_entra_tenant_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.openai_config.openai_api_base *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.openai_config.openai_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.openai_config.openai_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.openai_config.openai_api_type *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.openai_config.openai_api_version *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.openai_config.openai_deployment_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.openai_config.openai_organization *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.palm_config *modelserving.PaLmConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.palm_config.palm_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.palm_config.palm_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.provider *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].external_model.task *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].foundation_model *modelserving.FoundationModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].foundation_model.description *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].foundation_model.display_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].foundation_model.docs *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].foundation_model.name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].instance_profile_arn *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].max_provisioned_concurrency *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].max_provisioned_throughput *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].min_provisioned_concurrency *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].min_provisioned_throughput *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].model_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].model_version *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].provisioned_model_units *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].scale_to_zero_enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].state *modelserving.ServedModelState REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].state.deployment modelserving.ServedModelDeploymentState REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].state.deployment_state_message *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.served_models[*].workload_size *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.traffic_config *modelserving.TrafficConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.traffic_config.routes []modelserving.Route REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.traffic_config.routes[*] modelserving.Route REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.traffic_config.routes[*].served_entity_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.traffic_config.routes[*].served_model_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.config.traffic_config.routes[*].traffic_percentage *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.creation_timestamp *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.creator *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.data_plane_info *modelserving.ModelDataPlaneInfo REMOTE +resources.model_serving_endpoints.*.endpoint_details.data_plane_info.query_info *modelserving.DataPlaneInfo REMOTE +resources.model_serving_endpoints.*.endpoint_details.data_plane_info.query_info.authorization_details *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.data_plane_info.query_info.endpoint_url *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.description *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.email_notifications *modelserving.EmailNotifications REMOTE resources.model_serving_endpoints.*.endpoint_details.email_notifications.on_update_failure []string REMOTE resources.model_serving_endpoints.*.endpoint_details.email_notifications.on_update_failure[*] string REMOTE resources.model_serving_endpoints.*.endpoint_details.email_notifications.on_update_success []string REMOTE resources.model_serving_endpoints.*.endpoint_details.email_notifications.on_update_success[*] string REMOTE -resources.model_serving_endpoints.*.endpoint_details.endpoint_url string REMOTE -resources.model_serving_endpoints.*.endpoint_details.id string REMOTE -resources.model_serving_endpoints.*.endpoint_details.last_updated_timestamp int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config *serving.EndpointPendingConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config *serving.AutoCaptureConfigOutput REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.catalog_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.schema_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.state *serving.AutoCaptureState REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.state.payload_table *serving.PayloadTable REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.state.payload_table.name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.state.payload_table.status string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.state.payload_table.status_message string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.table_name_prefix string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.config_version int REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities []serving.ServedEntityOutput REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*] serving.ServedEntityOutput REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].burst_scaling_enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].creation_timestamp int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].creator string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].entity_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].entity_version string REMOTE +resources.model_serving_endpoints.*.endpoint_details.endpoint_url *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.last_updated_timestamp *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config *modelserving.PendingConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config *modelserving.AutoCaptureConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.catalog_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.schema_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.state *modelserving.AutoCaptureState REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.state.payload_table *modelserving.PayloadTable REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.state.payload_table.name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.state.payload_table.status *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.state.payload_table.status_message *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.auto_capture_config.table_name_prefix *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.config_version *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities []modelserving.ServedModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*] modelserving.ServedModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].burst_scaling_enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].creation_timestamp *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].creator *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].entity_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].entity_version *string REMOTE resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].environment_vars map[string]string REMOTE resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].environment_vars.* string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model *serving.ExternalModel REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.ai21labs_config *serving.Ai21LabsConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.ai21labs_config.ai21labs_api_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.ai21labs_config.ai21labs_api_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config *serving.AmazonBedrockConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.aws_access_key_id string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.aws_access_key_id_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.aws_region string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.aws_secret_access_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.aws_secret_access_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.bedrock_provider serving.AmazonBedrockConfigBedrockProvider REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.instance_profile_arn string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.uc_service_credential_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.anthropic_config *serving.AnthropicConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.anthropic_config.anthropic_api_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.anthropic_config.anthropic_api_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.cohere_config *serving.CohereConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.cohere_config.cohere_api_base string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.cohere_config.cohere_api_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.cohere_config.cohere_api_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config *serving.CustomProviderConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.api_key_auth *serving.ApiKeyAuth REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.api_key_auth.key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.api_key_auth.value string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.api_key_auth.value_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.bearer_token_auth *serving.BearerTokenAuth REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.bearer_token_auth.token string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.bearer_token_auth.token_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.custom_provider_url string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.databricks_model_serving_config *serving.DatabricksModelServingConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.databricks_model_serving_config.databricks_api_token string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.databricks_model_serving_config.databricks_api_token_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.databricks_model_serving_config.databricks_workspace_url string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.google_cloud_vertex_ai_config *serving.GoogleCloudVertexAiConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.google_cloud_vertex_ai_config.private_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.google_cloud_vertex_ai_config.private_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.google_cloud_vertex_ai_config.project_id string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.google_cloud_vertex_ai_config.region string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config *serving.OpenAiConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.microsoft_entra_client_id string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.microsoft_entra_client_secret string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.microsoft_entra_client_secret_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.microsoft_entra_tenant_id string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_api_base string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_api_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_api_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_api_type string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_api_version string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_deployment_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_organization string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.palm_config *serving.PaLmConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.palm_config.palm_api_key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.palm_config.palm_api_key_plaintext string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.provider serving.ExternalModelProvider REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.task string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].foundation_model *serving.FoundationModel REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].foundation_model.description string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].foundation_model.display_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].foundation_model.docs string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].foundation_model.name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].instance_profile_arn string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].max_provisioned_concurrency int REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].max_provisioned_throughput int REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].min_provisioned_concurrency int REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].min_provisioned_throughput int REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].provisioned_model_units int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].scale_to_zero_enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].state *serving.ServedModelState REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].state.deployment serving.ServedModelStateDeployment REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].state.deployment_state_message string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].workload_size string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].workload_type serving.ServingModelWorkloadType REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models []serving.ServedModelOutput REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*] serving.ServedModelOutput REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].burst_scaling_enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].creation_timestamp int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].creator string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model *modelserving.ExternalModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.ai21labs_config *modelserving.Ai21LabsConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.ai21labs_config.ai21labs_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.ai21labs_config.ai21labs_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config *modelserving.AmazonBedrockConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.aws_access_key_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.aws_access_key_id_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.aws_region *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.aws_secret_access_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.aws_secret_access_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.bedrock_provider *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.instance_profile_arn *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.amazon_bedrock_config.uc_service_credential_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.anthropic_config *modelserving.AnthropicConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.anthropic_config.anthropic_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.anthropic_config.anthropic_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.cohere_config *modelserving.CohereConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.cohere_config.cohere_api_base *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.cohere_config.cohere_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.cohere_config.cohere_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config *modelserving.CustomProviderConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.api_key_auth *modelserving.ApiKeyAuth REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.api_key_auth.key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.api_key_auth.value *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.api_key_auth.value_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.bearer_token_auth *modelserving.BearerTokenAuth REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.bearer_token_auth.token *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.bearer_token_auth.token_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.custom_provider_config.custom_provider_url *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.databricks_model_serving_config *modelserving.DatabricksModelServingConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.databricks_model_serving_config.databricks_api_token *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.databricks_model_serving_config.databricks_api_token_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.databricks_model_serving_config.databricks_workspace_url *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.google_cloud_vertex_ai_config *modelserving.GoogleCloudVertexAiConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.google_cloud_vertex_ai_config.private_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.google_cloud_vertex_ai_config.private_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.google_cloud_vertex_ai_config.project_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.google_cloud_vertex_ai_config.region *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config *modelserving.OpenAiConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.microsoft_entra_client_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.microsoft_entra_client_secret *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.microsoft_entra_client_secret_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.microsoft_entra_tenant_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_api_base *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_api_type *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_api_version *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_deployment_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.openai_config.openai_organization *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.palm_config *modelserving.PaLmConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.palm_config.palm_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.palm_config.palm_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.provider *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].external_model.task *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].foundation_model *modelserving.FoundationModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].foundation_model.description *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].foundation_model.display_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].foundation_model.docs *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].foundation_model.name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].instance_profile_arn *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].max_provisioned_concurrency *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].max_provisioned_throughput *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].min_provisioned_concurrency *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].min_provisioned_throughput *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].model_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].model_version *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].provisioned_model_units *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].scale_to_zero_enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].state *modelserving.ServedModelState REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].state.deployment modelserving.ServedModelDeploymentState REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].state.deployment_state_message *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_entities[*].workload_size *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models []modelserving.ServedModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*] modelserving.ServedModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].burst_scaling_enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].creation_timestamp *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].creator *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].entity_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].entity_version *string REMOTE resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].environment_vars map[string]string REMOTE resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].environment_vars.* string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].instance_profile_arn string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].max_provisioned_concurrency int REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].min_provisioned_concurrency int REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].model_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].model_version string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].provisioned_model_units int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].scale_to_zero_enabled bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].state *serving.ServedModelState REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].state.deployment serving.ServedModelStateDeployment REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].state.deployment_state_message string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].workload_size string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].workload_type serving.ServingModelWorkloadType REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.start_time int64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.traffic_config *serving.TrafficConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.traffic_config.routes []serving.Route REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.traffic_config.routes[*] serving.Route REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.traffic_config.routes[*].served_entity_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.traffic_config.routes[*].served_model_name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.pending_config.traffic_config.routes[*].traffic_percentage int REMOTE -resources.model_serving_endpoints.*.endpoint_details.permission_level serving.ServingEndpointDetailedPermissionLevel REMOTE -resources.model_serving_endpoints.*.endpoint_details.route_optimized bool REMOTE -resources.model_serving_endpoints.*.endpoint_details.state *serving.EndpointState REMOTE -resources.model_serving_endpoints.*.endpoint_details.state.config_update serving.EndpointStateConfigUpdate REMOTE -resources.model_serving_endpoints.*.endpoint_details.state.ready serving.EndpointStateReady REMOTE -resources.model_serving_endpoints.*.endpoint_details.tags []serving.EndpointTag REMOTE -resources.model_serving_endpoints.*.endpoint_details.tags[*] serving.EndpointTag REMOTE -resources.model_serving_endpoints.*.endpoint_details.tags[*].key string REMOTE -resources.model_serving_endpoints.*.endpoint_details.tags[*].value string REMOTE -resources.model_serving_endpoints.*.endpoint_details.task string REMOTE -resources.model_serving_endpoints.*.endpoint_details.telemetry_config *serving.TelemetryConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.telemetry_config.enabled_telemetry_features []serving.TelemetryFeature REMOTE -resources.model_serving_endpoints.*.endpoint_details.telemetry_config.enabled_telemetry_features[*] serving.TelemetryFeature REMOTE -resources.model_serving_endpoints.*.endpoint_details.telemetry_config.inference_table_config *serving.TelemetryInferenceTableConfig REMOTE -resources.model_serving_endpoints.*.endpoint_details.telemetry_config.inference_table_config.name string REMOTE -resources.model_serving_endpoints.*.endpoint_details.telemetry_config.inference_table_config.sampling_fraction float64 REMOTE -resources.model_serving_endpoints.*.endpoint_details.telemetry_config.table_names *serving.UnityCatalogTableNames REMOTE -resources.model_serving_endpoints.*.endpoint_details.telemetry_config.table_names.annotations_table string REMOTE -resources.model_serving_endpoints.*.endpoint_details.telemetry_config.table_names.logs_table string REMOTE -resources.model_serving_endpoints.*.endpoint_details.telemetry_config.table_names.metrics_table string REMOTE -resources.model_serving_endpoints.*.endpoint_details.telemetry_config.table_names.traces_table string REMOTE -resources.model_serving_endpoints.*.endpoint_details.telemetry_config.telemetry_profile_id string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model *modelserving.ExternalModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.ai21labs_config *modelserving.Ai21LabsConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.ai21labs_config.ai21labs_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.ai21labs_config.ai21labs_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.amazon_bedrock_config *modelserving.AmazonBedrockConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.amazon_bedrock_config.aws_access_key_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.amazon_bedrock_config.aws_access_key_id_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.amazon_bedrock_config.aws_region *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.amazon_bedrock_config.aws_secret_access_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.amazon_bedrock_config.aws_secret_access_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.amazon_bedrock_config.bedrock_provider *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.amazon_bedrock_config.instance_profile_arn *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.amazon_bedrock_config.uc_service_credential_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.anthropic_config *modelserving.AnthropicConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.anthropic_config.anthropic_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.anthropic_config.anthropic_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.cohere_config *modelserving.CohereConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.cohere_config.cohere_api_base *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.cohere_config.cohere_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.cohere_config.cohere_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.custom_provider_config *modelserving.CustomProviderConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.custom_provider_config.api_key_auth *modelserving.ApiKeyAuth REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.custom_provider_config.api_key_auth.key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.custom_provider_config.api_key_auth.value *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.custom_provider_config.api_key_auth.value_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.custom_provider_config.bearer_token_auth *modelserving.BearerTokenAuth REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.custom_provider_config.bearer_token_auth.token *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.custom_provider_config.bearer_token_auth.token_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.custom_provider_config.custom_provider_url *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.databricks_model_serving_config *modelserving.DatabricksModelServingConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.databricks_model_serving_config.databricks_api_token *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.databricks_model_serving_config.databricks_api_token_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.databricks_model_serving_config.databricks_workspace_url *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.google_cloud_vertex_ai_config *modelserving.GoogleCloudVertexAiConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.google_cloud_vertex_ai_config.private_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.google_cloud_vertex_ai_config.private_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.google_cloud_vertex_ai_config.project_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.google_cloud_vertex_ai_config.region *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.openai_config *modelserving.OpenAiConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.openai_config.microsoft_entra_client_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.openai_config.microsoft_entra_client_secret *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.openai_config.microsoft_entra_client_secret_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.openai_config.microsoft_entra_tenant_id *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.openai_config.openai_api_base *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.openai_config.openai_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.openai_config.openai_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.openai_config.openai_api_type *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.openai_config.openai_api_version *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.openai_config.openai_deployment_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.openai_config.openai_organization *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.palm_config *modelserving.PaLmConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.palm_config.palm_api_key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.palm_config.palm_api_key_plaintext *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.provider *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].external_model.task *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].foundation_model *modelserving.FoundationModel REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].foundation_model.description *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].foundation_model.display_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].foundation_model.docs *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].foundation_model.name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].instance_profile_arn *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].max_provisioned_concurrency *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].max_provisioned_throughput *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].min_provisioned_concurrency *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].min_provisioned_throughput *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].model_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].model_version *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].provisioned_model_units *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].scale_to_zero_enabled *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].state *modelserving.ServedModelState REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].state.deployment modelserving.ServedModelDeploymentState REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].state.deployment_state_message *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.served_models[*].workload_size *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.start_time *int64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.traffic_config *modelserving.TrafficConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.traffic_config.routes []modelserving.Route REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.traffic_config.routes[*] modelserving.Route REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.traffic_config.routes[*].served_entity_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.traffic_config.routes[*].served_model_name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.pending_config.traffic_config.routes[*].traffic_percentage *int REMOTE +resources.model_serving_endpoints.*.endpoint_details.permission_level modelserving.ServingEndpointDetailedPermissionLevel REMOTE +resources.model_serving_endpoints.*.endpoint_details.route_optimized *bool REMOTE +resources.model_serving_endpoints.*.endpoint_details.state *modelserving.InferenceEndpointState REMOTE +resources.model_serving_endpoints.*.endpoint_details.state.config_update modelserving.InferenceEndpointState_ConfigUpdateState REMOTE +resources.model_serving_endpoints.*.endpoint_details.state.ready modelserving.InferenceEndpointState_ReadyState REMOTE +resources.model_serving_endpoints.*.endpoint_details.tags []modelserving.EndpointTag REMOTE +resources.model_serving_endpoints.*.endpoint_details.tags[*] modelserving.EndpointTag REMOTE +resources.model_serving_endpoints.*.endpoint_details.tags[*].key *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.tags[*].value *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.task *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.telemetry_config *modelserving.TelemetryConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.telemetry_config.enabled_telemetry_features []modelserving.TelemetryFeature REMOTE +resources.model_serving_endpoints.*.endpoint_details.telemetry_config.enabled_telemetry_features[*] modelserving.TelemetryFeature REMOTE +resources.model_serving_endpoints.*.endpoint_details.telemetry_config.inference_table_config *modelserving.TelemetryInferenceTableConfig REMOTE +resources.model_serving_endpoints.*.endpoint_details.telemetry_config.inference_table_config.name *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.telemetry_config.inference_table_config.sampling_fraction *float64 REMOTE +resources.model_serving_endpoints.*.endpoint_details.telemetry_config.table_names *modelserving.UnityCatalogTableNames REMOTE +resources.model_serving_endpoints.*.endpoint_details.telemetry_config.table_names.annotations_table *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.telemetry_config.table_names.logs_table *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.telemetry_config.table_names.metrics_table *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.telemetry_config.table_names.traces_table *string REMOTE +resources.model_serving_endpoints.*.endpoint_details.telemetry_config.telemetry_profile_id *string REMOTE resources.model_serving_endpoints.*.endpoint_id string REMOTE resources.model_serving_endpoints.*.id string INPUT resources.model_serving_endpoints.*.lifecycle resources.Lifecycle INPUT resources.model_serving_endpoints.*.lifecycle.prevent_destroy bool INPUT resources.model_serving_endpoints.*.modified_status string INPUT -resources.model_serving_endpoints.*.name string ALL -resources.model_serving_endpoints.*.rate_limits []serving.RateLimit INPUT STATE -resources.model_serving_endpoints.*.rate_limits[*] serving.RateLimit INPUT STATE -resources.model_serving_endpoints.*.rate_limits[*].calls int64 INPUT STATE -resources.model_serving_endpoints.*.rate_limits[*].key serving.RateLimitKey INPUT STATE -resources.model_serving_endpoints.*.rate_limits[*].renewal_period serving.RateLimitRenewalPeriod INPUT STATE -resources.model_serving_endpoints.*.route_optimized bool ALL -resources.model_serving_endpoints.*.tags []serving.EndpointTag ALL -resources.model_serving_endpoints.*.tags[*] serving.EndpointTag ALL -resources.model_serving_endpoints.*.tags[*].key string ALL -resources.model_serving_endpoints.*.tags[*].value string ALL -resources.model_serving_endpoints.*.telemetry_config *serving.TelemetryConfig ALL -resources.model_serving_endpoints.*.telemetry_config.enabled_telemetry_features []serving.TelemetryFeature ALL -resources.model_serving_endpoints.*.telemetry_config.enabled_telemetry_features[*] serving.TelemetryFeature ALL -resources.model_serving_endpoints.*.telemetry_config.inference_table_config *serving.TelemetryInferenceTableConfig ALL -resources.model_serving_endpoints.*.telemetry_config.inference_table_config.name string ALL -resources.model_serving_endpoints.*.telemetry_config.inference_table_config.sampling_fraction float64 ALL -resources.model_serving_endpoints.*.telemetry_config.table_names *serving.UnityCatalogTableNames ALL -resources.model_serving_endpoints.*.telemetry_config.table_names.annotations_table string ALL -resources.model_serving_endpoints.*.telemetry_config.table_names.logs_table string ALL -resources.model_serving_endpoints.*.telemetry_config.table_names.metrics_table string ALL -resources.model_serving_endpoints.*.telemetry_config.table_names.traces_table string ALL -resources.model_serving_endpoints.*.telemetry_config.telemetry_profile_id string ALL +resources.model_serving_endpoints.*.name *string ALL +resources.model_serving_endpoints.*.rate_limits []modelserving.RateLimit INPUT STATE +resources.model_serving_endpoints.*.rate_limits[*] modelserving.RateLimit INPUT STATE +resources.model_serving_endpoints.*.rate_limits[*].calls *int64 INPUT STATE +resources.model_serving_endpoints.*.rate_limits[*].key *string INPUT STATE +resources.model_serving_endpoints.*.rate_limits[*].renewal_period *string INPUT STATE +resources.model_serving_endpoints.*.route_optimized *bool ALL +resources.model_serving_endpoints.*.tags []modelserving.EndpointTag ALL +resources.model_serving_endpoints.*.tags[*] modelserving.EndpointTag ALL +resources.model_serving_endpoints.*.tags[*].key *string ALL +resources.model_serving_endpoints.*.tags[*].value *string ALL +resources.model_serving_endpoints.*.telemetry_config *modelserving.TelemetryConfig ALL +resources.model_serving_endpoints.*.telemetry_config.enabled_telemetry_features []modelserving.TelemetryFeature ALL +resources.model_serving_endpoints.*.telemetry_config.enabled_telemetry_features[*] modelserving.TelemetryFeature ALL +resources.model_serving_endpoints.*.telemetry_config.inference_table_config *modelserving.TelemetryInferenceTableConfig ALL +resources.model_serving_endpoints.*.telemetry_config.inference_table_config.name *string ALL +resources.model_serving_endpoints.*.telemetry_config.inference_table_config.sampling_fraction *float64 ALL +resources.model_serving_endpoints.*.telemetry_config.table_names *modelserving.UnityCatalogTableNames ALL +resources.model_serving_endpoints.*.telemetry_config.table_names.annotations_table *string ALL +resources.model_serving_endpoints.*.telemetry_config.table_names.logs_table *string ALL +resources.model_serving_endpoints.*.telemetry_config.table_names.metrics_table *string ALL +resources.model_serving_endpoints.*.telemetry_config.table_names.traces_table *string ALL +resources.model_serving_endpoints.*.telemetry_config.telemetry_profile_id *string ALL resources.model_serving_endpoints.*.url string INPUT resources.model_serving_endpoints.*.permissions.object_id string ALL resources.model_serving_endpoints.*.permissions[*] dresources.StatePermission ALL resources.model_serving_endpoints.*.permissions[*].group_name string ALL -resources.model_serving_endpoints.*.permissions[*].level iam.PermissionLevel ALL +resources.model_serving_endpoints.*.permissions[*].level resources.PermissionLevel ALL resources.model_serving_endpoints.*.permissions[*].service_principal_name string ALL resources.model_serving_endpoints.*.permissions[*].user_name string ALL -resources.models.*.creation_timestamp int64 REMOTE -resources.models.*.description string ALL -resources.models.*.id string INPUT REMOTE -resources.models.*.last_updated_timestamp int64 REMOTE -resources.models.*.latest_versions []ml.ModelVersion REMOTE -resources.models.*.latest_versions[*] ml.ModelVersion REMOTE -resources.models.*.latest_versions[*].creation_timestamp int64 REMOTE -resources.models.*.latest_versions[*].current_stage string REMOTE -resources.models.*.latest_versions[*].description string REMOTE -resources.models.*.latest_versions[*].last_updated_timestamp int64 REMOTE -resources.models.*.latest_versions[*].name string REMOTE -resources.models.*.latest_versions[*].run_id string REMOTE -resources.models.*.latest_versions[*].run_link string REMOTE -resources.models.*.latest_versions[*].source string REMOTE -resources.models.*.latest_versions[*].status ml.ModelVersionStatus REMOTE -resources.models.*.latest_versions[*].status_message string REMOTE -resources.models.*.latest_versions[*].tags []ml.ModelVersionTag REMOTE -resources.models.*.latest_versions[*].tags[*] ml.ModelVersionTag REMOTE -resources.models.*.latest_versions[*].tags[*].key string REMOTE -resources.models.*.latest_versions[*].tags[*].value string REMOTE -resources.models.*.latest_versions[*].user_id string REMOTE -resources.models.*.latest_versions[*].version string REMOTE +resources.models.*.creation_timestamp *int64 REMOTE +resources.models.*.description *string ALL +resources.models.*.id *string REMOTE +resources.models.*.id string INPUT +resources.models.*.last_updated_timestamp *int64 REMOTE +resources.models.*.latest_versions []modelregistry.ModelVersion REMOTE +resources.models.*.latest_versions[*] modelregistry.ModelVersion REMOTE +resources.models.*.latest_versions[*].creation_timestamp *int64 REMOTE +resources.models.*.latest_versions[*].current_stage *string REMOTE +resources.models.*.latest_versions[*].description *string REMOTE +resources.models.*.latest_versions[*].last_updated_timestamp *int64 REMOTE +resources.models.*.latest_versions[*].name *string REMOTE +resources.models.*.latest_versions[*].run_id *string REMOTE +resources.models.*.latest_versions[*].run_link *string REMOTE +resources.models.*.latest_versions[*].source *string REMOTE +resources.models.*.latest_versions[*].status modelregistry.ModelVersionStatus REMOTE +resources.models.*.latest_versions[*].status_message *string REMOTE +resources.models.*.latest_versions[*].tags []modelregistry.ModelVersionTag REMOTE +resources.models.*.latest_versions[*].tags[*] modelregistry.ModelVersionTag REMOTE +resources.models.*.latest_versions[*].tags[*].key *string REMOTE +resources.models.*.latest_versions[*].tags[*].value *string REMOTE +resources.models.*.latest_versions[*].user_id *string REMOTE +resources.models.*.latest_versions[*].version *string REMOTE resources.models.*.lifecycle resources.Lifecycle INPUT resources.models.*.lifecycle.prevent_destroy bool INPUT resources.models.*.model_id string REMOTE resources.models.*.modified_status string INPUT -resources.models.*.name string ALL -resources.models.*.permission_level ml.PermissionLevel REMOTE -resources.models.*.tags []ml.ModelTag ALL -resources.models.*.tags[*] ml.ModelTag ALL -resources.models.*.tags[*].key string ALL -resources.models.*.tags[*].value string ALL +resources.models.*.name *string ALL +resources.models.*.permission_level modelregistry.PermissionLevel REMOTE +resources.models.*.tags []modelregistry.RegisteredModelTag ALL +resources.models.*.tags[*] modelregistry.RegisteredModelTag ALL +resources.models.*.tags[*].key *string ALL +resources.models.*.tags[*].value *string ALL resources.models.*.url string INPUT -resources.models.*.user_id string REMOTE +resources.models.*.user_id *string REMOTE resources.models.*.permissions.object_id string ALL resources.models.*.permissions[*] dresources.StatePermission ALL resources.models.*.permissions[*].group_name string ALL -resources.models.*.permissions[*].level iam.PermissionLevel ALL +resources.models.*.permissions[*].level resources.PermissionLevel ALL resources.models.*.permissions[*].service_principal_name string ALL resources.models.*.permissions[*].user_name string ALL -resources.pipelines.*.allow_duplicate_names bool ALL -resources.pipelines.*.budget_policy_id string ALL +resources.pipelines.*.allow_duplicate_names *bool ALL +resources.pipelines.*.budget_policy_id *string ALL resources.pipelines.*.cascade_on_destroy *bool INPUT STATE -resources.pipelines.*.catalog string ALL -resources.pipelines.*.cause string REMOTE -resources.pipelines.*.channel string ALL -resources.pipelines.*.cluster_id string REMOTE +resources.pipelines.*.catalog *string ALL +resources.pipelines.*.cause *string REMOTE +resources.pipelines.*.channel *string ALL +resources.pipelines.*.cluster_id *string REMOTE resources.pipelines.*.clusters []pipelines.PipelineCluster ALL resources.pipelines.*.clusters[*] pipelines.PipelineCluster ALL -resources.pipelines.*.clusters[*].apply_policy_default_values bool ALL -resources.pipelines.*.clusters[*].autoscale *pipelines.PipelineClusterAutoscale ALL -resources.pipelines.*.clusters[*].autoscale.max_workers int ALL -resources.pipelines.*.clusters[*].autoscale.min_workers int ALL -resources.pipelines.*.clusters[*].autoscale.mode pipelines.PipelineClusterAutoscaleMode ALL -resources.pipelines.*.clusters[*].aws_attributes *compute.AwsAttributes ALL -resources.pipelines.*.clusters[*].aws_attributes.availability compute.AwsAvailability ALL -resources.pipelines.*.clusters[*].aws_attributes.ebs_volume_count int ALL -resources.pipelines.*.clusters[*].aws_attributes.ebs_volume_iops int ALL -resources.pipelines.*.clusters[*].aws_attributes.ebs_volume_size int ALL -resources.pipelines.*.clusters[*].aws_attributes.ebs_volume_throughput int ALL -resources.pipelines.*.clusters[*].aws_attributes.ebs_volume_type compute.EbsVolumeType ALL -resources.pipelines.*.clusters[*].aws_attributes.first_on_demand int ALL -resources.pipelines.*.clusters[*].aws_attributes.instance_profile_arn string ALL -resources.pipelines.*.clusters[*].aws_attributes.spot_bid_price_percent int ALL -resources.pipelines.*.clusters[*].aws_attributes.zone_id string ALL -resources.pipelines.*.clusters[*].azure_attributes *compute.AzureAttributes ALL -resources.pipelines.*.clusters[*].azure_attributes.availability compute.AzureAvailability ALL -resources.pipelines.*.clusters[*].azure_attributes.capacity_reservation_group string ALL -resources.pipelines.*.clusters[*].azure_attributes.first_on_demand int ALL -resources.pipelines.*.clusters[*].azure_attributes.log_analytics_info *compute.LogAnalyticsInfo ALL -resources.pipelines.*.clusters[*].azure_attributes.log_analytics_info.log_analytics_primary_key string ALL -resources.pipelines.*.clusters[*].azure_attributes.log_analytics_info.log_analytics_workspace_id string ALL -resources.pipelines.*.clusters[*].azure_attributes.spot_bid_max_price float64 ALL -resources.pipelines.*.clusters[*].cluster_log_conf *compute.ClusterLogConf ALL -resources.pipelines.*.clusters[*].cluster_log_conf.dbfs *compute.DbfsStorageInfo ALL -resources.pipelines.*.clusters[*].cluster_log_conf.dbfs.destination string ALL -resources.pipelines.*.clusters[*].cluster_log_conf.s3 *compute.S3StorageInfo ALL -resources.pipelines.*.clusters[*].cluster_log_conf.s3.canned_acl string ALL -resources.pipelines.*.clusters[*].cluster_log_conf.s3.destination string ALL -resources.pipelines.*.clusters[*].cluster_log_conf.s3.enable_encryption bool ALL -resources.pipelines.*.clusters[*].cluster_log_conf.s3.encryption_type string ALL -resources.pipelines.*.clusters[*].cluster_log_conf.s3.endpoint string ALL -resources.pipelines.*.clusters[*].cluster_log_conf.s3.kms_key string ALL -resources.pipelines.*.clusters[*].cluster_log_conf.s3.region string ALL -resources.pipelines.*.clusters[*].cluster_log_conf.volumes *compute.VolumesStorageInfo ALL -resources.pipelines.*.clusters[*].cluster_log_conf.volumes.destination string ALL +resources.pipelines.*.clusters[*].apply_policy_default_values *bool ALL +resources.pipelines.*.clusters[*].autoscale *pipelines.PipelinesAutoScale ALL +resources.pipelines.*.clusters[*].autoscale.max_workers *int ALL +resources.pipelines.*.clusters[*].autoscale.min_workers *int ALL +resources.pipelines.*.clusters[*].autoscale.mode *string ALL +resources.pipelines.*.clusters[*].aws_attributes *pipelines.PipelinesAwsAttributes ALL +resources.pipelines.*.clusters[*].aws_attributes.availability pipelines.PipelinesAwsAvailability ALL +resources.pipelines.*.clusters[*].aws_attributes.ebs_volume_count *int ALL +resources.pipelines.*.clusters[*].aws_attributes.ebs_volume_iops *int ALL +resources.pipelines.*.clusters[*].aws_attributes.ebs_volume_size *int ALL +resources.pipelines.*.clusters[*].aws_attributes.ebs_volume_throughput *int ALL +resources.pipelines.*.clusters[*].aws_attributes.ebs_volume_type pipelines.PipelinesEbsVolumeType ALL +resources.pipelines.*.clusters[*].aws_attributes.first_on_demand *int ALL +resources.pipelines.*.clusters[*].aws_attributes.instance_profile_arn *string ALL +resources.pipelines.*.clusters[*].aws_attributes.spot_bid_price_percent *int ALL +resources.pipelines.*.clusters[*].aws_attributes.zone_id *string ALL +resources.pipelines.*.clusters[*].azure_attributes *pipelines.PipelinesAzureAttributes ALL +resources.pipelines.*.clusters[*].azure_attributes.availability pipelines.PipelinesAzureAvailability ALL +resources.pipelines.*.clusters[*].azure_attributes.first_on_demand *int ALL +resources.pipelines.*.clusters[*].azure_attributes.spot_bid_max_price *float64 ALL +resources.pipelines.*.clusters[*].cluster_log_conf *pipelines.PipelinesClusterLogConf ALL +resources.pipelines.*.clusters[*].cluster_log_conf.dbfs *pipelines.PipelinesDbfsStorageInfo ALL +resources.pipelines.*.clusters[*].cluster_log_conf.dbfs.destination *string ALL resources.pipelines.*.clusters[*].custom_tags map[string]string ALL resources.pipelines.*.clusters[*].custom_tags.* string ALL -resources.pipelines.*.clusters[*].driver_instance_pool_id string ALL -resources.pipelines.*.clusters[*].driver_node_type_id string ALL -resources.pipelines.*.clusters[*].enable_local_disk_encryption bool ALL -resources.pipelines.*.clusters[*].gcp_attributes *compute.GcpAttributes ALL -resources.pipelines.*.clusters[*].gcp_attributes.availability compute.GcpAvailability ALL -resources.pipelines.*.clusters[*].gcp_attributes.boot_disk_size int ALL -resources.pipelines.*.clusters[*].gcp_attributes.confidential_compute_type compute.ConfidentialComputeType ALL -resources.pipelines.*.clusters[*].gcp_attributes.first_on_demand int ALL -resources.pipelines.*.clusters[*].gcp_attributes.google_service_account string ALL -resources.pipelines.*.clusters[*].gcp_attributes.local_ssd_count int ALL -resources.pipelines.*.clusters[*].gcp_attributes.use_preemptible_executors bool ALL -resources.pipelines.*.clusters[*].gcp_attributes.zone_id string ALL -resources.pipelines.*.clusters[*].init_scripts []compute.InitScriptInfo ALL -resources.pipelines.*.clusters[*].init_scripts[*] compute.InitScriptInfo ALL -resources.pipelines.*.clusters[*].init_scripts[*].abfss *compute.Adlsgen2Info ALL -resources.pipelines.*.clusters[*].init_scripts[*].abfss.destination string ALL -resources.pipelines.*.clusters[*].init_scripts[*].dbfs *compute.DbfsStorageInfo ALL -resources.pipelines.*.clusters[*].init_scripts[*].dbfs.destination string ALL -resources.pipelines.*.clusters[*].init_scripts[*].file *compute.LocalFileInfo ALL -resources.pipelines.*.clusters[*].init_scripts[*].file.destination string ALL -resources.pipelines.*.clusters[*].init_scripts[*].gcs *compute.GcsStorageInfo ALL -resources.pipelines.*.clusters[*].init_scripts[*].gcs.destination string ALL -resources.pipelines.*.clusters[*].init_scripts[*].s3 *compute.S3StorageInfo ALL -resources.pipelines.*.clusters[*].init_scripts[*].s3.canned_acl string ALL -resources.pipelines.*.clusters[*].init_scripts[*].s3.destination string ALL -resources.pipelines.*.clusters[*].init_scripts[*].s3.enable_encryption bool ALL -resources.pipelines.*.clusters[*].init_scripts[*].s3.encryption_type string ALL -resources.pipelines.*.clusters[*].init_scripts[*].s3.endpoint string ALL -resources.pipelines.*.clusters[*].init_scripts[*].s3.kms_key string ALL -resources.pipelines.*.clusters[*].init_scripts[*].s3.region string ALL -resources.pipelines.*.clusters[*].init_scripts[*].volumes *compute.VolumesStorageInfo ALL -resources.pipelines.*.clusters[*].init_scripts[*].volumes.destination string ALL -resources.pipelines.*.clusters[*].init_scripts[*].workspace *compute.WorkspaceStorageInfo ALL -resources.pipelines.*.clusters[*].init_scripts[*].workspace.destination string ALL -resources.pipelines.*.clusters[*].instance_pool_id string ALL -resources.pipelines.*.clusters[*].label string ALL -resources.pipelines.*.clusters[*].node_type_id string ALL -resources.pipelines.*.clusters[*].num_workers int ALL -resources.pipelines.*.clusters[*].policy_id string ALL +resources.pipelines.*.clusters[*].driver_instance_pool_id *string ALL +resources.pipelines.*.clusters[*].driver_node_type_id *string ALL +resources.pipelines.*.clusters[*].enable_local_disk_encryption *bool ALL +resources.pipelines.*.clusters[*].gcp_attributes *pipelines.PipelinesGcpAttributes ALL +resources.pipelines.*.clusters[*].gcp_attributes.availability pipelines.PipelinesGcpAvailability ALL +resources.pipelines.*.clusters[*].gcp_attributes.boot_disk_size *int ALL +resources.pipelines.*.clusters[*].gcp_attributes.google_service_account *string ALL +resources.pipelines.*.clusters[*].gcp_attributes.local_ssd_count *int ALL +resources.pipelines.*.clusters[*].gcp_attributes.zone_id *string ALL +resources.pipelines.*.clusters[*].init_scripts []pipelines.PipelinesInitScriptInfo ALL +resources.pipelines.*.clusters[*].init_scripts[*] pipelines.PipelinesInitScriptInfo ALL +resources.pipelines.*.clusters[*].init_scripts[*].dbfs *pipelines.PipelinesDbfsStorageInfo ALL +resources.pipelines.*.clusters[*].init_scripts[*].dbfs.destination *string ALL +resources.pipelines.*.clusters[*].init_scripts[*].s3 *pipelines.PipelinesS3StorageInfo ALL +resources.pipelines.*.clusters[*].init_scripts[*].s3.canned_acl *string ALL +resources.pipelines.*.clusters[*].init_scripts[*].s3.destination *string ALL +resources.pipelines.*.clusters[*].init_scripts[*].s3.enable_encryption *bool ALL +resources.pipelines.*.clusters[*].init_scripts[*].s3.encryption_type *string ALL +resources.pipelines.*.clusters[*].init_scripts[*].s3.endpoint *string ALL +resources.pipelines.*.clusters[*].init_scripts[*].s3.kms_key *string ALL +resources.pipelines.*.clusters[*].init_scripts[*].s3.region *string ALL +resources.pipelines.*.clusters[*].instance_pool_id *string ALL +resources.pipelines.*.clusters[*].label *string ALL +resources.pipelines.*.clusters[*].node_type_id *string ALL +resources.pipelines.*.clusters[*].num_workers *int ALL +resources.pipelines.*.clusters[*].policy_id *string ALL resources.pipelines.*.clusters[*].spark_conf map[string]string ALL resources.pipelines.*.clusters[*].spark_conf.* string ALL resources.pipelines.*.clusters[*].spark_env_vars map[string]string ALL @@ -3007,99 +3205,100 @@ resources.pipelines.*.clusters[*].ssh_public_keys []string ALL resources.pipelines.*.clusters[*].ssh_public_keys[*] string ALL resources.pipelines.*.configuration map[string]string ALL resources.pipelines.*.configuration.* string ALL -resources.pipelines.*.continuous bool ALL -resources.pipelines.*.creator_user_name string REMOTE +resources.pipelines.*.continuous *bool ALL +resources.pipelines.*.creator_user_name *string REMOTE resources.pipelines.*.deployment *pipelines.PipelineDeployment ALL -resources.pipelines.*.deployment.deployment_id string ALL +resources.pipelines.*.deployment.deployment_id *string ALL resources.pipelines.*.deployment.kind pipelines.DeploymentKind ALL -resources.pipelines.*.deployment.metadata_file_path string ALL -resources.pipelines.*.deployment.version_id string ALL -resources.pipelines.*.development bool ALL -resources.pipelines.*.dry_run bool ALL -resources.pipelines.*.edition string ALL -resources.pipelines.*.effective_budget_policy_id string REMOTE +resources.pipelines.*.deployment.metadata_file_path *string ALL +resources.pipelines.*.deployment.version_id *string ALL +resources.pipelines.*.development *bool ALL +resources.pipelines.*.dry_run *bool ALL +resources.pipelines.*.edition *string ALL +resources.pipelines.*.effective_budget_policy_id *string REMOTE resources.pipelines.*.effective_publishing_mode pipelines.PublishingMode REMOTE -resources.pipelines.*.effective_serverless_compute_id string REMOTE +resources.pipelines.*.effective_serverless_compute_id *string REMOTE resources.pipelines.*.environment *pipelines.PipelinesEnvironment ALL resources.pipelines.*.environment.dependencies []string ALL resources.pipelines.*.environment.dependencies[*] string ALL -resources.pipelines.*.environment.environment_version string ALL +resources.pipelines.*.environment.environment_version *string ALL resources.pipelines.*.event_log *pipelines.EventLogSpec ALL -resources.pipelines.*.event_log.catalog string ALL -resources.pipelines.*.event_log.name string ALL -resources.pipelines.*.event_log.schema string ALL +resources.pipelines.*.event_log.catalog *string ALL +resources.pipelines.*.event_log.name *string ALL +resources.pipelines.*.event_log.schema *string ALL resources.pipelines.*.filters *pipelines.Filters ALL resources.pipelines.*.filters.exclude []string ALL resources.pipelines.*.filters.exclude[*] string ALL resources.pipelines.*.filters.include []string ALL resources.pipelines.*.filters.include[*] string ALL resources.pipelines.*.gateway_definition *pipelines.IngestionGatewayPipelineDefinition ALL -resources.pipelines.*.gateway_definition.connection_id string ALL -resources.pipelines.*.gateway_definition.connection_name string ALL +resources.pipelines.*.gateway_definition.connection_id *string ALL +resources.pipelines.*.gateway_definition.connection_name *string ALL resources.pipelines.*.gateway_definition.connection_parameters *pipelines.ConnectionParameters ALL -resources.pipelines.*.gateway_definition.connection_parameters.source_catalog string ALL -resources.pipelines.*.gateway_definition.gateway_storage_catalog string ALL -resources.pipelines.*.gateway_definition.gateway_storage_name string ALL -resources.pipelines.*.gateway_definition.gateway_storage_schema string ALL -resources.pipelines.*.health pipelines.GetPipelineResponseHealth REMOTE -resources.pipelines.*.id string ALL +resources.pipelines.*.gateway_definition.connection_parameters.source_catalog *string ALL +resources.pipelines.*.gateway_definition.gateway_storage_catalog *string ALL +resources.pipelines.*.gateway_definition.gateway_storage_name *string ALL +resources.pipelines.*.gateway_definition.gateway_storage_schema *string ALL +resources.pipelines.*.health pipelines.PipelineHealthStatus REMOTE +resources.pipelines.*.id *string ALL +resources.pipelines.*.id string INPUT resources.pipelines.*.ingestion_definition *pipelines.IngestionPipelineDefinition ALL -resources.pipelines.*.ingestion_definition.connection_name string ALL +resources.pipelines.*.ingestion_definition.connection_name *string ALL resources.pipelines.*.ingestion_definition.connector_type pipelines.ConnectorType ALL resources.pipelines.*.ingestion_definition.data_staging_options *pipelines.DataStagingOptions ALL -resources.pipelines.*.ingestion_definition.data_staging_options.catalog_name string ALL -resources.pipelines.*.ingestion_definition.data_staging_options.schema_name string ALL -resources.pipelines.*.ingestion_definition.data_staging_options.volume_name string ALL +resources.pipelines.*.ingestion_definition.data_staging_options.catalog_name *string ALL +resources.pipelines.*.ingestion_definition.data_staging_options.schema_name *string ALL +resources.pipelines.*.ingestion_definition.data_staging_options.volume_name *string ALL resources.pipelines.*.ingestion_definition.full_refresh_window *pipelines.OperationTimeWindow ALL resources.pipelines.*.ingestion_definition.full_refresh_window.days_of_week []pipelines.DayOfWeek ALL resources.pipelines.*.ingestion_definition.full_refresh_window.days_of_week[*] pipelines.DayOfWeek ALL -resources.pipelines.*.ingestion_definition.full_refresh_window.start_hour int ALL -resources.pipelines.*.ingestion_definition.full_refresh_window.time_zone_id string ALL -resources.pipelines.*.ingestion_definition.ingest_from_uc_foreign_catalog bool ALL -resources.pipelines.*.ingestion_definition.ingestion_gateway_id string ALL -resources.pipelines.*.ingestion_definition.netsuite_jar_path string ALL -resources.pipelines.*.ingestion_definition.objects []pipelines.IngestionConfig ALL -resources.pipelines.*.ingestion_definition.objects[*] pipelines.IngestionConfig ALL -resources.pipelines.*.ingestion_definition.objects[*].report *pipelines.ReportSpec ALL -resources.pipelines.*.ingestion_definition.objects[*].report.destination_catalog string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.destination_schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.destination_table string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.source_url string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration *pipelines.TableSpecificConfig ALL +resources.pipelines.*.ingestion_definition.full_refresh_window.start_hour *int ALL +resources.pipelines.*.ingestion_definition.full_refresh_window.time_zone_id *string ALL +resources.pipelines.*.ingestion_definition.ingest_from_uc_foreign_catalog *bool ALL +resources.pipelines.*.ingestion_definition.ingestion_gateway_id *string ALL +resources.pipelines.*.ingestion_definition.netsuite_jar_path *string ALL +resources.pipelines.*.ingestion_definition.objects []pipelines.IngestionPipelineDefinition_IngestionConfig ALL +resources.pipelines.*.ingestion_definition.objects[*] pipelines.IngestionPipelineDefinition_IngestionConfig ALL +resources.pipelines.*.ingestion_definition.objects[*].report *pipelines.IngestionPipelineDefinition_ReportSpec ALL +resources.pipelines.*.ingestion_definition.objects[*].report.destination_catalog *string ALL +resources.pipelines.*.ingestion_definition.objects[*].report.destination_schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].report.destination_table *string ALL +resources.pipelines.*.ingestion_definition.objects[*].report.source_url *string ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration *pipelines.IngestionPipelineDefinition_TableSpecificConfig ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.auto_full_refresh_policy *pipelines.AutoFullRefreshPolicy ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.auto_full_refresh_policy.enabled bool ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.auto_full_refresh_policy.min_interval_hours int ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.auto_full_refresh_policy.enabled *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.auto_full_refresh_policy.min_interval_hours *int ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.clustering_columns []string ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.clustering_columns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.enable_auto_clustering bool ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.enable_auto_clustering *bool ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.exclude_columns []string ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.exclude_columns[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.include_columns []string ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.include_columns[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.primary_keys []string ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.primary_keys[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.query_based_connector_config *pipelines.IngestionPipelineDefinitionTableSpecificConfigQueryBasedConnectorConfig ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.query_based_connector_config *pipelines.IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.query_based_connector_config.cursor_columns []string ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.query_based_connector_config.cursor_columns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.query_based_connector_config.deletion_condition string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.query_based_connector_config.hard_deletion_sync_min_interval_in_seconds int64 ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.row_filter string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.salesforce_include_formula_fields bool ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.scd_type pipelines.TableSpecificConfigScdType ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.query_based_connector_config.deletion_condition *string ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.query_based_connector_config.hard_deletion_sync_min_interval_in_seconds *int64 ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.row_filter *string ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.salesforce_include_formula_fields *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.scd_type pipelines.ScdType_ScdType ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.sequence_by []string ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.sequence_by[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.source_metadata_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.source_metadata_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.table_properties map[string]string ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.table_properties.* string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters *pipelines.IngestionPipelineDefinitionWorkdayReportParameters ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters.incremental bool ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters *pipelines.IngestionPipelineDefinition_WorkdayReportParameters ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters.incremental *bool ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters.parameters map[string]string ALL resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters.parameters.* string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters.report_parameters []pipelines.IngestionPipelineDefinitionWorkdayReportParametersQueryKeyValue ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters.report_parameters[*] pipelines.IngestionPipelineDefinitionWorkdayReportParametersQueryKeyValue ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters.report_parameters[*].key string ALL -resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters.report_parameters[*].value string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema *pipelines.SchemaSpec ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters.report_parameters []pipelines.IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters.report_parameters[*] pipelines.IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters.report_parameters[*].key *string ALL +resources.pipelines.*.ingestion_definition.objects[*].report.table_configuration.workday_report_parameters.report_parameters[*].value *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema *pipelines.IngestionPipelineDefinition_SchemaSpec ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options *pipelines.ConnectorOptions ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.api_source_connector_options *pipelines.ApiSourceConnectorOptions ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.api_source_connector_options.options map[string]string ALL @@ -3108,37 +3307,37 @@ resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.c resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.confluence_options.include_confluence_spaces []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.confluence_options.include_confluence_spaces[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options *pipelines.GoogleDriveOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.entity_type pipelines.GoogleDriveOptionsGoogleDriveEntityType ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.entity_type pipelines.GoogleDriveOptions_GoogleDriveEntityType ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options *pipelines.FileIngestionOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.corrupt_record_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.corrupt_record_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.file_filters []pipelines.FileFilter ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.file_filters[*] pipelines.FileFilter ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.file_filters[*].modified_after string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.file_filters[*].modified_before string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.file_filters[*].path_filter string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.format pipelines.FileIngestionOptionsFileFormat ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.file_filters[*].modified_after *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.file_filters[*].modified_before *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.file_filters[*].path_filter *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.format pipelines.FileIngestionOptions_FileFormat ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.format_options map[string]string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.format_options.* string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.ignore_corrupt_files bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.infer_column_types bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.reader_case_sensitive bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.rescued_data_column string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.schema_evolution_mode pipelines.FileIngestionOptionsSchemaEvolutionMode ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.schema_hints string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.single_variant_column string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.url string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.ignore_corrupt_files *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.infer_column_types *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.reader_case_sensitive *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.rescued_data_column *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.schema_evolution_mode pipelines.FileIngestionOptions_SchemaEvolutionMode ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.schema_hints *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.file_ingestion_options.single_variant_column *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.gdrive_options.url *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options *pipelines.GoogleAdsOptions ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.custom_report_options *pipelines.GoogleAdsCustomReportOptions ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.custom_report_options.metrics []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.custom_report_options.metrics[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.custom_report_options.resource string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.custom_report_options.resource *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.custom_report_options.resource_fields []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.custom_report_options.resource_fields[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.custom_report_options.segments []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.custom_report_options.segments[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.lookback_window_days int ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.manager_account_id string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.sync_start_date string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.lookback_window_days *int ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.manager_account_id *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.google_ads_options.sync_start_date *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.jira_options *pipelines.JiraConnectorOptions ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.jira_options.include_jira_spaces []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.jira_options.include_jira_spaces[*] string ALL @@ -3148,100 +3347,100 @@ resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.k resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer *pipelines.Transformer ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options *pipelines.AvroTransformerOptions ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.parse_mode pipelines.ParseMode ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.schema_file_path string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.schema_file_path *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.schema_registry *pipelines.SchemaRegistryConfig ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.schema_registry.confluent_options *pipelines.ConfluentSchemaRegistryOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.schema_registry.confluent_options.subject string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.schema_registry.connection_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.schema_registry.protobuf_message_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.format pipelines.TransformerFormat ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.input_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.schema_registry.confluent_options.subject *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.schema_registry.connection_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.avro_options.schema_registry.protobuf_message_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.format pipelines.Transformer_Format ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.input_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.json_options *pipelines.JsonTransformerOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.json_options.as_variant bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.json_options.schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.json_options.schema_evolution_mode pipelines.FileIngestionOptionsSchemaEvolutionMode ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.json_options.schema_file_path string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.json_options.schema_hints string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.output_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.json_options.as_variant *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.json_options.schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.json_options.schema_evolution_mode pipelines.FileIngestionOptions_SchemaEvolutionMode ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.json_options.schema_file_path *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.json_options.schema_hints *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.output_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options *pipelines.ProtobufTransformerOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.desc_file_path string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.message_name string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.desc_file_path *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.message_name *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.parse_mode pipelines.ParseMode ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.recursive_fields_max_depth int ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.recursive_fields_max_depth *int ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry *pipelines.SchemaRegistryConfig ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.confluent_options *pipelines.ConfluentSchemaRegistryOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.confluent_options.subject string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.connection_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.protobuf_message_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.max_offsets_per_trigger int64 ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.starting_offset string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.topic_pattern string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.confluent_options.subject *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.connection_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.protobuf_message_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.max_offsets_per_trigger *int64 ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.starting_offset *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.topic_pattern *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.topics []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.topics[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer *pipelines.Transformer ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options *pipelines.AvroTransformerOptions ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.parse_mode pipelines.ParseMode ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.schema_file_path string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.schema_file_path *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.schema_registry *pipelines.SchemaRegistryConfig ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.schema_registry.confluent_options *pipelines.ConfluentSchemaRegistryOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.schema_registry.confluent_options.subject string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.schema_registry.connection_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.schema_registry.protobuf_message_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.format pipelines.TransformerFormat ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.input_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.schema_registry.confluent_options.subject *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.schema_registry.connection_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.avro_options.schema_registry.protobuf_message_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.format pipelines.Transformer_Format ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.input_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.json_options *pipelines.JsonTransformerOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.json_options.as_variant bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.json_options.schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.json_options.schema_evolution_mode pipelines.FileIngestionOptionsSchemaEvolutionMode ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.json_options.schema_file_path string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.json_options.schema_hints string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.output_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.json_options.as_variant *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.json_options.schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.json_options.schema_evolution_mode pipelines.FileIngestionOptions_SchemaEvolutionMode ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.json_options.schema_file_path *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.json_options.schema_hints *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.output_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options *pipelines.ProtobufTransformerOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.desc_file_path string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.message_name string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.desc_file_path *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.message_name *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.parse_mode pipelines.ParseMode ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.recursive_fields_max_depth int ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.recursive_fields_max_depth *int ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry *pipelines.SchemaRegistryConfig ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.confluent_options *pipelines.ConfluentSchemaRegistryOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.confluent_options.subject string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.connection_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.protobuf_message_name string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.confluent_options.subject *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.connection_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.protobuf_message_name *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options *pipelines.LinkedInAdsOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.custom_report_options *pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.custom_report_options.entity_granularity []pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptionsLinkedInAdsEntityGranularity ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.custom_report_options.entity_granularity[*] pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptionsLinkedInAdsEntityGranularity ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.custom_report_options.finder pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptionsLinkedInAdsFinder ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.custom_report_options *pipelines.LinkedInAdsOptions_LinkedInAdsCustomReportOptions ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.custom_report_options.entity_granularity []pipelines.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.custom_report_options.entity_granularity[*] pipelines.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.custom_report_options.finder pipelines.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.custom_report_options.metrics []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.custom_report_options.metrics[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.custom_report_options.time_granularity pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptionsLinkedInAdsTimeGranularity ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.lookback_window_days int ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.sync_start_date string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.custom_report_options.time_granularity pipelines.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.lookback_window_days *int ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.linkedin_ads_options.sync_start_date *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.marketo_options *pipelines.MarketoOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.marketo_options.sync_start_date string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.marketo_options.sync_start_date *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options *pipelines.MetaMarketingOptions ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.action_attribution_windows []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.action_attribution_windows[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.action_breakdowns []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.action_breakdowns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.action_report_time string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.action_report_time *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.breakdowns []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.breakdowns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_insights_lookback_window int ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options *pipelines.MetaMarketingOptionsMetaMarketingCustomReportOptions ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_insights_lookback_window *int ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options *pipelines.MetaMarketingOptions_MetaMarketingCustomReportOptions ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options.action_attribution_windows []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options.action_attribution_windows[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options.action_breakdowns []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options.action_breakdowns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options.action_report_time string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options.action_report_time *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options.breakdowns []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options.breakdowns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options.level string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options.time_increment string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.level string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.start_date string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.time_increment string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options.level *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.custom_report_options.time_increment *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.level *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.start_date *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.meta_ads_options.time_increment *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.outlook_options *pipelines.OutlookOptions ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.outlook_options.attachment_mode pipelines.OutlookAttachmentMode ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.outlook_options.body_format pipelines.OutlookBodyFormat ALL @@ -3257,132 +3456,132 @@ resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.o resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.outlook_options.include_subjects[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.outlook_options.sender_filter []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.outlook_options.sender_filter[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.outlook_options.start_date string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.outlook_options.start_date *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.outlook_options.subject_filter []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.outlook_options.subject_filter[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.rabbitmq_options *pipelines.RabbitmqOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.rabbitmq_options.queue string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.rabbitmq_options.queue *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.reddit_ads_options *pipelines.RedditAdsOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.reddit_ads_options.custom_report_options *pipelines.RedditAdsOptionsRedditAdsCustomReportOptions ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.reddit_ads_options.custom_report_options *pipelines.RedditAdsOptions_RedditAdsCustomReportOptions ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.reddit_ads_options.custom_report_options.breakdowns []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.reddit_ads_options.custom_report_options.breakdowns[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.reddit_ads_options.custom_report_options.fields []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.reddit_ads_options.custom_report_options.fields[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.reddit_ads_options.lookback_window_days int ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.reddit_ads_options.sync_start_date string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.reddit_ads_options.lookback_window_days *int ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.reddit_ads_options.sync_start_date *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options *pipelines.SharepointOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.entity_type pipelines.SharepointOptionsSharepointEntityType ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.entity_type pipelines.SharepointOptions_SharepointEntityType ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options *pipelines.FileIngestionOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.corrupt_record_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.corrupt_record_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.file_filters []pipelines.FileFilter ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.file_filters[*] pipelines.FileFilter ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.file_filters[*].modified_after string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.file_filters[*].modified_before string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.file_filters[*].path_filter string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.format pipelines.FileIngestionOptionsFileFormat ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.file_filters[*].modified_after *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.file_filters[*].modified_before *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.file_filters[*].path_filter *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.format pipelines.FileIngestionOptions_FileFormat ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.format_options map[string]string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.format_options.* string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.ignore_corrupt_files bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.infer_column_types bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.reader_case_sensitive bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.rescued_data_column string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.schema_evolution_mode pipelines.FileIngestionOptionsSchemaEvolutionMode ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.schema_hints string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.single_variant_column string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.url string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.ignore_corrupt_files *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.infer_column_types *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.reader_case_sensitive *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.rescued_data_column *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.schema_evolution_mode pipelines.FileIngestionOptions_SchemaEvolutionMode ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.schema_hints *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.file_ingestion_options.single_variant_column *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.sharepoint_options.url *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.smartsheet_options *pipelines.SmartsheetOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.smartsheet_options.enforce_schema bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.smartsheet_options.enforce_schema *bool ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options *pipelines.TikTokAdsOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.custom_report_options *pipelines.TikTokAdsOptionsTikTokAdsCustomReportOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.custom_report_options.data_level pipelines.TikTokAdsOptionsTikTokDataLevel ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.custom_report_options *pipelines.TikTokAdsOptions_TikTokAdsCustomReportOptions ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.custom_report_options.data_level pipelines.TikTokAdsOptions_TikTokDataLevel ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.custom_report_options.dimensions []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.custom_report_options.dimensions[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.custom_report_options.metrics []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.custom_report_options.metrics[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.custom_report_options.query_lifetime bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.custom_report_options.report_type pipelines.TikTokAdsOptionsTikTokReportType ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.data_level pipelines.TikTokAdsOptionsTikTokDataLevel ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.custom_report_options.query_lifetime *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.custom_report_options.report_type pipelines.TikTokAdsOptions_TikTokReportType ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.data_level pipelines.TikTokAdsOptions_TikTokDataLevel ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.dimensions []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.dimensions[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.lookback_window_days int ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.lookback_window_days *int ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.metrics []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.metrics[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.query_lifetime bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.report_type pipelines.TikTokAdsOptionsTikTokReportType ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.sync_start_date string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.query_lifetime *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.report_type pipelines.TikTokAdsOptions_TikTokReportType ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.tiktok_ads_options.sync_start_date *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.zendesk_support_options *pipelines.ZendeskSupportOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.zendesk_support_options.start_date string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.destination_catalog string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.destination_schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options *pipelines.IngestionPipelineDefinitionFanoutOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.fanout_by string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.connector_options.zendesk_support_options.start_date *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.destination_catalog *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.destination_schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options *pipelines.IngestionPipelineDefinition_FanoutOptions ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.fanout_by *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms []pipelines.Transformer ALL resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*] pipelines.Transformer ALL resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options *pipelines.AvroTransformerOptions ALL resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.parse_mode pipelines.ParseMode ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.schema_file_path string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.schema_file_path *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.schema_registry *pipelines.SchemaRegistryConfig ALL resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.schema_registry.confluent_options *pipelines.ConfluentSchemaRegistryOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.schema_registry.confluent_options.subject string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.schema_registry.connection_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.schema_registry.protobuf_message_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].format pipelines.TransformerFormat ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].input_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.schema_registry.confluent_options.subject *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.schema_registry.connection_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].avro_options.schema_registry.protobuf_message_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].format pipelines.Transformer_Format ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].input_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].json_options *pipelines.JsonTransformerOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].json_options.as_variant bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].json_options.schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].json_options.schema_evolution_mode pipelines.FileIngestionOptionsSchemaEvolutionMode ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].json_options.schema_file_path string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].json_options.schema_hints string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].output_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].json_options.as_variant *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].json_options.schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].json_options.schema_evolution_mode pipelines.FileIngestionOptions_SchemaEvolutionMode ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].json_options.schema_file_path *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].json_options.schema_hints *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].output_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options *pipelines.ProtobufTransformerOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.desc_file_path string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.message_name string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.desc_file_path *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.message_name *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.parse_mode pipelines.ParseMode ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.recursive_fields_max_depth int ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.recursive_fields_max_depth *int ALL resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.schema_registry *pipelines.SchemaRegistryConfig ALL resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.schema_registry.confluent_options *pipelines.ConfluentSchemaRegistryOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.schema_registry.confluent_options.subject string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.schema_registry.connection_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.schema_registry.protobuf_message_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.source_catalog string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.source_schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration *pipelines.TableSpecificConfig ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.schema_registry.confluent_options.subject *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.schema_registry.connection_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.fanout_options.transforms[*].protobuf_options.schema_registry.protobuf_message_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.source_catalog *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.source_schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration *pipelines.IngestionPipelineDefinition_TableSpecificConfig ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.auto_full_refresh_policy *pipelines.AutoFullRefreshPolicy ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.auto_full_refresh_policy.enabled bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.auto_full_refresh_policy.min_interval_hours int ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.auto_full_refresh_policy.enabled *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.auto_full_refresh_policy.min_interval_hours *int ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.clustering_columns []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.clustering_columns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.enable_auto_clustering bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.enable_auto_clustering *bool ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.exclude_columns []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.exclude_columns[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.include_columns []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.include_columns[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.primary_keys []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.primary_keys[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.query_based_connector_config *pipelines.IngestionPipelineDefinitionTableSpecificConfigQueryBasedConnectorConfig ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.query_based_connector_config *pipelines.IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.query_based_connector_config.cursor_columns []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.query_based_connector_config.cursor_columns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.query_based_connector_config.deletion_condition string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.query_based_connector_config.hard_deletion_sync_min_interval_in_seconds int64 ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.row_filter string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.salesforce_include_formula_fields bool ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.scd_type pipelines.TableSpecificConfigScdType ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.query_based_connector_config.deletion_condition *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.query_based_connector_config.hard_deletion_sync_min_interval_in_seconds *int64 ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.row_filter *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.salesforce_include_formula_fields *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.scd_type pipelines.ScdType_ScdType ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.sequence_by []string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.sequence_by[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.source_metadata_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.source_metadata_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.table_properties map[string]string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.table_properties.* string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters *pipelines.IngestionPipelineDefinitionWorkdayReportParameters ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters.incremental bool ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters *pipelines.IngestionPipelineDefinition_WorkdayReportParameters ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters.incremental *bool ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters.parameters map[string]string ALL resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters.parameters.* string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters.report_parameters []pipelines.IngestionPipelineDefinitionWorkdayReportParametersQueryKeyValue ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters.report_parameters[*] pipelines.IngestionPipelineDefinitionWorkdayReportParametersQueryKeyValue ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters.report_parameters[*].key string ALL -resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters.report_parameters[*].value string ALL -resources.pipelines.*.ingestion_definition.objects[*].table *pipelines.TableSpec ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters.report_parameters []pipelines.IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters.report_parameters[*] pipelines.IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters.report_parameters[*].key *string ALL +resources.pipelines.*.ingestion_definition.objects[*].schema.table_configuration.workday_report_parameters.report_parameters[*].value *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table *pipelines.IngestionPipelineDefinition_TableSpec ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options *pipelines.ConnectorOptions ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.api_source_connector_options *pipelines.ApiSourceConnectorOptions ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.api_source_connector_options.options map[string]string ALL @@ -3391,37 +3590,37 @@ resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.co resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.confluence_options.include_confluence_spaces []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.confluence_options.include_confluence_spaces[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options *pipelines.GoogleDriveOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.entity_type pipelines.GoogleDriveOptionsGoogleDriveEntityType ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.entity_type pipelines.GoogleDriveOptions_GoogleDriveEntityType ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options *pipelines.FileIngestionOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.corrupt_record_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.corrupt_record_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.file_filters []pipelines.FileFilter ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.file_filters[*] pipelines.FileFilter ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.file_filters[*].modified_after string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.file_filters[*].modified_before string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.file_filters[*].path_filter string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.format pipelines.FileIngestionOptionsFileFormat ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.file_filters[*].modified_after *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.file_filters[*].modified_before *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.file_filters[*].path_filter *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.format pipelines.FileIngestionOptions_FileFormat ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.format_options map[string]string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.format_options.* string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.ignore_corrupt_files bool ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.infer_column_types bool ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.reader_case_sensitive bool ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.rescued_data_column string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.schema_evolution_mode pipelines.FileIngestionOptionsSchemaEvolutionMode ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.schema_hints string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.single_variant_column string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.url string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.ignore_corrupt_files *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.infer_column_types *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.reader_case_sensitive *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.rescued_data_column *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.schema_evolution_mode pipelines.FileIngestionOptions_SchemaEvolutionMode ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.schema_hints *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.file_ingestion_options.single_variant_column *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.gdrive_options.url *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options *pipelines.GoogleAdsOptions ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.custom_report_options *pipelines.GoogleAdsCustomReportOptions ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.custom_report_options.metrics []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.custom_report_options.metrics[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.custom_report_options.resource string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.custom_report_options.resource *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.custom_report_options.resource_fields []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.custom_report_options.resource_fields[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.custom_report_options.segments []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.custom_report_options.segments[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.lookback_window_days int ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.manager_account_id string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.sync_start_date string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.lookback_window_days *int ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.manager_account_id *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.google_ads_options.sync_start_date *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.jira_options *pipelines.JiraConnectorOptions ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.jira_options.include_jira_spaces []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.jira_options.include_jira_spaces[*] string ALL @@ -3431,100 +3630,100 @@ resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.ka resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer *pipelines.Transformer ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options *pipelines.AvroTransformerOptions ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.parse_mode pipelines.ParseMode ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.schema_file_path string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.schema_file_path *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.schema_registry *pipelines.SchemaRegistryConfig ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.schema_registry.confluent_options *pipelines.ConfluentSchemaRegistryOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.schema_registry.confluent_options.subject string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.schema_registry.connection_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.schema_registry.protobuf_message_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.format pipelines.TransformerFormat ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.input_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.schema_registry.confluent_options.subject *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.schema_registry.connection_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.avro_options.schema_registry.protobuf_message_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.format pipelines.Transformer_Format ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.input_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.json_options *pipelines.JsonTransformerOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.json_options.as_variant bool ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.json_options.schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.json_options.schema_evolution_mode pipelines.FileIngestionOptionsSchemaEvolutionMode ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.json_options.schema_file_path string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.json_options.schema_hints string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.output_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.json_options.as_variant *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.json_options.schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.json_options.schema_evolution_mode pipelines.FileIngestionOptions_SchemaEvolutionMode ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.json_options.schema_file_path *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.json_options.schema_hints *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.output_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options *pipelines.ProtobufTransformerOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.desc_file_path string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.message_name string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.desc_file_path *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.message_name *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.parse_mode pipelines.ParseMode ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.recursive_fields_max_depth int ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.recursive_fields_max_depth *int ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry *pipelines.SchemaRegistryConfig ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.confluent_options *pipelines.ConfluentSchemaRegistryOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.confluent_options.subject string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.connection_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.protobuf_message_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.max_offsets_per_trigger int64 ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.starting_offset string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.topic_pattern string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.confluent_options.subject *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.connection_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.key_transformer.protobuf_options.schema_registry.protobuf_message_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.max_offsets_per_trigger *int64 ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.starting_offset *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.topic_pattern *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.topics []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.topics[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer *pipelines.Transformer ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options *pipelines.AvroTransformerOptions ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.parse_mode pipelines.ParseMode ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.schema_file_path string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.schema_file_path *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.schema_registry *pipelines.SchemaRegistryConfig ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.schema_registry.confluent_options *pipelines.ConfluentSchemaRegistryOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.schema_registry.confluent_options.subject string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.schema_registry.connection_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.schema_registry.protobuf_message_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.format pipelines.TransformerFormat ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.input_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.schema_registry.confluent_options.subject *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.schema_registry.connection_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.avro_options.schema_registry.protobuf_message_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.format pipelines.Transformer_Format ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.input_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.json_options *pipelines.JsonTransformerOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.json_options.as_variant bool ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.json_options.schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.json_options.schema_evolution_mode pipelines.FileIngestionOptionsSchemaEvolutionMode ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.json_options.schema_file_path string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.json_options.schema_hints string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.output_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.json_options.as_variant *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.json_options.schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.json_options.schema_evolution_mode pipelines.FileIngestionOptions_SchemaEvolutionMode ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.json_options.schema_file_path *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.json_options.schema_hints *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.output_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options *pipelines.ProtobufTransformerOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.desc_file_path string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.message_name string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.desc_file_path *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.message_name *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.parse_mode pipelines.ParseMode ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.recursive_fields_max_depth int ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.recursive_fields_max_depth *int ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry *pipelines.SchemaRegistryConfig ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.confluent_options *pipelines.ConfluentSchemaRegistryOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.confluent_options.subject string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.connection_name string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.protobuf_message_name string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.confluent_options.subject *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.connection_name *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.kafka_options.value_transformer.protobuf_options.schema_registry.protobuf_message_name *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options *pipelines.LinkedInAdsOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.custom_report_options *pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.custom_report_options.entity_granularity []pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptionsLinkedInAdsEntityGranularity ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.custom_report_options.entity_granularity[*] pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptionsLinkedInAdsEntityGranularity ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.custom_report_options.finder pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptionsLinkedInAdsFinder ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.custom_report_options *pipelines.LinkedInAdsOptions_LinkedInAdsCustomReportOptions ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.custom_report_options.entity_granularity []pipelines.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.custom_report_options.entity_granularity[*] pipelines.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.custom_report_options.finder pipelines.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.custom_report_options.metrics []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.custom_report_options.metrics[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.custom_report_options.time_granularity pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptionsLinkedInAdsTimeGranularity ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.lookback_window_days int ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.sync_start_date string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.custom_report_options.time_granularity pipelines.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.lookback_window_days *int ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.linkedin_ads_options.sync_start_date *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.marketo_options *pipelines.MarketoOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.marketo_options.sync_start_date string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.marketo_options.sync_start_date *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options *pipelines.MetaMarketingOptions ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.action_attribution_windows []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.action_attribution_windows[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.action_breakdowns []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.action_breakdowns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.action_report_time string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.action_report_time *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.breakdowns []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.breakdowns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_insights_lookback_window int ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options *pipelines.MetaMarketingOptionsMetaMarketingCustomReportOptions ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_insights_lookback_window *int ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options *pipelines.MetaMarketingOptions_MetaMarketingCustomReportOptions ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options.action_attribution_windows []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options.action_attribution_windows[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options.action_breakdowns []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options.action_breakdowns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options.action_report_time string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options.action_report_time *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options.breakdowns []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options.breakdowns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options.level string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options.time_increment string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.level string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.start_date string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.time_increment string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options.level *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.custom_report_options.time_increment *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.level *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.start_date *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.meta_ads_options.time_increment *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.outlook_options *pipelines.OutlookOptions ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.outlook_options.attachment_mode pipelines.OutlookAttachmentMode ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.outlook_options.body_format pipelines.OutlookBodyFormat ALL @@ -3540,101 +3739,101 @@ resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.ou resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.outlook_options.include_subjects[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.outlook_options.sender_filter []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.outlook_options.sender_filter[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.outlook_options.start_date string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.outlook_options.start_date *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.outlook_options.subject_filter []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.outlook_options.subject_filter[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.rabbitmq_options *pipelines.RabbitmqOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.rabbitmq_options.queue string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.rabbitmq_options.queue *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.reddit_ads_options *pipelines.RedditAdsOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.reddit_ads_options.custom_report_options *pipelines.RedditAdsOptionsRedditAdsCustomReportOptions ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.reddit_ads_options.custom_report_options *pipelines.RedditAdsOptions_RedditAdsCustomReportOptions ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.reddit_ads_options.custom_report_options.breakdowns []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.reddit_ads_options.custom_report_options.breakdowns[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.reddit_ads_options.custom_report_options.fields []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.reddit_ads_options.custom_report_options.fields[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.reddit_ads_options.lookback_window_days int ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.reddit_ads_options.sync_start_date string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.reddit_ads_options.lookback_window_days *int ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.reddit_ads_options.sync_start_date *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options *pipelines.SharepointOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.entity_type pipelines.SharepointOptionsSharepointEntityType ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.entity_type pipelines.SharepointOptions_SharepointEntityType ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options *pipelines.FileIngestionOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.corrupt_record_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.corrupt_record_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.file_filters []pipelines.FileFilter ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.file_filters[*] pipelines.FileFilter ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.file_filters[*].modified_after string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.file_filters[*].modified_before string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.file_filters[*].path_filter string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.format pipelines.FileIngestionOptionsFileFormat ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.file_filters[*].modified_after *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.file_filters[*].modified_before *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.file_filters[*].path_filter *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.format pipelines.FileIngestionOptions_FileFormat ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.format_options map[string]string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.format_options.* string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.ignore_corrupt_files bool ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.infer_column_types bool ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.reader_case_sensitive bool ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.rescued_data_column string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.schema_evolution_mode pipelines.FileIngestionOptionsSchemaEvolutionMode ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.schema_hints string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.single_variant_column string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.url string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.ignore_corrupt_files *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.infer_column_types *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.reader_case_sensitive *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.rescued_data_column *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.schema_evolution_mode pipelines.FileIngestionOptions_SchemaEvolutionMode ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.schema_hints *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.file_ingestion_options.single_variant_column *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.sharepoint_options.url *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.smartsheet_options *pipelines.SmartsheetOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.smartsheet_options.enforce_schema bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.smartsheet_options.enforce_schema *bool ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options *pipelines.TikTokAdsOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.custom_report_options *pipelines.TikTokAdsOptionsTikTokAdsCustomReportOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.custom_report_options.data_level pipelines.TikTokAdsOptionsTikTokDataLevel ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.custom_report_options *pipelines.TikTokAdsOptions_TikTokAdsCustomReportOptions ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.custom_report_options.data_level pipelines.TikTokAdsOptions_TikTokDataLevel ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.custom_report_options.dimensions []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.custom_report_options.dimensions[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.custom_report_options.metrics []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.custom_report_options.metrics[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.custom_report_options.query_lifetime bool ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.custom_report_options.report_type pipelines.TikTokAdsOptionsTikTokReportType ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.data_level pipelines.TikTokAdsOptionsTikTokDataLevel ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.custom_report_options.query_lifetime *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.custom_report_options.report_type pipelines.TikTokAdsOptions_TikTokReportType ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.data_level pipelines.TikTokAdsOptions_TikTokDataLevel ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.dimensions []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.dimensions[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.lookback_window_days int ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.lookback_window_days *int ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.metrics []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.metrics[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.query_lifetime bool ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.report_type pipelines.TikTokAdsOptionsTikTokReportType ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.sync_start_date string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.query_lifetime *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.report_type pipelines.TikTokAdsOptions_TikTokReportType ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.tiktok_ads_options.sync_start_date *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.zendesk_support_options *pipelines.ZendeskSupportOptions ALL -resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.zendesk_support_options.start_date string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.destination_catalog string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.destination_schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.destination_table string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.source_catalog string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.source_schema string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.source_table string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration *pipelines.TableSpecificConfig ALL +resources.pipelines.*.ingestion_definition.objects[*].table.connector_options.zendesk_support_options.start_date *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.destination_catalog *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.destination_schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.destination_table *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.source_catalog *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.source_schema *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.source_table *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration *pipelines.IngestionPipelineDefinition_TableSpecificConfig ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.auto_full_refresh_policy *pipelines.AutoFullRefreshPolicy ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.auto_full_refresh_policy.enabled bool ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.auto_full_refresh_policy.min_interval_hours int ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.auto_full_refresh_policy.enabled *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.auto_full_refresh_policy.min_interval_hours *int ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.clustering_columns []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.clustering_columns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.enable_auto_clustering bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.enable_auto_clustering *bool ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.exclude_columns []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.exclude_columns[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.include_columns []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.include_columns[*] string ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.primary_keys []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.primary_keys[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.query_based_connector_config *pipelines.IngestionPipelineDefinitionTableSpecificConfigQueryBasedConnectorConfig ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.query_based_connector_config *pipelines.IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.query_based_connector_config.cursor_columns []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.query_based_connector_config.cursor_columns[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.query_based_connector_config.deletion_condition string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.query_based_connector_config.hard_deletion_sync_min_interval_in_seconds int64 ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.row_filter string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.salesforce_include_formula_fields bool ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.scd_type pipelines.TableSpecificConfigScdType ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.query_based_connector_config.deletion_condition *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.query_based_connector_config.hard_deletion_sync_min_interval_in_seconds *int64 ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.row_filter *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.salesforce_include_formula_fields *bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.scd_type pipelines.ScdType_ScdType ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.sequence_by []string ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.sequence_by[*] string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.source_metadata_column string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.source_metadata_column *string ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.table_properties map[string]string ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.table_properties.* string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters *pipelines.IngestionPipelineDefinitionWorkdayReportParameters ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters.incremental bool ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters *pipelines.IngestionPipelineDefinition_WorkdayReportParameters ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters.incremental *bool ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters.parameters map[string]string ALL resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters.parameters.* string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters.report_parameters []pipelines.IngestionPipelineDefinitionWorkdayReportParametersQueryKeyValue ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters.report_parameters[*] pipelines.IngestionPipelineDefinitionWorkdayReportParametersQueryKeyValue ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters.report_parameters[*].key string ALL -resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters.report_parameters[*].value string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters.report_parameters []pipelines.IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters.report_parameters[*] pipelines.IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters.report_parameters[*].key *string ALL +resources.pipelines.*.ingestion_definition.objects[*].table.table_configuration.workday_report_parameters.report_parameters[*].value *string ALL resources.pipelines.*.ingestion_definition.source_configurations []pipelines.SourceConfig ALL resources.pipelines.*.ingestion_definition.source_configurations[*] pipelines.SourceConfig ALL resources.pipelines.*.ingestion_definition.source_configurations[*].api_source_connector_config *pipelines.ApiSourceConnectorConfig ALL @@ -3643,71 +3842,71 @@ resources.pipelines.*.ingestion_definition.source_configurations[*].api_source_c resources.pipelines.*.ingestion_definition.source_configurations[*].catalog *pipelines.SourceCatalogConfig ALL resources.pipelines.*.ingestion_definition.source_configurations[*].catalog.postgres *pipelines.PostgresCatalogConfig ALL resources.pipelines.*.ingestion_definition.source_configurations[*].catalog.postgres.slot_config *pipelines.PostgresSlotConfig ALL -resources.pipelines.*.ingestion_definition.source_configurations[*].catalog.postgres.slot_config.publication_name string ALL -resources.pipelines.*.ingestion_definition.source_configurations[*].catalog.postgres.slot_config.slot_name string ALL -resources.pipelines.*.ingestion_definition.source_configurations[*].catalog.source_catalog string ALL +resources.pipelines.*.ingestion_definition.source_configurations[*].catalog.postgres.slot_config.publication_name *string ALL +resources.pipelines.*.ingestion_definition.source_configurations[*].catalog.postgres.slot_config.slot_name *string ALL +resources.pipelines.*.ingestion_definition.source_configurations[*].catalog.source_catalog *string ALL resources.pipelines.*.ingestion_definition.source_configurations[*].google_ads_config *pipelines.GoogleAdsConfig ALL -resources.pipelines.*.ingestion_definition.source_configurations[*].google_ads_config.manager_account_id string ALL +resources.pipelines.*.ingestion_definition.source_configurations[*].google_ads_config.manager_account_id *string ALL resources.pipelines.*.ingestion_definition.source_type pipelines.IngestionSourceType ALL -resources.pipelines.*.ingestion_definition.table_configuration *pipelines.TableSpecificConfig ALL +resources.pipelines.*.ingestion_definition.table_configuration *pipelines.IngestionPipelineDefinition_TableSpecificConfig ALL resources.pipelines.*.ingestion_definition.table_configuration.auto_full_refresh_policy *pipelines.AutoFullRefreshPolicy ALL -resources.pipelines.*.ingestion_definition.table_configuration.auto_full_refresh_policy.enabled bool ALL -resources.pipelines.*.ingestion_definition.table_configuration.auto_full_refresh_policy.min_interval_hours int ALL +resources.pipelines.*.ingestion_definition.table_configuration.auto_full_refresh_policy.enabled *bool ALL +resources.pipelines.*.ingestion_definition.table_configuration.auto_full_refresh_policy.min_interval_hours *int ALL resources.pipelines.*.ingestion_definition.table_configuration.clustering_columns []string ALL resources.pipelines.*.ingestion_definition.table_configuration.clustering_columns[*] string ALL -resources.pipelines.*.ingestion_definition.table_configuration.enable_auto_clustering bool ALL +resources.pipelines.*.ingestion_definition.table_configuration.enable_auto_clustering *bool ALL resources.pipelines.*.ingestion_definition.table_configuration.exclude_columns []string ALL resources.pipelines.*.ingestion_definition.table_configuration.exclude_columns[*] string ALL resources.pipelines.*.ingestion_definition.table_configuration.include_columns []string ALL resources.pipelines.*.ingestion_definition.table_configuration.include_columns[*] string ALL resources.pipelines.*.ingestion_definition.table_configuration.primary_keys []string ALL resources.pipelines.*.ingestion_definition.table_configuration.primary_keys[*] string ALL -resources.pipelines.*.ingestion_definition.table_configuration.query_based_connector_config *pipelines.IngestionPipelineDefinitionTableSpecificConfigQueryBasedConnectorConfig ALL +resources.pipelines.*.ingestion_definition.table_configuration.query_based_connector_config *pipelines.IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig ALL resources.pipelines.*.ingestion_definition.table_configuration.query_based_connector_config.cursor_columns []string ALL resources.pipelines.*.ingestion_definition.table_configuration.query_based_connector_config.cursor_columns[*] string ALL -resources.pipelines.*.ingestion_definition.table_configuration.query_based_connector_config.deletion_condition string ALL -resources.pipelines.*.ingestion_definition.table_configuration.query_based_connector_config.hard_deletion_sync_min_interval_in_seconds int64 ALL -resources.pipelines.*.ingestion_definition.table_configuration.row_filter string ALL -resources.pipelines.*.ingestion_definition.table_configuration.salesforce_include_formula_fields bool ALL -resources.pipelines.*.ingestion_definition.table_configuration.scd_type pipelines.TableSpecificConfigScdType ALL +resources.pipelines.*.ingestion_definition.table_configuration.query_based_connector_config.deletion_condition *string ALL +resources.pipelines.*.ingestion_definition.table_configuration.query_based_connector_config.hard_deletion_sync_min_interval_in_seconds *int64 ALL +resources.pipelines.*.ingestion_definition.table_configuration.row_filter *string ALL +resources.pipelines.*.ingestion_definition.table_configuration.salesforce_include_formula_fields *bool ALL +resources.pipelines.*.ingestion_definition.table_configuration.scd_type pipelines.ScdType_ScdType ALL resources.pipelines.*.ingestion_definition.table_configuration.sequence_by []string ALL resources.pipelines.*.ingestion_definition.table_configuration.sequence_by[*] string ALL -resources.pipelines.*.ingestion_definition.table_configuration.source_metadata_column string ALL +resources.pipelines.*.ingestion_definition.table_configuration.source_metadata_column *string ALL resources.pipelines.*.ingestion_definition.table_configuration.table_properties map[string]string ALL resources.pipelines.*.ingestion_definition.table_configuration.table_properties.* string ALL -resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters *pipelines.IngestionPipelineDefinitionWorkdayReportParameters ALL -resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters.incremental bool ALL +resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters *pipelines.IngestionPipelineDefinition_WorkdayReportParameters ALL +resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters.incremental *bool ALL resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters.parameters map[string]string ALL resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters.parameters.* string ALL -resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters.report_parameters []pipelines.IngestionPipelineDefinitionWorkdayReportParametersQueryKeyValue ALL -resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters.report_parameters[*] pipelines.IngestionPipelineDefinitionWorkdayReportParametersQueryKeyValue ALL -resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters.report_parameters[*].key string ALL -resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters.report_parameters[*].value string ALL -resources.pipelines.*.last_modified int64 REMOTE +resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters.report_parameters []pipelines.IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue ALL +resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters.report_parameters[*] pipelines.IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue ALL +resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters.report_parameters[*].key *string ALL +resources.pipelines.*.ingestion_definition.table_configuration.workday_report_parameters.report_parameters[*].value *string ALL +resources.pipelines.*.last_modified *int64 REMOTE resources.pipelines.*.latest_updates []pipelines.UpdateStateInfo REMOTE resources.pipelines.*.latest_updates[*] pipelines.UpdateStateInfo REMOTE -resources.pipelines.*.latest_updates[*].creation_time string REMOTE -resources.pipelines.*.latest_updates[*].state pipelines.UpdateStateInfoState REMOTE -resources.pipelines.*.latest_updates[*].update_id string REMOTE +resources.pipelines.*.latest_updates[*].creation_time *string REMOTE +resources.pipelines.*.latest_updates[*].state pipelines.UpdateState REMOTE +resources.pipelines.*.latest_updates[*].update_id *string REMOTE resources.pipelines.*.libraries []pipelines.PipelineLibrary ALL resources.pipelines.*.libraries[*] pipelines.PipelineLibrary ALL -resources.pipelines.*.libraries[*].file *pipelines.FileLibrary ALL -resources.pipelines.*.libraries[*].file.path string ALL +resources.pipelines.*.libraries[*].file *pipelines.NotebookLibrary ALL +resources.pipelines.*.libraries[*].file.path *string ALL resources.pipelines.*.libraries[*].glob *pipelines.PathPattern ALL -resources.pipelines.*.libraries[*].glob.include string ALL -resources.pipelines.*.libraries[*].jar string ALL -resources.pipelines.*.libraries[*].maven *compute.MavenLibrary ALL -resources.pipelines.*.libraries[*].maven.coordinates string ALL +resources.pipelines.*.libraries[*].glob.include *string ALL +resources.pipelines.*.libraries[*].jar *string ALL +resources.pipelines.*.libraries[*].maven *pipelines.PipelinesMavenLibrary ALL +resources.pipelines.*.libraries[*].maven.coordinates *string ALL resources.pipelines.*.libraries[*].maven.exclusions []string ALL resources.pipelines.*.libraries[*].maven.exclusions[*] string ALL -resources.pipelines.*.libraries[*].maven.repo string ALL +resources.pipelines.*.libraries[*].maven.repo *string ALL resources.pipelines.*.libraries[*].notebook *pipelines.NotebookLibrary ALL -resources.pipelines.*.libraries[*].notebook.path string ALL -resources.pipelines.*.libraries[*].whl string ALL +resources.pipelines.*.libraries[*].notebook.path *string ALL +resources.pipelines.*.libraries[*].whl *string ALL resources.pipelines.*.lifecycle resources.Lifecycle INPUT resources.pipelines.*.lifecycle.prevent_destroy bool INPUT resources.pipelines.*.modified_status string INPUT -resources.pipelines.*.name string ALL +resources.pipelines.*.name *string ALL resources.pipelines.*.notifications []pipelines.Notifications ALL resources.pipelines.*.notifications[*] pipelines.Notifications ALL resources.pipelines.*.notifications[*].alerts []string ALL @@ -3716,95 +3915,95 @@ resources.pipelines.*.notifications[*].email_recipients []string ALL resources.pipelines.*.notifications[*].email_recipients[*] string ALL resources.pipelines.*.parameters map[string]string ALL resources.pipelines.*.parameters.* string ALL -resources.pipelines.*.parent_path string ALL -resources.pipelines.*.photon bool ALL -resources.pipelines.*.pipeline_id string REMOTE +resources.pipelines.*.parent_path *string ALL +resources.pipelines.*.photon *bool ALL +resources.pipelines.*.pipeline_id *string REMOTE resources.pipelines.*.restart_window *pipelines.RestartWindow ALL resources.pipelines.*.restart_window.days_of_week []pipelines.DayOfWeek ALL resources.pipelines.*.restart_window.days_of_week[*] pipelines.DayOfWeek ALL -resources.pipelines.*.restart_window.start_hour int ALL -resources.pipelines.*.restart_window.time_zone_id string ALL -resources.pipelines.*.root_path string ALL -resources.pipelines.*.run_as *pipelines.RunAs ALL -resources.pipelines.*.run_as.group_name string ALL -resources.pipelines.*.run_as.service_principal_name string ALL -resources.pipelines.*.run_as.user_name string ALL -resources.pipelines.*.run_as_user_name string REMOTE -resources.pipelines.*.schema string ALL -resources.pipelines.*.serverless bool ALL -resources.pipelines.*.serverless_compute_id string ALL -resources.pipelines.*.state pipelines.PipelineState REMOTE -resources.pipelines.*.storage string ALL +resources.pipelines.*.restart_window.start_hour *int ALL +resources.pipelines.*.restart_window.time_zone_id *string ALL +resources.pipelines.*.root_path *string ALL +resources.pipelines.*.run_as *pipelines.PipelinesJobRunAs ALL +resources.pipelines.*.run_as.group_name *string ALL +resources.pipelines.*.run_as.service_principal_name *string ALL +resources.pipelines.*.run_as.user_name *string ALL +resources.pipelines.*.run_as_user_name *string REMOTE +resources.pipelines.*.schema *string ALL +resources.pipelines.*.serverless *bool ALL +resources.pipelines.*.serverless_compute_id *string ALL +resources.pipelines.*.state pipelines.PipelineState_PipelineState REMOTE +resources.pipelines.*.storage *string ALL resources.pipelines.*.tags map[string]string ALL resources.pipelines.*.tags.* string ALL -resources.pipelines.*.target string ALL +resources.pipelines.*.target *string ALL resources.pipelines.*.trigger *pipelines.PipelineTrigger ALL resources.pipelines.*.trigger.cron *pipelines.CronTrigger ALL -resources.pipelines.*.trigger.cron.quartz_cron_schedule string ALL -resources.pipelines.*.trigger.cron.timezone_id string ALL +resources.pipelines.*.trigger.cron.quartz_cron_schedule *string ALL +resources.pipelines.*.trigger.cron.timezone_id *string ALL resources.pipelines.*.trigger.manual *pipelines.ManualTrigger ALL resources.pipelines.*.url string INPUT -resources.pipelines.*.usage_policy_id string ALL +resources.pipelines.*.usage_policy_id *string ALL resources.pipelines.*.permissions.object_id string ALL resources.pipelines.*.permissions[*] dresources.StatePermission ALL resources.pipelines.*.permissions[*].group_name string ALL -resources.pipelines.*.permissions[*].level iam.PermissionLevel ALL +resources.pipelines.*.permissions[*].level resources.PermissionLevel ALL resources.pipelines.*.permissions[*].service_principal_name string ALL resources.pipelines.*.permissions[*].user_name string ALL resources.postgres_branches.*.branch_id string ALL -resources.postgres_branches.*.create_time *time.Time REMOTE -resources.postgres_branches.*.expire_time *time.Time ALL +resources.postgres_branches.*.create_time *types.Time REMOTE +resources.postgres_branches.*.expire_time *types.Time ALL resources.postgres_branches.*.id string INPUT -resources.postgres_branches.*.is_protected bool ALL +resources.postgres_branches.*.is_protected *bool ALL resources.postgres_branches.*.lifecycle resources.Lifecycle INPUT resources.postgres_branches.*.lifecycle.prevent_destroy bool INPUT resources.postgres_branches.*.modified_status string INPUT resources.postgres_branches.*.name string REMOTE -resources.postgres_branches.*.no_expiry bool ALL +resources.postgres_branches.*.no_expiry *bool ALL resources.postgres_branches.*.parent string ALL -resources.postgres_branches.*.purge_on_delete bool INPUT STATE +resources.postgres_branches.*.purge_on_delete *bool INPUT STATE resources.postgres_branches.*.replace_existing bool INPUT STATE -resources.postgres_branches.*.source_branch string ALL -resources.postgres_branches.*.source_branch_lsn string ALL -resources.postgres_branches.*.source_branch_time *time.Time ALL -resources.postgres_branches.*.source_snapshot string ALL +resources.postgres_branches.*.source_branch *string ALL +resources.postgres_branches.*.source_branch_lsn *string ALL +resources.postgres_branches.*.source_branch_time *types.Time ALL +resources.postgres_branches.*.source_snapshot *string ALL resources.postgres_branches.*.status *postgres.BranchStatus REMOTE -resources.postgres_branches.*.status.branch_id string REMOTE -resources.postgres_branches.*.status.current_state postgres.BranchStatusState REMOTE -resources.postgres_branches.*.status.default bool REMOTE -resources.postgres_branches.*.status.delete_time *time.Time REMOTE -resources.postgres_branches.*.status.expire_time *time.Time REMOTE -resources.postgres_branches.*.status.is_protected bool REMOTE -resources.postgres_branches.*.status.logical_size_bytes int64 REMOTE -resources.postgres_branches.*.status.pending_state postgres.BranchStatusState REMOTE -resources.postgres_branches.*.status.purge_time *time.Time REMOTE -resources.postgres_branches.*.status.source_branch string REMOTE -resources.postgres_branches.*.status.source_branch_lsn string REMOTE -resources.postgres_branches.*.status.source_branch_time *time.Time REMOTE -resources.postgres_branches.*.status.source_snapshot string REMOTE -resources.postgres_branches.*.status.state_change_time *time.Time REMOTE -resources.postgres_branches.*.ttl *duration.Duration ALL +resources.postgres_branches.*.status.branch_id *string REMOTE +resources.postgres_branches.*.status.current_state postgres.BranchStatus_State REMOTE +resources.postgres_branches.*.status.default *bool REMOTE +resources.postgres_branches.*.status.delete_time *types.Time REMOTE +resources.postgres_branches.*.status.expire_time *types.Time REMOTE +resources.postgres_branches.*.status.is_protected *bool REMOTE +resources.postgres_branches.*.status.logical_size_bytes *int64 REMOTE +resources.postgres_branches.*.status.pending_state postgres.BranchStatus_State REMOTE +resources.postgres_branches.*.status.purge_time *types.Time REMOTE +resources.postgres_branches.*.status.source_branch *string REMOTE +resources.postgres_branches.*.status.source_branch_lsn *string REMOTE +resources.postgres_branches.*.status.source_branch_time *types.Time REMOTE +resources.postgres_branches.*.status.source_snapshot *string REMOTE +resources.postgres_branches.*.status.state_change_time *types.Time REMOTE +resources.postgres_branches.*.ttl *types.Duration ALL resources.postgres_branches.*.uid string REMOTE -resources.postgres_branches.*.update_time *time.Time REMOTE +resources.postgres_branches.*.update_time *types.Time REMOTE resources.postgres_branches.*.url string INPUT -resources.postgres_catalogs.*.branch string ALL +resources.postgres_catalogs.*.branch *string ALL resources.postgres_catalogs.*.catalog_id string ALL -resources.postgres_catalogs.*.create_database_if_missing bool ALL -resources.postgres_catalogs.*.create_time *time.Time REMOTE +resources.postgres_catalogs.*.create_database_if_missing *bool ALL +resources.postgres_catalogs.*.create_time *types.Time REMOTE resources.postgres_catalogs.*.id string INPUT resources.postgres_catalogs.*.lifecycle resources.Lifecycle INPUT resources.postgres_catalogs.*.lifecycle.prevent_destroy bool INPUT resources.postgres_catalogs.*.modified_status string INPUT resources.postgres_catalogs.*.name string REMOTE -resources.postgres_catalogs.*.postgres_database string ALL -resources.postgres_catalogs.*.status *postgres.CatalogCatalogStatus REMOTE -resources.postgres_catalogs.*.status.branch string REMOTE -resources.postgres_catalogs.*.status.postgres_database string REMOTE -resources.postgres_catalogs.*.status.project string REMOTE +resources.postgres_catalogs.*.postgres_database *string ALL +resources.postgres_catalogs.*.status *postgres.Catalog_CatalogStatus REMOTE +resources.postgres_catalogs.*.status.branch *string REMOTE +resources.postgres_catalogs.*.status.postgres_database *string REMOTE +resources.postgres_catalogs.*.status.project *string REMOTE resources.postgres_catalogs.*.uid string REMOTE -resources.postgres_catalogs.*.update_time *time.Time REMOTE +resources.postgres_catalogs.*.update_time *types.Time REMOTE resources.postgres_catalogs.*.url string INPUT -resources.postgres_databases.*.create_time *time.Time REMOTE +resources.postgres_databases.*.create_time *types.Time REMOTE resources.postgres_databases.*.database_id string ALL resources.postgres_databases.*.id string INPUT resources.postgres_databases.*.lifecycle resources.Lifecycle INPUT @@ -3812,160 +4011,160 @@ resources.postgres_databases.*.lifecycle.prevent_destroy bool INPUT resources.postgres_databases.*.modified_status string INPUT resources.postgres_databases.*.name string REMOTE resources.postgres_databases.*.parent string ALL -resources.postgres_databases.*.postgres_database string ALL +resources.postgres_databases.*.postgres_database *string ALL resources.postgres_databases.*.replace_existing bool INPUT STATE -resources.postgres_databases.*.role string ALL -resources.postgres_databases.*.status *postgres.DatabaseDatabaseStatus REMOTE -resources.postgres_databases.*.status.database_id string REMOTE -resources.postgres_databases.*.status.postgres_database string REMOTE -resources.postgres_databases.*.status.role string REMOTE -resources.postgres_databases.*.update_time *time.Time REMOTE +resources.postgres_databases.*.role *string ALL +resources.postgres_databases.*.status *postgres.Database_DatabaseStatus REMOTE +resources.postgres_databases.*.status.database_id *string REMOTE +resources.postgres_databases.*.status.postgres_database *string REMOTE +resources.postgres_databases.*.status.role *string REMOTE +resources.postgres_databases.*.update_time *types.Time REMOTE resources.postgres_databases.*.url string INPUT -resources.postgres_endpoints.*.autoscaling_limit_max_cu float64 ALL -resources.postgres_endpoints.*.autoscaling_limit_min_cu float64 ALL -resources.postgres_endpoints.*.create_time *time.Time REMOTE -resources.postgres_endpoints.*.disabled bool ALL +resources.postgres_endpoints.*.autoscaling_limit_max_cu *float64 ALL +resources.postgres_endpoints.*.autoscaling_limit_min_cu *float64 ALL +resources.postgres_endpoints.*.create_time *types.Time REMOTE +resources.postgres_endpoints.*.disabled *bool ALL resources.postgres_endpoints.*.endpoint_id string ALL resources.postgres_endpoints.*.endpoint_type postgres.EndpointType ALL resources.postgres_endpoints.*.group *postgres.EndpointGroupSpec ALL -resources.postgres_endpoints.*.group.enable_readable_secondaries bool ALL -resources.postgres_endpoints.*.group.max int ALL -resources.postgres_endpoints.*.group.min int ALL +resources.postgres_endpoints.*.group.enable_readable_secondaries *bool ALL +resources.postgres_endpoints.*.group.max *int ALL +resources.postgres_endpoints.*.group.min *int ALL resources.postgres_endpoints.*.id string INPUT resources.postgres_endpoints.*.lifecycle resources.Lifecycle INPUT resources.postgres_endpoints.*.lifecycle.prevent_destroy bool INPUT resources.postgres_endpoints.*.modified_status string INPUT resources.postgres_endpoints.*.name string REMOTE -resources.postgres_endpoints.*.no_suspension bool ALL +resources.postgres_endpoints.*.no_suspension *bool ALL resources.postgres_endpoints.*.parent string ALL resources.postgres_endpoints.*.replace_existing bool INPUT STATE resources.postgres_endpoints.*.settings *postgres.EndpointSettings ALL resources.postgres_endpoints.*.settings.pg_settings map[string]string ALL resources.postgres_endpoints.*.settings.pg_settings.* string ALL resources.postgres_endpoints.*.status *postgres.EndpointStatus REMOTE -resources.postgres_endpoints.*.status.autoscaling_limit_max_cu float64 REMOTE -resources.postgres_endpoints.*.status.autoscaling_limit_min_cu float64 REMOTE -resources.postgres_endpoints.*.status.current_state postgres.EndpointStatusState REMOTE -resources.postgres_endpoints.*.status.disabled bool REMOTE -resources.postgres_endpoints.*.status.endpoint_id string REMOTE +resources.postgres_endpoints.*.status.autoscaling_limit_max_cu *float64 REMOTE +resources.postgres_endpoints.*.status.autoscaling_limit_min_cu *float64 REMOTE +resources.postgres_endpoints.*.status.current_state postgres.EndpointStatus_State REMOTE +resources.postgres_endpoints.*.status.disabled *bool REMOTE +resources.postgres_endpoints.*.status.endpoint_id *string REMOTE resources.postgres_endpoints.*.status.endpoint_type postgres.EndpointType REMOTE resources.postgres_endpoints.*.status.group *postgres.EndpointGroupStatus REMOTE -resources.postgres_endpoints.*.status.group.enable_readable_secondaries bool REMOTE -resources.postgres_endpoints.*.status.group.max int REMOTE -resources.postgres_endpoints.*.status.group.min int REMOTE +resources.postgres_endpoints.*.status.group.enable_readable_secondaries *bool REMOTE +resources.postgres_endpoints.*.status.group.max *int REMOTE +resources.postgres_endpoints.*.status.group.min *int REMOTE resources.postgres_endpoints.*.status.hosts *postgres.EndpointHosts REMOTE -resources.postgres_endpoints.*.status.hosts.host string REMOTE -resources.postgres_endpoints.*.status.hosts.read_only_host string REMOTE -resources.postgres_endpoints.*.status.hosts.read_only_pooled_host string REMOTE -resources.postgres_endpoints.*.status.hosts.read_write_pooled_host string REMOTE -resources.postgres_endpoints.*.status.last_active_time *time.Time REMOTE -resources.postgres_endpoints.*.status.pending_state postgres.EndpointStatusState REMOTE +resources.postgres_endpoints.*.status.hosts.host *string REMOTE +resources.postgres_endpoints.*.status.hosts.read_only_host *string REMOTE +resources.postgres_endpoints.*.status.hosts.read_only_pooled_host *string REMOTE +resources.postgres_endpoints.*.status.hosts.read_write_pooled_host *string REMOTE +resources.postgres_endpoints.*.status.last_active_time *types.Time REMOTE +resources.postgres_endpoints.*.status.pending_state postgres.EndpointStatus_State REMOTE resources.postgres_endpoints.*.status.settings *postgres.EndpointSettings REMOTE resources.postgres_endpoints.*.status.settings.pg_settings map[string]string REMOTE resources.postgres_endpoints.*.status.settings.pg_settings.* string REMOTE -resources.postgres_endpoints.*.status.suspend_timeout_duration *duration.Duration REMOTE -resources.postgres_endpoints.*.suspend_timeout_duration *duration.Duration ALL +resources.postgres_endpoints.*.status.suspend_timeout_duration *types.Duration REMOTE +resources.postgres_endpoints.*.suspend_timeout_duration *types.Duration ALL resources.postgres_endpoints.*.uid string REMOTE -resources.postgres_endpoints.*.update_time *time.Time REMOTE +resources.postgres_endpoints.*.update_time *types.Time REMOTE resources.postgres_endpoints.*.url string INPUT -resources.postgres_projects.*.budget_policy_id string ALL -resources.postgres_projects.*.create_time *time.Time REMOTE +resources.postgres_projects.*.budget_policy_id *string ALL +resources.postgres_projects.*.create_time *types.Time REMOTE resources.postgres_projects.*.custom_tags []postgres.ProjectCustomTag ALL resources.postgres_projects.*.custom_tags[*] postgres.ProjectCustomTag ALL -resources.postgres_projects.*.custom_tags[*].key string ALL -resources.postgres_projects.*.custom_tags[*].value string ALL -resources.postgres_projects.*.default_branch string ALL +resources.postgres_projects.*.custom_tags[*].key *string ALL +resources.postgres_projects.*.custom_tags[*].value *string ALL +resources.postgres_projects.*.default_branch *string ALL resources.postgres_projects.*.default_endpoint_settings *postgres.ProjectDefaultEndpointSettings ALL -resources.postgres_projects.*.default_endpoint_settings.autoscaling_limit_max_cu float64 ALL -resources.postgres_projects.*.default_endpoint_settings.autoscaling_limit_min_cu float64 ALL -resources.postgres_projects.*.default_endpoint_settings.no_suspension bool ALL +resources.postgres_projects.*.default_endpoint_settings.autoscaling_limit_max_cu *float64 ALL +resources.postgres_projects.*.default_endpoint_settings.autoscaling_limit_min_cu *float64 ALL +resources.postgres_projects.*.default_endpoint_settings.no_suspension *bool ALL resources.postgres_projects.*.default_endpoint_settings.pg_settings map[string]string ALL resources.postgres_projects.*.default_endpoint_settings.pg_settings.* string ALL -resources.postgres_projects.*.default_endpoint_settings.suspend_timeout_duration *duration.Duration ALL -resources.postgres_projects.*.delete_time *time.Time REMOTE -resources.postgres_projects.*.display_name string ALL -resources.postgres_projects.*.enable_pg_native_login bool ALL -resources.postgres_projects.*.history_retention_duration *duration.Duration ALL +resources.postgres_projects.*.default_endpoint_settings.suspend_timeout_duration *types.Duration ALL +resources.postgres_projects.*.delete_time *types.Time REMOTE +resources.postgres_projects.*.display_name *string ALL +resources.postgres_projects.*.enable_pg_native_login *bool ALL +resources.postgres_projects.*.history_retention_duration *types.Duration ALL resources.postgres_projects.*.id string INPUT resources.postgres_projects.*.initial_endpoint_spec *postgres.InitialEndpointSpec REMOTE -resources.postgres_projects.*.initial_endpoint_spec.autoscaling_limit_max_cu float64 REMOTE -resources.postgres_projects.*.initial_endpoint_spec.autoscaling_limit_min_cu float64 REMOTE +resources.postgres_projects.*.initial_endpoint_spec.autoscaling_limit_max_cu *float64 REMOTE +resources.postgres_projects.*.initial_endpoint_spec.autoscaling_limit_min_cu *float64 REMOTE resources.postgres_projects.*.initial_endpoint_spec.group *postgres.EndpointGroupSpec REMOTE -resources.postgres_projects.*.initial_endpoint_spec.group.enable_readable_secondaries bool REMOTE -resources.postgres_projects.*.initial_endpoint_spec.group.max int REMOTE -resources.postgres_projects.*.initial_endpoint_spec.group.min int REMOTE -resources.postgres_projects.*.initial_endpoint_spec.no_suspension bool REMOTE -resources.postgres_projects.*.initial_endpoint_spec.suspend_timeout_duration *duration.Duration REMOTE +resources.postgres_projects.*.initial_endpoint_spec.group.enable_readable_secondaries *bool REMOTE +resources.postgres_projects.*.initial_endpoint_spec.group.max *int REMOTE +resources.postgres_projects.*.initial_endpoint_spec.group.min *int REMOTE +resources.postgres_projects.*.initial_endpoint_spec.no_suspension *bool REMOTE +resources.postgres_projects.*.initial_endpoint_spec.suspend_timeout_duration *types.Duration REMOTE resources.postgres_projects.*.lifecycle resources.Lifecycle INPUT resources.postgres_projects.*.lifecycle.prevent_destroy bool INPUT resources.postgres_projects.*.modified_status string INPUT resources.postgres_projects.*.name string REMOTE -resources.postgres_projects.*.pg_version int ALL +resources.postgres_projects.*.pg_version *int ALL resources.postgres_projects.*.project_id string ALL -resources.postgres_projects.*.purge_on_delete bool INPUT STATE -resources.postgres_projects.*.purge_time *time.Time REMOTE +resources.postgres_projects.*.purge_on_delete *bool INPUT STATE +resources.postgres_projects.*.purge_time *types.Time REMOTE resources.postgres_projects.*.status *postgres.ProjectStatus REMOTE -resources.postgres_projects.*.status.branch_logical_size_limit_bytes int64 REMOTE -resources.postgres_projects.*.status.budget_policy_id string REMOTE -resources.postgres_projects.*.status.compute_last_active_time *time.Time REMOTE +resources.postgres_projects.*.status.branch_logical_size_limit_bytes *int64 REMOTE +resources.postgres_projects.*.status.budget_policy_id *string REMOTE +resources.postgres_projects.*.status.compute_last_active_time *types.Time REMOTE resources.postgres_projects.*.status.custom_tags []postgres.ProjectCustomTag REMOTE resources.postgres_projects.*.status.custom_tags[*] postgres.ProjectCustomTag REMOTE -resources.postgres_projects.*.status.custom_tags[*].key string REMOTE -resources.postgres_projects.*.status.custom_tags[*].value string REMOTE -resources.postgres_projects.*.status.default_branch string REMOTE +resources.postgres_projects.*.status.custom_tags[*].key *string REMOTE +resources.postgres_projects.*.status.custom_tags[*].value *string REMOTE +resources.postgres_projects.*.status.default_branch *string REMOTE resources.postgres_projects.*.status.default_endpoint_settings *postgres.ProjectDefaultEndpointSettings REMOTE -resources.postgres_projects.*.status.default_endpoint_settings.autoscaling_limit_max_cu float64 REMOTE -resources.postgres_projects.*.status.default_endpoint_settings.autoscaling_limit_min_cu float64 REMOTE -resources.postgres_projects.*.status.default_endpoint_settings.no_suspension bool REMOTE +resources.postgres_projects.*.status.default_endpoint_settings.autoscaling_limit_max_cu *float64 REMOTE +resources.postgres_projects.*.status.default_endpoint_settings.autoscaling_limit_min_cu *float64 REMOTE +resources.postgres_projects.*.status.default_endpoint_settings.no_suspension *bool REMOTE resources.postgres_projects.*.status.default_endpoint_settings.pg_settings map[string]string REMOTE resources.postgres_projects.*.status.default_endpoint_settings.pg_settings.* string REMOTE -resources.postgres_projects.*.status.default_endpoint_settings.suspend_timeout_duration *duration.Duration REMOTE -resources.postgres_projects.*.status.display_name string REMOTE -resources.postgres_projects.*.status.enable_pg_native_login bool REMOTE -resources.postgres_projects.*.status.history_retention_duration *duration.Duration REMOTE -resources.postgres_projects.*.status.owner string REMOTE -resources.postgres_projects.*.status.pg_version int REMOTE -resources.postgres_projects.*.status.project_id string REMOTE -resources.postgres_projects.*.status.synthetic_storage_size_bytes int64 REMOTE +resources.postgres_projects.*.status.default_endpoint_settings.suspend_timeout_duration *types.Duration REMOTE +resources.postgres_projects.*.status.display_name *string REMOTE +resources.postgres_projects.*.status.enable_pg_native_login *bool REMOTE +resources.postgres_projects.*.status.history_retention_duration *types.Duration REMOTE +resources.postgres_projects.*.status.owner *string REMOTE +resources.postgres_projects.*.status.pg_version *int REMOTE +resources.postgres_projects.*.status.project_id *string REMOTE +resources.postgres_projects.*.status.synthetic_storage_size_bytes *int64 REMOTE resources.postgres_projects.*.uid string REMOTE -resources.postgres_projects.*.update_time *time.Time REMOTE +resources.postgres_projects.*.update_time *types.Time REMOTE resources.postgres_projects.*.url string INPUT resources.postgres_projects.*.permissions.object_id string ALL resources.postgres_projects.*.permissions[*] dresources.StatePermission ALL resources.postgres_projects.*.permissions[*].group_name string ALL -resources.postgres_projects.*.permissions[*].level iam.PermissionLevel ALL +resources.postgres_projects.*.permissions[*].level resources.PermissionLevel ALL resources.postgres_projects.*.permissions[*].service_principal_name string ALL resources.postgres_projects.*.permissions[*].user_name string ALL -resources.postgres_roles.*.attributes *postgres.RoleAttributes ALL -resources.postgres_roles.*.attributes.bypassrls bool ALL -resources.postgres_roles.*.attributes.createdb bool ALL -resources.postgres_roles.*.attributes.createrole bool ALL -resources.postgres_roles.*.auth_method postgres.RoleAuthMethod ALL -resources.postgres_roles.*.create_time *time.Time REMOTE +resources.postgres_roles.*.attributes *postgres.Role_Attributes ALL +resources.postgres_roles.*.attributes.bypassrls *bool ALL +resources.postgres_roles.*.attributes.createdb *bool ALL +resources.postgres_roles.*.attributes.createrole *bool ALL +resources.postgres_roles.*.auth_method postgres.Role_AuthMethod ALL +resources.postgres_roles.*.create_time *types.Time REMOTE resources.postgres_roles.*.id string INPUT -resources.postgres_roles.*.identity_type postgres.RoleIdentityType ALL +resources.postgres_roles.*.identity_type postgres.Role_IdentityType ALL resources.postgres_roles.*.lifecycle resources.Lifecycle INPUT resources.postgres_roles.*.lifecycle.prevent_destroy bool INPUT -resources.postgres_roles.*.membership_roles []postgres.RoleMembershipRole ALL -resources.postgres_roles.*.membership_roles[*] postgres.RoleMembershipRole ALL +resources.postgres_roles.*.membership_roles []postgres.Role_MembershipRole ALL +resources.postgres_roles.*.membership_roles[*] postgres.Role_MembershipRole ALL resources.postgres_roles.*.modified_status string INPUT resources.postgres_roles.*.name string REMOTE resources.postgres_roles.*.parent string ALL -resources.postgres_roles.*.postgres_role string ALL +resources.postgres_roles.*.postgres_role *string ALL resources.postgres_roles.*.replace_existing bool INPUT STATE resources.postgres_roles.*.role_id string ALL -resources.postgres_roles.*.status *postgres.RoleRoleStatus REMOTE -resources.postgres_roles.*.status.attributes *postgres.RoleAttributes REMOTE -resources.postgres_roles.*.status.attributes.bypassrls bool REMOTE -resources.postgres_roles.*.status.attributes.createdb bool REMOTE -resources.postgres_roles.*.status.attributes.createrole bool REMOTE -resources.postgres_roles.*.status.auth_method postgres.RoleAuthMethod REMOTE -resources.postgres_roles.*.status.identity_type postgres.RoleIdentityType REMOTE -resources.postgres_roles.*.status.membership_roles []postgres.RoleMembershipRole REMOTE -resources.postgres_roles.*.status.membership_roles[*] postgres.RoleMembershipRole REMOTE -resources.postgres_roles.*.status.postgres_role string REMOTE -resources.postgres_roles.*.status.role_id string REMOTE -resources.postgres_roles.*.update_time *time.Time REMOTE +resources.postgres_roles.*.status *postgres.Role_RoleStatus REMOTE +resources.postgres_roles.*.status.attributes *postgres.Role_Attributes REMOTE +resources.postgres_roles.*.status.attributes.bypassrls *bool REMOTE +resources.postgres_roles.*.status.attributes.createdb *bool REMOTE +resources.postgres_roles.*.status.attributes.createrole *bool REMOTE +resources.postgres_roles.*.status.auth_method postgres.Role_AuthMethod REMOTE +resources.postgres_roles.*.status.identity_type postgres.Role_IdentityType REMOTE +resources.postgres_roles.*.status.membership_roles []postgres.Role_MembershipRole REMOTE +resources.postgres_roles.*.status.membership_roles[*] postgres.Role_MembershipRole REMOTE +resources.postgres_roles.*.status.postgres_role *string REMOTE +resources.postgres_roles.*.status.role_id *string REMOTE +resources.postgres_roles.*.update_time *types.Time REMOTE resources.postgres_roles.*.url string INPUT resources.postgres_snapshot_schedules.*.branch string ALL resources.postgres_snapshot_schedules.*.id string INPUT @@ -3976,428 +4175,432 @@ resources.postgres_snapshot_schedules.*.name string REMOTE resources.postgres_snapshot_schedules.*.schedule []postgres.ScheduleCadence ALL resources.postgres_snapshot_schedules.*.schedule[*] postgres.ScheduleCadence ALL resources.postgres_snapshot_schedules.*.schedule[*].daily_schedule *postgres.DailySchedule ALL -resources.postgres_snapshot_schedules.*.schedule[*].daily_schedule.hour int ALL +resources.postgres_snapshot_schedules.*.schedule[*].daily_schedule.hour *int ALL resources.postgres_snapshot_schedules.*.schedule[*].monthly_schedule *postgres.MonthlySchedule ALL -resources.postgres_snapshot_schedules.*.schedule[*].monthly_schedule.day int ALL -resources.postgres_snapshot_schedules.*.schedule[*].monthly_schedule.hour int ALL -resources.postgres_snapshot_schedules.*.schedule[*].retention duration.Duration ALL +resources.postgres_snapshot_schedules.*.schedule[*].monthly_schedule.day *int ALL +resources.postgres_snapshot_schedules.*.schedule[*].monthly_schedule.hour *int ALL +resources.postgres_snapshot_schedules.*.schedule[*].retention *types.Duration ALL resources.postgres_snapshot_schedules.*.schedule[*].weekly_schedule *postgres.WeeklySchedule ALL resources.postgres_snapshot_schedules.*.schedule[*].weekly_schedule.day_of_week postgres.DayOfWeek ALL -resources.postgres_snapshot_schedules.*.schedule[*].weekly_schedule.hour int ALL +resources.postgres_snapshot_schedules.*.schedule[*].weekly_schedule.hour *int ALL resources.postgres_snapshot_schedules.*.url string INPUT -resources.postgres_synced_tables.*.accelerated_sync bool ALL -resources.postgres_synced_tables.*.branch string ALL -resources.postgres_synced_tables.*.create_database_objects_if_missing bool ALL -resources.postgres_synced_tables.*.create_time *time.Time REMOTE -resources.postgres_synced_tables.*.existing_pipeline_id string ALL -resources.postgres_synced_tables.*.extra_columns []postgres.SyncedTableSyncedTableSpecExtraColumn ALL -resources.postgres_synced_tables.*.extra_columns[*] postgres.SyncedTableSyncedTableSpecExtraColumn ALL -resources.postgres_synced_tables.*.extra_columns[*].column_name string ALL -resources.postgres_synced_tables.*.extra_columns[*].column_type string ALL -resources.postgres_synced_tables.*.extra_columns[*].compute string ALL -resources.postgres_synced_tables.*.extra_columns[*].maintenance postgres.SyncedTableSyncedTableSpecExtraColumnMaintenance ALL +resources.postgres_synced_tables.*.accelerated_sync *bool ALL +resources.postgres_synced_tables.*.branch *string ALL +resources.postgres_synced_tables.*.create_database_objects_if_missing *bool ALL +resources.postgres_synced_tables.*.create_time *types.Time REMOTE +resources.postgres_synced_tables.*.existing_pipeline_id *string ALL +resources.postgres_synced_tables.*.extra_columns []postgres.SyncedTable_SyncedTableSpec_ExtraColumn ALL +resources.postgres_synced_tables.*.extra_columns[*] postgres.SyncedTable_SyncedTableSpec_ExtraColumn ALL +resources.postgres_synced_tables.*.extra_columns[*].column_name *string ALL +resources.postgres_synced_tables.*.extra_columns[*].column_type *string ALL +resources.postgres_synced_tables.*.extra_columns[*].compute *string ALL +resources.postgres_synced_tables.*.extra_columns[*].maintenance postgres.SyncedTable_SyncedTableSpec_ExtraColumn_Maintenance ALL resources.postgres_synced_tables.*.id string INPUT resources.postgres_synced_tables.*.lifecycle resources.Lifecycle INPUT resources.postgres_synced_tables.*.lifecycle.prevent_destroy bool INPUT resources.postgres_synced_tables.*.modified_status string INPUT resources.postgres_synced_tables.*.name string REMOTE resources.postgres_synced_tables.*.new_pipeline_spec *postgres.NewPipelineSpec ALL -resources.postgres_synced_tables.*.new_pipeline_spec.budget_policy_id string ALL -resources.postgres_synced_tables.*.new_pipeline_spec.pipeline_channel postgres.NewPipelineSpecPipelineChannel ALL -resources.postgres_synced_tables.*.new_pipeline_spec.storage_catalog string ALL -resources.postgres_synced_tables.*.new_pipeline_spec.storage_schema string ALL -resources.postgres_synced_tables.*.postgres_database string ALL +resources.postgres_synced_tables.*.new_pipeline_spec.budget_policy_id *string ALL +resources.postgres_synced_tables.*.new_pipeline_spec.pipeline_channel postgres.NewPipelineSpec_PipelineChannel ALL +resources.postgres_synced_tables.*.new_pipeline_spec.storage_catalog *string ALL +resources.postgres_synced_tables.*.new_pipeline_spec.storage_schema *string ALL +resources.postgres_synced_tables.*.postgres_database *string ALL resources.postgres_synced_tables.*.primary_key_columns []string ALL resources.postgres_synced_tables.*.primary_key_columns[*] string ALL -resources.postgres_synced_tables.*.scheduling_policy postgres.SyncedTableSyncedTableSpecSyncedTableSchedulingPolicy ALL -resources.postgres_synced_tables.*.source_table_full_name string ALL -resources.postgres_synced_tables.*.status *postgres.SyncedTableSyncedTableStatus REMOTE +resources.postgres_synced_tables.*.scheduling_policy postgres.SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy ALL +resources.postgres_synced_tables.*.source_table_full_name *string ALL +resources.postgres_synced_tables.*.status *postgres.SyncedTable_SyncedTableStatus REMOTE resources.postgres_synced_tables.*.status.detailed_state postgres.SyncedTableState REMOTE -resources.postgres_synced_tables.*.status.last_processed_commit_version int64 REMOTE +resources.postgres_synced_tables.*.status.last_processed_commit_version *int64 REMOTE resources.postgres_synced_tables.*.status.last_sync *postgres.SyncedTablePosition REMOTE resources.postgres_synced_tables.*.status.last_sync.delta_table_sync_info *postgres.DeltaTableSyncInfo REMOTE -resources.postgres_synced_tables.*.status.last_sync.delta_table_sync_info.delta_commit_time *time.Time REMOTE -resources.postgres_synced_tables.*.status.last_sync.delta_table_sync_info.delta_commit_version int64 REMOTE -resources.postgres_synced_tables.*.status.last_sync.sync_end_time *time.Time REMOTE -resources.postgres_synced_tables.*.status.last_sync.sync_start_time *time.Time REMOTE -resources.postgres_synced_tables.*.status.last_sync_time *time.Time REMOTE -resources.postgres_synced_tables.*.status.message string REMOTE +resources.postgres_synced_tables.*.status.last_sync.delta_table_sync_info.delta_commit_time *types.Time REMOTE +resources.postgres_synced_tables.*.status.last_sync.delta_table_sync_info.delta_commit_version *int64 REMOTE +resources.postgres_synced_tables.*.status.last_sync.sync_end_time *types.Time REMOTE +resources.postgres_synced_tables.*.status.last_sync.sync_start_time *types.Time REMOTE +resources.postgres_synced_tables.*.status.last_sync_time *types.Time REMOTE +resources.postgres_synced_tables.*.status.message *string REMOTE resources.postgres_synced_tables.*.status.ongoing_sync_progress *postgres.SyncedTablePipelineProgress REMOTE -resources.postgres_synced_tables.*.status.ongoing_sync_progress.estimated_completion_time_seconds float64 REMOTE -resources.postgres_synced_tables.*.status.ongoing_sync_progress.latest_version_currently_processing int64 REMOTE -resources.postgres_synced_tables.*.status.ongoing_sync_progress.sync_progress_completion float64 REMOTE -resources.postgres_synced_tables.*.status.ongoing_sync_progress.synced_row_count int64 REMOTE -resources.postgres_synced_tables.*.status.ongoing_sync_progress.total_row_count int64 REMOTE -resources.postgres_synced_tables.*.status.pipeline_id string REMOTE -resources.postgres_synced_tables.*.status.project string REMOTE +resources.postgres_synced_tables.*.status.ongoing_sync_progress.estimated_completion_time_seconds *float64 REMOTE +resources.postgres_synced_tables.*.status.ongoing_sync_progress.latest_version_currently_processing *int64 REMOTE +resources.postgres_synced_tables.*.status.ongoing_sync_progress.sync_progress_completion *float64 REMOTE +resources.postgres_synced_tables.*.status.ongoing_sync_progress.synced_row_count *int64 REMOTE +resources.postgres_synced_tables.*.status.ongoing_sync_progress.total_row_count *int64 REMOTE +resources.postgres_synced_tables.*.status.pipeline_id *string REMOTE +resources.postgres_synced_tables.*.status.project *string REMOTE resources.postgres_synced_tables.*.status.provisioning_phase postgres.ProvisioningPhase REMOTE -resources.postgres_synced_tables.*.status.unity_catalog_provisioning_state postgres.ProvisioningInfoState REMOTE +resources.postgres_synced_tables.*.status.unity_catalog_provisioning_state postgres.ProvisioningInfo_State REMOTE resources.postgres_synced_tables.*.synced_table_id string ALL -resources.postgres_synced_tables.*.timeseries_key string ALL -resources.postgres_synced_tables.*.type_overrides []postgres.SyncedTableSyncedTableSpecTypeOverride ALL -resources.postgres_synced_tables.*.type_overrides[*] postgres.SyncedTableSyncedTableSpecTypeOverride ALL -resources.postgres_synced_tables.*.type_overrides[*].column_name string ALL -resources.postgres_synced_tables.*.type_overrides[*].pg_type postgres.SyncedTableSyncedTableSpecPgSpecificType ALL -resources.postgres_synced_tables.*.type_overrides[*].size int ALL +resources.postgres_synced_tables.*.timeseries_key *string ALL +resources.postgres_synced_tables.*.type_overrides []postgres.SyncedTable_SyncedTableSpec_TypeOverride ALL +resources.postgres_synced_tables.*.type_overrides[*] postgres.SyncedTable_SyncedTableSpec_TypeOverride ALL +resources.postgres_synced_tables.*.type_overrides[*].column_name *string ALL +resources.postgres_synced_tables.*.type_overrides[*].pg_type postgres.SyncedTable_SyncedTableSpec_PgSpecificType ALL +resources.postgres_synced_tables.*.type_overrides[*].size *int ALL resources.postgres_synced_tables.*.uid string REMOTE resources.postgres_synced_tables.*.url string INPUT resources.quality_monitors.*.assets_dir string ALL resources.quality_monitors.*.baseline_table_name string ALL -resources.quality_monitors.*.custom_metrics []catalog.MonitorMetric ALL -resources.quality_monitors.*.custom_metrics[*] catalog.MonitorMetric ALL +resources.quality_monitors.*.custom_metrics []qualitymonitors.MonitorMetric ALL +resources.quality_monitors.*.custom_metrics[*] qualitymonitors.MonitorMetric ALL resources.quality_monitors.*.custom_metrics[*].definition string ALL resources.quality_monitors.*.custom_metrics[*].input_columns []string ALL resources.quality_monitors.*.custom_metrics[*].input_columns[*] string ALL resources.quality_monitors.*.custom_metrics[*].name string ALL resources.quality_monitors.*.custom_metrics[*].output_data_type string ALL -resources.quality_monitors.*.custom_metrics[*].type catalog.MonitorMetricType ALL +resources.quality_monitors.*.custom_metrics[*].type qualitymonitors.MonitorMetricType ALL resources.quality_monitors.*.dashboard_id string REMOTE -resources.quality_monitors.*.data_classification_config *catalog.MonitorDataClassificationConfig ALL +resources.quality_monitors.*.data_classification_config *qualitymonitors.MonitorDataClassificationConfig ALL resources.quality_monitors.*.data_classification_config.enabled bool ALL resources.quality_monitors.*.drift_metrics_table_name string REMOTE resources.quality_monitors.*.id string INPUT -resources.quality_monitors.*.inference_log *catalog.MonitorInferenceLog ALL +resources.quality_monitors.*.inference_log *qualitymonitors.MonitorInferenceLog ALL resources.quality_monitors.*.inference_log.granularities []string ALL resources.quality_monitors.*.inference_log.granularities[*] string ALL resources.quality_monitors.*.inference_log.label_col string ALL resources.quality_monitors.*.inference_log.model_id_col string ALL resources.quality_monitors.*.inference_log.prediction_col string ALL resources.quality_monitors.*.inference_log.prediction_proba_col string ALL -resources.quality_monitors.*.inference_log.problem_type catalog.MonitorInferenceLogProblemType ALL +resources.quality_monitors.*.inference_log.problem_type qualitymonitors.MonitorInferenceLogProblemType ALL resources.quality_monitors.*.inference_log.timestamp_col string ALL resources.quality_monitors.*.latest_monitor_failure_msg string ALL resources.quality_monitors.*.lifecycle resources.Lifecycle INPUT resources.quality_monitors.*.lifecycle.prevent_destroy bool INPUT resources.quality_monitors.*.modified_status string INPUT resources.quality_monitors.*.monitor_version int64 REMOTE -resources.quality_monitors.*.notifications *catalog.MonitorNotifications ALL -resources.quality_monitors.*.notifications.on_failure *catalog.MonitorDestination ALL +resources.quality_monitors.*.notifications *qualitymonitors.MonitorNotifications ALL +resources.quality_monitors.*.notifications.on_failure *qualitymonitors.MonitorDestination ALL resources.quality_monitors.*.notifications.on_failure.email_addresses []string ALL resources.quality_monitors.*.notifications.on_failure.email_addresses[*] string ALL -resources.quality_monitors.*.notifications.on_new_classification_tag_detected *catalog.MonitorDestination ALL +resources.quality_monitors.*.notifications.on_new_classification_tag_detected *qualitymonitors.MonitorDestination ALL resources.quality_monitors.*.notifications.on_new_classification_tag_detected.email_addresses []string ALL resources.quality_monitors.*.notifications.on_new_classification_tag_detected.email_addresses[*] string ALL resources.quality_monitors.*.output_schema_name string ALL resources.quality_monitors.*.profile_metrics_table_name string REMOTE -resources.quality_monitors.*.schedule *catalog.MonitorCronSchedule ALL -resources.quality_monitors.*.schedule.pause_status catalog.MonitorCronSchedulePauseStatus ALL +resources.quality_monitors.*.schedule *qualitymonitors.MonitorCronSchedule ALL +resources.quality_monitors.*.schedule.pause_status qualitymonitors.MonitorCronSchedulePauseStatus ALL resources.quality_monitors.*.schedule.quartz_cron_expression string ALL resources.quality_monitors.*.schedule.timezone_id string ALL resources.quality_monitors.*.skip_builtin_dashboard bool INPUT STATE resources.quality_monitors.*.slicing_exprs []string ALL resources.quality_monitors.*.slicing_exprs[*] string ALL -resources.quality_monitors.*.snapshot *catalog.MonitorSnapshot ALL -resources.quality_monitors.*.status catalog.MonitorInfoStatus REMOTE +resources.quality_monitors.*.snapshot *qualitymonitors.MonitorSnapshot ALL +resources.quality_monitors.*.status qualitymonitors.MonitorInfoStatus REMOTE resources.quality_monitors.*.table_name string ALL -resources.quality_monitors.*.time_series *catalog.MonitorTimeSeries ALL +resources.quality_monitors.*.time_series *qualitymonitors.MonitorTimeSeries ALL resources.quality_monitors.*.time_series.granularities []string ALL resources.quality_monitors.*.time_series.granularities[*] string ALL resources.quality_monitors.*.time_series.timestamp_col string ALL resources.quality_monitors.*.url string INPUT resources.quality_monitors.*.warehouse_id string INPUT STATE -resources.registered_models.*.aliases []catalog.RegisteredModelAlias ALL -resources.registered_models.*.aliases[*] catalog.RegisteredModelAlias ALL -resources.registered_models.*.aliases[*].alias_name string ALL -resources.registered_models.*.aliases[*].catalog_name string ALL -resources.registered_models.*.aliases[*].id string ALL -resources.registered_models.*.aliases[*].model_name string ALL -resources.registered_models.*.aliases[*].schema_name string ALL -resources.registered_models.*.aliases[*].version_num int ALL -resources.registered_models.*.browse_only bool ALL -resources.registered_models.*.catalog_name string ALL -resources.registered_models.*.comment string ALL -resources.registered_models.*.created_at int64 ALL -resources.registered_models.*.created_by string ALL -resources.registered_models.*.full_name string ALL +resources.registered_models.*.aliases []registeredmodels.RegisteredModelAliasInfo ALL +resources.registered_models.*.aliases[*] registeredmodels.RegisteredModelAliasInfo ALL +resources.registered_models.*.aliases[*].alias_name *string ALL +resources.registered_models.*.aliases[*].catalog_name *string ALL +resources.registered_models.*.aliases[*].id *string ALL +resources.registered_models.*.aliases[*].model_name *string ALL +resources.registered_models.*.aliases[*].schema_name *string ALL +resources.registered_models.*.aliases[*].version_num *int64 ALL +resources.registered_models.*.browse_only *bool ALL +resources.registered_models.*.catalog_name *string ALL +resources.registered_models.*.comment *string ALL +resources.registered_models.*.created_at *int64 ALL +resources.registered_models.*.created_by *string ALL +resources.registered_models.*.full_name *string ALL resources.registered_models.*.id string INPUT resources.registered_models.*.lifecycle resources.Lifecycle INPUT resources.registered_models.*.lifecycle.prevent_destroy bool INPUT -resources.registered_models.*.metastore_id string ALL +resources.registered_models.*.metastore_id *string ALL resources.registered_models.*.modified_status string INPUT -resources.registered_models.*.name string ALL -resources.registered_models.*.owner string ALL -resources.registered_models.*.schema_name string ALL -resources.registered_models.*.storage_location string ALL -resources.registered_models.*.updated_at int64 ALL -resources.registered_models.*.updated_by string ALL +resources.registered_models.*.name *string ALL +resources.registered_models.*.owner *string ALL +resources.registered_models.*.schema_name *string ALL +resources.registered_models.*.storage_location *string ALL +resources.registered_models.*.updated_at *int64 ALL +resources.registered_models.*.updated_by *string ALL resources.registered_models.*.url string INPUT resources.registered_models.*.grants.full_name string ALL resources.registered_models.*.grants.securable_type string ALL -resources.registered_models.*.grants[*] catalog.PrivilegeAssignment ALL -resources.registered_models.*.grants[*].principal string ALL -resources.registered_models.*.grants[*].privileges []catalog.Privilege ALL -resources.registered_models.*.grants[*].privileges[*] catalog.Privilege ALL -resources.schemas.*.browse_only bool REMOTE -resources.schemas.*.catalog_name string ALL -resources.schemas.*.catalog_type catalog.CatalogType REMOTE -resources.schemas.*.comment string ALL -resources.schemas.*.created_at int64 REMOTE -resources.schemas.*.created_by string REMOTE -resources.schemas.*.custom_max_retention_hours int64 ALL -resources.schemas.*.effective_predictive_optimization_flag *catalog.EffectivePredictiveOptimizationFlag REMOTE -resources.schemas.*.effective_predictive_optimization_flag.inherited_from_name string REMOTE -resources.schemas.*.effective_predictive_optimization_flag.inherited_from_type catalog.EffectivePredictiveOptimizationFlagInheritedFromType REMOTE -resources.schemas.*.effective_predictive_optimization_flag.value catalog.EnablePredictiveOptimization REMOTE -resources.schemas.*.enable_predictive_optimization catalog.EnablePredictiveOptimization REMOTE -resources.schemas.*.full_name string REMOTE +resources.registered_models.*.grants[*] grants.PrivilegeAssignment ALL +resources.registered_models.*.grants[*].principal *string ALL +resources.registered_models.*.grants[*].privileges []string ALL +resources.registered_models.*.grants[*].privileges[*] string ALL +resources.schemas.*.browse_only *bool REMOTE +resources.schemas.*.catalog_name *string ALL +resources.schemas.*.catalog_type schemas.CatalogType REMOTE +resources.schemas.*.comment *string ALL +resources.schemas.*.created_at *int64 REMOTE +resources.schemas.*.created_by *string REMOTE +resources.schemas.*.custom_max_retention_hours *int64 ALL +resources.schemas.*.effective_predictive_optimization_flag *schemas.EffectivePredictiveOptimizationFlag REMOTE +resources.schemas.*.effective_predictive_optimization_flag.inherited_from_name *string REMOTE +resources.schemas.*.effective_predictive_optimization_flag.inherited_from_type *string REMOTE +resources.schemas.*.effective_predictive_optimization_flag.value *string REMOTE +resources.schemas.*.enable_predictive_optimization *string REMOTE +resources.schemas.*.full_name *string REMOTE resources.schemas.*.id string INPUT resources.schemas.*.lifecycle resources.Lifecycle INPUT resources.schemas.*.lifecycle.prevent_destroy bool INPUT -resources.schemas.*.metastore_id string REMOTE +resources.schemas.*.metastore_id *string REMOTE resources.schemas.*.modified_status string INPUT -resources.schemas.*.name string ALL -resources.schemas.*.owner string REMOTE +resources.schemas.*.name *string ALL +resources.schemas.*.options map[string]string REMOTE +resources.schemas.*.options.* string REMOTE +resources.schemas.*.owner *string REMOTE resources.schemas.*.properties map[string]string ALL resources.schemas.*.properties.* string ALL -resources.schemas.*.schema_id string REMOTE -resources.schemas.*.storage_location string REMOTE -resources.schemas.*.storage_root string ALL -resources.schemas.*.updated_at int64 REMOTE -resources.schemas.*.updated_by string REMOTE +resources.schemas.*.schema_id *string REMOTE +resources.schemas.*.storage_location *string REMOTE +resources.schemas.*.storage_root *string ALL +resources.schemas.*.updated_at *int64 REMOTE +resources.schemas.*.updated_by *string REMOTE resources.schemas.*.url string INPUT resources.schemas.*.grants.full_name string ALL resources.schemas.*.grants.securable_type string ALL -resources.schemas.*.grants[*] catalog.PrivilegeAssignment ALL -resources.schemas.*.grants[*].principal string ALL -resources.schemas.*.grants[*].privileges []catalog.Privilege ALL -resources.schemas.*.grants[*].privileges[*] catalog.Privilege ALL -resources.secret_scopes.*.backend_azure_keyvault *workspace.AzureKeyVaultSecretScopeMetadata REMOTE STATE -resources.secret_scopes.*.backend_azure_keyvault.dns_name string REMOTE STATE -resources.secret_scopes.*.backend_azure_keyvault.resource_id string REMOTE STATE -resources.secret_scopes.*.backend_type workspace.ScopeBackendType INPUT +resources.schemas.*.grants[*] grants.PrivilegeAssignment ALL +resources.schemas.*.grants[*].principal *string ALL +resources.schemas.*.grants[*].privileges []string ALL +resources.schemas.*.grants[*].privileges[*] string ALL +resources.secret_scopes.*.backend_azure_keyvault *secrets.AzureKeyVaultSecretScopeMetadata REMOTE STATE +resources.secret_scopes.*.backend_azure_keyvault.dns_name *string REMOTE STATE +resources.secret_scopes.*.backend_azure_keyvault.resource_id *string REMOTE STATE +resources.secret_scopes.*.backend_type secrets.ScopeBackendType INPUT resources.secret_scopes.*.id string INPUT -resources.secret_scopes.*.initial_manage_principal string STATE -resources.secret_scopes.*.keyvault_metadata *workspace.AzureKeyVaultSecretScopeMetadata INPUT -resources.secret_scopes.*.keyvault_metadata.dns_name string INPUT -resources.secret_scopes.*.keyvault_metadata.resource_id string INPUT +resources.secret_scopes.*.initial_manage_principal *string STATE +resources.secret_scopes.*.keyvault_metadata *secrets.AzureKeyVaultSecretScopeMetadata INPUT +resources.secret_scopes.*.keyvault_metadata.dns_name *string INPUT +resources.secret_scopes.*.keyvault_metadata.resource_id *string INPUT resources.secret_scopes.*.lifecycle resources.Lifecycle INPUT resources.secret_scopes.*.lifecycle.prevent_destroy bool INPUT resources.secret_scopes.*.modified_status string INPUT resources.secret_scopes.*.name string INPUT REMOTE -resources.secret_scopes.*.scope string REMOTE STATE -resources.secret_scopes.*.scope_backend_type workspace.ScopeBackendType REMOTE STATE +resources.secret_scopes.*.scope *string STATE +resources.secret_scopes.*.scope string REMOTE +resources.secret_scopes.*.scope_backend_type secrets.ScopeBackendType REMOTE STATE resources.secret_scopes.*.url string INPUT -resources.secret_scopes.*.permissions.acls []workspace.AclItem ALL -resources.secret_scopes.*.permissions.acls[*] workspace.AclItem ALL -resources.secret_scopes.*.permissions.acls[*].permission workspace.AclPermission ALL -resources.secret_scopes.*.permissions.acls[*].principal string ALL +resources.secret_scopes.*.permissions.acls []secrets.AclItem ALL +resources.secret_scopes.*.permissions.acls[*] secrets.AclItem ALL +resources.secret_scopes.*.permissions.acls[*].permission secrets.AclPermission ALL +resources.secret_scopes.*.permissions.acls[*].principal *string ALL resources.secret_scopes.*.permissions.scope_name string ALL -resources.secrets.*.catalog_name string ALL -resources.secrets.*.comment string ALL -resources.secrets.*.create_time *time.Time ALL -resources.secrets.*.created_by string ALL -resources.secrets.*.effective_owner string ALL -resources.secrets.*.effective_value string ALL -resources.secrets.*.expire_time *time.Time ALL -resources.secrets.*.full_name string ALL +resources.secrets.*.catalog_name *string ALL +resources.secrets.*.comment *string ALL +resources.secrets.*.create_time *types.Time ALL +resources.secrets.*.created_by *string ALL +resources.secrets.*.effective_owner *string ALL +resources.secrets.*.effective_value *string ALL +resources.secrets.*.expire_time *types.Time ALL +resources.secrets.*.full_name *string ALL resources.secrets.*.id string INPUT resources.secrets.*.lifecycle resources.Lifecycle INPUT resources.secrets.*.lifecycle.prevent_destroy bool INPUT -resources.secrets.*.metastore_id string ALL +resources.secrets.*.metastore_id *string ALL resources.secrets.*.modified_status string INPUT -resources.secrets.*.name string ALL -resources.secrets.*.owner string ALL -resources.secrets.*.schema_name string ALL -resources.secrets.*.update_time *time.Time ALL -resources.secrets.*.updated_by string ALL +resources.secrets.*.name *string ALL +resources.secrets.*.owner *string ALL +resources.secrets.*.schema_name *string ALL +resources.secrets.*.update_time *types.Time ALL +resources.secrets.*.updated_by *string ALL resources.secrets.*.url string INPUT -resources.secrets.*.value string ALL +resources.secrets.*.value *string ALL resources.secrets.*.grants.full_name string ALL resources.secrets.*.grants.securable_type string ALL -resources.secrets.*.grants[*] catalog.PrivilegeAssignment ALL -resources.secrets.*.grants[*].principal string ALL -resources.secrets.*.grants[*].privileges []catalog.Privilege ALL -resources.secrets.*.grants[*].privileges[*] catalog.Privilege ALL -resources.sql_warehouses.*.auto_stop_mins int ALL -resources.sql_warehouses.*.channel *sql.Channel ALL -resources.sql_warehouses.*.channel.dbsql_version string ALL -resources.sql_warehouses.*.channel.name sql.ChannelName ALL -resources.sql_warehouses.*.cluster_size string ALL -resources.sql_warehouses.*.creator_name string ALL -resources.sql_warehouses.*.enable_photon bool ALL -resources.sql_warehouses.*.enable_serverless_compute bool ALL -resources.sql_warehouses.*.health *sql.EndpointHealth REMOTE -resources.sql_warehouses.*.health.details string REMOTE -resources.sql_warehouses.*.health.failure_reason *sql.TerminationReason REMOTE -resources.sql_warehouses.*.health.failure_reason.code sql.TerminationReasonCode REMOTE +resources.secrets.*.grants[*] grants.PrivilegeAssignment ALL +resources.secrets.*.grants[*].principal *string ALL +resources.secrets.*.grants[*].privileges []string ALL +resources.secrets.*.grants[*].privileges[*] string ALL +resources.sql_warehouses.*.auto_stop_mins *int ALL +resources.sql_warehouses.*.channel *warehouses.Channel ALL +resources.sql_warehouses.*.channel.dbsql_version *string ALL +resources.sql_warehouses.*.channel.name warehouses.ChannelName ALL +resources.sql_warehouses.*.cluster_size *string ALL +resources.sql_warehouses.*.creator_name *string ALL +resources.sql_warehouses.*.enable_photon *bool ALL +resources.sql_warehouses.*.enable_serverless_compute *bool ALL +resources.sql_warehouses.*.health *warehouses.EndpointHealth REMOTE +resources.sql_warehouses.*.health.details *string REMOTE +resources.sql_warehouses.*.health.failure_reason *warehouses.TerminationReason REMOTE +resources.sql_warehouses.*.health.failure_reason.code warehouses.TerminationCode REMOTE resources.sql_warehouses.*.health.failure_reason.parameters map[string]string REMOTE resources.sql_warehouses.*.health.failure_reason.parameters.* string REMOTE -resources.sql_warehouses.*.health.failure_reason.type sql.TerminationReasonType REMOTE -resources.sql_warehouses.*.health.message string REMOTE -resources.sql_warehouses.*.health.status sql.Status REMOTE -resources.sql_warehouses.*.health.summary string REMOTE -resources.sql_warehouses.*.id string INPUT REMOTE -resources.sql_warehouses.*.instance_profile_arn string ALL -resources.sql_warehouses.*.jdbc_url string REMOTE +resources.sql_warehouses.*.health.failure_reason.type warehouses.TerminationType REMOTE +resources.sql_warehouses.*.health.message *string REMOTE +resources.sql_warehouses.*.health.status warehouses.EndpointHealth_Status REMOTE +resources.sql_warehouses.*.health.summary *string REMOTE +resources.sql_warehouses.*.id *string REMOTE +resources.sql_warehouses.*.id string INPUT +resources.sql_warehouses.*.instance_profile_arn *string ALL +resources.sql_warehouses.*.jdbc_url *string REMOTE resources.sql_warehouses.*.lifecycle *dresources.StateLifecycle REMOTE STATE resources.sql_warehouses.*.lifecycle *resources.LifecycleWithStarted INPUT resources.sql_warehouses.*.lifecycle resources.Lifecycle INPUT resources.sql_warehouses.*.lifecycle.prevent_destroy bool INPUT resources.sql_warehouses.*.lifecycle.started *bool ALL -resources.sql_warehouses.*.max_num_clusters int ALL -resources.sql_warehouses.*.min_num_clusters int ALL +resources.sql_warehouses.*.max_num_clusters *int ALL +resources.sql_warehouses.*.min_num_clusters *int ALL resources.sql_warehouses.*.modified_status string INPUT -resources.sql_warehouses.*.name string ALL -resources.sql_warehouses.*.num_active_sessions int64 REMOTE -resources.sql_warehouses.*.num_clusters int REMOTE -resources.sql_warehouses.*.odbc_params *sql.OdbcParams REMOTE -resources.sql_warehouses.*.odbc_params.hostname string REMOTE -resources.sql_warehouses.*.odbc_params.path string REMOTE -resources.sql_warehouses.*.odbc_params.port int REMOTE -resources.sql_warehouses.*.odbc_params.protocol string REMOTE -resources.sql_warehouses.*.spot_instance_policy sql.SpotInstancePolicy ALL -resources.sql_warehouses.*.state sql.State REMOTE -resources.sql_warehouses.*.statement_timeout int ALL -resources.sql_warehouses.*.tags *sql.EndpointTags ALL -resources.sql_warehouses.*.tags.custom_tags []sql.EndpointTagPair ALL -resources.sql_warehouses.*.tags.custom_tags[*] sql.EndpointTagPair ALL -resources.sql_warehouses.*.tags.custom_tags[*].key string ALL -resources.sql_warehouses.*.tags.custom_tags[*].value string ALL +resources.sql_warehouses.*.name *string ALL +resources.sql_warehouses.*.num_active_sessions *int64 REMOTE +resources.sql_warehouses.*.num_clusters *int REMOTE +resources.sql_warehouses.*.odbc_params *warehouses.OdbcParams REMOTE +resources.sql_warehouses.*.odbc_params.hostname *string REMOTE +resources.sql_warehouses.*.odbc_params.path *string REMOTE +resources.sql_warehouses.*.odbc_params.port *int REMOTE +resources.sql_warehouses.*.odbc_params.protocol *string REMOTE +resources.sql_warehouses.*.spot_instance_policy warehouses.EndpointSpotInstancePolicy ALL +resources.sql_warehouses.*.state warehouses.EndpointState REMOTE +resources.sql_warehouses.*.statement_timeout *int ALL +resources.sql_warehouses.*.tags *warehouses.EndpointTags ALL +resources.sql_warehouses.*.tags.custom_tags []warehouses.EndpointTagPair ALL +resources.sql_warehouses.*.tags.custom_tags[*] warehouses.EndpointTagPair ALL +resources.sql_warehouses.*.tags.custom_tags[*].key *string ALL +resources.sql_warehouses.*.tags.custom_tags[*].value *string ALL resources.sql_warehouses.*.url string INPUT -resources.sql_warehouses.*.warehouse_type sql.CreateWarehouseRequestWarehouseType INPUT STATE -resources.sql_warehouses.*.warehouse_type sql.GetWarehouseResponseWarehouseType REMOTE +resources.sql_warehouses.*.warehouse_type warehouses.WarehouseType ALL resources.sql_warehouses.*.permissions.object_id string ALL resources.sql_warehouses.*.permissions[*] dresources.StatePermission ALL resources.sql_warehouses.*.permissions[*].group_name string ALL -resources.sql_warehouses.*.permissions[*].level iam.PermissionLevel ALL +resources.sql_warehouses.*.permissions[*].level resources.PermissionLevel ALL resources.sql_warehouses.*.permissions[*].service_principal_name string ALL resources.sql_warehouses.*.permissions[*].user_name string ALL resources.synced_database_tables.*.data_synchronization_status *database.SyncedTableStatus ALL resources.synced_database_tables.*.data_synchronization_status.continuous_update_status *database.SyncedTableContinuousUpdateStatus ALL resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.initial_pipeline_sync_progress *database.SyncedTablePipelineProgress ALL -resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.initial_pipeline_sync_progress.estimated_completion_time_seconds float64 ALL -resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.initial_pipeline_sync_progress.latest_version_currently_processing int64 ALL +resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.initial_pipeline_sync_progress.estimated_completion_time_seconds *float64 ALL +resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.initial_pipeline_sync_progress.latest_version_currently_processing *int64 ALL resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.initial_pipeline_sync_progress.provisioning_phase database.ProvisioningPhase ALL -resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.initial_pipeline_sync_progress.sync_progress_completion float64 ALL -resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.initial_pipeline_sync_progress.synced_row_count int64 ALL -resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.initial_pipeline_sync_progress.total_row_count int64 ALL -resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.last_processed_commit_version int64 ALL -resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.timestamp string ALL +resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.initial_pipeline_sync_progress.sync_progress_completion *float64 ALL +resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.initial_pipeline_sync_progress.synced_row_count *int64 ALL +resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.initial_pipeline_sync_progress.total_row_count *int64 ALL +resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.last_processed_commit_version *int64 ALL +resources.synced_database_tables.*.data_synchronization_status.continuous_update_status.timestamp *types.Time ALL resources.synced_database_tables.*.data_synchronization_status.detailed_state database.SyncedTableState ALL resources.synced_database_tables.*.data_synchronization_status.failed_status *database.SyncedTableFailedStatus ALL -resources.synced_database_tables.*.data_synchronization_status.failed_status.last_processed_commit_version int64 ALL -resources.synced_database_tables.*.data_synchronization_status.failed_status.timestamp string ALL +resources.synced_database_tables.*.data_synchronization_status.failed_status.last_processed_commit_version *int64 ALL +resources.synced_database_tables.*.data_synchronization_status.failed_status.timestamp *types.Time ALL resources.synced_database_tables.*.data_synchronization_status.last_sync *database.SyncedTablePosition ALL resources.synced_database_tables.*.data_synchronization_status.last_sync.delta_table_sync_info *database.DeltaTableSyncInfo ALL -resources.synced_database_tables.*.data_synchronization_status.last_sync.delta_table_sync_info.delta_commit_timestamp string ALL -resources.synced_database_tables.*.data_synchronization_status.last_sync.delta_table_sync_info.delta_commit_version int64 ALL -resources.synced_database_tables.*.data_synchronization_status.last_sync.sync_end_timestamp string ALL -resources.synced_database_tables.*.data_synchronization_status.last_sync.sync_start_timestamp string ALL -resources.synced_database_tables.*.data_synchronization_status.message string ALL -resources.synced_database_tables.*.data_synchronization_status.pipeline_id string ALL +resources.synced_database_tables.*.data_synchronization_status.last_sync.delta_table_sync_info.delta_commit_timestamp *types.Time ALL +resources.synced_database_tables.*.data_synchronization_status.last_sync.delta_table_sync_info.delta_commit_version *int64 ALL +resources.synced_database_tables.*.data_synchronization_status.last_sync.sync_end_timestamp *types.Time ALL +resources.synced_database_tables.*.data_synchronization_status.last_sync.sync_start_timestamp *types.Time ALL +resources.synced_database_tables.*.data_synchronization_status.message *string ALL +resources.synced_database_tables.*.data_synchronization_status.pipeline_id *string ALL resources.synced_database_tables.*.data_synchronization_status.provisioning_status *database.SyncedTableProvisioningStatus ALL resources.synced_database_tables.*.data_synchronization_status.provisioning_status.initial_pipeline_sync_progress *database.SyncedTablePipelineProgress ALL -resources.synced_database_tables.*.data_synchronization_status.provisioning_status.initial_pipeline_sync_progress.estimated_completion_time_seconds float64 ALL -resources.synced_database_tables.*.data_synchronization_status.provisioning_status.initial_pipeline_sync_progress.latest_version_currently_processing int64 ALL +resources.synced_database_tables.*.data_synchronization_status.provisioning_status.initial_pipeline_sync_progress.estimated_completion_time_seconds *float64 ALL +resources.synced_database_tables.*.data_synchronization_status.provisioning_status.initial_pipeline_sync_progress.latest_version_currently_processing *int64 ALL resources.synced_database_tables.*.data_synchronization_status.provisioning_status.initial_pipeline_sync_progress.provisioning_phase database.ProvisioningPhase ALL -resources.synced_database_tables.*.data_synchronization_status.provisioning_status.initial_pipeline_sync_progress.sync_progress_completion float64 ALL -resources.synced_database_tables.*.data_synchronization_status.provisioning_status.initial_pipeline_sync_progress.synced_row_count int64 ALL -resources.synced_database_tables.*.data_synchronization_status.provisioning_status.initial_pipeline_sync_progress.total_row_count int64 ALL +resources.synced_database_tables.*.data_synchronization_status.provisioning_status.initial_pipeline_sync_progress.sync_progress_completion *float64 ALL +resources.synced_database_tables.*.data_synchronization_status.provisioning_status.initial_pipeline_sync_progress.synced_row_count *int64 ALL +resources.synced_database_tables.*.data_synchronization_status.provisioning_status.initial_pipeline_sync_progress.total_row_count *int64 ALL resources.synced_database_tables.*.data_synchronization_status.triggered_update_status *database.SyncedTableTriggeredUpdateStatus ALL -resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.last_processed_commit_version int64 ALL -resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.timestamp string ALL +resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.last_processed_commit_version *int64 ALL +resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.timestamp *types.Time ALL resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.triggered_update_progress *database.SyncedTablePipelineProgress ALL -resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.triggered_update_progress.estimated_completion_time_seconds float64 ALL -resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.triggered_update_progress.latest_version_currently_processing int64 ALL +resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.triggered_update_progress.estimated_completion_time_seconds *float64 ALL +resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.triggered_update_progress.latest_version_currently_processing *int64 ALL resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.triggered_update_progress.provisioning_phase database.ProvisioningPhase ALL -resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.triggered_update_progress.sync_progress_completion float64 ALL -resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.triggered_update_progress.synced_row_count int64 ALL -resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.triggered_update_progress.total_row_count int64 ALL -resources.synced_database_tables.*.database_instance_name string ALL -resources.synced_database_tables.*.effective_database_instance_name string ALL -resources.synced_database_tables.*.effective_logical_database_name string ALL +resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.triggered_update_progress.sync_progress_completion *float64 ALL +resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.triggered_update_progress.synced_row_count *int64 ALL +resources.synced_database_tables.*.data_synchronization_status.triggered_update_status.triggered_update_progress.total_row_count *int64 ALL +resources.synced_database_tables.*.database_instance_name *string ALL +resources.synced_database_tables.*.effective_database_instance_name *string ALL +resources.synced_database_tables.*.effective_logical_database_name *string ALL resources.synced_database_tables.*.id string INPUT resources.synced_database_tables.*.lifecycle resources.Lifecycle INPUT resources.synced_database_tables.*.lifecycle.prevent_destroy bool INPUT -resources.synced_database_tables.*.logical_database_name string ALL +resources.synced_database_tables.*.logical_database_name *string ALL resources.synced_database_tables.*.modified_status string INPUT -resources.synced_database_tables.*.name string ALL +resources.synced_database_tables.*.name *string ALL resources.synced_database_tables.*.spec *database.SyncedTableSpec ALL -resources.synced_database_tables.*.spec.accelerated_sync bool ALL -resources.synced_database_tables.*.spec.create_database_objects_if_missing bool ALL -resources.synced_database_tables.*.spec.existing_pipeline_id string ALL +resources.synced_database_tables.*.spec.accelerated_sync *bool ALL +resources.synced_database_tables.*.spec.create_database_objects_if_missing *bool ALL +resources.synced_database_tables.*.spec.existing_pipeline_id *string ALL resources.synced_database_tables.*.spec.new_pipeline_spec *database.NewPipelineSpec ALL -resources.synced_database_tables.*.spec.new_pipeline_spec.budget_policy_id string ALL -resources.synced_database_tables.*.spec.new_pipeline_spec.storage_catalog string ALL -resources.synced_database_tables.*.spec.new_pipeline_spec.storage_schema string ALL +resources.synced_database_tables.*.spec.new_pipeline_spec.budget_policy_id *string ALL +resources.synced_database_tables.*.spec.new_pipeline_spec.storage_catalog *string ALL +resources.synced_database_tables.*.spec.new_pipeline_spec.storage_schema *string ALL resources.synced_database_tables.*.spec.primary_key_columns []string ALL resources.synced_database_tables.*.spec.primary_key_columns[*] string ALL resources.synced_database_tables.*.spec.scheduling_policy database.SyncedTableSchedulingPolicy ALL -resources.synced_database_tables.*.spec.source_table_full_name string ALL -resources.synced_database_tables.*.spec.timeseries_key string ALL -resources.synced_database_tables.*.spec.type_overrides []database.SyncedTableSpecTypeOverride ALL -resources.synced_database_tables.*.spec.type_overrides[*] database.SyncedTableSpecTypeOverride ALL -resources.synced_database_tables.*.spec.type_overrides[*].column_name string ALL -resources.synced_database_tables.*.spec.type_overrides[*].pg_type database.SyncedTableSpecPgSpecificType ALL -resources.synced_database_tables.*.spec.type_overrides[*].size int ALL -resources.synced_database_tables.*.unity_catalog_provisioning_state database.ProvisioningInfoState ALL +resources.synced_database_tables.*.spec.source_table_full_name *string ALL +resources.synced_database_tables.*.spec.timeseries_key *string ALL +resources.synced_database_tables.*.spec.type_overrides []database.SyncedTableSpec_TypeOverride ALL +resources.synced_database_tables.*.spec.type_overrides[*] database.SyncedTableSpec_TypeOverride ALL +resources.synced_database_tables.*.spec.type_overrides[*].column_name *string ALL +resources.synced_database_tables.*.spec.type_overrides[*].pg_type database.SyncedTableSpec_PgSpecificType ALL +resources.synced_database_tables.*.spec.type_overrides[*].size *int ALL +resources.synced_database_tables.*.unity_catalog_provisioning_state database.ProvisioningInfo_State ALL resources.synced_database_tables.*.url string INPUT -resources.vector_search_endpoints.*.budget_policy_id string ALL -resources.vector_search_endpoints.*.creation_timestamp int64 REMOTE -resources.vector_search_endpoints.*.creator string REMOTE +resources.vector_search_endpoints.*.budget_policy_id *string ALL +resources.vector_search_endpoints.*.creation_timestamp *int64 REMOTE +resources.vector_search_endpoints.*.creator *string REMOTE resources.vector_search_endpoints.*.custom_tags []vectorsearch.CustomTag REMOTE resources.vector_search_endpoints.*.custom_tags[*] vectorsearch.CustomTag REMOTE -resources.vector_search_endpoints.*.custom_tags[*].key string REMOTE -resources.vector_search_endpoints.*.custom_tags[*].value string REMOTE -resources.vector_search_endpoints.*.effective_budget_policy_id string REMOTE +resources.vector_search_endpoints.*.custom_tags[*].key *string REMOTE +resources.vector_search_endpoints.*.custom_tags[*].value *string REMOTE +resources.vector_search_endpoints.*.effective_budget_policy_id *string REMOTE resources.vector_search_endpoints.*.endpoint_status *vectorsearch.EndpointStatus REMOTE -resources.vector_search_endpoints.*.endpoint_status.message string REMOTE -resources.vector_search_endpoints.*.endpoint_status.state vectorsearch.EndpointStatusState REMOTE +resources.vector_search_endpoints.*.endpoint_status.message *string REMOTE +resources.vector_search_endpoints.*.endpoint_status.state vectorsearch.EndpointStatus_State REMOTE resources.vector_search_endpoints.*.endpoint_type vectorsearch.EndpointType ALL resources.vector_search_endpoints.*.endpoint_uuid string REMOTE -resources.vector_search_endpoints.*.id string INPUT REMOTE -resources.vector_search_endpoints.*.last_updated_timestamp int64 REMOTE -resources.vector_search_endpoints.*.last_updated_user string REMOTE +resources.vector_search_endpoints.*.id *string REMOTE +resources.vector_search_endpoints.*.id string INPUT +resources.vector_search_endpoints.*.last_updated_timestamp *int64 REMOTE +resources.vector_search_endpoints.*.last_updated_user *string REMOTE resources.vector_search_endpoints.*.lifecycle resources.Lifecycle INPUT resources.vector_search_endpoints.*.lifecycle.prevent_destroy bool INPUT resources.vector_search_endpoints.*.modified_status string INPUT -resources.vector_search_endpoints.*.name string ALL -resources.vector_search_endpoints.*.num_indexes int REMOTE +resources.vector_search_endpoints.*.name *string ALL +resources.vector_search_endpoints.*.num_indexes *int REMOTE resources.vector_search_endpoints.*.scaling_info *vectorsearch.EndpointScalingInfo REMOTE -resources.vector_search_endpoints.*.scaling_info.requested_target_qps int64 REMOTE +resources.vector_search_endpoints.*.scaling_info.requested_target_qps *int64 REMOTE resources.vector_search_endpoints.*.scaling_info.state vectorsearch.ScalingChangeState REMOTE -resources.vector_search_endpoints.*.target_qps int64 ALL +resources.vector_search_endpoints.*.target_qps *int64 ALL resources.vector_search_endpoints.*.url string INPUT -resources.vector_search_endpoints.*.usage_policy_id string INPUT STATE +resources.vector_search_endpoints.*.usage_policy_id *string INPUT STATE resources.vector_search_endpoints.*.permissions.object_id string ALL resources.vector_search_endpoints.*.permissions[*] dresources.StatePermission ALL resources.vector_search_endpoints.*.permissions[*].group_name string ALL -resources.vector_search_endpoints.*.permissions[*].level iam.PermissionLevel ALL +resources.vector_search_endpoints.*.permissions[*].level resources.PermissionLevel ALL resources.vector_search_endpoints.*.permissions[*].service_principal_name string ALL resources.vector_search_endpoints.*.permissions[*].user_name string ALL -resources.vector_search_indexes.*.creator string REMOTE +resources.vector_search_indexes.*.creator *string REMOTE +resources.vector_search_indexes.*.delta_sync_index_spec *vectorsearch.DeltaSyncVectorIndexSpec REMOTE resources.vector_search_indexes.*.delta_sync_index_spec *vectorsearch.DeltaSyncVectorIndexSpecRequest INPUT STATE -resources.vector_search_indexes.*.delta_sync_index_spec *vectorsearch.DeltaSyncVectorIndexSpecResponse REMOTE resources.vector_search_indexes.*.delta_sync_index_spec.columns_to_index []string ALL resources.vector_search_indexes.*.delta_sync_index_spec.columns_to_index[*] string ALL resources.vector_search_indexes.*.delta_sync_index_spec.columns_to_sync []string ALL resources.vector_search_indexes.*.delta_sync_index_spec.columns_to_sync[*] string ALL resources.vector_search_indexes.*.delta_sync_index_spec.embedding_source_columns []vectorsearch.EmbeddingSourceColumn ALL resources.vector_search_indexes.*.delta_sync_index_spec.embedding_source_columns[*] vectorsearch.EmbeddingSourceColumn ALL -resources.vector_search_indexes.*.delta_sync_index_spec.embedding_source_columns[*].embedding_model_endpoint_name string ALL -resources.vector_search_indexes.*.delta_sync_index_spec.embedding_source_columns[*].model_endpoint_name_for_query string ALL -resources.vector_search_indexes.*.delta_sync_index_spec.embedding_source_columns[*].name string ALL +resources.vector_search_indexes.*.delta_sync_index_spec.embedding_source_columns[*].embedding_model_endpoint_name *string ALL +resources.vector_search_indexes.*.delta_sync_index_spec.embedding_source_columns[*].model_endpoint_name_for_query *string ALL +resources.vector_search_indexes.*.delta_sync_index_spec.embedding_source_columns[*].name *string ALL resources.vector_search_indexes.*.delta_sync_index_spec.embedding_vector_columns []vectorsearch.EmbeddingVectorColumn ALL resources.vector_search_indexes.*.delta_sync_index_spec.embedding_vector_columns[*] vectorsearch.EmbeddingVectorColumn ALL -resources.vector_search_indexes.*.delta_sync_index_spec.embedding_vector_columns[*].embedding_dimension int ALL -resources.vector_search_indexes.*.delta_sync_index_spec.embedding_vector_columns[*].name string ALL -resources.vector_search_indexes.*.delta_sync_index_spec.embedding_writeback_table string ALL -resources.vector_search_indexes.*.delta_sync_index_spec.pipeline_id string REMOTE +resources.vector_search_indexes.*.delta_sync_index_spec.embedding_vector_columns[*].embedding_dimension *int ALL +resources.vector_search_indexes.*.delta_sync_index_spec.embedding_vector_columns[*].name *string ALL +resources.vector_search_indexes.*.delta_sync_index_spec.embedding_writeback_table *string ALL +resources.vector_search_indexes.*.delta_sync_index_spec.pipeline_id *string ALL resources.vector_search_indexes.*.delta_sync_index_spec.pipeline_type vectorsearch.PipelineType ALL -resources.vector_search_indexes.*.delta_sync_index_spec.source_table string ALL +resources.vector_search_indexes.*.delta_sync_index_spec.source_table *string ALL resources.vector_search_indexes.*.direct_access_index_spec *vectorsearch.DirectAccessVectorIndexSpec ALL resources.vector_search_indexes.*.direct_access_index_spec.embedding_source_columns []vectorsearch.EmbeddingSourceColumn ALL resources.vector_search_indexes.*.direct_access_index_spec.embedding_source_columns[*] vectorsearch.EmbeddingSourceColumn ALL -resources.vector_search_indexes.*.direct_access_index_spec.embedding_source_columns[*].embedding_model_endpoint_name string ALL -resources.vector_search_indexes.*.direct_access_index_spec.embedding_source_columns[*].model_endpoint_name_for_query string ALL -resources.vector_search_indexes.*.direct_access_index_spec.embedding_source_columns[*].name string ALL +resources.vector_search_indexes.*.direct_access_index_spec.embedding_source_columns[*].embedding_model_endpoint_name *string ALL +resources.vector_search_indexes.*.direct_access_index_spec.embedding_source_columns[*].model_endpoint_name_for_query *string ALL +resources.vector_search_indexes.*.direct_access_index_spec.embedding_source_columns[*].name *string ALL resources.vector_search_indexes.*.direct_access_index_spec.embedding_vector_columns []vectorsearch.EmbeddingVectorColumn ALL resources.vector_search_indexes.*.direct_access_index_spec.embedding_vector_columns[*] vectorsearch.EmbeddingVectorColumn ALL -resources.vector_search_indexes.*.direct_access_index_spec.embedding_vector_columns[*].embedding_dimension int ALL -resources.vector_search_indexes.*.direct_access_index_spec.embedding_vector_columns[*].name string ALL -resources.vector_search_indexes.*.direct_access_index_spec.schema_json string ALL -resources.vector_search_indexes.*.endpoint_id string REMOTE -resources.vector_search_indexes.*.endpoint_name string ALL +resources.vector_search_indexes.*.direct_access_index_spec.embedding_vector_columns[*].embedding_dimension *int ALL +resources.vector_search_indexes.*.direct_access_index_spec.embedding_vector_columns[*].name *string ALL +resources.vector_search_indexes.*.direct_access_index_spec.schema_json *string ALL +resources.vector_search_indexes.*.endpoint_id *string REMOTE +resources.vector_search_indexes.*.endpoint_name *string ALL resources.vector_search_indexes.*.endpoint_uuid string REMOTE STATE resources.vector_search_indexes.*.id string INPUT resources.vector_search_indexes.*.index_subtype vectorsearch.IndexSubtype ALL @@ -4405,49 +4608,49 @@ resources.vector_search_indexes.*.index_type vectorsearch.VectorIndexType ALL resources.vector_search_indexes.*.lifecycle resources.Lifecycle INPUT resources.vector_search_indexes.*.lifecycle.prevent_destroy bool INPUT resources.vector_search_indexes.*.modified_status string INPUT -resources.vector_search_indexes.*.name string ALL -resources.vector_search_indexes.*.primary_key string ALL +resources.vector_search_indexes.*.name *string ALL +resources.vector_search_indexes.*.primary_key *string ALL resources.vector_search_indexes.*.status *vectorsearch.VectorIndexStatus REMOTE -resources.vector_search_indexes.*.status.index_url string REMOTE -resources.vector_search_indexes.*.status.indexed_row_count int64 REMOTE -resources.vector_search_indexes.*.status.message string REMOTE -resources.vector_search_indexes.*.status.ready bool REMOTE +resources.vector_search_indexes.*.status.index_url *string REMOTE +resources.vector_search_indexes.*.status.indexed_row_count *int64 REMOTE +resources.vector_search_indexes.*.status.message *string REMOTE +resources.vector_search_indexes.*.status.ready *bool REMOTE resources.vector_search_indexes.*.url string INPUT resources.vector_search_indexes.*.grants.full_name string ALL resources.vector_search_indexes.*.grants.securable_type string ALL -resources.vector_search_indexes.*.grants[*] catalog.PrivilegeAssignment ALL -resources.vector_search_indexes.*.grants[*].principal string ALL -resources.vector_search_indexes.*.grants[*].privileges []catalog.Privilege ALL -resources.vector_search_indexes.*.grants[*].privileges[*] catalog.Privilege ALL -resources.volumes.*.access_point string REMOTE -resources.volumes.*.browse_only bool REMOTE -resources.volumes.*.catalog_name string ALL -resources.volumes.*.comment string ALL -resources.volumes.*.created_at int64 REMOTE -resources.volumes.*.created_by string REMOTE -resources.volumes.*.encryption_details *catalog.EncryptionDetails REMOTE -resources.volumes.*.encryption_details.sse_encryption_details *catalog.SseEncryptionDetails REMOTE -resources.volumes.*.encryption_details.sse_encryption_details.algorithm catalog.SseEncryptionDetailsAlgorithm REMOTE -resources.volumes.*.encryption_details.sse_encryption_details.aws_kms_key_arn string REMOTE -resources.volumes.*.full_name string REMOTE +resources.vector_search_indexes.*.grants[*] grants.PrivilegeAssignment ALL +resources.vector_search_indexes.*.grants[*].principal *string ALL +resources.vector_search_indexes.*.grants[*].privileges []string ALL +resources.vector_search_indexes.*.grants[*].privileges[*] string ALL +resources.volumes.*.access_point *string REMOTE +resources.volumes.*.browse_only *bool REMOTE +resources.volumes.*.catalog_name *string ALL +resources.volumes.*.comment *string ALL +resources.volumes.*.created_at *int64 REMOTE +resources.volumes.*.created_by *string REMOTE +resources.volumes.*.encryption_details *volumes.EncryptionDetails REMOTE +resources.volumes.*.encryption_details.sse_encryption_details *volumes.SseEncryptionDetails REMOTE +resources.volumes.*.encryption_details.sse_encryption_details.algorithm volumes.SseEncryptionAlgorithm REMOTE +resources.volumes.*.encryption_details.sse_encryption_details.aws_kms_key_arn *string REMOTE +resources.volumes.*.full_name *string REMOTE resources.volumes.*.id string INPUT resources.volumes.*.lifecycle resources.Lifecycle INPUT resources.volumes.*.lifecycle.prevent_destroy bool INPUT -resources.volumes.*.metastore_id string REMOTE +resources.volumes.*.metastore_id *string REMOTE resources.volumes.*.modified_status string INPUT -resources.volumes.*.name string ALL -resources.volumes.*.owner string REMOTE -resources.volumes.*.schema_name string ALL -resources.volumes.*.storage_location string ALL -resources.volumes.*.updated_at int64 REMOTE -resources.volumes.*.updated_by string REMOTE +resources.volumes.*.name *string ALL +resources.volumes.*.owner *string REMOTE +resources.volumes.*.schema_name *string ALL +resources.volumes.*.storage_location *string ALL +resources.volumes.*.updated_at *int64 REMOTE +resources.volumes.*.updated_by *string REMOTE resources.volumes.*.url string INPUT -resources.volumes.*.volume_id string REMOTE +resources.volumes.*.volume_id *string REMOTE resources.volumes.*.volume_path string INPUT -resources.volumes.*.volume_type catalog.VolumeType ALL +resources.volumes.*.volume_type volumes.VolumeType ALL resources.volumes.*.grants.full_name string ALL resources.volumes.*.grants.securable_type string ALL -resources.volumes.*.grants[*] catalog.PrivilegeAssignment ALL -resources.volumes.*.grants[*].principal string ALL -resources.volumes.*.grants[*].privileges []catalog.Privilege ALL -resources.volumes.*.grants[*].privileges[*] catalog.Privilege ALL +resources.volumes.*.grants[*] grants.PrivilegeAssignment ALL +resources.volumes.*.grants[*].principal *string ALL +resources.volumes.*.grants[*].privileges []string ALL +resources.volumes.*.grants[*].privileges[*] string ALL diff --git a/acceptance/bundle/resource_deps/id_chain/out.plan_skip.json b/acceptance/bundle/resource_deps/id_chain/out.plan_skip.json index 34e6950925c..72b4b095cd8 100644 --- a/acceptance/bundle/resource_deps/id_chain/out.plan_skip.json +++ b/acceptance/bundle/resource_deps/id_chain/out.plan_skip.json @@ -7,8 +7,6 @@ "resources.jobs.a": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS][0], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -17,15 +15,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [A_ID], "max_concurrent_runs": 1, "name": "aa", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][0], + "creator_user_name": "[USERNAME]", + "job_id": [A_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { @@ -54,8 +54,6 @@ ], "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS][1], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -64,15 +62,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [B_ID], "max_concurrent_runs": 1, "name": "bb", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][1], + "creator_user_name": "[USERNAME]", + "job_id": [B_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { @@ -101,8 +101,6 @@ ], "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS][2], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -111,15 +109,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [C_ID], "max_concurrent_runs": 1, "name": "cc", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][2], + "creator_user_name": "[USERNAME]", + "job_id": [C_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { @@ -148,8 +148,6 @@ ], "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS][3], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -158,15 +156,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [D_ID], "max_concurrent_runs": 1, "name": "dd", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][3], + "creator_user_name": "[USERNAME]", + "job_id": [D_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { @@ -195,8 +195,6 @@ ], "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS][4], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -205,15 +203,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [E_ID], "max_concurrent_runs": 1, "name": "ee", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][4], + "creator_user_name": "[USERNAME]", + "job_id": [E_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resource_deps/id_chain/out.plan_update.json b/acceptance/bundle/resource_deps/id_chain/out.plan_update.json index 182fe955fca..199070d13e1 100644 --- a/acceptance/bundle/resource_deps/id_chain/out.plan_update.json +++ b/acceptance/bundle/resource_deps/id_chain/out.plan_update.json @@ -23,8 +23,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS][0], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -33,15 +31,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [A_ID], "max_concurrent_runs": 1, "name": "aa", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][0], + "creator_user_name": "[USERNAME]", + "job_id": [A_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "description": { @@ -92,8 +92,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS][1], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -102,15 +100,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [B_ID], "max_concurrent_runs": 1, "name": "bb", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][1], + "creator_user_name": "[USERNAME]", + "job_id": [B_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "description": { @@ -161,8 +161,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS][2], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -171,15 +169,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [C_ID], "max_concurrent_runs": 1, "name": "cc", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][2], + "creator_user_name": "[USERNAME]", + "job_id": [C_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "description": { @@ -230,8 +230,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS][3], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -240,15 +238,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [D_ID], "max_concurrent_runs": 1, "name": "dd", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][3], + "creator_user_name": "[USERNAME]", + "job_id": [D_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "description": { @@ -299,8 +299,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS][4], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -309,15 +307,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [E_ID], "max_concurrent_runs": 1, "name": "ee", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][4], + "creator_user_name": "[USERNAME]", + "job_id": [E_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "description": { diff --git a/acceptance/bundle/resource_deps/job_id/out.plan_delete.json b/acceptance/bundle/resource_deps/job_id/out.plan_delete.json index ac3b30b9286..a1584cb532f 100644 --- a/acceptance/bundle/resource_deps/job_id/out.plan_delete.json +++ b/acceptance/bundle/resource_deps/job_id/out.plan_delete.json @@ -7,8 +7,6 @@ "resources.jobs.bar": { "action": "delete", "remote_state": { - "created_time": [UNIX_TIME_MILLIS][0], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -16,15 +14,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [BAR_ID], "max_concurrent_runs": 1, "name": "job bar", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][0], + "creator_user_name": "[USERNAME]", + "job_id": [BAR_ID], + "run_as_user_name": "[USERNAME]" } }, "resources.jobs.foo": { @@ -36,8 +36,6 @@ ], "action": "delete", "remote_state": { - "created_time": [UNIX_TIME_MILLIS][1], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -45,13 +43,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [FOO_ID], "max_concurrent_runs": 1, "name": "job foo", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -64,7 +60,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][1], + "creator_user_name": "[USERNAME]", + "job_id": [FOO_ID], + "run_as_user_name": "[USERNAME]" } } } diff --git a/acceptance/bundle/resource_deps/job_id_delete_bar/out.plan_delete.json b/acceptance/bundle/resource_deps/job_id_delete_bar/out.plan_delete.json index 7bfd65fc731..342fea7c9ca 100644 --- a/acceptance/bundle/resource_deps/job_id_delete_bar/out.plan_delete.json +++ b/acceptance/bundle/resource_deps/job_id_delete_bar/out.plan_delete.json @@ -7,8 +7,6 @@ "resources.jobs.bar": { "action": "delete", "remote_state": { - "created_time": [UNIX_TIME_MILLIS][0], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -16,15 +14,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [BAR_ID], "max_concurrent_runs": 1, "name": "job bar", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][0], + "creator_user_name": "[USERNAME]", + "job_id": [BAR_ID], + "run_as_user_name": "[USERNAME]" } }, "resources.jobs.foo": { @@ -45,8 +45,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS][1], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -54,13 +52,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [FOO_ID], "max_concurrent_runs": 1, "name": "job foo", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -73,7 +69,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][1], + "creator_user_name": "[USERNAME]", + "job_id": [FOO_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resource_deps/job_id_delete_foo/out.plan_delete.json b/acceptance/bundle/resource_deps/job_id_delete_foo/out.plan_delete.json index 2eaf14f4fd1..5b62ba555dc 100644 --- a/acceptance/bundle/resource_deps/job_id_delete_foo/out.plan_delete.json +++ b/acceptance/bundle/resource_deps/job_id_delete_foo/out.plan_delete.json @@ -7,8 +7,6 @@ "resources.jobs.bar": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS][0], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -16,15 +14,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [BAR_ID], "max_concurrent_runs": 1, "name": "job bar", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][0], + "creator_user_name": "[USERNAME]", + "job_id": [BAR_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { @@ -53,8 +53,6 @@ ], "action": "delete", "remote_state": { - "created_time": [UNIX_TIME_MILLIS][1], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -62,13 +60,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [FOO_ID], "max_concurrent_runs": 1, "name": "job foo", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -81,7 +77,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][1], + "creator_user_name": "[USERNAME]", + "job_id": [FOO_ID], + "run_as_user_name": "[USERNAME]" } } } diff --git a/acceptance/bundle/resource_deps/jobs_update_remote/out.plan_update.json b/acceptance/bundle/resource_deps/jobs_update_remote/out.plan_update.json index 5f91a583afe..994ccb00d54 100644 --- a/acceptance/bundle/resource_deps/jobs_update_remote/out.plan_update.json +++ b/acceptance/bundle/resource_deps/jobs_update_remote/out.plan_update.json @@ -13,8 +13,6 @@ ], "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS][0], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -23,15 +21,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [BAR_ID], "max_concurrent_runs": 1, "name": "bar", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][0], + "creator_user_name": "[USERNAME]", + "job_id": [BAR_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { @@ -85,8 +85,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS][1], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -102,13 +100,11 @@ } } ], - "job_id": [FOO_ID], "max_concurrent_runs": 1, "name": "foo", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, "trigger": { "pause_status": "UNPAUSED", @@ -117,7 +113,11 @@ "unit": "HOURS" } }, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][1], + "creator_user_name": "[USERNAME]", + "job_id": [FOO_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resource_deps/non_existent_field/out.deploy.txt b/acceptance/bundle/resource_deps/non_existent_field/out.deploy.txt index 8da224f9751..5f18645c9c4 100644 --- a/acceptance/bundle/resource_deps/non_existent_field/out.deploy.txt +++ b/acceptance/bundle/resource_deps/non_existent_field/out.deploy.txt @@ -1,5 +1,5 @@ Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... -Error: cannot plan resources.volumes.foo: cannot resolve "${resources.volumes.bar.non_existent}": schema mismatch: non_existent: field "non_existent" not found in catalog.CreateVolumeRequestContent; non_existent: field "non_existent" not found in catalog.VolumeInfo +Error: cannot plan resources.volumes.foo: cannot resolve "${resources.volumes.bar.non_existent}": schema mismatch: non_existent: field "non_existent" not found in resources.CreateVolumeRequestContent; non_existent: field "non_existent" not found in volumes.VolumeInfo Error: planning failed diff --git a/acceptance/bundle/resource_deps/non_existent_field/out.plan.txt b/acceptance/bundle/resource_deps/non_existent_field/out.plan.txt index 6a2b5d1157c..2c8b7759bf7 100644 --- a/acceptance/bundle/resource_deps/non_existent_field/out.plan.txt +++ b/acceptance/bundle/resource_deps/non_existent_field/out.plan.txt @@ -1,4 +1,4 @@ -Error: cannot plan resources.volumes.foo: cannot resolve "${resources.volumes.bar.non_existent}": schema mismatch: non_existent: field "non_existent" not found in catalog.CreateVolumeRequestContent; non_existent: field "non_existent" not found in catalog.VolumeInfo +Error: cannot plan resources.volumes.foo: cannot resolve "${resources.volumes.bar.non_existent}": schema mismatch: non_existent: field "non_existent" not found in resources.CreateVolumeRequestContent; non_existent: field "non_existent" not found in volumes.VolumeInfo Error: planning failed diff --git a/acceptance/bundle/resource_deps/pipelines_recreate/out.plan_noop.json b/acceptance/bundle/resource_deps/pipelines_recreate/out.plan_noop.json index ab330c5e467..a9c73657492 100644 --- a/acceptance/bundle/resource_deps/pipelines_recreate/out.plan_noop.json +++ b/acceptance/bundle/resource_deps/pipelines_recreate/out.plan_noop.json @@ -13,8 +13,6 @@ ], "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS][0], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -23,15 +21,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [BAR_ID], "max_concurrent_runs": 1, "name": "job bar", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][0], + "creator_user_name": "[USERNAME]", + "job_id": [BAR_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { @@ -55,20 +55,20 @@ "action": "skip", "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[FOO_ID_2]", - "last_modified": [UNIX_TIME_MILLIS][1], "name": "pipeline foo", + "storage": "dbfs:/my-new-storage", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS][1], "pipeline_id": "[FOO_ID_2]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/my-new-storage" + "state": "IDLE" } } } diff --git a/acceptance/bundle/resource_deps/pipelines_recreate/out.plan_update.json b/acceptance/bundle/resource_deps/pipelines_recreate/out.plan_update.json index 86b6c325aee..e957c4c682b 100644 --- a/acceptance/bundle/resource_deps/pipelines_recreate/out.plan_update.json +++ b/acceptance/bundle/resource_deps/pipelines_recreate/out.plan_update.json @@ -32,8 +32,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS][0], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -42,15 +40,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [BAR_ID], "max_concurrent_runs": 1, "name": "job bar", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS][0], + "creator_user_name": "[USERNAME]", + "job_id": [BAR_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "description": { @@ -92,20 +92,20 @@ }, "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[FOO_ID]", - "last_modified": [UNIX_TIME_MILLIS][1], "name": "pipeline foo", + "storage": "dbfs:/my-storage", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS][1], "pipeline_id": "[FOO_ID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/my-storage" + "state": "IDLE" }, "changes": { "storage": { diff --git a/acceptance/bundle/resource_deps/remote_pipeline/out.plan_skip.json b/acceptance/bundle/resource_deps/remote_pipeline/out.plan_skip.json index 37e2b7f7193..0cfbede41ab 100644 --- a/acceptance/bundle/resource_deps/remote_pipeline/out.plan_skip.json +++ b/acceptance/bundle/resource_deps/remote_pipeline/out.plan_skip.json @@ -8,20 +8,20 @@ "action": "skip", "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[UUID]", - "last_modified": [UNIX_TIME_MILLIS], "name": "foo1 name", + "storage": "dbfs:/pipelines/[UUID]", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], "pipeline_id": "[UUID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/[UUID]" + "state": "IDLE" }, "changes": { "storage": { @@ -41,20 +41,20 @@ "action": "skip", "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[UUID]", - "last_modified": [UNIX_TIME_MILLIS], "name": "foo2 foo1.creator_user_name=[USERNAME]", + "storage": "dbfs:/pipelines/[UUID]", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], "pipeline_id": "[UUID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/[UUID]" + "state": "IDLE" }, "changes": { "storage": { @@ -74,20 +74,20 @@ "action": "skip", "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[UUID]", - "last_modified": [UNIX_TIME_MILLIS], "name": "foo3 foo2.state=IDLE", + "storage": "dbfs:/pipelines/[UUID]", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], "pipeline_id": "[UUID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/[UUID]" + "state": "IDLE" }, "changes": { "storage": { @@ -107,20 +107,20 @@ "action": "skip", "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[UUID]", - "last_modified": [UNIX_TIME_MILLIS], "name": "foo4 foo3.last_modified=[UNIX_TIME_MILLIS]", + "storage": "dbfs:/pipelines/[UUID]", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], "pipeline_id": "[UUID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/[UUID]" + "state": "IDLE" }, "changes": { "storage": { diff --git a/acceptance/bundle/resources/apps/create_already_exists/output.txt b/acceptance/bundle/resources/apps/create_already_exists/output.txt index b8440469192..2b423c5886c 100644 --- a/acceptance/bundle/resources/apps/create_already_exists/output.txt +++ b/acceptance/bundle/resources/apps/create_already_exists/output.txt @@ -41,5 +41,29 @@ Files: 2 uploaded, 0 deleted >>> [CLI] apps delete test-app-already-exists { - "name": "" + "active_deployment": { + "deployment_id": "[APP_DEPLOYMENT_ID]", + "source_code_path": "/Workspace/Users/[USERNAME]/test-app-already-exists", + "status": { + "message": "Deployment succeeded", + "state": "SUCCEEDED" + } + }, + "app_status": { + "message": "App status is unavailable.", + "state": "UNAVAILABLE" + }, + "compute_size": "MEDIUM", + "compute_status": { + "message": "App is being deleted.", + "state": "DELETING" + }, + "default_source_code_path": "/Workspace/Users/[USERNAME]/test-app-already-exists", + "forward_user_access_token": true, + "id": "1000", + "name": "test-app-already-exists", + "service_principal_client_id": "[UUID]", + "service_principal_id": [SERVICE_PRINCIPAL_ID], + "service_principal_name": "app-test-app-already-exists", + "url": "test-app-already-exists-123.cloud.databricksapps.com" } diff --git a/acceptance/bundle/resources/apps/immutable/output.txt b/acceptance/bundle/resources/apps/immutable/output.txt index c411677bca0..9a4067a865e 100644 --- a/acceptance/bundle/resources/apps/immutable/output.txt +++ b/acceptance/bundle/resources/apps/immutable/output.txt @@ -30,7 +30,9 @@ You can access the app at my-immutable-app-123.cloud.databricksapps.com { "method": "POST", "path": "/api/2.0/apps/my-immutable-app/start", - "body": {} + "body": { + "name": "my-immutable-app" + } } { "method": "POST", diff --git a/acceptance/bundle/resources/apps/lifecycle-started-omitted/output.txt b/acceptance/bundle/resources/apps/lifecycle-started-omitted/output.txt index 701f2a7743b..8f796cacff1 100644 --- a/acceptance/bundle/resources/apps/lifecycle-started-omitted/output.txt +++ b/acceptance/bundle/resources/apps/lifecycle-started-omitted/output.txt @@ -46,7 +46,9 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged { "method": "POST", "path": "/api/2.0/apps/[UNIQUE_NAME]/start", - "body": {} + "body": { + "name": "[UNIQUE_NAME]" + } } { "method": "POST", diff --git a/acceptance/bundle/resources/apps/lifecycle-started-toggle/output.txt b/acceptance/bundle/resources/apps/lifecycle-started-toggle/output.txt index b6631453d16..547cd7fef98 100644 --- a/acceptance/bundle/resources/apps/lifecycle-started-toggle/output.txt +++ b/acceptance/bundle/resources/apps/lifecycle-started-toggle/output.txt @@ -33,7 +33,9 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged >>> print_app_requests { - "body": {}, + "body": { + "name": "[UNIQUE_NAME]" + }, "method": "POST", "path": "/api/2.0/apps/[UNIQUE_NAME]/start" } @@ -60,7 +62,9 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged >>> print_app_requests { - "body": {}, + "body": { + "name": "[UNIQUE_NAME]" + }, "method": "POST", "path": "/api/2.0/apps/[UNIQUE_NAME]/stop" } diff --git a/acceptance/bundle/resources/apps/lifecycle-started/output.txt b/acceptance/bundle/resources/apps/lifecycle-started/output.txt index 05c88f1cd78..82af0168e0a 100644 --- a/acceptance/bundle/resources/apps/lifecycle-started/output.txt +++ b/acceptance/bundle/resources/apps/lifecycle-started/output.txt @@ -10,6 +10,9 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged { "method": "POST", "path": "/api/2.0/apps", + "q": { + "no_compute": "false" + }, "body": { "description": "my_app_description", "name": "[UNIQUE_NAME]" @@ -80,7 +83,9 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged { "method": "POST", "path": "/api/2.0/apps/[UNIQUE_NAME]/stop", - "body": {} + "body": { + "name": "[UNIQUE_NAME]" + } } { "method": "POST", @@ -90,7 +95,8 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "description": "MY_APP_DESCRIPTION_2", "name": "[UNIQUE_NAME]" }, - "update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_size,compute_min_instances,compute_max_instances,git_repository,telemetry_export_destinations" + "app_name": "[UNIQUE_NAME]", + "update_mask": "budget_policy_id,compute_max_instances,compute_min_instances,compute_size,description,git_repository,resources,telemetry_export_destinations,usage_policy_id,user_api_scopes" } } @@ -117,13 +123,16 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "description": "MY_APP_DESCRIPTION_3", "name": "[UNIQUE_NAME]" }, - "update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_size,compute_min_instances,compute_max_instances,git_repository,telemetry_export_destinations" + "app_name": "[UNIQUE_NAME]", + "update_mask": "budget_policy_id,compute_max_instances,compute_min_instances,compute_size,description,git_repository,resources,telemetry_export_destinations,usage_policy_id,user_api_scopes" } } { "method": "POST", "path": "/api/2.0/apps/[UNIQUE_NAME]/start", - "body": {} + "body": { + "name": "[UNIQUE_NAME]" + } } { "method": "POST", diff --git a/acceptance/bundle/resources/apps/resource-refs/output.txt b/acceptance/bundle/resources/apps/resource-refs/output.txt index 1690bee41eb..95875254807 100644 --- a/acceptance/bundle/resources/apps/resource-refs/output.txt +++ b/acceptance/bundle/resources/apps/resource-refs/output.txt @@ -32,7 +32,9 @@ You can access the app at data-app-123.cloud.databricksapps.com { "method": "POST", "path": "/api/2.0/apps/data-app/start", - "body": {} + "body": { + "name": "data-app" + } } { "method": "POST", diff --git a/acceptance/bundle/resources/apps/update/out.requests.json b/acceptance/bundle/resources/apps/update/out.requests.json index e68269ec514..787422fc337 100644 --- a/acceptance/bundle/resources/apps/update/out.requests.json +++ b/acceptance/bundle/resources/apps/update/out.requests.json @@ -17,7 +17,8 @@ "description": "MY_APP_DESCRIPTION", "name": "myappname" }, - "update_mask": "description,budget_policy_id,usage_policy_id,resources,user_api_scopes,compute_size,compute_min_instances,compute_max_instances,git_repository,telemetry_export_destinations" + "app_name": "myappname", + "update_mask": "budget_policy_id,compute_max_instances,compute_min_instances,compute_size,description,git_repository,resources,telemetry_export_destinations,usage_policy_id,user_api_scopes" } } { diff --git a/acceptance/bundle/resources/catalogs/comment_out_of_band/output.txt b/acceptance/bundle/resources/catalogs/comment_out_of_band/output.txt index 58bebd5aac2..25c732582c6 100644 --- a/acceptance/bundle/resources/catalogs/comment_out_of_band/output.txt +++ b/acceptance/bundle/resources/catalogs/comment_out_of_band/output.txt @@ -47,7 +47,8 @@ Resources: 0 created, 0 changed, 0 deleted, 1 unchanged "path": "/api/2.1/unity-catalog/catalogs/test-catalog-[UNIQUE_NAME]", "body": { "comment": "", - "custom_max_retention_hours": 0 + "custom_max_retention_hours": 0, + "name_arg": "test-catalog-[UNIQUE_NAME]" } } diff --git a/acceptance/bundle/resources/cluster_policies/permissions/levels/output.txt b/acceptance/bundle/resources/cluster_policies/permissions/levels/output.txt index 37d4c20606e..d21c3535b6e 100644 --- a/acceptance/bundle/resources/cluster_policies/permissions/levels/output.txt +++ b/acceptance/bundle/resources/cluster_policies/permissions/levels/output.txt @@ -16,7 +16,9 @@ Resources: 2 created, 0 changed, 0 deleted, 0 unchanged "group_name": "users", "permission_level": "CAN_USE" } - ] + ], + "request_object_id": "[TEST_CLUSTER_POLICY_ID]", + "request_object_type": "cluster-policies" } } diff --git a/acceptance/bundle/resources/cluster_policies/permissions/out_of_band_grant/output.txt b/acceptance/bundle/resources/cluster_policies/permissions/out_of_band_grant/output.txt index 886ab1d7f1d..c2b62e2d5b8 100644 --- a/acceptance/bundle/resources/cluster_policies/permissions/out_of_band_grant/output.txt +++ b/acceptance/bundle/resources/cluster_policies/permissions/out_of_band_grant/output.txt @@ -61,7 +61,9 @@ Resources: 0 created, 1 changed, 0 deleted, 1 unchanged "group_name": "users", "permission_level": "CAN_USE" } - ] + ], + "request_object_id": "[TEST_CLUSTER_POLICY_ID]", + "request_object_type": "cluster-policies" } } diff --git a/acceptance/bundle/resources/clusters/deploy/update-and-resize-autoscale/out.plan_.json b/acceptance/bundle/resources/clusters/deploy/update-and-resize-autoscale/out.plan_.json index 9836cda3719..0854d00b3b5 100644 --- a/acceptance/bundle/resources/clusters/deploy/update-and-resize-autoscale/out.plan_.json +++ b/acceptance/bundle/resources/clusters/deploy/update-and-resize-autoscale/out.plan_.json @@ -46,13 +46,13 @@ "cluster_name": "test-cluster-[UNIQUE_NAME]", "driver_node_type_id": "[NODE_TYPE_ID]", "enable_elastic_disk": false, - "lifecycle": { - "started": false - }, "node_type_id": "[NODE_TYPE_ID]", "num_workers": 2, "spark_version": "13.3.x-snapshot-scala2.12", - "state": "TERMINATED" + "state": "TERMINATED", + "lifecycle": { + "started": false + } }, "changes": { "autoscale": { @@ -130,12 +130,12 @@ "cluster_name": "test-cluster-[UNIQUE_NAME]", "driver_node_type_id": "[NODE_TYPE_ID]", "enable_elastic_disk": false, - "lifecycle": { - "started": false - }, "node_type_id": "[NODE_TYPE_ID]", "spark_version": "13.3.x-snapshot-scala2.12", - "state": "TERMINATED" + "state": "TERMINATED", + "lifecycle": { + "started": false + } }, "changes": { "autoscale.max_workers": { @@ -213,12 +213,12 @@ "cluster_name": "test-cluster-[UNIQUE_NAME]", "driver_node_type_id": "[NODE_TYPE_ID]", "enable_elastic_disk": false, - "lifecycle": { - "started": true - }, "node_type_id": "[NODE_TYPE_ID]", "spark_version": "13.3.x-snapshot-scala2.12", - "state": "RUNNING" + "state": "RUNNING", + "lifecycle": { + "started": true + } }, "changes": { "autoscale.max_workers": { @@ -295,12 +295,12 @@ "cluster_name": "test-cluster-[UNIQUE_NAME]", "driver_node_type_id": "[NODE_TYPE_ID]", "enable_elastic_disk": false, - "lifecycle": { - "started": true - }, "node_type_id": "[NODE_TYPE_ID]", "spark_version": "13.3.x-snapshot-scala2.12", - "state": "RUNNING" + "state": "RUNNING", + "lifecycle": { + "started": true + } }, "changes": { "autoscale": { diff --git a/acceptance/bundle/resources/clusters/deploy/update-and-resize/out.plan_.json b/acceptance/bundle/resources/clusters/deploy/update-and-resize/out.plan_.json index d456a1730b5..4c44b8a1a4f 100644 --- a/acceptance/bundle/resources/clusters/deploy/update-and-resize/out.plan_.json +++ b/acceptance/bundle/resources/clusters/deploy/update-and-resize/out.plan_.json @@ -49,15 +49,15 @@ "cluster_name": "test-cluster-[UNIQUE_NAME]", "enable_elastic_disk": false, "instance_pool_id": "[TEST_INSTANCE_POOL_ID]", - "lifecycle": { - "started": true - }, "num_workers": 2, "spark_conf": { "spark.executor.memory": "2g" }, "spark_version": "13.3.x-snapshot-scala2.12", - "state": "RUNNING" + "state": "RUNNING", + "lifecycle": { + "started": true + } }, "changes": { "aws_attributes": { @@ -121,15 +121,15 @@ "cluster_name": "test-cluster-[UNIQUE_NAME]", "enable_elastic_disk": false, "instance_pool_id": "[TEST_INSTANCE_POOL_ID]", - "lifecycle": { - "started": true - }, "num_workers": 3, "spark_conf": { "spark.executor.memory": "2g" }, "spark_version": "13.3.x-snapshot-scala2.12", - "state": "RUNNING" + "state": "RUNNING", + "lifecycle": { + "started": true + } }, "changes": { "aws_attributes": { @@ -193,15 +193,15 @@ "cluster_name": "test-cluster-[UNIQUE_NAME]", "enable_elastic_disk": false, "instance_pool_id": "[TEST_INSTANCE_POOL_ID]", - "lifecycle": { - "started": true - }, "num_workers": 4, "spark_conf": { "spark.executor.memory": "2g" }, "spark_version": "13.3.x-snapshot-scala2.12", - "state": "RUNNING" + "state": "RUNNING", + "lifecycle": { + "started": true + } }, "changes": { "aws_attributes": { diff --git a/acceptance/bundle/resources/dashboards/change-embed-credentials/out.patch.requests.txt b/acceptance/bundle/resources/dashboards/change-embed-credentials/out.patch.requests.txt index f88ab90fe86..c3fbd68acd5 100644 --- a/acceptance/bundle/resources/dashboards/change-embed-credentials/out.patch.requests.txt +++ b/acceptance/bundle/resources/dashboards/change-embed-credentials/out.patch.requests.txt @@ -2,6 +2,7 @@ "method": "PATCH", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]", "body": { + "dashboard_id": "[DASHBOARD_ID]", "display_name": "test dashboard", "parent_path": "/Workspace/Users/[USERNAME]/.bundle/change-embed-credentials-[UNIQUE_NAME]/default/resources", "serialized_dashboard": "{}\n", diff --git a/acceptance/bundle/resources/dashboards/change-embed-credentials/out.post.requests.txt b/acceptance/bundle/resources/dashboards/change-embed-credentials/out.post.requests.txt index ec63c18b176..5ba7172b64d 100644 --- a/acceptance/bundle/resources/dashboards/change-embed-credentials/out.post.requests.txt +++ b/acceptance/bundle/resources/dashboards/change-embed-credentials/out.post.requests.txt @@ -19,6 +19,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", "body": { + "dashboard_id": "[DASHBOARD_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } @@ -34,6 +35,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", "body": { + "dashboard_id": "[DASHBOARD_ID]", "embed_credentials": true, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } diff --git a/acceptance/bundle/resources/dashboards/change-name/out.patch.requests.txt b/acceptance/bundle/resources/dashboards/change-name/out.patch.requests.txt index da0d6021446..cd675dcf32e 100644 --- a/acceptance/bundle/resources/dashboards/change-name/out.patch.requests.txt +++ b/acceptance/bundle/resources/dashboards/change-name/out.patch.requests.txt @@ -2,6 +2,7 @@ "method": "PATCH", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]", "body": { + "dashboard_id": "[DASHBOARD_ID]", "display_name": "dashboard2", "parent_path": "/Workspace/Users/[USERNAME]/.bundle/change-name-[UNIQUE_NAME]/default/resources", "serialized_dashboard": "{}\n", diff --git a/acceptance/bundle/resources/dashboards/change-name/out.post.requests.txt b/acceptance/bundle/resources/dashboards/change-name/out.post.requests.txt index 0ba99dc6e58..f6ee5347278 100644 --- a/acceptance/bundle/resources/dashboards/change-name/out.post.requests.txt +++ b/acceptance/bundle/resources/dashboards/change-name/out.post.requests.txt @@ -19,6 +19,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", "body": { + "dashboard_id": "[DASHBOARD_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } @@ -34,6 +35,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", "body": { + "dashboard_id": "[DASHBOARD_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } diff --git a/acceptance/bundle/resources/dashboards/change-parent-path/out.dashboardrequests.txt b/acceptance/bundle/resources/dashboards/change-parent-path/out.dashboardrequests.txt index b53ee4016c4..854fe95683b 100644 --- a/acceptance/bundle/resources/dashboards/change-parent-path/out.dashboardrequests.txt +++ b/acceptance/bundle/resources/dashboards/change-parent-path/out.dashboardrequests.txt @@ -19,6 +19,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[ORIGINAL_DASHBOARD_ID]/published", "body": { + "dashboard_id": "[ORIGINAL_DASHBOARD_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } @@ -65,6 +66,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[NEW_DASHBOARD_ID]/published", "body": { + "dashboard_id": "[NEW_DASHBOARD_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } diff --git a/acceptance/bundle/resources/dashboards/change-serialized-dashboard/out.patch.requests.txt b/acceptance/bundle/resources/dashboards/change-serialized-dashboard/out.patch.requests.txt index 361de88df6c..fa483df7f81 100644 --- a/acceptance/bundle/resources/dashboards/change-serialized-dashboard/out.patch.requests.txt +++ b/acceptance/bundle/resources/dashboards/change-serialized-dashboard/out.patch.requests.txt @@ -2,6 +2,7 @@ "method": "PATCH", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]", "body": { + "dashboard_id": "[DASHBOARD_ID]", "display_name": "test dashboard", "parent_path": "/Workspace/Users/[USERNAME]/.bundle/change-serialized-dashboard-[UNIQUE_NAME]/default/resources", "serialized_dashboard": "{\"pages\":[{\"name\":\"name2\",\"displayName\":\"name2\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}\n", diff --git a/acceptance/bundle/resources/dashboards/change-serialized-dashboard/out.post.requests.txt b/acceptance/bundle/resources/dashboards/change-serialized-dashboard/out.post.requests.txt index 3c3e001344d..c5d7f744004 100644 --- a/acceptance/bundle/resources/dashboards/change-serialized-dashboard/out.post.requests.txt +++ b/acceptance/bundle/resources/dashboards/change-serialized-dashboard/out.post.requests.txt @@ -19,6 +19,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", "body": { + "dashboard_id": "[DASHBOARD_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } @@ -34,6 +35,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", "body": { + "dashboard_id": "[DASHBOARD_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } diff --git a/acceptance/bundle/resources/dashboards/change-serialized-inline/out.plan.json b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.plan.json index f4532ccbb36..bc8a97b2fb1 100644 --- a/acceptance/bundle/resources/dashboards/change-serialized-inline/out.plan.json +++ b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.plan.json @@ -9,26 +9,24 @@ "new_state": { "value": { "display_name": "Inline Dash", - "embed_credentials": false, "parent_path": "/Workspace/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/resources", - "published": true, + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Page One\",\"name\":\"page1\"}]}", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "published": true } }, "remote_state": { "create_time": "[TIMESTAMP]", "dashboard_id": "[DASHBOARD_ID]", "display_name": "Inline Dash", - "embed_credentials": false, "etag": "80611980", "lifecycle_state": "ACTIVE", "parent_path": "/Workspace/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/resources", "path": "/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/resources/Inline Dash.lvdash.json", - "published": true, - "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Page 1\",\"name\":\"page1\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}\n", "update_time": "[TIMESTAMP]", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", + "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Page 1\",\"name\":\"page1\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}\n", + "published": true }, "changes": { "create_time": { diff --git a/acceptance/bundle/resources/dashboards/change-serialized-inline/out.requests.txt b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.requests.txt index 763f6fc22c7..bb1ae4100bb 100644 --- a/acceptance/bundle/resources/dashboards/change-serialized-inline/out.requests.txt +++ b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.requests.txt @@ -2,6 +2,7 @@ "method": "PATCH", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]", "body": { + "dashboard_id": "[DASHBOARD_ID]", "display_name": "Inline Dash", "parent_path": "/Workspace/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/resources", "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Page One\",\"name\":\"page1\"}]}", @@ -12,6 +13,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", "body": { + "dashboard_id": "[DASHBOARD_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } diff --git a/acceptance/bundle/resources/dashboards/dataset-catalog-schema/out.plan.json b/acceptance/bundle/resources/dashboards/dataset-catalog-schema/out.plan.json index fa0567e471e..41013315119 100644 --- a/acceptance/bundle/resources/dashboards/dataset-catalog-schema/out.plan.json +++ b/acceptance/bundle/resources/dashboards/dataset-catalog-schema/out.plan.json @@ -10,15 +10,15 @@ "create_time": "[TIMESTAMP]", "dashboard_id": "[DASHBOARD_ID]", "display_name": "test bundle-deploy-dashboard-dataset [UUID]", - "embed_credentials": true, "etag": "[ETAG]", "lifecycle_state": "ACTIVE", "parent_path": "/Workspace/Users/[USERNAME]", "path": "/Users/[USERNAME]/test bundle-deploy-dashboard-dataset [UUID].lvdash.json", - "published": true, - "serialized_dashboard": "[SERIALIZED_FIXTURE]", "update_time": "[TIMESTAMP]", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", + "serialized_dashboard": "[SERIALIZED_FIXTURE]", + "embed_credentials": true, + "published": true }, "changes": { "create_time": { diff --git a/acceptance/bundle/resources/dashboards/delete-trashed-out-of-band/out.plan.json b/acceptance/bundle/resources/dashboards/delete-trashed-out-of-band/out.plan.json index a2e342108ae..724202a63d1 100644 --- a/acceptance/bundle/resources/dashboards/delete-trashed-out-of-band/out.plan.json +++ b/acceptance/bundle/resources/dashboards/delete-trashed-out-of-band/out.plan.json @@ -9,11 +9,10 @@ "new_state": { "value": { "display_name": "test bundle-deploy-dashboard [UNIQUE_NAME])", - "embed_credentials": false, "parent_path": "/Workspace/Users/[USERNAME]/.bundle/delete-trashed-out-of-band-[UNIQUE_NAME]/default/resources", - "published": true, + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", "serialized_dashboard": "{\"pages\":[{\"name\":\"test-page\",\"displayName\":\"Test Dashboard\"}]}\n", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "published": true } }, "changes": { diff --git a/acceptance/bundle/resources/dashboards/detect-change/out.patch.requests.txt b/acceptance/bundle/resources/dashboards/detect-change/out.patch.requests.txt index dbd639d9cfe..f35ae174b9e 100644 --- a/acceptance/bundle/resources/dashboards/detect-change/out.patch.requests.txt +++ b/acceptance/bundle/resources/dashboards/detect-change/out.patch.requests.txt @@ -2,6 +2,7 @@ "method": "PATCH", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]", "body": { + "dashboard_id": "[DASHBOARD_ID]", "serialized_dashboard": "{}", "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } @@ -10,6 +11,7 @@ "method": "PATCH", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]", "body": { + "dashboard_id": "[DASHBOARD_ID]", "display_name": "test-dashboard-[UNIQUE_NAME]", "parent_path": "/Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/resources", "serialized_dashboard": "{\n \"pages\": [\n {\n \"displayName\": \"New Page\",\n \"layout\": [\n {\n \"position\": {\n \"height\": 2,\n \"width\": 6,\n \"x\": 0,\n \"y\": 0\n },\n \"widget\": {\n \"name\": \"82eb9107\",\n \"textbox_spec\": \"# I'm a title\"\n }\n },\n {\n \"position\": {\n \"height\": 2,\n \"width\": 6,\n \"x\": 0,\n \"y\": 2\n },\n \"widget\": {\n \"name\": \"ffa6de4f\",\n \"textbox_spec\": \"Text\"\n }\n }\n ],\n \"name\": \"fdd21a3c\"\n }\n ]\n}\n", diff --git a/acceptance/bundle/resources/dashboards/detect-change/out.plan.json b/acceptance/bundle/resources/dashboards/detect-change/out.plan.json index 74462c9c567..511623a838b 100644 --- a/acceptance/bundle/resources/dashboards/detect-change/out.plan.json +++ b/acceptance/bundle/resources/dashboards/detect-change/out.plan.json @@ -9,26 +9,24 @@ "new_state": { "value": { "display_name": "test-dashboard-[UNIQUE_NAME]", - "embed_credentials": false, "parent_path": "/Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/resources", - "published": true, + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", "serialized_dashboard": "{\n \"pages\": [\n {\n \"displayName\": \"New Page\",\n \"layout\": [\n {\n \"position\": {\n \"height\": 2,\n \"width\": 6,\n \"x\": 0,\n \"y\": 0\n },\n \"widget\": {\n \"name\": \"82eb9107\",\n \"textbox_spec\": \"# I'm a title\"\n }\n },\n {\n \"position\": {\n \"height\": 2,\n \"width\": 6,\n \"x\": 0,\n \"y\": 2\n },\n \"widget\": {\n \"name\": \"ffa6de4f\",\n \"textbox_spec\": \"Text\"\n }\n }\n ],\n \"name\": \"fdd21a3c\"\n }\n ]\n}\n", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "published": true } }, "remote_state": { "create_time": "[TIMESTAMP]", "dashboard_id": "[DASHBOARD_ID]", "display_name": "test-dashboard-[UNIQUE_NAME]", - "embed_credentials": false, "etag": "[ETAG_2]", "lifecycle_state": "ACTIVE", "parent_path": "/Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/resources", "path": "/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/resources/test-dashboard-[UNIQUE_NAME].lvdash.json", - "published": false, - "serialized_dashboard": "{}\n", "update_time": "[TIMESTAMP]", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", + "serialized_dashboard": "{}\n", + "published": false }, "changes": { "create_time": { diff --git a/acceptance/bundle/resources/dashboards/detect-change/out.post.requests.txt b/acceptance/bundle/resources/dashboards/detect-change/out.post.requests.txt index 8554a42a88f..472074f885f 100644 --- a/acceptance/bundle/resources/dashboards/detect-change/out.post.requests.txt +++ b/acceptance/bundle/resources/dashboards/detect-change/out.post.requests.txt @@ -12,6 +12,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", "body": { + "dashboard_id": "[DASHBOARD_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } @@ -20,6 +21,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", "body": { + "dashboard_id": "[DASHBOARD_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } diff --git a/acceptance/bundle/resources/dashboards/publish-failure-cleans-up-dashboard/out.dashboardrequests.txt b/acceptance/bundle/resources/dashboards/publish-failure-cleans-up-dashboard/out.dashboardrequests.txt index 3d6b7be0fe8..8ffae32360d 100644 --- a/acceptance/bundle/resources/dashboards/publish-failure-cleans-up-dashboard/out.dashboardrequests.txt +++ b/acceptance/bundle/resources/dashboards/publish-failure-cleans-up-dashboard/out.dashboardrequests.txt @@ -40,6 +40,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", "body": { + "dashboard_id": "[DASHBOARD_ID]", "embed_credentials": false, "warehouse_id": "doesnotexist" } diff --git a/acceptance/bundle/resources/dashboards/publish-failure-stale-content/output.txt b/acceptance/bundle/resources/dashboards/publish-failure-stale-content/output.txt index f57df03fe5e..2901733b1e0 100644 --- a/acceptance/bundle/resources/dashboards/publish-failure-stale-content/output.txt +++ b/acceptance/bundle/resources/dashboards/publish-failure-stale-content/output.txt @@ -41,6 +41,7 @@ Exit code: 1 "method": "PATCH", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD1_ID]", "body": { + "dashboard_id": "[DASHBOARD1_ID]", "display_name": "my dashboard renamed", "parent_path": "/Workspace/Users/[USERNAME]/.bundle/update-publish-failure-stale-content/default/resources", "serialized_dashboard": "{\"pages\":[{\"name\":\"test-page\",\"displayName\":\"Test Dashboard\"}]}\n", @@ -51,6 +52,7 @@ Exit code: 1 "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD1_ID]/published", "body": { + "dashboard_id": "[DASHBOARD1_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } @@ -134,6 +136,7 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "method": "PATCH", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD1_ID]", "body": { + "dashboard_id": "[DASHBOARD1_ID]", "display_name": "my dashboard renamed", "parent_path": "/Workspace/Users/[USERNAME]/.bundle/update-publish-failure-stale-content/default/resources", "serialized_dashboard": "{\"pages\":[{\"name\":\"test-page\",\"displayName\":\"Test Dashboard\"}]}\n", @@ -144,6 +147,7 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD1_ID]/published", "body": { + "dashboard_id": "[DASHBOARD1_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } diff --git a/acceptance/bundle/resources/dashboards/serialized-inline/output.txt b/acceptance/bundle/resources/dashboards/serialized-inline/output.txt index 24083cbb777..3040a4c742f 100644 --- a/acceptance/bundle/resources/dashboards/serialized-inline/output.txt +++ b/acceptance/bundle/resources/dashboards/serialized-inline/output.txt @@ -23,6 +23,7 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged "method": "POST", "path": "/api/2.0/lakeview/dashboards/[INLINE_DASH_ID]/published", "body": { + "dashboard_id": "[INLINE_DASH_ID]", "embed_credentials": false, "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } diff --git a/acceptance/bundle/resources/dashboards/simple/out.plan.json b/acceptance/bundle/resources/dashboards/simple/out.plan.json index 1f3d8674749..95ca60038a6 100644 --- a/acceptance/bundle/resources/dashboards/simple/out.plan.json +++ b/acceptance/bundle/resources/dashboards/simple/out.plan.json @@ -10,15 +10,15 @@ "create_time": "[TIMESTAMP]", "dashboard_id": "[DASHBOARD_ID]", "display_name": "test bundle-deploy-dashboard [UUID]", - "embed_credentials": true, "etag": "[ETAG]", "lifecycle_state": "ACTIVE", "parent_path": "/Workspace/Users/[USERNAME]", "path": "/Users/[USERNAME]/test bundle-deploy-dashboard [UUID].lvdash.json", - "published": true, - "serialized_dashboard": "{}\n", "update_time": "[TIMESTAMP]", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", + "serialized_dashboard": "{}\n", + "embed_credentials": true, + "published": true }, "changes": { "create_time": { diff --git a/acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.plan.json b/acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.plan.json index fadf6fe32eb..4fb5cb2e616 100644 --- a/acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.plan.json +++ b/acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.plan.json @@ -9,26 +9,24 @@ "new_state": { "value": { "display_name": "test bundle-deploy-dashboard [UNIQUE_NAME]", - "embed_credentials": false, "parent_path": "/Workspace/Users/[USERNAME]/.bundle/unpublish-out-of-band-[UNIQUE_NAME]/default/resources", - "published": true, + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Test Dashboard\",\"name\":\"test-page\"}]}", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "published": true } }, "remote_state": { "create_time": "[TIMESTAMP]", "dashboard_id": "[DASHBOARD1_ID]", "display_name": "test bundle-deploy-dashboard [UNIQUE_NAME]", - "embed_credentials": false, "etag": "[ETAG]", "lifecycle_state": "ACTIVE", "parent_path": "/Workspace/Users/[USERNAME]/.bundle/unpublish-out-of-band-[UNIQUE_NAME]/default/resources", "path": "/Users/[USERNAME]/.bundle/unpublish-out-of-band-[UNIQUE_NAME]/default/resources/test bundle-deploy-dashboard [UNIQUE_NAME].lvdash.json", - "published": false, - "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Test Dashboard\",\"name\":\"test-page\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}", "update_time": "[TIMESTAMP]", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", + "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Test Dashboard\",\"name\":\"test-page\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}", + "published": false }, "changes": { "create_time": { diff --git a/acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.plan_initial.json b/acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.plan_initial.json index 1584efd2131..28a4ec5d28b 100644 --- a/acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.plan_initial.json +++ b/acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.plan_initial.json @@ -7,11 +7,10 @@ "new_state": { "value": { "display_name": "test bundle-deploy-dashboard [UNIQUE_NAME]", - "embed_credentials": false, "parent_path": "/Workspace/Users/[USERNAME]/.bundle/unpublish-out-of-band-[UNIQUE_NAME]/default/resources", - "published": true, + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", "serialized_dashboard": "{\"pages\":[{\"name\":\"test-page\",\"displayName\":\"Test Dashboard\"}]}\n", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "published": true } } } diff --git a/acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.state.json b/acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.state.json index 393d9af4f43..8222a2be87e 100644 --- a/acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.state.json +++ b/acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.state.json @@ -1,2 +1,2 @@ "parent_path": "/Workspace/Users/[USERNAME]/.bundle/unpublish-out-of-band-[UNIQUE_NAME]/default/resources", - "published": true, + "published": true diff --git a/acceptance/bundle/resources/external_locations/comment_cleared/output.txt b/acceptance/bundle/resources/external_locations/comment_cleared/output.txt index a7b39cb324d..3e988876fca 100644 --- a/acceptance/bundle/resources/external_locations/comment_cleared/output.txt +++ b/acceptance/bundle/resources/external_locations/comment_cleared/output.txt @@ -29,6 +29,7 @@ Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged "body": { "comment": "", "credential_name": "test_storage_credential", + "name_arg": "myloc", "url": "s3://test-bucket/path" } } diff --git a/acceptance/bundle/resources/genie_spaces/change-serialized-space/output.txt b/acceptance/bundle/resources/genie_spaces/change-serialized-space/output.txt index 9100e42528f..ac5bd5b34c6 100644 --- a/acceptance/bundle/resources/genie_spaces/change-serialized-space/output.txt +++ b/acceptance/bundle/resources/genie_spaces/change-serialized-space/output.txt @@ -39,6 +39,7 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "description": "", "parent_path": "/Workspace/Users/[USERNAME]/.bundle/change-serialized-space-[UNIQUE_NAME]/default/resources", "serialized_space": "{\"version\":1,\"instructions\":{\"text_instructions\":[{\"id\":\"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4\",\"content\":[\"Summarize sales revenue by month\"]}]}}\n", + "space_id": "[MY_SPACE_ID]", "title": "test genie space", "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" } diff --git a/acceptance/bundle/resources/genie_spaces/inline/out.plan.json b/acceptance/bundle/resources/genie_spaces/inline/out.plan.json index ec5340a256c..3e7ec280e12 100644 --- a/acceptance/bundle/resources/genie_spaces/inline/out.plan.json +++ b/acceptance/bundle/resources/genie_spaces/inline/out.plan.json @@ -9,10 +9,10 @@ "remote_state": { "description": "Inline serialized_space test", "etag": "1", - "parent_path": "/Workspace/Users/[USERNAME]/.bundle/deploy-genie-space-inline-[UNIQUE_NAME]/default/resources", - "serialized_space": "{\"config\":{\"sample_questions\":[{\"id\":\"sq-001\",\"question\":[\"What is the total revenue?\"]}]},\"data_sources\":{\"tables\":[{\"column_configs\":[{\"column_name\":\"amount\",\"get_example_values\":true}],\"identifier\":\"main.sales.orders\"}]},\"version\":2}", "title": "Sales Analytics Inline Genie", - "warehouse_id": "test-warehouse-id" + "warehouse_id": "test-warehouse-id", + "parent_path": "/Workspace/Users/[USERNAME]/.bundle/deploy-genie-space-inline-[UNIQUE_NAME]/default/resources", + "serialized_space": "{\"config\":{\"sample_questions\":[{\"id\":\"sq-001\",\"question\":[\"What is the total revenue?\"]}]},\"data_sources\":{\"tables\":[{\"column_configs\":[{\"column_name\":\"amount\",\"get_example_values\":true}],\"identifier\":\"main.sales.orders\"}]},\"version\":2}" }, "changes": { "etag": { diff --git a/acceptance/bundle/resources/grants/catalogs/out.deploy1.requests.json b/acceptance/bundle/resources/grants/catalogs/out.deploy1.requests.json index 16f913b8a77..c784f81edb6 100644 --- a/acceptance/bundle/resources/grants/catalogs/out.deploy1.requests.json +++ b/acceptance/bundle/resources/grants/catalogs/out.deploy1.requests.json @@ -13,6 +13,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "catalog_grants_[UNIQUE_NAME]", + "securable_type": "catalog" } } diff --git a/acceptance/bundle/resources/grants/catalogs/out.deploy2.requests.json b/acceptance/bundle/resources/grants/catalogs/out.deploy2.requests.json index 47e1335feae..ddeef66c13e 100644 --- a/acceptance/bundle/resources/grants/catalogs/out.deploy2.requests.json +++ b/acceptance/bundle/resources/grants/catalogs/out.deploy2.requests.json @@ -13,6 +13,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "catalog_grants_[UNIQUE_NAME]", + "securable_type": "catalog" } } diff --git a/acceptance/bundle/resources/grants/mcp_services/out.deploy1.requests.json b/acceptance/bundle/resources/grants/mcp_services/out.deploy1.requests.json index 6e62d295a5b..c2946cd99e7 100644 --- a/acceptance/bundle/resources/grants/mcp_services/out.deploy1.requests.json +++ b/acceptance/bundle/resources/grants/mcp_services/out.deploy1.requests.json @@ -12,6 +12,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.myschema.myservice", + "securable_type": "mcp_service" } } diff --git a/acceptance/bundle/resources/grants/mcp_services/out.plan1.json b/acceptance/bundle/resources/grants/mcp_services/out.plan1.json index 9150113092f..04f44181e9c 100644 --- a/acceptance/bundle/resources/grants/mcp_services/out.plan1.json +++ b/acceptance/bundle/resources/grants/mcp_services/out.plan1.json @@ -6,9 +6,9 @@ "action": "create", "new_state": { "value": { - "comment": "mycomment", + "parent": "schemas/main.myschema", "mcp_service_id": "myservice", - "parent": "schemas/main.myschema" + "comment": "mycomment" } } }, diff --git a/acceptance/bundle/resources/grants/model_provider_services/out.deploy1.requests.json b/acceptance/bundle/resources/grants/model_provider_services/out.deploy1.requests.json index afcc75cc24f..5ee3adb4ea5 100644 --- a/acceptance/bundle/resources/grants/model_provider_services/out.deploy1.requests.json +++ b/acceptance/bundle/resources/grants/model_provider_services/out.deploy1.requests.json @@ -12,6 +12,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.myschema.myservice", + "securable_type": "model_provider_service" } } diff --git a/acceptance/bundle/resources/grants/model_provider_services/out.plan1.json b/acceptance/bundle/resources/grants/model_provider_services/out.plan1.json index 9c7ead61585..ccc66f44924 100644 --- a/acceptance/bundle/resources/grants/model_provider_services/out.plan1.json +++ b/acceptance/bundle/resources/grants/model_provider_services/out.plan1.json @@ -6,6 +6,8 @@ "action": "create", "new_state": { "value": { + "parent": "schemas/main.myschema", + "model_provider_service_id": "myservice", "comment": "mycomment", "config": { "custom": { @@ -25,9 +27,7 @@ ] } ] - }, - "model_provider_service_id": "myservice", - "parent": "schemas/main.myschema" + } } } }, diff --git a/acceptance/bundle/resources/grants/model_services/out.deploy1.requests.json b/acceptance/bundle/resources/grants/model_services/out.deploy1.requests.json index 0cc3d553954..e5679094a55 100644 --- a/acceptance/bundle/resources/grants/model_services/out.deploy1.requests.json +++ b/acceptance/bundle/resources/grants/model_services/out.deploy1.requests.json @@ -12,6 +12,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.myschema.myservice", + "securable_type": "model_service" } } diff --git a/acceptance/bundle/resources/grants/model_services/out.plan1.json b/acceptance/bundle/resources/grants/model_services/out.plan1.json index 8fcd09fb0eb..9d19cf6cf12 100644 --- a/acceptance/bundle/resources/grants/model_services/out.plan1.json +++ b/acceptance/bundle/resources/grants/model_services/out.plan1.json @@ -6,9 +6,9 @@ "action": "create", "new_state": { "value": { - "comment": "mycomment", + "parent": "schemas/main.myschema", "model_service_id": "myservice", - "parent": "schemas/main.myschema" + "comment": "mycomment" } } }, diff --git a/acceptance/bundle/resources/grants/registered_models/out.deploy1.requests.json b/acceptance/bundle/resources/grants/registered_models/out.deploy1.requests.json index 8491f706c62..1338d87b689 100644 --- a/acceptance/bundle/resources/grants/registered_models/out.deploy1.requests.json +++ b/acceptance/bundle/resources/grants/registered_models/out.deploy1.requests.json @@ -12,6 +12,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.myschema_[UNIQUE_NAME].mymodel", + "securable_type": "function" } } diff --git a/acceptance/bundle/resources/grants/schemas/all_privileges/out.requests.txt b/acceptance/bundle/resources/grants/schemas/all_privileges/out.requests.txt index d7cef386ad9..27c679e04ba 100644 --- a/acceptance/bundle/resources/grants/schemas/all_privileges/out.requests.txt +++ b/acceptance/bundle/resources/grants/schemas/all_privileges/out.requests.txt @@ -9,6 +9,8 @@ ], "principal": "deco-test-user@databricks.com" } - ] + ], + "securable_full_name": "main.schema_dup_grants_[UNIQUE_NAME]", + "securable_type": "schema" } } diff --git a/acceptance/bundle/resources/grants/schemas/all_privileges_manage/output.txt b/acceptance/bundle/resources/grants/schemas/all_privileges_manage/output.txt index d31b6a0422e..95c00002ed3 100644 --- a/acceptance/bundle/resources/grants/schemas/all_privileges_manage/output.txt +++ b/acceptance/bundle/resources/grants/schemas/all_privileges_manage/output.txt @@ -19,7 +19,9 @@ Resources: 2 created, 0 changed, 0 deleted, 0 unchanged ], "principal": "[USERNAME]" } - ] + ], + "securable_full_name": "main.schema_all_priv_manage_[UNIQUE_NAME]", + "securable_type": "schema" } } diff --git a/acceptance/bundle/resources/grants/schemas/change_privilege/out.deploy1.requests.json b/acceptance/bundle/resources/grants/schemas/change_privilege/out.deploy1.requests.json index 6c18c8b765d..879c595bfc3 100644 --- a/acceptance/bundle/resources/grants/schemas/change_privilege/out.deploy1.requests.json +++ b/acceptance/bundle/resources/grants/schemas/change_privilege/out.deploy1.requests.json @@ -13,6 +13,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.schema_grants_[UNIQUE_NAME]", + "securable_type": "schema" } } diff --git a/acceptance/bundle/resources/grants/schemas/change_privilege/out.deploy2.requests.json b/acceptance/bundle/resources/grants/schemas/change_privilege/out.deploy2.requests.json index 0701317c990..c8627818f59 100644 --- a/acceptance/bundle/resources/grants/schemas/change_privilege/out.deploy2.requests.json +++ b/acceptance/bundle/resources/grants/schemas/change_privilege/out.deploy2.requests.json @@ -13,6 +13,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.schema_grants_[UNIQUE_NAME]", + "securable_type": "schema" } } diff --git a/acceptance/bundle/resources/grants/schemas/duplicate_principals/out.requests.txt b/acceptance/bundle/resources/grants/schemas/duplicate_principals/out.requests.txt index a0d31441603..ae2a4b76c0f 100644 --- a/acceptance/bundle/resources/grants/schemas/duplicate_principals/out.requests.txt +++ b/acceptance/bundle/resources/grants/schemas/duplicate_principals/out.requests.txt @@ -12,6 +12,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.schema_dup_grants_[UNIQUE_NAME]", + "securable_type": "schema" } } diff --git a/acceptance/bundle/resources/grants/schemas/duplicate_privileges/out.requests.txt b/acceptance/bundle/resources/grants/schemas/duplicate_privileges/out.requests.txt index a0d31441603..ae2a4b76c0f 100644 --- a/acceptance/bundle/resources/grants/schemas/duplicate_privileges/out.requests.txt +++ b/acceptance/bundle/resources/grants/schemas/duplicate_privileges/out.requests.txt @@ -12,6 +12,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.schema_dup_grants_[UNIQUE_NAME]", + "securable_type": "schema" } } diff --git a/acceptance/bundle/resources/grants/schemas/remove_principal_manage/out.requests.txt b/acceptance/bundle/resources/grants/schemas/remove_principal_manage/out.requests.txt index 484afe9c778..d8247fa7269 100644 --- a/acceptance/bundle/resources/grants/schemas/remove_principal_manage/out.requests.txt +++ b/acceptance/bundle/resources/grants/schemas/remove_principal_manage/out.requests.txt @@ -19,6 +19,8 @@ "MANAGE" ] } - ] + ], + "securable_full_name": "main.schema_remove_principal_manage_[UNIQUE_NAME]", + "securable_type": "schema" } } diff --git a/acceptance/bundle/resources/grants/volumes/out.deploy1.requests.json b/acceptance/bundle/resources/grants/volumes/out.deploy1.requests.json index 782eecac450..a7b5ebd245f 100644 --- a/acceptance/bundle/resources/grants/volumes/out.deploy1.requests.json +++ b/acceptance/bundle/resources/grants/volumes/out.deploy1.requests.json @@ -13,6 +13,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.schema_grants_[UNIQUE_NAME].volume_name", + "securable_type": "volume" } } diff --git a/acceptance/bundle/resources/grants/volumes/out.deploy2.requests.json b/acceptance/bundle/resources/grants/volumes/out.deploy2.requests.json index fb9d6e90ba3..c4d8b4573a6 100644 --- a/acceptance/bundle/resources/grants/volumes/out.deploy2.requests.json +++ b/acceptance/bundle/resources/grants/volumes/out.deploy2.requests.json @@ -13,6 +13,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.schema_grants_[UNIQUE_NAME].volume_name", + "securable_type": "volume" } } diff --git a/acceptance/bundle/resources/job_runs/failed_run/output.txt b/acceptance/bundle/resources/job_runs/failed_run/output.txt index 44d3b17412a..3e61b621d24 100644 --- a/acceptance/bundle/resources/job_runs/failed_run/output.txt +++ b/acceptance/bundle/resources/job_runs/failed_run/output.txt @@ -36,13 +36,13 @@ Files: 3 uploaded, 0 deleted "result_state": "FAILED", "run_id": [MY_RUN_ID], "run_name": "test-job-[UNIQUE_NAME]", - "run_page_url": "[RUN_URL]", - "run_type": "JOB_RUN", "state": { "life_cycle_state": "INTERNAL_ERROR", "result_state": "FAILED", "state_message": "Task main failed with message: Workload failed, see run output for details." - } + }, + "run_page_url": "[RUN_URL]", + "run_type": "JOB_RUN" }, "changes": { "result_state": { diff --git a/acceptance/bundle/resources/job_runs/interrupted_run/output.txt b/acceptance/bundle/resources/job_runs/interrupted_run/output.txt index 7b911a49c38..06abb057360 100644 --- a/acceptance/bundle/resources/job_runs/interrupted_run/output.txt +++ b/acceptance/bundle/resources/job_runs/interrupted_run/output.txt @@ -45,11 +45,11 @@ Exit code: 1 "job_id": [MY_JOB_ID], "run_id": [MY_RUN_ID], "run_name": "my-job", - "run_page_url": "[DATABRICKS_URL]/jobs/[MY_JOB_ID]/runs/[MY_RUN_ID]?o=[WORKSPACE_ID]", - "run_type": "JOB_RUN", "state": { "life_cycle_state": "RUNNING" - } + }, + "run_page_url": "[DATABRICKS_URL]/jobs/[MY_JOB_ID]/runs/[MY_RUN_ID]?o=[WORKSPACE_ID]", + "run_type": "JOB_RUN" }, "changes": { "result_state": { diff --git a/acceptance/bundle/resources/job_runs/on_file_change/out.plan.create.json b/acceptance/bundle/resources/job_runs/on_file_change/out.plan.create.json index 8fb3fcdfd59..83652957952 100644 --- a/acceptance/bundle/resources/job_runs/on_file_change/out.plan.create.json +++ b/acceptance/bundle/resources/job_runs/on_file_change/out.plan.create.json @@ -13,14 +13,14 @@ "new_state": { "value": { "job_id": 0, + "result_state": "SUCCESS", "lifecycle": { "triggers_state": { "on_file_change": { "seed.txt": "[FILE_HASH]" } } - }, - "result_state": "SUCCESS" + } }, "vars": { "job_id": "${resources.jobs.my_job.id}" diff --git a/acceptance/bundle/resources/job_runs/on_file_change/output.txt b/acceptance/bundle/resources/job_runs/on_file_change/output.txt index cd580a8efa4..fcc4a37146e 100644 --- a/acceptance/bundle/resources/job_runs/on_file_change/output.txt +++ b/acceptance/bundle/resources/job_runs/on_file_change/output.txt @@ -51,14 +51,14 @@ Resources: 0 created, 0 changed, 0 deleted, 2 unchanged "new_state": { "value": { "job_id": [MY_JOB_ID], + "result_state": "SUCCESS", "lifecycle": { "triggers_state": { "on_file_change": { "seed.txt": "[FILE_HASH][0]" } } - }, - "result_state": "SUCCESS" + } } }, "remote_state": { @@ -66,12 +66,12 @@ Resources: 0 created, 0 changed, 0 deleted, 2 unchanged "result_state": "SUCCESS", "run_id": [MY_RUN_ID], "run_name": "my-job", - "run_page_url": "[DATABRICKS_URL]/jobs/[MY_JOB_ID]/runs/[MY_RUN_ID]?o=[WORKSPACE_ID]", - "run_type": "JOB_RUN", "state": { "life_cycle_state": "TERMINATED", "result_state": "SUCCESS" - } + }, + "run_page_url": "[DATABRICKS_URL]/jobs/[MY_JOB_ID]/runs/[MY_RUN_ID]?o=[WORKSPACE_ID]", + "run_type": "JOB_RUN" }, "changes": { "lifecycle.triggers_state.on_file_change['seed.txt']": { @@ -130,14 +130,14 @@ Warning: lifecycle.triggers.on_file_change: no synced files match "seed.txt" "new_state": { "value": { "job_id": [MY_JOB_ID], + "result_state": "SUCCESS", "lifecycle": { "triggers_state": { "on_file_change": { "seed.txt": "[FILE_HASH][2]" } } - }, - "result_state": "SUCCESS" + } } }, "remote_state": { @@ -145,12 +145,12 @@ Warning: lifecycle.triggers.on_file_change: no synced files match "seed.txt" "result_state": "SUCCESS", "run_id": [MY_RUN_ID_2], "run_name": "my-job", - "run_page_url": "[DATABRICKS_URL]/jobs/[MY_JOB_ID]/runs/[MY_RUN_ID_2]?o=[WORKSPACE_ID]", - "run_type": "JOB_RUN", "state": { "life_cycle_state": "TERMINATED", "result_state": "SUCCESS" - } + }, + "run_page_url": "[DATABRICKS_URL]/jobs/[MY_JOB_ID]/runs/[MY_RUN_ID_2]?o=[WORKSPACE_ID]", + "run_type": "JOB_RUN" }, "changes": { "lifecycle.triggers_state.on_file_change['seed.txt']": { diff --git a/acceptance/bundle/resources/job_runs/redeploy/output.txt b/acceptance/bundle/resources/job_runs/redeploy/output.txt index 577db05fae9..a6fd67ba16c 100644 --- a/acceptance/bundle/resources/job_runs/redeploy/output.txt +++ b/acceptance/bundle/resources/job_runs/redeploy/output.txt @@ -70,12 +70,12 @@ Resources: "result_state": "SUCCESS", "run_id": [MY_RUN_ID], "run_name": "my-job", - "run_page_url": "[DATABRICKS_URL]/jobs/[MY_JOB_ID]/runs/[MY_RUN_ID]?o=[WORKSPACE_ID]", - "run_type": "JOB_RUN", "state": { "life_cycle_state": "TERMINATED", "result_state": "SUCCESS" - } + }, + "run_page_url": "[DATABRICKS_URL]/jobs/[MY_JOB_ID]/runs/[MY_RUN_ID]?o=[WORKSPACE_ID]", + "run_type": "JOB_RUN" }, "changes": { "job_parameters['env']": { diff --git a/acceptance/bundle/resources/jobs/delete_job/out.plan.json b/acceptance/bundle/resources/jobs/delete_job/out.plan.json index c2b396b5d61..a41a5fce811 100644 --- a/acceptance/bundle/resources/jobs/delete_job/out.plan.json +++ b/acceptance/bundle/resources/jobs/delete_job/out.plan.json @@ -7,8 +7,6 @@ "resources.jobs.job": { "action": "delete", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -16,13 +14,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [JOB_ID], "max_concurrent_runs": 1, "name": "Untitled", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -64,7 +60,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [JOB_ID], + "run_as_user_name": "[USERNAME]" } } } diff --git a/acceptance/bundle/resources/jobs/delete_task/out.plan_update.json b/acceptance/bundle/resources/jobs/delete_task/out.plan_update.json index 61124e44ae6..867a7619f14 100644 --- a/acceptance/bundle/resources/jobs/delete_task/out.plan_update.json +++ b/acceptance/bundle/resources/jobs/delete_task/out.plan_update.json @@ -43,8 +43,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -52,13 +50,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [JOB_ID], "max_concurrent_runs": 1, "name": "Untitled", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -100,7 +96,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [JOB_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/jobs/num_workers/output.txt b/acceptance/bundle/resources/jobs/num_workers/output.txt index 605314d8f88..8b5df946d2b 100644 --- a/acceptance/bundle/resources/jobs/num_workers/output.txt +++ b/acceptance/bundle/resources/jobs/num_workers/output.txt @@ -16,6 +16,10 @@ are correctly set in the cluster specification: ResourceClass: SingleNode +Warning: num_workers is ignored because autoscale is set + at resources.jobs.sample_job.job_clusters[1].new_cluster.num_workers + in databricks.yml:53:26 + Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... Created jobs.sample_job Files: 3 uploaded, 0 deleted @@ -54,7 +58,6 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged }, "data_security_mode": "SINGLE_USER", "node_type_id": "[NODE_TYPE_ID]", - "num_workers": 1, "spark_version": "16.4.x-scala2.14" } }, @@ -125,4 +128,8 @@ are correctly set in the cluster specification: ResourceClass: SingleNode +Warning: num_workers is ignored because autoscale is set + at resources.jobs.sample_job.job_clusters[1].new_cluster.num_workers + in databricks.yml:53:26 + Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged diff --git a/acceptance/bundle/resources/jobs/remote_add_tag/out.plan_post_update.json b/acceptance/bundle/resources/jobs/remote_add_tag/out.plan_post_update.json index d52ca412cce..53444e0feea 100644 --- a/acceptance/bundle/resources/jobs/remote_add_tag/out.plan_post_update.json +++ b/acceptance/bundle/resources/jobs/remote_add_tag/out.plan_post_update.json @@ -40,8 +40,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -49,13 +47,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [FOO_ID], "max_concurrent_runs": 1, "name": "My Wheel Job", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tags": { "new_tag": "new_value", "tag1": "tag value" @@ -79,7 +75,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [FOO_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/jobs/remote_matches_config/out.plan.json b/acceptance/bundle/resources/jobs/remote_matches_config/out.plan.json index a1c295b4715..6f4426e3600 100644 --- a/acceptance/bundle/resources/jobs/remote_matches_config/out.plan.json +++ b/acceptance/bundle/resources/jobs/remote_matches_config/out.plan.json @@ -7,8 +7,6 @@ "resources.jobs.my_job": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -16,13 +14,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [MY_JOB_ID], "max_concurrent_runs": 2, "name": "Test Job for Conflict Detection", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tags": { "environment": "dev" }, @@ -50,7 +46,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [MY_JOB_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/jobs/update/out.plan_skip.json b/acceptance/bundle/resources/jobs/update/out.plan_skip.json index cf8fe1d1816..974bb36de8c 100644 --- a/acceptance/bundle/resources/jobs/update/out.plan_skip.json +++ b/acceptance/bundle/resources/jobs/update/out.plan_skip.json @@ -7,8 +7,6 @@ "resources.jobs.foo": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -25,13 +23,11 @@ } } ], - "job_id": [FOO_ID], "max_concurrent_runs": 1, "name": "foo", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, "trigger": { "pause_status": "UNPAUSED", @@ -40,7 +36,11 @@ "unit": "DAYS" } }, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [FOO_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/jobs/update/out.plan_update.json b/acceptance/bundle/resources/jobs/update/out.plan_update.json index 9409092f5aa..e0c2c9f0e23 100644 --- a/acceptance/bundle/resources/jobs/update/out.plan_update.json +++ b/acceptance/bundle/resources/jobs/update/out.plan_update.json @@ -38,8 +38,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -56,13 +54,11 @@ } } ], - "job_id": [FOO_ID], "max_concurrent_runs": 1, "name": "foo", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, "trigger": { "pause_status": "UNPAUSED", @@ -71,7 +67,11 @@ "unit": "DAYS" } }, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [FOO_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/jobs/update_single_node/out.plan_skip.json b/acceptance/bundle/resources/jobs/update_single_node/out.plan_skip.json index c654c443693..3267bde263a 100644 --- a/acceptance/bundle/resources/jobs/update_single_node/out.plan_skip.json +++ b/acceptance/bundle/resources/jobs/update_single_node/out.plan_skip.json @@ -7,8 +7,6 @@ "resources.jobs.foo": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -32,13 +30,11 @@ } } ], - "job_id": [FOO_ID], "max_concurrent_runs": 1, "name": "foo", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, "trigger": { "pause_status": "UNPAUSED", @@ -47,7 +43,11 @@ "unit": "DAYS" } }, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [FOO_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/jobs/update_single_node/out.plan_update.json b/acceptance/bundle/resources/jobs/update_single_node/out.plan_update.json index a8a72d9b48a..6e03476aca0 100644 --- a/acceptance/bundle/resources/jobs/update_single_node/out.plan_update.json +++ b/acceptance/bundle/resources/jobs/update_single_node/out.plan_update.json @@ -45,8 +45,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -70,13 +68,11 @@ } } ], - "job_id": [FOO_ID], "max_concurrent_runs": 1, "name": "foo", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, "trigger": { "pause_status": "UNPAUSED", @@ -85,7 +81,11 @@ "unit": "DAYS" } }, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [FOO_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/jobs/whole-block-overlap/out.plan.direct.json b/acceptance/bundle/resources/jobs/whole-block-overlap/out.plan.direct.json index 03edfb9f1d8..004c62932d6 100644 --- a/acceptance/bundle/resources/jobs/whole-block-overlap/out.plan.direct.json +++ b/acceptance/bundle/resources/jobs/whole-block-overlap/out.plan.direct.json @@ -35,8 +35,6 @@ } }, "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -44,13 +42,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [MY_JOB_ID], "max_concurrent_runs": 1, "name": "test-job", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -64,7 +60,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [MY_JOB_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/mcp_services/basic/output.txt b/acceptance/bundle/resources/mcp_services/basic/output.txt index 1e569e8b020..42a26288eba 100644 --- a/acceptance/bundle/resources/mcp_services/basic/output.txt +++ b/acceptance/bundle/resources/mcp_services/basic/output.txt @@ -10,7 +10,7 @@ === Verify it does not exist yet >>> musterr [CLI] ai-gateway get-mcp-service mcp-services/main.myschema.myservice -Error: Resource catalog.McpService not found: main.myschema.myservice +Error: Resource aigateway.McpService not found: main.myschema.myservice >>> [CLI] bundle deploy Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... @@ -62,7 +62,8 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "update_mask": "*" }, "body": { - "comment": "COMMENT2" + "comment": "COMMENT2", + "name": "mcp-services/main.myschema.myservice" } } diff --git a/acceptance/bundle/resources/model_provider_services/basic/output.txt b/acceptance/bundle/resources/model_provider_services/basic/output.txt index 6f61bef50bb..95c27a1f231 100644 --- a/acceptance/bundle/resources/model_provider_services/basic/output.txt +++ b/acceptance/bundle/resources/model_provider_services/basic/output.txt @@ -29,7 +29,7 @@ === Verify it does not exist yet >>> musterr [CLI] ai-gateway get-model-provider-service model-provider-services/main.myschema.myservice -Error: Resource catalog.ModelProviderService not found: main.myschema.myservice +Error: Resource aigateway.ModelProviderService not found: main.myschema.myservice >>> [CLI] bundle deploy Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... @@ -119,7 +119,8 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged ] } ] - } + }, + "name": "model-provider-services/main.myschema.myservice" } } diff --git a/acceptance/bundle/resources/model_services/basic/output.txt b/acceptance/bundle/resources/model_services/basic/output.txt index 42d7686eee0..eff8d4700ce 100644 --- a/acceptance/bundle/resources/model_services/basic/output.txt +++ b/acceptance/bundle/resources/model_services/basic/output.txt @@ -10,7 +10,7 @@ === Verify it does not exist yet >>> musterr [CLI] ai-gateway get-model-service model-services/main.myschema.myservice -Error: Resource catalog.ModelService not found: main.myschema.myservice +Error: Resource aigateway.ModelService not found: main.myschema.myservice >>> [CLI] bundle deploy Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... @@ -62,7 +62,8 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "update_mask": "*" }, "body": { - "comment": "COMMENT2" + "comment": "COMMENT2", + "name": "model-services/main.myschema.myservice" } } diff --git a/acceptance/bundle/resources/model_serving_endpoints/basic/out.first-requests.txt b/acceptance/bundle/resources/model_serving_endpoints/basic/out.first-requests.txt index ff4ff00fb8e..c6678fe3349 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/basic/out.first-requests.txt +++ b/acceptance/bundle/resources/model_serving_endpoints/basic/out.first-requests.txt @@ -7,3 +7,5 @@ json[1].body.access_control_list[0].permission_level = "CAN_MANAGE"; json[1].body.access_control_list[0].service_principal_name = "[USERNAME]"; json[1].body.access_control_list[1].permission_level = "CAN_VIEW"; json[1].body.access_control_list[1].user_name = "deco-test-user@databricks.com"; +json[1].body.request_object_id = "[ENDPOINT_ID_1]"; +json[1].body.request_object_type = "serving-endpoints"; diff --git a/acceptance/bundle/resources/model_serving_endpoints/basic/out.second-plan.txt b/acceptance/bundle/resources/model_serving_endpoints/basic/out.second-plan.txt index 60bca95b9ff..11163626611 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/basic/out.second-plan.txt +++ b/acceptance/bundle/resources/model_serving_endpoints/basic/out.second-plan.txt @@ -4,7 +4,6 @@ json.lineage = "[UUID]"; json.serial = 1; json.plan.resources.model_serving_endpoints.my_endpoint.action = "recreate"; json.plan.resources.model_serving_endpoints.my_endpoint.new_state.value.name = "[ENDPOINT_NAME_2]"; -json.plan.resources.model_serving_endpoints.my_endpoint.remote_state.description = ""; json.plan.resources.model_serving_endpoints.my_endpoint.remote_state.endpoint_details.creation_timestamp = [UNIX_TIME_MILLIS][0]; json.plan.resources.model_serving_endpoints.my_endpoint.remote_state.endpoint_details.creator = "[USERNAME]"; json.plan.resources.model_serving_endpoints.my_endpoint.remote_state.endpoint_details.description = ""; @@ -16,6 +15,7 @@ json.plan.resources.model_serving_endpoints.my_endpoint.remote_state.endpoint_de json.plan.resources.model_serving_endpoints.my_endpoint.remote_state.endpoint_details.state.config_update = "NOT_UPDATING"; json.plan.resources.model_serving_endpoints.my_endpoint.remote_state.endpoint_details.state.ready = "NOT_READY"; json.plan.resources.model_serving_endpoints.my_endpoint.remote_state.endpoint_id = "[ENDPOINT_ID_1]"; +json.plan.resources.model_serving_endpoints.my_endpoint.remote_state.description = ""; json.plan.resources.model_serving_endpoints.my_endpoint.remote_state.name = "[ENDPOINT_NAME_1]"; json.plan.resources.model_serving_endpoints.my_endpoint.remote_state.route_optimized = false; json.plan.resources.model_serving_endpoints.my_endpoint.changes.description.action = "skip"; diff --git a/acceptance/bundle/resources/model_serving_endpoints/basic/out.second-requests.txt b/acceptance/bundle/resources/model_serving_endpoints/basic/out.second-requests.txt index 8f5318593a8..9b9dd9b9808 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/basic/out.second-requests.txt +++ b/acceptance/bundle/resources/model_serving_endpoints/basic/out.second-requests.txt @@ -9,3 +9,5 @@ json[2].body.access_control_list[0].permission_level = "CAN_MANAGE"; json[2].body.access_control_list[0].service_principal_name = "[USERNAME]"; json[2].body.access_control_list[1].permission_level = "CAN_VIEW"; json[2].body.access_control_list[1].user_name = "deco-test-user@databricks.com"; +json[2].body.request_object_id = "[ENDPOINT_ID_2]"; +json[2].body.request_object_type = "serving-endpoints"; diff --git a/acceptance/bundle/resources/model_serving_endpoints/drift/telemetry_config_with_config_update/output.txt b/acceptance/bundle/resources/model_serving_endpoints/drift/telemetry_config_with_config_update/output.txt index 093d5875e98..465070e0fed 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/drift/telemetry_config_with_config_update/output.txt +++ b/acceptance/bundle/resources/model_serving_endpoints/drift/telemetry_config_with_config_update/output.txt @@ -21,9 +21,9 @@ Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged >>> print_requests.py --get --oneline //serving-endpoints 1 {"method": "POST", "path": "/api/2.0/serving-endpoints", "body": {"config": {"served_entities": [{"entity_name": "main.default.test_model", "entity_version": "1", "name": "prod", "scale_to_zero_enabled": true, "workload_size": "Small"}]}, "name": "test-endpoint", "telemetry_config": {"inference_table_config": {"sampling_fraction": 0.5}, "table_names": {"logs_table": "main.default.test_logs"}}}} 2 {"method": "GET", "path": "/api/2.0/serving-endpoints/test-endpoint"} -1 {"method": "PUT", "path": "/api/2.0/serving-endpoints/test-endpoint/config", "body": {"served_entities": [{"entity_name": "main.default.test_model", "entity_version": "1", "name": "prod", "scale_to_zero_enabled": true, "workload_size": "Medium"}]}} +1 {"method": "PUT", "path": "/api/2.0/serving-endpoints/test-endpoint/config", "body": {"name": "test-endpoint", "served_entities": [{"entity_name": "main.default.test_model", "entity_version": "1", "name": "prod", "scale_to_zero_enabled": true, "workload_size": "Medium"}]}} 2 {"method": "GET", "path": "/api/2.0/serving-endpoints/test-endpoint"} -1 {"method": "PATCH", "path": "/api/2.0/serving-endpoints/test-endpoint/telemetry-config", "body": {"telemetry_config": {"inference_table_config": {"sampling_fraction": 0.9}, "table_names": {"logs_table": "main.default.test_logs"}}}} +1 {"method": "PATCH", "path": "/api/2.0/serving-endpoints/test-endpoint/telemetry-config", "body": {"name": "test-endpoint", "telemetry_config": {"inference_table_config": {"sampling_fraction": 0.9}, "table_names": {"logs_table": "main.default.test_logs"}}}} 2 {"method": "GET", "path": "/api/2.0/serving-endpoints/test-endpoint"} === Remove telemetry_config @@ -42,4 +42,4 @@ Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged === Removal sends an empty telemetry PATCH >>> print_requests.py --method PATCH --oneline //serving-endpoints -{"method": "PATCH", "path": "/api/2.0/serving-endpoints/test-endpoint/telemetry-config", "body": {}} +{"method": "PATCH", "path": "/api/2.0/serving-endpoints/test-endpoint/telemetry-config", "body": {"name": "test-endpoint"}} diff --git a/acceptance/bundle/resources/model_serving_endpoints/drift/write_only/output.txt b/acceptance/bundle/resources/model_serving_endpoints/drift/write_only/output.txt index c0f856ff6c5..813db3d55ba 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/drift/write_only/output.txt +++ b/acceptance/bundle/resources/model_serving_endpoints/drift/write_only/output.txt @@ -17,22 +17,19 @@ Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged "action": "skip", "reason": "spec:input_only", "old": true, - "new": true, - "remote": false + "new": true }, "config.served_entities[0].external_model.openai_config.openai_api_key_plaintext": { "action": "skip", "reason": "spec:input_only", "old": "sk-test-plaintext-key", - "new": "sk-test-plaintext-key", - "remote": "" + "new": "sk-test-plaintext-key" }, "config.served_entities[1].external_model.custom_provider_config.api_key_auth.value_plaintext": { "action": "skip", "reason": "spec:input_only", "old": "custom-plaintext-key", - "new": "custom-plaintext-key", - "remote": "" + "new": "custom-plaintext-key" }, "description": { "action": "skip", diff --git a/acceptance/bundle/resources/model_serving_endpoints/recreate/catalog-name/out.second-plan.json b/acceptance/bundle/resources/model_serving_endpoints/recreate/catalog-name/out.second-plan.json index 89686b87922..4c07f98adee 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/recreate/catalog-name/out.second-plan.json +++ b/acceptance/bundle/resources/model_serving_endpoints/recreate/catalog-name/out.second-plan.json @@ -32,36 +32,6 @@ } }, "remote_state": { - "config": { - "auto_capture_config": { - "catalog_name": "main", - "schema_name": "default", - "table_name_prefix": "my_table" - }, - "served_entities": [ - { - "external_model": { - "name": "gpt-4o-mini", - "openai_config": { - "openai_api_key": "{{secrets/test-scope/openai-key}}" - }, - "provider": "openai", - "task": "llm/v1/chat" - }, - "name": "prod" - } - ], - "traffic_config": { - "routes": [ - { - "served_entity_name": "prod", - "served_model_name": "prod", - "traffic_percentage": 100 - } - ] - } - }, - "description": "", "endpoint_details": { "config": { "auto_capture_config": { @@ -106,6 +76,36 @@ } }, "endpoint_id": "[UUID]", + "config": { + "auto_capture_config": { + "catalog_name": "main", + "schema_name": "default", + "table_name_prefix": "my_table" + }, + "served_entities": [ + { + "external_model": { + "name": "gpt-4o-mini", + "openai_config": { + "openai_api_key": "{{secrets/test-scope/openai-key}}" + }, + "provider": "openai", + "task": "llm/v1/chat" + }, + "name": "prod" + } + ], + "traffic_config": { + "routes": [ + { + "served_entity_name": "prod", + "served_model_name": "prod", + "traffic_percentage": 100 + } + ] + } + }, + "description": "", "name": "[ORIGINAL_ENDPOINT_ID]", "route_optimized": false }, diff --git a/acceptance/bundle/resources/model_serving_endpoints/recreate/name-change/out.second-plan.json b/acceptance/bundle/resources/model_serving_endpoints/recreate/name-change/out.second-plan.json index 2a50d836ce7..7ebeab5b94a 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/recreate/name-change/out.second-plan.json +++ b/acceptance/bundle/resources/model_serving_endpoints/recreate/name-change/out.second-plan.json @@ -27,31 +27,6 @@ } }, "remote_state": { - "config": { - "served_entities": [ - { - "external_model": { - "name": "gpt-4o-mini", - "openai_config": { - "openai_api_key": "{{secrets/test-scope/openai-key}}" - }, - "provider": "openai", - "task": "llm/v1/chat" - }, - "name": "prod" - } - ], - "traffic_config": { - "routes": [ - { - "served_entity_name": "prod", - "served_model_name": "prod", - "traffic_percentage": 100 - } - ] - } - }, - "description": "", "endpoint_details": { "config": { "served_entities": [ @@ -91,6 +66,31 @@ } }, "endpoint_id": "[UUID]", + "config": { + "served_entities": [ + { + "external_model": { + "name": "gpt-4o-mini", + "openai_config": { + "openai_api_key": "{{secrets/test-scope/openai-key}}" + }, + "provider": "openai", + "task": "llm/v1/chat" + }, + "name": "prod" + } + ], + "traffic_config": { + "routes": [ + { + "served_entity_name": "prod", + "served_model_name": "prod", + "traffic_percentage": 100 + } + ] + } + }, + "description": "", "name": "[ORIGINAL_ENDPOINT_ID]", "route_optimized": false }, diff --git a/acceptance/bundle/resources/model_serving_endpoints/recreate/route-optimized/out.second-plan.json b/acceptance/bundle/resources/model_serving_endpoints/recreate/route-optimized/out.second-plan.json index b5555453219..4f2d9a75c4e 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/recreate/route-optimized/out.second-plan.json +++ b/acceptance/bundle/resources/model_serving_endpoints/recreate/route-optimized/out.second-plan.json @@ -24,27 +24,6 @@ } }, "remote_state": { - "config": { - "served_entities": [ - { - "entity_name": "system.ai.llama_v3_2_1b_instruct", - "entity_version": "1", - "name": "llama", - "scale_to_zero_enabled": true, - "workload_size": "Small" - } - ], - "traffic_config": { - "routes": [ - { - "served_entity_name": "llama", - "served_model_name": "llama", - "traffic_percentage": 100 - } - ] - } - }, - "description": "", "endpoint_details": { "config": { "served_entities": [ @@ -80,6 +59,27 @@ } }, "endpoint_id": "[UUID]", + "config": { + "served_entities": [ + { + "entity_name": "system.ai.llama_v3_2_1b_instruct", + "entity_version": "1", + "name": "llama", + "scale_to_zero_enabled": true, + "workload_size": "Small" + } + ], + "traffic_config": { + "routes": [ + { + "served_entity_name": "llama", + "served_model_name": "llama", + "traffic_percentage": 100 + } + ] + } + }, + "description": "", "name": "[ORIGINAL_ENDPOINT_ID]", "route_optimized": false }, diff --git a/acceptance/bundle/resources/model_serving_endpoints/recreate/schema-name/out.second-plan.json b/acceptance/bundle/resources/model_serving_endpoints/recreate/schema-name/out.second-plan.json index 0a2bc7bee2d..0be0822b6ff 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/recreate/schema-name/out.second-plan.json +++ b/acceptance/bundle/resources/model_serving_endpoints/recreate/schema-name/out.second-plan.json @@ -32,36 +32,6 @@ } }, "remote_state": { - "config": { - "auto_capture_config": { - "catalog_name": "main", - "schema_name": "default", - "table_name_prefix": "my_table" - }, - "served_entities": [ - { - "external_model": { - "name": "gpt-4o-mini", - "openai_config": { - "openai_api_key": "{{secrets/test-scope/openai-key}}" - }, - "provider": "openai", - "task": "llm/v1/chat" - }, - "name": "prod" - } - ], - "traffic_config": { - "routes": [ - { - "served_entity_name": "prod", - "served_model_name": "prod", - "traffic_percentage": 100 - } - ] - } - }, - "description": "", "endpoint_details": { "config": { "auto_capture_config": { @@ -106,6 +76,36 @@ } }, "endpoint_id": "[UUID]", + "config": { + "auto_capture_config": { + "catalog_name": "main", + "schema_name": "default", + "table_name_prefix": "my_table" + }, + "served_entities": [ + { + "external_model": { + "name": "gpt-4o-mini", + "openai_config": { + "openai_api_key": "{{secrets/test-scope/openai-key}}" + }, + "provider": "openai", + "task": "llm/v1/chat" + }, + "name": "prod" + } + ], + "traffic_config": { + "routes": [ + { + "served_entity_name": "prod", + "served_model_name": "prod", + "traffic_percentage": 100 + } + ] + } + }, + "description": "", "name": "[ORIGINAL_ENDPOINT_ID]", "route_optimized": false }, diff --git a/acceptance/bundle/resources/model_serving_endpoints/recreate/table-prefix/out.second-plan.json b/acceptance/bundle/resources/model_serving_endpoints/recreate/table-prefix/out.second-plan.json index 6d2c9deccb6..c601d6f0a81 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/recreate/table-prefix/out.second-plan.json +++ b/acceptance/bundle/resources/model_serving_endpoints/recreate/table-prefix/out.second-plan.json @@ -32,36 +32,6 @@ } }, "remote_state": { - "config": { - "auto_capture_config": { - "catalog_name": "main", - "schema_name": "default", - "table_name_prefix": "my_table" - }, - "served_entities": [ - { - "external_model": { - "name": "gpt-4o-mini", - "openai_config": { - "openai_api_key": "{{secrets/test-scope/openai-key}}" - }, - "provider": "openai", - "task": "llm/v1/chat" - }, - "name": "prod" - } - ], - "traffic_config": { - "routes": [ - { - "served_entity_name": "prod", - "served_model_name": "prod", - "traffic_percentage": 100 - } - ] - } - }, - "description": "", "endpoint_details": { "config": { "auto_capture_config": { @@ -106,6 +76,36 @@ } }, "endpoint_id": "[UUID]", + "config": { + "auto_capture_config": { + "catalog_name": "main", + "schema_name": "default", + "table_name_prefix": "my_table" + }, + "served_entities": [ + { + "external_model": { + "name": "gpt-4o-mini", + "openai_config": { + "openai_api_key": "{{secrets/test-scope/openai-key}}" + }, + "provider": "openai", + "task": "llm/v1/chat" + }, + "name": "prod" + } + ], + "traffic_config": { + "routes": [ + { + "served_entity_name": "prod", + "served_model_name": "prod", + "traffic_percentage": 100 + } + ] + } + }, + "description": "", "name": "[ORIGINAL_ENDPOINT_ID]", "route_optimized": false }, diff --git a/acceptance/bundle/resources/model_serving_endpoints/update/ai-gateway/out.plan.json b/acceptance/bundle/resources/model_serving_endpoints/update/ai-gateway/out.plan.json index afe9fa25886..bf83457ecd9 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/update/ai-gateway/out.plan.json +++ b/acceptance/bundle/resources/model_serving_endpoints/update/ai-gateway/out.plan.json @@ -32,36 +32,6 @@ } }, "remote_state": { - "ai_gateway": { - "inference_table_config": { - "catalog_name": "first-inference-catalog" - } - }, - "config": { - "served_entities": [ - { - "external_model": { - "name": "gpt-4o-mini", - "openai_config": { - "openai_api_key": "{{secrets/test-scope/openai-key}}" - }, - "provider": "openai", - "task": "llm/v1/chat" - }, - "name": "prod" - } - ], - "traffic_config": { - "routes": [ - { - "served_entity_name": "prod", - "served_model_name": "prod", - "traffic_percentage": 100 - } - ] - } - }, - "description": "", "endpoint_details": { "ai_gateway": { "inference_table_config": { @@ -106,6 +76,36 @@ } }, "endpoint_id": "[UUID]", + "ai_gateway": { + "inference_table_config": { + "catalog_name": "first-inference-catalog" + } + }, + "config": { + "served_entities": [ + { + "external_model": { + "name": "gpt-4o-mini", + "openai_config": { + "openai_api_key": "{{secrets/test-scope/openai-key}}" + }, + "provider": "openai", + "task": "llm/v1/chat" + }, + "name": "prod" + } + ], + "traffic_config": { + "routes": [ + { + "served_entity_name": "prod", + "served_model_name": "prod", + "traffic_percentage": 100 + } + ] + } + }, + "description": "", "name": "[ENDPOINT_ID]", "route_optimized": false }, diff --git a/acceptance/bundle/resources/model_serving_endpoints/update/ai-gateway/output.txt b/acceptance/bundle/resources/model_serving_endpoints/update/ai-gateway/output.txt index c7ca361a7db..0ceb60ef3af 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/update/ai-gateway/output.txt +++ b/acceptance/bundle/resources/model_serving_endpoints/update/ai-gateway/output.txt @@ -56,7 +56,8 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "body": { "inference_table_config": { "catalog_name": "second-inference-catalog" - } + }, + "name": "[ENDPOINT_ID]" } } diff --git a/acceptance/bundle/resources/model_serving_endpoints/update/both_gateway_and_tags/out.plan.json b/acceptance/bundle/resources/model_serving_endpoints/update/both_gateway_and_tags/out.plan.json index 32c30ee2612..2487b4f9e63 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/update/both_gateway_and_tags/out.plan.json +++ b/acceptance/bundle/resources/model_serving_endpoints/update/both_gateway_and_tags/out.plan.json @@ -38,36 +38,6 @@ } }, "remote_state": { - "ai_gateway": { - "inference_table_config": { - "catalog_name": "first-inference-catalog" - } - }, - "config": { - "served_entities": [ - { - "external_model": { - "name": "gpt-4o-mini", - "openai_config": { - "openai_api_key": "{{secrets/test-scope/openai-key}}" - }, - "provider": "openai", - "task": "llm/v1/chat" - }, - "name": "prod" - } - ], - "traffic_config": { - "routes": [ - { - "served_entity_name": "prod", - "served_model_name": "prod", - "traffic_percentage": 100 - } - ] - } - }, - "description": "", "endpoint_details": { "ai_gateway": { "inference_table_config": { @@ -118,6 +88,36 @@ ] }, "endpoint_id": "[UUID]", + "ai_gateway": { + "inference_table_config": { + "catalog_name": "first-inference-catalog" + } + }, + "config": { + "served_entities": [ + { + "external_model": { + "name": "gpt-4o-mini", + "openai_config": { + "openai_api_key": "{{secrets/test-scope/openai-key}}" + }, + "provider": "openai", + "task": "llm/v1/chat" + }, + "name": "prod" + } + ], + "traffic_config": { + "routes": [ + { + "served_entity_name": "prod", + "served_model_name": "prod", + "traffic_percentage": 100 + } + ] + } + }, + "description": "", "name": "[ENDPOINT_ID]", "route_optimized": false, "tags": [ diff --git a/acceptance/bundle/resources/model_serving_endpoints/update/both_gateway_and_tags/output.txt b/acceptance/bundle/resources/model_serving_endpoints/update/both_gateway_and_tags/output.txt index 39df6500a61..56fa722e685 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/update/both_gateway_and_tags/output.txt +++ b/acceptance/bundle/resources/model_serving_endpoints/update/both_gateway_and_tags/output.txt @@ -86,7 +86,8 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "key": "team", "value": "my-team-two" } - ] + ], + "name": "[ENDPOINT_ID]" } } { @@ -95,7 +96,8 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "body": { "inference_table_config": { "catalog_name": "second-inference-catalog" - } + }, + "name": "[ENDPOINT_ID]" } } diff --git a/acceptance/bundle/resources/model_serving_endpoints/update/config/out.plan.json b/acceptance/bundle/resources/model_serving_endpoints/update/config/out.plan.json index 5b90f2088d6..277374fa26a 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/update/config/out.plan.json +++ b/acceptance/bundle/resources/model_serving_endpoints/update/config/out.plan.json @@ -35,30 +35,6 @@ } }, "remote_state": { - "config": { - "served_entities": [ - { - "external_model": { - "name": "gpt-4o-mini", - "openai_config": { - "openai_api_key": "{{secrets/test-scope/openai-key}}" - }, - "provider": "openai", - "task": "llm/v1/chat" - }, - "name": "prod" - } - ], - "traffic_config": { - "routes": [ - { - "served_model_name": "prod", - "traffic_percentage": 100 - } - ] - } - }, - "description": "", "endpoint_details": { "config": { "served_entities": [ @@ -97,6 +73,30 @@ } }, "endpoint_id": "[UUID]", + "config": { + "served_entities": [ + { + "external_model": { + "name": "gpt-4o-mini", + "openai_config": { + "openai_api_key": "{{secrets/test-scope/openai-key}}" + }, + "provider": "openai", + "task": "llm/v1/chat" + }, + "name": "prod" + } + ], + "traffic_config": { + "routes": [ + { + "served_model_name": "prod", + "traffic_percentage": 100 + } + ] + } + }, + "description": "", "name": "[ENDPOINT_ID]", "route_optimized": false }, diff --git a/acceptance/bundle/resources/model_serving_endpoints/update/config/output.txt b/acceptance/bundle/resources/model_serving_endpoints/update/config/output.txt index 79c05120da8..890117684b7 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/update/config/output.txt +++ b/acceptance/bundle/resources/model_serving_endpoints/update/config/output.txt @@ -75,6 +75,7 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "method": "PUT", "path": "/api/2.0/serving-endpoints/[ENDPOINT_ID]/config", "body": { + "name": "[ENDPOINT_ID]", "served_entities": [ { "external_model": { diff --git a/acceptance/bundle/resources/model_serving_endpoints/update/email-notifications/out.plan.json b/acceptance/bundle/resources/model_serving_endpoints/update/email-notifications/out.plan.json index 0f860ce7ac3..1e9c1b0fdc3 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/update/email-notifications/out.plan.json +++ b/acceptance/bundle/resources/model_serving_endpoints/update/email-notifications/out.plan.json @@ -32,36 +32,6 @@ } }, "remote_state": { - "config": { - "served_entities": [ - { - "external_model": { - "name": "gpt-4o-mini", - "openai_config": { - "openai_api_key": "{{secrets/test-scope/openai-key}}" - }, - "provider": "openai", - "task": "llm/v1/chat" - }, - "name": "prod" - } - ], - "traffic_config": { - "routes": [ - { - "served_entity_name": "prod", - "served_model_name": "prod", - "traffic_percentage": 100 - } - ] - } - }, - "description": "", - "email_notifications": { - "on_update_success": [ - "user1@example.com" - ] - }, "endpoint_details": { "config": { "served_entities": [ @@ -106,6 +76,36 @@ } }, "endpoint_id": "[UUID]", + "config": { + "served_entities": [ + { + "external_model": { + "name": "gpt-4o-mini", + "openai_config": { + "openai_api_key": "{{secrets/test-scope/openai-key}}" + }, + "provider": "openai", + "task": "llm/v1/chat" + }, + "name": "prod" + } + ], + "traffic_config": { + "routes": [ + { + "served_entity_name": "prod", + "served_model_name": "prod", + "traffic_percentage": 100 + } + ] + } + }, + "description": "", + "email_notifications": { + "on_update_success": [ + "user1@example.com" + ] + }, "name": "[ENDPOINT_ID]", "route_optimized": false }, diff --git a/acceptance/bundle/resources/model_serving_endpoints/update/email-notifications/out.requests.json b/acceptance/bundle/resources/model_serving_endpoints/update/email-notifications/out.requests.json index bdf4a85b8b0..71cf3b6d1a3 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/update/email-notifications/out.requests.json +++ b/acceptance/bundle/resources/model_serving_endpoints/update/email-notifications/out.requests.json @@ -33,6 +33,7 @@ "on_update_success": [ "user2@example.com" ] - } + }, + "name": "[ENDPOINT_ID]" } } diff --git a/acceptance/bundle/resources/model_serving_endpoints/update/tags/out.plan.json b/acceptance/bundle/resources/model_serving_endpoints/update/tags/out.plan.json index f8850241ddf..1ebf09cf70d 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/update/tags/out.plan.json +++ b/acceptance/bundle/resources/model_serving_endpoints/update/tags/out.plan.json @@ -33,31 +33,6 @@ } }, "remote_state": { - "config": { - "served_entities": [ - { - "external_model": { - "name": "gpt-4o-mini", - "openai_config": { - "openai_api_key": "{{secrets/test-scope/openai-key}}" - }, - "provider": "openai", - "task": "llm/v1/chat" - }, - "name": "prod" - } - ], - "traffic_config": { - "routes": [ - { - "served_entity_name": "prod", - "served_model_name": "prod", - "traffic_percentage": 100 - } - ] - } - }, - "description": "", "endpoint_details": { "config": { "served_entities": [ @@ -103,6 +78,31 @@ ] }, "endpoint_id": "[UUID]", + "config": { + "served_entities": [ + { + "external_model": { + "name": "gpt-4o-mini", + "openai_config": { + "openai_api_key": "{{secrets/test-scope/openai-key}}" + }, + "provider": "openai", + "task": "llm/v1/chat" + }, + "name": "prod" + } + ], + "traffic_config": { + "routes": [ + { + "served_entity_name": "prod", + "served_model_name": "prod", + "traffic_percentage": 100 + } + ] + } + }, + "description": "", "name": "[ENDPOINT_ID]", "route_optimized": false, "tags": [ diff --git a/acceptance/bundle/resources/model_serving_endpoints/update/tags/output.txt b/acceptance/bundle/resources/model_serving_endpoints/update/tags/output.txt index 229d21f09ce..4d70da1e299 100644 --- a/acceptance/bundle/resources/model_serving_endpoints/update/tags/output.txt +++ b/acceptance/bundle/resources/model_serving_endpoints/update/tags/output.txt @@ -61,7 +61,8 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "key": "team", "value": "my-team-two" } - ] + ], + "name": "[ENDPOINT_ID]" } } diff --git a/acceptance/bundle/resources/models/readplan-permissions/output.txt b/acceptance/bundle/resources/models/readplan-permissions/output.txt index a4e059b61a7..322617a719e 100644 --- a/acceptance/bundle/resources/models/readplan-permissions/output.txt +++ b/acceptance/bundle/resources/models/readplan-permissions/output.txt @@ -25,7 +25,9 @@ Resources: 2 created, 0 changed, 0 deleted, 0 unchanged "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[MODEL_ID]", + "request_object_type": "registered-models" } } @@ -49,7 +51,9 @@ Resources: 0 created, 2 changed, 0 deleted, 0 unchanged "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[MODEL_ID]", + "request_object_type": "registered-models" } } diff --git a/acceptance/bundle/resources/permissions/apps/current_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/apps/current_can_manage/out.requests.deploy.json index 5e322e3e472..112178bdbd3 100644 --- a/acceptance/bundle/resources/permissions/apps/current_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/apps/current_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "apps" } } diff --git a/acceptance/bundle/resources/permissions/apps/other_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/apps/other_can_manage/out.requests.deploy.json index 5e322e3e472..112178bdbd3 100644 --- a/acceptance/bundle/resources/permissions/apps/other_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/apps/other_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "apps" } } diff --git a/acceptance/bundle/resources/permissions/clusters/current_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/clusters/current_can_manage/out.requests.deploy.json index 911f898ded8..fa997897c4d 100644 --- a/acceptance/bundle/resources/permissions/clusters/current_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/clusters/current_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "clusters" } } diff --git a/acceptance/bundle/resources/permissions/clusters/target/out.requests.json b/acceptance/bundle/resources/permissions/clusters/target/out.requests.json index 9a0adb10f0f..6c325a4d8eb 100644 --- a/acceptance/bundle/resources/permissions/clusters/target/out.requests.json +++ b/acceptance/bundle/resources/permissions/clusters/target/out.requests.json @@ -33,6 +33,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[UUID]", + "request_object_type": "clusters" } } diff --git a/acceptance/bundle/resources/permissions/dashboards/create/out.plan.json b/acceptance/bundle/resources/permissions/dashboards/create/out.plan.json index 0b4079b26f4..3b8d6f863a3 100644 --- a/acceptance/bundle/resources/permissions/dashboards/create/out.plan.json +++ b/acceptance/bundle/resources/permissions/dashboards/create/out.plan.json @@ -7,11 +7,10 @@ "new_state": { "value": { "display_name": "test-dashboard-[UNIQUE_NAME]", - "embed_credentials": false, "parent_path": "/Workspace/Users/[USERNAME]/folder1", - "published": true, + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", "serialized_dashboard": "{\"pages\":[{\"name\":\"page1\",\"displayName\":\"Page 1\"}]}", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "published": true } } }, diff --git a/acceptance/bundle/resources/permissions/dashboards/create/out.requests.deploy.json b/acceptance/bundle/resources/permissions/dashboards/create/out.requests.deploy.json index 207969d3ce6..ff6e882ad0e 100644 --- a/acceptance/bundle/resources/permissions/dashboards/create/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/dashboards/create/out.requests.deploy.json @@ -11,6 +11,8 @@ "permission_level": "CAN_MANAGE", "service_principal_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "dashboards" } } diff --git a/acceptance/bundle/resources/permissions/database_instances/current_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/database_instances/current_can_manage/out.requests.deploy.json index bbdbbef2ae3..5ea006c0809 100644 --- a/acceptance/bundle/resources/permissions/database_instances/current_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/database_instances/current_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "database-instances" } } diff --git a/acceptance/bundle/resources/permissions/experiments/current_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/experiments/current_can_manage/out.requests.deploy.json index 624fdfe97c8..0f0585f672f 100644 --- a/acceptance/bundle/resources/permissions/experiments/current_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/experiments/current_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "experiments" } } diff --git a/acceptance/bundle/resources/permissions/genie_spaces/current_can_manage/out.plan.json b/acceptance/bundle/resources/permissions/genie_spaces/current_can_manage/out.plan.json index f79599cba2d..b86fc36f0fd 100644 --- a/acceptance/bundle/resources/permissions/genie_spaces/current_can_manage/out.plan.json +++ b/acceptance/bundle/resources/permissions/genie_spaces/current_can_manage/out.plan.json @@ -6,10 +6,10 @@ "action": "create", "new_state": { "value": { - "parent_path": "/Workspace/Users/[USERNAME]", - "serialized_space": "{}", "title": "Permissions Test Space", - "warehouse_id": "test-warehouse-id" + "warehouse_id": "test-warehouse-id", + "parent_path": "/Workspace/Users/[USERNAME]", + "serialized_space": "{}" } } }, diff --git a/acceptance/bundle/resources/permissions/genie_spaces/current_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/genie_spaces/current_can_manage/out.requests.deploy.json index abcba718ab7..35db0699432 100644 --- a/acceptance/bundle/resources/permissions/genie_spaces/current_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/genie_spaces/current_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "genie" } } diff --git a/acceptance/bundle/resources/permissions/jobs/added_remotely/out.plan.json b/acceptance/bundle/resources/permissions/jobs/added_remotely/out.plan.json index 30ef353f822..a5b304bc0ac 100644 --- a/acceptance/bundle/resources/permissions/jobs/added_remotely/out.plan.json +++ b/acceptance/bundle/resources/permissions/jobs/added_remotely/out.plan.json @@ -7,8 +7,6 @@ "resources.jobs.job_with_permissions": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" @@ -16,13 +14,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [JOB_WITH_PERMISSIONS_ID], "max_concurrent_runs": 1, "name": "job permissions added remotely", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -36,7 +32,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [JOB_WITH_PERMISSIONS_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/permissions/jobs/current_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/jobs/current_can_manage/out.requests.deploy.json index 47781d53496..323d0585fd9 100644 --- a/acceptance/bundle/resources/permissions/jobs/current_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/jobs/current_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/current_can_manage_run/out.deploy.requests.json b/acceptance/bundle/resources/permissions/jobs/current_can_manage_run/out.deploy.requests.json index d40073afd65..679f28aa326 100644 --- a/acceptance/bundle/resources/permissions/jobs/current_can_manage_run/out.deploy.requests.json +++ b/acceptance/bundle/resources/permissions/jobs/current_can_manage_run/out.deploy.requests.json @@ -24,6 +24,8 @@ "permission_level": "IS_OWNER", "service_principal_name": "[USERNAME]" } - ] + ], + "request_object_id": "[INTERIM_GOLD_LAYER_JOB_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/current_can_manage_run/out.plan.txt b/acceptance/bundle/resources/permissions/jobs/current_can_manage_run/out.plan.txt index 461e74b2bd6..a186bb4e1c4 100644 --- a/acceptance/bundle/resources/permissions/jobs/current_can_manage_run/out.plan.txt +++ b/acceptance/bundle/resources/permissions/jobs/current_can_manage_run/out.plan.txt @@ -7,8 +7,6 @@ "resources.jobs.interim_gold_layer_job": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/green/state/metadata.json" @@ -16,15 +14,17 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [INTERIM_GOLD_LAYER_JOB_ID], "max_concurrent_runs": 1, "name": "Untitled", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [INTERIM_GOLD_LAYER_JOB_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/permissions/jobs/current_is_owner/out.requests.deploy.json b/acceptance/bundle/resources/permissions/jobs/current_is_owner/out.requests.deploy.json index bbb8445b5a5..dc2117949cc 100644 --- a/acceptance/bundle/resources/permissions/jobs/current_is_owner/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/jobs/current_is_owner/out.requests.deploy.json @@ -7,6 +7,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/delete_one/out.requests_create.txt b/acceptance/bundle/resources/permissions/jobs/delete_one/out.requests_create.txt index 1473810b3c9..9fd6e34fdb5 100644 --- a/acceptance/bundle/resources/permissions/jobs/delete_one/out.requests_create.txt +++ b/acceptance/bundle/resources/permissions/jobs/delete_one/out.requests_create.txt @@ -20,3 +20,5 @@ json[1].body.access_control_list[2].permission_level = "CAN_VIEW"; json[1].body.access_control_list[2].user_name = "test-dabs-2@databricks.com"; json[1].body.access_control_list[3].permission_level = "IS_OWNER"; json[1].body.access_control_list[3].service_principal_name = "[USERNAME]"; +json[1].body.request_object_id = "[JOB_WITH_PERMISSIONS_ID]"; +json[1].body.request_object_type = "jobs"; diff --git a/acceptance/bundle/resources/permissions/jobs/delete_one/out.requests_update.txt b/acceptance/bundle/resources/permissions/jobs/delete_one/out.requests_update.txt index c97c396a7d5..63590de1ff4 100644 --- a/acceptance/bundle/resources/permissions/jobs/delete_one/out.requests_update.txt +++ b/acceptance/bundle/resources/permissions/jobs/delete_one/out.requests_update.txt @@ -6,3 +6,5 @@ json.body.access_control_list[1].permission_level = "CAN_VIEW"; json.body.access_control_list[1].user_name = "test-dabs-2@databricks.com"; json.body.access_control_list[2].permission_level = "IS_OWNER"; json.body.access_control_list[2].service_principal_name = "[USERNAME]"; +json.body.request_object_id = "[JOB_WITH_PERMISSIONS_ID]"; +json.body.request_object_type = "jobs"; diff --git a/acceptance/bundle/resources/permissions/jobs/deleted_remotely/out.plan_restore.json b/acceptance/bundle/resources/permissions/jobs/deleted_remotely/out.plan_restore.json index d3172a577fe..d31309e3676 100644 --- a/acceptance/bundle/resources/permissions/jobs/deleted_remotely/out.plan_restore.json +++ b/acceptance/bundle/resources/permissions/jobs/deleted_remotely/out.plan_restore.json @@ -7,8 +7,6 @@ "resources.jobs.job_with_permissions": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/jobs-permissions-deleted-remotely/default/state/metadata.json" @@ -16,13 +14,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [JOB_WITH_PERMISSIONS_ID], "max_concurrent_runs": 1, "name": "job permissions deleted remotely", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -36,7 +32,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [JOB_WITH_PERMISSIONS_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/permissions/jobs/deleted_remotely/out.requests_create.json b/acceptance/bundle/resources/permissions/jobs/deleted_remotely/out.requests_create.json index 38772e9eafe..647721e1459 100644 --- a/acceptance/bundle/resources/permissions/jobs/deleted_remotely/out.requests_create.json +++ b/acceptance/bundle/resources/permissions/jobs/deleted_remotely/out.requests_create.json @@ -41,6 +41,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[JOB_WITH_PERMISSIONS_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/deleted_remotely/out.requests_restore.json b/acceptance/bundle/resources/permissions/jobs/deleted_remotely/out.requests_restore.json index 5d35bb60ea2..42d08aee719 100644 --- a/acceptance/bundle/resources/permissions/jobs/deleted_remotely/out.requests_restore.json +++ b/acceptance/bundle/resources/permissions/jobs/deleted_remotely/out.requests_restore.json @@ -15,6 +15,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[JOB_WITH_PERMISSIONS_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/deleted_remotely/output.txt b/acceptance/bundle/resources/permissions/jobs/deleted_remotely/output.txt index 3dbeecb21c7..1598fa9ed18 100644 --- a/acceptance/bundle/resources/permissions/jobs/deleted_remotely/output.txt +++ b/acceptance/bundle/resources/permissions/jobs/deleted_remotely/output.txt @@ -100,7 +100,9 @@ Resources: 2 created, 0 changed, 0 deleted, 0 unchanged "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[JOB_WITH_PERMISSIONS_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/other_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/jobs/other_can_manage/out.requests.deploy.json index 47781d53496..323d0585fd9 100644 --- a/acceptance/bundle/resources/permissions/jobs/other_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/jobs/other_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/other_can_manage_run/out.deploy.requests.json b/acceptance/bundle/resources/permissions/jobs/other_can_manage_run/out.deploy.requests.json index 8c03b139400..8e692aed81c 100644 --- a/acceptance/bundle/resources/permissions/jobs/other_can_manage_run/out.deploy.requests.json +++ b/acceptance/bundle/resources/permissions/jobs/other_can_manage_run/out.deploy.requests.json @@ -28,6 +28,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[INTERIM_GOLD_LAYER_JOB_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/other_is_owner/out.requests.deploy.json b/acceptance/bundle/resources/permissions/jobs/other_is_owner/out.requests.deploy.json index c43da51b594..92142dd286c 100644 --- a/acceptance/bundle/resources/permissions/jobs/other_is_owner/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/jobs/other_is_owner/out.requests.deploy.json @@ -11,6 +11,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/update/out.plan_delete_all.json b/acceptance/bundle/resources/permissions/jobs/update/out.plan_delete_all.json index b6cfa725c53..83a1f33e867 100644 --- a/acceptance/bundle/resources/permissions/jobs/update/out.plan_delete_all.json +++ b/acceptance/bundle/resources/permissions/jobs/update/out.plan_delete_all.json @@ -7,8 +7,6 @@ "resources.jobs.job_with_permissions": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/jobs-permissions-test/default/state/metadata.json" @@ -16,13 +14,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [JOB_WITH_PERMISSIONS_ID], "max_concurrent_runs": 1, "name": "job with permissions", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -36,7 +32,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [JOB_WITH_PERMISSIONS_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/permissions/jobs/update/out.plan_delete_one.json b/acceptance/bundle/resources/permissions/jobs/update/out.plan_delete_one.json index 2f685883af6..eeceb68d017 100644 --- a/acceptance/bundle/resources/permissions/jobs/update/out.plan_delete_one.json +++ b/acceptance/bundle/resources/permissions/jobs/update/out.plan_delete_one.json @@ -7,8 +7,6 @@ "resources.jobs.job_with_permissions": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/jobs-permissions-test/default/state/metadata.json" @@ -16,13 +14,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [JOB_WITH_PERMISSIONS_ID], "max_concurrent_runs": 1, "name": "job with permissions", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -36,7 +32,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [JOB_WITH_PERMISSIONS_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/permissions/jobs/update/out.plan_post_create.json b/acceptance/bundle/resources/permissions/jobs/update/out.plan_post_create.json index 86c1144b0da..66a645c5fb0 100644 --- a/acceptance/bundle/resources/permissions/jobs/update/out.plan_post_create.json +++ b/acceptance/bundle/resources/permissions/jobs/update/out.plan_post_create.json @@ -7,8 +7,6 @@ "resources.jobs.job_with_permissions": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/jobs-permissions-test/default/state/metadata.json" @@ -16,13 +14,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [JOB_WITH_PERMISSIONS_ID], "max_concurrent_runs": 1, "name": "job with permissions", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -36,7 +32,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [JOB_WITH_PERMISSIONS_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/permissions/jobs/update/out.plan_restore.json b/acceptance/bundle/resources/permissions/jobs/update/out.plan_restore.json index e62b14f7ce6..c80222b4454 100644 --- a/acceptance/bundle/resources/permissions/jobs/update/out.plan_restore.json +++ b/acceptance/bundle/resources/permissions/jobs/update/out.plan_restore.json @@ -7,8 +7,6 @@ "resources.jobs.job_with_permissions": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/jobs-permissions-test/default/state/metadata.json" @@ -16,13 +14,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [JOB_WITH_PERMISSIONS_ID], "max_concurrent_runs": 1, "name": "job with permissions", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -36,7 +32,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [JOB_WITH_PERMISSIONS_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/permissions/jobs/update/out.plan_set_empty.json b/acceptance/bundle/resources/permissions/jobs/update/out.plan_set_empty.json index b01df3c6905..54c8e947b54 100644 --- a/acceptance/bundle/resources/permissions/jobs/update/out.plan_set_empty.json +++ b/acceptance/bundle/resources/permissions/jobs/update/out.plan_set_empty.json @@ -7,8 +7,6 @@ "resources.jobs.job_with_permissions": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/jobs-permissions-test/default/state/metadata.json" @@ -16,13 +14,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [JOB_WITH_PERMISSIONS_ID], "max_concurrent_runs": 1, "name": "job with permissions", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -36,7 +32,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [JOB_WITH_PERMISSIONS_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/permissions/jobs/update/out.plan_update.json b/acceptance/bundle/resources/permissions/jobs/update/out.plan_update.json index 4c63a45fcd7..cac97047290 100644 --- a/acceptance/bundle/resources/permissions/jobs/update/out.plan_update.json +++ b/acceptance/bundle/resources/permissions/jobs/update/out.plan_update.json @@ -7,8 +7,6 @@ "resources.jobs.job_with_permissions": { "action": "skip", "remote_state": { - "created_time": [UNIX_TIME_MILLIS], - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/jobs-permissions-test/default/state/metadata.json" @@ -16,13 +14,11 @@ "edit_mode": "UI_LOCKED", "email_notifications": {}, "format": "MULTI_TASK", - "job_id": [JOB_WITH_PERMISSIONS_ID], "max_concurrent_runs": 1, "name": "job with permissions", "queue": { "enabled": true }, - "run_as_user_name": "[USERNAME]", "tasks": [ { "email_notifications": {}, @@ -36,7 +32,11 @@ } ], "timeout_seconds": 0, - "webhook_notifications": {} + "webhook_notifications": {}, + "created_time": [UNIX_TIME_MILLIS], + "creator_user_name": "[USERNAME]", + "job_id": [JOB_WITH_PERMISSIONS_ID], + "run_as_user_name": "[USERNAME]" }, "changes": { "email_notifications": { diff --git a/acceptance/bundle/resources/permissions/jobs/update/out.requests_create.json b/acceptance/bundle/resources/permissions/jobs/update/out.requests_create.json index 432fbaa4007..99e62b0e7c7 100644 --- a/acceptance/bundle/resources/permissions/jobs/update/out.requests_create.json +++ b/acceptance/bundle/resources/permissions/jobs/update/out.requests_create.json @@ -41,6 +41,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[JOB_WITH_PERMISSIONS_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/update/out.requests_delete_one.json b/acceptance/bundle/resources/permissions/jobs/update/out.requests_delete_one.json index 95b2f46e44d..79c7af9a815 100644 --- a/acceptance/bundle/resources/permissions/jobs/update/out.requests_delete_one.json +++ b/acceptance/bundle/resources/permissions/jobs/update/out.requests_delete_one.json @@ -11,6 +11,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[JOB_WITH_PERMISSIONS_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/update/out.requests_restore_original.json b/acceptance/bundle/resources/permissions/jobs/update/out.requests_restore_original.json index 5d35bb60ea2..42d08aee719 100644 --- a/acceptance/bundle/resources/permissions/jobs/update/out.requests_restore_original.json +++ b/acceptance/bundle/resources/permissions/jobs/update/out.requests_restore_original.json @@ -15,6 +15,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[JOB_WITH_PERMISSIONS_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/update/out.requests_update.json b/acceptance/bundle/resources/permissions/jobs/update/out.requests_update.json index 06d5787fb18..fbd328d4476 100644 --- a/acceptance/bundle/resources/permissions/jobs/update/out.requests_update.json +++ b/acceptance/bundle/resources/permissions/jobs/update/out.requests_update.json @@ -15,6 +15,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[JOB_WITH_PERMISSIONS_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/jobs/viewers/out.requests.deploy.json b/acceptance/bundle/resources/permissions/jobs/viewers/out.requests.deploy.json index 6fcb88e628c..507d1fa1b5f 100644 --- a/acceptance/bundle/resources/permissions/jobs/viewers/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/jobs/viewers/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/models/current_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/models/current_can_manage/out.requests.deploy.json index 568657ccaca..4305e5bfaa0 100644 --- a/acceptance/bundle/resources/permissions/models/current_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/models/current_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_MODEL_ID]", + "request_object_type": "registered-models" } } diff --git a/acceptance/bundle/resources/permissions/pipelines/504/plan/output.txt b/acceptance/bundle/resources/permissions/pipelines/504/plan/output.txt index 3bfb86fdf75..0d59fac4fdf 100644 --- a/acceptance/bundle/resources/permissions/pipelines/504/plan/output.txt +++ b/acceptance/bundle/resources/permissions/pipelines/504/plan/output.txt @@ -22,7 +22,7 @@ Warn: planning resources.pipelines.foo.permissions: retrying after 504 Gateway T Warn: planning resources.pipelines.foo.permissions: retrying after 504 Gateway Timeout from GET /api/2.0/permissions/pipelines/[UUID] Error: cannot plan resources.pipelines.foo.permissions: reading id="/pipelines/[UUID]": Fault injected by test. (504 INJECTED) -Endpoint: GET [DATABRICKS_URL]/api/2.0/permissions/pipelines/[UUID]? +Endpoint: GET [DATABRICKS_URL]/api/2.0/permissions/pipelines/[UUID] HTTP Status: 504 Gateway Timeout API error_code: INJECTED API message: Fault injected by test. diff --git a/acceptance/bundle/resources/permissions/pipelines/current_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/pipelines/current_can_manage/out.requests.deploy.json index 3cf3626b1d8..8150ff0e8bb 100644 --- a/acceptance/bundle/resources/permissions/pipelines/current_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/pipelines/current_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "pipelines" } } diff --git a/acceptance/bundle/resources/permissions/pipelines/current_is_owner/out.requests.deploy.json b/acceptance/bundle/resources/permissions/pipelines/current_is_owner/out.requests.deploy.json index 432b096a2b0..8ba9a06d406 100644 --- a/acceptance/bundle/resources/permissions/pipelines/current_is_owner/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/pipelines/current_is_owner/out.requests.deploy.json @@ -7,6 +7,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "pipelines" } } diff --git a/acceptance/bundle/resources/permissions/pipelines/other_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/pipelines/other_can_manage/out.requests.deploy.json index 3cf3626b1d8..8150ff0e8bb 100644 --- a/acceptance/bundle/resources/permissions/pipelines/other_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/pipelines/other_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "pipelines" } } diff --git a/acceptance/bundle/resources/permissions/pipelines/other_is_owner/out.requests.deploy.json b/acceptance/bundle/resources/permissions/pipelines/other_is_owner/out.requests.deploy.json index 374e454b56e..c20ebe058ad 100644 --- a/acceptance/bundle/resources/permissions/pipelines/other_is_owner/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/pipelines/other_is_owner/out.requests.deploy.json @@ -11,6 +11,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "pipelines" } } diff --git a/acceptance/bundle/resources/permissions/pipelines/update/out.plan_delete_all.json b/acceptance/bundle/resources/permissions/pipelines/update/out.plan_delete_all.json index d7f0f05e93e..f39a9e3cdc5 100644 --- a/acceptance/bundle/resources/permissions/pipelines/update/out.plan_delete_all.json +++ b/acceptance/bundle/resources/permissions/pipelines/update/out.plan_delete_all.json @@ -8,20 +8,20 @@ "action": "skip", "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/permissions-test/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[FOO_ID]", - "last_modified": [UNIX_TIME_MILLIS], "name": "foo", + "storage": "dbfs:/pipelines/[FOO_ID]", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], "pipeline_id": "[FOO_ID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/[FOO_ID]" + "state": "IDLE" }, "changes": { "storage": { diff --git a/acceptance/bundle/resources/permissions/pipelines/update/out.plan_delete_one.json b/acceptance/bundle/resources/permissions/pipelines/update/out.plan_delete_one.json index 3bf8a3cc617..858c5fdf697 100644 --- a/acceptance/bundle/resources/permissions/pipelines/update/out.plan_delete_one.json +++ b/acceptance/bundle/resources/permissions/pipelines/update/out.plan_delete_one.json @@ -8,20 +8,20 @@ "action": "skip", "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/permissions-test/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[FOO_ID]", - "last_modified": [UNIX_TIME_MILLIS], "name": "foo", + "storage": "dbfs:/pipelines/[FOO_ID]", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], "pipeline_id": "[FOO_ID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/[FOO_ID]" + "state": "IDLE" }, "changes": { "storage": { diff --git a/acceptance/bundle/resources/permissions/pipelines/update/out.plan_restore.json b/acceptance/bundle/resources/permissions/pipelines/update/out.plan_restore.json index bd9341b8f18..5f4d605b9ed 100644 --- a/acceptance/bundle/resources/permissions/pipelines/update/out.plan_restore.json +++ b/acceptance/bundle/resources/permissions/pipelines/update/out.plan_restore.json @@ -8,20 +8,20 @@ "action": "skip", "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/permissions-test/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[FOO_ID]", - "last_modified": [UNIX_TIME_MILLIS], "name": "foo", + "storage": "dbfs:/pipelines/[FOO_ID]", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], "pipeline_id": "[FOO_ID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/[FOO_ID]" + "state": "IDLE" }, "changes": { "storage": { diff --git a/acceptance/bundle/resources/permissions/pipelines/update/out.plan_update.json b/acceptance/bundle/resources/permissions/pipelines/update/out.plan_update.json index d5222ca0237..7e162cb2625 100644 --- a/acceptance/bundle/resources/permissions/pipelines/update/out.plan_update.json +++ b/acceptance/bundle/resources/permissions/pipelines/update/out.plan_update.json @@ -8,20 +8,20 @@ "action": "skip", "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/permissions-test/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[FOO_ID]", - "last_modified": [UNIX_TIME_MILLIS], "name": "foo", + "storage": "dbfs:/pipelines/[FOO_ID]", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], "pipeline_id": "[FOO_ID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/[FOO_ID]" + "state": "IDLE" }, "changes": { "storage": { diff --git a/acceptance/bundle/resources/permissions/pipelines/update/out.requests_create.json b/acceptance/bundle/resources/permissions/pipelines/update/out.requests_create.json index e7758818858..dd216ce77e8 100644 --- a/acceptance/bundle/resources/permissions/pipelines/update/out.requests_create.json +++ b/acceptance/bundle/resources/permissions/pipelines/update/out.requests_create.json @@ -28,6 +28,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "pipelines" } } diff --git a/acceptance/bundle/resources/permissions/pipelines/update/out.requests_delete_one.json b/acceptance/bundle/resources/permissions/pipelines/update/out.requests_delete_one.json index a8aa5af7f8b..448d88fcf62 100644 --- a/acceptance/bundle/resources/permissions/pipelines/update/out.requests_delete_one.json +++ b/acceptance/bundle/resources/permissions/pipelines/update/out.requests_delete_one.json @@ -11,6 +11,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "pipelines" } } diff --git a/acceptance/bundle/resources/permissions/pipelines/update/out.requests_restore_original.json b/acceptance/bundle/resources/permissions/pipelines/update/out.requests_restore_original.json index 2067ef6365a..daf1b028afd 100644 --- a/acceptance/bundle/resources/permissions/pipelines/update/out.requests_restore_original.json +++ b/acceptance/bundle/resources/permissions/pipelines/update/out.requests_restore_original.json @@ -15,6 +15,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "pipelines" } } diff --git a/acceptance/bundle/resources/permissions/pipelines/update/out.requests_update.json b/acceptance/bundle/resources/permissions/pipelines/update/out.requests_update.json index bbe8bba2ba7..78e155d8eea 100644 --- a/acceptance/bundle/resources/permissions/pipelines/update/out.requests_update.json +++ b/acceptance/bundle/resources/permissions/pipelines/update/out.requests_update.json @@ -15,6 +15,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "pipelines" } } diff --git a/acceptance/bundle/resources/permissions/postgres_projects/current_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/postgres_projects/current_can_manage/out.requests.deploy.json index 11f81a57efc..843ec803327 100644 --- a/acceptance/bundle/resources/permissions/postgres_projects/current_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/postgres_projects/current_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "test-project", + "request_object_type": "database-projects" } } diff --git a/acceptance/bundle/resources/permissions/sql_warehouses/current_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/sql_warehouses/current_can_manage/out.requests.deploy.json index 78d825e1a16..1aa24b9f545 100644 --- a/acceptance/bundle/resources/permissions/sql_warehouses/current_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/sql_warehouses/current_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "sql/warehouses" } } diff --git a/acceptance/bundle/resources/permissions/target_permissions/out.requests_create.json b/acceptance/bundle/resources/permissions/target_permissions/out.requests_create.json index 828a03592a6..1e0d5294fc6 100644 --- a/acceptance/bundle/resources/permissions/target_permissions/out.requests_create.json +++ b/acceptance/bundle/resources/permissions/target_permissions/out.requests_create.json @@ -33,6 +33,8 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[FOO_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/resources/permissions/vector_search_endpoints/current_can_manage/out.requests.deploy.json b/acceptance/bundle/resources/permissions/vector_search_endpoints/current_can_manage/out.requests.deploy.json index ecfc2c8ac50..319c3dfe9b2 100644 --- a/acceptance/bundle/resources/permissions/vector_search_endpoints/current_can_manage/out.requests.deploy.json +++ b/acceptance/bundle/resources/permissions/vector_search_endpoints/current_can_manage/out.requests.deploy.json @@ -19,6 +19,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[UUID]", + "request_object_type": "vector-search-endpoints" } } diff --git a/acceptance/bundle/resources/pipelines/recreate-add-whole-block/out.plan.json b/acceptance/bundle/resources/pipelines/recreate-add-whole-block/out.plan.json index 345c3fb80fd..1f0c3785565 100644 --- a/acceptance/bundle/resources/pipelines/recreate-add-whole-block/out.plan.json +++ b/acceptance/bundle/resources/pipelines/recreate-add-whole-block/out.plan.json @@ -33,15 +33,12 @@ }, "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/acc-[UNIQUE_NAME]/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[UUID]", - "last_modified": [UNIX_TIME_MILLIS], "libraries": [ { "file": { @@ -50,10 +47,13 @@ } ], "name": "test-pipeline-[UNIQUE_NAME]", + "storage": "dbfs:/pipelines/custom", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], "pipeline_id": "[UUID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/custom" + "state": "IDLE" }, "changes": { "ingestion_definition": { diff --git a/acceptance/bundle/resources/pipelines/recreate-keys/change-ingestion-definition/out.plan_recreate.json b/acceptance/bundle/resources/pipelines/recreate-keys/change-ingestion-definition/out.plan_recreate.json index a1eeb395141..3329177394c 100644 --- a/acceptance/bundle/resources/pipelines/recreate-keys/change-ingestion-definition/out.plan_recreate.json +++ b/acceptance/bundle/resources/pipelines/recreate-keys/change-ingestion-definition/out.plan_recreate.json @@ -32,13 +32,11 @@ }, "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/acc-[UNIQUE_NAME]/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[MY_ID]", "ingestion_definition": { "connection_name": "my_connection", @@ -46,7 +44,6 @@ {} ] }, - "last_modified": [UNIX_TIME_MILLIS], "libraries": [ { "file": { @@ -55,10 +52,13 @@ } ], "name": "test-pipeline-[UNIQUE_NAME]", + "storage": "dbfs:/pipelines/[MY_ID]", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], "pipeline_id": "[MY_ID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/[MY_ID]" + "state": "IDLE" }, "changes": { "ingestion_definition.connection_name": { diff --git a/acceptance/bundle/resources/pipelines/recreate-keys/change-storage/out.plan_recreate.json b/acceptance/bundle/resources/pipelines/recreate-keys/change-storage/out.plan_recreate.json index 2169f607228..c259882aa0c 100644 --- a/acceptance/bundle/resources/pipelines/recreate-keys/change-storage/out.plan_recreate.json +++ b/acceptance/bundle/resources/pipelines/recreate-keys/change-storage/out.plan_recreate.json @@ -27,15 +27,12 @@ }, "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/acc-[UNIQUE_NAME]/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[MY_ID]", - "last_modified": [UNIX_TIME_MILLIS], "libraries": [ { "file": { @@ -44,10 +41,13 @@ } ], "name": "test-pipeline-[UNIQUE_NAME]", + "storage": "dbfs:/pipelines/custom", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], "pipeline_id": "[MY_ID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/custom" + "state": "IDLE" }, "changes": { "storage": { diff --git a/acceptance/bundle/resources/pipelines/recreate-remove-whole-block/out.plan.json b/acceptance/bundle/resources/pipelines/recreate-remove-whole-block/out.plan.json index e9d4cb5b6d8..b5b9b23484c 100644 --- a/acceptance/bundle/resources/pipelines/recreate-remove-whole-block/out.plan.json +++ b/acceptance/bundle/resources/pipelines/recreate-remove-whole-block/out.plan.json @@ -27,13 +27,11 @@ }, "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/acc-[UNIQUE_NAME]/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[UUID]", "ingestion_definition": { "connection_name": "my_connection", @@ -41,7 +39,6 @@ {} ] }, - "last_modified": [UNIX_TIME_MILLIS], "libraries": [ { "file": { @@ -50,10 +47,13 @@ } ], "name": "test-pipeline-[UNIQUE_NAME]", + "storage": "dbfs:/pipelines/custom", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], "pipeline_id": "[UUID]", "run_as_user_name": "[USERNAME]", - "state": "IDLE", - "storage": "dbfs:/pipelines/custom" + "state": "IDLE" }, "changes": { "ingestion_definition": { diff --git a/acceptance/bundle/resources/pipelines/remote_matches_config/out.plan.json b/acceptance/bundle/resources/pipelines/remote_matches_config/out.plan.json index af5bdbf016b..a78ce139ba9 100644 --- a/acceptance/bundle/resources/pipelines/remote_matches_config/out.plan.json +++ b/acceptance/bundle/resources/pipelines/remote_matches_config/out.plan.json @@ -30,15 +30,12 @@ }, "remote_state": { "channel": "CURRENT", - "creator_user_name": "[USERNAME]", "deployment": { "kind": "BUNDLE", "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json" }, "edition": "ADVANCED", - "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", "id": "[MY_PIPELINE_ID]", - "last_modified": [UNIX_TIME_MILLIS], "libraries": [ { "notebook": { @@ -47,14 +44,17 @@ } ], "name": "Test Pipeline run_as guard", - "pipeline_id": "[MY_PIPELINE_ID]", "run_as": { "user_name": "changed@example.test" }, - "run_as_user_name": "[USERNAME]", "serverless": true, - "state": "IDLE", - "storage": "dbfs:/pipelines/[MY_PIPELINE_ID]" + "storage": "dbfs:/pipelines/[MY_PIPELINE_ID]", + "creator_user_name": "[USERNAME]", + "effective_publishing_mode": "DEFAULT_PUBLISHING_MODE", + "last_modified": [UNIX_TIME_MILLIS], + "pipeline_id": "[MY_PIPELINE_ID]", + "run_as_user_name": "[USERNAME]", + "state": "IDLE" }, "changes": { "run_as.user_name": { diff --git a/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.create.json b/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.create.json index 8939ec703a5..e02afd9ebbf 100644 --- a/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.create.json +++ b/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.create.json @@ -8,9 +8,9 @@ "action": "create", "new_state": { "value": { - "branch_id": "dev-branch", "is_protected": false, "no_expiry": true, + "branch_id": "dev-branch", "parent": "${resources.postgres_projects.my_project.id}" }, "vars": { diff --git a/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.no_change.json b/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.no_change.json index ff7df005d4e..67cfa011687 100644 --- a/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.no_change.json +++ b/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.no_change.json @@ -8,9 +8,8 @@ "action": "skip", "remote_state": { "branch_id": "dev-branch", - "create_time": "[TIMESTAMP]", - "name": "[DEV_BRANCH_ID]", "parent": "projects/test-pg-proj-[UNIQUE_NAME]", + "name": "[DEV_BRANCH_ID]", "status": { "branch_id": "dev-branch", "current_state": "READY", @@ -22,6 +21,7 @@ "state_change_time": "[TIMESTAMP]" }, "uid": "[BRANCH_UID]", + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { diff --git a/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.restore.json b/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.restore.json index 64acdc88a68..c8a282d89e5 100644 --- a/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.restore.json +++ b/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.restore.json @@ -8,17 +8,16 @@ "action": "update", "new_state": { "value": { - "branch_id": "dev-branch", "is_protected": false, "no_expiry": true, + "branch_id": "dev-branch", "parent": "projects/test-pg-proj-[UNIQUE_NAME]" } }, "remote_state": { "branch_id": "dev-branch", - "create_time": "[TIMESTAMP]", - "name": "[DEV_BRANCH_ID]", "parent": "projects/test-pg-proj-[UNIQUE_NAME]", + "name": "[DEV_BRANCH_ID]", "status": { "branch_id": "dev-branch", "current_state": "READY", @@ -30,6 +29,7 @@ "state_change_time": "[TIMESTAMP]" }, "uid": "[BRANCH_UID]", + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { diff --git a/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.update.json b/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.update.json index 6cc645dede6..959fd07dc81 100644 --- a/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.update.json +++ b/acceptance/bundle/resources/postgres_branches/update_protected/out.plan.update.json @@ -8,17 +8,16 @@ "action": "update", "new_state": { "value": { - "branch_id": "dev-branch", "is_protected": true, "no_expiry": true, + "branch_id": "dev-branch", "parent": "projects/test-pg-proj-[UNIQUE_NAME]" } }, "remote_state": { "branch_id": "dev-branch", - "create_time": "[TIMESTAMP]", - "name": "[DEV_BRANCH_ID]", "parent": "projects/test-pg-proj-[UNIQUE_NAME]", + "name": "[DEV_BRANCH_ID]", "status": { "branch_id": "dev-branch", "current_state": "READY", @@ -30,6 +29,7 @@ "state_change_time": "[TIMESTAMP]" }, "uid": "[BRANCH_UID]", + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { diff --git a/acceptance/bundle/resources/postgres_databases/update/out.plan.create.json b/acceptance/bundle/resources/postgres_databases/update/out.plan.create.json index 2cb56d4a187..e86755bf490 100644 --- a/acceptance/bundle/resources/postgres_databases/update/out.plan.create.json +++ b/acceptance/bundle/resources/postgres_databases/update/out.plan.create.json @@ -12,10 +12,10 @@ "action": "create", "new_state": { "value": { - "database_id": "my-database", - "parent": "${resources.postgres_branches.main.id}", "postgres_database": "initial_db_name", - "role": "${resources.postgres_roles.owner.id}" + "role": "${resources.postgres_roles.owner.id}", + "database_id": "my-database", + "parent": "${resources.postgres_branches.main.id}" }, "vars": { "parent": "${resources.postgres_branches.main.id}", diff --git a/acceptance/bundle/resources/postgres_databases/update/out.plan.no_change.json b/acceptance/bundle/resources/postgres_databases/update/out.plan.no_change.json index 002cec83a0e..689121e0793 100644 --- a/acceptance/bundle/resources/postgres_databases/update/out.plan.no_change.json +++ b/acceptance/bundle/resources/postgres_databases/update/out.plan.no_change.json @@ -11,16 +11,15 @@ ], "action": "skip", "remote_state": { - "create_time": "[TIMESTAMP]", "database_id": "my-database", - "name": "[MY_DATABASE_ID]", "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", - "role": "", + "name": "[MY_DATABASE_ID]", "status": { "database_id": "my-database", "postgres_database": "initial_db_name", "role": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner" }, + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { @@ -34,8 +33,7 @@ "action": "skip", "reason": "spec:input_only", "old": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner", - "new": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner", - "remote": "" + "new": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner" } } } diff --git a/acceptance/bundle/resources/postgres_databases/update/out.plan.restore.json b/acceptance/bundle/resources/postgres_databases/update/out.plan.restore.json index 1bd727c8de9..a904a9e6009 100644 --- a/acceptance/bundle/resources/postgres_databases/update/out.plan.restore.json +++ b/acceptance/bundle/resources/postgres_databases/update/out.plan.restore.json @@ -12,23 +12,22 @@ "action": "update", "new_state": { "value": { - "database_id": "my-database", - "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", "postgres_database": "initial_db_name", - "role": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner" + "role": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner", + "database_id": "my-database", + "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main" } }, "remote_state": { - "create_time": "[TIMESTAMP]", "database_id": "my-database", - "name": "[MY_DATABASE_ID]", "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", - "role": "", + "name": "[MY_DATABASE_ID]", "status": { "database_id": "my-database", "postgres_database": "renamed_db_name", "role": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner" }, + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { @@ -41,8 +40,7 @@ "action": "skip", "reason": "spec:input_only", "old": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner", - "new": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner", - "remote": "" + "new": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner" } } } diff --git a/acceptance/bundle/resources/postgres_databases/update/out.plan.update.json b/acceptance/bundle/resources/postgres_databases/update/out.plan.update.json index 9f104b5772c..86bca638ddc 100644 --- a/acceptance/bundle/resources/postgres_databases/update/out.plan.update.json +++ b/acceptance/bundle/resources/postgres_databases/update/out.plan.update.json @@ -12,23 +12,22 @@ "action": "update", "new_state": { "value": { - "database_id": "my-database", - "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", "postgres_database": "renamed_db_name", - "role": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner" + "role": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner", + "database_id": "my-database", + "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main" } }, "remote_state": { - "create_time": "[TIMESTAMP]", "database_id": "my-database", - "name": "[MY_DATABASE_ID]", "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", - "role": "", + "name": "[MY_DATABASE_ID]", "status": { "database_id": "my-database", "postgres_database": "initial_db_name", "role": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner" }, + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { @@ -41,8 +40,7 @@ "action": "skip", "reason": "spec:input_only", "old": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner", - "new": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner", - "remote": "" + "new": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner" } } } diff --git a/acceptance/bundle/resources/postgres_databases/update/out.requests.restore.json b/acceptance/bundle/resources/postgres_databases/update/out.requests.restore.json index 05d035f3dc0..6227df6fcd3 100644 --- a/acceptance/bundle/resources/postgres_databases/update/out.requests.restore.json +++ b/acceptance/bundle/resources/postgres_databases/update/out.requests.restore.json @@ -33,6 +33,7 @@ "update_mask": "spec.postgres_database" }, "body": { + "name": "[MY_DATABASE_ID]", "spec": { "postgres_database": "initial_db_name", "role": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner" diff --git a/acceptance/bundle/resources/postgres_databases/update/out.requests.update.json b/acceptance/bundle/resources/postgres_databases/update/out.requests.update.json index 82d82c5a603..6350dec3db8 100644 --- a/acceptance/bundle/resources/postgres_databases/update/out.requests.update.json +++ b/acceptance/bundle/resources/postgres_databases/update/out.requests.update.json @@ -33,6 +33,7 @@ "update_mask": "spec.postgres_database" }, "body": { + "name": "[MY_DATABASE_ID]", "spec": { "postgres_database": "renamed_db_name", "role": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/app-owner" diff --git a/acceptance/bundle/resources/postgres_endpoints/remove_suspend_timeout/out.plan.drift.json b/acceptance/bundle/resources/postgres_endpoints/remove_suspend_timeout/out.plan.drift.json index 77467bdb5d0..8f57d200630 100644 --- a/acceptance/bundle/resources/postgres_endpoints/remove_suspend_timeout/out.plan.drift.json +++ b/acceptance/bundle/resources/postgres_endpoints/remove_suspend_timeout/out.plan.drift.json @@ -17,8 +17,7 @@ "action": "skip", "reason": "spec:input_only", "old": "ENDPOINT_TYPE_READ_ONLY", - "new": "ENDPOINT_TYPE_READ_ONLY", - "remote": "" + "new": "ENDPOINT_TYPE_READ_ONLY" }, "suspend_timeout_duration": { "action": "update", diff --git a/acceptance/bundle/resources/postgres_endpoints/remove_suspend_timeout/out.plan.json b/acceptance/bundle/resources/postgres_endpoints/remove_suspend_timeout/out.plan.json index 77467bdb5d0..8f57d200630 100644 --- a/acceptance/bundle/resources/postgres_endpoints/remove_suspend_timeout/out.plan.json +++ b/acceptance/bundle/resources/postgres_endpoints/remove_suspend_timeout/out.plan.json @@ -17,8 +17,7 @@ "action": "skip", "reason": "spec:input_only", "old": "ENDPOINT_TYPE_READ_ONLY", - "new": "ENDPOINT_TYPE_READ_ONLY", - "remote": "" + "new": "ENDPOINT_TYPE_READ_ONLY" }, "suspend_timeout_duration": { "action": "update", diff --git a/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.create.json b/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.create.json index 2b8c7dce096..93cdd17a618 100644 --- a/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.create.json +++ b/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.create.json @@ -10,10 +10,10 @@ "value": { "autoscaling_limit_max_cu": 8, "autoscaling_limit_min_cu": 0.5, - "endpoint_id": "my-endpoint", "endpoint_type": "ENDPOINT_TYPE_READ_ONLY", - "parent": "${resources.postgres_branches.main.id}", - "suspend_timeout_duration": "300s" + "suspend_timeout_duration": "300s", + "endpoint_id": "my-endpoint", + "parent": "${resources.postgres_branches.main.id}" }, "vars": { "parent": "${resources.postgres_branches.main.id}" diff --git a/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.no_change.json b/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.no_change.json index 10c8affb555..04b26becd5b 100644 --- a/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.no_change.json +++ b/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.no_change.json @@ -23,8 +23,7 @@ "action": "skip", "reason": "spec:input_only", "old": "ENDPOINT_TYPE_READ_ONLY", - "new": "ENDPOINT_TYPE_READ_ONLY", - "remote": "" + "new": "ENDPOINT_TYPE_READ_ONLY" }, "suspend_timeout_duration": { "action": "skip", diff --git a/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.restore.json b/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.restore.json index 9228fd22296..ed642b9bfc3 100644 --- a/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.restore.json +++ b/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.restore.json @@ -10,10 +10,10 @@ "value": { "autoscaling_limit_max_cu": 8, "autoscaling_limit_min_cu": 0.5, - "endpoint_id": "my-endpoint", "endpoint_type": "ENDPOINT_TYPE_READ_ONLY", - "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", - "suspend_timeout_duration": "300s" + "suspend_timeout_duration": "300s", + "endpoint_id": "my-endpoint", + "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main" } }, "changes": { @@ -32,8 +32,7 @@ "action": "skip", "reason": "spec:input_only", "old": "ENDPOINT_TYPE_READ_ONLY", - "new": "ENDPOINT_TYPE_READ_ONLY", - "remote": "" + "new": "ENDPOINT_TYPE_READ_ONLY" }, "suspend_timeout_duration": { "action": "skip", diff --git a/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.update.json b/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.update.json index af255584b89..9c41a4087eb 100644 --- a/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.update.json +++ b/acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.update.json @@ -10,10 +10,10 @@ "value": { "autoscaling_limit_max_cu": 4, "autoscaling_limit_min_cu": 0.5, - "endpoint_id": "my-endpoint", "endpoint_type": "ENDPOINT_TYPE_READ_ONLY", - "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", - "suspend_timeout_duration": "300s" + "suspend_timeout_duration": "300s", + "endpoint_id": "my-endpoint", + "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main" } }, "changes": { @@ -32,8 +32,7 @@ "action": "skip", "reason": "spec:input_only", "old": "ENDPOINT_TYPE_READ_ONLY", - "new": "ENDPOINT_TYPE_READ_ONLY", - "remote": "" + "new": "ENDPOINT_TYPE_READ_ONLY" }, "suspend_timeout_duration": { "action": "skip", diff --git a/acceptance/bundle/resources/postgres_endpoints/update_pg_settings/out.plan.json b/acceptance/bundle/resources/postgres_endpoints/update_pg_settings/out.plan.json index 1cb37958265..b6969afecb2 100644 --- a/acceptance/bundle/resources/postgres_endpoints/update_pg_settings/out.plan.json +++ b/acceptance/bundle/resources/postgres_endpoints/update_pg_settings/out.plan.json @@ -17,8 +17,7 @@ "action": "skip", "reason": "spec:input_only", "old": "ENDPOINT_TYPE_READ_ONLY", - "new": "ENDPOINT_TYPE_READ_ONLY", - "remote": "" + "new": "ENDPOINT_TYPE_READ_ONLY" }, "settings": { "action": "update", diff --git a/acceptance/bundle/resources/postgres_endpoints/update_suspend_timeout/out.plan.json b/acceptance/bundle/resources/postgres_endpoints/update_suspend_timeout/out.plan.json index 0ec428d2dab..cb5fbe70f2b 100644 --- a/acceptance/bundle/resources/postgres_endpoints/update_suspend_timeout/out.plan.json +++ b/acceptance/bundle/resources/postgres_endpoints/update_suspend_timeout/out.plan.json @@ -17,8 +17,7 @@ "action": "skip", "reason": "spec:input_only", "old": "ENDPOINT_TYPE_READ_ONLY", - "new": "ENDPOINT_TYPE_READ_ONLY", - "remote": "" + "new": "ENDPOINT_TYPE_READ_ONLY" }, "suspend_timeout_duration": { "action": "update", diff --git a/acceptance/bundle/resources/postgres_projects/add_default_endpoint_settings/out.plan.json b/acceptance/bundle/resources/postgres_projects/add_default_endpoint_settings/out.plan.json index 90a8ddd5c91..01261e723dc 100644 --- a/acceptance/bundle/resources/postgres_projects/add_default_endpoint_settings/out.plan.json +++ b/acceptance/bundle/resources/postgres_projects/add_default_endpoint_settings/out.plan.json @@ -19,9 +19,8 @@ } }, "remote_state": { - "create_time": "[TIMESTAMP]", - "name": "projects/test-pg-proj-[UNIQUE_NAME]", "project_id": "test-pg-proj-[UNIQUE_NAME]", + "name": "projects/test-pg-proj-[UNIQUE_NAME]", "status": { "branch_logical_size_limit_bytes": [BRANCH_SIZE_LIMIT], "default_branch": "projects/test-pg-proj-[UNIQUE_NAME]/branches/production", @@ -39,6 +38,7 @@ "synthetic_storage_size_bytes": 0 }, "uid": "[UUID]", + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { diff --git a/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_spec/output.txt b/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_spec/output.txt index 315e46f8061..98814302c29 100644 --- a/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_spec/output.txt +++ b/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_spec/output.txt @@ -55,6 +55,7 @@ "update_mask": "spec" }, "body": { + "name": "projects/factcheck-spec-[UNIQUE_NAME]", "spec": { "display_name": "changed", "pg_version": 16 @@ -118,6 +119,7 @@ Exit code: 1 "update_mask": "spec" }, "body": { + "name": "projects/factcheck-spec-[UNIQUE_NAME]", "spec": { "display_name": "changed2", "history_retention_duration": "604800s", diff --git a/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_spec/script b/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_spec/script index a31e1f57ccd..c44af37d889 100644 --- a/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_spec/script +++ b/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_spec/script @@ -31,7 +31,9 @@ errcode trace $CLI postgres update-project "$name" spec --json '{"spec":{"displa trace print_requests.py //postgres/projects --method PATCH title "Set default_endpoint_settings to a non-default value (leaf mask)" -$CLI postgres update-project "$name" 'spec.default_endpoint_settings.autoscaling_limit_min_cu,spec.default_endpoint_settings.autoscaling_limit_max_cu,spec.default_endpoint_settings.suspension' --json '{"spec":{"default_endpoint_settings":{"autoscaling_limit_min_cu":0.5,"autoscaling_limit_max_cu":4,"suspend_timeout_duration":"300s"}}}' &> LOG.setup +# Raw API call: the mask names the oneof group (suspension), which the API requires +# and sdk-go's typed field mask rejects. +$CLI api patch "/api/2.0/postgres/$name?update_mask=spec.default_endpoint_settings.autoscaling_limit_min_cu,spec.default_endpoint_settings.autoscaling_limit_max_cu,spec.default_endpoint_settings.suspension" --json '{"spec":{"default_endpoint_settings":{"autoscaling_limit_min_cu":0.5,"autoscaling_limit_max_cu":4,"suspend_timeout_duration":"300s"}}}' &> LOG.setup trace $CLI postgres get-project "$name" | project_fields trace print_requests.py //postgres/projects --method PATCH diff --git a/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_star/output.txt b/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_star/output.txt index e968375589b..55d10a3fb33 100644 --- a/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_star/output.txt +++ b/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_star/output.txt @@ -37,6 +37,7 @@ Exit code: 1 "update_mask": "*" }, "body": { + "name": "projects/factcheck-star-[UNIQUE_NAME]", "spec": { "display_name": "changed", "pg_version": 16 @@ -100,6 +101,7 @@ Exit code: 1 "update_mask": "*" }, "body": { + "name": "projects/factcheck-star-[UNIQUE_NAME]", "spec": { "display_name": "changed2", "history_retention_duration": "604800s", diff --git a/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_star/script b/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_star/script index 8afce5004d1..35e019dc92e 100644 --- a/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_star/script +++ b/acceptance/bundle/resources/postgres_projects/factcheck/update_mask_star/script @@ -32,7 +32,9 @@ errcode trace $CLI postgres update-project "$name" '*' --json '{"spec":{"display trace print_requests.py //postgres/projects --method PATCH title "Set default_endpoint_settings to a non-default value (leaf mask)" -$CLI postgres update-project "$name" 'spec.default_endpoint_settings.autoscaling_limit_min_cu,spec.default_endpoint_settings.autoscaling_limit_max_cu,spec.default_endpoint_settings.suspension' --json '{"spec":{"default_endpoint_settings":{"autoscaling_limit_min_cu":0.5,"autoscaling_limit_max_cu":4,"suspend_timeout_duration":"300s"}}}' &> LOG.setup +# Raw API call: the mask names the oneof group (suspension), which the API requires +# and sdk-go's typed field mask rejects. +$CLI api patch "/api/2.0/postgres/$name?update_mask=spec.default_endpoint_settings.autoscaling_limit_min_cu,spec.default_endpoint_settings.autoscaling_limit_max_cu,spec.default_endpoint_settings.suspension" --json '{"spec":{"default_endpoint_settings":{"autoscaling_limit_min_cu":0.5,"autoscaling_limit_max_cu":4,"suspend_timeout_duration":"300s"}}}' &> LOG.setup trace $CLI postgres get-project "$name" | project_fields trace print_requests.py //postgres/projects --method PATCH diff --git a/acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.no_change.json b/acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.no_change.json index 0336f39f4a1..a6e7dd4fc7f 100644 --- a/acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.no_change.json +++ b/acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.no_change.json @@ -1,9 +1,8 @@ { "action": "skip", "remote_state": { - "create_time": "[TIMESTAMP]", - "name": "[MY_PROJECT_ID]", "project_id": "test-pg-proj-[UNIQUE_NAME]", + "name": "[MY_PROJECT_ID]", "status": { "branch_logical_size_limit_bytes": [BRANCH_SIZE_LIMIT], "default_branch": "[MY_PROJECT_ID]/branches/production", @@ -21,6 +20,7 @@ "synthetic_storage_size_bytes": 0 }, "uid": "[UUID]", + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { diff --git a/acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.restore.json b/acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.restore.json index 92ddb203f42..ce281a636af 100644 --- a/acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.restore.json +++ b/acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.restore.json @@ -14,9 +14,8 @@ } }, "remote_state": { - "create_time": "[TIMESTAMP]", - "name": "[MY_PROJECT_ID]", "project_id": "test-pg-proj-[UNIQUE_NAME]", + "name": "[MY_PROJECT_ID]", "status": { "branch_logical_size_limit_bytes": [BRANCH_SIZE_LIMIT], "default_branch": "[MY_PROJECT_ID]/branches/production", @@ -34,6 +33,7 @@ "synthetic_storage_size_bytes": 0 }, "uid": "[UUID]", + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { diff --git a/acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.update.json b/acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.update.json index 771d76a009f..869eca4eefe 100644 --- a/acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.update.json +++ b/acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.update.json @@ -14,9 +14,8 @@ } }, "remote_state": { - "create_time": "[TIMESTAMP]", - "name": "[MY_PROJECT_ID]", "project_id": "test-pg-proj-[UNIQUE_NAME]", + "name": "[MY_PROJECT_ID]", "status": { "branch_logical_size_limit_bytes": [BRANCH_SIZE_LIMIT], "default_branch": "[MY_PROJECT_ID]/branches/production", @@ -34,6 +33,7 @@ "synthetic_storage_size_bytes": 0 }, "uid": "[UUID]", + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { diff --git a/acceptance/bundle/resources/postgres_roles/update/out.plan.create.json b/acceptance/bundle/resources/postgres_roles/update/out.plan.create.json index d79dbc488a0..a391746333f 100644 --- a/acceptance/bundle/resources/postgres_roles/update/out.plan.create.json +++ b/acceptance/bundle/resources/postgres_roles/update/out.plan.create.json @@ -11,9 +11,9 @@ "attributes": { "createdb": false }, - "parent": "${resources.postgres_branches.main.id}", "postgres_role": "app_role", - "role_id": "test-role" + "role_id": "test-role", + "parent": "${resources.postgres_branches.main.id}" }, "vars": { "parent": "${resources.postgres_branches.main.id}" diff --git a/acceptance/bundle/resources/postgres_roles/update/out.plan.no_change.json b/acceptance/bundle/resources/postgres_roles/update/out.plan.no_change.json index 16cc6bd6a72..044686b2f0e 100644 --- a/acceptance/bundle/resources/postgres_roles/update/out.plan.no_change.json +++ b/acceptance/bundle/resources/postgres_roles/update/out.plan.no_change.json @@ -7,10 +7,9 @@ ], "action": "skip", "remote_state": { - "create_time": "[TIMESTAMP]", - "name": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/test-role", - "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", "role_id": "test-role", + "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", + "name": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/test-role", "status": { "attributes": { "bypassrls": false, @@ -22,6 +21,7 @@ "postgres_role": "app_role", "role_id": "test-role" }, + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { diff --git a/acceptance/bundle/resources/postgres_roles/update/out.plan.restore.json b/acceptance/bundle/resources/postgres_roles/update/out.plan.restore.json index e6ff6664b92..66e16427903 100644 --- a/acceptance/bundle/resources/postgres_roles/update/out.plan.restore.json +++ b/acceptance/bundle/resources/postgres_roles/update/out.plan.restore.json @@ -11,16 +11,15 @@ "attributes": { "createdb": false }, - "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", "postgres_role": "app_role", - "role_id": "test-role" + "role_id": "test-role", + "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main" } }, "remote_state": { - "create_time": "[TIMESTAMP]", - "name": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/test-role", - "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", "role_id": "test-role", + "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", + "name": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/test-role", "status": { "attributes": { "bypassrls": false, @@ -32,6 +31,7 @@ "postgres_role": "app_role", "role_id": "test-role" }, + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { diff --git a/acceptance/bundle/resources/postgres_roles/update/out.plan.update.json b/acceptance/bundle/resources/postgres_roles/update/out.plan.update.json index 76b67ee2de5..c5567f30162 100644 --- a/acceptance/bundle/resources/postgres_roles/update/out.plan.update.json +++ b/acceptance/bundle/resources/postgres_roles/update/out.plan.update.json @@ -11,16 +11,15 @@ "attributes": { "createdb": true }, - "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", "postgres_role": "app_role", - "role_id": "test-role" + "role_id": "test-role", + "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main" } }, "remote_state": { - "create_time": "[TIMESTAMP]", - "name": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/test-role", - "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", "role_id": "test-role", + "parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main", + "name": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/test-role", "status": { "attributes": { "bypassrls": false, @@ -32,6 +31,7 @@ "postgres_role": "app_role", "role_id": "test-role" }, + "create_time": "[TIMESTAMP]", "update_time": "[TIMESTAMP]" }, "changes": { diff --git a/acceptance/bundle/resources/postgres_roles/update/out.requests.restore.json b/acceptance/bundle/resources/postgres_roles/update/out.requests.restore.json index 198552d19ed..e6b9c884f1b 100644 --- a/acceptance/bundle/resources/postgres_roles/update/out.requests.restore.json +++ b/acceptance/bundle/resources/postgres_roles/update/out.requests.restore.json @@ -25,6 +25,7 @@ "update_mask": "spec.attributes.createdb" }, "body": { + "name": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/test-role", "spec": { "attributes": { "createdb": false diff --git a/acceptance/bundle/resources/postgres_roles/update/out.requests.update.json b/acceptance/bundle/resources/postgres_roles/update/out.requests.update.json index cdf033ce54f..b517f157c49 100644 --- a/acceptance/bundle/resources/postgres_roles/update/out.requests.update.json +++ b/acceptance/bundle/resources/postgres_roles/update/out.requests.update.json @@ -25,6 +25,7 @@ "update_mask": "spec.attributes.createdb" }, "body": { + "name": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main/roles/test-role", "spec": { "attributes": { "createdb": true diff --git a/acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.create.txt b/acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.create.txt index 7a674e8d1bc..ba64acabc60 100644 --- a/acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.create.txt +++ b/acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.create.txt @@ -9,6 +9,7 @@ "update_mask": "schedule" }, "body": { + "name": "projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule", "schedule": [ { "daily_schedule": { diff --git a/acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.remove.txt b/acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.remove.txt index 8449f260878..705eaafcecf 100644 --- a/acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.remove.txt +++ b/acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.remove.txt @@ -16,5 +16,7 @@ "q": { "update_mask": "schedule" }, - "body": {} + "body": { + "name": "projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule" + } } diff --git a/acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.update.txt b/acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.update.txt index 75841ac1e2a..1a6e3ff8e72 100644 --- a/acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.update.txt +++ b/acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.update.txt @@ -21,6 +21,7 @@ "update_mask": "schedule" }, "body": { + "name": "projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule", "schedule": [ { "daily_schedule": { diff --git a/acceptance/bundle/resources/quality_monitors/change_assets_dir/out.plan.json b/acceptance/bundle/resources/quality_monitors/change_assets_dir/out.plan.json index 0471f4d7f85..36bcb3fb506 100644 --- a/acceptance/bundle/resources/quality_monitors/change_assets_dir/out.plan.json +++ b/acceptance/bundle/resources/quality_monitors/change_assets_dir/out.plan.json @@ -11,8 +11,8 @@ "assets_dir": "/Workspace/Users/[USERNAME]/monitor_assets2_[UNIQUE_NAME]", "output_schema_name": "main.qm_test_[UNIQUE_NAME]", "snapshot": {}, - "table_name": "main.qm_test_[UNIQUE_NAME].test_table", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", + "table_name": "main.qm_test_[UNIQUE_NAME].test_table" } }, "remote_state": { diff --git a/acceptance/bundle/resources/quality_monitors/change_output_schema_name/out.plan.json b/acceptance/bundle/resources/quality_monitors/change_output_schema_name/out.plan.json index 7d37b225a2a..2f78973cace 100644 --- a/acceptance/bundle/resources/quality_monitors/change_output_schema_name/out.plan.json +++ b/acceptance/bundle/resources/quality_monitors/change_output_schema_name/out.plan.json @@ -11,8 +11,8 @@ "assets_dir": "/Workspace/Users/[USERNAME]/monitor_assets_[UNIQUE_NAME]", "output_schema_name": "main.qm_test_[UNIQUE_NAME]_2", "snapshot": {}, - "table_name": "main.qm_test_[UNIQUE_NAME].test_table", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", + "table_name": "main.qm_test_[UNIQUE_NAME].test_table" } }, "remote_state": { diff --git a/acceptance/bundle/resources/quality_monitors/change_table_name/out.plan.json b/acceptance/bundle/resources/quality_monitors/change_table_name/out.plan.json index 850061e1c60..40d80dcdff8 100644 --- a/acceptance/bundle/resources/quality_monitors/change_table_name/out.plan.json +++ b/acceptance/bundle/resources/quality_monitors/change_table_name/out.plan.json @@ -11,8 +11,8 @@ "assets_dir": "/Workspace/Users/[USERNAME]/monitor_assets_[UNIQUE_NAME]", "output_schema_name": "main.qm_test_[UNIQUE_NAME]", "snapshot": {}, - "table_name": "main.qm_test_[UNIQUE_NAME].test_table_2", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", + "table_name": "main.qm_test_[UNIQUE_NAME].test_table_2" } }, "remote_state": { diff --git a/acceptance/bundle/resources/quality_monitors/create/out.plan_create.json b/acceptance/bundle/resources/quality_monitors/create/out.plan_create.json index 59fadb45243..0805b303624 100644 --- a/acceptance/bundle/resources/quality_monitors/create/out.plan_create.json +++ b/acceptance/bundle/resources/quality_monitors/create/out.plan_create.json @@ -9,8 +9,8 @@ "assets_dir": "/Workspace/Users/[USERNAME]/monitor_assets_[UNIQUE_NAME]", "output_schema_name": "main.qm_test_[UNIQUE_NAME]", "snapshot": {}, - "table_name": "main.qm_test_[UNIQUE_NAME].test_table", - "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]", + "table_name": "main.qm_test_[UNIQUE_NAME].test_table" } } } diff --git a/acceptance/bundle/resources/quality_monitors/create/out.state.txt b/acceptance/bundle/resources/quality_monitors/create/out.state.txt index a09fecc62e8..459a0ad049c 100644 --- a/acceptance/bundle/resources/quality_monitors/create/out.state.txt +++ b/acceptance/bundle/resources/quality_monitors/create/out.state.txt @@ -1,2 +1,2 @@ "output_schema_name": "main.qm_test_[UNIQUE_NAME]", - "table_name": "main.qm_test_[UNIQUE_NAME].test_table", + "table_name": "main.qm_test_[UNIQUE_NAME].test_table" diff --git a/acceptance/bundle/resources/registered_models/comment_cleared/output.txt b/acceptance/bundle/resources/registered_models/comment_cleared/output.txt index 76ef93f002f..4ee4f543c76 100644 --- a/acceptance/bundle/resources/registered_models/comment_cleared/output.txt +++ b/acceptance/bundle/resources/registered_models/comment_cleared/output.txt @@ -30,6 +30,7 @@ Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged "body": { "catalog_name": "main", "comment": "", + "full_name_arg": "main.test-schema-[UNIQUE_NAME].test-model-[UNIQUE_NAME]", "name": "test-model-[UNIQUE_NAME]", "schema_name": "test-schema-[UNIQUE_NAME]" } diff --git a/acceptance/bundle/resources/schemas/comment_out_of_band/output.txt b/acceptance/bundle/resources/schemas/comment_out_of_band/output.txt index ff470fc8acd..bd7fbed70e5 100644 --- a/acceptance/bundle/resources/schemas/comment_out_of_band/output.txt +++ b/acceptance/bundle/resources/schemas/comment_out_of_band/output.txt @@ -47,7 +47,8 @@ Resources: 0 created, 0 changed, 0 deleted, 1 unchanged "path": "/api/2.1/unity-catalog/schemas/main.test-schema-[UNIQUE_NAME]", "body": { "comment": "", - "custom_max_retention_hours": 0 + "custom_max_retention_hours": 0, + "full_name_arg": "main.test-schema-[UNIQUE_NAME]" } } diff --git a/acceptance/bundle/resources/schemas/update/output.txt b/acceptance/bundle/resources/schemas/update/output.txt index ab18f7e09c7..1623ee360f8 100644 --- a/acceptance/bundle/resources/schemas/update/output.txt +++ b/acceptance/bundle/resources/schemas/update/output.txt @@ -30,6 +30,7 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged json.method = "PATCH"; json.path = "/api/2.1/unity-catalog/schemas/main.myschema"; json.body.comment = "COMMENT2"; +json.body.full_name_arg = "main.myschema"; schemas schema1 id='main.myschema' name='myschema' catalog_name='main' comment='COMMENT2' === Restore comment to original value and re-deploy @@ -45,4 +46,5 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged json.method = "PATCH"; json.path = "/api/2.1/unity-catalog/schemas/main.myschema"; json.body.comment = "COMMENT1"; +json.body.full_name_arg = "main.myschema"; schemas schema1 id='main.myschema' name='myschema' catalog_name='main' comment='COMMENT1' diff --git a/acceptance/bundle/resources/sql_warehouses/lifecycle-started-edit/output.txt b/acceptance/bundle/resources/sql_warehouses/lifecycle-started-edit/output.txt index 4e16305a146..dfb60c333bc 100644 --- a/acceptance/bundle/resources/sql_warehouses/lifecycle-started-edit/output.txt +++ b/acceptance/bundle/resources/sql_warehouses/lifecycle-started-edit/output.txt @@ -22,7 +22,9 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged { "method": "POST", "path": "/api/2.0/sql/warehouses/[WAREHOUSE_ID]/stop", - "body": {} + "body": { + "id": "[WAREHOUSE_ID]" + } } >>> errcode [CLI] warehouses get [WAREHOUSE_ID] @@ -45,6 +47,7 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "auto_stop_mins": 20, "cluster_size": "2X-Small", "enable_photon": true, + "id": "[WAREHOUSE_ID]", "max_num_clusters": 1, "name": "[UNIQUE_NAME]", "spot_instance_policy": "COST_OPTIMIZED" @@ -53,7 +56,9 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged { "method": "POST", "path": "/api/2.0/sql/warehouses/[WAREHOUSE_ID]/stop", - "body": {} + "body": { + "id": "[WAREHOUSE_ID]" + } } >>> errcode [CLI] warehouses get [WAREHOUSE_ID] diff --git a/acceptance/bundle/resources/sql_warehouses/lifecycle-started-toggle/output.txt b/acceptance/bundle/resources/sql_warehouses/lifecycle-started-toggle/output.txt index c0eaf7285cc..9ab7705ccda 100644 --- a/acceptance/bundle/resources/sql_warehouses/lifecycle-started-toggle/output.txt +++ b/acceptance/bundle/resources/sql_warehouses/lifecycle-started-toggle/output.txt @@ -22,7 +22,9 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged { "method": "POST", "path": "/api/2.0/sql/warehouses/[WAREHOUSE_ID]/stop", - "body": {} + "body": { + "id": "[WAREHOUSE_ID]" + } } >>> errcode [CLI] warehouses get [WAREHOUSE_ID] @@ -41,7 +43,9 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged { "method": "POST", "path": "/api/2.0/sql/warehouses/[WAREHOUSE_ID]/start", - "body": {} + "body": { + "id": "[WAREHOUSE_ID]" + } } >>> errcode [CLI] warehouses get [WAREHOUSE_ID] @@ -60,7 +64,9 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged { "method": "POST", "path": "/api/2.0/sql/warehouses/[WAREHOUSE_ID]/stop", - "body": {} + "body": { + "id": "[WAREHOUSE_ID]" + } } >>> errcode [CLI] warehouses get [WAREHOUSE_ID] diff --git a/acceptance/bundle/resources/sql_warehouses/lifecycle-started/output.txt b/acceptance/bundle/resources/sql_warehouses/lifecycle-started/output.txt index 13b09684797..cd3a566831e 100644 --- a/acceptance/bundle/resources/sql_warehouses/lifecycle-started/output.txt +++ b/acceptance/bundle/resources/sql_warehouses/lifecycle-started/output.txt @@ -43,12 +43,16 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged { "method": "POST", "path": "/api/2.0/sql/warehouses/[WAREHOUSE_ID]/stop", - "body": {} + "body": { + "id": "[WAREHOUSE_ID]" + } } { "method": "POST", "path": "/api/2.0/sql/warehouses/[WAREHOUSE_ID]/start", - "body": {} + "body": { + "id": "[WAREHOUSE_ID]" + } } >>> errcode [CLI] warehouses get [WAREHOUSE_ID] @@ -69,7 +73,9 @@ Resources: 0 created, 0 changed, 0 deleted, 1 unchanged { "method": "POST", "path": "/api/2.0/sql/warehouses/[WAREHOUSE_ID]/stop", - "body": {} + "body": { + "id": "[WAREHOUSE_ID]" + } } >>> errcode [CLI] warehouses get [WAREHOUSE_ID] @@ -88,7 +94,9 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged { "method": "POST", "path": "/api/2.0/sql/warehouses/[WAREHOUSE_ID]/start", - "body": {} + "body": { + "id": "[WAREHOUSE_ID]" + } } >>> errcode [CLI] warehouses get [WAREHOUSE_ID] diff --git a/acceptance/bundle/resources/sql_warehouses/output.txt b/acceptance/bundle/resources/sql_warehouses/output.txt index 5a109c71211..da6bb93954b 100644 --- a/acceptance/bundle/resources/sql_warehouses/output.txt +++ b/acceptance/bundle/resources/sql_warehouses/output.txt @@ -88,6 +88,7 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "cluster_size": "X-Large", "enable_photon": true, "enable_serverless_compute": true, + "id": "[UUID]", "max_num_clusters": 1, "min_num_clusters": 1, "name": "sql_warehouse_name_2", diff --git a/acceptance/bundle/resources/vector_search_endpoints/drift/target_qps/output.txt b/acceptance/bundle/resources/vector_search_endpoints/drift/target_qps/output.txt index 8e7a03dce0d..3d8f858f38b 100644 --- a/acceptance/bundle/resources/vector_search_endpoints/drift/target_qps/output.txt +++ b/acceptance/bundle/resources/vector_search_endpoints/drift/target_qps/output.txt @@ -42,6 +42,7 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "method": "PATCH", "path": "/api/2.0/vector-search/endpoints/vs-endpoint-[UNIQUE_NAME]", "body": { + "name": "vs-endpoint-[UNIQUE_NAME]", "target_qps": 1 } } diff --git a/acceptance/bundle/resources/vector_search_endpoints/update/budget_policy/out.requests.update.json b/acceptance/bundle/resources/vector_search_endpoints/update/budget_policy/out.requests.update.json index 36375854405..79951a43288 100644 --- a/acceptance/bundle/resources/vector_search_endpoints/update/budget_policy/out.requests.update.json +++ b/acceptance/bundle/resources/vector_search_endpoints/update/budget_policy/out.requests.update.json @@ -2,6 +2,7 @@ "method": "PATCH", "path": "/api/2.0/vector-search/endpoints/vs-endpoint-[UNIQUE_NAME]/budget-policy", "body": { - "budget_policy_id": "test-policy-id" + "budget_policy_id": "test-policy-id", + "name": "vs-endpoint-[UNIQUE_NAME]" } } diff --git a/acceptance/bundle/resources/vector_search_endpoints/update/target_qps/out.requests.create.json b/acceptance/bundle/resources/vector_search_endpoints/update/target_qps/out.requests.create.json index 7e7209e51e5..70059b7438f 100644 --- a/acceptance/bundle/resources/vector_search_endpoints/update/target_qps/out.requests.create.json +++ b/acceptance/bundle/resources/vector_search_endpoints/update/target_qps/out.requests.create.json @@ -20,6 +20,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[UUID]", + "request_object_type": "vector-search-endpoints" } } diff --git a/acceptance/bundle/resources/vector_search_endpoints/update/target_qps/out.requests.update.json b/acceptance/bundle/resources/vector_search_endpoints/update/target_qps/out.requests.update.json index b361b6e4357..02a6ccff279 100644 --- a/acceptance/bundle/resources/vector_search_endpoints/update/target_qps/out.requests.update.json +++ b/acceptance/bundle/resources/vector_search_endpoints/update/target_qps/out.requests.update.json @@ -2,6 +2,7 @@ "method": "PATCH", "path": "/api/2.0/vector-search/endpoints/vs-endpoint-[UNIQUE_NAME]", "body": { + "name": "vs-endpoint-[UNIQUE_NAME]", "target_qps": 2 } } @@ -18,6 +19,8 @@ "permission_level": "CAN_MANAGE", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[UUID]", + "request_object_type": "vector-search-endpoints" } } diff --git a/acceptance/bundle/resources/vector_search_indexes/grants/select/out.requests.json b/acceptance/bundle/resources/vector_search_indexes/grants/select/out.requests.json index 66c0fe79100..e82e94f23a0 100644 --- a/acceptance/bundle/resources/vector_search_indexes/grants/select/out.requests.json +++ b/acceptance/bundle/resources/vector_search_indexes/grants/select/out.requests.json @@ -31,6 +31,8 @@ "ALL_PRIVILEGES" ] } - ] + ], + "securable_full_name": "main.default.vs_index_[UNIQUE_NAME]", + "securable_type": "table" } } diff --git a/acceptance/bundle/resources/vector_search_indexes/recreate/with_endpoint/output.txt b/acceptance/bundle/resources/vector_search_indexes/recreate/with_endpoint/output.txt index 777eace89a2..056f1a8c725 100644 --- a/acceptance/bundle/resources/vector_search_indexes/recreate/with_endpoint/output.txt +++ b/acceptance/bundle/resources/vector_search_indexes/recreate/with_endpoint/output.txt @@ -37,12 +37,12 @@ Plan: 1 to add, 0 to change, 1 to delete, 1 unchanged "state": "ONLINE" }, "endpoint_type": "STANDARD", - "endpoint_uuid": "[UUID]", "id": "[UUID]", "last_updated_timestamp": [UNIX_TIME_MILLIS][0], "last_updated_user": "[USERNAME]", "name": "vs-endpoint-[UNIQUE_NAME]", - "scaling_info": {} + "scaling_info": {}, + "endpoint_uuid": "[UUID]" }, "changes": { "endpoint_type": { @@ -74,14 +74,14 @@ Plan: 1 to add, 0 to change, 1 to delete, 1 unchanged "schema_json": "{\"id\":\"int\",\"vector\":\"array\"}" }, "endpoint_name": "vs-endpoint-[UNIQUE_NAME]", - "endpoint_uuid": "[UUID]", "index_subtype": "HYBRID", "index_type": "DIRECT_ACCESS", "name": "main.default.vs_index_[UNIQUE_NAME]", "primary_key": "id", "status": { "ready": true - } + }, + "endpoint_uuid": "[UUID]" }, "changes": { "direct_access_index_spec.schema_json": { diff --git a/acceptance/bundle/resources/volumes/change-comment/output.txt b/acceptance/bundle/resources/volumes/change-comment/output.txt index 275ccb5f70d..14294d87658 100644 --- a/acceptance/bundle/resources/volumes/change-comment/output.txt +++ b/acceptance/bundle/resources/volumes/change-comment/output.txt @@ -81,7 +81,8 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "method": "PATCH", "path": "/api/2.1/unity-catalog/volumes/main.myschema.myvolume", "body": { - "comment": "COMMENT2" + "comment": "COMMENT2", + "full_name_arg": "main.myschema.myvolume" } } diff --git a/acceptance/bundle/resources/volumes/change-name/output.txt b/acceptance/bundle/resources/volumes/change-name/output.txt index 417cd36f6fd..b94386b329e 100644 --- a/acceptance/bundle/resources/volumes/change-name/output.txt +++ b/acceptance/bundle/resources/volumes/change-name/output.txt @@ -54,6 +54,7 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged "path": "/api/2.1/unity-catalog/volumes/main.myschema.myvolume", "body": { "comment": "COMMENT1", + "full_name_arg": "main.myschema.myvolume", "new_name": "mynewvolume" } } diff --git a/acceptance/bundle/resources/volumes/comment_out_of_band/output.txt b/acceptance/bundle/resources/volumes/comment_out_of_band/output.txt index b6619370518..8822c33e733 100644 --- a/acceptance/bundle/resources/volumes/comment_out_of_band/output.txt +++ b/acceptance/bundle/resources/volumes/comment_out_of_band/output.txt @@ -52,7 +52,8 @@ Resources: 0 created, 0 changed, 0 deleted, 2 unchanged "method": "PATCH", "path": "/api/2.1/unity-catalog/volumes/main.test-schema-[UNIQUE_NAME].test-volume-[UNIQUE_NAME]", "body": { - "comment": "" + "comment": "", + "full_name_arg": "main.test-schema-[UNIQUE_NAME].test-volume-[UNIQUE_NAME]" } } diff --git a/acceptance/bundle/resources/volumes/comment_with_rename/output.txt b/acceptance/bundle/resources/volumes/comment_with_rename/output.txt index 224755056d0..036f4671314 100644 --- a/acceptance/bundle/resources/volumes/comment_with_rename/output.txt +++ b/acceptance/bundle/resources/volumes/comment_with_rename/output.txt @@ -35,6 +35,7 @@ Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged "path": "/api/2.1/unity-catalog/volumes/main.test-schema-[UNIQUE_NAME].vol_one", "body": { "comment": "", + "full_name_arg": "main.test-schema-[UNIQUE_NAME].vol_one", "new_name": "vol_two" } } diff --git a/acceptance/bundle/run/development-mode-changes/output.txt b/acceptance/bundle/run/development-mode-changes/output.txt index c238681ff50..1ea01122bd3 100644 --- a/acceptance/bundle/run/development-mode-changes/output.txt +++ b/acceptance/bundle/run/development-mode-changes/output.txt @@ -30,7 +30,8 @@ Update ID: [UUID] "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", "body": { - "development": true + "development": true, + "pipeline_id": "[UUID]" } } @@ -53,7 +54,8 @@ Update ID: [UUID] "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", "body": { - "development": true + "development": true, + "pipeline_id": "[UUID]" } } @@ -75,7 +77,9 @@ Update ID: [UUID] { "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", - "body": {} + "body": { + "pipeline_id": "[UUID]" + } } === Pipeline switched to production outside the bundle: run on a development target sends development: true @@ -100,6 +104,7 @@ Update ID: [UUID] "method": "POST", "path": "/api/2.0/pipelines/[MY_PIPELINE_ID]/updates", "body": { - "development": true + "development": true, + "pipeline_id": "[MY_PIPELINE_ID]" } } diff --git a/acceptance/bundle/run/development-mode/output.txt b/acceptance/bundle/run/development-mode/output.txt index aae6f729a98..4bda209b945 100644 --- a/acceptance/bundle/run/development-mode/output.txt +++ b/acceptance/bundle/run/development-mode/output.txt @@ -15,7 +15,9 @@ Update ID: [UUID] { "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", - "body": {} + "body": { + "pipeline_id": "[UUID]" + } } === Development target: update sends development: true @@ -35,7 +37,8 @@ Update ID: [UUID] "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", "body": { - "development": true + "development": true, + "pipeline_id": "[UUID]" } } @@ -59,7 +62,8 @@ Pipeline configurations for this update: "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", "body": { - "development": true + "development": true, + "pipeline_id": "[UUID]" } } @@ -79,5 +83,7 @@ Update ID: [UUID] { "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", - "body": {} + "body": { + "pipeline_id": "[UUID]" + } } diff --git a/acceptance/bundle/run/development-override/output.txt b/acceptance/bundle/run/development-override/output.txt index 7110012790f..a44f40e1877 100644 --- a/acceptance/bundle/run/development-override/output.txt +++ b/acceptance/bundle/run/development-override/output.txt @@ -30,5 +30,7 @@ Update ID: [UUID] { "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", - "body": {} + "body": { + "pipeline_id": "[UUID]" + } } diff --git a/acceptance/bundle/run/refresh-flags/output.txt b/acceptance/bundle/run/refresh-flags/output.txt index 694608a5810..3e0322f7ea0 100644 --- a/acceptance/bundle/run/refresh-flags/output.txt +++ b/acceptance/bundle/run/refresh-flags/output.txt @@ -16,6 +16,7 @@ Update ID: [UUID] "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", "body": { + "pipeline_id": "[UUID]", "refresh_selection": [ "table1", "table2" @@ -34,7 +35,8 @@ Update ID: [UUID] "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", "body": { - "full_refresh": true + "full_refresh": true, + "pipeline_id": "[UUID]" } } @@ -52,7 +54,8 @@ Update ID: [UUID] "full_refresh_selection": [ "table1", "table2" - ] + ], + "pipeline_id": "[UUID]" } } @@ -71,6 +74,7 @@ Update ID: [UUID] "table1", "table2" ], + "pipeline_id": "[UUID]", "refresh_selection": [ "table3", "table4" diff --git a/acceptance/bundle/run/scripts/no-auth/output.txt b/acceptance/bundle/run/scripts/no-auth/output.txt index 79e350b834a..0dbc7799832 100644 --- a/acceptance/bundle/run/scripts/no-auth/output.txt +++ b/acceptance/bundle/run/scripts/no-auth/output.txt @@ -1,6 +1,6 @@ >>> [CLI] bundle run abcd -Error: failed during request visitor: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method. Config: databricks_cli_path=[CLI]. Env: DATABRICKS_CLI_PATH +Error: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method. Config: databricks_cli_path=[CLI]. Env: DATABRICKS_CLI_PATH Exit code: 1 diff --git a/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_service_principal_name.json b/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_service_principal_name.json index ed348b0244c..50c0a833ed8 100644 --- a/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_service_principal_name.json +++ b/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_service_principal_name.json @@ -36,7 +36,9 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[UUID]", + "request_object_type": "pipelines" }, "method": "PUT", "path": "/api/2.0/permissions/pipelines/[UUID]" diff --git a/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_service_principal_name_different.json b/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_service_principal_name_different.json index 31184316639..c31a9af0799 100644 --- a/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_service_principal_name_different.json +++ b/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_service_principal_name_different.json @@ -36,7 +36,9 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[UUID]", + "request_object_type": "pipelines" }, "method": "PUT", "path": "/api/2.0/permissions/pipelines/[UUID]" diff --git a/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_user_name.json b/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_user_name.json index d065490b516..dcd50acbd3d 100644 --- a/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_user_name.json +++ b/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_user_name.json @@ -36,7 +36,9 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[UUID]", + "request_object_type": "pipelines" }, "method": "PUT", "path": "/api/2.0/permissions/pipelines/[UUID]" diff --git a/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_user_name_different.json b/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_user_name_different.json index a5bb000230c..805bb987ca4 100644 --- a/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_user_name_different.json +++ b/acceptance/bundle/run_as/pipelines/regular_user/out.requests_t_user_name_different.json @@ -36,7 +36,9 @@ "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[UUID]", + "request_object_type": "pipelines" }, "method": "PUT", "path": "/api/2.0/permissions/pipelines/[UUID]" diff --git a/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_service_principal_name.json b/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_service_principal_name.json index 1f82ae598c3..e500efbdd3e 100644 --- a/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_service_principal_name.json +++ b/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_service_principal_name.json @@ -36,7 +36,9 @@ "permission_level": "IS_OWNER", "service_principal_name": "[USERNAME]" } - ] + ], + "request_object_id": "[UUID]", + "request_object_type": "pipelines" }, "method": "PUT", "path": "/api/2.0/permissions/pipelines/[UUID]" diff --git a/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_service_principal_name_different.json b/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_service_principal_name_different.json index 2748dd56670..0d2be7bcb27 100644 --- a/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_service_principal_name_different.json +++ b/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_service_principal_name_different.json @@ -36,7 +36,9 @@ "permission_level": "IS_OWNER", "service_principal_name": "[USERNAME]" } - ] + ], + "request_object_id": "[UUID]", + "request_object_type": "pipelines" }, "method": "PUT", "path": "/api/2.0/permissions/pipelines/[UUID]" diff --git a/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_user_name.json b/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_user_name.json index c67955f7540..836bd8231a9 100644 --- a/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_user_name.json +++ b/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_user_name.json @@ -36,7 +36,9 @@ "permission_level": "IS_OWNER", "service_principal_name": "[USERNAME]" } - ] + ], + "request_object_id": "[UUID]", + "request_object_type": "pipelines" }, "method": "PUT", "path": "/api/2.0/permissions/pipelines/[UUID]" diff --git a/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_user_name_different.json b/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_user_name_different.json index 5c8942a6084..c7d29178fe2 100644 --- a/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_user_name_different.json +++ b/acceptance/bundle/run_as/pipelines/service_principal/out.requests_t_user_name_different.json @@ -36,7 +36,9 @@ "permission_level": "IS_OWNER", "service_principal_name": "[USERNAME]" } - ] + ], + "request_object_id": "[UUID]", + "request_object_type": "pipelines" }, "method": "PUT", "path": "/api/2.0/permissions/pipelines/[UUID]" diff --git a/acceptance/bundle/select/grants_permissions/output.txt b/acceptance/bundle/select/grants_permissions/output.txt index 6ada2c1689b..723bb518879 100644 --- a/acceptance/bundle/select/grants_permissions/output.txt +++ b/acceptance/bundle/select/grants_permissions/output.txt @@ -45,7 +45,9 @@ Resources: 2 created, 0 changed, 0 deleted, 0 unchanged, 2 not selected ], "principal": "deco-test-user@databricks.com" } - ] + ], + "securable_full_name": "[MY_SCHEMA_ID]", + "securable_type": "schema" } } { @@ -61,7 +63,9 @@ Resources: 2 created, 0 changed, 0 deleted, 0 unchanged, 2 not selected "permission_level": "IS_OWNER", "user_name": "[USERNAME]" } - ] + ], + "request_object_id": "[MY_JOB_ID]", + "request_object_type": "jobs" } } diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/.vscode/__builtins__.pyi b/acceptance/bundle/templates/default-python/classic/output/my_default_python/.vscode/__builtins__.pyi deleted file mode 100644 index 0edd5181bc5..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/.vscode/__builtins__.pyi +++ /dev/null @@ -1,3 +0,0 @@ -# Typings for Pylance in Visual Studio Code -# see https://github.com/microsoft/pyright/blob/main/docs/builtins.md -from databricks.sdk.runtime import * diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/.vscode/extensions.json b/acceptance/bundle/templates/default-python/classic/output/my_default_python/.vscode/extensions.json deleted file mode 100644 index b958aacfcb4..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/.vscode/extensions.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "recommendations": [ - "charliermarsh.ruff", - "databricks.databricks", - "redhat.vscode-yaml" - ] -} diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/.vscode/settings.json b/acceptance/bundle/templates/default-python/classic/output/my_default_python/.vscode/settings.json deleted file mode 100644 index d73c73b5705..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/.vscode/settings.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "jupyter.interactiveWindow.cellMarker.codeRegex": "^# COMMAND ----------|^# Databricks notebook source|^(#\\s*%%|#\\s*\\|#\\s*In\\[\\d*?\\]|#\\s*In\\[ \\])", - "jupyter.interactiveWindow.cellMarker.default": "# COMMAND ----------", - "python.testing.pytestArgs": [ - "." - ], - "files.exclude": { - "**/*.egg-info": true, - "**/__pycache__": true, - ".pytest_cache": true, - "dist": true, - }, - "files.associations": { - "**/.gitkeep": "markdown" - }, - - // Pylance settings (VS Code) - // Set typeCheckingMode to "basic" to enable type checking! - "python.analysis.typeCheckingMode": "off", - "python.analysis.extraPaths": ["src", "lib", "resources"], - "python.analysis.diagnosticMode": "workspace", - "python.analysis.stubPath": ".vscode", - - // Pyright settings (Cursor) - // Set typeCheckingMode to "basic" to enable type checking! - "cursorpyright.analysis.typeCheckingMode": "off", - "cursorpyright.analysis.extraPaths": ["src", "lib", "resources"], - "cursorpyright.analysis.diagnosticMode": "workspace", - "cursorpyright.analysis.stubPath": ".vscode", - - // General Python settings - "python.defaultInterpreterPath": "./.venv/bin/python", - "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true, - "[python]": { - "editor.defaultFormatter": "charliermarsh.ruff", - "editor.formatOnSave": true, - }, -} diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/AGENTS.md b/acceptance/bundle/templates/default-python/classic/output/my_default_python/AGENTS.md deleted file mode 100644 index fdcca98a432..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/AGENTS.md +++ /dev/null @@ -1,25 +0,0 @@ -# Declarative Automation Bundles Project - -This project uses Declarative Automation Bundles (DABs) for deployment. Add project-specific instructions below. - -## For AI Agents: Use Databricks AI Tools - -**BEFORE any other action, read the `databricks-core` skill.** - -It sets you up to work with this project reliably: CLI authentication, profile -selection, data discovery, and the bundle deployment workflow. Without it, -results are often slower and less accurate. - -If this skill is not available (Databricks AI Tools are not installed), you can install them for your coding agent in seconds: - -```bash -databricks aitools install -``` - -If the CLI is not installed, see: https://docs.databricks.com/dev-tools/cli/install - ---- - -## Project Instructions - - diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/README.md b/acceptance/bundle/templates/default-python/classic/output/my_default_python/README.md deleted file mode 100644 index 3414d8b3087..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# my_default_python - -The 'my_default_python' project was generated by using the default-python template. - -* `src/`: Python source code for this project. - * `src/my_default_python/`: Shared Python code that can be used by jobs and pipelines. -* `resources/`: Resource configurations (jobs, pipelines, etc.) -* `tests/`: Unit tests for the shared Python code. -* `fixtures/`: Fixtures for data sets (primarily used for testing). - - -## Getting started - -Choose how you want to work on this project: - -(a) Directly in your Databricks workspace, see - https://docs.databricks.com/dev-tools/bundles/workspace. - -(b) Locally with an IDE like Cursor or VS Code, see - https://docs.databricks.com/dev-tools/vscode-ext.html. - -(c) With command line tools, see https://docs.databricks.com/dev-tools/cli/databricks-cli.html - -If you're developing with an IDE, dependencies for this project should be installed using uv: - -* Make sure you have the UV package manager installed. - It's an alternative to tools like pip: https://docs.astral.sh/uv/getting-started/installation/. -* Run `uv sync --dev` to install the project's dependencies. - - -# Using this project using the CLI - -The Databricks workspace and IDE extensions provide a graphical interface for working -with this project. It's also possible to interact with it directly using the CLI: - -1. Authenticate to your Databricks workspace, if you have not done so already: - ``` - $ databricks configure - ``` - -2. To deploy a development copy of this project, type: - ``` - $ databricks bundle deploy --target dev - ``` - (Note that "dev" is the default target, so the `--target` parameter - is optional here.) - - This deploys everything that's defined for this project. - For example, the default template would deploy a pipeline called - `[dev yourname] my_default_python_etl` to your workspace. - You can find that resource by opening your workpace and clicking on **Jobs & Pipelines**. - -3. Similarly, to deploy a production copy, type: - ``` - $ databricks bundle deploy --target prod - ``` - Note the default template has a includes a job that runs the pipeline every day - (defined in resources/sample_job.job.yml). The schedule - is paused when deploying in development mode (see - https://docs.databricks.com/dev-tools/bundles/deployment-modes.html). - -4. To run a job or pipeline, use the "run" command: - ``` - $ databricks bundle run - ``` - -5. Finally, to run tests locally, use `pytest`: - ``` - $ uv run pytest - ``` diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/databricks.yml b/acceptance/bundle/templates/default-python/classic/output/my_default_python/databricks.yml deleted file mode 100644 index d5abd8c8fa4..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/databricks.yml +++ /dev/null @@ -1,48 +0,0 @@ -# This is a Declarative Automation Bundle definition for my_default_python. -# See https://docs.databricks.com/dev-tools/bundles/index.html for documentation. -bundle: - name: my_default_python - uuid: [UUID] - -include: - - resources/*.yml - -artifacts: - python_artifact: - type: whl - build: uv build --wheel - -# Variable declarations. These variables are assigned in the dev/prod targets below. -variables: - catalog: - description: The catalog to use - schema: - description: The schema to use - -targets: - dev: - # The default target uses 'mode: development' to create a development copy. - # - Deployed resources get prefixed with '[dev my_user_name]' - # - Any job schedules and triggers are paused by default. - # See also https://docs.databricks.com/dev-tools/bundles/deployment-modes.html. - mode: development - default: true - workspace: - host: [DATABRICKS_URL] - variables: - catalog: hive_metastore - schema: ${workspace.current_user.short_name} - presets: - artifacts_dynamic_version: true - prod: - mode: production - workspace: - host: [DATABRICKS_URL] - # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. - root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} - variables: - catalog: hive_metastore - schema: prod - permissions: - - user_name: [USERNAME] - level: CAN_MANAGE diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/fixtures/.gitkeep b/acceptance/bundle/templates/default-python/classic/output/my_default_python/fixtures/.gitkeep deleted file mode 100644 index 77a906614cb..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/fixtures/.gitkeep +++ /dev/null @@ -1,9 +0,0 @@ -# Test fixtures directory - -Add JSON or CSV files here. In tests, use them with `load_fixture()`: - -``` -def test_using_fixture(load_fixture): - data = load_fixture("my_data.json") - assert len(data) >= 1 -``` diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/out.gitignore b/acceptance/bundle/templates/default-python/classic/output/my_default_python/out.gitignore deleted file mode 100644 index e566c51f740..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/out.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.databricks/ -build/ -dist/ -__pycache__/ -*.egg-info -.venv/ -scratch/** -!scratch/README.md -**/explorations/** -**/!explorations/README.md diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/pyproject.toml b/acceptance/bundle/templates/default-python/classic/output/my_default_python/pyproject.toml deleted file mode 100644 index e8bb641abd4..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/pyproject.toml +++ /dev/null @@ -1,31 +0,0 @@ -[project] -name = "my_default_python" -version = "0.0.1" -authors = [{ name = "[USERNAME]" }] -requires-python = ">=3.12,<3.13" -dependencies = [ - # Any dependencies for jobs and pipelines in this project can be added here - # See also https://docs.databricks.com/dev-tools/bundles/library-dependencies - # - # LIMITATION: for pipelines, dependencies are cached during development; - # add dependencies to the 'environment' section of your pipeline.yml file instead -] - -[dependency-groups] -dev = [ - "pytest", - "ruff", - "databricks-dlt", - "databricks-connect>=16.4,<16.5", - "ipykernel", -] - -[project.scripts] -main = "my_default_python.main:main" - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.ruff] -line-length = 120 diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/resources/my_default_python_etl.pipeline.yml b/acceptance/bundle/templates/default-python/classic/output/my_default_python/resources/my_default_python_etl.pipeline.yml deleted file mode 100644 index 896b271a0d5..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/resources/my_default_python_etl.pipeline.yml +++ /dev/null @@ -1,20 +0,0 @@ -# The main pipeline for my_default_python - -resources: - pipelines: - my_default_python_etl: - name: my_default_python_etl - ## Specify the 'catalog' field to configure this pipeline to make use of Unity Catalog: - # catalog: ${var.catalog} - schema: ${var.schema} - root_path: "../src/my_default_python_etl" - - libraries: - - glob: - include: ../src/my_default_python_etl/transformations/** - - environment: - dependencies: - # We include every dependency defined by pyproject.toml by defining an editable environment - # that points to the folder where pyproject.toml is deployed. - - --editable ${workspace.file_path} diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/resources/sample_job.job.yml b/acceptance/bundle/templates/default-python/classic/output/my_default_python/resources/sample_job.job.yml deleted file mode 100644 index 7f7289b632d..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/resources/sample_job.job.yml +++ /dev/null @@ -1,65 +0,0 @@ -# A sample job for my_default_python. - -resources: - jobs: - sample_job: - name: sample_job - - trigger: - # Run this job every day, exactly one day from the last run; see https://docs.databricks.com/api/workspace/jobs/create#trigger - periodic: - interval: 1 - unit: DAYS - - #email_notifications: - # on_failure: - # - your_email@example.com - - parameters: - - name: catalog - default: ${var.catalog} - - name: schema - default: ${var.schema} - - tasks: - - task_key: notebook_task - notebook_task: - notebook_path: ../src/sample_notebook.ipynb - job_cluster_key: job_cluster - libraries: - # By default we just include the .whl file generated for the my_default_python package. - # See https://docs.databricks.com/dev-tools/bundles/library-dependencies.html - # for more information on how to add other libraries. - - whl: ../dist/*.whl - - task_key: python_wheel_task - depends_on: - - task_key: notebook_task - python_wheel_task: - package_name: my_default_python - entry_point: main - parameters: - - "--catalog" - - "${var.catalog}" - - "--schema" - - "${var.schema}" - job_cluster_key: job_cluster - libraries: - # By default we just include the .whl file generated for the my_default_python package. - # See https://docs.databricks.com/dev-tools/bundles/library-dependencies.html - # for more information on how to add other libraries. - - whl: ../dist/*.whl - - task_key: refresh_pipeline - depends_on: - - task_key: notebook_task - pipeline_task: - pipeline_id: ${resources.pipelines.my_default_python_etl.id} - - job_clusters: - - job_cluster_key: job_cluster - new_cluster: - spark_version: 16.4.x-scala2.12 - node_type_id: [NODE_TYPE_ID] - data_security_mode: DATA_SECURITY_MODE_AUTO - autoscale: - min_workers: 1 - max_workers: 4 diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python/__init__.py b/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python/main.py b/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python/main.py deleted file mode 100644 index a1247306831..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python/main.py +++ /dev/null @@ -1,24 +0,0 @@ -import argparse -from databricks.sdk.runtime import spark -from my_default_python import taxis - - -def main(): - # Process command-line arguments - parser = argparse.ArgumentParser( - description="Databricks job with catalog and schema parameters", - ) - parser.add_argument("--catalog", required=True) - parser.add_argument("--schema", required=True) - args = parser.parse_args() - - # Set the default catalog and schema - spark.sql(f"USE CATALOG `{args.catalog}`") - spark.sql(f"USE SCHEMA `{args.schema}`") - - # Example: just find all taxis from a sample catalog - taxis.find_all_taxis().show(5) - - -if __name__ == "__main__": - main() diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python/taxis.py b/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python/taxis.py deleted file mode 100644 index a7309cd4c55..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python/taxis.py +++ /dev/null @@ -1,7 +0,0 @@ -from databricks.sdk.runtime import spark -from pyspark.sql import DataFrame - - -def find_all_taxis() -> DataFrame: - """Find all taxi data.""" - return spark.read.table("samples.nyctaxi.trips") diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python_etl/README.md b/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python_etl/README.md deleted file mode 100644 index 5b41468debe..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python_etl/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# my_default_python - -This folder defines all source code for the my_default_python pipeline: - -- `explorations/`: Ad-hoc notebooks used to explore the data processed by this pipeline. -- `transformations/`: All dataset definitions and transformations. -- `utilities/` (optional): Utility functions and Python modules used in this pipeline. -- `data_sources/` (optional): View definitions describing the source data for this pipeline. - -## Getting Started - -To get started, go to the `transformations` folder -- most of the relevant source code lives there: - -* By convention, every dataset under `transformations` is in a separate file. -* Take a look at the sample called "sample_trips_my_default_python.py" to get familiar with the syntax. - Read more about the syntax at https://docs.databricks.com/dlt/python-ref.html. -* If you're using the workspace UI, use `Run file` to run and preview a single transformation. -* If you're using the CLI, use `databricks bundle run my_default_python_etl --refresh sample_trips_my_default_python` to run a single transformation. - -For more tutorials and reference material, see https://docs.databricks.com/dlt. diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python_etl/explorations/sample_exploration.ipynb b/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python_etl/explorations/sample_exploration.ipynb deleted file mode 100644 index e326a351690..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python_etl/explorations/sample_exploration.ipynb +++ /dev/null @@ -1,63 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "application/vnd.databricks.v1+cell": { - "cellMetadata": {}, - "inputWidgets": {}, - "nuid": "[UUID]", - "showTitle": false, - "tableResultSettingsMap": {}, - "title": "" - } - }, - "source": [ - "### Example Exploratory Notebook\n", - "\n", - "Use this notebook to explore the data generated by the pipeline in your preferred programming language.\n", - "\n", - "**Note**: This notebook is not executed as part of the pipeline." - ] - }, - { - "cell_type": "code", - "execution_count": 0, - "metadata": { - "application/vnd.databricks.v1+cell": { - "cellMetadata": {}, - "inputWidgets": {}, - "nuid": "[UUID]", - "showTitle": false, - "tableResultSettingsMap": {}, - "title": "" - } - }, - "outputs": [], - "source": [ - "# !!! Before performing any data analysis, make sure to run the pipeline to materialize the sample datasets. The tables referenced in this notebook depend on that step.\n", - "\n", - "display(spark.sql(\"SELECT * FROM hive_metastore.[USERNAME].sample_trips_my_default_python\"))" - ] - } - ], - "metadata": { - "application/vnd.databricks.v1+notebook": { - "computePreferences": null, - "dashboards": [], - "environmentMetadata": null, - "inputWidgetPreferences": null, - "language": "python", - "notebookMetadata": { - "pythonIndentUnit": 2 - }, - "notebookName": "sample_exploration", - "widgets": {} - }, - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python_etl/transformations/sample_trips_my_default_python.py b/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python_etl/transformations/sample_trips_my_default_python.py deleted file mode 100644 index eb18701f085..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python_etl/transformations/sample_trips_my_default_python.py +++ /dev/null @@ -1,12 +0,0 @@ -from pyspark import pipelines as dp -from pyspark.sql.functions import col - - -# This file defines a sample transformation. -# Edit the sample below or add new transformations -# using "+ Add" in the file browser. - - -@dp.table -def sample_trips_my_default_python(): - return spark.read.table("samples.nyctaxi.trips") diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python_etl/transformations/sample_zones_my_default_python.py b/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python_etl/transformations/sample_zones_my_default_python.py deleted file mode 100644 index a9282b4dcc0..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/my_default_python_etl/transformations/sample_zones_my_default_python.py +++ /dev/null @@ -1,17 +0,0 @@ -from pyspark import pipelines as dp -from pyspark.sql.functions import col, sum - - -# This file defines a sample transformation. -# Edit the sample below or add new transformations -# using "+ Add" in the file browser. - - -@dp.table -def sample_zones_my_default_python(): - # Read from the "sample_trips" table, then sum all the fares - return ( - spark.read.table(f"sample_trips_my_default_python") - .groupBy(col("pickup_zip")) - .agg(sum("fare_amount").alias("total_fare")) - ) diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/sample_notebook.ipynb b/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/sample_notebook.ipynb deleted file mode 100644 index ea9c0a8404a..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/src/sample_notebook.ipynb +++ /dev/null @@ -1,149 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "application/vnd.databricks.v1+cell": { - "cellMetadata": {}, - "inputWidgets": {}, - "nuid": "[UUID]", - "showTitle": false, - "title": "" - } - }, - "source": [ - "# Default notebook\n", - "\n", - "This default notebook is executed using a Lakeflow job as defined in resources/sample_job.job.yml." - ] - }, - { - "cell_type": "code", - "execution_count": 0, - "metadata": { - "application/vnd.databricks.v1+cell": { - "cellMetadata": {}, - "inputWidgets": {}, - "nuid": "[UUID]", - "showTitle": false, - "title": "" - } - }, - "outputs": [], - "source": [ - "# Set default catalog and schema\n", - "catalog = dbutils.widgets.get(\"catalog\")\n", - "schema = dbutils.widgets.get(\"schema\")\n", - "spark.sql(f\"USE CATALOG `{catalog}`\")\n", - "spark.sql(f\"USE SCHEMA `{schema}`\")" - ] - }, - { - "cell_type": "code", - "execution_count": 0, - "metadata": { - "application/vnd.databricks.v1+cell": { - "cellMetadata": { - "byteLimit": 2048000, - "rowLimit": 10000 - }, - "inputWidgets": {}, - "nuid": "[UUID]", - "showTitle": false, - "title": "" - } - }, - "outputs": [], - "source": [ - "import sys\n", - "\n", - "sys.path.append(\"../src\")\n", - "from my_default_python import taxis\n", - "\n", - "taxis.find_all_taxis().show(10)" - ] - } - ], - "metadata": { - "application/vnd.databricks.v1+notebook": { - "dashboards": [], - "environmentMetadata": { - "base_environment": "", - "dependencies": [ - "--editable .." - ], - "environment_version": "5" - }, - "language": "python", - "notebookMetadata": { - "pythonIndentUnit": 2 - }, - "notebookName": "notebook", - "widgets": { - "catalog": { - "currentValue": "hive_metastore", - "nuid": "c4t4l0g-w1dg-3t12-3456-789012345678", - "typedWidgetInfo": { - "autoCreated": false, - "defaultValue": "hive_metastore", - "label": "Catalog", - "name": "catalog", - "options": { - "validationRegex": null, - "widgetDisplayType": "Text" - }, - "parameterDataType": "String" - }, - "widgetInfo": { - "defaultValue": "hive_metastore", - "label": "Catalog", - "name": "catalog", - "options": { - "autoCreated": false, - "validationRegex": null, - "widgetType": "text" - }, - "widgetType": "text" - } - }, - "schema": { - "currentValue": "[USERNAME]", - "nuid": "5ch3m4-w1dg-3t98-7654-321098765432", - "typedWidgetInfo": { - "autoCreated": false, - "defaultValue": "default", - "label": "Schema", - "name": "schema", - "options": { - "validationRegex": null, - "widgetDisplayType": "Text" - }, - "parameterDataType": "String" - }, - "widgetInfo": { - "defaultValue": "default", - "label": "Schema", - "name": "schema", - "options": { - "autoCreated": false, - "validationRegex": null, - "widgetType": "text" - }, - "widgetType": "text" - } - } - } - }, - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/tests/conftest.py b/acceptance/bundle/templates/default-python/classic/output/my_default_python/tests/conftest.py deleted file mode 100644 index 72ebfeb5666..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/tests/conftest.py +++ /dev/null @@ -1,94 +0,0 @@ -"""This file configures pytest, initializes Databricks Connect, and provides fixtures for Spark and loading test data.""" - -import os, sys, pathlib -from contextlib import contextmanager - - -try: - from databricks.connect import DatabricksSession - from databricks.sdk import WorkspaceClient - from pyspark.sql import SparkSession - import pytest - import json - import csv - import os -except ImportError: - raise ImportError( - "Test dependencies not found.\n\nRun tests using 'uv run pytest'. See http://docs.astral.sh/uv to learn more about uv." - ) - - -@pytest.fixture() -def spark() -> SparkSession: - """Provide a SparkSession fixture for tests. - - Minimal example: - def test_uses_spark(spark): - df = spark.createDataFrame([(1,)], ["x"]) - assert df.count() == 1 - """ - return DatabricksSession.builder.getOrCreate() - - -@pytest.fixture() -def load_fixture(spark: SparkSession): - """Provide a callable to load JSON or CSV from fixtures/ directory. - - Example usage: - - def test_using_fixture(load_fixture): - data = load_fixture("my_data.json") - assert data.count() >= 1 - """ - - def _loader(filename: str): - path = pathlib.Path(__file__).parent.parent / "fixtures" / filename - suffix = path.suffix.lower() - if suffix == ".json": - rows = json.loads(path.read_text()) - return spark.createDataFrame(rows) - if suffix == ".csv": - with path.open(newline="") as f: - rows = list(csv.DictReader(f)) - return spark.createDataFrame(rows) - raise ValueError(f"Unsupported fixture type for: {filename}") - - return _loader - - -def _enable_fallback_compute(): - """Enable serverless compute if no compute is specified.""" - conf = WorkspaceClient().config - if conf.serverless_compute_id or conf.cluster_id or os.environ.get("SPARK_REMOTE"): - return - - url = "https://docs.databricks.com/dev-tools/databricks-connect/cluster-config" - print("☁️ no compute specified, falling back to serverless compute", file=sys.stderr) - print(f" see {url} for manual configuration", file=sys.stdout) - - os.environ["DATABRICKS_SERVERLESS_COMPUTE_ID"] = "auto" - - -@contextmanager -def _allow_stderr_output(config: pytest.Config): - """Temporarily disable pytest output capture.""" - capman = config.pluginmanager.get_plugin("capturemanager") - if capman: - with capman.global_and_fixture_disabled(): - yield - else: - yield - - -def pytest_configure(config: pytest.Config): - """Configure pytest session.""" - with _allow_stderr_output(config): - _enable_fallback_compute() - - # Initialize Spark session eagerly, so it is available even when - # SparkSession.builder.getOrCreate() is used. For DB Connect 15+, - # we validate version compatibility with the remote cluster. - if hasattr(DatabricksSession.builder, "validateSession"): - DatabricksSession.builder.validateSession().getOrCreate() - else: - DatabricksSession.builder.getOrCreate() diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/tests/sample_taxis_test.py b/acceptance/bundle/templates/default-python/classic/output/my_default_python/tests/sample_taxis_test.py deleted file mode 100644 index e503dd2b2ca..00000000000 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/tests/sample_taxis_test.py +++ /dev/null @@ -1,8 +0,0 @@ -from databricks.sdk.runtime import spark -from pyspark.sql import DataFrame -from my_default_python import taxis - - -def test_find_all_taxis(): - results = taxis.find_all_taxis() - assert results.count() > 5 diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/.vscode/__builtins__.pyi b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/.vscode/__builtins__.pyi deleted file mode 100644 index 0edd5181bc5..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/.vscode/__builtins__.pyi +++ /dev/null @@ -1,3 +0,0 @@ -# Typings for Pylance in Visual Studio Code -# see https://github.com/microsoft/pyright/blob/main/docs/builtins.md -from databricks.sdk.runtime import * diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/.vscode/extensions.json b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/.vscode/extensions.json deleted file mode 100644 index b958aacfcb4..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/.vscode/extensions.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "recommendations": [ - "charliermarsh.ruff", - "databricks.databricks", - "redhat.vscode-yaml" - ] -} diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/.vscode/settings.json b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/.vscode/settings.json deleted file mode 100644 index d73c73b5705..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/.vscode/settings.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "jupyter.interactiveWindow.cellMarker.codeRegex": "^# COMMAND ----------|^# Databricks notebook source|^(#\\s*%%|#\\s*\\|#\\s*In\\[\\d*?\\]|#\\s*In\\[ \\])", - "jupyter.interactiveWindow.cellMarker.default": "# COMMAND ----------", - "python.testing.pytestArgs": [ - "." - ], - "files.exclude": { - "**/*.egg-info": true, - "**/__pycache__": true, - ".pytest_cache": true, - "dist": true, - }, - "files.associations": { - "**/.gitkeep": "markdown" - }, - - // Pylance settings (VS Code) - // Set typeCheckingMode to "basic" to enable type checking! - "python.analysis.typeCheckingMode": "off", - "python.analysis.extraPaths": ["src", "lib", "resources"], - "python.analysis.diagnosticMode": "workspace", - "python.analysis.stubPath": ".vscode", - - // Pyright settings (Cursor) - // Set typeCheckingMode to "basic" to enable type checking! - "cursorpyright.analysis.typeCheckingMode": "off", - "cursorpyright.analysis.extraPaths": ["src", "lib", "resources"], - "cursorpyright.analysis.diagnosticMode": "workspace", - "cursorpyright.analysis.stubPath": ".vscode", - - // General Python settings - "python.defaultInterpreterPath": "./.venv/bin/python", - "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true, - "[python]": { - "editor.defaultFormatter": "charliermarsh.ruff", - "editor.formatOnSave": true, - }, -} diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/AGENTS.md b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/AGENTS.md deleted file mode 100644 index fdcca98a432..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/AGENTS.md +++ /dev/null @@ -1,25 +0,0 @@ -# Declarative Automation Bundles Project - -This project uses Declarative Automation Bundles (DABs) for deployment. Add project-specific instructions below. - -## For AI Agents: Use Databricks AI Tools - -**BEFORE any other action, read the `databricks-core` skill.** - -It sets you up to work with this project reliably: CLI authentication, profile -selection, data discovery, and the bundle deployment workflow. Without it, -results are often slower and less accurate. - -If this skill is not available (Databricks AI Tools are not installed), you can install them for your coding agent in seconds: - -```bash -databricks aitools install -``` - -If the CLI is not installed, see: https://docs.databricks.com/dev-tools/cli/install - ---- - -## Project Instructions - - diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/README.md b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/README.md deleted file mode 100644 index 3414d8b3087..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# my_default_python - -The 'my_default_python' project was generated by using the default-python template. - -* `src/`: Python source code for this project. - * `src/my_default_python/`: Shared Python code that can be used by jobs and pipelines. -* `resources/`: Resource configurations (jobs, pipelines, etc.) -* `tests/`: Unit tests for the shared Python code. -* `fixtures/`: Fixtures for data sets (primarily used for testing). - - -## Getting started - -Choose how you want to work on this project: - -(a) Directly in your Databricks workspace, see - https://docs.databricks.com/dev-tools/bundles/workspace. - -(b) Locally with an IDE like Cursor or VS Code, see - https://docs.databricks.com/dev-tools/vscode-ext.html. - -(c) With command line tools, see https://docs.databricks.com/dev-tools/cli/databricks-cli.html - -If you're developing with an IDE, dependencies for this project should be installed using uv: - -* Make sure you have the UV package manager installed. - It's an alternative to tools like pip: https://docs.astral.sh/uv/getting-started/installation/. -* Run `uv sync --dev` to install the project's dependencies. - - -# Using this project using the CLI - -The Databricks workspace and IDE extensions provide a graphical interface for working -with this project. It's also possible to interact with it directly using the CLI: - -1. Authenticate to your Databricks workspace, if you have not done so already: - ``` - $ databricks configure - ``` - -2. To deploy a development copy of this project, type: - ``` - $ databricks bundle deploy --target dev - ``` - (Note that "dev" is the default target, so the `--target` parameter - is optional here.) - - This deploys everything that's defined for this project. - For example, the default template would deploy a pipeline called - `[dev yourname] my_default_python_etl` to your workspace. - You can find that resource by opening your workpace and clicking on **Jobs & Pipelines**. - -3. Similarly, to deploy a production copy, type: - ``` - $ databricks bundle deploy --target prod - ``` - Note the default template has a includes a job that runs the pipeline every day - (defined in resources/sample_job.job.yml). The schedule - is paused when deploying in development mode (see - https://docs.databricks.com/dev-tools/bundles/deployment-modes.html). - -4. To run a job or pipeline, use the "run" command: - ``` - $ databricks bundle run - ``` - -5. Finally, to run tests locally, use `pytest`: - ``` - $ uv run pytest - ``` diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/databricks.yml b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/databricks.yml deleted file mode 100644 index b8ad3140314..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/databricks.yml +++ /dev/null @@ -1,46 +0,0 @@ -# This is a Declarative Automation Bundle definition for my_default_python. -# See https://docs.databricks.com/dev-tools/bundles/index.html for documentation. -bundle: - name: my_default_python - uuid: [UUID] - -include: - - resources/*.yml - -artifacts: - python_artifact: - type: whl - build: uv build --wheel - -# Variable declarations. These variables are assigned in the dev/prod targets below. -variables: - catalog: - description: The catalog to use - schema: - description: The schema to use - -targets: - dev: - # The default target uses 'mode: development' to create a development copy. - # - Deployed resources get prefixed with '[dev my_user_name]' - # - Any job schedules and triggers are paused by default. - # See also https://docs.databricks.com/dev-tools/bundles/deployment-modes.html. - mode: development - default: true - workspace: - host: [DATABRICKS_URL] - variables: - catalog: hive_metastore - schema: ${workspace.current_user.short_name} - prod: - mode: production - workspace: - host: [DATABRICKS_URL] - # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. - root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} - variables: - catalog: hive_metastore - schema: prod - permissions: - - user_name: [USERNAME] - level: CAN_MANAGE diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/fixtures/.gitkeep b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/fixtures/.gitkeep deleted file mode 100644 index 77a906614cb..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/fixtures/.gitkeep +++ /dev/null @@ -1,9 +0,0 @@ -# Test fixtures directory - -Add JSON or CSV files here. In tests, use them with `load_fixture()`: - -``` -def test_using_fixture(load_fixture): - data = load_fixture("my_data.json") - assert len(data) >= 1 -``` diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/out.gitignore b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/out.gitignore deleted file mode 100644 index e566c51f740..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/out.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.databricks/ -build/ -dist/ -__pycache__/ -*.egg-info -.venv/ -scratch/** -!scratch/README.md -**/explorations/** -**/!explorations/README.md diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/pyproject.toml b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/pyproject.toml deleted file mode 100644 index e8bb641abd4..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/pyproject.toml +++ /dev/null @@ -1,31 +0,0 @@ -[project] -name = "my_default_python" -version = "0.0.1" -authors = [{ name = "[USERNAME]" }] -requires-python = ">=3.12,<3.13" -dependencies = [ - # Any dependencies for jobs and pipelines in this project can be added here - # See also https://docs.databricks.com/dev-tools/bundles/library-dependencies - # - # LIMITATION: for pipelines, dependencies are cached during development; - # add dependencies to the 'environment' section of your pipeline.yml file instead -] - -[dependency-groups] -dev = [ - "pytest", - "ruff", - "databricks-dlt", - "databricks-connect>=16.4,<16.5", - "ipykernel", -] - -[project.scripts] -main = "my_default_python.main:main" - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.ruff] -line-length = 120 diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/resources/my_default_python_etl.pipeline.yml b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/resources/my_default_python_etl.pipeline.yml deleted file mode 100644 index 3d6ad105c7c..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/resources/my_default_python_etl.pipeline.yml +++ /dev/null @@ -1,21 +0,0 @@ -# The main pipeline for my_default_python - -resources: - pipelines: - my_default_python_etl: - name: my_default_python_etl - # Catalog is required for serverless compute - catalog: main - schema: ${var.schema} - serverless: true - root_path: "../src/my_default_python_etl" - - libraries: - - glob: - include: ../src/my_default_python_etl/transformations/** - - environment: - dependencies: - # We include every dependency defined by pyproject.toml by defining an editable environment - # that points to the folder where pyproject.toml is deployed. - - --editable ${workspace.file_path} diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/resources/sample_job.job.yml b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/resources/sample_job.job.yml deleted file mode 100644 index 16716edb640..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/resources/sample_job.job.yml +++ /dev/null @@ -1,54 +0,0 @@ -# A sample job for my_default_python. - -resources: - jobs: - sample_job: - name: sample_job - - trigger: - # Run this job every day, exactly one day from the last run; see https://docs.databricks.com/api/workspace/jobs/create#trigger - periodic: - interval: 1 - unit: DAYS - - #email_notifications: - # on_failure: - # - your_email@example.com - - parameters: - - name: catalog - default: ${var.catalog} - - name: schema - default: ${var.schema} - - tasks: - - task_key: notebook_task - notebook_task: - notebook_path: ../src/sample_notebook.ipynb - - task_key: python_wheel_task - depends_on: - - task_key: notebook_task - python_wheel_task: - package_name: my_default_python - entry_point: main - parameters: - - "--catalog" - - "${var.catalog}" - - "--schema" - - "${var.schema}" - environment_key: default - - task_key: refresh_pipeline - depends_on: - - task_key: notebook_task - pipeline_task: - pipeline_id: ${resources.pipelines.my_default_python_etl.id} - - environments: - - environment_key: default - spec: - environment_version: "5" - dependencies: - # By default we just include the .whl file generated for the my_default_python package. - # See https://docs.databricks.com/dev-tools/bundles/library-dependencies.html - # for more information on how to add other libraries. - - ../dist/*.whl diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python/__init__.py b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python/main.py b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python/main.py deleted file mode 100644 index a1247306831..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python/main.py +++ /dev/null @@ -1,24 +0,0 @@ -import argparse -from databricks.sdk.runtime import spark -from my_default_python import taxis - - -def main(): - # Process command-line arguments - parser = argparse.ArgumentParser( - description="Databricks job with catalog and schema parameters", - ) - parser.add_argument("--catalog", required=True) - parser.add_argument("--schema", required=True) - args = parser.parse_args() - - # Set the default catalog and schema - spark.sql(f"USE CATALOG `{args.catalog}`") - spark.sql(f"USE SCHEMA `{args.schema}`") - - # Example: just find all taxis from a sample catalog - taxis.find_all_taxis().show(5) - - -if __name__ == "__main__": - main() diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python/taxis.py b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python/taxis.py deleted file mode 100644 index a7309cd4c55..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python/taxis.py +++ /dev/null @@ -1,7 +0,0 @@ -from databricks.sdk.runtime import spark -from pyspark.sql import DataFrame - - -def find_all_taxis() -> DataFrame: - """Find all taxi data.""" - return spark.read.table("samples.nyctaxi.trips") diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python_etl/README.md b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python_etl/README.md deleted file mode 100644 index 5b41468debe..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python_etl/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# my_default_python - -This folder defines all source code for the my_default_python pipeline: - -- `explorations/`: Ad-hoc notebooks used to explore the data processed by this pipeline. -- `transformations/`: All dataset definitions and transformations. -- `utilities/` (optional): Utility functions and Python modules used in this pipeline. -- `data_sources/` (optional): View definitions describing the source data for this pipeline. - -## Getting Started - -To get started, go to the `transformations` folder -- most of the relevant source code lives there: - -* By convention, every dataset under `transformations` is in a separate file. -* Take a look at the sample called "sample_trips_my_default_python.py" to get familiar with the syntax. - Read more about the syntax at https://docs.databricks.com/dlt/python-ref.html. -* If you're using the workspace UI, use `Run file` to run and preview a single transformation. -* If you're using the CLI, use `databricks bundle run my_default_python_etl --refresh sample_trips_my_default_python` to run a single transformation. - -For more tutorials and reference material, see https://docs.databricks.com/dlt. diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python_etl/explorations/sample_exploration.ipynb b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python_etl/explorations/sample_exploration.ipynb deleted file mode 100644 index e326a351690..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python_etl/explorations/sample_exploration.ipynb +++ /dev/null @@ -1,63 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "application/vnd.databricks.v1+cell": { - "cellMetadata": {}, - "inputWidgets": {}, - "nuid": "[UUID]", - "showTitle": false, - "tableResultSettingsMap": {}, - "title": "" - } - }, - "source": [ - "### Example Exploratory Notebook\n", - "\n", - "Use this notebook to explore the data generated by the pipeline in your preferred programming language.\n", - "\n", - "**Note**: This notebook is not executed as part of the pipeline." - ] - }, - { - "cell_type": "code", - "execution_count": 0, - "metadata": { - "application/vnd.databricks.v1+cell": { - "cellMetadata": {}, - "inputWidgets": {}, - "nuid": "[UUID]", - "showTitle": false, - "tableResultSettingsMap": {}, - "title": "" - } - }, - "outputs": [], - "source": [ - "# !!! Before performing any data analysis, make sure to run the pipeline to materialize the sample datasets. The tables referenced in this notebook depend on that step.\n", - "\n", - "display(spark.sql(\"SELECT * FROM hive_metastore.[USERNAME].sample_trips_my_default_python\"))" - ] - } - ], - "metadata": { - "application/vnd.databricks.v1+notebook": { - "computePreferences": null, - "dashboards": [], - "environmentMetadata": null, - "inputWidgetPreferences": null, - "language": "python", - "notebookMetadata": { - "pythonIndentUnit": 2 - }, - "notebookName": "sample_exploration", - "widgets": {} - }, - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python_etl/transformations/sample_trips_my_default_python.py b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python_etl/transformations/sample_trips_my_default_python.py deleted file mode 100644 index eb18701f085..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python_etl/transformations/sample_trips_my_default_python.py +++ /dev/null @@ -1,12 +0,0 @@ -from pyspark import pipelines as dp -from pyspark.sql.functions import col - - -# This file defines a sample transformation. -# Edit the sample below or add new transformations -# using "+ Add" in the file browser. - - -@dp.table -def sample_trips_my_default_python(): - return spark.read.table("samples.nyctaxi.trips") diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python_etl/transformations/sample_zones_my_default_python.py b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python_etl/transformations/sample_zones_my_default_python.py deleted file mode 100644 index a9282b4dcc0..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/my_default_python_etl/transformations/sample_zones_my_default_python.py +++ /dev/null @@ -1,17 +0,0 @@ -from pyspark import pipelines as dp -from pyspark.sql.functions import col, sum - - -# This file defines a sample transformation. -# Edit the sample below or add new transformations -# using "+ Add" in the file browser. - - -@dp.table -def sample_zones_my_default_python(): - # Read from the "sample_trips" table, then sum all the fares - return ( - spark.read.table(f"sample_trips_my_default_python") - .groupBy(col("pickup_zip")) - .agg(sum("fare_amount").alias("total_fare")) - ) diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/sample_notebook.ipynb b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/sample_notebook.ipynb deleted file mode 100644 index ea9c0a8404a..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/src/sample_notebook.ipynb +++ /dev/null @@ -1,149 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "application/vnd.databricks.v1+cell": { - "cellMetadata": {}, - "inputWidgets": {}, - "nuid": "[UUID]", - "showTitle": false, - "title": "" - } - }, - "source": [ - "# Default notebook\n", - "\n", - "This default notebook is executed using a Lakeflow job as defined in resources/sample_job.job.yml." - ] - }, - { - "cell_type": "code", - "execution_count": 0, - "metadata": { - "application/vnd.databricks.v1+cell": { - "cellMetadata": {}, - "inputWidgets": {}, - "nuid": "[UUID]", - "showTitle": false, - "title": "" - } - }, - "outputs": [], - "source": [ - "# Set default catalog and schema\n", - "catalog = dbutils.widgets.get(\"catalog\")\n", - "schema = dbutils.widgets.get(\"schema\")\n", - "spark.sql(f\"USE CATALOG `{catalog}`\")\n", - "spark.sql(f\"USE SCHEMA `{schema}`\")" - ] - }, - { - "cell_type": "code", - "execution_count": 0, - "metadata": { - "application/vnd.databricks.v1+cell": { - "cellMetadata": { - "byteLimit": 2048000, - "rowLimit": 10000 - }, - "inputWidgets": {}, - "nuid": "[UUID]", - "showTitle": false, - "title": "" - } - }, - "outputs": [], - "source": [ - "import sys\n", - "\n", - "sys.path.append(\"../src\")\n", - "from my_default_python import taxis\n", - "\n", - "taxis.find_all_taxis().show(10)" - ] - } - ], - "metadata": { - "application/vnd.databricks.v1+notebook": { - "dashboards": [], - "environmentMetadata": { - "base_environment": "", - "dependencies": [ - "--editable .." - ], - "environment_version": "5" - }, - "language": "python", - "notebookMetadata": { - "pythonIndentUnit": 2 - }, - "notebookName": "notebook", - "widgets": { - "catalog": { - "currentValue": "hive_metastore", - "nuid": "c4t4l0g-w1dg-3t12-3456-789012345678", - "typedWidgetInfo": { - "autoCreated": false, - "defaultValue": "hive_metastore", - "label": "Catalog", - "name": "catalog", - "options": { - "validationRegex": null, - "widgetDisplayType": "Text" - }, - "parameterDataType": "String" - }, - "widgetInfo": { - "defaultValue": "hive_metastore", - "label": "Catalog", - "name": "catalog", - "options": { - "autoCreated": false, - "validationRegex": null, - "widgetType": "text" - }, - "widgetType": "text" - } - }, - "schema": { - "currentValue": "[USERNAME]", - "nuid": "5ch3m4-w1dg-3t98-7654-321098765432", - "typedWidgetInfo": { - "autoCreated": false, - "defaultValue": "default", - "label": "Schema", - "name": "schema", - "options": { - "validationRegex": null, - "widgetDisplayType": "Text" - }, - "parameterDataType": "String" - }, - "widgetInfo": { - "defaultValue": "default", - "label": "Schema", - "name": "schema", - "options": { - "autoCreated": false, - "validationRegex": null, - "widgetType": "text" - }, - "widgetType": "text" - } - } - } - }, - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/tests/conftest.py b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/tests/conftest.py deleted file mode 100644 index 72ebfeb5666..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/tests/conftest.py +++ /dev/null @@ -1,94 +0,0 @@ -"""This file configures pytest, initializes Databricks Connect, and provides fixtures for Spark and loading test data.""" - -import os, sys, pathlib -from contextlib import contextmanager - - -try: - from databricks.connect import DatabricksSession - from databricks.sdk import WorkspaceClient - from pyspark.sql import SparkSession - import pytest - import json - import csv - import os -except ImportError: - raise ImportError( - "Test dependencies not found.\n\nRun tests using 'uv run pytest'. See http://docs.astral.sh/uv to learn more about uv." - ) - - -@pytest.fixture() -def spark() -> SparkSession: - """Provide a SparkSession fixture for tests. - - Minimal example: - def test_uses_spark(spark): - df = spark.createDataFrame([(1,)], ["x"]) - assert df.count() == 1 - """ - return DatabricksSession.builder.getOrCreate() - - -@pytest.fixture() -def load_fixture(spark: SparkSession): - """Provide a callable to load JSON or CSV from fixtures/ directory. - - Example usage: - - def test_using_fixture(load_fixture): - data = load_fixture("my_data.json") - assert data.count() >= 1 - """ - - def _loader(filename: str): - path = pathlib.Path(__file__).parent.parent / "fixtures" / filename - suffix = path.suffix.lower() - if suffix == ".json": - rows = json.loads(path.read_text()) - return spark.createDataFrame(rows) - if suffix == ".csv": - with path.open(newline="") as f: - rows = list(csv.DictReader(f)) - return spark.createDataFrame(rows) - raise ValueError(f"Unsupported fixture type for: {filename}") - - return _loader - - -def _enable_fallback_compute(): - """Enable serverless compute if no compute is specified.""" - conf = WorkspaceClient().config - if conf.serverless_compute_id or conf.cluster_id or os.environ.get("SPARK_REMOTE"): - return - - url = "https://docs.databricks.com/dev-tools/databricks-connect/cluster-config" - print("☁️ no compute specified, falling back to serverless compute", file=sys.stderr) - print(f" see {url} for manual configuration", file=sys.stdout) - - os.environ["DATABRICKS_SERVERLESS_COMPUTE_ID"] = "auto" - - -@contextmanager -def _allow_stderr_output(config: pytest.Config): - """Temporarily disable pytest output capture.""" - capman = config.pluginmanager.get_plugin("capturemanager") - if capman: - with capman.global_and_fixture_disabled(): - yield - else: - yield - - -def pytest_configure(config: pytest.Config): - """Configure pytest session.""" - with _allow_stderr_output(config): - _enable_fallback_compute() - - # Initialize Spark session eagerly, so it is available even when - # SparkSession.builder.getOrCreate() is used. For DB Connect 15+, - # we validate version compatibility with the remote cluster. - if hasattr(DatabricksSession.builder, "validateSession"): - DatabricksSession.builder.validateSession().getOrCreate() - else: - DatabricksSession.builder.getOrCreate() diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/tests/sample_taxis_test.py b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/tests/sample_taxis_test.py deleted file mode 100644 index e503dd2b2ca..00000000000 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/tests/sample_taxis_test.py +++ /dev/null @@ -1,8 +0,0 @@ -from databricks.sdk.runtime import spark -from pyspark.sql import DataFrame -from my_default_python import taxis - - -def test_find_all_taxis(): - results = taxis.find_all_taxis() - assert results.count() > 5 diff --git a/acceptance/bundle/validate/empty_tasks/output.txt b/acceptance/bundle/validate/empty_tasks/output.txt index 36e6a7e63a8..7a8fcd95b9e 100644 --- a/acceptance/bundle/validate/empty_tasks/output.txt +++ b/acceptance/bundle/validate/empty_tasks/output.txt @@ -12,8 +12,7 @@ "name": "job with empty tasks", "queue": { "enabled": true - }, - "tasks": null + } }, "valid": { "deployment": { diff --git a/acceptance/bundle/validate/required/output.txt b/acceptance/bundle/validate/required/output.txt index ae3e6dad2f8..0c55c9cdb78 100644 --- a/acceptance/bundle/validate/required/output.txt +++ b/acceptance/bundle/validate/required/output.txt @@ -4,10 +4,6 @@ Warning: required field "catalog_name" is not set at resources.volumes.my_volume in databricks.yml:35:7 -Warning: required field "job_id" is not set - at resources.jobs.my_job_1.tasks[1].run_job_task - in databricks.yml:29:24 - Warning: required field "name" is not set at resources.models.my_model_1 in databricks.yml:13:7 @@ -26,4 +22,4 @@ Workspace: User: [USERNAME] Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default -Found 5 warnings +Found 4 warnings diff --git a/acceptance/bundle/variables/host/output.txt b/acceptance/bundle/variables/host/output.txt index 21bd93961b3..d6363c95031 100644 --- a/acceptance/bundle/variables/host/output.txt +++ b/acceptance/bundle/variables/host/output.txt @@ -8,7 +8,7 @@ Warning: Variable interpolation is not supported for fields that configure authe Interpolation is not supported for the field workspace.host. Please set the DATABRICKS_HOST environment variable if you wish to configure this field at runtime. -Error: failed during request visitor: parse "https://${var.host}": invalid character "{" in host name +Error: parse "https://${var.host}": invalid character "{" in host name { "bundle": { @@ -42,7 +42,7 @@ Warning: Variable interpolation is not supported for fields that configure authe Interpolation is not supported for the field workspace.host. Please set the DATABRICKS_HOST environment variable if you wish to configure this field at runtime. -Error: failed during request visitor: parse "https://${var.host}": invalid character "{" in host name +Error: parse "https://${var.host}": invalid character "{" in host name Name: host Target: default @@ -62,7 +62,7 @@ Warning: Variable interpolation is not supported for fields that configure authe Interpolation is not supported for the field workspace.host. Please set the DATABRICKS_HOST environment variable if you wish to configure this field at runtime. -Error: failed during request visitor: parse "https://${var.host}": invalid character "{" in host name +Error: parse "https://${var.host}": invalid character "{" in host name Exit code: 1 diff --git a/acceptance/cleanup/main.go b/acceptance/cleanup/main.go index 3dd70824332..dd58b0460a3 100644 --- a/acceptance/cleanup/main.go +++ b/acceptance/cleanup/main.go @@ -6,7 +6,6 @@ package main import ( "context" - "errors" "flag" "fmt" "os" @@ -19,12 +18,14 @@ import ( "sync" "time" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/iamutil" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/workspaceapi" + "github.com/databricks/databricks-sdk-go/config" ) // ciRunID matches a valid GITHUB_RUN_ID (same cap as acceptance_test.go). @@ -56,7 +57,7 @@ func main() { func cleanBundles(ctx context.Context, execPath, prefix string) error { start := time.Now() - w, err := databricks.NewWorkspaceClient() + w, err := sdkclients.New(ctx, &config.Config{}) if err != nil { return fmt.Errorf("cannot create workspace client: %w", err) } @@ -71,8 +72,8 @@ func cleanBundles(ctx context.Context, execPath, prefix string) error { // so sweep both. A "/Shared/..." root_path is normalized to "/Workspace/Shared/..." // by prependWorkspacePrefix, so the swept path uses that form. bundleRoots := []string{ - "/Workspace/Users/" + me.UserName + "/.bundle", - "/Workspace/Shared/" + me.UserName + "/.bundle", + "/Workspace/Users/" + utils.Deref(me.UserName) + "/.bundle", + "/Workspace/Shared/" + utils.Deref(me.UserName) + "/.bundle", } // The run's prefix always appears in the first path segment under .bundle @@ -131,7 +132,7 @@ func cleanBundles(ctx context.Context, execPath, prefix string) error { // a "state" or "files" child, which the bundle deploy writes beneath the // resolved workspace.root_path. This works regardless of whether the root is // the default ~/.bundle// or a custom ~/.bundle/<...> override. -func findDeploymentRoots(ctx context.Context, w *databricks.WorkspaceClient, dir string) []string { +func findDeploymentRoots(ctx context.Context, w *sdkclients.Clients, dir string) []string { var childDirs []string for _, child := range listChildDirs(ctx, w, dir) { if base := path.Base(child); base == "state" || base == "files" { @@ -151,17 +152,17 @@ func findDeploymentRoots(ctx context.Context, w *databricks.WorkspaceClient, dir // listChildDirs returns the immediate subdirectory paths of dir. A missing dir // (nothing was deployed under it) yields nil silently; any other listing error // is logged loudly but does not stop the overall sweep. -func listChildDirs(ctx context.Context, w *databricks.WorkspaceClient, dir string) []string { - objects, err := w.Workspace.ListAll(ctx, workspace.ListWorkspaceRequest{Path: dir}) +func listChildDirs(ctx context.Context, w *sdkclients.Clients, dir string) []string { + objects, err := w.Workspace.ListAll(ctx, workspaceapi.ListWorkspaceRequest{Path: dir}) if err != nil { - if !errors.Is(err, apierr.ErrNotFound) { + if !apierrs.Is(err, apierrs.ErrNotFound) { log.Infof(ctx, "WARNING: bundle cleanup incomplete, cannot list %s: %s", dir, err) } return nil } var dirs []string for _, o := range objects { - if o.ObjectType == workspace.ObjectTypeDirectory { + if o.ObjectType == workspaceapi.ObjectTypeDirectory { dirs = append(dirs, o.Path) } } diff --git a/acceptance/cmd/api/integer-precision/output.txt b/acceptance/cmd/api/integer-precision/output.txt index 02c843db4b4..2a5cff6e0db 100644 --- a/acceptance/cmd/api/integer-precision/output.txt +++ b/acceptance/cmd/api/integer-precision/output.txt @@ -12,8 +12,8 @@ "method": "POST", "path": "/api/2.0/test/bigint", "body": { - "name": "a>> [CLI] clusters list ID Name State -4321 some-test-cluster -9876 some-other-cluster +4321 some-test-cluster RUNNING +9876 some-other-cluster RUNNING >>> print_requests.py --get //clusters/list { @@ -57,8 +57,8 @@ Validation OK! === No header when unset >>> [CLI] clusters list ID Name State -4321 some-test-cluster -9876 some-other-cluster +4321 some-test-cluster RUNNING +9876 some-other-cluster RUNNING >>> print_requests.py --get //clusters/list { diff --git a/acceptance/cmd/workspace/clusters-list/output.txt b/acceptance/cmd/workspace/clusters-list/output.txt index 3b3bcf763d0..690ea704e60 100644 --- a/acceptance/cmd/workspace/clusters-list/output.txt +++ b/acceptance/cmd/workspace/clusters-list/output.txt @@ -3,5 +3,5 @@ >>> [CLI] clusters list ID Name State -4321 some-test-cluster -9876 some-other-cluster +4321 some-test-cluster RUNNING +9876 some-other-cluster RUNNING diff --git a/acceptance/dbr_test.go b/acceptance/dbr_test.go index 7d182f971a8..539396a0a20 100644 --- a/acceptance/dbr_test.go +++ b/acceptance/dbr_test.go @@ -12,11 +12,13 @@ import ( "github.com/databricks/cli/internal/testarchive" "github.com/databricks/cli/libs/filer" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/workspaceapi" + "github.com/databricks/databricks-sdk-go/config" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" + "github.com/databricks/sdk-go/options/lro" + sdkscim "github.com/databricks/sdk-go/scim/v1" "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -25,16 +27,16 @@ import ( // workspaceTmpDir creates a temporary directory in the workspace for running tests. // This is used by acceptance tests when running with the -workspace-tmp-dir flag. func workspaceTmpDir(ctx context.Context, t *testing.T) string { - w, err := databricks.NewWorkspaceClient() + w, err := sdkclients.New(ctx, &config.Config{}) require.NoError(t, err) - currentUser, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + currentUser, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) require.NoError(t, err) timestamp := time.Now().Format("2006-01-02T15:04:05Z") path := fmt.Sprintf( "/Workspace/Users/%s/acceptance/%s/%s", - currentUser.UserName, + utils.Deref(currentUser.UserName), timestamp, uuid.New().String(), ) @@ -76,15 +78,15 @@ type dbrTestConfig struct { // setupDbrTestDir creates the test directory and returns the workspace client and filer. // It returns the API path (without /Workspace prefix) for use with workspace APIs. -func setupDbrTestDir(ctx context.Context, t *testing.T, uniqueID string) (*databricks.WorkspaceClient, filer.Filer, string) { - w, err := databricks.NewWorkspaceClient() +func setupDbrTestDir(ctx context.Context, t *testing.T, uniqueID string) (*sdkclients.Clients, filer.Filer, string) { + w, err := sdkclients.New(ctx, &config.Config{}) require.NoError(t, err) - currentUser, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + currentUser, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) require.NoError(t, err) // API path (without /Workspace prefix) for workspace API calls. - apiPath := path.Join("/Users", currentUser.UserName, "dbr-acceptance-test", uniqueID) + apiPath := path.Join("/Users", utils.Deref(currentUser.UserName), "dbr-acceptance-test", uniqueID) err = w.Workspace.MkdirsByPath(ctx, apiPath) require.NoError(t, err) @@ -134,7 +136,7 @@ func buildAndUploadArchive(ctx context.Context, t *testing.T, f filer.Filer, ver } // uploadRunner uploads the DBR runner notebook to the workspace using workspace.Import. -func uploadRunner(ctx context.Context, t *testing.T, w *databricks.WorkspaceClient, testDir string, verbose bool) string { +func uploadRunner(ctx context.Context, t *testing.T, w *sdkclients.Clients, testDir string, verbose bool) string { cwd, err := os.Getwd() require.NoError(t, err) @@ -147,11 +149,11 @@ func uploadRunner(ctx context.Context, t *testing.T, w *databricks.WorkspaceClie if verbose { t.Log("Uploading DBR runner notebook...") } - err = w.Workspace.Import(ctx, workspace.Import{ + err = w.Workspace.Import(ctx, workspaceapi.Import{ Path: notebookPath, Overwrite: true, - Language: workspace.LanguagePython, - Format: workspace.ImportFormatSource, + Language: workspaceapi.LanguagePython, + Format: workspaceapi.ImportFormatSource, Content: base64.StdEncoding.EncodeToString(runnerContent), }) require.NoError(t, err) @@ -175,17 +177,17 @@ func buildBaseParams(testDir, archiveName, debugLogPath string) map[string]strin } // runDbrTests creates a job and runs it to execute cloud and local acceptance tests on DBR. -func runDbrTests(ctx context.Context, t *testing.T, w *databricks.WorkspaceClient, testDir, archiveName, runnerName string, config dbrTestConfig) { +func runDbrTests(ctx context.Context, t *testing.T, w *sdkclients.Clients, testDir, archiveName, runnerName string, config dbrTestConfig) { cloudEnv := os.Getenv("CLOUD_ENV") if cloudEnv == "" { t.Fatal("CLOUD_ENV is not set. Please run DBR tests from a CI environment with deco env run.") } - currentUser, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + currentUser, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) require.NoError(t, err) // Create debug logs directory - debugLogsDir := path.Join("/Users", currentUser.UserName, "dbr_acceptance_tests") + debugLogsDir := path.Join("/Users", utils.Deref(currentUser.UserName), "dbr_acceptance_tests") err = w.Workspace.MkdirsByPath(ctx, debugLogsDir) require.NoError(t, err) @@ -196,10 +198,10 @@ func runDbrTests(ctx context.Context, t *testing.T, w *databricks.WorkspaceClien debugLogPath := path.Join(debugLogsDir, debugLogFileName) // Create empty file via workspace API - err = w.Workspace.Import(ctx, workspace.Import{ + err = w.Workspace.Import(ctx, workspaceapi.Import{ Path: debugLogPath, Overwrite: true, - Format: workspace.ImportFormatAuto, + Format: workspaceapi.ImportFormatAuto, Content: base64.StdEncoding.EncodeToString([]byte("")), }) require.NoError(t, err) @@ -232,32 +234,31 @@ func runDbrTests(ctx context.Context, t *testing.T, w *databricks.WorkspaceClien // Create a job (not a one-time run) so we can use MaxRetries on tasks. // Always use serverless compute. t.Log(" Cluster: serverless") - createJob := jobs.CreateJob{ - Name: jobName, - Environments: []jobs.JobEnvironment{ + createJob := sdkjobs.CreateJobRequest{ + Name: new(jobName), + Environments: []sdkjobs.JobEnvironment{ { - EnvironmentKey: "default", - Spec: &compute.Environment{ - EnvironmentVersion: "4", + EnvironmentKey: new("default"), + Spec: &sdkjobs.Environment{ + EnvironmentVersion: new("4"), }, }, }, - Tasks: []jobs.Task{ + Tasks: []sdkjobs.TaskSettings{ { - TaskKey: "cloud_tests", - EnvironmentKey: "default", - MaxRetries: 0, - NotebookTask: &jobs.NotebookTask{ - NotebookPath: notebookPath, + TaskKey: new("cloud_tests"), + EnvironmentRef: &sdkjobs.TaskSettings_EnvironmentRef_EnvironmentKey{EnvironmentKey: "default"}, + Task: &sdkjobs.TaskSettings_Task_NotebookTask{NotebookTask: sdkjobs.NotebookTask{ + NotebookPath: new(notebookPath), BaseParameters: cloudParams, - Source: jobs.SourceWorkspace, - }, + Source: sdkjobs.Source_Workspace, + }}, }, }, } // Create the job - job, err := w.Jobs.Create(ctx, createJob) + job, err := w.Jobs.CreateJob(ctx, createJob) require.NoError(t, err) // The job is not deleted after the test completes. @@ -265,36 +266,36 @@ func runDbrTests(ctx context.Context, t *testing.T, w *databricks.WorkspaceClien // It will automatically be cleaned by the nightly cleanup scripts. // Trigger a run of the job - wait, err := w.Jobs.RunNow(ctx, jobs.RunNow{JobId: job.JobId}) + wait, err := w.Jobs.RunNow(ctx, sdkjobs.RunNowRequest{JobId: job.JobId}) require.NoError(t, err) // Fetch run details immediately to get the URL so users can follow along - runDetails, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: wait.RunId}) + runDetails, err := w.Jobs.GetRun(ctx, sdkjobs.GetRunRequest{RunId: new(wait.GetRunId())}) require.NoError(t, err) t.Log("") t.Log("=== Job Started ===") - t.Logf(" Run URL: %s", runDetails.RunPageUrl) + t.Logf(" Run URL: %s", utils.Deref(runDetails.RunPageUrl)) t.Logf(" Debug logs: %s/editor/files/%d", w.Config.Host, debugLogStatus.ObjectId) t.Log("") t.Logf("Waiting for completion (timeout: %v)...", config.timeout) - run, err := wait.GetWithTimeout(config.timeout) + run, err := wait.Wait(ctx, lro.WithTimeout(config.timeout)) if err != nil { // Try to fetch the run details for the URL and task output - runDetails, fetchErr := w.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: wait.RunId}) + runDetails, fetchErr := w.Jobs.GetRun(ctx, sdkjobs.GetRunRequest{RunId: new(wait.GetRunId())}) if fetchErr == nil { // Try to get the task output for debugging for _, task := range runDetails.Tasks { - output, outputErr := w.Jobs.GetRunOutput(ctx, jobs.GetRunOutputRequest{ + output, outputErr := w.Jobs.GetRunOutput(ctx, sdkjobs.GetRunOutputRequest{ RunId: task.RunId, }) if outputErr == nil { - if output.Error != "" { - t.Logf("Task %s error: %s", task.TaskKey, output.Error) + if utils.Deref(output.Error) != "" { + t.Logf("Task %s error: %s", utils.Deref(task.TaskKey), utils.Deref(output.Error)) } - if output.ErrorTrace != "" { - t.Logf("Task %s error trace:\n%s", task.TaskKey, output.ErrorTrace) + if utils.Deref(output.ErrorTrace) != "" { + t.Logf("Task %s error trace:\n%s", utils.Deref(task.TaskKey), utils.Deref(output.ErrorTrace)) } } } @@ -305,20 +306,20 @@ func runDbrTests(ctx context.Context, t *testing.T, w *databricks.WorkspaceClien t.Logf("Job completed. Status: %s", run.State.ResultState) // Check if the job succeeded - if run.State.ResultState != jobs.RunResultStateSuccess { + if run.State.ResultState != sdkjobs.RunResultState_RunResultState_Success { // Try to get the task output for debugging for _, task := range run.Tasks { - output, outputErr := w.Jobs.GetRunOutput(ctx, jobs.GetRunOutputRequest{ + output, outputErr := w.Jobs.GetRunOutput(ctx, sdkjobs.GetRunOutputRequest{ RunId: task.RunId, }) - if outputErr == nil && output.Error != "" { - t.Logf("Task %s error: %s", task.TaskKey, output.Error) + if outputErr == nil && utils.Deref(output.Error) != "" { + t.Logf("Task %s error: %s", utils.Deref(task.TaskKey), utils.Deref(output.Error)) } - if outputErr == nil && output.ErrorTrace != "" { - t.Logf("Task %s error trace:\n%s", task.TaskKey, output.ErrorTrace) + if outputErr == nil && utils.Deref(output.ErrorTrace) != "" { + t.Logf("Task %s error trace:\n%s", utils.Deref(task.TaskKey), utils.Deref(output.ErrorTrace)) } } - t.Fatalf("Job failed with state: %s. Check the run URL for details: %s", run.State.ResultState, run.RunPageUrl) + t.Fatalf("Job failed with state: %s. Check the run URL for details: %s", run.State.ResultState, utils.Deref(run.RunPageUrl)) } t.Log("All tests passed!") diff --git a/acceptance/internal/dms_litebox.go b/acceptance/internal/dms_litebox.go index b59a172e06a..4a53a714557 100644 --- a/acceptance/internal/dms_litebox.go +++ b/acceptance/internal/dms_litebox.go @@ -13,6 +13,8 @@ import ( "testing" "time" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/testserver" "github.com/stretchr/testify/require" ) @@ -69,8 +71,8 @@ func configureDMSLitebox(t *testing.T, server *testserver.Server) { // Fixed test identity; this adapter only connects to a local LITE fixture. req.Header.Set("X-Databricks-Org-Id", "456") req.Header.Set("X-Databricks-Workspace-Id", "456") - req.Header.Set("X-Databricks-User-Id", testserver.TestUser.Id) - req.Header.Set("X-Databricks-User-Name", testserver.TestUser.UserName) + req.Header.Set("X-Databricks-User-Id", utils.Deref(testserver.TestUser.Id)) + req.Header.Set("X-Databricks-User-Name", utils.Deref(testserver.TestUser.UserName)) resp, err := client.Do(req) if err != nil { return liteboxFailure(err) diff --git a/acceptance/internal/prepare_server.go b/acceptance/internal/prepare_server.go index 468aa02dc9e..fd4f7093f2d 100644 --- a/acceptance/internal/prepare_server.go +++ b/acceptance/internal/prepare_server.go @@ -21,11 +21,11 @@ import ( "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/iamutil" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/databricks/cli/libs/testproxy" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" sdkconfig "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -92,7 +92,7 @@ func lookupEnv(testEnv []string, key string) (string, bool) { return "", false } -func PrepareServerAndClient(t *testing.T, config TestConfig, logRequests bool, outputDir string, testEnv []string) (*sdkconfig.Config, iam.User, string) { +func PrepareServerAndClient(t *testing.T, config TestConfig, logRequests bool, outputDir string, testEnv []string) (*sdkconfig.Config, scim.User, string) { cloudEnv := env.Get(t.Context(), "CLOUD_ENV") recordRequests := isTruePtr(config.RecordRequests) @@ -101,7 +101,7 @@ func PrepareServerAndClient(t *testing.T, config TestConfig, logRequests bool, o tokenSuffix := strings.ReplaceAll(uuid.NewString(), "-", "") var token string - var testUser iam.User + var testUser scim.User if isTruePtr(config.IsServicePrincipal) { token = testserver.ServicePrincipalTokenPrefix + tokenSuffix testUser = testserver.TestUserSP @@ -116,7 +116,7 @@ func PrepareServerAndClient(t *testing.T, config TestConfig, logRequests bool, o } if cloudEnv != "" { - w, err := databricks.NewWorkspaceClient() + w, err := sdkclients.New(t.Context(), &sdkconfig.Config{}) require.NoError(t, err) user, err := iamutil.GetCurrentUser(t.Context(), w) @@ -333,8 +333,8 @@ func getLoggedRequest(req *testserver.Request, includedHeaders []string) LoggedR } } - if json.Valid(req.Body) { - result.Body = json.RawMessage(req.Body) + if body, ok := sortedJSON(req.Body); ok { + result.Body = body } else if normalized, ok := normalizeMultipartBody(req); ok { // Multipart bodies contain a randomly generated boundary string and binary // content; record a normalized form (sorted form-field names with sizes for @@ -347,6 +347,22 @@ func getLoggedRequest(req *testserver.Request, includedHeaders []string) LoggedR return result } +// sortedJSON decodes a JSON body so that it is recorded with sorted object +// keys. Key order on the wire depends on the SDK's field declaration order, +// which carries no meaning and would only add noise to recorded requests. +func sortedJSON(data []byte) (any, bool) { + if !json.Valid(data) { + return nil, false + } + dec := json.NewDecoder(bytes.NewReader(data)) + dec.UseNumber() + var v any + if err := dec.Decode(&v); err != nil { + return nil, false + } + return v, true +} + // Multipart parts larger than this limit are summarized as a size placeholder // to keep recorded fixtures small. Reviewers care about *what* was uploaded // (path, format, overwrite flag), not the bytes themselves, for large blobs. diff --git a/acceptance/localenv/cluster-name-check/test.toml b/acceptance/localenv/cluster-name-check/test.toml index 8a4c4412163..16297533675 100644 --- a/acceptance/localenv/cluster-name-check/test.toml +++ b/acceptance/localenv/cluster-name-check/test.toml @@ -7,8 +7,8 @@ Pattern = "GET /api/2.1/clusters/list" Response.Body = ''' { "clusters": [ - {"cluster_id": "cid-123", "cluster_name": "my-cluster", "spark_version": "15.4.x-scala2.12"}, - {"cluster_id": "cid-999", "cluster_name": "other-cluster", "spark_version": "14.3.x-scala2.12"} + {"cluster_id": "cid-123", "cluster_name": "my-cluster", "spark_version": "15.4.x-scala2.12", "state": "RUNNING"}, + {"cluster_id": "cid-999", "cluster_name": "other-cluster", "spark_version": "14.3.x-scala2.12", "state": "RUNNING"} ] } ''' diff --git a/acceptance/localenv/cluster-stale-environment/test.toml b/acceptance/localenv/cluster-stale-environment/test.toml index f37b69e24c5..c85ff73df35 100644 --- a/acceptance/localenv/cluster-stale-environment/test.toml +++ b/acceptance/localenv/cluster-stale-environment/test.toml @@ -10,7 +10,7 @@ Pattern = "GET /api/2.1/clusters/list" Response.Body = ''' { "clusters": [ - {"cluster_id": "cid-123", "cluster_name": "my-cluster", "spark_version": "15.4.x-scala2.12"} + {"cluster_id": "cid-123", "cluster_name": "my-cluster", "spark_version": "15.4.x-scala2.12", "state": "RUNNING"} ] } ''' diff --git a/acceptance/pipelines/dry-run/dry-run-pipeline/output.txt b/acceptance/pipelines/dry-run/dry-run-pipeline/output.txt index a4e2c1eb7a4..48462d82014 100644 --- a/acceptance/pipelines/dry-run/dry-run-pipeline/output.txt +++ b/acceptance/pipelines/dry-run/dry-run-pipeline/output.txt @@ -19,6 +19,7 @@ Update ID: [UUID] "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", "body": { + "pipeline_id": "[UUID]", "validate_only": true } } @@ -36,6 +37,7 @@ Update ID: [UUID] "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", "body": { + "pipeline_id": "[UUID]", "validate_only": true } } diff --git a/acceptance/pipelines/dry-run/restart/output.txt b/acceptance/pipelines/dry-run/restart/output.txt index cf77b26a8e3..bb597759fcc 100644 --- a/acceptance/pipelines/dry-run/restart/output.txt +++ b/acceptance/pipelines/dry-run/restart/output.txt @@ -19,12 +19,16 @@ Update ID: [UUID] >>> print_requests.py //pipelines { "method": "POST", - "path": "/api/2.0/pipelines/[UUID]/stop" + "path": "/api/2.0/pipelines/[UUID]/stop", + "body": { + "pipeline_id": "[UUID]" + } } { "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", "body": { + "pipeline_id": "[UUID]", "validate_only": true } } diff --git a/acceptance/pipelines/run/refresh-flags/output.txt b/acceptance/pipelines/run/refresh-flags/output.txt index 68dcd0c9a23..5ef5adf8409 100644 --- a/acceptance/pipelines/run/refresh-flags/output.txt +++ b/acceptance/pipelines/run/refresh-flags/output.txt @@ -26,6 +26,7 @@ Pipeline configurations for this update: "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", "body": { + "pipeline_id": "[UUID]", "refresh_selection": [ "table1", "table2" @@ -53,7 +54,8 @@ Pipeline configurations for this update: "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", "body": { - "full_refresh": true + "full_refresh": true, + "pipeline_id": "[UUID]" } } @@ -80,7 +82,8 @@ Pipeline configurations for this update: "full_refresh_selection": [ "table1", "table2" - ] + ], + "pipeline_id": "[UUID]" } } @@ -108,6 +111,7 @@ Pipeline configurations for this update: "table1", "table2" ], + "pipeline_id": "[UUID]", "refresh_selection": [ "table3", "table4" diff --git a/acceptance/pipelines/run/restart/output.txt b/acceptance/pipelines/run/restart/output.txt index 07a3215d5dd..aa934dce409 100644 --- a/acceptance/pipelines/run/restart/output.txt +++ b/acceptance/pipelines/run/restart/output.txt @@ -24,10 +24,15 @@ Pipeline configurations for this update: >>> print_requests.py //pipelines { "method": "POST", - "path": "/api/2.0/pipelines/[UUID]/stop" + "path": "/api/2.0/pipelines/[UUID]/stop", + "body": { + "pipeline_id": "[UUID]" + } } { "method": "POST", "path": "/api/2.0/pipelines/[UUID]/updates", - "body": {} + "body": { + "pipeline_id": "[UUID]" + } } diff --git a/acceptance/pipelines/stop/output.txt b/acceptance/pipelines/stop/output.txt index 76587739aed..837e953e8a7 100644 --- a/acceptance/pipelines/stop/output.txt +++ b/acceptance/pipelines/stop/output.txt @@ -26,7 +26,10 @@ Stopping my_pipeline... my_pipeline has been stopped. { "method": "POST", - "path": "/api/2.0/pipelines/[UUID]/stop" + "path": "/api/2.0/pipelines/[UUID]/stop", + "body": { + "pipeline_id": "[UUID]" + } } === Stopping pipeline with KEY, expect same output as without KEY @@ -35,5 +38,8 @@ Stopping my_pipeline... my_pipeline has been stopped. { "method": "POST", - "path": "/api/2.0/pipelines/[UUID]/stop" + "path": "/api/2.0/pipelines/[UUID]/stop", + "body": { + "pipeline_id": "[UUID]" + } } diff --git a/acceptance/selftest/record_cloud/pipeline-crud/output.txt b/acceptance/selftest/record_cloud/pipeline-crud/output.txt index 97ac1421a4b..0627224ced5 100644 --- a/acceptance/selftest/record_cloud/pipeline-crud/output.txt +++ b/acceptance/selftest/record_cloud/pipeline-crud/output.txt @@ -48,7 +48,8 @@ } } ], - "name": "test-pipeline-2" + "name": "test-pipeline-2", + "pipeline_id": "[UUID]" } } diff --git a/acceptance/telemetry/failure/output.txt b/acceptance/telemetry/failure/output.txt index a4a56f92e22..e42866ab305 100644 --- a/acceptance/telemetry/failure/output.txt +++ b/acceptance/telemetry/failure/output.txt @@ -28,7 +28,6 @@ HH:MM:SS Debug: POST /telemetry-ext < "error_code": "ERROR_CODE", < "message": "Endpoint not implemented." < } pid=PID sdk=true -HH:MM:SS Debug: non-retriable error: Endpoint not implemented. pid=PID sdk=true HH:MM:SS Info: Attempt 1 failed due to a server side error. Retrying status code: 501 pid=PID HH:MM:SS Debug: POST /telemetry-ext > { @@ -44,7 +43,6 @@ HH:MM:SS Debug: POST /telemetry-ext < "error_code": "ERROR_CODE", < "message": "Endpoint not implemented." < } pid=PID sdk=true -HH:MM:SS Debug: non-retriable error: Endpoint not implemented. pid=PID sdk=true HH:MM:SS Info: Attempt 2 failed due to a server side error. Retrying status code: 501 pid=PID HH:MM:SS Debug: POST /telemetry-ext > { @@ -60,7 +58,6 @@ HH:MM:SS Debug: POST /telemetry-ext < "error_code": "ERROR_CODE", < "message": "Endpoint not implemented." < } pid=PID sdk=true -HH:MM:SS Debug: non-retriable error: Endpoint not implemented. pid=PID sdk=true HH:MM:SS Info: Attempt 3 failed due to a server side error. Retrying status code: 501 pid=PID HH:MM:SS Info: telemetry upload failed: failed to upload telemetry logs after three attempts pid=PID diff --git a/acceptance/telemetry/timeout/output.txt b/acceptance/telemetry/timeout/output.txt index 550fe861652..bd2c0d846ba 100644 --- a/acceptance/telemetry/timeout/output.txt +++ b/acceptance/telemetry/timeout/output.txt @@ -23,8 +23,7 @@ HH:MM:SS Debug: POST /telemetry-ext > ], > "uploadTime": [UNIX_TIME_MILLIS] > } -< Error: Post "[DATABRICKS_URL]/telemetry-ext": context deadline exceeded pid=PID sdk=true -HH:MM:SS Debug: non-retriable error: Post "[DATABRICKS_URL]/telemetry-ext": context deadline exceeded pid=PID sdk=true +< Error: context deadline exceeded pid=PID sdk=true HH:MM:SS Debug: Attempt 1 failed due to a timeout. Will not retry pid=PID HH:MM:SS Info: telemetry upload failed: uploading telemetry logs timed out: Post "[DATABRICKS_URL]/telemetry-ext": context deadline exceeded pid=PID diff --git a/acceptance/workspace/lakeview/publish/output.txt b/acceptance/workspace/lakeview/publish/output.txt index 16d93882a98..7e590a6a72c 100644 --- a/acceptance/workspace/lakeview/publish/output.txt +++ b/acceptance/workspace/lakeview/publish/output.txt @@ -25,6 +25,7 @@ "method": "POST", "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", "body": { + "dashboard_id": "[DASHBOARD_ID]", "embed_credentials": false } } diff --git a/acceptance/workspace/repos/git_cli_folder/output.txt b/acceptance/workspace/repos/git_cli_folder/output.txt index f27bd344833..1961a51c2c4 100644 --- a/acceptance/workspace/repos/git_cli_folder/output.txt +++ b/acceptance/workspace/repos/git_cli_folder/output.txt @@ -51,7 +51,8 @@ "method": "PATCH", "path": "/api/2.0/repos/[REPO_ID]", "body": { - "branch": "update-by-path" + "branch": "update-by-path", + "id": [REPO_ID] } } { diff --git a/acceptance/workspace/repos/update/output.txt b/acceptance/workspace/repos/update/output.txt index 24414ac795d..b80abb961fb 100644 --- a/acceptance/workspace/repos/update/output.txt +++ b/acceptance/workspace/repos/update/output.txt @@ -39,7 +39,8 @@ "method": "PATCH", "path": "/api/2.0/repos/[REPO_ID]", "body": { - "branch": "update-by-id" + "branch": "update-by-id", + "id": [REPO_ID] } } { @@ -57,7 +58,8 @@ "method": "PATCH", "path": "/api/2.0/repos/[REPO_ID]", "body": { - "branch": "update-by-path" + "branch": "update-by-path", + "id": [REPO_ID] } } { diff --git a/bundle/appdeploy/app.go b/bundle/appdeploy/app.go index 4f590be60ac..efe1f1a3c26 100644 --- a/bundle/appdeploy/app.go +++ b/bundle/appdeploy/app.go @@ -3,14 +3,21 @@ package appdeploy import ( "context" "fmt" + "slices" "time" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/bundle/internal/poll" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" - sdkapps "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/libs/utils" + sdkapps "github.com/databricks/sdk-go/apps/v1" ) +// appOperationTimeout is how long app start, stop and deployment are awaited. +const appOperationTimeout = 20 * time.Minute + func logProgress(ctx context.Context, msg string) { if msg == "" { return @@ -19,15 +26,17 @@ func logProgress(ctx context.Context, msg string) { } // BuildDeployment constructs an AppDeployment from the app's source code path, inline config and git source. -func BuildDeployment(sourcePath string, config *resources.AppConfig, gitSource *sdkapps.GitSource) sdkapps.AppDeployment { +func BuildDeployment(sourcePath string, config *resources.AppConfig, gitSource *apps.GitSource) (*sdkapps.AppDeployment, error) { // GitRepository is not supported in the Deploy API, only as part of Create, so we need to remove it. if gitSource != nil { gitSource.GitRepository = nil } - deployment := sdkapps.AppDeployment{ - Mode: sdkapps.AppDeploymentModeSnapshot, - SourceCodePath: sourcePath, - GitSource: gitSource, + deployment := apps.AppDeployment{ + Mode: apps.AppDeployment_Mode_Snapshot, + GitSource: gitSource, + } + if sourcePath != "" { + deployment.SourceCodePath = new(sourcePath) } if config != nil { @@ -36,27 +45,35 @@ func BuildDeployment(sourcePath string, config *resources.AppConfig, gitSource * } if len(config.Env) > 0 { - deployment.EnvVars = make([]sdkapps.EnvVar, len(config.Env)) + deployment.EnvVars = make([]apps.EnvVar, len(config.Env)) for i, env := range config.Env { - deployment.EnvVars[i] = sdkapps.EnvVar{ - Name: env.Name, - Value: env.Value, - ValueFrom: env.ValueFrom, + deployment.EnvVars[i] = apps.EnvVar{ + Name: new(env.Name), + Value: nonEmpty(env.Value), + ValueFrom: nonEmpty(env.ValueFrom), } } } } - return deployment + return apps.AppDeploymentToSDK(&deployment) +} + +func nonEmpty(s string) *string { + if s == "" { + return nil + } + return new(s) } // WaitForDeploymentToComplete waits for active and pending deployments on an app to finish. -func WaitForDeploymentToComplete(ctx context.Context, w *databricks.WorkspaceClient, app *sdkapps.App) error { +func WaitForDeploymentToComplete(ctx context.Context, w *sdkclients.Clients, app *sdkapps.App) error { + appName := utils.Deref(app.Name) if app.ActiveDeployment != nil && app.ActiveDeployment.Status != nil && - app.ActiveDeployment.Status.State == sdkapps.AppDeploymentStateInProgress { + app.ActiveDeployment.Status.State == apps.AppDeployment_State_InProgress { logProgress(ctx, "Waiting for the active deployment to complete...") - _, err := w.Apps.WaitGetDeploymentAppSucceeded(ctx, app.Name, app.ActiveDeployment.DeploymentId, 20*time.Minute, nil) + _, err := WaitDeploymentSucceeded(ctx, w, appName, utils.Deref(app.ActiveDeployment.DeploymentId), nil) if err != nil { return err } @@ -65,9 +82,9 @@ func WaitForDeploymentToComplete(ctx context.Context, w *databricks.WorkspaceCli if app.PendingDeployment != nil && app.PendingDeployment.Status != nil && - app.PendingDeployment.Status.State == sdkapps.AppDeploymentStateInProgress { + app.PendingDeployment.Status.State == apps.AppDeployment_State_InProgress { logProgress(ctx, "Waiting for the pending deployment to complete...") - _, err := w.Apps.WaitGetDeploymentAppSucceeded(ctx, app.Name, app.PendingDeployment.DeploymentId, 20*time.Minute, nil) + _, err := WaitDeploymentSucceeded(ctx, w, appName, utils.Deref(app.PendingDeployment.DeploymentId), nil) if err != nil { return err } @@ -79,13 +96,14 @@ func WaitForDeploymentToComplete(ctx context.Context, w *databricks.WorkspaceCli // Deploy deploys the app using the provided deployment request. // If another deployment is in progress, it waits for it to complete and retries. -func Deploy(ctx context.Context, w *databricks.WorkspaceClient, appName string, deployment sdkapps.AppDeployment) error { - wait, err := w.Apps.Deploy(ctx, sdkapps.CreateAppDeploymentRequest{ - AppName: appName, +func Deploy(ctx context.Context, w *sdkclients.Clients, appName string, deployment *sdkapps.AppDeployment) error { + req := sdkapps.CreateAppDeploymentRequest{ + AppName: new(appName), AppDeployment: deployment, - }) + } + wait, err := w.Apps.CreateAppDeployment(ctx, req) if err != nil { - existingApp, getErr := w.Apps.Get(ctx, sdkapps.GetAppRequest{Name: appName}) + existingApp, getErr := w.Apps.GetApp(ctx, sdkapps.GetAppRequest{Name: new(appName)}) if getErr != nil { return fmt.Errorf("failed to get app %s: %w", appName, getErr) } @@ -94,20 +112,88 @@ func Deploy(ctx context.Context, w *databricks.WorkspaceClient, appName string, return waitErr } - wait, err = w.Apps.Deploy(ctx, sdkapps.CreateAppDeploymentRequest{ - AppName: appName, - AppDeployment: deployment, - }) + wait, err = w.Apps.CreateAppDeployment(ctx, req) if err != nil { return err } } - _, err = wait.OnProgress(func(ad *sdkapps.AppDeployment) { + _, err = WaitDeploymentSucceeded(ctx, w, appName, wait.GetDeploymentId(), func(ad *sdkapps.AppDeployment) { if ad.Status == nil { return } - logProgress(ctx, ad.Status.Message) - }).Get() + logProgress(ctx, utils.Deref(ad.Status.Message)) + }) return err } + +// WaitDeploymentSucceeded polls the deployment until it succeeds, calling +// callback (if not nil) after every poll. +func WaitDeploymentSucceeded(ctx context.Context, w *sdkclients.Clients, appName, deploymentID string, callback func(*sdkapps.AppDeployment)) (*sdkapps.AppDeployment, error) { + return poll.Until(ctx, appOperationTimeout, func(ctx context.Context) (poll.Status[sdkapps.AppDeployment], error) { + deployment, err := w.Apps.GetAppDeployment(ctx, sdkapps.GetAppDeploymentRequest{ + AppName: new(appName), + DeploymentId: new(deploymentID), + }) + if err != nil { + return poll.Status[sdkapps.AppDeployment]{}, err + } + if callback != nil { + callback(deployment) + } + var status sdkapps.AppDeploymentStatus + if deployment.Status != nil { + status = *deployment.Status + } + message := utils.Deref(status.Message) + switch status.State { + case apps.AppDeployment_State_Succeeded: + return poll.Status[sdkapps.AppDeployment]{Done: true, Result: deployment}, nil + case apps.AppDeployment_State_Failed: + return poll.Status[sdkapps.AppDeployment]{}, fmt.Errorf("failed to reach %s, got %s: %s", + apps.AppDeployment_State_Succeeded, status.State, message) + case apps.AppDeployment_State_Unspecified, apps.AppDeployment_State_InProgress, apps.AppDeployment_State_Cancelled: + // Still polling; return current message + } + return poll.Status[sdkapps.AppDeployment]{Message: message}, nil + }) +} + +// WaitComputeState polls the app until its compute reaches target, failing +// when it reaches one of the failure states. callback (if not nil) is called +// after every poll. +func WaitComputeState(ctx context.Context, w *sdkclients.Clients, appName string, target apps.ComputeStatus_ComputeState, failures []apps.ComputeStatus_ComputeState, callback func(*sdkapps.App)) (*sdkapps.App, error) { + return poll.Until(ctx, appOperationTimeout, func(ctx context.Context) (poll.Status[sdkapps.App], error) { + app, err := w.Apps.GetApp(ctx, sdkapps.GetAppRequest{Name: new(appName)}) + if err != nil { + return poll.Status[sdkapps.App]{}, err + } + if callback != nil { + callback(app) + } + var status sdkapps.ComputeStatus + if app.ComputeStatus != nil { + status = *app.ComputeStatus + } + message := utils.Deref(status.Message) + if status.State == target { + return poll.Status[sdkapps.App]{Done: true, Result: app}, nil + } + if slices.Contains(failures, status.State) { + return poll.Status[sdkapps.App]{}, fmt.Errorf("failed to reach %s, got %s: %s", target, status.State, message) + } + return poll.Status[sdkapps.App]{Message: message}, nil + }) +} + +// WaitAppActive waits for the app compute to become ACTIVE. +func WaitAppActive(ctx context.Context, w *sdkclients.Clients, appName string, callback func(*sdkapps.App)) (*sdkapps.App, error) { + return WaitComputeState(ctx, w, appName, apps.ComputeStatus_ComputeState_Active, + []apps.ComputeStatus_ComputeState{apps.ComputeStatus_ComputeState_Error, apps.ComputeStatus_ComputeState_Stopped}, callback) +} + +// WaitAppStopped waits for the app compute to become STOPPED. +func WaitAppStopped(ctx context.Context, w *sdkclients.Clients, appName string, callback func(*sdkapps.App)) (*sdkapps.App, error) { + return WaitComputeState(ctx, w, appName, apps.ComputeStatus_ComputeState_Stopped, + []apps.ComputeStatus_ComputeState{apps.ComputeStatus_ComputeState_Error}, callback) +} diff --git a/bundle/apps/validate.go b/bundle/apps/validate.go index 2ab3384f991..d00a74cf400 100644 --- a/bundle/apps/validate.go +++ b/bundle/apps/validate.go @@ -9,8 +9,9 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" + "github.com/databricks/cli/libs/sdktypes/apps/v1" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/cli/libs/utils" ) // resourceReferencePattern matches ${resources...} variable references. @@ -23,7 +24,8 @@ func (v *validate) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics usedSourceCodePaths := make(map[string]string) for key, app := range b.Config.Resources.Apps { - if app.SourceCodePath == "" && app.GitSource == nil { + sourceCodePath := utils.Deref(app.SourceCodePath) + if sourceCodePath == "" && app.GitSource == nil { diags = append(diags, diag.Diagnostic{ Severity: diag.Error, Summary: "Missing app source code path or git source", @@ -33,7 +35,7 @@ func (v *validate) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics continue } - if app.SourceCodePath != "" && app.GitSource != nil { + if sourceCodePath != "" && app.GitSource != nil { diags = append(diags, diag.Diagnostic{ Severity: diag.Error, Summary: "Both source_code_path and git_source fields are set", @@ -43,15 +45,15 @@ func (v *validate) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics continue } - if _, ok := usedSourceCodePaths[app.SourceCodePath]; ok { + if _, ok := usedSourceCodePaths[sourceCodePath]; ok { diags = append(diags, diag.Diagnostic{ Severity: diag.Error, Summary: "Duplicate app source code path", - Detail: fmt.Sprintf("app resource '%s' has the same source code path as app resource '%s', this will lead to the app configuration being overridden by each other", key, usedSourceCodePaths[app.SourceCodePath]), + Detail: fmt.Sprintf("app resource '%s' has the same source code path as app resource '%s', this will lead to the app configuration being overridden by each other", key, usedSourceCodePaths[sourceCodePath]), Locations: b.Config.GetLocationsOf(structpath.NewPath(nil, "resources", "apps", key, "source_code_path")), }) } - usedSourceCodePaths[app.SourceCodePath] = key + usedSourceCodePaths[sourceCodePath] = key diags = diags.Extend(warnForAppResourcePermissions(b, key, app)) } @@ -65,22 +67,22 @@ func (v *validate) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics func appResourceRef(r apps.AppResource) (appResourceReference, bool) { switch { case r.Job != nil: - return appResourceReference{"jobs", r.Job.Id, string(r.Job.Permission)}, true + return appResourceReference{"jobs", utils.Deref(r.Job.Id), string(r.Job.Permission)}, true case r.SqlWarehouse != nil: - return appResourceReference{"sql_warehouses", r.SqlWarehouse.Id, string(r.SqlWarehouse.Permission)}, true + return appResourceReference{"sql_warehouses", utils.Deref(r.SqlWarehouse.Id), string(r.SqlWarehouse.Permission)}, true case r.ServingEndpoint != nil: - return appResourceReference{"model_serving_endpoints", r.ServingEndpoint.Name, string(r.ServingEndpoint.Permission)}, true + return appResourceReference{"model_serving_endpoints", utils.Deref(r.ServingEndpoint.Name), string(r.ServingEndpoint.Permission)}, true case r.Experiment != nil: - return appResourceReference{"experiments", r.Experiment.ExperimentId, string(r.Experiment.Permission)}, true + return appResourceReference{"experiments", utils.Deref(r.Experiment.ExperimentId), string(r.Experiment.Permission)}, true case r.Postgres != nil: - if r.Postgres.Branch != "" { - return appResourceReference{"postgres_projects", r.Postgres.Branch, string(r.Postgres.Permission)}, true + if branch := utils.Deref(r.Postgres.Branch); branch != "" { + return appResourceReference{"postgres_projects", branch, string(r.Postgres.Permission)}, true } return appResourceReference{ - "database_instances", r.Postgres.Database, string(r.Postgres.Permission), + "database_instances", utils.Deref(r.Postgres.Database), string(r.Postgres.Permission), }, true case r.UcSecurable != nil: - return appResourceReference{string(r.UcSecurable.SecurableType), r.UcSecurable.SecurableFullName, string(r.UcSecurable.Permission)}, true + return appResourceReference{string(r.UcSecurable.SecurableType), utils.Deref(r.UcSecurable.SecurableFullName), string(r.UcSecurable.Permission)}, true default: return appResourceReference{}, false } diff --git a/bundle/apps/validate_test.go b/bundle/apps/validate_test.go index 89b4e1d5907..594c782710b 100644 --- a/bundle/apps/validate_test.go +++ b/bundle/apps/validate_test.go @@ -4,6 +4,8 @@ import ( "path/filepath" "testing" + "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/mutator" @@ -12,7 +14,6 @@ import ( "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/vfs" - "github.com/databricks/databricks-sdk-go/service/apps" "github.com/stretchr/testify/require" ) @@ -32,14 +33,14 @@ func TestAppsValidateSameSourcePath(t *testing.T) { Apps: map[string]*resources.App{ "app1": { App: apps.App{ - Name: "app1", - SourceCodePath: "./app1", + Name: new("app1"), + SourceCodePath: new("./app1"), }, }, "app2": { App: apps.App{ - Name: "app2", - SourceCodePath: "./app1", + Name: new("app2"), + SourceCodePath: new("./app1"), }, }, }, @@ -66,7 +67,7 @@ func TestAppsValidateResourcePermissionsWarning(t *testing.T) { { name: "job with permissions warns", appResources: []apps.AppResource{ - {Name: "my-job", Job: &apps.AppResourceJob{Id: "${resources.jobs.my_job.id}", Permission: "CAN_MANAGE_RUN"}}, + {Name: new("my-job"), Job: &apps.AppResourceJob{Id: new("${resources.jobs.my_job.id}"), Permission: "CAN_MANAGE_RUN"}}, }, resources: config.Resources{ Jobs: map[string]*resources.Job{ @@ -79,7 +80,7 @@ func TestAppsValidateResourcePermissionsWarning(t *testing.T) { { name: "job with SP already included no warning", appResources: []apps.AppResource{ - {Name: "my-job", Job: &apps.AppResourceJob{Id: "${resources.jobs.my_job.id}", Permission: "CAN_MANAGE_RUN"}}, + {Name: new("my-job"), Job: &apps.AppResourceJob{Id: new("${resources.jobs.my_job.id}"), Permission: "CAN_MANAGE_RUN"}}, }, resources: config.Resources{ Jobs: map[string]*resources.Job{ @@ -94,7 +95,7 @@ func TestAppsValidateResourcePermissionsWarning(t *testing.T) { { name: "job without permissions no warning", appResources: []apps.AppResource{ - {Name: "my-job", Job: &apps.AppResourceJob{Id: "${resources.jobs.my_job.id}", Permission: "CAN_MANAGE_RUN"}}, + {Name: new("my-job"), Job: &apps.AppResourceJob{Id: new("${resources.jobs.my_job.id}"), Permission: "CAN_MANAGE_RUN"}}, }, resources: config.Resources{ Jobs: map[string]*resources.Job{"my_job": {}}, @@ -104,7 +105,7 @@ func TestAppsValidateResourcePermissionsWarning(t *testing.T) { { name: "sql_warehouse with permissions warns", appResources: []apps.AppResource{ - {Name: "my-wh", SqlWarehouse: &apps.AppResourceSqlWarehouse{Id: "${resources.sql_warehouses.my_wh.id}", Permission: "CAN_USE"}}, + {Name: new("my-wh"), SqlWarehouse: &apps.AppResourceSqlWarehouse{Id: new("${resources.sql_warehouses.my_wh.id}"), Permission: "CAN_USE"}}, }, resources: config.Resources{ SqlWarehouses: map[string]*resources.SqlWarehouse{ @@ -117,7 +118,7 @@ func TestAppsValidateResourcePermissionsWarning(t *testing.T) { { name: "serving_endpoint with permissions warns", appResources: []apps.AppResource{ - {Name: "my-ep", ServingEndpoint: &apps.AppResourceServingEndpoint{Name: "${resources.model_serving_endpoints.my_ep.name}", Permission: "CAN_QUERY"}}, + {Name: new("my-ep"), ServingEndpoint: &apps.AppResourceServingEndpoint{Name: new("${resources.model_serving_endpoints.my_ep.name}"), Permission: "CAN_QUERY"}}, }, resources: config.Resources{ ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{ @@ -130,7 +131,7 @@ func TestAppsValidateResourcePermissionsWarning(t *testing.T) { { name: "experiment with permissions warns", appResources: []apps.AppResource{ - {Name: "my-exp", Experiment: &apps.AppResourceExperiment{ExperimentId: "${resources.experiments.my_exp.experiment_id}", Permission: "CAN_READ"}}, + {Name: new("my-exp"), Experiment: &apps.AppResourceExperiment{ExperimentId: new("${resources.experiments.my_exp.experiment_id}"), Permission: "CAN_READ"}}, }, resources: config.Resources{ Experiments: map[string]*resources.MlflowExperiment{ @@ -143,7 +144,7 @@ func TestAppsValidateResourcePermissionsWarning(t *testing.T) { { name: "postgres with permissions warns", appResources: []apps.AppResource{ - {Name: "my-pg", Postgres: &apps.AppResourcePostgres{Branch: "${resources.postgres_projects.my_pg.name}", Permission: "CAN_CONNECT_AND_CREATE"}}, + {Name: new("my-pg"), Postgres: &apps.AppResourcePostgres{Branch: new("${resources.postgres_projects.my_pg.name}"), Permission: "CAN_CONNECT_AND_CREATE"}}, }, resources: config.Resources{ PostgresProjects: map[string]*resources.PostgresProject{ @@ -156,7 +157,7 @@ func TestAppsValidateResourcePermissionsWarning(t *testing.T) { { name: "postgres without permissions no warning", appResources: []apps.AppResource{ - {Name: "my-pg", Postgres: &apps.AppResourcePostgres{Branch: "${resources.postgres_projects.my_pg.name}", Permission: "CAN_CONNECT_AND_CREATE"}}, + {Name: new("my-pg"), Postgres: &apps.AppResourcePostgres{Branch: new("${resources.postgres_projects.my_pg.name}"), Permission: "CAN_CONNECT_AND_CREATE"}}, }, resources: config.Resources{ PostgresProjects: map[string]*resources.PostgresProject{ @@ -168,7 +169,7 @@ func TestAppsValidateResourcePermissionsWarning(t *testing.T) { { name: "non-reference id no warning", appResources: []apps.AppResource{ - {Name: "my-job", Job: &apps.AppResourceJob{Id: "12345", Permission: "CAN_MANAGE_RUN"}}, + {Name: new("my-job"), Job: &apps.AppResourceJob{Id: new("12345"), Permission: "CAN_MANAGE_RUN"}}, }, resources: config.Resources{ Jobs: map[string]*resources.Job{ @@ -187,9 +188,9 @@ func TestAppsValidateResourcePermissionsWarning(t *testing.T) { tc.resources.Apps = map[string]*resources.App{ "my_app": { App: apps.App{ - Name: "my_app", + Name: new("my_app"), Resources: tc.appResources, - SourceCodePath: "./app1", + SourceCodePath: new("./app1"), }, }, } @@ -236,10 +237,10 @@ func TestAppsValidateBothSourceCodePathAndGitSource(t *testing.T) { Apps: map[string]*resources.App{ "app1": { App: apps.App{ - Name: "app1", - SourceCodePath: "./app1", + Name: new("app1"), + SourceCodePath: new("./app1"), GitSource: &apps.GitSource{ - Branch: "main", + Branch: new("main"), }, }, }, diff --git a/bundle/bundle.go b/bundle/bundle.go index 68654bead7c..62634e5ac16 100644 --- a/bundle/bundle.go +++ b/bundle/bundle.go @@ -26,11 +26,11 @@ import ( "github.com/databricks/cli/libs/locker" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/logdiag" + "github.com/databricks/cli/libs/sdkclients" libsync "github.com/databricks/cli/libs/sync" "github.com/databricks/cli/libs/tags" "github.com/databricks/cli/libs/telemetry/protos" "github.com/databricks/cli/libs/vfs" - "github.com/databricks/databricks-sdk-go" "github.com/google/uuid" ) @@ -165,7 +165,7 @@ type Bundle struct { Metadata metadata.Metadata // Returns the workspace client, initializing it on first call. - getClient func() (*databricks.WorkspaceClient, error) + getClient func() (*sdkclients.Clients, error) // Files that are synced to the workspace.file_path Files []fileset.File @@ -285,7 +285,7 @@ func TryLoad(ctx context.Context) *Bundle { } func (b *Bundle) initClientOnce(ctx context.Context) { - b.getClient = sync.OnceValues(func() (*databricks.WorkspaceClient, error) { + b.getClient = sync.OnceValues(func() (*sdkclients.Clients, error) { w, err := b.Config.Workspace.Client(ctx) if err != nil { return nil, fmt.Errorf("cannot resolve bundle auth configuration: %w", err) @@ -294,14 +294,14 @@ func (b *Bundle) initClientOnce(ctx context.Context) { }) } -func (b *Bundle) WorkspaceClientE(ctx context.Context) (*databricks.WorkspaceClient, error) { +func (b *Bundle) WorkspaceClientE(ctx context.Context) (*sdkclients.Clients, error) { if b.getClient == nil { b.initClientOnce(ctx) } return b.getClient() } -func (b *Bundle) WorkspaceClient(ctx context.Context) *databricks.WorkspaceClient { +func (b *Bundle) WorkspaceClient(ctx context.Context) *sdkclients.Clients { client, err := b.WorkspaceClientE(ctx) if err != nil { panic(err) @@ -312,8 +312,8 @@ func (b *Bundle) WorkspaceClient(ctx context.Context) *databricks.WorkspaceClien // SetWorkpaceClient sets the workspace client for this bundle. // This is used to inject a mock client for testing. -func (b *Bundle) SetWorkpaceClient(w *databricks.WorkspaceClient) { - b.getClient = func() (*databricks.WorkspaceClient, error) { +func (b *Bundle) SetWorkpaceClient(w *sdkclients.Clients) { + b.getClient = func() (*sdkclients.Clients, error) { return w, nil } } diff --git a/bundle/config/mutator/clients_helper_test.go b/bundle/config/mutator/clients_helper_test.go new file mode 100644 index 00000000000..22473013bb3 --- /dev/null +++ b/bundle/config/mutator/clients_helper_test.go @@ -0,0 +1,22 @@ +package mutator + +import ( + "testing" + + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/testserver" + sdkconfig "github.com/databricks/databricks-sdk-go/config" + "github.com/stretchr/testify/require" +) + +// newTestClients returns clients for server, a test server without any handlers +// registered by default. +func newTestClients(t *testing.T, server *testserver.Server) *sdkclients.Clients { + w, err := sdkclients.New(t.Context(), &sdkconfig.Config{ + Host: server.URL, + Token: "testtoken", + Loaders: []sdkconfig.Loader{sdkconfig.ConfigAttributes}, + }) + require.NoError(t, err) + return w +} diff --git a/bundle/config/mutator/configure_wsfs_test.go b/bundle/config/mutator/configure_wsfs_test.go index bf71faac260..d3598ed0421 100644 --- a/bundle/config/mutator/configure_wsfs_test.go +++ b/bundle/config/mutator/configure_wsfs_test.go @@ -8,9 +8,9 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config/mutator" "github.com/databricks/cli/libs/dbr" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/vfs" "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/experimental/mocks" "github.com/stretchr/testify/assert" ) @@ -25,9 +25,7 @@ func mockBundleForConfigureWSFS(t *testing.T, syncRootPath string) *bundle.Bundl SyncRoot: vfs.MustNew(syncRootPath), } - w := mocks.NewMockWorkspaceClient(t) - w.WorkspaceClient.Config = &config.Config{} - b.SetWorkpaceClient(w.WorkspaceClient) + b.SetWorkpaceClient(&sdkclients.Clients{Config: &config.Config{}}) return b } diff --git a/bundle/config/mutator/drop_empty_strings.go b/bundle/config/mutator/drop_empty_strings.go index 028351ed943..8d3566e62c6 100644 --- a/bundle/config/mutator/drop_empty_strings.go +++ b/bundle/config/mutator/drop_empty_strings.go @@ -5,6 +5,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" + "github.com/databricks/cli/bundle/internal/validation/generated" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/convert" @@ -32,7 +33,11 @@ func (m *dropEmptyStrings) Name() string { func (m *dropEmptyStrings) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { var diags diag.Diagnostics err := b.Config.Mutate(func(root dyn.Value) (dyn.Value, error) { - root, err := dyn.Map(root, "resources", func(_ dyn.Path, resources dyn.Value) (dyn.Value, error) { + keep, err := requiredEmptyStrings(root) + if err != nil { + return root, err + } + root, err = dyn.Map(root, "resources", func(_ dyn.Path, resources dyn.Value) (dyn.Value, error) { // Normalize against the resources type so omitempty is known per field. // Only DropEmptyStrings is set: existing values are kept as-is otherwise. out, normDiags := convert.Normalize(config.Resources{}, resources, convert.DropEmptyStrings) @@ -42,6 +47,12 @@ func (m *dropEmptyStrings) Apply(ctx context.Context, b *bundle.Bundle) diag.Dia if err != nil { return root, err } + for _, kv := range keep { + root, err = dyn.SetByPath(root, kv.path, kv.value) + if err != nil { + return root, err + } + } // Keep an empty apps description instead of dropping it: an app update without // the field leaves the remote description unchanged, so removing description @@ -58,3 +69,41 @@ func (m *dropEmptyStrings) Apply(ctx context.Context, b *bundle.Bundle) diag.Dia } return diags } + +// requiredEmptyStrings returns the paths of empty strings set on required +// fields. Those are kept: "" is a value the user chose for a field that must be +// sent, as opposed to an optional field left empty. The sdk-go based resource +// types mark every field omitempty, so required fields come from the generated +// validation metadata instead of struct tags. +func requiredEmptyStrings(root dyn.Value) ([]pathValue, error) { + trie := &dyn.TrieNode{} + for k := range generated.RequiredFields { + pattern, err := dyn.NewPatternFromString(k) + if err != nil { + return nil, err + } + if err := trie.Insert(pattern); err != nil { + return nil, err + } + } + var out []pathValue + err := dyn.WalkReadOnly(root, func(p dyn.Path, v dyn.Value) error { + pattern, ok := trie.SearchPath(p) + if !ok { + return nil + } + for _, field := range generated.RequiredFields[pattern.String()] { + fv := v.Get(field) + if s, ok := fv.AsString(); ok && s == "" { + out = append(out, pathValue{p.Append(dyn.Key(field)), fv}) + } + } + return nil + }) + return out, err +} + +type pathValue struct { + path dyn.Path + value dyn.Value +} diff --git a/bundle/config/mutator/expand_workspace_root.go b/bundle/config/mutator/expand_workspace_root.go index 2ec70548fed..51170911296 100644 --- a/bundle/config/mutator/expand_workspace_root.go +++ b/bundle/config/mutator/expand_workspace_root.go @@ -5,6 +5,8 @@ import ( "path" "strings" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/diag" ) @@ -27,12 +29,12 @@ func (m *expandWorkspaceRoot) Apply(ctx context.Context, b *bundle.Bundle) diag. } currentUser := b.Config.Workspace.CurrentUser - if currentUser == nil || currentUser.User == nil || currentUser.UserName == "" { + if currentUser == nil || currentUser.User == nil || utils.Deref(currentUser.UserName) == "" { return diag.Errorf("unable to expand workspace root: current user not set") } if strings.HasPrefix(root, "~/") { - home := "/Workspace/Users/" + currentUser.UserName + home := "/Workspace/Users/" + utils.Deref(currentUser.UserName) b.Config.Workspace.RootPath = path.Join(home, root[2:]) } diff --git a/bundle/config/mutator/expand_workspace_root_test.go b/bundle/config/mutator/expand_workspace_root_test.go index 5a2a183321d..43f6f25dd1d 100644 --- a/bundle/config/mutator/expand_workspace_root_test.go +++ b/bundle/config/mutator/expand_workspace_root_test.go @@ -6,7 +6,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/mutator" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -16,8 +16,8 @@ func TestExpandWorkspaceRoot(t *testing.T) { Config: config.Root{ Workspace: config.Workspace{ CurrentUser: &config.User{ - User: &iam.User{ - UserName: "jane@doe.com", + User: &scim.User{ + UserName: new("jane@doe.com"), }, }, RootPath: "~/foo", @@ -34,8 +34,8 @@ func TestExpandWorkspaceRootDoesNothing(t *testing.T) { Config: config.Root{ Workspace: config.Workspace{ CurrentUser: &config.User{ - User: &iam.User{ - UserName: "jane@doe.com", + User: &scim.User{ + UserName: new("jane@doe.com"), }, }, RootPath: "/Users/charly@doe.com/foo", @@ -52,8 +52,8 @@ func TestExpandWorkspaceRootWithoutRoot(t *testing.T) { Config: config.Root{ Workspace: config.Workspace{ CurrentUser: &config.User{ - User: &iam.User{ - UserName: "jane@doe.com", + User: &scim.User{ + UserName: new("jane@doe.com"), }, }, }, diff --git a/bundle/config/mutator/initialize_urls_test.go b/bundle/config/mutator/initialize_urls_test.go index e89d6de116c..7f2e4356a1b 100644 --- a/bundle/config/mutator/initialize_urls_test.go +++ b/bundle/config/mutator/initialize_urls_test.go @@ -3,18 +3,22 @@ package mutator import ( "testing" + "github.com/databricks/cli/libs/qualitymonitors" + "github.com/databricks/cli/libs/sdktypes/clusters/v2" + "github.com/databricks/cli/libs/sdktypes/experiments/v1" + "github.com/databricks/cli/libs/sdktypes/modelregistry/v1" + "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/modelserving/v1" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/serving" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" + sdkconfig "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/require" ) @@ -28,70 +32,70 @@ func TestInitializeURLs(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { ID: "1", - JobSettings: jobs.JobSettings{Name: "job1"}, + JobSettings: jobs.JobSettings{Name: new("job1")}, }, }, Pipelines: map[string]*resources.Pipeline{ "pipeline1": { - ID: "3", - CreatePipeline: pipelines.CreatePipeline{Name: "pipeline1"}, + ID: "3", + CreatePipelineRequest: pipelines.CreatePipelineRequest{Name: new("pipeline1")}, }, }, Experiments: map[string]*resources.MlflowExperiment{ "experiment1": { - ID: "4", - CreateExperiment: ml.CreateExperiment{Name: "experiment1"}, + ID: "4", + CreateExperimentRequest: experiments.CreateExperimentRequest{Name: new("experiment1")}, }, }, Models: map[string]*resources.MlflowModel{ "model1": { - ID: "a model uses its name for identifier", - CreateModelRequest: ml.CreateModelRequest{Name: "a model uses its name for identifier"}, + ID: "a model uses its name for identifier", + CreateRegisteredModelRequest: modelregistry.CreateRegisteredModelRequest{Name: new("a model uses its name for identifier")}, }, }, ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{ "servingendpoint1": { ID: "my_serving_endpoint", - CreateServingEndpoint: serving.CreateServingEndpoint{ - Name: "my_serving_endpoint", + CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{ + Name: new("my_serving_endpoint"), }, }, }, RegisteredModels: map[string]*resources.RegisteredModel{ "registeredmodel1": { ID: "8", - CreateRegisteredModelRequest: catalog.CreateRegisteredModelRequest{ - Name: "my_registered_model", + CreateRegisteredModelRequest: registeredmodels.CreateRegisteredModelRequest{ + Name: new("my_registered_model"), }, }, }, QualityMonitors: map[string]*resources.QualityMonitor{ "qualityMonitor1": { TableName: "catalog.schema.qualityMonitor1", - CreateMonitor: catalog.CreateMonitor{}, + CreateMonitor: qualitymonitors.CreateMonitor{}, }, }, VectorSearchIndexes: map[string]*resources.VectorSearchIndex{ "vectorsearchindex1": { ID: "catalog.schema.vectorsearchindex1", CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{ - Name: "catalog.schema.vectorsearchindex1", + Name: new("catalog.schema.vectorsearchindex1"), }, }, }, Schemas: map[string]*resources.Schema{ "schema1": { ID: "catalog.schema", - CreateSchema: catalog.CreateSchema{ - Name: "schema", + CreateSchema: resources.CreateSchema{ + Name: new("schema"), }, }, }, Clusters: map[string]*resources.Cluster{ "cluster1": { ID: "1017-103929-vlr7jzcf", - ClusterSpec: compute.ClusterSpec{ - ClusterName: "cluster1", + CreateClusterRequest: clusters.CreateClusterRequest{ + ClusterName: new("cluster1"), }, }, }, @@ -139,7 +143,7 @@ func TestInitializeURLsWithoutOrgId(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { ID: "1", - JobSettings: jobs.JobSettings{Name: "job1"}, + JobSettings: jobs.JobSettings{Name: new("job1")}, }, }, }, @@ -160,7 +164,7 @@ func TestInitializeURLsApplyNonNumericConfigPassedThrough(t *testing.T) { server := testserver.New(t) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{ + w, err := sdkclients.New(t.Context(), &sdkconfig.Config{ Host: server.URL, Token: "testtoken", WorkspaceID: "some-uuid-style-id", @@ -173,7 +177,7 @@ func TestInitializeURLsApplyNonNumericConfigPassedThrough(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { ID: "1", - JobSettings: jobs.JobSettings{Name: "job1"}, + JobSettings: jobs.JobSettings{Name: new("job1")}, }, }, }, @@ -201,7 +205,7 @@ func TestInitializeURLsApplyNoneSentinelResolvesViaAPI(t *testing.T) { testserver.AddDefaultHandlers(server) // /Me returns X-Databricks-Org-Id: 900800700600. - w, err := databricks.NewWorkspaceClient(&databricks.Config{ + w, err := sdkclients.New(t.Context(), &sdkconfig.Config{ Host: server.URL, Token: "testtoken", WorkspaceID: "none", @@ -214,7 +218,7 @@ func TestInitializeURLsApplyNoneSentinelResolvesViaAPI(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { ID: "1", - JobSettings: jobs.JobSettings{Name: "job1"}, + JobSettings: jobs.JobSettings{Name: new("job1")}, }, }, }, @@ -240,7 +244,7 @@ func TestInitializeURLsApplyErrorsOnNumericWorkspaceIDMismatch(t *testing.T) { testserver.AddDefaultHandlers(server) // /Me returns X-Databricks-Org-Id: 900800700600. - w, err := databricks.NewWorkspaceClient(&databricks.Config{ + w, err := sdkclients.New(t.Context(), &sdkconfig.Config{ Host: server.URL, Token: "testtoken", WorkspaceID: "12345", // numeric but does not match 900800700600 @@ -253,7 +257,7 @@ func TestInitializeURLsApplyErrorsOnNumericWorkspaceIDMismatch(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { ID: "1", - JobSettings: jobs.JobSettings{Name: "job1"}, + JobSettings: jobs.JobSettings{Name: new("job1")}, }, }, }, diff --git a/bundle/config/mutator/initialize_volume_paths.go b/bundle/config/mutator/initialize_volume_paths.go index 20ea9ae6b38..e743b09f61d 100644 --- a/bundle/config/mutator/initialize_volume_paths.go +++ b/bundle/config/mutator/initialize_volume_paths.go @@ -4,6 +4,8 @@ import ( "context" "fmt" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" @@ -46,9 +48,9 @@ func (m *initializeVolumePaths) Apply(_ context.Context, b *bundle.Bundle) diag. } // Resolve references to compute the path only; the field values in v are left untouched. - vol.CatalogName = resolveResourceReference(root, vol.CatalogName) - vol.SchemaName = resolveResourceReference(root, vol.SchemaName) - vol.Name = resolveResourceReference(root, vol.Name) + vol.CatalogName = new(resolveResourceReference(root, utils.Deref(vol.CatalogName))) + vol.SchemaName = new(resolveResourceReference(root, utils.Deref(vol.SchemaName))) + vol.Name = new(resolveResourceReference(root, utils.Deref(vol.Name))) return dyn.Set(v, "volume_path", dyn.V(vol.ComputeVolumePath())) }) diff --git a/bundle/config/mutator/initialize_volume_paths_test.go b/bundle/config/mutator/initialize_volume_paths_test.go index b624a99a813..f8cbdd802f8 100644 --- a/bundle/config/mutator/initialize_volume_paths_test.go +++ b/bundle/config/mutator/initialize_volume_paths_test.go @@ -3,10 +3,11 @@ package mutator import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/stretchr/testify/require" ) @@ -16,27 +17,27 @@ func TestInitializeVolumePaths(t *testing.T) { Resources: config.Resources{ Schemas: map[string]*resources.Schema{ "my": { - CreateSchema: catalog.CreateSchema{ - CatalogName: "main", - Name: "myschema", + CreateSchema: resources.CreateSchema{ + CatalogName: new("main"), + Name: new("myschema"), }, }, }, Volumes: map[string]*resources.Volume{ "bar": { - CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{ - CatalogName: "main", - SchemaName: "myschema", - Name: "volbar", + CreateVolumeRequestContent: resources.CreateVolumeRequestContent{ + CatalogName: new("main"), + SchemaName: new("myschema"), + Name: new("volbar"), }, }, // foo references the schema's name; InitializeVolumePaths resolves // it locally to compute the path without rewriting schema_name. "foo": { - CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{ - CatalogName: "main", - SchemaName: "${resources.schemas.my.name}", - Name: "volfoo", + CreateVolumeRequestContent: resources.CreateVolumeRequestContent{ + CatalogName: new("main"), + SchemaName: new("${resources.schemas.my.name}"), + Name: new("volfoo"), }, }, }, @@ -52,7 +53,7 @@ func TestInitializeVolumePaths(t *testing.T) { foo := b.Config.Resources.Volumes["foo"] require.Equal(t, "/Volumes/main/myschema/volfoo", foo.VolumePath) // The schema_name reference must be preserved, not replaced with the resolved value. - require.Equal(t, "${resources.schemas.my.name}", foo.SchemaName) + require.Equal(t, "${resources.schemas.my.name}", utils.Deref(foo.SchemaName)) } func TestInitializeVolumePaths_UnresolvedReference(t *testing.T) { @@ -63,10 +64,10 @@ func TestInitializeVolumePaths_UnresolvedReference(t *testing.T) { // The reference cannot be resolved locally, so it is embedded into // the path verbatim to be resolved later during plan or deploy. "foo": { - CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{ - CatalogName: "main", - SchemaName: "${resources.schemas.missing.name}", - Name: "volfoo", + CreateVolumeRequestContent: resources.CreateVolumeRequestContent{ + CatalogName: new("main"), + SchemaName: new("${resources.schemas.missing.name}"), + Name: new("volfoo"), }, }, }, @@ -78,7 +79,7 @@ func TestInitializeVolumePaths_UnresolvedReference(t *testing.T) { require.NoError(t, diags.Error()) require.Equal(t, "/Volumes/main/${resources.schemas.missing.name}/volfoo", b.Config.Resources.Volumes["foo"].VolumePath) // The schema_name reference itself must be preserved, not rewritten. - require.Equal(t, "${resources.schemas.missing.name}", b.Config.Resources.Volumes["foo"].SchemaName) + require.Equal(t, "${resources.schemas.missing.name}", utils.Deref(b.Config.Resources.Volumes["foo"].SchemaName)) } func TestInitializeVolumePaths_RejectsUserProvidedPath(t *testing.T) { @@ -87,10 +88,10 @@ func TestInitializeVolumePaths_RejectsUserProvidedPath(t *testing.T) { Resources: config.Resources{ Volumes: map[string]*resources.Volume{ "foo": { - CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{ - CatalogName: "main", - SchemaName: "myschema", - Name: "volfoo", + CreateVolumeRequestContent: resources.CreateVolumeRequestContent{ + CatalogName: new("main"), + SchemaName: new("myschema"), + Name: new("volfoo"), }, VolumePath: "/Volumes/bogus/path/set-by-user", }, @@ -109,18 +110,18 @@ func TestVolumePathPipeline_ResolvesCrossVolumeReference(t *testing.T) { Resources: config.Resources{ Volumes: map[string]*resources.Volume{ "bar": { - CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{ - CatalogName: "main", - SchemaName: "myschema", - Name: "volbar", + CreateVolumeRequestContent: resources.CreateVolumeRequestContent{ + CatalogName: new("main"), + SchemaName: new("myschema"), + Name: new("volbar"), }, }, "foo": { - CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{ - CatalogName: "main", - SchemaName: "myschema", - Name: "volfoo", - Comment: "${resources.volumes.bar.volume_path}", + CreateVolumeRequestContent: resources.CreateVolumeRequestContent{ + CatalogName: new("main"), + SchemaName: new("myschema"), + Name: new("volfoo"), + Comment: new("${resources.volumes.bar.volume_path}"), }, }, }, @@ -136,5 +137,5 @@ func TestVolumePathPipeline_ResolvesCrossVolumeReference(t *testing.T) { ) require.NoError(t, diags.Error()) require.Equal(t, "/Volumes/main/myschema/volbar", b.Config.Resources.Volumes["bar"].VolumePath) - require.Equal(t, "/Volumes/main/myschema/volbar", b.Config.Resources.Volumes["foo"].Comment) + require.Equal(t, "/Volumes/main/myschema/volbar", utils.Deref(b.Config.Resources.Volumes["foo"].Comment)) } diff --git a/bundle/config/mutator/load_dbalert_files.go b/bundle/config/mutator/load_dbalert_files.go index 437095aa218..16048137eba 100644 --- a/bundle/config/mutator/load_dbalert_files.go +++ b/bundle/config/mutator/load_dbalert_files.go @@ -13,9 +13,8 @@ import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/dynvar" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/sql" ) type loadDBAlertFiles struct{} @@ -29,7 +28,7 @@ func (m *loadDBAlertFiles) Name() string { } type AlertFile struct { - sql.AlertV2 + alerts.Alert // query_text and custom_description can be split into lines to make it easier to view the diff // in a Git editor. @@ -37,14 +36,6 @@ type AlertFile struct { CustomDescriptionLines []string `json:"custom_description_lines,omitempty"` } -func (d *AlertFile) UnmarshalJSON(data []byte) error { - return marshal.Unmarshal(data, d) -} - -func (d AlertFile) MarshalJSON() ([]byte, error) { - return marshal.Marshal(d) -} - func (m *loadDBAlertFiles) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { // Fields that are only settable in the API, and are not allowed in .dbalert.json. // We will only allow these fields to be set in the bundle YAML when an .dbalert.json is @@ -163,40 +154,28 @@ func (m *loadDBAlertFiles) Apply(ctx context.Context, b *bundle.Bundle) diag.Dia customDescription = sb.String() } - newAlert := sql.AlertV2{ - // Fields with different schema in file vs API. - CustomDescription: customDescription, - QueryText: queryText, - - // API only fields. All these should be present in [allowedInYAML] - DisplayName: alert.DisplayName, - WarehouseId: alert.WarehouseId, - - // Fields with the same schema in file vs API. - CustomSummary: dbalertFromFile.CustomSummary, - Schedule: dbalertFromFile.Schedule, - Evaluation: dbalertFromFile.Evaluation, - EffectiveRunAs: dbalertFromFile.EffectiveRunAs, - RunAs: dbalertFromFile.RunAs, - RunAsUserName: dbalertFromFile.RunAsUserName, - ParentPath: dbalertFromFile.ParentPath, - Parameters: dbalertFromFile.Parameters, - CustomTemplateFormat: dbalertFromFile.CustomTemplateFormat, - - // Output only fields. - CreateTime: dbalertFromFile.CreateTime, - OwnerUserName: dbalertFromFile.OwnerUserName, - UpdateTime: dbalertFromFile.UpdateTime, - LifecycleState: dbalertFromFile.LifecycleState, - - // Other fields. - Id: dbalertFromFile.Id, - ForceSendFields: dbalertFromFile.ForceSendFields, - } + // Fields with the same schema in file vs API are taken from the file as is. + newAlert := dbalertFromFile.Alert + + // Fields with different schema in file vs API. + newAlert.CustomDescription = nonEmpty(customDescription) + newAlert.QueryText = nonEmpty(queryText) + + // API only fields. All these should be present in [allowedInYAML] + newAlert.DisplayName = alert.DisplayName + newAlert.WarehouseId = alert.WarehouseId // write values from the file to the alert. - b.Config.Resources.Alerts[alertKey].AlertV2 = newAlert + b.Config.Resources.Alerts[alertKey].Alert = newAlert } return nil } + +// nonEmpty returns nil for an empty string so that it is omitted like an unset field. +func nonEmpty(s string) *string { + if s == "" { + return nil + } + return &s +} diff --git a/bundle/config/mutator/load_dbalert_files_test.go b/bundle/config/mutator/load_dbalert_files_test.go index 5e8a8d896e6..6a2cb08aa14 100644 --- a/bundle/config/mutator/load_dbalert_files_test.go +++ b/bundle/config/mutator/load_dbalert_files_test.go @@ -5,13 +5,15 @@ import ( "path/filepath" "testing" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/mutator" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/sql" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -56,9 +58,9 @@ func TestLoadDBAlertFiles(t *testing.T) { Alerts: map[string]*resources.Alert{ "my_alert": { FilePath: filepath.Join(dir, "alert.dbalert.json"), - AlertV2: sql.AlertV2{ - DisplayName: "Test Alert", - WarehouseId: "abc123", + Alert: alerts.Alert{ + DisplayName: new("Test Alert"), + WarehouseId: new("abc123"), }, }, }, @@ -75,9 +77,9 @@ func TestLoadDBAlertFiles(t *testing.T) { diags := bundle.Apply(t.Context(), b, mutator.LoadDBAlertFiles()) require.NoError(t, diags.Error()) - assert.Equal(t, "Test Alert", b.Config.Resources.Alerts["my_alert"].DisplayName) - assert.Equal(t, "abc123", b.Config.Resources.Alerts["my_alert"].WarehouseId) - assert.Equal(t, "SELECT * FROM table\nWHERE value > 100\n", b.Config.Resources.Alerts["my_alert"].QueryText) + assert.Equal(t, "Test Alert", utils.Deref(b.Config.Resources.Alerts["my_alert"].DisplayName)) + assert.Equal(t, "abc123", utils.Deref(b.Config.Resources.Alerts["my_alert"].WarehouseId)) + assert.Equal(t, "SELECT * FROM table\nWHERE value > 100\n", utils.Deref(b.Config.Resources.Alerts["my_alert"].QueryText)) } func TestLoadDBAlertFilesRelativeToBundleRoot(t *testing.T) { @@ -99,9 +101,9 @@ func TestLoadDBAlertFilesRelativeToBundleRoot(t *testing.T) { Alerts: map[string]*resources.Alert{ "my_alert": { FilePath: "alert.dbalert.json", - AlertV2: sql.AlertV2{ - DisplayName: "Test Alert", - WarehouseId: "abc123", + Alert: alerts.Alert{ + DisplayName: new("Test Alert"), + WarehouseId: new("abc123"), }, }, }, @@ -116,5 +118,5 @@ func TestLoadDBAlertFilesRelativeToBundleRoot(t *testing.T) { diags := bundle.Apply(t.Context(), b, mutator.LoadDBAlertFiles()) require.NoError(t, diags.Error()) - assert.Equal(t, "SELECT 1\n", b.Config.Resources.Alerts["my_alert"].QueryText) + assert.Equal(t, "SELECT 1\n", utils.Deref(b.Config.Resources.Alerts["my_alert"].QueryText)) } diff --git a/bundle/config/mutator/normalize_paths_test.go b/bundle/config/mutator/normalize_paths_test.go index 9c9085a27c6..78aff1c78e0 100644 --- a/bundle/config/mutator/normalize_paths_test.go +++ b/bundle/config/mutator/normalize_paths_test.go @@ -9,7 +9,7 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -22,10 +22,10 @@ func TestNormalizePaths(t *testing.T) { Resources: config.Resources{ Jobs: map[string]*resources.Job{ "job1": {JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "../src/notebook.py", + NotebookPath: new("../src/notebook.py"), }, }, }, diff --git a/bundle/config/mutator/paths/app_paths_visitor_test.go b/bundle/config/mutator/paths/app_paths_visitor_test.go index 9ec01aeaf83..052d2b606b9 100644 --- a/bundle/config/mutator/paths/app_paths_visitor_test.go +++ b/bundle/config/mutator/paths/app_paths_visitor_test.go @@ -6,7 +6,7 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/cli/libs/sdktypes/apps/v1" "github.com/stretchr/testify/assert" ) @@ -16,7 +16,7 @@ func TestAppPathsVisitor(t *testing.T) { Apps: map[string]*resources.App{ "app0": { App: apps.App{ - SourceCodePath: "foo", + SourceCodePath: new("foo"), }, }, }, diff --git a/bundle/config/mutator/paths/job_libraries_paths_visitor_test.go b/bundle/config/mutator/paths/job_libraries_paths_visitor_test.go index 07b3c6d6641..1a2b77c365f 100644 --- a/bundle/config/mutator/paths/job_libraries_paths_visitor_test.go +++ b/bundle/config/mutator/paths/job_libraries_paths_visitor_test.go @@ -6,52 +6,51 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" ) func TestVisitJobLibrariesPaths(t *testing.T) { - task0 := jobs.Task{ + task0 := jobs.TaskSettings{ NotebookTask: &jobs.NotebookTask{ - NotebookPath: "abc", + NotebookPath: new("abc"), }, } - task1 := jobs.Task{ + task1 := jobs.TaskSettings{ SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "abc", + PythonFile: new("abc"), }, } - task2 := jobs.Task{ + task2 := jobs.TaskSettings{ DbtTask: &jobs.DbtTask{ - ProjectDirectory: "abc", + ProjectDirectory: new("abc"), }, } - task3 := jobs.Task{ + task3 := jobs.TaskSettings{ SqlTask: &jobs.SqlTask{ File: &jobs.SqlTaskFile{ - Path: "abc", + Path: new("abc"), }, }, } - task4 := jobs.Task{ - Libraries: []compute.Library{ - {Whl: "dist/foo.whl"}, + task4 := jobs.TaskSettings{ + Libraries: []jobs.Library{ + {Whl: new("dist/foo.whl")}, }, } - task5 := jobs.Task{ - Libraries: []compute.Library{ - {Jar: "dist/foo.jar"}, + task5 := jobs.TaskSettings{ + Libraries: []jobs.Library{ + {Jar: new("dist/foo.jar")}, }, } - task6 := jobs.Task{ - Libraries: []compute.Library{ - {Requirements: "requirements.txt"}, + task6 := jobs.TaskSettings{ + Libraries: []jobs.Library{ + {Requirements: new("requirements.txt")}, }, } job0 := &resources.Job{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ task0, task1, task2, @@ -81,7 +80,7 @@ func TestVisitJobLibrariesPaths(t *testing.T) { func TestVisitJobLibrariesPaths_environments(t *testing.T) { environment0 := jobs.JobEnvironment{ - Spec: &compute.Environment{ + Spec: &jobs.Environment{ Dependencies: []string{ "dist_0/*.whl", "dist_1/*.whl", diff --git a/bundle/config/mutator/paths/job_paths_visitor_test.go b/bundle/config/mutator/paths/job_paths_visitor_test.go index b9fe29d154e..53e5e8dac2d 100644 --- a/bundle/config/mutator/paths/job_paths_visitor_test.go +++ b/bundle/config/mutator/paths/job_paths_visitor_test.go @@ -6,64 +6,63 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" ) func TestVisitJobPaths(t *testing.T) { - task0 := jobs.Task{ + task0 := jobs.TaskSettings{ NotebookTask: &jobs.NotebookTask{ - NotebookPath: "abc", + NotebookPath: new("abc"), }, } - task1 := jobs.Task{ + task1 := jobs.TaskSettings{ SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "abc", + PythonFile: new("abc"), }, } - task2 := jobs.Task{ + task2 := jobs.TaskSettings{ DbtTask: &jobs.DbtTask{ - ProjectDirectory: "abc", + ProjectDirectory: new("abc"), }, } - task3 := jobs.Task{ + task3 := jobs.TaskSettings{ SqlTask: &jobs.SqlTask{ File: &jobs.SqlTaskFile{ - Path: "abc", + Path: new("abc"), }, }, } - task4 := jobs.Task{ - Libraries: []compute.Library{ - {Whl: "dist/foo.whl"}, + task4 := jobs.TaskSettings{ + Libraries: []jobs.Library{ + {Whl: new("dist/foo.whl")}, }, } - task5 := jobs.Task{ - Libraries: []compute.Library{ - {Jar: "dist/foo.jar"}, + task5 := jobs.TaskSettings{ + Libraries: []jobs.Library{ + {Jar: new("dist/foo.jar")}, }, } - task6 := jobs.Task{ - Libraries: []compute.Library{ - {Requirements: "requirements.txt"}, + task6 := jobs.TaskSettings{ + Libraries: []jobs.Library{ + {Requirements: new("requirements.txt")}, }, } - task7 := jobs.Task{ + task7 := jobs.TaskSettings{ AlertTask: &jobs.AlertTask{ - WorkspacePath: "abc", + WorkspacePath: new("abc"), }, } - task8 := jobs.Task{ + task8 := jobs.TaskSettings{ AiRuntimeTask: &jobs.AiRuntimeTask{ Deployments: []jobs.DeploymentSpec{ - {CommandPath: "abc"}, + {CommandPath: new("abc")}, }, }, } job0 := &resources.Job{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ task0, task1, task2, @@ -100,7 +99,7 @@ func TestVisitJobPaths(t *testing.T) { func TestVisitJobPaths_environments(t *testing.T) { environment0 := jobs.JobEnvironment{ - Spec: &compute.Environment{ + Spec: &jobs.Environment{ Dependencies: []string{ "dist_0/*.whl", "dist_1/*.whl", @@ -110,8 +109,8 @@ func TestVisitJobPaths_environments(t *testing.T) { job0 := &resources.Job{ Environments: []jobs.JobEnvironment{ environment0, - {Spec: &compute.Environment{ProjectEnvironment: "../pyproject.toml"}}, - {Spec: &compute.Environment{ProjectEnvironment: "/Workspace/shared/pyproject.toml"}}, + {Spec: &jobs.Environment{ProjectEnvironment: new("../pyproject.toml")}}, + {Spec: &jobs.Environment{ProjectEnvironment: new("/Workspace/shared/pyproject.toml")}}, }, } @@ -136,7 +135,7 @@ func TestVisitJobPaths_environmentVariables(t *testing.T) { job0 := &resources.Job{ EnvironmentVariables: []jobs.JobEnvironmentVariables{ { - EnvironmentVariablesKey: "default", + EnvironmentVariablesKey: new("default"), Spec: &jobs.JobEnvironmentVariablesSpec{ Files: []string{ "./a.env", @@ -165,26 +164,26 @@ func TestVisitJobPaths_environmentVariables(t *testing.T) { } func TestVisitJobPaths_foreach(t *testing.T) { - task0 := jobs.Task{ + task0 := jobs.TaskSettings{ ForEachTask: &jobs.ForEachTask{ - Task: jobs.Task{ + Task: &jobs.TaskSettings{ NotebookTask: &jobs.NotebookTask{ - NotebookPath: "abc", + NotebookPath: new("abc"), }, }, }, } - task1 := jobs.Task{ + task1 := jobs.TaskSettings{ ForEachTask: &jobs.ForEachTask{ - Task: jobs.Task{ + Task: &jobs.TaskSettings{ AlertTask: &jobs.AlertTask{ - WorkspacePath: "abc", + WorkspacePath: new("abc"), }, }, }, } job0 := &resources.Job{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ task0, task1, }, diff --git a/bundle/config/mutator/paths/pipeline_paths_visitor_test.go b/bundle/config/mutator/paths/pipeline_paths_visitor_test.go index eb9748bba37..c5e0a95d55e 100644 --- a/bundle/config/mutator/paths/pipeline_paths_visitor_test.go +++ b/bundle/config/mutator/paths/pipeline_paths_visitor_test.go @@ -6,7 +6,7 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/stretchr/testify/assert" ) @@ -15,22 +15,22 @@ func TestVisitPipelinePaths(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "pipeline0": { - CreatePipeline: pipelines.CreatePipeline{ - RootPath: "src", + CreatePipelineRequest: pipelines.CreatePipelineRequest{ + RootPath: new("src"), Libraries: []pipelines.PipelineLibrary{ { - File: &pipelines.FileLibrary{ - Path: "dist/foo.whl", + File: &pipelines.NotebookLibrary{ + Path: new("dist/foo.whl"), }, }, { Notebook: &pipelines.NotebookLibrary{ - Path: "src/foo.py", + Path: new("src/foo.py"), }, }, { Glob: &pipelines.PathPattern{ - Include: "a/b/c/**", + Include: new("a/b/c/**"), }, }, }, diff --git a/bundle/config/mutator/populate_current_user.go b/bundle/config/mutator/populate_current_user.go index a00234912fa..69600e26209 100644 --- a/bundle/config/mutator/populate_current_user.go +++ b/bundle/config/mutator/populate_current_user.go @@ -8,8 +8,8 @@ import ( "github.com/databricks/cli/libs/cache" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/iamutil" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/databricks/cli/libs/tags" - "github.com/databricks/databricks-sdk-go/service/iam" ) type populateCurrentUser struct{} @@ -30,7 +30,7 @@ func (m *populateCurrentUser) Apply(ctx context.Context, b *bundle.Bundle) diag. w := b.WorkspaceClient(ctx) fingerprint := b.GetUserFingerprint(ctx) - me, err := cache.GetOrCompute(ctx, b.Cache, fingerprint, func(ctx context.Context) (*iam.User, error) { + me, err := cache.GetOrCompute(ctx, b.Cache, fingerprint, func(ctx context.Context) (*scim.User, error) { return iamutil.GetCurrentUser(ctx, w) }) if err != nil { diff --git a/bundle/config/mutator/prepend_workspace_prefix_test.go b/bundle/config/mutator/prepend_workspace_prefix_test.go index 6c439247051..4a75821f705 100644 --- a/bundle/config/mutator/prepend_workspace_prefix_test.go +++ b/bundle/config/mutator/prepend_workspace_prefix_test.go @@ -7,7 +7,7 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/stretchr/testify/require" ) @@ -91,8 +91,8 @@ func TestPrependWorkspaceForDefaultConfig(t *testing.T) { }, Workspace: config.Workspace{ CurrentUser: &config.User{ - User: &iam.User{ - UserName: "jane@doe.com", + User: &scim.User{ + UserName: new("jane@doe.com"), }, }, }, diff --git a/bundle/config/mutator/python/python_mutator_test.go b/bundle/config/mutator/python/python_mutator_test.go index f2c91749e87..2ca15140c4b 100644 --- a/bundle/config/mutator/python/python_mutator_test.go +++ b/bundle/config/mutator/python/python_mutator_test.go @@ -11,6 +11,8 @@ import ( "slices" "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn/convert" @@ -109,15 +111,15 @@ workspace: { current_user: { userName: test }}`) assert.ElementsMatch(t, []string{"job0", "job1"}, slices.Collect(maps.Keys(b.Config.Resources.Jobs))) if job0, ok := b.Config.Resources.Jobs["job0"]; ok { - assert.Equal(t, "job_0", job0.Name) + assert.Equal(t, "job_0", utils.Deref(job0.Name)) } if job1, ok := b.Config.Resources.Jobs["job1"]; ok { - assert.Equal(t, "job_1", job1.Name) + assert.Equal(t, "job_1", utils.Deref(job1.Name)) } if pipeline0, ok := b.Config.Resources.Jobs["pipeline0"]; ok { - assert.Equal(t, "pipeline_0", pipeline0.Name) + assert.Equal(t, "pipeline_0", utils.Deref(pipeline0.Name)) } // output of locations.json should be applied to underlying dyn.Value @@ -216,8 +218,8 @@ resources: assert.NoError(t, diag.Error()) assert.ElementsMatch(t, []string{"job0"}, slices.Collect(maps.Keys(b.Config.Resources.Jobs))) - assert.Equal(t, "job_0", b.Config.Resources.Jobs["job0"].Name) - assert.Equal(t, "my job", b.Config.Resources.Jobs["job0"].Description) + assert.Equal(t, "job_0", utils.Deref(b.Config.Resources.Jobs["job0"].Name)) + assert.Equal(t, "my job", utils.Deref(b.Config.Resources.Jobs["job0"].Description)) err := b.Config.Mutate(func(v dyn.Value) (dyn.Value, error) { // 'name' wasn't changed, so it keeps its location diff --git a/bundle/config/mutator/resolve_lookup_variables_test.go b/bundle/config/mutator/resolve_lookup_variables_test.go index 104a8ddd851..9fe6c0df8b4 100644 --- a/bundle/config/mutator/resolve_lookup_variables_test.go +++ b/bundle/config/mutator/resolve_lookup_variables_test.go @@ -8,13 +8,9 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/variable" "github.com/databricks/cli/libs/env" - "github.com/stretchr/testify/mock" + "github.com/databricks/cli/libs/testserver" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/listing" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/iam" ) func TestResolveClusterReference(t *testing.T) { @@ -41,17 +37,15 @@ func TestResolveClusterReference(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) - clusterApi := m.GetMockClustersAPI() - clusterApi.EXPECT().ListAll(mock.Anything, compute.ListClustersRequest{ - FilterBy: &compute.ListClustersFilterBy{ - ClusterSources: []compute.ClusterSource{compute.ClusterSourceApi, compute.ClusterSourceUi}, - }, - }).Return([]compute.ClusterDetails{ - {ClusterId: "1234-5678-abcd", ClusterName: clusterRef1}, - {ClusterId: "9876-5432-xywz", ClusterName: clusterRef2}, - }, nil) + server := testserver.New(t) + server.Handle("GET", "/api/2.1/clusters/list", func(req testserver.Request) any { + assert.Equal(t, []string{"API", "UI"}, req.URL.Query()["filter_by.cluster_sources"]) + return map[string]any{"clusters": []map[string]any{ + {"cluster_id": "1234-5678-abcd", "cluster_name": clusterRef1}, + {"cluster_id": "9876-5432-xywz", "cluster_name": clusterRef2}, + }} + }) + b.SetWorkpaceClient(newTestClients(t, server)) diags := bundle.Apply(t.Context(), b, ResolveLookupVariables()) require.NoError(t, diags.Error()) @@ -77,16 +71,14 @@ func TestResolveNonExistentClusterReference(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) - clusterApi := m.GetMockClustersAPI() - clusterApi.EXPECT().ListAll(mock.Anything, compute.ListClustersRequest{ - FilterBy: &compute.ListClustersFilterBy{ - ClusterSources: []compute.ClusterSource{compute.ClusterSourceApi, compute.ClusterSourceUi}, - }, - }).Return([]compute.ClusterDetails{ - {ClusterId: "1234-5678-abcd", ClusterName: "some other cluster"}, - }, nil) + server := testserver.New(t) + server.Handle("GET", "/api/2.1/clusters/list", func(req testserver.Request) any { + assert.Equal(t, []string{"API", "UI"}, req.URL.Query()["filter_by.cluster_sources"]) + return map[string]any{"clusters": []map[string]any{ + {"cluster_id": "1234-5678-abcd", "cluster_name": "some other cluster"}, + }} + }) + b.SetWorkpaceClient(newTestClients(t, server)) diags := bundle.Apply(t.Context(), b, ResolveLookupVariables()) require.ErrorContains(t, diags.Error(), "failed to resolve cluster: Random, err: cluster named 'Random' does not exist") @@ -106,8 +98,7 @@ func TestNoLookupIfVariableIsSet(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) + b.SetWorkpaceClient(newTestClients(t, testserver.New(t))) err := b.Config.Variables["my-cluster-id"].Set("random value") require.NoError(t, err) @@ -131,20 +122,12 @@ func TestResolveServicePrincipal(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) - - api := m.GetMockServicePrincipalsV2API() - iterator := listing.SliceIterator[iam.ServicePrincipal]([]iam.ServicePrincipal{ - { - ApplicationId: "app-1234", - }, + server := testserver.New(t) + server.Handle("GET", "/api/2.0/preview/scim/v2/ServicePrincipals", func(req testserver.Request) any { + assert.Equal(t, fmt.Sprintf("displayName eq '%s'", spName), req.URL.Query().Get("filter")) + return map[string]any{"Resources": []map[string]any{{"applicationId": "app-1234"}}} }) - api.EXPECT(). - List(mock.Anything, iam.ListServicePrincipalsRequest{ - Filter: fmt.Sprintf("displayName eq '%s'", spName), - }). - Return(&iterator) + b.SetWorkpaceClient(newTestClients(t, server)) diags := bundle.Apply(t.Context(), b, ResolveLookupVariables()) require.NoError(t, diags.Error()) @@ -171,18 +154,15 @@ func TestResolveVariableReferencesInVariableLookups(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) - clusterApi := m.GetMockClustersAPI() - - clusterApi.EXPECT().ListAll(mock.Anything, compute.ListClustersRequest{ - FilterBy: &compute.ListClustersFilterBy{ - ClusterSources: []compute.ClusterSource{compute.ClusterSourceApi, compute.ClusterSourceUi}, - }, - }).Return([]compute.ClusterDetails{ - {ClusterId: "1234-5678-abcd", ClusterName: "cluster-bar-dev"}, - {ClusterId: "9876-5432-xywz", ClusterName: "some other cluster"}, - }, nil) + server := testserver.New(t) + server.Handle("GET", "/api/2.1/clusters/list", func(req testserver.Request) any { + assert.Equal(t, []string{"API", "UI"}, req.URL.Query()["filter_by.cluster_sources"]) + return map[string]any{"clusters": []map[string]any{ + {"cluster_id": "1234-5678-abcd", "cluster_name": "cluster-bar-dev"}, + {"cluster_id": "9876-5432-xywz", "cluster_name": "some other cluster"}, + }} + }) + b.SetWorkpaceClient(newTestClients(t, server)) diags := bundle.ApplySeq(t.Context(), b, ResolveVariableReferencesInLookup(), ResolveLookupVariables()) require.NoError(t, diags.Error()) @@ -208,8 +188,7 @@ func TestResolveLookupVariableReferencesInVariableLookups(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) + b.SetWorkpaceClient(newTestClients(t, testserver.New(t))) diags := bundle.ApplySeq(t.Context(), b, ResolveVariableReferencesInLookup(), ResolveLookupVariables()) require.ErrorContains(t, diags.Error(), "lookup variables cannot contain references to another lookup variables") @@ -231,8 +210,7 @@ func TestNoResolveLookupIfVariableSetWithEnvVariable(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) + b.SetWorkpaceClient(newTestClients(t, testserver.New(t))) ctx := t.Context() ctx = env.Set(ctx, "BUNDLE_VAR_lookup", "1234-5678-abcd") diff --git a/bundle/config/mutator/resolve_variable_references_test.go b/bundle/config/mutator/resolve_variable_references_test.go index 284b78846b4..16a9bee1f99 100644 --- a/bundle/config/mutator/resolve_variable_references_test.go +++ b/bundle/config/mutator/resolve_variable_references_test.go @@ -3,11 +3,13 @@ package mutator import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/stretchr/testify/require" ) @@ -48,7 +50,7 @@ func TestResolveVariableReferencesWithSourceLinkedDeployment(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "pipeline1": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Configuration: map[string]string{ "source": "${workspace.file_path}", }, @@ -80,13 +82,13 @@ func TestResolveVolumePathReferencesOnlyResources(t *testing.T) { }, } - b.Config.Resources.Volumes["volumePathRef"].Comment = "${resources.volumes.foo.volume_path}" - b.Config.Resources.Volumes["otherRef"].Comment = "${resources.volumes.foo.name}" + b.Config.Resources.Volumes["volumePathRef"].Comment = new("${resources.volumes.foo.volume_path}") + b.Config.Resources.Volumes["otherRef"].Comment = new("${resources.volumes.foo.name}") diags := bundle.Apply(t.Context(), b, ResolveVolumePathReferencesOnlyResources()) require.NoError(t, diags.Error()) - require.Equal(t, "/Volumes/main/myschema/myvolume", b.Config.Resources.Volumes["volumePathRef"].Comment) - require.Equal(t, "${resources.volumes.foo.name}", b.Config.Resources.Volumes["otherRef"].Comment) + require.Equal(t, "/Volumes/main/myschema/myvolume", utils.Deref(b.Config.Resources.Volumes["volumePathRef"].Comment)) + require.Equal(t, "${resources.volumes.foo.name}", utils.Deref(b.Config.Resources.Volumes["otherRef"].Comment)) } func TestResolveVolumePathReferencesOnlyResources_MissingTarget(t *testing.T) { @@ -99,7 +101,7 @@ func TestResolveVolumePathReferencesOnlyResources_MissingTarget(t *testing.T) { }, }, } - b.Config.Resources.Volumes["foo"].Comment = "${resources.volumes.missing.volume_path}" + b.Config.Resources.Volumes["foo"].Comment = new("${resources.volumes.missing.volume_path}") diags := bundle.Apply(t.Context(), b, ResolveVolumePathReferencesOnlyResources()) require.ErrorContains(t, diags.Error(), "reference does not exist: ${resources.volumes.missing.volume_path}") diff --git a/bundle/config/mutator/resourcemutator/apply_bundle_permissions.go b/bundle/config/mutator/resourcemutator/apply_bundle_permissions.go index f2a6d857090..a1697ba843d 100644 --- a/bundle/config/mutator/resourcemutator/apply_bundle_permissions.go +++ b/bundle/config/mutator/resourcemutator/apply_bundle_permissions.go @@ -14,7 +14,6 @@ import ( "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/convert" "github.com/databricks/cli/libs/logdiag" - "github.com/databricks/databricks-sdk-go/service/iam" ) var ( @@ -200,7 +199,7 @@ func convertPermissions( } permissions = append(permissions, resources.Permission{ - Level: iam.PermissionLevel(level), + Level: resources.PermissionLevel(level), UserName: p.UserName, GroupName: p.GroupName, ServicePrincipalName: p.ServicePrincipalName, diff --git a/bundle/config/mutator/resourcemutator/apply_bundle_permissions_test.go b/bundle/config/mutator/resourcemutator/apply_bundle_permissions_test.go index c71bb2c5834..65c7a07eb8f 100644 --- a/bundle/config/mutator/resourcemutator/apply_bundle_permissions_test.go +++ b/bundle/config/mutator/resourcemutator/apply_bundle_permissions_test.go @@ -11,7 +11,7 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -59,12 +59,12 @@ func TestApplyBundlePermissions(t *testing.T) { Jobs: map[string]*resources.Job{ "job_1": { JobSettings: jobs.JobSettings{ - Name: "job_1", + Name: new("job_1"), }, }, "job_2": { JobSettings: jobs.JobSettings{ - Name: "job_2", + Name: new("job_2"), }, }, }, @@ -188,7 +188,7 @@ func TestWarningOnOverlapPermission(t *testing.T) { Jobs: map[string]*resources.Job{ "job_1": { JobSettings: jobs.JobSettings{ - Name: "job_1", + Name: new("job_1"), }, Permissions: []resources.JobPermission{ {Level: "CAN_VIEW", UserName: "TestUser"}, @@ -196,7 +196,7 @@ func TestWarningOnOverlapPermission(t *testing.T) { }, "job_2": { JobSettings: jobs.JobSettings{ - Name: "job_2", + Name: new("job_2"), }, Permissions: []resources.JobPermission{ {Level: "CAN_VIEW", UserName: "TestUser2"}, diff --git a/bundle/config/mutator/resourcemutator/apply_default_task_source.go b/bundle/config/mutator/resourcemutator/apply_default_task_source.go index 30e000b1fb1..def63603825 100644 --- a/bundle/config/mutator/resourcemutator/apply_default_task_source.go +++ b/bundle/config/mutator/resourcemutator/apply_default_task_source.go @@ -6,7 +6,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" ) type applyDefaultTaskSource struct{} @@ -86,7 +86,7 @@ func setGitTaskSource(task dyn.Value) (dyn.Value, error) { continue } if _, err := dyn.Get(t, "source"); err != nil { - return dyn.Set(task, taskType+".source", dyn.V(string(jobs.SourceGit))) + return dyn.Set(task, taskType+".source", dyn.V(string(jobs.Source_Git))) } } return task, nil diff --git a/bundle/config/mutator/resourcemutator/apply_default_task_source_test.go b/bundle/config/mutator/resourcemutator/apply_default_task_source_test.go index 7bdcc76ed41..b45b190de12 100644 --- a/bundle/config/mutator/resourcemutator/apply_default_task_source_test.go +++ b/bundle/config/mutator/resourcemutator/apply_default_task_source_test.go @@ -6,7 +6,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -18,13 +18,13 @@ func TestApplyDefaultTaskSourceGitJob(t *testing.T) { Jobs: map[string]*resources.Job{ "git": { JobSettings: jobs.JobSettings{ - GitSource: &jobs.GitSource{GitUrl: "https://example.invalid/repo", GitProvider: "gitHub", GitBranch: "main"}, - Tasks: []jobs.Task{ - {TaskKey: "py", SparkPythonTask: &jobs.SparkPythonTask{PythonFile: "src/main.py"}}, - {TaskKey: "nb_explicit", NotebookTask: &jobs.NotebookTask{NotebookPath: "nb", Source: jobs.SourceWorkspace}}, - {TaskKey: "foreach", ForEachTask: &jobs.ForEachTask{Task: jobs.Task{ - TaskKey: "inner", - SparkPythonTask: &jobs.SparkPythonTask{PythonFile: "src/inner.py"}, + GitSource: &jobs.GitSource{GitUrl: new("https://example.invalid/repo"), GitProvider: new("gitHub"), GitBranch: new("main")}, + Tasks: []jobs.TaskSettings{ + {TaskKey: new("py"), SparkPythonTask: &jobs.SparkPythonTask{PythonFile: new("src/main.py")}}, + {TaskKey: new("nb_explicit"), NotebookTask: &jobs.NotebookTask{NotebookPath: new("nb"), Source: jobs.Source_Workspace}}, + {TaskKey: new("foreach"), ForEachTask: &jobs.ForEachTask{Task: &jobs.TaskSettings{ + TaskKey: new("inner"), + SparkPythonTask: &jobs.SparkPythonTask{PythonFile: new("src/inner.py")}, }}}, }, }, @@ -39,11 +39,11 @@ func TestApplyDefaultTaskSourceGitJob(t *testing.T) { tasks := b.Config.Resources.Jobs["git"].Tasks // Unset source on a git job is defaulted to GIT. - assert.Equal(t, jobs.SourceGit, tasks[0].SparkPythonTask.Source) + assert.Equal(t, jobs.Source_Git, tasks[0].SparkPythonTask.Source) // An explicit source is preserved. - assert.Equal(t, jobs.SourceWorkspace, tasks[1].NotebookTask.Source) + assert.Equal(t, jobs.Source_Workspace, tasks[1].NotebookTask.Source) // The nested for_each task is handled too. - assert.Equal(t, jobs.SourceGit, tasks[2].ForEachTask.Task.SparkPythonTask.Source) + assert.Equal(t, jobs.Source_Git, tasks[2].ForEachTask.Task.SparkPythonTask.Source) } func TestApplyDefaultTaskSourceNullGitSourceUntouched(t *testing.T) { @@ -77,8 +77,8 @@ func TestApplyDefaultTaskSourceNonGitJobUntouched(t *testing.T) { Jobs: map[string]*resources.Job{ "plain": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ - {TaskKey: "py", SparkPythonTask: &jobs.SparkPythonTask{PythonFile: "/Workspace/main.py"}}, + Tasks: []jobs.TaskSettings{ + {TaskKey: new("py"), SparkPythonTask: &jobs.SparkPythonTask{PythonFile: new("/Workspace/main.py")}}, }, }, }, diff --git a/bundle/config/mutator/resourcemutator/apply_presets.go b/bundle/config/mutator/resourcemutator/apply_presets.go index bb84240d7cc..5465b9f8cad 100644 --- a/bundle/config/mutator/resourcemutator/apply_presets.go +++ b/bundle/config/mutator/resourcemutator/apply_presets.go @@ -11,11 +11,14 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/metrics" "github.com/databricks/cli/libs/diag" + "github.com/databricks/cli/libs/qualitymonitors" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/sdktypes/experiments/v1" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/modelregistry/v1" + "github.com/databricks/cli/libs/sdktypes/warehouses/v1" "github.com/databricks/cli/libs/textutil" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/utils" ) type applyPresets struct{} @@ -59,7 +62,7 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos if j == nil { continue } - j.Name = prefix + j.Name + j.Name = addPrefix(prefix, j.Name) if len(tags) > 0 { if j.Tags == nil { // Note: only create this map if tags is not empty, to avoid inserting "tags: {}" entry in the config @@ -71,13 +74,15 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos } } } - if j.MaxConcurrentRuns == 0 { - j.MaxConcurrentRuns = t.JobsMaxConcurrentRuns + if utils.Deref(j.MaxConcurrentRuns) == 0 && t.JobsMaxConcurrentRuns != 0 { + j.MaxConcurrentRuns = new(t.JobsMaxConcurrentRuns) } if t.TriggerPauseStatus != "" { - paused := jobs.PauseStatusPaused + paused := jobs.SchedulePauseStatus_Paused if t.TriggerPauseStatus == config.Unpaused { - paused = jobs.PauseStatusUnpaused + // sdk-go models UNPAUSED as the enum's zero value; the API accepts + // the explicit value and the bundle configuration keeps it. + paused = jobs.SchedulePauseStatus("UNPAUSED") } if j.Schedule != nil && j.Schedule.PauseStatus == "" { @@ -97,14 +102,16 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos if p == nil { continue } - p.Name = prefix + p.Name + p.Name = addPrefix(prefix, p.Name) if config.IsExplicitlyEnabled(t.PipelinesDevelopment) { //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field - p.Development = true + p.Development = new(true) } if t.TriggerPauseStatus == config.Paused { //nolint:staticcheck // SA1019: pipeline continuous is deprecated in the SDK but remains a supported bundle config field - p.Continuous = false + if utils.Deref(p.Continuous) { + p.Continuous = nil + } } if len(tags) > 0 { @@ -125,14 +132,14 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos if m == nil { continue } - m.Name = prefix + m.Name + m.Name = addPrefix(prefix, m.Name) for _, t := range tags { - exists := slices.ContainsFunc(m.Tags, func(modelTag ml.ModelTag) bool { - return modelTag.Key == t.Key + exists := slices.ContainsFunc(m.Tags, func(modelTag modelregistry.RegisteredModelTag) bool { + return utils.Deref(modelTag.Key) == t.Key }) if !exists { // Only add this tag if the resource didn't include any tag that overrides its value. - m.Tags = append(m.Tags, ml.ModelTag{Key: t.Key, Value: t.Value}) + m.Tags = append(m.Tags, modelregistry.RegisteredModelTag{Key: new(t.Key), Value: new(t.Value)}) } } } @@ -142,24 +149,24 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos if e == nil { continue } - filepath := e.Name + filepath := utils.Deref(e.Name) dir := path.Dir(filepath) base := path.Base(filepath) if dir == "." { - e.Name = prefix + base + e.Name = addPrefix(prefix, new(base)) } else { - e.Name = dir + "/" + prefix + base + e.Name = new(dir + "/" + prefix + base) } for _, t := range tags { exists := false for _, experimentTag := range e.Tags { - if experimentTag.Key == t.Key { + if utils.Deref(experimentTag.Key) == t.Key { exists = true break } } if !exists { - e.Tags = append(e.Tags, ml.ExperimentTag{Key: t.Key, Value: t.Value}) + e.Tags = append(e.Tags, experiments.ExperimentTag{Key: new(t.Key), Value: new(t.Value)}) } } } @@ -169,7 +176,7 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos if e == nil { continue } - e.Name = normalizePrefix(prefix) + e.Name + e.Name = addPrefix(normalizePrefix(prefix), e.Name) // As of 2024-06, model serving endpoints don't yet support tags } @@ -179,7 +186,7 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos if m == nil { continue } - m.Name = normalizePrefix(prefix) + m.Name + m.Name = addPrefix(normalizePrefix(prefix), m.Name) // As of 2024-06, registered models don't yet support tags } @@ -193,7 +200,7 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos // Remove all schedules from monitors, since they don't support pausing/unpausing. // Quality monitors might support the "pause" property in the future, so at the // CLI level we do respect that property if it is set to "unpaused." - if q.Schedule != nil && q.Schedule.PauseStatus != catalog.MonitorCronSchedulePauseStatusUnpaused { + if q.Schedule != nil && q.Schedule.PauseStatus != qualitymonitors.MonitorCronSchedulePauseStatusUnpaused { q.Schedule = nil } } @@ -208,7 +215,7 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos if s == nil { continue } - s.Name = normalizePrefix(prefix) + s.Name + s.Name = addPrefix(normalizePrefix(prefix), s.Name) // HTTP API for schemas doesn't yet support tags. It's only supported in // the Databricks UI and via the SQL API. } @@ -218,7 +225,7 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos if c == nil { continue } - c.ClusterName = prefix + c.ClusterName + c.ClusterName = addPrefix(prefix, c.ClusterName) if len(tags) > 0 { if c.CustomTags == nil { c.CustomTags = make(map[string]string, len(tags)) @@ -238,7 +245,7 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos if pool == nil { continue } - pool.InstancePoolName = prefix + pool.InstancePoolName + pool.InstancePoolName = addPrefix(prefix, pool.InstancePoolName) if len(tags) > 0 { if pool.CustomTags == nil { pool.CustomTags = make(map[string]string, len(tags)) @@ -276,14 +283,14 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos if a == nil { continue } - a.DisplayName = prefix + a.DisplayName + a.DisplayName = addPrefix(prefix, a.DisplayName) if t.TriggerPauseStatus != "" { - paused := sql.SchedulePauseStatusPaused + paused := alerts.SchedulePauseStatus_Paused if t.TriggerPauseStatus == config.Unpaused { - paused = sql.SchedulePauseStatusUnpaused + paused = alerts.SchedulePauseStatus_Unpaused } // Only set pause status if a schedule is defined and pause status is not already set - if a.Schedule.QuartzCronSchedule != "" && a.Schedule.PauseStatus == "" { + if a.Schedule != nil && utils.Deref(a.Schedule.QuartzCronSchedule) != "" && a.Schedule.PauseStatus == "" { a.Schedule.PauseStatus = paused } } @@ -294,10 +301,10 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos if w == nil { continue } - w.Name = prefix + w.Name + w.Name = addPrefix(prefix, w.Name) if len(tags) > 0 { if w.Tags == nil { - w.Tags = &sql.EndpointTags{} + w.Tags = &warehouses.EndpointTags{} } for _, tag := range tags { normalisedKey := b.Tagging.NormalizeKey(tag.Key) @@ -306,16 +313,16 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos // Check if the tag already exists exists := false for _, t := range w.Tags.CustomTags { - if t.Key == normalisedKey { + if utils.Deref(t.Key) == normalisedKey { exists = true break } } if !exists { - w.Tags.CustomTags = append(w.Tags.CustomTags, sql.EndpointTagPair{ - Key: normalisedKey, - Value: normalisedValue, + w.Tags.CustomTags = append(w.Tags.CustomTags, warehouses.EndpointTagPair{ + Key: new(normalisedKey), + Value: new(normalisedValue), }) } } @@ -329,7 +336,7 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos if cp == nil { continue } - cp.Name = prefix + cp.Name + cp.Name = addPrefix(prefix, cp.Name) } // Vector Search Endpoints: no prefix. The endpoint name is the primary key @@ -356,6 +363,15 @@ func validatePauseStatus(b *bundle.Bundle) diag.Diagnostics { }} } +// addPrefix returns name with prefix prepended. A missing name stays missing +// when there is no prefix, so the preset does not materialize an empty name. +func addPrefix(prefix string, name *string) *string { + if prefix == "" { + return name + } + return new(prefix + utils.Deref(name)) +} + // toTagArray converts a map of tags to an array of tags. // We sort tags so ensure stable ordering. func toTagArray(tags map[string]string) []Tag { diff --git a/bundle/config/mutator/resourcemutator/apply_presets_test.go b/bundle/config/mutator/resourcemutator/apply_presets_test.go index c97db137b26..c9dd3153258 100644 --- a/bundle/config/mutator/resourcemutator/apply_presets_test.go +++ b/bundle/config/mutator/resourcemutator/apply_presets_test.go @@ -3,10 +3,11 @@ package resourcemutator import ( "testing" + "github.com/databricks/cli/libs/qualitymonitors" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -24,9 +25,9 @@ func TestApplyPresetsSkipsNilQualityMonitors(t *testing.T) { "nil_monitor": nil, "monitor": { TableName: "monitor", - CreateMonitor: catalog.CreateMonitor{ + CreateMonitor: qualitymonitors.CreateMonitor{ OutputSchemaName: "catalog.schema", - Schedule: &catalog.MonitorCronSchedule{}, + Schedule: &qualitymonitors.MonitorCronSchedule{}, }, }, }, diff --git a/bundle/config/mutator/resourcemutator/apply_target_mode_test.go b/bundle/config/mutator/resourcemutator/apply_target_mode_test.go index b43c1f18e8c..412b0752f16 100644 --- a/bundle/config/mutator/resourcemutator/apply_target_mode_test.go +++ b/bundle/config/mutator/resourcemutator/apply_target_mode_test.go @@ -5,25 +5,33 @@ import ( "slices" "testing" - "github.com/databricks/databricks-sdk-go/service/database" + "github.com/databricks/cli/libs/qualitymonitors" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2" + "github.com/databricks/cli/libs/sdktypes/clusters/v2" + "github.com/databricks/cli/libs/sdktypes/experiments/v1" + "github.com/databricks/cli/libs/sdktypes/instancepools/v2" + "github.com/databricks/cli/libs/sdktypes/modelregistry/v1" + "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1" + ucsecrets "github.com/databricks/cli/libs/sdktypes/uc/secrets/v1" + "github.com/databricks/cli/libs/sdktypes/warehouses/v1" + "github.com/databricks/cli/libs/utils" + + "github.com/databricks/cli/libs/sdktypes/database/v1" "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/modelserving/v1" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" "github.com/databricks/cli/libs/tags" "github.com/databricks/cli/libs/vfs" sdkconfig "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/service/apps" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/postgres" - "github.com/databricks/databricks-sdk-go/service/serving" - "github.com/databricks/databricks-sdk-go/service/sql" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -44,9 +52,9 @@ func mockBundle(mode config.Mode) *bundle.Bundle { Workspace: config.Workspace{ CurrentUser: &config.User{ ShortName: "lennart", - User: &iam.User{ - UserName: "lennart@company.com", - Id: "1", + User: &scim.User{ + UserName: new("lennart@company.com"), + Id: new("1"), }, }, StatePath: "/Users/lennart@company.com/.bundle/x/y/state", @@ -57,56 +65,56 @@ func mockBundle(mode config.Mode) *bundle.Bundle { Jobs: map[string]*resources.Job{ "job1": { JobSettings: jobs.JobSettings{ - Name: "job1", + Name: new("job1"), Schedule: &jobs.CronSchedule{ - QuartzCronExpression: "* * * * *", + QuartzCronExpression: new("* * * * *"), }, Tags: map[string]string{"existing": "tag"}, }, }, "job2": { JobSettings: jobs.JobSettings{ - Name: "job2", + Name: new("job2"), Schedule: &jobs.CronSchedule{ - QuartzCronExpression: "* * * * *", - PauseStatus: jobs.PauseStatusUnpaused, + QuartzCronExpression: new("* * * * *"), + PauseStatus: jobs.SchedulePauseStatus("UNPAUSED"), }, }, }, "job3": { JobSettings: jobs.JobSettings{ - Name: "job3", + Name: new("job3"), Trigger: &jobs.TriggerSettings{ FileArrival: &jobs.FileArrivalTriggerConfiguration{ - Url: "test.com", + Url: new("test.com"), }, }, }, }, "job4": { JobSettings: jobs.JobSettings{ - Name: "job4", - Continuous: &jobs.Continuous{ - PauseStatus: jobs.PauseStatusPaused, + Name: new("job4"), + Continuous: &jobs.ContinuousSettings{ + PauseStatus: jobs.SchedulePauseStatus_Paused, }, }, }, }, JobRuns: map[string]*resources.JobRun{ - "job_run1": {RunNow: jobs.RunNow{JobId: 1234}}, + "job_run1": {RunNowRequest: jobs.RunNowRequest{JobId: new(int64(1234))}}, }, Pipelines: map[string]*resources.Pipeline{ - "pipeline1": {CreatePipeline: pipelines.CreatePipeline{Name: "pipeline1", Continuous: true}}, //nolint:staticcheck // SA1019: pipeline continuous is deprecated in the SDK but remains a supported bundle config field + "pipeline1": {CreatePipelineRequest: pipelines.CreatePipelineRequest{Name: new("pipeline1"), Continuous: new(true)}}, //nolint:staticcheck // SA1019: pipeline continuous is deprecated in the SDK but remains a supported bundle config field }, Experiments: map[string]*resources.MlflowExperiment{ - "experiment1": {CreateExperiment: ml.CreateExperiment{Name: "/Users/lennart.kats@databricks.com/experiment1"}}, - "experiment2": {CreateExperiment: ml.CreateExperiment{Name: "experiment2"}}, + "experiment1": {CreateExperimentRequest: experiments.CreateExperimentRequest{Name: new("/Users/lennart.kats@databricks.com/experiment1")}}, + "experiment2": {CreateExperimentRequest: experiments.CreateExperimentRequest{Name: new("experiment2")}}, }, Models: map[string]*resources.MlflowModel{ - "model1": {CreateModelRequest: ml.CreateModelRequest{Name: "model1"}}, + "model1": {CreateRegisteredModelRequest: modelregistry.CreateRegisteredModelRequest{Name: new("model1")}}, }, ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{ - "servingendpoint1": {CreateServingEndpoint: serving.CreateServingEndpoint{Name: "servingendpoint1"}}, + "servingendpoint1": {CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{Name: new("servingendpoint1")}}, }, ModelServices: map[string]*resources.ModelService{ "modelservice1": {ModelServiceConfig: resources.ModelServiceConfig{Parent: "schemas/main.default", ModelServiceId: "modelservice1"}}, @@ -118,52 +126,52 @@ func mockBundle(mode config.Mode) *bundle.Bundle { "modelproviderservice1": {ModelProviderServiceConfig: resources.ModelProviderServiceConfig{Parent: "schemas/main.default", ModelProviderServiceId: "modelproviderservice1"}}, }, RegisteredModels: map[string]*resources.RegisteredModel{ - "registeredmodel1": {CreateRegisteredModelRequest: catalog.CreateRegisteredModelRequest{Name: "registeredmodel1"}}, + "registeredmodel1": {CreateRegisteredModelRequest: registeredmodels.CreateRegisteredModelRequest{Name: new("registeredmodel1")}}, }, QualityMonitors: map[string]*resources.QualityMonitor{ "qualityMonitor1": { TableName: "qualityMonitor1", - CreateMonitor: catalog.CreateMonitor{ + CreateMonitor: qualitymonitors.CreateMonitor{ OutputSchemaName: "catalog.schema", }, }, "qualityMonitor2": { TableName: "qualityMonitor2", - CreateMonitor: catalog.CreateMonitor{ + CreateMonitor: qualitymonitors.CreateMonitor{ OutputSchemaName: "catalog.schema", - Schedule: &catalog.MonitorCronSchedule{}, + Schedule: &qualitymonitors.MonitorCronSchedule{}, }, }, "qualityMonitor3": { TableName: "qualityMonitor3", - CreateMonitor: catalog.CreateMonitor{ + CreateMonitor: qualitymonitors.CreateMonitor{ OutputSchemaName: "catalog.schema", - Schedule: &catalog.MonitorCronSchedule{ - PauseStatus: catalog.MonitorCronSchedulePauseStatusUnpaused, + Schedule: &qualitymonitors.MonitorCronSchedule{ + PauseStatus: qualitymonitors.MonitorCronSchedulePauseStatusUnpaused, }, }, }, }, Catalogs: map[string]*resources.Catalog{ - "catalog1": {CreateCatalog: catalog.CreateCatalog{Name: "catalog1"}}, + "catalog1": {CreateCatalog: resources.CreateCatalog{Name: new("catalog1")}}, }, ExternalLocations: map[string]*resources.ExternalLocation{ - "externalLocation1": {CreateExternalLocation: catalog.CreateExternalLocation{Name: "externalLocation1"}}, + "externalLocation1": {CreateExternalLocation: resources.CreateExternalLocation{Name: new("externalLocation1")}}, }, Schemas: map[string]*resources.Schema{ - "schema1": {CreateSchema: catalog.CreateSchema{Name: "schema1"}}, + "schema1": {CreateSchema: resources.CreateSchema{Name: new("schema1")}}, }, Volumes: map[string]*resources.Volume{ - "volume1": {CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{Name: "volume1"}}, + "volume1": {CreateVolumeRequestContent: resources.CreateVolumeRequestContent{Name: new("volume1")}}, }, Clusters: map[string]*resources.Cluster{ - "cluster1": {ClusterSpec: compute.ClusterSpec{ClusterName: "cluster1", SparkVersion: "13.2.x", NumWorkers: 1}}, + "cluster1": {CreateClusterRequest: clusters.CreateClusterRequest{ClusterName: new("cluster1"), SparkVersion: new("13.2.x"), NumWorkers: new(1)}}, }, InstancePools: map[string]*resources.InstancePool{ - "instance_pool1": {CreateInstancePool: compute.CreateInstancePool{InstancePoolName: "instance_pool1", NodeTypeId: "i3.xlarge"}}, + "instance_pool1": {CreateInstancePoolRequest: instancepools.CreateInstancePoolRequest{InstancePoolName: new("instance_pool1"), NodeTypeId: new("i3.xlarge")}}, }, ClusterPolicies: map[string]*resources.ClusterPolicy{ - "cluster_policy1": {CreatePolicy: compute.CreatePolicy{Name: "cluster_policy1"}}, + "cluster_policy1": {CreatePolicyRequest: clusterpolicies.CreatePolicyRequest{Name: new("cluster_policy1")}}, }, Dashboards: map[string]*resources.Dashboard{ "dashboard1": { @@ -182,7 +190,7 @@ func mockBundle(mode config.Mode) *bundle.Bundle { Apps: map[string]*resources.App{ "app1": { App: apps.App{ - Name: "app1", + Name: new("app1"), }, }, }, @@ -193,62 +201,62 @@ func mockBundle(mode config.Mode) *bundle.Bundle { }, Secrets: map[string]*resources.Secret{ "secret1": { - Secret: catalog.Secret{ - CatalogName: "main", - SchemaName: "default", - Name: "secret1", + Secret: ucsecrets.Secret{ + CatalogName: new("main"), + SchemaName: new("default"), + Name: new("secret1"), }, }, }, SqlWarehouses: map[string]*resources.SqlWarehouse{ "sql_warehouse1": { - CreateWarehouseRequest: sql.CreateWarehouseRequest{ - Name: "sql_warehouse1", + CreateWarehouseRequest: warehouses.CreateWarehouseRequest{ + Name: new("sql_warehouse1"), }, }, }, DatabaseInstances: map[string]*resources.DatabaseInstance{ "database_instance1": { DatabaseInstance: database.DatabaseInstance{ - Name: "database_instance1", + Name: new("database_instance1"), }, }, }, DatabaseCatalogs: map[string]*resources.DatabaseCatalog{ "database_catalog1": { DatabaseCatalog: database.DatabaseCatalog{ - Name: "database_catalog1", + Name: new("database_catalog1"), }, }, }, SyncedDatabaseTables: map[string]*resources.SyncedDatabaseTable{ "synced_database_table1": { SyncedDatabaseTable: database.SyncedDatabaseTable{ - Name: "synced_database_table1", + Name: new("synced_database_table1"), }, }, }, Alerts: map[string]*resources.Alert{ "alert1": { - AlertV2: sql.AlertV2{ - DisplayName: "alert1", - Schedule: sql.CronSchedule{ - QuartzCronSchedule: "0 0 12 * * ?", + Alert: alerts.Alert{ + DisplayName: new("alert1"), + Schedule: &alerts.CronSchedule{ + QuartzCronSchedule: new("0 0 12 * * ?"), }, }, }, "alert2": { - AlertV2: sql.AlertV2{ - DisplayName: "alert2", - Schedule: sql.CronSchedule{ - QuartzCronSchedule: "0 0 12 * * ?", - PauseStatus: sql.SchedulePauseStatusUnpaused, + Alert: alerts.Alert{ + DisplayName: new("alert2"), + Schedule: &alerts.CronSchedule{ + QuartzCronSchedule: new("0 0 12 * * ?"), + PauseStatus: alerts.SchedulePauseStatus_Unpaused, }, }, }, "alert3": { - AlertV2: sql.AlertV2{ - DisplayName: "alert3", + Alert: alerts.Alert{ + DisplayName: new("alert3"), }, }, }, @@ -257,7 +265,7 @@ func mockBundle(mode config.Mode) *bundle.Bundle { PostgresProjectConfig: resources.PostgresProjectConfig{ ProjectId: "postgres-project-1", ProjectSpec: postgres.ProjectSpec{ - DisplayName: "postgres_project1", + DisplayName: new("postgres_project1"), }, }, }, @@ -276,7 +284,7 @@ func mockBundle(mode config.Mode) *bundle.Bundle { EndpointId: "postgres-endpoint-1", Parent: "projects/postgres-project-1/branches/postgres-branch-1", EndpointSpec: postgres.EndpointSpec{ - EndpointType: postgres.EndpointTypeEndpointTypeReadWrite, + EndpointType: postgres.EndpointType_EndpointTypeReadWrite, }, }, }, @@ -301,8 +309,8 @@ func mockBundle(mode config.Mode) *bundle.Bundle { PostgresRoleConfig: resources.PostgresRoleConfig{ RoleId: "postgres-role-1", Parent: "projects/postgres-project-1/branches/postgres-branch-1", - RoleRoleSpec: postgres.RoleRoleSpec{ - PostgresRole: "postgres_role_1", + Role_RoleSpec: postgres.Role_RoleSpec{ + PostgresRole: new("postgres_role_1"), }, }, }, @@ -323,19 +331,19 @@ func mockBundle(mode config.Mode) *bundle.Bundle { }, VectorSearchEndpoints: map[string]*resources.VectorSearchEndpoint{ "vs_endpoint1": { - CreateEndpoint: vectorsearch.CreateEndpoint{ - Name: "vs_endpoint1", - EndpointType: vectorsearch.EndpointTypeStandard, + CreateEndpointRequest: vectorsearch.CreateEndpointRequest{ + Name: new("vs_endpoint1"), + EndpointType: vectorsearch.EndpointType_Standard, }, }, }, VectorSearchIndexes: map[string]*resources.VectorSearchIndex{ "vs_index1": { CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{ - Name: "main.default.vs_index1", - EndpointName: "vs_endpoint1", - PrimaryKey: "id", - IndexType: vectorsearch.VectorIndexTypeDeltaSync, + Name: new("main.default.vs_index1"), + EndpointName: new("vs_endpoint1"), + PrimaryKey: new("id"), + IndexType: vectorsearch.VectorIndexType("DELTA_SYNC"), }, }, }, @@ -362,59 +370,59 @@ func TestProcessTargetModeDevelopment(t *testing.T) { require.NoError(t, diags.Error()) // Job 1 - assert.Equal(t, "[dev lennart] job1", b.Config.Resources.Jobs["job1"].Name) + assert.Equal(t, "[dev lennart] job1", utils.Deref(b.Config.Resources.Jobs["job1"].Name)) assert.Equal(t, "tag", b.Config.Resources.Jobs["job1"].Tags["existing"]) assert.Equal(t, "lennart", b.Config.Resources.Jobs["job1"].Tags["dev"]) - assert.Equal(t, jobs.PauseStatusPaused, b.Config.Resources.Jobs["job1"].Schedule.PauseStatus) + assert.Equal(t, jobs.SchedulePauseStatus_Paused, b.Config.Resources.Jobs["job1"].Schedule.PauseStatus) // Job 2 - assert.Equal(t, "[dev lennart] job2", b.Config.Resources.Jobs["job2"].Name) + assert.Equal(t, "[dev lennart] job2", utils.Deref(b.Config.Resources.Jobs["job2"].Name)) assert.Equal(t, "lennart", b.Config.Resources.Jobs["job2"].Tags["dev"]) - assert.Equal(t, jobs.PauseStatusUnpaused, b.Config.Resources.Jobs["job2"].Schedule.PauseStatus) + assert.Equal(t, jobs.SchedulePauseStatus("UNPAUSED"), b.Config.Resources.Jobs["job2"].Schedule.PauseStatus) // Pipeline 1 - assert.Equal(t, "[dev lennart] pipeline1", b.Config.Resources.Pipelines["pipeline1"].Name) - assert.False(t, b.Config.Resources.Pipelines["pipeline1"].Continuous) //nolint:staticcheck // SA1019: pipeline continuous is deprecated in the SDK but remains a supported bundle config field - assert.True(t, b.Config.Resources.Pipelines["pipeline1"].Development) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field + assert.Equal(t, "[dev lennart] pipeline1", utils.Deref(b.Config.Resources.Pipelines["pipeline1"].Name)) + assert.False(t, utils.Deref(b.Config.Resources.Pipelines["pipeline1"].Continuous)) //nolint:staticcheck // SA1019: pipeline continuous is deprecated in the SDK but remains a supported bundle config field + assert.True(t, utils.Deref(b.Config.Resources.Pipelines["pipeline1"].Development)) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field // Experiment 1 - assert.Equal(t, "/Users/lennart.kats@databricks.com/[dev lennart] experiment1", b.Config.Resources.Experiments["experiment1"].Name) - assert.Contains(t, b.Config.Resources.Experiments["experiment1"].Tags, ml.ExperimentTag{Key: "dev", Value: "lennart"}) - assert.Equal(t, "dev", b.Config.Resources.Experiments["experiment1"].CreateExperiment.Tags[0].Key) + assert.Equal(t, "/Users/lennart.kats@databricks.com/[dev lennart] experiment1", utils.Deref(b.Config.Resources.Experiments["experiment1"].Name)) + assert.Contains(t, b.Config.Resources.Experiments["experiment1"].Tags, experiments.ExperimentTag{Key: new("dev"), Value: new("lennart")}) + assert.Equal(t, "dev", utils.Deref(b.Config.Resources.Experiments["experiment1"].CreateExperimentRequest.Tags[0].Key)) // Experiment 2 - assert.Equal(t, "[dev lennart] experiment2", b.Config.Resources.Experiments["experiment2"].Name) - assert.Contains(t, b.Config.Resources.Experiments["experiment2"].Tags, ml.ExperimentTag{Key: "dev", Value: "lennart"}) + assert.Equal(t, "[dev lennart] experiment2", utils.Deref(b.Config.Resources.Experiments["experiment2"].Name)) + assert.Contains(t, b.Config.Resources.Experiments["experiment2"].Tags, experiments.ExperimentTag{Key: new("dev"), Value: new("lennart")}) // Model 1 - assert.Equal(t, "[dev lennart] model1", b.Config.Resources.Models["model1"].Name) - assert.Contains(t, b.Config.Resources.Models["model1"].Tags, ml.ModelTag{Key: "dev", Value: "lennart"}) + assert.Equal(t, "[dev lennart] model1", utils.Deref(b.Config.Resources.Models["model1"].Name)) + assert.Contains(t, b.Config.Resources.Models["model1"].Tags, modelregistry.RegisteredModelTag{Key: new("dev"), Value: new("lennart")}) // Model serving endpoint 1 - assert.Equal(t, "dev_lennart_servingendpoint1", b.Config.Resources.ModelServingEndpoints["servingendpoint1"].Name) + assert.Equal(t, "dev_lennart_servingendpoint1", utils.Deref(b.Config.Resources.ModelServingEndpoints["servingendpoint1"].Name)) // Vector search endpoint 1: name is the primary key, so it must not be prefixed. - assert.Equal(t, "vs_endpoint1", b.Config.Resources.VectorSearchEndpoints["vs_endpoint1"].Name) + assert.Equal(t, "vs_endpoint1", utils.Deref(b.Config.Resources.VectorSearchEndpoints["vs_endpoint1"].Name)) // Vector search index 1: name is the primary key, so it must not be prefixed. - assert.Equal(t, "main.default.vs_index1", b.Config.Resources.VectorSearchIndexes["vs_index1"].Name) + assert.Equal(t, "main.default.vs_index1", utils.Deref(b.Config.Resources.VectorSearchIndexes["vs_index1"].Name)) // Registered model 1 - assert.Equal(t, "dev_lennart_registeredmodel1", b.Config.Resources.RegisteredModels["registeredmodel1"].Name) + assert.Equal(t, "dev_lennart_registeredmodel1", utils.Deref(b.Config.Resources.RegisteredModels["registeredmodel1"].Name)) // Quality Monitor 1 assert.Equal(t, "qualityMonitor1", b.Config.Resources.QualityMonitors["qualityMonitor1"].TableName) assert.Nil(t, b.Config.Resources.QualityMonitors["qualityMonitor2"].Schedule) - assert.Equal(t, catalog.MonitorCronSchedulePauseStatusUnpaused, b.Config.Resources.QualityMonitors["qualityMonitor3"].Schedule.PauseStatus) + assert.Equal(t, qualitymonitors.MonitorCronSchedulePauseStatusUnpaused, b.Config.Resources.QualityMonitors["qualityMonitor3"].Schedule.PauseStatus) // Schema 1 - assert.Equal(t, "dev_lennart_schema1", b.Config.Resources.Schemas["schema1"].Name) + assert.Equal(t, "dev_lennart_schema1", utils.Deref(b.Config.Resources.Schemas["schema1"].Name)) // Clusters - assert.Equal(t, "[dev lennart] cluster1", b.Config.Resources.Clusters["cluster1"].ClusterName) + assert.Equal(t, "[dev lennart] cluster1", utils.Deref(b.Config.Resources.Clusters["cluster1"].ClusterName)) // Instance pools - assert.Equal(t, "[dev lennart] instance_pool1", b.Config.Resources.InstancePools["instance_pool1"].InstancePoolName) + assert.Equal(t, "[dev lennart] instance_pool1", utils.Deref(b.Config.Resources.InstancePools["instance_pool1"].InstancePoolName)) // Dashboards assert.Equal(t, "[dev lennart] dashboard1", b.Config.Resources.Dashboards["dashboard1"].DisplayName) @@ -423,16 +431,16 @@ func TestProcessTargetModeDevelopment(t *testing.T) { assert.Equal(t, "[dev lennart] geniespace1", b.Config.Resources.GenieSpaces["geniespace1"].Title) // Alert 1: has schedule without pause status set - should be paused - assert.Equal(t, "[dev lennart] alert1", b.Config.Resources.Alerts["alert1"].DisplayName) - assert.Equal(t, sql.SchedulePauseStatusPaused, b.Config.Resources.Alerts["alert1"].Schedule.PauseStatus) + assert.Equal(t, "[dev lennart] alert1", utils.Deref(b.Config.Resources.Alerts["alert1"].DisplayName)) + assert.Equal(t, alerts.SchedulePauseStatus_Paused, b.Config.Resources.Alerts["alert1"].Schedule.PauseStatus) // Alert 2: has schedule with pause status already set to unpaused - should remain unpaused - assert.Equal(t, "[dev lennart] alert2", b.Config.Resources.Alerts["alert2"].DisplayName) - assert.Equal(t, sql.SchedulePauseStatusUnpaused, b.Config.Resources.Alerts["alert2"].Schedule.PauseStatus) + assert.Equal(t, "[dev lennart] alert2", utils.Deref(b.Config.Resources.Alerts["alert2"].DisplayName)) + assert.Equal(t, alerts.SchedulePauseStatus_Unpaused, b.Config.Resources.Alerts["alert2"].Schedule.PauseStatus) // Alert 3: no schedule - pause status should remain empty - assert.Equal(t, "[dev lennart] alert3", b.Config.Resources.Alerts["alert3"].DisplayName) - assert.Empty(t, b.Config.Resources.Alerts["alert3"].Schedule.PauseStatus) + assert.Equal(t, "[dev lennart] alert3", utils.Deref(b.Config.Resources.Alerts["alert3"].DisplayName)) + assert.Nil(t, b.Config.Resources.Alerts["alert3"].Schedule) } func TestProcessTargetModeDevelopmentTagNormalizationForAws(t *testing.T) { @@ -482,18 +490,18 @@ func TestProcessTargetModeDefault(t *testing.T) { diags := bundle.ApplySeq(t.Context(), b, ApplyTargetMode(), ApplyPresets()) require.NoError(t, diags.Error()) - assert.Equal(t, "job1", b.Config.Resources.Jobs["job1"].Name) - assert.Equal(t, "pipeline1", b.Config.Resources.Pipelines["pipeline1"].Name) - assert.False(t, b.Config.Resources.Pipelines["pipeline1"].Development) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field - assert.Equal(t, "servingendpoint1", b.Config.Resources.ModelServingEndpoints["servingendpoint1"].Name) - assert.Equal(t, "registeredmodel1", b.Config.Resources.RegisteredModels["registeredmodel1"].Name) + assert.Equal(t, "job1", utils.Deref(b.Config.Resources.Jobs["job1"].Name)) + assert.Equal(t, "pipeline1", utils.Deref(b.Config.Resources.Pipelines["pipeline1"].Name)) + assert.False(t, utils.Deref(b.Config.Resources.Pipelines["pipeline1"].Development)) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field + assert.Equal(t, "servingendpoint1", utils.Deref(b.Config.Resources.ModelServingEndpoints["servingendpoint1"].Name)) + assert.Equal(t, "registeredmodel1", utils.Deref(b.Config.Resources.RegisteredModels["registeredmodel1"].Name)) assert.Equal(t, "qualityMonitor1", b.Config.Resources.QualityMonitors["qualityMonitor1"].TableName) - assert.Equal(t, "catalog1", b.Config.Resources.Catalogs["catalog1"].Name) - assert.Equal(t, "schema1", b.Config.Resources.Schemas["schema1"].Name) - assert.Equal(t, "volume1", b.Config.Resources.Volumes["volume1"].Name) - assert.Equal(t, "cluster1", b.Config.Resources.Clusters["cluster1"].ClusterName) - assert.Equal(t, "instance_pool1", b.Config.Resources.InstancePools["instance_pool1"].InstancePoolName) - assert.Equal(t, "sql_warehouse1", b.Config.Resources.SqlWarehouses["sql_warehouse1"].Name) + assert.Equal(t, "catalog1", utils.Deref(b.Config.Resources.Catalogs["catalog1"].Name)) + assert.Equal(t, "schema1", utils.Deref(b.Config.Resources.Schemas["schema1"].Name)) + assert.Equal(t, "volume1", utils.Deref(b.Config.Resources.Volumes["volume1"].Name)) + assert.Equal(t, "cluster1", utils.Deref(b.Config.Resources.Clusters["cluster1"].ClusterName)) + assert.Equal(t, "instance_pool1", utils.Deref(b.Config.Resources.InstancePools["instance_pool1"].InstancePoolName)) + assert.Equal(t, "sql_warehouse1", utils.Deref(b.Config.Resources.SqlWarehouses["sql_warehouse1"].Name)) } // Make sure that we have test coverage for all resource types @@ -605,7 +613,7 @@ func TestPrefixAlreadySet(t *testing.T) { diags := bundle.ApplySeq(t.Context(), b, ApplyTargetMode(), ApplyPresets()) require.NoError(t, diags.Error()) - assert.Equal(t, "custom_lennart_deploy_job1", b.Config.Resources.Jobs["job1"].Name) + assert.Equal(t, "custom_lennart_deploy_job1", utils.Deref(b.Config.Resources.Jobs["job1"].Name)) } func TestTagsAlreadySet(t *testing.T) { @@ -649,7 +657,7 @@ func TestJobsMaxConcurrentRunsAlreadySet(t *testing.T) { diags := bundle.ApplySeq(t.Context(), b, ApplyTargetMode(), ApplyPresets()) require.NoError(t, diags.Error()) - assert.Equal(t, 10, b.Config.Resources.Jobs["job1"].MaxConcurrentRuns) + assert.Equal(t, 10, utils.Deref(b.Config.Resources.Jobs["job1"].MaxConcurrentRuns)) } func TestJobsMaxConcurrentRunsDisabled(t *testing.T) { @@ -659,7 +667,7 @@ func TestJobsMaxConcurrentRunsDisabled(t *testing.T) { diags := bundle.ApplySeq(t.Context(), b, ApplyTargetMode(), ApplyPresets()) require.NoError(t, diags.Error()) - assert.Equal(t, 1, b.Config.Resources.Jobs["job1"].MaxConcurrentRuns) + assert.Equal(t, 1, utils.Deref(b.Config.Resources.Jobs["job1"].MaxConcurrentRuns)) } func TestPipelinesDevelopmentDisabled(t *testing.T) { @@ -670,5 +678,5 @@ func TestPipelinesDevelopmentDisabled(t *testing.T) { diags := bundle.ApplySeq(t.Context(), b, ApplyTargetMode(), ApplyPresets()) require.NoError(t, diags.Error()) - assert.False(t, b.Config.Resources.Pipelines["pipeline1"].Development) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field + assert.False(t, utils.Deref(b.Config.Resources.Pipelines["pipeline1"].Development)) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field } diff --git a/bundle/config/mutator/resourcemutator/capture_uc_dependencies.go b/bundle/config/mutator/resourcemutator/capture_uc_dependencies.go index 488e215a2e2..953c549fcdf 100644 --- a/bundle/config/mutator/resourcemutator/capture_uc_dependencies.go +++ b/bundle/config/mutator/resourcemutator/capture_uc_dependencies.go @@ -9,6 +9,7 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn/dynvar" + "github.com/databricks/cli/libs/utils" ) type captureUCDependencies struct{} @@ -47,7 +48,7 @@ func findSchema(b *bundle.Bundle, catalogName, schemaName string) (string, *reso } for k, s := range b.Config.Resources.Schemas { - if s != nil && s.CatalogName == catalogName && s.Name == schemaName { + if s != nil && utils.Deref(s.CatalogName) == catalogName && utils.Deref(s.Name) == schemaName { return k, s } } @@ -60,7 +61,7 @@ func findCatalog(b *bundle.Bundle, catalogName string) (string, *resources.Catal } for k, c := range b.Config.Resources.Catalogs { - if c != nil && c.Name == catalogName { + if c != nil && utils.Deref(c.Name) == catalogName { return k, c } } @@ -89,6 +90,24 @@ func resolveCatalog(b *bundle.Bundle, catalogName string) string { return catalogName } +// resolveSchemaPtr is resolveSchema for optional fields; an unset field stays unset. +func resolveSchemaPtr(b *bundle.Bundle, catalogName, schemaName *string) *string { + k, s := findSchema(b, utils.Deref(catalogName), utils.Deref(schemaName)) + if s != nil { + return new(schemaNameRef(k)) + } + return schemaName +} + +// resolveCatalogPtr is resolveCatalog for optional fields; an unset field stays unset. +func resolveCatalogPtr(b *bundle.Bundle, catalogName *string) *string { + k, c := findCatalog(b, utils.Deref(catalogName)) + if c != nil { + return new(catalogNameRef(k)) + } + return catalogName +} + // splitUCName splits a compound UC identifier into exactly n dot-separated // components, returning false if it has a different number of components. Callers // skip names containing a ${...} reference beforehand, so this is a plain split: @@ -126,22 +145,22 @@ func (m *captureUCDependencies) Apply(ctx context.Context, b *bundle.Bundle) dia if v == nil { continue } - v.SchemaName = resolveSchema(b, v.CatalogName, v.SchemaName) - v.CatalogName = resolveCatalog(b, v.CatalogName) + v.SchemaName = resolveSchemaPtr(b, v.CatalogName, v.SchemaName) + v.CatalogName = resolveCatalogPtr(b, v.CatalogName) } for _, s := range b.Config.Resources.Secrets { if s == nil { continue } - s.SchemaName = resolveSchema(b, s.CatalogName, s.SchemaName) - s.CatalogName = resolveCatalog(b, s.CatalogName) + s.SchemaName = resolveSchemaPtr(b, s.CatalogName, s.SchemaName) + s.CatalogName = resolveCatalogPtr(b, s.CatalogName) } for _, rm := range b.Config.Resources.RegisteredModels { if rm == nil { continue } - rm.SchemaName = resolveSchema(b, rm.CatalogName, rm.SchemaName) - rm.CatalogName = resolveCatalog(b, rm.CatalogName) + rm.SchemaName = resolveSchemaPtr(b, rm.CatalogName, rm.SchemaName) + rm.CatalogName = resolveCatalogPtr(b, rm.CatalogName) } for _, p := range b.Config.Resources.Pipelines { if p == nil { @@ -149,9 +168,9 @@ func (m *captureUCDependencies) Apply(ctx context.Context, b *bundle.Bundle) dia } // "schema" and "target" have the same semantics in the SDP API but are mutually // exclusive i.e. only one can be set at a time. - p.Schema = resolveSchema(b, p.Catalog, p.Schema) - p.Target = resolveSchema(b, p.Catalog, p.Target) - p.Catalog = resolveCatalog(b, p.Catalog) + p.Schema = resolveSchemaPtr(b, p.Catalog, p.Schema) + p.Target = resolveSchemaPtr(b, p.Catalog, p.Target) + p.Catalog = resolveCatalogPtr(b, p.Catalog) } for _, qm := range b.Config.Resources.QualityMonitors { if qm == nil || qm.OutputSchemaName == "" { @@ -179,16 +198,16 @@ func (m *captureUCDependencies) Apply(ctx context.Context, b *bundle.Bundle) dia } // A name that already contains a reference is left as is; a mix of // references and literals is not supported. - if dynvar.ContainsVariableReference(idx.Name) { + if dynvar.ContainsVariableReference(utils.Deref(idx.Name)) { continue } // Name is a three-part "catalog.schema.index" UC identifier. - parts, ok := splitUCName(idx.Name, 3) + parts, ok := splitUCName(utils.Deref(idx.Name), 3) if !ok { continue } catalogName, schemaName := parts[0], parts[1] - idx.Name = resolveCatalog(b, catalogName) + "." + resolveSchema(b, catalogName, schemaName) + "." + parts[2] + idx.Name = new(resolveCatalog(b, catalogName) + "." + resolveSchema(b, catalogName, schemaName) + "." + parts[2]) } for _, mse := range b.Config.Resources.ModelServingEndpoints { if mse == nil { @@ -196,14 +215,14 @@ func (m *captureUCDependencies) Apply(ctx context.Context, b *bundle.Bundle) dia } if mse.AiGateway != nil && mse.AiGateway.InferenceTableConfig != nil { itc := mse.AiGateway.InferenceTableConfig - itc.SchemaName = resolveSchema(b, itc.CatalogName, itc.SchemaName) - itc.CatalogName = resolveCatalog(b, itc.CatalogName) + itc.SchemaName = resolveSchemaPtr(b, itc.CatalogName, itc.SchemaName) + itc.CatalogName = resolveCatalogPtr(b, itc.CatalogName) } // AutoCaptureConfig is deprecated but still in use. if mse.Config != nil && mse.Config.AutoCaptureConfig != nil { acc := mse.Config.AutoCaptureConfig - acc.SchemaName = resolveSchema(b, acc.CatalogName, acc.SchemaName) - acc.CatalogName = resolveCatalog(b, acc.CatalogName) + acc.SchemaName = resolveSchemaPtr(b, acc.CatalogName, acc.SchemaName) + acc.CatalogName = resolveCatalogPtr(b, acc.CatalogName) } } for _, ms := range b.Config.Resources.ModelServices { @@ -237,7 +256,7 @@ func (m *captureUCDependencies) Apply(ctx context.Context, b *bundle.Bundle) dia if s == nil { continue } - s.CatalogName = resolveCatalog(b, s.CatalogName) + s.CatalogName = resolveCatalogPtr(b, s.CatalogName) } return nil } diff --git a/bundle/config/mutator/resourcemutator/capture_uc_dependencies_test.go b/bundle/config/mutator/resourcemutator/capture_uc_dependencies_test.go index e5281a42a77..7800df88183 100644 --- a/bundle/config/mutator/resourcemutator/capture_uc_dependencies_test.go +++ b/bundle/config/mutator/resourcemutator/capture_uc_dependencies_test.go @@ -3,13 +3,16 @@ package resourcemutator import ( "testing" + "github.com/databricks/cli/libs/qualitymonitors" + "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/serving" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" + "github.com/databricks/cli/libs/sdktypes/modelserving/v1" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -20,9 +23,9 @@ func bundleWithSchemas() *bundle.Bundle { Config: config.Root{ Resources: config.Resources{ Schemas: map[string]*resources.Schema{ - "schema1": {CreateSchema: catalog.CreateSchema{CatalogName: "catalog1", Name: "foobar"}}, - "schema2": {CreateSchema: catalog.CreateSchema{CatalogName: "catalog2", Name: "foobar"}}, - "schema3": {CreateSchema: catalog.CreateSchema{CatalogName: "catalog1", Name: "barfoo"}}, + "schema1": {CreateSchema: resources.CreateSchema{CatalogName: new("catalog1"), Name: new("foobar")}}, + "schema2": {CreateSchema: resources.CreateSchema{CatalogName: new("catalog2"), Name: new("foobar")}}, + "schema3": {CreateSchema: resources.CreateSchema{CatalogName: new("catalog1"), Name: new("barfoo")}}, }, }, }, @@ -35,8 +38,8 @@ func bundleWithCatalogs() *bundle.Bundle { Config: config.Root{ Resources: config.Resources{ Catalogs: map[string]*resources.Catalog{ - "dev_catalog": {CreateCatalog: catalog.CreateCatalog{Name: "catalog1"}}, - "prod_catalog": {CreateCatalog: catalog.CreateCatalog{Name: "catalog2"}}, + "dev_catalog": {CreateCatalog: resources.CreateCatalog{Name: new("catalog1")}}, + "prod_catalog": {CreateCatalog: resources.CreateCatalog{Name: new("catalog2")}}, }, }, }, @@ -98,36 +101,36 @@ func TestCaptureUCDependencies(t *testing.T) { Config: config.Root{ Resources: config.Resources{ Catalogs: map[string]*resources.Catalog{ - "my_catalog": {CreateCatalog: catalog.CreateCatalog{Name: "mycatalog"}}, + "my_catalog": {CreateCatalog: resources.CreateCatalog{Name: new("mycatalog")}}, }, Schemas: map[string]*resources.Schema{ - "my_schema": {CreateSchema: catalog.CreateSchema{CatalogName: "mycatalog", Name: "myschema"}}, + "my_schema": {CreateSchema: resources.CreateSchema{CatalogName: new("mycatalog"), Name: new("myschema")}}, }, Volumes: map[string]*resources.Volume{ - "my_volume": {CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{ - CatalogName: "mycatalog", SchemaName: "myschema", + "my_volume": {CreateVolumeRequestContent: resources.CreateVolumeRequestContent{ + CatalogName: new("mycatalog"), SchemaName: new("myschema"), }}, }, RegisteredModels: map[string]*resources.RegisteredModel{ - "my_model": {CreateRegisteredModelRequest: catalog.CreateRegisteredModelRequest{ - CatalogName: "mycatalog", SchemaName: "myschema", + "my_model": {CreateRegisteredModelRequest: registeredmodels.CreateRegisteredModelRequest{ + CatalogName: new("mycatalog"), SchemaName: new("myschema"), }}, }, Pipelines: map[string]*resources.Pipeline{ - "my_pipeline": {CreatePipeline: pipelines.CreatePipeline{ - Catalog: "mycatalog", Schema: "myschema", + "my_pipeline": {CreatePipelineRequest: pipelines.CreatePipelineRequest{ + Catalog: new("mycatalog"), Schema: new("myschema"), }}, }, QualityMonitors: map[string]*resources.QualityMonitor{ - "my_monitor": {CreateMonitor: catalog.CreateMonitor{ + "my_monitor": {CreateMonitor: qualitymonitors.CreateMonitor{ OutputSchemaName: "mycatalog.myschema", }}, }, ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{ - "my_endpoint": {CreateServingEndpoint: serving.CreateServingEndpoint{ - AiGateway: &serving.AiGatewayConfig{ - InferenceTableConfig: &serving.AiGatewayInferenceTableConfig{ - CatalogName: "mycatalog", SchemaName: "myschema", + "my_endpoint": {CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{ + AiGateway: &modelserving.AiGatewayConfig{ + InferenceTableConfig: &modelserving.InferenceTableConfig{ + CatalogName: new("mycatalog"), SchemaName: new("myschema"), }, }, }}, @@ -139,7 +142,7 @@ func TestCaptureUCDependencies(t *testing.T) { }, VectorSearchIndexes: map[string]*resources.VectorSearchIndex{ "my_index": {CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{ - Name: "mycatalog.myschema.myindex", + Name: new("mycatalog.myschema.myindex"), }}, }, McpServices: map[string]*resources.McpService{ @@ -163,33 +166,33 @@ func TestCaptureUCDependencies(t *testing.T) { catalogRef := "${resources.catalogs.my_catalog.name}" // Schema catalog dependency. - assert.Equal(t, catalogRef, b.Config.Resources.Schemas["my_schema"].CatalogName) + assert.Equal(t, catalogRef, utils.Deref(b.Config.Resources.Schemas["my_schema"].CatalogName)) // Volume. - assert.Equal(t, schemaRef, b.Config.Resources.Volumes["my_volume"].SchemaName) - assert.Equal(t, catalogRef, b.Config.Resources.Volumes["my_volume"].CatalogName) + assert.Equal(t, schemaRef, utils.Deref(b.Config.Resources.Volumes["my_volume"].SchemaName)) + assert.Equal(t, catalogRef, utils.Deref(b.Config.Resources.Volumes["my_volume"].CatalogName)) // Registered model. - assert.Equal(t, schemaRef, b.Config.Resources.RegisteredModels["my_model"].SchemaName) - assert.Equal(t, catalogRef, b.Config.Resources.RegisteredModels["my_model"].CatalogName) + assert.Equal(t, schemaRef, utils.Deref(b.Config.Resources.RegisteredModels["my_model"].SchemaName)) + assert.Equal(t, catalogRef, utils.Deref(b.Config.Resources.RegisteredModels["my_model"].CatalogName)) // Pipeline. - assert.Equal(t, schemaRef, b.Config.Resources.Pipelines["my_pipeline"].Schema) - assert.Equal(t, catalogRef, b.Config.Resources.Pipelines["my_pipeline"].Catalog) + assert.Equal(t, schemaRef, utils.Deref(b.Config.Resources.Pipelines["my_pipeline"].Schema)) + assert.Equal(t, catalogRef, utils.Deref(b.Config.Resources.Pipelines["my_pipeline"].Catalog)) // Quality monitor (compound "catalog.schema" field). assert.Equal(t, catalogRef+"."+schemaRef, b.Config.Resources.QualityMonitors["my_monitor"].OutputSchemaName) // Model serving endpoint. itc := b.Config.Resources.ModelServingEndpoints["my_endpoint"].AiGateway.InferenceTableConfig - assert.Equal(t, schemaRef, itc.SchemaName) - assert.Equal(t, catalogRef, itc.CatalogName) + assert.Equal(t, schemaRef, utils.Deref(itc.SchemaName)) + assert.Equal(t, catalogRef, utils.Deref(itc.CatalogName)) // Model service (compound "schemas/{catalog}.{schema}" parent field). assert.Equal(t, "schemas/"+catalogRef+"."+schemaRef, b.Config.Resources.ModelServices["my_model_service"].Parent) // Vector search index (three-part "catalog.schema.index" name). - assert.Equal(t, catalogRef+"."+schemaRef+".myindex", b.Config.Resources.VectorSearchIndexes["my_index"].Name) + assert.Equal(t, catalogRef+"."+schemaRef+".myindex", utils.Deref(b.Config.Resources.VectorSearchIndexes["my_index"].Name)) // MCP service (same compound parent field). assert.Equal(t, "schemas/"+catalogRef+"."+schemaRef, b.Config.Resources.McpServices["my_mcp_service"].Parent) @@ -205,11 +208,11 @@ func TestCaptureUCDependenciesPipelineSchemaTarget(t *testing.T) { Config: config.Root{ Resources: config.Resources{ Schemas: map[string]*resources.Schema{ - "s": {CreateSchema: catalog.CreateSchema{CatalogName: "c", Name: "n"}}, + "s": {CreateSchema: resources.CreateSchema{CatalogName: new("c"), Name: new("n")}}, }, Pipelines: map[string]*resources.Pipeline{ - "with_schema": {CreatePipeline: pipelines.CreatePipeline{Catalog: "c", Schema: "n"}}, - "with_target": {CreatePipeline: pipelines.CreatePipeline{Catalog: "c", Target: "n"}}, + "with_schema": {CreatePipelineRequest: pipelines.CreatePipelineRequest{Catalog: new("c"), Schema: new("n")}}, + "with_target": {CreatePipelineRequest: pipelines.CreatePipelineRequest{Catalog: new("c"), Target: new("n")}}, }, }, }, @@ -220,11 +223,11 @@ func TestCaptureUCDependenciesPipelineSchemaTarget(t *testing.T) { ref := "${resources.schemas.s.name}" - assert.Equal(t, ref, b.Config.Resources.Pipelines["with_schema"].Schema) - assert.Empty(t, b.Config.Resources.Pipelines["with_schema"].Target) + assert.Equal(t, ref, utils.Deref(b.Config.Resources.Pipelines["with_schema"].Schema)) + assert.Empty(t, utils.Deref(b.Config.Resources.Pipelines["with_schema"].Target)) - assert.Equal(t, ref, b.Config.Resources.Pipelines["with_target"].Target) - assert.Empty(t, b.Config.Resources.Pipelines["with_target"].Schema) + assert.Equal(t, ref, utils.Deref(b.Config.Resources.Pipelines["with_target"].Target)) + assert.Empty(t, utils.Deref(b.Config.Resources.Pipelines["with_target"].Schema)) } func TestCaptureUCDependenciesQualityMonitorEdgeCases(t *testing.T) { @@ -232,16 +235,16 @@ func TestCaptureUCDependenciesQualityMonitorEdgeCases(t *testing.T) { Config: config.Root{ Resources: config.Resources{ Catalogs: map[string]*resources.Catalog{ - "my_catalog": {CreateCatalog: catalog.CreateCatalog{Name: "mycatalog"}}, + "my_catalog": {CreateCatalog: resources.CreateCatalog{Name: new("mycatalog")}}, }, Schemas: map[string]*resources.Schema{ - "my_schema": {CreateSchema: catalog.CreateSchema{CatalogName: "mycatalog", Name: "myschema"}}, + "my_schema": {CreateSchema: resources.CreateSchema{CatalogName: new("mycatalog"), Name: new("myschema")}}, }, QualityMonitors: map[string]*resources.QualityMonitor{ - "catalog_only": {CreateMonitor: catalog.CreateMonitor{OutputSchemaName: "mycatalog.other"}}, - "no_match": {CreateMonitor: catalog.CreateMonitor{OutputSchemaName: "other.other"}}, - "empty": {CreateMonitor: catalog.CreateMonitor{OutputSchemaName: ""}}, - "no_dot": {CreateMonitor: catalog.CreateMonitor{OutputSchemaName: "nodot"}}, + "catalog_only": {CreateMonitor: qualitymonitors.CreateMonitor{OutputSchemaName: "mycatalog.other"}}, + "no_match": {CreateMonitor: qualitymonitors.CreateMonitor{OutputSchemaName: "other.other"}}, + "empty": {CreateMonitor: qualitymonitors.CreateMonitor{OutputSchemaName: ""}}, + "no_dot": {CreateMonitor: qualitymonitors.CreateMonitor{OutputSchemaName: "nodot"}}, "nil_monitor": nil, }, }, @@ -263,32 +266,32 @@ func TestCaptureUCDependenciesModelServingEndpointEdgeCases(t *testing.T) { Config: config.Root{ Resources: config.Resources{ Catalogs: map[string]*resources.Catalog{ - "my_catalog": {CreateCatalog: catalog.CreateCatalog{Name: "mycatalog"}}, + "my_catalog": {CreateCatalog: resources.CreateCatalog{Name: new("mycatalog")}}, }, Schemas: map[string]*resources.Schema{ - "my_schema": {CreateSchema: catalog.CreateSchema{CatalogName: "mycatalog", Name: "myschema"}}, + "my_schema": {CreateSchema: resources.CreateSchema{CatalogName: new("mycatalog"), Name: new("myschema")}}, }, ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{ // AutoCaptureConfig path. - "auto_capture": {CreateServingEndpoint: serving.CreateServingEndpoint{ - Config: &serving.EndpointCoreConfigInput{ + "auto_capture": {CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{ + Config: &modelserving.EndpointCoreConfig{ //nolint:staticcheck // SA1019: deprecated AutoCaptureConfigInput kept for bundle config compatibility - AutoCaptureConfig: &serving.AutoCaptureConfigInput{ - CatalogName: "mycatalog", SchemaName: "myschema", + AutoCaptureConfig: &modelserving.AutoCaptureConfig{ + CatalogName: new("mycatalog"), SchemaName: new("myschema"), }, }, }}, // No match. - "no_match": {CreateServingEndpoint: serving.CreateServingEndpoint{ - AiGateway: &serving.AiGatewayConfig{ - InferenceTableConfig: &serving.AiGatewayInferenceTableConfig{ - CatalogName: "other", SchemaName: "other", + "no_match": {CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{ + AiGateway: &modelserving.AiGatewayConfig{ + InferenceTableConfig: &modelserving.InferenceTableConfig{ + CatalogName: new("other"), SchemaName: new("other"), }, }, }}, // Various nil nesting levels. - "nil_gateway": {CreateServingEndpoint: serving.CreateServingEndpoint{}}, - "nil_inference_table": {CreateServingEndpoint: serving.CreateServingEndpoint{AiGateway: &serving.AiGatewayConfig{}}}, + "nil_gateway": {CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{}}, + "nil_inference_table": {CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{AiGateway: &modelserving.AiGatewayConfig{}}}, "nil_endpoint": nil, }, }, @@ -302,12 +305,12 @@ func TestCaptureUCDependenciesModelServingEndpointEdgeCases(t *testing.T) { catalogRef := "${resources.catalogs.my_catalog.name}" acc := b.Config.Resources.ModelServingEndpoints["auto_capture"].Config.AutoCaptureConfig - assert.Equal(t, schemaRef, acc.SchemaName) - assert.Equal(t, catalogRef, acc.CatalogName) + assert.Equal(t, schemaRef, utils.Deref(acc.SchemaName)) + assert.Equal(t, catalogRef, utils.Deref(acc.CatalogName)) itc := b.Config.Resources.ModelServingEndpoints["no_match"].AiGateway.InferenceTableConfig - assert.Equal(t, "other", itc.CatalogName) - assert.Equal(t, "other", itc.SchemaName) + assert.Equal(t, "other", utils.Deref(itc.CatalogName)) + assert.Equal(t, "other", utils.Deref(itc.SchemaName)) assert.Nil(t, b.Config.Resources.ModelServingEndpoints["nil_endpoint"]) } @@ -317,16 +320,16 @@ func TestCaptureUCDependenciesVectorSearchIndexEdgeCases(t *testing.T) { Config: config.Root{ Resources: config.Resources{ Catalogs: map[string]*resources.Catalog{ - "my_catalog": {CreateCatalog: catalog.CreateCatalog{Name: "mycatalog"}}, + "my_catalog": {CreateCatalog: resources.CreateCatalog{Name: new("mycatalog")}}, }, Schemas: map[string]*resources.Schema{ - "my_schema": {CreateSchema: catalog.CreateSchema{CatalogName: "mycatalog", Name: "myschema"}}, + "my_schema": {CreateSchema: resources.CreateSchema{CatalogName: new("mycatalog"), Name: new("myschema")}}, }, VectorSearchIndexes: map[string]*resources.VectorSearchIndex{ - "catalog_only": {CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{Name: "mycatalog.other.myindex"}}, - "no_match": {CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{Name: "other.other.myindex"}}, - "empty": {CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{Name: ""}}, - "two_part": {CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{Name: "mycatalog.myschema"}}, + "catalog_only": {CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{Name: new("mycatalog.other.myindex")}}, + "no_match": {CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{Name: new("other.other.myindex")}}, + "empty": {CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{Name: new("")}}, + "two_part": {CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{Name: new("mycatalog.myschema")}}, "nil_index": nil, }, }, @@ -336,10 +339,10 @@ func TestCaptureUCDependenciesVectorSearchIndexEdgeCases(t *testing.T) { d := bundle.Apply(t.Context(), b, CaptureUCDependencies()) require.Nil(t, d) - assert.Equal(t, "${resources.catalogs.my_catalog.name}.other.myindex", b.Config.Resources.VectorSearchIndexes["catalog_only"].Name) - assert.Equal(t, "other.other.myindex", b.Config.Resources.VectorSearchIndexes["no_match"].Name) - assert.Empty(t, b.Config.Resources.VectorSearchIndexes["empty"].Name) - assert.Equal(t, "mycatalog.myschema", b.Config.Resources.VectorSearchIndexes["two_part"].Name) + assert.Equal(t, "${resources.catalogs.my_catalog.name}.other.myindex", utils.Deref(b.Config.Resources.VectorSearchIndexes["catalog_only"].Name)) + assert.Equal(t, "other.other.myindex", utils.Deref(b.Config.Resources.VectorSearchIndexes["no_match"].Name)) + assert.Empty(t, utils.Deref(b.Config.Resources.VectorSearchIndexes["empty"].Name)) + assert.Equal(t, "mycatalog.myschema", utils.Deref(b.Config.Resources.VectorSearchIndexes["two_part"].Name)) assert.Nil(t, b.Config.Resources.VectorSearchIndexes["nil_index"]) } @@ -399,13 +402,13 @@ func TestCaptureUCDependenciesVectorSearchIndexReferences(t *testing.T) { Config: config.Root{ Resources: config.Resources{ Catalogs: map[string]*resources.Catalog{ - "dev_catalog": {CreateCatalog: catalog.CreateCatalog{Name: "catalog1"}}, + "dev_catalog": {CreateCatalog: resources.CreateCatalog{Name: new("catalog1")}}, }, Schemas: map[string]*resources.Schema{ - "my_schema": {CreateSchema: catalog.CreateSchema{CatalogName: "catalog1", Name: "myschema"}}, + "my_schema": {CreateSchema: resources.CreateSchema{CatalogName: new("catalog1"), Name: new("myschema")}}, }, VectorSearchIndexes: map[string]*resources.VectorSearchIndex{ - "idx": {CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{Name: indexName}}, + "idx": {CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{Name: new(indexName)}}, }, }, }, @@ -444,7 +447,7 @@ func TestCaptureUCDependenciesVectorSearchIndexReferences(t *testing.T) { b := newBundle(tc.input) d := bundle.Apply(t.Context(), b, CaptureUCDependencies()) require.Nil(t, d) - assert.Equal(t, tc.expected, b.Config.Resources.VectorSearchIndexes["idx"].Name) + assert.Equal(t, tc.expected, utils.Deref(b.Config.Resources.VectorSearchIndexes["idx"].Name)) }) } } diff --git a/bundle/config/mutator/resourcemutator/cluster_fixups.go b/bundle/config/mutator/resourcemutator/cluster_fixups.go index 53cf62e10dc..6ac1d219a82 100644 --- a/bundle/config/mutator/resourcemutator/cluster_fixups.go +++ b/bundle/config/mutator/resourcemutator/cluster_fixups.go @@ -2,12 +2,13 @@ package resourcemutator import ( "context" - "slices" "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/clusters/v2" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/structs/structpath" + "github.com/databricks/cli/libs/utils" ) type jobClustersFixups struct{} @@ -21,17 +22,28 @@ func (m *jobClustersFixups) Name() string { } func (m *jobClustersFixups) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { - for _, job := range b.Config.Resources.Jobs { + var diags diag.Diagnostics + for key, job := range b.Config.Resources.Jobs { if job == nil { continue } + for i, task := range job.Tasks { + if task.NewCluster != nil && dropNumWorkersWithAutoscale(&task.NewCluster.Autoscale, &task.NewCluster.NumWorkers) { + diags = diags.Append(numWorkersIgnored(b, "resources", "jobs", key, "tasks", i, "new_cluster", "num_workers")) + } + } + for i, jc := range job.JobClusters { + if jc.NewCluster != nil && dropNumWorkersWithAutoscale(&jc.NewCluster.Autoscale, &jc.NewCluster.NumWorkers) { + diags = diags.Append(numWorkersIgnored(b, "resources", "jobs", key, "job_clusters", i, "new_cluster", "num_workers")) + } + } // TODO: we should raise a warning when user specify both InstancePoolId and NodeTypeId since it's illegal. // Once we remove TF backend and had warning for some time, we can remove this transformation, the backend // will reject such configs. prepareJobSettingsForUpdate(&job.JobSettings) } - return nil + return diags } type clusterFixups struct{} @@ -45,75 +57,122 @@ func (m *clusterFixups) Name() string { } func (m *clusterFixups) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { - for _, cluster := range b.Config.Resources.Clusters { + var diags diag.Diagnostics + for key, cluster := range b.Config.Resources.Clusters { if cluster == nil { continue } + if dropNumWorkersWithAutoscale(&cluster.Autoscale, &cluster.NumWorkers) { + diags = diags.Append(numWorkersIgnored(b, "resources", "clusters", key, "num_workers")) + } // TODO: we should raise a warning when user specify both InstancePoolId and NodeTypeId since it's illegal. // Once we remove TF backend and had warning for some time, we can remove this transformation, the backend // will reject such configs. - ModifyRequestOnInstancePool(&cluster.ClusterSpec) + ModifyRequestOnInstancePool(&cluster.CreateClusterRequest) + } + return diags +} + +// dropNumWorkersWithAutoscale clears num_workers when autoscale is also set and +// reports whether it did. The API treats the two as alternatives (a oneof) and +// autoscale takes precedence. +func dropNumWorkersWithAutoscale[A any](autoscale **A, numWorkers **int) bool { + if *autoscale == nil || *numWorkers == nil { + return false + } + *numWorkers = nil + return true +} + +func numWorkersIgnored(b *bundle.Bundle, parts ...any) diag.Diagnostic { + path := structpath.NewPath(nil, parts...) + return diag.Diagnostic{ + Severity: diag.Warning, + Summary: "num_workers is ignored because autoscale is set", + Locations: b.Config.GetLocationsOf(path), + Paths: []*structpath.PathNode{path}, } - return nil } // Copied from // https://github.com/databricks/terraform-provider-databricks/blob/a8c92bb/clusters/resource_cluster.go // https://github.com/databricks/terraform-provider-databricks/blob/a8c92bb/clusters/clusters_api.go#L440 -func ModifyRequestOnInstancePool(c *compute.ClusterSpec) { +func ModifyRequestOnInstancePool(c *clusters.CreateClusterRequest) { // Instance profile id does not exist or not set - if c.InstancePoolId == "" { + if utils.Deref(c.InstancePoolId) == "" { // Worker must use an instance pool if driver uses an instance pool, // therefore empty the computed value for driver instance pool. - c.DriverInstancePoolId = "" + c.DriverInstancePoolId = nil return } if c.AwsAttributes != nil { // Reset AwsAttributes - awsAttributes := compute.AwsAttributes{ + c.AwsAttributes = &clusters.AwsAttributes{ InstanceProfileArn: c.AwsAttributes.InstanceProfileArn, } - c.AwsAttributes = &awsAttributes } if c.AzureAttributes != nil { - c.AzureAttributes = &compute.AzureAttributes{} + c.AzureAttributes = &clusters.AzureAttributes{} } if c.GcpAttributes != nil { - gcpAttributes := compute.GcpAttributes{ + c.GcpAttributes = &clusters.GcpAttributes{ GoogleServiceAccount: c.GcpAttributes.GoogleServiceAccount, } - c.GcpAttributes = &gcpAttributes } - c.EnableElasticDisk = false - c.NodeTypeId = "" - c.DriverNodeTypeId = "" + if utils.Deref(c.EnableElasticDisk) { + c.EnableElasticDisk = nil + } + c.NodeTypeId = nil + c.DriverNodeTypeId = nil +} + +// modifyJobClusterOnInstancePool is [ModifyRequestOnInstancePool] for job clusters. +func modifyJobClusterOnInstancePool(c *jobs.ClusterSpec_NewCluster) { + if utils.Deref(c.InstancePoolId) == "" { + c.DriverInstancePoolId = nil + return + } + if c.AwsAttributes != nil { + c.AwsAttributes = &jobs.AwsAttributes{ + InstanceProfileArn: c.AwsAttributes.InstanceProfileArn, + } + } + if c.AzureAttributes != nil { + c.AzureAttributes = &jobs.AzureAttributes{} + } + if c.GcpAttributes != nil { + c.GcpAttributes = &jobs.GcpAttributes{ + GoogleServiceAccount: c.GcpAttributes.GoogleServiceAccount, + } + } + if utils.Deref(c.EnableElasticDisk) { + c.EnableElasticDisk = nil + } + c.NodeTypeId = nil + c.DriverNodeTypeId = nil } // Copied https://github.com/databricks/terraform-provider-databricks/blob/a8c92bb130def431b3fadd9fd533c463e8d4813b/jobs/resource_job.go#L1016 func prepareJobSettingsForUpdate(js *jobs.JobSettings) { for _, task := range js.Tasks { if task.NewCluster != nil { - ModifyRequestOnInstancePool(task.NewCluster) + modifyJobClusterOnInstancePool(task.NewCluster) } } for ind := range js.JobClusters { nc := js.JobClusters[ind].NewCluster if nc != nil { - ModifyRequestOnInstancePool(nc) + modifyJobClusterOnInstancePool(nc) initializeNumWorkers(nc) } } } -func initializeNumWorkers(c *compute.ClusterSpec) { - if c.Autoscale != nil { - return - } - if c.NumWorkers != 0 { - return - } - if slices.Contains(c.ForceSendFields, "NumWorkers") { +// initializeNumWorkers makes a fixed-size job cluster send num_workers=0 +// explicitly instead of omitting it. +func initializeNumWorkers(c *jobs.ClusterSpec_NewCluster) { + if c.Autoscale != nil || c.NumWorkers != nil { return } - c.ForceSendFields = append(c.ForceSendFields, "NumWorkers") + c.NumWorkers = new(0) } diff --git a/bundle/config/mutator/resourcemutator/expand_pipeline_glob_paths_test.go b/bundle/config/mutator/resourcemutator/expand_pipeline_glob_paths_test.go index ead2084d835..8b6bbe21c45 100644 --- a/bundle/config/mutator/resourcemutator/expand_pipeline_glob_paths_test.go +++ b/bundle/config/mutator/resourcemutator/expand_pipeline_glob_paths_test.go @@ -5,6 +5,8 @@ import ( "path/filepath" "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config/mutator" "github.com/databricks/cli/bundle/config/mutator/resourcemutator" @@ -15,8 +17,7 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/stretchr/testify/require" ) @@ -51,55 +52,55 @@ func TestExpandGlobPathsInPipelines(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Libraries: []pipelines.PipelineLibrary{ { Notebook: &pipelines.NotebookLibrary{ - Path: "./**/*.ipynb", + Path: new("./**/*.ipynb"), }, }, { - Jar: "./*.jar", + Jar: new("./*.jar"), }, { - File: &pipelines.FileLibrary{ - Path: "./test/*.py", + File: &pipelines.NotebookLibrary{ + Path: new("./test/*.py"), }, }, { // This value is annotated to be defined in the "./relative" directory. - File: &pipelines.FileLibrary{ - Path: "./*.py", + File: &pipelines.NotebookLibrary{ + Path: new("./*.py"), }, }, { - Maven: &compute.MavenLibrary{ - Coordinates: "org.jsoup:jsoup:1.7.2", + Maven: &pipelines.PipelinesMavenLibrary{ + Coordinates: new("org.jsoup:jsoup:1.7.2"), }, }, { Notebook: &pipelines.NotebookLibrary{ - Path: "./test1.ipynb", + Path: new("./test1.ipynb"), }, }, { Notebook: &pipelines.NotebookLibrary{ - Path: "/Workspace/Users/me@company.com/test.ipynb", + Path: new("/Workspace/Users/me@company.com/test.ipynb"), }, }, { Notebook: &pipelines.NotebookLibrary{ - Path: "dbfs:/me@company.com/test.ipynb", + Path: new("dbfs:/me@company.com/test.ipynb"), }, }, { Notebook: &pipelines.NotebookLibrary{ - Path: "/Repos/somerepo/test.ipynb", + Path: new("/Repos/somerepo/test.ipynb"), }, }, { Notebook: &pipelines.NotebookLibrary{ - Path: "./non-existent.ipynb", + Path: new("./non-existent.ipynb"), }, }, }, @@ -159,7 +160,7 @@ func collectNotebooks(libraries []pipelines.PipelineLibrary) []string { var paths []string for _, l := range libraries { if l.Notebook != nil { - paths = append(paths, l.Notebook.Path) + paths = append(paths, utils.Deref(l.Notebook.Path)) } } @@ -169,8 +170,8 @@ func collectNotebooks(libraries []pipelines.PipelineLibrary) []string { func collectJars(libraries []pipelines.PipelineLibrary) []string { var paths []string for _, l := range libraries { - if l.Jar != "" { - paths = append(paths, l.Jar) + if utils.Deref(l.Jar) != "" { + paths = append(paths, utils.Deref(l.Jar)) } } @@ -181,7 +182,7 @@ func collectMaven(libraries []pipelines.PipelineLibrary) []string { var coordinates []string for _, l := range libraries { if l.Maven != nil { - coordinates = append(coordinates, l.Maven.Coordinates) + coordinates = append(coordinates, utils.Deref(l.Maven.Coordinates)) } } @@ -192,7 +193,7 @@ func collectFiles(libraries []pipelines.PipelineLibrary) []string { var paths []string for _, l := range libraries { if l.File != nil { - paths = append(paths, l.File.Path) + paths = append(paths, utils.Deref(l.File.Path)) } } diff --git a/bundle/config/mutator/resourcemutator/fix_permissions.go b/bundle/config/mutator/resourcemutator/fix_permissions.go index 9e6c785b0d9..26a98a2e2ab 100644 --- a/bundle/config/mutator/resourcemutator/fix_permissions.go +++ b/bundle/config/mutator/resourcemutator/fix_permissions.go @@ -4,6 +4,8 @@ import ( "context" "strings" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" @@ -220,7 +222,7 @@ func (m *fixPermissions) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagn if b.Config.Workspace.CurrentUser == nil { return nil } - currentUser := b.Config.Workspace.CurrentUser.UserName + currentUser := utils.Deref(b.Config.Workspace.CurrentUser.UserName) err := b.Config.Mutate(func(v dyn.Value) (dyn.Value, error) { // Use MapByPattern to directly process permissions arrays diff --git a/bundle/config/mutator/resourcemutator/merge_apps_test.go b/bundle/config/mutator/resourcemutator/merge_apps_test.go index d207fc2d7b3..a4da35665da 100644 --- a/bundle/config/mutator/resourcemutator/merge_apps_test.go +++ b/bundle/config/mutator/resourcemutator/merge_apps_test.go @@ -3,12 +3,14 @@ package resourcemutator_test import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config/mutator/resourcemutator" "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/cli/libs/sdktypes/apps/v1" "github.com/stretchr/testify/assert" ) @@ -19,33 +21,33 @@ func TestMergeApps(t *testing.T) { Apps: map[string]*resources.App{ "foo": { App: apps.App{ - Name: "foo", + Name: new("foo"), Resources: []apps.AppResource{ { - Name: "job1", + Name: new("job1"), Job: &apps.AppResourceJob{ - Id: "1234", + Id: new("1234"), Permission: "CAN_MANAGE_RUN", }, }, { - Name: "sql1", + Name: new("sql1"), SqlWarehouse: &apps.AppResourceSqlWarehouse{ - Id: "5678", + Id: new("5678"), Permission: "CAN_USE", }, }, { - Name: "job1", + Name: new("job1"), Job: &apps.AppResourceJob{ - Id: "1234", + Id: new("1234"), Permission: "CAN_MANAGE", }, }, { - Name: "sql1", + Name: new("sql1"), Job: &apps.AppResourceJob{ - Id: "9876", + Id: new("9876"), Permission: "CAN_MANAGE", }, }, @@ -63,8 +65,8 @@ func TestMergeApps(t *testing.T) { j := b.Config.Resources.Apps["foo"] assert.Len(t, j.Resources, 2) - assert.Equal(t, "job1", j.Resources[0].Name) - assert.Equal(t, "sql1", j.Resources[1].Name) + assert.Equal(t, "job1", utils.Deref(j.Resources[0].Name)) + assert.Equal(t, "sql1", utils.Deref(j.Resources[1].Name)) assert.Equal(t, "CAN_MANAGE", string(j.Resources[0].Job.Permission)) diff --git a/bundle/config/mutator/resourcemutator/merge_job_clusters_test.go b/bundle/config/mutator/resourcemutator/merge_job_clusters_test.go index 4f981022609..ba7c1846407 100644 --- a/bundle/config/mutator/resourcemutator/merge_job_clusters_test.go +++ b/bundle/config/mutator/resourcemutator/merge_job_clusters_test.go @@ -3,13 +3,14 @@ package resourcemutator_test import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config/mutator/resourcemutator" "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" ) @@ -22,24 +23,24 @@ func TestMergeJobClusters(t *testing.T) { JobSettings: jobs.JobSettings{ JobClusters: []jobs.JobCluster{ { - JobClusterKey: "foo", - NewCluster: &compute.ClusterSpec{ - SparkVersion: "13.3.x-scala2.12", - NodeTypeId: "i3.xlarge", - NumWorkers: 2, + JobClusterKey: new("foo"), + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("13.3.x-scala2.12"), + NodeTypeId: new("i3.xlarge"), + NumWorkers: new(2), }, }, { - JobClusterKey: "bar", - NewCluster: &compute.ClusterSpec{ - SparkVersion: "10.4.x-scala2.12", + JobClusterKey: new("bar"), + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("10.4.x-scala2.12"), }, }, { - JobClusterKey: "foo", - NewCluster: &compute.ClusterSpec{ - NodeTypeId: "i3.2xlarge", - NumWorkers: 4, + JobClusterKey: new("foo"), + NewCluster: &jobs.ClusterSpec_NewCluster{ + NodeTypeId: new("i3.2xlarge"), + NumWorkers: new(4), }, }, }, @@ -56,18 +57,18 @@ func TestMergeJobClusters(t *testing.T) { j := b.Config.Resources.Jobs["foo"] assert.Len(t, j.JobClusters, 2) - assert.Equal(t, "foo", j.JobClusters[0].JobClusterKey) - assert.Equal(t, "bar", j.JobClusters[1].JobClusterKey) + assert.Equal(t, "foo", utils.Deref(j.JobClusters[0].JobClusterKey)) + assert.Equal(t, "bar", utils.Deref(j.JobClusters[1].JobClusterKey)) // This job cluster was merged with a subsequent one. jc0 := j.JobClusters[0].NewCluster - assert.Equal(t, "13.3.x-scala2.12", jc0.SparkVersion) - assert.Equal(t, "i3.2xlarge", jc0.NodeTypeId) - assert.Equal(t, 4, jc0.NumWorkers) + assert.Equal(t, "13.3.x-scala2.12", utils.Deref(jc0.SparkVersion)) + assert.Equal(t, "i3.2xlarge", utils.Deref(jc0.NodeTypeId)) + assert.Equal(t, 4, utils.Deref(jc0.NumWorkers)) // This job cluster was left untouched. jc1 := j.JobClusters[1].NewCluster - assert.Equal(t, "10.4.x-scala2.12", jc1.SparkVersion) + assert.Equal(t, "10.4.x-scala2.12", utils.Deref(jc1.SparkVersion)) } func TestMergeJobClustersWithNilKey(t *testing.T) { @@ -79,16 +80,16 @@ func TestMergeJobClustersWithNilKey(t *testing.T) { JobSettings: jobs.JobSettings{ JobClusters: []jobs.JobCluster{ { - NewCluster: &compute.ClusterSpec{ - SparkVersion: "13.3.x-scala2.12", - NodeTypeId: "i3.xlarge", - NumWorkers: 2, + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("13.3.x-scala2.12"), + NodeTypeId: new("i3.xlarge"), + NumWorkers: new(2), }, }, { - NewCluster: &compute.ClusterSpec{ - NodeTypeId: "i3.2xlarge", - NumWorkers: 4, + NewCluster: &jobs.ClusterSpec_NewCluster{ + NodeTypeId: new("i3.2xlarge"), + NumWorkers: new(4), }, }, }, diff --git a/bundle/config/mutator/resourcemutator/merge_job_parameters_test.go b/bundle/config/mutator/resourcemutator/merge_job_parameters_test.go index f616a2e880c..10814801f5b 100644 --- a/bundle/config/mutator/resourcemutator/merge_job_parameters_test.go +++ b/bundle/config/mutator/resourcemutator/merge_job_parameters_test.go @@ -3,12 +3,14 @@ package resourcemutator_test import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config/mutator/resourcemutator" "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" ) @@ -19,18 +21,18 @@ func TestMergeJobParameters(t *testing.T) { Jobs: map[string]*resources.Job{ "foo": { JobSettings: jobs.JobSettings{ - Parameters: []jobs.JobParameterDefinition{ + Parameters: []jobs.JobLevelParameter{ { - Name: "foo", - Default: "v1", + Name: new("foo"), + Default: new("v1"), }, { - Name: "bar", - Default: "v1", + Name: new("bar"), + Default: new("v1"), }, { - Name: "foo", - Default: "v2", + Name: new("foo"), + Default: new("v2"), }, }, }, @@ -46,10 +48,10 @@ func TestMergeJobParameters(t *testing.T) { j := b.Config.Resources.Jobs["foo"] assert.Len(t, j.Parameters, 2) - assert.Equal(t, "foo", j.Parameters[0].Name) - assert.Equal(t, "v2", j.Parameters[0].Default) - assert.Equal(t, "bar", j.Parameters[1].Name) - assert.Equal(t, "v1", j.Parameters[1].Default) + assert.Equal(t, "foo", utils.Deref(j.Parameters[0].Name)) + assert.Equal(t, "v2", utils.Deref(j.Parameters[0].Default)) + assert.Equal(t, "bar", utils.Deref(j.Parameters[1].Name)) + assert.Equal(t, "v1", utils.Deref(j.Parameters[1].Default)) } func TestMergeJobParametersWithNilKey(t *testing.T) { @@ -59,12 +61,12 @@ func TestMergeJobParametersWithNilKey(t *testing.T) { Jobs: map[string]*resources.Job{ "foo": { JobSettings: jobs.JobSettings{ - Parameters: []jobs.JobParameterDefinition{ + Parameters: []jobs.JobLevelParameter{ { - Default: "v1", + Default: new("v1"), }, { - Default: "v2", + Default: new("v2"), }, }, }, diff --git a/bundle/config/mutator/resourcemutator/merge_job_tasks_test.go b/bundle/config/mutator/resourcemutator/merge_job_tasks_test.go index d54b2f17ed7..1ae5776b3c9 100644 --- a/bundle/config/mutator/resourcemutator/merge_job_tasks_test.go +++ b/bundle/config/mutator/resourcemutator/merge_job_tasks_test.go @@ -3,13 +3,14 @@ package resourcemutator_test import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config/mutator/resourcemutator" "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" ) @@ -20,33 +21,33 @@ func TestMergeJobTasks(t *testing.T) { Jobs: map[string]*resources.Job{ "foo": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "foo", - NewCluster: &compute.ClusterSpec{ - SparkVersion: "13.3.x-scala2.12", - NodeTypeId: "i3.xlarge", - NumWorkers: 2, + TaskKey: new("foo"), + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("13.3.x-scala2.12"), + NodeTypeId: new("i3.xlarge"), + NumWorkers: new(2), }, - Libraries: []compute.Library{ - {Whl: "package1"}, + Libraries: []jobs.Library{ + {Whl: new("package1")}, }, }, { - TaskKey: "bar", - NewCluster: &compute.ClusterSpec{ - SparkVersion: "10.4.x-scala2.12", + TaskKey: new("bar"), + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("10.4.x-scala2.12"), }, }, { - TaskKey: "foo", - NewCluster: &compute.ClusterSpec{ - NodeTypeId: "i3.2xlarge", - NumWorkers: 4, + TaskKey: new("foo"), + NewCluster: &jobs.ClusterSpec_NewCluster{ + NodeTypeId: new("i3.2xlarge"), + NumWorkers: new(4), }, - Libraries: []compute.Library{ - {Pypi: &compute.PythonPyPiLibrary{ - Package: "package2", + Libraries: []jobs.Library{ + {Pypi: &jobs.PythonPyPiLibrary{ + Package: new("package2"), }}, }, }, @@ -64,22 +65,22 @@ func TestMergeJobTasks(t *testing.T) { j := b.Config.Resources.Jobs["foo"] assert.Len(t, j.Tasks, 2) - assert.Equal(t, "foo", j.Tasks[1].TaskKey) - assert.Equal(t, "bar", j.Tasks[0].TaskKey) + assert.Equal(t, "foo", utils.Deref(j.Tasks[1].TaskKey)) + assert.Equal(t, "bar", utils.Deref(j.Tasks[0].TaskKey)) // This task was merged with a subsequent one. task0 := j.Tasks[1] cluster := task0.NewCluster - assert.Equal(t, "13.3.x-scala2.12", cluster.SparkVersion) - assert.Equal(t, "i3.2xlarge", cluster.NodeTypeId) - assert.Equal(t, 4, cluster.NumWorkers) + assert.Equal(t, "13.3.x-scala2.12", utils.Deref(cluster.SparkVersion)) + assert.Equal(t, "i3.2xlarge", utils.Deref(cluster.NodeTypeId)) + assert.Equal(t, 4, utils.Deref(cluster.NumWorkers)) assert.Len(t, task0.Libraries, 2) - assert.Equal(t, "package1", task0.Libraries[0].Whl) - assert.Equal(t, "package2", task0.Libraries[1].Pypi.Package) + assert.Equal(t, "package1", utils.Deref(task0.Libraries[0].Whl)) + assert.Equal(t, "package2", utils.Deref(task0.Libraries[1].Pypi.Package)) // This task was left untouched. task1 := j.Tasks[0].NewCluster - assert.Equal(t, "10.4.x-scala2.12", task1.SparkVersion) + assert.Equal(t, "10.4.x-scala2.12", utils.Deref(task1.SparkVersion)) } func TestMergeJobTasksWithNilKey(t *testing.T) { @@ -89,18 +90,18 @@ func TestMergeJobTasksWithNilKey(t *testing.T) { Jobs: map[string]*resources.Job{ "foo": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - NewCluster: &compute.ClusterSpec{ - SparkVersion: "13.3.x-scala2.12", - NodeTypeId: "i3.xlarge", - NumWorkers: 2, + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("13.3.x-scala2.12"), + NodeTypeId: new("i3.xlarge"), + NumWorkers: new(2), }, }, { - NewCluster: &compute.ClusterSpec{ - NodeTypeId: "i3.2xlarge", - NumWorkers: 4, + NewCluster: &jobs.ClusterSpec_NewCluster{ + NodeTypeId: new("i3.2xlarge"), + NumWorkers: new(4), }, }, }, diff --git a/bundle/config/mutator/resourcemutator/merge_pipeline_clusters_test.go b/bundle/config/mutator/resourcemutator/merge_pipeline_clusters_test.go index e27d174465c..fcbaa24d14a 100644 --- a/bundle/config/mutator/resourcemutator/merge_pipeline_clusters_test.go +++ b/bundle/config/mutator/resourcemutator/merge_pipeline_clusters_test.go @@ -4,12 +4,14 @@ import ( "strings" "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config/mutator/resourcemutator" "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/stretchr/testify/assert" ) @@ -19,20 +21,20 @@ func TestMergePipelineClusters(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "foo": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Clusters: []pipelines.PipelineCluster{ { - NodeTypeId: "i3.xlarge", - NumWorkers: 2, - PolicyId: "1234", + NodeTypeId: new("i3.xlarge"), + NumWorkers: new(2), + PolicyId: new("1234"), }, { - Label: "maintenance", - NodeTypeId: "i3.2xlarge", + Label: new("maintenance"), + NodeTypeId: new("i3.2xlarge"), }, { - NodeTypeId: "i3.2xlarge", - NumWorkers: 4, + NodeTypeId: new("i3.2xlarge"), + NumWorkers: new(4), }, }, }, @@ -48,18 +50,18 @@ func TestMergePipelineClusters(t *testing.T) { p := b.Config.Resources.Pipelines["foo"] assert.Len(t, p.Clusters, 2) - assert.Equal(t, "default", p.Clusters[0].Label) - assert.Equal(t, "maintenance", p.Clusters[1].Label) + assert.Equal(t, "default", utils.Deref(p.Clusters[0].Label)) + assert.Equal(t, "maintenance", utils.Deref(p.Clusters[1].Label)) // The default cluster was merged with a subsequent one. pc0 := p.Clusters[0] - assert.Equal(t, "i3.2xlarge", pc0.NodeTypeId) - assert.Equal(t, 4, pc0.NumWorkers) - assert.Equal(t, "1234", pc0.PolicyId) + assert.Equal(t, "i3.2xlarge", utils.Deref(pc0.NodeTypeId)) + assert.Equal(t, 4, utils.Deref(pc0.NumWorkers)) + assert.Equal(t, "1234", utils.Deref(pc0.PolicyId)) // The maintenance cluster was left untouched. pc1 := p.Clusters[1] - assert.Equal(t, "i3.2xlarge", pc1.NodeTypeId) + assert.Equal(t, "i3.2xlarge", utils.Deref(pc1.NodeTypeId)) } func TestMergePipelineClustersCaseInsensitive(t *testing.T) { @@ -68,15 +70,15 @@ func TestMergePipelineClustersCaseInsensitive(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "foo": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Clusters: []pipelines.PipelineCluster{ { - Label: "default", - NumWorkers: 2, + Label: new("default"), + NumWorkers: new(2), }, { - Label: "DEFAULT", - NumWorkers: 4, + Label: new("DEFAULT"), + NumWorkers: new(4), }, }, }, @@ -94,8 +96,8 @@ func TestMergePipelineClustersCaseInsensitive(t *testing.T) { // The default cluster was merged with a subsequent one. pc0 := p.Clusters[0] - assert.Equal(t, "default", strings.ToLower(pc0.Label)) - assert.Equal(t, 4, pc0.NumWorkers) + assert.Equal(t, "default", strings.ToLower(utils.Deref(pc0.Label))) + assert.Equal(t, 4, utils.Deref(pc0.NumWorkers)) } func TestMergePipelineClustersNilPipelines(t *testing.T) { diff --git a/bundle/config/mutator/resourcemutator/model_serving_endpoint_fixups.go b/bundle/config/mutator/resourcemutator/model_serving_endpoint_fixups.go index 6c25146e6bd..86b2c726799 100644 --- a/bundle/config/mutator/resourcemutator/model_serving_endpoint_fixups.go +++ b/bundle/config/mutator/resourcemutator/model_serving_endpoint_fixups.go @@ -5,8 +5,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/diag" - "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go/service/serving" + "github.com/databricks/cli/libs/sdktypes/modelserving/v1" ) type modelServingEndpointFixups struct{} @@ -19,8 +18,8 @@ func (m *modelServingEndpointFixups) Name() string { return "ModelServingEndpointFixups" } -func servedModelToServedEntity(model serving.ServedModelInput) serving.ServedEntityInput { - return serving.ServedEntityInput{ +func servedModelToServedEntity(model modelserving.ServedModel) modelserving.ServedModel { + return modelserving.ServedModel{ // served_models does not support ExternalModel, so we set ExternalModel to nil ExternalModel: nil, @@ -34,10 +33,8 @@ func servedModelToServedEntity(model serving.ServedModelInput) serving.ServedEnt ProvisionedModelUnits: model.ProvisionedModelUnits, ScaleToZeroEnabled: model.ScaleToZeroEnabled, WorkloadSize: model.WorkloadSize, - WorkloadType: serving.ServingModelWorkloadType(model.WorkloadType), MaxProvisionedConcurrency: model.MaxProvisionedConcurrency, MinProvisionedConcurrency: model.MinProvisionedConcurrency, - ForceSendFields: utils.FilterFields[serving.ServedEntityInput](model.ForceSendFields), } } @@ -75,7 +72,7 @@ func (m *modelServingEndpointFixups) Apply(ctx context.Context, b *bundle.Bundle }, }) - endpoint.Config.ServedEntities = make([]serving.ServedEntityInput, len(endpoint.Config.ServedModels)) + endpoint.Config.ServedEntities = make([]modelserving.ServedModel, len(endpoint.Config.ServedModels)) for i, model := range endpoint.Config.ServedModels { endpoint.Config.ServedEntities[i] = servedModelToServedEntity(model) } diff --git a/bundle/config/mutator/resourcemutator/override_compute.go b/bundle/config/mutator/resourcemutator/override_compute.go index 6b5251248d5..2a6764a8f6e 100644 --- a/bundle/config/mutator/resourcemutator/override_compute.go +++ b/bundle/config/mutator/resourcemutator/override_compute.go @@ -9,6 +9,7 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/env" + "github.com/databricks/cli/libs/utils" ) type overrideCompute struct{} @@ -25,15 +26,15 @@ func overrideJobCompute(j *resources.Job, compute string) { for i := range j.Tasks { task := &j.Tasks[i] - if task.ForEachTask != nil { - task = &task.ForEachTask.Task + if task.ForEachTask != nil && task.ForEachTask.Task != nil { + task = task.ForEachTask.Task } - if task.NewCluster != nil || task.ExistingClusterId != "" || task.EnvironmentKey != "" || task.JobClusterKey != "" { + if task.NewCluster != nil || utils.Deref(task.ExistingClusterId) != "" || utils.Deref(task.EnvironmentKey) != "" || utils.Deref(task.JobClusterKey) != "" { task.NewCluster = nil - task.JobClusterKey = "" - task.EnvironmentKey = "" - task.ExistingClusterId = compute + task.JobClusterKey = nil + task.EnvironmentKey = nil + task.ExistingClusterId = new(compute) } } } diff --git a/bundle/config/mutator/resourcemutator/override_compute_test.go b/bundle/config/mutator/resourcemutator/override_compute_test.go index c56456d46a1..80369a4c0a2 100644 --- a/bundle/config/mutator/resourcemutator/override_compute_test.go +++ b/bundle/config/mutator/resourcemutator/override_compute_test.go @@ -3,14 +3,15 @@ package resourcemutator_test import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config/mutator/resourcemutator" "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -26,21 +27,21 @@ func TestOverrideComputeModeDevelopment(t *testing.T) { Resources: config.Resources{ Jobs: map[string]*resources.Job{ "job1": {JobSettings: jobs.JobSettings{ - Name: "job1", - Tasks: []jobs.Task{ + Name: new("job1"), + Tasks: []jobs.TaskSettings{ { - NewCluster: &compute.ClusterSpec{ - SparkVersion: "14.2.x-scala2.12", + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("14.2.x-scala2.12"), }, }, { - ExistingClusterId: "cluster2", + ExistingClusterId: new("cluster2"), }, { - EnvironmentKey: "environment_key", + EnvironmentKey: new("environment_key"), }, { - JobClusterKey: "cluster_key", + JobClusterKey: new("cluster_key"), }, }, }}, @@ -53,14 +54,14 @@ func TestOverrideComputeModeDevelopment(t *testing.T) { diags := bundle.Apply(t.Context(), b, m) require.NoError(t, diags.Error()) assert.Nil(t, b.Config.Resources.Jobs["job1"].Tasks[0].NewCluster) - assert.Equal(t, "newClusterID", b.Config.Resources.Jobs["job1"].Tasks[0].ExistingClusterId) - assert.Equal(t, "newClusterID", b.Config.Resources.Jobs["job1"].Tasks[1].ExistingClusterId) - assert.Equal(t, "newClusterID", b.Config.Resources.Jobs["job1"].Tasks[2].ExistingClusterId) - assert.Equal(t, "newClusterID", b.Config.Resources.Jobs["job1"].Tasks[3].ExistingClusterId) + assert.Equal(t, "newClusterID", utils.Deref(b.Config.Resources.Jobs["job1"].Tasks[0].ExistingClusterId)) + assert.Equal(t, "newClusterID", utils.Deref(b.Config.Resources.Jobs["job1"].Tasks[1].ExistingClusterId)) + assert.Equal(t, "newClusterID", utils.Deref(b.Config.Resources.Jobs["job1"].Tasks[2].ExistingClusterId)) + assert.Equal(t, "newClusterID", utils.Deref(b.Config.Resources.Jobs["job1"].Tasks[3].ExistingClusterId)) assert.Nil(t, b.Config.Resources.Jobs["job1"].Tasks[0].NewCluster) - assert.Empty(t, b.Config.Resources.Jobs["job1"].Tasks[2].EnvironmentKey) - assert.Empty(t, b.Config.Resources.Jobs["job1"].Tasks[3].JobClusterKey) + assert.Empty(t, utils.Deref(b.Config.Resources.Jobs["job1"].Tasks[2].EnvironmentKey)) + assert.Empty(t, utils.Deref(b.Config.Resources.Jobs["job1"].Tasks[3].JobClusterKey)) } func TestOverrideComputeModeDefaultIgnoresVariable(t *testing.T) { @@ -73,13 +74,13 @@ func TestOverrideComputeModeDefaultIgnoresVariable(t *testing.T) { Resources: config.Resources{ Jobs: map[string]*resources.Job{ "job1": {JobSettings: jobs.JobSettings{ - Name: "job1", - Tasks: []jobs.Task{ + Name: new("job1"), + Tasks: []jobs.TaskSettings{ { - NewCluster: &compute.ClusterSpec{}, + NewCluster: &jobs.ClusterSpec_NewCluster{}, }, { - ExistingClusterId: "cluster2", + ExistingClusterId: new("cluster2"), }, }, }}, @@ -92,7 +93,7 @@ func TestOverrideComputeModeDefaultIgnoresVariable(t *testing.T) { diags := bundle.Apply(t.Context(), b, m) require.Len(t, diags, 1) assert.Equal(t, "The DATABRICKS_CLUSTER_ID variable is set but is ignored since the current target does not use 'mode: development'", diags[0].Summary) - assert.Equal(t, "cluster2", b.Config.Resources.Jobs["job1"].Tasks[1].ExistingClusterId) + assert.Equal(t, "cluster2", utils.Deref(b.Config.Resources.Jobs["job1"].Tasks[1].ExistingClusterId)) } func TestOverrideComputePipelineTask(t *testing.T) { @@ -102,8 +103,8 @@ func TestOverrideComputePipelineTask(t *testing.T) { Resources: config.Resources{ Jobs: map[string]*resources.Job{ "job1": {JobSettings: jobs.JobSettings{ - Name: "job1", - Tasks: []jobs.Task{ + Name: new("job1"), + Tasks: []jobs.TaskSettings{ { PipelineTask: &jobs.PipelineTask{}, }, @@ -117,7 +118,7 @@ func TestOverrideComputePipelineTask(t *testing.T) { m := resourcemutator.OverrideCompute() diags := bundle.Apply(t.Context(), b, m) require.NoError(t, diags.Error()) - assert.Empty(t, b.Config.Resources.Jobs["job1"].Tasks[0].ExistingClusterId) + assert.Empty(t, utils.Deref(b.Config.Resources.Jobs["job1"].Tasks[0].ExistingClusterId)) } func TestOverrideComputeForEachTask(t *testing.T) { @@ -127,8 +128,8 @@ func TestOverrideComputeForEachTask(t *testing.T) { Resources: config.Resources{ Jobs: map[string]*resources.Job{ "job1": {JobSettings: jobs.JobSettings{ - Name: "job1", - Tasks: []jobs.Task{ + Name: new("job1"), + Tasks: []jobs.TaskSettings{ { ForEachTask: &jobs.ForEachTask{}, }, @@ -155,13 +156,13 @@ func TestOverrideComputeModeProduction(t *testing.T) { Resources: config.Resources{ Jobs: map[string]*resources.Job{ "job1": {JobSettings: jobs.JobSettings{ - Name: "job1", - Tasks: []jobs.Task{ + Name: new("job1"), + Tasks: []jobs.TaskSettings{ { - NewCluster: &compute.ClusterSpec{}, + NewCluster: &jobs.ClusterSpec_NewCluster{}, }, { - ExistingClusterId: "cluster2", + ExistingClusterId: new("cluster2"), }, }, }}, @@ -175,7 +176,7 @@ func TestOverrideComputeModeProduction(t *testing.T) { require.Len(t, diags, 1) assert.Equal(t, "Setting a cluster override for a target that uses 'mode: production' is not recommended", diags[0].Summary) assert.Equal(t, diag.Warning, diags[0].Severity) - assert.Equal(t, "newClusterID", b.Config.Resources.Jobs["job1"].Tasks[0].ExistingClusterId) + assert.Equal(t, "newClusterID", utils.Deref(b.Config.Resources.Jobs["job1"].Tasks[0].ExistingClusterId)) } func TestOverrideComputeModeProductionIgnoresVariable(t *testing.T) { @@ -188,13 +189,13 @@ func TestOverrideComputeModeProductionIgnoresVariable(t *testing.T) { Resources: config.Resources{ Jobs: map[string]*resources.Job{ "job1": {JobSettings: jobs.JobSettings{ - Name: "job1", - Tasks: []jobs.Task{ + Name: new("job1"), + Tasks: []jobs.TaskSettings{ { - NewCluster: &compute.ClusterSpec{}, + NewCluster: &jobs.ClusterSpec_NewCluster{}, }, { - ExistingClusterId: "cluster2", + ExistingClusterId: new("cluster2"), }, }, }}, @@ -207,5 +208,5 @@ func TestOverrideComputeModeProductionIgnoresVariable(t *testing.T) { diags := bundle.Apply(t.Context(), b, m) require.Len(t, diags, 1) assert.Equal(t, "The DATABRICKS_CLUSTER_ID variable is set but is ignored since the current target does not use 'mode: development'", diags[0].Summary) - assert.Equal(t, "cluster2", b.Config.Resources.Jobs["job1"].Tasks[1].ExistingClusterId) + assert.Equal(t, "cluster2", utils.Deref(b.Config.Resources.Jobs["job1"].Tasks[1].ExistingClusterId)) } diff --git a/bundle/config/mutator/resourcemutator/run_as.go b/bundle/config/mutator/resourcemutator/run_as.go index 65279c7f212..626ad6db5d3 100644 --- a/bundle/config/mutator/resourcemutator/run_as.go +++ b/bundle/config/mutator/resourcemutator/run_as.go @@ -9,10 +9,11 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/utils" ) type setRunAs struct{} @@ -48,7 +49,7 @@ func validateRunAs(b *bundle.Bundle) diag.Diagnostics { identityCount := 0 runAs := b.Config.RunAs if runAs != nil { - for _, identity := range []string{runAs.UserName, runAs.ServicePrincipalName, runAs.GroupName} { + for _, identity := range []string{utils.Deref(runAs.UserName), utils.Deref(runAs.ServicePrincipalName), utils.Deref(runAs.GroupName)} { if identity != "" { identityCount++ } @@ -62,18 +63,20 @@ func validateRunAs(b *bundle.Bundle) diag.Diagnostics { }} } - identity := runAs.ServicePrincipalName + identity := utils.Deref(runAs.ServicePrincipalName) if identity == "" { - identity = runAs.UserName + identity = utils.Deref(runAs.UserName) } + currentUser := utils.Deref(b.Config.Workspace.CurrentUser.UserName) + groupName := utils.Deref(runAs.GroupName) // All resources are supported if the run_as identity is the same as the current deployment identity. - if runAs.GroupName == "" && identity == b.Config.Workspace.CurrentUser.UserName { + if groupName == "" && identity == currentUser { return diags } - if runAs.GroupName != "" { - identity = fmt.Sprintf("group %q", runAs.GroupName) + if groupName != "" { + identity = fmt.Sprintf("group %q", groupName) for _, alert := range b.Config.Resources.Alerts { if alert.RunAs == nil { return diag.Errorf("alerts do not support run_as.group_name; set run_as.user_name or run_as.service_principal_name on each alert") @@ -86,7 +89,7 @@ func validateRunAs(b *bundle.Bundle) diag.Diagnostics { diags = diags.Extend(reportRunAsNotSupported( "model_serving_endpoints", b.Config.GetLocation("resources.model_serving_endpoints"), - b.Config.Workspace.CurrentUser.UserName, + currentUser, identity, )) } @@ -96,7 +99,7 @@ func validateRunAs(b *bundle.Bundle) diag.Diagnostics { diags = diags.Extend(reportRunAsNotSupported( "quality_monitors", b.Config.GetLocation("resources.quality_monitors"), - b.Config.Workspace.CurrentUser.UserName, + currentUser, identity, )) } @@ -110,7 +113,7 @@ func validateRunAs(b *bundle.Bundle) diag.Diagnostics { diags = diags.Extend(reportRunAsNotSupported( "dashboards with embed_credentials set to true", b.Config.GetLocationOf(structpath.NewPath(nil, "resources", "dashboards", key)), - b.Config.Workspace.CurrentUser.UserName, + currentUser, identity, )) } @@ -121,7 +124,7 @@ func validateRunAs(b *bundle.Bundle) diag.Diagnostics { diags = diags.Extend(reportRunAsNotSupported( "apps", b.Config.GetLocation("resources.apps"), - b.Config.Workspace.CurrentUser.UserName, + currentUser, identity, )) } @@ -159,7 +162,7 @@ func setRunAsForPipelines(b *bundle.Bundle) { if pipeline.RunAs != nil { continue } - pipeline.RunAs = &pipelines.RunAs{ + pipeline.RunAs = &pipelines.PipelinesJobRunAs{ GroupName: runAs.GroupName, ServicePrincipalName: runAs.ServicePrincipalName, UserName: runAs.UserName, @@ -178,7 +181,7 @@ func setRunAsForAlerts(b *bundle.Bundle) { if alert.RunAs != nil { continue } - alert.RunAs = &sql.AlertV2RunAs{ + alert.RunAs = &alerts.AlertRunAs{ ServicePrincipalName: runAs.ServicePrincipalName, UserName: runAs.UserName, } @@ -193,24 +196,26 @@ func setPipelineOwnersToRunAsIdentity(b *bundle.Bundle) { return } - me := b.Config.Workspace.CurrentUser.UserName + me := utils.Deref(b.Config.Workspace.CurrentUser.UserName) + runAsUserName := utils.Deref(runAs.UserName) + runAsServicePrincipalName := utils.Deref(runAs.ServicePrincipalName) // If user deploying the bundle and the one defined in run_as are the same // Do not add IS_OWNER permission. Current user is implied to be an owner in this case. // Otherwise, it will fail due to this bug https://github.com/databricks/terraform-provider-databricks/issues/2407 - if runAs.UserName == me || runAs.ServicePrincipalName == me { + if runAsUserName == me || runAsServicePrincipalName == me { return } for i := range b.Config.Resources.Pipelines { pipeline := b.Config.Resources.Pipelines[i] pipeline.Permissions = slices.DeleteFunc(pipeline.Permissions, func(p resources.PipelinePermission) bool { - return (runAs.ServicePrincipalName != "" && p.ServicePrincipalName == runAs.ServicePrincipalName) || - (runAs.UserName != "" && p.UserName == runAs.UserName) + return (runAsServicePrincipalName != "" && p.ServicePrincipalName == runAsServicePrincipalName) || + (runAsUserName != "" && p.UserName == runAsUserName) }) pipeline.Permissions = append(pipeline.Permissions, resources.PipelinePermission{ - Level: pipelines.PipelinePermissionLevelIsOwner, - ServicePrincipalName: runAs.ServicePrincipalName, - UserName: runAs.UserName, + Level: resources.PipelinePermissionLevelIsOwner, + ServicePrincipalName: runAsServicePrincipalName, + UserName: runAsUserName, }) } } diff --git a/bundle/config/mutator/resourcemutator/run_as_test.go b/bundle/config/mutator/resourcemutator/run_as_test.go index 5d1aa602d02..1e7a9902afa 100644 --- a/bundle/config/mutator/resourcemutator/run_as_test.go +++ b/bundle/config/mutator/resourcemutator/run_as_test.go @@ -7,16 +7,18 @@ import ( "strings" "testing" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/convert" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -88,29 +90,29 @@ func TestRunAsWorksForAllowedResources(t *testing.T) { config := config.Root{ Workspace: config.Workspace{ CurrentUser: &config.User{ - User: &iam.User{ - UserName: "alice", + User: &scim.User{ + UserName: new("alice"), }, }, }, RunAs: &jobs.JobRunAs{ - UserName: "bob", + UserName: new("bob"), }, Resources: config.Resources{ Jobs: map[string]*resources.Job{ "job_one": { JobSettings: jobs.JobSettings{ - Name: "foo", + Name: new("foo"), }, }, "job_two": { JobSettings: jobs.JobSettings{ - Name: "bar", + Name: new("bar"), }, }, "job_three": { JobSettings: jobs.JobSettings{ - Name: "baz", + Name: new("baz"), }, }, }, @@ -128,8 +130,8 @@ func TestRunAsWorksForAllowedResources(t *testing.T) { }, Alerts: map[string]*resources.Alert{ "alert_one": { - AlertV2: sql.AlertV2{ - DisplayName: "alert", + Alert: alerts.Alert{ + DisplayName: new("alert"), }, }, }, @@ -144,11 +146,11 @@ func TestRunAsWorksForAllowedResources(t *testing.T) { assert.NoError(t, diags.Error()) for _, job := range b.Config.Resources.Jobs { - assert.Equal(t, "bob", job.RunAs.UserName) + assert.Equal(t, "bob", utils.Deref(job.RunAs.UserName)) } for _, alert := range b.Config.Resources.Alerts { - assert.Equal(t, "bob", alert.RunAs.UserName) + assert.Equal(t, "bob", utils.Deref(alert.RunAs.UserName)) } } @@ -271,9 +273,9 @@ func TestRunAsGroupSupportBehavior(t *testing.T) { require.NoError(t, diags.Error()) switch resourceType { case "jobs": - assert.Equal(t, "group", b.Config.Resources.Jobs["test"].RunAs.GroupName) + assert.Equal(t, "group", utils.Deref(b.Config.Resources.Jobs["test"].RunAs.GroupName)) case "pipelines": - assert.Equal(t, "group", b.Config.Resources.Pipelines["test"].RunAs.GroupName) + assert.Equal(t, "group", utils.Deref(b.Config.Resources.Pipelines["test"].RunAs.GroupName)) default: t.Fatalf("add a group propagation assertion for %s", resourceType) } @@ -288,13 +290,13 @@ func TestRunAsErrorForUnsupportedResources(t *testing.T) { base := config.Root{ Workspace: config.Workspace{ CurrentUser: &config.User{ - User: &iam.User{ - UserName: "alice", + User: &scim.User{ + UserName: new("alice"), }, }, }, RunAs: &jobs.JobRunAs{ - UserName: "bob", + UserName: new("bob"), }, } @@ -342,13 +344,13 @@ func TestRunAsNoErrorForSupportedResources(t *testing.T) { base := config.Root{ Workspace: config.Workspace{ CurrentUser: &config.User{ - User: &iam.User{ - UserName: "alice", + User: &scim.User{ + UserName: new("alice"), }, }, }, RunAs: &jobs.JobRunAs{ - UserName: "bob", + UserName: new("bob"), }, } @@ -473,9 +475,9 @@ func TestRunAsGroupInheritance(t *testing.T) { target string want jobs.JobRunAs }{ - {name: "root group", root: `{group_name: group}`, target: `{}`, want: jobs.JobRunAs{GroupName: "group"}}, - {name: "target group replaces user", root: `{user_name: user}`, target: `{run_as: {group_name: group}}`, want: jobs.JobRunAs{GroupName: "group"}}, - {name: "target user replaces group", root: `{group_name: group}`, target: `{run_as: {user_name: user}}`, want: jobs.JobRunAs{UserName: "user"}}, + {name: "root group", root: `{group_name: group}`, target: `{}`, want: jobs.JobRunAs{GroupName: new("group")}}, + {name: "target group replaces user", root: `{user_name: user}`, target: `{run_as: {group_name: group}}`, want: jobs.JobRunAs{GroupName: new("group")}}, + {name: "target user replaces group", root: `{group_name: group}`, target: `{run_as: {user_name: user}}`, want: jobs.JobRunAs{UserName: new("user")}}, } { t.Run(tc.name, func(t *testing.T) { yaml := fmt.Sprintf(` @@ -503,17 +505,17 @@ resources: require.NoError(t, diags.Error()) assert.Equal(t, &tc.want, b.Config.RunAs) assert.Equal(t, &tc.want, b.Config.Resources.Jobs["inherited"].RunAs) - assert.Equal(t, &jobs.JobRunAs{UserName: "other_user"}, b.Config.Resources.Jobs["user"].RunAs) - assert.Equal(t, &jobs.JobRunAs{ServicePrincipalName: "other_sp"}, b.Config.Resources.Jobs["sp"].RunAs) - assert.Equal(t, &jobs.JobRunAs{GroupName: "other_group"}, b.Config.Resources.Jobs["group"].RunAs) - assert.Equal(t, &pipelines.RunAs{ + assert.Equal(t, &jobs.JobRunAs{UserName: new("other_user")}, b.Config.Resources.Jobs["user"].RunAs) + assert.Equal(t, &jobs.JobRunAs{ServicePrincipalName: new("other_sp")}, b.Config.Resources.Jobs["sp"].RunAs) + assert.Equal(t, &jobs.JobRunAs{GroupName: new("other_group")}, b.Config.Resources.Jobs["group"].RunAs) + assert.Equal(t, &pipelines.PipelinesJobRunAs{ GroupName: tc.want.GroupName, ServicePrincipalName: tc.want.ServicePrincipalName, UserName: tc.want.UserName, }, b.Config.Resources.Pipelines["inherited"].RunAs) - assert.Equal(t, &pipelines.RunAs{UserName: "other_user"}, b.Config.Resources.Pipelines["user"].RunAs) - assert.Equal(t, &pipelines.RunAs{ServicePrincipalName: "other_sp"}, b.Config.Resources.Pipelines["sp"].RunAs) - assert.Equal(t, &pipelines.RunAs{GroupName: "other_group"}, b.Config.Resources.Pipelines["group"].RunAs) + assert.Equal(t, &pipelines.PipelinesJobRunAs{UserName: new("other_user")}, b.Config.Resources.Pipelines["user"].RunAs) + assert.Equal(t, &pipelines.PipelinesJobRunAs{ServicePrincipalName: new("other_sp")}, b.Config.Resources.Pipelines["sp"].RunAs) + assert.Equal(t, &pipelines.PipelinesJobRunAs{GroupName: new("other_group")}, b.Config.Resources.Pipelines["group"].RunAs) }) } } diff --git a/bundle/config/mutator/resourcemutator/secret_scope_fixups.go b/bundle/config/mutator/resourcemutator/secret_scope_fixups.go index 8404d2444eb..bd18a7e554c 100644 --- a/bundle/config/mutator/resourcemutator/secret_scope_fixups.go +++ b/bundle/config/mutator/resourcemutator/secret_scope_fixups.go @@ -6,12 +6,14 @@ import ( "slices" "strings" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/iamutil" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/iam" ) type secretScopeFixups struct{} @@ -24,10 +26,11 @@ func (m *secretScopeFixups) Name() string { return "SecretScopeFixups" } -func addManageForCurrentUser(scope *resources.SecretScope, currentUser *iam.User) { +func addManageForCurrentUser(scope *resources.SecretScope, currentUser *scim.User) { // Check if current user already has a permission configured + userName := utils.Deref(currentUser.UserName) for _, perm := range scope.Permissions { - if (perm.UserName == currentUser.UserName || perm.ServicePrincipalName == currentUser.UserName) && perm.Level == resources.SecretScopePermissionLevelManage { + if (perm.UserName == userName || perm.ServicePrincipalName == userName) && perm.Level == resources.SecretScopePermissionLevelManage { return } } @@ -36,9 +39,9 @@ func addManageForCurrentUser(scope *resources.SecretScope, currentUser *iam.User Level: resources.SecretScopePermissionLevelManage, } if iamutil.IsServicePrincipal(currentUser) { - acl.ServicePrincipalName = currentUser.UserName + acl.ServicePrincipalName = userName } else { - acl.UserName = currentUser.UserName + acl.UserName = userName } scope.Permissions = append(scope.Permissions, acl) } diff --git a/bundle/config/mutator/resourcemutator/secret_scope_fixups_test.go b/bundle/config/mutator/resourcemutator/secret_scope_fixups_test.go index 24cd7aa06a1..0090b4780fa 100644 --- a/bundle/config/mutator/resourcemutator/secret_scope_fixups_test.go +++ b/bundle/config/mutator/resourcemutator/secret_scope_fixups_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/stretchr/testify/assert" ) @@ -148,14 +148,14 @@ func TestCollapsePermissions(t *testing.T) { func TestAddManageForCurrentUser(t *testing.T) { tests := []struct { name string - currentUser *iam.User + currentUser *scim.User existingPerms []resources.SecretScopePermission expectedPerms []resources.SecretScopePermission shouldAddNewPerm bool }{ { name: "add MANAGE for regular user when no permissions exist", - currentUser: &iam.User{UserName: "user@example.com"}, + currentUser: &scim.User{UserName: new("user@example.com")}, existingPerms: []resources.SecretScopePermission{}, expectedPerms: []resources.SecretScopePermission{ {UserName: "user@example.com", Level: resources.SecretScopePermissionLevelManage}, @@ -164,7 +164,7 @@ func TestAddManageForCurrentUser(t *testing.T) { }, { name: "add MANAGE for service principal when no permissions exist", - currentUser: &iam.User{UserName: "12345678-1234-1234-1234-123456789012"}, + currentUser: &scim.User{UserName: new("12345678-1234-1234-1234-123456789012")}, existingPerms: []resources.SecretScopePermission{}, expectedPerms: []resources.SecretScopePermission{ {ServicePrincipalName: "12345678-1234-1234-1234-123456789012", Level: resources.SecretScopePermissionLevelManage}, @@ -173,7 +173,7 @@ func TestAddManageForCurrentUser(t *testing.T) { }, { name: "do not add if user already has MANAGE", - currentUser: &iam.User{UserName: "user@example.com"}, + currentUser: &scim.User{UserName: new("user@example.com")}, existingPerms: []resources.SecretScopePermission{ {UserName: "user@example.com", Level: resources.SecretScopePermissionLevelManage}, }, @@ -184,7 +184,7 @@ func TestAddManageForCurrentUser(t *testing.T) { }, { name: "add MANAGE if user has READ", - currentUser: &iam.User{UserName: "user@example.com"}, + currentUser: &scim.User{UserName: new("user@example.com")}, existingPerms: []resources.SecretScopePermission{ {UserName: "user@example.com", Level: resources.SecretScopePermissionLevelRead}, }, @@ -196,7 +196,7 @@ func TestAddManageForCurrentUser(t *testing.T) { }, { name: "add MANAGE if user has WRITE", - currentUser: &iam.User{UserName: "user@example.com"}, + currentUser: &scim.User{UserName: new("user@example.com")}, existingPerms: []resources.SecretScopePermission{ {UserName: "user@example.com", Level: resources.SecretScopePermissionLevelWrite}, }, @@ -208,7 +208,7 @@ func TestAddManageForCurrentUser(t *testing.T) { }, { name: "do not add if service principal already has MANAGE", - currentUser: &iam.User{UserName: "12345678-1234-1234-1234-123456789012"}, + currentUser: &scim.User{UserName: new("12345678-1234-1234-1234-123456789012")}, existingPerms: []resources.SecretScopePermission{ {ServicePrincipalName: "12345678-1234-1234-1234-123456789012", Level: resources.SecretScopePermissionLevelManage}, }, @@ -219,7 +219,7 @@ func TestAddManageForCurrentUser(t *testing.T) { }, { name: "add MANAGE when other users have permissions", - currentUser: &iam.User{UserName: "user1@example.com"}, + currentUser: &scim.User{UserName: new("user1@example.com")}, existingPerms: []resources.SecretScopePermission{ {UserName: "user2@example.com", Level: resources.SecretScopePermissionLevelRead}, {GroupName: "group1", Level: resources.SecretScopePermissionLevelWrite}, diff --git a/bundle/config/mutator/resourcemutator/validate_target_mode.go b/bundle/config/mutator/resourcemutator/validate_target_mode.go index bf6386264ad..7e970108bd1 100644 --- a/bundle/config/mutator/resourcemutator/validate_target_mode.go +++ b/bundle/config/mutator/resourcemutator/validate_target_mode.go @@ -5,6 +5,8 @@ import ( "fmt" "strings" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/iamutil" "github.com/databricks/cli/bundle" @@ -86,7 +88,7 @@ func validateDevelopmentMode(b *bundle.Bundle) diag.Diagnostics { // namePrefixContainsUserIdentifier checks if the name prefix contains any user identifier // (username, short name, or domain friendly name) to ensure uniqueness. func namePrefixContainsUserIdentifier(prefix string, u *config.User) bool { - if strings.Contains(prefix, u.UserName) { + if strings.Contains(prefix, utils.Deref(u.UserName)) { return true } if strings.Contains(prefix, u.ShortName) { @@ -108,7 +110,7 @@ func isNonUserPath(path string, u *config.User) bool { if strings.HasPrefix(path, resources.SnapshotFullPathRef) { return false } - return !strings.Contains(path, u.UserName) && !strings.Contains(path, u.ShortName) + return !strings.Contains(path, utils.Deref(u.UserName)) && !strings.Contains(path, u.ShortName) } // findNonUserPath finds the first workspace path such as root_path that doesn't @@ -137,7 +139,7 @@ func validateProductionMode(b *bundle.Bundle, isPrincipalUsed bool) diag.Diagnos r := b.Config.Resources for i := range r.Pipelines { //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field - if r.Pipelines[i].Development { + if utils.Deref(r.Pipelines[i].Development) { return diag.Errorf("target with 'mode: production' cannot include a pipeline with 'development: true'") } } @@ -149,7 +151,7 @@ func validateProductionMode(b *bundle.Bundle, isPrincipalUsed bool) diag.Diagnos "A common practice is to use a username or principal name in this path, i.e. use\n"+ "\n"+ " root_path: /Workspace/Users/%s/.bundle/${bundle.name}/${bundle.target}", - b.Config.Workspace.CurrentUser.UserName, + utils.Deref(b.Config.Workspace.CurrentUser.UserName), ) if !isExplicitRootSet(b) { if isRunAsSet(r) || isPrincipalUsed { diff --git a/bundle/config/mutator/resourcemutator/validate_target_mode_test.go b/bundle/config/mutator/resourcemutator/validate_target_mode_test.go index ce361de2d80..a8688af32b4 100644 --- a/bundle/config/mutator/resourcemutator/validate_target_mode_test.go +++ b/bundle/config/mutator/resourcemutator/validate_target_mode_test.go @@ -3,14 +3,16 @@ package resourcemutator import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/stretchr/testify/require" ) @@ -20,8 +22,8 @@ func TestValidateProductionPipelines(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ - Development: true, //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field + CreatePipelineRequest: pipelines.CreatePipelineRequest{ + Development: new(true), //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field }, }, }, @@ -85,10 +87,10 @@ func TestProcessTargetModeProduction(t *testing.T) { }, } b.Config.Resources.Jobs["job1"].Permissions = jobPermissions - b.Config.Resources.Jobs["job1"].RunAs = &jobs.JobRunAs{UserName: "user@company.com"} - b.Config.Resources.Jobs["job2"].RunAs = &jobs.JobRunAs{UserName: "user@company.com"} - b.Config.Resources.Jobs["job3"].RunAs = &jobs.JobRunAs{UserName: "user@company.com"} - b.Config.Resources.Jobs["job4"].RunAs = &jobs.JobRunAs{UserName: "user@company.com"} + b.Config.Resources.Jobs["job1"].RunAs = &jobs.JobRunAs{UserName: new("user@company.com")} + b.Config.Resources.Jobs["job2"].RunAs = &jobs.JobRunAs{UserName: new("user@company.com")} + b.Config.Resources.Jobs["job3"].RunAs = &jobs.JobRunAs{UserName: new("user@company.com")} + b.Config.Resources.Jobs["job4"].RunAs = &jobs.JobRunAs{UserName: new("user@company.com")} b.Config.Resources.Pipelines["pipeline1"].Permissions = pipelinePermissions b.Config.Resources.Experiments["experiment1"].Permissions = experimentPermissions b.Config.Resources.Experiments["experiment2"].Permissions = experimentPermissions @@ -99,15 +101,15 @@ func TestProcessTargetModeProduction(t *testing.T) { diags = validateProductionMode(b, false) require.NoError(t, diags.Error()) - assert.Equal(t, "job1", b.Config.Resources.Jobs["job1"].Name) - assert.Equal(t, "pipeline1", b.Config.Resources.Pipelines["pipeline1"].Name) - assert.False(t, b.Config.Resources.Pipelines["pipeline1"].Development) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field - assert.Equal(t, "servingendpoint1", b.Config.Resources.ModelServingEndpoints["servingendpoint1"].Name) - assert.Equal(t, "registeredmodel1", b.Config.Resources.RegisteredModels["registeredmodel1"].Name) + assert.Equal(t, "job1", utils.Deref(b.Config.Resources.Jobs["job1"].Name)) + assert.Equal(t, "pipeline1", utils.Deref(b.Config.Resources.Pipelines["pipeline1"].Name)) + assert.False(t, utils.Deref(b.Config.Resources.Pipelines["pipeline1"].Development)) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field + assert.Equal(t, "servingendpoint1", utils.Deref(b.Config.Resources.ModelServingEndpoints["servingendpoint1"].Name)) + assert.Equal(t, "registeredmodel1", utils.Deref(b.Config.Resources.RegisteredModels["registeredmodel1"].Name)) assert.Equal(t, "qualityMonitor1", b.Config.Resources.QualityMonitors["qualityMonitor1"].TableName) - assert.Equal(t, "schema1", b.Config.Resources.Schemas["schema1"].Name) - assert.Equal(t, "volume1", b.Config.Resources.Volumes["volume1"].Name) - assert.Equal(t, "cluster1", b.Config.Resources.Clusters["cluster1"].ClusterName) + assert.Equal(t, "schema1", utils.Deref(b.Config.Resources.Schemas["schema1"].Name)) + assert.Equal(t, "volume1", utils.Deref(b.Config.Resources.Volumes["volume1"].Name)) + assert.Equal(t, "cluster1", utils.Deref(b.Config.Resources.Clusters["cluster1"].ClusterName)) } func TestProcessTargetModeProductionOkForPrincipal(t *testing.T) { diff --git a/bundle/config/mutator/rewrite_workspace_prefix_test.go b/bundle/config/mutator/rewrite_workspace_prefix_test.go index 885d8dc2241..ae3f154fe3b 100644 --- a/bundle/config/mutator/rewrite_workspace_prefix_test.go +++ b/bundle/config/mutator/rewrite_workspace_prefix_test.go @@ -3,12 +3,13 @@ package mutator import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/require" ) @@ -27,45 +28,45 @@ func TestNoWorkspacePrefixUsed(t *testing.T) { Jobs: map[string]*resources.Job{ "test_job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "/Workspace/${workspace.root_path}/file1.py", + PythonFile: new("/Workspace/${workspace.root_path}/file1.py"), }, }, { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "/Workspace${workspace.file_path}/notebook1", + NotebookPath: new("/Workspace${workspace.file_path}/notebook1"), }, - Libraries: []compute.Library{ + Libraries: []jobs.Library{ { - Jar: "/Workspace/${workspace.artifact_path}/jar1.jar", + Jar: new("/Workspace/${workspace.artifact_path}/jar1.jar"), }, }, }, { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "${workspace.file_path}/notebook2", + NotebookPath: new("${workspace.file_path}/notebook2"), }, - Libraries: []compute.Library{ + Libraries: []jobs.Library{ { - Jar: "${workspace.artifact_path}/jar2.jar", + Jar: new("${workspace.artifact_path}/jar2.jar"), }, }, }, { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "/Workspace/${workspace.resource_path}/notebook3", + NotebookPath: new("/Workspace/${workspace.resource_path}/notebook3"), }, - Libraries: []compute.Library{ + Libraries: []jobs.Library{ { - Jar: "/Workspace${workspace.resource_path}/jar3.jar", + Jar: new("/Workspace${workspace.resource_path}/jar3.jar"), }, }, }, { SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "${workspace.file_path}/file2.py", + PythonFile: new("${workspace.file_path}/file2.py"), Parameters: []string{ "--input=/Workspace/${workspace.file_path}/in.txt --output=/Workspace/${workspace.file_path}/out.txt", "--cp=/Workspace/${workspace.root_path}/lib.jar:/Workspace${workspace.artifact_path}/dep.jar", @@ -100,14 +101,14 @@ func TestNoWorkspacePrefixUsed(t *testing.T) { delete(expectedErrors, d.Summary) } - require.Equal(t, "${workspace.root_path}/file1.py", b.Config.Resources.Jobs["test_job"].Tasks[0].SparkPythonTask.PythonFile) - require.Equal(t, "${workspace.file_path}/notebook1", b.Config.Resources.Jobs["test_job"].Tasks[1].NotebookTask.NotebookPath) - require.Equal(t, "${workspace.artifact_path}/jar1.jar", b.Config.Resources.Jobs["test_job"].JobSettings.Tasks[1].Libraries[0].Jar) - require.Equal(t, "${workspace.file_path}/notebook2", b.Config.Resources.Jobs["test_job"].Tasks[2].NotebookTask.NotebookPath) - require.Equal(t, "${workspace.artifact_path}/jar2.jar", b.Config.Resources.Jobs["test_job"].JobSettings.Tasks[2].Libraries[0].Jar) - require.Equal(t, "${workspace.resource_path}/notebook3", b.Config.Resources.Jobs["test_job"].Tasks[3].NotebookTask.NotebookPath) - require.Equal(t, "${workspace.resource_path}/jar3.jar", b.Config.Resources.Jobs["test_job"].JobSettings.Tasks[3].Libraries[0].Jar) - require.Equal(t, "${workspace.file_path}/file2.py", b.Config.Resources.Jobs["test_job"].Tasks[4].SparkPythonTask.PythonFile) + require.Equal(t, "${workspace.root_path}/file1.py", utils.Deref(b.Config.Resources.Jobs["test_job"].Tasks[0].SparkPythonTask.PythonFile)) + require.Equal(t, "${workspace.file_path}/notebook1", utils.Deref(b.Config.Resources.Jobs["test_job"].Tasks[1].NotebookTask.NotebookPath)) + require.Equal(t, "${workspace.artifact_path}/jar1.jar", utils.Deref(b.Config.Resources.Jobs["test_job"].JobSettings.Tasks[1].Libraries[0].Jar)) + require.Equal(t, "${workspace.file_path}/notebook2", utils.Deref(b.Config.Resources.Jobs["test_job"].Tasks[2].NotebookTask.NotebookPath)) + require.Equal(t, "${workspace.artifact_path}/jar2.jar", utils.Deref(b.Config.Resources.Jobs["test_job"].JobSettings.Tasks[2].Libraries[0].Jar)) + require.Equal(t, "${workspace.resource_path}/notebook3", utils.Deref(b.Config.Resources.Jobs["test_job"].Tasks[3].NotebookTask.NotebookPath)) + require.Equal(t, "${workspace.resource_path}/jar3.jar", utils.Deref(b.Config.Resources.Jobs["test_job"].JobSettings.Tasks[3].Libraries[0].Jar)) + require.Equal(t, "${workspace.file_path}/file2.py", utils.Deref(b.Config.Resources.Jobs["test_job"].Tasks[4].SparkPythonTask.PythonFile)) require.Equal(t, "--input=${workspace.file_path}/in.txt --output=${workspace.file_path}/out.txt", b.Config.Resources.Jobs["test_job"].Tasks[4].SparkPythonTask.Parameters[0]) require.Equal(t, "--cp=${workspace.root_path}/lib.jar:${workspace.artifact_path}/dep.jar", b.Config.Resources.Jobs["test_job"].Tasks[4].SparkPythonTask.Parameters[1]) } diff --git a/bundle/config/mutator/translate_paths_apps_test.go b/bundle/config/mutator/translate_paths_apps_test.go index 05c902235b1..b4c05b96fdf 100644 --- a/bundle/config/mutator/translate_paths_apps_test.go +++ b/bundle/config/mutator/translate_paths_apps_test.go @@ -4,14 +4,16 @@ import ( "path/filepath" "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/mutator" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/diag" + "github.com/databricks/cli/libs/sdktypes/apps/v1" "github.com/databricks/cli/libs/vfs" - "github.com/databricks/databricks-sdk-go/service/apps" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -32,8 +34,8 @@ func TestTranslatePathsApps_FilePathRelativeSubDirectory(t *testing.T) { Apps: map[string]*resources.App{ "app": { App: apps.App{ - Name: "My App", - SourceCodePath: "../src/app", + Name: new("My App"), + SourceCodePath: new("../src/app"), }, }, }, @@ -52,6 +54,6 @@ func TestTranslatePathsApps_FilePathRelativeSubDirectory(t *testing.T) { assert.Equal( t, "/bundle/files/src/app", - b.Config.Resources.Apps["app"].SourceCodePath, + utils.Deref(b.Config.Resources.Apps["app"].SourceCodePath), ) } diff --git a/bundle/config/mutator/translate_paths_test.go b/bundle/config/mutator/translate_paths_test.go index 8aaf9ce9c71..33e439a4b9f 100644 --- a/bundle/config/mutator/translate_paths_test.go +++ b/bundle/config/mutator/translate_paths_test.go @@ -8,6 +8,8 @@ import ( "runtime" "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/mutator" @@ -16,10 +18,9 @@ import ( "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/databricks/cli/libs/vfs" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -64,26 +65,26 @@ func TestTranslatePathsSkippedWithGitSource(t *testing.T) { "job": { JobSettings: jobs.JobSettings{ GitSource: &jobs.GitSource{ - GitBranch: "somebranch", - GitCommit: "somecommit", - GitProvider: "github", - GitTag: "sometag", - GitUrl: "https://github.com/someuser/somerepo", + GitBranch: new("somebranch"), + GitCommit: new("somecommit"), + GitProvider: new("github"), + GitTag: new("sometag"), + GitUrl: new("https://github.com/someuser/somerepo"), }, - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "my_job_notebook.py", + NotebookPath: new("my_job_notebook.py"), }, }, { PythonWheelTask: &jobs.PythonWheelTask{ - PackageName: "foo", + PackageName: new("foo"), }, }, { SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "my_python_file.py", + PythonFile: new("my_python_file.py"), }, }, }, @@ -102,17 +103,17 @@ func TestTranslatePathsSkippedWithGitSource(t *testing.T) { assert.Equal( t, "my_job_notebook.py", - b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath), ) assert.Equal( t, "foo", - b.Config.Resources.Jobs["job"].Tasks[1].PythonWheelTask.PackageName, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[1].PythonWheelTask.PackageName), ) assert.Equal( t, "my_python_file.py", - b.Config.Resources.Jobs["job"].Tasks[2].SparkPythonTask.PythonFile, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[2].SparkPythonTask.PythonFile), ) } @@ -136,52 +137,52 @@ func TestTranslatePaths(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "./my_job_notebook.py", + NotebookPath: new("./my_job_notebook.py"), }, - Libraries: []compute.Library{ - {Whl: "./dist/task.whl"}, + Libraries: []jobs.Library{ + {Whl: new("./dist/task.whl")}, }, }, { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "/Users/jane.doe@databricks.com/doesnt_exist.py", + NotebookPath: new("/Users/jane.doe@databricks.com/doesnt_exist.py"), }, }, { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "./my_job_notebook.py", + NotebookPath: new("./my_job_notebook.py"), }, - Libraries: []compute.Library{ - {Requirements: "./requirements.txt"}, + Libraries: []jobs.Library{ + {Requirements: new("./requirements.txt")}, }, }, { PythonWheelTask: &jobs.PythonWheelTask{ - PackageName: "foo", + PackageName: new("foo"), }, }, { SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "./my_python_file.py", + PythonFile: new("./my_python_file.py"), }, }, { SparkJarTask: &jobs.SparkJarTask{ - MainClassName: "HelloWorld", + MainClassName: new("HelloWorld"), }, - Libraries: []compute.Library{ - {Jar: "./dist/task.jar"}, + Libraries: []jobs.Library{ + {Jar: new("./dist/task.jar")}, }, }, { SparkJarTask: &jobs.SparkJarTask{ - MainClassName: "HelloWorldRemote", + MainClassName: new("HelloWorldRemote"), }, - Libraries: []compute.Library{ - {Jar: "dbfs:/bundle/dist/task_remote.jar"}, + Libraries: []jobs.Library{ + {Jar: new("dbfs:/bundle/dist/task_remote.jar")}, }, }, }, @@ -190,29 +191,29 @@ func TestTranslatePaths(t *testing.T) { }, Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Libraries: []pipelines.PipelineLibrary{ { Notebook: &pipelines.NotebookLibrary{ - Path: "./my_pipeline_notebook.py", + Path: new("./my_pipeline_notebook.py"), }, }, { Notebook: &pipelines.NotebookLibrary{ - Path: "/Users/jane.doe@databricks.com/doesnt_exist.py", + Path: new("/Users/jane.doe@databricks.com/doesnt_exist.py"), }, }, { Notebook: &pipelines.NotebookLibrary{ - Path: "./my_pipeline_notebook.py", + Path: new("./my_pipeline_notebook.py"), }, }, { - Jar: "foo", + Jar: new("foo"), }, { - File: &pipelines.FileLibrary{ - Path: "./my_python_file.py", + File: &pipelines.NotebookLibrary{ + Path: new("./my_python_file.py"), }, }, }, @@ -232,64 +233,64 @@ func TestTranslatePaths(t *testing.T) { assert.Equal( t, "/bundle/my_job_notebook", - b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath), ) assert.Equal( t, "dist/task.whl", - b.Config.Resources.Jobs["job"].Tasks[0].Libraries[0].Whl, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[0].Libraries[0].Whl), ) assert.Equal( t, "/Users/jane.doe@databricks.com/doesnt_exist.py", - b.Config.Resources.Jobs["job"].Tasks[1].NotebookTask.NotebookPath, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[1].NotebookTask.NotebookPath), ) assert.Equal( t, "/bundle/my_job_notebook", - b.Config.Resources.Jobs["job"].Tasks[2].NotebookTask.NotebookPath, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[2].NotebookTask.NotebookPath), ) assert.Equal( t, "/bundle/requirements.txt", - b.Config.Resources.Jobs["job"].Tasks[2].Libraries[0].Requirements, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[2].Libraries[0].Requirements), ) assert.Equal( t, "/bundle/my_python_file.py", - b.Config.Resources.Jobs["job"].Tasks[4].SparkPythonTask.PythonFile, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[4].SparkPythonTask.PythonFile), ) assert.Equal( t, "dist/task.jar", - b.Config.Resources.Jobs["job"].Tasks[5].Libraries[0].Jar, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[5].Libraries[0].Jar), ) assert.Equal( t, "dbfs:/bundle/dist/task_remote.jar", - b.Config.Resources.Jobs["job"].Tasks[6].Libraries[0].Jar, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[6].Libraries[0].Jar), ) // Assert that the path in the libraries now refer to the artifact. assert.Equal( t, "/bundle/my_pipeline_notebook", - b.Config.Resources.Pipelines["pipeline"].Libraries[0].Notebook.Path, + utils.Deref(b.Config.Resources.Pipelines["pipeline"].Libraries[0].Notebook.Path), ) assert.Equal( t, "/Users/jane.doe@databricks.com/doesnt_exist.py", - b.Config.Resources.Pipelines["pipeline"].Libraries[1].Notebook.Path, + utils.Deref(b.Config.Resources.Pipelines["pipeline"].Libraries[1].Notebook.Path), ) assert.Equal( t, "/bundle/my_pipeline_notebook", - b.Config.Resources.Pipelines["pipeline"].Libraries[2].Notebook.Path, + utils.Deref(b.Config.Resources.Pipelines["pipeline"].Libraries[2].Notebook.Path), ) assert.Equal( t, "/bundle/my_python_file.py", - b.Config.Resources.Pipelines["pipeline"].Libraries[4].File.Path, + utils.Deref(b.Config.Resources.Pipelines["pipeline"].Libraries[4].File.Path), ) } @@ -314,35 +315,35 @@ func TestTranslatePathsInSubdirectories(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "./my_python_file.py", + PythonFile: new("./my_python_file.py"), }, }, { SparkJarTask: &jobs.SparkJarTask{ - MainClassName: "HelloWorld", + MainClassName: new("HelloWorld"), }, - Libraries: []compute.Library{ - {Jar: "./dist/task.jar"}, + Libraries: []jobs.Library{ + {Jar: new("./dist/task.jar")}, }, }, { SqlTask: &jobs.SqlTask{ File: &jobs.SqlTaskFile{ - Path: "./my_sql_file.sql", + Path: new("./my_sql_file.sql"), }, }, }, { DbtTask: &jobs.DbtTask{ - ProjectDirectory: "./my_dbt_project", + ProjectDirectory: new("./my_dbt_project"), }, }, { AlertTask: &jobs.AlertTask{ - WorkspacePath: "./my_alert.dbalert.json", + WorkspacePath: new("./my_alert.dbalert.json"), }, }, }, @@ -351,11 +352,11 @@ func TestTranslatePathsInSubdirectories(t *testing.T) { }, Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Libraries: []pipelines.PipelineLibrary{ { - File: &pipelines.FileLibrary{ - Path: "./my_python_file.py", + File: &pipelines.NotebookLibrary{ + Path: new("./my_python_file.py"), }, }, }, @@ -375,33 +376,33 @@ func TestTranslatePathsInSubdirectories(t *testing.T) { assert.Equal( t, "/bundle/job/my_python_file.py", - b.Config.Resources.Jobs["job"].Tasks[0].SparkPythonTask.PythonFile, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[0].SparkPythonTask.PythonFile), ) assert.Equal( t, "job/dist/task.jar", - b.Config.Resources.Jobs["job"].Tasks[1].Libraries[0].Jar, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[1].Libraries[0].Jar), ) assert.Equal( t, "/bundle/job/my_sql_file.sql", - b.Config.Resources.Jobs["job"].Tasks[2].SqlTask.File.Path, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[2].SqlTask.File.Path), ) assert.Equal( t, "/bundle/job/my_dbt_project", - b.Config.Resources.Jobs["job"].Tasks[3].DbtTask.ProjectDirectory, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[3].DbtTask.ProjectDirectory), ) assert.Equal( t, "/bundle/job/my_alert.dbalert.json", - b.Config.Resources.Jobs["job"].Tasks[4].AlertTask.WorkspacePath, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[4].AlertTask.WorkspacePath), ) assert.Equal( t, "/bundle/pipeline/my_python_file.py", - b.Config.Resources.Pipelines["pipeline"].Libraries[0].File.Path, + utils.Deref(b.Config.Resources.Pipelines["pipeline"].Libraries[0].File.Path), ) } @@ -420,10 +421,10 @@ func TestTranslatePathsOutsideSyncRoot(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "./my_python_file.py", + PythonFile: new("./my_python_file.py"), }, }, }, @@ -452,10 +453,10 @@ func TestJobNotebookDoesNotExistError(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "./doesnt_exist.py", + NotebookPath: new("./doesnt_exist.py"), }, }, }, @@ -484,10 +485,10 @@ func TestJobFileDoesNotExistError(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "./doesnt_exist.py", + PythonFile: new("./doesnt_exist.py"), }, }, }, @@ -515,11 +516,11 @@ func TestPipelineNotebookDoesNotExistError(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Libraries: []pipelines.PipelineLibrary{ { Notebook: &pipelines.NotebookLibrary{ - Path: "./doesnt_exist.py", + Path: new("./doesnt_exist.py"), }, }, }, @@ -560,11 +561,11 @@ func TestPipelineNotebookDoesNotExistErrorWithoutExtension(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Libraries: []pipelines.PipelineLibrary{ { Notebook: &pipelines.NotebookLibrary{ - Path: "./foo", + Path: new("./foo"), }, }, }, @@ -601,11 +602,11 @@ func TestPipelineFileDoesNotExistError(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Libraries: []pipelines.PipelineLibrary{ { - File: &pipelines.FileLibrary{ - Path: "./doesnt_exist.py", + File: &pipelines.NotebookLibrary{ + Path: new("./doesnt_exist.py"), }, }, }, @@ -638,10 +639,10 @@ func TestJobSparkPythonTaskWithNotebookSourceError(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "./my_notebook.py", + PythonFile: new("./my_notebook.py"), }, }, }, @@ -674,10 +675,10 @@ func TestJobNotebookTaskWithFileSourceError(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "./my_file.py", + NotebookPath: new("./my_file.py"), }, }, }, @@ -709,11 +710,11 @@ func TestPipelineNotebookLibraryWithFileSourceError(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Libraries: []pipelines.PipelineLibrary{ { Notebook: &pipelines.NotebookLibrary{ - Path: "./my_file.py", + Path: new("./my_file.py"), }, }, }, @@ -745,11 +746,11 @@ func TestPipelineFileLibraryWithNotebookSourceError(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Libraries: []pipelines.PipelineLibrary{ { - File: &pipelines.FileLibrary{ - Path: "./my_notebook.py", + File: &pipelines.NotebookLibrary{ + Path: new("./my_notebook.py"), }, }, }, @@ -782,7 +783,7 @@ func TestTranslatePathJobEnvironments(t *testing.T) { JobSettings: jobs.JobSettings{ Environments: []jobs.JobEnvironment{ { - Spec: &compute.Environment{ + Spec: &jobs.Environment{ Dependencies: []string{ "./dist/env1.whl", "../dist/env2.whl", @@ -837,9 +838,9 @@ func TestTranslatePathWithComplexVariables(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "test", + TaskKey: new("test"), }, }, }, @@ -872,7 +873,7 @@ func TestTranslatePathWithComplexVariables(t *testing.T) { assert.Equal( t, "variables/local/whl.whl", - b.Config.Resources.Jobs["job"].Tasks[0].Libraries[0].Whl, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[0].Libraries[0].Whl), ) } @@ -901,47 +902,47 @@ func TestTranslatePathsWithSourceLinkedDeployment(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "my_job_notebook.py", + NotebookPath: new("my_job_notebook.py"), }, - Libraries: []compute.Library{ - {Whl: "./dist/task.whl"}, + Libraries: []jobs.Library{ + {Whl: new("./dist/task.whl")}, }, }, { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "/Users/jane.doe@databricks.com/absolute_remote.py", + NotebookPath: new("/Users/jane.doe@databricks.com/absolute_remote.py"), }, }, { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "my_job_notebook.py", + NotebookPath: new("my_job_notebook.py"), }, - Libraries: []compute.Library{ - {Requirements: "requirements.txt"}, + Libraries: []jobs.Library{ + {Requirements: new("requirements.txt")}, }, }, { SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "my_python_file.py", + PythonFile: new("my_python_file.py"), }, }, { SparkJarTask: &jobs.SparkJarTask{ - MainClassName: "HelloWorld", + MainClassName: new("HelloWorld"), }, - Libraries: []compute.Library{ - {Jar: "./dist/task.jar"}, + Libraries: []jobs.Library{ + {Jar: new("./dist/task.jar")}, }, }, { SparkJarTask: &jobs.SparkJarTask{ - MainClassName: "HelloWorldRemote", + MainClassName: new("HelloWorldRemote"), }, - Libraries: []compute.Library{ - {Jar: "dbfs:/bundle/dist/task_remote.jar"}, + Libraries: []jobs.Library{ + {Jar: new("dbfs:/bundle/dist/task_remote.jar")}, }, }, }, @@ -950,21 +951,21 @@ func TestTranslatePathsWithSourceLinkedDeployment(t *testing.T) { }, Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Libraries: []pipelines.PipelineLibrary{ { Notebook: &pipelines.NotebookLibrary{ - Path: "my_pipeline_notebook.py", + Path: new("my_pipeline_notebook.py"), }, }, { Notebook: &pipelines.NotebookLibrary{ - Path: "/Users/jane.doe@databricks.com/absolute_remote.py", + Path: new("/Users/jane.doe@databricks.com/absolute_remote.py"), }, }, { - File: &pipelines.FileLibrary{ - Path: "my_python_file.py", + File: &pipelines.NotebookLibrary{ + Path: new("my_python_file.py"), }, }, }, @@ -986,54 +987,54 @@ func TestTranslatePathsWithSourceLinkedDeployment(t *testing.T) { assert.Equal( t, dir+"/my_job_notebook", - b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath), ) assert.Equal( t, dir+"/requirements.txt", - b.Config.Resources.Jobs["job"].Tasks[2].Libraries[0].Requirements, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[2].Libraries[0].Requirements), ) assert.Equal( t, dir+"/my_python_file.py", - b.Config.Resources.Jobs["job"].Tasks[3].SparkPythonTask.PythonFile, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[3].SparkPythonTask.PythonFile), ) assert.Equal( t, dir+"/my_pipeline_notebook", - b.Config.Resources.Pipelines["pipeline"].Libraries[0].Notebook.Path, + utils.Deref(b.Config.Resources.Pipelines["pipeline"].Libraries[0].Notebook.Path), ) assert.Equal( t, dir+"/my_python_file.py", - b.Config.Resources.Pipelines["pipeline"].Libraries[2].File.Path, + utils.Deref(b.Config.Resources.Pipelines["pipeline"].Libraries[2].File.Path), ) // left as is assert.Equal( t, "dist/task.whl", - b.Config.Resources.Jobs["job"].Tasks[0].Libraries[0].Whl, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[0].Libraries[0].Whl), ) assert.Equal( t, "/Users/jane.doe@databricks.com/absolute_remote.py", - b.Config.Resources.Jobs["job"].Tasks[1].NotebookTask.NotebookPath, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[1].NotebookTask.NotebookPath), ) assert.Equal( t, "dist/task.jar", - b.Config.Resources.Jobs["job"].Tasks[4].Libraries[0].Jar, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[4].Libraries[0].Jar), ) assert.Equal( t, "dbfs:/bundle/dist/task_remote.jar", - b.Config.Resources.Jobs["job"].Tasks[5].Libraries[0].Jar, + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[5].Libraries[0].Jar), ) assert.Equal( t, "/Users/jane.doe@databricks.com/absolute_remote.py", - b.Config.Resources.Pipelines["pipeline"].Libraries[1].Notebook.Path, + utils.Deref(b.Config.Resources.Pipelines["pipeline"].Libraries[1].Notebook.Path), ) } @@ -1054,15 +1055,15 @@ func TestTranslatePathsWithSkipLocalFileValidation(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "./src/notebook.py", + NotebookPath: new("./src/notebook.py"), }, }, { SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "./src/main.py", + PythonFile: new("./src/main.py"), }, }, }, @@ -1071,11 +1072,11 @@ func TestTranslatePathsWithSkipLocalFileValidation(t *testing.T) { }, Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Libraries: []pipelines.PipelineLibrary{ { Notebook: &pipelines.NotebookLibrary{ - Path: "./src/pipeline_notebook.py", + Path: new("./src/pipeline_notebook.py"), }, }, }, @@ -1092,13 +1093,13 @@ func TestTranslatePathsWithSkipLocalFileValidation(t *testing.T) { require.NoError(t, diags.Error()) // Notebook path should be translated (extension stripped) even though file doesn't exist. - assert.Equal(t, "/bundle/src/notebook", b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath) + assert.Equal(t, "/bundle/src/notebook", utils.Deref(b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath)) // File path should be translated even though file doesn't exist. - assert.Equal(t, "/bundle/src/main.py", b.Config.Resources.Jobs["job"].Tasks[1].SparkPythonTask.PythonFile) + assert.Equal(t, "/bundle/src/main.py", utils.Deref(b.Config.Resources.Jobs["job"].Tasks[1].SparkPythonTask.PythonFile)) // Pipeline notebook path should be translated even though file doesn't exist. - assert.Equal(t, "/bundle/src/pipeline_notebook", b.Config.Resources.Pipelines["pipeline"].Libraries[0].Notebook.Path) + assert.Equal(t, "/bundle/src/pipeline_notebook", utils.Deref(b.Config.Resources.Pipelines["pipeline"].Libraries[0].Notebook.Path)) } func TestTranslatePathsWithSkipLocalFileValidationDirectory(t *testing.T) { @@ -1117,8 +1118,8 @@ func TestTranslatePathsWithSkipLocalFileValidationDirectory(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ - RootPath: "./pipeline_root", + CreatePipelineRequest: pipelines.CreatePipelineRequest{ + RootPath: new("./pipeline_root"), }, }, }, @@ -1132,7 +1133,7 @@ func TestTranslatePathsWithSkipLocalFileValidationDirectory(t *testing.T) { require.NoError(t, diags.Error()) // Directory path should be translated even though directory doesn't exist. - assert.Equal(t, "/bundle/pipeline_root", b.Config.Resources.Pipelines["pipeline"].RootPath) + assert.Equal(t, "/bundle/pipeline_root", utils.Deref(b.Config.Resources.Pipelines["pipeline"].RootPath)) } // TestTranslatePathsDesignerNotebook verifies that Lakeflow Designer notebooks @@ -1156,15 +1157,15 @@ func TestTranslatePathsDesignerNotebook(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "./src/designer.designer.ipynb", + NotebookPath: new("./src/designer.designer.ipynb"), }, }, { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "./src/regular.py", + NotebookPath: new("./src/regular.py"), }, }, }, @@ -1183,12 +1184,12 @@ func TestTranslatePathsDesignerNotebook(t *testing.T) { // Designer notebook keeps its full ".designer.ipynb" suffix. assert.Equal(t, "/bundle/src/designer.designer.ipynb", - b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath) + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath)) // Regular notebook still has its extension stripped on import. assert.Equal(t, "/bundle/src/regular", - b.Config.Resources.Jobs["job"].Tasks[1].NotebookTask.NotebookPath) + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[1].NotebookTask.NotebookPath)) } // TestTranslatePathsDesignerNotebookSkipLocalFileValidation verifies the @@ -1210,15 +1211,15 @@ func TestTranslatePathsDesignerNotebookSkipLocalFileValidation(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "./src/designer.designer.ipynb", + NotebookPath: new("./src/designer.designer.ipynb"), }, }, { NotebookTask: &jobs.NotebookTask{ - NotebookPath: "./src/regular.ipynb", + NotebookPath: new("./src/regular.ipynb"), }, }, }, @@ -1236,8 +1237,8 @@ func TestTranslatePathsDesignerNotebookSkipLocalFileValidation(t *testing.T) { assert.Equal(t, "/bundle/src/designer.designer.ipynb", - b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath) + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath)) assert.Equal(t, "/bundle/src/regular", - b.Config.Resources.Jobs["job"].Tasks[1].NotebookTask.NotebookPath) + utils.Deref(b.Config.Resources.Jobs["job"].Tasks[1].NotebookTask.NotebookPath)) } diff --git a/bundle/config/resources.go b/bundle/config/resources.go index f13a44617c4..76ce64fd5a3 100644 --- a/bundle/config/resources.go +++ b/bundle/config/resources.go @@ -6,7 +6,7 @@ import ( "net/url" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" ) // Resources defines Databricks resources associated with the bundle. @@ -58,7 +58,7 @@ type Resources struct { type ConfigResource interface { // Exists returns true if the resource exists in the workspace configured in // the input workspace client. - Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) + Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) // ResourceDescription returns a struct containing strings describing a resource ResourceDescription() resources.ResourceDescription diff --git a/bundle/config/resources/alerts.go b/bundle/config/resources/alerts.go index 4416873d526..5369a8bd5dd 100644 --- a/bundle/config/resources/alerts.go +++ b/bundle/config/resources/alerts.go @@ -4,17 +4,19 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/utils" + sdkalerts "github.com/databricks/sdk-go/alerts/v2" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/sql" ) type Alert struct { BaseResource - sql.AlertV2 //nolint:govet // AlertV2.Id and our depth-0 ID field both carry json:"id"; the depth-0 field wins - ID string `json:"id,omitempty" bundle:"readonly"` + alerts.Alert //nolint:govet // AlertV2.Id and our depth-0 ID field both carry json:"id"; the depth-0 field wins + ID string `json:"id,omitempty" bundle:"readonly"` Permissions []Permission `json:"permissions,omitempty"` @@ -24,16 +26,8 @@ type Alert struct { FilePath string `json:"file_path,omitempty"` } -func (a *Alert) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, a) -} - -func (a Alert) MarshalJSON() ([]byte, error) { - return marshal.Marshal(a) -} - -func (a *Alert) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { - _, err := w.AlertsV2.GetAlertById(ctx, id) +func (a *Alert) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { + _, err := w.Alerts.GetAlert(ctx, sdkalerts.GetAlertRequest{Id: new(id)}) if err != nil { log.Debugf(ctx, "alert %s does not exist", id) return false, err @@ -58,5 +52,5 @@ func (a *Alert) InitializeURL(baseURL url.URL) { } func (a *Alert) GetName() string { - return a.DisplayName + return utils.Deref(a.DisplayName) } diff --git a/bundle/config/resources/apps.go b/bundle/config/resources/apps.go index 76acbb29a96..6fff3736bec 100644 --- a/bundle/config/resources/apps.go +++ b/bundle/config/resources/apps.go @@ -4,11 +4,13 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/libs/utils" + sdkapps "github.com/databricks/sdk-go/apps/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/apps" ) // AppConfig represents the inline app.yaml configuration structure. @@ -65,16 +67,8 @@ func (a *App) GetLifecycle() LifecycleConfig { return *a.Lifecycle } -func (a *App) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, a) -} - -func (a App) MarshalJSON() ([]byte, error) { - return marshal.Marshal(a) -} - -func (a *App) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Apps.GetByName(ctx, name) +func (a *App) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Apps.GetApp(ctx, sdkapps.GetAppRequest{Name: new(name)}) if err != nil { log.Debugf(ctx, "app %s does not exist", name) return false, err @@ -103,5 +97,5 @@ func (a *App) GetName() string { if a.ID != "" { return a.ID } - return a.Name + return utils.Deref(a.Name) } diff --git a/bundle/config/resources/catalog.go b/bundle/config/resources/catalog.go index 3fc4a5c89dc..d7b206bd9c0 100644 --- a/bundle/config/resources/catalog.go +++ b/bundle/config/resources/catalog.go @@ -4,10 +4,11 @@ import ( "context" "net/url" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + "github.com/databricks/cli/libs/utils" + sdkcatalogs "github.com/databricks/sdk-go/uc/catalogs/v1" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" @@ -16,18 +17,18 @@ import ( type Catalog struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - catalog.CreateCatalog + CreateCatalog // List of grants to apply on this catalog. - Grants []catalog.PrivilegeAssignment `json:"grants,omitempty"` + Grants []grants.PrivilegeAssignment `json:"grants,omitempty"` } -func (c *Catalog) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Catalogs.GetByName(ctx, name) +func (c *Catalog) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Catalogs.GetCatalog(ctx, sdkcatalogs.GetCatalogRequest{NameArg: new(name)}) if err != nil { log.Debugf(ctx, "catalog with name %s does not exist: %v", name, err) - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return false, nil } @@ -53,13 +54,5 @@ func (c *Catalog) InitializeURL(baseURL url.URL) { } func (c *Catalog) GetName() string { - return c.Name -} - -func (c *Catalog) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c Catalog) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) + return utils.Deref(c.Name) } diff --git a/bundle/config/resources/cluster_policy.go b/bundle/config/resources/cluster_policy.go index 8315c5b8b90..868652f9c2d 100644 --- a/bundle/config/resources/cluster_policy.go +++ b/bundle/config/resources/cluster_policy.go @@ -4,17 +4,19 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2" + "github.com/databricks/cli/libs/utils" + sdkclusterpolicies "github.com/databricks/sdk-go/clusterpolicies/v2" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/compute" ) type ClusterPolicy struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - compute.CreatePolicy + clusterpolicies.CreatePolicyRequest // Shadows the embedded compute.CreatePolicy.Definition (a string). `any` lets the // definition be authored as inline YAML; ConfigureClusterPolicyDefinition normalizes @@ -28,16 +30,8 @@ type ClusterPolicy struct { Permissions []ClusterPolicyPermission `json:"permissions,omitempty"` } -func (s *ClusterPolicy) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s ClusterPolicy) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (s *ClusterPolicy) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { - _, err := w.ClusterPolicies.GetByPolicyId(ctx, id) +func (s *ClusterPolicy) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { + _, err := w.ClusterPolicies.GetPolicy(ctx, sdkclusterpolicies.GetPolicyRequest{PolicyId: new(id)}) if err != nil { log.Debugf(ctx, "cluster policy %s does not exist", id) return false, err @@ -62,5 +56,5 @@ func (s *ClusterPolicy) InitializeURL(baseURL url.URL) { } func (s *ClusterPolicy) GetName() string { - return s.Name + return utils.Deref(s.Name) } diff --git a/bundle/config/resources/clusters.go b/bundle/config/resources/clusters.go index 75b8f66b93d..734235dd887 100644 --- a/bundle/config/resources/clusters.go +++ b/bundle/config/resources/clusters.go @@ -4,23 +4,26 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/clusterlibraries/v2" + "github.com/databricks/cli/libs/sdktypes/clusters/v2" + "github.com/databricks/cli/libs/utils" + sdkclusters "github.com/databricks/sdk-go/clusters/v2" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/compute" ) type Cluster struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - compute.ClusterSpec + clusters.CreateClusterRequest // Lifecycle shadows BaseResource.Lifecycle to add support for lifecycle.started. Lifecycle *LifecycleWithStarted `json:"lifecycle,omitempty"` // Libraries are installed via the Libraries API, not the cluster spec. - Libraries []compute.Library `json:"libraries,omitempty"` + Libraries []clusterlibraries.Library `json:"libraries,omitempty"` Permissions []ClusterPermission `json:"permissions,omitempty"` } @@ -33,16 +36,8 @@ func (s *Cluster) GetLifecycle() LifecycleConfig { return *s.Lifecycle } -func (s *Cluster) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s Cluster) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (s *Cluster) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { - _, err := w.Clusters.GetByClusterId(ctx, id) +func (s *Cluster) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { + _, err := w.Clusters.GetCluster(ctx, sdkclusters.GetClusterRequest{ClusterId: new(id)}) if err != nil { log.Debugf(ctx, "cluster %s does not exist", id) return false, err @@ -67,5 +62,5 @@ func (s *Cluster) InitializeURL(baseURL url.URL) { } func (s *Cluster) GetName() string { - return s.ClusterName + return utils.Deref(s.ClusterName) } diff --git a/bundle/config/resources/dashboard.go b/bundle/config/resources/dashboard.go index 16b3229ed16..87950315c73 100644 --- a/bundle/config/resources/dashboard.go +++ b/bundle/config/resources/dashboard.go @@ -4,11 +4,12 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/lakeview/v1" + sdklakeview "github.com/databricks/sdk-go/lakeview/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/dashboards" ) type DashboardConfig struct { @@ -23,7 +24,7 @@ type DashboardConfig struct { // field is excluded in List Dashboards responses. Etag string `json:"etag,omitempty"` // The state of the dashboard resource. Used for tracking trashed status. - LifecycleState dashboards.LifecycleState `json:"lifecycle_state,omitempty"` + LifecycleState lakeview.LifecycleState `json:"lifecycle_state,omitempty"` // The workspace path of the folder containing the dashboard. Includes // leading slash and no trailing slash. This field is excluded in List // Dashboards responses. @@ -38,8 +39,6 @@ type DashboardConfig struct { // The warehouse ID used to run the dashboard. WarehouseId string `json:"warehouse_id,omitempty"` - ForceSendFields []string `json:"-" url:"-"` - // ============================================== // === overrides over [dashboards.Dashboard] === // ============================================== @@ -68,14 +67,6 @@ type DashboardConfig struct { DatasetSchema string `json:"dataset_schema,omitempty"` } -func (c *DashboardConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c DashboardConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) -} - type Dashboard struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` @@ -90,17 +81,9 @@ type Dashboard struct { FilePath string `json:"file_path,omitempty"` } -func (r *Dashboard) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, r) -} - -func (r Dashboard) MarshalJSON() ([]byte, error) { - return marshal.Marshal(r) -} - -func (*Dashboard) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { - _, err := w.Lakeview.Get(ctx, dashboards.GetDashboardRequest{ - DashboardId: id, +func (*Dashboard) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { + _, err := w.Lakeview.GetDashboard(ctx, sdklakeview.GetDashboardRequest{ + DashboardId: new(id), }) if err != nil { log.Debugf(ctx, "dashboard %s does not exist", id) diff --git a/bundle/config/resources/dashboard_test.go b/bundle/config/resources/dashboard_test.go index 83c80b17107..d629968a034 100644 --- a/bundle/config/resources/dashboard_test.go +++ b/bundle/config/resources/dashboard_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/databricks/databricks-sdk-go/service/dashboards" + dashboards "github.com/databricks/cli/libs/sdktypes/lakeview/v1" "github.com/stretchr/testify/assert" ) diff --git a/bundle/config/resources/database_catalog.go b/bundle/config/resources/database_catalog.go index c1c0b86bd24..55eefdcfca2 100644 --- a/bundle/config/resources/database_catalog.go +++ b/bundle/config/resources/database_catalog.go @@ -4,12 +4,13 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/database/v1" + "github.com/databricks/cli/libs/utils" + sdkdatabase "github.com/databricks/sdk-go/database/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/database" ) type DatabaseCatalog struct { @@ -18,16 +19,8 @@ type DatabaseCatalog struct { database.DatabaseCatalog } -func (d *DatabaseCatalog) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, d) -} - -func (d DatabaseCatalog) MarshalJSON() ([]byte, error) { - return marshal.Marshal(d) -} - -func (d *DatabaseCatalog) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Database.GetDatabaseCatalog(ctx, database.GetDatabaseCatalogRequest{Name: name}) +func (d *DatabaseCatalog) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Database.GetDatabaseCatalog(ctx, sdkdatabase.GetDatabaseCatalogRequest{Name: new(name)}) if err != nil { log.Debugf(ctx, "database Catalog %s does not exist", name) return false, err @@ -45,12 +38,12 @@ func (d *DatabaseCatalog) ResourceDescription() ResourceDescription { } func (d *DatabaseCatalog) GetName() string { - return d.Name + return utils.Deref(d.Name) } func (d *DatabaseCatalog) InitializeURL(baseURL url.URL) { - if d.Name == "" { + if d.Name == nil { return } - d.URL = workspaceurls.ResourceURL(baseURL, "database_catalogs", d.Name) + d.URL = workspaceurls.ResourceURL(baseURL, "database_catalogs", *d.Name) } diff --git a/bundle/config/resources/database_instance.go b/bundle/config/resources/database_instance.go index 5d4abf5a27a..12b8617c082 100644 --- a/bundle/config/resources/database_instance.go +++ b/bundle/config/resources/database_instance.go @@ -4,12 +4,13 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/database/v1" + "github.com/databricks/cli/libs/utils" + sdkdatabase "github.com/databricks/sdk-go/database/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/database" ) type DatabaseInstance struct { @@ -20,16 +21,8 @@ type DatabaseInstance struct { Permissions []Permission `json:"permissions,omitempty"` } -func (d *DatabaseInstance) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, d) -} - -func (d DatabaseInstance) MarshalJSON() ([]byte, error) { - return marshal.Marshal(d) -} - -func (d *DatabaseInstance) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Database.GetDatabaseInstance(ctx, database.GetDatabaseInstanceRequest{Name: name}) +func (d *DatabaseInstance) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Database.GetDatabaseInstance(ctx, sdkdatabase.GetDatabaseInstanceRequest{Name: new(name)}) if err != nil { log.Debugf(ctx, "database instance %s does not exist", name) return false, err @@ -47,15 +40,15 @@ func (d *DatabaseInstance) ResourceDescription() ResourceDescription { } func (d *DatabaseInstance) GetName() string { - return d.Name + return utils.Deref(d.Name) } func (d *DatabaseInstance) InitializeURL(baseURL url.URL) { if d.ModifiedStatus == ModifiedStatusCreated { return } - if d.Name == "" { + if d.Name == nil { return } - d.URL = workspaceurls.ResourceURL(baseURL, "database_instances", d.Name) + d.URL = workspaceurls.ResourceURL(baseURL, "database_instances", *d.Name) } diff --git a/bundle/config/resources/external_location.go b/bundle/config/resources/external_location.go index 5d9a52a1b75..93bfb50f1f7 100644 --- a/bundle/config/resources/external_location.go +++ b/bundle/config/resources/external_location.go @@ -4,10 +4,11 @@ import ( "context" "net/url" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + "github.com/databricks/cli/libs/utils" + sdkexternallocations "github.com/databricks/sdk-go/uc/externallocations/v1" "github.com/databricks/cli/libs/log" ) @@ -19,18 +20,18 @@ type ExternalLocation struct { // Note: We intentionally don't include BaseResource.URL here to avoid conflict with Url field below Lifecycle Lifecycle `json:"lifecycle,omitempty"` - catalog.CreateExternalLocation + CreateExternalLocation // List of grants to apply on this external location. - Grants []catalog.PrivilegeAssignment `json:"grants,omitempty"` + Grants []grants.PrivilegeAssignment `json:"grants,omitempty"` } -func (e *ExternalLocation) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.ExternalLocations.GetByName(ctx, name) +func (e *ExternalLocation) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.ExternalLocations.GetExternalLocation(ctx, sdkexternallocations.GetExternalLocationRequest{NameArg: new(name)}) if err != nil { log.Debugf(ctx, "external location with name %s does not exist: %v", name, err) - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return false, nil } @@ -59,18 +60,10 @@ func (e *ExternalLocation) GetURL() (string, bool) { } func (e *ExternalLocation) GetName() string { - return e.Name + return utils.Deref(e.Name) } // GetLifecycle returns the lifecycle settings for the resource. func (e *ExternalLocation) GetLifecycle() LifecycleConfig { return e.Lifecycle } - -func (e *ExternalLocation) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, e) -} - -func (e ExternalLocation) MarshalJSON() ([]byte, error) { - return marshal.Marshal(e) -} diff --git a/bundle/config/resources/external_location_test.go b/bundle/config/resources/external_location_test.go index af1b78e8d64..a3e36543cb8 100644 --- a/bundle/config/resources/external_location_test.go +++ b/bundle/config/resources/external_location_test.go @@ -3,41 +3,31 @@ package resources import ( "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/libs/testserver" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestExternalLocationExists(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockExternalLocationsAPI() + w := newTestClients(t, map[string]any{ + "GET /api/2.1/unity-catalog/external-locations/test_location": map[string]any{"name": "test_location"}, + "GET /api/2.1/unity-catalog/external-locations/nonexistent": testserver.Response{ + StatusCode: 404, + Body: map[string]string{"error_code": "RESOURCE_DOES_NOT_EXIST", "message": "not found"}, + }, + }) t.Run("exists", func(t *testing.T) { - api.EXPECT(). - GetByName(mock.Anything, "test_location"). - Return(&catalog.ExternalLocationInfo{Name: "test_location"}, nil) - el := &ExternalLocation{} - exists, err := el.Exists(ctx, m.WorkspaceClient, "test_location") + exists, err := el.Exists(ctx, w, "test_location") require.NoError(t, err) assert.True(t, exists) }) t.Run("does not exist", func(t *testing.T) { - notFoundErr := &apierr.APIError{ - StatusCode: 404, - ErrorCode: "RESOURCE_DOES_NOT_EXIST", - } - api.EXPECT(). - GetByName(mock.Anything, "nonexistent"). - Return(nil, notFoundErr) - el := &ExternalLocation{} - exists, err := el.Exists(ctx, m.WorkspaceClient, "nonexistent") + exists, err := el.Exists(ctx, w, "nonexistent") require.NoError(t, err) assert.False(t, exists) }) @@ -55,7 +45,7 @@ func TestExternalLocationResourceDescription(t *testing.T) { func TestExternalLocationGetName(t *testing.T) { el := &ExternalLocation{ - Name: "my_location", + Name: new("my_location"), } assert.Equal(t, "my_location", el.GetName()) diff --git a/bundle/config/resources/genie_space.go b/bundle/config/resources/genie_space.go index 3d60fa01a58..9ab371f71aa 100644 --- a/bundle/config/resources/genie_space.go +++ b/bundle/config/resources/genie_space.go @@ -4,12 +4,12 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + sdkgenie "github.com/databricks/sdk-go/genie/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/dashboards" ) type GenieSpaceConfig struct { @@ -28,8 +28,6 @@ type GenieSpaceConfig struct { // Parent folder path where the space will be registered ParentPath string `json:"parent_path,omitempty"` - ForceSendFields []string `json:"-" url:"-"` - // ============================================== // === overrides over [dashboards.GenieSpace] === // ============================================== @@ -41,14 +39,6 @@ type GenieSpaceConfig struct { SerializedSpace any `json:"serialized_space,omitempty"` } -func (c *GenieSpaceConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c GenieSpaceConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) -} - type GenieSpace struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` @@ -63,20 +53,12 @@ type GenieSpace struct { FilePath string `json:"file_path,omitempty"` } -func (r *GenieSpace) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, r) -} - -func (r GenieSpace) MarshalJSON() ([]byte, error) { - return marshal.Marshal(r) -} - -func (*GenieSpace) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { - _, err := w.Genie.GetSpace(ctx, dashboards.GenieGetSpaceRequest{ - SpaceId: id, +func (*GenieSpace) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { + _, err := w.Genie.GenieGetSpace(ctx, sdkgenie.GenieGetSpaceRequest{ + SpaceId: new(id), }) if err != nil { - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { log.Debugf(ctx, "genie space %s does not exist", id) return false, nil } diff --git a/bundle/config/resources/helpers_test.go b/bundle/config/resources/helpers_test.go new file mode 100644 index 00000000000..ed1970426be --- /dev/null +++ b/bundle/config/resources/helpers_test.go @@ -0,0 +1,46 @@ +package resources + +import ( + "net/http" + "testing" + + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/testserver" + "github.com/databricks/databricks-sdk-go/config" + "github.com/stretchr/testify/require" +) + +// newTestClients returns clients for a test server that answers each +// "METHOD /path" in routes with the given response body. +func newTestClients(t *testing.T, routes map[string]any) *sdkclients.Clients { + server := testserver.New(t) + for route, body := range routes { + var method, path string + for i := range route { + if route[i] == ' ' { + method, path = route[:i], route[i+1:] + break + } + } + server.Handle(method, path, func(testserver.Request) any { return body }) + } + return newServerClients(t, server) +} + +// newServerClients returns clients that talk to server. +func newServerClients(t *testing.T, server *testserver.Server) *sdkclients.Clients { + w, err := sdkclients.New(t.Context(), &config.Config{ + Host: server.URL, + Token: "testtoken", + Loaders: []config.Loader{config.ConfigAttributes}, + }) + require.NoError(t, err) + return w +} + +func notFound() testserver.Response { + return testserver.Response{ + StatusCode: http.StatusNotFound, + Body: map[string]string{"error_code": "NOT_FOUND", "message": "not found"}, + } +} diff --git a/bundle/config/resources/instance_pools.go b/bundle/config/resources/instance_pools.go index 81c9a75e166..5964d3e929b 100644 --- a/bundle/config/resources/instance_pools.go +++ b/bundle/config/resources/instance_pools.go @@ -4,30 +4,24 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/instancepools/v2" + "github.com/databricks/cli/libs/utils" + sdkinstancepools "github.com/databricks/sdk-go/instancepools/v2" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/compute" ) type InstancePool struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - compute.CreateInstancePool + instancepools.CreateInstancePoolRequest Permissions []InstancePoolPermission `json:"permissions,omitempty"` } -func (s *InstancePool) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s InstancePool) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (s *InstancePool) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { - _, err := w.InstancePools.GetByInstancePoolId(ctx, id) +func (s *InstancePool) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { + _, err := w.InstancePools.GetInstancePool(ctx, sdkinstancepools.GetInstancePoolRequest{InstancePoolId: new(id)}) if err != nil { log.Debugf(ctx, "instance pool %s does not exist", id) return false, err @@ -52,5 +46,5 @@ func (s *InstancePool) InitializeURL(baseURL url.URL) { } func (s *InstancePool) GetName() string { - return s.InstancePoolName + return utils.Deref(s.InstancePoolName) } diff --git a/bundle/config/resources/job.go b/bundle/config/resources/job.go index 5d62c511791..dd1ebea3e76 100644 --- a/bundle/config/resources/job.go +++ b/bundle/config/resources/job.go @@ -5,11 +5,13 @@ import ( "net/url" "strconv" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/jobs" ) type Job struct { @@ -20,21 +22,13 @@ type Job struct { Permissions []JobPermission `json:"permissions,omitempty"` } -func (j *Job) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, j) -} - -func (j Job) MarshalJSON() ([]byte, error) { - return marshal.Marshal(j) -} - -func (j *Job) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { +func (j *Job) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { jobId, err := strconv.Atoi(id) if err != nil { return false, err } - _, err = w.Jobs.Get(ctx, jobs.GetJobRequest{ - JobId: int64(jobId), + _, err = w.Jobs.GetJob(ctx, sdkjobs.GetJobRequest{ + JobId: new(int64(jobId)), }) if err != nil { log.Debugf(ctx, "job %s does not exist", id) @@ -60,5 +54,5 @@ func (j *Job) InitializeURL(baseURL url.URL) { } func (j *Job) GetName() string { - return j.Name + return utils.Deref(j.Name) } diff --git a/bundle/config/resources/job_run.go b/bundle/config/resources/job_run.go index ff9a91a8899..158d2eea68e 100644 --- a/bundle/config/resources/job_run.go +++ b/bundle/config/resources/job_run.go @@ -5,12 +5,14 @@ import ( "net/url" "strconv" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/jobs" ) // JobRun is the bundle config for a triggered job run, described by the same @@ -19,7 +21,7 @@ import ( type JobRun struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - jobs.RunNow + jobs.RunNowRequest // Lifecycle shadows BaseResource.Lifecycle so job_runs can set triggers. Lifecycle *JobRunLifecycle `json:"lifecycle,omitempty"` @@ -86,27 +88,19 @@ func (r *JobRun) HasOnFileChange() bool { return false } -func (r *JobRun) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, r) -} - -func (r JobRun) MarshalJSON() ([]byte, error) { - return marshal.Marshal(r) -} - // Exists reports whether the run with the given numeric id still exists, for as // long as the workspace retains its run history. -func (r *JobRun) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { +func (r *JobRun) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { runID, err := strconv.ParseInt(id, 10, 64) if err != nil { return false, err } - _, err = w.Jobs.GetRun(ctx, jobs.GetRunRequest{ - RunId: runID, + _, err = w.Jobs.GetRun(ctx, sdkjobs.GetRunRequest{ + RunId: new(runID), }) if err != nil { log.Debugf(ctx, "job run %s does not exist: %v", id, err) - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return false, nil } return false, err @@ -132,7 +126,7 @@ func (r *JobRun) GetName() string { // when resolved (deploy) or ResolvedJobID from state (read-only commands); if // either id is missing we skip rather than emit a broken jobs/0 URL. func (r *JobRun) InitializeURL(baseURL url.URL) { - jobID := r.JobId + jobID := utils.Deref(r.JobId) if jobID == 0 { jobID = r.ResolvedJobID } diff --git a/bundle/config/resources/mcp_service.go b/bundle/config/resources/mcp_service.go index 1ca5ce86901..2030feaa333 100644 --- a/bundle/config/resources/mcp_service.go +++ b/bundle/config/resources/mcp_service.go @@ -4,12 +4,14 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/aigateway/v1" + "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + sdkaigateway "github.com/databricks/sdk-go/aigateway/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/catalog" ) // McpServiceConfig is the bundle-authored state for an AI Gateway MCP service. @@ -30,17 +32,7 @@ type McpServiceConfig struct { // User-provided description. Comment string `json:"comment,omitempty"` // Operational configuration: source connection, tool selectors, rate limit. - Config *catalog.McpServiceConfig `json:"config,omitempty"` - - ForceSendFields []string `json:"-" url:"-"` -} - -func (c *McpServiceConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c McpServiceConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) + Config *aigateway.McpServiceConfig `json:"config,omitempty"` } type McpService struct { @@ -52,27 +44,20 @@ type McpService struct { // permissions API (the `.grants` sub-resource), not the MCP-service body, so // this field lives on the wrapper and stays out of the diffed state that // PrepareState returns (the embedded McpServiceConfig). - Grants []catalog.PrivilegeAssignment `json:"grants,omitempty"` + Grants []grants.PrivilegeAssignment `json:"grants,omitempty"` } // UnmarshalJSON / MarshalJSON are defined on the wrapper so it does not inherit // McpServiceConfig's promoted marshaler, which would silently drop the // BaseResource fields (id, url, lifecycle, modified_status). -func (m *McpService) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, m) -} - -func (m McpService) MarshalJSON() ([]byte, error) { - return marshal.Marshal(m) -} -func (m *McpService) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { +func (m *McpService) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { // The engine tracks the id as the bare {catalog}.{schema}.{mcp_service}; // the API addresses the resource by its full name. - _, err := w.AiGateway.GetMcpService(ctx, catalog.GetMcpServiceRequest{Name: "mcp-services/" + id}) + _, err := w.AiGateway.GetMcpService(ctx, sdkaigateway.GetMcpServiceRequest{Name: new("mcp-services/" + id)}) if err != nil { log.Debugf(ctx, "mcp service %s does not exist", id) - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return false, nil } return false, err diff --git a/bundle/config/resources/mlflow_experiment.go b/bundle/config/resources/mlflow_experiment.go index 965a3ca55ff..f8df5d30042 100644 --- a/bundle/config/resources/mlflow_experiment.go +++ b/bundle/config/resources/mlflow_experiment.go @@ -4,32 +4,26 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/experiments/v1" + "github.com/databricks/cli/libs/utils" + sdkexperiments "github.com/databricks/sdk-go/experiments/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/ml" ) type MlflowExperiment struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - ml.CreateExperiment + experiments.CreateExperimentRequest Permissions []MlflowExperimentPermission `json:"permissions,omitempty"` } -func (s *MlflowExperiment) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s MlflowExperiment) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (s *MlflowExperiment) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { - _, err := w.Experiments.GetExperiment(ctx, ml.GetExperimentRequest{ - ExperimentId: id, +func (s *MlflowExperiment) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { + _, err := w.Experiments.GetExperiment(ctx, sdkexperiments.GetExperimentRequest{ + ExperimentId: new(id), }) if err != nil { log.Debugf(ctx, "experiment %s does not exist", id) @@ -55,5 +49,5 @@ func (s *MlflowExperiment) InitializeURL(baseURL url.URL) { } func (s *MlflowExperiment) GetName() string { - return s.Name + return utils.Deref(s.Name) } diff --git a/bundle/config/resources/mlflow_model.go b/bundle/config/resources/mlflow_model.go index f7bbcd96e7a..a7a6a255815 100644 --- a/bundle/config/resources/mlflow_model.go +++ b/bundle/config/resources/mlflow_model.go @@ -4,32 +4,26 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/modelregistry/v1" + "github.com/databricks/cli/libs/utils" + sdkmodelregistry "github.com/databricks/sdk-go/modelregistry/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/ml" ) type MlflowModel struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - ml.CreateModelRequest + modelregistry.CreateRegisteredModelRequest Permissions []MlflowModelPermission `json:"permissions,omitempty"` } -func (s *MlflowModel) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s MlflowModel) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (s *MlflowModel) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { - _, err := w.ModelRegistry.GetModel(ctx, ml.GetModelRequest{ - Name: id, +func (s *MlflowModel) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { + _, err := w.ModelRegistry.GetRegisteredModelDatabricks(ctx, sdkmodelregistry.GetRegisteredModelDatabricksRequest{ + Name: new(id), }) if err != nil { log.Debugf(ctx, "model %s does not exist", id) @@ -55,5 +49,5 @@ func (s *MlflowModel) InitializeURL(baseURL url.URL) { } func (s *MlflowModel) GetName() string { - return s.Name + return utils.Deref(s.Name) } diff --git a/bundle/config/resources/model_provider_service.go b/bundle/config/resources/model_provider_service.go index 20bf48c5539..088c7e82734 100644 --- a/bundle/config/resources/model_provider_service.go +++ b/bundle/config/resources/model_provider_service.go @@ -4,12 +4,14 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/aigateway/v1" + "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + sdkaigateway "github.com/databricks/sdk-go/aigateway/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/catalog" ) // ModelProviderServiceConfig is the bundle-authored state for an AI Gateway @@ -37,17 +39,7 @@ type ModelProviderServiceConfig struct { Comment string `json:"comment,omitempty"` // Behavioral configuration: provider connection, model catalog, passthrough // policy. config.provider_type is required at create and immutable after. - Config *catalog.ModelProviderServiceConfig `json:"config,omitempty"` - - ForceSendFields []string `json:"-" url:"-"` -} - -func (c *ModelProviderServiceConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c ModelProviderServiceConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) + Config *aigateway.ModelProviderServiceConfig `json:"config,omitempty"` } type ModelProviderService struct { @@ -59,28 +51,21 @@ type ModelProviderService struct { // via the permissions API (the `.grants` sub-resource), not the service body, // so this field lives on the wrapper and stays out of the diffed state that // PrepareState returns (the embedded ModelProviderServiceConfig). - Grants []catalog.PrivilegeAssignment `json:"grants,omitempty"` + Grants []grants.PrivilegeAssignment `json:"grants,omitempty"` } // UnmarshalJSON / MarshalJSON are defined on the wrapper so it does not inherit // ModelProviderServiceConfig's promoted marshaler, which would silently drop the // BaseResource fields (id, url, lifecycle, modified_status). -func (m *ModelProviderService) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, m) -} - -func (m ModelProviderService) MarshalJSON() ([]byte, error) { - return marshal.Marshal(m) -} -func (m *ModelProviderService) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { +func (m *ModelProviderService) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { // The engine tracks the id as the bare // {catalog}.{schema}.{model_provider_service}; the API addresses the // resource by its full name. - _, err := w.AiGateway.GetModelProviderService(ctx, catalog.GetModelProviderServiceRequest{Name: "model-provider-services/" + id}) + _, err := w.AiGateway.GetModelProviderService(ctx, sdkaigateway.GetModelProviderServiceRequest{Name: new("model-provider-services/" + id)}) if err != nil { log.Debugf(ctx, "model provider service %s does not exist", id) - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return false, nil } return false, err diff --git a/bundle/config/resources/model_service.go b/bundle/config/resources/model_service.go index 28134a9cb06..8293fdcd444 100644 --- a/bundle/config/resources/model_service.go +++ b/bundle/config/resources/model_service.go @@ -4,12 +4,14 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/aigateway/v1" + "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + sdkaigateway "github.com/databricks/sdk-go/aigateway/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/catalog" ) // ModelServiceConfig is the bundle-authored state for an AI Gateway model @@ -37,17 +39,7 @@ type ModelServiceConfig struct { Comment string `json:"comment,omitempty"` // Operational configuration: destinations, routing, rate limits, inference // table. - Config *catalog.ModelServiceConfig `json:"config,omitempty"` - - ForceSendFields []string `json:"-" url:"-"` -} - -func (c *ModelServiceConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c ModelServiceConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) + Config *aigateway.ModelServiceConfig `json:"config,omitempty"` } type ModelService struct { @@ -59,27 +51,20 @@ type ModelService struct { // permissions API (the `.grants` sub-resource), not the model-service body, so // this field lives on the wrapper and stays out of the diffed state that // PrepareState returns (the embedded ModelServiceConfig). - Grants []catalog.PrivilegeAssignment `json:"grants,omitempty"` + Grants []grants.PrivilegeAssignment `json:"grants,omitempty"` } // UnmarshalJSON / MarshalJSON are defined on the wrapper so it does not inherit // ModelServiceConfig's promoted marshaler, which would silently drop the // BaseResource fields (id, url, lifecycle, modified_status). -func (m *ModelService) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, m) -} - -func (m ModelService) MarshalJSON() ([]byte, error) { - return marshal.Marshal(m) -} -func (m *ModelService) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { +func (m *ModelService) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { // The engine tracks the id as the bare {catalog}.{schema}.{model_service}; // the API addresses the resource by its full name. - _, err := w.AiGateway.GetModelService(ctx, catalog.GetModelServiceRequest{Name: "model-services/" + id}) + _, err := w.AiGateway.GetModelService(ctx, sdkaigateway.GetModelServiceRequest{Name: new("model-services/" + id)}) if err != nil { log.Debugf(ctx, "model service %s does not exist", id) - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return false, nil } return false, err diff --git a/bundle/config/resources/model_serving_endpoint.go b/bundle/config/resources/model_serving_endpoint.go index e3bc707cfad..897974b5e7c 100644 --- a/bundle/config/resources/model_serving_endpoint.go +++ b/bundle/config/resources/model_serving_endpoint.go @@ -4,35 +4,29 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/modelserving/v1" + "github.com/databricks/cli/libs/utils" + sdkmodelserving "github.com/databricks/sdk-go/modelserving/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/serving" ) type ModelServingEndpoint struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - serving.CreateServingEndpoint + modelserving.CreateInferenceEndpointRequest // This is a resource agnostic implementation of permissions for ACLs. // Implementation could be different based on the resource type. Permissions []ModelServingEndpointPermission `json:"permissions,omitempty"` } -func (s *ModelServingEndpoint) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s ModelServingEndpoint) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (s *ModelServingEndpoint) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.ServingEndpoints.Get(ctx, serving.GetServingEndpointRequest{ - Name: name, +func (s *ModelServingEndpoint) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.ServingEndpoints.GetInferenceEndpoint(ctx, sdkmodelserving.GetInferenceEndpointRequest{ + Name: new(name), }) if err != nil { log.Debugf(ctx, "serving endpoint %s does not exist", name) @@ -58,5 +52,5 @@ func (s *ModelServingEndpoint) InitializeURL(baseURL url.URL) { } func (s *ModelServingEndpoint) GetName() string { - return s.Name + return utils.Deref(s.Name) } diff --git a/bundle/config/resources/permission_levels.go b/bundle/config/resources/permission_levels.go new file mode 100644 index 00000000000..184cc40b85a --- /dev/null +++ b/bundle/config/resources/permission_levels.go @@ -0,0 +1,259 @@ +package resources + +// Permission levels accepted by the Permissions API for each resource type. +// The Permissions API itself is generic (sdk-go accessmanagement); these types +// give each resource its own enum in the bundle schema and validation. + +// Permission level +type AppPermissionLevel string + +const ( + AppPermissionLevelCanManage AppPermissionLevel = "CAN_MANAGE" + AppPermissionLevelCanUse AppPermissionLevel = "CAN_USE" +) + +// Values returns all valid AppPermissionLevel values. +func (AppPermissionLevel) Values() []AppPermissionLevel { + return []AppPermissionLevel{ + AppPermissionLevelCanManage, + AppPermissionLevelCanUse, + } +} + +// Permission level +type ClusterPermissionLevel string + +const ( + ClusterPermissionLevelCanAttachTo ClusterPermissionLevel = "CAN_ATTACH_TO" + ClusterPermissionLevelCanManage ClusterPermissionLevel = "CAN_MANAGE" + ClusterPermissionLevelCanRestart ClusterPermissionLevel = "CAN_RESTART" +) + +// Values returns all valid ClusterPermissionLevel values. +func (ClusterPermissionLevel) Values() []ClusterPermissionLevel { + return []ClusterPermissionLevel{ + ClusterPermissionLevelCanAttachTo, + ClusterPermissionLevelCanManage, + ClusterPermissionLevelCanRestart, + } +} + +// Permission level +type ClusterPolicyPermissionLevel string + +const ( + ClusterPolicyPermissionLevelCanUse ClusterPolicyPermissionLevel = "CAN_USE" +) + +// Values returns all valid ClusterPolicyPermissionLevel values. +func (ClusterPolicyPermissionLevel) Values() []ClusterPolicyPermissionLevel { + return []ClusterPolicyPermissionLevel{ + ClusterPolicyPermissionLevelCanUse, + } +} + +// Permission level +type InstancePoolPermissionLevel string + +const ( + InstancePoolPermissionLevelCanAttachTo InstancePoolPermissionLevel = "CAN_ATTACH_TO" + InstancePoolPermissionLevelCanManage InstancePoolPermissionLevel = "CAN_MANAGE" +) + +// Values returns all valid InstancePoolPermissionLevel values. +func (InstancePoolPermissionLevel) Values() []InstancePoolPermissionLevel { + return []InstancePoolPermissionLevel{ + InstancePoolPermissionLevelCanAttachTo, + InstancePoolPermissionLevelCanManage, + } +} + +// Permission level +type JobPermissionLevel string + +const ( + JobPermissionLevelCanManage JobPermissionLevel = "CAN_MANAGE" + JobPermissionLevelCanManageRun JobPermissionLevel = "CAN_MANAGE_RUN" + JobPermissionLevelCanView JobPermissionLevel = "CAN_VIEW" + JobPermissionLevelIsOwner JobPermissionLevel = "IS_OWNER" +) + +// Values returns all valid JobPermissionLevel values. +func (JobPermissionLevel) Values() []JobPermissionLevel { + return []JobPermissionLevel{ + JobPermissionLevelCanManage, + JobPermissionLevelCanManageRun, + JobPermissionLevelCanView, + JobPermissionLevelIsOwner, + } +} + +// Permission level +type ExperimentPermissionLevel string + +const ( + ExperimentPermissionLevelCanEdit ExperimentPermissionLevel = "CAN_EDIT" + ExperimentPermissionLevelCanManage ExperimentPermissionLevel = "CAN_MANAGE" + ExperimentPermissionLevelCanRead ExperimentPermissionLevel = "CAN_READ" +) + +// Values returns all valid ExperimentPermissionLevel values. +func (ExperimentPermissionLevel) Values() []ExperimentPermissionLevel { + return []ExperimentPermissionLevel{ + ExperimentPermissionLevelCanEdit, + ExperimentPermissionLevelCanManage, + ExperimentPermissionLevelCanRead, + } +} + +// Permission level +type RegisteredModelPermissionLevel string + +const ( + RegisteredModelPermissionLevelCanEdit RegisteredModelPermissionLevel = "CAN_EDIT" + RegisteredModelPermissionLevelCanManage RegisteredModelPermissionLevel = "CAN_MANAGE" + RegisteredModelPermissionLevelCanManageProductionVersions RegisteredModelPermissionLevel = "CAN_MANAGE_PRODUCTION_VERSIONS" + RegisteredModelPermissionLevelCanManageStagingVersions RegisteredModelPermissionLevel = "CAN_MANAGE_STAGING_VERSIONS" + RegisteredModelPermissionLevelCanRead RegisteredModelPermissionLevel = "CAN_READ" +) + +// Values returns all valid RegisteredModelPermissionLevel values. +func (RegisteredModelPermissionLevel) Values() []RegisteredModelPermissionLevel { + return []RegisteredModelPermissionLevel{ + RegisteredModelPermissionLevelCanEdit, + RegisteredModelPermissionLevelCanManage, + RegisteredModelPermissionLevelCanManageProductionVersions, + RegisteredModelPermissionLevelCanManageStagingVersions, + RegisteredModelPermissionLevelCanRead, + } +} + +// Permission level +type ServingEndpointPermissionLevel string + +const ( + ServingEndpointPermissionLevelCanManage ServingEndpointPermissionLevel = "CAN_MANAGE" + ServingEndpointPermissionLevelCanQuery ServingEndpointPermissionLevel = "CAN_QUERY" + ServingEndpointPermissionLevelCanView ServingEndpointPermissionLevel = "CAN_VIEW" +) + +// Values returns all valid ServingEndpointPermissionLevel values. +func (ServingEndpointPermissionLevel) Values() []ServingEndpointPermissionLevel { + return []ServingEndpointPermissionLevel{ + ServingEndpointPermissionLevelCanManage, + ServingEndpointPermissionLevelCanQuery, + ServingEndpointPermissionLevelCanView, + } +} + +// Permission level +type PipelinePermissionLevel string + +const ( + PipelinePermissionLevelCanManage PipelinePermissionLevel = "CAN_MANAGE" + PipelinePermissionLevelCanRun PipelinePermissionLevel = "CAN_RUN" + PipelinePermissionLevelCanView PipelinePermissionLevel = "CAN_VIEW" + PipelinePermissionLevelIsOwner PipelinePermissionLevel = "IS_OWNER" +) + +// Values returns all valid PipelinePermissionLevel values. +func (PipelinePermissionLevel) Values() []PipelinePermissionLevel { + return []PipelinePermissionLevel{ + PipelinePermissionLevelCanManage, + PipelinePermissionLevelCanRun, + PipelinePermissionLevelCanView, + PipelinePermissionLevelIsOwner, + } +} + +// Permission level +type WarehousePermissionLevel string + +const ( + WarehousePermissionLevelCanManage WarehousePermissionLevel = "CAN_MANAGE" + WarehousePermissionLevelCanMonitor WarehousePermissionLevel = "CAN_MONITOR" + WarehousePermissionLevelCanUse WarehousePermissionLevel = "CAN_USE" + WarehousePermissionLevelCanView WarehousePermissionLevel = "CAN_VIEW" + WarehousePermissionLevelIsOwner WarehousePermissionLevel = "IS_OWNER" +) + +// Values returns all valid WarehousePermissionLevel values. +func (WarehousePermissionLevel) Values() []WarehousePermissionLevel { + return []WarehousePermissionLevel{ + WarehousePermissionLevelCanManage, + WarehousePermissionLevelCanMonitor, + WarehousePermissionLevelCanUse, + WarehousePermissionLevelCanView, + WarehousePermissionLevelIsOwner, + } +} + +// Permission level +type VectorSearchEndpointPermissionLevel string + +const ( + VectorSearchEndpointPermissionLevelCanCreate VectorSearchEndpointPermissionLevel = "CAN_CREATE" + VectorSearchEndpointPermissionLevelCanManage VectorSearchEndpointPermissionLevel = "CAN_MANAGE" + VectorSearchEndpointPermissionLevelCanUse VectorSearchEndpointPermissionLevel = "CAN_USE" +) + +// Values returns all valid VectorSearchEndpointPermissionLevel values. +func (VectorSearchEndpointPermissionLevel) Values() []VectorSearchEndpointPermissionLevel { + return []VectorSearchEndpointPermissionLevel{ + VectorSearchEndpointPermissionLevelCanCreate, + VectorSearchEndpointPermissionLevelCanManage, + VectorSearchEndpointPermissionLevelCanUse, + } +} + +// Permission level +type PermissionLevel string + +const ( + PermissionLevelCanAttachTo PermissionLevel = "CAN_ATTACH_TO" + PermissionLevelCanBind PermissionLevel = "CAN_BIND" + PermissionLevelCanCreate PermissionLevel = "CAN_CREATE" + PermissionLevelCanCreateApp PermissionLevel = "CAN_CREATE_APP" + PermissionLevelCanEdit PermissionLevel = "CAN_EDIT" + PermissionLevelCanEditMetadata PermissionLevel = "CAN_EDIT_METADATA" + PermissionLevelCanManage PermissionLevel = "CAN_MANAGE" + PermissionLevelCanManageProductionVersions PermissionLevel = "CAN_MANAGE_PRODUCTION_VERSIONS" + PermissionLevelCanManageRun PermissionLevel = "CAN_MANAGE_RUN" + PermissionLevelCanManageStagingVersions PermissionLevel = "CAN_MANAGE_STAGING_VERSIONS" + PermissionLevelCanMonitor PermissionLevel = "CAN_MONITOR" + PermissionLevelCanMonitorOnly PermissionLevel = "CAN_MONITOR_ONLY" + PermissionLevelCanQuery PermissionLevel = "CAN_QUERY" + PermissionLevelCanRead PermissionLevel = "CAN_READ" + PermissionLevelCanRestart PermissionLevel = "CAN_RESTART" + PermissionLevelCanRun PermissionLevel = "CAN_RUN" + PermissionLevelCanUse PermissionLevel = "CAN_USE" + PermissionLevelCanView PermissionLevel = "CAN_VIEW" + PermissionLevelCanViewMetadata PermissionLevel = "CAN_VIEW_METADATA" + PermissionLevelIsOwner PermissionLevel = "IS_OWNER" +) + +// Values returns all valid PermissionLevel values. +func (PermissionLevel) Values() []PermissionLevel { + return []PermissionLevel{ + PermissionLevelCanAttachTo, + PermissionLevelCanBind, + PermissionLevelCanCreate, + PermissionLevelCanCreateApp, + PermissionLevelCanEdit, + PermissionLevelCanEditMetadata, + PermissionLevelCanManage, + PermissionLevelCanManageProductionVersions, + PermissionLevelCanManageRun, + PermissionLevelCanManageStagingVersions, + PermissionLevelCanMonitor, + PermissionLevelCanMonitorOnly, + PermissionLevelCanQuery, + PermissionLevelCanRead, + PermissionLevelCanRestart, + PermissionLevelCanRun, + PermissionLevelCanUse, + PermissionLevelCanView, + PermissionLevelCanViewMetadata, + PermissionLevelIsOwner, + } +} diff --git a/bundle/config/resources/permission_types.go b/bundle/config/resources/permission_types.go index 31d41e09439..87f7b296ffb 100644 --- a/bundle/config/resources/permission_types.go +++ b/bundle/config/resources/permission_types.go @@ -1,39 +1,27 @@ package resources -import ( - "github.com/databricks/databricks-sdk-go/service/apps" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/serving" - "github.com/databricks/databricks-sdk-go/service/sql" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" -) - // Each resource defines its own permission type so that the JSON schema names them distinctly. // Using non-alias type definitions (not =) makes them appear as named types in the schema. // The underlying struct is identical to PermissionT[L], enabling conversion to use generic methods. -// Permission is used for resources that use the generic iam.PermissionLevel (Alert, Dashboard, DatabaseInstance, PostgresProject). -type Permission PermissionT[iam.PermissionLevel] +// Permission is used for resources that use the generic PermissionLevel (Alert, Dashboard, DatabaseInstance, PostgresProject). +type Permission PermissionT[PermissionLevel] func (p Permission) String() string { - return PermissionT[iam.PermissionLevel](p).String() + return PermissionT[PermissionLevel](p).String() } // If the SDK exposes a resource's permission level, add it here. type ( - AppPermission PermissionT[apps.AppPermissionLevel] - ClusterPermission PermissionT[compute.ClusterPermissionLevel] - ClusterPolicyPermission PermissionT[compute.ClusterPolicyPermissionLevel] - InstancePoolPermission PermissionT[compute.InstancePoolPermissionLevel] - JobPermission PermissionT[jobs.JobPermissionLevel] - MlflowExperimentPermission PermissionT[ml.ExperimentPermissionLevel] - MlflowModelPermission PermissionT[ml.RegisteredModelPermissionLevel] - ModelServingEndpointPermission PermissionT[serving.ServingEndpointPermissionLevel] - PipelinePermission PermissionT[pipelines.PipelinePermissionLevel] - SqlWarehousePermission PermissionT[sql.WarehousePermissionLevel] - VectorSearchEndpointPermission PermissionT[vectorsearch.VectorSearchEndpointPermissionLevel] + AppPermission PermissionT[AppPermissionLevel] + ClusterPermission PermissionT[ClusterPermissionLevel] + ClusterPolicyPermission PermissionT[ClusterPolicyPermissionLevel] + InstancePoolPermission PermissionT[InstancePoolPermissionLevel] + JobPermission PermissionT[JobPermissionLevel] + MlflowExperimentPermission PermissionT[ExperimentPermissionLevel] + MlflowModelPermission PermissionT[RegisteredModelPermissionLevel] + ModelServingEndpointPermission PermissionT[ServingEndpointPermissionLevel] + PipelinePermission PermissionT[PipelinePermissionLevel] + SqlWarehousePermission PermissionT[WarehousePermissionLevel] + VectorSearchEndpointPermission PermissionT[VectorSearchEndpointPermissionLevel] ) diff --git a/bundle/config/resources/pipeline.go b/bundle/config/resources/pipeline.go index fd1fc61ce86..7c398df221d 100644 --- a/bundle/config/resources/pipeline.go +++ b/bundle/config/resources/pipeline.go @@ -4,17 +4,19 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/utils" + sdkpipelines "github.com/databricks/sdk-go/pipelines/v2" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/pipelines" ) type Pipeline struct { BaseResource - pipelines.CreatePipeline //nolint:govet // CreatePipeline.Id and our depth-0 ID field both carry json:"id"; the depth-0 field wins - ID string `json:"id,omitempty" bundle:"readonly"` + pipelines.CreatePipelineRequest //nolint:govet // CreatePipeline.Id and our depth-0 ID field both carry json:"id"; the depth-0 field wins + ID string `json:"id,omitempty" bundle:"readonly"` Permissions []PipelinePermission `json:"permissions,omitempty"` @@ -24,17 +26,9 @@ type Pipeline struct { CascadeOnDestroy *bool `json:"cascade_on_destroy,omitempty"` } -func (p *Pipeline) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, p) -} - -func (p Pipeline) MarshalJSON() ([]byte, error) { - return marshal.Marshal(p) -} - -func (p *Pipeline) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { - _, err := w.Pipelines.Get(ctx, pipelines.GetPipelineRequest{ - PipelineId: id, +func (p *Pipeline) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { + _, err := w.Pipelines.Get(ctx, sdkpipelines.GetPipelineRequest{ + PipelineId: new(id), }) if err != nil { log.Debugf(ctx, "pipeline %s does not exist", id) @@ -60,5 +54,5 @@ func (p *Pipeline) InitializeURL(baseURL url.URL) { } func (p *Pipeline) GetName() string { - return p.Name + return utils.Deref(p.Name) } diff --git a/bundle/config/resources/postgres_branch.go b/bundle/config/resources/postgres_branch.go index a248667a87e..611b2cf917a 100644 --- a/bundle/config/resources/postgres_branch.go +++ b/bundle/config/resources/postgres_branch.go @@ -4,10 +4,11 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" + "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" ) type PostgresBranchConfig struct { @@ -29,21 +30,7 @@ type PostgresBranchConfig struct { // DeleteBranch). When false or unset, the backend performs a soft delete that // can be undone within the branch's retention window. Input-only: not // returned by the GET API. - PurgeOnDelete bool `json:"purge_on_delete,omitempty"` - - // ForceSendFields shadows the embedded BranchSpec.ForceSendFields so the - // SDK's marshal package tracks zero-value top-level fields (branch_id, - // parent, replace_existing, purge_on_delete) here instead of polluting - // BranchSpec.ForceSendFields with names that don't exist in that struct. - ForceSendFields []string `json:"-" url:"-"` -} - -func (c *PostgresBranchConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c PostgresBranchConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) + PurgeOnDelete *bool `json:"purge_on_delete,omitempty"` } type PostgresBranch struct { @@ -52,16 +39,8 @@ type PostgresBranch struct { PostgresBranchConfig } -func (b *PostgresBranch) UnmarshalJSON(data []byte) error { - return marshal.Unmarshal(data, b) -} - -func (b PostgresBranch) MarshalJSON() ([]byte, error) { - return marshal.Marshal(b) -} - -func (b *PostgresBranch) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Postgres.GetBranch(ctx, postgres.GetBranchRequest{Name: name}) +func (b *PostgresBranch) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Postgres.GetBranch(ctx, sdkpostgres.GetBranchRequest{Name: new(name)}) if err != nil { log.Debugf(ctx, "postgres branch %s does not exist", name) return false, err diff --git a/bundle/config/resources/postgres_branch_test.go b/bundle/config/resources/postgres_branch_test.go index a9c846c38de..13e7e4b284d 100644 --- a/bundle/config/resources/postgres_branch_test.go +++ b/bundle/config/resources/postgres_branch_test.go @@ -8,23 +8,6 @@ import ( "github.com/stretchr/testify/require" ) -// TestPostgresBranchConfigMarshalHonorsForceSendFields pins the reason -// PostgresBranchConfig.MarshalJSON is declared on a value receiver. -// -// PurgeOnDelete is omitempty, so its zero value is emitted only because -// ForceSendFields names it, and the SDK marshaler is what honors ForceSendFields. -// With a pointer-receiver MarshalJSON, only *T satisfies json.Marshaler, so -// marshalling a value falls back to plain encoding/json -- which ignores -// ForceSendFields (tagged json:"-") and would drop the field. -func TestPostgresBranchConfigMarshalHonorsForceSendFields(t *testing.T) { - c := PostgresBranchConfig{BranchId: "b1", Parent: "projects/p1"} - c.ForceSendFields = []string{"PurgeOnDelete"} - - b, err := json.Marshal(c) - require.NoError(t, err) - assert.JSONEq(t, `{"branch_id":"b1","parent":"projects/p1","purge_on_delete":false}`, string(b)) -} - // TestPostgresBranchMarshalValueAndPointerAgree guards the invariant directly: // a value-receiver MarshalJSON makes json.Marshal(x) and json.Marshal(&x) // produce the same bytes. A pointer-only marshaler would send them down two diff --git a/bundle/config/resources/postgres_catalog.go b/bundle/config/resources/postgres_catalog.go index 51246f06af0..37552fa1455 100644 --- a/bundle/config/resources/postgres_catalog.go +++ b/bundle/config/resources/postgres_catalog.go @@ -4,45 +4,30 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" ) type PostgresCatalogConfig struct { - postgres.CatalogCatalogSpec + postgres.Catalog_CatalogSpec // CatalogId is the user-specified UC catalog name. Becomes the trailing // component of the server-assigned Name: "catalogs/{catalog_id}". CatalogId string `json:"catalog_id"` } -func (c *PostgresCatalogConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c PostgresCatalogConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) -} - type PostgresCatalog struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` PostgresCatalogConfig } -func (c *PostgresCatalog) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c PostgresCatalog) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) -} - -func (c *PostgresCatalog) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Postgres.GetCatalog(ctx, postgres.GetCatalogRequest{Name: name}) +func (c *PostgresCatalog) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Postgres.GetCatalog(ctx, sdkpostgres.GetCatalogRequest{Name: new(name)}) if err != nil { log.Debugf(ctx, "postgres catalog %s does not exist", name) return false, err diff --git a/bundle/config/resources/postgres_database.go b/bundle/config/resources/postgres_database.go index efbe5984d5e..7f9e16359cd 100644 --- a/bundle/config/resources/postgres_database.go +++ b/bundle/config/resources/postgres_database.go @@ -4,15 +4,16 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" + "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" ) type PostgresDatabaseConfig struct { - postgres.DatabaseDatabaseSpec + postgres.Database_DatabaseSpec // DatabaseId is the user-specified ID for the database (becomes part of the hierarchical name). // This is specified during creation and becomes part of Name: "projects/{project_id}/branches/{branch_id}/databases/{database_id}" @@ -27,31 +28,15 @@ type PostgresDatabaseConfig struct { ReplaceExisting bool `json:"replace_existing,omitempty"` } -func (c *PostgresDatabaseConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c PostgresDatabaseConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) -} - type PostgresDatabase struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` PostgresDatabaseConfig } -func (d *PostgresDatabase) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, d) -} - -func (d PostgresDatabase) MarshalJSON() ([]byte, error) { - return marshal.Marshal(d) -} - -func (d *PostgresDatabase) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Postgres.GetDatabase(ctx, postgres.GetDatabaseRequest{Name: name}) - if apierr.IsMissing(err) { +func (d *PostgresDatabase) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Postgres.GetDatabase(ctx, sdkpostgres.GetDatabaseRequest{Name: new(name)}) + if apierrs.IsMissing(err) { log.Debugf(ctx, "postgres database %s does not exist", name) return false, nil } diff --git a/bundle/config/resources/postgres_endpoint.go b/bundle/config/resources/postgres_endpoint.go index 0947045a719..47f6dcfed67 100644 --- a/bundle/config/resources/postgres_endpoint.go +++ b/bundle/config/resources/postgres_endpoint.go @@ -4,10 +4,11 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" + "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" ) type PostgresEndpointConfig struct { @@ -26,30 +27,14 @@ type PostgresEndpointConfig struct { ReplaceExisting bool `json:"replace_existing,omitempty"` } -func (c *PostgresEndpointConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c PostgresEndpointConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) -} - type PostgresEndpoint struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` PostgresEndpointConfig } -func (e *PostgresEndpoint) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, e) -} - -func (e PostgresEndpoint) MarshalJSON() ([]byte, error) { - return marshal.Marshal(e) -} - -func (e *PostgresEndpoint) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Postgres.GetEndpoint(ctx, postgres.GetEndpointRequest{Name: name}) +func (e *PostgresEndpoint) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Postgres.GetEndpoint(ctx, sdkpostgres.GetEndpointRequest{Name: new(name)}) if err != nil { log.Debugf(ctx, "postgres endpoint %s does not exist", name) return false, err diff --git a/bundle/config/resources/postgres_project.go b/bundle/config/resources/postgres_project.go index 0cdfbbcc2af..98bea4e0463 100644 --- a/bundle/config/resources/postgres_project.go +++ b/bundle/config/resources/postgres_project.go @@ -4,10 +4,12 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" + "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" ) type PostgresProjectConfig struct { @@ -21,21 +23,7 @@ type PostgresProjectConfig struct { // DeleteProject). When false or unset, the backend performs a soft delete that // can be undone within the project's retention window. Input-only: not // returned by the GET API. - PurgeOnDelete bool `json:"purge_on_delete,omitempty"` - - // ForceSendFields shadows the embedded ProjectSpec.ForceSendFields so the - // SDK's marshal package tracks zero-value top-level fields (project_id, - // purge_on_delete) here instead of polluting ProjectSpec.ForceSendFields - // with names that don't exist in that struct. - ForceSendFields []string `json:"-" url:"-"` -} - -func (c *PostgresProjectConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c PostgresProjectConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) + PurgeOnDelete *bool `json:"purge_on_delete,omitempty"` } type PostgresProject struct { @@ -46,16 +34,8 @@ type PostgresProject struct { Permissions []Permission `json:"permissions,omitempty"` } -func (p *PostgresProject) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, p) -} - -func (p PostgresProject) MarshalJSON() ([]byte, error) { - return marshal.Marshal(p) -} - -func (p *PostgresProject) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Postgres.GetProject(ctx, postgres.GetProjectRequest{Name: name}) +func (p *PostgresProject) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Postgres.GetProject(ctx, sdkpostgres.GetProjectRequest{Name: new(name)}) if err != nil { log.Debugf(ctx, "postgres project %s does not exist", name) return false, err @@ -73,7 +53,7 @@ func (p *PostgresProject) ResourceDescription() ResourceDescription { } func (p *PostgresProject) GetName() string { - return p.DisplayName + return utils.Deref(p.DisplayName) } func (p *PostgresProject) GetURL() (string, bool) { diff --git a/bundle/config/resources/postgres_role.go b/bundle/config/resources/postgres_role.go index 7cc30a3ee0a..5877267dcc9 100644 --- a/bundle/config/resources/postgres_role.go +++ b/bundle/config/resources/postgres_role.go @@ -4,15 +4,16 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" + "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" ) type PostgresRoleConfig struct { - postgres.RoleRoleSpec + postgres.Role_RoleSpec // RoleId is the user-specified ID for the role (becomes part of the hierarchical name). // This is specified during creation and becomes part of Name: "projects/{project_id}/branches/{branch_id}/roles/{role_id}" @@ -28,31 +29,15 @@ type PostgresRoleConfig struct { ReplaceExisting bool `json:"replace_existing,omitempty"` } -func (c *PostgresRoleConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c PostgresRoleConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) -} - type PostgresRole struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` PostgresRoleConfig } -func (r *PostgresRole) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, r) -} - -func (r PostgresRole) MarshalJSON() ([]byte, error) { - return marshal.Marshal(r) -} - -func (r *PostgresRole) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Postgres.GetRole(ctx, postgres.GetRoleRequest{Name: name}) - if apierr.IsMissing(err) { +func (r *PostgresRole) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Postgres.GetRole(ctx, sdkpostgres.GetRoleRequest{Name: new(name)}) + if apierrs.IsMissing(err) { log.Debugf(ctx, "postgres role %s does not exist", name) return false, nil } diff --git a/bundle/config/resources/postgres_snapshot_schedule.go b/bundle/config/resources/postgres_snapshot_schedule.go index d07ac597f31..06eb24f4a67 100644 --- a/bundle/config/resources/postgres_snapshot_schedule.go +++ b/bundle/config/resources/postgres_snapshot_schedule.go @@ -4,10 +4,11 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" + "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" ) type PostgresSnapshotScheduleConfig struct { @@ -21,18 +22,6 @@ type PostgresSnapshotScheduleConfig struct { // several cadences fire together a single snapshot is taken, retained for the // longest of their retentions. Schedule []postgres.ScheduleCadence `json:"schedule,omitempty"` - - // ForceSendFields tracks zero-value top-level fields (branch) for the SDK's - // marshal package. - ForceSendFields []string `json:"-" url:"-"` -} - -func (c *PostgresSnapshotScheduleConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c PostgresSnapshotScheduleConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) } type PostgresSnapshotSchedule struct { @@ -41,16 +30,8 @@ type PostgresSnapshotSchedule struct { PostgresSnapshotScheduleConfig } -func (b *PostgresSnapshotSchedule) UnmarshalJSON(data []byte) error { - return marshal.Unmarshal(data, b) -} - -func (b PostgresSnapshotSchedule) MarshalJSON() ([]byte, error) { - return marshal.Marshal(b) -} - -func (b *PostgresSnapshotSchedule) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Postgres.GetSnapshotSchedule(ctx, postgres.GetSnapshotScheduleRequest{Name: name}) +func (b *PostgresSnapshotSchedule) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Postgres.GetSnapshotSchedule(ctx, sdkpostgres.GetSnapshotScheduleRequest{Name: new(name)}) if err != nil { log.Debugf(ctx, "postgres snapshot schedule %s does not exist", name) return false, err diff --git a/bundle/config/resources/postgres_synced_table.go b/bundle/config/resources/postgres_synced_table.go index 3aac2578d70..d0c47f8d432 100644 --- a/bundle/config/resources/postgres_synced_table.go +++ b/bundle/config/resources/postgres_synced_table.go @@ -5,15 +5,16 @@ import ( "net/url" "strings" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" ) type PostgresSyncedTableConfig struct { - postgres.SyncedTableSyncedTableSpec + postgres.SyncedTable_SyncedTableSpec // SyncedTableId is the user-specified three-part UC name (catalog.schema.table). // Becomes the trailing component of the server-assigned Name: @@ -21,30 +22,14 @@ type PostgresSyncedTableConfig struct { SyncedTableId string `json:"synced_table_id"` } -func (c *PostgresSyncedTableConfig) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, c) -} - -func (c PostgresSyncedTableConfig) MarshalJSON() ([]byte, error) { - return marshal.Marshal(c) -} - type PostgresSyncedTable struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` PostgresSyncedTableConfig } -func (s *PostgresSyncedTable) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PostgresSyncedTable) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (s *PostgresSyncedTable) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Postgres.GetSyncedTable(ctx, postgres.GetSyncedTableRequest{Name: name}) +func (s *PostgresSyncedTable) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Postgres.GetSyncedTable(ctx, sdkpostgres.GetSyncedTableRequest{Name: new(name)}) if err != nil { log.Debugf(ctx, "postgres synced table %s does not exist", name) return false, err diff --git a/bundle/config/resources/quality_monitor.go b/bundle/config/resources/quality_monitor.go index 5548ef4d7da..26f9ee9a0c4 100644 --- a/bundle/config/resources/quality_monitor.go +++ b/bundle/config/resources/quality_monitor.go @@ -4,11 +4,11 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/qualitymonitors" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/catalog" ) type QualityMonitor struct { @@ -16,23 +16,15 @@ type QualityMonitor struct { ID string `json:"id,omitempty" bundle:"readonly"` // This struct defines the creation payload for a monitor. - catalog.CreateMonitor + qualitymonitors.CreateMonitor // The table name is a required field but not included as a JSON field in [catalog.CreateMonitor]. TableName string `json:"table_name"` } -func (s *QualityMonitor) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s QualityMonitor) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (s *QualityMonitor) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { +func (s *QualityMonitor) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { //nolint:staticcheck // Bundle quality_monitor still targets legacy monitor endpoints; v1 data-quality migration is separate work. - _, err := w.QualityMonitors.Get(ctx, catalog.GetQualityMonitorRequest{ + _, err := w.QualityMonitors.Get(ctx, qualitymonitors.GetQualityMonitorRequest{ TableName: id, }) if err != nil { diff --git a/bundle/config/resources/registered_model.go b/bundle/config/resources/registered_model.go index ed06e942f23..12ca9f5f4e1 100644 --- a/bundle/config/resources/registered_model.go +++ b/bundle/config/resources/registered_model.go @@ -4,34 +4,29 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1" + "github.com/databricks/cli/libs/utils" + sdkregisteredmodels "github.com/databricks/sdk-go/uc/registeredmodels/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/catalog" ) type RegisteredModel struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - catalog.CreateRegisteredModelRequest + registeredmodels.CreateRegisteredModelRequest // List of grants to apply on this registered model. - Grants []catalog.PrivilegeAssignment `json:"grants,omitempty"` -} - -func (s *RegisteredModel) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s RegisteredModel) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) + Grants []grants.PrivilegeAssignment `json:"grants,omitempty"` } -func (s *RegisteredModel) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { - _, err := w.RegisteredModels.Get(ctx, catalog.GetRegisteredModelRequest{ - FullName: id, +func (s *RegisteredModel) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { + _, err := w.RegisteredModels.GetRegisteredModel(ctx, sdkregisteredmodels.GetRegisteredModelRequest{ + FullNameArg: new(id), }) if err != nil { log.Debugf(ctx, "registered model %s does not exist", id) @@ -57,5 +52,5 @@ func (s *RegisteredModel) InitializeURL(baseURL url.URL) { } func (s *RegisteredModel) GetName() string { - return s.Name + return utils.Deref(s.Name) } diff --git a/bundle/config/resources/schema.go b/bundle/config/resources/schema.go index 5b6f5001516..73fdf3ce6f9 100644 --- a/bundle/config/resources/schema.go +++ b/bundle/config/resources/schema.go @@ -4,32 +4,32 @@ import ( "context" "net/url" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + "github.com/databricks/cli/libs/utils" + sdkschemas "github.com/databricks/sdk-go/uc/schemas/v1" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/catalog" ) type Schema struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - catalog.CreateSchema + CreateSchema // List of grants to apply on this schema. - Grants []catalog.PrivilegeAssignment `json:"grants,omitempty"` + Grants []grants.PrivilegeAssignment `json:"grants,omitempty"` } -func (s *Schema) Exists(ctx context.Context, w *databricks.WorkspaceClient, fullName string) (bool, error) { +func (s *Schema) Exists(ctx context.Context, w *sdkclients.Clients, fullName string) (bool, error) { log.Tracef(ctx, "Checking if schema with fullName=%s exists", fullName) - _, err := w.Schemas.GetByFullName(ctx, fullName) + _, err := w.Schemas.GetSchema(ctx, sdkschemas.GetSchemaRequest{FullNameArg: new(fullName)}) if err != nil { log.Debugf(ctx, "schema with full name %s does not exist: %v", fullName, err) - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return false, nil } @@ -55,13 +55,5 @@ func (s *Schema) InitializeURL(baseURL url.URL) { } func (s *Schema) GetName() string { - return s.Name -} - -func (s *Schema) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s Schema) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) + return utils.Deref(s.Name) } diff --git a/bundle/config/resources/schema_test.go b/bundle/config/resources/schema_test.go index 55537062d51..68c6d316509 100644 --- a/bundle/config/resources/schema_test.go +++ b/bundle/config/resources/schema_test.go @@ -3,22 +3,18 @@ package resources import ( "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestSchemaNotFound(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - m.GetMockSchemasAPI().On("GetByFullName", mock.Anything, "non-existent-schema").Return(nil, &apierr.APIError{ - StatusCode: 404, + w := newTestClients(t, map[string]any{ + "GET /api/2.1/unity-catalog/schemas/non-existent-schema": notFound(), }) s := &Schema{} - exists, err := s.Exists(ctx, m.WorkspaceClient, "non-existent-schema") + exists, err := s.Exists(ctx, w, "non-existent-schema") require.Falsef(t, exists, "Exists should return false when getting a 404 response from Workspace") require.NoErrorf(t, err, "Exists should not return an error when getting a 404 response from Workspace") diff --git a/bundle/config/resources/secret.go b/bundle/config/resources/secret.go index a6ce7540374..3c62d1a65bd 100644 --- a/bundle/config/resources/secret.go +++ b/bundle/config/resources/secret.go @@ -5,41 +5,36 @@ import ( "fmt" "net/url" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + "github.com/databricks/cli/libs/sdktypes/uc/secrets/v1" + "github.com/databricks/cli/libs/utils" + sdksecretsuc "github.com/databricks/sdk-go/uc/secrets/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/catalog" ) type Secret struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - catalog.Secret + secrets.Secret // List of grants to apply on this secret. - Grants []catalog.PrivilegeAssignment `json:"grants,omitempty"` -} - -func (s *Secret) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s Secret) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) + Grants []grants.PrivilegeAssignment `json:"grants,omitempty"` } -func (s *Secret) Exists(ctx context.Context, w *databricks.WorkspaceClient, fullName string) (bool, error) { +func (s *Secret) Exists(ctx context.Context, w *sdkclients.Clients, fullName string) (bool, error) { log.Tracef(ctx, "Checking if secret with fullName=%s exists", fullName) - _, err := w.SecretsUc.GetSecret(ctx, catalog.GetSecretRequest{ - FullName: fullName, + _, err := w.SecretsUc.GetSecret(ctx, sdksecretsuc.GetSecretRequest{ + FullName: new(fullName), }) if err != nil { log.Debugf(ctx, "secret with full name %s does not exist: %v", fullName, err) - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return false, nil } @@ -68,5 +63,5 @@ func (s *Secret) GetName() string { if s.ID != "" { return s.ID } - return fmt.Sprintf("%s.%s.%s", s.CatalogName, s.SchemaName, s.Name) + return fmt.Sprintf("%s.%s.%s", utils.Deref(s.CatalogName), utils.Deref(s.SchemaName), utils.Deref(s.Name)) } diff --git a/bundle/config/resources/secret_scope.go b/bundle/config/resources/secret_scope.go index abd34dff9b2..9634692f34b 100644 --- a/bundle/config/resources/secret_scope.go +++ b/bundle/config/resources/secret_scope.go @@ -4,9 +4,10 @@ import ( "context" "net/url" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/secrets/v1" + "github.com/databricks/cli/libs/utils" + sdksecrets "github.com/databricks/sdk-go/secrets/v1" ) type SecretScopePermissionLevel string @@ -54,20 +55,12 @@ type SecretScope struct { //nolint:recvcheck // pointer receiver needed for Unma // for better developer experience compared to `workspace.CreateScope`. // The type of secret scope backend. - BackendType workspace.ScopeBackendType `json:"backend_type,omitempty"` + BackendType secrets.ScopeBackendType `json:"backend_type,omitempty"` // The metadata for the secret scope if the type is `AZURE_KEYVAULT` - KeyvaultMetadata *workspace.AzureKeyVaultSecretScopeMetadata `json:"keyvault_metadata,omitempty"` + KeyvaultMetadata *secrets.AzureKeyVaultSecretScopeMetadata `json:"keyvault_metadata,omitempty"` } -func (s *SecretScope) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s SecretScope) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (s SecretScope) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { +func (s SecretScope) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { // NOTE: Scope lookup by name is not directly supported by the Secret scopes API // As of May 2025 there is no direct API method to retrieve a scope using its name as an identifier. // While scope names serve as unique identifiers, the API only provides: @@ -75,13 +68,13 @@ func (s SecretScope) Exists(ctx context.Context, w *databricks.WorkspaceClient, // - Other operational methods (e.g., reading a secret from a scope and parsing error messages) // // The indirect methods are not semantically ideal for simple existence checks, so we use the list API here - scopes, err := w.Secrets.ListScopesAll(ctx) + resp, err := w.Secrets.ListScopes(ctx, sdksecrets.ListScopesRequest{}) if err != nil { return false, nil //nolint:nilerr // treat API errors as "scope not found" } - for _, scope := range scopes { - if scope.Name == name { + for _, scope := range resp.Scopes { + if utils.Deref(scope.Name) == name { return true, nil } } diff --git a/bundle/config/resources/snapshot.go b/bundle/config/resources/snapshot.go index 95d98c89271..f6eccc313db 100644 --- a/bundle/config/resources/snapshot.go +++ b/bundle/config/resources/snapshot.go @@ -6,8 +6,9 @@ import ( "path" "strings" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/snapshot" - "github.com/databricks/databricks-sdk-go" ) const ( @@ -77,7 +78,7 @@ func (s *Snapshot) FullPath() string { return path.Join(s.RemoteRoot, s.RelativePath()) } -func (s *Snapshot) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { +func (s *Snapshot) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { _, err := w.Workspace.GetStatusByPath(ctx, s.FullPath()) if err != nil { return false, err diff --git a/bundle/config/resources/sql_warehouses.go b/bundle/config/resources/sql_warehouses.go index de0fda7de74..4e9d1be8675 100644 --- a/bundle/config/resources/sql_warehouses.go +++ b/bundle/config/resources/sql_warehouses.go @@ -4,17 +4,19 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/warehouses/v1" + "github.com/databricks/cli/libs/utils" + sdkwarehouses "github.com/databricks/sdk-go/warehouses/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/sql" ) type SqlWarehouse struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - sql.CreateWarehouseRequest + warehouses.CreateWarehouseRequest // Lifecycle shadows BaseResource.Lifecycle to add support for lifecycle.started. Lifecycle *LifecycleWithStarted `json:"lifecycle,omitempty"` @@ -30,16 +32,8 @@ func (sw *SqlWarehouse) GetLifecycle() LifecycleConfig { return *sw.Lifecycle } -func (sw *SqlWarehouse) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, sw) -} - -func (sw SqlWarehouse) MarshalJSON() ([]byte, error) { - return marshal.Marshal(sw) -} - -func (sw *SqlWarehouse) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) { - _, err := w.Warehouses.GetById(ctx, id) +func (sw *SqlWarehouse) Exists(ctx context.Context, w *sdkclients.Clients, id string) (bool, error) { + _, err := w.Warehouses.GetWarehouse(ctx, sdkwarehouses.GetWarehouseRequest{Id: new(id)}) if err != nil { log.Debugf(ctx, "sql warehouse %s does not exist", id) return false, err @@ -64,5 +58,5 @@ func (sw *SqlWarehouse) InitializeURL(baseURL url.URL) { } func (sw *SqlWarehouse) GetName() string { - return sw.Name + return utils.Deref(sw.Name) } diff --git a/bundle/config/resources/synced_database_table.go b/bundle/config/resources/synced_database_table.go index b8839d99a5e..05819726991 100644 --- a/bundle/config/resources/synced_database_table.go +++ b/bundle/config/resources/synced_database_table.go @@ -4,12 +4,13 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/database/v1" + "github.com/databricks/cli/libs/utils" + sdkdatabase "github.com/databricks/sdk-go/database/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/database" ) type SyncedDatabaseTable struct { @@ -18,16 +19,8 @@ type SyncedDatabaseTable struct { database.SyncedDatabaseTable } -func (s *SyncedDatabaseTable) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s SyncedDatabaseTable) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (s *SyncedDatabaseTable) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.Database.GetSyncedDatabaseTable(ctx, database.GetSyncedDatabaseTableRequest{Name: name}) +func (s *SyncedDatabaseTable) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.Database.GetSyncedDatabaseTable(ctx, sdkdatabase.GetSyncedDatabaseTableRequest{Name: new(name)}) if err != nil { log.Debugf(ctx, "synced database table %s does not exist", name) return false, err @@ -45,12 +38,12 @@ func (s *SyncedDatabaseTable) ResourceDescription() ResourceDescription { } func (s *SyncedDatabaseTable) GetName() string { - return s.Name + return utils.Deref(s.Name) } func (s *SyncedDatabaseTable) InitializeURL(baseURL url.URL) { - if s.Name == "" { + if s.Name == nil { return } - s.URL = workspaceurls.ResourceURL(baseURL, "synced_database_tables", s.Name) + s.URL = workspaceurls.ResourceURL(baseURL, "synced_database_tables", *s.Name) } diff --git a/bundle/config/resources/uc_types.go b/bundle/config/resources/uc_types.go new file mode 100644 index 00000000000..be63e0bf448 --- /dev/null +++ b/bundle/config/resources/uc_types.go @@ -0,0 +1,169 @@ +package resources + +import ( + "github.com/databricks/cli/libs/sdktypes/uc/catalogs/v1" + "github.com/databricks/cli/libs/sdktypes/uc/externallocations/v1" + "github.com/databricks/cli/libs/sdktypes/uc/schemas/v1" + "github.com/databricks/cli/libs/sdktypes/uc/volumes/v1" +) + +// The Unity Catalog create requests in sdk-go reuse the full securable +// message, including output-only fields such as created_at and metastore_id. +// Bundle configuration only accepts the fields a user can set on create, so +// these types carry that subset and convert to the full request. + +type CreateCatalog struct { + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // The name of the connection to an external data source. + ConnectionName *string `json:"connection_name,omitempty"` + // Custom maximum retention period in hours for the catalog + CustomMaxRetentionHours *int64 `json:"custom_max_retention_hours,omitempty"` + // Control CMK encryption for managed catalog data + ManagedEncryptionSettings *catalogs.EncryptionSettings `json:"managed_encryption_settings,omitempty"` + // Name of catalog. + Name *string `json:"name,omitempty"` + // A map of key-value properties attached to the securable. + Options map[string]string `json:"options,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + // The name of delta sharing provider. + // + // A Delta Sharing catalog is a catalog that is based on a Delta share on a + // remote sharing server. + ProviderName *string `json:"provider_name,omitempty"` + // The name of the share under the share provider. + ShareName *string `json:"share_name,omitempty"` + // Storage root URL for managed tables within catalog. + StorageRoot *string `json:"storage_root,omitempty"` +} + +// AsRequest returns the create request for this configuration. +func (c *CreateCatalog) AsRequest() *catalogs.CreateCatalogRequest { + return &catalogs.CreateCatalogRequest{ + Comment: c.Comment, + ConnectionName: c.ConnectionName, + CustomMaxRetentionHours: c.CustomMaxRetentionHours, + ManagedEncryptionSettings: c.ManagedEncryptionSettings, + Name: c.Name, + Options: c.Options, + Properties: c.Properties, + ProviderName: c.ProviderName, + ShareName: c.ShareName, + StorageRoot: c.StorageRoot, + } +} + +type CreateSchema struct { + // Name of parent catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Custom maximum retention period in hours for the schema. + CustomMaxRetentionHours *int64 `json:"custom_max_retention_hours,omitempty"` + // Name of schema, relative to parent catalog. + Name *string `json:"name,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + // Storage root URL for managed tables within schema. + StorageRoot *string `json:"storage_root,omitempty"` +} + +// AsRequest returns the create request for this configuration. +func (c *CreateSchema) AsRequest() *schemas.CreateSchemaRequest { + return &schemas.CreateSchemaRequest{ + CatalogName: c.CatalogName, + Comment: c.Comment, + CustomMaxRetentionHours: c.CustomMaxRetentionHours, + Name: c.Name, + Properties: c.Properties, + StorageRoot: c.StorageRoot, + } +} + +type CreateVolumeRequestContent struct { + // The name of the catalog where the schema and the volume are + CatalogName *string `json:"catalog_name,omitempty"` + // The comment attached to the volume + Comment *string `json:"comment,omitempty"` + // The name of the volume + Name *string `json:"name,omitempty"` + // The name of the schema where the volume is + SchemaName *string `json:"schema_name,omitempty"` + // The storage location on the cloud + StorageLocation *string `json:"storage_location,omitempty"` + // The type of the volume. An external volume is located in the specified + // external location. A managed volume is located in the default location which + // is specified by the parent schema, or the parent catalog, or the Metastore. + // [Learn more] + // + // [Learn more]: https://docs.databricks.com/aws/en/volumes/managed-vs-external + VolumeType volumes.VolumeType `json:"volume_type,omitempty"` +} + +// AsRequest returns the create request for this configuration. +func (c *CreateVolumeRequestContent) AsRequest() *volumes.CreateVolumeRequest { + return &volumes.CreateVolumeRequest{ + CatalogName: c.CatalogName, + Comment: c.Comment, + Name: c.Name, + SchemaName: c.SchemaName, + StorageLocation: c.StorageLocation, + VolumeType: c.VolumeType, + } +} + +type CreateExternalLocation struct { + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Name of the storage credential used with this location. + CredentialName *string `json:"credential_name,omitempty"` + // The effective value of `enable_file_events` after applying server-side + // defaults. + EffectiveEnableFileEvents *bool `json:"effective_enable_file_events,omitempty"` + // The effective file event queue configuration after applying server-side + // defaults. Always populated when a queue is provisioned, regardless of whether + // the user explicitly set `enable_file_events`. Use this field instead of + // `file_event_queue` for reading the actual queue state. + EffectiveFileEventQueue *externallocations.FileEventQueue `json:"effective_file_event_queue,omitempty"` + // Whether to enable file events on this external location. Default to `true`. + // Set to `false` to disable file events. The actual applied value may differ + // due to server-side defaults; check `effective_enable_file_events` for the + // effective state. + EnableFileEvents *bool `json:"enable_file_events,omitempty"` + EncryptionDetails *externallocations.EncryptionDetails `json:"encryption_details,omitempty"` + // Indicates whether fallback mode is enabled for this external location. When + // fallback mode is enabled, the access to the location falls back to cluster + // credentials if UC credentials are not sufficient. + Fallback *bool `json:"fallback,omitempty"` + // File event queue settings. If `enable_file_events` is not `false`, must be + // defined and have exactly one of the documented properties. + FileEventQueue *externallocations.FileEventQueue `json:"file_event_queue,omitempty"` + // Name of the external location. + Name *string `json:"name,omitempty"` + // Indicates whether the external location is read-only. + ReadOnly *bool `json:"read_only,omitempty"` + // Skips validation of the storage credential associated with the external + // location. + SkipValidation *bool `json:"skip_validation,omitempty"` + // Path URL of the external location. + Url *string `json:"url,omitempty"` +} + +// AsRequest returns the create request for this configuration. +func (c *CreateExternalLocation) AsRequest() *externallocations.CreateExternalLocationRequest { + return &externallocations.CreateExternalLocationRequest{ + Comment: c.Comment, + CredentialName: c.CredentialName, + EffectiveEnableFileEvents: c.EffectiveEnableFileEvents, + EffectiveFileEventQueue: c.EffectiveFileEventQueue, + EnableFileEvents: c.EnableFileEvents, + EncryptionDetails: c.EncryptionDetails, + Fallback: c.Fallback, + FileEventQueue: c.FileEventQueue, + Name: c.Name, + ReadOnly: c.ReadOnly, + SkipValidation: c.SkipValidation, + Url: c.Url, + } +} diff --git a/bundle/config/resources/vector_search_endpoint.go b/bundle/config/resources/vector_search_endpoint.go index 5404469bdfd..8a55fad9dcd 100644 --- a/bundle/config/resources/vector_search_endpoint.go +++ b/bundle/config/resources/vector_search_endpoint.go @@ -4,35 +4,29 @@ import ( "context" "net/url" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" + "github.com/databricks/cli/libs/utils" + sdkvectorsearch "github.com/databricks/sdk-go/vectorsearch/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" ) type VectorSearchEndpoint struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - vectorsearch.CreateEndpoint + vectorsearch.CreateEndpointRequest Permissions []VectorSearchEndpointPermission `json:"permissions,omitempty"` } -func (e *VectorSearchEndpoint) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, e) -} - -func (e VectorSearchEndpoint) MarshalJSON() ([]byte, error) { - return marshal.Marshal(e) -} - -func (e *VectorSearchEndpoint) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.VectorSearchEndpoints.GetEndpoint(ctx, vectorsearch.GetEndpointRequest{EndpointName: name}) +func (e *VectorSearchEndpoint) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.VectorSearch.GetEndpoint(ctx, sdkvectorsearch.GetEndpointRequest{Name: new(name)}) if err != nil { log.Debugf(ctx, "vector search endpoint %s does not exist: %v", name, err) - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return false, nil } return false, err @@ -50,12 +44,12 @@ func (e *VectorSearchEndpoint) ResourceDescription() ResourceDescription { } func (e *VectorSearchEndpoint) InitializeURL(baseURL url.URL) { - if e.Name == "" { + if e.Name == nil { return } - e.URL = workspaceurls.ResourceURL(baseURL, "vector_search_endpoints", e.Name) + e.URL = workspaceurls.ResourceURL(baseURL, "vector_search_endpoints", *e.Name) } func (e *VectorSearchEndpoint) GetName() string { - return e.Name + return utils.Deref(e.Name) } diff --git a/bundle/config/resources/vector_search_index.go b/bundle/config/resources/vector_search_index.go index 2c843376209..444250af0ed 100644 --- a/bundle/config/resources/vector_search_index.go +++ b/bundle/config/resources/vector_search_index.go @@ -5,13 +5,15 @@ import ( "net/url" "strings" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" + "github.com/databricks/cli/libs/utils" + sdkvectorsearch "github.com/databricks/sdk-go/vectorsearch/v1" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" ) type VectorSearchIndex struct { @@ -20,22 +22,14 @@ type VectorSearchIndex struct { vectorsearch.CreateVectorIndexRequest // List of grants to apply on this vector search index. - Grants []catalog.PrivilegeAssignment `json:"grants,omitempty"` -} - -func (e *VectorSearchIndex) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, e) -} - -func (e VectorSearchIndex) MarshalJSON() ([]byte, error) { - return marshal.Marshal(e) + Grants []grants.PrivilegeAssignment `json:"grants,omitempty"` } -func (e *VectorSearchIndex) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) { - _, err := w.VectorSearchIndexes.GetIndexByIndexName(ctx, name) +func (e *VectorSearchIndex) Exists(ctx context.Context, w *sdkclients.Clients, name string) (bool, error) { + _, err := w.VectorSearch.GetVectorIndex(ctx, sdkvectorsearch.GetVectorIndexRequest{Name: new(name)}) if err != nil { log.Debugf(ctx, "vector search index %s does not exist: %v", name, err) - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return false, nil } return false, err @@ -56,12 +50,12 @@ func (e *VectorSearchIndex) InitializeURL(baseURL url.URL) { // UC explore expects /{catalog}/{schema}/{name}, so bail if the name isn't // a fully resolved three-part identifier; an unresolved ${...} reference // would otherwise produce a misleading URL. - if strings.Count(e.Name, ".") != 2 { + if strings.Count(utils.Deref(e.Name), ".") != 2 { return } - e.URL = workspaceurls.ResourceURL(baseURL, "vector_search_indexes", e.Name) + e.URL = workspaceurls.ResourceURL(baseURL, "vector_search_indexes", *e.Name) } func (e *VectorSearchIndex) GetName() string { - return e.Name + return utils.Deref(e.Name) } diff --git a/bundle/config/resources/volume.go b/bundle/config/resources/volume.go index db321e9ceb2..0f76e7e73d1 100644 --- a/bundle/config/resources/volume.go +++ b/bundle/config/resources/volume.go @@ -5,43 +5,36 @@ import ( "fmt" "net/url" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + "github.com/databricks/cli/libs/utils" + sdkvolumes "github.com/databricks/sdk-go/uc/volumes/v1" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/catalog" ) type Volume struct { BaseResource ID string `json:"id,omitempty" bundle:"readonly"` - catalog.CreateVolumeRequestContent + CreateVolumeRequestContent // VolumePath is /Volumes/{catalog}/{schema}/{name}. Populated during initialize; not user-configurable. VolumePath string `json:"volume_path,omitempty" bundle:"readonly"` // List of grants to apply on this volume. - Grants []catalog.PrivilegeAssignment `json:"grants,omitempty"` + Grants []grants.PrivilegeAssignment `json:"grants,omitempty"` } -func (v *Volume) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, v) -} - -func (v Volume) MarshalJSON() ([]byte, error) { - return marshal.Marshal(v) -} - -func (v *Volume) Exists(ctx context.Context, w *databricks.WorkspaceClient, fullyQualifiedName string) (bool, error) { - _, err := w.Volumes.Read(ctx, catalog.ReadVolumeRequest{ - Name: fullyQualifiedName, +func (v *Volume) Exists(ctx context.Context, w *sdkclients.Clients, fullyQualifiedName string) (bool, error) { + _, err := w.Volumes.GetVolume(ctx, sdkvolumes.GetVolumeRequest{ + FullNameArg: new(fullyQualifiedName), }) if err != nil { log.Debugf(ctx, "volume with fully qualified name %s does not exist: %v", fullyQualifiedName, err) - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return false, nil } @@ -68,7 +61,7 @@ func (v *Volume) InitializeURL(baseURL url.URL) { } func (v *Volume) GetName() string { - return v.Name + return utils.Deref(v.Name) } // ComputeVolumePath returns the Unity Catalog volume path /Volumes/{catalog}/{schema}/{name}. @@ -77,5 +70,5 @@ func (v *Volume) GetName() string { // or deploy. Missing required fields and malformed references are reported by validation and the // plan/deploy backends, so this function does not guard against them. func (v *Volume) ComputeVolumePath() string { - return fmt.Sprintf("/Volumes/%s/%s/%s", v.CatalogName, v.SchemaName, v.Name) + return fmt.Sprintf("/Volumes/%s/%s/%s", utils.Deref(v.CatalogName), utils.Deref(v.SchemaName), utils.Deref(v.Name)) } diff --git a/bundle/config/resources/volume_test.go b/bundle/config/resources/volume_test.go index 065d8cb287d..c49e0e7c43c 100644 --- a/bundle/config/resources/volume_test.go +++ b/bundle/config/resources/volume_test.go @@ -3,26 +3,23 @@ package resources import ( "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestComputeVolumePath(t *testing.T) { v := &Volume{ - CatalogName: "main", - SchemaName: "myschema", - Name: "myvol", + CatalogName: new("main"), + SchemaName: new("myschema"), + Name: new("myvol"), } require.Equal(t, "/Volumes/main/myschema/myvol", v.ComputeVolumePath()) } func TestComputeVolumePath_PureReferenceEmbedded(t *testing.T) { v := &Volume{ - CatalogName: "main", - SchemaName: "${resources.schemas.my.name}", - Name: "myvol", + CatalogName: new("main"), + SchemaName: new("${resources.schemas.my.name}"), + Name: new("myvol"), } // A pure reference is embedded verbatim so it can be resolved later (plan/deploy). require.Equal(t, "/Volumes/main/${resources.schemas.my.name}/myvol", v.ComputeVolumePath()) @@ -31,13 +28,12 @@ func TestComputeVolumePath_PureReferenceEmbedded(t *testing.T) { func TestVolumeNotFound(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - m.GetMockVolumesAPI().On("Read", mock.Anything, mock.Anything).Return(nil, &apierr.APIError{ - StatusCode: 404, + w := newTestClients(t, map[string]any{ + "GET /api/2.1/unity-catalog/volumes/non-existent-volume": notFound(), }) s := &Volume{} - exists, err := s.Exists(ctx, m.WorkspaceClient, "non-existent-volume") + exists, err := s.Exists(ctx, w, "non-existent-volume") require.Falsef(t, exists, "Exists should return false when getting a 404 response from Workspace") require.NoErrorf(t, err, "Exists should not return an error when getting a 404 response from Workspace") diff --git a/bundle/config/resources_test.go b/bundle/config/resources_test.go index c666c8964c0..5cd890a1cbf 100644 --- a/bundle/config/resources_test.go +++ b/bundle/config/resources_test.go @@ -7,27 +7,30 @@ import ( "strings" "testing" - "github.com/databricks/databricks-sdk-go/service/database" + "github.com/databricks/cli/libs/qualitymonitors" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/sdktypes/experiments/v1" + "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1" + "github.com/databricks/cli/libs/sdktypes/warehouses/v1" - "github.com/databricks/databricks-sdk-go/service/sql" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdktypes/database/v1" - "github.com/databricks/databricks-sdk-go/service/serving" + "github.com/databricks/cli/libs/sdktypes/modelserving/v1" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + ucsecrets "github.com/databricks/cli/libs/sdktypes/uc/secrets/v1" + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/structs/structtag" "github.com/databricks/cli/libs/structs/structwalk" + "github.com/databricks/cli/libs/testserver" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/apps" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/postgres" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" - "github.com/stretchr/testify/mock" + sdkconfig "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/require" "github.com/stretchr/testify/assert" @@ -170,37 +173,37 @@ func TestResourcesBindSupport(t *testing.T) { }, JobRuns: map[string]*resources.JobRun{ "my_job_run": { - RunNow: jobs.RunNow{}, + RunNowRequest: jobs.RunNowRequest{}, }, }, Pipelines: map[string]*resources.Pipeline{ "my_pipeline": { - CreatePipeline: pipelines.CreatePipeline{}, + CreatePipelineRequest: pipelines.CreatePipelineRequest{}, }, }, Experiments: map[string]*resources.MlflowExperiment{ "my_experiment": { - CreateExperiment: ml.CreateExperiment{}, + CreateExperimentRequest: experiments.CreateExperimentRequest{}, }, }, RegisteredModels: map[string]*resources.RegisteredModel{ "my_registered_model": { - CreateRegisteredModelRequest: catalog.CreateRegisteredModelRequest{}, + CreateRegisteredModelRequest: registeredmodels.CreateRegisteredModelRequest{}, }, }, Catalogs: map[string]*resources.Catalog{ "my_catalog": { - CreateCatalog: catalog.CreateCatalog{}, + CreateCatalog: resources.CreateCatalog{}, }, }, ExternalLocations: map[string]*resources.ExternalLocation{ "my_external_location": { - CreateExternalLocation: catalog.CreateExternalLocation{}, + CreateExternalLocation: resources.CreateExternalLocation{}, }, }, Schemas: map[string]*resources.Schema{ "my_schema": { - CreateSchema: catalog.CreateSchema{}, + CreateSchema: resources.CreateSchema{}, }, }, Clusters: map[string]*resources.Cluster{ @@ -220,7 +223,7 @@ func TestResourcesBindSupport(t *testing.T) { }, Volumes: map[string]*resources.Volume{ "my_volume": { - CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{}, + CreateVolumeRequestContent: resources.CreateVolumeRequestContent{}, }, }, Apps: map[string]*resources.App{ @@ -230,17 +233,17 @@ func TestResourcesBindSupport(t *testing.T) { }, Alerts: map[string]*resources.Alert{ "my_alert": { - AlertV2: sql.AlertV2{}, + Alert: alerts.Alert{}, }, }, QualityMonitors: map[string]*resources.QualityMonitor{ "my_quality_monitor": { - CreateMonitor: catalog.CreateMonitor{}, + CreateMonitor: qualitymonitors.CreateMonitor{}, }, }, ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{ "my_model_serving_endpoint": { - CreateServingEndpoint: serving.CreateServingEndpoint{}, + CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{}, }, }, ModelServices: map[string]*resources.ModelService{ @@ -265,16 +268,16 @@ func TestResourcesBindSupport(t *testing.T) { }, Secrets: map[string]*resources.Secret{ "my_secret": { - Secret: catalog.Secret{ - CatalogName: "main", - SchemaName: "default", - Name: "my_secret", + Secret: ucsecrets.Secret{ + CatalogName: new("main"), + SchemaName: new("default"), + Name: new("my_secret"), }, }, }, SqlWarehouses: map[string]*resources.SqlWarehouse{ "my_sql_warehouse": { - CreateWarehouseRequest: sql.CreateWarehouseRequest{}, + CreateWarehouseRequest: warehouses.CreateWarehouseRequest{}, }, }, DatabaseInstances: map[string]*resources.DatabaseInstance{ @@ -297,7 +300,7 @@ func TestResourcesBindSupport(t *testing.T) { PostgresProjectConfig: resources.PostgresProjectConfig{ ProjectId: "my-postgres-project", ProjectSpec: postgres.ProjectSpec{ - DisplayName: "my_postgres_project", + DisplayName: new("my_postgres_project"), }, }, }, @@ -316,7 +319,7 @@ func TestResourcesBindSupport(t *testing.T) { EndpointId: "my-postgres-endpoint", Parent: "projects/my-postgres-project/branches/my-postgres-branch", EndpointSpec: postgres.EndpointSpec{ - EndpointType: postgres.EndpointTypeEndpointTypeReadWrite, + EndpointType: postgres.EndpointType_EndpointTypeReadWrite, }, }, }, @@ -341,8 +344,8 @@ func TestResourcesBindSupport(t *testing.T) { PostgresRoleConfig: resources.PostgresRoleConfig{ RoleId: "my-postgres-role", Parent: "projects/my-postgres-project/branches/my-postgres-branch", - RoleRoleSpec: postgres.RoleRoleSpec{ - PostgresRole: "my_postgres_role", + Role_RoleSpec: postgres.Role_RoleSpec{ + PostgresRole: new("my_postgres_role"), }, }, }, @@ -363,19 +366,19 @@ func TestResourcesBindSupport(t *testing.T) { }, VectorSearchEndpoints: map[string]*resources.VectorSearchEndpoint{ "my_vector_search_endpoint": { - CreateEndpoint: vectorsearch.CreateEndpoint{ - Name: "my_vector_search_endpoint", - EndpointType: vectorsearch.EndpointTypeStandard, + CreateEndpointRequest: vectorsearch.CreateEndpointRequest{ + Name: new("my_vector_search_endpoint"), + EndpointType: vectorsearch.EndpointType_Standard, }, }, }, VectorSearchIndexes: map[string]*resources.VectorSearchIndex{ "my_vector_search_index": { CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{ - Name: "my_vector_search_index", - EndpointName: "my_vector_search_endpoint", - PrimaryKey: "id", - IndexType: vectorsearch.VectorIndexTypeDeltaSync, + Name: new("my_vector_search_index"), + EndpointName: new("my_vector_search_endpoint"), + PrimaryKey: new("id"), + IndexType: vectorsearch.VectorIndexType("DELTA_SYNC"), }, }, }, @@ -386,47 +389,22 @@ func TestResourcesBindSupport(t *testing.T) { } ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - m.GetMockJobsAPI().EXPECT().Get(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockJobsAPI().EXPECT().GetRun(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockPipelinesAPI().EXPECT().Get(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockExperimentsAPI().EXPECT().GetExperiment(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockRegisteredModelsAPI().EXPECT().Get(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockCatalogsAPI().EXPECT().GetByName(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockExternalLocationsAPI().EXPECT().GetByName(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockSchemasAPI().EXPECT().GetByFullName(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockClustersAPI().EXPECT().GetByClusterId(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockInstancePoolsAPI().EXPECT().GetByInstancePoolId(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockClusterPoliciesAPI().EXPECT().GetByPolicyId(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockLakeviewAPI().EXPECT().Get(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockGenieAPI().EXPECT().GetSpace(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockVolumesAPI().EXPECT().Read(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockAppsAPI().EXPECT().GetByName(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockAlertsV2API().EXPECT().GetAlertById(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockQualityMonitorsAPI().EXPECT().Get(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockServingEndpointsAPI().EXPECT().Get(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockAiGatewayAPI().EXPECT().GetModelService(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockAiGatewayAPI().EXPECT().GetMcpService(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockAiGatewayAPI().EXPECT().GetModelProviderService(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockSecretsAPI().EXPECT().ListScopesAll(mock.Anything).Return([]workspace.SecretScope{ - {Name: "0"}, - }, nil) - m.GetMockWarehousesAPI().EXPECT().GetById(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockDatabaseAPI().EXPECT().GetDatabaseInstance(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockDatabaseAPI().EXPECT().GetDatabaseCatalog(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockDatabaseAPI().EXPECT().GetSyncedDatabaseTable(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockPostgresAPI().EXPECT().GetProject(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockPostgresAPI().EXPECT().GetBranch(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockPostgresAPI().EXPECT().GetEndpoint(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockPostgresAPI().EXPECT().GetCatalog(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockPostgresAPI().EXPECT().GetDatabase(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockPostgresAPI().EXPECT().GetRole(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockPostgresAPI().EXPECT().GetSyncedTable(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockPostgresAPI().EXPECT().GetSnapshotSchedule(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockPostgresAPI().EXPECT().GetRole(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockVectorSearchEndpointsAPI().EXPECT().GetEndpoint(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockVectorSearchIndexesAPI().EXPECT().GetIndexByIndexName(mock.Anything, mock.Anything).Return(nil, nil) - m.GetMockSecretsUcAPI().EXPECT().GetSecret(mock.Anything, mock.Anything).Return(&catalog.Secret{FullName: "0"}, nil) + // Every Exists implementation issues a GET; answer each with an empty + // object so all resources are reported as existing. Secret scopes are + // looked up by listing, so that listing must contain the scope. + server := testserver.New(t) + server.Handle("GET", "/api/2.0/secrets/scopes/list", func(testserver.Request) any { + return map[string]any{"scopes": []map[string]any{{"name": "0"}}} + }) + server.Handle("GET", "/{path...}", func(testserver.Request) any { + return map[string]any{} + }) + w, err := sdkclients.New(ctx, &sdkconfig.Config{ + Host: server.URL, + Token: "testtoken", + Loaders: []sdkconfig.Loader{sdkconfig.ConfigAttributes}, + }) + require.NoError(t, err) allResources := supportedResources.AllResources() for _, group := range allResources { @@ -439,7 +417,7 @@ func TestResourcesBindSupport(t *testing.T) { assert.NoError(t, err) // bind operation requires Exists to return true - exists, err := r.Exists(ctx, m.WorkspaceClient, "0") + exists, err := r.Exists(ctx, w, "0") assert.NoError(t, err) assert.True(t, exists) } diff --git a/bundle/config/resources_types_test.go b/bundle/config/resources_types_test.go index 7a698604612..f65744a8387 100644 --- a/bundle/config/resources_types_test.go +++ b/bundle/config/resources_types_test.go @@ -1,7 +1,6 @@ package config import ( - "encoding/json" "fmt" "reflect" "slices" @@ -9,11 +8,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/cli/libs/dyn" - "github.com/databricks/cli/libs/dyn/convert" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/structs/structtag" "github.com/databricks/cli/libs/structs/structwalk" @@ -31,88 +27,6 @@ func TestResourcesTypesMap(t *testing.T) { assert.Equal(t, reflect.TypeFor[[]resources.JobPermission](), typ, "resources type for 'jobs.permissions' mismatch") } -// TestResourceTypesZeroValueFieldsSerialize guards against the ForceSendFields -// routing bug fixed in libs/dyn/convert: a field declared in a struct embedded -// more than one level deep (e.g. PostgresProject -> PostgresProjectConfig -> -// ProjectSpec) had its zero value recorded in the wrong struct's ForceSendFields, -// which the SDK marshaler rejects with "field X cannot be found in struct Y". -// The direct engine hits this path when it serializes planned state to JSON. -// -// For every registered resource type it sets every omitempty scalar field (at any -// depth) to its zero value, converts via ToTyped, and marshals - the same round -// trip the direct engine performs. Any newly added resource whose wrapper embeds -// an SDK spec is covered automatically. -func TestResourceTypesZeroValueFieldsSerialize(t *testing.T) { - names := make([]string, 0, len(ResourcesTypes)) - for name := range ResourcesTypes { - names = append(names, name) - } - slices.Sort(names) - - for _, name := range names { - t.Run(name, func(t *testing.T) { - typ := ResourcesTypes[name] - zeros := zeroValueScalars(typ, 0, map[reflect.Type]bool{}) - if zeros.Kind() != dyn.KindMap { - return - } - - ptr := reflect.New(typ) - require.NoError(t, convert.ToTyped(ptr.Interface(), zeros)) - - _, err := json.Marshal(ptr.Interface()) - require.NoError(t, err) - }) - } -} - -// zeroValueScalars builds a [dyn.Value] map that sets every omitempty scalar field -// reachable through embedded anonymous structs to its zero value. Those are exactly -// the fields the convert layer records in ForceSendFields, so they exercise the -// routing logic. depth and seen bound recursion against deep or recursive types. -func zeroValueScalars(t reflect.Type, depth int, seen map[reflect.Type]bool) dyn.Value { - for t.Kind() == reflect.Pointer { - t = t.Elem() - } - if t.Kind() != reflect.Struct || depth > 6 || seen[t] { - return dyn.NilValue - } - seen[t] = true - defer delete(seen, t) - - m := dyn.NewMapping() - for f := range t.Fields() { - if f.Anonymous { - if sub := zeroValueScalars(f.Type, depth+1, seen); sub.Kind() == dyn.KindMap { - for _, p := range sub.MustMap().Pairs() { - m.SetLoc(p.Key.MustString(), nil, p.Value) - } - } - continue - } - - tag := structtag.JSONTag(f.Tag.Get("json")) - name := tag.Name() - if name == "" || name == "-" || !f.IsExported() || !tag.OmitEmpty() { - continue - } - - switch f.Type.Kind() { - case reflect.Bool: - m.SetLoc(name, nil, dyn.V(false)) - case reflect.String: - m.SetLoc(name, nil, dyn.V("")) - case reflect.Int, reflect.Int32, reflect.Int64: - m.SetLoc(name, nil, dyn.V(int64(0))) - case reflect.Float32, reflect.Float64: - m.SetLoc(name, nil, dyn.V(float64(0))) - default: - // Only basic types are eligible for ForceSendFields; skip the rest. - } - } - return dyn.V(m) -} - // TestNoSameDepthJSONShadows uses structwalk.WalkType — the dumb walker that // visits every field including duplicates — to detect unresolved same-depth json // name collisions. A collision is any json name WalkType visits more than once @@ -142,7 +56,7 @@ func TestNoSameDepthJSONShadows(t *testing.T) { // same-depth collision at deeper embedding levels, so those are OK. depth0 := map[string]bool{} for sf := range et.Fields() { - if sf.Anonymous || sf.PkgPath != "" || sf.Name == "ForceSendFields" { + if sf.Anonymous || sf.PkgPath != "" { continue } name := structtag.JSONTag(sf.Tag.Get("json")).Name() diff --git a/bundle/config/root.go b/bundle/config/root.go index 3aa6fdd8b87..397607d71a0 100644 --- a/bundle/config/root.go +++ b/bundle/config/root.go @@ -18,8 +18,8 @@ import ( "github.com/databricks/cli/libs/dyn/merge" "github.com/databricks/cli/libs/dyn/yamlloader" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/jobs" ) type Script struct { diff --git a/bundle/config/target.go b/bundle/config/target.go index fae9c940b3f..96e0d4a670f 100644 --- a/bundle/config/target.go +++ b/bundle/config/target.go @@ -3,7 +3,7 @@ package config import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/config/variable" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" ) type Mode string diff --git a/bundle/config/validate/files_to_sync_test.go b/bundle/config/validate/files_to_sync_test.go index 71a1dfaf5a7..a4ffa2ae9a6 100644 --- a/bundle/config/validate/files_to_sync_test.go +++ b/bundle/config/validate/files_to_sync_test.go @@ -8,13 +8,12 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/diag" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/libs/testserver" "github.com/databricks/cli/libs/vfs" sdkconfig "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/workspace" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) @@ -51,7 +50,7 @@ func setupBundleForFilesToSyncTest(t *testing.T) *bundle.Bundle { Workspace: config.Workspace{ FilePath: "/this/doesnt/matter", CurrentUser: &config.User{ - User: &iam.User{}, + User: &scim.User{}, }, }, Sync: config.Sync{ @@ -61,18 +60,21 @@ func setupBundleForFilesToSyncTest(t *testing.T) *bundle.Bundle { }, } - m := mocks.NewMockWorkspaceClient(t) - m.WorkspaceClient.Config = &sdkconfig.Config{ - Host: "https://foo.test", - } - // The initialization logic in [sync.New] performs a check on the destination path. // Removing this check at initialization time is tbd... - m.GetMockWorkspaceAPI().EXPECT().GetStatusByPath(mock.Anything, "/this/doesnt/matter").Return(&workspace.ObjectInfo{ - ObjectType: workspace.ObjectTypeDirectory, - }, nil) - - b.SetWorkpaceClient(m.WorkspaceClient) + server := testserver.New(t) + server.Handle("GET", "/api/2.0/workspace/get-status", func(req testserver.Request) any { + assert.Equal(t, "/this/doesnt/matter", req.URL.Query().Get("path")) + return map[string]any{"object_type": "DIRECTORY"} + }) + w, err := sdkclients.New(t.Context(), &sdkconfig.Config{ + Host: server.URL, + Token: "testtoken", + Loaders: []sdkconfig.Loader{sdkconfig.ConfigAttributes}, + }) + require.NoError(t, err) + + b.SetWorkpaceClient(w) return b } diff --git a/bundle/config/validate/folder_permissions_test.go b/bundle/config/validate/folder_permissions_test.go index 0cc97907c62..ddb703d2ca0 100644 --- a/bundle/config/validate/folder_permissions_test.go +++ b/bundle/config/validate/folder_permissions_test.go @@ -8,13 +8,47 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/permissions" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/workspace" - "github.com/stretchr/testify/mock" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/testserver" + sdkconfig "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/require" ) +// folderPermissionsClients returns clients for a workspace in which the paths +// in existing are directories with the given object IDs and every other path +// does not exist. Directory 1234 has the given access control list. +func folderPermissionsClients(t *testing.T, existing map[string]int64, acl []map[string]any) *sdkclients.Clients { + server := testserver.New(t) + server.Handle("GET", "/api/2.0/workspace/get-status", func(req testserver.Request) any { + path := req.URL.Query().Get("path") + id, ok := existing[path] + if !ok { + return testserver.Response{ + StatusCode: 404, + Body: map[string]string{"error_code": "RESOURCE_DOES_NOT_EXIST", "message": path + " does not exist"}, + } + } + return map[string]any{"object_id": id, "object_type": "DIRECTORY", "path": path} + }) + server.Handle("GET", "/api/2.0/permissions/directories/1234", func(testserver.Request) any { + return map[string]any{"object_id": "1234", "access_control_list": acl} + }) + w, err := sdkclients.New(t.Context(), &sdkconfig.Config{ + Host: server.URL, + Token: "testtoken", + Loaders: []sdkconfig.Loader{sdkconfig.ConfigAttributes}, + }) + require.NoError(t, err) + return w +} + +func manage(userName string) map[string]any { + return map[string]any{ + "user_name": userName, + "all_permissions": []map[string]any{{"permission_level": "CAN_MANAGE"}}, + } +} + func TestFolderPermissionsInheritedWhenRootPathDoesNotExist(t *testing.T) { b := &bundle.Bundle{ Config: config.Root{ @@ -30,44 +64,10 @@ func TestFolderPermissionsInheritedWhenRootPathDoesNotExist(t *testing.T) { }, }, } - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockWorkspaceAPI() - api.EXPECT().GetStatusByPath(mock.Anything, "/Workspace/Users/otherfoo@bar.test/artifacts").Return(nil, &apierr.APIError{ - StatusCode: 404, - ErrorCode: "RESOURCE_DOES_NOT_EXIST", - }) - api.EXPECT().GetStatusByPath(mock.Anything, "/Workspace/Users/otherfoo@bar.test").Return(nil, &apierr.APIError{ - StatusCode: 404, - ErrorCode: "RESOURCE_DOES_NOT_EXIST", - }) - api.EXPECT().GetStatusByPath(mock.Anything, "/Workspace/Users/foo@bar.test").Return(nil, &apierr.APIError{ - StatusCode: 404, - ErrorCode: "RESOURCE_DOES_NOT_EXIST", - }) - api.EXPECT().GetStatusByPath(mock.Anything, "/Workspace/Users").Return(nil, &apierr.APIError{ - StatusCode: 404, - ErrorCode: "RESOURCE_DOES_NOT_EXIST", - }) - api.EXPECT().GetStatusByPath(mock.Anything, "/Workspace").Return(&workspace.ObjectInfo{ - ObjectId: 1234, - }, nil) - api.EXPECT().GetPermissions(mock.Anything, workspace.GetWorkspaceObjectPermissionsRequest{ - WorkspaceObjectId: "1234", - WorkspaceObjectType: "directories", - }).Return(&workspace.WorkspaceObjectPermissions{ - ObjectId: "1234", - AccessControlList: []workspace.WorkspaceObjectAccessControlResponse{ - { - UserName: "foo@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ - {PermissionLevel: "CAN_MANAGE"}, - }, - }, - }, - }, nil) - - b.SetWorkpaceClient(m.WorkspaceClient) + b.SetWorkpaceClient(folderPermissionsClients(t, map[string]int64{"/Workspace": 1234}, []map[string]any{ + manage("foo@bar.test"), + })) diags := ValidateFolderPermissions().Apply(t.Context(), b) require.Empty(t, diags) } @@ -87,34 +87,11 @@ func TestValidateFolderPermissionsFailsOnMissingBundlePermission(t *testing.T) { }, }, } - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockWorkspaceAPI() - api.EXPECT().GetStatusByPath(mock.Anything, "/Workspace/Users/foo@bar.test").Return(&workspace.ObjectInfo{ - ObjectId: 1234, - }, nil) - - api.EXPECT().GetPermissions(mock.Anything, workspace.GetWorkspaceObjectPermissionsRequest{ - WorkspaceObjectId: "1234", - WorkspaceObjectType: "directories", - }).Return(&workspace.WorkspaceObjectPermissions{ - ObjectId: "1234", - AccessControlList: []workspace.WorkspaceObjectAccessControlResponse{ - { - UserName: "foo@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ - {PermissionLevel: "CAN_MANAGE"}, - }, - }, - { - UserName: "foo2@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ - {PermissionLevel: "CAN_MANAGE"}, - }, - }, - }, - }, nil) - b.SetWorkpaceClient(m.WorkspaceClient) + b.SetWorkpaceClient(folderPermissionsClients(t, map[string]int64{"/Workspace/Users/foo@bar.test": 1234}, []map[string]any{ + manage("foo@bar.test"), + manage("foo2@bar.test"), + })) diags := ValidateFolderPermissions().Apply(t.Context(), b) require.Len(t, diags, 1) require.Equal(t, "workspace folder has permissions not configured in bundle", diags[0].Summary) @@ -141,28 +118,10 @@ func TestValidateFolderPermissionsFailsOnPermissionMismatch(t *testing.T) { }, }, } - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockWorkspaceAPI() - api.EXPECT().GetStatusByPath(mock.Anything, "/Workspace/Users/foo@bar.test").Return(&workspace.ObjectInfo{ - ObjectId: 1234, - }, nil) - - api.EXPECT().GetPermissions(mock.Anything, workspace.GetWorkspaceObjectPermissionsRequest{ - WorkspaceObjectId: "1234", - WorkspaceObjectType: "directories", - }).Return(&workspace.WorkspaceObjectPermissions{ - ObjectId: "1234", - AccessControlList: []workspace.WorkspaceObjectAccessControlResponse{ - { - UserName: "foo2@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ - {PermissionLevel: "CAN_MANAGE"}, - }, - }, - }, - }, nil) - b.SetWorkpaceClient(m.WorkspaceClient) + b.SetWorkpaceClient(folderPermissionsClients(t, map[string]int64{"/Workspace/Users/foo@bar.test": 1234}, []map[string]any{ + manage("foo2@bar.test"), + })) diags := ValidateFolderPermissions().Apply(t.Context(), b) require.Len(t, diags, 1) require.Equal(t, "workspace folder has permissions not configured in bundle", diags[0].Summary) @@ -184,18 +143,8 @@ func TestValidateFolderPermissionsFailsOnNoRootFolder(t *testing.T) { }, }, } - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockWorkspaceAPI() - api.EXPECT().GetStatusByPath(mock.Anything, "/NotExisting").Return(nil, &apierr.APIError{ - StatusCode: 404, - ErrorCode: "RESOURCE_DOES_NOT_EXIST", - }) - api.EXPECT().GetStatusByPath(mock.Anything, "/").Return(nil, &apierr.APIError{ - StatusCode: 404, - ErrorCode: "RESOURCE_DOES_NOT_EXIST", - }) - b.SetWorkpaceClient(m.WorkspaceClient) + b.SetWorkpaceClient(folderPermissionsClients(t, nil, nil)) diags := ValidateFolderPermissions().Apply(t.Context(), b) require.Len(t, diags, 1) require.Equal(t, "folder / and its parent folders do not exist", diags[0].Summary) diff --git a/bundle/config/validate/job_cluster_key_defined.go b/bundle/config/validate/job_cluster_key_defined.go index eb9bea4df70..3e038267e43 100644 --- a/bundle/config/validate/job_cluster_key_defined.go +++ b/bundle/config/validate/job_cluster_key_defined.go @@ -4,6 +4,8 @@ import ( "context" "fmt" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/structs/structpath" @@ -25,18 +27,18 @@ func (v *jobClusterKeyDefined) Apply(ctx context.Context, b *bundle.Bundle) diag for k, job := range b.Config.Resources.Jobs { jobClusterKeys := make(map[string]bool) for _, cluster := range job.JobClusters { - if cluster.JobClusterKey != "" { - jobClusterKeys[cluster.JobClusterKey] = true + if utils.Deref(cluster.JobClusterKey) != "" { + jobClusterKeys[utils.Deref(cluster.JobClusterKey)] = true } } for index, task := range job.Tasks { - diags = diags.Extend(checkJobClusterKey(b, jobClusterKeys, task.JobClusterKey, + diags = diags.Extend(checkJobClusterKey(b, jobClusterKeys, utils.Deref(task.JobClusterKey), structpath.NewPath(nil, "resources", "jobs", k, "tasks", index, "job_cluster_key"))) // The Jobs API rejects nested for_each_task, so one level is sufficient. if task.ForEachTask != nil { - diags = diags.Extend(checkJobClusterKey(b, jobClusterKeys, task.ForEachTask.Task.JobClusterKey, + diags = diags.Extend(checkJobClusterKey(b, jobClusterKeys, utils.Deref(task.ForEachTask.Task.JobClusterKey), structpath.NewPath(nil, "resources", "jobs", k, "tasks", index, "for_each_task", "task", "job_cluster_key"))) } } diff --git a/bundle/config/validate/job_cluster_key_defined_test.go b/bundle/config/validate/job_cluster_key_defined_test.go index 248bc31a60e..9edbf921c7d 100644 --- a/bundle/config/validate/job_cluster_key_defined_test.go +++ b/bundle/config/validate/job_cluster_key_defined_test.go @@ -7,7 +7,7 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/require" ) @@ -18,12 +18,12 @@ func TestJobClusterKeyDefined(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { JobSettings: jobs.JobSettings{ - Name: "job1", + Name: new("job1"), JobClusters: []jobs.JobCluster{ - {JobClusterKey: "do-not-exist"}, + {JobClusterKey: new("do-not-exist")}, }, - Tasks: []jobs.Task{ - {JobClusterKey: "do-not-exist"}, + Tasks: []jobs.TaskSettings{ + {JobClusterKey: new("do-not-exist")}, }, }, }, @@ -44,9 +44,9 @@ func TestJobClusterKeyNotDefined(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { JobSettings: jobs.JobSettings{ - Name: "job1", - Tasks: []jobs.Task{ - {JobClusterKey: "do-not-exist"}, + Name: new("job1"), + Tasks: []jobs.TaskSettings{ + {JobClusterKey: new("do-not-exist")}, }, }, }, @@ -69,14 +69,14 @@ func TestJobClusterKeyDefinedInForEachTask(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { JobSettings: jobs.JobSettings{ - Name: "job1", + Name: new("job1"), JobClusters: []jobs.JobCluster{ - {JobClusterKey: "do-not-exist"}, + {JobClusterKey: new("do-not-exist")}, }, - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { ForEachTask: &jobs.ForEachTask{ - Task: jobs.Task{JobClusterKey: "do-not-exist"}, + Task: &jobs.TaskSettings{JobClusterKey: new("do-not-exist")}, }, }, }, @@ -99,11 +99,11 @@ func TestJobClusterKeyNotDefinedInForEachTask(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { JobSettings: jobs.JobSettings{ - Name: "job1", - Tasks: []jobs.Task{ + Name: new("job1"), + Tasks: []jobs.TaskSettings{ { ForEachTask: &jobs.ForEachTask{ - Task: jobs.Task{JobClusterKey: "do-not-exist"}, + Task: &jobs.TaskSettings{JobClusterKey: new("do-not-exist")}, }, }, }, @@ -130,17 +130,17 @@ func TestJobClusterKeyDefinedInDifferentJob(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { JobSettings: jobs.JobSettings{ - Name: "job1", - Tasks: []jobs.Task{ - {JobClusterKey: "do-not-exist"}, + Name: new("job1"), + Tasks: []jobs.TaskSettings{ + {JobClusterKey: new("do-not-exist")}, }, }, }, "job2": { JobSettings: jobs.JobSettings{ - Name: "job2", + Name: new("job2"), JobClusters: []jobs.JobCluster{ - {JobClusterKey: "do-not-exist"}, + {JobClusterKey: new("do-not-exist")}, }, }, }, diff --git a/bundle/config/validate/job_task_cluster_spec.go b/bundle/config/validate/job_task_cluster_spec.go index e387d83f6fb..e3245eb213f 100644 --- a/bundle/config/validate/job_task_cluster_spec.go +++ b/bundle/config/validate/job_task_cluster_spec.go @@ -5,11 +5,13 @@ import ( "fmt" "strings" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/jobs" ) // JobTaskClusterSpec validates that job tasks have cluster spec defined @@ -42,25 +44,25 @@ func (v *jobTaskClusterSpec) Apply(ctx context.Context, b *bundle.Bundle) diag.D return diags } -func validateJobTask(b *bundle.Bundle, task jobs.Task, taskPath dyn.Path) diag.Diagnostics { +func validateJobTask(b *bundle.Bundle, task jobs.TaskSettings, taskPath dyn.Path) diag.Diagnostics { diags := diag.Diagnostics{} var specified []string var unspecified []string - if task.JobClusterKey != "" { + if utils.Deref(task.JobClusterKey) != "" { specified = append(specified, "job_cluster_key") } else { unspecified = append(unspecified, "job_cluster_key") } - if task.EnvironmentKey != "" { + if utils.Deref(task.EnvironmentKey) != "" { specified = append(specified, "environment_key") } else { unspecified = append(unspecified, "environment_key") } - if task.ExistingClusterId != "" { + if utils.Deref(task.ExistingClusterId) != "" { specified = append(specified, "existing_cluster_id") } else { unspecified = append(unspecified, "existing_cluster_id") @@ -75,7 +77,9 @@ func validateJobTask(b *bundle.Bundle, task jobs.Task, taskPath dyn.Path) diag.D if task.ForEachTask != nil { forEachTaskPath := taskPath.Append(dyn.Key("for_each_task"), dyn.Key("task")) - diags = diags.Extend(validateJobTask(b, task.ForEachTask.Task, forEachTaskPath)) + if task.ForEachTask.Task != nil { + diags = diags.Extend(validateJobTask(b, *task.ForEachTask.Task, forEachTaskPath)) + } } if isComputeTask(task) && len(specified) == 0 { @@ -85,7 +89,7 @@ func validateJobTask(b *bundle.Bundle, task jobs.Task, taskPath dyn.Path) diag.D // path might be not very helpful, adding user-specified task key clarifies the context detail := fmt.Sprintf( "Task %q requires a cluster or an environment to run.\nSpecify one of the following fields: %s.", - task.TaskKey, + utils.Deref(task.TaskKey), strings.Join(unspecified, ", "), ) @@ -104,10 +108,10 @@ func validateJobTask(b *bundle.Bundle, task jobs.Task, taskPath dyn.Path) diag.D } // isComputeTask returns true if the task runs on a cluster or serverless GC -func isComputeTask(task jobs.Task) bool { +func isComputeTask(task jobs.TaskSettings) bool { if task.NotebookTask != nil { // if warehouse_id is set, it's SQL notebook that doesn't need cluster or serverless GC - if task.NotebookTask.WarehouseId != "" { + if utils.Deref(task.NotebookTask.WarehouseId) != "" { return false } else { // task settings don't require specifying a cluster/serverless GC, but task itself can run on one diff --git a/bundle/config/validate/job_task_cluster_spec_test.go b/bundle/config/validate/job_task_cluster_spec_test.go index 6f7d31ee944..ef28cb75bca 100644 --- a/bundle/config/validate/job_task_cluster_spec_test.go +++ b/bundle/config/validate/job_task_cluster_spec_test.go @@ -6,8 +6,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" ) @@ -16,7 +15,7 @@ func TestJobTaskClusterSpec(t *testing.T) { type testCase struct { name string - task jobs.Task + task jobs.TaskSettings errorPath string errorDetail string errorSummary string @@ -25,112 +24,112 @@ func TestJobTaskClusterSpec(t *testing.T) { testCases := []testCase{ { name: "valid notebook task", - task: jobs.Task{ + task: jobs.TaskSettings{ // while a cluster is needed, it will use notebook environment to create one NotebookTask: &jobs.NotebookTask{}, }, }, { name: "valid notebook task (job_cluster_key)", - task: jobs.Task{ - JobClusterKey: "cluster1", + task: jobs.TaskSettings{ + JobClusterKey: new("cluster1"), NotebookTask: &jobs.NotebookTask{}, }, }, { name: "valid notebook task (new_cluster)", - task: jobs.Task{ - NewCluster: &compute.ClusterSpec{}, + task: jobs.TaskSettings{ + NewCluster: &jobs.ClusterSpec_NewCluster{}, NotebookTask: &jobs.NotebookTask{}, }, }, { name: "valid notebook task (existing_cluster_id)", - task: jobs.Task{ - ExistingClusterId: "cluster1", + task: jobs.TaskSettings{ + ExistingClusterId: new("cluster1"), NotebookTask: &jobs.NotebookTask{}, }, }, { name: "valid SQL notebook task", - task: jobs.Task{ + task: jobs.TaskSettings{ NotebookTask: &jobs.NotebookTask{ - WarehouseId: "warehouse1", + WarehouseId: new("warehouse1"), }, }, }, { name: "valid python wheel task", - task: jobs.Task{ - JobClusterKey: "cluster1", + task: jobs.TaskSettings{ + JobClusterKey: new("cluster1"), PythonWheelTask: &jobs.PythonWheelTask{}, }, }, { name: "valid python wheel task (environment_key)", - task: jobs.Task{ - EnvironmentKey: "environment1", + task: jobs.TaskSettings{ + EnvironmentKey: new("environment1"), PythonWheelTask: &jobs.PythonWheelTask{}, }, }, { name: "valid dbt task", - task: jobs.Task{ - JobClusterKey: "cluster1", + task: jobs.TaskSettings{ + JobClusterKey: new("cluster1"), DbtTask: &jobs.DbtTask{}, }, }, { name: "valid spark jar task", - task: jobs.Task{ - JobClusterKey: "cluster1", + task: jobs.TaskSettings{ + JobClusterKey: new("cluster1"), SparkJarTask: &jobs.SparkJarTask{}, }, }, { name: "valid spark submit", - task: jobs.Task{ - NewCluster: &compute.ClusterSpec{}, + task: jobs.TaskSettings{ + NewCluster: &jobs.ClusterSpec_NewCluster{}, SparkSubmitTask: &jobs.SparkSubmitTask{}, }, }, { name: "valid spark python task", - task: jobs.Task{ - JobClusterKey: "cluster1", + task: jobs.TaskSettings{ + JobClusterKey: new("cluster1"), SparkPythonTask: &jobs.SparkPythonTask{}, }, }, { name: "valid SQL task", - task: jobs.Task{ + task: jobs.TaskSettings{ SqlTask: &jobs.SqlTask{}, }, }, { name: "valid pipeline task", - task: jobs.Task{ + task: jobs.TaskSettings{ PipelineTask: &jobs.PipelineTask{}, }, }, { name: "valid run job task", - task: jobs.Task{ + task: jobs.TaskSettings{ RunJobTask: &jobs.RunJobTask{}, }, }, { name: "valid condition task", - task: jobs.Task{ + task: jobs.TaskSettings{ ConditionTask: &jobs.ConditionTask{}, }, }, { name: "valid for each task", - task: jobs.Task{ + task: jobs.TaskSettings{ ForEachTask: &jobs.ForEachTask{ - Task: jobs.Task{ - JobClusterKey: "cluster1", + Task: &jobs.TaskSettings{ + JobClusterKey: new("cluster1"), NotebookTask: &jobs.NotebookTask{}, }, }, @@ -138,9 +137,9 @@ func TestJobTaskClusterSpec(t *testing.T) { }, { name: "invalid python wheel task", - task: jobs.Task{ + task: jobs.TaskSettings{ PythonWheelTask: &jobs.PythonWheelTask{}, - TaskKey: "my_task", + TaskKey: new("my_task"), }, errorPath: "resources.jobs.job1.tasks[0]", errorDetail: `Task "my_task" requires a cluster or an environment to run. @@ -149,11 +148,11 @@ Specify one of the following fields: job_cluster_key, environment_key, existing_ }, { name: "invalid for each task", - task: jobs.Task{ + task: jobs.TaskSettings{ ForEachTask: &jobs.ForEachTask{ - Task: jobs.Task{ + Task: &jobs.TaskSettings{ PythonWheelTask: &jobs.PythonWheelTask{}, - TaskKey: "my_task", + TaskKey: new("my_task"), }, }, }, @@ -167,7 +166,7 @@ Specify one of the following fields: job_cluster_key, environment_key, existing_ for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { job := &resources.Job{ - Tasks: []jobs.Task{tc.task}, + Tasks: []jobs.TaskSettings{tc.task}, } b := createBundle(map[string]*resources.Job{"job1": job}) diff --git a/bundle/config/validate/required.go b/bundle/config/validate/required.go index 9e3274b6f00..48563cd79a1 100644 --- a/bundle/config/validate/required.go +++ b/bundle/config/validate/required.go @@ -7,6 +7,8 @@ import ( "slices" "strings" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/internal/validation/generated" "github.com/databricks/cli/libs/diag" @@ -134,7 +136,7 @@ func errorForMissingFields(ctx context.Context, b *bundle.Bundle) diag.Diagnosti // sql_warehouses.name is optional in the SDK (json:"name,omitempty") but required // by the backend, which rejects whitespace-only names (name.trim.nonEmpty). for key, warehouse := range b.Config.Resources.SqlWarehouses { - if strings.TrimSpace(warehouse.Name) == "" { + if strings.TrimSpace(utils.Deref(warehouse.Name)) == "" { path := structpath.NewPath(nil, "resources", "sql_warehouses", key) diags = diags.Append(diag.Diagnostic{ Severity: diag.Error, diff --git a/bundle/config/validate/single_node_cluster_test.go b/bundle/config/validate/single_node_cluster_test.go index 997d39ea0ac..bdc1d2dddcf 100644 --- a/bundle/config/validate/single_node_cluster_test.go +++ b/bundle/config/validate/single_node_cluster_test.go @@ -3,16 +3,17 @@ package validate import ( "testing" + "github.com/databricks/cli/libs/sdktypes/clusters/v2" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/stretchr/testify/assert" ) @@ -99,7 +100,7 @@ func TestValidateSingleNodeClusterFailForInteractiveClusters(t *testing.T) { Resources: config.Resources{ Clusters: map[string]*resources.Cluster{ "foo": { - ClusterSpec: compute.ClusterSpec{ + CreateClusterRequest: clusters.CreateClusterRequest{ SparkConf: tc.sparkConf, CustomTags: tc.customTags, }, @@ -143,8 +144,8 @@ func TestValidateSingleNodeClusterFailForJobClusters(t *testing.T) { JobSettings: jobs.JobSettings{ JobClusters: []jobs.JobCluster{ { - NewCluster: &compute.ClusterSpec{ - ClusterName: "my_cluster", + NewCluster: &jobs.ClusterSpec_NewCluster{ + ClusterName: new("my_cluster"), SparkConf: tc.sparkConf, CustomTags: tc.customTags, }, @@ -190,10 +191,10 @@ func TestValidateSingleNodeClusterFailForJobTaskClusters(t *testing.T) { Jobs: map[string]*resources.Job{ "foo": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - NewCluster: &compute.ClusterSpec{ - ClusterName: "my_cluster", + NewCluster: &jobs.ClusterSpec_NewCluster{ + ClusterName: new("my_cluster"), SparkConf: tc.sparkConf, CustomTags: tc.customTags, }, @@ -238,7 +239,7 @@ func TestValidateSingleNodeClusterFailForPipelineClusters(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "foo": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Clusters: []pipelines.PipelineCluster{ { SparkConf: tc.sparkConf, @@ -285,12 +286,12 @@ func TestValidateSingleNodeClusterFailForJobForEachTaskCluster(t *testing.T) { Jobs: map[string]*resources.Job{ "foo": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { ForEachTask: &jobs.ForEachTask{ - Task: jobs.Task{ - NewCluster: &compute.ClusterSpec{ - ClusterName: "my_cluster", + Task: &jobs.TaskSettings{ + NewCluster: &jobs.ClusterSpec_NewCluster{ + ClusterName: new("my_cluster"), SparkConf: tc.sparkConf, CustomTags: tc.customTags, }, @@ -380,10 +381,10 @@ func TestValidateSingleNodeClusterPassInteractiveClusters(t *testing.T) { Resources: config.Resources{ Clusters: map[string]*resources.Cluster{ "foo": { - ClusterSpec: compute.ClusterSpec{ + CreateClusterRequest: clusters.CreateClusterRequest{ SparkConf: tc.sparkConf, CustomTags: tc.customTags, - PolicyId: tc.policyId, + PolicyId: new(tc.policyId), }, }, }, @@ -416,11 +417,11 @@ func TestValidateSingleNodeClusterPassJobClusters(t *testing.T) { JobSettings: jobs.JobSettings{ JobClusters: []jobs.JobCluster{ { - NewCluster: &compute.ClusterSpec{ - ClusterName: "my_cluster", + NewCluster: &jobs.ClusterSpec_NewCluster{ + ClusterName: new("my_cluster"), SparkConf: tc.sparkConf, CustomTags: tc.customTags, - PolicyId: tc.policyId, + PolicyId: new(tc.policyId), }, }, }, @@ -454,13 +455,13 @@ func TestValidateSingleNodeClusterPassJobTaskClusters(t *testing.T) { Jobs: map[string]*resources.Job{ "foo": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - NewCluster: &compute.ClusterSpec{ - ClusterName: "my_cluster", + NewCluster: &jobs.ClusterSpec_NewCluster{ + ClusterName: new("my_cluster"), SparkConf: tc.sparkConf, CustomTags: tc.customTags, - PolicyId: tc.policyId, + PolicyId: new(tc.policyId), }, }, }, @@ -493,12 +494,12 @@ func TestValidateSingleNodeClusterPassPipelineClusters(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "foo": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Clusters: []pipelines.PipelineCluster{ { SparkConf: tc.sparkConf, CustomTags: tc.customTags, - PolicyId: tc.policyId, + PolicyId: new(tc.policyId), }, }, }, @@ -531,15 +532,15 @@ func TestValidateSingleNodeClusterPassJobForEachTaskCluster(t *testing.T) { Jobs: map[string]*resources.Job{ "foo": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { ForEachTask: &jobs.ForEachTask{ - Task: jobs.Task{ - NewCluster: &compute.ClusterSpec{ - ClusterName: "my_cluster", + Task: &jobs.TaskSettings{ + NewCluster: &jobs.ClusterSpec_NewCluster{ + ClusterName: new("my_cluster"), SparkConf: tc.sparkConf, CustomTags: tc.customTags, - PolicyId: tc.policyId, + PolicyId: new(tc.policyId), }, }, }, @@ -577,8 +578,8 @@ func TestValidateSingleNodeClusterWithIsSingleNode(t *testing.T) { JobSettings: jobs.JobSettings{ JobClusters: []jobs.JobCluster{ { - NewCluster: &compute.ClusterSpec{ - ClusterName: "my_cluster", + NewCluster: &jobs.ClusterSpec_NewCluster{ + ClusterName: new("my_cluster"), }, }, }, diff --git a/bundle/config/validate/tf_only_references_test.go b/bundle/config/validate/tf_only_references_test.go index 7b994cf864e..84d5c14e29c 100644 --- a/bundle/config/validate/tf_only_references_test.go +++ b/bundle/config/validate/tf_only_references_test.go @@ -9,7 +9,7 @@ import ( "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -20,8 +20,8 @@ func makeBundle(t *testing.T) *bundle.Bundle { Config: config.Root{ Resources: config.Resources{ Jobs: map[string]*resources.Job{ - "src": {JobSettings: jobs.JobSettings{Name: "source"}}, - "dst": {JobSettings: jobs.JobSettings{Name: "placeholder"}}, + "src": {JobSettings: jobs.JobSettings{Name: new("source")}}, + "dst": {JobSettings: jobs.JobSettings{Name: new("placeholder")}}, }, }, }, diff --git a/bundle/config/validate/validate_artifact_path.go b/bundle/config/validate/validate_artifact_path.go index 36494cf7d77..e9643cd0d72 100644 --- a/bundle/config/validate/validate_artifact_path.go +++ b/bundle/config/validate/validate_artifact_path.go @@ -2,7 +2,6 @@ package validate import ( "context" - "errors" "fmt" "slices" "strings" @@ -10,11 +9,13 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/libraries" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/dynvar" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/utils" + sdkvolumes "github.com/databricks/sdk-go/uc/volumes/v1" ) type validateArtifactPath struct{ bundle.RO } @@ -55,7 +56,7 @@ func extractVolumeFromPath(artifactPath string) (string, string, string, error) func findVolumeInBundle(r config.Root, catalogName, schemaName, volumeName string) (dyn.Path, []diag.Location, bool) { volumes := r.Resources.Volumes for k, v := range volumes { - if v.CatalogName != catalogName || v.Name != volumeName { + if utils.Deref(v.CatalogName) != catalogName || utils.Deref(v.Name) != volumeName { continue } // UC schemas can be defined in the bundle itself, and thus might be interpolated @@ -64,9 +65,9 @@ func findVolumeInBundle(r config.Root, catalogName, schemaName, volumeName strin // schema name is interpolated. // We only have to check for ${resources.schemas...} references because any // other valid reference (like ${var.foo}) would have been interpolated by this point. - p, ok := dynvar.PureReferenceToPath(v.SchemaName) + p, ok := dynvar.PureReferenceToPath(utils.Deref(v.SchemaName)) isSchemaDefinedInBundle := ok && p.HasPrefix(dyn.Path{dyn.Key("resources"), dyn.Key("schemas")}) - if v.SchemaName != schemaName && !isSchemaDefinedInBundle { + if utils.Deref(v.SchemaName) != schemaName && !isSchemaDefinedInBundle { continue } return dyn.Path{dyn.Key("resources"), dyn.Key("volumes"), dyn.Key(k)}, r.GetLocationsOf(structpath.NewPath(nil, "resources", "volumes", k)), true @@ -97,12 +98,12 @@ func (v *validateArtifactPath) Apply(ctx context.Context, b *bundle.Bundle) diag } volumeFullName := fmt.Sprintf("%s.%s.%s", catalogName, schemaName, volumeName) w := b.WorkspaceClient(ctx) - _, err = w.Volumes.ReadByName(ctx, volumeFullName) + _, err = w.Volumes.GetVolume(ctx, sdkvolumes.GetVolumeRequest{FullNameArg: new(volumeFullName)}) - if errors.Is(err, apierr.ErrPermissionDenied) { - return wrapErrorMsg(fmt.Sprintf("cannot access volume %s: %s", volumeFullName, err)) + if apierrs.Is(err, apierrs.ErrPermissionDenied) { + return wrapErrorMsg(fmt.Sprintf("cannot access volume %s: %s", volumeFullName, apierrs.ErrorString(err))) } - if errors.Is(err, apierr.ErrNotFound) { + if apierrs.Is(err, apierrs.ErrNotFound) { path, locations, ok := findVolumeInBundle(b.Config, catalogName, schemaName, volumeName) if !ok { return wrapErrorMsg(fmt.Sprintf("volume %s does not exist", volumeFullName)) @@ -123,7 +124,7 @@ the artifact_path.`, } if err != nil { - return wrapErrorMsg(fmt.Sprintf("cannot read volume %s: %s", volumeFullName, err)) + return wrapErrorMsg(fmt.Sprintf("cannot read volume %s: %s", volumeFullName, apierrs.ErrorString(err))) } return nil } diff --git a/bundle/config/validate/validate_artifact_path_test.go b/bundle/config/validate/validate_artifact_path_test.go index 97a08ab6e30..94f17d996f9 100644 --- a/bundle/config/validate/validate_artifact_path_test.go +++ b/bundle/config/validate/validate_artifact_path_test.go @@ -9,12 +9,11 @@ import ( "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/libs/testserver" + sdkconfig "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) @@ -27,10 +26,10 @@ func TestValidateArtifactPathWithVolumeInBundle(t *testing.T) { Resources: config.Resources{ Volumes: map[string]*resources.Volume{ "foo": { - CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{ - CatalogName: "catalogN", - Name: "volumeN", - SchemaName: "schemaN", + CreateVolumeRequestContent: resources.CreateVolumeRequestContent{ + CatalogName: new("catalogN"), + Name: new("volumeN"), + SchemaName: new("schemaN"), }, }, }, @@ -42,12 +41,7 @@ func TestValidateArtifactPathWithVolumeInBundle(t *testing.T) { bundletest.SetLocation(b, "resources.volumes.foo", []diag.Location{{File: "file", Line: 2, Column: 2}}) ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockVolumesAPI() - api.EXPECT().ReadByName(mock.Anything, "catalogN.schemaN.volumeN").Return(nil, &apierr.APIError{ - StatusCode: 404, - }) - b.SetWorkpaceClient(m.WorkspaceClient) + b.SetWorkpaceClient(volumeClients(t, 404, "")) diags := ValidateArtifactPath().Apply(ctx, b) assert.Equal(t, diag.Diagnostics{{ @@ -91,42 +85,53 @@ func TestValidateArtifactPath(t *testing.T) { ctx := t.Context() tcases := []struct { - err error + statusCode int + message string expectedSummary string }{ { - err: &apierr.APIError{ - StatusCode: 403, - Message: "User does not have USE SCHEMA on Schema 'catalogN.schemaN'", - }, + statusCode: 403, + message: "User does not have USE SCHEMA on Schema 'catalogN.schemaN'", expectedSummary: "cannot access volume catalogN.schemaN.volumeN: User does not have USE SCHEMA on Schema 'catalogN.schemaN'", }, { - err: &apierr.APIError{ - StatusCode: 404, - }, + statusCode: 404, expectedSummary: "volume catalogN.schemaN.volumeN does not exist", }, { - err: &apierr.APIError{ - StatusCode: 500, - Message: "Internal Server Error", - }, + statusCode: 500, + message: "Internal Server Error", expectedSummary: "cannot read volume catalogN.schemaN.volumeN: Internal Server Error", }, } for _, tc := range tcases { - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockVolumesAPI() - api.EXPECT().ReadByName(mock.Anything, "catalogN.schemaN.volumeN").Return(nil, tc.err) - b.SetWorkpaceClient(m.WorkspaceClient) + b.SetWorkpaceClient(volumeClients(t, tc.statusCode, tc.message)) diags := ValidateArtifactPath().Apply(ctx, b) assertDiags(t, diags, tc.expectedSummary) } } +// volumeClients returns clients for a workspace that fails every volume GET +// with the given status code and message. +func volumeClients(t *testing.T, statusCode int, message string) *sdkclients.Clients { + server := testserver.New(t) + server.Handle("GET", "/api/2.1/unity-catalog/volumes/catalogN.schemaN.volumeN", func(testserver.Request) any { + return testserver.Response{ + StatusCode: statusCode, + Body: map[string]string{"message": message}, + } + }) + w, err := sdkclients.New(t.Context(), &sdkconfig.Config{ + Host: server.URL, + Token: "testtoken", + Loaders: []sdkconfig.Loader{sdkconfig.ConfigAttributes}, + }) + require.NoError(t, err) + return w +} + func invalidVolumePaths() []string { return []string{ "/Volumes/", @@ -182,10 +187,10 @@ func TestFindVolumeInBundle(t *testing.T) { Resources: config.Resources{ Volumes: map[string]*resources.Volume{ "foo": { - CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{ - CatalogName: "main", - Name: "my_volume", - SchemaName: "my_schema", + CreateVolumeRequestContent: resources.CreateVolumeRequestContent{ + CatalogName: new("main"), + Name: new("my_volume"), + SchemaName: new("my_schema"), }, }, }, @@ -225,12 +230,12 @@ func TestFindVolumeInBundle(t *testing.T) { // schema name is interpolated but does not have the right prefix. In this case // we should not match the volume. - b.Config.Resources.Volumes["foo"].SchemaName = "${foo.bar.baz}" + b.Config.Resources.Volumes["foo"].SchemaName = new("${foo.bar.baz}") _, _, ok = findVolumeInBundle(b.Config, "main", "my_schema", "my_volume") assert.False(t, ok) // schema name is interpolated. - b.Config.Resources.Volumes["foo"].SchemaName = "${resources.schemas.my_schema.name}" + b.Config.Resources.Volumes["foo"].SchemaName = new("${resources.schemas.my_schema.name}") path, locations, ok = findVolumeInBundle(b.Config, "main", "valuedoesnotmatter", "my_volume") assert.True(t, ok) assert.Equal(t, []diag.Location{{ diff --git a/bundle/config/validate/validate_deployment_fields.go b/bundle/config/validate/validate_deployment_fields.go index d1ca337f4ed..c6562cd114e 100644 --- a/bundle/config/validate/validate_deployment_fields.go +++ b/bundle/config/validate/validate_deployment_fields.go @@ -5,6 +5,8 @@ import ( "context" "slices" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/structs/structpath" @@ -41,14 +43,14 @@ func (v *validateDeploymentFields) Apply(_ context.Context, b *bundle.Bundle) di for name, job := range b.Config.Resources.Jobs { if d := job.Deployment; d != nil { - reject("jobs", name, "deployment_id", d.DeploymentId) - reject("jobs", name, "version_id", d.VersionId) + reject("jobs", name, "deployment_id", utils.Deref(d.DeploymentId)) + reject("jobs", name, "version_id", utils.Deref(d.VersionId)) } } for name, pipeline := range b.Config.Resources.Pipelines { if d := pipeline.Deployment; d != nil { - reject("pipelines", name, "deployment_id", d.DeploymentId) - reject("pipelines", name, "version_id", d.VersionId) + reject("pipelines", name, "deployment_id", utils.Deref(d.DeploymentId)) + reject("pipelines", name, "version_id", utils.Deref(d.VersionId)) } } diff --git a/bundle/config/validate/validate_deployment_fields_test.go b/bundle/config/validate/validate_deployment_fields_test.go index 766242bc8f6..6339dc16d1c 100644 --- a/bundle/config/validate/validate_deployment_fields_test.go +++ b/bundle/config/validate/validate_deployment_fields_test.go @@ -7,8 +7,8 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -20,7 +20,7 @@ func jobBundle(d *jobs.JobDeployment) *bundle.Bundle { Config: config.Root{ Resources: config.Resources{ Jobs: map[string]*resources.Job{ - "my_job": {JobSettings: jobs.JobSettings{Name: "my_job", Deployment: d}}, + "my_job": {JobSettings: jobs.JobSettings{Name: new("my_job"), Deployment: d}}, }, }, }, @@ -32,7 +32,7 @@ func pipelineBundle(d *pipelines.PipelineDeployment) *bundle.Bundle { Config: config.Root{ Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ - "my_pipeline": {CreatePipeline: pipelines.CreatePipeline{Name: "my_pipeline", Deployment: d}}, + "my_pipeline": {CreatePipelineRequest: pipelines.CreatePipelineRequest{Name: new("my_pipeline"), Deployment: d}}, }, }, }, @@ -45,10 +45,10 @@ func TestValidateDeploymentFieldsRejectsReservedFields(t *testing.T) { b *bundle.Bundle want string }{ - {"job deployment_id", jobBundle(&jobs.JobDeployment{DeploymentId: "x"}), "deployment_id" + reservedFieldMsg}, - {"job version_id", jobBundle(&jobs.JobDeployment{VersionId: "x"}), "version_id" + reservedFieldMsg}, - {"pipeline deployment_id", pipelineBundle(&pipelines.PipelineDeployment{DeploymentId: "x"}), "deployment_id" + reservedFieldMsg}, - {"pipeline version_id", pipelineBundle(&pipelines.PipelineDeployment{VersionId: "x"}), "version_id" + reservedFieldMsg}, + {"job deployment_id", jobBundle(&jobs.JobDeployment{DeploymentId: new("x")}), "deployment_id" + reservedFieldMsg}, + {"job version_id", jobBundle(&jobs.JobDeployment{VersionId: new("x")}), "version_id" + reservedFieldMsg}, + {"pipeline deployment_id", pipelineBundle(&pipelines.PipelineDeployment{DeploymentId: new("x")}), "deployment_id" + reservedFieldMsg}, + {"pipeline version_id", pipelineBundle(&pipelines.PipelineDeployment{VersionId: new("x")}), "version_id" + reservedFieldMsg}, } for _, tt := range tests { @@ -66,10 +66,10 @@ func TestValidateDeploymentFieldsReportsAllOffenders(t *testing.T) { Config: config.Root{ Resources: config.Resources{ Jobs: map[string]*resources.Job{ - "my_job": {JobSettings: jobs.JobSettings{Deployment: &jobs.JobDeployment{DeploymentId: "a"}}}, + "my_job": {JobSettings: jobs.JobSettings{Deployment: &jobs.JobDeployment{DeploymentId: new("a")}}}, }, Pipelines: map[string]*resources.Pipeline{ - "my_pipeline": {CreatePipeline: pipelines.CreatePipeline{Deployment: &pipelines.PipelineDeployment{VersionId: "b"}}}, + "my_pipeline": {CreatePipelineRequest: pipelines.CreatePipelineRequest{Deployment: &pipelines.PipelineDeployment{VersionId: new("b")}}}, }, }, }, diff --git a/bundle/config/validate/validate_job_run_idempotency_token.go b/bundle/config/validate/validate_job_run_idempotency_token.go index 61e07e302ca..dc9ddedc0f7 100644 --- a/bundle/config/validate/validate_job_run_idempotency_token.go +++ b/bundle/config/validate/validate_job_run_idempotency_token.go @@ -5,6 +5,8 @@ import ( "maps" "slices" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/structs/structpath" @@ -27,7 +29,7 @@ func (v *validateJobRunIdempotencyToken) Apply(_ context.Context, b *bundle.Bund for _, name := range slices.Sorted(maps.Keys(b.Config.Resources.JobRuns)) { jobRun := b.Config.Resources.JobRuns[name] // An empty `job_runs.:` entry loads as a present key with a nil value. - if jobRun == nil || jobRun.IdempotencyToken == "" { + if jobRun == nil || utils.Deref(jobRun.IdempotencyToken) == "" { continue } // The CLI mints the token; a configured one would also remain reserved after diff --git a/bundle/config/validate/validate_job_run_idempotency_token_test.go b/bundle/config/validate/validate_job_run_idempotency_token_test.go index 4aa5ad4dbbc..ee4eb735ee5 100644 --- a/bundle/config/validate/validate_job_run_idempotency_token_test.go +++ b/bundle/config/validate/validate_job_run_idempotency_token_test.go @@ -6,7 +6,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" ) @@ -15,7 +15,7 @@ func TestValidateJobRunIdempotencyTokenAcceptsRunsWithoutOne(t *testing.T) { Config: config.Root{ Resources: config.Resources{ JobRuns: map[string]*resources.JobRun{ - "my_run": {RunNow: jobs.RunNow{JobId: 456}}, + "my_run": {RunNowRequest: jobs.RunNowRequest{JobId: new(int64(456))}}, // An empty `job_runs.:` entry loads as a present key with a nil value. "empty": nil, }, diff --git a/bundle/config/variable/find_by_name.go b/bundle/config/variable/find_by_name.go new file mode 100644 index 00000000000..3b72c21ef08 --- /dev/null +++ b/bundle/config/variable/find_by_name.go @@ -0,0 +1,38 @@ +package variable + +import ( + "fmt" + "iter" +) + +// findByName returns the single item whose name is name. typeName is only +// used in error messages; it keeps the wording the lookups have always used. +func findByName[T any](items iter.Seq2[*T, error], name, typeName string, nameOf func(*T) string) (*T, error) { + var matches []*T + for item, err := range items { + if err != nil { + return nil, err + } + if nameOf(item) == name { + matches = append(matches, item) + } + } + if len(matches) == 0 { + return nil, fmt.Errorf("%s named '%s' does not exist", typeName, name) + } + if len(matches) > 1 { + return nil, fmt.Errorf("there are %d instances of %s named '%s'", len(matches), typeName, name) + } + return matches[0], nil +} + +// sliceSeq adapts a slice of values to the iterator form findByName expects. +func sliceSeq[T any](items []T) iter.Seq2[*T, error] { + return func(yield func(*T, error) bool) { + for i := range items { + if !yield(&items[i], nil) { + return + } + } + } +} diff --git a/bundle/config/variable/helpers_test.go b/bundle/config/variable/helpers_test.go new file mode 100644 index 00000000000..388006ec539 --- /dev/null +++ b/bundle/config/variable/helpers_test.go @@ -0,0 +1,46 @@ +package variable + +import ( + "net/http" + "testing" + + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/testserver" + "github.com/databricks/databricks-sdk-go/config" + "github.com/stretchr/testify/require" +) + +// newTestClients returns clients for a test server that answers each +// "METHOD /path" in routes with the given response body. +func newTestClients(t *testing.T, routes map[string]any) *sdkclients.Clients { + server := testserver.New(t) + for route, body := range routes { + var method, path string + for i := range route { + if route[i] == ' ' { + method, path = route[:i], route[i+1:] + break + } + } + server.Handle(method, path, func(testserver.Request) any { return body }) + } + return newServerClients(t, server) +} + +// newServerClients returns clients that talk to server. +func newServerClients(t *testing.T, server *testserver.Server) *sdkclients.Clients { + w, err := sdkclients.New(t.Context(), &config.Config{ + Host: server.URL, + Token: "testtoken", + Loaders: []config.Loader{config.ConfigAttributes}, + }) + require.NoError(t, err) + return w +} + +func notFound() testserver.Response { + return testserver.Response{ + StatusCode: http.StatusNotFound, + Body: map[string]string{"error_code": "NOT_FOUND", "message": "not found"}, + } +} diff --git a/bundle/config/variable/lookup.go b/bundle/config/variable/lookup.go index 71c8512e3ca..ea628b17441 100755 --- a/bundle/config/variable/lookup.go +++ b/bundle/config/variable/lookup.go @@ -4,7 +4,7 @@ import ( "context" "errors" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" ) type Lookup struct { @@ -35,7 +35,7 @@ type Lookup struct { type resolver interface { // Resolve resolves the underlying entity's ID. - Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) + Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) // String returns a human-readable representation of the resolver. String() string @@ -91,7 +91,7 @@ func (l *Lookup) constructResolver() (resolver, error) { } } -func (l *Lookup) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { +func (l *Lookup) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { r, err := l.constructResolver() if err != nil { return "", err diff --git a/bundle/config/variable/resolve_alert.go b/bundle/config/variable/resolve_alert.go index 507306aa061..afc1436a49d 100644 --- a/bundle/config/variable/resolve_alert.go +++ b/bundle/config/variable/resolve_alert.go @@ -3,19 +3,23 @@ package variable import ( "context" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/alerts/v1" ) type resolveAlert struct { name string } -func (l resolveAlert) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { - entity, err := w.Alerts.GetByDisplayName(ctx, l.name) +func (l resolveAlert) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { + entity, err := findByName(w.AlertsV1.ListAlertsIter(ctx, alerts.ListAlertsRequest{}), l.name, "ListAlertsResponseAlert", func(a *alerts.ListAlertsResponseAlert) string { + return utils.Deref(a.DisplayName) + }) if err != nil { return "", err } - return entity.Id, nil + return utils.Deref(entity.Id), nil } func (l resolveAlert) String() string { diff --git a/bundle/config/variable/resolve_alert_test.go b/bundle/config/variable/resolve_alert_test.go index 68fd38f08dd..575ac9018e3 100644 --- a/bundle/config/variable/resolve_alert_test.go +++ b/bundle/config/variable/resolve_alert_test.go @@ -3,43 +3,28 @@ package variable import ( "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/apierrs" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestResolveAlert_ResolveSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockAlertsAPI() - api.EXPECT(). - GetByDisplayName(mock.Anything, "alert"). - Return(&sql.ListAlertsResponseAlert{ - Id: "1234", - }, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/sql/alerts": map[string]any{"results": []map[string]any{{"id": "1234", "display_name": "alert"}}}, + }) l := resolveAlert{name: "alert"} - result, err := l.Resolve(ctx, m.WorkspaceClient) + result, err := l.Resolve(t.Context(), w) require.NoError(t, err) assert.Equal(t, "1234", result) } func TestResolveAlert_ResolveNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockAlertsAPI() - api.EXPECT(). - GetByDisplayName(mock.Anything, "alert"). - Return(nil, &apierr.APIError{StatusCode: 404}) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/sql/alerts": notFound(), + }) l := resolveAlert{name: "alert"} - _, err := l.Resolve(ctx, m.WorkspaceClient) - require.ErrorIs(t, err, apierr.ErrNotFound) + _, err := l.Resolve(t.Context(), w) + require.True(t, apierrs.Is(err, apierrs.ErrNotFound), "%v", err) } func TestResolveAlert_String(t *testing.T) { diff --git a/bundle/config/variable/resolve_cluster.go b/bundle/config/variable/resolve_cluster.go index 51278aef5c3..fe1ad856449 100644 --- a/bundle/config/variable/resolve_cluster.go +++ b/bundle/config/variable/resolve_cluster.go @@ -3,28 +3,57 @@ package variable import ( "context" "fmt" + "net/http" + "net/url" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" + "github.com/databricks/cli/libs/sdkclients" ) type resolveCluster struct { name string } +type listedCluster struct { + ClusterId string `json:"cluster_id"` + ClusterName string `json:"cluster_name"` +} + +type listClustersResponse struct { + Clusters []listedCluster `json:"clusters"` + NextPageToken string `json:"next_page_token"` +} + // We added a custom resolver for the cluster to add filtering for the cluster source when we list all clusters. // Without the filtering listing could take a very long time (5-10 mins) which leads to lookup timeouts. -func (l resolveCluster) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { - result, err := w.Clusters.ListAll(ctx, compute.ListClustersRequest{ - FilterBy: &compute.ListClustersFilterBy{ - ClusterSources: []compute.ClusterSource{compute.ClusterSourceApi, compute.ClusterSourceUi}, - }, - }) +// sdk-go does not expose the filter, so the list endpoint is called directly. +func (l resolveCluster) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { + api, err := apiclient.New(w.Config) if err != nil { return "", err } - tmp := map[string][]compute.ClusterDetails{} + var result []listedCluster + pageToken := "" + for { + query := url.Values{"filter_by.cluster_sources": {"API", "UI"}} + if pageToken != "" { + query.Set("page_token", pageToken) + } + var resp listClustersResponse + err := api.Do(ctx, http.MethodGet, "/api/2.1/clusters/list", auth.WorkspaceIDHeaders(w.Config), nil, query, &resp) + if err != nil { + return "", err + } + result = append(result, resp.Clusters...) + if resp.NextPageToken == "" { + break + } + pageToken = resp.NextPageToken + } + + tmp := map[string][]listedCluster{} for _, v := range result { key := v.ClusterName tmp[key] = append(tmp[key], v) diff --git a/bundle/config/variable/resolve_cluster_policy.go b/bundle/config/variable/resolve_cluster_policy.go index 94fd892b25d..06d22868dec 100644 --- a/bundle/config/variable/resolve_cluster_policy.go +++ b/bundle/config/variable/resolve_cluster_policy.go @@ -3,19 +3,27 @@ package variable import ( "context" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/clusterpolicies/v2" ) type resolveClusterPolicy struct { name string } -func (l resolveClusterPolicy) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { - entity, err := w.ClusterPolicies.GetByName(ctx, l.name) +func (l resolveClusterPolicy) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { + resp, err := w.ClusterPolicies.ListPolicies(ctx, clusterpolicies.ListPoliciesRequest{}) if err != nil { return "", err } - return entity.PolicyId, nil + entity, err := findByName(sliceSeq(resp.Policies), l.name, "Policy", func(p *clusterpolicies.Policy) string { + return utils.Deref(p.Name) + }) + if err != nil { + return "", err + } + return utils.Deref(entity.PolicyId), nil } func (l resolveClusterPolicy) String() string { diff --git a/bundle/config/variable/resolve_cluster_policy_test.go b/bundle/config/variable/resolve_cluster_policy_test.go index 574c9b5c597..78a9d233044 100644 --- a/bundle/config/variable/resolve_cluster_policy_test.go +++ b/bundle/config/variable/resolve_cluster_policy_test.go @@ -3,43 +3,28 @@ package variable import ( "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/cli/libs/apierrs" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestResolveClusterPolicy_ResolveSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockClusterPoliciesAPI() - api.EXPECT(). - GetByName(mock.Anything, "policy"). - Return(&compute.Policy{ - PolicyId: "1234", - }, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/policies/clusters/list": map[string]any{"policies": []map[string]any{{"policy_id": "1234", "name": "policy"}}}, + }) l := resolveClusterPolicy{name: "policy"} - result, err := l.Resolve(ctx, m.WorkspaceClient) + result, err := l.Resolve(t.Context(), w) require.NoError(t, err) assert.Equal(t, "1234", result) } func TestResolveClusterPolicy_ResolveNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockClusterPoliciesAPI() - api.EXPECT(). - GetByName(mock.Anything, "policy"). - Return(nil, &apierr.APIError{StatusCode: 404}) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/policies/clusters/list": notFound(), + }) l := resolveClusterPolicy{name: "policy"} - _, err := l.Resolve(ctx, m.WorkspaceClient) - require.ErrorIs(t, err, apierr.ErrNotFound) + _, err := l.Resolve(t.Context(), w) + require.True(t, apierrs.Is(err, apierrs.ErrNotFound), "%v", err) } func TestResolveClusterPolicy_String(t *testing.T) { diff --git a/bundle/config/variable/resolve_cluster_test.go b/bundle/config/variable/resolve_cluster_test.go index c99a090fba8..b90084d88a4 100644 --- a/bundle/config/variable/resolve_cluster_test.go +++ b/bundle/config/variable/resolve_cluster_test.go @@ -3,42 +3,29 @@ package variable import ( "testing" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/compute" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestResolveCluster_ResolveSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockClustersAPI() - api.EXPECT(). - ListAll(mock.Anything, mock.Anything). - Return([]compute.ClusterDetails{ - {ClusterId: "1234", ClusterName: "cluster1"}, - {ClusterId: "2345", ClusterName: "cluster2"}, - }, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.1/clusters/list": map[string]any{"clusters": []map[string]any{ + {"cluster_id": "1234", "cluster_name": "cluster1"}, + {"cluster_id": "2345", "cluster_name": "cluster2"}, + }}, + }) l := resolveCluster{name: "cluster2"} - result, err := l.Resolve(ctx, m.WorkspaceClient) + result, err := l.Resolve(t.Context(), w) require.NoError(t, err) assert.Equal(t, "2345", result) } func TestResolveCluster_ResolveNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockClustersAPI() - api.EXPECT(). - ListAll(mock.Anything, mock.Anything). - Return([]compute.ClusterDetails{}, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.1/clusters/list": map[string]any{}, + }) l := resolveCluster{name: "cluster"} - _, err := l.Resolve(ctx, m.WorkspaceClient) + _, err := l.Resolve(t.Context(), w) require.Error(t, err) assert.Contains(t, err.Error(), "cluster named 'cluster' does not exist") } diff --git a/bundle/config/variable/resolve_dashboard.go b/bundle/config/variable/resolve_dashboard.go index 63770011fda..c785bdf655e 100644 --- a/bundle/config/variable/resolve_dashboard.go +++ b/bundle/config/variable/resolve_dashboard.go @@ -4,23 +4,23 @@ import ( "context" "fmt" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sqllegacy" ) type resolveDashboard struct { name string } -func (l resolveDashboard) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { +func (l resolveDashboard) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { // List dashboards and find the one with the given name // If there are multiple dashboards with the same name, return an error - dashboards, err := w.Dashboards.ListAll(ctx, sql.ListDashboardsRequest{}) + dashboards, err := w.SqlLegacy.ListDashboardsAll(ctx, sqllegacy.ListDashboardsRequest{}) if err != nil { return "", err } - dashboardMap := make(map[string][]sql.Dashboard) + dashboardMap := make(map[string][]sqllegacy.Dashboard) for _, dashboard := range dashboards { dashboardMap[dashboard.Name] = append(dashboardMap[dashboard.Name], dashboard) } diff --git a/bundle/config/variable/resolve_dashboard_test.go b/bundle/config/variable/resolve_dashboard_test.go index 32c3a224736..0f536a11c69 100644 --- a/bundle/config/variable/resolve_dashboard_test.go +++ b/bundle/config/variable/resolve_dashboard_test.go @@ -3,45 +3,43 @@ package variable import ( "testing" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/testserver" + "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) -func TestResolveDashboard_ResolveSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockDashboardsAPI() - api.EXPECT(). - ListAll(mock.Anything, mock.Anything). - Return([]sql.Dashboard{ - {Id: "1234", Name: "dashboard"}, - {Id: "5678", Name: "dashboard2"}, - }, nil) +// dashboardPages serves the given dashboards as page 1 and an empty page 2, +// which is how the legacy dashboards API signals the end of the list. +func dashboardPages(dashboards []map[string]any) func(testserver.Request) any { + return func(req testserver.Request) any { + if req.URL.Query().Get("page") == "1" { + return map[string]any{"page": 1, "results": dashboards} + } + return map[string]any{"page": 2} + } +} - ctx := t.Context() +func TestResolveDashboard_ResolveSuccess(t *testing.T) { + server := testserver.New(t) + server.Handle("GET", "/api/2.0/preview/sql/dashboards", dashboardPages([]map[string]any{ + {"id": "1234", "name": "dashboard"}, + {"id": "5678", "name": "dashboard2"}, + })) l := resolveDashboard{name: "dashboard"} - result, err := l.Resolve(ctx, m.WorkspaceClient) + result, err := l.Resolve(t.Context(), newServerClients(t, server)) require.NoError(t, err) assert.Equal(t, "1234", result) } func TestResolveDashboard_ResolveNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockDashboardsAPI() - api.EXPECT(). - ListAll(mock.Anything, mock.Anything). - Return([]sql.Dashboard{ - {Id: "1234", Name: "dashboard1"}, - {Id: "5678", Name: "dashboard2"}, - }, nil) - - ctx := t.Context() + server := testserver.New(t) + server.Handle("GET", "/api/2.0/preview/sql/dashboards", dashboardPages([]map[string]any{ + {"id": "1234", "name": "dashboard1"}, + {"id": "5678", "name": "dashboard2"}, + })) l := resolveDashboard{name: "dashboard"} - _, err := l.Resolve(ctx, m.WorkspaceClient) + _, err := l.Resolve(t.Context(), newServerClients(t, server)) require.ErrorContains(t, err, "dashboard name 'dashboard' does not exist") } diff --git a/bundle/config/variable/resolve_instance_pool.go b/bundle/config/variable/resolve_instance_pool.go index 600b47a5073..5eee82619a5 100644 --- a/bundle/config/variable/resolve_instance_pool.go +++ b/bundle/config/variable/resolve_instance_pool.go @@ -3,19 +3,27 @@ package variable import ( "context" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/instancepools/v2" ) type resolveInstancePool struct { name string } -func (l resolveInstancePool) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { - entity, err := w.InstancePools.GetByInstancePoolName(ctx, l.name) +func (l resolveInstancePool) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { + resp, err := w.InstancePools.ListInstancePools(ctx, instancepools.ListInstancePoolsRequest{}) if err != nil { return "", err } - return entity.InstancePoolId, nil + entity, err := findByName(sliceSeq(resp.InstancePools), l.name, "InstancePoolAndStats", func(p *instancepools.InstancePoolAndStats) string { + return utils.Deref(p.InstancePoolName) + }) + if err != nil { + return "", err + } + return utils.Deref(entity.InstancePoolId), nil } func (l resolveInstancePool) String() string { diff --git a/bundle/config/variable/resolve_instance_pool_test.go b/bundle/config/variable/resolve_instance_pool_test.go index 0cf235f500c..b37f5dd8a09 100644 --- a/bundle/config/variable/resolve_instance_pool_test.go +++ b/bundle/config/variable/resolve_instance_pool_test.go @@ -3,43 +3,28 @@ package variable import ( "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/cli/libs/apierrs" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestResolveInstancePool_ResolveSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockInstancePoolsAPI() - api.EXPECT(). - GetByInstancePoolName(mock.Anything, "instance_pool"). - Return(&compute.InstancePoolAndStats{ - InstancePoolId: "5678", - }, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/instance-pools/list": map[string]any{"instance_pools": []map[string]any{{"instance_pool_id": "5678", "instance_pool_name": "instance_pool"}}}, + }) l := resolveInstancePool{name: "instance_pool"} - result, err := l.Resolve(ctx, m.WorkspaceClient) + result, err := l.Resolve(t.Context(), w) require.NoError(t, err) assert.Equal(t, "5678", result) } func TestResolveInstancePool_ResolveNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockInstancePoolsAPI() - api.EXPECT(). - GetByInstancePoolName(mock.Anything, "instance_pool"). - Return(nil, &apierr.APIError{StatusCode: 404}) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/instance-pools/list": notFound(), + }) l := resolveInstancePool{name: "instance_pool"} - _, err := l.Resolve(ctx, m.WorkspaceClient) - require.ErrorIs(t, err, apierr.ErrNotFound) + _, err := l.Resolve(t.Context(), w) + require.True(t, apierrs.Is(err, apierrs.ErrNotFound), "%v", err) } func TestResolveInstancePool_String(t *testing.T) { diff --git a/bundle/config/variable/resolve_job.go b/bundle/config/variable/resolve_job.go index 4fe6ae3e774..14397ca2b38 100644 --- a/bundle/config/variable/resolve_job.go +++ b/bundle/config/variable/resolve_job.go @@ -4,19 +4,26 @@ import ( "context" "strconv" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/jobs/v2" ) type resolveJob struct { name string } -func (l resolveJob) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { - entity, err := w.Jobs.GetBySettingsName(ctx, l.name) +func (l resolveJob) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { + entity, err := findByName(w.Jobs.ListJobsIter(ctx, jobs.ListJobsRequest{}), l.name, "BaseJob", func(j *jobs.BaseJob) string { + if j.Settings == nil { + return "" + } + return utils.Deref(j.Settings.Name) + }) if err != nil { return "", err } - return strconv.FormatInt(entity.JobId, 10), nil + return strconv.FormatInt(utils.Deref(entity.JobId), 10), nil } func (l resolveJob) String() string { diff --git a/bundle/config/variable/resolve_job_test.go b/bundle/config/variable/resolve_job_test.go index 375d62e7831..7cbd2b4ac05 100644 --- a/bundle/config/variable/resolve_job_test.go +++ b/bundle/config/variable/resolve_job_test.go @@ -3,43 +3,28 @@ package variable import ( "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/apierrs" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestResolveJob_ResolveSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockJobsAPI() - api.EXPECT(). - GetBySettingsName(mock.Anything, "job"). - Return(&jobs.BaseJob{ - JobId: 5678, - }, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.2/jobs/list": map[string]any{"jobs": []map[string]any{{"job_id": 5678, "settings": map[string]any{"name": "job"}}}}, + }) l := resolveJob{name: "job"} - result, err := l.Resolve(ctx, m.WorkspaceClient) + result, err := l.Resolve(t.Context(), w) require.NoError(t, err) assert.Equal(t, "5678", result) } func TestResolveJob_ResolveNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockJobsAPI() - api.EXPECT(). - GetBySettingsName(mock.Anything, "job"). - Return(nil, &apierr.APIError{StatusCode: 404}) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.2/jobs/list": notFound(), + }) l := resolveJob{name: "job"} - _, err := l.Resolve(ctx, m.WorkspaceClient) - require.ErrorIs(t, err, apierr.ErrNotFound) + _, err := l.Resolve(t.Context(), w) + require.True(t, apierrs.Is(err, apierrs.ErrNotFound), "%v", err) } func TestResolveJob_String(t *testing.T) { diff --git a/bundle/config/variable/resolve_metastore.go b/bundle/config/variable/resolve_metastore.go index 0652a399cde..c0fce465fae 100644 --- a/bundle/config/variable/resolve_metastore.go +++ b/bundle/config/variable/resolve_metastore.go @@ -4,24 +4,23 @@ import ( "context" "fmt" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/uc/metastores/v1" ) type resolveMetastore struct { name string } -func (l resolveMetastore) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { - result, err := w.Metastores.ListAll(ctx, catalog.ListMetastoresRequest{}) - if err != nil { - return "", err - } - +func (l resolveMetastore) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { // Collect all metastores with the given name. - var entities []catalog.MetastoreInfo - for _, entity := range result { - if entity.Name == l.name { + var entities []*metastores.MetastoreInfo + for entity, err := range w.Metastores.ListMetastoresIter(ctx, metastores.ListMetastoresRequest{}) { + if err != nil { + return "", err + } + if utils.Deref(entity.Name) == l.name { entities = append(entities, entity) } } @@ -31,7 +30,7 @@ func (l resolveMetastore) Resolve(ctx context.Context, w *databricks.WorkspaceCl case 0: return "", fmt.Errorf("metastore named %q does not exist", l.name) case 1: - return entities[0].MetastoreId, nil + return utils.Deref(entities[0].MetastoreId), nil default: return "", fmt.Errorf("there are %d instances of metastores named %q", len(entities), l.name) } diff --git a/bundle/config/variable/resolve_metastore_test.go b/bundle/config/variable/resolve_metastore_test.go index 759d394278d..f9d992669ee 100644 --- a/bundle/config/variable/resolve_metastore_test.go +++ b/bundle/config/variable/resolve_metastore_test.go @@ -3,60 +3,42 @@ package variable import ( "testing" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestResolveMetastore_ResolveSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockMetastoresAPI() - api.EXPECT(). - ListAll(mock.Anything, mock.Anything). - Return([]catalog.MetastoreInfo{ - {MetastoreId: "abcd", Name: "metastore"}, - }, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.1/unity-catalog/metastores": map[string]any{"metastores": []map[string]any{ + {"metastore_id": "abcd", "name": "metastore"}, + }}, + }) l := resolveMetastore{name: "metastore"} - result, err := l.Resolve(ctx, m.WorkspaceClient) + result, err := l.Resolve(t.Context(), w) require.NoError(t, err) assert.Equal(t, "abcd", result) } func TestResolveMetastore_ResolveNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockMetastoresAPI() - api.EXPECT(). - ListAll(mock.Anything, mock.Anything). - Return([]catalog.MetastoreInfo{ - {MetastoreId: "abcd", Name: "different"}, - }, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.1/unity-catalog/metastores": map[string]any{"metastores": []map[string]any{ + {"metastore_id": "abcd", "name": "different"}, + }}, + }) l := resolveMetastore{name: "metastore"} - _, err := l.Resolve(ctx, m.WorkspaceClient) + _, err := l.Resolve(t.Context(), w) require.ErrorContains(t, err, "metastore named \"metastore\" does not exist") } func TestResolveMetastore_ResolveMultiple(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockMetastoresAPI() - api.EXPECT(). - ListAll(mock.Anything, mock.Anything). - Return([]catalog.MetastoreInfo{ - {MetastoreId: "abcd", Name: "metastore"}, - {MetastoreId: "efgh", Name: "metastore"}, - }, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.1/unity-catalog/metastores": map[string]any{"metastores": []map[string]any{ + {"metastore_id": "abcd", "name": "metastore"}, + {"metastore_id": "efgh", "name": "metastore"}, + }}, + }) l := resolveMetastore{name: "metastore"} - _, err := l.Resolve(ctx, m.WorkspaceClient) + _, err := l.Resolve(t.Context(), w) require.Error(t, err) assert.ErrorContains(t, err, "there are 2 instances of metastores named \"metastore\"") } diff --git a/bundle/config/variable/resolve_notification_destination.go b/bundle/config/variable/resolve_notification_destination.go index 4696a52c8db..75d0c0c6ee4 100644 --- a/bundle/config/variable/resolve_notification_destination.go +++ b/bundle/config/variable/resolve_notification_destination.go @@ -4,28 +4,27 @@ import ( "context" "fmt" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/settings" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/notificationdestinations/v1" ) type resolveNotificationDestination struct { name string } -func (l resolveNotificationDestination) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { - result, err := w.NotificationDestinations.ListAll(ctx, settings.ListNotificationDestinationsRequest{ +func (l resolveNotificationDestination) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { + // Collect all notification destinations with the given name. + var entities []*notificationdestinations.ListNotificationDestinationsResult + for entity, err := range w.NotificationDestinations.ListNotificationDestinationsIter(ctx, notificationdestinations.ListNotificationDestinationsRequest{ // The default page size for this API is 20. // We use a higher value to make fewer API calls. - PageSize: 200, - }) - if err != nil { - return "", err - } - - // Collect all notification destinations with the given name. - var entities []settings.ListNotificationDestinationsResult - for _, entity := range result { - if entity.DisplayName == l.name { + PageSize: new(int64(200)), + }) { + if err != nil { + return "", err + } + if utils.Deref(entity.DisplayName) == l.name { entities = append(entities, entity) } } @@ -35,7 +34,7 @@ func (l resolveNotificationDestination) Resolve(ctx context.Context, w *databric case 0: return "", fmt.Errorf("notification destination named %q does not exist", l.name) case 1: - return entities[0].Id, nil + return utils.Deref(entities[0].Id), nil default: return "", fmt.Errorf("there are %d instances of clusters named %q", len(entities), l.name) } diff --git a/bundle/config/variable/resolve_notification_destination_test.go b/bundle/config/variable/resolve_notification_destination_test.go index f5e24a94cf0..8b9fd29657d 100644 --- a/bundle/config/variable/resolve_notification_destination_test.go +++ b/bundle/config/variable/resolve_notification_destination_test.go @@ -1,76 +1,60 @@ package variable import ( - "errors" + "net/http" "testing" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/settings" + "github.com/databricks/cli/libs/testserver" + "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) -func TestResolveNotificationDestination_ResolveSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockNotificationDestinationsAPI() - api.EXPECT(). - ListAll(mock.Anything, mock.Anything). - Return([]settings.ListNotificationDestinationsResult{ - {Id: "1234", DisplayName: "destination"}, - }, nil) +const notificationDestinationsPath = "GET /api/2.0/notification-destinations" - ctx := t.Context() +func TestResolveNotificationDestination_ResolveSuccess(t *testing.T) { + w := newTestClients(t, map[string]any{ + notificationDestinationsPath: map[string]any{"results": []map[string]any{ + {"id": "1234", "display_name": "destination"}, + }}, + }) l := resolveNotificationDestination{name: "destination"} - result, err := l.Resolve(ctx, m.WorkspaceClient) + result, err := l.Resolve(t.Context(), w) require.NoError(t, err) assert.Equal(t, "1234", result) } func TestResolveNotificationDestination_ResolveError(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockNotificationDestinationsAPI() - api.EXPECT(). - ListAll(mock.Anything, mock.Anything). - Return(nil, errors.New("bad")) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + notificationDestinationsPath: testserver.Response{ + StatusCode: http.StatusInternalServerError, + Body: map[string]string{"error_code": "INTERNAL_ERROR", "message": "bad"}, + }, + }) l := resolveNotificationDestination{name: "destination"} - _, err := l.Resolve(ctx, m.WorkspaceClient) + _, err := l.Resolve(t.Context(), w) assert.ErrorContains(t, err, "bad") } func TestResolveNotificationDestination_ResolveNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockNotificationDestinationsAPI() - api.EXPECT(). - ListAll(mock.Anything, mock.Anything). - Return([]settings.ListNotificationDestinationsResult{}, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + notificationDestinationsPath: map[string]any{}, + }) l := resolveNotificationDestination{name: "destination"} - _, err := l.Resolve(ctx, m.WorkspaceClient) + _, err := l.Resolve(t.Context(), w) require.Error(t, err) assert.ErrorContains(t, err, `notification destination named "destination" does not exist`) } func TestResolveNotificationDestination_ResolveMultiple(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockNotificationDestinationsAPI() - api.EXPECT(). - ListAll(mock.Anything, mock.Anything). - Return([]settings.ListNotificationDestinationsResult{ - {Id: "1234", DisplayName: "destination"}, - {Id: "5678", DisplayName: "destination"}, - }, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + notificationDestinationsPath: map[string]any{"results": []map[string]any{ + {"id": "1234", "display_name": "destination"}, + {"id": "5678", "display_name": "destination"}, + }}, + }) l := resolveNotificationDestination{name: "destination"} - _, err := l.Resolve(ctx, m.WorkspaceClient) + _, err := l.Resolve(t.Context(), w) require.Error(t, err) assert.ErrorContains(t, err, `there are 2 instances of clusters named "destination"`) } diff --git a/bundle/config/variable/resolve_pipeline.go b/bundle/config/variable/resolve_pipeline.go index 33b14530d94..398d9a0f1fe 100644 --- a/bundle/config/variable/resolve_pipeline.go +++ b/bundle/config/variable/resolve_pipeline.go @@ -3,19 +3,23 @@ package variable import ( "context" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/pipelines/v2" ) type resolvePipeline struct { name string } -func (l resolvePipeline) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { - entity, err := w.Pipelines.GetByName(ctx, l.name) +func (l resolvePipeline) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { + entity, err := findByName(w.Pipelines.ListIter(ctx, pipelines.ListPipelinesRequest{}), l.name, "PipelineStateInfo", func(p *pipelines.PipelineStateInfo) string { + return utils.Deref(p.Name) + }) if err != nil { return "", err } - return entity.PipelineId, nil + return utils.Deref(entity.PipelineId), nil } func (l resolvePipeline) String() string { diff --git a/bundle/config/variable/resolve_pipeline_test.go b/bundle/config/variable/resolve_pipeline_test.go index 5586b96a2b6..4f2bfd98f52 100644 --- a/bundle/config/variable/resolve_pipeline_test.go +++ b/bundle/config/variable/resolve_pipeline_test.go @@ -3,43 +3,28 @@ package variable import ( "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/apierrs" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestResolvePipeline_ResolveSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockPipelinesAPI() - api.EXPECT(). - GetByName(mock.Anything, "pipeline"). - Return(&pipelines.PipelineStateInfo{ - PipelineId: "abcd", - }, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/pipelines": map[string]any{"statuses": []map[string]any{{"pipeline_id": "abcd", "name": "pipeline"}}}, + }) l := resolvePipeline{name: "pipeline"} - result, err := l.Resolve(ctx, m.WorkspaceClient) + result, err := l.Resolve(t.Context(), w) require.NoError(t, err) assert.Equal(t, "abcd", result) } func TestResolvePipeline_ResolveNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockPipelinesAPI() - api.EXPECT(). - GetByName(mock.Anything, "pipeline"). - Return(nil, &apierr.APIError{StatusCode: 404}) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/pipelines": notFound(), + }) l := resolvePipeline{name: "pipeline"} - _, err := l.Resolve(ctx, m.WorkspaceClient) - require.ErrorIs(t, err, apierr.ErrNotFound) + _, err := l.Resolve(t.Context(), w) + require.True(t, apierrs.Is(err, apierrs.ErrNotFound), "%v", err) } func TestResolvePipeline_String(t *testing.T) { diff --git a/bundle/config/variable/resolve_query.go b/bundle/config/variable/resolve_query.go index 88f653dc6bb..964e6740b14 100644 --- a/bundle/config/variable/resolve_query.go +++ b/bundle/config/variable/resolve_query.go @@ -3,19 +3,23 @@ package variable import ( "context" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/queries/v1" ) type resolveQuery struct { name string } -func (l resolveQuery) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { - entity, err := w.Queries.GetByDisplayName(ctx, l.name) +func (l resolveQuery) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { + entity, err := findByName(w.Queries.ListQueriesIter(ctx, queries.ListQueriesRequest{}), l.name, "ListQueryObjectsResponseQuery", func(q *queries.ListQueryObjectsResponseQuery) string { + return utils.Deref(q.DisplayName) + }) if err != nil { return "", err } - return entity.Id, nil + return utils.Deref(entity.Id), nil } func (l resolveQuery) String() string { diff --git a/bundle/config/variable/resolve_query_test.go b/bundle/config/variable/resolve_query_test.go index 5fb0be05e31..f348d1fd503 100644 --- a/bundle/config/variable/resolve_query_test.go +++ b/bundle/config/variable/resolve_query_test.go @@ -3,43 +3,28 @@ package variable import ( "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/apierrs" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestResolveQuery_ResolveSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockQueriesAPI() - api.EXPECT(). - GetByDisplayName(mock.Anything, "query"). - Return(&sql.ListQueryObjectsResponseQuery{ - Id: "1234", - }, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/sql/queries": map[string]any{"results": []map[string]any{{"id": "1234", "display_name": "query"}}}, + }) l := resolveQuery{name: "query"} - result, err := l.Resolve(ctx, m.WorkspaceClient) + result, err := l.Resolve(t.Context(), w) require.NoError(t, err) assert.Equal(t, "1234", result) } func TestResolveQuery_ResolveNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockQueriesAPI() - api.EXPECT(). - GetByDisplayName(mock.Anything, "query"). - Return(nil, &apierr.APIError{StatusCode: 404}) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/sql/queries": notFound(), + }) l := resolveQuery{name: "query"} - _, err := l.Resolve(ctx, m.WorkspaceClient) - require.ErrorIs(t, err, apierr.ErrNotFound) + _, err := l.Resolve(t.Context(), w) + require.True(t, apierrs.Is(err, apierrs.ErrNotFound), "%v", err) } func TestResolveQuery_String(t *testing.T) { diff --git a/bundle/config/variable/resolve_service_principal.go b/bundle/config/variable/resolve_service_principal.go index e0ae7f879d3..52f09a09daf 100644 --- a/bundle/config/variable/resolve_service_principal.go +++ b/bundle/config/variable/resolve_service_principal.go @@ -3,26 +3,31 @@ package variable import ( "context" "fmt" + "iter" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/listing" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/scim/v1" ) type resolveServicePrincipal struct { name string } -func (l resolveServicePrincipal) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { - //nolint:staticcheck // this API is deprecated but we still need use it as there is no replacement yet. - it := w.ServicePrincipalsV2.List(ctx, iam.ListServicePrincipalsRequest{ - Filter: fmt.Sprintf("displayName eq '%s'", l.name), - }) - - servicePrincipals, err := listing.ToSliceN(ctx, it, 1) +func (l resolveServicePrincipal) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { + // Only the first match is used, so fetch no more than the first page. + next, stop := iter.Pull2(w.Scim.ListServicePrincipalsIter(ctx, scim.ListServicePrincipalsRequest{ + Filter: new(fmt.Sprintf("displayName eq '%s'", l.name)), + })) + defer stop() + var servicePrincipals []*scim.ServicePrincipal + sp, err, ok := next() if err != nil { return "", err } + if ok { + servicePrincipals = append(servicePrincipals, sp) + } if len(servicePrincipals) == 0 { return "", fmt.Errorf("service principal named %q does not exist", l.name) } @@ -31,7 +36,7 @@ func (l resolveServicePrincipal) Resolve(ctx context.Context, w *databricks.Work return "", fmt.Errorf("multiple service principals found with display name %q", l.name) } - return servicePrincipals[0].ApplicationId, nil + return utils.Deref(servicePrincipals[0].ApplicationId), nil } func (l resolveServicePrincipal) String() string { diff --git a/bundle/config/variable/resolve_service_principal_test.go b/bundle/config/variable/resolve_service_principal_test.go index d146a3a9bf6..2d392a3e716 100644 --- a/bundle/config/variable/resolve_service_principal_test.go +++ b/bundle/config/variable/resolve_service_principal_test.go @@ -3,50 +3,30 @@ package variable import ( "testing" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/listing" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/testserver" + "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestResolveServicePrincipal_ResolveSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockServicePrincipalsV2API() - iterator := listing.SliceIterator[iam.ServicePrincipal]([]iam.ServicePrincipal{ - { - ApplicationId: "5678", - }, + server := testserver.New(t) + server.Handle("GET", "/api/2.0/preview/scim/v2/ServicePrincipals", func(req testserver.Request) any { + assert.Equal(t, "displayName eq 'service-principal'", req.URL.Query().Get("filter")) + return map[string]any{"Resources": []map[string]any{{"applicationId": "5678"}}} }) - api.EXPECT(). - List(mock.Anything, iam.ListServicePrincipalsRequest{ - Filter: "displayName eq 'service-principal'", - }). - Return(&iterator) - - ctx := t.Context() l := resolveServicePrincipal{name: "service-principal"} - result, err := l.Resolve(ctx, m.WorkspaceClient) + result, err := l.Resolve(t.Context(), newServerClients(t, server)) require.NoError(t, err) assert.Equal(t, "5678", result) } func TestResolveServicePrincipal_ResolveNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockServicePrincipalsV2API() - iterator := listing.SliceIterator[iam.ServicePrincipal]([]iam.ServicePrincipal{}) - api.EXPECT(). - List(mock.Anything, iam.ListServicePrincipalsRequest{ - Filter: "displayName eq 'service-principal'", - }). - Return(&iterator) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/preview/scim/v2/ServicePrincipals": map[string]any{}, + }) l := resolveServicePrincipal{name: "service-principal"} - _, err := l.Resolve(ctx, m.WorkspaceClient) + _, err := l.Resolve(t.Context(), w) require.ErrorContains(t, err, "service principal named \"service-principal\" does not exist") } diff --git a/bundle/config/variable/resolve_warehouse.go b/bundle/config/variable/resolve_warehouse.go index cabdb116051..6c5f16d2887 100644 --- a/bundle/config/variable/resolve_warehouse.go +++ b/bundle/config/variable/resolve_warehouse.go @@ -3,19 +3,23 @@ package variable import ( "context" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/warehouses/v1" ) type resolveWarehouse struct { name string } -func (l resolveWarehouse) Resolve(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { - entity, err := w.Warehouses.GetByName(ctx, l.name) +func (l resolveWarehouse) Resolve(ctx context.Context, w *sdkclients.Clients) (string, error) { + entity, err := findByName(w.Warehouses.ListWarehousesIter(ctx, warehouses.ListWarehousesRequest{}), l.name, "EndpointInfo", func(e *warehouses.EndpointInfo) string { + return utils.Deref(e.Name) + }) if err != nil { return "", err } - return entity.Id, nil + return utils.Deref(entity.Id), nil } func (l resolveWarehouse) String() string { diff --git a/bundle/config/variable/resolve_warehouse_test.go b/bundle/config/variable/resolve_warehouse_test.go index e528374de96..8616e17c098 100644 --- a/bundle/config/variable/resolve_warehouse_test.go +++ b/bundle/config/variable/resolve_warehouse_test.go @@ -3,43 +3,28 @@ package variable import ( "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/apierrs" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestResolveWarehouse_ResolveSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockWarehousesAPI() - api.EXPECT(). - GetByName(mock.Anything, "warehouse"). - Return(&sql.EndpointInfo{ - Id: "abcd", - }, nil) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/sql/warehouses": map[string]any{"warehouses": []map[string]any{{"id": "abcd", "name": "warehouse"}}}, + }) l := resolveWarehouse{name: "warehouse"} - result, err := l.Resolve(ctx, m.WorkspaceClient) + result, err := l.Resolve(t.Context(), w) require.NoError(t, err) assert.Equal(t, "abcd", result) } func TestResolveWarehouse_ResolveNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - api := m.GetMockWarehousesAPI() - api.EXPECT(). - GetByName(mock.Anything, "warehouse"). - Return(nil, &apierr.APIError{StatusCode: 404}) - - ctx := t.Context() + w := newTestClients(t, map[string]any{ + "GET /api/2.0/sql/warehouses": notFound(), + }) l := resolveWarehouse{name: "warehouse"} - _, err := l.Resolve(ctx, m.WorkspaceClient) - require.ErrorIs(t, err, apierr.ErrNotFound) + _, err := l.Resolve(t.Context(), w) + require.True(t, apierrs.Is(err, apierrs.ErrNotFound), "%v", err) } func TestResolveWarehouse_String(t *testing.T) { diff --git a/bundle/config/workspace.go b/bundle/config/workspace.go index 46234b14d9d..e372efc40d4 100644 --- a/bundle/config/workspace.go +++ b/bundle/config/workspace.go @@ -8,10 +8,9 @@ import ( "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/databrickscfg" "github.com/databricks/cli/libs/liteswap" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/iam" ) // Workspace defines configurables at the workspace level. @@ -89,15 +88,7 @@ type User struct { // Can be used as a prefix for resources that use their name as part of their URL (e.g. Apps, Database Instances) DomainFriendlyName string `json:"domain_friendly_name,omitempty" bundle:"readonly"` - *iam.User -} - -func (s *User) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s User) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) + *scim.User } func (w *Workspace) Config(ctx context.Context) *config.Config { @@ -170,7 +161,7 @@ func (w *Workspace) NormalizeHostURL() { } } -func (w *Workspace) Client(ctx context.Context) (*databricks.WorkspaceClient, error) { +func (w *Workspace) Client(ctx context.Context) (*sdkclients.Clients, error) { // Extract query parameters (?o=, ?a=) from the host URL before building // the SDK config. This ensures workspace_id and account_id are available // for profile resolution during EnsureResolved(). @@ -212,5 +203,5 @@ func (w *Workspace) Client(ctx context.Context) (*databricks.WorkspaceClient, er } } - return databricks.NewWorkspaceClient((*databricks.Config)(cfg)) + return sdkclients.New(ctx, cfg) } diff --git a/bundle/deploy/check_dashboards_modified_remotely.go b/bundle/deploy/check_dashboards_modified_remotely.go index d685f7ebeb6..4059976bd8e 100644 --- a/bundle/deploy/check_dashboards_modified_remotely.go +++ b/bundle/deploy/check_dashboards_modified_remotely.go @@ -5,6 +5,9 @@ import ( "fmt" "strings" + "github.com/databricks/cli/libs/utils" + sdklakeview "github.com/databricks/sdk-go/lakeview/v1" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/agent" "github.com/databricks/cli/libs/diag" @@ -74,7 +77,7 @@ func (l *checkDashboardsModifiedRemotely) Apply(ctx context.Context, b *bundle.B path := structpath.NewPath(nil, "resources", "dashboards", dashboard.Name) loc := b.Config.GetLocationOf(path) - actual, err := b.WorkspaceClient(ctx).Lakeview.GetByDashboardId(ctx, dashboard.ID) + actual, err := b.WorkspaceClient(ctx).Lakeview.GetDashboard(ctx, sdklakeview.GetDashboardRequest{DashboardId: new(dashboard.ID)}) if err != nil { diags = diags.Append(diag.Diagnostic{ Severity: diag.Error, @@ -87,7 +90,7 @@ func (l *checkDashboardsModifiedRemotely) Apply(ctx context.Context, b *bundle.B } // If the ETag is the same, the dashboard has not been modified. - if actual.Etag == dashboard.ETag { + if utils.Deref(actual.Etag) == dashboard.ETag { continue } diff --git a/bundle/deploy/check_dashboards_modified_remotely_test.go b/bundle/deploy/check_dashboards_modified_remotely_test.go index 797fff59669..5f5c8eafbef 100644 --- a/bundle/deploy/check_dashboards_modified_remotely_test.go +++ b/bundle/deploy/check_dashboards_modified_remotely_test.go @@ -2,7 +2,6 @@ package deploy import ( "encoding/json" - "errors" "path/filepath" "testing" @@ -10,11 +9,10 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/direct/dstate" + "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/dashboards" + "github.com/databricks/cli/libs/testserver" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" ) func mockDashboardBundle(t *testing.T) *bundle.Bundle { @@ -68,17 +66,15 @@ func TestCheckDashboardsModifiedRemotely_ExistingStateNoChange(t *testing.T) { b := mockDashboardBundle(t) writeFakeDashboardState(t, b) - // Mock the call to the API. - m := mocks.NewMockWorkspaceClient(t) - dashboardsAPI := m.GetMockLakeviewAPI() - dashboardsAPI.EXPECT(). - GetByDashboardId(mock.Anything, "id1"). - Return(&dashboards.Dashboard{ - DisplayName: "My Special Dashboard", - Etag: "1000", - }, nil). - Once() - b.SetWorkpaceClient(m.WorkspaceClient) + // Serve the dashboard read by the check. + w, server := bundletest.NewClients(t) + calls := 0 + server.Handle("GET", "/api/2.0/lakeview/dashboards/id1", func(testserver.Request) any { + calls++ + return map[string]string{"dashboard_id": "id1", "display_name": "My Special Dashboard", "etag": "1000"} + }) + b.SetWorkpaceClient(w) + defer func() { assert.Equal(t, 1, calls) }() // No changes, so no diags. diags := bundle.Apply(ctx, b, CheckDashboardsModifiedRemotely(false)) @@ -91,17 +87,15 @@ func TestCheckDashboardsModifiedRemotely_ExistingStateChange(t *testing.T) { b := mockDashboardBundle(t) writeFakeDashboardState(t, b) - // Mock the call to the API. - m := mocks.NewMockWorkspaceClient(t) - dashboardsAPI := m.GetMockLakeviewAPI() - dashboardsAPI.EXPECT(). - GetByDashboardId(mock.Anything, "id1"). - Return(&dashboards.Dashboard{ - DisplayName: "My Special Dashboard", - Etag: "1234", - }, nil). - Once() - b.SetWorkpaceClient(m.WorkspaceClient) + // Serve the dashboard read by the check. + w, server := bundletest.NewClients(t) + calls := 0 + server.Handle("GET", "/api/2.0/lakeview/dashboards/id1", func(testserver.Request) any { + calls++ + return map[string]string{"dashboard_id": "id1", "display_name": "My Special Dashboard", "etag": "1234"} + }) + b.SetWorkpaceClient(w) + defer func() { assert.Equal(t, 1, calls) }() // The dashboard has changed, so expect an error. diags := bundle.Apply(ctx, b, CheckDashboardsModifiedRemotely(false)) @@ -117,14 +111,15 @@ func TestCheckDashboardsModifiedRemotely_ExistingStateFailureToGet(t *testing.T) b := mockDashboardBundle(t) writeFakeDashboardState(t, b) - // Mock the call to the API. - m := mocks.NewMockWorkspaceClient(t) - dashboardsAPI := m.GetMockLakeviewAPI() - dashboardsAPI.EXPECT(). - GetByDashboardId(mock.Anything, "id1"). - Return(nil, errors.New("failure")). - Once() - b.SetWorkpaceClient(m.WorkspaceClient) + // Serve the dashboard read by the check. + w, server := bundletest.NewClients(t) + calls := 0 + server.Handle("GET", "/api/2.0/lakeview/dashboards/id1", func(testserver.Request) any { + calls++ + return testserver.Response{StatusCode: 500, Body: map[string]string{"error_code": "INTERNAL_ERROR", "message": "failure"}} + }) + b.SetWorkpaceClient(w) + defer func() { assert.Equal(t, 1, calls) }() // Unable to get the dashboard, so expect an error. diags := bundle.Apply(ctx, b, CheckDashboardsModifiedRemotely(false)) @@ -140,17 +135,15 @@ func TestCheckDashboardsModifiedRemotely_ExistingStateChangePlanMode(t *testing. b := mockDashboardBundle(t) writeFakeDashboardState(t, b) - // Mock the call to the API. - m := mocks.NewMockWorkspaceClient(t) - dashboardsAPI := m.GetMockLakeviewAPI() - dashboardsAPI.EXPECT(). - GetByDashboardId(mock.Anything, "id1"). - Return(&dashboards.Dashboard{ - DisplayName: "My Special Dashboard", - Etag: "1234", - }, nil). - Once() - b.SetWorkpaceClient(m.WorkspaceClient) + // Serve the dashboard read by the check. + w, server := bundletest.NewClients(t) + calls := 0 + server.Handle("GET", "/api/2.0/lakeview/dashboards/id1", func(testserver.Request) any { + calls++ + return map[string]string{"dashboard_id": "id1", "display_name": "My Special Dashboard", "etag": "1234"} + }) + b.SetWorkpaceClient(w) + defer func() { assert.Equal(t, 1, calls) }() // The dashboard has changed, but in plan mode expect a warning instead of an error. diags := bundle.Apply(ctx, b, CheckDashboardsModifiedRemotely(true)) diff --git a/bundle/deploy/filer.go b/bundle/deploy/filer.go index 8d7b2a57636..981b4041977 100644 --- a/bundle/deploy/filer.go +++ b/bundle/deploy/filer.go @@ -9,7 +9,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/filer" "github.com/databricks/cli/libs/retry" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" ) // FilerFactory is a function that returns a filer.Filer. @@ -18,7 +18,7 @@ type FilerFactory func(ctx context.Context, b *bundle.Bundle) (filer.Filer, erro type stateFiler struct { filer filer.Filer - workspaceClient *databricks.WorkspaceClient + workspaceClient *sdkclients.Clients root filer.WorkspaceRootPath } diff --git a/bundle/deploy/files/delete.go b/bundle/deploy/files/delete.go index c30262f79ce..b9e5db86635 100644 --- a/bundle/deploy/files/delete.go +++ b/bundle/deploy/files/delete.go @@ -12,7 +12,7 @@ import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/sync" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/workspaceapi" ) type delete struct{} @@ -22,7 +22,7 @@ func (m *delete) Name() string { } func (m *delete) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { - err := b.WorkspaceClient(ctx).Workspace.Delete(ctx, workspace.Delete{ + err := b.WorkspaceClient(ctx).Workspace.Delete(ctx, workspaceapi.Delete{ Path: b.Config.Workspace.RootPath, Recursive: true, }) @@ -49,7 +49,7 @@ func removeBundleNameDir(ctx context.Context, b *bundle.Bundle) { } dir := path.Dir(b.Config.Workspace.RootPath) - err := b.WorkspaceClient(ctx).Workspace.Delete(ctx, workspace.Delete{Path: dir}) + err := b.WorkspaceClient(ctx).Workspace.Delete(ctx, workspaceapi.Delete{Path: dir}) if err != nil { log.Infof(ctx, "Leaving %s in place: %s", dir, err) } diff --git a/bundle/deploy/lock/acquire.go b/bundle/deploy/lock/acquire.go index bf8b91212dd..63f1abc5466 100644 --- a/bundle/deploy/lock/acquire.go +++ b/bundle/deploy/lock/acquire.go @@ -5,12 +5,14 @@ import ( "errors" "io/fs" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/permissions" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/locker" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go/apierr" ) // maxChildNodeSizeExceeded is the error_code the Workspace API returns (as a 403) @@ -31,7 +33,7 @@ func (m *acquire) Name() string { } func (m *acquire) init(ctx context.Context, b *bundle.Bundle) error { - user := b.Config.Workspace.CurrentUser.UserName + user := utils.Deref(b.Config.Workspace.CurrentUser.UserName) dir := b.Config.Workspace.StatePath l, err := locker.CreateLocker(user, dir, b.WorkspaceClient(ctx)) if err != nil { @@ -65,7 +67,7 @@ func (m *acquire) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics // This check must precede the fs.ErrPermission branch below because the API // reports the child-node limit as a 403, which the filer maps to that error. if m.goal == GoalDestroy && force { - if aerr, ok := errors.AsType[*apierr.APIError](err); ok && aerr.ErrorCode == maxChildNodeSizeExceeded { + if apierrs.ErrorCode(err) == maxChildNodeSizeExceeded { log.Warnf(ctx, "Proceeding with destroy without a deployment lock: %v", err) return nil } diff --git a/bundle/deploy/metadata/annotate_deployment_version.go b/bundle/deploy/metadata/annotate_deployment_version.go index 8a77250a3c4..2b5916927ea 100644 --- a/bundle/deploy/metadata/annotate_deployment_version.go +++ b/bundle/deploy/metadata/annotate_deployment_version.go @@ -26,11 +26,11 @@ func (m *annotateDeployment) Name() string { func (m *annotateDeployment) Apply(_ context.Context, b *bundle.Bundle) diag.Diagnostics { for _, job := range b.Config.Resources.Jobs { // Deployment is set by AnnotateJobs, which runs during initialize. - job.Deployment.DeploymentId = m.deploymentID + job.Deployment.DeploymentId = new(m.deploymentID) } for _, pipeline := range b.Config.Resources.Pipelines { - pipeline.Deployment.DeploymentId = m.deploymentID + pipeline.Deployment.DeploymentId = new(m.deploymentID) } return nil @@ -54,11 +54,11 @@ func (m *annotateDeploymentVersion) Apply(_ context.Context, b *bundle.Bundle) d versionID := strconv.Itoa(m.version) for _, job := range b.Config.Resources.Jobs { - job.Deployment.VersionId = versionID + job.Deployment.VersionId = new(versionID) } for _, pipeline := range b.Config.Resources.Pipelines { - pipeline.Deployment.VersionId = versionID + pipeline.Deployment.VersionId = new(versionID) } return nil diff --git a/bundle/deploy/metadata/annotate_deployment_version_test.go b/bundle/deploy/metadata/annotate_deployment_version_test.go index 297ba95f8ee..1704e559058 100644 --- a/bundle/deploy/metadata/annotate_deployment_version_test.go +++ b/bundle/deploy/metadata/annotate_deployment_version_test.go @@ -3,11 +3,13 @@ package metadata import ( "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -19,14 +21,14 @@ func TestAnnotateDeploymentVersion(t *testing.T) { Jobs: map[string]*resources.Job{ "my-job": { JobSettings: jobs.JobSettings{ - Deployment: &jobs.JobDeployment{Kind: jobs.JobDeploymentKindBundle}, + Deployment: &jobs.JobDeployment{Kind: jobs.JobDeployment_DeploymentKind_Bundle}, }, }, }, Pipelines: map[string]*resources.Pipeline{ "my-pipeline": { - CreatePipeline: pipelines.CreatePipeline{ - Deployment: &pipelines.PipelineDeployment{Kind: pipelines.DeploymentKindBundle}, + CreatePipelineRequest: pipelines.CreatePipelineRequest{ + Deployment: &pipelines.PipelineDeployment{Kind: pipelines.DeploymentKind_Bundle}, }, }, }, @@ -38,13 +40,13 @@ func TestAnnotateDeploymentVersion(t *testing.T) { require.NoError(t, diags.Error()) job := b.Config.Resources.Jobs["my-job"].Deployment - assert.Equal(t, "dep-123", job.DeploymentId) - assert.Equal(t, "7", job.VersionId) + assert.Equal(t, "dep-123", utils.Deref(job.DeploymentId)) + assert.Equal(t, "7", utils.Deref(job.VersionId)) // The kind set by AnnotateJobs is preserved. - assert.Equal(t, jobs.JobDeploymentKindBundle, job.Kind) + assert.Equal(t, jobs.JobDeployment_DeploymentKind_Bundle, job.Kind) pipeline := b.Config.Resources.Pipelines["my-pipeline"].Deployment - assert.Equal(t, "dep-123", pipeline.DeploymentId) - assert.Equal(t, "7", pipeline.VersionId) - assert.Equal(t, pipelines.DeploymentKindBundle, pipeline.Kind) + assert.Equal(t, "dep-123", utils.Deref(pipeline.DeploymentId)) + assert.Equal(t, "7", utils.Deref(pipeline.VersionId)) + assert.Equal(t, pipelines.DeploymentKind_Bundle, pipeline.Kind) } diff --git a/bundle/deploy/metadata/annotate_jobs.go b/bundle/deploy/metadata/annotate_jobs.go index 1537f6ae8f1..1ef6d3600f3 100644 --- a/bundle/deploy/metadata/annotate_jobs.go +++ b/bundle/deploy/metadata/annotate_jobs.go @@ -9,7 +9,7 @@ import ( "github.com/databricks/cli/bundle/env" "github.com/databricks/cli/libs/dbr" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" ) type annotateJobs struct{} @@ -25,19 +25,19 @@ func (m *annotateJobs) Name() string { func (m *annotateJobs) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { for _, job := range b.Config.Resources.Jobs { job.Deployment = &jobs.JobDeployment{ - Kind: jobs.JobDeploymentKindBundle, - MetadataFilePath: metadataFilePath(b), + Kind: jobs.JobDeployment_DeploymentKind_Bundle, + MetadataFilePath: new(metadataFilePath(b)), } isDatabricksWorkspace := dbr.RunsOnRuntime(ctx) && strings.HasPrefix(b.SyncRootPath, "/Workspace/") _, experimentalYamlSyncEnabled := env.ExperimentalYamlSync(ctx) if isDatabricksWorkspace && experimentalYamlSyncEnabled && b.Config.Bundle.Mode == config.Development { - job.EditMode = jobs.JobEditModeEditable + job.EditMode = jobs.JobEditMode_Editable } else { - job.EditMode = jobs.JobEditModeUiLocked + job.EditMode = jobs.JobEditMode_UiLocked } - job.Format = jobs.FormatMultiTask + job.Format = jobs.Format_MultiTask } return nil diff --git a/bundle/deploy/metadata/annotate_jobs_test.go b/bundle/deploy/metadata/annotate_jobs_test.go index 767559b19db..90156867408 100644 --- a/bundle/deploy/metadata/annotate_jobs_test.go +++ b/bundle/deploy/metadata/annotate_jobs_test.go @@ -3,12 +3,13 @@ package metadata import ( "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/dbr" "github.com/databricks/cli/libs/env" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -23,12 +24,12 @@ func TestAnnotateJobsMutator(t *testing.T) { Jobs: map[string]*resources.Job{ "my-job-1": { JobSettings: jobs.JobSettings{ - Name: "My Job One", + Name: new("My Job One"), }, }, "my-job-2": { JobSettings: jobs.JobSettings{ - Name: "My Job Two", + Name: new("My Job Two"), }, }, }, @@ -44,21 +45,21 @@ func TestAnnotateJobsMutator(t *testing.T) { assert.Equal(t, &jobs.JobDeployment{ - Kind: jobs.JobDeploymentKindBundle, - MetadataFilePath: "/a/b/c/metadata.json", + Kind: jobs.JobDeployment_DeploymentKind_Bundle, + MetadataFilePath: new("/a/b/c/metadata.json"), }, b.Config.Resources.Jobs["my-job-1"].Deployment) - assert.Equal(t, jobs.JobEditModeUiLocked, b.Config.Resources.Jobs["my-job-1"].EditMode) - assert.Equal(t, jobs.FormatMultiTask, b.Config.Resources.Jobs["my-job-1"].Format) + assert.Equal(t, jobs.JobEditMode_UiLocked, b.Config.Resources.Jobs["my-job-1"].EditMode) + assert.Equal(t, jobs.Format_MultiTask, b.Config.Resources.Jobs["my-job-1"].Format) assert.Equal(t, &jobs.JobDeployment{ - Kind: jobs.JobDeploymentKindBundle, - MetadataFilePath: "/a/b/c/metadata.json", + Kind: jobs.JobDeployment_DeploymentKind_Bundle, + MetadataFilePath: new("/a/b/c/metadata.json"), }, b.Config.Resources.Jobs["my-job-2"].Deployment) - assert.Equal(t, jobs.JobEditModeUiLocked, b.Config.Resources.Jobs["my-job-2"].EditMode) - assert.Equal(t, jobs.FormatMultiTask, b.Config.Resources.Jobs["my-job-2"].Format) + assert.Equal(t, jobs.JobEditMode_UiLocked, b.Config.Resources.Jobs["my-job-2"].EditMode) + assert.Equal(t, jobs.Format_MultiTask, b.Config.Resources.Jobs["my-job-2"].Format) } func TestAnnotateJobsMutatorJobWithoutSettings(t *testing.T) { @@ -93,7 +94,7 @@ func TestAnnotateJobsWorkspaceWithFlag(t *testing.T) { Jobs: map[string]*resources.Job{ "my-job": { JobSettings: jobs.JobSettings{ - Name: "My Job", + Name: new("My Job"), }, }, }, @@ -108,8 +109,8 @@ func TestAnnotateJobsWorkspaceWithFlag(t *testing.T) { diags := AnnotateJobs().Apply(ctx, b) require.NoError(t, diags.Error()) - assert.Equal(t, jobs.JobEditModeEditable, b.Config.Resources.Jobs["my-job"].EditMode) - assert.Equal(t, jobs.FormatMultiTask, b.Config.Resources.Jobs["my-job"].Format) + assert.Equal(t, jobs.JobEditMode_Editable, b.Config.Resources.Jobs["my-job"].EditMode) + assert.Equal(t, jobs.Format_MultiTask, b.Config.Resources.Jobs["my-job"].Format) } func TestAnnotateJobsWorkspaceNonDevelopment(t *testing.T) { @@ -126,7 +127,7 @@ func TestAnnotateJobsWorkspaceNonDevelopment(t *testing.T) { Jobs: map[string]*resources.Job{ "my-job": { JobSettings: jobs.JobSettings{ - Name: "My Job", + Name: new("My Job"), }, }, }, @@ -141,8 +142,8 @@ func TestAnnotateJobsWorkspaceNonDevelopment(t *testing.T) { diags := AnnotateJobs().Apply(ctx, b) require.NoError(t, diags.Error()) - assert.Equal(t, jobs.JobEditModeUiLocked, b.Config.Resources.Jobs["my-job"].EditMode) - assert.Equal(t, jobs.FormatMultiTask, b.Config.Resources.Jobs["my-job"].Format) + assert.Equal(t, jobs.JobEditMode_UiLocked, b.Config.Resources.Jobs["my-job"].EditMode) + assert.Equal(t, jobs.Format_MultiTask, b.Config.Resources.Jobs["my-job"].Format) } func TestAnnotateJobsWorkspaceWithoutFlag(t *testing.T) { @@ -156,7 +157,7 @@ func TestAnnotateJobsWorkspaceWithoutFlag(t *testing.T) { Jobs: map[string]*resources.Job{ "my-job": { JobSettings: jobs.JobSettings{ - Name: "My Job", + Name: new("My Job"), }, }, }, @@ -170,8 +171,8 @@ func TestAnnotateJobsWorkspaceWithoutFlag(t *testing.T) { diags := AnnotateJobs().Apply(ctx, b) require.NoError(t, diags.Error()) - assert.Equal(t, jobs.JobEditModeUiLocked, b.Config.Resources.Jobs["my-job"].EditMode) - assert.Equal(t, jobs.FormatMultiTask, b.Config.Resources.Jobs["my-job"].Format) + assert.Equal(t, jobs.JobEditMode_UiLocked, b.Config.Resources.Jobs["my-job"].EditMode) + assert.Equal(t, jobs.Format_MultiTask, b.Config.Resources.Jobs["my-job"].Format) } func TestAnnotateJobsNonWorkspaceWithFlag(t *testing.T) { @@ -185,7 +186,7 @@ func TestAnnotateJobsNonWorkspaceWithFlag(t *testing.T) { Jobs: map[string]*resources.Job{ "my-job": { JobSettings: jobs.JobSettings{ - Name: "My Job", + Name: new("My Job"), }, }, }, @@ -200,6 +201,6 @@ func TestAnnotateJobsNonWorkspaceWithFlag(t *testing.T) { diags := AnnotateJobs().Apply(ctx, b) require.NoError(t, diags.Error()) - assert.Equal(t, jobs.JobEditModeUiLocked, b.Config.Resources.Jobs["my-job"].EditMode) - assert.Equal(t, jobs.FormatMultiTask, b.Config.Resources.Jobs["my-job"].Format) + assert.Equal(t, jobs.JobEditMode_UiLocked, b.Config.Resources.Jobs["my-job"].EditMode) + assert.Equal(t, jobs.Format_MultiTask, b.Config.Resources.Jobs["my-job"].Format) } diff --git a/bundle/deploy/metadata/annotate_pipelines.go b/bundle/deploy/metadata/annotate_pipelines.go index 284766d8971..699776dcee7 100644 --- a/bundle/deploy/metadata/annotate_pipelines.go +++ b/bundle/deploy/metadata/annotate_pipelines.go @@ -5,7 +5,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" ) type annotatePipelines struct{} @@ -21,8 +21,8 @@ func (m *annotatePipelines) Name() string { func (m *annotatePipelines) Apply(_ context.Context, b *bundle.Bundle) diag.Diagnostics { for _, pipeline := range b.Config.Resources.Pipelines { pipeline.Deployment = &pipelines.PipelineDeployment{ - Kind: pipelines.DeploymentKindBundle, - MetadataFilePath: metadataFilePath(b), + Kind: pipelines.DeploymentKind_Bundle, + MetadataFilePath: new(metadataFilePath(b)), } } diff --git a/bundle/deploy/metadata/annotate_pipelines_test.go b/bundle/deploy/metadata/annotate_pipelines_test.go index 6a96248d016..f837003d780 100644 --- a/bundle/deploy/metadata/annotate_pipelines_test.go +++ b/bundle/deploy/metadata/annotate_pipelines_test.go @@ -3,10 +3,11 @@ package metadata import ( "testing" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -20,13 +21,13 @@ func TestAnnotatePipelinesMutator(t *testing.T) { Resources: config.Resources{ Pipelines: map[string]*resources.Pipeline{ "my-pipeline-1": { - CreatePipeline: pipelines.CreatePipeline{ - Name: "My Pipeline One", + CreatePipelineRequest: pipelines.CreatePipelineRequest{ + Name: new("My Pipeline One"), }, }, "my-pipeline-2": { - CreatePipeline: pipelines.CreatePipeline{ - Name: "My Pipeline Two", + CreatePipelineRequest: pipelines.CreatePipelineRequest{ + Name: new("My Pipeline Two"), }, }, }, @@ -39,15 +40,15 @@ func TestAnnotatePipelinesMutator(t *testing.T) { assert.Equal(t, &pipelines.PipelineDeployment{ - Kind: pipelines.DeploymentKindBundle, - MetadataFilePath: "/a/b/c/metadata.json", + Kind: pipelines.DeploymentKind_Bundle, + MetadataFilePath: new("/a/b/c/metadata.json"), }, b.Config.Resources.Pipelines["my-pipeline-1"].Deployment) assert.Equal(t, &pipelines.PipelineDeployment{ - Kind: pipelines.DeploymentKindBundle, - MetadataFilePath: "/a/b/c/metadata.json", + Kind: pipelines.DeploymentKind_Bundle, + MetadataFilePath: new("/a/b/c/metadata.json"), }, b.Config.Resources.Pipelines["my-pipeline-2"].Deployment) } diff --git a/bundle/deploy/metadata/compute_test.go b/bundle/deploy/metadata/compute_test.go index cb163914bdb..c346fa9ddad 100644 --- a/bundle/deploy/metadata/compute_test.go +++ b/bundle/deploy/metadata/compute_test.go @@ -4,6 +4,9 @@ import ( "runtime" "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" @@ -11,8 +14,6 @@ import ( "github.com/databricks/cli/bundle/metadata" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/vfs" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -41,27 +42,27 @@ func TestComputeMetadataMutator(t *testing.T) { "my-job-1": { ID: "1111", JobSettings: jobs.JobSettings{ - Name: "My Job One", + Name: new("My Job One"), }, }, "my-job-2": { ID: "2222", JobSettings: jobs.JobSettings{ - Name: "My Job Two", + Name: new("My Job Two"), }, }, }, Pipelines: map[string]*resources.Pipeline{ "my-pipeline-1": { ID: "3333", - CreatePipeline: pipelines.CreatePipeline{ - Name: "My Pipeline One", + CreatePipelineRequest: pipelines.CreatePipelineRequest{ + Name: new("My Pipeline One"), }, }, "my-pipeline-2": { ID: "4444", - CreatePipeline: pipelines.CreatePipeline{ - Name: "My Pipeline Two", + CreatePipelineRequest: pipelines.CreatePipelineRequest{ + Name: new("My Pipeline Two"), }, }, }, diff --git a/bundle/deploy/resource_path_mkdir.go b/bundle/deploy/resource_path_mkdir.go index 5c41a270a80..a496e54676e 100644 --- a/bundle/deploy/resource_path_mkdir.go +++ b/bundle/deploy/resource_path_mkdir.go @@ -2,11 +2,10 @@ package deploy import ( "context" - "errors" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/apierr" ) func ResourcePathMkdir() bundle.Mutator { @@ -29,7 +28,7 @@ func (m *resourcePathMkdir) Apply(ctx context.Context, b *bundle.Bundle) diag.Di // Optimisitcally create the resource path. If it already exists ignore the error. err := w.Workspace.MkdirsByPath(ctx, b.Config.Workspace.ResourcePath) - if aerr, ok := errors.AsType[*apierr.APIError](err); ok && aerr.ErrorCode == "RESOURCE_ALREADY_EXISTS" { + if apierrs.ErrorCode(err) == "RESOURCE_ALREADY_EXISTS" { return nil } return diag.FromErr(err) diff --git a/bundle/deploy/snapshot/path_test.go b/bundle/deploy/snapshot/path_test.go index 54407a98e20..fc3784894f7 100644 --- a/bundle/deploy/snapshot/path_test.go +++ b/bundle/deploy/snapshot/path_test.go @@ -8,13 +8,14 @@ import ( "slices" "testing" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deploy/snapshot" libsnapshot "github.com/databricks/cli/libs/snapshot" "github.com/databricks/cli/libs/vfs" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -43,7 +44,7 @@ func makeBundleWithFiles(t *testing.T, files map[string]string) *bundle.Bundle { Workspace: config.Workspace{CurrentUser: &config.User{}}, }, } - b.Config.Workspace.CurrentUser.User = &iam.User{UserName: "tester@example.com"} + b.Config.Workspace.CurrentUser.User = &scim.User{UserName: new("tester@example.com")} return b } diff --git a/bundle/deploy/snapshot/upload.go b/bundle/deploy/snapshot/upload.go index 3b7d7d1fc1a..a208b92d2e2 100644 --- a/bundle/deploy/snapshot/upload.go +++ b/bundle/deploy/snapshot/upload.go @@ -8,6 +8,8 @@ import ( "os" "path/filepath" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" @@ -143,7 +145,7 @@ func BundleID(b *bundle.Bundle) string { // top-level permissions section of the bundle config. func BuildACL(b *bundle.Bundle) []snapshot.ACLEntry { acl := []snapshot.ACLEntry{ - {UserName: b.Config.Workspace.CurrentUser.UserName, PermissionLevel: "CAN_READ"}, + {UserName: utils.Deref(b.Config.Workspace.CurrentUser.UserName), PermissionLevel: "CAN_READ"}, } for _, p := range b.Config.Permissions { acl = append(acl, snapshot.ACLEntry{ diff --git a/bundle/deploy/snapshot/upload_test.go b/bundle/deploy/snapshot/upload_test.go index 5bace57e2be..ac0f2b82308 100644 --- a/bundle/deploy/snapshot/upload_test.go +++ b/bundle/deploy/snapshot/upload_test.go @@ -3,12 +3,13 @@ package snapshot_test import ( "testing" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deploy/snapshot" libsnapshot "github.com/databricks/cli/libs/snapshot" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/stretchr/testify/assert" ) @@ -21,7 +22,7 @@ func bundleWithPermissions(currentUser string, perms []resources.Permission) *bu Permissions: perms, }, } - b.Config.Workspace.CurrentUser.User = &iam.User{UserName: currentUser} + b.Config.Workspace.CurrentUser.User = &scim.User{UserName: new(currentUser)} return b } diff --git a/bundle/deploy/snapshot/upload_warning_test.go b/bundle/deploy/snapshot/upload_warning_test.go index 85ff5a21b51..5fc0162bfe1 100644 --- a/bundle/deploy/snapshot/upload_warning_test.go +++ b/bundle/deploy/snapshot/upload_warning_test.go @@ -3,33 +3,34 @@ package snapshot import ( "context" "fmt" - "math" "os" "path/filepath" "testing" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/logdiag" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/testserver" "github.com/databricks/cli/libs/vfs" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/iam" + sdkconfig "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func setupTestClient(t *testing.T) *databricks.WorkspaceClient { +func setupTestClient(t *testing.T) *sdkclients.Clients { t.Helper() server := testserver.New(t) testserver.AddDefaultHandlers(server) - client, err := databricks.NewWorkspaceClient(&databricks.Config{ - Host: server.URL, - Token: "testtoken", - RateLimitPerSecond: math.MaxInt, + client, err := sdkclients.New(t.Context(), &sdkconfig.Config{ + Host: server.URL, + Token: "testtoken", + Loaders: []sdkconfig.Loader{sdkconfig.ConfigAttributes}, }) require.NoError(t, err) return client @@ -55,7 +56,7 @@ func makeBundle(t *testing.T, nFiles int) *bundle.Bundle { Sync: config.Sync{Paths: []string{"."}}, Workspace: config.Workspace{ CurrentUser: &config.User{ - User: &iam.User{UserName: "test@example.test"}, + User: &scim.User{UserName: new("test@example.test")}, }, }, }, diff --git a/bundle/deploy/state_pull_test.go b/bundle/deploy/state_pull_test.go index e30aeaa3237..bda1dbcd453 100644 --- a/bundle/deploy/state_pull_test.go +++ b/bundle/deploy/state_pull_test.go @@ -9,6 +9,8 @@ import ( "os" "testing" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/deploy/files" @@ -17,7 +19,6 @@ import ( "github.com/databricks/cli/libs/filer" "github.com/databricks/cli/libs/sync" "github.com/databricks/cli/libs/vfs" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) @@ -74,8 +75,8 @@ func testStatePull(t *testing.T, opts statePullOpts) { Workspace: config.Workspace{ StatePath: "/state", CurrentUser: &config.User{ - User: &iam.User{ - UserName: "test-user", + User: &scim.User{ + UserName: new("test-user"), }, }, }, diff --git a/bundle/deploy/state_update_test.go b/bundle/deploy/state_update_test.go index d4b24d85b33..aa7ea7b1434 100644 --- a/bundle/deploy/state_update_test.go +++ b/bundle/deploy/state_update_test.go @@ -5,13 +5,14 @@ import ( "os" "testing" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/internal/build" "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/fileset" "github.com/databricks/cli/libs/vfs" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/google/uuid" "github.com/stretchr/testify/require" ) @@ -35,8 +36,8 @@ func setupBundleForStateUpdate(t *testing.T) *bundle.Bundle { StatePath: "/state", FilePath: "/files", CurrentUser: &config.User{ - User: &iam.User{ - UserName: "test-user", + User: &scim.User{ + UserName: new("test-user"), }, }, }, diff --git a/bundle/direct/apply.go b/bundle/direct/apply.go index 57367883c6c..8df11a70184 100644 --- a/bundle/direct/apply.go +++ b/bundle/direct/apply.go @@ -8,12 +8,13 @@ import ( "reflect" "strings" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/bundle/deployplan" "github.com/databricks/cli/bundle/direct/dresources" "github.com/databricks/cli/bundle/direct/dstate" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/retry" - "github.com/databricks/databricks-sdk-go/apierr" ) func (d *DeploymentUnit) withResourceKey(ctx context.Context) context.Context { @@ -120,7 +121,7 @@ func (d *DeploymentUnit) Recreate(ctx context.Context, db *dstate.DeploymentStat _, err = retry.With(ctx, retry.IsTransient, func() (struct{}, error) { return struct{}{}, d.Adapter.DoDelete(ctx, oldID, oldState) }) - if err != nil && !apierr.IsMissing(err) && !isManagedByParent(err) { + if err != nil && !apierrs.IsMissing(err) && !isManagedByParent(err) { if !d.deleteConfirmedGone(ctx, oldID) { return fmt.Errorf("deleting old id=%s: %w", oldID, err) } @@ -145,7 +146,7 @@ func (d *DeploymentUnit) Recreate(ctx context.Context, db *dstate.DeploymentStat // RESOURCE_MAX_WAIT so a resource that opts in can bound its own poll by it. // A NotFound means the resource is gone, which is the success the wait polls for. err = d.Adapter.WaitAfterDelete(dresources.WithResourceMaxWait(ctx, d.MaxWait), oldID) - if err != nil && !apierr.IsMissing(err) { + if err != nil && !apierrs.IsMissing(err) { return fmt.Errorf("waiting after deleting id=%s: %w", oldID, err) } @@ -256,12 +257,12 @@ func (d *DeploymentUnit) Delete(ctx context.Context, db *dstate.DeploymentState, } err = d.Adapter.DoDelete(ctx, oldID, oldState) - if err != nil && !apierr.IsMissing(err) && !isManagedByParent(err) { + if err != nil && !apierrs.IsMissing(err) && !isManagedByParent(err) { // Rather than failing delete and requiring user to unbind, we perform unbind automatically there. // Some services, e.g. jobs, return 403 for missing resources if caller did not have permissions to it when job existed. // In those cases 403 hides 404. In other cases, user not having permissions to resource but having in the bundle might // mean configuration error that user is trying to fix by removing resource from their bundle. - if errors.Is(err, apierr.ErrPermissionDenied) { + if apierrs.Is(err, apierrs.ErrPermissionDenied) { log.Warnf(ctx, "Ignoring permission error when deleting %s id=%s: %s", d.ResourceKey, oldID, err) } else if d.deleteConfirmedGone(ctx, oldID) { log.Warnf(ctx, "Treating %s id=%s as already deleted despite delete error: %s", d.ResourceKey, oldID, err) @@ -287,7 +288,7 @@ func (d *DeploymentUnit) Delete(ctx context.Context, db *dstate.DeploymentState, return struct{}{}, d.Adapter.WaitAfterDelete(ctx, oldID) }) // A NotFound means the resource is gone, which is the success the wait polls for. - if err != nil && !apierr.IsMissing(err) { + if err != nil && !apierrs.IsMissing(err) { return fmt.Errorf("waiting after deleting id=%s: %w", oldID, err) } @@ -304,7 +305,7 @@ func (d *DeploymentUnit) Delete(ctx context.Context, db *dstate.DeploymentState, // apps/src/utils/AppsStatusUtils.scala) that carries no distinct SDK sentinel. func (d *DeploymentUnit) deleteConfirmedGone(ctx context.Context, id string) bool { remote, err := d.Adapter.DoRead(ctx, id) - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return true } if err != nil { diff --git a/bundle/direct/bind.go b/bundle/direct/bind.go index 9ac921b9c3c..7dec53d37cd 100644 --- a/bundle/direct/bind.go +++ b/bundle/direct/bind.go @@ -12,9 +12,9 @@ import ( "github.com/databricks/cli/bundle/direct/dresources" "github.com/databricks/cli/bundle/direct/dstate" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/structs/structaccess" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go" ) // ErrResourceAlreadyBound is returned when attempting to bind a resource @@ -61,7 +61,7 @@ type BindResult struct { // 5. Calculate plan again - this is the plan presented to the user // // Call Finalize to commit the state or Cancel to discard. -func (b *DeploymentBundle) Bind(ctx context.Context, client *databricks.WorkspaceClient, configRoot *config.Root, statePath, resourceKey, resourceID string) (*BindResult, error) { +func (b *DeploymentBundle) Bind(ctx context.Context, client *sdkclients.Clients, configRoot *config.Root, statePath, resourceKey, resourceID string) (*BindResult, error) { // Check if the resource is already managed (bound to a different ID) // The state is opened without a DMS client, so the writes below record nothing; // phases.Bind and phases.Unbind refuse to run at all when recording is enabled. diff --git a/bundle/direct/bundle_apply.go b/bundle/direct/bundle_apply.go index a673a3239c8..9d8f99e2d6d 100644 --- a/bundle/direct/bundle_apply.go +++ b/bundle/direct/bundle_apply.go @@ -12,16 +12,16 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/logdiag" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/structs/structaccess" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go" ) // Apply deploys every node in plan, respecting dependency order. When reportApplied // is set, each resource is reported as soon as it is applied, so a long deploy shows // what it has done and a failing one still reports the resources it did apply. Nodes // run in parallel, so the lines come out in completion order, which varies per run. -func (b *DeploymentBundle) Apply(ctx context.Context, client *databricks.WorkspaceClient, plan *deployplan.Plan, reportApplied bool) { +func (b *DeploymentBundle) Apply(ctx context.Context, client *sdkclients.Clients, plan *deployplan.Plan, reportApplied bool) { if plan == nil { panic("Planning is not done") } diff --git a/bundle/direct/bundle_plan.go b/bundle/direct/bundle_plan.go index 98da4f1376d..44f1dc026df 100644 --- a/bundle/direct/bundle_plan.go +++ b/bundle/direct/bundle_plan.go @@ -10,6 +10,8 @@ import ( "slices" "strings" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/deployplan" "github.com/databricks/cli/bundle/direct/dresources" @@ -20,18 +22,18 @@ import ( "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/logdiag" "github.com/databricks/cli/libs/retry" + "github.com/databricks/cli/libs/sdkclients" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/structs/structaccess" "github.com/databricks/cli/libs/structs/structdiff" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/structs/structvar" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/utils" ) var errDelayed = errors.New("must be resolved after apply") -func (b *DeploymentBundle) init(client *databricks.WorkspaceClient) error { +func (b *DeploymentBundle) init(client *sdkclients.Clients) error { if b.Adapters != nil { return nil } @@ -69,7 +71,7 @@ func ValidatePlanAgainstState(stateDB *dstate.DeploymentState, plan *deployplan. // InitForApply initializes the DeploymentBundle for applying a pre-computed plan. // StateDB must already be open for write before calling this function. -func (b *DeploymentBundle) InitForApply(ctx context.Context, client *databricks.WorkspaceClient, plan *deployplan.Plan) error { +func (b *DeploymentBundle) InitForApply(ctx context.Context, client *sdkclients.Clients, plan *deployplan.Plan) error { b.StateDB.AssertOpenedForWrite() err := b.init(client) @@ -139,13 +141,13 @@ func (b *DeploymentBundle) StampDeploymentIdForFirstVersion(deploymentID string) var stamped bool switch v := sv.Value.(type) { case *jobs.JobSettings: - if v.Deployment.DeploymentId == "" { - v.Deployment.DeploymentId = deploymentID + if utils.Deref(v.Deployment.DeploymentId) == "" { + v.Deployment.DeploymentId = new(deploymentID) stamped = true } case *dresources.PipelineState: - if v.Deployment.DeploymentId == "" { - v.Deployment.DeploymentId = deploymentID + if utils.Deref(v.Deployment.DeploymentId) == "" { + v.Deployment.DeploymentId = new(deploymentID) stamped = true } } @@ -160,7 +162,7 @@ func (b *DeploymentBundle) StampDeploymentIdForFirstVersion(deploymentID string) // CalculatePlan computes the deployment plan by comparing local config against remote state. // StateDB must already be open for read before calling this function. -func (b *DeploymentBundle) CalculatePlan(ctx context.Context, client *databricks.WorkspaceClient, configRoot *config.Root) (*deployplan.Plan, error) { +func (b *DeploymentBundle) CalculatePlan(ctx context.Context, client *sdkclients.Clients, configRoot *config.Root) (*deployplan.Plan, error) { b.StateDB.AssertOpenedForRead() err := b.init(client) @@ -241,7 +243,7 @@ func (b *DeploymentBundle) CalculatePlan(ctx context.Context, client *databricks return adapter.DoRead(ctx, id) }) if err != nil { - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { // The resource is already deleted remotely. Keep the Delete entry so // that applying it removes the stale state entry, but mark it Gone so // apply skips the delete call and prompts don't list it as a deletion. @@ -319,7 +321,7 @@ func (b *DeploymentBundle) CalculatePlan(ctx context.Context, client *databricks return adapter.DoRead(ctx, dbentry.ID) }) if err != nil { - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { remoteState = nil } else { logdiag.LogError(ctx, fmt.Errorf("%s: reading id=%q: %w", errorPrefix, dbentry.ID, err)) diff --git a/bundle/direct/bundle_plan_test.go b/bundle/direct/bundle_plan_test.go index 2d051dc21b9..8b8c6d93381 100644 --- a/bundle/direct/bundle_plan_test.go +++ b/bundle/direct/bundle_plan_test.go @@ -10,12 +10,11 @@ import ( "github.com/databricks/cli/bundle/direct/dresources" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/yamlloader" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + pipelines "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/databricks/cli/libs/structs/structdiff" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/structs/structvar" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -216,7 +215,7 @@ func TestRemoteAlreadySetGuards(t *testing.T) { adapters, err := dresources.InitAll(nil) require.NoError(t, err) - runAs := &pipelines.RunAs{UserName: "someone@example.test"} + runAs := &pipelines.PipelinesJobRunAs{UserName: new("someone@example.test")} tests := []struct { name string @@ -489,17 +488,17 @@ const jobRunKey = "resources.job_runs.my_run" func TestLookupReferencePreDeploy_FinishedJobRun(t *testing.T) { b := bundleWithSkippedJobRun(t, &dresources.JobRunRemote{ RunId: 123, - ResultState: jobs.RunResultStateSuccess, + ResultState: jobs.RunResultState_RunResultState_Success, State: &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateSuccess, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Success, }, }) value, err := b.LookupReferencePreDeploy(t.Context(), structpath.MustParsePath(jobRunKey+".state.result_state")) require.NoError(t, err) - assert.Equal(t, jobs.RunResultStateSuccess, value) + assert.Equal(t, jobs.RunResultState_RunResultState_Success, value) } // jobRunResultStateAction classifies the result_state drift of a run in the given @@ -512,8 +511,8 @@ func jobRunResultStateAction(t *testing.T, state *jobs.RunState) *deployplan.Cha remote := &dresources.JobRunRemote{RunId: 123, ResultState: state.ResultState, State: state} changes := deployplan.Changes{"result_state": &deployplan.ChangeDesc{ - Old: jobs.RunResultStateSuccess, - New: jobs.RunResultStateSuccess, + Old: jobs.RunResultState_RunResultState_Success, + New: jobs.RunResultState_RunResultState_Success, Remote: state.ResultState, }} @@ -526,20 +525,20 @@ func jobRunResultStateAction(t *testing.T, state *jobs.RunState) *deployplan.Cha func TestJobRunFinishedWithoutSuccessIsRecreate(t *testing.T) { for name, state := range map[string]*jobs.RunState{ "FAILED": { - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateFailed, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Failed, }, "CANCELED": { - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateCanceled, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Canceled, }, "TIMEDOUT": { - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateTimedout, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Timedout, }, // A skipped run never ran, so it reports no result_state at all — the same // as a run still going. Only the lifecycle state tells the two apart. - "SKIPPED": {LifeCycleState: jobs.RunLifeCycleStateSkipped}, + "SKIPPED": {LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Skipped}, } { t.Run(name, func(t *testing.T) { assert.Equal(t, deployplan.Recreate, jobRunResultStateAction(t, state).Action) @@ -550,10 +549,10 @@ func TestJobRunFinishedWithoutSuccessIsRecreate(t *testing.T) { // A run that has not stopped yet may still succeed, so the plan leaves it // alone rather than recreating it. Skip does not resume an abandoned wait. func TestJobRunInProgressIsSkip(t *testing.T) { - for _, lifeCycleState := range []jobs.RunLifeCycleState{ - jobs.RunLifeCycleStatePending, - jobs.RunLifeCycleStateRunning, - jobs.RunLifeCycleStateTerminating, + for _, lifeCycleState := range []jobs.RunLifeCycleState_RunLifeCycleState{ + jobs.RunLifeCycleState_RunLifeCycleState_Pending, + jobs.RunLifeCycleState_RunLifeCycleState_Running, + jobs.RunLifeCycleState_RunLifeCycleState_Terminating, } { t.Run(string(lifeCycleState), func(t *testing.T) { change := jobRunResultStateAction(t, &jobs.RunState{LifeCycleState: lifeCycleState}) @@ -567,8 +566,8 @@ func TestJobRunInProgressIsSkip(t *testing.T) { // The run reached the required outcome, so the plan can skip it. func TestJobRunSucceededOutcomeIsNotDrift(t *testing.T) { change := jobRunResultStateAction(t, &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateSuccess, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Success, }) assert.Equal(t, deployplan.Skip, change.Action) @@ -609,18 +608,18 @@ func TestShouldSkipRemoteAddition(t *testing.T) { } withPolicy := &jobs.JobSettings{JobClusters: []jobs.JobCluster{{ - JobClusterKey: "small", - NewCluster: &compute.ClusterSpec{PolicyId: "p1"}, + JobClusterKey: new("small"), + NewCluster: &jobs.ClusterSpec_NewCluster{PolicyId: new("p1")}, }}} withoutPolicy := &jobs.JobSettings{JobClusters: []jobs.JobCluster{{ - JobClusterKey: "small", - NewCluster: &compute.ClusterSpec{}, + JobClusterKey: new("small"), + NewCluster: &jobs.ClusterSpec_NewCluster{}, }}} // when_set resolves against the concrete object the rule matched, so two clusters in one // job are gated independently. mixed := &jobs.JobSettings{JobClusters: []jobs.JobCluster{ - {JobClusterKey: "gated", NewCluster: &compute.ClusterSpec{PolicyId: "p1"}}, - {JobClusterKey: "plain", NewCluster: &compute.ClusterSpec{}}, + {JobClusterKey: new("gated"), NewCluster: &jobs.ClusterSpec_NewCluster{PolicyId: new("p1")}}, + {JobClusterKey: new("plain"), NewCluster: &jobs.ClusterSpec_NewCluster{}}, }} const tagPath = "job_clusters[job_cluster_key='small'].new_cluster.custom_tags['CostCenter']" @@ -786,7 +785,7 @@ func TestLadderBackendDefaultBeforeRemoteAddition(t *testing.T) { adapter, err := dresources.NewAdapter(dresources.SupportedResources["clusters"], "clusters", nil) require.NoError(t, err) - newState := &dresources.ClusterState{PolicyId: "p1"} + newState := &dresources.ClusterState{PolicyId: new("p1")} changes := deployplan.Changes{ // config-absent (Old==New==nil), present in remote: matches both rules. "enable_elastic_disk": &deployplan.ChangeDesc{Remote: true}, diff --git a/bundle/direct/dresources/adapter.go b/bundle/direct/dresources/adapter.go index 80ece24b2be..dcd24e548bf 100644 --- a/bundle/direct/dresources/adapter.go +++ b/bundle/direct/dresources/adapter.go @@ -8,9 +8,9 @@ import ( "github.com/databricks/cli/bundle/deployplan" "github.com/databricks/cli/libs/calladapt" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/structs/structvar" - "github.com/databricks/databricks-sdk-go" ) type ( @@ -27,7 +27,7 @@ type IResource interface { // Note, this is a class method, it will be called with nil receiver. // The return value must be a pointer to a specific instance of the resource implementation, e.g. *ResourceJob. // Single instance is reused across all instances, so it must not store any resource-specific state. - New(client *databricks.WorkspaceClient) any + New(client *sdkclients.Clients) any // [Optional] Configure passes the resource type this instance is registered under in SupportedResources // (e.g. "jobs.permissions"). One instance is created per resource type, so type-level lookups belong here @@ -147,7 +147,7 @@ type Adapter struct { keyedSlices map[string]any } -func NewAdapter(typedNil any, resourceType string, client *databricks.WorkspaceClient) (*Adapter, error) { +func NewAdapter(typedNil any, resourceType string, client *sdkclients.Clients) (*Adapter, error) { newCall, err := prepareCallRequired(typedNil, "New") if err != nil { return nil, err diff --git a/bundle/direct/dresources/alert.go b/bundle/direct/dresources/alert.go index a18641e810a..8cffa9cf6e5 100644 --- a/bundle/direct/dresources/alert.go +++ b/bundle/direct/dresources/alert.go @@ -4,65 +4,80 @@ import ( "context" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/sdkclients" + alerts "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/utils" + sdkalerts "github.com/databricks/sdk-go/alerts/v2" ) type ResourceAlert struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } // New initializes a ResourceAlert with the given client. -func (*ResourceAlert) New(client *databricks.WorkspaceClient) *ResourceAlert { +func (*ResourceAlert) New(client *sdkclients.Clients) *ResourceAlert { return &ResourceAlert{client: client} } // PrepareState converts bundle config to the SDK type. -func (*ResourceAlert) PrepareState(input *resources.Alert) *sql.AlertV2 { - return &input.AlertV2 +func (*ResourceAlert) PrepareState(input *resources.Alert) *alerts.Alert { + return &input.Alert } // DoRead reads the alert by id. -func (r *ResourceAlert) DoRead(ctx context.Context, id string) (*sql.AlertV2, error) { - alert, err := r.client.AlertsV2.GetAlertById(ctx, id) +func (r *ResourceAlert) DoRead(ctx context.Context, id string) (*alerts.Alert, error) { + alert, err := r.client.Alerts.GetAlert(ctx, sdkalerts.GetAlertRequest{Id: new(id)}) if err != nil { return nil, err } // If the alert is already marked as thrashed, return a 404 on DoRead. - if alert.LifecycleState == sql.AlertLifecycleStateDeleted { - return nil, databricks.ErrResourceDoesNotExist + if alert.LifecycleState == sdkalerts.AlertLifecycleState_Deleted { + return nil, errResourceDoesNotExist("alert " + id + " is deleted") } - return alert, nil + return alerts.AlertFromSDK(alert) } // DoCreate creates the alert and returns its id. -func (r *ResourceAlert) DoCreate(ctx context.Context, config *sql.AlertV2) (string, *sql.AlertV2, error) { - request := sql.CreateAlertV2Request{ - Alert: *config, +func (r *ResourceAlert) DoCreate(ctx context.Context, config *alerts.Alert) (string, *alerts.Alert, error) { + request, err := alerts.CreateAlertRequestToSDK(&alerts.CreateAlertRequest{Alert: config}) + if err != nil { + return "", nil, err } - response, err := r.client.AlertsV2.CreateAlert(ctx, request) + response, err := r.client.Alerts.CreateAlert(ctx, *request) if err != nil || response == nil { return "", nil, err } - return response.Id, response, nil + alert, err := alerts.AlertFromSDK(response) + if err != nil { + return "", nil, err + } + return utils.Deref(alert.Id), alert, nil } // DoUpdate updates the alert in place. -func (r *ResourceAlert) DoUpdate(ctx context.Context, id string, config *sql.AlertV2, _ *PlanEntry) (*sql.AlertV2, error) { - request := sql.UpdateAlertV2Request{ - Id: id, - Alert: *config, - UpdateMask: "*", +func (r *ResourceAlert) DoUpdate(ctx context.Context, id string, config *alerts.Alert, _ *PlanEntry) (*alerts.Alert, error) { + alert := *config + alert.Id = new(id) + request, err := alerts.UpdateAlertRequestToSDK(&alerts.UpdateAlertRequest{ + Alert: &alert, + UpdateMask: new("*"), + }) + if err != nil { + return nil, err + } + response, err := r.client.Alerts.UpdateAlert(ctx, *request) + if err != nil { + return nil, err } - return r.client.AlertsV2.UpdateAlert(ctx, request) + return alerts.AlertFromSDK(response) } // DoDelete deletes the alert by id. -func (r *ResourceAlert) DoDelete(ctx context.Context, id string, _ *sql.AlertV2) error { - return r.client.AlertsV2.TrashAlert(ctx, sql.TrashAlertV2Request{ - Id: id, - Purge: true, - ForceSendFields: []string{"Purge"}, +func (r *ResourceAlert) DoDelete(ctx context.Context, id string, _ *alerts.Alert) error { + _, err := r.client.Alerts.TrashAlert(ctx, sdkalerts.TrashAlertRequest{ + Id: new(id), + Purge: new(true), }) + return err } diff --git a/bundle/direct/dresources/all.go b/bundle/direct/dresources/all.go index 27e8496b83e..9cb03a98f0c 100644 --- a/bundle/direct/dresources/all.go +++ b/bundle/direct/dresources/all.go @@ -3,7 +3,7 @@ package dresources import ( "fmt" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" ) var SupportedResources = map[string]any{ @@ -81,7 +81,7 @@ var SupportedResources = map[string]any{ "internal_immutable_snapshots": (*ResourceSnapshot)(nil), } -func InitAll(client *databricks.WorkspaceClient) (map[string]*Adapter, error) { +func InitAll(client *sdkclients.Clients) (map[string]*Adapter, error) { result := make(map[string]*Adapter) for resourceType, resource := range SupportedResources { adapter, err := NewAdapter(resource, resourceType, client) diff --git a/bundle/direct/dresources/all_test.go b/bundle/direct/dresources/all_test.go index f00037e48dc..d3842a3c0d1 100644 --- a/bundle/direct/dresources/all_test.go +++ b/bundle/direct/dresources/all_test.go @@ -7,79 +7,84 @@ import ( "os" "path/filepath" "reflect" - "strconv" "strings" "testing" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/sdktypes/database/v1" + "github.com/databricks/cli/libs/sdktypes/experiments/v1" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/modelregistry/v1" + "github.com/databricks/cli/libs/sdktypes/modelserving/v1" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/sdktypes/secrets/v1" + grants "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" "github.com/databricks/cli/libs/snapshot" "github.com/databricks/cli/libs/structs/structaccess" "github.com/databricks/cli/libs/structs/structdiff" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/structs/structwalk" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/apps" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/dashboards" - "github.com/databricks/databricks-sdk-go/service/database" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/postgres" - "github.com/databricks/databricks-sdk-go/service/serving" - "github.com/databricks/databricks-sdk-go/service/sql" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/databricks-sdk-go/config" + sdkapps "github.com/databricks/sdk-go/apps/v1" + sdkgenie "github.com/databricks/sdk-go/genie/v1" + sdklakeview "github.com/databricks/sdk-go/lakeview/v1" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" + sdkvectorsearch "github.com/databricks/sdk-go/vectorsearch/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) var testConfig map[string]any = map[string]any{ "apps": &resources.App{ - Name: "myapp", + Name: new("myapp"), }, "catalogs": &resources.Catalog{ - Name: "mycatalog", - Comment: "Test catalog", + Name: new("mycatalog"), + Comment: new("Test catalog"), // Note: EnablePredictiveOptimization and IsolationMode cannot be set during creation, // only during updates. They are not included in the test config. }, "external_locations": &resources.ExternalLocation{ - Name: "myexternallocation", - Url: "s3://mybucket/mypath", - CredentialName: "mycredential", - Comment: "Test external location", + Name: new("myexternallocation"), + Url: new("s3://mybucket/mypath"), + CredentialName: new("mycredential"), + Comment: new("Test external location"), }, "schemas": &resources.Schema{ - CatalogName: "main", - Name: "myschema", - Comment: "Test schema", + CatalogName: new("main"), + Name: new("myschema"), + Comment: new("Test schema"), }, "volumes": &resources.Volume{ - CatalogName: "main", - SchemaName: "myschema", - Name: "myvolume", - Comment: "Test volume", + CatalogName: new("main"), + SchemaName: new("myschema"), + Name: new("myvolume"), + Comment: new("Test volume"), }, "database_instances": &resources.DatabaseInstance{ - Name: "mydbinstance", + Name: new("mydbinstance"), }, "instance_pools": &resources.InstancePool{ - InstancePoolName: "my-instance-pool", - NodeTypeId: "i3.xlarge", + InstancePoolName: new("my-instance-pool"), + NodeTypeId: new("i3.xlarge"), }, "synced_database_tables": &resources.SyncedDatabaseTable{ - Name: "main.myschema.my_synced_table", + Name: new("main.myschema.my_synced_table"), }, "model_services": &resources.ModelService{ @@ -101,95 +106,91 @@ var testConfig map[string]any = map[string]any{ }, "registered_models": &resources.RegisteredModel{ - Name: "my_registered_model", - Comment: "Test registered model", - CatalogName: "main", - SchemaName: "default", - StorageLocation: "s3://my-bucket/my-path", + Name: new("my_registered_model"), + Comment: new("Test registered model"), + CatalogName: new("main"), + SchemaName: new("default"), + StorageLocation: new("s3://my-bucket/my-path"), }, "experiments": &resources.MlflowExperiment{ - Name: "my-experiment", - Tags: []ml.ExperimentTag{ + Name: new("my-experiment"), + Tags: []experiments.ExperimentTag{ { - Key: "my-tag", - Value: "my-value", + Key: new("my-tag"), + Value: new("my-value"), }, }, - ArtifactLocation: "s3://my-bucket/my-experiment", + ArtifactLocation: new("s3://my-bucket/my-experiment"), }, "models": &resources.MlflowModel{ - Name: "my_mlflow_model", - Description: "my_mlflow_model_description", - Tags: []ml.ModelTag{ + Name: new("my_mlflow_model"), + Description: new("my_mlflow_model_description"), + Tags: []modelregistry.RegisteredModelTag{ { - Key: "k1", - Value: "v1", + Key: new("k1"), + Value: new("v1"), }, }, }, "secrets": &resources.Secret{ - CatalogName: "main", - SchemaName: "default", - Name: "my_secret", - Value: "my_secret_value", - Comment: "Test secret", + CatalogName: new("main"), + SchemaName: new("default"), + Name: new("my_secret"), + Value: new("my_secret_value"), + Comment: new("Test secret"), }, "secret_scopes": &resources.SecretScope{ Name: "my_secret_scope", - BackendType: workspace.ScopeBackendTypeAzureKeyvault, + BackendType: secrets.ScopeBackendType_AzureKeyvault, Permissions: []resources.SecretScopePermission{ { Level: resources.SecretScopePermissionLevelManage, UserName: "user@example.com", }, }, - KeyvaultMetadata: &workspace.AzureKeyVaultSecretScopeMetadata{ - DnsName: "https://my-keyvault.vault.azure.net/", - ResourceId: "my-keyvault-resource-id", + KeyvaultMetadata: &secrets.AzureKeyVaultSecretScopeMetadata{ + DnsName: new("https://my-keyvault.vault.azure.net/"), + ResourceId: new("my-keyvault-resource-id"), }, }, "model_serving_endpoints": &resources.ModelServingEndpoint{ - Name: "my-endpoint", - Config: &serving.EndpointCoreConfigInput{ - Name: "my-endpoint", - //nolint:staticcheck // SA1019: deprecated AutoCaptureConfigInput kept for bundle config compatibility - AutoCaptureConfig: &serving.AutoCaptureConfigInput{ - CatalogName: "main", - SchemaName: "myschema", - TableNamePrefix: "my_table", - Enabled: true, - ForceSendFields: nil, + Name: new("my-endpoint"), + Config: &modelserving.EndpointCoreConfig{ + //nolint:staticcheck + AutoCaptureConfig: &modelserving.AutoCaptureConfig{ + CatalogName: new("main"), + SchemaName: new("myschema"), + TableNamePrefix: new("my_table"), + Enabled: new(true), }, ServedModels: nil, - ServedEntities: []serving.ServedEntityInput{ + ServedEntities: []modelserving.ServedModel{ { - EntityName: "entity-name", - EntityVersion: "1", - WorkloadSize: "Small", - ScaleToZeroEnabled: true, - WorkloadType: serving.ServingModelWorkloadTypeCpu, + EntityName: new("entity-name"), + EntityVersion: new("1"), + WorkloadSize: new("Small"), + ScaleToZeroEnabled: new(true), EnvironmentVars: map[string]string{"key": "value"}, - InstanceProfileArn: "arn:aws:iam::123456789012:instance-profile/my-instance-profile", - MaxProvisionedConcurrency: 10, - MaxProvisionedThroughput: 100, - MinProvisionedConcurrency: 1, - MinProvisionedThroughput: 10, - Name: "entity-name", - ProvisionedModelUnits: 100, + InstanceProfileArn: new("arn:aws:iam::123456789012:instance-profile/my-instance-profile"), + MaxProvisionedConcurrency: new(10), + MaxProvisionedThroughput: new(100), + MinProvisionedConcurrency: new(1), + MinProvisionedThroughput: new(10), + Name: new("entity-name"), + ProvisionedModelUnits: new(int64(100)), ExternalModel: nil, - ForceSendFields: nil, }, }, - TrafficConfig: &serving.TrafficConfig{ - Routes: []serving.Route{ + TrafficConfig: &modelserving.TrafficConfig{ + Routes: []modelserving.Route{ { - ServedModelName: "model-name-1", - TrafficPercentage: 100, + ServedModelName: new("model-name-1"), + TrafficPercentage: new(100), }, }, }, @@ -198,8 +199,8 @@ var testConfig map[string]any = map[string]any{ "postgres_projects": &resources.PostgresProject{ ProjectId: "test-project", - DisplayName: "Test Project", - PgVersion: 16, + DisplayName: new("Test Project"), + PgVersion: new(16), }, "postgres_catalogs": &resources.PostgresCatalog{ @@ -211,21 +212,21 @@ var testConfig map[string]any = map[string]any{ }, "alerts": &resources.Alert{ - DisplayName: "my-alert", - QueryText: "SELECT 1", - WarehouseId: "test-warehouse-id", - Schedule: sql.CronSchedule{ - QuartzCronSchedule: "0 0 12 * * ?", - TimezoneId: "UTC", + DisplayName: new("my-alert"), + QueryText: new("SELECT 1"), + WarehouseId: new("test-warehouse-id"), + Schedule: &alerts.CronSchedule{ + QuartzCronSchedule: new("0 0 12 * * ?"), + TimezoneId: new("UTC"), }, - Evaluation: sql.AlertV2Evaluation{ - ComparisonOperator: sql.ComparisonOperatorGreaterThan, - Source: sql.AlertV2OperandColumn{ - Name: "column1", + Evaluation: &alerts.AlertEvaluation{ + ComparisonOperator: alerts.ComparisonOperator_GreaterThan, + Source: &alerts.AlertOperandColumn{ + Name: new("column1"), }, - Threshold: &sql.AlertV2Operand{ - Column: &sql.AlertV2OperandColumn{ - Name: "column2", + Threshold: &alerts.AlertOperand{ + Column: &alerts.AlertOperandColumn{ + Name: new("column2"), }, }, }, @@ -255,53 +256,51 @@ var testConfig map[string]any = map[string]any{ }, "vector_search_endpoints": &resources.VectorSearchEndpoint{ - Name: "my-endpoint", - EndpointType: vectorsearch.EndpointTypeStandard, + Name: new("my-endpoint"), + EndpointType: vectorsearch.EndpointType_Standard, }, "vector_search_indexes": &resources.VectorSearchIndex{ - Name: "main.default.my_index", - EndpointName: "my-index-endpoint", - PrimaryKey: "id", - IndexType: vectorsearch.VectorIndexTypeDeltaSync, + Name: new("main.default.my_index"), + EndpointName: new("my-index-endpoint"), + PrimaryKey: new("id"), + IndexType: vectorsearch.VectorIndexType("DELTA_SYNC"), DeltaSyncIndexSpec: &vectorsearch.DeltaSyncVectorIndexSpecRequest{ - SourceTable: "main.default.source_table", - PipelineType: vectorsearch.PipelineTypeTriggered, + SourceTable: new("main.default.source_table"), + PipelineType: vectorsearch.PipelineType("TRIGGERED"), }, - Grants: []catalog.PrivilegeAssignment{{ - Principal: "user@example.com", - Privileges: []catalog.Privilege{catalog.PrivilegeSelect}, + Grants: []grants.PrivilegeAssignment{{ + Principal: new("user@example.com"), + Privileges: []string{"SELECT"}, }}, }, "internal_immutable_snapshots": &resources.Snapshot{ - RemoteRoot: "/Workspace/Users/" + testserver.TestUserSP.UserName + "/.snapshots", + RemoteRoot: "/Workspace/Users/" + utils.Deref(testserver.TestUserSP.UserName) + "/.snapshots", BundleID: "test-bundle-id", ACL: []snapshot.ACLEntry{{UserName: "user@example.com", PermissionLevel: "CAN_READ"}}, }, } -type prepareWorkspace func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) +type prepareWorkspace func(ctx context.Context, client *sdkclients.Clients) (any, error) // some resource require other resources to exist var testDeps = map[string]prepareWorkspace{ - "database_catalogs": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - _, err := client.Database.CreateDatabaseInstance(ctx, database.CreateDatabaseInstanceRequest{ - DatabaseInstance: database.DatabaseInstance{ - Name: "mydbinstance1", - }, + "database_catalogs": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + _, _, err := (&ResourceDatabaseInstance{client: client}).DoCreate(ctx, &database.DatabaseInstance{ + Name: new("mydbinstance1"), }) return &resources.DatabaseCatalog{ - Name: "mydbcatalog", - DatabaseInstanceName: "mydbinstance1", + Name: new("mydbcatalog"), + DatabaseInstanceName: new("mydbinstance1"), }, err }, - "vector_search_indexes": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - _, err := client.VectorSearchEndpoints.CreateEndpoint(ctx, vectorsearch.CreateEndpoint{ - Name: "my-index-endpoint", - EndpointType: vectorsearch.EndpointTypeStandard, + "vector_search_indexes": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + _, _, err := (&ResourceVectorSearchEndpoint{client: client}).DoCreate(ctx, &vectorsearch.CreateEndpointRequest{ + Name: new("my-index-endpoint"), + EndpointType: vectorsearch.EndpointType_Standard, }) if err != nil { return nil, err @@ -310,15 +309,15 @@ var testDeps = map[string]prepareWorkspace{ return testConfig["vector_search_indexes"], nil }, - "job_runs": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "job_runs": func(ctx context.Context, client *sdkclients.Clients) (any, error) { // A run can only be triggered against an existing job, so create one first. - resp, err := client.Jobs.Create(ctx, jobs.CreateJob{ - Name: "job-for-run", - Tasks: []jobs.Task{ + id, _, err := (&ResourceJob{client: client}).DoCreate(ctx, &jobs.JobSettings{ + Name: new("job-for-run"), + Tasks: []jobs.TaskSettings{ { - TaskKey: "t", + TaskKey: new("t"), NotebookTask: &jobs.NotebookTask{ - NotebookPath: "/Workspace/Users/user@example.com/notebook", + NotebookPath: new("/Workspace/Users/user@example.com/notebook"), }, }, }, @@ -326,20 +325,24 @@ var testDeps = map[string]prepareWorkspace{ if err != nil { return nil, err } + jobID, err := parseJobID(id) + if err != nil { + return nil, err + } return &resources.JobRun{ - JobId: resp.JobId, + JobId: new(jobID), }, nil }, - "jobs.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - resp, err := client.Jobs.Create(ctx, jobs.CreateJob{ - Name: "job-permissions", - Tasks: []jobs.Task{ + "jobs.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + id, _, err := (&ResourceJob{client: client}).DoCreate(ctx, &jobs.JobSettings{ + Name: new("job-permissions"), + Tasks: []jobs.TaskSettings{ { - TaskKey: "t", + TaskKey: new("t"), NotebookTask: &jobs.NotebookTask{ - NotebookPath: "/Workspace/Users/user@example.com/notebook", + NotebookPath: new("/Workspace/Users/user@example.com/notebook"), }, }, }, @@ -347,9 +350,8 @@ var testDeps = map[string]prepareWorkspace{ if err != nil { return nil, err } - return &PermissionsState{ - ObjectID: "/jobs/" + strconv.FormatInt(resp.JobId, 10), + ObjectID: "/jobs/" + id, EmbeddedSlice: []StatePermission{{ Level: "IS_OWNER", UserName: "user@example.com", @@ -357,16 +359,16 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "pipelines.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - resp, err := client.Pipelines.Create(ctx, pipelines.CreatePipeline{ - Name: "pipeline-permissions", + "pipelines.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + id, _, err := (&ResourcePipeline{client: client}).DoCreate(ctx, &PipelineState{ + Name: new("pipeline-permissions"), }) if err != nil { return nil, err } return &PermissionsState{ - ObjectID: "/pipelines/" + resp.PipelineId, + ObjectID: "/pipelines/" + id, EmbeddedSlice: []StatePermission{{ // Pipelines require exactly one owner, like jobs. Level: "IS_OWNER", @@ -375,17 +377,17 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "models.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - resp, err := client.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ - Name: "model-permissions", - Description: "model for permissions testing", + "models.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + name, _, err := (&ResourceMlflowModel{client: client}).DoCreate(ctx, &modelregistry.CreateRegisteredModelRequest{ + Name: new("model-permissions"), + Description: new("model for permissions testing"), }) if err != nil { return nil, err } return &PermissionsState{ - ObjectID: "/registered-models/" + resp.RegisteredModel.Name, + ObjectID: "/registered-models/" + name, EmbeddedSlice: []StatePermission{{ Level: "CAN_MANAGE", UserName: "user@example.com", @@ -393,16 +395,16 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "experiments.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - resp, err := client.Experiments.CreateExperiment(ctx, ml.CreateExperiment{ - Name: "experiment-permissions", + "experiments.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + id, _, err := (&ResourceExperiment{client: client}).DoCreate(ctx, &experiments.CreateExperimentRequest{ + Name: new("experiment-permissions"), }) if err != nil { return nil, err } return &PermissionsState{ - ObjectID: "/experiments/" + resp.ExperimentId, + ObjectID: "/experiments/" + id, EmbeddedSlice: []StatePermission{{ Level: "CAN_MANAGE", UserName: "user@example.com", @@ -410,7 +412,7 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "clusters.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "clusters.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &PermissionsState{ ObjectID: "/clusters/cluster-permissions", EmbeddedSlice: []StatePermission{{ @@ -420,7 +422,7 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "cluster_policies.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "cluster_policies.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &PermissionsState{ ObjectID: "/cluster-policies/cluster-policy-permissions", EmbeddedSlice: []StatePermission{{ @@ -430,7 +432,7 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "instance_pools.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "instance_pools.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &PermissionsState{ ObjectID: "/instance-pools/pool-permissions", EmbeddedSlice: []StatePermission{{ @@ -440,10 +442,10 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "apps.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - waiter, err := client.Apps.Create(ctx, apps.CreateAppRequest{ - App: apps.App{ - Name: "app-permissions", + "apps.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + waiter, err := client.Apps.CreateApp(ctx, sdkapps.CreateAppRequest{ + App: &sdkapps.App{ + Name: new("app-permissions"), }, }) if err != nil { @@ -451,7 +453,7 @@ var testDeps = map[string]prepareWorkspace{ } return &PermissionsState{ - ObjectID: "/apps/" + waiter.Response.Name, + ObjectID: "/apps/" + waiter.GetName(), EmbeddedSlice: []StatePermission{{ Level: "CAN_MANAGE", UserName: "user@example.com", @@ -459,7 +461,7 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "sql_warehouses.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "sql_warehouses.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &PermissionsState{ ObjectID: "/sql/warehouses/warehouse-permissions", EmbeddedSlice: []StatePermission{{ @@ -469,18 +471,16 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "database_instances.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - waiter, err := client.Database.CreateDatabaseInstance(ctx, database.CreateDatabaseInstanceRequest{ - DatabaseInstance: database.DatabaseInstance{ - Name: "dbinstance-permissions", - }, + "database_instances.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + name, _, err := (&ResourceDatabaseInstance{client: client}).DoCreate(ctx, &database.DatabaseInstance{ + Name: new("dbinstance-permissions"), }) if err != nil { return nil, err } return &PermissionsState{ - ObjectID: "/database-instances/" + waiter.Response.Name, + ObjectID: "/database-instances/" + name, EmbeddedSlice: []StatePermission{{ Level: "CAN_MANAGE", UserName: "user@example.com", @@ -488,10 +488,10 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "postgres_projects.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "postgres_projects.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { const projectID = "permissions-project" - waiter, err := client.Postgres.CreateProject(ctx, postgres.CreateProjectRequest{ - ProjectId: projectID, + waiter, err := client.Postgres.CreateProject(ctx, sdkpostgres.CreateProjectRequest{ + ProjectId: new(projectID), }) if err != nil { return nil, err @@ -509,7 +509,7 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "dashboards.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "dashboards.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { parentPath := "/Workspace/Users/user@example.com" // Create parent directory if it doesn't exist @@ -518,11 +518,11 @@ var testDeps = map[string]prepareWorkspace{ return nil, err } - resp, err := client.Lakeview.Create(ctx, dashboards.CreateDashboardRequest{ - Dashboard: dashboards.Dashboard{ - DisplayName: "dashboard-permissions", - ParentPath: parentPath, - SerializedDashboard: `{"pages":[{"name":"page1","displayName":"Page 1"}]}`, + resp, err := client.Lakeview.CreateDashboard(ctx, sdklakeview.CreateDashboardRequest{ + Dashboard: &sdklakeview.DashboardCreate{ + DisplayName: new("dashboard-permissions"), + ParentPath: new(parentPath), + SerializedDashboard: new(`{"pages":[{"name":"page1","displayName":"Page 1"}]}`), }, }) if err != nil { @@ -530,7 +530,7 @@ var testDeps = map[string]prepareWorkspace{ } return &PermissionsState{ - ObjectID: "/dashboards/" + resp.DashboardId, + ObjectID: "/dashboards/" + utils.Deref(resp.DashboardId), EmbeddedSlice: []StatePermission{{ Level: "CAN_MANAGE", UserName: "user@example.com", @@ -538,18 +538,18 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "genie_spaces.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - resp, err := client.Genie.CreateSpace(ctx, dashboards.GenieCreateSpaceRequest{ - Title: "genie-space-permissions", - WarehouseId: "test-warehouse-id", - SerializedSpace: "{}", + "genie_spaces.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + resp, err := client.Genie.CreateSpace(ctx, sdkgenie.GenieCreateSpaceRequest{ + Title: new("genie-space-permissions"), + WarehouseId: new("test-warehouse-id"), + SerializedSpace: new("{}"), }) if err != nil { return nil, err } return &PermissionsState{ - ObjectID: "/genie/" + resp.SpaceId, + ObjectID: "/genie/" + utils.Deref(resp.SpaceId), EmbeddedSlice: []StatePermission{{ Level: "CAN_MANAGE", UserName: "user@example.com", @@ -557,16 +557,16 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "model_serving_endpoints.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - waiter, err := client.ServingEndpoints.Create(ctx, serving.CreateServingEndpoint{ - Name: "endpoint-permissions", - Config: &serving.EndpointCoreConfigInput{ - ServedModels: []serving.ServedModelInput{ + "model_serving_endpoints.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + name, _, err := (&ResourceModelServingEndpoint{client: client}).DoCreate(ctx, &modelserving.CreateInferenceEndpointRequest{ + Name: new("endpoint-permissions"), + Config: &modelserving.EndpointCoreConfig{ + ServedModels: []modelserving.ServedModel{ { - ModelName: "model-name", - ModelVersion: "1", - WorkloadSize: "Small", - ScaleToZeroEnabled: true, + ModelName: new("model-name"), + ModelVersion: new("1"), + WorkloadSize: new("Small"), + ScaleToZeroEnabled: new(true), }, }, }, @@ -576,7 +576,7 @@ var testDeps = map[string]prepareWorkspace{ } return &PermissionsState{ - ObjectID: "/serving-endpoints/" + waiter.Response.Name, + ObjectID: "/serving-endpoints/" + name, EmbeddedSlice: []StatePermission{{ Level: "CAN_MANAGE", UserName: "user@example.com", @@ -584,17 +584,21 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "vector_search_endpoints.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - waiter, err := client.VectorSearchEndpoints.CreateEndpoint(ctx, vectorsearch.CreateEndpoint{ - Name: "vs-endpoint-permissions", - EndpointType: vectorsearch.EndpointTypeStandard, + "vector_search_endpoints.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + waiter, err := client.VectorSearch.CreateEndpoint(ctx, sdkvectorsearch.CreateEndpointRequest{ + Name: new("vs-endpoint-permissions"), + EndpointType: sdkvectorsearch.EndpointType_Standard, }) if err != nil { return nil, err } + endpoint, err := client.VectorSearch.GetEndpoint(ctx, sdkvectorsearch.GetEndpointRequest{Name: new(waiter.GetName())}) + if err != nil { + return nil, err + } return &PermissionsState{ - ObjectID: "/vector-search-endpoints/" + waiter.Response.Id, + ObjectID: "/vector-search-endpoints/" + utils.Deref(endpoint.Id), EmbeddedSlice: []StatePermission{{ Level: "CAN_MANAGE", UserName: "user@example.com", @@ -602,21 +606,19 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "alerts.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - resp, err := client.AlertsV2.CreateAlert(ctx, sql.CreateAlertV2Request{ - Alert: sql.AlertV2{ - DisplayName: "alert-permissions", - QueryText: "SELECT 1", - WarehouseId: "test-warehouse-id", - Schedule: sql.CronSchedule{ - QuartzCronSchedule: "0 0 12 * * ?", - TimezoneId: "UTC", - }, - Evaluation: sql.AlertV2Evaluation{ - ComparisonOperator: sql.ComparisonOperatorGreaterThan, - Source: sql.AlertV2OperandColumn{ - Name: "column1", - }, + "alerts.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + id, _, err := (&ResourceAlert{client: client}).DoCreate(ctx, &alerts.Alert{ + DisplayName: new("alert-permissions"), + QueryText: new("SELECT 1"), + WarehouseId: new("test-warehouse-id"), + Schedule: &alerts.CronSchedule{ + QuartzCronSchedule: new("0 0 12 * * ?"), + TimezoneId: new("UTC"), + }, + Evaluation: &alerts.AlertEvaluation{ + ComparisonOperator: alerts.ComparisonOperator_GreaterThan, + Source: &alerts.AlertOperandColumn{ + Name: new("column1"), }, }, }) @@ -625,7 +627,7 @@ var testDeps = map[string]prepareWorkspace{ } return &PermissionsState{ - ObjectID: "/alertsv2/" + resp.Id, + ObjectID: "/alertsv2/" + id, EmbeddedSlice: []StatePermission{{ Level: "CAN_MANAGE", UserName: "user@example.com", @@ -633,123 +635,123 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "catalogs.grants": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "catalogs.grants": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &GrantsState{ SecurableType: "catalog", FullName: "mycatalog", - EmbeddedSlice: []catalog.PrivilegeAssignment{{ - Privileges: []catalog.Privilege{catalog.PrivilegeUseCatalog}, - Principal: "user@example.com", + EmbeddedSlice: []grants.PrivilegeAssignment{{ + Privileges: []string{"USE_CATALOG"}, + Principal: new("user@example.com"), }}, }, nil }, - "external_locations.grants": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "external_locations.grants": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &GrantsState{ SecurableType: "external_location", FullName: "myexternallocation", - EmbeddedSlice: []catalog.PrivilegeAssignment{{ - Privileges: []catalog.Privilege{catalog.PrivilegeReadFiles}, - Principal: "user@example.com", + EmbeddedSlice: []grants.PrivilegeAssignment{{ + Privileges: []string{"READ_FILES"}, + Principal: new("user@example.com"), }}, }, nil }, - "schemas.grants": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "schemas.grants": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &GrantsState{ SecurableType: "schema", FullName: "main.myschema", - EmbeddedSlice: []catalog.PrivilegeAssignment{{ - Privileges: []catalog.Privilege{catalog.PrivilegeCreateView}, - Principal: "user@example.com", + EmbeddedSlice: []grants.PrivilegeAssignment{{ + Privileges: []string{"CREATE_VIEW"}, + Principal: new("user@example.com"), }}, }, nil }, - "volumes.grants": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "volumes.grants": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &GrantsState{ SecurableType: "volume", FullName: "main.myschema.myvolume", - EmbeddedSlice: []catalog.PrivilegeAssignment{{ - Privileges: []catalog.Privilege{catalog.PrivilegeCreateView}, - Principal: "user@example.com", + EmbeddedSlice: []grants.PrivilegeAssignment{{ + Privileges: []string{"CREATE_VIEW"}, + Principal: new("user@example.com"), }}, }, nil }, - "registered_models.grants": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "registered_models.grants": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &GrantsState{ SecurableType: "registered-model", FullName: "modelid", - EmbeddedSlice: []catalog.PrivilegeAssignment{{ - Privileges: []catalog.Privilege{catalog.PrivilegeCreateView}, - Principal: "user@example.com", + EmbeddedSlice: []grants.PrivilegeAssignment{{ + Privileges: []string{"CREATE_VIEW"}, + Principal: new("user@example.com"), }}, }, nil }, - "vector_search_indexes.grants": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "vector_search_indexes.grants": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &GrantsState{ SecurableType: "table", FullName: "main.default.my_index", - EmbeddedSlice: []catalog.PrivilegeAssignment{{ - Privileges: []catalog.Privilege{catalog.PrivilegeSelect}, - Principal: "user@example.com", + EmbeddedSlice: []grants.PrivilegeAssignment{{ + Privileges: []string{"SELECT"}, + Principal: new("user@example.com"), }}, }, nil }, - "secrets.grants": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "secrets.grants": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &GrantsState{ SecurableType: "secret", FullName: "main.default.my_secret", - EmbeddedSlice: []catalog.PrivilegeAssignment{{ - Privileges: []catalog.Privilege{catalog.PrivilegeSelect}, - Principal: "user@example.com", + EmbeddedSlice: []grants.PrivilegeAssignment{{ + Privileges: []string{"SELECT"}, + Principal: new("user@example.com"), }}, }, nil }, - "model_services.grants": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "model_services.grants": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &GrantsState{ SecurableType: "model_service", FullName: "main.myschema.mymodelservice", - EmbeddedSlice: []catalog.PrivilegeAssignment{{ - Privileges: []catalog.Privilege{catalog.PrivilegeApplyTag}, - Principal: "user@example.com", + EmbeddedSlice: []grants.PrivilegeAssignment{{ + Privileges: []string{"APPLY_TAG"}, + Principal: new("user@example.com"), }}, }, nil }, - "mcp_services.grants": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "mcp_services.grants": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &GrantsState{ SecurableType: "mcp_service", FullName: "main.myschema.mymcpservice", - EmbeddedSlice: []catalog.PrivilegeAssignment{{ - Privileges: []catalog.Privilege{catalog.PrivilegeApplyTag}, - Principal: "user@example.com", + EmbeddedSlice: []grants.PrivilegeAssignment{{ + Privileges: []string{"APPLY_TAG"}, + Principal: new("user@example.com"), }}, }, nil }, - "model_provider_services.grants": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "model_provider_services.grants": func(ctx context.Context, client *sdkclients.Clients) (any, error) { return &GrantsState{ SecurableType: "model_provider_service", FullName: "main.myschema.myproviderservice", - EmbeddedSlice: []catalog.PrivilegeAssignment{{ - Privileges: []catalog.Privilege{catalog.PrivilegeApplyTag}, - Principal: "user@example.com", + EmbeddedSlice: []grants.PrivilegeAssignment{{ + Privileges: []string{"APPLY_TAG"}, + Principal: new("user@example.com"), }}, }, nil }, - "secret_scopes.permissions": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { - err := client.Secrets.CreateScope(ctx, workspace.CreateScope{ - Scope: "permissions_test_scope", - ScopeBackendType: workspace.ScopeBackendTypeAzureKeyvault, - BackendAzureKeyvault: &workspace.AzureKeyVaultSecretScopeMetadata{ - DnsName: "https://my-keyvault.vault.azure.net/", - ResourceId: "my-keyvault-resource-id", + "secret_scopes.permissions": func(ctx context.Context, client *sdkclients.Clients) (any, error) { + _, _, err := (&ResourceSecretScope{client: client}).DoCreate(ctx, &SecretScopeConfig{ + Scope: new("permissions_test_scope"), + ScopeBackendType: secrets.ScopeBackendType_AzureKeyvault, + BackendAzureKeyvault: &secrets.AzureKeyVaultSecretScopeMetadata{ + DnsName: new("https://my-keyvault.vault.azure.net/"), + ResourceId: new("my-keyvault-resource-id"), }, }) if err != nil { @@ -758,48 +760,39 @@ var testDeps = map[string]prepareWorkspace{ return &SecretScopeAclsState{ ScopeName: "permissions_test_scope", - Acls: []workspace.AclItem{ + Acls: []secrets.AclItem{ { - Principal: "user@example.com", - Permission: workspace.AclPermissionManage, + Principal: new("user@example.com"), + Permission: secrets.AclPermission_Manage, }, }, }, nil }, - "postgres_branches": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "postgres_branches": func(ctx context.Context, client *sdkclients.Clients) (any, error) { // Create parent project first - _, err := client.Postgres.CreateProject(ctx, postgres.CreateProjectRequest{ - ProjectId: "test-project-for-branch", - Project: postgres.Project{ - Spec: &postgres.ProjectSpec{ - DisplayName: "Test Project for Branch", - PgVersion: 16, - }, - }, + _, _, err := (&ResourcePostgresProject{client: client}).DoCreate(ctx, &PostgresProjectState{ + ProjectId: "test-project-for-branch", + DisplayName: new("Test Project for Branch"), + PgVersion: new(16), }) if err != nil { return nil, err } return &resources.PostgresBranch{ - Parent: "projects/test-project-for-branch", - BranchId: "test-branch", - BranchSpec: postgres.BranchSpec{}, + Parent: "projects/test-project-for-branch", + BranchId: "test-branch", }, nil }, - "postgres_snapshot_schedules": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "postgres_snapshot_schedules": func(ctx context.Context, client *sdkclients.Clients) (any, error) { // Creating the project implicitly provisions the root "production" // branch, the only branch a snapshot schedule may target. - _, err := client.Postgres.CreateProject(ctx, postgres.CreateProjectRequest{ - ProjectId: "test-project-for-snapshot-schedule", - Project: postgres.Project{ - Spec: &postgres.ProjectSpec{ - DisplayName: "Test Project for Snapshot Schedule", - PgVersion: 16, - }, - }, + _, _, err := (&ResourcePostgresProject{client: client}).DoCreate(ctx, &PostgresProjectState{ + ProjectId: "test-project-for-snapshot-schedule", + DisplayName: new("Test Project for Snapshot Schedule"), + PgVersion: new(16), }) if err != nil { return nil, err @@ -810,26 +803,21 @@ var testDeps = map[string]prepareWorkspace{ }, nil }, - "postgres_endpoints": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "postgres_endpoints": func(ctx context.Context, client *sdkclients.Clients) (any, error) { // Create parent project first - _, err := client.Postgres.CreateProject(ctx, postgres.CreateProjectRequest{ - ProjectId: "test-project-for-endpoint", - Project: postgres.Project{ - Spec: &postgres.ProjectSpec{ - DisplayName: "Test Project for Endpoint", - PgVersion: 16, - }, - }, + _, _, err := (&ResourcePostgresProject{client: client}).DoCreate(ctx, &PostgresProjectState{ + ProjectId: "test-project-for-endpoint", + DisplayName: new("Test Project for Endpoint"), + PgVersion: new(16), }) if err != nil { return nil, err } // Create parent branch - _, err = client.Postgres.CreateBranch(ctx, postgres.CreateBranchRequest{ + _, _, err = (&ResourcePostgresBranch{client: client}).DoCreate(ctx, &PostgresBranchState{ Parent: "projects/test-project-for-endpoint", BranchId: "test-branch-for-endpoint", - Branch: postgres.Branch{}, }) if err != nil { return nil, err @@ -838,30 +826,25 @@ var testDeps = map[string]prepareWorkspace{ return &resources.PostgresEndpoint{ Parent: "projects/test-project-for-endpoint/branches/test-branch-for-endpoint", EndpointId: "test-endpoint", - EndpointType: postgres.EndpointTypeEndpointTypeReadWrite, + EndpointType: postgres.EndpointType_EndpointTypeReadWrite, }, nil }, - "postgres_databases": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "postgres_databases": func(ctx context.Context, client *sdkclients.Clients) (any, error) { // Create parent project first - _, err := client.Postgres.CreateProject(ctx, postgres.CreateProjectRequest{ - ProjectId: "test-project-for-database", - Project: postgres.Project{ - Spec: &postgres.ProjectSpec{ - DisplayName: "Test Project for Database", - PgVersion: 16, - }, - }, + _, _, err := (&ResourcePostgresProject{client: client}).DoCreate(ctx, &PostgresProjectState{ + ProjectId: "test-project-for-database", + DisplayName: new("Test Project for Database"), + PgVersion: new(16), }) if err != nil { return nil, err } // Create parent branch - _, err = client.Postgres.CreateBranch(ctx, postgres.CreateBranchRequest{ + _, _, err = (&ResourcePostgresBranch{client: client}).DoCreate(ctx, &PostgresBranchState{ Parent: "projects/test-project-for-database", BranchId: "test-branch-for-database", - Branch: postgres.Branch{}, }) if err != nil { return nil, err @@ -870,31 +853,26 @@ var testDeps = map[string]prepareWorkspace{ return &resources.PostgresDatabase{ Parent: "projects/test-project-for-database/branches/test-branch-for-database", DatabaseId: "test-database", - PostgresDatabase: "app_db", - Role: "projects/test-project-for-database/branches/test-branch-for-database/roles/owner", + PostgresDatabase: new("app_db"), + Role: new("projects/test-project-for-database/branches/test-branch-for-database/roles/owner"), }, nil }, - "postgres_roles": func(ctx context.Context, client *databricks.WorkspaceClient) (any, error) { + "postgres_roles": func(ctx context.Context, client *sdkclients.Clients) (any, error) { // Create parent project first - _, err := client.Postgres.CreateProject(ctx, postgres.CreateProjectRequest{ - ProjectId: "test-project-for-role", - Project: postgres.Project{ - Spec: &postgres.ProjectSpec{ - DisplayName: "Test Project for Role", - PgVersion: 16, - }, - }, + _, _, err := (&ResourcePostgresProject{client: client}).DoCreate(ctx, &PostgresProjectState{ + ProjectId: "test-project-for-role", + DisplayName: new("Test Project for Role"), + PgVersion: new(16), }) if err != nil { return nil, err } // Create parent branch - _, err = client.Postgres.CreateBranch(ctx, postgres.CreateBranchRequest{ + _, _, err = (&ResourcePostgresBranch{client: client}).DoCreate(ctx, &PostgresBranchState{ Parent: "projects/test-project-for-role", BranchId: "test-branch-for-role", - Branch: postgres.Branch{}, }) if err != nil { return nil, err @@ -903,7 +881,7 @@ var testDeps = map[string]prepareWorkspace{ return &resources.PostgresRole{ Parent: "projects/test-project-for-role/branches/test-branch-for-role", RoleId: "test-role", - PostgresRole: "test_role", + PostgresRole: new("test_role"), }, nil }, } @@ -1001,7 +979,7 @@ func (f *testIgnoreFilter) requireEqual(t *testing.T, expected, actual any, msgA require.Empty(t, relevantChanges, msgAndArgs...) } -func testCRUD(t *testing.T, group string, adapter *Adapter, client *databricks.WorkspaceClient) { +func testCRUD(t *testing.T, group string, adapter *Adapter, client *sdkclients.Clients) { var inputConfig any var err error @@ -1150,7 +1128,7 @@ func testCRUD(t *testing.T, group string, adapter *Adapter, client *databricks.W // WaitAfterDelete polls until the resource reads back gone; a NotFound is that // success and the caller (DeploymentUnit.waitDeleted) maps it to nil, so accept it here too. err = adapter.WaitAfterDelete(ctx, createdID) - if !apierr.IsMissing(err) { + if !apierrs.IsMissing(err) { require.NoError(t, err) } @@ -1406,10 +1384,10 @@ func TestNameStableOrOptedOut(t *testing.T) { } } -func setupTestServerClient(t *testing.T) (*testserver.Server, *databricks.WorkspaceClient) { +func setupTestServerClient(t *testing.T) (*testserver.Server, *sdkclients.Clients) { server := testserver.New(t) testserver.AddDefaultHandlers(server) - client, err := databricks.NewWorkspaceClient(&databricks.Config{ + client, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", RateLimitPerSecond: math.MaxInt, diff --git a/bundle/direct/dresources/apitypes.generated.yml b/bundle/direct/dresources/apitypes.generated.yml index af96326fa4c..a1c73ffc7ec 100644 --- a/bundle/direct/dresources/apitypes.generated.yml +++ b/bundle/direct/dresources/apitypes.generated.yml @@ -8,7 +8,7 @@ catalogs: catalog.CreateCatalog cluster_policies: compute.CreatePolicy -clusters: compute.ClusterSpec +clusters: compute.CreateCluster dashboards: dashboards.Dashboard diff --git a/bundle/direct/dresources/app.go b/bundle/direct/dresources/app.go index 22cd7cc2b4e..33abc13986b 100644 --- a/bundle/direct/dresources/app.go +++ b/bundle/direct/dresources/app.go @@ -2,21 +2,21 @@ package dresources import ( "context" - "errors" "fmt" - "slices" "strings" "time" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/bundle/appdeploy" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/bundle/direct/internal/retries" + "github.com/databricks/cli/libs/sdkclients" + apps "github.com/databricks/cli/libs/sdktypes/apps/v1" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/retries" - "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/cli/libs/utils" + sdkapps "github.com/databricks/sdk-go/apps/v1" ) // AppState is the state type for App resources. source_code_path and git_source come from @@ -35,29 +35,11 @@ type AppRemote struct { Lifecycle *StateLifecycle `json:"lifecycle,omitempty"` } -// Custom marshalers needed because embedded apps.App has its own MarshalJSON -// which would otherwise take over and ignore the additional fields. -func (s *AppState) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s AppState) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (r *AppRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, r) -} - -func (r AppRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(r) -} - type ResourceApp struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceApp) New(client *databricks.WorkspaceClient) *ResourceApp { +func (*ResourceApp) New(client *sdkclients.Clients) *ResourceApp { return &ResourceApp{client: client} } @@ -85,8 +67,20 @@ func (*ResourceApp) RemapState(remote *AppRemote) *AppState { } } +func (r *ResourceApp) getApp(ctx context.Context, name string) (*sdkapps.App, error) { + return r.client.Apps.GetApp(ctx, sdkapps.GetAppRequest{Name: new(name)}) +} + func (r *ResourceApp) DoRead(ctx context.Context, id string) (*AppRemote, error) { - app, err := r.client.Apps.GetByName(ctx, id) + app, err := r.getApp(ctx, id) + if err != nil { + return nil, err + } + return makeAppRemote(app) +} + +func makeAppRemote(resp *sdkapps.App) (*AppRemote, error) { + app, err := apps.AppFromSDK(resp) if err != nil { return nil, err } @@ -107,46 +101,43 @@ func (r *ResourceApp) DoRead(ctx context.Context, id string) (*AppRemote, error) } // appRequestBody returns config.App with the deploy-only fields cleared. source_code_path -// and git_source became part of apps.App in SDK v0.175, but DABs applies them through the -// Deploy API (see manageLifecycle), so they must not ride along in create/update bodies. -// ForceSendFields is cloned and stripped of SourceCodePath because the SDK's JSON -// unmarshal (used when loading the plan) adds every present basic-type field to -// ForceSendFields, which would otherwise force "source_code_path": "" into the body. -func appRequestBody(config *AppState) apps.App { +// and git_source are part of apps.App, but DABs applies them through the Deploy API (see +// manageLifecycle), so they must not ride along in create/update bodies. +func appRequestBody(config *AppState) *apps.App { app := config.App - app.SourceCodePath = "" + app.SourceCodePath = nil app.GitSource = nil - app.ForceSendFields = slices.DeleteFunc(slices.Clone(app.ForceSendFields), func(s string) bool { - return s == "SourceCodePath" - }) - return app + return &app } func (r *ResourceApp) DoCreate(ctx context.Context, config *AppState) (string, *AppRemote, error) { // Start app compute only when lifecycle.started=true is explicit. // For nil (omitted) or false, use no_compute=true (do not start compute). noCompute := config.Lifecycle == nil || config.Lifecycle.Started == nil || !*config.Lifecycle.Started - request := apps.CreateAppRequest{ - App: appRequestBody(config), - NoCompute: noCompute, - ForceSendFields: nil, + request, err := apps.CreateAppRequestToSDK(&apps.CreateAppRequest{ + App: appRequestBody(config), + NoCompute: new(noCompute), + }) + if err != nil { + return "", nil, err } - retrier := retries.New[apps.App](retries.WithTimeout(15*time.Minute), retries.WithRetryFunc(shouldRetry)) - app, err := retrier.Run(ctx, func(ctx context.Context) (*apps.App, error) { - waiter, err := r.client.Apps.Create(ctx, request) + name := utils.Deref(config.Name) + retrier := retries.New[sdkapps.App](retries.WithTimeout(15*time.Minute), retries.WithRetryFunc(shouldRetry)) + _, err = retrier.Run(ctx, func(ctx context.Context) (*sdkapps.App, error) { + _, err := r.client.Apps.CreateApp(ctx, *request) if err != nil { - if errors.Is(err, apierr.ErrResourceAlreadyExists) { + if apierrs.Is(err, apierrs.ErrResourceAlreadyExists) { // Check if the app is in DELETING state - only then should we retry - existingApp, getErr := r.client.Apps.GetByName(ctx, config.Name) + existingApp, getErr := r.getApp(ctx, name) if getErr != nil { // If we can't get the app (e.g., it was just deleted), retry the create - if apierr.IsMissing(getErr) { + if apierrs.IsMissing(getErr) { return nil, retries.Continues("app was deleted, retrying create") } return nil, retries.Halt(err) } - if existingApp.ComputeStatus != nil && existingApp.ComputeStatus.State == apps.ComputeStateDeleting { + if existingApp.ComputeStatus != nil && existingApp.ComputeStatus.State == sdkapps.ComputeStatus_ComputeState_Deleting { return nil, retries.Continues("app is deleting, retrying create") } // App exists and is not being deleted - this is a hard error @@ -154,13 +145,13 @@ func (r *ResourceApp) DoCreate(ctx context.Context, config *AppState) (string, * } return nil, retries.Halt(err) } - return waiter.Response, nil + return nil, nil }) if err != nil { return "", nil, err } - return app.Name, nil, nil + return name, nil, nil } var UpdateMaskFields = []string{ @@ -182,24 +173,32 @@ func (r *ResourceApp) DoUpdate(ctx context.Context, id string, config *AppState, // Deploy-only fields (source_code_path, config, git_source, lifecycle) are excluded // from the request body; see appRequestBody. if hasAppChanges(entry) { - app := appRequestBody(config) - request := apps.AsyncUpdateAppRequest{ - App: &app, - AppName: id, - UpdateMask: updateMask, + request, err := apps.AsyncUpdateAppRequestToSDK(&apps.AsyncUpdateAppRequest{ + App: appRequestBody(config), + AppName: new(id), + UpdateMask: new(updateMask), + }) + if err != nil { + return nil, err } - updateWaiter, err := r.client.Apps.CreateUpdate(ctx, request) + updateWaiter, err := r.client.Apps.AsyncUpdateApp(ctx, *request) if err != nil { return nil, err } - response, err := updateWaiter.Get() + response, err := updateWaiter.Wait(ctx) if err != nil { return nil, err } - if response.Status.State != apps.AppUpdateUpdateStatusUpdateStateSucceeded { - return nil, fmt.Errorf("update status: %s: %s", response.Status.State, response.Status.Message) + var state sdkapps.AppUpdate_UpdateStatus_UpdateState + var message string + if response.Status != nil { + state = response.Status.State + message = utils.Deref(response.Status.Message) + } + if state != sdkapps.AppUpdate_UpdateStatus_UpdateState_Succeeded { + return nil, fmt.Errorf("update status: %s: %s", state, message) } } @@ -215,11 +214,11 @@ func (r *ResourceApp) manageLifecycle(ctx context.Context, id string, config *Ap if desiredStarted { // lifecycle.started=true: ensure the app compute is running and deploy the latest code. if !alreadyStarted { - startWaiter, err := r.client.Apps.Start(ctx, apps.StartAppRequest{Name: id}) + startWaiter, err := r.client.Apps.StartApp(ctx, sdkapps.StartAppRequest{Name: new(id)}) if err != nil { return err } - startedApp, err := startWaiter.Get() + startedApp, err := startWaiter.Wait(ctx) if err != nil { return err } @@ -227,18 +226,21 @@ func (r *ResourceApp) manageLifecycle(ctx context.Context, id string, config *Ap return err } } - deployment := appdeploy.BuildDeployment(config.SourceCodePath, config.Config, config.GitSource) + deployment, err := appdeploy.BuildDeployment(utils.Deref(config.SourceCodePath), config.Config, config.GitSource) + if err != nil { + return err + } if err := appdeploy.Deploy(ctx, r.client, id, deployment); err != nil { return err } } else { // lifecycle.started=false: ensure the app compute is stopped. if alreadyStarted { - stopWaiter, err := r.client.Apps.Stop(ctx, apps.StopAppRequest{Name: id}) + stopWaiter, err := r.client.Apps.StopApp(ctx, sdkapps.StopAppRequest{Name: new(id)}) if err != nil { return err } - if _, err = stopWaiter.Get(); err != nil { + if _, err = stopWaiter.Wait(ctx); err != nil { return err } } @@ -271,8 +273,8 @@ func (*ResourceApp) OverrideChangeDesc(_ context.Context, path *structpath.PathN func isComputeStopped(app *apps.App) bool { return app.ComputeStatus == nil || - app.ComputeStatus.State == apps.ComputeStateStopped || - app.ComputeStatus.State == apps.ComputeStateError + app.ComputeStatus.State == apps.ComputeStatus_ComputeState_Stopped || + app.ComputeStatus.State == apps.ComputeStatus_ComputeState_Error } // remoteIsStarted reads the compute started state from the plan entry's remote state. @@ -301,9 +303,9 @@ func deploymentToAppConfig(d *apps.AppDeployment) *resources.AppConfig { config.Env = make([]resources.AppEnvVar, len(d.EnvVars)) for i, ev := range d.EnvVars { config.Env[i] = resources.AppEnvVar{ - Name: ev.Name, - Value: ev.Value, - ValueFrom: ev.ValueFrom, + Name: utils.Deref(ev.Name), + Value: utils.Deref(ev.Value), + ValueFrom: utils.Deref(ev.ValueFrom), } } } @@ -311,7 +313,7 @@ func deploymentToAppConfig(d *apps.AppDeployment) *resources.AppConfig { } func (r *ResourceApp) DoDelete(ctx context.Context, id string, _ *AppState) error { - _, err := r.client.Apps.DeleteByName(ctx, id) + _, err := r.client.Apps.DeleteApp(ctx, sdkapps.DeleteAppRequest{Name: new(id)}) return err } @@ -327,16 +329,17 @@ func (r *ResourceApp) DoDelete(ctx context.Context, id string, _ *AppState) erro // Still uncovered: a DELETING app hit during a normal deploy/update (not a // delete) produces a spurious update/skip because plan/apply do not special-case it there. func (*ResourceApp) IsGone(remote *AppRemote) bool { - return remote.ComputeStatus != nil && remote.ComputeStatus.State == apps.ComputeStateDeleting + return remote.ComputeStatus != nil && remote.ComputeStatus.State == apps.ComputeStatus_ComputeState_Deleting } func (r *ResourceApp) WaitAfterCreate(ctx context.Context, id string, config *AppState) (*AppRemote, error) { - remote, err := r.waitForApp(ctx, r.client, config.Name) + name := utils.Deref(config.Name) + remote, err := r.waitForApp(ctx, name) if err != nil { return nil, err } alreadyStarted := remote.Lifecycle != nil && remote.Lifecycle.Started != nil && *remote.Lifecycle.Started - if err := r.manageLifecycle(ctx, config.Name, config, alreadyStarted); err != nil { + if err := r.manageLifecycle(ctx, name, config, alreadyStarted); err != nil { return nil, err } return remote, nil @@ -347,21 +350,25 @@ func (r *ResourceApp) WaitAfterCreate(ctx context.Context, id string, config *Ap // We can't use the default waiter from SDK because it only waits on ACTIVE state but we need also STOPPED state. // Ideally this should be done in Go SDK but currently only ACTIVE is marked as terminal state // so this would need to be addressed by Apps service team first in their proto. -func (r *ResourceApp) waitForApp(ctx context.Context, w *databricks.WorkspaceClient, name string) (*AppRemote, error) { - retrier := retries.New[apps.App](retries.WithTimeout(-1), retries.WithRetryFunc(shouldRetry)) - app, err := retrier.Run(ctx, func(ctx context.Context) (*apps.App, error) { - app, err := w.Apps.GetByName(ctx, name) +func (r *ResourceApp) waitForApp(ctx context.Context, name string) (*AppRemote, error) { + retrier := retries.New[sdkapps.App](retries.WithTimeout(-1), retries.WithRetryFunc(shouldRetry)) + app, err := retrier.Run(ctx, func(ctx context.Context) (*sdkapps.App, error) { + app, err := r.getApp(ctx, name) if err != nil { return nil, retries.Halt(err) } - status := app.ComputeStatus.State - statusMessage := app.ComputeStatus.Message + var status sdkapps.ComputeStatus_ComputeState + var statusMessage string + if app.ComputeStatus != nil { + status = app.ComputeStatus.State + statusMessage = utils.Deref(app.ComputeStatus.Message) + } switch status { - case apps.ComputeStateActive, apps.ComputeStateStopped: + case sdkapps.ComputeStatus_ComputeState_Active, sdkapps.ComputeStatus_ComputeState_Stopped: return app, nil - case apps.ComputeStateError: + case sdkapps.ComputeStatus_ComputeState_Error: err := fmt.Errorf("failed to reach %s or %s, got %s: %s", - apps.ComputeStateActive, apps.ComputeStateStopped, status, statusMessage) + sdkapps.ComputeStatus_ComputeState_Active, sdkapps.ComputeStatus_ComputeState_Stopped, status, statusMessage) return nil, retries.Halt(err) default: return nil, retries.Continues(statusMessage) @@ -370,16 +377,5 @@ func (r *ResourceApp) waitForApp(ctx context.Context, w *databricks.WorkspaceCli if err != nil { return nil, err } - started := !isComputeStopped(app) - remote := &AppRemote{ - App: *app, - Config: nil, - Lifecycle: &StateLifecycle{Started: &started}, - } - if app.ActiveDeployment != nil { - remote.SourceCodePath = app.DefaultSourceCodePath - remote.GitSource = app.ActiveDeployment.GitSource - remote.Config = deploymentToAppConfig(app.ActiveDeployment) - } - return remote, nil + return makeAppRemote(app) } diff --git a/bundle/direct/dresources/app_test.go b/bundle/direct/dresources/app_test.go index a32dbdeb0ed..7f13ff0b5ae 100644 --- a/bundle/direct/dresources/app_test.go +++ b/bundle/direct/dresources/app_test.go @@ -7,9 +7,10 @@ import ( "strings" "testing" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/apps/v1" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -34,9 +35,9 @@ func TestAppDoCreate_RetriesWhenAppIsDeleting(t *testing.T) { } } return apps.App{ - Name: "test-app", + Name: new("test-app"), ComputeStatus: &apps.ComputeStatus{ - State: apps.ComputeStateActive, + State: apps.ComputeStatus_ComputeState_Active, }, } }) @@ -44,16 +45,16 @@ func TestAppDoCreate_RetriesWhenAppIsDeleting(t *testing.T) { server.Handle("GET", "/api/2.0/apps/{name}", func(req testserver.Request) any { getCallCount++ return apps.App{ - Name: req.Vars["name"], + Name: new(req.Vars["name"]), ComputeStatus: &apps.ComputeStatus{ - State: apps.ComputeStateDeleting, + State: apps.ComputeStatus_ComputeState_Deleting, }, } }) testserver.AddDefaultHandlers(server) - client, err := databricks.NewWorkspaceClient(&databricks.Config{ + client, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", }) @@ -61,7 +62,7 @@ func TestAppDoCreate_RetriesWhenAppIsDeleting(t *testing.T) { r := (&ResourceApp{}).New(client) ctx := t.Context() - name, _, err := r.DoCreate(ctx, &AppState{Name: "test-app"}) + name, _, err := r.DoCreate(ctx, &AppState{Name: new("test-app")}) require.NoError(t, err) assert.Equal(t, "test-app", name) @@ -89,9 +90,9 @@ func TestAppDoCreate_RetriesWhenGetReturnsNotFound(t *testing.T) { } } return apps.App{ - Name: "test-app", + Name: new("test-app"), ComputeStatus: &apps.ComputeStatus{ - State: apps.ComputeStateActive, + State: apps.ComputeStatus_ComputeState_Active, }, } }) @@ -109,7 +110,7 @@ func TestAppDoCreate_RetriesWhenGetReturnsNotFound(t *testing.T) { testserver.AddDefaultHandlers(server) - client, err := databricks.NewWorkspaceClient(&databricks.Config{ + client, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", }) @@ -117,7 +118,7 @@ func TestAppDoCreate_RetriesWhenGetReturnsNotFound(t *testing.T) { r := (&ResourceApp{}).New(client) ctx := t.Context() - name, _, err := r.DoCreate(ctx, &AppState{Name: "test-app"}) + name, _, err := r.DoCreate(ctx, &AppState{Name: new("test-app")}) require.NoError(t, err) assert.Equal(t, "test-app", name) @@ -173,35 +174,28 @@ func TestAppDoUpdate_UpdateMaskHasAllFields(t *testing.T) { } } -// TestAppRequestBody_StripsSourceCodePathFromForceSendFields verifies that -// appRequestBody removes SourceCodePath from ForceSendFields even when the plan -// JSON round-trip has forced it in — reproduces the v1.14.0 regression where -// "source_code_path": "" was sent in the UpdateApp body, causing a 400. -func TestAppRequestBody_StripsSourceCodePathFromForceSendFields(t *testing.T) { +// TestAppRequestBody_StripsDeployOnlyFields verifies that appRequestBody removes +// source_code_path and git_source, which DABs applies through the Deploy API, so +// that they never reach the create/update body (a "source_code_path": "" in the +// UpdateApp body caused a 400 in v1.14.0). +func TestAppRequestBody_StripsDeployOnlyFields(t *testing.T) { config := &AppState{ - Name: "my-app", - SourceCodePath: "/Workspace/Users/me/app", - // Simulate ForceSendFields as populated by marshal.Unmarshal when the - // plan entry is deserialized from JSON (ToStructVar calls json.Unmarshal, - // which calls apps.App.UnmarshalJSON -> marshal.Unmarshal, which adds - // every basic-type field present in the JSON to ForceSendFields). - ForceSendFields: []string{"Name", "SourceCodePath"}, + Name: new("my-app"), + SourceCodePath: new("/Workspace/Users/me/app"), + GitSource: &apps.GitSource{Branch: new("main")}, } body := appRequestBody(config) - // SourceCodePath must be cleared and absent from ForceSendFields so that - // the SDK's marshal.Marshal omits it from the request body. - assert.Empty(t, body.SourceCodePath) - assert.NotContains(t, body.ForceSendFields, "SourceCodePath") + assert.Nil(t, body.SourceCodePath) + assert.Nil(t, body.GitSource) + // The config itself is not modified. + assert.Equal(t, "/Workspace/Users/me/app", *config.SourceCodePath) - // Verify the field is absent from the marshaled JSON (the root cause of the 400). data, err := json.Marshal(body) require.NoError(t, err) var m map[string]any require.NoError(t, json.Unmarshal(data, &m)) assert.NotContains(t, m, "source_code_path", "source_code_path must not appear in the UpdateApp request body") - - // Other ForceSendFields entries must be preserved. - assert.Contains(t, body.ForceSendFields, "Name") + assert.Equal(t, "my-app", m["name"]) } diff --git a/bundle/direct/dresources/catalog.go b/bundle/direct/dresources/catalog.go index 638138bfbda..87a211e53b3 100644 --- a/bundle/direct/dresources/catalog.go +++ b/bundle/direct/dresources/catalog.go @@ -2,28 +2,28 @@ package dresources import ( "context" - "slices" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" + catalogs "github.com/databricks/cli/libs/sdktypes/uc/catalogs/v1" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/catalog" + sdkcatalogs "github.com/databricks/sdk-go/uc/catalogs/v1" ) type ResourceCatalog struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceCatalog) New(client *databricks.WorkspaceClient) *ResourceCatalog { +func (*ResourceCatalog) New(client *sdkclients.Clients) *ResourceCatalog { return &ResourceCatalog{client: client} } -func (*ResourceCatalog) PrepareState(input *resources.Catalog) *catalog.CreateCatalog { +func (*ResourceCatalog) PrepareState(input *resources.Catalog) *resources.CreateCatalog { return &input.CreateCatalog } -func (*ResourceCatalog) RemapState(info *catalog.CatalogInfo) *catalog.CreateCatalog { - return &catalog.CreateCatalog{ +func (*ResourceCatalog) RemapState(info *catalogs.CatalogInfo) *resources.CreateCatalog { + return &resources.CreateCatalog{ Comment: info.Comment, ConnectionName: info.ConnectionName, CustomMaxRetentionHours: info.CustomMaxRetentionHours, @@ -34,92 +34,105 @@ func (*ResourceCatalog) RemapState(info *catalog.CatalogInfo) *catalog.CreateCat ProviderName: info.ProviderName, ShareName: info.ShareName, StorageRoot: info.StorageRoot, - ForceSendFields: utils.FilterFields[catalog.CreateCatalog](info.ForceSendFields), } } -func (r *ResourceCatalog) DoRead(ctx context.Context, id string) (*catalog.CatalogInfo, error) { - return r.client.Catalogs.GetByName(ctx, id) +func (r *ResourceCatalog) DoRead(ctx context.Context, id string) (*catalogs.CatalogInfo, error) { + info, err := r.client.Catalogs.GetCatalog(ctx, sdkcatalogs.GetCatalogRequest{ + NameArg: new(id), + IncludeBrowse: nil, // Not applicable for basic catalog retrieval + }) + if err != nil { + return nil, err + } + return catalogs.CatalogInfoFromSDK(info) } -func (r *ResourceCatalog) DoCreate(ctx context.Context, config *catalog.CreateCatalog) (string, *catalog.CatalogInfo, error) { - response, err := r.client.Catalogs.Create(ctx, *config) - if err != nil || response == nil { +func (r *ResourceCatalog) DoCreate(ctx context.Context, config *resources.CreateCatalog) (string, *catalogs.CatalogInfo, error) { + request, err := toSDK[sdkcatalogs.CreateCatalogRequest](config.AsRequest()) + if err != nil { return "", nil, err } - return response.Name, response, nil -} - -// See schemaForceSend. Verified against a real workspace: {"comment": ""} clears it. -// -// CustomMaxRetentionHours is force-sent here even though schemaForceSend deliberately omits it: -// that omission was for parity with the removed Terraform engine, which does not apply to catalogs -// anyway. Verified against a real workspace: {"custom_max_retention_hours": 0} clears it (an empty PATCH is otherwise -// rejected with "Nothing to update"). -var catalogForceSend = []string{"Comment", "CustomMaxRetentionHours"} - -// DoUpdate updates the catalog in place and returns remote state. -func (r *ResourceCatalog) DoUpdate(ctx context.Context, id string, config *catalog.CreateCatalog, _ *PlanEntry) (*catalog.CatalogInfo, error) { - updateRequest := catalog.UpdateCatalog{ - Comment: config.Comment, - CustomMaxRetentionHours: config.CustomMaxRetentionHours, - EnablePredictiveOptimization: "", // Not supported by DABs - IsolationMode: "", // Not supported by DABs - ManagedEncryptionSettings: config.ManagedEncryptionSettings, - Name: id, - NewName: "", // Only set if name actually changes (see DoUpdateWithID) - Options: config.Options, - Owner: "", // Not supported by DABs - Properties: config.Properties, - ForceSendFields: utils.FilterFields[catalog.UpdateCatalog](append(slices.Clone(catalogForceSend), config.ForceSendFields...), "EnablePredictiveOptimization", "IsolationMode", "Owner"), + response, err := r.client.Catalogs.CreateCatalog(ctx, request) + if err != nil || response == nil { + return "", nil, err } - - response, err := r.client.Catalogs.Update(ctx, updateRequest) + info, err := catalogs.CatalogInfoFromSDK(response) if err != nil { - return nil, err + return "", nil, err } + return utils.Deref(info.Name), info, nil +} - return response, nil +// DoUpdate updates the catalog in place and returns remote state. +func (r *ResourceCatalog) DoUpdate(ctx context.Context, id string, config *resources.CreateCatalog, _ *PlanEntry) (*catalogs.CatalogInfo, error) { + return r.update(ctx, id, config, nil) } // DoUpdateWithID updates the catalog and returns the new ID if the name changes. -func (r *ResourceCatalog) DoUpdateWithID(ctx context.Context, id string, config *catalog.CreateCatalog, _ *PlanEntry) (string, *catalog.CatalogInfo, error) { - updateRequest := catalog.UpdateCatalog{ - Comment: config.Comment, - CustomMaxRetentionHours: config.CustomMaxRetentionHours, - EnablePredictiveOptimization: "", // Not supported by DABs - IsolationMode: "", // Not supported by DABs - ManagedEncryptionSettings: config.ManagedEncryptionSettings, - Name: id, - NewName: "", // Initialized below if needed - Options: config.Options, - Owner: "", // Not supported by DABs - Properties: config.Properties, - ForceSendFields: utils.FilterFields[catalog.UpdateCatalog](append(slices.Clone(catalogForceSend), config.ForceSendFields...), "EnablePredictiveOptimization", "IsolationMode", "Owner"), - } - - if config.Name != id { - updateRequest.NewName = config.Name +func (r *ResourceCatalog) DoUpdateWithID(ctx context.Context, id string, config *resources.CreateCatalog, _ *PlanEntry) (string, *catalogs.CatalogInfo, error) { + var newName *string + if name := utils.Deref(config.Name); name != id { + newName = new(name) } - - response, err := r.client.Catalogs.Update(ctx, updateRequest) + info, err := r.update(ctx, id, config, newName) if err != nil { return "", nil, err } - - // Return the new name as the ID if it changed, otherwise return the old ID - newID := id - if updateRequest.NewName != "" { - newID = updateRequest.NewName + if newName != nil { + return *newName, info, nil } + return id, info, nil +} - return newID, response, nil +func (r *ResourceCatalog) update(ctx context.Context, id string, config *resources.CreateCatalog, newName *string) (*catalogs.CatalogInfo, error) { + // Owner, isolation_mode and enable_predictive_optimization are not supported by DABs. + request, err := toSDK[sdkcatalogs.UpdateCatalogRequest](&catalogs.UpdateCatalogRequest{ + NameArg: new(id), + NewName: newName, + // Always sent so that removing them from config clears them. Verified against a real + // workspace: {"comment": ""} and {"custom_max_retention_hours": 0} clear the values (an + // empty PATCH is otherwise rejected with "Nothing to update"). + Comment: orZero(config.Comment), + CustomMaxRetentionHours: orZero(config.CustomMaxRetentionHours), + ManagedEncryptionSettings: config.ManagedEncryptionSettings, + Options: config.Options, + Properties: config.Properties, + BrowseOnly: nil, // Output only + CatalogType: "", // Output only + ConnectionName: nil, // Output only + CreatedAt: nil, // Output only + CreatedBy: nil, // Output only + EffectivePredictiveOptimizationFlag: nil, // Output only + EnablePredictiveOptimization: nil, // Not supported by DABs + FullName: nil, // Output only + IsolationMode: "", // Not supported by DABs + MetastoreId: nil, // Output only + Name: nil, // Read-only; use NewName for updates + Owner: nil, // Not supported by DABs + ProviderName: nil, // Output only + ProvisioningInfo: nil, // Output only + SecurableType: "", // Output only + ShareName: nil, // Output only + StorageLocation: nil, // Output only + StorageRoot: nil, // Output only + UpdatedAt: nil, // Output only + UpdatedBy: nil, // Output only + }) + if err != nil { + return nil, err + } + response, err := r.client.Catalogs.UpdateCatalog(ctx, request) + if err != nil { + return nil, err + } + return catalogs.CatalogInfoFromSDK(response) } -func (r *ResourceCatalog) DoDelete(ctx context.Context, id string, _ *catalog.CreateCatalog) error { - return r.client.Catalogs.Delete(ctx, catalog.DeleteCatalogRequest{ - Name: id, - Force: true, - ForceSendFields: nil, +func (r *ResourceCatalog) DoDelete(ctx context.Context, id string, _ *resources.CreateCatalog) error { + _, err := r.client.Catalogs.DeleteCatalog(ctx, sdkcatalogs.DeleteCatalogRequest{ + NameArg: new(id), + Force: new(true), }) + return err } diff --git a/bundle/direct/dresources/cluster.go b/bundle/direct/dresources/cluster.go index 82167080c4d..ca23b5cf973 100644 --- a/bundle/direct/dresources/cluster.go +++ b/bundle/direct/dresources/cluster.go @@ -2,21 +2,24 @@ package dresources import ( "context" - "errors" "fmt" + "slices" "strings" "time" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/bundle/direct/internal/retries" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/clusterlibraries/v2" + "github.com/databricks/cli/libs/sdktypes/clusters/v2" + "github.com/databricks/cli/libs/sdktypes/sdkconv" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/retries" - "github.com/databricks/databricks-sdk-go/service/compute" + sdkclusterlibraries "github.com/databricks/sdk-go/clusterlibraries/v2" + sdkclusters "github.com/databricks/sdk-go/clusters/v2" "golang.org/x/sync/errgroup" ) @@ -30,31 +33,21 @@ const librariesWaitTimeout = 15 * time.Minute // 30 minutes before giving up. Terminal states still halt immediately. const clusterWaitTimeout = 30 * time.Minute -// ClusterState is the state type for Cluster resources. It extends compute.ClusterSpec with +// ClusterState is the state type for Cluster resources. It extends clusters.CreateClusterRequest with // lifecycle settings and the cluster ID. // ClusterId is written to state by DoCreate/DoUpdate for informational purposes; it is not // used in diff computation (neither PrepareState nor RemapState set it). type ClusterState struct { - compute.ClusterSpec + clusters.CreateClusterRequest Lifecycle *StateLifecycle `json:"lifecycle,omitempty"` // Libraries are installed via the Libraries API, not the cluster spec, and managed as // part of the cluster (see reconcileLibraries and the install in WaitAfterCreate). - Libraries []compute.Library `json:"libraries,omitempty"` + Libraries []clusterlibraries.Library `json:"libraries,omitempty"` } -// Custom marshalers needed because embedded compute.ClusterSpec has its own MarshalJSON -// which would otherwise take over and ignore the additional fields. -func (s *ClusterState) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s ClusterState) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -// ClusterRemote extends compute.ClusterDetails with a synthetic Lifecycle field so that +// ClusterRemote extends clusters.ClusterInfo with a synthetic Lifecycle field so that // RemoteType satisfies TestRemoteSuperset (every field in ClusterState exists in ClusterRemote). // Lifecycle.Started is populated by DoRead from the cluster's running state. // @@ -63,28 +56,20 @@ func (s ClusterState) MarshalJSON() ([]byte, error) { // copies it up so RemapState stays a dumb copy and the field participates in normal drift // detection instead of being suppressed as missing_in_remote. type ClusterRemote struct { - compute.ClusterDetails - ApplyPolicyDefaultValues bool `json:"apply_policy_default_values,omitempty"` + clusters.ClusterInfo + ApplyPolicyDefaultValues *bool `json:"apply_policy_default_values,omitempty"` Lifecycle *StateLifecycle `json:"lifecycle,omitempty"` // Libraries is populated by DoRead from the Libraries cluster-status API (the cluster // GET does not return installed libraries), so it participates in drift detection. - Libraries []compute.Library `json:"libraries,omitempty"` -} - -func (r *ClusterRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, r) -} - -func (r ClusterRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(r) + Libraries []clusterlibraries.Library `json:"libraries,omitempty"` } type ResourceCluster struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (r *ResourceCluster) New(client *databricks.WorkspaceClient) any { +func (r *ResourceCluster) New(client *sdkclients.Clients) any { return &ResourceCluster{ client: client, } @@ -92,9 +77,9 @@ func (r *ResourceCluster) New(client *databricks.WorkspaceClient) any { func (r *ResourceCluster) PrepareState(input *resources.Cluster) *ClusterState { s := &ClusterState{ - ClusterSpec: input.ClusterSpec, - Lifecycle: nil, - Libraries: input.Libraries, + CreateClusterRequest: input.CreateClusterRequest, + Lifecycle: nil, + Libraries: input.Libraries, } if input.Lifecycle != nil && input.Lifecycle.Started != nil { s.Lifecycle = &StateLifecycle{Started: input.Lifecycle.Started} @@ -111,6 +96,7 @@ func (r *ResourceCluster) RemapState(input *ClusterRemote) *ClusterState { AutoterminationMinutes: input.AutoterminationMinutes, AwsAttributes: input.AwsAttributes, AzureAttributes: input.AzureAttributes, + CloneFrom: nil, // Not supported by DABs ClusterLogConf: input.ClusterLogConf, ClusterName: input.ClusterName, CustomTags: input.CustomTags, @@ -141,7 +127,6 @@ func (r *ResourceCluster) RemapState(input *ClusterRemote) *ClusterState { UseMlRuntime: input.UseMlRuntime, WorkloadType: input.WorkloadType, WorkerNodeTypeFlexibility: input.WorkerNodeTypeFlexibility, - ForceSendFields: utils.FilterFields[compute.ClusterSpec](input.ForceSendFields), Lifecycle: input.Lifecycle, Libraries: input.Libraries, } @@ -149,14 +134,14 @@ func (r *ResourceCluster) RemapState(input *ClusterRemote) *ClusterState { } func (r *ResourceCluster) DoRead(ctx context.Context, id string) (*ClusterRemote, error) { - var details *compute.ClusterDetails - var libraries []compute.Library + var details *clusters.ClusterInfo + var libraries []clusterlibraries.Library // The cluster GET and the library-status GET are independent, so run them concurrently. g, ctx := errgroup.WithContext(ctx) g.Go(func() error { var err error - details, err = r.client.Clusters.GetByClusterId(ctx, id) + details, err = r.getCluster(ctx, id) return err }) g.Go(func() error { @@ -169,8 +154,8 @@ func (r *ResourceCluster) DoRead(ctx context.Context, id string) (*ClusterRemote } remote := &ClusterRemote{ - ClusterDetails: *details, - ApplyPolicyDefaultValues: false, + ClusterInfo: *details, + ApplyPolicyDefaultValues: nil, Lifecycle: nil, Libraries: libraries, } @@ -181,12 +166,10 @@ func (r *ResourceCluster) DoRead(ctx context.Context, id string) (*ClusterRemote } switch details.State { - case compute.StateRunning: - started := true - remote.Lifecycle = &StateLifecycle{Started: &started} - case compute.StateTerminated: - started := false - remote.Lifecycle = &StateLifecycle{Started: &started} + case clusters.ClusterState_ClusterState_Running: + remote.Lifecycle = &StateLifecycle{Started: new(true)} + case clusters.ClusterState_ClusterState_Terminated: + remote.Lifecycle = &StateLifecycle{Started: new(false)} default: remote.Lifecycle = nil } @@ -194,18 +177,63 @@ func (r *ResourceCluster) DoRead(ctx context.Context, id string) (*ClusterRemote return remote, nil } +func (r *ResourceCluster) getCluster(ctx context.Context, id string) (*clusters.ClusterInfo, error) { + info, err := r.client.Clusters.GetCluster(ctx, sdkclusters.GetClusterRequest{ClusterId: new(id)}) + if err != nil { + return nil, err + } + return clusters.ClusterInfoFromSDK(info) +} + +// waitClusterState polls until the cluster reaches target. Reaching one of the +// failure states first is an error. +func (r *ResourceCluster) waitClusterState(ctx context.Context, id string, target clusters.ClusterState_ClusterState, failure ...clusters.ClusterState_ClusterState) error { + _, err := retries.Poll(ctx, clusterWaitTimeout, func() (*clusters.ClusterInfo, *retries.Err) { + details, err := r.getCluster(ctx, id) + if err != nil { + return nil, retries.Halt(err) + } + status := details.State + statusMessage := utils.Deref(details.StateMessage) + if status == target { + return details, nil + } + if slices.Contains(failure, status) { + return nil, retries.Halt(fmt.Errorf("failed to reach %s, got %s: %s", target, status, statusMessage)) + } + return nil, retries.Continues(statusMessage) + }) + return err +} + +func (r *ResourceCluster) waitRunning(ctx context.Context, id string) error { + return r.waitClusterState(ctx, id, clusters.ClusterState_ClusterState_Running, clusters.ClusterState_ClusterState_Error, clusters.ClusterState_ClusterState_Terminated) +} + +func (r *ResourceCluster) waitTerminated(ctx context.Context, id string) error { + return r.waitClusterState(ctx, id, clusters.ClusterState_ClusterState_Terminated, clusters.ClusterState_ClusterState_Error) +} + +func (r *ResourceCluster) clusterStatus(ctx context.Context, id string) (*clusterlibraries.ClusterLibraryStatuses, error) { + resp, err := r.client.Libraries.ClusterStatus(ctx, sdkclusterlibraries.ClusterStatusRequest{ClusterId: new(id)}) + if err != nil { + return nil, err + } + return clusterlibraries.ClusterLibraryStatusesFromSDK(resp) +} + // readLibraries returns the bundle-managed libraries installed on the cluster. // https://docs.databricks.com/api/workspace/libraries/clusterstatus -func (r *ResourceCluster) readLibraries(ctx context.Context, id string) ([]compute.Library, error) { - statuses, err := r.client.Libraries.ClusterStatusByClusterId(ctx, id) +func (r *ResourceCluster) readLibraries(ctx context.Context, id string) ([]clusterlibraries.Library, error) { + statuses, err := r.clusterStatus(ctx, id) if err != nil { return nil, err } - var libraries []compute.Library + var libraries []clusterlibraries.Library for _, s := range statuses.LibraryStatuses { // Libraries set for all clusters via the UI are not managed by the bundle; a library // pending uninstall on restart is on its way out. Skip both. - if s.Library == nil || s.IsLibraryForAllClusters || s.Status == compute.LibraryInstallStatusUninstallOnRestart { + if s.Library == nil || utils.Deref(s.IsLibraryForAllClusters) || s.Status == clusterlibraries.LibraryInstallStatus_UninstallOnRestart { continue } libraries = append(libraries, *s.Library) @@ -214,11 +242,15 @@ func (r *ResourceCluster) readLibraries(ctx context.Context, id string) ([]compu } func (r *ResourceCluster) DoCreate(ctx context.Context, config *ClusterState) (string, *ClusterRemote, error) { - wait, err := r.client.Clusters.Create(ctx, makeCreateCluster(&config.ClusterSpec)) + request, err := makeCreateCluster(&config.CreateClusterRequest) + if err != nil { + return "", nil, err + } + wait, err := r.client.Clusters.CreateCluster(ctx, request) if err != nil { return "", nil, err } - return wait.ClusterId, nil, nil + return wait.GetClusterId(), nil, nil } // hasClusterSpecChanges reports whether the plan entry changes a Cluster Edit API field — @@ -244,16 +276,20 @@ func (r *ResourceCluster) DoUpdate(ctx context.Context, id string, config *Clust if hasClusterSpecChanges(entry) { // Same retry as in TF provider logic // https://github.com/databricks/terraform-provider-databricks/blob/3eecd0f90cf99d7777e79a3d03c41f9b2aafb004/clusters/resource_cluster.go#L624 - _, err := retries.Poll(ctx, clusterWaitTimeout, func() (*compute.WaitGetClusterRunning[struct{}], *retries.Err) { - wait, err := r.client.Clusters.Edit(ctx, makeEditCluster(id, &config.ClusterSpec)) + request, err := makeEditCluster(id, &config.CreateClusterRequest) + if err != nil { + return nil, err + } + _, err = retries.Poll(ctx, clusterWaitTimeout, func() (*sdkclusters.EditClusterWaiter, *retries.Err) { + wait, err := r.client.Clusters.EditCluster(ctx, request) if err == nil { return wait, nil } // Only Running and Terminated clusters can be modified. In particular, autoscaling clusters cannot be modified // while the resizing is ongoing. We retry in this case. Scaling can take several minutes. - if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.ErrorCode == "INVALID_STATE" { - return nil, retries.Continues(fmt.Sprintf("cluster %s cannot be modified in its current state: %s", id, apiErr.Message)) + if apierrs.ErrorCode(err) == "INVALID_STATE" { + return nil, retries.Continues(fmt.Sprintf("cluster %s cannot be modified in its current state: %s", id, apierrs.Message(err))) } return nil, retries.Halt(err) }) @@ -284,12 +320,12 @@ func (r *ResourceCluster) DoUpdate(ctx context.Context, id string, config *Clust alreadyRunning := remoteClusterIsRunning(entry) if desiredStarted && !alreadyRunning { // lifecycle.started=true: fire Start; WaitAfterUpdate polls for RUNNING. - _, err := r.client.Clusters.Start(ctx, compute.StartCluster{ClusterId: id}) + _, err := r.client.Clusters.StartCluster(ctx, sdkclusters.StartClusterRequest{ClusterId: new(id)}) return nil, err } else if !desiredStarted && alreadyRunning { // lifecycle.started=false: fire Delete; WaitAfterUpdate polls for TERMINATED. // Note: Delete terminates the cluster; permanent removal is a separate API (permanent-delete). - _, err := r.client.Clusters.Delete(ctx, compute.DeleteCluster{ClusterId: id}) + _, err := r.client.Clusters.DeleteCluster(ctx, sdkclusters.DeleteClusterRequest{ClusterId: new(id)}) return nil, err } @@ -303,19 +339,16 @@ func (r *ResourceCluster) WaitAfterUpdate(ctx context.Context, id string, config } if *config.Lifecycle.Started { - _, err := r.client.Clusters.WaitGetClusterRunning(ctx, id, clusterWaitTimeout, nil) - return nil, err + return nil, r.waitRunning(ctx, id) } - - _, err := r.client.Clusters.WaitGetClusterTerminated(ctx, id, clusterWaitTimeout, nil) - return nil, err + return nil, r.waitTerminated(ctx, id) } // WaitAfterCreate waits for the cluster to reach RUNNING state (clusters always start on creation). // When lifecycle.started=false, it then terminates the cluster. func (r *ResourceCluster) WaitAfterCreate(ctx context.Context, id string, config *ClusterState) (*ClusterRemote, error) { // Always wait for RUNNING first: clusters start in PENDING state and must be polled. - _, err := r.client.Clusters.WaitGetClusterRunning(ctx, id, clusterWaitTimeout, nil) + err := r.waitRunning(ctx, id) if err != nil { return nil, err } @@ -325,7 +358,7 @@ func (r *ResourceCluster) WaitAfterCreate(ctx context.Context, id string, config // the create will cause a wait for libraries to be installed befor the cluster is installed. // this increases the risk of losing the cluster. This is a limitation if len(config.Libraries) > 0 { - err = r.client.Libraries.Install(ctx, compute.InstallLibraries{ClusterId: id, Libraries: config.Libraries}) + err = r.installLibraries(ctx, id, config.Libraries) if err != nil { return nil, err } @@ -337,30 +370,31 @@ func (r *ResourceCluster) WaitAfterCreate(ctx context.Context, id string, config if config.Lifecycle != nil && config.Lifecycle.Started != nil && !*config.Lifecycle.Started { // started=false: terminate the cluster after it reaches RUNNING. // Note: Delete terminates the cluster; permanent removal is a separate API (permanent-delete). - deleteWaiter, err := r.client.Clusters.Delete(ctx, compute.DeleteCluster{ClusterId: id}) + _, err := r.client.Clusters.DeleteCluster(ctx, sdkclusters.DeleteClusterRequest{ClusterId: new(id)}) if err != nil { return nil, err } - _, err = deleteWaiter.GetWithTimeout(clusterWaitTimeout) - return nil, err + return nil, r.waitTerminated(ctx, id) } return nil, nil } func (r *ResourceCluster) DoResize(ctx context.Context, id string, config *ClusterState, entry *PlanEntry) error { - _, err := r.client.Clusters.Resize(ctx, compute.ResizeCluster{ - ClusterId: id, - NumWorkers: config.NumWorkers, - Autoscale: config.Autoscale, - ForceSendFields: utils.FilterFields[compute.ResizeCluster](config.ForceSendFields), + request, err := clusters.ResizeClusterRequestToSDK(&clusters.ResizeClusterRequest{ + ClusterId: new(id), + NumWorkers: config.NumWorkers, + Autoscale: config.Autoscale, }) + if err != nil { + return err + } + _, err = r.client.Clusters.ResizeCluster(ctx, *request) if err == nil { return nil } - apiErr, ok := errors.AsType[*apierr.APIError](err) - if !ok || apiErr.ErrorCode != "INVALID_STATE" { + if apierrs.ErrorCode(err) != "INVALID_STATE" { return err } @@ -371,7 +405,8 @@ func (r *ResourceCluster) DoResize(ctx context.Context, id string, config *Clust } func (r *ResourceCluster) DoDelete(ctx context.Context, id string, _ *ClusterState) error { - return r.client.Clusters.PermanentDeleteByClusterId(ctx, id) + _, err := r.client.Clusters.PermanentDeleteCluster(ctx, sdkclusters.PermanentDeleteClusterRequest{ClusterId: new(id)}) + return err } func (r *ResourceCluster) OverrideChangeDesc(ctx context.Context, p *structpath.PathNode, change *ChangeDesc, remoteState *ClusterRemote) error { @@ -386,19 +421,19 @@ func (r *ResourceCluster) OverrideChangeDesc(ctx context.Context, p *structpath. case "data_security_mode": // We do change skip here in the same way TF provider does suppress diff if the alias is used. // https://github.com/databricks/terraform-provider-databricks/blob/main/clusters/resource_cluster.go#L109-L117 - if change.New == compute.DataSecurityModeDataSecurityModeStandard && change.Remote == compute.DataSecurityModeUserIsolation && change.New == change.Old { + if change.New == clusters.DataSecurityMode_DataSecurityModeStandard && change.Remote == clusters.DataSecurityMode_UserIsolation && change.New == change.Old { change.Action = deployplan.Skip change.Reason = deployplan.ReasonAlias - } else if change.New == compute.DataSecurityModeDataSecurityModeDedicated && change.Remote == compute.DataSecurityModeSingleUser && change.New == change.Old { + } else if change.New == clusters.DataSecurityMode_DataSecurityModeDedicated && change.Remote == clusters.DataSecurityMode_SingleUser && change.New == change.Old { change.Action = deployplan.Skip change.Reason = deployplan.ReasonAlias - } else if change.New == compute.DataSecurityModeDataSecurityModeAuto && (change.Remote == compute.DataSecurityModeSingleUser || change.Remote == compute.DataSecurityModeUserIsolation) && change.New == change.Old { + } else if change.New == clusters.DataSecurityMode_DataSecurityModeAuto && (change.Remote == clusters.DataSecurityMode_SingleUser || change.Remote == clusters.DataSecurityMode_UserIsolation) && change.New == change.Old { change.Action = deployplan.Skip change.Reason = deployplan.ReasonAlias } case "num_workers", "autoscale": - if remoteState != nil && remoteState.State == compute.StateRunning { + if remoteState != nil && remoteState.State == clusters.ClusterState_ClusterState_Running { change.Action = deployplan.Resize } @@ -424,107 +459,41 @@ func remoteClusterIsRunning(entry *PlanEntry) bool { if !ok { return false } - return remote.State == compute.StateRunning + return remote.State == clusters.ClusterState_ClusterState_Running } -func makeCreateCluster(config *compute.ClusterSpec) compute.CreateCluster { - create := compute.CreateCluster{ - ApplyPolicyDefaultValues: config.ApplyPolicyDefaultValues, - Autoscale: config.Autoscale, - AutoterminationMinutes: config.AutoterminationMinutes, - AwsAttributes: config.AwsAttributes, - AzureAttributes: config.AzureAttributes, - ClusterLogConf: config.ClusterLogConf, - ClusterName: config.ClusterName, - CloneFrom: nil, // Not supported by DABs - CustomTags: config.CustomTags, - DataSecurityMode: config.DataSecurityMode, - DependencyMode: config.DependencyMode, - DockerImage: config.DockerImage, - DriverInstancePoolId: config.DriverInstancePoolId, - DriverNodeTypeId: config.DriverNodeTypeId, - DriverNodeTypeFlexibility: config.DriverNodeTypeFlexibility, - EnableElasticDisk: config.EnableElasticDisk, - EnableLocalDiskEncryption: config.EnableLocalDiskEncryption, - GcpAttributes: config.GcpAttributes, - InitScripts: config.InitScripts, - InstancePoolId: config.InstancePoolId, - IsSingleNode: config.IsSingleNode, - Kind: config.Kind, - NodeTypeId: config.NodeTypeId, - NumWorkers: config.NumWorkers, - PolicyId: config.PolicyId, - RemoteDiskThroughput: config.RemoteDiskThroughput, - RuntimeEngine: config.RuntimeEngine, - SingleUserName: config.SingleUserName, - SparkConf: config.SparkConf, - SparkEnvVars: config.SparkEnvVars, - SparkVersion: config.SparkVersion, - SshPublicKeys: config.SshPublicKeys, - TotalInitialRemoteDiskSize: config.TotalInitialRemoteDiskSize, - UseMlRuntime: config.UseMlRuntime, - WorkloadType: config.WorkloadType, - WorkerNodeTypeFlexibility: config.WorkerNodeTypeFlexibility, - ForceSendFields: utils.FilterFields[compute.CreateCluster](config.ForceSendFields), - } +func makeCreateCluster(config *clusters.CreateClusterRequest) (sdkclusters.CreateClusterRequest, error) { + create := *config + create.CloneFrom = nil // Not supported by DABs // If autoscale is not set, we need to send NumWorkers because one of them is required. - // If NumWorkers is not nil, we don't need to set it to ForceSendFields as it will be sent anyway. - if config.Autoscale == nil && config.NumWorkers == 0 { - create.ForceSendFields = append(create.ForceSendFields, "NumWorkers") - } - - return create -} - -func makeEditCluster(id string, config *compute.ClusterSpec) compute.EditCluster { - edit := compute.EditCluster{ - ClusterId: id, - ApplyPolicyDefaultValues: config.ApplyPolicyDefaultValues, - Autoscale: config.Autoscale, - AutoterminationMinutes: config.AutoterminationMinutes, - AwsAttributes: config.AwsAttributes, - AzureAttributes: config.AzureAttributes, - ClusterLogConf: config.ClusterLogConf, - ClusterName: config.ClusterName, - CustomTags: config.CustomTags, - DataSecurityMode: config.DataSecurityMode, - DependencyMode: config.DependencyMode, - DockerImage: config.DockerImage, - DriverInstancePoolId: config.DriverInstancePoolId, - DriverNodeTypeId: config.DriverNodeTypeId, - DriverNodeTypeFlexibility: config.DriverNodeTypeFlexibility, - EnableElasticDisk: config.EnableElasticDisk, - EnableLocalDiskEncryption: config.EnableLocalDiskEncryption, - GcpAttributes: config.GcpAttributes, - InitScripts: config.InitScripts, - InstancePoolId: config.InstancePoolId, - IsSingleNode: config.IsSingleNode, - Kind: config.Kind, - NodeTypeId: config.NodeTypeId, - NumWorkers: config.NumWorkers, - PolicyId: config.PolicyId, - RemoteDiskThroughput: config.RemoteDiskThroughput, - RuntimeEngine: config.RuntimeEngine, - SingleUserName: config.SingleUserName, - SparkConf: config.SparkConf, - SparkEnvVars: config.SparkEnvVars, - SparkVersion: config.SparkVersion, - SshPublicKeys: config.SshPublicKeys, - TotalInitialRemoteDiskSize: config.TotalInitialRemoteDiskSize, - UseMlRuntime: config.UseMlRuntime, - WorkloadType: config.WorkloadType, - WorkerNodeTypeFlexibility: config.WorkerNodeTypeFlexibility, - ForceSendFields: utils.FilterFields[compute.EditCluster](config.ForceSendFields), + if create.Autoscale == nil && create.NumWorkers == nil { + create.NumWorkers = new(0) } + request, err := clusters.CreateClusterRequestToSDK(&create) + if err != nil { + return sdkclusters.CreateClusterRequest{}, err + } + return *request, nil +} + +func makeEditCluster(id string, config *clusters.CreateClusterRequest) (sdkclusters.EditClusterRequest, error) { + create := *config + create.CloneFrom = nil // Not supported by the edit API + // If autoscale is not set, we need to send NumWorkers because one of them is required. - // If NumWorkers is not nil, we don't need to set it to ForceSendFields as it will be sent anyway. - if config.Autoscale == nil && config.NumWorkers == 0 { - edit.ForceSendFields = append(edit.ForceSendFields, "NumWorkers") + if create.Autoscale == nil && create.NumWorkers == nil { + create.NumWorkers = new(0) } - return edit + // EditClusterRequest is CreateClusterRequest without clone_from plus the cluster id. + request, err := sdkconv.ToSDK[sdkclusters.EditClusterRequest](&create) + if err != nil { + return sdkclusters.EditClusterRequest{}, err + } + request.ClusterId = new(id) + return *request, nil } // librariesPath is the ClusterState path of the libraries slice, used to detect library changes. @@ -538,22 +507,34 @@ func (*ResourceCluster) KeyedSlices() map[string]any { // reconcileLibraries uninstalls libraries dropped from config and installs the desired set. // The Libraries API exposes install and uninstall as separate endpoints, so this is two calls. -func (r *ResourceCluster) reconcileLibraries(ctx context.Context, id string, desired []compute.Library, entry *PlanEntry) error { +func (r *ResourceCluster) reconcileLibraries(ctx context.Context, id string, desired []clusterlibraries.Library, entry *PlanEntry) error { removed := removedLibraries(desired, entry) if len(removed) > 0 { - err := r.client.Libraries.Uninstall(ctx, compute.UninstallLibraries{ClusterId: id, Libraries: removed}) + request, err := clusterlibraries.UninstallLibrariesRequestToSDK(&clusterlibraries.UninstallLibrariesRequest{ClusterId: new(id), Libraries: removed}) if err != nil { return err } + if _, err := r.client.Libraries.UninstallLibraries(ctx, *request); err != nil { + return err + } } if len(desired) > 0 { - return r.client.Libraries.Install(ctx, compute.InstallLibraries{ClusterId: id, Libraries: desired}) + return r.installLibraries(ctx, id, desired) } return nil } +func (r *ResourceCluster) installLibraries(ctx context.Context, id string, libraries []clusterlibraries.Library) error { + request, err := clusterlibraries.InstallLibrariesRequestToSDK(&clusterlibraries.InstallLibrariesRequest{ClusterId: new(id), Libraries: libraries}) + if err != nil { + return err + } + _, err = r.client.Libraries.InstallLibraries(ctx, *request) + return err +} + // removedLibraries returns libraries present in the remote state but absent from the desired set. -func removedLibraries(desired []compute.Library, entry *PlanEntry) []compute.Library { +func removedLibraries(desired []clusterlibraries.Library, entry *PlanEntry) []clusterlibraries.Library { remote, ok := entry.RemoteState.(*ClusterRemote) if !ok || remote == nil { return nil @@ -562,7 +543,7 @@ func removedLibraries(desired []compute.Library, entry *PlanEntry) []compute.Lib for _, l := range desired { desiredKeys[libraryMapKey(l)] = struct{}{} } - var result []compute.Library + var result []clusterlibraries.Library for _, l := range remote.Libraries { if _, ok := desiredKeys[libraryMapKey(l)]; !ok { result = append(result, l) @@ -574,15 +555,15 @@ func removedLibraries(desired []compute.Library, entry *PlanEntry) []compute.Lib // waitForInstall polls until every desired library reaches a terminal installed state. It returns // early without waiting when the cluster is not running: installs only progress on a running // cluster and are queued until it next starts. -func (r *ResourceCluster) waitForInstall(ctx context.Context, id string, desired []compute.Library) error { +func (r *ResourceCluster) waitForInstall(ctx context.Context, id string, desired []clusterlibraries.Library) error { if len(desired) == 0 { return nil } - details, err := r.client.Clusters.GetByClusterId(ctx, id) + details, err := r.getCluster(ctx, id) if err != nil { return err } - if details.State != compute.StateRunning { + if details.State != clusters.ClusterState_ClusterState_Running { log.Debugf(ctx, "cluster %s is not running (%s); skipping wait for library installation", id, details.State) return nil } @@ -598,7 +579,7 @@ func (r *ResourceCluster) waitForInstall(ctx context.Context, id string, desired } _, err = retries.Poll(ctx, librariesWaitTimeout, func() (*struct{}, *retries.Err) { - statuses, err := r.client.Libraries.ClusterStatusByClusterId(ctx, id) + statuses, err := r.clusterStatus(ctx, id) if err != nil { return nil, retries.Halt(err) } @@ -611,12 +592,14 @@ func (r *ResourceCluster) waitForInstall(ctx context.Context, id string, desired continue } switch s.Status { - case compute.LibraryInstallStatusFailed: + case clusterlibraries.LibraryInstallStatus_Failed: return nil, retries.Halt(fmt.Errorf("library %s failed to install: %s", libraryWaitMapKey(*s.Library), strings.Join(s.Messages, "; "))) - case compute.LibraryInstallStatusInstalled, compute.LibraryInstallStatusSkipped, compute.LibraryInstallStatusRestored: + case clusterlibraries.LibraryInstallStatus_Installed, clusterlibraries.LibraryInstallStatus_Skipped, clusterlibraries.LibraryInstallStatus_Restored: pending-- - case compute.LibraryInstallStatusPending, compute.LibraryInstallStatusResolving, compute.LibraryInstallStatusInstalling, compute.LibraryInstallStatusUninstallOnRestart: + case clusterlibraries.LibraryInstallStatus_Resolving, clusterlibraries.LibraryInstallStatus_Installing, clusterlibraries.LibraryInstallStatus_UninstallOnRestart: // Still in progress (or being removed); keep polling. + case clusterlibraries.LibraryInstallStatus_Unspecified: + // Unknown status; treat as in progress } } if pending > 0 { @@ -628,48 +611,48 @@ func (r *ResourceCluster) waitForInstall(ctx context.Context, id string, desired } // libraryWaitKey identifies a library by its primary field only, used to match install-status reports. -func libraryWaitKey(l compute.Library) (string, string) { +func libraryWaitKey(l clusterlibraries.Library) (string, string) { switch { - case l.Whl != "": - return "whl", l.Whl - case l.Jar != "": - return "jar", l.Jar - case l.Egg != "": - return "egg", l.Egg - case l.Requirements != "": - return "requirements", l.Requirements + case utils.Deref(l.Whl) != "": + return "whl", *l.Whl + case utils.Deref(l.Jar) != "": + return "jar", *l.Jar + case utils.Deref(l.Egg) != "": + return "egg", *l.Egg + case utils.Deref(l.Requirements) != "": + return "requirements", *l.Requirements case l.Pypi != nil: - return "pypi", l.Pypi.Package + return "pypi", utils.Deref(l.Pypi.Package) case l.Maven != nil: - return "maven", l.Maven.Coordinates + return "maven", utils.Deref(l.Maven.Coordinates) case l.Cran != nil: - return "cran", l.Cran.Package + return "cran", utils.Deref(l.Cran.Package) } return "", "" } // libraryKey extends libraryWaitKey with repo/exclusions so a repo-only change is detected. -func libraryKey(l compute.Library) (string, string) { +func libraryKey(l clusterlibraries.Library) (string, string) { typ, id := libraryWaitKey(l) switch { case l.Pypi != nil: - return typ, id + ";" + l.Pypi.Repo + return typ, id + ";" + utils.Deref(l.Pypi.Repo) case l.Maven != nil: - return typ, id + ";" + l.Maven.Repo + ";" + strings.Join(l.Maven.Exclusions, ",") + return typ, id + ";" + utils.Deref(l.Maven.Repo) + ";" + strings.Join(l.Maven.Exclusions, ",") case l.Cran != nil: - return typ, id + ";" + l.Cran.Repo + return typ, id + ";" + utils.Deref(l.Cran.Repo) } return typ, id } // libraryMapKey flattens libraryKey into a single string for map lookups. -func libraryMapKey(l compute.Library) string { +func libraryMapKey(l clusterlibraries.Library) string { f, v := libraryKey(l) return f + "=" + v } // libraryWaitMapKey flattens libraryWaitKey into a single string for map lookups. -func libraryWaitMapKey(l compute.Library) string { +func libraryWaitMapKey(l clusterlibraries.Library) string { f, v := libraryWaitKey(l) return f + "=" + v } diff --git a/bundle/direct/dresources/cluster_policy.go b/bundle/direct/dresources/cluster_policy.go index ae69390b9cc..282e161fc42 100644 --- a/bundle/direct/dresources/cluster_policy.go +++ b/bundle/direct/dresources/cluster_policy.go @@ -4,35 +4,36 @@ import ( "context" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" + clusterpolicies "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/compute" + sdkclusterpolicies "github.com/databricks/sdk-go/clusterpolicies/v2" ) type ResourceClusterPolicy struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceClusterPolicy) New(client *databricks.WorkspaceClient) *ResourceClusterPolicy { +func (*ResourceClusterPolicy) New(client *sdkclients.Clients) *ResourceClusterPolicy { return &ResourceClusterPolicy{client: client} } -func (*ResourceClusterPolicy) PrepareState(input *resources.ClusterPolicy) *compute.CreatePolicy { - cp := input.CreatePolicy +func (*ResourceClusterPolicy) PrepareState(input *resources.ClusterPolicy) *clusterpolicies.CreatePolicyRequest { + cp := input.CreatePolicyRequest // Copy the shadow fields, already normalized to JSON strings by ConfigureClusterPolicyDefinition. if s, ok := input.Definition.(string); ok { - cp.Definition = s + cp.Definition = new(s) } if s, ok := input.PolicyFamilyDefinitionOverrides.(string); ok { - cp.PolicyFamilyDefinitionOverrides = s + cp.PolicyFamilyDefinitionOverrides = new(s) } return &cp } -// RemapState copies the config fields shared by Policy and CreatePolicy; +// RemapState copies the config fields shared by Policy and CreatePolicyRequest; // output-only fields (policy_id, created_at_timestamp, creator_user_name, is_default) are not in the state. -func (*ResourceClusterPolicy) RemapState(remote *compute.Policy) *compute.CreatePolicy { - return &compute.CreatePolicy{ +func (*ResourceClusterPolicy) RemapState(remote *clusterpolicies.Policy) *clusterpolicies.CreatePolicyRequest { + return &clusterpolicies.CreatePolicyRequest{ Definition: remote.Definition, Description: remote.Description, Libraries: remote.Libraries, @@ -40,26 +41,32 @@ func (*ResourceClusterPolicy) RemapState(remote *compute.Policy) *compute.Create Name: remote.Name, PolicyFamilyDefinitionOverrides: remote.PolicyFamilyDefinitionOverrides, PolicyFamilyId: remote.PolicyFamilyId, - ForceSendFields: utils.FilterFields[compute.CreatePolicy](remote.ForceSendFields), } } -func (r *ResourceClusterPolicy) DoRead(ctx context.Context, id string) (*compute.Policy, error) { - return r.client.ClusterPolicies.GetByPolicyId(ctx, id) +func (r *ResourceClusterPolicy) DoRead(ctx context.Context, id string) (*clusterpolicies.Policy, error) { + policy, err := r.client.ClusterPolicies.GetPolicy(ctx, sdkclusterpolicies.GetPolicyRequest{PolicyId: new(id)}) + if err != nil { + return nil, err + } + return clusterpolicies.PolicyFromSDK(policy) } -func (r *ResourceClusterPolicy) DoCreate(ctx context.Context, config *compute.CreatePolicy) (string, *compute.Policy, error) { - resp, err := r.client.ClusterPolicies.Create(ctx, *config) +func (r *ResourceClusterPolicy) DoCreate(ctx context.Context, config *clusterpolicies.CreatePolicyRequest) (string, *clusterpolicies.Policy, error) { + request, err := clusterpolicies.CreatePolicyRequestToSDK(config) if err != nil { return "", nil, err } - - return resp.PolicyId, nil, nil + resp, err := r.client.ClusterPolicies.CreatePolicy(ctx, *request) + if err != nil { + return "", nil, err + } + return utils.Deref(resp.PolicyId), nil, nil } -func (r *ResourceClusterPolicy) DoUpdate(ctx context.Context, id string, config *compute.CreatePolicy, _ *PlanEntry) (*compute.Policy, error) { - return nil, r.client.ClusterPolicies.Edit(ctx, compute.EditPolicy{ - PolicyId: id, +func (r *ResourceClusterPolicy) DoUpdate(ctx context.Context, id string, config *clusterpolicies.CreatePolicyRequest, _ *PlanEntry) (*clusterpolicies.Policy, error) { + request, err := clusterpolicies.EditPolicyRequestToSDK(&clusterpolicies.EditPolicyRequest{ + PolicyId: new(id), Name: config.Name, Definition: config.Definition, Description: config.Description, @@ -67,10 +74,15 @@ func (r *ResourceClusterPolicy) DoUpdate(ctx context.Context, id string, config MaxClustersPerUser: config.MaxClustersPerUser, PolicyFamilyDefinitionOverrides: config.PolicyFamilyDefinitionOverrides, PolicyFamilyId: config.PolicyFamilyId, - ForceSendFields: utils.FilterFields[compute.EditPolicy](config.ForceSendFields), }) + if err != nil { + return nil, err + } + _, err = r.client.ClusterPolicies.EditPolicy(ctx, *request) + return nil, err } -func (r *ResourceClusterPolicy) DoDelete(ctx context.Context, id string, _ *compute.CreatePolicy) error { - return r.client.ClusterPolicies.DeleteByPolicyId(ctx, id) +func (r *ResourceClusterPolicy) DoDelete(ctx context.Context, id string, _ *clusterpolicies.CreatePolicyRequest) error { + _, err := r.client.ClusterPolicies.DeletePolicy(ctx, sdkclusterpolicies.DeletePolicyRequest{PolicyId: new(id)}) + return err } diff --git a/bundle/direct/dresources/cluster_policy_test.go b/bundle/direct/dresources/cluster_policy_test.go index 60377bfd0b3..ff49bef9994 100644 --- a/bundle/direct/dresources/cluster_policy_test.go +++ b/bundle/direct/dresources/cluster_policy_test.go @@ -3,6 +3,8 @@ package dresources import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config/resources" "github.com/stretchr/testify/assert" ) @@ -36,12 +38,12 @@ func TestClusterPolicyPrepareState(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { input := &resources.ClusterPolicy{Definition: tt.definition} - input.Name = "my_policy" + input.Name = new("my_policy") got := (*ResourceClusterPolicy)(nil).PrepareState(input) - assert.Equal(t, tt.want, got.Definition) - assert.Equal(t, "my_policy", got.Name) + assert.Equal(t, tt.want, utils.Deref(got.Definition)) + assert.Equal(t, "my_policy", utils.Deref(got.Name)) }) } } diff --git a/bundle/direct/dresources/cluster_test.go b/bundle/direct/dresources/cluster_test.go index 7d3af4440d4..639581dc664 100644 --- a/bundle/direct/dresources/cluster_test.go +++ b/bundle/direct/dresources/cluster_test.go @@ -4,14 +4,14 @@ import ( "testing" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/libs/sdktypes/clusterlibraries/v2" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/compute" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestClusterOverrideChangeDescLibraries(t *testing.T) { - jobLib := []compute.Library{{Whl: "/Workspace/job.whl"}} + jobLib := []clusterlibraries.Library{{Whl: new("/Workspace/job.whl")}} tests := []struct { name string @@ -37,7 +37,7 @@ func TestClusterOverrideChangeDescLibraries(t *testing.T) { { name: "empty list stays managed", path: "libraries", - change: ChangeDesc{Action: deployplan.Update, Old: nil, New: []compute.Library{}, Remote: jobLib}, + change: ChangeDesc{Action: deployplan.Update, Old: nil, New: []clusterlibraries.Library{}, Remote: jobLib}, action: deployplan.Update, }, { diff --git a/bundle/direct/dresources/configs/model_serving_endpoints.generated.yml b/bundle/direct/dresources/configs/model_serving_endpoints.generated.yml index 71df6d6f832..0e930e38103 100644 --- a/bundle/direct/dresources/configs/model_serving_endpoints.generated.yml +++ b/bundle/direct/dresources/configs/model_serving_endpoints.generated.yml @@ -29,6 +29,30 @@ ignore_remote_changes: reason: spec:input_only - field: config.served_models[*].burst_scaling_enabled reason: spec:input_only + - field: config.served_models[*].external_model.ai21labs_config.ai21labs_api_key_plaintext + reason: spec:input_only + - field: config.served_models[*].external_model.amazon_bedrock_config.aws_access_key_id_plaintext + reason: spec:input_only + - field: config.served_models[*].external_model.amazon_bedrock_config.aws_secret_access_key_plaintext + reason: spec:input_only + - field: config.served_models[*].external_model.anthropic_config.anthropic_api_key_plaintext + reason: spec:input_only + - field: config.served_models[*].external_model.cohere_config.cohere_api_key_plaintext + reason: spec:input_only + - field: config.served_models[*].external_model.custom_provider_config.api_key_auth.value_plaintext + reason: spec:input_only + - field: config.served_models[*].external_model.custom_provider_config.bearer_token_auth.token_plaintext + reason: spec:input_only + - field: config.served_models[*].external_model.databricks_model_serving_config.databricks_api_token_plaintext + reason: spec:input_only + - field: config.served_models[*].external_model.google_cloud_vertex_ai_config.private_key_plaintext + reason: spec:input_only + - field: config.served_models[*].external_model.openai_config.microsoft_entra_client_secret_plaintext + reason: spec:input_only + - field: config.served_models[*].external_model.openai_config.openai_api_key_plaintext + reason: spec:input_only + - field: config.served_models[*].external_model.palm_config.palm_api_key_plaintext + reason: spec:input_only - field: telemetry_config.inference_table_config.name reason: spec:output_only diff --git a/bundle/direct/dresources/configs/model_serving_endpoints.yml b/bundle/direct/dresources/configs/model_serving_endpoints.yml index c1f88a79a7c..e2f6e638bff 100644 --- a/bundle/direct/dresources/configs/model_serving_endpoints.yml +++ b/bundle/direct/dresources/configs/model_serving_endpoints.yml @@ -38,10 +38,6 @@ backend_defaults: # common.CustomizeSchemaPath(m, "config", "served_entities", "name").SetComputed() - field: config.served_entities[*].name - # https://github.com/databricks/terraform-provider-databricks/blob/4eba541abe1a9f50993ea7b9dd83874207e224a1/serving/resource_model_serving.go#L384 - # common.CustomizeSchemaPath(m, "config", "served_entities", "workload_type").SetComputed() - - field: config.served_entities[*].workload_type - # https://github.com/databricks/terraform-provider-databricks/blob/4eba541abe1a9f50993ea7b9dd83874207e224a1/serving/resource_model_serving.go#L372 # common.CustomizeSchemaPath(m, "config", "auto_capture_config", "enabled").SetComputed() - field: config.auto_capture_config.enabled diff --git a/bundle/direct/dresources/dashboard.go b/bundle/direct/dresources/dashboard.go index c47fed477fc..145f5333c86 100644 --- a/bundle/direct/dresources/dashboard.go +++ b/bundle/direct/dresources/dashboard.go @@ -4,25 +4,25 @@ import ( "context" "fmt" "path" - "slices" "strings" - "time" + + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/lakeview/v1" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/dashboards" + "github.com/databricks/sdk-go/core/types" + sdklakeview "github.com/databricks/sdk-go/lakeview/v1" "golang.org/x/sync/errgroup" ) // Terraform implementation reference: https://github.com/databricks/terraform-provider-databricks/blob/main/dashboards/resource_dashboard.go type ResourceDashboard struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } type DashboardState struct { @@ -40,15 +40,6 @@ type DashboardState struct { Published bool `json:"published"` } -// We need these dummy methiods otherwise custom marshaller from DashboardConfig takes over and ignores Published field -func (s *DashboardState) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s DashboardState) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - // ensureWorkspacePrefix adds the /Workspace prefix to the parent path if it's not already present. // The backend removes this prefix from parent path, and thus it needs to be added back // to match the local configuration. The default parent_path (i.e. ${workspace.resource_path}) @@ -63,7 +54,7 @@ func ensureWorkspacePrefix(parentPath string) string { return path.Join("/Workspace", parentPath) } -func (*ResourceDashboard) New(client *databricks.WorkspaceClient) *ResourceDashboard { +func (*ResourceDashboard) New(client *sdkclients.Clients) *ResourceDashboard { return &ResourceDashboard{client: client} } @@ -75,24 +66,24 @@ func (*ResourceDashboard) PrepareState(input *resources.Dashboard) *DashboardSta } func (r *ResourceDashboard) DoRead(ctx context.Context, id string) (*DashboardState, error) { - var dashboard *dashboards.Dashboard - var publishedDashboard *dashboards.PublishedDashboard + var dashboardResp *sdklakeview.Dashboard + var publishedResp *sdklakeview.PublishedDashboard var publishedErr error g, ctx := errgroup.WithContext(ctx) g.Go(func() error { var err error - dashboard, err = r.client.Lakeview.Get(ctx, dashboards.GetDashboardRequest{ - DashboardId: id, + dashboardResp, err = r.client.Lakeview.GetDashboard(ctx, sdklakeview.GetDashboardRequest{ + DashboardId: new(id), }) return err }) g.Go(func() error { var err error - publishedDashboard, err = r.client.Lakeview.GetPublished(ctx, dashboards.GetPublishedDashboardRequest{ - DashboardId: id, + publishedResp, err = r.client.Lakeview.GetPublishedDashboard(ctx, sdklakeview.GetPublishedDashboardRequest{ + DashboardId: new(id), }) // Store error but don't fail - dashboard might be unpublished publishedErr = err @@ -103,9 +94,21 @@ func (r *ResourceDashboard) DoRead(ctx context.Context, id string) (*DashboardSt return nil, err } + dashboard, err := lakeview.DashboardFromSDK(dashboardResp) + if err != nil { + return nil, err + } + var publishedDashboard *lakeview.PublishedDashboard + if publishedErr == nil { + publishedDashboard, err = lakeview.PublishedDashboardFromSDK(publishedResp) + if err != nil { + return nil, err + } + } + // A trashed dashboard is considered deleted - return not found error - if dashboard.LifecycleState == dashboards.LifecycleStateTrashed { - return nil, apierr.ErrNotFound + if dashboard.LifecycleState == lakeview.LifecycleState_Trashed { + return nil, errResourceDoesNotExist("dashboard " + id + " is trashed") } // A dashboard is published (in the sense that matters for planning: the current @@ -113,192 +116,172 @@ func (r *ResourceDashboard) DoRead(ctx context.Context, id string) (*DashboardSt // published revision is at least as new as the draft. A draft update without a // republish leaves stale content published, but GetPublished keeps returning it, // so publishedErr == nil alone cannot detect staleness — the timestamp comparison - // can. If either timestamp is unparseable, fall back to publish-existence so we + // can. If either timestamp is missing, fall back to publish-existence so we // don't spuriously republish. See DashboardState.Published. published := publishedErr == nil && publishedIsCurrent(dashboard, publishedDashboard) - forceSendFields := utils.FilterFields[DashboardState](dashboard.ForceSendFields) - // EmbedCredentials must always be included in ForceSendFields to ensure it's serialized - // even when false (zero value). - if !slices.Contains(forceSendFields, "EmbedCredentials") { - forceSendFields = append(forceSendFields, "EmbedCredentials") - } - - var embedCredentials bool - if publishedDashboard != nil { - embedCredentials = publishedDashboard.EmbedCredentials - } - - return &DashboardState{ - DisplayName: dashboard.DisplayName, - Etag: dashboard.Etag, - WarehouseId: dashboard.WarehouseId, - SerializedDashboard: dashboard.SerializedDashboard, - ParentPath: ensureWorkspacePrefix(dashboard.ParentPath), - // diffs are detected via etags, which will change if dataset_catalog/dataset_schema is updated. - DatasetCatalog: "", - DatasetSchema: "", - - // Output only fields. - CreateTime: dashboard.CreateTime, - DashboardId: dashboard.DashboardId, - LifecycleState: dashboard.LifecycleState, - Path: dashboard.Path, - UpdateTime: dashboard.UpdateTime, - ForceSendFields: forceSendFields, - - EmbedCredentials: embedCredentials, - Published: published, - }, nil + state := dashboardToState(dashboard, publishedDashboard, utils.Deref(dashboard.SerializedDashboard), published) + return state, nil } // publishedIsCurrent reports whether the published revision reflects the current // draft, i.e. the dashboard was published after its last draft update. The published // API exposes no etag, only revision_create_time, so we compare it against the draft's -// update_time. Both are RFC3339 timestamps set by the backend on a shared clock -// (verified on AWS/GCP/Azure/dogfood: a publish always leaves revision_create_time >= -// update_time, and a draft update pushes update_time ahead until the next publish). -// If either timestamp is missing or unparseable, return true so we do not force a -// spurious republish. -func publishedIsCurrent(dashboard *dashboards.Dashboard, published *dashboards.PublishedDashboard) bool { +// update_time. Both are set by the backend on a shared clock (verified on +// AWS/GCP/Azure/dogfood: a publish always leaves revision_create_time >= update_time, +// and a draft update pushes update_time ahead until the next publish). If either +// timestamp is missing, return true so we do not force a spurious republish. +func publishedIsCurrent(dashboard *lakeview.Dashboard, published *lakeview.PublishedDashboard) bool { if published == nil { return false } - updateTime, err := time.Parse(time.RFC3339, dashboard.UpdateTime) - if err != nil { + if dashboard.UpdateTime == nil || published.RevisionCreateTime == nil { return true } - revisionTime, err := time.Parse(time.RFC3339, published.RevisionCreateTime) - if err != nil { - return true - } - return !revisionTime.Before(updateTime) + return !published.RevisionCreateTime.AsTime().Before(dashboard.UpdateTime.AsTime()) } -func prepareDashboardRequest(config *DashboardState) (dashboards.Dashboard, error) { - dashboard := dashboards.Dashboard{ - DisplayName: config.DisplayName, - ParentPath: config.ParentPath, - WarehouseId: config.WarehouseId, - Etag: config.Etag, - CreateTime: "", - DashboardId: "", - LifecycleState: "", - Path: "", - SerializedDashboard: "", - UpdateTime: "", - // Fields like "embed_credentials" are part of the bundle configuration but not the create request here. - // Thus we need to filter such fields out. - ForceSendFields: utils.FilterFields[dashboards.Dashboard](config.ForceSendFields), +func prepareDashboardRequest(config *DashboardState) (*lakeview.Dashboard, error) { + // Fields like "embed_credentials" are part of the bundle configuration but not the + // create/update request here. + dashboard := &lakeview.Dashboard{ + DisplayName: nonEmpty(config.DisplayName), + ParentPath: nonEmpty(config.ParentPath), + WarehouseId: nonEmpty(config.WarehouseId), + Etag: nonEmpty(config.Etag), + CreateTime: nil, // Not set by DABs + DashboardId: nil, // Not set by DABs + LifecycleState: "", // Not set by DABs + Path: nil, // Not set by DABs + SerializedDashboard: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs } switch v := config.SerializedDashboard.(type) { case nil: case string: - dashboard.SerializedDashboard = v + dashboard.SerializedDashboard = nonEmpty(v) default: - return dashboards.Dashboard{}, fmt.Errorf("internal error: serialized_dashboard should have been normalized to a string, got %T", v) + return nil, fmt.Errorf("internal error: serialized_dashboard should have been normalized to a string, got %T", v) } return dashboard, nil } -func (r *ResourceDashboard) publishDashboard(ctx context.Context, id string, config *DashboardState) (*dashboards.PublishedDashboard, error) { - // embed_credentials as a zero valued default in resourcemutator/resource_mutator.go. - // Thus we always need to include it in the ForceSendFields list to ensure that it is sent to the server. - forceSendFields := utils.FilterFields[dashboards.PublishRequest](config.ForceSendFields) - if !slices.Contains(forceSendFields, "EmbedCredentials") { - forceSendFields = append(forceSendFields, "EmbedCredentials") - } - - return r.client.Lakeview.Publish(ctx, dashboards.PublishRequest{ - DashboardId: id, - EmbedCredentials: config.EmbedCredentials, - WarehouseId: config.WarehouseId, - ForceSendFields: forceSendFields, +func (r *ResourceDashboard) publishDashboard(ctx context.Context, id string, config *DashboardState) (*lakeview.PublishedDashboard, error) { + // embed_credentials has a zero valued default in resourcemutator/resource_mutator.go, + // so it is always sent, including when false. + resp, err := r.client.Lakeview.PublishDashboard(ctx, sdklakeview.PublishDashboardRequest{ + DashboardId: new(id), + EmbedCredentials: new(config.EmbedCredentials), + WarehouseId: nonEmpty(config.WarehouseId), }) + if err != nil { + return nil, err + } + return lakeview.PublishedDashboardFromSDK(resp) } -func responseToState(createOrUpdateResp *dashboards.Dashboard, publishResp *dashboards.PublishedDashboard, serializedDashboard string, published bool) *DashboardState { - forceSendFields := utils.FilterFields[DashboardState](createOrUpdateResp.ForceSendFields) - // EmbedCredentials must always be included in ForceSendFields to ensure it's serialized - // even when false (zero value). - if !slices.Contains(forceSendFields, "EmbedCredentials") { - forceSendFields = append(forceSendFields, "EmbedCredentials") +func timeString(t *types.Time) string { + if t == nil { + return "" } + return t.String() +} +func dashboardToState(dashboard *lakeview.Dashboard, publishResp *lakeview.PublishedDashboard, serializedDashboard string, published bool) *DashboardState { var embedCredentials bool if publishResp != nil { - embedCredentials = publishResp.EmbedCredentials + embedCredentials = utils.Deref(publishResp.EmbedCredentials) } return &DashboardState{ - DisplayName: createOrUpdateResp.DisplayName, - Etag: createOrUpdateResp.Etag, - WarehouseId: createOrUpdateResp.WarehouseId, + DisplayName: utils.Deref(dashboard.DisplayName), + Etag: utils.Deref(dashboard.Etag), + WarehouseId: utils.Deref(dashboard.WarehouseId), SerializedDashboard: serializedDashboard, - ParentPath: ensureWorkspacePrefix(createOrUpdateResp.ParentPath), - DatasetCatalog: "", - DatasetSchema: "", + ParentPath: ensureWorkspacePrefix(utils.Deref(dashboard.ParentPath)), + // diffs are detected via etags, which will change if dataset_catalog/dataset_schema is updated. + DatasetCatalog: "", + DatasetSchema: "", // Output only fields - CreateTime: createOrUpdateResp.CreateTime, - DashboardId: createOrUpdateResp.DashboardId, - LifecycleState: createOrUpdateResp.LifecycleState, - Path: createOrUpdateResp.Path, - UpdateTime: createOrUpdateResp.UpdateTime, - ForceSendFields: forceSendFields, + CreateTime: timeString(dashboard.CreateTime), + DashboardId: utils.Deref(dashboard.DashboardId), + LifecycleState: dashboard.LifecycleState, + Path: utils.Deref(dashboard.Path), + UpdateTime: timeString(dashboard.UpdateTime), EmbedCredentials: embedCredentials, Published: published, } } +func (r *ResourceDashboard) createDashboard(ctx context.Context, dashboard *lakeview.Dashboard, config *DashboardState) (*lakeview.Dashboard, error) { + create := &lakeview.DashboardCreate{ + DisplayName: dashboard.DisplayName, + ParentPath: dashboard.ParentPath, + WarehouseId: dashboard.WarehouseId, + SerializedDashboard: dashboard.SerializedDashboard, + CreateTime: nil, // Not set by DABs + DashboardId: nil, // Not set by DABs + LifecycleState: "", // Not set by DABs + Path: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs + } + request, err := lakeview.CreateDashboardRequestToSDK(&lakeview.CreateDashboardRequest{ + Dashboard: create, + DatasetCatalog: nonEmpty(config.DatasetCatalog), + DatasetSchema: nonEmpty(config.DatasetSchema), + }) + if err != nil { + return nil, err + } + resp, err := r.client.Lakeview.CreateDashboard(ctx, *request) + if err != nil { + return nil, err + } + return lakeview.DashboardFromSDK(resp) +} + +func (r *ResourceDashboard) trashDashboard(ctx context.Context, id string) error { + _, err := r.client.Lakeview.TrashDashboard(ctx, sdklakeview.TrashDashboardRequest{DashboardId: new(id)}) + return err +} + func (r *ResourceDashboard) DoCreate(ctx context.Context, config *DashboardState) (string, *DashboardState, error) { dashboard, err := prepareDashboardRequest(config) if err != nil { return "", nil, err } - createResp, err := r.client.Lakeview.Create(ctx, dashboards.CreateDashboardRequest{ - Dashboard: dashboard, - DatasetCatalog: config.DatasetCatalog, - DatasetSchema: config.DatasetSchema, - - ForceSendFields: nil, - }) + createResp, err := r.createDashboard(ctx, dashboard, config) // The API returns 404 if the parent directory doesn't exist. // If the parent directory doesn't exist, create it and try again. - if err != nil && apierr.IsMissing(err) { + if err != nil && apierrs.IsMissing(err) { err = r.client.Workspace.MkdirsByPath(ctx, config.ParentPath) if err != nil { return "", nil, fmt.Errorf("failed to create parent directory: %w", err) } - createResp, err = r.client.Lakeview.Create(ctx, dashboards.CreateDashboardRequest{ - Dashboard: dashboard, - DatasetCatalog: config.DatasetCatalog, - DatasetSchema: config.DatasetSchema, - - ForceSendFields: nil, - }) + createResp, err = r.createDashboard(ctx, dashboard, config) } if err != nil { return "", nil, err } + dashboardID := utils.Deref(createResp.DashboardId) + // Persist the etag in state. - config.Etag = createResp.Etag + config.Etag = utils.Deref(createResp.Etag) - var publishResp *dashboards.PublishedDashboard + var publishResp *lakeview.PublishedDashboard // Note, today config.Published is always true (we do not have this field in input config). if config.Published { - publishResp, err = r.publishDashboard(ctx, createResp.DashboardId, config) + publishResp, err = r.publishDashboard(ctx, dashboardID, config) if err != nil { // If the publish fails, we should delete the dashboard to avoid leaving it in a bad state. - deleteErr := r.client.Lakeview.Trash(ctx, dashboards.TrashDashboardRequest{ - DashboardId: createResp.DashboardId, - }) + deleteErr := r.trashDashboard(ctx, dashboardID) if deleteErr != nil { - log.Warnf(ctx, "failed to delete draft dashboard %s after publish failed: %v", createResp.DashboardId, deleteErr) + log.Warnf(ctx, "failed to delete draft dashboard %s after publish failed: %v", dashboardID, deleteErr) return "", nil, deleteErr } return "", nil, err @@ -306,7 +289,7 @@ func (r *ResourceDashboard) DoCreate(ctx context.Context, config *DashboardState } } - return createResp.DashboardId, responseToState(createResp, publishResp, dashboard.SerializedDashboard, config.Published), nil + return dashboardID, dashboardToState(createResp, publishResp, utils.Deref(dashboard.SerializedDashboard), config.Published), nil } func (r *ResourceDashboard) DoUpdate(ctx context.Context, id string, config *DashboardState, _ *PlanEntry) (*DashboardState, error) { @@ -314,25 +297,31 @@ func (r *ResourceDashboard) DoUpdate(ctx context.Context, id string, config *Das if err != nil { return nil, err } + dashboard.DashboardId = new(id) // TODO: if the only thing that changed was "published", we can skip Update()? - updateResp, err := r.client.Lakeview.Update(ctx, dashboards.UpdateDashboardRequest{ - DashboardId: id, + request, err := lakeview.UpdateDashboardRequestToSDK(&lakeview.UpdateDashboardRequest{ Dashboard: dashboard, - DatasetCatalog: config.DatasetCatalog, - DatasetSchema: config.DatasetSchema, - - ForceSendFields: nil, + DatasetCatalog: nonEmpty(config.DatasetCatalog), + DatasetSchema: nonEmpty(config.DatasetSchema), }) if err != nil { return nil, err } + resp, err := r.client.Lakeview.UpdateDashboard(ctx, *request) + if err != nil { + return nil, err + } + updateResp, err := lakeview.DashboardFromSDK(resp) + if err != nil { + return nil, err + } // Persist the etag in state. - config.Etag = updateResp.Etag + config.Etag = utils.Deref(updateResp.Etag) - var publishResp *dashboards.PublishedDashboard + var publishResp *lakeview.PublishedDashboard // Note, today config.Published is always true (we do not have this field in input config). if config.Published { publishResp, err = r.publishDashboard(ctx, id, config) @@ -342,13 +331,11 @@ func (r *ResourceDashboard) DoUpdate(ctx context.Context, id string, config *Das } } - return responseToState(updateResp, publishResp, dashboard.SerializedDashboard, config.Published), nil + return dashboardToState(updateResp, publishResp, utils.Deref(dashboard.SerializedDashboard), config.Published), nil } func (r *ResourceDashboard) DoDelete(ctx context.Context, id string, _ *DashboardState) error { - return r.client.Lakeview.Trash(ctx, dashboards.TrashDashboardRequest{ - DashboardId: id, - }) + return r.trashDashboard(ctx, id) } func (r *ResourceDashboard) OverrideChangeDesc(_ context.Context, path *structpath.PathNode, change *ChangeDesc, _ *DashboardState) error { diff --git a/bundle/direct/dresources/database_catalog.go b/bundle/direct/dresources/database_catalog.go index a1a7ebdef44..284380feb33 100644 --- a/bundle/direct/dresources/database_catalog.go +++ b/bundle/direct/dresources/database_catalog.go @@ -4,15 +4,17 @@ import ( "context" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/database" + "github.com/databricks/cli/libs/sdkclients" + database "github.com/databricks/cli/libs/sdktypes/database/v1" + "github.com/databricks/cli/libs/utils" + sdkdatabase "github.com/databricks/sdk-go/database/v1" ) type ResourceDatabaseCatalog struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceDatabaseCatalog) New(client *databricks.WorkspaceClient) *ResourceDatabaseCatalog { +func (*ResourceDatabaseCatalog) New(client *sdkclients.Clients) *ResourceDatabaseCatalog { return &ResourceDatabaseCatalog{client: client} } @@ -21,21 +23,27 @@ func (*ResourceDatabaseCatalog) PrepareState(input *resources.DatabaseCatalog) * } func (r *ResourceDatabaseCatalog) DoRead(ctx context.Context, id string) (*database.DatabaseCatalog, error) { - return r.client.Database.GetDatabaseCatalogByName(ctx, id) + catalog, err := r.client.Database.GetDatabaseCatalog(ctx, sdkdatabase.GetDatabaseCatalogRequest{Name: new(id)}) + if err != nil { + return nil, err + } + return database.DatabaseCatalogFromSDK(catalog) } func (r *ResourceDatabaseCatalog) DoCreate(ctx context.Context, config *database.DatabaseCatalog) (string, *database.DatabaseCatalog, error) { - result, err := r.client.Database.CreateDatabaseCatalog(ctx, database.CreateDatabaseCatalogRequest{ - Catalog: *config, - }) + request, err := database.CreateDatabaseCatalogRequestToSDK(&database.CreateDatabaseCatalogRequest{Catalog: config}) + if err != nil { + return "", nil, err + } + result, err := r.client.Database.CreateDatabaseCatalog(ctx, *request) if err != nil { return "", nil, err } - return result.Name, nil, nil + return utils.Deref(result.Name), nil, nil } func (r *ResourceDatabaseCatalog) DoDelete(ctx context.Context, id string, _ *database.DatabaseCatalog) error { - return r.client.Database.DeleteDatabaseCatalog(ctx, database.DeleteDatabaseCatalogRequest{ - Name: id, + return r.client.Database.DeleteDatabaseCatalog(ctx, sdkdatabase.DeleteDatabaseCatalogRequest{ + Name: new(id), }) } diff --git a/bundle/direct/dresources/database_instance.go b/bundle/direct/dresources/database_instance.go index 2169a61fc8e..37c7b171e88 100644 --- a/bundle/direct/dresources/database_instance.go +++ b/bundle/direct/dresources/database_instance.go @@ -2,18 +2,22 @@ package dresources import ( "context" + "fmt" "time" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/database" + "github.com/databricks/cli/bundle/direct/internal/retries" + "github.com/databricks/cli/libs/sdkclients" + database "github.com/databricks/cli/libs/sdktypes/database/v1" + "github.com/databricks/cli/libs/utils" + sdkdatabase "github.com/databricks/sdk-go/database/v1" ) type ResourceDatabaseInstance struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceDatabaseInstance) New(client *databricks.WorkspaceClient) *ResourceDatabaseInstance { +func (*ResourceDatabaseInstance) New(client *sdkclients.Clients) *ResourceDatabaseInstance { return &ResourceDatabaseInstance{client: client} } @@ -22,49 +26,61 @@ func (*ResourceDatabaseInstance) PrepareState(input *resources.DatabaseInstance) } func (d *ResourceDatabaseInstance) DoRead(ctx context.Context, id string) (*database.DatabaseInstance, error) { - return d.client.Database.GetDatabaseInstanceByName(ctx, id) + instance, err := d.client.Database.GetDatabaseInstance(ctx, sdkdatabase.GetDatabaseInstanceRequest{Name: new(id)}) + if err != nil { + return nil, err + } + return database.DatabaseInstanceFromSDK(instance) } func (d *ResourceDatabaseInstance) DoCreate(ctx context.Context, config *database.DatabaseInstance) (string, *database.DatabaseInstance, error) { - waiter, err := d.client.Database.CreateDatabaseInstance(ctx, database.CreateDatabaseInstanceRequest{ - DatabaseInstance: *config, + request, err := database.CreateDatabaseInstanceRequestToSDK(&database.CreateDatabaseInstanceRequest{ + DatabaseInstance: config, }) if err != nil { return "", nil, err } - return waiter.Response.Name, nil, nil + waiter, err := d.client.Database.CreateDatabaseInstance(ctx, *request) + if err != nil { + return "", nil, err + } + return waiter.GetName(), nil, nil } func (d *ResourceDatabaseInstance) DoUpdate(ctx context.Context, id string, config *database.DatabaseInstance, _ *PlanEntry) (*database.DatabaseInstance, error) { - request := database.UpdateDatabaseInstanceRequest{ - DatabaseInstance: *config, - Name: config.Name, - UpdateMask: "*", + instance := *config + instance.Uid = new(id) + request, err := database.UpdateDatabaseInstanceRequestToSDK(&database.UpdateDatabaseInstanceRequest{ + DatabaseInstance: &instance, + UpdateMask: new("*"), + }) + if err != nil { + return nil, err } - request.DatabaseInstance.Uid = id - _, err := d.client.Database.UpdateDatabaseInstance(ctx, request) + _, err = d.client.Database.UpdateDatabaseInstance(ctx, *request) return nil, err } func (d *ResourceDatabaseInstance) WaitAfterCreate(ctx context.Context, id string, config *database.DatabaseInstance) (*database.DatabaseInstance, error) { - waiter := &database.WaitGetDatabaseInstanceDatabaseAvailable[database.DatabaseInstance]{ - Response: config, - Name: config.Name, - Poll: func(timeout time.Duration, callback func(*database.DatabaseInstance)) (*database.DatabaseInstance, error) { - return d.client.Database.WaitGetDatabaseInstanceDatabaseAvailable(ctx, config.Name, timeout, callback) - }, - } - + name := utils.Deref(config.Name) // _ is remoteState, should we return it here? - _, err := waiter.GetWithTimeout(20 * time.Minute) + _, err := retries.Poll(ctx, 20*time.Minute, func() (*sdkdatabase.DatabaseInstance, *retries.Err) { + instance, err := d.client.Database.GetDatabaseInstance(ctx, sdkdatabase.GetDatabaseInstanceRequest{Name: new(name)}) + if err != nil { + return nil, retries.Halt(err) + } + if instance.State == sdkdatabase.DatabaseInstance_State_Available { + return instance, nil + } + return nil, retries.Continues(fmt.Sprintf("current status: %s", instance.State)) + }) return nil, err } func (d *ResourceDatabaseInstance) DoDelete(ctx context.Context, name string, _ *database.DatabaseInstance) error { - return d.client.Database.DeleteDatabaseInstance(ctx, database.DeleteDatabaseInstanceRequest{ - Name: name, - Purge: true, - Force: false, - ForceSendFields: nil, + return d.client.Database.DeleteDatabaseInstance(ctx, sdkdatabase.DeleteDatabaseInstanceRequest{ + Name: new(name), + Purge: new(true), + Force: nil, // Not set by DABs }) } diff --git a/bundle/direct/dresources/experiment.go b/bundle/direct/dresources/experiment.go index e4f2e8ebbd7..b1adc6b513f 100644 --- a/bundle/direct/dresources/experiment.go +++ b/bundle/direct/dresources/experiment.go @@ -6,74 +6,72 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/libs/sdkclients" + experiments "github.com/databricks/cli/libs/sdktypes/experiments/v1" + "github.com/databricks/cli/libs/sdktypes/sdkconv" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/ml" + sdkexperiments "github.com/databricks/sdk-go/experiments/v1" ) type ResourceExperiment struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceExperiment) New(client *databricks.WorkspaceClient) *ResourceExperiment { +func (*ResourceExperiment) New(client *sdkclients.Clients) *ResourceExperiment { return &ResourceExperiment{ client: client, } } -func (*ResourceExperiment) PrepareState(input *resources.MlflowExperiment) *ml.CreateExperiment { - return &ml.CreateExperiment{ - Name: input.Name, - ArtifactLocation: input.ArtifactLocation, - Tags: input.Tags, - TraceLocation: input.TraceLocation, - ForceSendFields: utils.FilterFields[ml.CreateExperiment](input.ForceSendFields), - } +func (*ResourceExperiment) PrepareState(input *resources.MlflowExperiment) *experiments.CreateExperimentRequest { + return &input.CreateExperimentRequest } -func (*ResourceExperiment) RemapState(experiment *ml.Experiment) *ml.CreateExperiment { - return &ml.CreateExperiment{ +func (*ResourceExperiment) RemapState(experiment *experiments.Experiment) *experiments.CreateExperimentRequest { + return &experiments.CreateExperimentRequest{ Name: experiment.Name, ArtifactLocation: experiment.ArtifactLocation, Tags: experiment.Tags, TraceLocation: experiment.TraceLocation, - ForceSendFields: utils.FilterFields[ml.CreateExperiment](experiment.ForceSendFields), } } -func (r *ResourceExperiment) DoRead(ctx context.Context, id string) (*ml.Experiment, error) { - result, err := r.client.Experiments.GetExperiment(ctx, ml.GetExperimentRequest{ - ExperimentId: id, +func (r *ResourceExperiment) DoRead(ctx context.Context, id string) (*experiments.Experiment, error) { + result, err := r.client.Experiments.GetExperiment(ctx, sdkexperiments.GetExperimentRequest{ + ExperimentId: new(id), }) if err != nil { return nil, err } - return result.Experiment, nil + return sdkconv.FromSDK[experiments.Experiment](result.Experiment) } -func (r *ResourceExperiment) DoCreate(ctx context.Context, config *ml.CreateExperiment) (string, *ml.Experiment, error) { - result, err := r.client.Experiments.CreateExperiment(ctx, *config) +func (r *ResourceExperiment) DoCreate(ctx context.Context, config *experiments.CreateExperimentRequest) (string, *experiments.Experiment, error) { + request, err := toSDK[sdkexperiments.CreateExperimentRequest](config) if err != nil { return "", nil, err } - return result.ExperimentId, nil, nil -} - -func (r *ResourceExperiment) DoUpdate(ctx context.Context, id string, config *ml.CreateExperiment, _ *PlanEntry) (*ml.Experiment, error) { - updateReq := ml.UpdateExperiment{ - ExperimentId: id, - NewName: config.Name, - ForceSendFields: utils.FilterFields[ml.UpdateExperiment](config.ForceSendFields), + result, err := r.client.Experiments.CreateExperiment(ctx, request) + if err != nil { + return "", nil, err } + return utils.Deref(result.ExperimentId), nil, nil +} - return nil, r.client.Experiments.UpdateExperiment(ctx, updateReq) +func (r *ResourceExperiment) DoUpdate(ctx context.Context, id string, config *experiments.CreateExperimentRequest, _ *PlanEntry) (*experiments.Experiment, error) { + _, err := r.client.Experiments.UpdateExperiment(ctx, sdkexperiments.UpdateExperimentRequest{ + ExperimentId: new(id), + NewName: config.Name, + }) + return nil, err } -func (r *ResourceExperiment) DoDelete(ctx context.Context, id string, _ *ml.CreateExperiment) error { - return r.client.Experiments.DeleteExperiment(ctx, ml.DeleteExperiment{ - ExperimentId: id, +func (r *ResourceExperiment) DoDelete(ctx context.Context, id string, _ *experiments.CreateExperimentRequest) error { + _, err := r.client.Experiments.DeleteExperiment(ctx, sdkexperiments.DeleteExperimentRequest{ + ExperimentId: new(id), }) + return err } // OverrideChangeDesc suppresses drift for the experiment name field when the @@ -83,7 +81,7 @@ func (r *ResourceExperiment) DoDelete(ctx context.Context, id string, _ *ml.Crea // // This matches the Terraform provider's experimentNameSuppressDiff behavior. // https://github.com/databricks/terraform-provider-databricks/blob/8945a7b2328659b1fc976d04e32457305860131f/mlflow/resource_mlflow_experiment.go#L13 -func (*ResourceExperiment) OverrideChangeDesc(_ context.Context, path *structpath.PathNode, change *ChangeDesc, _ *ml.Experiment) error { +func (*ResourceExperiment) OverrideChangeDesc(_ context.Context, path *structpath.PathNode, change *ChangeDesc, _ *experiments.Experiment) error { if change.Action == deployplan.Skip { return nil } diff --git a/bundle/direct/dresources/external_location.go b/bundle/direct/dresources/external_location.go index 26c957020ab..b3153acb682 100644 --- a/bundle/direct/dresources/external_location.go +++ b/bundle/direct/dresources/external_location.go @@ -2,28 +2,28 @@ package dresources import ( "context" - "slices" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" + externallocations "github.com/databricks/cli/libs/sdktypes/uc/externallocations/v1" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/catalog" + sdkexternallocations "github.com/databricks/sdk-go/uc/externallocations/v1" ) type ResourceExternalLocation struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceExternalLocation) New(client *databricks.WorkspaceClient) *ResourceExternalLocation { +func (*ResourceExternalLocation) New(client *sdkclients.Clients) *ResourceExternalLocation { return &ResourceExternalLocation{client: client} } -func (*ResourceExternalLocation) PrepareState(input *resources.ExternalLocation) *catalog.CreateExternalLocation { +func (*ResourceExternalLocation) PrepareState(input *resources.ExternalLocation) *resources.CreateExternalLocation { return &input.CreateExternalLocation } -func (*ResourceExternalLocation) RemapState(info *catalog.ExternalLocationInfo) *catalog.CreateExternalLocation { - return &catalog.CreateExternalLocation{ +func (*ResourceExternalLocation) RemapState(info *externallocations.ExternalLocationInfo) *resources.CreateExternalLocation { + return &resources.CreateExternalLocation{ Comment: info.Comment, CredentialName: info.CredentialName, // Output-only fields mirrored into state to avoid churn in remapped config. @@ -35,100 +35,107 @@ func (*ResourceExternalLocation) RemapState(info *catalog.ExternalLocationInfo) FileEventQueue: info.FileEventQueue, Name: info.Name, ReadOnly: info.ReadOnly, - SkipValidation: false, // This is an input-only parameter, never returned by API + SkipValidation: nil, // This is an input-only parameter, never returned by API Url: info.Url, - ForceSendFields: utils.FilterFields[catalog.CreateExternalLocation](info.ForceSendFields), } } -func (r *ResourceExternalLocation) DoRead(ctx context.Context, id string) (*catalog.ExternalLocationInfo, error) { - return r.client.ExternalLocations.GetByName(ctx, id) +func (r *ResourceExternalLocation) DoRead(ctx context.Context, id string) (*externallocations.ExternalLocationInfo, error) { + info, err := r.client.ExternalLocations.GetExternalLocation(ctx, sdkexternallocations.GetExternalLocationRequest{ + NameArg: new(id), + IncludeBrowse: nil, // Not set by DABs + }) + if err != nil { + return nil, err + } + return externallocations.ExternalLocationInfoFromSDK(info) } -func (r *ResourceExternalLocation) DoCreate(ctx context.Context, config *catalog.CreateExternalLocation) (string, *catalog.ExternalLocationInfo, error) { - response, err := r.client.ExternalLocations.Create(ctx, *config) +func (r *ResourceExternalLocation) DoCreate(ctx context.Context, config *resources.CreateExternalLocation) (string, *externallocations.ExternalLocationInfo, error) { + request, err := toSDK[sdkexternallocations.CreateExternalLocationRequest](config.AsRequest()) + if err != nil { + return "", nil, err + } + response, err := r.client.ExternalLocations.CreateExternalLocation(ctx, request) if err != nil || response == nil { return "", nil, err } - return response.Name, response, nil + info, err := externallocations.ExternalLocationInfoFromSDK(response) + if err != nil { + return "", nil, err + } + return utils.Deref(info.Name), info, nil } -// See schemaForceSend. Unlike the other four this one is not probed: an external -// location needs a storage credential with cloud IAM setup, which the test workspaces do -// not provision, so its acceptance test is local-only. Comment is carried here because it -// is the same field on the same UC PATCH family, where all four siblings clear on +// Comment is always sent, see ResourceSchema.DoUpdate. Unlike the other four this one is not +// probed: an external location needs a storage credential with cloud IAM setup, which the test +// workspaces do not provision, so its acceptance test is local-only. Comment is carried here +// because it is the same field on the same UC PATCH family, where all four siblings clear on // {"comment": ""}; re-probe before adding anything else. -var externalLocationForceSend = []string{"Comment"} - -// DoUpdate updates the external location in place and returns remote state. -func (r *ResourceExternalLocation) DoUpdate(ctx context.Context, id string, config *catalog.CreateExternalLocation, _ *PlanEntry) (*catalog.ExternalLocationInfo, error) { - updateRequest := catalog.UpdateExternalLocation{ - Comment: config.Comment, +// +// Output-only effective_* fields are never sent; isolation_mode and owner are not supported by DABs. +func (r *ResourceExternalLocation) update(ctx context.Context, id string, config *resources.CreateExternalLocation, newName *string) (*externallocations.ExternalLocationInfo, error) { + request, err := toSDK[sdkexternallocations.UpdateExternalLocationRequest](&externallocations.UpdateExternalLocationRequest{ + NameArg: new(id), + NewName: newName, + Comment: orZero(config.Comment), CredentialName: config.CredentialName, - EffectiveEnableFileEvents: false, // Output-only field; never sent in update payload. - EffectiveFileEventQueue: nil, EnableFileEvents: config.EnableFileEvents, EncryptionDetails: config.EncryptionDetails, Fallback: config.Fallback, FileEventQueue: config.FileEventQueue, - Force: false, - IsolationMode: "", // Not supported by DABs - Name: id, - NewName: "", // Only set if name actually changes (see DoUpdateWithID) - Owner: "", // Not supported by DABs ReadOnly: config.ReadOnly, SkipValidation: config.SkipValidation, Url: config.Url, - ForceSendFields: utils.FilterFields[catalog.UpdateExternalLocation](append(slices.Clone(externalLocationForceSend), config.ForceSendFields...), "IsolationMode", "Owner"), + BrowseOnly: nil, // Not set by DABs + CreatedAt: nil, // Not set by DABs + CreatedBy: nil, // Not set by DABs + CredentialId: nil, // Not set by DABs + EffectiveEnableFileEvents: nil, // Not set by DABs + EffectiveFileEventQueue: nil, // Not set by DABs + Force: nil, // Not set by DABs + IsolationMode: "", // Not set by DABs + MetastoreId: nil, // Not set by DABs + Name: nil, // Not set by DABs + Owner: nil, // Not set by DABs + UpdatedAt: nil, // Not set by DABs + UpdatedBy: nil, // Not set by DABs + }) + if err != nil { + return nil, err + } + response, err := r.client.ExternalLocations.UpdateExternalLocation(ctx, request) + if err != nil { + return nil, err } + return externallocations.ExternalLocationInfoFromSDK(response) +} - return r.client.ExternalLocations.Update(ctx, updateRequest) +// DoUpdate updates the external location in place and returns remote state. +func (r *ResourceExternalLocation) DoUpdate(ctx context.Context, id string, config *resources.CreateExternalLocation, _ *PlanEntry) (*externallocations.ExternalLocationInfo, error) { + return r.update(ctx, id, config, nil) } // DoUpdateWithID updates the external location and returns the new ID if the name changes. -func (r *ResourceExternalLocation) DoUpdateWithID(ctx context.Context, id string, config *catalog.CreateExternalLocation, _ *PlanEntry) (string, *catalog.ExternalLocationInfo, error) { - updateRequest := catalog.UpdateExternalLocation{ - Comment: config.Comment, - CredentialName: config.CredentialName, - EffectiveEnableFileEvents: false, // Output-only field; never sent in update payload. - EffectiveFileEventQueue: nil, - EnableFileEvents: config.EnableFileEvents, - EncryptionDetails: config.EncryptionDetails, - Fallback: config.Fallback, - FileEventQueue: config.FileEventQueue, - Force: false, - IsolationMode: "", // Not supported by DABs - Name: id, - NewName: "", // Initialized below if needed - Owner: "", // Not supported by DABs - ReadOnly: config.ReadOnly, - SkipValidation: config.SkipValidation, - Url: config.Url, - ForceSendFields: utils.FilterFields[catalog.UpdateExternalLocation](append(slices.Clone(externalLocationForceSend), config.ForceSendFields...), "IsolationMode", "Owner"), - } - - if config.Name != id { - updateRequest.NewName = config.Name +func (r *ResourceExternalLocation) DoUpdateWithID(ctx context.Context, id string, config *resources.CreateExternalLocation, _ *PlanEntry) (string, *externallocations.ExternalLocationInfo, error) { + var newName *string + if name := utils.Deref(config.Name); name != id { + newName = new(name) } - - response, err := r.client.ExternalLocations.Update(ctx, updateRequest) + response, err := r.update(ctx, id, config, newName) if err != nil { return "", nil, err } - - // Return the new name as the ID if it changed, otherwise return the old ID - newID := id - if updateRequest.NewName != "" { - newID = updateRequest.NewName + if newName != nil { + return *newName, response, nil } - - return newID, response, nil + return id, response, nil } -func (r *ResourceExternalLocation) DoDelete(ctx context.Context, id string, _ *catalog.CreateExternalLocation) error { - return r.client.ExternalLocations.Delete(ctx, catalog.DeleteExternalLocationRequest{ - Name: id, - Force: true, - ForceSendFields: nil, +func (r *ResourceExternalLocation) DoDelete(ctx context.Context, id string, _ *resources.CreateExternalLocation) error { + _, err := r.client.ExternalLocations.DeleteExternalLocation(ctx, sdkexternallocations.DeleteExternalLocationRequest{ + NameArg: new(id), + Force: new(true), }) + return err } diff --git a/bundle/direct/dresources/genie_space.go b/bundle/direct/dresources/genie_space.go index 30c8a07485f..a01ce632fb2 100644 --- a/bundle/direct/dresources/genie_space.go +++ b/bundle/direct/dresources/genie_space.go @@ -2,19 +2,18 @@ package dresources import ( "context" - "errors" "fmt" "net/http" - "slices" "strings" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/dashboards" + sdkgenie "github.com/databricks/sdk-go/genie/v1" ) // ResourceGenieSpace mirrors the dashboard resource pattern (see dashboard.go), @@ -33,10 +32,10 @@ import ( // Permissions follow the standard /permissions/genie/{id} endpoint and are wired // up via the generic permissions adapter (permissions.go). type ResourceGenieSpace struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceGenieSpace) New(client *databricks.WorkspaceClient) *ResourceGenieSpace { +func (*ResourceGenieSpace) New(client *sdkclients.Clients) *ResourceGenieSpace { return &ResourceGenieSpace{client: client} } @@ -45,15 +44,14 @@ func (*ResourceGenieSpace) PrepareState(input *resources.GenieSpace) *resources. } func (r *ResourceGenieSpace) DoRead(ctx context.Context, id string) (*resources.GenieSpaceConfig, error) { - space, err := r.client.Genie.GetSpace(ctx, dashboards.GenieGetSpaceRequest{ - SpaceId: id, - IncludeSerializedSpace: true, // otherwise etag isn't returned - ForceSendFields: nil, + space, err := r.client.Genie.GenieGetSpace(ctx, sdkgenie.GenieGetSpaceRequest{ + SpaceId: new(id), + IncludeSerializedSpace: new(true), // otherwise etag isn't returned }) if err != nil { return nil, err } - return responseToGenieSpaceConfig(space, space.SerializedSpace), nil + return responseToGenieSpaceConfig(space, utils.Deref(space.SerializedSpace)), nil } // prepareGenieSpaceRequest returns the serialized_space body to send to the API. @@ -71,21 +69,14 @@ func prepareGenieSpaceRequest(config *resources.GenieSpaceConfig) (string, error } } -func responseToGenieSpaceConfig(space *dashboards.GenieSpace, serializedSpace string) *resources.GenieSpaceConfig { - // SerializedSpace is excluded so it is never force-sent as an empty value; it is always - // populated from the bundle config on write. Done here (rather than in a RemapState) so - // every remote-producing path (DoRead/DoCreate/DoUpdate) yields the same force-send set. - forceSendFields := utils.FilterFields[resources.GenieSpaceConfig](space.ForceSendFields, "SerializedSpace") - +func responseToGenieSpaceConfig(space *sdkgenie.GenieSpace, serializedSpace string) *resources.GenieSpaceConfig { return &resources.GenieSpaceConfig{ - Description: space.Description, - Etag: space.Etag, - Title: space.Title, - WarehouseId: space.WarehouseId, - ParentPath: ensureWorkspacePrefix(space.ParentPath), + Description: utils.Deref(space.Description), + Etag: utils.Deref(space.Etag), + Title: utils.Deref(space.Title), + WarehouseId: utils.Deref(space.WarehouseId), + ParentPath: ensureWorkspacePrefix(utils.Deref(space.ParentPath)), SerializedSpace: serializedSpace, - - ForceSendFields: forceSendFields, } } @@ -109,19 +100,19 @@ func responseToGenieSpaceConfig(space *dashboards.GenieSpace, serializedSpace st // // Both forms unambiguously mean "create the parent and retry once". func isMissingGenieParentPathError(err error) bool { - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return true } - apiErr, ok := errors.AsType[*apierr.APIError](err) - if !ok { + if _, ok := apierrs.Get(err); !ok { return false } - return apiErr.StatusCode == http.StatusBadRequest && - apiErr.ErrorCode == "INVALID_PARAMETER_VALUE" && - strings.Contains(apiErr.Message, "Tree node with path") && - strings.Contains(apiErr.Message, "does not exist") + message := apierrs.Message(err) + return apierrs.StatusCode(err) == http.StatusBadRequest && + apierrs.ErrorCode(err) == "INVALID_PARAMETER_VALUE" && + strings.Contains(message, "Tree node with path") && + strings.Contains(message, "does not exist") } func (r *ResourceGenieSpace) DoCreate(ctx context.Context, config *resources.GenieSpaceConfig) (string, *resources.GenieSpaceConfig, error) { @@ -130,14 +121,12 @@ func (r *ResourceGenieSpace) DoCreate(ctx context.Context, config *resources.Gen return "", nil, err } - req := dashboards.GenieCreateSpaceRequest{ - Description: config.Description, - Title: config.Title, - WarehouseId: config.WarehouseId, - ParentPath: config.ParentPath, - SerializedSpace: serializedSpace, - - ForceSendFields: utils.FilterFields[dashboards.GenieCreateSpaceRequest](config.ForceSendFields), + req := sdkgenie.GenieCreateSpaceRequest{ + Description: nonEmpty(config.Description), + Title: nonEmpty(config.Title), + WarehouseId: nonEmpty(config.WarehouseId), + ParentPath: nonEmpty(config.ParentPath), + SerializedSpace: nonEmpty(serializedSpace), } createResp, err := r.client.Genie.CreateSpace(ctx, req) @@ -161,16 +150,11 @@ func (r *ResourceGenieSpace) DoCreate(ctx context.Context, config *resources.Gen // to DoCreate) as the state record, so mutating it here is what gets the // backend-returned etag onto disk for the next plan's drift check. // Matches the dashboard pattern (dashboard.go DoCreate). - config.Etag = createResp.Etag + config.Etag = utils.Deref(createResp.Etag) - return createResp.SpaceId, responseToGenieSpaceConfig(createResp, serializedSpace), nil + return utils.Deref(createResp.SpaceId), responseToGenieSpaceConfig(createResp, serializedSpace), nil } -// description is force-sent on update so that clearing it in config clears it on the space. -// Without this the omitempty field is dropped from the request and the old value drifts back on -// every plan. Verified against a real workspace: UpdateSpace accepts {"description": ""} as a clear. -var genieSpaceForceSend = []string{"Description"} - func (r *ResourceGenieSpace) DoUpdate(ctx context.Context, id string, config *resources.GenieSpaceConfig, _ *PlanEntry) (*resources.GenieSpaceConfig, error) { serializedSpace, err := prepareGenieSpaceRequest(config) if err != nil { @@ -183,16 +167,17 @@ func (r *ResourceGenieSpace) DoUpdate(ctx context.Context, id string, config *re // migrates serialized_space to a newer schema version, so a stale etag would // 409 a legitimate update after a migration. Etag is therefore left empty; // out-of-band drift is surfaced on read via OverrideChangeDesc instead. - updateResp, err := r.client.Genie.UpdateSpace(ctx, dashboards.GenieUpdateSpaceRequest{ - SpaceId: id, - Description: config.Description, - Title: config.Title, - WarehouseId: config.WarehouseId, - ParentPath: config.ParentPath, - SerializedSpace: serializedSpace, - Etag: "", - - ForceSendFields: utils.FilterFields[dashboards.GenieUpdateSpaceRequest](append(slices.Clone(genieSpaceForceSend), config.ForceSendFields...)), + // + // description is always sent so that clearing it in config clears it on the space. + // Verified against a real workspace: UpdateSpace accepts {"description": ""} as a clear. + updateResp, err := r.client.Genie.UpdateSpace(ctx, sdkgenie.GenieUpdateSpaceRequest{ + SpaceId: new(id), + Description: new(config.Description), + Title: nonEmpty(config.Title), + WarehouseId: nonEmpty(config.WarehouseId), + ParentPath: nonEmpty(config.ParentPath), + SerializedSpace: nonEmpty(serializedSpace), + Etag: nil, // Not set by DABs }) if err != nil { return nil, err @@ -200,7 +185,7 @@ func (r *ResourceGenieSpace) DoUpdate(ctx context.Context, id string, config *re // Persist the new etag in state (see DoCreate for the rationale). Record the // body we sent, mirroring DoCreate, so config-side and state-side match. - config.Etag = updateResp.Etag + config.Etag = utils.Deref(updateResp.Etag) return responseToGenieSpaceConfig(updateResp, serializedSpace), nil } @@ -224,7 +209,7 @@ func (r *ResourceGenieSpace) OverrideChangeDesc(_ context.Context, path *structp } func (r *ResourceGenieSpace) DoDelete(ctx context.Context, id string, _ *resources.GenieSpaceConfig) error { - return r.client.Genie.TrashSpace(ctx, dashboards.GenieTrashSpaceRequest{ - SpaceId: id, + return r.client.Genie.GenieTrashSpace(ctx, sdkgenie.GenieTrashSpaceRequest{ + SpaceId: new(id), }) } diff --git a/bundle/direct/dresources/genie_space_test.go b/bundle/direct/dresources/genie_space_test.go index a7bd8b0c2ed..a1f9d1507cc 100644 --- a/bundle/direct/dresources/genie_space_test.go +++ b/bundle/direct/dresources/genie_space_test.go @@ -1,18 +1,25 @@ package dresources import ( + "encoding/json" "testing" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/dashboards" + "github.com/databricks/cli/libs/testserver" + "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/sdk-go/core/apierr" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) +func apiError(status int, errorCode, message string) error { + body, _ := json.Marshal(map[string]string{"error_code": errorCode, "message": message}) + return apierr.FromHTTPError(status, nil, body) +} + func TestIsMissingGenieParentPathError(t *testing.T) { tests := []struct { name string @@ -21,29 +28,17 @@ func TestIsMissingGenieParentPathError(t *testing.T) { }{ { name: "standard missing error", - err: &apierr.APIError{ - StatusCode: 404, - ErrorCode: "NOT_FOUND", - Message: "not found", - }, + err: apiError(404, "NOT_FOUND", "not found"), want: true, }, { name: "invalid parameter tree node missing error", - err: &apierr.APIError{ - StatusCode: 400, - ErrorCode: "INVALID_PARAMETER_VALUE", - Message: "NOT_FOUND: Tree node with path /Workspace/foo does not exist", - }, + err: apiError(400, "INVALID_PARAMETER_VALUE", "NOT_FOUND: Tree node with path /Workspace/foo does not exist"), want: true, }, { name: "other invalid parameter error", - err: &apierr.APIError{ - StatusCode: 400, - ErrorCode: "INVALID_PARAMETER_VALUE", - Message: "some other validation failure", - }, + err: apiError(400, "INVALID_PARAMETER_VALUE", "some other validation failure"), want: false, }, } @@ -55,44 +50,47 @@ func TestIsMissingGenieParentPathError(t *testing.T) { } } +// newGenieTestClient returns a client that talks to server. +func newGenieTestClient(t *testing.T, server *testserver.Server) *sdkclients.Clients { + client, err := sdkclients.New(t.Context(), &config.Config{ + Host: server.URL, + Token: "testtoken", + }) + require.NoError(t, err) + return client +} + func TestGenieSpaceDoCreateRetriesWhenParentPathLooksMissing(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - r := (&ResourceGenieSpace{}).New(m.WorkspaceClient) + server := testserver.New(t) - req := dashboards.GenieCreateSpaceRequest{ - Title: "test genie space", - Description: "test description", - ParentPath: "/Workspace/test-parent", - WarehouseId: "test-warehouse-id", - SerializedSpace: "{}", - } - - m.GetMockGenieAPI().EXPECT(). - CreateSpace(ctx, req). - Return(nil, &apierr.APIError{ - StatusCode: 400, - ErrorCode: "INVALID_PARAMETER_VALUE", - Message: "NOT_FOUND: Tree node with path /Workspace/test-parent does not exist", - }). - Once() - - m.GetMockWorkspaceAPI().EXPECT(). - MkdirsByPath(ctx, "/Workspace/test-parent"). - Return(nil). - Once() - - m.GetMockGenieAPI().EXPECT(). - CreateSpace(ctx, req). - Return(&dashboards.GenieSpace{ - SpaceId: "space-id", - Title: "test genie space", - Description: "test description", - WarehouseId: "test-warehouse-id", - SerializedSpace: "{}", - }, nil). - Once() + var createBodies []string + server.Handle("POST", "/api/2.0/genie/spaces", func(req testserver.Request) any { + createBodies = append(createBodies, string(req.Body)) + if len(createBodies) == 1 { + return testserver.Response{ + StatusCode: 400, + Body: map[string]string{ + "error_code": "INVALID_PARAMETER_VALUE", + "message": "NOT_FOUND: Tree node with path /Workspace/test-parent does not exist", + }, + } + } + return map[string]string{ + "space_id": "space-id", + "title": "test genie space", + "description": "test description", + "warehouse_id": "test-warehouse-id", + "serialized_space": "{}", + } + }) + var mkdirsBodies []string + server.Handle("POST", "/api/2.0/workspace/mkdirs", func(req testserver.Request) any { + mkdirsBodies = append(mkdirsBodies, string(req.Body)) + return map[string]string{} + }) + r := (&ResourceGenieSpace{}).New(newGenieTestClient(t, server)) id, state, err := r.DoCreate(ctx, &resources.GenieSpaceConfig{ Title: "test genie space", Description: "test description", @@ -104,35 +102,32 @@ func TestGenieSpaceDoCreateRetriesWhenParentPathLooksMissing(t *testing.T) { assert.Equal(t, "space-id", id) require.NotNil(t, state) assert.Equal(t, "test genie space", state.Title) + + want := `{"warehouse_id":"test-warehouse-id","parent_path":"/Workspace/test-parent","serialized_space":"{}","title":"test genie space","description":"test description"}` + require.Len(t, createBodies, 2) + assert.JSONEq(t, want, createBodies[0]) + assert.JSONEq(t, want, createBodies[1]) + require.Len(t, mkdirsBodies, 1) + assert.JSONEq(t, `{"path":"/Workspace/test-parent"}`, mkdirsBodies[0]) } func TestGenieSpaceDoUpdateRoundTripsEtag(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - r := (&ResourceGenieSpace{}).New(m.WorkspaceClient) + server := testserver.New(t) + var updateBodies []string + server.Handle("PATCH", "/api/2.0/genie/spaces/{id}", func(req testserver.Request) any { + updateBodies = append(updateBodies, string(req.Body)) + return map[string]string{"space_id": "space-id", "title": "new", "etag": "etag-8"} + }) + + r := (&ResourceGenieSpace{}).New(newGenieTestClient(t, server)) entry := &deployplan.PlanEntry{ Changes: deployplan.Changes{ "title": {Action: deployplan.Update, Old: "old", New: "new"}, }, } - // The stored etag (etag-7) must NOT be sent as an If-Match guard — it would - // 409 after a backend serialized_space schema migration. Only the etag from - // the response is persisted, for drift detection on the next plan. - m.GetMockGenieAPI().EXPECT(). - UpdateSpace(ctx, dashboards.GenieUpdateSpaceRequest{ - SpaceId: "space-id", - Title: "new", - ForceSendFields: []string{"Description"}, - }). - Return(&dashboards.GenieSpace{ - SpaceId: "space-id", - Title: "new", - Etag: "etag-8", - }, nil). - Once() - state, err := r.DoUpdate(ctx, "space-id", &resources.GenieSpaceConfig{ Title: "new", Etag: "etag-7", @@ -140,12 +135,25 @@ func TestGenieSpaceDoUpdateRoundTripsEtag(t *testing.T) { require.NoError(t, err) require.NotNil(t, state) assert.Equal(t, "etag-8", state.Etag) + + // The stored etag (etag-7) must NOT be sent as an If-Match guard — it would + // 409 after a backend serialized_space schema migration. Only the etag from + // the response is persisted, for drift detection on the next plan. + require.Len(t, updateBodies, 1) + assert.JSONEq(t, `{"space_id":"space-id","title":"new","description":""}`, updateBodies[0]) } func TestGenieSpaceDoUpdateAlwaysSendsSerializedSpace(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - r := (&ResourceGenieSpace{}).New(m.WorkspaceClient) + server := testserver.New(t) + + var updateBodies []string + server.Handle("PATCH", "/api/2.0/genie/spaces/{id}", func(req testserver.Request) any { + updateBodies = append(updateBodies, string(req.Body)) + return map[string]string{"space_id": "space-id", "title": "new", "serialized_space": `{"converge":"me"}`} + }) + + r := (&ResourceGenieSpace{}).New(newGenieTestClient(t, server)) // Even though the plan entry only marks an unrelated field changed, the body // is sent so the deploy converges the space to the bundle config. @@ -155,20 +163,6 @@ func TestGenieSpaceDoUpdateAlwaysSendsSerializedSpace(t *testing.T) { }, } - m.GetMockGenieAPI().EXPECT(). - UpdateSpace(ctx, dashboards.GenieUpdateSpaceRequest{ - SpaceId: "space-id", - Title: "new", - SerializedSpace: "{\"converge\":\"me\"}", - ForceSendFields: []string{"Description"}, - }). - Return(&dashboards.GenieSpace{ - SpaceId: "space-id", - Title: "new", - SerializedSpace: "{\"converge\":\"me\"}", - }, nil). - Once() - state, err := r.DoUpdate(ctx, "space-id", &resources.GenieSpaceConfig{ Title: "new", SerializedSpace: "{\"converge\":\"me\"}", @@ -176,6 +170,9 @@ func TestGenieSpaceDoUpdateAlwaysSendsSerializedSpace(t *testing.T) { require.NoError(t, err) require.NotNil(t, state) assert.Equal(t, "{\"converge\":\"me\"}", state.SerializedSpace) + + require.Len(t, updateBodies, 1) + assert.JSONEq(t, `{"space_id":"space-id","title":"new","description":"","serialized_space":"{\"converge\":\"me\"}"}`, updateBodies[0]) } func TestGenieSpaceOverrideChangeDescEtag(t *testing.T) { diff --git a/bundle/direct/dresources/grants.go b/bundle/direct/dresources/grants.go index 3aa48c58279..d92fd477789 100644 --- a/bundle/direct/dresources/grants.go +++ b/bundle/direct/dresources/grants.go @@ -7,9 +7,11 @@ import ( "slices" "strings" + "github.com/databricks/cli/libs/sdkclients" + grants "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" "github.com/databricks/cli/libs/structs/structvar" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/libs/utils" + sdkgrants "github.com/databricks/sdk-go/uc/grants/v1" ) var grantResourceToSecurableType = map[string]string{ @@ -26,19 +28,19 @@ var grantResourceToSecurableType = map[string]string{ } type GrantsState struct { - SecurableType string `json:"securable_type"` - FullName string `json:"full_name"` - EmbeddedSlice []catalog.PrivilegeAssignment `json:"__embed__,omitempty"` + SecurableType string `json:"securable_type"` + FullName string `json:"full_name"` + EmbeddedSlice []grants.PrivilegeAssignment `json:"__embed__,omitempty"` } type ResourceGrants struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients // securableType is the UC securable type of the parent resource, e.g. "schema". securableType string } -func (*ResourceGrants) New(client *databricks.WorkspaceClient) *ResourceGrants { +func (*ResourceGrants) New(client *sdkclients.Clients) *ResourceGrants { return &ResourceGrants{client: client, securableType: ""} } @@ -56,7 +58,7 @@ func (r *ResourceGrants) Configure(resourceType string) error { return nil } -func (r *ResourceGrants) PrepareInputConfig(inputConfig *[]catalog.PrivilegeAssignment, resourceKey string) (*structvar.StructVar, error) { +func (r *ResourceGrants) PrepareInputConfig(inputConfig *[]grants.PrivilegeAssignment, resourceKey string) (*structvar.StructVar, error) { baseNode, ok := strings.CutSuffix(resourceKey, ".grants") if !ok { return nil, fmt.Errorf("internal error: node %q does not end with .grants", resourceKey) @@ -89,8 +91,8 @@ func (*ResourceGrants) IsEmptyState(state *GrantsState) bool { return len(state.EmbeddedSlice) == 0 } -func grantKey(x catalog.PrivilegeAssignment) (string, string) { - return "principal", x.Principal +func grantKey(x grants.PrivilegeAssignment) (string, string) { + return "principal", utils.Deref(x.Principal) } func (*ResourceGrants) KeyedSlices() map[string]any { @@ -133,13 +135,16 @@ func (r *ResourceGrants) DoUpdate(ctx context.Context, _ string, state *GrantsSt if state.FullName == "" { return nil, errors.New("internal error: grants full_name must be resolved before deployment") } - _, err := r.client.Grants.Update(ctx, catalog.UpdatePermissions{ - SecurableType: state.SecurableType, - FullName: state.FullName, + request, err := grants.UpdatePermissionsRequestToSDK(&grants.UpdatePermissionsRequest{ + SecurableType: new(state.SecurableType), + SecurableFullName: new(state.FullName), Changes: buildGrantChanges(state.EmbeddedSlice, remoteGrantPrivileges(entry)), - OmitPermissionsInResponse: false, - ForceSendFields: nil, + OmitPermissionsInResponse: nil, // Not set by DABs }) + if err != nil { + return nil, err + } + _, err = r.client.Grants.UpdatePermissions(ctx, *request) return nil, err } @@ -148,16 +153,16 @@ func (r *ResourceGrants) DoUpdate(ctx context.Context, _ string, state *GrantsSt // be confusing to explain wrt permissions. Deleting the resource is a state-only // cleanup (see PlanEntry.StateOnly). -func buildGrantChanges(desiredAssignments []catalog.PrivilegeAssignment, remote map[string][]catalog.Privilege) []catalog.PermissionsChange { - changes := make([]catalog.PermissionsChange, 0, len(desiredAssignments)+len(remote)) +func buildGrantChanges(desiredAssignments []grants.PrivilegeAssignment, remote map[string][]string) []grants.PermissionsChange { + changes := make([]grants.PermissionsChange, 0, len(desiredAssignments)+len(remote)) desiredPrincipals := make(map[string]struct{}, len(desiredAssignments)) for _, ga := range desiredAssignments { - desiredPrincipals[ga.Principal] = struct{}{} - changes = append(changes, catalog.PermissionsChange{ - Principal: ga.Principal, - Add: ga.Privileges, - Remove: grantRemovals(ga.Privileges, remote[ga.Principal]), - ForceSendFields: nil, + principal := utils.Deref(ga.Principal) + desiredPrincipals[principal] = struct{}{} + changes = append(changes, grants.PermissionsChange{ + Principal: new(principal), + Add: ga.Privileges, + Remove: grantRemovals(ga.Privileges, remote[principal]), }) } @@ -170,11 +175,10 @@ func buildGrantChanges(desiredAssignments []catalog.PrivilegeAssignment, remote } slices.Sort(removedPrincipals) for _, principal := range removedPrincipals { - changes = append(changes, catalog.PermissionsChange{ - Principal: principal, - Add: nil, - Remove: grantRemovals(nil, remote[principal]), - ForceSendFields: nil, + changes = append(changes, grants.PermissionsChange{ + Principal: new(principal), + Add: nil, + Remove: grantRemovals(nil, remote[principal]), }) } return changes @@ -186,19 +190,19 @@ func buildGrantChanges(desiredAssignments []catalog.PrivilegeAssignment, remote // no-longer-wanted excluded privileges are revoked. Otherwise ALL_PRIVILEGES is // removed to clear everything it implies, plus the excluded privileges by name // because ALL_PRIVILEGES does not imply them and its removal would leave them behind. -func grantRemovals(desired, remotePrivileges []catalog.Privilege) []catalog.Privilege { +func grantRemovals(desired, remotePrivileges []string) []string { remove := revokedExcludedPrivileges(desired, remotePrivileges) - if slices.Contains(desired, catalog.PrivilegeAllPrivileges) { + if slices.Contains(desired, privilegeAllPrivileges) { return remove } - return append([]catalog.Privilege{catalog.PrivilegeAllPrivileges}, remove...) + return append([]string{privilegeAllPrivileges}, remove...) } // revokedExcludedPrivileges returns the privileges not implied by ALL_PRIVILEGES // (see allPrivilegesExcludes) that the principal holds remotely but no longer // desires, so they can be revoked by name. -func revokedExcludedPrivileges(desired, remotePrivileges []catalog.Privilege) []catalog.Privilege { - var remove []catalog.Privilege +func revokedExcludedPrivileges(desired, remotePrivileges []string) []string { + var remove []string for _, p := range allPrivilegesExcludes { if slices.Contains(remotePrivileges, p) && !slices.Contains(desired, p) { remove = append(remove, p) @@ -210,7 +214,7 @@ func revokedExcludedPrivileges(desired, remotePrivileges []catalog.Privilege) [] // remoteGrantPrivileges maps each principal in the plan's remote state to the // privileges it currently holds, or nil when there is no remote state (e.g. on // create). The privileges are normalized the same way as the desired assignments. -func remoteGrantPrivileges(entry *PlanEntry) map[string][]catalog.Privilege { +func remoteGrantPrivileges(entry *PlanEntry) map[string][]string { if entry == nil { return nil } @@ -218,47 +222,47 @@ func remoteGrantPrivileges(entry *PlanEntry) map[string][]catalog.Privilege { if !ok || remote == nil { return nil } - result := make(map[string][]catalog.Privilege, len(remote.EmbeddedSlice)) + result := make(map[string][]string, len(remote.EmbeddedSlice)) for _, a := range remote.EmbeddedSlice { - if a.Principal != "" { - result[a.Principal] = a.Privileges + if principal := utils.Deref(a.Principal); principal != "" { + result[principal] = a.Privileges } } return result } -func (r *ResourceGrants) listGrants(ctx context.Context, securableType, fullName string) ([]catalog.PrivilegeAssignment, error) { - var assignments []catalog.PrivilegeAssignment - pageToken := "" +func (r *ResourceGrants) listGrants(ctx context.Context, securableType, fullName string) ([]grants.PrivilegeAssignment, error) { + var assignments []grants.PrivilegeAssignment + var pageToken *string for { - resp, err := r.client.Grants.Get(ctx, catalog.GetGrantRequest{ - FullName: fullName, - MaxResults: 0, - PageToken: pageToken, - Principal: "", - SecurableType: securableType, - ForceSendFields: nil, + sdkResp, err := r.client.Grants.GetPermissions(ctx, sdkgrants.GetPermissionsRequest{ + SecurableType: new(securableType), + SecurableFullName: new(fullName), + PageToken: pageToken, + Principal: nil, // Not set by DABs + MaxResults: nil, // Not set by DABs }) if err != nil { return nil, err } + resp, err := grants.GetPermissionsResponseFromSDK(sdkResp) + if err != nil { + return nil, err + } for _, assignment := range resp.PrivilegeAssignments { - if assignment.Principal == "" { + if utils.Deref(assignment.Principal) == "" { continue } - assignments = append(assignments, catalog.PrivilegeAssignment{ - Principal: assignment.Principal, - Privileges: assignment.Privileges, - ForceSendFields: nil, + assignments = append(assignments, grants.PrivilegeAssignment{ + Principal: assignment.Principal, + Privileges: assignment.Privileges, }) } - if resp.NextPageToken == "" { + if utils.Deref(resp.NextPageToken) == "" { break } pageToken = resp.NextPageToken } - // Normalize the same way as the config side (sort, collapse ALL_PRIVILEGES) - // so the two compare equal and we don't report false drift. normalizeAssignments(assignments) return assignments, nil } @@ -268,11 +272,14 @@ func (r *ResourceGrants) listGrants(ctx context.Context, securableType, fullName // normalizeAssignments. UC excludes exactly these four from ALL_PRIVILEGES to // avoid accidental data exfiltration or privilege escalation; see // https://docs.databricks.com/aws/en/data-governance/unity-catalog/manage-privileges/privileges -var allPrivilegesExcludes = []catalog.Privilege{ - catalog.PrivilegeExternalUseLocation, - catalog.PrivilegeExternalUseSchema, - catalog.PrivilegeManage, - catalog.PrivilegeReadMetadata, +// UC privilege names; sdk-go models privileges as plain strings. +const privilegeAllPrivileges = "ALL_PRIVILEGES" + +var allPrivilegesExcludes = []string{ + "EXTERNAL_USE_LOCATION", + "EXTERNAL_USE_SCHEMA", + "MANAGE", + "READ_METADATA", } // normalizeAssignments sorts each assignment's privileges (the backend sorts @@ -282,11 +289,11 @@ var allPrivilegesExcludes = []catalog.Privilege{ // matches a backend that reports ALL_PRIVILEGES plus the concrete privileges it // implies, instead of reporting a perpetual update. The excluded privileges are // kept so they are not silently dropped from both the request and the drift check. -func normalizeAssignments(assignments []catalog.PrivilegeAssignment) { +func normalizeAssignments(assignments []grants.PrivilegeAssignment) { for i := range assignments { privileges := assignments[i].Privileges - if slices.Contains(privileges, catalog.PrivilegeAllPrivileges) { - collapsed := []catalog.Privilege{catalog.PrivilegeAllPrivileges} + if slices.Contains(privileges, privilegeAllPrivileges) { + collapsed := []string{privilegeAllPrivileges} for _, p := range allPrivilegesExcludes { if slices.Contains(privileges, p) { collapsed = append(collapsed, p) diff --git a/bundle/direct/dresources/grants_test.go b/bundle/direct/dresources/grants_test.go index 73a4b1414a2..e0e1d5f90c8 100644 --- a/bundle/direct/dresources/grants_test.go +++ b/bundle/direct/dresources/grants_test.go @@ -3,7 +3,9 @@ package dresources import ( "testing" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/bundle/config/resources" + + grants "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -11,58 +13,58 @@ import ( func TestBuildGrantChanges(t *testing.T) { tests := []struct { name string - desired []catalog.PrivilegeAssignment - remote map[string][]catalog.Privilege - expected []catalog.PermissionsChange + desired []grants.PrivilegeAssignment + remote map[string][]string + expected []grants.PermissionsChange }{ { name: "removes all other privileges for desired principal", - desired: []catalog.PrivilegeAssignment{ + desired: []grants.PrivilegeAssignment{ { - Principal: "alice", - Privileges: []catalog.Privilege{ - catalog.PrivilegeApplyTag, - catalog.PrivilegeCreateTable, + Principal: new("alice"), + Privileges: []string{ + "APPLY_TAG", + "CREATE_TABLE", }, }, }, - expected: []catalog.PermissionsChange{ + expected: []grants.PermissionsChange{ { - Principal: "alice", - Add: []catalog.Privilege{ - catalog.PrivilegeApplyTag, - catalog.PrivilegeCreateTable, + Principal: new("alice"), + Add: []string{ + "APPLY_TAG", + "CREATE_TABLE", }, - Remove: []catalog.Privilege{ - catalog.PrivilegeAllPrivileges, + Remove: []string{ + "ALL_PRIVILEGES", }, }, }, }, { name: "skips ALL_PRIVILEGES removal when granting ALL_PRIVILEGES", - desired: []catalog.PrivilegeAssignment{ + desired: []grants.PrivilegeAssignment{ { - Principal: "alice", - Privileges: []catalog.Privilege{ - catalog.PrivilegeAllPrivileges, + Principal: new("alice"), + Privileges: []string{ + "ALL_PRIVILEGES", }, }, }, - remote: map[string][]catalog.Privilege{ - "bob": {catalog.PrivilegeAllPrivileges}, + remote: map[string][]string{ + "bob": {"ALL_PRIVILEGES"}, }, - expected: []catalog.PermissionsChange{ + expected: []grants.PermissionsChange{ { - Principal: "alice", - Add: []catalog.Privilege{ - catalog.PrivilegeAllPrivileges, + Principal: new("alice"), + Add: []string{ + "ALL_PRIVILEGES", }, }, { - Principal: "bob", - Remove: []catalog.Privilege{ - catalog.PrivilegeAllPrivileges, + Principal: new("bob"), + Remove: []string{ + "ALL_PRIVILEGES", }, }, }, @@ -71,20 +73,20 @@ func TestBuildGrantChanges(t *testing.T) { // ALL_PRIVILEGES stays granted, so MANAGE (which it does not imply and // which its removal would not clear) must be revoked by name. name: "revokes excluded privilege dropped while keeping ALL_PRIVILEGES", - desired: []catalog.PrivilegeAssignment{ + desired: []grants.PrivilegeAssignment{ { - Principal: "alice", - Privileges: []catalog.Privilege{catalog.PrivilegeAllPrivileges}, + Principal: new("alice"), + Privileges: []string{"ALL_PRIVILEGES"}, }, }, - remote: map[string][]catalog.Privilege{ - "alice": {catalog.PrivilegeAllPrivileges, catalog.PrivilegeManage}, + remote: map[string][]string{ + "alice": {"ALL_PRIVILEGES", "MANAGE"}, }, - expected: []catalog.PermissionsChange{ + expected: []grants.PermissionsChange{ { - Principal: "alice", - Add: []catalog.Privilege{catalog.PrivilegeAllPrivileges}, - Remove: []catalog.Privilege{catalog.PrivilegeManage}, + Principal: new("alice"), + Add: []string{"ALL_PRIVILEGES"}, + Remove: []string{"MANAGE"}, }, }, }, @@ -93,13 +95,13 @@ func TestBuildGrantChanges(t *testing.T) { // everything it implies, and MANAGE (which it does not imply) is revoked // by name so the principal is fully removed instead of lingering. name: "revokes excluded privilege of a removed principal", - remote: map[string][]catalog.Privilege{ - "alice": {catalog.PrivilegeAllPrivileges, catalog.PrivilegeManage}, + remote: map[string][]string{ + "alice": {"ALL_PRIVILEGES", "MANAGE"}, }, - expected: []catalog.PermissionsChange{ + expected: []grants.PermissionsChange{ { - Principal: "alice", - Remove: []catalog.Privilege{catalog.PrivilegeAllPrivileges, catalog.PrivilegeManage}, + Principal: new("alice"), + Remove: []string{"ALL_PRIVILEGES", "MANAGE"}, }, }, }, @@ -107,20 +109,20 @@ func TestBuildGrantChanges(t *testing.T) { // Downgrading a principal off ALL_PRIVILEGES: MANAGE must be revoked by // name too, since removing ALL_PRIVILEGES does not clear it. name: "revokes excluded privilege when downgrading off ALL_PRIVILEGES", - desired: []catalog.PrivilegeAssignment{ + desired: []grants.PrivilegeAssignment{ { - Principal: "alice", - Privileges: []catalog.Privilege{catalog.PrivilegeSelect}, + Principal: new("alice"), + Privileges: []string{"SELECT"}, }, }, - remote: map[string][]catalog.Privilege{ - "alice": {catalog.PrivilegeAllPrivileges, catalog.PrivilegeManage}, + remote: map[string][]string{ + "alice": {"ALL_PRIVILEGES", "MANAGE"}, }, - expected: []catalog.PermissionsChange{ + expected: []grants.PermissionsChange{ { - Principal: "alice", - Add: []catalog.Privilege{catalog.PrivilegeSelect}, - Remove: []catalog.Privilege{catalog.PrivilegeAllPrivileges, catalog.PrivilegeManage}, + Principal: new("alice"), + Add: []string{"SELECT"}, + Remove: []string{"ALL_PRIVILEGES", "MANAGE"}, }, }, }, @@ -142,7 +144,7 @@ func TestGrantsIsEmptyState(t *testing.T) { }{ { name: "empty grants list", - state: &GrantsState{SecurableType: "schema", EmbeddedSlice: []catalog.PrivilegeAssignment{}}, + state: &GrantsState{SecurableType: "schema", EmbeddedSlice: []grants.PrivilegeAssignment{}}, expected: true, }, { @@ -154,8 +156,8 @@ func TestGrantsIsEmptyState(t *testing.T) { name: "one assignment", state: &GrantsState{ SecurableType: "schema", - EmbeddedSlice: []catalog.PrivilegeAssignment{ - {Principal: "alice", Privileges: []catalog.Privilege{catalog.PrivilegeSelect}}, + EmbeddedSlice: []grants.PrivilegeAssignment{ + {Principal: new("alice"), Privileges: []string{"SELECT"}}, }, }, expected: false, @@ -179,7 +181,7 @@ func TestIsEmptyStateNotImplemented(t *testing.T) { adapter, err := NewAdapter(SupportedResources["schemas"], "schemas", nil) require.NoError(t, err) - empty, err := adapter.IsEmptyState(&catalog.CreateSchema{Name: "myschema"}) + empty, err := adapter.IsEmptyState(&resources.CreateSchema{Name: new("myschema")}) require.NoError(t, err) assert.False(t, empty) } @@ -187,16 +189,16 @@ func TestIsEmptyStateNotImplemented(t *testing.T) { func TestNormalizeAssignments(t *testing.T) { tests := []struct { name string - input []catalog.PrivilegeAssignment - expected []catalog.PrivilegeAssignment + input []grants.PrivilegeAssignment + expected []grants.PrivilegeAssignment }{ { name: "sorts privileges", - input: []catalog.PrivilegeAssignment{ - {Principal: "alice", Privileges: []catalog.Privilege{catalog.PrivilegeUseSchema, catalog.PrivilegeApplyTag}}, + input: []grants.PrivilegeAssignment{ + {Principal: new("alice"), Privileges: []string{"USE_SCHEMA", "APPLY_TAG"}}, }, - expected: []catalog.PrivilegeAssignment{ - {Principal: "alice", Privileges: []catalog.Privilege{catalog.PrivilegeApplyTag, catalog.PrivilegeUseSchema}}, + expected: []grants.PrivilegeAssignment{ + {Principal: new("alice"), Privileges: []string{"APPLY_TAG", "USE_SCHEMA"}}, }, }, { @@ -205,11 +207,11 @@ func TestNormalizeAssignments(t *testing.T) { // ALL_PRIVILEGES. Applied to both config and remote, this stops the // backend's extra concrete privileges from showing as drift. name: "collapses ALL_PRIVILEGES with concrete privileges", - input: []catalog.PrivilegeAssignment{ - {Principal: "alice", Privileges: []catalog.Privilege{catalog.PrivilegeUseCatalog, catalog.PrivilegeAllPrivileges, catalog.PrivilegeCreateSchema}}, + input: []grants.PrivilegeAssignment{ + {Principal: new("alice"), Privileges: []string{"USE_CATALOG", "ALL_PRIVILEGES", "CREATE_SCHEMA"}}, }, - expected: []catalog.PrivilegeAssignment{ - {Principal: "alice", Privileges: []catalog.Privilege{catalog.PrivilegeAllPrivileges}}, + expected: []grants.PrivilegeAssignment{ + {Principal: new("alice"), Privileges: []string{"ALL_PRIVILEGES"}}, }, }, { @@ -217,23 +219,23 @@ func TestNormalizeAssignments(t *testing.T) { // or EXTERNAL_USE_LOCATION, so all four must survive the collapse instead // of being dropped alongside the concrete privileges (e.g. USE_CATALOG). name: "keeps privileges not implied by ALL_PRIVILEGES", - input: []catalog.PrivilegeAssignment{ - {Principal: "alice", Privileges: []catalog.Privilege{ - catalog.PrivilegeUseCatalog, - catalog.PrivilegeManage, - catalog.PrivilegeReadMetadata, - catalog.PrivilegeExternalUseSchema, - catalog.PrivilegeExternalUseLocation, - catalog.PrivilegeAllPrivileges, + input: []grants.PrivilegeAssignment{ + {Principal: new("alice"), Privileges: []string{ + "USE_CATALOG", + "MANAGE", + "READ_METADATA", + "EXTERNAL_USE_SCHEMA", + "EXTERNAL_USE_LOCATION", + "ALL_PRIVILEGES", }}, }, - expected: []catalog.PrivilegeAssignment{ - {Principal: "alice", Privileges: []catalog.Privilege{ - catalog.PrivilegeAllPrivileges, - catalog.PrivilegeExternalUseLocation, - catalog.PrivilegeExternalUseSchema, - catalog.PrivilegeManage, - catalog.PrivilegeReadMetadata, + expected: []grants.PrivilegeAssignment{ + {Principal: new("alice"), Privileges: []string{ + "ALL_PRIVILEGES", + "EXTERNAL_USE_LOCATION", + "EXTERNAL_USE_SCHEMA", + "MANAGE", + "READ_METADATA", }}, }, }, diff --git a/bundle/direct/dresources/instance_pool.go b/bundle/direct/dresources/instance_pool.go index 37a1aeab447..9436ca854c6 100644 --- a/bundle/direct/dresources/instance_pool.go +++ b/bundle/direct/dresources/instance_pool.go @@ -4,27 +4,28 @@ import ( "context" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" + instancepools "github.com/databricks/cli/libs/sdktypes/instancepools/v2" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/compute" + sdkinstancepools "github.com/databricks/sdk-go/instancepools/v2" ) type ResourceInstancePool struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceInstancePool) New(client *databricks.WorkspaceClient) *ResourceInstancePool { +func (*ResourceInstancePool) New(client *sdkclients.Clients) *ResourceInstancePool { return &ResourceInstancePool{client: client} } -func (*ResourceInstancePool) PrepareState(input *resources.InstancePool) *compute.CreateInstancePool { - return &input.CreateInstancePool +func (*ResourceInstancePool) PrepareState(input *resources.InstancePool) *instancepools.CreateInstancePoolRequest { + return &input.CreateInstancePoolRequest } -// RemapState copies the config fields shared by GetInstancePool and CreateInstancePool; +// RemapState copies the config fields shared by GetInstancePoolResponse and CreateInstancePoolRequest; // output-only fields (state, stats, default_tags, instance_pool_id) are not in the state. -func (*ResourceInstancePool) RemapState(remote *compute.GetInstancePool) *compute.CreateInstancePool { - return &compute.CreateInstancePool{ +func (*ResourceInstancePool) RemapState(remote *instancepools.GetInstancePoolResponse) *instancepools.CreateInstancePoolRequest { + return &instancepools.CreateInstancePoolRequest{ AwsAttributes: remote.AwsAttributes, AzureAttributes: remote.AzureAttributes, CustomTags: remote.CustomTags, @@ -41,25 +42,33 @@ func (*ResourceInstancePool) RemapState(remote *compute.GetInstancePool) *comput PreloadedSparkVersions: remote.PreloadedSparkVersions, RemoteDiskThroughput: remote.RemoteDiskThroughput, TotalInitialRemoteDiskSize: remote.TotalInitialRemoteDiskSize, - ForceSendFields: utils.FilterFields[compute.CreateInstancePool](remote.ForceSendFields), } } -func (r *ResourceInstancePool) DoRead(ctx context.Context, id string) (*compute.GetInstancePool, error) { - return r.client.InstancePools.GetByInstancePoolId(ctx, id) +func (r *ResourceInstancePool) DoRead(ctx context.Context, id string) (*instancepools.GetInstancePoolResponse, error) { + pool, err := r.client.InstancePools.GetInstancePool(ctx, sdkinstancepools.GetInstancePoolRequest{InstancePoolId: new(id)}) + if err != nil { + return nil, err + } + return instancepools.GetInstancePoolResponseFromSDK(pool) } -func (r *ResourceInstancePool) DoCreate(ctx context.Context, config *compute.CreateInstancePool) (string, *compute.GetInstancePool, error) { - resp, err := r.client.InstancePools.Create(ctx, *config) +func (r *ResourceInstancePool) DoCreate(ctx context.Context, config *instancepools.CreateInstancePoolRequest) (string, *instancepools.GetInstancePoolResponse, error) { + request, err := instancepools.CreateInstancePoolRequestToSDK(config) if err != nil { return "", nil, err } - return resp.InstancePoolId, nil, nil + resp, err := r.client.InstancePools.CreateInstancePool(ctx, *request) + if err != nil { + return "", nil, err + } + return utils.Deref(resp.InstancePoolId), nil, nil } -func (r *ResourceInstancePool) DoUpdate(ctx context.Context, id string, config *compute.CreateInstancePool, _ *PlanEntry) (*compute.GetInstancePool, error) { - return nil, r.client.InstancePools.Edit(ctx, compute.EditInstancePool{ - InstancePoolId: id, +// DoUpdate sends only the fields the edit API allows changing. +func (r *ResourceInstancePool) DoUpdate(ctx context.Context, id string, config *instancepools.CreateInstancePoolRequest, _ *PlanEntry) (*instancepools.GetInstancePoolResponse, error) { + request, err := instancepools.EditInstancePoolRequestToSDK(&instancepools.EditInstancePoolRequest{ + InstancePoolId: new(id), InstancePoolName: config.InstancePoolName, NodeTypeId: config.NodeTypeId, MinIdleInstances: config.MinIdleInstances, @@ -68,10 +77,23 @@ func (r *ResourceInstancePool) DoUpdate(ctx context.Context, id string, config * CustomTags: config.CustomTags, RemoteDiskThroughput: config.RemoteDiskThroughput, TotalInitialRemoteDiskSize: config.TotalInitialRemoteDiskSize, - ForceSendFields: utils.FilterFields[compute.EditInstancePool](config.ForceSendFields), + AwsAttributes: nil, // Not set by DABs + AzureAttributes: nil, // Not set by DABs + DiskSpec: nil, // Not set by DABs + EnableElasticDisk: nil, // Not set by DABs + GcpAttributes: nil, // Not set by DABs + NodeTypeFlexibility: nil, // Not set by DABs + PreloadedDockerImages: nil, // Not set by DABs + PreloadedSparkVersions: nil, // Not set by DABs }) + if err != nil { + return nil, err + } + _, err = r.client.InstancePools.EditInstancePool(ctx, *request) + return nil, err } -func (r *ResourceInstancePool) DoDelete(ctx context.Context, id string, _ *compute.CreateInstancePool) error { - return r.client.InstancePools.DeleteByInstancePoolId(ctx, id) +func (r *ResourceInstancePool) DoDelete(ctx context.Context, id string, _ *instancepools.CreateInstancePoolRequest) error { + _, err := r.client.InstancePools.DeleteInstancePool(ctx, sdkinstancepools.DeleteInstancePoolRequest{InstancePoolId: new(id)}) + return err } diff --git a/bundle/direct/dresources/job.go b/bundle/direct/dresources/job.go index 86c4e0ca1c9..8e573e103ed 100644 --- a/bundle/direct/dresources/job.go +++ b/bundle/direct/dresources/job.go @@ -6,10 +6,11 @@ import ( "strconv" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/sdkconv" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/jobs" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" ) // JobRemote is the return type for DoRead. It embeds JobSettings so that all @@ -17,32 +18,22 @@ import ( type JobRemote struct { jobs.JobSettings - // Remote-specific fields from jobs.Job - CreatedTime int64 `json:"created_time,omitempty"` - CreatorUserName string `json:"creator_user_name,omitempty"` - EffectiveBudgetPolicyId string `json:"effective_budget_policy_id,omitempty"` - EffectiveUsagePolicyId string `json:"effective_usage_policy_id,omitempty"` - JobId int64 `json:"job_id,omitempty"` - RunAsUserName string `json:"run_as_user_name,omitempty"` - TriggerDetails []jobs.TriggerDetails `json:"trigger_details,omitempty"` - TriggerState *jobs.TriggerStateProto `json:"trigger_state,omitempty"` -} - -// Custom marshaler needed because embedded JobSettings has its own MarshalJSON -// which would otherwise take over and ignore the additional fields. -func (s *JobRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s JobRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) + // Remote-specific fields from jobs.GetJobResponse + CreatedTime *int64 `json:"created_time,omitempty"` + CreatorUserName *string `json:"creator_user_name,omitempty"` + EffectiveBudgetPolicyId *string `json:"effective_budget_policy_id,omitempty"` + EffectiveUsagePolicyId *string `json:"effective_usage_policy_id,omitempty"` + JobId *int64 `json:"job_id,omitempty"` + RunAsUserName *string `json:"run_as_user_name,omitempty"` + TriggerDetails []jobs.TriggerDetails `json:"trigger_details,omitempty"` + TriggerState *jobs.TriggerState `json:"trigger_state,omitempty"` } type ResourceJob struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceJob) New(client *databricks.WorkspaceClient) *ResourceJob { +func (*ResourceJob) New(client *sdkclients.Clients) *ResourceJob { return &ResourceJob{ client: client, } @@ -56,28 +47,28 @@ func (*ResourceJob) RemapState(remote *JobRemote) *jobs.JobSettings { return &remote.JobSettings } -func getTaskKey(x jobs.Task) (string, string) { - return "task_key", x.TaskKey +func getTaskKey(x jobs.TaskSettings) (string, string) { + return "task_key", utils.Deref(x.TaskKey) } -func getParameterName(x jobs.JobParameterDefinition) (string, string) { - return "name", x.Name +func getParameterName(x jobs.JobLevelParameter) (string, string) { + return "name", utils.Deref(x.Name) } func getJobClusterKey(x jobs.JobCluster) (string, string) { - return "job_cluster_key", x.JobClusterKey + return "job_cluster_key", utils.Deref(x.JobClusterKey) } func getEnvironmentKey(x jobs.JobEnvironment) (string, string) { - return "environment_key", x.EnvironmentKey + return "environment_key", utils.Deref(x.EnvironmentKey) } func getDependsOnTaskKey(x jobs.TaskDependency) (string, string) { - return "task_key", x.TaskKey + return "task_key", utils.Deref(x.TaskKey) } func getWebhookKey(x jobs.Webhook) (string, string) { - return "id", x.Id + return "id", utils.Deref(x.Id) } // The Jobs API returns webhook_notifications.on_* in an arbitrary order, so @@ -119,21 +110,48 @@ func (r *ResourceJob) DoRead(ctx context.Context, id string) (*JobRemote, error) if err != nil { return nil, err } - // GetByJobId only fetches the first page (100 tasks). Jobs.Get handles - // pagination and returns the complete job with all tasks merged. - job, err := r.client.Jobs.Get(ctx, jobs.GetJobRequest{ - JobId: idInt, - PageToken: "", - IncludeTriggerState: false, - ForceSendFields: nil, - }) + job, err := r.getJob(ctx, idInt) + if err != nil { + return nil, err + } + return makeJobRemote(job) +} + +// getJob fetches the job with all its tasks. jobs/get returns at most 100 +// tasks (and job clusters, parameters, environments) per page; later pages +// are fetched with next_page_token and merged. +func (r *ResourceJob) getJob(ctx context.Context, id int64) (*sdkjobs.GetJobResponse, error) { + req := sdkjobs.GetJobRequest{ + JobId: new(id), + IncludeTriggerState: nil, // Not set by DABs + PageToken: nil, // Not set by DABs + } + job, err := r.client.Jobs.GetJob(ctx, req) if err != nil { return nil, err } - return makeJobRemote(job), nil + for job.NextPageToken != nil && *job.NextPageToken != "" { + req.PageToken = job.NextPageToken + next, err := r.client.Jobs.GetJob(ctx, req) + if err != nil { + return nil, err + } + if job.Settings != nil && next.Settings != nil { + job.Settings.Tasks = append(job.Settings.Tasks, next.Settings.Tasks...) + job.Settings.JobClusters = append(job.Settings.JobClusters, next.Settings.JobClusters...) + job.Settings.Parameters = append(job.Settings.Parameters, next.Settings.Parameters...) + job.Settings.Environments = append(job.Settings.Environments, next.Settings.Environments...) + } + job.NextPageToken = next.NextPageToken + } + return job, nil } -func makeJobRemote(job *jobs.Job) *JobRemote { +func makeJobRemote(resp *sdkjobs.GetJobResponse) (*JobRemote, error) { + job, err := sdkconv.FromSDK[jobs.GetJobResponse](resp) + if err != nil { + return nil, err + } var settings jobs.JobSettings if job.Settings != nil { settings = *job.Settings @@ -148,86 +166,45 @@ func makeJobRemote(job *jobs.Job) *JobRemote { RunAsUserName: job.RunAsUserName, TriggerDetails: job.TriggerDetails, TriggerState: job.TriggerState, - } + }, nil } func (r *ResourceJob) DoCreate(ctx context.Context, config *jobs.JobSettings) (string, *JobRemote, error) { - request, err := makeCreateJob(*config) + // access_control_list is not supported by DABs; permissions are a separate resource. + request, err := sdkconv.ToSDK[sdkjobs.CreateJobRequest](config) if err != nil { return "", nil, err } - response, err := r.client.Jobs.Create(ctx, request) + response, err := r.client.Jobs.CreateJob(ctx, *request) if err != nil { return "", nil, err } - return strconv.FormatInt(response.JobId, 10), nil, nil + return strconv.FormatInt(utils.Deref(response.JobId), 10), nil, nil } func (r *ResourceJob) DoUpdate(ctx context.Context, id string, config *jobs.JobSettings, _ *PlanEntry) (*JobRemote, error) { - request, err := makeResetJob(*config, id) + idInt, err := parseJobID(id) if err != nil { return nil, err } - return nil, r.client.Jobs.Reset(ctx, request) -} - -func (r *ResourceJob) DoDelete(ctx context.Context, id string, _ *jobs.JobSettings) error { - idInt, err := parseJobID(id) + settings, err := jobs.JobSettingsToSDK(config) if err != nil { - return err - } - return r.client.Jobs.DeleteByJobId(ctx, idInt) -} - -func makeCreateJob(config jobs.JobSettings) (jobs.CreateJob, error) { - // Note, exhaustruct linter validates that all off CreateJob fields are initialized. - // We don't have linter that validates that all of config fields are used. - result := jobs.CreateJob{ - AccessControlList: nil, // Not supported by DABs - BudgetPolicyId: config.BudgetPolicyId, - Continuous: config.Continuous, - Deployment: config.Deployment, - Description: config.Description, - EditMode: config.EditMode, - EmailNotifications: config.EmailNotifications, - EnvironmentVariables: config.EnvironmentVariables, - Environments: config.Environments, - Format: config.Format, - GitSource: config.GitSource, - Health: config.Health, - JobClusters: config.JobClusters, - MaxConcurrentRuns: config.MaxConcurrentRuns, - Name: config.Name, - NotificationSettings: config.NotificationSettings, - Parameters: config.Parameters, - ParentPath: config.ParentPath, - PerformanceTarget: config.PerformanceTarget, - Queue: config.Queue, - RunAs: config.RunAs, - Schedule: config.Schedule, - Tags: config.Tags, - Tasks: config.Tasks, - TimeoutSeconds: config.TimeoutSeconds, - Trigger: config.Trigger, - Triggers: config.Triggers, - UsagePolicyId: config.UsagePolicyId, - WebhookNotifications: config.WebhookNotifications, - ForceSendFields: utils.FilterFields[jobs.CreateJob](config.ForceSendFields, "AccessControlList"), + return nil, err } - - return result, nil + _, err = r.client.Jobs.ResetJob(ctx, sdkjobs.ResetJobRequest{ + JobId: new(idInt), + NewSettings: settings, + }) + return nil, err } -func makeResetJob(config jobs.JobSettings, id string) (jobs.ResetJob, error) { +func (r *ResourceJob) DoDelete(ctx context.Context, id string, _ *jobs.JobSettings) error { idInt, err := parseJobID(id) if err != nil { - return jobs.ResetJob{}, err - } - result := jobs.ResetJob{ - JobId: idInt, - NewSettings: config, + return err } - return result, err + _, err = r.client.Jobs.DeleteJob(ctx, sdkjobs.DeleteJobRequest{JobId: new(idInt)}) + return err } func parseJobID(id string) (int64, error) { diff --git a/bundle/direct/dresources/job_run.go b/bundle/direct/dresources/job_run.go index ae38dcacdbc..8b0669c5fd6 100644 --- a/bundle/direct/dresources/job_run.go +++ b/bundle/direct/dresources/job_run.go @@ -12,14 +12,15 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/bundle/direct/internal/retries" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdkclients" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/structs/structpath" + "github.com/databricks/cli/libs/utils" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/retries" - "github.com/databricks/databricks-sdk-go/service/jobs" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" "github.com/google/uuid" ) @@ -33,32 +34,24 @@ type JobRunLifecycleState struct { // JobRunState is the RunNow request plus the outcome required for planning. type JobRunState struct { - jobs.RunNow + jobs.RunNowRequest // Always SUCCESS during planning and cleared before persistence. - ResultState jobs.RunResultState `json:"result_state,omitempty"` + ResultState jobs.RunResultState_RunResultState `json:"result_state,omitempty"` // Local-only fingerprint. Nested under lifecycle to avoid colliding with a // future Jobs API field; nil when no trigger is armed so the key is omitted. Lifecycle *JobRunLifecycleState `json:"lifecycle,omitempty"` } -func (s *JobRunState) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s JobRunState) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - // JobRunRemote is the RunNow request plus the run's output-only fields. It has no // lifecycle: GetRun never returns the fingerprints (see knownMissingInRemoteType). type JobRunRemote struct { - jobs.RunNow + jobs.RunNowRequest // Repeats state.result_state at the path JobRunState uses, so the planner can // compare the two. See "RemapState is a dumb copy" in README.md. - ResultState jobs.RunResultState `json:"result_state,omitempty"` + ResultState jobs.RunResultState_RunResultState `json:"result_state,omitempty"` RunId int64 `json:"run_id,omitempty"` RunName string `json:"run_name,omitempty"` @@ -67,21 +60,11 @@ type JobRunRemote struct { RunType jobs.RunType `json:"run_type,omitempty"` } -// Custom marshaler needed because embedded RunNow's MarshalJSON would otherwise -// take over and drop the additional fields. -func (s *JobRunRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s JobRunRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - type ResourceJobRun struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceJobRun) New(client *databricks.WorkspaceClient) *ResourceJobRun { +func (*ResourceJobRun) New(client *sdkclients.Clients) *ResourceJobRun { return &ResourceJobRun{ client: client, } @@ -89,9 +72,9 @@ func (*ResourceJobRun) New(client *databricks.WorkspaceClient) *ResourceJobRun { func (*ResourceJobRun) PrepareState(input *resources.JobRun) *JobRunState { state := &JobRunState{ - RunNow: input.RunNow, - ResultState: jobs.RunResultStateSuccess, - Lifecycle: nil, + RunNowRequest: input.RunNowRequest, + ResultState: jobs.RunResultState_RunResultState_Success, + Lifecycle: nil, } var ts resources.JobRunTriggersState if input.Lifecycle != nil && input.Lifecycle.TriggersState != nil { @@ -109,7 +92,7 @@ func (*ResourceJobRun) PrepareState(input *resources.JobRun) *JobRunState { // makeJobRunRemote maps the GetRun response into the RunNow-shaped remote: GET // nests the params under overriding_parameters and returns job_parameters as a // list, so both are flattened back into RunNow. -func makeJobRunRemote(run *jobs.Run) *JobRunRemote { +func makeJobRunRemote(run *jobs.GetRunResponse) *JobRunRemote { var overriding jobs.RunParameters if run.OverridingParameters != nil { overriding = *run.OverridingParameters @@ -118,9 +101,10 @@ func makeJobRunRemote(run *jobs.Run) *JobRunRemote { if len(run.JobParameters) > 0 { jobParameters = make(map[string]string, len(run.JobParameters)) for _, p := range run.JobParameters { - jobParameters[p.Name] = p.Value + jobParameters[utils.Deref(p.Name)] = utils.Deref(p.Value) } } + state := runState(run) return &JobRunRemote{ JobId: run.JobId, JobParameters: jobParameters, @@ -132,42 +116,62 @@ func makeJobRunRemote(run *jobs.Run) *JobRunRemote { PythonParams: overriding.PythonParams, SparkSubmitParams: overriding.SparkSubmitParams, SqlParams: overriding.SqlParams, - // Request-only fields GetRun never reports; listed so exhaustruct - // flags any new SDK field. - IdempotencyToken: "", + // Request-only fields GetRun never reports. + IdempotencyToken: nil, Only: nil, PerformanceTarget: "", Queue: nil, - ForceSendFields: nil, - ResultState: run.State.ResultState, - RunId: run.RunId, - RunName: run.RunName, - // Rebuilt, not copied: the SDK records explicitly-sent fields in - // ForceSendFields, which makes zero values workspace-dependent. + ResultState: state.ResultState, + RunId: utils.Deref(run.RunId), + RunName: utils.Deref(run.RunName), + // Only the fields planning reads; queue_reason and user_cancelled_or_timedout + // are left out so the remote does not depend on what the workspace reports. State: &jobs.RunState{ - LifeCycleState: run.State.LifeCycleState, - ResultState: run.State.ResultState, - StateMessage: run.State.StateMessage, - // Nothing reads these; listed so exhaustruct flags any new SDK field. - QueueReason: "", - UserCancelledOrTimedout: false, - ForceSendFields: nil, + LifeCycleState: state.LifeCycleState, + ResultState: state.ResultState, + StateMessage: state.StateMessage, + QueueReason: nil, // Not set by DABs + UserCancelledOrTimedout: nil, // Not set by DABs }, - RunPageUrl: workspaceurls.ModernizeJobRunPageURL(run.RunPageUrl), + RunPageUrl: workspaceurls.ModernizeJobRunPageURL(utils.Deref(run.RunPageUrl)), RunType: run.RunType, } } +// runState returns the run's state, or an empty one if the run has none. +func runState(run *jobs.GetRunResponse) jobs.RunState { + if run.State == nil { + return jobs.RunState{ + LifeCycleState: "", // Not set by DABs + QueueReason: nil, // Not set by DABs + ResultState: "", // Not set by DABs + StateMessage: nil, // Not set by DABs + UserCancelledOrTimedout: nil, // Not set by DABs + } + } + return *run.State +} + +func (r *ResourceJobRun) getRun(ctx context.Context, runID int64) (*jobs.GetRunResponse, error) { + run, err := r.client.Jobs.GetRun(ctx, sdkjobs.GetRunRequest{ + RunId: new(runID), + IncludeHistory: nil, // Not set by DABs + IncludeResolvedValues: nil, // Not set by DABs + PageToken: nil, // Not set by DABs + }) + if err != nil { + return nil, err + } + return jobs.GetRunResponseFromSDK(run) +} + // DoRead returns the run as GetRun reports it; a 404 lets the planner re-trigger. func (r *ResourceJobRun) DoRead(ctx context.Context, id string) (*JobRunRemote, error) { runID, err := parseRunID(id) if err != nil { return nil, err } - // var + field set (not a literal) avoids listing GetRunRequest's other fields. - var req jobs.GetRunRequest - req.RunId = runID - run, err := r.client.Jobs.GetRun(ctx, req) + run, err := r.getRun(ctx, runID) if err != nil { return nil, err } @@ -178,25 +182,29 @@ func (r *ResourceJobRun) DoRead(ctx context.Context, id string) (*JobRunRemote, // outcome the run reached. Lifecycle has no remote counterpart. func (*ResourceJobRun) RemapState(remote *JobRunRemote) *JobRunState { return &JobRunState{ - RunNow: remote.RunNow, - ResultState: remote.ResultState, - Lifecycle: nil, + RunNowRequest: remote.RunNowRequest, + ResultState: remote.ResultState, + Lifecycle: nil, } } func (r *ResourceJobRun) DoCreate(ctx context.Context, config *JobRunState) (string, *JobRunRemote, error) { // Mint a token so an SDK retry of a lost response returns the same run. Set it // on a copy: recording it in state would drift from the empty config and recreate. - req := config.RunNow - req.IdempotencyToken = uuid.NewString() + req := config.RunNowRequest + req.IdempotencyToken = new(uuid.NewString()) + request, err := jobs.RunNowRequestToSDK(&req) + if err != nil { + return "", nil, err + } // RunNow returns only the new run id, so we return a nil remote and let the // framework read it back via DoRead. - wait, err := r.client.Jobs.RunNow(ctx, req) + wait, err := r.client.Jobs.RunNow(ctx, *request) if err != nil { return "", nil, err } config.ResultState = "" - return strconv.FormatInt(wait.RunId, 10), nil, nil + return strconv.FormatInt(wait.GetRunId(), 10), nil, nil } // WaitAfterCreate blocks until the run finishes, so a resource referencing its @@ -222,23 +230,22 @@ func (r *ResourceJobRun) waitForRun(ctx context.Context, id string) (*JobRunRemo // INTERNAL_ERROR, the state a run whose task failed lands in, leaving // runFailedError nothing to name the failing task from. This poll returns the // run in whatever state it settles in. - run, err := retries.Poll(ctx, jobRunTimeout, func() (*jobs.Run, *retries.Err) { - var req jobs.GetRunRequest - req.RunId = runID - run, err := r.client.Jobs.GetRun(ctx, req) + run, err := retries.Poll(ctx, jobRunTimeout, func() (*jobs.GetRunResponse, *retries.Err) { + run, err := r.getRun(ctx, runID) if err != nil { return nil, retries.Halt(err) } - if pageURL == "" && run.RunPageUrl != "" { - pageURL = run.RunPageUrl + if pageURL == "" && utils.Deref(run.RunPageUrl) != "" { + pageURL = *run.RunPageUrl reportRunLine(ctx, runID, "Run URL: "+workspaceurls.ModernizeJobRunPageURL(pageURL)) } - if run.State.LifeCycleState != logged.LifeCycleState || run.State.ResultState != logged.ResultState { - logged = *run.State + state := runState(run) + if state.LifeCycleState != logged.LifeCycleState || state.ResultState != logged.ResultState { + logged = state log.Info(ctx, strings.TrimSpace(fmt.Sprintf("job run %d: %s %s", runID, logged.LifeCycleState, logged.ResultState))) } - if !runIsTerminal(run.State.LifeCycleState) { - return nil, retries.Continues(run.State.StateMessage) + if !runIsTerminal(state.LifeCycleState) { + return nil, retries.Continues(utils.Deref(state.StateMessage)) } return run, nil }) @@ -251,29 +258,30 @@ func (r *ResourceJobRun) waitForRun(ctx context.Context, id string) (*JobRunRemo } return nil, fmt.Errorf("%w%s", err, runPageLine(pageURL)) } - if run.State.ResultState != jobs.RunResultStateSuccess { + if runState(run).ResultState != jobs.RunResultState_RunResultState_Success { // The error names the outcome. return nil, r.runFailedError(ctx, run) } - reportRunLine(ctx, runID, string(run.State.ResultState)) + reportRunLine(ctx, runID, string(runState(run).ResultState)) return makeJobRunRemote(run), nil } // runFailedError reports why the run did not succeed, naming each failed task // and the error it reported. -func (r *ResourceJobRun) runFailedError(ctx context.Context, run *jobs.Run) error { +func (r *ResourceJobRun) runFailedError(ctx context.Context, run *jobs.GetRunResponse) error { + state := runState(run) // A skipped run has no result_state; report the lifecycle state. - outcome := cmp.Or(string(run.State.ResultState), string(run.State.LifeCycleState)) + outcome := cmp.Or(string(state.ResultState), string(state.LifeCycleState)) var msg strings.Builder // The framework already prefixes the resource key and the run id. fmt.Fprintf(&msg, "run did not succeed: %s", outcome) - if run.State.StateMessage != "" { - fmt.Fprintf(&msg, ": %s", run.State.StateMessage) + if message := utils.Deref(state.StateMessage); message != "" { + fmt.Fprintf(&msg, ": %s", message) } for _, task := range lastFailedAttempts(run.Tasks) { - fmt.Fprintf(&msg, "\ntask %q: %s", task.TaskKey, r.taskError(ctx, task)) + fmt.Fprintf(&msg, "\ntask %q: %s", utils.Deref(task.TaskKey), r.taskError(ctx, task)) } - msg.WriteString(runPageLine(run.RunPageUrl)) + msg.WriteString(runPageLine(utils.Deref(run.RunPageUrl))) return errors.New(msg.String()) } @@ -286,11 +294,11 @@ func lastFailedAttempts(tasks []jobs.RunTask) []jobs.RunTask { if !taskFailed(task) { continue } - i := slices.IndexFunc(result, func(seen jobs.RunTask) bool { return seen.TaskKey == task.TaskKey }) + i := slices.IndexFunc(result, func(seen jobs.RunTask) bool { return utils.Deref(seen.TaskKey) == utils.Deref(task.TaskKey) }) switch { case i < 0: result = append(result, task) - case task.AttemptNumber > result[i].AttemptNumber: + case utils.Deref(task.AttemptNumber) > utils.Deref(result[i].AttemptNumber): result[i] = task } } @@ -301,9 +309,9 @@ func lastFailedAttempts(tasks []jobs.RunTask) []jobs.RunTask { // SKIPPED or UPSTREAM_FAILED never ran, so it has no error to report. func taskFailed(task jobs.RunTask) bool { if task.State != nil { - return task.State.LifeCycleState == jobs.RunLifeCycleStateInternalError || - task.State.ResultState == jobs.RunResultStateFailed || - task.State.ResultState == jobs.RunResultStateTimedout + return task.State.LifeCycleState == jobs.RunLifeCycleState_RunLifeCycleState_InternalError || + task.State.ResultState == jobs.RunResultState_RunResultState_Failed || + task.State.ResultState == jobs.RunResultState_RunResultState_Timedout } // State is deprecated in favour of Status, so a workspace may stop setting it. if task.Status == nil || task.Status.TerminationDetails == nil { @@ -311,19 +319,19 @@ func taskFailed(task jobs.RunTask) bool { } details := task.Status.TerminationDetails // SKIPPED is also the code for a task an upstream failure skipped. - return details.Type != jobs.TerminationTypeTypeSuccess && - details.Code != jobs.TerminationCodeCodeSkipped + return details.Type != jobs.TerminationType_Type_Success && + details.Code != jobs.TerminationCode_Code_Skipped } // taskError returns the message the task reported, from the same place `bundle // run` reads it. func (r *ResourceJobRun) taskError(ctx context.Context, task jobs.RunTask) string { var reported string - output, err := r.client.Jobs.GetRunOutput(ctx, jobs.GetRunOutputRequest{RunId: task.RunId}) + output, err := r.client.Jobs.GetRunOutput(ctx, sdkjobs.GetRunOutputRequest{RunId: task.RunId}) if err != nil { - log.Debugf(ctx, "could not read output of task %s: %v", task.TaskKey, err) + log.Debugf(ctx, "could not read output of task %s: %v", utils.Deref(task.TaskKey), err) } else { - reported = output.Error + reported = utils.Deref(output.Error) } // Not every task type reports an error through GetRunOutput. return cmp.Or(reported, taskMessage(task)) @@ -333,9 +341,9 @@ func (r *ResourceJobRun) taskError(ctx context.Context, task jobs.RunTask) strin // on, so the field it reads is always set. func taskMessage(task jobs.RunTask) string { if task.State != nil { - return task.State.StateMessage + return utils.Deref(task.State.StateMessage) } - return task.Status.TerminationDetails.Message + return utils.Deref(task.Status.TerminationDetails.Message) } func runPageLine(rawURL string) string { @@ -346,10 +354,10 @@ func runPageLine(rawURL string) string { } // runIsTerminal reports whether a run has stopped, whatever it stopped as. -func runIsTerminal(state jobs.RunLifeCycleState) bool { - return state == jobs.RunLifeCycleStateTerminated || - state == jobs.RunLifeCycleStateSkipped || - state == jobs.RunLifeCycleStateInternalError +func runIsTerminal(state jobs.RunLifeCycleState_RunLifeCycleState) bool { + return state == jobs.RunLifeCycleState_RunLifeCycleState_Terminated || + state == jobs.RunLifeCycleState_RunLifeCycleState_Skipped || + state == jobs.RunLifeCycleState_RunLifeCycleState_InternalError } // reportRunLine names the resource and run id so concurrent deploys stay readable. diff --git a/bundle/direct/dresources/job_run_test.go b/bundle/direct/dresources/job_run_test.go index 5dc964c360f..6b194dedb28 100644 --- a/bundle/direct/dresources/job_run_test.go +++ b/bundle/direct/dresources/job_run_test.go @@ -11,10 +11,12 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/libs/sdkclients" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -22,11 +24,11 @@ import ( // jobRunClientFor returns a client talking to server. Call it after the test // registers its own handlers: first registration wins, so the defaults added here // only fill the gaps. -func jobRunClientFor(t *testing.T, server *testserver.Server) *databricks.WorkspaceClient { +func jobRunClientFor(t *testing.T, server *testserver.Server) *sdkclients.Clients { t.Helper() testserver.AddDefaultHandlers(server) - client, err := databricks.NewWorkspaceClient(&databricks.Config{ + client, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", }) @@ -36,7 +38,7 @@ func jobRunClientFor(t *testing.T, server *testserver.Server) *databricks.Worksp // jobRunServer returns a client whose runs/get is the given handler, so a wait can // be driven without a real run. -func jobRunServer(t *testing.T, getRun testserver.HandlerFunc) *databricks.WorkspaceClient { +func jobRunServer(t *testing.T, getRun testserver.HandlerFunc) *sdkclients.Clients { t.Helper() server := testserver.New(t) server.Handle("GET", "/api/2.2/jobs/runs/get", getRun) @@ -51,16 +53,16 @@ const ( ) // jobRunClient returns a client whose GetRun always reports the given run state. -func jobRunClient(t *testing.T, state *jobs.RunState) *databricks.WorkspaceClient { +func jobRunClient(t *testing.T, state *jobs.RunState) *sdkclients.Clients { t.Helper() return jobRunServer(t, func(req testserver.Request) any { - return jobs.Run{RunId: 123, JobId: 456, State: state, RunPageUrl: testRunPageURL} + return jobs.GetRunResponse{RunId: new(int64(123)), JobId: new(int64(456)), State: state, RunPageUrl: new(testRunPageURL)} }) } // waitForTestRun drives the framework hook, so it covers parsing the id the // framework hands back from DoCreate along with the wait itself. -func waitForTestRun(t *testing.T, ctx context.Context, client *databricks.WorkspaceClient) (*JobRunRemote, error) { +func waitForTestRun(t *testing.T, ctx context.Context, client *sdkclients.Clients) (*JobRunRemote, error) { t.Helper() r := (&ResourceJobRun{}).New(client) return r.WaitAfterCreate(ctx, "123", &JobRunState{}) @@ -68,9 +70,9 @@ func waitForTestRun(t *testing.T, ctx context.Context, client *databricks.Worksp func TestJobRunWaitFailsOnFailedResult(t *testing.T) { client := jobRunClient(t, &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateFailed, - StateMessage: "task failed", + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Failed, + StateMessage: new("task failed"), }) _, err := waitForTestRun(t, t.Context(), client) @@ -83,35 +85,35 @@ func TestJobRunWaitFailsOnFailedResult(t *testing.T) { func TestJobRunWaitReportsFailedTaskWithoutDeprecatedState(t *testing.T) { server := testserver.New(t) server.Handle("GET", "/api/2.2/jobs/runs/get", func(req testserver.Request) any { - return jobs.Run{ - RunId: 123, - JobId: 456, + return jobs.GetRunResponse{ + RunId: new(int64(123)), + JobId: new(int64(456)), State: &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateFailed, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Failed, }, Tasks: []jobs.RunTask{ - {TaskKey: "main", RunId: 999, Status: &jobs.RunStatus{ - State: jobs.RunLifecycleStateV2StateTerminated, + {TaskKey: new("main"), RunId: new(int64(999)), Status: &jobs.RunStatus{ + State: jobs.RunLifecycleStateV2_State_Terminated, TerminationDetails: &jobs.TerminationDetails{ - Type: jobs.TerminationTypeTypeClientError, - Code: jobs.TerminationCodeCodeRunExecutionError, - Message: "Workload failed, see run output for details", + Type: jobs.TerminationType_Type_ClientError, + Code: jobs.TerminationCode_Code_RunExecutionError, + Message: new("Workload failed, see run output for details"), }, }}, // Never ran, so it has no error of its own to report. - {TaskKey: "downstream", RunId: 1000, Status: &jobs.RunStatus{ - State: jobs.RunLifecycleStateV2StateTerminated, + {TaskKey: new("downstream"), RunId: new(int64(1000)), Status: &jobs.RunStatus{ + State: jobs.RunLifecycleStateV2_State_Terminated, TerminationDetails: &jobs.TerminationDetails{ - Type: jobs.TerminationTypeTypeClientError, - Code: jobs.TerminationCodeCodeSkipped, + Type: jobs.TerminationType_Type_ClientError, + Code: jobs.TerminationCode_Code_Skipped, }, }}, }, } }) server.Handle("GET", "/api/2.2/jobs/runs/get-output", func(req testserver.Request) any { - return jobs.RunOutput{Error: "RuntimeError: intentional failure"} + return jobs.GetRunOutputResponse{Error: new("RuntimeError: intentional failure")} }) _, err := waitForTestRun(t, t.Context(), jobRunClientFor(t, server)) @@ -124,27 +126,27 @@ func TestJobRunWaitReportsFailedTaskWithoutDeprecatedState(t *testing.T) { func TestJobRunWaitFallsBackToTheTerminationMessage(t *testing.T) { server := testserver.New(t) server.Handle("GET", "/api/2.2/jobs/runs/get", func(req testserver.Request) any { - return jobs.Run{ - RunId: 123, - JobId: 456, + return jobs.GetRunResponse{ + RunId: new(int64(123)), + JobId: new(int64(456)), State: &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateFailed, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Failed, }, Tasks: []jobs.RunTask{ - {TaskKey: "main", RunId: 999, Status: &jobs.RunStatus{ - State: jobs.RunLifecycleStateV2StateTerminated, + {TaskKey: new("main"), RunId: new(int64(999)), Status: &jobs.RunStatus{ + State: jobs.RunLifecycleStateV2_State_Terminated, TerminationDetails: &jobs.TerminationDetails{ - Type: jobs.TerminationTypeTypeCloudFailure, - Code: jobs.TerminationCodeCodeCloudFailure, - Message: "the cloud provider ran out of capacity", + Type: jobs.TerminationType_Type_CloudFailure, + Code: jobs.TerminationCode_Code_CloudFailure, + Message: new("the cloud provider ran out of capacity"), }, }}, }, } }) server.Handle("GET", "/api/2.2/jobs/runs/get-output", func(req testserver.Request) any { - return jobs.RunOutput{} + return jobs.GetRunOutputResponse{} }) _, err := waitForTestRun(t, t.Context(), jobRunClientFor(t, server)) @@ -156,24 +158,24 @@ func TestJobRunWaitFallsBackToTheTerminationMessage(t *testing.T) { func TestJobRunWaitFallsBackToTheTaskMessage(t *testing.T) { server := testserver.New(t) server.Handle("GET", "/api/2.2/jobs/runs/get", func(req testserver.Request) any { - return jobs.Run{ - RunId: 123, - JobId: 456, + return jobs.GetRunResponse{ + RunId: new(int64(123)), + JobId: new(int64(456)), State: &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateFailed, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Failed, }, Tasks: []jobs.RunTask{ - {TaskKey: "main", RunId: 999, State: &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateFailed, - StateMessage: "Workload failed, see run output for details", + {TaskKey: new("main"), RunId: new(int64(999)), State: &jobs.RunState{ + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Failed, + StateMessage: new("Workload failed, see run output for details"), }}, }, } }) server.Handle("GET", "/api/2.2/jobs/runs/get-output", func(req testserver.Request) any { - return jobs.RunOutput{} + return jobs.GetRunOutputResponse{} }) _, err := waitForTestRun(t, t.Context(), jobRunClientFor(t, server)) @@ -184,7 +186,7 @@ func TestJobRunWaitFallsBackToTheTaskMessage(t *testing.T) { func TestJobRunWaitFailsOnSkipped(t *testing.T) { // A skipped run has no result_state, so the lifecycle state is reported. client := jobRunClient(t, &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateSkipped, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Skipped, }) _, err := waitForTestRun(t, t.Context(), client) @@ -194,7 +196,7 @@ func TestJobRunWaitFailsOnSkipped(t *testing.T) { func TestJobRunWaitFailsOnInternalError(t *testing.T) { client := jobRunClient(t, &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateInternalError, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_InternalError, }) _, err := waitForTestRun(t, t.Context(), client) @@ -205,23 +207,23 @@ func TestJobRunWaitFailsOnInternalError(t *testing.T) { func TestJobRunWaitReportsOnlyTheLastAttemptOfATask(t *testing.T) { failed := &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateFailed, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Failed, } server := testserver.New(t) server.Handle("GET", "/api/2.2/jobs/runs/get", func(req testserver.Request) any { - return jobs.Run{ - RunId: 123, - JobId: 456, + return jobs.GetRunResponse{ + RunId: new(int64(123)), + JobId: new(int64(456)), State: failed, Tasks: []jobs.RunTask{ - {TaskKey: "main", RunId: 998, AttemptNumber: 0, State: failed}, - {TaskKey: "main", RunId: 999, AttemptNumber: 1, State: failed}, + {TaskKey: new("main"), RunId: new(int64(998)), AttemptNumber: new(0), State: failed}, + {TaskKey: new("main"), RunId: new(int64(999)), AttemptNumber: new(1), State: failed}, }, } }) server.Handle("GET", "/api/2.2/jobs/runs/get-output", func(req testserver.Request) any { - return jobs.RunOutput{Error: "output of run " + req.URL.Query().Get("run_id")} + return jobs.GetRunOutputResponse{Error: new("output of run " + req.URL.Query().Get("run_id"))} }) _, err := waitForTestRun(t, t.Context(), jobRunClientFor(t, server)) @@ -245,9 +247,9 @@ func TestJobRunWaitAbandonedLinksTheRun(t *testing.T) { if gets.Add(1) >= 2 { cancel() } - return jobs.Run{RunId: 123, JobId: 456, State: &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateRunning, - }, RunPageUrl: testRunPageURL} + return jobs.GetRunResponse{RunId: new(int64(123)), JobId: new(int64(456)), State: &jobs.RunState{ + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running, + }, RunPageUrl: new(testRunPageURL)} }) _, err := waitForTestRun(t, ctx, client) @@ -293,9 +295,9 @@ func TestJobRunPrepareStateCopiesResolvedTriggers(t *testing.T) { // The planner diffs RemapState(remote) against PrepareState(config), so a run // that did not end in SUCCESS has to surface as a difference on result_state. func TestJobRunRemapStateCarriesTheOutcome(t *testing.T) { - for _, outcome := range []jobs.RunResultState{ - jobs.RunResultStateSuccess, - jobs.RunResultStateFailed, + for _, outcome := range []jobs.RunResultState_RunResultState{ + jobs.RunResultState_RunResultState_Success, + jobs.RunResultState_RunResultState_Failed, // A run still going, and a SKIPPED one, report no result at all. "", } { @@ -317,12 +319,12 @@ func TestJobRunIgnoresEveryRequestField(t *testing.T) { require.NoError(t, err) ignored := adapters["job_runs"].ResourceConfig().IgnoreRemoteChanges - for field := range reflect.TypeFor[jobs.RunNow]().Fields() { + for field := range reflect.TypeFor[jobs.RunNowRequest]().Fields() { name, _, _ := strings.Cut(field.Tag.Get("json"), ",") if name == "" || name == "-" { continue } - assert.True(t, ignoresRemoteChanges(ignored, name), "jobs.RunNow field %q is not in job_runs ignore_remote_changes", name) + assert.True(t, ignoresRemoteChanges(ignored, name), "jobs.RunNowRequest field %q is not in job_runs ignore_remote_changes", name) } assert.False(t, ignoresRemoteChanges(ignored, "result_state"), "result_state must stay comparable against the remote") @@ -339,13 +341,13 @@ func TestJobRunWaitPollsUntilTerminal(t *testing.T) { var gets atomic.Int32 client := jobRunServer(t, func(req testserver.Request) any { if gets.Add(1) <= 2 { - return jobs.Run{RunId: 123, JobId: 456, State: &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateRunning, + return jobs.GetRunResponse{RunId: new(int64(123)), JobId: new(int64(456)), State: &jobs.RunState{ + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running, }} } - return jobs.Run{RunId: 123, JobId: 456, State: &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateSuccess, + return jobs.GetRunResponse{RunId: new(int64(123)), JobId: new(int64(456)), State: &jobs.RunState{ + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Success, }} }) @@ -354,7 +356,7 @@ func TestJobRunWaitPollsUntilTerminal(t *testing.T) { // SUCCESS is only reachable by polling past the RUNNING reads. require.NotNil(t, remote.State) - assert.Equal(t, jobs.RunResultStateSuccess, remote.State.ResultState) + assert.Equal(t, jobs.RunResultState_RunResultState_Success, remote.State.ResultState) assert.Equal(t, int32(3), gets.Load(), "expected the wait to poll past both RUNNING reads") } @@ -362,13 +364,13 @@ func TestJobRunCreateSendsAFreshIdempotencyToken(t *testing.T) { var tokens []string server := testserver.New(t) server.Handle("POST", "/api/2.2/jobs/run-now", func(req testserver.Request) any { - var body jobs.RunNow + var body jobs.RunNowRequest require.NoError(t, json.Unmarshal(req.Body, &body)) - tokens = append(tokens, body.IdempotencyToken) - return jobs.RunNowResponse{RunId: int64(123 + len(tokens))} + tokens = append(tokens, utils.Deref(body.IdempotencyToken)) + return jobs.RunNowResponse{RunId: new(int64(123 + len(tokens)))} }) r := (&ResourceJobRun{}).New(jobRunClientFor(t, server)) - config := &JobRunState{JobId: 456} + config := &JobRunState{JobId: new(int64(456))} for range 2 { _, _, err := r.DoCreate(t.Context(), config) @@ -379,7 +381,7 @@ func TestJobRunCreateSendsAFreshIdempotencyToken(t *testing.T) { assert.NotEmpty(t, tokens[0]) assert.NotEqual(t, tokens[0], tokens[1]) // Token must not leak into persisted state. - assert.Empty(t, config.IdempotencyToken) + assert.Empty(t, utils.Deref(config.IdempotencyToken)) } func TestJobRunOverrideChangeDescTriggerRemoved(t *testing.T) { @@ -492,7 +494,7 @@ func TestJobRunOverrideChangeDescTriggerRemoved(t *testing.T) { { name: "result_state with unreadable remote", path: "result_state", - old: jobs.RunResultStateSuccess, + old: jobs.RunResultState_RunResultState_Success, new: nil, action: deployplan.Recreate, reason: "", diff --git a/bundle/direct/dresources/job_test.go b/bundle/direct/dresources/job_test.go index ca19620023f..6e03a8e8341 100644 --- a/bundle/direct/dresources/job_test.go +++ b/bundle/direct/dresources/job_test.go @@ -4,27 +4,26 @@ import ( "reflect" "testing" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/structs/structdiff" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -// TestJobRemote verifies that all fields from jobs.Job (except Settings and pagination/internal fields) +// TestJobRemote verifies that all fields from jobs.GetJobResponse (except Settings and pagination fields) // are present in JobRemote. func TestJobRemote(t *testing.T) { - assertFieldsCovered(t, reflect.TypeFor[jobs.Job](), reflect.TypeFor[JobRemote](), map[string]bool{ - "Settings": true, // Embedded as jobs.JobSettings - "ForceSendFields": true, // Internal marshaling field - "HasMore": true, // Pagination field, not relevant for single job read - "NextPageToken": true, // Pagination field, not relevant for single job read + assertFieldsCovered(t, reflect.TypeFor[jobs.GetJobResponse](), reflect.TypeFor[JobRemote](), map[string]bool{ + "Settings": true, // Embedded as jobs.JobSettings + "HasMore": true, // Pagination field, not relevant for single job read + "NextPageToken": true, // Pagination field, not relevant for single job read }) } func webhooks(ids ...string) []jobs.Webhook { result := make([]jobs.Webhook, len(ids)) for i, id := range ids { - result[i] = jobs.Webhook{Id: id} + result[i] = jobs.Webhook{Id: new(id)} } return result } @@ -38,15 +37,15 @@ func TestJobWebhookNotificationsOrderInsensitive(t *testing.T) { WebhookNotifications: &jobs.WebhookNotifications{ OnSuccess: webhooks("a", "b", "c"), }, - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "t1", + TaskKey: new("t1"), WebhookNotifications: &jobs.WebhookNotifications{ OnFailure: webhooks("a", "b"), }, ForEachTask: &jobs.ForEachTask{ - Task: jobs.Task{ - TaskKey: "inner", + Task: &jobs.TaskSettings{ + TaskKey: new("inner"), WebhookNotifications: &jobs.WebhookNotifications{ OnStart: webhooks("x", "y"), }, @@ -60,15 +59,15 @@ func TestJobWebhookNotificationsOrderInsensitive(t *testing.T) { WebhookNotifications: &jobs.WebhookNotifications{ OnSuccess: webhooks("a", "c", "b"), }, - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "t1", + TaskKey: new("t1"), WebhookNotifications: &jobs.WebhookNotifications{ OnFailure: webhooks("b", "a"), }, ForEachTask: &jobs.ForEachTask{ - Task: jobs.Task{ - TaskKey: "inner", + Task: &jobs.TaskSettings{ + TaskKey: new("inner"), WebhookNotifications: &jobs.WebhookNotifications{ OnStart: webhooks("y", "x"), }, diff --git a/bundle/direct/dresources/mcp_service.go b/bundle/direct/dresources/mcp_service.go index 0882190dc5d..3537e4b15b3 100644 --- a/bundle/direct/dresources/mcp_service.go +++ b/bundle/direct/dresources/mcp_service.go @@ -6,9 +6,10 @@ import ( "strings" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/libs/sdkclients" + aigateway "github.com/databricks/cli/libs/sdktypes/aigateway/v1" + "github.com/databricks/cli/libs/utils" + sdkaigateway "github.com/databricks/sdk-go/aigateway/v1" ) // AI Gateway MCP service. @@ -22,10 +23,10 @@ import ( const mcpServiceNamePrefix = "mcp-services/" type ResourceMcpService struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceMcpService) New(client *databricks.WorkspaceClient) *ResourceMcpService { +func (*ResourceMcpService) New(client *sdkclients.Clients) *ResourceMcpService { return &ResourceMcpService{client: client} } @@ -48,41 +49,43 @@ func mcpServiceIdentityFromName(name string) (parent, mcpServiceId string, err e return "schemas/" + parts[0] + "." + parts[1], parts[2], nil } -func responseToMcpServiceConfig(ms *catalog.McpService) (*resources.McpServiceConfig, error) { - parent, id, err := mcpServiceIdentityFromName(ms.Name) +func responseToMcpServiceConfig(resp *sdkaigateway.McpService) (*resources.McpServiceConfig, error) { + ms, err := aigateway.McpServiceFromSDK(resp) + if err != nil { + return nil, err + } + parent, id, err := mcpServiceIdentityFromName(utils.Deref(ms.Name)) if err != nil { return nil, err } return &resources.McpServiceConfig{ - Parent: parent, - McpServiceId: id, - Comment: ms.Comment, - Config: ms.Config, - ForceSendFields: nil, + Parent: parent, + McpServiceId: id, + Comment: utils.Deref(ms.Comment), + Config: ms.Config, }, nil } // mcpServiceBody builds the McpService write payload from the bundle config. // Only comment and config are client-settable; every other field is OUTPUT_ONLY -// (server-derived) and sent as its zero value. -func mcpServiceBody(config *resources.McpServiceConfig) catalog.McpService { - return catalog.McpService{ - Comment: config.Comment, - Config: config.Config, - CreateTime: nil, - CreatedBy: "", - EffectiveOwner: "", - Etag: "", - MetastoreId: "", - Name: "", - UpdateTime: nil, - UpdatedBy: "", - ForceSendFields: nil, +// (server-derived) and not sent. name addresses the resource on update. +func mcpServiceBody(config *resources.McpServiceConfig, name *string) *aigateway.McpService { + return &aigateway.McpService{ + Name: name, + Comment: nonEmpty(config.Comment), + Config: config.Config, + CreateTime: nil, // Not set by DABs + CreatedBy: nil, // Not set by DABs + EffectiveOwner: nil, // Not set by DABs + Etag: nil, // Not set by DABs + MetastoreId: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs + UpdatedBy: nil, // Not set by DABs } } func (r *ResourceMcpService) DoRead(ctx context.Context, id string) (*resources.McpServiceConfig, error) { - ms, err := r.client.AiGateway.GetMcpService(ctx, catalog.GetMcpServiceRequest{Name: mcpServiceNamePrefix + id}) + ms, err := r.client.AiGateway.GetMcpService(ctx, sdkaigateway.GetMcpServiceRequest{Name: new(mcpServiceNamePrefix + id)}) if err != nil { return nil, err } @@ -90,19 +93,23 @@ func (r *ResourceMcpService) DoRead(ctx context.Context, id string) (*resources. } func (r *ResourceMcpService) DoCreate(ctx context.Context, config *resources.McpServiceConfig) (string, *resources.McpServiceConfig, error) { - resp, err := r.client.AiGateway.CreateMcpService(ctx, catalog.CreateMcpServiceRequest{ - Parent: config.Parent, - McpServiceId: config.McpServiceId, - McpService: mcpServiceBody(config), + request, err := aigateway.CreateMcpServiceRequestToSDK(&aigateway.CreateMcpServiceRequest{ + Parent: new(config.Parent), + McpServiceId: new(config.McpServiceId), + McpService: mcpServiceBody(config, nil), }) if err != nil { return "", nil, err } + resp, err := r.client.AiGateway.CreateMcpService(ctx, *request) + if err != nil { + return "", nil, err + } state, err := responseToMcpServiceConfig(resp) if err != nil { return "", nil, err } - return strings.TrimPrefix(resp.Name, mcpServiceNamePrefix), state, nil + return strings.TrimPrefix(utils.Deref(resp.Name), mcpServiceNamePrefix), state, nil } // DoUpdate sends update_mask "*" on every update. name, parent and @@ -115,23 +122,24 @@ func (r *ResourceMcpService) DoCreate(ctx context.Context, config *resources.Mcp // which also does not send etag. We deliberately do not do optimistic // concurrency on these resources. func (r *ResourceMcpService) DoUpdate(ctx context.Context, id string, config *resources.McpServiceConfig, _ *PlanEntry) (*resources.McpServiceConfig, error) { - resp, err := r.client.AiGateway.UpdateMcpService(ctx, catalog.UpdateMcpServiceRequest{ - Etag: "", - McpService: mcpServiceBody(config), - Name: mcpServiceNamePrefix + id, - UpdateMask: fieldmask.FieldMask{Paths: []string{"*"}}, - ForceSendFields: nil, + request, err := aigateway.UpdateMcpServiceRequestToSDK(&aigateway.UpdateMcpServiceRequest{ + McpService: mcpServiceBody(config, new(mcpServiceNamePrefix+id)), + UpdateMask: new("*"), + Etag: nil, // Not set by DABs }) if err != nil { return nil, err } + resp, err := r.client.AiGateway.UpdateMcpService(ctx, *request) + if err != nil { + return nil, err + } return responseToMcpServiceConfig(resp) } func (r *ResourceMcpService) DoDelete(ctx context.Context, id string, _ *resources.McpServiceConfig) error { - return r.client.AiGateway.DeleteMcpService(ctx, catalog.DeleteMcpServiceRequest{ - Etag: "", - Name: mcpServiceNamePrefix + id, - ForceSendFields: nil, + return r.client.AiGateway.DeleteMcpService(ctx, sdkaigateway.DeleteMcpServiceRequest{ + Name: new(mcpServiceNamePrefix + id), + Etag: nil, // Not set by DABs }) } diff --git a/bundle/direct/dresources/model.go b/bundle/direct/dresources/model.go index 83a4f8832aa..71e13aa8fc7 100644 --- a/bundle/direct/dresources/model.go +++ b/bundle/direct/dresources/model.go @@ -5,14 +5,14 @@ import ( "errors" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" + modelregistry "github.com/databricks/cli/libs/sdktypes/modelregistry/v1" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/ml" + sdkmodelregistry "github.com/databricks/sdk-go/modelregistry/v1" ) type ResourceMlflowModel struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } // MlflowModelRemote wraps the API response with the numeric model ID. @@ -20,52 +20,52 @@ type ResourceMlflowModel struct { // the permissions API requires the numeric ID. This wrapper exposes the numeric // ID as model_id, analogous to ModelServingEndpointRemote.EndpointId for serving endpoints. type MlflowModelRemote struct { - ml.ModelDatabricks + modelregistry.RegisteredModelDatabricks ModelId string `json:"model_id"` } -// Custom marshalers needed because embedded ml.ModelDatabricks has its own -// MarshalJSON which would otherwise take over and ignore model_id. -func (s *MlflowModelRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s MlflowModelRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (*ResourceMlflowModel) New(client *databricks.WorkspaceClient) *ResourceMlflowModel { +func (*ResourceMlflowModel) New(client *sdkclients.Clients) *ResourceMlflowModel { return &ResourceMlflowModel{client: client} } -func (*ResourceMlflowModel) PrepareState(input *resources.MlflowModel) *ml.CreateModelRequest { - return &input.CreateModelRequest +func (*ResourceMlflowModel) PrepareState(input *resources.MlflowModel) *modelregistry.CreateRegisteredModelRequest { + return &input.CreateRegisteredModelRequest } -func (*ResourceMlflowModel) RemapState(output *MlflowModelRemote) *ml.CreateModelRequest { - return &ml.CreateModelRequest{ - Name: output.Name, - Tags: output.Tags, - Description: output.Description, - ForceSendFields: utils.FilterFields[ml.CreateModelRequest](output.ForceSendFields), +func (*ResourceMlflowModel) RemapState(output *MlflowModelRemote) *modelregistry.CreateRegisteredModelRequest { + return &modelregistry.CreateRegisteredModelRequest{ + Name: output.Name, + Tags: output.Tags, + Description: output.Description, } } func (r *ResourceMlflowModel) DoRead(ctx context.Context, id string) (*MlflowModelRemote, error) { - response, err := r.client.ModelRegistry.GetModel(ctx, ml.GetModelRequest{ - Name: id, + resp, err := r.client.ModelRegistry.GetRegisteredModelDatabricks(ctx, sdkmodelregistry.GetRegisteredModelDatabricksRequest{ + Name: new(id), }) if err != nil { return nil, err } + response, err := modelregistry.GetRegisteredModelDatabricksResponseFromSDK(resp) + if err != nil { + return nil, err + } + if response.RegisteredModelDatabricks == nil { + return nil, errors.New("GetModel returned no registered_model_databricks") + } return &MlflowModelRemote{ - ModelDatabricks: *response.RegisteredModelDatabricks, - ModelId: response.RegisteredModelDatabricks.Id, + RegisteredModelDatabricks: *response.RegisteredModelDatabricks, + ModelId: utils.Deref(response.RegisteredModelDatabricks.Id), }, nil } -func (r *ResourceMlflowModel) DoCreate(ctx context.Context, config *ml.CreateModelRequest) (string, *MlflowModelRemote, error) { - response, err := r.client.ModelRegistry.CreateModel(ctx, *config) +func (r *ResourceMlflowModel) DoCreate(ctx context.Context, config *modelregistry.CreateRegisteredModelRequest) (string, *MlflowModelRemote, error) { + request, err := modelregistry.CreateRegisteredModelRequestToSDK(config) + if err != nil { + return "", nil, err + } + response, err := r.client.ModelRegistry.CreateRegisteredModel(ctx, *request) if err != nil { return "", nil, err } @@ -74,17 +74,18 @@ func (r *ResourceMlflowModel) DoCreate(ctx context.Context, config *ml.CreateMod } // Return nil for refresh output; the engine will call DoRead to populate the full state // including the numeric model ID needed for permissions. - return response.RegisteredModel.Name, nil, nil + return utils.Deref(response.RegisteredModel.Name), nil, nil } -func (r *ResourceMlflowModel) DoUpdate(ctx context.Context, id string, config *ml.CreateModelRequest, entry *PlanEntry) (*MlflowModelRemote, error) { - updateRequest := ml.UpdateModelRequest{ - Name: id, - Description: config.Description, - ForceSendFields: utils.FilterFields[ml.UpdateModelRequest](config.ForceSendFields), +func (r *ResourceMlflowModel) DoUpdate(ctx context.Context, id string, config *modelregistry.CreateRegisteredModelRequest, entry *PlanEntry) (*MlflowModelRemote, error) { + resp, err := r.client.ModelRegistry.UpdateRegisteredModel(ctx, sdkmodelregistry.UpdateRegisteredModelRequest{ + Name: new(id), + Description: config.Description, + }) + if err != nil { + return nil, err } - - response, err := r.client.ModelRegistry.UpdateModel(ctx, updateRequest) + response, err := modelregistry.UpdateRegisteredModelResponseFromSDK(resp) if err != nil { return nil, err } @@ -98,27 +99,28 @@ func (r *ResourceMlflowModel) DoUpdate(ctx context.Context, id string, config *m modelId = old.ModelId } - // Id and PermissionLevel are left empty because ml.Model (the UpdateModel + // Id and PermissionLevel are left empty because RegisteredModel (the update // response) does not carry them; every other field is taken from the // response so references against the post-update remote state resolve to // real values until the next plan's DoRead. + model := response.RegisteredModel return &MlflowModelRemote{ - CreationTimestamp: response.RegisteredModel.CreationTimestamp, - Description: response.RegisteredModel.Description, - Id: "", - LastUpdatedTimestamp: response.RegisteredModel.LastUpdatedTimestamp, - LatestVersions: response.RegisteredModel.LatestVersions, - Name: response.RegisteredModel.Name, - PermissionLevel: "", - Tags: response.RegisteredModel.Tags, - UserId: response.RegisteredModel.UserId, - ForceSendFields: utils.FilterFields[ml.ModelDatabricks](response.RegisteredModel.ForceSendFields, "Id", "PermissionLevel"), + CreationTimestamp: model.CreationTimestamp, + Description: model.Description, + LastUpdatedTimestamp: model.LastUpdatedTimestamp, + LatestVersions: model.LatestVersions, + Name: model.Name, + Tags: model.Tags, + UserId: model.UserId, ModelId: modelId, + Id: nil, // Not in the update response + PermissionLevel: "", // Not in the update response }, nil } -func (r *ResourceMlflowModel) DoDelete(ctx context.Context, id string, _ *ml.CreateModelRequest) error { - return r.client.ModelRegistry.DeleteModel(ctx, ml.DeleteModelRequest{ - Name: id, +func (r *ResourceMlflowModel) DoDelete(ctx context.Context, id string, _ *modelregistry.CreateRegisteredModelRequest) error { + _, err := r.client.ModelRegistry.DeleteRegisteredModel(ctx, sdkmodelregistry.DeleteRegisteredModelRequest{ + Name: new(id), }) + return err } diff --git a/bundle/direct/dresources/model_provider_service.go b/bundle/direct/dresources/model_provider_service.go index ebf02e9c3f6..1a14d92075b 100644 --- a/bundle/direct/dresources/model_provider_service.go +++ b/bundle/direct/dresources/model_provider_service.go @@ -6,9 +6,10 @@ import ( "strings" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/libs/sdkclients" + aigateway "github.com/databricks/cli/libs/sdktypes/aigateway/v1" + "github.com/databricks/cli/libs/utils" + sdkaigateway "github.com/databricks/sdk-go/aigateway/v1" ) // AI Gateway model provider service. @@ -22,10 +23,10 @@ import ( const modelProviderServiceNamePrefix = "model-provider-services/" type ResourceModelProviderService struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceModelProviderService) New(client *databricks.WorkspaceClient) *ResourceModelProviderService { +func (*ResourceModelProviderService) New(client *sdkclients.Clients) *ResourceModelProviderService { return &ResourceModelProviderService{client: client} } @@ -48,41 +49,43 @@ func modelProviderServiceIdentityFromName(name string) (parent, modelProviderSer return "schemas/" + parts[0] + "." + parts[1], parts[2], nil } -func responseToModelProviderServiceConfig(ms *catalog.ModelProviderService) (*resources.ModelProviderServiceConfig, error) { - parent, id, err := modelProviderServiceIdentityFromName(ms.Name) +func responseToModelProviderServiceConfig(resp *sdkaigateway.ModelProviderService) (*resources.ModelProviderServiceConfig, error) { + ms, err := aigateway.ModelProviderServiceFromSDK(resp) + if err != nil { + return nil, err + } + parent, id, err := modelProviderServiceIdentityFromName(utils.Deref(ms.Name)) if err != nil { return nil, err } return &resources.ModelProviderServiceConfig{ Parent: parent, ModelProviderServiceId: id, - Comment: ms.Comment, + Comment: utils.Deref(ms.Comment), Config: ms.Config, - ForceSendFields: nil, }, nil } // modelProviderServiceBody builds the ModelProviderService write payload from the // bundle config. Only comment and config are client-settable; every other field -// is OUTPUT_ONLY (server-derived) and sent as its zero value. -func modelProviderServiceBody(config *resources.ModelProviderServiceConfig) catalog.ModelProviderService { - return catalog.ModelProviderService{ - Comment: config.Comment, - Config: config.Config, - CreateTime: nil, - CreatedBy: "", - EffectiveOwner: "", - Etag: "", - MetastoreId: "", - Name: "", - UpdateTime: nil, - UpdatedBy: "", - ForceSendFields: nil, +// is OUTPUT_ONLY (server-derived) and not sent. name addresses the resource on update. +func modelProviderServiceBody(config *resources.ModelProviderServiceConfig, name *string) *aigateway.ModelProviderService { + return &aigateway.ModelProviderService{ + Name: name, + Comment: nonEmpty(config.Comment), + Config: config.Config, + CreateTime: nil, // Not set by DABs + CreatedBy: nil, // Not set by DABs + EffectiveOwner: nil, // Not set by DABs + Etag: nil, // Not set by DABs + MetastoreId: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs + UpdatedBy: nil, // Not set by DABs } } func (r *ResourceModelProviderService) DoRead(ctx context.Context, id string) (*resources.ModelProviderServiceConfig, error) { - ms, err := r.client.AiGateway.GetModelProviderService(ctx, catalog.GetModelProviderServiceRequest{Name: modelProviderServiceNamePrefix + id}) + ms, err := r.client.AiGateway.GetModelProviderService(ctx, sdkaigateway.GetModelProviderServiceRequest{Name: new(modelProviderServiceNamePrefix + id)}) if err != nil { return nil, err } @@ -90,19 +93,23 @@ func (r *ResourceModelProviderService) DoRead(ctx context.Context, id string) (* } func (r *ResourceModelProviderService) DoCreate(ctx context.Context, config *resources.ModelProviderServiceConfig) (string, *resources.ModelProviderServiceConfig, error) { - resp, err := r.client.AiGateway.CreateModelProviderService(ctx, catalog.CreateModelProviderServiceRequest{ - Parent: config.Parent, - ModelProviderServiceId: config.ModelProviderServiceId, - ModelProviderService: modelProviderServiceBody(config), + request, err := aigateway.CreateModelProviderServiceRequestToSDK(&aigateway.CreateModelProviderServiceRequest{ + Parent: new(config.Parent), + ModelProviderServiceId: new(config.ModelProviderServiceId), + ModelProviderService: modelProviderServiceBody(config, nil), }) if err != nil { return "", nil, err } + resp, err := r.client.AiGateway.CreateModelProviderService(ctx, *request) + if err != nil { + return "", nil, err + } state, err := responseToModelProviderServiceConfig(resp) if err != nil { return "", nil, err } - return strings.TrimPrefix(resp.Name, modelProviderServiceNamePrefix), state, nil + return strings.TrimPrefix(utils.Deref(resp.Name), modelProviderServiceNamePrefix), state, nil } // DoUpdate sends update_mask "*" on every update. name, parent and @@ -116,23 +123,24 @@ func (r *ResourceModelProviderService) DoCreate(ctx context.Context, config *res // which also does not send etag. We deliberately do not do optimistic // concurrency on these resources. func (r *ResourceModelProviderService) DoUpdate(ctx context.Context, id string, config *resources.ModelProviderServiceConfig, _ *PlanEntry) (*resources.ModelProviderServiceConfig, error) { - resp, err := r.client.AiGateway.UpdateModelProviderService(ctx, catalog.UpdateModelProviderServiceRequest{ - Etag: "", - Name: modelProviderServiceNamePrefix + id, - ModelProviderService: modelProviderServiceBody(config), - UpdateMask: fieldmask.FieldMask{Paths: []string{"*"}}, - ForceSendFields: nil, + request, err := aigateway.UpdateModelProviderServiceRequestToSDK(&aigateway.UpdateModelProviderServiceRequest{ + ModelProviderService: modelProviderServiceBody(config, new(modelProviderServiceNamePrefix+id)), + UpdateMask: new("*"), + Etag: nil, // Not set by DABs }) if err != nil { return nil, err } + resp, err := r.client.AiGateway.UpdateModelProviderService(ctx, *request) + if err != nil { + return nil, err + } return responseToModelProviderServiceConfig(resp) } func (r *ResourceModelProviderService) DoDelete(ctx context.Context, id string, _ *resources.ModelProviderServiceConfig) error { - return r.client.AiGateway.DeleteModelProviderService(ctx, catalog.DeleteModelProviderServiceRequest{ - Etag: "", - Name: modelProviderServiceNamePrefix + id, - ForceSendFields: nil, + return r.client.AiGateway.DeleteModelProviderService(ctx, sdkaigateway.DeleteModelProviderServiceRequest{ + Name: new(modelProviderServiceNamePrefix + id), + Etag: nil, // Not set by DABs }) } diff --git a/bundle/direct/dresources/model_service.go b/bundle/direct/dresources/model_service.go index 7eb3860d191..f7a08695bc2 100644 --- a/bundle/direct/dresources/model_service.go +++ b/bundle/direct/dresources/model_service.go @@ -6,9 +6,10 @@ import ( "strings" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/libs/sdkclients" + aigateway "github.com/databricks/cli/libs/sdktypes/aigateway/v1" + "github.com/databricks/cli/libs/utils" + sdkaigateway "github.com/databricks/sdk-go/aigateway/v1" ) // AI Gateway model service. @@ -27,10 +28,10 @@ import ( const modelServiceNamePrefix = "model-services/" type ResourceModelService struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceModelService) New(client *databricks.WorkspaceClient) *ResourceModelService { +func (*ResourceModelService) New(client *sdkclients.Clients) *ResourceModelService { return &ResourceModelService{client: client} } @@ -53,42 +54,44 @@ func modelServiceIdentityFromName(name string) (parent, modelServiceId string, e return "schemas/" + parts[0] + "." + parts[1], parts[2], nil } -func responseToModelServiceConfig(ms *catalog.ModelService) (*resources.ModelServiceConfig, error) { - parent, id, err := modelServiceIdentityFromName(ms.Name) +func responseToModelServiceConfig(resp *sdkaigateway.ModelService) (*resources.ModelServiceConfig, error) { + ms, err := aigateway.ModelServiceFromSDK(resp) + if err != nil { + return nil, err + } + parent, id, err := modelServiceIdentityFromName(utils.Deref(ms.Name)) if err != nil { return nil, err } return &resources.ModelServiceConfig{ - Parent: parent, - ModelServiceId: id, - Comment: ms.Comment, - Config: ms.Config, - ForceSendFields: nil, + Parent: parent, + ModelServiceId: id, + Comment: utils.Deref(ms.Comment), + Config: ms.Config, }, nil } // modelServiceBody builds the ModelService write payload from the bundle config. // Only comment and config are client-settable; every other field is OUTPUT_ONLY -// (server-derived) and sent as its zero value. -func modelServiceBody(config *resources.ModelServiceConfig) catalog.ModelService { - return catalog.ModelService{ - Comment: config.Comment, +// (server-derived) and not sent. name addresses the resource on update. +func modelServiceBody(config *resources.ModelServiceConfig, name *string) *aigateway.ModelService { + return &aigateway.ModelService{ + Name: name, + Comment: nonEmpty(config.Comment), Config: config.Config, - CreateTime: nil, - CreatedBy: "", - EffectiveOwner: "", - Etag: "", - MetastoreId: "", - Name: "", - SupportedApiTypes: nil, - UpdateTime: nil, - UpdatedBy: "", - ForceSendFields: nil, + CreateTime: nil, // Not set by DABs + CreatedBy: nil, // Not set by DABs + EffectiveOwner: nil, // Not set by DABs + Etag: nil, // Not set by DABs + MetastoreId: nil, // Not set by DABs + SupportedApiTypes: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs + UpdatedBy: nil, // Not set by DABs } } func (r *ResourceModelService) DoRead(ctx context.Context, id string) (*resources.ModelServiceConfig, error) { - ms, err := r.client.AiGateway.GetModelService(ctx, catalog.GetModelServiceRequest{Name: modelServiceNamePrefix + id}) + ms, err := r.client.AiGateway.GetModelService(ctx, sdkaigateway.GetModelServiceRequest{Name: new(modelServiceNamePrefix + id)}) if err != nil { return nil, err } @@ -96,19 +99,23 @@ func (r *ResourceModelService) DoRead(ctx context.Context, id string) (*resource } func (r *ResourceModelService) DoCreate(ctx context.Context, config *resources.ModelServiceConfig) (string, *resources.ModelServiceConfig, error) { - resp, err := r.client.AiGateway.CreateModelService(ctx, catalog.CreateModelServiceRequest{ - Parent: config.Parent, - ModelServiceId: config.ModelServiceId, - ModelService: modelServiceBody(config), + request, err := aigateway.CreateModelServiceRequestToSDK(&aigateway.CreateModelServiceRequest{ + Parent: new(config.Parent), + ModelServiceId: new(config.ModelServiceId), + ModelService: modelServiceBody(config, nil), }) if err != nil { return "", nil, err } + resp, err := r.client.AiGateway.CreateModelService(ctx, *request) + if err != nil { + return "", nil, err + } state, err := responseToModelServiceConfig(resp) if err != nil { return "", nil, err } - return strings.TrimPrefix(resp.Name, modelServiceNamePrefix), state, nil + return strings.TrimPrefix(utils.Deref(resp.Name), modelServiceNamePrefix), state, nil } // DoUpdate sends update_mask "*" on every update. name, parent and @@ -121,23 +128,24 @@ func (r *ResourceModelService) DoCreate(ctx context.Context, config *resources.M // which also does not send etag. We deliberately do not do optimistic // concurrency on these resources. func (r *ResourceModelService) DoUpdate(ctx context.Context, id string, config *resources.ModelServiceConfig, _ *PlanEntry) (*resources.ModelServiceConfig, error) { - resp, err := r.client.AiGateway.UpdateModelService(ctx, catalog.UpdateModelServiceRequest{ - Etag: "", - ModelService: modelServiceBody(config), - Name: modelServiceNamePrefix + id, - UpdateMask: fieldmask.FieldMask{Paths: []string{"*"}}, - ForceSendFields: nil, + request, err := aigateway.UpdateModelServiceRequestToSDK(&aigateway.UpdateModelServiceRequest{ + ModelService: modelServiceBody(config, new(modelServiceNamePrefix+id)), + UpdateMask: new("*"), + Etag: nil, // Not set by DABs }) if err != nil { return nil, err } + resp, err := r.client.AiGateway.UpdateModelService(ctx, *request) + if err != nil { + return nil, err + } return responseToModelServiceConfig(resp) } func (r *ResourceModelService) DoDelete(ctx context.Context, id string, _ *resources.ModelServiceConfig) error { - return r.client.AiGateway.DeleteModelService(ctx, catalog.DeleteModelServiceRequest{ - Etag: "", - Name: modelServiceNamePrefix + id, - ForceSendFields: nil, + return r.client.AiGateway.DeleteModelService(ctx, sdkaigateway.DeleteModelServiceRequest{ + Name: new(modelServiceNamePrefix + id), + Etag: nil, // Not set by DABs }) } diff --git a/bundle/direct/dresources/model_serving_endpoint.go b/bundle/direct/dresources/model_serving_endpoint.go index f9c0a2314ac..f657c52bac1 100644 --- a/bundle/direct/dresources/model_serving_endpoint.go +++ b/bundle/direct/dresources/model_serving_endpoint.go @@ -6,11 +6,12 @@ import ( "time" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/bundle/direct/internal/retries" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/modelserving/v1" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/serving" + sdkmodelserving "github.com/databricks/sdk-go/modelserving/v1" ) // Precalculated paths for HasChange checks @@ -23,41 +24,48 @@ var ( ) type ResourceModelServingEndpoint struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceModelServingEndpoint) New(client *databricks.WorkspaceClient) *ResourceModelServingEndpoint { +func (*ResourceModelServingEndpoint) New(client *sdkclients.Clients) *ResourceModelServingEndpoint { return &ResourceModelServingEndpoint{ client: client, } } -func (*ResourceModelServingEndpoint) PrepareState(input *resources.ModelServingEndpoint) *serving.CreateServingEndpoint { - return &input.CreateServingEndpoint +func (*ResourceModelServingEndpoint) PrepareState(input *resources.ModelServingEndpoint) *modelserving.CreateInferenceEndpointRequest { + return &input.CreateInferenceEndpointRequest } // AutoCaptureConfig is the legacy inference-table API; the recommended replacement // is AI Gateway inference tables. Bundles still expose it, so the conversion has to // keep working until users have migrated. // -//nolint:staticcheck // SA1019: deprecated AutoCaptureConfig{Input,Output} kept for bundle config compatibility -func autoCaptureConfigOutputToInput(output *serving.AutoCaptureConfigOutput) *serving.AutoCaptureConfigInput { +//nolint:staticcheck +func autoCaptureConfigOutputToInput(output *modelserving.AutoCaptureConfig) *modelserving.AutoCaptureConfig { if output == nil { return nil } - return &serving.AutoCaptureConfigInput{ + // state is output-only. + return &modelserving.AutoCaptureConfig{ CatalogName: output.CatalogName, SchemaName: output.SchemaName, TableNamePrefix: output.TableNamePrefix, Enabled: output.Enabled, - ForceSendFields: utils.FilterFields[serving.AutoCaptureConfigInput](output.ForceSendFields), + State: nil, // Not set by DABs } } -func servedEntitiesOutputToInput(output []serving.ServedEntityOutput) []serving.ServedEntityInput { - entities := make([]serving.ServedEntityInput, len(output)) +// servedEntitiesOutputToInput keeps the fields a user can set on a served entity; +// state, creator, creation_timestamp and foundation_model are output-only, and +// model_name/model_version belong to the legacy served_models field. +func servedEntitiesOutputToInput(output []modelserving.ServedModel) []modelserving.ServedModel { + if output == nil { + return nil + } + entities := make([]modelserving.ServedModel, len(output)) for i, entity := range output { - entities[i] = serving.ServedEntityInput{ + entities[i] = modelserving.ServedModel{ EntityName: entity.EntityName, EntityVersion: entity.EntityVersion, EnvironmentVars: entity.EnvironmentVars, @@ -71,30 +79,33 @@ func servedEntitiesOutputToInput(output []serving.ServedEntityOutput) []serving. ProvisionedModelUnits: entity.ProvisionedModelUnits, ScaleToZeroEnabled: entity.ScaleToZeroEnabled, WorkloadSize: entity.WorkloadSize, - WorkloadType: entity.WorkloadType, BurstScalingEnabled: entity.BurstScalingEnabled, - ForceSendFields: utils.FilterFields[serving.ServedEntityInput](entity.ForceSendFields), + CreationTimestamp: nil, // Not set by DABs + Creator: nil, // Not set by DABs + FoundationModel: nil, // Not set by DABs + ModelName: nil, // Not set by DABs + ModelVersion: nil, // Not set by DABs + State: nil, // Not set by DABs } } return entities } -func configOutputToInput(output *serving.EndpointCoreConfigOutput) *serving.EndpointCoreConfigInput { +func configOutputToInput(output *modelserving.EndpointCoreConfigOutput) *modelserving.EndpointCoreConfig { if output == nil { return nil } - return &serving.EndpointCoreConfigInput{ + return &modelserving.EndpointCoreConfig{ AutoCaptureConfig: autoCaptureConfigOutputToInput(output.AutoCaptureConfig), ServedEntities: servedEntitiesOutputToInput(output.ServedEntities), ServedModels: nil, TrafficConfig: output.TrafficConfig, - Name: "", } } -func (*ResourceModelServingEndpoint) RemapState(state *ModelServingEndpointRemote) *serving.CreateServingEndpoint { - return &serving.CreateServingEndpoint{ +func (*ResourceModelServingEndpoint) RemapState(state *ModelServingEndpointRemote) *modelserving.CreateInferenceEndpointRequest { + return &modelserving.CreateInferenceEndpointRequest{ AiGateway: state.AiGateway, BudgetPolicyId: state.BudgetPolicyId, Config: state.Config, @@ -104,7 +115,6 @@ func (*ResourceModelServingEndpoint) RemapState(state *ModelServingEndpointRemot RouteOptimized: state.RouteOptimized, Tags: state.Tags, TelemetryConfig: state.TelemetryConfig, - ForceSendFields: utils.FilterFields[serving.CreateServingEndpoint](state.ForceSendFields), // Rate limits are a deprecated field that are not returned by the API on GET calls. Thus we map them to nil. // TODO(shreyas): Add a warning when users try setting top level rate limits. @@ -113,40 +123,30 @@ func (*ResourceModelServingEndpoint) RemapState(state *ModelServingEndpointRemot } type ModelServingEndpointRemote struct { - EndpointDetails *serving.ServingEndpointDetailed `json:"endpoint_details"` - EndpointId string `json:"endpoint_id"` + EndpointDetails *modelserving.InferenceEndpointDetailed `json:"endpoint_details"` + EndpointId string `json:"endpoint_id"` // Fields mapped from EndpointDetails in DoRead so that RemapState is a direct copy // and these fields participate in normal drift detection. - AiGateway *serving.AiGatewayConfig `json:"ai_gateway,omitempty"` - BudgetPolicyId string `json:"budget_policy_id,omitempty"` - Config *serving.EndpointCoreConfigInput `json:"config,omitempty"` - Description string `json:"description,omitempty"` - EmailNotifications *serving.EmailNotifications `json:"email_notifications,omitempty"` - Name string `json:"name,omitempty"` - RouteOptimized bool `json:"route_optimized,omitempty"` - Tags []serving.EndpointTag `json:"tags,omitempty"` - TelemetryConfig *serving.TelemetryConfig `json:"telemetry_config,omitempty"` - - // ForceSendFields surfaces EndpointDetails.ForceSendFields at the root so RemapState is a - // plain field copy rather than reaching into the nested EndpointDetails struct. - ForceSendFields []string `json:"-"` + AiGateway *modelserving.AiGatewayConfig `json:"ai_gateway,omitempty"` + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + Config *modelserving.EndpointCoreConfig `json:"config,omitempty"` + Description *string `json:"description,omitempty"` + EmailNotifications *modelserving.EmailNotifications `json:"email_notifications,omitempty"` + Name *string `json:"name,omitempty"` + RouteOptimized *bool `json:"route_optimized,omitempty"` + Tags []modelserving.EndpointTag `json:"tags,omitempty"` + TelemetryConfig *modelserving.TelemetryConfig `json:"telemetry_config,omitempty"` } -// Custom marshalers so the SDK's ForceSendFields convention is honored on the wrapper and its -// extra fields survive a JSON state round-trip (mirrors VectorSearchEndpointRemote). -func (s *ModelServingEndpointRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s ModelServingEndpointRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func newModelServingEndpointRemote(details *serving.ServingEndpointDetailed) *ModelServingEndpointRemote { +func newModelServingEndpointRemote(resp *sdkmodelserving.InferenceEndpointDetailed) (*ModelServingEndpointRemote, error) { + details, err := modelserving.InferenceEndpointDetailedFromSDK(resp) + if err != nil { + return nil, err + } return &ModelServingEndpointRemote{ EndpointDetails: details, - EndpointId: details.Id, + EndpointId: utils.Deref(details.Id), AiGateway: details.AiGateway, BudgetPolicyId: details.BudgetPolicyId, Config: configOutputToInput(details.Config), @@ -156,107 +156,133 @@ func newModelServingEndpointRemote(details *serving.ServingEndpointDetailed) *Mo RouteOptimized: details.RouteOptimized, Tags: details.Tags, TelemetryConfig: details.TelemetryConfig, - ForceSendFields: utils.FilterFields[ModelServingEndpointRemote](details.ForceSendFields), - } + }, nil +} + +func (r *ResourceModelServingEndpoint) getEndpoint(ctx context.Context, name string) (*sdkmodelserving.InferenceEndpointDetailed, error) { + return r.client.ServingEndpoints.GetInferenceEndpoint(ctx, sdkmodelserving.GetInferenceEndpointRequest{Name: new(name)}) } func (r *ResourceModelServingEndpoint) DoRead(ctx context.Context, id string) (*ModelServingEndpointRemote, error) { - endpoint, err := r.client.ServingEndpoints.GetByName(ctx, id) + endpoint, err := r.getEndpoint(ctx, id) if err != nil { return nil, err } - return newModelServingEndpointRemote(endpoint), nil + return newModelServingEndpointRemote(endpoint) } -func (r *ResourceModelServingEndpoint) DoCreate(ctx context.Context, config *serving.CreateServingEndpoint) (string, *ModelServingEndpointRemote, error) { - waiter, err := r.client.ServingEndpoints.Create(ctx, *config) +func (r *ResourceModelServingEndpoint) DoCreate(ctx context.Context, config *modelserving.CreateInferenceEndpointRequest) (string, *ModelServingEndpointRemote, error) { + request, err := modelserving.CreateInferenceEndpointRequestToSDK(config) + if err != nil { + return "", nil, err + } + waiter, err := r.client.ServingEndpoints.CreateInferenceEndpoint(ctx, *request) if err != nil { return "", nil, err } - return waiter.Response.Name, nil, nil + return waiter.GetName(), nil, nil } // waitForEndpointReady waits for the serving endpoint to be ready (not updating) func (r *ResourceModelServingEndpoint) waitForEndpointReady(ctx context.Context, name string) (*ModelServingEndpointRemote, error) { - details, err := r.client.ServingEndpoints.WaitGetServingEndpointNotUpdating(ctx, name, 35*time.Minute, nil) + details, err := retries.Poll(ctx, 35*time.Minute, func() (*sdkmodelserving.InferenceEndpointDetailed, *retries.Err) { + details, err := r.getEndpoint(ctx, name) + if err != nil { + return nil, retries.Halt(err) + } + var status sdkmodelserving.InferenceEndpointState_ConfigUpdateState + if details.State != nil { + status = details.State.ConfigUpdate + } + statusMessage := fmt.Sprintf("current status: %s", status) + switch status { + case sdkmodelserving.InferenceEndpointState_ConfigUpdateState_NotUpdating: + return details, nil + case sdkmodelserving.InferenceEndpointState_ConfigUpdateState_UpdateFailed, sdkmodelserving.InferenceEndpointState_ConfigUpdateState_UpdateCanceled: + return nil, retries.Halt(fmt.Errorf("failed to reach %s, got %s: %s", + sdkmodelserving.InferenceEndpointState_ConfigUpdateState_NotUpdating, status, statusMessage)) + default: + return nil, retries.Continues(statusMessage) + } + }) if err != nil { return nil, err } - return newModelServingEndpointRemote(details), nil + return newModelServingEndpointRemote(details) } -func (r *ResourceModelServingEndpoint) WaitAfterCreate(ctx context.Context, id string, config *serving.CreateServingEndpoint) (*ModelServingEndpointRemote, error) { - return r.waitForEndpointReady(ctx, config.Name) +func (r *ResourceModelServingEndpoint) WaitAfterCreate(ctx context.Context, id string, config *modelserving.CreateInferenceEndpointRequest) (*ModelServingEndpointRemote, error) { + return r.waitForEndpointReady(ctx, utils.Deref(config.Name)) } -func (r *ResourceModelServingEndpoint) WaitAfterUpdate(ctx context.Context, id string, config *serving.CreateServingEndpoint) (*ModelServingEndpointRemote, error) { - return r.waitForEndpointReady(ctx, config.Name) +func (r *ResourceModelServingEndpoint) WaitAfterUpdate(ctx context.Context, id string, config *modelserving.CreateInferenceEndpointRequest) (*ModelServingEndpointRemote, error) { + return r.waitForEndpointReady(ctx, utils.Deref(config.Name)) } -func (r *ResourceModelServingEndpoint) updateAiGateway(ctx context.Context, id string, aiGateway *serving.AiGatewayConfig) error { - if aiGateway == nil { - req := serving.PutAiGatewayRequest{ - Name: id, - FallbackConfig: nil, - Guardrails: nil, - InferenceTableConfig: nil, - RateLimits: nil, - UsageTrackingConfig: nil, - } - _, err := r.client.ServingEndpoints.PutAiGateway(ctx, req) +func (r *ResourceModelServingEndpoint) updateAiGateway(ctx context.Context, id string, aiGateway *modelserving.AiGatewayConfig) error { + req := modelserving.PutInferenceEndpointAiGatewayRequest{ + Name: new(id), + FallbackConfig: nil, // Not set by DABs + Guardrails: nil, // Not set by DABs + InferenceTableConfig: nil, // Not set by DABs + RateLimits: nil, // Not set by DABs + UsageTrackingConfig: nil, // Not set by DABs + } + if aiGateway != nil { + req.FallbackConfig = aiGateway.FallbackConfig + req.Guardrails = aiGateway.Guardrails + req.InferenceTableConfig = aiGateway.InferenceTableConfig + req.RateLimits = aiGateway.RateLimits + req.UsageTrackingConfig = aiGateway.UsageTrackingConfig + } + request, err := modelserving.PutInferenceEndpointAiGatewayRequestToSDK(&req) + if err != nil { return err } - - req := serving.PutAiGatewayRequest{ - Name: id, - FallbackConfig: aiGateway.FallbackConfig, - Guardrails: aiGateway.Guardrails, - InferenceTableConfig: aiGateway.InferenceTableConfig, - RateLimits: aiGateway.RateLimits, - UsageTrackingConfig: aiGateway.UsageTrackingConfig, - } - _, err := r.client.ServingEndpoints.PutAiGateway(ctx, req) - if err != nil { + _, err = r.client.ServingEndpoints.PutInferenceEndpointAiGateway(ctx, *request) + if err != nil && aiGateway != nil { return fmt.Errorf("failed to update AI gateway: %w", err) } - return nil + return err } // TODO(shreyas): Add acceptance tests for update and for unsetting. Will be done once we add selective updates for these fields. -func (r *ResourceModelServingEndpoint) updateConfig(ctx context.Context, id string, config *serving.EndpointCoreConfigInput) error { - if config == nil { - // Unset config in resource. - req := serving.EndpointCoreConfigInput{ - Name: id, - AutoCaptureConfig: nil, - ServedEntities: nil, - TrafficConfig: nil, - ServedModels: nil, - } - _, err := r.client.ServingEndpoints.UpdateConfig(ctx, req) +func (r *ResourceModelServingEndpoint) updateConfig(ctx context.Context, id string, config *modelserving.EndpointCoreConfig) error { + // A nil config unsets the config in the resource. + req := modelserving.PutInferenceEndpointConfigRequest{ + Name: new(id), + AutoCaptureConfig: nil, // Not set by DABs + ServedEntities: nil, // Not set by DABs + ServedModels: nil, // Not set by DABs + TrafficConfig: nil, // Not set by DABs + } + if config != nil { + req.AutoCaptureConfig = config.AutoCaptureConfig + req.ServedEntities = config.ServedEntities + req.TrafficConfig = config.TrafficConfig + req.ServedModels = config.ServedModels + } + request, err := modelserving.PutInferenceEndpointConfigRequestToSDK(&req) + if err != nil { return err } - req := serving.EndpointCoreConfigInput{ - Name: id, - AutoCaptureConfig: config.AutoCaptureConfig, - ServedEntities: config.ServedEntities, - TrafficConfig: config.TrafficConfig, - ServedModels: config.ServedModels, - } - _, err := r.client.ServingEndpoints.UpdateConfig(ctx, req) - if err != nil { + _, err = r.client.ServingEndpoints.PutInferenceEndpointConfig(ctx, *request) + if err != nil && config != nil { return fmt.Errorf("failed to update config: %w", err) } - return nil + return err } -func (r *ResourceModelServingEndpoint) updateNotifications(ctx context.Context, id string, notifications *serving.EmailNotifications) error { - req := serving.UpdateInferenceEndpointNotifications{ - Name: id, +func (r *ResourceModelServingEndpoint) updateNotifications(ctx context.Context, id string, notifications *modelserving.EmailNotifications) error { + request, err := modelserving.UpdateInferenceEndpointNotificationsRequestToSDK(&modelserving.UpdateInferenceEndpointNotificationsRequest{ + Name: new(id), EmailNotifications: notifications, + }) + if err != nil { + return err } - _, err := r.client.ServingEndpoints.UpdateNotifications(ctx, req) + _, err = r.client.ServingEndpoints.UpdateInferenceEndpointNotifications(ctx, *request) if err != nil { return fmt.Errorf("failed to update notifications: %w", err) } @@ -264,47 +290,41 @@ func (r *ResourceModelServingEndpoint) updateNotifications(ctx context.Context, } // updateTelemetryConfig removes telemetry when telemetryConfig is nil. -func (r *ResourceModelServingEndpoint) updateTelemetryConfig(ctx context.Context, id string, telemetryConfig *serving.TelemetryConfig) error { - req := serving.PatchTelemetryConfigRequest{ - Name: id, +func (r *ResourceModelServingEndpoint) updateTelemetryConfig(ctx context.Context, id string, telemetryConfig *modelserving.TelemetryConfig) error { + request, err := modelserving.PatchInferenceEndpointTelemetryConfigRequestToSDK(&modelserving.PatchInferenceEndpointTelemetryConfigRequest{ + Name: new(id), TelemetryConfig: telemetryConfig, + }) + if err != nil { + return err } - _, err := r.client.ServingEndpoints.PatchTelemetryConfig(ctx, req) + _, err = r.client.ServingEndpoints.PatchInferenceEndpointTelemetryConfig(ctx, *request) if err != nil { return fmt.Errorf("failed to update telemetry config: %w", err) } return nil } -func diffTags(currentTags, desiredTags []serving.EndpointTag) (addTags []serving.EndpointTag, deleteTags []string) { - addTags = make([]serving.EndpointTag, 0) +func diffTags(currentTags, desiredTags []modelserving.EndpointTag) (addTags []modelserving.EndpointTag, deleteTags []string) { + addTags = make([]modelserving.EndpointTag, 0) // build maps for easy lookup. currentTagsMap := make(map[string]string) desiredTagsMap := make(map[string]string) for _, tag := range currentTags { - currentTagsMap[tag.Key] = tag.Value + currentTagsMap[utils.Deref(tag.Key)] = utils.Deref(tag.Value) } for _, tag := range desiredTags { - desiredTagsMap[tag.Key] = tag.Value + desiredTagsMap[utils.Deref(tag.Key)] = utils.Deref(tag.Value) } // Compute keys to be added. for key, desiredValue := range desiredTagsMap { v, ok := currentTagsMap[key] - if !ok { - addTags = append(addTags, serving.EndpointTag{ - Key: key, - Value: desiredValue, - ForceSendFields: nil, - }) - continue - } - if v != desiredValue { - addTags = append(addTags, serving.EndpointTag{ - Key: key, - Value: desiredValue, - ForceSendFields: nil, + if !ok || v != desiredValue { + addTags = append(addTags, modelserving.EndpointTag{ + Key: new(key), + Value: nonEmpty(desiredValue), }) } } @@ -319,27 +339,34 @@ func diffTags(currentTags, desiredTags []serving.EndpointTag) (addTags []serving return addTags, deleteTags } -func (r *ResourceModelServingEndpoint) updateTags(ctx context.Context, id string, tags []serving.EndpointTag) error { - endpoint, err := r.client.ServingEndpoints.GetByName(ctx, id) +func (r *ResourceModelServingEndpoint) updateTags(ctx context.Context, id string, tags []modelserving.EndpointTag) error { + resp, err := r.getEndpoint(ctx, id) + if err != nil { + return err + } + endpoint, err := modelserving.InferenceEndpointDetailedFromSDK(resp) if err != nil { return err } addTags, deleteTags := diffTags(endpoint.Tags, tags) - req := serving.PatchServingEndpointTags{ - Name: id, + request, err := modelserving.PatchInferenceEndpointTagsRequestToSDK(&modelserving.PatchInferenceEndpointTagsRequest{ + Name: new(id), AddTags: addTags, DeleteTags: deleteTags, + }) + if err != nil { + return err } - _, err = r.client.ServingEndpoints.Patch(ctx, req) + _, err = r.client.ServingEndpoints.PatchInferenceEndpointTags(ctx, *request) if err != nil { return fmt.Errorf("failed to update tags: %w", err) } return nil } -func (r *ResourceModelServingEndpoint) DoUpdate(ctx context.Context, id string, config *serving.CreateServingEndpoint, entry *PlanEntry) (*ModelServingEndpointRemote, error) { +func (r *ResourceModelServingEndpoint) DoUpdate(ctx context.Context, id string, config *modelserving.CreateInferenceEndpointRequest, entry *PlanEntry) (*ModelServingEndpointRemote, error) { var err error // Terraform makes these API calls sequentially. We do the same here. @@ -389,6 +416,7 @@ func (r *ResourceModelServingEndpoint) DoUpdate(ctx context.Context, id string, return nil, nil } -func (r *ResourceModelServingEndpoint) DoDelete(ctx context.Context, id string, _ *serving.CreateServingEndpoint) error { - return r.client.ServingEndpoints.DeleteByName(ctx, id) +func (r *ResourceModelServingEndpoint) DoDelete(ctx context.Context, id string, _ *modelserving.CreateInferenceEndpointRequest) error { + _, err := r.client.ServingEndpoints.DeleteInferenceEndpoint(ctx, sdkmodelserving.DeleteInferenceEndpointRequest{Name: new(id)}) + return err } diff --git a/bundle/direct/dresources/permissions.go b/bundle/direct/dresources/permissions.go index c2aebb4d0ac..c01ea247516 100644 --- a/bundle/direct/dresources/permissions.go +++ b/bundle/direct/dresources/permissions.go @@ -6,9 +6,12 @@ import ( "reflect" "strings" + "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" "github.com/databricks/cli/libs/structs/structvar" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/utils" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" ) // GetAPIRequestObjectType is used by direct to construct a request to permissions API: @@ -33,7 +36,7 @@ var permissionResourceToObjectType = map[string]string{ } type ResourcePermissions struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients // objectType is the permissions API prefix of the parent resource, e.g. "/jobs/". objectType string @@ -44,10 +47,10 @@ type ResourcePermissions struct { // StatePermission represents a permission entry in deployment state. type StatePermission struct { - Level iam.PermissionLevel `json:"level,omitempty"` - UserName string `json:"user_name,omitempty"` - ServicePrincipalName string `json:"service_principal_name,omitempty"` - GroupName string `json:"group_name,omitempty"` + Level resources.PermissionLevel `json:"level,omitempty"` + UserName string `json:"user_name,omitempty"` + ServicePrincipalName string `json:"service_principal_name,omitempty"` + GroupName string `json:"group_name,omitempty"` } // Note __embed__ name is not enforced by libs/structs, it's a convention we follow here. @@ -74,7 +77,7 @@ var permissionIDFields = map[string]string{ const defaultPermissionIDField = "id" -func (*ResourcePermissions) New(client *databricks.WorkspaceClient) *ResourcePermissions { +func (*ResourcePermissions) New(client *sdkclients.Clients) *ResourcePermissions { return &ResourcePermissions{client: client, objectType: "", idField: ""} } @@ -137,7 +140,7 @@ func toStatePermissions(ps any) ([]StatePermission, error) { for i := range v.Len() { elem := v.Index(i) result[i] = StatePermission{ - Level: iam.PermissionLevel(elem.FieldByName("Level").String()), + Level: resources.PermissionLevel(elem.FieldByName("Level").String()), UserName: elem.FieldByName("UserName").String(), ServicePrincipalName: elem.FieldByName("ServicePrincipalName").String(), GroupName: elem.FieldByName("GroupName").String(), @@ -194,13 +197,17 @@ func (r *ResourcePermissions) DoRead(ctx context.Context, id string) (*Permissio return nil, err } - acl, err := r.client.Permissions.Get(ctx, iam.GetPermissionRequest{ - RequestObjectId: extractedID, - RequestObjectType: extractedType, + resp, err := r.client.AccessManagement.GetObjectPermissions(ctx, sdkaccessmanagement.GetObjectPermissionsRequest{ + RequestObjectId: new(extractedID), + RequestObjectType: new(extractedType), }) if err != nil { return nil, err } + acl, err := accessmanagement.PermissionsResponseFromSDK(resp) + if err != nil { + return nil, err + } result := PermissionsState{ ObjectID: id, @@ -210,14 +217,14 @@ func (r *ResourcePermissions) DoRead(ctx context.Context, id string) (*Permissio for _, accessControl := range acl.AccessControlList { for _, permission := range accessControl.AllPermissions { // Inherited permissions can be ignored, as they are not set by the user (following TF) - if permission.Inherited { + if utils.Deref(permission.Inherited) { continue } result.EmbeddedSlice = append(result.EmbeddedSlice, StatePermission{ - Level: permission.PermissionLevel, - GroupName: accessControl.GroupName, - UserName: accessControl.UserName, - ServicePrincipalName: accessControl.ServicePrincipalName, + Level: resources.PermissionLevel(permission.PermissionLevel), + GroupName: utils.Deref(accessControl.GroupName), + UserName: utils.Deref(accessControl.UserName), + ServicePrincipalName: utils.Deref(accessControl.ServicePrincipalName), }) } } @@ -244,23 +251,25 @@ func (r *ResourcePermissions) DoUpdate(ctx context.Context, _ string, newState * return nil, err } - acl := make([]iam.AccessControlRequest, len(newState.EmbeddedSlice)) + acl := make([]accessmanagement.AccessControlRequest, len(newState.EmbeddedSlice)) for i, p := range newState.EmbeddedSlice { - acl[i] = iam.AccessControlRequest{ - PermissionLevel: p.Level, - UserName: p.UserName, - ServicePrincipalName: p.ServicePrincipalName, - GroupName: p.GroupName, - ForceSendFields: nil, + acl[i] = accessmanagement.AccessControlRequest{ + PermissionLevel: accessmanagement.PermissionLevel(p.Level), + UserName: nonEmpty(p.UserName), + ServicePrincipalName: nonEmpty(p.ServicePrincipalName), + GroupName: nonEmpty(p.GroupName), } } - _, err = r.client.Permissions.Set(ctx, iam.SetObjectPermissions{ - RequestObjectId: extractedID, - RequestObjectType: extractedType, + request, err := accessmanagement.SetObjectPermissionsRequestToSDK(&accessmanagement.SetObjectPermissionsRequest{ + RequestObjectId: new(extractedID), + RequestObjectType: new(extractedType), AccessControlList: acl, }) - + if err != nil { + return nil, err + } + _, err = r.client.AccessManagement.SetObjectPermissions(ctx, *request) return nil, err } diff --git a/bundle/direct/dresources/permissions_test.go b/bundle/direct/dresources/permissions_test.go index e6b63d37436..3763bfab90f 100644 --- a/bundle/direct/dresources/permissions_test.go +++ b/bundle/direct/dresources/permissions_test.go @@ -57,7 +57,7 @@ func TestPrepareInputConfigPassthrough(t *testing.T) { adapter, err := NewAdapter(SupportedResources["schemas"], "schemas", nil) require.NoError(t, err) - input := &resources.Schema{Name: "myschema"} + input := &resources.Schema{Name: new("myschema")} sv, err := adapter.PrepareInputConfig(input, "resources.schemas.foo") require.NoError(t, err) diff --git a/bundle/direct/dresources/pipeline.go b/bundle/direct/dresources/pipeline.go index 6f367d4e498..e1c01caf2f8 100644 --- a/bundle/direct/dresources/pipeline.go +++ b/bundle/direct/dresources/pipeline.go @@ -5,18 +5,19 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/libs/sdkclients" + pipelines "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/sdktypes/sdkconv" "github.com/databricks/cli/libs/structs/structdiff" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/pipelines" + sdkpipelines "github.com/databricks/sdk-go/pipelines/v2" ) // PipelineState is the state type for Pipeline resources. It extends CreatePipeline with // the CascadeOnDestroy field, a delete-time setting that is not part of the pipeline spec type PipelineState struct { - pipelines.CreatePipeline + pipelines.CreatePipelineRequest // CascadeOnDestroy controls whether deleting the pipeline also deletes its datasets (MVs, // STs, Views). Nil means the server default (cascade) applies. Read from persisted state at @@ -24,51 +25,33 @@ type PipelineState struct { CascadeOnDestroy *bool `json:"cascade_on_destroy,omitempty"` } -func (s *PipelineState) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PipelineState) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - // PipelineRemote is the return type for DoRead. It embeds CreatePipeline so that all // paths in StateType are valid paths in RemoteType. // Note that cascade_on_destroy is intentionally absent: it is a delete-time-only setting // that the GET response never returns, so the engine suppresses its drift automatically type PipelineRemote struct { - pipelines.CreatePipeline + pipelines.CreatePipelineRequest // Remote-specific fields from pipelines.GetPipelineResponse - Cause string `json:"cause,omitempty"` - ClusterId string `json:"cluster_id,omitempty"` - CreatorUserName string `json:"creator_user_name,omitempty"` - EffectiveBudgetPolicyId string `json:"effective_budget_policy_id,omitempty"` - EffectivePublishingMode pipelines.PublishingMode `json:"effective_publishing_mode,omitempty"` - EffectiveServerlessComputeId string `json:"effective_serverless_compute_id,omitempty"` - Health pipelines.GetPipelineResponseHealth `json:"health,omitempty"` - LastModified int64 `json:"last_modified,omitempty"` - LatestUpdates []pipelines.UpdateStateInfo `json:"latest_updates,omitempty"` - PipelineId string `json:"pipeline_id,omitempty"` - RunAsUserName string `json:"run_as_user_name,omitempty"` - State pipelines.PipelineState `json:"state,omitempty"` -} - -// Custom marshaler needed because embedded CreatePipeline has its own MarshalJSON -// which would otherwise take over and ignore the additional fields. -func (s *PipelineRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PipelineRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) + Cause *string `json:"cause,omitempty"` + ClusterId *string `json:"cluster_id,omitempty"` + CreatorUserName *string `json:"creator_user_name,omitempty"` + EffectiveBudgetPolicyId *string `json:"effective_budget_policy_id,omitempty"` + EffectivePublishingMode pipelines.PublishingMode `json:"effective_publishing_mode,omitempty"` + EffectiveServerlessComputeId *string `json:"effective_serverless_compute_id,omitempty"` + Health pipelines.PipelineHealthStatus `json:"health,omitempty"` + LastModified *int64 `json:"last_modified,omitempty"` + LatestUpdates []pipelines.UpdateStateInfo `json:"latest_updates,omitempty"` + PipelineId *string `json:"pipeline_id,omitempty"` + RunAsUserName *string `json:"run_as_user_name,omitempty"` + State pipelines.PipelineState_PipelineState `json:"state,omitempty"` } type ResourcePipeline struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourcePipeline) New(client *databricks.WorkspaceClient) *ResourcePipeline { +func (*ResourcePipeline) New(client *sdkclients.Clients) *ResourcePipeline { return &ResourcePipeline{ client: client, } @@ -76,73 +59,44 @@ func (*ResourcePipeline) New(client *databricks.WorkspaceClient) *ResourcePipeli func (*ResourcePipeline) PrepareState(input *resources.Pipeline) *PipelineState { return &PipelineState{ - CreatePipeline: input.CreatePipeline, - CascadeOnDestroy: input.CascadeOnDestroy, + CreatePipelineRequest: input.CreatePipelineRequest, + CascadeOnDestroy: input.CascadeOnDestroy, } } func (*ResourcePipeline) RemapState(remote *PipelineRemote) *PipelineState { return &PipelineState{ - CreatePipeline: remote.CreatePipeline, + CreatePipelineRequest: remote.CreatePipelineRequest, // cascade_on_destroy is input-only and absent from PipelineRemote, so it stays nil here. CascadeOnDestroy: nil, } } func (r *ResourcePipeline) DoRead(ctx context.Context, id string) (*PipelineRemote, error) { - resp, err := r.client.Pipelines.GetByPipelineId(ctx, id) + resp, err := r.client.Pipelines.Get(ctx, sdkpipelines.GetPipelineRequest{PipelineId: new(id)}) if err != nil { return nil, err } - return makePipelineRemote(resp), nil + return makePipelineRemote(resp) } -func makePipelineRemote(p *pipelines.GetPipelineResponse) *PipelineRemote { - var createPipeline pipelines.CreatePipeline +func makePipelineRemote(resp *sdkpipelines.GetPipelineResponse) (*PipelineRemote, error) { + p, err := sdkconv.FromSDK[pipelines.GetPipelineResponse](resp) + if err != nil { + return nil, err + } + var createPipeline pipelines.CreatePipelineRequest if p.Spec != nil { - spec := p.Spec - createPipeline = pipelines.CreatePipeline{ - // Note: AllowDuplicateNames and DryRun are not in PipelineSpec, - // they are request-only fields, so they stay at their zero values. - AllowDuplicateNames: false, - BudgetPolicyId: spec.BudgetPolicyId, - Catalog: spec.Catalog, - Channel: spec.Channel, - Clusters: spec.Clusters, - Configuration: spec.Configuration, - Continuous: spec.Continuous, //nolint:staticcheck // SA1019: pipeline continuous is deprecated in the SDK but remains a supported bundle config field - Deployment: spec.Deployment, - Development: spec.Development, //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field - DryRun: false, - Edition: spec.Edition, - Environment: spec.Environment, - EventLog: spec.EventLog, - Filters: spec.Filters, - GatewayDefinition: spec.GatewayDefinition, - Id: spec.Id, - IngestionDefinition: spec.IngestionDefinition, - Libraries: spec.Libraries, - Name: spec.Name, - Notifications: spec.Notifications, - Parameters: p.Parameters, - ParentPath: spec.ParentPath, - Photon: spec.Photon, - RestartWindow: spec.RestartWindow, - RootPath: spec.RootPath, - RunAs: p.RunAs, - Schema: spec.Schema, - Serverless: spec.Serverless, - ServerlessComputeId: spec.ServerlessComputeId, - Storage: spec.Storage, - Tags: spec.Tags, - Target: spec.Target, - Trigger: spec.Trigger, - UsagePolicyId: spec.UsagePolicyId, - ForceSendFields: utils.FilterFields[pipelines.CreatePipeline](spec.ForceSendFields, "AllowDuplicateNames", "DryRun", "Parameters", "RunAs"), + // PipelineSpec is CreatePipelineRequest without the request-only fields + // (allow_duplicate_names, dry_run) and the ones returned at the top level. + if err := sdkconv.Convert(&createPipeline, p.Spec); err != nil { + return nil, err } + createPipeline.Parameters = p.Parameters + createPipeline.RunAs = p.RunAs } return &PipelineRemote{ - CreatePipeline: createPipeline, + CreatePipelineRequest: createPipeline, Cause: p.Cause, ClusterId: p.ClusterId, CreatorUserName: p.CreatorUserName, @@ -155,15 +109,19 @@ func makePipelineRemote(p *pipelines.GetPipelineResponse) *PipelineRemote { PipelineId: p.PipelineId, RunAsUserName: p.RunAsUserName, State: p.State, - } + }, nil } func (r *ResourcePipeline) DoCreate(ctx context.Context, config *PipelineState) (string, *PipelineRemote, error) { - response, err := r.client.Pipelines.Create(ctx, config.CreatePipeline) + request, err := sdkconv.ToSDK[sdkpipelines.CreatePipelineRequest](&config.CreatePipelineRequest) + if err != nil { + return "", nil, err + } + response, err := r.client.Pipelines.Create(ctx, *request) if err != nil { return "", nil, err } - return response.PipelineId, nil, nil + return utils.Deref(response.PipelineId), nil, nil } func (r *ResourcePipeline) DoUpdate(ctx context.Context, id string, config *PipelineState, entry *PlanEntry) (*PipelineRemote, error) { @@ -173,61 +131,27 @@ func (r *ResourcePipeline) DoUpdate(ctx context.Context, id string, config *Pipe return nil, nil } - request := pipelines.EditPipeline{ - AllowDuplicateNames: config.AllowDuplicateNames, - BudgetPolicyId: config.BudgetPolicyId, - Catalog: config.Catalog, - Channel: config.Channel, - Clusters: config.Clusters, - Configuration: config.Configuration, - Continuous: config.Continuous, //nolint:staticcheck // SA1019: pipeline continuous is deprecated in the SDK but remains a supported bundle config field - Deployment: config.Deployment, - Development: config.Development, //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field - Edition: config.Edition, - Environment: config.Environment, - EventLog: config.EventLog, - ExpectedLastModified: 0, - Filters: config.Filters, - GatewayDefinition: config.GatewayDefinition, - Id: config.Id, - IngestionDefinition: config.IngestionDefinition, - Libraries: config.Libraries, - Name: config.Name, - Notifications: config.Notifications, - Parameters: config.Parameters, - ParentPath: config.ParentPath, - Photon: config.Photon, - RestartWindow: config.RestartWindow, - RootPath: config.RootPath, - RunAs: config.RunAs, - Schema: config.Schema, - Serverless: config.Serverless, - ServerlessComputeId: config.ServerlessComputeId, - Storage: config.Storage, - Tags: config.Tags, - Target: config.Target, - Trigger: config.Trigger, - UsagePolicyId: config.UsagePolicyId, - PipelineId: id, - ForceSendFields: utils.FilterFields[pipelines.EditPipeline](config.ForceSendFields), + // EditPipelineRequest is CreatePipelineRequest without dry_run plus the pipeline id. + create := config.CreatePipelineRequest + create.DryRun = nil + request, err := sdkconv.ToSDK[sdkpipelines.EditPipelineRequest](&create) + if err != nil { + return nil, err } - - return nil, r.client.Pipelines.Update(ctx, request) + request.PipelineId = new(id) + _, err = r.client.Pipelines.Edit(ctx, *request) + return nil, err } func (r *ResourcePipeline) DoDelete(ctx context.Context, id string, state *PipelineState) error { - if state.CascadeOnDestroy == nil { - // No explicit cascade_on_destroy in config: preserve the backend default (cascade). - return r.client.Pipelines.DeleteByPipelineId(ctx, id) - } - return r.client.Pipelines.Delete(ctx, pipelines.DeletePipelineRequest{ - PipelineId: id, - Cascade: *state.CascadeOnDestroy, - Force: false, - // Cascade is marshaled as `url:"cascade,omitempty"`, so a false value would be dropped from - // the query string. We specify `cascade` in ForceSendFields so the SDK send cascade=false explicitly - ForceSendFields: []string{"Cascade"}, + // A nil cascade_on_destroy preserves the backend default (cascade); an explicit + // false is sent as cascade=false. + _, err := r.client.Pipelines.Delete(ctx, sdkpipelines.DeletePipelineRequest{ + PipelineId: new(id), + Cascade: state.CascadeOnDestroy, + Force: nil, // Not set by DABs }) + return err } // OverrideChangeDesc forces a state-only Update when cascade_on_destroy changes locally. diff --git a/bundle/direct/dresources/pipeline_test.go b/bundle/direct/dresources/pipeline_test.go index 3629255a600..4a690224532 100644 --- a/bundle/direct/dresources/pipeline_test.go +++ b/bundle/direct/dresources/pipeline_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/databricks/cli/bundle/deployplan" + pipelines "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -15,11 +15,10 @@ import ( // (except Spec and internal fields) are present in PipelineRemote. func TestPipelineRemote(t *testing.T) { assertFieldsCovered(t, reflect.TypeFor[pipelines.GetPipelineResponse](), reflect.TypeFor[PipelineRemote](), map[string]bool{ - "Spec": true, // Embedded as pipelines.CreatePipeline (via makePipelineRemote) - "ForceSendFields": true, // Internal marshaling field - "Name": true, // Available through embedded CreatePipeline - "Parameters": true, // Available through embedded CreatePipeline - "RunAs": true, // Available through embedded CreatePipeline + "Spec": true, // Embedded as pipelines.CreatePipelineRequest (via makePipelineRemote) + "Name": true, // Available through embedded CreatePipelineRequest + "Parameters": true, // Available through embedded CreatePipelineRequest + "RunAs": true, // Available through embedded CreatePipelineRequest }) } diff --git a/bundle/direct/dresources/postgres_branch.go b/bundle/direct/dresources/postgres_branch.go index 57bba56707d..7c9414cf8fe 100644 --- a/bundle/direct/dresources/postgres_branch.go +++ b/bundle/direct/dresources/postgres_branch.go @@ -3,13 +3,14 @@ package dresources import ( "context" "slices" + "strings" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/sdkclients" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/types" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" ) // PostgresBranchRemote is the return type for DoRead. It embeds BranchSpec so that @@ -24,27 +25,17 @@ type PostgresBranchRemote struct { Name string `json:"name,omitempty"` Status *postgres.BranchStatus `json:"status,omitempty"` Uid string `json:"uid,omitempty"` - CreateTime *sdktime.Time `json:"create_time,omitempty"` - UpdateTime *sdktime.Time `json:"update_time,omitempty"` -} - -// Custom marshaler needed because embedded BranchSpec has its own MarshalJSON -// which would otherwise take over and ignore the additional fields. -func (s *PostgresBranchRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PostgresBranchRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) + CreateTime *types.Time `json:"create_time,omitempty"` + UpdateTime *types.Time `json:"update_time,omitempty"` } type ResourcePostgresBranch struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } type PostgresBranchState = resources.PostgresBranchConfig -func (*ResourcePostgresBranch) New(client *databricks.WorkspaceClient) *ResourcePostgresBranch { +func (*ResourcePostgresBranch) New(client *sdkclients.Clients) *ResourcePostgresBranch { return &ResourcePostgresBranch{client: client} } @@ -55,7 +46,6 @@ func (*ResourcePostgresBranch) PrepareState(input *resources.PostgresBranch) *Po ReplaceExisting: input.ReplaceExisting, PurgeOnDelete: input.PurgeOnDelete, BranchSpec: input.BranchSpec, - ForceSendFields: input.ForceSendFields, } } @@ -69,9 +59,8 @@ func (*ResourcePostgresBranch) RemapState(remote *PostgresBranchRemote) *Postgre ReplaceExisting: false, // purge_on_delete is a delete-time query parameter; the GET API never - // returns it, so RemapState leaves it false. - PurgeOnDelete: false, - ForceSendFields: nil, + // returns it, so RemapState leaves it unset. + PurgeOnDelete: nil, BranchSpec: remote.BranchSpec, } @@ -81,54 +70,59 @@ func (*ResourcePostgresBranch) RemapState(remote *PostgresBranchRemote) *Postgre // GET does not echo spec today (only status is returned); the embedded spec fields // stay at their zero values, and postgres_branches.yml suppresses phantom drift via // ignore_remote_changes with reason spec:input_only. -func makePostgresBranchRemote(branch *postgres.Branch) *PostgresBranchRemote { +func makePostgresBranchRemote(resp *sdkpostgres.Branch) (*PostgresBranchRemote, error) { + branch, err := postgres.BranchFromSDK(resp) + if err != nil { + return nil, err + } var spec postgres.BranchSpec if branch.Spec != nil { spec = *branch.Spec } return &PostgresBranchRemote{ BranchSpec: spec, - BranchId: branch.BranchId, - Parent: branch.Parent, - Name: branch.Name, + BranchId: utils.Deref(branch.BranchId), + Parent: utils.Deref(branch.Parent), + Name: utils.Deref(branch.Name), Status: branch.Status, - Uid: branch.Uid, + Uid: utils.Deref(branch.Uid), CreateTime: branch.CreateTime, UpdateTime: branch.UpdateTime, - } + }, nil } func (r *ResourcePostgresBranch) DoRead(ctx context.Context, id string) (*PostgresBranchRemote, error) { - branch, err := r.client.Postgres.GetBranch(ctx, postgres.GetBranchRequest{Name: id}) + branch, err := r.client.Postgres.GetBranch(ctx, sdkpostgres.GetBranchRequest{Name: new(id)}) if err != nil { return nil, err } - return makePostgresBranchRemote(branch), nil + return makePostgresBranchRemote(branch) } func (r *ResourcePostgresBranch) DoCreate(ctx context.Context, config *PostgresBranchState) (string, *PostgresBranchRemote, error) { - waiter, err := r.client.Postgres.CreateBranch(ctx, postgres.CreateBranchRequest{ - BranchId: config.BranchId, - Parent: config.Parent, - Branch: postgres.Branch{ - Spec: &config.BranchSpec, - - // Output-only fields. - BranchId: "", - CreateTime: nil, - Name: "", - Parent: "", - Status: nil, - Uid: "", - UpdateTime: nil, - ForceSendFields: nil, + // Only spec is set; the other Branch fields are output-only. + request, err := postgres.CreateBranchRequestToSDK(&postgres.CreateBranchRequest{ + BranchId: nonEmpty(config.BranchId), + Parent: nonEmpty(config.Parent), + Branch: &postgres.Branch{ + Spec: &config.BranchSpec, + BranchId: nil, // Not set by DABs + CreateTime: nil, // Not set by DABs + Name: nil, // Not set by DABs + Parent: nil, // Not set by DABs + Status: nil, // Not set by DABs + Uid: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs }, - ReplaceExisting: config.ReplaceExisting, - ForceSendFields: nil, + ReplaceExisting: trueOrNil(config.ReplaceExisting), }) if err != nil { return "", nil, err } + waiter, err := r.client.Postgres.CreateBranch(ctx, *request) + if err != nil { + return "", nil, err + } // Wait for the branch to be ready (long-running operation) result, err := waiter.Wait(ctx) @@ -136,7 +130,10 @@ func (r *ResourcePostgresBranch) DoCreate(ctx context.Context, config *PostgresB return "", nil, err } - remote := makePostgresBranchRemote(result) + remote, err := makePostgresBranchRemote(result) + if err != nil { + return "", nil, err + } return remote.Name, remote, nil } @@ -169,42 +166,31 @@ func (r *ResourcePostgresBranch) DoUpdate(ctx context.Context, id string, config return nil, nil } - waiter, err := r.client.Postgres.UpdateBranch(ctx, postgres.UpdateBranchRequest{ - Branch: postgres.Branch{ - Spec: &config.BranchSpec, - - // Output-only fields. - BranchId: "", - CreateTime: nil, - Name: "", - Parent: "", - Status: nil, - Uid: "", - UpdateTime: nil, - ForceSendFields: nil, - }, - Name: id, - UpdateMask: fieldmask.FieldMask{ - Paths: fieldPaths, - }, + // Only spec is set; the other Branch fields are output-only. + updated, err := updatePostgres[postgres.Branch](ctx, r.client, id, strings.Join(fieldPaths, ","), &postgres.Branch{ + Spec: &config.BranchSpec, + BranchId: nil, // Not set by DABs + CreateTime: nil, // Not set by DABs + Name: nil, // Not set by DABs + Parent: nil, // Not set by DABs + Status: nil, // Not set by DABs + Uid: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs }) if err != nil { return nil, err } - - // Wait for the update to complete - result, err := waiter.Wait(ctx) + result, err := postgres.BranchToSDK(updated) if err != nil { return nil, err } - return makePostgresBranchRemote(result), nil + return makePostgresBranchRemote(result) } func (r *ResourcePostgresBranch) DoDelete(ctx context.Context, id string, state *PostgresBranchState) error { - waiter, err := r.client.Postgres.DeleteBranch(ctx, postgres.DeleteBranchRequest{ - Name: id, - Purge: state.PurgeOnDelete, - ForceSendFields: nil, + waiter, err := r.client.Postgres.DeleteBranch(ctx, sdkpostgres.DeleteBranchRequest{ + Name: new(id), + Purge: trueOrNil(utils.Deref(state.PurgeOnDelete)), }) if err != nil { return err diff --git a/bundle/direct/dresources/postgres_catalog.go b/bundle/direct/dresources/postgres_catalog.go index 348ba88960b..7b0f1bdda85 100644 --- a/bundle/direct/dresources/postgres_catalog.go +++ b/bundle/direct/dresources/postgres_catalog.go @@ -5,58 +5,49 @@ import ( "strings" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/sdkclients" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/types" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" ) -// PostgresCatalogRemote is the return type for DoRead. It embeds CatalogCatalogSpec so +// PostgresCatalogRemote is the return type for DoRead. It embeds Catalog_CatalogSpec so // that all paths in StateType are valid paths in RemoteType, enabling drift detection // for spec fields once the backend echoes spec on GET. type PostgresCatalogRemote struct { - postgres.CatalogCatalogSpec + postgres.Catalog_CatalogSpec CatalogId string `json:"catalog_id,omitempty"` - Name string `json:"name,omitempty"` - Status *postgres.CatalogCatalogStatus `json:"status,omitempty"` - Uid string `json:"uid,omitempty"` - CreateTime *sdktime.Time `json:"create_time,omitempty"` - UpdateTime *sdktime.Time `json:"update_time,omitempty"` -} - -// Custom marshaler needed because embedded CatalogCatalogSpec has its own MarshalJSON -// which would otherwise take over and ignore the additional fields. -func (s *PostgresCatalogRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PostgresCatalogRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) + Name string `json:"name,omitempty"` + Status *postgres.Catalog_CatalogStatus `json:"status,omitempty"` + Uid string `json:"uid,omitempty"` + CreateTime *types.Time `json:"create_time,omitempty"` + UpdateTime *types.Time `json:"update_time,omitempty"` } type ResourcePostgresCatalog struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } type PostgresCatalogState = resources.PostgresCatalogConfig -func (*ResourcePostgresCatalog) New(client *databricks.WorkspaceClient) *ResourcePostgresCatalog { +func (*ResourcePostgresCatalog) New(client *sdkclients.Clients) *ResourcePostgresCatalog { return &ResourcePostgresCatalog{client: client} } func (*ResourcePostgresCatalog) PrepareState(input *resources.PostgresCatalog) *PostgresCatalogState { return &PostgresCatalogState{ - CatalogId: input.CatalogId, - CatalogCatalogSpec: input.CatalogCatalogSpec, + CatalogId: input.CatalogId, + Catalog_CatalogSpec: input.Catalog_CatalogSpec, } } func (*ResourcePostgresCatalog) RemapState(remote *PostgresCatalogRemote) *PostgresCatalogState { return &PostgresCatalogState{ - CatalogId: remote.CatalogId, - CatalogCatalogSpec: remote.CatalogCatalogSpec, + CatalogId: remote.CatalogId, + Catalog_CatalogSpec: remote.Catalog_CatalogSpec, } } @@ -67,62 +58,68 @@ func (*ResourcePostgresCatalog) RemapState(remote *PostgresCatalogRemote) *Postg // // The user-facing catalog id only appears as the trailing component of // remote.Name, so we strip the constant "catalogs/" prefix. -func makePostgresCatalogRemote(catalog *postgres.Catalog) *PostgresCatalogRemote { - var spec postgres.CatalogCatalogSpec +func makePostgresCatalogRemote(resp *sdkpostgres.Catalog) (*PostgresCatalogRemote, error) { + catalog, err := postgres.CatalogFromSDK(resp) + if err != nil { + return nil, err + } + var spec postgres.Catalog_CatalogSpec if catalog.Spec != nil { spec = *catalog.Spec } return &PostgresCatalogRemote{ - CatalogCatalogSpec: spec, - CatalogId: strings.TrimPrefix(catalog.Name, "catalogs/"), - Name: catalog.Name, - Status: catalog.Status, - Uid: catalog.Uid, - CreateTime: catalog.CreateTime, - UpdateTime: catalog.UpdateTime, - } + Catalog_CatalogSpec: spec, + CatalogId: strings.TrimPrefix(utils.Deref(catalog.Name), "catalogs/"), + Name: utils.Deref(catalog.Name), + Status: catalog.Status, + Uid: utils.Deref(catalog.Uid), + CreateTime: catalog.CreateTime, + UpdateTime: catalog.UpdateTime, + }, nil } func (r *ResourcePostgresCatalog) DoRead(ctx context.Context, id string) (*PostgresCatalogRemote, error) { - catalog, err := r.client.Postgres.GetCatalog(ctx, postgres.GetCatalogRequest{Name: id}) + catalog, err := r.client.Postgres.GetCatalog(ctx, sdkpostgres.GetCatalogRequest{Name: new(id)}) if err != nil { return nil, err } - return makePostgresCatalogRemote(catalog), nil + return makePostgresCatalogRemote(catalog) } func (r *ResourcePostgresCatalog) DoCreate(ctx context.Context, config *PostgresCatalogState) (string, *PostgresCatalogRemote, error) { - waiter, err := r.client.Postgres.CreateCatalog(ctx, postgres.CreateCatalogRequest{ - CatalogId: config.CatalogId, - Catalog: postgres.Catalog{ - Spec: &config.CatalogCatalogSpec, - - // Output-only fields. - CatalogId: "", - CreateTime: nil, - Name: "", - Status: nil, - Uid: "", - UpdateTime: nil, - ForceSendFields: nil, + request, err := postgres.CreateCatalogRequestToSDK(&postgres.CreateCatalogRequest{ + CatalogId: nonEmpty(config.CatalogId), + Catalog: &postgres.Catalog{ + Spec: &config.Catalog_CatalogSpec, + CatalogId: nil, // Not set by DABs + CreateTime: nil, // Not set by DABs + Name: nil, // Not set by DABs + Status: nil, // Not set by DABs + Uid: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs }, }) if err != nil { return "", nil, err } + waiter, err := r.client.Postgres.CreateCatalog(ctx, *request) + if err != nil { + return "", nil, err + } result, err := waiter.Wait(ctx) if err != nil { return "", nil, err } - remote := makePostgresCatalogRemote(result) + remote, err := makePostgresCatalogRemote(result) + if err != nil { + return "", nil, err + } return remote.Name, remote, nil } func (r *ResourcePostgresCatalog) DoDelete(ctx context.Context, id string, _ *PostgresCatalogState) error { - waiter, err := r.client.Postgres.DeleteCatalog(ctx, postgres.DeleteCatalogRequest{ - Name: id, - }) + waiter, err := r.client.Postgres.DeleteCatalog(ctx, sdkpostgres.DeleteCatalogRequest{Name: new(id)}) if err != nil { return err } diff --git a/bundle/direct/dresources/postgres_database.go b/bundle/direct/dresources/postgres_database.go index 613f5d90270..4226572ba3b 100644 --- a/bundle/direct/dresources/postgres_database.go +++ b/bundle/direct/dresources/postgres_database.go @@ -2,57 +2,48 @@ package dresources import ( "context" + "strings" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/sdkclients" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/types" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" ) // PostgresDatabaseRemote is the return type for DoRead. It embeds -// DatabaseDatabaseSpec so that all paths in StateType are valid paths in +// Database_DatabaseSpec so that all paths in StateType are valid paths in // RemoteType, enabling drift detection for spec fields once the backend echoes // spec on GET. type PostgresDatabaseRemote struct { - postgres.DatabaseDatabaseSpec + postgres.Database_DatabaseSpec DatabaseId string `json:"database_id,omitempty"` Parent string `json:"parent,omitempty"` - Name string `json:"name,omitempty"` - Status *postgres.DatabaseDatabaseStatus `json:"status,omitempty"` - CreateTime *sdktime.Time `json:"create_time,omitempty"` - UpdateTime *sdktime.Time `json:"update_time,omitempty"` -} - -// Custom marshaler needed because embedded DatabaseDatabaseSpec has its own -// MarshalJSON which would otherwise take over and ignore the additional fields. -func (s *PostgresDatabaseRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PostgresDatabaseRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) + Name string `json:"name,omitempty"` + Status *postgres.Database_DatabaseStatus `json:"status,omitempty"` + CreateTime *types.Time `json:"create_time,omitempty"` + UpdateTime *types.Time `json:"update_time,omitempty"` } type ResourcePostgresDatabase struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } type PostgresDatabaseState = resources.PostgresDatabaseConfig -func (*ResourcePostgresDatabase) New(client *databricks.WorkspaceClient) *ResourcePostgresDatabase { +func (*ResourcePostgresDatabase) New(client *sdkclients.Clients) *ResourcePostgresDatabase { return &ResourcePostgresDatabase{client: client} } func (*ResourcePostgresDatabase) PrepareState(input *resources.PostgresDatabase) *PostgresDatabaseState { return &PostgresDatabaseState{ - DatabaseId: input.DatabaseId, - Parent: input.Parent, - ReplaceExisting: input.ReplaceExisting, - DatabaseDatabaseSpec: input.DatabaseDatabaseSpec, + DatabaseId: input.DatabaseId, + Parent: input.Parent, + ReplaceExisting: input.ReplaceExisting, + Database_DatabaseSpec: input.Database_DatabaseSpec, } } @@ -65,7 +56,7 @@ func (*ResourcePostgresDatabase) RemapState(remote *PostgresDatabaseRemote) *Pos // it, so RemapState leaves it false. ReplaceExisting: false, - DatabaseDatabaseSpec: remote.DatabaseDatabaseSpec, + Database_DatabaseSpec: remote.Database_DatabaseSpec, } } @@ -73,52 +64,56 @@ func (*ResourcePostgresDatabase) RemapState(remote *PostgresDatabaseRemote) *Pos // shape. GET does not echo spec today (only status is returned); the embedded // spec fields stay at their zero values, and postgres_databases.yml suppresses phantom // drift via ignore_remote_changes with reason spec:input_only. -func makePostgresDatabaseRemote(database *postgres.Database) *PostgresDatabaseRemote { - var spec postgres.DatabaseDatabaseSpec +func makePostgresDatabaseRemote(resp *sdkpostgres.Database) (*PostgresDatabaseRemote, error) { + database, err := postgres.DatabaseFromSDK(resp) + if err != nil { + return nil, err + } + var spec postgres.Database_DatabaseSpec if database.Spec != nil { spec = *database.Spec } return &PostgresDatabaseRemote{ - DatabaseDatabaseSpec: spec, - DatabaseId: database.DatabaseId, - Parent: database.Parent, - Name: database.Name, - Status: database.Status, - CreateTime: database.CreateTime, - UpdateTime: database.UpdateTime, - } + Database_DatabaseSpec: spec, + DatabaseId: utils.Deref(database.DatabaseId), + Parent: utils.Deref(database.Parent), + Name: utils.Deref(database.Name), + Status: database.Status, + CreateTime: database.CreateTime, + UpdateTime: database.UpdateTime, + }, nil } func (r *ResourcePostgresDatabase) DoRead(ctx context.Context, id string) (*PostgresDatabaseRemote, error) { - database, err := r.client.Postgres.GetDatabase(ctx, postgres.GetDatabaseRequest{Name: id}) + database, err := r.client.Postgres.GetDatabase(ctx, sdkpostgres.GetDatabaseRequest{Name: new(id)}) if err != nil { return nil, err } - return makePostgresDatabaseRemote(database), nil + return makePostgresDatabaseRemote(database) } func (r *ResourcePostgresDatabase) DoCreate(ctx context.Context, config *PostgresDatabaseState) (string, *PostgresDatabaseRemote, error) { - waiter, err := r.client.Postgres.CreateDatabase(ctx, postgres.CreateDatabaseRequest{ - DatabaseId: config.DatabaseId, - Parent: config.Parent, - Database: postgres.Database{ - Spec: &config.DatabaseDatabaseSpec, - - // Output-only fields. - DatabaseId: "", - CreateTime: nil, - Name: "", - Parent: "", - Status: nil, - UpdateTime: nil, - ForceSendFields: nil, + request, err := postgres.CreateDatabaseRequestToSDK(&postgres.CreateDatabaseRequest{ + DatabaseId: nonEmpty(config.DatabaseId), + Parent: nonEmpty(config.Parent), + ReplaceExisting: trueOrNil(config.ReplaceExisting), + Database: &postgres.Database{ + Spec: &config.Database_DatabaseSpec, + CreateTime: nil, // Not set by DABs + DatabaseId: nil, // Not set by DABs + Name: nil, // Not set by DABs + Parent: nil, // Not set by DABs + Status: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs }, - ReplaceExisting: config.ReplaceExisting, - ForceSendFields: nil, }) if err != nil { return "", nil, err } + waiter, err := r.client.Postgres.CreateDatabase(ctx, *request) + if err != nil { + return "", nil, err + } // Wait for the database to be ready (long-running operation) result, err := waiter.Wait(ctx) @@ -126,7 +121,10 @@ func (r *ResourcePostgresDatabase) DoCreate(ctx context.Context, config *Postgre return "", nil, err } - remote := makePostgresDatabaseRemote(result) + remote, err := makePostgresDatabaseRemote(result) + if err != nil { + return "", nil, err + } return remote.Name, remote, nil } @@ -137,40 +135,35 @@ func (r *ResourcePostgresDatabase) DoUpdate(ctx context.Context, id string, conf // not relative to our flattened state type. fieldPaths := collectUpdatePathsWithPrefix(entry.Changes, "spec.", nil) - waiter, err := r.client.Postgres.UpdateDatabase(ctx, postgres.UpdateDatabaseRequest{ - Database: postgres.Database{ - Spec: &config.DatabaseDatabaseSpec, - - // Output-only fields. - DatabaseId: "", - CreateTime: nil, - Name: "", - Parent: "", - Status: nil, - UpdateTime: nil, - ForceSendFields: nil, - }, - Name: id, - UpdateMask: fieldmask.FieldMask{ - Paths: fieldPaths, + request, err := postgres.UpdateDatabaseRequestToSDK(&postgres.UpdateDatabaseRequest{ + Database: &postgres.Database{ + Name: new(id), Spec: &config.Database_DatabaseSpec, + CreateTime: nil, // Not set by DABs + DatabaseId: nil, // Not set by DABs + Parent: nil, // Not set by DABs + Status: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs }, + UpdateMask: new(strings.Join(fieldPaths, ",")), }) if err != nil { return nil, err } + waiter, err := r.client.Postgres.UpdateDatabase(ctx, *request) + if err != nil { + return nil, err + } // Wait for the update to complete result, err := waiter.Wait(ctx) if err != nil { return nil, err } - return makePostgresDatabaseRemote(result), nil + return makePostgresDatabaseRemote(result) } func (r *ResourcePostgresDatabase) DoDelete(ctx context.Context, id string, _ *PostgresDatabaseState) error { - waiter, err := r.client.Postgres.DeleteDatabase(ctx, postgres.DeleteDatabaseRequest{ - Name: id, - }) + waiter, err := r.client.Postgres.DeleteDatabase(ctx, sdkpostgres.DeleteDatabaseRequest{Name: new(id)}) if err != nil { return err } diff --git a/bundle/direct/dresources/postgres_endpoint.go b/bundle/direct/dresources/postgres_endpoint.go index 786f52b8b21..715f1d55f8b 100644 --- a/bundle/direct/dresources/postgres_endpoint.go +++ b/bundle/direct/dresources/postgres_endpoint.go @@ -8,12 +8,12 @@ import ( "time" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/types" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" ) // endpointReconciliationTimeout is the maximum time to wait for endpoint reconciliation. @@ -32,27 +32,17 @@ type PostgresEndpointRemote struct { Name string `json:"name,omitempty"` Status *postgres.EndpointStatus `json:"status,omitempty"` Uid string `json:"uid,omitempty"` - CreateTime *sdktime.Time `json:"create_time,omitempty"` - UpdateTime *sdktime.Time `json:"update_time,omitempty"` -} - -// Custom marshaler needed because embedded EndpointSpec has its own MarshalJSON -// which would otherwise take over and ignore the additional fields. -func (s *PostgresEndpointRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PostgresEndpointRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) + CreateTime *types.Time `json:"create_time,omitempty"` + UpdateTime *types.Time `json:"update_time,omitempty"` } type ResourcePostgresEndpoint struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } type PostgresEndpointState = resources.PostgresEndpointConfig -func (*ResourcePostgresEndpoint) New(client *databricks.WorkspaceClient) *ResourcePostgresEndpoint { +func (*ResourcePostgresEndpoint) New(client *sdkclients.Clients) *ResourcePostgresEndpoint { return &ResourcePostgresEndpoint{client: client} } @@ -82,29 +72,33 @@ func (*ResourcePostgresEndpoint) RemapState(remote *PostgresEndpointRemote) *Pos // GET does not echo spec today (only status is returned); the embedded spec fields // stay at their zero values, and postgres_endpoints.yml suppresses phantom drift via // ignore_remote_changes with reason spec:input_only. -func makePostgresEndpointRemote(endpoint *postgres.Endpoint) *PostgresEndpointRemote { +func makePostgresEndpointRemote(resp *sdkpostgres.Endpoint) (*PostgresEndpointRemote, error) { + endpoint, err := postgres.EndpointFromSDK(resp) + if err != nil { + return nil, err + } var spec postgres.EndpointSpec if endpoint.Spec != nil { spec = *endpoint.Spec } return &PostgresEndpointRemote{ EndpointSpec: spec, - EndpointId: endpoint.EndpointId, - Parent: endpoint.Parent, - Name: endpoint.Name, + EndpointId: utils.Deref(endpoint.EndpointId), + Parent: utils.Deref(endpoint.Parent), + Name: utils.Deref(endpoint.Name), Status: endpoint.Status, - Uid: endpoint.Uid, + Uid: utils.Deref(endpoint.Uid), CreateTime: endpoint.CreateTime, UpdateTime: endpoint.UpdateTime, - } + }, nil } func (r *ResourcePostgresEndpoint) DoRead(ctx context.Context, id string) (*PostgresEndpointRemote, error) { - endpoint, err := r.client.Postgres.GetEndpoint(ctx, postgres.GetEndpointRequest{Name: id}) + endpoint, err := r.client.Postgres.GetEndpoint(ctx, sdkpostgres.GetEndpointRequest{Name: new(id)}) if err != nil { return nil, err } - return makePostgresEndpointRemote(endpoint), nil + return makePostgresEndpointRemote(endpoint) } // waitForReconciliation polls the endpoint until PendingState is empty. @@ -113,14 +107,14 @@ func (r *ResourcePostgresEndpoint) DoRead(ctx context.Context, id string) (*Post func (r *ResourcePostgresEndpoint) waitForReconciliation(ctx context.Context, name string) (*PostgresEndpointRemote, error) { deadline := time.Now().Add(endpointReconciliationTimeout) for { - endpoint, err := r.client.Postgres.GetEndpoint(ctx, postgres.GetEndpointRequest{Name: name}) + endpoint, err := r.client.Postgres.GetEndpoint(ctx, sdkpostgres.GetEndpointRequest{Name: new(name)}) if err != nil { return nil, err } // If there's no pending state, reconciliation is complete if endpoint.Status == nil || endpoint.Status.PendingState == "" { - return makePostgresEndpointRemote(endpoint), nil + return makePostgresEndpointRemote(endpoint) } // Check if we've exceeded the timeout @@ -138,28 +132,29 @@ func (r *ResourcePostgresEndpoint) waitForReconciliation(ctx context.Context, na } func (r *ResourcePostgresEndpoint) DoCreate(ctx context.Context, config *PostgresEndpointState) (string, *PostgresEndpointRemote, error) { - waiter, err := r.client.Postgres.CreateEndpoint(ctx, postgres.CreateEndpointRequest{ - EndpointId: config.EndpointId, - Parent: config.Parent, - Endpoint: postgres.Endpoint{ - Spec: &config.EndpointSpec, - - // Output-only fields. - EndpointId: "", - CreateTime: nil, - Name: "", - Parent: "", - Status: nil, - Uid: "", - UpdateTime: nil, - ForceSendFields: nil, + // Only spec is set; the other Endpoint fields are output-only. + request, err := postgres.CreateEndpointRequestToSDK(&postgres.CreateEndpointRequest{ + EndpointId: nonEmpty(config.EndpointId), + Parent: nonEmpty(config.Parent), + Endpoint: &postgres.Endpoint{ + Spec: &config.EndpointSpec, + CreateTime: nil, // Not set by DABs + EndpointId: nil, // Not set by DABs + Name: nil, // Not set by DABs + Parent: nil, // Not set by DABs + Status: nil, // Not set by DABs + Uid: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs }, - ReplaceExisting: config.ReplaceExisting, - ForceSendFields: nil, + ReplaceExisting: trueOrNil(config.ReplaceExisting), }) if err != nil { return "", nil, err } + waiter, err := r.client.Postgres.CreateEndpoint(ctx, *request) + if err != nil { + return "", nil, err + } // Wait for the operation to complete result, err := waiter.Wait(ctx) @@ -168,7 +163,7 @@ func (r *ResourcePostgresEndpoint) DoCreate(ctx context.Context, config *Postgre } // Wait for reconciliation to complete - remote, err := r.waitForReconciliation(ctx, result.Name) + remote, err := r.waitForReconciliation(ctx, utils.Deref(result.Name)) if err != nil { return "", nil, err } @@ -176,8 +171,8 @@ func (r *ResourcePostgresEndpoint) DoCreate(ctx context.Context, config *Postgre return remote.Name, remote, nil } -// no_suspension and suspend_timeout_duration are two sides of one oneof, which the API -// accepts in update_mask only under the group name; see branchOneofGroups. +// no_suspension and suspend_timeout_duration are two sides of one oneof, and the API +// accepts them in update_mask only under the group name "suspension". var endpointOneofGroups = map[string]string{ "no_suspension": "suspension", "suspend_timeout_duration": "suspension", @@ -190,35 +185,21 @@ func (r *ResourcePostgresEndpoint) DoUpdate(ctx context.Context, id string, conf // not relative to our flattened state type. fieldPaths := collectUpdatePathsWithPrefix(entry.Changes, "spec.", endpointOneofGroups) - waiter, err := r.client.Postgres.UpdateEndpoint(ctx, postgres.UpdateEndpointRequest{ - Endpoint: postgres.Endpoint{ - Spec: &config.EndpointSpec, - - // Output-only fields. - EndpointId: "", - CreateTime: nil, - Name: "", - Parent: "", - Status: nil, - Uid: "", - UpdateTime: nil, - ForceSendFields: nil, - }, - Name: id, - UpdateMask: fieldmask.FieldMask{ - Paths: fieldPaths, - }, + // Only spec is set; the other Endpoint fields are output-only. + _, err := updatePostgres[postgres.Endpoint](ctx, r.client, id, strings.Join(fieldPaths, ","), &postgres.Endpoint{ + Spec: &config.EndpointSpec, + CreateTime: nil, // Not set by DABs + EndpointId: nil, // Not set by DABs + Name: nil, // Not set by DABs + Parent: nil, // Not set by DABs + Status: nil, // Not set by DABs + Uid: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs }) if err != nil { return nil, err } - // Wait for the update to complete - _, err = waiter.Wait(ctx) - if err != nil { - return nil, err - } - // Wait for reconciliation to complete return r.waitForReconciliation(ctx, id) } @@ -227,13 +208,12 @@ func (r *ResourcePostgresEndpoint) DoDelete(ctx context.Context, id string, _ *P // Retry loop to handle "Endpoint reconciliation still in progress" errors deadline := time.Now().Add(endpointReconciliationTimeout) for { - waiter, err := r.client.Postgres.DeleteEndpoint(ctx, postgres.DeleteEndpointRequest{ - Name: id, + waiter, err := r.client.Postgres.DeleteEndpoint(ctx, sdkpostgres.DeleteEndpointRequest{ + Name: new(id), }) if err != nil { // Check if this is a reconciliation in progress error - if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.StatusCode == http.StatusConflict && - strings.Contains(apiErr.Message, "reconciliation") { + if apierrs.StatusCode(err) == http.StatusConflict && strings.Contains(apierrs.Message(err), "reconciliation") { // Check if we've exceeded the timeout if time.Now().After(deadline) { return errors.New("timeout waiting for endpoint reconciliation to complete before delete") diff --git a/bundle/direct/dresources/postgres_project.go b/bundle/direct/dresources/postgres_project.go index bdb886e9437..1bece70a423 100644 --- a/bundle/direct/dresources/postgres_project.go +++ b/bundle/direct/dresources/postgres_project.go @@ -3,13 +3,14 @@ package dresources import ( "context" "slices" + "strings" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/sdkclients" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/types" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" ) // PostgresProjectRemote is the return type for DoRead. It embeds ProjectSpec so @@ -24,38 +25,27 @@ type PostgresProjectRemote struct { Name string `json:"name,omitempty"` Status *postgres.ProjectStatus `json:"status,omitempty"` Uid string `json:"uid,omitempty"` - CreateTime *sdktime.Time `json:"create_time,omitempty"` - DeleteTime *sdktime.Time `json:"delete_time,omitempty"` - PurgeTime *sdktime.Time `json:"purge_time,omitempty"` - UpdateTime *sdktime.Time `json:"update_time,omitempty"` -} - -// Custom marshaler needed because embedded ProjectSpec has its own MarshalJSON -// which would otherwise take over and ignore the additional fields. -func (s *PostgresProjectRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PostgresProjectRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) + CreateTime *types.Time `json:"create_time,omitempty"` + DeleteTime *types.Time `json:"delete_time,omitempty"` + PurgeTime *types.Time `json:"purge_time,omitempty"` + UpdateTime *types.Time `json:"update_time,omitempty"` } type ResourcePostgresProject struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } type PostgresProjectState = resources.PostgresProjectConfig -func (*ResourcePostgresProject) New(client *databricks.WorkspaceClient) *ResourcePostgresProject { +func (*ResourcePostgresProject) New(client *sdkclients.Clients) *ResourcePostgresProject { return &ResourcePostgresProject{client: client} } func (*ResourcePostgresProject) PrepareState(input *resources.PostgresProject) *PostgresProjectState { return &PostgresProjectState{ - ProjectId: input.ProjectId, - PurgeOnDelete: input.PurgeOnDelete, - ProjectSpec: input.ProjectSpec, - ForceSendFields: input.ForceSendFields, + ProjectId: input.ProjectId, + PurgeOnDelete: input.PurgeOnDelete, + ProjectSpec: input.ProjectSpec, } } @@ -65,9 +55,8 @@ func (*ResourcePostgresProject) RemapState(remote *PostgresProjectRemote) *Postg ProjectSpec: remote.ProjectSpec, // purge_on_delete is a delete-time query parameter; the GET API never - // returns it, so RemapState leaves it false. - PurgeOnDelete: false, - ForceSendFields: nil, + // returns it, so RemapState leaves it unset. + PurgeOnDelete: nil, } } @@ -75,56 +64,62 @@ func (*ResourcePostgresProject) RemapState(remote *PostgresProjectRemote) *Postg // GET does not echo spec today (only status is returned); the embedded spec fields // stay at their zero values, and postgres_projects.yml suppresses phantom drift via // ignore_remote_changes with reason spec:input_only. -func makePostgresProjectRemote(project *postgres.Project) *PostgresProjectRemote { +func makePostgresProjectRemote(resp *sdkpostgres.Project) (*PostgresProjectRemote, error) { + project, err := postgres.ProjectFromSDK(resp) + if err != nil { + return nil, err + } var spec postgres.ProjectSpec if project.Spec != nil { spec = *project.Spec } return &PostgresProjectRemote{ ProjectSpec: spec, - ProjectId: project.ProjectId, + ProjectId: utils.Deref(project.ProjectId), InitialEndpointSpec: project.InitialEndpointSpec, - Name: project.Name, + Name: utils.Deref(project.Name), Status: project.Status, - Uid: project.Uid, + Uid: utils.Deref(project.Uid), CreateTime: project.CreateTime, DeleteTime: project.DeleteTime, PurgeTime: project.PurgeTime, UpdateTime: project.UpdateTime, - } + }, nil } func (r *ResourcePostgresProject) DoRead(ctx context.Context, id string) (*PostgresProjectRemote, error) { - project, err := r.client.Postgres.GetProject(ctx, postgres.GetProjectRequest{Name: id}) + project, err := r.client.Postgres.GetProject(ctx, sdkpostgres.GetProjectRequest{Name: new(id)}) if err != nil { return nil, err } - return makePostgresProjectRemote(project), nil + return makePostgresProjectRemote(project) } func (r *ResourcePostgresProject) DoCreate(ctx context.Context, config *PostgresProjectState) (string, *PostgresProjectRemote, error) { - waiter, err := r.client.Postgres.CreateProject(ctx, postgres.CreateProjectRequest{ - ProjectId: config.ProjectId, - Project: postgres.Project{ + // Only spec is set; the other Project fields are output-only. + request, err := postgres.CreateProjectRequestToSDK(&postgres.CreateProjectRequest{ + ProjectId: nonEmpty(config.ProjectId), + Project: &postgres.Project{ Spec: &config.ProjectSpec, - InitialBranchSpec: nil, - InitialEndpointSpec: nil, - - // Output-only fields. - ProjectId: "", - CreateTime: nil, - DeleteTime: nil, - Name: "", - PurgeTime: nil, - Status: nil, - Uid: "", - UpdateTime: nil, - ForceSendFields: nil, + CreateTime: nil, // Not set by DABs + DeleteTime: nil, // Not set by DABs + InitialBranchSpec: nil, // Not set by DABs + InitialEndpointSpec: nil, // Not set by DABs + Name: nil, // Not set by DABs + ProjectId: nil, // Not set by DABs + PurgeTime: nil, // Not set by DABs + Status: nil, // Not set by DABs + Uid: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs }, }) if err != nil { return "", nil, err } + waiter, err := r.client.Postgres.CreateProject(ctx, *request) + if err != nil { + return "", nil, err + } // Wait for the project to be ready (long-running operation) result, err := waiter.Wait(ctx) @@ -132,12 +127,15 @@ func (r *ResourcePostgresProject) DoCreate(ctx context.Context, config *Postgres return "", nil, err } - remote := makePostgresProjectRemote(result) + remote, err := makePostgresProjectRemote(result) + if err != nil { + return "", nil, err + } return remote.Name, remote, nil } -// The default endpoint settings carry the same suspension oneof as an endpoint does; -// see branchOneofGroups. +// The default endpoint settings carry the same suspension oneof as an endpoint does, +// which the API accepts in update_mask only under the group name "suspension". var projectOneofGroups = map[string]string{ "default_endpoint_settings.no_suspension": "default_endpoint_settings.suspension", "default_endpoint_settings.suspend_timeout_duration": "default_endpoint_settings.suspension", @@ -163,45 +161,34 @@ func (r *ResourcePostgresProject) DoUpdate(ctx context.Context, id string, confi return nil, nil } - waiter, err := r.client.Postgres.UpdateProject(ctx, postgres.UpdateProjectRequest{ - Project: postgres.Project{ - Spec: &config.ProjectSpec, - InitialBranchSpec: nil, - InitialEndpointSpec: nil, - - // Output-only fields. - ProjectId: "", - CreateTime: nil, - DeleteTime: nil, - Name: "", - PurgeTime: nil, - Status: nil, - Uid: "", - UpdateTime: nil, - ForceSendFields: nil, - }, - Name: id, - UpdateMask: fieldmask.FieldMask{ - Paths: fieldPaths, - }, + // Only spec is set; the other Project fields are output-only. + updated, err := updatePostgres[postgres.Project](ctx, r.client, id, strings.Join(fieldPaths, ","), &postgres.Project{ + Spec: &config.ProjectSpec, + CreateTime: nil, // Not set by DABs + DeleteTime: nil, // Not set by DABs + InitialBranchSpec: nil, // Not set by DABs + InitialEndpointSpec: nil, // Not set by DABs + Name: nil, // Not set by DABs + ProjectId: nil, // Not set by DABs + PurgeTime: nil, // Not set by DABs + Status: nil, // Not set by DABs + Uid: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs }) if err != nil { return nil, err } - - // Wait for the update to complete - result, err := waiter.Wait(ctx) + result, err := postgres.ProjectToSDK(updated) if err != nil { return nil, err } - return makePostgresProjectRemote(result), nil + return makePostgresProjectRemote(result) } func (r *ResourcePostgresProject) DoDelete(ctx context.Context, id string, state *PostgresProjectState) error { - waiter, err := r.client.Postgres.DeleteProject(ctx, postgres.DeleteProjectRequest{ - Name: id, - Purge: state.PurgeOnDelete, - ForceSendFields: nil, + waiter, err := r.client.Postgres.DeleteProject(ctx, sdkpostgres.DeleteProjectRequest{ + Name: new(id), + Purge: trueOrNil(utils.Deref(state.PurgeOnDelete)), }) if err != nil { return err diff --git a/bundle/direct/dresources/postgres_role.go b/bundle/direct/dresources/postgres_role.go index 10ef250e37c..2b928c6cf34 100644 --- a/bundle/direct/dresources/postgres_role.go +++ b/bundle/direct/dresources/postgres_role.go @@ -2,17 +2,18 @@ package dresources import ( "context" + "strings" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/sdkclients" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/types" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" ) type ResourcePostgresRole struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } // PostgresRoleState keeps role_id and parent as separate fields rather than a @@ -22,7 +23,7 @@ type ResourcePostgresRole struct { // from input.Parent at PrepareState time would keep the literal ${...} string // when parent comes from a resource reference. type PostgresRoleState struct { - postgres.RoleRoleSpec + postgres.Role_RoleSpec // RoleId is the leaf id, matching the user-facing config. RoleId string `json:"role_id"` @@ -35,40 +36,22 @@ type PostgresRoleState struct { ReplaceExisting bool `json:"replace_existing,omitempty"` } -// PostgresRoleRemote is the return type for DoRead. It embeds RoleRoleSpec so that +// PostgresRoleRemote is the return type for DoRead. It embeds Role_RoleSpec so that // all paths in StateType are valid paths in RemoteType, enabling drift detection // for spec fields once the backend echoes spec on GET. type PostgresRoleRemote struct { - postgres.RoleRoleSpec + postgres.Role_RoleSpec RoleId string `json:"role_id,omitempty"` Parent string `json:"parent,omitempty"` - Name string `json:"name,omitempty"` - Status *postgres.RoleRoleStatus `json:"status,omitempty"` - CreateTime *sdktime.Time `json:"create_time,omitempty"` - UpdateTime *sdktime.Time `json:"update_time,omitempty"` + Name string `json:"name,omitempty"` + Status *postgres.Role_RoleStatus `json:"status,omitempty"` + CreateTime *types.Time `json:"create_time,omitempty"` + UpdateTime *types.Time `json:"update_time,omitempty"` } -// Custom marshalers needed because embedded RoleRoleSpec has its own MarshalJSON -// which would otherwise take over and ignore the additional fields. -func (s *PostgresRoleState) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PostgresRoleState) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (s *PostgresRoleRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PostgresRoleRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (*ResourcePostgresRole) New(client *databricks.WorkspaceClient) *ResourcePostgresRole { +func (*ResourcePostgresRole) New(client *sdkclients.Clients) *ResourcePostgresRole { return &ResourcePostgresRole{client: client} } @@ -77,7 +60,7 @@ func (*ResourcePostgresRole) PrepareState(input *resources.PostgresRole) *Postgr RoleId: input.RoleId, Parent: input.Parent, ReplaceExisting: input.ReplaceExisting, - RoleRoleSpec: input.RoleRoleSpec, + Role_RoleSpec: input.Role_RoleSpec, } } @@ -90,7 +73,7 @@ func (*ResourcePostgresRole) RemapState(remote *PostgresRoleRemote) *PostgresRol // it, so RemapState leaves it false. ReplaceExisting: false, - RoleRoleSpec: remote.RoleRoleSpec, + Role_RoleSpec: remote.Role_RoleSpec, } } @@ -98,59 +81,66 @@ func (*ResourcePostgresRole) RemapState(remote *PostgresRoleRemote) *PostgresRol // GET does not echo spec today (only status is returned); the embedded spec fields // stay at their zero values, and postgres_roles.yml suppresses phantom drift via // ignore_remote_changes with reason spec:input_only. -func makePostgresRoleRemote(role *postgres.Role) *PostgresRoleRemote { - var spec postgres.RoleRoleSpec +func makePostgresRoleRemote(resp *sdkpostgres.Role) (*PostgresRoleRemote, error) { + role, err := postgres.RoleFromSDK(resp) + if err != nil { + return nil, err + } + var spec postgres.Role_RoleSpec if role.Spec != nil { spec = *role.Spec } return &PostgresRoleRemote{ - RoleRoleSpec: spec, - RoleId: role.RoleId, - Parent: role.Parent, - Name: role.Name, - Status: role.Status, - CreateTime: role.CreateTime, - UpdateTime: role.UpdateTime, - } + Role_RoleSpec: spec, + RoleId: utils.Deref(role.RoleId), + Parent: utils.Deref(role.Parent), + Name: utils.Deref(role.Name), + Status: role.Status, + CreateTime: role.CreateTime, + UpdateTime: role.UpdateTime, + }, nil } func (r *ResourcePostgresRole) DoRead(ctx context.Context, id string) (*PostgresRoleRemote, error) { - role, err := r.client.Postgres.GetRole(ctx, postgres.GetRoleRequest{Name: id}) + role, err := r.client.Postgres.GetRole(ctx, sdkpostgres.GetRoleRequest{Name: new(id)}) if err != nil { return nil, err } - return makePostgresRoleRemote(role), nil + return makePostgresRoleRemote(role) } func (r *ResourcePostgresRole) DoCreate(ctx context.Context, config *PostgresRoleState) (string, *PostgresRoleRemote, error) { - waiter, err := r.client.Postgres.CreateRole(ctx, postgres.CreateRoleRequest{ - RoleId: config.RoleId, - Parent: config.Parent, - Role: postgres.Role{ - Spec: &config.RoleRoleSpec, - - // Output-only fields. - RoleId: "", - CreateTime: nil, - Name: "", - Parent: "", - Status: nil, - UpdateTime: nil, - ForceSendFields: nil, + request, err := postgres.CreateRoleRequestToSDK(&postgres.CreateRoleRequest{ + RoleId: nonEmpty(config.RoleId), + Parent: nonEmpty(config.Parent), + ReplaceExisting: trueOrNil(config.ReplaceExisting), + Role: &postgres.Role{ + Spec: &config.Role_RoleSpec, + CreateTime: nil, // Not set by DABs + Name: nil, // Not set by DABs + Parent: nil, // Not set by DABs + RoleId: nil, // Not set by DABs + Status: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs }, - ReplaceExisting: config.ReplaceExisting, - ForceSendFields: nil, }) if err != nil { return "", nil, err } + waiter, err := r.client.Postgres.CreateRole(ctx, *request) + if err != nil { + return "", nil, err + } result, err := waiter.Wait(ctx) if err != nil { return "", nil, err } - remote := makePostgresRoleRemote(result) + remote, err := makePostgresRoleRemote(result) + if err != nil { + return "", nil, err + } return remote.Name, remote, nil } @@ -160,44 +150,36 @@ func (r *ResourcePostgresRole) DoUpdate(ctx context.Context, id string, config * // object, not relative to our flattened state type. fieldPaths := collectUpdatePathsWithPrefix(entry.Changes, "spec.", nil) - waiter, err := r.client.Postgres.UpdateRole(ctx, postgres.UpdateRoleRequest{ - Name: id, - Role: postgres.Role{ - Spec: &config.RoleRoleSpec, - - // Output-only fields. - RoleId: "", - CreateTime: nil, - Name: "", - Parent: "", - Status: nil, - UpdateTime: nil, - ForceSendFields: nil, - }, - UpdateMask: fieldmask.FieldMask{ - Paths: fieldPaths, + request, err := postgres.UpdateRoleRequestToSDK(&postgres.UpdateRoleRequest{ + Role: &postgres.Role{ + Name: new(id), Spec: &config.Role_RoleSpec, + CreateTime: nil, // Not set by DABs + Parent: nil, // Not set by DABs + RoleId: nil, // Not set by DABs + Status: nil, // Not set by DABs + UpdateTime: nil, // Not set by DABs }, + UpdateMask: new(strings.Join(fieldPaths, ",")), }) if err != nil { return nil, err } + waiter, err := r.client.Postgres.UpdateRole(ctx, *request) + if err != nil { + return nil, err + } result, err := waiter.Wait(ctx) if err != nil { return nil, err } - return makePostgresRoleRemote(result), nil + return makePostgresRoleRemote(result) } func (r *ResourcePostgresRole) DoDelete(ctx context.Context, id string, _ *PostgresRoleState) error { - waiter, err := r.client.Postgres.DeleteRole(ctx, postgres.DeleteRoleRequest{ - Name: id, - - // ReassignOwnedTo is intentionally unset; honoring it would require - // user-facing config we don't expose, and it would spin up compute to - // run reassignment SQL. - ReassignOwnedTo: "", - ForceSendFields: nil, + waiter, err := r.client.Postgres.DeleteRole(ctx, sdkpostgres.DeleteRoleRequest{ + Name: new(id), + ReassignOwnedTo: nil, // Not set by DABs }) if err != nil { return err diff --git a/bundle/direct/dresources/postgres_snapshot_schedule.go b/bundle/direct/dresources/postgres_snapshot_schedule.go index 3f73e8c729f..ffdce07e321 100644 --- a/bundle/direct/dresources/postgres_snapshot_schedule.go +++ b/bundle/direct/dresources/postgres_snapshot_schedule.go @@ -5,10 +5,10 @@ import ( "strings" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/sdkclients" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" ) // snapshotScheduleSuffix is the final segment of a snapshot schedule's resource @@ -31,57 +31,51 @@ type PostgresSnapshotScheduleRemote struct { Name string `json:"name,omitempty"` } -func (s *PostgresSnapshotScheduleRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PostgresSnapshotScheduleRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - type ResourcePostgresSnapshotSchedule struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } type PostgresSnapshotScheduleState = resources.PostgresSnapshotScheduleConfig -func (*ResourcePostgresSnapshotSchedule) New(client *databricks.WorkspaceClient) *ResourcePostgresSnapshotSchedule { +func (*ResourcePostgresSnapshotSchedule) New(client *sdkclients.Clients) *ResourcePostgresSnapshotSchedule { return &ResourcePostgresSnapshotSchedule{client: client} } func (*ResourcePostgresSnapshotSchedule) PrepareState(input *resources.PostgresSnapshotSchedule) *PostgresSnapshotScheduleState { return &PostgresSnapshotScheduleState{ - Branch: input.Branch, - Schedule: input.Schedule, - ForceSendFields: input.ForceSendFields, + Branch: input.Branch, + Schedule: input.Schedule, } } func (*ResourcePostgresSnapshotSchedule) RemapState(remote *PostgresSnapshotScheduleRemote) *PostgresSnapshotScheduleState { return &PostgresSnapshotScheduleState{ - Branch: remote.Branch, - Schedule: remote.Schedule, - ForceSendFields: nil, + Branch: remote.Branch, + Schedule: remote.Schedule, } } // makePostgresSnapshotScheduleRemote converts the SDK SnapshotSchedule into the // remote shape. The API addresses the schedule by "{branch}/snapshot-schedule"; // branch is derived by stripping that suffix so it participates in drift detection. -func makePostgresSnapshotScheduleRemote(schedule *postgres.SnapshotSchedule) *PostgresSnapshotScheduleRemote { +func makePostgresSnapshotScheduleRemote(resp *sdkpostgres.SnapshotSchedule) (*PostgresSnapshotScheduleRemote, error) { + schedule, err := postgres.SnapshotScheduleFromSDK(resp) + if err != nil { + return nil, err + } return &PostgresSnapshotScheduleRemote{ - Branch: strings.TrimSuffix(schedule.Name, snapshotScheduleSuffix), + Branch: strings.TrimSuffix(utils.Deref(schedule.Name), snapshotScheduleSuffix), Schedule: schedule.Schedule, - Name: schedule.Name, - } + Name: utils.Deref(schedule.Name), + }, nil } func (r *ResourcePostgresSnapshotSchedule) DoRead(ctx context.Context, id string) (*PostgresSnapshotScheduleRemote, error) { - schedule, err := r.client.Postgres.GetSnapshotSchedule(ctx, postgres.GetSnapshotScheduleRequest{Name: id}) + schedule, err := r.client.Postgres.GetSnapshotSchedule(ctx, sdkpostgres.GetSnapshotScheduleRequest{Name: new(id)}) if err != nil { return nil, err } - return makePostgresSnapshotScheduleRemote(schedule), nil + return makePostgresSnapshotScheduleRemote(schedule) } // updateSnapshotSchedule sets the branch's schedule to the given cadences and @@ -89,23 +83,18 @@ func (r *ResourcePostgresSnapshotSchedule) DoRead(ctx context.Context, id string // behind create, update, and delete: there is no Create/DeleteSnapshotSchedule // endpoint, so the schedule is managed entirely through UpdateSnapshotSchedule. // schedule is the only updatable path, so a static mask is used. -func (r *ResourcePostgresSnapshotSchedule) updateSnapshotSchedule(ctx context.Context, name string, cadences []postgres.ScheduleCadence) (*postgres.SnapshotSchedule, error) { - waiter, err := r.client.Postgres.UpdateSnapshotSchedule(ctx, postgres.UpdateSnapshotScheduleRequest{ - Name: name, - SnapshotSchedule: postgres.SnapshotSchedule{ - Schedule: cadences, - - // Name is carried in the request's Name field, not the body. - Name: "", - ForceSendFields: nil, - }, - UpdateMask: fieldmask.FieldMask{ - Paths: []string{"schedule"}, - }, +func (r *ResourcePostgresSnapshotSchedule) updateSnapshotSchedule(ctx context.Context, name string, cadences []postgres.ScheduleCadence) (*sdkpostgres.SnapshotSchedule, error) { + request, err := postgres.UpdateSnapshotScheduleRequestToSDK(&postgres.UpdateSnapshotScheduleRequest{ + SnapshotSchedule: &postgres.SnapshotSchedule{Name: new(name), Schedule: cadences}, + UpdateMask: new("schedule"), }) if err != nil { return nil, err } + waiter, err := r.client.Postgres.UpdateSnapshotSchedule(ctx, *request) + if err != nil { + return nil, err + } return waiter.Wait(ctx) } @@ -116,7 +105,10 @@ func (r *ResourcePostgresSnapshotSchedule) DoCreate(ctx context.Context, config if err != nil { return "", nil, err } - remote := makePostgresSnapshotScheduleRemote(result) + remote, err := makePostgresSnapshotScheduleRemote(result) + if err != nil { + return "", nil, err + } return remote.Name, remote, nil } @@ -125,7 +117,7 @@ func (r *ResourcePostgresSnapshotSchedule) DoUpdate(ctx context.Context, id stri if err != nil { return nil, err } - return makePostgresSnapshotScheduleRemote(result), nil + return makePostgresSnapshotScheduleRemote(result) } func (r *ResourcePostgresSnapshotSchedule) DoDelete(ctx context.Context, id string, _ *PostgresSnapshotScheduleState) error { diff --git a/bundle/direct/dresources/postgres_synced_table.go b/bundle/direct/dresources/postgres_synced_table.go index f194df54e61..be1eb66eb2b 100644 --- a/bundle/direct/dresources/postgres_synced_table.go +++ b/bundle/direct/dresources/postgres_synced_table.go @@ -6,11 +6,12 @@ import ( "time" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/retries" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/bundle/direct/internal/retries" + "github.com/databricks/cli/libs/sdkclients" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/types" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" ) // deleteSyncedTableTimeout caps the post-delete poll so a stuck teardown does not @@ -19,51 +20,41 @@ import ( const deleteSyncedTableTimeout = 5 * time.Minute // PostgresSyncedTableRemote is the return type for DoRead. It embeds -// SyncedTableSyncedTableSpec so that all paths in StateType are valid paths in +// SyncedTable_SyncedTableSpec so that all paths in StateType are valid paths in // RemoteType, enabling drift detection for spec fields once the backend echoes // spec on GET. type PostgresSyncedTableRemote struct { - postgres.SyncedTableSyncedTableSpec + postgres.SyncedTable_SyncedTableSpec SyncedTableId string `json:"synced_table_id,omitempty"` - Name string `json:"name,omitempty"` - Status *postgres.SyncedTableSyncedTableStatus `json:"status,omitempty"` - Uid string `json:"uid,omitempty"` - CreateTime *sdktime.Time `json:"create_time,omitempty"` -} - -// Custom marshaler needed because embedded SyncedTableSyncedTableSpec has its own -// MarshalJSON which would otherwise take over and ignore the additional fields. -func (s *PostgresSyncedTableRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s PostgresSyncedTableRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) + Name string `json:"name,omitempty"` + Status *postgres.SyncedTable_SyncedTableStatus `json:"status,omitempty"` + Uid string `json:"uid,omitempty"` + CreateTime *types.Time `json:"create_time,omitempty"` } type ResourcePostgresSyncedTable struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } type PostgresSyncedTableState = resources.PostgresSyncedTableConfig -func (*ResourcePostgresSyncedTable) New(client *databricks.WorkspaceClient) *ResourcePostgresSyncedTable { +func (*ResourcePostgresSyncedTable) New(client *sdkclients.Clients) *ResourcePostgresSyncedTable { return &ResourcePostgresSyncedTable{client: client} } func (*ResourcePostgresSyncedTable) PrepareState(input *resources.PostgresSyncedTable) *PostgresSyncedTableState { return &PostgresSyncedTableState{ - SyncedTableId: input.SyncedTableId, - SyncedTableSyncedTableSpec: input.SyncedTableSyncedTableSpec, + SyncedTableId: input.SyncedTableId, + SyncedTable_SyncedTableSpec: input.SyncedTable_SyncedTableSpec, } } func (*ResourcePostgresSyncedTable) RemapState(remote *PostgresSyncedTableRemote) *PostgresSyncedTableState { return &PostgresSyncedTableState{ - SyncedTableId: remote.SyncedTableId, - SyncedTableSyncedTableSpec: remote.SyncedTableSyncedTableSpec, + SyncedTableId: remote.SyncedTableId, + SyncedTable_SyncedTableSpec: remote.SyncedTable_SyncedTableSpec, } } @@ -75,60 +66,66 @@ func (*ResourcePostgresSyncedTable) RemapState(remote *PostgresSyncedTableRemote // The synced-table API doesn't expose the user-facing id as a named field. It // only appears as the trailing component of remote.Name, so we strip the // constant "synced_tables/" prefix. -func makePostgresSyncedTableRemote(syncedTable *postgres.SyncedTable) *PostgresSyncedTableRemote { - var spec postgres.SyncedTableSyncedTableSpec +func makePostgresSyncedTableRemote(resp *sdkpostgres.SyncedTable) (*PostgresSyncedTableRemote, error) { + syncedTable, err := postgres.SyncedTableFromSDK(resp) + if err != nil { + return nil, err + } + var spec postgres.SyncedTable_SyncedTableSpec if syncedTable.Spec != nil { spec = *syncedTable.Spec } return &PostgresSyncedTableRemote{ - SyncedTableSyncedTableSpec: spec, - SyncedTableId: strings.TrimPrefix(syncedTable.Name, "synced_tables/"), - Name: syncedTable.Name, - Status: syncedTable.Status, - Uid: syncedTable.Uid, - CreateTime: syncedTable.CreateTime, - } + SyncedTable_SyncedTableSpec: spec, + SyncedTableId: strings.TrimPrefix(utils.Deref(syncedTable.Name), "synced_tables/"), + Name: utils.Deref(syncedTable.Name), + Status: syncedTable.Status, + Uid: utils.Deref(syncedTable.Uid), + CreateTime: syncedTable.CreateTime, + }, nil } func (r *ResourcePostgresSyncedTable) DoRead(ctx context.Context, id string) (*PostgresSyncedTableRemote, error) { - syncedTable, err := r.client.Postgres.GetSyncedTable(ctx, postgres.GetSyncedTableRequest{Name: id}) + syncedTable, err := r.client.Postgres.GetSyncedTable(ctx, sdkpostgres.GetSyncedTableRequest{Name: new(id)}) if err != nil { return nil, err } - return makePostgresSyncedTableRemote(syncedTable), nil + return makePostgresSyncedTableRemote(syncedTable) } func (r *ResourcePostgresSyncedTable) DoCreate(ctx context.Context, config *PostgresSyncedTableState) (string, *PostgresSyncedTableRemote, error) { - waiter, err := r.client.Postgres.CreateSyncedTable(ctx, postgres.CreateSyncedTableRequest{ - SyncedTableId: config.SyncedTableId, - SyncedTable: postgres.SyncedTable{ - Spec: &config.SyncedTableSyncedTableSpec, - - // Output-only fields. - SyncedTableId: "", - CreateTime: nil, - Name: "", - Status: nil, - Uid: "", - ForceSendFields: nil, + request, err := postgres.CreateSyncedTableRequestToSDK(&postgres.CreateSyncedTableRequest{ + SyncedTableId: nonEmpty(config.SyncedTableId), + SyncedTable: &postgres.SyncedTable{ + Spec: &config.SyncedTable_SyncedTableSpec, + CreateTime: nil, // Not set by DABs + Name: nil, // Not set by DABs + Status: nil, // Not set by DABs + SyncedTableId: nil, // Not set by DABs + Uid: nil, // Not set by DABs }, }) if err != nil { return "", nil, err } + waiter, err := r.client.Postgres.CreateSyncedTable(ctx, *request) + if err != nil { + return "", nil, err + } result, err := waiter.Wait(ctx) if err != nil { return "", nil, err } - remote := makePostgresSyncedTableRemote(result) + remote, err := makePostgresSyncedTableRemote(result) + if err != nil { + return "", nil, err + } return remote.Name, remote, nil } func (r *ResourcePostgresSyncedTable) DoDelete(ctx context.Context, id string, _ *PostgresSyncedTableState) error { - waiter, err := r.client.Postgres.DeleteSyncedTable(ctx, postgres.DeleteSyncedTableRequest{ - Name: id, - }) + waiter, err := r.client.Postgres.DeleteSyncedTable(ctx, sdkpostgres.DeleteSyncedTableRequest{Name: new(id)}) if err != nil { return err } @@ -161,7 +158,7 @@ func (r *ResourcePostgresSyncedTable) WaitAfterDelete(ctx context.Context, id st } _, err := retries.Poll[struct{}](ctx, timeout, func() (*struct{}, *retries.Err) { - _, getErr := r.client.Postgres.GetSyncedTable(ctx, postgres.GetSyncedTableRequest{Name: id}) + _, getErr := r.client.Postgres.GetSyncedTable(ctx, sdkpostgres.GetSyncedTableRequest{Name: new(id)}) if getErr != nil { return nil, retries.Halt(getErr) } diff --git a/bundle/direct/dresources/postgres_update.go b/bundle/direct/dresources/postgres_update.go new file mode 100644 index 00000000000..668001f3614 --- /dev/null +++ b/bundle/direct/dresources/postgres_update.go @@ -0,0 +1,68 @@ +package dresources + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "net/http" + "time" + + "github.com/databricks/cli/bundle/direct/internal/retries" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" +) + +const postgresUpdateTimeout = 20 * time.Minute + +// updatePostgres sends PATCH /api/2.0/postgres/{name}?update_mask=... and waits +// for the resulting operation, decoding its response into T. +// +// The API takes oneof members in update_mask under their group name (e.g. +// "spec.expiration" for ttl/expire_time/no_expiry), which sdk-go's FieldMask +// rejects as an unknown field. Such updates are therefore sent without sdk-go. +func updatePostgres[T any](ctx context.Context, client *sdkclients.Clients, name, updateMask string, body any) (*T, error) { + api, err := apiclient.New(client.Config) + if err != nil { + return nil, err + } + var op postgres.Operation + err = api.Do(ctx, http.MethodPatch, "/api/2.0/postgres/"+name, nil, map[string]any{"update_mask": updateMask}, body, &op) + if err != nil { + return nil, err + } + opName := utils.Deref(op.Name) + if opName == "" { + return nil, errors.New("invalid operation response: missing name") + } + return retries.Poll(ctx, postgresUpdateTimeout, func() (*T, *retries.Err) { + if !utils.Deref(op.Done) { + op = postgres.Operation{ + Done: nil, // Not set by DABs + Error: nil, // Not set by DABs + Metadata: nil, // Not set by DABs + Name: nil, // Not set by DABs + Response: nil, // Not set by DABs + } + if err := api.Do(ctx, http.MethodGet, "/api/2.0/postgres/"+opName, nil, nil, nil, &op); err != nil { + return nil, retries.Halt(err) + } + if !utils.Deref(op.Done) { + return nil, retries.Continues("operation " + opName + " is still running") + } + } + if op.Error != nil { + return nil, retries.Halt(fmt.Errorf("operation failed: %s", utils.Deref(op.Error.Message))) + } + if len(op.Response) == 0 { + return nil, retries.Halt(errors.New("operation completed without a response")) + } + var result T + if err := json.Unmarshal(op.Response, &result); err != nil { + return nil, retries.Halt(fmt.Errorf("decode operation response: %w", err)) + } + return &result, nil + }) +} diff --git a/bundle/direct/dresources/quality_monitor.go b/bundle/direct/dresources/quality_monitor.go index c66fed4e0bb..f4a9fb7fa28 100644 --- a/bundle/direct/dresources/quality_monitor.go +++ b/bundle/direct/dresources/quality_monitor.go @@ -4,33 +4,22 @@ import ( "context" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/libs/qualitymonitors" + "github.com/databricks/cli/libs/sdkclients" ) type QualityMonitorState struct { - catalog.CreateMonitor + qualitymonitors.CreateMonitor - // The table name is a required field but not included as a JSON field in [catalog.CreateMonitor]. + // The table name is a required field but not included as a JSON field in [qualitymonitors.CreateMonitor]. TableName string `json:"table_name"` } -// We need to provide these custom marshaller from CreateMonitor takes over and ignores TableName field -func (s *QualityMonitorState) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s QualityMonitorState) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - type ResourceQualityMonitor struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceQualityMonitor) New(client *databricks.WorkspaceClient) *ResourceQualityMonitor { +func (*ResourceQualityMonitor) New(client *sdkclients.Clients) *ResourceQualityMonitor { return &ResourceQualityMonitor{client: client} } @@ -41,9 +30,9 @@ func (*ResourceQualityMonitor) PrepareState(input *resources.QualityMonitor) *Qu } } -func (*ResourceQualityMonitor) RemapState(info *catalog.MonitorInfo) *QualityMonitorState { +func (*ResourceQualityMonitor) RemapState(info *qualitymonitors.MonitorInfo) *QualityMonitorState { return &QualityMonitorState{ - CreateMonitor: catalog.CreateMonitor{ + CreateMonitor: qualitymonitors.CreateMonitor{ AssetsDir: info.AssetsDir, BaselineTableName: info.BaselineTableName, CustomMetrics: info.CustomMetrics, @@ -59,23 +48,20 @@ func (*ResourceQualityMonitor) RemapState(info *catalog.MonitorInfo) *QualityMon TableName: info.TableName, TimeSeries: info.TimeSeries, WarehouseId: "", - ForceSendFields: utils.FilterFields[catalog.CreateMonitor](info.ForceSendFields), }, TableName: info.TableName, } } -func (r *ResourceQualityMonitor) DoRead(ctx context.Context, id string) (*catalog.MonitorInfo, error) { - //nolint:staticcheck // Direct quality_monitor resource still uses legacy monitor endpoints; v1 data-quality migration is separate work. - return r.client.QualityMonitors.Get(ctx, catalog.GetQualityMonitorRequest{ +func (r *ResourceQualityMonitor) DoRead(ctx context.Context, id string) (*qualitymonitors.MonitorInfo, error) { + return r.client.QualityMonitors.Get(ctx, qualitymonitors.GetQualityMonitorRequest{ TableName: id, }) } -func (r *ResourceQualityMonitor) DoCreate(ctx context.Context, config *QualityMonitorState) (string, *catalog.MonitorInfo, error) { +func (r *ResourceQualityMonitor) DoCreate(ctx context.Context, config *QualityMonitorState) (string, *qualitymonitors.MonitorInfo, error) { req := config.CreateMonitor req.TableName = config.TableName - //nolint:staticcheck // Direct quality_monitor resource still uses legacy monitor endpoints; v1 data-quality migration is separate work. response, err := r.client.QualityMonitors.Create(ctx, req) if err != nil || response == nil { return "", nil, err @@ -83,8 +69,8 @@ func (r *ResourceQualityMonitor) DoCreate(ctx context.Context, config *QualityMo return response.TableName, response, nil } -func (r *ResourceQualityMonitor) DoUpdate(ctx context.Context, id string, config *QualityMonitorState, _ *PlanEntry) (*catalog.MonitorInfo, error) { - updateRequest := catalog.UpdateMonitor{ +func (r *ResourceQualityMonitor) DoUpdate(ctx context.Context, id string, config *QualityMonitorState, _ *PlanEntry) (*qualitymonitors.MonitorInfo, error) { + updateRequest := qualitymonitors.UpdateMonitor{ TableName: id, BaselineTableName: config.BaselineTableName, CustomMetrics: config.CustomMetrics, @@ -98,10 +84,8 @@ func (r *ResourceQualityMonitor) DoUpdate(ctx context.Context, id string, config SlicingExprs: config.SlicingExprs, Snapshot: config.Snapshot, TimeSeries: config.TimeSeries, - ForceSendFields: utils.FilterFields[catalog.UpdateMonitor](config.ForceSendFields), } - //nolint:staticcheck // Direct quality_monitor resource still uses legacy monitor endpoints; v1 data-quality migration is separate work. response, err := r.client.QualityMonitors.Update(ctx, updateRequest) if err != nil { return nil, err @@ -111,8 +95,7 @@ func (r *ResourceQualityMonitor) DoUpdate(ctx context.Context, id string, config } func (r *ResourceQualityMonitor) DoDelete(ctx context.Context, id string, _ *QualityMonitorState) error { - //nolint:staticcheck // Direct quality_monitor resource still uses legacy monitor endpoints; v1 data-quality migration is separate work. - _, err := r.client.QualityMonitors.Delete(ctx, catalog.DeleteQualityMonitorRequest{ + _, err := r.client.QualityMonitors.Delete(ctx, qualitymonitors.DeleteQualityMonitorRequest{ TableName: id, }) return err diff --git a/bundle/direct/dresources/registered_model.go b/bundle/direct/dresources/registered_model.go index 1a2fd468ebb..c26daba3d37 100644 --- a/bundle/direct/dresources/registered_model.go +++ b/bundle/direct/dresources/registered_model.go @@ -2,36 +2,35 @@ package dresources import ( "context" - "slices" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" + registeredmodels "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/catalog" + sdkregisteredmodels "github.com/databricks/sdk-go/uc/registeredmodels/v1" ) type ResourceRegisteredModel struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceRegisteredModel) New(client *databricks.WorkspaceClient) *ResourceRegisteredModel { +func (*ResourceRegisteredModel) New(client *sdkclients.Clients) *ResourceRegisteredModel { return &ResourceRegisteredModel{ client: client, } } -func (*ResourceRegisteredModel) PrepareState(input *resources.RegisteredModel) *catalog.CreateRegisteredModelRequest { +func (*ResourceRegisteredModel) PrepareState(input *resources.RegisteredModel) *registeredmodels.CreateRegisteredModelRequest { return &input.CreateRegisteredModelRequest } -func (*ResourceRegisteredModel) RemapState(model *catalog.RegisteredModelInfo) *catalog.CreateRegisteredModelRequest { - return &catalog.CreateRegisteredModelRequest{ +func (*ResourceRegisteredModel) RemapState(model *registeredmodels.RegisteredModelInfo) *registeredmodels.CreateRegisteredModelRequest { + return ®isteredmodels.CreateRegisteredModelRequest{ CatalogName: model.CatalogName, Comment: model.Comment, Name: model.Name, SchemaName: model.SchemaName, StorageLocation: model.StorageLocation, - ForceSendFields: utils.FilterFields[catalog.CreateRegisteredModelRequest](model.ForceSendFields), Aliases: model.Aliases, BrowseOnly: model.BrowseOnly, @@ -48,41 +47,48 @@ func (*ResourceRegisteredModel) RemapState(model *catalog.RegisteredModelInfo) * } } -func (r *ResourceRegisteredModel) DoRead(ctx context.Context, id string) (*catalog.RegisteredModelInfo, error) { - return r.client.RegisteredModels.Get(ctx, catalog.GetRegisteredModelRequest{ - FullName: id, - IncludeAliases: false, - IncludeBrowse: false, - ForceSendFields: nil, +func (r *ResourceRegisteredModel) DoRead(ctx context.Context, id string) (*registeredmodels.RegisteredModelInfo, error) { + info, err := r.client.RegisteredModels.GetRegisteredModel(ctx, sdkregisteredmodels.GetRegisteredModelRequest{ + FullNameArg: new(id), + IncludeAliases: nil, // Not set by DABs + IncludeBrowse: nil, // Not set by DABs }) + if err != nil { + return nil, err + } + return registeredmodels.RegisteredModelInfoFromSDK(info) } -func (r *ResourceRegisteredModel) DoCreate(ctx context.Context, config *catalog.CreateRegisteredModelRequest) (string, *catalog.RegisteredModelInfo, error) { - response, err := r.client.RegisteredModels.Create(ctx, *config) +func (r *ResourceRegisteredModel) DoCreate(ctx context.Context, config *registeredmodels.CreateRegisteredModelRequest) (string, *registeredmodels.RegisteredModelInfo, error) { + request, err := registeredmodels.CreateRegisteredModelRequestToSDK(config) if err != nil { return "", nil, err } - - return response.FullName, response, nil + response, err := r.client.RegisteredModels.CreateRegisteredModel(ctx, *request) + if err != nil { + return "", nil, err + } + info, err := registeredmodels.RegisteredModelInfoFromSDK(response) + if err != nil { + return "", nil, err + } + return utils.Deref(info.FullName), info, nil } -// See schemaForceSend. Verified against a real workspace: {"comment": ""} clears it. -var registeredModelForceSend = []string{"Comment"} - -func (r *ResourceRegisteredModel) DoUpdate(ctx context.Context, id string, config *catalog.CreateRegisteredModelRequest, _ *PlanEntry) (*catalog.RegisteredModelInfo, error) { - updateRequest := catalog.UpdateRegisteredModelRequest{ - FullName: id, - Comment: config.Comment, - ForceSendFields: utils.FilterFields[catalog.UpdateRegisteredModelRequest](append(slices.Clone(registeredModelForceSend), config.ForceSendFields...), "Owner", "NewName"), +func (r *ResourceRegisteredModel) DoUpdate(ctx context.Context, id string, config *registeredmodels.CreateRegisteredModelRequest, _ *PlanEntry) (*registeredmodels.RegisteredModelInfo, error) { + request, err := registeredmodels.UpdateRegisteredModelRequestToSDK(®isteredmodels.UpdateRegisteredModelRequest{ + FullNameArg: new(id), + // Always sent, see ResourceSchema.DoUpdate. Verified against a real workspace: {"comment": ""} clears it. + Comment: orZero(config.Comment), // Owner is settable in the config (it comes from the embedded // CreateRegisteredModelRequest) and create sends it, but update never has: a // change to it is silently dropped rather than applied. - Owner: "", + Owner: nil, // Name updates are not supported yet without recreating. Can be added as a follow-up. // Note: TF also does not support changing name without a recreate so the current behavior matches TF. - NewName: "", + NewName: nil, Aliases: config.Aliases, BrowseOnly: config.BrowseOnly, @@ -95,18 +101,22 @@ func (r *ResourceRegisteredModel) DoUpdate(ctx context.Context, id string, confi StorageLocation: config.StorageLocation, Name: config.Name, CatalogName: config.CatalogName, + FullName: nil, + }) + if err != nil { + return nil, err } - response, err := r.client.RegisteredModels.Update(ctx, updateRequest) + response, err := r.client.RegisteredModels.UpdateRegisteredModel(ctx, *request) if err != nil { return nil, err } - - return response, nil + return registeredmodels.RegisteredModelInfoFromSDK(response) } -func (r *ResourceRegisteredModel) DoDelete(ctx context.Context, id string, _ *catalog.CreateRegisteredModelRequest) error { - return r.client.RegisteredModels.Delete(ctx, catalog.DeleteRegisteredModelRequest{ - FullName: id, +func (r *ResourceRegisteredModel) DoDelete(ctx context.Context, id string, _ *registeredmodels.CreateRegisteredModelRequest) error { + _, err := r.client.RegisteredModels.DeleteRegisteredModel(ctx, sdkregisteredmodels.DeleteRegisteredModelRequest{ + FullNameArg: new(id), }) + return err } diff --git a/bundle/direct/dresources/schema.go b/bundle/direct/dresources/schema.go index d80dac584bc..d449a88f04f 100644 --- a/bundle/direct/dresources/schema.go +++ b/bundle/direct/dresources/schema.go @@ -2,49 +2,63 @@ package dresources import ( "context" - "slices" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdkclients" + schemas "github.com/databricks/cli/libs/sdktypes/uc/schemas/v1" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/catalog" + sdkschemas "github.com/databricks/sdk-go/uc/schemas/v1" ) type ResourceSchema struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceSchema) New(client *databricks.WorkspaceClient) *ResourceSchema { +func (*ResourceSchema) New(client *sdkclients.Clients) *ResourceSchema { return &ResourceSchema{client: client} } -func (*ResourceSchema) PrepareState(input *resources.Schema) *catalog.CreateSchema { +func (*ResourceSchema) PrepareState(input *resources.Schema) *resources.CreateSchema { return &input.CreateSchema } -func (*ResourceSchema) RemapState(info *catalog.SchemaInfo) *catalog.CreateSchema { - return &catalog.CreateSchema{ +func (*ResourceSchema) RemapState(info *schemas.SchemaInfo) *resources.CreateSchema { + return &resources.CreateSchema{ CatalogName: info.CatalogName, Comment: info.Comment, CustomMaxRetentionHours: info.CustomMaxRetentionHours, Name: info.Name, Properties: info.Properties, StorageRoot: info.StorageRoot, - ForceSendFields: utils.FilterFields[catalog.CreateSchema](info.ForceSendFields), } } -func (r *ResourceSchema) DoRead(ctx context.Context, id string) (*catalog.SchemaInfo, error) { - return r.client.Schemas.GetByFullName(ctx, id) +func (r *ResourceSchema) DoRead(ctx context.Context, id string) (*schemas.SchemaInfo, error) { + info, err := r.client.Schemas.GetSchema(ctx, sdkschemas.GetSchemaRequest{ + FullNameArg: new(id), + IncludeBrowse: nil, // Not set by DABs + }) + if err != nil { + return nil, err + } + return schemas.SchemaInfoFromSDK(info) } -func (r *ResourceSchema) DoCreate(ctx context.Context, config *catalog.CreateSchema) (string, *catalog.SchemaInfo, error) { - response, err := r.client.Schemas.Create(ctx, *config) +func (r *ResourceSchema) DoCreate(ctx context.Context, config *resources.CreateSchema) (string, *schemas.SchemaInfo, error) { + request, err := toSDK[sdkschemas.CreateSchemaRequest](config.AsRequest()) + if err != nil { + return "", nil, err + } + response, err := r.client.Schemas.CreateSchema(ctx, request) if err != nil || response == nil { return "", nil, err } - return response.FullName, response, nil + info, err := schemas.SchemaInfoFromSDK(response) + if err != nil { + return "", nil, err + } + return utils.Deref(info.FullName), info, nil } // UC drops a field the payload omits, so a value the config stops declaring never @@ -53,46 +67,62 @@ func (r *ResourceSchema) DoCreate(ctx context.Context, config *catalog.CreateSch // which made a schema undeployable once someone set a description on it outside the // bundle. Sending these explicitly is the only way to express "the bundle owns this". // -// Only fields verified against a real workspace belong here: {"comment": ""} and +// Only fields verified against a real workspace are always sent: {"comment": ""} and // {"custom_max_retention_hours": 0} both clear. Do not add a field without probing it -- UC rejects // an empty value on some (owner: "" is "Could not find principal with name .", new_name: "" is "not -// a valid name"), and ForceSendFields is inert for maps, so listing properties would be a no-op. +// a valid name"). // -// custom_max_retention_hours is force-sent so the direct engine can clear it. The terraform +// custom_max_retention_hours is always sent so the direct engine can clear it. The terraform // databricks_schema resource cannot set this field at all, so a schema config that uses it deploys // differently under terraform (which drops it) than under direct; such configs are kept out of the // migrate invariant (schema.yml is excluded there, and schema_tf_compat.yml covers migrate instead). -var schemaForceSend = []string{"Comment", "CustomMaxRetentionHours"} - // DoUpdate updates the schema in place and returns remote state. -func (r *ResourceSchema) DoUpdate(ctx context.Context, id string, config *catalog.CreateSchema, _ *PlanEntry) (*catalog.SchemaInfo, error) { - updateRequest := catalog.UpdateSchema{ - Comment: config.Comment, - CustomMaxRetentionHours: config.CustomMaxRetentionHours, - EnablePredictiveOptimization: "", // Not supported by DABs - FullName: id, - NewName: "", // We recreate schemas on name change intentionally. - Owner: "", // Not supported by DABs - Properties: config.Properties, - ForceSendFields: utils.FilterFields[catalog.UpdateSchema](append(slices.Clone(schemaForceSend), config.ForceSendFields...), "EnablePredictiveOptimization", "NewName", "Owner"), +func (r *ResourceSchema) DoUpdate(ctx context.Context, id string, config *resources.CreateSchema, _ *PlanEntry) (*schemas.SchemaInfo, error) { + // new_name is not set: schemas are recreated on name change intentionally. + // owner and enable_predictive_optimization are not supported by DABs. + request, err := toSDK[sdkschemas.UpdateSchemaRequest](&schemas.UpdateSchemaRequest{ + FullNameArg: new(id), + Comment: orZero(config.Comment), + CustomMaxRetentionHours: orZero(config.CustomMaxRetentionHours), + Properties: config.Properties, + BrowseOnly: nil, // Not set by DABs + CatalogName: nil, // Not set by DABs + CatalogType: "", // Not set by DABs + CreatedAt: nil, // Not set by DABs + CreatedBy: nil, // Not set by DABs + EffectivePredictiveOptimizationFlag: nil, // Not set by DABs + EnablePredictiveOptimization: nil, // Not set by DABs + FullName: nil, // Not set by DABs + MetastoreId: nil, // Not set by DABs + Name: nil, // Not set by DABs + NewName: nil, // Not set by DABs + Options: nil, // Not set by DABs + Owner: nil, // Not set by DABs + SchemaId: nil, // Not set by DABs + StorageLocation: nil, // Not set by DABs + StorageRoot: nil, // Not set by DABs + UpdatedAt: nil, // Not set by DABs + UpdatedBy: nil, // Not set by DABs + }) + if err != nil { + return nil, err } - - response, err := r.client.Schemas.Update(ctx, updateRequest) + response, err := r.client.Schemas.UpdateSchema(ctx, request) if err != nil { return nil, err } - if response != nil && response.FullName != id { - log.Warnf(ctx, "schemas: response contains unexpected full_name=%#v (expected %#v)", response.FullName, id) + if response != nil && utils.Deref(response.FullName) != id { + log.Warnf(ctx, "schemas: response contains unexpected full_name=%#v (expected %#v)", utils.Deref(response.FullName), id) } - return response, nil + return schemas.SchemaInfoFromSDK(response) } -func (r *ResourceSchema) DoDelete(ctx context.Context, id string, _ *catalog.CreateSchema) error { - return r.client.Schemas.Delete(ctx, catalog.DeleteSchemaRequest{ - FullName: id, - Force: true, - ForceSendFields: nil, +func (r *ResourceSchema) DoDelete(ctx context.Context, id string, _ *resources.CreateSchema) error { + _, err := r.client.Schemas.DeleteSchema(ctx, sdkschemas.DeleteSchemaRequest{ + FullNameArg: new(id), + Force: new(true), }) + return err } diff --git a/bundle/direct/dresources/schema_test.go b/bundle/direct/dresources/schema_test.go index ee6397afc6e..19981230c63 100644 --- a/bundle/direct/dresources/schema_test.go +++ b/bundle/direct/dresources/schema_test.go @@ -4,38 +4,29 @@ import ( "encoding/json" "testing" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/bundle/config/resources" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func TestResourceSchema_DoUpdate_WithUnsupportedForceSendFields(t *testing.T) { +func TestResourceSchema_DoUpdate(t *testing.T) { _, client := setupTestServerClient(t) adapter := (*ResourceSchema)(nil).New(client) ctx := t.Context() - config := &catalog.CreateSchema{ - CatalogName: "main", - Name: "test_schema", - Comment: "original comment", - Properties: map[string]string{"key": "value"}, - StorageRoot: "", - ForceSendFields: nil, + config := &resources.CreateSchema{ + CatalogName: new("main"), + Name: new("test_schema"), + Comment: new("original comment"), + Properties: map[string]string{"key": "value"}, } id, _, err := adapter.DoCreate(ctx, config) require.NoError(t, err) - config.Comment = "updated comment" + config.Comment = new("updated comment") config.Properties = map[string]string{"key": "updated_value"} - config.ForceSendFields = []string{ - "Comment", - "Properties", - "EnablePredictiveOptimization", // Unsupported - should be filtered out - "NewName", // Unsupported - should be filtered out - "Owner", // Unsupported - should be filtered out - } _, err = adapter.DoUpdate(ctx, id, config, &PlanEntry{}) require.NoError(t, err) @@ -43,9 +34,9 @@ func TestResourceSchema_DoUpdate_WithUnsupportedForceSendFields(t *testing.T) { result, err := adapter.DoRead(ctx, id) require.NoError(t, err) - result.CreatedAt = 0 - result.UpdatedAt = 0 - result.SchemaId = "" + result.CreatedAt = new(int64(0)) + result.UpdatedAt = new(int64(0)) + result.SchemaId = new("") resultJSON, err := json.Marshal(result) require.NoError(t, err) diff --git a/bundle/direct/dresources/secret.go b/bundle/direct/dresources/secret.go index 2db0a334f82..de0ea305446 100644 --- a/bundle/direct/dresources/secret.go +++ b/bundle/direct/dresources/secret.go @@ -2,46 +2,44 @@ package dresources import ( "context" - "slices" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/libs/sdkclients" + secrets "github.com/databricks/cli/libs/sdktypes/uc/secrets/v1" "github.com/databricks/cli/libs/structs/structdiff" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - "github.com/databricks/databricks-sdk-go/service/catalog" + sdksecrets "github.com/databricks/sdk-go/uc/secrets/v1" ) // Terraform provider implementation: // https://github.com/databricks/terraform-provider-databricks/blob/main/catalog/resource_secret.go type ResourceSecret struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceSecret) New(client *databricks.WorkspaceClient) *ResourceSecret { +func (*ResourceSecret) New(client *sdkclients.Clients) *ResourceSecret { return &ResourceSecret{client: client} } -func (*ResourceSecret) PrepareState(input *resources.Secret) *catalog.Secret { - return &catalog.Secret{ - CatalogName: input.CatalogName, - SchemaName: input.SchemaName, - Name: input.Name, - Value: input.Value, - Comment: input.Comment, - ExpireTime: input.ExpireTime, - Owner: "", - CreateTime: nil, - CreatedBy: "", - EffectiveOwner: "", - EffectiveValue: "", - FullName: "", - MetastoreId: "", - UpdateTime: nil, - UpdatedBy: "", - ForceSendFields: utils.FilterFields[catalog.Secret](nil), +func (*ResourceSecret) PrepareState(input *resources.Secret) *secrets.Secret { + return &secrets.Secret{ + CatalogName: input.CatalogName, + SchemaName: input.SchemaName, + Name: input.Name, + Value: input.Value, + Comment: input.Comment, + ExpireTime: input.ExpireTime, + Owner: nil, + CreateTime: nil, + CreatedBy: nil, + EffectiveOwner: nil, + EffectiveValue: nil, + FullName: nil, + MetastoreId: nil, + UpdateTime: nil, + UpdatedBy: nil, } } @@ -51,63 +49,73 @@ func (*ResourceSecret) PrepareState(input *resources.Secret) *catalog.Secret { // The rest of the secret, including the output-only metadata, is left intact and handled // by ignore_remote_changes, so no information is discarded. It runs wherever remote state // is produced (DoRead/DoCreate/DoUpdate), so no RemapState hook is needed. -func remapSecretRemote(remote *catalog.Secret) *catalog.Secret { +func remapSecretRemote(resp *sdksecrets.Secret) (*secrets.Secret, error) { + remote, err := secrets.SecretFromSDK(resp) + if err != nil { + return nil, err + } remote.Value = remote.EffectiveValue remote.Owner = remote.EffectiveOwner - return remote + return remote, nil } // DoRead fetches the secret by full name. IncludeValue is set so remapSecretRemote can // recover the stored value from EffectiveValue. -func (r *ResourceSecret) DoRead(ctx context.Context, id string) (*catalog.Secret, error) { - remote, err := r.client.SecretsUc.GetSecret(ctx, catalog.GetSecretRequest{ - FullName: id, - IncludeValue: true, - ForceSendFields: nil, +func (r *ResourceSecret) DoRead(ctx context.Context, id string) (*secrets.Secret, error) { + remote, err := r.client.SecretsUc.GetSecret(ctx, sdksecrets.GetSecretRequest{ + FullName: new(id), + IncludeValue: new(true), }) if err != nil { return nil, err } - return remapSecretRemote(remote), nil + return remapSecretRemote(remote) } // DoCreate creates a new UC secret. -func (r *ResourceSecret) DoCreate(ctx context.Context, state *catalog.Secret) (string, *catalog.Secret, error) { - response, err := r.client.SecretsUc.CreateSecret(ctx, catalog.CreateSecretRequest{ - Secret: *state, - }) +func (r *ResourceSecret) DoCreate(ctx context.Context, state *secrets.Secret) (string, *secrets.Secret, error) { + request, err := secrets.CreateSecretRequestToSDK(&secrets.CreateSecretRequest{Secret: state}) + if err != nil { + return "", nil, err + } + response, err := r.client.SecretsUc.CreateSecret(ctx, *request) if err != nil || response == nil { return "", nil, err } - return response.FullName, remapSecretRemote(response), nil + remote, err := remapSecretRemote(response) + if err != nil { + return "", nil, err + } + return utils.Deref(remote.FullName), remote, nil } -// comment is force-sent on update so that clearing it in config clears it on the secret. The -// update_mask is "*" and the backend merges, so an omitempty comment would be dropped from the -// body and the old value would drift back. Verified against a real workspace: {"comment": ""} clears it. -var secretForceSend = []string{"Comment"} - // DoUpdate updates the secret in place and returns remote state. -func (r *ResourceSecret) DoUpdate(ctx context.Context, id string, state *catalog.Secret, _ *PlanEntry) (*catalog.Secret, error) { +// +// comment is always sent on update so that clearing it in config clears it on the secret. The +// update_mask is "*" and the backend merges, so an omitted comment would be dropped from the +// body and the old value would drift back. Verified against a real workspace: {"comment": ""} clears it. +func (r *ResourceSecret) DoUpdate(ctx context.Context, id string, state *secrets.Secret, _ *PlanEntry) (*secrets.Secret, error) { secret := *state - secret.ForceSendFields = utils.FilterFields[catalog.Secret](append(slices.Clone(secretForceSend), state.ForceSendFields...)) - response, err := r.client.SecretsUc.UpdateSecret(ctx, catalog.UpdateSecretRequest{ - FullName: id, - Secret: secret, - UpdateMask: fieldmask.FieldMask{ - Paths: []string{"*"}, - }, + secret.Comment = orZero(state.Comment) + request, err := secrets.UpdateSecretRequestToSDK(&secrets.UpdateSecretRequest{ + FullName: new(id), + Secret: &secret, + UpdateMask: new("*"), }) if err != nil { return nil, err } - return remapSecretRemote(response), nil + response, err := r.client.SecretsUc.UpdateSecret(ctx, *request) + if err != nil { + return nil, err + } + return remapSecretRemote(response) } // DoDelete deletes the secret. -func (r *ResourceSecret) DoDelete(ctx context.Context, id string, _ *catalog.Secret) error { - return r.client.SecretsUc.DeleteSecret(ctx, catalog.DeleteSecretRequest{ - FullName: id, +func (r *ResourceSecret) DoDelete(ctx context.Context, id string, _ *secrets.Secret) error { + return r.client.SecretsUc.DeleteSecret(ctx, sdksecrets.DeleteSecretRequest{ + FullName: new(id), }) } @@ -117,7 +125,7 @@ func (r *ResourceSecret) DoDelete(ctx context.Context, id string, _ *catalog.Sec // the actual stored value. We compare new vs remote (via effective_value from DoRead) // to decide whether the secret actually changed: if they are equal, the user's config // already matches what is stored remotely and no update is needed. -func (*ResourceSecret) OverrideChangeDesc(_ context.Context, path *structpath.PathNode, ch *ChangeDesc, _ *catalog.Secret) error { +func (*ResourceSecret) OverrideChangeDesc(_ context.Context, path *structpath.PathNode, ch *ChangeDesc, _ *secrets.Secret) error { if path.String() != "value" { return nil } diff --git a/bundle/direct/dresources/secret_scope.go b/bundle/direct/dresources/secret_scope.go index 7ad0b0d469a..e26d22b0467 100644 --- a/bundle/direct/dresources/secret_scope.go +++ b/bundle/direct/dresources/secret_scope.go @@ -4,46 +4,33 @@ import ( "context" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" + secrets "github.com/databricks/cli/libs/sdktypes/secrets/v1" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/workspace" + sdksecrets "github.com/databricks/sdk-go/secrets/v1" ) type ResourceSecretScope struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } type SecretScopeConfig struct { - workspace.CreateScope + secrets.CreateScopeRequest } // SecretScopeRemote is remote state for a secret scope. The Secrets API returns scopes as -// workspace.SecretScope (name/backend_type/keyvault_metadata); DoRead maps those onto the field +// secrets.SecretScope (name/backend_type/keyvault_metadata); DoRead maps those onto the field // names the state uses (scope/scope_backend_type/backend_azure_keyvault) so RemapState is a plain // field copy. name is retained because `${resources.secret_scopes..name}` references resolve // against the remote type. type SecretScopeRemote struct { - Name string `json:"name"` - Scope string `json:"scope"` - ScopeBackendType workspace.ScopeBackendType `json:"scope_backend_type,omitempty"` - BackendAzureKeyvault *workspace.AzureKeyVaultSecretScopeMetadata `json:"backend_azure_keyvault,omitempty"` - ForceSendFields []string `json:"-"` + Name string `json:"name"` + Scope string `json:"scope"` + ScopeBackendType secrets.ScopeBackendType `json:"scope_backend_type,omitempty"` + BackendAzureKeyvault *secrets.AzureKeyVaultSecretScopeMetadata `json:"backend_azure_keyvault,omitempty"` } -// Custom marshalers so the root ForceSendFields is honored: a force-sent zero-valued -// scalar (e.g. scope_backend_type) survives serialization instead of being dropped by -// omitempty, which plain encoding/json would do since it does not know the convention. -func (s *SecretScopeRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s SecretScopeRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func (*ResourceSecretScope) New(client *databricks.WorkspaceClient) *ResourceSecretScope { +func (*ResourceSecretScope) New(client *sdkclients.Clients) *ResourceSecretScope { return &ResourceSecretScope{ client: client, } @@ -51,21 +38,19 @@ func (*ResourceSecretScope) New(client *databricks.WorkspaceClient) *ResourceSec func (*ResourceSecretScope) PrepareState(input *resources.SecretScope) *SecretScopeConfig { return &SecretScopeConfig{ - Scope: input.Name, + Scope: new(input.Name), ScopeBackendType: input.BackendType, BackendAzureKeyvault: input.KeyvaultMetadata, - InitialManagePrincipal: "", - ForceSendFields: nil, + InitialManagePrincipal: nil, } } func (*ResourceSecretScope) RemapState(remote *SecretScopeRemote) *SecretScopeConfig { return &SecretScopeConfig{ - Scope: remote.Scope, + Scope: new(remote.Scope), ScopeBackendType: remote.ScopeBackendType, BackendAzureKeyvault: remote.BackendAzureKeyvault, - InitialManagePrincipal: "", - ForceSendFields: utils.FilterFields[workspace.CreateScope](remote.ForceSendFields), + InitialManagePrincipal: nil, } } @@ -73,38 +58,45 @@ func (*ResourceSecretScope) RemapState(remote *SecretScopeRemote) *SecretScopeCo // a "get by name" endpoint (see https://docs.databricks.com/api/workspace/secrets), // we must list all scopes and filter by name to check if the scope still exists. func (r *ResourceSecretScope) DoRead(ctx context.Context, id string) (*SecretScopeRemote, error) { - scopes, err := r.client.Secrets.ListScopesAll(ctx) + resp, err := r.client.Secrets.ListScopes(ctx, sdksecrets.ListScopesRequest{}) + if err != nil { + return nil, err + } + scopes, err := secrets.ListScopesResponseFromSDK(resp) if err != nil { return nil, err } - for _, scope := range scopes { - if scope.Name == id { + for _, scope := range scopes.Scopes { + if name := utils.Deref(scope.Name); name == id { return &SecretScopeRemote{ - Name: scope.Name, - Scope: scope.Name, + Name: name, + Scope: name, ScopeBackendType: scope.BackendType, BackendAzureKeyvault: scope.KeyvaultMetadata, - ForceSendFields: nil, }, nil } } - return nil, apierr.ErrNotFound + return nil, errResourceDoesNotExist("secret scope " + id + " does not exist") } func (r *ResourceSecretScope) DoCreate(ctx context.Context, state *SecretScopeConfig) (string, *SecretScopeRemote, error) { - err := r.client.Secrets.CreateScope(ctx, state.CreateScope) + request, err := secrets.CreateScopeRequestToSDK(&state.CreateScopeRequest) if err != nil { return "", nil, err } + if _, err := r.client.Secrets.CreateScope(ctx, *request); err != nil { + return "", nil, err + } - return state.Scope, nil, nil + return utils.Deref(state.Scope), nil, nil } // DoUpdate is not intentionally implemented here because scopes do not support a update API. All fields are marked to // return a recreate trigger. func (r *ResourceSecretScope) DoDelete(ctx context.Context, id string, _ *SecretScopeConfig) error { - return r.client.Secrets.DeleteScopeByScope(ctx, id) + _, err := r.client.Secrets.DeleteScope(ctx, sdksecrets.DeleteScopeRequest{Scope: new(id)}) + return err } diff --git a/bundle/direct/dresources/secret_scope_acls.go b/bundle/direct/dresources/secret_scope_acls.go index 1de301bde2c..620cd812704 100644 --- a/bundle/direct/dresources/secret_scope_acls.go +++ b/bundle/direct/dresources/secret_scope_acls.go @@ -2,27 +2,29 @@ package dresources import ( "context" - "errors" "fmt" "strings" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" + secrets "github.com/databricks/cli/libs/sdktypes/secrets/v1" "github.com/databricks/cli/libs/structs/structvar" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/utils" + sdksecrets "github.com/databricks/sdk-go/secrets/v1" ) type ResourceSecretScopeAcls struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } type SecretScopeAclsState struct { - ScopeName string `json:"scope_name"` - Acls []workspace.AclItem `json:"acls,omitempty"` + ScopeName string `json:"scope_name"` + Acls []secrets.AclItem `json:"acls,omitempty"` } -func (*ResourceSecretScopeAcls) New(client *databricks.WorkspaceClient) *ResourceSecretScopeAcls { +func (*ResourceSecretScopeAcls) New(client *sdkclients.Clients) *ResourceSecretScopeAcls { return &ResourceSecretScopeAcls{client: client} } @@ -36,18 +38,18 @@ func (*ResourceSecretScopeAcls) PrepareInputConfig(inputConfig *[]resources.Secr return nil, fmt.Errorf("internal error: node %q does not end with .permissions", resourceKey) } - acls := make([]workspace.AclItem, 0, len(*inputConfig)) + acls := make([]secrets.AclItem, 0, len(*inputConfig)) for _, elem := range *inputConfig { - acl := workspace.AclItem{ - Permission: workspace.AclPermission(elem.Level), - Principal: "", + acl := secrets.AclItem{ + Permission: secrets.AclPermission(elem.Level), + Principal: nil, } if elem.UserName != "" { - acl.Principal = elem.UserName + acl.Principal = new(elem.UserName) } else if elem.GroupName != "" { - acl.Principal = elem.GroupName + acl.Principal = new(elem.GroupName) } else if elem.ServicePrincipalName != "" { - acl.Principal = elem.ServicePrincipalName + acl.Principal = new(elem.ServicePrincipalName) } acls = append(acls, acl) } @@ -63,8 +65,8 @@ func (*ResourceSecretScopeAcls) PrepareInputConfig(inputConfig *[]resources.Secr }, nil } -func aclItemKey(x workspace.AclItem) (string, string) { - return "principal", x.Principal +func aclItemKey(x secrets.AclItem) (string, string) { + return "principal", utils.Deref(x.Principal) } func (*ResourceSecretScopeAcls) KeyedSlices() map[string]any { @@ -75,9 +77,7 @@ func (*ResourceSecretScopeAcls) KeyedSlices() map[string]any { func (r *ResourceSecretScopeAcls) DoRead(ctx context.Context, id string) (*SecretScopeAclsState, error) { // id is the scope name - currentAcls, err := r.client.Secrets.ListAclsAll(ctx, workspace.ListAclsRequest{ - Scope: id, - }) + currentAcls, err := r.listACLs(ctx, id) if err != nil { return nil, err } @@ -114,70 +114,75 @@ func (r *ResourceSecretScopeAcls) DoUpdate(ctx context.Context, id string, state // no-op, to match the behavior for permissions and grants. Deleting the resource is a // state-only cleanup (see PlanEntry.StateOnly). +func (r *ResourceSecretScopeAcls) listACLs(ctx context.Context, scopeName string) ([]secrets.AclItem, error) { + resp, err := r.client.Secrets.ListAcls(ctx, sdksecrets.ListAclsRequest{Scope: new(scopeName)}) + if err != nil { + return nil, err + } + acls, err := secrets.ListAclsResponseFromSDK(resp) + if err != nil { + return nil, err + } + return acls.Items, nil +} + // setACLs reconciles the desired ACLs with the current state -func (r *ResourceSecretScopeAcls) setACLs(ctx context.Context, scopeName string, desiredAcls []workspace.AclItem) error { - // Get current ACLs - currentAcls, err := r.client.Secrets.ListAclsAll(ctx, workspace.ListAclsRequest{ - Scope: scopeName, - }) +func (r *ResourceSecretScopeAcls) setACLs(ctx context.Context, scopeName string, desiredAcls []secrets.AclItem) error { + currentAcls, err := r.listACLs(ctx, scopeName) if err != nil { return fmt.Errorf("failed to list current ACLs: %w", err) } - // Build maps for reconciliation - desired := make(map[string]workspace.AclPermission) + desired := make(map[string]secrets.AclPermission) for _, perm := range desiredAcls { - desired[perm.Principal] = perm.Permission + desired[utils.Deref(perm.Principal)] = perm.Permission } - current := make(map[string]workspace.AclPermission) + current := make(map[string]secrets.AclPermission) for _, acl := range currentAcls { - current[acl.Principal] = acl.Permission + current[utils.Deref(acl.Principal)] = acl.Permission } - // Collect operations to perform in parallel - var toSet []workspace.PutAcl - var toDelete []workspace.DeleteAcl + type putACL struct { + principal string + permission secrets.AclPermission + } + var toSet []putACL + var toDelete []string - // Find ACLs to set (new or changed) for principal, permission := range desired { if currentPerm, exists := current[principal]; !exists || currentPerm != permission { - toSet = append(toSet, workspace.PutAcl{ - Scope: scopeName, - Principal: principal, - Permission: permission, - }) + toSet = append(toSet, putACL{principal: principal, permission: permission}) } } - // Find ACLs to delete for principal := range current { if _, exists := desired[principal]; !exists { - toDelete = append(toDelete, workspace.DeleteAcl{ - Scope: scopeName, - Principal: principal, - }) + toDelete = append(toDelete, principal) } } - // Set ACLs. The service returns inconsistent results for parallel API calls. That's why we do them sequentially - // here to maintain correctness. for _, acl := range toSet { - err := r.client.Secrets.PutAcl(ctx, acl) + _, err := r.client.Secrets.PutAcl(ctx, sdksecrets.PutAclRequest{ + Scope: new(scopeName), + Principal: new(acl.principal), + Permission: acl.permission, + }) if err != nil { - return fmt.Errorf("failed to set ACL %v for principal %q: %w", acl, acl.Principal, err) + return fmt.Errorf("failed to set ACL {%s %s %s} for principal %q: %w", acl.permission, acl.principal, scopeName, acl.principal, err) } } - // Delete ACLs - for _, acl := range toDelete { - err := r.client.Secrets.DeleteAcl(ctx, acl) - // Ignore not found errors for ACLs. - if errors.Is(err, apierr.ErrNotFound) { + for _, principal := range toDelete { + _, err := r.client.Secrets.DeleteAcl(ctx, sdksecrets.DeleteAclRequest{ + Scope: new(scopeName), + Principal: new(principal), + }) + if apierrs.Is(err, apierrs.ErrNotFound) { continue } if err != nil { - return fmt.Errorf("failed to delete ACL %v for principal %q: %w", acl, acl.Principal, err) + return fmt.Errorf("failed to delete ACL {%s %s} for principal %q: %w", principal, scopeName, principal, err) } } diff --git a/bundle/direct/dresources/serialize_test.go b/bundle/direct/dresources/serialize_test.go index 76078460193..f5e94184c35 100644 --- a/bundle/direct/dresources/serialize_test.go +++ b/bundle/direct/dresources/serialize_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" + "github.com/databricks/cli/libs/structs/structaccess" "github.com/databricks/cli/libs/structs/structdiff" "github.com/databricks/cli/libs/structs/structtag" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -52,7 +52,7 @@ func assertJSONRoundTrip(t *testing.T, v any, label string) { // Diff the Go values rather than the JSON: a wrapper that drops fields keeps // them populated in v but loses them in back, so structdiff flags it even // though both marshal to the same (already-truncated) JSON. structdiff skips - // ForceSendFields and json:"-" fields, which are intentionally not serialized. + // json:"-" fields, which are intentionally not serialized. // Free-form any fields must be populated with []any/map[string]any (as JSON // decoding yields) so they round-trip to the same concrete type. changes, err := structdiff.GetStructDiff(v, back, nil) @@ -201,9 +201,7 @@ func collectPointerOnlyMarshalers(t reflect.Type, seen, found map[reflect.Type]b // Such a method is satisfied by *T but not by T, and encoding/json reaches it // only for an addressable value. json.Marshal(&x) then uses the marshaler while // json.Marshal(x) silently falls back to plain struct-field encoding -- two code -// paths for one type. They disagree on more than key order, because encoding/json -// knows nothing about ForceSendFields (tagged json:"-"), so a force-sent zero -// value of an omitempty field survives one path and vanishes on the other. +// paths for one type, which can disagree on what is serialized. // // The walk covers embedded members and named fields, not just the surface type // itself. Both matter, for different reasons: an embedded member's pointer @@ -250,10 +248,47 @@ func TestMarshalerValueReceiver(t *testing.T) { } // fillNonZero recursively populates v with non-zero values so that every -// serializable field is observable in a round-trip. It skips ForceSendFields -// (json:"-") and bounds recursion depth to avoid runaway on self-referential +// serializable field is observable in a round-trip. It skips json:"-" fields +// and bounds recursion depth to avoid runaway on self-referential // SDK types; bounding is safe because the fields at risk (a wrapper's own // fields alongside an embedded SDK type) sit at the top level. +// fillStruct fills the fields of struct v that encoding/json serializes. A field +// of a flattened embedded struct is skipped when an outer field has the same +// JSON name (shadowed), since encoding/json never reads or writes it. +func fillStruct(v reflect.Value, depth int, shadowed map[string]bool) { + t := v.Type() + names := map[string]bool{} + for name := range shadowed { + names[name] = true + } + for sf := range t.Fields() { + if sf.IsExported() && !structaccess.IsFlattenedEmbed(sf) { + names[jsonFieldName(sf)] = true + } + } + for i := range t.NumField() { + sf := t.Field(i) + if !sf.IsExported() || structtag.JSONTag(sf.Tag.Get("json")).Name() == "-" { + continue + } + if structaccess.IsFlattenedEmbed(sf) { + fillStruct(v.Field(i), depth+1, names) + continue + } + if shadowed[jsonFieldName(sf)] { + continue + } + fillNonZero(v.Field(i), depth+1) + } +} + +func jsonFieldName(sf reflect.StructField) string { + if name := structtag.JSONTag(sf.Tag.Get("json")).Name(); name != "" { + return name + } + return sf.Name +} + func fillNonZero(v reflect.Value, depth int) { if depth > 6 { return @@ -285,121 +320,9 @@ func fillNonZero(v reflect.Value, depth int) { // Free-form any fields decode to map[string]any from JSON. v.Set(reflect.ValueOf(map[string]any{"k": "v"})) case reflect.Struct: - t := v.Type() - for i := range t.NumField() { - sf := t.Field(i) - if !sf.IsExported() || sf.Name == "ForceSendFields" { - continue - } - if structtag.JSONTag(sf.Tag.Get("json")).Name() == "-" { - continue - } - fillNonZero(v.Field(i), depth+1) - } + fillStruct(v, depth, nil) default: // Kinds that don't appear in SDK state/remote types (chan, func, // complex, array, etc.) are left at their zero value. } } - -// TestForceSendZeroValues verifies that every InputConfigType/StateType/RemoteType -// honors the SDK ForceSendFields convention: a zero-valued scalar field whose name is -// in ForceSendFields must still be serialized. -// -// The round-trip tests above fill every field non-zero and leave ForceSendFields -// empty, so they cover the "populated field silently dropped" failure mode but never -// the opposite one: a force-sent zero value that is omitted because the type marshals -// via plain encoding/json (which knows nothing about ForceSendFields) rather than the -// SDK marshaler. That path is the entire reason ForceSendFields and the wrapper -// marshalers exist, so it is the one worth pinning. -func TestForceSendZeroValues(t *testing.T) { - for _, dim := range []struct { - label string - typeOf func(*Adapter) reflect.Type - }{ - {"InputConfigType", (*Adapter).InputConfigType}, - {"StateType", (*Adapter).StateType}, - {"RemoteType", (*Adapter).RemoteType}, - } { - for resourceType, resource := range SupportedResources { - adapter, err := NewAdapter(resource, resourceType, nil) - require.NoError(t, err) - t.Run(dim.label+"/"+resourceType, func(t *testing.T) { - assertForceSendHonored(t, dim.typeOf(adapter)) - }) - } - } -} - -// assertForceSendHonored builds a zero value of typ (a pointer to struct), tells the -// struct that owns ForceSendFields to force-send each of its own scalar omitempty -// fields, marshals, and asserts each such field survives into the JSON. ForceSendFields -// governs the fields declared alongside it (embedded structs carry their own), so the -// forced fields and the ForceSendFields must come from the same struct. -func assertForceSendHonored(t *testing.T, typ reflect.Type) { - t.Helper() - - sf, ok := typ.Elem().FieldByName("ForceSendFields") - if !ok || sf.Type != reflect.TypeFor[[]string]() { - t.Skip("no ForceSendFields") - } - - ptr := reflect.New(typ.Elem()) - owner := fieldByIndexAlloc(ptr.Elem(), sf.Index[:len(sf.Index)-1]) - - var goNames, jsonNames []string - for field := range owner.Type().Fields() { - if !field.IsExported() || field.Anonymous || !isBasicKind(field.Type.Kind()) { - continue - } - tag := structtag.JSONTag(field.Tag.Get("json")) - if name := tag.Name(); name != "" && name != "-" && strings.Contains(field.Tag.Get("json"), "omitempty") { - goNames = append(goNames, field.Name) - jsonNames = append(jsonNames, name) - } - } - if len(goNames) == 0 { - t.Skip("no force-sendable scalar fields") - } - - owner.Field(sf.Index[len(sf.Index)-1]).Set(reflect.ValueOf(goNames)) - - data, err := json.Marshal(ptr.Interface()) - require.NoError(t, err) - - // The ForceSendFields owner is the top-level struct or an embed, so its fields - // serialize at the document root; a top-level key check is enough. - var top map[string]json.RawMessage - require.NoError(t, json.Unmarshal(data, &top)) - for _, name := range jsonNames { - assert.Contains(t, top, name, - "field %q is force-sent (zero value) but was dropped from the JSON: the type marshals via plain encoding/json instead of a ForceSendFields-aware marshaler", name) - } -} - -func isBasicKind(k reflect.Kind) bool { - switch k { - case reflect.Bool, reflect.String, - reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, - reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, - reflect.Float32, reflect.Float64: - return true - default: - return false - } -} - -// fieldByIndexAlloc walks index from v, allocating a nil pointer before descending -// through it, so a field reached through an unset pointer is still addressable. -func fieldByIndexAlloc(v reflect.Value, index []int) reflect.Value { - for _, i := range index { - if v.Kind() == reflect.Pointer { - if v.IsNil() { - v.Set(reflect.New(v.Type().Elem())) - } - v = v.Elem() - } - v = v.Field(i) - } - return v -} diff --git a/bundle/direct/dresources/snapshot.go b/bundle/direct/dresources/snapshot.go index 5c59e5110c8..85e7972f2cc 100644 --- a/bundle/direct/dresources/snapshot.go +++ b/bundle/direct/dresources/snapshot.go @@ -6,8 +6,8 @@ import ( "os" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/snapshot" - "github.com/databricks/databricks-sdk-go" ) type ResourceSnapshot struct { @@ -35,7 +35,7 @@ type SnapshotRemote struct { FullPath string `json:"full_path"` } -func (s *ResourceSnapshot) New(client *databricks.WorkspaceClient) *ResourceSnapshot { +func (s *ResourceSnapshot) New(client *sdkclients.Clients) *ResourceSnapshot { // Return a zero-value instance when client is nil (e.g. refschema introspection). if client == nil { return &ResourceSnapshot{ diff --git a/bundle/direct/dresources/sql_warehouse.go b/bundle/direct/dresources/sql_warehouse.go index 7d4578dd6f2..d93d36c6f17 100644 --- a/bundle/direct/dresources/sql_warehouse.go +++ b/bundle/direct/dresources/sql_warehouse.go @@ -2,61 +2,41 @@ package dresources import ( "context" + "fmt" + "slices" "time" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/bundle/direct/internal/retries" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdkclients" + warehouses "github.com/databricks/cli/libs/sdktypes/warehouses/v1" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/sql" + sdkwarehouses "github.com/databricks/sdk-go/warehouses/v1" ) // SqlWarehouseState is the state type for SqlWarehouse resources. It extends sql.CreateWarehouseRequest // with lifecycle settings. type SqlWarehouseState struct { - sql.CreateWarehouseRequest + warehouses.CreateWarehouseRequest Lifecycle *StateLifecycle `json:"lifecycle,omitempty"` } -// Custom marshalers needed because embedded sql.CreateWarehouseRequest has its own MarshalJSON -// which would otherwise take over and ignore the additional fields. -func (s *SqlWarehouseState) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s SqlWarehouseState) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -// SqlWarehouseRemote extends sql.GetWarehouseResponse with a synthetic Lifecycle field so that -// RemoteType satisfies TestRemoteSuperset (every field in SqlWarehouseState exists in SqlWarehouseRemote). -// Lifecycle.Started is populated by DoRead from the warehouse's running state. type SqlWarehouseRemote struct { - sql.GetWarehouseResponse + warehouses.GetWarehouseResponse Lifecycle *StateLifecycle `json:"lifecycle,omitempty"` } -func (r *SqlWarehouseRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, r) -} - -func (r SqlWarehouseRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(r) -} - type ResourceSqlWarehouse struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -// New initializes a ResourceSqlWarehouse with the given client. -func (*ResourceSqlWarehouse) New(client *databricks.WorkspaceClient) *ResourceSqlWarehouse { +func (*ResourceSqlWarehouse) New(client *sdkclients.Clients) *ResourceSqlWarehouse { return &ResourceSqlWarehouse{client: client} } -// PrepareState converts bundle config to the SDK type. func (*ResourceSqlWarehouse) PrepareState(input *resources.SqlWarehouse) *SqlWarehouseState { s := &SqlWarehouseState{ CreateWarehouseRequest: input.CreateWarehouseRequest, @@ -68,8 +48,6 @@ func (*ResourceSqlWarehouse) PrepareState(input *resources.SqlWarehouse) *SqlWar return s } -// RemapState maps the remote SqlWarehouseRemote to SqlWarehouseState for diff comparison. -// Started is derived from warehouse state so the planner can detect start/stop changes. func (*ResourceSqlWarehouse) RemapState(warehouse *SqlWarehouseRemote) *SqlWarehouseState { return &SqlWarehouseState{ AutoStopMins: warehouse.AutoStopMins, @@ -85,15 +63,17 @@ func (*ResourceSqlWarehouse) RemapState(warehouse *SqlWarehouseRemote) *SqlWareh SpotInstancePolicy: warehouse.SpotInstancePolicy, StatementTimeout: warehouse.StatementTimeout, Tags: warehouse.Tags, - WarehouseType: sql.CreateWarehouseRequestWarehouseType(warehouse.WarehouseType), - ForceSendFields: utils.FilterFields[sql.CreateWarehouseRequest](warehouse.ForceSendFields), + WarehouseType: warehouse.WarehouseType, Lifecycle: warehouse.Lifecycle, } } -// DoRead reads the warehouse by id. func (r *ResourceSqlWarehouse) DoRead(ctx context.Context, id string) (*SqlWarehouseRemote, error) { - warehouse, err := r.client.Warehouses.GetById(ctx, id) + resp, err := r.client.Warehouses.GetWarehouse(ctx, sdkwarehouses.GetWarehouseRequest{Id: new(id)}) + if err != nil { + return nil, err + } + warehouse, err := warehouses.GetWarehouseResponseFromSDK(resp) if err != nil { return nil, err } @@ -103,63 +83,64 @@ func (r *ResourceSqlWarehouse) DoRead(ctx context.Context, id string) (*SqlWareh } switch warehouse.State { - case sql.StateRunning: - started := true - remote.Lifecycle = &StateLifecycle{Started: &started} - case sql.StateStopped: - started := false - remote.Lifecycle = &StateLifecycle{Started: &started} + case warehouses.EndpointState_Running: + remote.Lifecycle = &StateLifecycle{Started: new(true)} + case warehouses.EndpointState_Stopped: + remote.Lifecycle = &StateLifecycle{Started: new(false)} default: remote.Lifecycle = nil } return remote, nil } -// DoCreate creates the warehouse and returns its id. func (r *ResourceSqlWarehouse) DoCreate(ctx context.Context, config *SqlWarehouseState) (string, *SqlWarehouseRemote, error) { - waiter, err := r.client.Warehouses.Create(ctx, config.CreateWarehouseRequest) + request, err := warehouses.CreateWarehouseRequestToSDK(&config.CreateWarehouseRequest) if err != nil { return "", nil, err } - return waiter.Id, nil, nil + waiter, err := r.client.Warehouses.CreateWarehouse(ctx, *request) + if err != nil { + return "", nil, err + } + return waiter.GetId(), nil, nil } -// hasWarehouseChanges reports whether the plan entry contains any Update changes -// to fields that belong to the Warehouse Edit API (i.e., not lifecycle-only fields). func hasWarehouseChanges(entry *PlanEntry) bool { return entry.Changes.HasChangeExcept("lifecycle", "lifecycle.started") } -// DoUpdate updates the warehouse in place. func (r *ResourceSqlWarehouse) DoUpdate(ctx context.Context, id string, config *SqlWarehouseState, entry *PlanEntry) (*SqlWarehouseRemote, error) { edited := hasWarehouseChanges(entry) if edited { - request := sql.EditWarehouseRequest{ - AutoStopMins: config.AutoStopMins, - Channel: config.Channel, - ClusterSize: config.ClusterSize, - CreatorName: config.CreatorName, - EnablePhoton: config.EnablePhoton, - EnableServerlessCompute: config.EnableServerlessCompute, - Id: id, - InstanceProfileArn: config.InstanceProfileArn, - MaxNumClusters: config.MaxNumClusters, - MinNumClusters: config.MinNumClusters, - Name: config.Name, - SpotInstancePolicy: config.SpotInstancePolicy, - StatementTimeout: config.StatementTimeout, - Tags: config.Tags, - WarehouseType: sql.EditWarehouseRequestWarehouseType(config.WarehouseType), - ForceSendFields: utils.FilterFields[sql.EditWarehouseRequest](config.ForceSendFields), + c := config.CreateWarehouseRequest + request, err := warehouses.EditWarehouseRequestToSDK(&warehouses.EditWarehouseRequest{ + AutoStopMins: c.AutoStopMins, + Channel: c.Channel, + ClusterSize: c.ClusterSize, + CreatorName: c.CreatorName, + EnablePhoton: c.EnablePhoton, + EnableServerlessCompute: c.EnableServerlessCompute, + Id: new(id), + InstanceProfileArn: c.InstanceProfileArn, + MaxNumClusters: c.MaxNumClusters, + MinNumClusters: c.MinNumClusters, + Name: c.Name, + SpotInstancePolicy: c.SpotInstancePolicy, + StatementTimeout: c.StatementTimeout, + Tags: c.Tags, + WarehouseType: c.WarehouseType, + }) + if err != nil { + return nil, err } - waiter, err := r.client.Warehouses.Edit(ctx, request) + waiter, err := r.client.Warehouses.EditWarehouse(ctx, *request) if err != nil { return nil, err } - if waiter.Id != id { - log.Warnf(ctx, "sql_warehouses: response contains unexpected id=%#v (expected %#v)", waiter.Id, id) + if waiter.GetId() != id { + log.Warnf(ctx, "sql_warehouses: response contains unexpected id=%#v (expected %#v)", waiter.GetId(), id) } } @@ -170,59 +151,77 @@ func (r *ResourceSqlWarehouse) DoUpdate(ctx context.Context, id string, config * desiredStarted := *config.Lifecycle.Started alreadyRunning := remoteWarehouseIsRunning(entry) if edited { - // Edit restarts the warehouse: its long-running op waits for RUNNING - // (SDK WaitGetWarehouseRunning), so reconcile from RUNNING, not the - // stale pre-plan state. alreadyRunning = true } if desiredStarted && !alreadyRunning { - // lifecycle.started=true: fire Start; WaitAfterUpdate polls for RUNNING. - _, err := r.client.Warehouses.Start(ctx, sql.StartRequest{Id: id}) + _, err := r.client.Warehouses.StartWarehouse(ctx, sdkwarehouses.StartRequest{Id: new(id)}) return nil, err } else if !desiredStarted && alreadyRunning { - // lifecycle.started=false: fire Stop; WaitAfterUpdate polls for STOPPED. - _, err := r.client.Warehouses.Stop(ctx, sql.StopRequest{Id: id}) + _, err := r.client.Warehouses.StopWarehouse(ctx, sdkwarehouses.StopRequest{Id: new(id)}) return nil, err } return nil, nil } -// WaitAfterUpdate waits for the warehouse to reach the desired lifecycle state after DoUpdate. +// waitWarehouseState polls until the warehouse reaches target. Reaching one of +// the failure states first is an error. +func (r *ResourceSqlWarehouse) waitWarehouseState(ctx context.Context, id string, target sdkwarehouses.EndpointState, failure ...sdkwarehouses.EndpointState) error { + _, err := retries.Poll(ctx, 20*time.Minute, func() (*sdkwarehouses.GetWarehouseResponse, *retries.Err) { + warehouse, err := r.client.Warehouses.GetWarehouse(ctx, sdkwarehouses.GetWarehouseRequest{Id: new(id)}) + if err != nil { + return nil, retries.Halt(err) + } + status := warehouse.State + statusMessage := fmt.Sprintf("current status: %s", status) + if warehouse.Health != nil { + statusMessage = utils.Deref(warehouse.Health.Summary) + } + if status == target { + return warehouse, nil + } + if slices.Contains(failure, status) { + return nil, retries.Halt(fmt.Errorf("failed to reach %s, got %s: %s", target, status, statusMessage)) + } + return nil, retries.Continues(statusMessage) + }) + return err +} + +func (r *ResourceSqlWarehouse) waitRunning(ctx context.Context, id string) error { + return r.waitWarehouseState(ctx, id, sdkwarehouses.EndpointState_Running, sdkwarehouses.EndpointState_Stopped, sdkwarehouses.EndpointState_Deleted) +} + +func (r *ResourceSqlWarehouse) waitStopped(ctx context.Context, id string) error { + return r.waitWarehouseState(ctx, id, sdkwarehouses.EndpointState_Stopped) +} + func (r *ResourceSqlWarehouse) WaitAfterUpdate(ctx context.Context, id string, config *SqlWarehouseState) (*SqlWarehouseRemote, error) { if config.Lifecycle == nil || config.Lifecycle.Started == nil { return nil, nil } if *config.Lifecycle.Started { - _, err := r.client.Warehouses.WaitGetWarehouseRunning(ctx, id, 20*time.Minute, nil) - return nil, err + return nil, r.waitRunning(ctx, id) } - - _, err := r.client.Warehouses.WaitGetWarehouseStopped(ctx, id, 20*time.Minute, nil) - return nil, err + return nil, r.waitStopped(ctx, id) } -// WaitAfterCreate waits for the warehouse to be ready, then stops it if lifecycle.started=false. -// Warehouses are created in a starting state; WaitGetWarehouseRunning waits for them to be RUNNING. func (r *ResourceSqlWarehouse) WaitAfterCreate(ctx context.Context, id string, config *SqlWarehouseState) (*SqlWarehouseRemote, error) { if config.Lifecycle == nil || config.Lifecycle.Started == nil { return nil, nil } - // Always wait for RUNNING first: warehouses start asynchronously. - _, err := r.client.Warehouses.WaitGetWarehouseRunning(ctx, id, 20*time.Minute, nil) - if err != nil { + if err := r.waitRunning(ctx, id); err != nil { return nil, err } if !*config.Lifecycle.Started { - // started=false: stop the warehouse after it reaches RUNNING. - stopWaiter, err := r.client.Warehouses.Stop(ctx, sql.StopRequest{Id: id}) + stopWaiter, err := r.client.Warehouses.StopWarehouse(ctx, sdkwarehouses.StopRequest{Id: new(id)}) if err != nil { return nil, err } - _, err = stopWaiter.Get() + _, err = stopWaiter.Wait(ctx) return nil, err } @@ -230,10 +229,10 @@ func (r *ResourceSqlWarehouse) WaitAfterCreate(ctx context.Context, id string, c } func (r *ResourceSqlWarehouse) DoDelete(ctx context.Context, oldID string, _ *SqlWarehouseState) error { - return r.client.Warehouses.DeleteById(ctx, oldID) + _, err := r.client.Warehouses.DeleteWarehouse(ctx, sdkwarehouses.DeleteWarehouseRequest{Id: new(oldID)}) + return err } -// remoteWarehouseIsRunning reads the warehouse running state from the plan entry's remote state. func remoteWarehouseIsRunning(entry *PlanEntry) bool { if entry.RemoteState == nil { return false @@ -242,5 +241,5 @@ func remoteWarehouseIsRunning(entry *PlanEntry) bool { if !ok { return false } - return remote.State == sql.StateRunning + return remote.State == warehouses.EndpointState_Running } diff --git a/bundle/direct/dresources/synced_database_table.go b/bundle/direct/dresources/synced_database_table.go index e1c0df12f00..20db65cef5a 100644 --- a/bundle/direct/dresources/synced_database_table.go +++ b/bundle/direct/dresources/synced_database_table.go @@ -4,15 +4,17 @@ import ( "context" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/database" + "github.com/databricks/cli/libs/sdkclients" + database "github.com/databricks/cli/libs/sdktypes/database/v1" + "github.com/databricks/cli/libs/utils" + sdkdatabase "github.com/databricks/sdk-go/database/v1" ) type ResourceSyncedDatabaseTable struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceSyncedDatabaseTable) New(client *databricks.WorkspaceClient) *ResourceSyncedDatabaseTable { +func (*ResourceSyncedDatabaseTable) New(client *sdkclients.Clients) *ResourceSyncedDatabaseTable { return &ResourceSyncedDatabaseTable{client: client} } @@ -21,23 +23,28 @@ func (*ResourceSyncedDatabaseTable) PrepareState(input *resources.SyncedDatabase } func (r *ResourceSyncedDatabaseTable) DoRead(ctx context.Context, name string) (*database.SyncedDatabaseTable, error) { - return r.client.Database.GetSyncedDatabaseTableByName(ctx, name) + table, err := r.client.Database.GetSyncedDatabaseTable(ctx, sdkdatabase.GetSyncedDatabaseTableRequest{Name: new(name)}) + if err != nil { + return nil, err + } + return database.SyncedDatabaseTableFromSDK(table) } func (r *ResourceSyncedDatabaseTable) DoCreate(ctx context.Context, config *database.SyncedDatabaseTable) (string, *database.SyncedDatabaseTable, error) { - result, err := r.client.Database.CreateSyncedDatabaseTable(ctx, database.CreateSyncedDatabaseTableRequest{ - SyncedTable: *config, - }) + request, err := database.CreateSyncedDatabaseTableRequestToSDK(&database.CreateSyncedDatabaseTableRequest{SyncedTable: config}) + if err != nil { + return "", nil, err + } + result, err := r.client.Database.CreateSyncedDatabaseTable(ctx, *request) if err != nil { return "", nil, err } - return result.Name, nil, nil + return utils.Deref(result.Name), nil, nil } func (r *ResourceSyncedDatabaseTable) DoDelete(ctx context.Context, id string, _ *database.SyncedDatabaseTable) error { - return r.client.Database.DeleteSyncedDatabaseTable(ctx, database.DeleteSyncedDatabaseTableRequest{ - Name: id, - PurgeData: false, - ForceSendFields: nil, + return r.client.Database.DeleteSyncedDatabaseTable(ctx, sdkdatabase.DeleteSyncedDatabaseTableRequest{ + Name: new(id), + PurgeData: nil, // Not set by DABs }) } diff --git a/bundle/direct/dresources/type_test.go b/bundle/direct/dresources/type_test.go index bc12c994621..071a323590a 100644 --- a/bundle/direct/dresources/type_test.go +++ b/bundle/direct/dresources/type_test.go @@ -16,6 +16,10 @@ import ( // These are known issues that should be fixed. If a field listed here is found in RemoteType, // the test fails to ensure the entry is removed from this map. var knownMissingInRemoteType = map[string][]string{ + "clusters": { + // clone_from is part of the create request but not supported by DABs; it is never returned on GET. + "clone_from", + }, "external_locations": { "skip_validation", }, diff --git a/bundle/direct/dresources/util.go b/bundle/direct/dresources/util.go index 3b918693ebf..f9dc0331dcd 100644 --- a/bundle/direct/dresources/util.go +++ b/bundle/direct/dresources/util.go @@ -1,12 +1,17 @@ package dresources import ( + "encoding/json" "errors" + "net/http" "slices" "strings" + "github.com/databricks/sdk-go/core/apierr" + "github.com/databricks/cli/bundle/deployplan" - "github.com/databricks/databricks-sdk-go/retries" + "github.com/databricks/cli/bundle/direct/internal/retries" + "github.com/databricks/cli/libs/sdktypes/sdkconv" ) type StateLifecycle struct { @@ -79,3 +84,51 @@ func maskPath(path string) string { } return path } + +// toSDK converts a JSON mirror value (or pointer to one) into an sdk-go request value. +func toSDK[S any](v any) (S, error) { + p, err := sdkconv.ToSDK[S](v) + if err != nil || p == nil { + var zero S + return zero, err + } + return *p, nil +} + +// orZero returns p, or a pointer to the zero value if p is nil. It is used for +// fields that must always be sent on update so that unsetting them in config +// clears them remotely. +func orZero[T any](p *T) *T { + if p == nil { + return new(T) + } + return p +} + +// nonEmpty returns a pointer to s, or nil if s is empty. It maps CLI string +// fields where "" means unset onto optional sdk-go fields. +func nonEmpty(s string) *string { + if s == "" { + return nil + } + return &s +} + +// errResourceDoesNotExist builds the error a GET of a missing resource returns, +// for resources whose existence is determined client-side (e.g. by listing). +func errResourceDoesNotExist(message string) error { + body, _ := json.Marshal(map[string]string{ + "error_code": "RESOURCE_DOES_NOT_EXIST", + "message": message, + }) + return apierr.FromHTTPError(http.StatusNotFound, nil, body) +} + +// trueOrNil returns a pointer to true if b is set and nil otherwise, for optional +// flags that are only sent when enabled. +func trueOrNil(b bool) *bool { + if !b { + return nil + } + return new(true) +} diff --git a/bundle/direct/dresources/vector_search_endpoint.go b/bundle/direct/dresources/vector_search_endpoint.go index 12470872b62..72fd1fa0d19 100644 --- a/bundle/direct/dresources/vector_search_endpoint.go +++ b/bundle/direct/dresources/vector_search_endpoint.go @@ -2,14 +2,16 @@ package dresources import ( "context" + "fmt" "time" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/bundle/direct/internal/retries" + "github.com/databricks/cli/libs/sdkclients" + vectorsearch "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" + sdkvectorsearch "github.com/databricks/sdk-go/vectorsearch/v1" ) var ( @@ -20,88 +22,107 @@ var ( // VectorSearchEndpointRemote is remote state for a vector search endpoint. It embeds API response // fields for drift comparison and adds endpoint_uuid for permissions; deployment state id remains the endpoint name. type VectorSearchEndpointRemote struct { - vectorsearch.EndpointInfo + vectorsearch.Endpoint EndpointUuid string `json:"endpoint_uuid"` - // TargetQps is mapped from EndpointInfo.ScalingInfo.RequestedTargetQps in DoRead + // TargetQps is mapped from Endpoint.ScalingInfo.RequestedTargetQps in DoRead // so that drift detection can compare it directly against the config field. - TargetQps int64 `json:"target_qps,omitempty"` + TargetQps *int64 `json:"target_qps,omitempty"` } -// Custom marshalers needed because embedded vectorsearch.EndpointInfo has its own -// MarshalJSON which would otherwise take over and ignore endpoint_uuid. -func (s *VectorSearchEndpointRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s VectorSearchEndpointRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - -func newVectorSearchEndpointRemote(info *vectorsearch.EndpointInfo) *VectorSearchEndpointRemote { - var targetQps int64 +func newVectorSearchEndpointRemote(endpoint *sdkvectorsearch.Endpoint) (*VectorSearchEndpointRemote, error) { + info, err := vectorsearch.EndpointFromSDK(endpoint) + if err != nil { + return nil, err + } + var targetQps *int64 if info.ScalingInfo != nil { targetQps = info.ScalingInfo.RequestedTargetQps } return &VectorSearchEndpointRemote{ - EndpointInfo: *info, - EndpointUuid: info.Id, + Endpoint: *info, + EndpointUuid: utils.Deref(info.Id), TargetQps: targetQps, - } + }, nil } type ResourceVectorSearchEndpoint struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceVectorSearchEndpoint) New(client *databricks.WorkspaceClient) *ResourceVectorSearchEndpoint { +func (*ResourceVectorSearchEndpoint) New(client *sdkclients.Clients) *ResourceVectorSearchEndpoint { return &ResourceVectorSearchEndpoint{client: client} } -func (*ResourceVectorSearchEndpoint) PrepareState(input *resources.VectorSearchEndpoint) *vectorsearch.CreateEndpoint { - return &input.CreateEndpoint +func (*ResourceVectorSearchEndpoint) PrepareState(input *resources.VectorSearchEndpoint) *vectorsearch.CreateEndpointRequest { + return &input.CreateEndpointRequest } -func (*ResourceVectorSearchEndpoint) RemapState(remote *VectorSearchEndpointRemote) *vectorsearch.CreateEndpoint { - return &vectorsearch.CreateEndpoint{ - Name: remote.Name, - EndpointType: remote.EndpointType, - BudgetPolicyId: remote.BudgetPolicyId, - UsagePolicyId: "", // Missing in remote - TargetQps: remote.TargetQps, - ForceSendFields: utils.FilterFields[vectorsearch.CreateEndpoint](remote.ForceSendFields, "UsagePolicyId"), +func (*ResourceVectorSearchEndpoint) RemapState(remote *VectorSearchEndpointRemote) *vectorsearch.CreateEndpointRequest { + return &vectorsearch.CreateEndpointRequest{ + Name: remote.Name, + EndpointType: remote.EndpointType, + BudgetPolicyId: remote.BudgetPolicyId, + UsagePolicyId: nil, // Missing in remote + TargetQps: remote.TargetQps, } } +func (r *ResourceVectorSearchEndpoint) getEndpoint(ctx context.Context, name string) (*sdkvectorsearch.Endpoint, error) { + return r.client.VectorSearch.GetEndpoint(ctx, sdkvectorsearch.GetEndpointRequest{Name: new(name)}) +} + func (r *ResourceVectorSearchEndpoint) DoRead(ctx context.Context, id string) (*VectorSearchEndpointRemote, error) { - info, err := r.client.VectorSearchEndpoints.GetEndpointByEndpointName(ctx, id) + endpoint, err := r.getEndpoint(ctx, id) if err != nil { return nil, err } - return newVectorSearchEndpointRemote(info), nil + return newVectorSearchEndpointRemote(endpoint) } -func (r *ResourceVectorSearchEndpoint) DoCreate(ctx context.Context, config *vectorsearch.CreateEndpoint) (string, *VectorSearchEndpointRemote, error) { - waiter, err := r.client.VectorSearchEndpoints.CreateEndpoint(ctx, *config) +func (r *ResourceVectorSearchEndpoint) DoCreate(ctx context.Context, config *vectorsearch.CreateEndpointRequest) (string, *VectorSearchEndpointRemote, error) { + request, err := vectorsearch.CreateEndpointRequestToSDK(config) if err != nil { return "", nil, err } - id := config.Name - return id, newVectorSearchEndpointRemote(waiter.Response), nil + if _, err := r.client.VectorSearch.CreateEndpoint(ctx, *request); err != nil { + return "", nil, err + } + return utils.Deref(config.Name), nil, nil } -func (r *ResourceVectorSearchEndpoint) WaitAfterCreate(ctx context.Context, id string, config *vectorsearch.CreateEndpoint) (*VectorSearchEndpointRemote, error) { - info, err := r.client.VectorSearchEndpoints.WaitGetEndpointVectorSearchEndpointOnline(ctx, config.Name, 60*time.Minute, nil) +func (r *ResourceVectorSearchEndpoint) WaitAfterCreate(ctx context.Context, id string, config *vectorsearch.CreateEndpointRequest) (*VectorSearchEndpointRemote, error) { + name := utils.Deref(config.Name) + endpoint, err := retries.Poll(ctx, 60*time.Minute, func() (*sdkvectorsearch.Endpoint, *retries.Err) { + endpoint, err := r.getEndpoint(ctx, name) + if err != nil { + return nil, retries.Halt(err) + } + var status sdkvectorsearch.EndpointStatus_State + statusMessage := "" + if endpoint.EndpointStatus != nil { + status = endpoint.EndpointStatus.State + statusMessage = utils.Deref(endpoint.EndpointStatus.Message) + } + switch status { + case sdkvectorsearch.EndpointStatus_State_Online: + return endpoint, nil + case sdkvectorsearch.EndpointStatus_State_Offline: + return nil, retries.Halt(fmt.Errorf("failed to reach %s, got %s: %s", sdkvectorsearch.EndpointStatus_State_Online, status, statusMessage)) + default: + return nil, retries.Continues(statusMessage) + } + }) if err != nil { return nil, err } - return newVectorSearchEndpointRemote(info), nil + return newVectorSearchEndpointRemote(endpoint) } -func (r *ResourceVectorSearchEndpoint) DoUpdate(ctx context.Context, id string, config *vectorsearch.CreateEndpoint, entry *PlanEntry) (*VectorSearchEndpointRemote, error) { +func (r *ResourceVectorSearchEndpoint) DoUpdate(ctx context.Context, id string, config *vectorsearch.CreateEndpointRequest, entry *PlanEntry) (*VectorSearchEndpointRemote, error) { if entry.Changes.HasChange(pathBudgetPolicyId) { - _, err := r.client.VectorSearchEndpoints.UpdateEndpointBudgetPolicy(ctx, vectorsearch.PatchEndpointBudgetPolicyRequest{ - EndpointName: id, - BudgetPolicyId: config.BudgetPolicyId, + _, err := r.client.VectorSearch.PatchEndpointBudgetPolicy(ctx, sdkvectorsearch.PatchEndpointBudgetPolicyRequest{ + Name: new(id), + BudgetPolicyId: orZero(config.BudgetPolicyId), }) if err != nil { return nil, err @@ -109,10 +130,9 @@ func (r *ResourceVectorSearchEndpoint) DoUpdate(ctx context.Context, id string, } if entry.Changes.HasChange(pathTargetQps) { - _, err := r.client.VectorSearchEndpoints.PatchEndpoint(ctx, vectorsearch.PatchEndpointRequest{ - EndpointName: id, - TargetQps: config.TargetQps, - ForceSendFields: nil, + _, err := r.client.VectorSearch.PatchEndpoint(ctx, sdkvectorsearch.PatchEndpointRequest{ + Name: new(id), + TargetQps: config.TargetQps, }) if err != nil { return nil, err @@ -122,6 +142,7 @@ func (r *ResourceVectorSearchEndpoint) DoUpdate(ctx context.Context, id string, return nil, nil } -func (r *ResourceVectorSearchEndpoint) DoDelete(ctx context.Context, id string, _ *vectorsearch.CreateEndpoint) error { - return r.client.VectorSearchEndpoints.DeleteEndpointByEndpointName(ctx, id) +func (r *ResourceVectorSearchEndpoint) DoDelete(ctx context.Context, id string, _ *vectorsearch.CreateEndpointRequest) error { + _, err := r.client.VectorSearch.DeleteEndpoint(ctx, sdkvectorsearch.DeleteEndpointRequest{Name: new(id)}) + return err } diff --git a/bundle/direct/dresources/vector_search_index.go b/bundle/direct/dresources/vector_search_index.go index 857e3fc44db..75d9068753d 100644 --- a/bundle/direct/dresources/vector_search_index.go +++ b/bundle/direct/dresources/vector_search_index.go @@ -2,19 +2,20 @@ package dresources import ( "context" - "errors" "fmt" "strings" "time" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/bundle/direct/internal/retries" + "github.com/databricks/cli/libs/sdkclients" + vectorsearch "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/retries" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" + "github.com/databricks/cli/libs/utils" + sdkvectorsearch "github.com/databricks/sdk-go/vectorsearch/v1" ) // deleteIndexTimeout caps the wait for an index deletion to complete. @@ -43,14 +44,6 @@ type VectorSearchIndexState struct { EndpointUuid string `json:"endpoint_uuid,omitempty"` } -func (s *VectorSearchIndexState) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s VectorSearchIndexState) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - // VectorSearchIndexRemote is remote state. endpoint_uuid is looked up from the // endpoint service since the index API itself doesn't return it. type VectorSearchIndexRemote struct { @@ -58,19 +51,11 @@ type VectorSearchIndexRemote struct { EndpointUuid string `json:"endpoint_uuid,omitempty"` } -func (s *VectorSearchIndexRemote) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, s) -} - -func (s VectorSearchIndexRemote) MarshalJSON() ([]byte, error) { - return marshal.Marshal(s) -} - type ResourceVectorSearchIndex struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceVectorSearchIndex) New(client *databricks.WorkspaceClient) *ResourceVectorSearchIndex { +func (*ResourceVectorSearchIndex) New(client *sdkclients.Clients) *ResourceVectorSearchIndex { return &ResourceVectorSearchIndex{client: client} } @@ -101,22 +86,30 @@ func (*ResourceVectorSearchIndex) RemapState(remote *VectorSearchIndexRemote) *V EmbeddingWritebackTable: remote.DeltaSyncIndexSpec.EmbeddingWritebackTable, PipelineType: remote.DeltaSyncIndexSpec.PipelineType, SourceTable: remote.DeltaSyncIndexSpec.SourceTable, - // ForceSendFields is an SDK marshaling concern (which zero-valued - // fields to wire-serialize) that has no meaning on the read path. - // Local config doesn't carry one either, so leave it nil rather - // than copy whatever the response struct happened to use. - ForceSendFields: nil, + PipelineId: nil, // Not set by DABs + // pipeline_id is output-only and not part of the config. } } return state } +func (r *ResourceVectorSearchIndex) getIndex(ctx context.Context, name string) (*sdkvectorsearch.VectorIndex, error) { + return r.client.VectorSearch.GetVectorIndex(ctx, sdkvectorsearch.GetVectorIndexRequest{ + Name: new(name), + EnsureRerankerCompatible: nil, // Not set by DABs + }) +} + func (r *ResourceVectorSearchIndex) DoRead(ctx context.Context, id string) (*VectorSearchIndexRemote, error) { - index, err := r.client.VectorSearchIndexes.GetIndexByIndexName(ctx, id) + resp, err := r.getIndex(ctx, id) if err != nil { return nil, err } - endpointUuid, err := r.lookupEndpointUuid(ctx, index.EndpointName) + index, err := vectorsearch.VectorIndexFromSDK(resp) + if err != nil { + return nil, err + } + endpointUuid, err := r.lookupEndpointUuid(ctx, utils.Deref(index.EndpointName)) if err != nil { return nil, err } @@ -127,7 +120,15 @@ func (r *ResourceVectorSearchIndex) DoRead(ctx context.Context, id string) (*Vec } func (r *ResourceVectorSearchIndex) DoCreate(ctx context.Context, config *VectorSearchIndexState) (string, *VectorSearchIndexRemote, error) { - index, err := r.createIndex(ctx, config.CreateVectorIndexRequest) + request, err := vectorsearch.CreateVectorIndexRequestToSDK(&config.CreateVectorIndexRequest) + if err != nil { + return "", nil, err + } + resp, err := r.createIndex(ctx, *request) + if err != nil { + return "", nil, err + } + index, err := vectorsearch.VectorIndexFromSDK(resp) if err != nil { return "", nil, err } @@ -135,12 +136,12 @@ func (r *ResourceVectorSearchIndex) DoCreate(ctx context.Context, config *Vector // endpoint UUID, but we need to persist it in state so a future plan can // detect that the endpoint was replaced out-of-band (same name, different // UUID -> orphan). - endpointUuid, err := r.lookupEndpointUuid(ctx, config.EndpointName) + endpointUuid, err := r.lookupEndpointUuid(ctx, utils.Deref(config.EndpointName)) if err != nil { return "", nil, err } config.EndpointUuid = endpointUuid - return config.Name, &VectorSearchIndexRemote{VectorIndex: *index, EndpointUuid: endpointUuid}, nil + return utils.Deref(config.Name), &VectorSearchIndexRemote{VectorIndex: *index, EndpointUuid: endpointUuid}, nil } // createIndex calls CreateIndex, retrying while the backend still reports the @@ -154,9 +155,9 @@ func (r *ResourceVectorSearchIndex) DoCreate(ctx context.Context, config *Vector // are observed on different endpoints, so the CREATE itself has to be retried. // The API exposes no DELETING state to poll for instead; remove this once it // does, or once CREATE queues behind the pending delete rather than failing. -func (r *ResourceVectorSearchIndex) createIndex(ctx context.Context, req vectorsearch.CreateVectorIndexRequest) (*vectorsearch.VectorIndex, error) { - return retries.Poll(ctx, pendingDeletionTimeout, func() (*vectorsearch.VectorIndex, *retries.Err) { - index, err := r.client.VectorSearchIndexes.CreateIndex(ctx, req) +func (r *ResourceVectorSearchIndex) createIndex(ctx context.Context, req sdkvectorsearch.CreateVectorIndexRequest) (*sdkvectorsearch.VectorIndex, error) { + return retries.Poll(ctx, pendingDeletionTimeout, func() (*sdkvectorsearch.VectorIndex, *retries.Err) { + index, err := r.client.VectorSearch.CreateVectorIndex(ctx, req) if err == nil { return index, nil } @@ -172,11 +173,10 @@ func (r *ResourceVectorSearchIndex) createIndex(ctx context.Context, req vectors // distinct error code for it — the backend returns a generic // INVALID_PARAMETER_VALUE — so the message has to be matched. func isIndexPendingDeletion(err error) bool { - if !errors.Is(err, apierr.ErrInvalidParameterValue) { + if !apierrs.Is(err, apierrs.ErrInvalidParameterValue) { return false } - apiErr, ok := errors.AsType[*apierr.APIError](err) - return ok && strings.Contains(apiErr.Message, "pending deletion") + return strings.Contains(apierrs.Message(err), "pending deletion") } // No DoUpdate: vector search indexes have no update API. All SDK fields are @@ -186,7 +186,8 @@ func isIndexPendingDeletion(err error) bool { // test in vector_search_index_test.go which catches it earlier at unit-test time). func (r *ResourceVectorSearchIndex) DoDelete(ctx context.Context, id string, _ *VectorSearchIndexState) error { - return r.client.VectorSearchIndexes.DeleteIndexByIndexName(ctx, id) + _, err := r.client.VectorSearch.DeleteVectorIndex(ctx, sdkvectorsearch.DeleteVectorIndexRequest{Name: new(id)}) + return err } // WaitAfterCreate polls GetIndex until Status.Ready=true. CreateIndex returns @@ -194,15 +195,15 @@ func (r *ResourceVectorSearchIndex) DoDelete(ctx context.Context, id string, _ * // provisioning; queries against an index that isn't ready fail. Blocking here // lets dependent resources (and the next plan) see a usable index. func (r *ResourceVectorSearchIndex) WaitAfterCreate(ctx context.Context, id string, config *VectorSearchIndexState) (*VectorSearchIndexRemote, error) { - index, err := retries.Poll(ctx, createIndexTimeout, func() (*vectorsearch.VectorIndex, *retries.Err) { - idx, getErr := r.client.VectorSearchIndexes.GetIndexByIndexName(ctx, id) + resp, err := retries.Poll(ctx, createIndexTimeout, func() (*sdkvectorsearch.VectorIndex, *retries.Err) { + idx, getErr := r.getIndex(ctx, id) if getErr != nil { return nil, retries.Halt(getErr) } - if idx.Status == nil || !idx.Status.Ready { + if idx.Status == nil || !utils.Deref(idx.Status.Ready) { msg := "index is still provisioning" - if idx.Status != nil && idx.Status.Message != "" { - msg = idx.Status.Message + if idx.Status != nil && utils.Deref(idx.Status.Message) != "" { + msg = *idx.Status.Message } return nil, retries.Continues(msg) } @@ -211,6 +212,10 @@ func (r *ResourceVectorSearchIndex) WaitAfterCreate(ctx context.Context, id stri if err != nil { return nil, err } + index, err := vectorsearch.VectorIndexFromSDK(resp) + if err != nil { + return nil, err + } return &VectorSearchIndexRemote{VectorIndex: *index, EndpointUuid: config.EndpointUuid}, nil } @@ -224,7 +229,7 @@ func (r *ResourceVectorSearchIndex) WaitAfterCreate(ctx context.Context, id stri // index disappears from GET, so createIndex retries the CREATE for the rest. func (r *ResourceVectorSearchIndex) WaitAfterDelete(ctx context.Context, id string) error { _, err := retries.Poll[struct{}](ctx, deleteIndexTimeout, func() (*struct{}, *retries.Err) { - _, getErr := r.client.VectorSearchIndexes.GetIndexByIndexName(ctx, id) + _, getErr := r.getIndex(ctx, id) if getErr != nil { return nil, retries.Halt(getErr) } @@ -272,12 +277,12 @@ func (r *ResourceVectorSearchIndex) lookupEndpointUuid(ctx context.Context, endp if endpointName == "" { return "", nil } - info, err := r.client.VectorSearchEndpoints.GetEndpointByEndpointName(ctx, endpointName) + info, err := r.client.VectorSearch.GetEndpoint(ctx, sdkvectorsearch.GetEndpointRequest{Name: new(endpointName)}) if err != nil { - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return "", nil } return "", fmt.Errorf("looking up vector search endpoint %q: %w", endpointName, err) } - return info.Id, nil + return utils.Deref(info.Id), nil } diff --git a/bundle/direct/dresources/vector_search_index_test.go b/bundle/direct/dresources/vector_search_index_test.go index 4bb49eb18d9..62e1b351108 100644 --- a/bundle/direct/dresources/vector_search_index_test.go +++ b/bundle/direct/dresources/vector_search_index_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/bundle/direct/dresources/volume.go b/bundle/direct/dresources/volume.go index 7cd1eaba1ce..017e0eb4869 100644 --- a/bundle/direct/dresources/volume.go +++ b/bundle/direct/dresources/volume.go @@ -3,117 +3,145 @@ package dresources import ( "context" "fmt" - "slices" "strings" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdkclients" + volumes "github.com/databricks/cli/libs/sdktypes/uc/volumes/v1" "github.com/databricks/cli/libs/utils" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/catalog" + sdkvolumes "github.com/databricks/sdk-go/uc/volumes/v1" ) type ResourceVolume struct { - client *databricks.WorkspaceClient + client *sdkclients.Clients } -func (*ResourceVolume) New(client *databricks.WorkspaceClient) *ResourceVolume { +func (*ResourceVolume) New(client *sdkclients.Clients) *ResourceVolume { return &ResourceVolume{client: client} } -func (*ResourceVolume) PrepareState(input *resources.Volume) *catalog.CreateVolumeRequestContent { +func (*ResourceVolume) PrepareState(input *resources.Volume) *resources.CreateVolumeRequestContent { return &input.CreateVolumeRequestContent } -func (*ResourceVolume) RemapState(info *catalog.VolumeInfo) *catalog.CreateVolumeRequestContent { - return &catalog.CreateVolumeRequestContent{ +func (*ResourceVolume) RemapState(info *volumes.VolumeInfo) *resources.CreateVolumeRequestContent { + return &resources.CreateVolumeRequestContent{ CatalogName: info.CatalogName, Comment: info.Comment, Name: info.Name, SchemaName: info.SchemaName, StorageLocation: info.StorageLocation, VolumeType: info.VolumeType, - ForceSendFields: utils.FilterFields[catalog.CreateVolumeRequestContent](info.ForceSendFields), } } -func (r *ResourceVolume) DoRead(ctx context.Context, id string) (*catalog.VolumeInfo, error) { - return r.client.Volumes.ReadByName(ctx, id) +func (r *ResourceVolume) DoRead(ctx context.Context, id string) (*volumes.VolumeInfo, error) { + info, err := r.client.Volumes.GetVolume(ctx, sdkvolumes.GetVolumeRequest{ + FullNameArg: new(id), + IncludeBrowse: nil, // Not set by DABs + }) + if err != nil { + return nil, err + } + return volumes.VolumeInfoFromSDK(info) } -func (r *ResourceVolume) DoCreate(ctx context.Context, config *catalog.CreateVolumeRequestContent) (string, *catalog.VolumeInfo, error) { - response, err := r.client.Volumes.Create(ctx, *config) +func (r *ResourceVolume) DoCreate(ctx context.Context, config *resources.CreateVolumeRequestContent) (string, *volumes.VolumeInfo, error) { + request, err := toSDK[sdkvolumes.CreateVolumeRequest](config.AsRequest()) if err != nil { return "", nil, err } - return response.FullName, response, nil + response, err := r.client.Volumes.CreateVolume(ctx, request) + if err != nil { + return "", nil, err + } + info, err := volumes.VolumeInfoFromSDK(response) + if err != nil { + return "", nil, err + } + return utils.Deref(info.FullName), info, nil } -// See schemaForceSend. Verified against a real workspace: {"comment": ""} clears it. -var volumeForceSend = []string{"Comment"} - -func (r *ResourceVolume) DoUpdate(ctx context.Context, id string, config *catalog.CreateVolumeRequestContent, _ *PlanEntry) (*catalog.VolumeInfo, error) { - updateRequest := catalog.UpdateVolumeRequestContent{ - Comment: config.Comment, - Name: id, - NewName: "", // Not supported by Update(). Needs DoUpdateWithID() - Owner: "", // Not supported by DABs - - ForceSendFields: utils.FilterFields[catalog.UpdateVolumeRequestContent](append(slices.Clone(volumeForceSend), config.ForceSendFields...), "NewName", "Owner"), +// comment is always sent, see ResourceSchema.DoUpdate. Verified against a real workspace: {"comment": ""} clears it. +// owner is not supported by DABs. +func (r *ResourceVolume) update(ctx context.Context, id string, config *resources.CreateVolumeRequestContent, newName *string) (*volumes.VolumeInfo, error) { + request, err := toSDK[sdkvolumes.UpdateVolumeRequest](&volumes.UpdateVolumeRequest{ + FullNameArg: new(id), + NewName: newName, + Comment: orZero(config.Comment), + AccessPoint: nil, // Not set by DABs + BrowseOnly: nil, // Not set by DABs + CatalogName: nil, // Not set by DABs + CreatedAt: nil, // Not set by DABs + CreatedBy: nil, // Not set by DABs + EncryptionDetails: nil, // Not set by DABs + FullName: nil, // Not set by DABs + MetastoreId: nil, // Not set by DABs + Name: nil, // Not set by DABs + Owner: nil, // Not set by DABs + SchemaName: nil, // Not set by DABs + StorageLocation: nil, // Not set by DABs + UpdatedAt: nil, // Not set by DABs + UpdatedBy: nil, // Not set by DABs + VolumeId: nil, // Not set by DABs + VolumeType: "", // Not set by DABs + }) + if err != nil { + return nil, err } + response, err := r.client.Volumes.UpdateVolume(ctx, request) + if err != nil { + return nil, err + } + return volumes.VolumeInfoFromSDK(response) +} +func (r *ResourceVolume) DoUpdate(ctx context.Context, id string, config *resources.CreateVolumeRequestContent, _ *PlanEntry) (*volumes.VolumeInfo, error) { nameFromID, err := getNameFromID(id) if err != nil { return nil, err } - if config.Name != nameFromID { - return nil, fmt.Errorf("internal error: unexpected change of name from %#v to %#v", nameFromID, config.Name) + if name := utils.Deref(config.Name); name != nameFromID { + return nil, fmt.Errorf("internal error: unexpected change of name from %#v to %#v", nameFromID, name) } - response, err := r.client.Volumes.Update(ctx, updateRequest) + // new_name is not supported by Update(), it needs DoUpdateWithID(). + response, err := r.update(ctx, id, config, nil) if err != nil { return nil, err } - if id != response.FullName { - log.Warnf(ctx, "volumes: response contains unexpected full_name=%#v (expected %#v)", response.FullName, id) + if fullName := utils.Deref(response.FullName); id != fullName { + log.Warnf(ctx, "volumes: response contains unexpected full_name=%#v (expected %#v)", fullName, id) } - return response, err + return response, nil } -func (r *ResourceVolume) DoUpdateWithID(ctx context.Context, id string, config *catalog.CreateVolumeRequestContent, _ *PlanEntry) (string, *catalog.VolumeInfo, error) { - updateRequest := catalog.UpdateVolumeRequestContent{ - Comment: config.Comment, - Name: id, - - NewName: "", // Initialized below if needed - Owner: "", // Not supported by DABs - - ForceSendFields: utils.FilterFields[catalog.UpdateVolumeRequestContent](append(slices.Clone(volumeForceSend), config.ForceSendFields...), "Owner"), - } - - items := strings.Split(id, ".") - if len(items) == 0 { - return "", nil, fmt.Errorf("unexpected id=%#v", id) +func (r *ResourceVolume) DoUpdateWithID(ctx context.Context, id string, config *resources.CreateVolumeRequestContent, _ *PlanEntry) (string, *volumes.VolumeInfo, error) { + nameFromID, err := getNameFromID(id) + if err != nil { + return "", nil, err } - nameFromID := items[len(items)-1] - if config.Name != nameFromID { - updateRequest.NewName = config.Name + var newName *string + if name := utils.Deref(config.Name); name != nameFromID { + newName = new(name) } - response, err := r.client.Volumes.Update(ctx, updateRequest) + response, err := r.update(ctx, id, config, newName) if err != nil || response == nil { return "", nil, err } - return response.FullName, response, nil + return utils.Deref(response.FullName), response, nil } -func (r *ResourceVolume) DoDelete(ctx context.Context, id string, _ *catalog.CreateVolumeRequestContent) error { - return r.client.Volumes.DeleteByName(ctx, id) +func (r *ResourceVolume) DoDelete(ctx context.Context, id string, _ *resources.CreateVolumeRequestContent) error { + _, err := r.client.Volumes.DeleteVolume(ctx, sdkvolumes.DeleteVolumeRequest{FullNameArg: new(id)}) + return err } func getNameFromID(id string) (string, error) { diff --git a/bundle/direct/dstate/migrate.go b/bundle/direct/dstate/migrate.go index e0ce585bedf..7312e094b7a 100644 --- a/bundle/direct/dstate/migrate.go +++ b/bundle/direct/dstate/migrate.go @@ -4,10 +4,10 @@ import ( "encoding/json" "fmt" + "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/direct/dresources" + grants "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/iam" ) // migrateState runs all necessary migrations on the database. @@ -112,7 +112,7 @@ func migratePermissionsEntry(raw json.RawMessage) (json.RawMessage, error) { } for _, p := range old.Permissions { newState.EmbeddedSlice = append(newState.EmbeddedSlice, dresources.StatePermission{ - Level: iam.PermissionLevel(p.PermissionLevel), + Level: resources.PermissionLevel(p.PermissionLevel), UserName: p.UserName, ServicePrincipalName: p.ServicePrincipalName, GroupName: p.GroupName, @@ -124,9 +124,9 @@ func migratePermissionsEntry(raw json.RawMessage) (json.RawMessage, error) { // oldGrantsStateV1 is the grants state format before v2. type oldGrantsStateV1 struct { - SecurableType string `json:"securable_type"` - FullName string `json:"full_name"` - Grants []catalog.PrivilegeAssignment `json:"grants,omitempty"` + SecurableType string `json:"securable_type"` + FullName string `json:"full_name"` + Grants []grants.PrivilegeAssignment `json:"grants,omitempty"` } func migrateGrantsEntry(raw json.RawMessage) (json.RawMessage, error) { diff --git a/bundle/direct/dstate/state.go b/bundle/direct/dstate/state.go index c0e7c4bfd89..7cae4fe40f2 100644 --- a/bundle/direct/dstate/state.go +++ b/bundle/direct/dstate/state.go @@ -20,10 +20,10 @@ import ( "github.com/databricks/cli/bundle/statemgmt/resourcestate" "github.com/databricks/cli/internal/build" "github.com/databricks/cli/libs/atomicfile" + "github.com/databricks/cli/libs/bundledeployments" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/dms" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" "github.com/google/uuid" ) diff --git a/bundle/direct/internal/retries/retries.go b/bundle/direct/internal/retries/retries.go new file mode 100644 index 00000000000..b3f469f2edc --- /dev/null +++ b/bundle/direct/internal/retries/retries.go @@ -0,0 +1,186 @@ +// Package retries is a copy of the polling helpers from databricks-sdk-go/retries, +// which sdk-go has no equivalent for. +package retries + +import ( + "context" + "fmt" + "math/rand/v2" + "strings" + "time" + + "github.com/databricks/cli/libs/log" +) + +type Err struct { + Err error + Halt bool +} + +func (e *Err) Error() string { + return e.Err.Error() +} + +func (e *Err) Unwrap() error { + return e.Err +} + +func Halt(err error) *Err { + return &Err{err, true} +} + +func Continue(err error) *Err { + return &Err{err, false} +} + +func Continues(msg string) *Err { + return Continue(fmt.Errorf("%s", msg)) +} + +var ( + maxWait = 10 * time.Second + minJitter = 50 * time.Millisecond + maxJitter = 750 * time.Millisecond +) + +func backoff(attempt int) time.Duration { + wait := min(time.Duration(attempt)*time.Second, maxWait) + // add some random jitter + jitter := rand.IntN(int(maxJitter)-int(minJitter)+1) + int(minJitter) + wait += time.Duration(jitter) + return wait +} + +type ErrTimedOut struct { + err error +} + +func (et *ErrTimedOut) Error() string { + return fmt.Sprintf("timed out: %s", et.err) +} + +func (et *ErrTimedOut) Unwrap() error { + return et.err +} + +// RetryOption is a function that sets part of the retry configuration for a retrier. +type RetryOption func(*RetryConfig) + +// RetryConfig is the configuration for a retrier. +type RetryConfig struct { + timeout time.Duration + shouldRetry func(error) bool + backoff func(int) time.Duration +} + +func (r RetryConfig) Timeout() time.Duration { + if r.timeout == 0 { + return 20 * time.Minute + } + return r.timeout +} + +func (r RetryConfig) Backoff(attempt int) time.Duration { + if r.backoff == nil { + return backoff(attempt) + } + return r.backoff(attempt) +} + +func (r RetryConfig) ShouldRetry(err error) bool { + if r.shouldRetry == nil { + return err != nil + } + return r.shouldRetry(err) +} + +// WithTimeout sets the timeout for the retrier. +func WithTimeout(timeout time.Duration) RetryOption { + return func(rc *RetryConfig) { + rc.timeout = timeout + } +} + +// WithRetryFunc sets the function that determines whether an error should halt the retrier. +// If the function returns true, the retrier will continue. If it returns false, the retrier will halt. +func WithRetryFunc(halt func(error) bool) RetryOption { + return func(rc *RetryConfig) { + rc.shouldRetry = halt + } +} + +// Retrier is a struct that can retry an operation until it succeeds or the timeout is reached. +// The empty struct indicates that the retrier should run for 20 minutes and retry on any non-nil error. +// The type parameter is the return type of the Run() method. +type Retrier[T any] struct { + config RetryConfig +} + +// New creates a new retrier with the given configuration. +// If no timeout is specified, the default is 20 minutes. If the timeout is negative, the retrier will run indefinitely. +// If no retry function is specified, the default is to retry on all errors. +func New[T any](configOpts ...RetryOption) Retrier[T] { + config := RetryConfig{} + for _, opt := range configOpts { + opt(&config) + } + return Retrier[T]{config} +} + +// Run runs the given function until it succeeds or the timeout is reached, returning the result. +// On timeout, it returns an error wrapping the last error returned by the function. +func (r Retrier[T]) Run(ctx context.Context, fn func(context.Context) (*T, error)) (*T, error) { + timeout := r.config.Timeout() + if timeout > 0 { + var cancel func() + ctx, cancel = context.WithTimeout(ctx, r.config.Timeout()) + defer cancel() + } + var attempt int + var lastErr error + for { + attempt++ + entity, err := fn(ctx) + if err == nil { + return entity, nil + } + if !r.config.ShouldRetry(err) { + log.Debugf(ctx, "non-retriable error: %s", err) + return nil, err + } + lastErr = err + wait := r.config.Backoff(attempt) + timer := time.NewTimer(wait) + log.Tracef(ctx, "%s. Sleeping %s", + strings.TrimSuffix(err.Error(), "."), + wait.Round(time.Millisecond)) + select { + // stop when either this or parent context times out + case <-ctx.Done(): + timer.Stop() + return nil, &ErrTimedOut{lastErr} + case <-timer.C: + } + } +} + +func shouldRetry(err error) bool { + if err == nil { + return false + } + e := err.(*Err) + if e == nil { + return false + } + return !e.Halt +} + +func Poll[T any](ctx context.Context, timeout time.Duration, fn func() (*T, *Err)) (*T, error) { + return New[T](WithTimeout(timeout), WithRetryFunc(shouldRetry)).Run(ctx, func(_ context.Context) (*T, error) { + res, err := fn() + if err != nil { + return res, err + } + return res, nil + }) +} diff --git a/bundle/direct/maxwait.go b/bundle/direct/maxwait.go index 6a9fff26ac9..8c0f151cf59 100644 --- a/bundle/direct/maxwait.go +++ b/bundle/direct/maxwait.go @@ -8,10 +8,10 @@ import ( "strings" "time" + "github.com/databricks/cli/bundle/direct/internal/retries" bundleenv "github.com/databricks/cli/bundle/env" "github.com/databricks/cli/libs/dagrun" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go/retries" ) // maxWaitUnset means "no cap configured", which must stay distinguishable from an explicit diff --git a/bundle/direct/maxwait_test.go b/bundle/direct/maxwait_test.go index da4fcdeaa43..9416c542913 100644 --- a/bundle/direct/maxwait_test.go +++ b/bundle/direct/maxwait_test.go @@ -6,10 +6,10 @@ import ( "testing" "time" + "github.com/databricks/cli/bundle/direct/internal/retries" bundleenv "github.com/databricks/cli/bundle/env" "github.com/databricks/cli/libs/dagrun" "github.com/databricks/cli/libs/env" - "github.com/databricks/databricks-sdk-go/retries" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/bundle/direct/tools/generate_resources.py b/bundle/direct/tools/generate_resources.py index 01302fedc79..76f2ce642f3 100644 --- a/bundle/direct/tools/generate_resources.py +++ b/bundle/direct/tools/generate_resources.py @@ -35,6 +35,22 @@ def parse_apitypes(generated_path, override_path): return result +# Maps the sdk-go based type names used in out.fields.txt (e.g. +# "modelserving.ServedEntityInput") to the cli.json schema names they mirror. +LEGACY_NAMES_PATH = Path(__file__).resolve().parents[2] / "internal" / "sdkmeta" / "legacy.json" + + +def load_legacy_names(path=LEGACY_NAMES_PATH): + names = json.loads(path.read_text())["names"] + out = {} + for full_name, legacy in names.items(): + pkg_path, _, type_name = full_name.rpartition(".") + segments = [seg for seg in pkg_path.split("/") if not re.fullmatch(r"v\d+", seg)] + short = f"{segments[-1]}.{type_name}" + out.setdefault(short, legacy) + return out + + def parse_out_fields(path): """Parse out.fields.txt to extract STATE field names per resource and array element types.""" state_fields = {} @@ -61,6 +77,7 @@ def parse_out_fields(path): if rest.endswith("[*]"): base_path = rest[:-3] elem_type = field_type.lstrip("*") + elem_type = LEGACY_NAMES.get(elem_type, elem_type) array_element_types[(resource, base_path)] = elem_type state_fields.setdefault(resource, set()).add(rest) @@ -210,6 +227,9 @@ def write_files(outdir, resource_behaviors): print(f"wrote {len(written)} files to {outdir}", file=sys.stderr) +LEGACY_NAMES = load_legacy_names() + + def main(): parser = argparse.ArgumentParser(description="Generate resources YAML from the cli.json schema block") parser.add_argument("apischema", type=Path, help="Path to cli.json schema block") diff --git a/bundle/direct/util.go b/bundle/direct/util.go index 1ec180fd20e..26c84f4d157 100644 --- a/bundle/direct/util.go +++ b/bundle/direct/util.go @@ -1,9 +1,7 @@ package direct import ( - "errors" - - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/apierrs" ) // isManagedByParent reports whether err is an API error carrying the @@ -14,10 +12,10 @@ import ( // the parent's Delete will cascade-clean. Mirrors the TF provider's // declarative.IsDeleteError suppression. func isManagedByParent(err error) bool { - apiErr, ok := errors.AsType[*apierr.APIError](err) + apiErr, ok := apierrs.Get(err) if !ok || apiErr == nil { return false } - info := apiErr.ErrorDetails().ErrorInfo + info := apiErr.Details().ErrorInfo return info != nil && info.Metadata["declarative_context"] == "MANAGED_BY_PARENT" } diff --git a/bundle/generate/alert.go b/bundle/generate/alert.go index eba68126dd8..dcafc43a413 100644 --- a/bundle/generate/alert.go +++ b/bundle/generate/alert.go @@ -3,15 +3,16 @@ package generate import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/utils" ) -func ConvertAlertToValue(alert *sql.AlertV2, filePath string) (dyn.Value, error) { +func ConvertAlertToValue(alert *alerts.Alert, filePath string) (dyn.Value, error) { // The majority of fields of the alert struct are present in .dbalert.json file. // We copy the relevant fields manually. dv := map[string]dyn.Value{ - "display_name": dyn.NewValue(alert.DisplayName, []diag.Location{{Line: 1}}), - "warehouse_id": dyn.NewValue(alert.WarehouseId, []diag.Location{{Line: 2}}), + "display_name": dyn.NewValue(utils.Deref(alert.DisplayName), []diag.Location{{Line: 1}}), + "warehouse_id": dyn.NewValue(utils.Deref(alert.WarehouseId), []diag.Location{{Line: 2}}), "file_path": dyn.NewValue(filePath, []diag.Location{{Line: 3}}), } diff --git a/bundle/generate/app.go b/bundle/generate/app.go index 0714fc9b324..032603f9b8b 100644 --- a/bundle/generate/app.go +++ b/bundle/generate/app.go @@ -4,7 +4,8 @@ import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/convert" - "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/libs/utils" ) func ConvertAppToValue(app *apps.App, sourceCodePath string) (dyn.Value, error) { @@ -16,8 +17,8 @@ func ConvertAppToValue(app *apps.App, sourceCodePath string) (dyn.Value, error) // The majority of fields of the app struct are read-only. // We copy the relevant fields manually. dv := map[string]dyn.Value{ - "name": dyn.NewValue(app.Name, []diag.Location{{Line: 1}}), - "description": dyn.NewValue(app.Description, []diag.Location{{Line: 2}}), + "name": dyn.NewValue(utils.Deref(app.Name), []diag.Location{{Line: 1}}), + "description": dyn.NewValue(utils.Deref(app.Description), []diag.Location{{Line: 2}}), } // For a git-backed app, emit git_repository + git_source instead of a @@ -42,11 +43,11 @@ func ConvertAppToValue(app *apps.App, sourceCodePath string) (dyn.Value, error) func gitRepositoryValue(r *apps.GitRepository) dyn.Value { m := map[string]dyn.Value{ - "url": dyn.NewValue(r.Url, []diag.Location{{Line: 1}}), - "provider": dyn.NewValue(r.Provider, []diag.Location{{Line: 2}}), + "url": dyn.NewValue(utils.Deref(r.Url), []diag.Location{{Line: 1}}), + "provider": dyn.NewValue(utils.Deref(r.Provider), []diag.Location{{Line: 2}}), } - if r.AutoDeploy { - m["auto_deploy"] = dyn.NewValue(r.AutoDeploy, []diag.Location{{Line: 3}}) + if utils.Deref(r.AutoDeploy) { + m["auto_deploy"] = dyn.NewValue(true, []diag.Location{{Line: 3}}) } return dyn.NewValue(m, []diag.Location{{Line: 3}}) } @@ -67,15 +68,15 @@ func gitSourceValue(app *apps.App) dyn.Value { m := map[string]dyn.Value{} switch { - case src.Branch != "": - m["branch"] = dyn.NewValue(src.Branch, []diag.Location{{Line: 1}}) - case src.Tag != "": - m["tag"] = dyn.NewValue(src.Tag, []diag.Location{{Line: 1}}) - case src.Commit != "": - m["commit"] = dyn.NewValue(src.Commit, []diag.Location{{Line: 1}}) + case utils.Deref(src.Branch) != "": + m["branch"] = dyn.NewValue(*src.Branch, []diag.Location{{Line: 1}}) + case utils.Deref(src.Tag) != "": + m["tag"] = dyn.NewValue(*src.Tag, []diag.Location{{Line: 1}}) + case utils.Deref(src.Commit) != "": + m["commit"] = dyn.NewValue(*src.Commit, []diag.Location{{Line: 1}}) } - if src.SourceCodePath != "" { - m["source_code_path"] = dyn.NewValue(src.SourceCodePath, []diag.Location{{Line: 2}}) + if sourceCodePath := utils.Deref(src.SourceCodePath); sourceCodePath != "" { + m["source_code_path"] = dyn.NewValue(sourceCodePath, []diag.Location{{Line: 2}}) } if len(m) == 0 { return dyn.NilValue diff --git a/bundle/generate/dashboard.go b/bundle/generate/dashboard.go index 6f045a39cb2..6a4329cb207 100644 --- a/bundle/generate/dashboard.go +++ b/bundle/generate/dashboard.go @@ -3,15 +3,16 @@ package generate import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/dashboards" + "github.com/databricks/cli/libs/sdktypes/lakeview/v1" + "github.com/databricks/cli/libs/utils" ) -func ConvertDashboardToValue(dashboard *dashboards.Dashboard, filePath string) (dyn.Value, error) { +func ConvertDashboardToValue(dashboard *lakeview.Dashboard, filePath string) (dyn.Value, error) { // The majority of fields of the dashboard struct are read-only. // We copy the relevant fields manually. dv := map[string]dyn.Value{ - "display_name": dyn.NewValue(dashboard.DisplayName, []diag.Location{{Line: 1}}), - "warehouse_id": dyn.NewValue(dashboard.WarehouseId, []diag.Location{{Line: 2}}), + "display_name": dyn.NewValue(utils.Deref(dashboard.DisplayName), []diag.Location{{Line: 1}}), + "warehouse_id": dyn.NewValue(utils.Deref(dashboard.WarehouseId), []diag.Location{{Line: 2}}), "file_path": dyn.NewValue(filePath, []diag.Location{{Line: 3}}), } diff --git a/bundle/generate/downloader.go b/bundle/generate/downloader.go index 6cacd948c58..cdb473b2f5b 100644 --- a/bundle/generate/downloader.go +++ b/bundle/generate/downloader.go @@ -10,27 +10,27 @@ import ( "path/filepath" "strings" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/notebook" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/workspaceapi" "golang.org/x/sync/errgroup" - - "github.com/databricks/databricks-sdk-go/client" ) type exportFile struct { path string - format workspace.ExportFormat + format workspaceapi.ExportFormat } type Downloader struct { files map[string]exportFile - w *databricks.WorkspaceClient + w *sdkclients.Clients sourceDir string configDir string basePath string @@ -53,13 +53,13 @@ func WithSparkPythonFiles() DownloaderOption { } } -func (n *Downloader) MarkTaskForDownload(ctx context.Context, task *jobs.Task) error { - if task.NotebookTask != nil { - return n.markNotebookForDownload(ctx, &task.NotebookTask.NotebookPath) +func (n *Downloader) MarkTaskForDownload(ctx context.Context, task *jobs.TaskSettings) error { + if task.NotebookTask != nil && task.NotebookTask.NotebookPath != nil { + return n.markNotebookForDownload(ctx, task.NotebookTask.NotebookPath) } - if n.downloadSparkPythonFiles && task.SparkPythonTask != nil && isWorkspaceFileTask(task.SparkPythonTask.Source, task.SparkPythonTask.PythonFile) { - return n.markFileForDownload(ctx, &task.SparkPythonTask.PythonFile) + if n.downloadSparkPythonFiles && task.SparkPythonTask != nil && isWorkspaceFileTask(task.SparkPythonTask.Source, utils.Deref(task.SparkPythonTask.PythonFile)) { + return n.markFileForDownload(ctx, task.SparkPythonTask.PythonFile) } return nil @@ -71,16 +71,16 @@ func (n *Downloader) MarkTaskForDownload(ctx context.Context, task *jobs.Task) e // (dbfs:/, s3:/, adls:/, gcs:/) which are not workspace paths; per the Jobs API, // workspace files are absolute and begin with "/". func isWorkspaceFileTask(source jobs.Source, filePath string) bool { - return source != jobs.SourceGit && strings.HasPrefix(filePath, "/") + return source != jobs.Source_Git && strings.HasPrefix(filePath, "/") } func (n *Downloader) MarkPipelineLibraryForDownload(ctx context.Context, lib *pipelines.PipelineLibrary) error { - if lib.Notebook != nil { - return n.markNotebookForDownload(ctx, &lib.Notebook.Path) + if lib.Notebook != nil && lib.Notebook.Path != nil { + return n.markNotebookForDownload(ctx, lib.Notebook.Path) } - if lib.File != nil { - return n.markFileForDownload(ctx, &lib.File.Path) + if lib.File != nil && lib.File.Path != nil { + return n.markFileForDownload(ctx, lib.File.Path) } return nil @@ -97,7 +97,7 @@ func (n *Downloader) markFileForDownload(ctx context.Context, filePath *string) n.files[targetPath] = exportFile{ path: *filePath, - format: workspace.ExportFormatSource, + format: workspaceapi.ExportFormatSource, } rel, err := filepath.Rel(n.configDir, targetPath) @@ -127,9 +127,9 @@ func (n *Downloader) MarkDirectoryForDownload(ctx context.Context, dirPath *stri for _, obj := range objects { switch obj.ObjectType { - case workspace.ObjectTypeDirectory: + case workspaceapi.ObjectTypeDirectory: continue - case workspace.ObjectTypeNotebook: + case workspaceapi.ObjectTypeNotebook: if err := n.markNotebookForDownload(ctx, &obj.Path); err != nil { return err } @@ -151,10 +151,10 @@ func (n *Downloader) MarkDirectoryForDownload(ctx context.Context, dirPath *stri // recursiveListWithExclusions recursively lists all files in a directory, // but skips recursing into directories that should be excluded (like node_modules). -func (n *Downloader) recursiveListWithExclusions(ctx context.Context, dirPath string) ([]workspace.ObjectInfo, error) { - var result []workspace.ObjectInfo +func (n *Downloader) recursiveListWithExclusions(ctx context.Context, dirPath string) ([]workspaceapi.ObjectInfo, error) { + var result []workspaceapi.ObjectInfo - objects, err := n.w.Workspace.ListAll(ctx, workspace.ListWorkspaceRequest{ + objects, err := n.w.Workspace.ListAll(ctx, workspaceapi.ListWorkspaceRequest{ Path: dirPath, }) if err != nil { @@ -162,7 +162,7 @@ func (n *Downloader) recursiveListWithExclusions(ctx context.Context, dirPath st } for _, obj := range objects { - if obj.ObjectType == workspace.ObjectTypeDirectory { + if obj.ObjectType == workspaceapi.ObjectTypeDirectory { if path.Base(obj.Path) == "node_modules" { continue } @@ -181,13 +181,13 @@ func (n *Downloader) recursiveListWithExclusions(ctx context.Context, dirPath st } type workspaceStatus struct { - Language workspace.Language `json:"language,omitempty"` - ObjectType workspace.ObjectType `json:"object_type,omitempty"` - ExportFormat workspace.ExportFormat `json:"repos_export_format,omitempty"` + Language workspaceapi.Language `json:"language,omitempty"` + ObjectType workspaceapi.ObjectType `json:"object_type,omitempty"` + ExportFormat workspaceapi.ExportFormat `json:"repos_export_format,omitempty"` } func (n *Downloader) markNotebookForDownload(ctx context.Context, notebookPath *string) error { - apiClient, err := client.New(n.w.Config) + apiClient, err := apiclient.New(n.w.Config) if err != nil { return err } @@ -219,11 +219,11 @@ func (n *Downloader) markNotebookForDownload(ctx context.Context, notebookPath * // (preserved above) and report no export format, so we use a fixed one. format = fixed } else { - ext := notebook.GetExtensionByLanguage(&workspace.ObjectInfo{ + ext := notebook.GetExtensionByLanguage(&workspaceapi.ObjectInfo{ Language: stat.Language, ObjectType: stat.ObjectType, }) - if format == workspace.ExportFormatJupyter { + if format == workspaceapi.ExportFormatJupyter { ext = notebook.ExtensionJupyter } relPath += ext @@ -246,14 +246,14 @@ func (n *Downloader) markNotebookForDownload(ctx context.Context, notebookPath * return nil } -func (n *Downloader) MarkTasksForDownload(ctx context.Context, tasks []jobs.Task) error { +func (n *Downloader) MarkTasksForDownload(ctx context.Context, tasks []jobs.TaskSettings) error { var paths []string for _, task := range tasks { - if task.NotebookTask != nil { - paths = append(paths, task.NotebookTask.NotebookPath) + if task.NotebookTask != nil && task.NotebookTask.NotebookPath != nil { + paths = append(paths, *task.NotebookTask.NotebookPath) } - if n.downloadSparkPythonFiles && task.SparkPythonTask != nil && isWorkspaceFileTask(task.SparkPythonTask.Source, task.SparkPythonTask.PythonFile) { - paths = append(paths, task.SparkPythonTask.PythonFile) + if n.downloadSparkPythonFiles && task.SparkPythonTask != nil && isWorkspaceFileTask(task.SparkPythonTask.Source, utils.Deref(task.SparkPythonTask.PythonFile)) { + paths = append(paths, *task.SparkPythonTask.PythonFile) } } if len(paths) > 0 { @@ -352,7 +352,7 @@ func (n *Downloader) FlushToDisk(ctx context.Context, force bool) error { return err } errs.Go(func() error { - reader, err := n.w.Workspace.Download(errCtx, exportFile.path, workspace.DownloadFormat(exportFile.format)) + reader, err := n.w.Workspace.Download(errCtx, exportFile.path, workspaceapi.DownloadFormat(exportFile.format)) if err != nil { return err } @@ -387,7 +387,7 @@ func writeAndClose(dst io.WriteCloser, src io.Reader) error { return err } -func NewDownloader(w *databricks.WorkspaceClient, sourceDir, configDir string, opts ...DownloaderOption) *Downloader { +func NewDownloader(w *sdkclients.Clients, sourceDir, configDir string, opts ...DownloaderOption) *Downloader { n := &Downloader{ files: make(map[string]exportFile), w: w, diff --git a/bundle/generate/downloader_test.go b/bundle/generate/downloader_test.go index ed2e4e6e145..0edca2b4c26 100644 --- a/bundle/generate/downloader_test.go +++ b/bundle/generate/downloader_test.go @@ -9,44 +9,39 @@ import ( "net/http/httptest" "os" "path/filepath" + "slices" "strings" "testing" "testing/iotest" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + workspace "github.com/databricks/cli/libs/workspaceapi" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestDownloader_MarkFileReturnsRelativePath(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) + f1 := "/a/b/c" + f2 := "/a/b/c/d" + w := newTestWorkspaceClient(t, objectsHandler(t, []string{f1, f2}, nil)) dir := "base/dir/doesnt/matter" sourceDir := filepath.Join(dir, "source") configDir := filepath.Join(dir, "config") - downloader := NewDownloader(m.WorkspaceClient, sourceDir, configDir) + downloader := NewDownloader(w, sourceDir, configDir) var err error // Test that the path is normalized to be relative to the config directory. - f1 := "/a/b/c" - m.GetMockWorkspaceAPI().EXPECT().GetStatusByPath(ctx, f1).Return(&workspace.ObjectInfo{ - Path: f1, - }, nil) err = downloader.markFileForDownload(ctx, &f1) require.NoError(t, err) assert.Equal(t, "../source/c", f1) // Test that the previous path doesn't influence the next path. - f2 := "/a/b/c/d" - m.GetMockWorkspaceAPI().EXPECT().GetStatusByPath(ctx, f2).Return(&workspace.ObjectInfo{ - Path: f2, - }, nil) err = downloader.markFileForDownload(ctx, &f2) require.NoError(t, err) assert.Equal(t, "../source/d", f2) @@ -54,47 +49,28 @@ func TestDownloader_MarkFileReturnsRelativePath(t *testing.T) { func TestDownloader_DoesNotRecurseIntoNodeModules(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) + rootPath := "/workspace/app" + + // Root directory contains: app.py, src/, node_modules/; src/ contains index.js. + // node_modules is not listed: listing it fails the test. + w := newTestWorkspaceClient(t, objectsHandler(t, + []string{rootPath, "/workspace/app/app.py", "/workspace/app/src/index.js"}, + map[string][]workspace.ObjectInfo{ + rootPath: { + {Path: "/workspace/app/app.py", ObjectType: workspace.ObjectTypeFile}, + {Path: "/workspace/app/src", ObjectType: workspace.ObjectTypeDirectory}, + {Path: "/workspace/app/node_modules", ObjectType: workspace.ObjectTypeDirectory}, + }, + "/workspace/app/src": { + {Path: "/workspace/app/src/index.js", ObjectType: workspace.ObjectTypeFile}, + }, + }, + )) dir := "base/dir" sourceDir := filepath.Join(dir, "source") configDir := filepath.Join(dir, "config") - downloader := NewDownloader(m.WorkspaceClient, sourceDir, configDir) - - rootPath := "/workspace/app" - - // Mock the root directory listing - m.GetMockWorkspaceAPI().EXPECT(). - GetStatusByPath(ctx, rootPath). - Return(&workspace.ObjectInfo{Path: rootPath}, nil) - - // Root directory contains: app.py, src/, node_modules/ - m.GetMockWorkspaceAPI().EXPECT(). - ListAll(ctx, workspace.ListWorkspaceRequest{Path: rootPath}). - Return([]workspace.ObjectInfo{ - {Path: "/workspace/app/app.py", ObjectType: workspace.ObjectTypeFile}, - {Path: "/workspace/app/src", ObjectType: workspace.ObjectTypeDirectory}, - {Path: "/workspace/app/node_modules", ObjectType: workspace.ObjectTypeDirectory}, - }, nil) - - // src/ directory contains: index.js - m.GetMockWorkspaceAPI().EXPECT(). - ListAll(ctx, workspace.ListWorkspaceRequest{Path: "/workspace/app/src"}). - Return([]workspace.ObjectInfo{ - {Path: "/workspace/app/src/index.js", ObjectType: workspace.ObjectTypeFile}, - }, nil) - - // We should NOT list node_modules directory - this is the key assertion - // If this expectation is not met, the test will fail - - // Mock file downloads to make markFileForDownload work - m.GetMockWorkspaceAPI().EXPECT(). - GetStatusByPath(ctx, "/workspace/app/app.py"). - Return(&workspace.ObjectInfo{Path: "/workspace/app/app.py"}, nil) - - m.GetMockWorkspaceAPI().EXPECT(). - GetStatusByPath(ctx, "/workspace/app/src/index.js"). - Return(&workspace.ObjectInfo{Path: "/workspace/app/src/index.js"}, nil) + downloader := NewDownloader(w, sourceDir, configDir) // Execute err := downloader.MarkDirectoryForDownload(ctx, &rootPath) @@ -155,7 +131,36 @@ func TestCommonDirPrefix(t *testing.T) { } } -func newTestWorkspaceClient(t *testing.T, handler http.HandlerFunc) *databricks.WorkspaceClient { +// objectsHandler serves get-status for the given objects and list for the +// given directory contents; any other request fails the test. +func objectsHandler(t *testing.T, objects []string, dirs map[string][]workspace.ObjectInfo) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + path := r.URL.Query().Get("path") + switch r.URL.Path { + case "/api/2.0/workspace/get-status": + if !slices.Contains(objects, path) { + t.Errorf("unexpected get-status path: %s", path) + http.NotFound(w, r) + return + } + assert.NoError(t, json.NewEncoder(w).Encode(workspace.ObjectInfo{Path: path})) + case "/api/2.0/workspace/list": + children, ok := dirs[path] + if !ok { + t.Errorf("unexpected list path: %s", path) + http.NotFound(w, r) + return + } + assert.NoError(t, json.NewEncoder(w).Encode(map[string]any{"objects": children})) + default: + t.Errorf("unexpected request: %s %s", r.Method, r.URL.Path) + http.NotFound(w, r) + } + } +} + +func newTestWorkspaceClient(t *testing.T, handler http.HandlerFunc) *sdkclients.Clients { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.Path == "/.well-known/databricks-config" { http.NotFound(w, r) @@ -166,9 +171,10 @@ func newTestWorkspaceClient(t *testing.T, handler http.HandlerFunc) *databricks. })) t.Cleanup(server.Close) - w, err := databricks.NewWorkspaceClient(&databricks.Config{ - Host: server.URL, - Token: "test-token", + w, err := sdkclients.New(t.Context(), &config.Config{ + Host: server.URL, + Token: "test-token", + Loaders: []config.Loader{config.ConfigAttributes}, }) require.NoError(t, err) return w @@ -216,11 +222,11 @@ func TestDownloader_MarkTasksForDownload_DesignerNotebook(t *testing.T) { configDir := filepath.Join(dir, "config") downloader := NewDownloader(w, sourceDir, configDir) - tasks := []jobs.Task{ + tasks := []jobs.TaskSettings{ { - TaskKey: "designer_task", + TaskKey: new("designer_task"), NotebookTask: &jobs.NotebookTask{ - NotebookPath: "/Users/user/project/My Pipeline.designer.ipynb", + NotebookPath: new("/Users/user/project/My Pipeline.designer.ipynb"), }, }, } @@ -229,7 +235,7 @@ func TestDownloader_MarkTasksForDownload_DesignerNotebook(t *testing.T) { require.NoError(t, err) // The ".designer.ipynb" suffix must be preserved, not stripped to ".designer". - assert.Equal(t, "../source/My Pipeline.designer.ipynb", tasks[0].NotebookTask.NotebookPath) + assert.Equal(t, "../source/My Pipeline.designer.ipynb", *tasks[0].NotebookTask.NotebookPath) require.Len(t, downloader.files, 1) f := downloader.files[filepath.Join(sourceDir, "My Pipeline.designer.ipynb")] assert.Equal(t, "/Users/user/project/My Pipeline.designer.ipynb", f.path) @@ -246,17 +252,17 @@ func TestDownloader_MarkTasksForDownload_PreservesStructure(t *testing.T) { configDir := filepath.Join(dir, "config") downloader := NewDownloader(w, sourceDir, configDir) - tasks := []jobs.Task{ + tasks := []jobs.TaskSettings{ { - TaskKey: "extract_task", + TaskKey: new("extract_task"), NotebookTask: &jobs.NotebookTask{ - NotebookPath: "/Users/user/project/etl/extract", + NotebookPath: new("/Users/user/project/etl/extract"), }, }, { - TaskKey: "dashboard_task", + TaskKey: new("dashboard_task"), NotebookTask: &jobs.NotebookTask{ - NotebookPath: "/Users/user/project/reporting/dashboard", + NotebookPath: new("/Users/user/project/reporting/dashboard"), }, }, } @@ -264,8 +270,8 @@ func TestDownloader_MarkTasksForDownload_PreservesStructure(t *testing.T) { err := downloader.MarkTasksForDownload(t.Context(), tasks) require.NoError(t, err) - assert.Equal(t, "../source/etl/extract.py", tasks[0].NotebookTask.NotebookPath) - assert.Equal(t, "../source/reporting/dashboard.py", tasks[1].NotebookTask.NotebookPath) + assert.Equal(t, "../source/etl/extract.py", *tasks[0].NotebookTask.NotebookPath) + assert.Equal(t, "../source/reporting/dashboard.py", *tasks[1].NotebookTask.NotebookPath) assert.Len(t, downloader.files, 2) } @@ -278,11 +284,11 @@ func TestDownloader_MarkTasksForDownload_SingleNotebook(t *testing.T) { configDir := filepath.Join(dir, "config") downloader := NewDownloader(w, sourceDir, configDir) - tasks := []jobs.Task{ + tasks := []jobs.TaskSettings{ { - TaskKey: "task1", + TaskKey: new("task1"), NotebookTask: &jobs.NotebookTask{ - NotebookPath: "/Users/user/project/notebook", + NotebookPath: new("/Users/user/project/notebook"), }, }, } @@ -291,29 +297,25 @@ func TestDownloader_MarkTasksForDownload_SingleNotebook(t *testing.T) { require.NoError(t, err) // Single notebook: basePath = path.Dir => same as old behavior. - assert.Equal(t, "../source/notebook.py", tasks[0].NotebookTask.NotebookPath) + assert.Equal(t, "../source/notebook.py", *tasks[0].NotebookTask.NotebookPath) assert.Len(t, downloader.files, 1) } func TestDownloader_MarkTasksForDownload_SparkPythonFile(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) + pythonFile := "/Users/user/project/etl/job.py" + w := newTestWorkspaceClient(t, objectsHandler(t, []string{pythonFile}, nil)) dir := "base/dir" sourceDir := filepath.Join(dir, "source") configDir := filepath.Join(dir, "config") - downloader := NewDownloader(m.WorkspaceClient, sourceDir, configDir, WithSparkPythonFiles()) - - pythonFile := "/Users/user/project/etl/job.py" - m.GetMockWorkspaceAPI().EXPECT().GetStatusByPath(ctx, pythonFile).Return(&workspace.ObjectInfo{ - Path: pythonFile, - }, nil) + downloader := NewDownloader(w, sourceDir, configDir, WithSparkPythonFiles()) - tasks := []jobs.Task{ + tasks := []jobs.TaskSettings{ { - TaskKey: "spark_python_task", + TaskKey: new("spark_python_task"), SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: pythonFile, + PythonFile: new(pythonFile), }, }, } @@ -321,7 +323,7 @@ func TestDownloader_MarkTasksForDownload_SparkPythonFile(t *testing.T) { err := downloader.MarkTasksForDownload(ctx, tasks) require.NoError(t, err) - assert.Equal(t, "../source/job.py", tasks[0].SparkPythonTask.PythonFile) + assert.Equal(t, "../source/job.py", *tasks[0].SparkPythonTask.PythonFile) require.Len(t, downloader.files, 1) f := downloader.files[filepath.Join(sourceDir, "job.py")] assert.Equal(t, pythonFile, f.path) @@ -338,18 +340,18 @@ func TestDownloader_MarkTasksForDownload_SparkPythonFileSkipped(t *testing.T) { downloader := NewDownloader(w, "source", "config", WithSparkPythonFiles()) - tasks := []jobs.Task{ + tasks := []jobs.TaskSettings{ { - TaskKey: "cloud_uri_task", + TaskKey: new("cloud_uri_task"), SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "dbfs:/FileStore/job.py", + PythonFile: new("dbfs:/FileStore/job.py"), }, }, { - TaskKey: "git_task", + TaskKey: new("git_task"), SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "etl/job.py", - Source: jobs.SourceGit, + PythonFile: new("etl/job.py"), + Source: jobs.Source_Git, }, }, } @@ -357,8 +359,8 @@ func TestDownloader_MarkTasksForDownload_SparkPythonFileSkipped(t *testing.T) { err := downloader.MarkTasksForDownload(ctx, tasks) require.NoError(t, err) assert.Empty(t, downloader.files) - assert.Equal(t, "dbfs:/FileStore/job.py", tasks[0].SparkPythonTask.PythonFile) - assert.Equal(t, "etl/job.py", tasks[1].SparkPythonTask.PythonFile) + assert.Equal(t, "dbfs:/FileStore/job.py", *tasks[0].SparkPythonTask.PythonFile) + assert.Equal(t, "etl/job.py", *tasks[1].SparkPythonTask.PythonFile) } func TestDownloader_MarkTasksForDownload_SparkPythonFileDisabledByDefault(t *testing.T) { @@ -372,11 +374,11 @@ func TestDownloader_MarkTasksForDownload_SparkPythonFileDisabledByDefault(t *tes downloader := NewDownloader(w, "source", "config") pythonFile := "/Users/user/project/etl/job.py" - tasks := []jobs.Task{ + tasks := []jobs.TaskSettings{ { - TaskKey: "spark_python_task", + TaskKey: new("spark_python_task"), SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: pythonFile, + PythonFile: new(pythonFile), }, }, } @@ -384,7 +386,7 @@ func TestDownloader_MarkTasksForDownload_SparkPythonFileDisabledByDefault(t *tes err := downloader.MarkTasksForDownload(ctx, tasks) require.NoError(t, err) assert.Empty(t, downloader.files) - assert.Equal(t, pythonFile, tasks[0].SparkPythonTask.PythonFile) + assert.Equal(t, pythonFile, *tasks[0].SparkPythonTask.PythonFile) } func TestDownloader_MarkTasksForDownload_NoNotebooks(t *testing.T) { @@ -395,9 +397,9 @@ func TestDownloader_MarkTasksForDownload_NoNotebooks(t *testing.T) { downloader := NewDownloader(w, "source", "config") - tasks := []jobs.Task{ - {TaskKey: "spark_task"}, - {TaskKey: "python_wheel_task"}, + tasks := []jobs.TaskSettings{ + {TaskKey: new("spark_task")}, + {TaskKey: new("python_wheel_task")}, } err := downloader.MarkTasksForDownload(ctx, tasks) diff --git a/bundle/generate/genie_space.go b/bundle/generate/genie_space.go index 639c65f314b..04096689873 100644 --- a/bundle/generate/genie_space.go +++ b/bundle/generate/genie_space.go @@ -3,26 +3,27 @@ package generate import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/dashboards" + "github.com/databricks/cli/libs/sdktypes/genie/v1" + "github.com/databricks/cli/libs/utils" ) -func ConvertGenieSpaceToValue(genieSpace *dashboards.GenieSpace, filePath string) (dyn.Value, error) { +func ConvertGenieSpaceToValue(genieSpace *genie.GenieSpace, filePath string) (dyn.Value, error) { // Emit only the fields a user authors in a bundle. serialized_space is // written to a separate file and referenced via file_path, and output-only // fields (e.g. space_id, etag) must not appear in the generated config, so // we build the value field by field rather than marshaling the struct. dv := map[string]dyn.Value{ - "title": dyn.NewValue(genieSpace.Title, []diag.Location{{Line: 1}}), - "warehouse_id": dyn.NewValue(genieSpace.WarehouseId, []diag.Location{{Line: 2}}), + "title": dyn.NewValue(utils.Deref(genieSpace.Title), []diag.Location{{Line: 1}}), + "warehouse_id": dyn.NewValue(utils.Deref(genieSpace.WarehouseId), []diag.Location{{Line: 2}}), "file_path": dyn.NewValue(filePath, []diag.Location{{Line: 3}}), } - if genieSpace.Description != "" { - dv["description"] = dyn.NewValue(genieSpace.Description, []diag.Location{{Line: 4}}) + if description := utils.Deref(genieSpace.Description); description != "" { + dv["description"] = dyn.NewValue(description, []diag.Location{{Line: 4}}) } - if genieSpace.ParentPath != "" { - dv["parent_path"] = dyn.NewValue(ensureWorkspacePrefix(genieSpace.ParentPath), []diag.Location{{Line: 5}}) + if parentPath := utils.Deref(genieSpace.ParentPath); parentPath != "" { + dv["parent_path"] = dyn.NewValue(ensureWorkspacePrefix(parentPath), []diag.Location{{Line: 5}}) } return dyn.V(dv), nil diff --git a/bundle/generate/job.go b/bundle/generate/job.go index 801eee1f5bd..8277da3ff2d 100644 --- a/bundle/generate/job.go +++ b/bundle/generate/job.go @@ -4,7 +4,8 @@ import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/yamlsaver" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" ) var ( @@ -12,7 +13,7 @@ var ( taskOrder = yamlsaver.NewOrder([]string{"task_key", "depends_on", "existing_cluster_id", "new_cluster", "job_cluster_key"}) ) -func ConvertJobToValue(job *jobs.Job) (dyn.Value, error) { +func ConvertJobToValue(job *jobs.GetJobResponse) (dyn.Value, error) { value := make(map[string]dyn.Value) if job.Settings.Tasks != nil { var tasks []dyn.Value @@ -32,8 +33,8 @@ func ConvertJobToValue(job *jobs.Job) (dyn.Value, error) { var params []dyn.Value for _, parameter := range job.Settings.Parameters { p := map[string]dyn.Value{ - "name": dyn.NewValue(parameter.Name, []diag.Location{{Line: 0}}), // We use Line: 0 to ensure that the name goes first. - "default": dyn.NewValue(parameter.Default, []diag.Location{{Line: 1}}), + "name": dyn.NewValue(utils.Deref(parameter.Name), []diag.Location{{Line: 0}}), // We use Line: 0 to ensure that the name goes first. + "default": dyn.NewValue(utils.Deref(parameter.Default), []diag.Location{{Line: 1}}), } params = append(params, dyn.V(p)) } @@ -44,7 +45,7 @@ func ConvertJobToValue(job *jobs.Job) (dyn.Value, error) { return yamlsaver.ConvertToMapValue(job.Settings, jobOrder, []string{"format", "new_cluster", "existing_cluster_id"}, value) } -func convertTaskToValue(task jobs.Task, order *yamlsaver.Order) (dyn.Value, error) { +func convertTaskToValue(task jobs.TaskSettings, order *yamlsaver.Order) (dyn.Value, error) { dst := make(map[string]dyn.Value) return yamlsaver.ConvertToMapValue(task, order, []string{"format"}, dst) } diff --git a/bundle/generate/pipeline.go b/bundle/generate/pipeline.go index 115330ea0f6..31941722ea6 100644 --- a/bundle/generate/pipeline.go +++ b/bundle/generate/pipeline.go @@ -5,21 +5,22 @@ import ( "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/yamlsaver" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/utils" ) var pipelineOrder = yamlsaver.NewOrder([]string{"name", "clusters", "configuration", "libraries"}) func ConvertPipelineToValue(pipeline *pipelines.PipelineSpec, rootPath, remoteRootPath string) (dyn.Value, error) { - if pipeline.RootPath != "" { - pipeline.RootPath = rootPath + if utils.Deref(pipeline.RootPath) != "" { + pipeline.RootPath = new(rootPath) } if pipeline.Libraries != nil && remoteRootPath != "" { for i := range pipeline.Libraries { lib := &pipeline.Libraries[i] - if lib.Glob != nil { - lib.Glob.Include = strings.ReplaceAll(lib.Glob.Include, remoteRootPath, rootPath) + if lib.Glob != nil && lib.Glob.Include != nil { + lib.Glob.Include = new(strings.ReplaceAll(*lib.Glob.Include, remoteRootPath, rootPath)) } } } diff --git a/bundle/internal/bundletest/benchmark.go b/bundle/internal/bundletest/benchmark.go index 59647d814fd..123340ef42c 100644 --- a/bundle/internal/bundletest/benchmark.go +++ b/bundle/internal/bundletest/benchmark.go @@ -10,7 +10,7 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/require" ) diff --git a/bundle/internal/bundletest/clients.go b/bundle/internal/bundletest/clients.go new file mode 100644 index 00000000000..fa7e937ee9a --- /dev/null +++ b/bundle/internal/bundletest/clients.go @@ -0,0 +1,23 @@ +package bundletest + +import ( + "testing" + + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/testserver" + "github.com/databricks/databricks-sdk-go/config" + "github.com/stretchr/testify/require" +) + +// NewClients starts a test server and returns sdk-go clients that talk to it. +// Register the endpoints a test needs with server.Handle. +func NewClients(t *testing.T) (*sdkclients.Clients, *testserver.Server) { + server := testserver.New(t) + w, err := sdkclients.New(t.Context(), &config.Config{ + Host: server.URL, + Token: "testtoken", + Loaders: []config.Loader{config.ConfigAttributes}, + }) + require.NoError(t, err) + return w, server +} diff --git a/bundle/internal/poll/poll.go b/bundle/internal/poll/poll.go new file mode 100644 index 00000000000..8d0f8788eeb --- /dev/null +++ b/bundle/internal/poll/poll.go @@ -0,0 +1,50 @@ +// Package poll waits for long-running operations whose progress the CLI +// reports itself. sdk-go waiters poll silently, so callers that print +// progress on every poll use this instead. +package poll + +import ( + "context" + "errors" + "fmt" + "math/rand/v2" + "time" +) + +// Status is the outcome of one poll. +type Status[T any] struct { + // Done reports that the operation reached its target state; Result is returned. + Done bool + Result *T + // Message describes the current state; it becomes the timeout error. + Message string +} + +// Until calls fn until it reports Done or returns an error, waiting between +// attempts with linear backoff (1s per attempt, up to 10s, plus jitter). When +// timeout expires it returns "timed out: ". +func Until[T any](ctx context.Context, timeout time.Duration, fn func(context.Context) (Status[T], error)) (*T, error) { + ctx, cancel := context.WithTimeout(ctx, timeout) + defer cancel() + for attempt := 1; ; attempt++ { + status, err := fn(ctx) + if err != nil { + return nil, err + } + if status.Done { + return status.Result, nil + } + timer := time.NewTimer(backoff(attempt)) + select { + case <-ctx.Done(): + timer.Stop() + return nil, fmt.Errorf("timed out: %w", errors.New(status.Message)) + case <-timer.C: + } + } +} + +func backoff(attempt int) time.Duration { + wait := min(time.Duration(attempt)*time.Second, 10*time.Second) + return wait + time.Duration(50+rand.IntN(701))*time.Millisecond +} diff --git a/bundle/internal/schema/annotations.go b/bundle/internal/schema/annotations.go index 548cf5ae95f..5159f8687d2 100644 --- a/bundle/internal/schema/annotations.go +++ b/bundle/internal/schema/annotations.go @@ -6,6 +6,8 @@ import ( "regexp" "strings" + "github.com/databricks/cli/bundle/internal/sdkmeta" + "github.com/databricks/cli/bundle/internal/annotation" "github.com/databricks/cli/internal/clijson" "github.com/databricks/cli/libs/dyn" @@ -106,6 +108,12 @@ func (d *annotationHandler) addAnnotations(typ reflect.Type, s jsonschema.Schema if !shouldHandle { return s } + // API types without a previous SDK name are only reachable through fields + // cli.json does not define; their definitions are dropped (see + // dropUnreachableAPIDefinitions), so they need no documentation. + if isUnmappedAPIPath(refPath) { + return s + } ta := d.parsedAnnotations[refPath] assignAnnotation(&s, ta.Self) @@ -140,8 +148,35 @@ func (d *annotationHandler) syncWithMissingAnnotations(outputPath string, g *typ return nil } +// getPath returns the key annotations of typ are stored under. API types use +// their previous SDK type path (see legacyTypePaths), so that several sdk-go +// types standing for one previous type share their documentation. func getPath(typ reflect.Type) string { - return typ.PkgPath() + "." + typ.Name() + return legacyTypePath(typ.PkgPath() + "." + typ.Name()) +} + +// legacyTypePaths maps jsonschema type paths of API types to the type paths of +// the previous SDK types. It is set once the configuration is mapped. +var legacyTypePaths map[string]string + +func legacyTypePath(p string) string { + if l, ok := legacyTypePaths[p]; ok { + return l + } + return p +} + +func isUnmappedAPIPath(p string) bool { + return strings.HasPrefix(p, "github.com/databricks/cli/libs/sdktypes/") || strings.HasPrefix(p, "github.com/databricks/sdk-go/") +} + +func setLegacyTypePaths(meta *sdkmeta.Meta) { + legacyTypePaths = map[string]string{} + for t := range meta.Types() { + if name, ok := meta.DefinitionName(t); ok { + legacyTypePaths[jsonschemaTypePath(t)] = name + } + } } func assignAnnotation(s *jsonschema.Schema, a annotation.Descriptor) { diff --git a/bundle/internal/schema/annotations.yml b/bundle/internal/schema/annotations.yml index 710e4b8373f..3fa9fc73e9a 100644 --- a/bundle/internal/schema/annotations.yml +++ b/bundle/internal/schema/annotations.yml @@ -1297,8 +1297,6 @@ resources: "entity_version": "description": |- PLACEHOLDER - "served_models": - "$fields": "model_name": "description": |- PLACEHOLDER diff --git a/bundle/internal/schema/legacy_names.go b/bundle/internal/schema/legacy_names.go new file mode 100644 index 00000000000..e39da41b621 --- /dev/null +++ b/bundle/internal/schema/legacy_names.go @@ -0,0 +1,387 @@ +package main + +import ( + "encoding/json" + "fmt" + "log" + "maps" + "path" + "reflect" + "slices" + "strings" + + "github.com/databricks/cli/bundle/internal/annotation" + "github.com/databricks/cli/bundle/internal/sdkmeta" + "github.com/databricks/cli/internal/clijson" + "github.com/databricks/cli/libs/jsonschema" +) + +// renameDefinitions renames the $defs of API types to the names the previous +// SDK types had (see sdkmeta) and rewrites every $ref accordingly, so that the +// published schema and the Python classes generated from it keep their names. +// +// Several sdk-go types can map to one previous name: sdk-go duplicates shared +// messages per API (jobs.AwsAttributes, clusters.AwsAttributes, ...) where the +// previous SDK had a single compute.AwsAttributes. Such definitions are merged; +// properties present in only some of them are kept. +func renameDefinitions(s *jsonschema.Schema, meta *sdkmeta.Meta, schemas map[string]*clijson.SchemaJSON, docsMode bool) { + names := map[string]string{} + order := map[string]int{} + for t := range meta.Types() { + if name, ok := meta.DefinitionName(t); ok { + names[jsonschemaTypePath(t)] = name + } + if i, ok := meta.Order(t); ok { + order[jsonschemaTypePath(t)] = i + } + } + + rename := func(p string) string { + var prefix []string + for { + head, rest, ok := strings.Cut(p, "/") + if !ok || (head != "slice" && head != "map") { + break + } + prefix = append(prefix, head) + p = rest + } + if n, ok := names[p]; ok { + p = n + } + return path.Join(append(prefix, p)...) + } + + flat := map[string]jsonschema.Schema{} + flattenDefinitions("", s.Definitions, flat) + + // Merge in walk order so that the type annotations.yml documents (the first + // occurrence in the configuration) wins. + keys := slices.Sorted(maps.Keys(flat)) + pos := func(k string) int { + if i, ok := order[k]; ok { + return i + } + return len(order) + } + slices.SortStableFunc(keys, func(a, b string) int { return pos(a) - pos(b) }) + renamed := map[string]jsonschema.Schema{} + for _, k := range keys { + def := flat[k] + rewriteRefs(&def, rename) + nk := rename(k) + if prev, ok := renamed[nk]; ok { + def = mergeDefinitions(nk, prev, def) + } + renamed[nk] = def + } + rewriteRefs(s, rename) + applyFieldRefs(renamed, schemas, docsMode) + pruneToSpec(renamed, schemas) + dropUnreachableAPIDefinitions(s, renamed) + s.Definitions = nestDefinitions(renamed) +} + +// pruneToSpec removes properties of API definitions that their cli.json +// schema does not define. A type sdk-go unified from several previous types +// carries the union of their fields until here (see removeFieldsMissingFromSpec). +func pruneToSpec(defs map[string]jsonschema.Schema, schemas map[string]*clijson.SchemaJSON) { + for k, def := range defs { + name, ok := strings.CutPrefix(k, sdkmeta.LegacyPkgPrefix) + if !ok { + continue + } + spec := schemas[name] + obj := objectSchema(&def) + if spec == nil || spec.Fields == nil || obj == nil { + continue + } + for prop := range obj.Properties { + if spec.Fields[prop] == nil { + delete(obj.Properties, prop) + obj.Required = slices.DeleteFunc(obj.Required, func(r string) bool { return r == prop }) + } + } + defs[k] = def + } +} + +// applyFieldRefs points fields whose type sdk-go changed back at the +// definitions they referred to before (see sdkmeta.FieldRef): enums that +// became plain strings get their enum definition from cli.json, and fields of +// unified messages get a copy of the unified definition under the old name. +func applyFieldRefs(defs map[string]jsonschema.Schema, schemas map[string]*clijson.SchemaJSON, docsMode bool) { + for _, k := range slices.Sorted(maps.Keys(defs)) { + name, ok := strings.CutPrefix(k, sdkmeta.LegacyPkgPrefix) + if !ok { + continue + } + def := defs[k] + obj := objectSchema(&def) + if obj == nil { + continue + } + for prop, ps := range obj.Properties { + ref, ok := sdkmeta.FieldRef(name, prop) + if !ok || ps.Reference == nil { + continue + } + target := strings.TrimPrefix(*ps.Reference, "#/$defs/") + newTarget := ensureDefinition(defs, target, sdkmeta.LegacyPkgPrefix+ref, schemas[ref], docsMode) + *ps.Reference = "#/$defs/" + newTarget + } + defs[k] = def + } +} + +// ensureDefinition makes a definition named newBase from the definition target +// refers to (through slice/ and map/ wrappers, which are recreated), and +// returns the new key replacing target. +func ensureDefinition(defs map[string]jsonschema.Schema, target, newBase string, spec *clijson.SchemaJSON, docsMode bool) string { + head, rest, ok := strings.Cut(target, "/") + if ok && (head == "slice" || head == "map") { + inner := ensureDefinition(defs, rest, newBase, spec, docsMode) + key := head + "/" + inner + if _, ok := defs[key]; !ok { + wrapper := cloneSchema(defs[target]) + ref := "#/$defs/" + inner + if len(wrapper.OneOf) == 0 { + switch head { + case "slice": + wrapper.Items = &jsonschema.Schema{Reference: &ref} + case "map": + wrapper.AdditionalProperties = &jsonschema.Schema{Reference: &ref} + } + } else { + switch head { + case "slice": + wrapper.OneOf[0].Items = &jsonschema.Schema{Reference: &ref} + case "map": + wrapper.OneOf[0].AdditionalProperties = &jsonschema.Schema{Reference: &ref} + } + } + defs[key] = wrapper + } + return key + } + if _, ok := defs[newBase]; ok { + return newBase + } + if target == "string" && spec != nil && len(spec.Enum) > 0 { + defs[newBase] = enumDefinition(spec, docsMode) + return newBase + } + def := cloneSchema(defs[target]) + if o := objectSchema(&def); o != nil && spec != nil { + o.Description = spec.Description + name := strings.TrimPrefix(newBase, sdkmeta.LegacyPkgPrefix) + o.Required = nil + for _, r := range sdkmeta.RequiredFields(name) { + if _, ok := o.Properties[r]; ok { + o.Required = append(o.Required, r) + } + } + for prop, ps := range o.Properties { + if f := spec.Fields[prop]; f != nil && f.Description != "" { + stage, _ := clijson.ParseLaunchStage(f.LaunchStage) + ps.Description = prefixWithPreviewTag(f.Description, annotation.PreviewTag(stage)) + } + } + } + defs[newBase] = def + return newBase +} + +// enumDefinition builds the definition of an enum from its cli.json schema, +// the way the generator does for enum types. +func enumDefinition(spec *clijson.SchemaJSON, docsMode bool) jsonschema.Schema { + s := jsonschema.Schema{Type: jsonschema.StringType} + stages, err := notableEnumLaunchStages(spec.EnumLaunchStages) + if err != nil { + log.Fatal(err) + } + assignAnnotation(&s, annotation.Descriptor{ + Description: spec.Description, + Enum: enumValues(spec.Enum), + EnumLaunchStages: stages, + EnumDescriptions: nonEmptyEnumDescriptions(spec.EnumDescriptions), + }) + if docsMode { + return s + } + return addInterpolationPatterns(reflect.TypeFor[string](), s) +} + +func cloneSchema(s jsonschema.Schema) jsonschema.Schema { + b, err := json.Marshal(s) + if err != nil { + panic(err) + } + var out jsonschema.Schema + if err := json.Unmarshal(b, &out); err != nil { + panic(err) + } + return out +} + +// jsonschemaTypePath is the $defs key jsonschema.FromType uses for t. +func jsonschemaTypePath(t reflect.Type) string { + name, _, _ := strings.Cut(t.Name(), "[") + return t.PkgPath() + "." + name +} + +func flattenDefinitions(prefix string, m map[string]any, out map[string]jsonschema.Schema) { + for k, v := range m { + var p string + if prefix != "" { + p = prefix + "/" + k + } else { + p = k + } + switch x := v.(type) { + case jsonschema.Schema: + out[p] = x + case map[string]any: + flattenDefinitions(p, x, out) + default: + log.Fatalf("unexpected definition %s of type %T", p, v) + } + } +} + +func nestDefinitions(flat map[string]jsonschema.Schema) map[string]any { + res := map[string]any{} + for k, v := range flat { + parts := strings.Split(k, "/") + cur := res + for _, p := range parts[:len(parts)-1] { + next, ok := cur[p].(map[string]any) + if !ok { + next = map[string]any{} + cur[p] = next + } + cur = next + } + cur[parts[len(parts)-1]] = v + } + return res +} + +func rewriteRefs(s *jsonschema.Schema, rename func(string) string) { + if s == nil { + return + } + if s.Reference != nil { + ref := "#/$defs/" + rename(strings.TrimPrefix(*s.Reference, "#/$defs/")) + s.Reference = &ref + } + for _, p := range s.Properties { + rewriteRefs(p, rename) + } + rewriteRefs(s.Items, rename) + switch ap := s.AdditionalProperties.(type) { + case *jsonschema.Schema: + rewriteRefs(ap, rename) + case jsonschema.Schema: + rewriteRefs(&ap, rename) + s.AdditionalProperties = ap + } + for i := range s.AnyOf { + rewriteRefs(&s.AnyOf[i], rename) + } + for i := range s.OneOf { + rewriteRefs(&s.OneOf[i], rename) + } +} + +// mergeDefinitions combines two definitions that map to the same name. +func mergeDefinitions(name string, a, b jsonschema.Schema) jsonschema.Schema { + if equalSchemas(a, b) { + return a + } + ao, bo := objectSchema(&a), objectSchema(&b) + if ao == nil || bo == nil { + // Enums and other non-object definitions: keep the first one. + return a + } + for k, v := range bo.Properties { + if _, ok := ao.Properties[k]; !ok { + ao.Properties[k] = v + } + } + var required []string + for _, r := range ao.Required { + if slices.Contains(bo.Required, r) { + required = append(required, r) + } + } + ao.Required = required + return a +} + +// objectSchema returns the object schema of a definition, which may be wrapped +// in a oneOf that allows variable interpolation. +func objectSchema(s *jsonschema.Schema) *jsonschema.Schema { + if s.Type == jsonschema.ObjectType && s.Properties != nil { + return s + } + for i := range s.OneOf { + if s.OneOf[i].Type == jsonschema.ObjectType && s.OneOf[i].Properties != nil { + return &s.OneOf[i] + } + } + return nil +} + +func equalSchemas(a, b jsonschema.Schema) bool { + ab, err := json.Marshal(a) + if err != nil { + panic(fmt.Sprintf("marshal: %v", err)) + } + bb, err := json.Marshal(b) + if err != nil { + panic(fmt.Sprintf("marshal: %v", err)) + } + return string(ab) == string(bb) +} + +// dropUnreachableAPIDefinitions removes definitions of sdk-go types that are +// not referenced from the schema, i.e. types only used by fields pruned +// because cli.json does not define them. Other unreferenced definitions are +// kept, as the generator always emitted them. +func dropUnreachableAPIDefinitions(root *jsonschema.Schema, defs map[string]jsonschema.Schema) { + reached := map[string]bool{} + var visit func(s *jsonschema.Schema) + visit = func(s *jsonschema.Schema) { + if s == nil { + return + } + if s.Reference != nil { + k := strings.TrimPrefix(*s.Reference, "#/$defs/") + if !reached[k] { + reached[k] = true + def := defs[k] + visit(&def) + } + } + for _, p := range s.Properties { + visit(p) + } + visit(s.Items) + if ap, ok := s.AdditionalProperties.(*jsonschema.Schema); ok { + visit(ap) + } + for i := range s.AnyOf { + visit(&s.AnyOf[i]) + } + for i := range s.OneOf { + visit(&s.OneOf[i]) + } + } + visit(root) + for k := range defs { + if !reached[k] && (strings.Contains(k, "github.com/databricks/cli/libs/sdktypes/") || strings.Contains(k, "github.com/databricks/sdk-go/")) { + delete(defs, k) + } + } +} diff --git a/bundle/internal/schema/main.go b/bundle/internal/schema/main.go index 01a743933b2..a7370d815ee 100644 --- a/bundle/internal/schema/main.go +++ b/bundle/internal/schema/main.go @@ -12,11 +12,12 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/config/variable" + "github.com/databricks/cli/bundle/internal/sdkmeta" "github.com/databricks/cli/internal/clijson" "github.com/databricks/cli/libs/dyn/dynvar" "github.com/databricks/cli/libs/jsonschema" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" ) // interpolationPattern builds a JSON Schema regex for ${prefix.path...} references. @@ -175,6 +176,66 @@ func makeVolumeTypeOptional(typ reflect.Type, s jsonschema.Schema) jsonschema.Sc return s } +// removeFieldsMissingFromSpec drops fields of API types that the cli.json +// schema of the type does not define. sdk-go can be ahead of cli.json (new +// fields) and its messages often combine input and output fields where the +// spec has separate input types; the spec decides what is configurable. +func removeFieldsMissingFromSpec(meta *sdkmeta.Meta) func(reflect.Type, jsonschema.Schema) jsonschema.Schema { + return func(typ reflect.Type, s jsonschema.Schema) jsonschema.Schema { + if typ.Kind() != reflect.Struct || s.Properties == nil { + return s + } + owners := meta.FieldOwners(typ) + for name := range s.Properties { + owner, ok := owners[name] + if !ok { + continue + } + spec, ok := meta.Schema(owner) + if !ok || spec.Fields == nil { + continue + } + inSpec := spec.Fields[name] != nil + for _, alt := range meta.AltSchemas(owner) { + inSpec = inSpec || alt.Fields[name] != nil + } + if !inSpec { + delete(s.Properties, name) + s.Required = slices.DeleteFunc(s.Required, func(r string) bool { return r == name }) + } + } + return s + } +} + +// addRequiredFields marks the required fields of API types as required. +// sdk-go and its JSON mirrors declare every field optional, so the required +// fields come from sdkmeta instead of the json tags. +func addRequiredFields(meta *sdkmeta.Meta) func(reflect.Type, jsonschema.Schema) jsonschema.Schema { + return func(typ reflect.Type, s jsonschema.Schema) jsonschema.Schema { + if typ.Kind() != reflect.Struct || s.Properties == nil { + return s + } + required := meta.Required(typ) + if len(required) == 0 { + return s + } + // Fields declared by the CLI come first, in declaration order; API + // fields follow sorted, matching the alphabetical field order of the + // previous SDK types. + res := slices.Clone(s.Required) + var api []string + for _, name := range required { + if _, ok := s.Properties[name]; ok && !slices.Contains(res, name) { + api = append(api, name) + } + } + slices.Sort(api) + s.Required = append(res, api...) + return s + } +} + func removeOutputOnlyFields(typ reflect.Type, s jsonschema.Schema) jsonschema.Schema { // Only process object types with properties if s.Type != jsonschema.ObjectType || s.Properties == nil { @@ -234,8 +295,8 @@ func main() { // schema generator's structural field prunes applied, so the annotations file // only documents fields the generated schema actually contains. Both the // generator and the detached-annotation test use it to stay in lockstep. -func configTypeGraph() (*typeGraph, error) { - return newTypeGraph(reflect.TypeFor[config.Root](), removeJobsFields, removePipelineFields) +func configTypeGraph(meta *sdkmeta.Meta) (*typeGraph, error) { + return newTypeGraph(reflect.TypeFor[config.Root](), removeFieldsMissingFromSpec(meta), removeJobsFields, removePipelineFields) } func generateSchema(workdir, outputFile, cliJSONFile string, docsMode bool) { @@ -252,12 +313,18 @@ func generateSchema(workdir, outputFile, cliJSONFile string, docsMode bool) { log.Fatalf("no schemas found in %s", cliJSONFile) } - extracted, err := newParser(doc.Schemas).extractAnnotations(reflect.TypeFor[config.Root]()) + meta, err := sdkmeta.Build(reflect.TypeFor[config.Root](), doc.Schemas) + if err != nil { + log.Fatal(err) + } + setLegacyTypePaths(meta) + + extracted, err := newParser(doc.Schemas, meta.Name, meta.AltSchemas).extractAnnotations(reflect.TypeFor[config.Root]()) if err != nil { log.Fatal(err) } - graph, err := configTypeGraph() + graph, err := configTypeGraph(meta) if err != nil { log.Fatal(err) } @@ -282,6 +349,8 @@ func generateSchema(workdir, outputFile, cliJSONFile string, docsMode bool) { } transforms := []func(reflect.Type, jsonschema.Schema) jsonschema.Schema{ + removeFieldsMissingFromSpec(meta), + addRequiredFields(meta), removeJobsFields, removePipelineFields, removeDeploymentFields, @@ -307,6 +376,7 @@ func generateSchema(workdir, outputFile, cliJSONFile string, docsMode bool) { if err != nil { log.Fatal(err) } + renameDefinitions(&s, meta, doc.Schemas, docsMode) // Overwrite the input annotation file, adding missing annotations err = a.syncWithMissingAnnotations(annotationsPath, graph) diff --git a/bundle/internal/schema/main_test.go b/bundle/internal/schema/main_test.go index 92184a2d48f..81db8cfa1bb 100644 --- a/bundle/internal/schema/main_test.go +++ b/bundle/internal/schema/main_test.go @@ -106,7 +106,7 @@ func TestRequiredAnnotationsForNewFields(t *testing.T) { // Checks that the annotations file only contains entries that match the // current bundle configuration structure. func TestNoDetachedAnnotations(t *testing.T) { - g, err := configTypeGraph() + g, err := configTypeGraph(testMeta(t)) require.NoError(t, err) _, unknown, err := loadAnnotationsFile("annotations.yml", g) diff --git a/bundle/internal/schema/parser.go b/bundle/internal/schema/parser.go index c9698749267..5745f8f9c9e 100644 --- a/bundle/internal/schema/parser.go +++ b/bundle/internal/schema/parser.go @@ -3,10 +3,8 @@ package main import ( "errors" "fmt" - "path" "reflect" "slices" - "strings" "github.com/databricks/cli/bundle/internal/annotation" "github.com/databricks/cli/internal/clijson" @@ -15,6 +13,11 @@ import ( type annotationParser struct { ref map[string]*clijson.SchemaJSON + // schemaName returns the cli.json schema name of an API type. + schemaName func(reflect.Type) (string, bool) + // altSchemas returns further schemas an API type stands for; they document + // fields its own schema lacks. + altSchemas func(reflect.Type) []*clijson.SchemaJSON } // deprecationMessage is the message emitted for any field or type that the spec @@ -31,16 +34,16 @@ func deprecationMessageFor(deprecated bool) string { return "" } -func newParser(schemas map[string]*clijson.SchemaJSON) *annotationParser { - return &annotationParser{ref: schemas} +func newParser(schemas map[string]*clijson.SchemaJSON, schemaName func(reflect.Type) (string, bool), altSchemas func(reflect.Type) []*clijson.SchemaJSON) *annotationParser { + return &annotationParser{ref: schemas, schemaName: schemaName, altSchemas: altSchemas} } // This function checks if the input type: -// 1. Is a Databricks Go SDK type. -// 2. Has a Databricks Go SDK type embedded in it, at any depth. +// 1. Is an API type (see sdkmeta). +// 2. Has an API type embedded in it, at any depth. // // If the above conditions are met, the function returns the schema -// corresponding to the Databricks Go SDK type from the spec. +// corresponding to the API type from the spec. // // Embedded structs are traversed breadth first, mirroring how // [jsonschema.FromType] flattens them, so the shallowest SDK type present in @@ -80,14 +83,13 @@ func (p *annotationParser) findRef(typ reflect.Type) (*clijson.SchemaJSON, bool) return nil, false } -// lookupSDKType returns the spec schema for a Databricks Go SDK type, if the -// spec defines one for it. +// lookupSDKType returns the spec schema for an API type, if the spec defines +// one for it. func (p *annotationParser) lookupSDKType(typ reflect.Type) (*clijson.SchemaJSON, bool) { - if !strings.HasPrefix(typ.PkgPath(), "github.com/databricks/databricks-sdk-go") { + k, ok := p.schemaName(typ) + if !ok { return nil, false } - - k := fmt.Sprintf("%s.%s", path.Base(typ.PkgPath()), typ.Name()) ref, ok := p.ref[k] return ref, ok } @@ -206,7 +208,13 @@ func (p *annotationParser) extractAnnotations(typ reflect.Type) (annotation.File } for k := range s.Properties { - if refProp, ok := ref.Fields[k]; ok { + refProp, ok := ref.Fields[k] + for _, alt := range p.altSchemas(typ) { + if !ok { + refProp, ok = alt.Fields[k] + } + } + if ok { // An empty stage means the contract assigns none; keep it // unmarked rather than letting ParseLaunchStage default it to GA. var launchStage clijson.LaunchStage diff --git a/bundle/internal/schema/parser_test.go b/bundle/internal/schema/parser_test.go index c89e7b8f832..6e8fdf8ef36 100644 --- a/bundle/internal/schema/parser_test.go +++ b/bundle/internal/schema/parser_test.go @@ -8,8 +8,9 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/internal/annotation" + "github.com/databricks/cli/bundle/internal/sdkmeta" "github.com/databricks/cli/internal/clijson" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -26,9 +27,25 @@ type testProject struct { testProjectConfig } +// newTestParser returns a parser over schemas that maps API types the way the +// generator does. +func newTestParser(t *testing.T, schemas map[string]*clijson.SchemaJSON) *annotationParser { + meta := testMeta(t) + return newParser(schemas, meta.Name, meta.AltSchemas) +} + +func testMeta(t *testing.T) *sdkmeta.Meta { + doc, err := clijson.Parse("../../../.codegen/cli.json") + require.NoError(t, err) + meta, err := sdkmeta.Build(reflect.TypeFor[config.Root](), doc.Schemas) + require.NoError(t, err) + setLegacyTypePaths(meta) + return meta +} + func TestFindRefNestedEmbeddedSDKType(t *testing.T) { spec := &clijson.SchemaJSON{Description: "A Lakebase project."} - p := newParser(map[string]*clijson.SchemaJSON{"postgres.ProjectSpec": spec}) + p := newTestParser(t, map[string]*clijson.SchemaJSON{"postgres.ProjectSpec": spec}) t.Run("resolves a spec embedded below the first level", func(t *testing.T) { got, ok := p.findRef(reflect.TypeFor[testProject]()) @@ -43,7 +60,7 @@ func TestFindRefNestedEmbeddedSDKType(t *testing.T) { }) t.Run("reports no match when the spec omits the type", func(t *testing.T) { - _, ok := newParser(nil).findRef(reflect.TypeFor[testProject]()) + _, ok := newTestParser(t, nil).findRef(reflect.TypeFor[testProject]()) assert.False(t, ok) }) } @@ -52,7 +69,7 @@ func TestFindRefNestedEmbeddedSDKType(t *testing.T) { // land on the wrapping resource type, since that is where the schema generator // flattens the spec's fields to. func TestExtractAnnotationsNestedEmbeddedSDKType(t *testing.T) { - p := newParser(map[string]*clijson.SchemaJSON{ + p := newTestParser(t, map[string]*clijson.SchemaJSON{ "postgres.ProjectSpec": { Fields: map[string]*clijson.SchemaFieldJSON{ "display_name": { @@ -129,7 +146,7 @@ func TestPostgresResourcesHaveLaunchStageOverride(t *testing.T) { // auth_method is a field of postgres.RoleRoleSpec, embedded by // resources.PostgresRole. func TestExtractAnnotationsOverridesLaunchStage(t *testing.T) { - p := newParser(map[string]*clijson.SchemaJSON{ + p := newTestParser(t, map[string]*clijson.SchemaJSON{ "postgres.RoleRoleSpec": { Fields: map[string]*clijson.SchemaFieldJSON{ "auth_method": { @@ -152,7 +169,7 @@ func TestExtractAnnotationsOverridesLaunchStage(t *testing.T) { // type-level x-databricks-launch-stage is emitted, not just its fields'. The // contract carries no type-level stage, so the override map is the only source. func TestExtractAnnotationsStampsTypeLaunchStage(t *testing.T) { - p := newParser(map[string]*clijson.SchemaJSON{ + p := newTestParser(t, map[string]*clijson.SchemaJSON{ "postgres.RoleRoleSpec": {Fields: map[string]*clijson.SchemaFieldJSON{}}, }) diff --git a/bundle/internal/schema/typegraph.go b/bundle/internal/schema/typegraph.go index f1be78d7377..84ca9f1a770 100644 --- a/bundle/internal/schema/typegraph.go +++ b/bundle/internal/schema/typegraph.go @@ -66,7 +66,16 @@ func newTypeGraph(root reflect.Type, transforms ...func(reflect.Type, jsonschema } } - g.fields[refPath] = edges + // Several API types can share one path (see getPath); keep the union of + // their fields, in first-seen order. + for _, e := range edges { + if _, ok := g.edge(refPath, e.name); !ok { + g.fields[refPath] = append(g.fields[refPath], e) + } + } + if _, ok := g.fields[refPath]; !ok { + g.fields[refPath] = nil + } return s } @@ -97,7 +106,7 @@ func structFieldOrder(typ reflect.Type, props map[string]*jsonschema.Schema) []s seen := map[string]bool{} bfsQueue := list.New() - for field := range typ.Fields() { + for _, field := range declaredFields(typ) { bfsQueue.PushBack(field) } for bfsQueue.Len() > 0 { @@ -110,7 +119,7 @@ func structFieldOrder(typ reflect.Type, props map[string]*jsonschema.Schema) []s if fieldType.Kind() == reflect.Pointer { fieldType = fieldType.Elem() } - for f := range fieldType.Fields() { + for _, f := range declaredFields(fieldType) { bfsQueue.PushBack(f) } continue @@ -144,9 +153,21 @@ func resolveEdgeType(prop *jsonschema.Schema) string { case strings.HasPrefix(ref, "map/"): ref = strings.TrimPrefix(ref, "map/") case strings.HasPrefix(ref, "github.com"): - return ref + return legacyTypePath(ref) default: return "" } } } + +// declaredFields returns the fields of typ in declaration order. Fields of API +// types are sorted by name instead: the previous SDK declared them +// alphabetically, and the order decides where annotations.yml documents a +// type that occurs several times. +func declaredFields(typ reflect.Type) []reflect.StructField { + fields := slices.Collect(typ.Fields()) + if _, ok := legacyTypePaths[typ.PkgPath()+"."+typ.Name()]; ok { + slices.SortStableFunc(fields, func(a, b reflect.StructField) int { return strings.Compare(a.Name, b.Name) }) + } + return fields +} diff --git a/bundle/internal/sdkmeta/bootstrap_test.go b/bundle/internal/sdkmeta/bootstrap_test.go new file mode 100644 index 00000000000..db0c5cf23d4 --- /dev/null +++ b/bundle/internal/sdkmeta/bootstrap_test.go @@ -0,0 +1,161 @@ +package sdkmeta + +import ( + "encoding/json" + "os" + "reflect" + "slices" + "strings" + "testing" + + "github.com/stretchr/testify/require" +) + +// TestBootstrap derives legacy.json from a JSON schema generated by the +// previous SDK types (git show :bundle/schema/jsonschema.json). +func TestBootstrap(t *testing.T) { + src := os.Getenv("SDKMETA_BOOTSTRAP") + if src == "" { + t.Skip() + } + data, err := os.ReadFile(src) + require.NoError(t, err) + var schema map[string]any + require.NoError(t, json.Unmarshal(data, &schema)) + defs := map[string]map[string]any{} + var flatten func(prefix string, m map[string]any) + flatten = func(prefix string, m map[string]any) { + for k, v := range m { + vm, ok := v.(map[string]any) + if !ok { + continue + } + var p string + if prefix != "" { + p = prefix + "/" + k + } else { + p = k + } + _, isSchema := vm["type"] + _, hasOneOf := vm["oneOf"] + _, hasAnyOf := vm["anyOf"] + if isSchema || hasOneOf || hasAnyOf { + defs[p] = vm + } + flatten(p, vm) + } + } + flatten("", schema["$defs"].(map[string]any)) + + object := func(s map[string]any) map[string]any { + if o, ok := s["oneOf"].([]any); ok { + return o[0].(map[string]any) + } + return s + } + // resolve follows a $ref through slice/ and map/ wrappers to a type def name. + resolve := func(ref string) string { + name := strings.TrimPrefix(ref, "#/$defs/") + for strings.HasPrefix(name, "slice/") || strings.HasPrefix(name, "map/") { + name = name[strings.Index(name, "/")+1:] + } + return name + } + + names := map[string]string{} + required := map[string][]string{} + fieldRefs := map[string]string{} + seen := map[reflect.Type]bool{} + var walk func(t reflect.Type, def map[string]any) + walk = func(t reflect.Type, def map[string]any) { + t = elem(t) + if seen[t] || t.Kind() != reflect.Struct { + return + } + seen[t] = true + obj := object(def) + props, _ := obj["properties"].(map[string]any) + for _, f := range fields(t) { + if f.field.Anonymous { + continue + } + ft := elem(f.field.Type) + p, ok := props[f.name].(map[string]any) + if !ok { + continue + } + ref, _ := p["$ref"].(string) + if ref == "" { + continue + } + old := resolve(ref) + if after, ok0 := strings.CutPrefix(old, LegacyPkgPrefix); ok0 { + oldName := after + key := typeName(ft) + if _, ok := names[key]; !ok && isAPIType(ft) { + if _, isRoot := roots()[ft]; !isRoot { + names[key] = oldName + } + } + mapped := names[key] + if n, ok := roots()[ft]; ok { + mapped = n + } + if mapped != oldName && f.owner != nil { + ownerName := names[typeName(f.owner)] + if n, ok := roots()[f.owner]; ok { + ownerName = n + } + if ownerName != "" { + fieldRefs[ownerName+"."+f.name] = oldName + } + } + } + if d, ok := defs[old]; ok { + walk(ft, d) + } + } + // Required fields of the API types flattened into t. + reqs, _ := obj["required"].([]any) + for _, f := range fields(t) { + if f.field.Anonymous || f.owner == nil { + continue + } + owner := "" + if n, ok := roots()[f.owner]; ok { + owner = n + } else { + owner = names[typeName(f.owner)] + } + for _, r := range reqs { + if r == f.name && owner != "" { + required[owner] = append(required[owner], f.name) + } + } + } + } + walk(reflect.TypeFor[testRoot](), defs["github.com/databricks/cli/bundle/config.Resources"]) + + // Required fields of every previous type with a definition, including those + // only reachable through fields the schema prunes. + for k, def := range defs { + name, ok := strings.CutPrefix(k, LegacyPkgPrefix) + if !ok { + continue + } + reqs, _ := object(def)["required"].([]any) + for _, r := range reqs { + required[name] = append(required[name], r.(string)) + } + } + // The JSON schema makes volume_type optional (DABs defaults it), but the + // API requires it, and bundle validation used to check it. + required["catalog.CreateVolumeRequestContent"] = append(required["catalog.CreateVolumeRequestContent"], "volume_type") + for k := range required { + slices.Sort(required[k]) + required[k] = slices.Compact(required[k]) + } + out, err := json.MarshalIndent(legacyFile{Names: names, Required: required, FieldRefs: fieldRefs}, "", " ") + require.NoError(t, err) + require.NoError(t, os.WriteFile("legacy.json", append(out, '\n'), 0o644)) +} diff --git a/bundle/internal/sdkmeta/legacy.json b/bundle/internal/sdkmeta/legacy.json new file mode 100644 index 00000000000..df1bc7edb58 --- /dev/null +++ b/bundle/internal/sdkmeta/legacy.json @@ -0,0 +1,954 @@ +{ + "names": { + "github.com/databricks/cli/libs/qualitymonitors.MonitorCronSchedule": "catalog.MonitorCronSchedule", + "github.com/databricks/cli/libs/qualitymonitors.MonitorCronSchedulePauseStatus": "catalog.MonitorCronSchedulePauseStatus", + "github.com/databricks/cli/libs/qualitymonitors.MonitorDataClassificationConfig": "catalog.MonitorDataClassificationConfig", + "github.com/databricks/cli/libs/qualitymonitors.MonitorDestination": "catalog.MonitorDestination", + "github.com/databricks/cli/libs/qualitymonitors.MonitorInferenceLog": "catalog.MonitorInferenceLog", + "github.com/databricks/cli/libs/qualitymonitors.MonitorInferenceLogProblemType": "catalog.MonitorInferenceLogProblemType", + "github.com/databricks/cli/libs/qualitymonitors.MonitorMetric": "catalog.MonitorMetric", + "github.com/databricks/cli/libs/qualitymonitors.MonitorMetricType": "catalog.MonitorMetricType", + "github.com/databricks/cli/libs/qualitymonitors.MonitorNotifications": "catalog.MonitorNotifications", + "github.com/databricks/cli/libs/qualitymonitors.MonitorSnapshot": "catalog.MonitorSnapshot", + "github.com/databricks/cli/libs/qualitymonitors.MonitorTimeSeries": "catalog.MonitorTimeSeries", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.InferenceTableConfig": "catalog.InferenceTableConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.McpServiceConfig_SourceConnection": "catalog.McpServiceConfigSourceConnection", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_AmazonBedrockProviderConfig": "catalog.ModelProviderServiceConfigAmazonBedrockProviderConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig": "catalog.ModelProviderServiceConfigAmazonBedrockProviderDirectConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_AnthropicProviderConfig": "catalog.ModelProviderServiceConfigAnthropicProviderConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_AnthropicProviderDirectConfig": "catalog.ModelProviderServiceConfigAnthropicProviderDirectConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_AnthropicProviderRelayedConfig": "catalog.ModelProviderServiceConfigAnthropicProviderRelayedConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_AwsAccessKey": "catalog.ModelProviderServiceConfigAwsAccessKey", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_AzureOpenAiProviderConfig": "catalog.ModelProviderServiceConfigAzureOpenAiProviderConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig": "catalog.ModelProviderServiceConfigAzureOpenAiProviderDirectConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuth": "catalog.ModelProviderServiceConfigCustomProviderApiKeyHeaderAuth", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_CustomProviderConfig": "catalog.ModelProviderServiceConfigCustomProviderConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_CustomProviderDirectConfig": "catalog.ModelProviderServiceConfigCustomProviderDirectConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_EntraServicePrincipal": "catalog.ModelProviderServiceConfigEntraServicePrincipal", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_GeminiEnterpriseProviderConfig": "catalog.ModelProviderServiceConfigGeminiEnterpriseProviderConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig": "catalog.ModelProviderServiceConfigGeminiEnterpriseProviderDirectConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_MicrosoftFoundryProviderConfig": "catalog.ModelProviderServiceConfigMicrosoftFoundryProviderConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig": "catalog.ModelProviderServiceConfigMicrosoftFoundryProviderDirectConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_ModelTargetConfig": "catalog.ModelProviderServiceConfigModelTargetConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_OpenAiProviderConfig": "catalog.ModelProviderServiceConfigOpenAiProviderConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_OpenAiProviderDirectConfig": "catalog.ModelProviderServiceConfigOpenAiProviderDirectConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_ProviderPricingConfig": "catalog.ModelProviderServiceConfigProviderPricingConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_ProviderSecret": "catalog.ModelProviderServiceConfigProviderSecret", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_SecretReference": "catalog.ModelProviderServiceConfigSecretReference", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelProviderServiceConfig_ServiceCredential": "catalog.ModelProviderServiceConfigServiceCredential", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelServiceConfig_DestinationConfig": "catalog.ModelServiceConfigDestinationConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelServiceConfig_ExternalModelConfig": "catalog.ModelServiceConfigExternalModelConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelServiceConfig_FallbackConfig": "catalog.ModelServiceConfigFallbackConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelServiceConfig_PayPerTokenConfig": "catalog.ModelServiceConfigPayPerTokenConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelServiceConfig_ProvisionedThroughputConfig": "catalog.ModelServiceConfigProvisionedThroughputConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.ModelServiceConfig_RoutingConfig": "catalog.ModelServiceConfigRoutingConfig", + "github.com/databricks/cli/libs/sdktypes/aigateway/v1.RateLimit": "catalog.RateLimit", + "github.com/databricks/cli/libs/sdktypes/alerts/v2.AlertEvaluation": "sql.AlertV2Evaluation", + "github.com/databricks/cli/libs/sdktypes/alerts/v2.AlertNotification": "sql.AlertV2Notification", + "github.com/databricks/cli/libs/sdktypes/alerts/v2.AlertOperand": "sql.AlertV2Operand", + "github.com/databricks/cli/libs/sdktypes/alerts/v2.AlertOperandColumn": "sql.AlertV2OperandColumn", + "github.com/databricks/cli/libs/sdktypes/alerts/v2.AlertOperandValue": "sql.AlertV2OperandValue", + "github.com/databricks/cli/libs/sdktypes/alerts/v2.AlertRunAs": "sql.AlertV2RunAs", + "github.com/databricks/cli/libs/sdktypes/alerts/v2.AlertStatementParameter": "sql.AlertStatementParameter", + "github.com/databricks/cli/libs/sdktypes/alerts/v2.AlertSubscription": "sql.AlertV2Subscription", + "github.com/databricks/cli/libs/sdktypes/alerts/v2.CronSchedule": "sql.CronSchedule", + "github.com/databricks/cli/libs/sdktypes/apps/v1.AppResource": "apps.AppResource", + "github.com/databricks/cli/libs/sdktypes/apps/v1.AppResourceApp": "apps.AppResourceApp", + "github.com/databricks/cli/libs/sdktypes/apps/v1.AppResourceDatabase": "apps.AppResourceDatabase", + "github.com/databricks/cli/libs/sdktypes/apps/v1.AppResourceExperiment": "apps.AppResourceExperiment", + "github.com/databricks/cli/libs/sdktypes/apps/v1.AppResourceGenieSpace": "apps.AppResourceGenieSpace", + "github.com/databricks/cli/libs/sdktypes/apps/v1.AppResourceJob": "apps.AppResourceJob", + "github.com/databricks/cli/libs/sdktypes/apps/v1.AppResourcePostgres": "apps.AppResourcePostgres", + "github.com/databricks/cli/libs/sdktypes/apps/v1.AppResourceSecret": "apps.AppResourceSecret", + "github.com/databricks/cli/libs/sdktypes/apps/v1.AppResourceServingEndpoint": "apps.AppResourceServingEndpoint", + "github.com/databricks/cli/libs/sdktypes/apps/v1.AppResourceSqlWarehouse": "apps.AppResourceSqlWarehouse", + "github.com/databricks/cli/libs/sdktypes/apps/v1.AppResourceUcSecurable": "apps.AppResourceUcSecurable", + "github.com/databricks/cli/libs/sdktypes/apps/v1.GitRepository": "apps.GitRepository", + "github.com/databricks/cli/libs/sdktypes/apps/v1.GitSource": "apps.GitSource", + "github.com/databricks/cli/libs/sdktypes/apps/v1.TelemetryExportDestination": "apps.TelemetryExportDestination", + "github.com/databricks/cli/libs/sdktypes/apps/v1.UnityCatalog": "apps.UnityCatalog", + "github.com/databricks/cli/libs/sdktypes/clusterlibraries/v2.MavenLibrary": "compute.MavenLibrary", + "github.com/databricks/cli/libs/sdktypes/clusterlibraries/v2.PythonPyPiLibrary": "compute.PythonPyPiLibrary", + "github.com/databricks/cli/libs/sdktypes/clusterlibraries/v2.RCranLibrary": "compute.RCranLibrary", + "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2.Library": "compute.Library", + "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2.MavenLibrary": "compute.MavenLibrary", + "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2.PythonPyPiLibrary": "compute.PythonPyPiLibrary", + "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2.RCranLibrary": "compute.RCranLibrary", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.Adlsgen2Info": "compute.Adlsgen2Info", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.AutoScale": "compute.AutoScale", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.AwsAttributes": "compute.AwsAttributes", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.AzureAttributes": "compute.AzureAttributes", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.ClusterLogConf": "compute.ClusterLogConf", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.DbfsStorageInfo": "compute.DbfsStorageInfo", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.DockerBasicAuth": "compute.DockerBasicAuth", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.DockerImage": "compute.DockerImage", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.GcpAttributes": "compute.GcpAttributes", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.GcsStorageInfo": "compute.GcsStorageInfo", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.InitScriptInfo": "compute.InitScriptInfo", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.LocalFileInfo": "compute.LocalFileInfo", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.LogAnalyticsInfo": "compute.LogAnalyticsInfo", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.NodeTypeFlexibility": "compute.NodeTypeFlexibility", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.S3StorageInfo": "compute.S3StorageInfo", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.VolumesStorageInfo": "compute.VolumesStorageInfo", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.WorkloadType": "compute.WorkloadType", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.WorkloadType_ClientsTypes": "compute.ClientsTypes", + "github.com/databricks/cli/libs/sdktypes/clusters/v2.WorkspaceStorageInfo": "compute.WorkspaceStorageInfo", + "github.com/databricks/cli/libs/sdktypes/database/v1.CustomTag": "database.CustomTag", + "github.com/databricks/cli/libs/sdktypes/database/v1.DatabaseInstanceRef": "database.DatabaseInstanceRef", + "github.com/databricks/cli/libs/sdktypes/database/v1.NewPipelineSpec": "database.NewPipelineSpec", + "github.com/databricks/cli/libs/sdktypes/database/v1.SyncedTableSpec": "database.SyncedTableSpec", + "github.com/databricks/cli/libs/sdktypes/database/v1.SyncedTableSpec_TypeOverride": "database.SyncedTableSpecTypeOverride", + "github.com/databricks/cli/libs/sdktypes/experiments/v1.ExperimentTag": "ml.ExperimentTag", + "github.com/databricks/cli/libs/sdktypes/experiments/v1.ExperimentTraceLocation": "ml.ExperimentTraceLocation", + "github.com/databricks/cli/libs/sdktypes/experiments/v1.UcTraceLocation": "ml.UcTraceLocation", + "github.com/databricks/cli/libs/sdktypes/instancepools/v2.DiskSpec": "compute.DiskSpec", + "github.com/databricks/cli/libs/sdktypes/instancepools/v2.DiskType": "compute.DiskType", + "github.com/databricks/cli/libs/sdktypes/instancepools/v2.DockerBasicAuth": "compute.DockerBasicAuth", + "github.com/databricks/cli/libs/sdktypes/instancepools/v2.DockerImage": "compute.DockerImage", + "github.com/databricks/cli/libs/sdktypes/instancepools/v2.InstancePoolAwsAttributes": "compute.InstancePoolAwsAttributes", + "github.com/databricks/cli/libs/sdktypes/instancepools/v2.InstancePoolAzureAttributes": "compute.InstancePoolAzureAttributes", + "github.com/databricks/cli/libs/sdktypes/instancepools/v2.InstancePoolGcpAttributes": "compute.InstancePoolGcpAttributes", + "github.com/databricks/cli/libs/sdktypes/instancepools/v2.NodeTypeFlexibility": "compute.NodeTypeFlexibility", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.Adlsgen2Info": "compute.Adlsgen2Info", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.AiRuntimeTask": "jobs.AiRuntimeTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.AlertTask": "jobs.AlertTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.AlertTaskSubscriber": "jobs.AlertTaskSubscriber", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.AutoScale": "compute.AutoScale", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.AwsAttributes": "compute.AwsAttributes", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.AzureAttributes": "compute.AzureAttributes", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.CleanRoomsNotebookTask": "jobs.CleanRoomsNotebookTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.ClusterLogConf": "compute.ClusterLogConf", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.ClusterSpec_NewCluster": "compute.ClusterSpec", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.Compute": "jobs.Compute", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.ComputeConfig": "jobs.ComputeConfig", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.ComputeSpec": "jobs.ComputeSpec", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.ConditionTask": "jobs.ConditionTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.ContinuousSettings": "jobs.Continuous", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.ContinuousTriggerConfiguration": "jobs.ContinuousTriggerConfiguration", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.CronSchedule": "jobs.CronSchedule", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.CronTriggerConfiguration": "jobs.CronTriggerConfiguration", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.DashboardTask": "jobs.DashboardTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.DbfsStorageInfo": "compute.DbfsStorageInfo", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.DbtCloudTask": "jobs.DbtCloudTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.DbtPlatformTask": "jobs.DbtPlatformTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.DbtTask": "jobs.DbtTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.DeploymentSpec": "jobs.DeploymentSpec", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.DockerBasicAuth": "compute.DockerBasicAuth", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.DockerImage": "compute.DockerImage", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.Environment": "compute.Environment", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.FileArrivalTriggerConfiguration": "jobs.FileArrivalTriggerConfiguration", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.ForEachTask": "jobs.ForEachTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.GcpAttributes": "compute.GcpAttributes", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.GcsStorageInfo": "compute.GcsStorageInfo", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.GenAiComputeTask": "jobs.GenAiComputeTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.GitSource": "jobs.GitSource", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.InitScriptInfo": "compute.InitScriptInfo", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.JobCluster": "jobs.JobCluster", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.JobEmailNotifications": "jobs.JobEmailNotifications", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.JobEnvironment": "jobs.JobEnvironment", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.JobEnvironmentVariables": "jobs.JobEnvironmentVariables", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.JobEnvironmentVariablesSpec": "jobs.JobEnvironmentVariablesSpec", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.JobLevelParameter": "jobs.JobParameterDefinition", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.JobRunAs": "jobs.JobRunAs", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.JobsHealthRule": "jobs.JobsHealthRule", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.JobsHealthRules": "jobs.JobsHealthRules", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.Library": "compute.Library", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.LocalFileInfo": "compute.LocalFileInfo", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.LogAnalyticsInfo": "compute.LogAnalyticsInfo", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.MaintenanceWindow": "jobs.MaintenanceWindow", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.MavenLibrary": "compute.MavenLibrary", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.ModelTriggerConfiguration": "jobs.ModelTriggerConfiguration", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.NodeTypeFlexibility": "compute.NodeTypeFlexibility", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.NotebookTask": "jobs.NotebookTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.NotificationSettings": "jobs.JobNotificationSettings", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.PeriodicTriggerConfiguration": "jobs.PeriodicTriggerConfiguration", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.PipelineParameters": "jobs.PipelineParams", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.PipelineTask": "jobs.PipelineTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.PowerBiModel": "jobs.PowerBiModel", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.PowerBiTable": "jobs.PowerBiTable", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.PowerBiTask": "jobs.PowerBiTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.PythonOperatorTask": "jobs.PythonOperatorTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.PythonOperatorTask_Parameter": "jobs.PythonOperatorTaskParameter", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.PythonPyPiLibrary": "compute.PythonPyPiLibrary", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.PythonWheelTask": "jobs.PythonWheelTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.QueueSettings": "jobs.QueueSettings", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.RCranLibrary": "compute.RCranLibrary", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.RunJobTask": "jobs.RunJobTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.S3StorageInfo": "compute.S3StorageInfo", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.SparkJarTask": "jobs.SparkJarTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.SparkPythonTask": "jobs.SparkPythonTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.SparkSubmitTask": "jobs.SparkSubmitTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.SparseCheckout": "jobs.SparseCheckout", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.SqlConditionConfiguration": "jobs.SqlConditionConfiguration", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.SqlTask": "jobs.SqlTask", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.SqlTaskAlert": "jobs.SqlTaskAlert", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.SqlTaskDashboard": "jobs.SqlTaskDashboard", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.SqlTaskFile": "jobs.SqlTaskFile", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.SqlTaskQuery": "jobs.SqlTaskQuery", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.SqlTaskSubscription": "jobs.SqlTaskSubscription", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.Subscription": "jobs.Subscription", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.Subscription_Subscriber": "jobs.SubscriptionSubscriber", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.TableTriggerConfiguration": "jobs.TableUpdateTriggerConfiguration", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.TaskDependency": "jobs.TaskDependency", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.TaskSettings": "jobs.Task", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.TriggerConfiguration": "jobs.TriggerConfiguration", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.TriggerSettings": "jobs.TriggerSettings", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.VolumesStorageInfo": "compute.VolumesStorageInfo", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.Webhook": "jobs.Webhook", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.WebhookNotifications": "jobs.WebhookNotifications", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.WorkloadType": "compute.WorkloadType", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.WorkloadType_ClientsTypes": "compute.ClientsTypes", + "github.com/databricks/cli/libs/sdktypes/jobs/v2.WorkspaceStorageInfo": "compute.WorkspaceStorageInfo", + "github.com/databricks/cli/libs/sdktypes/modelregistry/v1.RegisteredModelTag": "ml.ModelTag", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.Ai21LabsConfig": "serving.Ai21LabsConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.AiGatewayConfig": "serving.AiGatewayConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.AiGatewayRateLimit": "serving.AiGatewayRateLimit", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.AiGuardrailParameters": "serving.AiGatewayGuardrailParameters", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.AiGuardrails": "serving.AiGatewayGuardrails", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.AmazonBedrockConfig": "serving.AmazonBedrockConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.AnthropicConfig": "serving.AnthropicConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.ApiKeyAuth": "serving.ApiKeyAuth", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.AutoCaptureConfig": "serving.AutoCaptureConfigInput", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.BearerTokenAuth": "serving.BearerTokenAuth", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.CohereConfig": "serving.CohereConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.CustomProviderConfig": "serving.CustomProviderConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.DatabricksModelServingConfig": "serving.DatabricksModelServingConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.EmailNotifications": "serving.EmailNotifications", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.EndpointCoreConfig": "serving.EndpointCoreConfigInput", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.EndpointTag": "serving.EndpointTag", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.ExternalModel": "serving.ExternalModel", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.FallbackConfig": "serving.FallbackConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.GoogleCloudVertexAiConfig": "serving.GoogleCloudVertexAiConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.InferenceTableConfig": "serving.AiGatewayInferenceTableConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.OpenAiConfig": "serving.OpenAiConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.PaLmConfig": "serving.PaLmConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.PiiSettings": "serving.AiGatewayGuardrailPiiBehavior", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.RateLimit": "serving.RateLimit", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.Route": "serving.Route", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.ServedModel": "serving.ServedEntityInput", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.TelemetryConfig": "serving.TelemetryConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.TelemetryInferenceTableConfig": "serving.TelemetryInferenceTableConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.TrafficConfig": "serving.TrafficConfig", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.UnityCatalogTableNames": "serving.UnityCatalogTableNames", + "github.com/databricks/cli/libs/sdktypes/modelserving/v1.UsageTrackingConfig": "serving.AiGatewayUsageTrackingConfig", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.ApiSourceConnectorConfig": "pipelines.ApiSourceConnectorConfig", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.ApiSourceConnectorOptions": "pipelines.ApiSourceConnectorOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.AutoFullRefreshPolicy": "pipelines.AutoFullRefreshPolicy", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.AvroTransformerOptions": "pipelines.AvroTransformerOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.ConfluenceConnectorOptions": "pipelines.ConfluenceConnectorOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.ConfluentSchemaRegistryOptions": "pipelines.ConfluentSchemaRegistryOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.ConnectionParameters": "pipelines.ConnectionParameters", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.ConnectorOptions": "pipelines.ConnectorOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.CronTrigger": "pipelines.CronTrigger", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.DataStagingOptions": "pipelines.DataStagingOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.EventLogSpec": "pipelines.EventLogSpec", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.FileFilter": "pipelines.FileFilter", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.FileIngestionOptions": "pipelines.FileIngestionOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.Filters": "pipelines.Filters", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.GoogleAdsConfig": "pipelines.GoogleAdsConfig", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.GoogleAdsCustomReportOptions": "pipelines.GoogleAdsCustomReportOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.GoogleAdsOptions": "pipelines.GoogleAdsOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.GoogleDriveOptions": "pipelines.GoogleDriveOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.IngestionGatewayPipelineDefinition": "pipelines.IngestionGatewayPipelineDefinition", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.IngestionPipelineDefinition": "pipelines.IngestionPipelineDefinition", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.IngestionPipelineDefinition_FanoutOptions": "pipelines.IngestionPipelineDefinitionFanoutOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.IngestionPipelineDefinition_IngestionConfig": "pipelines.IngestionConfig", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.IngestionPipelineDefinition_ReportSpec": "pipelines.ReportSpec", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.IngestionPipelineDefinition_SchemaSpec": "pipelines.SchemaSpec", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.IngestionPipelineDefinition_TableSpec": "pipelines.TableSpec", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.IngestionPipelineDefinition_TableSpecificConfig": "pipelines.TableSpecificConfig", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig": "pipelines.IngestionPipelineDefinitionTableSpecificConfigQueryBasedConnectorConfig", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.IngestionPipelineDefinition_WorkdayReportParameters": "pipelines.IngestionPipelineDefinitionWorkdayReportParameters", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue": "pipelines.IngestionPipelineDefinitionWorkdayReportParametersQueryKeyValue", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.JiraConnectorOptions": "pipelines.JiraConnectorOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.JsonTransformerOptions": "pipelines.JsonTransformerOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.KafkaOptions": "pipelines.KafkaOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.LinkedInAdsOptions": "pipelines.LinkedInAdsOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.LinkedInAdsOptions_LinkedInAdsCustomReportOptions": "pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.ManualTrigger": "pipelines.ManualTrigger", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.MarketoOptions": "pipelines.MarketoOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.MetaMarketingOptions": "pipelines.MetaMarketingOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.MetaMarketingOptions_MetaMarketingCustomReportOptions": "pipelines.MetaMarketingOptionsMetaMarketingCustomReportOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.NotebookLibrary": "pipelines.NotebookLibrary", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.Notifications": "pipelines.Notifications", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.OperationTimeWindow": "pipelines.OperationTimeWindow", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.OutlookOptions": "pipelines.OutlookOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PathPattern": "pipelines.PathPattern", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelineCluster": "pipelines.PipelineCluster", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelineLibrary": "pipelines.PipelineLibrary", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelineTrigger": "pipelines.PipelineTrigger", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelinesAutoScale": "pipelines.PipelineClusterAutoscale", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelinesAwsAttributes": "compute.AwsAttributes", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelinesAzureAttributes": "compute.AzureAttributes", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelinesClusterLogConf": "compute.ClusterLogConf", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelinesDbfsStorageInfo": "compute.DbfsStorageInfo", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelinesEnvironment": "pipelines.PipelinesEnvironment", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelinesGcpAttributes": "compute.GcpAttributes", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelinesInitScriptInfo": "compute.InitScriptInfo", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelinesJobRunAs": "pipelines.RunAs", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelinesMavenLibrary": "compute.MavenLibrary", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PipelinesS3StorageInfo": "compute.S3StorageInfo", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PostgresCatalogConfig": "pipelines.PostgresCatalogConfig", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.PostgresSlotConfig": "pipelines.PostgresSlotConfig", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.ProtobufTransformerOptions": "pipelines.ProtobufTransformerOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.RabbitmqOptions": "pipelines.RabbitmqOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.RedditAdsOptions": "pipelines.RedditAdsOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.RedditAdsOptions_RedditAdsCustomReportOptions": "pipelines.RedditAdsOptionsRedditAdsCustomReportOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.RestartWindow": "pipelines.RestartWindow", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.SchemaRegistryConfig": "pipelines.SchemaRegistryConfig", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.SharepointOptions": "pipelines.SharepointOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.SmartsheetOptions": "pipelines.SmartsheetOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.SourceCatalogConfig": "pipelines.SourceCatalogConfig", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.SourceConfig": "pipelines.SourceConfig", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.TikTokAdsOptions": "pipelines.TikTokAdsOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.TikTokAdsOptions_TikTokAdsCustomReportOptions": "pipelines.TikTokAdsOptionsTikTokAdsCustomReportOptions", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.Transformer": "pipelines.Transformer", + "github.com/databricks/cli/libs/sdktypes/pipelines/v2.ZendeskSupportOptions": "pipelines.ZendeskSupportOptions", + "github.com/databricks/cli/libs/sdktypes/postgres/v1.DailySchedule": "postgres.DailySchedule", + "github.com/databricks/cli/libs/sdktypes/postgres/v1.EndpointGroupSpec": "postgres.EndpointGroupSpec", + "github.com/databricks/cli/libs/sdktypes/postgres/v1.EndpointSettings": "postgres.EndpointSettings", + "github.com/databricks/cli/libs/sdktypes/postgres/v1.MonthlySchedule": "postgres.MonthlySchedule", + "github.com/databricks/cli/libs/sdktypes/postgres/v1.NewPipelineSpec": "postgres.NewPipelineSpec", + "github.com/databricks/cli/libs/sdktypes/postgres/v1.ProjectCustomTag": "postgres.ProjectCustomTag", + "github.com/databricks/cli/libs/sdktypes/postgres/v1.ProjectDefaultEndpointSettings": "postgres.ProjectDefaultEndpointSettings", + "github.com/databricks/cli/libs/sdktypes/postgres/v1.Role_Attributes": "postgres.RoleAttributes", + "github.com/databricks/cli/libs/sdktypes/postgres/v1.SyncedTable_SyncedTableSpec_ExtraColumn": "postgres.SyncedTableSyncedTableSpecExtraColumn", + "github.com/databricks/cli/libs/sdktypes/postgres/v1.SyncedTable_SyncedTableSpec_TypeOverride": "postgres.SyncedTableSyncedTableSpecTypeOverride", + "github.com/databricks/cli/libs/sdktypes/postgres/v1.WeeklySchedule": "postgres.WeeklySchedule", + "github.com/databricks/cli/libs/sdktypes/uc/catalogs/v1.AzureEncryptionSettings": "catalog.AzureEncryptionSettings", + "github.com/databricks/cli/libs/sdktypes/uc/catalogs/v1.EncryptionSettings": "catalog.EncryptionSettings", + "github.com/databricks/cli/libs/sdktypes/uc/externallocations/v1.AwsSqsQueue": "catalog.AwsSqsQueue", + "github.com/databricks/cli/libs/sdktypes/uc/externallocations/v1.AzureQueueStorage": "catalog.AzureQueueStorage", + "github.com/databricks/cli/libs/sdktypes/uc/externallocations/v1.EncryptionDetails": "catalog.EncryptionDetails", + "github.com/databricks/cli/libs/sdktypes/uc/externallocations/v1.FileEventQueue": "catalog.FileEventQueue", + "github.com/databricks/cli/libs/sdktypes/uc/externallocations/v1.GcpPubsub": "catalog.GcpPubsub", + "github.com/databricks/cli/libs/sdktypes/uc/externallocations/v1.SseEncryptionDetails": "catalog.SseEncryptionDetails", + "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1.RegisteredModelAliasInfo": "catalog.RegisteredModelAlias", + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1.DeltaSyncVectorIndexSpecRequest": "vectorsearch.DeltaSyncVectorIndexSpecRequest", + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1.DirectAccessVectorIndexSpec": "vectorsearch.DirectAccessVectorIndexSpec", + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1.EmbeddingSourceColumn": "vectorsearch.EmbeddingSourceColumn", + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1.EmbeddingVectorColumn": "vectorsearch.EmbeddingVectorColumn", + "github.com/databricks/cli/libs/sdktypes/warehouses/v1.Channel": "sql.Channel", + "github.com/databricks/cli/libs/sdktypes/warehouses/v1.EndpointTagPair": "sql.EndpointTagPair", + "github.com/databricks/cli/libs/sdktypes/warehouses/v1.EndpointTags": "sql.EndpointTags", + "github.com/databricks/sdk-go/aigateway/v1.ModelProviderServiceConfig_ExternalModelProviderType": "catalog.ModelProviderServiceConfigExternalModelProviderType", + "github.com/databricks/sdk-go/aigateway/v1.ModelServiceConfig_DestinationConfig_DestinationType": "catalog.ModelServiceConfigDestinationConfigDestinationType", + "github.com/databricks/sdk-go/aigateway/v1.RateLimit_RateLimitKey": "catalog.RateLimitRateLimitKey", + "github.com/databricks/sdk-go/aigateway/v1.RateLimit_RateLimitRenewalPeriod": "catalog.RateLimitRateLimitRenewalPeriod", + "github.com/databricks/sdk-go/alerts/v2.Aggregation": "sql.Aggregation", + "github.com/databricks/sdk-go/alerts/v2.AlertEvaluationState": "sql.AlertEvaluationState", + "github.com/databricks/sdk-go/alerts/v2.ComparisonOperator": "sql.ComparisonOperator", + "github.com/databricks/sdk-go/alerts/v2.CustomTemplateFormat": "sql.CustomTemplateFormat", + "github.com/databricks/sdk-go/alerts/v2.SchedulePauseStatus": "sql.SchedulePauseStatus", + "github.com/databricks/sdk-go/apps/v1.AppResourceApp_AppPermission": "apps.AppResourceAppAppPermission", + "github.com/databricks/sdk-go/apps/v1.AppResourceDatabase_DatabasePermission": "apps.AppResourceDatabaseDatabasePermission", + "github.com/databricks/sdk-go/apps/v1.AppResourceExperiment_ExperimentPermission": "apps.AppResourceExperimentExperimentPermission", + "github.com/databricks/sdk-go/apps/v1.AppResourceGenieSpace_GenieSpacePermission": "apps.AppResourceGenieSpaceGenieSpacePermission", + "github.com/databricks/sdk-go/apps/v1.AppResourceJob_JobPermission": "apps.AppResourceJobJobPermission", + "github.com/databricks/sdk-go/apps/v1.AppResourcePostgres_PostgresPermission": "apps.AppResourcePostgresPostgresPermission", + "github.com/databricks/sdk-go/apps/v1.AppResourceSecret_SecretPermission": "apps.AppResourceSecretSecretPermission", + "github.com/databricks/sdk-go/apps/v1.AppResourceServingEndpoint_ServingEndpointPermission": "apps.AppResourceServingEndpointServingEndpointPermission", + "github.com/databricks/sdk-go/apps/v1.AppResourceSqlWarehouse_SqlWarehousePermission": "apps.AppResourceSqlWarehouseSqlWarehousePermission", + "github.com/databricks/sdk-go/apps/v1.AppResourceUcSecurable_UcSecurablePermission": "apps.AppResourceUcSecurableUcSecurablePermission", + "github.com/databricks/sdk-go/apps/v1.AppResourceUcSecurable_UcSecurableType": "apps.AppResourceUcSecurableUcSecurableType", + "github.com/databricks/sdk-go/apps/v1.ComputeSize": "apps.ComputeSize", + "github.com/databricks/sdk-go/clusters/v2.AwsAvailability": "compute.AwsAvailability", + "github.com/databricks/sdk-go/clusters/v2.AzureAvailability": "compute.AzureAvailability", + "github.com/databricks/sdk-go/clusters/v2.ComputeKind": "compute.Kind", + "github.com/databricks/sdk-go/clusters/v2.ConfidentialComputeType": "compute.ConfidentialComputeType", + "github.com/databricks/sdk-go/clusters/v2.DataSecurityMode": "compute.DataSecurityMode", + "github.com/databricks/sdk-go/clusters/v2.DependencyMode": "compute.DependencyMode", + "github.com/databricks/sdk-go/clusters/v2.EbsVolumeType": "compute.EbsVolumeType", + "github.com/databricks/sdk-go/clusters/v2.GcpAvailability": "compute.GcpAvailability", + "github.com/databricks/sdk-go/clusters/v2.RuntimeEngine": "compute.RuntimeEngine", + "github.com/databricks/sdk-go/database/v1.SyncedTableSchedulingPolicy": "database.SyncedTableSchedulingPolicy", + "github.com/databricks/sdk-go/database/v1.SyncedTableSpec_PgSpecificType": "database.SyncedTableSpecPgSpecificType", + "github.com/databricks/sdk-go/instancepools/v2.AwsAvailability": "compute.InstancePoolAwsAttributesAvailability", + "github.com/databricks/sdk-go/instancepools/v2.AzureAvailability": "compute.InstancePoolAzureAttributesAvailability", + "github.com/databricks/sdk-go/instancepools/v2.AzureDiskVolumeType": "compute.DiskTypeAzureDiskVolumeType", + "github.com/databricks/sdk-go/instancepools/v2.EbsVolumeType": "compute.DiskTypeEbsVolumeType", + "github.com/databricks/sdk-go/instancepools/v2.GcpAvailability": "compute.GcpAvailability", + "github.com/databricks/sdk-go/jobs/v2.AiRuntimeTask_PriorityClass": "jobs.AiRuntimeTaskPriorityClass", + "github.com/databricks/sdk-go/jobs/v2.AuthenticationMethod": "jobs.AuthenticationMethod", + "github.com/databricks/sdk-go/jobs/v2.AwsAvailability": "compute.AwsAvailability", + "github.com/databricks/sdk-go/jobs/v2.AzureAvailability": "compute.AzureAvailability", + "github.com/databricks/sdk-go/jobs/v2.ComputeKind": "compute.Kind", + "github.com/databricks/sdk-go/jobs/v2.ComputeSpec_AcceleratorType": "jobs.ComputeSpecAcceleratorType", + "github.com/databricks/sdk-go/jobs/v2.ConditionTask_ConditionTaskOperator": "jobs.ConditionTaskOp", + "github.com/databricks/sdk-go/jobs/v2.ConfidentialComputeType": "compute.ConfidentialComputeType", + "github.com/databricks/sdk-go/jobs/v2.DataSecurityMode": "compute.DataSecurityMode", + "github.com/databricks/sdk-go/jobs/v2.DayOfWeek": "jobs.DayOfWeek", + "github.com/databricks/sdk-go/jobs/v2.DependencyMode": "compute.DependencyMode", + "github.com/databricks/sdk-go/jobs/v2.EbsVolumeType": "compute.EbsVolumeType", + "github.com/databricks/sdk-go/jobs/v2.GcpAvailability": "compute.GcpAvailability", + "github.com/databricks/sdk-go/jobs/v2.HardwareAcceleratorType": "compute.HardwareAcceleratorType", + "github.com/databricks/sdk-go/jobs/v2.JobsHealthMetric": "jobs.JobsHealthMetric", + "github.com/databricks/sdk-go/jobs/v2.JobsHealthOperator": "jobs.JobsHealthOperator", + "github.com/databricks/sdk-go/jobs/v2.ModelTriggerConfiguration_ModelTriggerCondition": "jobs.ModelTriggerConfigurationCondition", + "github.com/databricks/sdk-go/jobs/v2.PerformanceTarget_PerformanceTarget": "jobs.PerformanceTarget", + "github.com/databricks/sdk-go/jobs/v2.PeriodicTriggerConfiguration_TimeUnit": "jobs.PeriodicTriggerConfigurationTimeUnit", + "github.com/databricks/sdk-go/jobs/v2.RuntimeEngine": "compute.RuntimeEngine", + "github.com/databricks/sdk-go/jobs/v2.SchedulePauseStatus": "jobs.PauseStatus", + "github.com/databricks/sdk-go/jobs/v2.Source": "jobs.Source", + "github.com/databricks/sdk-go/jobs/v2.SqlConditionTriggerMode": "jobs.SqlConditionTriggerMode", + "github.com/databricks/sdk-go/jobs/v2.StorageMode": "jobs.StorageMode", + "github.com/databricks/sdk-go/jobs/v2.TableTriggerConfiguration_Condition": "jobs.Condition", + "github.com/databricks/sdk-go/jobs/v2.TaskDependencyType": "jobs.RunIf", + "github.com/databricks/sdk-go/jobs/v2.TaskRetryMode": "jobs.TaskRetryMode", + "github.com/databricks/sdk-go/modelserving/v1.Behavior": "serving.AiGatewayGuardrailPiiBehaviorBehavior", + "github.com/databricks/sdk-go/modelserving/v1.TelemetryFeature": "serving.TelemetryFeature", + "github.com/databricks/sdk-go/pipelines/v2.ConnectorType": "pipelines.ConnectorType", + "github.com/databricks/sdk-go/pipelines/v2.DayOfWeek": "pipelines.DayOfWeek", + "github.com/databricks/sdk-go/pipelines/v2.FileIngestionOptions_FileFormat": "pipelines.FileIngestionOptionsFileFormat", + "github.com/databricks/sdk-go/pipelines/v2.FileIngestionOptions_SchemaEvolutionMode": "pipelines.FileIngestionOptionsSchemaEvolutionMode", + "github.com/databricks/sdk-go/pipelines/v2.GoogleDriveOptions_GoogleDriveEntityType": "pipelines.GoogleDriveOptionsGoogleDriveEntityType", + "github.com/databricks/sdk-go/pipelines/v2.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity": "pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptionsLinkedInAdsEntityGranularity", + "github.com/databricks/sdk-go/pipelines/v2.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder": "pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptionsLinkedInAdsFinder", + "github.com/databricks/sdk-go/pipelines/v2.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity": "pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptionsLinkedInAdsTimeGranularity", + "github.com/databricks/sdk-go/pipelines/v2.OutlookAttachmentMode": "pipelines.OutlookAttachmentMode", + "github.com/databricks/sdk-go/pipelines/v2.OutlookBodyFormat": "pipelines.OutlookBodyFormat", + "github.com/databricks/sdk-go/pipelines/v2.ParseMode": "pipelines.ParseMode", + "github.com/databricks/sdk-go/pipelines/v2.PipelinesAwsAvailability": "compute.AwsAvailability", + "github.com/databricks/sdk-go/pipelines/v2.PipelinesAzureAvailability": "compute.AzureAvailability", + "github.com/databricks/sdk-go/pipelines/v2.PipelinesEbsVolumeType": "compute.EbsVolumeType", + "github.com/databricks/sdk-go/pipelines/v2.PipelinesGcpAvailability": "compute.GcpAvailability", + "github.com/databricks/sdk-go/pipelines/v2.ScdType_ScdType": "pipelines.TableSpecificConfigScdType", + "github.com/databricks/sdk-go/pipelines/v2.SharepointOptions_SharepointEntityType": "pipelines.SharepointOptionsSharepointEntityType", + "github.com/databricks/sdk-go/pipelines/v2.TikTokAdsOptions_TikTokDataLevel": "pipelines.TikTokAdsOptionsTikTokDataLevel", + "github.com/databricks/sdk-go/pipelines/v2.TikTokAdsOptions_TikTokReportType": "pipelines.TikTokAdsOptionsTikTokReportType", + "github.com/databricks/sdk-go/pipelines/v2.Transformer_Format": "pipelines.TransformerFormat", + "github.com/databricks/sdk-go/postgres/v1.DayOfWeek": "postgres.DayOfWeek", + "github.com/databricks/sdk-go/postgres/v1.EndpointType": "postgres.EndpointType", + "github.com/databricks/sdk-go/postgres/v1.NewPipelineSpec_PipelineChannel": "postgres.NewPipelineSpecPipelineChannel", + "github.com/databricks/sdk-go/postgres/v1.Role_AuthMethod": "postgres.RoleAuthMethod", + "github.com/databricks/sdk-go/postgres/v1.Role_IdentityType": "postgres.RoleIdentityType", + "github.com/databricks/sdk-go/postgres/v1.Role_MembershipRole": "postgres.RoleMembershipRole", + "github.com/databricks/sdk-go/postgres/v1.SyncedTable_SyncedTableSpec_ExtraColumn_Maintenance": "postgres.SyncedTableSyncedTableSpecExtraColumnMaintenance", + "github.com/databricks/sdk-go/postgres/v1.SyncedTable_SyncedTableSpec_PgSpecificType": "postgres.SyncedTableSyncedTableSpecPgSpecificType", + "github.com/databricks/sdk-go/postgres/v1.SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy": "postgres.SyncedTableSyncedTableSpecSyncedTableSchedulingPolicy", + "github.com/databricks/sdk-go/uc/externallocations/v1.SseEncryptionAlgorithm": "catalog.SseEncryptionDetailsAlgorithm", + "github.com/databricks/sdk-go/uc/volumes/v1.VolumeType": "catalog.VolumeType", + "github.com/databricks/sdk-go/vectorsearch/v1.EndpointType": "vectorsearch.EndpointType", + "github.com/databricks/sdk-go/vectorsearch/v1.IndexSubtype": "vectorsearch.IndexSubtype", + "github.com/databricks/sdk-go/vectorsearch/v1.PipelineType": "vectorsearch.PipelineType", + "github.com/databricks/sdk-go/vectorsearch/v1.VectorIndexType": "vectorsearch.VectorIndexType", + "github.com/databricks/sdk-go/warehouses/v1.ChannelName": "sql.ChannelName", + "github.com/databricks/sdk-go/warehouses/v1.EndpointSpotInstancePolicy": "sql.SpotInstancePolicy", + "github.com/databricks/sdk-go/warehouses/v1.WarehouseType": "sql.CreateWarehouseRequestWarehouseType" + }, + "required": { + "apps.App": [ + "name" + ], + "apps.AppResource": [ + "name" + ], + "apps.AppResourceDatabase": [ + "database_name", + "instance_name", + "permission" + ], + "apps.AppResourceExperiment": [ + "experiment_id", + "permission" + ], + "apps.AppResourceGenieSpace": [ + "name", + "permission", + "space_id" + ], + "apps.AppResourceJob": [ + "id", + "permission" + ], + "apps.AppResourceSecret": [ + "key", + "permission", + "scope" + ], + "apps.AppResourceServingEndpoint": [ + "name", + "permission" + ], + "apps.AppResourceSqlWarehouse": [ + "id", + "permission" + ], + "apps.AppResourceUcSecurable": [ + "permission", + "securable_full_name", + "securable_type" + ], + "apps.GitRepository": [ + "provider", + "url" + ], + "apps.UnityCatalog": [ + "logs_table", + "metrics_table", + "traces_table" + ], + "catalog.AzureEncryptionSettings": [ + "azure_tenant_id" + ], + "catalog.CreateCatalog": [ + "name" + ], + "catalog.CreateExternalLocation": [ + "credential_name", + "name", + "url" + ], + "catalog.CreateMonitor": [ + "assets_dir", + "output_schema_name" + ], + "catalog.CreateSchema": [ + "catalog_name", + "name" + ], + "catalog.CreateVolumeRequestContent": [ + "catalog_name", + "name", + "schema_name", + "volume_type" + ], + "catalog.InferenceTableConfig": [ + "parent" + ], + "catalog.McpServiceConfigSourceConnection": [ + "name" + ], + "catalog.ModelProviderServiceConfigModelTargetConfig": [ + "model" + ], + "catalog.ModelProviderServiceConfigSecretReference": [ + "name" + ], + "catalog.ModelProviderServiceConfigServiceCredential": [ + "name" + ], + "catalog.ModelServiceConfigDestinationConfig": [ + "destination_type", + "name" + ], + "catalog.ModelServiceConfigExternalModelConfig": [ + "model_provider_service", + "target" + ], + "catalog.ModelServiceConfigPayPerTokenConfig": [ + "model" + ], + "catalog.ModelServiceConfigProvisionedThroughputConfig": [ + "model_serving_endpoint" + ], + "catalog.MonitorCronSchedule": [ + "quartz_cron_expression", + "timezone_id" + ], + "catalog.MonitorInferenceLog": [ + "granularities", + "model_id_col", + "prediction_col", + "problem_type", + "timestamp_col" + ], + "catalog.MonitorMetric": [ + "definition", + "input_columns", + "name", + "output_data_type", + "type" + ], + "catalog.MonitorTimeSeries": [ + "granularities", + "timestamp_col" + ], + "catalog.RateLimit": [ + "key", + "renewal_period" + ], + "catalog.Secret": [ + "catalog_name", + "name", + "schema_name", + "value" + ], + "compute.Adlsgen2Info": [ + "destination" + ], + "compute.CreateInstancePool": [ + "instance_pool_name", + "node_type_id" + ], + "compute.DbfsStorageInfo": [ + "destination" + ], + "compute.GcsStorageInfo": [ + "destination" + ], + "compute.LocalFileInfo": [ + "destination" + ], + "compute.MavenLibrary": [ + "coordinates" + ], + "compute.PythonPyPiLibrary": [ + "package" + ], + "compute.RCranLibrary": [ + "package" + ], + "compute.S3StorageInfo": [ + "destination" + ], + "compute.VolumesStorageInfo": [ + "destination" + ], + "compute.WorkloadType": [ + "clients" + ], + "compute.WorkspaceStorageInfo": [ + "destination" + ], + "database.DatabaseCatalog": [ + "database_instance_name", + "database_name", + "name" + ], + "database.DatabaseInstance": [ + "name" + ], + "database.SyncedDatabaseTable": [ + "name" + ], + "database.SyncedTableSpecTypeOverride": [ + "column_name", + "pg_type" + ], + "jobs.AiRuntimeTask": [ + "deployments", + "experiment" + ], + "jobs.CleanRoomsNotebookTask": [ + "clean_room_name", + "notebook_name" + ], + "jobs.ComputeConfig": [ + "num_gpus" + ], + "jobs.ComputeSpec": [ + "accelerator_count", + "accelerator_type" + ], + "jobs.ConditionTask": [ + "left", + "op", + "right" + ], + "jobs.CronSchedule": [ + "quartz_cron_expression", + "timezone_id" + ], + "jobs.CronTriggerConfiguration": [ + "quartz_cron_expression", + "timezone_id" + ], + "jobs.DbtTask": [ + "commands" + ], + "jobs.DeploymentSpec": [ + "compute" + ], + "jobs.FileArrivalTriggerConfiguration": [ + "url" + ], + "jobs.ForEachTask": [ + "inputs", + "task" + ], + "jobs.GenAiComputeTask": [ + "dl_runtime_image" + ], + "jobs.GitSource": [ + "git_provider", + "git_url" + ], + "jobs.JobCluster": [ + "job_cluster_key" + ], + "jobs.JobDeployment": [ + "kind" + ], + "jobs.JobEnvironment": [ + "environment_key" + ], + "jobs.JobEnvironmentVariables": [ + "environment_variables_key" + ], + "jobs.JobParameterDefinition": [ + "default", + "name" + ], + "jobs.JobSource": [ + "import_from_git_branch", + "job_config_path" + ], + "jobs.JobsHealthRule": [ + "metric", + "op", + "value" + ], + "jobs.MaintenanceWindow": [ + "day_of_week", + "start_hour", + "timezone_id" + ], + "jobs.ModelTriggerConfiguration": [ + "condition" + ], + "jobs.NotebookTask": [ + "notebook_path" + ], + "jobs.PeriodicTriggerConfiguration": [ + "interval", + "unit" + ], + "jobs.PipelineTask": [ + "pipeline_id" + ], + "jobs.PythonWheelTask": [ + "entry_point", + "package_name" + ], + "jobs.QueueSettings": [ + "enabled" + ], + "jobs.RunJobTask": [ + "job_id" + ], + "jobs.RunNow": [ + "job_id" + ], + "jobs.SparkPythonTask": [ + "python_file" + ], + "jobs.SqlConditionConfiguration": [ + "sql_query_id", + "warehouse_id" + ], + "jobs.SqlTask": [ + "warehouse_id" + ], + "jobs.SqlTaskAlert": [ + "alert_id" + ], + "jobs.SqlTaskDashboard": [ + "dashboard_id" + ], + "jobs.SqlTaskFile": [ + "path" + ], + "jobs.SqlTaskQuery": [ + "query_id" + ], + "jobs.TableUpdateTriggerConfiguration": [ + "table_names" + ], + "jobs.Task": [ + "task_key" + ], + "jobs.TaskDependency": [ + "task_key" + ], + "jobs.Webhook": [ + "id" + ], + "ml.CreateExperiment": [ + "name" + ], + "ml.CreateModelRequest": [ + "name" + ], + "ml.UcTraceLocation": [ + "catalog", + "schema" + ], + "pipelines.AutoFullRefreshPolicy": [ + "enabled" + ], + "pipelines.DataStagingOptions": [ + "catalog_name", + "schema_name" + ], + "pipelines.GoogleAdsCustomReportOptions": [ + "resource" + ], + "pipelines.GoogleAdsOptions": [ + "manager_account_id" + ], + "pipelines.IngestionGatewayPipelineDefinition": [ + "connection_name", + "gateway_storage_catalog", + "gateway_storage_schema" + ], + "pipelines.LinkedInAdsOptionsLinkedInAdsCustomReportOptions": [ + "finder" + ], + "pipelines.OperationTimeWindow": [ + "start_hour" + ], + "pipelines.PipelineClusterAutoscale": [ + "max_workers", + "min_workers" + ], + "pipelines.PipelineDeployment": [ + "kind" + ], + "pipelines.RabbitmqOptions": [ + "queue" + ], + "pipelines.ReportSpec": [ + "destination_catalog", + "destination_schema", + "source_url" + ], + "pipelines.RestartWindow": [ + "start_hour" + ], + "pipelines.SchemaSpec": [ + "destination_catalog", + "destination_schema" + ], + "pipelines.TableSpec": [ + "destination_catalog", + "destination_schema" + ], + "postgres.CatalogCatalogSpec": [ + "postgres_database" + ], + "postgres.DatabaseDatabaseSpec": [ + "role" + ], + "postgres.EndpointGroupSpec": [ + "max", + "min" + ], + "postgres.EndpointSpec": [ + "endpoint_type" + ], + "postgres.MonthlySchedule": [ + "day" + ], + "postgres.ScheduleCadence": [ + "retention" + ], + "postgres.SyncedTableSyncedTableSpecExtraColumn": [ + "column_name", + "column_type" + ], + "postgres.SyncedTableSyncedTableSpecTypeOverride": [ + "column_name", + "pg_type" + ], + "postgres.WeeklySchedule": [ + "day_of_week" + ], + "serving.AiGatewayRateLimit": [ + "renewal_period" + ], + "serving.AmazonBedrockConfig": [ + "aws_region", + "bedrock_provider" + ], + "serving.ApiKeyAuth": [ + "key" + ], + "serving.CreateServingEndpoint": [ + "name" + ], + "serving.CustomProviderConfig": [ + "custom_provider_url" + ], + "serving.DatabricksModelServingConfig": [ + "databricks_workspace_url" + ], + "serving.EndpointTag": [ + "key" + ], + "serving.ExternalModel": [ + "name", + "provider", + "task" + ], + "serving.FallbackConfig": [ + "enabled" + ], + "serving.GoogleCloudVertexAiConfig": [ + "project_id", + "region" + ], + "serving.RateLimit": [ + "calls", + "renewal_period" + ], + "serving.Route": [ + "traffic_percentage" + ], + "serving.ServedModelInput": [ + "model_name", + "model_version", + "scale_to_zero_enabled" + ], + "sql.AlertStatementParameter": [ + "name" + ], + "sql.AlertV2": [ + "display_name", + "evaluation", + "query_text", + "schedule", + "warehouse_id" + ], + "sql.AlertV2Evaluation": [ + "comparison_operator", + "source" + ], + "sql.AlertV2OperandColumn": [ + "name" + ], + "sql.CronSchedule": [ + "quartz_cron_schedule", + "timezone_id" + ], + "vectorsearch.CreateEndpoint": [ + "endpoint_type", + "name" + ], + "vectorsearch.CreateVectorIndexRequest": [ + "endpoint_name", + "index_type", + "name", + "primary_key" + ], + "workspace.AzureKeyVaultSecretScopeMetadata": [ + "dns_name", + "resource_id" + ] + }, + "field_refs": { + "catalog.PrivilegeAssignment.privileges": "catalog.Privilege", + "jobs.GitSource.git_provider": "jobs.GitProvider", + "jobs.Task.email_notifications": "jobs.TaskEmailNotifications", + "jobs.Task.notification_settings": "jobs.TaskNotificationSettings", + "pipelines.PipelineClusterAutoscale.mode": "pipelines.PipelineClusterAutoscaleMode", + "pipelines.PipelineLibrary.file": "pipelines.FileLibrary", + "serving.AiGatewayRateLimit.key": "serving.AiGatewayRateLimitKey", + "serving.AiGatewayRateLimit.renewal_period": "serving.AiGatewayRateLimitRenewalPeriod", + "serving.AmazonBedrockConfig.bedrock_provider": "serving.AmazonBedrockConfigBedrockProvider", + "serving.EndpointCoreConfigInput.served_models": "serving.ServedModelInput", + "serving.ExternalModel.provider": "serving.ExternalModelProvider", + "serving.RateLimit.key": "serving.RateLimitKey", + "serving.RateLimit.renewal_period": "serving.RateLimitRenewalPeriod" + } +} diff --git a/bundle/internal/sdkmeta/roots.go b/bundle/internal/sdkmeta/roots.go new file mode 100644 index 00000000000..2e0d8a4a0f9 --- /dev/null +++ b/bundle/internal/sdkmeta/roots.go @@ -0,0 +1,111 @@ +package sdkmeta + +import ( + "reflect" + "sync" + + "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/qualitymonitors" + "github.com/databricks/cli/libs/sdktypes/aigateway/v1" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/libs/sdktypes/clusterlibraries/v2" + "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2" + "github.com/databricks/cli/libs/sdktypes/clusters/v2" + "github.com/databricks/cli/libs/sdktypes/database/v1" + "github.com/databricks/cli/libs/sdktypes/experiments/v1" + "github.com/databricks/cli/libs/sdktypes/instancepools/v2" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/lakeview/v1" + "github.com/databricks/cli/libs/sdktypes/modelregistry/v1" + "github.com/databricks/cli/libs/sdktypes/modelserving/v1" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/sdktypes/secrets/v1" + "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1" + ucsecrets "github.com/databricks/cli/libs/sdktypes/uc/secrets/v1" + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" + "github.com/databricks/cli/libs/sdktypes/warehouses/v1" + sdktypes "github.com/databricks/sdk-go/core/types" +) + +// Pseudo schema names for sdk-go native types; they are not in cli.json and +// keep the definition names of the previous SDK's equivalents. +const ( + nativeTime = "@time" + nativeDuration = "@duration" +) + +var nativeDefinitionNames = map[string]string{ + nativeTime: "github.com/databricks/databricks-sdk-go/common/types/time.Time", + nativeDuration: "github.com/databricks/databricks-sdk-go/common/types/duration.Duration", +} + +// roots maps the API types that the bundle configuration references directly +// (embedded in resources or used by CLI-owned fields) to their cli.json schema. +// Types nested inside them are mapped by following cli.json refs. CLI-owned +// stand-ins for API types (resources.CreateCatalog, permission levels) are +// listed here too so they keep their previous schema definition names. +var roots = sync.OnceValue(func() map[reflect.Type]string { + return map[reflect.Type]string{ + reflect.TypeFor[sdktypes.Time](): nativeTime, + reflect.TypeFor[sdktypes.Duration](): nativeDuration, + + reflect.TypeFor[alerts.Alert](): "sql.AlertV2", + reflect.TypeFor[apps.App](): "apps.App", + // Only referenced from output-only fields, so not reached through refs. + reflect.TypeFor[apps.EnvVar](): "apps.EnvVar", + reflect.TypeFor[resources.CreateCatalog](): "catalog.CreateCatalog", + reflect.TypeFor[clusterpolicies.CreatePolicyRequest](): "compute.CreatePolicy", + reflect.TypeFor[clusters.CreateClusterRequest](): "compute.ClusterSpec", + reflect.TypeFor[clusterlibraries.Library](): "compute.Library", + reflect.TypeFor[lakeview.LifecycleState](): "dashboards.LifecycleState", + reflect.TypeFor[database.DatabaseCatalog](): "database.DatabaseCatalog", + reflect.TypeFor[database.DatabaseInstance](): "database.DatabaseInstance", + reflect.TypeFor[database.SyncedDatabaseTable](): "database.SyncedDatabaseTable", + reflect.TypeFor[resources.CreateExternalLocation](): "catalog.CreateExternalLocation", + reflect.TypeFor[instancepools.CreateInstancePoolRequest](): "compute.CreateInstancePool", + reflect.TypeFor[jobs.JobSettings](): "jobs.JobSettings", + reflect.TypeFor[jobs.RunNowRequest](): "jobs.RunNow", + reflect.TypeFor[aigateway.McpServiceConfig](): "catalog.McpServiceConfig", + reflect.TypeFor[aigateway.ModelProviderServiceConfig](): "catalog.ModelProviderServiceConfig", + reflect.TypeFor[aigateway.ModelServiceConfig](): "catalog.ModelServiceConfig", + reflect.TypeFor[experiments.CreateExperimentRequest](): "ml.CreateExperiment", + reflect.TypeFor[modelregistry.CreateRegisteredModelRequest](): "ml.CreateModelRequest", + reflect.TypeFor[modelserving.CreateInferenceEndpointRequest](): "serving.CreateServingEndpoint", + reflect.TypeFor[pipelines.CreatePipelineRequest](): "pipelines.CreatePipeline", + reflect.TypeFor[postgres.BranchSpec](): "postgres.BranchSpec", + reflect.TypeFor[postgres.Catalog_CatalogSpec](): "postgres.CatalogCatalogSpec", + reflect.TypeFor[postgres.Database_DatabaseSpec](): "postgres.DatabaseDatabaseSpec", + reflect.TypeFor[postgres.EndpointSpec](): "postgres.EndpointSpec", + reflect.TypeFor[postgres.ProjectSpec](): "postgres.ProjectSpec", + reflect.TypeFor[postgres.Role_RoleSpec](): "postgres.RoleRoleSpec", + reflect.TypeFor[postgres.ScheduleCadence](): "postgres.ScheduleCadence", + reflect.TypeFor[postgres.SyncedTable_SyncedTableSpec](): "postgres.SyncedTableSyncedTableSpec", + reflect.TypeFor[qualitymonitors.CreateMonitor](): "catalog.CreateMonitor", + reflect.TypeFor[registeredmodels.CreateRegisteredModelRequest](): "catalog.CreateRegisteredModelRequest", + reflect.TypeFor[resources.CreateSchema](): "catalog.CreateSchema", + reflect.TypeFor[ucsecrets.Secret](): "catalog.Secret", + reflect.TypeFor[secrets.ScopeBackendType](): "workspace.ScopeBackendType", + reflect.TypeFor[secrets.AzureKeyVaultSecretScopeMetadata](): "workspace.AzureKeyVaultSecretScopeMetadata", + reflect.TypeFor[warehouses.CreateWarehouseRequest](): "sql.CreateWarehouseRequest", + reflect.TypeFor[vectorsearch.CreateEndpointRequest](): "vectorsearch.CreateEndpoint", + reflect.TypeFor[vectorsearch.CreateVectorIndexRequest](): "vectorsearch.CreateVectorIndexRequest", + reflect.TypeFor[resources.CreateVolumeRequestContent](): "catalog.CreateVolumeRequestContent", + reflect.TypeFor[grants.PrivilegeAssignment](): "catalog.PrivilegeAssignment", + + reflect.TypeFor[resources.AppPermissionLevel](): "apps.AppPermissionLevel", + reflect.TypeFor[resources.ClusterPermissionLevel](): "compute.ClusterPermissionLevel", + reflect.TypeFor[resources.ClusterPolicyPermissionLevel](): "compute.ClusterPolicyPermissionLevel", + reflect.TypeFor[resources.InstancePoolPermissionLevel](): "compute.InstancePoolPermissionLevel", + reflect.TypeFor[resources.JobPermissionLevel](): "jobs.JobPermissionLevel", + reflect.TypeFor[resources.ExperimentPermissionLevel](): "ml.ExperimentPermissionLevel", + reflect.TypeFor[resources.RegisteredModelPermissionLevel](): "ml.RegisteredModelPermissionLevel", + reflect.TypeFor[resources.ServingEndpointPermissionLevel](): "serving.ServingEndpointPermissionLevel", + reflect.TypeFor[resources.PipelinePermissionLevel](): "pipelines.PipelinePermissionLevel", + reflect.TypeFor[resources.WarehousePermissionLevel](): "sql.WarehousePermissionLevel", + reflect.TypeFor[resources.VectorSearchEndpointPermissionLevel](): "vectorsearch.VectorSearchEndpointPermissionLevel", + reflect.TypeFor[resources.PermissionLevel](): "iam.PermissionLevel", + } +}) diff --git a/bundle/internal/sdkmeta/sdkmeta.go b/bundle/internal/sdkmeta/sdkmeta.go new file mode 100644 index 00000000000..aa66cb104ac --- /dev/null +++ b/bundle/internal/sdkmeta/sdkmeta.go @@ -0,0 +1,332 @@ +// Package sdkmeta maps the API types used in the bundle configuration to the +// schemas of .codegen/cli.json and to the names they had in the previous Go SDK. +// +// Bundle configuration embeds sdk-go JSON mirrors (libs/sdktypes). Their names +// follow sdk-go (e.g. jobs.TaskSettings), while cli.json schemas and the +// published JSON schema / Python classes use the previous names (jobs.Task). +// The mapping is derived by walking the Go type graph of the bundle +// configuration in parallel with the cli.json schema graph: every field of a +// mapped type that refers to another schema maps the field's Go type to that +// schema. The walk starts from the explicit roots in roots.go. +package sdkmeta + +import ( + _ "embed" + "encoding/json" + "maps" + "reflect" + "slices" + "strings" + "sync" + + "github.com/databricks/cli/internal/clijson" + "github.com/databricks/cli/libs/structs/structtag" +) + +// LegacyPkgPrefix is the package path prefix of the previous Go SDK. Schema +// definition names keep using it so that generated artifacts stay stable. +const LegacyPkgPrefix = "github.com/databricks/databricks-sdk-go/service/" + +// Meta holds the mapping for one configuration root type. +type Meta struct { + schemas map[string]*clijson.SchemaJSON + names map[reflect.Type]string + // order records the walk order of types, see Order. + order map[reflect.Type]int + // alt lists, for types that sdk-go unified from several previous types, + // the other schemas they stand for (see legacyFile.FieldRefs). + alt map[reflect.Type][]string +} + +// legacyFile is the format of legacy.json: the schema names API types had in +// the previous SDK, and their required fields. sdk-go and its JSON mirrors +// mark every field optional, and cli.json carries neither list element refs +// nor required fields, so this information is recorded here. New types not +// listed are mapped by following cli.json refs or fall back to their own name. +type legacyFile struct { + // Names maps a Go type path to a cli.json schema name. + Names map[string]string `json:"names"` + // Required maps a cli.json schema name to its required fields. + Required map[string][]string `json:"required"` + // FieldRefs maps "." to the schema the field referred to + // where sdk-go changed the field's type: an enum replaced by a plain + // string, or two messages unified into one (jobs.TaskEmailNotifications + // and jobs.JobEmailNotifications). + FieldRefs map[string]string `json:"field_refs"` +} + +//go:embed legacy.json +var legacyJSON []byte + +var legacy = sync.OnceValue(func() legacyFile { + var f legacyFile + if err := json.Unmarshal(legacyJSON, &f); err != nil { + panic(err) + } + return f +}) + +// Build walks root and maps every API type reachable from it. +func Build(root reflect.Type, schemas map[string]*clijson.SchemaJSON) (*Meta, error) { + m := &Meta{schemas: schemas, names: map[reflect.Type]string{}, alt: map[reflect.Type][]string{}, order: map[reflect.Type]int{}} + maps.Copy(m.names, roots()) + lookup := func(t reflect.Type) string { + if name, ok := m.names[t]; ok { + return name + } + return legacy().Names[typeName(t)] + } + + seen := map[reflect.Type]bool{} + var walk func(t reflect.Type) + walk = func(t reflect.Type) { + t = elem(t) + if seen[t] { + return + } + seen[t] = true + m.order[t] = len(m.order) + if isAPIType(t) { + if name := lookup(t); name != "" { + m.names[t] = name + } + } + if t.Kind() != reflect.Struct || isNative(t) { + return + } + for _, f := range fields(t) { + ft := elem(f.field.Type) + if !f.field.Anonymous && isAPIType(ft) && lookup(ft) == "" && f.owner != nil { + if s := schemas[m.names[f.owner]]; s != nil { + if fs := s.Fields[f.name]; fs != nil && fs.Ref != "" { + m.names[ft] = fs.Ref + } + } + } + if !f.field.Anonymous && f.owner != nil { + if ref, ok := FieldRef(m.names[f.owner], f.name); ok && lookup(ft) != ref && !slices.Contains(m.alt[ft], ref) { + m.alt[ft] = append(m.alt[ft], ref) + } + } + walk(ft) + } + } + walk(root) + return m, nil +} + +// Name returns the cli.json schema name of t (e.g. "jobs.Task"), if t is a +// mapped API type. +func (m *Meta) Name(t reflect.Type) (string, bool) { + name, ok := m.names[elem(t)] + return name, ok +} + +// Schema returns the cli.json schema of t, if t is a mapped API type. +func (m *Meta) Schema(t reflect.Type) (*clijson.SchemaJSON, bool) { + name, ok := m.Name(t) + if !ok { + return nil, false + } + s, ok := m.schemas[name] + return s, ok +} + +// DefinitionName returns the type path the previous SDK type had, which is +// used as the JSON schema definition name (e.g. +// "github.com/databricks/databricks-sdk-go/service/jobs.Task"). +func (m *Meta) DefinitionName(t reflect.Type) (string, bool) { + name, ok := m.Name(t) + if !ok { + return "", false + } + if p, ok := nativeDefinitionNames[name]; ok { + return p, true + } + return LegacyPkgPrefix + name, true +} + +// Enum returns the enum values of t from cli.json. +func (m *Meta) Enum(t reflect.Type) ([]string, bool) { + s, ok := m.Schema(t) + if !ok || len(s.Enum) == 0 { + return nil, false + } + return s.Enum, true +} + +// SchemaHasField reports whether the named cli.json schema defines field. It +// reports true for names without a schema with fields (CLI types). +func (m *Meta) SchemaHasField(schema, field string) bool { + s, ok := m.schemas[schema] + if !ok || s.Fields == nil { + return true + } + _, ok = s.Fields[field] + return ok +} + +// EnumOf returns the enum values of the named cli.json schema. +func (m *Meta) EnumOf(schema string) ([]string, bool) { + s, ok := m.schemas[schema] + if !ok || len(s.Enum) == 0 { + return nil, false + } + return s.Enum, true +} + +// Required returns the JSON names of the required fields of t, including +// those of API types embedded in t. +func (m *Meta) Required(t reflect.Type) []string { + t = elem(t) + var out []string + queue := []reflect.Type{t} + for len(queue) > 0 { + ct := queue[0] + queue = queue[1:] + if name, ok := m.names[ct]; ok { + out = append(out, legacy().Required[name]...) + } + if ct.Kind() != reflect.Struct { + continue + } + for f := range ct.Fields() { + if f.Anonymous { + queue = append(queue, elem(f.Type)) + } + } + } + slices.Sort(out) + return slices.Compact(out) +} + +// FieldRef returns the schema the given field of schema referred to before +// sdk-go changed the field's type, if it did. +func FieldRef(schema, field string) (string, bool) { + ref, ok := legacy().FieldRefs[schema+"."+field] + return ref, ok +} + +// Order returns the position of t in a depth-first walk of the root type in +// field declaration order, which is the order jsonschema.FromType visits +// types in. ok is false for types not reachable from the root. +func (m *Meta) Order(t reflect.Type) (int, bool) { + i, ok := m.order[elem(t)] + return i, ok +} + +// RequiredFields returns the required fields of a cli.json schema. +func RequiredFields(schema string) []string { + return legacy().Required[schema] +} + +// AltSchemas returns the cli.json schemas of the previous types that t also +// stands for, beyond the one returned by Schema. +func (m *Meta) AltSchemas(t reflect.Type) []*clijson.SchemaJSON { + var out []*clijson.SchemaJSON + for _, name := range m.alt[elem(t)] { + if s, ok := m.schemas[name]; ok { + out = append(out, s) + } + } + return out +} + +// FieldOwners returns, for each serialized field of t, the API type declaring +// it, if any. +func (m *Meta) FieldOwners(t reflect.Type) map[string]reflect.Type { + out := map[string]reflect.Type{} + for _, f := range fields(elem(t)) { + if !f.field.Anonymous && f.owner != nil { + out[f.name] = f.owner + } + } + return out +} + +// Types returns all mapped types. +func (m *Meta) Types() map[reflect.Type]string { + return m.names +} + +type fieldInfo struct { + name string + field reflect.StructField + // owner is the mapped API type declaring the field, nil for CLI types. + owner reflect.Type +} + +// fields lists the serialized fields of t with embedded structs flattened +// breadth first (as encoding/json and the schema generator do), remembering +// for each field the nearest API type that declares it. Embedded fields are +// listed too so the caller can validate their mapping. +func fields(t reflect.Type) []fieldInfo { + type item struct { + t reflect.Type + owner reflect.Type + } + var out []fieldInfo + seen := map[string]bool{} + queue := []item{{t, nil}} + for len(queue) > 0 { + it := queue[0] + queue = queue[1:] + owner := it.owner + if isAPIType(it.t) { + owner = it.t + } + for f := range it.t.Fields() { + if f.Anonymous { + out = append(out, fieldInfo{field: f}) + queue = append(queue, item{elem(f.Type), owner}) + continue + } + name := structtag.JSONTag(f.Tag.Get("json")).Name() + if name == "" || name == "-" || !f.IsExported() || seen[name] { + continue + } + seen[name] = true + out = append(out, fieldInfo{name: name, field: f, owner: owner}) + } + } + return out +} + +func elem(t reflect.Type) reflect.Type { + for { + switch t.Kind() { + case reflect.Pointer, reflect.Slice, reflect.Map: + t = t.Elem() + default: + return t + } + } +} + +const ( + mirrorPkgPrefix = "github.com/databricks/cli/libs/sdktypes/" + sdkPkgPrefix = "github.com/databricks/sdk-go/" + nativePkgPath = "github.com/databricks/sdk-go/core/types" +) + +// isAPIType reports whether t comes from the API (sdk-go mirrors, sdk-go +// enums aliased by the mirrors, hand-written API packages) or is a CLI-owned +// stand-in for an API type registered in roots. +func isAPIType(t reflect.Type) bool { + if t.Name() == "" { + return false + } + p := t.PkgPath() + if _, ok := roots()[t]; ok { + return true + } + return strings.HasPrefix(p, mirrorPkgPrefix) || strings.HasPrefix(p, sdkPkgPrefix) || p == "github.com/databricks/cli/libs/qualitymonitors" +} + +func isNative(t reflect.Type) bool { + return t.PkgPath() == nativePkgPath +} + +func typeName(t reflect.Type) string { + return t.PkgPath() + "." + t.Name() +} diff --git a/bundle/internal/sdkmeta/sdkmeta_test.go b/bundle/internal/sdkmeta/sdkmeta_test.go new file mode 100644 index 00000000000..d04acb9958e --- /dev/null +++ b/bundle/internal/sdkmeta/sdkmeta_test.go @@ -0,0 +1,74 @@ +package sdkmeta + +import ( + "reflect" + "slices" + "testing" + + "github.com/databricks/cli/bundle/config" + "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/internal/clijson" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +type testRoot struct { + Jobs map[string]*resources.Job `json:"jobs,omitempty"` + JobRuns map[string]*resources.JobRun `json:"job_runs,omitempty"` + Pipelines map[string]*resources.Pipeline `json:"pipelines,omitempty"` + Models map[string]*resources.MlflowModel `json:"models,omitempty"` + Experiments map[string]*resources.MlflowExperiment `json:"experiments,omitempty"` + ModelServingEndpoints map[string]*resources.ModelServingEndpoint `json:"model_serving_endpoints,omitempty"` + ModelServices map[string]*resources.ModelService `json:"model_services,omitempty"` + McpServices map[string]*resources.McpService `json:"mcp_services,omitempty"` + ModelProviderServices map[string]*resources.ModelProviderService `json:"model_provider_services,omitempty"` + RegisteredModels map[string]*resources.RegisteredModel `json:"registered_models,omitempty"` + QualityMonitors map[string]*resources.QualityMonitor `json:"quality_monitors,omitempty"` + Catalogs map[string]*resources.Catalog `json:"catalogs,omitempty"` + Schemas map[string]*resources.Schema `json:"schemas,omitempty"` + Volumes map[string]*resources.Volume `json:"volumes,omitempty"` + ExternalLocations map[string]*resources.ExternalLocation `json:"external_locations,omitempty"` + Clusters map[string]*resources.Cluster `json:"clusters,omitempty"` + Dashboards map[string]*resources.Dashboard `json:"dashboards,omitempty"` + GenieSpaces map[string]*resources.GenieSpace `json:"genie_spaces,omitempty"` + Apps map[string]*resources.App `json:"apps,omitempty"` + SecretScopes map[string]*resources.SecretScope `json:"secret_scopes,omitempty"` + Alerts map[string]*resources.Alert `json:"alerts,omitempty"` + SqlWarehouses map[string]*resources.SqlWarehouse `json:"sql_warehouses,omitempty"` + DatabaseInstances map[string]*resources.DatabaseInstance `json:"database_instances,omitempty"` + DatabaseCatalogs map[string]*resources.DatabaseCatalog `json:"database_catalogs,omitempty"` + SyncedDatabaseTables map[string]*resources.SyncedDatabaseTable `json:"synced_database_tables,omitempty"` + PostgresProjects map[string]*resources.PostgresProject `json:"postgres_projects,omitempty"` + PostgresBranches map[string]*resources.PostgresBranch `json:"postgres_branches,omitempty"` + PostgresEndpoints map[string]*resources.PostgresEndpoint `json:"postgres_endpoints,omitempty"` + PostgresCatalogs map[string]*resources.PostgresCatalog `json:"postgres_catalogs,omitempty"` + PostgresDatabases map[string]*resources.PostgresDatabase `json:"postgres_databases,omitempty"` + PostgresRoles map[string]*resources.PostgresRole `json:"postgres_roles,omitempty"` + PostgresSyncedTables map[string]*resources.PostgresSyncedTable `json:"postgres_synced_tables,omitempty"` + PostgresSnapshotSchedules map[string]*resources.PostgresSnapshotSchedule `json:"postgres_snapshot_schedules,omitempty"` + VectorSearchEndpoints map[string]*resources.VectorSearchEndpoint `json:"vector_search_endpoints,omitempty"` + VectorSearchIndexes map[string]*resources.VectorSearchIndex `json:"vector_search_indexes,omitempty"` + InstancePools map[string]*resources.InstancePool `json:"instance_pools,omitempty"` + Secrets map[string]*resources.Secret `json:"secrets,omitempty"` + ClusterPolicies map[string]*resources.ClusterPolicy `json:"cluster_policies,omitempty"` + Snapshots map[string]*resources.Snapshot `json:"internal_immutable_snapshots,omitempty" bundle:"internal"` +} + +func TestBuild(t *testing.T) { + doc, err := clijson.Parse("../../../.codegen/cli.json") + require.NoError(t, err) + m, err := Build(reflect.TypeFor[config.Root](), doc.Schemas) + require.NoError(t, err) + + var missing []string + for typ, name := range m.Types() { + if _, ok := nativeDefinitionNames[name]; ok { + continue + } + if _, ok := doc.Schemas[name]; !ok { + missing = append(missing, typeName(typ)+" -> "+name) + } + } + slices.Sort(missing) + assert.Empty(t, missing, "mapped to schemas not in cli.json") +} diff --git a/bundle/internal/validation/enum.go b/bundle/internal/validation/enum.go index df58193c898..359780661e1 100644 --- a/bundle/internal/validation/enum.go +++ b/bundle/internal/validation/enum.go @@ -14,6 +14,7 @@ import ( "text/template" "github.com/databricks/cli/bundle/config" + "github.com/databricks/cli/bundle/internal/sdkmeta" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/structs/structtag" "github.com/databricks/cli/libs/structs/structwalk" @@ -110,13 +111,41 @@ func getEnumValues(typ reflect.Type) ([]string, error) { } // extractEnumFields walks through a struct type and extracts enum field patterns -func extractEnumFields(typ reflect.Type) ([]EnumPatternInfo, error) { +func extractEnumFields(typ reflect.Type, meta *sdkmeta.Meta) ([]EnumPatternInfo, error) { fieldsByPattern := make(map[string][]string) + // Types of the visited nodes, to find the struct declaring a field. + types := map[string]reflect.Type{} + // cli.json schema of the API type at each visited node, if any. + schemas := map[string]string{} err := structwalk.WalkType(typ, func(path *structpath.PatternNode, fieldType reflect.Type, field *reflect.StructField) bool { if path == nil { + types[""] = typ return true } + // Embedded structs are visited with the path of the struct embedding + // them; keep the outermost type. + if _, ok := types[path.String()]; !ok { + types[path.String()] = fieldType + } + // Skip fields of API types that cli.json does not define, as the JSON + // schema does. Fields whose type sdk-go unified with another one are + // checked against the schema of the type they had before. + key, parentKey := path.String(), path.Parent().String() + schema, _ := meta.Name(fieldType) + if name, ok := path.StringKey(); ok { + if !meta.SchemaHasField(schemas[parentKey], name) { + return false + } + if ref, ok := sdkmeta.FieldRef(schemas[parentKey], name); ok { + schema = ref + } + } else { + schema = schemas[parentKey] + } + if _, ok := schemas[key]; !ok { + schemas[key] = schema + } // Do not generate enum validation code for fields that are internal or readonly. if field != nil { @@ -135,6 +164,8 @@ func extractEnumFields(typ reflect.Type) ([]EnumPatternInfo, error) { return true } + fieldsByPattern[path.String()] = enumValues + } else if enumValues, ok := apiEnumValues(meta, types, path, fieldType); ok { fieldsByPattern[path.String()] = enumValues } return true @@ -144,6 +175,41 @@ func extractEnumFields(typ reflect.Type) ([]EnumPatternInfo, error) { } // buildEnumPatternInfos converts the field map to EnumPatternInfo slice +// apiEnumValues returns the values of an API enum field from cli.json: either +// the field's type is an sdk-go enum, or the field is a plain string where the +// previous SDK had an enum (see sdkmeta.FieldRef). +func apiEnumValues(meta *sdkmeta.Meta, types map[string]reflect.Type, path *structpath.PatternNode, fieldType reflect.Type) ([]string, bool) { + for fieldType.Kind() == reflect.Pointer { + fieldType = fieldType.Elem() + } + if fieldType.Kind() != reflect.String { + return nil, false + } + // The previous SDK listed enum values alphabetically. + if values, ok := meta.Enum(fieldType); ok { + return slices.Sorted(slices.Values(values)), true + } + // Elements of a list of enums are matched through the list field. + fieldPath := path + if _, ok := path.StringKey(); !ok { + fieldPath = path.Parent() + } + name, ok := fieldPath.StringKey() + if !ok { + return nil, false + } + parent, ok := meta.Name(types[fieldPath.Parent().String()]) + if !ok { + return nil, false + } + ref, ok := sdkmeta.FieldRef(parent, name) + if !ok { + return nil, false + } + values, ok := meta.EnumOf(ref) + return slices.Sorted(slices.Values(values)), ok +} + func buildEnumPatternInfos(fieldsByPattern map[string][]string) []EnumPatternInfo { patterns := make([]EnumPatternInfo, 0, len(fieldsByPattern)) @@ -202,8 +268,8 @@ func sortGroupedPatternsEnum(groupedPatterns map[string][]EnumPatternInfo) [][]E } // enumFields returns grouped enum field patterns for validation -func enumFields() ([][]EnumPatternInfo, error) { - patterns, err := extractEnumFields(reflect.TypeFor[config.Root]()) +func enumFields(meta *sdkmeta.Meta) ([][]EnumPatternInfo, error) { + patterns, err := extractEnumFields(reflect.TypeFor[config.Root](), meta) if err != nil { return nil, err } @@ -213,8 +279,8 @@ func enumFields() ([][]EnumPatternInfo, error) { } // Generate creates a Go source file with enum field validation rules -func generateEnumFields(outPath string) error { - enumFields, err := enumFields() +func generateEnumFields(outPath string, meta *sdkmeta.Meta) error { + enumFields, err := enumFields(meta) if err != nil { return fmt.Errorf("failed to generate enum fields: %w", err) } diff --git a/bundle/internal/validation/generated/enum_fields.go b/bundle/internal/validation/generated/enum_fields.go index 42401ec6968..9d4be59dc1a 100644 --- a/bundle/internal/validation/generated/enum_fields.go +++ b/bundle/internal/validation/generated/enum_fields.go @@ -182,8 +182,6 @@ var EnumFields = map[string][]string{ "resources.model_serving_endpoints.*.ai_gateway.rate_limits[*].renewal_period": {"minute"}, "resources.model_serving_endpoints.*.config.served_entities[*].external_model.amazon_bedrock_config.bedrock_provider": {"ai21labs", "amazon", "anthropic", "cohere"}, "resources.model_serving_endpoints.*.config.served_entities[*].external_model.provider": {"ai21labs", "amazon-bedrock", "anthropic", "cohere", "custom", "databricks-model-serving", "google-cloud-vertex-ai", "openai", "palm"}, - "resources.model_serving_endpoints.*.config.served_entities[*].workload_type": {"CPU", "CPU_LARGE", "CPU_MEDIUM", "GPU_LARGE", "GPU_MEDIUM", "GPU_SMALL", "GPU_XLARGE", "GPU_XLARGE_8", "MULTIGPU_MEDIUM"}, - "resources.model_serving_endpoints.*.config.served_models[*].workload_type": {"CPU", "CPU_LARGE", "CPU_MEDIUM", "GPU_LARGE", "GPU_MEDIUM", "GPU_SMALL", "GPU_XLARGE", "GPU_XLARGE_8", "MULTIGPU_MEDIUM"}, "resources.model_serving_endpoints.*.permissions[*].level": {"CAN_MANAGE", "CAN_QUERY", "CAN_VIEW"}, "resources.model_serving_endpoints.*.rate_limits[*].key": {"endpoint", "user"}, "resources.model_serving_endpoints.*.rate_limits[*].renewal_period": {"minute"}, @@ -196,7 +194,6 @@ var EnumFields = map[string][]string{ "resources.pipelines.*.clusters[*].aws_attributes.ebs_volume_type": {"GENERAL_PURPOSE_SSD", "THROUGHPUT_OPTIMIZED_HDD"}, "resources.pipelines.*.clusters[*].azure_attributes.availability": {"ON_DEMAND_AZURE", "SPOT_AZURE", "SPOT_WITH_FALLBACK_AZURE"}, "resources.pipelines.*.clusters[*].gcp_attributes.availability": {"ON_DEMAND_GCP", "PREEMPTIBLE_GCP", "PREEMPTIBLE_WITH_FALLBACK_GCP"}, - "resources.pipelines.*.clusters[*].gcp_attributes.confidential_compute_type": {"CONFIDENTIAL_COMPUTE_TYPE_NONE", "SEV_SNP"}, "resources.pipelines.*.deployment.kind": {"BUNDLE"}, "resources.pipelines.*.ingestion_definition.connector_type": {"CDC", "QUERY_BASED"}, "resources.pipelines.*.ingestion_definition.full_refresh_window.days_of_week[*]": {"FRIDAY", "MONDAY", "SATURDAY", "SUNDAY", "THURSDAY", "TUESDAY", "WEDNESDAY"}, diff --git a/bundle/internal/validation/generated/required_fields.go b/bundle/internal/validation/generated/required_fields.go index 9488299bba0..041321acd67 100644 --- a/bundle/internal/validation/generated/required_fields.go +++ b/bundle/internal/validation/generated/required_fields.go @@ -272,15 +272,8 @@ var RequiredFields = map[string][]string{ "resources.pipelines.*.clusters[*].autoscale": {"max_workers", "min_workers"}, "resources.pipelines.*.clusters[*].cluster_log_conf.dbfs": {"destination"}, - "resources.pipelines.*.clusters[*].cluster_log_conf.s3": {"destination"}, - "resources.pipelines.*.clusters[*].cluster_log_conf.volumes": {"destination"}, - "resources.pipelines.*.clusters[*].init_scripts[*].abfss": {"destination"}, "resources.pipelines.*.clusters[*].init_scripts[*].dbfs": {"destination"}, - "resources.pipelines.*.clusters[*].init_scripts[*].file": {"destination"}, - "resources.pipelines.*.clusters[*].init_scripts[*].gcs": {"destination"}, "resources.pipelines.*.clusters[*].init_scripts[*].s3": {"destination"}, - "resources.pipelines.*.clusters[*].init_scripts[*].volumes": {"destination"}, - "resources.pipelines.*.clusters[*].init_scripts[*].workspace": {"destination"}, "resources.pipelines.*.deployment": {"kind"}, "resources.pipelines.*.gateway_definition": {"connection_name", "gateway_storage_catalog", "gateway_storage_schema"}, "resources.pipelines.*.ingestion_definition.data_staging_options": {"catalog_name", "schema_name"}, diff --git a/bundle/internal/validation/main.go b/bundle/internal/validation/main.go index ce07aede5da..a96a790512d 100644 --- a/bundle/internal/validation/main.go +++ b/bundle/internal/validation/main.go @@ -2,16 +2,30 @@ package main import ( "log" + "reflect" + + "github.com/databricks/cli/bundle/config" + "github.com/databricks/cli/bundle/internal/sdkmeta" + "github.com/databricks/cli/internal/clijson" ) // This package is meant to be run from the root of the CLI repo. func main() { - err := generateRequiredFields("bundle/internal/validation/generated") + doc, err := clijson.Parse(".codegen/cli.json") + if err != nil { + log.Fatalf("Error reading cli.json: %v", err) + } + meta, err := sdkmeta.Build(reflect.TypeFor[config.Root](), doc.Schemas) + if err != nil { + log.Fatalf("Error mapping API types: %v", err) + } + + err = generateRequiredFields("bundle/internal/validation/generated", meta) if err != nil { log.Fatalf("Error generating required fields: %v", err) } - err = generateEnumFields("bundle/internal/validation/generated") + err = generateEnumFields("bundle/internal/validation/generated", meta) if err != nil { log.Fatalf("Error generating enum fields: %v", err) } diff --git a/bundle/internal/validation/required.go b/bundle/internal/validation/required.go index 045ac32257a..4a9150546c7 100644 --- a/bundle/internal/validation/required.go +++ b/bundle/internal/validation/required.go @@ -14,6 +14,7 @@ import ( "text/template" "github.com/databricks/cli/bundle/config" + "github.com/databricks/cli/bundle/internal/sdkmeta" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/structs/structtag" "github.com/databricks/cli/libs/structs/structwalk" @@ -46,11 +47,47 @@ func formatSliceToString(values []string) string { } // extractRequiredFields walks through a struct type and extracts required field patterns -func extractRequiredFields(typ reflect.Type) ([]RequiredPatternInfo, error) { +func extractRequiredFields(typ reflect.Type, meta *sdkmeta.Meta) ([]RequiredPatternInfo, error) { fieldsByPattern := make(map[string][]string) - - err := structwalk.WalkType(typ, func(path *structpath.PatternNode, _ reflect.Type, field *reflect.StructField) bool { - if path == nil || field == nil { + // Required fields of the struct at each visited node. + required := map[string][]string{} + // cli.json schema of the API type at each visited node, if any. + schemas := map[string]string{} + types := map[string]reflect.Type{} + + err := structwalk.WalkType(typ, func(path *structpath.PatternNode, fieldType reflect.Type, field *reflect.StructField) bool { + if path == nil { + required[""] = meta.Required(typ) + return true + } + key, parentKey := path.String(), path.Parent().String() + // Embedded structs are visited with the path of the struct embedding + // them; keep the outermost type. + if _, ok := types[key]; !ok { + types[key] = fieldType + } + // Skip fields of API types that cli.json does not define, as the JSON + // schema does. + if name, ok := path.StringKey(); ok && !meta.SchemaHasField(schemas[parentKey], name) { + return false + } + // Fields whose type sdk-go unified with another one keep the required + // fields of the type they had before (see sdkmeta.FieldRef). + schema, _ := meta.Name(fieldType) + if name, ok := path.StringKey(); ok { + if ref, ok := sdkmeta.FieldRef(schemas[parentKey], name); ok { + schema = ref + } + } else { + schema = schemas[parentKey] + } + schemas[key] = schema + if ref, _ := meta.Name(fieldType); schema != "" && schema != ref { + required[key] = sdkmeta.RequiredFields(schema) + } else { + required[key] = meta.Required(fieldType) + } + if field == nil { return true } @@ -68,24 +105,66 @@ func extractRequiredFields(typ reflect.Type) ([]RequiredPatternInfo, error) { } // The "omitempty" tag indicates the field is optional in bundle config. - jsonTag := structtag.JSONTag(rawTag) - if jsonTag.OmitEmpty() { + fieldName, ok := path.StringKey() + if !ok { return true } + parentPath := path.Parent().String() - fieldName, ok := path.StringKey() - if !ok { + // API types mark every field omitempty; their required fields come + // from sdkmeta. + jsonTag := structtag.JSONTag(rawTag) + if jsonTag.OmitEmpty() && !slices.Contains(required[parentPath], fieldName) { return true } - parentPath := path.Parent().String() fieldsByPattern[parentPath] = append(fieldsByPattern[parentPath], fieldName) return true }) + for parentPath, fields := range fieldsByPattern { + order := legacyFieldOrder(meta, types[parentPath]) + if parentPath == "" { + order = legacyFieldOrder(meta, typ) + } + slices.SortStableFunc(fields, func(a, b string) int { return order[a] - order[b] }) + } return buildPatternInfos(fieldsByPattern), err } +// legacyFieldOrder returns the position of each field of t in the order the +// walk visited them with the previous SDK types: embedded structs are expanded +// in place, and the fields of API types, which the previous SDK declared +// alphabetically, are sorted by name. +func legacyFieldOrder(meta *sdkmeta.Meta, t reflect.Type) map[string]int { + order := map[string]int{} + var visit func(t reflect.Type) + visit = func(t reflect.Type) { + for t.Kind() == reflect.Pointer || t.Kind() == reflect.Slice || t.Kind() == reflect.Map { + t = t.Elem() + } + if t.Kind() != reflect.Struct { + return + } + fields := slices.Collect(t.Fields()) + if _, ok := meta.Name(t); ok { + slices.SortStableFunc(fields, func(a, b reflect.StructField) int { return strings.Compare(a.Name, b.Name) }) + } + for _, f := range fields { + if f.Anonymous { + visit(f.Type) + continue + } + name := structtag.JSONTag(f.Tag.Get("json")).Name() + if _, ok := order[name]; !ok { + order[name] = len(order) + } + } + } + visit(t) + return order +} + // buildPatternInfos converts the field map to PatternInfo slice func buildPatternInfos(fieldsByPattern map[string][]string) []RequiredPatternInfo { patterns := make([]RequiredPatternInfo, 0, len(fieldsByPattern)) @@ -158,8 +237,8 @@ func sortGroupedPatterns(groupedPatterns map[string][]RequiredPatternInfo) [][]R } // RequiredFields returns grouped required field patterns for validation -func requiredFields() ([][]RequiredPatternInfo, error) { - patterns, err := extractRequiredFields(reflect.TypeFor[config.Root]()) +func requiredFields(meta *sdkmeta.Meta) ([][]RequiredPatternInfo, error) { + patterns, err := extractRequiredFields(reflect.TypeFor[config.Root](), meta) if err != nil { return nil, err } @@ -169,8 +248,8 @@ func requiredFields() ([][]RequiredPatternInfo, error) { } // Generate creates a Go source file with required field validation rules -func generateRequiredFields(outPath string) error { - requiredFields, err := requiredFields() +func generateRequiredFields(outPath string, meta *sdkmeta.Meta) error { + requiredFields, err := requiredFields(meta) if err != nil { return fmt.Errorf("failed to generate required fields: %w", err) } diff --git a/bundle/libraries/expand_glob_references_test.go b/bundle/libraries/expand_glob_references_test.go index 331fbf2e7cb..d0f408132b6 100644 --- a/bundle/libraries/expand_glob_references_test.go +++ b/bundle/libraries/expand_glob_references_test.go @@ -4,6 +4,9 @@ import ( "path/filepath" "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" @@ -11,9 +14,6 @@ import ( "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -32,27 +32,27 @@ func TestGlobReferencesExpandedForTaskLibraries(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "task", - Libraries: []compute.Library{ + TaskKey: new("task"), + Libraries: []jobs.Library{ { - Whl: "whl/*.whl", + Whl: new("whl/*.whl"), }, { - Whl: "/Workspace/path/to/whl/my.whl", + Whl: new("/Workspace/path/to/whl/my.whl"), }, { - Jar: "./jar/*.jar", + Jar: new("./jar/*.jar"), }, { - Egg: "egg/*.egg", + Egg: new("egg/*.egg"), }, { - Jar: "/Workspace/path/to/jar/*.jar", + Jar: new("/Workspace/path/to/jar/*.jar"), }, { - Whl: "/some/full/path/to/whl/*.whl", + Whl: new("/some/full/path/to/whl/*.whl"), }, }, }, @@ -71,30 +71,30 @@ func TestGlobReferencesExpandedForTaskLibraries(t *testing.T) { job := b.Config.Resources.Jobs["job"] task := job.Tasks[0] - require.Equal(t, []compute.Library{ + require.Equal(t, []jobs.Library{ { - Whl: filepath.Join("whl", "my1.whl"), + Whl: new(filepath.Join("whl", "my1.whl")), }, { - Whl: filepath.Join("whl", "my2.whl"), + Whl: new(filepath.Join("whl", "my2.whl")), }, { - Whl: "/Workspace/path/to/whl/my.whl", + Whl: new("/Workspace/path/to/whl/my.whl"), }, { - Jar: filepath.Join("jar", "my1.jar"), + Jar: new(filepath.Join("jar", "my1.jar")), }, { - Jar: filepath.Join("jar", "my2.jar"), + Jar: new(filepath.Join("jar", "my2.jar")), }, { - Egg: "egg/*.egg", + Egg: new("egg/*.egg"), }, { - Jar: "/Workspace/path/to/jar/*.jar", + Jar: new("/Workspace/path/to/jar/*.jar"), }, { - Whl: "/some/full/path/to/whl/*.whl", + Whl: new("/some/full/path/to/whl/*.whl"), }, }, task.Libraries) } @@ -113,29 +113,29 @@ func TestGlobReferencesExpandedForForeachTaskLibraries(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "task", + TaskKey: new("task"), ForEachTask: &jobs.ForEachTask{ - Task: jobs.Task{ - Libraries: []compute.Library{ + Task: &jobs.TaskSettings{ + Libraries: []jobs.Library{ { - Whl: "whl/*.whl", + Whl: new("whl/*.whl"), }, { - Whl: "/Workspace/path/to/whl/my.whl", + Whl: new("/Workspace/path/to/whl/my.whl"), }, { - Jar: "./jar/*.jar", + Jar: new("./jar/*.jar"), }, { - Egg: "egg/*.egg", + Egg: new("egg/*.egg"), }, { - Jar: "/Workspace/path/to/jar/*.jar", + Jar: new("/Workspace/path/to/jar/*.jar"), }, { - Whl: "/some/full/path/to/whl/*.whl", + Whl: new("/some/full/path/to/whl/*.whl"), }, }, }, @@ -156,30 +156,30 @@ func TestGlobReferencesExpandedForForeachTaskLibraries(t *testing.T) { job := b.Config.Resources.Jobs["job"] task := job.Tasks[0].ForEachTask.Task - require.Equal(t, []compute.Library{ + require.Equal(t, []jobs.Library{ { - Whl: filepath.Join("whl", "my1.whl"), + Whl: new(filepath.Join("whl", "my1.whl")), }, { - Whl: filepath.Join("whl", "my2.whl"), + Whl: new(filepath.Join("whl", "my2.whl")), }, { - Whl: "/Workspace/path/to/whl/my.whl", + Whl: new("/Workspace/path/to/whl/my.whl"), }, { - Jar: filepath.Join("jar", "my1.jar"), + Jar: new(filepath.Join("jar", "my1.jar")), }, { - Jar: filepath.Join("jar", "my2.jar"), + Jar: new(filepath.Join("jar", "my2.jar")), }, { - Egg: "egg/*.egg", + Egg: new("egg/*.egg"), }, { - Jar: "/Workspace/path/to/jar/*.jar", + Jar: new("/Workspace/path/to/jar/*.jar"), }, { - Whl: "/some/full/path/to/whl/*.whl", + Whl: new("/some/full/path/to/whl/*.whl"), }, }, task.Libraries) } @@ -198,16 +198,16 @@ func TestGlobReferencesExpandedForEnvironmentsDeps(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "task", - EnvironmentKey: "env", + TaskKey: new("task"), + EnvironmentKey: new("env"), }, }, Environments: []jobs.JobEnvironment{ { - EnvironmentKey: "env", - Spec: &compute.Environment{ + EnvironmentKey: new("env"), + Spec: &jobs.Environment{ Dependencies: []string{ "./whl/*.whl", "/Workspace/path/to/whl/my.whl", @@ -251,11 +251,11 @@ func TestExpandGlobReferencesPreservesLocations(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "task", - Libraries: []compute.Library{ - {Whl: "/Workspace/remote.whl"}, + TaskKey: new("task"), + Libraries: []jobs.Library{ + {Whl: new("/Workspace/remote.whl")}, }, }, }, @@ -264,7 +264,7 @@ func TestExpandGlobReferencesPreservesLocations(t *testing.T) { }, Pipelines: map[string]*resources.Pipeline{ "pipeline": { - CreatePipeline: pipelines.CreatePipeline{ + CreatePipelineRequest: pipelines.CreatePipelineRequest{ Environment: &pipelines.PipelinesEnvironment{ Dependencies: []string{ "--editable /Workspace/foo", diff --git a/bundle/libraries/filer_test.go b/bundle/libraries/filer_test.go index f3de3e41e73..8947de7b0d3 100644 --- a/bundle/libraries/filer_test.go +++ b/bundle/libraries/filer_test.go @@ -5,9 +5,8 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" + "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/filer" - databrickscfg "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/experimental/mocks" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -21,9 +20,8 @@ func TestGetFilerForLibrariesValidWsfs(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - m.WorkspaceClient.Config = &databrickscfg.Config{} - b.SetWorkpaceClient(m.WorkspaceClient) + w, _ := bundletest.NewClients(t) + b.SetWorkpaceClient(w) client, uploadPath, diags := GetFilerForLibraries(t.Context(), b) require.NoError(t, diags.Error()) @@ -41,9 +39,8 @@ func TestGetFilerForLibrariesCleanupValidWsfs(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - m.WorkspaceClient.Config = &databrickscfg.Config{} - b.SetWorkpaceClient(m.WorkspaceClient) + w, _ := bundletest.NewClients(t) + b.SetWorkpaceClient(w) client, uploadPath, diags := GetFilerForLibrariesCleanup(t.Context(), b) require.NoError(t, diags.Error()) @@ -61,9 +58,8 @@ func TestGetFilerForLibrariesValidUcVolume(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - m.WorkspaceClient.Config = &databrickscfg.Config{} - b.SetWorkpaceClient(m.WorkspaceClient) + w, _ := bundletest.NewClients(t) + b.SetWorkpaceClient(w) client, uploadPath, diags := GetFilerForLibraries(t.Context(), b) require.NoError(t, diags.Error()) @@ -81,9 +77,8 @@ func TestGetFilerForLibrariesCleanupValidUcVolume(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - m.WorkspaceClient.Config = &databrickscfg.Config{} - b.SetWorkpaceClient(m.WorkspaceClient) + w, _ := bundletest.NewClients(t) + b.SetWorkpaceClient(w) client, uploadPath, diags := GetFilerForLibrariesCleanup(t.Context(), b) require.NoError(t, diags.Error()) @@ -99,9 +94,8 @@ func TestGetFilerForLibrariesRemotePathNotSet(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - m.WorkspaceClient.Config = &databrickscfg.Config{} - b.SetWorkpaceClient(m.WorkspaceClient) + w, _ := bundletest.NewClients(t) + b.SetWorkpaceClient(w) _, _, diags := GetFilerForLibraries(t.Context(), b) require.EqualError(t, diags.Error(), "remote artifact path not configured") diff --git a/bundle/libraries/helpers.go b/bundle/libraries/helpers.go index 5a1a9511c2d..9ba11da7ab6 100644 --- a/bundle/libraries/helpers.go +++ b/bundle/libraries/helpers.go @@ -3,21 +3,22 @@ package libraries import ( "errors" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" ) -func libraryPath(library *compute.Library) (string, error) { - if library.Whl != "" { - return library.Whl, nil +func libraryPath(library *jobs.Library) (string, error) { + if whl := utils.Deref(library.Whl); whl != "" { + return whl, nil } - if library.Jar != "" { - return library.Jar, nil + if jar := utils.Deref(library.Jar); jar != "" { + return jar, nil } - if library.Egg != "" { - return library.Egg, nil + if egg := utils.Deref(library.Egg); egg != "" { + return egg, nil } - if library.Requirements != "" { - return library.Requirements, nil + if requirements := utils.Deref(library.Requirements); requirements != "" { + return requirements, nil } return "", errors.New("not supported library type") diff --git a/bundle/libraries/helpers_test.go b/bundle/libraries/helpers_test.go index ac4993c6df1..d95d62ce60d 100644 --- a/bundle/libraries/helpers_test.go +++ b/bundle/libraries/helpers_test.go @@ -3,34 +3,35 @@ package libraries import ( "testing" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/stretchr/testify/assert" ) func TestLibraryPath(t *testing.T) { path := "/some/path" - p, err := libraryPath(&compute.Library{Whl: path}) + p, err := libraryPath(&jobs.Library{Whl: new(path)}) assert.Equal(t, path, p) assert.NoError(t, err) - p, err = libraryPath(&compute.Library{Jar: path}) + p, err = libraryPath(&jobs.Library{Jar: new(path)}) assert.Equal(t, path, p) assert.NoError(t, err) - p, err = libraryPath(&compute.Library{Egg: path}) + p, err = libraryPath(&jobs.Library{Egg: new(path)}) assert.Equal(t, path, p) assert.NoError(t, err) - p, err = libraryPath(&compute.Library{Requirements: path}) + p, err = libraryPath(&jobs.Library{Requirements: new(path)}) assert.Equal(t, path, p) assert.NoError(t, err) - p, err = libraryPath(&compute.Library{}) + p, err = libraryPath(&jobs.Library{}) assert.Empty(t, p) assert.Error(t, err) - p, err = libraryPath(&compute.Library{Pypi: &compute.PythonPyPiLibrary{Package: "pypipackage"}}) + p, err = libraryPath(&jobs.Library{Pypi: &jobs.PythonPyPiLibrary{Package: new("pypipackage")}}) assert.Empty(t, p) assert.Error(t, err) } diff --git a/bundle/libraries/libraries.go b/bundle/libraries/libraries.go index ba7d4272a65..0dceefc2fb7 100644 --- a/bundle/libraries/libraries.go +++ b/bundle/libraries/libraries.go @@ -4,12 +4,12 @@ import ( "slices" "github.com/databricks/cli/bundle" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" ) -func findAllTasks(b *bundle.Bundle) map[string]([]jobs.Task) { +func findAllTasks(b *bundle.Bundle) map[string]([]jobs.TaskSettings) { r := b.Config.Resources - result := make(map[string]([]jobs.Task), 0) + result := make(map[string]([]jobs.TaskSettings), 0) for k := range b.Config.Resources.Jobs { result[k] = append(result[k], r.Jobs[k].Tasks...) } @@ -44,11 +44,11 @@ func isEnvsWithLocalLibraries(envs []jobs.JobEnvironment) bool { return false } -func FindTasksWithLocalLibraries(b *bundle.Bundle) []jobs.Task { +func FindTasksWithLocalLibraries(b *bundle.Bundle) []jobs.TaskSettings { tasks := findAllTasks(b) envs := FindAllEnvironments(b) - var allTasks []jobs.Task + var allTasks []jobs.TaskSettings for k, jobTasks := range tasks { for i := range jobTasks { task := jobTasks[i] @@ -65,7 +65,7 @@ func FindTasksWithLocalLibraries(b *bundle.Bundle) []jobs.Task { return allTasks } -func isTaskWithLocalLibraries(task jobs.Task) bool { +func isTaskWithLocalLibraries(task jobs.TaskSettings) bool { for _, l := range task.Libraries { p, err := libraryPath(&l) // If there's an error, skip the library because it's not of supported type @@ -80,7 +80,7 @@ func isTaskWithLocalLibraries(task jobs.Task) bool { return false } -func IsTaskWithWorkspaceLibraries(task jobs.Task) bool { +func IsTaskWithWorkspaceLibraries(task jobs.TaskSettings) bool { for _, l := range task.Libraries { if IsWorkspaceLibrary(&l) { return true diff --git a/bundle/libraries/match_test.go b/bundle/libraries/match_test.go index d047785b332..d6da5b9dbea 100644 --- a/bundle/libraries/match_test.go +++ b/bundle/libraries/match_test.go @@ -3,12 +3,12 @@ package libraries import ( "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/internal/testutil" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/require" ) @@ -25,7 +25,7 @@ func TestValidateEnvironments(t *testing.T) { JobSettings: jobs.JobSettings{ Environments: []jobs.JobEnvironment{ { - Spec: &compute.Environment{ + Spec: &jobs.Environment{ Dependencies: []string{ "./wheel.whl", "simplejson", @@ -57,7 +57,7 @@ func TestValidateEnvironmentsNoFile(t *testing.T) { JobSettings: jobs.JobSettings{ Environments: []jobs.JobEnvironment{ { - Spec: &compute.Environment{ + Spec: &jobs.Environment{ Dependencies: []string{ "./wheel.whl", "simplejson", @@ -89,14 +89,14 @@ func TestValidateTaskLibraries(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - Libraries: []compute.Library{ + Libraries: []jobs.Library{ { - Whl: "./wheel.whl", + Whl: new("./wheel.whl"), }, { - Whl: "/Workspace/Users/foo@bar.test/artifacts/test.whl", + Whl: new("/Workspace/Users/foo@bar.test/artifacts/test.whl"), }, }, }, @@ -122,14 +122,14 @@ func TestValidateTaskLibrariesNoFile(t *testing.T) { Jobs: map[string]*resources.Job{ "job": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - Libraries: []compute.Library{ + Libraries: []jobs.Library{ { - Whl: "./wheel.whl", + Whl: new("./wheel.whl"), }, { - Whl: "/Workspace/Users/foo@bar.test/artifacts/test.whl", + Whl: new("/Workspace/Users/foo@bar.test/artifacts/test.whl"), }, }, }, diff --git a/bundle/libraries/path.go b/bundle/libraries/path.go index 418d9ca73cb..7e4977cfe8c 100644 --- a/bundle/libraries/path.go +++ b/bundle/libraries/path.go @@ -3,7 +3,7 @@ package libraries import ( "strings" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" ) // IsWorkspacePath returns true if the specified path indicates that @@ -28,7 +28,7 @@ func IsWorkspacePath(path string) bool { } // IsWorkspaceLibrary returns true if the specified library refers to a workspace path. -func IsWorkspaceLibrary(library *compute.Library) bool { +func IsWorkspaceLibrary(library *jobs.Library) bool { path, err := libraryPath(library) if err != nil { return false diff --git a/bundle/libraries/path_test.go b/bundle/libraries/path_test.go index 90fe187a257..1514e49e3db 100644 --- a/bundle/libraries/path_test.go +++ b/bundle/libraries/path_test.go @@ -3,7 +3,8 @@ package libraries import ( "testing" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/stretchr/testify/assert" ) @@ -21,15 +22,15 @@ func TestIsWorkspacePath(t *testing.T) { func TestIsWorkspaceLibrary(t *testing.T) { // Workspace paths. - assert.True(t, IsWorkspaceLibrary(&compute.Library{Whl: "/Workspace/path/to/file.whl"})) + assert.True(t, IsWorkspaceLibrary(&jobs.Library{Whl: new("/Workspace/path/to/file.whl")})) // Non-workspace paths. - assert.False(t, IsWorkspaceLibrary(&compute.Library{Whl: "./file.whl"})) - assert.False(t, IsWorkspaceLibrary(&compute.Library{Jar: "../target/some.jar"})) - assert.False(t, IsWorkspaceLibrary(&compute.Library{Jar: "s3:/bucket/path/some.jar"})) + assert.False(t, IsWorkspaceLibrary(&jobs.Library{Whl: new("./file.whl")})) + assert.False(t, IsWorkspaceLibrary(&jobs.Library{Jar: new("../target/some.jar")})) + assert.False(t, IsWorkspaceLibrary(&jobs.Library{Jar: new("s3:/bucket/path/some.jar")})) // Empty. - assert.False(t, IsWorkspaceLibrary(&compute.Library{})) + assert.False(t, IsWorkspaceLibrary(&jobs.Library{})) } func TestIsVolumesPath(t *testing.T) { diff --git a/bundle/libraries/switch_to_patched_wheels.go b/bundle/libraries/switch_to_patched_wheels.go index 3c5ff184a97..848c7dd060d 100644 --- a/bundle/libraries/switch_to_patched_wheels.go +++ b/bundle/libraries/switch_to_patched_wheels.go @@ -6,6 +6,8 @@ import ( "path/filepath" "slices" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/libs/diag" @@ -32,12 +34,12 @@ func (c switchToPatchedWheels) Apply(ctx context.Context, b *bundle.Bundle) diag for taskInd, task := range job.Tasks { // Update resources.jobs.*.task[*].libraries[*].whl for libInd, lib := range task.Libraries { - repl := replacements[lib.Whl] + repl := replacements[utils.Deref(lib.Whl)] if repl != "" { - log.Debugf(ctx, "Updating resources.jobs.%s.task[%d].libraries[%d].whl from %s to %s", jobName, taskInd, libInd, lib.Whl, repl) - job.Tasks[taskInd].Libraries[libInd].Whl = repl + log.Debugf(ctx, "Updating resources.jobs.%s.task[%d].libraries[%d].whl from %s to %s", jobName, taskInd, libInd, utils.Deref(lib.Whl), repl) + job.Tasks[taskInd].Libraries[libInd].Whl = new(repl) } else { - log.Debugf(ctx, "Not updating resources.jobs.%s.task[%d].libraries[%d].whl from %s. Available replacements: %v", jobName, taskInd, libInd, lib.Whl, slices.Sorted(maps.Keys(replacements))) + log.Debugf(ctx, "Not updating resources.jobs.%s.task[%d].libraries[%d].whl from %s. Available replacements: %v", jobName, taskInd, libInd, utils.Deref(lib.Whl), slices.Sorted(maps.Keys(replacements))) } } @@ -46,12 +48,12 @@ func (c switchToPatchedWheels) Apply(ctx context.Context, b *bundle.Bundle) diag foreachptr := task.ForEachTask if foreachptr != nil { for libInd, lib := range foreachptr.Task.Libraries { - repl := replacements[lib.Whl] + repl := replacements[utils.Deref(lib.Whl)] if repl != "" { - log.Debugf(ctx, "Updating resources.jobs.%s.task[%d].for_each_task.task.libraries[%d].whl from %s to %s", jobName, taskInd, libInd, lib.Whl, repl) - foreachptr.Task.Libraries[libInd].Whl = repl + log.Debugf(ctx, "Updating resources.jobs.%s.task[%d].for_each_task.task.libraries[%d].whl from %s to %s", jobName, taskInd, libInd, utils.Deref(lib.Whl), repl) + foreachptr.Task.Libraries[libInd].Whl = new(repl) } else { - log.Debugf(ctx, "Not updating resources.jobs.%s.task[%d].for_each_task.task.libraries[%d].whl from %s. Available replacements: %v", jobName, taskInd, libInd, lib.Whl, slices.Sorted(maps.Keys(replacements))) + log.Debugf(ctx, "Not updating resources.jobs.%s.task[%d].for_each_task.task.libraries[%d].whl from %s. Available replacements: %v", jobName, taskInd, libInd, utils.Deref(lib.Whl), slices.Sorted(maps.Keys(replacements))) } } } @@ -85,12 +87,12 @@ func (c switchToPatchedWheels) Apply(ctx context.Context, b *bundle.Bundle) diag continue } for libInd, lib := range clusterRef.Libraries { - repl := replacements[lib.Whl] + repl := replacements[utils.Deref(lib.Whl)] if repl != "" { - log.Debugf(ctx, "Updating resources.clusters.%s.libraries[%d].whl from %s to %s", clusterName, libInd, lib.Whl, repl) - clusterRef.Libraries[libInd].Whl = repl + log.Debugf(ctx, "Updating resources.clusters.%s.libraries[%d].whl from %s to %s", clusterName, libInd, utils.Deref(lib.Whl), repl) + clusterRef.Libraries[libInd].Whl = new(repl) } else { - log.Debugf(ctx, "Not updating resources.clusters.%s.libraries[%d].whl from %s. Available replacements: %v", clusterName, libInd, lib.Whl, slices.Sorted(maps.Keys(replacements))) + log.Debugf(ctx, "Not updating resources.clusters.%s.libraries[%d].whl from %s. Available replacements: %v", clusterName, libInd, utils.Deref(lib.Whl), slices.Sorted(maps.Keys(replacements))) } } } diff --git a/bundle/metrics/track_used_compute.go b/bundle/metrics/track_used_compute.go index 1f3bf051dc0..abdc78f9f6a 100644 --- a/bundle/metrics/track_used_compute.go +++ b/bundle/metrics/track_used_compute.go @@ -3,6 +3,8 @@ package metrics import ( "context" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/diag" ) @@ -23,19 +25,19 @@ func (c *trackUsedCompute) Apply(ctx context.Context, b *bundle.Bundle) diag.Dia for _, job := range b.Config.Resources.Jobs { for _, task := range job.Tasks { // If the environment_key is set - then serverless compute is used - if task.EnvironmentKey != "" { + if utils.Deref(task.EnvironmentKey) != "" { hasServerlessCompute = true continue } // If the new_cluster or job_cluster_key is set - then classic job compute is used - if task.NewCluster != nil || task.JobClusterKey != "" { + if task.NewCluster != nil || utils.Deref(task.JobClusterKey) != "" { hasClassicJobCompute = true continue } // If existing_cluster_id is set - then classic interactive compute is used - if task.ExistingClusterId != "" { + if utils.Deref(task.ExistingClusterId) != "" { hasClassicInteractiveCompute = true continue } diff --git a/bundle/permissions/folder_acl.go b/bundle/permissions/folder_acl.go index 6145608a694..3681ca657bf 100644 --- a/bundle/permissions/folder_acl.go +++ b/bundle/permissions/folder_acl.go @@ -2,15 +2,15 @@ package permissions import ( "context" - "errors" "fmt" "path" "strconv" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/workspaceapi" ) // adminsGroup is the workspace admins group. Its members can write to any @@ -35,13 +35,13 @@ type FolderACL struct { // ResolveFolderACL reads the ACL that applies to folderPath. When folderPath does // not exist, it walks up to the closest existing ancestor, since a folder created // under it will inherit that ancestor's permissions. -func ResolveFolderACL(ctx context.Context, w workspace.WorkspaceInterface, folderPath string) (*FolderACL, error) { +func ResolveFolderACL(ctx context.Context, w *workspaceapi.Client, folderPath string) (*FolderACL, error) { obj, err := closestExistingObject(ctx, w, folderPath) if err != nil { return nil, err } - objPermissions, err := w.GetPermissions(ctx, workspace.GetWorkspaceObjectPermissionsRequest{ + objPermissions, err := w.GetPermissions(ctx, workspaceapi.GetWorkspaceObjectPermissionsRequest{ WorkspaceObjectId: strconv.FormatInt(obj.ObjectId, 10), WorkspaceObjectType: "directories", }) @@ -87,10 +87,10 @@ const ( // "does not have Manage permissions" otherwise), so a 403 means the user cannot // manage, and therefore cannot write to, the folder. // See https://docs.databricks.com/aws/en/security/auth/access-control/ -func CheckWritable(ctx context.Context, w workspace.WorkspaceInterface, folderPath string, user *iam.User) Writability { +func CheckWritable(ctx context.Context, w *workspaceapi.Client, folderPath string, user *scim.User) Writability { acl, err := ResolveFolderACL(ctx, w, folderPath) if err != nil { - if errors.Is(err, apierr.ErrPermissionDenied) { + if apierrs.Is(err, apierrs.ErrPermissionDenied) { return WritabilityNotWritable } return WritabilityUnknown @@ -110,8 +110,9 @@ func CheckWritable(ctx context.Context, w workspace.WorkspaceInterface, folderPa // it assumes write access when the user is a workspace admin (admins bypass the // folder ACL) or when their group membership is not known here, because // concluding "cannot write" in those cases would be a false alarm. -func (f *FolderACL) CanWrite(user *iam.User) bool { +func (f *FolderACL) CanWrite(user *scim.User) bool { groups := userGroupNames(user) + userName := utils.Deref(user.UserName) if groups[adminsGroup] { return true } @@ -121,9 +122,9 @@ func (f *FolderACL) CanWrite(user *iam.User) bool { continue } switch { - case p.UserName != "" && p.UserName == user.UserName: + case p.UserName != "" && p.UserName == userName: return true - case p.ServicePrincipalName != "" && p.ServicePrincipalName == user.UserName: + case p.ServicePrincipalName != "" && p.ServicePrincipalName == userName: return true case p.GroupName != "" && groups[p.GroupName]: return true @@ -140,11 +141,11 @@ func isWriteLevel(level string) bool { } // userGroupNames returns the set of group display names the user belongs to. -func userGroupNames(user *iam.User) map[string]bool { +func userGroupNames(user *scim.User) map[string]bool { groups := make(map[string]bool, len(user.Groups)) for _, g := range user.Groups { - if g.Display != "" { - groups[g.Display] = true + if display := utils.Deref(g.Display); display != "" { + groups[display] = true } } return groups @@ -153,14 +154,14 @@ func userGroupNames(user *iam.User) map[string]bool { // closestExistingObject returns the object at folderPath, or the closest existing // ancestor when folderPath does not exist. A not-yet-created folder inherits the // permissions of its closest existing ancestor. -func closestExistingObject(ctx context.Context, w workspace.WorkspaceInterface, folderPath string) (*workspace.ObjectInfo, error) { +func closestExistingObject(ctx context.Context, w *workspaceapi.Client, folderPath string) (*workspaceapi.ObjectInfo, error) { for { obj, err := w.GetStatusByPath(ctx, folderPath) if err == nil { return obj, nil } - if !apierr.IsMissing(err) { + if !apierrs.IsMissing(err) { return nil, err } diff --git a/bundle/permissions/folder_acl_test.go b/bundle/permissions/folder_acl_test.go index 45de01063ab..ab91ee91822 100644 --- a/bundle/permissions/folder_acl_test.go +++ b/bundle/permissions/folder_acl_test.go @@ -3,24 +3,24 @@ package permissions import ( "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + + "github.com/databricks/cli/bundle/internal/bundletest" + "github.com/databricks/cli/libs/testserver" + "github.com/databricks/cli/libs/workspaceapi" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) -func user(name string, groups ...string) *iam.User { - u := &iam.User{UserName: name} +func user(name string, groups ...string) *scim.User { + u := &scim.User{UserName: new(name)} for _, g := range groups { - u.Groups = append(u.Groups, iam.ComplexValue{Display: g}) + u.Groups = append(u.Groups, scim.ComplexValue{Display: new(g)}) } return u } -func aclFor(t *testing.T, acl []workspace.WorkspaceObjectAccessControlResponse) *FolderACL { +func aclFor(t *testing.T, acl []workspaceapi.WorkspaceObjectAccessControlResponse) *FolderACL { t.Helper() return &FolderACL{ RequestedPath: "/Workspace/f", @@ -30,34 +30,34 @@ func aclFor(t *testing.T, acl []workspace.WorkspaceObjectAccessControlResponse) } func TestFolderACLCanWrite(t *testing.T) { - editUser := []workspace.WorkspaceObjectAccessControlResponse{ + editUser := []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "me@example.com", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_EDIT"}, }, }, } - manageGroup := []workspace.WorkspaceObjectAccessControlResponse{ + manageGroup := []workspaceapi.WorkspaceObjectAccessControlResponse{ { GroupName: "devs", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, } - readOnlyUser := []workspace.WorkspaceObjectAccessControlResponse{ + readOnlyUser := []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "me@example.com", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_READ"}, }, }, } - sp := []workspace.WorkspaceObjectAccessControlResponse{ + sp := []workspaceapi.WorkspaceObjectAccessControlResponse{ { ServicePrincipalName: "sp-uuid", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, @@ -65,8 +65,8 @@ func TestFolderACLCanWrite(t *testing.T) { tests := []struct { name string - acl []workspace.WorkspaceObjectAccessControlResponse - user *iam.User + acl []workspaceapi.WorkspaceObjectAccessControlResponse + user *scim.User want bool }{ {"direct write", editUser, user("me@example.com"), true}, @@ -94,22 +94,22 @@ func TestFolderACLCanWrite(t *testing.T) { // directly. // homeDirACL: owner has direct CAN_MANAGE (writable). -var homeDirACL = []workspace.WorkspaceObjectAccessControlResponse{ +var homeDirACL = []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "owner@example.com", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, { ServicePrincipalName: "00000000-0000-0000-0000-000000000000", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE", Inherited: true}, }, }, { GroupName: "admins", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE", Inherited: true}, }, }, @@ -117,16 +117,16 @@ var homeDirACL = []workspace.WorkspaceObjectAccessControlResponse{ // sharedDirACL: CAN_MANAGE granted to the "users" group (write via group, not a // direct grant). -var sharedDirACL = []workspace.WorkspaceObjectAccessControlResponse{ +var sharedDirACL = []workspaceapi.WorkspaceObjectAccessControlResponse{ { GroupName: "users", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, { GroupName: "admins", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE", Inherited: true}, }, }, @@ -144,25 +144,47 @@ func TestFolderACLCanWriteRealisticACLs(t *testing.T) { assert.False(t, aclFor(t, sharedDirACL).CanWrite(other)) } +// workspaceWithACL serves get-status for the given directories (path -> object id) +// and returns getPerms for the permissions read of any of them. +func workspaceWithACL(t *testing.T, ids map[string]int64, getPerms func() any) *workspaceapi.Client { + w, server := bundletest.NewClients(t) + server.Handle("GET", "/api/2.0/workspace/get-status", func(req testserver.Request) any { + path := req.URL.Query().Get("path") + id, ok := ids[path] + if !ok { + return testserver.Response{StatusCode: 404, Body: map[string]string{"error_code": "RESOURCE_DOES_NOT_EXIST", "message": path}} + } + return workspaceapi.ObjectInfo{ObjectId: id, ObjectType: workspaceapi.ObjectTypeDirectory, Path: path} + }) + server.Handle("GET", "/api/2.0/permissions/directories/{id}", func(req testserver.Request) any { + return getPerms() + }) + return w.Workspace +} + +func apiError(status int, code string) testserver.Response { + return testserver.Response{StatusCode: status, Body: map[string]string{"error_code": code, "message": code}} +} + func TestCheckWritable(t *testing.T) { const folder = "/Workspace/f" me := user("me@example.com") - writableACL := &workspace.WorkspaceObjectPermissions{ - AccessControlList: []workspace.WorkspaceObjectAccessControlResponse{ + writableACL := &workspaceapi.WorkspaceObjectPermissions{ + AccessControlList: []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "me@example.com", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, }, } - readOnlyACL := &workspace.WorkspaceObjectPermissions{ - AccessControlList: []workspace.WorkspaceObjectAccessControlResponse{ + readOnlyACL := &workspaceapi.WorkspaceObjectPermissions{ + AccessControlList: []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "me@example.com", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_READ"}, }, }, @@ -171,72 +193,55 @@ func TestCheckWritable(t *testing.T) { tests := []struct { name string - getPerms func() (*workspace.WorkspaceObjectPermissions, error) + getPerms func() any want Writability }{ { "writable", - func() (*workspace.WorkspaceObjectPermissions, error) { return writableACL, nil }, + func() any { return writableACL }, WritabilityWritable, }, { // Reading the ACL is denied because it requires manage access, so the // user definitely cannot write. This is the common real-world case. "permission denied on ACL read means not writable", - func() (*workspace.WorkspaceObjectPermissions, error) { - return nil, &apierr.APIError{StatusCode: 403, ErrorCode: "PERMISSION_DENIED"} - }, + func() any { return apiError(403, "PERMISSION_DENIED") }, WritabilityNotWritable, }, { "readable ACL without a write grant means not writable", - func() (*workspace.WorkspaceObjectPermissions, error) { return readOnlyACL, nil }, + func() any { return readOnlyACL }, WritabilityNotWritable, }, { "other errors are unknown", - func() (*workspace.WorkspaceObjectPermissions, error) { - return nil, &apierr.APIError{StatusCode: 500} - }, + func() any { return apiError(500, "INTERNAL_ERROR") }, WritabilityUnknown, }, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - w := m.GetMockWorkspaceAPI() - w.EXPECT().GetStatusByPath(mock.Anything, folder). - Return(&workspace.ObjectInfo{ObjectId: 7, Path: folder}, nil) - w.EXPECT().GetPermissions(mock.Anything, mock.Anything).Return(tc.getPerms()) - + w := workspaceWithACL(t, map[string]int64{folder: 7}, tc.getPerms) assert.Equal(t, tc.want, CheckWritable(t.Context(), w, folder, me)) }) } } func TestResolveFolderACLWalksUpToClosestExistingAncestor(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - w := m.GetMockWorkspaceAPI() - // The requested folder does not exist yet; its parent does. - w.EXPECT().GetStatusByPath(mock.Anything, "/Workspace/root/files"). - Return(nil, &apierr.APIError{StatusCode: 404}) - w.EXPECT().GetStatusByPath(mock.Anything, "/Workspace/root"). - Return(&workspace.ObjectInfo{ObjectId: 42, Path: "/Workspace/root"}, nil) - w.EXPECT().GetPermissions(mock.Anything, workspace.GetWorkspaceObjectPermissionsRequest{ - WorkspaceObjectId: "42", - WorkspaceObjectType: "directories", - }).Return(&workspace.WorkspaceObjectPermissions{ - AccessControlList: []workspace.WorkspaceObjectAccessControlResponse{ - { - UserName: "me@example.com", - AllPermissions: []workspace.WorkspaceObjectPermission{ - {PermissionLevel: "CAN_MANAGE"}, + w := workspaceWithACL(t, map[string]int64{"/Workspace/root": 42}, func() any { + return &workspaceapi.WorkspaceObjectPermissions{ + AccessControlList: []workspaceapi.WorkspaceObjectAccessControlResponse{ + { + UserName: "me@example.com", + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ + {PermissionLevel: "CAN_MANAGE"}, + }, }, }, - }, - }, nil) + } + }) acl, err := ResolveFolderACL(t.Context(), w, "/Workspace/root/files") require.NoError(t, err) diff --git a/bundle/permissions/permission_diagnostics.go b/bundle/permissions/permission_diagnostics.go index 0e01f72a0f4..a200a95dce6 100644 --- a/bundle/permissions/permission_diagnostics.go +++ b/bundle/permissions/permission_diagnostics.go @@ -6,6 +6,8 @@ import ( "slices" "strings" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/iamutil" @@ -54,9 +56,9 @@ func (m *permissionDiagnostics) Apply(ctx context.Context, b *bundle.Bundle) dia " - %s: %s\n"+ " level: CAN_MANAGE\n\n"+ "See https://docs.databricks.com/dev-tools/bundles/permissions.html to learn more about permission configuration.", - b.Config.Workspace.CurrentUser.UserName, + utils.Deref(b.Config.Workspace.CurrentUser.UserName), identityType, - b.Config.Workspace.CurrentUser.UserName, + utils.Deref(b.Config.Workspace.CurrentUser.UserName), ), Locations: []diag.Location{b.Config.GetLocation("permissions")}, ID: diag.PermissionNotIncluded, @@ -73,13 +75,15 @@ func (m *permissionDiagnostics) Apply(ctx context.Context, b *bundle.Bundle) dia func analyzeBundlePermissions(b *bundle.Bundle) (bool, string) { canManageBundle := false otherManagers := set.NewSet[string]() - if b.Config.RunAs != nil && b.Config.RunAs.UserName != "" && b.Config.RunAs.UserName != b.Config.Workspace.CurrentUser.UserName { - // The run_as user is another human that could be contacted - // about this bundle. - otherManagers.Add(b.Config.RunAs.UserName) + currentUser := utils.Deref(b.Config.Workspace.CurrentUser.UserName) + if b.Config.RunAs != nil { + if runAsUser := utils.Deref(b.Config.RunAs.UserName); runAsUser != "" && runAsUser != currentUser { + // The run_as user is another human that could be contacted + // about this bundle. + otherManagers.Add(runAsUser) + } } - currentUser := b.Config.Workspace.CurrentUser.UserName targetPermissions := b.Config.Permissions for _, p := range targetPermissions { if p.Level != CAN_MANAGE { @@ -124,7 +128,7 @@ func isGroupOfCurrentUser(b *bundle.Bundle, groupName string) bool { currentUserGroups := b.Config.Workspace.CurrentUser.Groups for _, g := range currentUserGroups { - if g.Display == groupName { + if utils.Deref(g.Display) == groupName { return true } } diff --git a/bundle/permissions/permission_diagnostics_test.go b/bundle/permissions/permission_diagnostics_test.go index e5a9214f437..8fb533e9922 100644 --- a/bundle/permissions/permission_diagnostics_test.go +++ b/bundle/permissions/permission_diagnostics_test.go @@ -3,12 +3,13 @@ package permissions_test import ( "testing" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/permissions" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/stretchr/testify/require" ) @@ -53,11 +54,11 @@ func mockBundle(permissions []resources.Permission) *bundle.Bundle { Config: config.Root{ Workspace: config.Workspace{ CurrentUser: &config.User{ - User: &iam.User{ - UserName: "testuser@databricks.com", - DisplayName: "Test User", - Groups: []iam.ComplexValue{ - {Display: "testgroup"}, + User: &scim.User{ + UserName: new("testuser@databricks.com"), + DisplayName: new("Test User"), + Groups: []scim.ComplexValue{ + {Display: new("testgroup")}, }, }, }, diff --git a/bundle/permissions/permission_report.go b/bundle/permissions/permission_report.go index 36526eeeba9..e5cc59d719f 100644 --- a/bundle/permissions/permission_report.go +++ b/bundle/permissions/permission_report.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/iamutil" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/utils" ) // ReportPossiblePermissionDenied generates a diagnostic message when a permission denied error is encountered. @@ -18,9 +19,9 @@ func ReportPossiblePermissionDenied(ctx context.Context, b *bundle.Bundle, path log.Errorf(ctx, "Failed to update, encountered possible permission error: %v", path) me := b.Config.Workspace.CurrentUser.User - userName := me.UserName + userName := utils.Deref(me.UserName) if iamutil.IsServicePrincipal(me) { - userName = me.DisplayName + userName = utils.Deref(me.DisplayName) } canManageBundle, assistance := analyzeBundlePermissions(b) diff --git a/bundle/permissions/validate_test.go b/bundle/permissions/validate_test.go index afaab38f3a1..7de64738981 100644 --- a/bundle/permissions/validate_test.go +++ b/bundle/permissions/validate_test.go @@ -3,12 +3,13 @@ package permissions import ( "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/require" ) @@ -23,15 +24,15 @@ func TestValidateSharedRootPermissionsForShared(t *testing.T) { }, Resources: config.Resources{ Jobs: map[string]*resources.Job{ - "job_1": {JobSettings: jobs.JobSettings{Name: "job_1"}}, - "job_2": {JobSettings: jobs.JobSettings{Name: "job_2"}}, + "job_1": {JobSettings: jobs.JobSettings{Name: new("job_1")}}, + "job_2": {JobSettings: jobs.JobSettings{Name: new("job_2")}}, }, }, }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) + w, _ := bundletest.NewClients(t) + b.SetWorkpaceClient(w) diags := bundle.Apply(t.Context(), b, ValidateSharedRootPermissions()) require.Empty(t, diags) @@ -48,15 +49,15 @@ func TestValidateSharedRootPermissionsForSharedError(t *testing.T) { }, Resources: config.Resources{ Jobs: map[string]*resources.Job{ - "job_1": {JobSettings: jobs.JobSettings{Name: "job_1"}}, - "job_2": {JobSettings: jobs.JobSettings{Name: "job_2"}}, + "job_1": {JobSettings: jobs.JobSettings{Name: new("job_1")}}, + "job_2": {JobSettings: jobs.JobSettings{Name: new("job_2")}}, }, }, }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) + w, _ := bundletest.NewClients(t) + b.SetWorkpaceClient(w) diags := bundle.Apply(t.Context(), b, ValidateSharedRootPermissions()) require.Len(t, diags, 1) diff --git a/bundle/permissions/workspace_path_permissions.go b/bundle/permissions/workspace_path_permissions.go index a577396597e..5c75851f15d 100644 --- a/bundle/permissions/workspace_path_permissions.go +++ b/bundle/permissions/workspace_path_permissions.go @@ -6,8 +6,7 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/workspaceapi" ) type WorkspacePathPermissions struct { @@ -15,7 +14,7 @@ type WorkspacePathPermissions struct { Permissions []resources.Permission } -func ObjectAclToResourcePermissions(path string, acl []workspace.WorkspaceObjectAccessControlResponse) *WorkspacePathPermissions { +func ObjectAclToResourcePermissions(path string, acl []workspaceapi.WorkspaceObjectAccessControlResponse) *WorkspacePathPermissions { var permissions []resources.Permission for _, a := range acl { // Skip the admin group because it's added to all resources by default. @@ -24,9 +23,9 @@ func ObjectAclToResourcePermissions(path string, acl []workspace.WorkspaceObject } // Find the highest permission level for this principal (handles inherited + explicit permissions) - var highestLevel iam.PermissionLevel + var highestLevel resources.PermissionLevel for _, pl := range a.AllPermissions { - level := iam.PermissionLevel(convertWorkspaceObjectPermissionLevel(pl.PermissionLevel)) + level := resources.PermissionLevel(convertWorkspaceObjectPermissionLevel(pl.PermissionLevel)) if resources.GetLevelScore(string(level)) > resources.GetLevelScore(string(highestLevel)) { highestLevel = level } @@ -111,9 +110,9 @@ func containsAll(permA, permB []resources.Permission) (bool, []resources.Permiss // convertWorkspaceObjectPermissionLevel converts matching object permission levels to bundle ones. // If there is no matching permission level, it returns permission level as is, for example, CAN_EDIT. -func convertWorkspaceObjectPermissionLevel(level workspace.WorkspaceObjectPermissionLevel) string { +func convertWorkspaceObjectPermissionLevel(level workspaceapi.WorkspaceObjectPermissionLevel) string { switch level { - case workspace.WorkspaceObjectPermissionLevelCanRead: + case workspaceapi.WorkspaceObjectPermissionLevelCanRead: return CAN_VIEW default: return string(level) diff --git a/bundle/permissions/workspace_path_permissions_test.go b/bundle/permissions/workspace_path_permissions_test.go index fd8a592da01..3d6a73a56e7 100644 --- a/bundle/permissions/workspace_path_permissions_test.go +++ b/bundle/permissions/workspace_path_permissions_test.go @@ -5,25 +5,24 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/workspaceapi" "github.com/stretchr/testify/require" ) func TestWorkspacePathPermissionsCompare(t *testing.T) { testCases := []struct { perms []resources.Permission - acl []workspace.WorkspaceObjectAccessControlResponse + acl []workspaceapi.WorkspaceObjectAccessControlResponse expected diag.Diagnostics }{ { perms: []resources.Permission{ {Level: CAN_MANAGE, UserName: "foo@bar.test"}, }, - acl: []workspace.WorkspaceObjectAccessControlResponse{ + acl: []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "foo@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, @@ -34,16 +33,16 @@ func TestWorkspacePathPermissionsCompare(t *testing.T) { perms: []resources.Permission{ {Level: CAN_MANAGE, UserName: "foo@bar.test"}, }, - acl: []workspace.WorkspaceObjectAccessControlResponse{ + acl: []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "foo@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, { GroupName: "admins", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, @@ -55,10 +54,10 @@ func TestWorkspacePathPermissionsCompare(t *testing.T) { {Level: CAN_VIEW, UserName: "foo@bar.test"}, {Level: CAN_MANAGE, ServicePrincipalName: "sp.com"}, }, - acl: []workspace.WorkspaceObjectAccessControlResponse{ + acl: []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "foo@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_READ"}, }, }, @@ -69,16 +68,16 @@ func TestWorkspacePathPermissionsCompare(t *testing.T) { perms: []resources.Permission{ {Level: CAN_MANAGE, UserName: "foo@bar.test"}, }, - acl: []workspace.WorkspaceObjectAccessControlResponse{ + acl: []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "foo@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, { GroupName: "foo", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, @@ -98,10 +97,10 @@ func TestWorkspacePathPermissionsCompare(t *testing.T) { perms: []resources.Permission{ {Level: CAN_MANAGE, UserName: "foo@bar.test"}, }, - acl: []workspace.WorkspaceObjectAccessControlResponse{ + acl: []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "foo2@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, @@ -130,7 +129,7 @@ func TestWorkspacePathPermissionsCompareWithHierarchy(t *testing.T) { testCases := []struct { name string perms []resources.Permission - acl []workspace.WorkspaceObjectAccessControlResponse + acl []workspaceapi.WorkspaceObjectAccessControlResponse expected diag.Diagnostics }{ { @@ -138,10 +137,10 @@ func TestWorkspacePathPermissionsCompareWithHierarchy(t *testing.T) { perms: []resources.Permission{ {Level: CAN_MANAGE, UserName: "foo@bar.test"}, }, - acl: []workspace.WorkspaceObjectAccessControlResponse{ + acl: []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "foo@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_READ"}, }, }, @@ -153,10 +152,10 @@ func TestWorkspacePathPermissionsCompareWithHierarchy(t *testing.T) { perms: []resources.Permission{ {Level: CAN_VIEW, UserName: "foo@bar.test"}, }, - acl: []workspace.WorkspaceObjectAccessControlResponse{ + acl: []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "foo@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, @@ -177,10 +176,10 @@ func TestWorkspacePathPermissionsCompareWithHierarchy(t *testing.T) { perms: []resources.Permission{ {Level: CAN_MANAGE, UserName: "foo@bar.test"}, }, - acl: []workspace.WorkspaceObjectAccessControlResponse{ + acl: []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "foo@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_MANAGE"}, }, }, @@ -200,10 +199,10 @@ func TestWorkspacePathPermissionsCompareWithHierarchy(t *testing.T) { func TestWorkspacePathPermissionsDeduplication(t *testing.T) { // User has both inherited CAN_VIEW and explicit CAN_MANAGE - acl := []workspace.WorkspaceObjectAccessControlResponse{ + acl := []workspaceapi.WorkspaceObjectAccessControlResponse{ { UserName: "foo@bar.test", - AllPermissions: []workspace.WorkspaceObjectPermission{ + AllPermissions: []workspaceapi.WorkspaceObjectPermission{ {PermissionLevel: "CAN_READ"}, // inherited {PermissionLevel: "CAN_MANAGE"}, // explicit }, @@ -214,7 +213,7 @@ func TestWorkspacePathPermissionsDeduplication(t *testing.T) { // Should only have one permission entry with the highest level require.Len(t, wp.Permissions, 1) - require.Equal(t, iam.PermissionLevel(CAN_MANAGE), wp.Permissions[0].Level) + require.Equal(t, resources.PermissionLevel(CAN_MANAGE), wp.Permissions[0].Level) require.Equal(t, "foo@bar.test", wp.Permissions[0].UserName) } diff --git a/bundle/permissions/workspace_root.go b/bundle/permissions/workspace_root.go index d4f3ee173c7..fa7b3d8bf6c 100644 --- a/bundle/permissions/workspace_root.go +++ b/bundle/permissions/workspace_root.go @@ -7,6 +7,8 @@ import ( "strconv" "strings" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" @@ -14,7 +16,7 @@ import ( "github.com/databricks/cli/bundle/metrics" "github.com/databricks/cli/bundle/paths" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/workspaceapi" "golang.org/x/sync/errgroup" ) @@ -55,14 +57,14 @@ func (*workspaceRootPermissions) Apply(ctx context.Context, b *bundle.Bundle) di // the deployment state. It returns nil only when no permissions are declared, in // which case no folders are synced. func giveAccessForWorkspaceRoot(ctx context.Context, b *bundle.Bundle, wsConfig config.Workspace) (*WorkspacePathPermissions, error) { - var permissions []workspace.WorkspaceObjectAccessControlRequest + var permissions []workspaceapi.WorkspaceObjectAccessControlRequest for _, p := range b.Config.Permissions { level, err := GetWorkspaceObjectPermissionLevel(string(p.Level)) if err != nil { return nil, err } - permissions = append(permissions, workspace.WorkspaceObjectAccessControlRequest{ + permissions = append(permissions, workspaceapi.WorkspaceObjectAccessControlRequest{ GroupName: p.GroupName, UserName: p.UserName, ServicePrincipalName: p.ServicePrincipalName, @@ -104,7 +106,7 @@ func giveAccessForWorkspaceRoot(ctx context.Context, b *bundle.Bundle, wsConfig return folderPermissions[i], nil } -func setPermissions(ctx context.Context, w workspace.WorkspaceInterface, path string, permissions []workspace.WorkspaceObjectAccessControlRequest) (*WorkspacePathPermissions, error) { +func setPermissions(ctx context.Context, w *workspaceapi.Client, path string, permissions []workspaceapi.WorkspaceObjectAccessControlRequest) (*WorkspacePathPermissions, error) { // Shared folders are writable by all workspace users and the sync does not modify // them. Return that ACL statically so callers need no special case for them. if libraries.IsWorkspaceSharedPath(path) { @@ -123,7 +125,7 @@ func setPermissions(ctx context.Context, w workspace.WorkspaceInterface, path st // it against the declaration without an extra API call. The Set replaces the direct // ACL with the declared permissions, so any principal still showing higher access is // inherited from a parent folder. - resp, err := w.SetPermissions(ctx, workspace.WorkspaceObjectPermissionsRequest{ + resp, err := w.SetPermissions(ctx, workspaceapi.WorkspaceObjectPermissionsRequest{ WorkspaceObjectId: strconv.FormatInt(obj.ObjectId, 10), WorkspaceObjectType: "directories", AccessControlList: permissions, @@ -135,14 +137,14 @@ func setPermissions(ctx context.Context, w workspace.WorkspaceInterface, path st return ObjectAclToResourcePermissions(path, resp.AccessControlList), nil } -func GetWorkspaceObjectPermissionLevel(bundlePermission string) (workspace.WorkspaceObjectPermissionLevel, error) { +func GetWorkspaceObjectPermissionLevel(bundlePermission string) (workspaceapi.WorkspaceObjectPermissionLevel, error) { switch bundlePermission { case CAN_MANAGE: - return workspace.WorkspaceObjectPermissionLevelCanManage, nil + return workspaceapi.WorkspaceObjectPermissionLevelCanManage, nil case CAN_RUN: - return workspace.WorkspaceObjectPermissionLevelCanRun, nil + return workspaceapi.WorkspaceObjectPermissionLevelCanRun, nil case CAN_VIEW: - return workspace.WorkspaceObjectPermissionLevelCanRead, nil + return workspaceapi.WorkspaceObjectPermissionLevelCanRead, nil default: return "", fmt.Errorf("unsupported bundle permission level %s", bundlePermission) } @@ -265,7 +267,7 @@ func deployingUserName(b *bundle.Bundle) string { if b.Config.Workspace.CurrentUser == nil { return "" } - return b.Config.Workspace.CurrentUser.UserName + return utils.Deref(b.Config.Workspace.CurrentUser.UserName) } // isDeployingUser reports whether p is the user performing the deploy. diff --git a/bundle/permissions/workspace_root_test.go b/bundle/permissions/workspace_root_test.go index db4ea36fc8c..51d568a02a5 100644 --- a/bundle/permissions/workspace_root_test.go +++ b/bundle/permissions/workspace_root_test.go @@ -1,21 +1,62 @@ package permissions import ( + "encoding/json" + "sync" "testing" + "github.com/databricks/cli/libs/sdktypes/experiments/v1" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/modelserving/v1" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/serving" - "github.com/databricks/databricks-sdk-go/service/workspace" - "github.com/stretchr/testify/mock" + "github.com/databricks/cli/bundle/internal/bundletest" + "github.com/databricks/cli/libs/testserver" + "github.com/databricks/cli/libs/workspaceapi" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) +var expectedRootACL = []workspaceapi.WorkspaceObjectAccessControlRequest{ + {UserName: "TestUser", PermissionLevel: "CAN_MANAGE"}, + {GroupName: "TestGroup", PermissionLevel: "CAN_READ"}, + {ServicePrincipalName: "TestServicePrincipal", PermissionLevel: "CAN_RUN"}, +} + +// fakeDirs records the ACLs set on workspace directories. +type fakeDirs struct { + mu sync.Mutex + set map[string][]workspaceapi.WorkspaceObjectAccessControlRequest +} + +// fakeDirectories serves get-status for the given directories (path -> object id) +// and records permission updates on them. +func fakeDirectories(t *testing.T, b *bundle.Bundle, ids map[string]int64) *fakeDirs { + w, server := bundletest.NewClients(t) + b.SetWorkpaceClient(w) + dirs := &fakeDirs{set: map[string][]workspaceapi.WorkspaceObjectAccessControlRequest{}} + server.Handle("GET", "/api/2.0/workspace/get-status", func(req testserver.Request) any { + path := req.URL.Query().Get("path") + id, ok := ids[path] + if !ok { + return testserver.Response{StatusCode: 404, Body: map[string]string{"error_code": "RESOURCE_DOES_NOT_EXIST", "message": path}} + } + return workspaceapi.ObjectInfo{ObjectId: id, ObjectType: workspaceapi.ObjectTypeDirectory, Path: path} + }) + server.Handle("PUT", "/api/2.0/permissions/directories/{id}", func(req testserver.Request) any { + var body workspaceapi.WorkspaceObjectPermissionsRequest + assert.NoError(t, json.Unmarshal(req.Body, &body)) + dirs.mu.Lock() + defer dirs.mu.Unlock() + dirs.set[req.Vars["id"]] = body.AccessControlList + return workspaceapi.WorkspaceObjectPermissions{} + }) + return dirs +} + func TestApplyWorkspaceRootPermissions(t *testing.T) { b := &bundle.Bundle{ Config: config.Root{ @@ -33,47 +74,34 @@ func TestApplyWorkspaceRootPermissions(t *testing.T) { }, Resources: config.Resources{ Jobs: map[string]*resources.Job{ - "job_1": {JobSettings: jobs.JobSettings{Name: "job_1"}}, - "job_2": {JobSettings: jobs.JobSettings{Name: "job_2"}}, + "job_1": {JobSettings: jobs.JobSettings{Name: new("job_1")}}, + "job_2": {JobSettings: jobs.JobSettings{Name: new("job_2")}}, }, Pipelines: map[string]*resources.Pipeline{ - "pipeline_1": {CreatePipeline: pipelines.CreatePipeline{}}, - "pipeline_2": {CreatePipeline: pipelines.CreatePipeline{}}, + "pipeline_1": {CreatePipelineRequest: pipelines.CreatePipelineRequest{}}, + "pipeline_2": {CreatePipelineRequest: pipelines.CreatePipelineRequest{}}, }, Models: map[string]*resources.MlflowModel{ "model_1": {}, "model_2": {}, }, Experiments: map[string]*resources.MlflowExperiment{ - "experiment_1": {CreateExperiment: ml.CreateExperiment{}}, - "experiment_2": {CreateExperiment: ml.CreateExperiment{}}, + "experiment_1": {CreateExperimentRequest: experiments.CreateExperimentRequest{}}, + "experiment_2": {CreateExperimentRequest: experiments.CreateExperimentRequest{}}, }, ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{ - "endpoint_1": {CreateServingEndpoint: serving.CreateServingEndpoint{}}, - "endpoint_2": {CreateServingEndpoint: serving.CreateServingEndpoint{}}, + "endpoint_1": {CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{}}, + "endpoint_2": {CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{}}, }, }, }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) - workspaceApi := m.GetMockWorkspaceAPI() - workspaceApi.EXPECT().GetStatusByPath(mock.Anything, "/Users/foo@bar.test").Return(&workspace.ObjectInfo{ - ObjectId: 1234, - }, nil) - workspaceApi.EXPECT().SetPermissions(mock.Anything, workspace.WorkspaceObjectPermissionsRequest{ - AccessControlList: []workspace.WorkspaceObjectAccessControlRequest{ - {UserName: "TestUser", PermissionLevel: "CAN_MANAGE"}, - {GroupName: "TestGroup", PermissionLevel: "CAN_READ"}, - {ServicePrincipalName: "TestServicePrincipal", PermissionLevel: "CAN_RUN"}, - }, - WorkspaceObjectId: "1234", - WorkspaceObjectType: "directories", - }).Return(&workspace.WorkspaceObjectPermissions{}, nil) + dirs := fakeDirectories(t, b, map[string]int64{"/Users/foo@bar.test": 1234}) diags := bundle.ApplySeq(t.Context(), b, ValidateSharedRootPermissions(), ApplyWorkspaceRootPermissions()) require.Empty(t, diags) + assert.Equal(t, map[string][]workspaceapi.WorkspaceObjectAccessControlRequest{"1234": expectedRootACL}, dirs.set) } func TestApplyWorkspaceRootPermissionsForAllPaths(t *testing.T) { @@ -93,100 +121,46 @@ func TestApplyWorkspaceRootPermissionsForAllPaths(t *testing.T) { }, Resources: config.Resources{ Jobs: map[string]*resources.Job{ - "job_1": {JobSettings: jobs.JobSettings{Name: "job_1"}}, - "job_2": {JobSettings: jobs.JobSettings{Name: "job_2"}}, + "job_1": {JobSettings: jobs.JobSettings{Name: new("job_1")}}, + "job_2": {JobSettings: jobs.JobSettings{Name: new("job_2")}}, }, Pipelines: map[string]*resources.Pipeline{ - "pipeline_1": {CreatePipeline: pipelines.CreatePipeline{}}, - "pipeline_2": {CreatePipeline: pipelines.CreatePipeline{}}, + "pipeline_1": {CreatePipelineRequest: pipelines.CreatePipelineRequest{}}, + "pipeline_2": {CreatePipelineRequest: pipelines.CreatePipelineRequest{}}, }, Models: map[string]*resources.MlflowModel{ "model_1": {}, "model_2": {}, }, Experiments: map[string]*resources.MlflowExperiment{ - "experiment_1": {CreateExperiment: ml.CreateExperiment{}}, - "experiment_2": {CreateExperiment: ml.CreateExperiment{}}, + "experiment_1": {CreateExperimentRequest: experiments.CreateExperimentRequest{}}, + "experiment_2": {CreateExperimentRequest: experiments.CreateExperimentRequest{}}, }, ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{ - "endpoint_1": {CreateServingEndpoint: serving.CreateServingEndpoint{}}, - "endpoint_2": {CreateServingEndpoint: serving.CreateServingEndpoint{}}, + "endpoint_1": {CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{}}, + "endpoint_2": {CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{}}, }, }, }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) - workspaceApi := m.GetMockWorkspaceAPI() - workspaceApi.EXPECT().GetStatusByPath(mock.Anything, "/Some/Root/Path").Return(&workspace.ObjectInfo{ - ObjectId: 1, - }, nil) - workspaceApi.EXPECT().GetStatusByPath(mock.Anything, "/Users/foo@bar.test/artifacts").Return(&workspace.ObjectInfo{ - ObjectId: 2, - }, nil) - workspaceApi.EXPECT().GetStatusByPath(mock.Anything, "/Users/foo@bar.test/files").Return(&workspace.ObjectInfo{ - ObjectId: 3, - }, nil) - workspaceApi.EXPECT().GetStatusByPath(mock.Anything, "/Users/foo@bar.test/state").Return(&workspace.ObjectInfo{ - ObjectId: 4, - }, nil) - workspaceApi.EXPECT().GetStatusByPath(mock.Anything, "/Users/foo@bar.test/resources").Return(&workspace.ObjectInfo{ - ObjectId: 5, - }, nil) - - workspaceApi.EXPECT().SetPermissions(mock.Anything, workspace.WorkspaceObjectPermissionsRequest{ - AccessControlList: []workspace.WorkspaceObjectAccessControlRequest{ - {UserName: "TestUser", PermissionLevel: "CAN_MANAGE"}, - {GroupName: "TestGroup", PermissionLevel: "CAN_READ"}, - {ServicePrincipalName: "TestServicePrincipal", PermissionLevel: "CAN_RUN"}, - }, - WorkspaceObjectId: "1", - WorkspaceObjectType: "directories", - }).Return(&workspace.WorkspaceObjectPermissions{}, nil) - - workspaceApi.EXPECT().SetPermissions(mock.Anything, workspace.WorkspaceObjectPermissionsRequest{ - AccessControlList: []workspace.WorkspaceObjectAccessControlRequest{ - {UserName: "TestUser", PermissionLevel: "CAN_MANAGE"}, - {GroupName: "TestGroup", PermissionLevel: "CAN_READ"}, - {ServicePrincipalName: "TestServicePrincipal", PermissionLevel: "CAN_RUN"}, - }, - WorkspaceObjectId: "2", - WorkspaceObjectType: "directories", - }).Return(&workspace.WorkspaceObjectPermissions{}, nil) - - workspaceApi.EXPECT().SetPermissions(mock.Anything, workspace.WorkspaceObjectPermissionsRequest{ - AccessControlList: []workspace.WorkspaceObjectAccessControlRequest{ - {UserName: "TestUser", PermissionLevel: "CAN_MANAGE"}, - {GroupName: "TestGroup", PermissionLevel: "CAN_READ"}, - {ServicePrincipalName: "TestServicePrincipal", PermissionLevel: "CAN_RUN"}, - }, - WorkspaceObjectId: "3", - WorkspaceObjectType: "directories", - }).Return(&workspace.WorkspaceObjectPermissions{}, nil) - - workspaceApi.EXPECT().SetPermissions(mock.Anything, workspace.WorkspaceObjectPermissionsRequest{ - AccessControlList: []workspace.WorkspaceObjectAccessControlRequest{ - {UserName: "TestUser", PermissionLevel: "CAN_MANAGE"}, - {GroupName: "TestGroup", PermissionLevel: "CAN_READ"}, - {ServicePrincipalName: "TestServicePrincipal", PermissionLevel: "CAN_RUN"}, - }, - WorkspaceObjectId: "4", - WorkspaceObjectType: "directories", - }).Return(&workspace.WorkspaceObjectPermissions{}, nil) - - workspaceApi.EXPECT().SetPermissions(mock.Anything, workspace.WorkspaceObjectPermissionsRequest{ - AccessControlList: []workspace.WorkspaceObjectAccessControlRequest{ - {UserName: "TestUser", PermissionLevel: "CAN_MANAGE"}, - {GroupName: "TestGroup", PermissionLevel: "CAN_READ"}, - {ServicePrincipalName: "TestServicePrincipal", PermissionLevel: "CAN_RUN"}, - }, - WorkspaceObjectId: "5", - WorkspaceObjectType: "directories", - }).Return(&workspace.WorkspaceObjectPermissions{}, nil) + dirs := fakeDirectories(t, b, map[string]int64{ + "/Some/Root/Path": 1, + "/Users/foo@bar.test/artifacts": 2, + "/Users/foo@bar.test/files": 3, + "/Users/foo@bar.test/state": 4, + "/Users/foo@bar.test/resources": 5, + }) diags := bundle.Apply(t.Context(), b, ApplyWorkspaceRootPermissions()) require.NoError(t, diags.Error()) + assert.Equal(t, map[string][]workspaceapi.WorkspaceObjectAccessControlRequest{ + "1": expectedRootACL, + "2": expectedRootACL, + "3": expectedRootACL, + "4": expectedRootACL, + "5": expectedRootACL, + }, dirs.set) } func TestUndeclaredWriterTypes(t *testing.T) { diff --git a/bundle/phases/deploy.go b/bundle/phases/deploy.go index 13c5121f569..7ff1e143e32 100644 --- a/bundle/phases/deploy.go +++ b/bundle/phases/deploy.go @@ -21,12 +21,12 @@ import ( "github.com/databricks/cli/bundle/scripts" "github.com/databricks/cli/bundle/statemgmt" "github.com/databricks/cli/libs/agent" + "github.com/databricks/cli/libs/bundledeployments" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/dms" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/logdiag" "github.com/databricks/cli/libs/sync" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" ) var deployApprovalGroups = []approvalGroup{ diff --git a/bundle/phases/destroy.go b/bundle/phases/destroy.go index 8b5497d626a..8348f65d3de 100644 --- a/bundle/phases/destroy.go +++ b/bundle/phases/destroy.go @@ -14,20 +14,20 @@ import ( "github.com/databricks/cli/bundle/deploy/files" "github.com/databricks/cli/bundle/deploy/lock" "github.com/databricks/cli/bundle/deployplan" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/bundledeployments" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dms" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/logdiag" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" ) func assertRootPathExists(ctx context.Context, b *bundle.Bundle) (bool, error) { w := b.WorkspaceClient(ctx) _, err := w.Workspace.GetStatusByPath(ctx, b.Config.Workspace.RootPath) - if aerr, ok := errors.AsType[*apierr.APIError](err); ok && aerr.StatusCode == http.StatusNotFound { + if apierrs.StatusCode(err) == http.StatusNotFound { log.Infof(ctx, "Root path does not exist: %s", b.Config.Workspace.RootPath) return false, nil } diff --git a/bundle/phases/dms.go b/bundle/phases/dms.go index abd89f03f2f..e1b8161f35c 100644 --- a/bundle/phases/dms.go +++ b/bundle/phases/dms.go @@ -13,13 +13,12 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/deployplan" "github.com/databricks/cli/internal/build" + "github.com/databricks/cli/libs/bundledeployments" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/dms" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/logdiag" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" ) // stagedOperations lists the resources the plan will touch, for CreateVersion to stage an @@ -98,7 +97,7 @@ func createOrUpdateDeployment(ctx context.Context, b *bundle.Bundle, current *bu _, err := w.BundleDeployments.UpdateDeployment(ctx, bundledeployments.UpdateDeploymentRequest{ Name: dms.DeploymentName(deploymentID), Deployment: dms.DeploymentUpdate(metadata, mask), - UpdateMask: fieldmask.FieldMask{Paths: strings.Split(mask, ",")}, + UpdateMask: bundledeployments.FieldMask{Paths: strings.Split(mask, ",")}, }) if err != nil { logdiag.LogError(ctx, fmt.Errorf("failed to update deployment: %w", err)) diff --git a/bundle/phases/dms_test.go b/bundle/phases/dms_test.go index 6b045f863ae..2f90af4b12c 100644 --- a/bundle/phases/dms_test.go +++ b/bundle/phases/dms_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/databricks/cli/bundle/deployplan" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" + "github.com/databricks/cli/libs/bundledeployments" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/bundle/phases/telemetry.go b/bundle/phases/telemetry.go index 99464f3ef24..b2cf688cf69 100644 --- a/bundle/phases/telemetry.go +++ b/bundle/phases/telemetry.go @@ -16,9 +16,9 @@ import ( "github.com/databricks/cli/bundle/metrics" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/telemetry" "github.com/databricks/cli/libs/telemetry/protos" - "github.com/databricks/databricks-sdk-go/service/jobs" ) func getExecutionTimes(b *bundle.Bundle) []protos.IntMapEntry { @@ -117,7 +117,7 @@ func uploadFileSizeHistogram(files []sizer) []int64 { // fields (notebook_task, spark_python_task, ai_runtime_task, ...); we reflect over // the fields whose JSON name ends in "_task" so every task type is captured, // including ones added later, without changing this code. -func addTaskTypeKeys(task jobs.Task, out map[string]bool) { +func addTaskTypeKeys(task jobs.TaskSettings, out map[string]bool) { v := reflect.ValueOf(task) t := v.Type() for i := range t.NumField() { @@ -143,8 +143,8 @@ func collectTaskTypes(jobs map[string]*resources.Job) []string { } for _, task := range job.Tasks { addTaskTypeKeys(task, seen) - if task.ForEachTask != nil { - addTaskTypeKeys(task.ForEachTask.Task, seen) + if task.ForEachTask != nil && task.ForEachTask.Task != nil { + addTaskTypeKeys(*task.ForEachTask.Task, seen) } } } @@ -173,7 +173,7 @@ func aiRuntimeTaskMetrics(jobs map[string]*resources.Job) (present, scheduled, m jobHasAiRuntimeTask := false for _, task := range job.Tasks { rt := task.AiRuntimeTask - if rt == nil && task.ForEachTask != nil { + if rt == nil && task.ForEachTask != nil && task.ForEachTask.Task != nil { rt = task.ForEachTask.Task.AiRuntimeTask } if rt != nil { diff --git a/bundle/phases/telemetry_test.go b/bundle/phases/telemetry_test.go index d6badfaa792..05b2187fcda 100644 --- a/bundle/phases/telemetry_test.go +++ b/bundle/phases/telemetry_test.go @@ -3,8 +3,9 @@ package phases import ( "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/assert" ) @@ -81,15 +82,15 @@ func TestUploadFileSizeHistogramEmpty(t *testing.T) { func TestCollectTaskTypes(t *testing.T) { jobs := map[string]*resources.Job{ "nil": nil, - "a": {JobSettings: jobs.JobSettings{Tasks: []jobs.Task{ - {TaskKey: "nb", NotebookTask: &jobs.NotebookTask{NotebookPath: "/nb"}}, - {TaskKey: "train", AiRuntimeTask: &jobs.AiRuntimeTask{Experiment: "exp"}}, + "a": {JobSettings: jobs.JobSettings{Tasks: []jobs.TaskSettings{ + {TaskKey: new("nb"), NotebookTask: &jobs.NotebookTask{NotebookPath: new("/nb")}}, + {TaskKey: new("train"), AiRuntimeTask: &jobs.AiRuntimeTask{Experiment: new("exp")}}, }}}, - "b": {JobSettings: jobs.JobSettings{Tasks: []jobs.Task{ + "b": {JobSettings: jobs.JobSettings{Tasks: []jobs.TaskSettings{ // for_each wrapping a spark_python_task: both the wrapper and the // nested task type should be recorded. - {TaskKey: "fan", ForEachTask: &jobs.ForEachTask{Task: jobs.Task{ - SparkPythonTask: &jobs.SparkPythonTask{PythonFile: "main.py"}, + {TaskKey: new("fan"), ForEachTask: &jobs.ForEachTask{Task: &jobs.TaskSettings{ + SparkPythonTask: &jobs.SparkPythonTask{PythonFile: new("main.py")}, }}}, }}}, } @@ -106,23 +107,23 @@ func TestCollectTaskTypes(t *testing.T) { // aiRuntimeJob builds a job with a single ai_runtime_task, plus optionally an extra // no-op task to make it multi-task. func aiRuntimeJob(extraTask bool) *resources.Job { - tasks := []jobs.Task{{ - TaskKey: "train", - AiRuntimeTask: &jobs.AiRuntimeTask{Experiment: "exp"}, + tasks := []jobs.TaskSettings{{ + TaskKey: new("train"), + AiRuntimeTask: &jobs.AiRuntimeTask{Experiment: new("exp")}, }} if extraTask { - tasks = append(tasks, jobs.Task{TaskKey: "prep"}) + tasks = append(tasks, jobs.TaskSettings{TaskKey: new("prep")}) } return &resources.Job{Tasks: tasks} } func TestAiRuntimeTaskMetrics(t *testing.T) { scheduledJob := aiRuntimeJob(false) - scheduledJob.Schedule = &jobs.CronSchedule{QuartzCronExpression: "0 0 * * * ?"} + scheduledJob.Schedule = &jobs.CronSchedule{QuartzCronExpression: new("0 0 * * * ?")} - forEachJob := &resources.Job{Tasks: []jobs.Task{{ - TaskKey: "fanout", - ForEachTask: &jobs.ForEachTask{Task: jobs.Task{AiRuntimeTask: &jobs.AiRuntimeTask{Experiment: "exp"}}}, + forEachJob := &resources.Job{Tasks: []jobs.TaskSettings{{ + TaskKey: new("fanout"), + ForEachTask: &jobs.ForEachTask{Task: &jobs.TaskSettings{AiRuntimeTask: &jobs.AiRuntimeTask{Experiment: new("exp")}}}, }}} tests := []struct { @@ -136,7 +137,7 @@ func TestAiRuntimeTaskMetrics(t *testing.T) { }, { name: "job without ai_runtime_task", - jobs: map[string]*resources.Job{"j": {JobSettings: jobs.JobSettings{Tasks: []jobs.Task{{TaskKey: "notebook"}}}}}, + jobs: map[string]*resources.Job{"j": {JobSettings: jobs.JobSettings{Tasks: []jobs.TaskSettings{{TaskKey: new("notebook")}}}}}, }, { name: "single task", diff --git a/bundle/render/render_text_output.go b/bundle/render/render_text_output.go index 27ae5b6f7c5..f0766938052 100644 --- a/bundle/render/render_text_output.go +++ b/bundle/render/render_text_output.go @@ -12,7 +12,8 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/logdiag" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/libs/utils" ) const summaryHeaderTemplate = `{{- if .Name -}} @@ -98,7 +99,7 @@ func renderSummaryHeaderTemplate(ctx context.Context, out io.Writer, b *bundle.B return nil } - currentUser := &iam.User{} + currentUser := &scim.User{} if b.Config.Workspace.CurrentUser != nil { if b.Config.Workspace.CurrentUser.User != nil { @@ -110,7 +111,7 @@ func renderSummaryHeaderTemplate(ctx context.Context, out io.Writer, b *bundle.B err := t.Execute(out, map[string]any{ "Name": b.Config.Bundle.Name, "Target": b.Config.Bundle.Target, - "User": currentUser.UserName, + "User": utils.Deref(currentUser.UserName), "Path": b.Config.Workspace.RootPath, "Host": b.Config.Workspace.Host, }) diff --git a/bundle/render/render_text_output_test.go b/bundle/render/render_text_output_test.go index 4c87fbb4eb9..548998ae059 100644 --- a/bundle/render/render_text_output_test.go +++ b/bundle/render/render_text_output_test.go @@ -6,6 +6,11 @@ import ( "io" "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/modelserving/v1" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" @@ -13,11 +18,6 @@ import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/logdiag" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/serving" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -92,7 +92,7 @@ func TestRenderDiagnosticsSummary(t *testing.T) { Host: "https://test.databricks.com", RootPath: "/Users/test@test.com/.bundle/test-bundle/test-target", CurrentUser: &config.User{ - User: &iam.User{UserName: "test@test.com"}, + User: &scim.User{UserName: new("test@test.com")}, }, }, }, @@ -302,13 +302,13 @@ func TestRenderSummary(t *testing.T) { ID: "1", BaseResource: resources.BaseResource{URL: "https://url1"}, - JobSettings: jobs.JobSettings{Name: "job1-name"}, + JobSettings: jobs.JobSettings{Name: new("job1-name")}, }, "job2": { ID: "2", BaseResource: resources.BaseResource{URL: "https://url2"}, - JobSettings: jobs.JobSettings{Name: "job2-name"}, + JobSettings: jobs.JobSettings{Name: new("job2-name")}, }, }, Pipelines: map[string]*resources.Pipeline{ @@ -316,20 +316,20 @@ func TestRenderSummary(t *testing.T) { ID: "4", // no URL - CreatePipeline: pipelines.CreatePipeline{Name: "pipeline2-name"}, + CreatePipelineRequest: pipelines.CreatePipelineRequest{Name: new("pipeline2-name")}, }, "pipeline1": { ID: "3", BaseResource: resources.BaseResource{URL: "https://url3"}, - CreatePipeline: pipelines.CreatePipeline{Name: "pipeline1-name"}, + CreatePipelineRequest: pipelines.CreatePipelineRequest{Name: new("pipeline1-name")}, }, }, Schemas: map[string]*resources.Schema{ "schema1": { ID: "catalog.schema", - CreateSchema: catalog.CreateSchema{ - Name: "schema", + CreateSchema: resources.CreateSchema{ + Name: new("schema"), }, // no URL }, @@ -339,8 +339,8 @@ func TestRenderSummary(t *testing.T) { ID: "7", BaseResource: resources.BaseResource{URL: "https://url4"}, - CreateServingEndpoint: serving.CreateServingEndpoint{ - Name: "my_serving_endpoint", + CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{ + Name: new("my_serving_endpoint"), }, }, }, diff --git a/bundle/resources/completion_test.go b/bundle/resources/completion_test.go index 8e736a36b46..52c2993a51d 100644 --- a/bundle/resources/completion_test.go +++ b/bundle/resources/completion_test.go @@ -3,11 +3,12 @@ package resources import ( "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/stretchr/testify/assert" ) @@ -25,7 +26,7 @@ func TestCompletions_SkipDuplicates(t *testing.T) { }, Pipelines: map[string]*resources.Pipeline{ "foo": { - CreatePipeline: pipelines.CreatePipeline{}, + CreatePipelineRequest: pipelines.CreatePipelineRequest{}, }, }, }, @@ -50,7 +51,7 @@ func TestCompletions_Filter(t *testing.T) { }, Pipelines: map[string]*resources.Pipeline{ "bar": { - CreatePipeline: pipelines.CreatePipeline{}, + CreatePipelineRequest: pipelines.CreatePipelineRequest{}, }, }, }, diff --git a/bundle/resources/lookup_test.go b/bundle/resources/lookup_test.go index 328aca60f14..edf0881daea 100644 --- a/bundle/resources/lookup_test.go +++ b/bundle/resources/lookup_test.go @@ -3,11 +3,12 @@ package resources import ( "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -56,7 +57,7 @@ func TestLookup_MultipleFound(t *testing.T) { }, Pipelines: map[string]*resources.Pipeline{ "foo": { - CreatePipeline: pipelines.CreatePipeline{}, + CreatePipelineRequest: pipelines.CreatePipelineRequest{}, }, }, }, @@ -75,7 +76,7 @@ func TestLookup_Nominal(t *testing.T) { Jobs: map[string]*resources.Job{ "foo": { JobSettings: jobs.JobSettings{ - Name: "Foo job", + Name: new("Foo job"), }, }, }, @@ -107,7 +108,7 @@ func TestLookup_NominalWithFilters(t *testing.T) { }, Pipelines: map[string]*resources.Pipeline{ "bar": { - CreatePipeline: pipelines.CreatePipeline{}, + CreatePipelineRequest: pipelines.CreatePipelineRequest{}, }, }, }, diff --git a/bundle/run/app.go b/bundle/run/app.go index f7b347710de..de31d61d59d 100644 --- a/bundle/run/app.go +++ b/bundle/run/app.go @@ -4,14 +4,15 @@ import ( "context" "errors" "fmt" - "time" "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/appdeploy" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/run/output" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/libs/utils" + sdkapps "github.com/databricks/sdk-go/apps/v1" "github.com/spf13/cobra" ) @@ -34,12 +35,12 @@ func (a *appRunner) Name() string { return "" } - return a.app.Name + return utils.Deref(a.app.Name) } -func isAppComputeStopped(app *apps.App) bool { +func isAppComputeStopped(app *sdkapps.App) bool { return app.ComputeStatus == nil || - (app.ComputeStatus.State == apps.ComputeStateStopped || app.ComputeStatus.State == apps.ComputeStateError) + (app.ComputeStatus.State == apps.ComputeStatus_ComputeState_Stopped || app.ComputeStatus.State == apps.ComputeStatus_ComputeState_Error) } func (a *appRunner) Run(ctx context.Context, opts *Options) (output.RunOutput, error) { @@ -49,11 +50,12 @@ func (a *appRunner) Run(ctx context.Context, opts *Options) (output.RunOutput, e return nil, errors.New("app is not defined") } - logProgress(ctx, "Getting the status of the app "+app.Name) + appName := utils.Deref(app.Name) + logProgress(ctx, "Getting the status of the app "+appName) w := b.WorkspaceClient(ctx) // Check the status of the app first. - createdApp, err := w.Apps.Get(ctx, apps.GetAppRequest{Name: app.Name}) + createdApp, err := w.Apps.GetApp(ctx, sdkapps.GetAppRequest{Name: new(appName)}) if err != nil { return nil, err } @@ -79,7 +81,7 @@ func (a *appRunner) Run(ctx context.Context, opts *Options) (output.RunOutput, e // If the app is starting, we need to wait for it to be active before we can deploy it. if isAppComputeStarting(createdApp) { - _, err := w.Apps.WaitGetAppActive(ctx, app.Name, 20*time.Minute, nil) + _, err := appdeploy.WaitAppActive(ctx, w, appName, nil) if err != nil { return nil, err } @@ -91,12 +93,12 @@ func (a *appRunner) Run(ctx context.Context, opts *Options) (output.RunOutput, e return nil, err } - cmdio.LogString(ctx, "You can access the app at "+createdApp.Url) + cmdio.LogString(ctx, "You can access the app at "+utils.Deref(createdApp.Url)) return nil, nil } -func isAppComputeStarting(app *apps.App) bool { - return app.ComputeStatus != nil && app.ComputeStatus.State == apps.ComputeStateStarting +func isAppComputeStarting(app *sdkapps.App) bool { + return app.ComputeStatus != nil && app.ComputeStatus.State == apps.ComputeStatus_ComputeState_Starting } func (a *appRunner) start(ctx context.Context) error { @@ -104,18 +106,19 @@ func (a *appRunner) start(ctx context.Context) error { b := a.bundle w := b.WorkspaceClient(ctx) - logProgress(ctx, "Starting the app "+app.Name) - wait, err := w.Apps.Start(ctx, apps.StartAppRequest{Name: app.Name}) + appName := utils.Deref(app.Name) + logProgress(ctx, "Starting the app "+appName) + _, err := w.Apps.StartApp(ctx, sdkapps.StartAppRequest{Name: new(appName)}) if err != nil { return err } - startedApp, err := wait.OnProgress(func(p *apps.App) { + startedApp, err := appdeploy.WaitAppActive(ctx, w, appName, func(p *sdkapps.App) { if p.AppStatus == nil { return } logProgress(ctx, "App is starting...") - }).Get() + }) if err != nil { return err } @@ -138,8 +141,11 @@ func (a *appRunner) deploy(ctx context.Context) error { // source_code_path and config already have their ${resources.*} references resolved // against the deployed state during run setup (see // DeploymentBundle.ResolveConfigAgainstState), so they are usable as-is. - deployment := appdeploy.BuildDeployment(a.app.SourceCodePath, a.app.Config, a.app.GitSource) - return appdeploy.Deploy(ctx, w, a.app.Name, deployment) + deployment, err := appdeploy.BuildDeployment(utils.Deref(a.app.SourceCodePath), a.app.Config, a.app.GitSource) + if err != nil { + return err + } + return appdeploy.Deploy(ctx, w, utils.Deref(a.app.Name), deployment) } func (a *appRunner) Cancel(ctx context.Context) error { @@ -152,18 +158,19 @@ func (a *appRunner) Cancel(ctx context.Context) error { w := b.WorkspaceClient(ctx) - logProgress(ctx, "Stopping app "+app.Name) - wait, err := w.Apps.Stop(ctx, apps.StopAppRequest{Name: app.Name}) + appName := utils.Deref(app.Name) + logProgress(ctx, "Stopping app "+appName) + _, err := w.Apps.StopApp(ctx, sdkapps.StopAppRequest{Name: new(appName)}) if err != nil { return err } - _, err = wait.OnProgress(func(p *apps.App) { + _, err = appdeploy.WaitAppStopped(ctx, w, appName, func(p *sdkapps.App) { if p.AppStatus == nil { return } - logProgress(ctx, p.AppStatus.Message) - }).Get() + logProgress(ctx, utils.Deref(p.AppStatus.Message)) + }) logProgress(ctx, "App is stopped!") return err diff --git a/bundle/run/app_test.go b/bundle/run/app_test.go index 76946938ebb..45bfbb29f93 100644 --- a/bundle/run/app_test.go +++ b/bundle/run/app_test.go @@ -2,11 +2,10 @@ package run import ( "context" - "errors" + "encoding/json" "os" "path/filepath" "testing" - "time" "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/appdeploy" @@ -16,31 +15,88 @@ import ( "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/diag" + "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/libs/testserver" + "github.com/databricks/cli/libs/utils" "github.com/databricks/cli/libs/vfs" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/apps" - "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -type testAppRunner struct { - m *mocks.MockWorkspaceClient - b *bundle.Bundle - ctx context.Context +// fakeApps serves the apps API calls made by appRunner and records them. +type fakeApps struct { + t *testing.T + + // app is returned by GET /api/2.0/apps/my_app. + app map[string]any + // startedApp replaces app after a start request. + startedApp map[string]any + + // deployErrors is the number of deploy requests to reject before accepting one. + deployErrors int + + starts int + stops int + deployments []map[string]any + waited []string } -func (ta *testAppRunner) run(t *testing.T) { +func newFakeApps(t *testing.T, server *testserver.Server) *fakeApps { + f := &fakeApps{t: t} + server.Handle("GET", "/api/2.0/apps/{name}", func(req testserver.Request) any { + assert.Equal(t, "my_app", req.Vars["name"]) + return f.app + }) + server.Handle("POST", "/api/2.0/apps/{name}/start", func(req testserver.Request) any { + f.starts++ + f.app = f.startedApp + return f.app + }) + server.Handle("POST", "/api/2.0/apps/{name}/stop", func(req testserver.Request) any { + f.stops++ + f.app = appWithState("UNAVAILABLE", "STOPPED") + return f.app + }) + server.Handle("POST", "/api/2.0/apps/{name}/deployments", func(req testserver.Request) any { + if f.deployErrors > 0 { + f.deployErrors-- + return testserver.Response{ + StatusCode: 400, + Body: map[string]string{"error_code": "INVALID_STATE", "message": "deployment in progress"}, + } + } + var body map[string]any + assert.NoError(t, json.Unmarshal(req.Body, &body)) + f.deployments = append(f.deployments, body) + return map[string]any{"deployment_id": "new_deployment_id", "status": map[string]any{"state": "IN_PROGRESS"}} + }) + server.Handle("GET", "/api/2.0/apps/{name}/deployments/{id}", func(req testserver.Request) any { + f.waited = append(f.waited, req.Vars["id"]) + return map[string]any{"deployment_id": req.Vars["id"], "status": map[string]any{"state": "SUCCEEDED"}} + }) + return f +} + +func (f *fakeApps) run(ctx context.Context, b *bundle.Bundle) { r := appRunner{ key: "my_app", - bundle: ta.b, - app: ta.b.Config.Resources.Apps["my_app"], + bundle: b, + app: b.Config.Resources.Apps["my_app"], } - _, err := r.Run(ta.ctx, &Options{}) - require.NoError(t, err) + _, err := r.Run(ctx, &Options{}) + require.NoError(f.t, err) +} + +func (f *fakeApps) assertDeployedOnce() { + expected := []map[string]any{{ + "mode": "SNAPSHOT", + "source_code_path": "/Workspace/Users/foo@bar.test/files/my_app", + }} + assert.Equal(f.t, expected, f.deployments) } -func setupBundle(t *testing.T) (context.Context, *bundle.Bundle, *mocks.MockWorkspaceClient) { +func setupBundle(t *testing.T) (context.Context, *bundle.Bundle, *testserver.Server) { root := t.TempDir() err := os.MkdirAll(filepath.Join(root, "my_app"), 0o700) require.NoError(t, err) @@ -57,8 +113,8 @@ func setupBundle(t *testing.T) (context.Context, *bundle.Bundle, *mocks.MockWork Apps: map[string]*resources.App{ "my_app": { App: apps.App{ - Name: "my_app", - SourceCodePath: "./my_app", + Name: new("my_app"), + SourceCodePath: new("./my_app"), }, }, }, @@ -66,8 +122,8 @@ func setupBundle(t *testing.T) (context.Context, *bundle.Bundle, *mocks.MockWork }, } - mwc := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(mwc.WorkspaceClient) + w, server := bundletest.NewClients(t) + b.SetWorkpaceClient(w) bundletest.SetLocation(b, "resources.apps.my_app", []diag.Location{{File: filepath.Join(root, "./databricks.yml")}}) ctx := cmdio.MockDiscard(t.Context()) @@ -79,188 +135,77 @@ func setupBundle(t *testing.T) (context.Context, *bundle.Bundle, *mocks.MockWork ) require.Empty(t, diags) - return ctx, b, mwc + return ctx, b, server } -func setupTestApp(t *testing.T, initialAppState apps.ApplicationState, initialComputeState apps.ComputeState) *testAppRunner { - ctx, b, mwc := setupBundle(t) - - appApi := mwc.GetMockAppsAPI() - appApi.EXPECT().Get(mock.Anything, apps.GetAppRequest{ - Name: "my_app", - }).Return(&apps.App{ - Name: "my_app", - AppStatus: &apps.ApplicationStatus{ - State: initialAppState, - }, - ComputeStatus: &apps.ComputeStatus{ - State: initialComputeState, - }, - }, nil) - - wait := &apps.WaitGetDeploymentAppSucceeded[apps.AppDeployment]{ - Poll: func(_ time.Duration, _ func(*apps.AppDeployment)) (*apps.AppDeployment, error) { - return nil, nil - }, - } - appApi.EXPECT().Deploy(mock.Anything, apps.CreateAppDeploymentRequest{ - AppName: "my_app", - AppDeployment: apps.AppDeployment{ - Mode: apps.AppDeploymentModeSnapshot, - SourceCodePath: "/Workspace/Users/foo@bar.test/files/my_app", - }, - }).Return(wait, nil) - - return &testAppRunner{ - m: mwc, - b: b, - ctx: ctx, +func appWithState(appState, computeState string) map[string]any { + return map[string]any{ + "name": "my_app", + "app_status": map[string]any{"state": appState}, + "compute_status": map[string]any{"state": computeState}, } } func TestAppRunStartedApp(t *testing.T) { - r := setupTestApp(t, apps.ApplicationStateRunning, apps.ComputeStateActive) - r.run(t) + ctx, b, server := setupBundle(t) + f := newFakeApps(t, server) + f.app = appWithState("RUNNING", "ACTIVE") + + f.run(ctx, b) + assert.Equal(t, 0, f.starts) + f.assertDeployedOnce() } func TestAppRunStoppedApp(t *testing.T) { - r := setupTestApp(t, apps.ApplicationStateCrashed, apps.ComputeStateStopped) - - appsApi := r.m.GetMockAppsAPI() - appsApi.EXPECT().Start(mock.Anything, apps.StartAppRequest{ - Name: "my_app", - }).Return(&apps.WaitGetAppActive[apps.App]{ - Poll: func(_ time.Duration, _ func(*apps.App)) (*apps.App, error) { - return &apps.App{ - Name: "my_app", - AppStatus: &apps.ApplicationStatus{ - State: apps.ApplicationStateRunning, - }, - ComputeStatus: &apps.ComputeStatus{ - State: apps.ComputeStateActive, - }, - }, nil - }, - }, nil) - - r.run(t) + ctx, b, server := setupBundle(t) + f := newFakeApps(t, server) + f.app = appWithState("CRASHED", "STOPPED") + f.startedApp = appWithState("RUNNING", "ACTIVE") + + f.run(ctx, b) + assert.Equal(t, 1, f.starts) + f.assertDeployedOnce() } func TestAppRunWithAnActiveDeploymentInProgress(t *testing.T) { - r := setupTestApp(t, apps.ApplicationStateCrashed, apps.ComputeStateStopped) - - appsApi := r.m.GetMockAppsAPI() - appsApi.EXPECT().Start(mock.Anything, apps.StartAppRequest{ - Name: "my_app", - }).Return(&apps.WaitGetAppActive[apps.App]{ - Poll: func(_ time.Duration, _ func(*apps.App)) (*apps.App, error) { - return &apps.App{ - Name: "my_app", - AppStatus: &apps.ApplicationStatus{ - State: apps.ApplicationStateRunning, - }, - ComputeStatus: &apps.ComputeStatus{ - State: apps.ComputeStateActive, - }, - ActiveDeployment: &apps.AppDeployment{ - DeploymentId: "active_deployment_id", - Status: &apps.AppDeploymentStatus{ - State: apps.AppDeploymentStateInProgress, - }, - }, - PendingDeployment: &apps.AppDeployment{ - DeploymentId: "pending_deployment_id", - Status: &apps.AppDeploymentStatus{ - State: apps.AppDeploymentStateCancelled, - }, - }, - }, nil - }, - }, nil) - - appsApi.EXPECT().WaitGetDeploymentAppSucceeded(mock.Anything, "my_app", "active_deployment_id", mock.Anything, mock.Anything).Return(nil, nil) + ctx, b, server := setupBundle(t) + f := newFakeApps(t, server) + f.app = appWithState("CRASHED", "STOPPED") + f.startedApp = appWithState("RUNNING", "ACTIVE") + f.startedApp["active_deployment"] = map[string]any{ + "deployment_id": "active_deployment_id", + "status": map[string]any{"state": "IN_PROGRESS"}, + } + f.startedApp["pending_deployment"] = map[string]any{ + "deployment_id": "pending_deployment_id", + "status": map[string]any{"state": "CANCELLED"}, + } - r.run(t) + f.run(ctx, b) + assert.Equal(t, []string{"active_deployment_id", "new_deployment_id"}, f.waited) + f.assertDeployedOnce() } func TestAppDeployWithDeploymentInProgress(t *testing.T) { - ctx, b, mwc := setupBundle(t) - - appApi := mwc.GetMockAppsAPI() - appApi.EXPECT().Get(mock.Anything, apps.GetAppRequest{ - Name: "my_app", - }).Return(&apps.App{ - Name: "my_app", - AppStatus: &apps.ApplicationStatus{ - State: apps.ApplicationStateRunning, - }, - ComputeStatus: &apps.ComputeStatus{ - State: apps.ComputeStateActive, - }, - }, nil).Once() - - wait := &apps.WaitGetDeploymentAppSucceeded[apps.AppDeployment]{ - Poll: func(_ time.Duration, _ func(*apps.AppDeployment)) (*apps.AppDeployment, error) { - return nil, nil - }, + ctx, b, server := setupBundle(t) + f := newFakeApps(t, server) + f.app = appWithState("RUNNING", "ACTIVE") + f.app["active_deployment"] = map[string]any{ + "deployment_id": "active_deployment_id", + "status": map[string]any{"state": "IN_PROGRESS"}, } + // The first deployment is rejected; the runner waits for the active + // deployment and retries. + f.deployErrors = 1 - // First deployment fails - appApi.EXPECT().Deploy(mock.Anything, apps.CreateAppDeploymentRequest{ - AppName: "my_app", - AppDeployment: apps.AppDeployment{ - Mode: apps.AppDeploymentModeSnapshot, - SourceCodePath: "/Workspace/Users/foo@bar.test/files/my_app", - }, - }).Return(nil, errors.New("deployment in progress")).Once() - - // After first deployment fails, we should get the app and wait for the deployment to complete - appApi.EXPECT().Get(mock.Anything, apps.GetAppRequest{ - Name: "my_app", - }).Return(&apps.App{ - Name: "my_app", - ActiveDeployment: &apps.AppDeployment{ - DeploymentId: "active_deployment_id", - Status: &apps.AppDeploymentStatus{ - State: apps.AppDeploymentStateInProgress, - }, - }, - }, nil).Once() - - appApi.EXPECT().WaitGetDeploymentAppSucceeded(mock.Anything, "my_app", "active_deployment_id", mock.Anything, mock.Anything).Return(nil, nil) - - // Second one should succeed - appApi.EXPECT().Deploy(mock.Anything, apps.CreateAppDeploymentRequest{ - AppName: "my_app", - AppDeployment: apps.AppDeployment{ - Mode: apps.AppDeploymentModeSnapshot, - SourceCodePath: "/Workspace/Users/foo@bar.test/files/my_app", - }, - }).Return(wait, nil).Once() - - r := &testAppRunner{ - m: mwc, - b: b, - ctx: ctx, - } - r.run(t) + f.run(ctx, b) + assert.Equal(t, []string{"active_deployment_id", "new_deployment_id"}, f.waited) + f.assertDeployedOnce() } func TestStopApp(t *testing.T) { - ctx, b, mwc := setupBundle(t) - appsApi := mwc.GetMockAppsAPI() - appsApi.EXPECT().Stop(mock.Anything, apps.StopAppRequest{ - Name: "my_app", - }).Return(&apps.WaitGetAppStopped[apps.App]{ - Poll: func(_ time.Duration, _ func(*apps.App)) (*apps.App, error) { - return &apps.App{ - Name: "my_app", - AppStatus: &apps.ApplicationStatus{ - State: apps.ApplicationStateUnavailable, - }, - }, nil - }, - }, nil) + ctx, b, server := setupBundle(t) + f := newFakeApps(t, server) r := appRunner{ key: "my_app", @@ -270,11 +215,12 @@ func TestStopApp(t *testing.T) { err := r.Cancel(ctx) require.NoError(t, err) + assert.Equal(t, 1, f.stops) } func TestBuildAppDeploymentWithValueFrom(t *testing.T) { app := &resources.App{ - SourceCodePath: "/path/to/app", + SourceCodePath: new("/path/to/app"), Config: &resources.AppConfig{ Command: []string{"python", "app.py"}, Env: []resources.AppEnvVar{ @@ -286,37 +232,35 @@ func TestBuildAppDeploymentWithValueFrom(t *testing.T) { Name: "SECRET_VAR", ValueFrom: "secrets/my-secret", }, - { - Name: "COMBINED_VAR", - Value: "default_value", - ValueFrom: "secrets/override", - }, }, }, } - deployment := appdeploy.BuildDeployment(app.SourceCodePath, app.Config, app.GitSource) - - require.Equal(t, apps.AppDeploymentModeSnapshot, deployment.Mode) - require.Equal(t, "/path/to/app", deployment.SourceCodePath) - require.Len(t, deployment.Command, 2) - require.Equal(t, "python", deployment.Command[0]) - require.Equal(t, "app.py", deployment.Command[1]) + sdkDeployment, err := appdeploy.BuildDeployment(utils.Deref(app.SourceCodePath), app.Config, app.GitSource) + require.NoError(t, err) + deployment, err := apps.AppDeploymentFromSDK(sdkDeployment) + require.NoError(t, err) - require.Len(t, deployment.EnvVars, 3) + require.Equal(t, apps.AppDeployment_Mode_Snapshot, deployment.Mode) + require.Equal(t, "/path/to/app", utils.Deref(deployment.SourceCodePath)) + require.Equal(t, []string{"python", "app.py"}, deployment.Command) - // Regular env var with value - require.Equal(t, "REGULAR_VAR", deployment.EnvVars[0].Name) - require.Equal(t, "regular_value", deployment.EnvVars[0].Value) - require.Empty(t, deployment.EnvVars[0].ValueFrom) + require.Equal(t, []apps.EnvVar{ + {Name: new("REGULAR_VAR"), Value: new("regular_value")}, + {Name: new("SECRET_VAR"), ValueFrom: new("secrets/my-secret")}, + }, deployment.EnvVars) +} - // Env var with value_from - require.Equal(t, "SECRET_VAR", deployment.EnvVars[1].Name) - require.Empty(t, deployment.EnvVars[1].Value) - require.Equal(t, "secrets/my-secret", deployment.EnvVars[1].ValueFrom) +// value and value_from are a oneof in the Apps API. +func TestBuildAppDeploymentRejectsValueAndValueFrom(t *testing.T) { + config := &resources.AppConfig{ + Env: []resources.AppEnvVar{{ + Name: "COMBINED_VAR", + Value: "default_value", + ValueFrom: "secrets/override", + }}, + } - // Env var with both value and value_from - require.Equal(t, "COMBINED_VAR", deployment.EnvVars[2].Name) - require.Equal(t, "default_value", deployment.EnvVars[2].Value) - require.Equal(t, "secrets/override", deployment.EnvVars[2].ValueFrom) + _, err := appdeploy.BuildDeployment("/path/to/app", config, nil) + require.ErrorContains(t, err, "only one of value, value_from can be set") } diff --git a/bundle/run/job.go b/bundle/run/job.go index 98f059e5784..b59d4ee063d 100644 --- a/bundle/run/job.go +++ b/bundle/run/job.go @@ -10,12 +10,17 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/bundle/internal/poll" "github.com/databricks/cli/bundle/run/output" "github.com/databricks/cli/bundle/run/progress" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go/service/jobs" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" "golang.org/x/sync/errgroup" ) @@ -34,49 +39,59 @@ func (r *jobRunner) Name() string { if r.job == nil { return "" } - return r.job.Name + return utils.Deref(r.job.Name) } -func isFailed(task jobs.RunTask) bool { - return task.State.LifeCycleState == jobs.RunLifeCycleStateInternalError || - (task.State.LifeCycleState == jobs.RunLifeCycleStateTerminated && - task.State.ResultState == jobs.RunResultStateFailed) +func taskState(task sdkjobs.RunTask) sdkjobs.RunState { + if task.State == nil { + return sdkjobs.RunState{} + } + return *task.State +} + +func isFailed(task sdkjobs.RunTask) bool { + state := taskState(task) + return state.LifeCycleState == jobs.RunLifeCycleState_RunLifeCycleState_InternalError || + (state.LifeCycleState == jobs.RunLifeCycleState_RunLifeCycleState_Terminated && + state.ResultState == jobs.RunResultState_RunResultState_Failed) } -func isSuccess(task jobs.RunTask) bool { - return task.State.LifeCycleState == jobs.RunLifeCycleStateTerminated && - task.State.ResultState == jobs.RunResultStateSuccess +func isSuccess(task sdkjobs.RunTask) bool { + state := taskState(task) + return state.LifeCycleState == jobs.RunLifeCycleState_RunLifeCycleState_Terminated && + state.ResultState == jobs.RunResultState_RunResultState_Success } func (r *jobRunner) logFailedTasks(ctx context.Context, runId int64) { w := r.bundle.WorkspaceClient(ctx) - run, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{ - RunId: runId, - }) + run, err := output.GetRun(ctx, w, runId) if err != nil { log.Errorf(ctx, "failed to log job run. Error: %s", err) return } - if run.State.ResultState == jobs.RunResultStateSuccess { + if run.State != nil && run.State.ResultState == jobs.RunResultState_RunResultState_Success { return } for _, task := range run.Tasks { + taskKey := utils.Deref(task.TaskKey) if isSuccess(task) { - log.Infof(ctx, "task %s completed successfully", cmdio.Green(ctx, task.TaskKey)) + log.Infof(ctx, "task %s completed successfully", cmdio.Green(ctx, taskKey)) } else if isFailed(task) { - taskInfo, err := w.Jobs.GetRunOutput(ctx, jobs.GetRunOutputRequest{ + taskInfo, err := w.Jobs.GetRunOutput(ctx, sdkjobs.GetRunOutputRequest{ RunId: task.RunId, }) if err != nil { - log.Errorf(ctx, "task %s failed. Unable to fetch error trace: %s", cmdio.Red(ctx, task.TaskKey), err) + log.Errorf(ctx, "task %s failed. Unable to fetch error trace: %s", cmdio.Red(ctx, taskKey), err) continue } - cmdio.Log(ctx, progress.NewTaskErrorEvent(task.TaskKey, taskInfo.Error, taskInfo.ErrorTrace)) + taskError := utils.Deref(taskInfo.Error) + taskTrace := utils.Deref(taskInfo.ErrorTrace) + cmdio.Log(ctx, progress.NewTaskErrorEvent(taskKey, taskError, taskTrace)) log.Errorf(ctx, "Task %s failed!\nError:\n%s\nTrace:\n%s", - cmdio.Red(ctx, task.TaskKey), taskInfo.Error, taskInfo.ErrorTrace) + cmdio.Red(ctx, taskKey), taskError, taskTrace) } else { log.Infof(ctx, "task %s is in state %s", - cmdio.Yellow(ctx, task.TaskKey), task.State.LifeCycleState) + cmdio.Yellow(ctx, taskKey), taskState(task).LifeCycleState) } } } @@ -85,11 +100,11 @@ func (r *jobRunner) logFailedTasks(ctx context.Context, runId int64) { // for monitoring progress. type jobRunMonitor struct { ctx context.Context - prevState *jobs.RunState + prevState *sdkjobs.RunState } // onProgress is the single callback that handles all state tracking and logging. -func (m *jobRunMonitor) onProgress(info *jobs.Run) { +func (m *jobRunMonitor) onProgress(info *sdkjobs.GetRunResponse) { state := info.State if state == nil { return @@ -97,7 +112,7 @@ func (m *jobRunMonitor) onProgress(info *jobs.Run) { // First time we see this run. if m.prevState == nil { - runURL := workspaceurls.ModernizeJobRunPageURL(info.RunPageUrl) + runURL := workspaceurls.ModernizeJobRunPageURL(utils.Deref(info.RunPageUrl)) log.Infof(m.ctx, "Run available at %s", runURL) cmdio.Log(m.ctx, progress.NewJobRunUrlEvent(runURL)) } @@ -112,13 +127,19 @@ func (m *jobRunMonitor) onProgress(info *jobs.Run) { // Capture current state as previous state for next call. m.prevState = state + runState, err := jobs.RunStateFromSDK(state) + if err != nil { + log.Warnf(m.ctx, "cannot convert run state: %s", err) + return + } + // Log progress event both to the terminal (in place or append), and to the logger. event := &progress.JobProgressEvent{ Timestamp: time.Now(), - JobId: info.JobId, - RunId: info.RunId, - RunName: info.RunName, - State: *info.State, + JobId: utils.Deref(info.JobId), + RunId: utils.Deref(info.RunId), + RunName: utils.Deref(info.RunName), + State: *runState, } cmdio.Log(m.ctx, event) log.Info(m.ctx, event.String()) @@ -154,50 +175,52 @@ func (r *jobRunner) Run(ctx context.Context, opts *Options) (output.RunOutput, e if err != nil { return nil, fmt.Errorf("cannot start job: %w", err) } + runId := waiter.GetRunId() if opts.NoWait { - details, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{ - RunId: waiter.RunId, + details, err := w.Jobs.GetRun(ctx, sdkjobs.GetRunRequest{ + RunId: new(runId), }) if err != nil { return nil, err } - cmdio.Log(ctx, progress.NewJobRunUrlEvent(workspaceurls.ModernizeJobRunPageURL(details.RunPageUrl))) + cmdio.Log(ctx, progress.NewJobRunUrlEvent(workspaceurls.ModernizeJobRunPageURL(utils.Deref(details.RunPageUrl)))) return nil, nil } - run, err := waiter.OnProgress(monitor.onProgress).GetWithTimeout(jobRunTimeout) + run, err := waitForRun(ctx, w, runId, jobRunTimeout, monitor.onProgress) if err != nil { - r.logFailedTasks(ctx, waiter.RunId) + r.logFailedTasks(ctx, runId) } if err != nil { return nil, err } - if run.State.LifeCycleState == jobs.RunLifeCycleStateSkipped { + stateMessage := utils.Deref(run.State.StateMessage) + if run.State.LifeCycleState == jobs.RunLifeCycleState_RunLifeCycleState_Skipped { log.Infof(ctx, "Run was skipped!") - return nil, fmt.Errorf("run skipped: %s", run.State.StateMessage) + return nil, fmt.Errorf("run skipped: %s", stateMessage) } switch run.State.ResultState { // The run was canceled at user request. - case jobs.RunResultStateCanceled: + case jobs.RunResultState_RunResultState_Canceled: log.Infof(ctx, "Run was cancelled!") - return nil, fmt.Errorf("run canceled: %s", run.State.StateMessage) + return nil, fmt.Errorf("run canceled: %s", stateMessage) // The task completed with an error. - case jobs.RunResultStateFailed: + case jobs.RunResultState_RunResultState_Failed: log.Infof(ctx, "Run has failed!") - return nil, fmt.Errorf("run failed: %s", run.State.StateMessage) + return nil, fmt.Errorf("run failed: %s", stateMessage) // The task completed successfully. - case jobs.RunResultStateSuccess: + case jobs.RunResultState_RunResultState_Success: log.Infof(ctx, "Run has completed successfully!") - return output.GetJobOutput(ctx, r.bundle.WorkspaceClient(ctx), waiter.RunId) + return output.GetJobOutput(ctx, r.bundle.WorkspaceClient(ctx), runId) // The run was stopped after reaching the timeout. - case jobs.RunResultStateTimedout: + case jobs.RunResultState_RunResultState_Timedout: log.Infof(ctx, "Run has timed out!") - return nil, fmt.Errorf("run timed out: %s", run.State.StateMessage) + return nil, fmt.Errorf("run timed out: %s", stateMessage) // TODO: handle other result states. default: @@ -252,12 +275,15 @@ func (r *jobRunner) Cancel(ctx context.Context) error { return fmt.Errorf("job ID is not an integer: %s", r.job.ID) } - runs, err := w.Jobs.ListRunsAll(ctx, jobs.ListRunsRequest{ - ActiveOnly: true, - JobId: jobID, - }) - if err != nil { - return err + var runs []*sdkjobs.BaseRun + for run, err := range w.Jobs.ListRunsIter(ctx, sdkjobs.ListRunsRequest{ + StateConstraint: &sdkjobs.ListRunsRequest_StateConstraint_ActiveOnly{ActiveOnly: true}, + JobId: new(jobID), + }) { + if err != nil { + return err + } + runs = append(runs, run) } if len(runs) == 0 { @@ -268,14 +294,14 @@ func (r *jobRunner) Cancel(ctx context.Context) error { for _, run := range runs { runId := run.RunId errGroup.Go(func() error { - wait, err := w.Jobs.CancelRun(errCtx, jobs.CancelRun{ + wait, err := w.Jobs.CancelRun(errCtx, sdkjobs.CancelRunRequest{ RunId: runId, }) if err != nil { return err } // Waits for the Terminated or Skipped state - _, err = wait.GetWithTimeout(jobRunTimeout) + _, err = wait.Wait(errCtx, lro.WithTimeout(jobRunTimeout)) return err }) } @@ -291,7 +317,7 @@ func (r *jobRunner) Restart(ctx context.Context, opts *Options) (output.RunOutpu // New job runs will be queued instead and will wait for existing runs to finish. // In this case, we need to cancel the existing runs before starting a new one. continuous := r.job.Continuous - if continuous != nil && continuous.PauseStatus == jobs.PauseStatusUnpaused { + if continuous != nil && continuous.PauseStatus == pauseStatusUnpaused { return r.Run(ctx, opts) } @@ -313,3 +339,39 @@ func (r *jobRunner) ParseArgs(args []string, opts *Options) error { func (r *jobRunner) CompleteArgs(args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return r.posArgsHandler().CompleteArgs(args, toComplete) } + +// sdk-go only names PAUSED (UNPAUSED is the proto default), but configurations +// and the API use the explicit "UNPAUSED" value. +const pauseStatusUnpaused jobs.SchedulePauseStatus = "UNPAUSED" + +// waitForRun polls the run until it is TERMINATED or SKIPPED, calling +// onProgress after every poll, with the error messages of the previous SDK's +// run waiter. +func waitForRun(ctx context.Context, w *sdkclients.Clients, runId int64, timeout time.Duration, onProgress func(*sdkjobs.GetRunResponse)) (*sdkjobs.GetRunResponse, error) { + return poll.Until(ctx, timeout, func(ctx context.Context) (poll.Status[sdkjobs.GetRunResponse], error) { + run, err := output.GetRun(ctx, w, runId) + if err != nil { + return poll.Status[sdkjobs.GetRunResponse]{}, err + } + onProgress(run) + var state sdkjobs.RunState + if run.State != nil { + state = *run.State + } + statusMessage := utils.Deref(state.StateMessage) + switch state.LifeCycleState { + case jobs.RunLifeCycleState_RunLifeCycleState_Terminated, jobs.RunLifeCycleState_RunLifeCycleState_Skipped: + return poll.Status[sdkjobs.GetRunResponse]{Done: true, Result: run}, nil + case jobs.RunLifeCycleState_RunLifeCycleState_InternalError: + return poll.Status[sdkjobs.GetRunResponse]{}, fmt.Errorf("failed to reach %s or %s, got %s: %s", + jobs.RunLifeCycleState_RunLifeCycleState_Terminated, jobs.RunLifeCycleState_RunLifeCycleState_Skipped, + state.LifeCycleState, statusMessage) + case jobs.RunLifeCycleState_RunLifeCycleState_Unspecified, jobs.RunLifeCycleState_RunLifeCycleState_Pending, + jobs.RunLifeCycleState_RunLifeCycleState_Running, jobs.RunLifeCycleState_RunLifeCycleState_Terminating, + jobs.RunLifeCycleState_RunLifeCycleState_Blocked, jobs.RunLifeCycleState_RunLifeCycleState_WaitingForRetry, + jobs.RunLifeCycleState_RunLifeCycleState_Queued: + // Still running or queued; keep polling + } + return poll.Status[sdkjobs.GetRunResponse]{Message: statusMessage}, nil + }) +} diff --git a/bundle/run/job_args.go b/bundle/run/job_args.go index dea9e71e560..910e92c21c0 100644 --- a/bundle/run/job_args.go +++ b/bundle/run/job_args.go @@ -4,6 +4,8 @@ import ( "maps" "slices" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config/resources" "github.com/spf13/cobra" ) @@ -30,7 +32,7 @@ func (a jobParameterArgs) ParseArgs(args []string, opts *Options) error { func (a jobParameterArgs) CompleteArgs(args []string, toComplete string) ([]string, cobra.ShellCompDirective) { var completions []string for _, param := range a.Parameters { - completions = append(completions, param.Name) + completions = append(completions, utils.Deref(param.Name)) } return genericCompleteKeyValueArgs(args, toComplete, completions) } diff --git a/bundle/run/job_args_test.go b/bundle/run/job_args_test.go index ad7433dbb7a..68a75eb1a65 100644 --- a/bundle/run/job_args_test.go +++ b/bundle/run/job_args_test.go @@ -3,22 +3,23 @@ package run import ( "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/assert" ) func TestJobParameterArgs(t *testing.T) { a := jobParameterArgs{ &resources.Job{ - Parameters: []jobs.JobParameterDefinition{ + Parameters: []jobs.JobLevelParameter{ { - Name: "foo", - Default: "value", + Name: new("foo"), + Default: new("value"), }, { - Name: "bar", - Default: "value", + Name: new("bar"), + Default: new("value"), }, }, }, @@ -68,7 +69,7 @@ func TestJobParameterArgs(t *testing.T) { func TestJobTaskNotebookParamArgs(t *testing.T) { a := jobTaskNotebookParamArgs{ &resources.Job{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { NotebookTask: &jobs.NotebookTask{ BaseParameters: map[string]string{ diff --git a/bundle/run/job_options.go b/bundle/run/job_options.go index ce5e2004a9e..5a2af16506c 100644 --- a/bundle/run/job_options.go +++ b/bundle/run/job_options.go @@ -7,7 +7,8 @@ import ( "strconv" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/utils" + jobs "github.com/databricks/sdk-go/jobs/v2" flag "github.com/spf13/pflag" ) @@ -90,13 +91,13 @@ func (o *JobOptions) Validate(job *resources.Job) error { found := false for _, t := range job.Tasks { - if t.TaskKey == task { + if utils.Deref(t.TaskKey) == task { found = true break } } if !found { - return fmt.Errorf("task %#v not found in job %#v", task, job.Name) + return fmt.Errorf("task %#v not found in job %#v", task, utils.Deref(job.Name)) } } } @@ -104,7 +105,7 @@ func (o *JobOptions) Validate(job *resources.Job) error { return nil } -func (o *JobOptions) validatePipelineParams() (*jobs.PipelineParams, error) { +func (o *JobOptions) validatePipelineParams() (*jobs.PipelineParameters, error) { if len(o.pipelineParams) == 0 { return nil, nil } @@ -120,14 +121,16 @@ func (o *JobOptions) validatePipelineParams() (*jobs.PipelineParams, error) { return nil, defaultErr } - pipelineParams := &jobs.PipelineParams{ - FullRefresh: b, + // full_refresh=false is the API default, so it is not sent. + pipelineParams := &jobs.PipelineParameters{} + if b { + pipelineParams.FullRefresh = new(true) } return pipelineParams, nil } -func (o *JobOptions) toPayload(job *resources.Job, jobID int64) (*jobs.RunNow, error) { +func (o *JobOptions) toPayload(job *resources.Job, jobID int64) (*jobs.RunNowRequest, error) { if err := o.Validate(job); err != nil { return nil, err } @@ -137,8 +140,8 @@ func (o *JobOptions) toPayload(job *resources.Job, jobID int64) (*jobs.RunNow, e return nil, err } - payload := &jobs.RunNow{ - JobId: jobID, + payload := &jobs.RunNowRequest{ + JobId: new(jobID), DbtCommands: o.dbtCommands, JarParams: o.jarParams, diff --git a/bundle/run/job_options_test.go b/bundle/run/job_options_test.go index e54fdba7e32..94673361e58 100644 --- a/bundle/run/job_options_test.go +++ b/bundle/run/job_options_test.go @@ -3,8 +3,9 @@ package run import ( "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/jobs" flag "github.com/spf13/pflag" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -188,10 +189,10 @@ func TestJobOptionsSqlParamsMultiple(t *testing.T) { func TestJobOptionsValidateIfJobHasJobParameters(t *testing.T) { job := &resources.Job{ - Parameters: []jobs.JobParameterDefinition{ + Parameters: []jobs.JobLevelParameter{ { - Name: "param", - Default: "value", + Name: new("param"), + Default: new("value"), }, }, } @@ -217,7 +218,7 @@ func TestJobOptionsValidateIfJobHasJobParameters(t *testing.T) { func TestJobOptionsValidateIfJobHasNoJobParameters(t *testing.T) { job := &resources.Job{ - Parameters: []jobs.JobParameterDefinition{}, + Parameters: []jobs.JobLevelParameter{}, } { diff --git a/bundle/run/job_test.go b/bundle/run/job_test.go index 0343b09e728..afd7b95611a 100644 --- a/bundle/run/job_test.go +++ b/bundle/run/job_test.go @@ -1,26 +1,28 @@ package run import ( - "errors" + "encoding/json" + "slices" + "sync" "testing" - "time" "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/stretchr/testify/mock" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/testserver" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestConvertPythonParams(t *testing.T) { job := &resources.Job{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ {PythonWheelTask: &jobs.PythonWheelTask{ - PackageName: "my_test_code", - EntryPoint: "run", + PackageName: new("my_test_code"), + EntryPoint: new("run"), }}, }, } @@ -53,9 +55,24 @@ func TestConvertPythonParams(t *testing.T) { require.Equal(t, `["param1","param2","param3"]`, opts.Job.notebookParams["__python_params"]) } -func TestJobRunnerCancel(t *testing.T) { +// fakeJobs serves the jobs API calls made by jobRunner and records them. +type fakeJobs struct { + mu sync.Mutex + + // activeRuns is returned by runs/list. + activeRuns []int64 + // getRunError, if set, is returned by runs/get. + getRunError *testserver.Response + + listCalls int + cancelled []int64 + runNowJobs []int64 +} + +func newJobRunner(t *testing.T, settings jobs.JobSettings) (jobRunner, *fakeJobs) { job := &resources.Job{ - ID: "123", + ID: "123", + JobSettings: settings, } b := &bundle.Bundle{ Config: config.Root{ @@ -67,223 +84,128 @@ func TestJobRunnerCancel(t *testing.T) { }, } - runner := jobRunner{key: "test", bundle: b, job: job} + w, server := bundletest.NewClients(t) + b.SetWorkpaceClient(w) + + f := &fakeJobs{} + server.Handle("GET", "/api/2.2/jobs/runs/list", func(req testserver.Request) any { + f.mu.Lock() + defer f.mu.Unlock() + assert.Equal(t, "123", req.URL.Query().Get("job_id")) + assert.Equal(t, "true", req.URL.Query().Get("active_only")) + f.listCalls++ + var runs []map[string]any + for _, id := range f.activeRuns { + runs = append(runs, map[string]any{"run_id": id}) + } + return map[string]any{"runs": runs} + }) + server.Handle("POST", "/api/2.2/jobs/runs/cancel", func(req testserver.Request) any { + f.mu.Lock() + defer f.mu.Unlock() + var body struct { + RunId int64 `json:"run_id"` + } + assert.NoError(t, json.Unmarshal(req.Body, &body)) + f.cancelled = append(f.cancelled, body.RunId) + return map[string]any{} + }) + server.Handle("POST", "/api/2.2/jobs/run-now", func(req testserver.Request) any { + f.mu.Lock() + defer f.mu.Unlock() + var body struct { + JobId int64 `json:"job_id"` + } + assert.NoError(t, json.Unmarshal(req.Body, &body)) + f.runNowJobs = append(f.runNowJobs, body.JobId) + return map[string]any{"run_id": 456} + }) + server.Handle("GET", "/api/2.2/jobs/runs/get", func(req testserver.Request) any { + f.mu.Lock() + defer f.mu.Unlock() + if f.getRunError != nil { + return *f.getRunError + } + return map[string]any{ + "run_id": req.URL.Query().Get("run_id"), + "state": map[string]any{"life_cycle_state": "TERMINATED", "result_state": "SUCCESS"}, + } + }) - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) + return jobRunner{key: "test", bundle: b, job: job}, f +} - jobApi := m.GetMockJobsAPI() - jobApi.EXPECT().ListRunsAll(mock.Anything, jobs.ListRunsRequest{ - ActiveOnly: true, - JobId: 123, - }).Return([]jobs.BaseRun{ - {RunId: 1}, - {RunId: 2}, - }, nil) +func (f *fakeJobs) cancelledRuns() []int64 { + f.mu.Lock() + defer f.mu.Unlock() + return slices.Sorted(slices.Values(f.cancelled)) +} - mockWait := &jobs.WaitGetRunJobTerminatedOrSkipped[struct{}]{ - Poll: func(time time.Duration, f func(j *jobs.Run)) (*jobs.Run, error) { - return nil, nil - }, - } - jobApi.EXPECT().CancelRun(mock.Anything, jobs.CancelRun{ - RunId: 1, - }).Return(mockWait, nil) - jobApi.EXPECT().CancelRun(mock.Anything, jobs.CancelRun{ - RunId: 2, - }).Return(mockWait, nil) +func TestJobRunnerCancel(t *testing.T) { + runner, f := newJobRunner(t, jobs.JobSettings{}) + f.activeRuns = []int64{1, 2} err := runner.Cancel(t.Context()) require.NoError(t, err) + assert.Equal(t, []int64{1, 2}, f.cancelledRuns()) } func TestJobRunnerCancelWithNoActiveRuns(t *testing.T) { - job := &resources.Job{ - ID: "123", - } - b := &bundle.Bundle{ - Config: config.Root{ - Resources: config.Resources{ - Jobs: map[string]*resources.Job{ - "test_job": job, - }, - }, - }, - } - - runner := jobRunner{key: "test", bundle: b, job: job} - - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) - - jobApi := m.GetMockJobsAPI() - jobApi.EXPECT().ListRunsAll(mock.Anything, jobs.ListRunsRequest{ - ActiveOnly: true, - JobId: 123, - }).Return([]jobs.BaseRun{}, nil) - - jobApi.AssertNotCalled(t, "CancelRun") + runner, f := newJobRunner(t, jobs.JobSettings{}) err := runner.Cancel(t.Context()) require.NoError(t, err) + assert.Equal(t, 1, f.listCalls) + assert.Empty(t, f.cancelledRuns()) } func TestJobRunnerRestart(t *testing.T) { for _, jobSettings := range []jobs.JobSettings{ {}, { - Continuous: &jobs.Continuous{ - PauseStatus: jobs.PauseStatusPaused, + Continuous: &jobs.ContinuousSettings{ + PauseStatus: jobs.SchedulePauseStatus_Paused, }, }, } { - job := &resources.Job{ - ID: "123", - JobSettings: jobSettings, - } - b := &bundle.Bundle{ - Config: config.Root{ - Resources: config.Resources{ - Jobs: map[string]*resources.Job{ - "test_job": job, - }, - }, - }, - } - - runner := jobRunner{key: "test", bundle: b, job: job} - - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) + runner, f := newJobRunner(t, jobSettings) + f.activeRuns = []int64{1, 2} ctx := cmdio.MockDiscard(t.Context()) - - jobApi := m.GetMockJobsAPI() - jobApi.EXPECT().ListRunsAll(mock.Anything, jobs.ListRunsRequest{ - ActiveOnly: true, - JobId: 123, - }).Return([]jobs.BaseRun{ - {RunId: 1}, - {RunId: 2}, - }, nil) - - // Mock the runner cancelling existing job runs. - mockWait := &jobs.WaitGetRunJobTerminatedOrSkipped[struct{}]{ - Poll: func(time time.Duration, f func(j *jobs.Run)) (*jobs.Run, error) { - return nil, nil - }, - } - jobApi.EXPECT().CancelRun(mock.Anything, jobs.CancelRun{ - RunId: 1, - }).Return(mockWait, nil) - jobApi.EXPECT().CancelRun(mock.Anything, jobs.CancelRun{ - RunId: 2, - }).Return(mockWait, nil) - - // Mock the runner triggering a job run - mockWaitForRun := &jobs.WaitGetRunJobTerminatedOrSkipped[jobs.RunNowResponse]{ - Poll: func(d time.Duration, f func(*jobs.Run)) (*jobs.Run, error) { - return &jobs.Run{ - State: &jobs.RunState{ - ResultState: jobs.RunResultStateSuccess, - }, - }, nil - }, - } - jobApi.EXPECT().RunNow(mock.Anything, jobs.RunNow{ - JobId: 123, - }).Return(mockWaitForRun, nil) - - // Mock the runner getting the job output - jobApi.EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{}).Return(&jobs.Run{}, nil) - _, err := runner.Restart(ctx, &Options{}) require.NoError(t, err) + assert.Equal(t, []int64{1, 2}, f.cancelledRuns()) + assert.Equal(t, []int64{123}, f.runNowJobs) } } func TestJobRunnerRunNoWaitGetRunFails(t *testing.T) { - job := &resources.Job{ - ID: "123", - } - b := &bundle.Bundle{ - Config: config.Root{ - Resources: config.Resources{ - Jobs: map[string]*resources.Job{ - "test_job": job, - }, - }, - }, + runner, f := newJobRunner(t, jobs.JobSettings{}) + f.getRunError = &testserver.Response{ + StatusCode: 400, + Body: map[string]string{"error_code": "INVALID_PARAMETER_VALUE", "message": "transient error"}, } - runner := jobRunner{key: "test", bundle: b, job: job} - - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) - ctx := cmdio.MockDiscard(t.Context()) - jobApi := m.GetMockJobsAPI() - jobApi.EXPECT().RunNow(mock.Anything, jobs.RunNow{ - JobId: 123, - }).Return(&jobs.WaitGetRunJobTerminatedOrSkipped[jobs.RunNowResponse]{RunId: 456}, nil) - // Run must surface the error instead of dereferencing the nil run details. - jobApi.EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{ - RunId: 456, - }).Return(nil, errors.New("transient error")) - _, err := runner.Run(ctx, &Options{NoWait: true}) require.ErrorContains(t, err, "transient error") } func TestJobRunnerRestartForContinuousUnpausedJobs(t *testing.T) { - job := &resources.Job{ - ID: "123", - Continuous: &jobs.Continuous{ - PauseStatus: jobs.PauseStatusUnpaused, + runner, f := newJobRunner(t, jobs.JobSettings{ + Continuous: &jobs.ContinuousSettings{ + PauseStatus: "UNPAUSED", }, - } - b := &bundle.Bundle{ - Config: config.Root{ - Resources: config.Resources{ - Jobs: map[string]*resources.Job{ - "test_job": job, - }, - }, - }, - } - - runner := jobRunner{key: "test", bundle: b, job: job} - - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) + }) ctx := cmdio.MockDiscard(t.Context()) - - jobApi := m.GetMockJobsAPI() - - // The runner should not try and cancel existing job runs for unpaused continuous jobs. - jobApi.AssertNotCalled(t, "ListRunsAll") - jobApi.AssertNotCalled(t, "CancelRun") - - // Mock the runner triggering a job run - mockWaitForRun := &jobs.WaitGetRunJobTerminatedOrSkipped[jobs.RunNowResponse]{ - Poll: func(d time.Duration, f func(*jobs.Run)) (*jobs.Run, error) { - return &jobs.Run{ - State: &jobs.RunState{ - ResultState: jobs.RunResultStateSuccess, - }, - }, nil - }, - } - jobApi.EXPECT().RunNow(mock.Anything, jobs.RunNow{ - JobId: 123, - }).Return(mockWaitForRun, nil) - - // Mock the runner getting the job output - jobApi.EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{}).Return(&jobs.Run{}, nil) - _, err := runner.Restart(ctx, &Options{}) require.NoError(t, err) + + // The runner should not try and cancel existing job runs for unpaused continuous jobs. + assert.Equal(t, 0, f.listCalls) + assert.Empty(t, f.cancelledRuns()) + assert.Equal(t, []int64{123}, f.runNowJobs) } diff --git a/bundle/run/output/job.go b/bundle/run/output/job.go index 0de381e4c4b..cad3b117862 100644 --- a/bundle/run/output/job.go +++ b/bundle/run/output/job.go @@ -7,8 +7,10 @@ import ( "slices" "strings" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" ) type TaskOutput struct { @@ -53,10 +55,31 @@ func (out *JobOutput) String() (string, error) { return result.String(), nil } -func GetJobOutput(ctx context.Context, w *databricks.WorkspaceClient, runId int64) (*JobOutput, error) { - jobRun, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{ - RunId: runId, - }) +// GetRun fetches a job run, following next_page_token so that the result +// holds all tasks. +func GetRun(ctx context.Context, w *sdkclients.Clients, runId int64) (*sdkjobs.GetRunResponse, error) { + req := sdkjobs.GetRunRequest{RunId: new(runId)} + run, err := w.Jobs.GetRun(ctx, req) + if err != nil { + return nil, err + } + for utils.Deref(run.NextPageToken) != "" { + req.PageToken = run.NextPageToken + next, err := w.Jobs.GetRun(ctx, req) + if err != nil { + return nil, err + } + run.Tasks = append(run.Tasks, next.Tasks...) + run.JobClusters = append(run.JobClusters, next.JobClusters...) + run.JobParameters = append(run.JobParameters, next.JobParameters...) + run.RepairHistory = append(run.RepairHistory, next.RepairHistory...) + run.NextPageToken = next.NextPageToken + } + return run, nil +} + +func GetJobOutput(ctx context.Context, w *sdkclients.Clients, runId int64) (*JobOutput, error) { + jobRun, err := GetRun(ctx, w, runId) if err != nil { return nil, err } @@ -64,17 +87,21 @@ func GetJobOutput(ctx context.Context, w *databricks.WorkspaceClient, runId int6 TaskOutputs: make([]TaskOutput, 0), } for _, task := range jobRun.Tasks { - jobRunOutput, err := w.Jobs.GetRunOutput(ctx, jobs.GetRunOutputRequest{ + sdkOutput, err := w.Jobs.GetRunOutput(ctx, sdkjobs.GetRunOutputRequest{ RunId: task.RunId, }) if err != nil { return nil, err } + jobRunOutput, err := jobs.GetRunOutputResponseFromSDK(sdkOutput) + if err != nil { + return nil, err + } out := toRunOutput(jobRunOutput) if out == nil { continue } - task := TaskOutput{TaskKey: task.TaskKey, Output: out, EndTime: task.EndTime} + task := TaskOutput{TaskKey: utils.Deref(task.TaskKey), Output: out, EndTime: utils.Deref(task.EndTime)} result.TaskOutputs = append(result.TaskOutputs, task) } return result, nil diff --git a/bundle/run/output/job_test.go b/bundle/run/output/job_test.go index 9ecb7fc43e4..75bcf894eec 100644 --- a/bundle/run/output/job_test.go +++ b/bundle/run/output/job_test.go @@ -3,7 +3,8 @@ package output import ( "testing" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -93,13 +94,13 @@ baz } func TestNotebookOutputToRunOutput(t *testing.T) { - jobOutput := &jobs.RunOutput{ - NotebookOutput: &jobs.NotebookOutput{ - Result: "foo", - Truncated: true, + jobOutput := &jobs.GetRunOutputResponse{ + NotebookOutput: &jobs.NotebookTask_NotebookOutput{ + Result: new("foo"), + Truncated: new(true), }, - Logs: "hello :)", - LogsTruncated: true, + Logs: new("hello :)"), + LogsTruncated: new(true), } actual := toRunOutput(jobOutput) @@ -111,12 +112,12 @@ func TestNotebookOutputToRunOutput(t *testing.T) { } func TestNotebookOutputWithEmptyResultFallsBackToLogs(t *testing.T) { - jobOutput := &jobs.RunOutput{ - NotebookOutput: &jobs.NotebookOutput{ - Result: "", + jobOutput := &jobs.GetRunOutputResponse{ + NotebookOutput: &jobs.NotebookTask_NotebookOutput{ + Result: new(""), }, - Logs: "hello :)", - LogsTruncated: true, + Logs: new("hello :)"), + LogsTruncated: new(true), } actual := toRunOutput(jobOutput) @@ -128,11 +129,11 @@ func TestNotebookOutputWithEmptyResultFallsBackToLogs(t *testing.T) { } func TestDbtOutputToRunOutput(t *testing.T) { - jobOutput := &jobs.RunOutput{ - DbtOutput: &jobs.DbtOutput{ - ArtifactsLink: "foo", + jobOutput := &jobs.GetRunOutputResponse{ + DbtOutput: &jobs.DbtTask_DbtTaskOutput{ + ArtifactsLink: new("foo"), }, - Logs: "hello :)", + Logs: new("hello :)"), } actual := toRunOutput(jobOutput) @@ -143,28 +144,28 @@ func TestDbtOutputToRunOutput(t *testing.T) { } func TestSqlOutputToRunOutput(t *testing.T) { - jobOutput := &jobs.RunOutput{ - SqlOutput: &jobs.SqlOutput{ - QueryOutput: &jobs.SqlQueryOutput{ - OutputLink: "foo", + jobOutput := &jobs.GetRunOutputResponse{ + SqlOutput: &jobs.SqlTask_SqlOutput{ + QueryOutput: &jobs.SqlTask_SqlQueryOutput{ + OutputLink: new("foo"), }, }, - Logs: "hello :)", + Logs: new("hello :)"), } actual := toRunOutput(jobOutput) expected := &SqlOutput{ - QueryOutput: &jobs.SqlQueryOutput{ - OutputLink: "foo", + QueryOutput: &jobs.SqlTask_SqlQueryOutput{ + OutputLink: new("foo"), }, } assert.Equal(t, expected, actual) } func TestLogOutputToRunOutput(t *testing.T) { - jobOutput := &jobs.RunOutput{ - Logs: "hello :)", - LogsTruncated: true, + jobOutput := &jobs.GetRunOutputResponse{ + Logs: new("hello :)"), + LogsTruncated: new(true), } actual := toRunOutput(jobOutput) diff --git a/bundle/run/output/task.go b/bundle/run/output/task.go index d30370bb015..c26da1d839e 100644 --- a/bundle/run/output/task.go +++ b/bundle/run/output/task.go @@ -3,21 +3,43 @@ package output import ( "encoding/json" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" ) type ( - NotebookOutput jobs.NotebookOutput - DbtOutput jobs.DbtOutput - SqlOutput jobs.SqlOutput - LogsOutput struct { + NotebookOutput struct { + // The value passed to dbutils.notebook.exit(). + Result string `json:"result,omitempty"` + // Whether or not the result was truncated. + Truncated bool `json:"truncated,omitempty"` + } + DbtOutput struct { + // An optional map of headers to send when retrieving the artifact from + // the `artifacts_link`. + ArtifactsHeaders map[string]string `json:"artifacts_headers,omitempty"` + // A pre-signed URL to download the (compressed) dbt artifacts. + ArtifactsLink string `json:"artifacts_link,omitempty"` + } + SqlOutput jobs.SqlTask_SqlOutput + LogsOutput struct { Logs string `json:"logs"` LogsTruncated bool `json:"logs_truncated"` } ) +// structToString renders val as indented JSON with keys sorted, so the output +// does not depend on the field order of the API types. func structToString(val any) (string, error) { - b, err := json.MarshalIndent(val, "", " ") + data, err := json.Marshal(val) + if err != nil { + return "", err + } + var generic any + if err := json.Unmarshal(data, &generic); err != nil { + return "", err + } + b, err := json.MarshalIndent(generic, "", " ") if err != nil { return "", err } @@ -64,32 +86,37 @@ func (out *LogsOutput) String() (string, error) { return out.Logs, nil } -func toRunOutput(output *jobs.RunOutput) RunOutput { +func toRunOutput(output *jobs.GetRunOutputResponse) RunOutput { + logs := utils.Deref(output.Logs) + logsTruncated := utils.Deref(output.LogsTruncated) switch { case output.NotebookOutput != nil: - if output.NotebookOutput.Result == "" && !output.NotebookOutput.Truncated && output.Logs != "" { - result := LogsOutput{ - Logs: output.Logs, - LogsTruncated: output.LogsTruncated, + result := NotebookOutput{ + Result: utils.Deref(output.NotebookOutput.Result), + Truncated: utils.Deref(output.NotebookOutput.Truncated), + } + if result.Result == "" && !result.Truncated && logs != "" { + return &LogsOutput{ + Logs: logs, + LogsTruncated: logsTruncated, } - return &result } - result := NotebookOutput(*output.NotebookOutput) return &result case output.DbtOutput != nil: - result := DbtOutput(*output.DbtOutput) - return &result + return &DbtOutput{ + ArtifactsHeaders: output.DbtOutput.ArtifactsHeaders, + ArtifactsLink: utils.Deref(output.DbtOutput.ArtifactsLink), + } case output.SqlOutput != nil: result := SqlOutput(*output.SqlOutput) return &result // Corresponds to JAR, python script and python wheel tasks - case output.Logs != "": - result := LogsOutput{ - Logs: output.Logs, - LogsTruncated: output.LogsTruncated, + case logs != "": + return &LogsOutput{ + Logs: logs, + LogsTruncated: logsTruncated, } - return &result default: return nil } diff --git a/bundle/run/output/task_test.go b/bundle/run/output/task_test.go index 62aacaca5a7..ef48041e65e 100644 --- a/bundle/run/output/task_test.go +++ b/bundle/run/output/task_test.go @@ -4,7 +4,8 @@ import ( "fmt" "testing" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -68,10 +69,10 @@ func TestDbtOutputToString(t *testing.T) { func TestSqlOutputToString(t *testing.T) { task := SqlOutput{ - QueryOutput: &jobs.SqlQueryOutput{ - OutputLink: "a", - QueryText: "b", - WarehouseId: "d", + QueryOutput: &jobs.SqlTask_SqlQueryOutput{ + OutputLink: new("a"), + QueryText: new("b"), + WarehouseId: new("d"), }, } diff --git a/bundle/run/pipeline.go b/bundle/run/pipeline.go index 97b8144d28b..5d29698932d 100644 --- a/bundle/run/pipeline.go +++ b/bundle/run/pipeline.go @@ -15,14 +15,17 @@ import ( "github.com/databricks/cli/bundle/run/progress" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/options/lro" + sdkpipelines "github.com/databricks/sdk-go/pipelines/v2" "github.com/spf13/cobra" ) func filterEventsByUpdateId(events []pipelines.PipelineEvent, updateId string) []pipelines.PipelineEvent { var result []pipelines.PipelineEvent for i := range events { - if events[i].Origin.UpdateId == updateId { + if events[i].Origin != nil && utils.Deref(events[i].Origin.UpdateId) == updateId { result = append(result, events[i]) } } @@ -31,18 +34,18 @@ func filterEventsByUpdateId(events []pipelines.PipelineEvent, updateId string) [ func (r *pipelineRunner) logEvent(ctx context.Context, event pipelines.PipelineEvent) { var sb strings.Builder - if event.Message != "" { - fmt.Fprintf(&sb, " %s\n", event.Message) + if message := utils.Deref(event.Message); message != "" { + fmt.Fprintf(&sb, " %s\n", message) } if event.Error != nil && len(event.Error.Exceptions) > 0 { sb.WriteString("trace for most recent exception: \n") for _, exc := range event.Error.Exceptions { - sb.WriteString(exc.Message) + sb.WriteString(utils.Deref(exc.Message)) sb.WriteByte('\n') } } if sb.Len() > 0 { - log.Errorf(ctx, "[%s] %s", event.EventType, sb.String()) + log.Errorf(ctx, "[%s] %s", utils.Deref(event.EventType), sb.String()) } } @@ -58,10 +61,10 @@ func (r *pipelineRunner) logErrorEvent(ctx context.Context, pipelineId, updateId // Otherwise for long lived pipelines, there can be a lot of unnecessary // latency due to multiple pagination API calls needed underneath the hood for // ListPipelineEventsAll - events, err := w.Pipelines.ListPipelineEventsAll(ctx, pipelines.ListPipelineEventsRequest{ - Filter: `level='ERROR'`, - MaxResults: 100, - PipelineId: pipelineId, + events, err := progress.ListEvents(ctx, w, sdkpipelines.ListPipelineEventsRequest{ + Filter: new(`level='ERROR'`), + MaxResults: new(100), + PipelineId: new(pipelineId), }) if err != nil { return err @@ -85,7 +88,7 @@ func (r *pipelineRunner) Name() string { if r.pipeline == nil { return "" } - return r.pipeline.Name + return utils.Deref(r.pipeline.Name) } func (r *pipelineRunner) Run(ctx context.Context, opts *Options) (output.RunOutput, error) { @@ -103,12 +106,12 @@ func (r *pipelineRunner) Run(ctx context.Context, opts *Options) (output.RunOutp return nil, err } - res, err := w.Pipelines.StartUpdate(ctx, *req) + res, err := w.Pipelines.Start(ctx, *req) if err != nil { return nil, err } - updateID := res.UpdateId + updateID := utils.Deref(res.UpdateId) // setup progress logger and tracker to query events updateTracker := progress.NewUpdateTracker(pipelineID, updateID, w) @@ -124,7 +127,7 @@ func (r *pipelineRunner) Run(ctx context.Context, opts *Options) (output.RunOutp // Poll update for completion and post status. // Note: there is no "StartUpdateAndWait" wrapper for this API. - var prevState *pipelines.UpdateInfoState + var prevState *pipelines.UpdateState for { events, err := updateTracker.Events(ctx) if err != nil { @@ -135,23 +138,29 @@ func (r *pipelineRunner) Run(ctx context.Context, opts *Options) (output.RunOutp log.Info(ctx, event.String()) } - update, err := w.Pipelines.GetUpdateByPipelineIdAndUpdateId(ctx, pipelineID, updateID) + update, err := w.Pipelines.GetUpdate(ctx, sdkpipelines.GetUpdateRequest{ + PipelineId: new(pipelineID), + UpdateId: new(updateID), + }) if err != nil { return nil, err } // Log only if the current state is different from the previous state. - state := update.Update.State + var state pipelines.UpdateState + if update.Update != nil { + state = update.Update.State + } if prevState == nil || *prevState != state { log.Infof(ctx, "Update status: %s", state) prevState = &state } - if state == pipelines.UpdateInfoStateCanceled { + if state == pipelines.UpdateState_Canceled { log.Infof(ctx, "Update was cancelled!") return nil, errors.New("update cancelled") } - if state == pipelines.UpdateInfoStateFailed { + if state == pipelines.UpdateState_Failed { log.Infof(ctx, "Update has failed!") err := r.logErrorEvent(ctx, pipelineID, updateID) if err != nil { @@ -159,7 +168,7 @@ func (r *pipelineRunner) Run(ctx context.Context, opts *Options) (output.RunOutp } return nil, errors.New("update failed") } - if state == pipelines.UpdateInfoStateCompleted { + if state == pipelines.UpdateState_Completed { log.Infof(ctx, "Update has completed successfully!") return &output.PipelineOutput{ UpdateId: updateID, @@ -172,15 +181,15 @@ func (r *pipelineRunner) Run(ctx context.Context, opts *Options) (output.RunOutp func (r *pipelineRunner) Cancel(ctx context.Context) error { w := r.bundle.WorkspaceClient(ctx) - wait, err := w.Pipelines.Stop(ctx, pipelines.StopRequest{ - PipelineId: r.pipeline.ID, + wait, err := w.Pipelines.Stop(ctx, sdkpipelines.StopPipelineRequest{ + PipelineId: new(r.pipeline.ID), }) if err != nil { return err } // Waits for the Idle state of the pipeline - _, err = wait.GetWithTimeout(jobRunTimeout) + _, err = wait.Wait(ctx, lro.WithTimeout(jobRunTimeout)) return err } diff --git a/bundle/run/pipeline_options.go b/bundle/run/pipeline_options.go index 63ff3e81289..432bdf64e0e 100644 --- a/bundle/run/pipeline_options.go +++ b/bundle/run/pipeline_options.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/pipelines" + pipelines "github.com/databricks/sdk-go/pipelines/v2" flag "github.com/spf13/pflag" ) @@ -58,22 +58,31 @@ func (o *PipelineOptions) Validate(pipeline *resources.Pipeline) error { return nil } -func (o *PipelineOptions) toPayload(pipeline *resources.Pipeline, pipelineID string, development bool) (*pipelines.StartUpdate, error) { +func (o *PipelineOptions) toPayload(pipeline *resources.Pipeline, pipelineID string, development bool) (*pipelines.StartUpdateRequest, error) { if err := o.Validate(pipeline); err != nil { return nil, err } - payload := &pipelines.StartUpdate{ - PipelineId: pipelineID, + payload := &pipelines.StartUpdateRequest{ + PipelineId: new(pipelineID), // Note: `RefreshAll` is implied if the fields below are not set. RefreshSelection: o.Refresh, - FullRefresh: o.FullRefreshAll, + FullRefresh: trueOrNil(o.FullRefreshAll), FullRefreshSelection: o.FullRefresh, - ValidateOnly: o.ValidateOnly, + ValidateOnly: trueOrNil(o.ValidateOnly), // Only true is sent. When false the field is omitted, so the backend keeps // using the pipeline-level development property while it is being deprecated. - Development: development, + Development: trueOrNil(development), } return payload, nil } + +// trueOrNil returns a pointer to true, or nil for false so that the field is +// omitted from the request and the backend default applies. +func trueOrNil(b bool) *bool { + if !b { + return nil + } + return new(true) +} diff --git a/bundle/run/pipeline_test.go b/bundle/run/pipeline_test.go index 354216ee490..471ef5d15ef 100644 --- a/bundle/run/pipeline_test.go +++ b/bundle/run/pipeline_test.go @@ -1,21 +1,20 @@ package run import ( + "encoding/json" "testing" - "time" "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/bundle/internal/bundletest" "github.com/databricks/cli/libs/cmdio" - sdk_config "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/stretchr/testify/mock" + "github.com/databricks/cli/libs/testserver" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func TestPipelineRunnerCancel(t *testing.T) { +func newPipelineRunner(t *testing.T) (pipelineRunner, *testserver.Server) { pipeline := &resources.Pipeline{ ID: "123", } @@ -30,84 +29,62 @@ func TestPipelineRunnerCancel(t *testing.T) { }, } - runner := pipelineRunner{key: "test", bundle: b, pipeline: pipeline} - - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) + w, server := bundletest.NewClients(t) + b.SetWorkpaceClient(w) + return pipelineRunner{key: "test", bundle: b, pipeline: pipeline}, server +} - mockWait := &pipelines.WaitGetPipelineIdle[struct{}]{ - Poll: func(time.Duration, func(*pipelines.GetPipelineResponse)) (*pipelines.GetPipelineResponse, error) { - return nil, nil - }, - } +// handleStop serves the stop request and the pipeline poll that waits for IDLE. +func handleStop(t *testing.T, server *testserver.Server) *int { + stops := 0 + server.Handle("POST", "/api/2.0/pipelines/{pipeline_id}/stop", func(req testserver.Request) any { + assert.Equal(t, "123", req.Vars["pipeline_id"]) + stops++ + return map[string]any{} + }) + server.Handle("GET", "/api/2.0/pipelines/{pipeline_id}", func(req testserver.Request) any { + return map[string]any{"pipeline_id": "123", "state": "IDLE"} + }) + return &stops +} - pipelineApi := m.GetMockPipelinesAPI() - pipelineApi.EXPECT().Stop(t.Context(), pipelines.StopRequest{ - PipelineId: "123", - }).Return(mockWait, nil) +func TestPipelineRunnerCancel(t *testing.T) { + runner, server := newPipelineRunner(t) + stops := handleStop(t, server) err := runner.Cancel(t.Context()) require.NoError(t, err) + assert.Equal(t, 1, *stops) } func TestPipelineRunnerRestart(t *testing.T) { - pipeline := &resources.Pipeline{ - ID: "123", - } - - b := &bundle.Bundle{ - Config: config.Root{ - Resources: config.Resources{ - Pipelines: map[string]*resources.Pipeline{ - "test_pipeline": pipeline, - }, - }, - }, - } - - runner := pipelineRunner{key: "test", bundle: b, pipeline: pipeline} - - m := mocks.NewMockWorkspaceClient(t) - m.WorkspaceClient.Config = &sdk_config.Config{ - Host: "https://test.test", - } - b.SetWorkpaceClient(m.WorkspaceClient) + runner, server := newPipelineRunner(t) + stops := handleStop(t, server) + + // The runner starts a new update. + server.Handle("POST", "/api/2.0/pipelines/{pipeline_id}/updates", func(req testserver.Request) any { + var body map[string]any + assert.NoError(t, json.Unmarshal(req.Body, &body)) + // sdk-go repeats the pipeline_id path parameter in the body. + assert.Equal(t, map[string]any{"pipeline_id": "123"}, body) + return map[string]any{"update_id": "456"} + }) + + // The runner polls for events. + server.Handle("GET", "/api/2.0/pipelines/{pipeline_id}/events", func(req testserver.Request) any { + assert.Equal(t, "update_id = '456'", req.URL.Query().Get("filter")) + assert.Equal(t, "100", req.URL.Query().Get("max_results")) + return map[string]any{} + }) + + // The runner polls for the update status. + server.Handle("GET", "/api/2.0/pipelines/{pipeline_id}/updates/{update_id}", func(req testserver.Request) any { + assert.Equal(t, "456", req.Vars["update_id"]) + return map[string]any{"update": map[string]any{"state": "COMPLETED"}} + }) ctx := cmdio.MockDiscard(t.Context()) - - mockWait := &pipelines.WaitGetPipelineIdle[struct{}]{ - Poll: func(time.Duration, func(*pipelines.GetPipelineResponse)) (*pipelines.GetPipelineResponse, error) { - return nil, nil - }, - } - - pipelineApi := m.GetMockPipelinesAPI() - pipelineApi.EXPECT().Stop(mock.Anything, pipelines.StopRequest{ - PipelineId: "123", - }).Return(mockWait, nil) - - // Mock runner starting a new update - pipelineApi.EXPECT().StartUpdate(mock.Anything, pipelines.StartUpdate{ - PipelineId: "123", - }).Return(&pipelines.StartUpdateResponse{ - UpdateId: "456", - }, nil) - - // Mock runner polling for events - pipelineApi.EXPECT().ListPipelineEventsAll(mock.Anything, pipelines.ListPipelineEventsRequest{ - Filter: `update_id = '456'`, - MaxResults: 100, - PipelineId: "123", - }).Return([]pipelines.PipelineEvent{}, nil) - - // Mock runner polling for update status - pipelineApi.EXPECT().GetUpdateByPipelineIdAndUpdateId(mock.Anything, "123", "456"). - Return(&pipelines.GetUpdateResponse{ - Update: &pipelines.UpdateInfo{ - State: pipelines.UpdateInfoStateCompleted, - }, - }, nil) - _, err := runner.Restart(ctx, &Options{}) require.NoError(t, err) + assert.Equal(t, 1, *stops) } diff --git a/bundle/run/progress/job.go b/bundle/run/progress/job.go index 6deee451ad6..89879d419a0 100644 --- a/bundle/run/progress/job.go +++ b/bundle/run/progress/job.go @@ -5,7 +5,8 @@ import ( "strings" "time" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" ) type JobProgressEvent struct { @@ -20,14 +21,14 @@ func (event *JobProgressEvent) String() string { result := strings.Builder{} result.WriteString(event.Timestamp.Format("2006-01-02 15:04:05") + " ") result.WriteString(fmt.Sprintf(`"%s"`, event.RunName) + " ") - result.WriteString(event.State.LifeCycleState.String()) + result.WriteString(string(event.State.LifeCycleState)) - resultState := event.State.ResultState.String() + resultState := string(event.State.ResultState) if resultState != "" { result.WriteString(" " + resultState) } - stateMessage := event.State.StateMessage + stateMessage := utils.Deref(event.State.StateMessage) if stateMessage != "" { result.WriteString(" " + stateMessage) } diff --git a/bundle/run/progress/job_test.go b/bundle/run/progress/job_test.go index 31196520305..ba45a8a8b8b 100644 --- a/bundle/run/progress/job_test.go +++ b/bundle/run/progress/job_test.go @@ -4,7 +4,8 @@ import ( "testing" "time" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/stretchr/testify/assert" ) @@ -15,9 +16,9 @@ func TestJobProgressEventString(t *testing.T) { RunId: 456, RunName: "run_name", State: jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateSuccess, - StateMessage: "state_message", + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Success, + StateMessage: new("state_message"), }, } assert.Equal(t, "-0001-11-30 00:00:00 \"run_name\" TERMINATED SUCCESS state_message", event.String()) diff --git a/bundle/run/progress/pipeline.go b/bundle/run/progress/pipeline.go index cce17965da8..5214c91ad8c 100644 --- a/bundle/run/progress/pipeline.go +++ b/bundle/run/progress/pipeline.go @@ -6,8 +6,10 @@ import ( "slices" "strings" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/utils" + sdkpipelines "github.com/databricks/sdk-go/pipelines/v2" ) // The dlt backend computes events for pipeline runs which are accessible through @@ -23,18 +25,18 @@ type ProgressEvent pipelines.PipelineEvent func (event *ProgressEvent) String() string { result := strings.Builder{} - result.WriteString(event.Timestamp + " ") + result.WriteString(utils.Deref(event.Timestamp) + " ") // Print event type with some padding to make output more pretty - result.WriteString(fmt.Sprintf("%-15s", event.EventType) + " ") + result.WriteString(fmt.Sprintf("%-15s", utils.Deref(event.EventType)) + " ") - result.WriteString(event.Level.String() + " ") - fmt.Fprintf(&result, `"%s"`, event.Message) + result.WriteString(string(event.Level) + " ") + fmt.Fprintf(&result, `"%s"`, utils.Deref(event.Message)) // construct error string if level=`Error` - if event.Level == pipelines.EventLevelError && event.Error != nil { + if event.Level == pipelines.EventLevel_Error && event.Error != nil { for _, exception := range event.Error.Exceptions { - result.WriteString("\n" + exception.Message) + result.WriteString("\n" + utils.Deref(exception.Message)) } } return result.String() @@ -44,10 +46,10 @@ type UpdateTracker struct { UpdateId string PipelineId string LatestEventTimestamp string - w *databricks.WorkspaceClient + w *sdkclients.Clients } -func NewUpdateTracker(pipelineId, updateId string, w *databricks.WorkspaceClient) *UpdateTracker { +func NewUpdateTracker(pipelineId, updateId string, w *sdkclients.Clients) *UpdateTracker { return &UpdateTracker{ w: w, PipelineId: pipelineId, @@ -74,10 +76,10 @@ func (l *UpdateTracker) Events(ctx context.Context) ([]ProgressEvent, error) { } // we only check the most recent 100 events for progress - events, err := l.w.Pipelines.ListPipelineEventsAll(ctx, pipelines.ListPipelineEventsRequest{ - PipelineId: l.PipelineId, - MaxResults: 100, - Filter: filter, + events, err := ListEvents(ctx, l.w, sdkpipelines.ListPipelineEventsRequest{ + PipelineId: new(l.PipelineId), + MaxResults: new(100), + Filter: new(filter), }) if err != nil { return nil, err @@ -87,15 +89,32 @@ func (l *UpdateTracker) Events(ctx context.Context) ([]ProgressEvent, error) { // Return events in chronological order. for _, event := range slices.Backward(events) { // filter to only include update_progress and flow_progress events - if event.EventType == "flow_progress" || event.EventType == "update_progress" { + eventType := utils.Deref(event.EventType) + if eventType == "flow_progress" || eventType == "update_progress" { result = append(result, ProgressEvent(event)) } } // update latest event timestamp for next time if len(result) > 0 { - l.LatestEventTimestamp = result[len(result)-1].Timestamp + l.LatestEventTimestamp = utils.Deref(result[len(result)-1].Timestamp) } return result, nil } + +// ListEvents returns all pipeline events matching req, most recent first. +func ListEvents(ctx context.Context, w *sdkclients.Clients, req sdkpipelines.ListPipelineEventsRequest) ([]pipelines.PipelineEvent, error) { + var events []pipelines.PipelineEvent + for event, err := range w.Pipelines.EventsIter(ctx, req) { + if err != nil { + return nil, err + } + e, err := pipelines.PipelineEventFromSDK(event) + if err != nil { + return nil, err + } + events = append(events, *e) + } + return events, nil +} diff --git a/bundle/run/progress/pipeline_test.go b/bundle/run/progress/pipeline_test.go index ba4213ac7b1..91ec8f51246 100644 --- a/bundle/run/progress/pipeline_test.go +++ b/bundle/run/progress/pipeline_test.go @@ -3,52 +3,53 @@ package progress import ( "testing" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/stretchr/testify/assert" ) func TestFlowProgressEventToString(t *testing.T) { event := ProgressEvent{ - EventType: "flow_progress", - Message: "my_message", - Level: pipelines.EventLevelInfo, + EventType: new("flow_progress"), + Message: new("my_message"), + Level: pipelines.EventLevel_Info, Origin: &pipelines.Origin{ - FlowName: "my_flow", - PipelineName: "my_pipeline", + FlowName: new("my_flow"), + PipelineName: new("my_pipeline"), }, - Timestamp: "2023-03-27T23:30:36.122Z", + Timestamp: new("2023-03-27T23:30:36.122Z"), } assert.Equal(t, `2023-03-27T23:30:36.122Z flow_progress INFO "my_message"`, event.String()) } func TestUpdateProgressEventToString(t *testing.T) { event := ProgressEvent{ - EventType: "update_progress", - Message: "my_message", - Level: pipelines.EventLevelError, + EventType: new("update_progress"), + Message: new("my_message"), + Level: pipelines.EventLevel_Error, Origin: &pipelines.Origin{ - FlowName: "my_flow", - PipelineName: "my_pipeline", + FlowName: new("my_flow"), + PipelineName: new("my_pipeline"), }, - Timestamp: "2023-03-27T23:30:36.122Z", + Timestamp: new("2023-03-27T23:30:36.122Z"), } assert.Equal(t, `2023-03-27T23:30:36.122Z update_progress ERROR "my_message"`, event.String()) } func TestUpdateErrorEventToString(t *testing.T) { event := ProgressEvent{ - EventType: "update_progress", - Message: "failed to update pipeline", - Level: pipelines.EventLevelError, + EventType: new("update_progress"), + Message: new("failed to update pipeline"), + Level: pipelines.EventLevel_Error, Origin: &pipelines.Origin{ - FlowName: "my_flow", - PipelineName: "my_pipeline", + FlowName: new("my_flow"), + PipelineName: new("my_pipeline"), }, - Timestamp: "2023-03-27T23:30:36.122Z", + Timestamp: new("2023-03-27T23:30:36.122Z"), Error: &pipelines.ErrorDetail{ Exceptions: []pipelines.SerializedException{ { - Message: "parsing error", + Message: new("parsing error"), }, }, }, @@ -58,18 +59,18 @@ func TestUpdateErrorEventToString(t *testing.T) { func TestUpdateErrorIgnoredForWarnEvents(t *testing.T) { event := ProgressEvent{ - EventType: "update_progress", - Message: "failed to update pipeline", - Level: pipelines.EventLevelWarn, + EventType: new("update_progress"), + Message: new("failed to update pipeline"), + Level: pipelines.EventLevel_Warn, Origin: &pipelines.Origin{ - FlowName: "my_flow", - PipelineName: "my_pipeline", + FlowName: new("my_flow"), + PipelineName: new("my_pipeline"), }, - Timestamp: "2023-03-27T23:30:36.122Z", + Timestamp: new("2023-03-27T23:30:36.122Z"), Error: &pipelines.ErrorDetail{ Exceptions: []pipelines.SerializedException{ { - Message: "THIS IS IGNORED", + Message: new("THIS IS IGNORED"), }, }, }, diff --git a/bundle/schema/jsonschema.json b/bundle/schema/jsonschema.json index e8422a92b40..f6a30c5c7a4 100644 --- a/bundle/schema/jsonschema.json +++ b/bundle/schema/jsonschema.json @@ -4394,16 +4394,7 @@ "type": "string" }, "time.Time": { - "oneOf": [ - { - "type": "object", - "additionalProperties": false - }, - { - "type": "string", - "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" - } - ] + "type": "string" } } }, @@ -7069,7 +7060,7 @@ }, "version_num": { "description": "Integer version number of the model version to which this alias points.", - "$ref": "#/$defs/int", + "$ref": "#/$defs/int64", "x-databricks-launch-stage": "GA" } }, @@ -8633,7 +8624,7 @@ "properties": { "branch_time": { "description": "[Public Preview] Branch time of the ref database instance.\nFor a parent ref instance, this is the point in time on the parent instance from which the\ninstance was created.\nFor a child ref instance, this is the point in time on the instance from which the child\ninstance was created.\nInput: For specifying the point in time to create a child instance. Optional.\nOutput: Only populated if provided as input to create a child instance.", - "$ref": "#/$defs/string", + "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/common/types/time.Time", "x-databricks-launch-stage": "PUBLIC_PREVIEW" }, "lsn": { @@ -16986,11 +16977,6 @@ "description": "The workload size of the served entity. The workload size corresponds to a range of provisioned concurrency that the compute autoscales between. A single unit of provisioned concurrency can process one request at a time. Valid workload sizes are \"Small\" (4 - 4 provisioned concurrency), \"Medium\" (8 - 16 provisioned concurrency), and \"Large\" (16 - 64 provisioned concurrency). Additional custom workload sizes can also be used when available in the workspace. If scale-to-zero is enabled, the lower bound of the provisioned concurrency for each workload size is 0. Do not use if min_provisioned_concurrency and max_provisioned_concurrency are specified.", "$ref": "#/$defs/string", "x-databricks-launch-stage": "GA" - }, - "workload_type": { - "description": "The workload type of the served entity. The workload type selects which type of compute to use in the endpoint. The default value for this parameter is \"CPU\". For deep learning workloads, GPU acceleration is available by selecting workload types like GPU_SMALL and others. See the available [GPU types](https://docs.databricks.com/en/machine-learning/model-serving/create-manage-serving-endpoints.html#gpu-workload-types).", - "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.ServingModelWorkloadType", - "x-databricks-launch-stage": "GA" } }, "additionalProperties": false @@ -17068,11 +17054,6 @@ "description": "The workload size of the served entity. The workload size corresponds to a range of provisioned concurrency that the compute autoscales between. A single unit of provisioned concurrency can process one request at a time. Valid workload sizes are \"Small\" (4 - 4 provisioned concurrency), \"Medium\" (8 - 16 provisioned concurrency), and \"Large\" (16 - 64 provisioned concurrency). Additional custom workload sizes can also be used when available in the workspace. If scale-to-zero is enabled, the lower bound of the provisioned concurrency for each workload size is 0. Do not use if min_provisioned_concurrency and max_provisioned_concurrency are specified.", "$ref": "#/$defs/string", "x-databricks-launch-stage": "GA" - }, - "workload_type": { - "description": "The workload type of the served entity. The workload type selects which type of compute to use in the endpoint. The default value for this parameter is \"CPU\". For deep learning workloads, GPU acceleration is available by selecting workload types like GPU_SMALL and others. See the available [GPU types](https://docs.databricks.com/en/machine-learning/model-serving/create-manage-serving-endpoints.html#gpu-workload-types).", - "$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.ServedModelInputWorkloadType", - "x-databricks-launch-stage": "GA" } }, "additionalProperties": false, @@ -17088,40 +17069,6 @@ } ] }, - "serving.ServedModelInputWorkloadType": { - "oneOf": [ - { - "type": "string", - "description": "Please keep this in sync with workload types in InferenceEndpointEntities.scala.", - "enum": [ - "CPU", - "GPU_MEDIUM", - "GPU_SMALL", - "GPU_LARGE", - "MULTIGPU_MEDIUM", - "CPU_LARGE", - "GPU_XLARGE_8", - "GPU_XLARGE", - "CPU_MEDIUM" - ], - "enumDescriptions": [ - "", - "", - "", - "", - "", - "[Beta]", - "[Beta]", - "[Beta]", - "[Beta]" - ] - }, - { - "type": "string", - "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" - } - ] - }, "serving.ServingEndpointPermissionLevel": { "oneOf": [ { @@ -17139,40 +17086,6 @@ } ] }, - "serving.ServingModelWorkloadType": { - "oneOf": [ - { - "type": "string", - "description": "Please keep this in sync with workload types in InferenceEndpointEntities.scala.", - "enum": [ - "CPU", - "GPU_MEDIUM", - "GPU_SMALL", - "GPU_LARGE", - "MULTIGPU_MEDIUM", - "CPU_LARGE", - "GPU_XLARGE_8", - "GPU_XLARGE", - "CPU_MEDIUM" - ], - "enumDescriptions": [ - "", - "", - "", - "", - "", - "[Beta]", - "[Beta]", - "[Beta]", - "[Beta]" - ] - }, - { - "type": "string", - "pattern": "\\$\\{(var(\\._*\\p{L}+([-_]*[\\p{L}\\p{N}]+)*(\\[[0-9]+\\])*)+)\\}" - } - ] - }, "serving.TelemetryConfig": { "oneOf": [ { diff --git a/bundle/statemgmt/check_running_resources.go b/bundle/statemgmt/check_running_resources.go index 63681bd5eb9..ca1fd587250 100644 --- a/bundle/statemgmt/check_running_resources.go +++ b/bundle/statemgmt/check_running_resources.go @@ -7,11 +7,12 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" + sdkpipelines "github.com/databricks/sdk-go/pipelines/v2" "golang.org/x/sync/errgroup" ) @@ -47,7 +48,7 @@ func CheckRunningResource() bundle.Mutator { return &checkRunningResources{} } -func checkAnyResourceRunning(ctx context.Context, w *databricks.WorkspaceClient, state ExportedResourcesMap) error { +func checkAnyResourceRunning(ctx context.Context, w *sdkclients.Clients, state ExportedResourcesMap) error { errs, errCtx := errgroup.WithContext(ctx) for resourceKey, attrs := range state { @@ -88,33 +89,39 @@ func checkAnyResourceRunning(ctx context.Context, w *databricks.WorkspaceClient, return errs.Wait() } -func IsJobRunning(ctx context.Context, w *databricks.WorkspaceClient, jobId string) (bool, error) { +func IsJobRunning(ctx context.Context, w *sdkclients.Clients, jobId string) (bool, error) { id, err := strconv.Atoi(jobId) if err != nil { return false, err } - runs, err := w.Jobs.ListRunsAll(ctx, jobs.ListRunsRequest{JobId: int64(id), ActiveOnly: true}) - if apierr.IsMissing(err) { - return false, nil - } - if err != nil { - return false, err + for _, err := range w.Jobs.ListRunsIter(ctx, sdkjobs.ListRunsRequest{ + JobId: new(int64(id)), + StateConstraint: &sdkjobs.ListRunsRequest_StateConstraint_ActiveOnly{ActiveOnly: true}, + }) { + if apierrs.IsMissing(err) { + return false, nil + } + if err != nil { + return false, err + } + // Any active run means the job is running. + return true, nil } - return len(runs) > 0, nil + return false, nil } -func IsPipelineRunning(ctx context.Context, w *databricks.WorkspaceClient, pipelineId string) (bool, error) { - resp, err := w.Pipelines.Get(ctx, pipelines.GetPipelineRequest{PipelineId: pipelineId}) - if apierr.IsMissing(err) { +func IsPipelineRunning(ctx context.Context, w *sdkclients.Clients, pipelineId string) (bool, error) { + resp, err := w.Pipelines.Get(ctx, sdkpipelines.GetPipelineRequest{PipelineId: new(pipelineId)}) + if apierrs.IsMissing(err) { return false, nil } if err != nil { return false, err } switch resp.State { - case pipelines.PipelineStateIdle, pipelines.PipelineStateFailed, pipelines.PipelineStateDeleted: + case pipelines.PipelineState_PipelineState_Idle, pipelines.PipelineState_PipelineState_Failed, pipelines.PipelineState_PipelineState_Deleted: return false, nil default: return true, nil diff --git a/bundle/statemgmt/check_running_resources_test.go b/bundle/statemgmt/check_running_resources_test.go index 763af295d60..86b2cdada0f 100644 --- a/bundle/statemgmt/check_running_resources_test.go +++ b/bundle/statemgmt/check_running_resources_test.go @@ -1,119 +1,105 @@ package statemgmt import ( - "errors" "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/stretchr/testify/mock" + "github.com/databricks/cli/bundle/internal/bundletest" + "github.com/databricks/cli/libs/testserver" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) +func notFound(testserver.Request) any { + return testserver.Response{ + StatusCode: 404, + Body: map[string]string{"error_code": "RESOURCE_DOES_NOT_EXIST", "message": "not found"}, + } +} + func TestIsAnyResourceRunningWithEmptyState(t *testing.T) { - mock := mocks.NewMockWorkspaceClient(t) - err := checkAnyResourceRunning(t.Context(), mock.WorkspaceClient, nil) + w, _ := bundletest.NewClients(t) + err := checkAnyResourceRunning(t.Context(), w, nil) require.NoError(t, err) } func TestIsAnyResourceRunningWithJob(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) + w, server := bundletest.NewClients(t) resources := ExportedResourcesMap{ "resources.jobs.job1": {ID: "123"}, } - jobsApi := m.GetMockJobsAPI() - jobsApi.EXPECT().ListRunsAll(mock.Anything, jobs.ListRunsRequest{ - JobId: 123, - ActiveOnly: true, - }).Return([]jobs.BaseRun{ - {RunId: 1234}, - }, nil).Once() + runs := []map[string]any{{"run_id": 1234}} + server.Handle("GET", "/api/2.2/jobs/runs/list", func(req testserver.Request) any { + assert.Equal(t, "123", req.URL.Query().Get("job_id")) + assert.Equal(t, "true", req.URL.Query().Get("active_only")) + return map[string]any{"runs": runs} + }) - err := checkAnyResourceRunning(t.Context(), m.WorkspaceClient, resources) + err := checkAnyResourceRunning(t.Context(), w, resources) require.ErrorContains(t, err, "job 123 is running") - jobsApi.EXPECT().ListRunsAll(mock.Anything, jobs.ListRunsRequest{ - JobId: 123, - ActiveOnly: true, - }).Return([]jobs.BaseRun{}, nil).Once() - - err = checkAnyResourceRunning(t.Context(), m.WorkspaceClient, resources) + runs = nil + err = checkAnyResourceRunning(t.Context(), w, resources) require.NoError(t, err) } func TestIsAnyResourceRunningWithPipeline(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) + w, server := bundletest.NewClients(t) resources := ExportedResourcesMap{ "resources.pipelines.pipeline1": {ID: "123"}, } - pipelineApi := m.GetMockPipelinesAPI() - pipelineApi.EXPECT().Get(mock.Anything, pipelines.GetPipelineRequest{ - PipelineId: "123", - }).Return(&pipelines.GetPipelineResponse{ - PipelineId: "123", - State: pipelines.PipelineStateRunning, - }, nil).Once() + state := "RUNNING" + server.Handle("GET", "/api/2.0/pipelines/{pipeline_id}", func(req testserver.Request) any { + assert.Equal(t, "123", req.Vars["pipeline_id"]) + return map[string]any{"pipeline_id": "123", "state": state} + }) - err := checkAnyResourceRunning(t.Context(), m.WorkspaceClient, resources) + err := checkAnyResourceRunning(t.Context(), w, resources) require.ErrorContains(t, err, "pipeline 123 is running") - pipelineApi.EXPECT().Get(mock.Anything, pipelines.GetPipelineRequest{ - PipelineId: "123", - }).Return(&pipelines.GetPipelineResponse{ - PipelineId: "123", - State: pipelines.PipelineStateIdle, - }, nil).Once() - err = checkAnyResourceRunning(t.Context(), m.WorkspaceClient, resources) + state = "IDLE" + err = checkAnyResourceRunning(t.Context(), w, resources) require.NoError(t, err) } func TestIsAnyResourceRunningWithAPIFailure(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - + w, server := bundletest.NewClients(t) resources := ExportedResourcesMap{ "resources.pipelines.pipeline1": {ID: "123"}, } - pipelineApi := m.GetMockPipelinesAPI() - pipelineApi.EXPECT().Get(mock.Anything, pipelines.GetPipelineRequest{ - PipelineId: "123", - }).Return(nil, errors.New("API failure")).Once() + server.Handle("GET", "/api/2.0/pipelines/{pipeline_id}", func(testserver.Request) any { + return testserver.Response{ + StatusCode: 400, + Body: map[string]string{"error_code": "INVALID_PARAMETER_VALUE", "message": "API failure"}, + } + }) - err := checkAnyResourceRunning(t.Context(), m.WorkspaceClient, resources) + err := checkAnyResourceRunning(t.Context(), w, resources) require.ErrorContains(t, err, "API failure") } func TestIsAnyResourceRunningWithDeletedJob(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) + w, server := bundletest.NewClients(t) resources := ExportedResourcesMap{ "resources.jobs.job1": {ID: "123"}, } - jobsApi := m.GetMockJobsAPI() - jobsApi.EXPECT().ListRunsAll(mock.Anything, jobs.ListRunsRequest{ - JobId: 123, - ActiveOnly: true, - }).Return(nil, &apierr.APIError{StatusCode: 404}).Once() + server.Handle("GET", "/api/2.2/jobs/runs/list", notFound) - err := checkAnyResourceRunning(t.Context(), m.WorkspaceClient, resources) + err := checkAnyResourceRunning(t.Context(), w, resources) require.NoError(t, err) } func TestIsAnyResourceRunningWithDeletedPipeline(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) + w, server := bundletest.NewClients(t) resources := ExportedResourcesMap{ "resources.pipelines.pipeline1": {ID: "123"}, } - pipelineApi := m.GetMockPipelinesAPI() - pipelineApi.EXPECT().Get(mock.Anything, pipelines.GetPipelineRequest{ - PipelineId: "123", - }).Return(nil, &apierr.APIError{StatusCode: 404}).Once() + server.Handle("GET", "/api/2.0/pipelines/{pipeline_id}", notFound) - err := checkAnyResourceRunning(t.Context(), m.WorkspaceClient, resources) + err := checkAnyResourceRunning(t.Context(), w, resources) require.NoError(t, err) } diff --git a/bundle/statemgmt/state_load_test.go b/bundle/statemgmt/state_load_test.go index b03ff469284..f993345ed77 100644 --- a/bundle/statemgmt/state_load_test.go +++ b/bundle/statemgmt/state_load_test.go @@ -4,19 +4,27 @@ import ( "reflect" "testing" + "github.com/databricks/cli/libs/qualitymonitors" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2" + "github.com/databricks/cli/libs/sdktypes/clusters/v2" + "github.com/databricks/cli/libs/sdktypes/database/v1" + "github.com/databricks/cli/libs/sdktypes/experiments/v1" + "github.com/databricks/cli/libs/sdktypes/instancepools/v2" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/modelregistry/v1" + "github.com/databricks/cli/libs/sdktypes/modelserving/v1" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1" + "github.com/databricks/cli/libs/sdktypes/uc/secrets/v1" + "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" + "github.com/databricks/cli/libs/sdktypes/warehouses/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/apps" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/database" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/postgres" - "github.com/databricks/databricks-sdk-go/service/serving" - "github.com/databricks/databricks-sdk-go/service/sql" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" "github.com/stretchr/testify/assert" ) @@ -114,7 +122,7 @@ func TestStateToBundleEmptyLocalResources(t *testing.T) { assert.Equal(t, resources.ModifiedStatusDeleted, config.Resources.GenieSpaces["test_genie_space"].ModifiedStatus) assert.Equal(t, "app1", config.Resources.Apps["test_app"].ID) - assert.Empty(t, config.Resources.Apps["test_app"].Name) + assert.Empty(t, utils.Deref(config.Resources.Apps["test_app"].Name)) assert.Equal(t, resources.ModifiedStatusDeleted, config.Resources.Apps["test_app"].ModifiedStatus) assert.Equal(t, "secret_scope1", config.Resources.SecretScopes["test_secret_scope"].ID) @@ -185,92 +193,92 @@ func TestStateToBundleEmptyRemoteResources(t *testing.T) { Jobs: map[string]*resources.Job{ "test_job": { JobSettings: jobs.JobSettings{ - Name: "test_job", + Name: new("test_job"), }, }, }, JobRuns: map[string]*resources.JobRun{ "test_job_run": { - RunNow: jobs.RunNow{ - JobId: 1234, + RunNowRequest: jobs.RunNowRequest{ + JobId: new(int64(1234)), }, }, }, Pipelines: map[string]*resources.Pipeline{ "test_pipeline": { - CreatePipeline: pipelines.CreatePipeline{ - Name: "test_pipeline", + CreatePipelineRequest: pipelines.CreatePipelineRequest{ + Name: new("test_pipeline"), }, }, }, Models: map[string]*resources.MlflowModel{ "test_mlflow_model": { - CreateModelRequest: ml.CreateModelRequest{ - Name: "test_mlflow_model", + CreateRegisteredModelRequest: modelregistry.CreateRegisteredModelRequest{ + Name: new("test_mlflow_model"), }, }, }, Experiments: map[string]*resources.MlflowExperiment{ "test_mlflow_experiment": { - CreateExperiment: ml.CreateExperiment{ - Name: "test_mlflow_experiment", + CreateExperimentRequest: experiments.CreateExperimentRequest{ + Name: new("test_mlflow_experiment"), }, }, }, ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{ "test_model_serving": { - CreateServingEndpoint: serving.CreateServingEndpoint{ - Name: "test_model_serving", + CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{ + Name: new("test_model_serving"), }, }, }, RegisteredModels: map[string]*resources.RegisteredModel{ "test_registered_model": { - CreateRegisteredModelRequest: catalog.CreateRegisteredModelRequest{ - Name: "test_registered_model", + CreateRegisteredModelRequest: registeredmodels.CreateRegisteredModelRequest{ + Name: new("test_registered_model"), }, }, }, QualityMonitors: map[string]*resources.QualityMonitor{ "test_monitor": { - CreateMonitor: catalog.CreateMonitor{ + CreateMonitor: qualitymonitors.CreateMonitor{ TableName: "test_monitor", }, }, }, Catalogs: map[string]*resources.Catalog{ "test_catalog": { - CreateCatalog: catalog.CreateCatalog{ - Name: "test_catalog", + CreateCatalog: resources.CreateCatalog{ + Name: new("test_catalog"), }, }, }, Schemas: map[string]*resources.Schema{ "test_schema": { - CreateSchema: catalog.CreateSchema{ - Name: "test_schema", + CreateSchema: resources.CreateSchema{ + Name: new("test_schema"), }, }, }, ExternalLocations: map[string]*resources.ExternalLocation{ "test_external_location": { - CreateExternalLocation: catalog.CreateExternalLocation{ - Name: "test_external_location", - Url: "s3://test-bucket/path", + CreateExternalLocation: resources.CreateExternalLocation{ + Name: new("test_external_location"), + Url: new("s3://test-bucket/path"), }, }, }, Volumes: map[string]*resources.Volume{ "test_volume": { - CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{ - Name: "test_volume", + CreateVolumeRequestContent: resources.CreateVolumeRequestContent{ + Name: new("test_volume"), }, }, }, Clusters: map[string]*resources.Cluster{ "test_cluster": { - ClusterSpec: compute.ClusterSpec{ - ClusterName: "test_cluster", + CreateClusterRequest: clusters.CreateClusterRequest{ + ClusterName: new("test_cluster"), }, }, }, @@ -291,7 +299,7 @@ func TestStateToBundleEmptyRemoteResources(t *testing.T) { Apps: map[string]*resources.App{ "test_app": { App: apps.App{ - Description: "test_app", + Description: new("test_app"), }, }, }, @@ -302,45 +310,45 @@ func TestStateToBundleEmptyRemoteResources(t *testing.T) { }, Secrets: map[string]*resources.Secret{ "test_secret": { - Secret: catalog.Secret{ - CatalogName: "main", - SchemaName: "default", - Name: "test_secret", + Secret: secrets.Secret{ + CatalogName: new("main"), + SchemaName: new("default"), + Name: new("test_secret"), }, }, }, SqlWarehouses: map[string]*resources.SqlWarehouse{ "test_sql_warehouse": { - CreateWarehouseRequest: sql.CreateWarehouseRequest{ - Name: "test_sql_warehouse", + CreateWarehouseRequest: warehouses.CreateWarehouseRequest{ + Name: new("test_sql_warehouse"), }, }, }, DatabaseInstances: map[string]*resources.DatabaseInstance{ "test_database_instance": { DatabaseInstance: database.DatabaseInstance{ - Name: "test_database_instance", + Name: new("test_database_instance"), }, }, }, DatabaseCatalogs: map[string]*resources.DatabaseCatalog{ "test_database_catalog": { DatabaseCatalog: database.DatabaseCatalog{ - Name: "test_database_catalog", + Name: new("test_database_catalog"), }, }, }, SyncedDatabaseTables: map[string]*resources.SyncedDatabaseTable{ "test_synced_database_table": { SyncedDatabaseTable: database.SyncedDatabaseTable{ - Name: "test_synced_database_table", + Name: new("test_synced_database_table"), }, }, }, Alerts: map[string]*resources.Alert{ "test_alert": { - AlertV2: sql.AlertV2{ - DisplayName: "test_alert", + Alert: alerts.Alert{ + DisplayName: new("test_alert"), }, }, }, @@ -349,7 +357,7 @@ func TestStateToBundleEmptyRemoteResources(t *testing.T) { PostgresProjectConfig: resources.PostgresProjectConfig{ ProjectId: "test-project", ProjectSpec: postgres.ProjectSpec{ - DisplayName: "test_postgres_project", + DisplayName: new("test_postgres_project"), }, }, }, @@ -409,29 +417,29 @@ func TestStateToBundleEmptyRemoteResources(t *testing.T) { }, VectorSearchEndpoints: map[string]*resources.VectorSearchEndpoint{ "test_vector_search_endpoint": { - CreateEndpoint: vectorsearch.CreateEndpoint{ - Name: "test_vector_search_endpoint", + CreateEndpointRequest: vectorsearch.CreateEndpointRequest{ + Name: new("test_vector_search_endpoint"), }, }, }, VectorSearchIndexes: map[string]*resources.VectorSearchIndex{ "test_vector_search_index": { CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{ - Name: "test_vector_search_index", + Name: new("test_vector_search_index"), }, }, }, InstancePools: map[string]*resources.InstancePool{ "test_instance_pool": { - CreateInstancePool: compute.CreateInstancePool{ - InstancePoolName: "test_instance_pool", + CreateInstancePoolRequest: instancepools.CreateInstancePoolRequest{ + InstancePoolName: new("test_instance_pool"), }, }, }, ClusterPolicies: map[string]*resources.ClusterPolicy{ "test_cluster_policy": { - CreatePolicy: compute.CreatePolicy{ - Name: "test_cluster_policy", + CreatePolicyRequest: clusterpolicies.CreatePolicyRequest{ + Name: new("test_cluster_policy"), }, }, }, @@ -510,7 +518,7 @@ func TestStateToBundleEmptyRemoteResources(t *testing.T) { assert.Empty(t, config.Resources.GenieSpaces["test_genie_space"].ID) assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.GenieSpaces["test_genie_space"].ModifiedStatus) - assert.Empty(t, config.Resources.Apps["test_app"].Name) + assert.Empty(t, utils.Deref(config.Resources.Apps["test_app"].Name)) assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.Apps["test_app"].ModifiedStatus) assert.Empty(t, config.Resources.SecretScopes["test_secret_scope"].ID) @@ -587,152 +595,152 @@ func TestStateToBundleModifiedResources(t *testing.T) { Jobs: map[string]*resources.Job{ "test_job": { JobSettings: jobs.JobSettings{ - Name: "test_job", + Name: new("test_job"), }, }, "test_job_new": { JobSettings: jobs.JobSettings{ - Name: "test_job_new", + Name: new("test_job_new"), }, }, }, JobRuns: map[string]*resources.JobRun{ "test_job_run": { - RunNow: jobs.RunNow{ - JobId: 1234, + RunNowRequest: jobs.RunNowRequest{ + JobId: new(int64(1234)), }, }, "test_job_run_new": { - RunNow: jobs.RunNow{ - JobId: 5678, + RunNowRequest: jobs.RunNowRequest{ + JobId: new(int64(5678)), }, }, }, Pipelines: map[string]*resources.Pipeline{ "test_pipeline": { - CreatePipeline: pipelines.CreatePipeline{ - Name: "test_pipeline", + CreatePipelineRequest: pipelines.CreatePipelineRequest{ + Name: new("test_pipeline"), }, }, "test_pipeline_new": { - CreatePipeline: pipelines.CreatePipeline{ - Name: "test_pipeline_new", + CreatePipelineRequest: pipelines.CreatePipelineRequest{ + Name: new("test_pipeline_new"), }, }, }, Models: map[string]*resources.MlflowModel{ "test_mlflow_model": { - CreateModelRequest: ml.CreateModelRequest{ - Name: "test_mlflow_model", + CreateRegisteredModelRequest: modelregistry.CreateRegisteredModelRequest{ + Name: new("test_mlflow_model"), }, }, "test_mlflow_model_new": { - CreateModelRequest: ml.CreateModelRequest{ - Name: "test_mlflow_model_new", + CreateRegisteredModelRequest: modelregistry.CreateRegisteredModelRequest{ + Name: new("test_mlflow_model_new"), }, }, }, Experiments: map[string]*resources.MlflowExperiment{ "test_mlflow_experiment": { - CreateExperiment: ml.CreateExperiment{ - Name: "test_mlflow_experiment", + CreateExperimentRequest: experiments.CreateExperimentRequest{ + Name: new("test_mlflow_experiment"), }, }, "test_mlflow_experiment_new": { - CreateExperiment: ml.CreateExperiment{ - Name: "test_mlflow_experiment_new", + CreateExperimentRequest: experiments.CreateExperimentRequest{ + Name: new("test_mlflow_experiment_new"), }, }, }, ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{ "test_model_serving": { - CreateServingEndpoint: serving.CreateServingEndpoint{ - Name: "test_model_serving", + CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{ + Name: new("test_model_serving"), }, }, "test_model_serving_new": { - CreateServingEndpoint: serving.CreateServingEndpoint{ - Name: "test_model_serving_new", + CreateInferenceEndpointRequest: modelserving.CreateInferenceEndpointRequest{ + Name: new("test_model_serving_new"), }, }, }, RegisteredModels: map[string]*resources.RegisteredModel{ "test_registered_model": { - CreateRegisteredModelRequest: catalog.CreateRegisteredModelRequest{ - Name: "test_registered_model", + CreateRegisteredModelRequest: registeredmodels.CreateRegisteredModelRequest{ + Name: new("test_registered_model"), }, }, "test_registered_model_new": { - CreateRegisteredModelRequest: catalog.CreateRegisteredModelRequest{ - Name: "test_registered_model_new", + CreateRegisteredModelRequest: registeredmodels.CreateRegisteredModelRequest{ + Name: new("test_registered_model_new"), }, }, }, QualityMonitors: map[string]*resources.QualityMonitor{ "test_monitor": { - CreateMonitor: catalog.CreateMonitor{ + CreateMonitor: qualitymonitors.CreateMonitor{ TableName: "test_monitor", }, }, "test_monitor_new": { - CreateMonitor: catalog.CreateMonitor{ + CreateMonitor: qualitymonitors.CreateMonitor{ TableName: "test_monitor_new", }, }, }, Catalogs: map[string]*resources.Catalog{ "test_catalog": { - CreateCatalog: catalog.CreateCatalog{ - Name: "test_catalog", + CreateCatalog: resources.CreateCatalog{ + Name: new("test_catalog"), }, }, "test_catalog_new": { - CreateCatalog: catalog.CreateCatalog{ - Name: "test_catalog_new", + CreateCatalog: resources.CreateCatalog{ + Name: new("test_catalog_new"), }, }, }, Schemas: map[string]*resources.Schema{ "test_schema": { - CreateSchema: catalog.CreateSchema{ - Name: "test_schema", + CreateSchema: resources.CreateSchema{ + Name: new("test_schema"), }, }, "test_schema_new": { - CreateSchema: catalog.CreateSchema{ - Name: "test_schema_new", + CreateSchema: resources.CreateSchema{ + Name: new("test_schema_new"), }, }, }, ExternalLocations: map[string]*resources.ExternalLocation{ "test_external_location": { - CreateExternalLocation: catalog.CreateExternalLocation{ - Name: "test_external_location", - Url: "s3://test-bucket/path", + CreateExternalLocation: resources.CreateExternalLocation{ + Name: new("test_external_location"), + Url: new("s3://test-bucket/path"), }, }, }, Volumes: map[string]*resources.Volume{ "test_volume": { - CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{ - Name: "test_volume", + CreateVolumeRequestContent: resources.CreateVolumeRequestContent{ + Name: new("test_volume"), }, }, "test_volume_new": { - CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{ - Name: "test_volume_new", + CreateVolumeRequestContent: resources.CreateVolumeRequestContent{ + Name: new("test_volume_new"), }, }, }, Clusters: map[string]*resources.Cluster{ "test_cluster": { - ClusterSpec: compute.ClusterSpec{ - ClusterName: "test_cluster", + CreateClusterRequest: clusters.CreateClusterRequest{ + ClusterName: new("test_cluster"), }, }, "test_cluster_new": { - ClusterSpec: compute.ClusterSpec{ - ClusterName: "test_cluster_new", + CreateClusterRequest: clusters.CreateClusterRequest{ + ClusterName: new("test_cluster_new"), }, }, }, @@ -763,12 +771,12 @@ func TestStateToBundleModifiedResources(t *testing.T) { Apps: map[string]*resources.App{ "test_app": { App: apps.App{ - Name: "test_app", + Name: new("test_app"), }, }, "test_app_new": { App: apps.App{ - Name: "test_app_new", + Name: new("test_app_new"), }, }, }, @@ -782,77 +790,77 @@ func TestStateToBundleModifiedResources(t *testing.T) { }, Secrets: map[string]*resources.Secret{ "test_secret": { - Secret: catalog.Secret{ - CatalogName: "main", - SchemaName: "default", - Name: "test_secret", + Secret: secrets.Secret{ + CatalogName: new("main"), + SchemaName: new("default"), + Name: new("test_secret"), }, }, "test_secret_new": { - Secret: catalog.Secret{ - CatalogName: "main", - SchemaName: "default", - Name: "test_secret_new", + Secret: secrets.Secret{ + CatalogName: new("main"), + SchemaName: new("default"), + Name: new("test_secret_new"), }, }, }, SqlWarehouses: map[string]*resources.SqlWarehouse{ "test_sql_warehouse": { - CreateWarehouseRequest: sql.CreateWarehouseRequest{ - Name: "test_sql_warehouse", + CreateWarehouseRequest: warehouses.CreateWarehouseRequest{ + Name: new("test_sql_warehouse"), }, }, "test_sql_warehouse_new": { - CreateWarehouseRequest: sql.CreateWarehouseRequest{ - Name: "test_sql_warehouse_new", + CreateWarehouseRequest: warehouses.CreateWarehouseRequest{ + Name: new("test_sql_warehouse_new"), }, }, }, DatabaseInstances: map[string]*resources.DatabaseInstance{ "test_database_instance": { DatabaseInstance: database.DatabaseInstance{ - Name: "test_database_instance", + Name: new("test_database_instance"), }, }, "test_database_instance_new": { DatabaseInstance: database.DatabaseInstance{ - Name: "test_database_instance_new", + Name: new("test_database_instance_new"), }, }, }, DatabaseCatalogs: map[string]*resources.DatabaseCatalog{ "test_database_catalog": { DatabaseCatalog: database.DatabaseCatalog{ - Name: "test_database_catalog", + Name: new("test_database_catalog"), }, }, "test_database_catalog_new": { DatabaseCatalog: database.DatabaseCatalog{ - Name: "test_database_catalog_new", + Name: new("test_database_catalog_new"), }, }, }, SyncedDatabaseTables: map[string]*resources.SyncedDatabaseTable{ "test_synced_database_table": { SyncedDatabaseTable: database.SyncedDatabaseTable{ - Name: "test_synced_database_table", + Name: new("test_synced_database_table"), }, }, "test_synced_database_table_new": { SyncedDatabaseTable: database.SyncedDatabaseTable{ - Name: "test_synced_database_table_new", + Name: new("test_synced_database_table_new"), }, }, }, Alerts: map[string]*resources.Alert{ "test_alert": { - AlertV2: sql.AlertV2{ - DisplayName: "test_alert", + Alert: alerts.Alert{ + DisplayName: new("test_alert"), }, }, "test_alert_new": { - AlertV2: sql.AlertV2{ - DisplayName: "test_alert_new", + Alert: alerts.Alert{ + DisplayName: new("test_alert_new"), }, }, }, @@ -861,7 +869,7 @@ func TestStateToBundleModifiedResources(t *testing.T) { PostgresProjectConfig: resources.PostgresProjectConfig{ ProjectId: "test-project", ProjectSpec: postgres.ProjectSpec{ - DisplayName: "test_postgres_project", + DisplayName: new("test_postgres_project"), }, }, }, @@ -869,7 +877,7 @@ func TestStateToBundleModifiedResources(t *testing.T) { PostgresProjectConfig: resources.PostgresProjectConfig{ ProjectId: "test-project-new", ProjectSpec: postgres.ProjectSpec{ - DisplayName: "test_postgres_project_new", + DisplayName: new("test_postgres_project_new"), }, }, }, @@ -958,49 +966,49 @@ func TestStateToBundleModifiedResources(t *testing.T) { }, VectorSearchEndpoints: map[string]*resources.VectorSearchEndpoint{ "test_vector_search_endpoint": { - CreateEndpoint: vectorsearch.CreateEndpoint{ - Name: "test_vector_search_endpoint", + CreateEndpointRequest: vectorsearch.CreateEndpointRequest{ + Name: new("test_vector_search_endpoint"), }, }, "test_vector_search_endpoint_new": { - CreateEndpoint: vectorsearch.CreateEndpoint{ - Name: "test_vector_search_endpoint_new", + CreateEndpointRequest: vectorsearch.CreateEndpointRequest{ + Name: new("test_vector_search_endpoint_new"), }, }, }, VectorSearchIndexes: map[string]*resources.VectorSearchIndex{ "test_vector_search_index": { CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{ - Name: "test_vector_search_index", + Name: new("test_vector_search_index"), }, }, "test_vector_search_index_new": { CreateVectorIndexRequest: vectorsearch.CreateVectorIndexRequest{ - Name: "test_vector_search_index_new", + Name: new("test_vector_search_index_new"), }, }, }, InstancePools: map[string]*resources.InstancePool{ "test_instance_pool": { - CreateInstancePool: compute.CreateInstancePool{ - InstancePoolName: "test_instance_pool", + CreateInstancePoolRequest: instancepools.CreateInstancePoolRequest{ + InstancePoolName: new("test_instance_pool"), }, }, "test_instance_pool_new": { - CreateInstancePool: compute.CreateInstancePool{ - InstancePoolName: "test_instance_pool_new", + CreateInstancePoolRequest: instancepools.CreateInstancePoolRequest{ + InstancePoolName: new("test_instance_pool_new"), }, }, }, ClusterPolicies: map[string]*resources.ClusterPolicy{ "test_cluster_policy": { - CreatePolicy: compute.CreatePolicy{ - Name: "test_cluster_policy", + CreatePolicyRequest: clusterpolicies.CreatePolicyRequest{ + Name: new("test_cluster_policy"), }, }, "test_cluster_policy_new": { - CreatePolicy: compute.CreatePolicy{ - Name: "test_cluster_policy_new", + CreatePolicyRequest: clusterpolicies.CreatePolicyRequest{ + Name: new("test_cluster_policy_new"), }, }, }, @@ -1217,12 +1225,12 @@ func TestStateToBundleModifiedResources(t *testing.T) { assert.Empty(t, config.Resources.GenieSpaces["test_genie_space_new"].ID) assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.GenieSpaces["test_genie_space_new"].ModifiedStatus) - assert.Equal(t, "test_app", config.Resources.Apps["test_app"].Name) + assert.Equal(t, "test_app", utils.Deref(config.Resources.Apps["test_app"].Name)) assert.Empty(t, config.Resources.Apps["test_app"].ModifiedStatus) assert.Equal(t, "test_app_old", config.Resources.Apps["test_app_old"].ID) - assert.Empty(t, config.Resources.Apps["test_app_old"].Name) + assert.Empty(t, utils.Deref(config.Resources.Apps["test_app_old"].Name)) assert.Equal(t, resources.ModifiedStatusDeleted, config.Resources.Apps["test_app_old"].ModifiedStatus) - assert.Equal(t, "test_app_new", config.Resources.Apps["test_app_new"].Name) + assert.Equal(t, "test_app_new", utils.Deref(config.Resources.Apps["test_app_new"].Name)) assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.Apps["test_app_new"].ModifiedStatus) assert.Equal(t, "test_secret_scope", config.Resources.SecretScopes["test_secret_scope"].Name) diff --git a/bundle/tests/environment_overrides_test.go b/bundle/tests/environment_overrides_test.go index b68b083ffc5..1052a6d434c 100644 --- a/bundle/tests/environment_overrides_test.go +++ b/bundle/tests/environment_overrides_test.go @@ -3,6 +3,8 @@ package config_tests import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/stretchr/testify/assert" ) @@ -18,18 +20,18 @@ func TestEnvironmentOverridesWorkspaceStaging(t *testing.T) { func TestEnvironmentOverridesResourcesDev(t *testing.T) { b := loadTarget(t, "./environment_overrides/resources", "development") - assert.Equal(t, "base job", b.Config.Resources.Jobs["job1"].Name) + assert.Equal(t, "base job", utils.Deref(b.Config.Resources.Jobs["job1"].Name)) // Base values are preserved in the development environment. - assert.True(t, b.Config.Resources.Pipelines["boolean1"].Photon) - assert.False(t, b.Config.Resources.Pipelines["boolean2"].Photon) + assert.True(t, utils.Deref(b.Config.Resources.Pipelines["boolean1"].Photon)) + assert.False(t, utils.Deref(b.Config.Resources.Pipelines["boolean2"].Photon)) } func TestEnvironmentOverridesResourcesStaging(t *testing.T) { b := loadTarget(t, "./environment_overrides/resources", "staging") - assert.Equal(t, "staging job", b.Config.Resources.Jobs["job1"].Name) + assert.Equal(t, "staging job", utils.Deref(b.Config.Resources.Jobs["job1"].Name)) // Override values are applied in the staging environment. - assert.False(t, b.Config.Resources.Pipelines["boolean1"].Photon) - assert.True(t, b.Config.Resources.Pipelines["boolean2"].Photon) + assert.False(t, utils.Deref(b.Config.Resources.Pipelines["boolean1"].Photon)) + assert.True(t, utils.Deref(b.Config.Resources.Pipelines["boolean2"].Photon)) } diff --git a/bundle/tests/environments_job_and_pipeline_test.go b/bundle/tests/environments_job_and_pipeline_test.go index 148b1ecaa4a..a3f837a5cf6 100644 --- a/bundle/tests/environments_job_and_pipeline_test.go +++ b/bundle/tests/environments_job_and_pipeline_test.go @@ -3,6 +3,8 @@ package config_tests import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -15,10 +17,10 @@ func TestJobAndPipelineDevelopmentWithEnvironment(t *testing.T) { p := b.Config.Resources.Pipelines["nyc_taxi_pipeline"] assert.Equal(t, config.Development, b.Config.Bundle.Mode) - assert.True(t, p.Development) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field + assert.True(t, utils.Deref(p.Development)) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field require.Len(t, p.Libraries, 1) - assert.Equal(t, "./dlt/nyc_taxi_loader", p.Libraries[0].Notebook.Path) - assert.Equal(t, "nyc_taxi_development", p.Target) + assert.Equal(t, "./dlt/nyc_taxi_loader", utils.Deref(p.Libraries[0].Notebook.Path)) + assert.Equal(t, "nyc_taxi_development", utils.Deref(p.Target)) } func TestJobAndPipelineStagingWithEnvironment(t *testing.T) { @@ -27,10 +29,10 @@ func TestJobAndPipelineStagingWithEnvironment(t *testing.T) { assert.Len(t, b.Config.Resources.Pipelines, 1) p := b.Config.Resources.Pipelines["nyc_taxi_pipeline"] - assert.False(t, p.Development) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field + assert.False(t, utils.Deref(p.Development)) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field require.Len(t, p.Libraries, 1) - assert.Equal(t, "./dlt/nyc_taxi_loader", p.Libraries[0].Notebook.Path) - assert.Equal(t, "nyc_taxi_staging", p.Target) + assert.Equal(t, "./dlt/nyc_taxi_loader", utils.Deref(p.Libraries[0].Notebook.Path)) + assert.Equal(t, "nyc_taxi_staging", utils.Deref(p.Target)) } func TestJobAndPipelineProductionWithEnvironment(t *testing.T) { @@ -39,13 +41,13 @@ func TestJobAndPipelineProductionWithEnvironment(t *testing.T) { assert.Len(t, b.Config.Resources.Pipelines, 1) p := b.Config.Resources.Pipelines["nyc_taxi_pipeline"] - assert.False(t, p.Development) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field + assert.False(t, utils.Deref(p.Development)) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field require.Len(t, p.Libraries, 1) - assert.Equal(t, "./dlt/nyc_taxi_loader", p.Libraries[0].Notebook.Path) - assert.Equal(t, "nyc_taxi_production", p.Target) + assert.Equal(t, "./dlt/nyc_taxi_loader", utils.Deref(p.Libraries[0].Notebook.Path)) + assert.Equal(t, "nyc_taxi_production", utils.Deref(p.Target)) j := b.Config.Resources.Jobs["pipeline_schedule"] - assert.Equal(t, "Daily refresh of production pipeline", j.Name) + assert.Equal(t, "Daily refresh of production pipeline", utils.Deref(j.Name)) require.Len(t, j.Tasks, 1) - assert.NotEmpty(t, j.Tasks[0].PipelineTask.PipelineId) + assert.NotEmpty(t, utils.Deref(j.Tasks[0].PipelineTask.PipelineId)) } diff --git a/bundle/tests/environments_override_job_cluster_test.go b/bundle/tests/environments_override_job_cluster_test.go index b3ec74453e3..fd06816c932 100644 --- a/bundle/tests/environments_override_job_cluster_test.go +++ b/bundle/tests/environments_override_job_cluster_test.go @@ -3,27 +3,29 @@ package config_tests import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/stretchr/testify/assert" ) func TestOverrideJobClusterDevWithEnvironment(t *testing.T) { b := loadTarget(t, "./environments_override_job_cluster", "development") - assert.Equal(t, "job", b.Config.Resources.Jobs["foo"].Name) + assert.Equal(t, "job", utils.Deref(b.Config.Resources.Jobs["foo"].Name)) assert.Len(t, b.Config.Resources.Jobs["foo"].JobClusters, 1) c := b.Config.Resources.Jobs["foo"].JobClusters[0] - assert.Equal(t, "13.3.x-scala2.12", c.NewCluster.SparkVersion) - assert.Equal(t, "i3.xlarge", c.NewCluster.NodeTypeId) - assert.Equal(t, 1, c.NewCluster.NumWorkers) + assert.Equal(t, "13.3.x-scala2.12", utils.Deref(c.NewCluster.SparkVersion)) + assert.Equal(t, "i3.xlarge", utils.Deref(c.NewCluster.NodeTypeId)) + assert.Equal(t, 1, utils.Deref(c.NewCluster.NumWorkers)) } func TestOverrideJobClusterStagingWithEnvironment(t *testing.T) { b := loadTarget(t, "./environments_override_job_cluster", "staging") - assert.Equal(t, "job", b.Config.Resources.Jobs["foo"].Name) + assert.Equal(t, "job", utils.Deref(b.Config.Resources.Jobs["foo"].Name)) assert.Len(t, b.Config.Resources.Jobs["foo"].JobClusters, 1) c := b.Config.Resources.Jobs["foo"].JobClusters[0] - assert.Equal(t, "13.3.x-scala2.12", c.NewCluster.SparkVersion) - assert.Equal(t, "i3.2xlarge", c.NewCluster.NodeTypeId) - assert.Equal(t, 4, c.NewCluster.NumWorkers) + assert.Equal(t, "13.3.x-scala2.12", utils.Deref(c.NewCluster.SparkVersion)) + assert.Equal(t, "i3.2xlarge", utils.Deref(c.NewCluster.NodeTypeId)) + assert.Equal(t, 4, utils.Deref(c.NewCluster.NumWorkers)) } diff --git a/bundle/tests/interpolation_test.go b/bundle/tests/interpolation_test.go index 86ca833a6c3..083b20785d5 100644 --- a/bundle/tests/interpolation_test.go +++ b/bundle/tests/interpolation_test.go @@ -3,6 +3,8 @@ package config_tests import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config/mutator" "github.com/stretchr/testify/assert" @@ -25,7 +27,7 @@ func TestInterpolation(t *testing.T) { ) require.NoError(t, diags.Error()) assert.Equal(t, "foo bar", b.Config.Bundle.Name) - assert.Equal(t, "foo bar | bar", b.Config.Resources.Jobs["my_job"].Name) + assert.Equal(t, "foo bar | bar", utils.Deref(b.Config.Resources.Jobs["my_job"].Name)) } func TestInterpolationWithTarget_withoutResources(t *testing.T) { @@ -36,7 +38,7 @@ func TestInterpolationWithTarget_withoutResources(t *testing.T) { )) require.NoError(t, diags.Error()) assert.Equal(t, "foo ${workspace.profile}", b.Config.Bundle.Name) - assert.Equal(t, "foo bar | bar | development | development", b.Config.Resources.Jobs["my_job"].Name) + assert.Equal(t, "foo bar | bar | development | development", utils.Deref(b.Config.Resources.Jobs["my_job"].Name)) } func TestInterpolationWithTarget_onlyResources(t *testing.T) { @@ -47,5 +49,5 @@ func TestInterpolationWithTarget_onlyResources(t *testing.T) { )) require.NoError(t, diags.Error()) assert.Equal(t, "foo bar", b.Config.Bundle.Name) - assert.Equal(t, "${bundle.name} | ${workspace.profile} | ${bundle.environment} | ${bundle.target}", b.Config.Resources.Jobs["my_job"].Name) + assert.Equal(t, "${bundle.name} | ${workspace.profile} | ${bundle.environment} | ${bundle.target}", utils.Deref(b.Config.Resources.Jobs["my_job"].Name)) } diff --git a/bundle/tests/job_and_pipeline_test.go b/bundle/tests/job_and_pipeline_test.go index ceb200c8691..07ca9e51a69 100644 --- a/bundle/tests/job_and_pipeline_test.go +++ b/bundle/tests/job_and_pipeline_test.go @@ -3,6 +3,8 @@ package config_tests import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -15,10 +17,10 @@ func TestJobAndPipelineDevelopment(t *testing.T) { p := b.Config.Resources.Pipelines["nyc_taxi_pipeline"] assert.Equal(t, config.Development, b.Config.Bundle.Mode) - assert.True(t, p.Development) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field + assert.True(t, utils.Deref(p.Development)) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field require.Len(t, p.Libraries, 1) - assert.Equal(t, "./dlt/nyc_taxi_loader", p.Libraries[0].Notebook.Path) - assert.Equal(t, "nyc_taxi_development", p.Target) + assert.Equal(t, "./dlt/nyc_taxi_loader", utils.Deref(p.Libraries[0].Notebook.Path)) + assert.Equal(t, "nyc_taxi_development", utils.Deref(p.Target)) } func TestJobAndPipelineStaging(t *testing.T) { @@ -27,10 +29,10 @@ func TestJobAndPipelineStaging(t *testing.T) { assert.Len(t, b.Config.Resources.Pipelines, 1) p := b.Config.Resources.Pipelines["nyc_taxi_pipeline"] - assert.False(t, p.Development) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field + assert.False(t, utils.Deref(p.Development)) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field require.Len(t, p.Libraries, 1) - assert.Equal(t, "./dlt/nyc_taxi_loader", p.Libraries[0].Notebook.Path) - assert.Equal(t, "nyc_taxi_staging", p.Target) + assert.Equal(t, "./dlt/nyc_taxi_loader", utils.Deref(p.Libraries[0].Notebook.Path)) + assert.Equal(t, "nyc_taxi_staging", utils.Deref(p.Target)) } func TestJobAndPipelineProduction(t *testing.T) { @@ -39,13 +41,13 @@ func TestJobAndPipelineProduction(t *testing.T) { assert.Len(t, b.Config.Resources.Pipelines, 1) p := b.Config.Resources.Pipelines["nyc_taxi_pipeline"] - assert.False(t, p.Development) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field + assert.False(t, utils.Deref(p.Development)) //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field require.Len(t, p.Libraries, 1) - assert.Equal(t, "./dlt/nyc_taxi_loader", p.Libraries[0].Notebook.Path) - assert.Equal(t, "nyc_taxi_production", p.Target) + assert.Equal(t, "./dlt/nyc_taxi_loader", utils.Deref(p.Libraries[0].Notebook.Path)) + assert.Equal(t, "nyc_taxi_production", utils.Deref(p.Target)) j := b.Config.Resources.Jobs["pipeline_schedule"] - assert.Equal(t, "Daily refresh of production pipeline", j.Name) + assert.Equal(t, "Daily refresh of production pipeline", utils.Deref(j.Name)) require.Len(t, j.Tasks, 1) - assert.NotEmpty(t, j.Tasks[0].PipelineTask.PipelineId) + assert.NotEmpty(t, utils.Deref(j.Tasks[0].PipelineTask.PipelineId)) } diff --git a/bundle/tests/job_with_spark_conf_test.go b/bundle/tests/job_with_spark_conf_test.go index 90bdc977d6e..2853515c60f 100644 --- a/bundle/tests/job_with_spark_conf_test.go +++ b/bundle/tests/job_with_spark_conf_test.go @@ -3,6 +3,8 @@ package config_tests import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -13,15 +15,15 @@ func TestJobWithSparkConf(t *testing.T) { job := b.Config.Resources.Jobs["job_with_spark_conf"] assert.Len(t, job.JobClusters, 1) - assert.Equal(t, "test_cluster", job.JobClusters[0].JobClusterKey) + assert.Equal(t, "test_cluster", utils.Deref(job.JobClusters[0].JobClusterKey)) // This test exists because of https://github.com/databricks/cli/issues/992. // It is solved for bundles as of https://github.com/databricks/cli/pull/1098. require.Len(t, job.JobClusters, 1) cluster := job.JobClusters[0] - assert.Equal(t, "14.2.x-scala2.12", cluster.NewCluster.SparkVersion) - assert.Equal(t, "i3.xlarge", cluster.NewCluster.NodeTypeId) - assert.Equal(t, 2, cluster.NewCluster.NumWorkers) + assert.Equal(t, "14.2.x-scala2.12", utils.Deref(cluster.NewCluster.SparkVersion)) + assert.Equal(t, "i3.xlarge", utils.Deref(cluster.NewCluster.NodeTypeId)) + assert.Equal(t, 2, utils.Deref(cluster.NewCluster.NumWorkers)) assert.Equal(t, map[string]string{ "spark.string": "string", "spark.int": "1", diff --git a/bundle/tests/model_serving_endpoint_test.go b/bundle/tests/model_serving_endpoint_test.go index c0997c0f9a6..dbacabcd03f 100644 --- a/bundle/tests/model_serving_endpoint_test.go +++ b/bundle/tests/model_serving_endpoint_test.go @@ -3,6 +3,8 @@ package config_tests import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/stretchr/testify/assert" @@ -12,11 +14,11 @@ func assertExpected(t *testing.T, p *resources.ModelServingEndpoint) { // After ModelServingEndpointFixups mutator, served_models is converted to served_entities assert.Nil(t, p.Config.ServedModels, "served_models should be nil after conversion") assert.Len(t, p.Config.ServedEntities, 1, "served_entities should have one entity") - assert.Equal(t, "model-name", p.Config.ServedEntities[0].EntityName) - assert.Equal(t, "1", p.Config.ServedEntities[0].EntityVersion) + assert.Equal(t, "model-name", utils.Deref(p.Config.ServedEntities[0].EntityName)) + assert.Equal(t, "1", utils.Deref(p.Config.ServedEntities[0].EntityVersion)) - assert.Equal(t, "model-name-1", p.Config.TrafficConfig.Routes[0].ServedModelName) - assert.Equal(t, 100, p.Config.TrafficConfig.Routes[0].TrafficPercentage) + assert.Equal(t, "model-name-1", utils.Deref(p.Config.TrafficConfig.Routes[0].ServedModelName)) + assert.Equal(t, 100, utils.Deref(p.Config.TrafficConfig.Routes[0].TrafficPercentage)) assert.Equal(t, resources.ModelServingEndpointPermission{ GroupName: "users", Level: "CAN_QUERY", @@ -29,7 +31,7 @@ func TestModelServingEndpointDevelopment(t *testing.T) { assert.Equal(t, config.Development, b.Config.Bundle.Mode) p := b.Config.Resources.ModelServingEndpoints["my_model_serving_endpoint"] - assert.Equal(t, "my-dev-endpoint", p.Name) + assert.Equal(t, "my-dev-endpoint", utils.Deref(p.Name)) assertExpected(t, p) } @@ -38,7 +40,7 @@ func TestModelServingEndpointStaging(t *testing.T) { assert.Len(t, b.Config.Resources.ModelServingEndpoints, 1) p := b.Config.Resources.ModelServingEndpoints["my_model_serving_endpoint"] - assert.Equal(t, "my-staging-endpoint", p.Name) + assert.Equal(t, "my-staging-endpoint", utils.Deref(p.Name)) assertExpected(t, p) } @@ -47,6 +49,6 @@ func TestModelServingEndpointProduction(t *testing.T) { assert.Len(t, b.Config.Resources.ModelServingEndpoints, 1) p := b.Config.Resources.ModelServingEndpoints["my_model_serving_endpoint"] - assert.Equal(t, "my-prod-endpoint", p.Name) + assert.Equal(t, "my-prod-endpoint", utils.Deref(p.Name)) assertExpected(t, p) } diff --git a/bundle/tests/override_job_parameters_test.go b/bundle/tests/override_job_parameters_test.go index 21e0e35a67b..05139fcf08a 100644 --- a/bundle/tests/override_job_parameters_test.go +++ b/bundle/tests/override_job_parameters_test.go @@ -3,29 +3,31 @@ package config_tests import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/stretchr/testify/assert" ) func TestOverrideJobParametersDev(t *testing.T) { b := loadTarget(t, "./override_job_parameters", "development") - assert.Equal(t, "job", b.Config.Resources.Jobs["foo"].Name) + assert.Equal(t, "job", utils.Deref(b.Config.Resources.Jobs["foo"].Name)) p := b.Config.Resources.Jobs["foo"].Parameters assert.Len(t, p, 2) - assert.Equal(t, "foo", p[0].Name) - assert.Equal(t, "v2", p[0].Default) - assert.Equal(t, "bar", p[1].Name) - assert.Equal(t, "v1", p[1].Default) + assert.Equal(t, "foo", utils.Deref(p[0].Name)) + assert.Equal(t, "v2", utils.Deref(p[0].Default)) + assert.Equal(t, "bar", utils.Deref(p[1].Name)) + assert.Equal(t, "v1", utils.Deref(p[1].Default)) } func TestOverrideJobParametersStaging(t *testing.T) { b := loadTarget(t, "./override_job_parameters", "staging") - assert.Equal(t, "job", b.Config.Resources.Jobs["foo"].Name) + assert.Equal(t, "job", utils.Deref(b.Config.Resources.Jobs["foo"].Name)) p := b.Config.Resources.Jobs["foo"].Parameters assert.Len(t, p, 2) - assert.Equal(t, "foo", p[0].Name) - assert.Equal(t, "v1", p[0].Default) - assert.Equal(t, "bar", p[1].Name) - assert.Equal(t, "v2", p[1].Default) + assert.Equal(t, "foo", utils.Deref(p[0].Name)) + assert.Equal(t, "v1", utils.Deref(p[0].Default)) + assert.Equal(t, "bar", utils.Deref(p[1].Name)) + assert.Equal(t, "v2", utils.Deref(p[1].Default)) } diff --git a/bundle/tests/registered_model_test.go b/bundle/tests/registered_model_test.go index ce11656efcc..c31a4684c25 100644 --- a/bundle/tests/registered_model_test.go +++ b/bundle/tests/registered_model_test.go @@ -3,18 +3,19 @@ package config_tests import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/stretchr/testify/assert" ) func assertExpectedModel(t *testing.T, p *resources.RegisteredModel) { - assert.Equal(t, "main", p.CatalogName) - assert.Equal(t, "default", p.SchemaName) - assert.Equal(t, "comment", p.Comment) - assert.Equal(t, "account users", p.Grants[0].Principal) - assert.Equal(t, catalog.Privilege("EXECUTE"), p.Grants[0].Privileges[0]) + assert.Equal(t, "main", utils.Deref(p.CatalogName)) + assert.Equal(t, "default", utils.Deref(p.SchemaName)) + assert.Equal(t, "comment", utils.Deref(p.Comment)) + assert.Equal(t, "account users", utils.Deref(p.Grants[0].Principal)) + assert.Equal(t, "EXECUTE", p.Grants[0].Privileges[0]) } func TestRegisteredModelDevelopment(t *testing.T) { @@ -23,7 +24,7 @@ func TestRegisteredModelDevelopment(t *testing.T) { assert.Equal(t, config.Development, b.Config.Bundle.Mode) p := b.Config.Resources.RegisteredModels["my_registered_model"] - assert.Equal(t, "my-dev-model", p.Name) + assert.Equal(t, "my-dev-model", utils.Deref(p.Name)) assertExpectedModel(t, p) } @@ -32,7 +33,7 @@ func TestRegisteredModelStaging(t *testing.T) { assert.Len(t, b.Config.Resources.RegisteredModels, 1) p := b.Config.Resources.RegisteredModels["my_registered_model"] - assert.Equal(t, "my-staging-model", p.Name) + assert.Equal(t, "my-staging-model", utils.Deref(p.Name)) assertExpectedModel(t, p) } @@ -41,6 +42,6 @@ func TestRegisteredModelProduction(t *testing.T) { assert.Len(t, b.Config.Resources.RegisteredModels, 1) p := b.Config.Resources.RegisteredModels["my_registered_model"] - assert.Equal(t, "my-prod-model", p.Name) + assert.Equal(t, "my-prod-model", utils.Deref(p.Name)) assertExpectedModel(t, p) } diff --git a/bundle/tests/relative_path_with_includes_test.go b/bundle/tests/relative_path_with_includes_test.go index 50bb8a776b7..1c6a2f1b2f8 100644 --- a/bundle/tests/relative_path_with_includes_test.go +++ b/bundle/tests/relative_path_with_includes_test.go @@ -4,6 +4,8 @@ import ( "path" "testing" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config/mutator" "github.com/stretchr/testify/assert" @@ -38,6 +40,6 @@ func TestRelativePathsWithIncludes(t *testing.T) { b.Config.Sync.Exclude, ) - assert.Equal(t, "dist/job_a.whl", b.Config.Resources.Jobs["job_a"].Tasks[0].Libraries[0].Whl) - assert.Equal(t, "subfolder/dist/job_b.whl", b.Config.Resources.Jobs["job_b"].Tasks[0].Libraries[0].Whl) + assert.Equal(t, "dist/job_a.whl", utils.Deref(b.Config.Resources.Jobs["job_a"].Tasks[0].Libraries[0].Whl)) + assert.Equal(t, "subfolder/dist/job_b.whl", utils.Deref(b.Config.Resources.Jobs["job_b"].Tasks[0].Libraries[0].Whl)) } diff --git a/bundle/tests/target_overrides_test.go b/bundle/tests/target_overrides_test.go index 2516ce2a316..fca3458bbc7 100644 --- a/bundle/tests/target_overrides_test.go +++ b/bundle/tests/target_overrides_test.go @@ -3,6 +3,8 @@ package config_tests import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/stretchr/testify/assert" ) @@ -18,10 +20,10 @@ func TestTargetOverridesWorkspaceStaging(t *testing.T) { func TestTargetOverridesResourcesDev(t *testing.T) { b := loadTarget(t, "./target_overrides/resources", "development") - assert.Equal(t, "base job", b.Config.Resources.Jobs["job1"].Name) + assert.Equal(t, "base job", utils.Deref(b.Config.Resources.Jobs["job1"].Name)) } func TestTargetOverridesResourcesStaging(t *testing.T) { b := loadTarget(t, "./target_overrides/resources", "staging") - assert.Equal(t, "staging job", b.Config.Resources.Jobs["job1"].Name) + assert.Equal(t, "staging job", utils.Deref(b.Config.Resources.Jobs["job1"].Name)) } diff --git a/bundle/tests/yaml_anchors_test.go b/bundle/tests/yaml_anchors_test.go index 29681c0840a..ed5898c0fe3 100644 --- a/bundle/tests/yaml_anchors_test.go +++ b/bundle/tests/yaml_anchors_test.go @@ -3,6 +3,8 @@ package config_tests import ( "testing" + "github.com/databricks/cli/libs/utils" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -21,8 +23,8 @@ func TestYAMLAnchors(t *testing.T) { require.NotNil(t, t0.NewCluster) require.NotNil(t, t1.NewCluster) - assert.Equal(t, "10.4.x-scala2.12", t0.NewCluster.SparkVersion) - assert.Equal(t, "10.4.x-scala2.12", t1.NewCluster.SparkVersion) + assert.Equal(t, "10.4.x-scala2.12", utils.Deref(t0.NewCluster.SparkVersion)) + assert.Equal(t, "10.4.x-scala2.12", utils.Deref(t1.NewCluster.SparkVersion)) } func TestYAMLAnchorsNoWarnings(t *testing.T) { diff --git a/bundle/trampoline/conditional_transform_test.go b/bundle/trampoline/conditional_transform_test.go index 928ed578d17..c36a071cccb 100644 --- a/bundle/trampoline/conditional_transform_test.go +++ b/bundle/trampoline/conditional_transform_test.go @@ -4,11 +4,12 @@ import ( "path/filepath" "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/require" ) @@ -29,15 +30,15 @@ func TestNoTransformByDefault(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "key1", + TaskKey: new("key1"), PythonWheelTask: &jobs.PythonWheelTask{ - PackageName: "test_package", - EntryPoint: "main", + PackageName: new("test_package"), + EntryPoint: new("main"), }, - Libraries: []compute.Library{ - {Whl: "/Workspace/Users/test@test.com/bundle/dist/test.whl"}, + Libraries: []jobs.Library{ + {Whl: new("/Workspace/Users/test@test.com/bundle/dist/test.whl")}, }, }, }, @@ -54,9 +55,9 @@ func TestNoTransformByDefault(t *testing.T) { task := b.Config.Resources.Jobs["job1"].Tasks[0] require.NotNil(t, task.PythonWheelTask) - require.Equal(t, "test_package", task.PythonWheelTask.PackageName) - require.Equal(t, "main", task.PythonWheelTask.EntryPoint) - require.Equal(t, "/Workspace/Users/test@test.com/bundle/dist/test.whl", task.Libraries[0].Whl) + require.Equal(t, "test_package", utils.Deref(task.PythonWheelTask.PackageName)) + require.Equal(t, "main", utils.Deref(task.PythonWheelTask.EntryPoint)) + require.Equal(t, "/Workspace/Users/test@test.com/bundle/dist/test.whl", utils.Deref(task.Libraries[0].Whl)) require.Nil(t, task.NotebookTask) } @@ -78,16 +79,16 @@ func TestTransformWithExperimentalSettingSetToTrue(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "key1", + TaskKey: new("key1"), PythonWheelTask: &jobs.PythonWheelTask{ - PackageName: "test_package", - EntryPoint: "main", + PackageName: new("test_package"), + EntryPoint: new("main"), }, - Libraries: []compute.Library{ - {Whl: "/Workspace/Users/test@test.com/bundle/dist/test.whl"}, - {Jar: "/Workspace/Users/test@test.com/bundle/dist/test.jar"}, + Libraries: []jobs.Library{ + {Whl: new("/Workspace/Users/test@test.com/bundle/dist/test.whl")}, + {Jar: new("/Workspace/Users/test@test.com/bundle/dist/test.jar")}, }, }, }, @@ -108,8 +109,8 @@ func TestTransformWithExperimentalSettingSetToTrue(t *testing.T) { task := b.Config.Resources.Jobs["job1"].Tasks[0] require.Nil(t, task.PythonWheelTask) require.NotNil(t, task.NotebookTask) - require.Equal(t, "/Workspace/files/my_bundle/.databricks/bundle/development/.internal/notebook_4_job1_key1", task.NotebookTask.NotebookPath) + require.Equal(t, "/Workspace/files/my_bundle/.databricks/bundle/development/.internal/notebook_4_job1_key1", utils.Deref(task.NotebookTask.NotebookPath)) require.Len(t, task.Libraries, 1) - require.Equal(t, "/Workspace/Users/test@test.com/bundle/dist/test.jar", task.Libraries[0].Jar) + require.Equal(t, "/Workspace/Users/test@test.com/bundle/dist/test.jar", utils.Deref(task.Libraries[0].Jar)) } diff --git a/bundle/trampoline/python_dbr_warning.go b/bundle/trampoline/python_dbr_warning.go index 4cc7a67dc8c..69fc3141383 100644 --- a/bundle/trampoline/python_dbr_warning.go +++ b/bundle/trampoline/python_dbr_warning.go @@ -12,7 +12,9 @@ import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn/dynvar" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + sdkclusters "github.com/databricks/sdk-go/clusters/v2" "golang.org/x/mod/semver" ) @@ -49,24 +51,29 @@ func hasIncompatibleWheelTasks(ctx context.Context, b *bundle.Bundle) diag.Diagn tasks := libraries.FindTasksWithLocalLibraries(b) for _, task := range tasks { + taskKey := utils.Deref(task.TaskKey) if task.NewCluster != nil { - if lowerThanExpectedVersion(task.NewCluster.SparkVersion) { + if sparkVersion := utils.Deref(task.NewCluster.SparkVersion); lowerThanExpectedVersion(sparkVersion) { diags = append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: fmt.Sprintf("task %s uses cluster with incompatible DBR version %s", task.TaskKey, task.NewCluster.SparkVersion), + Summary: fmt.Sprintf("task %s uses cluster with incompatible DBR version %s", taskKey, sparkVersion), }) continue } } - if task.JobClusterKey != "" { + if jobClusterKey := utils.Deref(task.JobClusterKey); jobClusterKey != "" { for _, job := range b.Config.Resources.Jobs { for _, cluster := range job.JobClusters { - if task.JobClusterKey == cluster.JobClusterKey && cluster.NewCluster.SparkVersion != "" { - if lowerThanExpectedVersion(cluster.NewCluster.SparkVersion) { + if cluster.NewCluster == nil { + continue + } + sparkVersion := utils.Deref(cluster.NewCluster.SparkVersion) + if jobClusterKey == utils.Deref(cluster.JobClusterKey) && sparkVersion != "" { + if lowerThanExpectedVersion(sparkVersion) { diags = append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: fmt.Sprintf("job cluster %s uses incompatible DBR version %s", cluster.JobClusterKey, cluster.NewCluster.SparkVersion), + Summary: fmt.Sprintf("job cluster %s uses incompatible DBR version %s", jobClusterKey, sparkVersion), }) continue } @@ -75,21 +82,21 @@ func hasIncompatibleWheelTasks(ctx context.Context, b *bundle.Bundle) diag.Diagn } } - if task.ExistingClusterId != "" { + if existingClusterId := utils.Deref(task.ExistingClusterId); existingClusterId != "" { var version string var err error // If the cluster id is a variable and it's not resolved, it means it references a cluster defined in the same bundle. // So we can get the version from the cluster definition. // It's defined in a form of resources.clusters..id - if strings.HasPrefix(task.ExistingClusterId, "${") { - p, ok := dynvar.PureReferenceToPath(task.ExistingClusterId) + if strings.HasPrefix(existingClusterId, "${") { + p, ok := dynvar.PureReferenceToPath(existingClusterId) if !ok || len(p) < 3 { - log.Warnf(ctx, "unable to parse cluster key from %s", task.ExistingClusterId) + log.Warnf(ctx, "unable to parse cluster key from %s", existingClusterId) continue } if p[0].Key() != "resources" || p[1].Key() != "clusters" { - log.Warnf(ctx, "incorrect variable reference for cluster id %s", task.ExistingClusterId) + log.Warnf(ctx, "incorrect variable reference for cluster id %s", existingClusterId) continue } @@ -99,12 +106,12 @@ func hasIncompatibleWheelTasks(ctx context.Context, b *bundle.Bundle) diag.Diagn log.Warnf(ctx, "unable to find cluster with key %s", clusterKey) continue } - version = cluster.SparkVersion + version = utils.Deref(cluster.SparkVersion) } else { - version, err = getSparkVersionForCluster(ctx, b.WorkspaceClient(ctx), task.ExistingClusterId) + version, err = getSparkVersionForCluster(ctx, b.WorkspaceClient(ctx), existingClusterId) // If there's error getting spark version for cluster, do not mark it as incompatible if err != nil { - log.Warnf(ctx, "unable to get spark version for cluster %s, err: %s", task.ExistingClusterId, err.Error()) + log.Warnf(ctx, "unable to get spark version for cluster %s, err: %s", existingClusterId, err.Error()) continue } } @@ -112,7 +119,7 @@ func hasIncompatibleWheelTasks(ctx context.Context, b *bundle.Bundle) diag.Diagn if lowerThanExpectedVersion(version) { diags = append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: fmt.Sprintf("task %s uses cluster with incompatible DBR version %s", task.TaskKey, version), + Summary: fmt.Sprintf("task %s uses cluster with incompatible DBR version %s", taskKey, version), }) continue } @@ -151,11 +158,11 @@ func (m *wrapperWarning) Name() string { return "PythonWrapperWarning" } -func getSparkVersionForCluster(ctx context.Context, w *databricks.WorkspaceClient, clusterId string) (string, error) { - details, err := w.Clusters.GetByClusterId(ctx, clusterId) +func getSparkVersionForCluster(ctx context.Context, w *sdkclients.Clients, clusterId string) (string, error) { + details, err := w.Clusters.GetCluster(ctx, sdkclusters.GetClusterRequest{ClusterId: new(clusterId)}) if err != nil { return "", err } - return details.SparkVersion, nil + return utils.Deref(details.SparkVersion), nil } diff --git a/bundle/trampoline/python_dbr_warning_test.go b/bundle/trampoline/python_dbr_warning_test.go index 3f5c35bf7c6..1f6a8a3579f 100644 --- a/bundle/trampoline/python_dbr_warning_test.go +++ b/bundle/trampoline/python_dbr_warning_test.go @@ -3,13 +3,13 @@ package trampoline import ( "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/stretchr/testify/mock" + "github.com/databricks/cli/bundle/internal/bundletest" + "github.com/databricks/cli/libs/testserver" "github.com/stretchr/testify/require" ) @@ -20,25 +20,25 @@ func TestIncompatibleWheelTasksWithNewCluster(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "key1", + TaskKey: new("key1"), PythonWheelTask: &jobs.PythonWheelTask{}, - NewCluster: &compute.ClusterSpec{ - SparkVersion: "12.2.x-scala2.12", + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("12.2.x-scala2.12"), }, - Libraries: []compute.Library{ - {Whl: "./dist/test.whl"}, + Libraries: []jobs.Library{ + {Whl: new("./dist/test.whl")}, }, }, { - TaskKey: "key2", + TaskKey: new("key2"), PythonWheelTask: &jobs.PythonWheelTask{}, - NewCluster: &compute.ClusterSpec{ - SparkVersion: "13.1.x-scala2.12", + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("13.1.x-scala2.12"), }, - Libraries: []compute.Library{ - {Whl: "./dist/test.whl"}, + Libraries: []jobs.Library{ + {Whl: new("./dist/test.whl")}, }, }, }, @@ -62,33 +62,33 @@ func TestIncompatibleWheelTasksWithJobClusterKey(t *testing.T) { JobSettings: jobs.JobSettings{ JobClusters: []jobs.JobCluster{ { - JobClusterKey: "cluster1", - NewCluster: &compute.ClusterSpec{ - SparkVersion: "12.2.x-scala2.12", + JobClusterKey: new("cluster1"), + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("12.2.x-scala2.12"), }, }, { - JobClusterKey: "cluster2", - NewCluster: &compute.ClusterSpec{ - SparkVersion: "13.1.x-scala2.12", + JobClusterKey: new("cluster2"), + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("13.1.x-scala2.12"), }, }, }, - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "key1", + TaskKey: new("key1"), PythonWheelTask: &jobs.PythonWheelTask{}, - JobClusterKey: "cluster1", - Libraries: []compute.Library{ - {Whl: "./dist/test.whl"}, + JobClusterKey: new("cluster1"), + Libraries: []jobs.Library{ + {Whl: new("./dist/test.whl")}, }, }, { - TaskKey: "key2", + TaskKey: new("key2"), PythonWheelTask: &jobs.PythonWheelTask{}, - JobClusterKey: "cluster2", - Libraries: []compute.Library{ - {Whl: "./dist/test.whl"}, + JobClusterKey: new("cluster2"), + Libraries: []jobs.Library{ + {Whl: new("./dist/test.whl")}, }, }, }, @@ -113,21 +113,21 @@ func TestIncompatibleWheelTasksWithExistingClusterId(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "key1", + TaskKey: new("key1"), PythonWheelTask: &jobs.PythonWheelTask{}, - ExistingClusterId: "test-key-1", - Libraries: []compute.Library{ - {Whl: "./dist/test.whl"}, + ExistingClusterId: new("test-key-1"), + Libraries: []jobs.Library{ + {Whl: new("./dist/test.whl")}, }, }, { - TaskKey: "key2", + TaskKey: new("key2"), PythonWheelTask: &jobs.PythonWheelTask{}, - ExistingClusterId: "test-key-2", - Libraries: []compute.Library{ - {Whl: "./dist/test.whl"}, + ExistingClusterId: new("test-key-2"), + Libraries: []jobs.Library{ + {Whl: new("./dist/test.whl")}, }, }, }, @@ -138,15 +138,10 @@ func TestIncompatibleWheelTasksWithExistingClusterId(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) - clustersApi := m.GetMockClustersAPI() - clustersApi.EXPECT().GetByClusterId(mock.Anything, "test-key-1").Return(&compute.ClusterDetails{ - SparkVersion: "12.2.x-scala2.12", - }, nil) - clustersApi.EXPECT().GetByClusterId(mock.Anything, "test-key-2").Return(&compute.ClusterDetails{ - SparkVersion: "12.2.x-scala2.12", - }, nil) + setClusters(t, b, map[string]string{ + "test-key-1": "12.2.x-scala2.12", + "test-key-2": "12.2.x-scala2.12", + }) diags := hasIncompatibleWheelTasks(t.Context(), b) require.NotEmpty(t, diags) @@ -162,81 +157,81 @@ func TestNoIncompatibleWheelTasks(t *testing.T) { JobSettings: jobs.JobSettings{ JobClusters: []jobs.JobCluster{ { - JobClusterKey: "cluster1", - NewCluster: &compute.ClusterSpec{ - SparkVersion: "12.2.x-scala2.12", + JobClusterKey: new("cluster1"), + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("12.2.x-scala2.12"), }, }, { - JobClusterKey: "cluster2", - NewCluster: &compute.ClusterSpec{ - SparkVersion: "13.1.x-scala2.12", + JobClusterKey: new("cluster2"), + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("13.1.x-scala2.12"), }, }, }, - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "key1", + TaskKey: new("key1"), PythonWheelTask: &jobs.PythonWheelTask{}, - NewCluster: &compute.ClusterSpec{ - SparkVersion: "12.2.x-scala2.12", + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("12.2.x-scala2.12"), }, - Libraries: []compute.Library{ - {Whl: "/Workspace/Users/me@me.com/dist/test.whl"}, + Libraries: []jobs.Library{ + {Whl: new("/Workspace/Users/me@me.com/dist/test.whl")}, }, }, { - TaskKey: "key2", + TaskKey: new("key2"), PythonWheelTask: &jobs.PythonWheelTask{}, - NewCluster: &compute.ClusterSpec{ - SparkVersion: "13.3.x-scala2.12", + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("13.3.x-scala2.12"), }, - Libraries: []compute.Library{ - {Whl: "./dist/test.whl"}, + Libraries: []jobs.Library{ + {Whl: new("./dist/test.whl")}, }, }, { - TaskKey: "key3", + TaskKey: new("key3"), PythonWheelTask: &jobs.PythonWheelTask{}, - NewCluster: &compute.ClusterSpec{ - SparkVersion: "12.2.x-scala2.12", + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("12.2.x-scala2.12"), }, - Libraries: []compute.Library{ - {Whl: "dbfs:/dist/test.whl"}, + Libraries: []jobs.Library{ + {Whl: new("dbfs:/dist/test.whl")}, }, }, { - TaskKey: "key4", + TaskKey: new("key4"), PythonWheelTask: &jobs.PythonWheelTask{}, - JobClusterKey: "cluster1", - Libraries: []compute.Library{ - {Whl: "/Workspace/Users/me@me.com/dist/test.whl"}, + JobClusterKey: new("cluster1"), + Libraries: []jobs.Library{ + {Whl: new("/Workspace/Users/me@me.com/dist/test.whl")}, }, }, { - TaskKey: "key5", + TaskKey: new("key5"), PythonWheelTask: &jobs.PythonWheelTask{}, - JobClusterKey: "cluster2", - Libraries: []compute.Library{ - {Whl: "./dist/test.whl"}, + JobClusterKey: new("cluster2"), + Libraries: []jobs.Library{ + {Whl: new("./dist/test.whl")}, }, }, { - TaskKey: "key6", + TaskKey: new("key6"), PythonWheelTask: &jobs.PythonWheelTask{}, - ExistingClusterId: "test-key-2", - Libraries: []compute.Library{ - {Whl: "./dist/test.whl"}, + ExistingClusterId: new("test-key-2"), + Libraries: []jobs.Library{ + {Whl: new("./dist/test.whl")}, }, }, { - TaskKey: "key7", + TaskKey: new("key7"), PythonWheelTask: &jobs.PythonWheelTask{}, - ExistingClusterId: "test-key-2", - Libraries: []compute.Library{ - {Whl: "signol_lib-0.4.4-20240822+prod-py3-none-any.whl"}, - {Pypi: &compute.PythonPyPiLibrary{ - Package: "requests==2.25.1", + ExistingClusterId: new("test-key-2"), + Libraries: []jobs.Library{ + {Whl: new("signol_lib-0.4.4-20240822+prod-py3-none-any.whl")}, + {Pypi: &jobs.PythonPyPiLibrary{ + Package: new("requests==2.25.1"), }}, }, }, @@ -248,12 +243,9 @@ func TestNoIncompatibleWheelTasks(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) - clustersApi := m.GetMockClustersAPI() - clustersApi.EXPECT().GetByClusterId(mock.Anything, "test-key-2").Return(&compute.ClusterDetails{ - SparkVersion: "13.2.x-scala2.12", - }, nil) + setClusters(t, b, map[string]string{ + "test-key-2": "13.2.x-scala2.12", + }) diags := hasIncompatibleWheelTasks(t.Context(), b) require.Empty(t, diags) @@ -268,20 +260,20 @@ func TestTasksWithPyPiPackageAreCompatible(t *testing.T) { JobSettings: jobs.JobSettings{ JobClusters: []jobs.JobCluster{ { - JobClusterKey: "cluster1", - NewCluster: &compute.ClusterSpec{ - SparkVersion: "12.2.x-scala2.12", + JobClusterKey: new("cluster1"), + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("12.2.x-scala2.12"), }, }, }, - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "key1", + TaskKey: new("key1"), PythonWheelTask: &jobs.PythonWheelTask{}, - ExistingClusterId: "test-key-2", - Libraries: []compute.Library{ - {Pypi: &compute.PythonPyPiLibrary{ - Package: "requests==2.25.1", + ExistingClusterId: new("test-key-2"), + Libraries: []jobs.Library{ + {Pypi: &jobs.PythonPyPiLibrary{ + Package: new("requests==2.25.1"), }}, }, }, @@ -293,8 +285,7 @@ func TestTasksWithPyPiPackageAreCompatible(t *testing.T) { }, } - m := mocks.NewMockWorkspaceClient(t) - b.SetWorkpaceClient(m.WorkspaceClient) + setClusters(t, b, nil) diags := hasIncompatibleWheelTasks(t.Context(), b) require.Empty(t, diags) @@ -310,25 +301,25 @@ func TestNoWarningWhenPythonWheelWrapperIsOn(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "key1", + TaskKey: new("key1"), PythonWheelTask: &jobs.PythonWheelTask{}, - NewCluster: &compute.ClusterSpec{ - SparkVersion: "12.2.x-scala2.12", + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("12.2.x-scala2.12"), }, - Libraries: []compute.Library{ - {Whl: "./dist/test.whl"}, + Libraries: []jobs.Library{ + {Whl: new("./dist/test.whl")}, }, }, { - TaskKey: "key2", + TaskKey: new("key2"), PythonWheelTask: &jobs.PythonWheelTask{}, - NewCluster: &compute.ClusterSpec{ - SparkVersion: "13.1.x-scala2.12", + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("13.1.x-scala2.12"), }, - Libraries: []compute.Library{ - {Whl: "./dist/test.whl"}, + Libraries: []jobs.Library{ + {Whl: new("./dist/test.whl")}, }, }, }, @@ -366,3 +357,17 @@ func TestSparkVersionLowerThanExpected(t *testing.T) { require.Equal(t, v, result, k) } } + +// setClusters serves clusters/get for the given clusters (id -> spark version). +func setClusters(t *testing.T, b *bundle.Bundle, sparkVersions map[string]string) { + w, server := bundletest.NewClients(t) + b.SetWorkpaceClient(w) + server.Handle("GET", "/api/2.1/clusters/get", func(req testserver.Request) any { + id := req.URL.Query().Get("cluster_id") + version, ok := sparkVersions[id] + if !ok { + t.Errorf("unexpected cluster id %q", id) + } + return map[string]string{"cluster_id": id, "spark_version": version} + }) +} diff --git a/bundle/trampoline/python_wheel.go b/bundle/trampoline/python_wheel.go index 722a0b35e6c..3cf41b0df0f 100644 --- a/bundle/trampoline/python_wheel.go +++ b/bundle/trampoline/python_wheel.go @@ -11,8 +11,8 @@ import ( "github.com/databricks/cli/bundle/libraries" "github.com/databricks/cli/bundle/metrics" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" ) const NOTEBOOK_TEMPLATE = `# Databricks notebook source @@ -93,12 +93,12 @@ func (transformWheelTask) Apply(ctx context.Context, b *bundle.Bundle) diag.Diag type pythonTrampoline struct{} -func (t *pythonTrampoline) CleanUp(task *jobs.Task) error { +func (t *pythonTrampoline) CleanUp(task *jobs.TaskSettings) error { task.PythonWheelTask = nil - var nonWheelLibraries []compute.Library + var nonWheelLibraries []jobs.Library for _, l := range task.Libraries { - if l.Whl == "" { + if utils.Deref(l.Whl) == "" { nonWheelLibraries = append(nonWheelLibraries, l) } } @@ -132,15 +132,15 @@ func (t *pythonTrampoline) GetTasks(b *bundle.Bundle) []TaskWithJobKey { return result } -func needsTrampoline(task jobs.Task) bool { +func needsTrampoline(task jobs.TaskSettings) bool { return libraries.IsTaskWithWorkspaceLibraries(task) } -func (t *pythonTrampoline) GetTemplateData(task *jobs.Task) (map[string]any, error) { +func (t *pythonTrampoline) GetTemplateData(task *jobs.TaskSettings) (map[string]any, error) { params, err := t.generateParameters(task.PythonWheelTask) - var whlLibraries []compute.Library + var whlLibraries []jobs.Library for _, l := range task.Libraries { - if l.Whl != "" { + if utils.Deref(l.Whl) != "" { whlLibraries = append(whlLibraries, l) } } @@ -162,7 +162,7 @@ func (t *pythonTrampoline) generateParameters(task *jobs.PythonWheelTask) (strin if task.Parameters != nil && task.NamedParameters != nil { return "", errors.New("not allowed to pass both parameters and named_parameters") } - params := append([]string{task.PackageName}, task.Parameters...) + params := append([]string{utils.Deref(task.PackageName)}, task.Parameters...) for k, v := range task.NamedParameters { params = append(params, fmt.Sprintf("%s=%s", k, v)) } diff --git a/bundle/trampoline/python_wheel_test.go b/bundle/trampoline/python_wheel_test.go index 1ae42a063e0..1dfcf7d39c3 100644 --- a/bundle/trampoline/python_wheel_test.go +++ b/bundle/trampoline/python_wheel_test.go @@ -4,11 +4,12 @@ import ( "strings" "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/require" ) @@ -42,7 +43,7 @@ var paramsTestCasesNamed []testCaseNamed = []testCaseNamed{ func TestGenerateParameters(t *testing.T) { trampoline := pythonTrampoline{} for _, c := range paramsTestCases { - task := &jobs.PythonWheelTask{PackageName: "my_test_code", Parameters: c.Actual} + task := &jobs.PythonWheelTask{PackageName: new("my_test_code"), Parameters: c.Actual} result, err := trampoline.generateParameters(task) require.NoError(t, err) require.Equal(t, c.Expected, result) @@ -52,7 +53,7 @@ func TestGenerateParameters(t *testing.T) { func TestGenerateNamedParameters(t *testing.T) { trampoline := pythonTrampoline{} for _, c := range paramsTestCasesNamed { - task := &jobs.PythonWheelTask{PackageName: "my_test_code", NamedParameters: c.Actual} + task := &jobs.PythonWheelTask{PackageName: new("my_test_code"), NamedParameters: c.Actual} result, err := trampoline.generateParameters(task) require.NoError(t, err) @@ -77,23 +78,23 @@ func TestTransformFiltersWheelTasksOnly(t *testing.T) { Jobs: map[string]*resources.Job{ "job1": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "key1", + TaskKey: new("key1"), PythonWheelTask: &jobs.PythonWheelTask{}, - Libraries: []compute.Library{ - {Whl: "/Workspace/Users/test@test.com/bundle/dist/test.whl"}, + Libraries: []jobs.Library{ + {Whl: new("/Workspace/Users/test@test.com/bundle/dist/test.whl")}, }, }, { - TaskKey: "key2", + TaskKey: new("key2"), NotebookTask: &jobs.NotebookTask{}, }, { - TaskKey: "key3", + TaskKey: new("key3"), PythonWheelTask: &jobs.PythonWheelTask{}, - Libraries: []compute.Library{ - {Whl: "dbfs:/FileStore/dist/test.whl"}, + Libraries: []jobs.Library{ + {Whl: new("dbfs:/FileStore/dist/test.whl")}, }, }, }, @@ -107,7 +108,7 @@ func TestTransformFiltersWheelTasksOnly(t *testing.T) { tasks := trampoline.GetTasks(b) require.Len(t, tasks, 1) require.Equal(t, "job1", tasks[0].JobKey) - require.Equal(t, "key1", tasks[0].Task.TaskKey) + require.Equal(t, "key1", utils.Deref(tasks[0].Task.TaskKey)) require.NotNil(t, tasks[0].Task.PythonWheelTask) } @@ -123,9 +124,9 @@ func TestNoPanicWithNoPythonWheelTasks(t *testing.T) { Jobs: map[string]*resources.Job{ "test": { JobSettings: jobs.JobSettings{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: "notebook_task", + TaskKey: new("notebook_task"), NotebookTask: &jobs.NotebookTask{}, }, }, diff --git a/bundle/trampoline/trampoline.go b/bundle/trampoline/trampoline.go index b3683688fee..ca571284ed2 100644 --- a/bundle/trampoline/trampoline.go +++ b/bundle/trampoline/trampoline.go @@ -10,18 +10,19 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" ) type TaskWithJobKey struct { - Task *jobs.Task + Task *jobs.TaskSettings JobKey string } type TrampolineFunctions interface { - GetTemplateData(task *jobs.Task) (map[string]any, error) + GetTemplateData(task *jobs.TaskSettings) (map[string]any, error) GetTasks(b *bundle.Bundle) []TaskWithJobKey - CleanUp(task *jobs.Task) error + CleanUp(task *jobs.TaskSettings) error } type trampoline struct { @@ -61,7 +62,7 @@ func (m *trampoline) generateNotebookWrapper(ctx context.Context, b *bundle.Bund // Keys may contain underscores, so joining with "_" alone is ambiguous ("a_b"+"c" // vs "a"+"b_c"); the job key length prefix keeps the filename unique per task. - notebookName := fmt.Sprintf("notebook_%d_%s_%s", len(task.JobKey), task.JobKey, task.Task.TaskKey) + notebookName := fmt.Sprintf("notebook_%d_%s_%s", len(task.JobKey), task.JobKey, utils.Deref(task.Task.TaskKey)) localNotebookPath := filepath.Join(internalDir, notebookName+".py") err = os.MkdirAll(filepath.Dir(localNotebookPath), 0o755) @@ -97,7 +98,7 @@ func (m *trampoline) generateNotebookWrapper(ctx context.Context, b *bundle.Bund remotePath := path.Join(b.Config.Workspace.FilePath, filepath.ToSlash(internalDirRel), notebookName) task.Task.NotebookTask = &jobs.NotebookTask{ - NotebookPath: remotePath, + NotebookPath: new(remotePath), } return t.Execute(f, data) diff --git a/bundle/trampoline/trampoline_test.go b/bundle/trampoline/trampoline_test.go index d4e46795619..b97d38af459 100644 --- a/bundle/trampoline/trampoline_test.go +++ b/bundle/trampoline/trampoline_test.go @@ -6,10 +6,12 @@ import ( "path/filepath" "testing" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/require" ) @@ -29,7 +31,7 @@ func (f *functions) GetTasks(b *bundle.Bundle) []TaskWithJobKey { return tasks } -func (f *functions) GetTemplateData(task *jobs.Task) (map[string]any, error) { +func (f *functions) GetTemplateData(task *jobs.TaskSettings) (map[string]any, error) { if task.PythonWheelTask == nil { return nil, errors.New("PythonWheelTask cannot be nil") } @@ -39,7 +41,7 @@ func (f *functions) GetTemplateData(task *jobs.Task) (map[string]any, error) { return data, nil } -func (f *functions) CleanUp(task *jobs.Task) error { +func (f *functions) CleanUp(task *jobs.TaskSettings) error { task.PythonWheelTask = nil return nil } @@ -47,12 +49,12 @@ func (f *functions) CleanUp(task *jobs.Task) error { func TestGenerateTrampoline(t *testing.T) { tmpDir := t.TempDir() - tasks := []jobs.Task{ + tasks := []jobs.TaskSettings{ { - TaskKey: "to_trampoline", + TaskKey: new("to_trampoline"), PythonWheelTask: &jobs.PythonWheelTask{ - PackageName: "test", - EntryPoint: "run", + PackageName: new("test"), + EntryPoint: new("run"), }, }, } @@ -95,7 +97,7 @@ func TestGenerateTrampoline(t *testing.T) { require.Equal(t, "Hello from Trampoline", string(bytes)) task := b.Config.Resources.Jobs["test"].Tasks[0] - require.Equal(t, "/Workspace/files/my_bundle/.databricks/bundle/development/.internal/notebook_4_test_to_trampoline", task.NotebookTask.NotebookPath) + require.Equal(t, "/Workspace/files/my_bundle/.databricks/bundle/development/.internal/notebook_4_test_to_trampoline", utils.Deref(task.NotebookTask.NotebookPath)) require.Nil(t, task.PythonWheelTask) } @@ -104,12 +106,12 @@ func TestGenerateTrampolineWithCollidingKeys(t *testing.T) { newJob := func(taskKey string) *resources.Job { return &resources.Job{ - Tasks: []jobs.Task{ + Tasks: []jobs.TaskSettings{ { - TaskKey: taskKey, + TaskKey: new(taskKey), PythonWheelTask: &jobs.PythonWheelTask{ - PackageName: "test", - EntryPoint: "run", + PackageName: new("test"), + EntryPoint: new("run"), }, }, }, @@ -151,8 +153,8 @@ func TestGenerateTrampolineWithCollidingKeys(t *testing.T) { require.Equal(t, "/Workspace/files/my_bundle/.databricks/bundle/development/.internal/notebook_3_a_b_c", - b.Config.Resources.Jobs["a_b"].Tasks[0].NotebookTask.NotebookPath) + utils.Deref(b.Config.Resources.Jobs["a_b"].Tasks[0].NotebookTask.NotebookPath)) require.Equal(t, "/Workspace/files/my_bundle/.databricks/bundle/development/.internal/notebook_1_a_b_c", - b.Config.Resources.Jobs["a"].Tasks[0].NotebookTask.NotebookPath) + utils.Deref(b.Config.Resources.Jobs["a"].Tasks[0].NotebookTask.NotebookPath)) } diff --git a/cmd/account/access-control/access-control.go b/cmd/account/access-control/access-control.go index 3be9b6579cb..0717897b26d 100644 --- a/cmd/account/access-control/access-control.go +++ b/cmd/account/access-control/access-control.go @@ -9,8 +9,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" ) // Slice with functions to override default command behavior. @@ -53,13 +54,12 @@ These APIs manage access rules on resources in an account. Currently, only // Functions can be added from the `init()` function in manually curated files in this directory. var getAssignableRolesForResourceOverrides []func( *cobra.Command, - *iam.GetAssignableRolesForResourceRequest, + *accessmanagement.ListAssignableRolesForResourceRequest, ) func newGetAssignableRolesForResource() *cobra.Command { cmd := &cobra.Command{} - - var getAssignableRolesForResourceReq iam.GetAssignableRolesForResourceRequest + var getAssignableRolesForResourceReq accessmanagement.ListAssignableRolesForResourceRequest cmd.Use = "get-assignable-roles-for-resource RESOURCE" cmd.Short = `*Public Preview* Get assignable roles for a resource.` @@ -95,15 +95,24 @@ Get assignable roles for a resource. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getAssignableRolesForResourceReq.Resource = args[0] + getAssignableRolesForResourceReq.Resource = new(args[0]) - response, err := a.AccessControl.GetAssignableRolesForResource(ctx, getAssignableRolesForResourceReq) + sdkReq, err := accessmanagement.ListAssignableRolesForResourceRequestToSDK(&getAssignableRolesForResourceReq) + if err != nil { + return err + } + response, err := a.AccessManagement.ListAssignableRolesForResource(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListAssignableRolesForResourceResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -124,13 +133,12 @@ Get assignable roles for a resource. // Functions can be added from the `init()` function in manually curated files in this directory. var getRuleSetOverrides []func( *cobra.Command, - *iam.GetRuleSetRequest, + *accessmanagement.GetRuleSetRequest, ) func newGetRuleSet() *cobra.Command { cmd := &cobra.Command{} - - var getRuleSetReq iam.GetRuleSetRequest + var getRuleSetReq accessmanagement.GetRuleSetRequest cmd.Use = "get-rule-set NAME ETAG" cmd.Short = `*Public Preview* Get a rule set.` @@ -181,16 +189,25 @@ Get a rule set. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getRuleSetReq.Name = args[0] - getRuleSetReq.Etag = args[1] + getRuleSetReq.Name = new(args[0]) + getRuleSetReq.Etag = new(args[1]) - response, err := a.AccessControl.GetRuleSet(ctx, getRuleSetReq) + sdkReq, err := accessmanagement.GetRuleSetRequestToSDK(&getRuleSetReq) + if err != nil { + return err + } + response, err := a.AccessManagement.GetRuleSet(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.RuleSetFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -211,13 +228,13 @@ Get a rule set. // Functions can be added from the `init()` function in manually curated files in this directory. var updateRuleSetOverrides []func( *cobra.Command, - *iam.UpdateRuleSetRequest, + *accessmanagement.UpdateRuleSetRequest, ) func newUpdateRuleSet() *cobra.Command { cmd := &cobra.Command{} + var updateRuleSetReq accessmanagement.UpdateRuleSetRequest - var updateRuleSetReq iam.UpdateRuleSetRequest var updateRuleSetJson flags.JsonFlag cmd.Flags().Var(&updateRuleSetJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -240,6 +257,7 @@ Update a rule set. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateRuleSetJson.Unmarshal(&updateRuleSetReq) @@ -256,12 +274,20 @@ Update a rule set. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.AccessControl.UpdateRuleSet(ctx, updateRuleSetReq) + sdkReq, err := accessmanagement.UpdateRuleSetRequestToSDK(&updateRuleSetReq) + if err != nil { + return err + } + response, err := a.AccessManagement.UpdateRuleSet(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.RuleSetFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/billable-usage/billable-usage.go b/cmd/account/billable-usage/billable-usage.go index b7d0365fb63..47d655a0330 100644 --- a/cmd/account/billable-usage/billable-usage.go +++ b/cmd/account/billable-usage/billable-usage.go @@ -3,10 +3,14 @@ package billable_usage import ( + "fmt" + + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/billing" "github.com/spf13/cobra" ) @@ -45,15 +49,18 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var downloadOverrides []func( *cobra.Command, - *billing.DownloadRequest, + *map[string]any, ) func newDownload() *cobra.Command { cmd := &cobra.Command{} + var downloadReq map[string]any + downloadReq = map[string]any{} + var downloadEndMonthRaw string + var downloadPersonalDataRaw bool + var downloadStartMonthRaw string - var downloadReq billing.DownloadRequest - - cmd.Flags().BoolVar(&downloadReq.PersonalData, "personal-data", downloadReq.PersonalData, `Specify whether to include personally identifiable information in the billable usage logs, for example the email addresses of cluster creators.`) + cmd.Flags().BoolVar(&downloadPersonalDataRaw, "personal-data", downloadPersonalDataRaw, `Specify whether to include personally identifiable information in the billable usage logs, for example the email addresses of cluster creators.`) cmd.Use = "download START_MONTH END_MONTH" cmd.Short = `Return billable usage logs.` @@ -89,17 +96,34 @@ func newDownload() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - downloadReq.StartMonth = args[0] - downloadReq.EndMonth = args[1] + downloadStartMonthRaw = args[0] + downloadEndMonthRaw = args[1] - response, err := a.BillableUsage.Download(ctx, downloadReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("end-month") || downloadEndMonthRaw != "" { + rawQuery["end_month"] = downloadEndMonthRaw + } + if cmd.Flags().Changed("personal-data") || downloadPersonalDataRaw != false { + rawQuery["personal_data"] = downloadPersonalDataRaw + } + if cmd.Flags().Changed("start-month") || downloadStartMonthRaw != "" { + rawQuery["start_month"] = downloadStartMonthRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/usage/download", a.Config.AccountID) + + maps.Copy(rawQuery, downloadReq) + api, err := apiclient.New(a.Config) if err != nil { return err } - - defer response.Contents.Close() - return cmdio.Render(ctx, response.Contents) + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) + if err != nil { + return err + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. diff --git a/cmd/account/budget-policy/budget-policy.go b/cmd/account/budget-policy/budget-policy.go index 917f23548dc..e98e83345aa 100644 --- a/cmd/account/budget-policy/budget-policy.go +++ b/cmd/account/budget-policy/budget-policy.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/billing" "github.com/spf13/cobra" + + budgetpolicy "github.com/databricks/cli/libs/sdktypes/budgetpolicy/v1" + sdkbudgetpolicy "github.com/databricks/sdk-go/budgetpolicy/v1" ) // Slice with functions to override default command behavior. @@ -53,19 +56,19 @@ A service serves REST API about Budget policies`, // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *billing.CreateBudgetPolicyRequest, + *budgetpolicy.CreateBudgetPolicyRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq budgetpolicy.CreateBudgetPolicyRequest - var createReq billing.CreateBudgetPolicyRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: policy - cmd.Flags().StringVar(&createReq.RequestId, "request-id", createReq.RequestId, `A unique identifier for this request.`) + flags.StringPtrVar(cmd.Flags(), &createReq.RequestId, "request-id", `A unique identifier for this request.`) cmd.Use = "create" cmd.Short = `*Public Preview* Create a budget policy.` @@ -88,6 +91,7 @@ Create a budget policy. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -102,12 +106,20 @@ Create a budget policy. } } - response, err := a.BudgetPolicy.Create(ctx, createReq) + sdkReq, err := budgetpolicy.CreateBudgetPolicyRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.BudgetPolicy.CreateBudgetPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := budgetpolicy.BudgetPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -128,13 +140,12 @@ Create a budget policy. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *billing.DeleteBudgetPolicyRequest, + *sdkbudgetpolicy.DeleteBudgetPolicyRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq billing.DeleteBudgetPolicyRequest + var deleteReq sdkbudgetpolicy.DeleteBudgetPolicyRequest cmd.Use = "delete POLICY_ID" cmd.Short = `*Public Preview* Delete a budget policy.` @@ -160,10 +171,12 @@ Delete a budget policy. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.PolicyId = args[0] + deleteReq.PolicyId = new(args[0]) - err = a.BudgetPolicy.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = a.BudgetPolicy.DeleteBudgetPolicy(ctx, *sdkReq) if err != nil { return err } @@ -188,13 +201,12 @@ Delete a budget policy. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *billing.GetBudgetPolicyRequest, + *sdkbudgetpolicy.GetBudgetPolicyRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq billing.GetBudgetPolicyRequest + var getReq sdkbudgetpolicy.GetBudgetPolicyRequest cmd.Use = "get POLICY_ID" cmd.Short = `*Public Preview* Get a budget policy.` @@ -220,15 +232,21 @@ Get a budget policy. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.PolicyId = args[0] + getReq.PolicyId = new(args[0]) - response, err := a.BudgetPolicy.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.BudgetPolicy.GetBudgetPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := budgetpolicy.BudgetPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -249,27 +267,27 @@ Get a budget policy. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *billing.ListBudgetPoliciesRequest, + *budgetpolicy.ListBudgetPoliciesRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq budgetpolicy.ListBudgetPoliciesRequest - var listReq billing.ListBudgetPoliciesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int // TODO: complex arg: filter_by - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `The maximum number of budget policies to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", `The maximum number of budget policies to return.`) // TODO: complex arg: sort_spec // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -294,16 +312,20 @@ List policies. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.BudgetPolicy.List(ctx, listReq) + sdkReq, err := budgetpolicy.ListBudgetPoliciesRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.BudgetPolicy.ListBudgetPoliciesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, budgetpolicy.BudgetPolicyFromSDK)) } // Disable completions since they are not applicable. @@ -324,14 +346,14 @@ List policies. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *billing.UpdateBudgetPolicyRequest, + *budgetpolicy.UpdateBudgetPolicyRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq budgetpolicy.UpdateBudgetPolicyRequest + updateReq.Policy = &budgetpolicy.BudgetPolicy{} - var updateReq billing.UpdateBudgetPolicyRequest - updateReq.Policy = billing.BudgetPolicy{} var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -339,7 +361,7 @@ func newUpdate() *cobra.Command { // TODO: complex arg: limit_config // TODO: array: binding_workspace_ids // TODO: array: custom_tags - cmd.Flags().StringVar(&updateReq.Policy.PolicyName, "policy-name", updateReq.Policy.PolicyName, `The name of the policy.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Policy.PolicyName, "policy-name", `The name of the policy.`) cmd.Use = "update POLICY_ID" cmd.Short = `*Public Preview* Update a budget policy.` @@ -366,6 +388,7 @@ Update a budget policy. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.Policy) @@ -379,14 +402,22 @@ Update a budget policy. } } } - updateReq.PolicyId = args[0] + updateReq.Policy.PolicyId = new(args[0]) - response, err := a.BudgetPolicy.Update(ctx, updateReq) + sdkReq, err := budgetpolicy.UpdateBudgetPolicyRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := a.BudgetPolicy.UpdateBudgetPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := budgetpolicy.BudgetPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/budgets/budgets.go b/cmd/account/budgets/budgets.go index 723486a2e40..dc7dbe77b7a 100644 --- a/cmd/account/budgets/budgets.go +++ b/cmd/account/budgets/budgets.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/billing" "github.com/spf13/cobra" + + budgets "github.com/databricks/cli/libs/sdktypes/budgets/v1" + sdkbudgets "github.com/databricks/sdk-go/budgets/v1" ) // Slice with functions to override default command behavior. @@ -57,13 +60,13 @@ These APIs manage budget configurations for this account. Budgets enable you // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *billing.CreateBudgetConfigurationRequest, + *budgets.CreateBudgetConfigurationRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq budgets.CreateBudgetConfigurationRequest - var createReq billing.CreateBudgetConfigurationRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -85,6 +88,7 @@ Create new budget. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -101,12 +105,20 @@ Create new budget. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.Budgets.Create(ctx, createReq) + sdkReq, err := budgets.CreateBudgetConfigurationRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Budgets.CreateBudgetConfiguration(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := budgets.CreateBudgetConfigurationResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -127,13 +139,12 @@ Create new budget. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *billing.DeleteBudgetConfigurationRequest, + *sdkbudgets.DeleteBudgetConfigurationRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq billing.DeleteBudgetConfigurationRequest + var deleteReq sdkbudgets.DeleteBudgetConfigurationRequest cmd.Use = "delete BUDGET_ID" cmd.Short = `*Public Preview* Delete budget.` @@ -160,13 +171,17 @@ Delete budget. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.BudgetId = args[0] + deleteReq.BudgetId = new(args[0]) - err = a.Budgets.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.Budgets.DeleteBudgetConfiguration(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -188,13 +203,12 @@ Delete budget. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *billing.GetBudgetConfigurationRequest, + *sdkbudgets.GetBudgetConfigurationRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq billing.GetBudgetConfigurationRequest + var getReq sdkbudgets.GetBudgetConfigurationRequest cmd.Use = "get BUDGET_ID" cmd.Short = `*Public Preview* Get budget.` @@ -221,15 +235,21 @@ Get budget. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.BudgetId = args[0] + getReq.BudgetId = new(args[0]) - response, err := a.Budgets.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Budgets.GetBudgetConfiguration(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := budgets.GetBudgetConfigurationResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -250,13 +270,13 @@ Get budget. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *billing.ListBudgetConfigurationsRequest, + *budgets.ListBudgetConfigurationsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq budgets.ListBudgetConfigurationsRequest - var listReq billing.ListBudgetConfigurationsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -266,7 +286,7 @@ func newList() *cobra.Command { cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -290,16 +310,20 @@ Get all budgets. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.Budgets.List(ctx, listReq) + sdkReq, err := budgets.ListBudgetConfigurationsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Budgets.ListBudgetConfigurationsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, budgets.BudgetConfigurationFromSDK)) } // Disable completions since they are not applicable. @@ -320,13 +344,13 @@ Get all budgets. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *billing.UpdateBudgetConfigurationRequest, + *budgets.UpdateBudgetConfigurationRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq budgets.UpdateBudgetConfigurationRequest - var updateReq billing.UpdateBudgetConfigurationRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -356,6 +380,7 @@ Modify budget. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -371,14 +396,22 @@ Modify budget. } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateReq.BudgetId = args[0] + updateReq.BudgetId = new(args[0]) - response, err := a.Budgets.Update(ctx, updateReq) + sdkReq, err := budgets.UpdateBudgetConfigurationRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := a.Budgets.UpdateBudgetConfiguration(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := budgets.UpdateBudgetConfigurationResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/credentials/credentials.go b/cmd/account/credentials/credentials.go index 580a650e889..0763e680774 100644 --- a/cmd/account/credentials/credentials.go +++ b/cmd/account/credentials/credentials.go @@ -9,8 +9,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/provisioning" "github.com/spf13/cobra" + + uccredentials "github.com/databricks/cli/libs/sdktypes/uc/credentials/v1" + sdkuccredentials "github.com/databricks/sdk-go/uc/credentials/v1" ) // Slice with functions to override default command behavior. @@ -54,13 +56,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *provisioning.CreateCredentialRequest, + *uccredentials.CreateCredentialsRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq uccredentials.CreateCredentialsRequest - var createReq provisioning.CreateCredentialRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -92,6 +94,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -108,12 +111,20 @@ func newCreate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.Credentials.Create(ctx, createReq) + sdkReq, err := uccredentials.CreateCredentialsRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Credentials.CreateCredentialsPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.CredentialsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -134,13 +145,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *provisioning.DeleteCredentialRequest, + *sdkuccredentials.DeleteCredentialsRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq provisioning.DeleteCredentialRequest + var deleteReq sdkuccredentials.DeleteCredentialsRequest cmd.Use = "delete CREDENTIALS_ID" cmd.Short = `Delete credential configuration.` @@ -166,15 +176,21 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.CredentialsId = args[0] + deleteReq.CredentialsId = new(args[0]) - response, err := a.Credentials.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.Credentials.DeleteCredentialsPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.CredentialsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -195,13 +211,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *provisioning.GetCredentialRequest, + *sdkuccredentials.GetCredentialsRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq provisioning.GetCredentialRequest + var getReq sdkuccredentials.GetCredentialsRequest cmd.Use = "get CREDENTIALS_ID" cmd.Short = `Get credential configuration.` @@ -226,15 +241,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.CredentialsId = args[0] + getReq.CredentialsId = new(args[0]) - response, err := a.Credentials.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Credentials.GetCredentialsPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.CredentialsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -275,12 +296,17 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - response, err := a.Credentials.List(ctx) + _ = a + + sdkReq := &sdkuccredentials.ListCredentialsPublicRequest{} + + response, err := a.Credentials.ListCredentialsPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. diff --git a/cmd/account/csp-enablement-account/csp-enablement-account.go b/cmd/account/csp-enablement-account/csp-enablement-account.go index 6e90bdae435..26f18b69f46 100644 --- a/cmd/account/csp-enablement-account/csp-enablement-account.go +++ b/cmd/account/csp-enablement-account/csp-enablement-account.go @@ -4,12 +4,15 @@ package csp_enablement_account import ( "errors" + "fmt" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" "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/settings" "github.com/spf13/cobra" ) @@ -55,15 +58,16 @@ The compliance security profile settings at the account level control whether // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetCspEnablementAccountSettingRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetCspEnablementAccountSettingRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `*Public Preview* Get the compliance security profile setting for new workspaces.` @@ -86,12 +90,24 @@ Get the compliance security profile setting for new workspaces. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/shield_csp_enablement_ac/names/default", a.Config.AccountID) - response, err := a.Settings.CspEnablementAccount().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -113,13 +129,16 @@ Get the compliance security profile setting for new workspaces. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateCspEnablementAccountSettingRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateCspEnablementAccountSettingRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -141,6 +160,7 @@ Update the compliance security profile setting for new workspaces. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -157,11 +177,24 @@ Update the compliance security profile setting for new workspaces. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.Settings.CspEnablementAccount().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/shield_csp_enablement_ac/names/default", a.Config.AccountID) + + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/account/custom-app-integration/custom-app-integration.go b/cmd/account/custom-app-integration/custom-app-integration.go index 16882132e51..7a30ceff8c1 100644 --- a/cmd/account/custom-app-integration/custom-app-integration.go +++ b/cmd/account/custom-app-integration/custom-app-integration.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/oauth2" "github.com/spf13/cobra" + + oauth "github.com/databricks/cli/libs/sdktypes/oauth/v1" + sdkoauth "github.com/databricks/sdk-go/oauth/v1" ) // Slice with functions to override default command behavior. @@ -53,19 +56,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *oauth2.CreateCustomAppIntegration, + *oauth.CreateCustomOAuthAppIntegrationRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq oauth.CreateCustomOAuthAppIntegrationRequest - var createReq oauth2.CreateCustomAppIntegration var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createReq.Confidential, "confidential", createReq.Confidential, `This field indicates whether an OAuth client secret is required to authenticate this client.`) - cmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `Name of the custom OAuth app.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.Confidential, "confidential", `This field indicates whether an OAuth client secret is required to authenticate this client.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Name, "name", `Name of the custom OAuth app.`) // TODO: array: redirect_urls // TODO: array: scopes // TODO: complex arg: token_access_policy @@ -95,6 +98,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -109,12 +113,20 @@ func newCreate() *cobra.Command { } } - response, err := a.CustomAppIntegration.Create(ctx, createReq) + sdkReq, err := oauth.CreateCustomOAuthAppIntegrationRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.OAuth.CreateCustomOAuthAppIntegration(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := oauth.CustomOAuthAppIntegrationSecretFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -135,13 +147,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *oauth2.DeleteCustomAppIntegrationRequest, + *sdkoauth.DeleteCustomOAuthAppIntegrationRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq oauth2.DeleteCustomAppIntegrationRequest + var deleteReq sdkoauth.DeleteCustomOAuthAppIntegrationRequest cmd.Use = "delete INTEGRATION_ID" cmd.Short = `Delete Custom OAuth App Integration.` @@ -165,13 +176,17 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.IntegrationId = args[0] + deleteReq.IntegrationId = new(args[0]) - err = a.CustomAppIntegration.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.OAuth.DeleteCustomOAuthAppIntegration(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -193,13 +208,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *oauth2.GetCustomAppIntegrationRequest, + *sdkoauth.GetCustomOAuthAppIntegrationRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq oauth2.GetCustomAppIntegrationRequest + var getReq sdkoauth.GetCustomOAuthAppIntegrationRequest cmd.Use = "get INTEGRATION_ID" cmd.Short = `Get OAuth Custom App Integration.` @@ -223,15 +237,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.IntegrationId = args[0] + getReq.IntegrationId = new(args[0]) - response, err := a.CustomAppIntegration.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.OAuth.GetCustomOAuthAppIntegration(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := oauth.CustomOAuthAppIntegrationFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -252,26 +272,26 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *oauth2.ListCustomAppIntegrationsRequest, + *oauth.ListCustomOAuthAppIntegrationsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq oauth.ListCustomOAuthAppIntegrationsRequest - var listReq oauth2.ListCustomAppIntegrationsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().BoolVar(&listReq.IncludeCreatorUsername, "include-creator-username", listReq.IncludeCreatorUsername, ``) - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeCreatorUsername, "include-creator-username", ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -294,16 +314,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.CustomAppIntegration.List(ctx, listReq) + sdkReq, err := oauth.ListCustomOAuthAppIntegrationsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.OAuth.ListCustomOAuthAppIntegrationsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, oauth.CustomOAuthAppIntegrationFromSDK)) } // Disable completions since they are not applicable. @@ -324,13 +348,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *oauth2.UpdateCustomAppIntegration, + *oauth.UpdateCustomOAuthAppIntegrationRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq oauth.UpdateCustomOAuthAppIntegrationRequest - var updateReq oauth2.UpdateCustomAppIntegration var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -362,6 +386,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -375,12 +400,18 @@ func newUpdate() *cobra.Command { } } } - updateReq.IntegrationId = args[0] + updateReq.IntegrationId = new(args[0]) - err = a.CustomAppIntegration.Update(ctx, updateReq) + sdkReq, err := oauth.UpdateCustomOAuthAppIntegrationRequestToSDK(&updateReq) if err != nil { return err } + response, err := a.OAuth.UpdateCustomOAuthAppIntegration(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } diff --git a/cmd/account/disable-legacy-features/disable-legacy-features.go b/cmd/account/disable-legacy-features/disable-legacy-features.go index 7ded95ff0a3..50601db6361 100644 --- a/cmd/account/disable-legacy-features/disable-legacy-features.go +++ b/cmd/account/disable-legacy-features/disable-legacy-features.go @@ -4,12 +4,15 @@ package disable_legacy_features import ( "errors" + "fmt" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" "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/settings" "github.com/spf13/cobra" ) @@ -52,15 +55,16 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteDisableLegacyFeaturesRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeleteDisableLegacyFeaturesRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `Delete the disable legacy features setting.` @@ -81,12 +85,24 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/disable_legacy_features/names/default", a.Config.AccountID) - response, err := a.Settings.DisableLegacyFeatures().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -108,15 +124,16 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetDisableLegacyFeaturesRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetDisableLegacyFeaturesRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `Get the disable legacy features setting.` @@ -137,12 +154,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/disable_legacy_features/names/default", a.Config.AccountID) - response, err := a.Settings.DisableLegacyFeatures().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -164,13 +193,16 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateDisableLegacyFeaturesRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateDisableLegacyFeaturesRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -189,6 +221,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -205,11 +238,24 @@ func newUpdate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.Settings.DisableLegacyFeatures().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/disable_legacy_features/names/default", a.Config.AccountID) + + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/account/disaster-recovery/disaster-recovery.go b/cmd/account/disaster-recovery/disaster-recovery.go index 014927b2dba..49eb6cdd8e7 100644 --- a/cmd/account/disaster-recovery/disaster-recovery.go +++ b/cmd/account/disaster-recovery/disaster-recovery.go @@ -5,15 +5,16 @@ package disaster_recovery import ( "errors" "fmt" - "strings" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "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/disasterrecovery" "github.com/spf13/cobra" + + disasterrecovery "github.com/databricks/cli/libs/sdktypes/disasterrecovery/v1" + sdkdisasterrecovery "github.com/databricks/sdk-go/disasterrecovery/v1" ) // Slice with functions to override default command behavior. @@ -64,15 +65,15 @@ var createFailoverGroupOverrides []func( func newCreateFailoverGroup() *cobra.Command { cmd := &cobra.Command{} - var createFailoverGroupReq disasterrecovery.CreateFailoverGroupRequest - createFailoverGroupReq.FailoverGroup = disasterrecovery.FailoverGroup{} + createFailoverGroupReq.FailoverGroup = &disasterrecovery.FailoverGroup{} + var createFailoverGroupJson flags.JsonFlag cmd.Flags().Var(&createFailoverGroupJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createFailoverGroupReq.ValidateOnly, "validate-only", createFailoverGroupReq.ValidateOnly, `When true, validates the request without creating the failover group.`) - cmd.Flags().StringVar(&createFailoverGroupReq.FailoverGroup.Name, "name", createFailoverGroupReq.FailoverGroup.Name, `Fully qualified resource name in the format accounts/{account_id}/failover-groups/{failover_group_id}.`) + flags.BoolPtrVar(cmd.Flags(), &createFailoverGroupReq.ValidateOnly, "validate-only", `When true, validates the request without creating the failover group.`) + flags.StringPtrVar(cmd.Flags(), &createFailoverGroupReq.FailoverGroup.Name, "name", `Fully qualified resource name in the format accounts/{account_id}/failover-groups/{failover_group_id}.`) // TODO: complex arg: unity_catalog_assets cmd.Use = "create-failover-group PARENT FAILOVER_GROUP_ID REGIONS WORKSPACE_SETS INITIAL_PRIMARY_REGION" @@ -110,6 +111,7 @@ func newCreateFailoverGroup() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createFailoverGroupJson.Unmarshal(&createFailoverGroupReq.FailoverGroup) @@ -123,32 +125,32 @@ func newCreateFailoverGroup() *cobra.Command { } } } - createFailoverGroupReq.Parent = args[0] - createFailoverGroupReq.FailoverGroupId = args[1] + createFailoverGroupReq.Parent = new(args[0]) + createFailoverGroupReq.FailoverGroupId = new(args[1]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &createFailoverGroupReq.FailoverGroup.Regions) - if err != nil { - return fmt.Errorf("invalid REGIONS: %s", args[2]) - } - + _ = args[2] // TODO: complex arg: regions } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &createFailoverGroupReq.FailoverGroup.WorkspaceSets) - if err != nil { - return fmt.Errorf("invalid WORKSPACE_SETS: %s", args[3]) - } - + _ = args[3] // TODO: complex arg: workspace_sets } if !cmd.Flags().Changed("json") { - createFailoverGroupReq.FailoverGroup.InitialPrimaryRegion = args[4] + createFailoverGroupReq.FailoverGroup.InitialPrimaryRegion = new(args[4]) } - response, err := a.DisasterRecovery.CreateFailoverGroup(ctx, createFailoverGroupReq) + sdkReq, err := disasterrecovery.CreateFailoverGroupRequestToSDK(&createFailoverGroupReq) + if err != nil { + return err + } + response, err := a.DisasterRecovery.CreateFailoverGroup(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := disasterrecovery.FailoverGroupFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -174,15 +176,15 @@ var createStableUrlOverrides []func( func newCreateStableUrl() *cobra.Command { cmd := &cobra.Command{} - var createStableUrlReq disasterrecovery.CreateStableUrlRequest - createStableUrlReq.StableUrl = disasterrecovery.StableUrl{} + createStableUrlReq.StableUrl = &disasterrecovery.StableUrl{} + var createStableUrlJson flags.JsonFlag cmd.Flags().Var(&createStableUrlJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createStableUrlReq.ValidateOnly, "validate-only", createStableUrlReq.ValidateOnly, `When true, validates the request without creating the stable URL.`) - cmd.Flags().StringVar(&createStableUrlReq.StableUrl.Name, "name", createStableUrlReq.StableUrl.Name, `Fully qualified resource name.`) + flags.BoolPtrVar(cmd.Flags(), &createStableUrlReq.ValidateOnly, "validate-only", `When true, validates the request without creating the stable URL.`) + flags.StringPtrVar(cmd.Flags(), &createStableUrlReq.StableUrl.Name, "name", `Fully qualified resource name.`) cmd.Use = "create-stable-url PARENT STABLE_URL_ID INITIAL_WORKSPACE_ID" cmd.Short = `Create a Stable URL.` @@ -218,6 +220,7 @@ func newCreateStableUrl() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createStableUrlJson.Unmarshal(&createStableUrlReq.StableUrl) @@ -231,18 +234,26 @@ func newCreateStableUrl() *cobra.Command { } } } - createStableUrlReq.Parent = args[0] - createStableUrlReq.StableUrlId = args[1] + createStableUrlReq.Parent = new(args[0]) + createStableUrlReq.StableUrlId = new(args[1]) if !cmd.Flags().Changed("json") { - createStableUrlReq.StableUrl.InitialWorkspaceId = args[2] + createStableUrlReq.StableUrl.InitialWorkspaceId = new(args[2]) } - response, err := a.DisasterRecovery.CreateStableUrl(ctx, createStableUrlReq) + sdkReq, err := disasterrecovery.CreateStableUrlRequestToSDK(&createStableUrlReq) + if err != nil { + return err + } + response, err := a.DisasterRecovery.CreateStableUrl(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := disasterrecovery.StableUrlFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -268,10 +279,9 @@ var deleteFailoverGroupOverrides []func( func newDeleteFailoverGroup() *cobra.Command { cmd := &cobra.Command{} - var deleteFailoverGroupReq disasterrecovery.DeleteFailoverGroupRequest - cmd.Flags().StringVar(&deleteFailoverGroupReq.Etag, "etag", deleteFailoverGroupReq.Etag, `Opaque version string for optimistic locking.`) + flags.StringPtrVar(cmd.Flags(), &deleteFailoverGroupReq.Etag, "etag", `Opaque version string for optimistic locking.`) cmd.Use = "delete-failover-group NAME" cmd.Short = `Delete a Failover Group.` @@ -296,10 +306,15 @@ func newDeleteFailoverGroup() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteFailoverGroupReq.Name = args[0] + deleteFailoverGroupReq.Name = new(args[0]) - err = a.DisasterRecovery.DeleteFailoverGroup(ctx, deleteFailoverGroupReq) + sdkReq, err := disasterrecovery.DeleteFailoverGroupRequestToSDK(&deleteFailoverGroupReq) + if err != nil { + return err + } + err = a.DisasterRecovery.DeleteFailoverGroup(ctx, *sdkReq) if err != nil { return err } @@ -324,13 +339,12 @@ func newDeleteFailoverGroup() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteStableUrlOverrides []func( *cobra.Command, - *disasterrecovery.DeleteStableUrlRequest, + *sdkdisasterrecovery.DeleteStableUrlRequest, ) func newDeleteStableUrl() *cobra.Command { cmd := &cobra.Command{} - - var deleteStableUrlReq disasterrecovery.DeleteStableUrlRequest + var deleteStableUrlReq sdkdisasterrecovery.DeleteStableUrlRequest cmd.Use = "delete-stable-url NAME" cmd.Short = `Delete a Stable URL.` @@ -355,10 +369,12 @@ func newDeleteStableUrl() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteStableUrlReq.Name = args[0] + deleteStableUrlReq.Name = new(args[0]) - err = a.DisasterRecovery.DeleteStableUrl(ctx, deleteStableUrlReq) + sdkReq := &deleteStableUrlReq + err = a.DisasterRecovery.DeleteStableUrl(ctx, *sdkReq) if err != nil { return err } @@ -388,13 +404,13 @@ var failoverFailoverGroupOverrides []func( func newFailoverFailoverGroup() *cobra.Command { cmd := &cobra.Command{} - var failoverFailoverGroupReq disasterrecovery.FailoverFailoverGroupRequest + var failoverFailoverGroupJson flags.JsonFlag cmd.Flags().Var(&failoverFailoverGroupJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&failoverFailoverGroupReq.Etag, "etag", failoverFailoverGroupReq.Etag, `Opaque version string for optimistic locking.`) + flags.StringPtrVar(cmd.Flags(), &failoverFailoverGroupReq.Etag, "etag", `Opaque version string for optimistic locking.`) cmd.Use = "failover-failover-group NAME TARGET_PRIMARY_REGION FAILOVER_TYPE" cmd.Short = `Failover a Failover Group to a new primary region.` @@ -431,6 +447,7 @@ func newFailoverFailoverGroup() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := failoverFailoverGroupJson.Unmarshal(&failoverFailoverGroupReq) @@ -444,24 +461,28 @@ func newFailoverFailoverGroup() *cobra.Command { } } } - failoverFailoverGroupReq.Name = args[0] + failoverFailoverGroupReq.Name = new(args[0]) if !cmd.Flags().Changed("json") { - failoverFailoverGroupReq.TargetPrimaryRegion = args[1] + failoverFailoverGroupReq.TargetPrimaryRegion = new(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &failoverFailoverGroupReq.FailoverType) - if err != nil { - return fmt.Errorf("invalid FAILOVER_TYPE: %s", args[2]) - } - + failoverFailoverGroupReq.FailoverType = disasterrecovery.FailoverFailoverGroupRequest_FailoverType(args[2]) } - response, err := a.DisasterRecovery.FailoverFailoverGroup(ctx, failoverFailoverGroupReq) + sdkReq, err := disasterrecovery.FailoverFailoverGroupRequestToSDK(&failoverFailoverGroupReq) + if err != nil { + return err + } + response, err := a.DisasterRecovery.FailoverFailoverGroup(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := disasterrecovery.FailoverGroupFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -482,13 +503,12 @@ func newFailoverFailoverGroup() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getFailoverGroupOverrides []func( *cobra.Command, - *disasterrecovery.GetFailoverGroupRequest, + *sdkdisasterrecovery.GetFailoverGroupRequest, ) func newGetFailoverGroup() *cobra.Command { cmd := &cobra.Command{} - - var getFailoverGroupReq disasterrecovery.GetFailoverGroupRequest + var getFailoverGroupReq sdkdisasterrecovery.GetFailoverGroupRequest cmd.Use = "get-failover-group NAME" cmd.Short = `Get a Failover Group.` @@ -513,15 +533,21 @@ func newGetFailoverGroup() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getFailoverGroupReq.Name = args[0] + getFailoverGroupReq.Name = new(args[0]) - response, err := a.DisasterRecovery.GetFailoverGroup(ctx, getFailoverGroupReq) + sdkReq := &getFailoverGroupReq + response, err := a.DisasterRecovery.GetFailoverGroup(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := disasterrecovery.FailoverGroupFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -542,13 +568,12 @@ func newGetFailoverGroup() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getStableUrlOverrides []func( *cobra.Command, - *disasterrecovery.GetStableUrlRequest, + *sdkdisasterrecovery.GetStableUrlRequest, ) func newGetStableUrl() *cobra.Command { cmd := &cobra.Command{} - - var getStableUrlReq disasterrecovery.GetStableUrlRequest + var getStableUrlReq sdkdisasterrecovery.GetStableUrlRequest cmd.Use = "get-stable-url NAME" cmd.Short = `Get a Stable URL.` @@ -573,15 +598,21 @@ func newGetStableUrl() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getStableUrlReq.Name = args[0] + getStableUrlReq.Name = new(args[0]) - response, err := a.DisasterRecovery.GetStableUrl(ctx, getStableUrlReq) + sdkReq := &getStableUrlReq + response, err := a.DisasterRecovery.GetStableUrl(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := disasterrecovery.StableUrlFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -607,20 +638,20 @@ var listFailoverGroupsOverrides []func( func newListFailoverGroups() *cobra.Command { cmd := &cobra.Command{} - var listFailoverGroupsReq disasterrecovery.ListFailoverGroupsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listFailoverGroupsLimit int - cmd.Flags().IntVar(&listFailoverGroupsReq.PageSize, "page-size", listFailoverGroupsReq.PageSize, `Maximum number of failover groups to return per page: - when set to a value greater than 0, the page length is the minimum of this value and a server configured value; - when set to 0 or unset, the page length is set to a server configured value (recommended); - when set to a value less than 0, an invalid parameter error is returned.`) + flags.IntPtrVar(cmd.Flags(), &listFailoverGroupsReq.PageSize, "page-size", `Maximum number of failover groups to return per page: - when set to a value greater than 0, the page length is the minimum of this value and a server configured value; - when set to 0 or unset, the page length is set to a server configured value (recommended); - when set to a value less than 0, an invalid parameter error is returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listFailoverGroupsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listFailoverGroupsReq.PageToken, "page-token", listFailoverGroupsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listFailoverGroupsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-failover-groups PARENT" @@ -648,18 +679,22 @@ func newListFailoverGroups() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - listFailoverGroupsReq.Parent = args[0] + listFailoverGroupsReq.Parent = new(args[0]) - response := a.DisasterRecovery.ListFailoverGroups(ctx, listFailoverGroupsReq) + sdkReq, err := disasterrecovery.ListFailoverGroupsRequestToSDK(&listFailoverGroupsReq) + if err != nil { + return err + } if listFailoverGroupsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listFailoverGroupsLimit) } if listFailoverGroupsLimit > 0 { ctx = cmdio.WithLimit(ctx, listFailoverGroupsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.DisasterRecovery.ListFailoverGroupsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, disasterrecovery.FailoverGroupFromSDK)) } // Disable completions since they are not applicable. @@ -685,20 +720,20 @@ var listStableUrlsOverrides []func( func newListStableUrls() *cobra.Command { cmd := &cobra.Command{} - var listStableUrlsReq disasterrecovery.ListStableUrlsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listStableUrlsLimit int - cmd.Flags().IntVar(&listStableUrlsReq.PageSize, "page-size", listStableUrlsReq.PageSize, `Maximum number of stable URLs to return per page: - when set to a value greater than 0, the page length is the minimum of this value and a server configured value; - when set to 0 or unset, the page length is set to a server configured value (recommended); - when set to a value less than 0, an invalid parameter error is returned.`) + flags.IntPtrVar(cmd.Flags(), &listStableUrlsReq.PageSize, "page-size", `Maximum number of stable URLs to return per page: - when set to a value greater than 0, the page length is the minimum of this value and a server configured value; - when set to 0 or unset, the page length is set to a server configured value (recommended); - when set to a value less than 0, an invalid parameter error is returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listStableUrlsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listStableUrlsReq.PageToken, "page-token", listStableUrlsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listStableUrlsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-stable-urls PARENT" @@ -723,18 +758,22 @@ func newListStableUrls() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - listStableUrlsReq.Parent = args[0] + listStableUrlsReq.Parent = new(args[0]) - response := a.DisasterRecovery.ListStableUrls(ctx, listStableUrlsReq) + sdkReq, err := disasterrecovery.ListStableUrlsRequestToSDK(&listStableUrlsReq) + if err != nil { + return err + } if listStableUrlsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listStableUrlsLimit) } if listStableUrlsLimit > 0 { ctx = cmdio.WithLimit(ctx, listStableUrlsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.DisasterRecovery.ListStableUrlsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, disasterrecovery.StableUrlFromSDK)) } // Disable completions since they are not applicable. @@ -760,15 +799,15 @@ var updateFailoverGroupOverrides []func( func newUpdateFailoverGroup() *cobra.Command { cmd := &cobra.Command{} - var updateFailoverGroupReq disasterrecovery.UpdateFailoverGroupRequest - updateFailoverGroupReq.FailoverGroup = disasterrecovery.FailoverGroup{} + updateFailoverGroupReq.FailoverGroup = &disasterrecovery.FailoverGroup{} + var updateFailoverGroupJson flags.JsonFlag cmd.Flags().Var(&updateFailoverGroupJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateFailoverGroupReq.Etag, "etag", updateFailoverGroupReq.Etag, `Optional opaque version string for optimistic locking, obtained from a prior read of the failover group.`) - cmd.Flags().StringVar(&updateFailoverGroupReq.FailoverGroup.Name, "name", updateFailoverGroupReq.FailoverGroup.Name, `Fully qualified resource name in the format accounts/{account_id}/failover-groups/{failover_group_id}.`) + flags.StringPtrVar(cmd.Flags(), &updateFailoverGroupReq.Etag, "etag", `Optional opaque version string for optimistic locking, obtained from a prior read of the failover group.`) + flags.StringPtrVar(cmd.Flags(), &updateFailoverGroupReq.FailoverGroup.Name, "name", `Fully qualified resource name in the format accounts/{account_id}/failover-groups/{failover_group_id}.`) // TODO: complex arg: unity_catalog_assets cmd.Use = "update-failover-group NAME UPDATE_MASK REGIONS WORKSPACE_SETS INITIAL_PRIMARY_REGION" @@ -806,6 +845,7 @@ func newUpdateFailoverGroup() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateFailoverGroupJson.Unmarshal(&updateFailoverGroupReq.FailoverGroup) @@ -819,35 +859,34 @@ func newUpdateFailoverGroup() *cobra.Command { } } } - updateFailoverGroupReq.Name = args[0] + updateFailoverGroupReq.FailoverGroup.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateFailoverGroupReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateFailoverGroupReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &updateFailoverGroupReq.FailoverGroup.Regions) - if err != nil { - return fmt.Errorf("invalid REGIONS: %s", args[2]) - } - + _ = args[2] // TODO: complex arg: regions } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updateFailoverGroupReq.FailoverGroup.WorkspaceSets) - if err != nil { - return fmt.Errorf("invalid WORKSPACE_SETS: %s", args[3]) - } - + _ = args[3] // TODO: complex arg: workspace_sets } if !cmd.Flags().Changed("json") { - updateFailoverGroupReq.FailoverGroup.InitialPrimaryRegion = args[4] + updateFailoverGroupReq.FailoverGroup.InitialPrimaryRegion = new(args[4]) } - response, err := a.DisasterRecovery.UpdateFailoverGroup(ctx, updateFailoverGroupReq) + sdkReq, err := disasterrecovery.UpdateFailoverGroupRequestToSDK(&updateFailoverGroupReq) + if err != nil { + return err + } + response, err := a.DisasterRecovery.UpdateFailoverGroup(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := disasterrecovery.FailoverGroupFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/enable-ip-access-lists/enable-ip-access-lists.go b/cmd/account/enable-ip-access-lists/enable-ip-access-lists.go index e417dc92144..13922926080 100644 --- a/cmd/account/enable-ip-access-lists/enable-ip-access-lists.go +++ b/cmd/account/enable-ip-access-lists/enable-ip-access-lists.go @@ -4,12 +4,15 @@ package enable_ip_access_lists import ( "errors" + "fmt" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" "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/settings" "github.com/spf13/cobra" ) @@ -52,15 +55,16 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteAccountIpAccessEnableRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeleteAccountIpAccessEnableRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `Delete the account IP access toggle setting.` @@ -81,12 +85,24 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/acct_ip_acl_enable/names/default", a.Config.AccountID) - response, err := a.Settings.EnableIpAccessLists().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -108,15 +124,16 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetAccountIpAccessEnableRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetAccountIpAccessEnableRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `Get the account IP access toggle setting.` @@ -137,12 +154,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/acct_ip_acl_enable/names/default", a.Config.AccountID) - response, err := a.Settings.EnableIpAccessLists().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -164,13 +193,16 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateAccountIpAccessEnableRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateAccountIpAccessEnableRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -189,6 +221,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -205,11 +238,24 @@ func newUpdate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.Settings.EnableIpAccessLists().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/acct_ip_acl_enable/names/default", a.Config.AccountID) + + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/account/encryption-keys/encryption-keys.go b/cmd/account/encryption-keys/encryption-keys.go index 941fe953d43..2c081e93237 100644 --- a/cmd/account/encryption-keys/encryption-keys.go +++ b/cmd/account/encryption-keys/encryption-keys.go @@ -9,8 +9,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/provisioning" "github.com/spf13/cobra" + + keyconfigurations "github.com/databricks/cli/libs/sdktypes/keyconfigurations/v1" + sdkkeyconfigurations "github.com/databricks/sdk-go/keyconfigurations/v1" ) // Slice with functions to override default command behavior. @@ -65,13 +67,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *provisioning.CreateCustomerManagedKeyRequest, + *keyconfigurations.CreateCustomerManagedKeyRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq keyconfigurations.CreateCustomerManagedKeyRequest - var createReq provisioning.CreateCustomerManagedKeyRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -120,6 +122,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -136,12 +139,20 @@ func newCreate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.EncryptionKeys.Create(ctx, createReq) + sdkReq, err := keyconfigurations.CreateCustomerManagedKeyRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.KeyConfigurations.CreateCustomerManagedKeyPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := keyconfigurations.CustomerManagedKeyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -162,13 +173,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *provisioning.DeleteEncryptionKeyRequest, + *sdkkeyconfigurations.DeleteCustomerManagedKeyRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq provisioning.DeleteEncryptionKeyRequest + var deleteReq sdkkeyconfigurations.DeleteCustomerManagedKeyRequest cmd.Use = "delete CUSTOMER_MANAGED_KEY_ID" cmd.Short = `Delete encryption key configuration.` @@ -193,15 +203,21 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.CustomerManagedKeyId = args[0] + deleteReq.CustomerManagedKeyId = new(args[0]) - response, err := a.EncryptionKeys.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.KeyConfigurations.DeleteCustomerManagedKeyPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := keyconfigurations.CustomerManagedKeyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -222,13 +238,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *provisioning.GetEncryptionKeyRequest, + *sdkkeyconfigurations.GetCustomerManagedKeyRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq provisioning.GetEncryptionKeyRequest + var getReq sdkkeyconfigurations.GetCustomerManagedKeyRequest cmd.Use = "get CUSTOMER_MANAGED_KEY_ID" cmd.Short = `Get encryption key configuration.` @@ -266,15 +281,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.CustomerManagedKeyId = args[0] + getReq.CustomerManagedKeyId = new(args[0]) - response, err := a.EncryptionKeys.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.KeyConfigurations.GetCustomerManagedKeyPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := keyconfigurations.CustomerManagedKeyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -314,12 +335,17 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - response, err := a.EncryptionKeys.List(ctx) + _ = a + + sdkReq := &sdkkeyconfigurations.ListCustomerManagedKeyRequest{} + + response, err := a.KeyConfigurations.ListCustomerManagedKeyPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. diff --git a/cmd/account/endpoints/endpoints.go b/cmd/account/endpoints/endpoints.go index 8cdb1b5c73f..668e0217707 100644 --- a/cmd/account/endpoints/endpoints.go +++ b/cmd/account/endpoints/endpoints.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/networking" "github.com/spf13/cobra" + + networking "github.com/databricks/cli/libs/sdktypes/networking/v1" + sdknetworking "github.com/databricks/sdk-go/networking/v1" ) // Slice with functions to override default command behavior. @@ -56,9 +59,9 @@ var createEndpointOverrides []func( func newCreateEndpoint() *cobra.Command { cmd := &cobra.Command{} - var createEndpointReq networking.CreateEndpointRequest - createEndpointReq.Endpoint = networking.Endpoint{} + createEndpointReq.Endpoint = &networking.Endpoint{} + var createEndpointJson flags.JsonFlag cmd.Flags().Var(&createEndpointJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -109,6 +112,7 @@ func newCreateEndpoint() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createEndpointJson.Unmarshal(&createEndpointReq.Endpoint) @@ -122,20 +126,28 @@ func newCreateEndpoint() *cobra.Command { } } } - createEndpointReq.Parent = args[0] + createEndpointReq.Parent = new(args[0]) if !cmd.Flags().Changed("json") { - createEndpointReq.Endpoint.DisplayName = args[1] + createEndpointReq.Endpoint.DisplayName = new(args[1]) } if !cmd.Flags().Changed("json") { - createEndpointReq.Endpoint.Region = args[2] + createEndpointReq.Endpoint.Region = new(args[2]) } - response, err := a.Endpoints.CreateEndpoint(ctx, createEndpointReq) + sdkReq, err := networking.CreateEndpointRequestToSDK(&createEndpointReq) + if err != nil { + return err + } + response, err := a.Networking.CreateEndpoint(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.EndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -156,13 +168,12 @@ func newCreateEndpoint() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteEndpointOverrides []func( *cobra.Command, - *networking.DeleteEndpointRequest, + *sdknetworking.DeleteEndpointRequest, ) func newDeleteEndpoint() *cobra.Command { cmd := &cobra.Command{} - - var deleteEndpointReq networking.DeleteEndpointRequest + var deleteEndpointReq sdknetworking.DeleteEndpointRequest cmd.Use = "delete-endpoint NAME" cmd.Short = `Delete a network endpoint.` @@ -185,10 +196,12 @@ func newDeleteEndpoint() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteEndpointReq.Name = args[0] + deleteEndpointReq.Name = new(args[0]) - err = a.Endpoints.DeleteEndpoint(ctx, deleteEndpointReq) + sdkReq := &deleteEndpointReq + err = a.Networking.DeleteEndpoint(ctx, *sdkReq) if err != nil { return err } @@ -213,13 +226,12 @@ func newDeleteEndpoint() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getEndpointOverrides []func( *cobra.Command, - *networking.GetEndpointRequest, + *sdknetworking.GetEndpointRequest, ) func newGetEndpoint() *cobra.Command { cmd := &cobra.Command{} - - var getEndpointReq networking.GetEndpointRequest + var getEndpointReq sdknetworking.GetEndpointRequest cmd.Use = "get-endpoint NAME" cmd.Short = `Get a network endpoint.` @@ -240,15 +252,21 @@ func newGetEndpoint() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getEndpointReq.Name = args[0] + getEndpointReq.Name = new(args[0]) - response, err := a.Endpoints.GetEndpoint(ctx, getEndpointReq) + sdkReq := &getEndpointReq + response, err := a.Networking.GetEndpoint(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.EndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -274,20 +292,20 @@ var listEndpointsOverrides []func( func newListEndpoints() *cobra.Command { cmd := &cobra.Command{} - var listEndpointsReq networking.ListEndpointsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listEndpointsLimit int - cmd.Flags().IntVar(&listEndpointsReq.PageSize, "page-size", listEndpointsReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listEndpointsReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listEndpointsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listEndpointsReq.PageToken, "page-token", listEndpointsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listEndpointsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-endpoints PARENT" @@ -313,18 +331,22 @@ func newListEndpoints() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - listEndpointsReq.Parent = args[0] + listEndpointsReq.Parent = new(args[0]) - response := a.Endpoints.ListEndpoints(ctx, listEndpointsReq) + sdkReq, err := networking.ListEndpointsRequestToSDK(&listEndpointsReq) + if err != nil { + return err + } if listEndpointsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listEndpointsLimit) } if listEndpointsLimit > 0 { ctx = cmdio.WithLimit(ctx, listEndpointsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Networking.ListEndpointsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, networking.EndpointFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/account/esm-enablement-account/esm-enablement-account.go b/cmd/account/esm-enablement-account/esm-enablement-account.go index 75af94183a2..a1d03872f6f 100644 --- a/cmd/account/esm-enablement-account/esm-enablement-account.go +++ b/cmd/account/esm-enablement-account/esm-enablement-account.go @@ -4,12 +4,15 @@ package esm_enablement_account import ( "errors" + "fmt" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" "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/settings" "github.com/spf13/cobra" ) @@ -53,15 +56,16 @@ The enhanced security monitoring setting at the account level controls whether // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetEsmEnablementAccountSettingRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetEsmEnablementAccountSettingRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `*Public Preview* Get the enhanced security monitoring setting for new workspaces.` @@ -84,12 +88,24 @@ Get the enhanced security monitoring setting for new workspaces. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/shield_esm_enablement_ac/names/default", a.Config.AccountID) - response, err := a.Settings.EsmEnablementAccount().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -111,13 +127,16 @@ Get the enhanced security monitoring setting for new workspaces. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateEsmEnablementAccountSettingRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateEsmEnablementAccountSettingRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -139,6 +158,7 @@ Update the enhanced security monitoring setting for new workspaces. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -155,11 +175,24 @@ Update the enhanced security monitoring setting for new workspaces. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.Settings.EsmEnablementAccount().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/shield_esm_enablement_ac/names/default", a.Config.AccountID) + + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/account/federation-policy/federation-policy.go b/cmd/account/federation-policy/federation-policy.go index f9ccb47c442..c0e0c5102b9 100644 --- a/cmd/account/federation-policy/federation-policy.go +++ b/cmd/account/federation-policy/federation-policy.go @@ -7,10 +7,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/oauth2" "github.com/spf13/cobra" + + authentication "github.com/databricks/cli/libs/sdktypes/authentication/v1" ) // Slice with functions to override default command behavior. @@ -99,20 +101,20 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *oauth2.CreateAccountFederationPolicyRequest, + *authentication.CreateAccountFederationPolicyRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq authentication.CreateAccountFederationPolicyRequest + createReq.Policy = &authentication.FederationPolicy{} - var createReq oauth2.CreateAccountFederationPolicyRequest - createReq.Policy = oauth2.FederationPolicy{} 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.PolicyId, "policy-id", createReq.PolicyId, `The identifier for the federation policy.`) - cmd.Flags().StringVar(&createReq.Policy.Description, "description", createReq.Policy.Description, `Description of the federation policy.`) + flags.StringPtrVar(cmd.Flags(), &createReq.PolicyId, "policy-id", `The identifier for the federation policy.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Policy.Description, "description", `Description of the federation policy.`) // TODO: complex arg: oidc_policy cmd.Use = "create" @@ -132,6 +134,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.Policy) @@ -146,12 +149,20 @@ func newCreate() *cobra.Command { } } - response, err := a.FederationPolicy.Create(ctx, createReq) + sdkReq, err := authentication.CreateAccountFederationPolicyRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Authentication.CreateAccountFederationPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := authentication.FederationPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -172,13 +183,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *oauth2.DeleteAccountFederationPolicyRequest, + *authentication.DeleteAccountFederationPolicyRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq oauth2.DeleteAccountFederationPolicyRequest + var deleteReq authentication.DeleteAccountFederationPolicyRequest cmd.Use = "delete POLICY_ID" cmd.Short = `Delete account federation policy.` @@ -200,10 +210,15 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.PolicyId = args[0] + deleteReq.PolicyId = new(args[0]) - err = a.FederationPolicy.Delete(ctx, deleteReq) + sdkReq, err := authentication.DeleteAccountFederationPolicyRequestToSDK(&deleteReq) + if err != nil { + return err + } + err = a.Authentication.DeleteAccountFederationPolicy(ctx, *sdkReq) if err != nil { return err } @@ -228,13 +243,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *oauth2.GetAccountFederationPolicyRequest, + *authentication.GetAccountFederationPolicyRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq oauth2.GetAccountFederationPolicyRequest + var getReq authentication.GetAccountFederationPolicyRequest cmd.Use = "get POLICY_ID" cmd.Short = `Get account federation policy.` @@ -256,15 +270,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.PolicyId = args[0] + getReq.PolicyId = new(args[0]) - response, err := a.FederationPolicy.Get(ctx, getReq) + sdkReq, err := authentication.GetAccountFederationPolicyRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := a.Authentication.GetAccountFederationPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := authentication.FederationPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -285,25 +308,25 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *oauth2.ListAccountFederationPoliciesRequest, + *authentication.ListAccountFederationPoliciesRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq authentication.ListAccountFederationPoliciesRequest - var listReq oauth2.ListAccountFederationPoliciesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -323,16 +346,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.FederationPolicy.List(ctx, listReq) + sdkReq, err := authentication.ListAccountFederationPoliciesRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Authentication.ListAccountFederationPoliciesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, authentication.FederationPolicyFromSDK)) } // Disable completions since they are not applicable. @@ -353,20 +380,20 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *oauth2.UpdateAccountFederationPolicyRequest, + *authentication.UpdateAccountFederationPolicyRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq authentication.UpdateAccountFederationPolicyRequest + updateReq.Policy = &authentication.FederationPolicy{} - var updateReq oauth2.UpdateAccountFederationPolicyRequest - updateReq.Policy = oauth2.FederationPolicy{} 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.UpdateMask, "update-mask", updateReq.UpdateMask, `The field mask specifies which fields of the policy to update.`) - cmd.Flags().StringVar(&updateReq.Policy.Description, "description", updateReq.Policy.Description, `Description of the federation policy.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.UpdateMask, "update-mask", `The field mask specifies which fields of the policy to update.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Policy.Description, "description", `Description of the federation policy.`) // TODO: complex arg: oidc_policy cmd.Use = "update POLICY_ID" @@ -389,6 +416,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.Policy) @@ -402,14 +430,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.PolicyId = args[0] + updateReq.PolicyId = new(args[0]) - response, err := a.FederationPolicy.Update(ctx, updateReq) + sdkReq, err := authentication.UpdateAccountFederationPolicyRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := a.Authentication.UpdateAccountFederationPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := authentication.FederationPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/groups-v2/groups-v2.go b/cmd/account/groups-v2/groups-v2.go index 63c47c53ee8..5eeaf6b2333 100644 --- a/cmd/account/groups-v2/groups-v2.go +++ b/cmd/account/groups-v2/groups-v2.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" + + scim "github.com/databricks/cli/libs/sdktypes/scim/v1" + sdkscim "github.com/databricks/sdk-go/scim/v1" ) // Slice with functions to override default command behavior. @@ -58,20 +61,20 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *iam.CreateAccountGroupRequest, + *scim.CreateAccountGroupRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq scim.CreateAccountGroupRequest - var createReq iam.CreateAccountGroupRequest 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.DisplayName, "display-name", createReq.DisplayName, `String that represents a human-readable group name.`) - cmd.Flags().StringVar(&createReq.ExternalId, "external-id", createReq.ExternalId, ``) - cmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Databricks group ID.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DisplayName, "display-name", `String that represents a human-readable group name.`) + flags.StringPtrVar(cmd.Flags(), &createReq.ExternalId, "external-id", ``) + flags.StringPtrVar(cmd.Flags(), &createReq.Id, "id", `Databricks group ID.`) // TODO: array: members // TODO: complex arg: meta // TODO: array: roles @@ -96,6 +99,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -110,12 +114,20 @@ func newCreate() *cobra.Command { } } - response, err := a.GroupsV2.Create(ctx, createReq) + sdkReq, err := scim.CreateAccountGroupRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Scim.CreateAccountGroup(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.AccountGroupFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -136,13 +148,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *iam.DeleteAccountGroupRequest, + *sdkscim.DeleteAccountGroupRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq iam.DeleteAccountGroupRequest + var deleteReq sdkscim.DeleteAccountGroupRequest cmd.Use = "delete ID" cmd.Short = `Delete a group.` @@ -166,10 +177,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = a.GroupsV2.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = a.Scim.DeleteAccountGroup(ctx, *sdkReq) if err != nil { return err } @@ -194,13 +207,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *iam.GetAccountGroupRequest, + *sdkscim.GetAccountGroupRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq iam.GetAccountGroupRequest + var getReq sdkscim.GetAccountGroupRequest cmd.Use = "get ID" cmd.Short = `Get group details.` @@ -224,15 +236,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := a.GroupsV2.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Scim.GetAccountGroup(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.AccountGroupFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -253,31 +271,31 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *iam.ListAccountGroupsRequest, + *scim.ListAccountGroupsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq scim.ListAccountGroupsRequest - var listReq iam.ListAccountGroupsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.Attributes, "attributes", listReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().StringVar(&listReq.ExcludedAttributes, "excluded-attributes", listReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&listReq.Filter, "filter", listReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&listReq.SortBy, "sort-by", listReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) + flags.StringPtrVar(cmd.Flags(), &listReq.Attributes, "attributes", `Comma-separated list of attributes to return in response.`) + flags.StringPtrVar(cmd.Flags(), &listReq.ExcludedAttributes, "excluded-attributes", `Comma-separated list of attributes to exclude in response.`) + flags.StringPtrVar(cmd.Flags(), &listReq.Filter, "filter", `Query by which the results have to be filtered.`) + flags.StringPtrVar(cmd.Flags(), &listReq.SortBy, "sort-by", `Attribute to sort the results.`) + flags.EnumVar(cmd.Flags(), &listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`, "ListSortOrder", "ascending", "descending") // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().Int64Var(&listReq.StartIndex, "start-index", listReq.StartIndex, `Specifies the index of the first result.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.StartIndex, "start-index", `Specifies the index of the first result.`) cmd.Flags().Lookup("start-index").Hidden = true - cmd.Flags().Int64Var(&listReq.Count, "count", listReq.Count, `Number of results per API page.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.Count, "count", `Number of results per API page.`) cmd.Flags().Lookup("count").Hidden = true cmd.Use = "list" @@ -303,16 +321,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.GroupsV2.List(ctx, listReq) + sdkReq, err := scim.ListAccountGroupsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Scim.ListAccountGroupsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, scim.AccountGroupFromSDK)) } // Disable completions since they are not applicable. @@ -333,13 +355,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var patchOverrides []func( *cobra.Command, - *iam.PatchAccountGroupRequest, + *scim.PatchAccountGroupRequest, ) func newPatch() *cobra.Command { cmd := &cobra.Command{} + var patchReq scim.PatchAccountGroupRequest - var patchReq iam.PatchAccountGroupRequest var patchJson flags.JsonFlag cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -369,6 +391,7 @@ func newPatch() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -382,9 +405,13 @@ func newPatch() *cobra.Command { } } } - patchReq.Id = args[0] + patchReq.Id = new(args[0]) - err = a.GroupsV2.Patch(ctx, patchReq) + sdkReq, err := scim.PatchAccountGroupRequestToSDK(&patchReq) + if err != nil { + return err + } + err = a.Scim.PatchAccountGroup(ctx, *sdkReq) if err != nil { return err } @@ -409,19 +436,19 @@ func newPatch() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *iam.UpdateAccountGroupRequest, + *scim.UpdateAccountGroupRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq scim.UpdateAccountGroupRequest - var updateReq iam.UpdateAccountGroupRequest 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.DisplayName, "display-name", updateReq.DisplayName, `String that represents a human-readable group name.`) - cmd.Flags().StringVar(&updateReq.ExternalId, "external-id", updateReq.ExternalId, ``) + flags.StringPtrVar(cmd.Flags(), &updateReq.DisplayName, "display-name", `String that represents a human-readable group name.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.ExternalId, "external-id", ``) // TODO: array: members // TODO: complex arg: meta // TODO: array: roles @@ -448,6 +475,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -461,9 +489,13 @@ func newUpdate() *cobra.Command { } } } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - err = a.GroupsV2.Update(ctx, updateReq) + sdkReq, err := scim.UpdateAccountGroupRequestToSDK(&updateReq) + if err != nil { + return err + } + err = a.Scim.UpdateAccountGroup(ctx, *sdkReq) if err != nil { return err } diff --git a/cmd/account/groups/groups.go b/cmd/account/groups/groups.go index 9f2a4e89dfd..edbf91c3dfd 100755 --- a/cmd/account/groups/groups.go +++ b/cmd/account/groups/groups.go @@ -2,17 +2,11 @@ // but are now manually maintained because the v2 API versions have taken // over as the generated commands. See https://github.com/databricks/cli/pull/4722. -//nolint:staticcheck,perfsprint package groups import ( - "fmt" - + groups_v2 "github.com/databricks/cli/cmd/account/groups-v2" "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/iam" "github.com/spf13/cobra" ) @@ -20,6 +14,11 @@ import ( // Functions can be added from the `init()` function in manually curated files in this directory. var cmdOverrides []func(*cobra.Command) +// Slices with functions to override the behavior of individual commands. +var listOverrides []func(*cobra.Command) + +// The commands are the groups-v2 commands (same API) presented under their +// original names and help text. func New() *cobra.Command { cmd := &cobra.Command{ Use: "groups", @@ -38,471 +37,102 @@ func New() *cobra.Command { RunE: root.ReportUnknownSubcommand, } - // Add methods - cmd.AddCommand(newCreate()) - cmd.AddCommand(newDelete()) - cmd.AddCommand(newGet()) - cmd.AddCommand(newList()) - cmd.AddCommand(newPatch()) - 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, - *iam.Group, -) - -func newCreate() *cobra.Command { - cmd := &cobra.Command{} - - var createReq iam.Group - 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.DisplayName, "display-name", createReq.DisplayName, `String that represents a human-readable group name.`) - // TODO: array: entitlements - cmd.Flags().StringVar(&createReq.ExternalId, "external-id", createReq.ExternalId, ``) - // TODO: array: groups - cmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Databricks group ID.`) - // TODO: array: members - // TODO: complex arg: meta - // TODO: array: roles - // TODO: array: schemas - - cmd.Use = "create" - cmd.Short = `Create a new group.` - cmd.Long = `Create a new group. - - Creates a group in the Databricks account with a unique name, using the - supplied group details.` - - cmd.Annotations = make(map[string]string) - - cmd.Args = func(cmd *cobra.Command, args []string) error { - check := root.ExactArgs(0) - return check(cmd, args) - } - - cmd.PreRunE = root.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - if cmd.Flags().Changed("json") { - diags := createJson.Unmarshal(&createReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err + v2 := groups_v2.New() + for _, sub := range v2.Commands() { + doc, ok := commandDocs[sub.Name()] + if !ok { + continue + } + v2.RemoveCommand(sub) + sub.Use = doc.use + if doc.short != "" { + sub.Short = doc.short + sub.Long = doc.long + } + sub.Hidden = doc.hidden + if sub.Name() == "list" { + // These were regular flags of the original commands. + for _, name := range []string{"count", "start-index"} { + if f := sub.Flags().Lookup(name); f != nil { + f.Hidden = false } } + for _, fn := range listOverrides { + fn(sub) + } } - - response, err := a.Groups.Create(ctx, createReq) - if err != nil { - return err - } - return cmdio.Render(ctx, response) + cmd.AddCommand(sub) } - // 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) + for _, fn := range cmdOverrides { + fn(cmd) } 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, - *iam.DeleteAccountGroupRequest, -) - -func newDelete() *cobra.Command { - cmd := &cobra.Command{} +type commandDoc struct { + use, short, long string + hidden bool +} - var deleteReq iam.DeleteAccountGroupRequest +var commandDocs = map[string]commandDoc{ + "create": { + use: "create", + short: `Create a new group.`, + long: `Create a new group. - cmd.Use = "delete ID" - cmd.Short = `Delete a group.` - cmd.Long = `Delete a group. + Creates a group in the Databricks account with a unique name, using the + supplied group details.`, + }, + "delete": { + use: "delete ID", + short: `Delete a group.`, + long: `Delete a group. Deletes a group from the Databricks account. Arguments: - ID: Unique ID for a group in the Databricks account.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Account Groups drop-down.") - names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID for a group in the Databricks account") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id for a group in the databricks account") - } - deleteReq.Id = args[0] - - err = a.Groups.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, - *iam.GetAccountGroupRequest, -) - -func newGet() *cobra.Command { - cmd := &cobra.Command{} - - var getReq iam.GetAccountGroupRequest - - cmd.Use = "get ID" - cmd.Short = `Get group details.` - cmd.Long = `Get group details. + ID: Unique ID for a group in the Databricks account.`, + }, + "get": { + use: "get ID", + short: `Get group details.`, + long: `Get group details. Gets the information for a specific group in the Databricks account. Arguments: - ID: Unique ID for a group in the Databricks account.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Account Groups drop-down.") - names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID for a group in the Databricks account") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id for a group in the databricks account") - } - getReq.Id = args[0] - - response, err := a.Groups.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, - *iam.ListAccountGroupsRequest, -) - -func newList() *cobra.Command { - cmd := &cobra.Command{} - - var listReq iam.ListAccountGroupsRequest - - cmd.Flags().StringVar(&listReq.Attributes, "attributes", listReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().Int64Var(&listReq.Count, "count", listReq.Count, `Desired number of results per page.`) - cmd.Flags().StringVar(&listReq.ExcludedAttributes, "excluded-attributes", listReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&listReq.Filter, "filter", listReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&listReq.SortBy, "sort-by", listReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) - cmd.Flags().Int64Var(&listReq.StartIndex, "start-index", listReq.StartIndex, `Specifies the index of the first result.`) - - cmd.Use = "list" - cmd.Short = `List group details.` - cmd.Long = `List group details. + ID: Unique ID for a group in the Databricks account.`, + }, + "list": { + use: "list", + short: `List group details.`, + long: `List group details. Gets all details of the groups associated with the Databricks account. As of 08/22/2025, this endpoint will not return members. Instead, members should be - retrieved by iterating through Get group details.` - - 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.Groups.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 patch 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 patchOverrides []func( - *cobra.Command, - *iam.PartialUpdate, -) - -func newPatch() *cobra.Command { - cmd := &cobra.Command{} - - var patchReq iam.PartialUpdate - var patchJson flags.JsonFlag - - cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - // TODO: array: Operations - // TODO: array: schemas - - cmd.Use = "patch ID" - cmd.Short = `Update group details.` - cmd.Long = `Update group details. + retrieved by iterating through Get group details.`, + }, + "patch": { + use: "patch ID", + short: `Update group details.`, + long: `Update group details. Partially updates the details of a group. Arguments: - ID: Unique ID in the Databricks workspace.` - - cmd.Annotations = make(map[string]string) - - 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 := patchJson.Unmarshal(&patchReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Account Groups drop-down.") - names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID in the Databricks workspace") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id in the databricks workspace") - } - patchReq.Id = args[0] - - err = a.Groups.Patch(ctx, patchReq) - 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 patchOverrides { - fn(cmd, &patchReq) - } - - 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, - *iam.Group, -) - -func newUpdate() *cobra.Command { - cmd := &cobra.Command{} - - var updateReq iam.Group - 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.DisplayName, "display-name", updateReq.DisplayName, `String that represents a human-readable group name.`) - // TODO: array: entitlements - cmd.Flags().StringVar(&updateReq.ExternalId, "external-id", updateReq.ExternalId, ``) - // TODO: array: groups - cmd.Flags().StringVar(&updateReq.Id, "id", updateReq.Id, `Databricks group ID.`) - // TODO: array: members - // TODO: complex arg: meta - // TODO: array: roles - // TODO: array: schemas - - cmd.Use = "update ID" - cmd.Short = `Replace a group.` - cmd.Long = `Replace a group. + ID: Unique ID in the Databricks workspace.`, + }, + "update": { + use: "update ID", + short: `Replace a group.`, + long: `Replace a group. Updates the details of a group by replacing the entire group entity. Arguments: - ID: Databricks group ID` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - if cmd.Flags().Changed("json") { - diags := updateJson.Unmarshal(&updateReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Account Groups drop-down.") - names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks group ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks group id") - } - updateReq.Id = args[0] - - err = a.Groups.Update(ctx, updateReq) - 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 updateOverrides { - fn(cmd, &updateReq) - } - - return cmd + ID: Databricks group ID`, + }, } - -// end service AccountGroups diff --git a/cmd/account/groups/overrides.go b/cmd/account/groups/overrides.go index 37d05c64f93..2ec551b0034 100644 --- a/cmd/account/groups/overrides.go +++ b/cmd/account/groups/overrides.go @@ -2,12 +2,12 @@ package groups import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *iam.ListAccountGroupsRequest) { - listReq.Attributes = "id,displayName" +func listOverride(listCmd *cobra.Command) { + // Request only the columns the template shows unless --attributes is given. + _ = listCmd.Flags().Lookup("attributes").Value.Set("id,displayName") listCmd.Annotations["template"] = cmdio.Heredoc(` {{range .}}{{.Id|green}} {{.DisplayName}} {{end}}`) diff --git a/cmd/account/iam-v2/iam-v2.go b/cmd/account/iam-v2/iam-v2.go index cfee439a56a..f29542d59da 100644 --- a/cmd/account/iam-v2/iam-v2.go +++ b/cmd/account/iam-v2/iam-v2.go @@ -5,14 +5,14 @@ package iam_v2 import ( "errors" "fmt" - "strings" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" "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/iamv2" "github.com/spf13/cobra" ) @@ -93,14 +93,20 @@ These APIs are used to manage identities and the workspace access of these // Functions can be added from the `init()` function in manually curated files in this directory. var createDirectGroupMemberOverrides []func( *cobra.Command, - *iamv2.CreateDirectGroupMemberRequest, + *map[string]any, ) func newCreateDirectGroupMember() *cobra.Command { cmd := &cobra.Command{} + var createDirectGroupMemberReq map[string]any + createDirectGroupMemberReq = map[string]any{} + var createDirectGroupMemberGroupIdRaw int64 + var createDirectGroupMemberDisplayNameRaw string + var createDirectGroupMemberExternalIdRaw string + var createDirectGroupMemberMembershipSourceRaw string + var createDirectGroupMemberPrincipalIdRaw int64 + var createDirectGroupMemberPrincipalTypeRaw string - var createDirectGroupMemberReq iamv2.CreateDirectGroupMemberRequest - createDirectGroupMemberReq.DirectGroupMember = iamv2.DirectGroupMember{} var createDirectGroupMemberJson flags.JsonFlag cmd.Flags().Var(&createDirectGroupMemberJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -140,9 +146,10 @@ Create a direct group membership. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := createDirectGroupMemberJson.Unmarshal(&createDirectGroupMemberReq.DirectGroupMember) + diags := createDirectGroupMemberJson.Unmarshal(&createDirectGroupMemberReq) if diags.HasError() { return diags.Error() } @@ -153,24 +160,47 @@ Create a direct group membership. } } } - _, err = fmt.Sscan(args[0], &createDirectGroupMemberReq.GroupId) + _, err = fmt.Sscan(args[0], &createDirectGroupMemberGroupIdRaw) if err != nil { return fmt.Errorf("invalid GROUP_ID: %s", args[0]) } - if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createDirectGroupMemberReq.DirectGroupMember.PrincipalId) + _, err = fmt.Sscan(args[1], &createDirectGroupMemberPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("display-name") || createDirectGroupMemberDisplayNameRaw != "" { + createDirectGroupMemberReq["display_name"] = createDirectGroupMemberDisplayNameRaw + } + if cmd.Flags().Changed("external-id") || createDirectGroupMemberExternalIdRaw != "" { + createDirectGroupMemberReq["external_id"] = createDirectGroupMemberExternalIdRaw + } + if cmd.Flags().Changed("group-id") || createDirectGroupMemberGroupIdRaw != 0 { + createDirectGroupMemberReq["group_id"] = createDirectGroupMemberGroupIdRaw + } + if cmd.Flags().Changed("membership-source") || createDirectGroupMemberMembershipSourceRaw != "" { + createDirectGroupMemberReq["membership_source"] = createDirectGroupMemberMembershipSourceRaw } + if cmd.Flags().Changed("principal-id") || createDirectGroupMemberPrincipalIdRaw != 0 { + createDirectGroupMemberReq["principal_id"] = createDirectGroupMemberPrincipalIdRaw + } + if cmd.Flags().Changed("principal-type") || createDirectGroupMemberPrincipalTypeRaw != "" { + createDirectGroupMemberReq["principal_type"] = createDirectGroupMemberPrincipalTypeRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/groups/%s/direct-members", a.Config.AccountID, fmt.Sprint(createDirectGroupMemberGroupIdRaw)) - response, err := a.IamV2.CreateDirectGroupMember(ctx, createDirectGroupMemberReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, nil, rawQuery, createDirectGroupMemberReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -192,20 +222,24 @@ Create a direct group membership. // Functions can be added from the `init()` function in manually curated files in this directory. var createGroupOverrides []func( *cobra.Command, - *iamv2.CreateGroupRequest, + *map[string]any, ) func newCreateGroup() *cobra.Command { cmd := &cobra.Command{} + var createGroupReq map[string]any + createGroupReq = map[string]any{} + var createGroupAccountIdRaw string + var createGroupExternalIdRaw string + var createGroupGroupIdRaw string + var createGroupGroupNameRaw string - var createGroupReq iamv2.CreateGroupRequest - createGroupReq.Group = iamv2.Group{} var createGroupJson flags.JsonFlag cmd.Flags().Var(&createGroupJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createGroupReq.Group.ExternalId, "external-id", createGroupReq.Group.ExternalId, `ExternalId of the group in the customer's IdP.`) - cmd.Flags().StringVar(&createGroupReq.Group.GroupName, "group-name", createGroupReq.Group.GroupName, `Display name of the group.`) + cmd.Flags().StringVar(&createGroupExternalIdRaw, "external-id", createGroupExternalIdRaw, `ExternalId of the group in the customer's IdP.`) + cmd.Flags().StringVar(&createGroupGroupNameRaw, "group-name", createGroupGroupNameRaw, `Display name of the group.`) cmd.Use = "create-group" cmd.Short = `*Beta* Create a group in the account.` @@ -236,9 +270,10 @@ Create a group in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := createGroupJson.Unmarshal(&createGroupReq.Group) + diags := createGroupJson.Unmarshal(&createGroupReq) if diags.HasError() { return diags.Error() } @@ -250,11 +285,30 @@ Create a group in the account. } } - response, err := a.IamV2.CreateGroup(ctx, createGroupReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || createGroupAccountIdRaw != "" { + createGroupReq["account_id"] = createGroupAccountIdRaw + } + if cmd.Flags().Changed("external-id") || createGroupExternalIdRaw != "" { + createGroupReq["external_id"] = createGroupExternalIdRaw + } + if cmd.Flags().Changed("group-id") || createGroupGroupIdRaw != "" { + createGroupReq["group_id"] = createGroupGroupIdRaw + } + if cmd.Flags().Changed("group-name") || createGroupGroupNameRaw != "" { + createGroupReq["group_name"] = createGroupGroupNameRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/groups", a.Config.AccountID) + + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, nil, rawQuery, createGroupReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -276,19 +330,23 @@ Create a group in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var createIdentityVisibilityFilterOverrides []func( *cobra.Command, - *iamv2.CreateIdentityVisibilityFilterRequest, + *map[string]any, ) func newCreateIdentityVisibilityFilter() *cobra.Command { cmd := &cobra.Command{} + var createIdentityVisibilityFilterReq map[string]any + createIdentityVisibilityFilterReq = map[string]any{} + var createIdentityVisibilityFilterIdentityVisibilityFilterIdRaw string + var createIdentityVisibilityFilterParentRaw string + var createIdentityVisibilityFilterNameRaw string + var createIdentityVisibilityFilterPrincipalTypeRaw string - var createIdentityVisibilityFilterReq iamv2.CreateIdentityVisibilityFilterRequest - createIdentityVisibilityFilterReq.IdentityVisibilityFilter = iamv2.IdentityVisibilityFilter{} var createIdentityVisibilityFilterJson flags.JsonFlag cmd.Flags().Var(&createIdentityVisibilityFilterJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createIdentityVisibilityFilterReq.IdentityVisibilityFilterId, "identity-visibility-filter-id", createIdentityVisibilityFilterReq.IdentityVisibilityFilterId, `Optional.`) + cmd.Flags().StringVar(&createIdentityVisibilityFilterIdentityVisibilityFilterIdRaw, "identity-visibility-filter-id", createIdentityVisibilityFilterIdentityVisibilityFilterIdRaw, `Optional.`) // TODO: complex arg: exact // TODO: complex arg: prefix @@ -327,9 +385,10 @@ func newCreateIdentityVisibilityFilter() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := createIdentityVisibilityFilterJson.Unmarshal(&createIdentityVisibilityFilterReq.IdentityVisibilityFilter) + diags := createIdentityVisibilityFilterJson.Unmarshal(&createIdentityVisibilityFilterReq) if diags.HasError() { return diags.Error() } @@ -340,20 +399,32 @@ func newCreateIdentityVisibilityFilter() *cobra.Command { } } } - createIdentityVisibilityFilterReq.Parent = args[0] + createIdentityVisibilityFilterParentRaw = args[0] if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createIdentityVisibilityFilterReq.IdentityVisibilityFilter.PrincipalType) - if err != nil { - return fmt.Errorf("invalid PRINCIPAL_TYPE: %s", args[1]) - } + createIdentityVisibilityFilterPrincipalTypeRaw = args[1] + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("identity-visibility-filter-id") || createIdentityVisibilityFilterIdentityVisibilityFilterIdRaw != "" { + rawQuery["identity_visibility_filter_id"] = createIdentityVisibilityFilterIdentityVisibilityFilterIdRaw + } + if cmd.Flags().Changed("name") || createIdentityVisibilityFilterNameRaw != "" { + createIdentityVisibilityFilterReq["name"] = createIdentityVisibilityFilterNameRaw + } + if cmd.Flags().Changed("principal-type") || createIdentityVisibilityFilterPrincipalTypeRaw != "" { + createIdentityVisibilityFilterReq["principal_type"] = createIdentityVisibilityFilterPrincipalTypeRaw } + rawPath := fmt.Sprintf("/api/2.0/identity/%s/identity-visibility-filters", fmt.Sprint(createIdentityVisibilityFilterParentRaw)) - response, err := a.IamV2.CreateIdentityVisibilityFilter(ctx, createIdentityVisibilityFilterReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, nil, rawQuery, createIdentityVisibilityFilterReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -375,19 +446,25 @@ func newCreateIdentityVisibilityFilter() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createServicePrincipalOverrides []func( *cobra.Command, - *iamv2.CreateServicePrincipalRequest, + *map[string]any, ) func newCreateServicePrincipal() *cobra.Command { cmd := &cobra.Command{} + var createServicePrincipalReq map[string]any + createServicePrincipalReq = map[string]any{} + var createServicePrincipalAccountIdRaw string + var createServicePrincipalAccountSpStatusRaw string + var createServicePrincipalApplicationIdRaw string + var createServicePrincipalDisplayNameRaw string + var createServicePrincipalExternalIdRaw string + var createServicePrincipalServicePrincipalIdRaw string - var createServicePrincipalReq iamv2.CreateServicePrincipalRequest - createServicePrincipalReq.ServicePrincipal = iamv2.ServicePrincipal{} var createServicePrincipalJson flags.JsonFlag cmd.Flags().Var(&createServicePrincipalJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createServicePrincipalReq.ServicePrincipal.ExternalId, "external-id", createServicePrincipalReq.ServicePrincipal.ExternalId, `ExternalId of the service principal in the customer's IdP.`) + cmd.Flags().StringVar(&createServicePrincipalExternalIdRaw, "external-id", createServicePrincipalExternalIdRaw, `ExternalId of the service principal in the customer's IdP.`) cmd.Use = "create-service-principal DISPLAY_NAME ACCOUNT_SP_STATUS" cmd.Short = `*Beta* Create a service principal in the account.` @@ -430,9 +507,10 @@ Create a service principal in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := createServicePrincipalJson.Unmarshal(&createServicePrincipalReq.ServicePrincipal) + diags := createServicePrincipalJson.Unmarshal(&createServicePrincipalReq) if diags.HasError() { return diags.Error() } @@ -444,21 +522,42 @@ Create a service principal in the account. } } if !cmd.Flags().Changed("json") { - createServicePrincipalReq.ServicePrincipal.DisplayName = args[0] + createServicePrincipalDisplayNameRaw = args[0] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createServicePrincipalReq.ServicePrincipal.AccountSpStatus) - if err != nil { - return fmt.Errorf("invalid ACCOUNT_SP_STATUS: %s", args[1]) - } + createServicePrincipalAccountSpStatusRaw = args[1] + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || createServicePrincipalAccountIdRaw != "" { + createServicePrincipalReq["account_id"] = createServicePrincipalAccountIdRaw + } + if cmd.Flags().Changed("account-sp-status") || createServicePrincipalAccountSpStatusRaw != "" { + createServicePrincipalReq["account_sp_status"] = createServicePrincipalAccountSpStatusRaw } + if cmd.Flags().Changed("application-id") || createServicePrincipalApplicationIdRaw != "" { + createServicePrincipalReq["application_id"] = createServicePrincipalApplicationIdRaw + } + if cmd.Flags().Changed("display-name") || createServicePrincipalDisplayNameRaw != "" { + createServicePrincipalReq["display_name"] = createServicePrincipalDisplayNameRaw + } + if cmd.Flags().Changed("external-id") || createServicePrincipalExternalIdRaw != "" { + createServicePrincipalReq["external_id"] = createServicePrincipalExternalIdRaw + } + if cmd.Flags().Changed("service-principal-id") || createServicePrincipalServicePrincipalIdRaw != "" { + createServicePrincipalReq["service_principal_id"] = createServicePrincipalServicePrincipalIdRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/service-principals", a.Config.AccountID) - response, err := a.IamV2.CreateServicePrincipal(ctx, createServicePrincipalReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, nil, rawQuery, createServicePrincipalReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -480,19 +579,24 @@ Create a service principal in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var createUserOverrides []func( *cobra.Command, - *iamv2.CreateUserRequest, + *map[string]any, ) func newCreateUser() *cobra.Command { cmd := &cobra.Command{} + var createUserReq map[string]any + createUserReq = map[string]any{} + var createUserAccountIdRaw string + var createUserAccountUserStatusRaw string + var createUserExternalIdRaw string + var createUserUserIdRaw string + var createUserUsernameRaw string - var createUserReq iamv2.CreateUserRequest - createUserReq.User = iamv2.User{} var createUserJson flags.JsonFlag cmd.Flags().Var(&createUserJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createUserReq.User.ExternalId, "external-id", createUserReq.User.ExternalId, `ExternalId of the user in the customer's IdP.`) + cmd.Flags().StringVar(&createUserExternalIdRaw, "external-id", createUserExternalIdRaw, `ExternalId of the user in the customer's IdP.`) cmd.Use = "create-user USERNAME FULL_NAME ACCOUNT_USER_STATUS" cmd.Short = `*Beta* Create a user in the account.` @@ -536,9 +640,10 @@ Create a user in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := createUserJson.Unmarshal(&createUserReq.User) + diags := createUserJson.Unmarshal(&createUserReq) if diags.HasError() { return diags.Error() } @@ -550,28 +655,42 @@ Create a user in the account. } } if !cmd.Flags().Changed("json") { - createUserReq.User.Username = args[0] + createUserUsernameRaw = args[0] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createUserReq.User.FullName) - if err != nil { - return fmt.Errorf("invalid FULL_NAME: %s", args[1]) - } - + createUserReq["full_name"] = args[1] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &createUserReq.User.AccountUserStatus) - if err != nil { - return fmt.Errorf("invalid ACCOUNT_USER_STATUS: %s", args[2]) - } + createUserAccountUserStatusRaw = args[2] + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || createUserAccountIdRaw != "" { + createUserReq["account_id"] = createUserAccountIdRaw + } + if cmd.Flags().Changed("account-user-status") || createUserAccountUserStatusRaw != "" { + createUserReq["account_user_status"] = createUserAccountUserStatusRaw + } + if cmd.Flags().Changed("external-id") || createUserExternalIdRaw != "" { + createUserReq["external_id"] = createUserExternalIdRaw + } + if cmd.Flags().Changed("user-id") || createUserUserIdRaw != "" { + createUserReq["user_id"] = createUserUserIdRaw } + if cmd.Flags().Changed("username") || createUserUsernameRaw != "" { + createUserReq["username"] = createUserUsernameRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/users", a.Config.AccountID) - response, err := a.IamV2.CreateUser(ctx, createUserReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, nil, rawQuery, createUserReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -593,14 +712,18 @@ Create a user in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var createWorkspaceAssignmentOverrides []func( *cobra.Command, - *iamv2.CreateWorkspaceAssignmentRequest, + *map[string]any, ) func newCreateWorkspaceAssignment() *cobra.Command { cmd := &cobra.Command{} + var createWorkspaceAssignmentReq map[string]any + createWorkspaceAssignmentReq = map[string]any{} + var createWorkspaceAssignmentWorkspaceIdRaw int64 + var createWorkspaceAssignmentAccountIdRaw string + var createWorkspaceAssignmentPrincipalIdRaw int64 + var createWorkspaceAssignmentPrincipalTypeRaw string - var createWorkspaceAssignmentReq iamv2.CreateWorkspaceAssignmentRequest - createWorkspaceAssignmentReq.WorkspaceAssignment = iamv2.WorkspaceAssignment{} var createWorkspaceAssignmentJson flags.JsonFlag cmd.Flags().Var(&createWorkspaceAssignmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -645,9 +768,10 @@ Create a workspace assignment. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := createWorkspaceAssignmentJson.Unmarshal(&createWorkspaceAssignmentReq.WorkspaceAssignment) + diags := createWorkspaceAssignmentJson.Unmarshal(&createWorkspaceAssignmentReq) if diags.HasError() { return diags.Error() } @@ -658,24 +782,41 @@ Create a workspace assignment. } } } - _, err = fmt.Sscan(args[0], &createWorkspaceAssignmentReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &createWorkspaceAssignmentWorkspaceIdRaw) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createWorkspaceAssignmentReq.WorkspaceAssignment.PrincipalId) + _, err = fmt.Sscan(args[1], &createWorkspaceAssignmentPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || createWorkspaceAssignmentAccountIdRaw != "" { + createWorkspaceAssignmentReq["account_id"] = createWorkspaceAssignmentAccountIdRaw + } + if cmd.Flags().Changed("principal-id") || createWorkspaceAssignmentPrincipalIdRaw != 0 { + createWorkspaceAssignmentReq["principal_id"] = createWorkspaceAssignmentPrincipalIdRaw } + if cmd.Flags().Changed("principal-type") || createWorkspaceAssignmentPrincipalTypeRaw != "" { + createWorkspaceAssignmentReq["principal_type"] = createWorkspaceAssignmentPrincipalTypeRaw + } + if cmd.Flags().Changed("workspace-id") || createWorkspaceAssignmentWorkspaceIdRaw != 0 { + createWorkspaceAssignmentReq["workspace_id"] = createWorkspaceAssignmentWorkspaceIdRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/workspaces/%s/workspace-assignments", a.Config.AccountID, fmt.Sprint(createWorkspaceAssignmentWorkspaceIdRaw)) - response, err := a.IamV2.CreateWorkspaceAssignment(ctx, createWorkspaceAssignmentReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, nil, rawQuery, createWorkspaceAssignmentReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -697,14 +838,18 @@ Create a workspace assignment. // Functions can be added from the `init()` function in manually curated files in this directory. var createWorkspaceAssignmentDetailOverrides []func( *cobra.Command, - *iamv2.CreateWorkspaceAssignmentDetailRequest, + *map[string]any, ) func newCreateWorkspaceAssignmentDetail() *cobra.Command { cmd := &cobra.Command{} + var createWorkspaceAssignmentDetailReq map[string]any + createWorkspaceAssignmentDetailReq = map[string]any{} + var createWorkspaceAssignmentDetailWorkspaceIdRaw int64 + var createWorkspaceAssignmentDetailAccountIdRaw string + var createWorkspaceAssignmentDetailPrincipalIdRaw int64 + var createWorkspaceAssignmentDetailPrincipalTypeRaw string - var createWorkspaceAssignmentDetailReq iamv2.CreateWorkspaceAssignmentDetailRequest - createWorkspaceAssignmentDetailReq.WorkspaceAssignmentDetail = iamv2.WorkspaceAssignmentDetail{} var createWorkspaceAssignmentDetailJson flags.JsonFlag cmd.Flags().Var(&createWorkspaceAssignmentDetailJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -746,9 +891,10 @@ func newCreateWorkspaceAssignmentDetail() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := createWorkspaceAssignmentDetailJson.Unmarshal(&createWorkspaceAssignmentDetailReq.WorkspaceAssignmentDetail) + diags := createWorkspaceAssignmentDetailJson.Unmarshal(&createWorkspaceAssignmentDetailReq) if diags.HasError() { return diags.Error() } @@ -759,24 +905,41 @@ func newCreateWorkspaceAssignmentDetail() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &createWorkspaceAssignmentDetailReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &createWorkspaceAssignmentDetailWorkspaceIdRaw) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createWorkspaceAssignmentDetailReq.WorkspaceAssignmentDetail.PrincipalId) + _, err = fmt.Sscan(args[1], &createWorkspaceAssignmentDetailPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || createWorkspaceAssignmentDetailAccountIdRaw != "" { + createWorkspaceAssignmentDetailReq["account_id"] = createWorkspaceAssignmentDetailAccountIdRaw } + if cmd.Flags().Changed("principal-id") || createWorkspaceAssignmentDetailPrincipalIdRaw != 0 { + createWorkspaceAssignmentDetailReq["principal_id"] = createWorkspaceAssignmentDetailPrincipalIdRaw + } + if cmd.Flags().Changed("principal-type") || createWorkspaceAssignmentDetailPrincipalTypeRaw != "" { + createWorkspaceAssignmentDetailReq["principal_type"] = createWorkspaceAssignmentDetailPrincipalTypeRaw + } + if cmd.Flags().Changed("workspace-id") || createWorkspaceAssignmentDetailWorkspaceIdRaw != 0 { + createWorkspaceAssignmentDetailReq["workspace_id"] = createWorkspaceAssignmentDetailWorkspaceIdRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/workspaces/%s/workspace-assignment-details", a.Config.AccountID, fmt.Sprint(createWorkspaceAssignmentDetailWorkspaceIdRaw)) - response, err := a.IamV2.CreateWorkspaceAssignmentDetail(ctx, createWorkspaceAssignmentDetailReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, nil, rawQuery, createWorkspaceAssignmentDetailReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -798,13 +961,15 @@ func newCreateWorkspaceAssignmentDetail() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteDirectGroupMemberOverrides []func( *cobra.Command, - *iamv2.DeleteDirectGroupMemberRequest, + *map[string]any, ) func newDeleteDirectGroupMember() *cobra.Command { cmd := &cobra.Command{} - - var deleteDirectGroupMemberReq iamv2.DeleteDirectGroupMemberRequest + var deleteDirectGroupMemberReq map[string]any + deleteDirectGroupMemberReq = map[string]any{} + var deleteDirectGroupMemberGroupIdRaw int64 + var deleteDirectGroupMemberPrincipalIdRaw int64 cmd.Use = "delete-direct-group-member GROUP_ID PRINCIPAL_ID" cmd.Short = `*Beta* Delete a direct group membership.` @@ -834,18 +999,26 @@ Delete a direct group membership. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &deleteDirectGroupMemberReq.GroupId) + _, err = fmt.Sscan(args[0], &deleteDirectGroupMemberGroupIdRaw) if err != nil { return fmt.Errorf("invalid GROUP_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &deleteDirectGroupMemberReq.PrincipalId) + _, err = fmt.Sscan(args[1], &deleteDirectGroupMemberPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } - err = a.IamV2.DeleteDirectGroupMember(ctx, deleteDirectGroupMemberReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/groups/%s/direct-members/%s", a.Config.AccountID, fmt.Sprint(deleteDirectGroupMemberGroupIdRaw), fmt.Sprint(deleteDirectGroupMemberPrincipalIdRaw)) + + maps.Copy(rawQuery, deleteDirectGroupMemberReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, nil, rawQuery, nil, nil) if err != nil { return err } @@ -870,13 +1043,14 @@ Delete a direct group membership. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteGroupOverrides []func( *cobra.Command, - *iamv2.DeleteGroupRequest, + *map[string]any, ) func newDeleteGroup() *cobra.Command { cmd := &cobra.Command{} - - var deleteGroupReq iamv2.DeleteGroupRequest + var deleteGroupReq map[string]any + deleteGroupReq = map[string]any{} + var deleteGroupGroupIdRaw string cmd.Use = "delete-group GROUP_ID" cmd.Short = `*Beta* Delete a group in the account.` @@ -905,10 +1079,19 @@ Delete a group in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteGroupReq.GroupId = args[0] + deleteGroupGroupIdRaw = args[0] - err = a.IamV2.DeleteGroup(ctx, deleteGroupReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/groups/%s", a.Config.AccountID, fmt.Sprint(deleteGroupGroupIdRaw)) + + maps.Copy(rawQuery, deleteGroupReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, nil, rawQuery, nil, nil) if err != nil { return err } @@ -933,13 +1116,14 @@ Delete a group in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteIdentityVisibilityFilterOverrides []func( *cobra.Command, - *iamv2.DeleteIdentityVisibilityFilterRequest, + *map[string]any, ) func newDeleteIdentityVisibilityFilter() *cobra.Command { cmd := &cobra.Command{} - - var deleteIdentityVisibilityFilterReq iamv2.DeleteIdentityVisibilityFilterRequest + var deleteIdentityVisibilityFilterReq map[string]any + deleteIdentityVisibilityFilterReq = map[string]any{} + var deleteIdentityVisibilityFilterNameRaw string cmd.Use = "delete-identity-visibility-filter NAME" cmd.Short = `Delete an identity-visibility filter.` @@ -967,10 +1151,19 @@ func newDeleteIdentityVisibilityFilter() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + deleteIdentityVisibilityFilterNameRaw = args[0] - deleteIdentityVisibilityFilterReq.Name = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/%s", fmt.Sprint(deleteIdentityVisibilityFilterNameRaw)) - err = a.IamV2.DeleteIdentityVisibilityFilter(ctx, deleteIdentityVisibilityFilterReq) + maps.Copy(rawQuery, deleteIdentityVisibilityFilterReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, nil, rawQuery, nil, nil) if err != nil { return err } @@ -995,13 +1188,14 @@ func newDeleteIdentityVisibilityFilter() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteServicePrincipalOverrides []func( *cobra.Command, - *iamv2.DeleteServicePrincipalRequest, + *map[string]any, ) func newDeleteServicePrincipal() *cobra.Command { cmd := &cobra.Command{} - - var deleteServicePrincipalReq iamv2.DeleteServicePrincipalRequest + var deleteServicePrincipalReq map[string]any + deleteServicePrincipalReq = map[string]any{} + var deleteServicePrincipalServicePrincipalIdRaw string cmd.Use = "delete-service-principal SERVICE_PRINCIPAL_ID" cmd.Short = `*Beta* Delete a service principal in the account.` @@ -1027,10 +1221,19 @@ Delete a service principal in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + deleteServicePrincipalServicePrincipalIdRaw = args[0] - deleteServicePrincipalReq.ServicePrincipalId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/service-principals/%s", a.Config.AccountID, fmt.Sprint(deleteServicePrincipalServicePrincipalIdRaw)) - err = a.IamV2.DeleteServicePrincipal(ctx, deleteServicePrincipalReq) + maps.Copy(rawQuery, deleteServicePrincipalReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, nil, rawQuery, nil, nil) if err != nil { return err } @@ -1055,13 +1258,14 @@ Delete a service principal in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteUserOverrides []func( *cobra.Command, - *iamv2.DeleteUserRequest, + *map[string]any, ) func newDeleteUser() *cobra.Command { cmd := &cobra.Command{} - - var deleteUserReq iamv2.DeleteUserRequest + var deleteUserReq map[string]any + deleteUserReq = map[string]any{} + var deleteUserUserIdRaw string cmd.Use = "delete-user USER_ID" cmd.Short = `*Beta* Delete a user in the account.` @@ -1087,10 +1291,19 @@ Delete a user in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + deleteUserUserIdRaw = args[0] - deleteUserReq.UserId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/users/%s", a.Config.AccountID, fmt.Sprint(deleteUserUserIdRaw)) - err = a.IamV2.DeleteUser(ctx, deleteUserReq) + maps.Copy(rawQuery, deleteUserReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, nil, rawQuery, nil, nil) if err != nil { return err } @@ -1115,13 +1328,15 @@ Delete a user in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteWorkspaceAssignmentOverrides []func( *cobra.Command, - *iamv2.DeleteWorkspaceAssignmentRequest, + *map[string]any, ) func newDeleteWorkspaceAssignment() *cobra.Command { cmd := &cobra.Command{} - - var deleteWorkspaceAssignmentReq iamv2.DeleteWorkspaceAssignmentRequest + var deleteWorkspaceAssignmentReq map[string]any + deleteWorkspaceAssignmentReq = map[string]any{} + var deleteWorkspaceAssignmentPrincipalIdRaw int64 + var deleteWorkspaceAssignmentWorkspaceIdRaw int64 cmd.Use = "delete-workspace-assignment WORKSPACE_ID PRINCIPAL_ID" cmd.Short = `*Beta* Delete a workspace assignment.` @@ -1152,18 +1367,26 @@ Delete a workspace assignment. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &deleteWorkspaceAssignmentReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &deleteWorkspaceAssignmentWorkspaceIdRaw) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &deleteWorkspaceAssignmentReq.PrincipalId) + _, err = fmt.Sscan(args[1], &deleteWorkspaceAssignmentPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } - err = a.IamV2.DeleteWorkspaceAssignment(ctx, deleteWorkspaceAssignmentReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/workspaces/%s/workspace-assignments/%s", a.Config.AccountID, fmt.Sprint(deleteWorkspaceAssignmentWorkspaceIdRaw), fmt.Sprint(deleteWorkspaceAssignmentPrincipalIdRaw)) + + maps.Copy(rawQuery, deleteWorkspaceAssignmentReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, nil, rawQuery, nil, nil) if err != nil { return err } @@ -1188,13 +1411,15 @@ Delete a workspace assignment. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteWorkspaceAssignmentDetailOverrides []func( *cobra.Command, - *iamv2.DeleteWorkspaceAssignmentDetailRequest, + *map[string]any, ) func newDeleteWorkspaceAssignmentDetail() *cobra.Command { cmd := &cobra.Command{} - - var deleteWorkspaceAssignmentDetailReq iamv2.DeleteWorkspaceAssignmentDetailRequest + var deleteWorkspaceAssignmentDetailReq map[string]any + deleteWorkspaceAssignmentDetailReq = map[string]any{} + var deleteWorkspaceAssignmentDetailPrincipalIdRaw int64 + var deleteWorkspaceAssignmentDetailWorkspaceIdRaw int64 cmd.Use = "delete-workspace-assignment-detail WORKSPACE_ID PRINCIPAL_ID" cmd.Short = `Delete a workspace assignment detail.` @@ -1226,18 +1451,26 @@ func newDeleteWorkspaceAssignmentDetail() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &deleteWorkspaceAssignmentDetailReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &deleteWorkspaceAssignmentDetailWorkspaceIdRaw) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &deleteWorkspaceAssignmentDetailReq.PrincipalId) + _, err = fmt.Sscan(args[1], &deleteWorkspaceAssignmentDetailPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } - err = a.IamV2.DeleteWorkspaceAssignmentDetail(ctx, deleteWorkspaceAssignmentDetailReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/workspaces/%s/workspace-assignment-details/%s", a.Config.AccountID, fmt.Sprint(deleteWorkspaceAssignmentDetailWorkspaceIdRaw), fmt.Sprint(deleteWorkspaceAssignmentDetailPrincipalIdRaw)) + + maps.Copy(rawQuery, deleteWorkspaceAssignmentDetailReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, nil, rawQuery, nil, nil) if err != nil { return err } @@ -1262,13 +1495,15 @@ func newDeleteWorkspaceAssignmentDetail() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getDirectGroupMemberOverrides []func( *cobra.Command, - *iamv2.GetDirectGroupMemberRequest, + *map[string]any, ) func newGetDirectGroupMember() *cobra.Command { cmd := &cobra.Command{} - - var getDirectGroupMemberReq iamv2.GetDirectGroupMemberRequest + var getDirectGroupMemberReq map[string]any + getDirectGroupMemberReq = map[string]any{} + var getDirectGroupMemberGroupIdRaw int64 + var getDirectGroupMemberPrincipalIdRaw int64 cmd.Use = "get-direct-group-member GROUP_ID PRINCIPAL_ID" cmd.Short = `*Beta* Get a direct group member.` @@ -1296,22 +1531,30 @@ Get a direct group member. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &getDirectGroupMemberReq.GroupId) + _, err = fmt.Sscan(args[0], &getDirectGroupMemberGroupIdRaw) if err != nil { return fmt.Errorf("invalid GROUP_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &getDirectGroupMemberReq.PrincipalId) + _, err = fmt.Sscan(args[1], &getDirectGroupMemberPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } - response, err := a.IamV2.GetDirectGroupMember(ctx, getDirectGroupMemberReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/groups/%s/direct-members/%s", a.Config.AccountID, fmt.Sprint(getDirectGroupMemberGroupIdRaw), fmt.Sprint(getDirectGroupMemberPrincipalIdRaw)) + + maps.Copy(rawQuery, getDirectGroupMemberReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1333,13 +1576,14 @@ Get a direct group member. // Functions can be added from the `init()` function in manually curated files in this directory. var getExternalGroupOverrides []func( *cobra.Command, - *iamv2.GetExternalGroupRequest, + *map[string]any, ) func newGetExternalGroup() *cobra.Command { cmd := &cobra.Command{} - - var getExternalGroupReq iamv2.GetExternalGroupRequest + var getExternalGroupReq map[string]any + getExternalGroupReq = map[string]any{} + var getExternalGroupNameRaw string cmd.Use = "get-external-group NAME" cmd.Short = `*Beta* Get an external group in the account.` @@ -1369,14 +1613,23 @@ Get an external group in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getExternalGroupReq.Name = args[0] + getExternalGroupNameRaw = args[0] - response, err := a.IamV2.GetExternalGroup(ctx, getExternalGroupReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/%s", fmt.Sprint(getExternalGroupNameRaw)) + + maps.Copy(rawQuery, getExternalGroupReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1398,13 +1651,14 @@ Get an external group in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var getExternalServicePrincipalOverrides []func( *cobra.Command, - *iamv2.GetExternalServicePrincipalRequest, + *map[string]any, ) func newGetExternalServicePrincipal() *cobra.Command { cmd := &cobra.Command{} - - var getExternalServicePrincipalReq iamv2.GetExternalServicePrincipalRequest + var getExternalServicePrincipalReq map[string]any + getExternalServicePrincipalReq = map[string]any{} + var getExternalServicePrincipalNameRaw string cmd.Use = "get-external-service-principal NAME" cmd.Short = `*Beta* Get an external service principal in the account.` @@ -1434,14 +1688,23 @@ Get an external service principal in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + getExternalServicePrincipalNameRaw = args[0] - getExternalServicePrincipalReq.Name = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/%s", fmt.Sprint(getExternalServicePrincipalNameRaw)) - response, err := a.IamV2.GetExternalServicePrincipal(ctx, getExternalServicePrincipalReq) + maps.Copy(rawQuery, getExternalServicePrincipalReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1463,13 +1726,14 @@ Get an external service principal in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var getExternalUserOverrides []func( *cobra.Command, - *iamv2.GetExternalUserRequest, + *map[string]any, ) func newGetExternalUser() *cobra.Command { cmd := &cobra.Command{} - - var getExternalUserReq iamv2.GetExternalUserRequest + var getExternalUserReq map[string]any + getExternalUserReq = map[string]any{} + var getExternalUserNameRaw string cmd.Use = "get-external-user NAME" cmd.Short = `*Beta* Get an external user in the account.` @@ -1498,14 +1762,23 @@ Get an external user in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + getExternalUserNameRaw = args[0] - getExternalUserReq.Name = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/%s", fmt.Sprint(getExternalUserNameRaw)) - response, err := a.IamV2.GetExternalUser(ctx, getExternalUserReq) + maps.Copy(rawQuery, getExternalUserReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1527,13 +1800,14 @@ Get an external user in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var getGroupOverrides []func( *cobra.Command, - *iamv2.GetGroupRequest, + *map[string]any, ) func newGetGroup() *cobra.Command { cmd := &cobra.Command{} - - var getGroupReq iamv2.GetGroupRequest + var getGroupReq map[string]any + getGroupReq = map[string]any{} + var getGroupGroupIdRaw string cmd.Use = "get-group GROUP_ID" cmd.Short = `*Beta* Get a group in the account.` @@ -1559,14 +1833,23 @@ Get a group in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + getGroupGroupIdRaw = args[0] - getGroupReq.GroupId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/groups/%s", a.Config.AccountID, fmt.Sprint(getGroupGroupIdRaw)) - response, err := a.IamV2.GetGroup(ctx, getGroupReq) + maps.Copy(rawQuery, getGroupReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1588,13 +1871,14 @@ Get a group in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var getIdentityVisibilityFilterOverrides []func( *cobra.Command, - *iamv2.GetIdentityVisibilityFilterRequest, + *map[string]any, ) func newGetIdentityVisibilityFilter() *cobra.Command { cmd := &cobra.Command{} - - var getIdentityVisibilityFilterReq iamv2.GetIdentityVisibilityFilterRequest + var getIdentityVisibilityFilterReq map[string]any + getIdentityVisibilityFilterReq = map[string]any{} + var getIdentityVisibilityFilterNameRaw string cmd.Use = "get-identity-visibility-filter NAME" cmd.Short = `Get an identity-visibility filter.` @@ -1622,14 +1906,23 @@ func newGetIdentityVisibilityFilter() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getIdentityVisibilityFilterReq.Name = args[0] + getIdentityVisibilityFilterNameRaw = args[0] - response, err := a.IamV2.GetIdentityVisibilityFilter(ctx, getIdentityVisibilityFilterReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/%s", fmt.Sprint(getIdentityVisibilityFilterNameRaw)) + + maps.Copy(rawQuery, getIdentityVisibilityFilterReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1651,13 +1944,14 @@ func newGetIdentityVisibilityFilter() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getServicePrincipalOverrides []func( *cobra.Command, - *iamv2.GetServicePrincipalRequest, + *map[string]any, ) func newGetServicePrincipal() *cobra.Command { cmd := &cobra.Command{} - - var getServicePrincipalReq iamv2.GetServicePrincipalRequest + var getServicePrincipalReq map[string]any + getServicePrincipalReq = map[string]any{} + var getServicePrincipalServicePrincipalIdRaw string cmd.Use = "get-service-principal SERVICE_PRINCIPAL_ID" cmd.Short = `*Beta* Get a service principal in the account.` @@ -1683,14 +1977,23 @@ Get a service principal in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getServicePrincipalReq.ServicePrincipalId = args[0] + getServicePrincipalServicePrincipalIdRaw = args[0] - response, err := a.IamV2.GetServicePrincipal(ctx, getServicePrincipalReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/service-principals/%s", a.Config.AccountID, fmt.Sprint(getServicePrincipalServicePrincipalIdRaw)) + + maps.Copy(rawQuery, getServicePrincipalReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1712,13 +2015,14 @@ Get a service principal in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var getUserOverrides []func( *cobra.Command, - *iamv2.GetUserRequest, + *map[string]any, ) func newGetUser() *cobra.Command { cmd := &cobra.Command{} - - var getUserReq iamv2.GetUserRequest + var getUserReq map[string]any + getUserReq = map[string]any{} + var getUserUserIdRaw string cmd.Use = "get-user USER_ID" cmd.Short = `*Beta* Get a user in the account.` @@ -1744,14 +2048,23 @@ Get a user in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + getUserUserIdRaw = args[0] - getUserReq.UserId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/users/%s", a.Config.AccountID, fmt.Sprint(getUserUserIdRaw)) - response, err := a.IamV2.GetUser(ctx, getUserReq) + maps.Copy(rawQuery, getUserReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1773,15 +2086,18 @@ Get a user in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var getWorkspaceAccessDetailOverrides []func( *cobra.Command, - *iamv2.GetWorkspaceAccessDetailRequest, + *map[string]any, ) func newGetWorkspaceAccessDetail() *cobra.Command { cmd := &cobra.Command{} + var getWorkspaceAccessDetailReq map[string]any + getWorkspaceAccessDetailReq = map[string]any{} + var getWorkspaceAccessDetailPrincipalIdRaw int64 + var getWorkspaceAccessDetailViewRaw string + var getWorkspaceAccessDetailWorkspaceIdRaw int64 - var getWorkspaceAccessDetailReq iamv2.GetWorkspaceAccessDetailRequest - - cmd.Flags().Var(&getWorkspaceAccessDetailReq.View, "view", `Controls what fields are returned. Supported values: [BASIC, FULL]`) + flags.EnumVar(cmd.Flags(), &getWorkspaceAccessDetailViewRaw, "view", `Controls what fields are returned. Supported values: [BASIC, FULL]`, "WorkspaceAccessDetailView", "BASIC", "FULL") cmd.Use = "get-workspace-access-detail WORKSPACE_ID PRINCIPAL_ID" cmd.Short = `*Beta* Get workspace access details for a principal.` @@ -1815,22 +2131,33 @@ Get workspace access details for a principal. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &getWorkspaceAccessDetailReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &getWorkspaceAccessDetailWorkspaceIdRaw) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &getWorkspaceAccessDetailReq.PrincipalId) + _, err = fmt.Sscan(args[1], &getWorkspaceAccessDetailPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } - response, err := a.IamV2.GetWorkspaceAccessDetail(ctx, getWorkspaceAccessDetailReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("view") || getWorkspaceAccessDetailViewRaw != "" { + rawQuery["view"] = getWorkspaceAccessDetailViewRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/workspaces/%s/workspace-access-details/%s", a.Config.AccountID, fmt.Sprint(getWorkspaceAccessDetailWorkspaceIdRaw), fmt.Sprint(getWorkspaceAccessDetailPrincipalIdRaw)) + + maps.Copy(rawQuery, getWorkspaceAccessDetailReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1852,13 +2179,15 @@ Get workspace access details for a principal. // Functions can be added from the `init()` function in manually curated files in this directory. var getWorkspaceAssignmentOverrides []func( *cobra.Command, - *iamv2.GetWorkspaceAssignmentRequest, + *map[string]any, ) func newGetWorkspaceAssignment() *cobra.Command { cmd := &cobra.Command{} - - var getWorkspaceAssignmentReq iamv2.GetWorkspaceAssignmentRequest + var getWorkspaceAssignmentReq map[string]any + getWorkspaceAssignmentReq = map[string]any{} + var getWorkspaceAssignmentPrincipalIdRaw int64 + var getWorkspaceAssignmentWorkspaceIdRaw int64 cmd.Use = "get-workspace-assignment WORKSPACE_ID PRINCIPAL_ID" cmd.Short = `*Beta* Get a workspace assignment for a principal.` @@ -1886,22 +2215,30 @@ Get a workspace assignment for a principal. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &getWorkspaceAssignmentReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &getWorkspaceAssignmentWorkspaceIdRaw) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &getWorkspaceAssignmentReq.PrincipalId) + _, err = fmt.Sscan(args[1], &getWorkspaceAssignmentPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } - response, err := a.IamV2.GetWorkspaceAssignment(ctx, getWorkspaceAssignmentReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/workspaces/%s/workspace-assignments/%s", a.Config.AccountID, fmt.Sprint(getWorkspaceAssignmentWorkspaceIdRaw), fmt.Sprint(getWorkspaceAssignmentPrincipalIdRaw)) + + maps.Copy(rawQuery, getWorkspaceAssignmentReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1923,13 +2260,15 @@ Get a workspace assignment for a principal. // Functions can be added from the `init()` function in manually curated files in this directory. var getWorkspaceAssignmentDetailOverrides []func( *cobra.Command, - *iamv2.GetWorkspaceAssignmentDetailRequest, + *map[string]any, ) func newGetWorkspaceAssignmentDetail() *cobra.Command { cmd := &cobra.Command{} - - var getWorkspaceAssignmentDetailReq iamv2.GetWorkspaceAssignmentDetailRequest + var getWorkspaceAssignmentDetailReq map[string]any + getWorkspaceAssignmentDetailReq = map[string]any{} + var getWorkspaceAssignmentDetailPrincipalIdRaw int64 + var getWorkspaceAssignmentDetailWorkspaceIdRaw int64 cmd.Use = "get-workspace-assignment-detail WORKSPACE_ID PRINCIPAL_ID" cmd.Short = `Get workspace assignment details for a principal.` @@ -1959,22 +2298,30 @@ func newGetWorkspaceAssignmentDetail() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &getWorkspaceAssignmentDetailReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &getWorkspaceAssignmentDetailWorkspaceIdRaw) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &getWorkspaceAssignmentDetailReq.PrincipalId) + _, err = fmt.Sscan(args[1], &getWorkspaceAssignmentDetailPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } - response, err := a.IamV2.GetWorkspaceAssignmentDetail(ctx, getWorkspaceAssignmentDetailReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/workspaces/%s/workspace-assignment-details/%s", a.Config.AccountID, fmt.Sprint(getWorkspaceAssignmentDetailWorkspaceIdRaw), fmt.Sprint(getWorkspaceAssignmentDetailPrincipalIdRaw)) + + maps.Copy(rawQuery, getWorkspaceAssignmentDetailReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1996,25 +2343,29 @@ func newGetWorkspaceAssignmentDetail() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listDirectGroupMembersOverrides []func( *cobra.Command, - *iamv2.ListDirectGroupMembersRequest, + *map[string]any, ) func newListDirectGroupMembers() *cobra.Command { cmd := &cobra.Command{} + var listDirectGroupMembersReq map[string]any + listDirectGroupMembersReq = map[string]any{} + var listDirectGroupMembersGroupIdRaw int64 + var listDirectGroupMembersPageSizeRaw int + var listDirectGroupMembersPageTokenRaw string - var listDirectGroupMembersReq iamv2.ListDirectGroupMembersRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listDirectGroupMembersLimit int - cmd.Flags().IntVar(&listDirectGroupMembersReq.PageSize, "page-size", listDirectGroupMembersReq.PageSize, `The maximum number of members to return.`) + cmd.Flags().IntVar(&listDirectGroupMembersPageSizeRaw, "page-size", listDirectGroupMembersPageSizeRaw, `The maximum number of members to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listDirectGroupMembersLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listDirectGroupMembersReq.PageToken, "page-token", listDirectGroupMembersReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listDirectGroupMembersPageTokenRaw, "page-token", listDirectGroupMembersPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-direct-group-members GROUP_ID" @@ -2043,21 +2394,36 @@ List direct group members. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &listDirectGroupMembersReq.GroupId) + _, err = fmt.Sscan(args[0], &listDirectGroupMembersGroupIdRaw) if err != nil { return fmt.Errorf("invalid GROUP_ID: %s", args[0]) } - response := a.IamV2.ListDirectGroupMembers(ctx, listDirectGroupMembersReq) - if listDirectGroupMembersLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listDirectGroupMembersLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("page-size") || listDirectGroupMembersPageSizeRaw != 0 { + rawQuery["page_size"] = listDirectGroupMembersPageSizeRaw } - if listDirectGroupMembersLimit > 0 { - ctx = cmdio.WithLimit(ctx, listDirectGroupMembersLimit) + if cmd.Flags().Changed("page-token") || listDirectGroupMembersPageTokenRaw != "" { + rawQuery["page_token"] = listDirectGroupMembersPageTokenRaw } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/groups/%s/direct-members", a.Config.AccountID, fmt.Sprint(listDirectGroupMembersGroupIdRaw)) - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listDirectGroupMembersReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) + if err != nil { + return err + } + if listDirectGroupMembersLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listDirectGroupMembersLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -2078,26 +2444,30 @@ List direct group members. // Functions can be added from the `init()` function in manually curated files in this directory. var listGroupsOverrides []func( *cobra.Command, - *iamv2.ListGroupsRequest, + *map[string]any, ) func newListGroups() *cobra.Command { cmd := &cobra.Command{} + var listGroupsReq map[string]any + listGroupsReq = map[string]any{} + var listGroupsFilterRaw string + var listGroupsPageSizeRaw int + var listGroupsPageTokenRaw string - var listGroupsReq iamv2.ListGroupsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listGroupsLimit int - cmd.Flags().StringVar(&listGroupsReq.Filter, "filter", listGroupsReq.Filter, `Optional.`) - cmd.Flags().IntVar(&listGroupsReq.PageSize, "page-size", listGroupsReq.PageSize, `The maximum number of groups to return.`) + cmd.Flags().StringVar(&listGroupsFilterRaw, "filter", listGroupsFilterRaw, `Optional.`) + cmd.Flags().IntVar(&listGroupsPageSizeRaw, "page-size", listGroupsPageSizeRaw, `The maximum number of groups to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listGroupsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listGroupsReq.PageToken, "page-token", listGroupsReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listGroupsPageTokenRaw, "page-token", listGroupsPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-groups" @@ -2122,16 +2492,34 @@ List groups in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.IamV2.ListGroups(ctx, listGroupsReq) - if listGroupsLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listGroupsLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("filter") || listGroupsFilterRaw != "" { + rawQuery["filter"] = listGroupsFilterRaw + } + if cmd.Flags().Changed("page-size") || listGroupsPageSizeRaw != 0 { + rawQuery["page_size"] = listGroupsPageSizeRaw } - if listGroupsLimit > 0 { - ctx = cmdio.WithLimit(ctx, listGroupsLimit) + if cmd.Flags().Changed("page-token") || listGroupsPageTokenRaw != "" { + rawQuery["page_token"] = listGroupsPageTokenRaw } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/groups", a.Config.AccountID) - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listGroupsReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) + if err != nil { + return err + } + if listGroupsLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listGroupsLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -2152,25 +2540,29 @@ List groups in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var listIdentityVisibilityFiltersOverrides []func( *cobra.Command, - *iamv2.ListIdentityVisibilityFiltersRequest, + *map[string]any, ) func newListIdentityVisibilityFilters() *cobra.Command { cmd := &cobra.Command{} + var listIdentityVisibilityFiltersReq map[string]any + listIdentityVisibilityFiltersReq = map[string]any{} + var listIdentityVisibilityFiltersPageSizeRaw int + var listIdentityVisibilityFiltersPageTokenRaw string + var listIdentityVisibilityFiltersParentRaw string - var listIdentityVisibilityFiltersReq iamv2.ListIdentityVisibilityFiltersRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listIdentityVisibilityFiltersLimit int - cmd.Flags().IntVar(&listIdentityVisibilityFiltersReq.PageSize, "page-size", listIdentityVisibilityFiltersReq.PageSize, `The maximum number of filters to return.`) + cmd.Flags().IntVar(&listIdentityVisibilityFiltersPageSizeRaw, "page-size", listIdentityVisibilityFiltersPageSizeRaw, `The maximum number of filters to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listIdentityVisibilityFiltersLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listIdentityVisibilityFiltersReq.PageToken, "page-token", listIdentityVisibilityFiltersReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listIdentityVisibilityFiltersPageTokenRaw, "page-token", listIdentityVisibilityFiltersPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-identity-visibility-filters PARENT" @@ -2199,18 +2591,33 @@ func newListIdentityVisibilityFilters() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - listIdentityVisibilityFiltersReq.Parent = args[0] + listIdentityVisibilityFiltersParentRaw = args[0] - response := a.IamV2.ListIdentityVisibilityFilters(ctx, listIdentityVisibilityFiltersReq) - if listIdentityVisibilityFiltersLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listIdentityVisibilityFiltersLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("page-size") || listIdentityVisibilityFiltersPageSizeRaw != 0 { + rawQuery["page_size"] = listIdentityVisibilityFiltersPageSizeRaw } - if listIdentityVisibilityFiltersLimit > 0 { - ctx = cmdio.WithLimit(ctx, listIdentityVisibilityFiltersLimit) + if cmd.Flags().Changed("page-token") || listIdentityVisibilityFiltersPageTokenRaw != "" { + rawQuery["page_token"] = listIdentityVisibilityFiltersPageTokenRaw } + rawPath := fmt.Sprintf("/api/2.0/identity/%s/identity-visibility-filters", fmt.Sprint(listIdentityVisibilityFiltersParentRaw)) - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listIdentityVisibilityFiltersReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) + if err != nil { + return err + } + if listIdentityVisibilityFiltersLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listIdentityVisibilityFiltersLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -2231,26 +2638,30 @@ func newListIdentityVisibilityFilters() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listServicePrincipalsOverrides []func( *cobra.Command, - *iamv2.ListServicePrincipalsRequest, + *map[string]any, ) func newListServicePrincipals() *cobra.Command { cmd := &cobra.Command{} + var listServicePrincipalsReq map[string]any + listServicePrincipalsReq = map[string]any{} + var listServicePrincipalsFilterRaw string + var listServicePrincipalsPageSizeRaw int + var listServicePrincipalsPageTokenRaw string - var listServicePrincipalsReq iamv2.ListServicePrincipalsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listServicePrincipalsLimit int - cmd.Flags().StringVar(&listServicePrincipalsReq.Filter, "filter", listServicePrincipalsReq.Filter, `Optional.`) - cmd.Flags().IntVar(&listServicePrincipalsReq.PageSize, "page-size", listServicePrincipalsReq.PageSize, `The maximum number of service principals to return.`) + cmd.Flags().StringVar(&listServicePrincipalsFilterRaw, "filter", listServicePrincipalsFilterRaw, `Optional.`) + cmd.Flags().IntVar(&listServicePrincipalsPageSizeRaw, "page-size", listServicePrincipalsPageSizeRaw, `The maximum number of service principals to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listServicePrincipalsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listServicePrincipalsReq.PageToken, "page-token", listServicePrincipalsReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listServicePrincipalsPageTokenRaw, "page-token", listServicePrincipalsPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-service-principals" @@ -2275,16 +2686,34 @@ List service principals in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.IamV2.ListServicePrincipals(ctx, listServicePrincipalsReq) - if listServicePrincipalsLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listServicePrincipalsLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("filter") || listServicePrincipalsFilterRaw != "" { + rawQuery["filter"] = listServicePrincipalsFilterRaw } - if listServicePrincipalsLimit > 0 { - ctx = cmdio.WithLimit(ctx, listServicePrincipalsLimit) + if cmd.Flags().Changed("page-size") || listServicePrincipalsPageSizeRaw != 0 { + rawQuery["page_size"] = listServicePrincipalsPageSizeRaw } + if cmd.Flags().Changed("page-token") || listServicePrincipalsPageTokenRaw != "" { + rawQuery["page_token"] = listServicePrincipalsPageTokenRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/service-principals", a.Config.AccountID) - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listServicePrincipalsReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) + if err != nil { + return err + } + if listServicePrincipalsLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listServicePrincipalsLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -2305,16 +2734,19 @@ List service principals in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var listTransitiveParentGroupsOverrides []func( *cobra.Command, - *iamv2.ListTransitiveParentGroupsRequest, + *map[string]any, ) func newListTransitiveParentGroups() *cobra.Command { cmd := &cobra.Command{} + var listTransitiveParentGroupsReq map[string]any + listTransitiveParentGroupsReq = map[string]any{} + var listTransitiveParentGroupsPageSizeRaw int + var listTransitiveParentGroupsPageTokenRaw string + var listTransitiveParentGroupsPrincipalIdRaw int64 - var listTransitiveParentGroupsReq iamv2.ListTransitiveParentGroupsRequest - - cmd.Flags().IntVar(&listTransitiveParentGroupsReq.PageSize, "page-size", listTransitiveParentGroupsReq.PageSize, `The maximum number of parent groups to return.`) - cmd.Flags().StringVar(&listTransitiveParentGroupsReq.PageToken, "page-token", listTransitiveParentGroupsReq.PageToken, `A page token, received from a previous ListTransitiveParentGroups call.`) + cmd.Flags().IntVar(&listTransitiveParentGroupsPageSizeRaw, "page-size", listTransitiveParentGroupsPageSizeRaw, `The maximum number of parent groups to return.`) + cmd.Flags().StringVar(&listTransitiveParentGroupsPageTokenRaw, "page-token", listTransitiveParentGroupsPageTokenRaw, `A page token, received from a previous ListTransitiveParentGroups call.`) cmd.Use = "list-transitive-parent-groups PRINCIPAL_ID" cmd.Short = `*Beta* List all transitive parent groups of a principal.` @@ -2341,17 +2773,32 @@ List all transitive parent groups of a principal. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &listTransitiveParentGroupsReq.PrincipalId) + _, err = fmt.Sscan(args[0], &listTransitiveParentGroupsPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } - response, err := a.IamV2.ListTransitiveParentGroups(ctx, listTransitiveParentGroupsReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("page-size") || listTransitiveParentGroupsPageSizeRaw != 0 { + rawQuery["page_size"] = listTransitiveParentGroupsPageSizeRaw + } + if cmd.Flags().Changed("page-token") || listTransitiveParentGroupsPageTokenRaw != "" { + rawQuery["page_token"] = listTransitiveParentGroupsPageTokenRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/principals/%s/transitive-parent-groups", a.Config.AccountID, fmt.Sprint(listTransitiveParentGroupsPrincipalIdRaw)) + + maps.Copy(rawQuery, listTransitiveParentGroupsReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2373,26 +2820,30 @@ List all transitive parent groups of a principal. // Functions can be added from the `init()` function in manually curated files in this directory. var listUsersOverrides []func( *cobra.Command, - *iamv2.ListUsersRequest, + *map[string]any, ) func newListUsers() *cobra.Command { cmd := &cobra.Command{} + var listUsersReq map[string]any + listUsersReq = map[string]any{} + var listUsersFilterRaw string + var listUsersPageSizeRaw int + var listUsersPageTokenRaw string - var listUsersReq iamv2.ListUsersRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listUsersLimit int - cmd.Flags().StringVar(&listUsersReq.Filter, "filter", listUsersReq.Filter, `Optional.`) - cmd.Flags().IntVar(&listUsersReq.PageSize, "page-size", listUsersReq.PageSize, `The maximum number of users to return.`) + cmd.Flags().StringVar(&listUsersFilterRaw, "filter", listUsersFilterRaw, `Optional.`) + cmd.Flags().IntVar(&listUsersPageSizeRaw, "page-size", listUsersPageSizeRaw, `The maximum number of users to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listUsersLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listUsersReq.PageToken, "page-token", listUsersReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listUsersPageTokenRaw, "page-token", listUsersPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-users" @@ -2417,16 +2868,34 @@ List users in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.IamV2.ListUsers(ctx, listUsersReq) - if listUsersLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listUsersLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("filter") || listUsersFilterRaw != "" { + rawQuery["filter"] = listUsersFilterRaw + } + if cmd.Flags().Changed("page-size") || listUsersPageSizeRaw != 0 { + rawQuery["page_size"] = listUsersPageSizeRaw } - if listUsersLimit > 0 { - ctx = cmdio.WithLimit(ctx, listUsersLimit) + if cmd.Flags().Changed("page-token") || listUsersPageTokenRaw != "" { + rawQuery["page_token"] = listUsersPageTokenRaw } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/users", a.Config.AccountID) - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listUsersReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) + if err != nil { + return err + } + if listUsersLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listUsersLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -2447,25 +2916,29 @@ List users in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var listWorkspaceAssignmentDetailsOverrides []func( *cobra.Command, - *iamv2.ListWorkspaceAssignmentDetailsRequest, + *map[string]any, ) func newListWorkspaceAssignmentDetails() *cobra.Command { cmd := &cobra.Command{} + var listWorkspaceAssignmentDetailsReq map[string]any + listWorkspaceAssignmentDetailsReq = map[string]any{} + var listWorkspaceAssignmentDetailsPageSizeRaw int + var listWorkspaceAssignmentDetailsPageTokenRaw string + var listWorkspaceAssignmentDetailsWorkspaceIdRaw int64 - var listWorkspaceAssignmentDetailsReq iamv2.ListWorkspaceAssignmentDetailsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listWorkspaceAssignmentDetailsLimit int - cmd.Flags().IntVar(&listWorkspaceAssignmentDetailsReq.PageSize, "page-size", listWorkspaceAssignmentDetailsReq.PageSize, `The maximum number of workspace assignment details to return.`) + cmd.Flags().IntVar(&listWorkspaceAssignmentDetailsPageSizeRaw, "page-size", listWorkspaceAssignmentDetailsPageSizeRaw, `The maximum number of workspace assignment details to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listWorkspaceAssignmentDetailsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listWorkspaceAssignmentDetailsReq.PageToken, "page-token", listWorkspaceAssignmentDetailsReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listWorkspaceAssignmentDetailsPageTokenRaw, "page-token", listWorkspaceAssignmentDetailsPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-workspace-assignment-details WORKSPACE_ID" @@ -2497,21 +2970,36 @@ func newListWorkspaceAssignmentDetails() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &listWorkspaceAssignmentDetailsReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &listWorkspaceAssignmentDetailsWorkspaceIdRaw) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - response := a.IamV2.ListWorkspaceAssignmentDetails(ctx, listWorkspaceAssignmentDetailsReq) - if listWorkspaceAssignmentDetailsLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listWorkspaceAssignmentDetailsLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("page-size") || listWorkspaceAssignmentDetailsPageSizeRaw != 0 { + rawQuery["page_size"] = listWorkspaceAssignmentDetailsPageSizeRaw } - if listWorkspaceAssignmentDetailsLimit > 0 { - ctx = cmdio.WithLimit(ctx, listWorkspaceAssignmentDetailsLimit) + if cmd.Flags().Changed("page-token") || listWorkspaceAssignmentDetailsPageTokenRaw != "" { + rawQuery["page_token"] = listWorkspaceAssignmentDetailsPageTokenRaw } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/workspaces/%s/workspace-assignment-details", a.Config.AccountID, fmt.Sprint(listWorkspaceAssignmentDetailsWorkspaceIdRaw)) - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listWorkspaceAssignmentDetailsReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) + if err != nil { + return err + } + if listWorkspaceAssignmentDetailsLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listWorkspaceAssignmentDetailsLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -2532,25 +3020,29 @@ func newListWorkspaceAssignmentDetails() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listWorkspaceAssignmentsOverrides []func( *cobra.Command, - *iamv2.ListWorkspaceAssignmentsRequest, + *map[string]any, ) func newListWorkspaceAssignments() *cobra.Command { cmd := &cobra.Command{} + var listWorkspaceAssignmentsReq map[string]any + listWorkspaceAssignmentsReq = map[string]any{} + var listWorkspaceAssignmentsPageSizeRaw int + var listWorkspaceAssignmentsPageTokenRaw string + var listWorkspaceAssignmentsWorkspaceIdRaw int64 - var listWorkspaceAssignmentsReq iamv2.ListWorkspaceAssignmentsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listWorkspaceAssignmentsLimit int - cmd.Flags().IntVar(&listWorkspaceAssignmentsReq.PageSize, "page-size", listWorkspaceAssignmentsReq.PageSize, `The maximum number of workspace assignments to return.`) + cmd.Flags().IntVar(&listWorkspaceAssignmentsPageSizeRaw, "page-size", listWorkspaceAssignmentsPageSizeRaw, `The maximum number of workspace assignments to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listWorkspaceAssignmentsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listWorkspaceAssignmentsReq.PageToken, "page-token", listWorkspaceAssignmentsReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listWorkspaceAssignmentsPageTokenRaw, "page-token", listWorkspaceAssignmentsPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-workspace-assignments WORKSPACE_ID" @@ -2581,21 +3073,36 @@ List workspace assignments for a workspace. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &listWorkspaceAssignmentsReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &listWorkspaceAssignmentsWorkspaceIdRaw) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - response := a.IamV2.ListWorkspaceAssignments(ctx, listWorkspaceAssignmentsReq) - if listWorkspaceAssignmentsLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listWorkspaceAssignmentsLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("page-size") || listWorkspaceAssignmentsPageSizeRaw != 0 { + rawQuery["page_size"] = listWorkspaceAssignmentsPageSizeRaw } - if listWorkspaceAssignmentsLimit > 0 { - ctx = cmdio.WithLimit(ctx, listWorkspaceAssignmentsLimit) + if cmd.Flags().Changed("page-token") || listWorkspaceAssignmentsPageTokenRaw != "" { + rawQuery["page_token"] = listWorkspaceAssignmentsPageTokenRaw } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/workspaces/%s/workspace-assignments", a.Config.AccountID, fmt.Sprint(listWorkspaceAssignmentsWorkspaceIdRaw)) - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listWorkspaceAssignmentsReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) + if err != nil { + return err + } + if listWorkspaceAssignmentsLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listWorkspaceAssignmentsLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -2616,13 +3123,15 @@ List workspace assignments for a workspace. // Functions can be added from the `init()` function in manually curated files in this directory. var resolveGroupOverrides []func( *cobra.Command, - *iamv2.ResolveGroupRequest, + *map[string]any, ) func newResolveGroup() *cobra.Command { cmd := &cobra.Command{} + var resolveGroupReq map[string]any + resolveGroupReq = map[string]any{} + var resolveGroupExternalIdRaw string - var resolveGroupReq iamv2.ResolveGroupRequest var resolveGroupJson flags.JsonFlag cmd.Flags().Var(&resolveGroupJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2661,6 +3170,7 @@ Resolve an external group in the Databricks account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := resolveGroupJson.Unmarshal(&resolveGroupReq) @@ -2675,14 +3185,24 @@ Resolve an external group in the Databricks account. } } if !cmd.Flags().Changed("json") { - resolveGroupReq.ExternalId = args[0] + resolveGroupExternalIdRaw = args[0] + } + + rawQuery := map[string]any{} + if cmd.Flags().Changed("external-id") || resolveGroupExternalIdRaw != "" { + resolveGroupReq["external_id"] = resolveGroupExternalIdRaw } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/groups/resolve-by-external-id", a.Config.AccountID) - response, err := a.IamV2.ResolveGroup(ctx, resolveGroupReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, nil, rawQuery, resolveGroupReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2704,13 +3224,15 @@ Resolve an external group in the Databricks account. // Functions can be added from the `init()` function in manually curated files in this directory. var resolveServicePrincipalOverrides []func( *cobra.Command, - *iamv2.ResolveServicePrincipalRequest, + *map[string]any, ) func newResolveServicePrincipal() *cobra.Command { cmd := &cobra.Command{} + var resolveServicePrincipalReq map[string]any + resolveServicePrincipalReq = map[string]any{} + var resolveServicePrincipalExternalIdRaw string - var resolveServicePrincipalReq iamv2.ResolveServicePrincipalRequest var resolveServicePrincipalJson flags.JsonFlag cmd.Flags().Var(&resolveServicePrincipalJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2749,6 +3271,7 @@ Resolve an external service principal in the Databricks account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := resolveServicePrincipalJson.Unmarshal(&resolveServicePrincipalReq) @@ -2763,14 +3286,24 @@ Resolve an external service principal in the Databricks account. } } if !cmd.Flags().Changed("json") { - resolveServicePrincipalReq.ExternalId = args[0] + resolveServicePrincipalExternalIdRaw = args[0] + } + + rawQuery := map[string]any{} + if cmd.Flags().Changed("external-id") || resolveServicePrincipalExternalIdRaw != "" { + resolveServicePrincipalReq["external_id"] = resolveServicePrincipalExternalIdRaw } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/service-principals/resolve-by-external-id", a.Config.AccountID) - response, err := a.IamV2.ResolveServicePrincipal(ctx, resolveServicePrincipalReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, nil, rawQuery, resolveServicePrincipalReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2792,13 +3325,15 @@ Resolve an external service principal in the Databricks account. // Functions can be added from the `init()` function in manually curated files in this directory. var resolveUserOverrides []func( *cobra.Command, - *iamv2.ResolveUserRequest, + *map[string]any, ) func newResolveUser() *cobra.Command { cmd := &cobra.Command{} + var resolveUserReq map[string]any + resolveUserReq = map[string]any{} + var resolveUserExternalIdRaw string - var resolveUserReq iamv2.ResolveUserRequest var resolveUserJson flags.JsonFlag cmd.Flags().Var(&resolveUserJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2836,6 +3371,7 @@ Resolve an external user in the Databricks account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := resolveUserJson.Unmarshal(&resolveUserReq) @@ -2850,14 +3386,24 @@ Resolve an external user in the Databricks account. } } if !cmd.Flags().Changed("json") { - resolveUserReq.ExternalId = args[0] + resolveUserExternalIdRaw = args[0] + } + + rawQuery := map[string]any{} + if cmd.Flags().Changed("external-id") || resolveUserExternalIdRaw != "" { + resolveUserReq["external_id"] = resolveUserExternalIdRaw } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/users/resolve-by-external-id", a.Config.AccountID) - response, err := a.IamV2.ResolveUser(ctx, resolveUserReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, nil, rawQuery, resolveUserReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2879,20 +3425,25 @@ Resolve an external user in the Databricks account. // Functions can be added from the `init()` function in manually curated files in this directory. var updateGroupOverrides []func( *cobra.Command, - *iamv2.UpdateGroupRequest, + *map[string]any, ) func newUpdateGroup() *cobra.Command { cmd := &cobra.Command{} + var updateGroupReq map[string]any + updateGroupReq = map[string]any{} + var updateGroupGroupIdRaw string + var updateGroupUpdateMaskRaw string + var updateGroupAccountIdRaw string + var updateGroupExternalIdRaw string + var updateGroupGroupNameRaw string - var updateGroupReq iamv2.UpdateGroupRequest - updateGroupReq.Group = iamv2.Group{} var updateGroupJson flags.JsonFlag cmd.Flags().Var(&updateGroupJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateGroupReq.Group.ExternalId, "external-id", updateGroupReq.Group.ExternalId, `ExternalId of the group in the customer's IdP.`) - cmd.Flags().StringVar(&updateGroupReq.Group.GroupName, "group-name", updateGroupReq.Group.GroupName, `Display name of the group.`) + cmd.Flags().StringVar(&updateGroupExternalIdRaw, "external-id", updateGroupExternalIdRaw, `ExternalId of the group in the customer's IdP.`) + cmd.Flags().StringVar(&updateGroupGroupNameRaw, "group-name", updateGroupGroupNameRaw, `Display name of the group.`) cmd.Use = "update-group GROUP_ID UPDATE_MASK" cmd.Short = `*Beta* Update a group in the account.` @@ -2928,9 +3479,10 @@ Update a group in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := updateGroupJson.Unmarshal(&updateGroupReq.Group) + diags := updateGroupJson.Unmarshal(&updateGroupReq) if diags.HasError() { return diags.Error() } @@ -2941,14 +3493,36 @@ Update a group in the account. } } } - updateGroupReq.GroupId = args[0] - updateGroupReq.UpdateMask = args[1] + updateGroupGroupIdRaw = args[0] + updateGroupUpdateMaskRaw = args[1] + + rawQuery := map[string]any{} + if cmd.Flags().Changed("update-mask") || updateGroupUpdateMaskRaw != "" { + rawQuery["update_mask"] = updateGroupUpdateMaskRaw + } + if cmd.Flags().Changed("account-id") || updateGroupAccountIdRaw != "" { + updateGroupReq["account_id"] = updateGroupAccountIdRaw + } + if cmd.Flags().Changed("external-id") || updateGroupExternalIdRaw != "" { + updateGroupReq["external_id"] = updateGroupExternalIdRaw + } + if cmd.Flags().Changed("group-id") || updateGroupGroupIdRaw != "" { + updateGroupReq["group_id"] = updateGroupGroupIdRaw + } + if cmd.Flags().Changed("group-name") || updateGroupGroupNameRaw != "" { + updateGroupReq["group_name"] = updateGroupGroupNameRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/groups/%s", a.Config.AccountID, fmt.Sprint(updateGroupGroupIdRaw)) - response, err := a.IamV2.UpdateGroup(ctx, updateGroupReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updateGroupReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2970,19 +3544,26 @@ Update a group in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var updateServicePrincipalOverrides []func( *cobra.Command, - *iamv2.UpdateServicePrincipalRequest, + *map[string]any, ) func newUpdateServicePrincipal() *cobra.Command { cmd := &cobra.Command{} + var updateServicePrincipalReq map[string]any + updateServicePrincipalReq = map[string]any{} + var updateServicePrincipalServicePrincipalIdRaw string + var updateServicePrincipalUpdateMaskRaw string + var updateServicePrincipalAccountIdRaw string + var updateServicePrincipalAccountSpStatusRaw string + var updateServicePrincipalApplicationIdRaw string + var updateServicePrincipalDisplayNameRaw string + var updateServicePrincipalExternalIdRaw string - var updateServicePrincipalReq iamv2.UpdateServicePrincipalRequest - updateServicePrincipalReq.ServicePrincipal = iamv2.ServicePrincipal{} var updateServicePrincipalJson flags.JsonFlag cmd.Flags().Var(&updateServicePrincipalJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateServicePrincipalReq.ServicePrincipal.ExternalId, "external-id", updateServicePrincipalReq.ServicePrincipal.ExternalId, `ExternalId of the service principal in the customer's IdP.`) + cmd.Flags().StringVar(&updateServicePrincipalExternalIdRaw, "external-id", updateServicePrincipalExternalIdRaw, `ExternalId of the service principal in the customer's IdP.`) cmd.Use = "update-service-principal SERVICE_PRINCIPAL_ID UPDATE_MASK DISPLAY_NAME ACCOUNT_SP_STATUS" cmd.Short = `*Beta* Update a service principal in the account.` @@ -3025,9 +3606,10 @@ Update a service principal in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := updateServicePrincipalJson.Unmarshal(&updateServicePrincipalReq.ServicePrincipal) + diags := updateServicePrincipalJson.Unmarshal(&updateServicePrincipalReq) if diags.HasError() { return diags.Error() } @@ -3038,24 +3620,48 @@ Update a service principal in the account. } } } - updateServicePrincipalReq.ServicePrincipalId = args[0] - updateServicePrincipalReq.UpdateMask = args[1] + updateServicePrincipalServicePrincipalIdRaw = args[0] + updateServicePrincipalUpdateMaskRaw = args[1] if !cmd.Flags().Changed("json") { - updateServicePrincipalReq.ServicePrincipal.DisplayName = args[2] + updateServicePrincipalDisplayNameRaw = args[2] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updateServicePrincipalReq.ServicePrincipal.AccountSpStatus) - if err != nil { - return fmt.Errorf("invalid ACCOUNT_SP_STATUS: %s", args[3]) - } + updateServicePrincipalAccountSpStatusRaw = args[3] + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("update-mask") || updateServicePrincipalUpdateMaskRaw != "" { + rawQuery["update_mask"] = updateServicePrincipalUpdateMaskRaw + } + if cmd.Flags().Changed("account-id") || updateServicePrincipalAccountIdRaw != "" { + updateServicePrincipalReq["account_id"] = updateServicePrincipalAccountIdRaw } + if cmd.Flags().Changed("account-sp-status") || updateServicePrincipalAccountSpStatusRaw != "" { + updateServicePrincipalReq["account_sp_status"] = updateServicePrincipalAccountSpStatusRaw + } + if cmd.Flags().Changed("application-id") || updateServicePrincipalApplicationIdRaw != "" { + updateServicePrincipalReq["application_id"] = updateServicePrincipalApplicationIdRaw + } + if cmd.Flags().Changed("display-name") || updateServicePrincipalDisplayNameRaw != "" { + updateServicePrincipalReq["display_name"] = updateServicePrincipalDisplayNameRaw + } + if cmd.Flags().Changed("external-id") || updateServicePrincipalExternalIdRaw != "" { + updateServicePrincipalReq["external_id"] = updateServicePrincipalExternalIdRaw + } + if cmd.Flags().Changed("service-principal-id") || updateServicePrincipalServicePrincipalIdRaw != "" { + updateServicePrincipalReq["service_principal_id"] = updateServicePrincipalServicePrincipalIdRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/service-principals/%s", a.Config.AccountID, fmt.Sprint(updateServicePrincipalServicePrincipalIdRaw)) - response, err := a.IamV2.UpdateServicePrincipal(ctx, updateServicePrincipalReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updateServicePrincipalReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -3077,19 +3683,25 @@ Update a service principal in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var updateUserOverrides []func( *cobra.Command, - *iamv2.UpdateUserRequest, + *map[string]any, ) func newUpdateUser() *cobra.Command { cmd := &cobra.Command{} + var updateUserReq map[string]any + updateUserReq = map[string]any{} + var updateUserUpdateMaskRaw string + var updateUserUserIdRaw string + var updateUserAccountIdRaw string + var updateUserAccountUserStatusRaw string + var updateUserExternalIdRaw string + var updateUserUsernameRaw string - var updateUserReq iamv2.UpdateUserRequest - updateUserReq.User = iamv2.User{} var updateUserJson flags.JsonFlag cmd.Flags().Var(&updateUserJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateUserReq.User.ExternalId, "external-id", updateUserReq.User.ExternalId, `ExternalId of the user in the customer's IdP.`) + cmd.Flags().StringVar(&updateUserExternalIdRaw, "external-id", updateUserExternalIdRaw, `ExternalId of the user in the customer's IdP.`) cmd.Use = "update-user USER_ID UPDATE_MASK USERNAME FULL_NAME ACCOUNT_USER_STATUS" cmd.Short = `*Beta* Update a user in the account.` @@ -3133,9 +3745,10 @@ Update a user in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := updateUserJson.Unmarshal(&updateUserReq.User) + diags := updateUserJson.Unmarshal(&updateUserReq) if diags.HasError() { return diags.Error() } @@ -3146,31 +3759,48 @@ Update a user in the account. } } } - updateUserReq.UserId = args[0] - updateUserReq.UpdateMask = args[1] + updateUserUserIdRaw = args[0] + updateUserUpdateMaskRaw = args[1] if !cmd.Flags().Changed("json") { - updateUserReq.User.Username = args[2] + updateUserUsernameRaw = args[2] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updateUserReq.User.FullName) - if err != nil { - return fmt.Errorf("invalid FULL_NAME: %s", args[3]) - } - + updateUserReq["full_name"] = args[3] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[4], &updateUserReq.User.AccountUserStatus) - if err != nil { - return fmt.Errorf("invalid ACCOUNT_USER_STATUS: %s", args[4]) - } + updateUserAccountUserStatusRaw = args[4] + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("update-mask") || updateUserUpdateMaskRaw != "" { + rawQuery["update_mask"] = updateUserUpdateMaskRaw + } + if cmd.Flags().Changed("account-id") || updateUserAccountIdRaw != "" { + updateUserReq["account_id"] = updateUserAccountIdRaw + } + if cmd.Flags().Changed("account-user-status") || updateUserAccountUserStatusRaw != "" { + updateUserReq["account_user_status"] = updateUserAccountUserStatusRaw } + if cmd.Flags().Changed("external-id") || updateUserExternalIdRaw != "" { + updateUserReq["external_id"] = updateUserExternalIdRaw + } + if cmd.Flags().Changed("user-id") || updateUserUserIdRaw != "" { + updateUserReq["user_id"] = updateUserUserIdRaw + } + if cmd.Flags().Changed("username") || updateUserUsernameRaw != "" { + updateUserReq["username"] = updateUserUsernameRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/users/%s", a.Config.AccountID, fmt.Sprint(updateUserUserIdRaw)) - response, err := a.IamV2.UpdateUser(ctx, updateUserReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updateUserReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -3192,14 +3822,18 @@ Update a user in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var updateWorkspaceAssignmentOverrides []func( *cobra.Command, - *iamv2.UpdateWorkspaceAssignmentRequest, + *map[string]any, ) func newUpdateWorkspaceAssignment() *cobra.Command { cmd := &cobra.Command{} + var updateWorkspaceAssignmentReq map[string]any + updateWorkspaceAssignmentReq = map[string]any{} + var updateWorkspaceAssignmentPrincipalIdRaw int64 + var updateWorkspaceAssignmentWorkspaceIdRaw int64 + var updateWorkspaceAssignmentAccountIdRaw string + var updateWorkspaceAssignmentPrincipalTypeRaw string - var updateWorkspaceAssignmentReq iamv2.UpdateWorkspaceAssignmentRequest - updateWorkspaceAssignmentReq.WorkspaceAssignment = iamv2.WorkspaceAssignment{} var updateWorkspaceAssignmentJson flags.JsonFlag cmd.Flags().Var(&updateWorkspaceAssignmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -3245,9 +3879,10 @@ Update a workspace assignment. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := updateWorkspaceAssignmentJson.Unmarshal(&updateWorkspaceAssignmentReq.WorkspaceAssignment) + diags := updateWorkspaceAssignmentJson.Unmarshal(&updateWorkspaceAssignmentReq) if diags.HasError() { return diags.Error() } @@ -3258,33 +3893,48 @@ Update a workspace assignment. } } } - _, err = fmt.Sscan(args[0], &updateWorkspaceAssignmentReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &updateWorkspaceAssignmentWorkspaceIdRaw) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &updateWorkspaceAssignmentReq.PrincipalId) + _, err = fmt.Sscan(args[1], &updateWorkspaceAssignmentPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } - if args[2] != "" { - updateMaskArray := strings.Split(args[2], ",") - updateWorkspaceAssignmentReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateWorkspaceAssignmentReq["update_mask"] = args[2] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updateWorkspaceAssignmentReq.WorkspaceAssignment.PrincipalId) + _, err = fmt.Sscan(args[3], &updateWorkspaceAssignmentPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[3]) } + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || updateWorkspaceAssignmentAccountIdRaw != "" { + updateWorkspaceAssignmentReq["account_id"] = updateWorkspaceAssignmentAccountIdRaw + } + if cmd.Flags().Changed("principal-id") || updateWorkspaceAssignmentPrincipalIdRaw != 0 { + updateWorkspaceAssignmentReq["principal_id"] = updateWorkspaceAssignmentPrincipalIdRaw } + if cmd.Flags().Changed("principal-type") || updateWorkspaceAssignmentPrincipalTypeRaw != "" { + updateWorkspaceAssignmentReq["principal_type"] = updateWorkspaceAssignmentPrincipalTypeRaw + } + if cmd.Flags().Changed("workspace-id") || updateWorkspaceAssignmentWorkspaceIdRaw != 0 { + updateWorkspaceAssignmentReq["workspace_id"] = updateWorkspaceAssignmentWorkspaceIdRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/workspaces/%s/workspace-assignments/%s", a.Config.AccountID, fmt.Sprint(updateWorkspaceAssignmentWorkspaceIdRaw), fmt.Sprint(updateWorkspaceAssignmentPrincipalIdRaw)) - response, err := a.IamV2.UpdateWorkspaceAssignment(ctx, updateWorkspaceAssignmentReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updateWorkspaceAssignmentReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -3306,14 +3956,18 @@ Update a workspace assignment. // Functions can be added from the `init()` function in manually curated files in this directory. var updateWorkspaceAssignmentDetailOverrides []func( *cobra.Command, - *iamv2.UpdateWorkspaceAssignmentDetailRequest, + *map[string]any, ) func newUpdateWorkspaceAssignmentDetail() *cobra.Command { cmd := &cobra.Command{} + var updateWorkspaceAssignmentDetailReq map[string]any + updateWorkspaceAssignmentDetailReq = map[string]any{} + var updateWorkspaceAssignmentDetailPrincipalIdRaw int64 + var updateWorkspaceAssignmentDetailWorkspaceIdRaw int64 + var updateWorkspaceAssignmentDetailAccountIdRaw string + var updateWorkspaceAssignmentDetailPrincipalTypeRaw string - var updateWorkspaceAssignmentDetailReq iamv2.UpdateWorkspaceAssignmentDetailRequest - updateWorkspaceAssignmentDetailReq.WorkspaceAssignmentDetail = iamv2.WorkspaceAssignmentDetail{} var updateWorkspaceAssignmentDetailJson flags.JsonFlag cmd.Flags().Var(&updateWorkspaceAssignmentDetailJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -3360,9 +4014,10 @@ func newUpdateWorkspaceAssignmentDetail() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := updateWorkspaceAssignmentDetailJson.Unmarshal(&updateWorkspaceAssignmentDetailReq.WorkspaceAssignmentDetail) + diags := updateWorkspaceAssignmentDetailJson.Unmarshal(&updateWorkspaceAssignmentDetailReq) if diags.HasError() { return diags.Error() } @@ -3373,33 +4028,48 @@ func newUpdateWorkspaceAssignmentDetail() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &updateWorkspaceAssignmentDetailReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &updateWorkspaceAssignmentDetailWorkspaceIdRaw) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &updateWorkspaceAssignmentDetailReq.PrincipalId) + _, err = fmt.Sscan(args[1], &updateWorkspaceAssignmentDetailPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } - if args[2] != "" { - updateMaskArray := strings.Split(args[2], ",") - updateWorkspaceAssignmentDetailReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateWorkspaceAssignmentDetailReq["update_mask"] = args[2] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updateWorkspaceAssignmentDetailReq.WorkspaceAssignmentDetail.PrincipalId) + _, err = fmt.Sscan(args[3], &updateWorkspaceAssignmentDetailPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[3]) } + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || updateWorkspaceAssignmentDetailAccountIdRaw != "" { + updateWorkspaceAssignmentDetailReq["account_id"] = updateWorkspaceAssignmentDetailAccountIdRaw + } + if cmd.Flags().Changed("principal-id") || updateWorkspaceAssignmentDetailPrincipalIdRaw != 0 { + updateWorkspaceAssignmentDetailReq["principal_id"] = updateWorkspaceAssignmentDetailPrincipalIdRaw + } + if cmd.Flags().Changed("principal-type") || updateWorkspaceAssignmentDetailPrincipalTypeRaw != "" { + updateWorkspaceAssignmentDetailReq["principal_type"] = updateWorkspaceAssignmentDetailPrincipalTypeRaw } + if cmd.Flags().Changed("workspace-id") || updateWorkspaceAssignmentDetailWorkspaceIdRaw != 0 { + updateWorkspaceAssignmentDetailReq["workspace_id"] = updateWorkspaceAssignmentDetailWorkspaceIdRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/accounts/%s/workspaces/%s/workspace-assignment-details/%s", a.Config.AccountID, fmt.Sprint(updateWorkspaceAssignmentDetailWorkspaceIdRaw), fmt.Sprint(updateWorkspaceAssignmentDetailPrincipalIdRaw)) - response, err := a.IamV2.UpdateWorkspaceAssignmentDetail(ctx, updateWorkspaceAssignmentDetailReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updateWorkspaceAssignmentDetailReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/account/ip-access-lists/ip-access-lists.go b/cmd/account/ip-access-lists/ip-access-lists.go index 7e9dab8b09b..e25385ec7bf 100644 --- a/cmd/account/ip-access-lists/ip-access-lists.go +++ b/cmd/account/ip-access-lists/ip-access-lists.go @@ -10,8 +10,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" + + networking "github.com/databricks/cli/libs/sdktypes/networking/v1" + sdknetworking "github.com/databricks/sdk-go/networking/v1" ) // Slice with functions to override default command behavior. @@ -74,13 +76,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *settings.CreateIpAccessList, + *networking.CreateAccountIpAccessListRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq networking.CreateAccountIpAccessListRequest - var createReq settings.CreateIpAccessList var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -131,6 +133,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -145,22 +148,26 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Label = args[0] + createReq.Label = new(args[0]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createReq.ListType) - if err != nil { - return fmt.Errorf("invalid LIST_TYPE: %s", args[1]) - } - + createReq.ListType = networking.AccountIpAccessListType_IpAccessListType(args[1]) } - response, err := a.IpAccessLists.Create(ctx, createReq) + sdkReq, err := networking.CreateAccountIpAccessListRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Networking.CreateAccountIpAccessList(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.CreateAccountIpAccessListResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -181,13 +188,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteAccountIpAccessListRequest, + *sdknetworking.DeleteAccountIpAccessListRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq settings.DeleteAccountIpAccessListRequest + var deleteReq sdknetworking.DeleteAccountIpAccessListRequest cmd.Use = "delete IP_ACCESS_LIST_ID" cmd.Short = `Delete access list.` @@ -202,34 +208,26 @@ func newDelete() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = a - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No IP_ACCESS_LIST_ID argument specified. Loading names for Account Ip Access Lists drop-down.") - names, err := a.IpAccessLists.IpAccessListInfoLabelToListIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id for the corresponding ip access list") - } - deleteReq.IpAccessListId = args[0] + deleteReq.ListId = new(args[0]) - err = a.IpAccessLists.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.Networking.DeleteAccountIpAccessList(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -251,13 +249,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetAccountIpAccessListRequest, + *sdknetworking.GetAccountIpAccessListRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq settings.GetAccountIpAccessListRequest + var getReq sdknetworking.GetAccountIpAccessListRequest cmd.Use = "get IP_ACCESS_LIST_ID" cmd.Short = `Get IP access list.` @@ -272,36 +269,30 @@ func newGet() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = a - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No IP_ACCESS_LIST_ID argument specified. Loading names for Account Ip Access Lists drop-down.") - names, err := a.IpAccessLists.IpAccessListInfoLabelToListIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id for the corresponding ip access list") - } - getReq.IpAccessListId = args[0] + getReq.ListId = new(args[0]) - response, err := a.IpAccessLists.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Networking.GetAccountIpAccessList(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.GetAccountIpAccessListResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -350,7 +341,14 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - response := a.IpAccessLists.List(ctx) + _ = a + + sdkReq := &sdknetworking.ListAccountIpAccessListsRequest{} + + response, err := a.Networking.ListAccountIpAccessLists(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -358,7 +356,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := networking.ListAccountIpAccessListsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.IpAccessLists) } // Disable completions since they are not applicable. @@ -379,13 +381,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var replaceOverrides []func( *cobra.Command, - *settings.ReplaceIpAccessList, + *networking.ReplaceAccountIpAccessListRequest, ) func newReplace() *cobra.Command { cmd := &cobra.Command{} + var replaceReq networking.ReplaceAccountIpAccessListRequest - var replaceReq settings.ReplaceIpAccessList var replaceJson flags.JsonFlag cmd.Flags().Var(&replaceJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -434,6 +436,7 @@ func newReplace() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := replaceJson.Unmarshal(&replaceReq) @@ -447,30 +450,36 @@ func newReplace() *cobra.Command { } } } - replaceReq.IpAccessListId = args[0] + replaceReq.ListId = new(args[0]) if !cmd.Flags().Changed("json") { - replaceReq.Label = args[1] + replaceReq.Label = new(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &replaceReq.ListType) - if err != nil { - return fmt.Errorf("invalid LIST_TYPE: %s", args[2]) - } - + replaceReq.ListType = networking.AccountIpAccessListType_IpAccessListType(args[2]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &replaceReq.Enabled) + var replaceEnabledArg bool + _, err = fmt.Sscan(args[3], &replaceEnabledArg) if err != nil { return fmt.Errorf("invalid ENABLED: %s", args[3]) } + replaceReq.Enabled = &replaceEnabledArg + } + sdkReq, err := networking.ReplaceAccountIpAccessListRequestToSDK(&replaceReq) + if err != nil { + return err + } + response, err := a.Networking.ReplaceAccountIpAccessList(ctx, *sdkReq) + if err != nil { + return err } - err = a.IpAccessLists.Replace(ctx, replaceReq) + out, err := networking.ReplaceAccountIpAccessListResponseFromSDK(response) if err != nil { return err } - return nil + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -491,21 +500,21 @@ func newReplace() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateIpAccessList, + *networking.UpdateAccountIpAccessListRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq networking.UpdateAccountIpAccessListRequest - var updateReq settings.UpdateIpAccessList var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&updateReq.Enabled, "enabled", updateReq.Enabled, `Specifies whether this IP access list is enabled.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Enabled, "enabled", `Specifies whether this IP access list is enabled.`) // TODO: array: ip_addresses - cmd.Flags().StringVar(&updateReq.Label, "label", updateReq.Label, `Label for the IP access list.`) - cmd.Flags().Var(&updateReq.ListType, "list-type", `Supported values: [ALLOW, BLOCK]`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Label, "label", `Label for the IP access list.`) + flags.EnumVar(cmd.Flags(), &updateReq.ListType, "list-type", `Supported values: [ALLOW, BLOCK]`, "ListType", "ALLOW", "BLOCK") cmd.Use = "update IP_ACCESS_LIST_ID" cmd.Short = `Update access list.` @@ -533,10 +542,16 @@ func newUpdate() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -550,30 +565,22 @@ func newUpdate() *cobra.Command { } } } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No IP_ACCESS_LIST_ID argument specified. Loading names for Account Ip Access Lists drop-down.") - names, err := a.IpAccessLists.IpAccessListInfoLabelToListIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list") - if err != nil { - return err - } - args = append(args, id) + updateReq.ListId = new(args[0]) + + sdkReq, err := networking.UpdateAccountIpAccessListRequestToSDK(&updateReq) + if err != nil { + return err } - if len(args) != 1 { - return errors.New("expected to have the id for the corresponding ip access list") + response, err := a.Networking.UpdateAccountIpAccessList(ctx, *sdkReq) + if err != nil { + return err } - updateReq.IpAccessListId = args[0] - err = a.IpAccessLists.Update(ctx, updateReq) + out, err := networking.UpdateAccountIpAccessListResponseFromSDK(response) if err != nil { return err } - return nil + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/llm-proxy-partner-powered-account/llm-proxy-partner-powered-account.go b/cmd/account/llm-proxy-partner-powered-account/llm-proxy-partner-powered-account.go index c81d65af84c..c2e70c5b600 100644 --- a/cmd/account/llm-proxy-partner-powered-account/llm-proxy-partner-powered-account.go +++ b/cmd/account/llm-proxy-partner-powered-account/llm-proxy-partner-powered-account.go @@ -4,12 +4,15 @@ package llm_proxy_partner_powered_account import ( "errors" + "fmt" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" "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/settings" "github.com/spf13/cobra" ) @@ -50,15 +53,16 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetLlmProxyPartnerPoweredAccountRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetLlmProxyPartnerPoweredAccountRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `Get the enable partner powered AI features account setting.` @@ -79,12 +83,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/llm_proxy_partner_powered/names/default", a.Config.AccountID) - response, err := a.Settings.LlmProxyPartnerPoweredAccount().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -106,13 +122,16 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateLlmProxyPartnerPoweredAccountRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateLlmProxyPartnerPoweredAccountRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -131,6 +150,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -147,11 +167,24 @@ func newUpdate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.Settings.LlmProxyPartnerPoweredAccount().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/llm_proxy_partner_powered/names/default", a.Config.AccountID) + + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/account/llm-proxy-partner-powered-enforce/llm-proxy-partner-powered-enforce.go b/cmd/account/llm-proxy-partner-powered-enforce/llm-proxy-partner-powered-enforce.go index 035b0a0accf..1665a6e71ad 100644 --- a/cmd/account/llm-proxy-partner-powered-enforce/llm-proxy-partner-powered-enforce.go +++ b/cmd/account/llm-proxy-partner-powered-enforce/llm-proxy-partner-powered-enforce.go @@ -4,12 +4,15 @@ package llm_proxy_partner_powered_enforce import ( "errors" + "fmt" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" "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/settings" "github.com/spf13/cobra" ) @@ -51,15 +54,16 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetLlmProxyPartnerPoweredEnforceRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetLlmProxyPartnerPoweredEnforceRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `Get the enforcement status of partner powered AI features account setting.` @@ -80,12 +84,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/llm_proxy_partner_powered_enforce/names/default", a.Config.AccountID) - response, err := a.Settings.LlmProxyPartnerPoweredEnforce().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -107,13 +123,16 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateLlmProxyPartnerPoweredEnforceRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateLlmProxyPartnerPoweredEnforceRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -133,6 +152,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -149,11 +169,24 @@ func newUpdate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.Settings.LlmProxyPartnerPoweredEnforce().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/llm_proxy_partner_powered_enforce/names/default", a.Config.AccountID) + + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/account/log-delivery/log-delivery.go b/cmd/account/log-delivery/log-delivery.go index 93310e7aad5..44a1587566d 100644 --- a/cmd/account/log-delivery/log-delivery.go +++ b/cmd/account/log-delivery/log-delivery.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/billing" "github.com/spf13/cobra" + + logdelivery "github.com/databricks/cli/libs/sdktypes/logdelivery/v1" + sdklogdelivery "github.com/databricks/sdk-go/logdelivery/v1" ) // Slice with functions to override default command behavior. @@ -116,13 +119,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *billing.WrappedCreateLogDeliveryConfiguration, + *logdelivery.CreateLogDeliveryConfigurationRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq logdelivery.CreateLogDeliveryConfigurationRequest - var createReq billing.WrappedCreateLogDeliveryConfiguration var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -165,6 +168,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -181,12 +185,20 @@ func newCreate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.LogDelivery.Create(ctx, createReq) + sdkReq, err := logdelivery.CreateLogDeliveryConfigurationRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.LogDelivery.CreateLogDeliveryConfiguration(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := logdelivery.CreateLogDeliveryConfigurationResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -207,13 +219,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *billing.GetLogDeliveryRequest, + *sdklogdelivery.GetLogDeliveryConfigurationRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq billing.GetLogDeliveryRequest + var getReq sdklogdelivery.GetLogDeliveryConfigurationRequest cmd.Use = "get LOG_DELIVERY_CONFIGURATION_ID" cmd.Short = `Get log delivery configuration.` @@ -233,11 +244,12 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No LOG_DELIVERY_CONFIGURATION_ID argument specified. Loading names for Log Delivery drop-down.") - names, err := a.LogDelivery.LogDeliveryConfigurationConfigNameToConfigIdMap(ctx, billing.ListLogDeliveryRequest{}) + names, err := cmdgen.NamedIdMap(ctx, a.LogDelivery.ListLogDeliveryConfigurationIter(ctx, sdklogdelivery.ListLogDeliveryConfigurationRequest{}), []string{"ConfigName"}, []string{"ConfigId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Log Delivery drop-down. Please manually specify required arguments. Original error: %w", err) @@ -251,14 +263,19 @@ func newGet() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the log delivery configuration id of customer") } - getReq.LogDeliveryConfigurationId = args[0] + getReq.ConfigId = new(args[0]) - response, err := a.LogDelivery.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.LogDelivery.GetLogDeliveryConfiguration(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := logdelivery.GetLogDeliveryConfigurationResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -279,27 +296,27 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *billing.ListLogDeliveryRequest, + *logdelivery.ListLogDeliveryConfigurationRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq logdelivery.ListLogDeliveryConfigurationRequest - var listReq billing.ListLogDeliveryRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.CredentialsId, "credentials-id", listReq.CredentialsId, `The Credentials id to filter the search results with.`) - cmd.Flags().Var(&listReq.Status, "status", `The log delivery status to filter the search results with. Supported values: [DISABLED, ENABLED]`) - cmd.Flags().StringVar(&listReq.StorageConfigurationId, "storage-configuration-id", listReq.StorageConfigurationId, `The Storage Configuration id to filter the search results with.`) + flags.StringPtrVar(cmd.Flags(), &listReq.CredentialsId, "credentials-id", `The Credentials id to filter the search results with.`) + flags.EnumVar(cmd.Flags(), &listReq.Status, "status", `The log delivery status to filter the search results with. Supported values: [DISABLED, ENABLED]`, "LogDeliveryConfigStatus", "DISABLED", "ENABLED") + flags.StringPtrVar(cmd.Flags(), &listReq.StorageConfigurationId, "storage-configuration-id", `The Storage Configuration id to filter the search results with.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -322,16 +339,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.LogDelivery.List(ctx, listReq) + sdkReq, err := logdelivery.ListLogDeliveryConfigurationRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.LogDelivery.ListLogDeliveryConfigurationIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, logdelivery.LogDeliveryConfigurationFromSDK)) } // Disable completions since they are not applicable. @@ -352,13 +373,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var patchStatusOverrides []func( *cobra.Command, - *billing.UpdateLogDeliveryConfigurationStatusRequest, + *logdelivery.UpdateLogDeliveryConfigurationRequest, ) func newPatchStatus() *cobra.Command { cmd := &cobra.Command{} + var patchStatusReq logdelivery.UpdateLogDeliveryConfigurationRequest - var patchStatusReq billing.UpdateLogDeliveryConfigurationStatusRequest var patchStatusJson flags.JsonFlag cmd.Flags().Var(&patchStatusJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -402,6 +423,7 @@ func newPatchStatus() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := patchStatusJson.Unmarshal(&patchStatusReq) @@ -415,19 +437,21 @@ func newPatchStatus() *cobra.Command { } } } - patchStatusReq.LogDeliveryConfigurationId = args[0] + patchStatusReq.ConfigId = new(args[0]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &patchStatusReq.Status) - if err != nil { - return fmt.Errorf("invalid STATUS: %s", args[1]) - } - + patchStatusReq.Status = logdelivery.LogDeliveryConfigStatus(args[1]) } - err = a.LogDelivery.PatchStatus(ctx, patchStatusReq) + sdkReq, err := logdelivery.UpdateLogDeliveryConfigurationRequestToSDK(&patchStatusReq) if err != nil { return err } + response, err := a.LogDelivery.UpdateLogDeliveryConfiguration(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } diff --git a/cmd/account/metastore-assignments/metastore-assignments.go b/cmd/account/metastore-assignments/metastore-assignments.go index 622b56f75dd..c6f51a0b6f2 100644 --- a/cmd/account/metastore-assignments/metastore-assignments.go +++ b/cmd/account/metastore-assignments/metastore-assignments.go @@ -9,8 +9,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucmetastores "github.com/databricks/cli/libs/sdktypes/uc/metastores/v1" + sdkucmetastores "github.com/databricks/sdk-go/uc/metastores/v1" ) // Slice with functions to override default command behavior. @@ -51,13 +53,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.AccountsCreateMetastoreAssignment, + *ucmetastores.AccountsCreateMetastoreAssignmentRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq ucmetastores.AccountsCreateMetastoreAssignmentRequest - var createReq catalog.AccountsCreateMetastoreAssignment var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -87,6 +89,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -100,19 +103,25 @@ func newCreate() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &createReq.WorkspaceId) + var createWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &createWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + createReq.WorkspaceId = &createWorkspaceIdArg + createReq.MetastoreId = new(args[1]) - createReq.MetastoreId = args[1] - - response, err := a.MetastoreAssignments.Create(ctx, createReq) + sdkReq, err := ucmetastores.AccountsCreateMetastoreAssignmentRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Metastores.CreateAccountsMetastoreAssignment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. @@ -133,13 +142,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteAccountMetastoreAssignmentRequest, + *sdkucmetastores.AccountsDeleteMetastoreAssignmentRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq catalog.DeleteAccountMetastoreAssignmentRequest + var deleteReq sdkucmetastores.AccountsDeleteMetastoreAssignmentRequest cmd.Use = "delete WORKSPACE_ID METASTORE_ID" cmd.Short = `Delete a metastore assignment.` @@ -165,20 +173,24 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &deleteReq.WorkspaceId) + var deleteWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &deleteWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + deleteReq.WorkspaceId = &deleteWorkspaceIdArg + deleteReq.MetastoreId = new(args[1]) - deleteReq.MetastoreId = args[1] - - response, err := a.MetastoreAssignments.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.Metastores.DeleteAccountsMetastoreAssignment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. @@ -199,13 +211,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetAccountMetastoreAssignmentRequest, + *sdkucmetastores.AccountsGetMetastoreAssignmentRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq catalog.GetAccountMetastoreAssignmentRequest + var getReq sdkucmetastores.AccountsGetMetastoreAssignmentRequest cmd.Use = "get WORKSPACE_ID" cmd.Short = `Gets the metastore assignment for a workspace.` @@ -232,18 +243,26 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &getReq.WorkspaceId) + var getWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &getWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + getReq.WorkspaceId = &getWorkspaceIdArg - response, err := a.MetastoreAssignments.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Metastores.GetMetastoreAssignment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucmetastores.AccountsGetMetastoreAssignmentResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -264,13 +283,13 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListAccountMetastoreAssignmentsRequest, + *sdkucmetastores.AccountsListWorkspaceIdsForMetastoreRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq sdkucmetastores.AccountsListWorkspaceIdsForMetastoreRequest - var listReq catalog.ListAccountMetastoreAssignmentsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -304,10 +323,15 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - listReq.MetastoreId = args[0] + listReq.MetastoreId = new(args[0]) - response := a.MetastoreAssignments.List(ctx, listReq) + sdkReq := &listReq + response, err := a.Metastores.ListMetastoreAssignments(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -315,7 +339,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := ucmetastores.AccountsListWorkspaceIdsForMetastoreResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.WorkspaceIds) } // Disable completions since they are not applicable. @@ -336,13 +364,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.AccountsUpdateMetastoreAssignment, + *ucmetastores.AccountsUpdateMetastoreAssignmentRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucmetastores.AccountsUpdateMetastoreAssignmentRequest - var updateReq catalog.AccountsUpdateMetastoreAssignment var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -373,6 +401,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -386,19 +415,25 @@ func newUpdate() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &updateReq.WorkspaceId) + var updateWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &updateWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + updateReq.WorkspaceId = &updateWorkspaceIdArg + updateReq.MetastoreId = new(args[1]) - updateReq.MetastoreId = args[1] - - response, err := a.MetastoreAssignments.Update(ctx, updateReq) + sdkReq, err := ucmetastores.AccountsUpdateMetastoreAssignmentRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := a.Metastores.UpdateAccountsMetastoreAssignment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. diff --git a/cmd/account/metastores/metastores.go b/cmd/account/metastores/metastores.go index 7967101987f..9de01786dcc 100644 --- a/cmd/account/metastores/metastores.go +++ b/cmd/account/metastores/metastores.go @@ -9,8 +9,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucmetastores "github.com/databricks/cli/libs/sdktypes/uc/metastores/v1" + sdkucmetastores "github.com/databricks/sdk-go/uc/metastores/v1" ) // Slice with functions to override default command behavior. @@ -52,13 +54,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.AccountsCreateMetastore, + *ucmetastores.AccountsCreateMetastoreRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq ucmetastores.AccountsCreateMetastoreRequest - var createReq catalog.AccountsCreateMetastore var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -84,6 +86,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -98,12 +101,20 @@ func newCreate() *cobra.Command { } } - response, err := a.Metastores.Create(ctx, createReq) + sdkReq, err := ucmetastores.AccountsCreateMetastoreRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Metastores.CreateAccountsMetastore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucmetastores.AccountsCreateMetastoreResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -124,15 +135,14 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteAccountMetastoreRequest, + *ucmetastores.AccountsDeleteMetastoreRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq ucmetastores.AccountsDeleteMetastoreRequest - var deleteReq catalog.DeleteAccountMetastoreRequest - - cmd.Flags().BoolVar(&deleteReq.Force, "force", deleteReq.Force, `Force deletion even if the metastore is not empty.`) + flags.BoolPtrVar(cmd.Flags(), &deleteReq.Force, "force", `Force deletion even if the metastore is not empty.`) cmd.Use = "delete METASTORE_ID" cmd.Short = `Delete a metastore.` @@ -156,15 +166,21 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.MetastoreId = args[0] + deleteReq.MetastoreId = new(args[0]) - response, err := a.Metastores.Delete(ctx, deleteReq) + sdkReq, err := ucmetastores.AccountsDeleteMetastoreRequestToSDK(&deleteReq) + if err != nil { + return err + } + response, err := a.Metastores.DeleteAccountsMetastore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. @@ -185,13 +201,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetAccountMetastoreRequest, + *sdkucmetastores.AccountsGetMetastoreRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq catalog.GetAccountMetastoreRequest + var getReq sdkucmetastores.AccountsGetMetastoreRequest cmd.Use = "get METASTORE_ID" cmd.Short = `Get a metastore.` @@ -215,15 +230,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.MetastoreId = args[0] + getReq.MetastoreId = new(args[0]) - response, err := a.Metastores.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Metastores.GetAccountsMetastore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucmetastores.AccountsGetMetastoreResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -272,7 +293,14 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - response := a.Metastores.List(ctx) + _ = a + + sdkReq := &sdkucmetastores.AccountsListMetastoresRequest{} + + response, err := a.Metastores.ListAccountsMetastores(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -280,7 +308,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := ucmetastores.AccountsListMetastoresResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.Metastores) } // Disable completions since they are not applicable. @@ -301,13 +333,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.AccountsUpdateMetastore, + *ucmetastores.AccountsUpdateMetastoreRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucmetastores.AccountsUpdateMetastoreRequest - var updateReq catalog.AccountsUpdateMetastore var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -336,6 +368,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -349,14 +382,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.MetastoreId = args[0] + updateReq.MetastoreId = new(args[0]) - response, err := a.Metastores.Update(ctx, updateReq) + sdkReq, err := ucmetastores.AccountsUpdateMetastoreRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := a.Metastores.UpdateAccountsMetastore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucmetastores.AccountsUpdateMetastoreResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/network-connectivity/network-connectivity.go b/cmd/account/network-connectivity/network-connectivity.go index 3a1b00e18f6..5ab50cbecca 100644 --- a/cmd/account/network-connectivity/network-connectivity.go +++ b/cmd/account/network-connectivity/network-connectivity.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" + + networking "github.com/databricks/cli/libs/sdktypes/networking/v1" + sdknetworking "github.com/databricks/sdk-go/networking/v1" ) // Slice with functions to override default command behavior. @@ -64,14 +67,14 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createNetworkConnectivityConfigurationOverrides []func( *cobra.Command, - *settings.CreateNetworkConnectivityConfigRequest, + *networking.CreateNetworkConnectivityConfigRequest, ) func newCreateNetworkConnectivityConfiguration() *cobra.Command { cmd := &cobra.Command{} + var createNetworkConnectivityConfigurationReq networking.CreateNetworkConnectivityConfigRequest + createNetworkConnectivityConfigurationReq.NetworkConnectivityConfig = &networking.CreateNetworkConnectivityConfiguration{} - var createNetworkConnectivityConfigurationReq settings.CreateNetworkConnectivityConfigRequest - createNetworkConnectivityConfigurationReq.NetworkConnectivityConfig = settings.CreateNetworkConnectivityConfiguration{} var createNetworkConnectivityConfigurationJson flags.JsonFlag cmd.Flags().Var(&createNetworkConnectivityConfigurationJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -122,6 +125,7 @@ func newCreateNetworkConnectivityConfiguration() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createNetworkConnectivityConfigurationJson.Unmarshal(&createNetworkConnectivityConfigurationReq.NetworkConnectivityConfig) @@ -136,18 +140,26 @@ func newCreateNetworkConnectivityConfiguration() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createNetworkConnectivityConfigurationReq.NetworkConnectivityConfig.Name = args[0] + createNetworkConnectivityConfigurationReq.NetworkConnectivityConfig.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createNetworkConnectivityConfigurationReq.NetworkConnectivityConfig.Region = args[1] + createNetworkConnectivityConfigurationReq.NetworkConnectivityConfig.Region = new(args[1]) } - response, err := a.NetworkConnectivity.CreateNetworkConnectivityConfiguration(ctx, createNetworkConnectivityConfigurationReq) + sdkReq, err := networking.CreateNetworkConnectivityConfigRequestToSDK(&createNetworkConnectivityConfigurationReq) + if err != nil { + return err + } + response, err := a.Networking.CreateNetworkConnectivityConfigPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.NetworkConnectivityConfigFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -168,24 +180,24 @@ func newCreateNetworkConnectivityConfiguration() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createPrivateEndpointRuleOverrides []func( *cobra.Command, - *settings.CreatePrivateEndpointRuleRequest, + *networking.CreateNccPrivateEndpointRuleRequest, ) func newCreatePrivateEndpointRule() *cobra.Command { cmd := &cobra.Command{} + var createPrivateEndpointRuleReq networking.CreateNccPrivateEndpointRuleRequest + createPrivateEndpointRuleReq.PrivateEndpointRule = &networking.CreatePrivateEndpointRule{} - var createPrivateEndpointRuleReq settings.CreatePrivateEndpointRuleRequest - createPrivateEndpointRuleReq.PrivateEndpointRule = settings.CreatePrivateEndpointRule{} var createPrivateEndpointRuleJson flags.JsonFlag cmd.Flags().Var(&createPrivateEndpointRuleJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: domain_names - cmd.Flags().StringVar(&createPrivateEndpointRuleReq.PrivateEndpointRule.EndpointService, "endpoint-service", createPrivateEndpointRuleReq.PrivateEndpointRule.EndpointService, `The full target AWS endpoint service name that connects to the destination resources of the private endpoint.`) - cmd.Flags().StringVar(&createPrivateEndpointRuleReq.PrivateEndpointRule.ErrorMessage, "error-message", createPrivateEndpointRuleReq.PrivateEndpointRule.ErrorMessage, ``) + flags.StringPtrVar(cmd.Flags(), &createPrivateEndpointRuleReq.PrivateEndpointRule.EndpointService, "endpoint-service", `The full target AWS endpoint service name that connects to the destination resources of the private endpoint.`) + flags.StringPtrVar(cmd.Flags(), &createPrivateEndpointRuleReq.PrivateEndpointRule.ErrorMessage, "error-message", ``) // TODO: complex arg: gcp_endpoint - cmd.Flags().StringVar(&createPrivateEndpointRuleReq.PrivateEndpointRule.GroupId, "group-id", createPrivateEndpointRuleReq.PrivateEndpointRule.GroupId, `Not used by customer-managed private endpoint services.`) - cmd.Flags().StringVar(&createPrivateEndpointRuleReq.PrivateEndpointRule.ResourceId, "resource-id", createPrivateEndpointRuleReq.PrivateEndpointRule.ResourceId, `The Azure resource ID of the target resource.`) + flags.StringPtrVar(cmd.Flags(), &createPrivateEndpointRuleReq.PrivateEndpointRule.GroupId, "group-id", `Not used by customer-managed private endpoint services.`) + flags.StringPtrVar(cmd.Flags(), &createPrivateEndpointRuleReq.PrivateEndpointRule.ResourceId, "resource-id", `The Azure resource ID of the target resource.`) // TODO: array: resource_names cmd.Use = "create-private-endpoint-rule NETWORK_CONNECTIVITY_CONFIG_ID" @@ -219,6 +231,7 @@ func newCreatePrivateEndpointRule() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createPrivateEndpointRuleJson.Unmarshal(&createPrivateEndpointRuleReq.PrivateEndpointRule) @@ -232,14 +245,22 @@ func newCreatePrivateEndpointRule() *cobra.Command { } } } - createPrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0] + createPrivateEndpointRuleReq.NetworkConnectivityConfigId = new(args[0]) - response, err := a.NetworkConnectivity.CreatePrivateEndpointRule(ctx, createPrivateEndpointRuleReq) + sdkReq, err := networking.CreateNccPrivateEndpointRuleRequestToSDK(&createPrivateEndpointRuleReq) + if err != nil { + return err + } + response, err := a.Networking.CreateNccPrivateEndpointRule(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.NccPrivateEndpointRuleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -260,13 +281,12 @@ func newCreatePrivateEndpointRule() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteNetworkConnectivityConfigurationOverrides []func( *cobra.Command, - *settings.DeleteNetworkConnectivityConfigurationRequest, + *sdknetworking.DeleteNetworkConnectivityConfigRequest, ) func newDeleteNetworkConnectivityConfiguration() *cobra.Command { cmd := &cobra.Command{} - - var deleteNetworkConnectivityConfigurationReq settings.DeleteNetworkConnectivityConfigurationRequest + var deleteNetworkConnectivityConfigurationReq sdknetworking.DeleteNetworkConnectivityConfigRequest cmd.Use = "delete-network-connectivity-configuration NETWORK_CONNECTIVITY_CONFIG_ID" cmd.Short = `Delete a network connectivity configuration.` @@ -290,10 +310,12 @@ func newDeleteNetworkConnectivityConfiguration() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteNetworkConnectivityConfigurationReq.NetworkConnectivityConfigId = args[0] + deleteNetworkConnectivityConfigurationReq.NetworkConnectivityConfigId = new(args[0]) - err = a.NetworkConnectivity.DeleteNetworkConnectivityConfiguration(ctx, deleteNetworkConnectivityConfigurationReq) + sdkReq := &deleteNetworkConnectivityConfigurationReq + err = a.Networking.DeleteNetworkConnectivityConfigPublic(ctx, *sdkReq) if err != nil { return err } @@ -318,13 +340,12 @@ func newDeleteNetworkConnectivityConfiguration() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deletePrivateEndpointRuleOverrides []func( *cobra.Command, - *settings.DeletePrivateEndpointRuleRequest, + *sdknetworking.DeleteNccPrivateEndpointRuleRequest, ) func newDeletePrivateEndpointRule() *cobra.Command { cmd := &cobra.Command{} - - var deletePrivateEndpointRuleReq settings.DeletePrivateEndpointRuleRequest + var deletePrivateEndpointRuleReq sdknetworking.DeleteNccPrivateEndpointRuleRequest cmd.Use = "delete-private-endpoint-rule NETWORK_CONNECTIVITY_CONFIG_ID PRIVATE_ENDPOINT_RULE_ID" cmd.Short = `Delete a private endpoint rule.` @@ -354,16 +375,22 @@ func newDeletePrivateEndpointRule() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deletePrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0] - deletePrivateEndpointRuleReq.PrivateEndpointRuleId = args[1] + deletePrivateEndpointRuleReq.NetworkConnectivityConfigId = new(args[0]) + deletePrivateEndpointRuleReq.PrivateEndpointRuleId = new(args[1]) - response, err := a.NetworkConnectivity.DeletePrivateEndpointRule(ctx, deletePrivateEndpointRuleReq) + sdkReq := &deletePrivateEndpointRuleReq + response, err := a.Networking.DeleteNccPrivateEndpointRule(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.NccPrivateEndpointRuleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -384,13 +411,12 @@ func newDeletePrivateEndpointRule() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getNetworkConnectivityConfigurationOverrides []func( *cobra.Command, - *settings.GetNetworkConnectivityConfigurationRequest, + *sdknetworking.GetNetworkConnectivityConfigRequest, ) func newGetNetworkConnectivityConfiguration() *cobra.Command { cmd := &cobra.Command{} - - var getNetworkConnectivityConfigurationReq settings.GetNetworkConnectivityConfigurationRequest + var getNetworkConnectivityConfigurationReq sdknetworking.GetNetworkConnectivityConfigRequest cmd.Use = "get-network-connectivity-configuration NETWORK_CONNECTIVITY_CONFIG_ID" cmd.Short = `Get a network connectivity configuration.` @@ -414,15 +440,21 @@ func newGetNetworkConnectivityConfiguration() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getNetworkConnectivityConfigurationReq.NetworkConnectivityConfigId = args[0] + getNetworkConnectivityConfigurationReq.NetworkConnectivityConfigId = new(args[0]) - response, err := a.NetworkConnectivity.GetNetworkConnectivityConfiguration(ctx, getNetworkConnectivityConfigurationReq) + sdkReq := &getNetworkConnectivityConfigurationReq + response, err := a.Networking.GetNetworkConnectivityConfigPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.NetworkConnectivityConfigFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -443,13 +475,12 @@ func newGetNetworkConnectivityConfiguration() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPrivateEndpointRuleOverrides []func( *cobra.Command, - *settings.GetPrivateEndpointRuleRequest, + *sdknetworking.GetNccPrivateEndpointRuleRequest, ) func newGetPrivateEndpointRule() *cobra.Command { cmd := &cobra.Command{} - - var getPrivateEndpointRuleReq settings.GetPrivateEndpointRuleRequest + var getPrivateEndpointRuleReq sdknetworking.GetNccPrivateEndpointRuleRequest cmd.Use = "get-private-endpoint-rule NETWORK_CONNECTIVITY_CONFIG_ID PRIVATE_ENDPOINT_RULE_ID" cmd.Short = `Gets a private endpoint rule.` @@ -474,16 +505,22 @@ func newGetPrivateEndpointRule() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getPrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0] - getPrivateEndpointRuleReq.PrivateEndpointRuleId = args[1] + getPrivateEndpointRuleReq.NetworkConnectivityConfigId = new(args[0]) + getPrivateEndpointRuleReq.PrivateEndpointRuleId = new(args[1]) - response, err := a.NetworkConnectivity.GetPrivateEndpointRule(ctx, getPrivateEndpointRuleReq) + sdkReq := &getPrivateEndpointRuleReq + response, err := a.Networking.GetNccPrivateEndpointRule(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.NccPrivateEndpointRuleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -504,13 +541,13 @@ func newGetPrivateEndpointRule() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listNetworkConnectivityConfigurationsOverrides []func( *cobra.Command, - *settings.ListNetworkConnectivityConfigurationsRequest, + *networking.ListNetworkConnectivityConfigsRequest, ) func newListNetworkConnectivityConfigurations() *cobra.Command { cmd := &cobra.Command{} + var listNetworkConnectivityConfigurationsReq networking.ListNetworkConnectivityConfigsRequest - var listNetworkConnectivityConfigurationsReq settings.ListNetworkConnectivityConfigurationsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -520,7 +557,7 @@ func newListNetworkConnectivityConfigurations() *cobra.Command { cmd.Flags().IntVar(&listNetworkConnectivityConfigurationsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listNetworkConnectivityConfigurationsReq.PageToken, "page-token", listNetworkConnectivityConfigurationsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listNetworkConnectivityConfigurationsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-network-connectivity-configurations" @@ -542,16 +579,20 @@ func newListNetworkConnectivityConfigurations() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.NetworkConnectivity.ListNetworkConnectivityConfigurations(ctx, listNetworkConnectivityConfigurationsReq) + sdkReq, err := networking.ListNetworkConnectivityConfigsRequestToSDK(&listNetworkConnectivityConfigurationsReq) + if err != nil { + return err + } if listNetworkConnectivityConfigurationsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listNetworkConnectivityConfigurationsLimit) } if listNetworkConnectivityConfigurationsLimit > 0 { ctx = cmdio.WithLimit(ctx, listNetworkConnectivityConfigurationsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Networking.ListNetworkConnectivityConfigsPublicIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, networking.NetworkConnectivityConfigFromSDK)) } // Disable completions since they are not applicable. @@ -572,13 +613,13 @@ func newListNetworkConnectivityConfigurations() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listPrivateEndpointRulesOverrides []func( *cobra.Command, - *settings.ListPrivateEndpointRulesRequest, + *networking.ListNccPrivateEndpointRulesRequest, ) func newListPrivateEndpointRules() *cobra.Command { cmd := &cobra.Command{} + var listPrivateEndpointRulesReq networking.ListNccPrivateEndpointRulesRequest - var listPrivateEndpointRulesReq settings.ListPrivateEndpointRulesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -588,7 +629,7 @@ func newListPrivateEndpointRules() *cobra.Command { cmd.Flags().IntVar(&listPrivateEndpointRulesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listPrivateEndpointRulesReq.PageToken, "page-token", listPrivateEndpointRulesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listPrivateEndpointRulesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-private-endpoint-rules NETWORK_CONNECTIVITY_CONFIG_ID" @@ -613,18 +654,22 @@ func newListPrivateEndpointRules() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - listPrivateEndpointRulesReq.NetworkConnectivityConfigId = args[0] + listPrivateEndpointRulesReq.NetworkConnectivityConfigId = new(args[0]) - response := a.NetworkConnectivity.ListPrivateEndpointRules(ctx, listPrivateEndpointRulesReq) + sdkReq, err := networking.ListNccPrivateEndpointRulesRequestToSDK(&listPrivateEndpointRulesReq) + if err != nil { + return err + } if listPrivateEndpointRulesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listPrivateEndpointRulesLimit) } if listPrivateEndpointRulesLimit > 0 { ctx = cmdio.WithLimit(ctx, listPrivateEndpointRulesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Networking.ListNccPrivateEndpointRulesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, networking.NccPrivateEndpointRuleFromSDK)) } // Disable completions since they are not applicable. @@ -645,21 +690,21 @@ func newListPrivateEndpointRules() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePrivateEndpointRuleOverrides []func( *cobra.Command, - *settings.UpdateNccPrivateEndpointRuleRequest, + *networking.UpdateNccPrivateEndpointRuleRequest, ) func newUpdatePrivateEndpointRule() *cobra.Command { cmd := &cobra.Command{} + var updatePrivateEndpointRuleReq networking.UpdateNccPrivateEndpointRuleRequest + updatePrivateEndpointRuleReq.PrivateEndpointRule = &networking.UpdatePrivateEndpointRule{} - var updatePrivateEndpointRuleReq settings.UpdateNccPrivateEndpointRuleRequest - updatePrivateEndpointRuleReq.PrivateEndpointRule = settings.UpdatePrivateEndpointRule{} var updatePrivateEndpointRuleJson flags.JsonFlag cmd.Flags().Var(&updatePrivateEndpointRuleJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: domain_names - cmd.Flags().BoolVar(&updatePrivateEndpointRuleReq.PrivateEndpointRule.Enabled, "enabled", updatePrivateEndpointRuleReq.PrivateEndpointRule.Enabled, `Update this field to activate/deactivate this private endpoint to allow egress access from serverless compute resources.`) - cmd.Flags().StringVar(&updatePrivateEndpointRuleReq.PrivateEndpointRule.ErrorMessage, "error-message", updatePrivateEndpointRuleReq.PrivateEndpointRule.ErrorMessage, ``) + flags.BoolPtrVar(cmd.Flags(), &updatePrivateEndpointRuleReq.PrivateEndpointRule.Enabled, "enabled", `Update this field to activate/deactivate this private endpoint to allow egress access from serverless compute resources.`) + flags.StringPtrVar(cmd.Flags(), &updatePrivateEndpointRuleReq.PrivateEndpointRule.ErrorMessage, "error-message", ``) // TODO: complex arg: gcp_endpoint // TODO: array: resource_names @@ -694,6 +739,7 @@ func newUpdatePrivateEndpointRule() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updatePrivateEndpointRuleJson.Unmarshal(&updatePrivateEndpointRuleReq.PrivateEndpointRule) @@ -707,16 +753,24 @@ func newUpdatePrivateEndpointRule() *cobra.Command { } } } - updatePrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0] - updatePrivateEndpointRuleReq.PrivateEndpointRuleId = args[1] - updatePrivateEndpointRuleReq.UpdateMask = args[2] + updatePrivateEndpointRuleReq.NetworkConnectivityConfigId = new(args[0]) + updatePrivateEndpointRuleReq.PrivateEndpointRuleId = new(args[1]) + updatePrivateEndpointRuleReq.UpdateMask = new(args[2]) - response, err := a.NetworkConnectivity.UpdatePrivateEndpointRule(ctx, updatePrivateEndpointRuleReq) + sdkReq, err := networking.UpdateNccPrivateEndpointRuleRequestToSDK(&updatePrivateEndpointRuleReq) + if err != nil { + return err + } + response, err := a.Networking.UpdateNccPrivateEndpointRule(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.NccPrivateEndpointRuleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/network-policies/network-policies.go b/cmd/account/network-policies/network-policies.go index 15cc31d5fa0..58e78042d81 100644 --- a/cmd/account/network-policies/network-policies.go +++ b/cmd/account/network-policies/network-policies.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" + + networking "github.com/databricks/cli/libs/sdktypes/networking/v1" + sdknetworking "github.com/databricks/sdk-go/networking/v1" ) // Slice with functions to override default command behavior. @@ -57,14 +60,14 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createNetworkPolicyRpcOverrides []func( *cobra.Command, - *settings.CreateNetworkPolicyRequest, + *networking.CreateNetworkPolicyRequest, ) func newCreateNetworkPolicyRpc() *cobra.Command { cmd := &cobra.Command{} + var createNetworkPolicyRpcReq networking.CreateNetworkPolicyRequest + createNetworkPolicyRpcReq.NetworkPolicy = &networking.AccountNetworkPolicy{} - var createNetworkPolicyRpcReq settings.CreateNetworkPolicyRequest - createNetworkPolicyRpcReq.NetworkPolicy = settings.AccountNetworkPolicy{} var createNetworkPolicyRpcJson flags.JsonFlag cmd.Flags().Var(&createNetworkPolicyRpcJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -72,7 +75,7 @@ func newCreateNetworkPolicyRpc() *cobra.Command { // TODO: complex arg: egress // TODO: complex arg: ingress // TODO: complex arg: ingress_dry_run - cmd.Flags().StringVar(&createNetworkPolicyRpcReq.NetworkPolicy.NetworkPolicyId, "network-policy-id", createNetworkPolicyRpcReq.NetworkPolicy.NetworkPolicyId, `The unique identifier for the network policy.`) + flags.StringPtrVar(cmd.Flags(), &createNetworkPolicyRpcReq.NetworkPolicy.NetworkPolicyId, "network-policy-id", `The unique identifier for the network policy.`) cmd.Use = "create-network-policy-rpc" cmd.Short = `Create a network policy.` @@ -94,6 +97,7 @@ func newCreateNetworkPolicyRpc() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createNetworkPolicyRpcJson.Unmarshal(&createNetworkPolicyRpcReq.NetworkPolicy) @@ -108,12 +112,20 @@ func newCreateNetworkPolicyRpc() *cobra.Command { } } - response, err := a.NetworkPolicies.CreateNetworkPolicyRpc(ctx, createNetworkPolicyRpcReq) + sdkReq, err := networking.CreateNetworkPolicyRequestToSDK(&createNetworkPolicyRpcReq) + if err != nil { + return err + } + response, err := a.Networking.CreateNetworkPolicyRpc(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.AccountNetworkPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -134,13 +146,12 @@ func newCreateNetworkPolicyRpc() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteNetworkPolicyRpcOverrides []func( *cobra.Command, - *settings.DeleteNetworkPolicyRequest, + *sdknetworking.DeleteNetworkPolicyRequest, ) func newDeleteNetworkPolicyRpc() *cobra.Command { cmd := &cobra.Command{} - - var deleteNetworkPolicyRpcReq settings.DeleteNetworkPolicyRequest + var deleteNetworkPolicyRpcReq sdknetworking.DeleteNetworkPolicyRequest cmd.Use = "delete-network-policy-rpc NETWORK_POLICY_ID" cmd.Short = `Delete a network policy.` @@ -164,10 +175,12 @@ func newDeleteNetworkPolicyRpc() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteNetworkPolicyRpcReq.NetworkPolicyId = args[0] + deleteNetworkPolicyRpcReq.NetworkPolicyId = new(args[0]) - err = a.NetworkPolicies.DeleteNetworkPolicyRpc(ctx, deleteNetworkPolicyRpcReq) + sdkReq := &deleteNetworkPolicyRpcReq + err = a.Networking.DeleteNetworkPolicyRpc(ctx, *sdkReq) if err != nil { return err } @@ -192,13 +205,12 @@ func newDeleteNetworkPolicyRpc() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getNetworkPolicyRpcOverrides []func( *cobra.Command, - *settings.GetNetworkPolicyRequest, + *sdknetworking.GetNetworkPolicyRequest, ) func newGetNetworkPolicyRpc() *cobra.Command { cmd := &cobra.Command{} - - var getNetworkPolicyRpcReq settings.GetNetworkPolicyRequest + var getNetworkPolicyRpcReq sdknetworking.GetNetworkPolicyRequest cmd.Use = "get-network-policy-rpc NETWORK_POLICY_ID" cmd.Short = `Get a network policy.` @@ -222,15 +234,21 @@ func newGetNetworkPolicyRpc() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getNetworkPolicyRpcReq.NetworkPolicyId = args[0] + getNetworkPolicyRpcReq.NetworkPolicyId = new(args[0]) - response, err := a.NetworkPolicies.GetNetworkPolicyRpc(ctx, getNetworkPolicyRpcReq) + sdkReq := &getNetworkPolicyRpcReq + response, err := a.Networking.GetNetworkPolicyRpc(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.AccountNetworkPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -251,13 +269,13 @@ func newGetNetworkPolicyRpc() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listNetworkPoliciesRpcOverrides []func( *cobra.Command, - *settings.ListNetworkPoliciesRequest, + *networking.ListNetworkPoliciesRequest, ) func newListNetworkPoliciesRpc() *cobra.Command { cmd := &cobra.Command{} + var listNetworkPoliciesRpcReq networking.ListNetworkPoliciesRequest - var listNetworkPoliciesRpcReq settings.ListNetworkPoliciesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -267,7 +285,7 @@ func newListNetworkPoliciesRpc() *cobra.Command { cmd.Flags().IntVar(&listNetworkPoliciesRpcLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listNetworkPoliciesRpcReq.PageToken, "page-token", listNetworkPoliciesRpcReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listNetworkPoliciesRpcReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-network-policies-rpc" @@ -289,16 +307,20 @@ func newListNetworkPoliciesRpc() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.NetworkPolicies.ListNetworkPoliciesRpc(ctx, listNetworkPoliciesRpcReq) + sdkReq, err := networking.ListNetworkPoliciesRequestToSDK(&listNetworkPoliciesRpcReq) + if err != nil { + return err + } if listNetworkPoliciesRpcLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listNetworkPoliciesRpcLimit) } if listNetworkPoliciesRpcLimit > 0 { ctx = cmdio.WithLimit(ctx, listNetworkPoliciesRpcLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Networking.ListNetworkPoliciesRpcIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, networking.AccountNetworkPolicyFromSDK)) } // Disable completions since they are not applicable. @@ -319,14 +341,14 @@ func newListNetworkPoliciesRpc() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateNetworkPolicyRpcOverrides []func( *cobra.Command, - *settings.UpdateNetworkPolicyRequest, + *networking.UpdateNetworkPolicyRequest, ) func newUpdateNetworkPolicyRpc() *cobra.Command { cmd := &cobra.Command{} + var updateNetworkPolicyRpcReq networking.UpdateNetworkPolicyRequest + updateNetworkPolicyRpcReq.NetworkPolicy = &networking.AccountNetworkPolicy{} - var updateNetworkPolicyRpcReq settings.UpdateNetworkPolicyRequest - updateNetworkPolicyRpcReq.NetworkPolicy = settings.AccountNetworkPolicy{} var updateNetworkPolicyRpcJson flags.JsonFlag cmd.Flags().Var(&updateNetworkPolicyRpcJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -334,7 +356,7 @@ func newUpdateNetworkPolicyRpc() *cobra.Command { // TODO: complex arg: egress // TODO: complex arg: ingress // TODO: complex arg: ingress_dry_run - cmd.Flags().StringVar(&updateNetworkPolicyRpcReq.NetworkPolicy.NetworkPolicyId, "network-policy-id", updateNetworkPolicyRpcReq.NetworkPolicy.NetworkPolicyId, `The unique identifier for the network policy.`) + flags.StringPtrVar(cmd.Flags(), &updateNetworkPolicyRpcReq.NetworkPolicyId, "network-policy-id", `The unique identifier for the network policy.`) cmd.Use = "update-network-policy-rpc NETWORK_POLICY_ID" cmd.Short = `Update a network policy.` @@ -359,6 +381,7 @@ func newUpdateNetworkPolicyRpc() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateNetworkPolicyRpcJson.Unmarshal(&updateNetworkPolicyRpcReq.NetworkPolicy) @@ -372,14 +395,22 @@ func newUpdateNetworkPolicyRpc() *cobra.Command { } } } - updateNetworkPolicyRpcReq.NetworkPolicyId = args[0] + updateNetworkPolicyRpcReq.NetworkPolicyId = new(args[0]) - response, err := a.NetworkPolicies.UpdateNetworkPolicyRpc(ctx, updateNetworkPolicyRpcReq) + sdkReq, err := networking.UpdateNetworkPolicyRequestToSDK(&updateNetworkPolicyRpcReq) + if err != nil { + return err + } + response, err := a.Networking.UpdateNetworkPolicyRpc(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.AccountNetworkPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/networks/networks.go b/cmd/account/networks/networks.go index ae7318e76b9..6dbe78a8175 100644 --- a/cmd/account/networks/networks.go +++ b/cmd/account/networks/networks.go @@ -7,8 +7,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/provisioning" "github.com/spf13/cobra" + + networking "github.com/databricks/cli/libs/sdktypes/networking/v1" + sdknetworking "github.com/databricks/sdk-go/networking/v1" ) // Slice with functions to override default command behavior. @@ -49,23 +51,23 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *provisioning.CreateNetworkRequest, + *networking.CreateNetworkRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq networking.CreateNetworkRequest - var createReq provisioning.CreateNetworkRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: gcp_network_info - cmd.Flags().StringVar(&createReq.NetworkName, "network-name", createReq.NetworkName, `The human-readable name of the network configuration.`) + flags.StringPtrVar(cmd.Flags(), &createReq.NetworkName, "network-name", `The human-readable name of the network configuration.`) // TODO: array: security_group_ids // TODO: array: subnet_ids // TODO: complex arg: vpc_endpoints - cmd.Flags().StringVar(&createReq.VpcId, "vpc-id", createReq.VpcId, `The ID of the VPC associated with this network configuration.`) + flags.StringPtrVar(cmd.Flags(), &createReq.VpcId, "vpc-id", `The ID of the VPC associated with this network configuration.`) cmd.Use = "create" cmd.Short = `Create network configuration.` @@ -88,6 +90,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -102,12 +105,20 @@ func newCreate() *cobra.Command { } } - response, err := a.Networks.Create(ctx, createReq) + sdkReq, err := networking.CreateNetworkRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Networking.CreateNetworkPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.NetworkFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -128,13 +139,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *provisioning.DeleteNetworkRequest, + *sdknetworking.DeleteNetworkRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq provisioning.DeleteNetworkRequest + var deleteReq sdknetworking.DeleteNetworkRequest cmd.Use = "delete NETWORK_ID" cmd.Short = `Delete a network configuration.` @@ -163,15 +173,21 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.NetworkId = args[0] + deleteReq.NetworkId = new(args[0]) - response, err := a.Networks.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.Networking.DeleteNetworkPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.NetworkFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -192,13 +208,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *provisioning.GetNetworkRequest, + *sdknetworking.GetNetworkRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq provisioning.GetNetworkRequest + var getReq sdknetworking.GetNetworkRequest cmd.Use = "get NETWORK_ID" cmd.Short = `Get a network configuration.` @@ -223,15 +238,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.NetworkId = args[0] + getReq.NetworkId = new(args[0]) - response, err := a.Networks.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Networking.GetNetworkPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.NetworkFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -271,12 +292,17 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - response, err := a.Networks.List(ctx) + _ = a + + sdkReq := &sdknetworking.ListNetworkRequest{} + + response, err := a.Networking.ListNetworkPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. diff --git a/cmd/account/o-auth-published-apps/o-auth-published-apps.go b/cmd/account/o-auth-published-apps/o-auth-published-apps.go index 89b96f0fadb..2f98ba337b9 100644 --- a/cmd/account/o-auth-published-apps/o-auth-published-apps.go +++ b/cmd/account/o-auth-published-apps/o-auth-published-apps.go @@ -7,9 +7,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/oauth2" + "github.com/databricks/cli/libs/flags" "github.com/spf13/cobra" + + oauth "github.com/databricks/cli/libs/sdktypes/oauth/v1" ) // Slice with functions to override default command behavior. @@ -49,25 +52,25 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *oauth2.ListOAuthPublishedAppsRequest, + *oauth.ListPublishedOAuthAppsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq oauth.ListPublishedOAuthAppsRequest - var listReq oauth2.ListOAuthPublishedAppsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `The max number of OAuth published apps to return in one page.`) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", `The max number of OAuth published apps to return in one page.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -89,16 +92,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.OAuthPublishedApps.List(ctx, listReq) + sdkReq, err := oauth.ListPublishedOAuthAppsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.OAuth.ListPublishedOAuthAppsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, oauth.PublishedOAuthAppFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/account/personal-compute/personal-compute.go b/cmd/account/personal-compute/personal-compute.go index 1e6c3569975..4c58fe8a914 100644 --- a/cmd/account/personal-compute/personal-compute.go +++ b/cmd/account/personal-compute/personal-compute.go @@ -4,12 +4,15 @@ package personal_compute import ( "errors" + "fmt" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" "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/settings" "github.com/spf13/cobra" ) @@ -59,15 +62,16 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeletePersonalComputeSettingRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeletePersonalComputeSettingRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `Delete Personal Compute setting.` @@ -88,12 +92,24 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/dcp_acct_enable/names/default", a.Config.AccountID) - response, err := a.Settings.PersonalCompute().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -115,15 +131,16 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetPersonalComputeSettingRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetPersonalComputeSettingRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `Get Personal Compute setting.` @@ -144,12 +161,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/dcp_acct_enable/names/default", a.Config.AccountID) - response, err := a.Settings.PersonalCompute().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -171,13 +200,16 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdatePersonalComputeSettingRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdatePersonalComputeSettingRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -196,6 +228,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -212,11 +245,24 @@ func newUpdate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.Settings.PersonalCompute().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := fmt.Sprintf("/api/2.0/accounts/%s/settings/types/dcp_acct_enable/names/default", a.Config.AccountID) + + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/account/private-access/private-access.go b/cmd/account/private-access/private-access.go index 779cad0cff7..c96b8ba8a0f 100644 --- a/cmd/account/private-access/private-access.go +++ b/cmd/account/private-access/private-access.go @@ -7,8 +7,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/provisioning" "github.com/spf13/cobra" + + networking "github.com/databricks/cli/libs/sdktypes/networking/v1" + sdknetworking "github.com/databricks/sdk-go/networking/v1" ) // Slice with functions to override default command behavior. @@ -49,22 +51,22 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *provisioning.CreatePrivateAccessSettingsRequest, + *networking.CreatePrivateAccessSettingsRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq networking.CreatePrivateAccessSettingsRequest - var createReq provisioning.CreatePrivateAccessSettingsRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: allowed_vpc_endpoint_ids - cmd.Flags().Var(&createReq.PrivateAccessLevel, "private-access-level", `The private access level controls which VPC endpoints can connect to the UI or API of any workspace that attaches this private access settings object. Supported values: [ACCOUNT, ENDPOINT]`) - cmd.Flags().StringVar(&createReq.PrivateAccessSettingsName, "private-access-settings-name", createReq.PrivateAccessSettingsName, `The human-readable name of the private access settings object.`) - cmd.Flags().BoolVar(&createReq.PublicAccessEnabled, "public-access-enabled", createReq.PublicAccessEnabled, `Determines if the workspace can be accessed over public internet.`) - cmd.Flags().StringVar(&createReq.Region, "region", createReq.Region, `The AWS region for workspaces attached to this private access settings object.`) + flags.EnumVar(cmd.Flags(), &createReq.PrivateAccessLevel, "private-access-level", `The private access level controls which VPC endpoints can connect to the UI or API of any workspace that attaches this private access settings object. Supported values: [ACCOUNT, ENDPOINT]`, "PrivateAccessLevel", "ACCOUNT", "ENDPOINT") + flags.StringPtrVar(cmd.Flags(), &createReq.PrivateAccessSettingsName, "private-access-settings-name", `The human-readable name of the private access settings object.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.PublicAccessEnabled, "public-access-enabled", `Determines if the workspace can be accessed over public internet.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Region, "region", `The AWS region for workspaces attached to this private access settings object.`) cmd.Use = "create" cmd.Short = `Create private access settings.` @@ -88,6 +90,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -102,12 +105,20 @@ func newCreate() *cobra.Command { } } - response, err := a.PrivateAccess.Create(ctx, createReq) + sdkReq, err := networking.CreatePrivateAccessSettingsRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Networking.CreatePrivateAccessSettingsPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.PrivateAccessSettingsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -128,13 +139,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *provisioning.DeletePrivateAccesRequest, + *sdknetworking.DeletePrivateAccessSettingsRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq provisioning.DeletePrivateAccesRequest + var deleteReq sdknetworking.DeletePrivateAccessSettingsRequest cmd.Use = "delete PRIVATE_ACCESS_SETTINGS_ID" cmd.Short = `Delete private access settings.` @@ -156,15 +166,21 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.PrivateAccessSettingsId = args[0] + deleteReq.PrivateAccessSettingsId = new(args[0]) - response, err := a.PrivateAccess.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.Networking.DeletePrivateAccessSettingsPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.PrivateAccessSettingsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -185,13 +201,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *provisioning.GetPrivateAccesRequest, + *sdknetworking.GetPrivateAccessSettingsRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq provisioning.GetPrivateAccesRequest + var getReq sdknetworking.GetPrivateAccessSettingsRequest cmd.Use = "get PRIVATE_ACCESS_SETTINGS_ID" cmd.Short = `Get private access settings.` @@ -212,15 +227,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.PrivateAccessSettingsId = args[0] + getReq.PrivateAccessSettingsId = new(args[0]) - response, err := a.PrivateAccess.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Networking.GetPrivateAccessSettingsPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.PrivateAccessSettingsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -260,12 +281,17 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - response, err := a.PrivateAccess.List(ctx) + _ = a + + sdkReq := &sdknetworking.ListPrivateAccessSettingsRequest{} + + response, err := a.Networking.ListPrivateAccessSettingsPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. @@ -286,23 +312,23 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var replaceOverrides []func( *cobra.Command, - *provisioning.ReplacePrivateAccessSettingsRequest, + *networking.UpdatePrivateAccessSettingsRequest, ) func newReplace() *cobra.Command { cmd := &cobra.Command{} + var replaceReq networking.UpdatePrivateAccessSettingsRequest + replaceReq.CustomerFacingPrivateAccessSettings = &networking.PrivateAccessSettings{} - var replaceReq provisioning.ReplacePrivateAccessSettingsRequest - replaceReq.CustomerFacingPrivateAccessSettings = provisioning.PrivateAccessSettings{} var replaceJson flags.JsonFlag cmd.Flags().Var(&replaceJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: allowed_vpc_endpoint_ids - cmd.Flags().Var(&replaceReq.CustomerFacingPrivateAccessSettings.PrivateAccessLevel, "private-access-level", `The private access level controls which VPC endpoints can connect to the UI or API of any workspace that attaches this private access settings object. Supported values: [ACCOUNT, ENDPOINT]`) - cmd.Flags().StringVar(&replaceReq.CustomerFacingPrivateAccessSettings.PrivateAccessSettingsName, "private-access-settings-name", replaceReq.CustomerFacingPrivateAccessSettings.PrivateAccessSettingsName, `The human-readable name of the private access settings object.`) - cmd.Flags().BoolVar(&replaceReq.CustomerFacingPrivateAccessSettings.PublicAccessEnabled, "public-access-enabled", replaceReq.CustomerFacingPrivateAccessSettings.PublicAccessEnabled, `Determines if the workspace can be accessed over public internet.`) - cmd.Flags().StringVar(&replaceReq.CustomerFacingPrivateAccessSettings.Region, "region", replaceReq.CustomerFacingPrivateAccessSettings.Region, `The AWS region for workspaces attached to this private access settings object.`) + flags.EnumVar(cmd.Flags(), &replaceReq.CustomerFacingPrivateAccessSettings.PrivateAccessLevel, "private-access-level", `The private access level controls which VPC endpoints can connect to the UI or API of any workspace that attaches this private access settings object. Supported values: [ACCOUNT, ENDPOINT]`, "PrivateAccessLevel", "ACCOUNT", "ENDPOINT") + flags.StringPtrVar(cmd.Flags(), &replaceReq.CustomerFacingPrivateAccessSettings.PrivateAccessSettingsName, "private-access-settings-name", `The human-readable name of the private access settings object.`) + flags.BoolPtrVar(cmd.Flags(), &replaceReq.CustomerFacingPrivateAccessSettings.PublicAccessEnabled, "public-access-enabled", `Determines if the workspace can be accessed over public internet.`) + flags.StringPtrVar(cmd.Flags(), &replaceReq.CustomerFacingPrivateAccessSettings.Region, "region", `The AWS region for workspaces attached to this private access settings object.`) cmd.Use = "replace PRIVATE_ACCESS_SETTINGS_ID" cmd.Short = `Update private access settings.` @@ -338,6 +364,7 @@ func newReplace() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := replaceJson.Unmarshal(&replaceReq.CustomerFacingPrivateAccessSettings) @@ -351,14 +378,22 @@ func newReplace() *cobra.Command { } } } - replaceReq.PrivateAccessSettingsId = args[0] + replaceReq.CustomerFacingPrivateAccessSettings.PrivateAccessSettingsId = new(args[0]) - response, err := a.PrivateAccess.Replace(ctx, replaceReq) + sdkReq, err := networking.UpdatePrivateAccessSettingsRequestToSDK(&replaceReq) + if err != nil { + return err + } + response, err := a.Networking.UpdatePrivateAccessSettingsPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.PrivateAccessSettingsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/private-network-gateways/private-network-gateways.go b/cmd/account/private-network-gateways/private-network-gateways.go index aae82a8b651..2f19929ab58 100644 --- a/cmd/account/private-network-gateways/private-network-gateways.go +++ b/cmd/account/private-network-gateways/private-network-gateways.go @@ -5,17 +5,19 @@ package private_network_gateways import ( "errors" "fmt" - "strings" "time" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" "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/experimental/api" - "github.com/databricks/databricks-sdk-go/service/networking" "github.com/spf13/cobra" + + networking "github.com/databricks/cli/libs/sdktypes/networking/v1" + sdknetworking "github.com/databricks/sdk-go/networking/v1" ) // Slice with functions to override default command behavior. @@ -61,14 +63,22 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createPrivateNetworkGatewayOverrides []func( *cobra.Command, - *networking.CreatePrivateNetworkGatewayRequest, + *map[string]any, ) func newCreatePrivateNetworkGateway() *cobra.Command { cmd := &cobra.Command{} + var createPrivateNetworkGatewayReq map[string]any + createPrivateNetworkGatewayReq = map[string]any{} + var createPrivateNetworkGatewayParentRaw string + var createPrivateNetworkGatewayRequestIdRaw string + var createPrivateNetworkGatewayBandwidthTierGigabitsPerSecondRaw int + var createPrivateNetworkGatewayDisplayNameRaw string + var createPrivateNetworkGatewayErrorMessageRaw string + var createPrivateNetworkGatewayNameRaw string + var createPrivateNetworkGatewayStateRaw string + var createPrivateNetworkGatewayTrafficModeRaw string - var createPrivateNetworkGatewayReq networking.CreatePrivateNetworkGatewayRequest - createPrivateNetworkGatewayReq.PrivateNetworkGateway = networking.PrivateNetworkGateway{} var createPrivateNetworkGatewayJson flags.JsonFlag var createPrivateNetworkGatewaySkipWait bool @@ -79,12 +89,12 @@ func newCreatePrivateNetworkGateway() *cobra.Command { cmd.Flags().Var(&createPrivateNetworkGatewayJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createPrivateNetworkGatewayReq.RequestId, "request-id", createPrivateNetworkGatewayReq.RequestId, `A unique identifier for this request.`) + cmd.Flags().StringVar(&createPrivateNetworkGatewayRequestIdRaw, "request-id", createPrivateNetworkGatewayRequestIdRaw, `A unique identifier for this request.`) // TODO: complex arg: aws_cloud_connection // TODO: complex arg: azure_cloud_connection - cmd.Flags().IntVar(&createPrivateNetworkGatewayReq.PrivateNetworkGateway.BandwidthTierGigabitsPerSecond, "bandwidth-tier-gigabits-per-second", createPrivateNetworkGatewayReq.PrivateNetworkGateway.BandwidthTierGigabitsPerSecond, `The provisioned bandwidth tier for an Azure gateway, in gigabits per second.`) + cmd.Flags().IntVar(&createPrivateNetworkGatewayBandwidthTierGigabitsPerSecondRaw, "bandwidth-tier-gigabits-per-second", createPrivateNetworkGatewayBandwidthTierGigabitsPerSecondRaw, `The provisioned bandwidth tier for an Azure gateway, in gigabits per second.`) // TODO: array: destinations - cmd.Flags().StringVar(&createPrivateNetworkGatewayReq.PrivateNetworkGateway.Name, "name", createPrivateNetworkGatewayReq.PrivateNetworkGateway.Name, `The canonical resource name of the gateway, in the form accounts/{account_id}/network-connectivity-configs/{ncc_id}/private-network-gateways/{gateway_id}.`) + cmd.Flags().StringVar(&createPrivateNetworkGatewayNameRaw, "name", createPrivateNetworkGatewayNameRaw, `The canonical resource name of the gateway, in the form accounts/{account_id}/network-connectivity-configs/{ncc_id}/private-network-gateways/{gateway_id}.`) // TODO: array: private_dns_resolvers cmd.Use = "create-private-network-gateway PARENT DISPLAY_NAME TRAFFIC_MODE" @@ -124,9 +134,10 @@ func newCreatePrivateNetworkGateway() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := createPrivateNetworkGatewayJson.Unmarshal(&createPrivateNetworkGatewayReq.PrivateNetworkGateway) + diags := createPrivateNetworkGatewayJson.Unmarshal(&createPrivateNetworkGatewayReq) if diags.HasError() { return diags.Error() } @@ -137,54 +148,48 @@ func newCreatePrivateNetworkGateway() *cobra.Command { } } } - createPrivateNetworkGatewayReq.Parent = args[0] + createPrivateNetworkGatewayParentRaw = args[0] if !cmd.Flags().Changed("json") { - createPrivateNetworkGatewayReq.PrivateNetworkGateway.DisplayName = args[1] + createPrivateNetworkGatewayDisplayNameRaw = args[1] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &createPrivateNetworkGatewayReq.PrivateNetworkGateway.TrafficMode) - if err != nil { - return fmt.Errorf("invalid TRAFFIC_MODE: %s", args[2]) - } - + createPrivateNetworkGatewayTrafficModeRaw = args[2] } - // Determine which mode to execute based on flags. - switch { - case createPrivateNetworkGatewaySkipWait: - wait, err := a.PrivateNetworkGateways.CreatePrivateNetworkGateway(ctx, createPrivateNetworkGatewayReq) - if err != nil { - return err - } - - // Return operation immediately without waiting. - operation, err := a.PrivateNetworkGateways.GetPrivateNetworkGatewayOperation(ctx, networking.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) - - default: - wait, err := a.PrivateNetworkGateways.CreatePrivateNetworkGateway(ctx, createPrivateNetworkGatewayReq) - if err != nil { - return err - } - - // Show spinner while waiting for completion. - sp := cmdio.NewSpinner(ctx) - sp.Update("Waiting for create-private-network-gateway to complete...") + rawQuery := map[string]any{} + if cmd.Flags().Changed("request-id") || createPrivateNetworkGatewayRequestIdRaw != "" { + rawQuery["request_id"] = createPrivateNetworkGatewayRequestIdRaw + } + if cmd.Flags().Changed("bandwidth-tier-gigabits-per-second") || createPrivateNetworkGatewayBandwidthTierGigabitsPerSecondRaw != 0 { + createPrivateNetworkGatewayReq["bandwidth_tier_gigabits_per_second"] = createPrivateNetworkGatewayBandwidthTierGigabitsPerSecondRaw + } + if cmd.Flags().Changed("display-name") || createPrivateNetworkGatewayDisplayNameRaw != "" { + createPrivateNetworkGatewayReq["display_name"] = createPrivateNetworkGatewayDisplayNameRaw + } + if cmd.Flags().Changed("error-message") || createPrivateNetworkGatewayErrorMessageRaw != "" { + createPrivateNetworkGatewayReq["error_message"] = createPrivateNetworkGatewayErrorMessageRaw + } + if cmd.Flags().Changed("name") || createPrivateNetworkGatewayNameRaw != "" { + createPrivateNetworkGatewayReq["name"] = createPrivateNetworkGatewayNameRaw + } + if cmd.Flags().Changed("state") || createPrivateNetworkGatewayStateRaw != "" { + createPrivateNetworkGatewayReq["state"] = createPrivateNetworkGatewayStateRaw + } + if cmd.Flags().Changed("traffic-mode") || createPrivateNetworkGatewayTrafficModeRaw != "" { + createPrivateNetworkGatewayReq["traffic_mode"] = createPrivateNetworkGatewayTrafficModeRaw + } + rawPath := fmt.Sprintf("/api/networking/v1/%s/private-network-gateways", fmt.Sprint(createPrivateNetworkGatewayParentRaw)) - // Wait for completion. - opts := api.WithTimeout(createPrivateNetworkGatewayTimeout) - response, err := wait.Wait(ctx, opts) - if err != nil { - return err - } - sp.Close() - return cmdio.Render(ctx, response) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, nil, rawQuery, createPrivateNetworkGatewayReq, &response) + if err != nil { + return err } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -205,13 +210,12 @@ func newCreatePrivateNetworkGateway() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deletePrivateNetworkGatewayOverrides []func( *cobra.Command, - *networking.DeletePrivateNetworkGatewayRequest, + *sdknetworking.DeleteEndpointRequest, ) func newDeletePrivateNetworkGateway() *cobra.Command { cmd := &cobra.Command{} - - var deletePrivateNetworkGatewayReq networking.DeletePrivateNetworkGatewayRequest + var deletePrivateNetworkGatewayReq sdknetworking.DeleteEndpointRequest cmd.Use = "delete-private-network-gateway NAME" cmd.Short = `Delete a private network gateway.` @@ -235,10 +239,12 @@ func newDeletePrivateNetworkGateway() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deletePrivateNetworkGatewayReq.Name = args[0] + deletePrivateNetworkGatewayReq.Name = new(args[0]) - err = a.PrivateNetworkGateways.DeletePrivateNetworkGateway(ctx, deletePrivateNetworkGatewayReq) + sdkReq := &deletePrivateNetworkGatewayReq + err = a.Networking.DeleteEndpoint(ctx, *sdkReq) if err != nil { return err } @@ -263,13 +269,12 @@ func newDeletePrivateNetworkGateway() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPrivateNetworkGatewayOverrides []func( *cobra.Command, - *networking.GetPrivateNetworkGatewayRequest, + *sdknetworking.GetEndpointRequest, ) func newGetPrivateNetworkGateway() *cobra.Command { cmd := &cobra.Command{} - - var getPrivateNetworkGatewayReq networking.GetPrivateNetworkGatewayRequest + var getPrivateNetworkGatewayReq sdknetworking.GetEndpointRequest cmd.Use = "get-private-network-gateway NAME" cmd.Short = `Get a private network gateway.` @@ -293,15 +298,21 @@ func newGetPrivateNetworkGateway() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getPrivateNetworkGatewayReq.Name = args[0] + getPrivateNetworkGatewayReq.Name = new(args[0]) - response, err := a.PrivateNetworkGateways.GetPrivateNetworkGateway(ctx, getPrivateNetworkGatewayReq) + sdkReq := &getPrivateNetworkGatewayReq + response, err := a.Networking.GetEndpoint(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.EndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -322,13 +333,12 @@ func newGetPrivateNetworkGateway() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPrivateNetworkGatewayOperationOverrides []func( *cobra.Command, - *networking.GetOperationRequest, + *sdknetworking.GetEndpointRequest, ) func newGetPrivateNetworkGatewayOperation() *cobra.Command { cmd := &cobra.Command{} - - var getPrivateNetworkGatewayOperationReq networking.GetOperationRequest + var getPrivateNetworkGatewayOperationReq sdknetworking.GetEndpointRequest cmd.Use = "get-private-network-gateway-operation NAME" cmd.Short = `Get a private network gateway operation.` @@ -352,15 +362,21 @@ func newGetPrivateNetworkGatewayOperation() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getPrivateNetworkGatewayOperationReq.Name = args[0] + getPrivateNetworkGatewayOperationReq.Name = new(args[0]) - response, err := a.PrivateNetworkGateways.GetPrivateNetworkGatewayOperation(ctx, getPrivateNetworkGatewayOperationReq) + sdkReq := &getPrivateNetworkGatewayOperationReq + response, err := a.Networking.GetEndpoint(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.EndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -381,13 +397,16 @@ func newGetPrivateNetworkGatewayOperation() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listPrivateNetworkGatewaysOverrides []func( *cobra.Command, - *networking.ListPrivateNetworkGatewaysRequest, + *map[string]any, ) func newListPrivateNetworkGateways() *cobra.Command { cmd := &cobra.Command{} + var listPrivateNetworkGatewaysReq map[string]any + listPrivateNetworkGatewaysReq = map[string]any{} + var listPrivateNetworkGatewaysPageTokenRaw string + var listPrivateNetworkGatewaysParentRaw string - var listPrivateNetworkGatewaysReq networking.ListPrivateNetworkGatewaysRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -397,7 +416,7 @@ func newListPrivateNetworkGateways() *cobra.Command { cmd.Flags().IntVar(&listPrivateNetworkGatewaysLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listPrivateNetworkGatewaysReq.PageToken, "page-token", listPrivateNetworkGatewaysReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listPrivateNetworkGatewaysPageTokenRaw, "page-token", listPrivateNetworkGatewaysPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-private-network-gateways PARENT" @@ -422,18 +441,30 @@ func newListPrivateNetworkGateways() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - listPrivateNetworkGatewaysReq.Parent = args[0] + listPrivateNetworkGatewaysParentRaw = args[0] - response := a.PrivateNetworkGateways.ListPrivateNetworkGateways(ctx, listPrivateNetworkGatewaysReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("page-token") || listPrivateNetworkGatewaysPageTokenRaw != "" { + rawQuery["page_token"] = listPrivateNetworkGatewaysPageTokenRaw + } + rawPath := fmt.Sprintf("/api/networking/v1/%s/private-network-gateways", fmt.Sprint(listPrivateNetworkGatewaysParentRaw)) + + maps.Copy(rawQuery, listPrivateNetworkGatewaysReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, nil, rawQuery, nil, &response) + if err != nil { + return err + } if listPrivateNetworkGatewaysLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listPrivateNetworkGatewaysLimit) } - if listPrivateNetworkGatewaysLimit > 0 { - ctx = cmdio.WithLimit(ctx, listPrivateNetworkGatewaysLimit) - } - - return cmdio.RenderIterator(ctx, response) + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -454,23 +485,29 @@ func newListPrivateNetworkGateways() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePrivateNetworkGatewayOverrides []func( *cobra.Command, - *networking.UpdatePrivateNetworkGatewayRequest, + *map[string]any, ) func newUpdatePrivateNetworkGateway() *cobra.Command { cmd := &cobra.Command{} + var updatePrivateNetworkGatewayReq map[string]any + updatePrivateNetworkGatewayReq = map[string]any{} + var updatePrivateNetworkGatewayNameRaw string + var updatePrivateNetworkGatewayBandwidthTierGigabitsPerSecondRaw int + var updatePrivateNetworkGatewayDisplayNameRaw string + var updatePrivateNetworkGatewayErrorMessageRaw string + var updatePrivateNetworkGatewayStateRaw string + var updatePrivateNetworkGatewayTrafficModeRaw string - var updatePrivateNetworkGatewayReq networking.UpdatePrivateNetworkGatewayRequest - updatePrivateNetworkGatewayReq.PrivateNetworkGateway = networking.PrivateNetworkGateway{} var updatePrivateNetworkGatewayJson flags.JsonFlag cmd.Flags().Var(&updatePrivateNetworkGatewayJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: aws_cloud_connection // TODO: complex arg: azure_cloud_connection - cmd.Flags().IntVar(&updatePrivateNetworkGatewayReq.PrivateNetworkGateway.BandwidthTierGigabitsPerSecond, "bandwidth-tier-gigabits-per-second", updatePrivateNetworkGatewayReq.PrivateNetworkGateway.BandwidthTierGigabitsPerSecond, `The provisioned bandwidth tier for an Azure gateway, in gigabits per second.`) + cmd.Flags().IntVar(&updatePrivateNetworkGatewayBandwidthTierGigabitsPerSecondRaw, "bandwidth-tier-gigabits-per-second", updatePrivateNetworkGatewayBandwidthTierGigabitsPerSecondRaw, `The provisioned bandwidth tier for an Azure gateway, in gigabits per second.`) // TODO: array: destinations - cmd.Flags().StringVar(&updatePrivateNetworkGatewayReq.PrivateNetworkGateway.Name, "name", updatePrivateNetworkGatewayReq.PrivateNetworkGateway.Name, `The canonical resource name of the gateway, in the form accounts/{account_id}/network-connectivity-configs/{ncc_id}/private-network-gateways/{gateway_id}.`) + cmd.Flags().StringVar(&updatePrivateNetworkGatewayNameRaw, "name", updatePrivateNetworkGatewayNameRaw, `The canonical resource name of the gateway, in the form accounts/{account_id}/network-connectivity-configs/{ncc_id}/private-network-gateways/{gateway_id}.`) // TODO: array: private_dns_resolvers cmd.Use = "update-private-network-gateway NAME UPDATE_MASK DISPLAY_NAME TRAFFIC_MODE" @@ -507,9 +544,10 @@ func newUpdatePrivateNetworkGateway() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { - diags := updatePrivateNetworkGatewayJson.Unmarshal(&updatePrivateNetworkGatewayReq.PrivateNetworkGateway) + diags := updatePrivateNetworkGatewayJson.Unmarshal(&updatePrivateNetworkGatewayReq) if diags.HasError() { return diags.Error() } @@ -520,27 +558,47 @@ func newUpdatePrivateNetworkGateway() *cobra.Command { } } } - updatePrivateNetworkGatewayReq.Name = args[0] + updatePrivateNetworkGatewayNameRaw = args[0] if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updatePrivateNetworkGatewayReq.UpdateMask = *fieldmask.New(updateMaskArray) + updatePrivateNetworkGatewayReq["update_mask"] = args[1] } if !cmd.Flags().Changed("json") { - updatePrivateNetworkGatewayReq.PrivateNetworkGateway.DisplayName = args[2] + updatePrivateNetworkGatewayDisplayNameRaw = args[2] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updatePrivateNetworkGatewayReq.PrivateNetworkGateway.TrafficMode) - if err != nil { - return fmt.Errorf("invalid TRAFFIC_MODE: %s", args[3]) - } + updatePrivateNetworkGatewayTrafficModeRaw = args[3] + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("bandwidth-tier-gigabits-per-second") || updatePrivateNetworkGatewayBandwidthTierGigabitsPerSecondRaw != 0 { + updatePrivateNetworkGatewayReq["bandwidth_tier_gigabits_per_second"] = updatePrivateNetworkGatewayBandwidthTierGigabitsPerSecondRaw + } + if cmd.Flags().Changed("display-name") || updatePrivateNetworkGatewayDisplayNameRaw != "" { + updatePrivateNetworkGatewayReq["display_name"] = updatePrivateNetworkGatewayDisplayNameRaw + } + if cmd.Flags().Changed("error-message") || updatePrivateNetworkGatewayErrorMessageRaw != "" { + updatePrivateNetworkGatewayReq["error_message"] = updatePrivateNetworkGatewayErrorMessageRaw } + if cmd.Flags().Changed("name") || updatePrivateNetworkGatewayNameRaw != "" { + updatePrivateNetworkGatewayReq["name"] = updatePrivateNetworkGatewayNameRaw + } + if cmd.Flags().Changed("state") || updatePrivateNetworkGatewayStateRaw != "" { + updatePrivateNetworkGatewayReq["state"] = updatePrivateNetworkGatewayStateRaw + } + if cmd.Flags().Changed("traffic-mode") || updatePrivateNetworkGatewayTrafficModeRaw != "" { + updatePrivateNetworkGatewayReq["traffic_mode"] = updatePrivateNetworkGatewayTrafficModeRaw + } + rawPath := fmt.Sprintf("/api/networking/v1/%s", fmt.Sprint(updatePrivateNetworkGatewayNameRaw)) - response, err := a.PrivateNetworkGateways.UpdatePrivateNetworkGateway(ctx, updatePrivateNetworkGatewayReq) + api, err := apiclient.New(a.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, nil, rawQuery, updatePrivateNetworkGatewayReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/account/published-app-integration/published-app-integration.go b/cmd/account/published-app-integration/published-app-integration.go index d49f9013eac..e6809ffd368 100644 --- a/cmd/account/published-app-integration/published-app-integration.go +++ b/cmd/account/published-app-integration/published-app-integration.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/oauth2" "github.com/spf13/cobra" + + oauth "github.com/databricks/cli/libs/sdktypes/oauth/v1" + sdkoauth "github.com/databricks/sdk-go/oauth/v1" ) // Slice with functions to override default command behavior. @@ -53,18 +56,18 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *oauth2.CreatePublishedAppIntegration, + *oauth.CreatePublishedOAuthAppIntegrationRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq oauth.CreatePublishedOAuthAppIntegrationRequest - var createReq oauth2.CreatePublishedAppIntegration 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.AppId, "app-id", createReq.AppId, `App id of the OAuth published app integration.`) + flags.StringPtrVar(cmd.Flags(), &createReq.AppId, "app-id", `App id of the OAuth published app integration.`) // TODO: complex arg: token_access_policy cmd.Use = "create" @@ -91,6 +94,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -105,12 +109,20 @@ func newCreate() *cobra.Command { } } - response, err := a.PublishedAppIntegration.Create(ctx, createReq) + sdkReq, err := oauth.CreatePublishedOAuthAppIntegrationRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.OAuth.CreatePublishedOAuthAppIntegration(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := oauth.CreatePublishedOAuthAppIntegrationResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -131,13 +143,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *oauth2.DeletePublishedAppIntegrationRequest, + *sdkoauth.DeletePublishedOAuthAppIntegrationRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq oauth2.DeletePublishedAppIntegrationRequest + var deleteReq sdkoauth.DeletePublishedOAuthAppIntegrationRequest cmd.Use = "delete INTEGRATION_ID" cmd.Short = `Delete Published OAuth App Integration.` @@ -161,13 +172,17 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.IntegrationId = args[0] + deleteReq.IntegrationId = new(args[0]) - err = a.PublishedAppIntegration.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.OAuth.DeletePublishedOAuthAppIntegration(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -189,13 +204,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *oauth2.GetPublishedAppIntegrationRequest, + *sdkoauth.GetPublishedOAuthAppIntegrationRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq oauth2.GetPublishedAppIntegrationRequest + var getReq sdkoauth.GetPublishedOAuthAppIntegrationRequest cmd.Use = "get INTEGRATION_ID" cmd.Short = `Get OAuth Published App Integration.` @@ -216,15 +230,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.IntegrationId = args[0] + getReq.IntegrationId = new(args[0]) - response, err := a.PublishedAppIntegration.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.OAuth.GetPublishedOAuthAppIntegration(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := oauth.PublishedOAuthAppIntegrationFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -245,25 +265,25 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *oauth2.ListPublishedAppIntegrationsRequest, + *oauth.ListPublishedOAuthAppIntegrationsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq oauth.ListPublishedOAuthAppIntegrationsRequest - var listReq oauth2.ListPublishedAppIntegrationsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -286,16 +306,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.PublishedAppIntegration.List(ctx, listReq) + sdkReq, err := oauth.ListPublishedOAuthAppIntegrationsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.OAuth.ListPublishedOAuthAppIntegrationsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, oauth.PublishedOAuthAppIntegrationFromSDK)) } // Disable completions since they are not applicable. @@ -316,13 +340,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *oauth2.UpdatePublishedAppIntegration, + *oauth.UpdatePublishedOAuthAppIntegrationRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq oauth.UpdatePublishedOAuthAppIntegrationRequest - var updateReq oauth2.UpdatePublishedAppIntegration var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -351,6 +375,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -364,12 +389,18 @@ func newUpdate() *cobra.Command { } } } - updateReq.IntegrationId = args[0] + updateReq.IntegrationId = new(args[0]) - err = a.PublishedAppIntegration.Update(ctx, updateReq) + sdkReq, err := oauth.UpdatePublishedOAuthAppIntegrationRequestToSDK(&updateReq) if err != nil { return err } + response, err := a.OAuth.UpdatePublishedOAuthAppIntegration(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } diff --git a/cmd/account/service-principal-federation-policy/service-principal-federation-policy.go b/cmd/account/service-principal-federation-policy/service-principal-federation-policy.go index 7a148865891..5beaf3fb0a2 100644 --- a/cmd/account/service-principal-federation-policy/service-principal-federation-policy.go +++ b/cmd/account/service-principal-federation-policy/service-principal-federation-policy.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/oauth2" "github.com/spf13/cobra" + + authentication "github.com/databricks/cli/libs/sdktypes/authentication/v1" + sdkauthentication "github.com/databricks/sdk-go/authentication/v1" ) // Slice with functions to override default command behavior. @@ -104,20 +107,20 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *oauth2.CreateServicePrincipalFederationPolicyRequest, + *authentication.CreateServicePrincipalFederationPolicyRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq authentication.CreateServicePrincipalFederationPolicyRequest + createReq.Policy = &authentication.FederationPolicy{} - var createReq oauth2.CreateServicePrincipalFederationPolicyRequest - createReq.Policy = oauth2.FederationPolicy{} 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.PolicyId, "policy-id", createReq.PolicyId, `The identifier for the federation policy.`) - cmd.Flags().StringVar(&createReq.Policy.Description, "description", createReq.Policy.Description, `Description of the federation policy.`) + flags.StringPtrVar(cmd.Flags(), &createReq.PolicyId, "policy-id", `The identifier for the federation policy.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Policy.Description, "description", `Description of the federation policy.`) // TODO: complex arg: oidc_policy cmd.Use = "create SERVICE_PRINCIPAL_ID" @@ -142,6 +145,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.Policy) @@ -155,17 +159,27 @@ func newCreate() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &createReq.ServicePrincipalId) + var createServicePrincipalIdArg int64 + _, err = fmt.Sscan(args[0], &createServicePrincipalIdArg) if err != nil { return fmt.Errorf("invalid SERVICE_PRINCIPAL_ID: %s", args[0]) } + createReq.ServicePrincipalId = &createServicePrincipalIdArg - response, err := a.ServicePrincipalFederationPolicy.Create(ctx, createReq) + sdkReq, err := authentication.CreateServicePrincipalFederationPolicyRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Authentication.CreateServicePrincipalFederationPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := authentication.FederationPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -186,13 +200,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *oauth2.DeleteServicePrincipalFederationPolicyRequest, + *sdkauthentication.DeleteServicePrincipalFederationPolicyRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq oauth2.DeleteServicePrincipalFederationPolicyRequest + var deleteReq sdkauthentication.DeleteServicePrincipalFederationPolicyRequest cmd.Use = "delete SERVICE_PRINCIPAL_ID POLICY_ID" cmd.Short = `Delete service principal federation policy.` @@ -217,15 +230,18 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &deleteReq.ServicePrincipalId) + var deleteServicePrincipalIdArg int64 + _, err = fmt.Sscan(args[0], &deleteServicePrincipalIdArg) if err != nil { return fmt.Errorf("invalid SERVICE_PRINCIPAL_ID: %s", args[0]) } + deleteReq.ServicePrincipalId = &deleteServicePrincipalIdArg + deleteReq.PolicyId = new(args[1]) - deleteReq.PolicyId = args[1] - - err = a.ServicePrincipalFederationPolicy.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = a.Authentication.DeleteServicePrincipalFederationPolicy(ctx, *sdkReq) if err != nil { return err } @@ -250,13 +266,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *oauth2.GetServicePrincipalFederationPolicyRequest, + *sdkauthentication.GetServicePrincipalFederationPolicyRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq oauth2.GetServicePrincipalFederationPolicyRequest + var getReq sdkauthentication.GetServicePrincipalFederationPolicyRequest cmd.Use = "get SERVICE_PRINCIPAL_ID POLICY_ID" cmd.Short = `Get service principal federation policy.` @@ -281,20 +296,27 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &getReq.ServicePrincipalId) + var getServicePrincipalIdArg int64 + _, err = fmt.Sscan(args[0], &getServicePrincipalIdArg) if err != nil { return fmt.Errorf("invalid SERVICE_PRINCIPAL_ID: %s", args[0]) } + getReq.ServicePrincipalId = &getServicePrincipalIdArg + getReq.PolicyId = new(args[1]) - getReq.PolicyId = args[1] - - response, err := a.ServicePrincipalFederationPolicy.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Authentication.GetServicePrincipalFederationPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := authentication.FederationPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -315,25 +337,25 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *oauth2.ListServicePrincipalFederationPoliciesRequest, + *authentication.ListServicePrincipalFederationPoliciesRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq authentication.ListServicePrincipalFederationPoliciesRequest - var listReq oauth2.ListServicePrincipalFederationPoliciesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list SERVICE_PRINCIPAL_ID" @@ -358,21 +380,27 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &listReq.ServicePrincipalId) + var listServicePrincipalIdArg int64 + _, err = fmt.Sscan(args[0], &listServicePrincipalIdArg) if err != nil { return fmt.Errorf("invalid SERVICE_PRINCIPAL_ID: %s", args[0]) } + listReq.ServicePrincipalId = &listServicePrincipalIdArg - response := a.ServicePrincipalFederationPolicy.List(ctx, listReq) + sdkReq, err := authentication.ListServicePrincipalFederationPoliciesRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Authentication.ListServicePrincipalFederationPoliciesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, authentication.FederationPolicyFromSDK)) } // Disable completions since they are not applicable. @@ -393,20 +421,20 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *oauth2.UpdateServicePrincipalFederationPolicyRequest, + *authentication.UpdateServicePrincipalFederationPolicyRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq authentication.UpdateServicePrincipalFederationPolicyRequest + updateReq.Policy = &authentication.FederationPolicy{} - var updateReq oauth2.UpdateServicePrincipalFederationPolicyRequest - updateReq.Policy = oauth2.FederationPolicy{} 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.UpdateMask, "update-mask", updateReq.UpdateMask, `The field mask specifies which fields of the policy to update.`) - cmd.Flags().StringVar(&updateReq.Policy.Description, "description", updateReq.Policy.Description, `Description of the federation policy.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.UpdateMask, "update-mask", `The field mask specifies which fields of the policy to update.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Policy.Description, "description", `Description of the federation policy.`) // TODO: complex arg: oidc_policy cmd.Use = "update SERVICE_PRINCIPAL_ID POLICY_ID" @@ -432,6 +460,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.Policy) @@ -445,19 +474,28 @@ func newUpdate() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &updateReq.ServicePrincipalId) + var updateServicePrincipalIdArg int64 + _, err = fmt.Sscan(args[0], &updateServicePrincipalIdArg) if err != nil { return fmt.Errorf("invalid SERVICE_PRINCIPAL_ID: %s", args[0]) } + updateReq.ServicePrincipalId = &updateServicePrincipalIdArg + updateReq.PolicyId = new(args[1]) - updateReq.PolicyId = args[1] - - response, err := a.ServicePrincipalFederationPolicy.Update(ctx, updateReq) + sdkReq, err := authentication.UpdateServicePrincipalFederationPolicyRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := a.Authentication.UpdateServicePrincipalFederationPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := authentication.FederationPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/service-principal-secrets/service-principal-secrets.go b/cmd/account/service-principal-secrets/service-principal-secrets.go index 0ed1a3995f2..63c6e5c97b5 100644 --- a/cmd/account/service-principal-secrets/service-principal-secrets.go +++ b/cmd/account/service-principal-secrets/service-principal-secrets.go @@ -7,10 +7,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/oauth2" "github.com/spf13/cobra" + + authentication "github.com/databricks/cli/libs/sdktypes/authentication/v1" ) // Slice with functions to override default command behavior. @@ -61,18 +63,18 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *oauth2.CreateServicePrincipalSecretRequest, + *authentication.CreateServicePrincipalSecretRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq authentication.CreateServicePrincipalSecretRequest - var createReq oauth2.CreateServicePrincipalSecretRequest 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.Lifetime, "lifetime", createReq.Lifetime, `The lifetime of the secret in seconds.`) + flags.JSONStringPtrVar(cmd.Flags(), &createReq.Lifetime, "lifetime", `The lifetime of the secret in seconds.`) cmd.Use = "create SERVICE_PRINCIPAL_ID" cmd.Short = `Create service principal secret.` @@ -96,6 +98,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -109,14 +112,22 @@ func newCreate() *cobra.Command { } } } - createReq.ServicePrincipalId = args[0] + createReq.ServicePrincipal = new(args[0]) - response, err := a.ServicePrincipalSecrets.Create(ctx, createReq) + sdkReq, err := authentication.CreateServicePrincipalSecretRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Authentication.CreateServicePrincipalSecret(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := authentication.CreateServicePrincipalSecretResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -137,13 +148,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *oauth2.DeleteServicePrincipalSecretRequest, + *authentication.DeleteServicePrincipalSecretRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq oauth2.DeleteServicePrincipalSecretRequest + var deleteReq authentication.DeleteServicePrincipalSecretRequest cmd.Use = "delete SERVICE_PRINCIPAL_ID SECRET_ID" cmd.Short = `Delete service principal secret.` @@ -168,14 +178,21 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.ServicePrincipalId = args[0] - deleteReq.SecretId = args[1] + deleteReq.ServicePrincipal = new(args[0]) + deleteReq.SecretId = new(args[1]) - err = a.ServicePrincipalSecrets.Delete(ctx, deleteReq) + sdkReq, err := authentication.DeleteServicePrincipalSecretRequestToSDK(&deleteReq) if err != nil { return err } + response, err := a.Authentication.DeleteServicePrincipalSecret(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -197,25 +214,25 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *oauth2.ListServicePrincipalSecretsRequest, + *authentication.ListServicePrincipalSecretsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq authentication.ListServicePrincipalSecretsRequest - var listReq oauth2.ListServicePrincipalSecretsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list SERVICE_PRINCIPAL_ID" @@ -242,18 +259,22 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - listReq.ServicePrincipalId = args[0] + listReq.ServicePrincipal = new(args[0]) - response := a.ServicePrincipalSecrets.List(ctx, listReq) + sdkReq, err := authentication.ListServicePrincipalSecretsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Authentication.ListServicePrincipalSecretsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, authentication.ServicePrincipalSecretFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/account/service-principals-v2/service-principals-v2.go b/cmd/account/service-principals-v2/service-principals-v2.go index ba6aadb6cb6..491b0b2ee4f 100644 --- a/cmd/account/service-principals-v2/service-principals-v2.go +++ b/cmd/account/service-principals-v2/service-principals-v2.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" + + scim "github.com/databricks/cli/libs/sdktypes/scim/v1" + sdkscim "github.com/databricks/sdk-go/scim/v1" ) // Slice with functions to override default command behavior. @@ -57,22 +60,22 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *iam.CreateAccountServicePrincipalRequest, + *scim.CreateAccountServicePrincipalRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq scim.CreateAccountServicePrincipalRequest - var createReq iam.CreateAccountServicePrincipalRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createReq.Active, "active", createReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&createReq.ApplicationId, "application-id", createReq.ApplicationId, `UUID relating to the service principal.`) - cmd.Flags().StringVar(&createReq.DisplayName, "display-name", createReq.DisplayName, `String that represents a concatenation of given and family names.`) - cmd.Flags().StringVar(&createReq.ExternalId, "external-id", createReq.ExternalId, ``) - cmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Databricks service principal ID.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.Active, "active", `If this user is active.`) + flags.StringPtrVar(cmd.Flags(), &createReq.ApplicationId, "application-id", `UUID relating to the service principal.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DisplayName, "display-name", `String that represents a concatenation of given and family names.`) + flags.StringPtrVar(cmd.Flags(), &createReq.ExternalId, "external-id", ``) + flags.StringPtrVar(cmd.Flags(), &createReq.Id, "id", `Databricks service principal ID.`) // TODO: array: roles cmd.Use = "create" @@ -94,6 +97,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -108,12 +112,20 @@ func newCreate() *cobra.Command { } } - response, err := a.ServicePrincipalsV2.Create(ctx, createReq) + sdkReq, err := scim.CreateAccountServicePrincipalRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Scim.CreateAccountServicePrincipal(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.AccountServicePrincipalFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -134,13 +146,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *iam.DeleteAccountServicePrincipalRequest, + *sdkscim.DeleteAccountServicePrincipalRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq iam.DeleteAccountServicePrincipalRequest + var deleteReq sdkscim.DeleteAccountServicePrincipalRequest cmd.Use = "delete ID" cmd.Short = `Delete a service principal.` @@ -164,10 +175,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = a.ServicePrincipalsV2.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = a.Scim.DeleteAccountServicePrincipal(ctx, *sdkReq) if err != nil { return err } @@ -192,13 +205,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *iam.GetAccountServicePrincipalRequest, + *sdkscim.GetAccountServicePrincipalRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq iam.GetAccountServicePrincipalRequest + var getReq sdkscim.GetAccountServicePrincipalRequest cmd.Use = "get ID" cmd.Short = `Get service principal details.` @@ -223,15 +235,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := a.ServicePrincipalsV2.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Scim.GetAccountServicePrincipal(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.AccountServicePrincipalFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -252,31 +270,31 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *iam.ListAccountServicePrincipalsRequest, + *scim.ListAccountServicePrincipalsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq scim.ListAccountServicePrincipalsRequest - var listReq iam.ListAccountServicePrincipalsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.Attributes, "attributes", listReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().StringVar(&listReq.ExcludedAttributes, "excluded-attributes", listReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&listReq.Filter, "filter", listReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&listReq.SortBy, "sort-by", listReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) + flags.StringPtrVar(cmd.Flags(), &listReq.Attributes, "attributes", `Comma-separated list of attributes to return in response.`) + flags.StringPtrVar(cmd.Flags(), &listReq.ExcludedAttributes, "excluded-attributes", `Comma-separated list of attributes to exclude in response.`) + flags.StringPtrVar(cmd.Flags(), &listReq.Filter, "filter", `Query by which the results have to be filtered.`) + flags.StringPtrVar(cmd.Flags(), &listReq.SortBy, "sort-by", `Attribute to sort the results.`) + flags.EnumVar(cmd.Flags(), &listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`, "ListSortOrder", "ascending", "descending") // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().Int64Var(&listReq.StartIndex, "start-index", listReq.StartIndex, `Specifies the index of the first result.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.StartIndex, "start-index", `Specifies the index of the first result.`) cmd.Flags().Lookup("start-index").Hidden = true - cmd.Flags().Int64Var(&listReq.Count, "count", listReq.Count, `Number of results per API page.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.Count, "count", `Number of results per API page.`) cmd.Flags().Lookup("count").Hidden = true cmd.Use = "list" @@ -298,16 +316,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.ServicePrincipalsV2.List(ctx, listReq) + sdkReq, err := scim.ListAccountServicePrincipalsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Scim.ListAccountServicePrincipalsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, scim.AccountServicePrincipalFromSDK)) } // Disable completions since they are not applicable. @@ -328,13 +350,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var patchOverrides []func( *cobra.Command, - *iam.PatchAccountServicePrincipalRequest, + *scim.PatchAccountServicePrincipalRequest, ) func newPatch() *cobra.Command { cmd := &cobra.Command{} + var patchReq scim.PatchAccountServicePrincipalRequest - var patchReq iam.PatchAccountServicePrincipalRequest var patchJson flags.JsonFlag cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -365,6 +387,7 @@ func newPatch() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -378,9 +401,13 @@ func newPatch() *cobra.Command { } } } - patchReq.Id = args[0] + patchReq.Id = new(args[0]) - err = a.ServicePrincipalsV2.Patch(ctx, patchReq) + sdkReq, err := scim.PatchAccountServicePrincipalRequestToSDK(&patchReq) + if err != nil { + return err + } + err = a.Scim.PatchAccountServicePrincipal(ctx, *sdkReq) if err != nil { return err } @@ -405,21 +432,21 @@ func newPatch() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *iam.UpdateAccountServicePrincipalRequest, + *scim.UpdateAccountServicePrincipalRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq scim.UpdateAccountServicePrincipalRequest - var updateReq iam.UpdateAccountServicePrincipalRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&updateReq.Active, "active", updateReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&updateReq.ApplicationId, "application-id", updateReq.ApplicationId, `UUID relating to the service principal.`) - cmd.Flags().StringVar(&updateReq.DisplayName, "display-name", updateReq.DisplayName, `String that represents a concatenation of given and family names.`) - cmd.Flags().StringVar(&updateReq.ExternalId, "external-id", updateReq.ExternalId, ``) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Active, "active", `If this user is active.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.ApplicationId, "application-id", `UUID relating to the service principal.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.DisplayName, "display-name", `String that represents a concatenation of given and family names.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.ExternalId, "external-id", ``) // TODO: array: roles cmd.Use = "update ID" @@ -446,6 +473,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -459,9 +487,13 @@ func newUpdate() *cobra.Command { } } } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - err = a.ServicePrincipalsV2.Update(ctx, updateReq) + sdkReq, err := scim.UpdateAccountServicePrincipalRequestToSDK(&updateReq) + if err != nil { + return err + } + err = a.Scim.UpdateAccountServicePrincipal(ctx, *sdkReq) if err != nil { return err } diff --git a/cmd/account/service-principals/overrides.go b/cmd/account/service-principals/overrides.go index d94a4267c85..480f2b66db0 100644 --- a/cmd/account/service-principals/overrides.go +++ b/cmd/account/service-principals/overrides.go @@ -2,11 +2,10 @@ package service_principals import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, _ *iam.ListAccountServicePrincipalsRequest) { +func listOverride(listCmd *cobra.Command) { listCmd.Annotations["template"] = cmdio.Heredoc(` {{range .}}{{.Id|green}} {{.ApplicationId}} {{.DisplayName}} {{range .Groups}}{{.Display}} {{end}} {{if .Active}}{{"ACTIVE"|green}}{{else}}DISABLED{{end}} {{end}}`) diff --git a/cmd/account/service-principals/service-principals.go b/cmd/account/service-principals/service-principals.go index 06d410fc33d..d1582349a54 100755 --- a/cmd/account/service-principals/service-principals.go +++ b/cmd/account/service-principals/service-principals.go @@ -2,17 +2,11 @@ // but are now manually maintained because the v2 API versions have taken // over as the generated commands. See https://github.com/databricks/cli/pull/4722. -//nolint:staticcheck,perfsprint package service_principals import ( - "fmt" - + service_principals_v2 "github.com/databricks/cli/cmd/account/service-principals-v2" "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/iam" "github.com/spf13/cobra" ) @@ -20,6 +14,11 @@ import ( // Functions can be added from the `init()` function in manually curated files in this directory. var cmdOverrides []func(*cobra.Command) +// Slices with functions to override the behavior of individual commands. +var listOverrides []func(*cobra.Command) + +// The commands are the service-principals-v2 commands (same API) presented under their +// original names and help text. func New() *cobra.Command { cmd := &cobra.Command{ Use: "service-principals", @@ -37,472 +36,103 @@ func New() *cobra.Command { RunE: root.ReportUnknownSubcommand, } - // Add methods - cmd.AddCommand(newCreate()) - cmd.AddCommand(newDelete()) - cmd.AddCommand(newGet()) - cmd.AddCommand(newList()) - cmd.AddCommand(newPatch()) - 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, - *iam.ServicePrincipal, -) - -func newCreate() *cobra.Command { - cmd := &cobra.Command{} - - var createReq iam.ServicePrincipal - var createJson flags.JsonFlag - - cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - cmd.Flags().BoolVar(&createReq.Active, "active", createReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&createReq.ApplicationId, "application-id", createReq.ApplicationId, `UUID relating to the service principal.`) - cmd.Flags().StringVar(&createReq.DisplayName, "display-name", createReq.DisplayName, `String that represents a concatenation of given and family names.`) - // TODO: array: entitlements - cmd.Flags().StringVar(&createReq.ExternalId, "external-id", createReq.ExternalId, ``) - // TODO: array: groups - cmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Databricks service principal ID.`) - // TODO: array: roles - // TODO: array: schemas - - cmd.Use = "create" - cmd.Short = `Create a service principal.` - cmd.Long = `Create a service principal. - - Creates a new service principal in the Databricks 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.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - if cmd.Flags().Changed("json") { - diags := createJson.Unmarshal(&createReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err + v2 := service_principals_v2.New() + for _, sub := range v2.Commands() { + doc, ok := commandDocs[sub.Name()] + if !ok { + continue + } + v2.RemoveCommand(sub) + sub.Use = doc.use + if doc.short != "" { + sub.Short = doc.short + sub.Long = doc.long + } + sub.Hidden = doc.hidden + if sub.Name() == "list" { + // These were regular flags of the original commands. + for _, name := range []string{"count", "start-index"} { + if f := sub.Flags().Lookup(name); f != nil { + f.Hidden = false } } + for _, fn := range listOverrides { + fn(sub) + } } - - response, err := a.ServicePrincipals.Create(ctx, createReq) - if err != nil { - return err - } - return cmdio.Render(ctx, response) + cmd.AddCommand(sub) } - // 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) + for _, fn := range cmdOverrides { + fn(cmd) } 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, - *iam.DeleteAccountServicePrincipalRequest, -) - -func newDelete() *cobra.Command { - cmd := &cobra.Command{} +type commandDoc struct { + use, short, long string + hidden bool +} - var deleteReq iam.DeleteAccountServicePrincipalRequest +var commandDocs = map[string]commandDoc{ + "create": { + use: "create", + short: `Create a service principal.`, + long: `Create a service principal. - cmd.Use = "delete ID" - cmd.Short = `Delete a service principal.` - cmd.Long = `Delete a service principal. + Creates a new service principal in the Databricks account.`, + }, + "delete": { + use: "delete ID", + short: `Delete a service principal.`, + long: `Delete a service principal. Delete a single service principal in the Databricks account. Arguments: - ID: Unique ID for a service principal in the Databricks account.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Account Service Principals drop-down.") - names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID for a service principal in the Databricks account") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id for a service principal in the databricks account") - } - deleteReq.Id = args[0] - - err = a.ServicePrincipals.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, - *iam.GetAccountServicePrincipalRequest, -) - -func newGet() *cobra.Command { - cmd := &cobra.Command{} - - var getReq iam.GetAccountServicePrincipalRequest - - cmd.Use = "get ID" - cmd.Short = `Get service principal details.` - cmd.Long = `Get service principal details. + ID: Unique ID for a service principal in the Databricks account.`, + }, + "get": { + use: "get ID", + short: `Get service principal details.`, + long: `Get service principal details. Gets the details for a single service principal define in the Databricks account. Arguments: - ID: Unique ID for a service principal in the Databricks account.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Account Service Principals drop-down.") - names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID for a service principal in the Databricks account") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id for a service principal in the databricks account") - } - getReq.Id = args[0] - - response, err := a.ServicePrincipals.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, - *iam.ListAccountServicePrincipalsRequest, -) - -func newList() *cobra.Command { - cmd := &cobra.Command{} - - var listReq iam.ListAccountServicePrincipalsRequest - - cmd.Flags().StringVar(&listReq.Attributes, "attributes", listReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().Int64Var(&listReq.Count, "count", listReq.Count, `Desired number of results per page.`) - cmd.Flags().StringVar(&listReq.ExcludedAttributes, "excluded-attributes", listReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&listReq.Filter, "filter", listReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&listReq.SortBy, "sort-by", listReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) - cmd.Flags().Int64Var(&listReq.StartIndex, "start-index", listReq.StartIndex, `Specifies the index of the first result.`) - - cmd.Use = "list" - cmd.Short = `List service principals.` - cmd.Long = `List service principals. - - Gets the set of service principals associated with a Databricks 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.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - response := a.ServicePrincipals.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 patch 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 patchOverrides []func( - *cobra.Command, - *iam.PartialUpdate, -) - -func newPatch() *cobra.Command { - cmd := &cobra.Command{} - - var patchReq iam.PartialUpdate - var patchJson flags.JsonFlag - - cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - // TODO: array: Operations - // TODO: array: schemas - - cmd.Use = "patch ID" - cmd.Short = `Update service principal details.` - cmd.Long = `Update service principal details. + ID: Unique ID for a service principal in the Databricks account.`, + }, + "list": { + use: "list", + short: `List service principals.`, + long: `List service principals. + + Gets the set of service principals associated with a Databricks account.`, + }, + "patch": { + use: "patch ID", + short: `Update service principal details.`, + long: `Update service principal details. Partially updates the details of a single service principal in the Databricks account. Arguments: - ID: Unique ID in the Databricks workspace.` - - cmd.Annotations = make(map[string]string) - - 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 := patchJson.Unmarshal(&patchReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Account Service Principals drop-down.") - names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID in the Databricks workspace") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id in the databricks workspace") - } - patchReq.Id = args[0] - - err = a.ServicePrincipals.Patch(ctx, patchReq) - 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 patchOverrides { - fn(cmd, &patchReq) - } - - 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, - *iam.ServicePrincipal, -) - -func newUpdate() *cobra.Command { - cmd := &cobra.Command{} - - var updateReq iam.ServicePrincipal - var updateJson flags.JsonFlag - - cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - cmd.Flags().BoolVar(&updateReq.Active, "active", updateReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&updateReq.ApplicationId, "application-id", updateReq.ApplicationId, `UUID relating to the service principal.`) - cmd.Flags().StringVar(&updateReq.DisplayName, "display-name", updateReq.DisplayName, `String that represents a concatenation of given and family names.`) - // TODO: array: entitlements - cmd.Flags().StringVar(&updateReq.ExternalId, "external-id", updateReq.ExternalId, ``) - // TODO: array: groups - cmd.Flags().StringVar(&updateReq.Id, "id", updateReq.Id, `Databricks service principal ID.`) - // TODO: array: roles - // TODO: array: schemas - - cmd.Use = "update ID" - cmd.Short = `Replace service principal.` - cmd.Long = `Replace service principal. + ID: Unique ID in the Databricks workspace.`, + }, + "update": { + use: "update ID", + short: `Replace service principal.`, + long: `Replace service principal. Updates the details of a single service principal. This action replaces the existing service principal with the same name. Arguments: - ID: Databricks service principal ID.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - if cmd.Flags().Changed("json") { - diags := updateJson.Unmarshal(&updateReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Account Service Principals drop-down.") - names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks service principal ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks service principal id") - } - updateReq.Id = args[0] - - err = a.ServicePrincipals.Update(ctx, updateReq) - 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 updateOverrides { - fn(cmd, &updateReq) - } - - return cmd + ID: Databricks service principal ID.`, + }, } - -// end service AccountServicePrincipals diff --git a/cmd/account/settings-v2/settings-v2.go b/cmd/account/settings-v2/settings-v2.go index b84f334b6c5..bcb33df9979 100644 --- a/cmd/account/settings-v2/settings-v2.go +++ b/cmd/account/settings-v2/settings-v2.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/settingsv2" "github.com/spf13/cobra" + + settings "github.com/databricks/cli/libs/sdktypes/settings/v2" + sdksettings "github.com/databricks/sdk-go/settings/v2" ) // Slice with functions to override default command behavior. @@ -52,13 +55,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPublicAccountSettingOverrides []func( *cobra.Command, - *settingsv2.GetPublicAccountSettingRequest, + *sdksettings.GetPublicAccountSettingRequest, ) func newGetPublicAccountSetting() *cobra.Command { cmd := &cobra.Command{} - - var getPublicAccountSettingReq settingsv2.GetPublicAccountSettingRequest + var getPublicAccountSettingReq sdksettings.GetPublicAccountSettingRequest cmd.Use = "get-public-account-setting NAME" cmd.Short = `Get an account setting.` @@ -81,15 +83,21 @@ func newGetPublicAccountSetting() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getPublicAccountSettingReq.Name = args[0] + getPublicAccountSettingReq.Name = new(args[0]) - response, err := a.SettingsV2.GetPublicAccountSetting(ctx, getPublicAccountSettingReq) + sdkReq := &getPublicAccountSettingReq + response, err := a.Settings.GetPublicAccountSetting(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := settings.SettingFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -110,13 +118,12 @@ func newGetPublicAccountSetting() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPublicAccountUserPreferenceOverrides []func( *cobra.Command, - *settingsv2.GetPublicAccountUserPreferenceRequest, + *sdksettings.GetPublicAccountUserPreferenceRequest, ) func newGetPublicAccountUserPreference() *cobra.Command { cmd := &cobra.Command{} - - var getPublicAccountUserPreferenceReq settingsv2.GetPublicAccountUserPreferenceRequest + var getPublicAccountUserPreferenceReq sdksettings.GetPublicAccountUserPreferenceRequest cmd.Use = "get-public-account-user-preference USER_ID NAME" cmd.Short = `*Beta* Get a user preference.` @@ -146,16 +153,22 @@ Get a user preference. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getPublicAccountUserPreferenceReq.UserId = args[0] - getPublicAccountUserPreferenceReq.Name = args[1] + getPublicAccountUserPreferenceReq.UserId = new(args[0]) + getPublicAccountUserPreferenceReq.Name = new(args[1]) - response, err := a.SettingsV2.GetPublicAccountUserPreference(ctx, getPublicAccountUserPreferenceReq) + sdkReq := &getPublicAccountUserPreferenceReq + response, err := a.Settings.GetPublicAccountUserPreference(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := settings.UserPreferenceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -176,25 +189,25 @@ Get a user preference. // Functions can be added from the `init()` function in manually curated files in this directory. var listAccountSettingsMetadataOverrides []func( *cobra.Command, - *settingsv2.ListAccountSettingsMetadataRequest, + *settings.ListAccountSettingsMetadataRequest, ) func newListAccountSettingsMetadata() *cobra.Command { cmd := &cobra.Command{} + var listAccountSettingsMetadataReq settings.ListAccountSettingsMetadataRequest - var listAccountSettingsMetadataReq settingsv2.ListAccountSettingsMetadataRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listAccountSettingsMetadataLimit int - cmd.Flags().IntVar(&listAccountSettingsMetadataReq.PageSize, "page-size", listAccountSettingsMetadataReq.PageSize, `The maximum number of settings to return.`) + flags.IntPtrVar(cmd.Flags(), &listAccountSettingsMetadataReq.PageSize, "page-size", `The maximum number of settings to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listAccountSettingsMetadataLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listAccountSettingsMetadataReq.PageToken, "page-token", listAccountSettingsMetadataReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listAccountSettingsMetadataReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-account-settings-metadata" @@ -218,16 +231,20 @@ func newListAccountSettingsMetadata() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.SettingsV2.ListAccountSettingsMetadata(ctx, listAccountSettingsMetadataReq) + sdkReq, err := settings.ListAccountSettingsMetadataRequestToSDK(&listAccountSettingsMetadataReq) + if err != nil { + return err + } if listAccountSettingsMetadataLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listAccountSettingsMetadataLimit) } if listAccountSettingsMetadataLimit > 0 { ctx = cmdio.WithLimit(ctx, listAccountSettingsMetadataLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Settings.ListAccountSettingsMetadataIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, settings.SettingsMetadataFromSDK)) } // Disable completions since they are not applicable. @@ -248,25 +265,25 @@ func newListAccountSettingsMetadata() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listAccountUserPreferencesMetadataOverrides []func( *cobra.Command, - *settingsv2.ListAccountUserPreferencesMetadataRequest, + *settings.ListAccountUserPreferencesMetadataRequest, ) func newListAccountUserPreferencesMetadata() *cobra.Command { cmd := &cobra.Command{} + var listAccountUserPreferencesMetadataReq settings.ListAccountUserPreferencesMetadataRequest - var listAccountUserPreferencesMetadataReq settingsv2.ListAccountUserPreferencesMetadataRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listAccountUserPreferencesMetadataLimit int - cmd.Flags().IntVar(&listAccountUserPreferencesMetadataReq.PageSize, "page-size", listAccountUserPreferencesMetadataReq.PageSize, `The maximum number of settings to return.`) + flags.IntPtrVar(cmd.Flags(), &listAccountUserPreferencesMetadataReq.PageSize, "page-size", `The maximum number of settings to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listAccountUserPreferencesMetadataLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listAccountUserPreferencesMetadataReq.PageToken, "page-token", listAccountUserPreferencesMetadataReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listAccountUserPreferencesMetadataReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-account-user-preferences-metadata USER_ID" @@ -297,18 +314,22 @@ List user preferences and their metadata. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - listAccountUserPreferencesMetadataReq.UserId = args[0] + listAccountUserPreferencesMetadataReq.UserId = new(args[0]) - response := a.SettingsV2.ListAccountUserPreferencesMetadata(ctx, listAccountUserPreferencesMetadataReq) + sdkReq, err := settings.ListAccountUserPreferencesMetadataRequestToSDK(&listAccountUserPreferencesMetadataReq) + if err != nil { + return err + } if listAccountUserPreferencesMetadataLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listAccountUserPreferencesMetadataLimit) } if listAccountUserPreferencesMetadataLimit > 0 { ctx = cmdio.WithLimit(ctx, listAccountUserPreferencesMetadataLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Settings.ListAccountUserPreferencesMetadataIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, settings.SettingsMetadataFromSDK)) } // Disable completions since they are not applicable. @@ -329,14 +350,14 @@ List user preferences and their metadata. // Functions can be added from the `init()` function in manually curated files in this directory. var patchPublicAccountSettingOverrides []func( *cobra.Command, - *settingsv2.PatchPublicAccountSettingRequest, + *settings.PatchPublicAccountSettingRequest, ) func newPatchPublicAccountSetting() *cobra.Command { cmd := &cobra.Command{} + var patchPublicAccountSettingReq settings.PatchPublicAccountSettingRequest + patchPublicAccountSettingReq.Setting = &settings.Setting{} - 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`) @@ -360,7 +381,7 @@ func newPatchPublicAccountSetting() *cobra.Command { // TODO: complex arg: effective_string_val // TODO: complex arg: effective_workspace_label // TODO: complex arg: integer_val - cmd.Flags().StringVar(&patchPublicAccountSettingReq.Setting.Name, "name", patchPublicAccountSettingReq.Setting.Name, `Name of the setting.`) + flags.StringPtrVar(cmd.Flags(), &patchPublicAccountSettingReq.Name, "name", `Name of the setting.`) // TODO: complex arg: operational_email_custom_recipient // TODO: complex arg: personal_compute // TODO: complex arg: restrict_workspace_admins @@ -392,6 +413,7 @@ func newPatchPublicAccountSetting() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := patchPublicAccountSettingJson.Unmarshal(&patchPublicAccountSettingReq.Setting) @@ -405,14 +427,22 @@ func newPatchPublicAccountSetting() *cobra.Command { } } } - patchPublicAccountSettingReq.Name = args[0] + patchPublicAccountSettingReq.Name = new(args[0]) - response, err := a.SettingsV2.PatchPublicAccountSetting(ctx, patchPublicAccountSettingReq) + sdkReq, err := settings.PatchPublicAccountSettingRequestToSDK(&patchPublicAccountSettingReq) + if err != nil { + return err + } + response, err := a.Settings.PatchPublicAccountSetting(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := settings.SettingFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -433,14 +463,14 @@ func newPatchPublicAccountSetting() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var patchPublicAccountUserPreferenceOverrides []func( *cobra.Command, - *settingsv2.PatchPublicAccountUserPreferenceRequest, + *settings.PatchPublicAccountUserPreferenceRequest, ) func newPatchPublicAccountUserPreference() *cobra.Command { cmd := &cobra.Command{} + var patchPublicAccountUserPreferenceReq settings.PatchPublicAccountUserPreferenceRequest + patchPublicAccountUserPreferenceReq.Setting = &settings.UserPreference{} - var patchPublicAccountUserPreferenceReq settingsv2.PatchPublicAccountUserPreferenceRequest - patchPublicAccountUserPreferenceReq.Setting = settingsv2.UserPreference{} var patchPublicAccountUserPreferenceJson flags.JsonFlag cmd.Flags().Var(&patchPublicAccountUserPreferenceJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -448,9 +478,9 @@ func newPatchPublicAccountUserPreference() *cobra.Command { // TODO: complex arg: boolean_val // TODO: complex arg: effective_boolean_val // TODO: complex arg: effective_string_val - cmd.Flags().StringVar(&patchPublicAccountUserPreferenceReq.Setting.Name, "name", patchPublicAccountUserPreferenceReq.Setting.Name, `Name of the setting.`) + flags.StringPtrVar(cmd.Flags(), &patchPublicAccountUserPreferenceReq.Name, "name", `Name of the setting.`) // TODO: complex arg: string_val - cmd.Flags().StringVar(&patchPublicAccountUserPreferenceReq.Setting.UserId, "user-id", patchPublicAccountUserPreferenceReq.Setting.UserId, `User ID of the user.`) + flags.StringPtrVar(cmd.Flags(), &patchPublicAccountUserPreferenceReq.UserId, "user-id", `User ID of the user.`) cmd.Use = "patch-public-account-user-preference USER_ID NAME" cmd.Short = `*Beta* Update a user preference.` @@ -482,6 +512,7 @@ Update a user preference. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := patchPublicAccountUserPreferenceJson.Unmarshal(&patchPublicAccountUserPreferenceReq.Setting) @@ -495,15 +526,23 @@ Update a user preference. } } } - patchPublicAccountUserPreferenceReq.UserId = args[0] - patchPublicAccountUserPreferenceReq.Name = args[1] + patchPublicAccountUserPreferenceReq.UserId = new(args[0]) + patchPublicAccountUserPreferenceReq.Name = new(args[1]) - response, err := a.SettingsV2.PatchPublicAccountUserPreference(ctx, patchPublicAccountUserPreferenceReq) + sdkReq, err := settings.PatchPublicAccountUserPreferenceRequestToSDK(&patchPublicAccountUserPreferenceReq) + if err != nil { + return err + } + response, err := a.Settings.PatchPublicAccountUserPreference(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := settings.UserPreferenceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/storage-credentials/storage-credentials.go b/cmd/account/storage-credentials/storage-credentials.go index ba3f3ded1b6..6496cf8e89b 100644 --- a/cmd/account/storage-credentials/storage-credentials.go +++ b/cmd/account/storage-credentials/storage-credentials.go @@ -9,8 +9,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + uccredentials "github.com/databricks/cli/libs/sdktypes/uc/credentials/v1" + sdkuccredentials "github.com/databricks/sdk-go/uc/credentials/v1" ) // Slice with functions to override default command behavior. @@ -51,19 +53,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.AccountsCreateStorageCredential, + *uccredentials.AccountsCreateStorageCredentialRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq uccredentials.AccountsCreateStorageCredentialRequest - var createReq catalog.AccountsCreateStorageCredential var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: credential_info - cmd.Flags().BoolVar(&createReq.SkipValidation, "skip-validation", createReq.SkipValidation, `Optional, default false.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.SkipValidation, "skip-validation", `Optional, default false.`) cmd.Use = "create METASTORE_ID" cmd.Short = `Create a storage credential.` @@ -92,6 +94,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -105,14 +108,22 @@ func newCreate() *cobra.Command { } } } - createReq.MetastoreId = args[0] + createReq.MetastoreId = new(args[0]) - response, err := a.StorageCredentials.Create(ctx, createReq) + sdkReq, err := uccredentials.AccountsCreateStorageCredentialRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Credentials.CreateAccountsStorageCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.AccountsCreateStorageCredentialResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -133,15 +144,14 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteAccountStorageCredentialRequest, + *uccredentials.AccountsDeleteStorageCredentialRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq uccredentials.AccountsDeleteStorageCredentialRequest - var deleteReq catalog.DeleteAccountStorageCredentialRequest - - cmd.Flags().BoolVar(&deleteReq.Force, "force", deleteReq.Force, `Force deletion even if the Storage Credential is not empty.`) + flags.BoolPtrVar(cmd.Flags(), &deleteReq.Force, "force", `Force deletion even if the Storage Credential is not empty.`) cmd.Use = "delete METASTORE_ID STORAGE_CREDENTIAL_NAME" cmd.Short = `Delete a storage credential.` @@ -167,16 +177,22 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.MetastoreId = args[0] - deleteReq.StorageCredentialName = args[1] + deleteReq.MetastoreId = new(args[0]) + deleteReq.NameArg = new(args[1]) - response, err := a.StorageCredentials.Delete(ctx, deleteReq) + sdkReq, err := uccredentials.AccountsDeleteStorageCredentialRequestToSDK(&deleteReq) + if err != nil { + return err + } + response, err := a.Credentials.DeleteAccountsStorageCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. @@ -197,13 +213,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetAccountStorageCredentialRequest, + *sdkuccredentials.AccountsGetStorageCredentialRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq catalog.GetAccountStorageCredentialRequest + var getReq sdkuccredentials.AccountsGetStorageCredentialRequest cmd.Use = "get METASTORE_ID STORAGE_CREDENTIAL_NAME" cmd.Short = `Gets the named storage credential.` @@ -230,16 +245,22 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.MetastoreId = args[0] - getReq.StorageCredentialName = args[1] + getReq.MetastoreId = new(args[0]) + getReq.NameArg = new(args[1]) - response, err := a.StorageCredentials.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Credentials.GetAccountsStorageCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.AccountsGetStorageCredentialResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -260,13 +281,13 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListAccountStorageCredentialsRequest, + *sdkuccredentials.AccountsListStorageCredentialsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq sdkuccredentials.AccountsListStorageCredentialsRequest - var listReq catalog.ListAccountStorageCredentialsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -300,10 +321,15 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - listReq.MetastoreId = args[0] + listReq.MetastoreId = new(args[0]) - response := a.StorageCredentials.List(ctx, listReq) + sdkReq := &listReq + response, err := a.Credentials.ListAccountsStorageCredentials(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -311,7 +337,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := uccredentials.AccountsListStorageCredentialsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.StorageCredentials) } // Disable completions since they are not applicable. @@ -332,19 +362,19 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.AccountsUpdateStorageCredential, + *uccredentials.AccountsUpdateStorageCredentialRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq uccredentials.AccountsUpdateStorageCredentialRequest - var updateReq catalog.AccountsUpdateStorageCredential var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: credential_info - cmd.Flags().BoolVar(&updateReq.SkipValidation, "skip-validation", updateReq.SkipValidation, `Optional.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.SkipValidation, "skip-validation", `Optional.`) cmd.Use = "update METASTORE_ID STORAGE_CREDENTIAL_NAME" cmd.Short = `Updates a storage credential.` @@ -371,6 +401,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -384,15 +415,23 @@ func newUpdate() *cobra.Command { } } } - updateReq.MetastoreId = args[0] - updateReq.StorageCredentialName = args[1] + updateReq.MetastoreId = new(args[0]) + updateReq.NameArg = new(args[1]) - response, err := a.StorageCredentials.Update(ctx, updateReq) + sdkReq, err := uccredentials.AccountsUpdateStorageCredentialRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := a.Credentials.UpdateAccountsStorageCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.AccountsUpdateStorageCredentialResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/storage/storage.go b/cmd/account/storage/storage.go index 116b58fc2ca..e6e4ca4bf06 100644 --- a/cmd/account/storage/storage.go +++ b/cmd/account/storage/storage.go @@ -9,8 +9,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/provisioning" "github.com/spf13/cobra" + + storageconfigurations "github.com/databricks/cli/libs/sdktypes/storageconfigurations/v1" + sdkstorageconfigurations "github.com/databricks/sdk-go/storageconfigurations/v1" ) // Slice with functions to override default command behavior. @@ -55,18 +57,18 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *provisioning.CreateStorageConfigurationRequest, + *storageconfigurations.CreateStorageConfigurationRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq storageconfigurations.CreateStorageConfigurationRequest - var createReq provisioning.CreateStorageConfigurationRequest 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.RoleArn, "role-arn", createReq.RoleArn, `Optional IAM role that is used to access the workspace catalog which is created during workspace creation for UC by Default.`) + flags.StringPtrVar(cmd.Flags(), &createReq.RoleArn, "role-arn", `Optional IAM role that is used to access the workspace catalog which is created during workspace creation for UC by Default.`) cmd.Use = "create" cmd.Short = `Create a storage configuration.` @@ -82,6 +84,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -98,12 +101,20 @@ func newCreate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := a.Storage.Create(ctx, createReq) + sdkReq, err := storageconfigurations.CreateStorageConfigurationRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.StorageConfigurations.CreateStorageConfigurationPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := storageconfigurations.StorageConfigurationFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -124,13 +135,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *provisioning.DeleteStorageRequest, + *sdkstorageconfigurations.DeleteStorageConfigurationRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq provisioning.DeleteStorageRequest + var deleteReq sdkstorageconfigurations.DeleteStorageConfigurationRequest cmd.Use = "delete STORAGE_CONFIGURATION_ID" cmd.Short = `Delete a storage configuration.` @@ -152,15 +162,21 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.StorageConfigurationId = args[0] + deleteReq.StorageConfigurationId = new(args[0]) - response, err := a.Storage.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.StorageConfigurations.DeleteStorageConfigurationPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := storageconfigurations.StorageConfigurationFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -181,13 +197,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *provisioning.GetStorageRequest, + *sdkstorageconfigurations.GetStorageConfigurationRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq provisioning.GetStorageRequest + var getReq sdkstorageconfigurations.GetStorageConfigurationRequest cmd.Use = "get STORAGE_CONFIGURATION_ID" cmd.Short = `Get a storage configuration.` @@ -208,15 +223,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.StorageConfigurationId = args[0] + getReq.StorageConfigurationId = new(args[0]) - response, err := a.Storage.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.StorageConfigurations.GetStorageConfigurationPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := storageconfigurations.StorageConfigurationFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -256,12 +277,17 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - response, err := a.Storage.List(ctx) + _ = a + + sdkReq := &sdkstorageconfigurations.ListStorageConfigurationRequest{} + + response, err := a.StorageConfigurations.ListStorageConfigurationPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. diff --git a/cmd/account/usage-dashboards/usage-dashboards.go b/cmd/account/usage-dashboards/usage-dashboards.go index 05d5d15177c..b2ccea3b166 100644 --- a/cmd/account/usage-dashboards/usage-dashboards.go +++ b/cmd/account/usage-dashboards/usage-dashboards.go @@ -7,8 +7,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/billing" "github.com/spf13/cobra" + + usagedashboards "github.com/databricks/cli/libs/sdktypes/usagedashboards/v1" ) // Slice with functions to override default command behavior. @@ -48,20 +49,20 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *billing.CreateBillingUsageDashboardRequest, + *usagedashboards.CreateBillingUsageDashboardRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq usagedashboards.CreateBillingUsageDashboardRequest - var createReq billing.CreateBillingUsageDashboardRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Var(&createReq.DashboardType, "dashboard-type", `Workspace level usage dashboard shows usage data for the specified workspace ID. Supported values: [USAGE_DASHBOARD_TYPE_GLOBAL, USAGE_DASHBOARD_TYPE_WORKSPACE]`) - cmd.Flags().Var(&createReq.MajorVersion, "major-version", `The major version of the usage dashboard template to use. Supported values: [USAGE_DASHBOARD_MAJOR_VERSION_1, USAGE_DASHBOARD_MAJOR_VERSION_2]`) - cmd.Flags().Int64Var(&createReq.WorkspaceId, "workspace-id", createReq.WorkspaceId, `The workspace ID of the workspace in which the usage dashboard is created.`) + flags.EnumVar(cmd.Flags(), &createReq.DashboardType, "dashboard-type", `Workspace level usage dashboard shows usage data for the specified workspace ID. Supported values: [USAGE_DASHBOARD_TYPE_GLOBAL, USAGE_DASHBOARD_TYPE_WORKSPACE]`, "UsageDashboardType", "USAGE_DASHBOARD_TYPE_GLOBAL", "USAGE_DASHBOARD_TYPE_WORKSPACE") + flags.EnumVar(cmd.Flags(), &createReq.MajorVersion, "major-version", `The major version of the usage dashboard template to use. Supported values: [USAGE_DASHBOARD_MAJOR_VERSION_1, USAGE_DASHBOARD_MAJOR_VERSION_2]`, "UsageDashboardMajorVersion", "USAGE_DASHBOARD_MAJOR_VERSION_1", "USAGE_DASHBOARD_MAJOR_VERSION_2") + flags.Int64PtrVar(cmd.Flags(), &createReq.WorkspaceId, "workspace-id", `The workspace ID of the workspace in which the usage dashboard is created.`) cmd.Use = "create" cmd.Short = `Create new usage dashboard.` @@ -83,6 +84,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -97,12 +99,20 @@ func newCreate() *cobra.Command { } } - response, err := a.UsageDashboards.Create(ctx, createReq) + sdkReq, err := usagedashboards.CreateBillingUsageDashboardRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.UsageDashboards.CreateBillingUsageDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := usagedashboards.CreateBillingUsageDashboardResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -123,16 +133,15 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *billing.GetBillingUsageDashboardRequest, + *usagedashboards.GetBillingUsageDashboardRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq usagedashboards.GetBillingUsageDashboardRequest - var getReq billing.GetBillingUsageDashboardRequest - - cmd.Flags().Var(&getReq.DashboardType, "dashboard-type", `Workspace level usage dashboard shows usage data for the specified workspace ID. Supported values: [USAGE_DASHBOARD_TYPE_GLOBAL, USAGE_DASHBOARD_TYPE_WORKSPACE]`) - cmd.Flags().Int64Var(&getReq.WorkspaceId, "workspace-id", getReq.WorkspaceId, `The workspace ID of the workspace in which the usage dashboard is created.`) + flags.EnumVar(cmd.Flags(), &getReq.DashboardType, "dashboard-type", `Workspace level usage dashboard shows usage data for the specified workspace ID. Supported values: [USAGE_DASHBOARD_TYPE_GLOBAL, USAGE_DASHBOARD_TYPE_WORKSPACE]`, "UsageDashboardType", "USAGE_DASHBOARD_TYPE_GLOBAL", "USAGE_DASHBOARD_TYPE_WORKSPACE") + flags.Int64PtrVar(cmd.Flags(), &getReq.WorkspaceId, "workspace-id", `The workspace ID of the workspace in which the usage dashboard is created.`) cmd.Use = "get" cmd.Short = `Get usage dashboard.` @@ -153,13 +162,22 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response, err := a.UsageDashboards.Get(ctx, getReq) + sdkReq, err := usagedashboards.GetBillingUsageDashboardRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := a.UsageDashboards.GetBillingUsageDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := usagedashboards.GetBillingUsageDashboardResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/users-v2/users-v2.go b/cmd/account/users-v2/users-v2.go index 5fff739b461..d1d01659874 100644 --- a/cmd/account/users-v2/users-v2.go +++ b/cmd/account/users-v2/users-v2.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" + + scim "github.com/databricks/cli/libs/sdktypes/scim/v1" + sdkscim "github.com/databricks/sdk-go/scim/v1" ) // Slice with functions to override default command behavior. @@ -62,25 +65,25 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *iam.CreateAccountUserRequest, + *scim.CreateAccountUserRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq scim.CreateAccountUserRequest - var createReq iam.CreateAccountUserRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createReq.Active, "active", createReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&createReq.DisplayName, "display-name", createReq.DisplayName, `String that represents a concatenation of given and family names.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.Active, "active", `If this user is active.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DisplayName, "display-name", `String that represents a concatenation of given and family names.`) // TODO: array: emails - cmd.Flags().StringVar(&createReq.ExternalId, "external-id", createReq.ExternalId, `External ID is not currently supported.`) - cmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Databricks user ID.`) + flags.StringPtrVar(cmd.Flags(), &createReq.ExternalId, "external-id", `External ID is not currently supported.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Id, "id", `Databricks user ID.`) // TODO: complex arg: name // TODO: array: roles - cmd.Flags().StringVar(&createReq.UserName, "user-name", createReq.UserName, `Email address of the Databricks user.`) + flags.StringPtrVar(cmd.Flags(), &createReq.UserName, "user-name", `Email address of the Databricks user.`) cmd.Use = "create" cmd.Short = `Create a new user.` @@ -102,6 +105,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -116,12 +120,20 @@ func newCreate() *cobra.Command { } } - response, err := a.UsersV2.Create(ctx, createReq) + sdkReq, err := scim.CreateAccountUserRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Scim.CreateAccountUser(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.AccountUserFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -142,13 +154,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *iam.DeleteAccountUserRequest, + *sdkscim.DeleteAccountUserRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq iam.DeleteAccountUserRequest + var deleteReq sdkscim.DeleteAccountUserRequest cmd.Use = "delete ID" cmd.Short = `Delete a user.` @@ -173,10 +184,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = a.UsersV2.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = a.Scim.DeleteAccountUser(ctx, *sdkReq) if err != nil { return err } @@ -201,21 +214,20 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *iam.GetAccountUserRequest, + *scim.GetAccountUserRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq scim.GetAccountUserRequest - var getReq iam.GetAccountUserRequest - - cmd.Flags().StringVar(&getReq.Attributes, "attributes", getReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().IntVar(&getReq.Count, "count", getReq.Count, `Desired number of results per page.`) - cmd.Flags().StringVar(&getReq.ExcludedAttributes, "excluded-attributes", getReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&getReq.Filter, "filter", getReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&getReq.SortBy, "sort-by", getReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&getReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) - cmd.Flags().IntVar(&getReq.StartIndex, "start-index", getReq.StartIndex, `Specifies the index of the first result.`) + flags.StringPtrVar(cmd.Flags(), &getReq.Attributes, "attributes", `Comma-separated list of attributes to return in response.`) + flags.IntPtrVar(cmd.Flags(), &getReq.Count, "count", `Desired number of results per page.`) + flags.StringPtrVar(cmd.Flags(), &getReq.ExcludedAttributes, "excluded-attributes", `Comma-separated list of attributes to exclude in response.`) + flags.StringPtrVar(cmd.Flags(), &getReq.Filter, "filter", `Query by which the results have to be filtered.`) + flags.StringPtrVar(cmd.Flags(), &getReq.SortBy, "sort-by", `Attribute to sort the results.`) + flags.EnumVar(cmd.Flags(), &getReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`, "GetSortOrder", "ascending", "descending") + flags.IntPtrVar(cmd.Flags(), &getReq.StartIndex, "start-index", `Specifies the index of the first result.`) cmd.Use = "get ID" cmd.Short = `Get user details.` @@ -239,15 +251,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := a.UsersV2.Get(ctx, getReq) + sdkReq, err := scim.GetAccountUserRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := a.Scim.GetAccountUser(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.AccountUserFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -268,31 +289,31 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *iam.ListAccountUsersRequest, + *scim.ListAccountUsersRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq scim.ListAccountUsersRequest - var listReq iam.ListAccountUsersRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.Attributes, "attributes", listReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().StringVar(&listReq.ExcludedAttributes, "excluded-attributes", listReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&listReq.Filter, "filter", listReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&listReq.SortBy, "sort-by", listReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) + flags.StringPtrVar(cmd.Flags(), &listReq.Attributes, "attributes", `Comma-separated list of attributes to return in response.`) + flags.StringPtrVar(cmd.Flags(), &listReq.ExcludedAttributes, "excluded-attributes", `Comma-separated list of attributes to exclude in response.`) + flags.StringPtrVar(cmd.Flags(), &listReq.Filter, "filter", `Query by which the results have to be filtered.`) + flags.StringPtrVar(cmd.Flags(), &listReq.SortBy, "sort-by", `Attribute to sort the results.`) + flags.EnumVar(cmd.Flags(), &listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`, "ListSortOrder", "ascending", "descending") // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().Int64Var(&listReq.StartIndex, "start-index", listReq.StartIndex, `Specifies the index of the first result.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.StartIndex, "start-index", `Specifies the index of the first result.`) cmd.Flags().Lookup("start-index").Hidden = true - cmd.Flags().Int64Var(&listReq.Count, "count", listReq.Count, `Number of results per API page.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.Count, "count", `Number of results per API page.`) cmd.Flags().Lookup("count").Hidden = true cmd.Use = "list" @@ -314,16 +335,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - response := a.UsersV2.List(ctx, listReq) + sdkReq, err := scim.ListAccountUsersRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := a.Scim.ListAccountUsersIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, scim.AccountUserFromSDK)) } // Disable completions since they are not applicable. @@ -344,13 +369,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var patchOverrides []func( *cobra.Command, - *iam.PatchAccountUserRequest, + *scim.PatchAccountUserRequest, ) func newPatch() *cobra.Command { cmd := &cobra.Command{} + var patchReq scim.PatchAccountUserRequest - var patchReq iam.PatchAccountUserRequest var patchJson flags.JsonFlag cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -382,6 +407,7 @@ func newPatch() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -395,9 +421,13 @@ func newPatch() *cobra.Command { } } } - patchReq.Id = args[0] + patchReq.Id = new(args[0]) - err = a.UsersV2.Patch(ctx, patchReq) + sdkReq, err := scim.PatchAccountUserRequestToSDK(&patchReq) + if err != nil { + return err + } + err = a.Scim.PatchAccountUser(ctx, *sdkReq) if err != nil { return err } @@ -422,24 +452,24 @@ func newPatch() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *iam.UpdateAccountUserRequest, + *scim.UpdateAccountUserRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq scim.UpdateAccountUserRequest - var updateReq iam.UpdateAccountUserRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&updateReq.Active, "active", updateReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&updateReq.DisplayName, "display-name", updateReq.DisplayName, `String that represents a concatenation of given and family names.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Active, "active", `If this user is active.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.DisplayName, "display-name", `String that represents a concatenation of given and family names.`) // TODO: array: emails - cmd.Flags().StringVar(&updateReq.ExternalId, "external-id", updateReq.ExternalId, `External ID is not currently supported.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.ExternalId, "external-id", `External ID is not currently supported.`) // TODO: complex arg: name // TODO: array: roles - cmd.Flags().StringVar(&updateReq.UserName, "user-name", updateReq.UserName, `Email address of the Databricks user.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.UserName, "user-name", `Email address of the Databricks user.`) cmd.Use = "update ID" cmd.Short = `Replace a user.` @@ -465,6 +495,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -478,9 +509,13 @@ func newUpdate() *cobra.Command { } } } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - err = a.UsersV2.Update(ctx, updateReq) + sdkReq, err := scim.UpdateAccountUserRequestToSDK(&updateReq) + if err != nil { + return err + } + err = a.Scim.UpdateAccountUser(ctx, *sdkReq) if err != nil { return err } diff --git a/cmd/account/users/overrides.go b/cmd/account/users/overrides.go index ff977334513..a94ff10f93a 100644 --- a/cmd/account/users/overrides.go +++ b/cmd/account/users/overrides.go @@ -2,12 +2,12 @@ package users import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *iam.ListAccountUsersRequest) { - listReq.Attributes = "id,userName,groups,active" +func listOverride(listCmd *cobra.Command) { + // Request only the columns the template shows unless --attributes is given. + _ = listCmd.Flags().Lookup("attributes").Value.Set("id,userName,groups,active") listCmd.Annotations["template"] = cmdio.Heredoc(` {{range .}}{{.Id|green}} {{.UserName}} {{range .Groups}}{{.Display}} {{end}} {{if .Active}}{{"ACTIVE"|green}}{{else}}DISABLED{{end}} {{end}}`) diff --git a/cmd/account/users/users.go b/cmd/account/users/users.go index 57218bafc65..2bf4d9af7f0 100755 --- a/cmd/account/users/users.go +++ b/cmd/account/users/users.go @@ -2,17 +2,11 @@ // but are now manually maintained because the v2 API versions have taken // over as the generated commands. See https://github.com/databricks/cli/pull/4722. -//nolint:staticcheck,perfsprint package users import ( - "fmt" - + users_v2 "github.com/databricks/cli/cmd/account/users-v2" "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/iam" "github.com/spf13/cobra" ) @@ -20,6 +14,11 @@ import ( // Functions can be added from the `init()` function in manually curated files in this directory. var cmdOverrides []func(*cobra.Command) +// Slices with functions to override the behavior of individual commands. +var listOverrides []func(*cobra.Command) + +// The commands are the users-v2 commands (same API) presented under their +// original names and help text. func New() *cobra.Command { cmd := &cobra.Command{ Use: "users", @@ -42,483 +41,102 @@ func New() *cobra.Command { RunE: root.ReportUnknownSubcommand, } - // Add methods - cmd.AddCommand(newCreate()) - cmd.AddCommand(newDelete()) - cmd.AddCommand(newGet()) - cmd.AddCommand(newList()) - cmd.AddCommand(newPatch()) - 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, - *iam.User, -) - -func newCreate() *cobra.Command { - cmd := &cobra.Command{} - - var createReq iam.User - var createJson flags.JsonFlag - - cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - cmd.Flags().BoolVar(&createReq.Active, "active", createReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&createReq.DisplayName, "display-name", createReq.DisplayName, `String that represents a concatenation of given and family names.`) - // TODO: array: emails - // TODO: array: entitlements - cmd.Flags().StringVar(&createReq.ExternalId, "external-id", createReq.ExternalId, `External ID is not currently supported.`) - // TODO: array: groups - cmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Databricks user ID.`) - // TODO: complex arg: name - // TODO: array: roles - // TODO: array: schemas - cmd.Flags().StringVar(&createReq.UserName, "user-name", createReq.UserName, `Email address of the Databricks user.`) - - cmd.Use = "create" - cmd.Short = `Create a new user.` - cmd.Long = `Create a new user. - - Creates a new user in the Databricks account. This new user will also be added - to the Databricks 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.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - if cmd.Flags().Changed("json") { - diags := createJson.Unmarshal(&createReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err + v2 := users_v2.New() + for _, sub := range v2.Commands() { + doc, ok := commandDocs[sub.Name()] + if !ok { + continue + } + v2.RemoveCommand(sub) + sub.Use = doc.use + if doc.short != "" { + sub.Short = doc.short + sub.Long = doc.long + } + sub.Hidden = doc.hidden + if sub.Name() == "list" { + // These were regular flags of the original commands. + for _, name := range []string{"count", "start-index"} { + if f := sub.Flags().Lookup(name); f != nil { + f.Hidden = false } } + for _, fn := range listOverrides { + fn(sub) + } } - - response, err := a.Users.Create(ctx, createReq) - if err != nil { - return err - } - return cmdio.Render(ctx, response) + cmd.AddCommand(sub) } - // 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) + for _, fn := range cmdOverrides { + fn(cmd) } 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, - *iam.DeleteAccountUserRequest, -) - -func newDelete() *cobra.Command { - cmd := &cobra.Command{} +type commandDoc struct { + use, short, long string + hidden bool +} - var deleteReq iam.DeleteAccountUserRequest +var commandDocs = map[string]commandDoc{ + "create": { + use: "create", + short: `Create a new user.`, + long: `Create a new user. - cmd.Use = "delete ID" - cmd.Short = `Delete a user.` - cmd.Long = `Delete a user. + Creates a new user in the Databricks account. This new user will also be added + to the Databricks account.`, + }, + "delete": { + use: "delete ID", + short: `Delete a user.`, + long: `Delete a user. Deletes a user. Deleting a user from a Databricks account also removes objects associated with the user. Arguments: - ID: Unique ID for a user in the Databricks account.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Account Users drop-down.") - names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID for a user in the Databricks account") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id for a user in the databricks account") - } - deleteReq.Id = args[0] - - err = a.Users.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, - *iam.GetAccountUserRequest, -) - -func newGet() *cobra.Command { - cmd := &cobra.Command{} - - var getReq iam.GetAccountUserRequest - - cmd.Flags().StringVar(&getReq.Attributes, "attributes", getReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().IntVar(&getReq.Count, "count", getReq.Count, `Desired number of results per page.`) - cmd.Flags().StringVar(&getReq.ExcludedAttributes, "excluded-attributes", getReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&getReq.Filter, "filter", getReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&getReq.SortBy, "sort-by", getReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&getReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) - cmd.Flags().IntVar(&getReq.StartIndex, "start-index", getReq.StartIndex, `Specifies the index of the first result.`) - - cmd.Use = "get ID" - cmd.Short = `Get user details.` - cmd.Long = `Get user details. + ID: Unique ID for a user in the Databricks account.`, + }, + "get": { + use: "get ID", + short: `Get user details.`, + long: `Get user details. Gets information for a specific user in Databricks account. Arguments: - ID: Unique ID for a user in the Databricks account.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Account Users drop-down.") - names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID for a user in the Databricks account") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id for a user in the databricks account") - } - getReq.Id = args[0] - - response, err := a.Users.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, - *iam.ListAccountUsersRequest, -) - -func newList() *cobra.Command { - cmd := &cobra.Command{} - - var listReq iam.ListAccountUsersRequest - - cmd.Flags().StringVar(&listReq.Attributes, "attributes", listReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().Int64Var(&listReq.Count, "count", listReq.Count, `Desired number of results per page.`) - cmd.Flags().StringVar(&listReq.ExcludedAttributes, "excluded-attributes", listReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&listReq.Filter, "filter", listReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&listReq.SortBy, "sort-by", listReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) - cmd.Flags().Int64Var(&listReq.StartIndex, "start-index", listReq.StartIndex, `Specifies the index of the first result.`) - - cmd.Use = "list" - cmd.Short = `List users.` - cmd.Long = `List users. - - Gets details for all the users associated with a Databricks 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.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - response := a.Users.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 patch 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 patchOverrides []func( - *cobra.Command, - *iam.PartialUpdate, -) - -func newPatch() *cobra.Command { - cmd := &cobra.Command{} - - var patchReq iam.PartialUpdate - var patchJson flags.JsonFlag - - cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - // TODO: array: Operations - // TODO: array: schemas - - cmd.Use = "patch ID" - cmd.Short = `Update user details.` - cmd.Long = `Update user details. + ID: Unique ID for a user in the Databricks account.`, + }, + "list": { + use: "list", + short: `List users.`, + long: `List users. + + Gets details for all the users associated with a Databricks account.`, + }, + "patch": { + use: "patch ID", + short: `Update user details.`, + long: `Update user details. Partially updates a user resource by applying the supplied operations on specific user attributes. Arguments: - ID: Unique ID in the Databricks workspace.` - - cmd.Annotations = make(map[string]string) - - 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 := patchJson.Unmarshal(&patchReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Account Users drop-down.") - names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID in the Databricks workspace") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id in the databricks workspace") - } - patchReq.Id = args[0] - - err = a.Users.Patch(ctx, patchReq) - 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 patchOverrides { - fn(cmd, &patchReq) - } - - 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, - *iam.User, -) - -func newUpdate() *cobra.Command { - cmd := &cobra.Command{} - - var updateReq iam.User - var updateJson flags.JsonFlag - - cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - cmd.Flags().BoolVar(&updateReq.Active, "active", updateReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&updateReq.DisplayName, "display-name", updateReq.DisplayName, `String that represents a concatenation of given and family names.`) - // TODO: array: emails - // TODO: array: entitlements - cmd.Flags().StringVar(&updateReq.ExternalId, "external-id", updateReq.ExternalId, `External ID is not currently supported.`) - // TODO: array: groups - cmd.Flags().StringVar(&updateReq.Id, "id", updateReq.Id, `Databricks user ID.`) - // TODO: complex arg: name - // TODO: array: roles - // TODO: array: schemas - cmd.Flags().StringVar(&updateReq.UserName, "user-name", updateReq.UserName, `Email address of the Databricks user.`) - - cmd.Use = "update ID" - cmd.Short = `Replace a user.` - cmd.Long = `Replace a user. + ID: Unique ID in the Databricks workspace.`, + }, + "update": { + use: "update ID", + short: `Replace a user.`, + long: `Replace a user. Replaces a user's information with the data supplied in request. Arguments: - ID: Databricks user ID.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustAccountClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - a := cmdctx.AccountClient(ctx) - - if cmd.Flags().Changed("json") { - diags := updateJson.Unmarshal(&updateReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Account Users drop-down.") - names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks user ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks user id") - } - updateReq.Id = args[0] - - err = a.Users.Update(ctx, updateReq) - 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 updateOverrides { - fn(cmd, &updateReq) - } - - return cmd + ID: Databricks user ID.`, + }, } - -// end service AccountUsers diff --git a/cmd/account/vpc-endpoints/vpc-endpoints.go b/cmd/account/vpc-endpoints/vpc-endpoints.go index d05ae2fc063..f8765cdebd3 100644 --- a/cmd/account/vpc-endpoints/vpc-endpoints.go +++ b/cmd/account/vpc-endpoints/vpc-endpoints.go @@ -7,8 +7,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/provisioning" "github.com/spf13/cobra" + + networking "github.com/databricks/cli/libs/sdktypes/networking/v1" + sdknetworking "github.com/databricks/sdk-go/networking/v1" ) // Slice with functions to override default command behavior. @@ -48,21 +50,21 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *provisioning.CreateVpcEndpointRequest, + *networking.CreateVpcEndpointRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq networking.CreateVpcEndpointRequest - var createReq provisioning.CreateVpcEndpointRequest 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.AwsVpcEndpointId, "aws-vpc-endpoint-id", createReq.AwsVpcEndpointId, `The ID of the VPC endpoint object in AWS.`) + flags.StringPtrVar(cmd.Flags(), &createReq.AwsVpcEndpointId, "aws-vpc-endpoint-id", `The ID of the VPC endpoint object in AWS.`) // TODO: complex arg: gcp_vpc_endpoint_info - cmd.Flags().StringVar(&createReq.Region, "region", createReq.Region, `The region in which this VPC endpoint object exists.`) - cmd.Flags().StringVar(&createReq.VpcEndpointName, "vpc-endpoint-name", createReq.VpcEndpointName, `The human-readable name of the storage configuration.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Region, "region", `The region in which this VPC endpoint object exists.`) + flags.StringPtrVar(cmd.Flags(), &createReq.VpcEndpointName, "vpc-endpoint-name", `The human-readable name of the storage configuration.`) cmd.Use = "create" cmd.Short = `Create a VPC endpoint configuration.` @@ -95,6 +97,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -109,12 +112,20 @@ func newCreate() *cobra.Command { } } - response, err := a.VpcEndpoints.Create(ctx, createReq) + sdkReq, err := networking.CreateVpcEndpointRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := a.Networking.CreateVpcEndpointPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.VpcEndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -135,13 +146,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *provisioning.DeleteVpcEndpointRequest, + *sdknetworking.DeleteVpcEndpointRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq provisioning.DeleteVpcEndpointRequest + var deleteReq sdknetworking.DeleteVpcEndpointRequest cmd.Use = "delete VPC_ENDPOINT_ID" cmd.Short = `Delete a VPC endpoint configuration.` @@ -163,15 +173,21 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - deleteReq.VpcEndpointId = args[0] + deleteReq.VpcEndpointId = new(args[0]) - response, err := a.VpcEndpoints.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.Networking.DeleteVpcEndpointPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.VpcEndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -192,13 +208,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *provisioning.GetVpcEndpointRequest, + *sdknetworking.GetVpcEndpointRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq provisioning.GetVpcEndpointRequest + var getReq sdknetworking.GetVpcEndpointRequest cmd.Use = "get VPC_ENDPOINT_ID" cmd.Short = `Get a VPC endpoint configuration.` @@ -226,15 +241,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - getReq.VpcEndpointId = args[0] + getReq.VpcEndpointId = new(args[0]) - response, err := a.VpcEndpoints.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Networking.GetVpcEndpointPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.VpcEndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -274,12 +295,17 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - response, err := a.VpcEndpoints.List(ctx) + _ = a + + sdkReq := &sdknetworking.ListVpcEndpointRequest{} + + response, err := a.Networking.ListVpcEndpointPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. diff --git a/cmd/account/workspace-assignment/workspace-assignment.go b/cmd/account/workspace-assignment/workspace-assignment.go index 08895b11b96..2ac13a16bf1 100644 --- a/cmd/account/workspace-assignment/workspace-assignment.go +++ b/cmd/account/workspace-assignment/workspace-assignment.go @@ -9,8 +9,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" ) // Slice with functions to override default command behavior. @@ -51,13 +53,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *iam.DeleteWorkspaceAssignmentRequest, + *sdkaccessmanagement.DeleteWorkspacePermissionAssignmentRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq iam.DeleteWorkspaceAssignmentRequest + var deleteReq sdkaccessmanagement.DeleteWorkspacePermissionAssignmentRequest cmd.Use = "delete WORKSPACE_ID PRINCIPAL_ID" cmd.Short = `Delete permissions assignment.` @@ -83,21 +84,28 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &deleteReq.WorkspaceId) + var deleteWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &deleteWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &deleteReq.PrincipalId) + deleteReq.WorkspaceId = &deleteWorkspaceIdArg + var deletePrincipalIdArg int64 + _, err = fmt.Sscan(args[1], &deletePrincipalIdArg) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } + deleteReq.PrincipalId = &deletePrincipalIdArg - err = a.WorkspaceAssignment.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.AccessManagement.DeleteWorkspacePermissionAssignment(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -119,13 +127,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *iam.GetWorkspaceAssignmentRequest, + *sdkaccessmanagement.ListWorkspacePermissionsRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq iam.GetWorkspaceAssignmentRequest + var getReq sdkaccessmanagement.ListWorkspacePermissionsRequest cmd.Use = "get WORKSPACE_ID" cmd.Short = `List workspace permissions.` @@ -149,18 +156,26 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &getReq.WorkspaceId) + var getWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &getWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + getReq.WorkspaceId = &getWorkspaceIdArg - response, err := a.WorkspaceAssignment.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.AccessManagement.ListWorkspacePermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListWorkspacePermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -181,13 +196,13 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *iam.ListWorkspaceAssignmentRequest, + *sdkaccessmanagement.ListWorkspacePermissionAssignmentsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq sdkaccessmanagement.ListWorkspacePermissionAssignmentsRequest - var listReq iam.ListWorkspaceAssignmentRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -221,13 +236,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &listReq.WorkspaceId) + var listWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &listWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + listReq.WorkspaceId = &listWorkspaceIdArg - response := a.WorkspaceAssignment.List(ctx, listReq) + sdkReq := &listReq + response, err := a.AccessManagement.ListWorkspacePermissionAssignments(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -235,7 +257,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := accessmanagement.ListWorkspacePermissionAssignmentsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.PermissionAssignments) } // Disable completions since they are not applicable. @@ -256,13 +282,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *iam.UpdateWorkspaceAssignments, + *accessmanagement.UpdateWorkspacePermissionAssignmentRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq accessmanagement.UpdateWorkspacePermissionAssignmentRequest - var updateReq iam.UpdateWorkspaceAssignments var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -293,6 +319,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -306,22 +333,33 @@ func newUpdate() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &updateReq.WorkspaceId) + var updateWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &updateWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &updateReq.PrincipalId) + updateReq.WorkspaceId = &updateWorkspaceIdArg + var updatePrincipalIdArg int64 + _, err = fmt.Sscan(args[1], &updatePrincipalIdArg) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } + updateReq.PrincipalId = &updatePrincipalIdArg - response, err := a.WorkspaceAssignment.Update(ctx, updateReq) + sdkReq, err := accessmanagement.UpdateWorkspacePermissionAssignmentRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := a.AccessManagement.UpdateWorkspacePermissionAssignment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.WorkspacePermissionAssignmentOutputFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/workspace-network-configuration/workspace-network-configuration.go b/cmd/account/workspace-network-configuration/workspace-network-configuration.go index 58ef41e0119..142c1b19039 100644 --- a/cmd/account/workspace-network-configuration/workspace-network-configuration.go +++ b/cmd/account/workspace-network-configuration/workspace-network-configuration.go @@ -9,8 +9,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" + + networking "github.com/databricks/cli/libs/sdktypes/networking/v1" + sdknetworking "github.com/databricks/sdk-go/networking/v1" ) // Slice with functions to override default command behavior. @@ -54,13 +56,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getWorkspaceNetworkOptionRpcOverrides []func( *cobra.Command, - *settings.GetWorkspaceNetworkOptionRequest, + *sdknetworking.GetWorkspaceNetworkOptionRequest, ) func newGetWorkspaceNetworkOptionRpc() *cobra.Command { cmd := &cobra.Command{} - - var getWorkspaceNetworkOptionRpcReq settings.GetWorkspaceNetworkOptionRequest + var getWorkspaceNetworkOptionRpcReq sdknetworking.GetWorkspaceNetworkOptionRequest cmd.Use = "get-workspace-network-option-rpc WORKSPACE_ID" cmd.Short = `Get workspace network option.` @@ -86,18 +87,26 @@ func newGetWorkspaceNetworkOptionRpc() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &getWorkspaceNetworkOptionRpcReq.WorkspaceId) + var getWorkspaceNetworkOptionRpcWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &getWorkspaceNetworkOptionRpcWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + getWorkspaceNetworkOptionRpcReq.WorkspaceId = &getWorkspaceNetworkOptionRpcWorkspaceIdArg - response, err := a.WorkspaceNetworkConfiguration.GetWorkspaceNetworkOptionRpc(ctx, getWorkspaceNetworkOptionRpcReq) + sdkReq := &getWorkspaceNetworkOptionRpcReq + response, err := a.Networking.GetWorkspaceNetworkOptionRpc(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.WorkspaceNetworkOptionFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -118,20 +127,20 @@ func newGetWorkspaceNetworkOptionRpc() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateWorkspaceNetworkOptionRpcOverrides []func( *cobra.Command, - *settings.UpdateWorkspaceNetworkOptionRequest, + *networking.UpdateWorkspaceNetworkOptionRequest, ) func newUpdateWorkspaceNetworkOptionRpc() *cobra.Command { cmd := &cobra.Command{} + var updateWorkspaceNetworkOptionRpcReq networking.UpdateWorkspaceNetworkOptionRequest + updateWorkspaceNetworkOptionRpcReq.WorkspaceNetworkOption = &networking.WorkspaceNetworkOption{} - var updateWorkspaceNetworkOptionRpcReq settings.UpdateWorkspaceNetworkOptionRequest - updateWorkspaceNetworkOptionRpcReq.WorkspaceNetworkOption = settings.WorkspaceNetworkOption{} var updateWorkspaceNetworkOptionRpcJson flags.JsonFlag cmd.Flags().Var(&updateWorkspaceNetworkOptionRpcJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateWorkspaceNetworkOptionRpcReq.WorkspaceNetworkOption.NetworkPolicyId, "network-policy-id", updateWorkspaceNetworkOptionRpcReq.WorkspaceNetworkOption.NetworkPolicyId, `The network policy ID to apply to the workspace.`) - cmd.Flags().Int64Var(&updateWorkspaceNetworkOptionRpcReq.WorkspaceNetworkOption.WorkspaceId, "workspace-id", updateWorkspaceNetworkOptionRpcReq.WorkspaceNetworkOption.WorkspaceId, `The workspace ID.`) + flags.StringPtrVar(cmd.Flags(), &updateWorkspaceNetworkOptionRpcReq.WorkspaceNetworkOption.NetworkPolicyId, "network-policy-id", `The network policy ID to apply to the workspace.`) + flags.Int64PtrVar(cmd.Flags(), &updateWorkspaceNetworkOptionRpcReq.WorkspaceId, "workspace-id", `The workspace ID.`) cmd.Use = "update-workspace-network-option-rpc WORKSPACE_ID" cmd.Short = `Update workspace network option.` @@ -157,6 +166,7 @@ func newUpdateWorkspaceNetworkOptionRpc() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateWorkspaceNetworkOptionRpcJson.Unmarshal(&updateWorkspaceNetworkOptionRpcReq.WorkspaceNetworkOption) @@ -170,17 +180,27 @@ func newUpdateWorkspaceNetworkOptionRpc() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &updateWorkspaceNetworkOptionRpcReq.WorkspaceId) + var updateWorkspaceNetworkOptionRpcWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &updateWorkspaceNetworkOptionRpcWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + updateWorkspaceNetworkOptionRpcReq.WorkspaceId = &updateWorkspaceNetworkOptionRpcWorkspaceIdArg - response, err := a.WorkspaceNetworkConfiguration.UpdateWorkspaceNetworkOptionRpc(ctx, updateWorkspaceNetworkOptionRpcReq) + sdkReq, err := networking.UpdateWorkspaceNetworkOptionRequestToSDK(&updateWorkspaceNetworkOptionRpcReq) + if err != nil { + return err + } + response, err := a.Networking.UpdateWorkspaceNetworkOptionRpc(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.WorkspaceNetworkOptionFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/account/workspaces/workspaces.go b/cmd/account/workspaces/workspaces.go index 1025f94e68b..1b0b03ee566 100644 --- a/cmd/account/workspaces/workspaces.go +++ b/cmd/account/workspaces/workspaces.go @@ -8,10 +8,14 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/provisioning" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + workspaces "github.com/databricks/cli/libs/sdktypes/workspaces/v1" + sdkworkspaces "github.com/databricks/sdk-go/workspaces/v1" ) // Slice with functions to override default command behavior. @@ -59,13 +63,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *provisioning.CreateWorkspaceRequest, + *workspaces.CreateWorkspaceRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq workspaces.CreateWorkspaceRequest - var createReq provisioning.CreateWorkspaceRequest var createJson flags.JsonFlag var createSkipWait bool @@ -76,31 +80,31 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createReq.AwsRegion, "aws-region", createReq.AwsRegion, ``) - cmd.Flags().StringVar(&createReq.Cloud, "cloud", createReq.Cloud, `DEPRECATED: This field is being ignored by the server and will be removed in the future.`) + flags.StringPtrVar(cmd.Flags(), &createReq.AwsRegion, "aws-region", ``) + flags.StringPtrVar(cmd.Flags(), &createReq.Cloud, "cloud", `DEPRECATED: This field is being ignored by the server and will be removed in the future.`) // TODO: complex arg: cloud_resource_container - cmd.Flags().Var(&createReq.ComputeMode, "compute-mode", `If the compute mode is SERVERLESS, a serverless workspace is created that comes pre-configured with serverless compute and default storage, providing a fully-managed, enterprise-ready SaaS experience. Supported values: [HYBRID, SERVERLESS]`) - cmd.Flags().StringVar(&createReq.CredentialsId, "credentials-id", createReq.CredentialsId, `ID of the workspace's credential configuration object.`) + flags.EnumVar(cmd.Flags(), &createReq.ComputeMode, "compute-mode", `If the compute mode is SERVERLESS, a serverless workspace is created that comes pre-configured with serverless compute and default storage, providing a fully-managed, enterprise-ready SaaS experience. Supported values: [HYBRID, SERVERLESS]`, "CustomerFacingComputeMode", "HYBRID", "SERVERLESS") + flags.StringPtrVar(cmd.Flags(), &createReq.CredentialsId, "credentials-id", `ID of the workspace's credential configuration object.`) // TODO: map via StringToStringVar: custom_tags - cmd.Flags().StringVar(&createReq.DeploymentName, "deployment-name", createReq.DeploymentName, `The deployment name defines part of the subdomain for the workspace.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DeploymentName, "deployment-name", `The deployment name defines part of the subdomain for the workspace.`) // TODO: complex arg: gcp_managed_network_config // TODO: complex arg: gke_config - cmd.Flags().StringVar(&createReq.Location, "location", createReq.Location, `The Google Cloud region of the workspace data plane in your Google account (for example, us-east4).`) - cmd.Flags().StringVar(&createReq.ManagedServicesCustomerManagedKeyId, "managed-services-customer-managed-key-id", createReq.ManagedServicesCustomerManagedKeyId, `The ID of the workspace's managed services encryption key configuration object.`) - cmd.Flags().StringVar(&createReq.NetworkConnectivityConfigId, "network-connectivity-config-id", createReq.NetworkConnectivityConfigId, `The object ID of network connectivity config.`) - cmd.Flags().StringVar(&createReq.NetworkId, "network-id", createReq.NetworkId, `The ID of the workspace's network configuration object.`) - cmd.Flags().Var(&createReq.PricingTier, "pricing-tier", `Supported values: [ + flags.StringPtrVar(cmd.Flags(), &createReq.Location, "location", `The Google Cloud region of the workspace data plane in your Google account (for example, us-east4).`) + flags.StringPtrVar(cmd.Flags(), &createReq.ManagedServicesCustomerManagedKeyId, "managed-services-customer-managed-key-id", `The ID of the workspace's managed services encryption key configuration object.`) + flags.StringPtrVar(cmd.Flags(), &createReq.NetworkConnectivityConfigId, "network-connectivity-config-id", `The object ID of network connectivity config.`) + flags.StringPtrVar(cmd.Flags(), &createReq.NetworkId, "network-id", `The ID of the workspace's network configuration object.`) + flags.EnumVar(cmd.Flags(), &createReq.PricingTier, "pricing-tier", `Supported values: [ COMMUNITY_EDITION, DEDICATED, ENTERPRISE, PREMIUM, STANDARD, UNKNOWN, -]`) - cmd.Flags().StringVar(&createReq.PrivateAccessSettingsId, "private-access-settings-id", createReq.PrivateAccessSettingsId, `ID of the workspace's private access settings object.`) - cmd.Flags().StringVar(&createReq.StorageConfigurationId, "storage-configuration-id", createReq.StorageConfigurationId, `ID of the workspace's storage configuration object.`) - cmd.Flags().StringVar(&createReq.StorageCustomerManagedKeyId, "storage-customer-managed-key-id", createReq.StorageCustomerManagedKeyId, `The ID of the workspace's storage encryption key configuration object.`) - cmd.Flags().StringVar(&createReq.WorkspaceName, "workspace-name", createReq.WorkspaceName, `The human-readable name of the workspace.`) +]`, "PricingTier", "COMMUNITY_EDITION", "DEDICATED", "ENTERPRISE", "PREMIUM", "STANDARD", "UNKNOWN") + flags.StringPtrVar(cmd.Flags(), &createReq.PrivateAccessSettingsId, "private-access-settings-id", `ID of the workspace's private access settings object.`) + flags.StringPtrVar(cmd.Flags(), &createReq.StorageConfigurationId, "storage-configuration-id", `ID of the workspace's storage configuration object.`) + flags.StringPtrVar(cmd.Flags(), &createReq.StorageCustomerManagedKeyId, "storage-customer-managed-key-id", `The ID of the workspace's storage encryption key configuration object.`) + flags.StringPtrVar(cmd.Flags(), &createReq.WorkspaceName, "workspace-name", `The human-readable name of the workspace.`) cmd.Use = "create" cmd.Short = `Create a workspace.` @@ -156,6 +160,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -170,23 +175,39 @@ func newCreate() *cobra.Command { } } - wait, err := a.Workspaces.Create(ctx, createReq) + sdkReq, err := workspaces.CreateWorkspaceRequestToSDK(&createReq) + if err != nil { + return err + } + wait, err := a.Workspaces.CreateWorkspacePublic(ctx, *sdkReq) if err != nil { return err } if createSkipWait { - return cmdio.Render(ctx, wait.Response) + // Render the current state, as of right after the call. + current, err := a.Workspaces.GetWorkspacePublic(ctx, sdkworkspaces.GetWorkspaceRequest{WorkspaceId: new(wait.GetWorkspaceId())}) + if err != nil { + return err + } + out, err := workspaces.WorkspaceFromSDK(current) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *provisioning.Workspace) { - statusMessage := i.WorkspaceStatusMessage - sp.Update(statusMessage) - }).GetWithTimeout(createTimeout) + sp.Update("Waiting for create to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := workspaces.WorkspaceFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -207,13 +228,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *provisioning.DeleteWorkspaceRequest, + *sdkworkspaces.DeleteWorkspaceRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq provisioning.DeleteWorkspaceRequest + var deleteReq sdkworkspaces.DeleteWorkspaceRequest cmd.Use = "delete WORKSPACE_ID" cmd.Short = `Delete a workspace.` @@ -234,18 +254,26 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &deleteReq.WorkspaceId) + var deleteWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &deleteWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + deleteReq.WorkspaceId = &deleteWorkspaceIdArg - response, err := a.Workspaces.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := a.Workspaces.DeleteWorkspacePublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := workspaces.WorkspaceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -266,13 +294,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *provisioning.GetWorkspaceRequest, + *sdkworkspaces.GetWorkspaceRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq provisioning.GetWorkspaceRequest + var getReq sdkworkspaces.GetWorkspaceRequest cmd.Use = "get WORKSPACE_ID" cmd.Short = `Get a workspace.` @@ -301,18 +328,26 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a - _, err = fmt.Sscan(args[0], &getReq.WorkspaceId) + var getWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &getWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + getReq.WorkspaceId = &getWorkspaceIdArg - response, err := a.Workspaces.Get(ctx, getReq) + sdkReq := &getReq + response, err := a.Workspaces.GetWorkspacePublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := workspaces.WorkspaceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -352,12 +387,17 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) - response, err := a.Workspaces.List(ctx) + _ = a + + sdkReq := &sdkworkspaces.ListWorkspacesRequest{} + + response, err := a.Workspaces.ListWorkspacesPublic(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. @@ -378,14 +418,14 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *provisioning.UpdateWorkspaceRequest, + *workspaces.UpdateWorkspaceRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq workspaces.UpdateWorkspaceRequest + updateReq.CustomerFacingWorkspace = &workspaces.Workspace{} - var updateReq provisioning.UpdateWorkspaceRequest - updateReq.CustomerFacingWorkspace = provisioning.Workspace{} var updateJson flags.JsonFlag var updateSkipWait bool @@ -396,33 +436,33 @@ func newUpdate() *cobra.Command { cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateReq.UpdateMask, "update-mask", updateReq.UpdateMask, `The field mask must be a single string, with multiple fields separated by commas (no spaces).`) - cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.AwsRegion, "aws-region", updateReq.CustomerFacingWorkspace.AwsRegion, ``) + flags.StringPtrVar(cmd.Flags(), &updateReq.UpdateMask, "update-mask", `The field mask must be a single string, with multiple fields separated by commas (no spaces).`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.AwsRegion, "aws-region", ``) // TODO: complex arg: azure_workspace_info - cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.Cloud, "cloud", updateReq.CustomerFacingWorkspace.Cloud, `The cloud name.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.Cloud, "cloud", `The cloud name.`) // TODO: complex arg: cloud_resource_container - cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.CredentialsId, "credentials-id", updateReq.CustomerFacingWorkspace.CredentialsId, `ID of the workspace's credential configuration object.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.CredentialsId, "credentials-id", `ID of the workspace's credential configuration object.`) // TODO: map via StringToStringVar: custom_tags - cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.DeploymentName, "deployment-name", updateReq.CustomerFacingWorkspace.DeploymentName, ``) - cmd.Flags().Var(&updateReq.CustomerFacingWorkspace.ExpectedWorkspaceStatus, "expected-workspace-status", `A client owned field used to indicate the workspace status that the client expects to be in. Supported values: [ + flags.StringPtrVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.DeploymentName, "deployment-name", ``) + flags.EnumVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.ExpectedWorkspaceStatus, "expected-workspace-status", `A client owned field used to indicate the workspace status that the client expects to be in. Supported values: [ BANNED, CANCELLING, FAILED, NOT_PROVISIONED, PROVISIONING, RUNNING, -]`) +]`, "WorkspaceStatus", "BANNED", "CANCELLING", "FAILED", "NOT_PROVISIONED", "PROVISIONING", "RUNNING") // TODO: complex arg: gcp_managed_network_config // TODO: complex arg: gke_config - cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.Location, "location", updateReq.CustomerFacingWorkspace.Location, `The Google Cloud region of the workspace data plane in your Google account (for example, us-east4).`) - cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.ManagedServicesCustomerManagedKeyId, "managed-services-customer-managed-key-id", updateReq.CustomerFacingWorkspace.ManagedServicesCustomerManagedKeyId, `ID of the key configuration for encrypting managed services.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.Location, "location", `The Google Cloud region of the workspace data plane in your Google account (for example, us-east4).`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.ManagedServicesCustomerManagedKeyId, "managed-services-customer-managed-key-id", `ID of the key configuration for encrypting managed services.`) // TODO: complex arg: network - cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.NetworkConnectivityConfigId, "network-connectivity-config-id", updateReq.CustomerFacingWorkspace.NetworkConnectivityConfigId, `The object ID of network connectivity config.`) - cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.NetworkId, "network-id", updateReq.CustomerFacingWorkspace.NetworkId, `If this workspace is BYO VPC, then the network_id will be populated.`) - cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.PrivateAccessSettingsId, "private-access-settings-id", updateReq.CustomerFacingWorkspace.PrivateAccessSettingsId, `ID of the workspace's private access settings object.`) - cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.StorageConfigurationId, "storage-configuration-id", updateReq.CustomerFacingWorkspace.StorageConfigurationId, `ID of the workspace's storage configuration object.`) - cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.StorageCustomerManagedKeyId, "storage-customer-managed-key-id", updateReq.CustomerFacingWorkspace.StorageCustomerManagedKeyId, `ID of the key configuration for encrypting workspace storage.`) - cmd.Flags().StringVar(&updateReq.CustomerFacingWorkspace.WorkspaceName, "workspace-name", updateReq.CustomerFacingWorkspace.WorkspaceName, `The human-readable name of the workspace.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.NetworkConnectivityConfigId, "network-connectivity-config-id", `The object ID of network connectivity config.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.NetworkId, "network-id", `If this workspace is BYO VPC, then the network_id will be populated.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.PrivateAccessSettingsId, "private-access-settings-id", `ID of the workspace's private access settings object.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.StorageConfigurationId, "storage-configuration-id", `ID of the workspace's storage configuration object.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.StorageCustomerManagedKeyId, "storage-customer-managed-key-id", `ID of the key configuration for encrypting workspace storage.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CustomerFacingWorkspace.WorkspaceName, "workspace-name", `The human-readable name of the workspace.`) cmd.Use = "update WORKSPACE_ID" cmd.Short = `Update a workspace.` @@ -446,6 +486,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() a := cmdctx.AccountClient(ctx) + _ = a if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.CustomerFacingWorkspace) @@ -459,28 +500,46 @@ func newUpdate() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &updateReq.WorkspaceId) + var updateWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &updateWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + updateReq.CustomerFacingWorkspace.WorkspaceId = &updateWorkspaceIdArg - wait, err := a.Workspaces.Update(ctx, updateReq) + sdkReq, err := workspaces.UpdateWorkspaceRequestToSDK(&updateReq) + if err != nil { + return err + } + wait, err := a.Workspaces.UpdateWorkspacePublic(ctx, *sdkReq) if err != nil { return err } if updateSkipWait { - return cmdio.Render(ctx, wait.Response) + // Render the current state, as of right after the call. + current, err := a.Workspaces.GetWorkspacePublic(ctx, sdkworkspaces.GetWorkspaceRequest{WorkspaceId: new(wait.GetWorkspaceId())}) + if err != nil { + return err + } + out, err := workspaces.WorkspaceFromSDK(current) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *provisioning.Workspace) { - statusMessage := i.WorkspaceStatusMessage - sp.Update(statusMessage) - }).GetWithTimeout(updateTimeout) + sp.Update("Waiting for update to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(updateTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := workspaces.WorkspaceFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/air/aitraining.go b/cmd/air/aitraining.go index 594489a5d74..db90009c9bd 100644 --- a/cmd/air/aitraining.go +++ b/cmd/air/aitraining.go @@ -7,9 +7,9 @@ import ( "net/http" "time" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/auth" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/cli/libs/sdkclients" ) // aiTrainingWorkflowsPath is the AiTrainingService index of the caller's own AIR @@ -40,8 +40,8 @@ type aiTrainingWorkflowsResponse struct { // listAiTrainingWorkflows pages the index and returns every workflow ref the // caller owns. Pagination stops at the end or when a page token repeats, which // guards against a stuck or cycling cursor without an arbitrary page cap. -func listAiTrainingWorkflows(ctx context.Context, w *databricks.WorkspaceClient, activeOnly bool) ([]workflowRef, error) { - apiClient, err := client.New(w.Config) +func listAiTrainingWorkflows(ctx context.Context, w *sdkclients.Clients, activeOnly bool) ([]workflowRef, error) { + apiClient, err := apiclient.New(w.Config) if err != nil { return nil, fmt.Errorf("failed to create API client: %w", err) } diff --git a/cmd/air/apierror_test.go b/cmd/air/apierror_test.go new file mode 100644 index 00000000000..8c8a7bd6875 --- /dev/null +++ b/cmd/air/apierror_test.go @@ -0,0 +1,39 @@ +package aircmd + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/sdk-go/core/apierr" +) + +func newAPIError(status int, errorCode, message string) *apierr.APIError { + body, _ := json.Marshal(map[string]string{"error_code": errorCode, "message": message}) + return apierr.FromHTTPError(status, nil, body) +} + +// fakeWorkspace serves routes keyed by "METHOD /path" and answers any other +// request (e.g. the host metadata probe) with "{}". It returns a client for it. +func fakeWorkspace(t *testing.T, routes map[string]http.HandlerFunc) *sdkclients.Clients { + t.Helper() + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if h, ok := routes[r.Method+" "+r.URL.Path]; ok { + h(w, r) + return + } + _, _ = w.Write([]byte(`{}`)) + })) + t.Cleanup(srv.Close) + return newTestWorkspaceClient(t, srv.URL) +} + +// respond returns a handler that writes body with the given status. +func respond(status int, body string) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(status) + _, _ = w.Write([]byte(body)) + } +} diff --git a/cmd/air/cancel.go b/cmd/air/cancel.go index fe7e2cbdbff..8b4ca4377d0 100644 --- a/cmd/air/cancel.go +++ b/cmd/air/cancel.go @@ -10,13 +10,13 @@ import ( "text/tabwriter" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/sdk-go/core/apierr" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" "github.com/spf13/cobra" ) @@ -86,7 +86,7 @@ all active runs submitted by the current user. if all { data.All = true - me, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + me, err := currentUserName(ctx, w) if err != nil { return renderError(ctx, cmd, "INTERNAL_ERROR", "TRANSIENT", true, fmt.Errorf("failed to resolve current user: %w", err)) @@ -94,12 +94,12 @@ all active runs submitted by the current user. host := strings.TrimRight(w.Config.Host, "/") if !jsonOut { - cmdio.LogString(ctx, fmt.Sprintf("Searching active runs for %s in %s...", me.UserName, host)) + cmdio.LogString(ctx, fmt.Sprintf("Searching active runs for %s in %s...", me, host)) } // Fetch every active run (up to the scan bound) so --all cancels all // of them, not just the first page. - fetcher := newRunFetcher(ctx, w, listQuery{activeOnly: true, userFilter: me.UserName}) + fetcher := newRunFetcher(ctx, w, listQuery{activeOnly: true, userFilter: me}) rows, err := fetcher.next(maxListScan) if err != nil { return renderError(ctx, cmd, "INTERNAL_ERROR", "TRANSIENT", true, @@ -138,12 +138,12 @@ all active runs submitted by the current user. for _, rid := range runIDs { err := cancelRun(ctx, w, rid) if err != nil { - data.Failed = append(data.Failed, cancelFailure{RunID: rid, Error: err.Error()}) + data.Failed = append(data.Failed, cancelFailure{RunID: rid, Error: apierrs.ErrorString(err)}) if !jsonOut { if runNotFound(err) { cmdio.LogString(ctx, fmt.Sprintf("Run %s not found. Please check the run ID and ensure you're using a Job Run ID.", rid)) } else { - cmdio.LogString(ctx, fmt.Sprintf("Failed to cancel run %s: %s", rid, err)) + cmdio.LogString(ctx, fmt.Sprintf("Failed to cancel run %s: %s", rid, apierrs.ErrorString(err))) } } continue @@ -183,23 +183,23 @@ all active runs submitted by the current user. // an unknown run, and the SDK only remaps that to ErrResourceDoesNotExist for // the runs/get path, not cancel — so we also detect the raw code here. func runNotFound(err error) bool { - if errors.Is(err, apierr.ErrResourceDoesNotExist) { + if apierrs.Is(err, apierrs.ErrResourceDoesNotExist) { return true } if apiErr, ok := errors.AsType[*apierr.APIError](err); ok { - return apiErr.StatusCode == http.StatusBadRequest && apiErr.ErrorCode == "INVALID_PARAMETER_VALUE" + return apiErr.HTTPStatusCode() == http.StatusBadRequest && apierrs.ErrorCode(apiErr) == "INVALID_PARAMETER_VALUE" } return false } // cancelRun requests cancellation of a single job run. The cancel is async, so // the returned waiter is ignored. -func cancelRun(ctx context.Context, w *databricks.WorkspaceClient, rid string) error { +func cancelRun(ctx context.Context, w *sdkclients.Clients, rid string) error { runID, err := strconv.ParseInt(rid, 10, 64) if err != nil || runID <= 0 { return fmt.Errorf("invalid run ID %q: must be a positive integer", rid) } - _, err = w.Jobs.CancelRun(ctx, jobs.CancelRun{RunId: runID}) + _, err = w.Jobs.CancelRun(ctx, sdkjobs.CancelRunRequest{RunId: new(runID)}) return err } diff --git a/cmd/air/cancel_test.go b/cmd/air/cancel_test.go index 5601a99f84a..c2092347d9b 100644 --- a/cmd/air/cancel_test.go +++ b/cmd/air/cancel_test.go @@ -15,20 +15,37 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) +// cancelServer serves runs/cancel with the handler registered for the run_id +// in the request body; any other run id fails the test. +func cancelServer(t *testing.T, byRunID map[int64]http.HandlerFunc) *sdkclients.Clients { + t.Helper() + return fakeWorkspace(t, map[string]http.HandlerFunc{ + "POST /api/2.2/jobs/runs/cancel": func(w http.ResponseWriter, r *http.Request) { + var req struct { + RunID int64 `json:"run_id"` + } + if !assert.NoError(t, json.NewDecoder(r.Body).Decode(&req)) { + return + } + h, ok := byRunID[req.RunID] + if !assert.True(t, ok, "unexpected cancel of run %d", req.RunID) { + w.WriteHeader(http.StatusBadRequest) + return + } + h(w, r) + }, + }) +} + // runCancelAll runs `cancel --all` against w with the given output mode and // stdin, capturing output into buf. -func runCancelAll(t *testing.T, w *databricks.WorkspaceClient, out flags.Output, in io.Reader, buf *bytes.Buffer) error { +func runCancelAll(t *testing.T, w *sdkclients.Clients, out flags.Output, in io.Reader, buf *bytes.Buffer) error { t.Helper() cmd := withOutput(newCancelCommand(), out) require.NoError(t, cmd.Flags().Set("all", "true")) @@ -45,7 +62,7 @@ type cancelEnvelope struct { // runCancel runs the cancel command against w with the given output mode and // stdin, capturing stdout/stderr into buf. -func runCancel(t *testing.T, w *databricks.WorkspaceClient, out flags.Output, in string, buf *bytes.Buffer, args ...string) (*cobra.Command, error) { +func runCancel(t *testing.T, w *sdkclients.Clients, out flags.Output, in string, buf *bytes.Buffer, args ...string) (*cobra.Command, error) { t.Helper() ctx := cmdio.InContext(t.Context(), cmdio.NewIO(t.Context(), out, strings.NewReader(in), buf, buf, "", "")) ctx = cmdctx.SetWorkspaceClient(ctx, w) @@ -86,21 +103,19 @@ func TestCancelArgs(t *testing.T) { } func TestCancelRunInvalidID(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) + w := fakeWorkspace(t, nil) for _, id := range []string{"abc", "0", "-1"} { - err := cancelRun(t.Context(), m.WorkspaceClient, id) + err := cancelRun(t.Context(), w, id) require.Error(t, err) assert.Contains(t, err.Error(), "invalid run ID") } } func TestCancelByIDSuccess(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockJobsAPI().EXPECT().CancelRun(mock.Anything, jobs.CancelRun{RunId: 123}).Return(nil, nil) - m.GetMockJobsAPI().EXPECT().CancelRun(mock.Anything, jobs.CancelRun{RunId: 456}).Return(nil, nil) + w := cancelServer(t, map[int64]http.HandlerFunc{123: respond(200, `{}`), 456: respond(200, `{}`)}) var buf bytes.Buffer - _, err := runCancel(t, m.WorkspaceClient, flags.OutputText, "", &buf, "123", "456") + _, err := runCancel(t, w, flags.OutputText, "", &buf, "123", "456") require.NoError(t, err) out := buf.String() @@ -111,11 +126,10 @@ func TestCancelByIDSuccess(t *testing.T) { } func TestCancelByIDNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockJobsAPI().EXPECT().CancelRun(mock.Anything, jobs.CancelRun{RunId: 5}).Return(nil, apierr.ErrResourceDoesNotExist) + w := cancelServer(t, map[int64]http.HandlerFunc{5: respond(404, `{"error_code":"RESOURCE_DOES_NOT_EXIST","message":"Run 5 does not exist."}`)}) var buf bytes.Buffer - _, err := runCancel(t, m.WorkspaceClient, flags.OutputText, "", &buf, "5") + _, err := runCancel(t, w, flags.OutputText, "", &buf, "5") require.ErrorIs(t, err, root.ErrAlreadyPrinted) out := buf.String() @@ -126,23 +140,22 @@ func TestCancelByIDNotFound(t *testing.T) { func TestCancelByIDNotFoundInvalidParam(t *testing.T) { // The cancel endpoint reports an unknown run as 400 INVALID_PARAMETER_VALUE, // which the SDK does not remap to ErrResourceDoesNotExist for this path. - m := mocks.NewMockWorkspaceClient(t) - apiErr := &apierr.APIError{StatusCode: http.StatusBadRequest, ErrorCode: "INVALID_PARAMETER_VALUE", Message: "Run 5 does not exist."} - m.GetMockJobsAPI().EXPECT().CancelRun(mock.Anything, jobs.CancelRun{RunId: 5}).Return(nil, apiErr) + w := cancelServer(t, map[int64]http.HandlerFunc{5: respond(400, `{"error_code":"INVALID_PARAMETER_VALUE","message":"Run 5 does not exist."}`)}) var buf bytes.Buffer - _, err := runCancel(t, m.WorkspaceClient, flags.OutputText, "", &buf, "5") + _, err := runCancel(t, w, flags.OutputText, "", &buf, "5") require.ErrorIs(t, err, root.ErrAlreadyPrinted) assert.Contains(t, buf.String(), "Run 5 not found") } func TestCancelPartialFailureJSON(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockJobsAPI().EXPECT().CancelRun(mock.Anything, jobs.CancelRun{RunId: 123}).Return(nil, nil) - m.GetMockJobsAPI().EXPECT().CancelRun(mock.Anything, jobs.CancelRun{RunId: 5}).Return(nil, apierr.ErrResourceDoesNotExist) + w := cancelServer(t, map[int64]http.HandlerFunc{ + 123: respond(200, `{}`), + 5: respond(404, `{"error_code":"RESOURCE_DOES_NOT_EXIST","message":"Run 5 does not exist."}`), + }) var buf bytes.Buffer - _, err := runCancel(t, m.WorkspaceClient, flags.OutputJSON, "", &buf, "123", "5") + _, err := runCancel(t, w, flags.OutputJSON, "", &buf, "123", "5") // The envelope is printed, but a failure still exits non-zero. require.ErrorIs(t, err, root.ErrAlreadyPrinted) @@ -155,11 +168,10 @@ func TestCancelPartialFailureJSON(t *testing.T) { } func TestCancelByIDSuccessJSON(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockJobsAPI().EXPECT().CancelRun(mock.Anything, jobs.CancelRun{RunId: 123}).Return(nil, nil) + w := cancelServer(t, map[int64]http.HandlerFunc{123: respond(200, `{}`)}) var buf bytes.Buffer - _, err := runCancel(t, m.WorkspaceClient, flags.OutputJSON, "", &buf, "123") + _, err := runCancel(t, w, flags.OutputJSON, "", &buf, "123") require.NoError(t, err) var got cancelEnvelope @@ -169,11 +181,10 @@ func TestCancelByIDSuccessJSON(t *testing.T) { } func TestCancelByIDGenericFailure(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockJobsAPI().EXPECT().CancelRun(mock.Anything, jobs.CancelRun{RunId: 7}).Return(nil, errors.New("boom")) + w := cancelServer(t, map[int64]http.HandlerFunc{7: respond(500, `{"error_code":"INTERNAL_ERROR","message":"boom"}`)}) var buf bytes.Buffer - _, err := runCancel(t, m.WorkspaceClient, flags.OutputText, "", &buf, "7") + _, err := runCancel(t, w, flags.OutputText, "", &buf, "7") require.ErrorIs(t, err, root.ErrAlreadyPrinted) assert.Contains(t, buf.String(), "Failed to cancel run 7: boom") } @@ -239,11 +250,12 @@ func TestCancelAllConfirmReadError(t *testing.T) { } func TestCancelAllMeError(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockCurrentUserAPI().EXPECT().Me(mock.Anything, iam.MeRequest{}).Return(nil, errors.New("nope")) + w := fakeWorkspace(t, map[string]http.HandlerFunc{ + "GET /api/2.0/preview/scim/v2/Me": respond(500, `{"error_code":"INTERNAL_ERROR","message":"nope"}`), + }) var buf bytes.Buffer - err := runCancelAll(t, m.WorkspaceClient, flags.OutputText, nil, &buf) + err := runCancelAll(t, w, flags.OutputText, nil, &buf) require.Error(t, err) assert.Contains(t, err.Error(), "failed to resolve current user") } diff --git a/cmd/air/eta.go b/cmd/air/eta.go index dab5b5df762..f64d1c7b65c 100644 --- a/cmd/air/eta.go +++ b/cmd/air/eta.go @@ -10,8 +10,10 @@ import ( "strings" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/ml" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/experiments/v1" + "github.com/databricks/cli/libs/utils" + sdkexperiments "github.com/databricks/sdk-go/experiments/v1" ) // trainingETA is a best-effort estimate of how far a running training job has @@ -85,12 +87,12 @@ func coarseDuration(totalSeconds int64) string { // estimate can't be made (no known total, too little history, still warming up, an // API error): Progress is a convenience, so any failure is logged and treated as // "no estimate" rather than failing the command. -func estimateTrainingETA(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID string) *trainingETA { +func estimateTrainingETA(ctx context.Context, w *sdkclients.Clients, mlflowRunID string) *trainingETA { if mlflowRunID == "" { return nil } - resp, err := w.Experiments.GetRun(ctx, ml.GetRunRequest{RunId: mlflowRunID}) + resp, err := w.Experiments.GetRun(ctx, sdkexperiments.GetRunRequest{RunId: new(mlflowRunID)}) if err != nil { log.Debugf(ctx, "air: could not fetch MLflow run for progress estimate: %v", err) return nil @@ -101,18 +103,35 @@ func estimateTrainingETA(ctx context.Context, w *databricks.WorkspaceClient, mlf // The total is only present once the contract is met; skip the metric-history // fetch entirely when it is absent, so a run we can't estimate costs one call. - params := paramMap(resp.Run.Data.Params) + var mlflowParams []experiments.Param + for i := range resp.Run.Data.Params { + p, err := experiments.ParamFromSDK(&resp.Run.Data.Params[i]) + if err != nil { + log.Debugf(ctx, "air: could not read MLflow run params for progress estimate: %v", err) + return nil + } + mlflowParams = append(mlflowParams, *p) + } + params := paramMap(mlflowParams) if _, hasSteps := positiveInt(params["max_steps"]); !hasSteps { if _, hasEpochs := positiveFloat(params["num_train_epochs"]); !hasEpochs { return nil } } - history, err := w.Experiments.GetHistoryAll(ctx, ml.GetHistoryRequest{ - RunId: mlflowRunID, - MetricKey: etaProgressMetric, - }) - if err != nil { + var history []experiments.Metric + for m, err := range w.Experiments.ListMetricHistoryIter(ctx, sdkexperiments.ListMetricHistoryRequest{ + RunId: new(mlflowRunID), + MetricKey: new(etaProgressMetric), + }) { + if err == nil { + var metric *experiments.Metric + metric, err = experiments.MetricFromSDK(m) + if err == nil { + history = append(history, *metric) + continue + } + } log.Debugf(ctx, "air: could not fetch %q metric history for progress estimate: %v", etaProgressMetric, err) return nil } @@ -126,26 +145,28 @@ func estimateTrainingETA(ctx context.Context, w *databricks.WorkspaceClient, mlf // // When max_steps is set (> 0) the run trains by step and it wins over // num_train_epochs, matching HuggingFace Trainer's own precedence. -func computeETA(params map[string]string, history []ml.Metric) *trainingETA { +func computeETA(params map[string]string, history []experiments.Metric) *trainingETA { if len(history) < 2 { return nil } // History should already be ordered by step; sort by timestamp defensively so // the rate is measured over increasing wall-clock time. - points := append([]ml.Metric(nil), history...) - slices.SortStableFunc(points, func(a, b ml.Metric) int { return cmp.Compare(a.Timestamp, b.Timestamp) }) + points := append([]experiments.Metric(nil), history...) + slices.SortStableFunc(points, func(a, b experiments.Metric) int { + return cmp.Compare(utils.Deref(a.Timestamp), utils.Deref(b.Timestamp)) + }) if len(points) > etaWindowPoints { points = points[len(points)-etaWindowPoints:] } first, last := points[0], points[len(points)-1] // Withhold an estimate during the first few steps while throughput settles. - if last.Step < minStepsForETA { + if utils.Deref(last.Step) < minStepsForETA { return nil } - elapsedSec := float64(last.Timestamp-first.Timestamp) / 1000.0 + elapsedSec := float64(utils.Deref(last.Timestamp)-utils.Deref(first.Timestamp)) / 1000.0 if elapsedSec <= 0 { return nil } @@ -161,39 +182,39 @@ func computeETA(params map[string]string, history []ml.Metric) *trainingETA { // stepETA projects from the global step (the metric's MLflow step) against a known // max_steps. -func stepETA(first, last ml.Metric, elapsedSec float64, maxSteps int64) *trainingETA { +func stepETA(first, last experiments.Metric, elapsedSec float64, maxSteps int64) *trainingETA { current := last.Step - if current <= 0 || current >= maxSteps { + if utils.Deref(current) <= 0 || utils.Deref(current) >= maxSteps { return nil } - done := last.Step - first.Step + done := utils.Deref(last.Step) - utils.Deref(first.Step) if done <= 0 { return nil } perSec := float64(done) / elapsedSec - remaining := float64(maxSteps-current) / perSec + remaining := float64(maxSteps-utils.Deref(current)) / perSec return &trainingETA{ RemainingSeconds: int64(math.Round(remaining)), - PercentComplete: percentComplete(float64(current), float64(maxSteps)), + PercentComplete: percentComplete(float64(utils.Deref(current)), float64(maxSteps)), } } // epochETA projects from the fractional epoch (the metric's value) against a known // num_train_epochs. -func epochETA(first, last ml.Metric, elapsedSec, totalEpochs float64) *trainingETA { +func epochETA(first, last experiments.Metric, elapsedSec, totalEpochs float64) *trainingETA { current := last.Value - if current <= 0 || current >= totalEpochs { + if utils.Deref(current) <= 0 || utils.Deref(current) >= totalEpochs { return nil } - done := last.Value - first.Value + done := utils.Deref(last.Value) - utils.Deref(first.Value) if done <= 0 { return nil } perSec := done / elapsedSec - remaining := (totalEpochs - current) / perSec + remaining := (totalEpochs - utils.Deref(current)) / perSec return &trainingETA{ RemainingSeconds: int64(math.Round(remaining)), - PercentComplete: percentComplete(current, totalEpochs), + PercentComplete: percentComplete(utils.Deref(current), totalEpochs), } } @@ -211,10 +232,10 @@ func percentComplete(current, total float64) int { } // paramMap indexes MLflow params by key. -func paramMap(params []ml.Param) map[string]string { +func paramMap(params []experiments.Param) map[string]string { m := make(map[string]string, len(params)) for _, p := range params { - m[p.Key] = p.Value + m[utils.Deref(p.Key)] = utils.Deref(p.Value) } return m } diff --git a/cmd/air/eta_test.go b/cmd/air/eta_test.go index 061761cb975..be80d2c8f0a 100644 --- a/cmd/air/eta_test.go +++ b/cmd/air/eta_test.go @@ -3,15 +3,15 @@ package aircmd import ( "testing" - "github.com/databricks/databricks-sdk-go/service/ml" + "github.com/databricks/cli/libs/sdktypes/experiments/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) // metric builds one epoch-metric history point: fractional epoch as the value, // global step as the MLflow step, wall-clock as the timestamp (ms). -func metric(tsMillis, step int64, epoch float64) ml.Metric { - return ml.Metric{Key: "epoch", Timestamp: tsMillis, Step: step, Value: epoch} +func metric(tsMillis, step int64, epoch float64) experiments.Metric { + return experiments.Metric{Key: new("epoch"), Timestamp: new(tsMillis), Step: new(step), Value: new(epoch)} } func TestComputeETA_StepMode(t *testing.T) { @@ -19,7 +19,7 @@ func TestComputeETA_StepMode(t *testing.T) { // 5000 steps remain => 125s; 5000/10000 => 50%. eta := computeETA( map[string]string{"max_steps": "10000", "num_train_epochs": "3"}, - []ml.Metric{metric(0, 1000, 0.3), metric(100_000, 5000, 1.5)}, + []experiments.Metric{metric(0, 1000, 0.3), metric(100_000, 5000, 1.5)}, ) require.NotNil(t, eta) assert.Equal(t, int64(125), eta.RemainingSeconds) @@ -34,7 +34,7 @@ func TestComputeETA_EpochMode(t *testing.T) { // 1.5/3 => 50%. eta := computeETA( map[string]string{"max_steps": "-1", "num_train_epochs": "3"}, - []ml.Metric{metric(0, 100, 0.5), metric(90_000, 900, 1.5)}, + []experiments.Metric{metric(0, 100, 0.5), metric(90_000, 900, 1.5)}, ) require.NotNil(t, eta) assert.Equal(t, int64(135), eta.RemainingSeconds) @@ -46,7 +46,7 @@ func TestComputeETA_UsesTrailingWindow(t *testing.T) { // Early points are slow, recent points fast; the window should reflect the // recent rate, not the whole-run average. Build 12 points; only the last // etaWindowPoints (10) count. - var pts []ml.Metric + var pts []experiments.Metric pts = append(pts, metric(0, 0, 0), metric(100_000, 10, 0.1)) for i := int64(1); i <= 10; i++ { pts = append(pts, metric(100_000+i*10_000, 10+i*100, 0.1+float64(i)*0.1)) @@ -59,22 +59,22 @@ func TestComputeETA_UsesTrailingWindow(t *testing.T) { } func TestComputeETA_NoEstimate(t *testing.T) { - base := []ml.Metric{metric(0, 100, 0.3), metric(100_000, 5000, 1.5)} + base := []experiments.Metric{metric(0, 100, 0.3), metric(100_000, 5000, 1.5)} cases := []struct { name string params map[string]string - history []ml.Metric + history []experiments.Metric }{ {"no total param", map[string]string{}, base}, {"max_steps not positive", map[string]string{"max_steps": "-1"}, base}, {"num_train_epochs zero", map[string]string{"num_train_epochs": "0"}, base}, {"total param unparseable", map[string]string{"max_steps": "lots"}, base}, {"too few points", map[string]string{"max_steps": "10000"}, base[:1]}, - {"still warming up", map[string]string{"max_steps": "10000"}, []ml.Metric{metric(0, 2, 0.01), metric(30_000, 8, 0.02)}}, - {"no elapsed time", map[string]string{"max_steps": "10000"}, []ml.Metric{metric(500, 100, 0.3), metric(500, 5000, 1.5)}}, + {"still warming up", map[string]string{"max_steps": "10000"}, []experiments.Metric{metric(0, 2, 0.01), metric(30_000, 8, 0.02)}}, + {"no elapsed time", map[string]string{"max_steps": "10000"}, []experiments.Metric{metric(500, 100, 0.3), metric(500, 5000, 1.5)}}, {"already at max steps", map[string]string{"max_steps": "5000"}, base}, {"epoch already complete", map[string]string{"num_train_epochs": "1.5"}, base}, - {"step not advancing", map[string]string{"max_steps": "10000"}, []ml.Metric{metric(0, 5000, 1.5), metric(100_000, 5000, 1.5)}}, + {"step not advancing", map[string]string{"max_steps": "10000"}, []experiments.Metric{metric(0, 5000, 1.5), metric(100_000, 5000, 1.5)}}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { @@ -87,7 +87,7 @@ func TestComputeETA_PercentClampedBelow100(t *testing.T) { // A run one step from done is still "running", so it never shows 100%. eta := computeETA( map[string]string{"max_steps": "1000"}, - []ml.Metric{metric(0, 900, 0.9), metric(10_000, 999, 0.999)}, + []experiments.Metric{metric(0, 900, 0.9), metric(10_000, 999, 0.999)}, ) require.NotNil(t, eta) assert.Equal(t, 99, eta.PercentComplete) diff --git a/cmd/air/format.go b/cmd/air/format.go index 1271f89b4ae..1dad6bcf84a 100644 --- a/cmd/air/format.go +++ b/cmd/air/format.go @@ -11,7 +11,8 @@ import ( "time" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" "github.com/muesli/termenv" "go.yaml.in/yaml/v3" ) @@ -88,8 +89,8 @@ var gpuDisplayNames = map[string]string{ // isRunning reports whether a run is currently executing (lifecycle RUNNING), as // opposed to pending, terminal, or state-unknown. Only a running run has a // meaningful remaining-time estimate. -func isRunning(run *jobs.Run) bool { - return run.State != nil && run.State.LifeCycleState == jobs.RunLifeCycleStateRunning +func isRunning(run *jobs.GetRunResponse) bool { + return run.State != nil && run.State.LifeCycleState == jobs.RunLifeCycleState_RunLifeCycleState_Running } // runStatus returns the single status word to show for a run. The backend @@ -103,7 +104,7 @@ func runStatus(state *jobs.RunState) string { return statusWord(string(state.LifeCycleState), string(state.ResultState)) } -func displayRunStatus(run *jobs.Run) string { +func displayRunStatus(run *jobs.GetRunResponse) string { status := runStatus(run.State) if runWaitingForCompute(run) { return "PENDING" @@ -111,26 +112,26 @@ func displayRunStatus(run *jobs.Run) string { return status } -func runWaitingForCompute(run *jobs.Run) bool { +func runWaitingForCompute(run *jobs.GetRunResponse) bool { if run.State == nil || run.State.ResultState != "" { return false } - if run.State.LifeCycleState == jobs.RunLifeCycleStatePending { + if run.State.LifeCycleState == jobs.RunLifeCycleState_RunLifeCycleState_Pending { return true } - if run.State.LifeCycleState != jobs.RunLifeCycleStateRunning || len(run.Tasks) == 0 || run.Tasks[0].State == nil { + if run.State.LifeCycleState != jobs.RunLifeCycleState_RunLifeCycleState_Running || len(run.Tasks) == 0 || run.Tasks[0].State == nil { return false } switch run.Tasks[0].State.LifeCycleState { - case jobs.RunLifeCycleStatePending, jobs.RunLifeCycleStateQueued, - jobs.RunLifeCycleStateWaitingForRetry, jobs.RunLifeCycleStateBlocked: + case jobs.RunLifeCycleState_RunLifeCycleState_Pending, jobs.RunLifeCycleState_RunLifeCycleState_Queued, + jobs.RunLifeCycleState_RunLifeCycleState_WaitingForRetry, jobs.RunLifeCycleState_RunLifeCycleState_Blocked: return true default: return false } } -func detailedDisplayRunStatus(run *jobs.Run, statusMessage string) string { +func detailedDisplayRunStatus(run *jobs.GetRunResponse, statusMessage string) string { if run.State != nil && run.State.ResultState == "" && statusMessage != "" { return statusMessage } @@ -140,23 +141,23 @@ func detailedDisplayRunStatus(run *jobs.Run, statusMessage string) string { return displayRunStatus(run) } -func terminationReason(run *jobs.Run) *string { +func terminationReason(run *jobs.GetRunResponse) *string { status := runStatus(run.State) if status != "FAILED" && status != "TIMEDOUT" && status != "INTERNAL_ERROR" { return nil } if run.Status != nil && run.Status.TerminationDetails != nil { - if message := strings.TrimSpace(run.Status.TerminationDetails.Message); message != "" { + if message := strings.TrimSpace(utils.Deref(run.Status.TerminationDetails.Message)); message != "" { return &message } } if run.State != nil { - if message := strings.TrimSpace(run.State.StateMessage); message != "" { + if message := strings.TrimSpace(utils.Deref(run.State.StateMessage)); message != "" { return &message } } if len(run.Tasks) > 0 && run.Tasks[0].State != nil { - if message := strings.TrimSpace(run.Tasks[0].State.StateMessage); message != "" { + if message := strings.TrimSpace(utils.Deref(run.Tasks[0].State.StateMessage)); message != "" { return &message } } @@ -179,15 +180,15 @@ func statusWord(lifeCycle, result string) string { // preferring the last task's window over the run-level times so a retried run // reports its latest attempt. Mirrors Python's _reported_attempt_timing // (cli_display.py:78-87). -func reportedTiming(run *jobs.Run) (startMillis, endMillis int64) { - startMillis, endMillis = run.StartTime, run.EndTime +func reportedTiming(run *jobs.GetRunResponse) (startMillis, endMillis int64) { + startMillis, endMillis = utils.Deref(run.StartTime), utils.Deref(run.EndTime) if n := len(run.Tasks); n > 0 { last := run.Tasks[n-1] - if last.StartTime > 0 { - startMillis = last.StartTime + if utils.Deref(last.StartTime) > 0 { + startMillis = utils.Deref(last.StartTime) } - if last.EndTime > 0 { - endMillis = last.EndTime + if utils.Deref(last.EndTime) > 0 { + endMillis = utils.Deref(last.EndTime) } } return startMillis, endMillis @@ -196,7 +197,7 @@ func reportedTiming(run *jobs.Run) (startMillis, endMillis int64) { // startedAt returns the run's start time as a Python-isoformat string ("+00:00", // not "Z"; microseconds only when non-zero, cli_entrypoint.py:1899), or nil if it // hasn't started. -func startedAt(run *jobs.Run) *string { +func startedAt(run *jobs.GetRunResponse) *string { startMillis, _ := reportedTiming(run) if startMillis == 0 { return nil @@ -221,7 +222,7 @@ func isoFormat(t time.Time) string { // "2006-01-02 15:04 UTC", or "N/A" if it hasn't started. Mirrors Python's // _format_timestamp (cli_display.py); we render in UTC for stable output rather // than the local zone Python uses. -func submittedDisplay(run *jobs.Run) string { +func submittedDisplay(run *jobs.GetRunResponse) string { startMillis, _ := reportedTiming(run) if startMillis == 0 { return na @@ -232,7 +233,7 @@ func submittedDisplay(run *jobs.Run) string { // durationSeconds returns how long the run has taken, in whole seconds, or nil // if it has not started. For a finished run this is the elapsed time of the // reported attempt; for a still-running run it is the time since it started. -func durationSeconds(run *jobs.Run) *int64 { +func durationSeconds(run *jobs.GetRunResponse) *int64 { startMillis, endMillis := reportedTiming(run) if startMillis == 0 { return nil @@ -281,26 +282,26 @@ func formatDuration(totalSeconds int64) string { // latestAttemptNumber returns the retry count of the run's most recent task. // Tasks start at attempt 0, so a value of 0 means the run has not been retried. -func latestAttemptNumber(run *jobs.Run) int { +func latestAttemptNumber(run *jobs.GetRunResponse) int { if len(run.Tasks) == 0 { return 0 } - return run.Tasks[len(run.Tasks)-1].AttemptNumber + return utils.Deref(run.Tasks[len(run.Tasks)-1].AttemptNumber) } // experimentName returns the MLflow experiment name for the run, or nil if there // isn't one. Experiment names are often stored under a user's home folder (e.g. // "/Users/me@example.com/my-experiment"); we strip that prefix so users see just // the experiment name they chose. -func experimentName(run *jobs.Run) *string { +func experimentName(run *jobs.GetRunResponse) *string { if len(run.Tasks) == 0 { return nil } task := run.Tasks[0].GenAiComputeTask - if task == nil || task.MlflowExperimentName == "" { + if task == nil || utils.Deref(task.MlflowExperimentName) == "" { return nil } - name := stripExperimentUserPrefix(task.MlflowExperimentName) + name := stripExperimentUserPrefix(utils.Deref(task.MlflowExperimentName)) return &name } @@ -321,7 +322,7 @@ func stripExperimentUserPrefix(name string) string { // accelerators returns a short description of the GPUs the run uses, such as // "8x H100", or an empty string if the run has no GPU compute attached. -func accelerators(run *jobs.Run) string { +func accelerators(run *jobs.GetRunResponse) string { if len(run.Tasks) == 0 { return "" } @@ -329,7 +330,7 @@ func accelerators(run *jobs.Run) string { if task == nil || task.Compute == nil { return "" } - return acceleratorLabel(task.Compute.GpuType, task.Compute.NumGpus) + return acceleratorLabel(utils.Deref(task.Compute.GpuType), utils.Deref(task.Compute.NumGpus)) } // acceleratorLabel renders a GPU count and type as "8x H100", "" for none, or @@ -355,13 +356,13 @@ func gpuDisplayName(gpuType string) string { // maxRetries returns the configured retry limit for the run's latest task as a // display string: "unlimited" for the backend's -1, otherwise the count. -func maxRetries(run *jobs.Run) string { +func maxRetries(run *jobs.GetRunResponse) string { if len(run.Tasks) == 0 { return "0" } n := run.Tasks[len(run.Tasks)-1].MaxRetries - if n < 0 { + if utils.Deref(n) < 0 { return "unlimited" } - return strconv.Itoa(n) + return strconv.Itoa(utils.Deref(n)) } diff --git a/cmd/air/format_test.go b/cmd/air/format_test.go index 842806e6113..d214997423f 100644 --- a/cmd/air/format_test.go +++ b/cmd/air/format_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -16,9 +16,9 @@ func TestOrNA(t *testing.T) { } func TestSubmittedDisplay(t *testing.T) { - assert.Equal(t, "N/A", submittedDisplay(&jobs.Run{})) + assert.Equal(t, "N/A", submittedDisplay(&jobs.GetRunResponse{})) // 1700000000000 ms == 2023-11-14 22:13:20 UTC. - assert.Equal(t, "2023-11-14 22:13 UTC", submittedDisplay(&jobs.Run{StartTime: 1700000000000})) + assert.Equal(t, "2023-11-14 22:13 UTC", submittedDisplay(&jobs.GetRunResponse{StartTime: new(int64(1700000000000))})) } func TestHyperlink(t *testing.T) { @@ -78,12 +78,12 @@ func TestGpuDisplayName(t *testing.T) { func TestRunStatusPrefersResultState(t *testing.T) { // Result state wins once the run has finished. assert.Equal(t, "SUCCESS", runStatus(&jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateSuccess, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Success, })) // Before completion only the lifecycle state is set. assert.Equal(t, "RUNNING", runStatus(&jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateRunning, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running, })) // Non-nil state with neither field set, and nil state. assert.Equal(t, "UNKNOWN", runStatus(&jobs.RunState{})) @@ -92,26 +92,26 @@ func TestRunStatusPrefersResultState(t *testing.T) { func TestReportedTiming(t *testing.T) { // No tasks: run-level times are used. - start, end := reportedTiming(&jobs.Run{StartTime: 100, EndTime: 200}) + start, end := reportedTiming(&jobs.GetRunResponse{StartTime: new(int64(100)), EndTime: new(int64(200))}) assert.Equal(t, int64(100), start) assert.Equal(t, int64(200), end) // The last task's window is preferred over the run-level window, so a // retried run reports its most recent attempt. - start, end = reportedTiming(&jobs.Run{ - StartTime: 100, EndTime: 200, + start, end = reportedTiming(&jobs.GetRunResponse{ + StartTime: new(int64(100)), EndTime: new(int64(200)), Tasks: []jobs.RunTask{ - {StartTime: 100, EndTime: 150}, - {StartTime: 300, EndTime: 450}, + {StartTime: new(int64(100)), EndTime: new(int64(150))}, + {StartTime: new(int64(300)), EndTime: new(int64(450))}, }, }) assert.Equal(t, int64(300), start) assert.Equal(t, int64(450), end) // A task missing a field falls back to the run-level value for that field. - start, end = reportedTiming(&jobs.Run{ - StartTime: 100, EndTime: 200, - Tasks: []jobs.RunTask{{StartTime: 300}}, + start, end = reportedTiming(&jobs.GetRunResponse{ + StartTime: new(int64(100)), EndTime: new(int64(200)), + Tasks: []jobs.RunTask{{StartTime: new(int64(300))}}, }) assert.Equal(t, int64(300), start) assert.Equal(t, int64(200), end) @@ -119,19 +119,19 @@ func TestReportedTiming(t *testing.T) { func TestStartedAt(t *testing.T) { // Not started yet. - assert.Nil(t, startedAt(&jobs.Run{})) + assert.Nil(t, startedAt(&jobs.GetRunResponse{})) // 1700000000000 ms == 2023-11-14T22:13:20+00:00 (Python isoformat, not "Z"). - got := startedAt(&jobs.Run{StartTime: 1700000000000}) + got := startedAt(&jobs.GetRunResponse{StartTime: new(int64(1700000000000))}) require.NotNil(t, got) assert.Equal(t, "2023-11-14T22:13:20+00:00", *got) // A sub-second start time carries microsecond precision. - got = startedAt(&jobs.Run{StartTime: 1700000000500}) + got = startedAt(&jobs.GetRunResponse{StartTime: new(int64(1700000000500))}) require.NotNil(t, got) assert.Equal(t, "2023-11-14T22:13:20.500000+00:00", *got) // The last attempt's start time is reported. 1700000060000 ms == 22:14:20. - got = startedAt(&jobs.Run{ - StartTime: 1700000000000, - Tasks: []jobs.RunTask{{StartTime: 1700000060000}}, + got = startedAt(&jobs.GetRunResponse{ + StartTime: new(int64(1700000000000)), + Tasks: []jobs.RunTask{{StartTime: new(int64(1700000060000))}}, }) require.NotNil(t, got) assert.Equal(t, "2023-11-14T22:14:20+00:00", *got) @@ -139,29 +139,29 @@ func TestStartedAt(t *testing.T) { func TestDurationSeconds(t *testing.T) { // Not started yet. - assert.Nil(t, durationSeconds(&jobs.Run{})) + assert.Nil(t, durationSeconds(&jobs.GetRunResponse{})) // Finished run: reported end - start. - d := durationSeconds(&jobs.Run{StartTime: 1700000000000, EndTime: 1700000012000}) + d := durationSeconds(&jobs.GetRunResponse{StartTime: new(int64(1700000000000)), EndTime: new(int64(1700000012000))}) require.NotNil(t, d) assert.Equal(t, int64(12), *d) // Sub-second remainders round to the nearest second, matching Python: an // 11,500 ms run reports 12s, not 11s. - d = durationSeconds(&jobs.Run{StartTime: 1700000000000, EndTime: 1700000011500}) + d = durationSeconds(&jobs.GetRunResponse{StartTime: new(int64(1700000000000)), EndTime: new(int64(1700000011500))}) require.NotNil(t, d) assert.Equal(t, int64(12), *d) // The last attempt's window drives the duration for a retried run. - d = durationSeconds(&jobs.Run{ - StartTime: 1700000000000, EndTime: 1700000012000, - Tasks: []jobs.RunTask{{StartTime: 1700000000000, EndTime: 1700000005000}}, + d = durationSeconds(&jobs.GetRunResponse{ + StartTime: new(int64(1700000000000)), EndTime: new(int64(1700000012000)), + Tasks: []jobs.RunTask{{StartTime: new(int64(1700000000000)), EndTime: new(int64(1700000005000))}}, }) require.NotNil(t, d) assert.Equal(t, int64(5), *d) // Still running: measured against the current time, so positive. - d = durationSeconds(&jobs.Run{StartTime: 1700000000000}) + d = durationSeconds(&jobs.GetRunResponse{StartTime: new(int64(1700000000000))}) require.NotNil(t, d) assert.Positive(t, *d) } @@ -172,19 +172,19 @@ func TestDashboardURL(t *testing.T) { } func TestLatestAttemptNumber(t *testing.T) { - assert.Equal(t, 0, latestAttemptNumber(&jobs.Run{})) - run := &jobs.Run{Tasks: []jobs.RunTask{{AttemptNumber: 0}, {AttemptNumber: 2}}} + assert.Equal(t, 0, latestAttemptNumber(&jobs.GetRunResponse{})) + run := &jobs.GetRunResponse{Tasks: []jobs.RunTask{{AttemptNumber: new(0)}, {AttemptNumber: new(2)}}} assert.Equal(t, 2, latestAttemptNumber(run)) } func TestExperimentName(t *testing.T) { - assert.Nil(t, experimentName(&jobs.Run{})) - assert.Nil(t, experimentName(&jobs.Run{Tasks: []jobs.RunTask{{}}})) - assert.Nil(t, experimentName(&jobs.Run{Tasks: []jobs.RunTask{{ - GenAiComputeTask: &jobs.GenAiComputeTask{MlflowExperimentName: ""}, + assert.Nil(t, experimentName(&jobs.GetRunResponse{})) + assert.Nil(t, experimentName(&jobs.GetRunResponse{Tasks: []jobs.RunTask{{}}})) + assert.Nil(t, experimentName(&jobs.GetRunResponse{Tasks: []jobs.RunTask{{ + GenAiComputeTask: &jobs.GenAiComputeTask{MlflowExperimentName: new("")}, }}})) - got := experimentName(&jobs.Run{Tasks: []jobs.RunTask{{ - GenAiComputeTask: &jobs.GenAiComputeTask{MlflowExperimentName: "/Users/me@example.com/exp"}, + got := experimentName(&jobs.GetRunResponse{Tasks: []jobs.RunTask{{ + GenAiComputeTask: &jobs.GenAiComputeTask{MlflowExperimentName: new("/Users/me@example.com/exp")}, }}}) require.NotNil(t, got) assert.Equal(t, "exp", *got) @@ -210,16 +210,16 @@ func TestReformatYAMLForDisplay(t *testing.T) { } func TestAccelerators(t *testing.T) { - assert.Empty(t, accelerators(&jobs.Run{})) - assert.Empty(t, accelerators(&jobs.Run{Tasks: []jobs.RunTask{{}}})) - assert.Empty(t, accelerators(&jobs.Run{Tasks: []jobs.RunTask{{ + assert.Empty(t, accelerators(&jobs.GetRunResponse{})) + assert.Empty(t, accelerators(&jobs.GetRunResponse{Tasks: []jobs.RunTask{{}}})) + assert.Empty(t, accelerators(&jobs.GetRunResponse{Tasks: []jobs.RunTask{{ GenAiComputeTask: &jobs.GenAiComputeTask{}, }}})) - assert.Empty(t, accelerators(&jobs.Run{Tasks: []jobs.RunTask{{ - GenAiComputeTask: &jobs.GenAiComputeTask{Compute: &jobs.ComputeConfig{NumGpus: 0}}, + assert.Empty(t, accelerators(&jobs.GetRunResponse{Tasks: []jobs.RunTask{{ + GenAiComputeTask: &jobs.GenAiComputeTask{Compute: &jobs.ComputeConfig{NumGpus: new(0)}}, }}})) - assert.Equal(t, "8x H100", accelerators(&jobs.Run{Tasks: []jobs.RunTask{{ - GenAiComputeTask: &jobs.GenAiComputeTask{Compute: &jobs.ComputeConfig{NumGpus: 8, GpuType: "GPU_8xH100"}}, + assert.Equal(t, "8x H100", accelerators(&jobs.GetRunResponse{Tasks: []jobs.RunTask{{ + GenAiComputeTask: &jobs.GenAiComputeTask{Compute: &jobs.ComputeConfig{NumGpus: new(8), GpuType: new("GPU_8xH100")}}, }}})) } @@ -239,67 +239,67 @@ func TestStatusWord(t *testing.T) { } func TestDisplayRunStatus(t *testing.T) { - pendingStates := []jobs.RunLifeCycleState{ - jobs.RunLifeCycleStatePending, - jobs.RunLifeCycleStateQueued, - jobs.RunLifeCycleStateWaitingForRetry, - jobs.RunLifeCycleStateBlocked, + pendingStates := []jobs.RunLifeCycleState_RunLifeCycleState{ + jobs.RunLifeCycleState_RunLifeCycleState_Pending, + jobs.RunLifeCycleState_RunLifeCycleState_Queued, + jobs.RunLifeCycleState_RunLifeCycleState_WaitingForRetry, + jobs.RunLifeCycleState_RunLifeCycleState_Blocked, } for _, state := range pendingStates { - run := &jobs.Run{ - State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning}, + run := &jobs.GetRunResponse{ + State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running}, Tasks: []jobs.RunTask{{State: &jobs.RunState{LifeCycleState: state}}}, } assert.Equal(t, "PENDING", displayRunStatus(run)) } - assert.Equal(t, "RUNNING", displayRunStatus(&jobs.Run{ - State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning}, - Tasks: []jobs.RunTask{{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning}}}, + assert.Equal(t, "RUNNING", displayRunStatus(&jobs.GetRunResponse{ + State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running}, + Tasks: []jobs.RunTask{{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running}}}, })) - assert.Equal(t, "RUNNING", displayRunStatus(&jobs.Run{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning}})) - assert.Equal(t, "FAILED", displayRunStatus(&jobs.Run{ - State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateTerminated, ResultState: jobs.RunResultStateFailed}, - Tasks: []jobs.RunTask{{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStatePending}}}, + assert.Equal(t, "RUNNING", displayRunStatus(&jobs.GetRunResponse{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running}})) + assert.Equal(t, "FAILED", displayRunStatus(&jobs.GetRunResponse{ + State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, ResultState: jobs.RunResultState_RunResultState_Failed}, + Tasks: []jobs.RunTask{{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Pending}}}, })) } func TestDetailedDisplayRunStatus(t *testing.T) { - waiting := &jobs.Run{ - State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning}, - Tasks: []jobs.RunTask{{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateQueued}}}, + waiting := &jobs.GetRunResponse{ + State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running}, + Tasks: []jobs.RunTask{{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Queued}}}, } assert.Equal(t, "Waiting for GPU capacity...", detailedDisplayRunStatus(waiting, "Waiting for GPU capacity...")) assert.Equal(t, waitingForComputeStatus, detailedDisplayRunStatus(waiting, "")) - started := &jobs.Run{ - State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning}, - Tasks: []jobs.RunTask{{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning}}}, + started := &jobs.GetRunResponse{ + State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running}, + Tasks: []jobs.RunTask{{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running}}}, } assert.Equal(t, "RUNNING", detailedDisplayRunStatus(started, "")) - failed := &jobs.Run{ - State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateTerminated, ResultState: jobs.RunResultStateFailed}, - Tasks: []jobs.RunTask{{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStatePending}}}, + failed := &jobs.GetRunResponse{ + State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, ResultState: jobs.RunResultState_RunResultState_Failed}, + Tasks: []jobs.RunTask{{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Pending}}}, } assert.Equal(t, "FAILED", detailedDisplayRunStatus(failed, "stale status...")) } func TestTerminationReason(t *testing.T) { - reason := terminationReason(&jobs.Run{ - State: &jobs.RunState{ResultState: jobs.RunResultStateFailed, StateMessage: "parent reason"}, - Status: &jobs.RunStatus{TerminationDetails: &jobs.TerminationDetails{Message: " detailed reason "}}, + reason := terminationReason(&jobs.GetRunResponse{ + State: &jobs.RunState{ResultState: jobs.RunResultState_RunResultState_Failed, StateMessage: new("parent reason")}, + Status: &jobs.RunStatus{TerminationDetails: &jobs.TerminationDetails{Message: new(" detailed reason ")}}, }) require.NotNil(t, reason) assert.Equal(t, "detailed reason", *reason) - reason = terminationReason(&jobs.Run{ - State: &jobs.RunState{ResultState: jobs.RunResultStateTimedout}, - Tasks: []jobs.RunTask{{State: &jobs.RunState{StateMessage: "task timed out"}}}, + reason = terminationReason(&jobs.GetRunResponse{ + State: &jobs.RunState{ResultState: jobs.RunResultState_RunResultState_Timedout}, + Tasks: []jobs.RunTask{{State: &jobs.RunState{StateMessage: new("task timed out")}}}, }) require.NotNil(t, reason) assert.Equal(t, "task timed out", *reason) - assert.Nil(t, terminationReason(&jobs.Run{State: &jobs.RunState{ResultState: jobs.RunResultStateSuccess, StateMessage: "done"}})) - assert.Nil(t, terminationReason(&jobs.Run{State: &jobs.RunState{ResultState: jobs.RunResultStateCanceled, StateMessage: "cancelled"}})) + assert.Nil(t, terminationReason(&jobs.GetRunResponse{State: &jobs.RunState{ResultState: jobs.RunResultState_RunResultState_Success, StateMessage: new("done")}})) + assert.Nil(t, terminationReason(&jobs.GetRunResponse{State: &jobs.RunState{ResultState: jobs.RunResultState_RunResultState_Canceled, StateMessage: new("cancelled")}})) } diff --git a/cmd/air/get.go b/cmd/air/get.go index 9f55f0f60e8..6b6e3702fb5 100644 --- a/cmd/air/get.go +++ b/cmd/air/get.go @@ -8,12 +8,12 @@ import ( "strconv" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/spf13/cobra" ) @@ -91,7 +91,7 @@ func authError(ctx context.Context, cmd *cobra.Command, err error) error { if errors.Is(err, config.ErrCannotConfigureDefault) { return renderError(ctx, cmd, "UNAUTHENTICATED", "PERMANENT", false, errNoProfile) } - if errors.Is(err, apierr.ErrUnauthenticated) || errors.Is(err, apierr.ErrPermissionDenied) { + if apierrs.Is(err, apierrs.ErrUnauthenticated) || apierrs.Is(err, apierrs.ErrPermissionDenied) { return renderError(ctx, cmd, "UNAUTHENTICATED", "PERMANENT", false, fmt.Errorf("authentication was not successful: %w", err)) } @@ -141,14 +141,14 @@ JOB_RUN_ID is the job run ID returned by "air run".`, // attaches credentials (e.g. it does not check a PAT server-side), so // without this a bad credential would surface as a confusing failure // mid-render instead of a clear "not authenticated" error here. - if _, err := w.CurrentUser.Me(ctx, iam.MeRequest{}); err != nil { + if _, err := currentUserName(ctx, w); err != nil { return authError(ctx, cmd, err) } - run, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: runID}) + run, err := getRun(ctx, w, runID) if err != nil { // The backend returns this when the run ID is unknown to the user. - if errors.Is(err, apierr.ErrResourceDoesNotExist) { + if apierrs.Is(err, apierrs.ErrResourceDoesNotExist) { return renderError(ctx, cmd, "NOT_FOUND", "NOT_FOUND", false, fmt.Errorf("run %d not found: check the run ID and that it is a job run ID", runID)) } @@ -182,7 +182,7 @@ JOB_RUN_ID is the job run ID returned by "air run".`, } } if task := findForEachTask(run); task != nil { - data.Sweep = buildSweepInfo(ctx, w, task) + data.Sweep = buildSweepInfo(ctx, w, runID, task) } else if genAIComputeTask(run) == nil { enrichFromAiRuntimeTask(run, &data) } @@ -200,7 +200,7 @@ JOB_RUN_ID is the job run ID returned by "air run".`, } statusMessage := "" if taskOutput != nil { - statusMessage = normalizeStatusMessage(taskOutput.StatusMessage) + statusMessage = normalizeStatusMessage(utils.Deref(taskOutput.StatusMessage)) } data.DisplayStatus = detailedDisplayRunStatus(run, statusMessage) @@ -214,29 +214,29 @@ JOB_RUN_ID is the job run ID returned by "air run".`, // enrichFromAiRuntimeTask fills the config path, experiment, and accelerators // from the run's ai_runtime_task. Best-effort: empty fields leave the existing // "N/A" fallbacks in place. -func enrichFromAiRuntimeTask(run *jobs.Run, data *getData) { +func enrichFromAiRuntimeTask(run *jobs.GetRunResponse, data *getData) { task := aiRuntimeTaskOf(run) if task == nil { return } if len(task.Deployments) > 0 { d := task.Deployments[0] - if d.CommandPath != "" { - data.TrainingConfigPath = path.Join(path.Dir(d.CommandPath), trainingConfigName) + if utils.Deref(d.CommandPath) != "" { + data.TrainingConfigPath = path.Join(path.Dir(utils.Deref(d.CommandPath)), trainingConfigName) } - if a := acceleratorLabel(string(d.Compute.AcceleratorType), d.Compute.AcceleratorCount); a != "" { + if a := acceleratorLabel(string(d.Compute.AcceleratorType), utils.Deref(d.Compute.AcceleratorCount)); a != "" { data.AcceleratorsDisplay = a } } - if task.Experiment != "" { - exp := stripExperimentUserPrefix(task.Experiment) + if utils.Deref(task.Experiment) != "" { + exp := stripExperimentUserPrefix(utils.Deref(task.Experiment)) data.ExperimentName = &exp data.ExperimentDisplay = exp } } // aiRuntimeTaskOf returns the run's first ai_runtime_task, or nil. -func aiRuntimeTaskOf(run *jobs.Run) *jobs.AiRuntimeTask { +func aiRuntimeTaskOf(run *jobs.GetRunResponse) *jobs.AiRuntimeTask { if len(run.Tasks) == 0 { return nil } @@ -246,9 +246,9 @@ func aiRuntimeTaskOf(run *jobs.Run) *jobs.AiRuntimeTask { // buildGetData extracts the fields we display from a run. The text-view cells // are pre-rendered here with their "N/A" fallbacks; the styled renderer adds the // hyperlinks and colors once the dashboard and MLflow identifiers are known. -func buildGetData(run *jobs.Run) getData { +func buildGetData(run *jobs.GetRunResponse) getData { data := getData{ - RunID: strconv.FormatInt(run.RunId, 10), + RunID: strconv.FormatInt(utils.Deref(run.RunId), 10), Status: runStatus(run.State), DisplayStatus: displayRunStatus(run), TerminationReason: terminationReason(run), @@ -266,7 +266,7 @@ func buildGetData(run *jobs.Run) getData { if data.ExperimentName != nil { data.ExperimentDisplay = *data.ExperimentName } - data.UserDisplay = orNA(run.CreatorUserName) + data.UserDisplay = orNA(utils.Deref(run.CreatorUserName)) data.AcceleratorsDisplay = orNA(accelerators(run)) // EnvironmentDisplay is resolved at render time: the serverless environment // version needs a raw GetRun read (the typed SDK Run drops it), so it is not diff --git a/cmd/air/get_test.go b/cmd/air/get_test.go index 7df2cf5e613..66bb173e705 100644 --- a/cmd/air/get_test.go +++ b/cmd/air/get_test.go @@ -13,12 +13,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) @@ -47,8 +44,7 @@ func TestGetCommandShape(t *testing.T) { } func TestGetRunInvalidID(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), m.WorkspaceClient) + ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), fakeWorkspace(t, nil)) cmd := withOutput(newGetCommand(), flags.OutputText) cmd.SetContext(ctx) @@ -87,11 +83,15 @@ func TestGetRunNotFound(t *testing.T) { } func TestGetRunAuthFailed(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) // A genuine auth failure (permission denied) is validated before the run is // fetched, so GetRun is never reached and nothing is rendered. - m.GetMockCurrentUserAPI().EXPECT().Me(mock.Anything, mock.Anything).Return(nil, apierr.ErrPermissionDenied) - ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), m.WorkspaceClient) + w := fakeWorkspace(t, map[string]http.HandlerFunc{ + "GET /api/2.0/preview/scim/v2/Me": respond(403, `{"error_code":"PERMISSION_DENIED","message":"denied"}`), + "GET /api/2.2/jobs/runs/get": func(w http.ResponseWriter, r *http.Request) { + t.Error("runs/get must not be called after a failed auth probe") + }, + }) + ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), w) cmd := withOutput(newGetCommand(), flags.OutputText) cmd.SetContext(ctx) @@ -101,11 +101,12 @@ func TestGetRunAuthFailed(t *testing.T) { } func TestGetRunAuthTransient(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) // A transient failure at the auth probe must not be misreported as an auth // error; it surfaces as a retryable internal error instead. - m.GetMockCurrentUserAPI().EXPECT().Me(mock.Anything, mock.Anything).Return(nil, errors.New("connection reset")) - ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), m.WorkspaceClient) + w := fakeWorkspace(t, map[string]http.HandlerFunc{ + "GET /api/2.0/preview/scim/v2/Me": respond(500, `{"error_code":"INTERNAL_ERROR","message":"connection reset"}`), + }) + ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), w) cmd := withOutput(newGetCommand(), flags.OutputText) cmd.SetContext(ctx) @@ -125,11 +126,11 @@ func TestAuthError(t *testing.T) { assert.Contains(t, noProfile.Error(), "no default profile is set") // A 401 / 403 (via the SDK sentinels) is a real auth failure. - unauth := authError(ctx, cmd, apierr.ErrUnauthenticated) + unauth := authError(ctx, cmd, newAPIError(401, "UNAUTHENTICATED", "invalid token")) require.Error(t, unauth) assert.Contains(t, unauth.Error(), "authentication was not successful") - denied := authError(ctx, cmd, apierr.ErrPermissionDenied) + denied := authError(ctx, cmd, newAPIError(403, "PERMISSION_DENIED", "denied")) require.Error(t, denied) assert.Contains(t, denied.Error(), "authentication was not successful") @@ -191,17 +192,17 @@ func TestGetTemplateSweepNoTasks(t *testing.T) { } func TestBuildGetData(t *testing.T) { - run := &jobs.Run{ - RunId: 123, - CreatorUserName: "me@example.com", - StartTime: 1700000000000, - EndTime: 1700000012000, - State: &jobs.RunState{ResultState: jobs.RunResultStateSuccess}, + run := &jobs.GetRunResponse{ + RunId: new(int64(123)), + CreatorUserName: new("me@example.com"), + StartTime: new(int64(1700000000000)), + EndTime: new(int64(1700000012000)), + State: &jobs.RunState{ResultState: jobs.RunResultState_RunResultState_Success}, Tasks: []jobs.RunTask{{ - AttemptNumber: 1, + AttemptNumber: new(1), GenAiComputeTask: &jobs.GenAiComputeTask{ - MlflowExperimentName: "/Users/me@example.com/exp", - Compute: &jobs.ComputeConfig{NumGpus: 8, GpuType: "GPU_8xH100"}, + MlflowExperimentName: new("/Users/me@example.com/exp"), + Compute: &jobs.ComputeConfig{NumGpus: new(8), GpuType: new("GPU_8xH100")}, }, }}, } @@ -221,11 +222,11 @@ func TestBuildGetData(t *testing.T) { } func TestBuildGetDataTerminationReasonJSON(t *testing.T) { - failed := buildGetData(&jobs.Run{ - RunId: 5, - State: &jobs.RunState{ResultState: jobs.RunResultStateFailed}, + failed := buildGetData(&jobs.GetRunResponse{ + RunId: new(int64(5)), + State: &jobs.RunState{ResultState: jobs.RunResultState_RunResultState_Failed}, Status: &jobs.RunStatus{TerminationDetails: &jobs.TerminationDetails{ - Message: "out of memory", + Message: new("out of memory"), }}, }) body, err := json.Marshal(failed) @@ -236,7 +237,7 @@ func TestBuildGetDataTerminationReasonJSON(t *testing.T) { "termination_reason":"out of memory","est_remaining_seconds":null,"est_percent_complete":null }`, string(body)) - canceled := buildGetData(&jobs.Run{RunId: 6, State: &jobs.RunState{ResultState: jobs.RunResultStateCanceled, StateMessage: "user canceled"}}) + canceled := buildGetData(&jobs.GetRunResponse{RunId: new(int64(6)), State: &jobs.RunState{ResultState: jobs.RunResultState_RunResultState_Canceled, StateMessage: new("user canceled")}}) body, err = json.Marshal(canceled) require.NoError(t, err) assert.NotContains(t, string(body), "termination_reason") @@ -254,12 +255,12 @@ func TestGetTemplateUsesDisplayStatus(t *testing.T) { func TestEnrichFromAiRuntimeTask(t *testing.T) { t.Run("fills config path, experiment, and accelerators", func(t *testing.T) { - run := &jobs.Run{RunId: 5, Tasks: []jobs.RunTask{{ + run := &jobs.GetRunResponse{RunId: new(int64(5)), Tasks: []jobs.RunTask{{ AiRuntimeTask: &jobs.AiRuntimeTask{ - Experiment: "/Users/me@example.com/my-exp", + Experiment: new("/Users/me@example.com/my-exp"), Deployments: []jobs.DeploymentSpec{{ - CommandPath: "/Workspace/run/command.sh", - Compute: jobs.ComputeSpec{AcceleratorType: jobs.ComputeSpecAcceleratorTypeGpu1xA10, AcceleratorCount: 1}, + CommandPath: new("/Workspace/run/command.sh"), + Compute: &jobs.ComputeSpec{AcceleratorType: jobs.ComputeSpec_AcceleratorType_Gpu1xA10, AcceleratorCount: new(1)}, }}, }, }}} @@ -273,7 +274,7 @@ func TestEnrichFromAiRuntimeTask(t *testing.T) { }) t.Run("leaves fallbacks when the run has no ai_runtime_task", func(t *testing.T) { - run := &jobs.Run{RunId: 5, Tasks: []jobs.RunTask{{}}} + run := &jobs.GetRunResponse{RunId: new(int64(5)), Tasks: []jobs.RunTask{{}}} data := &getData{ExperimentDisplay: na, AcceleratorsDisplay: na} enrichFromAiRuntimeTask(run, data) assert.Empty(t, data.TrainingConfigPath) @@ -284,7 +285,7 @@ func TestEnrichFromAiRuntimeTask(t *testing.T) { func TestBuildGetDataEmpty(t *testing.T) { // A run with no tasks, creator, or timing renders every text cell as "N/A". - d := buildGetData(&jobs.Run{RunId: 7}) + d := buildGetData(&jobs.GetRunResponse{RunId: new(int64(7))}) assert.Equal(t, "7", d.RunID) assert.Equal(t, na, d.SubmittedDisplay) assert.Equal(t, na, d.DurationDisplay) diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index 12e72c1f0cc..aca9a370a8e 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -11,7 +11,7 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" @@ -28,7 +28,7 @@ func newImagePushTestCommand(t *testing.T, profile string) (*cobra.Command, *byt stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} ctx := cmdio.InContext(t.Context(), cmdio.NewIO(t.Context(), flags.OutputText, strings.NewReader(""), stdout, stderr, "", "")) - ctx = cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{Config: &config.Config{Profile: profile}}) + ctx = cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{Config: &config.Config{Profile: profile}}) cmd := &cobra.Command{Use: "push"} cmd.SetContext(ctx) cmd.SetIn(strings.NewReader("")) diff --git a/cmd/air/joblist.go b/cmd/air/joblist.go index dd786d8b496..b3395d9e30a 100644 --- a/cmd/air/joblist.go +++ b/cmd/air/joblist.go @@ -6,9 +6,10 @@ import ( "fmt" "net/http" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/apierr" "golang.org/x/sync/errgroup" ) @@ -18,7 +19,7 @@ const hydrateConcurrency = 16 // firstTask returns the run's first task, unwrapping a foreach sweep to the // iterated task, or nil when the run has no tasks. -func firstTask(r *jobs.Run) *jobs.RunTask { +func firstTask(r *jobs.GetRunResponse) *jobs.RunTask { if len(r.Tasks) == 0 { return nil } @@ -39,68 +40,68 @@ func firstTask(r *jobs.Run) *jobs.RunTask { // isAirRun reports whether a run is an AI runtime workload: an ai_runtime_task, // or a legacy gen_ai_compute_task with a training script. -func isAirRun(r *jobs.Run) bool { +func isAirRun(r *jobs.GetRunResponse) bool { t := firstTask(r) if t == nil { return false } return t.AiRuntimeTask != nil || - (t.GenAiComputeTask != nil && t.GenAiComputeTask.TrainingScriptPath != "") + (t.GenAiComputeTask != nil && utils.Deref(t.GenAiComputeTask.TrainingScriptPath) != "") } // isSweep reports whether the run's first task fans out into iterations. -func isSweep(r *jobs.Run) bool { +func isSweep(r *jobs.GetRunResponse) bool { return len(r.Tasks) > 0 && r.Tasks[0].ForEachTask != nil } // taskRunID returns the run id of the AIR task, used to fetch its MLflow output. -func taskRunID(r *jobs.Run) int64 { +func taskRunID(r *jobs.GetRunResponse) int64 { if len(r.Tasks) == 0 { return 0 } - return r.Tasks[0].RunId + return utils.Deref(r.Tasks[0].RunId) } // jobExperiment returns the run's MLflow experiment name (user-folder prefix // stripped), or "" when there is none. -func jobExperiment(r *jobs.Run) string { +func jobExperiment(r *jobs.GetRunResponse) string { t := firstTask(r) switch { case t == nil: return "" - case t.AiRuntimeTask != nil && t.AiRuntimeTask.Experiment != "": - return stripExperimentUserPrefix(t.AiRuntimeTask.Experiment) - case t.GenAiComputeTask != nil && t.GenAiComputeTask.MlflowExperimentName != "": - return stripExperimentUserPrefix(t.GenAiComputeTask.MlflowExperimentName) + case t.AiRuntimeTask != nil && utils.Deref(t.AiRuntimeTask.Experiment) != "": + return stripExperimentUserPrefix(utils.Deref(t.AiRuntimeTask.Experiment)) + case t.GenAiComputeTask != nil && utils.Deref(t.GenAiComputeTask.MlflowExperimentName) != "": + return stripExperimentUserPrefix(utils.Deref(t.GenAiComputeTask.MlflowExperimentName)) } return "" } // jobCompute returns the run's accelerator type and count, or ("", 0) when it // has none. -func jobCompute(r *jobs.Run) (string, int) { +func jobCompute(r *jobs.GetRunResponse) (string, int) { t := firstTask(r) switch { case t == nil: return "", 0 case t.AiRuntimeTask != nil && len(t.AiRuntimeTask.Deployments) > 0: c := t.AiRuntimeTask.Deployments[0].Compute - return string(c.AcceleratorType), c.AcceleratorCount + return string(c.AcceleratorType), utils.Deref(c.AcceleratorCount) case t.GenAiComputeTask != nil && t.GenAiComputeTask.Compute != nil: c := t.GenAiComputeTask.Compute - return c.GpuType, c.NumGpus + return utils.Deref(c.GpuType), utils.Deref(c.NumGpus) } return "", 0 } // jobTiming returns the run's start and end times (epoch ms), preferring the // first task's window so a run reports its task attempt rather than the wrapper. -func jobTiming(r *jobs.Run) (startMillis, endMillis int64) { - startMillis, endMillis = r.StartTime, r.EndTime +func jobTiming(r *jobs.GetRunResponse) (startMillis, endMillis int64) { + startMillis, endMillis = utils.Deref(r.StartTime), utils.Deref(r.EndTime) if len(r.Tasks) > 0 { - if t := r.Tasks[0]; t.StartTime > 0 { - startMillis = t.StartTime - endMillis = t.EndTime + if t := r.Tasks[0]; utils.Deref(t.StartTime) > 0 { + startMillis = utils.Deref(t.StartTime) + endMillis = utils.Deref(t.EndTime) } } return startMillis, endMillis @@ -108,12 +109,12 @@ func jobTiming(r *jobs.Run) (startMillis, endMillis int64) { // isTerminal reports whether a run has finished and its details are immutable, // so its row is safe to cache. -func isTerminal(r *jobs.Run) bool { +func isTerminal(r *jobs.GetRunResponse) bool { if r.State == nil { return false } switch r.State.LifeCycleState { - case jobs.RunLifeCycleStateTerminated, jobs.RunLifeCycleStateInternalError, jobs.RunLifeCycleStateSkipped: + case jobs.RunLifeCycleState_RunLifeCycleState_Terminated, jobs.RunLifeCycleState_RunLifeCycleState_InternalError, jobs.RunLifeCycleState_RunLifeCycleState_Skipped: return true default: return false @@ -122,8 +123,8 @@ func isTerminal(r *jobs.Run) bool { // baseRunToRun converts a runs/list BaseRun into a Run so the display helpers // operate on a single type. The two share every field the list path reads. -func baseRunToRun(b jobs.BaseRun) *jobs.Run { - return &jobs.Run{ +func baseRunToRun(b jobs.BaseRun) *jobs.GetRunResponse { + return &jobs.GetRunResponse{ RunId: b.RunId, RunName: b.RunName, CreatorUserName: b.CreatorUserName, @@ -136,8 +137,8 @@ func baseRunToRun(b jobs.BaseRun) *jobs.Run { // fetchJobRun fetches a single run via runs/get; expand_tasks is implied by the // typed SDK, which returns the ai_runtime_task in the response. -func fetchJobRun(ctx context.Context, w *databricks.WorkspaceClient, runID int64) (*jobs.Run, error) { - run, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: runID}) +func fetchJobRun(ctx context.Context, w *sdkclients.Clients, runID int64) (*jobs.GetRunResponse, error) { + run, err := getRun(ctx, w, runID) if err != nil { return nil, fmt.Errorf("failed to get run %d: %w", runID, err) } @@ -148,8 +149,8 @@ func fetchJobRun(ctx context.Context, w *databricks.WorkspaceClient, runID int64 // input order. runs/get enforces per-run view ACLs, so an id the caller can't // view (403) or that has been purged (404) is dropped; any other error is // systemic and fails the whole batch. -func hydrateJobRuns(ctx context.Context, w *databricks.WorkspaceClient, ids []int64) ([]*jobs.Run, error) { - runs := make([]*jobs.Run, len(ids)) +func hydrateJobRuns(ctx context.Context, w *sdkclients.Clients, ids []int64) ([]*jobs.GetRunResponse, error) { + runs := make([]*jobs.GetRunResponse, len(ids)) g, gctx := errgroup.WithContext(ctx) g.SetLimit(hydrateConcurrency) for i, id := range ids { @@ -157,7 +158,7 @@ func hydrateJobRuns(ctx context.Context, w *databricks.WorkspaceClient, ids []in run, err := fetchJobRun(gctx, w, id) if err != nil { if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && - (apiErr.StatusCode == http.StatusForbidden || apiErr.StatusCode == http.StatusNotFound) { + (apiErr.HTTPStatusCode() == http.StatusForbidden || apiErr.HTTPStatusCode() == http.StatusNotFound) { return nil // not viewable or purged: drop this id } return fmt.Errorf("failed to get run %d: %w", id, err) @@ -170,7 +171,7 @@ func hydrateJobRuns(ctx context.Context, w *databricks.WorkspaceClient, ids []in return nil, err } - hydrated := make([]*jobs.Run, 0, len(runs)) + hydrated := make([]*jobs.GetRunResponse, 0, len(runs)) for _, run := range runs { if run != nil { hydrated = append(hydrated, run) diff --git a/cmd/air/list.go b/cmd/air/list.go index 4b5c623eccc..eb59cb975b7 100644 --- a/cmd/air/list.go +++ b/cmd/air/list.go @@ -3,15 +3,16 @@ package aircmd import ( "context" "fmt" + "iter" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/listing" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" "github.com/spf13/cobra" "golang.org/x/sync/errgroup" ) @@ -134,11 +135,11 @@ Filters: userFilter := f.User var currentUser string if userFilter == "" && !allUsers { - me, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + me, err := currentUserName(ctx, w) if err != nil { return fmt.Errorf("failed to resolve current user: %w", err) } - currentUser = me.UserName + currentUser = me userFilter = currentUser } @@ -196,7 +197,7 @@ type listStrategy interface { // shared tail: MLflow enrichment (text only) and row projection. type runFetcher struct { ctx context.Context - w *databricks.WorkspaceClient + w *sdkclients.Clients fetchMLflow bool strategy listStrategy workspaceID int64 @@ -204,7 +205,7 @@ type runFetcher struct { exhausted bool } -func newRunFetcher(ctx context.Context, w *databricks.WorkspaceClient, q listQuery) *runFetcher { +func newRunFetcher(ctx context.Context, w *sdkclients.Clients, q listQuery) *runFetcher { return &runFetcher{ ctx: ctx, w: w, @@ -219,7 +220,7 @@ func newRunFetcher(ctx context.Context, w *databricks.WorkspaceClient, q listQue // index load fails (e.g. endpoint unavailable in this workspace), we fall back to // the Jobs scan so the command still returns. Everything else — the default // active list, --all-users, and --all-status for another user — uses the scan. -func newListStrategy(ctx context.Context, w *databricks.WorkspaceClient, q listQuery) listStrategy { +func newListStrategy(ctx context.Context, w *sdkclients.Clients, q listQuery) listStrategy { useIndex := !q.activeOnly && !q.allUsers && (q.userFilter == "" || q.userFilter == q.currentUser) if !useIndex { return newJobsScanStrategy(ctx, w, q) @@ -262,9 +263,17 @@ func (f *runFetcher) next(want int) ([]listRow, error) { // and filters. It buffers a page's leftover runs so successive next() calls // resume where the last stopped. type jobsScanStrategy struct { - ctx context.Context - w *databricks.WorkspaceClient - iter listing.Iterator[jobs.BaseRun] + ctx context.Context + w *sdkclients.Clients + pull func() (*jobs.BaseRun, error, bool) + stop func() + + // One run of lookahead, so done() knows whether the listing is exhausted + // without consuming a run. + peeked *jobs.BaseRun + peekedErr error + hasPeeked bool + exhausted bool userFilter string filters listFilters host string @@ -273,17 +282,21 @@ type jobsScanStrategy struct { scanned int } -func newJobsScanStrategy(ctx context.Context, w *databricks.WorkspaceClient, q listQuery) *jobsScanStrategy { - req := jobs.ListRunsRequest{ - RunType: jobs.RunTypeSubmitRun, - ExpandTasks: true, - Limit: jobsPageLimit, - ActiveOnly: q.activeOnly, +func newJobsScanStrategy(ctx context.Context, w *sdkclients.Clients, q listQuery) *jobsScanStrategy { + req := sdkjobs.ListRunsRequest{ + RunType: sdkjobs.RunType_SubmitRun, + ExpandTasks: new(true), + Limit: new(int(jobsPageLimit)), + } + if q.activeOnly { + req.StateConstraint = &sdkjobs.ListRunsRequest_StateConstraint_ActiveOnly{ActiveOnly: true} } + pull, stop := iter.Pull2(listRuns(ctx, w, req)) return &jobsScanStrategy{ ctx: ctx, w: w, - iter: w.Jobs.ListRuns(ctx, req), + pull: pull, + stop: stop, userFilter: q.userFilter, filters: q.filters, host: w.Config.Host, @@ -293,30 +306,42 @@ func newJobsScanStrategy(ctx context.Context, w *databricks.WorkspaceClient, q l func (s *jobsScanStrategy) next(want int) ([]listedRun, error) { var entries []listedRun - for len(entries) < want && s.scanned < maxListScan && s.iter.HasNext(s.ctx) { - base, err := s.iter.Next(s.ctx) + for len(entries) < want && s.scanned < maxListScan && s.hasNext() { + base, err := s.peeked, s.peekedErr + s.hasPeeked = false if err != nil { return nil, fmt.Errorf("failed to list runs: %w", err) } s.scanned++ - run := baseRunToRun(base) + run := baseRunToRun(*base) if !isAirRun(run) { continue } - if s.userFilter != "" && run.CreatorUserName != s.userFilter { + if s.userFilter != "" && utils.Deref(run.CreatorUserName) != s.userFilter { continue } if !s.filters.matches(run) { continue } - entries = append(entries, listedRun{row: buildListRow(run, s.host, s.workspaceID), runID: run.RunId, taskRunID: taskRunID(run)}) + entries = append(entries, listedRun{row: buildListRow(run, s.host, s.workspaceID), runID: utils.Deref(run.RunId), taskRunID: taskRunID(run)}) } return entries, nil } func (s *jobsScanStrategy) done() bool { - return s.scanned >= maxListScan || !s.iter.HasNext(s.ctx) + return s.scanned >= maxListScan || !s.hasNext() +} + +func (s *jobsScanStrategy) hasNext() bool { + if !s.hasPeeked && !s.exhausted { + s.peeked, s.peekedErr, s.hasPeeked = s.pull() + if !s.hasPeeked { + s.exhausted = true + s.stop() + } + } + return s.hasPeeked } func (s *jobsScanStrategy) truncated() bool { @@ -335,7 +360,7 @@ func warnIfTruncated(ctx context.Context, f *runFetcher) { // and, for a running run, its ETA - in parallel, best-effort: a row whose IDs // can't be resolved keeps its "-" placeholder, and a run we can't estimate has // no ETA. -func setMLflowLinks(ctx context.Context, w *databricks.WorkspaceClient, host string, entries []listedRun) { +func setMLflowLinks(ctx context.Context, w *sdkclients.Clients, host string, entries []listedRun) { var g errgroup.Group g.SetLimit(enrichConcurrency) for i := range entries { @@ -353,7 +378,7 @@ func setMLflowLinks(ctx context.Context, w *databricks.WorkspaceClient, host str entries[i].row.ExperimentURL = mlflowExperimentURL(host, ids) // The ETA needs a progress-metric history fetch, so it's computed only // for running rows (the only ones that can have one). - if entries[i].row.Status == string(jobs.RunLifeCycleStateRunning) { + if entries[i].row.Status == string(jobs.RunLifeCycleState_RunLifeCycleState_Running) { if eta := estimateTrainingETA(ctx, w, ids.RunID); eta != nil { entries[i].row.Progress = eta.compact() } diff --git a/cmd/air/list_cache_test.go b/cmd/air/list_cache_test.go index 820b7d1718f..b828117e655 100644 --- a/cmd/air/list_cache_test.go +++ b/cmd/air/list_cache_test.go @@ -6,7 +6,7 @@ import ( "net/http/httptest" "testing" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -43,7 +43,7 @@ func TestIndexStrategyServesCachedRowWithoutFetch(t *testing.T) { t.Setenv("DATABRICKS_CACHE_DIR", t.TempDir()) refs := []workflowRef{{jobRunID: 7, submitTimeMs: 1000_000}} - srv, hits := indexAndGetServer(t, refs, map[int64]jobs.Run{7: indexRun(7, 1000_000)}, nil, nil) + srv, hits := indexAndGetServer(t, refs, map[int64]jobs.GetRunResponse{7: indexRun(7, 1000_000)}, nil, nil) host := srv.URL // Pre-seed the cache for run 7 so hydration should skip runs/get entirely. @@ -64,7 +64,7 @@ func TestIndexStrategyFiltersCachedRow(t *testing.T) { t.Setenv("DATABRICKS_CACHE_DIR", t.TempDir()) refs := []workflowRef{{jobRunID: 7, submitTimeMs: 1000_000}} - srv, hits := indexAndGetServer(t, refs, map[int64]jobs.Run{7: indexRun(7, 1000_000)}, nil, nil) + srv, hits := indexAndGetServer(t, refs, map[int64]jobs.GetRunResponse{7: indexRun(7, 1000_000)}, nil, nil) host := srv.URL // Cache hit under experiment "bar" must be filtered out by an experiment=foo query. @@ -87,7 +87,7 @@ func TestIndexStrategyServesMatchingCachedRow(t *testing.T) { t.Setenv("DATABRICKS_CACHE_DIR", t.TempDir()) refs := []workflowRef{{jobRunID: 7, submitTimeMs: 1000_000}} - srv, hits := indexAndGetServer(t, refs, map[int64]jobs.Run{7: indexRun(7, 1000_000)}, nil, nil) + srv, hits := indexAndGetServer(t, refs, map[int64]jobs.GetRunResponse{7: indexRun(7, 1000_000)}, nil, nil) host := srv.URL ctx := t.Context() @@ -110,7 +110,7 @@ func TestIndexStrategyCachesMLflowEnrichment(t *testing.T) { t.Setenv("DATABRICKS_CACHE_DIR", t.TempDir()) run := indexRun(7, 1000_000) - run.Tasks[0].RunId = 70 + run.Tasks[0].RunId = new(int64(70)) var getHits, outputHits, mlflowHits int var outputRunIDs []string srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -163,8 +163,8 @@ func TestIndexStrategyCachesMLflowEnrichment(t *testing.T) { } func TestIsTerminal(t *testing.T) { - assert.True(t, isTerminal(&jobs.Run{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateTerminated}})) - assert.True(t, isTerminal(&jobs.Run{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateInternalError}})) - assert.False(t, isTerminal(&jobs.Run{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning}})) - assert.False(t, isTerminal(&jobs.Run{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStatePending}})) + assert.True(t, isTerminal(&jobs.GetRunResponse{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated}})) + assert.True(t, isTerminal(&jobs.GetRunResponse{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_InternalError}})) + assert.False(t, isTerminal(&jobs.GetRunResponse{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running}})) + assert.False(t, isTerminal(&jobs.GetRunResponse{State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Pending}})) } diff --git a/cmd/air/list_detail.go b/cmd/air/list_detail.go index c0eca25b13f..69dfadc390e 100644 --- a/cmd/air/list_detail.go +++ b/cmd/air/list_detail.go @@ -3,20 +3,18 @@ package aircmd import ( "bytes" "context" - "errors" "fmt" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" ) // runDetailText fetches a run and renders the same styled view as `air get` into // a string, for the list picker's detail pane. -func runDetailText(ctx context.Context, w *databricks.WorkspaceClient, runID int64) (string, error) { - run, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: runID}) +func runDetailText(ctx context.Context, w *sdkclients.Clients, runID int64) (string, error) { + run, err := getRun(ctx, w, runID) if err != nil { - if errors.Is(err, apierr.ErrResourceDoesNotExist) { + if apierrs.Is(err, apierrs.ErrResourceDoesNotExist) { return "", fmt.Errorf("run %d not found", runID) } return "", fmt.Errorf("failed to fetch run: %w", err) @@ -40,10 +38,10 @@ func runDetailText(ctx context.Context, w *databricks.WorkspaceClient, runID int // runLogsSnapshot fetches a one-shot tail of a run's logs into a string, for the // list picker's detail pane. -func runLogsSnapshot(ctx context.Context, w *databricks.WorkspaceClient, runID int64) (string, error) { +func runLogsSnapshot(ctx context.Context, w *sdkclients.Clients, runID int64) (string, error) { status, err := resolveRunStatus(ctx, w, runID) if err != nil { - if errors.Is(err, apierr.ErrResourceDoesNotExist) { + if apierrs.Is(err, apierrs.ErrResourceDoesNotExist) { return "", fmt.Errorf("run %d not found", runID) } return "", fmt.Errorf("failed to fetch run status: %w", err) diff --git a/cmd/air/list_filter.go b/cmd/air/list_filter.go index bd2bf8dff6e..d5553fb5b8a 100644 --- a/cmd/air/list_filter.go +++ b/cmd/air/list_filter.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" ) // supportedFilterKeys are the keys accepted by `air list --filter KEY=VALUE`. @@ -68,7 +68,7 @@ type filterFields struct { GPUCount int `json:"gpu_count"` } -func filterFieldsFromRun(run *jobs.Run) filterFields { +func filterFieldsFromRun(run *jobs.GetRunResponse) filterFields { gpuType, count := jobCompute(run) return filterFields{ Experiment: jobExperiment(run), @@ -80,7 +80,7 @@ func filterFieldsFromRun(run *jobs.Run) filterFields { // matches reports whether a run satisfies the experiment, accelerator-type and // accelerator-count filters. The user filter is applied separately while // scanning, since it maps onto the run's creator rather than its task. -func (f listFilters) matches(run *jobs.Run) bool { +func (f listFilters) matches(run *jobs.GetRunResponse) bool { return f.matchesFields(filterFieldsFromRun(run)) } diff --git a/cmd/air/list_format.go b/cmd/air/list_format.go index 81c22fbbea9..474bc670b5e 100644 --- a/cmd/air/list_format.go +++ b/cmd/air/list_format.go @@ -4,13 +4,14 @@ import ( "strconv" "time" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" ) // buildListRow extracts the columns shown for one run. Optional cells fall back // to "-"; MLflowURL starts as "-" and setMLflowLinks fills it in for text output. // host and workspaceID are used for building dashboard URLs. -func buildListRow(run *jobs.Run, host string, workspaceID int64) listRow { +func buildListRow(run *jobs.GetRunResponse, host string, workspaceID int64) listRow { experiment := "-" if e := jobExperiment(run); e != "" { experiment = e @@ -34,9 +35,9 @@ func buildListRow(run *jobs.Run, host string, workspaceID int64) listRow { } return listRow{ - RunID: strconv.FormatInt(run.RunId, 10), - RunName: run.RunName, - User: run.CreatorUserName, + RunID: strconv.FormatInt(utils.Deref(run.RunId), 10), + RunName: utils.Deref(run.RunName), + User: utils.Deref(run.CreatorUserName), Status: displayRunStatus(run), DisplayStatus: displayRunStatus(run), StartedAt: startedAt, @@ -45,7 +46,7 @@ func buildListRow(run *jobs.Run, host string, workspaceID int64) listRow { Duration: duration, MLflowURL: "-", MLflowLabel: "-", - RunURL: dashboardURL(host, run.RunId, workspaceID), + RunURL: dashboardURL(host, utils.Deref(run.RunId), workspaceID), Accelerators: accel, } } diff --git a/cmd/air/list_index.go b/cmd/air/list_index.go index 52a70173a97..32dce3eb709 100644 --- a/cmd/air/list_index.go +++ b/cmd/air/list_index.go @@ -6,7 +6,8 @@ import ( "slices" "github.com/databricks/cli/libs/cache" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" ) // indexStrategy serves the caller's own runs from the AiTrainingService index: @@ -17,7 +18,7 @@ import ( // whole id set first), but it still yields in batches so the table paints early. type indexStrategy struct { ctx context.Context - w *databricks.WorkspaceClient + w *sdkclients.Clients activeOnly bool filters listFilters limit int @@ -30,7 +31,7 @@ type indexStrategy struct { loaded bool } -func newIndexStrategy(ctx context.Context, w *databricks.WorkspaceClient, q listQuery, limit int) *indexStrategy { +func newIndexStrategy(ctx context.Context, w *sdkclients.Clients, q listQuery, limit int) *indexStrategy { return &indexStrategy{ ctx: ctx, w: w, @@ -126,10 +127,10 @@ func (s *indexStrategy) hydrate(ids []int64) ([]listedRun, error) { } row := buildListRow(run, s.host, s.workspaceID) taskRunID := taskRunID(run) - rows = append(rows, listedRun{row: row, runID: run.RunId, taskRunID: taskRunID}) + rows = append(rows, listedRun{row: row, runID: utils.Deref(run.RunId), taskRunID: taskRunID}) if isTerminal(run) { start, _ := jobTiming(run) - putRow(s.ctx, s.cache, host, run.RunId, taskRunID, start, row, fields) + putRow(s.ctx, s.cache, host, utils.Deref(run.RunId), taskRunID, start, row, fields) } } diff --git a/cmd/air/list_index_test.go b/cmd/air/list_index_test.go index f9f6151aae4..4961b6066d0 100644 --- a/cmd/air/list_index_test.go +++ b/cmd/air/list_index_test.go @@ -8,17 +8,17 @@ import ( "strconv" "testing" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) // indexRun is a terminal AIR run with a start time, for index-path hydration. -func indexRun(id, startMillis int64) jobs.Run { +func indexRun(id, startMillis int64) jobs.GetRunResponse { r := airRun(id, "me@example.com", "GPU_1xH100", 1, "/Users/me@example.com/exp") - r.State = &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateTerminated, ResultState: jobs.RunResultStateSuccess} - r.Tasks[0].StartTime = startMillis - r.Tasks[0].EndTime = startMillis + 1000 + r.State = &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, ResultState: jobs.RunResultState_RunResultState_Success} + r.Tasks[0].StartTime = new(startMillis) + r.Tasks[0].EndTime = new(startMillis + 1000) return r } @@ -27,7 +27,7 @@ func indexRun(id, startMillis int64) jobs.Run { // runID in forbidden returns 403; in missing returns 404. type indexHits struct{ index, get int } -func indexAndGetServer(t *testing.T, refs []workflowRef, runs map[int64]jobs.Run, forbidden, missing map[int64]bool) (*httptest.Server, *indexHits) { +func indexAndGetServer(t *testing.T, refs []workflowRef, runs map[int64]jobs.GetRunResponse, forbidden, missing map[int64]bool) (*httptest.Server, *indexHits) { t.Helper() hits := &indexHits{} wfs := make([]map[string]any, len(refs)) @@ -69,7 +69,7 @@ func TestIndexStrategyOrdersAndLimits(t *testing.T) { {jobRunID: 2, submitTimeMs: 3000_000}, {jobRunID: 3, submitTimeMs: 2000_000}, } - runs := map[int64]jobs.Run{ + runs := map[int64]jobs.GetRunResponse{ 1: indexRun(1, 1000_000), 2: indexRun(2, 3000_000), 3: indexRun(3, 2000_000), @@ -96,10 +96,10 @@ func TestIndexStrategyOverFetchesWithTaskFilter(t *testing.T) { {jobRunID: 2, submitTimeMs: 2000_000}, } run1 := indexRun(1, 3000_000) - run1.Tasks[0].AiRuntimeTask.Experiment = "/Users/me@example.com/llama" + run1.Tasks[0].AiRuntimeTask.Experiment = new("/Users/me@example.com/llama") run2 := indexRun(2, 2000_000) - run2.Tasks[0].AiRuntimeTask.Experiment = "/Users/me@example.com/qwen" - srv, _ := indexAndGetServer(t, refs, map[int64]jobs.Run{1: run1, 2: run2}, nil, nil) + run2.Tasks[0].AiRuntimeTask.Experiment = new("/Users/me@example.com/qwen") + srv, _ := indexAndGetServer(t, refs, map[int64]jobs.GetRunResponse{1: run1, 2: run2}, nil, nil) t.Setenv("DATABRICKS_CACHE_ENABLED", "false") f := newRunFetcher(t.Context(), newTestWorkspaceClient(t, srv.URL), listQuery{ @@ -118,7 +118,7 @@ func TestIndexStrategyDropsForbiddenAndMissing(t *testing.T) { {jobRunID: 2, submitTimeMs: 2000_000}, {jobRunID: 3, submitTimeMs: 1000_000}, } - runs := map[int64]jobs.Run{1: indexRun(1, 3000_000), 3: indexRun(3, 1000_000)} + runs := map[int64]jobs.GetRunResponse{1: indexRun(1, 3000_000), 3: indexRun(3, 1000_000)} srv, _ := indexAndGetServer(t, refs, runs, map[int64]bool{2: true}, nil) t.Setenv("DATABRICKS_CACHE_ENABLED", "false") diff --git a/cmd/air/list_test.go b/cmd/air/list_test.go index a7700d162f0..2cf43fad2a2 100644 --- a/cmd/air/list_test.go +++ b/cmd/air/list_test.go @@ -9,8 +9,8 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -19,29 +19,29 @@ import ( // returns it with expand_tasks. func airBaseRun(id int64, user, accelType string, count int, experiment string) jobs.BaseRun { return jobs.BaseRun{ - RunId: id, - RunName: "run-" + strconv.FormatInt(id, 10), - CreatorUserName: user, - State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning}, + RunId: new(id), + RunName: new("run-" + strconv.FormatInt(id, 10)), + CreatorUserName: new(user), + State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running}, Tasks: []jobs.RunTask{{AiRuntimeTask: &jobs.AiRuntimeTask{ - Experiment: experiment, + Experiment: new(experiment), Deployments: []jobs.DeploymentSpec{{ - Compute: jobs.ComputeSpec{AcceleratorType: jobs.ComputeSpecAcceleratorType(accelType), AcceleratorCount: count}, + Compute: &jobs.ComputeSpec{AcceleratorType: jobs.ComputeSpec_AcceleratorType(accelType), AcceleratorCount: new(count)}, }}, }}}, } } // airRun is the runs/get equivalent of airBaseRun, for the helpers that operate -// on a *jobs.Run. -func airRun(id int64, user, accelType string, count int, experiment string) jobs.Run { +// on a *jobs.GetRunResponse. +func airRun(id int64, user, accelType string, count int, experiment string) jobs.GetRunResponse { return *baseRunToRun(airBaseRun(id, user, accelType, count, experiment)) } // runsListBody marshals one runs/list response page. func runsListBody(t *testing.T, nextToken string, runs ...jobs.BaseRun) string { t.Helper() - b, err := json.Marshal(jobs.ListRunsResponse{Runs: runs, NextPageToken: nextToken, HasMore: nextToken != ""}) + b, err := json.Marshal(jobs.ListRunsResponse{Runs: runs, NextPageToken: utils.NonZero(nextToken), HasMore: utils.NonZero(nextToken != "")}) require.NoError(t, err) return string(b) } @@ -67,8 +67,8 @@ func runsServer(t *testing.T, bodies ...string) *httptest.Server { func TestListAirRunsFiltersUserAndType(t *testing.T) { runs := []jobs.BaseRun{ airBaseRun(1, "me@example.com", "GPU_8xH100", 8, "/Users/me@example.com/exp-a"), - {RunId: 2, CreatorUserName: "me@example.com", Tasks: []jobs.RunTask{{}}}, // not an AIR run - airBaseRun(3, "other@example.com", "GPU_1xA10", 1, "/Users/other/exp-b"), // wrong user + {RunId: new(int64(2)), CreatorUserName: new("me@example.com"), Tasks: []jobs.RunTask{{}}}, // not an AIR run + airBaseRun(3, "other@example.com", "GPU_1xA10", 1, "/Users/other/exp-b"), // wrong user airBaseRun(5, "me@example.com", "GPU_1xH100", 1, "/Users/me@example.com/exp-c"), } srv := runsServer(t, runsListBody(t, "", runs...)) @@ -157,9 +157,9 @@ func TestRunFetcherResumesAcrossCalls(t *testing.T) { func TestBuildListRowFromRun(t *testing.T) { run := airRun(842552489592352, "me@example.com", "GPU_1xA10", 1, "my-first-air-run") - run.StartTime = 1700000000000 - run.EndTime = 1700000012000 - run.State = &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateTerminated, ResultState: jobs.RunResultStateSuccess} + run.StartTime = new(int64(1700000000000)) + run.EndTime = new(int64(1700000012000)) + run.State = &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, ResultState: jobs.RunResultState_RunResultState_Success} assert.True(t, isAirRun(&run)) assert.Equal(t, "my-first-air-run", jobExperiment(&run)) @@ -177,9 +177,9 @@ func TestBuildListRowFromRun(t *testing.T) { func TestBuildListRow(t *testing.T) { run := airRun(123, "me@example.com", "GPU_8xH100", 8, "/Users/me@example.com/exp") - run.StartTime = 1700000000000 - run.EndTime = 1700000012000 - run.State = &jobs.RunState{ResultState: jobs.RunResultStateSuccess} + run.StartTime = new(int64(1700000000000)) + run.EndTime = new(int64(1700000012000)) + run.State = &jobs.RunState{ResultState: jobs.RunResultState_RunResultState_Success} row := buildListRow(&run, "https://example.test", 0) assert.Equal(t, "123", row.RunID) @@ -195,8 +195,8 @@ func TestBuildListRow(t *testing.T) { func TestBuildListRowWaitingForComputeStatus(t *testing.T) { run := airRun(123, "me@example.com", "GPU_8xH100", 8, "exp") - run.State = &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning} - run.Tasks[0].State = &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStatePending} + run.State = &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running} + run.Tasks[0].State = &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Pending} row := buildListRow(&run, "https://example.test", 0) body, err := json.Marshal(row) @@ -212,7 +212,7 @@ func TestBuildListRowWaitingForComputeStatus(t *testing.T) { func TestBuildListRowDashFallbacks(t *testing.T) { // A run with no task, compute, or start time falls back to dashes and UNKNOWN. - row := buildListRow(&jobs.Run{RunId: 7}, "https://example.test", 0) + row := buildListRow(&jobs.GetRunResponse{RunId: new(int64(7))}, "https://example.test", 0) assert.Equal(t, "-", row.Experiment) assert.Equal(t, "-", row.Duration) assert.Equal(t, "-", row.Accelerators) @@ -222,16 +222,15 @@ func TestBuildListRowDashFallbacks(t *testing.T) { } func TestBuildListRowSweep(t *testing.T) { - run := jobs.Run{RunId: 9, Tasks: []jobs.RunTask{{ - ForEachTask: &jobs.RunForEachTask{Task: jobs.Task{AiRuntimeTask: &jobs.AiRuntimeTask{Experiment: "sweep"}}}, + run := jobs.GetRunResponse{RunId: new(int64(9)), Tasks: []jobs.RunTask{{ + ForEachTask: &jobs.ForEachTask{Task: &jobs.TaskSettings{AiRuntimeTask: &jobs.AiRuntimeTask{Experiment: new("sweep")}}}, }}} assert.True(t, buildListRow(&run, "https://example.test", 0).IsSweep) assert.Equal(t, "sweep", buildListRow(&run, "https://example.test", 0).Experiment) } func TestListInvalidLimit(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), m.WorkspaceClient) + ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), fakeWorkspace(t, nil)) cmd := newListCommand() cmd.SetContext(ctx) require.NoError(t, cmd.Flags().Set("limit", "0")) @@ -242,8 +241,7 @@ func TestListInvalidLimit(t *testing.T) { } func TestListInvalidFilter(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), m.WorkspaceClient) + ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), fakeWorkspace(t, nil)) cmd := newListCommand() cmd.SetContext(ctx) require.NoError(t, cmd.Flags().Set("filter", "bogus=1")) diff --git a/cmd/air/list_tui.go b/cmd/air/list_tui.go index 636836a84a0..3a5f40165f7 100644 --- a/cmd/air/list_tui.go +++ b/cmd/air/list_tui.go @@ -9,6 +9,7 @@ import ( "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/browser" "github.com/databricks/cli/libs/cmdio" "github.com/spf13/cobra" @@ -201,7 +202,7 @@ func (m listModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } m.detailLoading = false if msg.err != nil { - m.detailContent = fmt.Sprintf("Error: %v", msg.err) + m.detailContent = "Error: " + apierrs.ErrorString(msg.err) } else { m.detailContent = msg.body } diff --git a/cmd/air/logbricklens.go b/cmd/air/logbricklens.go index ca3b8170130..57e9a6331da 100644 --- a/cmd/air/logbricklens.go +++ b/cmd/air/logbricklens.go @@ -7,7 +7,7 @@ import ( "net/http" "strconv" - "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/cli/libs/apiclient" ) // bricklensLogsPathFmt is the log endpoint, keyed by Jobs run id. Called with a @@ -55,7 +55,7 @@ type bricklensLogsQuery struct { // getBricklensLogs fetches one page of logs. The API client is built once by the // caller and reused across the poll loop. It returns the raw error so the caller // can classify it via classifyLogError. -func getBricklensLogs(ctx context.Context, apiClient *client.DatabricksClient, headers map[string]string, runID int64, q bricklensLogsQuery) (*bricklensLogsResponse, error) { +func getBricklensLogs(ctx context.Context, apiClient *apiclient.Client, headers map[string]string, runID int64, q bricklensLogsQuery) (*bricklensLogsResponse, error) { query := map[string]any{ // Always sent: the tail path relies on an explicit false for newest-first. "ascending": strconv.FormatBool(q.ascending), diff --git a/cmd/air/logbricklens_test.go b/cmd/air/logbricklens_test.go index b9ef527a4f5..996fcdd2781 100644 --- a/cmd/air/logbricklens_test.go +++ b/cmd/air/logbricklens_test.go @@ -6,7 +6,7 @@ import ( "net/url" "testing" - "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/cli/libs/apiclient" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -24,7 +24,7 @@ func TestGetBricklensLogsQuerySerialization(t *testing.T) { t.Cleanup(srv.Close) w := newTestWorkspaceClient(t, srv.URL) - apiClient, err := client.New(w.Config) + apiClient, err := apiclient.New(w.Config) require.NoError(t, err) _, err = getBricklensLogs(t.Context(), apiClient, nil, 42, bricklensLogsQuery{ fromSeconds: 100, @@ -58,7 +58,7 @@ func TestGetBricklensLogsOmitsOptionals(t *testing.T) { t.Cleanup(srv.Close) w := newTestWorkspaceClient(t, srv.URL) - apiClient, err := client.New(w.Config) + apiClient, err := apiclient.New(w.Config) require.NoError(t, err) // attempt -1 (latest) and node 0 are the default request; from/to/page unset. _, err = getBricklensLogs(t.Context(), apiClient, nil, 7, bricklensLogsQuery{attemptNumber: -1, nodeIndex: 0}) diff --git a/cmd/air/logdetect.go b/cmd/air/logdetect.go index f804f4d5812..43e3342ac5e 100644 --- a/cmd/air/logdetect.go +++ b/cmd/air/logdetect.go @@ -1,6 +1,8 @@ package aircmd -import "regexp" +import ( + "regexp" +) // fatalPatterns match log lines that signal a run-ending failure (OOM, NCCL // timeouts, CUDA errors, segfaults, etc.). In --json mode a matching line emits diff --git a/cmd/air/logdownload.go b/cmd/air/logdownload.go index a0eeea33a05..ac8bde14c6b 100644 --- a/cmd/air/logdownload.go +++ b/cmd/air/logdownload.go @@ -11,10 +11,12 @@ import ( "slices" "sync" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" "golang.org/x/sync/errgroup" ) @@ -27,13 +29,13 @@ const downloadConcurrency = 8 var errNodeOutOfRange = errors.New("invalid --node") // resolveNodeCount returns how many nodes a run used. -func resolveNodeCount(run *jobs.Run) (int, error) { +func resolveNodeCount(run *jobs.GetRunResponse) (int, error) { accelType, count := jobCompute(run) if accelType == "" { - return 0, fmt.Errorf("run %d has no AI runtime compute config", run.RunId) + return 0, fmt.Errorf("run %d has no AI runtime compute config", utils.Deref(run.RunId)) } if count <= 0 { - return 0, fmt.Errorf("run %d reports %d accelerators", run.RunId, count) + return 0, fmt.Errorf("run %d reports %d accelerators", utils.Deref(run.RunId), count) } g, err := parseGPUType(accelType) if err != nil { @@ -46,7 +48,7 @@ func resolveNodeCount(run *jobs.Run) (int, error) { // Accelerators come in whole nodes, so a remainder means we can't map the // count onto node indices. if count%perNode != 0 { - return 0, fmt.Errorf("run %d reports %d %s accelerators, which is not a multiple of %d per node", run.RunId, count, accelType, perNode) + return 0, fmt.Errorf("run %d reports %d %s accelerators, which is not a multiple of %d per node", utils.Deref(run.RunId), count, accelType, perNode) } return count / perNode, nil } @@ -55,8 +57,8 @@ func resolveNodeCount(run *jobs.Run) (int, error) { // prints a summary. An explicit --node downloads only that node; otherwise all of // them. Logs come from MLflow artifacts, since Bricklens only streams. The // returned bool is the run's outcome, so the exit code matches the streaming path. -func downloadLogs(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer, req logRequest, status logRunStatus) (bool, error) { - run, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: req.runID}) +func downloadLogs(ctx context.Context, w *sdkclients.Clients, out io.Writer, req logRequest, status logRunStatus) (bool, error) { + run, err := getRun(ctx, w, req.runID) if err != nil { return false, err } @@ -136,7 +138,7 @@ func downloadLogs(ctx context.Context, w *databricks.WorkspaceClient, out io.Wri // node->path map for the nodes that had logs and a node->reason map for those // that failed; a truncated node appears in both. The log-dir layout is run-wide, // so it is probed once here rather than by every worker. -func downloadAllNodeLogs(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID, dir string, nodes []int, attempt int) (map[int]string, map[int]string, error) { +func downloadAllNodeLogs(ctx context.Context, w *sdkclients.Clients, mlflowRunID, dir string, nodes []int, attempt int) (map[int]string, map[int]string, error) { // -1 (latest) maps to attempt 0's directory, as on the streaming path. attemptDir := max(attempt, 0) withAttempt, err := discoverAttemptPrefix(ctx, w, mlflowRunID, attemptDir) @@ -158,7 +160,7 @@ func downloadAllNodeLogs(ctx context.Context, w *databricks.WorkspaceClient, mlf case err != nil: // One bad node shouldn't abort the rest. A truncated node // returns a path as well as an error, so keep both. - reasons[i] = err.Error() + reasons[i] = apierrs.ErrorString(err) paths[i] = path default: paths[i] = path @@ -189,7 +191,7 @@ func downloadAllNodeLogs(ctx context.Context, w *databricks.WorkspaceClient, mlf // error naming the gaps. The bytes are copied verbatim: a download should // reproduce the log exactly, so it must not round-trip through lines (which would // rewrite line endings and cap long lines). -func downloadNodeLog(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID string, node, attempt int, withAttempt bool, dir string) (string, error) { +func downloadNodeLog(ctx context.Context, w *sdkclients.Clients, mlflowRunID string, node, attempt int, withAttempt bool, dir string) (string, error) { logDir := constructLogPath(node, attempt, withAttempt) chunks, err := listLogChunks(ctx, w, mlflowRunID, logDir) if err != nil { @@ -249,7 +251,7 @@ func downloadNodeLog(ctx context.Context, w *databricks.WorkspaceClient, mlflowR // copyArtifactTo streams one artifact's bytes into dst and returns how many were // written. -func copyArtifactTo(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID, artifactPath string, dst io.Writer) (int64, error) { +func copyArtifactTo(ctx context.Context, w *sdkclients.Clients, mlflowRunID, artifactPath string, dst io.Writer) (int64, error) { local, err := downloadArtifact(ctx, w, mlflowRunID, artifactPath) if err != nil { return 0, err diff --git a/cmd/air/logdownload_test.go b/cmd/air/logdownload_test.go index 57b6982bddf..91d0554bde1 100644 --- a/cmd/air/logdownload_test.go +++ b/cmd/air/logdownload_test.go @@ -12,22 +12,22 @@ import ( "testing" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) // airRunWithCompute builds a run reporting the given accelerator type and count. -func airRunWithCompute(accelType string, count int) *jobs.Run { - return &jobs.Run{ - RunId: 123, +func airRunWithCompute(accelType string, count int) *jobs.GetRunResponse { + return &jobs.GetRunResponse{ + RunId: new(int64(123)), Tasks: []jobs.RunTask{{ - RunId: 456, + RunId: new(int64(456)), AiRuntimeTask: &jobs.AiRuntimeTask{ Deployments: []jobs.DeploymentSpec{{ - Compute: jobs.ComputeSpec{ - AcceleratorType: jobs.ComputeSpecAcceleratorType(accelType), - AcceleratorCount: count, + Compute: &jobs.ComputeSpec{ + AcceleratorType: jobs.ComputeSpec_AcceleratorType(accelType), + AcceleratorCount: new(count), }, }}, }, @@ -53,7 +53,7 @@ func TestResolveNodeCount(t *testing.T) { } // A run with no AI runtime compute errors. - _, err := resolveNodeCount(&jobs.Run{RunId: 1}) + _, err := resolveNodeCount(&jobs.GetRunResponse{RunId: new(int64(1))}) require.Error(t, err) // A count that isn't a whole number of nodes can't be mapped to node indices, diff --git a/cmd/air/logmlflow.go b/cmd/air/logmlflow.go index 90c5c0bd5c8..a0f0ef9b5ce 100644 --- a/cmd/air/logmlflow.go +++ b/cmd/air/logmlflow.go @@ -3,7 +3,6 @@ package aircmd import ( "bufio" "context" - "errors" "fmt" "io" "net" @@ -17,26 +16,26 @@ import ( "sync" "time" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/filer" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/listing" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/experiments/v1" + "github.com/databricks/cli/libs/utils" + sdkexperiments "github.com/databricks/sdk-go/experiments/v1" ) var mlflowArtifactRoots sync.Map -func mlflowArtifactRoot(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID string) (string, error) { +func mlflowArtifactRoot(ctx context.Context, w *sdkclients.Clients, mlflowRunID string) (string, error) { key := strings.TrimRight(w.Config.Host, "/") + "\x00" + mlflowRunID if cached, ok := mlflowArtifactRoots.Load(key); ok { return cached.(string), nil } - response, err := w.Experiments.GetRun(ctx, ml.GetRunRequest{RunId: mlflowRunID}) + response, err := w.Experiments.GetRun(ctx, sdkexperiments.GetRunRequest{RunId: new(mlflowRunID)}) if err != nil { log.Debugf(ctx, "air logs: could not resolve MLflow artifact URI for %s: %v", mlflowRunID, err) return "", nil @@ -44,7 +43,7 @@ func mlflowArtifactRoot(ctx context.Context, w *databricks.WorkspaceClient, mlfl if response.Run == nil || response.Run.Info == nil { return "", nil } - root := strings.TrimRight(response.Run.Info.ArtifactUri, "/") + root := strings.TrimRight(utils.Deref(response.Run.Info.ArtifactUri), "/") mlflowArtifactRoots.Store(key, root) return root, nil } @@ -82,7 +81,7 @@ var artifactDownloadClient = &http.Client{ // // The tail length is --tail, else the default cap. MLflow chunks are not // time-indexed, so --minutes cannot restrict the window here. -func mlflowLogFallback(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer, req logRequest, status logRunStatus) (bool, error) { +func mlflowLogFallback(ctx context.Context, w *sdkclients.Clients, out io.Writer, req logRequest, status logRunStatus) (bool, error) { if req.windowMinutes > 0 { cmdio.LogString(ctx, "Warning: --minutes is ignored when logs are served from MLflow artifacts.") } @@ -93,7 +92,7 @@ func mlflowLogFallback(ctx context.Context, w *databricks.WorkspaceClient, out i return fetchMLflowLogTail(ctx, w, out, req, status) } -func fetchMLflowLogTail(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer, req logRequest, status logRunStatus) (bool, error) { +func fetchMLflowLogTail(ctx context.Context, w *sdkclients.Clients, out io.Writer, req logRequest, status logRunStatus) (bool, error) { mlflowRunID, logDir, err := resolveMLflowLogPath(ctx, w, req) if err != nil { return false, err @@ -135,7 +134,7 @@ func fetchMLflowLogTail(ctx context.Context, w *databricks.WorkspaceClient, out return status.downloadOutcome(), nil } -func mlflowLogsExist(ctx context.Context, w *databricks.WorkspaceClient, req logRequest) bool { +func mlflowLogsExist(ctx context.Context, w *sdkclients.Clients, req logRequest) bool { mlflowRunID, logDir, err := resolveMLflowLogPath(ctx, w, req) if err != nil || mlflowRunID == "" || logDir == "" { if err != nil { @@ -151,7 +150,7 @@ func mlflowLogsExist(ctx context.Context, w *databricks.WorkspaceClient, req log return len(chunks) > 0 } -func streamMLflowLogs(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer, req logRequest, status logRunStatus) (bool, error) { +func streamMLflowLogs(ctx context.Context, w *sdkclients.Clients, out io.Writer, req logRequest, status logRunStatus) (bool, error) { lineOffsets := make(map[string]int) currentRunID := "" printed := false @@ -222,7 +221,7 @@ func streamMLflowLogs(ctx context.Context, w *databricks.WorkspaceClient, out io } refreshed, err := resolveRunStatus(ctx, w, req.runID) if err != nil { - if errors.Is(err, apierr.ErrResourceDoesNotExist) || ctx.Err() != nil { + if apierrs.Is(err, apierrs.ErrResourceDoesNotExist) || ctx.Err() != nil { return false, err } log.Debugf(ctx, "air logs: failed to refresh run status on MLflow fallback: %v", err) @@ -233,8 +232,8 @@ func streamMLflowLogs(ctx context.Context, w *databricks.WorkspaceClient, out io } // resolveMLflowLogPath returns the run's MLflow run id and per-node log directory. -func resolveMLflowLogPath(ctx context.Context, w *databricks.WorkspaceClient, req logRequest) (string, string, error) { - run, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: req.runID}) +func resolveMLflowLogPath(ctx context.Context, w *sdkclients.Clients, req logRequest) (string, string, error) { + run, err := getRun(ctx, w, req.runID) if err != nil { return "", "", err } @@ -258,7 +257,7 @@ func resolveMLflowLogPath(ctx context.Context, w *databricks.WorkspaceClient, re // attempt-prefixed (logs/attempt_X/node_Y) or old (logs/node_Y). A bare // logs/node_ means old; a logs/attempt_ entry means prefixed. // Defaults to old when nothing is listed. -func discoverAttemptPrefix(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID string, attempt int) (bool, error) { +func discoverAttemptPrefix(ctx context.Context, w *sdkclients.Clients, mlflowRunID string, attempt int) (bool, error) { files, err := listArtifacts(ctx, w, mlflowRunID, "logs") if err != nil { // Not fatal: default to the old layout; the chunk listing finds it empty if wrong. @@ -268,10 +267,10 @@ func discoverAttemptPrefix(ctx context.Context, w *databricks.WorkspaceClient, m attemptDir := fmt.Sprintf("logs/attempt_%d", attempt) for _, f := range files { - if oldFormatNodeDir.MatchString(f.Path) { + if oldFormatNodeDir.MatchString(utils.Deref(f.Path)) { return false, nil } - if f.Path == attemptDir { + if utils.Deref(f.Path) == attemptDir { return true, nil } } @@ -298,7 +297,7 @@ type logChunk struct { } // listLogChunks lists the chunk files under a log dir, sorted ascending by index. -func listLogChunks(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID, logDir string) ([]logChunk, error) { +func listLogChunks(ctx context.Context, w *sdkclients.Clients, mlflowRunID, logDir string) ([]logChunk, error) { files, err := listArtifacts(ctx, w, mlflowRunID, logDir) if err != nil { return nil, err @@ -306,7 +305,7 @@ func listLogChunks(ctx context.Context, w *databricks.WorkspaceClient, mlflowRun var chunks []logChunk for _, f := range files { - base := path.Base(f.Path) + base := path.Base(utils.Deref(f.Path)) m := chunkFilePattern.FindStringSubmatch(base) if m == nil { continue @@ -315,7 +314,7 @@ func listLogChunks(ctx context.Context, w *databricks.WorkspaceClient, mlflowRun if err != nil { continue } - chunks = append(chunks, logChunk{index: idx, path: f.Path}) + chunks = append(chunks, logChunk{index: idx, path: utils.Deref(f.Path)}) } slices.SortFunc(chunks, func(a, b logChunk) int { return a.index - b.index }) return chunks, nil @@ -324,7 +323,7 @@ func listLogChunks(ctx context.Context, w *databricks.WorkspaceClient, mlflowRun // tailChunks walks chunks newest-first, prepending each chunk's lines, until it // has `target` lines or runs out. A mid-walk download failure stops the walk // rather than splice non-adjacent chunks. -func tailChunks(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID string, chunks []logChunk, target int) ([]string, error) { +func tailChunks(ctx context.Context, w *sdkclients.Clients, mlflowRunID string, chunks []logChunk, target int) ([]string, error) { var accumulated []string for _, chunk := range slices.Backward(chunks) { lines, err := downloadChunkLines(ctx, w, mlflowRunID, chunk.path) @@ -346,12 +345,12 @@ type downloadedChunk struct { } // downloadChunkLines fetches one chunk artifact and returns its lines. -func downloadChunkLines(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID, artifactPath string) ([]string, error) { +func downloadChunkLines(ctx context.Context, w *sdkclients.Clients, mlflowRunID, artifactPath string) ([]string, error) { content, err := downloadChunk(ctx, w, mlflowRunID, artifactPath) return content.lines, err } -func downloadChunk(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID, artifactPath string) (downloadedChunk, error) { +func downloadChunk(ctx context.Context, w *sdkclients.Clients, mlflowRunID, artifactPath string) (downloadedChunk, error) { f, err := downloadArtifact(ctx, w, mlflowRunID, artifactPath) if err != nil { return downloadedChunk{}, err @@ -379,7 +378,7 @@ func downloadChunk(ctx context.Context, w *databricks.WorkspaceClient, mlflowRun } // listArtifacts lists a run's artifacts under a path. -func listArtifacts(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID, artifactPath string) ([]ml.FileInfo, error) { +func listArtifacts(ctx context.Context, w *sdkclients.Clients, mlflowRunID, artifactPath string) ([]experiments.FileInfo, error) { root, err := mlflowArtifactRoot(ctx, w, mlflowRunID) if err != nil { return nil, err @@ -393,22 +392,32 @@ func listArtifacts(ctx context.Context, w *databricks.WorkspaceClient, mlflowRun if err != nil { return nil, err } - files := make([]ml.FileInfo, 0, len(entries)) + files := make([]experiments.FileInfo, 0, len(entries)) for _, entry := range entries { - info := ml.FileInfo{Path: path.Join(artifactPath, entry.Name()), IsDir: entry.IsDir()} + info := experiments.FileInfo{Path: new(path.Join(artifactPath, entry.Name())), IsDir: new(entry.IsDir())} if !entry.IsDir() { stat, err := entry.Info() if err != nil { return nil, err } - info.FileSize = stat.Size() + info.FileSize = new(stat.Size()) } files = append(files, info) } return files, nil } - it := w.Experiments.ListArtifacts(ctx, ml.ListArtifactsRequest{RunId: mlflowRunID, Path: artifactPath}) - return listing.ToSlice(ctx, it) + var files []experiments.FileInfo + for f, err := range w.Experiments.ListArtifactsIter(ctx, sdkexperiments.ListArtifactsRequest{RunId: new(mlflowRunID), Path: new(artifactPath)}) { + if err != nil { + return nil, err + } + info, err := experiments.FileInfoFromSDK(f) + if err != nil { + return nil, err + } + files = append(files, *info) + } + return files, nil } // credentialInfo is one credentials-for-read entry: a pre-signed URL plus any @@ -428,7 +437,7 @@ type credentialsForReadResponse struct { // downloadArtifact downloads one run artifact to a temp file and returns its // path. credentials-for-read returns a pre-signed URL, which we stream to disk; // that endpoint is not modeled by the SDK, so it is called via a raw client.Do. -func downloadArtifact(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID, artifactPath string) (string, error) { +func downloadArtifact(ctx context.Context, w *sdkclients.Clients, mlflowRunID, artifactPath string) (string, error) { root, err := mlflowArtifactRoot(ctx, w, mlflowRunID) if err != nil { return "", err @@ -458,7 +467,7 @@ func downloadArtifact(ctx context.Context, w *databricks.WorkspaceClient, mlflow } return tmp.Name(), nil } - apiClient, err := client.New(w.Config) + apiClient, err := apiclient.New(w.Config) if err != nil { return "", fmt.Errorf("failed to create API client: %w", err) } diff --git a/cmd/air/logmlflow_test.go b/cmd/air/logmlflow_test.go index 0acb74dd592..0076f9ae1b5 100644 --- a/cmd/air/logmlflow_test.go +++ b/cmd/air/logmlflow_test.go @@ -15,18 +15,19 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/filer" "github.com/databricks/cli/libs/flags" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestResolveLogAttempt(t *testing.T) { - run := &jobs.Run{RunId: 5, Tasks: []jobs.RunTask{ - {RunId: 100, AttemptNumber: 0}, - {RunId: 101, AttemptNumber: 1}, - {RunId: 102, AttemptNumber: 2}, + run := &jobs.GetRunResponse{RunId: new(int64(5)), Tasks: []jobs.RunTask{ + {RunId: new(int64(100)), AttemptNumber: new(0)}, + {RunId: new(int64(101)), AttemptNumber: new(1)}, + {RunId: new(int64(102)), AttemptNumber: new(2)}, }} attempt, taskRunID, err := resolveLogAttempt(run, -1) @@ -278,7 +279,7 @@ func TestVolumeArtifactListAndDownload(t *testing.T) { }) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) fc, err := filer.NewFilesClient(t.Context(), w, "/Volumes/main/default/logs/root") require.NoError(t, err) diff --git a/cmd/air/logs.go b/cmd/air/logs.go index 9689e1e8a4a..1176a656f69 100644 --- a/cmd/air/logs.go +++ b/cmd/air/logs.go @@ -9,12 +9,12 @@ import ( "strconv" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" "github.com/spf13/cobra" ) @@ -147,13 +147,13 @@ func runLogs(ctx context.Context, cmd *cobra.Command, req logRequest) error { // Validate credentials server-side before fetching (MustWorkspaceClient only // attaches them), so a bad token fails clearly here. - if _, err := w.CurrentUser.Me(ctx, iam.MeRequest{}); err != nil { + if _, err := currentUserName(ctx, w); err != nil { return authError(ctx, cmd, err) } status, err := resolveRunStatus(ctx, w, req.runID) if err != nil { - if errors.Is(err, apierr.ErrResourceDoesNotExist) { + if apierrs.Is(err, apierrs.ErrResourceDoesNotExist) { return renderError(ctx, cmd, "NOT_FOUND", "NOT_FOUND", false, fmt.Errorf("run %d not found: check the run ID and that it is a job run ID", req.runID)) } @@ -191,7 +191,7 @@ func runLogs(ctx context.Context, cmd *cobra.Command, req logRequest) error { out := cmd.OutOrStdout() success, err := fetchLogs(ctx, w, out, req, status) if err != nil { - if errors.Is(err, apierr.ErrResourceDoesNotExist) { + if apierrs.Is(err, apierrs.ErrResourceDoesNotExist) { return renderError(ctx, cmd, "NOT_FOUND", "NOT_FOUND", false, fmt.Errorf("run %d not found: check the run ID and that it is a job run ID", req.runID)) } @@ -207,7 +207,7 @@ func runLogs(ctx context.Context, cmd *cobra.Command, req logRequest) error { return nil } -func resolveLogAttempt(run *jobs.Run, requested int) (int, int64, error) { +func resolveLogAttempt(run *jobs.GetRunResponse, requested int) (int, int64, error) { if requested < -1 { return 0, 0, fmt.Errorf("invalid retry %d: must be -1 or greater", requested) } @@ -223,16 +223,16 @@ func resolveLogAttempt(run *jobs.Run, requested int) (int, int64, error) { return 0, 0, fmt.Errorf("invalid retry %d: available retries are 0 to %d", requested, latest) } for _, v := range slices.Backward(run.Tasks) { - if v.AttemptNumber == attempt { - return attempt, v.RunId, nil + if utils.Deref(v.AttemptNumber) == attempt { + return attempt, utils.Deref(v.RunId), nil } } - return 0, 0, fmt.Errorf("run %d has no task for retry %d", run.RunId, attempt) + return 0, 0, fmt.Errorf("run %d has no task for retry %d", utils.Deref(run.RunId), attempt) } // fetchLogs serves logs from Bricklens, falling back to MLflow when Bricklens // returns errBricklensFeatureDisabled. -func fetchLogs(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer, req logRequest, status logRunStatus) (bool, error) { +func fetchLogs(ctx context.Context, w *sdkclients.Clients, out io.Writer, req logRequest, status logRunStatus) (bool, error) { if req.attempt < 0 && !status.terminal() && req.retryTracker == nil { req.retryTracker = newRetryTracker(status) } diff --git a/cmd/air/logs_test.go b/cmd/air/logs_test.go index 857339360f8..d3192c7c714 100644 --- a/cmd/air/logs_test.go +++ b/cmd/air/logs_test.go @@ -13,7 +13,6 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/experimental/mocks" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -40,8 +39,7 @@ func TestLogsCommandShape(t *testing.T) { // API call. func runLogsCmd(t *testing.T, args []string, flagsToSet map[string]string) error { t.Helper() - m := mocks.NewMockWorkspaceClient(t) - ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), m.WorkspaceClient) + ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), fakeWorkspace(t, nil)) cmd := withOutput(newLogsCommand(), flags.OutputText) for k, v := range flagsToSet { require.NoError(t, cmd.Flags().Set(k, v)) diff --git a/cmd/air/logstream.go b/cmd/air/logstream.go index 11c03d86d47..63604442547 100644 --- a/cmd/air/logstream.go +++ b/cmd/air/logstream.go @@ -10,13 +10,15 @@ import ( "strings" "time" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/apierr" ) const ( @@ -143,12 +145,12 @@ func newRetryTracker(status logRunStatus) *retryTracker { return &retryTracker{ lastReportedRetry: status.latestAttempt, lastObservedAttempt: status.latestAttempt, - lastObservedWaitingForRetry: status.latestTaskLifeCycleState == string(jobs.RunLifeCycleStateWaitingForRetry), + lastObservedWaitingForRetry: status.latestTaskLifeCycleState == string(jobs.RunLifeCycleState_RunLifeCycleState_WaitingForRetry), } } func (t *retryTracker) observe(status logRunStatus) (int, bool) { - waitingForRetry := status.latestTaskLifeCycleState == string(jobs.RunLifeCycleStateWaitingForRetry) + waitingForRetry := status.latestTaskLifeCycleState == string(jobs.RunLifeCycleState_RunLifeCycleState_WaitingForRetry) retry := 0 if status.latestAttempt > t.lastObservedAttempt { t.lastObservedAttempt = status.latestAttempt @@ -206,15 +208,15 @@ func (s logRunStatus) waitingForCompute() bool { if s.resultState != "" { return false } - if s.lifeCycleState == string(jobs.RunLifeCycleStatePending) { + if s.lifeCycleState == string(jobs.RunLifeCycleState_RunLifeCycleState_Pending) { return true } - if s.lifeCycleState != string(jobs.RunLifeCycleStateRunning) { + if s.lifeCycleState != string(jobs.RunLifeCycleState_RunLifeCycleState_Running) { return false } - switch jobs.RunLifeCycleState(s.latestTaskLifeCycleState) { - case jobs.RunLifeCycleStatePending, jobs.RunLifeCycleStateQueued, - jobs.RunLifeCycleStateWaitingForRetry, jobs.RunLifeCycleStateBlocked: + switch jobs.RunLifeCycleState_RunLifeCycleState(s.latestTaskLifeCycleState) { + case jobs.RunLifeCycleState_RunLifeCycleState_Pending, jobs.RunLifeCycleState_RunLifeCycleState_Queued, + jobs.RunLifeCycleState_RunLifeCycleState_WaitingForRetry, jobs.RunLifeCycleState_RunLifeCycleState_Blocked: return true default: return false @@ -229,9 +231,9 @@ func (s logRunStatus) downloadOutcome() bool { } // resolveRunStatus fetches a run's state and projects it onto logRunStatus. An -// unknown run id surfaces as apierr.ErrResourceDoesNotExist. -func resolveRunStatus(ctx context.Context, w *databricks.WorkspaceClient, runID int64) (logRunStatus, error) { - run, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: runID}) +// unknown run id surfaces as apierrs.ErrResourceDoesNotExist. +func resolveRunStatus(ctx context.Context, w *sdkclients.Clients, runID int64) (logRunStatus, error) { + run, err := getRun(ctx, w, runID) if err != nil { return logRunStatus{}, err } @@ -240,22 +242,22 @@ func resolveRunStatus(ctx context.Context, w *databricks.WorkspaceClient, runID // projectRunStatus extracts logRunStatus from a run. Split out so it can be // tested without an API client. -func projectRunStatus(run *jobs.Run) logRunStatus { +func projectRunStatus(run *jobs.GetRunResponse) logRunStatus { s := logRunStatus{ - startTimeMs: run.StartTime, - endTimeMs: run.EndTime, + startTimeMs: utils.Deref(run.StartTime), + endTimeMs: utils.Deref(run.EndTime), } if run.State != nil { s.lifeCycleState = string(run.State.LifeCycleState) s.resultState = string(run.State.ResultState) - s.stateMessage = run.State.StateMessage + s.stateMessage = utils.Deref(run.State.StateMessage) } for i := range run.Tasks { task := &run.Tasks[i] - if i > 0 && task.AttemptNumber <= s.latestAttempt { + if i > 0 && utils.Deref(task.AttemptNumber) <= s.latestAttempt { continue } - s.latestAttempt = task.AttemptNumber + s.latestAttempt = utils.Deref(task.AttemptNumber) s.latestTaskLifeCycleState = "" if task.State != nil { s.latestTaskLifeCycleState = string(task.State.LifeCycleState) @@ -271,15 +273,15 @@ func projectRunStatus(run *jobs.Run) logRunStatus { // - nil: a transient failure the caller should retry. func classifyLogError(err error) error { if apiErr, ok := errors.AsType[*apierr.APIError](err); ok { - switch apiErr.ErrorCode { + switch apierrs.ErrorCode(apiErr) { case "FEATURE_DISABLED", "ENDPOINT_NOT_FOUND": return errBricklensFeatureDisabled } - if apiErr.StatusCode == http.StatusNotFound { + if apiErr.HTTPStatusCode() == http.StatusNotFound { return errBricklensFeatureDisabled } } - if errors.Is(err, apierr.ErrResourceDoesNotExist) { + if apierrs.Is(err, apierrs.ErrResourceDoesNotExist) { return err } return nil @@ -312,9 +314,9 @@ func (req logRequest) toSeconds(status logRunStatus) int64 { // completed run, or a poll-and-drain loop that follows an active run to // completion. It returns whether the run finished with SUCCESS; // errBricklensFeatureDisabled means the caller should fall back to MLflow. -func streamBricklensLogs(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer, req logRequest, status logRunStatus) (bool, error) { +func streamBricklensLogs(ctx context.Context, w *sdkclients.Clients, out io.Writer, req logRequest, status logRunStatus) (bool, error) { // Build the API client once and reuse it for every page fetch in the loop. - apiClient, err := client.New(w.Config) + apiClient, err := apiclient.New(w.Config) if err != nil { return false, fmt.Errorf("failed to create API client: %w", err) } @@ -335,8 +337,8 @@ func streamBricklensLogs(ctx context.Context, w *databricks.WorkspaceClient, out // highest emitted timestamp, and the dedup set. type bricklensStreamer struct { ctx context.Context - w *databricks.WorkspaceClient - apiClient *client.DatabricksClient + w *sdkclients.Clients + apiClient *apiclient.Client headers map[string]string out io.Writer req logRequest @@ -375,12 +377,12 @@ func (st *bricklensStreamer) waitingSpinnerText() string { // output, re-resolved each call so a retry's new task run is picked up. // Best-effort: any fetch failure logs at debug and returns "". func (st *bricklensStreamer) serverStatusMessage() string { - run, err := st.w.Jobs.GetRun(st.ctx, jobs.GetRunRequest{RunId: st.req.runID}) + run, err := getRun(st.ctx, st.w, st.req.runID) if err != nil || len(run.Tasks) == 0 { return "" } taskRunID := run.Tasks[len(run.Tasks)-1].RunId - out, err := st.w.Jobs.GetRunOutputByRunId(st.ctx, taskRunID) + out, err := getRunOutput(st.ctx, st.w, utils.Deref(taskRunID)) if err != nil { log.Debugf(st.ctx, "air logs: status_message fetch failed for run %d: %v", st.req.runID, err) return "" @@ -388,7 +390,7 @@ func (st *bricklensStreamer) serverStatusMessage() string { if out.AiRuntimeTaskOutput == nil { return "" } - return normalizeStatusMessage(out.AiRuntimeTaskOutput.StatusMessage) + return normalizeStatusMessage(utils.Deref(out.AiRuntimeTaskOutput.StatusMessage)) } // reportStatusChange fires onStatusChange when the run's display state differs @@ -440,7 +442,7 @@ func (st *bricklensStreamer) run() (bool, error) { if !firstIteration { status, err := resolveRunStatus(st.ctx, st.w, st.req.runID) if err != nil { - if errors.Is(err, apierr.ErrResourceDoesNotExist) { + if apierrs.Is(err, apierrs.ErrResourceDoesNotExist) { return false, err } // A cancelled context (Ctrl-C) is not a transient blip: stop diff --git a/cmd/air/logstream_test.go b/cmd/air/logstream_test.go index 242a0b51b38..5948300dc20 100644 --- a/cmd/air/logstream_test.go +++ b/cmd/air/logstream_test.go @@ -12,15 +12,16 @@ import ( "testing" "time" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) +var runDoesNotExist = newAPIError(400, "RESOURCE_DOES_NOT_EXIST", "Run 7 does not exist.") + func TestClassifyLogError(t *testing.T) { tests := []struct { name string @@ -29,27 +30,27 @@ func TestClassifyLogError(t *testing.T) { }{ { name: "feature disabled falls back", - err: &apierr.APIError{ErrorCode: "FEATURE_DISABLED", StatusCode: http.StatusForbidden}, + err: newAPIError(http.StatusForbidden, "FEATURE_DISABLED", ""), want: errBricklensFeatureDisabled, }, { name: "endpoint not found falls back", - err: &apierr.APIError{ErrorCode: "ENDPOINT_NOT_FOUND", StatusCode: http.StatusNotFound}, + err: newAPIError(http.StatusNotFound, "ENDPOINT_NOT_FOUND", ""), want: errBricklensFeatureDisabled, }, { name: "bare 404 falls back", - err: &apierr.APIError{ErrorCode: "SOMETHING", StatusCode: http.StatusNotFound}, + err: newAPIError(http.StatusNotFound, "SOMETHING", ""), want: errBricklensFeatureDisabled, }, { name: "genuine resource-does-not-exist surfaces", - err: apierr.ErrResourceDoesNotExist, - want: apierr.ErrResourceDoesNotExist, + err: runDoesNotExist, + want: runDoesNotExist, }, { name: "transient 500 is retried", - err: &apierr.APIError{ErrorCode: "INTERNAL", StatusCode: http.StatusInternalServerError}, + err: newAPIError(http.StatusInternalServerError, "INTERNAL", ""), want: nil, }, { @@ -75,18 +76,18 @@ func TestClassifyLogError(t *testing.T) { } func TestProjectRunStatus(t *testing.T) { - run := &jobs.Run{ - StartTime: 1000, - EndTime: 2000, + run := &jobs.GetRunResponse{ + StartTime: new(int64(1000)), + EndTime: new(int64(2000)), State: &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateSuccess, - StateMessage: "done", + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Success, + StateMessage: new("done"), }, Tasks: []jobs.RunTask{ - {AttemptNumber: 0, State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateQueued}}, - {AttemptNumber: 2, State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateWaitingForRetry}}, - {AttemptNumber: 1}, + {AttemptNumber: new(0), State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Queued}}, + {AttemptNumber: new(2), State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_WaitingForRetry}}, + {AttemptNumber: new(1)}, }, } @@ -108,14 +109,14 @@ func TestRetryTrackerDeduplicatesWaitingAndAttemptIncrease(t *testing.T) { retry, ok := tracker.observe(logRunStatus{ latestAttempt: 0, - latestTaskLifeCycleState: string(jobs.RunLifeCycleStateWaitingForRetry), + latestTaskLifeCycleState: string(jobs.RunLifeCycleState_RunLifeCycleState_WaitingForRetry), }) assert.True(t, ok) assert.Equal(t, 1, retry) _, ok = tracker.observe(logRunStatus{ latestAttempt: 1, - latestTaskLifeCycleState: string(jobs.RunLifeCycleStateWaitingForRetry), + latestTaskLifeCycleState: string(jobs.RunLifeCycleState_RunLifeCycleState_WaitingForRetry), }) assert.False(t, ok) } @@ -124,7 +125,7 @@ func TestRetryTrackerDetectsAttemptCreatedInWaitingState(t *testing.T) { tracker := newRetryTracker(logRunStatus{latestAttempt: 0}) waiting := logRunStatus{ latestAttempt: 1, - latestTaskLifeCycleState: string(jobs.RunLifeCycleStateWaitingForRetry), + latestTaskLifeCycleState: string(jobs.RunLifeCycleState_RunLifeCycleState_WaitingForRetry), } retry, ok := tracker.observe(waiting) @@ -152,7 +153,7 @@ func TestReportRetryText(t *testing.T) { req.reportRetry(ctx, &stdout, logRunStatus{ latestAttempt: 0, - latestTaskLifeCycleState: string(jobs.RunLifeCycleStateWaitingForRetry), + latestTaskLifeCycleState: string(jobs.RunLifeCycleState_RunLifeCycleState_WaitingForRetry), }, func() { stopped = true }) assert.True(t, stopped) @@ -240,7 +241,7 @@ func TestDrainPagesDedupAndOrdering(t *testing.T) { var buf bytes.Buffer w := newTestWorkspaceClient(t, srv.URL) - apiClient, err := client.New(w.Config) + apiClient, err := apiclient.New(w.Config) require.NoError(t, err) st := &bricklensStreamer{ ctx: t.Context(), @@ -288,7 +289,7 @@ func TestDrainPagesEmitsLateRecordsWithinLookback(t *testing.T) { var buf bytes.Buffer w := newTestWorkspaceClient(t, srv.URL) - apiClient, err := client.New(w.Config) + apiClient, err := apiclient.New(w.Config) require.NoError(t, err) st := &bricklensStreamer{ ctx: t.Context(), @@ -581,7 +582,7 @@ func TestRequestPageRetriesThenFallsBack(t *testing.T) { t.Cleanup(srv.Close) w := newTestWorkspaceClient(t, srv.URL) - apiClient, err := client.New(w.Config) + apiClient, err := apiclient.New(w.Config) require.NoError(t, err) st := &bricklensStreamer{ ctx: t.Context(), @@ -618,7 +619,7 @@ func TestRequestPageRetriesThenSucceeds(t *testing.T) { t.Cleanup(srv.Close) wc := newTestWorkspaceClient(t, srv.URL) - apiClient, err := client.New(wc.Config) + apiClient, err := apiclient.New(wc.Config) require.NoError(t, err) st := &bricklensStreamer{ ctx: t.Context(), diff --git a/cmd/air/mlflow.go b/cmd/air/mlflow.go index 5434142a3c8..3ce6374765b 100644 --- a/cmd/air/mlflow.go +++ b/cmd/air/mlflow.go @@ -6,9 +6,10 @@ import ( "strings" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + sdkexperiments "github.com/databricks/sdk-go/experiments/v1" ) // mlflowIdentifiers are the experiment and run IDs MLflow assigns to a run. @@ -19,31 +20,31 @@ type mlflowIdentifiers struct { // mlflowIDs fetches the MLflow IDs for a run via its latest task. Returns nil if // they can't be obtained. -func mlflowIDs(ctx context.Context, w *databricks.WorkspaceClient, run *jobs.Run) *mlflowIdentifiers { +func mlflowIDs(ctx context.Context, w *sdkclients.Clients, run *jobs.GetRunResponse) *mlflowIdentifiers { return mlflowIDsFromOutput(aiRuntimeTaskOutput(ctx, w, run)) } -func aiRuntimeTaskOutput(ctx context.Context, w *databricks.WorkspaceClient, run *jobs.Run) *jobs.AiRuntimeTaskOutput { +func aiRuntimeTaskOutput(ctx context.Context, w *sdkclients.Clients, run *jobs.GetRunResponse) *jobs.AiRuntimeTaskOutput { if len(run.Tasks) == 0 { return nil } - return aiRuntimeTaskOutputForTask(ctx, w, run.Tasks[len(run.Tasks)-1].RunId) + return aiRuntimeTaskOutputForTask(ctx, w, utils.Deref(run.Tasks[len(run.Tasks)-1].RunId)) } // mlflowIDsForTask fetches a task run's MLflow experiment and run IDs from // runs/get-output, or nil if they can't be obtained. They drive a convenience // link, so any failure (endpoint error, run not yet started, no MLflow output) // is logged and treated as "no link" rather than failing the command. -func mlflowIDsForTask(ctx context.Context, w *databricks.WorkspaceClient, taskRunID int64) *mlflowIdentifiers { +func mlflowIDsForTask(ctx context.Context, w *sdkclients.Clients, taskRunID int64) *mlflowIdentifiers { return mlflowIDsFromOutput(aiRuntimeTaskOutputForTask(ctx, w, taskRunID)) } -func aiRuntimeTaskOutputForTask(ctx context.Context, w *databricks.WorkspaceClient, taskRunID int64) *jobs.AiRuntimeTaskOutput { +func aiRuntimeTaskOutputForTask(ctx context.Context, w *sdkclients.Clients, taskRunID int64) *jobs.AiRuntimeTaskOutput { if taskRunID == 0 { return nil } - out, err := w.Jobs.GetRunOutputByRunId(ctx, taskRunID) + out, err := getRunOutput(ctx, w, taskRunID) if err != nil { log.Debugf(ctx, "air: could not fetch run output for MLflow link: %v", err) return nil @@ -53,10 +54,10 @@ func aiRuntimeTaskOutputForTask(ctx context.Context, w *databricks.WorkspaceClie } func mlflowIDsFromOutput(output *jobs.AiRuntimeTaskOutput) *mlflowIdentifiers { - if output == nil || output.MlflowExperimentId == "" || output.MlflowRunId == "" { + if output == nil || utils.Deref(output.MlflowExperimentId) == "" || utils.Deref(output.MlflowRunId) == "" { return nil } - return &mlflowIdentifiers{ExperimentID: output.MlflowExperimentId, RunID: output.MlflowRunId} + return &mlflowIdentifiers{ExperimentID: utils.Deref(output.MlflowExperimentId), RunID: utils.Deref(output.MlflowRunId)} } // mlflowLogsURL is the deep link to a run's node-0 logs. It is the value of the @@ -82,8 +83,8 @@ func mlflowExperimentURL(host string, ids *mlflowIdentifiers) string { // fetchMLflowRunName fetches a run's MLflow run_name via the MLflow REST API, // returning "" if it can't be obtained. Best-effort, like the rest of the MLflow // enrichment. -func fetchMLflowRunName(ctx context.Context, w *databricks.WorkspaceClient, mlflowRunID string) string { - resp, err := w.Experiments.GetRun(ctx, ml.GetRunRequest{RunId: mlflowRunID}) +func fetchMLflowRunName(ctx context.Context, w *sdkclients.Clients, mlflowRunID string) string { + resp, err := w.Experiments.GetRun(ctx, sdkexperiments.GetRunRequest{RunId: new(mlflowRunID)}) if err != nil { log.Debugf(ctx, "air get: could not fetch MLflow run name: %v", err) return "" @@ -91,7 +92,7 @@ func fetchMLflowRunName(ctx context.Context, w *databricks.WorkspaceClient, mlfl if resp.Run == nil || resp.Run.Info == nil { return "" } - return resp.Run.Info.RunName + return utils.Deref(resp.Run.Info.RunName) } // mlflowRunLabel is the text shown for the MLflow Run cell: the run's name, or diff --git a/cmd/air/mlflow_test.go b/cmd/air/mlflow_test.go index a3dd5376298..51d66f35990 100644 --- a/cmd/air/mlflow_test.go +++ b/cmd/air/mlflow_test.go @@ -5,18 +5,21 @@ import ( "net/http/httptest" "testing" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) // newTestWorkspaceClient builds a WorkspaceClient pointed at a mock HTTP server, // so the SDK calls these tests exercise are served locally. -func newTestWorkspaceClient(t *testing.T, host string) *databricks.WorkspaceClient { +func newTestWorkspaceClient(t *testing.T, host string) *sdkclients.Clients { t.Helper() - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: host, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: host, Token: "token"}) require.NoError(t, err) + authenticate(t, w) return w } @@ -38,7 +41,7 @@ func runOutputServer(t *testing.T, body string, hit *bool) *httptest.Server { func TestMLflowIDs(t *testing.T) { ctx := t.Context() - run := &jobs.Run{Tasks: []jobs.RunTask{{RunId: 99}}} + run := &jobs.GetRunResponse{Tasks: []jobs.RunTask{{RunId: new(int64(99))}}} t.Run("returns the identifiers on success", func(t *testing.T) { var hit bool @@ -58,7 +61,7 @@ func TestMLflowIDs(t *testing.T) { t.Run("nil when the run has no tasks", func(t *testing.T) { // Returns before any HTTP call, so the host is never contacted. - assert.Nil(t, mlflowIDs(ctx, newTestWorkspaceClient(t, "https://unused.invalid"), &jobs.Run{})) + assert.Nil(t, mlflowIDs(ctx, newTestWorkspaceClient(t, "https://unused.invalid"), &jobs.GetRunResponse{})) }) t.Run("uses the latest attempt's task run", func(t *testing.T) { @@ -72,7 +75,7 @@ func TestMLflowIDs(t *testing.T) { })) t.Cleanup(srv.Close) - retried := &jobs.Run{Tasks: []jobs.RunTask{{RunId: 99}, {RunId: 100}}} + retried := &jobs.GetRunResponse{Tasks: []jobs.RunTask{{RunId: new(int64(99))}, {RunId: new(int64(100))}}} mlflowIDs(ctx, newTestWorkspaceClient(t, srv.URL), retried) assert.Equal(t, "100", gotRunID) }) @@ -81,12 +84,12 @@ func TestMLflowIDs(t *testing.T) { func TestAiRuntimeTaskOutput(t *testing.T) { var hit bool srv := runOutputServer(t, `{"ai_runtime_task_output":{"status_message":"STATUS: Waiting for GPU capacity"}}`, &hit) - run := &jobs.Run{Tasks: []jobs.RunTask{{RunId: 99}}} + run := &jobs.GetRunResponse{Tasks: []jobs.RunTask{{RunId: new(int64(99))}}} got := aiRuntimeTaskOutput(t.Context(), newTestWorkspaceClient(t, srv.URL), run) require.NotNil(t, got) assert.True(t, hit) - assert.Equal(t, "STATUS: Waiting for GPU capacity", got.StatusMessage) + assert.Equal(t, "STATUS: Waiting for GPU capacity", utils.Deref(got.StatusMessage)) } func TestMLflowIDsForTask(t *testing.T) { @@ -148,3 +151,12 @@ func TestFetchMLflowRunName(t *testing.T) { assert.Empty(t, fetchMLflowRunName(ctx, newTestWorkspaceClient(t, srv.URL), "run1")) }) } + +// authenticate resolves the clients' credentials, as the CLI's root command +// does before running a command. +func authenticate(t *testing.T, w *sdkclients.Clients) { + t.Helper() + req, err := http.NewRequestWithContext(t.Context(), http.MethodGet, w.Config.Host, nil) + require.NoError(t, err) + require.NoError(t, w.Config.Authenticate(req)) +} diff --git a/cmd/air/output.go b/cmd/air/output.go index c00d870e386..2cf665d1d2c 100644 --- a/cmd/air/output.go +++ b/cmd/air/output.go @@ -5,6 +5,7 @@ import ( "time" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" "github.com/spf13/cobra" @@ -72,7 +73,7 @@ func renderError(ctx context.Context, cmd *cobra.Command, code, kind string, ret Error: jsonError{ Code: code, Kind: kind, - Message: err.Error(), + Message: apierrs.ErrorString(err), Retryable: retryable, }, }); rerr != nil { diff --git a/cmd/air/pools.go b/cmd/air/pools.go index c6bf6c7d9cb..da2a21f6558 100644 --- a/cmd/air/pools.go +++ b/cmd/air/pools.go @@ -11,12 +11,13 @@ import ( "strings" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/sdk-go/core/apierr" "github.com/spf13/cobra" ) @@ -120,11 +121,11 @@ func poolAPIError(ctx context.Context, cmd *cobra.Command, action string, err er // where it is not yet rolled out. That is a permanent state for the // workspace, not a retryable failure — and its explicit error code is more // specific than the generic 403 it may arrive as, so check it first. - if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.ErrorCode == "FEATURE_DISABLED" { + if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apierrs.ErrorCode(apiErr) == "FEATURE_DISABLED" { return renderError(ctx, cmd, "FEATURE_DISABLED", "PERMANENT", false, errors.New("the GPU pools API is not enabled for this workspace")) } - if errors.Is(err, apierr.ErrUnauthenticated) || errors.Is(err, apierr.ErrPermissionDenied) { + if apierrs.Is(err, apierrs.ErrUnauthenticated) || apierrs.Is(err, apierrs.ErrPermissionDenied) { return authError(ctx, cmd, err) } return renderError(ctx, cmd, "INTERNAL_ERROR", "TRANSIENT", true, @@ -132,8 +133,8 @@ func poolAPIError(ctx context.Context, cmd *cobra.Command, action string, err er } // listPools pages the list endpoint fully. -func listPools(ctx context.Context, w *databricks.WorkspaceClient) ([]provisionedCapacity, error) { - apiClient, err := client.New(w.Config) +func listPools(ctx context.Context, w *sdkclients.Clients) ([]provisionedCapacity, error) { + apiClient, err := apiclient.New(w.Config) if err != nil { return nil, fmt.Errorf("failed to create API client: %w", err) } @@ -163,8 +164,8 @@ func listPools(ctx context.Context, w *databricks.WorkspaceClient) ([]provisione } // getPool fetches one pool, including its usage summary. -func getPool(ctx context.Context, w *databricks.WorkspaceClient, id string) (*provisionedCapacity, error) { - apiClient, err := client.New(w.Config) +func getPool(ctx context.Context, w *sdkclients.Clients, id string) (*provisionedCapacity, error) { + apiClient, err := apiclient.New(w.Config) if err != nil { return nil, fmt.Errorf("failed to create API client: %w", err) } @@ -272,7 +273,7 @@ func newGetPoolCommand() *cobra.Command { pool, err := getPool(ctx, w, id) if err != nil { // ErrNotFound covers a plain 404 as well as RESOURCE_DOES_NOT_EXIST. - if errors.Is(err, apierr.ErrNotFound) { + if apierrs.Is(err, apierrs.ErrNotFound) { return renderError(ctx, cmd, "NOT_FOUND", "NOT_FOUND", false, fmt.Errorf("GPU pool %q not found: check the id with `air pools list`", id)) } @@ -293,7 +294,7 @@ func newGetPoolCommand() *cobra.Command { // resolveSolePoolID returns the id of the workspace's only pool, for `air pools // get` with no argument. It errors (with the ids to choose from) when there is // not exactly one, so the convenience never silently picks among several. -func resolveSolePoolID(ctx context.Context, cmd *cobra.Command, w *databricks.WorkspaceClient) (string, error) { +func resolveSolePoolID(ctx context.Context, cmd *cobra.Command, w *sdkclients.Clients) (string, error) { pools, err := listPools(ctx, w) if err != nil { return "", poolAPIError(ctx, cmd, "list GPU pools", err) diff --git a/cmd/air/pools_test.go b/cmd/air/pools_test.go index 0062c48f61a..b709fc906e1 100644 --- a/cmd/air/pools_test.go +++ b/cmd/air/pools_test.go @@ -339,7 +339,7 @@ func TestGetPoolNotFoundJSON(t *testing.T) { func TestGetPoolPlain404(t *testing.T) { // A bare HTTP 404 (no RESOURCE_DOES_NOT_EXIST error code) must still map to - // NOT_FOUND, since apierr.ErrNotFound covers any 404. + // NOT_FOUND, since apierrs.ErrNotFound covers any 404. srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotFound) _, _ = w.Write([]byte(`{"message":"no such thing"}`)) diff --git a/cmd/air/render.go b/cmd/air/render.go index f7a96f27b26..f45ee059ee8 100644 --- a/cmd/air/render.go +++ b/cmd/air/render.go @@ -9,12 +9,13 @@ import ( "strings" "github.com/charmbracelet/lipgloss" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" "github.com/muesli/termenv" "go.yaml.in/yaml/v3" ) @@ -92,7 +93,7 @@ type runView struct { // completed progress bar, and a field list, separated by blank lines. It is a // one-shot renderer — it builds the full string and writes it once, with no // streaming, spinner, or redraw. -func renderRunText(ctx context.Context, out io.Writer, w *databricks.WorkspaceClient, run *jobs.Run, data *getData, ids *mlflowIdentifiers) { +func renderRunText(ctx context.Context, out io.Writer, w *sdkclients.Clients, run *jobs.GetRunResponse, data *getData, ids *mlflowIdentifiers) { // cmdio.NewRenderer sets the Ascii color profile when color is off, which // emits no SGR codes; combined with the link fallback below this gives clean, // un-escaped output under --no-color / NO_COLOR / piped stdout. @@ -102,7 +103,7 @@ func renderRunText(ctx context.Context, out io.Writer, w *databricks.WorkspaceCl // The serverless environment version lives on the run's environments[].spec, // which the typed SDK Run drops, so read it with a raw request. Empty (a run // with no serverless environment) stays "N/A". - data.EnvironmentDisplay = orNA(aiRuntimeEnvironmentVersion(ctx, w, run.RunId)) + data.EnvironmentDisplay = orNA(aiRuntimeEnvironmentVersion(ctx, w, utils.Deref(run.RunId))) view := runView{ runID: data.RunID, @@ -156,7 +157,7 @@ func renderRunText(ctx context.Context, out io.Writer, w *databricks.WorkspaceCl } // genAIComputeTask returns the run's first GenAI-compute task, or nil. -func genAIComputeTask(run *jobs.Run) *jobs.GenAiComputeTask { +func genAIComputeTask(run *jobs.GetRunResponse) *jobs.GenAiComputeTask { if len(run.Tasks) == 0 { return nil } @@ -168,8 +169,8 @@ func genAIComputeTask(run *jobs.Run) *jobs.GenAiComputeTask { // environments[] entry keyed by aiRuntimeEnvironmentKey. The typed SDK Run has // no environments field, so the value is fetched with a raw request. Best-effort: // returns "" (logged) on any error or when the run declares no environment. -func aiRuntimeEnvironmentVersion(ctx context.Context, w *databricks.WorkspaceClient, runID int64) string { - apiClient, err := client.New(w.Config) +func aiRuntimeEnvironmentVersion(ctx context.Context, w *sdkclients.Clients, runID int64) string { + apiClient, err := apiclient.New(w.Config) if err != nil { log.Warnf(ctx, "air get: could not create client to read environment: %v", err) return "" @@ -199,7 +200,7 @@ func aiRuntimeEnvironmentVersion(ctx context.Context, w *databricks.WorkspaceCli // resolveConfigYAML returns the config box body: from the downloaded config file // when we have its path, else from the legacy task. -func resolveConfigYAML(ctx context.Context, w *databricks.WorkspaceClient, run *jobs.Run, data *getData) string { +func resolveConfigYAML(ctx context.Context, w *sdkclients.Clients, run *jobs.GetRunResponse, data *getData) string { if data.TrainingConfigPath != "" { if raw := downloadConfig(ctx, w, data.TrainingConfigPath); len(raw) > 0 { return strings.TrimRight(reformatYAMLForDisplay(raw), "\n") @@ -215,12 +216,12 @@ func resolveConfigYAML(ctx context.Context, w *databricks.WorkspaceClient, run * // full config (including the command/script) lives in the run's parameters, not // the structured task fields, so we prefer the inline parameters, then the // parameters file, and only synthesize a minimal config as a last resort. -func configYAML(ctx context.Context, w *databricks.WorkspaceClient, task *jobs.GenAiComputeTask) string { - if task.YamlParameters != "" { - return strings.TrimRight(reformatYAMLForDisplay([]byte(task.YamlParameters)), "\n") +func configYAML(ctx context.Context, w *sdkclients.Clients, task *jobs.GenAiComputeTask) string { + if utils.Deref(task.YamlParameters) != "" { + return strings.TrimRight(reformatYAMLForDisplay([]byte(*task.YamlParameters)), "\n") } - if task.YamlParametersFilePath != "" { - if raw := downloadConfig(ctx, w, task.YamlParametersFilePath); len(raw) > 0 { + if utils.Deref(task.YamlParametersFilePath) != "" { + if raw := downloadConfig(ctx, w, utils.Deref(task.YamlParametersFilePath)); len(raw) > 0 { return strings.TrimRight(reformatYAMLForDisplay(raw), "\n") } } @@ -229,7 +230,7 @@ func configYAML(ctx context.Context, w *databricks.WorkspaceClient, task *jobs.G // downloadConfig fetches the run's training-config file, returning nil on // failure (logged as a warning). Best-effort, like the rest of the enrichment. -func downloadConfig(ctx context.Context, w *databricks.WorkspaceClient, path string) []byte { +func downloadConfig(ctx context.Context, w *sdkclients.Clients, path string) []byte { r, err := w.Workspace.Download(ctx, path) if err != nil { log.Warnf(ctx, "air get: could not download training config %s: %v", path, err) @@ -260,13 +261,13 @@ type configCompute struct { // omits the command, which is only available in the run parameters. func synthConfigYAML(task *jobs.GenAiComputeTask) string { cfg := configBox{} - if task.MlflowExperimentName != "" { - cfg.ExperimentName = stripExperimentUserPrefix(task.MlflowExperimentName) + if utils.Deref(task.MlflowExperimentName) != "" { + cfg.ExperimentName = stripExperimentUserPrefix(utils.Deref(task.MlflowExperimentName)) } - if task.Compute != nil && task.Compute.NumGpus > 0 { + if task.Compute != nil && utils.Deref(task.Compute.NumGpus) > 0 { cfg.Compute = &configCompute{ - AcceleratorType: task.Compute.GpuType, - NumAccelerators: task.Compute.NumGpus, + AcceleratorType: utils.Deref(task.Compute.GpuType), + NumAccelerators: utils.Deref(task.Compute.NumGpus), } } if cfg.ExperimentName == "" && cfg.Compute == nil { diff --git a/cmd/air/render_test.go b/cmd/air/render_test.go index 66e5b09deb7..fc2dd7370e1 100644 --- a/cmd/air/render_test.go +++ b/cmd/air/render_test.go @@ -2,16 +2,16 @@ package aircmd import ( "io" + "net/http" "strings" "testing" "github.com/charmbracelet/lipgloss" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/muesli/termenv" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" ) // asciiPalette returns a palette whose styles emit no escape codes, so render @@ -21,14 +21,25 @@ func asciiPalette(t *testing.T) palette { return newPalette(r) } +// exportServer serves the workspace export of a single file. +func exportServer(t *testing.T, path, content string) *sdkclients.Clients { + t.Helper() + return fakeWorkspace(t, map[string]http.HandlerFunc{ + "GET /api/2.0/workspace/export": func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, path, r.URL.Query().Get("path")) + _, _ = w.Write([]byte(content)) + }, + }) +} + func TestConfigYAML(t *testing.T) { ctx := t.Context() t.Run("inline parameters include the command as a block literal", func(t *testing.T) { task := &jobs.GenAiComputeTask{ - YamlParameters: "experiment_name: my-exp\ncompute:\n accelerator_type: a10\n num_accelerators: 1\ncommand: \"for i in $(seq 1 3); do echo $i; done\\n\"\n", + YamlParameters: new("experiment_name: my-exp\ncompute:\n accelerator_type: a10\n num_accelerators: 1\ncommand: \"for i in $(seq 1 3); do echo $i; done\\n\"\n"), } - got := configYAML(ctx, mocks.NewMockWorkspaceClient(t).WorkspaceClient, task) + got := configYAML(ctx, fakeWorkspace(t, nil), task) assert.Contains(t, got, "experiment_name: my-exp") assert.Contains(t, got, "accelerator_type: a10") assert.Contains(t, got, "command: |") @@ -36,20 +47,17 @@ func TestConfigYAML(t *testing.T) { }) t.Run("downloads the parameters file when there are no inline parameters", func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockWorkspaceAPI().EXPECT(). - Download(mock.Anything, "/Workspace/cfg.yaml"). - Return(io.NopCloser(strings.NewReader("experiment_name: from-file\n")), nil) - task := &jobs.GenAiComputeTask{YamlParametersFilePath: "/Workspace/cfg.yaml"} - assert.Equal(t, "experiment_name: from-file", configYAML(ctx, m.WorkspaceClient, task)) + w := exportServer(t, "/Workspace/cfg.yaml", "experiment_name: from-file\n") + task := &jobs.GenAiComputeTask{YamlParametersFilePath: new("/Workspace/cfg.yaml")} + assert.Equal(t, "experiment_name: from-file", configYAML(ctx, w, task)) }) t.Run("falls back to a synthesized config", func(t *testing.T) { task := &jobs.GenAiComputeTask{ - MlflowExperimentName: "/Users/me@example.com/exp", - Compute: &jobs.ComputeConfig{GpuType: "a10", NumGpus: 1}, + MlflowExperimentName: new("/Users/me@example.com/exp"), + Compute: &jobs.ComputeConfig{GpuType: new("a10"), NumGpus: new(1)}, } - got := configYAML(ctx, mocks.NewMockWorkspaceClient(t).WorkspaceClient, task) + got := configYAML(ctx, fakeWorkspace(t, nil), task) assert.Contains(t, got, "experiment_name: exp") assert.NotContains(t, got, "command") }) @@ -59,33 +67,30 @@ func TestResolveConfigYAML(t *testing.T) { ctx := t.Context() t.Run("downloads the training config path for new runs", func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockWorkspaceAPI().EXPECT(). - Download(mock.Anything, "/Workspace/run/training_config.yaml"). - Return(io.NopCloser(strings.NewReader("experiment_name: from-air\n")), nil) - run := &jobs.Run{Tasks: []jobs.RunTask{{}}} + w := exportServer(t, "/Workspace/run/training_config.yaml", "experiment_name: from-air\n") + run := &jobs.GetRunResponse{Tasks: []jobs.RunTask{{}}} data := &getData{TrainingConfigPath: "/Workspace/run/training_config.yaml"} - assert.Equal(t, "experiment_name: from-air", resolveConfigYAML(ctx, m.WorkspaceClient, run, data)) + assert.Equal(t, "experiment_name: from-air", resolveConfigYAML(ctx, w, run, data)) }) t.Run("falls back to the legacy task when no path is set", func(t *testing.T) { - run := &jobs.Run{Tasks: []jobs.RunTask{{GenAiComputeTask: &jobs.GenAiComputeTask{ - MlflowExperimentName: "/Users/me@example.com/exp", + run := &jobs.GetRunResponse{Tasks: []jobs.RunTask{{GenAiComputeTask: &jobs.GenAiComputeTask{ + MlflowExperimentName: new("/Users/me@example.com/exp"), }}}} - got := resolveConfigYAML(ctx, mocks.NewMockWorkspaceClient(t).WorkspaceClient, run, &getData{}) + got := resolveConfigYAML(ctx, fakeWorkspace(t, nil), run, &getData{}) assert.Contains(t, got, "experiment_name: exp") }) t.Run("empty when neither source is present", func(t *testing.T) { - run := &jobs.Run{Tasks: []jobs.RunTask{{}}} - assert.Empty(t, resolveConfigYAML(ctx, mocks.NewMockWorkspaceClient(t).WorkspaceClient, run, &getData{})) + run := &jobs.GetRunResponse{Tasks: []jobs.RunTask{{}}} + assert.Empty(t, resolveConfigYAML(ctx, fakeWorkspace(t, nil), run, &getData{})) }) } func TestSynthConfigYAML(t *testing.T) { task := &jobs.GenAiComputeTask{ - MlflowExperimentName: "/Users/me@example.com/stream-latency-test", - Compute: &jobs.ComputeConfig{GpuType: "a10", NumGpus: 1}, + MlflowExperimentName: new("/Users/me@example.com/stream-latency-test"), + Compute: &jobs.ComputeConfig{GpuType: new("a10"), NumGpus: new(1)}, } // The accelerator_type uses the raw GPU type; the command is omitted because // it lives only in the run parameters. diff --git a/cmd/air/run.go b/cmd/air/run.go index c8027b09e9a..ecf2968fa84 100644 --- a/cmd/air/run.go +++ b/cmd/air/run.go @@ -16,8 +16,8 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/shellquote" - "github.com/databricks/databricks-sdk-go" "github.com/spf13/cobra" ) @@ -362,7 +362,7 @@ func printLogsDivider(ctx context.Context, out io.Writer) { // watchTerminalStatus resolves a watched run's final display state for the // closing --watch envelope. The run is terminal once streaming returns; if the // status can't be re-fetched, "UNKNOWN" is reported rather than guessing. -func watchTerminalStatus(ctx context.Context, w *databricks.WorkspaceClient, runID int64) string { +func watchTerminalStatus(ctx context.Context, w *sdkclients.Clients, runID int64) string { status, err := resolveRunStatus(ctx, w, runID) if err != nil { return "UNKNOWN" diff --git a/cmd/air/runconfig_test.go b/cmd/air/runconfig_test.go index 798d23a6b5f..5920a0d450e 100644 --- a/cmd/air/runconfig_test.go +++ b/cmd/air/runconfig_test.go @@ -167,7 +167,7 @@ containers: - name: inference command: python infer.py ranks: [0, 1] - unity_catalog_image: main.ml.inference:v1 + unity_catalog_image: main.experiments.inference:v1 environment_variables: variables: MODEL_NAME: llama @@ -175,7 +175,7 @@ containers: - name: dataproc command: python dataproc.py ranks: [2, 3] - unity_catalog_image: main.ml.dataproc:v2 + unity_catalog_image: main.experiments.dataproc:v2 `)) require.NoError(t, err) require.Nil(t, cfg.Command) @@ -201,11 +201,11 @@ containers: - name: first command: echo first ranks: [0] - unity_catalog_image: main.ml.first:v1 + unity_catalog_image: main.experiments.first:v1 - name: second command: echo second ranks: [%s] - unity_catalog_image: main.ml.second:v1 + unity_catalog_image: main.experiments.second:v1 ` for _, tc := range []struct { name string diff --git a/cmd/air/runlaunch.go b/cmd/air/runlaunch.go index c914a949216..72d6e7bbb14 100644 --- a/cmd/air/runlaunch.go +++ b/cmd/air/runlaunch.go @@ -2,16 +2,14 @@ package aircmd import ( "context" - "errors" "fmt" "path" "strings" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/env" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/workspaceapi" "github.com/google/uuid" ) @@ -20,16 +18,16 @@ import ( const userWorkspaceDirEnv = "DATABRICKS_INTERNAL_USER_WORKSPACE_DIR" // currentUserEmail returns the authenticated user's email (works for any domain). -func currentUserEmail(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { - me, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) +func currentUserEmail(ctx context.Context, w *sdkclients.Clients) (string, error) { + me, err := currentUserName(ctx, w) if err != nil { return "", fmt.Errorf("failed to resolve current user: %w", err) } - return me.UserName, nil + return me, nil } // userWorkspaceDir returns the user's workspace home, honoring the env override. -func userWorkspaceDir(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { +func userWorkspaceDir(ctx context.Context, w *sdkclients.Clients) (string, error) { if override := env.Get(ctx, userWorkspaceDirEnv); override != "" { return override, nil } @@ -59,7 +57,7 @@ func cliLaunchDir(base, experiment, run string) string { // prospectiveLaunchPaths returns the workspace paths a submission would use // without creating directories or uploading artifacts. -func prospectiveLaunchPaths(ctx context.Context, w *databricks.WorkspaceClient, cfg *runConfig) (string, string, string, error) { +func prospectiveLaunchPaths(ctx context.Context, w *sdkclients.Clients, cfg *runConfig) (string, string, string, error) { base, err := userWorkspaceDir(ctx, w) if err != nil { return "", "", "", err @@ -76,19 +74,19 @@ func prospectiveLaunchPaths(ctx context.Context, w *databricks.WorkspaceClient, // CLI's convention for its other artifact directories. Without this, a missing // parent surfaces only as a server-side INTERNAL_ERROR after the run is wasted. // An empty dir means the default (/Users//...), which always exists. -func ensureExperimentDirectory(ctx context.Context, w *databricks.WorkspaceClient, experimentDir string) error { +func ensureExperimentDirectory(ctx context.Context, w *sdkclients.Clients, experimentDir string) error { if experimentDir == "" { return nil } info, err := w.Workspace.GetStatusByPath(ctx, experimentDir) - if errors.Is(err, apierr.ErrNotFound) { + if apierrs.Is(err, apierrs.ErrNotFound) { return w.Workspace.MkdirsByPath(ctx, experimentDir) } if err != nil { return fmt.Errorf("failed to check experiment_directory %q: %w", experimentDir, err) } - if info.ObjectType != workspace.ObjectTypeDirectory { + if info.ObjectType != workspaceapi.ObjectTypeDirectory { return fmt.Errorf("experiment_directory %q is not a directory (object_type=%s)", experimentDir, info.ObjectType) } return nil diff --git a/cmd/air/runlaunch_test.go b/cmd/air/runlaunch_test.go index 7654e544964..6737015816c 100644 --- a/cmd/air/runlaunch_test.go +++ b/cmd/air/runlaunch_test.go @@ -7,8 +7,9 @@ import ( "testing" "github.com/databricks/cli/libs/filer" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -22,11 +23,11 @@ func TestCliLaunchDir(t *testing.T) { assert.NotEqual(t, dir, cliLaunchDir("/Workspace/Users/me@example.com", "my-exp", "")) } -func newFakeWorkspaceClient(t *testing.T) *databricks.WorkspaceClient { +func newFakeWorkspaceClient(t *testing.T) *sdkclients.Clients { server := testserver.New(t) t.Cleanup(server.Close) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) return w } diff --git a/cmd/air/runpermissions.go b/cmd/air/runpermissions.go index b26ff33df43..972df06c092 100644 --- a/cmd/air/runpermissions.go +++ b/cmd/air/runpermissions.go @@ -8,10 +8,10 @@ import ( "time" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" ) const ( @@ -25,36 +25,46 @@ const ( mlflowPermissionPollInterval = 100 * time.Millisecond ) +// permissionLevelCanManage is missing from the sdk-go PermissionLevel enum, +// although the Permissions API accepts it. +const permissionLevelCanManage accessmanagement.PermissionLevel = "CAN_MANAGE" + // permissionAccessControl builds an ACL entry for a validated permission grant. -func permissionAccessControl(p permission) iam.AccessControlRequest { - acl := iam.AccessControlRequest{PermissionLevel: iam.PermissionLevel(p.Level)} - switch { - case p.UserName != nil: - acl.UserName = *p.UserName - case p.GroupName != nil: - acl.GroupName = *p.GroupName - case p.ServicePrincipalName != nil: - acl.ServicePrincipalName = *p.ServicePrincipalName - } - return acl +func permissionAccessControl(p permission) accessmanagement.AccessControlRequest { + return accessmanagement.AccessControlRequest{ + PermissionLevel: accessmanagement.PermissionLevel(p.Level), + UserName: p.UserName, + GroupName: p.GroupName, + ServicePrincipalName: p.ServicePrincipalName, + } +} + +// updateObjectPermissions adds acl to the permissions of the given object. +func updateObjectPermissions(ctx context.Context, w *sdkclients.Clients, objectType, objectID string, acl []accessmanagement.AccessControlRequest) error { + req, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&accessmanagement.UpdateObjectPermissionsRequest{ + RequestObjectType: new(objectType), + RequestObjectId: new(objectID), + AccessControlList: acl, + }) + if err != nil { + return err + } + _, err = w.AccessManagement.UpdateObjectPermissions(ctx, *req) + return err } // grantJobPermissions adds the configured ACLs to a job. -func grantJobPermissions(ctx context.Context, w *databricks.WorkspaceClient, jobID string, permissions []permission) error { +func grantJobPermissions(ctx context.Context, w *sdkclients.Clients, jobID string, permissions []permission) error { if len(permissions) == 0 { return nil } - jobACL := make([]iam.AccessControlRequest, 0, len(permissions)) + jobACL := make([]accessmanagement.AccessControlRequest, 0, len(permissions)) for _, p := range permissions { jobACL = append(jobACL, permissionAccessControl(p)) } - _, err := w.Permissions.Update(ctx, iam.UpdateObjectPermissions{ - RequestObjectType: "jobs", - RequestObjectId: jobID, - AccessControlList: jobACL, - }) + err := updateObjectPermissions(ctx, w, "jobs", jobID, jobACL) if err != nil { return fmt.Errorf("failed to grant job permissions: %w", err) } @@ -65,14 +75,14 @@ func grantJobPermissions(ctx context.Context, w *databricks.WorkspaceClient, job // experiment permission level. Experiments only support CAN_READ/CAN_EDIT/ // CAN_MANAGE, so the job-oriented levels fold onto those. ok is false when the // level has no experiment equivalent and the grant should be skipped. -func experimentPermissionLevel(level string) (ml.ExperimentPermissionLevel, bool) { - switch iam.PermissionLevel(level) { - case iam.PermissionLevelCanView: - return ml.ExperimentPermissionLevelCanRead, true - case iam.PermissionLevelCanManageRun: - return ml.ExperimentPermissionLevelCanEdit, true - case iam.PermissionLevelCanManage, iam.PermissionLevelIsOwner: - return ml.ExperimentPermissionLevelCanManage, true +func experimentPermissionLevel(level string) (accessmanagement.PermissionLevel, bool) { + switch accessmanagement.PermissionLevel(level) { + case accessmanagement.PermissionLevel_CanView: + return accessmanagement.PermissionLevel_CanRead, true + case accessmanagement.PermissionLevel_CanManageRun: + return accessmanagement.PermissionLevel_CanEdit, true + case permissionLevelCanManage, accessmanagement.PermissionLevel_IsOwner: + return permissionLevelCanManage, true default: return "", false } @@ -80,20 +90,13 @@ func experimentPermissionLevel(level string) (ml.ExperimentPermissionLevel, bool // experimentAccessControl builds an experiment ACL entry from a validated grant. // ok is false when the grant's level has no experiment equivalent. -func experimentAccessControl(p permission) (ml.ExperimentAccessControlRequest, bool) { +func experimentAccessControl(p permission) (accessmanagement.AccessControlRequest, bool) { level, ok := experimentPermissionLevel(p.Level) if !ok { - return ml.ExperimentAccessControlRequest{}, false - } - acl := ml.ExperimentAccessControlRequest{PermissionLevel: level} - switch { - case p.UserName != nil: - acl.UserName = *p.UserName - case p.GroupName != nil: - acl.GroupName = *p.GroupName - case p.ServicePrincipalName != nil: - acl.ServicePrincipalName = *p.ServicePrincipalName + return accessmanagement.AccessControlRequest{}, false } + acl := permissionAccessControl(p) + acl.PermissionLevel = level return acl, true } @@ -103,12 +106,12 @@ func experimentAccessControl(p permission) (ml.ExperimentAccessControlRequest, b // unlike resolving a bare experiment name, which would have to guess the owning // directory (and has no default for a service principal). Returns "" if the id // doesn't become available in time. -func resolveSubmittedExperimentID(ctx context.Context, w *databricks.WorkspaceClient, run *jobs.Run) string { +func resolveSubmittedExperimentID(ctx context.Context, w *sdkclients.Clients, run *jobs.GetRunResponse) string { ticker := time.NewTicker(mlflowPermissionPollInterval) defer ticker.Stop() for { - if out := aiRuntimeTaskOutput(ctx, w, run); out != nil && out.MlflowExperimentId != "" { - return out.MlflowExperimentId + if out := aiRuntimeTaskOutput(ctx, w, run); out != nil && utils.Deref(out.MlflowExperimentId) != "" { + return utils.Deref(out.MlflowExperimentId) } select { @@ -123,8 +126,8 @@ func resolveSubmittedExperimentID(ctx context.Context, w *databricks.WorkspaceCl // configured ACLs to it. Unlike jobs, whose permissions are set remotely, the // experiment is created by the AI Runtime backend so its ACLs must be set here // from the client. -func grantExperimentPermissions(ctx context.Context, w *databricks.WorkspaceClient, run *jobs.Run, permissions []permission) error { - experimentACL := make([]ml.ExperimentAccessControlRequest, 0, len(permissions)) +func grantExperimentPermissions(ctx context.Context, w *sdkclients.Clients, run *jobs.GetRunResponse, permissions []permission) error { + experimentACL := make([]accessmanagement.AccessControlRequest, 0, len(permissions)) for _, p := range permissions { if acl, ok := experimentAccessControl(p); ok { experimentACL = append(experimentACL, acl) @@ -144,10 +147,7 @@ func grantExperimentPermissions(ctx context.Context, w *databricks.WorkspaceClie return errors.New("could not resolve the run's MLflow experiment") } - _, err := w.Experiments.UpdatePermissions(ctx, ml.ExperimentPermissionsRequest{ - ExperimentId: experimentID, - AccessControlList: experimentACL, - }) + err := updateObjectPermissions(ctx, w, "experiments", experimentID, experimentACL) if err != nil { return fmt.Errorf("failed to grant experiment permissions: %w", err) } @@ -158,7 +158,7 @@ func grantExperimentPermissions(ctx context.Context, w *databricks.WorkspaceClie // result has been shown, wrapping the bounded best-effort grant in a spinner so // it never silently delays the success line. showProgress gates the spinner // (text mode only). -func grantSubmittedPermissions(ctx context.Context, w *databricks.WorkspaceClient, runID int64, permissions []permission, showProgress bool) { +func grantSubmittedPermissions(ctx context.Context, w *sdkclients.Clients, runID int64, permissions []permission, showProgress bool) { if len(permissions) == 0 { return } @@ -170,19 +170,19 @@ func grantSubmittedPermissions(ctx context.Context, w *databricks.WorkspaceClien // applySubmittedPermissions resolves the submitted run and grants its configured // ACLs on both the job (remotely) and the MLflow experiment (client-side). -func applySubmittedPermissions(ctx context.Context, w *databricks.WorkspaceClient, runID int64, permissions []permission) { +func applySubmittedPermissions(ctx context.Context, w *sdkclients.Clients, runID int64, permissions []permission) { if len(permissions) == 0 { return } - run, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: runID}) + run, err := getRun(ctx, w, runID) if err != nil { log.Warnf(ctx, "failed to grant permissions on workload: %v", err) log.Warnf(ctx, "job was created successfully, but permissions could not be granted") return } - if err := grantJobPermissions(ctx, w, strconv.FormatInt(run.JobId, 10), permissions); err != nil { + if err := grantJobPermissions(ctx, w, strconv.FormatInt(utils.Deref(run.JobId), 10), permissions); err != nil { log.Warnf(ctx, "failed to grant permissions on workload: %v", err) log.Warnf(ctx, "job was created successfully, but permissions could not be granted") } diff --git a/cmd/air/runpermissions_test.go b/cmd/air/runpermissions_test.go index 891b830c9ca..b288a8d4cb1 100644 --- a/cmd/air/runpermissions_test.go +++ b/cmd/air/runpermissions_test.go @@ -5,10 +5,11 @@ import ( "testing" "time" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -23,7 +24,7 @@ func TestGrantJobPermissions(t *testing.T) { return map[string]any{} }) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) err = grantJobPermissions(t.Context(), w, "123", []permission{ {UserName: new("alice@example.com"), Level: "CAN_MANAGE"}, @@ -33,6 +34,8 @@ func TestGrantJobPermissions(t *testing.T) { require.NoError(t, err) assert.JSONEq(t, `{ + "request_object_type": "jobs", + "request_object_id": "123", "access_control_list": [ {"user_name": "alice@example.com", "permission_level": "CAN_MANAGE"}, {"group_name": "data-team", "permission_level": "CAN_VIEW"}, @@ -44,13 +47,13 @@ func TestGrantJobPermissions(t *testing.T) { func TestExperimentPermissionLevel(t *testing.T) { cases := []struct { job string - want ml.ExperimentPermissionLevel + want accessmanagement.PermissionLevel ok bool }{ - {"CAN_VIEW", ml.ExperimentPermissionLevelCanRead, true}, - {"CAN_MANAGE_RUN", ml.ExperimentPermissionLevelCanEdit, true}, - {"CAN_MANAGE", ml.ExperimentPermissionLevelCanManage, true}, - {"IS_OWNER", ml.ExperimentPermissionLevelCanManage, true}, + {"CAN_VIEW", accessmanagement.PermissionLevel_CanRead, true}, + {"CAN_MANAGE_RUN", accessmanagement.PermissionLevel_CanEdit, true}, + {"CAN_MANAGE", permissionLevelCanManage, true}, + {"IS_OWNER", permissionLevelCanManage, true}, {"CAN_ATTACH_TO", "", false}, } for _, tc := range cases { @@ -76,9 +79,9 @@ func TestGrantExperimentPermissions(t *testing.T) { return map[string]any{} }) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) - run := &jobs.Run{Tasks: []jobs.RunTask{{RunId: 456, AiRuntimeTask: &jobs.AiRuntimeTask{Experiment: "submit-smoke"}}}} + run := &jobs.GetRunResponse{Tasks: []jobs.RunTask{{RunId: new(int64(456)), AiRuntimeTask: &jobs.AiRuntimeTask{Experiment: new("submit-smoke")}}}} err = grantExperimentPermissions(t.Context(), w, run, []permission{ {UserName: new("alice@example.com"), Level: "CAN_MANAGE"}, {GroupName: new("data-team"), Level: "CAN_VIEW"}, @@ -88,6 +91,8 @@ func TestGrantExperimentPermissions(t *testing.T) { // Job levels are mapped onto their nearest experiment equivalents. assert.JSONEq(t, `{ + "request_object_type": "experiments", + "request_object_id": "42", "access_control_list": [ {"user_name": "alice@example.com", "permission_level": "CAN_MANAGE"}, {"group_name": "data-team", "permission_level": "CAN_READ"}, @@ -105,13 +110,13 @@ func TestResolveSubmittedExperimentIDTimesOut(t *testing.T) { return map[string]any{} }) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) // An already-expired context gives up on the first miss without polling. ctx, cancel := context.WithTimeout(t.Context(), time.Nanosecond) defer cancel() - run := &jobs.Run{Tasks: []jobs.RunTask{{RunId: 456}}} + run := &jobs.GetRunResponse{Tasks: []jobs.RunTask{{RunId: new(int64(456))}}} assert.Empty(t, resolveSubmittedExperimentID(ctx, w, run)) } @@ -145,12 +150,12 @@ func TestApplySubmittedPermissionsAiRuntimeTask(t *testing.T) { return map[string]any{} }) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) applySubmittedPermissions(t.Context(), w, 555, []permission{ {UserName: new("alice@example.com"), Level: "CAN_MANAGE"}, }) - assert.JSONEq(t, `{"access_control_list":[{"user_name":"alice@example.com","permission_level":"CAN_MANAGE"}]}`, jobBody) - assert.JSONEq(t, `{"access_control_list":[{"user_name":"alice@example.com","permission_level":"CAN_MANAGE"}]}`, experimentBody) + assert.JSONEq(t, `{"request_object_type":"jobs","request_object_id":"123","access_control_list":[{"user_name":"alice@example.com","permission_level":"CAN_MANAGE"}]}`, jobBody) + assert.JSONEq(t, `{"request_object_type":"experiments","request_object_id":"42","access_control_list":[{"user_name":"alice@example.com","permission_level":"CAN_MANAGE"}]}`, experimentBody) } diff --git a/cmd/air/runsubmit.go b/cmd/air/runsubmit.go index dfc847fcb52..288e54d459e 100644 --- a/cmd/air/runsubmit.go +++ b/cmd/air/runsubmit.go @@ -12,14 +12,14 @@ import ( "strings" "time" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/filer" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" "github.com/google/uuid" "golang.org/x/sync/errgroup" ) @@ -46,12 +46,12 @@ func dlRuntimeImage(ctx context.Context, runtimeVersion string) string { return strings.TrimPrefix(img, "CLIENT-GPU-") } -func buildRunEnvironment(dlImage string, deps []string) *compute.Environment { - environment := &compute.Environment{} +func buildRunEnvironment(dlImage string, deps []string) *jobs.Environment { + environment := &jobs.Environment{} if strings.HasPrefix(dlImage, databricksAIPrefix) { - environment.BaseEnvironment = "workspace-base-environments/" + dlImage + environment.BaseEnvironment = utils.NonZero("workspace-base-environments/" + dlImage) } else { - environment.EnvironmentVersion = dlImage + environment.EnvironmentVersion = utils.NonZero(dlImage) } if len(deps) > 0 { environment.Dependencies = deps @@ -70,43 +70,42 @@ func buildRunEnvironment(dlImage string, deps []string) *compute.Environment { // omitempty so the wire form matches the Python CLI (which never emits a bare // "false"). Jobs performs the retries — each attempt is a fresh AI Runtime // workload. -func buildSubmitPayload(cfg *runConfig, commandPath, dlImage, usagePolicyID string, snap snapshotResult, deps []string) jobs.SubmitRun { +func buildSubmitPayload(cfg *runConfig, commandPath, dlImage, usagePolicyID string, snap snapshotResult, deps []string) jobs.SubmitRunRequest { deployment := jobs.DeploymentSpec{ - Compute: jobs.ComputeSpec{ - AcceleratorType: jobs.ComputeSpecAcceleratorType(cfg.Compute.AcceleratorType), - AcceleratorCount: cfg.Compute.NumAccelerators, + Compute: &jobs.ComputeSpec{ + AcceleratorType: jobs.ComputeSpec_AcceleratorType(cfg.Compute.AcceleratorType), + AcceleratorCount: utils.NonZero(cfg.Compute.NumAccelerators), }, } if len(cfg.Containers) == 0 { - deployment.CommandPath = commandPath + deployment.CommandPath = utils.NonZero(commandPath) } task := jobs.AiRuntimeTask{ - Experiment: cfg.ExperimentName, + Experiment: utils.NonZero(cfg.ExperimentName), Deployments: []jobs.DeploymentSpec{deployment}, - CodeSourcePath: snap.CodeSourcePath, + CodeSourcePath: utils.NonZero(snap.CodeSourcePath), } if cfg.MLflowRunName != nil { - task.MlflowRun = *cfg.MLflowRunName + task.MlflowRun = utils.NonZero(*cfg.MLflowRunName) } if cfg.MLflowExperimentDirectory != nil { - task.MlflowExperimentDirectory = *cfg.MLflowExperimentDirectory + task.MlflowExperimentDirectory = utils.NonZero(*cfg.MLflowExperimentDirectory) } if cfg.MLflowArtifactLocation != nil { - task.MlflowArtifactLocation = *cfg.MLflowArtifactLocation + task.MlflowArtifactLocation = utils.NonZero(*cfg.MLflowArtifactLocation) } maxRetries := cfg.maxRetries() - st := jobs.SubmitTask{ - TaskKey: cfg.ExperimentName, - RunIf: jobs.RunIfAllSuccess, + st := jobs.RunTaskSettings{ + TaskKey: utils.NonZero(cfg.ExperimentName), + RunIf: jobs.TaskDependencyType_AllSuccess, AiRuntimeTask: &task, - EnvironmentKey: aiRuntimeEnvironmentKey, - MaxRetries: maxRetries, + EnvironmentKey: utils.NonZero(aiRuntimeEnvironmentKey), + MaxRetries: new(maxRetries), // retry_on_timeout only makes sense when retries are allowed; otherwise // omit it (matches Python's native path, which sets retry_on_timeout only // under the same > 0 gate). - RetryOnTimeout: maxRetries > 0, - ForceSendFields: []string{"MaxRetries"}, + RetryOnTimeout: utils.NonZero(maxRetries > 0), } // Carry the user's declared deps inline on spec.dependencies; the AI Runtime @@ -114,15 +113,15 @@ func buildSubmitPayload(cfg *runConfig, commandPath, dlImage, usagePolicyID stri // slices, so a no-deps run omits the key. envSpec := buildRunEnvironment(dlImage, deps) - return jobs.SubmitRun{ - RunName: cfg.ExperimentName, + return jobs.SubmitRunRequest{ + RunName: utils.NonZero(cfg.ExperimentName), // budget_policy_id matches what the Python CLI and `ssh connect` send; // usage_policy_id is the newer alias for the same thing on SubmitRun. - BudgetPolicyId: usagePolicyID, - TimeoutSeconds: cfg.timeoutSeconds(), - Tasks: []jobs.SubmitTask{st}, + BudgetPolicyId: utils.NonZero(usagePolicyID), + TimeoutSeconds: utils.NonZero(cfg.timeoutSeconds()), + Tasks: []jobs.RunTaskSettings{st}, Environments: []jobs.JobEnvironment{{ - EnvironmentKey: aiRuntimeEnvironmentKey, + EnvironmentKey: utils.NonZero(aiRuntimeEnvironmentKey), Spec: envSpec, }}, } @@ -135,17 +134,21 @@ type submittedContainer struct { UnityCatalogImagePath string } -func submitRun(ctx context.Context, w *databricks.WorkspaceClient, payload jobs.SubmitRun, poolID, priorityClass, unityCatalogImagePath string, containers []submittedContainer) (int64, error) { +func submitRun(ctx context.Context, w *sdkclients.Clients, payload jobs.SubmitRunRequest, poolID, priorityClass, unityCatalogImagePath string, containers []submittedContainer) (int64, error) { // None of these fields are modeled by the SDK's AiRuntimeTask, so a run that // sets any of them has to go through the raw /api/2.2 body. priority_class only // ever appears alongside a pool (validation enforces it), but route on // all of them so none can be silently dropped. if poolID == "" && priorityClass == "" && unityCatalogImagePath == "" && len(containers) == 0 { - wait, err := w.Jobs.Submit(ctx, payload) + req, err := jobs.SubmitRunRequestToSDK(&payload) if err != nil { return 0, err } - return wait.RunId, nil + wait, err := w.Jobs.SubmitRun(ctx, *req) + if err != nil { + return 0, err + } + return wait.GetRunId(), nil } raw, err := json.Marshal(payload) @@ -174,7 +177,7 @@ func submitRun(ctx context.Context, w *databricks.WorkspaceClient, payload jobs. } } - apiClient, err := client.New(w.Config) + apiClient, err := apiclient.New(w.Config) if err != nil { return 0, fmt.Errorf("failed to create API client: %w", err) } @@ -183,7 +186,7 @@ func submitRun(ctx context.Context, w *databricks.WorkspaceClient, payload jobs. if err != nil { return 0, err } - return response.RunId, nil + return utils.Deref(response.RunId), nil } func injectContainers(body map[string]any, containers []submittedContainer) error { @@ -331,7 +334,7 @@ func stageRunArtifacts(ctx context.Context, launchWriter fileWriter, items []upl // upload the launch artifacts, assemble the Jobs payload, and submit it. It // returns the new run_id and its dashboard URL. showProgress enables the stderr // staging spinner (text mode only). -func submitWorkload(ctx context.Context, w *databricks.WorkspaceClient, cfg *runConfig, configPath, idempotencyKey string, showProgress bool) (runID int64, dashboardURL string, err error) { +func submitWorkload(ctx context.Context, w *sdkclients.Clients, cfg *runConfig, configPath, idempotencyKey string, showProgress bool) (runID int64, dashboardURL string, err error) { start := time.Now() var snap snapshotResult defer func() { logRunEvent(ctx, cfg, snap, runID, time.Since(start), err) }() @@ -414,7 +417,7 @@ func submitWorkload(ctx context.Context, w *databricks.WorkspaceClient, cfg *run runtimeVersion, _ := cfg.runtimeVersion() payload := buildSubmitPayload(cfg, commandPath, dlRuntimeImage(ctx, runtimeVersion), usagePolicyID, snap, deps) - payload.IdempotencyToken = token + payload.IdempotencyToken = utils.NonZero(token) // The pool id is sent on the wire as provisioned_capacity_id (the backend's // name for a GPU pool); only the user-facing YAML field is pool_id. diff --git a/cmd/air/runsubmit_test.go b/cmd/air/runsubmit_test.go index 5c5a2e7f23a..5ede8de9d07 100644 --- a/cmd/air/runsubmit_test.go +++ b/cmd/air/runsubmit_test.go @@ -15,9 +15,11 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/filer" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -64,35 +66,35 @@ func TestBuildSubmitPayload(t *testing.T) { p := buildSubmitPayload(cfg, "/d/command.sh", "5", "", snapshotResult{}, nil) - assert.Equal(t, "exp", p.RunName) - assert.Equal(t, 1800, p.TimeoutSeconds) + assert.Equal(t, "exp", utils.Deref(p.RunName)) + assert.Equal(t, 1800, utils.Deref(p.TimeoutSeconds)) // No policy configured: the field stays empty and is omitted from the wire form. assert.Empty(t, p.BudgetPolicyId) require.Len(t, p.Environments, 1) - assert.Equal(t, aiRuntimeEnvironmentKey, p.Environments[0].EnvironmentKey) + assert.Equal(t, aiRuntimeEnvironmentKey, utils.Deref(p.Environments[0].EnvironmentKey)) require.NotNil(t, p.Environments[0].Spec) - assert.Equal(t, "5", p.Environments[0].Spec.EnvironmentVersion) + assert.Equal(t, "5", utils.Deref(p.Environments[0].Spec.EnvironmentVersion)) environmentJSON, err := json.Marshal(p.Environments[0].Spec) require.NoError(t, err) assert.JSONEq(t, `{"environment_version":"5"}`, string(environmentJSON)) require.Len(t, p.Tasks, 1) task := p.Tasks[0] - assert.Equal(t, "exp", task.TaskKey) - assert.Equal(t, jobs.RunIfAllSuccess, task.RunIf) - assert.Equal(t, aiRuntimeEnvironmentKey, task.EnvironmentKey) - assert.Equal(t, 2, task.MaxRetries) - assert.True(t, task.RetryOnTimeout) + assert.Equal(t, "exp", utils.Deref(task.TaskKey)) + assert.Equal(t, jobs.TaskDependencyType_AllSuccess, task.RunIf) + assert.Equal(t, aiRuntimeEnvironmentKey, utils.Deref(task.EnvironmentKey)) + assert.Equal(t, 2, utils.Deref(task.MaxRetries)) + assert.True(t, utils.Deref(task.RetryOnTimeout)) at := task.AiRuntimeTask require.NotNil(t, at) - assert.Equal(t, "exp", at.Experiment) - assert.Equal(t, "run-v2", at.MlflowRun) - assert.Equal(t, "/Workspace/Users/me/exp", at.MlflowExperimentDirectory) - assert.Equal(t, "dbfs:/Volumes/main/default/artifacts", at.MlflowArtifactLocation) + assert.Equal(t, "exp", utils.Deref(at.Experiment)) + assert.Equal(t, "run-v2", utils.Deref(at.MlflowRun)) + assert.Equal(t, "/Workspace/Users/me/exp", utils.Deref(at.MlflowExperimentDirectory)) + assert.Equal(t, "dbfs:/Volumes/main/default/artifacts", utils.Deref(at.MlflowArtifactLocation)) require.Len(t, at.Deployments, 1) - assert.Equal(t, "/d/command.sh", at.Deployments[0].CommandPath) - assert.Equal(t, jobs.ComputeSpec{AcceleratorType: jobs.ComputeSpecAcceleratorTypeGpu8xH100, AcceleratorCount: 16}, at.Deployments[0].Compute) + assert.Equal(t, "/d/command.sh", utils.Deref(at.Deployments[0].CommandPath)) + assert.Equal(t, &jobs.ComputeSpec{AcceleratorType: jobs.ComputeSpec_AcceleratorType_Gpu8xH100, AcceleratorCount: new(16)}, at.Deployments[0].Compute) } func TestBuildSubmitPayloadB300(t *testing.T) { @@ -105,12 +107,12 @@ func TestBuildSubmitPayloadB300(t *testing.T) { p := buildSubmitPayload(cfg, "/d/command.sh", "databricks_ai_v6", "", snapshotResult{}, nil) require.Len(t, p.Environments, 1) require.NotNil(t, p.Environments[0].Spec) - assert.Equal(t, "workspace-base-environments/databricks_ai_v6", p.Environments[0].Spec.BaseEnvironment) + assert.Equal(t, "workspace-base-environments/databricks_ai_v6", utils.Deref(p.Environments[0].Spec.BaseEnvironment)) assert.Empty(t, p.Environments[0].Spec.EnvironmentVersion) require.Len(t, p.Tasks, 1) require.NotNil(t, p.Tasks[0].AiRuntimeTask) require.Len(t, p.Tasks[0].AiRuntimeTask.Deployments, 1) - assert.Equal(t, jobs.ComputeSpec{AcceleratorType: jobs.ComputeSpecAcceleratorType("GPU_8xB300"), AcceleratorCount: 8}, p.Tasks[0].AiRuntimeTask.Deployments[0].Compute) + assert.Equal(t, &jobs.ComputeSpec{AcceleratorType: jobs.ComputeSpec_AcceleratorType("GPU_8xB300"), AcceleratorCount: new(8)}, p.Tasks[0].AiRuntimeTask.Deployments[0].Compute) } func TestSubmitRun(t *testing.T) { @@ -163,10 +165,10 @@ func TestSubmitRun(t *testing.T) { } else { assert.Equal(t, tc.poolID, compute["provisioned_capacity_id"]) } - return jobs.SubmitRunResponse{RunId: 42} + return jobs.SubmitRunResponse{RunId: new(int64(42))} }) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token", WorkspaceID: "123"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token", WorkspaceID: "123"}) require.NoError(t, err) payload := buildSubmitPayload(&runConfig{ ExperimentName: "exp", @@ -174,7 +176,7 @@ func TestSubmitRun(t *testing.T) { Compute: &computeConfig{AcceleratorType: "GPU_1xH100", NumAccelerators: 1}, MaxRetries: new(0), }, "/command.sh", "4", "", snapshotResult{}, nil) - payload.IdempotencyToken = "idem-key" + payload.IdempotencyToken = new("idem-key") runID, err := submitRun(t.Context(), w, payload, tc.poolID, tc.priorityClass, tc.unityCatalogImagePath, nil) require.NoError(t, err) @@ -192,8 +194,8 @@ func TestBuildSubmitPayloadDefaultRetries(t *testing.T) { Compute: &computeConfig{AcceleratorType: "GPU_1xH100", NumAccelerators: 1}, } task := buildSubmitPayload(cfg, "/d/command.sh", "4", "", snapshotResult{}, nil).Tasks[0] - assert.Equal(t, defaultMaxRetries, task.MaxRetries) - assert.True(t, task.RetryOnTimeout) + assert.Equal(t, defaultMaxRetries, utils.Deref(task.MaxRetries)) + assert.True(t, utils.Deref(task.RetryOnTimeout)) } func TestBuildSubmitPayloadNoRetries(t *testing.T) { @@ -207,8 +209,8 @@ func TestBuildSubmitPayloadNoRetries(t *testing.T) { MaxRetries: new(0), } task := buildSubmitPayload(cfg, "/d/command.sh", "4", "", snapshotResult{}, nil).Tasks[0] - assert.Equal(t, 0, task.MaxRetries) - assert.False(t, task.RetryOnTimeout) + assert.Equal(t, 0, utils.Deref(task.MaxRetries)) + assert.False(t, utils.Deref(task.RetryOnTimeout)) b, err := json.Marshal(task) require.NoError(t, err) @@ -229,7 +231,7 @@ func TestBuildSubmitPayloadInlineDependencies(t *testing.T) { deps := []string{"torch==2.3.0", "--extra-index-url https://internal/pypi", "numpy"} spec := buildSubmitPayload(cfg, "/d/command.sh", "5", "", snapshotResult{}, deps).Environments[0].Spec assert.Equal(t, deps, spec.Dependencies) - assert.Equal(t, "5", spec.EnvironmentVersion) + assert.Equal(t, "5", utils.Deref(spec.EnvironmentVersion)) // The SDK marshaler drops empty/nil slices, so no "dependencies" key is emitted. for _, empty := range [][]string{{}, nil} { @@ -339,10 +341,10 @@ func TestSubmitWorkload(t *testing.T) { t.Cleanup(server.Close) // Register before AddDefaultHandlers: the router is first-wins, so this must claim the route ahead of the default handler. - var got jobs.SubmitRun + var got jobs.SubmitRunRequest server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { require.NoError(t, json.Unmarshal(req.Body, &got)) - return jobs.SubmitRunResponse{RunId: 777} + return jobs.SubmitRunResponse{RunId: new(int64(777))} }) var validatedToken string server.Handle("POST", validateConfigPath, func(req testserver.Request) any { @@ -354,7 +356,7 @@ func TestSubmitWorkload(t *testing.T) { }) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) cfgPath := writeConfigFile(t, "run.yaml", minimalConfig) @@ -369,18 +371,18 @@ func TestSubmitWorkload(t *testing.T) { // The submitted payload is a native ai_runtime_task pointing at the uploaded // command.sh under the run's launch directory. - assert.Equal(t, "my-run", got.RunName) - assert.Equal(t, "idem-key", got.IdempotencyToken) + assert.Equal(t, "my-run", utils.Deref(got.RunName)) + assert.Equal(t, "idem-key", utils.Deref(got.IdempotencyToken)) require.Len(t, got.Environments, 1) require.Len(t, got.Tasks, 1) at := got.Tasks[0].AiRuntimeTask require.NotNil(t, at) require.Len(t, at.Deployments, 1) d := at.Deployments[0] - assert.True(t, strings.HasSuffix(d.CommandPath, "/"+commandScriptName), d.CommandPath) - assert.Contains(t, d.CommandPath, "/.air/cli_launch/") - assert.Equal(t, jobs.ComputeSpecAcceleratorTypeGpu1xH100, d.Compute.AcceleratorType) - assert.Equal(t, 1, d.Compute.AcceleratorCount) + assert.True(t, strings.HasSuffix(utils.Deref(d.CommandPath), "/"+commandScriptName), utils.Deref(d.CommandPath)) + assert.Contains(t, utils.Deref(d.CommandPath), "/.air/cli_launch/") + assert.Equal(t, jobs.ComputeSpec_AcceleratorType_Gpu1xH100, d.Compute.AcceleratorType) + assert.Equal(t, 1, utils.Deref(d.Compute.AcceleratorCount)) assert.Empty(t, d.Compute.ProvisionedCapacityId) } @@ -419,11 +421,11 @@ func TestSubmitWorkloadValidationOutcome(t *testing.T) { }) server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { submissions.Add(1) - return jobs.SubmitRunResponse{RunId: 777} + return jobs.SubmitRunResponse{RunId: new(int64(777))} }) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token", RetryTimeoutSeconds: 1}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token", RetryTimeoutSeconds: 1}) require.NoError(t, err) cfgPath := writeConfigFile(t, "run.yaml", minimalConfig) cfg, err := loadRunConfig(cfgPath) @@ -453,7 +455,7 @@ func TestSubmitWorkloadStagingErrorPreventsSubmit(t *testing.T) { var submitCalls atomic.Int32 server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { submitCalls.Add(1) - return jobs.SubmitRunResponse{RunId: 777} + return jobs.SubmitRunResponse{RunId: new(int64(777))} }) server.Handle("POST", "/api/2.0/workspace/mkdirs", func(req testserver.Request) any { return testserver.Response{StatusCode: 500, Body: map[string]string{"message": "mkdir failed"}} @@ -461,7 +463,7 @@ func TestSubmitWorkloadStagingErrorPreventsSubmit(t *testing.T) { stubValidateConfig(server) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) cfgPath := writeConfigFile(t, "run.yaml", minimalConfig) cfg, err := loadRunConfig(cfgPath) @@ -483,14 +485,14 @@ func TestSubmitWorkloadHonorsOverride(t *testing.T) { // Register before AddDefaultHandlers: the router is first-wins, so this must // claim the route ahead of the default jobs/runs/submit handler. - var got jobs.SubmitRun + var got jobs.SubmitRunRequest server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { require.NoError(t, json.Unmarshal(req.Body, &got)) - return jobs.SubmitRunResponse{RunId: 777} + return jobs.SubmitRunResponse{RunId: new(int64(777))} }) stubValidateConfig(server) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) cfgPath := writeConfigFile(t, "run.yaml", minimalConfig) @@ -504,7 +506,7 @@ func TestSubmitWorkloadHonorsOverride(t *testing.T) { at := got.Tasks[0].AiRuntimeTask require.NotNil(t, at) require.Len(t, at.Deployments, 1) - assert.Equal(t, 4, at.Deployments[0].Compute.AcceleratorCount) + assert.Equal(t, 4, utils.Deref(at.Deployments[0].Compute.AcceleratorCount)) } func TestSubmitWorkloadSendsUnityCatalogImagePath(t *testing.T) { @@ -514,11 +516,11 @@ func TestSubmitWorkloadSendsUnityCatalogImagePath(t *testing.T) { var got map[string]any server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { require.NoError(t, json.Unmarshal(req.Body, &got)) - return jobs.SubmitRunResponse{RunId: 777} + return jobs.SubmitRunResponse{RunId: new(int64(777))} }) stubValidateConfig(server) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) cfgPath := writeConfigFile(t, "run.yaml", minimalConfig+` @@ -543,7 +545,7 @@ environment: func TestInjectContainers(t *testing.T) { cfg := baseRunConfig() - cfg.Containers = []containerConfig{{Name: "inference", Ranks: []int{0, 1}, UnityCatalogImage: "main.ml.inference:v1"}} + cfg.Containers = []containerConfig{{Name: "inference", Ranks: []int{0, 1}, UnityCatalogImage: "main.experiments.inference:v1"}} payload := buildSubmitPayload(cfg, "/Workspace/run/command.sh", "6", "", snapshotResult{}, nil) assert.Empty(t, payload.Tasks[0].AiRuntimeTask.Deployments[0].CommandPath) raw, err := json.Marshal(payload) @@ -552,8 +554,8 @@ func TestInjectContainers(t *testing.T) { require.NoError(t, json.Unmarshal(raw, &body)) err = injectContainers(body, []submittedContainer{ - {Name: "inference", CommandPath: "/Workspace/run/containers/inference/command.sh", Ranks: []int{0, 1}, UnityCatalogImagePath: "main.ml.inference:v1"}, - {Name: "dataproc", CommandPath: "/Workspace/run/containers/dataproc/command.sh", Ranks: []int{2}, UnityCatalogImagePath: "main.ml.dataproc:v1"}, + {Name: "inference", CommandPath: "/Workspace/run/containers/inference/command.sh", Ranks: []int{0, 1}, UnityCatalogImagePath: "main.experiments.inference:v1"}, + {Name: "dataproc", CommandPath: "/Workspace/run/containers/dataproc/command.sh", Ranks: []int{2}, UnityCatalogImagePath: "main.experiments.dataproc:v1"}, }) require.NoError(t, err) @@ -566,7 +568,7 @@ func TestInjectContainers(t *testing.T) { first := containers[0].(map[string]any) assert.Equal(t, "inference", first["name"]) assert.Equal(t, "/Workspace/run/containers/inference/command.sh", first["command_path"]) - assert.Equal(t, "main.ml.inference:v1", first["unity_catalog_image_path"]) + assert.Equal(t, "main.experiments.inference:v1", first["unity_catalog_image_path"]) assert.Equal(t, []any{0, 1}, first["ranks"]) assert.NotContains(t, first, "environment_variables") } @@ -578,11 +580,11 @@ func TestSubmitWorkloadSendsContainerCommandsWithoutDeploymentCommand(t *testing var got map[string]any server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { require.NoError(t, json.Unmarshal(req.Body, &got)) - return jobs.SubmitRunResponse{RunId: 777} + return jobs.SubmitRunResponse{RunId: new(int64(777))} }) stubValidateConfig(server) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) cfgPath := writeConfigFile(t, "run.yaml", `experiment_name: container-run @@ -592,11 +594,11 @@ compute: containers: - name: inference ranks: [0] - unity_catalog_image: main.ml.inference:v1 + unity_catalog_image: main.experiments.inference:v1 command: python infer.py - name: trainer ranks: [1] - unity_catalog_image: main.ml.trainer:v1 + unity_catalog_image: main.experiments.trainer:v1 command: python train.py `) cfg, err := loadRunConfig(cfgPath) @@ -626,10 +628,10 @@ func TestSubmitWorkloadWithCodeSource(t *testing.T) { t.Cleanup(server.Close) // Register before AddDefaultHandlers: the router is first-wins, so this must claim the route ahead of the default handler. - var got jobs.SubmitRun + var got jobs.SubmitRunRequest server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { require.NoError(t, json.Unmarshal(req.Body, &got)) - return jobs.SubmitRunResponse{RunId: 555} + return jobs.SubmitRunResponse{RunId: new(int64(555))} }) var meCalls atomic.Int32 server.Handle("GET", "/api/2.0/preview/scim/v2/Me", func(req testserver.Request) any { @@ -638,7 +640,7 @@ func TestSubmitWorkloadWithCodeSource(t *testing.T) { }) stubValidateConfig(server) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) // A plain working-tree directory: packaging is plain-tar. @@ -663,8 +665,8 @@ code_source: at := got.Tasks[0].AiRuntimeTask // The tarball is uploaded to the artifact .internal dir and code_source_path // rewritten to it. - assert.Contains(t, at.CodeSourcePath, "/.air/repo_snapshots/.internal/") - assert.True(t, strings.HasSuffix(at.CodeSourcePath, ".tar.gz"), at.CodeSourcePath) + assert.Contains(t, utils.Deref(at.CodeSourcePath), "/.air/repo_snapshots/.internal/") + assert.True(t, strings.HasSuffix(utils.Deref(at.CodeSourcePath), ".tar.gz"), at.CodeSourcePath) assert.Equal(t, int32(1), meCalls.Load(), "code-source submission should resolve the workspace base once") } @@ -674,14 +676,14 @@ func TestSubmitWorkloadWithGitPinnedCodeSource(t *testing.T) { server := testserver.New(t) t.Cleanup(server.Close) - var got jobs.SubmitRun + var got jobs.SubmitRunRequest server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { require.NoError(t, json.Unmarshal(req.Body, &got)) - return jobs.SubmitRunResponse{RunId: 555} + return jobs.SubmitRunResponse{RunId: new(int64(555))} }) stubValidateConfig(server) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) // A git repo committed at HEAD, referenced by commit so packaging is git_archive. @@ -706,13 +708,13 @@ code_source: require.NoError(t, err) at := got.Tasks[0].AiRuntimeTask - assert.Contains(t, at.CodeSourcePath, "/.air/repo_snapshots/.internal/") - assert.True(t, strings.HasSuffix(at.CodeSourcePath, ".tar.gz"), at.CodeSourcePath) + assert.Contains(t, utils.Deref(at.CodeSourcePath), "/.air/repo_snapshots/.internal/") + assert.True(t, strings.HasSuffix(utils.Deref(at.CodeSourcePath), ".tar.gz"), at.CodeSourcePath) } // testSidecarStore builds a workspace filer + base path standing in for the run's // launch dir, where uploadSnapshot writes git provenance sidecars. -func testSidecarStore(t *testing.T, w *databricks.WorkspaceClient) (filer.Filer, string) { +func testSidecarStore(t *testing.T, w *sdkclients.Clients) (filer.Filer, string) { t.Helper() base := "/Workspace/Users/tester@databricks.com/.air/cli_launch/test" f, err := filer.NewWorkspaceFilesClient(w, base) @@ -730,7 +732,7 @@ func TestSubmitWorkloadPlainTarContentAddressed(t *testing.T) { t.Cleanup(server.Close) server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { - return jobs.SubmitRunResponse{RunId: 555} + return jobs.SubmitRunResponse{RunId: new(int64(555))} }) // Count snapshot import calls, preserving fake-workspace persistence so the // second submit's existence Stat sees the first upload. A count (not a set keyed by @@ -748,7 +750,7 @@ func TestSubmitWorkloadPlainTarContentAddressed(t *testing.T) { }) stubValidateConfig(server) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) // A plain working-tree directory named "src": the old code named the tarball @@ -804,7 +806,7 @@ func TestSubmitWorkloadGitArchiveCaching(t *testing.T) { t.Cleanup(server.Close) server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { - return jobs.SubmitRunResponse{RunId: 555} + return jobs.SubmitRunResponse{RunId: new(int64(555))} }) // Track which snapshot tarballs get uploaded, preserving fake-workspace // persistence so the second submit's cache-existence Stat sees the first upload. @@ -821,7 +823,7 @@ func TestSubmitWorkloadGitArchiveCaching(t *testing.T) { }) stubValidateConfig(server) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) repo := newTestRepo(t) @@ -871,11 +873,11 @@ func TestSubmitWorkloadSkipsProvenanceSidecars(t *testing.T) { t.Cleanup(server.Close) server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { - return jobs.SubmitRunResponse{RunId: 555} + return jobs.SubmitRunResponse{RunId: new(int64(555))} }) stubValidateConfig(server) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) // Commit, then dirty the tree to cover the previously active sidecar path. @@ -916,10 +918,10 @@ func TestSubmitWorkloadWithRemoteVolumeCodeSource(t *testing.T) { server := testserver.New(t) t.Cleanup(server.Close) - var got jobs.SubmitRun + var got jobs.SubmitRunRequest server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { require.NoError(t, json.Unmarshal(req.Body, &got)) - return jobs.SubmitRunResponse{RunId: 555} + return jobs.SubmitRunResponse{RunId: new(int64(555))} }) // Stub the UC Volume file write: the fake server's default handler 404s when the // parent dir is absent (no auto-mkdir), so accept the PUT to exercise the Volume @@ -929,7 +931,7 @@ func TestSubmitWorkloadWithRemoteVolumeCodeSource(t *testing.T) { }) stubValidateConfig(server) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) repo := filepath.Join(t.TempDir(), "src") @@ -951,8 +953,8 @@ code_source: require.NoError(t, err) at := got.Tasks[0].AiRuntimeTask - assert.Contains(t, at.CodeSourcePath, "/Volumes/main/default/code/.internal/") - assert.True(t, strings.HasSuffix(at.CodeSourcePath, ".tar.gz"), at.CodeSourcePath) + assert.Contains(t, utils.Deref(at.CodeSourcePath), "/Volumes/main/default/code/.internal/") + assert.True(t, strings.HasSuffix(utils.Deref(at.CodeSourcePath), ".tar.gz"), at.CodeSourcePath) } func TestSubmitWorkloadGuards(t *testing.T) { @@ -977,7 +979,7 @@ func TestSubmitWorkloadGuards(t *testing.T) { }) stubValidateConfig(server) testserver.AddDefaultHandlers(server) - pw, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + pw, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) cfg := *base @@ -994,21 +996,21 @@ func TestSubmitWorkloadGuards(t *testing.T) { func TestSubmitWorkloadSendsUsagePolicy(t *testing.T) { const policyID = "12345678-90ab-cdef-1234-567890abcdef" - setup := func(t *testing.T) (*databricks.WorkspaceClient, *jobs.SubmitRun) { + setup := func(t *testing.T) (*sdkclients.Clients, *jobs.SubmitRunRequest) { server := testserver.New(t) t.Cleanup(server.Close) - got := &jobs.SubmitRun{} + got := &jobs.SubmitRunRequest{} server.Handle("POST", "/api/2.2/jobs/runs/submit", func(req testserver.Request) any { require.NoError(t, json.Unmarshal(req.Body, got)) - return jobs.SubmitRunResponse{RunId: 1} + return jobs.SubmitRunResponse{RunId: new(int64(1))} }) server.Handle("GET", "/api/2.0/serverless-policies", func(req testserver.Request) any { return usagePoliciesResponse{Policies: []usagePolicy{{PolicyID: policyID, PolicyName: "team-a"}}} }) stubValidateConfig(server) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) return w, got } @@ -1021,7 +1023,7 @@ func TestSubmitWorkloadSendsUsagePolicy(t *testing.T) { _, _, err = submitWorkload(cmdio.MockDiscard(t.Context()), w, cfg, cfgPath, "idem", false) require.NoError(t, err) - assert.Equal(t, policyID, got.BudgetPolicyId) + assert.Equal(t, policyID, utils.Deref(got.BudgetPolicyId)) }) t.Run("resolved from name", func(t *testing.T) { @@ -1032,6 +1034,6 @@ func TestSubmitWorkloadSendsUsagePolicy(t *testing.T) { _, _, err = submitWorkload(cmdio.MockDiscard(t.Context()), w, cfg, cfgPath, "idem", false) require.NoError(t, err) - assert.Equal(t, policyID, got.BudgetPolicyId) + assert.Equal(t, policyID, utils.Deref(got.BudgetPolicyId)) }) } diff --git a/cmd/air/runupload_test.go b/cmd/air/runupload_test.go index 60436a5e504..f502b745241 100644 --- a/cmd/air/runupload_test.go +++ b/cmd/air/runupload_test.go @@ -168,7 +168,7 @@ containers: - name: inference command: python infer.py ranks: [0] - unity_catalog_image: main.ml.inference:v1 + unity_catalog_image: main.experiments.inference:v1 environment_variables: variables: OVERRIDE: inference @@ -176,7 +176,7 @@ containers: - name: dataproc command: python dataproc.py ranks: [1] - unity_catalog_image: main.ml.dataproc:v1 + unity_catalog_image: main.experiments.dataproc:v1 `)) require.NoError(t, err) diff --git a/cmd/air/sdk.go b/cmd/air/sdk.go new file mode 100644 index 00000000000..3693c892500 --- /dev/null +++ b/cmd/air/sdk.go @@ -0,0 +1,91 @@ +package aircmd + +import ( + "context" + "iter" + "net/http" + + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" + sdkscim "github.com/databricks/sdk-go/scim/v1" +) + +// getRun fetches a run with all its tasks. runs/get returns at most 100 tasks +// per page, so the remaining pages are fetched and merged. +func getRun(ctx context.Context, w *sdkclients.Clients, runID int64) (*jobs.GetRunResponse, error) { + resp, err := w.Jobs.GetRun(ctx, sdkjobs.GetRunRequest{RunId: new(runID)}) + if err != nil { + return nil, err + } + run, err := jobs.GetRunResponseFromSDK(resp) + if err != nil { + return nil, err + } + for run.NextPageToken != nil && *run.NextPageToken != "" { + resp, err := w.Jobs.GetRun(ctx, sdkjobs.GetRunRequest{RunId: new(runID), PageToken: run.NextPageToken}) + if err != nil { + return nil, err + } + next, err := jobs.GetRunResponseFromSDK(resp) + if err != nil { + return nil, err + } + run.Tasks = append(run.Tasks, next.Tasks...) + run.JobClusters = append(run.JobClusters, next.JobClusters...) + run.JobParameters = append(run.JobParameters, next.JobParameters...) + run.RepairHistory = append(run.RepairHistory, next.RepairHistory...) + run.NextPageToken = next.NextPageToken + } + return run, nil +} + +// getRunOutput fetches the output of a single task run. +func getRunOutput(ctx context.Context, w *sdkclients.Clients, taskRunID int64) (*jobs.GetRunOutputResponse, error) { + resp, err := w.Jobs.GetRunOutput(ctx, sdkjobs.GetRunOutputRequest{RunId: new(taskRunID)}) + if err != nil { + return nil, err + } + return jobs.GetRunOutputResponseFromSDK(resp) +} + +// listRuns yields the runs matching req, converted to mirrors. +func listRuns(ctx context.Context, w *sdkclients.Clients, req sdkjobs.ListRunsRequest) iter.Seq2[*jobs.BaseRun, error] { + return func(yield func(*jobs.BaseRun, error) bool) { + for base, err := range w.Jobs.ListRunsIter(ctx, req) { + if err != nil { + yield(nil, err) + return + } + run, err := jobs.BaseRunFromSDK(base) + if !yield(run, err) || err != nil { + return + } + } + } +} + +// currentUserName returns the user name of the authenticated principal. +func currentUserName(ctx context.Context, w *sdkclients.Clients) (string, error) { + me, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) + if err != nil { + return "", err + } + if me.UserName == nil { + return "", nil + } + return *me.UserName, nil +} + +// getRunRaw decodes the runs/get response for runID into out. It is used for +// response fields sdk-go does not model. +func getRunRaw(ctx context.Context, w *sdkclients.Clients, runID int64, out any) error { + apiClient, err := apiclient.New(w.Config) + if err != nil { + return err + } + query := map[string]any{"run_id": runID} + return apiClient.Do(ctx, http.MethodGet, jobsRunsGetPath, auth.WorkspaceIDHeaders(w.Config), query, nil, out) +} diff --git a/cmd/air/snapshot_upload.go b/cmd/air/snapshot_upload.go index 1d4e9a533b8..054cee2f077 100644 --- a/cmd/air/snapshot_upload.go +++ b/cmd/air/snapshot_upload.go @@ -15,7 +15,7 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/filer" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" ) // uploadProvenanceSidecars controls collection and upload of git_state.json @@ -28,7 +28,7 @@ const uploadProvenanceSidecars = false // artifact store's .internal directory, returning the remote path to attach to the // ai_runtime_task. Uploading reuses libs/filer for the workspace/volume write without // depending on the bundle package (see uploadSnapshotTarball / snapshotUploadFiler). -func uploadSnapshot(ctx context.Context, w *databricks.WorkspaceClient, snap *snapshotSourceConfig, configPath, snapshotArtifactPath string, sidecarStore filer.Filer, sidecarBase string) (snapshotResult, error) { +func uploadSnapshot(ctx context.Context, w *sdkclients.Clients, snap *snapshotSourceConfig, configPath, snapshotArtifactPath string, sidecarStore filer.Filer, sidecarBase string) (snapshotResult, error) { repoPath, err := resolveRootPath(ctx, snap.RootPath, filepath.Dir(configPath)) if err != nil { return snapshotResult{}, err @@ -157,7 +157,7 @@ const airArtifactInternalDir = ".internal" // The tarball name is content-addressed — by (commit, include_paths, root_path subtree) // for git_archive and by the working-tree metadata fingerprint for plain_tar — so if // the identical object already exists we skip packaging and upload entirely and reuse it. -func uploadSnapshotTarball(ctx context.Context, w *databricks.WorkspaceClient, repoPath string, plan snapshotPlan, artifactPath string) (snapshotResult, error) { +func uploadSnapshotTarball(ctx context.Context, w *sdkclients.Clients, repoPath string, plan snapshotPlan, artifactPath string) (snapshotResult, error) { result := snapshotResult{UsesGit: &plan.isGitRepo, PackagingMode: &plan.mode} f, uploadPath, err := snapshotUploadFiler(ctx, w, artifactPath) if err != nil { @@ -225,7 +225,7 @@ func uploadSnapshotTarball(ctx context.Context, w *databricks.WorkspaceClient, r // upload path. It routes /Volumes paths to a Files API filer and everything else to a // workspace files filer, matching bundle artifact-upload resolution without depending // on the bundle package. -func snapshotUploadFiler(ctx context.Context, w *databricks.WorkspaceClient, artifactPath string) (filer.Filer, string, error) { +func snapshotUploadFiler(ctx context.Context, w *sdkclients.Clients, artifactPath string) (filer.Filer, string, error) { if artifactPath == "" { return nil, "", errors.New("remote artifact path not configured") } diff --git a/cmd/air/sweep.go b/cmd/air/sweep.go index b346f43f1b6..2a14fbeaf2b 100644 --- a/cmd/air/sweep.go +++ b/cmd/air/sweep.go @@ -5,8 +5,9 @@ import ( "strconv" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" ) // sweepInfo summarizes a "foreach" run, which fans a single config out into many @@ -30,7 +31,7 @@ type sweepTask struct { // findForEachTask returns the run's foreach task if it has one, or nil. A run is // a sweep when one of its tasks fans out into iterations. -func findForEachTask(run *jobs.Run) *jobs.RunTask { +func findForEachTask(run *jobs.GetRunResponse) *jobs.RunTask { for i := range run.Tasks { if run.Tasks[i].ForEachTask != nil { return &run.Tasks[i] @@ -40,13 +41,40 @@ func findForEachTask(run *jobs.Run) *jobs.RunTask { } // buildSweepInfo gathers the iteration counts and per-iteration rows for a -// sweep. The counts come from the task we already have; the individual -// iterations require a second lookup. If that lookup fails we still return the -// counts (logging the failure) so the user sees the summary. -func buildSweepInfo(ctx context.Context, w *databricks.WorkspaceClient, task *jobs.RunTask) *sweepInfo { +// sweep. The counts come from the foreach task of the parent run; the +// individual iterations require a lookup of the foreach task run. If a lookup +// fails we still return what we have (logging the failure) so the user sees +// the summary. +// +// sdk-go models neither for_each_task.stats nor iterations on runs/get, so both +// are read with raw requests. +func buildSweepInfo(ctx context.Context, w *sdkclients.Clients, runID int64, task *jobs.RunTask) *sweepInfo { info := &sweepInfo{} - if task.ForEachTask.Stats != nil && task.ForEachTask.Stats.TaskRunStats != nil { - stats := task.ForEachTask.Stats.TaskRunStats + + var parent struct { + Tasks []struct { + TaskKey string `json:"task_key"` + ForEachTask *struct { + Stats *struct { + TaskRunStats *struct { + TotalIterations int `json:"total_iterations"` + SucceededIterations int `json:"succeeded_iterations"` + FailedIterations int `json:"failed_iterations"` + ActiveIterations int `json:"active_iterations"` + CompletedIterations int `json:"completed_iterations"` + } `json:"task_run_stats"` + } `json:"stats"` + } `json:"for_each_task"` + } `json:"tasks"` + } + if err := getRunRaw(ctx, w, runID, &parent); err != nil { + log.Debugf(ctx, "air get: could not fetch sweep stats: %v", err) + } + for _, t := range parent.Tasks { + if t.TaskKey != utils.Deref(task.TaskKey) || t.ForEachTask == nil || t.ForEachTask.Stats == nil || t.ForEachTask.Stats.TaskRunStats == nil { + continue + } + stats := t.ForEachTask.Stats.TaskRunStats info.Total = stats.TotalIterations info.Succeeded = stats.SucceededIterations info.Failed = stats.FailedIterations @@ -55,20 +83,22 @@ func buildSweepInfo(ctx context.Context, w *databricks.WorkspaceClient, task *jo } // The iterations are returned as part of a run lookup on the foreach task. - iterated, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: task.RunId}) - if err != nil { + var iterated struct { + Iterations []jobs.RunTask `json:"iterations"` + } + if err := getRunRaw(ctx, w, utils.Deref(task.RunId), &iterated); err != nil { log.Debugf(ctx, "air get: could not fetch sweep iterations: %v", err) return info } for _, it := range iterated.Iterations { row := sweepTask{ - TaskKey: it.TaskKey, - RunID: strconv.FormatInt(it.RunId, 10), + TaskKey: utils.Deref(it.TaskKey), + RunID: strconv.FormatInt(utils.Deref(it.RunId), 10), Status: runStatus(it.State), } - if it.GenAiComputeTask != nil && it.GenAiComputeTask.MlflowExperimentName != "" { - row.Experiment = stripExperimentUserPrefix(it.GenAiComputeTask.MlflowExperimentName) + if it.GenAiComputeTask != nil && utils.Deref(it.GenAiComputeTask.MlflowExperimentName) != "" { + row.Experiment = stripExperimentUserPrefix(*it.GenAiComputeTask.MlflowExperimentName) } info.Tasks = append(info.Tasks, row) } diff --git a/cmd/air/sweep_test.go b/cmd/air/sweep_test.go index 10134c0df42..5714005907b 100644 --- a/cmd/air/sweep_test.go +++ b/cmd/air/sweep_test.go @@ -1,62 +1,74 @@ package aircmd import ( + "net/http" "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestFindForEachTask(t *testing.T) { // No tasks at all. - assert.Nil(t, findForEachTask(&jobs.Run{})) + assert.Nil(t, findForEachTask(&jobs.GetRunResponse{})) // A task that is not a foreach. - assert.Nil(t, findForEachTask(&jobs.Run{Tasks: []jobs.RunTask{{TaskKey: "a"}}})) + assert.Nil(t, findForEachTask(&jobs.GetRunResponse{Tasks: []jobs.RunTask{{TaskKey: new("a")}}})) // The foreach task is found even when it isn't first. - run := &jobs.Run{Tasks: []jobs.RunTask{ - {TaskKey: "a"}, - {TaskKey: "sweep", ForEachTask: &jobs.RunForEachTask{}}, + run := &jobs.GetRunResponse{Tasks: []jobs.RunTask{ + {TaskKey: new("a")}, + {TaskKey: new("sweep"), ForEachTask: &jobs.ForEachTask{}}, }} got := findForEachTask(run) require.NotNil(t, got) - assert.Equal(t, "sweep", got.TaskKey) + assert.Equal(t, "sweep", utils.Deref(got.TaskKey)) } func sweepTaskFixture() *jobs.RunTask { return &jobs.RunTask{ - RunId: 99, - ForEachTask: &jobs.RunForEachTask{ - Stats: &jobs.ForEachStats{TaskRunStats: &jobs.ForEachTaskTaskRunStats{ - TotalIterations: 4, - SucceededIterations: 1, - FailedIterations: 1, - ActiveIterations: 2, - CompletedIterations: 2, - }}, - }, + TaskKey: new("sweep"), + RunId: new(int64(99)), + ForEachTask: &jobs.ForEachTask{}, } } +// sweepServer serves runs/get for the parent run 1 (with the foreach task's +// stats) and for the foreach task run 99 (with iterationsBody, or an error when +// it is empty). +func sweepServer(t *testing.T, iterationsBody string) *sdkclients.Clients { + t.Helper() + return fakeWorkspace(t, map[string]http.HandlerFunc{ + "GET /api/2.2/jobs/runs/get": func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Query().Get("run_id") { + case "1": + _, _ = w.Write([]byte(`{"run_id":1,"tasks":[{"task_key":"sweep","run_id":99,"for_each_task":{"stats":{"task_run_stats":{ + "total_iterations":4,"succeeded_iterations":1,"failed_iterations":1,"active_iterations":2,"completed_iterations":2}}}}]}`)) + case "99": + if iterationsBody == "" { + w.WriteHeader(http.StatusNotFound) + _, _ = w.Write([]byte(`{"error_code":"RESOURCE_DOES_NOT_EXIST","message":"Run 99 does not exist."}`)) + return + } + _, _ = w.Write([]byte(iterationsBody)) + default: + t.Errorf("unexpected runs/get for run %s", r.URL.Query().Get("run_id")) + } + }, + }) +} + func TestBuildSweepInfo(t *testing.T) { ctx := t.Context() t.Run("counts and iteration rows", func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockJobsAPI().EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{RunId: 99}).Return( - &jobs.Run{Iterations: []jobs.RunTask{{ - TaskKey: "iter_0", - RunId: 100, - State: &jobs.RunState{ResultState: jobs.RunResultStateSuccess}, - GenAiComputeTask: &jobs.GenAiComputeTask{MlflowExperimentName: "/Users/me@example.com/exp"}, - }}}, nil) + w := sweepServer(t, `{"iterations":[{"task_key":"iter_0","run_id":100,"state":{"result_state":"SUCCESS"}, + "gen_ai_compute_task":{"mlflow_experiment_name":"/Users/me@example.com/exp"}}]}`) - info := buildSweepInfo(ctx, m.WorkspaceClient, sweepTaskFixture()) + info := buildSweepInfo(ctx, w, 1, sweepTaskFixture()) assert.Equal(t, 4, info.Total) assert.Equal(t, 2, info.Completed) assert.Equal(t, 1, info.Succeeded) @@ -70,11 +82,9 @@ func TestBuildSweepInfo(t *testing.T) { }) t.Run("iteration lookup failure still returns counts", func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockJobsAPI().EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{RunId: 99}).Return( - nil, apierr.ErrResourceDoesNotExist) + w := sweepServer(t, "") - info := buildSweepInfo(ctx, m.WorkspaceClient, sweepTaskFixture()) + info := buildSweepInfo(ctx, w, 1, sweepTaskFixture()) assert.Equal(t, 4, info.Total) assert.Empty(t, info.Tasks) }) diff --git a/cmd/air/telemetry_test.go b/cmd/air/telemetry_test.go index 49760d24ad9..11797dd6d8a 100644 --- a/cmd/air/telemetry_test.go +++ b/cmd/air/telemetry_test.go @@ -11,16 +11,17 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/telemetry" "github.com/databricks/cli/libs/telemetry/protos" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func captureAirTelemetry(t *testing.T, server *testserver.Server, w *databricks.WorkspaceClient) (context.Context, *[]protos.FrontendLog) { +func captureAirTelemetry(t *testing.T, server *testserver.Server, w *sdkclients.Clients) (context.Context, *[]protos.FrontendLog) { t.Helper() var events []protos.FrontendLog server.Handle("POST", "/telemetry-ext", func(req testserver.Request) any { @@ -58,7 +59,7 @@ func TestAirRunTelemetry(t *testing.T) { "error_code": "INVALID_PARAMETER_VALUE", "message": "submission rejected", }} } - return jobs.SubmitRunResponse{RunId: 555} + return jobs.SubmitRunResponse{RunId: new(int64(555))} }) var uploadedSize int64 server.Handle("POST", "/api/2.0/workspace/import", func(req testserver.Request) any { @@ -76,7 +77,7 @@ func TestAirRunTelemetry(t *testing.T) { return req.Workspace.WorkspaceFilesImportFile(form.Path, form.Content, form.Overwrite) }) stubValidateConfig(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) ctx, events := captureAirTelemetry(t, server, w) testserver.AddDefaultHandlers(server) @@ -141,7 +142,7 @@ func TestAirRunTelemetry(t *testing.T) { func TestAirRunTelemetryConfig(t *testing.T) { server := testserver.New(t) t.Cleanup(server.Close) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) ctx, events := captureAirTelemetry(t, server, w) cfgPath := writeConfigFile(t, "run.yaml", minimalConfig) @@ -176,7 +177,7 @@ func TestSnapshotPackagingFailureMeasurements(t *testing.T) { server := testserver.New(t) t.Cleanup(server.Close) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) // The commit is no longer available when git archive attempts to package it. result, err := uploadSnapshotTarball(t.Context(), w, newTestRepo(t), snapshotPlan{ @@ -194,7 +195,7 @@ func TestSnapshotPackagingFailureMeasurements(t *testing.T) { func TestAirRunTelemetryContainersHaveDockerImage(t *testing.T) { server := testserver.New(t) t.Cleanup(server.Close) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) ctx, events := captureAirTelemetry(t, server, w) cfg, err := loadRunConfig(writeConfigFile(t, "run.yaml", minimalConfig)) diff --git a/cmd/air/usagepolicy.go b/cmd/air/usagepolicy.go index c014065e943..06e4b4f1f32 100644 --- a/cmd/air/usagepolicy.go +++ b/cmd/air/usagepolicy.go @@ -8,9 +8,9 @@ import ( "slices" "strings" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/auth" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/cli/libs/sdkclients" ) // serverlessPoliciesPath is the workspace-scoped ListBudgetPolicies endpoint on @@ -50,8 +50,8 @@ type usagePoliciesResponse struct { // The filter key is spelled with its dotted proto path rather than as a nested // map: the SDK only flattens nesting for struct-typed query values, and would // format a nested map with %v into a useless "map[...]" literal. -func listUsagePolicies(ctx context.Context, w *databricks.WorkspaceClient, policyName string) ([]usagePolicy, error) { - apiClient, err := client.New(w.Config) +func listUsagePolicies(ctx context.Context, w *sdkclients.Clients, policyName string) ([]usagePolicy, error) { + apiClient, err := apiclient.New(w.Config) if err != nil { return nil, fmt.Errorf("failed to create API client: %w", err) } @@ -103,7 +103,7 @@ func listUsagePolicies(ctx context.Context, w *databricks.WorkspaceClient, polic // user-created policy the two are the same, so the distinction only surfaces for // the system defaults; a user who supplies a display name that isn't a // policy_name gets the not-found error with the real names as candidates. -func resolveUsagePolicyIDByName(ctx context.Context, w *databricks.WorkspaceClient, name string) (string, error) { +func resolveUsagePolicyIDByName(ctx context.Context, w *sdkclients.Clients, name string) (string, error) { target := strings.TrimSpace(name) // Guard the contract independently of the YAML validator: an empty filter would // otherwise list (then reject against) every policy in the workspace. diff --git a/cmd/air/usagepolicy_test.go b/cmd/air/usagepolicy_test.go index 441657bdb83..e8fe0a17d89 100644 --- a/cmd/air/usagepolicy_test.go +++ b/cmd/air/usagepolicy_test.go @@ -5,15 +5,16 @@ import ( "strconv" "testing" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) // policyServer serves /api/2.0/serverless-policies from the given pages, // returning one page per request and recording each request's query. -func policyServer(t *testing.T, pages ...usagePoliciesResponse) (*databricks.WorkspaceClient, *[]url.Values) { +func policyServer(t *testing.T, pages ...usagePoliciesResponse) (*sdkclients.Clients, *[]url.Values) { server := testserver.New(t) t.Cleanup(server.Close) @@ -26,7 +27,7 @@ func policyServer(t *testing.T, pages ...usagePoliciesResponse) (*databricks.Wor return page }) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) return w, &queries } @@ -202,7 +203,7 @@ func TestResolveUsagePolicyIDByName(t *testing.T) { return testserver.Response{StatusCode: 403, Body: `{"error_code":"PERMISSION_DENIED","message":"nope"}`} }) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) _, err = resolveUsagePolicyIDByName(t.Context(), w, "team-a") diff --git a/cmd/air/validateconfig.go b/cmd/air/validateconfig.go index 62dad63f8ab..ae5acb171b8 100644 --- a/cmd/air/validateconfig.go +++ b/cmd/air/validateconfig.go @@ -1,52 +1,35 @@ package aircmd import ( + "bytes" "context" "crypto/tls" "encoding/json" "errors" "fmt" + "io" "net/http" "net/url" "strings" "time" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/common" - "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/httpclient" - "github.com/databricks/databricks-sdk-go/httpclient/traceparent" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/useragent" + "github.com/databricks/sdk-go/core/apierr" ) // validateConfigPath is AiTrainingService's pre-flight: it checks a training // config server-side and returns the problems, without submitting. Called with a -// raw client.Do because the SDK does not model AiTrainingService. +// raw request because the SDK does not model AiTrainingService. const validateConfigPath = "/api/2.0/ai-training/config:validate" const dryRunValidationMaxAttempts = 2 const submissionValidationTimeout = 5 * time.Second -type dryRunValidationAttemptBudgetKey struct{} - -func armDryRunValidationAttemptBudget(ctx context.Context) context.Context { - return context.WithValue(ctx, dryRunValidationAttemptBudgetKey{}, new(int)) -} - -func allowDryRunValidationRetry(ctx context.Context) bool { - attempts, ok := ctx.Value(dryRunValidationAttemptBudgetKey{}).(*int) - if !ok { - return false - } - *attempts++ - return *attempts < dryRunValidationMaxAttempts -} - // configFieldError is one problem the server found, addressed to the config // field that caused it. Mirrors the proto FieldError. type configFieldError struct { @@ -90,7 +73,7 @@ func validationUnavailable(err error) (*validationUnavailableError, bool) { // a bad config fails fast with the server's own field-level errors. // // Availability failures fail open, while caller failures and field errors block. -func preflightValidate(ctx context.Context, w *databricks.WorkspaceClient, cfg *runConfig, commandPath string, containers []submittedContainer, idempotencyToken string) error { +func preflightValidate(ctx context.Context, w *sdkclients.Clients, cfg *runConfig, commandPath string, containers []submittedContainer, idempotencyToken string) error { validationCtx, cancel := context.WithTimeout(ctx, submissionValidationTimeout) defer cancel() @@ -104,53 +87,49 @@ func preflightValidate(ctx context.Context, w *databricks.WorkspaceClient, cfg * return err } -func validateConfigOnce(ctx context.Context, w *databricks.WorkspaceClient, cfg *runConfig, commandPath string, containers []submittedContainer, idempotencyToken string) error { - clientCfg, err := config.HTTPClientConfigFromConfig(w.Config) - if err != nil { - return fmt.Errorf("failed to create API client: %w", err) - } - - requestBody, err := common.NewRequestBody(validateConfigRequest(ctx, cfg, commandPath, containers, idempotencyToken)) +func validateConfigOnce(ctx context.Context, w *sdkclients.Clients, cfg *runConfig, commandPath string, containers []submittedContainer, idempotencyToken string) error { + body, err := json.Marshal(validateConfigRequest(ctx, cfg, commandPath, containers, idempotencyToken)) if err != nil { return fmt.Errorf("failed to validate config: %w", err) } - req, err := http.NewRequestWithContext(ctx, http.MethodPost, validateConfigPath, requestBody.Reader) + host := strings.TrimSuffix(w.Config.CanonicalHostName(), "/") + req, err := http.NewRequestWithContext(ctx, http.MethodPost, host+validateConfigPath, bytes.NewReader(body)) if err != nil { return fmt.Errorf("failed to validate config: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("Content-Type", requestBody.ContentType) - if clientCfg.AuthVisitor != nil { - // Some SDK OAuth visitors refresh with context.Background(). For those - // providers, acquire the token with the preflight context first. - switch w.Config.AuthType { - case auth.AuthTypePat, auth.AuthTypeBasic, "noop", auth.AuthTypeAzureCli, auth.AuthTypeAzureMSI, auth.AuthTypeAzureSecret, auth.AuthTypeGoogleCreds, auth.AuthTypeGoogleID: - default: - token, err := w.Config.GetTokenSource().Token(req.Context()) - if err != nil { - return &validationAuthenticationError{fmt.Errorf("failed to validate config: %w", err)} - } - token.SetAuthHeader(req) - } - if err := clientCfg.AuthVisitor(req); err != nil { + req.Header.Set("Content-Type", "application/json") + // Some SDK OAuth visitors refresh with context.Background(). For those + // providers, acquire the token with the preflight context first. + switch w.Config.AuthType { + case auth.AuthTypePat, auth.AuthTypeBasic, "noop", auth.AuthTypeAzureCli, auth.AuthTypeAzureMSI, auth.AuthTypeAzureSecret, auth.AuthTypeGoogleCreds, auth.AuthTypeGoogleID: + default: + token, err := w.Config.GetTokenSource().Token(req.Context()) + if err != nil { return &validationAuthenticationError{fmt.Errorf("failed to validate config: %w", err)} } + token.SetAuthHeader(req) + } + if err := w.Config.Authenticate(req); err != nil { + return &validationAuthenticationError{fmt.Errorf("failed to validate config: %w", err)} } - for _, visitor := range clientCfg.Visitors { - if err := visitor(req); err != nil { + if w.Config.Headers != nil { + if err := w.Config.Headers(req); err != nil { return fmt.Errorf("failed to validate config: %w", err) } } for key, value := range auth.WorkspaceIDHeaders(w.Config) { req.Header.Set(key, value) } - req.Header.Set("User-Agent", useragent.FromContext(req.Context())) - traceparent.AddTraceparent(req) + uaCtx := useragent.InContext(req.Context(), useragent.AuthKey, w.Config.AuthType) + req.Header.Set("User-Agent", useragent.FromContext(uaCtx)) - transport := clientCfg.Transport + // A single attempt without the retries of the regular API transport: the + // preflight must never delay submission. + transport := w.Config.HTTPTransport if transport == nil { defaultTransport := http.DefaultTransport.(*http.Transport).Clone() - if clientCfg.InsecureSkipVerify { + if w.Config.InsecureSkipVerify { defaultTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} } transport = defaultTransport @@ -160,26 +139,26 @@ func validateConfigOnce(ctx context.Context, w *databricks.WorkspaceClient, cfg return fmt.Errorf("failed to validate config: %w", err) } defer resp.Body.Close() - responseBody, err := common.NewResponseWrapper(resp, requestBody) + responseBody, err := io.ReadAll(resp.Body) if err != nil { err = fmt.Errorf("failed to validate config: %w", err) if errors.Is(err, context.Canceled) { return err } if resp.StatusCode >= 400 { - return &apierr.APIError{ - StatusCode: resp.StatusCode, - Message: err.Error(), - } + // Keep the status so classifyValidationFailure can still tell a + // caller error from an unavailable service. + body, _ := json.Marshal(map[string]string{"message": err.Error()}) + return apierr.FromHTTPError(resp.StatusCode, resp.Header, body) } return asValidationUnavailable(err, true) } - if err := apierr.GetAPIError(ctx, responseBody); err != nil { - return fmt.Errorf("failed to validate config: %w", err) + if apiErr := apierr.FromHTTPError(resp.StatusCode, resp.Header, responseBody); apiErr != nil { + return fmt.Errorf("failed to validate config: %w", apiErr) } var result validateConfigResponse - if err := json.Unmarshal(responseBody.DebugBytes, &result); err != nil { + if err := json.Unmarshal(responseBody, &result); err != nil { return asValidationUnavailable(fmt.Errorf("failed to validate config: %w", err), true) } if len(result.Errors) == 0 { @@ -188,57 +167,24 @@ func validateConfigOnce(ctx context.Context, w *databricks.WorkspaceClient, cfg return errors.New(formatConfigErrors(result.Errors)) } -func newDryRunValidationClient(w *databricks.WorkspaceClient) (*client.DatabricksClient, error) { - clientCfg, err := config.HTTPClientConfigFromConfig(w.Config) - if err != nil { - return nil, err - } - clientCfg.TransientErrors = nil - clientCfg.ErrorRetriable = func(ctx context.Context, err error) bool { - apiErr, ok := errors.AsType[*apierr.APIError](err) - if !ok { - return false - } - if apiErr.StatusCode != http.StatusTooManyRequests && apiErr.StatusCode != http.StatusServiceUnavailable { - return false - } - return allowDryRunValidationRetry(ctx) - } - return client.NewWithClient(w.Config, httpclient.NewApiClient(clientCfg)) -} - -func validateDryRunConfig(ctx context.Context, w *databricks.WorkspaceClient, cfg *runConfig, commandPath string, containers []submittedContainer, idempotencyToken string, timeout time.Duration) error { - apiClient, err := newDryRunValidationClient(w) - if err != nil { - return fmt.Errorf("failed to create API client: %w", err) - } - +func validateDryRunConfig(ctx context.Context, w *sdkclients.Clients, cfg *runConfig, commandPath string, containers []submittedContainer, idempotencyToken string, timeout time.Duration) error { validationCtx, cancel := context.WithTimeout(ctx, timeout) defer cancel() - validationCtx = armDryRunValidationAttemptBudget(validationCtx) - err = validateConfig(validationCtx, apiClient, cfg, commandPath, containers, idempotencyToken) + var err error + for range dryRunValidationMaxAttempts { + err = validateConfigOnce(validationCtx, w, cfg, commandPath, containers, idempotencyToken) + code := apierrs.StatusCode(err) + if code != http.StatusTooManyRequests && code != http.StatusServiceUnavailable { + break + } + } if unavailable, retryable := classifyValidationFailure(err); unavailable { return asValidationUnavailable(err, retryable) } return err } -// validateConfig performs the current backend validation without client-side -// availability fallbacks. The legacy response reports field errors only; it -// cannot yet distinguish complete success from skipped backend dependencies. -func validateConfig(ctx context.Context, apiClient *client.DatabricksClient, cfg *runConfig, commandPath string, containers []submittedContainer, idempotencyToken string) error { - var resp validateConfigResponse - err := apiClient.Do(ctx, http.MethodPost, validateConfigPath, auth.WorkspaceIDHeaders(apiClient.Config), nil, validateConfigRequest(ctx, cfg, commandPath, containers, idempotencyToken), &resp) - if err != nil { - return fmt.Errorf("failed to validate config: %w", err) - } - if len(resp.Errors) == 0 { - return nil - } - return errors.New(formatConfigErrors(resp.Errors)) -} - // classifyValidationFailure separates service failures from caller errors and // reports whether retrying the same request may succeed. func classifyValidationFailure(err error) (unavailable, retryable bool) { @@ -263,14 +209,14 @@ func classifyValidationFailure(err error) (unavailable, retryable bool) { if !ok { return false, false } - if apiErr.ErrorCode == "FEATURE_DISABLED" || - apiErr.StatusCode == http.StatusNotFound || - apiErr.StatusCode == http.StatusNotImplemented { + if apierrs.ErrorCode(apiErr) == "FEATURE_DISABLED" || + apiErr.HTTPStatusCode() == http.StatusNotFound || + apiErr.HTTPStatusCode() == http.StatusNotImplemented { return true, false } - if apiErr.StatusCode == http.StatusRequestTimeout || - apiErr.StatusCode == http.StatusTooManyRequests || - apiErr.StatusCode >= 500 { + if apiErr.HTTPStatusCode() == http.StatusRequestTimeout || + apiErr.HTTPStatusCode() == http.StatusTooManyRequests || + apiErr.HTTPStatusCode() >= 500 { return true, true } return false, false diff --git a/cmd/air/validateconfig_test.go b/cmd/air/validateconfig_test.go index f0a0f3e38c8..57449680044 100644 --- a/cmd/air/validateconfig_test.go +++ b/cmd/air/validateconfig_test.go @@ -14,11 +14,11 @@ import ( "time" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/sdkclients" sdkconfig "github.com/databricks/databricks-sdk-go/config" "github.com/databricks/databricks-sdk-go/config/credentials" sdkauth "github.com/databricks/databricks-sdk-go/config/experimental/auth" + "github.com/databricks/sdk-go/core/apierr" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/oauth2" @@ -50,21 +50,22 @@ func validateServer(t *testing.T, status int, body string, gotReq *map[string]an return srv } -func validationTestWorkspaceClient(t *testing.T, host string) *databricks.WorkspaceClient { +func validationTestWorkspaceClient(t *testing.T, host string) *sdkclients.Clients { t.Helper() w := newTestWorkspaceClient(t, host) w.Config.RetryTimeoutSeconds = 1 return w } -func validationTestWorkspaceClientWithTransport(t *testing.T, transport validationRoundTripFunc) *databricks.WorkspaceClient { +func validationTestWorkspaceClientWithTransport(t *testing.T, transport validationRoundTripFunc) *sdkclients.Clients { t.Helper() - w, err := databricks.NewWorkspaceClient(&databricks.Config{ + w, err := sdkclients.New(t.Context(), &sdkconfig.Config{ Host: "https://example.test", Token: "token", HTTPTransport: transport, }) require.NoError(t, err) + authenticate(t, w) return w } @@ -207,7 +208,7 @@ func TestPreflightValidationBodyReadFailureOnCallerErrorBlocks(t *testing.T) { require.Error(t, err) apiErr, ok := errors.AsType[*apierr.APIError](err) require.True(t, ok) - assert.Equal(t, http.StatusUnauthorized, apiErr.StatusCode) + assert.Equal(t, http.StatusUnauthorized, apiErr.HTTPStatusCode()) } func TestPreflightValidationOAuthRefreshUsesDeadline(t *testing.T) { @@ -223,7 +224,7 @@ func TestPreflightValidationOAuthRefreshUsesDeadline(t *testing.T) { Expiry: time.Now().Add(-time.Hour), }), ) - w, err := databricks.NewWorkspaceClient(&databricks.Config{ + w, err := sdkclients.New(t.Context(), &sdkconfig.Config{ Host: "https://example.test", Credentials: validationOAuthCredentials{tokenSource: tokenSource}, HTTPTransport: validationRoundTripFunc(func(*http.Request) (*http.Response, error) { @@ -252,12 +253,11 @@ func TestPreflightValidationOAuthRefreshUsesDeadline(t *testing.T) { func TestPreflightValidationM2MOAuthRejectionBlocks(t *testing.T) { tests := []struct { - status int - wantErr error + status int }{ - {http.StatusBadRequest, apierr.ErrBadRequest}, - {http.StatusUnauthorized, apierr.ErrUnauthenticated}, - {http.StatusForbidden, apierr.ErrPermissionDenied}, + {http.StatusBadRequest}, + {http.StatusUnauthorized}, + {http.StatusForbidden}, } for _, tt := range tests { @@ -273,7 +273,7 @@ func TestPreflightValidationM2MOAuthRejectionBlocks(t *testing.T) { })) t.Cleanup(srv.Close) - w, err := databricks.NewWorkspaceClient(&databricks.Config{ + w, err := sdkclients.New(t.Context(), &sdkconfig.Config{ Host: srv.URL, ClientID: "client-id", ClientSecret: "client-secret", @@ -286,7 +286,9 @@ func TestPreflightValidationM2MOAuthRejectionBlocks(t *testing.T) { require.NoError(t, err) err = preflightValidate(t.Context(), w, baseRunConfig(), "/Workspace/Users/me/cmd.sh", nil, "token") - require.ErrorIs(t, err, tt.wantErr) + // The token endpoint's rejection blocks submission as an auth failure. + _, isAuthErr := errors.AsType[*validationAuthenticationError](err) + require.True(t, isAuthErr, "unexpected error: %v", err) }) } } @@ -384,15 +386,15 @@ func TestClassifyValidationFailure(t *testing.T) { {"deadline", context.DeadlineExceeded, true, true}, {"transport", &url.Error{Op: "Post", URL: "https://example.test", Err: errors.New("connection failed")}, true, true}, {"unknown", errors.New("authentication visitor failed"), false, false}, - {"bad request", &apierr.APIError{StatusCode: http.StatusBadRequest}, false, false}, - {"disabled", &apierr.APIError{StatusCode: http.StatusBadRequest, ErrorCode: "FEATURE_DISABLED"}, true, false}, - {"unauthenticated", &apierr.APIError{StatusCode: http.StatusUnauthorized}, false, false}, - {"forbidden", &apierr.APIError{StatusCode: http.StatusForbidden}, false, false}, - {"not found", &apierr.APIError{StatusCode: http.StatusNotFound}, true, false}, - {"not implemented", &apierr.APIError{StatusCode: http.StatusNotImplemented}, true, false}, - {"request timeout", &apierr.APIError{StatusCode: http.StatusRequestTimeout}, true, true}, - {"rate limited", &apierr.APIError{StatusCode: http.StatusTooManyRequests}, true, true}, - {"server error", &apierr.APIError{StatusCode: http.StatusInternalServerError}, true, true}, + {"bad request", newAPIError(http.StatusBadRequest, "", ""), false, false}, + {"disabled", newAPIError(http.StatusBadRequest, "FEATURE_DISABLED", ""), true, false}, + {"unauthenticated", newAPIError(http.StatusUnauthorized, "", ""), false, false}, + {"forbidden", newAPIError(http.StatusForbidden, "", ""), false, false}, + {"not found", newAPIError(http.StatusNotFound, "", ""), true, false}, + {"not implemented", newAPIError(http.StatusNotImplemented, "", ""), true, false}, + {"request timeout", newAPIError(http.StatusRequestTimeout, "", ""), true, true}, + {"rate limited", newAPIError(http.StatusTooManyRequests, "", ""), true, true}, + {"server error", newAPIError(http.StatusInternalServerError, "", ""), true, true}, } for _, tt := range tests { diff --git a/cmd/api/api.go b/cmd/api/api.go index e6bd47b8ec2..313287b6d14 100644 --- a/cmd/api/api.go +++ b/cmd/api/api.go @@ -12,13 +12,13 @@ import ( "strings" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/databrickscfg" "github.com/databricks/cli/libs/databrickscfg/profile" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/client" "github.com/databricks/databricks-sdk-go/config" "github.com/spf13/cobra" ) @@ -105,7 +105,7 @@ func makeCommand(method string) *cobra.Command { // Skips the default profile when DATABRICKS_HOST is set (#5616). root.ResolveDefaultProfile(cmd.Context(), cfg) - api, err := client.New(cfg) + api, err := apiclient.New(cfg) if err != nil { return err } diff --git a/cmd/apps/bundle_helpers.go b/cmd/apps/bundle_helpers.go index d1e587bebca..9b81225ef77 100644 --- a/cmd/apps/bundle_helpers.go +++ b/cmd/apps/bundle_helpers.go @@ -13,7 +13,8 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/cli/libs/utils" + sdkapps "github.com/databricks/sdk-go/apps/v1" "github.com/spf13/cobra" ) @@ -159,32 +160,32 @@ func isIdempotencyError(err error, keywords ...string) bool { } // displayAppURL displays the app URL in a consistent format if available. -func displayAppURL(ctx context.Context, appInfo *apps.App) { - if appInfo != nil && appInfo.Url != "" { - cmdio.LogString(ctx, fmt.Sprintf("\n🔗 %s\n", appInfo.Url)) +func displayAppURL(ctx context.Context, appInfo *sdkapps.App) { + if appInfo != nil && utils.Deref(appInfo.Url) != "" { + cmdio.LogString(ctx, fmt.Sprintf("\n🔗 %s\n", *appInfo.Url)) } } // formatAppStatusMessage formats a user-friendly status message for an app. -func formatAppStatusMessage(appInfo *apps.App, appName, verb string) string { +func formatAppStatusMessage(appInfo *sdkapps.App, appName, verb string) string { computeState := "unknown" if appInfo != nil && appInfo.ComputeStatus != nil { computeState = string(appInfo.ComputeStatus.State) } - if appInfo != nil && appInfo.AppStatus != nil && appInfo.AppStatus.State == apps.ApplicationStateUnavailable { + if appInfo != nil && appInfo.AppStatus != nil && appInfo.AppStatus.State == sdkapps.ApplicationStatus_ApplicationState_Unavailable { return fmt.Sprintf("⚠ App '%s' %s but is unavailable (compute: %s, app: %s)", appName, verb, computeState, appInfo.AppStatus.State) } if appInfo != nil && appInfo.ComputeStatus != nil { state := appInfo.ComputeStatus.State switch state { - case apps.ComputeStateActive: + case sdkapps.ComputeStatus_ComputeState_Active: if verb == "is deployed" { return fmt.Sprintf("✔ App '%s' is already running (status: %s)", appName, state) } return fmt.Sprintf("✔ App '%s' started successfully (status: %s)", appName, state) - case apps.ComputeStateStarting: + case sdkapps.ComputeStatus_ComputeState_Starting: return fmt.Sprintf("⚠ App '%s' is already starting (status: %s)", appName, state) default: return fmt.Sprintf("✔ App '%s' status: %s", appName, state) @@ -216,12 +217,12 @@ type spinnerInterface interface { } // createAppProgressCallback creates a progress callback for app operations. -func createAppProgressCallback(spinner spinnerInterface) func(*apps.App) { - return func(i *apps.App) { +func createAppProgressCallback(spinner spinnerInterface) func(*sdkapps.App) { + return func(i *sdkapps.App) { if i.ComputeStatus == nil { return } - statusMessage := i.ComputeStatus.Message + statusMessage := utils.Deref(i.ComputeStatus.Message) if statusMessage == "" { statusMessage = fmt.Sprintf("current status: %s", i.ComputeStatus.State) } @@ -242,7 +243,7 @@ func handleAlreadyInStateError(ctx context.Context, cmd *cobra.Command, err erro } w := cmdctx.WorkspaceClient(ctx) - appInfo, getErr := w.Apps.Get(ctx, apps.GetAppRequest{Name: appName}) + appInfo, getErr := w.Apps.GetApp(ctx, sdkapps.GetAppRequest{Name: new(appName)}) if getErr != nil { return true, wrapError(cmd, appName, getErr) } @@ -252,3 +253,12 @@ func handleAlreadyInStateError(ctx context.Context, cmd *cobra.Command, err erro displayAppURL(ctx, appInfo) return true, nil } + +// appNameArg returns the app name passed as the command's positional argument, +// or "" when the app comes from the project configuration. +func appNameArg(args []string) string { + if len(args) == 0 { + return "" + } + return args[0] +} diff --git a/cmd/apps/bundle_helpers_test.go b/cmd/apps/bundle_helpers_test.go index 3aade05a582..5c66131ac18 100644 --- a/cmd/apps/bundle_helpers_test.go +++ b/cmd/apps/bundle_helpers_test.go @@ -6,7 +6,7 @@ import ( "path/filepath" "testing" - "github.com/databricks/databricks-sdk-go/service/apps" + apps "github.com/databricks/sdk-go/apps/v1" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" ) @@ -46,10 +46,10 @@ func TestFormatAppStatusMessage(t *testing.T) { t.Run("handles unavailable app state", func(t *testing.T) { appInfo := &apps.App{ AppStatus: &apps.ApplicationStatus{ - State: apps.ApplicationStateUnavailable, + State: apps.ApplicationStatus_ApplicationState_Unavailable, }, ComputeStatus: &apps.ComputeStatus{ - State: apps.ComputeStateActive, + State: apps.ComputeStatus_ComputeState_Active, }, } msg := formatAppStatusMessage(appInfo, "test-app", "started") @@ -60,7 +60,7 @@ func TestFormatAppStatusMessage(t *testing.T) { t.Run("formats active state with 'is deployed' verb", func(t *testing.T) { appInfo := &apps.App{ ComputeStatus: &apps.ComputeStatus{ - State: apps.ComputeStateActive, + State: apps.ComputeStatus_ComputeState_Active, }, } msg := formatAppStatusMessage(appInfo, "test-app", "is deployed") @@ -71,7 +71,7 @@ func TestFormatAppStatusMessage(t *testing.T) { t.Run("formats active state with 'started' verb", func(t *testing.T) { appInfo := &apps.App{ ComputeStatus: &apps.ComputeStatus{ - State: apps.ComputeStateActive, + State: apps.ComputeStatus_ComputeState_Active, }, } msg := formatAppStatusMessage(appInfo, "test-app", "started") @@ -82,7 +82,7 @@ func TestFormatAppStatusMessage(t *testing.T) { t.Run("formats starting state", func(t *testing.T) { appInfo := &apps.App{ ComputeStatus: &apps.ComputeStatus{ - State: apps.ComputeStateStarting, + State: apps.ComputeStatus_ComputeState_Starting, }, } msg := formatAppStatusMessage(appInfo, "test-app", "started") @@ -93,7 +93,7 @@ func TestFormatAppStatusMessage(t *testing.T) { t.Run("formats other compute states", func(t *testing.T) { appInfo := &apps.App{ ComputeStatus: &apps.ComputeStatus{ - State: apps.ComputeStateStopped, + State: apps.ComputeStatus_ComputeState_Stopped, }, } msg := formatAppStatusMessage(appInfo, "test-app", "stopped") diff --git a/cmd/apps/delete_bundle.go b/cmd/apps/delete_bundle.go index b4c0e72f87c..6e280c5e357 100644 --- a/cmd/apps/delete_bundle.go +++ b/cmd/apps/delete_bundle.go @@ -2,14 +2,13 @@ package apps import ( "github.com/databricks/cli/cmd/bundle" - "github.com/databricks/databricks-sdk-go/service/apps" "github.com/spf13/cobra" ) // BundleDeleteOverrideWithWrapper creates a delete override function that uses // the provided error wrapper for API fallback errors. -func BundleDeleteOverrideWithWrapper(wrapError ErrorWrapper) func(*cobra.Command, *apps.DeleteAppRequest) { - return func(deleteCmd *cobra.Command, deleteReq *apps.DeleteAppRequest) { +func BundleDeleteOverrideWithWrapper[R any](wrapError ErrorWrapper) func(*cobra.Command, *R) { + return func(deleteCmd *cobra.Command, _ *R) { var ( autoApprove bool forceDestroy bool @@ -27,7 +26,7 @@ func BundleDeleteOverrideWithWrapper(wrapError ErrorWrapper) func(*cobra.Command } err := originalRunE(cmd, args) - return wrapError(cmd, deleteReq.Name, err) + return wrapError(cmd, appNameArg(args), err) } deleteCmd.Long = `Delete an app. diff --git a/cmd/apps/delete_bundle_test.go b/cmd/apps/delete_bundle_test.go index 0e717bbf737..f7ff37dead9 100644 --- a/cmd/apps/delete_bundle_test.go +++ b/cmd/apps/delete_bundle_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - "github.com/databricks/databricks-sdk-go/service/apps" + apps "github.com/databricks/sdk-go/apps/v1" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -15,7 +15,7 @@ func TestBundleDeleteOverrideWithWrapper(t *testing.T) { return err } - overrideFunc := BundleDeleteOverrideWithWrapper(mockWrapper) + overrideFunc := BundleDeleteOverrideWithWrapper[apps.DeleteAppRequest](mockWrapper) assert.NotNil(t, overrideFunc) cmd := &cobra.Command{} @@ -36,7 +36,7 @@ func TestBundleDeleteOverrideFlags(t *testing.T) { cmd := &cobra.Command{} deleteReq := &apps.DeleteAppRequest{} - overrideFunc := BundleDeleteOverrideWithWrapper(mockWrapper) + overrideFunc := BundleDeleteOverrideWithWrapper[apps.DeleteAppRequest](mockWrapper) overrideFunc(cmd, deleteReq) t.Run("auto-approve flag defaults to false", func(t *testing.T) { @@ -60,7 +60,7 @@ func TestBundleDeleteOverrideHelpText(t *testing.T) { cmd := &cobra.Command{} deleteReq := &apps.DeleteAppRequest{} - overrideFunc := BundleDeleteOverrideWithWrapper(mockWrapper) + overrideFunc := BundleDeleteOverrideWithWrapper[apps.DeleteAppRequest](mockWrapper) overrideFunc(cmd, deleteReq) assert.NotEmpty(t, cmd.Long) @@ -82,9 +82,9 @@ func TestBundleDeleteOverrideErrorWrapping(t *testing.T) { return errors.New("api error") }, } - deleteReq := &apps.DeleteAppRequest{Name: "test-app"} + deleteReq := &apps.DeleteAppRequest{Name: new("test-app")} - overrideFunc := BundleDeleteOverrideWithWrapper(mockWrapper) + overrideFunc := BundleDeleteOverrideWithWrapper[apps.DeleteAppRequest](mockWrapper) overrideFunc(cmd, deleteReq) err := cmd.RunE(cmd, []string{"test-app"}) diff --git a/cmd/apps/deploy_bundle.go b/cmd/apps/deploy_bundle.go index b390f45e132..ec44a93bbca 100644 --- a/cmd/apps/deploy_bundle.go +++ b/cmd/apps/deploy_bundle.go @@ -16,7 +16,6 @@ import ( "github.com/databricks/cli/libs/apps/validation" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go/service/apps" "github.com/spf13/cobra" ) @@ -66,8 +65,8 @@ func applyDeployFlags(cmd *cobra.Command, b *bundle.Bundle, opts bundleDeployOpt // BundleDeployOverrideWithWrapper creates a deploy override function that uses // the provided error wrapper for API fallback errors. -func BundleDeployOverrideWithWrapper(wrapError ErrorWrapper) func(*cobra.Command, *apps.CreateAppDeploymentRequest) { - return func(deployCmd *cobra.Command, deployReq *apps.CreateAppDeploymentRequest) { +func BundleDeployOverrideWithWrapper[R any](wrapError ErrorWrapper) func(*cobra.Command, *R) { + return func(deployCmd *cobra.Command, _ *R) { var opts bundleDeployOptions deployCmd.Flags().BoolVar(&opts.force, "force", false, "Force-override Git branch validation.") @@ -96,7 +95,7 @@ func BundleDeployOverrideWithWrapper(wrapError ErrorWrapper) func(*cobra.Command } err := originalRunE(cmd, args) - return wrapError(cmd, deployReq.AppName, err) + return wrapError(cmd, appNameArg(args), err) } deployCmd.Long = `Create an app deployment. diff --git a/cmd/apps/deploy_bundle_test.go b/cmd/apps/deploy_bundle_test.go index 86f0535d99c..1e6fe98dc04 100644 --- a/cmd/apps/deploy_bundle_test.go +++ b/cmd/apps/deploy_bundle_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/databricks/cli/bundle" - "github.com/databricks/databricks-sdk-go/service/apps" + apps "github.com/databricks/sdk-go/apps/v1" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -16,7 +16,7 @@ func TestBundleDeployOverrideWithWrapper(t *testing.T) { return err } - overrideFunc := BundleDeployOverrideWithWrapper(mockWrapper) + overrideFunc := BundleDeployOverrideWithWrapper[apps.CreateAppDeploymentRequest](mockWrapper) assert.NotNil(t, overrideFunc) cmd := &cobra.Command{} @@ -35,7 +35,7 @@ func TestBundleDeployOverrideFlags(t *testing.T) { cmd := &cobra.Command{} deployReq := &apps.CreateAppDeploymentRequest{} - overrideFunc := BundleDeployOverrideWithWrapper(mockWrapper) + overrideFunc := BundleDeployOverrideWithWrapper[apps.CreateAppDeploymentRequest](mockWrapper) overrideFunc(cmd, deployReq) tests := []struct { @@ -71,7 +71,7 @@ func TestBundleDeployOverrideDeprecatedAndHiddenFlags(t *testing.T) { cmd := &cobra.Command{} deployReq := &apps.CreateAppDeploymentRequest{} - overrideFunc := BundleDeployOverrideWithWrapper(mockWrapper) + overrideFunc := BundleDeployOverrideWithWrapper[apps.CreateAppDeploymentRequest](mockWrapper) overrideFunc(cmd, deployReq) computeID := cmd.Flags().Lookup("compute-id") @@ -91,7 +91,7 @@ func TestBundleDeployOverrideClusterIDShorthand(t *testing.T) { cmd := &cobra.Command{} deployReq := &apps.CreateAppDeploymentRequest{} - overrideFunc := BundleDeployOverrideWithWrapper(mockWrapper) + overrideFunc := BundleDeployOverrideWithWrapper[apps.CreateAppDeploymentRequest](mockWrapper) overrideFunc(cmd, deployReq) flag := cmd.Flags().Lookup("cluster-id") @@ -107,7 +107,7 @@ func TestBundleDeployOverrideHelpText(t *testing.T) { cmd := &cobra.Command{} deployReq := &apps.CreateAppDeploymentRequest{} - overrideFunc := BundleDeployOverrideWithWrapper(mockWrapper) + overrideFunc := BundleDeployOverrideWithWrapper[apps.CreateAppDeploymentRequest](mockWrapper) overrideFunc(cmd, deployReq) assert.NotEmpty(t, cmd.Long) @@ -202,7 +202,7 @@ func TestApplyDeployFlags(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { cmd := &cobra.Command{Use: "deploy"} - BundleDeployOverrideWithWrapper(noopWrapper)(cmd, &apps.CreateAppDeploymentRequest{}) + BundleDeployOverrideWithWrapper[apps.CreateAppDeploymentRequest](noopWrapper)(cmd, &apps.CreateAppDeploymentRequest{}) require.NoError(t, cmd.ParseFlags(tc.args)) b := &bundle.Bundle{} @@ -229,9 +229,9 @@ func TestBundleDeployOverrideErrorWrapping(t *testing.T) { return errors.New("api error") }, } - deployReq := &apps.CreateAppDeploymentRequest{AppName: "test-app"} + deployReq := &apps.CreateAppDeploymentRequest{AppName: new("test-app")} - overrideFunc := BundleDeployOverrideWithWrapper(mockWrapper) + overrideFunc := BundleDeployOverrideWithWrapper[apps.CreateAppDeploymentRequest](mockWrapper) overrideFunc(cmd, deployReq) err := cmd.RunE(cmd, []string{"test-app"}) diff --git a/cmd/apps/dev.go b/cmd/apps/dev.go index db9adee6252..d08d9201da8 100644 --- a/cmd/apps/dev.go +++ b/cmd/apps/dev.go @@ -17,11 +17,12 @@ import ( "github.com/databricks/cli/bundle/phases" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/apps/prompt" "github.com/databricks/cli/libs/apps/vite" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/utils" "github.com/spf13/cobra" ) @@ -64,7 +65,7 @@ func detectAppNameFromBundle(cmd *cobra.Command) string { // If there's exactly one app, return its name if len(bundleApps) == 1 { for _, app := range bundleApps { - return app.Name + return utils.Deref(app.Name) } } @@ -185,7 +186,7 @@ Examples: }) if err != nil { // The Apps API reports both a never-created and a deleted app with a 404. - if errors.Is(err, apierr.ErrNotFound) { + if apierrs.Is(err, apierrs.ErrNotFound) { return fmt.Errorf("application '%s' has not been deployed yet. Run `databricks apps deploy` to deploy and then try again", appName) } return fmt.Errorf("failed to get app domain: %w", err) diff --git a/cmd/apps/import.go b/cmd/apps/import.go index 355c51c690e..1f5feacb0ad 100644 --- a/cmd/apps/import.go +++ b/cmd/apps/import.go @@ -12,8 +12,6 @@ import ( "slices" "strings" - "go.yaml.in/yaml/v3" - "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/generate" "github.com/databricks/cli/bundle/phases" @@ -31,12 +29,15 @@ import ( "github.com/databricks/cli/libs/dyn/yamlsaver" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/logdiag" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/apps/v1" "github.com/databricks/cli/libs/textutil" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/apps" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/workspaceapi" + sdkapps "github.com/databricks/sdk-go/apps/v1" + sdkscim "github.com/databricks/sdk-go/scim/v1" "github.com/spf13/cobra" + "go.yaml.in/yaml/v3" ) func newImportCommand() *cobra.Command { @@ -90,28 +91,29 @@ Examples: w := cmdctx.WorkspaceClient(ctx) // Get current user to filter apps - me, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + me, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) if err != nil { return fmt.Errorf("failed to get current user: %w", err) } - currentUserEmail := strings.ToLower(me.UserName) + currentUserEmail := strings.ToLower(utils.Deref(me.UserName)) // If no app name provided, list apps and let user select if name == "" { // List all apps spinner := cmdio.NewSpinner(ctx) spinner.Update("Loading available apps...") - allApps := w.Apps.List(ctx, apps.ListAppsRequest{}) - // Collect all apps var appList []apps.App - for allApps.HasNext(ctx) { - app, err := allApps.Next(ctx) + for sdkApp, err := range w.Apps.ListAppsIter(ctx, sdkapps.ListAppsRequest{}) { + var app *apps.App + if err == nil { + app, err = apps.AppFromSDK(sdkApp) + } if err != nil { spinner.Close() return fmt.Errorf("failed to iterate apps: %w", err) } - appList = append(appList, app) + appList = append(appList, *app) } spinner.Close() @@ -121,21 +123,21 @@ Examples: // Sort apps: owned by current user first slices.SortFunc(appList, func(a, b apps.App) int { - aOwned := strings.ToLower(a.Creator) == currentUserEmail - bOwned := strings.ToLower(b.Creator) == currentUserEmail + aOwned := strings.ToLower(utils.Deref(a.Creator)) == currentUserEmail + bOwned := strings.ToLower(utils.Deref(b.Creator)) == currentUserEmail if aOwned != bOwned { if aOwned { return -1 } return 1 } - return cmp.Compare(a.Name, b.Name) + return cmp.Compare(utils.Deref(a.Name), utils.Deref(b.Name)) }) // Build selection map names := make(map[string]string) for _, app := range appList { - owner := app.Creator + owner := utils.Deref(app.Creator) if owner == "" { owner = "unknown" } @@ -143,8 +145,8 @@ Examples: if idx := strings.Index(owner, "@"); idx > 0 { owner = owner[:idx] } - label := fmt.Sprintf("%s (owner: %s)", app.Name, owner) - names[label] = app.Name + label := fmt.Sprintf("%s (owner: %s)", utils.Deref(app.Name), owner) + names[label] = utils.Deref(app.Name) } // Prompt user to select @@ -197,7 +199,7 @@ Examples: cmdio.LogString(ctx, "Cleaning up previous app folder") } - err = w.Workspace.Delete(ctx, workspace.Delete{ + err = w.Workspace.Delete(ctx, workspaceapi.Delete{ Path: oldSourceCodePath, Recursive: true, }) @@ -231,30 +233,34 @@ Examples: return cmd } -func runImport(ctx context.Context, w *databricks.WorkspaceClient, appName, outputDir string, oldSourceCodePath *string, forceImport bool, currentUserEmail string, quiet bool) error { +func runImport(ctx context.Context, w *sdkclients.Clients, appName, outputDir string, oldSourceCodePath *string, forceImport bool, currentUserEmail string, quiet bool) error { // Step 1: Load the app from workspace if !quiet { cmdio.LogString(ctx, fmt.Sprintf("Loading app '%s' configuration", appName)) } - app, err := w.Apps.Get(ctx, apps.GetAppRequest{Name: appName}) + sdkApp, err := w.Apps.GetApp(ctx, sdkapps.GetAppRequest{Name: new(appName)}) + if err != nil { + return fmt.Errorf("failed to get app: %w", err) + } + app, err := apps.AppFromSDK(sdkApp) if err != nil { return fmt.Errorf("failed to get app: %w", err) } // Save the old source code path for cleanup - *oldSourceCodePath = app.DefaultSourceCodePath + *oldSourceCodePath = utils.Deref(app.DefaultSourceCodePath) // Check if the app's source code path is inside a .bundle folder (indicating it was already imported) - alreadyImported := app.DefaultSourceCodePath != "" && strings.Contains(app.DefaultSourceCodePath, "/.bundle/") + alreadyImported := utils.Deref(app.DefaultSourceCodePath) != "" && strings.Contains(utils.Deref(app.DefaultSourceCodePath), "/.bundle/") if alreadyImported { if !forceImport { - return fmt.Errorf("app '%s' appears to have already been imported (workspace path '%s' is inside a .bundle folder). Use --force-import to import anyway", appName, app.DefaultSourceCodePath) + return fmt.Errorf("app '%s' appears to have already been imported (workspace path '%s' is inside a .bundle folder). Use --force-import to import anyway", appName, utils.Deref(app.DefaultSourceCodePath)) } // Check if the app is owned by the current user - appOwner := strings.ToLower(app.Creator) + appOwner := strings.ToLower(utils.Deref(app.Creator)) if appOwner != currentUserEmail { - return fmt.Errorf("--force-import can only be used for apps you own. App '%s' is owned by '%s'", appName, app.Creator) + return fmt.Errorf("--force-import can only be used for apps you own. App '%s' is owned by '%s'", appName, utils.Deref(app.Creator)) } if !quiet { @@ -322,12 +328,12 @@ func runImport(ctx context.Context, w *databricks.WorkspaceClient, appName, outp } // Verify the app exists - exists, err := resource.Exists(ctx, b.WorkspaceClient(ctx), app.Name) + exists, err := resource.Exists(ctx, b.WorkspaceClient(ctx), utils.Deref(app.Name)) if err != nil { return fmt.Errorf("failed to verify app exists: %w", err) } if !exists { - return fmt.Errorf("app '%s' no longer exists in workspace", app.Name) + return fmt.Errorf("app '%s' no longer exists in workspace", utils.Deref(app.Name)) } // Bind the resource @@ -335,14 +341,14 @@ func runImport(ctx context.Context, w *databricks.WorkspaceClient, appName, outp AutoApprove: true, Group: resource.ResourceDescription().PluralName, ResourceKey: appKey, - ResourceId: app.Name, + ResourceId: utils.Deref(app.Name), }, stateDesc) if logdiag.HasError(ctx) { return errors.New("failed to bind resource") } if !quiet { - cmdio.LogString(ctx, fmt.Sprintf("Successfully bound to app '%s'", app.Name)) + cmdio.LogString(ctx, fmt.Sprintf("Successfully bound to app '%s'", utils.Deref(app.Name))) } } else if !quiet { cmdio.LogString(ctx, "Skipping bind step (app already imported)") @@ -416,7 +422,7 @@ func runImport(ctx context.Context, w *databricks.WorkspaceClient, appName, outp return nil } -func generateAppBundle(ctx context.Context, w *databricks.WorkspaceClient, app *apps.App, quiet bool) (string, error) { +func generateAppBundle(ctx context.Context, w *sdkclients.Clients, app *apps.App, quiet bool) (string, error) { // Use constant "app" as the resource key appKey := "app" @@ -425,9 +431,8 @@ func generateAppBundle(ctx context.Context, w *databricks.WorkspaceClient, app * downloader := generate.NewDownloader(w, sourceDir, ".") // Download app source code if it exists - sourceCodePath := app.DefaultSourceCodePath - if sourceCodePath != "" { - err := downloader.MarkDirectoryForDownload(ctx, &sourceCodePath) + if utils.Deref(app.DefaultSourceCodePath) != "" { + err := downloader.MarkDirectoryForDownload(ctx, app.DefaultSourceCodePath) if err != nil { return "", fmt.Errorf("failed to mark directory for download: %w", err) } @@ -458,7 +463,7 @@ func generateAppBundle(ctx context.Context, w *databricks.WorkspaceClient, app * // Create the bundle configuration with explicit line numbers to control ordering // Use the app name for the bundle name - bundleName := textutil.NormalizeString(app.Name) + bundleName := textutil.NormalizeString(utils.Deref(app.Name)) bundleConfig := map[string]dyn.Value{ "bundle": dyn.NewValue(map[string]dyn.Value{ "name": dyn.NewValue(bundleName, []diag.Location{{Line: 1}}), diff --git a/cmd/apps/logs.go b/cmd/apps/logs.go index 777a9f3621b..aed7b2fa240 100644 --- a/cmd/apps/logs.go +++ b/cmd/apps/logs.go @@ -21,8 +21,9 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/utils" "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/service/apps" + apps "github.com/databricks/sdk-go/apps/v1" "github.com/gorilla/websocket" "github.com/spf13/cobra" ) @@ -104,15 +105,15 @@ Examples: name := args[0] w := cmdctx.WorkspaceClient(ctx) - app, err := w.Apps.Get(ctx, apps.GetAppRequest{Name: name}) + app, err := w.Apps.GetApp(ctx, apps.GetAppRequest{Name: new(name)}) if err != nil { return err } - if app.Url == "" { + if utils.Deref(app.Url) == "" { return fmt.Errorf("app %s does not have a public URL; deploy and start it before streaming logs", name) } - wsURL, err := buildLogsURL(app.Url) + wsURL, err := buildLogsURL(*app.Url) if err != nil { return err } @@ -141,7 +142,7 @@ Examples: } appStatusChecker := func(ctx context.Context) error { - app, err := w.Apps.Get(ctx, apps.GetAppRequest{Name: name}) + app, err := w.Apps.GetApp(ctx, apps.GetAppRequest{Name: new(name)}) if err != nil { return err } @@ -150,7 +151,7 @@ Examples: } // Check if app is in a terminal/stopped state switch app.ComputeStatus.State { - case apps.ComputeStateStopped, apps.ComputeStateDeleting, apps.ComputeStateError: + case apps.ComputeStatus_ComputeState_Stopped, apps.ComputeStatus_ComputeState_Deleting, apps.ComputeStatus_ComputeState_Error: return fmt.Errorf("app is %s", app.ComputeStatus.State) default: // App is running or transitioning - continue streaming @@ -181,7 +182,7 @@ Examples: return logstream.Run(ctx, logstream.Config{ Dialer: newLogStreamDialer(cfg), URL: wsURL, - Origin: normalizeOrigin(app.Url), + Origin: normalizeOrigin(utils.Deref(app.Url)), Token: initialToken.AccessToken, TokenProvider: tokenProvider, AppStatusChecker: appStatusChecker, diff --git a/cmd/apps/run_local.go b/cmd/apps/run_local.go index d9671276f0f..74cac498187 100644 --- a/cmd/apps/run_local.go +++ b/cmd/apps/run_local.go @@ -17,8 +17,8 @@ import ( "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdkclients" + sdkscim "github.com/databricks/sdk-go/scim/v1" "github.com/spf13/cobra" ) @@ -111,13 +111,13 @@ func startAppProcess(cmd *cobra.Command, config *runlocal.Config, app runlocal.A return appCmd, nil } -func setupProxy(ctx context.Context, cmd *cobra.Command, config *runlocal.Config, w *databricks.WorkspaceClient, port int, debug bool) error { +func setupProxy(ctx context.Context, cmd *cobra.Command, config *runlocal.Config, w *sdkclients.Clients, port int, debug bool) error { proxy, err := appproxy.New(ctx, config.AppURL) if err != nil { return err } - me, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + me, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) if err != nil { return err } diff --git a/cmd/apps/run_local_test.go b/cmd/apps/run_local_test.go index 94a0b56ec70..546f0dfe6c5 100644 --- a/cmd/apps/run_local_test.go +++ b/cmd/apps/run_local_test.go @@ -8,10 +8,9 @@ import ( "time" "github.com/databricks/cli/libs/apps/runlocal" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/httpfixtures" + "github.com/databricks/cli/libs/sdkclients" "github.com/spf13/cobra" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) @@ -21,11 +20,17 @@ func TestSetupProxyPortInUse(t *testing.T) { defer ln.Close() port := ln.Addr().(*net.TCPAddr).Port - m := mocks.NewMockWorkspaceClient(t) - m.GetMockCurrentUserAPI().EXPECT().Me(mock.Anything, mock.Anything).Return(&iam.User{UserName: "test-user"}, nil) + cfg, _ := httpfixtures.Fixtures{{ + Method: "GET", + Resource: "/api/2.0/preview/scim/v2/Me", + Response: `{"userName":"test-user"}`, + ReuseRequest: true, + }}.Config(t) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) config := runlocal.NewConfig("https://workspace.databricks.test", "123", t.TempDir(), runlocal.DEFAULT_HOST, runlocal.DEFAULT_PORT) - err = setupProxy(t.Context(), &cobra.Command{}, config, m.WorkspaceClient, port, false) + err = setupProxy(t.Context(), &cobra.Command{}, config, w, port, false) require.ErrorContains(t, err, "failed to start app proxy") } diff --git a/cmd/apps/start_bundle.go b/cmd/apps/start_bundle.go index 8e7225ee948..c8c69fadf09 100644 --- a/cmd/apps/start_bundle.go +++ b/cmd/apps/start_bundle.go @@ -7,14 +7,14 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/apps" + sdkapps "github.com/databricks/sdk-go/apps/v1" "github.com/spf13/cobra" ) // BundleStartOverrideWithWrapper creates a start override function that uses // the provided error wrapper for API fallback errors. -func BundleStartOverrideWithWrapper(wrapError ErrorWrapper) func(*cobra.Command, *apps.StartAppRequest) { - return func(startCmd *cobra.Command, startReq *apps.StartAppRequest) { +func BundleStartOverrideWithWrapper[R any](wrapError ErrorWrapper) func(*cobra.Command, *R) { + return func(startCmd *cobra.Command, _ *R) { makeArgsOptionalWithBundle(startCmd, "start [NAME]") originalRunE := startCmd.RunE @@ -28,13 +28,11 @@ func BundleStartOverrideWithWrapper(wrapError ErrorWrapper) func(*cobra.Command, return err } if fromBundle { - startReq.Name = appName - if outputFormat == flags.OutputText { cmdio.LogString(ctx, fmt.Sprintf("Starting app '%s' from project configuration", appName)) w := cmdctx.WorkspaceClient(ctx) - wait, err := w.Apps.Start(ctx, *startReq) + _, err := w.Apps.StartApp(ctx, sdkapps.StartAppRequest{Name: new(appName)}) if err != nil { handled, handledErr := handleAlreadyInStateError(ctx, cmd, err, appName, []string{"ACTIVE state", "already"}, "is deployed", wrapError) if handled { @@ -43,16 +41,16 @@ func BundleStartOverrideWithWrapper(wrapError ErrorWrapper) func(*cobra.Command, return wrapError(cmd, appName, err) } - var appInfo *apps.App + var appInfo *sdkapps.App if shouldWaitForCompletion(cmd) { spinner := cmdio.NewSpinner(ctx) - appInfo, err = wait.OnProgress(createAppProgressCallback(spinner)).GetWithTimeout(getWaitTimeout(cmd)) + appInfo, err = waitForAppCompute(ctx, w, appName, sdkapps.ComputeStatus_ComputeState_Active, getWaitTimeout(cmd), createAppProgressCallback(spinner)) spinner.Close() if err != nil { return wrapError(cmd, appName, err) } } else { - appInfo, err = w.Apps.Get(ctx, apps.GetAppRequest{Name: appName}) + appInfo, err = w.Apps.GetApp(ctx, sdkapps.GetAppRequest{Name: new(appName)}) if err != nil { return wrapError(cmd, appName, err) } @@ -70,12 +68,12 @@ func BundleStartOverrideWithWrapper(wrapError ErrorWrapper) func(*cobra.Command, err := originalRunE(cmd, args) if err != nil { - handled, handledErr := handleAlreadyInStateError(ctx, cmd, err, startReq.Name, []string{"ACTIVE state", "already"}, "is deployed", wrapError) + handled, handledErr := handleAlreadyInStateError(ctx, cmd, err, appNameArg(args), []string{"ACTIVE state", "already"}, "is deployed", wrapError) if handled { return handledErr } } - return wrapError(cmd, startReq.Name, err) + return wrapError(cmd, appNameArg(args), err) } updateCommandHelp(startCmd, "Start", "start") diff --git a/cmd/apps/start_bundle_test.go b/cmd/apps/start_bundle_test.go index e7287d4950c..8b7abed6f0e 100644 --- a/cmd/apps/start_bundle_test.go +++ b/cmd/apps/start_bundle_test.go @@ -3,7 +3,7 @@ package apps import ( "testing" - "github.com/databricks/databricks-sdk-go/service/apps" + apps "github.com/databricks/sdk-go/apps/v1" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" ) @@ -13,7 +13,7 @@ func TestBundleStartOverrideWithWrapper(t *testing.T) { return err } - overrideFunc := BundleStartOverrideWithWrapper(mockWrapper) + overrideFunc := BundleStartOverrideWithWrapper[apps.StartAppRequest](mockWrapper) assert.NotNil(t, overrideFunc) cmd := &cobra.Command{} @@ -32,7 +32,7 @@ func TestBundleStartOverrideHelpText(t *testing.T) { cmd := &cobra.Command{} startReq := &apps.StartAppRequest{} - overrideFunc := BundleStartOverrideWithWrapper(mockWrapper) + overrideFunc := BundleStartOverrideWithWrapper[apps.StartAppRequest](mockWrapper) overrideFunc(cmd, startReq) assert.NotEmpty(t, cmd.Long) diff --git a/cmd/apps/stop_bundle.go b/cmd/apps/stop_bundle.go index 6f3916ac622..b90040c0cad 100644 --- a/cmd/apps/stop_bundle.go +++ b/cmd/apps/stop_bundle.go @@ -7,14 +7,14 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/apps" + sdkapps "github.com/databricks/sdk-go/apps/v1" "github.com/spf13/cobra" ) // BundleStopOverrideWithWrapper creates a stop override function that uses // the provided error wrapper for API fallback errors. -func BundleStopOverrideWithWrapper(wrapError ErrorWrapper) func(*cobra.Command, *apps.StopAppRequest) { - return func(stopCmd *cobra.Command, stopReq *apps.StopAppRequest) { +func BundleStopOverrideWithWrapper[R any](wrapError ErrorWrapper) func(*cobra.Command, *R) { + return func(stopCmd *cobra.Command, _ *R) { makeArgsOptionalWithBundle(stopCmd, "stop [NAME]") originalRunE := stopCmd.RunE @@ -28,13 +28,11 @@ func BundleStopOverrideWithWrapper(wrapError ErrorWrapper) func(*cobra.Command, return err } if fromBundle { - stopReq.Name = appName - if outputFormat == flags.OutputText { cmdio.LogString(ctx, fmt.Sprintf("Stopping app '%s' from project configuration", appName)) w := cmdctx.WorkspaceClient(ctx) - wait, err := w.Apps.Stop(ctx, *stopReq) + _, err := w.Apps.StopApp(ctx, sdkapps.StopAppRequest{Name: new(appName)}) if err != nil { handled, handledErr := handleAlreadyInStateError(ctx, cmd, err, appName, []string{"STOPPED state", "already"}, "stopped", wrapError) if handled { @@ -43,16 +41,16 @@ func BundleStopOverrideWithWrapper(wrapError ErrorWrapper) func(*cobra.Command, return wrapError(cmd, appName, err) } - var appInfo *apps.App + var appInfo *sdkapps.App if shouldWaitForCompletion(cmd) { spinner := cmdio.NewSpinner(ctx) - appInfo, err = wait.OnProgress(createAppProgressCallback(spinner)).GetWithTimeout(getWaitTimeout(cmd)) + appInfo, err = waitForAppCompute(ctx, w, appName, sdkapps.ComputeStatus_ComputeState_Stopped, getWaitTimeout(cmd), createAppProgressCallback(spinner)) spinner.Close() if err != nil { return wrapError(cmd, appName, err) } } else { - appInfo, err = w.Apps.Get(ctx, apps.GetAppRequest{Name: appName}) + appInfo, err = w.Apps.GetApp(ctx, sdkapps.GetAppRequest{Name: new(appName)}) if err != nil { return wrapError(cmd, appName, err) } @@ -69,12 +67,12 @@ func BundleStopOverrideWithWrapper(wrapError ErrorWrapper) func(*cobra.Command, err := originalRunE(cmd, args) if err != nil { - handled, handledErr := handleAlreadyInStateError(ctx, cmd, err, stopReq.Name, []string{"STOPPED state", "already"}, "stopped", wrapError) + handled, handledErr := handleAlreadyInStateError(ctx, cmd, err, appNameArg(args), []string{"STOPPED state", "already"}, "stopped", wrapError) if handled { return handledErr } } - return wrapError(cmd, stopReq.Name, err) + return wrapError(cmd, appNameArg(args), err) } updateCommandHelp(stopCmd, "Stop", "stop") diff --git a/cmd/apps/stop_bundle_test.go b/cmd/apps/stop_bundle_test.go index 7d82905548b..e6ada50cf17 100644 --- a/cmd/apps/stop_bundle_test.go +++ b/cmd/apps/stop_bundle_test.go @@ -3,7 +3,7 @@ package apps import ( "testing" - "github.com/databricks/databricks-sdk-go/service/apps" + apps "github.com/databricks/sdk-go/apps/v1" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" ) @@ -13,7 +13,7 @@ func TestBundleStopOverrideWithWrapper(t *testing.T) { return err } - overrideFunc := BundleStopOverrideWithWrapper(mockWrapper) + overrideFunc := BundleStopOverrideWithWrapper[apps.StopAppRequest](mockWrapper) assert.NotNil(t, overrideFunc) cmd := &cobra.Command{} @@ -32,7 +32,7 @@ func TestBundleStopOverrideHelpText(t *testing.T) { cmd := &cobra.Command{} stopReq := &apps.StopAppRequest{} - overrideFunc := BundleStopOverrideWithWrapper(mockWrapper) + overrideFunc := BundleStopOverrideWithWrapper[apps.StopAppRequest](mockWrapper) overrideFunc(cmd, stopReq) assert.NotEmpty(t, cmd.Long) diff --git a/cmd/apps/wait.go b/cmd/apps/wait.go new file mode 100644 index 00000000000..1473a7d9a5c --- /dev/null +++ b/cmd/apps/wait.go @@ -0,0 +1,56 @@ +package apps + +import ( + "context" + "fmt" + "time" + + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + sdkapps "github.com/databricks/sdk-go/apps/v1" +) + +// waitForAppCompute polls the app until its compute reaches target, calling +// callback with every polled state. Reaching ERROR, or STOPPED when waiting +// for ACTIVE, fails the wait. sdk-go waiters report no progress, so the +// commands that show a spinner poll here instead. +func waitForAppCompute(ctx context.Context, w *sdkclients.Clients, name string, target sdkapps.ComputeStatus_ComputeState, timeout time.Duration, callback func(*sdkapps.App)) (*sdkapps.App, error) { + ctx, cancel := context.WithTimeout(ctx, timeout) + defer cancel() + + var lastStatus string + for attempt := 1; ; attempt++ { + app, err := w.Apps.GetApp(ctx, sdkapps.GetAppRequest{Name: new(name)}) + if err != nil { + if ctx.Err() != nil && lastStatus != "" { + return nil, fmt.Errorf("timed out after %s: %s", timeout, lastStatus) + } + return nil, err + } + if callback != nil { + callback(app) + } + var status sdkapps.ComputeStatus_ComputeState + if app.ComputeStatus != nil { + status = app.ComputeStatus.State + } + statusMessage := fmt.Sprintf("current status: %s", status) + if app.ComputeStatus != nil { + statusMessage = utils.Deref(app.ComputeStatus.Message) + } + switch { + case status == target: + return app, nil + case status == sdkapps.ComputeStatus_ComputeState_Error, + status == sdkapps.ComputeStatus_ComputeState_Stopped && target == sdkapps.ComputeStatus_ComputeState_Active: + return nil, fmt.Errorf("failed to reach %s, got %s: %s", target, status, statusMessage) + } + lastStatus = statusMessage + + select { + case <-ctx.Done(): + return nil, fmt.Errorf("timed out after %s: %s", timeout, lastStatus) + case <-time.After(min(time.Duration(attempt)*time.Second, 10*time.Second)): + } + } +} diff --git a/cmd/auth/describe.go b/cmd/auth/describe.go index a58e964de27..ab2b9f01104 100644 --- a/cmd/auth/describe.go +++ b/cmd/auth/describe.go @@ -14,9 +14,11 @@ import ( "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/service/iam" + sdkscim "github.com/databricks/sdk-go/scim/v1" + sdkworkspaces "github.com/databricks/sdk-go/workspaces/v1" "github.com/spf13/cobra" ) @@ -130,7 +132,7 @@ func getAuthStatus(cmd *cobra.Command, args []string, showSensitive bool, fn try a := cmdctx.AccountClient(ctx) // Doing a simple API call to check if the auth is valid - _, err := a.Workspaces.List(ctx) + _, err := listWorkspaces(ctx, a) if err == nil { return successAuthStatus(ctx, cmd, a.Config, showSensitive, a.Config.Username, a.Config.AccountID), nil } @@ -140,15 +142,15 @@ func getAuthStatus(cmd *cobra.Command, args []string, showSensitive bool, fn try // endpoint with the same resolved config before reporting failure. me, meErr := verifyWorkspaceAuth(ctx, a.Config) if meErr == nil { - return successAuthStatus(ctx, cmd, a.Config, showSensitive, me.UserName, ""), nil + return successAuthStatus(ctx, cmd, a.Config, showSensitive, utils.Deref(me.UserName), ""), nil } return errorAuthStatus(ctx, cmd, cfg, showSensitive, err), nil } w := cmdctx.WorkspaceClient(ctx) - me, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + me, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) if err == nil { - return successAuthStatus(ctx, cmd, w.Config, showSensitive, me.UserName, ""), nil + return successAuthStatus(ctx, cmd, w.Config, showSensitive, utils.Deref(me.UserName), ""), nil } // Account console profiles that also carry a workspace_id resolve to a @@ -169,12 +171,12 @@ func getAuthStatus(cmd *cobra.Command, args []string, showSensitive bool, fn try // workspace endpoint. The client is built over the same resolved config // pointer (config.Config must not be copied by value), without any profile // prompting. -func verifyWorkspaceAuth(ctx context.Context, cfg *config.Config) (*iam.User, error) { - w, err := databricks.NewWorkspaceClient((*databricks.Config)(cfg)) +func verifyWorkspaceAuth(ctx context.Context, cfg *config.Config) (*sdkscim.User, error) { + w, err := sdkclients.New(ctx, cfg) if err != nil { return nil, err } - return w.CurrentUser.Me(ctx, iam.MeRequest{}) + return w.Scim.Me(ctx, sdkscim.MeRequest{}) } // verifyAccountAuth checks whether cfg's credentials are accepted by the @@ -182,14 +184,24 @@ func verifyWorkspaceAuth(ctx context.Context, cfg *config.Config) (*iam.User, er // the same resolved config pointer (config.Config must not be copied by // value), without any profile prompting. func verifyAccountAuth(ctx context.Context, cfg *config.Config) error { - a, err := databricks.NewAccountClient((*databricks.Config)(cfg)) + a, err := sdkclients.New(ctx, cfg) if err != nil { return err } - _, err = a.Workspaces.List(ctx) + _, err = listWorkspaces(ctx, a) return err } +// listWorkspaces lists the workspaces of the account the clients are +// configured for. +func listWorkspaces(ctx context.Context, a *sdkclients.Clients) ([]sdkworkspaces.Workspace, error) { + resp, err := a.Workspaces.ListWorkspacesPublic(ctx, sdkworkspaces.ListWorkspacesRequest{AccountId: new(a.Config.AccountID)}) + if err != nil { + return nil, err + } + return resp.Workspaces, nil +} + // successAuthStatus reports verified credentials, with details derived from cfg. func successAuthStatus(ctx context.Context, cmd *cobra.Command, cfg *config.Config, showSensitive bool, username, accountID string) *authStatus { details := getAuthDetails(cmd, cfg, showSensitive) diff --git a/cmd/auth/describe_test.go b/cmd/auth/describe_test.go index 3d7bd62a0a1..117534526a1 100644 --- a/cmd/auth/describe_test.go +++ b/cmd/auth/describe_test.go @@ -12,13 +12,11 @@ import ( "github.com/databricks/cli/libs/auth/storage" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/databrickscfg/profile" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/httpfixtures" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) @@ -85,19 +83,14 @@ func TestResolveProfileFromHostFlag(t *testing.T) { func TestGetWorkspaceAuthStatus(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - ctx = cmdctx.SetWorkspaceClient(ctx, m.WorkspaceClient) + m := fakeClients(t, httpfixtures.Fixtures{{Method: "GET", Resource: "/api/2.0/preview/scim/v2/Me", Response: `{"userName":"test-user"}`}}) + ctx = cmdctx.SetWorkspaceClient(ctx, m) cmd := &cobra.Command{} cmd.SetContext(ctx) showSensitive := false - currentUserApi := m.GetMockCurrentUserAPI() - currentUserApi.EXPECT().Me(mock.Anything, mock.Anything).Return(&iam.User{ - UserName: "test-user", - }, nil) - cmd.Flags().String("host", "", "") cmd.Flags().String("profile", "", "") err := cmd.Flag("profile").Value.Set("my-profile") @@ -107,7 +100,7 @@ func TestGetWorkspaceAuthStatus(t *testing.T) { cfg := &config.Config{ Profile: "my-profile", } - m.WorkspaceClient.Config = cfg + m.Config = cfg t.Setenv("DATABRICKS_AUTH_TYPE", "azure-cli") err = config.ConfigAttributes.Configure(cfg) require.NoError(t, err) @@ -143,8 +136,8 @@ func TestGetWorkspaceAuthStatus(t *testing.T) { func TestGetWorkspaceAuthStatusError(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - ctx = cmdctx.SetWorkspaceClient(ctx, m.WorkspaceClient) + m := fakeClients(t, nil) + ctx = cmdctx.SetWorkspaceClient(ctx, m) cmd := &cobra.Command{} cmd.SetContext(ctx) @@ -160,7 +153,7 @@ func TestGetWorkspaceAuthStatusError(t *testing.T) { cfg := &config.Config{ Profile: "my-profile", } - m.WorkspaceClient.Config = cfg + m.Config = cfg t.Setenv("DATABRICKS_AUTH_TYPE", "azure-cli") err = config.ConfigAttributes.Configure(cfg) require.NoError(t, err) @@ -192,8 +185,8 @@ func TestGetWorkspaceAuthStatusError(t *testing.T) { func TestGetWorkspaceAuthStatusSensitive(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - ctx = cmdctx.SetWorkspaceClient(ctx, m.WorkspaceClient) + m := fakeClients(t, nil) + ctx = cmdctx.SetWorkspaceClient(ctx, m) cmd := &cobra.Command{} cmd.SetContext(ctx) @@ -209,7 +202,7 @@ func TestGetWorkspaceAuthStatusSensitive(t *testing.T) { cfg := &config.Config{ Profile: "my-profile", } - m.WorkspaceClient.Config = cfg + m.Config = cfg t.Setenv("DATABRICKS_AUTH_TYPE", "azure-cli") err = config.ConfigAttributes.Configure(cfg) require.NoError(t, err) @@ -237,8 +230,8 @@ func TestGetWorkspaceAuthStatusSensitive(t *testing.T) { func TestGetAccountAuthStatus(t *testing.T) { ctx := t.Context() - m := mocks.NewMockAccountClient(t) - ctx = cmdctx.SetAccountClient(ctx, m.AccountClient) + m := fakeClients(t, httpfixtures.Fixtures{{Method: "GET", Resource: "/api/2.0/accounts/test-account-id/workspaces", Response: `[]`}}) + ctx = cmdctx.SetAccountClient(ctx, m) cmd := &cobra.Command{} cmd.SetContext(ctx) @@ -254,14 +247,11 @@ func TestGetAccountAuthStatus(t *testing.T) { cfg := &config.Config{ Profile: "my-profile", } - m.AccountClient.Config = cfg + m.Config = cfg t.Setenv("DATABRICKS_AUTH_TYPE", "azure-cli") err = config.ConfigAttributes.Configure(cfg) require.NoError(t, err) - wsApi := m.GetMockWorkspacesAPI() - wsApi.EXPECT().List(mock.Anything).Return(nil, nil) - status, err := getAuthStatus(cmd, []string{}, showSensitive, func(cmd *cobra.Command, args []string) (*config.Config, bool, error) { err = config.ConfigAttributes.ResolveFromStringMap(cfg, map[string]string{ "account_id": "test-account-id", @@ -366,22 +356,19 @@ func TestStorageSourceLabel_NonConfigDelegatesToSource(t *testing.T) { func TestGetWorkspaceAuthStatus_U2M_PopulatesTokenStorage(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - ctx = cmdctx.SetWorkspaceClient(ctx, m.WorkspaceClient) + m := fakeClients(t, httpfixtures.Fixtures{{Method: "GET", Resource: "/api/2.0/preview/scim/v2/Me", Response: `{"userName":"u2m-user"}`}}) + ctx = cmdctx.SetWorkspaceClient(ctx, m) cmd := &cobra.Command{} cmd.SetContext(ctx) - currentUserApi := m.GetMockCurrentUserAPI() - currentUserApi.EXPECT().Me(mock.Anything, mock.Anything).Return(&iam.User{UserName: "u2m-user"}, nil) - cmd.Flags().String("host", "", "") cmd.Flags().String("profile", "", "") require.NoError(t, cmd.Flag("profile").Value.Set("u2m-profile")) cmd.Flag("profile").Changed = true cfg := &config.Config{Profile: "u2m-profile"} - m.WorkspaceClient.Config = cfg + m.Config = cfg t.Setenv(storage.EnvVar, "secure") t.Setenv("DATABRICKS_CONFIG_FILE", t.TempDir()+"/.databrickscfg") require.NoError(t, config.ConfigAttributes.Configure(cfg)) @@ -433,28 +420,26 @@ func describeVerifyServer(t *testing.T, accountID string, meStatus, listStatus i return server } -// newDescribeWorkspaceCmd wires a mocked workspace client whose Me call fails +// newDescribeWorkspaceCmd wires a fake workspace client whose Me call fails // with meErr, with cfg as its resolved configuration. -func newDescribeWorkspaceCmd(t *testing.T, cfg *config.Config, meErr error) *cobra.Command { +func newDescribeWorkspaceCmd(t *testing.T, cfg *config.Config, meErr apiError) *cobra.Command { t.Helper() - m := mocks.NewMockWorkspaceClient(t) - m.WorkspaceClient.Config = cfg - m.GetMockCurrentUserAPI().EXPECT().Me(mock.Anything, mock.Anything).Return(nil, meErr) + m := fakeClients(t, httpfixtures.Fixtures{meErr.fixture("GET", "/api/2.0/preview/scim/v2/Me")}) + m.Config = cfg cmd := newHostProfileCmd(t) - cmd.SetContext(cmdctx.SetWorkspaceClient(t.Context(), m.WorkspaceClient)) + cmd.SetContext(cmdctx.SetWorkspaceClient(t.Context(), m)) t.Setenv("DATABRICKS_CONFIG_FILE", filepath.Join(t.TempDir(), ".databrickscfg")) return cmd } -// newDescribeAccountCmd wires a mocked account client whose Workspaces.List +// newDescribeAccountCmd wires a fake account client whose Workspaces.List // call fails with listErr, with cfg as its resolved configuration. -func newDescribeAccountCmd(t *testing.T, cfg *config.Config, listErr error) *cobra.Command { +func newDescribeAccountCmd(t *testing.T, cfg *config.Config, accountID string, listErr apiError) *cobra.Command { t.Helper() - m := mocks.NewMockAccountClient(t) - m.AccountClient.Config = cfg - m.GetMockWorkspacesAPI().EXPECT().List(mock.Anything).Return(nil, listErr) + m := fakeClients(t, httpfixtures.Fixtures{listErr.fixture("GET", "/api/2.0/accounts/"+accountID+"/workspaces")}) + m.Config = cfg cmd := newHostProfileCmd(t) - cmd.SetContext(cmdctx.SetAccountClient(t.Context(), m.AccountClient)) + cmd.SetContext(cmdctx.SetAccountClient(t.Context(), m)) t.Setenv("DATABRICKS_CONFIG_FILE", filepath.Join(t.TempDir(), ".databrickscfg")) return cmd } @@ -478,7 +463,7 @@ func TestGetAuthStatusVerificationFallback(t *testing.T) { tests := []struct { name string isAccount bool - primaryErr *apierr.APIError + primaryErr apiError meStatus int listStatus int accountID string @@ -488,7 +473,7 @@ func TestGetAuthStatusVerificationFallback(t *testing.T) { }{ { name: "workspace check fails, account check succeeds", - primaryErr: &apierr.APIError{StatusCode: http.StatusBadRequest, Message: "Unable to load OAuth Config"}, + primaryErr: apiError{http.StatusBadRequest, "Unable to load OAuth Config"}, meStatus: http.StatusNotFound, listStatus: http.StatusOK, accountID: "test-acct", @@ -497,13 +482,13 @@ func TestGetAuthStatusVerificationFallback(t *testing.T) { }, { name: "no second call without an account id", - primaryErr: &apierr.APIError{StatusCode: http.StatusBadRequest, Message: "Unable to load OAuth Config"}, + primaryErr: apiError{http.StatusBadRequest, "Unable to load OAuth Config"}, wantStatus: "error", }, { name: "account check fails, workspace check succeeds", isAccount: true, - primaryErr: &apierr.APIError{StatusCode: http.StatusForbidden, Message: "This API is disabled for users without account admin status"}, + primaryErr: apiError{http.StatusForbidden, "This API is disabled for users without account admin status"}, meStatus: http.StatusOK, listStatus: http.StatusNotFound, accountID: "test-acct", @@ -512,7 +497,7 @@ func TestGetAuthStatusVerificationFallback(t *testing.T) { }, { name: "workspace branch, both checks fail", - primaryErr: &apierr.APIError{StatusCode: http.StatusBadRequest, Message: "Unable to load OAuth Config"}, + primaryErr: apiError{http.StatusBadRequest, "Unable to load OAuth Config"}, meStatus: http.StatusNotFound, listStatus: http.StatusUnauthorized, accountID: "test-acct", @@ -521,7 +506,7 @@ func TestGetAuthStatusVerificationFallback(t *testing.T) { { name: "account branch, both checks fail", isAccount: true, - primaryErr: &apierr.APIError{StatusCode: http.StatusUnauthorized, Message: "credentials expired"}, + primaryErr: apiError{http.StatusUnauthorized, "credentials expired"}, meStatus: http.StatusUnauthorized, listStatus: http.StatusNotFound, accountID: "test-acct", @@ -536,7 +521,7 @@ func TestGetAuthStatusVerificationFallback(t *testing.T) { cfg := &config.Config{} var cmd *cobra.Command if tc.isAccount { - cmd = newDescribeAccountCmd(t, cfg, tc.primaryErr) + cmd = newDescribeAccountCmd(t, cfg, tc.accountID, tc.primaryErr) } else { cmd = newDescribeWorkspaceCmd(t, cfg, tc.primaryErr) } @@ -555,7 +540,7 @@ func TestGetAuthStatusVerificationFallback(t *testing.T) { assert.Equal(t, tc.wantUsername, status.Username) assert.Equal(t, tc.wantAccountID, status.AccountID) if tc.wantStatus == "error" { - assert.ErrorIs(t, status.Error, tc.primaryErr) + assert.ErrorContains(t, status.Error, tc.primaryErr.message) } }) } @@ -563,20 +548,17 @@ func TestGetAuthStatusVerificationFallback(t *testing.T) { func TestGetWorkspaceAuthStatus_NonU2M_OmitsTokenStorage(t *testing.T) { ctx := t.Context() - m := mocks.NewMockWorkspaceClient(t) - ctx = cmdctx.SetWorkspaceClient(ctx, m.WorkspaceClient) + m := fakeClients(t, httpfixtures.Fixtures{{Method: "GET", Resource: "/api/2.0/preview/scim/v2/Me", Response: `{"userName":"pat-user"}`}}) + ctx = cmdctx.SetWorkspaceClient(ctx, m) cmd := &cobra.Command{} cmd.SetContext(ctx) - currentUserApi := m.GetMockCurrentUserAPI() - currentUserApi.EXPECT().Me(mock.Anything, mock.Anything).Return(&iam.User{UserName: "pat-user"}, nil) - cmd.Flags().String("host", "", "") cmd.Flags().String("profile", "", "") cfg := &config.Config{} - m.WorkspaceClient.Config = cfg + m.Config = cfg require.NoError(t, config.ConfigAttributes.Configure(cfg)) status, err := getAuthStatus(cmd, []string{}, false, func(cmd *cobra.Command, args []string) (*config.Config, bool, error) { @@ -591,3 +573,29 @@ func TestGetWorkspaceAuthStatus_NonU2M_OmitsTokenStorage(t *testing.T) { require.NotNil(t, status) assert.Nil(t, status.TokenStorage) } + +// fakeClients returns clients that send requests to a server for fixtures. +// Tests replace the returned Config with the config under test; the clients +// keep authenticating against the fixture server. +func fakeClients(t *testing.T, fixtures httpfixtures.Fixtures) *sdkclients.Clients { + t.Helper() + cfg, _ := fixtures.Config(t) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) + return w +} + +// apiError is an API error response a fixture returns. +type apiError struct { + status int + message string +} + +func (e apiError) fixture(method, resource string) httpfixtures.Fixture { + return httpfixtures.Fixture{ + Method: method, + Resource: resource, + Status: e.status, + Response: map[string]string{"error_code": "TEST_ERROR", "message": e.message}, + } +} diff --git a/cmd/auth/docker/docker_profile.go b/cmd/auth/docker/docker_profile.go index c616157cf33..e2615cc6710 100644 --- a/cmd/auth/docker/docker_profile.go +++ b/cmd/auth/docker/docker_profile.go @@ -10,7 +10,8 @@ import ( "github.com/databricks/cli/libs/databrickscfg/profile" "github.com/databricks/cli/libs/dockercredentials" "github.com/databricks/cli/libs/env" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/databricks-sdk-go/config" ) // dockerWorkspace holds the selected profile and its resolved workspace ID. @@ -18,7 +19,7 @@ type dockerWorkspace struct { profile profile.Profile id string executable string - client *databricks.WorkspaceClient + client *sdkclients.Clients } type dockerTarget struct { @@ -60,9 +61,9 @@ func loadDockerWorkspace(ctx context.Context, name string, region *string) (*doc if err != nil { return nil, fmt.Errorf("locate databricks executable: %w", err) } - var client *databricks.WorkspaceClient + var client *sdkclients.Clients if region == nil || p.WorkspaceID == "" || p.WorkspaceID == profile.WorkspaceIDNone { - client, err = databricks.NewWorkspaceClient(&databricks.Config{ + client, err = sdkclients.New(ctx, &config.Config{ Profile: p.Name, Host: p.Host, AccountID: p.AccountID, diff --git a/cmd/auth/login.go b/cmd/auth/login.go index 1f0ddb9b707..ee838683349 100644 --- a/cmd/auth/login.go +++ b/cmd/auth/login.go @@ -19,7 +19,8 @@ import ( "github.com/databricks/cli/libs/databrickscfg/profile" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" "github.com/databricks/databricks-sdk-go/config" "github.com/databricks/databricks-sdk-go/config/experimental/auth/authconv" "github.com/spf13/cobra" @@ -388,7 +389,7 @@ a new profile is created. // Create a workspace client to list clusters for interactive selection. // We use a custom CredentialsStrategy that wraps the token we just minted, // avoiding the need to spawn a child CLI process (which AuthType "databricks-cli" does). - w, err := databricks.NewWorkspaceClient(&databricks.Config{ + w, err := sdkclients.New(ctx, &config.Config{ Host: authArguments.Host, AccountID: authArguments.AccountID, WorkspaceID: authArguments.WorkspaceID, @@ -863,7 +864,7 @@ func promptForWorkspaceSelection(ctx context.Context, authArguments *auth.AuthAr return "", nil } - a, err := databricks.NewAccountClient(&databricks.Config{ + a, err := sdkclients.New(ctx, &config.Config{ Host: authArguments.Host, AccountID: authArguments.AccountID, Credentials: config.NewTokenSourceStrategy("login-token", authconv.AuthTokenSource(tokenSource)), @@ -872,7 +873,7 @@ func promptForWorkspaceSelection(ctx context.Context, authArguments *auth.AuthAr return "", err } - workspaces, err := a.Workspaces.List(ctx) + workspaces, err := listWorkspaces(ctx, a) if err != nil { log.Debugf(ctx, "Failed to load workspaces (this can happen if the user has no account-level access): %v", err) return promptForWorkspaceID(ctx) @@ -889,16 +890,16 @@ func promptForWorkspaceSelection(ctx context.Context, authArguments *auth.AuthAr } if len(workspaces) == 1 { - wsID := strconv.FormatInt(workspaces[0].WorkspaceId, 10) - cmdio.LogString(ctx, fmt.Sprintf("Auto-selected workspace %q (%s)", workspaces[0].WorkspaceName, wsID)) + wsID := strconv.FormatInt(utils.Deref(workspaces[0].WorkspaceId), 10) + cmdio.LogString(ctx, fmt.Sprintf("Auto-selected workspace %q (%s)", utils.Deref(workspaces[0].WorkspaceName), wsID)) return wsID, nil } items := make([]cmdio.Tuple, 0, len(workspaces)+1) for _, ws := range workspaces { items = append(items, cmdio.Tuple{ - Name: ws.WorkspaceName, - Id: strconv.FormatInt(ws.WorkspaceId, 10), + Name: utils.Deref(ws.WorkspaceName), + Id: strconv.FormatInt(utils.Deref(ws.WorkspaceId), 10), }) } // Allow skipping workspace selection for account-level access. diff --git a/cmd/auth/profiles.go b/cmd/auth/profiles.go index e65b11371b7..8df03b24d3b 100644 --- a/cmd/auth/profiles.go +++ b/cmd/auth/profiles.go @@ -14,9 +14,9 @@ import ( "github.com/databricks/cli/libs/databrickscfg/profile" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/service/iam" + sdkscim "github.com/databricks/sdk-go/scim/v1" "github.com/spf13/cobra" "gopkg.in/ini.v1" ) @@ -94,11 +94,11 @@ func (c *profileMetadata) Load(ctx context.Context, configFilePath string, skipV switch configType { case config.AccountConfig: - a, err := databricks.NewAccountClient((*databricks.Config)(cfg)) + a, err := sdkclients.New(ctx, cfg) if err != nil { return } - _, err = a.Workspaces.List(callCtx) + _, err = listWorkspaces(callCtx, a) c.Host = cfg.Host c.AuthType = cfg.AuthType if err != nil { @@ -106,11 +106,11 @@ func (c *profileMetadata) Load(ctx context.Context, configFilePath string, skipV } c.Valid = true case config.WorkspaceConfig: - w, err := databricks.NewWorkspaceClient((*databricks.Config)(cfg)) + w, err := sdkclients.New(ctx, cfg) if err != nil { return } - _, err = w.CurrentUser.Me(callCtx, iam.MeRequest{}) + _, err = w.Scim.Me(callCtx, sdkscim.MeRequest{}) c.Host = cfg.Host c.AuthType = cfg.AuthType if err != nil { diff --git a/cmd/bundle/generate/alert.go b/cmd/bundle/generate/alert.go index cb78b24de1e..96ff7531cb5 100644 --- a/cmd/bundle/generate/alert.go +++ b/cmd/bundle/generate/alert.go @@ -15,10 +15,12 @@ import ( "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/yamlsaver" "github.com/databricks/cli/libs/logdiag" + "github.com/databricks/cli/libs/sdktypes/alerts/v2" "github.com/databricks/cli/libs/textutil" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/sql" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/workspaceapi" + sdkalerts "github.com/databricks/sdk-go/alerts/v2" + "github.com/databricks/sdk-go/core/apierr" "github.com/spf13/cobra" "go.yaml.in/yaml/v3" ) @@ -73,19 +75,23 @@ After generation, you can deploy this alert to other targets using: w := b.WorkspaceClient(ctx) // Get alert from Databricks - alert, err := w.AlertsV2.GetAlert(ctx, sql.GetAlertV2Request{Id: alertID}) + sdkAlert, err := w.Alerts.GetAlert(ctx, sdkalerts.GetAlertRequest{Id: new(alertID)}) if err != nil { // Check if it's a not found error to provide a better message - if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.StatusCode == http.StatusNotFound { + if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.HTTPStatusCode() == http.StatusNotFound { return fmt.Errorf("alert with ID %s not found", alertID) } return err } + alert, err := alerts.AlertFromSDK(sdkAlert) + if err != nil { + return err + } // Calculate paths alertKey := cmd.Flag("key").Value.String() if alertKey == "" { - alertKey = textutil.NormalizeString(alert.DisplayName) + alertKey = textutil.NormalizeString(utils.Deref(alert.DisplayName)) } // Make paths absolute if they aren't already @@ -108,8 +114,8 @@ After generation, you can deploy this alert to other targets using: alertPath := filepath.Join(sourceDir, alertBasename) // remote alert path - remoteAlertPath := path.Join(alert.ParentPath, alert.DisplayName+".dbalert.json") - resp, err := w.Workspace.Export(ctx, workspace.ExportRequest{ + remoteAlertPath := path.Join(utils.Deref(alert.ParentPath), utils.Deref(alert.DisplayName)+".dbalert.json") + resp, err := w.Workspace.Export(ctx, workspaceapi.ExportRequest{ Path: remoteAlertPath, }) if err != nil { diff --git a/cmd/bundle/generate/app.go b/cmd/bundle/generate/app.go index bec005408cd..7111686f33e 100644 --- a/cmd/bundle/generate/app.go +++ b/cmd/bundle/generate/app.go @@ -11,8 +11,10 @@ import ( "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/yamlsaver" "github.com/databricks/cli/libs/logdiag" + "github.com/databricks/cli/libs/sdktypes/apps/v1" "github.com/databricks/cli/libs/textutil" - "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/cli/libs/utils" + sdkapps "github.com/databricks/sdk-go/apps/v1" "github.com/spf13/cobra" ) @@ -72,14 +74,18 @@ per target environment.`, w := b.WorkspaceClient(ctx) cmdio.LogString(ctx, fmt.Sprintf("Loading app '%s' configuration", appName)) - app, err := w.Apps.Get(ctx, apps.GetAppRequest{Name: appName}) + sdkApp, err := w.Apps.GetApp(ctx, sdkapps.GetAppRequest{Name: new(appName)}) + if err != nil { + return err + } + app, err := apps.AppFromSDK(sdkApp) if err != nil { return err } downloader := generate.NewDownloader(w, sourceDir, configDir) - sourceCodePath := app.DefaultSourceCodePath + sourceCodePath := utils.Deref(app.DefaultSourceCodePath) // If the source code path is not set, we don't need to download anything. // This is the case for apps that are not yet deployed. A git-backed app // keeps its source in Git rather than the workspace, so there is nothing @@ -104,7 +110,7 @@ per target environment.`, appKey := cmd.Flag("key").Value.String() if appKey == "" { - appKey = textutil.NormalizeString(app.Name) + appKey = textutil.NormalizeString(utils.Deref(app.Name)) } result := map[string]dyn.Value{ @@ -133,7 +139,7 @@ per target environment.`, warnIfNotIncluded(ctx, b, filename) if bind { - return deployment.BindResource(cmd, appKey, app.Name, true, false, true) + return deployment.BindResource(cmd, appKey, utils.Deref(app.Name), true, false, true) } return nil diff --git a/cmd/bundle/generate/dashboard.go b/cmd/bundle/generate/dashboard.go index 9c4be81b391..c34018b751f 100644 --- a/cmd/bundle/generate/dashboard.go +++ b/cmd/bundle/generate/dashboard.go @@ -20,16 +20,18 @@ import ( "github.com/databricks/cli/bundle/resources" "github.com/databricks/cli/cmd/bundle/deployment" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/yamlsaver" "github.com/databricks/cli/libs/logdiag" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/lakeview/v1" "github.com/databricks/cli/libs/textutil" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/dashboards" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/workspaceapi" + sdklakeview "github.com/databricks/sdk-go/lakeview/v1" "github.com/spf13/cobra" "go.yaml.in/yaml/v3" ) @@ -82,13 +84,13 @@ func (d *dashboard) resolveFromPath(ctx context.Context, b *bundle.Bundle) strin w := b.WorkspaceClient(ctx) obj, err := w.Workspace.GetStatusByPath(ctx, d.existingPath) if err != nil { - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { logdiag.LogError(ctx, fmt.Errorf("dashboard %q not found", path.Base(d.existingPath))) return "" } // Emit a more descriptive error message for legacy dashboards. - if errors.Is(err, apierr.ErrBadRequest) && strings.HasPrefix(err.Error(), "dbsqlDashboard ") { + if apierrs.Is(err, apierrs.ErrBadRequest) && strings.HasPrefix(apierrs.Message(err), "dbsqlDashboard ") { logdiag.LogDiag(ctx, diag.Diagnostic{ Severity: diag.Error, Summary: fmt.Sprintf("dashboard %q is a legacy dashboard", path.Base(d.existingPath)), @@ -105,7 +107,7 @@ func (d *dashboard) resolveFromPath(ctx context.Context, b *bundle.Bundle) strin return "" } - if obj.ObjectType != workspace.ObjectTypeDashboard { + if obj.ObjectType != workspaceapi.ObjectTypeDashboard { found := strings.ToLower(obj.ObjectType.String()) logdiag.LogDiag(ctx, diag.Diagnostic{ Severity: diag.Error, @@ -127,9 +129,9 @@ func (d *dashboard) resolveFromPath(ctx context.Context, b *bundle.Bundle) strin func (d *dashboard) resolveFromID(ctx context.Context, b *bundle.Bundle) string { w := b.WorkspaceClient(ctx) - obj, err := w.Lakeview.GetByDashboardId(ctx, d.existingID) + obj, err := getDashboard(ctx, w, d.existingID) if err != nil { - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { logdiag.LogError(ctx, fmt.Errorf("dashboard with ID %s not found", d.existingID)) return "" } @@ -137,7 +139,7 @@ func (d *dashboard) resolveFromID(ctx context.Context, b *bundle.Bundle) string return "" } - return obj.DashboardId + return utils.Deref(obj.DashboardId) } func remarshalJSON(data []byte) ([]byte, error) { @@ -163,10 +165,10 @@ func remarshalJSON(data []byte) ([]byte, error) { return buf.Bytes(), nil } -func (d *dashboard) saveSerializedDashboard(ctx context.Context, b *bundle.Bundle, dashboard *dashboards.Dashboard, filename string) error { +func (d *dashboard) saveSerializedDashboard(ctx context.Context, b *bundle.Bundle, dashboard *lakeview.Dashboard, filename string) error { // Unmarshal and remarshal the serialized dashboard to ensure it is formatted correctly. // The result will have alphabetically sorted keys and be indented. - data, err := remarshalJSON([]byte(dashboard.SerializedDashboard)) + data, err := remarshalJSON([]byte(utils.Deref(dashboard.SerializedDashboard))) if err != nil { return err } @@ -200,7 +202,7 @@ func (d *dashboard) saveSerializedDashboard(ctx context.Context, b *bundle.Bundl return os.WriteFile(filename, data, 0o644) } -func (d *dashboard) saveConfiguration(ctx context.Context, b *bundle.Bundle, dashboard *dashboards.Dashboard, key string) error { +func (d *dashboard) saveConfiguration(ctx context.Context, b *bundle.Bundle, dashboard *lakeview.Dashboard, key string) error { // Save serialized dashboard definition to the dashboard directory. dashboardBasename := key + ".lvdash.json" dashboardPath := filepath.Join(d.dashboardDir, dashboardBasename) @@ -251,16 +253,16 @@ func (d *dashboard) saveConfiguration(ctx context.Context, b *bundle.Bundle, das return nil } -func waitForChanges(ctx context.Context, w *databricks.WorkspaceClient, dashboard *dashboards.Dashboard) { +func waitForChanges(ctx context.Context, w *sdkclients.Clients, dashboard *lakeview.Dashboard) { // Compute [time.Time] for the most recent update. - tref, err := time.Parse(time.RFC3339, dashboard.UpdateTime) - if err != nil { - logdiag.LogError(ctx, err) + if dashboard.UpdateTime == nil { + logdiag.LogError(ctx, errors.New("dashboard has no update time")) return } + tref := dashboard.UpdateTime.AsTime() for { - obj, err := w.Workspace.GetStatusByPath(ctx, dashboard.Path) + obj, err := w.Workspace.GetStatusByPath(ctx, utils.Deref(dashboard.Path)) if err != nil { logdiag.LogError(ctx, err) return @@ -303,13 +305,13 @@ func (d *dashboard) updateDashboardForResource(ctx context.Context, b *bundle.Bu // Start polling the underlying dashboard for changes. var etag string for { - dashboard, err := w.Lakeview.GetByDashboardId(ctx, dashboardID) + dashboard, err := getDashboard(ctx, w, dashboardID) if err != nil { logdiag.LogError(ctx, err) return } - if etag != dashboard.Etag { + if etag != utils.Deref(dashboard.Etag) { err = d.saveSerializedDashboard(ctx, b, dashboard, dashboardPath) if err != nil { logdiag.LogError(ctx, err) @@ -323,7 +325,7 @@ func (d *dashboard) updateDashboardForResource(ctx context.Context, b *bundle.Bu } // Update the etag for the next iteration. - etag = dashboard.Etag + etag = utils.Deref(dashboard.Etag) // Now poll the workspace API for changes. // This is much more efficient than polling the dashboard API because it @@ -335,7 +337,7 @@ func (d *dashboard) updateDashboardForResource(ctx context.Context, b *bundle.Bu func (d *dashboard) generateForExisting(ctx context.Context, b *bundle.Bundle, dashboardID string) { w := b.WorkspaceClient(ctx) - dashboard, err := w.Lakeview.GetByDashboardId(ctx, dashboardID) + dashboard, err := getDashboard(ctx, w, dashboardID) if err != nil { logdiag.LogError(ctx, err) return @@ -344,7 +346,7 @@ func (d *dashboard) generateForExisting(ctx context.Context, b *bundle.Bundle, d // The "key" flag is a persistent flag on the parent "generate" command. key := d.cmd.Flag("key").Value.String() if key == "" { - key = textutil.NormalizeString(dashboard.DisplayName) + key = textutil.NormalizeString(utils.Deref(dashboard.DisplayName)) } err = d.saveConfiguration(ctx, b, dashboard, key) if err != nil { @@ -529,3 +531,12 @@ bundle files automatically, useful during active dashboard development.`, d.cmd = cmd return cmd } + +// getDashboard fetches a dashboard as its JSON-capable mirror. +func getDashboard(ctx context.Context, w *sdkclients.Clients, dashboardID string) (*lakeview.Dashboard, error) { + dashboard, err := w.Lakeview.GetDashboard(ctx, sdklakeview.GetDashboardRequest{DashboardId: new(dashboardID)}) + if err != nil { + return nil, err + } + return lakeview.DashboardFromSDK(dashboard) +} diff --git a/cmd/bundle/generate/dashboard_test.go b/cmd/bundle/generate/dashboard_test.go index 8c346250c8c..7f7067ba30b 100644 --- a/cmd/bundle/generate/dashboard_test.go +++ b/cmd/bundle/generate/dashboard_test.go @@ -5,12 +5,10 @@ import ( "testing" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/libs/httpfixtures" "github.com/databricks/cli/libs/logdiag" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - + "github.com/databricks/cli/libs/sdkclients" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) @@ -27,19 +25,20 @@ func TestDashboard_ErrorOnLegacyDashboard(t *testing.T) { existingPath: "/path/to/legacy dashboard", } - m := mocks.NewMockWorkspaceClient(t) - w := m.GetMockWorkspaceAPI() - w.On("GetStatusByPath", mock.Anything, "/path/to/legacy dashboard").Return(nil, &apierr.APIError{ - StatusCode: 400, - ErrorCode: "BAD_REQUEST", - Message: "dbsqlDashboard is not user-facing.", - }) + cfg, _ := httpfixtures.Fixtures{{ + Method: "GET", + Resource: "/api/2.0/workspace/get-status?path=/path/to/legacy%20dashboard", + Status: 400, + Response: `{"error_code":"BAD_REQUEST","message":"dbsqlDashboard is not user-facing."}`, + }}.Config(t) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) ctx := t.Context() ctx = logdiag.InitContext(ctx) logdiag.SetCollect(ctx, true) b := &bundle.Bundle{} - b.SetWorkpaceClient(m.WorkspaceClient) + b.SetWorkpaceClient(w) id := d.resolveID(ctx, b) assert.Empty(t, id) diff --git a/cmd/bundle/generate/genie_space.go b/cmd/bundle/generate/genie_space.go index 7c520abc320..43b9d7ec375 100644 --- a/cmd/bundle/generate/genie_space.go +++ b/cmd/bundle/generate/genie_space.go @@ -17,13 +17,16 @@ import ( "github.com/databricks/cli/bundle/resources" "github.com/databricks/cli/cmd/bundle/deployment" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/yamlsaver" "github.com/databricks/cli/libs/logdiag" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/genie/v1" "github.com/databricks/cli/libs/textutil" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/dashboards" + "github.com/databricks/cli/libs/utils" + sdkgenie "github.com/databricks/sdk-go/genie/v1" "github.com/spf13/cobra" "go.yaml.in/yaml/v3" ) @@ -59,11 +62,9 @@ type genieSpace struct { func (g *genieSpace) resolveFromID(ctx context.Context, b *bundle.Bundle) string { w := b.WorkspaceClient(ctx) - obj, err := w.Genie.GetSpace(ctx, dashboards.GenieGetSpaceRequest{ - SpaceId: g.existingID, - }) + obj, err := getGenieSpace(ctx, w, g.existingID, false) if err != nil { - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { logdiag.LogError(ctx, fmt.Errorf("genie space with ID %s not found", g.existingID)) return "" } @@ -71,17 +72,17 @@ func (g *genieSpace) resolveFromID(ctx context.Context, b *bundle.Bundle) string return "" } - return obj.SpaceId + return utils.Deref(obj.SpaceId) } -func (g *genieSpace) saveSerializedGenieSpace(ctx context.Context, b *bundle.Bundle, genieSpace *dashboards.GenieSpace, filename string) error { - if genieSpace.SerializedSpace == "" { +func (g *genieSpace) saveSerializedGenieSpace(ctx context.Context, b *bundle.Bundle, genieSpace *genie.GenieSpace, filename string) error { + if utils.Deref(genieSpace.SerializedSpace) == "" { return fmt.Errorf("genie space response did not include serialized_space; refusing to write %s", filepath.ToSlash(filename)) } // Unmarshal and remarshal the serialized genie space to ensure it is formatted correctly. // The result will have alphabetically sorted keys and be indented. - data, err := remarshalJSON([]byte(genieSpace.SerializedSpace)) + data, err := remarshalJSON([]byte(utils.Deref(genieSpace.SerializedSpace))) if err != nil { return err } @@ -115,7 +116,7 @@ func (g *genieSpace) saveSerializedGenieSpace(ctx context.Context, b *bundle.Bun return os.WriteFile(filename, data, 0o644) } -func (g *genieSpace) saveConfiguration(ctx context.Context, b *bundle.Bundle, genieSpace *dashboards.GenieSpace, key string) error { +func (g *genieSpace) saveConfiguration(ctx context.Context, b *bundle.Bundle, genieSpace *genie.GenieSpace, key string) error { // Save serialized genie space definition to the genie space directory. genieSpaceBasename := key + ".geniespace.json" genieSpacePath := filepath.Join(g.genieSpaceDir, genieSpaceBasename) @@ -185,10 +186,7 @@ func (g *genieSpace) updateGenieSpaceForResource(ctx context.Context, b *bundle. first := true for { - genieSpace, err := w.Genie.GetSpace(ctx, dashboards.GenieGetSpaceRequest{ - SpaceId: genieSpaceID, - IncludeSerializedSpace: true, - }) + genieSpace, err := getGenieSpace(ctx, w, genieSpaceID, true) if err != nil { logdiag.LogError(ctx, err) return @@ -200,7 +198,7 @@ func (g *genieSpace) updateGenieSpaceForResource(ctx context.Context, b *bundle. // match the prior behavior of an unconditional initial sync. shouldSave := first if !first { - differs, err := genieSpaceBodyDiffersFromDisk(genieSpace.SerializedSpace, genieSpacePath) + differs, err := genieSpaceBodyDiffersFromDisk(utils.Deref(genieSpace.SerializedSpace), genieSpacePath) if err != nil { logdiag.LogError(ctx, err) return @@ -250,10 +248,7 @@ func genieSpaceBodyDiffersFromDisk(remoteSerialized, filename string) (bool, err func (g *genieSpace) generateForExisting(ctx context.Context, b *bundle.Bundle, genieSpaceID string) { w := b.WorkspaceClient(ctx) - genieSpace, err := w.Genie.GetSpace(ctx, dashboards.GenieGetSpaceRequest{ - SpaceId: genieSpaceID, - IncludeSerializedSpace: true, - }) + genieSpace, err := getGenieSpace(ctx, w, genieSpaceID, true) if err != nil { logdiag.LogError(ctx, err) return @@ -261,7 +256,7 @@ func (g *genieSpace) generateForExisting(ctx context.Context, b *bundle.Bundle, key := g.cmd.Flag("key").Value.String() if key == "" { - key = textutil.NormalizeString(genieSpace.Title) + key = textutil.NormalizeString(utils.Deref(genieSpace.Title)) } err = g.saveConfiguration(ctx, b, genieSpace, key) if err != nil { @@ -434,3 +429,15 @@ bundle files automatically, useful during active Genie space development.`, g.cmd = cmd return cmd } + +// getGenieSpace fetches a Genie space as its JSON-capable mirror. +func getGenieSpace(ctx context.Context, w *sdkclients.Clients, spaceID string, includeSerializedSpace bool) (*genie.GenieSpace, error) { + space, err := w.Genie.GenieGetSpace(ctx, sdkgenie.GenieGetSpaceRequest{ + SpaceId: new(spaceID), + IncludeSerializedSpace: utils.NonZero(includeSerializedSpace), + }) + if err != nil { + return nil, err + } + return genie.GenieSpaceFromSDK(space) +} diff --git a/cmd/bundle/generate/genie_space_test.go b/cmd/bundle/generate/genie_space_test.go index 746b2b1c3af..7cea033a620 100644 --- a/cmd/bundle/generate/genie_space_test.go +++ b/cmd/bundle/generate/genie_space_test.go @@ -11,15 +11,14 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/httpfixtures" "github.com/databricks/cli/libs/logdiag" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/dashboards" + "github.com/databricks/cli/libs/sdkclients" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) -func newGenieSpaceTestBundle(t *testing.T, m *mocks.MockWorkspaceClient, filePath string) *bundle.Bundle { +func newGenieSpaceTestBundle(t *testing.T, m *sdkclients.Clients, filePath string) *bundle.Bundle { t.Helper() b := &bundle.Bundle{ BundleRootPath: t.TempDir(), @@ -37,7 +36,7 @@ func newGenieSpaceTestBundle(t *testing.T, m *mocks.MockWorkspaceClient, filePat }, } b.Config.Resources.GenieSpaces["my_space"].ID = "space-id-1" - b.SetWorkpaceClient(m.WorkspaceClient) + b.SetWorkpaceClient(m) return b } @@ -45,18 +44,7 @@ func TestGenieSpace_UpdateForResource_WritesFileWhenNotWatching(t *testing.T) { dir := t.TempDir() filePath := filepath.Join(dir, "my_space.geniespace.json") - m := mocks.NewMockWorkspaceClient(t) - m.GetMockGenieAPI().EXPECT(). - GetSpace(mock.Anything, dashboards.GenieGetSpaceRequest{ - SpaceId: "space-id-1", - IncludeSerializedSpace: true, - }). - Return(&dashboards.GenieSpace{ - SpaceId: "space-id-1", - Title: "My Space", - SerializedSpace: `{"version":1}`, - }, nil). - Once() + m := genieSpaceClients(t) g := &genieSpace{ resource: "my_space", @@ -80,19 +68,7 @@ func TestGenieSpace_UpdateForResource_WatchExitsOnCancel(t *testing.T) { dir := t.TempDir() filePath := filepath.Join(dir, "my_space.geniespace.json") - m := mocks.NewMockWorkspaceClient(t) - // Allow any number of GetSpace calls; we don't know how many fire before cancel. - m.GetMockGenieAPI().EXPECT(). - GetSpace(mock.Anything, dashboards.GenieGetSpaceRequest{ - SpaceId: "space-id-1", - IncludeSerializedSpace: true, - }). - Return(&dashboards.GenieSpace{ - SpaceId: "space-id-1", - Title: "My Space", - SerializedSpace: `{"version":1}`, - }, nil). - Maybe() + m := genieSpaceClients(t) g := &genieSpace{ resource: "my_space", @@ -124,3 +100,17 @@ func TestGenieSpace_UpdateForResource_WatchExitsOnCancel(t *testing.T) { t.Fatal("watch loop did not exit promptly after ctx cancel") } } + +// genieSpaceClients serves the Genie space of newGenieSpaceTestBundle. +func genieSpaceClients(t *testing.T) *sdkclients.Clients { + t.Helper() + cfg, _ := httpfixtures.Fixtures{{ + Method: "GET", + Resource: "/api/2.0/genie/spaces/space-id-1?include_serialized_space=true", + Response: `{"space_id":"space-id-1","title":"My Space","serialized_space":"{\"version\":1}"}`, + ReuseRequest: true, + }}.Config(t) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) + return w +} diff --git a/cmd/bundle/generate/job.go b/cmd/bundle/generate/job.go index db6839ade98..4515982f703 100644 --- a/cmd/bundle/generate/job.go +++ b/cmd/bundle/generate/job.go @@ -1,6 +1,7 @@ package generate import ( + "context" "errors" "fmt" "io/fs" @@ -15,8 +16,11 @@ import ( "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/yamlsaver" "github.com/databricks/cli/libs/logdiag" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/textutil" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/utils" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" "github.com/spf13/cobra" "go.yaml.in/yaml/v3" ) @@ -78,7 +82,11 @@ After generation, you can deploy this job to other targets using: } w := b.WorkspaceClient(ctx) - job, err := w.Jobs.Get(ctx, jobs.GetJobRequest{JobId: jobId}) + sdkJob, err := getJob(ctx, w, jobId) + if err != nil { + return err + } + job, err := jobs.GetJobResponseFromSDK(sdkJob) if err != nil { return err } @@ -112,7 +120,7 @@ After generation, you can deploy this job to other targets using: jobKey := cmd.Flag("key").Value.String() if jobKey == "" { - jobKey = textutil.NormalizeString(job.Settings.Name) + jobKey = textutil.NormalizeString(utils.Deref(job.Settings.Name)) } result := map[string]dyn.Value{ @@ -165,3 +173,29 @@ After generation, you can deploy this job to other targets using: return cmd } + +// getJob fetches the job with all its tasks. jobs/get returns at most 100 +// tasks (and job clusters, parameters, environments) per page; later pages +// are fetched with next_page_token and merged. +func getJob(ctx context.Context, w *sdkclients.Clients, id int64) (*sdkjobs.GetJobResponse, error) { + req := sdkjobs.GetJobRequest{JobId: new(id)} + job, err := w.Jobs.GetJob(ctx, req) + if err != nil { + return nil, err + } + for job.NextPageToken != nil && *job.NextPageToken != "" { + req.PageToken = job.NextPageToken + next, err := w.Jobs.GetJob(ctx, req) + if err != nil { + return nil, err + } + if job.Settings != nil && next.Settings != nil { + job.Settings.Tasks = append(job.Settings.Tasks, next.Settings.Tasks...) + job.Settings.JobClusters = append(job.Settings.JobClusters, next.Settings.JobClusters...) + job.Settings.Parameters = append(job.Settings.Parameters, next.Settings.Parameters...) + job.Settings.Environments = append(job.Settings.Environments, next.Settings.Environments...) + } + job.NextPageToken = next.NextPageToken + } + return job, nil +} diff --git a/cmd/bundle/generate/pipeline.go b/cmd/bundle/generate/pipeline.go index cdde5984d40..5585dc42a3f 100644 --- a/cmd/bundle/generate/pipeline.go +++ b/cmd/bundle/generate/pipeline.go @@ -14,8 +14,10 @@ import ( "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/yamlsaver" "github.com/databricks/cli/libs/logdiag" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/databricks/cli/libs/textutil" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/utils" + sdkpipelines "github.com/databricks/sdk-go/pipelines/v2" "github.com/spf13/cobra" "go.yaml.in/yaml/v3" ) @@ -74,7 +76,11 @@ like catalogs, schemas, and compute configurations per target.`, } w := b.WorkspaceClient(ctx) - pipeline, err := w.Pipelines.Get(ctx, pipelines.GetPipelineRequest{PipelineId: pipelineId}) + sdkPipeline, err := w.Pipelines.Get(ctx, sdkpipelines.GetPipelineRequest{PipelineId: new(pipelineId)}) + if err != nil { + return err + } + pipeline, err := pipelines.GetPipelineResponseFromSDK(sdkPipeline) if err != nil { return err } @@ -88,9 +94,9 @@ like catalogs, schemas, and compute configurations per target.`, } // If the root path is set, we need to download the files from the root path - remoteRootPath := pipeline.Spec.RootPath - if pipeline.Spec.RootPath != "" { - err := downloader.MarkDirectoryForDownload(ctx, &pipeline.Spec.RootPath) + remoteRootPath := utils.Deref(pipeline.Spec.RootPath) + if pipeline.Spec.RootPath != nil && *pipeline.Spec.RootPath != "" { + err := downloader.MarkDirectoryForDownload(ctx, pipeline.Spec.RootPath) if err != nil { return err } @@ -109,7 +115,7 @@ like catalogs, schemas, and compute configurations per target.`, pipelineKey := cmd.Flag("key").Value.String() if pipelineKey == "" { - pipelineKey = textutil.NormalizeString(pipeline.Name) + pipelineKey = textutil.NormalizeString(utils.Deref(pipeline.Name)) } result := map[string]dyn.Value{ diff --git a/cmd/bundle/utils/process.go b/cmd/bundle/utils/process.go index 6ccb3367db7..6e2beb2b831 100644 --- a/cmd/bundle/utils/process.go +++ b/cmd/bundle/utils/process.go @@ -24,6 +24,8 @@ import ( "github.com/databricks/cli/bundle/statemgmt" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/internal/build" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/bundledeployments" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/diag" @@ -31,12 +33,10 @@ import ( "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/logdiag" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/sync" "github.com/databricks/cli/libs/telemetry" "github.com/databricks/cli/libs/telemetry/protos" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" "github.com/databricks/databricks-sdk-go/useragent" "github.com/spf13/cobra" "golang.org/x/mod/semver" @@ -594,11 +594,11 @@ func ValidateEngineSetting(ctx context.Context, b *bundle.Bundle) error { // // TODO: ask the service for a lookup by state path, so this is one round trip rather than two - a // workspace lookup to turn the node into an id, then a get by that id. -func fetchDeploymentFromStatePath(ctx context.Context, w *databricks.WorkspaceClient, statePath string) (string, *bundledeployments.Deployment, error) { +func fetchDeploymentFromStatePath(ctx context.Context, w *sdkclients.Clients, statePath string) (string, *bundledeployments.Deployment, error) { nodePath := path.Join(statePath, dms.DeploymentNodeName) obj, err := w.Workspace.GetStatusByPath(ctx, nodePath) - if errors.Is(err, apierr.ErrNotFound) || errors.Is(err, apierr.ErrResourceDoesNotExist) { + if apierrs.Is(err, apierrs.ErrNotFound) || apierrs.Is(err, apierrs.ErrResourceDoesNotExist) { return "", nil, nil } if err != nil { diff --git a/cmd/bundle/utils/process_test.go b/cmd/bundle/utils/process_test.go index b216f1102d2..da15db52fd5 100644 --- a/cmd/bundle/utils/process_test.go +++ b/cmd/bundle/utils/process_test.go @@ -7,7 +7,7 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/direct/dstate" "github.com/databricks/cli/bundle/statemgmt" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" + "github.com/databricks/cli/libs/bundledeployments" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/cmd/configure/configure.go b/cmd/configure/configure.go index 35ffad26d83..8e412f32bb0 100644 --- a/cmd/configure/configure.go +++ b/cmd/configure/configure.go @@ -8,7 +8,7 @@ import ( "github.com/databricks/cli/libs/databrickscfg" "github.com/databricks/cli/libs/databrickscfg/cfgpickers" "github.com/databricks/cli/libs/env" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" "github.com/spf13/cobra" ) @@ -55,7 +55,7 @@ func configureInteractive(cmd *cobra.Command, flags *configureFlags, cfg *config // Ask user to specify a cluster if not already set. if flags.ConfigureCluster && cfg.ClusterID == "" { // Create workspace client with configuration without the profile name set. - w, err := databricks.NewWorkspaceClient(&databricks.Config{ + w, err := sdkclients.New(ctx, &config.Config{ Host: cfg.Host, Token: cfg.Token, }) diff --git a/cmd/environments/compute.go b/cmd/environments/compute.go index d0b82ba4e52..89d9bc3f1aa 100644 --- a/cmd/environments/compute.go +++ b/cmd/environments/compute.go @@ -6,24 +6,27 @@ import ( "strconv" "strings" + "github.com/databricks/cli/libs/listing" localenv "github.com/databricks/cli/libs/localenv" - databricks "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + compute "github.com/databricks/sdk-go/clusters/v2" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" ) // sdkCompute adapts the Databricks SDK to the localenv.ComputeClient interface. type sdkCompute struct { - w *databricks.WorkspaceClient + w *sdkclients.Clients } // GetClusterSparkVersion returns the Spark version string for a running cluster. func (c sdkCompute) GetClusterSparkVersion(ctx context.Context, clusterID string) (string, error) { - d, err := c.w.Clusters.GetByClusterId(ctx, clusterID) + d, err := c.w.Clusters.GetCluster(ctx, compute.GetClusterRequest{ClusterId: new(clusterID)}) if err != nil { return "", fmt.Errorf("get cluster %s: %w", clusterID, err) } - return d.SparkVersion, nil + return utils.Deref(d.SparkVersion), nil } // GetClusterByName resolves a cluster name to its ID and Spark version. @@ -40,25 +43,24 @@ func (c sdkCompute) GetClusterSparkVersion(ctx context.Context, clusterID string // named"; this is acceptable since a long-terminated cluster is not a usable // target and the user can always pass --cluster-id. func (c sdkCompute) GetClusterByName(ctx context.Context, name string) (string, string, error) { - clusters, err := c.w.Clusters.ListAll(ctx, compute.ListClustersRequest{ - FilterBy: &compute.ListClustersFilterBy{ - // TERMINATING is excluded alongside TERMINATED: a cluster on its way - // down is not a usable target, and keeping it would reintroduce the - // stale-collision problem this filter exists to avoid. - ClusterStates: []compute.State{ - compute.StatePending, - compute.StateRunning, - compute.StateRestarting, - compute.StateResizing, - }, - }, - }) + clusters, err := listing.Collect(c.w.Clusters.ListClustersIter(ctx, compute.ListClustersRequest{})) if err != nil { return "", "", fmt.Errorf("list clusters to resolve name %q: %w", name, err) } - var matches []compute.ClusterDetails + var matches []compute.ClusterInfo for _, cl := range clusters { - if cl.ClusterName == name { + // TERMINATING is excluded alongside TERMINATED: a cluster on its way + // down is not a usable target, and keeping it would reintroduce the + // stale-collision problem this filter exists to avoid. + switch cl.State { + case compute.ClusterState_ClusterState_Pending, + compute.ClusterState_ClusterState_Running, + compute.ClusterState_ClusterState_Restarting, + compute.ClusterState_ClusterState_Resizing: + default: + continue + } + if utils.Deref(cl.ClusterName) == name { matches = append(matches, cl) } } @@ -66,7 +68,7 @@ func (c sdkCompute) GetClusterByName(ctx context.Context, name string) (string, case 0: return "", "", fmt.Errorf("no active cluster named %q", name) case 1: - return matches[0].ClusterId, matches[0].SparkVersion, nil + return utils.Deref(matches[0].ClusterId), utils.Deref(matches[0].SparkVersion), nil default: return "", "", fmt.Errorf("there are %d active clusters named %q; use --cluster-id to disambiguate", len(matches), name) } @@ -92,7 +94,11 @@ func (c sdkCompute) JobTaskEnvironment(ctx context.Context, jobID, taskKey strin return "", false, "", fmt.Errorf("invalid job ID %q: must be an integer: %w", jobID, err) } - job, err := c.w.Jobs.GetByJobId(ctx, id) + sdkJob, err := c.w.Jobs.GetJob(ctx, sdkjobs.GetJobRequest{JobId: new(id)}) + if err != nil { + return "", false, "", fmt.Errorf("get job %d: %w", id, err) + } + job, err := jobs.GetJobResponseFromSDK(sdkJob) if err != nil { return "", false, "", fmt.Errorf("get job %d: %w", id, err) } @@ -102,7 +108,7 @@ func (c sdkCompute) JobTaskEnvironment(ctx context.Context, jobID, taskKey strin taskKeys := make([]string, 0, len(job.Settings.Tasks)) for _, t := range job.Settings.Tasks { - taskKeys = append(taskKeys, t.TaskKey) + taskKeys = append(taskKeys, utils.Deref(t.TaskKey)) } // No task key given: ask the caller to pick one, listing what is available. @@ -111,9 +117,9 @@ func (c sdkCompute) JobTaskEnvironment(ctx context.Context, jobID, taskKey strin return "", false, "", &localenv.ErrTaskKeyRequired{JobID: jobID, TaskKeys: taskKeys} } - var task *jobs.Task + var task *jobs.TaskSettings for i := range job.Settings.Tasks { - if job.Settings.Tasks[i].TaskKey == taskKey { + if utils.Deref(job.Settings.Tasks[i].TaskKey) == taskKey { task = &job.Settings.Tasks[i] break } @@ -126,7 +132,7 @@ func (c sdkCompute) JobTaskEnvironment(ctx context.Context, jobID, taskKey strin // (environment_key / new_cluster / existing_cluster_id / job_cluster_key) // lives on the nested task, not the outer one. Resolve against that. if task.ForEachTask != nil { - task = &task.ForEachTask.Task + task = task.ForEachTask.Task } return c.resolveTaskCompute(ctx, job.Settings, task, jobID, taskKey) @@ -136,46 +142,46 @@ func (c sdkCompute) JobTaskEnvironment(ctx context.Context, jobID, taskKey strin // serverless environment version directly (no fallback) or the classic cluster's // Spark version, consulting the job-level environments and job_clusters the task // references by key. -func (c sdkCompute) resolveTaskCompute(ctx context.Context, settings *jobs.JobSettings, task *jobs.Task, jobID, taskKey string) (sparkVersion string, isServerless bool, version string, err error) { +func (c sdkCompute) resolveTaskCompute(ctx context.Context, settings *jobs.JobSettings, task *jobs.TaskSettings, jobID, taskKey string) (sparkVersion string, isServerless bool, version string, err error) { // Serverless task: it references one of the job's environments by key; the // version lives on that environment's spec and is used directly. - if task.EnvironmentKey != "" { + if utils.Deref(task.EnvironmentKey) != "" { for _, e := range settings.Environments { - if e.EnvironmentKey == task.EnvironmentKey { + if utils.Deref(e.EnvironmentKey) == utils.Deref(task.EnvironmentKey) { v := environmentVersion(e) if v == "" { - return "", false, "", fmt.Errorf("task %q of job %s binds environment %q, which records no environment version", taskKey, jobID, task.EnvironmentKey) + return "", false, "", fmt.Errorf("task %q of job %s binds environment %q, which records no environment version", taskKey, jobID, utils.Deref(task.EnvironmentKey)) } return "", true, v, nil } } - return "", false, "", fmt.Errorf("task %q of job %s references environment %q, which the job does not define", taskKey, jobID, task.EnvironmentKey) + return "", false, "", fmt.Errorf("task %q of job %s references environment %q, which the job does not define", taskKey, jobID, utils.Deref(task.EnvironmentKey)) } // Classic task with an inline cluster spec. - if task.NewCluster != nil && task.NewCluster.SparkVersion != "" { - return task.NewCluster.SparkVersion, false, task.NewCluster.SparkVersion, nil + if task.NewCluster != nil && utils.Deref(task.NewCluster.SparkVersion) != "" { + return utils.Deref(task.NewCluster.SparkVersion), false, utils.Deref(task.NewCluster.SparkVersion), nil } // Classic task referencing a shared job cluster by key: read that cluster's // Spark version from the job's job_clusters (the common classic-task shape). - if task.JobClusterKey != "" { + if utils.Deref(task.JobClusterKey) != "" { for _, jc := range settings.JobClusters { - if jc.JobClusterKey == task.JobClusterKey { - if jc.NewCluster.SparkVersion == "" { - return "", false, "", fmt.Errorf("task %q of job %s uses job cluster %q, which has no spark_version", taskKey, jobID, task.JobClusterKey) + if utils.Deref(jc.JobClusterKey) == utils.Deref(task.JobClusterKey) { + if jc.NewCluster == nil || utils.Deref(jc.NewCluster.SparkVersion) == "" { + return "", false, "", fmt.Errorf("task %q of job %s uses job cluster %q, which has no spark_version", taskKey, jobID, utils.Deref(task.JobClusterKey)) } - return jc.NewCluster.SparkVersion, false, jc.NewCluster.SparkVersion, nil + return utils.Deref(jc.NewCluster.SparkVersion), false, utils.Deref(jc.NewCluster.SparkVersion), nil } } - return "", false, "", fmt.Errorf("task %q of job %s references job cluster %q, which the job does not define", taskKey, jobID, task.JobClusterKey) + return "", false, "", fmt.Errorf("task %q of job %s references job cluster %q, which the job does not define", taskKey, jobID, utils.Deref(task.JobClusterKey)) } // Classic task pinned to an existing cluster: resolve its Spark version. - if task.ExistingClusterId != "" { - sv, cerr := c.GetClusterSparkVersion(ctx, task.ExistingClusterId) + if utils.Deref(task.ExistingClusterId) != "" { + sv, cerr := c.GetClusterSparkVersion(ctx, utils.Deref(task.ExistingClusterId)) if cerr != nil { - return "", false, "", fmt.Errorf("resolving existing cluster %s for task %q of job %s: %w", task.ExistingClusterId, taskKey, jobID, cerr) + return "", false, "", fmt.Errorf("resolving existing cluster %s for task %q of job %s: %w", utils.Deref(task.ExistingClusterId), taskKey, jobID, cerr) } return sv, false, sv, nil } @@ -195,8 +201,8 @@ func environmentVersion(e jobs.JobEnvironment) string { if e.Spec == nil { return "" } - if e.Spec.EnvironmentVersion != "" { - return e.Spec.EnvironmentVersion + if utils.Deref(e.Spec.EnvironmentVersion) != "" { + return utils.Deref(e.Spec.EnvironmentVersion) } - return e.Spec.Client + return utils.Deref(e.Spec.Client) } diff --git a/cmd/environments/compute_test.go b/cmd/environments/compute_test.go index 7b4b9300b75..69ef0aed9f8 100644 --- a/cmd/environments/compute_test.go +++ b/cmd/environments/compute_test.go @@ -3,8 +3,7 @@ package environments import ( "testing" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" ) @@ -15,14 +14,14 @@ func TestEnvironmentVersion(t *testing.T) { want string }{ {"nil spec", jobs.JobEnvironment{}, ""}, - {"environment_version", jobs.JobEnvironment{Spec: &compute.Environment{EnvironmentVersion: "3"}}, "3"}, + {"environment_version", jobs.JobEnvironment{Spec: &jobs.Environment{EnvironmentVersion: new("3")}}, "3"}, // client is the deprecated predecessor of environment_version; some jobs // still pin via it, so it must be read when environment_version is empty. - {"client fallback", jobs.JobEnvironment{Spec: &compute.Environment{Client: "2"}}, "2"}, + {"client fallback", jobs.JobEnvironment{Spec: &jobs.Environment{Client: new("2")}}, "2"}, // environment_version wins when both are present. - {"environment_version wins", jobs.JobEnvironment{Spec: &compute.Environment{EnvironmentVersion: "4", Client: "2"}}, "4"}, + {"environment_version wins", jobs.JobEnvironment{Spec: &jobs.Environment{EnvironmentVersion: new("4"), Client: new("2")}}, "4"}, // base_environment is a path/ID, not a version, and is ignored. - {"base_environment ignored", jobs.JobEnvironment{Spec: &compute.Environment{BaseEnvironment: "/Workspace/env.yaml"}}, ""}, + {"base_environment ignored", jobs.JobEnvironment{Spec: &jobs.Environment{BaseEnvironment: new("/Workspace/env.yaml")}}, ""}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { diff --git a/cmd/experimental/workspace_open_test.go b/cmd/experimental/workspace_open_test.go index 24f9d49c79b..8ff1b5658d6 100644 --- a/cmd/experimental/workspace_open_test.go +++ b/cmd/experimental/workspace_open_test.go @@ -11,8 +11,8 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/log/handler" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/workspaceurls" - "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/config" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" @@ -183,7 +183,7 @@ func TestWorkspaceOpenCommandOpensBrowserByDefault(t *testing.T) { } ctx, stderr := cmdio.NewTestContextWithStderr(t.Context()) - ctx = cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{ + ctx = cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{ Config: &config.Config{ Host: "https://myworkspace.databricks.com", }, @@ -222,7 +222,7 @@ func TestWorkspaceOpenCommandURLFlag(t *testing.T) { } ctx, stderr := cmdio.NewTestContextWithStderr(t.Context()) - ctx = cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{ + ctx = cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{ Config: &config.Config{ Host: "https://myworkspace.databricks.com", }, @@ -264,7 +264,7 @@ func TestWorkspaceOpenCommandWarnsWhenWorkspaceIDLookupFails(t *testing.T) { ctx = log.NewContext(ctx, slog.New(handler.NewFriendlyHandler(stderr, &handler.Options{ Level: log.LevelWarn, }))) - ctx = cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{ + ctx = cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{ Config: &config.Config{ Host: "https://myworkspace.databricks.com", }, diff --git a/cmd/fs/helpers_test.go b/cmd/fs/helpers_test.go index ee1a88e23fb..2020393260a 100644 --- a/cmd/fs/helpers_test.go +++ b/cmd/fs/helpers_test.go @@ -9,8 +9,8 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/fakefs" "github.com/databricks/cli/libs/filer" - databrickscfg "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/experimental/mocks" + "github.com/databricks/cli/libs/httpfixtures" + "github.com/databricks/cli/libs/sdkclients" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -55,9 +55,7 @@ func TestFilerForPathForDbfsScheme(t *testing.T) { for _, tc := range tcases { t.Run(tc.fullPath, func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.WorkspaceClient.Config = &databrickscfg.Config{} - ctx := cmdctx.SetWorkspaceClient(t.Context(), m.WorkspaceClient) + ctx := cmdctx.SetWorkspaceClient(t.Context(), testClients(t)) f, path, err := filerForPath(ctx, tc.fullPath) require.NoError(t, err) @@ -96,18 +94,26 @@ func mockMustWorkspaceClientFunc(cmd *cobra.Command, args []string) error { return nil } -func setupCommand(t *testing.T) (*cobra.Command, *mocks.MockWorkspaceClient) { - m := mocks.NewMockWorkspaceClient(t) - ctx := t.Context() - ctx = cmdctx.SetWorkspaceClient(ctx, m.WorkspaceClient) +// testClients returns clients for a server that expects no requests. +func testClients(t *testing.T) *sdkclients.Clients { + t.Helper() + cfg, _ := httpfixtures.Fixtures{}.Config(t) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) + return w +} + +func setupCommand(t *testing.T) (*cobra.Command, *sdkclients.Clients) { + w := testClients(t) + ctx := cmdctx.SetWorkspaceClient(t.Context(), w) cmd := &cobra.Command{} cmd.SetContext(ctx) - return cmd, m + return cmd, w } -func setupTest(t *testing.T) (*validArgs, *cobra.Command, *mocks.MockWorkspaceClient) { +func setupTest(t *testing.T) (*validArgs, *cobra.Command, *sdkclients.Clients) { cmd, m := setupCommand(t) fakeFilerForPath := func(ctx context.Context, fullPath string) (filer.Filer, string, error) { diff --git a/cmd/fuzz_panic_test.go b/cmd/fuzz_panic_test.go index 970ca17f0a8..3cdd1f390ea 100644 --- a/cmd/fuzz_panic_test.go +++ b/cmd/fuzz_panic_test.go @@ -15,7 +15,7 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/logdiag" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" "github.com/spf13/cobra" "github.com/stretchr/testify/require" @@ -64,7 +64,7 @@ type leafCommand struct { func newFuzzHarness(t *testing.T) *fuzzHarness { t.Helper() - wc, err := databricks.NewWorkspaceClient((*databricks.Config)(&config.Config{ + wc, err := sdkclients.New(t.Context(), (&config.Config{ Host: "https://fuzz.invalid", Token: "fuzz", AuthType: "pat", @@ -72,7 +72,7 @@ func newFuzzHarness(t *testing.T) *fuzzHarness { })) require.NoError(t, err) - ac, err := databricks.NewAccountClient((*databricks.Config)(&config.Config{ + ac, err := sdkclients.New(t.Context(), (&config.Config{ Host: "https://fuzz.invalid", Token: "fuzz", AuthType: "pat", diff --git a/cmd/labs/project/command_test.go b/cmd/labs/project/command_test.go index 6dc73855f7e..21fb721d602 100644 --- a/cmd/labs/project/command_test.go +++ b/cmd/labs/project/command_test.go @@ -13,7 +13,6 @@ import ( "github.com/databricks/cli/internal/testcli" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/python" - "github.com/databricks/databricks-sdk-go" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -48,7 +47,7 @@ func TestRunningBlueprintEchoProfileWrongOverride(t *testing.T) { ctx := devEnvContext(t) r := testcli.NewRunner(t, ctx, "labs", "blueprint", "echo", "--profile", "workspace-profile") _, _, err := r.Run() - assert.ErrorIs(t, err, databricks.ErrNotAccountClient) + assert.ErrorContains(t, err, "invalid Databricks Account configuration") } func TestRunningCommand(t *testing.T) { diff --git a/cmd/labs/project/entrypoint.go b/cmd/labs/project/entrypoint.go index 20eae235f08..02bc8197bb7 100644 --- a/cmd/labs/project/entrypoint.go +++ b/cmd/labs/project/entrypoint.go @@ -15,7 +15,7 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" "github.com/databricks/databricks-sdk-go/logger" "github.com/spf13/cobra" @@ -124,19 +124,23 @@ func (e *Entrypoint) preparePython(ctx context.Context, environment map[string]s func (e *Entrypoint) ensureRunningCluster(ctx context.Context, cfg *config.Config) error { sp := cmdio.NewSpinner(ctx) defer sp.Close() - w, err := databricks.NewWorkspaceClient((*databricks.Config)(cfg)) + w, err := sdkclients.New(ctx, cfg) if err != nil { return fmt.Errorf("workspace client: %w", err) } // TODO: add in-progress callback to EnsureClusterIsRunning() in SDK sp.Update("Ensuring the cluster is running...") - err = w.Clusters.EnsureClusterIsRunning(ctx, cfg.ClusterID) + err = w.EnsureClusterIsRunning(ctx, cfg.ClusterID) if err != nil { return fmt.Errorf("ensure running: %w", err) } return nil } +// errNotAccountClient is returned when an account-level command runs with a +// workspace profile. +var errNotAccountClient = errors.New("invalid Databricks Account configuration - host incorrect or account_id missing") + func (e *Entrypoint) joinPaths(paths ...string) string { return strings.Join(paths, string(os.PathListSeparator)) } @@ -267,7 +271,7 @@ func (e *Entrypoint) validLogin(cmd *cobra.Command) (*config.Config, error) { } return replaceCfg, nil } else if e.IsAccountLevel && !isACC { - return nil, databricks.ErrNotAccountClient + return nil, errNotAccountClient } if e.NeedsCluster() && !isACC && cfg.ClusterID == "" { return nil, ErrMissingClusterID diff --git a/cmd/labs/project/installer.go b/cmd/labs/project/installer.go index 32a74b6808f..34392e759e7 100644 --- a/cmd/labs/project/installer.go +++ b/cmd/labs/project/installer.go @@ -9,6 +9,8 @@ import ( "os" "strings" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/cmd/labs/github" "github.com/databricks/cli/cmd/labs/unpack" "github.com/databricks/cli/libs/cmdio" @@ -16,16 +18,16 @@ import ( "github.com/databricks/cli/libs/databrickscfg/profile" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/process" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/sql" + compute "github.com/databricks/sdk-go/clusters/v2" + sql "github.com/databricks/sdk-go/warehouses/v1" "github.com/spf13/cobra" ) const ownerRWXworldRX = 0o755 -type whTypes []sql.EndpointInfoWarehouseType +type whTypes []sql.WarehouseType type hook struct { *Entrypoint `yaml:",inline"` @@ -96,7 +98,7 @@ func (i *installer) Install(ctx context.Context) error { if err != nil { return err } - w, err = databricks.NewWorkspaceClient((*databricks.Config)(cfg)) + w, err = sdkclients.New(ctx, cfg) if err != nil { return fmt.Errorf("no ~/.databrickscfg: %w", err) } @@ -168,7 +170,7 @@ func (i *installer) recordVersion(ctx context.Context) error { return i.writeVersionFile(ctx, i.version) } -func (i *installer) login(ctx context.Context) (*databricks.WorkspaceClient, error) { +func (i *installer) login(ctx context.Context) (*sdkclients.Clients, error) { cfg, err := i.metaEntrypoint(ctx).validLogin(i.cmd) if errors.Is(err, ErrNoLoginConfig) { cfg, err = i.Installer.envAwareConfig(ctx) @@ -220,7 +222,7 @@ func (i *installer) downloadAndUnpackZipball(ctx context.Context, libTarget stri return zipball.UnpackTo(libTarget) } -func (i *installer) setupPythonVirtualEnvironment(ctx context.Context, w *databricks.WorkspaceClient) error { +func (i *installer) setupPythonVirtualEnvironment(ctx context.Context, w *sdkclients.Clients) error { if !i.HasPython() { return nil } @@ -245,15 +247,15 @@ func (i *installer) setupPythonVirtualEnvironment(ctx context.Context, w *databr } if i.Installer != nil && i.Installer.RequireDatabricksConnect { sp.Update("Determining Databricks Connect version") - cluster, err := w.Clusters.Get(ctx, compute.GetClusterRequest{ - ClusterId: w.Config.ClusterID, + cluster, err := w.Clusters.GetCluster(ctx, compute.GetClusterRequest{ + ClusterId: new(w.Config.ClusterID), }) if err != nil { return fmt.Errorf("cluster: %w", err) } runtimeVersion, ok := cfgpickers.GetRuntimeVersion(*cluster) if !ok { - return fmt.Errorf("unsupported runtime: %s", cluster.SparkVersion) + return fmt.Errorf("unsupported runtime: %s", utils.Deref(cluster.SparkVersion)) } sp.Update("Installing Databricks Connect v" + runtimeVersion) pipSpec := "databricks-connect==" + runtimeVersion diff --git a/cmd/labs/project/installer_test.go b/cmd/labs/project/installer_test.go index 266d42dbeb8..ced9b0b6322 100644 --- a/cmd/labs/project/installer_test.go +++ b/cmd/labs/project/installer_test.go @@ -23,9 +23,6 @@ import ( "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/process" "github.com/databricks/cli/libs/python" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/sql" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -188,9 +185,7 @@ func TestInstallerWorksForReleases(t *testing.T) { return } if r.URL.Path == "/api/2.1/clusters/get" { - respondWithJSON(t, w, &compute.ClusterDetails{ - State: compute.StateRunning, - }) + respondWithJSON(t, w, json.RawMessage(`{"state":"RUNNING"}`)) return } t.Errorf("unexpected request: %s", r.URL.Path) @@ -257,9 +252,7 @@ func TestOfflineInstallerWorksForReleases(t *testing.T) { return } if r.URL.Path == "/api/2.1/clusters/get" { - respondWithJSON(t, w, &compute.ClusterDetails{ - State: compute.StateRunning, - }) + respondWithJSON(t, w, json.RawMessage(`{"state":"RUNNING"}`)) return } t.Errorf("unexpected request: %s", r.URL.Path) @@ -304,62 +297,26 @@ func TestInstallerWorksForDevelopment(t *testing.T) { return } if r.URL.Path == "/api/2.1/clusters/list" { - respondWithJSON(t, w, compute.ListClustersResponse{ - Clusters: []compute.ClusterDetails{ - { - ClusterId: "abc-id", - ClusterName: "first shared", - ClusterSource: compute.ClusterSourceApi, - DataSecurityMode: compute.DataSecurityModeUserIsolation, - SparkVersion: "12.2.x-whatever", - State: compute.StateRunning, - }, - { - ClusterId: "bcd-id", - ClusterName: "second personal", - ClusterSource: compute.ClusterSourceApi, - DataSecurityMode: compute.DataSecurityModeSingleUser, - SparkVersion: "14.5.x-whatever", - State: compute.StateRunning, - SingleUserName: "serge", - }, - }, - }) + respondWithJSON(t, w, json.RawMessage(`{"clusters":[ + {"cluster_id":"abc-id","cluster_name":"first shared","cluster_source":"API","data_security_mode":"USER_ISOLATION","spark_version":"12.2.x-whatever","state":"RUNNING"}, + {"cluster_id":"bcd-id","cluster_name":"second personal","cluster_source":"API","data_security_mode":"SINGLE_USER","spark_version":"14.5.x-whatever","state":"RUNNING","single_user_name":"serge"} + ]}`)) return } if r.URL.Path == "/api/2.0/preview/scim/v2/Me" { - respondWithJSON(t, w, iam.User{ - UserName: "serge", - }) + respondWithJSON(t, w, json.RawMessage(`{"userName":"serge"}`)) return } if r.URL.Path == "/api/2.1/clusters/spark-versions" { - respondWithJSON(t, w, compute.GetSparkVersionsResponse{ - Versions: []compute.SparkVersion{ - { - Key: "14.5.x-whatever", - Name: "14.5 (Awesome)", - }, - }, - }) + respondWithJSON(t, w, json.RawMessage(`{"versions":[{"key":"14.5.x-whatever","name":"14.5 (Awesome)"}]}`)) return } if r.URL.Path == "/api/2.1/clusters/get" { - respondWithJSON(t, w, &compute.ClusterDetails{ - State: compute.StateRunning, - }) + respondWithJSON(t, w, json.RawMessage(`{"state":"RUNNING"}`)) return } if r.URL.Path == "/api/2.0/sql/warehouses" { - respondWithJSON(t, w, sql.ListWarehousesResponse{ - Warehouses: []sql.EndpointInfo{ - { - Id: "efg-id", - Name: "First PRO Warehouse", - WarehouseType: sql.EndpointInfoWarehouseTypePro, - }, - }, - }) + respondWithJSON(t, w, json.RawMessage(`{"warehouses":[{"id":"efg-id","name":"First PRO Warehouse","warehouse_type":"PRO"}]}`)) return } t.Errorf("unexpected request: %s", r.URL.Path) @@ -448,9 +405,7 @@ func TestUpgraderWorksForReleases(t *testing.T) { return } if r.URL.Path == "/api/2.1/clusters/get" { - respondWithJSON(t, w, &compute.ClusterDetails{ - State: compute.StateRunning, - }) + respondWithJSON(t, w, json.RawMessage(`{"state":"RUNNING"}`)) return } t.Errorf("unexpected request: %s", r.URL.Path) diff --git a/cmd/labs/project/login.go b/cmd/labs/project/login.go index 39ccbf24540..cecc9915976 100644 --- a/cmd/labs/project/login.go +++ b/cmd/labs/project/login.go @@ -10,7 +10,7 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/databrickscfg/cfgpickers" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" ) @@ -22,7 +22,7 @@ type loginConfig struct { WarehouseID string `json:"warehouse_id,omitempty"` } -func (lc *loginConfig) askWorkspace(ctx context.Context, cfg *config.Config) (*databricks.WorkspaceClient, error) { +func (lc *loginConfig) askWorkspace(ctx context.Context, cfg *config.Config) (*sdkclients.Clients, error) { if cfg.ConfigType() == config.AccountConfig { return nil, nil } @@ -30,7 +30,7 @@ func (lc *loginConfig) askWorkspace(ctx context.Context, cfg *config.Config) (*d if err != nil { return nil, fmt.Errorf("profile: %w", err) } - w, err := databricks.NewWorkspaceClient((*databricks.Config)(cfg)) + w, err := sdkclients.New(ctx, cfg) if err != nil { return nil, fmt.Errorf("client: %w", err) } @@ -64,7 +64,7 @@ func (lc *loginConfig) askWorkspaceProfile(ctx context.Context, cfg *config.Conf return err } -func (lc *loginConfig) askCluster(ctx context.Context, w *databricks.WorkspaceClient) (err error) { +func (lc *loginConfig) askCluster(ctx context.Context, w *sdkclients.Clients) (err error) { if !lc.NeedsCluster() { return err } @@ -85,7 +85,7 @@ func (lc *loginConfig) askCluster(ctx context.Context, w *databricks.WorkspaceCl return err } -func (lc *loginConfig) askWarehouse(ctx context.Context, w *databricks.WorkspaceClient) (err error) { +func (lc *loginConfig) askWarehouse(ctx context.Context, w *sdkclients.Clients) (err error) { if !lc.NeedsWarehouse() { return err } diff --git a/cmd/labs/project/project.go b/cmd/labs/project/project.go index e40ef2a5501..fb5303f6654 100644 --- a/cmd/labs/project/project.go +++ b/cmd/labs/project/project.go @@ -17,9 +17,8 @@ import ( "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/python" "github.com/databricks/databricks-sdk-go/logger" - "go.yaml.in/yaml/v3" - "github.com/spf13/cobra" + "go.yaml.in/yaml/v3" ) const ownerRW = 0o600 diff --git a/cmd/pipelines/generate.go b/cmd/pipelines/generate.go index c865213c36a..98ea678a9da 100644 --- a/cmd/pipelines/generate.go +++ b/cmd/pipelines/generate.go @@ -16,7 +16,7 @@ import ( "github.com/databricks/cli/libs/dyn/yamlloader" "github.com/databricks/cli/libs/dyn/yamlsaver" "github.com/databricks/cli/libs/logdiag" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/spf13/cobra" ) @@ -324,7 +324,7 @@ func convertLibraries(relativePath string, specLibraries []sdpPipelineLibrary) ( relativeIncludePath := filepath.ToSlash(filepath.Join(relativePath, lib.Glob.Include)) libraries = append(libraries, pipelines.PipelineLibrary{ - Glob: &pipelines.PathPattern{Include: relativeIncludePath}, + Glob: &pipelines.PathPattern{Include: new(relativeIncludePath)}, }) } } diff --git a/cmd/pipelines/history.go b/cmd/pipelines/history.go index a5fc42a4f61..398e85f6f72 100644 --- a/cmd/pipelines/history.go +++ b/cmd/pipelines/history.go @@ -8,8 +8,8 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdgroup" "github.com/databricks/cli/libs/cmdio" - databricks "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/google/uuid" "github.com/spf13/cobra" ) @@ -38,7 +38,7 @@ func historyCommand() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) error { var key, pipelineId string - var w *databricks.WorkspaceClient + var w *sdkclients.Clients if len(args) == 1 { id, err := uuid.Parse(args[0]) if err == nil { diff --git a/cmd/pipelines/history_test.go b/cmd/pipelines/history_test.go index a125d74d0d9..56b32f08006 100644 --- a/cmd/pipelines/history_test.go +++ b/cmd/pipelines/history_test.go @@ -3,17 +3,18 @@ package pipelines import ( "testing" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/utils" ) func TestUpdatesBefore(t *testing.T) { // Test data: updates sorted in descending order (newest first) updates := []pipelines.UpdateInfo{ - {CreationTime: 1000}, // newest - {CreationTime: 800}, - {CreationTime: 600}, - {CreationTime: 400}, - {CreationTime: 200}, // oldest + {CreationTime: new(int64(1000))}, // newest + {CreationTime: new(int64(800))}, + {CreationTime: new(int64(600))}, + {CreationTime: new(int64(400))}, + {CreationTime: new(int64(200))}, // oldest } tests := []struct { @@ -54,8 +55,8 @@ func TestUpdatesBefore(t *testing.T) { if len(result) != tt.expectedCount { t.Errorf("updatesBefore(updates, %d) returned %d updates, want %d", *tt.timestamp, len(result), tt.expectedCount) } - if tt.expectedCount > 0 && result[0].CreationTime != tt.expectedFirst { - t.Errorf("updatesBefore(updates, %d) first update = %d, want %d", *tt.timestamp, result[0].CreationTime, tt.expectedFirst) + if tt.expectedCount > 0 && utils.Deref(result[0].CreationTime) != tt.expectedFirst { + t.Errorf("updatesBefore(updates, %d) first update = %d, want %d", *tt.timestamp, utils.Deref(result[0].CreationTime), tt.expectedFirst) } }) } @@ -64,11 +65,11 @@ func TestUpdatesBefore(t *testing.T) { func TestUpdatesAfter(t *testing.T) { // Test data: updates sorted in descending order (newest first) updates := []pipelines.UpdateInfo{ - {CreationTime: 1000}, // newest - {CreationTime: 800}, - {CreationTime: 600}, - {CreationTime: 400}, - {CreationTime: 200}, // oldest + {CreationTime: new(int64(1000))}, // newest + {CreationTime: new(int64(800))}, + {CreationTime: new(int64(600))}, + {CreationTime: new(int64(400))}, + {CreationTime: new(int64(200))}, // oldest } tests := []struct { @@ -109,8 +110,8 @@ func TestUpdatesAfter(t *testing.T) { if len(result) != tt.expectedCount { t.Errorf("updatesAfter(updates, %d) returned %d updates, want %d", *tt.timestamp, len(result), tt.expectedCount) } - if tt.expectedCount > 0 && result[0].CreationTime != tt.expectedFirst { - t.Errorf("updatesAfter(updates, %d) first update = %d, want %d", *tt.timestamp, result[0].CreationTime, tt.expectedFirst) + if tt.expectedCount > 0 && utils.Deref(result[0].CreationTime) != tt.expectedFirst { + t.Errorf("updatesAfter(updates, %d) first update = %d, want %d", *tt.timestamp, utils.Deref(result[0].CreationTime), tt.expectedFirst) } }) } @@ -146,17 +147,17 @@ func TestUpdatesEmptySlice(t *testing.T) { func TestFilterUpdates(t *testing.T) { // Test data: updates sorted in descending order (newest first) updates := []pipelines.UpdateInfo{ - {CreationTime: 1000}, // newest - {CreationTime: 800}, - {CreationTime: 600}, - {CreationTime: 400}, - {CreationTime: 200}, // oldest + {CreationTime: new(int64(1000))}, // newest + {CreationTime: new(int64(800))}, + {CreationTime: new(int64(600))}, + {CreationTime: new(int64(400))}, + {CreationTime: new(int64(200))}, // oldest } var noUpdates []pipelines.UpdateInfo oneUpdate := []pipelines.UpdateInfo{ - {CreationTime: 500}, + {CreationTime: new(int64(500))}, } tests := []struct { @@ -279,11 +280,11 @@ func TestFilterUpdates(t *testing.T) { t.Errorf("filterUpdates() returned %d updates, want %d", len(result), tt.expectedCount) } if tt.expectedCount > 0 { - if result[0].CreationTime != tt.expectedFirst { - t.Errorf("filterUpdates() first update = %d, want %d", result[0].CreationTime, tt.expectedFirst) + if utils.Deref(result[0].CreationTime) != tt.expectedFirst { + t.Errorf("filterUpdates() first update = %d, want %d", utils.Deref(result[0].CreationTime), tt.expectedFirst) } - if result[len(result)-1].CreationTime != tt.expectedLast { - t.Errorf("filterUpdates() last update = %d, want %d", result[len(result)-1].CreationTime, tt.expectedLast) + if utils.Deref(result[len(result)-1].CreationTime) != tt.expectedLast { + t.Errorf("filterUpdates() last update = %d, want %d", utils.Deref(result[len(result)-1].CreationTime), tt.expectedLast) } } }) diff --git a/cmd/pipelines/run.go b/cmd/pipelines/run.go index 9f81961b6f0..88bfd444aa6 100644 --- a/cmd/pipelines/run.go +++ b/cmd/pipelines/run.go @@ -23,8 +23,10 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/logdiag" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + libutils "github.com/databricks/cli/libs/utils" + sdkpipelines "github.com/databricks/sdk-go/pipelines/v2" "github.com/spf13/cobra" ) @@ -44,13 +46,26 @@ type ProgressEventsData struct { ProgressEvents []ProgressEventWithDuration } +// updateStates lists the pipeline update states in the order they are +// matched against event messages. +var updateStates = []pipelines.UpdateState{ + pipelines.UpdateState_Canceled, + pipelines.UpdateState_Completed, + pipelines.UpdateState_Created, + pipelines.UpdateState_Failed, + pipelines.UpdateState_Initializing, + pipelines.UpdateState_Queued, + pipelines.UpdateState_Resetting, + pipelines.UpdateState_Running, + pipelines.UpdateState_SettingUpTables, + pipelines.UpdateState_Stopping, + pipelines.UpdateState_WaitingForResources, +} + // phaseFromUpdateProgress extracts the phase name from an event message by checking if it contains any of the UpdateInfoState values // Example: "Update 6fc8a8 is WAITING_FOR_RESOURCES." -> "WAITING_FOR_RESOURCES" func phaseFromUpdateProgress(eventMessage string) (string, error) { - var updateInfoState pipelines.UpdateInfoState - updateInfoStates := updateInfoState.Values() - - for _, state := range updateInfoStates { + for _, state := range updateStates { if strings.Contains(eventMessage, string(state)) { return string(state), nil } @@ -87,11 +102,11 @@ func readableDuration(diff time.Duration) (string, error) { // eventTimeDifference returns the time difference between two events. func eventTimeDifference(earlierEvent, laterEvent pipelines.PipelineEvent) (time.Duration, error) { - earlierTime, err := time.Parse(time.RFC3339Nano, earlierEvent.Timestamp) + earlierTime, err := time.Parse(time.RFC3339Nano, libutils.Deref(earlierEvent.Timestamp)) if err != nil { return 0, err } - laterTime, err := time.Parse(time.RFC3339Nano, laterEvent.Timestamp) + laterTime, err := time.Parse(time.RFC3339Nano, libutils.Deref(laterEvent.Timestamp)) if err != nil { return 0, err } @@ -112,7 +127,7 @@ func enrichEvents(events []pipelines.PipelineEvent, endTime string) ([]ProgressE var nextEvent pipelines.PipelineEvent event := events[j] if j == len(events)-1 { - nextEvent = pipelines.PipelineEvent{Timestamp: endTime} + nextEvent = pipelines.PipelineEvent{Timestamp: new(endTime)} } else { nextEvent = events[j+1] } @@ -124,7 +139,7 @@ func enrichEvents(events []pipelines.PipelineEvent, endTime string) ([]ProgressE if err != nil { return nil, err } - phase, err := phaseFromUpdateProgress(event.Message) + phase, err := phaseFromUpdateProgress(libutils.Deref(event.Message)) if err != nil { return nil, err } @@ -157,7 +172,7 @@ func displayProgressEventsDurations(ctx context.Context, events []pipelines.Pipe } // fetchAndDisplayPipelineUpdate fetches the update and the update's associated update_progress events' durations. -func fetchAndDisplayPipelineUpdate(ctx context.Context, w *databricks.WorkspaceClient, pipelineId, updateId string) error { +func fetchAndDisplayPipelineUpdate(ctx context.Context, w *sdkclients.Clients, pipelineId, updateId string) error { if pipelineId == "" { return errors.New("no pipeline ID provided") } @@ -165,13 +180,17 @@ func fetchAndDisplayPipelineUpdate(ctx context.Context, w *databricks.WorkspaceC return errors.New("no update ID provided") } - getUpdateResponse, err := w.Pipelines.GetUpdate(ctx, pipelines.GetUpdateRequest{ - PipelineId: pipelineId, - UpdateId: updateId, + sdkResponse, err := w.Pipelines.GetUpdate(ctx, sdkpipelines.GetUpdateRequest{ + PipelineId: new(pipelineId), + UpdateId: new(updateId), }) if err != nil { return err } + getUpdateResponse, err := pipelines.GetUpdateResponseFromSDK(sdkResponse) + if err != nil { + return err + } if getUpdateResponse.Update == nil { return fmt.Errorf("no update found with id %s for pipeline %s", updateId, pipelineId) @@ -209,7 +228,7 @@ func getLastEventTime(events []pipelines.PipelineEvent) string { return "" } lastEvent := events[len(events)-1] - parsedTime, err := time.Parse(time.RFC3339Nano, lastEvent.Timestamp) + parsedTime, err := time.Parse(time.RFC3339Nano, libutils.Deref(lastEvent.Timestamp)) if err != nil { return "" } diff --git a/cmd/pipelines/run_test.go b/cmd/pipelines/run_test.go index 9937cb83d0d..c57f73b5cab 100644 --- a/cmd/pipelines/run_test.go +++ b/cmd/pipelines/run_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/stretchr/testify/assert" ) @@ -20,31 +20,31 @@ func TestDisplayPipelineUpdate(t *testing.T) { { name: "comprehensive pipeline update with all fields", update: pipelines.UpdateInfo{ - UpdateId: "update-123", - FullRefresh: true, + UpdateId: new("update-123"), + FullRefresh: new(true), Cause: "Manual trigger", - CreationTime: 1640995200000, // 2022-01-01T00:00:00Z - ClusterId: "cluster-456", + CreationTime: new(int64(1640995200000)), // 2022-01-01T00:00:00Z + ClusterId: new("cluster-456"), Config: &pipelines.PipelineSpec{ - Name: "test-pipeline", - Id: "pipeline-789", - Serverless: true, - Channel: "CURRENT", - Continuous: true, //nolint:staticcheck // SA1019: pipeline continuous is deprecated in the SDK but remains a supported bundle config field - Development: true, //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field - Catalog: "test_catalog", - Schema: "test_schema", + Name: new("test-pipeline"), + Id: new("pipeline-789"), + Serverless: new(true), + Channel: new("CURRENT"), + Continuous: new(true), //nolint:staticcheck // SA1019: pipeline continuous is deprecated in the SDK but remains a supported bundle config field + Development: new(true), //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field + Catalog: new("test_catalog"), + Schema: new("test_schema"), }, }, pipelineID: "pipeline-456", events: []pipelines.PipelineEvent{ { - Timestamp: "2022-01-01T00:00:00Z", - EventType: "update_progress", + Timestamp: new("2022-01-01T00:00:00Z"), + EventType: new("update_progress"), }, { - Timestamp: "2022-01-01T01:00:00Z", - EventType: "update_progress", + Timestamp: new("2022-01-01T01:00:00Z"), + EventType: new("update_progress"), }, }, expected: ` @@ -68,7 +68,7 @@ Pipeline configurations for this update: { name: "minimal pipeline update with default refresh", update: pipelines.UpdateInfo{ - UpdateId: "update-456", + UpdateId: new("update-456"), }, pipelineID: "pipeline-789", events: []pipelines.PipelineEvent{}, @@ -82,15 +82,15 @@ Pipeline configurations for this update: { name: "pipeline update with mixed refresh selections", update: pipelines.UpdateInfo{ - UpdateId: "update-789", + UpdateId: new("update-789"), RefreshSelection: []string{"table1", "table2"}, FullRefreshSelection: []string{"table3"}, }, pipelineID: "pipeline-101", events: []pipelines.PipelineEvent{ { - Timestamp: "2022-01-01T02:00:00Z", - EventType: "update_progress", + Timestamp: new("2022-01-01T02:00:00Z"), + EventType: new("update_progress"), }, }, expected: ` @@ -104,11 +104,11 @@ Pipeline configurations for this update: { name: "pipeline update with storage instead of catalog/schema", update: pipelines.UpdateInfo{ - UpdateId: "update-storage", + UpdateId: new("update-storage"), Config: &pipelines.PipelineSpec{ - Name: "test-pipeline", - Id: "pipeline-789", - Storage: "test_storage", + Name: new("test-pipeline"), + Id: new("pipeline-789"), + Storage: new("test_storage"), }, }, pipelineID: "pipeline-456", @@ -126,8 +126,8 @@ Pipeline configurations for this update: { name: "pipeline update with classic compute and no config", update: pipelines.UpdateInfo{ - UpdateId: "update-classic", - ClusterId: "cluster-123", + UpdateId: new("update-classic"), + ClusterId: new("cluster-123"), }, pipelineID: "pipeline-456", events: []pipelines.PipelineEvent{}, @@ -163,10 +163,10 @@ func TestEventTimeDifference(t *testing.T) { { name: "normal time difference - seconds", earlierEvent: pipelines.PipelineEvent{ - Timestamp: "2022-01-01T00:00:00.000Z", + Timestamp: new("2022-01-01T00:00:00.000Z"), }, laterEvent: pipelines.PipelineEvent{ - Timestamp: "2022-01-01T00:00:05.000Z", + Timestamp: new("2022-01-01T00:00:05.000Z"), }, expectedResult: 5 * time.Second, expectedError: "", @@ -174,10 +174,10 @@ func TestEventTimeDifference(t *testing.T) { { name: "normal time difference - minutes and seconds", earlierEvent: pipelines.PipelineEvent{ - Timestamp: "2022-01-01T00:00:00.000Z", + Timestamp: new("2022-01-01T00:00:00.000Z"), }, laterEvent: pipelines.PipelineEvent{ - Timestamp: "2022-01-01T00:01:30.000Z", + Timestamp: new("2022-01-01T00:01:30.000Z"), }, expectedResult: 90 * time.Second, expectedError: "", @@ -185,10 +185,10 @@ func TestEventTimeDifference(t *testing.T) { { name: "millisecond precision", earlierEvent: pipelines.PipelineEvent{ - Timestamp: "2022-01-01T00:00:00.000Z", + Timestamp: new("2022-01-01T00:00:00.000Z"), }, laterEvent: pipelines.PipelineEvent{ - Timestamp: "2022-01-01T00:00:00.500Z", + Timestamp: new("2022-01-01T00:00:00.500Z"), }, expectedResult: 500 * time.Millisecond, expectedError: "", @@ -196,10 +196,10 @@ func TestEventTimeDifference(t *testing.T) { { name: "edge case - same timestamp", earlierEvent: pipelines.PipelineEvent{ - Timestamp: "2022-01-01T00:00:00.000Z", + Timestamp: new("2022-01-01T00:00:00.000Z"), }, laterEvent: pipelines.PipelineEvent{ - Timestamp: "2022-01-01T00:00:00.000Z", + Timestamp: new("2022-01-01T00:00:00.000Z"), }, expectedResult: 0, expectedError: "", @@ -207,10 +207,10 @@ func TestEventTimeDifference(t *testing.T) { { name: "edge case - invalid timestamp format", earlierEvent: pipelines.PipelineEvent{ - Timestamp: "invalid-timestamp", + Timestamp: new("invalid-timestamp"), }, laterEvent: pipelines.PipelineEvent{ - Timestamp: "2022-01-01T00:00:00.000Z", + Timestamp: new("2022-01-01T00:00:00.000Z"), }, expectedResult: 0, expectedError: "parsing time \"invalid-timestamp\" as \"2006-01-02T15:04:05.999999999Z07:00\": cannot parse \"invalid-timestamp\" as \"2006\"", @@ -218,10 +218,10 @@ func TestEventTimeDifference(t *testing.T) { { name: "edge case - later event before earlier event", earlierEvent: pipelines.PipelineEvent{ - Timestamp: "2022-01-01T00:00:05.000Z", + Timestamp: new("2022-01-01T00:00:05.000Z"), }, laterEvent: pipelines.PipelineEvent{ - Timestamp: "2022-01-01T00:00:00.000Z", + Timestamp: new("2022-01-01T00:00:00.000Z"), }, expectedResult: 0, expectedError: "second event timestamp must be after first event timestamp", @@ -282,34 +282,34 @@ func TestDisplayProgressEventsDurations(t *testing.T) { name: "pipeline completed with all phases", events: []pipelines.PipelineEvent{ { - Timestamp: "2022-01-01T00:00:01.000Z", - EventType: "update_progress", - Message: "Update test-update-123 is CREATED.", + Timestamp: new("2022-01-01T00:00:01.000Z"), + EventType: new("update_progress"), + Message: new("Update test-update-123 is CREATED."), }, { - Timestamp: "2022-01-01T00:00:02.000Z", - EventType: "update_progress", - Message: "Update test-update-123 is WAITING_FOR_RESOURCES.", + Timestamp: new("2022-01-01T00:00:02.000Z"), + EventType: new("update_progress"), + Message: new("Update test-update-123 is WAITING_FOR_RESOURCES."), }, { - Timestamp: "2022-01-01T00:00:03.000Z", - EventType: "update_progress", - Message: "Update test-update-123 is INITIALIZING.", + Timestamp: new("2022-01-01T00:00:03.000Z"), + EventType: new("update_progress"), + Message: new("Update test-update-123 is INITIALIZING."), }, { - Timestamp: "2022-01-01T00:00:04.000Z", - EventType: "update_progress", - Message: "Update test-update-123 is SETTING_UP_TABLES.", + Timestamp: new("2022-01-01T00:00:04.000Z"), + EventType: new("update_progress"), + Message: new("Update test-update-123 is SETTING_UP_TABLES."), }, { - Timestamp: "2022-01-01T00:00:05.000Z", - EventType: "update_progress", - Message: "Update test-update-123 is RUNNING.", + Timestamp: new("2022-01-01T00:00:05.000Z"), + EventType: new("update_progress"), + Message: new("Update test-update-123 is RUNNING."), }, { - Timestamp: "2022-01-01T00:01:30.000Z", - EventType: "update_progress", - Message: "Update test-update-123 is COMPLETED.", + Timestamp: new("2022-01-01T00:01:30.000Z"), + EventType: new("update_progress"), + Message: new("Update test-update-123 is COMPLETED."), }, }, expected: ` @@ -326,19 +326,19 @@ RUNNING 1m 25s name: "pipeline with millisecond and decimal second durations", events: []pipelines.PipelineEvent{ { - Timestamp: "2022-01-01T00:00:00.000Z", - EventType: "update_progress", - Message: "Update test-update-ms is WAITING_FOR_RESOURCES.", + Timestamp: new("2022-01-01T00:00:00.000Z"), + EventType: new("update_progress"), + Message: new("Update test-update-ms is WAITING_FOR_RESOURCES."), }, { - Timestamp: "2022-01-01T00:00:00.500Z", - EventType: "update_progress", - Message: "Update test-update-ms is RUNNING.", + Timestamp: new("2022-01-01T00:00:00.500Z"), + EventType: new("update_progress"), + Message: new("Update test-update-ms is RUNNING."), }, { - Timestamp: "2022-01-01T00:00:01.250Z", - EventType: "update_progress", - Message: "Update test-update-ms is COMPLETED.", + Timestamp: new("2022-01-01T00:00:01.250Z"), + EventType: new("update_progress"), + Message: new("Update test-update-ms is COMPLETED."), }, }, expected: ` @@ -358,9 +358,9 @@ RUNNING 750ms name: "edge cases - single event", events: []pipelines.PipelineEvent{ { - Timestamp: "2022-01-01T00:00:00Z", - EventType: "update_progress", - Message: "Update test-update-single is RUNNING.", + Timestamp: new("2022-01-01T00:00:00Z"), + EventType: new("update_progress"), + Message: new("Update test-update-single is RUNNING."), }, }, expected: "", diff --git a/cmd/pipelines/show.go b/cmd/pipelines/show.go index af8fd732d4c..8af0af592ef 100644 --- a/cmd/pipelines/show.go +++ b/cmd/pipelines/show.go @@ -12,8 +12,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/databrickscfg/cfgpickers" "github.com/databricks/cli/libs/flags" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/sqlexec" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/utils" "github.com/spf13/cobra" ) @@ -94,7 +95,7 @@ schema.table (legacy Hive metastore).`, // warehouse to query either --warehouse-id flag, DATABRICKS_WAREHOUSE_ID config, // or the workspace default warehouse. -func resolveWarehouseID(ctx context.Context, w *databricks.WorkspaceClient, flag string) (string, error) { +func resolveWarehouseID(ctx context.Context, w *sdkclients.Clients, flag string) (string, error) { if flag != "" { return flag, nil } @@ -108,7 +109,7 @@ func resolveWarehouseID(ctx context.Context, w *databricks.WorkspaceClient, flag if err != nil { return "", err } - return warehouse.Id, nil + return utils.Deref(warehouse.Id), nil } // writes the result as JSON (--output json) or a terminal-width-aware table. diff --git a/cmd/pipelines/show_test.go b/cmd/pipelines/show_test.go index 116762b6b92..679e62cdfb8 100644 --- a/cmd/pipelines/show_test.go +++ b/cmd/pipelines/show_test.go @@ -2,22 +2,25 @@ package pipelines import ( "context" + "encoding/json" + "errors" "testing" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/httpfixtures" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/sqlexec" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/utils" "github.com/databricks/databricks-sdk-go/config" - mocksql "github.com/databricks/databricks-sdk-go/experimental/mocks/service/sql" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/sdk-go/options/call" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestResolveWarehouseIDFlagWins(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - w := &databricks.WorkspaceClient{Config: &config.Config{WarehouseID: "from-config"}} + w := &sdkclients.Clients{Config: &config.Config{WarehouseID: "from-config"}} id, err := resolveWarehouseID(ctx, w, "from-flag") require.NoError(t, err) assert.Equal(t, "from-flag", id) @@ -25,7 +28,7 @@ func TestResolveWarehouseIDFlagWins(t *testing.T) { func TestResolveWarehouseIDFallsBackToConfig(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - w := &databricks.WorkspaceClient{Config: &config.Config{WarehouseID: "from-config"}} + w := &sdkclients.Clients{Config: &config.Config{WarehouseID: "from-config"}} id, err := resolveWarehouseID(ctx, w, "") require.NoError(t, err) assert.Equal(t, "from-config", id) @@ -33,33 +36,55 @@ func TestResolveWarehouseIDFallsBackToConfig(t *testing.T) { func TestResolveWarehouseIDUsesDefaultWarehouse(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockWH := mocksql.NewMockWarehousesInterface(t) - mockWH.EXPECT().Get(mock.Anything, sql.GetWarehouseRequest{Id: "default"}). - Return(&sql.GetWarehouseResponse{Id: "wh-default"}, nil) - - w := &databricks.WorkspaceClient{Config: &config.Config{}, Warehouses: mockWH} + cfg, _ := httpfixtures.Fixtures{{ + Method: "GET", + Resource: "/api/2.0/sql/warehouses/default", + Response: `{"id":"wh-default"}`, + }}.Config(t) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) id, err := resolveWarehouseID(ctx, w, "") require.NoError(t, err) assert.Equal(t, "wh-default", id) } +// fakeStatements implements sqlexec.API; only ExecuteStatement is expected. +type fakeStatements struct { + execute func(context.Context, sql.ExecuteStatementRequest) (*sql.StatementResponse, error) +} + +func (f fakeStatements) ExecuteStatement(ctx context.Context, req sql.ExecuteStatementRequest, _ ...call.Option) (*sql.StatementResponse, error) { + return f.execute(ctx, req) +} + +func (fakeStatements) GetStatementResult(context.Context, sql.GetStatementResultRequest, ...call.Option) (*sql.StatementResponse, error) { + return nil, errors.New("unexpected GetStatementResult") +} + +func (fakeStatements) GetResultData(context.Context, sql.GetResultDataRequest, ...call.Option) (*sql.ResultData, error) { + return nil, errors.New("unexpected GetResultData") +} + +func (fakeStatements) CancelStatement(context.Context, sql.CancelStatementRequest, ...call.Option) (*sql.CancelStatementResponse, error) { + return &sql.CancelStatementResponse{}, nil +} + func TestExecuteSelectQuotesAndLimits(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) - - mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.WarehouseId == "wh-1" && - req.Statement == "SELECT * FROM `main`.`sales`.`orders` LIMIT 25" - })).Return(&sql.StatementResponse{ - StatementId: "s1", - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, - Manifest: &sql.ResultManifest{Schema: &sql.ResultSchema{Columns: []sql.ColumnInfo{{Name: "id"}}}}, - Result: &sql.ResultData{DataArray: [][]string{{"1"}}}, - }, nil) + api := fakeStatements{execute: func(_ context.Context, req sql.ExecuteStatementRequest) (*sql.StatementResponse, error) { + assert.Equal(t, "wh-1", utils.Deref(req.WarehouseId)) + assert.Equal(t, "SELECT * FROM `main`.`sales`.`orders` LIMIT 25", utils.Deref(req.Statement)) + return &sql.StatementResponse{ + StatementId: new("s1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, + Manifest: &sql.ResultManifest{Schema: &sql.Schema{Columns: []sql.ColumnInfo{{Name: new("id")}}}}, + Result: &sql.ResultData{DataArray: [][]json.RawMessage{{json.RawMessage(`"1"`)}}}, + }, nil + }} quoted, err := quoteTableName("main.sales.orders") require.NoError(t, err) - client := sqlexec.New(mockAPI, "wh-1") + client := sqlexec.New(api, "wh-1") result, err := client.Execute(ctx, "SELECT * FROM "+quoted+" LIMIT 25") require.NoError(t, err) assert.Equal(t, []string{"id"}, result.Columns) @@ -68,36 +93,33 @@ func TestExecuteSelectQuotesAndLimits(t *testing.T) { func TestExecuteSelectSurfacesStatementError(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) - - mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.Anything).Return(&sql.StatementResponse{ - StatementId: "s1", - Status: &sql.StatementStatus{ - State: sql.StatementStateFailed, - Error: &sql.ServiceError{ErrorCode: sql.ServiceErrorCodeBadRequest, Message: "TABLE_OR_VIEW_NOT_FOUND"}, - }, - }, nil) - - client := sqlexec.New(mockAPI, "wh-1") + api := fakeStatements{execute: func(context.Context, sql.ExecuteStatementRequest) (*sql.StatementResponse, error) { + return &sql.StatementResponse{ + StatementId: new("s1"), + Status: &sql.StatementStatus{ + State: sql.StatementStatus_State_Failed, + Error: &sql.ServiceError{ErrorCode: sql.ServiceErrorCode_BadRequest, Message: new("TABLE_OR_VIEW_NOT_FOUND")}, + }, + }, nil + }} + + client := sqlexec.New(api, "wh-1") _, err := client.Execute(ctx, "SELECT * FROM `x`.`y`.`z` LIMIT 25") require.Error(t, err) var stmtErr *sqlexec.StatementError require.ErrorAs(t, err, &stmtErr) - assert.Equal(t, sql.ServiceErrorCodeBadRequest, stmtErr.Code) + assert.Equal(t, sql.ServiceErrorCode_BadRequest, stmtErr.Code) } func TestExecuteSelectInterruptedSetsContextError(t *testing.T) { ctx, cancel := context.WithCancel(cmdio.MockDiscard(t.Context())) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) - - mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.Anything).RunAndReturn( - func(context.Context, sql.ExecuteStatementRequest) (*sql.StatementResponse, error) { - cancel() - return &sql.StatementResponse{StatementId: "s1", Status: &sql.StatementStatus{State: sql.StatementStatePending}}, nil - }) + api := fakeStatements{execute: func(context.Context, sql.ExecuteStatementRequest) (*sql.StatementResponse, error) { + cancel() + return &sql.StatementResponse{StatementId: new("s1"), Status: &sql.StatementStatus{State: sql.StatementStatus_State_Pending}}, nil + }} - client := sqlexec.New(mockAPI, "wh-1") + client := sqlexec.New(api, "wh-1") _, err := client.Execute(ctx, "SELECT * FROM `x`.`y`.`z` LIMIT 25") require.Error(t, err) assert.Error(t, ctx.Err()) diff --git a/cmd/pipelines/utils.go b/cmd/pipelines/utils.go index 39cc74f3681..aa8f13c8a6d 100644 --- a/cmd/pipelines/utils.go +++ b/cmd/pipelines/utils.go @@ -12,13 +12,15 @@ import ( configresources "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/bundle/resources" "github.com/databricks/cli/bundle/run" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/logdiag" - databricks "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/utils" + sdkpipelines "github.com/databricks/sdk-go/pipelines/v2" "github.com/spf13/cobra" ) @@ -156,13 +158,13 @@ type PipelineEventsQueryParams struct { // fetchAllPipelineEvents retrieves pipeline events with optional SQL filtering and ordering. // Necessary as current Go SDK endpoints don't support OrderBy parameter. // Retrieves only one page of results, so the number of results is bound by the API's limit of results per page. -func fetchAllPipelineEvents(ctx context.Context, w *databricks.WorkspaceClient, pipelineID string, params *PipelineEventsQueryParams) ([]pipelines.PipelineEvent, error) { +func fetchAllPipelineEvents(ctx context.Context, w *sdkclients.Clients, pipelineID string, params *PipelineEventsQueryParams) ([]pipelines.PipelineEvent, error) { maxResultsPerPage := 250 if params.MaxResults > maxResultsPerPage { return nil, fmt.Errorf("number of results must be %d or less", maxResultsPerPage) } - apiClient, err := client.New(w.Config) + apiClient, err := apiclient.New(w.Config) if err != nil { return nil, fmt.Errorf("failed to create API client: %w", err) } @@ -201,12 +203,10 @@ func fetchAllPipelineEvents(ctx context.Context, w *databricks.WorkspaceClient, // getMostRecentUpdateId fetches one page of updates for a given pipeline and returns the first update ID. // Expects to receive updates in decreasing timestamp order, so the first update is the most recent. -func getMostRecentUpdateId(ctx context.Context, w *databricks.WorkspaceClient, pipelineID string) (string, error) { - request := pipelines.ListUpdatesRequest{ - PipelineId: pipelineID, - } - - response, err := w.Pipelines.ListUpdates(ctx, request) +func getMostRecentUpdateId(ctx context.Context, w *sdkclients.Clients, pipelineID string) (string, error) { + response, err := listUpdates(ctx, w, sdkpipelines.ListUpdatesRequest{ + PipelineId: new(pipelineID), + }) if err != nil { return "", err } @@ -216,7 +216,7 @@ func getMostRecentUpdateId(ctx context.Context, w *databricks.WorkspaceClient, p return "", errors.New("no updates") } - return updates[0].UpdateId, nil + return utils.Deref(updates[0].UpdateId), nil } // parseAndFormatTimestamp parses a timestamp string and formats it to the pipeline events API format. @@ -252,7 +252,7 @@ func parseTimeToUnixMillis(timeStr string) (*int64, error) { func updatesBefore(updates []pipelines.UpdateInfo, ts int64) []pipelines.UpdateInfo { // Binary search for index with CreationTime <= ts idx, _ := slices.BinarySearchFunc(updates, ts, func(u pipelines.UpdateInfo, target int64) int { - if u.CreationTime <= target { + if utils.Deref(u.CreationTime) <= target { return 1 } return -1 @@ -266,7 +266,7 @@ func updatesBefore(updates []pipelines.UpdateInfo, ts int64) []pipelines.UpdateI func updatesAfter(updates []pipelines.UpdateInfo, ts int64) []pipelines.UpdateInfo { // Binary search for index with CreationTime < ts idx, _ := slices.BinarySearchFunc(updates, ts, func(u pipelines.UpdateInfo, target int64) int { - if u.CreationTime < target { + if utils.Deref(u.CreationTime) < target { return 1 } return -1 @@ -283,15 +283,15 @@ func filterUpdates(updates []pipelines.UpdateInfo, startTime, endTime *int64) ([ return updates, nil } - if (endTime == nil || updates[0].CreationTime <= *endTime) && (startTime == nil || updates[len(updates)-1].CreationTime >= *startTime) { + if (endTime == nil || utils.Deref(updates[0].CreationTime) <= *endTime) && (startTime == nil || utils.Deref(updates[len(updates)-1].CreationTime) >= *startTime) { return updates, nil } - if startTime != nil && updates[0].CreationTime < *startTime { + if startTime != nil && utils.Deref(updates[0].CreationTime) < *startTime { return nil, nil } - if endTime != nil && updates[len(updates)-1].CreationTime > *endTime { + if endTime != nil && utils.Deref(updates[len(updates)-1].CreationTime) > *endTime { return nil, nil } @@ -308,20 +308,20 @@ func filterUpdates(updates []pipelines.UpdateInfo, startTime, endTime *int64) ([ // fetchPipelineUpdates fetches pipeline updates with optional filtering by time. // Time is in milliseconds since epoch. If time is nil, it is ignored. -func fetchPipelineUpdates(ctx context.Context, w *databricks.WorkspaceClient, startTime, endTime *int64, pipelineId string) ([]pipelines.UpdateInfo, error) { +func fetchPipelineUpdates(ctx context.Context, w *sdkclients.Clients, startTime, endTime *int64, pipelineId string) ([]pipelines.UpdateInfo, error) { var updates []pipelines.UpdateInfo var pageToken string for { - request := pipelines.ListUpdatesRequest{ - PipelineId: pipelineId, + request := sdkpipelines.ListUpdatesRequest{ + PipelineId: new(pipelineId), } if pageToken != "" { - request.PageToken = pageToken + request.PageToken = new(pageToken) } - response, err := w.Pipelines.ListUpdates(ctx, request) + response, err := listUpdates(ctx, w, request) if err != nil { return nil, err } @@ -332,10 +332,10 @@ func fetchPipelineUpdates(ctx context.Context, w *databricks.WorkspaceClient, st } updates = append(updates, filteredUpdates...) - if response.NextPageToken == "" { + if utils.Deref(response.NextPageToken) == "" { break } - pageToken = response.NextPageToken + pageToken = *response.NextPageToken } return updates, nil @@ -363,3 +363,12 @@ If you've made local changes, run '%s' first to ensure they are included.`, logdiag.LogDiag(ctx, el) } } + +// listUpdates lists one page of pipeline updates as JSON-capable mirrors. +func listUpdates(ctx context.Context, w *sdkclients.Clients, request sdkpipelines.ListUpdatesRequest) (*pipelines.ListUpdatesResponse, error) { + response, err := w.Pipelines.ListUpdates(ctx, request) + if err != nil { + return nil, err + } + return pipelines.ListUpdatesResponseFromSDK(response) +} diff --git a/cmd/psql/psql.go b/cmd/psql/psql.go index b07f37f6c6c..80c5cb78821 100644 --- a/cmd/psql/psql.go +++ b/cmd/psql/psql.go @@ -11,10 +11,12 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdgroup" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/listing" libpsql "github.com/databricks/cli/libs/psql" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/database" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + database "github.com/databricks/sdk-go/database/v1" + postgres "github.com/databricks/sdk-go/postgres/v1" "github.com/spf13/cobra" ) @@ -188,10 +190,10 @@ For more information, see: https://docs.databricks.com/aws/en/oltp/ var names []string for _, inst := range instances { - names = append(names, inst.Name) + names = append(names, utils.Deref(inst.Name)) } for _, proj := range projects { - names = append(names, proj.Name) + names = append(names, utils.Deref(proj.Name)) } return names, cobra.ShellCompDirectiveNoFileComp @@ -243,7 +245,7 @@ func parseResourcePath(input string) (project, branch, endpoint string, err erro // A single failing call is tolerated because a workspace may have only one of // the two products enabled; an error is returned only when both calls fail, // so that e.g. an auth failure is not reported as an empty workspace. -func listAllDatabases(ctx context.Context, w *databricks.WorkspaceClient) ([]database.DatabaseInstance, []postgres.Project, error) { +func listAllDatabases(ctx context.Context, w *sdkclients.Clients) ([]database.DatabaseInstance, []postgres.Project, error) { type result[T any] struct { value []T err error @@ -253,12 +255,12 @@ func listAllDatabases(ctx context.Context, w *databricks.WorkspaceClient) ([]dat projectsCh := make(chan result[postgres.Project], 1) go func() { - instances, err := w.Database.ListDatabaseInstancesAll(ctx, database.ListDatabaseInstancesRequest{}) + instances, err := listing.Collect(w.Database.ListDatabaseInstancesIter(ctx, database.ListDatabaseInstancesRequest{})) instancesCh <- result[database.DatabaseInstance]{instances, err} }() go func() { - projects, err := w.Postgres.ListProjectsAll(ctx, postgres.ListProjectsRequest{}) + projects, err := listing.Collect(w.Postgres.ListProjectsIter(ctx, postgres.ListProjectsRequest{})) projectsCh <- result[postgres.Project]{projects, err} }() @@ -301,18 +303,18 @@ func showSelectionAndConnect(ctx context.Context, retryConfig libpsql.RetryConfi var items []cmdio.Tuple for _, inst := range instances { items = append(items, cmdio.Tuple{ - Name: inst.Name + " (provisioned)", - Id: "provisioned:" + inst.Name, + Name: utils.Deref(inst.Name) + " (provisioned)", + Id: "provisioned:" + utils.Deref(inst.Name), }) } for _, proj := range projects { - displayName := extractIDFromName(proj.Name, "projects") - if proj.Status != nil && proj.Status.DisplayName != "" { - displayName = proj.Status.DisplayName + displayName := extractIDFromName(utils.Deref(proj.Name), "projects") + if proj.Status != nil && utils.Deref(proj.Status.DisplayName) != "" { + displayName = utils.Deref(proj.Status.DisplayName) } items = append(items, cmdio.Tuple{ Name: displayName + " (autoscaling)", - Id: "autoscaling:" + proj.Name, + Id: "autoscaling:" + utils.Deref(proj.Name), }) } diff --git a/cmd/psql/psql_autoscaling.go b/cmd/psql/psql_autoscaling.go index 331e05b55b5..0f661df479c 100644 --- a/cmd/psql/psql_autoscaling.go +++ b/cmd/psql/psql_autoscaling.go @@ -8,10 +8,12 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/listing" libpsql "github.com/databricks/cli/libs/psql" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + postgres "github.com/databricks/sdk-go/postgres/v1" + sdkscim "github.com/databricks/sdk-go/scim/v1" ) // autoscalingDefaultDatabase is the default database for Lakebase Autoscaling projects. @@ -38,7 +40,7 @@ func connectAutoscaling(ctx context.Context, projectID, branchID, endpointID str return err } - user, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + user, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) if err != nil { return fmt.Errorf("failed to get current user: %w", err) } @@ -47,7 +49,7 @@ func connectAutoscaling(ctx context.Context, projectID, branchID, endpointID str return errors.New("endpoint status is not available") } - if endpoint.Status.Hosts == nil || endpoint.Status.Hosts.Host == "" { + if endpoint.Status.Hosts == nil || utils.Deref(endpoint.Status.Hosts.Host) == "" { return errors.New("endpoint host information is not available") } @@ -60,9 +62,9 @@ func connectAutoscaling(ctx context.Context, projectID, branchID, endpointID str var endpointType string switch endpoint.Status.EndpointType { - case postgres.EndpointTypeEndpointTypeReadWrite: + case postgres.EndpointType_EndpointTypeReadWrite: endpointType = "read-write" - case postgres.EndpointTypeEndpointTypeReadOnly: + case postgres.EndpointType_EndpointTypeReadOnly: endpointType = "read-only" default: endpointType = string(endpoint.Status.EndpointType) @@ -71,9 +73,9 @@ func connectAutoscaling(ctx context.Context, projectID, branchID, endpointID str state := endpoint.Status.CurrentState var suffix string switch state { - case postgres.EndpointStatusStateActive: + case postgres.EndpointStatus_State_Active: // No need to inform the user that the endpoint is active. - case postgres.EndpointStatusStateIdle: + case postgres.EndpointStatus_State_Idle: suffix = " (idle, waking up)" default: return errors.New("endpoint is not ready for accepting connections") @@ -82,9 +84,9 @@ func connectAutoscaling(ctx context.Context, projectID, branchID, endpointID str cmdio.LogString(ctx, fmt.Sprintf("Connecting to %s endpoint%s...", endpointType, suffix)) return libpsql.Connect(ctx, libpsql.ConnectOptions{ - Host: endpoint.Status.Hosts.Host, - Username: user.UserName, - Password: cred.Token, + Host: utils.Deref(endpoint.Status.Hosts.Host), + Username: utils.Deref(user.UserName), + Password: utils.Deref(cred.Token), DefaultDatabase: autoscalingDefaultDatabase, ExtraArgs: extraArgs, }, retryConfig) @@ -92,7 +94,7 @@ func connectAutoscaling(ctx context.Context, projectID, branchID, endpointID str // resolveEndpoint resolves a partial specification to a full endpoint. // Uses interactive selection when components are missing. -func resolveEndpoint(ctx context.Context, w *databricks.WorkspaceClient, projectID, branchID, endpointID string) (*postgres.Endpoint, error) { +func resolveEndpoint(ctx context.Context, w *sdkclients.Clients, projectID, branchID, endpointID string) (*postgres.Endpoint, error) { // If project not specified, select one if projectID == "" { var err error @@ -103,26 +105,26 @@ func resolveEndpoint(ctx context.Context, w *databricks.WorkspaceClient, project } // Get project to display its name - project, err := w.Postgres.GetProject(ctx, postgres.GetProjectRequest{Name: "projects/" + projectID}) + project, err := w.Postgres.GetProject(ctx, postgres.GetProjectRequest{Name: new("projects/" + projectID)}) if err != nil { return nil, fmt.Errorf("failed to get project: %w", err) } projectDisplayName := projectID - if project.Status != nil && project.Status.DisplayName != "" { - projectDisplayName = project.Status.DisplayName + if project.Status != nil && utils.Deref(project.Status.DisplayName) != "" { + projectDisplayName = utils.Deref(project.Status.DisplayName) } cmdio.LogString(ctx, "Project: "+projectDisplayName) // If branch not specified, select one if branchID == "" { - branchID, err = selectBranchID(ctx, w, project.Name) + branchID, err = selectBranchID(ctx, w, utils.Deref(project.Name)) if err != nil { return nil, fmt.Errorf("failed to select branch: %w", err) } } // Get branch to validate it exists - branch, err := w.Postgres.GetBranch(ctx, postgres.GetBranchRequest{Name: project.Name + "/branches/" + branchID}) + branch, err := w.Postgres.GetBranch(ctx, postgres.GetBranchRequest{Name: new(utils.Deref(project.Name) + "/branches/" + branchID)}) if err != nil { return nil, fmt.Errorf("failed to get branch: %w", err) } @@ -130,14 +132,14 @@ func resolveEndpoint(ctx context.Context, w *databricks.WorkspaceClient, project // If endpoint not specified, select one if endpointID == "" { - endpointID, err = selectEndpointID(ctx, w, branch.Name) + endpointID, err = selectEndpointID(ctx, w, utils.Deref(branch.Name)) if err != nil { return nil, fmt.Errorf("failed to select endpoint: %w", err) } } // Get endpoint to validate and return it - endpoint, err := w.Postgres.GetEndpoint(ctx, postgres.GetEndpointRequest{Name: branch.Name + "/endpoints/" + endpointID}) + endpoint, err := w.Postgres.GetEndpoint(ctx, postgres.GetEndpointRequest{Name: new(utils.Deref(branch.Name) + "/endpoints/" + endpointID)}) if err != nil { return nil, fmt.Errorf("failed to get endpoint: %w", err) } @@ -148,10 +150,10 @@ func resolveEndpoint(ctx context.Context, w *databricks.WorkspaceClient, project // selectProjectID auto-selects if there's only one project, otherwise prompts user to select. // Returns the project ID (not the full project object). -func selectProjectID(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { +func selectProjectID(ctx context.Context, w *sdkclients.Clients) (string, error) { sp := cmdio.NewSpinner(ctx) sp.Update("Loading projects...") - projects, err := w.Postgres.ListProjectsAll(ctx, postgres.ListProjectsRequest{}) + projects, err := listing.Collect(w.Postgres.ListProjectsIter(ctx, postgres.ListProjectsRequest{})) sp.Close() if err != nil { return "", err @@ -163,16 +165,16 @@ func selectProjectID(ctx context.Context, w *databricks.WorkspaceClient) (string // Auto-select if there's only one project if len(projects) == 1 { - return extractIDFromName(projects[0].Name, "projects"), nil + return extractIDFromName(utils.Deref(projects[0].Name), "projects"), nil } // Multiple projects, prompt user to select var items []cmdio.Tuple for _, project := range projects { - projectID := extractIDFromName(project.Name, "projects") + projectID := extractIDFromName(utils.Deref(project.Name), "projects") displayName := projectID - if project.Status != nil && project.Status.DisplayName != "" { - displayName = project.Status.DisplayName + if project.Status != nil && utils.Deref(project.Status.DisplayName) != "" { + displayName = utils.Deref(project.Status.DisplayName) } items = append(items, cmdio.Tuple{Name: displayName, Id: projectID}) } @@ -182,12 +184,12 @@ func selectProjectID(ctx context.Context, w *databricks.WorkspaceClient) (string // selectBranchID auto-selects if there's only one branch, otherwise prompts user to select. // Returns the branch ID (not the full branch object). -func selectBranchID(ctx context.Context, w *databricks.WorkspaceClient, projectName string) (string, error) { +func selectBranchID(ctx context.Context, w *sdkclients.Clients, projectName string) (string, error) { sp := cmdio.NewSpinner(ctx) sp.Update("Loading branches...") - branches, err := w.Postgres.ListBranchesAll(ctx, postgres.ListBranchesRequest{ - Parent: projectName, - }) + branches, err := listing.Collect(w.Postgres.ListBranchesIter(ctx, postgres.ListBranchesRequest{ + Parent: new(projectName), + })) sp.Close() if err != nil { return "", err @@ -199,13 +201,13 @@ func selectBranchID(ctx context.Context, w *databricks.WorkspaceClient, projectN // Auto-select if there's only one branch if len(branches) == 1 { - return extractIDFromName(branches[0].Name, "branches"), nil + return extractIDFromName(utils.Deref(branches[0].Name), "branches"), nil } // Multiple branches, prompt user to select var items []cmdio.Tuple for _, branch := range branches { - branchID := extractIDFromName(branch.Name, "branches") + branchID := extractIDFromName(utils.Deref(branch.Name), "branches") items = append(items, cmdio.Tuple{Name: branchID, Id: branchID}) } @@ -214,12 +216,12 @@ func selectBranchID(ctx context.Context, w *databricks.WorkspaceClient, projectN // selectEndpointID auto-selects if there's only one endpoint, otherwise prompts user to select. // Returns the endpoint ID (not the full endpoint object). -func selectEndpointID(ctx context.Context, w *databricks.WorkspaceClient, branchName string) (string, error) { +func selectEndpointID(ctx context.Context, w *sdkclients.Clients, branchName string) (string, error) { sp := cmdio.NewSpinner(ctx) sp.Update("Loading endpoints...") - endpoints, err := w.Postgres.ListEndpointsAll(ctx, postgres.ListEndpointsRequest{ - Parent: branchName, - }) + endpoints, err := listing.Collect(w.Postgres.ListEndpointsIter(ctx, postgres.ListEndpointsRequest{ + Parent: new(branchName), + })) sp.Close() if err != nil { return "", err @@ -231,13 +233,13 @@ func selectEndpointID(ctx context.Context, w *databricks.WorkspaceClient, branch // Auto-select if there's only one endpoint if len(endpoints) == 1 { - return extractIDFromName(endpoints[0].Name, "endpoints"), nil + return extractIDFromName(utils.Deref(endpoints[0].Name), "endpoints"), nil } // Multiple endpoints, prompt user to select var items []cmdio.Tuple for _, endpoint := range endpoints { - endpointID := extractIDFromName(endpoint.Name, "endpoints") + endpointID := extractIDFromName(utils.Deref(endpoint.Name), "endpoints") items = append(items, cmdio.Tuple{Name: endpointID, Id: endpointID}) } diff --git a/cmd/psql/psql_provisioned.go b/cmd/psql/psql_provisioned.go index b66f17d1508..17b3f9704ef 100644 --- a/cmd/psql/psql_provisioned.go +++ b/cmd/psql/psql_provisioned.go @@ -7,10 +7,12 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/listing" libpsql "github.com/databricks/cli/libs/psql" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/database" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + database "github.com/databricks/sdk-go/database/v1" + sdkscim "github.com/databricks/sdk-go/scim/v1" "github.com/google/uuid" ) @@ -27,22 +29,22 @@ func connectProvisioned(ctx context.Context, instanceName string, retryConfig li return err } - user, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + user, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) if err != nil { return fmt.Errorf("failed to get current user: %w", err) } - if instance.State != database.DatabaseInstanceStateAvailable { + if instance.State != database.DatabaseInstance_State_Available { cmdio.LogString(ctx, fmt.Sprintf("Instance status: %s", instance.State)) - if instance.State == database.DatabaseInstanceStateStarting || instance.State == database.DatabaseInstanceStateUpdating || instance.State == database.DatabaseInstanceStateFailingOver { + if instance.State == database.DatabaseInstance_State_Starting || instance.State == database.DatabaseInstance_State_Updating || instance.State == database.DatabaseInstance_State_FailingOver { cmdio.LogString(ctx, "Please retry when the instance becomes available") } return errors.New("database instance is not ready for accepting connections") } cred, err := w.Database.GenerateDatabaseCredential(ctx, database.GenerateDatabaseCredentialRequest{ - InstanceNames: []string{instance.Name}, - RequestId: uuid.NewString(), + InstanceNames: []string{utils.Deref(instance.Name)}, + RequestId: new(uuid.NewString()), }) if err != nil { return fmt.Errorf("failed to get database credentials: %w", err) @@ -51,9 +53,9 @@ func connectProvisioned(ctx context.Context, instanceName string, retryConfig li cmdio.LogString(ctx, "Connecting to database instance...") return libpsql.Connect(ctx, libpsql.ConnectOptions{ - Host: instance.ReadWriteDns, - Username: user.UserName, - Password: cred.Token, + Host: utils.Deref(instance.ReadWriteDns), + Username: utils.Deref(user.UserName), + Password: utils.Deref(cred.Token), DefaultDatabase: provisionedDefaultDatabase, ExtraArgs: extraArgs, }, retryConfig) @@ -61,7 +63,7 @@ func connectProvisioned(ctx context.Context, instanceName string, retryConfig li // resolveInstance resolves an instance name to a full instance object. // If instanceName is empty, prompts the user to select one. -func resolveInstance(ctx context.Context, w *databricks.WorkspaceClient, instanceName string) (*database.DatabaseInstance, error) { +func resolveInstance(ctx context.Context, w *sdkclients.Clients, instanceName string) (*database.DatabaseInstance, error) { // If instance not specified, select one if instanceName == "" { var err error @@ -72,26 +74,26 @@ func resolveInstance(ctx context.Context, w *databricks.WorkspaceClient, instanc } instance, err := w.Database.GetDatabaseInstance(ctx, database.GetDatabaseInstanceRequest{ - Name: instanceName, + Name: new(instanceName), }) if err != nil { return nil, fmt.Errorf("failed to get database instance: %w", err) } // Ensure Name is set (API response may not include it) - if instance.Name == "" { - instance.Name = instanceName + if utils.Deref(instance.Name) == "" { + instance.Name = new(instanceName) } - cmdio.LogString(ctx, "Instance: "+instance.Name) + cmdio.LogString(ctx, "Instance: "+utils.Deref(instance.Name)) return instance, nil } // selectInstanceID auto-selects if there's only one instance, otherwise prompts user to select. // Returns the instance name. -func selectInstanceID(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { +func selectInstanceID(ctx context.Context, w *sdkclients.Clients) (string, error) { sp := cmdio.NewSpinner(ctx) sp.Update("Loading instances...") - instances, err := w.Database.ListDatabaseInstancesAll(ctx, database.ListDatabaseInstancesRequest{}) + instances, err := listing.Collect(w.Database.ListDatabaseInstancesIter(ctx, database.ListDatabaseInstancesRequest{})) sp.Close() if err != nil { return "", err @@ -103,13 +105,13 @@ func selectInstanceID(ctx context.Context, w *databricks.WorkspaceClient) (strin // Auto-select if there's only one instance if len(instances) == 1 { - return instances[0].Name, nil + return utils.Deref(instances[0].Name), nil } // Multiple instances, prompt user to select var items []cmdio.Tuple for _, inst := range instances { - items = append(items, cmdio.Tuple{Name: inst.Name, Id: inst.Name}) + items = append(items, cmdio.Tuple{Name: utils.Deref(inst.Name), Id: utils.Deref(inst.Name)}) } return cmdio.SelectOrdered(ctx, items, "Select instance") diff --git a/cmd/psql/psql_test.go b/cmd/psql/psql_test.go index c33a8c32a19..953764cc296 100644 --- a/cmd/psql/psql_test.go +++ b/cmd/psql/psql_test.go @@ -1,14 +1,15 @@ package psql import ( - "errors" + "net/http" + "net/http/httptest" "testing" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/database" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/databricks-sdk-go/config" + database "github.com/databricks/sdk-go/database/v1" + postgres "github.com/databricks/sdk-go/postgres/v1" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) @@ -88,15 +89,15 @@ func TestParseResourcePath(t *testing.T) { } func TestListAllDatabases(t *testing.T) { - instErr := errors.New("instances list failed") - projErr := errors.New("projects list failed") - instances := []database.DatabaseInstance{{Name: "my-instance"}} - projects := []postgres.Project{{Name: "projects/my-project"}} + const instancesBody = `{"database_instances":[{"name":"my-instance"}]}` + const projectsBody = `{"projects":[{"name":"projects/my-project"}]}` + instances := []database.DatabaseInstance{{Name: new("my-instance")}} + projects := []postgres.Project{{Name: new("projects/my-project")}} tests := []struct { name string - instErr error - projErr error + instFails bool + projFails bool wantInstances []database.DatabaseInstance wantProjects []postgres.Project wantErr bool @@ -108,47 +109,52 @@ func TestListAllDatabases(t *testing.T) { }, { name: "instances call fails", - instErr: instErr, + instFails: true, wantProjects: projects, }, { name: "projects call fails", - projErr: projErr, + projFails: true, wantInstances: instances, }, { - name: "both calls fail", - instErr: instErr, - projErr: projErr, - wantErr: true, + name: "both calls fail", + instFails: true, + projFails: true, + wantErr: true, }, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - - var instReturn []database.DatabaseInstance - if tc.instErr == nil { - instReturn = instances - } - m.GetMockDatabaseAPI().EXPECT(). - ListDatabaseInstancesAll(mock.Anything, database.ListDatabaseInstancesRequest{}). - Return(instReturn, tc.instErr) - - var projReturn []postgres.Project - if tc.projErr == nil { - projReturn = projects + handler := func(fails bool, body, message string) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + if fails { + w.WriteHeader(http.StatusInternalServerError) + body = `{"error_code":"INTERNAL_ERROR","message":"` + message + `"}` + } + _, _ = w.Write([]byte(body)) + } } - m.GetMockPostgresAPI().EXPECT(). - ListProjectsAll(mock.Anything, postgres.ListProjectsRequest{}). - Return(projReturn, tc.projErr) + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/api/2.0/database/instances": + handler(tc.instFails, instancesBody, "instances list failed")(w, r) + case "/api/2.0/postgres/projects": + handler(tc.projFails, projectsBody, "projects list failed")(w, r) + default: + _, _ = w.Write([]byte(`{}`)) + } + })) + t.Cleanup(srv.Close) + w, err := sdkclients.New(t.Context(), &config.Config{Host: srv.URL, Token: "token"}) + require.NoError(t, err) - gotInstances, gotProjects, err := listAllDatabases(t.Context(), m.WorkspaceClient) + gotInstances, gotProjects, err := listAllDatabases(t.Context(), w) if tc.wantErr { require.Error(t, err) - assert.ErrorIs(t, err, tc.instErr) - assert.ErrorIs(t, err, tc.projErr) + assert.Contains(t, err.Error(), "instances list failed") + assert.Contains(t, err.Error(), "projects list failed") return } require.NoError(t, err) diff --git a/cmd/root/auth.go b/cmd/root/auth.go index 5c03c8cfa8c..02e55fa94b4 100644 --- a/cmd/root/auth.go +++ b/cmd/root/auth.go @@ -14,7 +14,7 @@ import ( envlib "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/liteswap" "github.com/databricks/cli/libs/logdiag" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" "github.com/spf13/cobra" ) @@ -32,6 +32,8 @@ import ( // SDK removed the variable entirely in v0.127.0, so we now own it here. var errNotWorkspaceClient = errors.New("invalid Databricks Workspace configuration - host is not a workspace host") +var errNotAccountClient = errors.New("invalid Databricks Account configuration - host incorrect or account_id missing") + type ErrNoWorkspaceProfiles struct { path string } @@ -123,8 +125,8 @@ func applyProfileAuthPrecedence(ctx context.Context, cfg *config.Config, hasProf } // Helper function to create an account client or prompt once if the given configuration is not valid. -func accountClientOrPrompt(ctx context.Context, cfg *config.Config, allowPrompt bool) (*databricks.AccountClient, error) { - a, err := databricks.NewAccountClient((*databricks.Config)(cfg)) +func accountClientOrPrompt(ctx context.Context, cfg *config.Config, allowPrompt bool) (*sdkclients.Clients, error) { + a, err := sdkclients.New(ctx, cfg) if err == nil { err = a.Config.Authenticate(emptyHttpRequest(ctx)) } @@ -160,7 +162,7 @@ func accountClientOrPrompt(ctx context.Context, cfg *config.Config, allowPrompt if !allowPrompt || !cmdio.IsPromptSupported(ctx) { if err == nil { - err = databricks.ErrNotAccountClient + err = errNotAccountClient } return a, err } @@ -173,7 +175,7 @@ func accountClientOrPrompt(ctx context.Context, cfg *config.Config, allowPrompt // The picked profile resolves into its own config, not the caller's cfg. // Return the client (even on failure) so the caller renders errors against // that config rather than the original, otherwise-empty one. - a, err = databricks.NewAccountClient(&databricks.Config{Profile: profile}) + a, err = sdkclients.New(ctx, &config.Config{Profile: profile}) if err == nil { err = a.Config.Authenticate(emptyHttpRequest(ctx)) } @@ -257,8 +259,8 @@ func MustAccountClient(cmd *cobra.Command, args []string) error { } // Helper function to create a workspace client or prompt once if the given configuration is not valid. -func workspaceClientOrPrompt(ctx context.Context, cfg *config.Config, allowPrompt bool) (*databricks.WorkspaceClient, error) { - w, err := databricks.NewWorkspaceClient((*databricks.Config)(cfg)) +func workspaceClientOrPrompt(ctx context.Context, cfg *config.Config, allowPrompt bool) (*sdkclients.Clients, error) { + w, err := sdkclients.New(ctx, cfg) if err == nil && cfg.Profile != "" && cfg.AccountID != "" && (cfg.WorkspaceID == "" || cfg.WorkspaceID == profile.WorkspaceIDNone) { // Account-only profile (created with --skip-workspace): account_id is @@ -325,7 +327,7 @@ func workspaceClientOrPrompt(ctx context.Context, cfg *config.Config, allowPromp // The picked profile resolves into its own config, not the caller's cfg. // Return the client (even on failure) so the caller renders errors against // that config rather than the original, otherwise-empty one. - w, err = databricks.NewWorkspaceClient(&databricks.Config{Profile: profile}) + w, err = sdkclients.New(ctx, &config.Config{Profile: profile}) if err == nil { err = w.Config.Authenticate(emptyHttpRequest(ctx)) } diff --git a/cmd/root/auth_test.go b/cmd/root/auth_test.go index b455dd0e382..f241a94207e 100644 --- a/cmd/root/auth_test.go +++ b/cmd/root/auth_test.go @@ -14,7 +14,6 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/databrickscfg/profile" - "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -645,7 +644,7 @@ func TestAccountClientOrPromptReturnsErrorForWrongHostType(t *testing.T) { a, err := accountClientOrPrompt(t.Context(), cfg, false) assert.NotNil(t, a) - assert.ErrorIs(t, err, databricks.ErrNotAccountClient) + assert.ErrorIs(t, err, errNotAccountClient) } func TestIsPATOnSPOGWithoutWorkspaceID(t *testing.T) { @@ -920,7 +919,7 @@ func TestAccountClientOrPromptReturnsErrorForMissingAccountID(t *testing.T) { a, err := accountClientOrPrompt(t.Context(), cfg, false) assert.NotNil(t, a) - assert.ErrorIs(t, err, databricks.ErrNotAccountClient) + assert.ErrorIs(t, err, errNotAccountClient) } func TestMustWorkspaceClientWithoutConfiguredDefaultFallsBackToDefaultSection(t *testing.T) { diff --git a/cmd/root/root.go b/cmd/root/root.go index 81b341e9c5c..928b3cbdaef 100644 --- a/cmd/root/root.go +++ b/cmd/root/root.go @@ -14,6 +14,7 @@ import ( "github.com/databricks/cli/internal/build" "github.com/databricks/cli/libs/aitools/agents" "github.com/databricks/cli/libs/aitools/installer" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" @@ -165,7 +166,7 @@ Stack Trace: if cmdctx.HasWorkspaceClient(cmd.Context()) { err = auth.AppendAccountHostHint(cmdctx.WorkspaceClient(cmd.Context()).Config, err) } - fmt.Fprintf(cmd.ErrOrStderr(), "Error: %s\n", err.Error()) + fmt.Fprintf(cmd.ErrOrStderr(), "Error: %s\n", apierrs.ErrorString(err)) } // Log exit status and error diff --git a/cmd/root/root_test.go b/cmd/root/root_test.go index ce1584eacd4..d706b5698b2 100644 --- a/cmd/root/root_test.go +++ b/cmd/root/root_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/databricks/cli/libs/cmdctx" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/sdk-go/core/apierr" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -24,11 +24,7 @@ func TestExecuteEnrichesAuthErrors(t *testing.T) { SilenceUsage: true, SilenceErrors: true, RunE: func(cmd *cobra.Command, args []string) error { - return &apierr.APIError{ - StatusCode: 403, - ErrorCode: "PERMISSION_DENIED", - Message: "no access", - } + return apierr.FromHTTPError(403, nil, []byte(`{"error_code":"PERMISSION_DENIED","message":"no access"}`)) }, } cmd.SetErr(stderr) @@ -62,11 +58,7 @@ func TestExecuteNoEnrichmentWithoutConfigUsed(t *testing.T) { SilenceUsage: true, SilenceErrors: true, RunE: func(cmd *cobra.Command, args []string) error { - return &apierr.APIError{ - StatusCode: 403, - ErrorCode: "PERMISSION_DENIED", - Message: "no access", - } + return apierr.FromHTTPError(403, nil, []byte(`{"error_code":"PERMISSION_DENIED","message":"no access"}`)) }, } cmd.SetErr(stderr) @@ -91,7 +83,7 @@ func TestExecuteAppendsAccountHostHint(t *testing.T) { setup: func(ctx context.Context) context.Context { cfg := &config.Config{Host: "https://accounts.test", Profile: "acc"} ctx = cmdctx.SetConfigUsed(ctx, cfg) - return cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{Config: cfg}) + return cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{Config: cfg}) }, wantHint: true, }, @@ -100,7 +92,7 @@ func TestExecuteAppendsAccountHostHint(t *testing.T) { setup: func(ctx context.Context) context.Context { cfg := &config.Config{Host: "https://adb-123.test", Profile: "ws"} ctx = cmdctx.SetConfigUsed(ctx, cfg) - return cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{Config: cfg}) + return cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{Config: cfg}) }, wantHint: false, }, @@ -111,7 +103,7 @@ func TestExecuteAppendsAccountHostHint(t *testing.T) { setup: func(ctx context.Context) context.Context { cfg := &config.Config{Host: "https://accounts.test", Profile: "acc"} ctx = cmdctx.SetConfigUsed(ctx, cfg) - return cmdctx.SetAccountClient(ctx, &databricks.AccountClient{Config: cfg}) + return cmdctx.SetAccountClient(ctx, &sdkclients.Clients{Config: cfg}) }, wantHint: false, }, diff --git a/cmd/sandbox/api.go b/cmd/sandbox/api.go index 61fe94d9de5..59e2d92c4f5 100644 --- a/cmd/sandbox/api.go +++ b/cmd/sandbox/api.go @@ -9,12 +9,10 @@ import ( "strings" "time" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/databrickscfg/profile" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/httpclient" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/sdk-go/core/apierr" ) // sandboxPath returns the URL path for a single sandbox resource. The ID is @@ -41,28 +39,9 @@ const ( ) // max503Attempts caps attempts when the server keeps answering 503; the -// SDK's default budget would otherwise retry for up to 5 minutes. +// default budget would otherwise retry for up to 5 minutes. const max503Attempts = 3 -type attempt503CounterKey struct{} - -// arm503Budget attaches the request's 503 attempt counter; retries of one -// request run sequentially, so a plain *int suffices. -func arm503Budget(ctx context.Context) context.Context { - return context.WithValue(ctx, attempt503CounterKey{}, new(int)) -} - -// allow503Retry consumes one unit of the request's 503 budget. Unarmed -// contexts get no retries. -func allow503Retry(ctx context.Context) bool { - n, ok := ctx.Value(attempt503CounterKey{}).(*int) - if !ok { - return false - } - *n++ - return *n < max503Attempts -} - // sandboxDocsURL points users at the Sandbox documentation, including its // region availability. The cloud-neutral path redirects to the reader's // cloud-specific docs page. @@ -71,7 +50,7 @@ const sandboxDocsURL = "https://docs.databricks.com/compute/serverless/sandbox" // translateError replaces a 503 with a user-facing message; the gateway // body adds nothing, so it is dropped rather than wrapped. func translateError(err error) error { - if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.StatusCode == http.StatusServiceUnavailable { + if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.HTTPStatusCode() == http.StatusServiceUnavailable { return fmt.Errorf("the Databricks Sandbox feature is not available in your region. See %s", sandboxDocsURL) } return err @@ -97,7 +76,7 @@ func validateName(name string) error { // sandboxAPI wraps the SDK ApiClient with workspace-id-aware request headers. type sandboxAPI struct { - c *client.DatabricksClient + c *apiclient.Client } // sandboxCreateBody is the inner `Sandbox` message in the create payload. @@ -216,19 +195,8 @@ type registerKeyRequest struct { } // newSandboxAPI returns a sandboxAPI bound to the workspace client's config. -func newSandboxAPI(w *databricks.WorkspaceClient) (*sandboxAPI, error) { - clientCfg, err := config.HTTPClientConfigFromConfig(w.Config) - if err != nil { - return nil, fmt.Errorf("failed to create sandbox API client: %w", err) - } - defaultRetriable := clientCfg.ErrorRetriable - clientCfg.ErrorRetriable = func(ctx context.Context, err error) bool { - if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.StatusCode == http.StatusServiceUnavailable { - return allow503Retry(ctx) - } - return defaultRetriable(ctx, err) - } - c, err := client.NewWithClient(w.Config, httpclient.NewApiClient(clientCfg)) +func newSandboxAPI(w *sdkclients.Clients) (*sandboxAPI, error) { + c, err := apiclient.New(w.Config) if err != nil { return nil, fmt.Errorf("failed to create sandbox API client: %w", err) } @@ -250,7 +218,7 @@ func (a *sandboxAPI) headers() map[string]string { // do issues one sandbox API request: arms the 503 retry budget, attaches // the workspace routing headers, and translates terminal errors. func (a *sandboxAPI) do(ctx context.Context, method, path string, request, response any) error { - return translateError(a.c.Do(arm503Budget(ctx), method, path, a.headers(), nil, request, response)) + return translateError(a.c.Do(apiclient.WithMaxAttempts(ctx, max503Attempts), method, path, a.headers(), nil, request, response)) } // create calls POST /api/2.0/lakebox/sandboxes. An empty `name` is omitted diff --git a/cmd/sandbox/api_test.go b/cmd/sandbox/api_test.go index 3b6f0df0117..72f39ec75d3 100644 --- a/cmd/sandbox/api_test.go +++ b/cmd/sandbox/api_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/sdk-go/core/apierr" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -24,29 +24,16 @@ func TestValidateNameRejectsOversize(t *testing.T) { } func TestTranslateErrorRewrites503(t *testing.T) { - orig := &apierr.APIError{StatusCode: http.StatusServiceUnavailable, Message: "Service Unavailable"} + orig := apierr.FromHTTPError(http.StatusServiceUnavailable, nil, []byte(`{"message":"Service Unavailable"}`)) err := translateError(orig) require.Error(t, err) assert.Equal(t, "the Databricks Sandbox feature is not available in your region. See "+sandboxDocsURL, err.Error()) } -func TestAllow503RetryConsumesBudget(t *testing.T) { - ctx := arm503Budget(t.Context()) - // max503Attempts-1 retries are allowed, then the budget is exhausted. - for range max503Attempts - 1 { - assert.True(t, allow503Retry(ctx)) - } - assert.False(t, allow503Retry(ctx)) -} - -func TestAllow503RetryUnarmedContext(t *testing.T) { - assert.False(t, allow503Retry(t.Context())) -} - func TestTranslateErrorPassesThroughOthers(t *testing.T) { require.NoError(t, translateError(nil)) - notFound := &apierr.APIError{StatusCode: http.StatusNotFound, Message: "Sandbox not found"} + notFound := apierr.FromHTTPError(http.StatusNotFound, nil, []byte(`{"message":"Sandbox not found"}`)) assert.Equal(t, error(notFound), translateError(notFound)) } diff --git a/cmd/sandbox/create.go b/cmd/sandbox/create.go index 2d9beb19763..0c19f05a991 100644 --- a/cmd/sandbox/create.go +++ b/cmd/sandbox/create.go @@ -2,13 +2,12 @@ package sandbox import ( "encoding/json" - "errors" "fmt" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/apierr" "github.com/spf13/cobra" ) @@ -76,7 +75,7 @@ Examples: currentDefault := getDefault(ctx, profile) shouldSetDefault := currentDefault == "" if !shouldSetDefault { - if _, err := api.get(ctx, currentDefault); errors.Is(err, apierr.ErrNotFound) { + if _, err := api.get(ctx, currentDefault); apierrs.Is(err, apierrs.ErrNotFound) { shouldSetDefault = true } } diff --git a/cmd/sandbox/default.go b/cmd/sandbox/default.go index 8e59a1d5348..3ef97d323a3 100644 --- a/cmd/sandbox/default.go +++ b/cmd/sandbox/default.go @@ -1,12 +1,11 @@ package sandbox import ( - "errors" "fmt" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdctx" - "github.com/databricks/databricks-sdk-go/apierr" "github.com/spf13/cobra" ) @@ -45,7 +44,7 @@ Example: } entry, err := api.get(ctx, sandboxID) if err != nil { - if errors.Is(err, apierr.ErrNotFound) { + if apierrs.Is(err, apierrs.ErrNotFound) { return fmt.Errorf("no sandbox named %q — `databricks sandbox list` shows available IDs", sandboxID) } return fmt.Errorf("failed to validate sandbox %s: %w", sandboxID, err) diff --git a/cmd/sandbox/delete.go b/cmd/sandbox/delete.go index 589a77dfeac..0d0487bcd9f 100644 --- a/cmd/sandbox/delete.go +++ b/cmd/sandbox/delete.go @@ -5,9 +5,9 @@ import ( "fmt" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/apierr" "github.com/spf13/cobra" ) @@ -51,7 +51,7 @@ Examples: // surface typos clearly. entry, err := api.get(ctx, sandboxID) if err != nil { - if errors.Is(err, apierr.ErrNotFound) { + if apierrs.Is(err, apierrs.ErrNotFound) { return fmt.Errorf("no sandbox named %q — `databricks sandbox list` shows available IDs", sandboxID) } return fmt.Errorf("failed to look up sandbox %s: %w", sandboxID, err) diff --git a/cmd/sandbox/ssh.go b/cmd/sandbox/ssh.go index 7fbe7df1c20..3b7d6c1224c 100644 --- a/cmd/sandbox/ssh.go +++ b/cmd/sandbox/ssh.go @@ -9,11 +9,11 @@ import ( "strings" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/execv" "github.com/databricks/cli/libs/shellquote" - "github.com/databricks/databricks-sdk-go/apierr" "github.com/spf13/cobra" ) @@ -113,7 +113,7 @@ Examples: sandboxID = def sandboxGatewayHost = sb.GatewayHost sandboxStatus = sb.Status - case errors.Is(err, apierr.ErrNotFound): + case apierrs.Is(err, apierrs.ErrNotFound): _ = clearDefault(ctx, profile) return fmt.Errorf("saved default %q no longer exists (cleared) — run `databricks sandbox create` to provision a new one, or `databricks sandbox default ` to point at an existing sandbox", def) default: @@ -133,7 +133,7 @@ Examples: case err == nil: sandboxGatewayHost = sb.GatewayHost sandboxStatus = sb.Status - case errors.Is(err, apierr.ErrNotFound): + case apierrs.Is(err, apierrs.ErrNotFound): return fmt.Errorf("no sandbox named %q — `databricks sandbox list` shows available IDs", sandboxID) default: warn(ctx, fmt.Sprintf("Could not validate sandbox %s: %v", sandboxID, err)) diff --git a/cmd/sandbox/ssh_test.go b/cmd/sandbox/ssh_test.go index 31f53eee6b4..511284df52a 100644 --- a/cmd/sandbox/ssh_test.go +++ b/cmd/sandbox/ssh_test.go @@ -8,7 +8,8 @@ import ( "testing" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -96,7 +97,7 @@ func TestEnsureRunningLifecycle(t *testing.T) { })) t.Cleanup(server.Close) - workspaceClient, err := databricks.NewWorkspaceClient(&databricks.Config{ + workspaceClient, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "test-token", }) diff --git a/cmd/sandbox/status.go b/cmd/sandbox/status.go index 3062686ed13..27e24bb04fb 100644 --- a/cmd/sandbox/status.go +++ b/cmd/sandbox/status.go @@ -2,13 +2,12 @@ package sandbox import ( "encoding/json" - "errors" "fmt" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/apierr" "github.com/spf13/cobra" ) @@ -46,7 +45,7 @@ Example: entry, err := api.get(ctx, sandboxID) if err != nil { - if errors.Is(err, apierr.ErrNotFound) { + if apierrs.Is(err, apierrs.ErrNotFound) { return fmt.Errorf("no sandbox named %q — `databricks sandbox list` shows available IDs", sandboxID) } return fmt.Errorf("failed to get sandbox %s: %w", sandboxID, err) diff --git a/cmd/sync/completion.go b/cmd/sync/completion.go index c82d85a1c38..b15de384a22 100644 --- a/cmd/sync/completion.go +++ b/cmd/sync/completion.go @@ -5,20 +5,21 @@ import ( "path" "strings" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/iamutil" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/workspaceapi" "github.com/spf13/cobra" ) // List directories or repos under the specified path. // Returns a channel such that we can list multiple paths in parallel. -func fetchDirs(ctx context.Context, wsc *databricks.WorkspaceClient, path string) <-chan []string { +func fetchDirs(ctx context.Context, wsc *sdkclients.Clients, path string) <-chan []string { ch := make(chan []string, 1) go func() { defer close(ch) - files, err := wsc.Workspace.ListAll(ctx, workspace.ListWorkspaceRequest{ + files, err := wsc.Workspace.ListAll(ctx, workspaceapi.ListWorkspaceRequest{ Path: path, }) if err != nil { @@ -29,7 +30,7 @@ func fetchDirs(ctx context.Context, wsc *databricks.WorkspaceClient, path string // We're interested only in paths we can sync to. var dirs []string for _, file := range files { - if file.ObjectType == workspace.ObjectTypeDirectory || file.ObjectType == workspace.ObjectTypeRepo { + if file.ObjectType == workspaceapi.ObjectTypeDirectory || file.ObjectType == workspaceapi.ObjectTypeRepo { dirs = append(dirs, file.Path) } } @@ -42,17 +43,17 @@ func fetchDirs(ctx context.Context, wsc *databricks.WorkspaceClient, path string func completeRemotePath( ctx context.Context, - wsc *databricks.WorkspaceClient, + wsc *sdkclients.Clients, toComplete string, ) ([]string, cobra.ShellCompDirective) { - me, err := wsc.CurrentUser.Me(ctx, iam.MeRequest{}) + me, err := iamutil.GetCurrentUser(ctx, wsc) if err != nil { return nil, cobra.ShellCompDirectiveError } prefixes := []string{ - path.Clean("/Users/"+me.UserName) + "/", - path.Clean("/Repos/"+me.UserName) + "/", + path.Clean("/Users/"+utils.Deref(me.UserName)) + "/", + path.Clean("/Repos/"+utils.Deref(me.UserName)) + "/", } validPrefix := false diff --git a/cmd/workspace/access-control/access-control.go b/cmd/workspace/access-control/access-control.go index f3571d21c3f..6982b6f0fdb 100644 --- a/cmd/workspace/access-control/access-control.go +++ b/cmd/workspace/access-control/access-control.go @@ -9,8 +9,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" ) // Slice with functions to override default command behavior. @@ -50,13 +51,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var checkPolicyOverrides []func( *cobra.Command, - *iam.CheckPolicyRequest, + *accessmanagement.CheckPolicyRequest, ) func newCheckPolicy() *cobra.Command { cmd := &cobra.Command{} + var checkPolicyReq accessmanagement.CheckPolicyRequest - var checkPolicyReq iam.CheckPolicyRequest var checkPolicyJson flags.JsonFlag cmd.Flags().Var(&checkPolicyJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -75,6 +76,7 @@ func newCheckPolicy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := checkPolicyJson.Unmarshal(&checkPolicyReq) @@ -91,12 +93,20 @@ func newCheckPolicy() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.AccessControl.CheckPolicy(ctx, checkPolicyReq) + sdkReq, err := accessmanagement.CheckPolicyRequestToSDK(&checkPolicyReq) + if err != nil { + return err + } + response, err := w.AccessManagement.CheckPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.CheckPolicyResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/agent-bricks/agent-bricks.go b/cmd/workspace/agent-bricks/agent-bricks.go index 145b4198dee..5973c0b6992 100644 --- a/cmd/workspace/agent-bricks/agent-bricks.go +++ b/cmd/workspace/agent-bricks/agent-bricks.go @@ -9,8 +9,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/agentbricks" "github.com/spf13/cobra" + + customllms "github.com/databricks/cli/libs/sdktypes/customllms/v1" + sdkcustomllms "github.com/databricks/sdk-go/customllms/v1" ) // Slice with functions to override default command behavior. @@ -56,13 +58,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var cancelOptimizeOverrides []func( *cobra.Command, - *agentbricks.CancelCustomLlmOptimizationRunRequest, + *customllms.CancelCustomLlmOptimizationRunRequest, ) func newCancelOptimize() *cobra.Command { cmd := &cobra.Command{} - - var cancelOptimizeReq agentbricks.CancelCustomLlmOptimizationRunRequest + var cancelOptimizeReq customllms.CancelCustomLlmOptimizationRunRequest cmd.Use = "cancel-optimize ID" cmd.Short = `Cancel a Custom LLM Optimization Run.` @@ -81,10 +82,15 @@ func newCancelOptimize() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - cancelOptimizeReq.Id = args[0] + cancelOptimizeReq.Id = new(args[0]) - err = w.AgentBricks.CancelOptimize(ctx, cancelOptimizeReq) + sdkReq, err := customllms.CancelCustomLlmOptimizationRunRequestToSDK(&cancelOptimizeReq) + if err != nil { + return err + } + err = w.CustomLlms.CancelCustomLlmOptimizationRun(ctx, *sdkReq) if err != nil { return err } @@ -109,18 +115,18 @@ func newCancelOptimize() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createCustomLlmOverrides []func( *cobra.Command, - *agentbricks.CreateCustomLlmRequest, + *customllms.CreateCustomLlmRequest, ) func newCreateCustomLlm() *cobra.Command { cmd := &cobra.Command{} + var createCustomLlmReq customllms.CreateCustomLlmRequest - var createCustomLlmReq agentbricks.CreateCustomLlmRequest var createCustomLlmJson flags.JsonFlag 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, `This will soon be deprecated!! Optional: UC path for agent artifacts.`) + flags.StringPtrVar(cmd.Flags(), &createCustomLlmReq.AgentArtifactPath, "agent-artifact-path", `This will soon be deprecated!! Optional: UC path for agent artifacts.`) // TODO: array: datasets // TODO: array: guidelines @@ -152,6 +158,7 @@ func newCreateCustomLlm() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createCustomLlmJson.Unmarshal(&createCustomLlmReq) @@ -166,18 +173,26 @@ func newCreateCustomLlm() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createCustomLlmReq.Name = args[0] + createCustomLlmReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createCustomLlmReq.Instructions = args[1] + createCustomLlmReq.Instructions = new(args[1]) } - response, err := w.AgentBricks.CreateCustomLlm(ctx, createCustomLlmReq) + sdkReq, err := customllms.CreateCustomLlmRequestToSDK(&createCustomLlmReq) + if err != nil { + return err + } + response, err := w.CustomLlms.CreateCustomLlm(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := customllms.CustomLlmFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -198,13 +213,12 @@ func newCreateCustomLlm() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteCustomLlmOverrides []func( *cobra.Command, - *agentbricks.DeleteCustomLlmRequest, + *sdkcustomllms.DeleteCustomLlmRequest, ) func newDeleteCustomLlm() *cobra.Command { cmd := &cobra.Command{} - - var deleteCustomLlmReq agentbricks.DeleteCustomLlmRequest + var deleteCustomLlmReq sdkcustomllms.DeleteCustomLlmRequest cmd.Use = "delete-custom-llm ID" cmd.Short = `Delete a Custom LLM.` @@ -226,10 +240,12 @@ func newDeleteCustomLlm() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteCustomLlmReq.Id = args[0] + deleteCustomLlmReq.Id = new(args[0]) - err = w.AgentBricks.DeleteCustomLlm(ctx, deleteCustomLlmReq) + sdkReq := &deleteCustomLlmReq + err = w.CustomLlms.DeleteCustomLlm(ctx, *sdkReq) if err != nil { return err } @@ -254,13 +270,12 @@ func newDeleteCustomLlm() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getCustomLlmOverrides []func( *cobra.Command, - *agentbricks.GetCustomLlmRequest, + *sdkcustomllms.GetCustomLlmRequest, ) func newGetCustomLlm() *cobra.Command { cmd := &cobra.Command{} - - var getCustomLlmReq agentbricks.GetCustomLlmRequest + var getCustomLlmReq sdkcustomllms.GetCustomLlmRequest cmd.Use = "get-custom-llm ID" cmd.Short = `Get a Custom LLM.` @@ -282,15 +297,21 @@ func newGetCustomLlm() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getCustomLlmReq.Id = args[0] + getCustomLlmReq.Id = new(args[0]) - response, err := w.AgentBricks.GetCustomLlm(ctx, getCustomLlmReq) + sdkReq := &getCustomLlmReq + response, err := w.CustomLlms.GetCustomLlm(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := customllms.CustomLlmFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -311,13 +332,12 @@ func newGetCustomLlm() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var startOptimizeOverrides []func( *cobra.Command, - *agentbricks.StartCustomLlmOptimizationRunRequest, + *customllms.StartCustomLlmOptimizationRunRequest, ) func newStartOptimize() *cobra.Command { cmd := &cobra.Command{} - - var startOptimizeReq agentbricks.StartCustomLlmOptimizationRunRequest + var startOptimizeReq customllms.StartCustomLlmOptimizationRunRequest cmd.Use = "start-optimize ID" cmd.Short = `Start a Custom LLM Optimization Run.` @@ -339,15 +359,24 @@ func newStartOptimize() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - startOptimizeReq.Id = args[0] + startOptimizeReq.Id = new(args[0]) - response, err := w.AgentBricks.StartOptimize(ctx, startOptimizeReq) + sdkReq, err := customllms.StartCustomLlmOptimizationRunRequestToSDK(&startOptimizeReq) + if err != nil { + return err + } + response, err := w.CustomLlms.StartCustomLlmOptimizationRun(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := customllms.CustomLlmFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -368,13 +397,13 @@ func newStartOptimize() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateCustomLlmOverrides []func( *cobra.Command, - *agentbricks.UpdateCustomLlmRequest, + *customllms.UpdateCustomLlmRequest, ) func newUpdateCustomLlm() *cobra.Command { cmd := &cobra.Command{} + var updateCustomLlmReq customllms.UpdateCustomLlmRequest - var updateCustomLlmReq agentbricks.UpdateCustomLlmRequest var updateCustomLlmJson flags.JsonFlag cmd.Flags().Var(&updateCustomLlmJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -399,6 +428,7 @@ func newUpdateCustomLlm() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateCustomLlmJson.Unmarshal(&updateCustomLlmReq) @@ -414,14 +444,22 @@ func newUpdateCustomLlm() *cobra.Command { } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateCustomLlmReq.Id = args[0] + updateCustomLlmReq.Id = new(args[0]) - response, err := w.AgentBricks.UpdateCustomLlm(ctx, updateCustomLlmReq) + sdkReq, err := customllms.UpdateCustomLlmRequestToSDK(&updateCustomLlmReq) + if err != nil { + return err + } + response, err := w.CustomLlms.UpdateCustomLlm(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := customllms.CustomLlmFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/agent-kit/agent-kit.go b/cmd/workspace/agent-kit/agent-kit.go index 96eecabe31f..92f49ee7192 100644 --- a/cmd/workspace/agent-kit/agent-kit.go +++ b/cmd/workspace/agent-kit/agent-kit.go @@ -5,15 +5,16 @@ package agent_kit import ( "errors" "fmt" - "strings" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "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/agentkit" "github.com/spf13/cobra" + + agentkit "github.com/databricks/cli/libs/sdktypes/agentkit/v1" + sdkagentkit "github.com/databricks/sdk-go/agentkit/v1" ) // Slice with functions to override default command behavior. @@ -85,8 +86,8 @@ var appendSessionItemsOverrides []func( func newAppendSessionItems() *cobra.Command { cmd := &cobra.Command{} - var appendSessionItemsReq agentkit.AppendSessionItemsRequest + var appendSessionItemsJson flags.JsonFlag cmd.Flags().Var(&appendSessionItemsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -114,6 +115,7 @@ func newAppendSessionItems() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := appendSessionItemsJson.Unmarshal(&appendSessionItemsReq) @@ -129,14 +131,22 @@ func newAppendSessionItems() *cobra.Command { } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - appendSessionItemsReq.Parent = args[0] + appendSessionItemsReq.Parent = new(args[0]) - response, err := w.AgentKit.AppendSessionItems(ctx, appendSessionItemsReq) + sdkReq, err := agentkit.AppendSessionItemsRequestToSDK(&appendSessionItemsReq) + if err != nil { + return err + } + response, err := w.AgentKit.AppendSessionItems(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.AppendSessionItemsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -162,7 +172,6 @@ var clearSessionItemsOverrides []func( func newClearSessionItems() *cobra.Command { cmd := &cobra.Command{} - var clearSessionItemsReq agentkit.ClearSessionItemsRequest cmd.Use = "clear-session-items PARENT" @@ -188,15 +197,21 @@ func newClearSessionItems() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - clearSessionItemsReq.Parent = args[0] + clearSessionItemsReq.Parent = new(args[0]) - response, err := w.AgentKit.ClearSessionItems(ctx, clearSessionItemsReq) + sdkReq, err := agentkit.ClearSessionItemsRequestToSDK(&clearSessionItemsReq) + if err != nil { + return err + } + response, err := w.AgentKit.ClearSessionItems(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. @@ -222,18 +237,18 @@ var createMemoryOverrides []func( func newCreateMemory() *cobra.Command { cmd := &cobra.Command{} - var createMemoryReq agentkit.CreateManagedMemoryEntryRequest - createMemoryReq.ManagedMemoryEntry = agentkit.ManagedMemoryEntry{} + createMemoryReq.ManagedMemoryEntry = &agentkit.ManagedMemoryEntry{} + var createMemoryJson flags.JsonFlag cmd.Flags().Var(&createMemoryJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createMemoryReq.ManagedMemoryEntryId, "managed-memory-entry-id", createMemoryReq.ManagedMemoryEntryId, `Optional caller-selected managed memory entry ID.`) - cmd.Flags().StringVar(&createMemoryReq.ManagedMemoryEntry.Content, "content", createMemoryReq.ManagedMemoryEntry.Content, `Optional free-form memory content.`) - cmd.Flags().StringVar(&createMemoryReq.ManagedMemoryEntry.Description, "description", createMemoryReq.ManagedMemoryEntry.Description, `Human-readable description of the memory entry.`) - cmd.Flags().StringVar(&createMemoryReq.ManagedMemoryEntry.SessionId, "session-id", createMemoryReq.ManagedMemoryEntry.SessionId, `Optional identifier for the session associated with this memory entry.`) - cmd.Flags().Var(&createMemoryReq.ManagedMemoryEntry.SourceType, "source-type", `Which writer created this entry. Supported values: [MANAGED_MEMORY_ENTRY_SOURCE_TYPE_AGENT, MANAGED_MEMORY_ENTRY_SOURCE_TYPE_DREAMER]`) + flags.StringPtrVar(cmd.Flags(), &createMemoryReq.ManagedMemoryEntryId, "managed-memory-entry-id", `Optional caller-selected managed memory entry ID.`) + flags.StringPtrVar(cmd.Flags(), &createMemoryReq.ManagedMemoryEntry.Content, "content", `Optional free-form memory content.`) + flags.StringPtrVar(cmd.Flags(), &createMemoryReq.ManagedMemoryEntry.Description, "description", `Human-readable description of the memory entry.`) + flags.StringPtrVar(cmd.Flags(), &createMemoryReq.ManagedMemoryEntry.SessionId, "session-id", `Optional identifier for the session associated with this memory entry.`) + flags.EnumVar(cmd.Flags(), &createMemoryReq.ManagedMemoryEntry.SourceType, "source-type", `Which writer created this entry. Supported values: [MANAGED_MEMORY_ENTRY_SOURCE_TYPE_AGENT, MANAGED_MEMORY_ENTRY_SOURCE_TYPE_DREAMER]`, "ManagedMemoryEntrySourceType", "MANAGED_MEMORY_ENTRY_SOURCE_TYPE_AGENT", "MANAGED_MEMORY_ENTRY_SOURCE_TYPE_DREAMER") cmd.Use = "create-memory PARENT ACTOR_ID PATH" cmd.Short = `Create a managed memory entry.` @@ -275,6 +290,7 @@ func newCreateMemory() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createMemoryJson.Unmarshal(&createMemoryReq.ManagedMemoryEntry) @@ -288,20 +304,28 @@ func newCreateMemory() *cobra.Command { } } } - createMemoryReq.Parent = args[0] + createMemoryReq.Parent = new(args[0]) if !cmd.Flags().Changed("json") { - createMemoryReq.ManagedMemoryEntry.ActorId = args[1] + createMemoryReq.ManagedMemoryEntry.ActorId = new(args[1]) } if !cmd.Flags().Changed("json") { - createMemoryReq.ManagedMemoryEntry.Path = args[2] + createMemoryReq.ManagedMemoryEntry.Path = new(args[2]) } - response, err := w.AgentKit.CreateMemory(ctx, createMemoryReq) + sdkReq, err := agentkit.CreateManagedMemoryEntryRequestToSDK(&createMemoryReq) + if err != nil { + return err + } + response, err := w.AgentKit.CreateMemory(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.ManagedMemoryEntryFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -327,15 +351,15 @@ var createMemoryStoreOverrides []func( func newCreateMemoryStore() *cobra.Command { cmd := &cobra.Command{} - var createMemoryStoreReq agentkit.CreateManagedMemoryStoreRequest - createMemoryStoreReq.ManagedMemoryStore = agentkit.ManagedMemoryStore{} + createMemoryStoreReq.ManagedMemoryStore = &agentkit.ManagedMemoryStore{} + var createMemoryStoreJson flags.JsonFlag cmd.Flags().Var(&createMemoryStoreJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createMemoryStoreReq.ManagedMemoryStore.Description, "description", createMemoryStoreReq.ManagedMemoryStore.Description, `Human-readable description of the memory store.`) - cmd.Flags().StringVar(&createMemoryStoreReq.ManagedMemoryStore.DisplayName, "display-name", createMemoryStoreReq.ManagedMemoryStore.DisplayName, `Deprecated compatibility alias for the caller-provided managed memory store ID.`) + flags.StringPtrVar(cmd.Flags(), &createMemoryStoreReq.ManagedMemoryStore.Description, "description", `Human-readable description of the memory store.`) + flags.StringPtrVar(cmd.Flags(), &createMemoryStoreReq.ManagedMemoryStore.DisplayName, "display-name", `Deprecated compatibility alias for the caller-provided managed memory store ID.`) // TODO: complex arg: storage_backend cmd.Use = "create-memory-store MANAGED_MEMORY_STORE_ID" @@ -362,6 +386,7 @@ func newCreateMemoryStore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createMemoryStoreJson.Unmarshal(&createMemoryStoreReq.ManagedMemoryStore) @@ -375,14 +400,22 @@ func newCreateMemoryStore() *cobra.Command { } } } - createMemoryStoreReq.ManagedMemoryStoreId = args[0] + createMemoryStoreReq.ManagedMemoryStoreId = new(args[0]) - response, err := w.AgentKit.CreateMemoryStore(ctx, createMemoryStoreReq) + sdkReq, err := agentkit.CreateManagedMemoryStoreRequestToSDK(&createMemoryStoreReq) + if err != nil { + return err + } + response, err := w.AgentKit.CreateMemoryStore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.ManagedMemoryStoreFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -408,16 +441,16 @@ var createSessionOverrides []func( func newCreateSession() *cobra.Command { cmd := &cobra.Command{} - var createSessionReq agentkit.CreateSessionRequest - createSessionReq.Session = agentkit.Session{} + createSessionReq.Session = &agentkit.Session{} + var createSessionJson flags.JsonFlag cmd.Flags().Var(&createSessionJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createSessionReq.SessionId, "session-id", createSessionReq.SessionId, `Optional caller-selected session ID.`) + flags.StringPtrVar(cmd.Flags(), &createSessionReq.SessionId, "session-id", `Optional caller-selected session ID.`) // TODO: map via StringToStringVar: metadata - cmd.Flags().StringVar(&createSessionReq.Session.ParentSessionId, "parent-session-id", createSessionReq.Session.ParentSessionId, `Immediate parent session ID.`) + flags.StringPtrVar(cmd.Flags(), &createSessionReq.Session.ParentSessionId, "parent-session-id", `Immediate parent session ID.`) cmd.Use = "create-session PARENT ACTOR_ID" cmd.Short = `Create a session.` @@ -456,6 +489,7 @@ func newCreateSession() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createSessionJson.Unmarshal(&createSessionReq.Session) @@ -469,17 +503,25 @@ func newCreateSession() *cobra.Command { } } } - createSessionReq.Parent = args[0] + createSessionReq.Parent = new(args[0]) if !cmd.Flags().Changed("json") { - createSessionReq.Session.ActorId = args[1] + createSessionReq.Session.ActorId = new(args[1]) } - response, err := w.AgentKit.CreateSession(ctx, createSessionReq) + sdkReq, err := agentkit.CreateSessionRequestToSDK(&createSessionReq) + if err != nil { + return err + } + response, err := w.AgentKit.CreateSession(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.SessionFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -505,14 +547,14 @@ var createSessionStoreOverrides []func( func newCreateSessionStore() *cobra.Command { cmd := &cobra.Command{} - var createSessionStoreReq agentkit.CreateSessionStoreRequest - createSessionStoreReq.SessionStore = agentkit.SessionStore{} + createSessionStoreReq.SessionStore = &agentkit.SessionStore{} + var createSessionStoreJson flags.JsonFlag cmd.Flags().Var(&createSessionStoreJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createSessionStoreReq.SessionStore.Description, "description", createSessionStoreReq.SessionStore.Description, `Human-readable description of the session store.`) + flags.StringPtrVar(cmd.Flags(), &createSessionStoreReq.SessionStore.Description, "description", `Human-readable description of the session store.`) // TODO: map via StringToStringVar: metadata cmd.Use = "create-session-store SESSION_STORE_ID" @@ -539,6 +581,7 @@ func newCreateSessionStore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createSessionStoreJson.Unmarshal(&createSessionStoreReq.SessionStore) @@ -552,14 +595,22 @@ func newCreateSessionStore() *cobra.Command { } } } - createSessionStoreReq.SessionStoreId = args[0] + createSessionStoreReq.SessionStoreId = new(args[0]) - response, err := w.AgentKit.CreateSessionStore(ctx, createSessionStoreReq) + sdkReq, err := agentkit.CreateSessionStoreRequestToSDK(&createSessionStoreReq) + if err != nil { + return err + } + response, err := w.AgentKit.CreateSessionStore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.SessionStoreFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -580,13 +631,12 @@ func newCreateSessionStore() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteMemoryOverrides []func( *cobra.Command, - *agentkit.DeleteManagedMemoryEntryRequest, + *sdkagentkit.DeleteManagedMemoryEntryRequest, ) func newDeleteMemory() *cobra.Command { cmd := &cobra.Command{} - - var deleteMemoryReq agentkit.DeleteManagedMemoryEntryRequest + var deleteMemoryReq sdkagentkit.DeleteManagedMemoryEntryRequest cmd.Use = "delete-memory NAME" cmd.Short = `Delete a managed memory entry by resource name.` @@ -612,10 +662,12 @@ func newDeleteMemory() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteMemoryReq.Name = args[0] + deleteMemoryReq.Name = new(args[0]) - err = w.AgentKit.DeleteMemory(ctx, deleteMemoryReq) + sdkReq := &deleteMemoryReq + err = w.AgentKit.DeleteMemory(ctx, *sdkReq) if err != nil { return err } @@ -640,13 +692,12 @@ func newDeleteMemory() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteMemoryStoreOverrides []func( *cobra.Command, - *agentkit.DeleteManagedMemoryStoreRequest, + *sdkagentkit.DeleteManagedMemoryStoreRequest, ) func newDeleteMemoryStore() *cobra.Command { cmd := &cobra.Command{} - - var deleteMemoryStoreReq agentkit.DeleteManagedMemoryStoreRequest + var deleteMemoryStoreReq sdkagentkit.DeleteManagedMemoryStoreRequest cmd.Use = "delete-memory-store NAME" cmd.Short = `Delete a managed memory store by resource name.` @@ -671,10 +722,12 @@ func newDeleteMemoryStore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteMemoryStoreReq.Name = args[0] + deleteMemoryStoreReq.Name = new(args[0]) - err = w.AgentKit.DeleteMemoryStore(ctx, deleteMemoryStoreReq) + sdkReq := &deleteMemoryStoreReq + err = w.AgentKit.DeleteMemoryStore(ctx, *sdkReq) if err != nil { return err } @@ -699,13 +752,12 @@ func newDeleteMemoryStore() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteSessionOverrides []func( *cobra.Command, - *agentkit.DeleteSessionRequest, + *sdkagentkit.DeleteSessionRequest, ) func newDeleteSession() *cobra.Command { cmd := &cobra.Command{} - - var deleteSessionReq agentkit.DeleteSessionRequest + var deleteSessionReq sdkagentkit.DeleteSessionRequest cmd.Use = "delete-session NAME" cmd.Short = `Delete a session.` @@ -731,10 +783,12 @@ func newDeleteSession() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteSessionReq.Name = args[0] + deleteSessionReq.Name = new(args[0]) - err = w.AgentKit.DeleteSession(ctx, deleteSessionReq) + sdkReq := &deleteSessionReq + err = w.AgentKit.DeleteSession(ctx, *sdkReq) if err != nil { return err } @@ -759,13 +813,12 @@ func newDeleteSession() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteSessionStoreOverrides []func( *cobra.Command, - *agentkit.DeleteSessionStoreRequest, + *sdkagentkit.DeleteSessionStoreRequest, ) func newDeleteSessionStore() *cobra.Command { cmd := &cobra.Command{} - - var deleteSessionStoreReq agentkit.DeleteSessionStoreRequest + var deleteSessionStoreReq sdkagentkit.DeleteSessionStoreRequest cmd.Use = "delete-session-store NAME" cmd.Short = `Delete a session store.` @@ -790,10 +843,12 @@ func newDeleteSessionStore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteSessionStoreReq.Name = args[0] + deleteSessionStoreReq.Name = new(args[0]) - err = w.AgentKit.DeleteSessionStore(ctx, deleteSessionStoreReq) + sdkReq := &deleteSessionStoreReq + err = w.AgentKit.DeleteSessionStore(ctx, *sdkReq) if err != nil { return err } @@ -823,14 +878,14 @@ var extractMemoriesOverrides []func( func newExtractMemories() *cobra.Command { cmd := &cobra.Command{} - var extractMemoriesReq agentkit.ExtractMemoriesRequest + var extractMemoriesJson flags.JsonFlag cmd.Flags().Var(&extractMemoriesJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&extractMemoriesReq.DryRun, "dry-run", extractMemoriesReq.DryRun, `When true, extract and return the entries without writing them to the memory store.`) - cmd.Flags().StringVar(&extractMemoriesReq.Instructions, "instructions", extractMemoriesReq.Instructions, `Instructions steering what is extracted from the session.`) + flags.BoolPtrVar(cmd.Flags(), &extractMemoriesReq.DryRun, "dry-run", `When true, extract and return the entries without writing them to the memory store.`) + flags.StringPtrVar(cmd.Flags(), &extractMemoriesReq.Instructions, "instructions", `Instructions steering what is extracted from the session.`) cmd.Use = "extract-memories SESSION_STORE SESSION_ID MEMORY_STORE" cmd.Short = `Extract memories from a session.` @@ -866,6 +921,7 @@ func newExtractMemories() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := extractMemoriesJson.Unmarshal(&extractMemoriesReq) @@ -879,18 +935,26 @@ func newExtractMemories() *cobra.Command { } } } - extractMemoriesReq.SessionStore = args[0] - extractMemoriesReq.SessionId = args[1] + extractMemoriesReq.SessionStore = new(args[0]) + extractMemoriesReq.SessionId = new(args[1]) if !cmd.Flags().Changed("json") { - extractMemoriesReq.MemoryStore = args[2] + extractMemoriesReq.MemoryStore = new(args[2]) } - response, err := w.AgentKit.ExtractMemories(ctx, extractMemoriesReq) + sdkReq, err := agentkit.ExtractMemoriesRequestToSDK(&extractMemoriesReq) + if err != nil { + return err + } + response, err := w.AgentKit.ExtractMemories(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.ExtractMemoriesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -916,15 +980,15 @@ var forkSessionOverrides []func( func newForkSession() *cobra.Command { cmd := &cobra.Command{} - var forkSessionReq agentkit.ForkSessionRequest + var forkSessionJson flags.JsonFlag cmd.Flags().Var(&forkSessionJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: map via StringToStringVar: metadata - cmd.Flags().StringVar(&forkSessionReq.SessionId, "session-id", forkSessionReq.SessionId, `Optional unique ID for the forked session.`) - cmd.Flags().StringVar(&forkSessionReq.UpToItemId, "up-to-item-id", forkSessionReq.UpToItemId, `Optional last item ID to copy through, inclusively.`) + flags.StringPtrVar(cmd.Flags(), &forkSessionReq.SessionId, "session-id", `Optional unique ID for the forked session.`) + flags.StringPtrVar(cmd.Flags(), &forkSessionReq.UpToItemId, "up-to-item-id", `Optional last item ID to copy through, inclusively.`) cmd.Use = "fork-session PARENT SOURCE_SESSION_ID ACTOR_ID" cmd.Short = `Fork a session.` @@ -959,6 +1023,7 @@ func newForkSession() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := forkSessionJson.Unmarshal(&forkSessionReq) @@ -972,20 +1037,28 @@ func newForkSession() *cobra.Command { } } } - forkSessionReq.Parent = args[0] + forkSessionReq.Parent = new(args[0]) if !cmd.Flags().Changed("json") { - forkSessionReq.SourceSessionId = args[1] + forkSessionReq.SourceSessionId = new(args[1]) } if !cmd.Flags().Changed("json") { - forkSessionReq.ActorId = args[2] + forkSessionReq.ActorId = new(args[2]) } - response, err := w.AgentKit.ForkSession(ctx, forkSessionReq) + sdkReq, err := agentkit.ForkSessionRequestToSDK(&forkSessionReq) + if err != nil { + return err + } + response, err := w.AgentKit.ForkSession(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.ForkSessionResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1011,7 +1084,6 @@ var getMemoryOverrides []func( func newGetMemory() *cobra.Command { cmd := &cobra.Command{} - var getMemoryReq agentkit.GetManagedMemoryEntryRequest var readMaskParam string @@ -1042,20 +1114,28 @@ func newGetMemory() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getMemoryReq.Name = args[0] + getMemoryReq.Name = new(args[0]) if readMaskParam != "" { - readMaskArray := strings.Split(readMaskParam, ",") - getMemoryReq.ReadMask = fieldmask.New(readMaskArray) + _ = readMaskParam } - response, err := w.AgentKit.GetMemory(ctx, getMemoryReq) + sdkReq, err := agentkit.GetManagedMemoryEntryRequestToSDK(&getMemoryReq) + if err != nil { + return err + } + response, err := w.AgentKit.GetMemory(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.ManagedMemoryEntryFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1076,13 +1156,12 @@ func newGetMemory() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getMemoryStoreOverrides []func( *cobra.Command, - *agentkit.GetManagedMemoryStoreRequest, + *sdkagentkit.GetManagedMemoryStoreRequest, ) func newGetMemoryStore() *cobra.Command { cmd := &cobra.Command{} - - var getMemoryStoreReq agentkit.GetManagedMemoryStoreRequest + var getMemoryStoreReq sdkagentkit.GetManagedMemoryStoreRequest cmd.Use = "get-memory-store NAME" cmd.Short = `Get a managed memory store by resource name.` @@ -1107,15 +1186,21 @@ func newGetMemoryStore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getMemoryStoreReq.Name = args[0] + getMemoryStoreReq.Name = new(args[0]) - response, err := w.AgentKit.GetMemoryStore(ctx, getMemoryStoreReq) + sdkReq := &getMemoryStoreReq + response, err := w.AgentKit.GetMemoryStore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.ManagedMemoryStoreFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1136,13 +1221,12 @@ func newGetMemoryStore() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getSessionOverrides []func( *cobra.Command, - *agentkit.GetSessionRequest, + *sdkagentkit.GetSessionRequest, ) func newGetSession() *cobra.Command { cmd := &cobra.Command{} - - var getSessionReq agentkit.GetSessionRequest + var getSessionReq sdkagentkit.GetSessionRequest cmd.Use = "get-session NAME" cmd.Short = `Get a session.` @@ -1167,15 +1251,21 @@ func newGetSession() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSessionReq.Name = args[0] + getSessionReq.Name = new(args[0]) - response, err := w.AgentKit.GetSession(ctx, getSessionReq) + sdkReq := &getSessionReq + response, err := w.AgentKit.GetSession(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.SessionFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1196,13 +1286,12 @@ func newGetSession() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getSessionStoreOverrides []func( *cobra.Command, - *agentkit.GetSessionStoreRequest, + *sdkagentkit.GetSessionStoreRequest, ) func newGetSessionStore() *cobra.Command { cmd := &cobra.Command{} - - var getSessionStoreReq agentkit.GetSessionStoreRequest + var getSessionStoreReq sdkagentkit.GetSessionStoreRequest cmd.Use = "get-session-store NAME" cmd.Short = `Get a session store.` @@ -1226,15 +1315,21 @@ func newGetSessionStore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSessionStoreReq.Name = args[0] + getSessionStoreReq.Name = new(args[0]) - response, err := w.AgentKit.GetSessionStore(ctx, getSessionStoreReq) + sdkReq := &getSessionStoreReq + response, err := w.AgentKit.GetSessionStore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.SessionStoreFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1260,24 +1355,24 @@ var listMemoriesOverrides []func( func newListMemories() *cobra.Command { cmd := &cobra.Command{} - var listMemoriesReq agentkit.ListManagedMemoryEntriesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listMemoriesLimit int - cmd.Flags().IntVar(&listMemoriesReq.PageSize, "page-size", listMemoriesReq.PageSize, `Maximum number of entries to return. Wire name: 'page_size'.`) - cmd.Flags().StringVar(&listMemoriesReq.PathPrefix, "path-prefix", listMemoriesReq.PathPrefix, `Optional path prefix used to restrict entries within the actor partition. Wire name: 'path_prefix'.`) + flags.IntPtrVar(cmd.Flags(), &listMemoriesReq.PageSize, "page-size", `Maximum number of entries to return. Wire name: 'page_size'.`) + flags.StringPtrVar(cmd.Flags(), &listMemoriesReq.PathPrefix, "path-prefix", `Optional path prefix used to restrict entries within the actor partition. Wire name: 'path_prefix'.`) var readMaskParam string cmd.Flags().StringVar(&readMaskParam, "read-mask", readMaskParam, `Deprecated. Wire name: 'read_mask'.`) - cmd.Flags().StringVar(&listMemoriesReq.SessionId, "session-id", listMemoriesReq.SessionId, `Optional session identifier. Wire name: 'session_id'.`) + flags.StringPtrVar(cmd.Flags(), &listMemoriesReq.SessionId, "session-id", `Optional session identifier. Wire name: 'session_id'.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listMemoriesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listMemoriesReq.PageToken, "page-token", listMemoriesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listMemoriesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-memories PARENT ACTOR_ID" @@ -1307,24 +1402,27 @@ func newListMemories() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listMemoriesReq.Parent = args[0] - listMemoriesReq.ActorId = args[1] + listMemoriesReq.Parent = new(args[0]) + listMemoriesReq.ActorId = new(args[1]) if readMaskParam != "" { - readMaskArray := strings.Split(readMaskParam, ",") - listMemoriesReq.ReadMask = fieldmask.New(readMaskArray) + _ = readMaskParam } - response := w.AgentKit.ListMemories(ctx, listMemoriesReq) + sdkReq, err := agentkit.ListManagedMemoryEntriesRequestToSDK(&listMemoriesReq) + if err != nil { + return err + } if listMemoriesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listMemoriesLimit) } if listMemoriesLimit > 0 { ctx = cmdio.WithLimit(ctx, listMemoriesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AgentKit.ListMemoriesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, agentkit.ManagedMemoryEntryFromSDK)) } // Disable completions since they are not applicable. @@ -1350,20 +1448,20 @@ var listMemoryStoresOverrides []func( func newListMemoryStores() *cobra.Command { cmd := &cobra.Command{} - var listMemoryStoresReq agentkit.ListManagedMemoryStoresRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listMemoryStoresLimit int - cmd.Flags().IntVar(&listMemoryStoresReq.PageSize, "page-size", listMemoryStoresReq.PageSize, `Maximum number of stores to return.`) + flags.IntPtrVar(cmd.Flags(), &listMemoryStoresReq.PageSize, "page-size", `Maximum number of stores to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listMemoryStoresLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listMemoryStoresReq.PageToken, "page-token", listMemoryStoresReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listMemoryStoresReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-memory-stores" @@ -1385,16 +1483,20 @@ func newListMemoryStores() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.AgentKit.ListMemoryStores(ctx, listMemoryStoresReq) + sdkReq, err := agentkit.ListManagedMemoryStoresRequestToSDK(&listMemoryStoresReq) + if err != nil { + return err + } if listMemoryStoresLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listMemoryStoresLimit) } if listMemoryStoresLimit > 0 { ctx = cmdio.WithLimit(ctx, listMemoryStoresLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AgentKit.ListMemoryStoresIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, agentkit.ManagedMemoryStoreFromSDK)) } // Disable completions since they are not applicable. @@ -1420,21 +1522,21 @@ var listSessionItemsOverrides []func( func newListSessionItems() *cobra.Command { cmd := &cobra.Command{} - var listSessionItemsReq agentkit.ListSessionItemsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSessionItemsLimit int - cmd.Flags().StringVar(&listSessionItemsReq.OrderBy, "order-by", listSessionItemsReq.OrderBy, `Sort order.`) - cmd.Flags().IntVar(&listSessionItemsReq.PageSize, "page-size", listSessionItemsReq.PageSize, `Maximum number of items to return.`) + flags.StringPtrVar(cmd.Flags(), &listSessionItemsReq.OrderBy, "order-by", `Sort order.`) + flags.IntPtrVar(cmd.Flags(), &listSessionItemsReq.PageSize, "page-size", `Maximum number of items to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listSessionItemsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSessionItemsReq.PageToken, "page-token", listSessionItemsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSessionItemsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-session-items PARENT" @@ -1460,18 +1562,22 @@ func newListSessionItems() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listSessionItemsReq.Parent = args[0] + listSessionItemsReq.Parent = new(args[0]) - response := w.AgentKit.ListSessionItems(ctx, listSessionItemsReq) + sdkReq, err := agentkit.ListSessionItemsRequestToSDK(&listSessionItemsReq) + if err != nil { + return err + } if listSessionItemsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSessionItemsLimit) } if listSessionItemsLimit > 0 { ctx = cmdio.WithLimit(ctx, listSessionItemsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AgentKit.ListSessionItemsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, agentkit.SessionItemFromSDK)) } // Disable completions since they are not applicable. @@ -1497,20 +1603,20 @@ var listSessionStoresOverrides []func( func newListSessionStores() *cobra.Command { cmd := &cobra.Command{} - var listSessionStoresReq agentkit.ListSessionStoresRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSessionStoresLimit int - cmd.Flags().IntVar(&listSessionStoresReq.PageSize, "page-size", listSessionStoresReq.PageSize, `Maximum number of session stores to return.`) + flags.IntPtrVar(cmd.Flags(), &listSessionStoresReq.PageSize, "page-size", `Maximum number of session stores to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listSessionStoresLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSessionStoresReq.PageToken, "page-token", listSessionStoresReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSessionStoresReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-session-stores" @@ -1532,16 +1638,20 @@ func newListSessionStores() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.AgentKit.ListSessionStores(ctx, listSessionStoresReq) + sdkReq, err := agentkit.ListSessionStoresRequestToSDK(&listSessionStoresReq) + if err != nil { + return err + } if listSessionStoresLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSessionStoresLimit) } if listSessionStoresLimit > 0 { ctx = cmdio.WithLimit(ctx, listSessionStoresLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AgentKit.ListSessionStoresIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, agentkit.SessionStoreFromSDK)) } // Disable completions since they are not applicable. @@ -1567,22 +1677,22 @@ var listSessionsOverrides []func( func newListSessions() *cobra.Command { cmd := &cobra.Command{} - var listSessionsReq agentkit.ListSessionsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSessionsLimit int - cmd.Flags().StringVar(&listSessionsReq.Filter, "filter", listSessionsReq.Filter, `Filter expression.`) - cmd.Flags().StringVar(&listSessionsReq.OrderBy, "order-by", listSessionsReq.OrderBy, `Sort order.`) - cmd.Flags().IntVar(&listSessionsReq.PageSize, "page-size", listSessionsReq.PageSize, `Maximum number of sessions to return.`) + flags.StringPtrVar(cmd.Flags(), &listSessionsReq.Filter, "filter", `Filter expression.`) + flags.StringPtrVar(cmd.Flags(), &listSessionsReq.OrderBy, "order-by", `Sort order.`) + flags.IntPtrVar(cmd.Flags(), &listSessionsReq.PageSize, "page-size", `Maximum number of sessions to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listSessionsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSessionsReq.PageToken, "page-token", listSessionsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSessionsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-sessions PARENT" @@ -1608,18 +1718,22 @@ func newListSessions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listSessionsReq.Parent = args[0] + listSessionsReq.Parent = new(args[0]) - response := w.AgentKit.ListSessions(ctx, listSessionsReq) + sdkReq, err := agentkit.ListSessionsRequestToSDK(&listSessionsReq) + if err != nil { + return err + } if listSessionsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSessionsLimit) } if listSessionsLimit > 0 { ctx = cmdio.WithLimit(ctx, listSessionsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AgentKit.ListSessionsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, agentkit.SessionFromSDK)) } // Disable completions since they are not applicable. @@ -1645,7 +1759,6 @@ var popSessionItemOverrides []func( func newPopSessionItem() *cobra.Command { cmd := &cobra.Command{} - var popSessionItemReq agentkit.PopSessionItemRequest cmd.Use = "pop-session-item PARENT" @@ -1671,15 +1784,24 @@ func newPopSessionItem() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - popSessionItemReq.Parent = args[0] + popSessionItemReq.Parent = new(args[0]) - response, err := w.AgentKit.PopSessionItem(ctx, popSessionItemReq) + sdkReq, err := agentkit.PopSessionItemRequestToSDK(&popSessionItemReq) + if err != nil { + return err + } + response, err := w.AgentKit.PopSessionItem(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.PopSessionItemResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1705,8 +1827,8 @@ var searchMemoriesOverrides []func( func newSearchMemories() *cobra.Command { cmd := &cobra.Command{} - var searchMemoriesReq agentkit.SearchManagedMemoryEntriesRequest + var searchMemoriesJson flags.JsonFlag // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO @@ -1715,17 +1837,17 @@ func newSearchMemories() *cobra.Command { cmd.Flags().Var(&searchMemoriesJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().IntVar(&searchMemoriesReq.PageSize, "page-size", searchMemoriesReq.PageSize, `Maximum number of relevance-ranked entries to return. Wire name: 'page_size'.`) - cmd.Flags().StringVar(&searchMemoriesReq.PathPrefix, "path-prefix", searchMemoriesReq.PathPrefix, `Optional absolute, case-sensitive path prefix used to restrict searched entries within the actor partition. Wire name: 'path_prefix'.`) + flags.IntPtrVar(cmd.Flags(), &searchMemoriesReq.PageSize, "page-size", `Maximum number of relevance-ranked entries to return. Wire name: 'page_size'.`) + flags.StringPtrVar(cmd.Flags(), &searchMemoriesReq.PathPrefix, "path-prefix", `Optional absolute, case-sensitive path prefix used to restrict searched entries within the actor partition. Wire name: 'path_prefix'.`) var readMaskParam string cmd.Flags().StringVar(&readMaskParam, "read-mask", readMaskParam, `Deprecated. Wire name: 'read_mask'.`) - cmd.Flags().StringVar(&searchMemoriesReq.SessionId, "session-id", searchMemoriesReq.SessionId, `Optional session identifier. Wire name: 'session_id'.`) + flags.StringPtrVar(cmd.Flags(), &searchMemoriesReq.SessionId, "session-id", `Optional session identifier. Wire name: 'session_id'.`) // Limit flag for total result capping. cmd.Flags().IntVar(&searchMemoriesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&searchMemoriesReq.PageToken, "page-token", searchMemoriesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &searchMemoriesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "search-memories PARENT ACTOR_ID QUERY" @@ -1762,6 +1884,7 @@ func newSearchMemories() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := searchMemoriesJson.Unmarshal(&searchMemoriesReq) @@ -1775,28 +1898,30 @@ func newSearchMemories() *cobra.Command { } } } - searchMemoriesReq.Parent = args[0] + searchMemoriesReq.Parent = new(args[0]) if !cmd.Flags().Changed("json") { - searchMemoriesReq.ActorId = args[1] + searchMemoriesReq.ActorId = new(args[1]) } if !cmd.Flags().Changed("json") { - searchMemoriesReq.Query = args[2] + searchMemoriesReq.Query = new(args[2]) } if readMaskParam != "" { - readMaskArray := strings.Split(readMaskParam, ",") - searchMemoriesReq.ReadMask = fieldmask.New(readMaskArray) + _ = readMaskParam } - response := w.AgentKit.SearchMemories(ctx, searchMemoriesReq) + sdkReq, err := agentkit.SearchManagedMemoryEntriesRequestToSDK(&searchMemoriesReq) + if err != nil { + return err + } if searchMemoriesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", searchMemoriesLimit) } if searchMemoriesLimit > 0 { ctx = cmdio.WithLimit(ctx, searchMemoriesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AgentKit.SearchMemoriesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, agentkit.ManagedMemoryEntrySearchResultFromSDK)) } // Disable completions since they are not applicable. @@ -1822,17 +1947,17 @@ var updateMemoryOverrides []func( func newUpdateMemory() *cobra.Command { cmd := &cobra.Command{} - var updateMemoryReq agentkit.UpdateManagedMemoryEntryRequest - updateMemoryReq.ManagedMemoryEntry = agentkit.ManagedMemoryEntry{} + updateMemoryReq.ManagedMemoryEntry = &agentkit.ManagedMemoryEntry{} + var updateMemoryJson flags.JsonFlag cmd.Flags().Var(&updateMemoryJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateMemoryReq.ManagedMemoryEntry.Content, "content", updateMemoryReq.ManagedMemoryEntry.Content, `Optional free-form memory content.`) - cmd.Flags().StringVar(&updateMemoryReq.ManagedMemoryEntry.Description, "description", updateMemoryReq.ManagedMemoryEntry.Description, `Human-readable description of the memory entry.`) - cmd.Flags().StringVar(&updateMemoryReq.ManagedMemoryEntry.SessionId, "session-id", updateMemoryReq.ManagedMemoryEntry.SessionId, `Optional identifier for the session associated with this memory entry.`) - cmd.Flags().Var(&updateMemoryReq.ManagedMemoryEntry.SourceType, "source-type", `Which writer created this entry. Supported values: [MANAGED_MEMORY_ENTRY_SOURCE_TYPE_AGENT, MANAGED_MEMORY_ENTRY_SOURCE_TYPE_DREAMER]`) + flags.StringPtrVar(cmd.Flags(), &updateMemoryReq.ManagedMemoryEntry.Content, "content", `Optional free-form memory content.`) + flags.StringPtrVar(cmd.Flags(), &updateMemoryReq.ManagedMemoryEntry.Description, "description", `Human-readable description of the memory entry.`) + flags.StringPtrVar(cmd.Flags(), &updateMemoryReq.ManagedMemoryEntry.SessionId, "session-id", `Optional identifier for the session associated with this memory entry.`) + flags.EnumVar(cmd.Flags(), &updateMemoryReq.ManagedMemoryEntry.SourceType, "source-type", `Which writer created this entry. Supported values: [MANAGED_MEMORY_ENTRY_SOURCE_TYPE_AGENT, MANAGED_MEMORY_ENTRY_SOURCE_TYPE_DREAMER]`, "ManagedMemoryEntrySourceType", "MANAGED_MEMORY_ENTRY_SOURCE_TYPE_AGENT", "MANAGED_MEMORY_ENTRY_SOURCE_TYPE_DREAMER") cmd.Use = "update-memory NAME UPDATE_MASK ACTOR_ID PATH" cmd.Short = `Update a managed memory entry.` @@ -1871,6 +1996,7 @@ func newUpdateMemory() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateMemoryJson.Unmarshal(&updateMemoryReq.ManagedMemoryEntry) @@ -1884,24 +2010,31 @@ func newUpdateMemory() *cobra.Command { } } } - updateMemoryReq.Name = args[0] + updateMemoryReq.ManagedMemoryEntry.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateMemoryReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateMemoryReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - updateMemoryReq.ManagedMemoryEntry.ActorId = args[2] + updateMemoryReq.ManagedMemoryEntry.ActorId = new(args[2]) } if !cmd.Flags().Changed("json") { - updateMemoryReq.ManagedMemoryEntry.Path = args[3] + updateMemoryReq.ManagedMemoryEntry.Path = new(args[3]) } - response, err := w.AgentKit.UpdateMemory(ctx, updateMemoryReq) + sdkReq, err := agentkit.UpdateManagedMemoryEntryRequestToSDK(&updateMemoryReq) + if err != nil { + return err + } + response, err := w.AgentKit.UpdateMemory(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.ManagedMemoryEntryFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1927,15 +2060,15 @@ var updateMemoryStoreOverrides []func( func newUpdateMemoryStore() *cobra.Command { cmd := &cobra.Command{} - var updateMemoryStoreReq agentkit.UpdateManagedMemoryStoreRequest - updateMemoryStoreReq.ManagedMemoryStore = agentkit.ManagedMemoryStore{} + updateMemoryStoreReq.ManagedMemoryStore = &agentkit.ManagedMemoryStore{} + var updateMemoryStoreJson flags.JsonFlag cmd.Flags().Var(&updateMemoryStoreJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateMemoryStoreReq.ManagedMemoryStore.Description, "description", updateMemoryStoreReq.ManagedMemoryStore.Description, `Human-readable description of the memory store.`) - cmd.Flags().StringVar(&updateMemoryStoreReq.ManagedMemoryStore.DisplayName, "display-name", updateMemoryStoreReq.ManagedMemoryStore.DisplayName, `Deprecated compatibility alias for the caller-provided managed memory store ID.`) + flags.StringPtrVar(cmd.Flags(), &updateMemoryStoreReq.ManagedMemoryStore.Description, "description", `Human-readable description of the memory store.`) + flags.StringPtrVar(cmd.Flags(), &updateMemoryStoreReq.ManagedMemoryStore.DisplayName, "display-name", `Deprecated compatibility alias for the caller-provided managed memory store ID.`) // TODO: complex arg: storage_backend cmd.Use = "update-memory-store NAME UPDATE_MASK" @@ -1962,6 +2095,7 @@ func newUpdateMemoryStore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateMemoryStoreJson.Unmarshal(&updateMemoryStoreReq.ManagedMemoryStore) @@ -1975,18 +2109,25 @@ func newUpdateMemoryStore() *cobra.Command { } } } - updateMemoryStoreReq.Name = args[0] + updateMemoryStoreReq.ManagedMemoryStore.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateMemoryStoreReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateMemoryStoreReq.UpdateMask = new(args[1]) } - response, err := w.AgentKit.UpdateMemoryStore(ctx, updateMemoryStoreReq) + sdkReq, err := agentkit.UpdateManagedMemoryStoreRequestToSDK(&updateMemoryStoreReq) + if err != nil { + return err + } + response, err := w.AgentKit.UpdateMemoryStore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.ManagedMemoryStoreFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2012,15 +2153,15 @@ var updateSessionOverrides []func( func newUpdateSession() *cobra.Command { cmd := &cobra.Command{} - var updateSessionReq agentkit.UpdateSessionRequest - updateSessionReq.Session = agentkit.Session{} + updateSessionReq.Session = &agentkit.Session{} + var updateSessionJson flags.JsonFlag cmd.Flags().Var(&updateSessionJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: map via StringToStringVar: metadata - cmd.Flags().StringVar(&updateSessionReq.Session.ParentSessionId, "parent-session-id", updateSessionReq.Session.ParentSessionId, `Immediate parent session ID.`) + flags.StringPtrVar(cmd.Flags(), &updateSessionReq.Session.ParentSessionId, "parent-session-id", `Immediate parent session ID.`) cmd.Use = "update-session NAME UPDATE_MASK ACTOR_ID" cmd.Short = `Update a session.` @@ -2061,6 +2202,7 @@ func newUpdateSession() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateSessionJson.Unmarshal(&updateSessionReq.Session) @@ -2074,21 +2216,28 @@ func newUpdateSession() *cobra.Command { } } } - updateSessionReq.Name = args[0] + updateSessionReq.Session.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateSessionReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateSessionReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - updateSessionReq.Session.ActorId = args[2] + updateSessionReq.Session.ActorId = new(args[2]) } - response, err := w.AgentKit.UpdateSession(ctx, updateSessionReq) + sdkReq, err := agentkit.UpdateSessionRequestToSDK(&updateSessionReq) + if err != nil { + return err + } + response, err := w.AgentKit.UpdateSession(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.SessionFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2114,14 +2263,14 @@ var updateSessionStoreOverrides []func( func newUpdateSessionStore() *cobra.Command { cmd := &cobra.Command{} - var updateSessionStoreReq agentkit.UpdateSessionStoreRequest - updateSessionStoreReq.SessionStore = agentkit.SessionStore{} + updateSessionStoreReq.SessionStore = &agentkit.SessionStore{} + var updateSessionStoreJson flags.JsonFlag cmd.Flags().Var(&updateSessionStoreJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateSessionStoreReq.SessionStore.Description, "description", updateSessionStoreReq.SessionStore.Description, `Human-readable description of the session store.`) + flags.StringPtrVar(cmd.Flags(), &updateSessionStoreReq.SessionStore.Description, "description", `Human-readable description of the session store.`) // TODO: map via StringToStringVar: metadata cmd.Use = "update-session-store NAME UPDATE_MASK" @@ -2148,6 +2297,7 @@ func newUpdateSessionStore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateSessionStoreJson.Unmarshal(&updateSessionStoreReq.SessionStore) @@ -2161,18 +2311,25 @@ func newUpdateSessionStore() *cobra.Command { } } } - updateSessionStoreReq.Name = args[0] + updateSessionStoreReq.SessionStore.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateSessionStoreReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateSessionStoreReq.UpdateMask = new(args[1]) } - response, err := w.AgentKit.UpdateSessionStore(ctx, updateSessionStoreReq) + sdkReq, err := agentkit.UpdateSessionStoreRequestToSDK(&updateSessionStoreReq) + if err != nil { + return err + } + response, err := w.AgentKit.UpdateSessionStore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := agentkit.SessionStoreFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/ai-functions/ai-functions.go b/cmd/workspace/ai-functions/ai-functions.go index 2565a239bb9..0665b4d96b3 100644 --- a/cmd/workspace/ai-functions/ai-functions.go +++ b/cmd/workspace/ai-functions/ai-functions.go @@ -9,8 +9,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/aifunctions" "github.com/spf13/cobra" + + aifunctions "github.com/databricks/cli/libs/sdktypes/aifunctions/v1" ) // Slice with functions to override default command behavior. @@ -55,8 +56,8 @@ var aiClassifyOverrides []func( func newAiClassify() *cobra.Command { cmd := &cobra.Command{} - var aiClassifyReq aifunctions.AiClassifyRequest + var aiClassifyJson flags.JsonFlag cmd.Flags().Var(&aiClassifyJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -79,6 +80,7 @@ func newAiClassify() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := aiClassifyJson.Unmarshal(&aiClassifyReq) @@ -95,12 +97,20 @@ func newAiClassify() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.AiFunctions.AiClassify(ctx, aiClassifyReq) + sdkReq, err := aifunctions.AiClassifyRequestToSDK(&aiClassifyReq) + if err != nil { + return err + } + response, err := w.AiFunctions.AiClassify(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aifunctions.AiClassifyResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -126,8 +136,8 @@ var aiDecideOverrides []func( func newAiDecide() *cobra.Command { cmd := &cobra.Command{} - var aiDecideReq aifunctions.AiDecideRequest + var aiDecideJson flags.JsonFlag cmd.Flags().Var(&aiDecideJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -152,6 +162,7 @@ Get fast structured decisions. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := aiDecideJson.Unmarshal(&aiDecideReq) @@ -168,12 +179,20 @@ Get fast structured decisions. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.AiFunctions.AiDecide(ctx, aiDecideReq) + sdkReq, err := aifunctions.AiDecideRequestToSDK(&aiDecideReq) + if err != nil { + return err + } + response, err := w.AiFunctions.AiDecide(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aifunctions.AiDecideResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -199,8 +218,8 @@ var aiExtractOverrides []func( func newAiExtract() *cobra.Command { cmd := &cobra.Command{} - var aiExtractReq aifunctions.AiExtractRequest + var aiExtractJson flags.JsonFlag cmd.Flags().Var(&aiExtractJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -224,6 +243,7 @@ func newAiExtract() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := aiExtractJson.Unmarshal(&aiExtractReq) @@ -240,12 +260,20 @@ func newAiExtract() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.AiFunctions.AiExtract(ctx, aiExtractReq) + sdkReq, err := aifunctions.AiExtractRequestToSDK(&aiExtractReq) + if err != nil { + return err + } + response, err := w.AiFunctions.AiExtract(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aifunctions.AiExtractResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -271,8 +299,8 @@ var aiParseDocumentOverrides []func( func newAiParseDocument() *cobra.Command { cmd := &cobra.Command{} - var aiParseDocumentReq aifunctions.AiParseDocumentRequest + var aiParseDocumentJson flags.JsonFlag cmd.Flags().Var(&aiParseDocumentJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -311,6 +339,7 @@ func newAiParseDocument() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := aiParseDocumentJson.Unmarshal(&aiParseDocumentReq) @@ -325,15 +354,23 @@ func newAiParseDocument() *cobra.Command { } } if !cmd.Flags().Changed("json") { - aiParseDocumentReq.Content = args[0] + aiParseDocumentReq.Content = new(args[0]) } - response, err := w.AiFunctions.AiParseDocument(ctx, aiParseDocumentReq) + sdkReq, err := aifunctions.AiParseDocumentRequestToSDK(&aiParseDocumentReq) + if err != nil { + return err + } + response, err := w.AiFunctions.AiParseDocument(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aifunctions.AiParseDocumentResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/ai-gateway/ai-gateway.go b/cmd/workspace/ai-gateway/ai-gateway.go index 3fe1d3da088..993419e8254 100644 --- a/cmd/workspace/ai-gateway/ai-gateway.go +++ b/cmd/workspace/ai-gateway/ai-gateway.go @@ -4,15 +4,16 @@ package ai_gateway import ( "fmt" - "strings" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "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/catalog" "github.com/spf13/cobra" + + aigateway "github.com/databricks/cli/libs/sdktypes/aigateway/v1" + sdkaigateway "github.com/databricks/sdk-go/aigateway/v1" ) // Slice with functions to override default command behavior. @@ -76,21 +77,21 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createMcpServiceOverrides []func( *cobra.Command, - *catalog.CreateMcpServiceRequest, + *aigateway.CreateMcpServiceRequest, ) func newCreateMcpService() *cobra.Command { cmd := &cobra.Command{} + var createMcpServiceReq aigateway.CreateMcpServiceRequest + createMcpServiceReq.McpService = &aigateway.McpService{} - var createMcpServiceReq catalog.CreateMcpServiceRequest - createMcpServiceReq.McpService = catalog.McpService{} var createMcpServiceJson flags.JsonFlag cmd.Flags().Var(&createMcpServiceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createMcpServiceReq.McpService.Comment, "comment", createMcpServiceReq.McpService.Comment, `User-provided description.`) + flags.StringPtrVar(cmd.Flags(), &createMcpServiceReq.McpService.Comment, "comment", `User-provided description.`) // TODO: complex arg: config - cmd.Flags().StringVar(&createMcpServiceReq.McpService.Name, "name", createMcpServiceReq.McpService.Name, `Resource name of the MCP service.`) + flags.StringPtrVar(cmd.Flags(), &createMcpServiceReq.McpService.Name, "name", `Resource name of the MCP service.`) cmd.Use = "create-mcp-service PARENT MCP_SERVICE_ID" cmd.Short = `Create an MCP service.` @@ -124,6 +125,7 @@ func newCreateMcpService() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createMcpServiceJson.Unmarshal(&createMcpServiceReq.McpService) @@ -137,15 +139,23 @@ func newCreateMcpService() *cobra.Command { } } } - createMcpServiceReq.Parent = args[0] - createMcpServiceReq.McpServiceId = args[1] + createMcpServiceReq.Parent = new(args[0]) + createMcpServiceReq.McpServiceId = new(args[1]) - response, err := w.AiGateway.CreateMcpService(ctx, createMcpServiceReq) + sdkReq, err := aigateway.CreateMcpServiceRequestToSDK(&createMcpServiceReq) + if err != nil { + return err + } + response, err := w.AiGateway.CreateMcpService(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.McpServiceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -166,14 +176,14 @@ func newCreateMcpService() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createMcpServiceUserMappedCredentialOverrides []func( *cobra.Command, - *catalog.CreateMcpServiceUserMappedCredentialRequest, + *aigateway.CreateMcpServiceUserMappedCredentialRequest, ) func newCreateMcpServiceUserMappedCredential() *cobra.Command { cmd := &cobra.Command{} + var createMcpServiceUserMappedCredentialReq aigateway.CreateMcpServiceUserMappedCredentialRequest + createMcpServiceUserMappedCredentialReq.Login = &aigateway.McpServiceUserMappedCredentialLogin{} - var createMcpServiceUserMappedCredentialReq catalog.CreateMcpServiceUserMappedCredentialRequest - createMcpServiceUserMappedCredentialReq.Login = catalog.McpServiceUserMappedCredentialLogin{} var createMcpServiceUserMappedCredentialJson flags.JsonFlag cmd.Flags().Var(&createMcpServiceUserMappedCredentialJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -210,6 +220,7 @@ Create an MCP service user credential. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createMcpServiceUserMappedCredentialJson.Unmarshal(&createMcpServiceUserMappedCredentialReq.Login) @@ -223,14 +234,22 @@ Create an MCP service user credential. } } } - createMcpServiceUserMappedCredentialReq.Name = args[0] + createMcpServiceUserMappedCredentialReq.Name = new(args[0]) - response, err := w.AiGateway.CreateMcpServiceUserMappedCredential(ctx, createMcpServiceUserMappedCredentialReq) + sdkReq, err := aigateway.CreateMcpServiceUserMappedCredentialRequestToSDK(&createMcpServiceUserMappedCredentialReq) + if err != nil { + return err + } + response, err := w.AiGateway.CreateMcpServiceUserMappedCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.McpServiceUserMappedCredentialFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -251,21 +270,21 @@ Create an MCP service user credential. // Functions can be added from the `init()` function in manually curated files in this directory. var createModelProviderServiceOverrides []func( *cobra.Command, - *catalog.CreateModelProviderServiceRequest, + *aigateway.CreateModelProviderServiceRequest, ) func newCreateModelProviderService() *cobra.Command { cmd := &cobra.Command{} + var createModelProviderServiceReq aigateway.CreateModelProviderServiceRequest + createModelProviderServiceReq.ModelProviderService = &aigateway.ModelProviderService{} - var createModelProviderServiceReq catalog.CreateModelProviderServiceRequest - createModelProviderServiceReq.ModelProviderService = catalog.ModelProviderService{} var createModelProviderServiceJson flags.JsonFlag cmd.Flags().Var(&createModelProviderServiceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createModelProviderServiceReq.ModelProviderService.Comment, "comment", createModelProviderServiceReq.ModelProviderService.Comment, `User-provided description.`) + flags.StringPtrVar(cmd.Flags(), &createModelProviderServiceReq.ModelProviderService.Comment, "comment", `User-provided description.`) // TODO: complex arg: config - cmd.Flags().StringVar(&createModelProviderServiceReq.ModelProviderService.Name, "name", createModelProviderServiceReq.ModelProviderService.Name, `Resource name of the provider service.`) + flags.StringPtrVar(cmd.Flags(), &createModelProviderServiceReq.ModelProviderService.Name, "name", `Resource name of the provider service.`) cmd.Use = "create-model-provider-service PARENT MODEL_PROVIDER_SERVICE_ID" cmd.Short = `Create a model provider service.` @@ -301,6 +320,7 @@ func newCreateModelProviderService() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createModelProviderServiceJson.Unmarshal(&createModelProviderServiceReq.ModelProviderService) @@ -314,15 +334,23 @@ func newCreateModelProviderService() *cobra.Command { } } } - createModelProviderServiceReq.Parent = args[0] - createModelProviderServiceReq.ModelProviderServiceId = args[1] + createModelProviderServiceReq.Parent = new(args[0]) + createModelProviderServiceReq.ModelProviderServiceId = new(args[1]) - response, err := w.AiGateway.CreateModelProviderService(ctx, createModelProviderServiceReq) + sdkReq, err := aigateway.CreateModelProviderServiceRequestToSDK(&createModelProviderServiceReq) + if err != nil { + return err + } + response, err := w.AiGateway.CreateModelProviderService(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.ModelProviderServiceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -343,21 +371,21 @@ func newCreateModelProviderService() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createModelServiceOverrides []func( *cobra.Command, - *catalog.CreateModelServiceRequest, + *aigateway.CreateModelServiceRequest, ) func newCreateModelService() *cobra.Command { cmd := &cobra.Command{} + var createModelServiceReq aigateway.CreateModelServiceRequest + createModelServiceReq.ModelService = &aigateway.ModelService{} - var createModelServiceReq catalog.CreateModelServiceRequest - createModelServiceReq.ModelService = catalog.ModelService{} var createModelServiceJson flags.JsonFlag cmd.Flags().Var(&createModelServiceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createModelServiceReq.ModelService.Comment, "comment", createModelServiceReq.ModelService.Comment, `User-provided description.`) + flags.StringPtrVar(cmd.Flags(), &createModelServiceReq.ModelService.Comment, "comment", `User-provided description.`) // TODO: complex arg: config - cmd.Flags().StringVar(&createModelServiceReq.ModelService.Name, "name", createModelServiceReq.ModelService.Name, `Resource name of the model service.`) + flags.StringPtrVar(cmd.Flags(), &createModelServiceReq.ModelService.Name, "name", `Resource name of the model service.`) // TODO: array: supported_api_types cmd.Use = "create-model-service PARENT MODEL_SERVICE_ID" @@ -394,6 +422,7 @@ func newCreateModelService() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createModelServiceJson.Unmarshal(&createModelServiceReq.ModelService) @@ -407,15 +436,23 @@ func newCreateModelService() *cobra.Command { } } } - createModelServiceReq.Parent = args[0] - createModelServiceReq.ModelServiceId = args[1] + createModelServiceReq.Parent = new(args[0]) + createModelServiceReq.ModelServiceId = new(args[1]) - response, err := w.AiGateway.CreateModelService(ctx, createModelServiceReq) + sdkReq, err := aigateway.CreateModelServiceRequestToSDK(&createModelServiceReq) + if err != nil { + return err + } + response, err := w.AiGateway.CreateModelService(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.ModelServiceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -436,20 +473,20 @@ func newCreateModelService() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createSkillOverrides []func( *cobra.Command, - *catalog.CreateSkillRequest, + *aigateway.CreateSkillRequest, ) func newCreateSkill() *cobra.Command { cmd := &cobra.Command{} + var createSkillReq aigateway.CreateSkillRequest + createSkillReq.Skill = &aigateway.Skill{} - var createSkillReq catalog.CreateSkillRequest - createSkillReq.Skill = catalog.Skill{} var createSkillJson flags.JsonFlag cmd.Flags().Var(&createSkillJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createSkillReq.Skill.Comment, "comment", createSkillReq.Skill.Comment, `User-provided comment for the skill.`) - cmd.Flags().StringVar(&createSkillReq.Skill.Name, "name", createSkillReq.Skill.Name, `Resource name of the skill.`) + flags.StringPtrVar(cmd.Flags(), &createSkillReq.Skill.Comment, "comment", `User-provided comment for the skill.`) + flags.StringPtrVar(cmd.Flags(), &createSkillReq.Skill.Name, "name", `Resource name of the skill.`) cmd.Use = "create-skill PARENT SKILL_ID" cmd.Short = `*Beta* Create a skill.` @@ -485,6 +522,7 @@ Create a skill. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createSkillJson.Unmarshal(&createSkillReq.Skill) @@ -498,15 +536,23 @@ Create a skill. } } } - createSkillReq.Parent = args[0] - createSkillReq.SkillId = args[1] + createSkillReq.Parent = new(args[0]) + createSkillReq.SkillId = new(args[1]) - response, err := w.AiGateway.CreateSkill(ctx, createSkillReq) + sdkReq, err := aigateway.CreateSkillRequestToSDK(&createSkillReq) + if err != nil { + return err + } + response, err := w.AiGateway.CreateSkill(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.SkillFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -527,15 +573,14 @@ Create a skill. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteMcpServiceOverrides []func( *cobra.Command, - *catalog.DeleteMcpServiceRequest, + *aigateway.DeleteMcpServiceRequest, ) func newDeleteMcpService() *cobra.Command { cmd := &cobra.Command{} + var deleteMcpServiceReq aigateway.DeleteMcpServiceRequest - var deleteMcpServiceReq catalog.DeleteMcpServiceRequest - - cmd.Flags().StringVar(&deleteMcpServiceReq.Etag, "etag", deleteMcpServiceReq.Etag, `Optimistic concurrency token from the most recent read.`) + flags.Base64Var(cmd.Flags(), &deleteMcpServiceReq.Etag, "etag", `Optimistic concurrency token from the most recent read.`) cmd.Use = "delete-mcp-service NAME" cmd.Short = `Delete an MCP service.` @@ -566,10 +611,15 @@ func newDeleteMcpService() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteMcpServiceReq.Name = args[0] + deleteMcpServiceReq.Name = new(args[0]) - err = w.AiGateway.DeleteMcpService(ctx, deleteMcpServiceReq) + sdkReq, err := aigateway.DeleteMcpServiceRequestToSDK(&deleteMcpServiceReq) + if err != nil { + return err + } + err = w.AiGateway.DeleteMcpService(ctx, *sdkReq) if err != nil { return err } @@ -594,13 +644,12 @@ func newDeleteMcpService() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteMcpServiceUserMappedCredentialOverrides []func( *cobra.Command, - *catalog.DeleteMcpServiceUserMappedCredentialRequest, + *sdkaigateway.DeleteMcpServiceUserMappedCredentialRequest, ) func newDeleteMcpServiceUserMappedCredential() *cobra.Command { cmd := &cobra.Command{} - - var deleteMcpServiceUserMappedCredentialReq catalog.DeleteMcpServiceUserMappedCredentialRequest + var deleteMcpServiceUserMappedCredentialReq sdkaigateway.DeleteMcpServiceUserMappedCredentialRequest cmd.Use = "delete-mcp-service-user-mapped-credential NAME" cmd.Short = `*Beta* Delete an MCP service user credential.` @@ -631,15 +680,18 @@ Delete an MCP service user credential. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteMcpServiceUserMappedCredentialReq.Name = args[0] + deleteMcpServiceUserMappedCredentialReq.Name = new(args[0]) - response, err := w.AiGateway.DeleteMcpServiceUserMappedCredential(ctx, deleteMcpServiceUserMappedCredentialReq) + sdkReq := &deleteMcpServiceUserMappedCredentialReq + response, err := w.AiGateway.DeleteMcpServiceUserMappedCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. @@ -660,15 +712,14 @@ Delete an MCP service user credential. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteModelProviderServiceOverrides []func( *cobra.Command, - *catalog.DeleteModelProviderServiceRequest, + *aigateway.DeleteModelProviderServiceRequest, ) func newDeleteModelProviderService() *cobra.Command { cmd := &cobra.Command{} + var deleteModelProviderServiceReq aigateway.DeleteModelProviderServiceRequest - var deleteModelProviderServiceReq catalog.DeleteModelProviderServiceRequest - - cmd.Flags().StringVar(&deleteModelProviderServiceReq.Etag, "etag", deleteModelProviderServiceReq.Etag, `Optimistic concurrency token from the most recent read.`) + flags.Base64Var(cmd.Flags(), &deleteModelProviderServiceReq.Etag, "etag", `Optimistic concurrency token from the most recent read.`) cmd.Use = "delete-model-provider-service NAME" cmd.Short = `Delete a model provider service.` @@ -700,10 +751,15 @@ func newDeleteModelProviderService() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteModelProviderServiceReq.Name = args[0] + deleteModelProviderServiceReq.Name = new(args[0]) - err = w.AiGateway.DeleteModelProviderService(ctx, deleteModelProviderServiceReq) + sdkReq, err := aigateway.DeleteModelProviderServiceRequestToSDK(&deleteModelProviderServiceReq) + if err != nil { + return err + } + err = w.AiGateway.DeleteModelProviderService(ctx, *sdkReq) if err != nil { return err } @@ -728,15 +784,14 @@ func newDeleteModelProviderService() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteModelServiceOverrides []func( *cobra.Command, - *catalog.DeleteModelServiceRequest, + *aigateway.DeleteModelServiceRequest, ) func newDeleteModelService() *cobra.Command { cmd := &cobra.Command{} + var deleteModelServiceReq aigateway.DeleteModelServiceRequest - var deleteModelServiceReq catalog.DeleteModelServiceRequest - - cmd.Flags().StringVar(&deleteModelServiceReq.Etag, "etag", deleteModelServiceReq.Etag, `Optimistic concurrency token from the most recent read.`) + flags.Base64Var(cmd.Flags(), &deleteModelServiceReq.Etag, "etag", `Optimistic concurrency token from the most recent read.`) cmd.Use = "delete-model-service NAME" cmd.Short = `Delete a model service.` @@ -767,10 +822,15 @@ func newDeleteModelService() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteModelServiceReq.Name = args[0] + deleteModelServiceReq.Name = new(args[0]) - err = w.AiGateway.DeleteModelService(ctx, deleteModelServiceReq) + sdkReq, err := aigateway.DeleteModelServiceRequestToSDK(&deleteModelServiceReq) + if err != nil { + return err + } + err = w.AiGateway.DeleteModelService(ctx, *sdkReq) if err != nil { return err } @@ -795,15 +855,14 @@ func newDeleteModelService() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteSkillOverrides []func( *cobra.Command, - *catalog.DeleteSkillRequest, + *aigateway.DeleteSkillRequest, ) func newDeleteSkill() *cobra.Command { cmd := &cobra.Command{} + var deleteSkillReq aigateway.DeleteSkillRequest - var deleteSkillReq catalog.DeleteSkillRequest - - cmd.Flags().StringVar(&deleteSkillReq.Etag, "etag", deleteSkillReq.Etag, `Optimistic concurrency token from the most recent read.`) + flags.Base64Var(cmd.Flags(), &deleteSkillReq.Etag, "etag", `Optimistic concurrency token from the most recent read.`) cmd.Use = "delete-skill NAME" cmd.Short = `*Beta* Delete a skill.` @@ -837,10 +896,15 @@ Delete a skill. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteSkillReq.Name = args[0] + deleteSkillReq.Name = new(args[0]) - err = w.AiGateway.DeleteSkill(ctx, deleteSkillReq) + sdkReq, err := aigateway.DeleteSkillRequestToSDK(&deleteSkillReq) + if err != nil { + return err + } + err = w.AiGateway.DeleteSkill(ctx, *sdkReq) if err != nil { return err } @@ -865,13 +929,12 @@ Delete a skill. // Functions can be added from the `init()` function in manually curated files in this directory. var finalizeSkillOverrides []func( *cobra.Command, - *catalog.FinalizeSkillRequest, + *sdkaigateway.FinalizeSkillRequest, ) func newFinalizeSkill() *cobra.Command { cmd := &cobra.Command{} - - var finalizeSkillReq catalog.FinalizeSkillRequest + var finalizeSkillReq sdkaigateway.FinalizeSkillRequest cmd.Use = "finalize-skill NAME" cmd.Short = `*Beta* Finalize a skill.` @@ -909,15 +972,21 @@ Finalize a skill. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - finalizeSkillReq.Name = args[0] + finalizeSkillReq.Name = new(args[0]) - response, err := w.AiGateway.FinalizeSkill(ctx, finalizeSkillReq) + sdkReq := &finalizeSkillReq + response, err := w.AiGateway.FinalizeSkill(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.SkillFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -938,13 +1007,12 @@ Finalize a skill. // Functions can be added from the `init()` function in manually curated files in this directory. var getMcpServiceOverrides []func( *cobra.Command, - *catalog.GetMcpServiceRequest, + *sdkaigateway.GetMcpServiceRequest, ) func newGetMcpService() *cobra.Command { cmd := &cobra.Command{} - - var getMcpServiceReq catalog.GetMcpServiceRequest + var getMcpServiceReq sdkaigateway.GetMcpServiceRequest cmd.Use = "get-mcp-service NAME" cmd.Short = `Get an MCP service.` @@ -974,15 +1042,21 @@ func newGetMcpService() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getMcpServiceReq.Name = args[0] + getMcpServiceReq.Name = new(args[0]) - response, err := w.AiGateway.GetMcpService(ctx, getMcpServiceReq) + sdkReq := &getMcpServiceReq + response, err := w.AiGateway.GetMcpService(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.McpServiceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1003,13 +1077,12 @@ func newGetMcpService() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getMcpServiceUserMappedCredentialOverrides []func( *cobra.Command, - *catalog.GetMcpServiceUserMappedCredentialRequest, + *sdkaigateway.GetMcpServiceUserMappedCredentialRequest, ) func newGetMcpServiceUserMappedCredential() *cobra.Command { cmd := &cobra.Command{} - - var getMcpServiceUserMappedCredentialReq catalog.GetMcpServiceUserMappedCredentialRequest + var getMcpServiceUserMappedCredentialReq sdkaigateway.GetMcpServiceUserMappedCredentialRequest cmd.Use = "get-mcp-service-user-mapped-credential NAME" cmd.Short = `*Beta* Get MCP service user credential status.` @@ -1044,15 +1117,21 @@ Get MCP service user credential status. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getMcpServiceUserMappedCredentialReq.Name = args[0] + getMcpServiceUserMappedCredentialReq.Name = new(args[0]) - response, err := w.AiGateway.GetMcpServiceUserMappedCredential(ctx, getMcpServiceUserMappedCredentialReq) + sdkReq := &getMcpServiceUserMappedCredentialReq + response, err := w.AiGateway.GetMcpServiceUserMappedCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.McpServiceUserMappedCredentialFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1073,13 +1152,12 @@ Get MCP service user credential status. // Functions can be added from the `init()` function in manually curated files in this directory. var getModelProviderServiceOverrides []func( *cobra.Command, - *catalog.GetModelProviderServiceRequest, + *sdkaigateway.GetModelProviderServiceRequest, ) func newGetModelProviderService() *cobra.Command { cmd := &cobra.Command{} - - var getModelProviderServiceReq catalog.GetModelProviderServiceRequest + var getModelProviderServiceReq sdkaigateway.GetModelProviderServiceRequest cmd.Use = "get-model-provider-service NAME" cmd.Short = `Get a model provider service.` @@ -1109,15 +1187,21 @@ func newGetModelProviderService() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getModelProviderServiceReq.Name = args[0] + getModelProviderServiceReq.Name = new(args[0]) - response, err := w.AiGateway.GetModelProviderService(ctx, getModelProviderServiceReq) + sdkReq := &getModelProviderServiceReq + response, err := w.AiGateway.GetModelProviderService(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.ModelProviderServiceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1138,13 +1222,12 @@ func newGetModelProviderService() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getModelServiceOverrides []func( *cobra.Command, - *catalog.GetModelServiceRequest, + *sdkaigateway.GetModelServiceRequest, ) func newGetModelService() *cobra.Command { cmd := &cobra.Command{} - - var getModelServiceReq catalog.GetModelServiceRequest + var getModelServiceReq sdkaigateway.GetModelServiceRequest cmd.Use = "get-model-service NAME" cmd.Short = `Get a model service.` @@ -1174,15 +1257,21 @@ func newGetModelService() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getModelServiceReq.Name = args[0] + getModelServiceReq.Name = new(args[0]) - response, err := w.AiGateway.GetModelService(ctx, getModelServiceReq) + sdkReq := &getModelServiceReq + response, err := w.AiGateway.GetModelService(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.ModelServiceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1203,13 +1292,12 @@ func newGetModelService() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getSkillOverrides []func( *cobra.Command, - *catalog.GetSkillRequest, + *sdkaigateway.GetSkillRequest, ) func newGetSkill() *cobra.Command { cmd := &cobra.Command{} - - var getSkillReq catalog.GetSkillRequest + var getSkillReq sdkaigateway.GetSkillRequest cmd.Use = "get-skill NAME" cmd.Short = `*Beta* Get a skill.` @@ -1241,15 +1329,21 @@ Get a skill. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSkillReq.Name = args[0] + getSkillReq.Name = new(args[0]) - response, err := w.AiGateway.GetSkill(ctx, getSkillReq) + sdkReq := &getSkillReq + response, err := w.AiGateway.GetSkill(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.SkillFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1270,27 +1364,27 @@ Get a skill. // Functions can be added from the `init()` function in manually curated files in this directory. var listMcpServicesOverrides []func( *cobra.Command, - *catalog.ListMcpServicesRequest, + *aigateway.ListMcpServicesRequest, ) func newListMcpServices() *cobra.Command { cmd := &cobra.Command{} + var listMcpServicesReq aigateway.ListMcpServicesRequest - var listMcpServicesReq catalog.ListMcpServicesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listMcpServicesLimit int - cmd.Flags().IntVar(&listMcpServicesReq.PageSize, "page-size", listMcpServicesReq.PageSize, `Maximum number of MCP services to return.`) - cmd.Flags().StringVar(&listMcpServicesReq.Parent, "parent", listMcpServicesReq.Parent, `Parent schema to list within, in the form schemas/{catalog}.{schema}.`) - cmd.Flags().Var(&listMcpServicesReq.View, "view", `Fields to return for each service. Supported values: [BASIC, FULL]`) + flags.IntPtrVar(cmd.Flags(), &listMcpServicesReq.PageSize, "page-size", `Maximum number of MCP services to return.`) + flags.StringPtrVar(cmd.Flags(), &listMcpServicesReq.Parent, "parent", `Parent schema to list within, in the form schemas/{catalog}.{schema}.`) + flags.EnumVar(cmd.Flags(), &listMcpServicesReq.View, "view", `Fields to return for each service. Supported values: [BASIC, FULL]`, "ListMcpServicesRequestView", "BASIC", "FULL") // Limit flag for total result capping. cmd.Flags().IntVar(&listMcpServicesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listMcpServicesReq.PageToken, "page-token", listMcpServicesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listMcpServicesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-mcp-services" @@ -1318,16 +1412,20 @@ func newListMcpServices() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.AiGateway.ListMcpServices(ctx, listMcpServicesReq) + sdkReq, err := aigateway.ListMcpServicesRequestToSDK(&listMcpServicesReq) + if err != nil { + return err + } if listMcpServicesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listMcpServicesLimit) } if listMcpServicesLimit > 0 { ctx = cmdio.WithLimit(ctx, listMcpServicesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AiGateway.ListMcpServicesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, aigateway.McpServiceFromSDK)) } // Disable completions since they are not applicable. @@ -1348,27 +1446,27 @@ func newListMcpServices() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listModelProviderServicesOverrides []func( *cobra.Command, - *catalog.ListModelProviderServicesRequest, + *aigateway.ListModelProviderServicesRequest, ) func newListModelProviderServices() *cobra.Command { cmd := &cobra.Command{} + var listModelProviderServicesReq aigateway.ListModelProviderServicesRequest - var listModelProviderServicesReq catalog.ListModelProviderServicesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listModelProviderServicesLimit int - cmd.Flags().IntVar(&listModelProviderServicesReq.PageSize, "page-size", listModelProviderServicesReq.PageSize, `Maximum number of provider services to return.`) - cmd.Flags().StringVar(&listModelProviderServicesReq.Parent, "parent", listModelProviderServicesReq.Parent, `Parent schema to list within, in the form schemas/{catalog}.{schema}.`) - cmd.Flags().Var(&listModelProviderServicesReq.View, "view", `Fields to return for each service. Supported values: [BASIC, FULL]`) + flags.IntPtrVar(cmd.Flags(), &listModelProviderServicesReq.PageSize, "page-size", `Maximum number of provider services to return.`) + flags.StringPtrVar(cmd.Flags(), &listModelProviderServicesReq.Parent, "parent", `Parent schema to list within, in the form schemas/{catalog}.{schema}.`) + flags.EnumVar(cmd.Flags(), &listModelProviderServicesReq.View, "view", `Fields to return for each service. Supported values: [BASIC, FULL]`, "ListModelProviderServicesRequestView", "BASIC", "FULL") // Limit flag for total result capping. cmd.Flags().IntVar(&listModelProviderServicesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listModelProviderServicesReq.PageToken, "page-token", listModelProviderServicesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listModelProviderServicesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-model-provider-services" @@ -1396,16 +1494,20 @@ func newListModelProviderServices() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.AiGateway.ListModelProviderServices(ctx, listModelProviderServicesReq) + sdkReq, err := aigateway.ListModelProviderServicesRequestToSDK(&listModelProviderServicesReq) + if err != nil { + return err + } if listModelProviderServicesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listModelProviderServicesLimit) } if listModelProviderServicesLimit > 0 { ctx = cmdio.WithLimit(ctx, listModelProviderServicesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AiGateway.ListModelProviderServicesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, aigateway.ModelProviderServiceFromSDK)) } // Disable completions since they are not applicable. @@ -1426,27 +1528,27 @@ func newListModelProviderServices() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listModelServicesOverrides []func( *cobra.Command, - *catalog.ListModelServicesRequest, + *aigateway.ListModelServicesRequest, ) func newListModelServices() *cobra.Command { cmd := &cobra.Command{} + var listModelServicesReq aigateway.ListModelServicesRequest - var listModelServicesReq catalog.ListModelServicesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listModelServicesLimit int - cmd.Flags().IntVar(&listModelServicesReq.PageSize, "page-size", listModelServicesReq.PageSize, `Maximum number of model services to return.`) - cmd.Flags().StringVar(&listModelServicesReq.Parent, "parent", listModelServicesReq.Parent, `Parent schema to list within, in the form schemas/{catalog}.{schema}.`) - cmd.Flags().Var(&listModelServicesReq.View, "view", `Fields to return for each service. Supported values: [BASIC, FULL]`) + flags.IntPtrVar(cmd.Flags(), &listModelServicesReq.PageSize, "page-size", `Maximum number of model services to return.`) + flags.StringPtrVar(cmd.Flags(), &listModelServicesReq.Parent, "parent", `Parent schema to list within, in the form schemas/{catalog}.{schema}.`) + flags.EnumVar(cmd.Flags(), &listModelServicesReq.View, "view", `Fields to return for each service. Supported values: [BASIC, FULL]`, "ListModelServicesRequestView", "BASIC", "FULL") // Limit flag for total result capping. cmd.Flags().IntVar(&listModelServicesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listModelServicesReq.PageToken, "page-token", listModelServicesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listModelServicesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-model-services" @@ -1474,16 +1576,20 @@ func newListModelServices() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.AiGateway.ListModelServices(ctx, listModelServicesReq) + sdkReq, err := aigateway.ListModelServicesRequestToSDK(&listModelServicesReq) + if err != nil { + return err + } if listModelServicesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listModelServicesLimit) } if listModelServicesLimit > 0 { ctx = cmdio.WithLimit(ctx, listModelServicesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AiGateway.ListModelServicesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, aigateway.ModelServiceFromSDK)) } // Disable completions since they are not applicable. @@ -1504,25 +1610,25 @@ func newListModelServices() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listSkillsOverrides []func( *cobra.Command, - *catalog.ListSkillsRequest, + *aigateway.ListSkillsRequest, ) func newListSkills() *cobra.Command { cmd := &cobra.Command{} + var listSkillsReq aigateway.ListSkillsRequest - var listSkillsReq catalog.ListSkillsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSkillsLimit int - cmd.Flags().IntVar(&listSkillsReq.PageSize, "page-size", listSkillsReq.PageSize, `Maximum number of skills to return.`) + flags.IntPtrVar(cmd.Flags(), &listSkillsReq.PageSize, "page-size", `Maximum number of skills to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listSkillsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSkillsReq.PageToken, "page-token", listSkillsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSkillsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-skills PARENT" @@ -1559,18 +1665,22 @@ List skills. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listSkillsReq.Parent = args[0] + listSkillsReq.Parent = new(args[0]) - response := w.AiGateway.ListSkills(ctx, listSkillsReq) + sdkReq, err := aigateway.ListSkillsRequestToSDK(&listSkillsReq) + if err != nil { + return err + } if listSkillsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSkillsLimit) } if listSkillsLimit > 0 { ctx = cmdio.WithLimit(ctx, listSkillsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AiGateway.ListSkillsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, aigateway.SkillFromSDK)) } // Disable completions since they are not applicable. @@ -1591,22 +1701,22 @@ List skills. // Functions can be added from the `init()` function in manually curated files in this directory. var updateMcpServiceOverrides []func( *cobra.Command, - *catalog.UpdateMcpServiceRequest, + *aigateway.UpdateMcpServiceRequest, ) func newUpdateMcpService() *cobra.Command { cmd := &cobra.Command{} + var updateMcpServiceReq aigateway.UpdateMcpServiceRequest + updateMcpServiceReq.McpService = &aigateway.McpService{} - var updateMcpServiceReq catalog.UpdateMcpServiceRequest - updateMcpServiceReq.McpService = catalog.McpService{} var updateMcpServiceJson flags.JsonFlag cmd.Flags().Var(&updateMcpServiceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateMcpServiceReq.Etag, "etag", updateMcpServiceReq.Etag, `Optimistic concurrency token from the most recent read.`) - cmd.Flags().StringVar(&updateMcpServiceReq.McpService.Comment, "comment", updateMcpServiceReq.McpService.Comment, `User-provided description.`) + flags.Base64Var(cmd.Flags(), &updateMcpServiceReq.Etag, "etag", `Optimistic concurrency token from the most recent read.`) + flags.StringPtrVar(cmd.Flags(), &updateMcpServiceReq.McpService.Comment, "comment", `User-provided description.`) // TODO: complex arg: config - cmd.Flags().StringVar(&updateMcpServiceReq.McpService.Name, "name", updateMcpServiceReq.McpService.Name, `Resource name of the MCP service.`) + flags.StringPtrVar(cmd.Flags(), &updateMcpServiceReq.McpService.Name, "name", `Resource name of the MCP service.`) cmd.Use = "update-mcp-service NAME UPDATE_MASK" cmd.Short = `Update an MCP service.` @@ -1645,6 +1755,7 @@ func newUpdateMcpService() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateMcpServiceJson.Unmarshal(&updateMcpServiceReq.McpService) @@ -1658,18 +1769,25 @@ func newUpdateMcpService() *cobra.Command { } } } - updateMcpServiceReq.Name = args[0] + updateMcpServiceReq.McpService.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateMcpServiceReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateMcpServiceReq.UpdateMask = new(args[1]) } - response, err := w.AiGateway.UpdateMcpService(ctx, updateMcpServiceReq) + sdkReq, err := aigateway.UpdateMcpServiceRequestToSDK(&updateMcpServiceReq) + if err != nil { + return err + } + response, err := w.AiGateway.UpdateMcpService(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.McpServiceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1690,22 +1808,22 @@ func newUpdateMcpService() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateModelProviderServiceOverrides []func( *cobra.Command, - *catalog.UpdateModelProviderServiceRequest, + *aigateway.UpdateModelProviderServiceRequest, ) func newUpdateModelProviderService() *cobra.Command { cmd := &cobra.Command{} + var updateModelProviderServiceReq aigateway.UpdateModelProviderServiceRequest + updateModelProviderServiceReq.ModelProviderService = &aigateway.ModelProviderService{} - var updateModelProviderServiceReq catalog.UpdateModelProviderServiceRequest - updateModelProviderServiceReq.ModelProviderService = catalog.ModelProviderService{} var updateModelProviderServiceJson flags.JsonFlag cmd.Flags().Var(&updateModelProviderServiceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateModelProviderServiceReq.Etag, "etag", updateModelProviderServiceReq.Etag, `Optimistic concurrency token from the most recent read.`) - cmd.Flags().StringVar(&updateModelProviderServiceReq.ModelProviderService.Comment, "comment", updateModelProviderServiceReq.ModelProviderService.Comment, `User-provided description.`) + flags.Base64Var(cmd.Flags(), &updateModelProviderServiceReq.Etag, "etag", `Optimistic concurrency token from the most recent read.`) + flags.StringPtrVar(cmd.Flags(), &updateModelProviderServiceReq.ModelProviderService.Comment, "comment", `User-provided description.`) // TODO: complex arg: config - cmd.Flags().StringVar(&updateModelProviderServiceReq.ModelProviderService.Name, "name", updateModelProviderServiceReq.ModelProviderService.Name, `Resource name of the provider service.`) + flags.StringPtrVar(cmd.Flags(), &updateModelProviderServiceReq.ModelProviderService.Name, "name", `Resource name of the provider service.`) cmd.Use = "update-model-provider-service NAME UPDATE_MASK" cmd.Short = `Update a model provider service.` @@ -1759,6 +1877,7 @@ func newUpdateModelProviderService() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateModelProviderServiceJson.Unmarshal(&updateModelProviderServiceReq.ModelProviderService) @@ -1772,18 +1891,25 @@ func newUpdateModelProviderService() *cobra.Command { } } } - updateModelProviderServiceReq.Name = args[0] + updateModelProviderServiceReq.ModelProviderService.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateModelProviderServiceReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateModelProviderServiceReq.UpdateMask = new(args[1]) } - response, err := w.AiGateway.UpdateModelProviderService(ctx, updateModelProviderServiceReq) + sdkReq, err := aigateway.UpdateModelProviderServiceRequestToSDK(&updateModelProviderServiceReq) + if err != nil { + return err + } + response, err := w.AiGateway.UpdateModelProviderService(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.ModelProviderServiceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1804,22 +1930,22 @@ func newUpdateModelProviderService() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateModelServiceOverrides []func( *cobra.Command, - *catalog.UpdateModelServiceRequest, + *aigateway.UpdateModelServiceRequest, ) func newUpdateModelService() *cobra.Command { cmd := &cobra.Command{} + var updateModelServiceReq aigateway.UpdateModelServiceRequest + updateModelServiceReq.ModelService = &aigateway.ModelService{} - var updateModelServiceReq catalog.UpdateModelServiceRequest - updateModelServiceReq.ModelService = catalog.ModelService{} var updateModelServiceJson flags.JsonFlag cmd.Flags().Var(&updateModelServiceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateModelServiceReq.Etag, "etag", updateModelServiceReq.Etag, `Optimistic concurrency token from the most recent read.`) - cmd.Flags().StringVar(&updateModelServiceReq.ModelService.Comment, "comment", updateModelServiceReq.ModelService.Comment, `User-provided description.`) + flags.Base64Var(cmd.Flags(), &updateModelServiceReq.Etag, "etag", `Optimistic concurrency token from the most recent read.`) + flags.StringPtrVar(cmd.Flags(), &updateModelServiceReq.ModelService.Comment, "comment", `User-provided description.`) // TODO: complex arg: config - cmd.Flags().StringVar(&updateModelServiceReq.ModelService.Name, "name", updateModelServiceReq.ModelService.Name, `Resource name of the model service.`) + flags.StringPtrVar(cmd.Flags(), &updateModelServiceReq.ModelService.Name, "name", `Resource name of the model service.`) // TODO: array: supported_api_types cmd.Use = "update-model-service NAME UPDATE_MASK" @@ -1866,6 +1992,7 @@ func newUpdateModelService() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateModelServiceJson.Unmarshal(&updateModelServiceReq.ModelService) @@ -1879,18 +2006,25 @@ func newUpdateModelService() *cobra.Command { } } } - updateModelServiceReq.Name = args[0] + updateModelServiceReq.ModelService.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateModelServiceReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateModelServiceReq.UpdateMask = new(args[1]) } - response, err := w.AiGateway.UpdateModelService(ctx, updateModelServiceReq) + sdkReq, err := aigateway.UpdateModelServiceRequestToSDK(&updateModelServiceReq) + if err != nil { + return err + } + response, err := w.AiGateway.UpdateModelService(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.ModelServiceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1911,21 +2045,21 @@ func newUpdateModelService() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateSkillOverrides []func( *cobra.Command, - *catalog.UpdateSkillRequest, + *aigateway.UpdateSkillRequest, ) func newUpdateSkill() *cobra.Command { cmd := &cobra.Command{} + var updateSkillReq aigateway.UpdateSkillRequest + updateSkillReq.Skill = &aigateway.Skill{} - var updateSkillReq catalog.UpdateSkillRequest - updateSkillReq.Skill = catalog.Skill{} var updateSkillJson flags.JsonFlag cmd.Flags().Var(&updateSkillJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateSkillReq.Etag, "etag", updateSkillReq.Etag, `Optimistic concurrency token from the most recent read.`) - cmd.Flags().StringVar(&updateSkillReq.Skill.Comment, "comment", updateSkillReq.Skill.Comment, `User-provided comment for the skill.`) - cmd.Flags().StringVar(&updateSkillReq.Skill.Name, "name", updateSkillReq.Skill.Name, `Resource name of the skill.`) + flags.Base64Var(cmd.Flags(), &updateSkillReq.Etag, "etag", `Optimistic concurrency token from the most recent read.`) + flags.StringPtrVar(cmd.Flags(), &updateSkillReq.Skill.Comment, "comment", `User-provided comment for the skill.`) + flags.StringPtrVar(cmd.Flags(), &updateSkillReq.Skill.Name, "name", `Resource name of the skill.`) cmd.Use = "update-skill NAME UPDATE_MASK" cmd.Short = `*Beta* Update a skill.` @@ -1962,6 +2096,7 @@ Update a skill. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateSkillJson.Unmarshal(&updateSkillReq.Skill) @@ -1975,18 +2110,25 @@ Update a skill. } } } - updateSkillReq.Name = args[0] + updateSkillReq.Skill.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateSkillReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateSkillReq.UpdateMask = new(args[1]) } - response, err := w.AiGateway.UpdateSkill(ctx, updateSkillReq) + sdkReq, err := aigateway.UpdateSkillRequestToSDK(&updateSkillReq) + if err != nil { + return err + } + response, err := w.AiGateway.UpdateSkill(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aigateway.SkillFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/ai-search/ai-search.go b/cmd/workspace/ai-search/ai-search.go index 82e664eb3e2..e512a1a7ad2 100644 --- a/cmd/workspace/ai-search/ai-search.go +++ b/cmd/workspace/ai-search/ai-search.go @@ -5,15 +5,16 @@ package ai_search import ( "errors" "fmt" - "strings" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "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/aisearch" "github.com/spf13/cobra" + + aisearch "github.com/databricks/cli/libs/sdktypes/aisearch/v1" + sdkaisearch "github.com/databricks/sdk-go/aisearch/v1" ) // Slice with functions to override default command behavior. @@ -72,23 +73,23 @@ var createEndpointOverrides []func( func newCreateEndpoint() *cobra.Command { cmd := &cobra.Command{} - var createEndpointReq aisearch.CreateEndpointRequest - createEndpointReq.Endpoint = aisearch.Endpoint{} + createEndpointReq.Endpoint = &aisearch.Endpoint{} + var createEndpointJson flags.JsonFlag cmd.Flags().Var(&createEndpointJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createEndpointReq.EndpointId, "endpoint-id", createEndpointReq.EndpointId, `The user-supplied short name for the Endpoint, per AIP-133.`) - cmd.Flags().StringVar(&createEndpointReq.Endpoint.BudgetPolicyId, "budget-policy-id", createEndpointReq.Endpoint.BudgetPolicyId, `The user-selected budget policy id for the endpoint.`) + flags.StringPtrVar(cmd.Flags(), &createEndpointReq.EndpointId, "endpoint-id", `The user-supplied short name for the Endpoint, per AIP-133.`) + flags.StringPtrVar(cmd.Flags(), &createEndpointReq.Endpoint.BudgetPolicyId, "budget-policy-id", `The user-selected budget policy id for the endpoint.`) // TODO: array: custom_tags // TODO: complex arg: endpoint_status - cmd.Flags().StringVar(&createEndpointReq.Endpoint.Name, "name", createEndpointReq.Endpoint.Name, `Name of the AI Search endpoint.`) - cmd.Flags().IntVar(&createEndpointReq.Endpoint.ReplicaCount, "replica-count", createEndpointReq.Endpoint.ReplicaCount, `The client-supplied desired number of replicas for the endpoint, applied at create/update time.`) + flags.StringPtrVar(cmd.Flags(), &createEndpointReq.Endpoint.Name, "name", `Name of the AI Search endpoint.`) + flags.IntPtrVar(cmd.Flags(), &createEndpointReq.Endpoint.ReplicaCount, "replica-count", `The client-supplied desired number of replicas for the endpoint, applied at create/update time.`) // TODO: complex arg: scaling_info - cmd.Flags().IntVar(&createEndpointReq.Endpoint.TargetQps, "target-qps", createEndpointReq.Endpoint.TargetQps, `Target QPS for the endpoint.`) + flags.IntPtrVar(cmd.Flags(), &createEndpointReq.Endpoint.TargetQps, "target-qps", `Target QPS for the endpoint.`) // TODO: complex arg: throughput_info - cmd.Flags().StringVar(&createEndpointReq.Endpoint.UsagePolicyId, "usage-policy-id", createEndpointReq.Endpoint.UsagePolicyId, `The usage policy id applied to the endpoint.`) + flags.StringPtrVar(cmd.Flags(), &createEndpointReq.Endpoint.UsagePolicyId, "usage-policy-id", `The usage policy id applied to the endpoint.`) cmd.Use = "create-endpoint PARENT ENDPOINT_TYPE" cmd.Short = `*Public Preview* Create an AI Search endpoint.` @@ -124,6 +125,7 @@ Create an AI Search endpoint. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createEndpointJson.Unmarshal(&createEndpointReq.Endpoint) @@ -137,21 +139,25 @@ Create an AI Search endpoint. } } } - createEndpointReq.Parent = args[0] + createEndpointReq.Parent = new(args[0]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createEndpointReq.Endpoint.EndpointType) - if err != nil { - return fmt.Errorf("invalid ENDPOINT_TYPE: %s", args[1]) - } - + createEndpointReq.Endpoint.EndpointType = aisearch.EndpointType(args[1]) } - response, err := w.AiSearch.CreateEndpoint(ctx, createEndpointReq) + sdkReq, err := aisearch.CreateEndpointRequestToSDK(&createEndpointReq) + if err != nil { + return err + } + response, err := w.AiSearch.CreateEndpoint(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aisearch.EndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -177,18 +183,18 @@ var createIndexOverrides []func( func newCreateIndex() *cobra.Command { cmd := &cobra.Command{} - var createIndexReq aisearch.CreateIndexRequest - createIndexReq.Index = aisearch.Index{} + createIndexReq.Index = &aisearch.Index{} + var createIndexJson flags.JsonFlag cmd.Flags().Var(&createIndexJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createIndexReq.IndexId, "index-id", createIndexReq.IndexId, `The user-supplied Unity Catalog table name for the Index, per AIP-133.`) + flags.StringPtrVar(cmd.Flags(), &createIndexReq.IndexId, "index-id", `The user-supplied Unity Catalog table name for the Index, per AIP-133.`) // TODO: complex arg: delta_sync_index_spec // TODO: complex arg: direct_access_index_spec - cmd.Flags().Var(&createIndexReq.Index.IndexSubtype, "index-subtype", `The subtype of the index. Supported values: [FULL_TEXT, HYBRID, VECTOR]`) - cmd.Flags().StringVar(&createIndexReq.Index.Name, "name", createIndexReq.Index.Name, `Name of the AI Search index.`) + flags.EnumVar(cmd.Flags(), &createIndexReq.Index.IndexSubtype, "index-subtype", `The subtype of the index. Supported values: [FULL_TEXT, HYBRID, VECTOR]`, "IndexSubtype", "FULL_TEXT", "HYBRID", "VECTOR") + flags.StringPtrVar(cmd.Flags(), &createIndexReq.Index.Name, "name", `Name of the AI Search index.`) // TODO: complex arg: status cmd.Use = "create-index PARENT PRIMARY_KEY INDEX_TYPE" @@ -226,6 +232,7 @@ Create an AI Search index. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createIndexJson.Unmarshal(&createIndexReq.Index) @@ -239,24 +246,28 @@ Create an AI Search index. } } } - createIndexReq.Parent = args[0] + createIndexReq.Parent = new(args[0]) if !cmd.Flags().Changed("json") { - createIndexReq.Index.PrimaryKey = args[1] + createIndexReq.Index.PrimaryKey = new(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &createIndexReq.Index.IndexType) - if err != nil { - return fmt.Errorf("invalid INDEX_TYPE: %s", args[2]) - } - + createIndexReq.Index.IndexType = aisearch.IndexType(args[2]) } - response, err := w.AiSearch.CreateIndex(ctx, createIndexReq) + sdkReq, err := aisearch.CreateIndexRequestToSDK(&createIndexReq) + if err != nil { + return err + } + response, err := w.AiSearch.CreateIndex(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aisearch.IndexFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -277,13 +288,12 @@ Create an AI Search index. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteEndpointOverrides []func( *cobra.Command, - *aisearch.DeleteEndpointRequest, + *sdkaisearch.DeleteEndpointRequest, ) func newDeleteEndpoint() *cobra.Command { cmd := &cobra.Command{} - - var deleteEndpointReq aisearch.DeleteEndpointRequest + var deleteEndpointReq sdkaisearch.DeleteEndpointRequest cmd.Use = "delete-endpoint NAME" cmd.Short = `*Public Preview* Delete an AI Search endpoint.` @@ -308,10 +318,12 @@ Delete an AI Search endpoint. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteEndpointReq.Name = args[0] + deleteEndpointReq.Name = new(args[0]) - err = w.AiSearch.DeleteEndpoint(ctx, deleteEndpointReq) + sdkReq := &deleteEndpointReq + err = w.AiSearch.DeleteEndpoint(ctx, *sdkReq) if err != nil { return err } @@ -336,13 +348,12 @@ Delete an AI Search endpoint. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteIndexOverrides []func( *cobra.Command, - *aisearch.DeleteIndexRequest, + *sdkaisearch.DeleteIndexRequest, ) func newDeleteIndex() *cobra.Command { cmd := &cobra.Command{} - - var deleteIndexReq aisearch.DeleteIndexRequest + var deleteIndexReq sdkaisearch.DeleteIndexRequest cmd.Use = "delete-index NAME" cmd.Short = `*Public Preview* Delete an AI Search index.` @@ -367,10 +378,12 @@ Delete an AI Search index. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteIndexReq.Name = args[0] + deleteIndexReq.Name = new(args[0]) - err = w.AiSearch.DeleteIndex(ctx, deleteIndexReq) + sdkReq := &deleteIndexReq + err = w.AiSearch.DeleteIndex(ctx, *sdkReq) if err != nil { return err } @@ -395,13 +408,12 @@ Delete an AI Search index. // Functions can be added from the `init()` function in manually curated files in this directory. var getEndpointOverrides []func( *cobra.Command, - *aisearch.GetEndpointRequest, + *sdkaisearch.GetEndpointRequest, ) func newGetEndpoint() *cobra.Command { cmd := &cobra.Command{} - - var getEndpointReq aisearch.GetEndpointRequest + var getEndpointReq sdkaisearch.GetEndpointRequest cmd.Use = "get-endpoint NAME" cmd.Short = `*Public Preview* Get an AI Search endpoint.` @@ -428,15 +440,21 @@ Get an AI Search endpoint. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getEndpointReq.Name = args[0] + getEndpointReq.Name = new(args[0]) - response, err := w.AiSearch.GetEndpoint(ctx, getEndpointReq) + sdkReq := &getEndpointReq + response, err := w.AiSearch.GetEndpoint(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aisearch.EndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -457,13 +475,12 @@ Get an AI Search endpoint. // Functions can be added from the `init()` function in manually curated files in this directory. var getIndexOverrides []func( *cobra.Command, - *aisearch.GetIndexRequest, + *sdkaisearch.GetIndexRequest, ) func newGetIndex() *cobra.Command { cmd := &cobra.Command{} - - var getIndexReq aisearch.GetIndexRequest + var getIndexReq sdkaisearch.GetIndexRequest cmd.Use = "get-index NAME" cmd.Short = `*Public Preview* Get an AI Search index.` @@ -490,15 +507,21 @@ Get an AI Search index. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getIndexReq.Name = args[0] + getIndexReq.Name = new(args[0]) - response, err := w.AiSearch.GetIndex(ctx, getIndexReq) + sdkReq := &getIndexReq + response, err := w.AiSearch.GetIndex(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aisearch.IndexFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -524,20 +547,20 @@ var listEndpointsOverrides []func( func newListEndpoints() *cobra.Command { cmd := &cobra.Command{} - var listEndpointsReq aisearch.ListEndpointsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listEndpointsLimit int - cmd.Flags().IntVar(&listEndpointsReq.PageSize, "page-size", listEndpointsReq.PageSize, `Best-effort upper bound on the number of results to return.`) + flags.IntPtrVar(cmd.Flags(), &listEndpointsReq.PageSize, "page-size", `Best-effort upper bound on the number of results to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listEndpointsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listEndpointsReq.PageToken, "page-token", listEndpointsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listEndpointsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-endpoints PARENT" @@ -565,18 +588,22 @@ List AI Search endpoints. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listEndpointsReq.Parent = args[0] + listEndpointsReq.Parent = new(args[0]) - response := w.AiSearch.ListEndpoints(ctx, listEndpointsReq) + sdkReq, err := aisearch.ListEndpointsRequestToSDK(&listEndpointsReq) + if err != nil { + return err + } if listEndpointsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listEndpointsLimit) } if listEndpointsLimit > 0 { ctx = cmdio.WithLimit(ctx, listEndpointsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AiSearch.ListEndpointsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, aisearch.EndpointFromSDK)) } // Disable completions since they are not applicable. @@ -602,20 +629,20 @@ var listIndexesOverrides []func( func newListIndexes() *cobra.Command { cmd := &cobra.Command{} - var listIndexesReq aisearch.ListIndexesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listIndexesLimit int - cmd.Flags().IntVar(&listIndexesReq.PageSize, "page-size", listIndexesReq.PageSize, `Best-effort upper bound on the number of results to return.`) + flags.IntPtrVar(cmd.Flags(), &listIndexesReq.PageSize, "page-size", `Best-effort upper bound on the number of results to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listIndexesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listIndexesReq.PageToken, "page-token", listIndexesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listIndexesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-indexes PARENT" @@ -643,18 +670,22 @@ List AI Search indexes. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listIndexesReq.Parent = args[0] + listIndexesReq.Parent = new(args[0]) - response := w.AiSearch.ListIndexes(ctx, listIndexesReq) + sdkReq, err := aisearch.ListIndexesRequestToSDK(&listIndexesReq) + if err != nil { + return err + } if listIndexesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listIndexesLimit) } if listIndexesLimit > 0 { ctx = cmdio.WithLimit(ctx, listIndexesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AiSearch.ListIndexesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, aisearch.IndexFromSDK)) } // Disable completions since they are not applicable. @@ -680,22 +711,22 @@ var queryIndexOverrides []func( func newQueryIndex() *cobra.Command { cmd := &cobra.Command{} - var queryIndexReq aisearch.QueryIndexRequest + var queryIndexJson flags.JsonFlag cmd.Flags().Var(&queryIndexJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: columns_to_rerank // TODO: array: facets - cmd.Flags().StringVar(&queryIndexReq.FiltersJson, "filters-json", queryIndexReq.FiltersJson, `JSON string describing query filters (e.g.`) - cmd.Flags().IntVar(&queryIndexReq.MaxResults, "max-results", queryIndexReq.MaxResults, `Maximum number of results to return (the legacy num_results).`) + flags.StringPtrVar(cmd.Flags(), &queryIndexReq.FiltersJson, "filters-json", `JSON string describing query filters (e.g.`) + flags.IntPtrVar(cmd.Flags(), &queryIndexReq.MaxResults, "max-results", `Maximum number of results to return (the legacy num_results).`) // TODO: array: query_columns - cmd.Flags().StringVar(&queryIndexReq.QueryText, "query-text", queryIndexReq.QueryText, `Query text.`) - cmd.Flags().StringVar(&queryIndexReq.QueryType, "query-type", queryIndexReq.QueryType, `Query type: ANN, HYBRID, or FULL_TEXT.`) + flags.StringPtrVar(cmd.Flags(), &queryIndexReq.QueryText, "query-text", `Query text.`) + flags.StringPtrVar(cmd.Flags(), &queryIndexReq.QueryType, "query-type", `Query type: ANN, HYBRID, or FULL_TEXT.`) // TODO: array: query_vector // TODO: complex arg: reranker - cmd.Flags().Float64Var(&queryIndexReq.ScoreThreshold, "score-threshold", queryIndexReq.ScoreThreshold, `Score threshold for the approximate nearest-neighbor search.`) + flags.Float32PtrVar(cmd.Flags(), &queryIndexReq.ScoreThreshold, "score-threshold", `Score threshold for the approximate nearest-neighbor search.`) // TODO: array: sort_columns cmd.Use = "query-index NAME" @@ -724,6 +755,7 @@ Query an AI Search index. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := queryIndexJson.Unmarshal(&queryIndexReq) @@ -739,14 +771,22 @@ Query an AI Search index. } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - queryIndexReq.Name = args[0] + queryIndexReq.Name = new(args[0]) - response, err := w.AiSearch.QueryIndex(ctx, queryIndexReq) + sdkReq, err := aisearch.QueryIndexRequestToSDK(&queryIndexReq) + if err != nil { + return err + } + response, err := w.AiSearch.QueryIndex(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aisearch.QueryIndexResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -772,8 +812,8 @@ var removeDataOverrides []func( func newRemoveData() *cobra.Command { cmd := &cobra.Command{} - var removeDataReq aisearch.RemoveDataRequest + var removeDataJson flags.JsonFlag cmd.Flags().Var(&removeDataJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -803,6 +843,7 @@ Remove data from an AI Search index. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := removeDataJson.Unmarshal(&removeDataReq) @@ -818,14 +859,22 @@ Remove data from an AI Search index. } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - removeDataReq.Name = args[0] + removeDataReq.Name = new(args[0]) - response, err := w.AiSearch.RemoveData(ctx, removeDataReq) + sdkReq, err := aisearch.RemoveDataRequestToSDK(&removeDataReq) + if err != nil { + return err + } + response, err := w.AiSearch.RemoveData(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aisearch.RemoveDataResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -851,14 +900,14 @@ var scanIndexOverrides []func( func newScanIndex() *cobra.Command { cmd := &cobra.Command{} - var scanIndexReq aisearch.ScanIndexRequest + var scanIndexJson flags.JsonFlag cmd.Flags().Var(&scanIndexJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().IntVar(&scanIndexReq.PageSize, "page-size", scanIndexReq.PageSize, `Maximum number of rows to return in this page.`) - cmd.Flags().StringVar(&scanIndexReq.PageToken, "page-token", scanIndexReq.PageToken, `Page token from a previous response; if unset, scanning starts from the beginning.`) + flags.IntPtrVar(cmd.Flags(), &scanIndexReq.PageSize, "page-size", `Maximum number of rows to return in this page.`) + flags.StringPtrVar(cmd.Flags(), &scanIndexReq.PageToken, "page-token", `Page token from a previous response; if unset, scanning starts from the beginning.`) cmd.Use = "scan-index NAME" cmd.Short = `*Public Preview* Scan an AI Search index.` @@ -885,6 +934,7 @@ Scan an AI Search index. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := scanIndexJson.Unmarshal(&scanIndexReq) @@ -898,14 +948,22 @@ Scan an AI Search index. } } } - scanIndexReq.Name = args[0] + scanIndexReq.Name = new(args[0]) - response, err := w.AiSearch.ScanIndex(ctx, scanIndexReq) + sdkReq, err := aisearch.ScanIndexRequestToSDK(&scanIndexReq) + if err != nil { + return err + } + response, err := w.AiSearch.ScanIndex(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aisearch.ScanIndexResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -931,7 +989,6 @@ var syncIndexOverrides []func( func newSyncIndex() *cobra.Command { cmd := &cobra.Command{} - var syncIndexReq aisearch.SyncIndexRequest cmd.Use = "sync-index NAME" @@ -962,15 +1019,21 @@ Synchronize an AI Search index. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - syncIndexReq.Name = args[0] + syncIndexReq.Name = new(args[0]) - response, err := w.AiSearch.SyncIndex(ctx, syncIndexReq) + sdkReq, err := aisearch.SyncIndexRequestToSDK(&syncIndexReq) + if err != nil { + return err + } + response, err := w.AiSearch.SyncIndex(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. @@ -996,22 +1059,22 @@ var updateEndpointOverrides []func( func newUpdateEndpoint() *cobra.Command { cmd := &cobra.Command{} - var updateEndpointReq aisearch.UpdateEndpointRequest - updateEndpointReq.Endpoint = aisearch.Endpoint{} + updateEndpointReq.Endpoint = &aisearch.Endpoint{} + var updateEndpointJson flags.JsonFlag cmd.Flags().Var(&updateEndpointJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateEndpointReq.Endpoint.BudgetPolicyId, "budget-policy-id", updateEndpointReq.Endpoint.BudgetPolicyId, `The user-selected budget policy id for the endpoint.`) + flags.StringPtrVar(cmd.Flags(), &updateEndpointReq.Endpoint.BudgetPolicyId, "budget-policy-id", `The user-selected budget policy id for the endpoint.`) // TODO: array: custom_tags // TODO: complex arg: endpoint_status - cmd.Flags().StringVar(&updateEndpointReq.Endpoint.Name, "name", updateEndpointReq.Endpoint.Name, `Name of the AI Search endpoint.`) - cmd.Flags().IntVar(&updateEndpointReq.Endpoint.ReplicaCount, "replica-count", updateEndpointReq.Endpoint.ReplicaCount, `The client-supplied desired number of replicas for the endpoint, applied at create/update time.`) + flags.StringPtrVar(cmd.Flags(), &updateEndpointReq.Endpoint.Name, "name", `Name of the AI Search endpoint.`) + flags.IntPtrVar(cmd.Flags(), &updateEndpointReq.Endpoint.ReplicaCount, "replica-count", `The client-supplied desired number of replicas for the endpoint, applied at create/update time.`) // TODO: complex arg: scaling_info - cmd.Flags().IntVar(&updateEndpointReq.Endpoint.TargetQps, "target-qps", updateEndpointReq.Endpoint.TargetQps, `Target QPS for the endpoint.`) + flags.IntPtrVar(cmd.Flags(), &updateEndpointReq.Endpoint.TargetQps, "target-qps", `Target QPS for the endpoint.`) // TODO: complex arg: throughput_info - cmd.Flags().StringVar(&updateEndpointReq.Endpoint.UsagePolicyId, "usage-policy-id", updateEndpointReq.Endpoint.UsagePolicyId, `The usage policy id applied to the endpoint.`) + flags.StringPtrVar(cmd.Flags(), &updateEndpointReq.Endpoint.UsagePolicyId, "usage-policy-id", `The usage policy id applied to the endpoint.`) cmd.Use = "update-endpoint NAME UPDATE_MASK ENDPOINT_TYPE" cmd.Short = `*Public Preview* Update an AI Search endpoint.` @@ -1055,6 +1118,7 @@ Update an AI Search endpoint. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateEndpointJson.Unmarshal(&updateEndpointReq.Endpoint) @@ -1068,25 +1132,28 @@ Update an AI Search endpoint. } } } - updateEndpointReq.Name = args[0] + updateEndpointReq.Endpoint.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateEndpointReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateEndpointReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &updateEndpointReq.Endpoint.EndpointType) - if err != nil { - return fmt.Errorf("invalid ENDPOINT_TYPE: %s", args[2]) - } - + updateEndpointReq.Endpoint.EndpointType = aisearch.EndpointType(args[2]) } - response, err := w.AiSearch.UpdateEndpoint(ctx, updateEndpointReq) + sdkReq, err := aisearch.UpdateEndpointRequestToSDK(&updateEndpointReq) + if err != nil { + return err + } + response, err := w.AiSearch.UpdateEndpoint(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aisearch.EndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1112,8 +1179,8 @@ var upsertDataOverrides []func( func newUpsertData() *cobra.Command { cmd := &cobra.Command{} - var upsertDataReq aisearch.UpsertDataRequest + var upsertDataJson flags.JsonFlag cmd.Flags().Var(&upsertDataJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1151,6 +1218,7 @@ Upsert data into an AI Search index. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := upsertDataJson.Unmarshal(&upsertDataReq) @@ -1164,17 +1232,25 @@ Upsert data into an AI Search index. } } } - upsertDataReq.Name = args[0] + upsertDataReq.Name = new(args[0]) if !cmd.Flags().Changed("json") { - upsertDataReq.InputsJson = args[1] + upsertDataReq.InputsJson = new(args[1]) } - response, err := w.AiSearch.UpsertData(ctx, upsertDataReq) + sdkReq, err := aisearch.UpsertDataRequestToSDK(&upsertDataReq) + if err != nil { + return err + } + response, err := w.AiSearch.UpsertData(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := aisearch.UpsertDataResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/aibi-dashboard-embedding-access-policy/aibi-dashboard-embedding-access-policy.go b/cmd/workspace/aibi-dashboard-embedding-access-policy/aibi-dashboard-embedding-access-policy.go index 5341051cd12..247ff711fc0 100644 --- a/cmd/workspace/aibi-dashboard-embedding-access-policy/aibi-dashboard-embedding-access-policy.go +++ b/cmd/workspace/aibi-dashboard-embedding-access-policy/aibi-dashboard-embedding-access-policy.go @@ -5,11 +5,14 @@ package aibi_dashboard_embedding_access_policy import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -52,15 +55,16 @@ Controls whether AI/BI published dashboard embedding is enabled, conditionally // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteAibiDashboardEmbeddingAccessPolicySettingRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeleteAibiDashboardEmbeddingAccessPolicySettingRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `*Public Preview* Delete the AI/BI dashboard embedding access policy.` @@ -84,12 +88,24 @@ Delete the AI/BI dashboard embedding access policy. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := "/api/2.0/settings/types/aibi_dash_embed_ws_acc_policy/names/default" - response, err := w.Settings.AibiDashboardEmbeddingAccessPolicy().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -111,15 +127,16 @@ Delete the AI/BI dashboard embedding access policy. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetAibiDashboardEmbeddingAccessPolicySettingRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetAibiDashboardEmbeddingAccessPolicySettingRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `*Public Preview* Retrieve the AI/BI dashboard embedding access policy.` @@ -144,12 +161,24 @@ Retrieve the AI/BI dashboard embedding access policy. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/aibi_dash_embed_ws_acc_policy/names/default" - response, err := w.Settings.AibiDashboardEmbeddingAccessPolicy().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -171,13 +200,16 @@ Retrieve the AI/BI dashboard embedding access policy. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateAibiDashboardEmbeddingAccessPolicySettingRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateAibiDashboardEmbeddingAccessPolicySettingRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -198,6 +230,7 @@ Update the AI/BI dashboard embedding access policy. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -214,11 +247,24 @@ Update the AI/BI dashboard embedding access policy. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.AibiDashboardEmbeddingAccessPolicy().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/aibi_dash_embed_ws_acc_policy/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/aibi-dashboard-embedding-approved-domains/aibi-dashboard-embedding-approved-domains.go b/cmd/workspace/aibi-dashboard-embedding-approved-domains/aibi-dashboard-embedding-approved-domains.go index 3477f3a0971..6e28150f8ee 100644 --- a/cmd/workspace/aibi-dashboard-embedding-approved-domains/aibi-dashboard-embedding-approved-domains.go +++ b/cmd/workspace/aibi-dashboard-embedding-approved-domains/aibi-dashboard-embedding-approved-domains.go @@ -5,11 +5,14 @@ package aibi_dashboard_embedding_approved_domains import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -52,15 +55,16 @@ Controls the list of domains approved to host the embedded AI/BI dashboards. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteAibiDashboardEmbeddingApprovedDomainsSettingRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeleteAibiDashboardEmbeddingApprovedDomainsSettingRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `*Public Preview* Delete AI/BI dashboard embedding approved domains.` @@ -84,12 +88,24 @@ Delete AI/BI dashboard embedding approved domains. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := "/api/2.0/settings/types/aibi_dash_embed_ws_apprvd_domains/names/default" - response, err := w.Settings.AibiDashboardEmbeddingApprovedDomains().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -111,15 +127,16 @@ Delete AI/BI dashboard embedding approved domains. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetAibiDashboardEmbeddingApprovedDomainsSettingRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetAibiDashboardEmbeddingApprovedDomainsSettingRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `*Public Preview* Retrieve the list of domains approved to host embedded AI/BI dashboards.` @@ -142,12 +159,24 @@ Retrieve the list of domains approved to host embedded AI/BI dashboards. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/aibi_dash_embed_ws_apprvd_domains/names/default" - response, err := w.Settings.AibiDashboardEmbeddingApprovedDomains().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -169,13 +198,16 @@ Retrieve the list of domains approved to host embedded AI/BI dashboards. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateAibiDashboardEmbeddingApprovedDomainsSettingRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateAibiDashboardEmbeddingApprovedDomainsSettingRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -198,6 +230,7 @@ Update the list of domains approved to host embedded AI/BI dashboards. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -214,11 +247,24 @@ Update the list of domains approved to host embedded AI/BI dashboards. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.AibiDashboardEmbeddingApprovedDomains().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/aibi_dash_embed_ws_apprvd_domains/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/alerts-legacy/alerts-legacy.go b/cmd/workspace/alerts-legacy/alerts-legacy.go index b381f027b2c..398864df7cc 100644 --- a/cmd/workspace/alerts-legacy/alerts-legacy.go +++ b/cmd/workspace/alerts-legacy/alerts-legacy.go @@ -4,12 +4,16 @@ package alerts_legacy import ( "errors" + "fmt" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/sql" "github.com/spf13/cobra" ) @@ -62,19 +66,24 @@ The alerts API can be used to perform CRUD operations on alerts. An alert is a // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *sql.CreateAlert, + *map[string]any, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq map[string]any + createReq = map[string]any{} + var createNameRaw string + var createParentRaw string + var createQueryIdRaw string + var createRearmRaw int - var createReq sql.CreateAlert 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.Parent, "parent", createReq.Parent, `The identifier of the workspace folder containing the object.`) - cmd.Flags().IntVar(&createReq.Rearm, "rearm", createReq.Rearm, `Number of seconds after being triggered before the alert rearms itself and can be triggered again.`) + cmd.Flags().StringVar(&createParentRaw, "parent", createParentRaw, `The identifier of the workspace folder containing the object.`) + cmd.Flags().IntVar(&createRearmRaw, "rearm", createRearmRaw, `Number of seconds after being triggered before the alert rearms itself and can be triggered again.`) cmd.Use = "create" cmd.Short = `*Public Preview* Create an alert.` @@ -99,6 +108,7 @@ Create an alert. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -115,11 +125,30 @@ Create an alert. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.AlertsLegacy.Create(ctx, createReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("name") || createNameRaw != "" { + createReq["name"] = createNameRaw + } + if cmd.Flags().Changed("parent") || createParentRaw != "" { + createReq["parent"] = createParentRaw + } + if cmd.Flags().Changed("query-id") || createQueryIdRaw != "" { + createReq["query_id"] = createQueryIdRaw + } + if cmd.Flags().Changed("rearm") || createRearmRaw != 0 { + createReq["rearm"] = createRearmRaw + } + rawPath := "/api/2.0/preview/sql/alerts" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -141,13 +170,14 @@ Create an alert. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sql.DeleteAlertsLegacyRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sql.DeleteAlertsLegacyRequest + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteAlertIdRaw string cmd.Use = "delete ALERT_ID" cmd.Short = `*Public Preview* Delete an alert.` @@ -177,10 +207,19 @@ Delete an alert. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.AlertId = args[0] + deleteAlertIdRaw = args[0] - err = w.AlertsLegacy.Delete(ctx, deleteReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/preview/sql/alerts/%s", fmt.Sprint(deleteAlertIdRaw)) + + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -205,13 +244,14 @@ Delete an alert. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *sql.GetAlertsLegacyRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq sql.GetAlertsLegacyRequest + var getReq map[string]any + getReq = map[string]any{} + var getAlertIdRaw string cmd.Use = "get ALERT_ID" cmd.Short = `*Public Preview* Get an alert.` @@ -239,14 +279,23 @@ Get an alert. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getAlertIdRaw = args[0] - getReq.AlertId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/preview/sql/alerts/%s", fmt.Sprint(getAlertIdRaw)) - response, err := w.AlertsLegacy.Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -294,11 +343,21 @@ Get alerts. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.AlertsLegacy.List(ctx) + _ = w + listReq := map[string]any{} + rawQuery := map[string]any{} + rawPath := "/api/2.0/preview/sql/alerts" + + maps.Copy(rawQuery, listReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -320,18 +379,23 @@ Get alerts. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *sql.EditAlert, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAlertIdRaw string + var updateNameRaw string + var updateQueryIdRaw string + var updateRearmRaw int - var updateReq sql.EditAlert var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().IntVar(&updateReq.Rearm, "rearm", updateReq.Rearm, `Number of seconds after being triggered before the alert rearms itself and can be triggered again.`) + cmd.Flags().IntVar(&updateRearmRaw, "rearm", updateRearmRaw, `Number of seconds after being triggered before the alert rearms itself and can be triggered again.`) cmd.Use = "update ALERT_ID" cmd.Short = `*Public Preview* Update an alert.` @@ -359,6 +423,7 @@ Update an alert. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -374,9 +439,25 @@ Update an alert. } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateReq.AlertId = args[0] + updateAlertIdRaw = args[0] + + rawQuery := map[string]any{} + if cmd.Flags().Changed("name") || updateNameRaw != "" { + updateReq["name"] = updateNameRaw + } + if cmd.Flags().Changed("query-id") || updateQueryIdRaw != "" { + updateReq["query_id"] = updateQueryIdRaw + } + if cmd.Flags().Changed("rearm") || updateRearmRaw != 0 { + updateReq["rearm"] = updateRearmRaw + } + rawPath := fmt.Sprintf("/api/2.0/preview/sql/alerts/%s", fmt.Sprint(updateAlertIdRaw)) - err = w.AlertsLegacy.Update(ctx, updateReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "PUT", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, nil) if err != nil { return err } diff --git a/cmd/workspace/alerts-v2/alerts-v2.go b/cmd/workspace/alerts-v2/alerts-v2.go index f7a31691341..27868eb48da 100644 --- a/cmd/workspace/alerts-v2/alerts-v2.go +++ b/cmd/workspace/alerts-v2/alerts-v2.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" + + alertsv2 "github.com/databricks/cli/libs/sdktypes/alerts/v2" + sdkalertsv2 "github.com/databricks/sdk-go/alerts/v2" ) // Slice with functions to override default command behavior. @@ -52,26 +55,26 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createAlertOverrides []func( *cobra.Command, - *sql.CreateAlertV2Request, + *alertsv2.CreateAlertRequest, ) func newCreateAlert() *cobra.Command { cmd := &cobra.Command{} + var createAlertReq alertsv2.CreateAlertRequest + createAlertReq.Alert = &alertsv2.Alert{} - var createAlertReq sql.CreateAlertV2Request - createAlertReq.Alert = sql.AlertV2{} var createAlertJson flags.JsonFlag cmd.Flags().Var(&createAlertJson, "json", `either inline JSON string or @path/to/file.json with request body`) - 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().Var(&createAlertReq.Alert.CustomTemplateFormat, "custom-template-format", `The format used to interpret the custom_summary and custom_description templates. Supported values: [HTML, MARKDOWN]`) + flags.StringPtrVar(cmd.Flags(), &createAlertReq.Alert.CustomDescription, "custom-description", `Custom description for the alert.`) + flags.StringPtrVar(cmd.Flags(), &createAlertReq.Alert.CustomSummary, "custom-summary", `Custom summary for the alert.`) + flags.EnumVar(cmd.Flags(), &createAlertReq.Alert.CustomTemplateFormat, "custom-template-format", `The format used to interpret the custom_summary and custom_description templates. Supported values: [HTML, MARKDOWN]`, "CustomTemplateFormat", "HTML", "MARKDOWN") // TODO: complex arg: effective_run_as // TODO: array: parameters - cmd.Flags().StringVar(&createAlertReq.Alert.ParentPath, "parent-path", createAlertReq.Alert.ParentPath, `The workspace path of the folder containing the alert.`) + flags.StringPtrVar(cmd.Flags(), &createAlertReq.Alert.ParentPath, "parent-path", `The workspace path of the folder containing the alert.`) // 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.`) + flags.StringPtrVar(cmd.Flags(), &createAlertReq.Alert.RunAsUserName, "run-as-user-name", `The run as username or application ID of service principal.`) cmd.Use = "create-alert DISPLAY_NAME QUERY_TEXT WAREHOUSE_ID EVALUATION SCHEDULE" cmd.Short = `Create an alert.` @@ -106,6 +109,7 @@ func newCreateAlert() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createAlertJson.Unmarshal(&createAlertReq.Alert) @@ -120,35 +124,35 @@ func newCreateAlert() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createAlertReq.Alert.DisplayName = args[0] + createAlertReq.Alert.DisplayName = new(args[0]) } if !cmd.Flags().Changed("json") { - createAlertReq.Alert.QueryText = args[1] + createAlertReq.Alert.QueryText = new(args[1]) } if !cmd.Flags().Changed("json") { - createAlertReq.Alert.WarehouseId = args[2] + createAlertReq.Alert.WarehouseId = new(args[2]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &createAlertReq.Alert.Evaluation) - if err != nil { - return fmt.Errorf("invalid EVALUATION: %s", args[3]) - } - + _ = args[3] // TODO: complex arg: evaluation } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[4], &createAlertReq.Alert.Schedule) - if err != nil { - return fmt.Errorf("invalid SCHEDULE: %s", args[4]) - } - + _ = args[4] // TODO: complex arg: schedule } - response, err := w.AlertsV2.CreateAlert(ctx, createAlertReq) + sdkReq, err := alertsv2.CreateAlertRequestToSDK(&createAlertReq) + if err != nil { + return err + } + response, err := w.Alerts.CreateAlert(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := alertsv2.AlertFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -169,13 +173,12 @@ func newCreateAlert() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getAlertOverrides []func( *cobra.Command, - *sql.GetAlertV2Request, + *sdkalertsv2.GetAlertRequest, ) func newGetAlert() *cobra.Command { cmd := &cobra.Command{} - - var getAlertReq sql.GetAlertV2Request + var getAlertReq sdkalertsv2.GetAlertRequest cmd.Use = "get-alert ID" cmd.Short = `Get an alert.` @@ -191,11 +194,12 @@ func newGetAlert() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Alerts V2 drop-down.") - names, err := w.AlertsV2.AlertV2DisplayNameToIdMap(ctx, sql.ListAlertsV2Request{}) + names, err := cmdgen.NamedIdMap(ctx, w.Alerts.ListAlertsIter(ctx, sdkalertsv2.ListAlertsRequest{}), []string{"DisplayName"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Alerts V2 drop-down. Please manually specify required arguments. Original error: %w", err) @@ -209,14 +213,19 @@ func newGetAlert() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - getAlertReq.Id = args[0] + getAlertReq.Id = new(args[0]) - response, err := w.AlertsV2.GetAlert(ctx, getAlertReq) + sdkReq := &getAlertReq + response, err := w.Alerts.GetAlert(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := alertsv2.AlertFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -237,25 +246,25 @@ func newGetAlert() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listAlertsOverrides []func( *cobra.Command, - *sql.ListAlertsV2Request, + *alertsv2.ListAlertsRequest, ) func newListAlerts() *cobra.Command { cmd := &cobra.Command{} + var listAlertsReq alertsv2.ListAlertsRequest - var listAlertsReq sql.ListAlertsV2Request // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listAlertsLimit int - cmd.Flags().IntVar(&listAlertsReq.PageSize, "page-size", listAlertsReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listAlertsReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listAlertsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listAlertsReq.PageToken, "page-token", listAlertsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listAlertsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-alerts" @@ -277,16 +286,20 @@ func newListAlerts() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.AlertsV2.ListAlerts(ctx, listAlertsReq) + sdkReq, err := alertsv2.ListAlertsRequestToSDK(&listAlertsReq) + if err != nil { + return err + } if listAlertsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listAlertsLimit) } if listAlertsLimit > 0 { ctx = cmdio.WithLimit(ctx, listAlertsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Alerts.ListAlertsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, alertsv2.AlertFromSDK)) } // Disable completions since they are not applicable. @@ -307,15 +320,14 @@ func newListAlerts() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var trashAlertOverrides []func( *cobra.Command, - *sql.TrashAlertV2Request, + *alertsv2.TrashAlertRequest, ) func newTrashAlert() *cobra.Command { cmd := &cobra.Command{} + var trashAlertReq alertsv2.TrashAlertRequest - var trashAlertReq sql.TrashAlertV2Request - - cmd.Flags().BoolVar(&trashAlertReq.Purge, "purge", trashAlertReq.Purge, `Whether to permanently delete the alert.`) + flags.BoolPtrVar(cmd.Flags(), &trashAlertReq.Purge, "purge", `Whether to permanently delete the alert.`) cmd.Use = "trash-alert ID" cmd.Short = `Delete an alert (legacy TrashAlert).` @@ -333,11 +345,12 @@ func newTrashAlert() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Alerts V2 drop-down.") - names, err := w.AlertsV2.AlertV2DisplayNameToIdMap(ctx, sql.ListAlertsV2Request{}) + names, err := cmdgen.NamedIdMap(ctx, w.Alerts.ListAlertsIter(ctx, sdkalertsv2.ListAlertsRequest{}), []string{"DisplayName"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Alerts V2 drop-down. Please manually specify required arguments. Original error: %w", err) @@ -351,12 +364,18 @@ func newTrashAlert() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - trashAlertReq.Id = args[0] + trashAlertReq.Id = new(args[0]) - err = w.AlertsV2.TrashAlert(ctx, trashAlertReq) + sdkReq, err := alertsv2.TrashAlertRequestToSDK(&trashAlertReq) + if err != nil { + return err + } + response, err := w.Alerts.TrashAlert(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -378,26 +397,26 @@ func newTrashAlert() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateAlertOverrides []func( *cobra.Command, - *sql.UpdateAlertV2Request, + *alertsv2.UpdateAlertRequest, ) func newUpdateAlert() *cobra.Command { cmd := &cobra.Command{} + var updateAlertReq alertsv2.UpdateAlertRequest + updateAlertReq.Alert = &alertsv2.Alert{} - var updateAlertReq sql.UpdateAlertV2Request - updateAlertReq.Alert = sql.AlertV2{} var updateAlertJson flags.JsonFlag cmd.Flags().Var(&updateAlertJson, "json", `either inline JSON string or @path/to/file.json with request body`) - 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().Var(&updateAlertReq.Alert.CustomTemplateFormat, "custom-template-format", `The format used to interpret the custom_summary and custom_description templates. Supported values: [HTML, MARKDOWN]`) + flags.StringPtrVar(cmd.Flags(), &updateAlertReq.Alert.CustomDescription, "custom-description", `Custom description for the alert.`) + flags.StringPtrVar(cmd.Flags(), &updateAlertReq.Alert.CustomSummary, "custom-summary", `Custom summary for the alert.`) + flags.EnumVar(cmd.Flags(), &updateAlertReq.Alert.CustomTemplateFormat, "custom-template-format", `The format used to interpret the custom_summary and custom_description templates. Supported values: [HTML, MARKDOWN]`, "CustomTemplateFormat", "HTML", "MARKDOWN") // TODO: complex arg: effective_run_as // TODO: array: parameters - cmd.Flags().StringVar(&updateAlertReq.Alert.ParentPath, "parent-path", updateAlertReq.Alert.ParentPath, `The workspace path of the folder containing the alert.`) + flags.StringPtrVar(cmd.Flags(), &updateAlertReq.Alert.ParentPath, "parent-path", `The workspace path of the folder containing the alert.`) // 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.`) + flags.StringPtrVar(cmd.Flags(), &updateAlertReq.Alert.RunAsUserName, "run-as-user-name", `The run as username or application ID of service principal.`) cmd.Use = "update-alert ID UPDATE_MASK DISPLAY_NAME QUERY_TEXT WAREHOUSE_ID EVALUATION SCHEDULE" cmd.Short = `Update an alert.` @@ -444,6 +463,7 @@ func newUpdateAlert() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateAlertJson.Unmarshal(&updateAlertReq.Alert) @@ -457,38 +477,38 @@ func newUpdateAlert() *cobra.Command { } } } - updateAlertReq.Id = args[0] - updateAlertReq.UpdateMask = args[1] + updateAlertReq.Alert.Id = new(args[0]) + updateAlertReq.UpdateMask = new(args[1]) if !cmd.Flags().Changed("json") { - updateAlertReq.Alert.DisplayName = args[2] + updateAlertReq.Alert.DisplayName = new(args[2]) } if !cmd.Flags().Changed("json") { - updateAlertReq.Alert.QueryText = args[3] + updateAlertReq.Alert.QueryText = new(args[3]) } if !cmd.Flags().Changed("json") { - updateAlertReq.Alert.WarehouseId = args[4] + updateAlertReq.Alert.WarehouseId = new(args[4]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[5], &updateAlertReq.Alert.Evaluation) - if err != nil { - return fmt.Errorf("invalid EVALUATION: %s", args[5]) - } - + _ = args[5] // TODO: complex arg: evaluation } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[6], &updateAlertReq.Alert.Schedule) - if err != nil { - return fmt.Errorf("invalid SCHEDULE: %s", args[6]) - } - + _ = args[6] // TODO: complex arg: schedule } - response, err := w.AlertsV2.UpdateAlert(ctx, updateAlertReq) + sdkReq, err := alertsv2.UpdateAlertRequestToSDK(&updateAlertReq) + if err != nil { + return err + } + response, err := w.Alerts.UpdateAlert(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := alertsv2.AlertFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/alerts/alerts.go b/cmd/workspace/alerts/alerts.go index 3d7ea15c063..835ed20387d 100644 --- a/cmd/workspace/alerts/alerts.go +++ b/cmd/workspace/alerts/alerts.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" + + alertsv1 "github.com/databricks/cli/libs/sdktypes/alerts/v1" + sdkalertsv1 "github.com/databricks/sdk-go/alerts/v1" ) // Slice with functions to override default command behavior. @@ -56,19 +59,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *sql.CreateAlertRequest, + *alertsv1.CreateAlertRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq alertsv1.CreateAlertRequest - var createReq sql.CreateAlertRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: alert - cmd.Flags().BoolVar(&createReq.AutoResolveDisplayName, "auto-resolve-display-name", createReq.AutoResolveDisplayName, `If true, automatically resolve alert display name conflicts.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.AutoResolveDisplayName, "auto-resolve-display-name", `If true, automatically resolve alert display name conflicts.`) cmd.Use = "create" cmd.Short = `Create an alert.` @@ -89,6 +92,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -103,12 +107,20 @@ func newCreate() *cobra.Command { } } - response, err := w.Alerts.Create(ctx, createReq) + sdkReq, err := alertsv1.CreateAlertRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.AlertsV1.CreateAlert(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := alertsv1.AlertFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -129,13 +141,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sql.TrashAlertRequest, + *sdkalertsv1.TrashAlertRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sql.TrashAlertRequest + var deleteReq sdkalertsv1.TrashAlertRequest cmd.Use = "delete ID" cmd.Short = `Delete an alert.` @@ -153,11 +164,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Alerts drop-down.") - names, err := w.Alerts.ListAlertsResponseAlertDisplayNameToIdMap(ctx, sql.ListAlertsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.AlertsV1.ListAlertsIter(ctx, sdkalertsv1.ListAlertsRequest{}), []string{"DisplayName"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Alerts drop-down. Please manually specify required arguments. Original error: %w", err) @@ -171,12 +183,15 @@ func newDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = w.Alerts.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.AlertsV1.TrashAlert(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -198,13 +213,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *sql.GetAlertRequest, + *sdkalertsv1.GetAlertRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq sql.GetAlertRequest + var getReq sdkalertsv1.GetAlertRequest cmd.Use = "get ID" cmd.Short = `Get an alert.` @@ -220,11 +234,12 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Alerts drop-down.") - names, err := w.Alerts.ListAlertsResponseAlertDisplayNameToIdMap(ctx, sql.ListAlertsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.AlertsV1.ListAlertsIter(ctx, sdkalertsv1.ListAlertsRequest{}), []string{"DisplayName"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Alerts drop-down. Please manually specify required arguments. Original error: %w", err) @@ -238,14 +253,19 @@ func newGet() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.Alerts.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.AlertsV1.GetAlert(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := alertsv1.AlertFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -266,25 +286,25 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *sql.ListAlertsRequest, + *alertsv1.ListAlertsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq alertsv1.ListAlertsRequest - var listReq sql.ListAlertsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -308,16 +328,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Alerts.List(ctx, listReq) + sdkReq, err := alertsv1.ListAlertsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AlertsV1.ListAlertsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, alertsv1.ListAlertsResponseAlertFromSDK)) } // Disable completions since they are not applicable. @@ -338,19 +362,19 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *sql.UpdateAlertRequest, + *alertsv1.UpdateAlertRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq alertsv1.UpdateAlertRequest - var updateReq sql.UpdateAlertRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: alert - cmd.Flags().BoolVar(&updateReq.AutoResolveDisplayName, "auto-resolve-display-name", updateReq.AutoResolveDisplayName, `If true, automatically resolve alert display name conflicts.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.AutoResolveDisplayName, "auto-resolve-display-name", `If true, automatically resolve alert display name conflicts.`) cmd.Use = "update ID UPDATE_MASK" cmd.Short = `Update an alert.` @@ -392,6 +416,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -405,17 +430,25 @@ func newUpdate() *cobra.Command { } } } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) if !cmd.Flags().Changed("json") { - updateReq.UpdateMask = args[1] + updateReq.UpdateMask = new(args[1]) } - response, err := w.Alerts.Update(ctx, updateReq) + sdkReq, err := alertsv1.UpdateAlertRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.AlertsV1.UpdateAlert(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := alertsv1.AlertFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/apps-settings/apps-settings.go b/cmd/workspace/apps-settings/apps-settings.go index ce5e6d84a41..c6ce3997961 100644 --- a/cmd/workspace/apps-settings/apps-settings.go +++ b/cmd/workspace/apps-settings/apps-settings.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/apps" "github.com/spf13/cobra" + + apps "github.com/databricks/cli/libs/sdktypes/apps/v1" + sdkapps "github.com/databricks/sdk-go/apps/v1" ) // Slice with functions to override default command behavior. @@ -61,14 +64,14 @@ var createCustomTemplateOverrides []func( func newCreateCustomTemplate() *cobra.Command { cmd := &cobra.Command{} - var createCustomTemplateReq apps.CreateCustomTemplateRequest - createCustomTemplateReq.Template = apps.CustomTemplate{} + 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.`) + flags.StringPtrVar(cmd.Flags(), &createCustomTemplateReq.Template.Description, "description", `The description of the template.`) cmd.Use = "create-custom-template NAME GIT_REPO PATH MANIFEST GIT_PROVIDER" cmd.Short = `Create a template.` @@ -106,6 +109,7 @@ func newCreateCustomTemplate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createCustomTemplateJson.Unmarshal(&createCustomTemplateReq.Template) @@ -120,31 +124,35 @@ func newCreateCustomTemplate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createCustomTemplateReq.Template.Name = args[0] + createCustomTemplateReq.Template.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createCustomTemplateReq.Template.GitRepo = args[1] + createCustomTemplateReq.Template.GitRepo = new(args[1]) } if !cmd.Flags().Changed("json") { - createCustomTemplateReq.Template.Path = args[2] + createCustomTemplateReq.Template.Path = new(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]) - } - + _ = args[3] // TODO: complex arg: manifest } if !cmd.Flags().Changed("json") { - createCustomTemplateReq.Template.GitProvider = args[4] + createCustomTemplateReq.Template.GitProvider = new(args[4]) } - response, err := w.AppsSettings.CreateCustomTemplate(ctx, createCustomTemplateReq) + sdkReq, err := apps.CreateCustomTemplateRequestToSDK(&createCustomTemplateReq) + if err != nil { + return err + } + response, err := w.Apps.CreateCustomTemplate(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := apps.CustomTemplateFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -165,13 +173,12 @@ func newCreateCustomTemplate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteCustomTemplateOverrides []func( *cobra.Command, - *apps.DeleteCustomTemplateRequest, + *sdkapps.DeleteCustomTemplateRequest, ) func newDeleteCustomTemplate() *cobra.Command { cmd := &cobra.Command{} - - var deleteCustomTemplateReq apps.DeleteCustomTemplateRequest + var deleteCustomTemplateReq sdkapps.DeleteCustomTemplateRequest cmd.Use = "delete-custom-template NAME" cmd.Short = `Delete a template.` @@ -195,15 +202,21 @@ func newDeleteCustomTemplate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteCustomTemplateReq.Name = args[0] + deleteCustomTemplateReq.Name = new(args[0]) - response, err := w.AppsSettings.DeleteCustomTemplate(ctx, deleteCustomTemplateReq) + sdkReq := &deleteCustomTemplateReq + response, err := w.Apps.DeleteCustomTemplate(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := apps.CustomTemplateFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -224,13 +237,12 @@ func newDeleteCustomTemplate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getCustomTemplateOverrides []func( *cobra.Command, - *apps.GetCustomTemplateRequest, + *sdkapps.GetCustomTemplateRequest, ) func newGetCustomTemplate() *cobra.Command { cmd := &cobra.Command{} - - var getCustomTemplateReq apps.GetCustomTemplateRequest + var getCustomTemplateReq sdkapps.GetCustomTemplateRequest cmd.Use = "get-custom-template NAME" cmd.Short = `Get a template.` @@ -254,15 +266,21 @@ func newGetCustomTemplate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getCustomTemplateReq.Name = args[0] + getCustomTemplateReq.Name = new(args[0]) - response, err := w.AppsSettings.GetCustomTemplate(ctx, getCustomTemplateReq) + sdkReq := &getCustomTemplateReq + response, err := w.Apps.GetCustomTemplate(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := apps.CustomTemplateFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -288,20 +306,20 @@ var listCustomTemplatesOverrides []func( func newListCustomTemplates() *cobra.Command { cmd := &cobra.Command{} - var listCustomTemplatesReq apps.ListCustomTemplatesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listCustomTemplatesLimit int - cmd.Flags().IntVar(&listCustomTemplatesReq.PageSize, "page-size", listCustomTemplatesReq.PageSize, `Upper bound for items returned.`) + flags.IntPtrVar(cmd.Flags(), &listCustomTemplatesReq.PageSize, "page-size", `Upper bound for items returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listCustomTemplatesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listCustomTemplatesReq.PageToken, "page-token", listCustomTemplatesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listCustomTemplatesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-custom-templates" @@ -323,16 +341,20 @@ func newListCustomTemplates() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.AppsSettings.ListCustomTemplates(ctx, listCustomTemplatesReq) + sdkReq, err := apps.ListCustomTemplatesRequestToSDK(&listCustomTemplatesReq) + if err != nil { + return err + } if listCustomTemplatesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listCustomTemplatesLimit) } if listCustomTemplatesLimit > 0 { ctx = cmdio.WithLimit(ctx, listCustomTemplatesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Apps.ListCustomTemplatesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, apps.CustomTemplateFromSDK)) } // Disable completions since they are not applicable. @@ -358,14 +380,14 @@ var updateCustomTemplateOverrides []func( func newUpdateCustomTemplate() *cobra.Command { cmd := &cobra.Command{} - var updateCustomTemplateReq apps.UpdateCustomTemplateRequest - updateCustomTemplateReq.Template = apps.CustomTemplate{} + 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.`) + flags.StringPtrVar(cmd.Flags(), &updateCustomTemplateReq.Template.Description, "description", `The description of the template.`) cmd.Use = "update-custom-template NAME GIT_REPO PATH MANIFEST GIT_PROVIDER" cmd.Short = `Update a template.` @@ -404,6 +426,7 @@ func newUpdateCustomTemplate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateCustomTemplateJson.Unmarshal(&updateCustomTemplateReq.Template) @@ -417,30 +440,34 @@ func newUpdateCustomTemplate() *cobra.Command { } } } - updateCustomTemplateReq.Name = args[0] + updateCustomTemplateReq.Template.Name = new(args[0]) if !cmd.Flags().Changed("json") { - updateCustomTemplateReq.Template.GitRepo = args[1] + updateCustomTemplateReq.Template.GitRepo = new(args[1]) } if !cmd.Flags().Changed("json") { - updateCustomTemplateReq.Template.Path = args[2] + updateCustomTemplateReq.Template.Path = new(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]) - } - + _ = args[3] // TODO: complex arg: manifest } if !cmd.Flags().Changed("json") { - updateCustomTemplateReq.Template.GitProvider = args[4] + updateCustomTemplateReq.Template.GitProvider = new(args[4]) } - response, err := w.AppsSettings.UpdateCustomTemplate(ctx, updateCustomTemplateReq) + sdkReq, err := apps.UpdateCustomTemplateRequestToSDK(&updateCustomTemplateReq) + if err != nil { + return err + } + response, err := w.Apps.UpdateCustomTemplate(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := apps.CustomTemplateFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/apps/apps.go b/cmd/workspace/apps/apps.go index af088696b8b..81bc28c8214 100644 --- a/cmd/workspace/apps/apps.go +++ b/cmd/workspace/apps/apps.go @@ -5,17 +5,26 @@ package apps import ( "errors" "fmt" - "strings" "time" + "maps" + "net/url" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "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/experimental/api" - "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + apps "github.com/databricks/cli/libs/sdktypes/apps/v1" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdkapps "github.com/databricks/sdk-go/apps/v1" ) // Slice with functions to override default command behavior. @@ -82,9 +91,9 @@ var createOverrides []func( func newCreate() *cobra.Command { cmd := &cobra.Command{} - var createReq apps.CreateAppRequest - createReq.App = apps.App{} + createReq.App = &apps.App{} + var createJson flags.JsonFlag var createSkipWait bool @@ -95,26 +104,26 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createReq.NoCompute, "no-compute", createReq.NoCompute, `If true, the app will not be started after creation.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.NoCompute, "no-compute", `If true, the app will not be started after creation.`) // TODO: complex arg: active_deployment // TODO: complex arg: app_status - cmd.Flags().StringVar(&createReq.App.BudgetPolicyId, "budget-policy-id", createReq.App.BudgetPolicyId, ``) - cmd.Flags().IntVar(&createReq.App.ComputeMaxInstances, "compute-max-instances", createReq.App.ComputeMaxInstances, `Maximum number of app instances the app is configured to run.`) - cmd.Flags().IntVar(&createReq.App.ComputeMinInstances, "compute-min-instances", createReq.App.ComputeMinInstances, `Minimum number of app instances the app is configured to run.`) - cmd.Flags().Var(&createReq.App.ComputeSize, "compute-size", `Supported values: [LARGE, MEDIUM, XLARGE]`) + flags.StringPtrVar(cmd.Flags(), &createReq.App.BudgetPolicyId, "budget-policy-id", ``) + flags.IntPtrVar(cmd.Flags(), &createReq.App.ComputeMaxInstances, "compute-max-instances", `Maximum number of app instances the app is configured to run.`) + flags.IntPtrVar(cmd.Flags(), &createReq.App.ComputeMinInstances, "compute-min-instances", `Minimum number of app instances the app is configured to run.`) + flags.EnumVar(cmd.Flags(), &createReq.App.ComputeSize, "compute-size", `Supported values: [LARGE, MEDIUM, XLARGE]`, "ComputeSize", "LARGE", "MEDIUM", "XLARGE") // TODO: complex arg: compute_status // TODO: complex arg: default_git_source - cmd.Flags().StringVar(&createReq.App.Description, "description", createReq.App.Description, `The description of the app.`) + flags.StringPtrVar(cmd.Flags(), &createReq.App.Description, "description", `The description of the app.`) // TODO: array: effective_user_api_scopes - cmd.Flags().BoolVar(&createReq.App.ForwardUserAccessToken, "forward-user-access-token", createReq.App.ForwardUserAccessToken, `Forward the user's access token to the app.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.App.ForwardUserAccessToken, "forward-user-access-token", `Forward the user's access token to the app.`) // TODO: complex arg: git_repository // TODO: complex arg: git_source // TODO: complex arg: pending_deployment // TODO: array: resources - cmd.Flags().StringVar(&createReq.App.SourceCodePath, "source-code-path", createReq.App.SourceCodePath, ``) - cmd.Flags().StringVar(&createReq.App.Space, "space", createReq.App.Space, `Name of the space this app belongs to.`) + flags.StringPtrVar(cmd.Flags(), &createReq.App.SourceCodePath, "source-code-path", ``) + flags.StringPtrVar(cmd.Flags(), &createReq.App.Space, "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, ``) + flags.StringPtrVar(cmd.Flags(), &createReq.App.UsagePolicyId, "usage-policy-id", ``) // TODO: array: user_api_scopes cmd.Use = "create NAME" @@ -147,6 +156,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.App) @@ -161,33 +171,42 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.App.Name = args[0] + createReq.App.Name = new(args[0]) } - wait, err := w.Apps.Create(ctx, createReq) + sdkReq, err := apps.CreateAppRequestToSDK(&createReq) if err != nil { return err } if createSkipWait { - return cmdio.Render(ctx, wait.Response) - } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *apps.App) { - if i.ComputeStatus == nil { - return + api, err := apiclient.New(w.Config) + if err != nil { + return err } - status := i.ComputeStatus.State - statusMessage := fmt.Sprintf("current status: %s", status) - if i.ComputeStatus != nil { - statusMessage = i.ComputeStatus.Message + var current apps.App + err = api.Do(ctx, "POST", "/api/2.0/apps", auth.WorkspaceIDHeaders(w.Config), map[string]any{"no_compute": createReq.NoCompute}, createReq.App, ¤t) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(createTimeout) + return cmdio.Render(ctx, current) + } + wait, err := w.Apps.CreateApp(ctx, *sdkReq) + if err != nil { + return err + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for create to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := apps.AppFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -213,9 +232,9 @@ var createSpaceOverrides []func( func newCreateSpace() *cobra.Command { cmd := &cobra.Command{} - var createSpaceReq apps.CreateSpaceRequest - createSpaceReq.Space = apps.Space{} + createSpaceReq.Space = &apps.Space{} + var createSpaceJson flags.JsonFlag var createSpaceSkipWait bool @@ -226,12 +245,12 @@ func newCreateSpace() *cobra.Command { cmd.Flags().Var(&createSpaceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createSpaceReq.Space.AssumeGroupId, "assume-group-id", createSpaceReq.Space.AssumeGroupId, `The group whose permissions users assume via Role Authorization for apps in this space.`) - cmd.Flags().StringVar(&createSpaceReq.Space.Description, "description", createSpaceReq.Space.Description, `The description of the app space.`) + flags.StringPtrVar(cmd.Flags(), &createSpaceReq.Space.AssumeGroupId, "assume-group-id", `The group whose permissions users assume via Role Authorization for apps in this space.`) + flags.StringPtrVar(cmd.Flags(), &createSpaceReq.Space.Description, "description", `The description of the app space.`) // TODO: array: effective_user_api_scopes // TODO: array: resources // TODO: complex arg: status - cmd.Flags().StringVar(&createSpaceReq.Space.UsagePolicyId, "usage-policy-id", createSpaceReq.Space.UsagePolicyId, `The usage policy ID for managing cost at the space level.`) + flags.StringPtrVar(cmd.Flags(), &createSpaceReq.Space.UsagePolicyId, "usage-policy-id", `The usage policy ID for managing cost at the space level.`) // TODO: array: user_api_scopes cmd.Use = "create-space NAME" @@ -273,6 +292,7 @@ func newCreateSpace() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createSpaceJson.Unmarshal(&createSpaceReq.Space) @@ -287,28 +307,26 @@ func newCreateSpace() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createSpaceReq.Space.Name = args[0] + createSpaceReq.Space.Name = new(args[0]) } + sdkReq, err := apps.CreateSpaceRequestToSDK(&createSpaceReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case createSpaceSkipWait: - wait, err := w.Apps.CreateSpace(ctx, createSpaceReq) + wait, err := w.Apps.CreateSpace(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Apps.GetSpaceOperation(ctx, apps.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Apps.CreateSpace(ctx, createSpaceReq) + wait, err := w.Apps.CreateSpace(ctx, *sdkReq) if err != nil { return err } @@ -318,13 +336,17 @@ func newCreateSpace() *cobra.Command { sp.Update("Waiting for create-space to complete...") // Wait for completion. - opts := api.WithTimeout(createSpaceTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(createSpaceTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := apps.SpaceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -351,8 +373,8 @@ var createUpdateOverrides []func( func newCreateUpdate() *cobra.Command { cmd := &cobra.Command{} - var createUpdateReq apps.AsyncUpdateAppRequest + var createUpdateJson flags.JsonFlag var createUpdateSkipWait bool @@ -407,6 +429,7 @@ func newCreateUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createUpdateJson.Unmarshal(&createUpdateReq) @@ -420,35 +443,44 @@ func newCreateUpdate() *cobra.Command { } } } - createUpdateReq.AppName = args[0] + createUpdateReq.AppName = new(args[0]) if !cmd.Flags().Changed("json") { - createUpdateReq.UpdateMask = args[1] + createUpdateReq.UpdateMask = new(args[1]) } - wait, err := w.Apps.CreateUpdate(ctx, createUpdateReq) + sdkReq, err := apps.AsyncUpdateAppRequestToSDK(&createUpdateReq) if err != nil { return err } if createUpdateSkipWait { - return cmdio.Render(ctx, wait.Response) - } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *apps.AppUpdate) { - if i.Status == nil { - return + api, err := apiclient.New(w.Config) + if err != nil { + return err } - status := i.Status.State - statusMessage := fmt.Sprintf("current status: %s", status) - if i.Status != nil { - statusMessage = i.Status.Message + var current apps.AppUpdate + err = api.Do(ctx, "POST", fmt.Sprintf("/api/2.0/apps/%s/update", url.PathEscape(fmt.Sprint(utils.Deref(createUpdateReq.AppName)))), auth.WorkspaceIDHeaders(w.Config), nil, &createUpdateReq, ¤t) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(createUpdateTimeout) + return cmdio.Render(ctx, current) + } + wait, err := w.Apps.AsyncUpdateApp(ctx, *sdkReq) + if err != nil { + return err + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for create-update to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createUpdateTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := apps.AppUpdateFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -469,13 +501,12 @@ func newCreateUpdate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *apps.DeleteAppRequest, + *sdkapps.DeleteAppRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq apps.DeleteAppRequest + var deleteReq sdkapps.DeleteAppRequest cmd.Use = "delete NAME" cmd.Short = `Delete an app.` @@ -499,15 +530,21 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Name = args[0] + deleteReq.Name = new(args[0]) - response, err := w.Apps.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Apps.DeleteApp(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := apps.AppFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -528,13 +565,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteAppThumbnailOverrides []func( *cobra.Command, - *apps.DeleteAppThumbnailRequest, + *sdkapps.DeleteAppThumbnailRequest, ) func newDeleteAppThumbnail() *cobra.Command { cmd := &cobra.Command{} - - var deleteAppThumbnailReq apps.DeleteAppThumbnailRequest + var deleteAppThumbnailReq sdkapps.DeleteAppThumbnailRequest cmd.Use = "delete-app-thumbnail NAME" cmd.Short = `Delete an app thumbnail.` @@ -558,10 +594,12 @@ func newDeleteAppThumbnail() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteAppThumbnailReq.Name = args[0] + deleteAppThumbnailReq.Name = new(args[0]) - err = w.Apps.DeleteAppThumbnail(ctx, deleteAppThumbnailReq) + sdkReq := &deleteAppThumbnailReq + err = w.Apps.DeleteAppThumbnail(ctx, *sdkReq) if err != nil { return err } @@ -586,13 +624,12 @@ func newDeleteAppThumbnail() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteSpaceOverrides []func( *cobra.Command, - *apps.DeleteSpaceRequest, + *sdkapps.DeleteSpaceRequest, ) func newDeleteSpace() *cobra.Command { cmd := &cobra.Command{} - - var deleteSpaceReq apps.DeleteSpaceRequest + var deleteSpaceReq sdkapps.DeleteSpaceRequest var deleteSpaceSkipWait bool var deleteSpaceTimeout time.Duration @@ -630,28 +667,24 @@ func newDeleteSpace() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteSpaceReq.Name = args[0] + deleteSpaceReq.Name = new(args[0]) + sdkReq := &deleteSpaceReq // Determine which mode to execute based on flags. switch { case deleteSpaceSkipWait: - wait, err := w.Apps.DeleteSpace(ctx, deleteSpaceReq) + wait, err := w.Apps.DeleteSpace(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Apps.GetSpaceOperation(ctx, apps.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Apps.DeleteSpace(ctx, deleteSpaceReq) + wait, err := w.Apps.DeleteSpace(ctx, *sdkReq) if err != nil { return err } @@ -661,13 +694,14 @@ func newDeleteSpace() *cobra.Command { sp.Update("Waiting for delete-space to complete...") // Wait for completion. - opts := api.WithTimeout(deleteSpaceTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(deleteSpaceTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -695,9 +729,9 @@ var deployOverrides []func( func newDeploy() *cobra.Command { cmd := &cobra.Command{} - var deployReq apps.CreateAppDeploymentRequest - deployReq.AppDeployment = apps.AppDeployment{} + deployReq.AppDeployment = &apps.AppDeployment{} + var deployJson flags.JsonFlag var deploySkipWait bool @@ -710,12 +744,12 @@ func newDeploy() *cobra.Command { // TODO: array: command // TODO: complex arg: deployment_artifacts - cmd.Flags().StringVar(&deployReq.AppDeployment.DeploymentId, "deployment-id", deployReq.AppDeployment.DeploymentId, `The unique id of the deployment.`) + flags.StringPtrVar(cmd.Flags(), &deployReq.AppDeployment.DeploymentId, "deployment-id", `The unique id of the deployment.`) // TODO: array: env_vars // TODO: complex arg: git_source // TODO: complex arg: health_check - cmd.Flags().Var(&deployReq.AppDeployment.Mode, "mode", `The mode of which the deployment will manage the source code. Supported values: [AUTO_SYNC, SNAPSHOT]`) - cmd.Flags().StringVar(&deployReq.AppDeployment.SourceCodePath, "source-code-path", deployReq.AppDeployment.SourceCodePath, `The workspace file system path of the source code used to create the app deployment.`) + flags.EnumVar(cmd.Flags(), &deployReq.AppDeployment.Mode, "mode", `The mode of which the deployment will manage the source code. Supported values: [AUTO_SYNC, SNAPSHOT]`, "AppDeploymentMode", "AUTO_SYNC", "SNAPSHOT") + flags.StringPtrVar(cmd.Flags(), &deployReq.AppDeployment.SourceCodePath, "source-code-path", `The workspace file system path of the source code used to create the app deployment.`) // TODO: complex arg: status cmd.Use = "deploy APP_NAME" @@ -740,6 +774,7 @@ func newDeploy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deployJson.Unmarshal(&deployReq.AppDeployment) @@ -753,32 +788,41 @@ func newDeploy() *cobra.Command { } } } - deployReq.AppName = args[0] + deployReq.AppName = new(args[0]) - wait, err := w.Apps.Deploy(ctx, deployReq) + sdkReq, err := apps.CreateAppDeploymentRequestToSDK(&deployReq) if err != nil { return err } if deploySkipWait { - return cmdio.Render(ctx, wait.Response) - } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *apps.AppDeployment) { - if i.Status == nil { - return + api, err := apiclient.New(w.Config) + if err != nil { + return err } - status := i.Status.State - statusMessage := fmt.Sprintf("current status: %s", status) - if i.Status != nil { - statusMessage = i.Status.Message + var current apps.AppDeployment + err = api.Do(ctx, "POST", fmt.Sprintf("/api/2.0/apps/%s/deployments", url.PathEscape(fmt.Sprint(utils.Deref(deployReq.AppName)))), auth.WorkspaceIDHeaders(w.Config), nil, deployReq.AppDeployment, ¤t) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(deployTimeout) + return cmdio.Render(ctx, current) + } + wait, err := w.Apps.CreateAppDeployment(ctx, *sdkReq) + if err != nil { + return err + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for deploy to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(deployTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := apps.AppDeploymentFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -799,13 +843,12 @@ func newDeploy() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *apps.GetAppRequest, + *sdkapps.GetAppRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq apps.GetAppRequest + var getReq sdkapps.GetAppRequest cmd.Use = "get NAME" cmd.Short = `Get an app.` @@ -829,15 +872,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Name = args[0] + getReq.Name = new(args[0]) - response, err := w.Apps.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Apps.GetApp(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := apps.AppFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -858,13 +907,12 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getDeploymentOverrides []func( *cobra.Command, - *apps.GetAppDeploymentRequest, + *sdkapps.GetAppDeploymentRequest, ) func newGetDeployment() *cobra.Command { cmd := &cobra.Command{} - - var getDeploymentReq apps.GetAppDeploymentRequest + var getDeploymentReq sdkapps.GetAppDeploymentRequest cmd.Use = "get-deployment APP_NAME DEPLOYMENT_ID" cmd.Short = `Get an app deployment.` @@ -890,16 +938,22 @@ func newGetDeployment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getDeploymentReq.AppName = args[0] - getDeploymentReq.DeploymentId = args[1] + getDeploymentReq.AppName = new(args[0]) + getDeploymentReq.DeploymentId = new(args[1]) - response, err := w.Apps.GetDeployment(ctx, getDeploymentReq) + sdkReq := &getDeploymentReq + response, err := w.Apps.GetAppDeployment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := apps.AppDeploymentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -920,13 +974,12 @@ func newGetDeployment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *apps.GetAppPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq apps.GetAppPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels APP_NAME" cmd.Short = `Get app permission levels.` @@ -950,15 +1003,23 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getPermissionLevelsReq.RequestObjectId = new(args[0]) - getPermissionLevelsReq.AppName = args[0] + getPermissionLevelsReq.RequestObjectType = new("apps") - response, err := w.Apps.GetPermissionLevels(ctx, getPermissionLevelsReq) + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -979,13 +1040,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *apps.GetAppPermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq apps.GetAppPermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions APP_NAME" cmd.Short = `Get app permissions.` @@ -1010,15 +1070,23 @@ func newGetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getPermissionsReq.RequestObjectId = new(args[0]) - getPermissionsReq.AppName = args[0] + getPermissionsReq.RequestObjectType = new("apps") - response, err := w.Apps.GetPermissions(ctx, getPermissionsReq) + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1039,13 +1107,12 @@ func newGetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getSpaceOverrides []func( *cobra.Command, - *apps.GetSpaceRequest, + *sdkapps.GetSpaceRequest, ) func newGetSpace() *cobra.Command { cmd := &cobra.Command{} - - var getSpaceReq apps.GetSpaceRequest + var getSpaceReq sdkapps.GetSpaceRequest cmd.Use = "get-space NAME" cmd.Short = `Get an app space.` @@ -1072,15 +1139,21 @@ func newGetSpace() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSpaceReq.Name = args[0] + getSpaceReq.Name = new(args[0]) - response, err := w.Apps.GetSpace(ctx, getSpaceReq) + sdkReq := &getSpaceReq + response, err := w.Apps.GetSpace(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := apps.SpaceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1101,13 +1174,14 @@ func newGetSpace() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getSpaceOperationOverrides []func( *cobra.Command, - *apps.GetOperationRequest, + *map[string]any, ) func newGetSpaceOperation() *cobra.Command { cmd := &cobra.Command{} - - var getSpaceOperationReq apps.GetOperationRequest + var getSpaceOperationReq map[string]any + getSpaceOperationReq = map[string]any{} + var getSpaceOperationNameRaw string cmd.Use = "get-space-operation NAME" cmd.Short = `Get the status of an app space operation.` @@ -1134,14 +1208,23 @@ func newGetSpaceOperation() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getSpaceOperationNameRaw = args[0] - getSpaceOperationReq.Name = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/app-spaces/%s/operation", fmt.Sprint(getSpaceOperationNameRaw)) - response, err := w.Apps.GetSpaceOperation(ctx, getSpaceOperationReq) + maps.Copy(rawQuery, getSpaceOperationReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1163,13 +1246,12 @@ func newGetSpaceOperation() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getUpdateOverrides []func( *cobra.Command, - *apps.GetAppUpdateRequest, + *sdkapps.GetAppUpdateRequest, ) func newGetUpdate() *cobra.Command { cmd := &cobra.Command{} - - var getUpdateReq apps.GetAppUpdateRequest + var getUpdateReq sdkapps.GetAppUpdateRequest cmd.Use = "get-update APP_NAME" cmd.Short = `Get an app update.` @@ -1193,15 +1275,21 @@ func newGetUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getUpdateReq.AppName = args[0] + getUpdateReq.AppName = new(args[0]) - response, err := w.Apps.GetUpdate(ctx, getUpdateReq) + sdkReq := &getUpdateReq + response, err := w.Apps.GetAppUpdate(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := apps.AppUpdateFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1227,21 +1315,21 @@ var listOverrides []func( func newList() *cobra.Command { cmd := &cobra.Command{} - var listReq apps.ListAppsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `Upper bound for items returned.`) - cmd.Flags().StringVar(&listReq.Space, "space", listReq.Space, `Filter apps by app space name.`) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", `Upper bound for items returned.`) + flags.StringPtrVar(cmd.Flags(), &listReq.Space, "space", `Filter apps by app space name.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -1263,16 +1351,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Apps.List(ctx, listReq) + sdkReq, err := apps.ListAppsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Apps.ListAppsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, apps.AppFromSDK)) } // Disable completions since they are not applicable. @@ -1298,20 +1390,20 @@ var listDeploymentsOverrides []func( func newListDeployments() *cobra.Command { cmd := &cobra.Command{} - var listDeploymentsReq apps.ListAppDeploymentsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listDeploymentsLimit int - cmd.Flags().IntVar(&listDeploymentsReq.PageSize, "page-size", listDeploymentsReq.PageSize, `Upper bound for items returned.`) + flags.IntPtrVar(cmd.Flags(), &listDeploymentsReq.PageSize, "page-size", `Upper bound for items returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listDeploymentsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listDeploymentsReq.PageToken, "page-token", listDeploymentsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listDeploymentsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-deployments APP_NAME" @@ -1336,18 +1428,22 @@ func newListDeployments() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listDeploymentsReq.AppName = args[0] + listDeploymentsReq.AppName = new(args[0]) - response := w.Apps.ListDeployments(ctx, listDeploymentsReq) + sdkReq, err := apps.ListAppDeploymentsRequestToSDK(&listDeploymentsReq) + if err != nil { + return err + } if listDeploymentsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listDeploymentsLimit) } if listDeploymentsLimit > 0 { ctx = cmdio.WithLimit(ctx, listDeploymentsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Apps.ListAppDeploymentsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, apps.AppDeploymentFromSDK)) } // Disable completions since they are not applicable. @@ -1373,20 +1469,20 @@ var listSpacesOverrides []func( func newListSpaces() *cobra.Command { cmd := &cobra.Command{} - var listSpacesReq apps.ListSpacesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSpacesLimit int - cmd.Flags().IntVar(&listSpacesReq.PageSize, "page-size", listSpacesReq.PageSize, `Upper bound for items returned.`) + flags.IntPtrVar(cmd.Flags(), &listSpacesReq.PageSize, "page-size", `Upper bound for items returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listSpacesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSpacesReq.PageToken, "page-token", listSpacesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSpacesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-spaces" @@ -1411,16 +1507,20 @@ func newListSpaces() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Apps.ListSpaces(ctx, listSpacesReq) + sdkReq, err := apps.ListSpacesRequestToSDK(&listSpacesReq) + if err != nil { + return err + } if listSpacesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSpacesLimit) } if listSpacesLimit > 0 { ctx = cmdio.WithLimit(ctx, listSpacesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Apps.ListSpacesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, apps.SpaceFromSDK)) } // Disable completions since they are not applicable. @@ -1441,13 +1541,13 @@ func newListSpaces() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *apps.AppPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq apps.AppPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1478,6 +1578,7 @@ func newSetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -1491,14 +1592,24 @@ func newSetPermissions() *cobra.Command { } } } - setPermissionsReq.AppName = args[0] + setPermissionsReq.RequestObjectId = new(args[0]) + + setPermissionsReq.RequestObjectType = new("apps") - response, err := w.Apps.SetPermissions(ctx, setPermissionsReq) + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1524,7 +1635,6 @@ var startOverrides []func( func newStart() *cobra.Command { cmd := &cobra.Command{} - var startReq apps.StartAppRequest var startSkipWait bool @@ -1555,33 +1665,43 @@ func newStart() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - startReq.Name = args[0] + startReq.Name = new(args[0]) - wait, err := w.Apps.Start(ctx, startReq) + sdkReq, err := apps.StartAppRequestToSDK(&startReq) if err != nil { return err } if startSkipWait { - return cmdio.Render(ctx, wait.Response) - } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *apps.App) { - if i.ComputeStatus == nil { - return + api, err := apiclient.New(w.Config) + if err != nil { + return err } - status := i.ComputeStatus.State - statusMessage := fmt.Sprintf("current status: %s", status) - if i.ComputeStatus != nil { - statusMessage = i.ComputeStatus.Message + var current apps.App + err = api.Do(ctx, "POST", fmt.Sprintf("/api/2.0/apps/%s/start", url.PathEscape(fmt.Sprint(utils.Deref(startReq.Name)))), auth.WorkspaceIDHeaders(w.Config), nil, &startReq, ¤t) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(startTimeout) + return cmdio.Render(ctx, current) + } + wait, err := w.Apps.StartApp(ctx, *sdkReq) + if err != nil { + return err + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for start to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(startTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := apps.AppFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1607,7 +1727,6 @@ var stopOverrides []func( func newStop() *cobra.Command { cmd := &cobra.Command{} - var stopReq apps.StopAppRequest var stopSkipWait bool @@ -1638,33 +1757,43 @@ func newStop() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - stopReq.Name = args[0] + stopReq.Name = new(args[0]) - wait, err := w.Apps.Stop(ctx, stopReq) + sdkReq, err := apps.StopAppRequestToSDK(&stopReq) if err != nil { return err } if stopSkipWait { - return cmdio.Render(ctx, wait.Response) - } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *apps.App) { - if i.ComputeStatus == nil { - return + api, err := apiclient.New(w.Config) + if err != nil { + return err } - status := i.ComputeStatus.State - statusMessage := fmt.Sprintf("current status: %s", status) - if i.ComputeStatus != nil { - statusMessage = i.ComputeStatus.Message + var current apps.App + err = api.Do(ctx, "POST", fmt.Sprintf("/api/2.0/apps/%s/stop", url.PathEscape(fmt.Sprint(utils.Deref(stopReq.Name)))), auth.WorkspaceIDHeaders(w.Config), nil, &stopReq, ¤t) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(stopTimeout) + return cmdio.Render(ctx, current) + } + wait, err := w.Apps.StopApp(ctx, *sdkReq) + if err != nil { + return err + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for stop to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(stopTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := apps.AppFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1690,32 +1819,32 @@ var updateOverrides []func( func newUpdate() *cobra.Command { cmd := &cobra.Command{} - var updateReq apps.UpdateAppRequest - updateReq.App = apps.App{} + updateReq.App = &apps.App{} + var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: active_deployment // TODO: complex arg: app_status - cmd.Flags().StringVar(&updateReq.App.BudgetPolicyId, "budget-policy-id", updateReq.App.BudgetPolicyId, ``) - cmd.Flags().IntVar(&updateReq.App.ComputeMaxInstances, "compute-max-instances", updateReq.App.ComputeMaxInstances, `Maximum number of app instances the app is configured to run.`) - cmd.Flags().IntVar(&updateReq.App.ComputeMinInstances, "compute-min-instances", updateReq.App.ComputeMinInstances, `Minimum number of app instances the app is configured to run.`) - cmd.Flags().Var(&updateReq.App.ComputeSize, "compute-size", `Supported values: [LARGE, MEDIUM, XLARGE]`) + flags.StringPtrVar(cmd.Flags(), &updateReq.App.BudgetPolicyId, "budget-policy-id", ``) + flags.IntPtrVar(cmd.Flags(), &updateReq.App.ComputeMaxInstances, "compute-max-instances", `Maximum number of app instances the app is configured to run.`) + flags.IntPtrVar(cmd.Flags(), &updateReq.App.ComputeMinInstances, "compute-min-instances", `Minimum number of app instances the app is configured to run.`) + flags.EnumVar(cmd.Flags(), &updateReq.App.ComputeSize, "compute-size", `Supported values: [LARGE, MEDIUM, XLARGE]`, "ComputeSize", "LARGE", "MEDIUM", "XLARGE") // TODO: complex arg: compute_status // TODO: complex arg: default_git_source - cmd.Flags().StringVar(&updateReq.App.Description, "description", updateReq.App.Description, `The description of the app.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.App.Description, "description", `The description of the app.`) // TODO: array: effective_user_api_scopes - cmd.Flags().BoolVar(&updateReq.App.ForwardUserAccessToken, "forward-user-access-token", updateReq.App.ForwardUserAccessToken, `Forward the user's access token to the app.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.App.ForwardUserAccessToken, "forward-user-access-token", `Forward the user's access token to the app.`) // TODO: complex arg: git_repository // TODO: complex arg: git_source // TODO: complex arg: pending_deployment // TODO: array: resources - cmd.Flags().StringVar(&updateReq.App.SourceCodePath, "source-code-path", updateReq.App.SourceCodePath, ``) - cmd.Flags().StringVar(&updateReq.App.Space, "space", updateReq.App.Space, `Name of the space this app belongs to.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.App.SourceCodePath, "source-code-path", ``) + flags.StringPtrVar(cmd.Flags(), &updateReq.App.Space, "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, ``) + flags.StringPtrVar(cmd.Flags(), &updateReq.App.UsagePolicyId, "usage-policy-id", ``) // TODO: array: user_api_scopes cmd.Use = "update NAME" @@ -1742,6 +1871,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.App) @@ -1755,14 +1885,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.Name = args[0] + updateReq.App.Name = new(args[0]) - response, err := w.Apps.Update(ctx, updateReq) + sdkReq, err := apps.UpdateAppRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Apps.UpdateApp(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := apps.AppFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1788,8 +1926,8 @@ var updateAppThumbnailOverrides []func( func newUpdateAppThumbnail() *cobra.Command { cmd := &cobra.Command{} - var updateAppThumbnailReq apps.UpdateAppThumbnailRequest + var updateAppThumbnailJson flags.JsonFlag cmd.Flags().Var(&updateAppThumbnailJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1818,6 +1956,7 @@ func newUpdateAppThumbnail() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateAppThumbnailJson.Unmarshal(&updateAppThumbnailReq) @@ -1831,14 +1970,22 @@ func newUpdateAppThumbnail() *cobra.Command { } } } - updateAppThumbnailReq.Name = args[0] + updateAppThumbnailReq.Name = new(args[0]) - response, err := w.Apps.UpdateAppThumbnail(ctx, updateAppThumbnailReq) + sdkReq, err := apps.UpdateAppThumbnailRequestToSDK(&updateAppThumbnailReq) + if err != nil { + return err + } + response, err := w.Apps.UpdateAppThumbnail(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := apps.AppThumbnailFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1859,13 +2006,13 @@ func newUpdateAppThumbnail() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *apps.AppPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq apps.AppPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1895,6 +2042,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -1908,14 +2056,24 @@ func newUpdatePermissions() *cobra.Command { } } } - updatePermissionsReq.AppName = args[0] + updatePermissionsReq.RequestObjectId = new(args[0]) + + updatePermissionsReq.RequestObjectType = new("apps") - response, err := w.Apps.UpdatePermissions(ctx, updatePermissionsReq) + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1941,9 +2099,9 @@ var updateSpaceOverrides []func( func newUpdateSpace() *cobra.Command { cmd := &cobra.Command{} - var updateSpaceReq apps.UpdateSpaceRequest - updateSpaceReq.Space = apps.Space{} + updateSpaceReq.Space = &apps.Space{} + var updateSpaceJson flags.JsonFlag var updateSpaceSkipWait bool @@ -1954,12 +2112,12 @@ func newUpdateSpace() *cobra.Command { cmd.Flags().Var(&updateSpaceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateSpaceReq.Space.AssumeGroupId, "assume-group-id", updateSpaceReq.Space.AssumeGroupId, `The group whose permissions users assume via Role Authorization for apps in this space.`) - cmd.Flags().StringVar(&updateSpaceReq.Space.Description, "description", updateSpaceReq.Space.Description, `The description of the app space.`) + flags.StringPtrVar(cmd.Flags(), &updateSpaceReq.Space.AssumeGroupId, "assume-group-id", `The group whose permissions users assume via Role Authorization for apps in this space.`) + flags.StringPtrVar(cmd.Flags(), &updateSpaceReq.Space.Description, "description", `The description of the app space.`) // TODO: array: effective_user_api_scopes // TODO: array: resources // TODO: complex arg: status - cmd.Flags().StringVar(&updateSpaceReq.Space.UsagePolicyId, "usage-policy-id", updateSpaceReq.Space.UsagePolicyId, `The usage policy ID for managing cost at the space level.`) + flags.StringPtrVar(cmd.Flags(), &updateSpaceReq.Space.UsagePolicyId, "usage-policy-id", `The usage policy ID for managing cost at the space level.`) // TODO: array: user_api_scopes cmd.Use = "update-space NAME UPDATE_MASK" @@ -2006,6 +2164,7 @@ func newUpdateSpace() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateSpaceJson.Unmarshal(&updateSpaceReq.Space) @@ -2019,31 +2178,28 @@ func newUpdateSpace() *cobra.Command { } } } - updateSpaceReq.Name = args[0] + updateSpaceReq.Space.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateSpaceReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateSpaceReq.UpdateMask = new(args[1]) } + sdkReq, err := apps.UpdateSpaceRequestToSDK(&updateSpaceReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case updateSpaceSkipWait: - wait, err := w.Apps.UpdateSpace(ctx, updateSpaceReq) + wait, err := w.Apps.UpdateSpace(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Apps.GetSpaceOperation(ctx, apps.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Apps.UpdateSpace(ctx, updateSpaceReq) + wait, err := w.Apps.UpdateSpace(ctx, *sdkReq) if err != nil { return err } @@ -2053,13 +2209,17 @@ func newUpdateSpace() *cobra.Command { sp.Update("Waiting for update-space to complete...") // Wait for completion. - opts := api.WithTimeout(updateSpaceTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(updateSpaceTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := apps.SpaceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } diff --git a/cmd/workspace/apps/errors.go b/cmd/workspace/apps/errors.go index cbcb2ce3860..f4a668ce71c 100644 --- a/cmd/workspace/apps/errors.go +++ b/cmd/workspace/apps/errors.go @@ -4,24 +4,23 @@ import ( "errors" "fmt" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/retries" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/cmdgen" "github.com/spf13/cobra" ) const tailLinesSuggestedValue = 100 // isDeploymentWaitError checks if the error is from the deployment wait phase. -// These are errors wrapped by retries.Halt() during GetWithTimeout(). +// The generated commands mark errors of the wait as cmdgen.WaitError. // Excludes API client errors (4xx) which are validation errors before deployment starts. func isDeploymentWaitError(err error) bool { - retriesErr, ok := errors.AsType[*retries.Err](err) - if !ok || !retriesErr.Halt { + if _, ok := errors.AsType[*cmdgen.WaitError](err); !ok { return false } // Exclude API client errors (4xx) (e.g. app not found) - if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.StatusCode >= 400 && apiErr.StatusCode < 500 { + if code := apierrs.StatusCode(err); code >= 400 && code < 500 { return false } diff --git a/cmd/workspace/apps/errors_test.go b/cmd/workspace/apps/errors_test.go index f9e6fade6d5..e9d7dd7572f 100644 --- a/cmd/workspace/apps/errors_test.go +++ b/cmd/workspace/apps/errors_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/retries" + "github.com/databricks/cli/libs/cmdgen" + "github.com/databricks/sdk-go/core/apierr" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -80,66 +80,50 @@ func TestWrapDeploymentError(t *testing.T) { description: "plain errors should not be wrapped", }, { - name: "retries.Err with Halt=false", - err: retries.Continues("still in progress"), + name: "error outside of the wait", + err: errors.New("still in progress"), appName: "test-app", expectWrapped: false, description: "transient retries errors should not be wrapped", }, { - name: "retries.Err with 404 API error (not found)", - err: retries.Halt(fmt.Errorf("API error: %w", &apierr.APIError{ - StatusCode: 404, - ErrorCode: "NOT_FOUND", - Message: "App with name test-app does not exist or is deleted.", - })), + name: "wait error with 404 API error (not found)", + err: waitErr(fmt.Errorf("API error: %w", apierr.FromHTTPError(404, nil, []byte(`{"error_code":"NOT_FOUND","message":"App with name test-app does not exist or is deleted."}`)))), appName: "test-app", expectWrapped: false, description: "404 not found errors should not be wrapped with logs hint", }, { - name: "retries.Err with 400 API error (bad request)", - err: retries.Halt(fmt.Errorf("API error: %w", &apierr.APIError{ - StatusCode: 400, - ErrorCode: "BAD_REQUEST", - Message: "Invalid request parameters", - })), + name: "wait error with 400 API error (bad request)", + err: waitErr(fmt.Errorf("API error: %w", apierr.FromHTTPError(400, nil, []byte(`{"error_code":"BAD_REQUEST","message":"Invalid request parameters"}`)))), appName: "test-app", expectWrapped: false, description: "400 bad request errors should not be wrapped with logs hint", }, { - name: "retries.Err with 403 API error (forbidden)", - err: retries.Halt(fmt.Errorf("API error: %w", &apierr.APIError{ - StatusCode: 403, - ErrorCode: "FORBIDDEN", - Message: "Access denied", - })), + name: "wait error with 403 API error (forbidden)", + err: waitErr(fmt.Errorf("API error: %w", apierr.FromHTTPError(403, nil, []byte(`{"error_code":"FORBIDDEN","message":"Access denied"}`)))), appName: "test-app", expectWrapped: false, description: "403 forbidden errors should not be wrapped with logs hint", }, { - name: "retries.Err with 500 API error (server error)", - err: retries.Halt(fmt.Errorf("API error: %w", &apierr.APIError{ - StatusCode: 500, - ErrorCode: "INTERNAL_ERROR", - Message: "Internal server error", - })), + name: "wait error with 500 API error (server error)", + err: waitErr(fmt.Errorf("API error: %w", apierr.FromHTTPError(500, nil, []byte(`{"error_code":"INTERNAL_ERROR","message":"Internal server error"}`)))), appName: "test-app", expectWrapped: true, description: "500 server errors during wait should be wrapped with logs hint", }, { - name: "retries.Err without API error (deployment failure)", - err: retries.Halt(errors.New("failed to reach SUCCEEDED, got FAILED: Error building app")), + name: "wait error without API error (deployment failure)", + err: waitErr(errors.New("failed to reach SUCCEEDED, got FAILED: Error building app")), appName: "test-app", expectWrapped: true, description: "deployment failures should be wrapped with logs hint", }, { - name: "retries.Err without API error (timeout)", - err: retries.Halt(errors.New("timeout waiting for deployment")), + name: "wait error without API error (timeout)", + err: waitErr(errors.New("timeout waiting for deployment")), appName: "test-app", expectWrapped: true, description: "timeout errors should be wrapped with logs hint", @@ -166,3 +150,7 @@ func TestWrapDeploymentError(t *testing.T) { }) } } + +func waitErr(err error) error { + return &cmdgen.WaitError{Err: err} +} diff --git a/cmd/workspace/apps/git_flags.go b/cmd/workspace/apps/git_flags.go index c600d4d0c05..9f009bc0526 100644 --- a/cmd/workspace/apps/git_flags.go +++ b/cmd/workspace/apps/git_flags.go @@ -5,7 +5,8 @@ import ( "fmt" "github.com/databricks/cli/libs/cmdctx" - "github.com/databricks/databricks-sdk-go/service/apps" + apps "github.com/databricks/cli/libs/sdktypes/apps/v1" + sdkapps "github.com/databricks/sdk-go/apps/v1" "github.com/spf13/cobra" ) @@ -62,15 +63,14 @@ func gitRepositoryFlags(cmd *cobra.Command, target **apps.GitRepository, withCal if (autoDeploySet || credSet) && !urlSet { return errors.New(modifiers + " require --git-url and --git-provider") } - repo := &apps.GitRepository{Url: url, Provider: provider} + repo := &apps.GitRepository{Url: &url, Provider: &provider} if autoDeploySet { - repo.AutoDeploy = autoDeploy - // auto_deploy is omitempty; force-send so --git-auto-deploy=false is - // transmitted (e.g. to turn auto-deploy off on update). - repo.ForceSendFields = append(repo.ForceSendFields, "AutoDeploy") + // Set even when false so --git-auto-deploy=false is transmitted + // (e.g. to turn auto-deploy off on update). + repo.AutoDeploy = &autoDeploy } if credSet { - repo.CallerCredentialId = callerCredentialID + repo.CallerCredentialId = &callerCredentialID } *target = repo return nil @@ -113,12 +113,22 @@ func gitSourceFlags(cmd *cobra.Command, target **apps.GitSource) func(*cobra.Com if pathSet && !refSet { return errors.New("--git-source-code-path requires one of --git-branch, --git-tag, or --git-commit") } - *target = &apps.GitSource{ - Branch: branch, - Tag: tag, - Commit: commit, - SourceCodePath: sourceCodePath, + src := &apps.GitSource{} + for _, f := range []struct { + flag string + value string + dst **string + }{ + {"git-branch", branch, &src.Branch}, + {"git-tag", tag, &src.Tag}, + {"git-commit", commit, &src.Commit}, + {"git-source-code-path", sourceCodePath, &src.SourceCodePath}, + } { + if cmd.Flags().Changed(f.flag) { + *f.dst = new(f.value) + } } + *target = src return nil } } @@ -185,14 +195,13 @@ func gitCreateOverride(createCmd *cobra.Command, createReq *apps.CreateAppReques } // applyPreservedAutoDeploy carries a currently-enabled auto_deploy forward onto -// the update request's git_repository. auto_deploy=true survives the omitempty -// tag, so no ForceSendFields entry is needed; a currently-disabled auto_deploy -// stays omitted (the server keeps it off). +// the update request's git_repository; a currently-disabled auto_deploy stays +// omitted (the server keeps it off). func applyPreservedAutoDeploy(repo *apps.GitRepository, currentAutoDeploy bool) { if repo == nil || !currentAutoDeploy { return } - repo.AutoDeploy = true + repo.AutoDeploy = new(true) } // preserveAutoDeployOnUpdate keeps auto-deploy from being silently torn down @@ -210,12 +219,12 @@ func preserveAutoDeployOnUpdate(req *apps.UpdateAppRequest) func(*cobra.Command, return nil } ctx := cmd.Context() - current, err := cmdctx.WorkspaceClient(ctx).Apps.GetByName(ctx, args[0]) + current, err := cmdctx.WorkspaceClient(ctx).Apps.GetApp(ctx, sdkapps.GetAppRequest{Name: new(args[0])}) if err != nil { return fmt.Errorf("read current app to preserve auto-deploy: %w", err) } - if current.GitRepository != nil { - applyPreservedAutoDeploy(req.App.GitRepository, current.GitRepository.AutoDeploy) + if current.GitRepository != nil && current.GitRepository.AutoDeploy != nil { + applyPreservedAutoDeploy(req.App.GitRepository, *current.GitRepository.AutoDeploy) } return nil } diff --git a/cmd/workspace/apps/git_flags_test.go b/cmd/workspace/apps/git_flags_test.go index 847afa99347..b03b3fb5819 100644 --- a/cmd/workspace/apps/git_flags_test.go +++ b/cmd/workspace/apps/git_flags_test.go @@ -3,7 +3,8 @@ package apps import ( "testing" - "github.com/databricks/databricks-sdk-go/service/apps" + apps "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/libs/utils" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -48,8 +49,8 @@ func TestGitRepositoryFlags(t *testing.T) { }) require.NoError(t, err) require.NotNil(t, target) - assert.Equal(t, "https://github.com/databricks/git_app_repo.git", target.Url) - assert.Equal(t, "gitHub", target.Provider) + assert.Equal(t, "https://github.com/databricks/git_app_repo.git", utils.Deref(target.Url)) + assert.Equal(t, "gitHub", utils.Deref(target.Provider)) }) t.Run("url without provider errors", func(t *testing.T) { @@ -73,11 +74,11 @@ func TestGitRepositoryFlags(t *testing.T) { }) require.NoError(t, err) require.NotNil(t, target) - assert.True(t, target.AutoDeploy) - assert.Equal(t, int64(93488329053511), target.CallerCredentialId) + assert.True(t, utils.Deref(target.AutoDeploy)) + assert.Equal(t, int64(93488329053511), utils.Deref(target.CallerCredentialId)) }) - t.Run("auto-deploy=false is force-sent", func(t *testing.T) { + t.Run("auto-deploy=false is sent", func(t *testing.T) { target, err := runGitRepositoryFlags(t, []string{ "--git-url", "https://github.com/x/y", "--git-provider", "gitHub", @@ -85,10 +86,10 @@ func TestGitRepositoryFlags(t *testing.T) { }) require.NoError(t, err) require.NotNil(t, target) - assert.False(t, target.AutoDeploy) + require.NotNil(t, target.AutoDeploy) + assert.False(t, *target.AutoDeploy) // Otherwise omitempty would drop the field and the server could not // distinguish "disable auto-deploy" from "unset". - assert.Contains(t, target.ForceSendFields, "AutoDeploy") }) t.Run("auto-deploy without url and provider errors", func(t *testing.T) { @@ -225,15 +226,15 @@ func TestRequireRepoForGitSourceOnCreate(t *testing.T) { func TestApplyPreservedAutoDeploy(t *testing.T) { t.Run("carries a currently-enabled auto_deploy forward", func(t *testing.T) { - repo := &apps.GitRepository{Url: "https://github.com/x/y", Provider: "gitHub"} + repo := &apps.GitRepository{Url: new("https://github.com/x/y"), Provider: new("gitHub")} applyPreservedAutoDeploy(repo, true) - assert.True(t, repo.AutoDeploy) + assert.True(t, utils.Deref(repo.AutoDeploy)) }) t.Run("leaves a currently-disabled auto_deploy off", func(t *testing.T) { - repo := &apps.GitRepository{Url: "https://github.com/x/y", Provider: "gitHub"} + repo := &apps.GitRepository{Url: new("https://github.com/x/y"), Provider: new("gitHub")} applyPreservedAutoDeploy(repo, false) - assert.False(t, repo.AutoDeploy) + assert.Nil(t, repo.AutoDeploy) }) t.Run("nil repo is a no-op", func(t *testing.T) { @@ -256,25 +257,25 @@ func TestPreserveAutoDeployOnUpdate_Guards(t *testing.T) { // Each guard returns before the GetApp call, so no client is needed. If a // guard failed to short-circuit, WorkspaceClient(ctx) would panic here. t.Run("skips when --json is set", func(t *testing.T) { - req := &apps.UpdateAppRequest{} + req := &apps.UpdateAppRequest{App: &apps.App{}} cmd := newPreserveCmd(t, req, []string{"--json", "{}", "--git-url", "https://github.com/x/y", "--git-provider", "gitHub"}) require.NoError(t, preserveAutoDeployOnUpdate(req)(cmd, []string{"my-app"})) }) t.Run("skips when --git-auto-deploy was passed", func(t *testing.T) { - req := &apps.UpdateAppRequest{} + req := &apps.UpdateAppRequest{App: &apps.App{}} cmd := newPreserveCmd(t, req, []string{"--git-url", "https://github.com/x/y", "--git-provider", "gitHub", "--git-auto-deploy"}) require.NoError(t, preserveAutoDeployOnUpdate(req)(cmd, []string{"my-app"})) }) t.Run("skips when no repository change is being sent", func(t *testing.T) { - req := &apps.UpdateAppRequest{} + req := &apps.UpdateAppRequest{App: &apps.App{}} cmd := newPreserveCmd(t, req, nil) // GitRepository stays nil require.NoError(t, preserveAutoDeployOnUpdate(req)(cmd, []string{"my-app"})) }) t.Run("skips when no app name is available", func(t *testing.T) { - req := &apps.UpdateAppRequest{} + req := &apps.UpdateAppRequest{App: &apps.App{}} cmd := newPreserveCmd(t, req, []string{"--git-url", "https://github.com/x/y", "--git-provider", "gitHub"}) require.NoError(t, preserveAutoDeployOnUpdate(req)(cmd, nil)) }) @@ -291,9 +292,9 @@ func TestGitSourceFlags(t *testing.T) { target, err := runGitSourceFlags(t, []string{"--git-branch", "main"}) require.NoError(t, err) require.NotNil(t, target) - assert.Equal(t, "main", target.Branch) - assert.Empty(t, target.Tag) - assert.Empty(t, target.Commit) + assert.Equal(t, "main", utils.Deref(target.Branch)) + assert.Nil(t, target.Tag) + assert.Nil(t, target.Commit) }) t.Run("commit with source-code-path populates both", func(t *testing.T) { @@ -303,8 +304,8 @@ func TestGitSourceFlags(t *testing.T) { }) require.NoError(t, err) require.NotNil(t, target) - assert.Equal(t, "abc123", target.Commit) - assert.Equal(t, "my-app", target.SourceCodePath) + assert.Equal(t, "abc123", utils.Deref(target.Commit)) + assert.Equal(t, "my-app", utils.Deref(target.SourceCodePath)) }) t.Run("source-code-path without a ref errors", func(t *testing.T) { diff --git a/cmd/workspace/apps/overrides.go b/cmd/workspace/apps/overrides.go index 6a909a943e7..40a136a779d 100644 --- a/cmd/workspace/apps/overrides.go +++ b/cmd/workspace/apps/overrides.go @@ -5,7 +5,9 @@ import ( appsCli "github.com/databricks/cli/cmd/apps" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/apps" + apps "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/libs/utils" + sdkapps "github.com/databricks/sdk-go/apps/v1" "github.com/spf13/cobra" ) @@ -32,7 +34,7 @@ func createOverride(createCmd *cobra.Command, createReq *apps.CreateAppRequest) originalRunE := createCmd.RunE createCmd.RunE = func(cmd *cobra.Command, args []string) error { err := originalRunE(cmd, args) - return wrapDeploymentError(cmd, createReq.App.Name, err) + return wrapDeploymentError(cmd, utils.Deref(createReq.App.Name), err) } } @@ -40,7 +42,7 @@ func createUpdateOverride(createUpdateCmd *cobra.Command, createUpdateReq *apps. originalRunE := createUpdateCmd.RunE createUpdateCmd.RunE = func(cmd *cobra.Command, args []string) error { err := originalRunE(cmd, args) - return wrapDeploymentError(cmd, createUpdateReq.AppName, err) + return wrapDeploymentError(cmd, utils.Deref(createUpdateReq.AppName), err) } } @@ -87,9 +89,9 @@ func init() { listOverrides = append(listOverrides, listOverride) listDeploymentsOverrides = append(listDeploymentsOverrides, listDeploymentsOverride) createOverrides = append(createOverrides, createOverride) - deployOverrides = append(deployOverrides, appsCli.BundleDeployOverrideWithWrapper(wrapDeploymentError)) - deleteOverrides = append(deleteOverrides, appsCli.BundleDeleteOverrideWithWrapper(wrapDeploymentError)) - startOverrides = append(startOverrides, appsCli.BundleStartOverrideWithWrapper(wrapDeploymentError)) - stopOverrides = append(stopOverrides, appsCli.BundleStopOverrideWithWrapper(wrapDeploymentError)) + deployOverrides = append(deployOverrides, appsCli.BundleDeployOverrideWithWrapper[apps.CreateAppDeploymentRequest](wrapDeploymentError)) + deleteOverrides = append(deleteOverrides, appsCli.BundleDeleteOverrideWithWrapper[sdkapps.DeleteAppRequest](wrapDeploymentError)) + startOverrides = append(startOverrides, appsCli.BundleStartOverrideWithWrapper[apps.StartAppRequest](wrapDeploymentError)) + stopOverrides = append(stopOverrides, appsCli.BundleStopOverrideWithWrapper[apps.StopAppRequest](wrapDeploymentError)) createUpdateOverrides = append(createUpdateOverrides, createUpdateOverride) } diff --git a/cmd/workspace/artifact-allowlists/artifact-allowlists.go b/cmd/workspace/artifact-allowlists/artifact-allowlists.go index d6fce44ebd1..f84f30378fc 100644 --- a/cmd/workspace/artifact-allowlists/artifact-allowlists.go +++ b/cmd/workspace/artifact-allowlists/artifact-allowlists.go @@ -4,14 +4,15 @@ package artifact_allowlists import ( "errors" - "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" + + ucartifactallowlists "github.com/databricks/cli/libs/sdktypes/uc/artifactallowlists/v1" + sdkucartifactallowlists "github.com/databricks/sdk-go/uc/artifactallowlists/v1" ) // Slice with functions to override default command behavior. @@ -51,13 +52,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetArtifactAllowlistRequest, + *sdkucartifactallowlists.GetArtifactAllowlistRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq catalog.GetArtifactAllowlistRequest + var getReq sdkucartifactallowlists.GetArtifactAllowlistRequest cmd.Use = "get ARTIFACT_TYPE" cmd.Short = `Get an artifact allowlist.` @@ -83,18 +83,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getReq.ArtifactType = sdkucartifactallowlists.ArtifactType(args[0]) - _, err = fmt.Sscan(args[0], &getReq.ArtifactType) + sdkReq := &getReq + response, err := w.ArtifactAllowlists.GetArtifactAllowlist(ctx, *sdkReq) if err != nil { - return fmt.Errorf("invalid ARTIFACT_TYPE: %s", args[0]) + return err } - response, err := w.ArtifactAllowlists.Get(ctx, getReq) + out, err := ucartifactallowlists.ArtifactAllowlistInfoFromSDK(response) if err != nil { return err } - - return cmdio.Render(ctx, response) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -115,13 +118,13 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.SetArtifactAllowlist, + *ucartifactallowlists.SetArtifactAllowlistRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucartifactallowlists.SetArtifactAllowlistRequest - var updateReq catalog.SetArtifactAllowlist var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -151,6 +154,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -166,17 +170,22 @@ func newUpdate() *cobra.Command { } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - _, err = fmt.Sscan(args[0], &updateReq.ArtifactType) + updateReq.ArtifactType = ucartifactallowlists.ArtifactType(args[0]) + + sdkReq, err := ucartifactallowlists.SetArtifactAllowlistRequestToSDK(&updateReq) if err != nil { - return fmt.Errorf("invalid ARTIFACT_TYPE: %s", args[0]) + return err } - - response, err := w.ArtifactAllowlists.Update(ctx, updateReq) + response, err := w.ArtifactAllowlists.SetArtifactAllowlist(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucartifactallowlists.ArtifactAllowlistInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/automatic-cluster-update/automatic-cluster-update.go b/cmd/workspace/automatic-cluster-update/automatic-cluster-update.go index 2ee11c74d41..38cba90fe58 100644 --- a/cmd/workspace/automatic-cluster-update/automatic-cluster-update.go +++ b/cmd/workspace/automatic-cluster-update/automatic-cluster-update.go @@ -5,11 +5,14 @@ package automatic_cluster_update import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -50,15 +53,16 @@ Controls whether automatic cluster update is enabled for the current // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetAutomaticClusterUpdateSettingRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetAutomaticClusterUpdateSettingRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `*Public Preview* Get the automatic cluster update setting.` @@ -81,12 +85,24 @@ Get the automatic cluster update setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/automatic_cluster_update/names/default" - response, err := w.Settings.AutomaticClusterUpdate().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -108,13 +124,16 @@ Get the automatic cluster update setting. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateAutomaticClusterUpdateSettingRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateAutomaticClusterUpdateSettingRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -139,6 +158,7 @@ Update the automatic cluster update setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -155,11 +175,24 @@ Update the automatic cluster update setting. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.AutomaticClusterUpdate().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/automatic_cluster_update/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/bundle-deployments/bundle-deployments.go b/cmd/workspace/bundle-deployments/bundle-deployments.go index b29e9dcac82..8fc724944bc 100644 --- a/cmd/workspace/bundle-deployments/bundle-deployments.go +++ b/cmd/workspace/bundle-deployments/bundle-deployments.go @@ -10,8 +10,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" "github.com/spf13/cobra" + + bundledeployments "github.com/databricks/cli/libs/bundledeployments" ) // Slice with functions to override default command behavior. @@ -70,8 +71,8 @@ var completeVersionOverrides []func( func newCompleteVersion() *cobra.Command { cmd := &cobra.Command{} - var completeVersionReq bundledeployments.CompleteVersionRequest + var completeVersionJson flags.JsonFlag cmd.Flags().Var(&completeVersionJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -116,6 +117,7 @@ func newCompleteVersion() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := completeVersionJson.Unmarshal(&completeVersionReq) @@ -135,14 +137,12 @@ func newCompleteVersion() *cobra.Command { if err != nil { return fmt.Errorf("invalid COMPLETION_REASON: %s", args[1]) } - } response, err := w.BundleDeployments.CompleteVersion(ctx, completeVersionReq) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -169,9 +169,9 @@ var createDeploymentOverrides []func( func newCreateDeployment() *cobra.Command { cmd := &cobra.Command{} - var createDeploymentReq bundledeployments.CreateDeploymentRequest createDeploymentReq.Deployment = bundledeployments.Deployment{} + var createDeploymentJson flags.JsonFlag cmd.Flags().Var(&createDeploymentJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -203,6 +203,7 @@ func newCreateDeployment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createDeploymentJson.Unmarshal(&createDeploymentReq.Deployment) @@ -221,7 +222,6 @@ func newCreateDeployment() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -248,9 +248,9 @@ var createVersionOverrides []func( func newCreateVersion() *cobra.Command { cmd := &cobra.Command{} - var createVersionReq bundledeployments.CreateVersionRequest createVersionReq.Version = bundledeployments.Version{} + var createVersionJson flags.JsonFlag cmd.Flags().Var(&createVersionJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -318,6 +318,7 @@ func newCreateVersion() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createVersionJson.Unmarshal(&createVersionReq.Version) @@ -341,14 +342,12 @@ func newCreateVersion() *cobra.Command { if err != nil { return fmt.Errorf("invalid VERSION_TYPE: %s", args[3]) } - } response, err := w.BundleDeployments.CreateVersion(ctx, createVersionReq) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -375,7 +374,6 @@ var deleteDeploymentOverrides []func( func newDeleteDeployment() *cobra.Command { cmd := &cobra.Command{} - var deleteDeploymentReq bundledeployments.DeleteDeploymentRequest cmd.Use = "delete-deployment NAME" @@ -401,6 +399,7 @@ func newDeleteDeployment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w deleteDeploymentReq.Name = args[0] @@ -434,7 +433,6 @@ var getDeploymentOverrides []func( func newGetDeployment() *cobra.Command { cmd := &cobra.Command{} - var getDeploymentReq bundledeployments.GetDeploymentRequest cmd.Use = "get-deployment NAME" @@ -460,6 +458,7 @@ func newGetDeployment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w getDeploymentReq.Name = args[0] @@ -467,7 +466,6 @@ func newGetDeployment() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -494,7 +492,6 @@ var getOperationOverrides []func( func newGetOperation() *cobra.Command { cmd := &cobra.Command{} - var getOperationReq bundledeployments.GetOperationRequest cmd.Use = "get-operation NAME" @@ -520,6 +517,7 @@ func newGetOperation() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w getOperationReq.Name = args[0] @@ -527,7 +525,6 @@ func newGetOperation() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -554,7 +551,6 @@ var getResourceOverrides []func( func newGetResource() *cobra.Command { cmd := &cobra.Command{} - var getResourceReq bundledeployments.GetResourceRequest cmd.Use = "get-resource NAME" @@ -580,6 +576,7 @@ func newGetResource() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w getResourceReq.Name = args[0] @@ -587,7 +584,6 @@ func newGetResource() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -614,7 +610,6 @@ var getVersionOverrides []func( func newGetVersion() *cobra.Command { cmd := &cobra.Command{} - var getVersionReq bundledeployments.GetVersionRequest cmd.Use = "get-version NAME" @@ -640,6 +635,7 @@ func newGetVersion() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w getVersionReq.Name = args[0] @@ -647,7 +643,6 @@ func newGetVersion() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -674,7 +669,6 @@ var heartbeatOverrides []func( func newHeartbeat() *cobra.Command { cmd := &cobra.Command{} - var heartbeatReq bundledeployments.HeartbeatRequest cmd.Use = "heartbeat NAME" @@ -704,6 +698,7 @@ func newHeartbeat() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w heartbeatReq.Name = args[0] @@ -711,7 +706,6 @@ func newHeartbeat() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -738,8 +732,8 @@ var listDeploymentsOverrides []func( func newListDeployments() *cobra.Command { cmd := &cobra.Command{} - var listDeploymentsReq bundledeployments.ListDeploymentsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -773,6 +767,7 @@ func newListDeployments() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w response := w.BundleDeployments.ListDeployments(ctx, listDeploymentsReq) if listDeploymentsLimit < 0 { @@ -781,8 +776,7 @@ func newListDeployments() *cobra.Command { if listDeploymentsLimit > 0 { ctx = cmdio.WithLimit(ctx, listDeploymentsLimit) } - - return cmdio.RenderIterator(ctx, response) + return cmdio.RenderListing(ctx, response) } // Disable completions since they are not applicable. @@ -808,8 +802,8 @@ var listOperationsOverrides []func( func newListOperations() *cobra.Command { cmd := &cobra.Command{} - var listOperationsReq bundledeployments.ListOperationsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -847,6 +841,7 @@ func newListOperations() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w listOperationsReq.Parent = args[0] @@ -857,8 +852,7 @@ func newListOperations() *cobra.Command { if listOperationsLimit > 0 { ctx = cmdio.WithLimit(ctx, listOperationsLimit) } - - return cmdio.RenderIterator(ctx, response) + return cmdio.RenderListing(ctx, response) } // Disable completions since they are not applicable. @@ -884,8 +878,8 @@ var listResourcesOverrides []func( func newListResources() *cobra.Command { cmd := &cobra.Command{} - var listResourcesReq bundledeployments.ListResourcesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -922,6 +916,7 @@ func newListResources() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w listResourcesReq.Parent = args[0] @@ -932,8 +927,7 @@ func newListResources() *cobra.Command { if listResourcesLimit > 0 { ctx = cmdio.WithLimit(ctx, listResourcesLimit) } - - return cmdio.RenderIterator(ctx, response) + return cmdio.RenderListing(ctx, response) } // Disable completions since they are not applicable. @@ -959,8 +953,8 @@ var listVersionsOverrides []func( func newListVersions() *cobra.Command { cmd := &cobra.Command{} - var listVersionsReq bundledeployments.ListVersionsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -998,6 +992,7 @@ func newListVersions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w listVersionsReq.Parent = args[0] @@ -1008,8 +1003,7 @@ func newListVersions() *cobra.Command { if listVersionsLimit > 0 { ctx = cmdio.WithLimit(ctx, listVersionsLimit) } - - return cmdio.RenderIterator(ctx, response) + return cmdio.RenderListing(ctx, response) } // Disable completions since they are not applicable. @@ -1035,9 +1029,9 @@ var updateDeploymentOverrides []func( func newUpdateDeployment() *cobra.Command { cmd := &cobra.Command{} - var updateDeploymentReq bundledeployments.UpdateDeploymentRequest updateDeploymentReq.Deployment = bundledeployments.Deployment{} + var updateDeploymentJson flags.JsonFlag cmd.Flags().Var(&updateDeploymentJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1064,6 +1058,7 @@ func newUpdateDeployment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateDeploymentJson.Unmarshal(&updateDeploymentReq.Deployment) @@ -1085,7 +1080,6 @@ func newUpdateDeployment() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1112,9 +1106,9 @@ var updateOperationOverrides []func( func newUpdateOperation() *cobra.Command { cmd := &cobra.Command{} - var updateOperationReq bundledeployments.UpdateOperationRequest updateOperationReq.Operation = bundledeployments.Operation{} + var updateOperationJson flags.JsonFlag cmd.Flags().Var(&updateOperationJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1156,6 +1150,7 @@ func newUpdateOperation() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateOperationJson.Unmarshal(&updateOperationReq.Operation) @@ -1177,7 +1172,6 @@ func newUpdateOperation() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/catalogs/catalogs.go b/cmd/workspace/catalogs/catalogs.go index 0bc03d53555..4f94a9b0377 100644 --- a/cmd/workspace/catalogs/catalogs.go +++ b/cmd/workspace/catalogs/catalogs.go @@ -8,10 +8,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + uccatalogs "github.com/databricks/cli/libs/sdktypes/uc/catalogs/v1" ) // Slice with functions to override default command behavior. @@ -59,26 +61,26 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateCatalog, + *uccatalogs.CreateCatalogRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq uccatalogs.CreateCatalogRequest - var createReq catalog.CreateCatalog 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.Comment, "comment", createReq.Comment, `User-provided free-form text description.`) - cmd.Flags().StringVar(&createReq.ConnectionName, "connection-name", createReq.ConnectionName, `The name of the connection to an external data source.`) - cmd.Flags().Int64Var(&createReq.CustomMaxRetentionHours, "custom-max-retention-hours", createReq.CustomMaxRetentionHours, `Custom maximum retention period in hours for the catalog.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Comment, "comment", `User-provided free-form text description.`) + flags.StringPtrVar(cmd.Flags(), &createReq.ConnectionName, "connection-name", `The name of the connection to an external data source.`) + flags.Int64PtrVar(cmd.Flags(), &createReq.CustomMaxRetentionHours, "custom-max-retention-hours", `Custom maximum retention period in hours for the catalog.`) // TODO: complex arg: managed_encryption_settings // TODO: map via StringToStringVar: options // TODO: map via StringToStringVar: properties - cmd.Flags().StringVar(&createReq.ProviderName, "provider-name", createReq.ProviderName, `The name of delta sharing provider.`) - cmd.Flags().StringVar(&createReq.ShareName, "share-name", createReq.ShareName, `The name of the share under the share provider.`) - cmd.Flags().StringVar(&createReq.StorageRoot, "storage-root", createReq.StorageRoot, `Storage root URL for managed tables within catalog.`) + flags.StringPtrVar(cmd.Flags(), &createReq.ProviderName, "provider-name", `The name of delta sharing provider.`) + flags.StringPtrVar(cmd.Flags(), &createReq.ShareName, "share-name", `The name of the share under the share provider.`) + flags.StringPtrVar(cmd.Flags(), &createReq.StorageRoot, "storage-root", `Storage root URL for managed tables within catalog.`) cmd.Use = "create NAME" cmd.Short = `Create a catalog.` @@ -110,6 +112,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -124,15 +127,23 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Name = args[0] + createReq.Name = new(args[0]) } - response, err := w.Catalogs.Create(ctx, createReq) + sdkReq, err := uccatalogs.CreateCatalogRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Catalogs.CreateCatalog(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccatalogs.CatalogInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -153,15 +164,14 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteCatalogRequest, + *uccatalogs.DeleteCatalogRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq uccatalogs.DeleteCatalogRequest - var deleteReq catalog.DeleteCatalogRequest - - cmd.Flags().BoolVar(&deleteReq.Force, "force", deleteReq.Force, `Force deletion even if the catalog is not empty.`) + flags.BoolPtrVar(cmd.Flags(), &deleteReq.Force, "force", `Force deletion even if the catalog is not empty.`) cmd.Use = "delete NAME" cmd.Short = `Delete a catalog.` @@ -186,13 +196,20 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Name = args[0] + deleteReq.NameArg = new(args[0]) - err = w.Catalogs.Delete(ctx, deleteReq) + sdkReq, err := uccatalogs.DeleteCatalogRequestToSDK(&deleteReq) if err != nil { return err } + response, err := w.Catalogs.DeleteCatalog(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -214,15 +231,14 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetCatalogRequest, + *uccatalogs.GetCatalogRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq uccatalogs.GetCatalogRequest - var getReq catalog.GetCatalogRequest - - cmd.Flags().BoolVar(&getReq.IncludeBrowse, "include-browse", getReq.IncludeBrowse, `Whether to include catalogs in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeBrowse, "include-browse", `Whether to include catalogs in the response for which the principal can only access selective metadata for.`) cmd.Use = "get NAME" cmd.Short = `Get a catalog.` @@ -248,15 +264,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Name = args[0] + getReq.NameArg = new(args[0]) - response, err := w.Catalogs.Get(ctx, getReq) + sdkReq, err := uccatalogs.GetCatalogRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.Catalogs.GetCatalog(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccatalogs.CatalogInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -277,28 +302,28 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListCatalogsRequest, + *uccatalogs.ListCatalogsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq uccatalogs.ListCatalogsRequest - var listReq catalog.ListCatalogsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().BoolVar(&listReq.IncludeBrowse, "include-browse", listReq.IncludeBrowse, `Whether to include catalogs in the response for which the principal can only access selective metadata for.`) - cmd.Flags().BoolVar(&listReq.IncludeUnbound, "include-unbound", listReq.IncludeUnbound, `Whether to include catalogs not bound to the workspace.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeBrowse, "include-browse", `Whether to include catalogs in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeUnbound, "include-unbound", `Whether to include catalogs not bound to the workspace.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of catalogs to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of catalogs to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list" @@ -332,16 +357,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Catalogs.List(ctx, listReq) + sdkReq, err := uccatalogs.ListCatalogsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Catalogs.ListCatalogsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, uccatalogs.CatalogInfoFromSDK)) } // Disable completions since they are not applicable. @@ -362,25 +391,25 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateCatalog, + *uccatalogs.UpdateCatalogRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq uccatalogs.UpdateCatalogRequest - var updateReq catalog.UpdateCatalog 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.Comment, "comment", updateReq.Comment, `User-provided free-form text description.`) - cmd.Flags().Int64Var(&updateReq.CustomMaxRetentionHours, "custom-max-retention-hours", updateReq.CustomMaxRetentionHours, `Custom maximum retention period in hours for the catalog.`) - cmd.Flags().Var(&updateReq.EnablePredictiveOptimization, "enable-predictive-optimization", `Whether predictive optimization should be enabled for this object and objects under it. Supported values: [DISABLE, ENABLE, INHERIT]`) - cmd.Flags().Var(&updateReq.IsolationMode, "isolation-mode", `Whether the current securable is accessible from all workspaces or a specific set of workspaces. Supported values: [ISOLATED, OPEN]`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Comment, "comment", `User-provided free-form text description.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.CustomMaxRetentionHours, "custom-max-retention-hours", `Custom maximum retention period in hours for the catalog.`) + flags.EnumPtrVar(cmd.Flags(), &updateReq.EnablePredictiveOptimization, "enable-predictive-optimization", `Whether predictive optimization should be enabled for this object and objects under it. Supported values: [DISABLE, ENABLE, INHERIT]`, "EnablePredictiveOptimization", "DISABLE", "ENABLE", "INHERIT") + flags.EnumVar(cmd.Flags(), &updateReq.IsolationMode, "isolation-mode", `Whether the current securable is accessible from all workspaces or a specific set of workspaces. Supported values: [ISOLATED, OPEN]`, "CatalogIsolationMode", "ISOLATED", "OPEN") // TODO: complex arg: managed_encryption_settings - cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the catalog.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.NewName, "new-name", `New name for the catalog.`) // TODO: map via StringToStringVar: options - cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of current owner of catalog.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `Username of current owner of catalog.`) // TODO: map via StringToStringVar: properties cmd.Use = "update NAME" @@ -407,6 +436,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -420,14 +450,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.Name = args[0] + updateReq.NameArg = new(args[0]) - response, err := w.Catalogs.Update(ctx, updateReq) + sdkReq, err := uccatalogs.UpdateCatalogRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Catalogs.UpdateCatalog(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccatalogs.CatalogInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/catalogs/overrides.go b/cmd/workspace/catalogs/overrides.go index e2201dc152e..f50ed273b68 100644 --- a/cmd/workspace/catalogs/overrides.go +++ b/cmd/workspace/catalogs/overrides.go @@ -2,11 +2,11 @@ package catalogs import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/catalog" + uccatalogs "github.com/databricks/cli/libs/sdktypes/uc/catalogs/v1" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *catalog.ListCatalogsRequest) { +func listOverride(listCmd *cobra.Command, listReq *uccatalogs.ListCatalogsRequest) { listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "Name"}} {{header "Type"}} {{header "Comment"}}`) listCmd.Annotations["template"] = cmdio.Heredoc(` diff --git a/cmd/workspace/clean-room-asset-revisions/clean-room-asset-revisions.go b/cmd/workspace/clean-room-asset-revisions/clean-room-asset-revisions.go index 8379f87849f..07911cfc53c 100644 --- a/cmd/workspace/clean-room-asset-revisions/clean-room-asset-revisions.go +++ b/cmd/workspace/clean-room-asset-revisions/clean-room-asset-revisions.go @@ -7,9 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/cleanrooms" + "github.com/databricks/cli/libs/flags" "github.com/spf13/cobra" + + cleanrooms "github.com/databricks/cli/libs/sdktypes/cleanrooms/v1" + sdkcleanrooms "github.com/databricks/sdk-go/cleanrooms/v1" ) // Slice with functions to override default command behavior. @@ -50,13 +54,12 @@ Clean Room Asset Revisions denote new versions of uploaded assets (e.g. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *cleanrooms.GetCleanRoomAssetRevisionRequest, + *sdkcleanrooms.GetCleanRoomAssetRevisionRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq cleanrooms.GetCleanRoomAssetRevisionRequest + var getReq sdkcleanrooms.GetCleanRoomAssetRevisionRequest cmd.Use = "get CLEAN_ROOM_NAME ASSET_TYPE NAME ETAG" cmd.Short = `*Beta* Get an asset revision.` @@ -94,22 +97,24 @@ Get an asset revision. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.CleanRoomName = args[0] - _, err = fmt.Sscan(args[1], &getReq.AssetType) + getReq.CleanRoomName = new(args[0]) + getReq.AssetType = sdkcleanrooms.CleanRoomAsset_AssetType(args[1]) + getReq.Name = new(args[2]) + getReq.Etag = new(args[3]) + + sdkReq := &getReq + response, err := w.CleanRooms.GetCleanRoomAssetRevision(ctx, *sdkReq) if err != nil { - return fmt.Errorf("invalid ASSET_TYPE: %s", args[1]) + return err } - getReq.Name = args[2] - getReq.Etag = args[3] - - response, err := w.CleanRoomAssetRevisions.Get(ctx, getReq) + out, err := cleanrooms.CleanRoomAssetFromSDK(response) if err != nil { return err } - - return cmdio.Render(ctx, response) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -135,20 +140,20 @@ var listOverrides []func( func newList() *cobra.Command { cmd := &cobra.Command{} - var listReq cleanrooms.ListCleanRoomAssetRevisionsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `Maximum number of asset revisions to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", `Maximum number of asset revisions to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list CLEAN_ROOM_NAME ASSET_TYPE NAME" @@ -185,24 +190,24 @@ List asset revisions. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + listReq.CleanRoomName = new(args[0]) + listReq.AssetType = cleanrooms.CleanRoomAsset_AssetType(args[1]) + listReq.Name = new(args[2]) - listReq.CleanRoomName = args[0] - _, err = fmt.Sscan(args[1], &listReq.AssetType) + sdkReq, err := cleanrooms.ListCleanRoomAssetRevisionsRequestToSDK(&listReq) if err != nil { - return fmt.Errorf("invalid ASSET_TYPE: %s", args[1]) + return err } - - listReq.Name = args[2] - - response := w.CleanRoomAssetRevisions.List(ctx, listReq) if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.CleanRooms.ListCleanRoomAssetRevisionsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, cleanrooms.CleanRoomAssetFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/clean-room-assets/clean-room-assets.go b/cmd/workspace/clean-room-assets/clean-room-assets.go index cc8c6f7f334..c0f8ef26d4b 100644 --- a/cmd/workspace/clean-room-assets/clean-room-assets.go +++ b/cmd/workspace/clean-room-assets/clean-room-assets.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/cleanrooms" "github.com/spf13/cobra" + + cleanrooms "github.com/databricks/cli/libs/sdktypes/cleanrooms/v1" + sdkcleanrooms "github.com/databricks/sdk-go/cleanrooms/v1" ) // Slice with functions to override default command behavior. @@ -59,14 +62,14 @@ var createOverrides []func( func newCreate() *cobra.Command { cmd := &cobra.Command{} - var createReq cleanrooms.CreateCleanRoomAssetRequest - createReq.Asset = cleanrooms.CleanRoomAsset{} + createReq.Asset = &cleanrooms.CleanRoomAsset{} + 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.Asset.CleanRoomName, "clean-room-name", createReq.Asset.CleanRoomName, `The name of the clean room this asset belongs to.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Asset.CleanRoomName, "clean-room-name", `The name of the clean room this asset belongs to.`) // TODO: complex arg: foreign_table // TODO: complex arg: foreign_table_local_details // TODO: complex arg: jar_analysis @@ -129,6 +132,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.Asset) @@ -142,24 +146,28 @@ func newCreate() *cobra.Command { } } } - createReq.CleanRoomName = args[0] + createReq.Asset.CleanRoomName = new(args[0]) if !cmd.Flags().Changed("json") { - createReq.Asset.Name = args[1] + createReq.Asset.Name = new(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &createReq.Asset.AssetType) - if err != nil { - return fmt.Errorf("invalid ASSET_TYPE: %s", args[2]) - } - + createReq.Asset.AssetType = cleanrooms.CleanRoomAsset_AssetType(args[2]) } - response, err := w.CleanRoomAssets.Create(ctx, createReq) + sdkReq, err := cleanrooms.CreateCleanRoomAssetRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.CleanRooms.CreateCleanRoomAsset(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := cleanrooms.CleanRoomAssetFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -185,8 +193,8 @@ var createCleanRoomAssetReviewOverrides []func( func newCreateCleanRoomAssetReview() *cobra.Command { cmd := &cobra.Command{} - var createCleanRoomAssetReviewReq cleanrooms.CreateCleanRoomAssetReviewRequest + var createCleanRoomAssetReviewJson flags.JsonFlag cmd.Flags().Var(&createCleanRoomAssetReviewJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -228,6 +236,7 @@ Create a review (e.g. approval) for an asset. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createCleanRoomAssetReviewJson.Unmarshal(&createCleanRoomAssetReviewReq) @@ -241,20 +250,24 @@ Create a review (e.g. approval) for an asset. } } } - createCleanRoomAssetReviewReq.CleanRoomName = args[0] - _, err = fmt.Sscan(args[1], &createCleanRoomAssetReviewReq.AssetType) + createCleanRoomAssetReviewReq.CleanRoomName = new(args[0]) + createCleanRoomAssetReviewReq.AssetType = cleanrooms.CleanRoomAsset_AssetType(args[1]) + createCleanRoomAssetReviewReq.Name = new(args[2]) + + sdkReq, err := cleanrooms.CreateCleanRoomAssetReviewRequestToSDK(&createCleanRoomAssetReviewReq) if err != nil { - return fmt.Errorf("invalid ASSET_TYPE: %s", args[1]) + return err } - - createCleanRoomAssetReviewReq.Name = args[2] - - response, err := w.CleanRoomAssets.CreateCleanRoomAssetReview(ctx, createCleanRoomAssetReviewReq) + response, err := w.CleanRooms.CreateCleanRoomAssetReview(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := cleanrooms.CreateCleanRoomAssetReviewResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -275,13 +288,12 @@ Create a review (e.g. approval) for an asset. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *cleanrooms.DeleteCleanRoomAssetRequest, + *sdkcleanrooms.DeleteCleanRoomAssetRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq cleanrooms.DeleteCleanRoomAssetRequest + var deleteReq sdkcleanrooms.DeleteCleanRoomAssetRequest cmd.Use = "delete CLEAN_ROOM_NAME ASSET_TYPE NAME" cmd.Short = `Delete an asset.` @@ -316,19 +328,19 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.CleanRoomName = args[0] - _, err = fmt.Sscan(args[1], &deleteReq.AssetType) - if err != nil { - return fmt.Errorf("invalid ASSET_TYPE: %s", args[1]) - } - - deleteReq.Name = args[2] + deleteReq.CleanRoomName = new(args[0]) + deleteReq.AssetType = sdkcleanrooms.CleanRoomAsset_AssetType(args[1]) + deleteReq.Name = new(args[2]) - err = w.CleanRoomAssets.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.CleanRooms.DeleteCleanRoomAsset(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -350,13 +362,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *cleanrooms.GetCleanRoomAssetRequest, + *sdkcleanrooms.GetCleanRoomAssetRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq cleanrooms.GetCleanRoomAssetRequest + var getReq sdkcleanrooms.GetCleanRoomAssetRequest cmd.Use = "get CLEAN_ROOM_NAME ASSET_TYPE NAME" cmd.Short = `Get an asset.` @@ -391,21 +402,23 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getReq.CleanRoomName = new(args[0]) + getReq.AssetType = sdkcleanrooms.CleanRoomAsset_AssetType(args[1]) + getReq.Name = new(args[2]) - getReq.CleanRoomName = args[0] - _, err = fmt.Sscan(args[1], &getReq.AssetType) + sdkReq := &getReq + response, err := w.CleanRooms.GetCleanRoomAsset(ctx, *sdkReq) if err != nil { - return fmt.Errorf("invalid ASSET_TYPE: %s", args[1]) + return err } - getReq.Name = args[2] - - response, err := w.CleanRoomAssets.Get(ctx, getReq) + out, err := cleanrooms.CleanRoomAssetFromSDK(response) if err != nil { return err } - - return cmdio.Render(ctx, response) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -431,8 +444,8 @@ var listOverrides []func( func newList() *cobra.Command { cmd := &cobra.Command{} - var listReq cleanrooms.ListCleanRoomAssetsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -442,7 +455,7 @@ func newList() *cobra.Command { cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list CLEAN_ROOM_NAME" @@ -465,18 +478,22 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.CleanRoomName = args[0] + listReq.CleanRoomName = new(args[0]) - response := w.CleanRoomAssets.List(ctx, listReq) + sdkReq, err := cleanrooms.ListCleanRoomAssetsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.CleanRooms.ListCleanRoomAssetsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, cleanrooms.CleanRoomAssetFromSDK)) } // Disable completions since they are not applicable. @@ -502,14 +519,14 @@ var updateOverrides []func( func newUpdate() *cobra.Command { cmd := &cobra.Command{} - var updateReq cleanrooms.UpdateCleanRoomAssetRequest - updateReq.Asset = cleanrooms.CleanRoomAsset{} + updateReq.Asset = &cleanrooms.CleanRoomAsset{} + 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.Asset.CleanRoomName, "clean-room-name", updateReq.Asset.CleanRoomName, `The name of the clean room this asset belongs to.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CleanRoomName, "clean-room-name", `The name of the clean room this asset belongs to.`) // TODO: complex arg: foreign_table // TODO: complex arg: foreign_table_local_details // TODO: complex arg: jar_analysis @@ -561,6 +578,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.Asset) @@ -574,20 +592,24 @@ func newUpdate() *cobra.Command { } } } - updateReq.CleanRoomName = args[0] - _, err = fmt.Sscan(args[1], &updateReq.AssetType) + updateReq.CleanRoomName = new(args[0]) + updateReq.Asset.AssetType = cleanrooms.CleanRoomAsset_AssetType(args[1]) + updateReq.Asset.Name = new(args[2]) + + sdkReq, err := cleanrooms.UpdateCleanRoomAssetRequestToSDK(&updateReq) if err != nil { - return fmt.Errorf("invalid ASSET_TYPE: %s", args[1]) + return err } - - updateReq.Name = args[2] - - response, err := w.CleanRoomAssets.Update(ctx, updateReq) + response, err := w.CleanRooms.UpdateCleanRoomAsset(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := cleanrooms.CleanRoomAssetFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/clean-room-auto-approval-rules/clean-room-auto-approval-rules.go b/cmd/workspace/clean-room-auto-approval-rules/clean-room-auto-approval-rules.go index 6ffea68d40d..37bbd2052c2 100644 --- a/cmd/workspace/clean-room-auto-approval-rules/clean-room-auto-approval-rules.go +++ b/cmd/workspace/clean-room-auto-approval-rules/clean-room-auto-approval-rules.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/cleanrooms" "github.com/spf13/cobra" + + cleanrooms "github.com/databricks/cli/libs/sdktypes/cleanrooms/v1" + sdkcleanrooms "github.com/databricks/sdk-go/cleanrooms/v1" ) // Slice with functions to override default command behavior. @@ -61,8 +64,8 @@ var createOverrides []func( func newCreate() *cobra.Command { cmd := &cobra.Command{} - var createReq cleanrooms.CreateCleanRoomAutoApprovalRuleRequest + var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -91,6 +94,7 @@ Create an auto-approval rule. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -106,14 +110,22 @@ Create an auto-approval rule. } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - createReq.CleanRoomName = args[0] + createReq.AutoApprovalRule.CleanRoomName = new(args[0]) - response, err := w.CleanRoomAutoApprovalRules.Create(ctx, createReq) + sdkReq, err := cleanrooms.CreateCleanRoomAutoApprovalRuleRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.CleanRooms.CreateCleanRoomAutoApprovalRule(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := cleanrooms.CleanRoomAutoApprovalRuleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -134,13 +146,12 @@ Create an auto-approval rule. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *cleanrooms.DeleteCleanRoomAutoApprovalRuleRequest, + *sdkcleanrooms.DeleteCleanRoomAutoApprovalRuleRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq cleanrooms.DeleteCleanRoomAutoApprovalRuleRequest + var deleteReq sdkcleanrooms.DeleteCleanRoomAutoApprovalRuleRequest cmd.Use = "delete CLEAN_ROOM_NAME RULE_ID" cmd.Short = `*Beta* Delete an auto-approval rule.` @@ -163,11 +174,13 @@ Delete an auto-approval rule. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.CleanRoomName = args[0] - deleteReq.RuleId = args[1] + deleteReq.CleanRoomName = new(args[0]) + deleteReq.RuleId = new(args[1]) - err = w.CleanRoomAutoApprovalRules.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = w.CleanRooms.DeleteCleanRoomAutoApprovalRule(ctx, *sdkReq) if err != nil { return err } @@ -192,13 +205,12 @@ Delete an auto-approval rule. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *cleanrooms.GetCleanRoomAutoApprovalRuleRequest, + *sdkcleanrooms.GetCleanRoomAutoApprovalRuleRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq cleanrooms.GetCleanRoomAutoApprovalRuleRequest + var getReq sdkcleanrooms.GetCleanRoomAutoApprovalRuleRequest cmd.Use = "get CLEAN_ROOM_NAME RULE_ID" cmd.Short = `*Beta* Get an auto-approval rule.` @@ -221,16 +233,22 @@ Get an auto-approval rule. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.CleanRoomName = args[0] - getReq.RuleId = args[1] + getReq.CleanRoomName = new(args[0]) + getReq.RuleId = new(args[1]) - response, err := w.CleanRoomAutoApprovalRules.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.CleanRooms.GetCleanRoomAutoApprovalRule(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := cleanrooms.CleanRoomAutoApprovalRuleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -256,20 +274,20 @@ var listOverrides []func( func newList() *cobra.Command { cmd := &cobra.Command{} - var listReq cleanrooms.ListCleanRoomAutoApprovalRulesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `Maximum number of auto-approval rules to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", `Maximum number of auto-approval rules to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list CLEAN_ROOM_NAME" @@ -293,18 +311,22 @@ List auto-approval rules. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.CleanRoomName = args[0] + listReq.CleanRoomName = new(args[0]) - response := w.CleanRoomAutoApprovalRules.List(ctx, listReq) + sdkReq, err := cleanrooms.ListCleanRoomAutoApprovalRulesRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.CleanRooms.ListCleanRoomAutoApprovalRulesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, cleanrooms.CleanRoomAutoApprovalRuleFromSDK)) } // Disable completions since they are not applicable. @@ -330,17 +352,17 @@ var updateOverrides []func( func newUpdate() *cobra.Command { cmd := &cobra.Command{} - var updateReq cleanrooms.UpdateCleanRoomAutoApprovalRuleRequest - updateReq.AutoApprovalRule = cleanrooms.CleanRoomAutoApprovalRule{} + updateReq.AutoApprovalRule = &cleanrooms.CleanRoomAutoApprovalRule{} + 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.AutoApprovalRule.AuthorCollaboratorAlias, "author-collaborator-alias", updateReq.AutoApprovalRule.AuthorCollaboratorAlias, `Collaborator alias of the author covered by the rule.`) - cmd.Flags().Var(&updateReq.AutoApprovalRule.AuthorScope, "author-scope", `Scope of authors covered by the rule. Supported values: [ANY_AUTHOR]`) - cmd.Flags().StringVar(&updateReq.AutoApprovalRule.CleanRoomName, "clean-room-name", updateReq.AutoApprovalRule.CleanRoomName, `The name of the clean room this auto-approval rule belongs to.`) - cmd.Flags().StringVar(&updateReq.AutoApprovalRule.RunnerCollaboratorAlias, "runner-collaborator-alias", updateReq.AutoApprovalRule.RunnerCollaboratorAlias, `Collaborator alias of the runner covered by the rule.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.AutoApprovalRule.AuthorCollaboratorAlias, "author-collaborator-alias", `Collaborator alias of the author covered by the rule.`) + flags.EnumVar(cmd.Flags(), &updateReq.AutoApprovalRule.AuthorScope, "author-scope", `Scope of authors covered by the rule. Supported values: [ANY_AUTHOR]`, "CleanRoomAutoApprovalRuleAuthorScope", "ANY_AUTHOR") + flags.StringPtrVar(cmd.Flags(), &updateReq.AutoApprovalRule.CleanRoomName, "clean-room-name", `The name of the clean room this auto-approval rule belongs to.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.AutoApprovalRule.RunnerCollaboratorAlias, "runner-collaborator-alias", `Collaborator alias of the runner covered by the rule.`) cmd.Use = "update CLEAN_ROOM_NAME RULE_ID" cmd.Short = `*Beta* Update an auto-approval rule.` @@ -367,6 +389,7 @@ Update an auto-approval rule. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.AutoApprovalRule) @@ -380,15 +403,23 @@ Update an auto-approval rule. } } } - updateReq.CleanRoomName = args[0] - updateReq.RuleId = args[1] + updateReq.AutoApprovalRule.CleanRoomName = new(args[0]) + updateReq.AutoApprovalRule.RuleId = new(args[1]) - response, err := w.CleanRoomAutoApprovalRules.Update(ctx, updateReq) + sdkReq, err := cleanrooms.UpdateCleanRoomAutoApprovalRuleRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.CleanRooms.UpdateCleanRoomAutoApprovalRule(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := cleanrooms.CleanRoomAutoApprovalRuleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/clean-room-task-runs/clean-room-task-runs.go b/cmd/workspace/clean-room-task-runs/clean-room-task-runs.go index 1ab6b639bc6..52d8e24d14f 100644 --- a/cmd/workspace/clean-room-task-runs/clean-room-task-runs.go +++ b/cmd/workspace/clean-room-task-runs/clean-room-task-runs.go @@ -7,9 +7,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/cleanrooms" + "github.com/databricks/cli/libs/flags" "github.com/spf13/cobra" + + cleanrooms "github.com/databricks/cli/libs/sdktypes/cleanrooms/v1" ) // Slice with functions to override default command behavior. @@ -53,21 +56,21 @@ var listOverrides []func( func newList() *cobra.Command { cmd := &cobra.Command{} - var listReq cleanrooms.ListCleanRoomNotebookTaskRunsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.NotebookName, "notebook-name", listReq.NotebookName, `Notebook name.`) - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `The maximum number of task runs to return.`) + flags.StringPtrVar(cmd.Flags(), &listReq.NotebookName, "notebook-name", `Notebook name.`) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", `The maximum number of task runs to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list CLEAN_ROOM_NAME" @@ -92,18 +95,22 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.CleanRoomName = args[0] + listReq.CleanRoomName = new(args[0]) - response := w.CleanRoomTaskRuns.List(ctx, listReq) + sdkReq, err := cleanrooms.ListCleanRoomNotebookTaskRunsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.CleanRooms.ListCleanRoomNotebookTaskRunsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, cleanrooms.CleanRoomNotebookTaskRunFromSDK)) } // Disable completions since they are not applicable. @@ -129,22 +136,22 @@ var listCleanRoomTaskRunsHandlerOverrides []func( func newListCleanRoomTaskRunsHandler() *cobra.Command { cmd := &cobra.Command{} - var listCleanRoomTaskRunsHandlerReq cleanrooms.ListCleanRoomTaskRunsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listCleanRoomTaskRunsHandlerLimit int - cmd.Flags().StringVar(&listCleanRoomTaskRunsHandlerReq.Name, "name", listCleanRoomTaskRunsHandlerReq.Name, `Executable name.`) - cmd.Flags().IntVar(&listCleanRoomTaskRunsHandlerReq.PageSize, "page-size", listCleanRoomTaskRunsHandlerReq.PageSize, `The maximum number of task runs to return.`) - cmd.Flags().Var(&listCleanRoomTaskRunsHandlerReq.TaskType, "task-type", `Filter by the type of Clean Room task. Supported values: [JAR, NOTEBOOK]`) + flags.StringPtrVar(cmd.Flags(), &listCleanRoomTaskRunsHandlerReq.Name, "name", `Executable name.`) + flags.IntPtrVar(cmd.Flags(), &listCleanRoomTaskRunsHandlerReq.PageSize, "page-size", `The maximum number of task runs to return.`) + flags.EnumVar(cmd.Flags(), &listCleanRoomTaskRunsHandlerReq.TaskType, "task-type", `Filter by the type of Clean Room task. Supported values: [JAR, NOTEBOOK]`, "CleanRoomTaskType", "JAR", "NOTEBOOK") // Limit flag for total result capping. cmd.Flags().IntVar(&listCleanRoomTaskRunsHandlerLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listCleanRoomTaskRunsHandlerReq.PageToken, "page-token", listCleanRoomTaskRunsHandlerReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listCleanRoomTaskRunsHandlerReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-clean-room-task-runs-handler CLEAN_ROOM_NAME" @@ -169,18 +176,22 @@ func newListCleanRoomTaskRunsHandler() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listCleanRoomTaskRunsHandlerReq.CleanRoomName = args[0] + listCleanRoomTaskRunsHandlerReq.CleanRoomName = new(args[0]) - response := w.CleanRoomTaskRuns.ListCleanRoomTaskRunsHandler(ctx, listCleanRoomTaskRunsHandlerReq) + sdkReq, err := cleanrooms.ListCleanRoomTaskRunsRequestToSDK(&listCleanRoomTaskRunsHandlerReq) + if err != nil { + return err + } if listCleanRoomTaskRunsHandlerLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listCleanRoomTaskRunsHandlerLimit) } if listCleanRoomTaskRunsHandlerLimit > 0 { ctx = cmdio.WithLimit(ctx, listCleanRoomTaskRunsHandlerLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.CleanRooms.ListCleanRoomTaskRunsHandlerIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, cleanrooms.CleanRoomTaskRunFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/clean-rooms/clean-rooms.go b/cmd/workspace/clean-rooms/clean-rooms.go index aa904968b58..6b27741f62d 100644 --- a/cmd/workspace/clean-rooms/clean-rooms.go +++ b/cmd/workspace/clean-rooms/clean-rooms.go @@ -7,11 +7,17 @@ import ( "time" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/cleanrooms" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + cleanrooms "github.com/databricks/cli/libs/sdktypes/cleanrooms/v1" + sdkcleanrooms "github.com/databricks/sdk-go/cleanrooms/v1" ) // Slice with functions to override default command behavior. @@ -60,9 +66,9 @@ var createOverrides []func( func newCreate() *cobra.Command { cmd := &cobra.Command{} - var createReq cleanrooms.CreateCleanRoomRequest - createReq.CleanRoom = cleanrooms.CleanRoom{} + createReq.CleanRoom = &cleanrooms.CleanRoom{} + var createJson flags.JsonFlag var createSkipWait bool @@ -73,11 +79,11 @@ 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.CleanRoom.Comment, "comment", createReq.CleanRoom.Comment, ``) - cmd.Flags().BoolVar(&createReq.CleanRoom.EnableSharedOutput, "enable-shared-output", createReq.CleanRoom.EnableSharedOutput, `Whether allow task to write to shared output schema.`) - cmd.Flags().StringVar(&createReq.CleanRoom.Name, "name", createReq.CleanRoom.Name, `The name of the clean room.`) + flags.StringPtrVar(cmd.Flags(), &createReq.CleanRoom.Comment, "comment", ``) + flags.BoolPtrVar(cmd.Flags(), &createReq.CleanRoom.EnableSharedOutput, "enable-shared-output", `Whether allow task to write to shared output schema.`) + flags.StringPtrVar(cmd.Flags(), &createReq.CleanRoom.Name, "name", `The name of the clean room.`) // TODO: complex arg: output_catalog - 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.`) + flags.StringPtrVar(cmd.Flags(), &createReq.CleanRoom.Owner, "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" @@ -109,6 +115,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.CleanRoom) @@ -123,24 +130,39 @@ func newCreate() *cobra.Command { } } - wait, err := w.CleanRooms.Create(ctx, createReq) + sdkReq, err := cleanrooms.CreateCleanRoomRequestToSDK(&createReq) if err != nil { return err } if createSkipWait { - return cmdio.Render(ctx, wait.Response) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var current cleanrooms.CleanRoom + err = api.Do(ctx, "POST", "/api/2.0/clean-rooms", auth.WorkspaceIDHeaders(w.Config), nil, createReq.CleanRoom, ¤t) + if err != nil { + return err + } + return cmdio.Render(ctx, current) + } + wait, err := w.CleanRooms.CreateCleanRoom(ctx, *sdkReq) + if err != nil { + return err } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *cleanrooms.CleanRoom) { - status := i.Status - statusMessage := fmt.Sprintf("current status: %s", status) - sp.Update(statusMessage) - }).GetWithTimeout(createTimeout) + sp.Update("Waiting for create to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := cleanrooms.CleanRoomFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -166,14 +188,14 @@ var createOutputCatalogOverrides []func( func newCreateOutputCatalog() *cobra.Command { cmd := &cobra.Command{} - var createOutputCatalogReq cleanrooms.CreateCleanRoomOutputCatalogRequest - createOutputCatalogReq.OutputCatalog = cleanrooms.CleanRoomOutputCatalog{} + createOutputCatalogReq.OutputCatalog = &cleanrooms.CleanRoomOutputCatalog{} + var createOutputCatalogJson flags.JsonFlag cmd.Flags().Var(&createOutputCatalogJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createOutputCatalogReq.OutputCatalog.CatalogName, "catalog-name", createOutputCatalogReq.OutputCatalog.CatalogName, `The name of the output catalog in UC.`) + flags.StringPtrVar(cmd.Flags(), &createOutputCatalogReq.OutputCatalog.CatalogName, "catalog-name", `The name of the output catalog in UC.`) cmd.Use = "create-output-catalog CLEAN_ROOM_NAME" cmd.Short = `Create an output catalog.` @@ -197,6 +219,7 @@ func newCreateOutputCatalog() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createOutputCatalogJson.Unmarshal(&createOutputCatalogReq.OutputCatalog) @@ -210,14 +233,22 @@ func newCreateOutputCatalog() *cobra.Command { } } } - createOutputCatalogReq.CleanRoomName = args[0] + createOutputCatalogReq.CleanRoomName = new(args[0]) - response, err := w.CleanRooms.CreateOutputCatalog(ctx, createOutputCatalogReq) + sdkReq, err := cleanrooms.CreateCleanRoomOutputCatalogRequestToSDK(&createOutputCatalogReq) + if err != nil { + return err + } + response, err := w.CleanRooms.CreateCleanRoomOutputCatalog(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := cleanrooms.CreateCleanRoomOutputCatalogResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -238,13 +269,12 @@ func newCreateOutputCatalog() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *cleanrooms.DeleteCleanRoomRequest, + *sdkcleanrooms.DeleteCleanRoomRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq cleanrooms.DeleteCleanRoomRequest + var deleteReq sdkcleanrooms.DeleteCleanRoomRequest cmd.Use = "delete NAME" cmd.Short = `Delete a clean room.` @@ -271,10 +301,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Name = args[0] + deleteReq.Name = new(args[0]) - err = w.CleanRooms.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = w.CleanRooms.DeleteCleanRoom(ctx, *sdkReq) if err != nil { return err } @@ -299,13 +331,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *cleanrooms.GetCleanRoomRequest, + *sdkcleanrooms.GetCleanRoomRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq cleanrooms.GetCleanRoomRequest + var getReq sdkcleanrooms.GetCleanRoomRequest cmd.Use = "get NAME" cmd.Short = `Get a clean room.` @@ -326,15 +357,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Name = args[0] + getReq.Name = new(args[0]) - response, err := w.CleanRooms.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.CleanRooms.GetCleanRoom(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := cleanrooms.CleanRoomFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -360,20 +397,20 @@ var listOverrides []func( func newList() *cobra.Command { cmd := &cobra.Command{} - var listReq cleanrooms.ListCleanRoomsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `Maximum number of clean rooms to return (i.e., the page length).`) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", `Maximum number of clean rooms to return (i.e., the page length).`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -396,16 +433,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.CleanRooms.List(ctx, listReq) + sdkReq, err := cleanrooms.ListCleanRoomsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.CleanRooms.ListCleanRoomsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, cleanrooms.CleanRoomFromSDK)) } // Disable completions since they are not applicable. @@ -431,8 +472,8 @@ var updateOverrides []func( func newUpdate() *cobra.Command { cmd := &cobra.Command{} - var updateReq cleanrooms.UpdateCleanRoomRequest + var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -464,6 +505,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -477,14 +519,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.Name = args[0] + updateReq.Name = new(args[0]) - response, err := w.CleanRooms.Update(ctx, updateReq) + sdkReq, err := cleanrooms.UpdateCleanRoomRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.CleanRooms.UpdateCleanRoom(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := cleanrooms.CleanRoomFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/cluster-policies/cluster-policies.go b/cmd/workspace/cluster-policies/cluster-policies.go index c601693c28c..63b3feb8cfd 100644 --- a/cmd/workspace/cluster-policies/cluster-policies.go +++ b/cmd/workspace/cluster-policies/cluster-policies.go @@ -10,8 +10,11 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + clusterpolicies "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" ) // Slice with functions to override default command behavior. @@ -78,24 +81,24 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *compute.CreatePolicy, + *clusterpolicies.CreatePolicyRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq clusterpolicies.CreatePolicyRequest - var createReq compute.CreatePolicy 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.Definition, "definition", createReq.Definition, `Policy definition document expressed in [Databricks Cluster Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html).`) - cmd.Flags().StringVar(&createReq.Description, "description", createReq.Description, `Additional human-readable description of the cluster policy.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Definition, "definition", `Policy definition document expressed in [Databricks Cluster Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html).`) + flags.StringPtrVar(cmd.Flags(), &createReq.Description, "description", `Additional human-readable description of the cluster policy.`) // TODO: array: libraries - cmd.Flags().Int64Var(&createReq.MaxClustersPerUser, "max-clusters-per-user", createReq.MaxClustersPerUser, `Max number of clusters per user that can be active using this policy.`) - cmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `Cluster Policy name requested by the user.`) - cmd.Flags().StringVar(&createReq.PolicyFamilyDefinitionOverrides, "policy-family-definition-overrides", createReq.PolicyFamilyDefinitionOverrides, `Policy definition JSON document expressed in [Databricks Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html).`) - cmd.Flags().StringVar(&createReq.PolicyFamilyId, "policy-family-id", createReq.PolicyFamilyId, `ID of the policy family.`) + flags.Int64PtrVar(cmd.Flags(), &createReq.MaxClustersPerUser, "max-clusters-per-user", `Max number of clusters per user that can be active using this policy.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Name, "name", `Cluster Policy name requested by the user.`) + flags.StringPtrVar(cmd.Flags(), &createReq.PolicyFamilyDefinitionOverrides, "policy-family-definition-overrides", `Policy definition JSON document expressed in [Databricks Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html).`) + flags.StringPtrVar(cmd.Flags(), &createReq.PolicyFamilyId, "policy-family-id", `ID of the policy family.`) cmd.Use = "create" cmd.Short = `Create a new policy.` @@ -116,6 +119,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -130,12 +134,20 @@ func newCreate() *cobra.Command { } } - response, err := w.ClusterPolicies.Create(ctx, createReq) + sdkReq, err := clusterpolicies.CreatePolicyRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.ClusterPolicies.CreatePolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := clusterpolicies.CreatePolicyResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -156,13 +168,13 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *compute.DeletePolicy, + *clusterpolicies.DeletePolicyRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq clusterpolicies.DeletePolicyRequest - var deleteReq compute.DeletePolicy var deleteJson flags.JsonFlag cmd.Flags().Var(&deleteJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -189,13 +201,15 @@ func newDelete() *cobra.Command { } return nil } - 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) + _ = w if cmd.Flags().Changed("json") { diags := deleteJson.Unmarshal(&deleteReq) @@ -208,31 +222,21 @@ func newDelete() *cobra.Command { return err } } - } else { - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No POLICY_ID argument specified. Loading names for Cluster Policies drop-down.") - names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID of the policy to delete") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id of the policy to delete") - } - deleteReq.PolicyId = args[0] + } + if !cmd.Flags().Changed("json") { + deleteReq.PolicyId = new(args[0]) } - err = w.ClusterPolicies.Delete(ctx, deleteReq) + sdkReq, err := clusterpolicies.DeletePolicyRequestToSDK(&deleteReq) + if err != nil { + return err + } + response, err := w.ClusterPolicies.DeletePolicy(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -254,24 +258,24 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var editOverrides []func( *cobra.Command, - *compute.EditPolicy, + *clusterpolicies.EditPolicyRequest, ) func newEdit() *cobra.Command { cmd := &cobra.Command{} + var editReq clusterpolicies.EditPolicyRequest - var editReq compute.EditPolicy var editJson flags.JsonFlag cmd.Flags().Var(&editJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&editReq.Definition, "definition", editReq.Definition, `Policy definition document expressed in [Databricks Cluster Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html).`) - cmd.Flags().StringVar(&editReq.Description, "description", editReq.Description, `Additional human-readable description of the cluster policy.`) + flags.StringPtrVar(cmd.Flags(), &editReq.Definition, "definition", `Policy definition document expressed in [Databricks Cluster Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html).`) + flags.StringPtrVar(cmd.Flags(), &editReq.Description, "description", `Additional human-readable description of the cluster policy.`) // TODO: array: libraries - cmd.Flags().Int64Var(&editReq.MaxClustersPerUser, "max-clusters-per-user", editReq.MaxClustersPerUser, `Max number of clusters per user that can be active using this policy.`) - cmd.Flags().StringVar(&editReq.Name, "name", editReq.Name, `Cluster Policy name requested by the user.`) - cmd.Flags().StringVar(&editReq.PolicyFamilyDefinitionOverrides, "policy-family-definition-overrides", editReq.PolicyFamilyDefinitionOverrides, `Policy definition JSON document expressed in [Databricks Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html).`) - cmd.Flags().StringVar(&editReq.PolicyFamilyId, "policy-family-id", editReq.PolicyFamilyId, `ID of the policy family.`) + flags.Int64PtrVar(cmd.Flags(), &editReq.MaxClustersPerUser, "max-clusters-per-user", `Max number of clusters per user that can be active using this policy.`) + flags.StringPtrVar(cmd.Flags(), &editReq.Name, "name", `Cluster Policy name requested by the user.`) + flags.StringPtrVar(cmd.Flags(), &editReq.PolicyFamilyDefinitionOverrides, "policy-family-definition-overrides", `Policy definition JSON document expressed in [Databricks Policy Definition Language](https://docs.databricks.com/administration-guide/clusters/policy-definition.html).`) + flags.StringPtrVar(cmd.Flags(), &editReq.PolicyFamilyId, "policy-family-id", `ID of the policy family.`) cmd.Use = "edit POLICY_ID" cmd.Short = `Update a cluster policy.` @@ -295,13 +299,15 @@ func newEdit() *cobra.Command { } return nil } - 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) + _ = w if cmd.Flags().Changed("json") { diags := editJson.Unmarshal(&editReq) @@ -314,32 +320,21 @@ func newEdit() *cobra.Command { return err } } - } else { - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No POLICY_ID argument specified. Loading names for Cluster Policies drop-down.") - names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID of the policy to update") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id of the policy to update") - } - editReq.PolicyId = args[0] - + } + if !cmd.Flags().Changed("json") { + editReq.PolicyId = new(args[0]) } - err = w.ClusterPolicies.Edit(ctx, editReq) + sdkReq, err := clusterpolicies.EditPolicyRequestToSDK(&editReq) + if err != nil { + return err + } + response, err := w.ClusterPolicies.EditPolicy(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -361,13 +356,12 @@ func newEdit() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *compute.GetClusterPolicyRequest, + *clusterpolicies.GetPolicyRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq compute.GetClusterPolicyRequest + var getReq clusterpolicies.GetPolicyRequest cmd.Use = "get POLICY_ID" cmd.Short = `Get a cluster policy.` @@ -382,36 +376,33 @@ func newGet() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No POLICY_ID argument specified. Loading names for Cluster Policies drop-down.") - names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Canonical unique identifier for the Cluster Policy") - if err != nil { - return err - } - args = append(args, id) + getReq.PolicyId = new(args[0]) + + sdkReq, err := clusterpolicies.GetPolicyRequestToSDK(&getReq) + if err != nil { + return err } - if len(args) != 1 { - return errors.New("expected to have canonical unique identifier for the cluster policy") + response, err := w.ClusterPolicies.GetPolicy(ctx, *sdkReq) + if err != nil { + return err } - getReq.PolicyId = args[0] - response, err := w.ClusterPolicies.Get(ctx, getReq) + out, err := clusterpolicies.PolicyFromSDK(response) if err != nil { return err } - - return cmdio.Render(ctx, response) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -432,13 +423,12 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *compute.GetClusterPolicyPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq compute.GetClusterPolicyPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels CLUSTER_POLICY_ID" cmd.Short = `Get cluster policy permission levels.` @@ -453,36 +443,32 @@ func newGetPermissionLevels() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down.") - names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The cluster policy for which to get or manage permissions") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the cluster policy for which to get or manage permissions") - } - getPermissionLevelsReq.ClusterPolicyId = args[0] + getPermissionLevelsReq.RequestObjectId = new(args[0]) - response, err := w.ClusterPolicies.GetPermissionLevels(ctx, getPermissionLevelsReq) + getPermissionLevelsReq.RequestObjectType = new("cluster-policies") + + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -503,13 +489,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *compute.GetClusterPolicyPermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq compute.GetClusterPolicyPermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions CLUSTER_POLICY_ID" cmd.Short = `Get cluster policy permissions.` @@ -525,36 +510,32 @@ func newGetPermissions() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down.") - names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The cluster policy for which to get or manage permissions") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the cluster policy for which to get or manage permissions") - } - getPermissionsReq.ClusterPolicyId = args[0] + getPermissionsReq.RequestObjectId = new(args[0]) - response, err := w.ClusterPolicies.GetPermissions(ctx, getPermissionsReq) + getPermissionsReq.RequestObjectType = new("cluster-policies") + + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -575,20 +556,20 @@ func newGetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *compute.ListClusterPoliciesRequest, + *clusterpolicies.ListPoliciesRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq clusterpolicies.ListPoliciesRequest - var listReq compute.ListClusterPoliciesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().Var(&listReq.SortColumn, "sort-column", `The cluster policy attribute to sort by. Supported values: [POLICY_CREATION_TIME, POLICY_NAME]`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order in which the policies get listed. Supported values: [ASC, DESC]`) + flags.EnumVar(cmd.Flags(), &listReq.SortColumn, "sort-column", `The cluster policy attribute to sort by. Supported values: [POLICY_CREATION_TIME, POLICY_NAME]`, "ListSortColumn", "POLICY_CREATION_TIME", "POLICY_NAME") + flags.EnumVar(cmd.Flags(), &listReq.SortOrder, "sort-order", `The order in which the policies get listed. Supported values: [ASC, DESC]`, "ListSortOrder", "ASC", "DESC") // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) @@ -614,8 +595,16 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ClusterPolicies.List(ctx, listReq) + sdkReq, err := clusterpolicies.ListPoliciesRequestToSDK(&listReq) + if err != nil { + return err + } + response, err := w.ClusterPolicies.ListPolicies(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -623,7 +612,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := clusterpolicies.ListPoliciesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.Policies) } // Disable completions since they are not applicable. @@ -644,13 +637,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *compute.ClusterPolicyPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq compute.ClusterPolicyPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -672,10 +665,16 @@ func newSetPermissions() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -689,31 +688,24 @@ func newSetPermissions() *cobra.Command { } } } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down.") - names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The cluster policy for which to get or manage permissions") - if err != nil { - return err - } - args = append(args, id) + setPermissionsReq.RequestObjectId = new(args[0]) + + setPermissionsReq.RequestObjectType = new("cluster-policies") + + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err } - if len(args) != 1 { - return errors.New("expected to have the cluster policy for which to get or manage permissions") + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) + if err != nil { + return err } - setPermissionsReq.ClusterPolicyId = args[0] - response, err := w.ClusterPolicies.SetPermissions(ctx, setPermissionsReq) + out, err := accessmanagement.PermissionsResponseFromSDK(response) if err != nil { return err } - - return cmdio.Render(ctx, response) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -734,13 +726,13 @@ func newSetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *compute.ClusterPolicyPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq compute.ClusterPolicyPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -761,10 +753,16 @@ func newUpdatePermissions() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -778,31 +776,24 @@ func newUpdatePermissions() *cobra.Command { } } } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down.") - names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The cluster policy for which to get or manage permissions") - if err != nil { - return err - } - args = append(args, id) + updatePermissionsReq.RequestObjectId = new(args[0]) + + updatePermissionsReq.RequestObjectType = new("cluster-policies") + + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err } - if len(args) != 1 { - return errors.New("expected to have the cluster policy for which to get or manage permissions") + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) + if err != nil { + return err } - updatePermissionsReq.ClusterPolicyId = args[0] - response, err := w.ClusterPolicies.UpdatePermissions(ctx, updatePermissionsReq) + out, err := accessmanagement.PermissionsResponseFromSDK(response) if err != nil { return err } - - return cmdio.Render(ctx, response) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/cluster-policies/overrides.go b/cmd/workspace/cluster-policies/overrides.go index 9278b29c391..27b39c6c8d2 100644 --- a/cmd/workspace/cluster-policies/overrides.go +++ b/cmd/workspace/cluster-policies/overrides.go @@ -2,17 +2,17 @@ package cluster_policies import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/compute" + clusterpolicies "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, _ *compute.ListClusterPoliciesRequest) { +func listOverride(listCmd *cobra.Command, _ *clusterpolicies.ListPoliciesRequest) { listCmd.Annotations["template"] = cmdio.Heredoc(` {{range .}}{{.PolicyId | green}} {{.Name}} {{end}}`) } -func getOverride(getCmd *cobra.Command, _ *compute.GetClusterPolicyRequest) { +func getOverride(getCmd *cobra.Command, _ *clusterpolicies.GetPolicyRequest) { getCmd.Annotations["template"] = cmdio.Heredoc(`{{.Definition | pretty_json}}`) } diff --git a/cmd/workspace/clusters/clusters.go b/cmd/workspace/clusters/clusters.go index d0b0302b66f..f668317bc48 100644 --- a/cmd/workspace/clusters/clusters.go +++ b/cmd/workspace/clusters/clusters.go @@ -8,11 +8,19 @@ import ( "time" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + clusters "github.com/databricks/cli/libs/sdktypes/clusters/v2" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdkclusters "github.com/databricks/sdk-go/clusters/v2" ) // Slice with functions to override default command behavior. @@ -94,13 +102,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var changeOwnerOverrides []func( *cobra.Command, - *compute.ChangeClusterOwner, + *clusters.ChangeClusterOwnerRequest, ) func newChangeOwner() *cobra.Command { cmd := &cobra.Command{} + var changeOwnerReq clusters.ChangeClusterOwnerRequest - var changeOwnerReq compute.ChangeClusterOwner var changeOwnerJson flags.JsonFlag cmd.Flags().Var(&changeOwnerJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -137,6 +145,7 @@ func newChangeOwner() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := changeOwnerJson.Unmarshal(&changeOwnerReq) @@ -151,16 +160,22 @@ func newChangeOwner() *cobra.Command { } } if !cmd.Flags().Changed("json") { - changeOwnerReq.ClusterId = args[0] + changeOwnerReq.ClusterId = new(args[0]) } if !cmd.Flags().Changed("json") { - changeOwnerReq.OwnerUsername = args[1] + changeOwnerReq.OwnerUsername = new(args[1]) } - err = w.Clusters.ChangeOwner(ctx, changeOwnerReq) + sdkReq, err := clusters.ChangeClusterOwnerRequestToSDK(&changeOwnerReq) + if err != nil { + return err + } + response, err := w.Clusters.ChangeClusterOwner(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -182,13 +197,13 @@ func newChangeOwner() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *compute.CreateCluster, + *clusters.CreateClusterRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq clusters.CreateClusterRequest - var createReq compute.CreateCluster var createJson flags.JsonFlag var createSkipWait bool @@ -199,16 +214,16 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createReq.ApplyPolicyDefaultValues, "apply-policy-default-values", createReq.ApplyPolicyDefaultValues, `When set to true, fixed and default values from the policy will be used for fields that are omitted.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.ApplyPolicyDefaultValues, "apply-policy-default-values", `When set to true, fixed and default values from the policy will be used for fields that are omitted.`) // TODO: complex arg: autoscale - cmd.Flags().IntVar(&createReq.AutoterminationMinutes, "autotermination-minutes", createReq.AutoterminationMinutes, `Automatically terminates the cluster after it is inactive for this time in minutes.`) + flags.IntPtrVar(cmd.Flags(), &createReq.AutoterminationMinutes, "autotermination-minutes", `Automatically terminates the cluster after it is inactive for this time in minutes.`) // TODO: complex arg: aws_attributes // TODO: complex arg: azure_attributes // TODO: complex arg: clone_from // TODO: complex arg: cluster_log_conf - cmd.Flags().StringVar(&createReq.ClusterName, "cluster-name", createReq.ClusterName, `Cluster name requested by the user.`) + flags.StringPtrVar(cmd.Flags(), &createReq.ClusterName, "cluster-name", `Cluster name requested by the user.`) // TODO: map via StringToStringVar: custom_tags - cmd.Flags().Var(&createReq.DataSecurityMode, "data-security-mode", `Supported values: [ + flags.EnumVar(cmd.Flags(), &createReq.DataSecurityMode, "data-security-mode", `Supported values: [ DATA_SECURITY_MODE_AUTO, DATA_SECURITY_MODE_DEDICATED, DATA_SECURITY_MODE_STANDARD, @@ -219,30 +234,30 @@ func newCreate() *cobra.Command { NONE, SINGLE_USER, USER_ISOLATION, -]`) - cmd.Flags().Var(&createReq.DependencyMode, "dependency-mode", `Controls dependency configuration for the cluster. Supported values: [DEPENDENCY_MODE_AUTO, DEPENDENCY_MODE_CLUSTER_LIBRARIES, DEPENDENCY_MODE_ENVIRONMENTS]`) +]`, "DataSecurityMode", "DATA_SECURITY_MODE_AUTO", "DATA_SECURITY_MODE_DEDICATED", "DATA_SECURITY_MODE_STANDARD", "LEGACY_PASSTHROUGH", "LEGACY_SINGLE_USER", "LEGACY_SINGLE_USER_STANDARD", "LEGACY_TABLE_ACL", "NONE", "SINGLE_USER", "USER_ISOLATION") + flags.EnumVar(cmd.Flags(), &createReq.DependencyMode, "dependency-mode", `Controls dependency configuration for the cluster. Supported values: [DEPENDENCY_MODE_AUTO, DEPENDENCY_MODE_CLUSTER_LIBRARIES, DEPENDENCY_MODE_ENVIRONMENTS]`, "DependencyMode", "DEPENDENCY_MODE_AUTO", "DEPENDENCY_MODE_CLUSTER_LIBRARIES", "DEPENDENCY_MODE_ENVIRONMENTS") // TODO: complex arg: docker_image - cmd.Flags().StringVar(&createReq.DriverInstancePoolId, "driver-instance-pool-id", createReq.DriverInstancePoolId, `The optional ID of the instance pool for the driver of the cluster belongs.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DriverInstancePoolId, "driver-instance-pool-id", `The optional ID of the instance pool for the driver of the cluster belongs.`) // TODO: complex arg: driver_node_type_flexibility - cmd.Flags().StringVar(&createReq.DriverNodeTypeId, "driver-node-type-id", createReq.DriverNodeTypeId, `The node type of the Spark driver.`) - cmd.Flags().BoolVar(&createReq.EnableElasticDisk, "enable-elastic-disk", createReq.EnableElasticDisk, `Autoscaling Local Storage: when enabled, this cluster will dynamically acquire additional disk space when its Spark workers are running low on disk space.`) - cmd.Flags().BoolVar(&createReq.EnableLocalDiskEncryption, "enable-local-disk-encryption", createReq.EnableLocalDiskEncryption, `Whether to enable LUKS on cluster VMs' local disks.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DriverNodeTypeId, "driver-node-type-id", `The node type of the Spark driver.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.EnableElasticDisk, "enable-elastic-disk", `Autoscaling Local Storage: when enabled, this cluster will dynamically acquire additional disk space when its Spark workers are running low on disk space.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.EnableLocalDiskEncryption, "enable-local-disk-encryption", `Whether to enable LUKS on cluster VMs' local disks.`) // TODO: complex arg: gcp_attributes // TODO: array: init_scripts - cmd.Flags().StringVar(&createReq.InstancePoolId, "instance-pool-id", createReq.InstancePoolId, `The optional ID of the instance pool to which the cluster belongs.`) - cmd.Flags().BoolVar(&createReq.IsSingleNode, "is-single-node", createReq.IsSingleNode, `This field can only be used when kind = CLASSIC_PREVIEW.`) - cmd.Flags().Var(&createReq.Kind, "kind", `Supported values: [CLASSIC_PREVIEW]`) - cmd.Flags().StringVar(&createReq.NodeTypeId, "node-type-id", createReq.NodeTypeId, `This field encodes, through a single value, the resources available to each of the Spark nodes in this cluster.`) - cmd.Flags().IntVar(&createReq.NumWorkers, "num-workers", createReq.NumWorkers, `Number of worker nodes that this cluster should have.`) - cmd.Flags().StringVar(&createReq.PolicyId, "policy-id", createReq.PolicyId, `The ID of the cluster policy used to create the cluster if applicable.`) - cmd.Flags().IntVar(&createReq.RemoteDiskThroughput, "remote-disk-throughput", createReq.RemoteDiskThroughput, `If set, what the configurable throughput (in Mb/s) for the remote disk is.`) - cmd.Flags().Var(&createReq.RuntimeEngine, "runtime-engine", `Determines the cluster's runtime engine, either standard or Photon. Supported values: [NULL, PHOTON, STANDARD]`) - cmd.Flags().StringVar(&createReq.SingleUserName, "single-user-name", createReq.SingleUserName, `Single user name if data_security_mode is SINGLE_USER.`) + flags.StringPtrVar(cmd.Flags(), &createReq.InstancePoolId, "instance-pool-id", `The optional ID of the instance pool to which the cluster belongs.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.IsSingleNode, "is-single-node", `This field can only be used when kind = CLASSIC_PREVIEW.`) + flags.EnumVar(cmd.Flags(), &createReq.Kind, "kind", `Supported values: [CLASSIC_PREVIEW]`, "Kind", "CLASSIC_PREVIEW") + flags.StringPtrVar(cmd.Flags(), &createReq.NodeTypeId, "node-type-id", `This field encodes, through a single value, the resources available to each of the Spark nodes in this cluster.`) + flags.IntPtrVar(cmd.Flags(), &createReq.NumWorkers, "num-workers", `Number of worker nodes that this cluster should have.`) + flags.StringPtrVar(cmd.Flags(), &createReq.PolicyId, "policy-id", `The ID of the cluster policy used to create the cluster if applicable.`) + flags.IntPtrVar(cmd.Flags(), &createReq.RemoteDiskThroughput, "remote-disk-throughput", `If set, what the configurable throughput (in Mb/s) for the remote disk is.`) + flags.EnumVar(cmd.Flags(), &createReq.RuntimeEngine, "runtime-engine", `Determines the cluster's runtime engine, either standard or Photon. Supported values: [NULL, PHOTON, STANDARD]`, "RuntimeEngine", "NULL", "PHOTON", "STANDARD") + flags.StringPtrVar(cmd.Flags(), &createReq.SingleUserName, "single-user-name", `Single user name if data_security_mode is SINGLE_USER.`) // TODO: map via StringToStringVar: spark_conf // TODO: map via StringToStringVar: spark_env_vars // TODO: array: ssh_public_keys - cmd.Flags().IntVar(&createReq.TotalInitialRemoteDiskSize, "total-initial-remote-disk-size", createReq.TotalInitialRemoteDiskSize, `If set, what the total initial volume size (in GB) of the remote disks should be.`) - cmd.Flags().BoolVar(&createReq.UseMlRuntime, "use-ml-runtime", createReq.UseMlRuntime, `This field can only be used when kind = CLASSIC_PREVIEW.`) + flags.IntPtrVar(cmd.Flags(), &createReq.TotalInitialRemoteDiskSize, "total-initial-remote-disk-size", `If set, what the total initial volume size (in GB) of the remote disks should be.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.UseMlRuntime, "use-ml-runtime", `This field can only be used when kind = CLASSIC_PREVIEW.`) // TODO: complex arg: worker_node_type_flexibility // TODO: complex arg: workload_type @@ -295,6 +310,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -309,26 +325,42 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.SparkVersion = args[0] + createReq.SparkVersion = new(args[0]) } - wait, err := w.Clusters.Create(ctx, createReq) + sdkReq, err := clusters.CreateClusterRequestToSDK(&createReq) if err != nil { return err } if createSkipWait { - return cmdio.Render(ctx, wait.Response) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var current clusters.CreateClusterResponse + err = api.Do(ctx, "POST", "/api/2.1/clusters/create", auth.WorkspaceIDHeaders(w.Config), nil, &createReq, ¤t) + if err != nil { + return err + } + return cmdio.Render(ctx, current) + } + wait, err := w.Clusters.CreateCluster(ctx, *sdkReq) + if err != nil { + return err } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *compute.ClusterDetails) { - statusMessage := i.StateMessage - sp.Update(statusMessage) - }).GetWithTimeout(createTimeout) + sp.Update("Waiting for create to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := clusters.ClusterInfoFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -349,13 +381,13 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *compute.DeleteCluster, + *clusters.DeleteClusterRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq clusters.DeleteClusterRequest - var deleteReq compute.DeleteCluster var deleteJson flags.JsonFlag var deleteSkipWait bool @@ -397,6 +429,7 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deleteJson.Unmarshal(&deleteReq) @@ -413,7 +446,7 @@ func newDelete() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -427,26 +460,42 @@ func newDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the cluster to be terminated") } - deleteReq.ClusterId = args[0] + deleteReq.ClusterId = new(args[0]) } - wait, err := w.Clusters.Delete(ctx, deleteReq) + sdkReq, err := clusters.DeleteClusterRequestToSDK(&deleteReq) + if err != nil { + return err + } + wait, err := w.Clusters.DeleteCluster(ctx, *sdkReq) if err != nil { return err } if deleteSkipWait { - return nil + // Render the current state, as of right after the call. + current, err := w.Clusters.GetCluster(ctx, sdkclusters.GetClusterRequest{ClusterId: new(wait.GetClusterId())}) + if err != nil { + return err + } + out, err := clusters.ClusterInfoFromSDK(current) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *compute.ClusterDetails) { - statusMessage := i.StateMessage - sp.Update(statusMessage) - }).GetWithTimeout(deleteTimeout) + sp.Update("Waiting for delete to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(deleteTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := clusters.ClusterInfoFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -467,13 +516,13 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var editOverrides []func( *cobra.Command, - *compute.EditCluster, + *clusters.EditClusterRequest, ) func newEdit() *cobra.Command { cmd := &cobra.Command{} + var editReq clusters.EditClusterRequest - var editReq compute.EditCluster var editJson flags.JsonFlag var editSkipWait bool @@ -484,15 +533,15 @@ func newEdit() *cobra.Command { cmd.Flags().Var(&editJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&editReq.ApplyPolicyDefaultValues, "apply-policy-default-values", editReq.ApplyPolicyDefaultValues, `When set to true, fixed and default values from the policy will be used for fields that are omitted.`) + flags.BoolPtrVar(cmd.Flags(), &editReq.ApplyPolicyDefaultValues, "apply-policy-default-values", `When set to true, fixed and default values from the policy will be used for fields that are omitted.`) // TODO: complex arg: autoscale - cmd.Flags().IntVar(&editReq.AutoterminationMinutes, "autotermination-minutes", editReq.AutoterminationMinutes, `Automatically terminates the cluster after it is inactive for this time in minutes.`) + flags.IntPtrVar(cmd.Flags(), &editReq.AutoterminationMinutes, "autotermination-minutes", `Automatically terminates the cluster after it is inactive for this time in minutes.`) // TODO: complex arg: aws_attributes // TODO: complex arg: azure_attributes // TODO: complex arg: cluster_log_conf - cmd.Flags().StringVar(&editReq.ClusterName, "cluster-name", editReq.ClusterName, `Cluster name requested by the user.`) + flags.StringPtrVar(cmd.Flags(), &editReq.ClusterName, "cluster-name", `Cluster name requested by the user.`) // TODO: map via StringToStringVar: custom_tags - cmd.Flags().Var(&editReq.DataSecurityMode, "data-security-mode", `Supported values: [ + flags.EnumVar(cmd.Flags(), &editReq.DataSecurityMode, "data-security-mode", `Supported values: [ DATA_SECURITY_MODE_AUTO, DATA_SECURITY_MODE_DEDICATED, DATA_SECURITY_MODE_STANDARD, @@ -503,30 +552,30 @@ func newEdit() *cobra.Command { NONE, SINGLE_USER, USER_ISOLATION, -]`) - cmd.Flags().Var(&editReq.DependencyMode, "dependency-mode", `Controls dependency configuration for the cluster. Supported values: [DEPENDENCY_MODE_AUTO, DEPENDENCY_MODE_CLUSTER_LIBRARIES, DEPENDENCY_MODE_ENVIRONMENTS]`) +]`, "DataSecurityMode", "DATA_SECURITY_MODE_AUTO", "DATA_SECURITY_MODE_DEDICATED", "DATA_SECURITY_MODE_STANDARD", "LEGACY_PASSTHROUGH", "LEGACY_SINGLE_USER", "LEGACY_SINGLE_USER_STANDARD", "LEGACY_TABLE_ACL", "NONE", "SINGLE_USER", "USER_ISOLATION") + flags.EnumVar(cmd.Flags(), &editReq.DependencyMode, "dependency-mode", `Controls dependency configuration for the cluster. Supported values: [DEPENDENCY_MODE_AUTO, DEPENDENCY_MODE_CLUSTER_LIBRARIES, DEPENDENCY_MODE_ENVIRONMENTS]`, "DependencyMode", "DEPENDENCY_MODE_AUTO", "DEPENDENCY_MODE_CLUSTER_LIBRARIES", "DEPENDENCY_MODE_ENVIRONMENTS") // TODO: complex arg: docker_image - cmd.Flags().StringVar(&editReq.DriverInstancePoolId, "driver-instance-pool-id", editReq.DriverInstancePoolId, `The optional ID of the instance pool for the driver of the cluster belongs.`) + flags.StringPtrVar(cmd.Flags(), &editReq.DriverInstancePoolId, "driver-instance-pool-id", `The optional ID of the instance pool for the driver of the cluster belongs.`) // TODO: complex arg: driver_node_type_flexibility - cmd.Flags().StringVar(&editReq.DriverNodeTypeId, "driver-node-type-id", editReq.DriverNodeTypeId, `The node type of the Spark driver.`) - cmd.Flags().BoolVar(&editReq.EnableElasticDisk, "enable-elastic-disk", editReq.EnableElasticDisk, `Autoscaling Local Storage: when enabled, this cluster will dynamically acquire additional disk space when its Spark workers are running low on disk space.`) - cmd.Flags().BoolVar(&editReq.EnableLocalDiskEncryption, "enable-local-disk-encryption", editReq.EnableLocalDiskEncryption, `Whether to enable LUKS on cluster VMs' local disks.`) + flags.StringPtrVar(cmd.Flags(), &editReq.DriverNodeTypeId, "driver-node-type-id", `The node type of the Spark driver.`) + flags.BoolPtrVar(cmd.Flags(), &editReq.EnableElasticDisk, "enable-elastic-disk", `Autoscaling Local Storage: when enabled, this cluster will dynamically acquire additional disk space when its Spark workers are running low on disk space.`) + flags.BoolPtrVar(cmd.Flags(), &editReq.EnableLocalDiskEncryption, "enable-local-disk-encryption", `Whether to enable LUKS on cluster VMs' local disks.`) // TODO: complex arg: gcp_attributes // TODO: array: init_scripts - cmd.Flags().StringVar(&editReq.InstancePoolId, "instance-pool-id", editReq.InstancePoolId, `The optional ID of the instance pool to which the cluster belongs.`) - cmd.Flags().BoolVar(&editReq.IsSingleNode, "is-single-node", editReq.IsSingleNode, `This field can only be used when kind = CLASSIC_PREVIEW.`) - cmd.Flags().Var(&editReq.Kind, "kind", `Supported values: [CLASSIC_PREVIEW]`) - cmd.Flags().StringVar(&editReq.NodeTypeId, "node-type-id", editReq.NodeTypeId, `This field encodes, through a single value, the resources available to each of the Spark nodes in this cluster.`) - cmd.Flags().IntVar(&editReq.NumWorkers, "num-workers", editReq.NumWorkers, `Number of worker nodes that this cluster should have.`) - cmd.Flags().StringVar(&editReq.PolicyId, "policy-id", editReq.PolicyId, `The ID of the cluster policy used to create the cluster if applicable.`) - cmd.Flags().IntVar(&editReq.RemoteDiskThroughput, "remote-disk-throughput", editReq.RemoteDiskThroughput, `If set, what the configurable throughput (in Mb/s) for the remote disk is.`) - cmd.Flags().Var(&editReq.RuntimeEngine, "runtime-engine", `Determines the cluster's runtime engine, either standard or Photon. Supported values: [NULL, PHOTON, STANDARD]`) - cmd.Flags().StringVar(&editReq.SingleUserName, "single-user-name", editReq.SingleUserName, `Single user name if data_security_mode is SINGLE_USER.`) + flags.StringPtrVar(cmd.Flags(), &editReq.InstancePoolId, "instance-pool-id", `The optional ID of the instance pool to which the cluster belongs.`) + flags.BoolPtrVar(cmd.Flags(), &editReq.IsSingleNode, "is-single-node", `This field can only be used when kind = CLASSIC_PREVIEW.`) + flags.EnumVar(cmd.Flags(), &editReq.Kind, "kind", `Supported values: [CLASSIC_PREVIEW]`, "Kind", "CLASSIC_PREVIEW") + flags.StringPtrVar(cmd.Flags(), &editReq.NodeTypeId, "node-type-id", `This field encodes, through a single value, the resources available to each of the Spark nodes in this cluster.`) + flags.IntPtrVar(cmd.Flags(), &editReq.NumWorkers, "num-workers", `Number of worker nodes that this cluster should have.`) + flags.StringPtrVar(cmd.Flags(), &editReq.PolicyId, "policy-id", `The ID of the cluster policy used to create the cluster if applicable.`) + flags.IntPtrVar(cmd.Flags(), &editReq.RemoteDiskThroughput, "remote-disk-throughput", `If set, what the configurable throughput (in Mb/s) for the remote disk is.`) + flags.EnumVar(cmd.Flags(), &editReq.RuntimeEngine, "runtime-engine", `Determines the cluster's runtime engine, either standard or Photon. Supported values: [NULL, PHOTON, STANDARD]`, "RuntimeEngine", "NULL", "PHOTON", "STANDARD") + flags.StringPtrVar(cmd.Flags(), &editReq.SingleUserName, "single-user-name", `Single user name if data_security_mode is SINGLE_USER.`) // TODO: map via StringToStringVar: spark_conf // TODO: map via StringToStringVar: spark_env_vars // TODO: array: ssh_public_keys - cmd.Flags().IntVar(&editReq.TotalInitialRemoteDiskSize, "total-initial-remote-disk-size", editReq.TotalInitialRemoteDiskSize, `If set, what the total initial volume size (in GB) of the remote disks should be.`) - cmd.Flags().BoolVar(&editReq.UseMlRuntime, "use-ml-runtime", editReq.UseMlRuntime, `This field can only be used when kind = CLASSIC_PREVIEW.`) + flags.IntPtrVar(cmd.Flags(), &editReq.TotalInitialRemoteDiskSize, "total-initial-remote-disk-size", `If set, what the total initial volume size (in GB) of the remote disks should be.`) + flags.BoolPtrVar(cmd.Flags(), &editReq.UseMlRuntime, "use-ml-runtime", `This field can only be used when kind = CLASSIC_PREVIEW.`) // TODO: complex arg: worker_node_type_flexibility // TODO: complex arg: workload_type @@ -575,6 +624,7 @@ func newEdit() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := editJson.Unmarshal(&editReq) @@ -589,29 +639,45 @@ func newEdit() *cobra.Command { } } if !cmd.Flags().Changed("json") { - editReq.ClusterId = args[0] + editReq.ClusterId = new(args[0]) } if !cmd.Flags().Changed("json") { - editReq.SparkVersion = args[1] + editReq.SparkVersion = new(args[1]) } - wait, err := w.Clusters.Edit(ctx, editReq) + sdkReq, err := clusters.EditClusterRequestToSDK(&editReq) + if err != nil { + return err + } + wait, err := w.Clusters.EditCluster(ctx, *sdkReq) if err != nil { return err } if editSkipWait { - return nil + // Render the current state, as of right after the call. + current, err := w.Clusters.GetCluster(ctx, sdkclusters.GetClusterRequest{ClusterId: new(wait.GetClusterId())}) + if err != nil { + return err + } + out, err := clusters.ClusterInfoFromSDK(current) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *compute.ClusterDetails) { - statusMessage := i.StateMessage - sp.Update(statusMessage) - }).GetWithTimeout(editTimeout) + sp.Update("Waiting for edit to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(editTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := clusters.ClusterInfoFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -632,13 +698,13 @@ func newEdit() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var eventsOverrides []func( *cobra.Command, - *compute.GetEvents, + *clusters.ListEventsRequest, ) func newEvents() *cobra.Command { cmd := &cobra.Command{} + var eventsReq clusters.ListEventsRequest - var eventsReq compute.GetEvents var eventsJson flags.JsonFlag // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO @@ -647,18 +713,18 @@ func newEvents() *cobra.Command { cmd.Flags().Var(&eventsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Int64Var(&eventsReq.EndTime, "end-time", eventsReq.EndTime, `The end time in epoch milliseconds.`) + flags.Int64PtrVar(cmd.Flags(), &eventsReq.EndTime, "end-time", `The end time in epoch milliseconds.`) // TODO: array: event_types - cmd.Flags().Var(&eventsReq.Order, "order", `The order to list events in; either "ASC" or "DESC". Supported values: [ASC, DESC]`) - cmd.Flags().IntVar(&eventsReq.PageSize, "page-size", eventsReq.PageSize, `The maximum number of events to include in a page of events.`) - cmd.Flags().StringVar(&eventsReq.PageToken, "page-token", eventsReq.PageToken, `Use next_page_token or prev_page_token returned from the previous request to list the next or previous page of events respectively.`) - cmd.Flags().Int64Var(&eventsReq.StartTime, "start-time", eventsReq.StartTime, `The start time in epoch milliseconds.`) + flags.EnumVar(cmd.Flags(), &eventsReq.Order, "order", `The order to list events in; either "ASC" or "DESC". Supported values: [ASC, DESC]`, "GetEventsOrder", "ASC", "DESC") + flags.IntPtrVar(cmd.Flags(), &eventsReq.PageSize, "page-size", `The maximum number of events to include in a page of events.`) + flags.StringPtrVar(cmd.Flags(), &eventsReq.PageToken, "page-token", `Use next_page_token or prev_page_token returned from the previous request to list the next or previous page of events respectively.`) + flags.Int64PtrVar(cmd.Flags(), &eventsReq.StartTime, "start-time", `The start time in epoch milliseconds.`) // Limit flag for total result capping. cmd.Flags().IntVar(&eventsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().Int64Var(&eventsReq.Offset, "offset", eventsReq.Offset, `Deprecated: use page_token in combination with page_size instead.`) + flags.Int64PtrVar(cmd.Flags(), &eventsReq.Offset, "offset", `Deprecated: use page_token in combination with page_size instead.`) cmd.Flags().Lookup("offset").Hidden = true cmd.Use = "events CLUSTER_ID" @@ -691,6 +757,7 @@ func newEvents() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := eventsJson.Unmarshal(&eventsReq) @@ -707,7 +774,7 @@ func newEvents() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -721,19 +788,22 @@ func newEvents() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the id of the cluster to retrieve events about") } - eventsReq.ClusterId = args[0] + eventsReq.ClusterId = new(args[0]) } - response := w.Clusters.Events(ctx, eventsReq) + sdkReq, err := clusters.ListEventsRequestToSDK(&eventsReq) + if err != nil { + return err + } if eventsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", eventsLimit) } if eventsLimit > 0 { ctx = cmdio.WithLimit(ctx, eventsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Clusters.ListEventsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, clusters.ClusterEventFromSDK)) } // Disable completions since they are not applicable. @@ -754,13 +824,12 @@ func newEvents() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *compute.GetClusterRequest, + *clusters.GetClusterRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq compute.GetClusterRequest + var getReq clusters.GetClusterRequest cmd.Use = "get CLUSTER_ID" cmd.Short = `Get cluster info.` @@ -780,11 +849,12 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -798,14 +868,22 @@ func newGet() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the cluster about which to retrieve information") } - getReq.ClusterId = args[0] + getReq.ClusterId = new(args[0]) - response, err := w.Clusters.Get(ctx, getReq) + sdkReq, err := clusters.GetClusterRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.Clusters.GetCluster(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := clusters.ClusterInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -826,13 +904,12 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *compute.GetClusterPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq compute.GetClusterPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels CLUSTER_ID" cmd.Short = `Get cluster permission levels.` @@ -851,11 +928,12 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -869,14 +947,21 @@ func newGetPermissionLevels() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the cluster for which to get or manage permissions") } - getPermissionLevelsReq.ClusterId = args[0] + getPermissionLevelsReq.RequestObjectId = new(args[0]) + + getPermissionLevelsReq.RequestObjectType = new("clusters") - response, err := w.Clusters.GetPermissionLevels(ctx, getPermissionLevelsReq) + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -897,13 +982,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *compute.GetClusterPermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq compute.GetClusterPermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions CLUSTER_ID" cmd.Short = `Get cluster permissions.` @@ -923,11 +1007,12 @@ func newGetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -941,14 +1026,21 @@ func newGetPermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the cluster for which to get or manage permissions") } - getPermissionsReq.ClusterId = args[0] + getPermissionsReq.RequestObjectId = new(args[0]) + + getPermissionsReq.RequestObjectType = new("clusters") - response, err := w.Clusters.GetPermissions(ctx, getPermissionsReq) + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -969,27 +1061,27 @@ func newGetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *compute.ListClustersRequest, + *clusters.ListClustersRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq clusters.ListClustersRequest - var listReq compute.ListClustersRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int // TODO: complex arg: filter_by - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `Use this field to specify the maximum number of results to be returned by the server.`) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", `Use this field to specify the maximum number of results to be returned by the server.`) // TODO: complex arg: sort_by // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -1013,16 +1105,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Clusters.List(ctx, listReq) + sdkReq, err := clusters.ListClustersRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Clusters.ListClustersIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, clusters.ClusterInfoFromSDK)) } // Disable completions since they are not applicable. @@ -1063,12 +1159,20 @@ func newListNodeTypes() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.Clusters.ListNodeTypes(ctx) + _ = w + + sdkReq := &sdkclusters.ListNodeTypesRequest{} + + response, err := w.Clusters.ListNodeTypes(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := clusters.ListNodeTypesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1109,12 +1213,20 @@ func newListZones() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.Clusters.ListZones(ctx) + _ = w + + sdkReq := &sdkclusters.ListAvailableZonesRequest{} + + response, err := w.Clusters.ListAvailableZones(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := clusters.ListAvailableZonesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1135,13 +1247,13 @@ func newListZones() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var permanentDeleteOverrides []func( *cobra.Command, - *compute.PermanentDeleteCluster, + *clusters.PermanentDeleteClusterRequest, ) func newPermanentDelete() *cobra.Command { cmd := &cobra.Command{} + var permanentDeleteReq clusters.PermanentDeleteClusterRequest - var permanentDeleteReq compute.PermanentDeleteCluster var permanentDeleteJson flags.JsonFlag cmd.Flags().Var(&permanentDeleteJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1179,6 +1291,7 @@ func newPermanentDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := permanentDeleteJson.Unmarshal(&permanentDeleteReq) @@ -1195,7 +1308,7 @@ func newPermanentDelete() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1209,13 +1322,19 @@ func newPermanentDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the cluster to be deleted") } - permanentDeleteReq.ClusterId = args[0] + permanentDeleteReq.ClusterId = new(args[0]) } - err = w.Clusters.PermanentDelete(ctx, permanentDeleteReq) + sdkReq, err := clusters.PermanentDeleteClusterRequestToSDK(&permanentDeleteReq) + if err != nil { + return err + } + response, err := w.Clusters.PermanentDeleteCluster(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -1237,13 +1356,13 @@ func newPermanentDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var pinOverrides []func( *cobra.Command, - *compute.PinCluster, + *clusters.PinClusterRequest, ) func newPin() *cobra.Command { cmd := &cobra.Command{} + var pinReq clusters.PinClusterRequest - var pinReq compute.PinCluster var pinJson flags.JsonFlag cmd.Flags().Var(&pinJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1275,6 +1394,7 @@ func newPin() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := pinJson.Unmarshal(&pinReq) @@ -1291,7 +1411,7 @@ func newPin() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1305,13 +1425,19 @@ func newPin() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - pinReq.ClusterId = args[0] + pinReq.ClusterId = new(args[0]) } - err = w.Clusters.Pin(ctx, pinReq) + sdkReq, err := clusters.PinClusterRequestToSDK(&pinReq) if err != nil { return err } + response, err := w.Clusters.PinCluster(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -1333,13 +1459,13 @@ func newPin() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var resizeOverrides []func( *cobra.Command, - *compute.ResizeCluster, + *clusters.ResizeClusterRequest, ) func newResize() *cobra.Command { cmd := &cobra.Command{} + var resizeReq clusters.ResizeClusterRequest - var resizeReq compute.ResizeCluster var resizeJson flags.JsonFlag var resizeSkipWait bool @@ -1351,7 +1477,7 @@ func newResize() *cobra.Command { cmd.Flags().Var(&resizeJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: autoscale - cmd.Flags().IntVar(&resizeReq.NumWorkers, "num-workers", resizeReq.NumWorkers, `Number of worker nodes that this cluster should have.`) + flags.IntPtrVar(cmd.Flags(), &resizeReq.NumWorkers, "num-workers", `Number of worker nodes that this cluster should have.`) cmd.Use = "resize CLUSTER_ID" cmd.Short = `Resize cluster.` @@ -1382,6 +1508,7 @@ func newResize() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := resizeJson.Unmarshal(&resizeReq) @@ -1398,7 +1525,7 @@ func newResize() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1412,27 +1539,43 @@ func newResize() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the cluster to be resized") } - resizeReq.ClusterId = args[0] + resizeReq.ClusterId = new(args[0]) } - wait, err := w.Clusters.Resize(ctx, resizeReq) + sdkReq, err := clusters.ResizeClusterRequestToSDK(&resizeReq) + if err != nil { + return err + } + wait, err := w.Clusters.ResizeCluster(ctx, *sdkReq) if err != nil { return err } if resizeSkipWait { - return nil + // Render the current state, as of right after the call. + current, err := w.Clusters.GetCluster(ctx, sdkclusters.GetClusterRequest{ClusterId: new(wait.GetClusterId())}) + if err != nil { + return err + } + out, err := clusters.ClusterInfoFromSDK(current) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *compute.ClusterDetails) { - statusMessage := i.StateMessage - sp.Update(statusMessage) - }).GetWithTimeout(resizeTimeout) + sp.Update("Waiting for resize to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(resizeTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := clusters.ClusterInfoFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1453,13 +1596,13 @@ func newResize() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var restartOverrides []func( *cobra.Command, - *compute.RestartCluster, + *clusters.RestartClusterRequest, ) func newRestart() *cobra.Command { cmd := &cobra.Command{} + var restartReq clusters.RestartClusterRequest - var restartReq compute.RestartCluster var restartJson flags.JsonFlag var restartSkipWait bool @@ -1470,7 +1613,7 @@ func newRestart() *cobra.Command { cmd.Flags().Var(&restartJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&restartReq.RestartUser, "restart-user", restartReq.RestartUser, ``) + flags.StringPtrVar(cmd.Flags(), &restartReq.RestartUser, "restart-user", ``) cmd.Use = "restart CLUSTER_ID" cmd.Short = `Restart cluster.` @@ -1501,6 +1644,7 @@ func newRestart() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := restartJson.Unmarshal(&restartReq) @@ -1517,7 +1661,7 @@ func newRestart() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1531,27 +1675,43 @@ func newRestart() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the cluster to be started") } - restartReq.ClusterId = args[0] + restartReq.ClusterId = new(args[0]) } - wait, err := w.Clusters.Restart(ctx, restartReq) + sdkReq, err := clusters.RestartClusterRequestToSDK(&restartReq) + if err != nil { + return err + } + wait, err := w.Clusters.RestartCluster(ctx, *sdkReq) if err != nil { return err } if restartSkipWait { - return nil + // Render the current state, as of right after the call. + current, err := w.Clusters.GetCluster(ctx, sdkclusters.GetClusterRequest{ClusterId: new(wait.GetClusterId())}) + if err != nil { + return err + } + out, err := clusters.ClusterInfoFromSDK(current) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *compute.ClusterDetails) { - statusMessage := i.StateMessage - sp.Update(statusMessage) - }).GetWithTimeout(restartTimeout) + sp.Update("Waiting for restart to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(restartTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := clusters.ClusterInfoFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1572,13 +1732,13 @@ func newRestart() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *compute.ClusterPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq compute.ClusterPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1604,6 +1764,7 @@ func newSetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -1620,7 +1781,7 @@ func newSetPermissions() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1634,14 +1795,24 @@ func newSetPermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the cluster for which to get or manage permissions") } - setPermissionsReq.ClusterId = args[0] + setPermissionsReq.RequestObjectId = new(args[0]) + + setPermissionsReq.RequestObjectType = new("clusters") - response, err := w.Clusters.SetPermissions(ctx, setPermissionsReq) + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1682,12 +1853,20 @@ func newSparkVersions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.Clusters.SparkVersions(ctx) + _ = w + + sdkReq := &sdkclusters.GetSparkVersionsRequest{} + + response, err := w.Clusters.ListSparkVersions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := clusters.GetSparkVersionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1708,13 +1887,13 @@ func newSparkVersions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var startOverrides []func( *cobra.Command, - *compute.StartCluster, + *clusters.StartClusterRequest, ) func newStart() *cobra.Command { cmd := &cobra.Command{} + var startReq clusters.StartClusterRequest - var startReq compute.StartCluster var startJson flags.JsonFlag var startSkipWait bool @@ -1759,6 +1938,7 @@ func newStart() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := startJson.Unmarshal(&startReq) @@ -1775,7 +1955,7 @@ func newStart() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1789,26 +1969,42 @@ func newStart() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the cluster to be started") } - startReq.ClusterId = args[0] + startReq.ClusterId = new(args[0]) } - wait, err := w.Clusters.Start(ctx, startReq) + sdkReq, err := clusters.StartClusterRequestToSDK(&startReq) + if err != nil { + return err + } + wait, err := w.Clusters.StartCluster(ctx, *sdkReq) if err != nil { return err } if startSkipWait { - return nil + // Render the current state, as of right after the call. + current, err := w.Clusters.GetCluster(ctx, sdkclusters.GetClusterRequest{ClusterId: new(wait.GetClusterId())}) + if err != nil { + return err + } + out, err := clusters.ClusterInfoFromSDK(current) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *compute.ClusterDetails) { - statusMessage := i.StateMessage - sp.Update(statusMessage) - }).GetWithTimeout(startTimeout) + sp.Update("Waiting for start to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(startTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := clusters.ClusterInfoFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1829,13 +2025,13 @@ func newStart() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var unpinOverrides []func( *cobra.Command, - *compute.UnpinCluster, + *clusters.UnpinClusterRequest, ) func newUnpin() *cobra.Command { cmd := &cobra.Command{} + var unpinReq clusters.UnpinClusterRequest - var unpinReq compute.UnpinCluster var unpinJson flags.JsonFlag cmd.Flags().Var(&unpinJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1867,6 +2063,7 @@ func newUnpin() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := unpinJson.Unmarshal(&unpinReq) @@ -1883,7 +2080,7 @@ func newUnpin() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1897,13 +2094,19 @@ func newUnpin() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - unpinReq.ClusterId = args[0] + unpinReq.ClusterId = new(args[0]) } - err = w.Clusters.Unpin(ctx, unpinReq) + sdkReq, err := clusters.UnpinClusterRequestToSDK(&unpinReq) if err != nil { return err } + response, err := w.Clusters.UnpinCluster(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -1925,13 +2128,13 @@ func newUnpin() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *compute.UpdateCluster, + *clusters.UpdateClusterRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq clusters.UpdateClusterRequest - var updateReq compute.UpdateCluster var updateJson flags.JsonFlag var updateSkipWait bool @@ -1996,6 +2199,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -2010,29 +2214,45 @@ func newUpdate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - updateReq.ClusterId = args[0] + updateReq.ClusterId = new(args[0]) } if !cmd.Flags().Changed("json") { - updateReq.UpdateMask = args[1] + updateReq.UpdateMask = new(args[1]) } - wait, err := w.Clusters.Update(ctx, updateReq) + sdkReq, err := clusters.UpdateClusterRequestToSDK(&updateReq) + if err != nil { + return err + } + wait, err := w.Clusters.UpdateCluster(ctx, *sdkReq) if err != nil { return err } if updateSkipWait { - return nil + // Render the current state, as of right after the call. + current, err := w.Clusters.GetCluster(ctx, sdkclusters.GetClusterRequest{ClusterId: new(wait.GetClusterId())}) + if err != nil { + return err + } + out, err := clusters.ClusterInfoFromSDK(current) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *compute.ClusterDetails) { - statusMessage := i.StateMessage - sp.Update(statusMessage) - }).GetWithTimeout(updateTimeout) + sp.Update("Waiting for update to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(updateTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := clusters.ClusterInfoFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2053,13 +2273,13 @@ func newUpdate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *compute.ClusterPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq compute.ClusterPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2084,6 +2304,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -2100,7 +2321,7 @@ func newUpdatePermissions() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No CLUSTER_ID argument specified. Loading names for Clusters drop-down.") - names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Clusters.ListClustersIter(ctx, sdkclusters.ListClustersRequest{}), []string{"ClusterName"}, []string{"ClusterId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -2114,14 +2335,24 @@ func newUpdatePermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the cluster for which to get or manage permissions") } - updatePermissionsReq.ClusterId = args[0] + updatePermissionsReq.RequestObjectId = new(args[0]) - response, err := w.Clusters.UpdatePermissions(ctx, updatePermissionsReq) + updatePermissionsReq.RequestObjectType = new("clusters") + + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/clusters/overrides.go b/cmd/workspace/clusters/overrides.go index 45c530a14a2..58fa6277421 100644 --- a/cmd/workspace/clusters/overrides.go +++ b/cmd/workspace/clusters/overrides.go @@ -1,42 +1,105 @@ package clusters import ( + "iter" "strings" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" + "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/compute" + clusters "github.com/databricks/cli/libs/sdktypes/clusters/v2" "github.com/spf13/cobra" ) // Below we add overrides for filter flags for cluster list command to allow for custom filtering // Auto generating such flags is not yet supported by the CLI generator -func listOverride(listCmd *cobra.Command, listReq *compute.ListClustersRequest) { +func listOverride(listCmd *cobra.Command, listReq *clusters.ListClustersRequest) { listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "ID"}} {{header "Name"}} {{header "State"}}`) listCmd.Annotations["template"] = cmdio.Heredoc(` {{range .}}{{.ClusterId | green}} {{.ClusterName | cyan}} {{if eq .State "RUNNING"}}{{green "%s" .State}}{{else if eq .State "TERMINATED"}}{{red "%s" .State}}{{else}}{{blue "%s" .State}}{{end}} {{end}}`) - listReq.FilterBy = &compute.ListClustersFilterBy{} - listCmd.Flags().BoolVar(&listReq.FilterBy.IsPinned, "is-pinned", false, "Filter clusters by pinned status") - listCmd.Flags().StringVar(&listReq.FilterBy.PolicyId, "policy-id", "", "Filter clusters by policy id") + var filter clusterFilter + listCmd.Flags().BoolVar(&filter.isPinned, "is-pinned", false, "Filter clusters by pinned status") + listCmd.Flags().StringVar(&filter.policyID, "policy-id", "", "Filter clusters by policy id") - sources := &clusterSources{source: &listReq.FilterBy.ClusterSources} + sources := &clusterSources{source: &filter.sources} listCmd.Flags().Var(sources, "cluster-sources", "Filter clusters by source") - states := &clusterStates{state: &listReq.FilterBy.ClusterStates} + states := &clusterStates{state: &filter.states} listCmd.Flags().Var(states, "cluster-states", "Filter clusters by states") + + // The sdk-go list request has no filter_by, so filtered listings call the + // REST API directly. + runE := listCmd.RunE + listCmd.RunE = func(cmd *cobra.Command, args []string) error { + if !filter.isSet(cmd) { + return runE(cmd, args) + } + ctx := cmd.Context() + api, err := apiclient.New(cmdctx.WorkspaceClient(ctx).Config) + if err != nil { + return err + } + query := map[string]any{} + if cmd.Flags().Changed("is-pinned") { + query["filter_by.is_pinned"] = filter.isPinned + } + if filter.policyID != "" { + query["filter_by.policy_id"] = filter.policyID + } + if len(filter.sources) > 0 { + query["filter_by.cluster_sources"] = filter.sources + } + if len(filter.states) > 0 { + query["filter_by.cluster_states"] = filter.states + } + if listReq.PageSize != nil { + query["page_size"] = *listReq.PageSize + } + headers := auth.WorkspaceIDHeaders(api.Config) + seq := func(yield func(*clusters.ClusterInfo, error) bool) { + for { + var resp clusters.ListClustersResponse + if err := api.Do(ctx, "GET", "/api/2.1/clusters/list", headers, query, nil, &resp); err != nil { + yield(nil, err) + return + } + for i := range resp.Clusters { + if !yield(&resp.Clusters[i], nil) { + return + } + } + if resp.NextPageToken == nil || *resp.NextPageToken == "" { + return + } + query["page_token"] = *resp.NextPageToken + } + } + return cmdio.RenderIterator(ctx, iter.Seq2[*clusters.ClusterInfo, error](seq)) + } +} + +type clusterFilter struct { + isPinned bool + policyID string + sources []string + states []string +} + +func (f *clusterFilter) isSet(cmd *cobra.Command) bool { + return cmd.Flags().Changed("is-pinned") || f.policyID != "" || len(f.sources) > 0 || len(f.states) > 0 } type clusterSources struct { - source *[]compute.ClusterSource + source *[]string } func (c *clusterSources) String() string { s := make([]string, len(*c.source)) - for i, source := range *c.source { - s[i] = string(source) - } + copy(s, *c.source) return strings.Join(s, ",") } @@ -44,7 +107,7 @@ func (c *clusterSources) String() string { func (c *clusterSources) Set(value string) error { splits := strings.SplitSeq(value, ",") for split := range splits { - *c.source = append(*c.source, compute.ClusterSource(split)) + *c.source = append(*c.source, split) } return nil @@ -55,14 +118,12 @@ func (c *clusterSources) Type() string { } type clusterStates struct { - state *[]compute.State + state *[]string } func (c *clusterStates) String() string { s := make([]string, len(*c.state)) - for i, source := range *c.state { - s[i] = string(source) - } + copy(s, *c.state) return strings.Join(s, ",") } @@ -70,7 +131,7 @@ func (c *clusterStates) String() string { func (c *clusterStates) Set(value string) error { splits := strings.SplitSeq(value, ",") for split := range splits { - *c.state = append(*c.state, compute.State(split)) + *c.state = append(*c.state, split) } return nil diff --git a/cmd/workspace/compliance-security-profile/compliance-security-profile.go b/cmd/workspace/compliance-security-profile/compliance-security-profile.go index 0a87f8a7bc9..8881e34f137 100644 --- a/cmd/workspace/compliance-security-profile/compliance-security-profile.go +++ b/cmd/workspace/compliance-security-profile/compliance-security-profile.go @@ -5,11 +5,14 @@ package compliance_security_profile import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -53,15 +56,16 @@ Controls whether to enable the compliance security profile for the current // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetComplianceSecurityProfileSettingRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetComplianceSecurityProfileSettingRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `*Public Preview* Get the compliance security profile setting.` @@ -84,12 +88,24 @@ Get the compliance security profile setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/shield_csp_enablement_ws_db/names/default" - response, err := w.Settings.ComplianceSecurityProfile().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -111,13 +127,16 @@ Get the compliance security profile setting. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateComplianceSecurityProfileSettingRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateComplianceSecurityProfileSettingRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -142,6 +161,7 @@ Update the compliance security profile setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -158,11 +178,24 @@ Update the compliance security profile setting. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.ComplianceSecurityProfile().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/shield_csp_enablement_ws_db/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/connections/connections.go b/cmd/workspace/connections/connections.go index 3adb27bc530..de6a44d643f 100644 --- a/cmd/workspace/connections/connections.go +++ b/cmd/workspace/connections/connections.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucconnections "github.com/databricks/cli/libs/sdktypes/uc/connections/v1" + sdkucconnections "github.com/databricks/sdk-go/uc/connections/v1" ) // Slice with functions to override default command behavior. @@ -60,22 +63,22 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateConnection, + *ucconnections.CreateConnectionRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq ucconnections.CreateConnectionRequest - var createReq catalog.CreateConnection 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.Comment, "comment", createReq.Comment, `User-provided free-form text description.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Comment, "comment", `User-provided free-form text description.`) // TODO: complex arg: environment_settings - cmd.Flags().StringVar(&createReq.Parent, "parent", createReq.Parent, `Parent schema for schema-level connections, in format "schemas/{catalog}.{schema}".`) + flags.StringPtrVar(cmd.Flags(), &createReq.Parent, "parent", `Parent schema for schema-level connections, in format "schemas/{catalog}.{schema}".`) // TODO: map via StringToStringVar: properties - cmd.Flags().BoolVar(&createReq.ReadOnly, "read-only", createReq.ReadOnly, `If the connection is read only.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.ReadOnly, "read-only", `If the connection is read only.`) cmd.Use = "create" cmd.Short = `Create a connection.` @@ -95,6 +98,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -111,12 +115,20 @@ func newCreate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Connections.Create(ctx, createReq) + sdkReq, err := ucconnections.CreateConnectionRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Connections.CreateConnection(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucconnections.ConnectionInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -137,13 +149,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteConnectionRequest, + *sdkucconnections.DeleteConnectionRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq catalog.DeleteConnectionRequest + var deleteReq sdkucconnections.DeleteConnectionRequest cmd.Use = "delete NAME" cmd.Short = `Delete a connection.` @@ -162,11 +173,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Connections drop-down.") - names, err := w.Connections.ConnectionInfoNameToFullNameMap(ctx, catalog.ListConnectionsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Connections.ListConnectionsIter(ctx, sdkucconnections.ListConnectionsRequest{}), []string{"Name"}, []string{"FullName"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Connections drop-down. Please manually specify required arguments. Original error: %w", err) @@ -180,12 +192,15 @@ func newDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the name of the connection to be deleted") } - deleteReq.Name = args[0] + deleteReq.NameArg = new(args[0]) - err = w.Connections.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Connections.DeleteConnection(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -207,13 +222,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetConnectionRequest, + *sdkucconnections.GetConnectionRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq catalog.GetConnectionRequest + var getReq sdkucconnections.GetConnectionRequest cmd.Use = "get NAME" cmd.Short = `Get a connection.` @@ -232,11 +246,12 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Connections drop-down.") - names, err := w.Connections.ConnectionInfoNameToFullNameMap(ctx, catalog.ListConnectionsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Connections.ListConnectionsIter(ctx, sdkucconnections.ListConnectionsRequest{}), []string{"Name"}, []string{"FullName"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Connections drop-down. Please manually specify required arguments. Original error: %w", err) @@ -250,14 +265,19 @@ func newGet() *cobra.Command { if len(args) != 1 { return errors.New("expected to have name of the connection") } - getReq.Name = args[0] + getReq.NameArg = new(args[0]) - response, err := w.Connections.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Connections.GetConnection(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucconnections.ConnectionInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -278,27 +298,27 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListConnectionsRequest, + *ucconnections.ListConnectionsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq ucconnections.ListConnectionsRequest - var listReq catalog.ListConnectionsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.Parent, "parent", listReq.Parent, `Optional.`) + flags.StringPtrVar(cmd.Flags(), &listReq.Parent, "parent", `Optional.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of connections to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of connections to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list" @@ -328,16 +348,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Connections.List(ctx, listReq) + sdkReq, err := ucconnections.ListConnectionsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Connections.ListConnectionsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucconnections.ConnectionInfoFromSDK)) } // Disable completions since they are not applicable. @@ -358,20 +382,20 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateConnection, + *ucconnections.UpdateConnectionRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucconnections.UpdateConnectionRequest - var updateReq catalog.UpdateConnection var updateJson flags.JsonFlag 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.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.NewName, "new-name", `New name for the connection.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `Username of current owner of the connection.`) cmd.Use = "update NAME" cmd.Short = `Update a connection.` @@ -395,6 +419,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -410,14 +435,22 @@ func newUpdate() *cobra.Command { } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateReq.Name = args[0] + updateReq.NameArg = new(args[0]) - response, err := w.Connections.Update(ctx, updateReq) + sdkReq, err := ucconnections.UpdateConnectionRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Connections.UpdateConnection(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucconnections.ConnectionInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/consumer-fulfillments/consumer-fulfillments.go b/cmd/workspace/consumer-fulfillments/consumer-fulfillments.go index 73c78334ca7..ddf9459bca1 100644 --- a/cmd/workspace/consumer-fulfillments/consumer-fulfillments.go +++ b/cmd/workspace/consumer-fulfillments/consumer-fulfillments.go @@ -7,9 +7,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/marketplace" + "github.com/databricks/cli/libs/flags" "github.com/spf13/cobra" + + marketplaces "github.com/databricks/cli/libs/sdktypes/marketplaces/v1" ) // Slice with functions to override default command behavior. @@ -49,25 +52,25 @@ Fulfillments are entities that allow consumers to preview installations.`, // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *marketplace.GetListingContentMetadataRequest, + *marketplaces.GetListingContentMetadataRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq marketplaces.GetListingContentMetadataRequest - var getReq marketplace.GetListingContentMetadataRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var getLimit int - cmd.Flags().IntVar(&getReq.PageSize, "page-size", getReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &getReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&getLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&getReq.PageToken, "page-token", getReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &getReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "get LISTING_ID" @@ -91,18 +94,22 @@ Get listing content metadata. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.ListingId = args[0] + getReq.ListingId = new(args[0]) - response := w.ConsumerFulfillments.Get(ctx, getReq) + sdkReq, err := marketplaces.GetListingContentMetadataRequestToSDK(&getReq) + if err != nil { + return err + } if getLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", getLimit) } if getLimit > 0 { ctx = cmdio.WithLimit(ctx, getLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.GetListingContentIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.SharedDataObjectFromSDK)) } // Disable completions since they are not applicable. @@ -123,25 +130,25 @@ Get listing content metadata. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *marketplace.ListFulfillmentsRequest, + *marketplaces.ListListingFulfillmentsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq marketplaces.ListListingFulfillmentsRequest - var listReq marketplace.ListFulfillmentsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list LISTING_ID" @@ -169,18 +176,22 @@ List all listing fulfillments. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.ListingId = args[0] + listReq.ListingId = new(args[0]) - response := w.ConsumerFulfillments.List(ctx, listReq) + sdkReq, err := marketplaces.ListListingFulfillmentsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.ListListingFulfillmentsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.ListingFulfillmentFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/consumer-installations/consumer-installations.go b/cmd/workspace/consumer-installations/consumer-installations.go index 7325f18f9cc..73dc4eac583 100644 --- a/cmd/workspace/consumer-installations/consumer-installations.go +++ b/cmd/workspace/consumer-installations/consumer-installations.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" + + marketplaces "github.com/databricks/cli/libs/sdktypes/marketplaces/v1" + sdkmarketplaces "github.com/databricks/sdk-go/marketplaces/v1" ) // Slice with functions to override default command behavior. @@ -55,22 +58,22 @@ Installations are entities that allow consumers to interact with Databricks // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *marketplace.CreateInstallationRequest, + *marketplaces.CreateInstallationRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq marketplaces.CreateInstallationRequest - var createReq marketplace.CreateInstallationRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: accepted_consumer_terms - cmd.Flags().StringVar(&createReq.CatalogName, "catalog-name", createReq.CatalogName, ``) - cmd.Flags().Var(&createReq.RecipientType, "recipient-type", `Supported values: [DELTA_SHARING_RECIPIENT_TYPE_DATABRICKS, DELTA_SHARING_RECIPIENT_TYPE_OPEN]`) + flags.StringPtrVar(cmd.Flags(), &createReq.CatalogName, "catalog-name", ``) + flags.EnumVar(cmd.Flags(), &createReq.RecipientType, "recipient-type", `Supported values: [DELTA_SHARING_RECIPIENT_TYPE_DATABRICKS, DELTA_SHARING_RECIPIENT_TYPE_OPEN]`, "DeltaSharingRecipientType", "DELTA_SHARING_RECIPIENT_TYPE_DATABRICKS", "DELTA_SHARING_RECIPIENT_TYPE_OPEN") // TODO: complex arg: repo_detail - cmd.Flags().StringVar(&createReq.ShareName, "share-name", createReq.ShareName, ``) + flags.StringPtrVar(cmd.Flags(), &createReq.ShareName, "share-name", ``) cmd.Use = "create LISTING_ID" cmd.Short = `*Public Preview* Install from a listing.` @@ -93,6 +96,7 @@ Install from a listing. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -106,14 +110,22 @@ Install from a listing. } } } - createReq.ListingId = args[0] + createReq.ListingId = new(args[0]) - response, err := w.ConsumerInstallations.Create(ctx, createReq) + sdkReq, err := marketplaces.CreateInstallationRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Marketplaces.InstallListing(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.CreateInstallationResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -134,13 +146,12 @@ Install from a listing. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *marketplace.DeleteInstallationRequest, + *sdkmarketplaces.DeleteInstallationRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq marketplace.DeleteInstallationRequest + var deleteReq sdkmarketplaces.DeleteInstallationRequest cmd.Use = "delete LISTING_ID INSTALLATION_ID" cmd.Short = `*Public Preview* Uninstall from a listing.` @@ -163,14 +174,18 @@ Uninstall from a listing. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.ListingId = args[0] - deleteReq.InstallationId = args[1] + deleteReq.ListingId = new(args[0]) + deleteReq.InstallationId = new(args[1]) - err = w.ConsumerInstallations.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Marketplaces.UninstallListing(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -192,25 +207,25 @@ Uninstall from a listing. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *marketplace.ListAllInstallationsRequest, + *marketplaces.ListInstallationsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq marketplaces.ListInstallationsRequest - var listReq marketplace.ListAllInstallationsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -234,16 +249,20 @@ List all installations. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ConsumerInstallations.List(ctx, listReq) + sdkReq, err := marketplaces.ListInstallationsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.ListInstallationsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.InstallationDetailFromSDK)) } // Disable completions since they are not applicable. @@ -264,25 +283,25 @@ List all installations. // Functions can be added from the `init()` function in manually curated files in this directory. var listListingInstallationsOverrides []func( *cobra.Command, - *marketplace.ListInstallationsRequest, + *marketplaces.GetInstallationDetailsRequest, ) func newListListingInstallations() *cobra.Command { cmd := &cobra.Command{} + var listListingInstallationsReq marketplaces.GetInstallationDetailsRequest - var listListingInstallationsReq marketplace.ListInstallationsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listListingInstallationsLimit int - cmd.Flags().IntVar(&listListingInstallationsReq.PageSize, "page-size", listListingInstallationsReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listListingInstallationsReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listListingInstallationsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listListingInstallationsReq.PageToken, "page-token", listListingInstallationsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listListingInstallationsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-listing-installations LISTING_ID" @@ -306,18 +325,22 @@ List installations for a listing. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listListingInstallationsReq.ListingId = args[0] + listListingInstallationsReq.ListingId = new(args[0]) - response := w.ConsumerInstallations.ListListingInstallations(ctx, listListingInstallationsReq) + sdkReq, err := marketplaces.GetInstallationDetailsRequestToSDK(&listListingInstallationsReq) + if err != nil { + return err + } if listListingInstallationsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listListingInstallationsLimit) } if listListingInstallationsLimit > 0 { ctx = cmdio.WithLimit(ctx, listListingInstallationsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.GetInstallationDetailsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.InstallationDetailFromSDK)) } // Disable completions since they are not applicable. @@ -338,18 +361,18 @@ List installations for a listing. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *marketplace.UpdateInstallationRequest, + *marketplaces.UpdateInstallationRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq marketplaces.UpdateInstallationRequest - var updateReq marketplace.UpdateInstallationRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&updateReq.RotateToken, "rotate-token", updateReq.RotateToken, ``) + flags.BoolPtrVar(cmd.Flags(), &updateReq.RotateToken, "rotate-token", ``) cmd.Use = "update LISTING_ID INSTALLATION_ID" cmd.Short = `*Public Preview* Update an installation.` @@ -376,6 +399,7 @@ Update an installation. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -391,15 +415,23 @@ Update an installation. } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateReq.ListingId = args[0] - updateReq.InstallationId = args[1] + updateReq.ListingId = new(args[0]) + updateReq.InstallationId = new(args[1]) - response, err := w.ConsumerInstallations.Update(ctx, updateReq) + sdkReq, err := marketplaces.UpdateInstallationRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Marketplaces.UpdateInstallationDetail(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.UpdateInstallationResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/consumer-listings/consumer-listings.go b/cmd/workspace/consumer-listings/consumer-listings.go index 691fdada926..1c6b910a087 100644 --- a/cmd/workspace/consumer-listings/consumer-listings.go +++ b/cmd/workspace/consumer-listings/consumer-listings.go @@ -8,9 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/marketplace" + "github.com/databricks/cli/libs/flags" "github.com/spf13/cobra" + + marketplaces "github.com/databricks/cli/libs/sdktypes/marketplaces/v1" + sdkmarketplaces "github.com/databricks/sdk-go/marketplaces/v1" ) // Slice with functions to override default command behavior. @@ -53,13 +57,12 @@ Listings are the core entities in the Marketplace. They represent the products // Functions can be added from the `init()` function in manually curated files in this directory. var batchGetOverrides []func( *cobra.Command, - *marketplace.BatchGetListingsRequest, + *marketplaces.BatchGetListingsRequest, ) func newBatchGet() *cobra.Command { cmd := &cobra.Command{} - - var batchGetReq marketplace.BatchGetListingsRequest + var batchGetReq marketplaces.BatchGetListingsRequest // TODO: array: ids @@ -85,13 +88,22 @@ Get one batch of listings. One may specify up to 50 IDs per request. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response, err := w.ConsumerListings.BatchGet(ctx, batchGetReq) + sdkReq, err := marketplaces.BatchGetListingsRequestToSDK(&batchGetReq) + if err != nil { + return err + } + response, err := w.Marketplaces.BatchGetListings(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.BatchGetListingsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -112,13 +124,12 @@ Get one batch of listings. One may specify up to 50 IDs per request. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *marketplace.GetListingRequest, + *sdkmarketplaces.GetPublishedListingForConsumerRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq marketplace.GetListingRequest + var getReq sdkmarketplaces.GetPublishedListingForConsumerRequest cmd.Use = "get ID" cmd.Short = `*Public Preview* Get listing.` @@ -137,11 +148,12 @@ Get listing. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Consumer Listings drop-down.") - names, err := w.ConsumerListings.ListingSummaryNameToIdMap(ctx, marketplace.ListListingsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Marketplaces.ListPublishedListingsForConsumerIter(ctx, sdkmarketplaces.ListPublishedListingsForConsumerRequest{}), []string{"Summary", "Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Consumer Listings drop-down. Please manually specify required arguments. Original error: %w", err) @@ -155,14 +167,19 @@ Get listing. if len(args) != 1 { return errors.New("expected to have ") } - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.ConsumerListings.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Marketplaces.GetPublishedListingForConsumer(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.GetPublishedListingForConsumerResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -183,13 +200,13 @@ Get listing. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *marketplace.ListListingsRequest, + *marketplaces.ListPublishedListingsForConsumerRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq marketplaces.ListPublishedListingsForConsumerRequest - var listReq marketplace.ListListingsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -197,10 +214,10 @@ func newList() *cobra.Command { // TODO: array: assets // TODO: array: categories - cmd.Flags().BoolVar(&listReq.IsFree, "is-free", listReq.IsFree, `Filters each listing based on if it is free.`) - cmd.Flags().BoolVar(&listReq.IsPrivateExchange, "is-private-exchange", listReq.IsPrivateExchange, `Filters each listing based on if it is a private exchange.`) - cmd.Flags().BoolVar(&listReq.IsStaffPick, "is-staff-pick", listReq.IsStaffPick, `Filters each listing based on whether it is a staff pick.`) - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.BoolPtrVar(cmd.Flags(), &listReq.IsFree, "is-free", `Filters each listing based on if it is free.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IsPrivateExchange, "is-private-exchange", `Filters each listing based on if it is a private exchange.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IsStaffPick, "is-staff-pick", `Filters each listing based on whether it is a staff pick.`) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // TODO: array: provider_ids // TODO: complex arg: tags @@ -208,7 +225,7 @@ func newList() *cobra.Command { cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -233,16 +250,20 @@ List listings. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ConsumerListings.List(ctx, listReq) + sdkReq, err := marketplaces.ListPublishedListingsForConsumerRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.ListPublishedListingsForConsumerIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.ListingFromSDK)) } // Disable completions since they are not applicable. @@ -263,13 +284,13 @@ List listings. // Functions can be added from the `init()` function in manually curated files in this directory. var searchOverrides []func( *cobra.Command, - *marketplace.SearchListingsRequest, + *marketplaces.SearchPublishedListingsForConsumerRequest, ) func newSearch() *cobra.Command { cmd := &cobra.Command{} + var searchReq marketplaces.SearchPublishedListingsForConsumerRequest - var searchReq marketplace.SearchListingsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -277,16 +298,16 @@ func newSearch() *cobra.Command { // TODO: array: assets // TODO: array: categories - cmd.Flags().BoolVar(&searchReq.IsFree, "is-free", searchReq.IsFree, ``) - cmd.Flags().BoolVar(&searchReq.IsPrivateExchange, "is-private-exchange", searchReq.IsPrivateExchange, ``) - cmd.Flags().IntVar(&searchReq.PageSize, "page-size", searchReq.PageSize, ``) + flags.BoolPtrVar(cmd.Flags(), &searchReq.IsFree, "is-free", ``) + flags.BoolPtrVar(cmd.Flags(), &searchReq.IsPrivateExchange, "is-private-exchange", ``) + flags.IntPtrVar(cmd.Flags(), &searchReq.PageSize, "page-size", ``) // TODO: array: provider_ids // Limit flag for total result capping. cmd.Flags().IntVar(&searchLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&searchReq.PageToken, "page-token", searchReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &searchReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "search QUERY" @@ -310,11 +331,12 @@ Search listings. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No QUERY argument specified. Loading names for Consumer Listings drop-down.") - names, err := w.ConsumerListings.ListingSummaryNameToIdMap(ctx, marketplace.ListListingsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Marketplaces.ListPublishedListingsForConsumerIter(ctx, sdkmarketplaces.ListPublishedListingsForConsumerRequest{}), []string{"Summary", "Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Consumer Listings drop-down. Please manually specify required arguments. Original error: %w", err) @@ -328,17 +350,20 @@ Search listings. if len(args) != 1 { return errors.New("expected to have fuzzy matches query") } - searchReq.Query = args[0] + searchReq.Query = new(args[0]) - response := w.ConsumerListings.Search(ctx, searchReq) + sdkReq, err := marketplaces.SearchPublishedListingsForConsumerRequestToSDK(&searchReq) + if err != nil { + return err + } if searchLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", searchLimit) } if searchLimit > 0 { ctx = cmdio.WithLimit(ctx, searchLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.SearchPublishedListingsForConsumerIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.ListingFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go b/cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go index ff2f4c0e55c..dbb252171ca 100644 --- a/cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go +++ b/cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" + + marketplaces "github.com/databricks/cli/libs/sdktypes/marketplaces/v1" + sdkmarketplaces "github.com/databricks/sdk-go/marketplaces/v1" ) // Slice with functions to override default command behavior. @@ -53,23 +56,23 @@ Personalization Requests allow customers to interact with the individualized // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *marketplace.CreatePersonalizationRequest, + *marketplaces.CreatePersonalizationRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq marketplaces.CreatePersonalizationRequest - var createReq marketplace.CreatePersonalizationRequest 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.Comment, "comment", createReq.Comment, ``) - cmd.Flags().StringVar(&createReq.Company, "company", createReq.Company, ``) - cmd.Flags().StringVar(&createReq.FirstName, "first-name", createReq.FirstName, ``) - cmd.Flags().BoolVar(&createReq.IsFromLighthouse, "is-from-lighthouse", createReq.IsFromLighthouse, ``) - cmd.Flags().StringVar(&createReq.LastName, "last-name", createReq.LastName, ``) - cmd.Flags().Var(&createReq.RecipientType, "recipient-type", `Supported values: [DELTA_SHARING_RECIPIENT_TYPE_DATABRICKS, DELTA_SHARING_RECIPIENT_TYPE_OPEN]`) + flags.StringPtrVar(cmd.Flags(), &createReq.Comment, "comment", ``) + flags.StringPtrVar(cmd.Flags(), &createReq.Company, "company", ``) + flags.StringPtrVar(cmd.Flags(), &createReq.FirstName, "first-name", ``) + flags.BoolPtrVar(cmd.Flags(), &createReq.IsFromLighthouse, "is-from-lighthouse", ``) + flags.StringPtrVar(cmd.Flags(), &createReq.LastName, "last-name", ``) + flags.EnumVar(cmd.Flags(), &createReq.RecipientType, "recipient-type", `Supported values: [DELTA_SHARING_RECIPIENT_TYPE_DATABRICKS, DELTA_SHARING_RECIPIENT_TYPE_OPEN]`, "DeltaSharingRecipientType", "DELTA_SHARING_RECIPIENT_TYPE_DATABRICKS", "DELTA_SHARING_RECIPIENT_TYPE_OPEN") cmd.Use = "create LISTING_ID" cmd.Short = `*Public Preview* Create a personalization request.` @@ -92,6 +95,7 @@ Create a personalization request. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -107,14 +111,22 @@ Create a personalization request. } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - createReq.ListingId = args[0] + createReq.ListingId = new(args[0]) - response, err := w.ConsumerPersonalizationRequests.Create(ctx, createReq) + sdkReq, err := marketplaces.CreatePersonalizationRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Marketplaces.CreatePersonalizationRequest(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.CreatePersonalizationResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -135,13 +147,12 @@ Create a personalization request. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *marketplace.GetPersonalizationRequestRequest, + *sdkmarketplaces.GetPersonalizationRequestsForConsumerRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq marketplace.GetPersonalizationRequestRequest + var getReq sdkmarketplaces.GetPersonalizationRequestsForConsumerRequest cmd.Use = "get LISTING_ID" cmd.Short = `*Public Preview* Get the personalization request for a listing.` @@ -165,15 +176,21 @@ Get the personalization request for a listing. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.ListingId = args[0] + getReq.ListingId = new(args[0]) - response, err := w.ConsumerPersonalizationRequests.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Marketplaces.GetPersonalizationRequestsForConsumer(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.GetPersonalizationRequestsForConsumerResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -194,25 +211,25 @@ Get the personalization request for a listing. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *marketplace.ListAllPersonalizationRequestsRequest, + *marketplaces.ListPersonalizationRequestsForConsumerRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq marketplaces.ListPersonalizationRequestsForConsumerRequest - var listReq marketplace.ListAllPersonalizationRequestsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -236,16 +253,20 @@ List all personalization requests. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ConsumerPersonalizationRequests.List(ctx, listReq) + sdkReq, err := marketplaces.ListPersonalizationRequestsForConsumerRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.ListPersonalizationRequestsForConsumerIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.PersonalizationRequestFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/consumer-providers/consumer-providers.go b/cmd/workspace/consumer-providers/consumer-providers.go index 03ee75f84ce..dcc653dfe96 100644 --- a/cmd/workspace/consumer-providers/consumer-providers.go +++ b/cmd/workspace/consumer-providers/consumer-providers.go @@ -8,9 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/marketplace" + "github.com/databricks/cli/libs/flags" "github.com/spf13/cobra" + + marketplaces "github.com/databricks/cli/libs/sdktypes/marketplaces/v1" + sdkmarketplaces "github.com/databricks/sdk-go/marketplaces/v1" ) // Slice with functions to override default command behavior. @@ -51,13 +55,12 @@ Providers are the entities that publish listings to the Marketplace.`, // Functions can be added from the `init()` function in manually curated files in this directory. var batchGetOverrides []func( *cobra.Command, - *marketplace.BatchGetProvidersRequest, + *marketplaces.BatchGetProvidersRequest, ) func newBatchGet() *cobra.Command { cmd := &cobra.Command{} - - var batchGetReq marketplace.BatchGetProvidersRequest + var batchGetReq marketplaces.BatchGetProvidersRequest // TODO: array: ids @@ -83,13 +86,22 @@ Get one batch of providers. One may specify up to 50 IDs per request. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response, err := w.ConsumerProviders.BatchGet(ctx, batchGetReq) + sdkReq, err := marketplaces.BatchGetProvidersRequestToSDK(&batchGetReq) + if err != nil { + return err + } + response, err := w.Marketplaces.BatchGetProviders(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.BatchGetProvidersResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -110,13 +122,12 @@ Get one batch of providers. One may specify up to 50 IDs per request. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *marketplace.GetProviderRequest, + *sdkmarketplaces.GetPublishedProviderForConsumerRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq marketplace.GetProviderRequest + var getReq sdkmarketplaces.GetPublishedProviderForConsumerRequest cmd.Use = "get ID" cmd.Short = `*Public Preview* Get a provider.` @@ -135,11 +146,12 @@ Get a provider. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Consumer Providers drop-down.") - names, err := w.ConsumerProviders.ProviderInfoNameToIdMap(ctx, marketplace.ListConsumerProvidersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Marketplaces.ListPublishedProvidersForConsumerIter(ctx, sdkmarketplaces.ListPublishedProvidersForConsumerRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Consumer Providers drop-down. Please manually specify required arguments. Original error: %w", err) @@ -153,14 +165,19 @@ Get a provider. if len(args) != 1 { return errors.New("expected to have ") } - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.ConsumerProviders.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Marketplaces.GetPublishedProviderForConsumer(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.GetPublishedProviderForConsumerResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -181,26 +198,26 @@ Get a provider. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *marketplace.ListConsumerProvidersRequest, + *marketplaces.ListPublishedProvidersForConsumerRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq marketplaces.ListPublishedProvidersForConsumerRequest - var listReq marketplace.ListConsumerProvidersRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().BoolVar(&listReq.IsFeatured, "is-featured", listReq.IsFeatured, ``) - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.BoolPtrVar(cmd.Flags(), &listReq.IsFeatured, "is-featured", ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -225,16 +242,20 @@ List providers. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ConsumerProviders.List(ctx, listReq) + sdkReq, err := marketplaces.ListPublishedProvidersForConsumerRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.ListPublishedProvidersForConsumerIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.ProviderInfoFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/credentials-manager/credentials-manager.go b/cmd/workspace/credentials-manager/credentials-manager.go index 6c960ed692f..9555ffec0fd 100644 --- a/cmd/workspace/credentials-manager/credentials-manager.go +++ b/cmd/workspace/credentials-manager/credentials-manager.go @@ -6,10 +6,11 @@ import ( "errors" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -51,13 +52,14 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var exchangeTokenOverrides []func( *cobra.Command, - *settings.ExchangeTokenRequest, + *map[string]any, ) func newExchangeToken() *cobra.Command { cmd := &cobra.Command{} + var exchangeTokenReq map[string]any + exchangeTokenReq = map[string]any{} - var exchangeTokenReq settings.ExchangeTokenRequest var exchangeTokenJson flags.JsonFlag cmd.Flags().Var(&exchangeTokenJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -88,6 +90,7 @@ func newExchangeToken() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := exchangeTokenJson.Unmarshal(&exchangeTokenReq) @@ -104,11 +107,18 @@ func newExchangeToken() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.CredentialsManager.ExchangeToken(ctx, exchangeTokenReq) + rawQuery := map[string]any{} + rawPath := "/api/2.0/credentials-manager/exchange-tokens/token" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, exchangeTokenReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/credentials/credentials.go b/cmd/workspace/credentials/credentials.go index 60348246c1b..165cbb15e86 100644 --- a/cmd/workspace/credentials/credentials.go +++ b/cmd/workspace/credentials/credentials.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + uccredentials "github.com/databricks/cli/libs/sdktypes/uc/credentials/v1" + sdkuccredentials "github.com/databricks/sdk-go/uc/credentials/v1" ) // Slice with functions to override default command behavior. @@ -61,13 +64,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createCredentialOverrides []func( *cobra.Command, - *catalog.CreateCredentialRequest, + *uccredentials.CreateCredentialRequest, ) func newCreateCredential() *cobra.Command { cmd := &cobra.Command{} + var createCredentialReq uccredentials.CreateCredentialRequest - var createCredentialReq catalog.CreateCredentialRequest var createCredentialJson flags.JsonFlag cmd.Flags().Var(&createCredentialJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -75,11 +78,11 @@ func newCreateCredential() *cobra.Command { // TODO: complex arg: aws_iam_role // TODO: complex arg: azure_managed_identity // TODO: complex arg: azure_service_principal - cmd.Flags().StringVar(&createCredentialReq.Comment, "comment", createCredentialReq.Comment, `Comment associated with the credential.`) + flags.StringPtrVar(cmd.Flags(), &createCredentialReq.Comment, "comment", `Comment associated with the credential.`) // TODO: complex arg: databricks_gcp_service_account - cmd.Flags().Var(&createCredentialReq.Purpose, "purpose", `Indicates the purpose of the credential. Supported values: [SERVICE, STORAGE]`) - cmd.Flags().BoolVar(&createCredentialReq.ReadOnly, "read-only", createCredentialReq.ReadOnly, `Whether the credential is usable only for read operations.`) - cmd.Flags().BoolVar(&createCredentialReq.SkipValidation, "skip-validation", createCredentialReq.SkipValidation, `Optional.`) + // TODO: field not in sdk-go request: purpose + flags.BoolPtrVar(cmd.Flags(), &createCredentialReq.ReadOnly, "read-only", `Whether the credential is usable only for read operations.`) + flags.BoolPtrVar(cmd.Flags(), &createCredentialReq.SkipValidation, "skip-validation", `Optional.`) cmd.Use = "create-credential NAME" cmd.Short = `Create a credential.` @@ -116,6 +119,7 @@ func newCreateCredential() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createCredentialJson.Unmarshal(&createCredentialReq) @@ -130,15 +134,23 @@ func newCreateCredential() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createCredentialReq.Name = args[0] + createCredentialReq.Name = new(args[0]) } - response, err := w.Credentials.CreateCredential(ctx, createCredentialReq) + sdkReq, err := uccredentials.CreateCredentialRequestToSDK(&createCredentialReq) + if err != nil { + return err + } + response, err := w.Credentials.CreateCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.StorageCredentialInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -159,15 +171,14 @@ func newCreateCredential() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteCredentialOverrides []func( *cobra.Command, - *catalog.DeleteCredentialRequest, + *uccredentials.DeleteCredentialRequest, ) func newDeleteCredential() *cobra.Command { cmd := &cobra.Command{} + var deleteCredentialReq uccredentials.DeleteCredentialRequest - var deleteCredentialReq catalog.DeleteCredentialRequest - - cmd.Flags().BoolVar(&deleteCredentialReq.Force, "force", deleteCredentialReq.Force, `Force an update even if there are dependent services (when purpose is **SERVICE**) or dependent external locations and external tables (when purpose is **STORAGE**).`) + flags.BoolPtrVar(cmd.Flags(), &deleteCredentialReq.Force, "force", `Force an update even if there are dependent services (when purpose is **SERVICE**) or dependent external locations and external tables (when purpose is **STORAGE**).`) cmd.Use = "delete-credential NAME_ARG" cmd.Short = `Delete a credential.` @@ -192,13 +203,20 @@ func newDeleteCredential() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteCredentialReq.NameArg = args[0] + deleteCredentialReq.NameArg = new(args[0]) - err = w.Credentials.DeleteCredential(ctx, deleteCredentialReq) + sdkReq, err := uccredentials.DeleteCredentialRequestToSDK(&deleteCredentialReq) if err != nil { return err } + response, err := w.Credentials.DeleteCredential(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -220,13 +238,13 @@ func newDeleteCredential() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var generateTemporaryServiceCredentialOverrides []func( *cobra.Command, - *catalog.GenerateTemporaryServiceCredentialRequest, + *uccredentials.GenerateTemporaryServiceCredentialRequest, ) func newGenerateTemporaryServiceCredential() *cobra.Command { cmd := &cobra.Command{} + var generateTemporaryServiceCredentialReq uccredentials.GenerateTemporaryServiceCredentialRequest - var generateTemporaryServiceCredentialReq catalog.GenerateTemporaryServiceCredentialRequest var generateTemporaryServiceCredentialJson flags.JsonFlag cmd.Flags().Var(&generateTemporaryServiceCredentialJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -265,6 +283,7 @@ func newGenerateTemporaryServiceCredential() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := generateTemporaryServiceCredentialJson.Unmarshal(&generateTemporaryServiceCredentialReq) @@ -279,15 +298,23 @@ func newGenerateTemporaryServiceCredential() *cobra.Command { } } if !cmd.Flags().Changed("json") { - generateTemporaryServiceCredentialReq.CredentialName = args[0] + generateTemporaryServiceCredentialReq.CredentialName = new(args[0]) } - response, err := w.Credentials.GenerateTemporaryServiceCredential(ctx, generateTemporaryServiceCredentialReq) + sdkReq, err := uccredentials.GenerateTemporaryServiceCredentialRequestToSDK(&generateTemporaryServiceCredentialReq) + if err != nil { + return err + } + response, err := w.Credentials.GenerateTemporaryServiceCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.TemporaryCredentialsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -308,13 +335,12 @@ func newGenerateTemporaryServiceCredential() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getCredentialOverrides []func( *cobra.Command, - *catalog.GetCredentialRequest, + *sdkuccredentials.GetCredentialRequest, ) func newGetCredential() *cobra.Command { cmd := &cobra.Command{} - - var getCredentialReq catalog.GetCredentialRequest + var getCredentialReq sdkuccredentials.GetCredentialRequest cmd.Use = "get-credential NAME_ARG" cmd.Short = `Get a credential.` @@ -340,15 +366,21 @@ func newGetCredential() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getCredentialReq.NameArg = args[0] + getCredentialReq.NameArg = new(args[0]) - response, err := w.Credentials.GetCredential(ctx, getCredentialReq) + sdkReq := &getCredentialReq + response, err := w.Credentials.GetCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.StorageCredentialInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -369,27 +401,27 @@ func newGetCredential() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listCredentialsOverrides []func( *cobra.Command, - *catalog.ListCredentialsRequest, + *uccredentials.ListCredentialsRequest, ) func newListCredentials() *cobra.Command { cmd := &cobra.Command{} + var listCredentialsReq uccredentials.ListCredentialsRequest - var listCredentialsReq catalog.ListCredentialsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listCredentialsLimit int - cmd.Flags().BoolVar(&listCredentialsReq.IncludeUnbound, "include-unbound", listCredentialsReq.IncludeUnbound, `Whether to include credentials not bound to the workspace.`) - cmd.Flags().IntVar(&listCredentialsReq.MaxResults, "max-results", listCredentialsReq.MaxResults, `Maximum number of credentials to return.`) - cmd.Flags().Var(&listCredentialsReq.Purpose, "purpose", `Return only credentials for the specified purpose. Supported values: [SERVICE, STORAGE]`) + flags.BoolPtrVar(cmd.Flags(), &listCredentialsReq.IncludeUnbound, "include-unbound", `Whether to include credentials not bound to the workspace.`) + flags.IntPtrVar(cmd.Flags(), &listCredentialsReq.MaxResults, "max-results", `Maximum number of credentials to return.`) + // TODO: field not in sdk-go request: purpose // Limit flag for total result capping. cmd.Flags().IntVar(&listCredentialsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listCredentialsReq.PageToken, "page-token", listCredentialsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listCredentialsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-credentials" @@ -421,16 +453,20 @@ func newListCredentials() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Credentials.ListCredentials(ctx, listCredentialsReq) + sdkReq, err := uccredentials.ListCredentialsRequestToSDK(&listCredentialsReq) + if err != nil { + return err + } if listCredentialsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listCredentialsLimit) } if listCredentialsLimit > 0 { ctx = cmdio.WithLimit(ctx, listCredentialsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Credentials.ListCredentialsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, uccredentials.CredentialInfoFromSDK)) } // Disable completions since they are not applicable. @@ -451,13 +487,13 @@ func newListCredentials() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateCredentialOverrides []func( *cobra.Command, - *catalog.UpdateCredentialRequest, + *uccredentials.UpdateCredentialRequest, ) func newUpdateCredential() *cobra.Command { cmd := &cobra.Command{} + var updateCredentialReq uccredentials.UpdateCredentialRequest - var updateCredentialReq catalog.UpdateCredentialRequest var updateCredentialJson flags.JsonFlag cmd.Flags().Var(&updateCredentialJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -465,14 +501,14 @@ func newUpdateCredential() *cobra.Command { // TODO: complex arg: aws_iam_role // TODO: complex arg: azure_managed_identity // TODO: complex arg: azure_service_principal - cmd.Flags().StringVar(&updateCredentialReq.Comment, "comment", updateCredentialReq.Comment, `Comment associated with the credential.`) + flags.StringPtrVar(cmd.Flags(), &updateCredentialReq.Comment, "comment", `Comment associated with the credential.`) // TODO: complex arg: databricks_gcp_service_account - cmd.Flags().BoolVar(&updateCredentialReq.Force, "force", updateCredentialReq.Force, `Force an update even if there are dependent services (when purpose is **SERVICE**) or dependent external locations and external tables (when purpose is **STORAGE**).`) - cmd.Flags().Var(&updateCredentialReq.IsolationMode, "isolation-mode", `Whether the current securable is accessible from all workspaces or a specific set of workspaces. Supported values: [ISOLATION_MODE_ISOLATED, ISOLATION_MODE_OPEN]`) - cmd.Flags().StringVar(&updateCredentialReq.NewName, "new-name", updateCredentialReq.NewName, `New name of credential.`) - cmd.Flags().StringVar(&updateCredentialReq.Owner, "owner", updateCredentialReq.Owner, `Username of current owner of credential.`) - cmd.Flags().BoolVar(&updateCredentialReq.ReadOnly, "read-only", updateCredentialReq.ReadOnly, `Whether the credential is usable only for read operations.`) - cmd.Flags().BoolVar(&updateCredentialReq.SkipValidation, "skip-validation", updateCredentialReq.SkipValidation, `Supply true to this argument to skip validation of the updated credential.`) + flags.BoolPtrVar(cmd.Flags(), &updateCredentialReq.Force, "force", `Force an update even if there are dependent services (when purpose is **SERVICE**) or dependent external locations and external tables (when purpose is **STORAGE**).`) + flags.EnumVar(cmd.Flags(), &updateCredentialReq.IsolationMode, "isolation-mode", `Whether the current securable is accessible from all workspaces or a specific set of workspaces. Supported values: [ISOLATION_MODE_ISOLATED, ISOLATION_MODE_OPEN]`, "IsolationMode", "ISOLATION_MODE_ISOLATED", "ISOLATION_MODE_OPEN") + flags.StringPtrVar(cmd.Flags(), &updateCredentialReq.NewName, "new-name", `New name of credential.`) + flags.StringPtrVar(cmd.Flags(), &updateCredentialReq.Owner, "owner", `Username of current owner of credential.`) + flags.BoolPtrVar(cmd.Flags(), &updateCredentialReq.ReadOnly, "read-only", `Whether the credential is usable only for read operations.`) + flags.BoolPtrVar(cmd.Flags(), &updateCredentialReq.SkipValidation, "skip-validation", `Supply true to this argument to skip validation of the updated credential.`) cmd.Use = "update-credential NAME_ARG" cmd.Short = `Update a credential.` @@ -500,6 +536,7 @@ func newUpdateCredential() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateCredentialJson.Unmarshal(&updateCredentialReq) @@ -513,14 +550,22 @@ func newUpdateCredential() *cobra.Command { } } } - updateCredentialReq.NameArg = args[0] + updateCredentialReq.NameArg = new(args[0]) - response, err := w.Credentials.UpdateCredential(ctx, updateCredentialReq) + sdkReq, err := uccredentials.UpdateCredentialRequestToSDK(&updateCredentialReq) + if err != nil { + return err + } + response, err := w.Credentials.UpdateCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.StorageCredentialInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -541,25 +586,25 @@ func newUpdateCredential() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var validateCredentialOverrides []func( *cobra.Command, - *catalog.ValidateCredentialRequest, + *uccredentials.ValidateCredentialRequest, ) func newValidateCredential() *cobra.Command { cmd := &cobra.Command{} + var validateCredentialReq uccredentials.ValidateCredentialRequest - var validateCredentialReq catalog.ValidateCredentialRequest var validateCredentialJson flags.JsonFlag cmd.Flags().Var(&validateCredentialJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: aws_iam_role // TODO: complex arg: azure_managed_identity - cmd.Flags().StringVar(&validateCredentialReq.CredentialName, "credential-name", validateCredentialReq.CredentialName, `Required.`) + flags.StringPtrVar(cmd.Flags(), &validateCredentialReq.CredentialName, "credential-name", `Required.`) // TODO: complex arg: databricks_gcp_service_account - cmd.Flags().StringVar(&validateCredentialReq.ExternalLocationName, "external-location-name", validateCredentialReq.ExternalLocationName, `The name of an existing external location to validate.`) - cmd.Flags().Var(&validateCredentialReq.Purpose, "purpose", `The purpose of the credential. Supported values: [SERVICE, STORAGE]`) - cmd.Flags().BoolVar(&validateCredentialReq.ReadOnly, "read-only", validateCredentialReq.ReadOnly, `Whether the credential is only usable for read operations.`) - cmd.Flags().StringVar(&validateCredentialReq.Url, "url", validateCredentialReq.Url, `The external location url to validate.`) + flags.StringPtrVar(cmd.Flags(), &validateCredentialReq.ExternalLocationName, "external-location-name", `The name of an existing external location to validate.`) + // TODO: field not in sdk-go request: purpose + flags.BoolPtrVar(cmd.Flags(), &validateCredentialReq.ReadOnly, "read-only", `Whether the credential is only usable for read operations.`) + flags.StringPtrVar(cmd.Flags(), &validateCredentialReq.Url, "url", `The external location url to validate.`) cmd.Use = "validate-credential" cmd.Short = `Validate a credential.` @@ -594,6 +639,7 @@ func newValidateCredential() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := validateCredentialJson.Unmarshal(&validateCredentialReq) @@ -608,12 +654,20 @@ func newValidateCredential() *cobra.Command { } } - response, err := w.Credentials.ValidateCredential(ctx, validateCredentialReq) + sdkReq, err := uccredentials.ValidateCredentialRequestToSDK(&validateCredentialReq) + if err != nil { + return err + } + response, err := w.Credentials.ValidateCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.ValidateCredentialResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/current-user/current-user.go b/cmd/workspace/current-user/current-user.go index de32f481229..d1b2782bb4c 100644 --- a/cmd/workspace/current-user/current-user.go +++ b/cmd/workspace/current-user/current-user.go @@ -6,8 +6,10 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/flags" "github.com/spf13/cobra" + + scim "github.com/databricks/cli/libs/sdktypes/scim/v1" ) // Slice with functions to override default command behavior. @@ -47,16 +49,15 @@ This API allows retrieving information about currently authenticated user or // Functions can be added from the `init()` function in manually curated files in this directory. var meOverrides []func( *cobra.Command, - *iam.MeRequest, + *scim.MeRequest, ) func newMe() *cobra.Command { cmd := &cobra.Command{} + var meReq scim.MeRequest - var meReq iam.MeRequest - - cmd.Flags().StringVar(&meReq.Attributes, "attributes", meReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().StringVar(&meReq.ExcludedAttributes, "excluded-attributes", meReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) + flags.StringPtrVar(cmd.Flags(), &meReq.Attributes, "attributes", `Comma-separated list of attributes to return in response.`) + flags.StringPtrVar(cmd.Flags(), &meReq.ExcludedAttributes, "excluded-attributes", `Comma-separated list of attributes to exclude in response.`) cmd.Use = "me" cmd.Short = `*Public Preview* Get current user info.` @@ -79,13 +80,22 @@ Get current user info. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response, err := w.CurrentUser.Me(ctx, meReq) + sdkReq, err := scim.MeRequestToSDK(&meReq) + if err != nil { + return err + } + response, err := w.Scim.Me(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.UserFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/dashboard-email-subscriptions/dashboard-email-subscriptions.go b/cmd/workspace/dashboard-email-subscriptions/dashboard-email-subscriptions.go index b8cb554761f..00da3019528 100644 --- a/cmd/workspace/dashboard-email-subscriptions/dashboard-email-subscriptions.go +++ b/cmd/workspace/dashboard-email-subscriptions/dashboard-email-subscriptions.go @@ -5,11 +5,14 @@ package dashboard_email_subscriptions import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -52,15 +55,16 @@ Controls whether schedules or workload tasks for refreshing AI/BI Dashboards // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteDashboardEmailSubscriptionsRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeleteDashboardEmailSubscriptionsRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `*Public Preview* Delete the Dashboard Email Subscriptions setting.` @@ -83,12 +87,24 @@ Delete the Dashboard Email Subscriptions setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := "/api/2.0/settings/types/dashboard_email_subscriptions/names/default" - response, err := w.Settings.DashboardEmailSubscriptions().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -110,15 +126,16 @@ Delete the Dashboard Email Subscriptions setting. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetDashboardEmailSubscriptionsRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetDashboardEmailSubscriptionsRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `*Public Preview* Get the Dashboard Email Subscriptions setting.` @@ -141,12 +158,24 @@ Get the Dashboard Email Subscriptions setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/dashboard_email_subscriptions/names/default" - response, err := w.Settings.DashboardEmailSubscriptions().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -168,13 +197,16 @@ Get the Dashboard Email Subscriptions setting. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateDashboardEmailSubscriptionsRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateDashboardEmailSubscriptionsRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -195,6 +227,7 @@ Update the Dashboard Email Subscriptions setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -211,11 +244,24 @@ Update the Dashboard Email Subscriptions setting. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.DashboardEmailSubscriptions().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/dashboard_email_subscriptions/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/dashboard-widgets/dashboard-widgets.go b/cmd/workspace/dashboard-widgets/dashboard-widgets.go index b417deb6c32..1465d15d88f 100644 --- a/cmd/workspace/dashboard-widgets/dashboard-widgets.go +++ b/cmd/workspace/dashboard-widgets/dashboard-widgets.go @@ -4,12 +4,16 @@ package dashboard_widgets import ( "errors" + "fmt" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/sql" "github.com/spf13/cobra" ) @@ -54,19 +58,24 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *sql.CreateWidget, + *map[string]any, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq map[string]any + createReq = map[string]any{} + var createDashboardIdRaw string + var createTextRaw string + var createVisualizationIdRaw string + var createWidthRaw int - var createReq sql.CreateWidget 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.Text, "text", createReq.Text, `If this is a textbox widget, the application displays this text.`) - cmd.Flags().StringVar(&createReq.VisualizationId, "visualization-id", createReq.VisualizationId, `Query Visualization ID returned by :method:queryvisualizations/create.`) + cmd.Flags().StringVar(&createTextRaw, "text", createTextRaw, `If this is a textbox widget, the application displays this text.`) + cmd.Flags().StringVar(&createVisualizationIdRaw, "visualization-id", createVisualizationIdRaw, `Query Visualization ID returned by :method:queryvisualizations/create.`) cmd.Use = "create" cmd.Short = `Add widget to a dashboard.` @@ -82,6 +91,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -98,11 +108,30 @@ func newCreate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.DashboardWidgets.Create(ctx, createReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("dashboard-id") || createDashboardIdRaw != "" { + createReq["dashboard_id"] = createDashboardIdRaw + } + if cmd.Flags().Changed("text") || createTextRaw != "" { + createReq["text"] = createTextRaw + } + if cmd.Flags().Changed("visualization-id") || createVisualizationIdRaw != "" { + createReq["visualization_id"] = createVisualizationIdRaw + } + if cmd.Flags().Changed("width") || createWidthRaw != 0 { + createReq["width"] = createWidthRaw + } + rawPath := "/api/2.0/preview/sql/widgets" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -124,13 +153,14 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sql.DeleteDashboardWidgetRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sql.DeleteDashboardWidgetRequest + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteIdRaw string cmd.Use = "delete ID" cmd.Short = `Remove widget.` @@ -154,10 +184,19 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + deleteIdRaw = args[0] - deleteReq.Id = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/preview/sql/widgets/%s", fmt.Sprint(deleteIdRaw)) - err = w.DashboardWidgets.Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -182,19 +221,25 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *sql.UpdateWidgetRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateDashboardIdRaw string + var updateIdRaw string + var updateTextRaw string + var updateVisualizationIdRaw string + var updateWidthRaw int - var updateReq sql.UpdateWidgetRequest 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.Text, "text", updateReq.Text, `If this is a textbox widget, the application displays this text.`) - cmd.Flags().StringVar(&updateReq.VisualizationId, "visualization-id", updateReq.VisualizationId, `Query Visualization ID returned by :method:queryvisualizations/create.`) + cmd.Flags().StringVar(&updateTextRaw, "text", updateTextRaw, `If this is a textbox widget, the application displays this text.`) + cmd.Flags().StringVar(&updateVisualizationIdRaw, "visualization-id", updateVisualizationIdRaw, `Query Visualization ID returned by :method:queryvisualizations/create.`) cmd.Use = "update ID" cmd.Short = `Update existing widget.` @@ -218,6 +263,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -233,13 +279,32 @@ func newUpdate() *cobra.Command { } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateReq.Id = args[0] + updateIdRaw = args[0] + + rawQuery := map[string]any{} + if cmd.Flags().Changed("dashboard-id") || updateDashboardIdRaw != "" { + updateReq["dashboard_id"] = updateDashboardIdRaw + } + if cmd.Flags().Changed("text") || updateTextRaw != "" { + updateReq["text"] = updateTextRaw + } + if cmd.Flags().Changed("visualization-id") || updateVisualizationIdRaw != "" { + updateReq["visualization_id"] = updateVisualizationIdRaw + } + if cmd.Flags().Changed("width") || updateWidthRaw != 0 { + updateReq["width"] = updateWidthRaw + } + rawPath := fmt.Sprintf("/api/2.0/preview/sql/widgets/%s", fmt.Sprint(updateIdRaw)) - response, err := w.DashboardWidgets.Update(ctx, updateReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/dashboards/dashboards.go b/cmd/workspace/dashboards/dashboards.go index 5eb7ed2d3a1..26f41b02023 100644 --- a/cmd/workspace/dashboards/dashboards.go +++ b/cmd/workspace/dashboards/dashboards.go @@ -5,11 +5,14 @@ package dashboards import ( "fmt" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/sql" "github.com/spf13/cobra" ) @@ -61,13 +64,14 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sql.DeleteDashboardRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sql.DeleteDashboardRequest + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteDashboardIdRaw string cmd.Use = "delete DASHBOARD_ID" cmd.Short = `Remove a dashboard.` @@ -94,10 +98,19 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + deleteDashboardIdRaw = args[0] - deleteReq.DashboardId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/preview/sql/dashboards/%s", fmt.Sprint(deleteDashboardIdRaw)) - err = w.Dashboards.Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -122,13 +135,14 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *sql.GetDashboardRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq sql.GetDashboardRequest + var getReq map[string]any + getReq = map[string]any{} + var getDashboardIdRaw string cmd.Use = "get DASHBOARD_ID" cmd.Short = `Retrieve a definition.` @@ -155,14 +169,23 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getDashboardIdRaw = args[0] - getReq.DashboardId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/preview/sql/dashboards/%s", fmt.Sprint(getDashboardIdRaw)) - response, err := w.Dashboards.Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -184,28 +207,33 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *sql.ListDashboardsRequest, + *map[string]any, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq map[string]any + listReq = map[string]any{} + var listOrderRaw string + var listPageRaw int + var listPageSizeRaw int + var listQRaw string - var listReq sql.ListDashboardsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().Var(&listReq.Order, "order", `Name of dashboard attribute to order by. Supported values: [created_at, name]`) - cmd.Flags().StringVar(&listReq.Q, "q", listReq.Q, `Full text search term.`) + flags.EnumVar(cmd.Flags(), &listOrderRaw, "order", `Name of dashboard attribute to order by. Supported values: [created_at, name]`, "ListOrder", "created_at", "name") + cmd.Flags().StringVar(&listQRaw, "q", listQRaw, `Full text search term.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().IntVar(&listReq.Page, "page", listReq.Page, `Page number to retrieve.`) + cmd.Flags().IntVar(&listPageRaw, "page", listPageRaw, `Page number to retrieve.`) cmd.Flags().Lookup("page").Hidden = true - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `Number of results per API page.`) + cmd.Flags().IntVar(&listPageSizeRaw, "page-size", listPageSizeRaw, `Number of results per API page.`) cmd.Flags().Lookup("page-size").Hidden = true cmd.Use = "list" @@ -235,16 +263,37 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Dashboards.List(ctx, listReq) - if listLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("order") || listOrderRaw != "" { + rawQuery["order"] = listOrderRaw + } + if cmd.Flags().Changed("page") || listPageRaw != 0 { + rawQuery["page"] = listPageRaw } - if listLimit > 0 { - ctx = cmdio.WithLimit(ctx, listLimit) + if cmd.Flags().Changed("page-size") || listPageSizeRaw != 0 { + rawQuery["page_size"] = listPageSizeRaw } + if cmd.Flags().Changed("q") || listQRaw != "" { + rawQuery["q"] = listQRaw + } + rawPath := "/api/2.0/preview/sql/dashboards" - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) + if err != nil { + return err + } + if listLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -265,13 +314,14 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var restoreOverrides []func( *cobra.Command, - *sql.RestoreDashboardRequest, + *map[string]any, ) func newRestore() *cobra.Command { cmd := &cobra.Command{} - - var restoreReq sql.RestoreDashboardRequest + var restoreReq map[string]any + restoreReq = map[string]any{} + var restoreDashboardIdRaw string cmd.Use = "restore DASHBOARD_ID" cmd.Short = `Restore a dashboard.` @@ -297,10 +347,18 @@ func newRestore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - restoreReq.DashboardId = args[0] + restoreDashboardIdRaw = args[0] - err = w.Dashboards.Restore(ctx, restoreReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/preview/sql/dashboards/trash/%s", fmt.Sprint(restoreDashboardIdRaw)) + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, restoreReq, nil) if err != nil { return err } @@ -325,19 +383,23 @@ func newRestore() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *sql.DashboardEditContent, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateDashboardIdRaw string + var updateNameRaw string + var updateRunAsRoleRaw string - var updateReq sql.DashboardEditContent 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.Name, "name", updateReq.Name, `The title of this dashboard that appears in list views and at the top of the dashboard page.`) - cmd.Flags().Var(&updateReq.RunAsRole, "run-as-role", `Sets the **Run as** role for the object. Supported values: [owner, viewer]`) + cmd.Flags().StringVar(&updateNameRaw, "name", updateNameRaw, `The title of this dashboard that appears in list views and at the top of the dashboard page.`) + flags.EnumVar(cmd.Flags(), &updateRunAsRoleRaw, "run-as-role", `Sets the **Run as** role for the object. Supported values: [owner, viewer]`, "RunAsRole", "owner", "viewer") // TODO: array: tags cmd.Use = "update DASHBOARD_ID" @@ -367,6 +429,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -380,13 +443,26 @@ func newUpdate() *cobra.Command { } } } - updateReq.DashboardId = args[0] + updateDashboardIdRaw = args[0] + + rawQuery := map[string]any{} + if cmd.Flags().Changed("name") || updateNameRaw != "" { + updateReq["name"] = updateNameRaw + } + if cmd.Flags().Changed("run-as-role") || updateRunAsRoleRaw != "" { + updateReq["run_as_role"] = updateRunAsRoleRaw + } + rawPath := fmt.Sprintf("/api/2.0/preview/sql/dashboards/%s", fmt.Sprint(updateDashboardIdRaw)) - response, err := w.Dashboards.Update(ctx, updateReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/dashboards/overrides.go b/cmd/workspace/dashboards/overrides.go index 6a26ebbfbcd..2d91bdd215a 100644 --- a/cmd/workspace/dashboards/overrides.go +++ b/cmd/workspace/dashboards/overrides.go @@ -2,11 +2,10 @@ package dashboards import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, _ *sql.ListDashboardsRequest) { +func listOverride(listCmd *cobra.Command, _ *map[string]any) { listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "ID"}} {{header "Name"}}`) listCmd.Annotations["template"] = cmdio.Heredoc(` diff --git a/cmd/workspace/data-classification/data-classification.go b/cmd/workspace/data-classification/data-classification.go index 1bf8212d360..8dc47e1bdc8 100644 --- a/cmd/workspace/data-classification/data-classification.go +++ b/cmd/workspace/data-classification/data-classification.go @@ -3,15 +3,14 @@ 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" + + dataclassification "github.com/databricks/cli/libs/sdktypes/dataclassification/v1" + sdkdataclassification "github.com/databricks/sdk-go/dataclassification/v1" ) // Slice with functions to override default command behavior. @@ -61,9 +60,9 @@ var createCatalogConfigOverrides []func( func newCreateCatalogConfig() *cobra.Command { cmd := &cobra.Command{} - var createCatalogConfigReq dataclassification.CreateCatalogConfigRequest - createCatalogConfigReq.CatalogConfig = dataclassification.CatalogConfig{} + 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`) @@ -71,7 +70,7 @@ func newCreateCatalogConfig() *cobra.Command { // TODO: array: auto_tag_configs // TODO: complex arg: excluded_schemas // TODO: complex arg: included_schemas - cmd.Flags().StringVar(&createCatalogConfigReq.CatalogConfig.Name, "name", createCatalogConfigReq.CatalogConfig.Name, `Resource name in the format: catalogs/{catalog_name}/config.`) + flags.StringPtrVar(cmd.Flags(), &createCatalogConfigReq.CatalogConfig.Name, "name", `Resource name in the format: catalogs/{catalog_name}/config.`) cmd.Use = "create-catalog-config PARENT" cmd.Short = `*Public Preview* Create config for a catalog.` @@ -100,6 +99,7 @@ Create config for a catalog. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createCatalogConfigJson.Unmarshal(&createCatalogConfigReq.CatalogConfig) @@ -113,14 +113,22 @@ Create config for a catalog. } } } - createCatalogConfigReq.Parent = args[0] + createCatalogConfigReq.Parent = new(args[0]) - response, err := w.DataClassification.CreateCatalogConfig(ctx, createCatalogConfigReq) + sdkReq, err := dataclassification.CreateCatalogConfigRequestToSDK(&createCatalogConfigReq) + if err != nil { + return err + } + response, err := w.DataClassification.CreateCatalogConfig(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := dataclassification.CatalogConfigFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -141,13 +149,12 @@ Create config for a catalog. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteCatalogConfigOverrides []func( *cobra.Command, - *dataclassification.DeleteCatalogConfigRequest, + *sdkdataclassification.DeleteCatalogConfigRequest, ) func newDeleteCatalogConfig() *cobra.Command { cmd := &cobra.Command{} - - var deleteCatalogConfigReq dataclassification.DeleteCatalogConfigRequest + var deleteCatalogConfigReq sdkdataclassification.DeleteCatalogConfigRequest cmd.Use = "delete-catalog-config NAME" cmd.Short = `*Public Preview* Delete config for a catalog.` @@ -173,10 +180,12 @@ Delete config for a catalog. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteCatalogConfigReq.Name = args[0] + deleteCatalogConfigReq.Name = new(args[0]) - err = w.DataClassification.DeleteCatalogConfig(ctx, deleteCatalogConfigReq) + sdkReq := &deleteCatalogConfigReq + err = w.DataClassification.DeleteCatalogConfig(ctx, *sdkReq) if err != nil { return err } @@ -201,13 +210,12 @@ Delete config for a catalog. // Functions can be added from the `init()` function in manually curated files in this directory. var getCatalogConfigOverrides []func( *cobra.Command, - *dataclassification.GetCatalogConfigRequest, + *sdkdataclassification.GetCatalogConfigRequest, ) func newGetCatalogConfig() *cobra.Command { cmd := &cobra.Command{} - - var getCatalogConfigReq dataclassification.GetCatalogConfigRequest + var getCatalogConfigReq sdkdataclassification.GetCatalogConfigRequest cmd.Use = "get-catalog-config NAME" cmd.Short = `*Public Preview* Get config for a catalog.` @@ -233,15 +241,21 @@ Get config for a catalog. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getCatalogConfigReq.Name = args[0] + getCatalogConfigReq.Name = new(args[0]) - response, err := w.DataClassification.GetCatalogConfig(ctx, getCatalogConfigReq) + sdkReq := &getCatalogConfigReq + response, err := w.DataClassification.GetCatalogConfig(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := dataclassification.CatalogConfigFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -267,9 +281,9 @@ var updateCatalogConfigOverrides []func( func newUpdateCatalogConfig() *cobra.Command { cmd := &cobra.Command{} - var updateCatalogConfigReq dataclassification.UpdateCatalogConfigRequest - updateCatalogConfigReq.CatalogConfig = dataclassification.CatalogConfig{} + 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`) @@ -277,7 +291,7 @@ func newUpdateCatalogConfig() *cobra.Command { // TODO: array: auto_tag_configs // TODO: complex arg: excluded_schemas // TODO: complex arg: included_schemas - cmd.Flags().StringVar(&updateCatalogConfigReq.CatalogConfig.Name, "name", updateCatalogConfigReq.CatalogConfig.Name, `Resource name in the format: catalogs/{catalog_name}/config.`) + flags.StringPtrVar(cmd.Flags(), &updateCatalogConfigReq.CatalogConfig.Name, "name", `Resource name in the format: catalogs/{catalog_name}/config.`) cmd.Use = "update-catalog-config NAME UPDATE_MASK" cmd.Short = `*Public Preview* Update config for a catalog.` @@ -306,6 +320,7 @@ Update config for a catalog. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateCatalogConfigJson.Unmarshal(&updateCatalogConfigReq.CatalogConfig) @@ -319,18 +334,25 @@ Update config for a catalog. } } } - updateCatalogConfigReq.Name = args[0] + updateCatalogConfigReq.CatalogConfig.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateCatalogConfigReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateCatalogConfigReq.UpdateMask = new(args[1]) } - response, err := w.DataClassification.UpdateCatalogConfig(ctx, updateCatalogConfigReq) + sdkReq, err := dataclassification.UpdateCatalogConfigRequestToSDK(&updateCatalogConfigReq) + if err != nil { + return err + } + response, err := w.DataClassification.UpdateCatalogConfig(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := dataclassification.CatalogConfigFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/data-quality/data-quality.go b/cmd/workspace/data-quality/data-quality.go index b7ed15b8acb..9d2416bfde0 100644 --- a/cmd/workspace/data-quality/data-quality.go +++ b/cmd/workspace/data-quality/data-quality.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/dataquality" "github.com/spf13/cobra" + + dataquality "github.com/databricks/cli/libs/sdktypes/dataquality/v1" + sdkdataquality "github.com/databricks/sdk-go/dataquality/v1" ) // Slice with functions to override default command behavior. @@ -66,7 +69,6 @@ var cancelRefreshOverrides []func( func newCancelRefresh() *cobra.Command { cmd := &cobra.Command{} - var cancelRefreshReq dataquality.CancelRefreshRequest cmd.Use = "cancel-refresh OBJECT_TYPE OBJECT_ID REFRESH_ID" @@ -118,20 +120,31 @@ Cancel a refresh. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - cancelRefreshReq.ObjectType = args[0] - cancelRefreshReq.ObjectId = args[1] - _, err = fmt.Sscan(args[2], &cancelRefreshReq.RefreshId) + cancelRefreshReq.ObjectType = new(args[0]) + cancelRefreshReq.ObjectId = new(args[1]) + var cancelRefreshRefreshIdArg int64 + _, err = fmt.Sscan(args[2], &cancelRefreshRefreshIdArg) if err != nil { return fmt.Errorf("invalid REFRESH_ID: %s", args[2]) } + cancelRefreshReq.RefreshId = &cancelRefreshRefreshIdArg - response, err := w.DataQuality.CancelRefresh(ctx, cancelRefreshReq) + sdkReq, err := dataquality.CancelRefreshRequestToSDK(&cancelRefreshReq) + if err != nil { + return err + } + response, err := w.DataQuality.CancelRefresh(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := dataquality.CancelRefreshResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -157,9 +170,9 @@ var createMonitorOverrides []func( func newCreateMonitor() *cobra.Command { cmd := &cobra.Command{} - var createMonitorReq dataquality.CreateMonitorRequest - createMonitorReq.Monitor = dataquality.Monitor{} + createMonitorReq.Monitor = &dataquality.Monitor{} + var createMonitorJson flags.JsonFlag cmd.Flags().Var(&createMonitorJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -231,6 +244,7 @@ Create a monitor. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createMonitorJson.Unmarshal(&createMonitorReq.Monitor) @@ -245,18 +259,26 @@ Create a monitor. } } if !cmd.Flags().Changed("json") { - createMonitorReq.Monitor.ObjectType = args[0] + createMonitorReq.Monitor.ObjectType = new(args[0]) } if !cmd.Flags().Changed("json") { - createMonitorReq.Monitor.ObjectId = args[1] + createMonitorReq.Monitor.ObjectId = new(args[1]) } - response, err := w.DataQuality.CreateMonitor(ctx, createMonitorReq) + sdkReq, err := dataquality.CreateMonitorRequestToSDK(&createMonitorReq) + if err != nil { + return err + } + response, err := w.DataQuality.CreateMonitor(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := dataquality.MonitorFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -282,9 +304,9 @@ var createRefreshOverrides []func( func newCreateRefresh() *cobra.Command { cmd := &cobra.Command{} - var createRefreshReq dataquality.CreateRefreshRequest - createRefreshReq.Refresh = dataquality.Refresh{} + createRefreshReq.Refresh = &dataquality.Refresh{} + var createRefreshJson flags.JsonFlag cmd.Flags().Var(&createRefreshJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -336,6 +358,7 @@ Create a refresh. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createRefreshJson.Unmarshal(&createRefreshReq.Refresh) @@ -349,15 +372,23 @@ Create a refresh. } } } - createRefreshReq.ObjectType = args[0] - createRefreshReq.ObjectId = args[1] + createRefreshReq.Refresh.ObjectType = new(args[0]) + createRefreshReq.Refresh.ObjectId = new(args[1]) - response, err := w.DataQuality.CreateRefresh(ctx, createRefreshReq) + sdkReq, err := dataquality.CreateRefreshRequestToSDK(&createRefreshReq) + if err != nil { + return err + } + response, err := w.DataQuality.CreateRefresh(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := dataquality.RefreshFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -378,13 +409,12 @@ Create a refresh. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteMonitorOverrides []func( *cobra.Command, - *dataquality.DeleteMonitorRequest, + *sdkdataquality.DeleteMonitorRequest, ) func newDeleteMonitor() *cobra.Command { cmd := &cobra.Command{} - - var deleteMonitorReq dataquality.DeleteMonitorRequest + var deleteMonitorReq sdkdataquality.DeleteMonitorRequest cmd.Use = "delete-monitor OBJECT_TYPE OBJECT_ID" cmd.Short = `*Public Preview* Delete a monitor.` @@ -440,11 +470,13 @@ Delete a monitor. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteMonitorReq.ObjectType = args[0] - deleteMonitorReq.ObjectId = args[1] + deleteMonitorReq.ObjectType = new(args[0]) + deleteMonitorReq.ObjectId = new(args[1]) - err = w.DataQuality.DeleteMonitor(ctx, deleteMonitorReq) + sdkReq := &deleteMonitorReq + err = w.DataQuality.DeleteMonitor(ctx, *sdkReq) if err != nil { return err } @@ -469,13 +501,12 @@ Delete a monitor. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteRefreshOverrides []func( *cobra.Command, - *dataquality.DeleteRefreshRequest, + *sdkdataquality.DeleteRefreshRequest, ) func newDeleteRefresh() *cobra.Command { cmd := &cobra.Command{} - - var deleteRefreshReq dataquality.DeleteRefreshRequest + var deleteRefreshReq sdkdataquality.DeleteRefreshRequest cmd.Use = "delete-refresh OBJECT_TYPE OBJECT_ID REFRESH_ID" cmd.Short = `*Public Preview* Delete a refresh.` @@ -517,15 +548,19 @@ Delete a refresh. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteRefreshReq.ObjectType = args[0] - deleteRefreshReq.ObjectId = args[1] - _, err = fmt.Sscan(args[2], &deleteRefreshReq.RefreshId) + deleteRefreshReq.ObjectType = new(args[0]) + deleteRefreshReq.ObjectId = new(args[1]) + var deleteRefreshRefreshIdArg int64 + _, err = fmt.Sscan(args[2], &deleteRefreshRefreshIdArg) if err != nil { return fmt.Errorf("invalid REFRESH_ID: %s", args[2]) } + deleteRefreshReq.RefreshId = &deleteRefreshRefreshIdArg - err = w.DataQuality.DeleteRefresh(ctx, deleteRefreshReq) + sdkReq := &deleteRefreshReq + err = w.DataQuality.DeleteRefresh(ctx, *sdkReq) if err != nil { return err } @@ -550,13 +585,12 @@ Delete a refresh. // Functions can be added from the `init()` function in manually curated files in this directory. var getMonitorOverrides []func( *cobra.Command, - *dataquality.GetMonitorRequest, + *sdkdataquality.GetMonitorRequest, ) func newGetMonitor() *cobra.Command { cmd := &cobra.Command{} - - var getMonitorReq dataquality.GetMonitorRequest + var getMonitorReq sdkdataquality.GetMonitorRequest cmd.Use = "get-monitor OBJECT_TYPE OBJECT_ID" cmd.Short = `*Public Preview* Read a monitor.` @@ -614,16 +648,22 @@ Read a monitor. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getMonitorReq.ObjectType = args[0] - getMonitorReq.ObjectId = args[1] + getMonitorReq.ObjectType = new(args[0]) + getMonitorReq.ObjectId = new(args[1]) - response, err := w.DataQuality.GetMonitor(ctx, getMonitorReq) + sdkReq := &getMonitorReq + response, err := w.DataQuality.GetMonitor(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := dataquality.MonitorFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -644,13 +684,12 @@ Read a monitor. // Functions can be added from the `init()` function in manually curated files in this directory. var getRefreshOverrides []func( *cobra.Command, - *dataquality.GetRefreshRequest, + *sdkdataquality.GetRefreshRequest, ) func newGetRefresh() *cobra.Command { cmd := &cobra.Command{} - - var getRefreshReq dataquality.GetRefreshRequest + var getRefreshReq sdkdataquality.GetRefreshRequest cmd.Use = "get-refresh OBJECT_TYPE OBJECT_ID REFRESH_ID" cmd.Short = `*Public Preview* Get a refresh.` @@ -705,20 +744,28 @@ Get a refresh. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getRefreshReq.ObjectType = args[0] - getRefreshReq.ObjectId = args[1] - _, err = fmt.Sscan(args[2], &getRefreshReq.RefreshId) + getRefreshReq.ObjectType = new(args[0]) + getRefreshReq.ObjectId = new(args[1]) + var getRefreshRefreshIdArg int64 + _, err = fmt.Sscan(args[2], &getRefreshRefreshIdArg) if err != nil { return fmt.Errorf("invalid REFRESH_ID: %s", args[2]) } + getRefreshReq.RefreshId = &getRefreshRefreshIdArg - response, err := w.DataQuality.GetRefresh(ctx, getRefreshReq) + sdkReq := &getRefreshReq + response, err := w.DataQuality.GetRefresh(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := dataquality.RefreshFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -744,20 +791,20 @@ var listMonitorOverrides []func( func newListMonitor() *cobra.Command { cmd := &cobra.Command{} - var listMonitorReq dataquality.ListMonitorRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listMonitorLimit int - cmd.Flags().IntVar(&listMonitorReq.PageSize, "page-size", listMonitorReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listMonitorReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listMonitorLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listMonitorReq.PageToken, "page-token", listMonitorReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listMonitorReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-monitor" @@ -781,16 +828,20 @@ List monitors. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.DataQuality.ListMonitor(ctx, listMonitorReq) + sdkReq, err := dataquality.ListMonitorRequestToSDK(&listMonitorReq) + if err != nil { + return err + } if listMonitorLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listMonitorLimit) } if listMonitorLimit > 0 { ctx = cmdio.WithLimit(ctx, listMonitorLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.DataQuality.ListMonitorIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, dataquality.MonitorFromSDK)) } // Disable completions since they are not applicable. @@ -816,20 +867,20 @@ var listRefreshOverrides []func( func newListRefresh() *cobra.Command { cmd := &cobra.Command{} - var listRefreshReq dataquality.ListRefreshRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listRefreshLimit int - cmd.Flags().IntVar(&listRefreshReq.PageSize, "page-size", listRefreshReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listRefreshReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listRefreshLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listRefreshReq.PageToken, "page-token", listRefreshReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listRefreshReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-refresh OBJECT_TYPE OBJECT_ID" @@ -884,19 +935,23 @@ List refreshes. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listRefreshReq.ObjectType = args[0] - listRefreshReq.ObjectId = args[1] + listRefreshReq.ObjectType = new(args[0]) + listRefreshReq.ObjectId = new(args[1]) - response := w.DataQuality.ListRefresh(ctx, listRefreshReq) + sdkReq, err := dataquality.ListRefreshRequestToSDK(&listRefreshReq) + if err != nil { + return err + } if listRefreshLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listRefreshLimit) } if listRefreshLimit > 0 { ctx = cmdio.WithLimit(ctx, listRefreshLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.DataQuality.ListRefreshIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, dataquality.RefreshFromSDK)) } // Disable completions since they are not applicable. @@ -922,9 +977,9 @@ var updateMonitorOverrides []func( func newUpdateMonitor() *cobra.Command { cmd := &cobra.Command{} - var updateMonitorReq dataquality.UpdateMonitorRequest - updateMonitorReq.Monitor = dataquality.Monitor{} + updateMonitorReq.Monitor = &dataquality.Monitor{} + var updateMonitorJson flags.JsonFlag cmd.Flags().Var(&updateMonitorJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1009,6 +1064,7 @@ Update a monitor. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateMonitorJson.Unmarshal(&updateMonitorReq.Monitor) @@ -1022,22 +1078,30 @@ Update a monitor. } } } - updateMonitorReq.ObjectType = args[0] - updateMonitorReq.ObjectId = args[1] - updateMonitorReq.UpdateMask = args[2] + updateMonitorReq.ObjectType = new(args[0]) + updateMonitorReq.ObjectId = new(args[1]) + updateMonitorReq.UpdateMask = new(args[2]) if !cmd.Flags().Changed("json") { - updateMonitorReq.Monitor.ObjectType = args[3] + updateMonitorReq.ObjectType = new(args[3]) } if !cmd.Flags().Changed("json") { - updateMonitorReq.Monitor.ObjectId = args[4] + updateMonitorReq.ObjectId = new(args[4]) } - response, err := w.DataQuality.UpdateMonitor(ctx, updateMonitorReq) + sdkReq, err := dataquality.UpdateMonitorRequestToSDK(&updateMonitorReq) + if err != nil { + return err + } + response, err := w.DataQuality.UpdateMonitor(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := dataquality.MonitorFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1063,9 +1127,9 @@ var updateRefreshOverrides []func( func newUpdateRefresh() *cobra.Command { cmd := &cobra.Command{} - var updateRefreshReq dataquality.UpdateRefreshRequest - updateRefreshReq.Refresh = dataquality.Refresh{} + updateRefreshReq.Refresh = &dataquality.Refresh{} + var updateRefreshJson flags.JsonFlag cmd.Flags().Var(&updateRefreshJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1134,6 +1198,7 @@ Update a refresh. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateRefreshJson.Unmarshal(&updateRefreshReq.Refresh) @@ -1147,27 +1212,36 @@ Update a refresh. } } } - updateRefreshReq.ObjectType = args[0] - updateRefreshReq.ObjectId = args[1] - _, err = fmt.Sscan(args[2], &updateRefreshReq.RefreshId) + updateRefreshReq.ObjectType = new(args[0]) + updateRefreshReq.ObjectId = new(args[1]) + var updateRefreshRefreshIdArg int64 + _, err = fmt.Sscan(args[2], &updateRefreshRefreshIdArg) if err != nil { return fmt.Errorf("invalid REFRESH_ID: %s", args[2]) } - - updateRefreshReq.UpdateMask = args[3] + updateRefreshReq.RefreshId = &updateRefreshRefreshIdArg + updateRefreshReq.UpdateMask = new(args[3]) if !cmd.Flags().Changed("json") { - updateRefreshReq.Refresh.ObjectType = args[4] + updateRefreshReq.ObjectType = new(args[4]) } if !cmd.Flags().Changed("json") { - updateRefreshReq.Refresh.ObjectId = args[5] + updateRefreshReq.ObjectId = new(args[5]) } - response, err := w.DataQuality.UpdateRefresh(ctx, updateRefreshReq) + sdkReq, err := dataquality.UpdateRefreshRequestToSDK(&updateRefreshReq) + if err != nil { + return err + } + response, err := w.DataQuality.UpdateRefresh(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := dataquality.RefreshFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/data-sources/data-sources.go b/cmd/workspace/data-sources/data-sources.go index 33bee7f17bf..af02cc8d378 100644 --- a/cmd/workspace/data-sources/data-sources.go +++ b/cmd/workspace/data-sources/data-sources.go @@ -3,7 +3,11 @@ package data_sources import ( + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/spf13/cobra" @@ -83,11 +87,21 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.DataSources.List(ctx) + _ = w + listReq := map[string]any{} + rawQuery := map[string]any{} + rawPath := "/api/2.0/preview/sql/data_sources" + + maps.Copy(rawQuery, listReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/database/database.go b/cmd/workspace/database/database.go index af4e28dbc03..230e6ecef1a 100644 --- a/cmd/workspace/database/database.go +++ b/cmd/workspace/database/database.go @@ -8,11 +8,17 @@ import ( "time" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/database" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + database "github.com/databricks/cli/libs/sdktypes/database/v1" + sdkdatabase "github.com/databricks/sdk-go/database/v1" ) // Slice with functions to override default command behavior. @@ -79,14 +85,14 @@ var createDatabaseCatalogOverrides []func( func newCreateDatabaseCatalog() *cobra.Command { cmd := &cobra.Command{} - var createDatabaseCatalogReq database.CreateDatabaseCatalogRequest - createDatabaseCatalogReq.Catalog = database.DatabaseCatalog{} + createDatabaseCatalogReq.Catalog = &database.DatabaseCatalog{} + var createDatabaseCatalogJson flags.JsonFlag cmd.Flags().Var(&createDatabaseCatalogJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createDatabaseCatalogReq.Catalog.CreateDatabaseIfNotExists, "create-database-if-not-exists", createDatabaseCatalogReq.Catalog.CreateDatabaseIfNotExists, ``) + flags.BoolPtrVar(cmd.Flags(), &createDatabaseCatalogReq.Catalog.CreateDatabaseIfNotExists, "create-database-if-not-exists", ``) cmd.Use = "create-database-catalog NAME DATABASE_INSTANCE_NAME DATABASE_NAME" cmd.Short = `*Public Preview* Create a Database Catalog.` @@ -119,6 +125,7 @@ Create a Database Catalog. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createDatabaseCatalogJson.Unmarshal(&createDatabaseCatalogReq.Catalog) @@ -133,21 +140,29 @@ Create a Database Catalog. } } if !cmd.Flags().Changed("json") { - createDatabaseCatalogReq.Catalog.Name = args[0] + createDatabaseCatalogReq.Catalog.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createDatabaseCatalogReq.Catalog.DatabaseInstanceName = args[1] + createDatabaseCatalogReq.Catalog.DatabaseInstanceName = new(args[1]) } if !cmd.Flags().Changed("json") { - createDatabaseCatalogReq.Catalog.DatabaseName = args[2] + createDatabaseCatalogReq.Catalog.DatabaseName = new(args[2]) } - response, err := w.Database.CreateDatabaseCatalog(ctx, createDatabaseCatalogReq) + sdkReq, err := database.CreateDatabaseCatalogRequestToSDK(&createDatabaseCatalogReq) + if err != nil { + return err + } + response, err := w.Database.CreateDatabaseCatalog(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.DatabaseCatalogFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -173,9 +188,9 @@ var createDatabaseInstanceOverrides []func( func newCreateDatabaseInstance() *cobra.Command { cmd := &cobra.Command{} - var createDatabaseInstanceReq database.CreateDatabaseInstanceRequest - createDatabaseInstanceReq.DatabaseInstance = database.DatabaseInstance{} + createDatabaseInstanceReq.DatabaseInstance = &database.DatabaseInstance{} + var createDatabaseInstanceJson flags.JsonFlag var createDatabaseInstanceSkipWait bool @@ -186,17 +201,17 @@ func newCreateDatabaseInstance() *cobra.Command { cmd.Flags().Var(&createDatabaseInstanceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createDatabaseInstanceReq.DatabaseInstance.Capacity, "capacity", createDatabaseInstanceReq.DatabaseInstance.Capacity, `The sku of the instance.`) + flags.StringPtrVar(cmd.Flags(), &createDatabaseInstanceReq.DatabaseInstance.Capacity, "capacity", `The sku of the instance.`) // TODO: array: child_instance_refs // TODO: array: custom_tags // TODO: array: effective_custom_tags - cmd.Flags().BoolVar(&createDatabaseInstanceReq.DatabaseInstance.EnablePgNativeLogin, "enable-pg-native-login", createDatabaseInstanceReq.DatabaseInstance.EnablePgNativeLogin, `Whether to enable PG native password login on the instance.`) - cmd.Flags().BoolVar(&createDatabaseInstanceReq.DatabaseInstance.EnableReadableSecondaries, "enable-readable-secondaries", createDatabaseInstanceReq.DatabaseInstance.EnableReadableSecondaries, `Whether to enable secondaries to serve read-only traffic.`) - cmd.Flags().IntVar(&createDatabaseInstanceReq.DatabaseInstance.NodeCount, "node-count", createDatabaseInstanceReq.DatabaseInstance.NodeCount, `The number of nodes in the instance, composed of 1 primary and 0 or more secondaries.`) + flags.BoolPtrVar(cmd.Flags(), &createDatabaseInstanceReq.DatabaseInstance.EnablePgNativeLogin, "enable-pg-native-login", `Whether to enable PG native password login on the instance.`) + flags.BoolPtrVar(cmd.Flags(), &createDatabaseInstanceReq.DatabaseInstance.EnableReadableSecondaries, "enable-readable-secondaries", `Whether to enable secondaries to serve read-only traffic.`) + flags.IntPtrVar(cmd.Flags(), &createDatabaseInstanceReq.DatabaseInstance.NodeCount, "node-count", `The number of nodes in the instance, composed of 1 primary and 0 or more secondaries.`) // TODO: complex arg: parent_instance_ref - cmd.Flags().IntVar(&createDatabaseInstanceReq.DatabaseInstance.RetentionWindowInDays, "retention-window-in-days", createDatabaseInstanceReq.DatabaseInstance.RetentionWindowInDays, `The retention window for the instance.`) - cmd.Flags().BoolVar(&createDatabaseInstanceReq.DatabaseInstance.Stopped, "stopped", createDatabaseInstanceReq.DatabaseInstance.Stopped, `Whether to stop the instance.`) - cmd.Flags().StringVar(&createDatabaseInstanceReq.DatabaseInstance.UsagePolicyId, "usage-policy-id", createDatabaseInstanceReq.DatabaseInstance.UsagePolicyId, `The desired usage policy to associate with the instance.`) + flags.IntPtrVar(cmd.Flags(), &createDatabaseInstanceReq.DatabaseInstance.RetentionWindowInDays, "retention-window-in-days", `The retention window for the instance.`) + flags.BoolPtrVar(cmd.Flags(), &createDatabaseInstanceReq.DatabaseInstance.Stopped, "stopped", `Whether to stop the instance.`) + flags.StringPtrVar(cmd.Flags(), &createDatabaseInstanceReq.DatabaseInstance.UsagePolicyId, "usage-policy-id", `The desired usage policy to associate with the instance.`) cmd.Use = "create-database-instance NAME" cmd.Short = `*Public Preview* Create a Database Instance.` @@ -227,6 +242,7 @@ Create a Database Instance. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createDatabaseInstanceJson.Unmarshal(&createDatabaseInstanceReq.DatabaseInstance) @@ -241,27 +257,42 @@ Create a Database Instance. } } if !cmd.Flags().Changed("json") { - createDatabaseInstanceReq.DatabaseInstance.Name = args[0] + createDatabaseInstanceReq.DatabaseInstance.Name = new(args[0]) } - wait, err := w.Database.CreateDatabaseInstance(ctx, createDatabaseInstanceReq) + sdkReq, err := database.CreateDatabaseInstanceRequestToSDK(&createDatabaseInstanceReq) if err != nil { return err } if createDatabaseInstanceSkipWait { - return cmdio.Render(ctx, wait.Response) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var current database.DatabaseInstance + err = api.Do(ctx, "POST", "/api/2.0/database/instances", auth.WorkspaceIDHeaders(w.Config), nil, createDatabaseInstanceReq.DatabaseInstance, ¤t) + if err != nil { + return err + } + return cmdio.Render(ctx, current) + } + wait, err := w.Database.CreateDatabaseInstance(ctx, *sdkReq) + if err != nil { + return err } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *database.DatabaseInstance) { - status := i.State - statusMessage := fmt.Sprintf("current status: %s", status) - sp.Update(statusMessage) - }).GetWithTimeout(createDatabaseInstanceTimeout) + sp.Update("Waiting for create-database-instance to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createDatabaseInstanceTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := database.DatabaseInstanceFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -287,19 +318,19 @@ var createDatabaseInstanceRoleOverrides []func( func newCreateDatabaseInstanceRole() *cobra.Command { cmd := &cobra.Command{} - var createDatabaseInstanceRoleReq database.CreateDatabaseInstanceRoleRequest - createDatabaseInstanceRoleReq.DatabaseInstanceRole = database.DatabaseInstanceRole{} + createDatabaseInstanceRoleReq.DatabaseInstanceRole = &database.DatabaseInstanceRole{} + var createDatabaseInstanceRoleJson flags.JsonFlag cmd.Flags().Var(&createDatabaseInstanceRoleJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createDatabaseInstanceRoleReq.DatabaseInstanceName, "database-instance-name", createDatabaseInstanceRoleReq.DatabaseInstanceName, ``) + flags.StringPtrVar(cmd.Flags(), &createDatabaseInstanceRoleReq.DatabaseInstanceName, "database-instance-name", ``) // TODO: complex arg: attributes // TODO: complex arg: effective_attributes - cmd.Flags().Var(&createDatabaseInstanceRoleReq.DatabaseInstanceRole.IdentityType, "identity-type", `The type of the role. Supported values: [GROUP, PG_ONLY, SERVICE_PRINCIPAL, USER]`) - cmd.Flags().StringVar(&createDatabaseInstanceRoleReq.DatabaseInstanceRole.InstanceName, "instance-name", createDatabaseInstanceRoleReq.DatabaseInstanceRole.InstanceName, ``) - cmd.Flags().Var(&createDatabaseInstanceRoleReq.DatabaseInstanceRole.MembershipRole, "membership-role", `An enum value for a standard role that this role is a member of. Supported values: [DATABRICKS_SUPERUSER]`) + flags.EnumVar(cmd.Flags(), &createDatabaseInstanceRoleReq.DatabaseInstanceRole.IdentityType, "identity-type", `The type of the role. Supported values: [GROUP, PG_ONLY, SERVICE_PRINCIPAL, USER]`, "DatabaseInstanceRoleIdentityType", "GROUP", "PG_ONLY", "SERVICE_PRINCIPAL", "USER") + flags.StringPtrVar(cmd.Flags(), &createDatabaseInstanceRoleReq.InstanceName, "instance-name", ``) + flags.EnumVar(cmd.Flags(), &createDatabaseInstanceRoleReq.DatabaseInstanceRole.MembershipRole, "membership-role", `An enum value for a standard role that this role is a member of. Supported values: [DATABRICKS_SUPERUSER]`, "DatabaseInstanceRoleMembershipRole", "DATABRICKS_SUPERUSER") cmd.Use = "create-database-instance-role INSTANCE_NAME NAME" cmd.Short = `Create a role for a Database Instance.` @@ -333,6 +364,7 @@ func newCreateDatabaseInstanceRole() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createDatabaseInstanceRoleJson.Unmarshal(&createDatabaseInstanceRoleReq.DatabaseInstanceRole) @@ -346,17 +378,25 @@ func newCreateDatabaseInstanceRole() *cobra.Command { } } } - createDatabaseInstanceRoleReq.InstanceName = args[0] + createDatabaseInstanceRoleReq.InstanceName = new(args[0]) if !cmd.Flags().Changed("json") { - createDatabaseInstanceRoleReq.DatabaseInstanceRole.Name = args[1] + createDatabaseInstanceRoleReq.DatabaseInstanceRole.Name = new(args[1]) } - response, err := w.Database.CreateDatabaseInstanceRole(ctx, createDatabaseInstanceRoleReq) + sdkReq, err := database.CreateDatabaseInstanceRoleRequestToSDK(&createDatabaseInstanceRoleReq) + if err != nil { + return err + } + response, err := w.Database.CreateDatabaseInstanceRole(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.DatabaseInstanceRoleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -382,15 +422,15 @@ var createDatabaseTableOverrides []func( func newCreateDatabaseTable() *cobra.Command { cmd := &cobra.Command{} - var createDatabaseTableReq database.CreateDatabaseTableRequest - createDatabaseTableReq.Table = database.DatabaseTable{} + createDatabaseTableReq.Table = &database.DatabaseTable{} + var createDatabaseTableJson flags.JsonFlag cmd.Flags().Var(&createDatabaseTableJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createDatabaseTableReq.Table.DatabaseInstanceName, "database-instance-name", createDatabaseTableReq.Table.DatabaseInstanceName, `Name of the target database instance.`) - cmd.Flags().StringVar(&createDatabaseTableReq.Table.LogicalDatabaseName, "logical-database-name", createDatabaseTableReq.Table.LogicalDatabaseName, `Target Postgres database object (logical database) name for this table.`) + flags.StringPtrVar(cmd.Flags(), &createDatabaseTableReq.Table.DatabaseInstanceName, "database-instance-name", `Name of the target database instance.`) + flags.StringPtrVar(cmd.Flags(), &createDatabaseTableReq.Table.LogicalDatabaseName, "logical-database-name", `Target Postgres database object (logical database) name for this table.`) cmd.Use = "create-database-table NAME" cmd.Short = `*Public Preview* Create a Database Table.` @@ -425,6 +465,7 @@ Create a Database Table. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createDatabaseTableJson.Unmarshal(&createDatabaseTableReq.Table) @@ -439,15 +480,23 @@ Create a Database Table. } } if !cmd.Flags().Changed("json") { - createDatabaseTableReq.Table.Name = args[0] + createDatabaseTableReq.Table.Name = new(args[0]) } - response, err := w.Database.CreateDatabaseTable(ctx, createDatabaseTableReq) + sdkReq, err := database.CreateDatabaseTableRequestToSDK(&createDatabaseTableReq) + if err != nil { + return err + } + response, err := w.Database.CreateDatabaseTable(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.DatabaseTableFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -473,16 +522,16 @@ var createSyncedDatabaseTableOverrides []func( func newCreateSyncedDatabaseTable() *cobra.Command { cmd := &cobra.Command{} - var createSyncedDatabaseTableReq database.CreateSyncedDatabaseTableRequest - createSyncedDatabaseTableReq.SyncedTable = database.SyncedDatabaseTable{} + createSyncedDatabaseTableReq.SyncedTable = &database.SyncedDatabaseTable{} + var createSyncedDatabaseTableJson flags.JsonFlag cmd.Flags().Var(&createSyncedDatabaseTableJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: data_synchronization_status - cmd.Flags().StringVar(&createSyncedDatabaseTableReq.SyncedTable.DatabaseInstanceName, "database-instance-name", createSyncedDatabaseTableReq.SyncedTable.DatabaseInstanceName, `Name of the target database instance.`) - cmd.Flags().StringVar(&createSyncedDatabaseTableReq.SyncedTable.LogicalDatabaseName, "logical-database-name", createSyncedDatabaseTableReq.SyncedTable.LogicalDatabaseName, `Target Postgres database object (logical database) name for this table.`) + flags.StringPtrVar(cmd.Flags(), &createSyncedDatabaseTableReq.SyncedTable.DatabaseInstanceName, "database-instance-name", `Name of the target database instance.`) + flags.StringPtrVar(cmd.Flags(), &createSyncedDatabaseTableReq.SyncedTable.LogicalDatabaseName, "logical-database-name", `Target Postgres database object (logical database) name for this table.`) // TODO: complex arg: spec cmd.Use = "create-synced-database-table NAME" @@ -514,6 +563,7 @@ Create a Synced Database Table. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createSyncedDatabaseTableJson.Unmarshal(&createSyncedDatabaseTableReq.SyncedTable) @@ -528,15 +578,23 @@ Create a Synced Database Table. } } if !cmd.Flags().Changed("json") { - createSyncedDatabaseTableReq.SyncedTable.Name = args[0] + createSyncedDatabaseTableReq.SyncedTable.Name = new(args[0]) } - response, err := w.Database.CreateSyncedDatabaseTable(ctx, createSyncedDatabaseTableReq) + sdkReq, err := database.CreateSyncedDatabaseTableRequestToSDK(&createSyncedDatabaseTableReq) + if err != nil { + return err + } + response, err := w.Database.CreateSyncedDatabaseTable(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.SyncedDatabaseTableFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -557,13 +615,12 @@ Create a Synced Database Table. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteDatabaseCatalogOverrides []func( *cobra.Command, - *database.DeleteDatabaseCatalogRequest, + *sdkdatabase.DeleteDatabaseCatalogRequest, ) func newDeleteDatabaseCatalog() *cobra.Command { cmd := &cobra.Command{} - - var deleteDatabaseCatalogReq database.DeleteDatabaseCatalogRequest + var deleteDatabaseCatalogReq sdkdatabase.DeleteDatabaseCatalogRequest cmd.Use = "delete-database-catalog NAME" cmd.Short = `*Public Preview* Delete a Database Catalog.` @@ -584,10 +641,12 @@ Delete a Database Catalog.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteDatabaseCatalogReq.Name = args[0] + deleteDatabaseCatalogReq.Name = new(args[0]) - err = w.Database.DeleteDatabaseCatalog(ctx, deleteDatabaseCatalogReq) + sdkReq := &deleteDatabaseCatalogReq + err = w.Database.DeleteDatabaseCatalog(ctx, *sdkReq) if err != nil { return err } @@ -617,11 +676,10 @@ var deleteDatabaseInstanceOverrides []func( func newDeleteDatabaseInstance() *cobra.Command { cmd := &cobra.Command{} - var deleteDatabaseInstanceReq database.DeleteDatabaseInstanceRequest - cmd.Flags().BoolVar(&deleteDatabaseInstanceReq.Force, "force", deleteDatabaseInstanceReq.Force, `By default, an instance cannot be deleted if it has descendant instances created via PITR.`) - cmd.Flags().BoolVar(&deleteDatabaseInstanceReq.Purge, "purge", deleteDatabaseInstanceReq.Purge, `Deprecated.`) + flags.BoolPtrVar(cmd.Flags(), &deleteDatabaseInstanceReq.Force, "force", `By default, an instance cannot be deleted if it has descendant instances created via PITR.`) + flags.BoolPtrVar(cmd.Flags(), &deleteDatabaseInstanceReq.Purge, "purge", `Deprecated.`) cmd.Use = "delete-database-instance NAME" cmd.Short = `*Public Preview* Delete a Database Instance.` @@ -645,10 +703,15 @@ Delete a Database Instance. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteDatabaseInstanceReq.Name = args[0] + deleteDatabaseInstanceReq.Name = new(args[0]) - err = w.Database.DeleteDatabaseInstance(ctx, deleteDatabaseInstanceReq) + sdkReq, err := database.DeleteDatabaseInstanceRequestToSDK(&deleteDatabaseInstanceReq) + if err != nil { + return err + } + err = w.Database.DeleteDatabaseInstance(ctx, *sdkReq) if err != nil { return err } @@ -678,11 +741,10 @@ var deleteDatabaseInstanceRoleOverrides []func( func newDeleteDatabaseInstanceRole() *cobra.Command { cmd := &cobra.Command{} - var deleteDatabaseInstanceRoleReq database.DeleteDatabaseInstanceRoleRequest - cmd.Flags().BoolVar(&deleteDatabaseInstanceRoleReq.AllowMissing, "allow-missing", deleteDatabaseInstanceRoleReq.AllowMissing, `This is the AIP standard name for the equivalent of Postgres' IF EXISTS option.`) - cmd.Flags().StringVar(&deleteDatabaseInstanceRoleReq.ReassignOwnedTo, "reassign-owned-to", deleteDatabaseInstanceRoleReq.ReassignOwnedTo, ``) + flags.BoolPtrVar(cmd.Flags(), &deleteDatabaseInstanceRoleReq.AllowMissing, "allow-missing", `This is the AIP standard name for the equivalent of Postgres' IF EXISTS option.`) + flags.StringPtrVar(cmd.Flags(), &deleteDatabaseInstanceRoleReq.ReassignOwnedTo, "reassign-owned-to", ``) cmd.Use = "delete-database-instance-role INSTANCE_NAME NAME" cmd.Short = `Delete a role for a Database Instance.` @@ -706,11 +768,16 @@ func newDeleteDatabaseInstanceRole() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteDatabaseInstanceRoleReq.InstanceName = args[0] - deleteDatabaseInstanceRoleReq.Name = args[1] + deleteDatabaseInstanceRoleReq.InstanceName = new(args[0]) + deleteDatabaseInstanceRoleReq.Name = new(args[1]) - err = w.Database.DeleteDatabaseInstanceRole(ctx, deleteDatabaseInstanceRoleReq) + sdkReq, err := database.DeleteDatabaseInstanceRoleRequestToSDK(&deleteDatabaseInstanceRoleReq) + if err != nil { + return err + } + err = w.Database.DeleteDatabaseInstanceRole(ctx, *sdkReq) if err != nil { return err } @@ -735,13 +802,12 @@ func newDeleteDatabaseInstanceRole() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteDatabaseTableOverrides []func( *cobra.Command, - *database.DeleteDatabaseTableRequest, + *sdkdatabase.DeleteDatabaseTableRequest, ) func newDeleteDatabaseTable() *cobra.Command { cmd := &cobra.Command{} - - var deleteDatabaseTableReq database.DeleteDatabaseTableRequest + var deleteDatabaseTableReq sdkdatabase.DeleteDatabaseTableRequest cmd.Use = "delete-database-table NAME" cmd.Short = `*Public Preview* Delete a Database Table.` @@ -762,10 +828,12 @@ Delete a Database Table.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteDatabaseTableReq.Name = args[0] + deleteDatabaseTableReq.Name = new(args[0]) - err = w.Database.DeleteDatabaseTable(ctx, deleteDatabaseTableReq) + sdkReq := &deleteDatabaseTableReq + err = w.Database.DeleteDatabaseTable(ctx, *sdkReq) if err != nil { return err } @@ -795,10 +863,9 @@ var deleteSyncedDatabaseTableOverrides []func( func newDeleteSyncedDatabaseTable() *cobra.Command { cmd := &cobra.Command{} - var deleteSyncedDatabaseTableReq database.DeleteSyncedDatabaseTableRequest - cmd.Flags().BoolVar(&deleteSyncedDatabaseTableReq.PurgeData, "purge-data", deleteSyncedDatabaseTableReq.PurgeData, `Optional.`) + flags.BoolPtrVar(cmd.Flags(), &deleteSyncedDatabaseTableReq.PurgeData, "purge-data", `Optional.`) cmd.Use = "delete-synced-database-table NAME" cmd.Short = `*Public Preview* Delete a Synced Database Table.` @@ -819,10 +886,15 @@ Delete a Synced Database Table.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteSyncedDatabaseTableReq.Name = args[0] + deleteSyncedDatabaseTableReq.Name = new(args[0]) - err = w.Database.DeleteSyncedDatabaseTable(ctx, deleteSyncedDatabaseTableReq) + sdkReq, err := database.DeleteSyncedDatabaseTableRequestToSDK(&deleteSyncedDatabaseTableReq) + if err != nil { + return err + } + err = w.Database.DeleteSyncedDatabaseTable(ctx, *sdkReq) if err != nil { return err } @@ -852,10 +924,9 @@ var findDatabaseInstanceByUidOverrides []func( func newFindDatabaseInstanceByUid() *cobra.Command { cmd := &cobra.Command{} - var findDatabaseInstanceByUidReq database.FindDatabaseInstanceByUidRequest - cmd.Flags().StringVar(&findDatabaseInstanceByUidReq.Uid, "uid", findDatabaseInstanceByUidReq.Uid, `UID of the cluster to get.`) + flags.StringPtrVar(cmd.Flags(), &findDatabaseInstanceByUidReq.Uid, "uid", `UID of the cluster to get.`) cmd.Use = "find-database-instance-by-uid" cmd.Short = `*Public Preview* Find a Database Instance by uid.` @@ -876,13 +947,22 @@ Find a Database Instance by uid.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response, err := w.Database.FindDatabaseInstanceByUid(ctx, findDatabaseInstanceByUidReq) + sdkReq, err := database.FindDatabaseInstanceByUidRequestToSDK(&findDatabaseInstanceByUidReq) + if err != nil { + return err + } + response, err := w.Database.FindDatabaseInstanceByUid(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.DatabaseInstanceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -908,15 +988,15 @@ var generateDatabaseCredentialOverrides []func( func newGenerateDatabaseCredential() *cobra.Command { cmd := &cobra.Command{} - var generateDatabaseCredentialReq database.GenerateDatabaseCredentialRequest + var generateDatabaseCredentialJson flags.JsonFlag cmd.Flags().Var(&generateDatabaseCredentialJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: claims // TODO: array: instance_names - cmd.Flags().StringVar(&generateDatabaseCredentialReq.RequestId, "request-id", generateDatabaseCredentialReq.RequestId, ``) + flags.StringPtrVar(cmd.Flags(), &generateDatabaseCredentialReq.RequestId, "request-id", ``) cmd.Use = "generate-database-credential" cmd.Short = `*Public Preview* Generates a credential that can be used to access database instances.` @@ -937,6 +1017,7 @@ Generates a credential that can be used to access database instances.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := generateDatabaseCredentialJson.Unmarshal(&generateDatabaseCredentialReq) @@ -951,12 +1032,20 @@ Generates a credential that can be used to access database instances.` } } - response, err := w.Database.GenerateDatabaseCredential(ctx, generateDatabaseCredentialReq) + sdkReq, err := database.GenerateDatabaseCredentialRequestToSDK(&generateDatabaseCredentialReq) + if err != nil { + return err + } + response, err := w.Database.GenerateDatabaseCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.DatabaseCredentialFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -977,13 +1066,12 @@ Generates a credential that can be used to access database instances.` // Functions can be added from the `init()` function in manually curated files in this directory. var getDatabaseCatalogOverrides []func( *cobra.Command, - *database.GetDatabaseCatalogRequest, + *sdkdatabase.GetDatabaseCatalogRequest, ) func newGetDatabaseCatalog() *cobra.Command { cmd := &cobra.Command{} - - var getDatabaseCatalogReq database.GetDatabaseCatalogRequest + var getDatabaseCatalogReq sdkdatabase.GetDatabaseCatalogRequest cmd.Use = "get-database-catalog NAME" cmd.Short = `*Public Preview* Get a Database Catalog.` @@ -1004,15 +1092,21 @@ Get a Database Catalog.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getDatabaseCatalogReq.Name = args[0] + getDatabaseCatalogReq.Name = new(args[0]) - response, err := w.Database.GetDatabaseCatalog(ctx, getDatabaseCatalogReq) + sdkReq := &getDatabaseCatalogReq + response, err := w.Database.GetDatabaseCatalog(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.DatabaseCatalogFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1033,13 +1127,12 @@ Get a Database Catalog.` // Functions can be added from the `init()` function in manually curated files in this directory. var getDatabaseInstanceOverrides []func( *cobra.Command, - *database.GetDatabaseInstanceRequest, + *sdkdatabase.GetDatabaseInstanceRequest, ) func newGetDatabaseInstance() *cobra.Command { cmd := &cobra.Command{} - - var getDatabaseInstanceReq database.GetDatabaseInstanceRequest + var getDatabaseInstanceReq sdkdatabase.GetDatabaseInstanceRequest cmd.Use = "get-database-instance NAME" cmd.Short = `*Public Preview* Get a Database Instance.` @@ -1063,15 +1156,21 @@ Get a Database Instance. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getDatabaseInstanceReq.Name = args[0] + getDatabaseInstanceReq.Name = new(args[0]) - response, err := w.Database.GetDatabaseInstance(ctx, getDatabaseInstanceReq) + sdkReq := &getDatabaseInstanceReq + response, err := w.Database.GetDatabaseInstance(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.DatabaseInstanceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1092,13 +1191,12 @@ Get a Database Instance. // Functions can be added from the `init()` function in manually curated files in this directory. var getDatabaseInstanceRoleOverrides []func( *cobra.Command, - *database.GetDatabaseInstanceRoleRequest, + *sdkdatabase.GetDatabaseInstanceRoleRequest, ) func newGetDatabaseInstanceRole() *cobra.Command { cmd := &cobra.Command{} - - var getDatabaseInstanceRoleReq database.GetDatabaseInstanceRoleRequest + var getDatabaseInstanceRoleReq sdkdatabase.GetDatabaseInstanceRoleRequest cmd.Use = "get-database-instance-role INSTANCE_NAME NAME" cmd.Short = `Get a role for a Database Instance.` @@ -1122,16 +1220,22 @@ func newGetDatabaseInstanceRole() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getDatabaseInstanceRoleReq.InstanceName = args[0] - getDatabaseInstanceRoleReq.Name = args[1] + getDatabaseInstanceRoleReq.InstanceName = new(args[0]) + getDatabaseInstanceRoleReq.Name = new(args[1]) - response, err := w.Database.GetDatabaseInstanceRole(ctx, getDatabaseInstanceRoleReq) + sdkReq := &getDatabaseInstanceRoleReq + response, err := w.Database.GetDatabaseInstanceRole(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.DatabaseInstanceRoleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1152,13 +1256,12 @@ func newGetDatabaseInstanceRole() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getDatabaseTableOverrides []func( *cobra.Command, - *database.GetDatabaseTableRequest, + *sdkdatabase.GetDatabaseTableRequest, ) func newGetDatabaseTable() *cobra.Command { cmd := &cobra.Command{} - - var getDatabaseTableReq database.GetDatabaseTableRequest + var getDatabaseTableReq sdkdatabase.GetDatabaseTableRequest cmd.Use = "get-database-table NAME" cmd.Short = `*Public Preview* Get a Database Table.` @@ -1179,15 +1282,21 @@ Get a Database Table.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getDatabaseTableReq.Name = args[0] + getDatabaseTableReq.Name = new(args[0]) - response, err := w.Database.GetDatabaseTable(ctx, getDatabaseTableReq) + sdkReq := &getDatabaseTableReq + response, err := w.Database.GetDatabaseTable(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.DatabaseTableFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1208,13 +1317,12 @@ Get a Database Table.` // Functions can be added from the `init()` function in manually curated files in this directory. var getSyncedDatabaseTableOverrides []func( *cobra.Command, - *database.GetSyncedDatabaseTableRequest, + *sdkdatabase.GetSyncedDatabaseTableRequest, ) func newGetSyncedDatabaseTable() *cobra.Command { cmd := &cobra.Command{} - - var getSyncedDatabaseTableReq database.GetSyncedDatabaseTableRequest + var getSyncedDatabaseTableReq sdkdatabase.GetSyncedDatabaseTableRequest cmd.Use = "get-synced-database-table NAME" cmd.Short = `*Public Preview* Get a Synced Database Table.` @@ -1235,15 +1343,21 @@ Get a Synced Database Table.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSyncedDatabaseTableReq.Name = args[0] + getSyncedDatabaseTableReq.Name = new(args[0]) - response, err := w.Database.GetSyncedDatabaseTable(ctx, getSyncedDatabaseTableReq) + sdkReq := &getSyncedDatabaseTableReq + response, err := w.Database.GetSyncedDatabaseTable(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.SyncedDatabaseTableFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1269,20 +1383,20 @@ var listDatabaseCatalogsOverrides []func( func newListDatabaseCatalogs() *cobra.Command { cmd := &cobra.Command{} - var listDatabaseCatalogsReq database.ListDatabaseCatalogsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listDatabaseCatalogsLimit int - cmd.Flags().IntVar(&listDatabaseCatalogsReq.PageSize, "page-size", listDatabaseCatalogsReq.PageSize, `Upper bound for items returned.`) + flags.IntPtrVar(cmd.Flags(), &listDatabaseCatalogsReq.PageSize, "page-size", `Upper bound for items returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listDatabaseCatalogsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listDatabaseCatalogsReq.PageToken, "page-token", listDatabaseCatalogsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listDatabaseCatalogsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-database-catalogs INSTANCE_NAME" @@ -1310,18 +1424,22 @@ func newListDatabaseCatalogs() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listDatabaseCatalogsReq.InstanceName = args[0] + listDatabaseCatalogsReq.InstanceName = new(args[0]) - response := w.Database.ListDatabaseCatalogs(ctx, listDatabaseCatalogsReq) + sdkReq, err := database.ListDatabaseCatalogsRequestToSDK(&listDatabaseCatalogsReq) + if err != nil { + return err + } if listDatabaseCatalogsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listDatabaseCatalogsLimit) } if listDatabaseCatalogsLimit > 0 { ctx = cmdio.WithLimit(ctx, listDatabaseCatalogsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Database.ListDatabaseCatalogsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, database.DatabaseCatalogFromSDK)) } // Disable completions since they are not applicable. @@ -1347,20 +1465,20 @@ var listDatabaseInstanceRolesOverrides []func( func newListDatabaseInstanceRoles() *cobra.Command { cmd := &cobra.Command{} - var listDatabaseInstanceRolesReq database.ListDatabaseInstanceRolesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listDatabaseInstanceRolesLimit int - cmd.Flags().IntVar(&listDatabaseInstanceRolesReq.PageSize, "page-size", listDatabaseInstanceRolesReq.PageSize, `Upper bound for items returned.`) + flags.IntPtrVar(cmd.Flags(), &listDatabaseInstanceRolesReq.PageSize, "page-size", `Upper bound for items returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listDatabaseInstanceRolesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listDatabaseInstanceRolesReq.PageToken, "page-token", listDatabaseInstanceRolesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listDatabaseInstanceRolesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-database-instance-roles INSTANCE_NAME" @@ -1389,18 +1507,22 @@ func newListDatabaseInstanceRoles() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listDatabaseInstanceRolesReq.InstanceName = args[0] + listDatabaseInstanceRolesReq.InstanceName = new(args[0]) - response := w.Database.ListDatabaseInstanceRoles(ctx, listDatabaseInstanceRolesReq) + sdkReq, err := database.ListDatabaseInstanceRolesRequestToSDK(&listDatabaseInstanceRolesReq) + if err != nil { + return err + } if listDatabaseInstanceRolesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listDatabaseInstanceRolesLimit) } if listDatabaseInstanceRolesLimit > 0 { ctx = cmdio.WithLimit(ctx, listDatabaseInstanceRolesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Database.ListDatabaseInstanceRolesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, database.DatabaseInstanceRoleFromSDK)) } // Disable completions since they are not applicable. @@ -1426,20 +1548,20 @@ var listDatabaseInstancesOverrides []func( func newListDatabaseInstances() *cobra.Command { cmd := &cobra.Command{} - var listDatabaseInstancesReq database.ListDatabaseInstancesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listDatabaseInstancesLimit int - cmd.Flags().IntVar(&listDatabaseInstancesReq.PageSize, "page-size", listDatabaseInstancesReq.PageSize, `Upper bound for items returned.`) + flags.IntPtrVar(cmd.Flags(), &listDatabaseInstancesReq.PageSize, "page-size", `Upper bound for items returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listDatabaseInstancesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listDatabaseInstancesReq.PageToken, "page-token", listDatabaseInstancesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listDatabaseInstancesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-database-instances" @@ -1461,16 +1583,20 @@ List Database Instances.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Database.ListDatabaseInstances(ctx, listDatabaseInstancesReq) + sdkReq, err := database.ListDatabaseInstancesRequestToSDK(&listDatabaseInstancesReq) + if err != nil { + return err + } if listDatabaseInstancesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listDatabaseInstancesLimit) } if listDatabaseInstancesLimit > 0 { ctx = cmdio.WithLimit(ctx, listDatabaseInstancesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Database.ListDatabaseInstancesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, database.DatabaseInstanceFromSDK)) } // Disable completions since they are not applicable. @@ -1496,20 +1622,20 @@ var listSyncedDatabaseTablesOverrides []func( func newListSyncedDatabaseTables() *cobra.Command { cmd := &cobra.Command{} - var listSyncedDatabaseTablesReq database.ListSyncedDatabaseTablesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSyncedDatabaseTablesLimit int - cmd.Flags().IntVar(&listSyncedDatabaseTablesReq.PageSize, "page-size", listSyncedDatabaseTablesReq.PageSize, `Upper bound for items returned.`) + flags.IntPtrVar(cmd.Flags(), &listSyncedDatabaseTablesReq.PageSize, "page-size", `Upper bound for items returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listSyncedDatabaseTablesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSyncedDatabaseTablesReq.PageToken, "page-token", listSyncedDatabaseTablesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSyncedDatabaseTablesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-synced-database-tables INSTANCE_NAME" @@ -1537,18 +1663,22 @@ func newListSyncedDatabaseTables() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listSyncedDatabaseTablesReq.InstanceName = args[0] + listSyncedDatabaseTablesReq.InstanceName = new(args[0]) - response := w.Database.ListSyncedDatabaseTables(ctx, listSyncedDatabaseTablesReq) + sdkReq, err := database.ListSyncedDatabaseTablesRequestToSDK(&listSyncedDatabaseTablesReq) + if err != nil { + return err + } if listSyncedDatabaseTablesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSyncedDatabaseTablesLimit) } if listSyncedDatabaseTablesLimit > 0 { ctx = cmdio.WithLimit(ctx, listSyncedDatabaseTablesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Database.ListSyncedDatabaseTablesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, database.SyncedDatabaseTableFromSDK)) } // Disable completions since they are not applicable. @@ -1574,14 +1704,14 @@ var updateDatabaseCatalogOverrides []func( func newUpdateDatabaseCatalog() *cobra.Command { cmd := &cobra.Command{} - var updateDatabaseCatalogReq database.UpdateDatabaseCatalogRequest - updateDatabaseCatalogReq.DatabaseCatalog = database.DatabaseCatalog{} + updateDatabaseCatalogReq.DatabaseCatalog = &database.DatabaseCatalog{} + var updateDatabaseCatalogJson flags.JsonFlag cmd.Flags().Var(&updateDatabaseCatalogJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&updateDatabaseCatalogReq.DatabaseCatalog.CreateDatabaseIfNotExists, "create-database-if-not-exists", updateDatabaseCatalogReq.DatabaseCatalog.CreateDatabaseIfNotExists, ``) + flags.BoolPtrVar(cmd.Flags(), &updateDatabaseCatalogReq.DatabaseCatalog.CreateDatabaseIfNotExists, "create-database-if-not-exists", ``) cmd.Use = "update-database-catalog NAME UPDATE_MASK DATABASE_INSTANCE_NAME DATABASE_NAME" cmd.Short = `Update a Database Catalog.` @@ -1618,6 +1748,7 @@ func newUpdateDatabaseCatalog() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateDatabaseCatalogJson.Unmarshal(&updateDatabaseCatalogReq.DatabaseCatalog) @@ -1631,21 +1762,29 @@ func newUpdateDatabaseCatalog() *cobra.Command { } } } - updateDatabaseCatalogReq.Name = args[0] - updateDatabaseCatalogReq.UpdateMask = args[1] + updateDatabaseCatalogReq.DatabaseCatalog.Name = new(args[0]) + updateDatabaseCatalogReq.UpdateMask = new(args[1]) if !cmd.Flags().Changed("json") { - updateDatabaseCatalogReq.DatabaseCatalog.DatabaseInstanceName = args[2] + updateDatabaseCatalogReq.DatabaseCatalog.DatabaseInstanceName = new(args[2]) } if !cmd.Flags().Changed("json") { - updateDatabaseCatalogReq.DatabaseCatalog.DatabaseName = args[3] + updateDatabaseCatalogReq.DatabaseCatalog.DatabaseName = new(args[3]) } - response, err := w.Database.UpdateDatabaseCatalog(ctx, updateDatabaseCatalogReq) + sdkReq, err := database.UpdateDatabaseCatalogRequestToSDK(&updateDatabaseCatalogReq) + if err != nil { + return err + } + response, err := w.Database.UpdateDatabaseCatalog(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.DatabaseCatalogFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1671,24 +1810,24 @@ var updateDatabaseInstanceOverrides []func( func newUpdateDatabaseInstance() *cobra.Command { cmd := &cobra.Command{} - var updateDatabaseInstanceReq database.UpdateDatabaseInstanceRequest - updateDatabaseInstanceReq.DatabaseInstance = database.DatabaseInstance{} + updateDatabaseInstanceReq.DatabaseInstance = &database.DatabaseInstance{} + var updateDatabaseInstanceJson flags.JsonFlag cmd.Flags().Var(&updateDatabaseInstanceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateDatabaseInstanceReq.DatabaseInstance.Capacity, "capacity", updateDatabaseInstanceReq.DatabaseInstance.Capacity, `The sku of the instance.`) + flags.StringPtrVar(cmd.Flags(), &updateDatabaseInstanceReq.DatabaseInstance.Capacity, "capacity", `The sku of the instance.`) // TODO: array: child_instance_refs // TODO: array: custom_tags // TODO: array: effective_custom_tags - cmd.Flags().BoolVar(&updateDatabaseInstanceReq.DatabaseInstance.EnablePgNativeLogin, "enable-pg-native-login", updateDatabaseInstanceReq.DatabaseInstance.EnablePgNativeLogin, `Whether to enable PG native password login on the instance.`) - cmd.Flags().BoolVar(&updateDatabaseInstanceReq.DatabaseInstance.EnableReadableSecondaries, "enable-readable-secondaries", updateDatabaseInstanceReq.DatabaseInstance.EnableReadableSecondaries, `Whether to enable secondaries to serve read-only traffic.`) - cmd.Flags().IntVar(&updateDatabaseInstanceReq.DatabaseInstance.NodeCount, "node-count", updateDatabaseInstanceReq.DatabaseInstance.NodeCount, `The number of nodes in the instance, composed of 1 primary and 0 or more secondaries.`) + flags.BoolPtrVar(cmd.Flags(), &updateDatabaseInstanceReq.DatabaseInstance.EnablePgNativeLogin, "enable-pg-native-login", `Whether to enable PG native password login on the instance.`) + flags.BoolPtrVar(cmd.Flags(), &updateDatabaseInstanceReq.DatabaseInstance.EnableReadableSecondaries, "enable-readable-secondaries", `Whether to enable secondaries to serve read-only traffic.`) + flags.IntPtrVar(cmd.Flags(), &updateDatabaseInstanceReq.DatabaseInstance.NodeCount, "node-count", `The number of nodes in the instance, composed of 1 primary and 0 or more secondaries.`) // TODO: complex arg: parent_instance_ref - cmd.Flags().IntVar(&updateDatabaseInstanceReq.DatabaseInstance.RetentionWindowInDays, "retention-window-in-days", updateDatabaseInstanceReq.DatabaseInstance.RetentionWindowInDays, `The retention window for the instance.`) - cmd.Flags().BoolVar(&updateDatabaseInstanceReq.DatabaseInstance.Stopped, "stopped", updateDatabaseInstanceReq.DatabaseInstance.Stopped, `Whether to stop the instance.`) - cmd.Flags().StringVar(&updateDatabaseInstanceReq.DatabaseInstance.UsagePolicyId, "usage-policy-id", updateDatabaseInstanceReq.DatabaseInstance.UsagePolicyId, `The desired usage policy to associate with the instance.`) + flags.IntPtrVar(cmd.Flags(), &updateDatabaseInstanceReq.DatabaseInstance.RetentionWindowInDays, "retention-window-in-days", `The retention window for the instance.`) + flags.BoolPtrVar(cmd.Flags(), &updateDatabaseInstanceReq.DatabaseInstance.Stopped, "stopped", `Whether to stop the instance.`) + flags.StringPtrVar(cmd.Flags(), &updateDatabaseInstanceReq.DatabaseInstance.UsagePolicyId, "usage-policy-id", `The desired usage policy to associate with the instance.`) cmd.Use = "update-database-instance NAME UPDATE_MASK" cmd.Short = `*Public Preview* Update a Database Instance.` @@ -1715,6 +1854,7 @@ Update a Database Instance. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateDatabaseInstanceJson.Unmarshal(&updateDatabaseInstanceReq.DatabaseInstance) @@ -1728,15 +1868,23 @@ Update a Database Instance. } } } - updateDatabaseInstanceReq.Name = args[0] - updateDatabaseInstanceReq.UpdateMask = args[1] + updateDatabaseInstanceReq.DatabaseInstance.Name = new(args[0]) + updateDatabaseInstanceReq.UpdateMask = new(args[1]) - response, err := w.Database.UpdateDatabaseInstance(ctx, updateDatabaseInstanceReq) + sdkReq, err := database.UpdateDatabaseInstanceRequestToSDK(&updateDatabaseInstanceReq) + if err != nil { + return err + } + response, err := w.Database.UpdateDatabaseInstance(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.DatabaseInstanceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1762,16 +1910,16 @@ var updateSyncedDatabaseTableOverrides []func( func newUpdateSyncedDatabaseTable() *cobra.Command { cmd := &cobra.Command{} - var updateSyncedDatabaseTableReq database.UpdateSyncedDatabaseTableRequest - updateSyncedDatabaseTableReq.SyncedTable = database.SyncedDatabaseTable{} + updateSyncedDatabaseTableReq.SyncedTable = &database.SyncedDatabaseTable{} + var updateSyncedDatabaseTableJson flags.JsonFlag cmd.Flags().Var(&updateSyncedDatabaseTableJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: data_synchronization_status - cmd.Flags().StringVar(&updateSyncedDatabaseTableReq.SyncedTable.DatabaseInstanceName, "database-instance-name", updateSyncedDatabaseTableReq.SyncedTable.DatabaseInstanceName, `Name of the target database instance.`) - cmd.Flags().StringVar(&updateSyncedDatabaseTableReq.SyncedTable.LogicalDatabaseName, "logical-database-name", updateSyncedDatabaseTableReq.SyncedTable.LogicalDatabaseName, `Target Postgres database object (logical database) name for this table.`) + flags.StringPtrVar(cmd.Flags(), &updateSyncedDatabaseTableReq.SyncedTable.DatabaseInstanceName, "database-instance-name", `Name of the target database instance.`) + flags.StringPtrVar(cmd.Flags(), &updateSyncedDatabaseTableReq.SyncedTable.LogicalDatabaseName, "logical-database-name", `Target Postgres database object (logical database) name for this table.`) // TODO: complex arg: spec cmd.Use = "update-synced-database-table NAME UPDATE_MASK" @@ -1800,6 +1948,7 @@ func newUpdateSyncedDatabaseTable() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateSyncedDatabaseTableJson.Unmarshal(&updateSyncedDatabaseTableReq.SyncedTable) @@ -1813,15 +1962,23 @@ func newUpdateSyncedDatabaseTable() *cobra.Command { } } } - updateSyncedDatabaseTableReq.Name = args[0] - updateSyncedDatabaseTableReq.UpdateMask = args[1] + updateSyncedDatabaseTableReq.SyncedTable.Name = new(args[0]) + updateSyncedDatabaseTableReq.UpdateMask = new(args[1]) - response, err := w.Database.UpdateSyncedDatabaseTable(ctx, updateSyncedDatabaseTableReq) + sdkReq, err := database.UpdateSyncedDatabaseTableRequestToSDK(&updateSyncedDatabaseTableReq) + if err != nil { + return err + } + response, err := w.Database.UpdateSyncedDatabaseTable(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := database.SyncedDatabaseTableFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/default-namespace/default-namespace.go b/cmd/workspace/default-namespace/default-namespace.go index c0ebe0ed600..ed1f42d02c7 100644 --- a/cmd/workspace/default-namespace/default-namespace.go +++ b/cmd/workspace/default-namespace/default-namespace.go @@ -5,11 +5,14 @@ package default_namespace import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -61,15 +64,16 @@ The default namespace setting API allows users to configure the default // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteDefaultNamespaceSettingRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeleteDefaultNamespaceSettingRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `*Public Preview* Delete the default namespace setting.` @@ -96,12 +100,24 @@ Delete the default namespace setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := "/api/2.0/settings/types/default_namespace_ws/names/default" - response, err := w.Settings.DefaultNamespace().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -123,15 +139,16 @@ Delete the default namespace setting. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetDefaultNamespaceSettingRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetDefaultNamespaceSettingRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `*Public Preview* Get the default namespace setting.` @@ -154,12 +171,24 @@ Get the default namespace setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/default_namespace_ws/names/default" - response, err := w.Settings.DefaultNamespace().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -181,13 +210,16 @@ Get the default namespace setting. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateDefaultNamespaceSettingRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateDefaultNamespaceSettingRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -214,6 +246,7 @@ Update the default namespace setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -230,11 +263,24 @@ Update the default namespace setting. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.DefaultNamespace().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/default_namespace_ws/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/default-warehouse-id/default-warehouse-id.go b/cmd/workspace/default-warehouse-id/default-warehouse-id.go index 491ac6b972c..1a93d6ddd14 100644 --- a/cmd/workspace/default-warehouse-id/default-warehouse-id.go +++ b/cmd/workspace/default-warehouse-id/default-warehouse-id.go @@ -5,11 +5,14 @@ package default_warehouse_id import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -52,15 +55,16 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteDefaultWarehouseIdRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeleteDefaultWarehouseIdRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `Delete the Default Warehouse Id setting.` @@ -81,12 +85,24 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := "/api/2.0/settings/types/default_warehouse_id/names/default" - response, err := w.Settings.DefaultWarehouseId().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -108,15 +124,16 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetDefaultWarehouseIdRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetDefaultWarehouseIdRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `Get the Default Warehouse Id setting.` @@ -137,12 +154,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/default_warehouse_id/names/default" - response, err := w.Settings.DefaultWarehouseId().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -164,13 +193,16 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateDefaultWarehouseIdRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateDefaultWarehouseIdRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -189,6 +221,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -205,11 +238,24 @@ func newUpdate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.DefaultWarehouseId().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/default_warehouse_id/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/disable-legacy-access/disable-legacy-access.go b/cmd/workspace/disable-legacy-access/disable-legacy-access.go index 5a4c9639605..694d8dd0658 100644 --- a/cmd/workspace/disable-legacy-access/disable-legacy-access.go +++ b/cmd/workspace/disable-legacy-access/disable-legacy-access.go @@ -5,11 +5,14 @@ package disable_legacy_access import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -53,15 +56,16 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteDisableLegacyAccessRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeleteDisableLegacyAccessRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `Delete Legacy Access Disablement Status.` @@ -82,12 +86,24 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := "/api/2.0/settings/types/disable_legacy_access/names/default" - response, err := w.Settings.DisableLegacyAccess().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -109,15 +125,16 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetDisableLegacyAccessRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetDisableLegacyAccessRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `Retrieve Legacy Access Disablement Status.` @@ -138,12 +155,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/disable_legacy_access/names/default" - response, err := w.Settings.DisableLegacyAccess().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -165,13 +194,16 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateDisableLegacyAccessRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateDisableLegacyAccessRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -190,6 +222,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -206,11 +239,24 @@ func newUpdate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.DisableLegacyAccess().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/disable_legacy_access/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/disable-legacy-dbfs/disable-legacy-dbfs.go b/cmd/workspace/disable-legacy-dbfs/disable-legacy-dbfs.go index b624e1bffa8..2afab94ef3a 100644 --- a/cmd/workspace/disable-legacy-dbfs/disable-legacy-dbfs.go +++ b/cmd/workspace/disable-legacy-dbfs/disable-legacy-dbfs.go @@ -5,11 +5,14 @@ package disable_legacy_dbfs import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -56,15 +59,16 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteDisableLegacyDbfsRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeleteDisableLegacyDbfsRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `Delete the disable legacy DBFS setting.` @@ -86,12 +90,24 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := "/api/2.0/settings/types/disable_legacy_dbfs/names/default" - response, err := w.Settings.DisableLegacyDbfs().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -113,15 +129,16 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetDisableLegacyDbfsRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetDisableLegacyDbfsRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `Get the disable legacy DBFS setting.` @@ -142,12 +159,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/disable_legacy_dbfs/names/default" - response, err := w.Settings.DisableLegacyDbfs().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -169,13 +198,16 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateDisableLegacyDbfsRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateDisableLegacyDbfsRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -194,6 +226,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -210,11 +243,24 @@ func newUpdate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.DisableLegacyDbfs().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/disable_legacy_dbfs/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/domains/domains.go b/cmd/workspace/domains/domains.go index 5c4b670cb32..6a25ed68f3a 100644 --- a/cmd/workspace/domains/domains.go +++ b/cmd/workspace/domains/domains.go @@ -5,15 +5,16 @@ package domains import ( "errors" "fmt" - "strings" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "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/domains" "github.com/spf13/cobra" + + domains "github.com/databricks/cli/libs/sdktypes/domains/v1" + sdkdomains "github.com/databricks/sdk-go/domains/v1" ) // Slice with functions to override default command behavior. @@ -61,21 +62,21 @@ var createDomainOverrides []func( func newCreateDomain() *cobra.Command { cmd := &cobra.Command{} - var createDomainReq domains.CreateDomainRequest - createDomainReq.Domain = domains.Domain{} + createDomainReq.Domain = &domains.Domain{} + var createDomainJson flags.JsonFlag cmd.Flags().Var(&createDomainJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createDomainReq.DomainId, "domain-id", createDomainReq.DomainId, `Client-supplied resource ID for the new domain.`) + flags.StringPtrVar(cmd.Flags(), &createDomainReq.DomainId, "domain-id", `Client-supplied resource ID for the new domain.`) // TODO: array: business_owner_ids - cmd.Flags().StringVar(&createDomainReq.Domain.Description, "description", createDomainReq.Domain.Description, `Full description (max 4096 chars).`) - cmd.Flags().BoolVar(&createDomainReq.Domain.Draft, "draft", createDomainReq.Domain.Draft, `Whether to mark the domain as a draft.`) + flags.StringPtrVar(cmd.Flags(), &createDomainReq.Domain.Description, "description", `Full description (max 4096 chars).`) + flags.BoolPtrVar(cmd.Flags(), &createDomainReq.Domain.Draft, "draft", `Whether to mark the domain as a draft.`) // TODO: complex arg: icon - cmd.Flags().StringVar(&createDomainReq.Domain.Name, "name", createDomainReq.Domain.Name, `Full resource name of the domain.`) - cmd.Flags().StringVar(&createDomainReq.Domain.ParentDomainId, "parent-domain-id", createDomainReq.Domain.ParentDomainId, `Domain ID of the parent.`) - cmd.Flags().StringVar(&createDomainReq.Domain.Subtitle, "subtitle", createDomainReq.Domain.Subtitle, `Short description (max 280 chars).`) + flags.StringPtrVar(cmd.Flags(), &createDomainReq.Domain.Name, "name", `Full resource name of the domain.`) + flags.StringPtrVar(cmd.Flags(), &createDomainReq.Domain.ParentDomainId, "parent-domain-id", `Domain ID of the parent.`) + flags.StringPtrVar(cmd.Flags(), &createDomainReq.Domain.Subtitle, "subtitle", `Short description (max 280 chars).`) // TODO: array: technical_owner_ids cmd.Use = "create-domain TAG_KEY" @@ -109,6 +110,7 @@ Create a domain. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createDomainJson.Unmarshal(&createDomainReq.Domain) @@ -123,15 +125,23 @@ Create a domain. } } if !cmd.Flags().Changed("json") { - createDomainReq.Domain.TagKey = args[0] + createDomainReq.Domain.TagKey = new(args[0]) } - response, err := w.Domains.CreateDomain(ctx, createDomainReq) + sdkReq, err := domains.CreateDomainRequestToSDK(&createDomainReq) + if err != nil { + return err + } + response, err := w.Domains.CreateDomain(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := domains.DomainFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -157,10 +167,9 @@ var deleteDomainOverrides []func( func newDeleteDomain() *cobra.Command { cmd := &cobra.Command{} - var deleteDomainReq domains.DeleteDomainRequest - cmd.Flags().BoolVar(&deleteDomainReq.Force, "force", deleteDomainReq.Force, `When false (default), DeleteDomain is rejected with FAILED_PRECONDITION if the domain still has Glossary pages.`) + flags.BoolPtrVar(cmd.Flags(), &deleteDomainReq.Force, "force", `When false (default), DeleteDomain is rejected with FAILED_PRECONDITION if the domain still has Glossary pages.`) cmd.Use = "delete-domain NAME" cmd.Short = `*Beta* Delete a domain.` @@ -187,10 +196,15 @@ Delete a domain. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteDomainReq.Name = args[0] + deleteDomainReq.Name = new(args[0]) - err = w.Domains.DeleteDomain(ctx, deleteDomainReq) + sdkReq, err := domains.DeleteDomainRequestToSDK(&deleteDomainReq) + if err != nil { + return err + } + err = w.Domains.DeleteDomain(ctx, *sdkReq) if err != nil { return err } @@ -215,13 +229,12 @@ Delete a domain. // Functions can be added from the `init()` function in manually curated files in this directory. var getDomainOverrides []func( *cobra.Command, - *domains.GetDomainRequest, + *sdkdomains.GetDomainRequest, ) func newGetDomain() *cobra.Command { cmd := &cobra.Command{} - - var getDomainReq domains.GetDomainRequest + var getDomainReq sdkdomains.GetDomainRequest cmd.Use = "get-domain NAME" cmd.Short = `*Beta* Get a domain.` @@ -250,15 +263,21 @@ Get a domain. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getDomainReq.Name = args[0] + getDomainReq.Name = new(args[0]) - response, err := w.Domains.GetDomain(ctx, getDomainReq) + sdkReq := &getDomainReq + response, err := w.Domains.GetDomain(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := domains.DomainFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -284,21 +303,21 @@ var listDomainsOverrides []func( func newListDomains() *cobra.Command { cmd := &cobra.Command{} - var listDomainsReq domains.ListDomainsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listDomainsLimit int - cmd.Flags().IntVar(&listDomainsReq.PageSize, "page-size", listDomainsReq.PageSize, ``) - cmd.Flags().StringVar(&listDomainsReq.ParentDomainId, "parent-domain-id", listDomainsReq.ParentDomainId, `Filter by parent domain.`) + flags.IntPtrVar(cmd.Flags(), &listDomainsReq.PageSize, "page-size", ``) + flags.StringPtrVar(cmd.Flags(), &listDomainsReq.ParentDomainId, "parent-domain-id", `Filter by parent domain.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listDomainsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listDomainsReq.PageToken, "page-token", listDomainsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listDomainsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-domains" @@ -326,16 +345,20 @@ List domains. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Domains.ListDomains(ctx, listDomainsReq) + sdkReq, err := domains.ListDomainsRequestToSDK(&listDomainsReq) + if err != nil { + return err + } if listDomainsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listDomainsLimit) } if listDomainsLimit > 0 { ctx = cmdio.WithLimit(ctx, listDomainsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Domains.ListDomainsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, domains.DomainFromSDK)) } // Disable completions since they are not applicable. @@ -361,20 +384,20 @@ var updateDomainOverrides []func( func newUpdateDomain() *cobra.Command { cmd := &cobra.Command{} - var updateDomainReq domains.UpdateDomainRequest - updateDomainReq.Domain = domains.Domain{} + updateDomainReq.Domain = &domains.Domain{} + var updateDomainJson flags.JsonFlag cmd.Flags().Var(&updateDomainJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: business_owner_ids - cmd.Flags().StringVar(&updateDomainReq.Domain.Description, "description", updateDomainReq.Domain.Description, `Full description (max 4096 chars).`) - cmd.Flags().BoolVar(&updateDomainReq.Domain.Draft, "draft", updateDomainReq.Domain.Draft, `Whether to mark the domain as a draft.`) + flags.StringPtrVar(cmd.Flags(), &updateDomainReq.Domain.Description, "description", `Full description (max 4096 chars).`) + flags.BoolPtrVar(cmd.Flags(), &updateDomainReq.Domain.Draft, "draft", `Whether to mark the domain as a draft.`) // TODO: complex arg: icon - cmd.Flags().StringVar(&updateDomainReq.Domain.Name, "name", updateDomainReq.Domain.Name, `Full resource name of the domain.`) - cmd.Flags().StringVar(&updateDomainReq.Domain.ParentDomainId, "parent-domain-id", updateDomainReq.Domain.ParentDomainId, `Domain ID of the parent.`) - cmd.Flags().StringVar(&updateDomainReq.Domain.Subtitle, "subtitle", updateDomainReq.Domain.Subtitle, `Short description (max 280 chars).`) + flags.StringPtrVar(cmd.Flags(), &updateDomainReq.Domain.Name, "name", `Full resource name of the domain.`) + flags.StringPtrVar(cmd.Flags(), &updateDomainReq.Domain.ParentDomainId, "parent-domain-id", `Domain ID of the parent.`) + flags.StringPtrVar(cmd.Flags(), &updateDomainReq.Domain.Subtitle, "subtitle", `Short description (max 280 chars).`) // TODO: array: technical_owner_ids cmd.Use = "update-domain NAME UPDATE_MASK TAG_KEY" @@ -424,6 +447,7 @@ Update a domain. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateDomainJson.Unmarshal(&updateDomainReq.Domain) @@ -437,21 +461,28 @@ Update a domain. } } } - updateDomainReq.Name = args[0] + updateDomainReq.Domain.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateDomainReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateDomainReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - updateDomainReq.Domain.TagKey = args[2] + updateDomainReq.Domain.TagKey = new(args[2]) } - response, err := w.Domains.UpdateDomain(ctx, updateDomainReq) + sdkReq, err := domains.UpdateDomainRequestToSDK(&updateDomainReq) + if err != nil { + return err + } + response, err := w.Domains.UpdateDomain(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := domains.DomainFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/enable-export-notebook/enable-export-notebook.go b/cmd/workspace/enable-export-notebook/enable-export-notebook.go index 234e724440d..319b1922498 100644 --- a/cmd/workspace/enable-export-notebook/enable-export-notebook.go +++ b/cmd/workspace/enable-export-notebook/enable-export-notebook.go @@ -5,11 +5,14 @@ package enable_export_notebook import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -71,11 +74,21 @@ Get the Notebook and File exporting setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.Settings.EnableExportNotebook().GetEnableExportNotebook(ctx) + _ = w + getEnableExportNotebookReq := map[string]any{} + rawQuery := map[string]any{} + rawPath := "/api/2.0/settings/types/enable-export-notebook/names/default" + + maps.Copy(rawQuery, getEnableExportNotebookReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -97,13 +110,16 @@ Get the Notebook and File exporting setting. // Functions can be added from the `init()` function in manually curated files in this directory. var patchEnableExportNotebookOverrides []func( *cobra.Command, - *settings.UpdateEnableExportNotebookRequest, + *map[string]any, ) func newPatchEnableExportNotebook() *cobra.Command { cmd := &cobra.Command{} + var patchEnableExportNotebookReq map[string]any + patchEnableExportNotebookReq = map[string]any{} + var patchEnableExportNotebookAllowMissingRaw bool + var patchEnableExportNotebookFieldMaskRaw string - var patchEnableExportNotebookReq settings.UpdateEnableExportNotebookRequest var patchEnableExportNotebookJson flags.JsonFlag cmd.Flags().Var(&patchEnableExportNotebookJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -126,6 +142,7 @@ Update the Notebook and File exporting setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := patchEnableExportNotebookJson.Unmarshal(&patchEnableExportNotebookReq) @@ -142,11 +159,24 @@ Update the Notebook and File exporting setting. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.EnableExportNotebook().PatchEnableExportNotebook(ctx, patchEnableExportNotebookReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || patchEnableExportNotebookAllowMissingRaw != false { + patchEnableExportNotebookReq["allow_missing"] = patchEnableExportNotebookAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || patchEnableExportNotebookFieldMaskRaw != "" { + patchEnableExportNotebookReq["field_mask"] = patchEnableExportNotebookFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/enable-export-notebook/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, patchEnableExportNotebookReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/enable-notebook-table-clipboard/enable-notebook-table-clipboard.go b/cmd/workspace/enable-notebook-table-clipboard/enable-notebook-table-clipboard.go index 48e11680f9f..25d21e52812 100644 --- a/cmd/workspace/enable-notebook-table-clipboard/enable-notebook-table-clipboard.go +++ b/cmd/workspace/enable-notebook-table-clipboard/enable-notebook-table-clipboard.go @@ -5,11 +5,14 @@ package enable_notebook_table_clipboard import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -71,11 +74,21 @@ Get the Results Table Clipboard features setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.Settings.EnableNotebookTableClipboard().GetEnableNotebookTableClipboard(ctx) + _ = w + getEnableNotebookTableClipboardReq := map[string]any{} + rawQuery := map[string]any{} + rawPath := "/api/2.0/settings/types/enable-notebook-table-clipboard/names/default" + + maps.Copy(rawQuery, getEnableNotebookTableClipboardReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -97,13 +110,16 @@ Get the Results Table Clipboard features setting. // Functions can be added from the `init()` function in manually curated files in this directory. var patchEnableNotebookTableClipboardOverrides []func( *cobra.Command, - *settings.UpdateEnableNotebookTableClipboardRequest, + *map[string]any, ) func newPatchEnableNotebookTableClipboard() *cobra.Command { cmd := &cobra.Command{} + var patchEnableNotebookTableClipboardReq map[string]any + patchEnableNotebookTableClipboardReq = map[string]any{} + var patchEnableNotebookTableClipboardAllowMissingRaw bool + var patchEnableNotebookTableClipboardFieldMaskRaw string - var patchEnableNotebookTableClipboardReq settings.UpdateEnableNotebookTableClipboardRequest var patchEnableNotebookTableClipboardJson flags.JsonFlag cmd.Flags().Var(&patchEnableNotebookTableClipboardJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -126,6 +142,7 @@ Update the Results Table Clipboard features setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := patchEnableNotebookTableClipboardJson.Unmarshal(&patchEnableNotebookTableClipboardReq) @@ -142,11 +159,24 @@ Update the Results Table Clipboard features setting. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.EnableNotebookTableClipboard().PatchEnableNotebookTableClipboard(ctx, patchEnableNotebookTableClipboardReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || patchEnableNotebookTableClipboardAllowMissingRaw != false { + patchEnableNotebookTableClipboardReq["allow_missing"] = patchEnableNotebookTableClipboardAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || patchEnableNotebookTableClipboardFieldMaskRaw != "" { + patchEnableNotebookTableClipboardReq["field_mask"] = patchEnableNotebookTableClipboardFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/enable-notebook-table-clipboard/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, patchEnableNotebookTableClipboardReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/enable-results-downloading/enable-results-downloading.go b/cmd/workspace/enable-results-downloading/enable-results-downloading.go index 9d417344d76..323aa3aab4c 100644 --- a/cmd/workspace/enable-results-downloading/enable-results-downloading.go +++ b/cmd/workspace/enable-results-downloading/enable-results-downloading.go @@ -5,11 +5,14 @@ package enable_results_downloading import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -71,11 +74,21 @@ Get the Notebook results download setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.Settings.EnableResultsDownloading().GetEnableResultsDownloading(ctx) + _ = w + getEnableResultsDownloadingReq := map[string]any{} + rawQuery := map[string]any{} + rawPath := "/api/2.0/settings/types/enable-results-downloading/names/default" + + maps.Copy(rawQuery, getEnableResultsDownloadingReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -97,13 +110,16 @@ Get the Notebook results download setting. // Functions can be added from the `init()` function in manually curated files in this directory. var patchEnableResultsDownloadingOverrides []func( *cobra.Command, - *settings.UpdateEnableResultsDownloadingRequest, + *map[string]any, ) func newPatchEnableResultsDownloading() *cobra.Command { cmd := &cobra.Command{} + var patchEnableResultsDownloadingReq map[string]any + patchEnableResultsDownloadingReq = map[string]any{} + var patchEnableResultsDownloadingAllowMissingRaw bool + var patchEnableResultsDownloadingFieldMaskRaw string - var patchEnableResultsDownloadingReq settings.UpdateEnableResultsDownloadingRequest var patchEnableResultsDownloadingJson flags.JsonFlag cmd.Flags().Var(&patchEnableResultsDownloadingJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -126,6 +142,7 @@ Update the Notebook results download setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := patchEnableResultsDownloadingJson.Unmarshal(&patchEnableResultsDownloadingReq) @@ -142,11 +159,24 @@ Update the Notebook results download setting. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.EnableResultsDownloading().PatchEnableResultsDownloading(ctx, patchEnableResultsDownloadingReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || patchEnableResultsDownloadingAllowMissingRaw != false { + patchEnableResultsDownloadingReq["allow_missing"] = patchEnableResultsDownloadingAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || patchEnableResultsDownloadingFieldMaskRaw != "" { + patchEnableResultsDownloadingReq["field_mask"] = patchEnableResultsDownloadingFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/enable-results-downloading/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, patchEnableResultsDownloadingReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go b/cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go index ee5eb69c722..396c8fc0a96 100644 --- a/cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go +++ b/cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go @@ -5,11 +5,14 @@ package enhanced_security_monitoring import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -55,15 +58,16 @@ Controls whether enhanced security monitoring is enabled for the current // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetEnhancedSecurityMonitoringSettingRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetEnhancedSecurityMonitoringSettingRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `*Public Preview* Get the enhanced security monitoring setting.` @@ -86,12 +90,24 @@ Get the enhanced security monitoring setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/shield_esm_enablement_ws_db/names/default" - response, err := w.Settings.EnhancedSecurityMonitoring().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -113,13 +129,16 @@ Get the enhanced security monitoring setting. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateEnhancedSecurityMonitoringSettingRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateEnhancedSecurityMonitoringSettingRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -144,6 +163,7 @@ Update the enhanced security monitoring setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -160,11 +180,24 @@ Update the enhanced security monitoring setting. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.EnhancedSecurityMonitoring().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/shield_esm_enablement_ws_db/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/entity-tag-assignments/entity-tag-assignments.go b/cmd/workspace/entity-tag-assignments/entity-tag-assignments.go index d7caf1bbab7..70022a45a93 100644 --- a/cmd/workspace/entity-tag-assignments/entity-tag-assignments.go +++ b/cmd/workspace/entity-tag-assignments/entity-tag-assignments.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucentitytagassignments "github.com/databricks/cli/libs/sdktypes/uc/entitytagassignments/v1" + sdkucentitytagassignments "github.com/databricks/sdk-go/uc/entitytagassignments/v1" ) // Slice with functions to override default command behavior. @@ -56,19 +59,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateEntityTagAssignmentRequest, + *ucentitytagassignments.CreateEntityTagAssignmentRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq ucentitytagassignments.CreateEntityTagAssignmentRequest + createReq.TagAssignment = &ucentitytagassignments.EntityTagAssignment{} - 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.`) + flags.StringPtrVar(cmd.Flags(), &createReq.TagAssignment.TagValue, "tag-value", `The value of the tag.`) cmd.Use = "create ENTITY_NAME TAG_KEY ENTITY_TYPE" cmd.Short = `Create an entity tag assignment.` @@ -111,6 +114,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.TagAssignment) @@ -125,21 +129,29 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.TagAssignment.EntityName = args[0] + createReq.TagAssignment.EntityName = new(args[0]) } if !cmd.Flags().Changed("json") { - createReq.TagAssignment.TagKey = args[1] + createReq.TagAssignment.TagKey = new(args[1]) } if !cmd.Flags().Changed("json") { - createReq.TagAssignment.EntityType = args[2] + createReq.TagAssignment.EntityType = new(args[2]) } - response, err := w.EntityTagAssignments.Create(ctx, createReq) + sdkReq, err := ucentitytagassignments.CreateEntityTagAssignmentRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.EntityTagAssignments.CreateEntityTagAssignment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucentitytagassignments.EntityTagAssignmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -160,13 +172,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteEntityTagAssignmentRequest, + *sdkucentitytagassignments.DeleteEntityTagAssignmentRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq catalog.DeleteEntityTagAssignmentRequest + var deleteReq sdkucentitytagassignments.DeleteEntityTagAssignmentRequest cmd.Use = "delete ENTITY_TYPE ENTITY_NAME TAG_KEY" cmd.Short = `Delete an entity tag assignment.` @@ -202,12 +213,14 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.EntityType = args[0] - deleteReq.EntityName = args[1] - deleteReq.TagKey = args[2] + deleteReq.EntityType = new(args[0]) + deleteReq.EntityName = new(args[1]) + deleteReq.TagKey = new(args[2]) - err = w.EntityTagAssignments.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = w.EntityTagAssignments.DeleteEntityTagAssignment(ctx, *sdkReq) if err != nil { return err } @@ -232,13 +245,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetEntityTagAssignmentRequest, + *sdkucentitytagassignments.GetEntityTagAssignmentRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq catalog.GetEntityTagAssignmentRequest + var getReq sdkucentitytagassignments.GetEntityTagAssignmentRequest cmd.Use = "get ENTITY_TYPE ENTITY_NAME TAG_KEY" cmd.Short = `Get an entity tag assignment.` @@ -264,17 +276,23 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.EntityType = args[0] - getReq.EntityName = args[1] - getReq.TagKey = args[2] + getReq.EntityType = new(args[0]) + getReq.EntityName = new(args[1]) + getReq.TagKey = new(args[2]) - response, err := w.EntityTagAssignments.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.EntityTagAssignments.GetEntityTagAssignment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucentitytagassignments.EntityTagAssignmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -295,25 +313,25 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListEntityTagAssignmentsRequest, + *ucentitytagassignments.ListEntityTagAssignmentsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq ucentitytagassignments.ListEntityTagAssignmentsRequest - var listReq catalog.ListEntityTagAssignmentsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Optional.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Optional.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list ENTITY_TYPE ENTITY_NAME" @@ -344,19 +362,23 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.EntityType = args[0] - listReq.EntityName = args[1] + listReq.EntityType = new(args[0]) + listReq.EntityName = new(args[1]) - response := w.EntityTagAssignments.List(ctx, listReq) + sdkReq, err := ucentitytagassignments.ListEntityTagAssignmentsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.EntityTagAssignments.ListEntityTagAssignmentsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucentitytagassignments.EntityTagAssignmentFromSDK)) } // Disable completions since they are not applicable. @@ -377,19 +399,19 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateEntityTagAssignmentRequest, + *ucentitytagassignments.UpdateEntityTagAssignmentRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucentitytagassignments.UpdateEntityTagAssignmentRequest + updateReq.TagAssignment = &ucentitytagassignments.EntityTagAssignment{} - 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.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.TagAssignment.TagValue, "tag-value", `The value of the tag.`) cmd.Use = "update ENTITY_TYPE ENTITY_NAME TAG_KEY UPDATE_MASK" cmd.Short = `Update an entity tag assignment.` @@ -436,6 +458,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.TagAssignment) @@ -449,17 +472,25 @@ func newUpdate() *cobra.Command { } } } - updateReq.EntityType = args[0] - updateReq.EntityName = args[1] - updateReq.TagKey = args[2] - updateReq.UpdateMask = args[3] + updateReq.TagAssignment.EntityType = new(args[0]) + updateReq.TagAssignment.EntityName = new(args[1]) + updateReq.TagAssignment.TagKey = new(args[2]) + updateReq.UpdateMask = new(args[3]) - response, err := w.EntityTagAssignments.Update(ctx, updateReq) + sdkReq, err := ucentitytagassignments.UpdateEntityTagAssignmentRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.EntityTagAssignments.UpdateEntityTagAssignment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucentitytagassignments.EntityTagAssignmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/environments/environments.go b/cmd/workspace/environments/environments.go index a11d550a52d..3b63f13fd12 100644 --- a/cmd/workspace/environments/environments.go +++ b/cmd/workspace/environments/environments.go @@ -5,17 +5,18 @@ package environments import ( "errors" "fmt" - "strings" "time" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "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/experimental/api" - "github.com/databricks/databricks-sdk-go/service/environments" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + environments "github.com/databricks/cli/libs/sdktypes/environments/v1" + sdkenvironments "github.com/databricks/sdk-go/environments/v1" ) // Slice with functions to override default command behavior. @@ -70,9 +71,9 @@ var createWorkspaceBaseEnvironmentOverrides []func( func newCreateWorkspaceBaseEnvironment() *cobra.Command { cmd := &cobra.Command{} - var createWorkspaceBaseEnvironmentReq environments.CreateWorkspaceBaseEnvironmentRequest - createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment = environments.WorkspaceBaseEnvironment{} + createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment = &environments.WorkspaceBaseEnvironment{} + var createWorkspaceBaseEnvironmentJson flags.JsonFlag var createWorkspaceBaseEnvironmentSkipWait bool @@ -83,11 +84,11 @@ func newCreateWorkspaceBaseEnvironment() *cobra.Command { cmd.Flags().Var(&createWorkspaceBaseEnvironmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createWorkspaceBaseEnvironmentReq.RequestId, "request-id", createWorkspaceBaseEnvironmentReq.RequestId, `A unique identifier for this request.`) - cmd.Flags().StringVar(&createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironmentId, "workspace-base-environment-id", createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironmentId, `The ID to use for the workspace base environment, which will become the final component of the resource name.`) - cmd.Flags().Var(&createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.BaseEnvironmentType, "base-environment-type", `The type of base environment (CPU or GPU). Supported values: [CPU, GPU]`) - cmd.Flags().StringVar(&createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.Filepath, "filepath", createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.Filepath, `The WSFS or UC Volumes path to the environment YAML file.`) - cmd.Flags().StringVar(&createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.Name, "name", createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.Name, `The resource name of the workspace base environment.`) + flags.StringPtrVar(cmd.Flags(), &createWorkspaceBaseEnvironmentReq.RequestId, "request-id", `A unique identifier for this request.`) + flags.StringPtrVar(cmd.Flags(), &createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironmentId, "workspace-base-environment-id", `The ID to use for the workspace base environment, which will become the final component of the resource name.`) + flags.EnumVar(cmd.Flags(), &createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.BaseEnvironmentType, "base-environment-type", `The type of base environment (CPU or GPU). Supported values: [CPU, GPU]`, "BaseEnvironmentType", "CPU", "GPU") + flags.StringPtrVar(cmd.Flags(), &createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.Filepath, "filepath", `The WSFS or UC Volumes path to the environment YAML file.`) + flags.StringPtrVar(cmd.Flags(), &createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.Name, "name", `The resource name of the workspace base environment.`) // TODO: complex arg: spec cmd.Use = "create-workspace-base-environment DISPLAY_NAME" @@ -127,6 +128,7 @@ func newCreateWorkspaceBaseEnvironment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createWorkspaceBaseEnvironmentJson.Unmarshal(&createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment) @@ -141,28 +143,26 @@ func newCreateWorkspaceBaseEnvironment() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.DisplayName = args[0] + createWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.DisplayName = new(args[0]) } + sdkReq, err := environments.CreateWorkspaceBaseEnvironmentRequestToSDK(&createWorkspaceBaseEnvironmentReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case createWorkspaceBaseEnvironmentSkipWait: - wait, err := w.Environments.CreateWorkspaceBaseEnvironment(ctx, createWorkspaceBaseEnvironmentReq) + wait, err := w.Environments.CreateWorkspaceBaseEnvironment(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Environments.GetOperation(ctx, environments.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Environments.CreateWorkspaceBaseEnvironment(ctx, createWorkspaceBaseEnvironmentReq) + wait, err := w.Environments.CreateWorkspaceBaseEnvironment(ctx, *sdkReq) if err != nil { return err } @@ -172,13 +172,17 @@ func newCreateWorkspaceBaseEnvironment() *cobra.Command { sp.Update("Waiting for create-workspace-base-environment to complete...") // Wait for completion. - opts := api.WithTimeout(createWorkspaceBaseEnvironmentTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(createWorkspaceBaseEnvironmentTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := environments.WorkspaceBaseEnvironmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -200,13 +204,12 @@ func newCreateWorkspaceBaseEnvironment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteWorkspaceBaseEnvironmentOverrides []func( *cobra.Command, - *environments.DeleteWorkspaceBaseEnvironmentRequest, + *sdkenvironments.DeleteWorkspaceBaseEnvironmentRequest, ) func newDeleteWorkspaceBaseEnvironment() *cobra.Command { cmd := &cobra.Command{} - - var deleteWorkspaceBaseEnvironmentReq environments.DeleteWorkspaceBaseEnvironmentRequest + var deleteWorkspaceBaseEnvironmentReq sdkenvironments.DeleteWorkspaceBaseEnvironmentRequest cmd.Use = "delete-workspace-base-environment NAME" cmd.Short = `Delete a workspace base environment.` @@ -233,10 +236,12 @@ func newDeleteWorkspaceBaseEnvironment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteWorkspaceBaseEnvironmentReq.Name = args[0] + deleteWorkspaceBaseEnvironmentReq.Name = new(args[0]) - err = w.Environments.DeleteWorkspaceBaseEnvironment(ctx, deleteWorkspaceBaseEnvironmentReq) + sdkReq := &deleteWorkspaceBaseEnvironmentReq + err = w.Environments.DeleteWorkspaceBaseEnvironment(ctx, *sdkReq) if err != nil { return err } @@ -261,13 +266,12 @@ func newDeleteWorkspaceBaseEnvironment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getDefaultWorkspaceBaseEnvironmentOverrides []func( *cobra.Command, - *environments.GetDefaultWorkspaceBaseEnvironmentRequest, + *sdkenvironments.GetDefaultWorkspaceBaseEnvironmentRequest, ) func newGetDefaultWorkspaceBaseEnvironment() *cobra.Command { cmd := &cobra.Command{} - - var getDefaultWorkspaceBaseEnvironmentReq environments.GetDefaultWorkspaceBaseEnvironmentRequest + var getDefaultWorkspaceBaseEnvironmentReq sdkenvironments.GetDefaultWorkspaceBaseEnvironmentRequest cmd.Use = "get-default-workspace-base-environment NAME" cmd.Short = `Get the default workspace base environment configuration.` @@ -294,15 +298,21 @@ func newGetDefaultWorkspaceBaseEnvironment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getDefaultWorkspaceBaseEnvironmentReq.Name = args[0] + getDefaultWorkspaceBaseEnvironmentReq.Name = new(args[0]) - response, err := w.Environments.GetDefaultWorkspaceBaseEnvironment(ctx, getDefaultWorkspaceBaseEnvironmentReq) + sdkReq := &getDefaultWorkspaceBaseEnvironmentReq + response, err := w.Environments.GetDefaultWorkspaceBaseEnvironment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := environments.DefaultWorkspaceBaseEnvironmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -323,13 +333,12 @@ func newGetDefaultWorkspaceBaseEnvironment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOperationOverrides []func( *cobra.Command, - *environments.GetOperationRequest, + *sdkenvironments.GetDefaultWorkspaceBaseEnvironmentRequest, ) func newGetOperation() *cobra.Command { cmd := &cobra.Command{} - - var getOperationReq environments.GetOperationRequest + var getOperationReq sdkenvironments.GetDefaultWorkspaceBaseEnvironmentRequest cmd.Use = "get-operation NAME" cmd.Short = `Get the status of a long-running operation.` @@ -354,15 +363,21 @@ func newGetOperation() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getOperationReq.Name = args[0] + getOperationReq.Name = new(args[0]) - response, err := w.Environments.GetOperation(ctx, getOperationReq) + sdkReq := &getOperationReq + response, err := w.Environments.GetDefaultWorkspaceBaseEnvironment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := environments.DefaultWorkspaceBaseEnvironmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -383,13 +398,12 @@ func newGetOperation() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getWorkspaceBaseEnvironmentOverrides []func( *cobra.Command, - *environments.GetWorkspaceBaseEnvironmentRequest, + *sdkenvironments.GetWorkspaceBaseEnvironmentRequest, ) func newGetWorkspaceBaseEnvironment() *cobra.Command { cmd := &cobra.Command{} - - var getWorkspaceBaseEnvironmentReq environments.GetWorkspaceBaseEnvironmentRequest + var getWorkspaceBaseEnvironmentReq sdkenvironments.GetWorkspaceBaseEnvironmentRequest cmd.Use = "get-workspace-base-environment NAME" cmd.Short = `Get a workspace base environment.` @@ -414,15 +428,21 @@ func newGetWorkspaceBaseEnvironment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getWorkspaceBaseEnvironmentReq.Name = args[0] + getWorkspaceBaseEnvironmentReq.Name = new(args[0]) - response, err := w.Environments.GetWorkspaceBaseEnvironment(ctx, getWorkspaceBaseEnvironmentReq) + sdkReq := &getWorkspaceBaseEnvironmentReq + response, err := w.Environments.GetWorkspaceBaseEnvironment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := environments.WorkspaceBaseEnvironmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -448,20 +468,20 @@ var listWorkspaceBaseEnvironmentsOverrides []func( func newListWorkspaceBaseEnvironments() *cobra.Command { cmd := &cobra.Command{} - var listWorkspaceBaseEnvironmentsReq environments.ListWorkspaceBaseEnvironmentsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listWorkspaceBaseEnvironmentsLimit int - cmd.Flags().IntVar(&listWorkspaceBaseEnvironmentsReq.PageSize, "page-size", listWorkspaceBaseEnvironmentsReq.PageSize, `The maximum number of environments to return per page.`) + flags.IntPtrVar(cmd.Flags(), &listWorkspaceBaseEnvironmentsReq.PageSize, "page-size", `The maximum number of environments to return per page.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listWorkspaceBaseEnvironmentsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listWorkspaceBaseEnvironmentsReq.PageToken, "page-token", listWorkspaceBaseEnvironmentsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listWorkspaceBaseEnvironmentsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-workspace-base-environments" @@ -495,16 +515,20 @@ func newListWorkspaceBaseEnvironments() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Environments.ListWorkspaceBaseEnvironments(ctx, listWorkspaceBaseEnvironmentsReq) + sdkReq, err := environments.ListWorkspaceBaseEnvironmentsRequestToSDK(&listWorkspaceBaseEnvironmentsReq) + if err != nil { + return err + } if listWorkspaceBaseEnvironmentsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listWorkspaceBaseEnvironmentsLimit) } if listWorkspaceBaseEnvironmentsLimit > 0 { ctx = cmdio.WithLimit(ctx, listWorkspaceBaseEnvironmentsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Environments.ListWorkspaceBaseEnvironmentsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, environments.WorkspaceBaseEnvironmentFromSDK)) } // Disable completions since they are not applicable. @@ -530,7 +554,6 @@ var refreshWorkspaceBaseEnvironmentOverrides []func( func newRefreshWorkspaceBaseEnvironment() *cobra.Command { cmd := &cobra.Command{} - var refreshWorkspaceBaseEnvironmentReq environments.RefreshWorkspaceBaseEnvironmentRequest var refreshWorkspaceBaseEnvironmentSkipWait bool @@ -571,28 +594,27 @@ func newRefreshWorkspaceBaseEnvironment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - refreshWorkspaceBaseEnvironmentReq.Name = args[0] + refreshWorkspaceBaseEnvironmentReq.Name = new(args[0]) + sdkReq, err := environments.RefreshWorkspaceBaseEnvironmentRequestToSDK(&refreshWorkspaceBaseEnvironmentReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case refreshWorkspaceBaseEnvironmentSkipWait: - wait, err := w.Environments.RefreshWorkspaceBaseEnvironment(ctx, refreshWorkspaceBaseEnvironmentReq) + wait, err := w.Environments.RefreshWorkspaceBaseEnvironment(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Environments.GetOperation(ctx, environments.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Environments.RefreshWorkspaceBaseEnvironment(ctx, refreshWorkspaceBaseEnvironmentReq) + wait, err := w.Environments.RefreshWorkspaceBaseEnvironment(ctx, *sdkReq) if err != nil { return err } @@ -602,13 +624,17 @@ func newRefreshWorkspaceBaseEnvironment() *cobra.Command { sp.Update("Waiting for refresh-workspace-base-environment to complete...") // Wait for completion. - opts := api.WithTimeout(refreshWorkspaceBaseEnvironmentTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(refreshWorkspaceBaseEnvironmentTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := environments.WorkspaceBaseEnvironmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -635,16 +661,16 @@ var updateDefaultWorkspaceBaseEnvironmentOverrides []func( func newUpdateDefaultWorkspaceBaseEnvironment() *cobra.Command { cmd := &cobra.Command{} - var updateDefaultWorkspaceBaseEnvironmentReq environments.UpdateDefaultWorkspaceBaseEnvironmentRequest - updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment = environments.DefaultWorkspaceBaseEnvironment{} + updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment = &environments.DefaultWorkspaceBaseEnvironment{} + var updateDefaultWorkspaceBaseEnvironmentJson flags.JsonFlag cmd.Flags().Var(&updateDefaultWorkspaceBaseEnvironmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment.CpuWorkspaceBaseEnvironment, "cpu-workspace-base-environment", updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment.CpuWorkspaceBaseEnvironment, `The default workspace base environment for CPU compute.`) - cmd.Flags().StringVar(&updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment.GpuWorkspaceBaseEnvironment, "gpu-workspace-base-environment", updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment.GpuWorkspaceBaseEnvironment, `The default workspace base environment for GPU compute.`) - cmd.Flags().StringVar(&updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment.Name, "name", updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment.Name, `The resource name of this singleton resource.`) + flags.StringPtrVar(cmd.Flags(), &updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment.CpuWorkspaceBaseEnvironment, "cpu-workspace-base-environment", `The default workspace base environment for CPU compute.`) + flags.StringPtrVar(cmd.Flags(), &updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment.GpuWorkspaceBaseEnvironment, "gpu-workspace-base-environment", `The default workspace base environment for GPU compute.`) + flags.StringPtrVar(cmd.Flags(), &updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment.Name, "name", `The resource name of this singleton resource.`) cmd.Use = "update-default-workspace-base-environment NAME UPDATE_MASK" cmd.Short = `Update the default workspace base environment configuration.` @@ -679,6 +705,7 @@ func newUpdateDefaultWorkspaceBaseEnvironment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateDefaultWorkspaceBaseEnvironmentJson.Unmarshal(&updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment) @@ -692,18 +719,25 @@ func newUpdateDefaultWorkspaceBaseEnvironment() *cobra.Command { } } } - updateDefaultWorkspaceBaseEnvironmentReq.Name = args[0] + updateDefaultWorkspaceBaseEnvironmentReq.DefaultWorkspaceBaseEnvironment.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateDefaultWorkspaceBaseEnvironmentReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateDefaultWorkspaceBaseEnvironmentReq.UpdateMask = new(args[1]) } - response, err := w.Environments.UpdateDefaultWorkspaceBaseEnvironment(ctx, updateDefaultWorkspaceBaseEnvironmentReq) + sdkReq, err := environments.UpdateDefaultWorkspaceBaseEnvironmentRequestToSDK(&updateDefaultWorkspaceBaseEnvironmentReq) + if err != nil { + return err + } + response, err := w.Environments.UpdateDefaultWorkspaceBaseEnvironment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := environments.DefaultWorkspaceBaseEnvironmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -729,9 +763,9 @@ var updateWorkspaceBaseEnvironmentOverrides []func( func newUpdateWorkspaceBaseEnvironment() *cobra.Command { cmd := &cobra.Command{} - var updateWorkspaceBaseEnvironmentReq environments.UpdateWorkspaceBaseEnvironmentRequest - updateWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment = environments.WorkspaceBaseEnvironment{} + updateWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment = &environments.WorkspaceBaseEnvironment{} + var updateWorkspaceBaseEnvironmentJson flags.JsonFlag var updateWorkspaceBaseEnvironmentSkipWait bool @@ -742,9 +776,9 @@ func newUpdateWorkspaceBaseEnvironment() *cobra.Command { cmd.Flags().Var(&updateWorkspaceBaseEnvironmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Var(&updateWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.BaseEnvironmentType, "base-environment-type", `The type of base environment (CPU or GPU). Supported values: [CPU, GPU]`) - cmd.Flags().StringVar(&updateWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.Filepath, "filepath", updateWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.Filepath, `The WSFS or UC Volumes path to the environment YAML file.`) - cmd.Flags().StringVar(&updateWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.Name, "name", updateWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.Name, `The resource name of the workspace base environment.`) + flags.EnumVar(cmd.Flags(), &updateWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.BaseEnvironmentType, "base-environment-type", `The type of base environment (CPU or GPU). Supported values: [CPU, GPU]`, "BaseEnvironmentType", "CPU", "GPU") + flags.StringPtrVar(cmd.Flags(), &updateWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.Filepath, "filepath", `The WSFS or UC Volumes path to the environment YAML file.`) + flags.StringPtrVar(cmd.Flags(), &updateWorkspaceBaseEnvironmentReq.Name, "name", `The resource name of the workspace base environment.`) // TODO: complex arg: spec cmd.Use = "update-workspace-base-environment NAME DISPLAY_NAME" @@ -786,6 +820,7 @@ func newUpdateWorkspaceBaseEnvironment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateWorkspaceBaseEnvironmentJson.Unmarshal(&updateWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment) @@ -799,30 +834,28 @@ func newUpdateWorkspaceBaseEnvironment() *cobra.Command { } } } - updateWorkspaceBaseEnvironmentReq.Name = args[0] + updateWorkspaceBaseEnvironmentReq.Name = new(args[0]) if !cmd.Flags().Changed("json") { - updateWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.DisplayName = args[1] + updateWorkspaceBaseEnvironmentReq.WorkspaceBaseEnvironment.DisplayName = new(args[1]) } + sdkReq, err := environments.UpdateWorkspaceBaseEnvironmentRequestToSDK(&updateWorkspaceBaseEnvironmentReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case updateWorkspaceBaseEnvironmentSkipWait: - wait, err := w.Environments.UpdateWorkspaceBaseEnvironment(ctx, updateWorkspaceBaseEnvironmentReq) + wait, err := w.Environments.UpdateWorkspaceBaseEnvironment(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Environments.GetOperation(ctx, environments.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Environments.UpdateWorkspaceBaseEnvironment(ctx, updateWorkspaceBaseEnvironmentReq) + wait, err := w.Environments.UpdateWorkspaceBaseEnvironment(ctx, *sdkReq) if err != nil { return err } @@ -832,13 +865,17 @@ func newUpdateWorkspaceBaseEnvironment() *cobra.Command { sp.Update("Waiting for update-workspace-base-environment to complete...") // Wait for completion. - opts := api.WithTimeout(updateWorkspaceBaseEnvironmentTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(updateWorkspaceBaseEnvironmentTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := environments.WorkspaceBaseEnvironmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } diff --git a/cmd/workspace/experiments/experiments.go b/cmd/workspace/experiments/experiments.go index 6a668968176..68444fe0f49 100644 --- a/cmd/workspace/experiments/experiments.go +++ b/cmd/workspace/experiments/experiments.go @@ -8,10 +8,15 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/ml" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + experiments "github.com/databricks/cli/libs/sdktypes/experiments/v1" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdkexperiments "github.com/databricks/sdk-go/experiments/v1" ) // Slice with functions to override default command behavior. @@ -94,18 +99,18 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createExperimentOverrides []func( *cobra.Command, - *ml.CreateExperiment, + *experiments.CreateExperimentRequest, ) func newCreateExperiment() *cobra.Command { cmd := &cobra.Command{} + var createExperimentReq experiments.CreateExperimentRequest - var createExperimentReq ml.CreateExperiment var createExperimentJson flags.JsonFlag cmd.Flags().Var(&createExperimentJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createExperimentReq.ArtifactLocation, "artifact-location", createExperimentReq.ArtifactLocation, `Location where all artifacts for the experiment are stored.`) + flags.StringPtrVar(cmd.Flags(), &createExperimentReq.ArtifactLocation, "artifact-location", `Location where all artifacts for the experiment are stored.`) // TODO: array: tags // TODO: complex arg: trace_location @@ -145,6 +150,7 @@ func newCreateExperiment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createExperimentJson.Unmarshal(&createExperimentReq) @@ -159,15 +165,23 @@ func newCreateExperiment() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createExperimentReq.Name = args[0] + createExperimentReq.Name = new(args[0]) } - response, err := w.Experiments.CreateExperiment(ctx, createExperimentReq) + sdkReq, err := experiments.CreateExperimentRequestToSDK(&createExperimentReq) + if err != nil { + return err + } + response, err := w.Experiments.CreateExperiment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := experiments.CreateExperimentResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -188,21 +202,21 @@ func newCreateExperiment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createLoggedModelOverrides []func( *cobra.Command, - *ml.CreateLoggedModelRequest, + *experiments.CreateLoggedModelRequest, ) func newCreateLoggedModel() *cobra.Command { cmd := &cobra.Command{} + var createLoggedModelReq experiments.CreateLoggedModelRequest - var createLoggedModelReq ml.CreateLoggedModelRequest var createLoggedModelJson flags.JsonFlag cmd.Flags().Var(&createLoggedModelJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createLoggedModelReq.ModelType, "model-type", createLoggedModelReq.ModelType, `The type of the model, such as "Agent", "Classifier", "LLM".`) - cmd.Flags().StringVar(&createLoggedModelReq.Name, "name", createLoggedModelReq.Name, `The name of the model (optional).`) + flags.StringPtrVar(cmd.Flags(), &createLoggedModelReq.ModelType, "model-type", `The type of the model, such as "Agent", "Classifier", "LLM".`) + flags.StringPtrVar(cmd.Flags(), &createLoggedModelReq.Name, "name", `The name of the model (optional).`) // TODO: array: params - cmd.Flags().StringVar(&createLoggedModelReq.SourceRunId, "source-run-id", createLoggedModelReq.SourceRunId, `The ID of the run that created the model.`) + flags.StringPtrVar(cmd.Flags(), &createLoggedModelReq.SourceRunId, "source-run-id", `The ID of the run that created the model.`) // TODO: array: tags cmd.Use = "create-logged-model EXPERIMENT_ID" @@ -232,6 +246,7 @@ func newCreateLoggedModel() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createLoggedModelJson.Unmarshal(&createLoggedModelReq) @@ -246,15 +261,23 @@ func newCreateLoggedModel() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createLoggedModelReq.ExperimentId = args[0] + createLoggedModelReq.ExperimentId = new(args[0]) } - response, err := w.Experiments.CreateLoggedModel(ctx, createLoggedModelReq) + sdkReq, err := experiments.CreateLoggedModelRequestToSDK(&createLoggedModelReq) + if err != nil { + return err + } + response, err := w.Experiments.CreateLoggedModel(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := experiments.CreateLoggedModelResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -275,22 +298,22 @@ func newCreateLoggedModel() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createRunOverrides []func( *cobra.Command, - *ml.CreateRun, + *experiments.CreateRunRequest, ) func newCreateRun() *cobra.Command { cmd := &cobra.Command{} + var createRunReq experiments.CreateRunRequest - var createRunReq ml.CreateRun var createRunJson flags.JsonFlag cmd.Flags().Var(&createRunJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createRunReq.ExperimentId, "experiment-id", createRunReq.ExperimentId, `ID of the associated experiment.`) - cmd.Flags().StringVar(&createRunReq.RunName, "run-name", createRunReq.RunName, `The name of the run.`) - cmd.Flags().Int64Var(&createRunReq.StartTime, "start-time", createRunReq.StartTime, `Unix timestamp in milliseconds of when the run started.`) + flags.StringPtrVar(cmd.Flags(), &createRunReq.ExperimentId, "experiment-id", `ID of the associated experiment.`) + flags.StringPtrVar(cmd.Flags(), &createRunReq.RunName, "run-name", `The name of the run.`) + flags.Int64PtrVar(cmd.Flags(), &createRunReq.StartTime, "start-time", `Unix timestamp in milliseconds of when the run started.`) // TODO: array: tags - cmd.Flags().StringVar(&createRunReq.UserId, "user-id", createRunReq.UserId, `ID of the user executing the run.`) + flags.StringPtrVar(cmd.Flags(), &createRunReq.UserId, "user-id", `ID of the user executing the run.`) cmd.Use = "create-run" cmd.Short = `Create a run.` @@ -314,6 +337,7 @@ func newCreateRun() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createRunJson.Unmarshal(&createRunReq) @@ -328,12 +352,20 @@ func newCreateRun() *cobra.Command { } } - response, err := w.Experiments.CreateRun(ctx, createRunReq) + sdkReq, err := experiments.CreateRunRequestToSDK(&createRunReq) + if err != nil { + return err + } + response, err := w.Experiments.CreateRun(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := experiments.CreateRunResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -354,13 +386,13 @@ func newCreateRun() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteExperimentOverrides []func( *cobra.Command, - *ml.DeleteExperiment, + *experiments.DeleteExperimentRequest, ) func newDeleteExperiment() *cobra.Command { cmd := &cobra.Command{} + var deleteExperimentReq experiments.DeleteExperimentRequest - var deleteExperimentReq ml.DeleteExperiment var deleteExperimentJson flags.JsonFlag cmd.Flags().Var(&deleteExperimentJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -396,6 +428,7 @@ func newDeleteExperiment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deleteExperimentJson.Unmarshal(&deleteExperimentReq) @@ -410,13 +443,19 @@ func newDeleteExperiment() *cobra.Command { } } if !cmd.Flags().Changed("json") { - deleteExperimentReq.ExperimentId = args[0] + deleteExperimentReq.ExperimentId = new(args[0]) } - err = w.Experiments.DeleteExperiment(ctx, deleteExperimentReq) + sdkReq, err := experiments.DeleteExperimentRequestToSDK(&deleteExperimentReq) if err != nil { return err } + response, err := w.Experiments.DeleteExperiment(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -438,13 +477,12 @@ func newDeleteExperiment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteLoggedModelOverrides []func( *cobra.Command, - *ml.DeleteLoggedModelRequest, + *sdkexperiments.DeleteLoggedModelRequest, ) func newDeleteLoggedModel() *cobra.Command { cmd := &cobra.Command{} - - var deleteLoggedModelReq ml.DeleteLoggedModelRequest + var deleteLoggedModelReq sdkexperiments.DeleteLoggedModelRequest cmd.Use = "delete-logged-model MODEL_ID" cmd.Short = `Delete a logged model.` @@ -466,13 +504,17 @@ func newDeleteLoggedModel() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteLoggedModelReq.ModelId = args[0] + deleteLoggedModelReq.ModelId = new(args[0]) - err = w.Experiments.DeleteLoggedModel(ctx, deleteLoggedModelReq) + sdkReq := &deleteLoggedModelReq + response, err := w.Experiments.DeleteLoggedModel(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -494,13 +536,12 @@ func newDeleteLoggedModel() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteLoggedModelTagOverrides []func( *cobra.Command, - *ml.DeleteLoggedModelTagRequest, + *sdkexperiments.DeleteLoggedModelTagRequest, ) func newDeleteLoggedModelTag() *cobra.Command { cmd := &cobra.Command{} - - var deleteLoggedModelTagReq ml.DeleteLoggedModelTagRequest + var deleteLoggedModelTagReq sdkexperiments.DeleteLoggedModelTagRequest cmd.Use = "delete-logged-model-tag MODEL_ID TAG_KEY" cmd.Short = `Delete a tag on a logged model.` @@ -523,14 +564,18 @@ func newDeleteLoggedModelTag() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteLoggedModelTagReq.ModelId = args[0] - deleteLoggedModelTagReq.TagKey = args[1] + deleteLoggedModelTagReq.ModelId = new(args[0]) + deleteLoggedModelTagReq.TagKey = new(args[1]) - err = w.Experiments.DeleteLoggedModelTag(ctx, deleteLoggedModelTagReq) + sdkReq := &deleteLoggedModelTagReq + response, err := w.Experiments.DeleteLoggedModelTag(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -552,13 +597,13 @@ func newDeleteLoggedModelTag() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteRunOverrides []func( *cobra.Command, - *ml.DeleteRun, + *experiments.DeleteRunRequest, ) func newDeleteRun() *cobra.Command { cmd := &cobra.Command{} + var deleteRunReq experiments.DeleteRunRequest - var deleteRunReq ml.DeleteRun var deleteRunJson flags.JsonFlag cmd.Flags().Var(&deleteRunJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -592,6 +637,7 @@ func newDeleteRun() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deleteRunJson.Unmarshal(&deleteRunReq) @@ -606,13 +652,19 @@ func newDeleteRun() *cobra.Command { } } if !cmd.Flags().Changed("json") { - deleteRunReq.RunId = args[0] + deleteRunReq.RunId = new(args[0]) } - err = w.Experiments.DeleteRun(ctx, deleteRunReq) + sdkReq, err := experiments.DeleteRunRequestToSDK(&deleteRunReq) + if err != nil { + return err + } + response, err := w.Experiments.DeleteRun(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -634,18 +686,18 @@ func newDeleteRun() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteRunsOverrides []func( *cobra.Command, - *ml.DeleteRuns, + *experiments.DeleteRunsRequest, ) func newDeleteRuns() *cobra.Command { cmd := &cobra.Command{} + var deleteRunsReq experiments.DeleteRunsRequest - var deleteRunsReq ml.DeleteRuns var deleteRunsJson flags.JsonFlag cmd.Flags().Var(&deleteRunsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().IntVar(&deleteRunsReq.MaxRuns, "max-runs", deleteRunsReq.MaxRuns, `An optional positive integer indicating the maximum number of runs to delete.`) + flags.IntPtrVar(cmd.Flags(), &deleteRunsReq.MaxRuns, "max-runs", `An optional positive integer indicating the maximum number of runs to delete.`) cmd.Use = "delete-runs EXPERIMENT_ID MAX_TIMESTAMP_MILLIS" cmd.Short = `Delete runs by creation time.` @@ -681,6 +733,7 @@ func newDeleteRuns() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deleteRunsJson.Unmarshal(&deleteRunsReq) @@ -695,22 +748,31 @@ func newDeleteRuns() *cobra.Command { } } if !cmd.Flags().Changed("json") { - deleteRunsReq.ExperimentId = args[0] + deleteRunsReq.ExperimentId = new(args[0]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &deleteRunsReq.MaxTimestampMillis) + var deleteRunsMaxTimestampMillisArg int64 + _, err = fmt.Sscan(args[1], &deleteRunsMaxTimestampMillisArg) if err != nil { return fmt.Errorf("invalid MAX_TIMESTAMP_MILLIS: %s", args[1]) } - + deleteRunsReq.MaxTimestampMillis = &deleteRunsMaxTimestampMillisArg } - response, err := w.Experiments.DeleteRuns(ctx, deleteRunsReq) + sdkReq, err := experiments.DeleteRunsRequestToSDK(&deleteRunsReq) + if err != nil { + return err + } + response, err := w.Experiments.DeleteRuns(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := experiments.DeleteRunsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -731,13 +793,13 @@ func newDeleteRuns() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteTagOverrides []func( *cobra.Command, - *ml.DeleteTag, + *experiments.DeleteTagRequest, ) func newDeleteTag() *cobra.Command { cmd := &cobra.Command{} + var deleteTagReq experiments.DeleteTagRequest - var deleteTagReq ml.DeleteTag var deleteTagJson flags.JsonFlag cmd.Flags().Var(&deleteTagJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -773,6 +835,7 @@ func newDeleteTag() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deleteTagJson.Unmarshal(&deleteTagReq) @@ -787,16 +850,22 @@ func newDeleteTag() *cobra.Command { } } if !cmd.Flags().Changed("json") { - deleteTagReq.RunId = args[0] + deleteTagReq.RunId = new(args[0]) } if !cmd.Flags().Changed("json") { - deleteTagReq.Key = args[1] + deleteTagReq.Key = new(args[1]) } - err = w.Experiments.DeleteTag(ctx, deleteTagReq) + sdkReq, err := experiments.DeleteTagRequestToSDK(&deleteTagReq) + if err != nil { + return err + } + response, err := w.Experiments.DeleteTag(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -818,13 +887,13 @@ func newDeleteTag() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var finalizeLoggedModelOverrides []func( *cobra.Command, - *ml.FinalizeLoggedModelRequest, + *experiments.FinalizeLoggedModelRequest, ) func newFinalizeLoggedModel() *cobra.Command { cmd := &cobra.Command{} + var finalizeLoggedModelReq experiments.FinalizeLoggedModelRequest - var finalizeLoggedModelReq ml.FinalizeLoggedModelRequest var finalizeLoggedModelJson flags.JsonFlag cmd.Flags().Var(&finalizeLoggedModelJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -860,6 +929,7 @@ func newFinalizeLoggedModel() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := finalizeLoggedModelJson.Unmarshal(&finalizeLoggedModelReq) @@ -873,21 +943,25 @@ func newFinalizeLoggedModel() *cobra.Command { } } } - finalizeLoggedModelReq.ModelId = args[0] + finalizeLoggedModelReq.ModelId = new(args[0]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &finalizeLoggedModelReq.Status) - if err != nil { - return fmt.Errorf("invalid STATUS: %s", args[1]) - } - + finalizeLoggedModelReq.Status = experiments.LoggedModelStatus(args[1]) } - response, err := w.Experiments.FinalizeLoggedModel(ctx, finalizeLoggedModelReq) + sdkReq, err := experiments.FinalizeLoggedModelRequestToSDK(&finalizeLoggedModelReq) + if err != nil { + return err + } + response, err := w.Experiments.FinalizeLoggedModel(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := experiments.FinalizeLoggedModelResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -908,13 +982,12 @@ func newFinalizeLoggedModel() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getByNameOverrides []func( *cobra.Command, - *ml.GetByNameRequest, + *experiments.GetExperimentByNameRequest, ) func newGetByName() *cobra.Command { cmd := &cobra.Command{} - - var getByNameReq ml.GetByNameRequest + var getByNameReq experiments.GetExperimentByNameRequest cmd.Use = "get-by-name EXPERIMENT_NAME" cmd.Short = `Get an experiment by name.` @@ -946,15 +1019,24 @@ func newGetByName() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getByNameReq.ExperimentName = args[0] + getByNameReq.ExperimentName = new(args[0]) - response, err := w.Experiments.GetByName(ctx, getByNameReq) + sdkReq, err := experiments.GetExperimentByNameRequestToSDK(&getByNameReq) + if err != nil { + return err + } + response, err := w.Experiments.GetExperimentByName(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := experiments.GetExperimentByNameResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -975,13 +1057,12 @@ func newGetByName() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getExperimentOverrides []func( *cobra.Command, - *ml.GetExperimentRequest, + *experiments.GetExperimentRequest, ) func newGetExperiment() *cobra.Command { cmd := &cobra.Command{} - - var getExperimentReq ml.GetExperimentRequest + var getExperimentReq experiments.GetExperimentRequest cmd.Use = "get-experiment EXPERIMENT_ID" cmd.Short = `Get an experiment.` @@ -1005,15 +1086,24 @@ func newGetExperiment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getExperimentReq.ExperimentId = args[0] + getExperimentReq.ExperimentId = new(args[0]) - response, err := w.Experiments.GetExperiment(ctx, getExperimentReq) + sdkReq, err := experiments.GetExperimentRequestToSDK(&getExperimentReq) + if err != nil { + return err + } + response, err := w.Experiments.GetExperiment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := experiments.GetExperimentResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1034,27 +1124,27 @@ func newGetExperiment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getHistoryOverrides []func( *cobra.Command, - *ml.GetHistoryRequest, + *experiments.ListMetricHistoryRequest, ) func newGetHistory() *cobra.Command { cmd := &cobra.Command{} + var getHistoryReq experiments.ListMetricHistoryRequest - var getHistoryReq ml.GetHistoryRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var getHistoryLimit int - cmd.Flags().IntVar(&getHistoryReq.MaxResults, "max-results", getHistoryReq.MaxResults, `Maximum number of Metric records to return per paginated request.`) - cmd.Flags().StringVar(&getHistoryReq.RunId, "run-id", getHistoryReq.RunId, `ID of the run from which to fetch metric values.`) - cmd.Flags().StringVar(&getHistoryReq.RunUuid, "run-uuid", getHistoryReq.RunUuid, `[Deprecated, use run_id instead] ID of the run from which to fetch metric values.`) + flags.IntPtrVar(cmd.Flags(), &getHistoryReq.MaxResults, "max-results", `Maximum number of Metric records to return per paginated request.`) + flags.StringPtrVar(cmd.Flags(), &getHistoryReq.RunId, "run-id", `ID of the run from which to fetch metric values.`) + flags.StringPtrVar(cmd.Flags(), &getHistoryReq.RunUuid, "run-uuid", `[Deprecated, use run_id instead] ID of the run from which to fetch metric values.`) // Limit flag for total result capping. cmd.Flags().IntVar(&getHistoryLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&getHistoryReq.PageToken, "page-token", getHistoryReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &getHistoryReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "get-history METRIC_KEY" @@ -1079,18 +1169,22 @@ func newGetHistory() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getHistoryReq.MetricKey = args[0] + getHistoryReq.MetricKey = new(args[0]) - response := w.Experiments.GetHistory(ctx, getHistoryReq) + sdkReq, err := experiments.ListMetricHistoryRequestToSDK(&getHistoryReq) + if err != nil { + return err + } if getHistoryLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", getHistoryLimit) } if getHistoryLimit > 0 { ctx = cmdio.WithLimit(ctx, getHistoryLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Experiments.ListMetricHistoryIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, experiments.MetricFromSDK)) } // Disable completions since they are not applicable. @@ -1111,13 +1205,12 @@ func newGetHistory() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getLoggedModelOverrides []func( *cobra.Command, - *ml.GetLoggedModelRequest, + *sdkexperiments.GetLoggedModelRequest, ) func newGetLoggedModel() *cobra.Command { cmd := &cobra.Command{} - - var getLoggedModelReq ml.GetLoggedModelRequest + var getLoggedModelReq sdkexperiments.GetLoggedModelRequest cmd.Use = "get-logged-model MODEL_ID" cmd.Short = `Get a logged model.` @@ -1139,15 +1232,21 @@ func newGetLoggedModel() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getLoggedModelReq.ModelId = args[0] + getLoggedModelReq.ModelId = new(args[0]) - response, err := w.Experiments.GetLoggedModel(ctx, getLoggedModelReq) + sdkReq := &getLoggedModelReq + response, err := w.Experiments.GetLoggedModel(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := experiments.GetLoggedModelResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1168,13 +1267,12 @@ func newGetLoggedModel() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *ml.GetExperimentPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq ml.GetExperimentPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels EXPERIMENT_ID" cmd.Short = `Get experiment permission levels.` @@ -1198,15 +1296,23 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getPermissionLevelsReq.RequestObjectId = new(args[0]) - getPermissionLevelsReq.ExperimentId = args[0] + getPermissionLevelsReq.RequestObjectType = new("experiments") - response, err := w.Experiments.GetPermissionLevels(ctx, getPermissionLevelsReq) + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1227,13 +1333,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *ml.GetExperimentPermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq ml.GetExperimentPermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions EXPERIMENT_ID" cmd.Short = `Get experiment permissions.` @@ -1258,15 +1363,23 @@ func newGetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getPermissionsReq.ExperimentId = args[0] + getPermissionsReq.RequestObjectId = new(args[0]) - response, err := w.Experiments.GetPermissions(ctx, getPermissionsReq) + getPermissionsReq.RequestObjectType = new("experiments") + + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1287,15 +1400,14 @@ func newGetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getRunOverrides []func( *cobra.Command, - *ml.GetRunRequest, + *experiments.GetRunRequest, ) func newGetRun() *cobra.Command { cmd := &cobra.Command{} + var getRunReq experiments.GetRunRequest - var getRunReq ml.GetRunRequest - - cmd.Flags().StringVar(&getRunReq.RunUuid, "run-uuid", getRunReq.RunUuid, `[Deprecated, use run_id instead] ID of the run to fetch.`) + flags.StringPtrVar(cmd.Flags(), &getRunReq.RunUuid, "run-uuid", `[Deprecated, use run_id instead] ID of the run to fetch.`) cmd.Use = "get-run RUN_ID" cmd.Short = `Get a run.` @@ -1324,15 +1436,24 @@ func newGetRun() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getRunReq.RunId = args[0] + getRunReq.RunId = new(args[0]) - response, err := w.Experiments.GetRun(ctx, getRunReq) + sdkReq, err := experiments.GetRunRequestToSDK(&getRunReq) + if err != nil { + return err + } + response, err := w.Experiments.GetRun(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := experiments.GetRunResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1353,27 +1474,27 @@ func newGetRun() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listArtifactsOverrides []func( *cobra.Command, - *ml.ListArtifactsRequest, + *experiments.ListArtifactsRequest, ) func newListArtifacts() *cobra.Command { cmd := &cobra.Command{} + var listArtifactsReq experiments.ListArtifactsRequest - var listArtifactsReq ml.ListArtifactsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listArtifactsLimit int - cmd.Flags().StringVar(&listArtifactsReq.Path, "path", listArtifactsReq.Path, `Filter artifacts matching this path (a relative path from the root artifact directory).`) - cmd.Flags().StringVar(&listArtifactsReq.RunId, "run-id", listArtifactsReq.RunId, `ID of the run whose artifacts to list.`) - cmd.Flags().StringVar(&listArtifactsReq.RunUuid, "run-uuid", listArtifactsReq.RunUuid, `[Deprecated, use run_id instead] ID of the run whose artifacts to list.`) + flags.StringPtrVar(cmd.Flags(), &listArtifactsReq.Path, "path", `Filter artifacts matching this path (a relative path from the root artifact directory).`) + flags.StringPtrVar(cmd.Flags(), &listArtifactsReq.RunId, "run-id", `ID of the run whose artifacts to list.`) + flags.StringPtrVar(cmd.Flags(), &listArtifactsReq.RunUuid, "run-uuid", `[Deprecated, use run_id instead] ID of the run whose artifacts to list.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listArtifactsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listArtifactsReq.PageToken, "page-token", listArtifactsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listArtifactsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-artifacts" @@ -1400,16 +1521,20 @@ func newListArtifacts() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Experiments.ListArtifacts(ctx, listArtifactsReq) + sdkReq, err := experiments.ListArtifactsRequestToSDK(&listArtifactsReq) + if err != nil { + return err + } if listArtifactsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listArtifactsLimit) } if listArtifactsLimit > 0 { ctx = cmdio.WithLimit(ctx, listArtifactsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Experiments.ListArtifactsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, experiments.FileInfoFromSDK)) } // Disable completions since they are not applicable. @@ -1430,26 +1555,26 @@ func newListArtifacts() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listExperimentsOverrides []func( *cobra.Command, - *ml.ListExperimentsRequest, + *experiments.ListExperimentsRequest, ) func newListExperiments() *cobra.Command { cmd := &cobra.Command{} + var listExperimentsReq experiments.ListExperimentsRequest - var listExperimentsReq ml.ListExperimentsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listExperimentsLimit int - cmd.Flags().Int64Var(&listExperimentsReq.MaxResults, "max-results", listExperimentsReq.MaxResults, `Maximum number of experiments desired.`) - cmd.Flags().Var(&listExperimentsReq.ViewType, "view-type", `Qualifier for type of experiments to be returned. Supported values: [ACTIVE_ONLY, ALL, DELETED_ONLY]`) + flags.Int64PtrVar(cmd.Flags(), &listExperimentsReq.MaxResults, "max-results", `Maximum number of experiments desired.`) + flags.EnumVar(cmd.Flags(), &listExperimentsReq.ViewType, "view-type", `Qualifier for type of experiments to be returned. Supported values: [ACTIVE_ONLY, ALL, DELETED_ONLY]`, "ViewType", "ACTIVE_ONLY", "ALL", "DELETED_ONLY") // Limit flag for total result capping. cmd.Flags().IntVar(&listExperimentsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listExperimentsReq.PageToken, "page-token", listExperimentsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listExperimentsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-experiments" @@ -1471,16 +1596,20 @@ func newListExperiments() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Experiments.ListExperiments(ctx, listExperimentsReq) + sdkReq, err := experiments.ListExperimentsRequestToSDK(&listExperimentsReq) + if err != nil { + return err + } if listExperimentsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listExperimentsLimit) } if listExperimentsLimit > 0 { ctx = cmdio.WithLimit(ctx, listExperimentsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Experiments.ListExperimentsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, experiments.ExperimentFromSDK)) } // Disable completions since they are not applicable. @@ -1501,20 +1630,20 @@ func newListExperiments() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var logBatchOverrides []func( *cobra.Command, - *ml.LogBatch, + *experiments.LogBatchRequest, ) func newLogBatch() *cobra.Command { cmd := &cobra.Command{} + var logBatchReq experiments.LogBatchRequest - var logBatchReq ml.LogBatch var logBatchJson flags.JsonFlag cmd.Flags().Var(&logBatchJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: metrics // TODO: array: params - cmd.Flags().StringVar(&logBatchReq.RunId, "run-id", logBatchReq.RunId, `ID of the run to log under.`) + flags.StringPtrVar(cmd.Flags(), &logBatchReq.RunId, "run-id", `ID of the run to log under.`) // TODO: array: tags cmd.Use = "log-batch" @@ -1578,6 +1707,7 @@ func newLogBatch() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := logBatchJson.Unmarshal(&logBatchReq) @@ -1592,10 +1722,16 @@ func newLogBatch() *cobra.Command { } } - err = w.Experiments.LogBatch(ctx, logBatchReq) + sdkReq, err := experiments.LogBatchRequestToSDK(&logBatchReq) + if err != nil { + return err + } + response, err := w.Experiments.LogBatch(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -1617,13 +1753,13 @@ func newLogBatch() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var logInputsOverrides []func( *cobra.Command, - *ml.LogInputs, + *experiments.LogInputsRequest, ) func newLogInputs() *cobra.Command { cmd := &cobra.Command{} + var logInputsReq experiments.LogInputsRequest - var logInputsReq ml.LogInputs var logInputsJson flags.JsonFlag cmd.Flags().Var(&logInputsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1660,6 +1796,7 @@ func newLogInputs() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := logInputsJson.Unmarshal(&logInputsReq) @@ -1674,13 +1811,19 @@ func newLogInputs() *cobra.Command { } } if !cmd.Flags().Changed("json") { - logInputsReq.RunId = args[0] + logInputsReq.RunId = new(args[0]) } - err = w.Experiments.LogInputs(ctx, logInputsReq) + sdkReq, err := experiments.LogInputsRequestToSDK(&logInputsReq) + if err != nil { + return err + } + response, err := w.Experiments.LogInputs(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -1702,13 +1845,13 @@ func newLogInputs() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var logLoggedModelParamsOverrides []func( *cobra.Command, - *ml.LogLoggedModelParamsRequest, + *experiments.LogLoggedModelParamsRequest, ) func newLogLoggedModelParams() *cobra.Command { cmd := &cobra.Command{} + var logLoggedModelParamsReq experiments.LogLoggedModelParamsRequest - var logLoggedModelParamsReq ml.LogLoggedModelParamsRequest var logLoggedModelParamsJson flags.JsonFlag cmd.Flags().Var(&logLoggedModelParamsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1740,6 +1883,7 @@ func newLogLoggedModelParams() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := logLoggedModelParamsJson.Unmarshal(&logLoggedModelParamsReq) @@ -1753,12 +1897,18 @@ func newLogLoggedModelParams() *cobra.Command { } } } - logLoggedModelParamsReq.ModelId = args[0] + logLoggedModelParamsReq.ModelId = new(args[0]) - err = w.Experiments.LogLoggedModelParams(ctx, logLoggedModelParamsReq) + sdkReq, err := experiments.LogLoggedModelParamsRequestToSDK(&logLoggedModelParamsReq) + if err != nil { + return err + } + response, err := w.Experiments.LogLoggedModelParams(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -1780,23 +1930,23 @@ func newLogLoggedModelParams() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var logMetricOverrides []func( *cobra.Command, - *ml.LogMetric, + *experiments.LogMetricRequest, ) func newLogMetric() *cobra.Command { cmd := &cobra.Command{} + var logMetricReq experiments.LogMetricRequest - var logMetricReq ml.LogMetric var logMetricJson flags.JsonFlag cmd.Flags().Var(&logMetricJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&logMetricReq.DatasetDigest, "dataset-digest", logMetricReq.DatasetDigest, `Dataset digest of the dataset associated with the metric, e.g.`) - cmd.Flags().StringVar(&logMetricReq.DatasetName, "dataset-name", logMetricReq.DatasetName, `The name of the dataset associated with the metric.`) - cmd.Flags().StringVar(&logMetricReq.ModelId, "model-id", logMetricReq.ModelId, `ID of the logged model associated with the metric, if applicable.`) - cmd.Flags().StringVar(&logMetricReq.RunId, "run-id", logMetricReq.RunId, `ID of the run under which to log the metric.`) - cmd.Flags().StringVar(&logMetricReq.RunUuid, "run-uuid", logMetricReq.RunUuid, `[Deprecated, use run_id instead] ID of the run under which to log the metric.`) - cmd.Flags().Int64Var(&logMetricReq.Step, "step", logMetricReq.Step, `Step at which to log the metric.`) + flags.StringPtrVar(cmd.Flags(), &logMetricReq.DatasetDigest, "dataset-digest", `Dataset digest of the dataset associated with the metric, e.g.`) + flags.StringPtrVar(cmd.Flags(), &logMetricReq.DatasetName, "dataset-name", `The name of the dataset associated with the metric.`) + flags.StringPtrVar(cmd.Flags(), &logMetricReq.ModelId, "model-id", `ID of the logged model associated with the metric, if applicable.`) + flags.StringPtrVar(cmd.Flags(), &logMetricReq.RunId, "run-id", `ID of the run under which to log the metric.`) + flags.StringPtrVar(cmd.Flags(), &logMetricReq.RunUuid, "run-uuid", `[Deprecated, use run_id instead] ID of the run under which to log the metric.`) + flags.Int64PtrVar(cmd.Flags(), &logMetricReq.Step, "step", `Step at which to log the metric.`) cmd.Use = "log-metric KEY VALUE TIMESTAMP" cmd.Short = `Log a metric for a run.` @@ -1831,6 +1981,7 @@ func newLogMetric() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := logMetricJson.Unmarshal(&logMetricReq) @@ -1845,27 +1996,35 @@ func newLogMetric() *cobra.Command { } } if !cmd.Flags().Changed("json") { - logMetricReq.Key = args[0] + logMetricReq.Key = new(args[0]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &logMetricReq.Value) + var logMetricValueArg float64 + _, err = fmt.Sscan(args[1], &logMetricValueArg) if err != nil { return fmt.Errorf("invalid VALUE: %s", args[1]) } - + logMetricReq.Value = &logMetricValueArg } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &logMetricReq.Timestamp) + var logMetricTimestampArg int64 + _, err = fmt.Sscan(args[2], &logMetricTimestampArg) if err != nil { return fmt.Errorf("invalid TIMESTAMP: %s", args[2]) } - + logMetricReq.Timestamp = &logMetricTimestampArg } - err = w.Experiments.LogMetric(ctx, logMetricReq) + sdkReq, err := experiments.LogMetricRequestToSDK(&logMetricReq) + if err != nil { + return err + } + response, err := w.Experiments.LogMetric(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -1887,19 +2046,19 @@ func newLogMetric() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var logModelOverrides []func( *cobra.Command, - *ml.LogModel, + *experiments.LogModelRequest, ) func newLogModel() *cobra.Command { cmd := &cobra.Command{} + var logModelReq experiments.LogModelRequest - var logModelReq ml.LogModel var logModelJson flags.JsonFlag cmd.Flags().Var(&logModelJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&logModelReq.ModelJson, "model-json", logModelReq.ModelJson, `MLmodel file in json format.`) - cmd.Flags().StringVar(&logModelReq.RunId, "run-id", logModelReq.RunId, `ID of the run to log under.`) + flags.StringPtrVar(cmd.Flags(), &logModelReq.ModelJson, "model-json", `MLmodel file in json format.`) + flags.StringPtrVar(cmd.Flags(), &logModelReq.RunId, "run-id", `ID of the run to log under.`) cmd.Use = "log-model" cmd.Short = `Log a model.` @@ -1924,6 +2083,7 @@ func newLogModel() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := logModelJson.Unmarshal(&logModelReq) @@ -1938,10 +2098,16 @@ func newLogModel() *cobra.Command { } } - err = w.Experiments.LogModel(ctx, logModelReq) + sdkReq, err := experiments.LogModelRequestToSDK(&logModelReq) + if err != nil { + return err + } + response, err := w.Experiments.LogModel(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -1963,13 +2129,13 @@ func newLogModel() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var logOutputsOverrides []func( *cobra.Command, - *ml.LogOutputsRequest, + *experiments.LogOutputsRequest, ) func newLogOutputs() *cobra.Command { cmd := &cobra.Command{} + var logOutputsReq experiments.LogOutputsRequest - var logOutputsReq ml.LogOutputsRequest var logOutputsJson flags.JsonFlag cmd.Flags().Var(&logOutputsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2005,6 +2171,7 @@ func newLogOutputs() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := logOutputsJson.Unmarshal(&logOutputsReq) @@ -2019,13 +2186,19 @@ func newLogOutputs() *cobra.Command { } } if !cmd.Flags().Changed("json") { - logOutputsReq.RunId = args[0] + logOutputsReq.RunId = new(args[0]) } - err = w.Experiments.LogOutputs(ctx, logOutputsReq) + sdkReq, err := experiments.LogOutputsRequestToSDK(&logOutputsReq) + if err != nil { + return err + } + response, err := w.Experiments.LogOutputs(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -2047,19 +2220,19 @@ func newLogOutputs() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var logParamOverrides []func( *cobra.Command, - *ml.LogParam, + *experiments.LogParamRequest, ) func newLogParam() *cobra.Command { cmd := &cobra.Command{} + var logParamReq experiments.LogParamRequest - var logParamReq ml.LogParam var logParamJson flags.JsonFlag cmd.Flags().Var(&logParamJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&logParamReq.RunId, "run-id", logParamReq.RunId, `ID of the run under which to log the param.`) - cmd.Flags().StringVar(&logParamReq.RunUuid, "run-uuid", logParamReq.RunUuid, `[Deprecated, use run_id instead] ID of the run under which to log the param.`) + flags.StringPtrVar(cmd.Flags(), &logParamReq.RunId, "run-id", `ID of the run under which to log the param.`) + flags.StringPtrVar(cmd.Flags(), &logParamReq.RunUuid, "run-uuid", `[Deprecated, use run_id instead] ID of the run under which to log the param.`) cmd.Use = "log-param KEY VALUE" cmd.Short = `Log a param for a run.` @@ -2094,6 +2267,7 @@ func newLogParam() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := logParamJson.Unmarshal(&logParamReq) @@ -2108,16 +2282,22 @@ func newLogParam() *cobra.Command { } } if !cmd.Flags().Changed("json") { - logParamReq.Key = args[0] + logParamReq.Key = new(args[0]) } if !cmd.Flags().Changed("json") { - logParamReq.Value = args[1] + logParamReq.Value = new(args[1]) } - err = w.Experiments.LogParam(ctx, logParamReq) + sdkReq, err := experiments.LogParamRequestToSDK(&logParamReq) + if err != nil { + return err + } + response, err := w.Experiments.LogParam(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -2139,13 +2319,13 @@ func newLogParam() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var restoreExperimentOverrides []func( *cobra.Command, - *ml.RestoreExperiment, + *experiments.RestoreExperimentRequest, ) func newRestoreExperiment() *cobra.Command { cmd := &cobra.Command{} + var restoreExperimentReq experiments.RestoreExperimentRequest - var restoreExperimentReq ml.RestoreExperiment var restoreExperimentJson flags.JsonFlag cmd.Flags().Var(&restoreExperimentJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2184,6 +2364,7 @@ func newRestoreExperiment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := restoreExperimentJson.Unmarshal(&restoreExperimentReq) @@ -2198,13 +2379,19 @@ func newRestoreExperiment() *cobra.Command { } } if !cmd.Flags().Changed("json") { - restoreExperimentReq.ExperimentId = args[0] + restoreExperimentReq.ExperimentId = new(args[0]) } - err = w.Experiments.RestoreExperiment(ctx, restoreExperimentReq) + sdkReq, err := experiments.RestoreExperimentRequestToSDK(&restoreExperimentReq) + if err != nil { + return err + } + response, err := w.Experiments.RestoreExperiment(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -2226,13 +2413,13 @@ func newRestoreExperiment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var restoreRunOverrides []func( *cobra.Command, - *ml.RestoreRun, + *experiments.RestoreRunRequest, ) func newRestoreRun() *cobra.Command { cmd := &cobra.Command{} + var restoreRunReq experiments.RestoreRunRequest - var restoreRunReq ml.RestoreRun var restoreRunJson flags.JsonFlag cmd.Flags().Var(&restoreRunJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2270,6 +2457,7 @@ func newRestoreRun() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := restoreRunJson.Unmarshal(&restoreRunReq) @@ -2284,13 +2472,19 @@ func newRestoreRun() *cobra.Command { } } if !cmd.Flags().Changed("json") { - restoreRunReq.RunId = args[0] + restoreRunReq.RunId = new(args[0]) } - err = w.Experiments.RestoreRun(ctx, restoreRunReq) + sdkReq, err := experiments.RestoreRunRequestToSDK(&restoreRunReq) + if err != nil { + return err + } + response, err := w.Experiments.RestoreRun(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -2312,18 +2506,18 @@ func newRestoreRun() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var restoreRunsOverrides []func( *cobra.Command, - *ml.RestoreRuns, + *experiments.RestoreRunsRequest, ) func newRestoreRuns() *cobra.Command { cmd := &cobra.Command{} + var restoreRunsReq experiments.RestoreRunsRequest - var restoreRunsReq ml.RestoreRuns var restoreRunsJson flags.JsonFlag cmd.Flags().Var(&restoreRunsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().IntVar(&restoreRunsReq.MaxRuns, "max-runs", restoreRunsReq.MaxRuns, `An optional positive integer indicating the maximum number of runs to restore.`) + flags.IntPtrVar(cmd.Flags(), &restoreRunsReq.MaxRuns, "max-runs", `An optional positive integer indicating the maximum number of runs to restore.`) cmd.Use = "restore-runs EXPERIMENT_ID MIN_TIMESTAMP_MILLIS" cmd.Short = `Restore runs by deletion time.` @@ -2359,6 +2553,7 @@ func newRestoreRuns() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := restoreRunsJson.Unmarshal(&restoreRunsReq) @@ -2373,22 +2568,31 @@ func newRestoreRuns() *cobra.Command { } } if !cmd.Flags().Changed("json") { - restoreRunsReq.ExperimentId = args[0] + restoreRunsReq.ExperimentId = new(args[0]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &restoreRunsReq.MinTimestampMillis) + var restoreRunsMinTimestampMillisArg int64 + _, err = fmt.Sscan(args[1], &restoreRunsMinTimestampMillisArg) if err != nil { return fmt.Errorf("invalid MIN_TIMESTAMP_MILLIS: %s", args[1]) } - + restoreRunsReq.MinTimestampMillis = &restoreRunsMinTimestampMillisArg } - response, err := w.Experiments.RestoreRuns(ctx, restoreRunsReq) + sdkReq, err := experiments.RestoreRunsRequestToSDK(&restoreRunsReq) + if err != nil { + return err + } + response, err := w.Experiments.RestoreRuns(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := experiments.RestoreRunsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2409,13 +2613,13 @@ func newRestoreRuns() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var searchExperimentsOverrides []func( *cobra.Command, - *ml.SearchExperiments, + *experiments.SearchExperimentsRequest, ) func newSearchExperiments() *cobra.Command { cmd := &cobra.Command{} + var searchExperimentsReq experiments.SearchExperimentsRequest - var searchExperimentsReq ml.SearchExperiments var searchExperimentsJson flags.JsonFlag // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO @@ -2424,16 +2628,16 @@ func newSearchExperiments() *cobra.Command { cmd.Flags().Var(&searchExperimentsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&searchExperimentsReq.Filter, "filter", searchExperimentsReq.Filter, `String representing a SQL filter condition (e.g.`) - cmd.Flags().Int64Var(&searchExperimentsReq.MaxResults, "max-results", searchExperimentsReq.MaxResults, `Maximum number of experiments desired.`) + flags.StringPtrVar(cmd.Flags(), &searchExperimentsReq.Filter, "filter", `String representing a SQL filter condition (e.g.`) + flags.Int64PtrVar(cmd.Flags(), &searchExperimentsReq.MaxResults, "max-results", `Maximum number of experiments desired.`) // TODO: array: order_by - cmd.Flags().Var(&searchExperimentsReq.ViewType, "view-type", `Qualifier for type of experiments to be returned. Supported values: [ACTIVE_ONLY, ALL, DELETED_ONLY]`) + flags.EnumVar(cmd.Flags(), &searchExperimentsReq.ViewType, "view-type", `Qualifier for type of experiments to be returned. Supported values: [ACTIVE_ONLY, ALL, DELETED_ONLY]`, "ViewType", "ACTIVE_ONLY", "ALL", "DELETED_ONLY") // Limit flag for total result capping. cmd.Flags().IntVar(&searchExperimentsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&searchExperimentsReq.PageToken, "page-token", searchExperimentsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &searchExperimentsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "search-experiments" @@ -2455,6 +2659,7 @@ func newSearchExperiments() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := searchExperimentsJson.Unmarshal(&searchExperimentsReq) @@ -2469,15 +2674,18 @@ func newSearchExperiments() *cobra.Command { } } - response := w.Experiments.SearchExperiments(ctx, searchExperimentsReq) + sdkReq, err := experiments.SearchExperimentsRequestToSDK(&searchExperimentsReq) + if err != nil { + return err + } if searchExperimentsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", searchExperimentsLimit) } if searchExperimentsLimit > 0 { ctx = cmdio.WithLimit(ctx, searchExperimentsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Experiments.SearchExperimentsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, experiments.ExperimentFromSDK)) } // Disable completions since they are not applicable. @@ -2498,23 +2706,23 @@ func newSearchExperiments() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var searchLoggedModelsOverrides []func( *cobra.Command, - *ml.SearchLoggedModelsRequest, + *experiments.SearchLoggedModelsRequest, ) func newSearchLoggedModels() *cobra.Command { cmd := &cobra.Command{} + var searchLoggedModelsReq experiments.SearchLoggedModelsRequest - var searchLoggedModelsReq ml.SearchLoggedModelsRequest var searchLoggedModelsJson flags.JsonFlag cmd.Flags().Var(&searchLoggedModelsJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: datasets // TODO: array: experiment_ids - cmd.Flags().StringVar(&searchLoggedModelsReq.Filter, "filter", searchLoggedModelsReq.Filter, `A filter expression over logged model info and data that allows returning a subset of logged models.`) - cmd.Flags().IntVar(&searchLoggedModelsReq.MaxResults, "max-results", searchLoggedModelsReq.MaxResults, `The maximum number of Logged Models to return.`) + flags.StringPtrVar(cmd.Flags(), &searchLoggedModelsReq.Filter, "filter", `A filter expression over logged model info and data that allows returning a subset of logged models.`) + flags.IntPtrVar(cmd.Flags(), &searchLoggedModelsReq.MaxResults, "max-results", `The maximum number of Logged Models to return.`) // TODO: array: order_by - cmd.Flags().StringVar(&searchLoggedModelsReq.PageToken, "page-token", searchLoggedModelsReq.PageToken, `The token indicating the page of logged models to fetch.`) + flags.StringPtrVar(cmd.Flags(), &searchLoggedModelsReq.PageToken, "page-token", `The token indicating the page of logged models to fetch.`) cmd.Use = "search-logged-models" cmd.Short = `Search logged models.` @@ -2535,6 +2743,7 @@ func newSearchLoggedModels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := searchLoggedModelsJson.Unmarshal(&searchLoggedModelsReq) @@ -2549,12 +2758,20 @@ func newSearchLoggedModels() *cobra.Command { } } - response, err := w.Experiments.SearchLoggedModels(ctx, searchLoggedModelsReq) + sdkReq, err := experiments.SearchLoggedModelsRequestToSDK(&searchLoggedModelsReq) + if err != nil { + return err + } + response, err := w.Experiments.SearchLoggedModels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := experiments.SearchLoggedModelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2575,13 +2792,13 @@ func newSearchLoggedModels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var searchRunsOverrides []func( *cobra.Command, - *ml.SearchRuns, + *experiments.SearchRunsRequest, ) func newSearchRuns() *cobra.Command { cmd := &cobra.Command{} + var searchRunsReq experiments.SearchRunsRequest - var searchRunsReq ml.SearchRuns var searchRunsJson flags.JsonFlag // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO @@ -2591,16 +2808,16 @@ func newSearchRuns() *cobra.Command { cmd.Flags().Var(&searchRunsJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: experiment_ids - cmd.Flags().StringVar(&searchRunsReq.Filter, "filter", searchRunsReq.Filter, `A filter expression over params, metrics, and tags, that allows returning a subset of runs.`) - cmd.Flags().IntVar(&searchRunsReq.MaxResults, "max-results", searchRunsReq.MaxResults, `Maximum number of runs desired.`) + flags.StringPtrVar(cmd.Flags(), &searchRunsReq.Filter, "filter", `A filter expression over params, metrics, and tags, that allows returning a subset of runs.`) + flags.IntPtrVar(cmd.Flags(), &searchRunsReq.MaxResults, "max-results", `Maximum number of runs desired.`) // TODO: array: order_by - cmd.Flags().Var(&searchRunsReq.RunViewType, "run-view-type", `Whether to display only active, only deleted, or all runs. Supported values: [ACTIVE_ONLY, ALL, DELETED_ONLY]`) + flags.EnumVar(cmd.Flags(), &searchRunsReq.RunViewType, "run-view-type", `Whether to display only active, only deleted, or all runs. Supported values: [ACTIVE_ONLY, ALL, DELETED_ONLY]`, "ViewType", "ACTIVE_ONLY", "ALL", "DELETED_ONLY") // Limit flag for total result capping. cmd.Flags().IntVar(&searchRunsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&searchRunsReq.PageToken, "page-token", searchRunsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &searchRunsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "search-runs" @@ -2624,6 +2841,7 @@ func newSearchRuns() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := searchRunsJson.Unmarshal(&searchRunsReq) @@ -2638,15 +2856,18 @@ func newSearchRuns() *cobra.Command { } } - response := w.Experiments.SearchRuns(ctx, searchRunsReq) + sdkReq, err := experiments.SearchRunsRequestToSDK(&searchRunsReq) + if err != nil { + return err + } if searchRunsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", searchRunsLimit) } if searchRunsLimit > 0 { ctx = cmdio.WithLimit(ctx, searchRunsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Experiments.SearchRunsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, experiments.RunFromSDK)) } // Disable completions since they are not applicable. @@ -2667,13 +2888,13 @@ func newSearchRuns() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setExperimentTagOverrides []func( *cobra.Command, - *ml.SetExperimentTag, + *experiments.SetExperimentTagRequest, ) func newSetExperimentTag() *cobra.Command { cmd := &cobra.Command{} + var setExperimentTagReq experiments.SetExperimentTagRequest - var setExperimentTagReq ml.SetExperimentTag var setExperimentTagJson flags.JsonFlag cmd.Flags().Var(&setExperimentTagJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2710,6 +2931,7 @@ func newSetExperimentTag() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setExperimentTagJson.Unmarshal(&setExperimentTagReq) @@ -2724,19 +2946,25 @@ func newSetExperimentTag() *cobra.Command { } } if !cmd.Flags().Changed("json") { - setExperimentTagReq.ExperimentId = args[0] + setExperimentTagReq.ExperimentId = new(args[0]) } if !cmd.Flags().Changed("json") { - setExperimentTagReq.Key = args[1] + setExperimentTagReq.Key = new(args[1]) } if !cmd.Flags().Changed("json") { - setExperimentTagReq.Value = args[2] + setExperimentTagReq.Value = new(args[2]) } - err = w.Experiments.SetExperimentTag(ctx, setExperimentTagReq) + sdkReq, err := experiments.SetExperimentTagRequestToSDK(&setExperimentTagReq) if err != nil { return err } + response, err := w.Experiments.SetExperimentTag(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -2758,13 +2986,13 @@ func newSetExperimentTag() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setLoggedModelTagsOverrides []func( *cobra.Command, - *ml.SetLoggedModelTagsRequest, + *experiments.SetLoggedModelTagsRequest, ) func newSetLoggedModelTags() *cobra.Command { cmd := &cobra.Command{} + var setLoggedModelTagsReq experiments.SetLoggedModelTagsRequest - var setLoggedModelTagsReq ml.SetLoggedModelTagsRequest var setLoggedModelTagsJson flags.JsonFlag cmd.Flags().Var(&setLoggedModelTagsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2791,6 +3019,7 @@ func newSetLoggedModelTags() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setLoggedModelTagsJson.Unmarshal(&setLoggedModelTagsReq) @@ -2804,12 +3033,18 @@ func newSetLoggedModelTags() *cobra.Command { } } } - setLoggedModelTagsReq.ModelId = args[0] + setLoggedModelTagsReq.ModelId = new(args[0]) - err = w.Experiments.SetLoggedModelTags(ctx, setLoggedModelTagsReq) + sdkReq, err := experiments.SetLoggedModelTagsRequestToSDK(&setLoggedModelTagsReq) + if err != nil { + return err + } + response, err := w.Experiments.SetLoggedModelTags(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -2831,13 +3066,13 @@ func newSetLoggedModelTags() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *ml.ExperimentPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq ml.ExperimentPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2868,6 +3103,7 @@ func newSetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -2881,14 +3117,24 @@ func newSetPermissions() *cobra.Command { } } } - setPermissionsReq.ExperimentId = args[0] + setPermissionsReq.RequestObjectId = new(args[0]) + + setPermissionsReq.RequestObjectType = new("experiments") - response, err := w.Experiments.SetPermissions(ctx, setPermissionsReq) + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2909,19 +3155,19 @@ func newSetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setTagOverrides []func( *cobra.Command, - *ml.SetTag, + *experiments.SetTagRequest, ) func newSetTag() *cobra.Command { cmd := &cobra.Command{} + var setTagReq experiments.SetTagRequest - var setTagReq ml.SetTag var setTagJson flags.JsonFlag cmd.Flags().Var(&setTagJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&setTagReq.RunId, "run-id", setTagReq.RunId, `ID of the run under which to log the tag.`) - cmd.Flags().StringVar(&setTagReq.RunUuid, "run-uuid", setTagReq.RunUuid, `[Deprecated, use run_id instead] ID of the run under which to log the tag.`) + flags.StringPtrVar(cmd.Flags(), &setTagReq.RunId, "run-id", `ID of the run under which to log the tag.`) + flags.StringPtrVar(cmd.Flags(), &setTagReq.RunUuid, "run-uuid", `[Deprecated, use run_id instead] ID of the run under which to log the tag.`) cmd.Use = "set-tag KEY VALUE" cmd.Short = `Set a tag for a run.` @@ -2955,6 +3201,7 @@ func newSetTag() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setTagJson.Unmarshal(&setTagReq) @@ -2969,16 +3216,22 @@ func newSetTag() *cobra.Command { } } if !cmd.Flags().Changed("json") { - setTagReq.Key = args[0] + setTagReq.Key = new(args[0]) } if !cmd.Flags().Changed("json") { - setTagReq.Value = args[1] + setTagReq.Value = new(args[1]) } - err = w.Experiments.SetTag(ctx, setTagReq) + sdkReq, err := experiments.SetTagRequestToSDK(&setTagReq) + if err != nil { + return err + } + response, err := w.Experiments.SetTag(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -3000,18 +3253,18 @@ func newSetTag() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateExperimentOverrides []func( *cobra.Command, - *ml.UpdateExperiment, + *experiments.UpdateExperimentRequest, ) func newUpdateExperiment() *cobra.Command { cmd := &cobra.Command{} + var updateExperimentReq experiments.UpdateExperimentRequest - var updateExperimentReq ml.UpdateExperiment var updateExperimentJson flags.JsonFlag cmd.Flags().Var(&updateExperimentJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateExperimentReq.NewName, "new-name", updateExperimentReq.NewName, `If provided, the experiment's name is changed to the new name.`) + flags.StringPtrVar(cmd.Flags(), &updateExperimentReq.NewName, "new-name", `If provided, the experiment's name is changed to the new name.`) cmd.Use = "update-experiment EXPERIMENT_ID" cmd.Short = `Update an experiment.` @@ -3042,6 +3295,7 @@ func newUpdateExperiment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateExperimentJson.Unmarshal(&updateExperimentReq) @@ -3056,13 +3310,19 @@ func newUpdateExperiment() *cobra.Command { } } if !cmd.Flags().Changed("json") { - updateExperimentReq.ExperimentId = args[0] + updateExperimentReq.ExperimentId = new(args[0]) } - err = w.Experiments.UpdateExperiment(ctx, updateExperimentReq) + sdkReq, err := experiments.UpdateExperimentRequestToSDK(&updateExperimentReq) + if err != nil { + return err + } + response, err := w.Experiments.UpdateExperiment(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -3084,13 +3344,13 @@ func newUpdateExperiment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *ml.ExperimentPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq ml.ExperimentPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -3120,6 +3380,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -3133,14 +3394,24 @@ func newUpdatePermissions() *cobra.Command { } } } - updatePermissionsReq.ExperimentId = args[0] + updatePermissionsReq.RequestObjectId = new(args[0]) + + updatePermissionsReq.RequestObjectType = new("experiments") - response, err := w.Experiments.UpdatePermissions(ctx, updatePermissionsReq) + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -3161,22 +3432,22 @@ func newUpdatePermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateRunOverrides []func( *cobra.Command, - *ml.UpdateRun, + *experiments.UpdateRunRequest, ) func newUpdateRun() *cobra.Command { cmd := &cobra.Command{} + var updateRunReq experiments.UpdateRunRequest - var updateRunReq ml.UpdateRun var updateRunJson flags.JsonFlag cmd.Flags().Var(&updateRunJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Int64Var(&updateRunReq.EndTime, "end-time", updateRunReq.EndTime, `Unix timestamp in milliseconds of when the run ended.`) - cmd.Flags().StringVar(&updateRunReq.RunId, "run-id", updateRunReq.RunId, `ID of the run to update.`) - cmd.Flags().StringVar(&updateRunReq.RunName, "run-name", updateRunReq.RunName, `Updated name of the run.`) - cmd.Flags().StringVar(&updateRunReq.RunUuid, "run-uuid", updateRunReq.RunUuid, `[Deprecated, use run_id instead] ID of the run to update.`) - cmd.Flags().Var(&updateRunReq.Status, "status", `Updated status of the run. Supported values: [FAILED, FINISHED, KILLED, RUNNING, SCHEDULED]`) + flags.Int64PtrVar(cmd.Flags(), &updateRunReq.EndTime, "end-time", `Unix timestamp in milliseconds of when the run ended.`) + flags.StringPtrVar(cmd.Flags(), &updateRunReq.RunId, "run-id", `ID of the run to update.`) + flags.StringPtrVar(cmd.Flags(), &updateRunReq.RunName, "run-name", `Updated name of the run.`) + flags.StringPtrVar(cmd.Flags(), &updateRunReq.RunUuid, "run-uuid", `[Deprecated, use run_id instead] ID of the run to update.`) + flags.EnumVar(cmd.Flags(), &updateRunReq.Status, "status", `Updated status of the run. Supported values: [FAILED, FINISHED, KILLED, RUNNING, SCHEDULED]`, "UpdateRunStatus", "FAILED", "FINISHED", "KILLED", "RUNNING", "SCHEDULED") cmd.Use = "update-run" cmd.Short = `Update a run.` @@ -3197,6 +3468,7 @@ func newUpdateRun() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateRunJson.Unmarshal(&updateRunReq) @@ -3211,12 +3483,20 @@ func newUpdateRun() *cobra.Command { } } - response, err := w.Experiments.UpdateRun(ctx, updateRunReq) + sdkReq, err := experiments.UpdateRunRequestToSDK(&updateRunReq) + if err != nil { + return err + } + response, err := w.Experiments.UpdateRun(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := experiments.UpdateRunResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/external-lineage/external-lineage.go b/cmd/workspace/external-lineage/external-lineage.go index 7d6cec7c938..33dd7f225f1 100644 --- a/cmd/workspace/external-lineage/external-lineage.go +++ b/cmd/workspace/external-lineage/external-lineage.go @@ -8,10 +8,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucexternallineage "github.com/databricks/cli/libs/sdktypes/uc/externallineage/v1" ) // Slice with functions to override default command behavior. @@ -59,14 +61,14 @@ External Lineage APIs enable defining and managing lineage relationships // Functions can be added from the `init()` function in manually curated files in this directory. var createExternalLineageRelationshipOverrides []func( *cobra.Command, - *catalog.CreateExternalLineageRelationshipRequest, + *ucexternallineage.CreateExternalLineageRelationshipRequest, ) func newCreateExternalLineageRelationship() *cobra.Command { cmd := &cobra.Command{} + var createExternalLineageRelationshipReq ucexternallineage.CreateExternalLineageRelationshipRequest + createExternalLineageRelationshipReq.ExternalLineageRelationship = &ucexternallineage.CreateRequestExternalLineage{} - var createExternalLineageRelationshipReq catalog.CreateExternalLineageRelationshipRequest - createExternalLineageRelationshipReq.ExternalLineageRelationship = catalog.CreateRequestExternalLineage{} var createExternalLineageRelationshipJson flags.JsonFlag cmd.Flags().Var(&createExternalLineageRelationshipJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -107,6 +109,7 @@ Create an external lineage relationship. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createExternalLineageRelationshipJson.Unmarshal(&createExternalLineageRelationshipReq.ExternalLineageRelationship) @@ -121,26 +124,26 @@ Create an external lineage relationship. } } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[0], &createExternalLineageRelationshipReq.ExternalLineageRelationship.Source) - if err != nil { - return fmt.Errorf("invalid SOURCE: %s", args[0]) - } - + _ = args[0] // TODO: complex arg: source } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createExternalLineageRelationshipReq.ExternalLineageRelationship.Target) - if err != nil { - return fmt.Errorf("invalid TARGET: %s", args[1]) - } - + _ = args[1] // TODO: complex arg: target } - response, err := w.ExternalLineage.CreateExternalLineageRelationship(ctx, createExternalLineageRelationshipReq) + sdkReq, err := ucexternallineage.CreateExternalLineageRelationshipRequestToSDK(&createExternalLineageRelationshipReq) + if err != nil { + return err + } + response, err := w.ExternalLineage.CreateExternalLineageRelationship(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucexternallineage.ExternalLineageRelationshipFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -161,13 +164,13 @@ Create an external lineage relationship. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteExternalLineageRelationshipOverrides []func( *cobra.Command, - *catalog.DeleteExternalLineageRelationshipRequest, + *ucexternallineage.DeleteExternalLineageRelationshipRequest, ) func newDeleteExternalLineageRelationship() *cobra.Command { cmd := &cobra.Command{} + var deleteExternalLineageRelationshipReq ucexternallineage.DeleteExternalLineageRelationshipRequest - var deleteExternalLineageRelationshipReq catalog.DeleteExternalLineageRelationshipRequest var deleteExternalLineageRelationshipJson flags.JsonFlag cmd.Flags().Var(&deleteExternalLineageRelationshipJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -189,6 +192,7 @@ Delete an external lineage relationship. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deleteExternalLineageRelationshipJson.Unmarshal(&deleteExternalLineageRelationshipReq) @@ -205,7 +209,11 @@ Delete an external lineage relationship. return errors.New("please provide command input in JSON format by specifying the --json flag") } - err = w.ExternalLineage.DeleteExternalLineageRelationship(ctx, deleteExternalLineageRelationshipReq) + sdkReq, err := ucexternallineage.DeleteExternalLineageRelationshipRequestToSDK(&deleteExternalLineageRelationshipReq) + if err != nil { + return err + } + err = w.ExternalLineage.DeleteExternalLineageRelationship(ctx, *sdkReq) if err != nil { return err } @@ -230,13 +238,13 @@ Delete an external lineage relationship. // Functions can be added from the `init()` function in manually curated files in this directory. var listExternalLineageRelationshipsOverrides []func( *cobra.Command, - *catalog.ListExternalLineageRelationshipsRequest, + *ucexternallineage.ListExternalLineageRelationshipsRequest, ) func newListExternalLineageRelationships() *cobra.Command { cmd := &cobra.Command{} + var listExternalLineageRelationshipsReq ucexternallineage.ListExternalLineageRelationshipsRequest - var listExternalLineageRelationshipsReq catalog.ListExternalLineageRelationshipsRequest var listExternalLineageRelationshipsJson flags.JsonFlag // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO @@ -245,13 +253,13 @@ func newListExternalLineageRelationships() *cobra.Command { cmd.Flags().Var(&listExternalLineageRelationshipsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().IntVar(&listExternalLineageRelationshipsReq.PageSize, "page-size", listExternalLineageRelationshipsReq.PageSize, `Specifies the maximum number of external lineage relationships to return in a single response.`) + flags.IntPtrVar(cmd.Flags(), &listExternalLineageRelationshipsReq.PageSize, "page-size", `Specifies the maximum number of external lineage relationships to return in a single response.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listExternalLineageRelationshipsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listExternalLineageRelationshipsReq.PageToken, "page-token", listExternalLineageRelationshipsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listExternalLineageRelationshipsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-external-lineage-relationships" @@ -271,6 +279,7 @@ List external lineage relationships. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := listExternalLineageRelationshipsJson.Unmarshal(&listExternalLineageRelationshipsReq) @@ -287,15 +296,18 @@ List external lineage relationships. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response := w.ExternalLineage.ListExternalLineageRelationships(ctx, listExternalLineageRelationshipsReq) + sdkReq, err := ucexternallineage.ListExternalLineageRelationshipsRequestToSDK(&listExternalLineageRelationshipsReq) + if err != nil { + return err + } if listExternalLineageRelationshipsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listExternalLineageRelationshipsLimit) } if listExternalLineageRelationshipsLimit > 0 { ctx = cmdio.WithLimit(ctx, listExternalLineageRelationshipsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.ExternalLineage.ListExternalLineageRelationshipsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucexternallineage.ExternalLineageInfoFromSDK)) } // Disable completions since they are not applicable. @@ -316,14 +328,14 @@ List external lineage relationships. // Functions can be added from the `init()` function in manually curated files in this directory. var updateExternalLineageRelationshipOverrides []func( *cobra.Command, - *catalog.UpdateExternalLineageRelationshipRequest, + *ucexternallineage.UpdateExternalLineageRelationshipRequest, ) func newUpdateExternalLineageRelationship() *cobra.Command { cmd := &cobra.Command{} + var updateExternalLineageRelationshipReq ucexternallineage.UpdateExternalLineageRelationshipRequest + updateExternalLineageRelationshipReq.ExternalLineageRelationship = &ucexternallineage.UpdateRequestExternalLineage{} - var updateExternalLineageRelationshipReq catalog.UpdateExternalLineageRelationshipRequest - updateExternalLineageRelationshipReq.ExternalLineageRelationship = catalog.UpdateRequestExternalLineage{} var updateExternalLineageRelationshipJson flags.JsonFlag cmd.Flags().Var(&updateExternalLineageRelationshipJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -375,6 +387,7 @@ Update an external lineage relationship. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateExternalLineageRelationshipJson.Unmarshal(&updateExternalLineageRelationshipReq.ExternalLineageRelationship) @@ -388,28 +401,28 @@ Update an external lineage relationship. } } } - updateExternalLineageRelationshipReq.UpdateMask = args[0] + updateExternalLineageRelationshipReq.UpdateMask = new(args[0]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &updateExternalLineageRelationshipReq.ExternalLineageRelationship.Source) - if err != nil { - return fmt.Errorf("invalid SOURCE: %s", args[1]) - } - + _ = args[1] // TODO: complex arg: source } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &updateExternalLineageRelationshipReq.ExternalLineageRelationship.Target) - if err != nil { - return fmt.Errorf("invalid TARGET: %s", args[2]) - } - + _ = args[2] // TODO: complex arg: target } - response, err := w.ExternalLineage.UpdateExternalLineageRelationship(ctx, updateExternalLineageRelationshipReq) + sdkReq, err := ucexternallineage.UpdateExternalLineageRelationshipRequestToSDK(&updateExternalLineageRelationshipReq) + if err != nil { + return err + } + response, err := w.ExternalLineage.UpdateExternalLineageRelationship(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucexternallineage.ExternalLineageRelationshipFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/external-locations/external-locations.go b/cmd/workspace/external-locations/external-locations.go index edd702cb4ec..d4180e679e0 100644 --- a/cmd/workspace/external-locations/external-locations.go +++ b/cmd/workspace/external-locations/external-locations.go @@ -8,10 +8,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucexternallocations "github.com/databricks/cli/libs/sdktypes/uc/externallocations/v1" ) // Slice with functions to override default command behavior. @@ -64,25 +66,25 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateExternalLocation, + *ucexternallocations.CreateExternalLocationRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq ucexternallocations.CreateExternalLocationRequest - var createReq catalog.CreateExternalLocation 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.Comment, "comment", createReq.Comment, `User-provided free-form text description.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Comment, "comment", `User-provided free-form text description.`) // TODO: complex arg: effective_file_event_queue - cmd.Flags().BoolVar(&createReq.EnableFileEvents, "enable-file-events", createReq.EnableFileEvents, `Whether to enable file events on this external location.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.EnableFileEvents, "enable-file-events", `Whether to enable file events on this external location.`) // TODO: complex arg: encryption_details - cmd.Flags().BoolVar(&createReq.Fallback, "fallback", createReq.Fallback, `Indicates whether fallback mode is enabled for this external location.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.Fallback, "fallback", `Indicates whether fallback mode is enabled for this external location.`) // TODO: complex arg: file_event_queue - cmd.Flags().BoolVar(&createReq.ReadOnly, "read-only", createReq.ReadOnly, `Indicates whether the external location is read-only.`) - cmd.Flags().BoolVar(&createReq.SkipValidation, "skip-validation", createReq.SkipValidation, `Skips validation of the storage credential associated with the external location.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.ReadOnly, "read-only", `Indicates whether the external location is read-only.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.SkipValidation, "skip-validation", `Skips validation of the storage credential associated with the external location.`) cmd.Use = "create NAME URL CREDENTIAL_NAME" cmd.Short = `Create an external location.` @@ -117,6 +119,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -131,21 +134,29 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Name = args[0] + createReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createReq.Url = args[1] + createReq.Url = new(args[1]) } if !cmd.Flags().Changed("json") { - createReq.CredentialName = args[2] + createReq.CredentialName = new(args[2]) } - response, err := w.ExternalLocations.Create(ctx, createReq) + sdkReq, err := ucexternallocations.CreateExternalLocationRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.ExternalLocations.CreateExternalLocation(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucexternallocations.ExternalLocationInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -166,15 +177,14 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteExternalLocationRequest, + *ucexternallocations.DeleteExternalLocationRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq ucexternallocations.DeleteExternalLocationRequest - var deleteReq catalog.DeleteExternalLocationRequest - - cmd.Flags().BoolVar(&deleteReq.Force, "force", deleteReq.Force, `Force deletion even if there are dependent external tables or mounts.`) + flags.BoolPtrVar(cmd.Flags(), &deleteReq.Force, "force", `Force deletion even if there are dependent external tables or mounts.`) cmd.Use = "delete NAME" cmd.Short = `Delete an external location.` @@ -199,13 +209,20 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Name = args[0] + deleteReq.NameArg = new(args[0]) - err = w.ExternalLocations.Delete(ctx, deleteReq) + sdkReq, err := ucexternallocations.DeleteExternalLocationRequestToSDK(&deleteReq) if err != nil { return err } + response, err := w.ExternalLocations.DeleteExternalLocation(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -227,15 +244,14 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetExternalLocationRequest, + *ucexternallocations.GetExternalLocationRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq ucexternallocations.GetExternalLocationRequest - var getReq catalog.GetExternalLocationRequest - - cmd.Flags().BoolVar(&getReq.IncludeBrowse, "include-browse", getReq.IncludeBrowse, `Whether to include external locations in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeBrowse, "include-browse", `Whether to include external locations in the response for which the principal can only access selective metadata for.`) cmd.Use = "get NAME" cmd.Short = `Get an external location.` @@ -261,15 +277,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Name = args[0] + getReq.NameArg = new(args[0]) - response, err := w.ExternalLocations.Get(ctx, getReq) + sdkReq, err := ucexternallocations.GetExternalLocationRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.ExternalLocations.GetExternalLocation(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucexternallocations.ExternalLocationInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -290,28 +315,28 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListExternalLocationsRequest, + *ucexternallocations.ListExternalLocationsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq ucexternallocations.ListExternalLocationsRequest - var listReq catalog.ListExternalLocationsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().BoolVar(&listReq.IncludeBrowse, "include-browse", listReq.IncludeBrowse, `Whether to include external locations in the response for which the principal can only access selective metadata for.`) - cmd.Flags().BoolVar(&listReq.IncludeUnbound, "include-unbound", listReq.IncludeUnbound, `Whether to include external locations not bound to the workspace.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeBrowse, "include-browse", `Whether to include external locations in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeUnbound, "include-unbound", `Whether to include external locations not bound to the workspace.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of external locations to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of external locations to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list" @@ -344,16 +369,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ExternalLocations.List(ctx, listReq) + sdkReq, err := ucexternallocations.ListExternalLocationsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.ExternalLocations.ListExternalLocationsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucexternallocations.ExternalLocationInfoFromSDK)) } // Disable completions since they are not applicable. @@ -374,31 +403,31 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateExternalLocation, + *ucexternallocations.UpdateExternalLocationRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucexternallocations.UpdateExternalLocationRequest - var updateReq catalog.UpdateExternalLocation 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.Comment, "comment", updateReq.Comment, `User-provided free-form text description.`) - cmd.Flags().StringVar(&updateReq.CredentialName, "credential-name", updateReq.CredentialName, `Name of the storage credential used with this location.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Comment, "comment", `User-provided free-form text description.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CredentialName, "credential-name", `Name of the storage credential used with this location.`) // TODO: complex arg: effective_file_event_queue - cmd.Flags().BoolVar(&updateReq.EnableFileEvents, "enable-file-events", updateReq.EnableFileEvents, `Whether to enable file events on this external location.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.EnableFileEvents, "enable-file-events", `Whether to enable file events on this external location.`) // TODO: complex arg: encryption_details - cmd.Flags().BoolVar(&updateReq.Fallback, "fallback", updateReq.Fallback, `Indicates whether fallback mode is enabled for this external location.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Fallback, "fallback", `Indicates whether fallback mode is enabled for this external location.`) // TODO: complex arg: file_event_queue - cmd.Flags().BoolVar(&updateReq.Force, "force", updateReq.Force, `Force update even if changing url invalidates dependent external tables or mounts.`) - cmd.Flags().Var(&updateReq.IsolationMode, "isolation-mode", `Supported values: [ISOLATION_MODE_ISOLATED, ISOLATION_MODE_OPEN]`) - cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the external location.`) - cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `The owner of the external location.`) - cmd.Flags().BoolVar(&updateReq.ReadOnly, "read-only", updateReq.ReadOnly, `Indicates whether the external location is read-only.`) - cmd.Flags().BoolVar(&updateReq.SkipValidation, "skip-validation", updateReq.SkipValidation, `Skips validation of the storage credential associated with the external location.`) - cmd.Flags().StringVar(&updateReq.Url, "url", updateReq.Url, `Path URL of the external location.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Force, "force", `Force update even if changing url invalidates dependent external tables or mounts.`) + flags.EnumVar(cmd.Flags(), &updateReq.IsolationMode, "isolation-mode", `Supported values: [ISOLATION_MODE_ISOLATED, ISOLATION_MODE_OPEN]`, "IsolationMode", "ISOLATION_MODE_ISOLATED", "ISOLATION_MODE_OPEN") + flags.StringPtrVar(cmd.Flags(), &updateReq.NewName, "new-name", `New name for the external location.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `The owner of the external location.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.ReadOnly, "read-only", `Indicates whether the external location is read-only.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.SkipValidation, "skip-validation", `Skips validation of the storage credential associated with the external location.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Url, "url", `Path URL of the external location.`) cmd.Use = "update NAME" cmd.Short = `Update an external location.` @@ -424,6 +453,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -437,14 +467,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.Name = args[0] + updateReq.NameArg = new(args[0]) - response, err := w.ExternalLocations.Update(ctx, updateReq) + sdkReq, err := ucexternallocations.UpdateExternalLocationRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.ExternalLocations.UpdateExternalLocation(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucexternallocations.ExternalLocationInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/external-locations/overrides.go b/cmd/workspace/external-locations/overrides.go index 00b4921d4dc..b08a6685f6e 100644 --- a/cmd/workspace/external-locations/overrides.go +++ b/cmd/workspace/external-locations/overrides.go @@ -2,11 +2,11 @@ package external_locations import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/catalog" + ucexternallocations "github.com/databricks/cli/libs/sdktypes/uc/externallocations/v1" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *catalog.ListExternalLocationsRequest) { +func listOverride(listCmd *cobra.Command, listReq *ucexternallocations.ListExternalLocationsRequest) { listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "Name"}} {{header "Credential"}} {{header "URL"}}`) listCmd.Annotations["template"] = cmdio.Heredoc(` diff --git a/cmd/workspace/external-metadata/external-metadata.go b/cmd/workspace/external-metadata/external-metadata.go index 3d8e7dac3db..fa1e9505066 100644 --- a/cmd/workspace/external-metadata/external-metadata.go +++ b/cmd/workspace/external-metadata/external-metadata.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucexternalmetadata "github.com/databricks/cli/libs/sdktypes/uc/externalmetadata/v1" + sdkucexternalmetadata "github.com/databricks/sdk-go/uc/externalmetadata/v1" ) // Slice with functions to override default command behavior. @@ -60,23 +63,23 @@ External Metadata objects enable customers to register and manage metadata // Functions can be added from the `init()` function in manually curated files in this directory. var createExternalMetadataOverrides []func( *cobra.Command, - *catalog.CreateExternalMetadataRequest, + *ucexternalmetadata.CreateExternalMetadataRequest, ) func newCreateExternalMetadata() *cobra.Command { cmd := &cobra.Command{} + var createExternalMetadataReq ucexternalmetadata.CreateExternalMetadataRequest + createExternalMetadataReq.ExternalMetadata = &ucexternalmetadata.ExternalMetadata{} - var createExternalMetadataReq catalog.CreateExternalMetadataRequest - createExternalMetadataReq.ExternalMetadata = catalog.ExternalMetadata{} var createExternalMetadataJson flags.JsonFlag cmd.Flags().Var(&createExternalMetadataJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: columns - cmd.Flags().StringVar(&createExternalMetadataReq.ExternalMetadata.Description, "description", createExternalMetadataReq.ExternalMetadata.Description, `User-provided free-form text description.`) - cmd.Flags().StringVar(&createExternalMetadataReq.ExternalMetadata.Owner, "owner", createExternalMetadataReq.ExternalMetadata.Owner, `Owner of the external metadata object.`) + flags.StringPtrVar(cmd.Flags(), &createExternalMetadataReq.ExternalMetadata.Description, "description", `User-provided free-form text description.`) + flags.StringPtrVar(cmd.Flags(), &createExternalMetadataReq.ExternalMetadata.Owner, "owner", `Owner of the external metadata object.`) // TODO: map via StringToStringVar: properties - cmd.Flags().StringVar(&createExternalMetadataReq.ExternalMetadata.Url, "url", createExternalMetadataReq.ExternalMetadata.Url, `URL associated with the external metadata object.`) + flags.StringPtrVar(cmd.Flags(), &createExternalMetadataReq.ExternalMetadata.Url, "url", `URL associated with the external metadata object.`) cmd.Use = "create-external-metadata NAME SYSTEM_TYPE ENTITY_TYPE" cmd.Short = `*Public Preview* Create an external metadata object.` @@ -138,6 +141,7 @@ Create an external metadata object. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createExternalMetadataJson.Unmarshal(&createExternalMetadataReq.ExternalMetadata) @@ -152,25 +156,29 @@ Create an external metadata object. } } if !cmd.Flags().Changed("json") { - createExternalMetadataReq.ExternalMetadata.Name = args[0] + createExternalMetadataReq.ExternalMetadata.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createExternalMetadataReq.ExternalMetadata.SystemType) - if err != nil { - return fmt.Errorf("invalid SYSTEM_TYPE: %s", args[1]) - } - + createExternalMetadataReq.ExternalMetadata.SystemType = ucexternalmetadata.SystemType(args[1]) } if !cmd.Flags().Changed("json") { - createExternalMetadataReq.ExternalMetadata.EntityType = args[2] + createExternalMetadataReq.ExternalMetadata.EntityType = new(args[2]) } - response, err := w.ExternalMetadata.CreateExternalMetadata(ctx, createExternalMetadataReq) + sdkReq, err := ucexternalmetadata.CreateExternalMetadataRequestToSDK(&createExternalMetadataReq) + if err != nil { + return err + } + response, err := w.ExternalMetadata.CreateExternalMetadataV2(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucexternalmetadata.ExternalMetadataFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -191,13 +199,12 @@ Create an external metadata object. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteExternalMetadataOverrides []func( *cobra.Command, - *catalog.DeleteExternalMetadataRequest, + *sdkucexternalmetadata.DeleteExternalMetadataRequest, ) func newDeleteExternalMetadata() *cobra.Command { cmd := &cobra.Command{} - - var deleteExternalMetadataReq catalog.DeleteExternalMetadataRequest + var deleteExternalMetadataReq sdkucexternalmetadata.DeleteExternalMetadataRequest cmd.Use = "delete-external-metadata NAME" cmd.Short = `*Public Preview* Delete an external metadata object.` @@ -222,10 +229,12 @@ Delete an external metadata object. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteExternalMetadataReq.Name = args[0] + deleteExternalMetadataReq.Name = new(args[0]) - err = w.ExternalMetadata.DeleteExternalMetadata(ctx, deleteExternalMetadataReq) + sdkReq := &deleteExternalMetadataReq + err = w.ExternalMetadata.DeleteExternalMetadataV2(ctx, *sdkReq) if err != nil { return err } @@ -250,13 +259,12 @@ Delete an external metadata object. // Functions can be added from the `init()` function in manually curated files in this directory. var getExternalMetadataOverrides []func( *cobra.Command, - *catalog.GetExternalMetadataRequest, + *sdkucexternalmetadata.GetExternalMetadataRequest, ) func newGetExternalMetadata() *cobra.Command { cmd := &cobra.Command{} - - var getExternalMetadataReq catalog.GetExternalMetadataRequest + var getExternalMetadataReq sdkucexternalmetadata.GetExternalMetadataRequest cmd.Use = "get-external-metadata NAME" cmd.Short = `*Public Preview* Get an external metadata object.` @@ -281,15 +289,21 @@ Get an external metadata object. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getExternalMetadataReq.Name = args[0] + getExternalMetadataReq.Name = new(args[0]) - response, err := w.ExternalMetadata.GetExternalMetadata(ctx, getExternalMetadataReq) + sdkReq := &getExternalMetadataReq + response, err := w.ExternalMetadata.GetExternalMetadataV2(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucexternalmetadata.ExternalMetadataFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -310,25 +324,25 @@ Get an external metadata object. // Functions can be added from the `init()` function in manually curated files in this directory. var listExternalMetadataOverrides []func( *cobra.Command, - *catalog.ListExternalMetadataRequest, + *ucexternalmetadata.ListExternalMetadataRequest, ) func newListExternalMetadata() *cobra.Command { cmd := &cobra.Command{} + var listExternalMetadataReq ucexternalmetadata.ListExternalMetadataRequest - var listExternalMetadataReq catalog.ListExternalMetadataRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listExternalMetadataLimit int - cmd.Flags().IntVar(&listExternalMetadataReq.PageSize, "page-size", listExternalMetadataReq.PageSize, `Specifies the maximum number of external metadata objects to return in a single response.`) + flags.IntPtrVar(cmd.Flags(), &listExternalMetadataReq.PageSize, "page-size", `Specifies the maximum number of external metadata objects to return in a single response.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listExternalMetadataLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listExternalMetadataReq.PageToken, "page-token", listExternalMetadataReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listExternalMetadataReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-external-metadata" @@ -356,16 +370,20 @@ List external metadata objects. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ExternalMetadata.ListExternalMetadata(ctx, listExternalMetadataReq) + sdkReq, err := ucexternalmetadata.ListExternalMetadataRequestToSDK(&listExternalMetadataReq) + if err != nil { + return err + } if listExternalMetadataLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listExternalMetadataLimit) } if listExternalMetadataLimit > 0 { ctx = cmdio.WithLimit(ctx, listExternalMetadataLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.ExternalMetadata.ListExternalMetadataV2Iter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucexternalmetadata.ExternalMetadataFromSDK)) } // Disable completions since they are not applicable. @@ -386,23 +404,23 @@ List external metadata objects. // Functions can be added from the `init()` function in manually curated files in this directory. var updateExternalMetadataOverrides []func( *cobra.Command, - *catalog.UpdateExternalMetadataRequest, + *ucexternalmetadata.UpdateExternalMetadataRequest, ) func newUpdateExternalMetadata() *cobra.Command { cmd := &cobra.Command{} + var updateExternalMetadataReq ucexternalmetadata.UpdateExternalMetadataRequest + updateExternalMetadataReq.ExternalMetadata = &ucexternalmetadata.ExternalMetadata{} - var updateExternalMetadataReq catalog.UpdateExternalMetadataRequest - updateExternalMetadataReq.ExternalMetadata = catalog.ExternalMetadata{} var updateExternalMetadataJson flags.JsonFlag cmd.Flags().Var(&updateExternalMetadataJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: columns - cmd.Flags().StringVar(&updateExternalMetadataReq.ExternalMetadata.Description, "description", updateExternalMetadataReq.ExternalMetadata.Description, `User-provided free-form text description.`) - cmd.Flags().StringVar(&updateExternalMetadataReq.ExternalMetadata.Owner, "owner", updateExternalMetadataReq.ExternalMetadata.Owner, `Owner of the external metadata object.`) + flags.StringPtrVar(cmd.Flags(), &updateExternalMetadataReq.ExternalMetadata.Description, "description", `User-provided free-form text description.`) + flags.StringPtrVar(cmd.Flags(), &updateExternalMetadataReq.ExternalMetadata.Owner, "owner", `Owner of the external metadata object.`) // TODO: map via StringToStringVar: properties - cmd.Flags().StringVar(&updateExternalMetadataReq.ExternalMetadata.Url, "url", updateExternalMetadataReq.ExternalMetadata.Url, `URL associated with the external metadata object.`) + flags.StringPtrVar(cmd.Flags(), &updateExternalMetadataReq.ExternalMetadata.Url, "url", `URL associated with the external metadata object.`) cmd.Use = "update-external-metadata NAME UPDATE_MASK SYSTEM_TYPE ENTITY_TYPE" cmd.Short = `*Public Preview* Update an external metadata object.` @@ -477,6 +495,7 @@ Update an external metadata object. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateExternalMetadataJson.Unmarshal(&updateExternalMetadataReq.ExternalMetadata) @@ -490,25 +509,29 @@ Update an external metadata object. } } } - updateExternalMetadataReq.Name = args[0] - updateExternalMetadataReq.UpdateMask = args[1] + updateExternalMetadataReq.ExternalMetadata.Name = new(args[0]) + updateExternalMetadataReq.UpdateMask = new(args[1]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &updateExternalMetadataReq.ExternalMetadata.SystemType) - if err != nil { - return fmt.Errorf("invalid SYSTEM_TYPE: %s", args[2]) - } - + updateExternalMetadataReq.ExternalMetadata.SystemType = ucexternalmetadata.SystemType(args[2]) } if !cmd.Flags().Changed("json") { - updateExternalMetadataReq.ExternalMetadata.EntityType = args[3] + updateExternalMetadataReq.ExternalMetadata.EntityType = new(args[3]) } - response, err := w.ExternalMetadata.UpdateExternalMetadata(ctx, updateExternalMetadataReq) + sdkReq, err := ucexternalmetadata.UpdateExternalMetadataRequestToSDK(&updateExternalMetadataReq) + if err != nil { + return err + } + response, err := w.ExternalMetadata.UpdateExternalMetadataV2(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucexternalmetadata.ExternalMetadataFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/feature-engineering/feature-engineering.go b/cmd/workspace/feature-engineering/feature-engineering.go index 2c689804776..1ae2ad98e76 100644 --- a/cmd/workspace/feature-engineering/feature-engineering.go +++ b/cmd/workspace/feature-engineering/feature-engineering.go @@ -5,17 +5,22 @@ package feature_engineering import ( "errors" "fmt" - "strings" "time" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "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/experimental/api" - "github.com/databricks/databricks-sdk-go/service/ml" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + features "github.com/databricks/cli/libs/sdktypes/features/v1" + sdkfeatures "github.com/databricks/sdk-go/features/v1" ) // Slice with functions to override default command behavior. @@ -78,13 +83,13 @@ Feature Engineering provides APIs for managing features and materialized // Functions can be added from the `init()` function in manually curated files in this directory. var backfillFeaturesOverrides []func( *cobra.Command, - *ml.BackfillFeaturesRequest, + *features.BackfillFeaturesRequest, ) func newBackfillFeatures() *cobra.Command { cmd := &cobra.Command{} + var backfillFeaturesReq features.BackfillFeaturesRequest - var backfillFeaturesReq ml.BackfillFeaturesRequest var backfillFeaturesJson flags.JsonFlag var backfillFeaturesSkipWait bool @@ -95,8 +100,8 @@ func newBackfillFeatures() *cobra.Command { cmd.Flags().Var(&backfillFeaturesJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&backfillFeaturesReq.BudgetPolicyId, "budget-policy-id", backfillFeaturesReq.BudgetPolicyId, `The budget policy ID, in UUID format, used to attribute the serverless compute cost of this backfill.`) - cmd.Flags().StringVar(&backfillFeaturesReq.RequestId, "request-id", backfillFeaturesReq.RequestId, `Idempotency token for the request.`) + flags.StringPtrVar(cmd.Flags(), &backfillFeaturesReq.BudgetPolicyId, "budget-policy-id", `The budget policy ID, in UUID format, used to attribute the serverless compute cost of this backfill.`) + flags.StringPtrVar(cmd.Flags(), &backfillFeaturesReq.RequestId, "request-id", `Idempotency token for the request.`) // TODO: map via StringToStringVar: tags cmd.Use = "backfill-features" @@ -119,6 +124,7 @@ func newBackfillFeatures() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := backfillFeaturesJson.Unmarshal(&backfillFeaturesReq) @@ -135,25 +141,23 @@ func newBackfillFeatures() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } + sdkReq, err := features.BackfillFeaturesRequestToSDK(&backfillFeaturesReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case backfillFeaturesSkipWait: - wait, err := w.FeatureEngineering.BackfillFeatures(ctx, backfillFeaturesReq) + wait, err := w.Features.BackfillFeatures(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.FeatureEngineering.GetOperation(ctx, ml.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.FeatureEngineering.BackfillFeatures(ctx, backfillFeaturesReq) + wait, err := w.Features.BackfillFeatures(ctx, *sdkReq) if err != nil { return err } @@ -163,13 +167,17 @@ func newBackfillFeatures() *cobra.Command { sp.Update("Waiting for backfill-features to complete...") // Wait for completion. - opts := api.WithTimeout(backfillFeaturesTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(backfillFeaturesTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := features.BackfillFeaturesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -191,13 +199,14 @@ func newBackfillFeatures() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var cancelOperationOverrides []func( *cobra.Command, - *ml.CancelOperationRequest, + *map[string]any, ) func newCancelOperation() *cobra.Command { cmd := &cobra.Command{} - - var cancelOperationReq ml.CancelOperationRequest + var cancelOperationReq map[string]any + cancelOperationReq = map[string]any{} + var cancelOperationNameRaw string cmd.Use = "cancel-operation NAME" cmd.Short = `Cancel an operation.` @@ -222,10 +231,18 @@ func newCancelOperation() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + cancelOperationNameRaw = args[0] - cancelOperationReq.Name = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/feature-engineering/%s:cancel", fmt.Sprint(cancelOperationNameRaw)) - err = w.FeatureEngineering.CancelOperation(ctx, cancelOperationReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, cancelOperationReq, nil) if err != nil { return err } @@ -250,21 +267,21 @@ func newCancelOperation() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createFeatureOverrides []func( *cobra.Command, - *ml.CreateFeatureRequest, + *features.CreateFeatureRequest, ) func newCreateFeature() *cobra.Command { cmd := &cobra.Command{} + var createFeatureReq features.CreateFeatureRequest + createFeatureReq.Feature = &features.Feature{} - var createFeatureReq ml.CreateFeatureRequest - createFeatureReq.Feature = ml.Feature{} var createFeatureJson flags.JsonFlag 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.`) + flags.StringPtrVar(cmd.Flags(), &createFeatureReq.Feature.Description, "description", `The description of the feature.`) // TODO: array: entities - cmd.Flags().StringVar(&createFeatureReq.Feature.FilterCondition, "filter-condition", createFeatureReq.Feature.FilterCondition, ``) + flags.StringPtrVar(cmd.Flags(), &createFeatureReq.Feature.FilterCondition, "filter-condition", ``) // TODO: array: inputs // TODO: complex arg: lineage_context // TODO: complex arg: time_window @@ -303,6 +320,7 @@ Create a feature. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createFeatureJson.Unmarshal(&createFeatureReq.Feature) @@ -317,29 +335,29 @@ Create a feature. } } if !cmd.Flags().Changed("json") { - createFeatureReq.Feature.FullName = args[0] + createFeatureReq.Feature.FullName = new(args[0]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createFeatureReq.Feature.Source) - if err != nil { - return fmt.Errorf("invalid SOURCE: %s", args[1]) - } - + _ = args[1] // TODO: complex arg: source } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &createFeatureReq.Feature.Function) - if err != nil { - return fmt.Errorf("invalid FUNCTION: %s", args[2]) - } - + _ = args[2] // TODO: complex arg: function } - response, err := w.FeatureEngineering.CreateFeature(ctx, createFeatureReq) + sdkReq, err := features.CreateFeatureRequestToSDK(&createFeatureReq) + if err != nil { + return err + } + response, err := w.Features.CreateFeature(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := features.FeatureFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -360,14 +378,14 @@ Create a feature. // Functions can be added from the `init()` function in manually curated files in this directory. var createKafkaConfigOverrides []func( *cobra.Command, - *ml.CreateKafkaConfigRequest, + *features.CreateKafkaConfigRequest, ) func newCreateKafkaConfig() *cobra.Command { cmd := &cobra.Command{} + var createKafkaConfigReq features.CreateKafkaConfigRequest + createKafkaConfigReq.KafkaConfig = &features.KafkaConfig{} - var createKafkaConfigReq ml.CreateKafkaConfigRequest - createKafkaConfigReq.KafkaConfig = ml.KafkaConfig{} var createKafkaConfigJson flags.JsonFlag cmd.Flags().Var(&createKafkaConfigJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -417,6 +435,7 @@ func newCreateKafkaConfig() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createKafkaConfigJson.Unmarshal(&createKafkaConfigReq.KafkaConfig) @@ -431,32 +450,32 @@ func newCreateKafkaConfig() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createKafkaConfigReq.KafkaConfig.Name = args[0] + createKafkaConfigReq.KafkaConfig.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createKafkaConfigReq.KafkaConfig.BootstrapServers = args[1] + createKafkaConfigReq.KafkaConfig.BootstrapServers = new(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &createKafkaConfigReq.KafkaConfig.SubscriptionMode) - if err != nil { - return fmt.Errorf("invalid SUBSCRIPTION_MODE: %s", args[2]) - } - + _ = args[2] // TODO: complex arg: subscription_mode } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &createKafkaConfigReq.KafkaConfig.AuthConfig) - if err != nil { - return fmt.Errorf("invalid AUTH_CONFIG: %s", args[3]) - } - + _ = args[3] // TODO: complex arg: auth_config } - response, err := w.FeatureEngineering.CreateKafkaConfig(ctx, createKafkaConfigReq) + sdkReq, err := features.CreateKafkaConfigRequestToSDK(&createKafkaConfigReq) + if err != nil { + return err + } + response, err := w.Features.CreateKafkaConfig(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := features.KafkaConfigFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -477,26 +496,26 @@ func newCreateKafkaConfig() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createMaterializedFeatureOverrides []func( *cobra.Command, - *ml.CreateMaterializedFeatureRequest, + *features.CreateMaterializedFeatureRequest, ) func newCreateMaterializedFeature() *cobra.Command { cmd := &cobra.Command{} + var createMaterializedFeatureReq features.CreateMaterializedFeatureRequest + createMaterializedFeatureReq.MaterializedFeature = &features.MaterializedFeature{} - var createMaterializedFeatureReq ml.CreateMaterializedFeatureRequest - createMaterializedFeatureReq.MaterializedFeature = ml.MaterializedFeature{} var createMaterializedFeatureJson flags.JsonFlag cmd.Flags().Var(&createMaterializedFeatureJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createMaterializedFeatureReq.MaterializedFeature.BudgetPolicyId, "budget-policy-id", createMaterializedFeatureReq.MaterializedFeature.BudgetPolicyId, `The ID of the budget policy used to attribute the serverless compute cost of this materialization.`) - cmd.Flags().StringVar(&createMaterializedFeatureReq.MaterializedFeature.CronSchedule, "cron-schedule", createMaterializedFeatureReq.MaterializedFeature.CronSchedule, ``) + flags.StringPtrVar(cmd.Flags(), &createMaterializedFeatureReq.MaterializedFeature.BudgetPolicyId, "budget-policy-id", `The ID of the budget policy used to attribute the serverless compute cost of this materialization.`) + flags.StringPtrVar(cmd.Flags(), &createMaterializedFeatureReq.MaterializedFeature.CronSchedule, "cron-schedule", ``) // TODO: complex arg: cron_schedule_trigger - cmd.Flags().StringVar(&createMaterializedFeatureReq.MaterializedFeature.MaterializedFeatureId, "materialized-feature-id", createMaterializedFeatureReq.MaterializedFeature.MaterializedFeatureId, `Server-assigned unique identifier for the materialized feature.`) + flags.StringPtrVar(cmd.Flags(), &createMaterializedFeatureReq.MaterializedFeature.MaterializedFeatureId, "materialized-feature-id", `Server-assigned unique identifier for the materialized feature.`) // TODO: complex arg: notifications // 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]`) + flags.EnumVar(cmd.Flags(), &createMaterializedFeatureReq.MaterializedFeature.PipelineScheduleState, "pipeline-schedule-state", `The schedule state of the materialization pipeline. Supported values: [ACTIVE, PAUSED, SNAPSHOT]`, "MaterializedFeaturePipelineScheduleState", "ACTIVE", "PAUSED", "SNAPSHOT") // TODO: complex arg: streaming_mode // TODO: complex arg: table_trigger // TODO: map via StringToStringVar: tags @@ -530,6 +549,7 @@ Create a materialized feature. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createMaterializedFeatureJson.Unmarshal(&createMaterializedFeatureReq.MaterializedFeature) @@ -544,15 +564,23 @@ Create a materialized feature. } } if !cmd.Flags().Changed("json") { - createMaterializedFeatureReq.MaterializedFeature.FeatureName = args[0] + createMaterializedFeatureReq.MaterializedFeature.FeatureName = new(args[0]) } - response, err := w.FeatureEngineering.CreateMaterializedFeature(ctx, createMaterializedFeatureReq) + sdkReq, err := features.CreateMaterializedFeatureRequestToSDK(&createMaterializedFeatureReq) + if err != nil { + return err + } + response, err := w.Features.CreateMaterializedFeature(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := features.MaterializedFeatureFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -573,21 +601,21 @@ Create a materialized feature. // Functions can be added from the `init()` function in manually curated files in this directory. var createStreamOverrides []func( *cobra.Command, - *ml.CreateStreamRequest, + *features.CreateStreamRequest, ) func newCreateStream() *cobra.Command { cmd := &cobra.Command{} + var createStreamReq features.CreateStreamRequest + createStreamReq.Stream = &features.Stream{} - var createStreamReq ml.CreateStreamRequest - createStreamReq.Stream = ml.Stream{} var createStreamJson flags.JsonFlag cmd.Flags().Var(&createStreamJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createStreamReq.Stream.Description, "description", createStreamReq.Stream.Description, `User-provided description.`) + flags.StringPtrVar(cmd.Flags(), &createStreamReq.Stream.Description, "description", `User-provided description.`) // TODO: array: excluded_columns - cmd.Flags().StringVar(&createStreamReq.Stream.RecordTypeFilter, "record-type-filter", createStreamReq.Stream.RecordTypeFilter, `Optional SQL predicate to filter which record types from a streaming channel (e.g.`) + flags.StringPtrVar(cmd.Flags(), &createStreamReq.Stream.RecordTypeFilter, "record-type-filter", `Optional SQL predicate to filter which record types from a streaming channel (e.g.`) cmd.Use = "create-stream NAME SOURCE_CONFIG CONNECTION_CONFIG SCHEMA_CONFIG INGESTION_CONFIG" cmd.Short = `*Public Preview* Create a Stream.` @@ -627,6 +655,7 @@ Create a Stream. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createStreamJson.Unmarshal(&createStreamReq.Stream) @@ -641,43 +670,35 @@ Create a Stream. } } if !cmd.Flags().Changed("json") { - createStreamReq.Stream.Name = args[0] + createStreamReq.Stream.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createStreamReq.Stream.SourceConfig) - if err != nil { - return fmt.Errorf("invalid SOURCE_CONFIG: %s", args[1]) - } - + _ = args[1] // TODO: complex arg: source_config } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &createStreamReq.Stream.ConnectionConfig) - if err != nil { - return fmt.Errorf("invalid CONNECTION_CONFIG: %s", args[2]) - } - + _ = args[2] // TODO: complex arg: connection_config } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &createStreamReq.Stream.SchemaConfig) - if err != nil { - return fmt.Errorf("invalid SCHEMA_CONFIG: %s", args[3]) - } - + _ = args[3] // TODO: complex arg: schema_config } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[4], &createStreamReq.Stream.IngestionConfig) - if err != nil { - return fmt.Errorf("invalid INGESTION_CONFIG: %s", args[4]) - } - + _ = args[4] // TODO: complex arg: ingestion_config } - response, err := w.FeatureEngineering.CreateStream(ctx, createStreamReq) + sdkReq, err := features.CreateStreamRequestToSDK(&createStreamReq) + if err != nil { + return err + } + response, err := w.Features.CreateStream(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := features.StreamFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -698,13 +719,12 @@ Create a Stream. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteFeatureOverrides []func( *cobra.Command, - *ml.DeleteFeatureRequest, + *sdkfeatures.DeleteFeatureRequest, ) func newDeleteFeature() *cobra.Command { cmd := &cobra.Command{} - - var deleteFeatureReq ml.DeleteFeatureRequest + var deleteFeatureReq sdkfeatures.DeleteFeatureRequest cmd.Use = "delete-feature FULL_NAME" cmd.Short = `*Public Preview* Delete a feature.` @@ -730,10 +750,12 @@ Delete a feature. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteFeatureReq.FullName = args[0] + deleteFeatureReq.FullName = new(args[0]) - err = w.FeatureEngineering.DeleteFeature(ctx, deleteFeatureReq) + sdkReq := &deleteFeatureReq + err = w.Features.DeleteFeature(ctx, *sdkReq) if err != nil { return err } @@ -758,13 +780,12 @@ Delete a feature. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteKafkaConfigOverrides []func( *cobra.Command, - *ml.DeleteKafkaConfigRequest, + *sdkfeatures.DeleteKafkaConfigRequest, ) func newDeleteKafkaConfig() *cobra.Command { cmd := &cobra.Command{} - - var deleteKafkaConfigReq ml.DeleteKafkaConfigRequest + var deleteKafkaConfigReq sdkfeatures.DeleteKafkaConfigRequest cmd.Use = "delete-kafka-config NAME" cmd.Short = `Delete a Kafka config.` @@ -793,10 +814,12 @@ func newDeleteKafkaConfig() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteKafkaConfigReq.Name = args[0] + deleteKafkaConfigReq.Name = new(args[0]) - err = w.FeatureEngineering.DeleteKafkaConfig(ctx, deleteKafkaConfigReq) + sdkReq := &deleteKafkaConfigReq + err = w.Features.DeleteKafkaConfig(ctx, *sdkReq) if err != nil { return err } @@ -821,13 +844,12 @@ func newDeleteKafkaConfig() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteMaterializedFeatureOverrides []func( *cobra.Command, - *ml.DeleteMaterializedFeatureRequest, + *sdkfeatures.DeleteMaterializedFeatureRequest, ) func newDeleteMaterializedFeature() *cobra.Command { cmd := &cobra.Command{} - - var deleteMaterializedFeatureReq ml.DeleteMaterializedFeatureRequest + var deleteMaterializedFeatureReq sdkfeatures.DeleteMaterializedFeatureRequest cmd.Use = "delete-materialized-feature MATERIALIZED_FEATURE_ID" cmd.Short = `*Public Preview* Delete a materialized feature.` @@ -851,10 +873,12 @@ Delete a materialized feature. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteMaterializedFeatureReq.MaterializedFeatureId = args[0] + deleteMaterializedFeatureReq.MaterializedFeatureId = new(args[0]) - err = w.FeatureEngineering.DeleteMaterializedFeature(ctx, deleteMaterializedFeatureReq) + sdkReq := &deleteMaterializedFeatureReq + err = w.Features.DeleteMaterializedFeature(ctx, *sdkReq) if err != nil { return err } @@ -879,13 +903,12 @@ Delete a materialized feature. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteStreamOverrides []func( *cobra.Command, - *ml.DeleteStreamRequest, + *sdkfeatures.DeleteStreamRequest, ) func newDeleteStream() *cobra.Command { cmd := &cobra.Command{} - - var deleteStreamReq ml.DeleteStreamRequest + var deleteStreamReq sdkfeatures.DeleteStreamRequest cmd.Use = "delete-stream NAME" cmd.Short = `*Public Preview* Delete a Stream.` @@ -911,10 +934,12 @@ Delete a Stream. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteStreamReq.Name = args[0] + deleteStreamReq.Name = new(args[0]) - err = w.FeatureEngineering.DeleteStream(ctx, deleteStreamReq) + sdkReq := &deleteStreamReq + err = w.Features.DeleteStream(ctx, *sdkReq) if err != nil { return err } @@ -939,13 +964,12 @@ Delete a Stream. // Functions can be added from the `init()` function in manually curated files in this directory. var getFeatureOverrides []func( *cobra.Command, - *ml.GetFeatureRequest, + *sdkfeatures.GetFeatureRequest, ) func newGetFeature() *cobra.Command { cmd := &cobra.Command{} - - var getFeatureReq ml.GetFeatureRequest + var getFeatureReq sdkfeatures.GetFeatureRequest cmd.Use = "get-feature FULL_NAME" cmd.Short = `*Public Preview* Get a feature.` @@ -971,15 +995,21 @@ Get a feature. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getFeatureReq.FullName = args[0] + getFeatureReq.FullName = new(args[0]) - response, err := w.FeatureEngineering.GetFeature(ctx, getFeatureReq) + sdkReq := &getFeatureReq + response, err := w.Features.GetFeature(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := features.FeatureFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1000,13 +1030,12 @@ Get a feature. // Functions can be added from the `init()` function in manually curated files in this directory. var getKafkaConfigOverrides []func( *cobra.Command, - *ml.GetKafkaConfigRequest, + *sdkfeatures.GetKafkaConfigRequest, ) func newGetKafkaConfig() *cobra.Command { cmd := &cobra.Command{} - - var getKafkaConfigReq ml.GetKafkaConfigRequest + var getKafkaConfigReq sdkfeatures.GetKafkaConfigRequest cmd.Use = "get-kafka-config NAME" cmd.Short = `Get a Kafka config.` @@ -1035,15 +1064,21 @@ func newGetKafkaConfig() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getKafkaConfigReq.Name = args[0] + getKafkaConfigReq.Name = new(args[0]) - response, err := w.FeatureEngineering.GetKafkaConfig(ctx, getKafkaConfigReq) + sdkReq := &getKafkaConfigReq + response, err := w.Features.GetKafkaConfig(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := features.KafkaConfigFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1064,13 +1099,12 @@ func newGetKafkaConfig() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getMaterializedFeatureOverrides []func( *cobra.Command, - *ml.GetMaterializedFeatureRequest, + *sdkfeatures.GetMaterializedFeatureRequest, ) func newGetMaterializedFeature() *cobra.Command { cmd := &cobra.Command{} - - var getMaterializedFeatureReq ml.GetMaterializedFeatureRequest + var getMaterializedFeatureReq sdkfeatures.GetMaterializedFeatureRequest cmd.Use = "get-materialized-feature MATERIALIZED_FEATURE_ID" cmd.Short = `*Public Preview* Get a materialized feature.` @@ -1094,15 +1128,21 @@ Get a materialized feature. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getMaterializedFeatureReq.MaterializedFeatureId = args[0] + getMaterializedFeatureReq.MaterializedFeatureId = new(args[0]) - response, err := w.FeatureEngineering.GetMaterializedFeature(ctx, getMaterializedFeatureReq) + sdkReq := &getMaterializedFeatureReq + response, err := w.Features.GetMaterializedFeature(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := features.MaterializedFeatureFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1123,13 +1163,14 @@ Get a materialized feature. // Functions can be added from the `init()` function in manually curated files in this directory. var getOperationOverrides []func( *cobra.Command, - *ml.GetOperationRequest, + *map[string]any, ) func newGetOperation() *cobra.Command { cmd := &cobra.Command{} - - var getOperationReq ml.GetOperationRequest + var getOperationReq map[string]any + getOperationReq = map[string]any{} + var getOperationNameRaw string cmd.Use = "get-operation NAME" cmd.Short = `Get an operation.` @@ -1154,14 +1195,23 @@ func newGetOperation() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getOperationReq.Name = args[0] + getOperationNameRaw = args[0] - response, err := w.FeatureEngineering.GetOperation(ctx, getOperationReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/feature-engineering/%s", fmt.Sprint(getOperationNameRaw)) + + maps.Copy(rawQuery, getOperationReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1183,13 +1233,12 @@ func newGetOperation() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getStreamOverrides []func( *cobra.Command, - *ml.GetStreamRequest, + *sdkfeatures.GetStreamRequest, ) func newGetStream() *cobra.Command { cmd := &cobra.Command{} - - var getStreamReq ml.GetStreamRequest + var getStreamReq sdkfeatures.GetStreamRequest cmd.Use = "get-stream NAME" cmd.Short = `*Public Preview* Get a Stream.` @@ -1215,15 +1264,21 @@ Get a Stream. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getStreamReq.Name = args[0] + getStreamReq.Name = new(args[0]) - response, err := w.FeatureEngineering.GetStream(ctx, getStreamReq) + sdkReq := &getStreamReq + response, err := w.Features.GetStream(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := features.StreamFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1244,25 +1299,25 @@ Get a Stream. // Functions can be added from the `init()` function in manually curated files in this directory. var listFeaturesOverrides []func( *cobra.Command, - *ml.ListFeaturesRequest, + *features.ListFeaturesRequest, ) func newListFeatures() *cobra.Command { cmd := &cobra.Command{} + var listFeaturesReq features.ListFeaturesRequest - var listFeaturesReq ml.ListFeaturesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listFeaturesLimit int - cmd.Flags().IntVar(&listFeaturesReq.PageSize, "page-size", listFeaturesReq.PageSize, `The maximum number of results to return.`) + flags.IntPtrVar(cmd.Flags(), &listFeaturesReq.PageSize, "page-size", `The maximum number of results to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listFeaturesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listFeaturesReq.PageToken, "page-token", listFeaturesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listFeaturesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-features CATALOG_NAME SCHEMA_NAME" @@ -1290,19 +1345,23 @@ List features. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listFeaturesReq.CatalogName = args[0] - listFeaturesReq.SchemaName = args[1] + listFeaturesReq.CatalogName = new(args[0]) + listFeaturesReq.SchemaName = new(args[1]) - response := w.FeatureEngineering.ListFeatures(ctx, listFeaturesReq) + sdkReq, err := features.ListFeaturesRequestToSDK(&listFeaturesReq) + if err != nil { + return err + } if listFeaturesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listFeaturesLimit) } if listFeaturesLimit > 0 { ctx = cmdio.WithLimit(ctx, listFeaturesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Features.ListFeaturesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, features.FeatureFromSDK)) } // Disable completions since they are not applicable. @@ -1323,25 +1382,25 @@ List features. // Functions can be added from the `init()` function in manually curated files in this directory. var listKafkaConfigsOverrides []func( *cobra.Command, - *ml.ListKafkaConfigsRequest, + *features.ListKafkaConfigsRequest, ) func newListKafkaConfigs() *cobra.Command { cmd := &cobra.Command{} + var listKafkaConfigsReq features.ListKafkaConfigsRequest - var listKafkaConfigsReq ml.ListKafkaConfigsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listKafkaConfigsLimit int - cmd.Flags().IntVar(&listKafkaConfigsReq.PageSize, "page-size", listKafkaConfigsReq.PageSize, `The maximum number of results to return.`) + flags.IntPtrVar(cmd.Flags(), &listKafkaConfigsReq.PageSize, "page-size", `The maximum number of results to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listKafkaConfigsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listKafkaConfigsReq.PageToken, "page-token", listKafkaConfigsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listKafkaConfigsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-kafka-configs" @@ -1368,16 +1427,20 @@ func newListKafkaConfigs() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.FeatureEngineering.ListKafkaConfigs(ctx, listKafkaConfigsReq) + sdkReq, err := features.ListKafkaConfigsRequestToSDK(&listKafkaConfigsReq) + if err != nil { + return err + } if listKafkaConfigsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listKafkaConfigsLimit) } if listKafkaConfigsLimit > 0 { ctx = cmdio.WithLimit(ctx, listKafkaConfigsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Features.ListKafkaConfigsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, features.KafkaConfigFromSDK)) } // Disable completions since they are not applicable. @@ -1398,26 +1461,26 @@ func newListKafkaConfigs() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listMaterializedFeaturesOverrides []func( *cobra.Command, - *ml.ListMaterializedFeaturesRequest, + *features.ListMaterializedFeaturesRequest, ) func newListMaterializedFeatures() *cobra.Command { cmd := &cobra.Command{} + var listMaterializedFeaturesReq features.ListMaterializedFeaturesRequest - var listMaterializedFeaturesReq ml.ListMaterializedFeaturesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listMaterializedFeaturesLimit int - cmd.Flags().StringVar(&listMaterializedFeaturesReq.FeatureName, "feature-name", listMaterializedFeaturesReq.FeatureName, `Filter by feature name.`) - cmd.Flags().IntVar(&listMaterializedFeaturesReq.PageSize, "page-size", listMaterializedFeaturesReq.PageSize, `The maximum number of results to return.`) + flags.StringPtrVar(cmd.Flags(), &listMaterializedFeaturesReq.FeatureName, "feature-name", `Filter by feature name.`) + flags.IntPtrVar(cmd.Flags(), &listMaterializedFeaturesReq.PageSize, "page-size", `The maximum number of results to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listMaterializedFeaturesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listMaterializedFeaturesReq.PageToken, "page-token", listMaterializedFeaturesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listMaterializedFeaturesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-materialized-features" @@ -1439,16 +1502,20 @@ List materialized features.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.FeatureEngineering.ListMaterializedFeatures(ctx, listMaterializedFeaturesReq) + sdkReq, err := features.ListMaterializedFeaturesRequestToSDK(&listMaterializedFeaturesReq) + if err != nil { + return err + } if listMaterializedFeaturesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listMaterializedFeaturesLimit) } if listMaterializedFeaturesLimit > 0 { ctx = cmdio.WithLimit(ctx, listMaterializedFeaturesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Features.ListMaterializedFeaturesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, features.MaterializedFeatureFromSDK)) } // Disable completions since they are not applicable. @@ -1469,26 +1536,26 @@ List materialized features.` // Functions can be added from the `init()` function in manually curated files in this directory. var listStreamsOverrides []func( *cobra.Command, - *ml.ListStreamsRequest, + *features.ListStreamsRequest, ) func newListStreams() *cobra.Command { cmd := &cobra.Command{} + var listStreamsReq features.ListStreamsRequest - var listStreamsReq ml.ListStreamsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listStreamsLimit int - cmd.Flags().IntVar(&listStreamsReq.PageSize, "page-size", listStreamsReq.PageSize, `The maximum number of results to return.`) - cmd.Flags().StringVar(&listStreamsReq.Parent, "parent", listStreamsReq.Parent, `Two-part name (catalog.schema) of the parent under which to list Streams.`) + flags.IntPtrVar(cmd.Flags(), &listStreamsReq.PageSize, "page-size", `The maximum number of results to return.`) + flags.StringPtrVar(cmd.Flags(), &listStreamsReq.Parent, "parent", `Two-part name (catalog.schema) of the parent under which to list Streams.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listStreamsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listStreamsReq.PageToken, "page-token", listStreamsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listStreamsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-streams" @@ -1512,16 +1579,20 @@ List Streams. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.FeatureEngineering.ListStreams(ctx, listStreamsReq) + sdkReq, err := features.ListStreamsRequestToSDK(&listStreamsReq) + if err != nil { + return err + } if listStreamsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listStreamsLimit) } if listStreamsLimit > 0 { ctx = cmdio.WithLimit(ctx, listStreamsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Features.ListStreamsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, features.StreamFromSDK)) } // Disable completions since they are not applicable. @@ -1542,13 +1613,13 @@ List Streams. // Functions can be added from the `init()` function in manually curated files in this directory. var purgeFeatureEntitiesOverrides []func( *cobra.Command, - *ml.PurgeFeatureEntitiesRequest, + *features.PurgeFeatureEntitiesRequest, ) func newPurgeFeatureEntities() *cobra.Command { cmd := &cobra.Command{} + var purgeFeatureEntitiesReq features.PurgeFeatureEntitiesRequest - var purgeFeatureEntitiesReq ml.PurgeFeatureEntitiesRequest var purgeFeatureEntitiesJson flags.JsonFlag var purgeFeatureEntitiesSkipWait bool @@ -1559,8 +1630,8 @@ func newPurgeFeatureEntities() *cobra.Command { cmd.Flags().Var(&purgeFeatureEntitiesJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&purgeFeatureEntitiesReq.BudgetPolicyId, "budget-policy-id", purgeFeatureEntitiesReq.BudgetPolicyId, `The budget policy ID, in UUID format, used to attribute the serverless compute cost of this purge.`) - cmd.Flags().StringVar(&purgeFeatureEntitiesReq.RequestId, "request-id", purgeFeatureEntitiesReq.RequestId, `Optional UUID4 idempotency token for the request.`) + flags.StringPtrVar(cmd.Flags(), &purgeFeatureEntitiesReq.BudgetPolicyId, "budget-policy-id", `The budget policy ID, in UUID format, used to attribute the serverless compute cost of this purge.`) + flags.StringPtrVar(cmd.Flags(), &purgeFeatureEntitiesReq.RequestId, "request-id", `Optional UUID4 idempotency token for the request.`) // TODO: map via StringToStringVar: tags cmd.Use = "purge-feature-entities" @@ -1585,6 +1656,7 @@ func newPurgeFeatureEntities() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := purgeFeatureEntitiesJson.Unmarshal(&purgeFeatureEntitiesReq) @@ -1601,25 +1673,23 @@ func newPurgeFeatureEntities() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } + sdkReq, err := features.PurgeFeatureEntitiesRequestToSDK(&purgeFeatureEntitiesReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case purgeFeatureEntitiesSkipWait: - wait, err := w.FeatureEngineering.PurgeFeatureEntities(ctx, purgeFeatureEntitiesReq) + wait, err := w.Features.PurgeFeatureEntities(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.FeatureEngineering.GetOperation(ctx, ml.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.FeatureEngineering.PurgeFeatureEntities(ctx, purgeFeatureEntitiesReq) + wait, err := w.Features.PurgeFeatureEntities(ctx, *sdkReq) if err != nil { return err } @@ -1629,13 +1699,17 @@ func newPurgeFeatureEntities() *cobra.Command { sp.Update("Waiting for purge-feature-entities to complete...") // Wait for completion. - opts := api.WithTimeout(purgeFeatureEntitiesTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(purgeFeatureEntitiesTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := features.PurgeFeatureEntitiesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -1657,21 +1731,21 @@ func newPurgeFeatureEntities() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateFeatureOverrides []func( *cobra.Command, - *ml.UpdateFeatureRequest, + *features.UpdateFeatureRequest, ) func newUpdateFeature() *cobra.Command { cmd := &cobra.Command{} + var updateFeatureReq features.UpdateFeatureRequest + updateFeatureReq.Feature = &features.Feature{} - var updateFeatureReq ml.UpdateFeatureRequest - updateFeatureReq.Feature = ml.Feature{} var updateFeatureJson flags.JsonFlag 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.`) + flags.StringPtrVar(cmd.Flags(), &updateFeatureReq.Feature.Description, "description", `The description of the feature.`) // TODO: array: entities - cmd.Flags().StringVar(&updateFeatureReq.Feature.FilterCondition, "filter-condition", updateFeatureReq.Feature.FilterCondition, ``) + flags.StringPtrVar(cmd.Flags(), &updateFeatureReq.Feature.FilterCondition, "filter-condition", ``) // TODO: array: inputs // TODO: complex arg: lineage_context // TODO: complex arg: time_window @@ -1711,6 +1785,7 @@ Update a feature's description (all other fields are immutable). cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateFeatureJson.Unmarshal(&updateFeatureReq.Feature) @@ -1724,29 +1799,29 @@ Update a feature's description (all other fields are immutable). } } } - updateFeatureReq.FullName = args[0] - updateFeatureReq.UpdateMask = args[1] + updateFeatureReq.Feature.FullName = new(args[0]) + updateFeatureReq.UpdateMask = new(args[1]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &updateFeatureReq.Feature.Source) - if err != nil { - return fmt.Errorf("invalid SOURCE: %s", args[2]) - } - + _ = args[2] // TODO: complex arg: source } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updateFeatureReq.Feature.Function) - if err != nil { - return fmt.Errorf("invalid FUNCTION: %s", args[3]) - } - + _ = args[3] // TODO: complex arg: function } - response, err := w.FeatureEngineering.UpdateFeature(ctx, updateFeatureReq) + sdkReq, err := features.UpdateFeatureRequestToSDK(&updateFeatureReq) + if err != nil { + return err + } + response, err := w.Features.UpdateFeature(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := features.FeatureFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1767,14 +1842,14 @@ Update a feature's description (all other fields are immutable). // Functions can be added from the `init()` function in manually curated files in this directory. var updateKafkaConfigOverrides []func( *cobra.Command, - *ml.UpdateKafkaConfigRequest, + *features.UpdateKafkaConfigRequest, ) func newUpdateKafkaConfig() *cobra.Command { cmd := &cobra.Command{} + var updateKafkaConfigReq features.UpdateKafkaConfigRequest + updateKafkaConfigReq.KafkaConfig = &features.KafkaConfig{} - var updateKafkaConfigReq ml.UpdateKafkaConfigRequest - updateKafkaConfigReq.KafkaConfig = ml.KafkaConfig{} var updateKafkaConfigJson flags.JsonFlag cmd.Flags().Var(&updateKafkaConfigJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1825,6 +1900,7 @@ func newUpdateKafkaConfig() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateKafkaConfigJson.Unmarshal(&updateKafkaConfigReq.KafkaConfig) @@ -1838,35 +1914,34 @@ func newUpdateKafkaConfig() *cobra.Command { } } } - updateKafkaConfigReq.Name = args[0] + updateKafkaConfigReq.KafkaConfig.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateKafkaConfigReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateKafkaConfigReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - updateKafkaConfigReq.KafkaConfig.BootstrapServers = args[2] + updateKafkaConfigReq.KafkaConfig.BootstrapServers = new(args[2]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updateKafkaConfigReq.KafkaConfig.SubscriptionMode) - if err != nil { - return fmt.Errorf("invalid SUBSCRIPTION_MODE: %s", args[3]) - } - + _ = args[3] // TODO: complex arg: subscription_mode } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[4], &updateKafkaConfigReq.KafkaConfig.AuthConfig) - if err != nil { - return fmt.Errorf("invalid AUTH_CONFIG: %s", args[4]) - } - + _ = args[4] // TODO: complex arg: auth_config } - response, err := w.FeatureEngineering.UpdateKafkaConfig(ctx, updateKafkaConfigReq) + sdkReq, err := features.UpdateKafkaConfigRequestToSDK(&updateKafkaConfigReq) + if err != nil { + return err + } + response, err := w.Features.UpdateKafkaConfig(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := features.KafkaConfigFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1887,26 +1962,26 @@ func newUpdateKafkaConfig() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateMaterializedFeatureOverrides []func( *cobra.Command, - *ml.UpdateMaterializedFeatureRequest, + *features.UpdateMaterializedFeatureRequest, ) func newUpdateMaterializedFeature() *cobra.Command { cmd := &cobra.Command{} + var updateMaterializedFeatureReq features.UpdateMaterializedFeatureRequest + updateMaterializedFeatureReq.MaterializedFeature = &features.MaterializedFeature{} - var updateMaterializedFeatureReq ml.UpdateMaterializedFeatureRequest - updateMaterializedFeatureReq.MaterializedFeature = ml.MaterializedFeature{} var updateMaterializedFeatureJson flags.JsonFlag cmd.Flags().Var(&updateMaterializedFeatureJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateMaterializedFeatureReq.MaterializedFeature.BudgetPolicyId, "budget-policy-id", updateMaterializedFeatureReq.MaterializedFeature.BudgetPolicyId, `The ID of the budget policy used to attribute the serverless compute cost of this materialization.`) - cmd.Flags().StringVar(&updateMaterializedFeatureReq.MaterializedFeature.CronSchedule, "cron-schedule", updateMaterializedFeatureReq.MaterializedFeature.CronSchedule, ``) + flags.StringPtrVar(cmd.Flags(), &updateMaterializedFeatureReq.MaterializedFeature.BudgetPolicyId, "budget-policy-id", `The ID of the budget policy used to attribute the serverless compute cost of this materialization.`) + flags.StringPtrVar(cmd.Flags(), &updateMaterializedFeatureReq.MaterializedFeature.CronSchedule, "cron-schedule", ``) // TODO: complex arg: cron_schedule_trigger - cmd.Flags().StringVar(&updateMaterializedFeatureReq.MaterializedFeature.MaterializedFeatureId, "materialized-feature-id", updateMaterializedFeatureReq.MaterializedFeature.MaterializedFeatureId, `Server-assigned unique identifier for the materialized feature.`) + flags.StringPtrVar(cmd.Flags(), &updateMaterializedFeatureReq.MaterializedFeature.MaterializedFeatureId, "materialized-feature-id", `Server-assigned unique identifier for the materialized feature.`) // TODO: complex arg: notifications // 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]`) + flags.EnumVar(cmd.Flags(), &updateMaterializedFeatureReq.MaterializedFeature.PipelineScheduleState, "pipeline-schedule-state", `The schedule state of the materialization pipeline. Supported values: [ACTIVE, PAUSED, SNAPSHOT]`, "MaterializedFeaturePipelineScheduleState", "ACTIVE", "PAUSED", "SNAPSHOT") // TODO: complex arg: streaming_mode // TODO: complex arg: table_trigger // TODO: map via StringToStringVar: tags @@ -1945,6 +2020,7 @@ Update a materialized feature. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateMaterializedFeatureJson.Unmarshal(&updateMaterializedFeatureReq.MaterializedFeature) @@ -1958,18 +2034,26 @@ Update a materialized feature. } } } - updateMaterializedFeatureReq.MaterializedFeatureId = args[0] - updateMaterializedFeatureReq.UpdateMask = args[1] + updateMaterializedFeatureReq.MaterializedFeature.MaterializedFeatureId = new(args[0]) + updateMaterializedFeatureReq.UpdateMask = new(args[1]) if !cmd.Flags().Changed("json") { - updateMaterializedFeatureReq.MaterializedFeature.FeatureName = args[2] + updateMaterializedFeatureReq.MaterializedFeature.FeatureName = new(args[2]) } - response, err := w.FeatureEngineering.UpdateMaterializedFeature(ctx, updateMaterializedFeatureReq) + sdkReq, err := features.UpdateMaterializedFeatureRequestToSDK(&updateMaterializedFeatureReq) + if err != nil { + return err + } + response, err := w.Features.UpdateMaterializedFeature(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := features.MaterializedFeatureFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1990,21 +2074,21 @@ Update a materialized feature. // Functions can be added from the `init()` function in manually curated files in this directory. var updateStreamOverrides []func( *cobra.Command, - *ml.UpdateStreamRequest, + *features.UpdateStreamRequest, ) func newUpdateStream() *cobra.Command { cmd := &cobra.Command{} + var updateStreamReq features.UpdateStreamRequest + updateStreamReq.Stream = &features.Stream{} - var updateStreamReq ml.UpdateStreamRequest - updateStreamReq.Stream = ml.Stream{} var updateStreamJson flags.JsonFlag cmd.Flags().Var(&updateStreamJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateStreamReq.Stream.Description, "description", updateStreamReq.Stream.Description, `User-provided description.`) + flags.StringPtrVar(cmd.Flags(), &updateStreamReq.Stream.Description, "description", `User-provided description.`) // TODO: array: excluded_columns - cmd.Flags().StringVar(&updateStreamReq.Stream.RecordTypeFilter, "record-type-filter", updateStreamReq.Stream.RecordTypeFilter, `Optional SQL predicate to filter which record types from a streaming channel (e.g.`) + flags.StringPtrVar(cmd.Flags(), &updateStreamReq.Stream.RecordTypeFilter, "record-type-filter", `Optional SQL predicate to filter which record types from a streaming channel (e.g.`) cmd.Use = "update-stream NAME UPDATE_MASK SOURCE_CONFIG CONNECTION_CONFIG SCHEMA_CONFIG INGESTION_CONFIG" cmd.Short = `*Public Preview* Update a Stream.` @@ -2044,6 +2128,7 @@ Update a Stream. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateStreamJson.Unmarshal(&updateStreamReq.Stream) @@ -2057,46 +2142,37 @@ Update a Stream. } } } - updateStreamReq.Name = args[0] + updateStreamReq.Stream.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateStreamReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateStreamReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &updateStreamReq.Stream.SourceConfig) - if err != nil { - return fmt.Errorf("invalid SOURCE_CONFIG: %s", args[2]) - } - + _ = args[2] // TODO: complex arg: source_config } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updateStreamReq.Stream.ConnectionConfig) - if err != nil { - return fmt.Errorf("invalid CONNECTION_CONFIG: %s", args[3]) - } - + _ = args[3] // TODO: complex arg: connection_config } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[4], &updateStreamReq.Stream.SchemaConfig) - if err != nil { - return fmt.Errorf("invalid SCHEMA_CONFIG: %s", args[4]) - } - + _ = args[4] // TODO: complex arg: schema_config } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[5], &updateStreamReq.Stream.IngestionConfig) - if err != nil { - return fmt.Errorf("invalid INGESTION_CONFIG: %s", args[5]) - } - + _ = args[5] // TODO: complex arg: ingestion_config } - response, err := w.FeatureEngineering.UpdateStream(ctx, updateStreamReq) + sdkReq, err := features.UpdateStreamRequestToSDK(&updateStreamReq) + if err != nil { + return err + } + response, err := w.Features.UpdateStream(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := features.StreamFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/feature-store/feature-store.go b/cmd/workspace/feature-store/feature-store.go index 1bb57ee7a48..83c905d4026 100644 --- a/cmd/workspace/feature-store/feature-store.go +++ b/cmd/workspace/feature-store/feature-store.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/ml" "github.com/spf13/cobra" + + featurestore "github.com/databricks/cli/libs/sdktypes/featurestore/v1" + sdkfeaturestore "github.com/databricks/sdk-go/featurestore/v1" ) // Slice with functions to override default command behavior. @@ -63,20 +66,20 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOnlineStoreOverrides []func( *cobra.Command, - *ml.CreateOnlineStoreRequest, + *featurestore.CreateOnlineStoreRequest, ) func newCreateOnlineStore() *cobra.Command { cmd := &cobra.Command{} + var createOnlineStoreReq featurestore.CreateOnlineStoreRequest + createOnlineStoreReq.OnlineStore = &featurestore.OnlineStore{} - var createOnlineStoreReq ml.CreateOnlineStoreRequest - createOnlineStoreReq.OnlineStore = ml.OnlineStore{} var createOnlineStoreJson flags.JsonFlag cmd.Flags().Var(&createOnlineStoreJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().IntVar(&createOnlineStoreReq.OnlineStore.ReadReplicaCount, "read-replica-count", createOnlineStoreReq.OnlineStore.ReadReplicaCount, `The number of read replicas for the online store.`) - cmd.Flags().StringVar(&createOnlineStoreReq.OnlineStore.UsagePolicyId, "usage-policy-id", createOnlineStoreReq.OnlineStore.UsagePolicyId, `The usage policy applied to the online store to track billing.`) + flags.IntPtrVar(cmd.Flags(), &createOnlineStoreReq.OnlineStore.ReadReplicaCount, "read-replica-count", `The number of read replicas for the online store.`) + flags.StringPtrVar(cmd.Flags(), &createOnlineStoreReq.OnlineStore.UsagePolicyId, "usage-policy-id", `The usage policy applied to the online store to track billing.`) cmd.Use = "create-online-store NAME CAPACITY" cmd.Short = `Create an Online Feature Store.` @@ -108,6 +111,7 @@ func newCreateOnlineStore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createOnlineStoreJson.Unmarshal(&createOnlineStoreReq.OnlineStore) @@ -122,18 +126,26 @@ func newCreateOnlineStore() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createOnlineStoreReq.OnlineStore.Name = args[0] + createOnlineStoreReq.OnlineStore.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createOnlineStoreReq.OnlineStore.Capacity = args[1] + createOnlineStoreReq.OnlineStore.Capacity = new(args[1]) } - response, err := w.FeatureStore.CreateOnlineStore(ctx, createOnlineStoreReq) + sdkReq, err := featurestore.CreateOnlineStoreRequestToSDK(&createOnlineStoreReq) + if err != nil { + return err + } + response, err := w.FeatureStore.CreateOnlineStore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := featurestore.OnlineStoreFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -154,13 +166,12 @@ func newCreateOnlineStore() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOnlineStoreOverrides []func( *cobra.Command, - *ml.DeleteOnlineStoreRequest, + *sdkfeaturestore.DeleteOnlineStoreRequest, ) func newDeleteOnlineStore() *cobra.Command { cmd := &cobra.Command{} - - var deleteOnlineStoreReq ml.DeleteOnlineStoreRequest + var deleteOnlineStoreReq sdkfeaturestore.DeleteOnlineStoreRequest cmd.Use = "delete-online-store NAME" cmd.Short = `Delete an Online Feature Store.` @@ -182,10 +193,12 @@ func newDeleteOnlineStore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteOnlineStoreReq.Name = args[0] + deleteOnlineStoreReq.Name = new(args[0]) - err = w.FeatureStore.DeleteOnlineStore(ctx, deleteOnlineStoreReq) + sdkReq := &deleteOnlineStoreReq + err = w.FeatureStore.DeleteOnlineStore(ctx, *sdkReq) if err != nil { return err } @@ -210,13 +223,12 @@ func newDeleteOnlineStore() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOnlineTableOverrides []func( *cobra.Command, - *ml.DeleteOnlineTableRequest, + *sdkfeaturestore.DeleteOnlineTableRequest, ) func newDeleteOnlineTable() *cobra.Command { cmd := &cobra.Command{} - - var deleteOnlineTableReq ml.DeleteOnlineTableRequest + var deleteOnlineTableReq sdkfeaturestore.DeleteOnlineTableRequest cmd.Use = "delete-online-table ONLINE_TABLE_NAME" cmd.Short = `Delete an online table.` @@ -240,10 +252,12 @@ func newDeleteOnlineTable() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteOnlineTableReq.OnlineTableName = args[0] + deleteOnlineTableReq.OnlineTableName = new(args[0]) - err = w.FeatureStore.DeleteOnlineTable(ctx, deleteOnlineTableReq) + sdkReq := &deleteOnlineTableReq + err = w.FeatureStore.DeleteOnlineTable(ctx, *sdkReq) if err != nil { return err } @@ -268,13 +282,12 @@ func newDeleteOnlineTable() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOnlineStoreOverrides []func( *cobra.Command, - *ml.GetOnlineStoreRequest, + *sdkfeaturestore.GetOnlineStoreRequest, ) func newGetOnlineStore() *cobra.Command { cmd := &cobra.Command{} - - var getOnlineStoreReq ml.GetOnlineStoreRequest + var getOnlineStoreReq sdkfeaturestore.GetOnlineStoreRequest cmd.Use = "get-online-store NAME" cmd.Short = `Get an Online Feature Store.` @@ -296,15 +309,21 @@ func newGetOnlineStore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getOnlineStoreReq.Name = args[0] + getOnlineStoreReq.Name = new(args[0]) - response, err := w.FeatureStore.GetOnlineStore(ctx, getOnlineStoreReq) + sdkReq := &getOnlineStoreReq + response, err := w.FeatureStore.GetOnlineStore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := featurestore.OnlineStoreFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -325,25 +344,25 @@ func newGetOnlineStore() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOnlineStoresOverrides []func( *cobra.Command, - *ml.ListOnlineStoresRequest, + *featurestore.ListOnlineStoresRequest, ) func newListOnlineStores() *cobra.Command { cmd := &cobra.Command{} + var listOnlineStoresReq featurestore.ListOnlineStoresRequest - var listOnlineStoresReq ml.ListOnlineStoresRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listOnlineStoresLimit int - cmd.Flags().IntVar(&listOnlineStoresReq.PageSize, "page-size", listOnlineStoresReq.PageSize, `The maximum number of results to return.`) + flags.IntPtrVar(cmd.Flags(), &listOnlineStoresReq.PageSize, "page-size", `The maximum number of results to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listOnlineStoresLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listOnlineStoresReq.PageToken, "page-token", listOnlineStoresReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listOnlineStoresReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-online-stores" @@ -363,16 +382,20 @@ func newListOnlineStores() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.FeatureStore.ListOnlineStores(ctx, listOnlineStoresReq) + sdkReq, err := featurestore.ListOnlineStoresRequestToSDK(&listOnlineStoresReq) + if err != nil { + return err + } if listOnlineStoresLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listOnlineStoresLimit) } if listOnlineStoresLimit > 0 { ctx = cmdio.WithLimit(ctx, listOnlineStoresLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.FeatureStore.ListOnlineStoresIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, featurestore.OnlineStoreFromSDK)) } // Disable completions since they are not applicable. @@ -393,13 +416,13 @@ func newListOnlineStores() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var publishTableOverrides []func( *cobra.Command, - *ml.PublishTableRequest, + *featurestore.PublishTableRequest, ) func newPublishTable() *cobra.Command { cmd := &cobra.Command{} + var publishTableReq featurestore.PublishTableRequest - var publishTableReq ml.PublishTableRequest var publishTableJson flags.JsonFlag cmd.Flags().Var(&publishTableJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -424,6 +447,7 @@ func newPublishTable() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := publishTableJson.Unmarshal(&publishTableReq) @@ -439,14 +463,22 @@ func newPublishTable() *cobra.Command { } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - publishTableReq.SourceTableName = args[0] + publishTableReq.SourceTableName = new(args[0]) - response, err := w.FeatureStore.PublishTable(ctx, publishTableReq) + sdkReq, err := featurestore.PublishTableRequestToSDK(&publishTableReq) + if err != nil { + return err + } + response, err := w.FeatureStore.PublishTable(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := featurestore.PublishTableResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -467,20 +499,20 @@ func newPublishTable() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOnlineStoreOverrides []func( *cobra.Command, - *ml.UpdateOnlineStoreRequest, + *featurestore.UpdateOnlineStoreRequest, ) func newUpdateOnlineStore() *cobra.Command { cmd := &cobra.Command{} + var updateOnlineStoreReq featurestore.UpdateOnlineStoreRequest + updateOnlineStoreReq.OnlineStore = &featurestore.OnlineStore{} - var updateOnlineStoreReq ml.UpdateOnlineStoreRequest - updateOnlineStoreReq.OnlineStore = ml.OnlineStore{} var updateOnlineStoreJson flags.JsonFlag cmd.Flags().Var(&updateOnlineStoreJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().IntVar(&updateOnlineStoreReq.OnlineStore.ReadReplicaCount, "read-replica-count", updateOnlineStoreReq.OnlineStore.ReadReplicaCount, `The number of read replicas for the online store.`) - cmd.Flags().StringVar(&updateOnlineStoreReq.OnlineStore.UsagePolicyId, "usage-policy-id", updateOnlineStoreReq.OnlineStore.UsagePolicyId, `The usage policy applied to the online store to track billing.`) + flags.IntPtrVar(cmd.Flags(), &updateOnlineStoreReq.OnlineStore.ReadReplicaCount, "read-replica-count", `The number of read replicas for the online store.`) + flags.StringPtrVar(cmd.Flags(), &updateOnlineStoreReq.OnlineStore.UsagePolicyId, "usage-policy-id", `The usage policy applied to the online store to track billing.`) cmd.Use = "update-online-store NAME UPDATE_MASK CAPACITY" cmd.Short = `Update an Online Feature Store.` @@ -519,6 +551,7 @@ func newUpdateOnlineStore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateOnlineStoreJson.Unmarshal(&updateOnlineStoreReq.OnlineStore) @@ -532,18 +565,26 @@ func newUpdateOnlineStore() *cobra.Command { } } } - updateOnlineStoreReq.Name = args[0] - updateOnlineStoreReq.UpdateMask = args[1] + updateOnlineStoreReq.OnlineStore.Name = new(args[0]) + updateOnlineStoreReq.UpdateMask = new(args[1]) if !cmd.Flags().Changed("json") { - updateOnlineStoreReq.OnlineStore.Capacity = args[2] + updateOnlineStoreReq.OnlineStore.Capacity = new(args[2]) } - response, err := w.FeatureStore.UpdateOnlineStore(ctx, updateOnlineStoreReq) + sdkReq, err := featurestore.UpdateOnlineStoreRequestToSDK(&updateOnlineStoreReq) + if err != nil { + return err + } + response, err := w.FeatureStore.UpdateOnlineStore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := featurestore.OnlineStoreFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/forecasting/forecasting.go b/cmd/workspace/forecasting/forecasting.go index 29aa8a08fba..763a2d4aa9c 100644 --- a/cmd/workspace/forecasting/forecasting.go +++ b/cmd/workspace/forecasting/forecasting.go @@ -8,11 +8,17 @@ import ( "time" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/ml" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + forecasting "github.com/databricks/cli/libs/sdktypes/forecasting/v1" + sdkforecasting "github.com/databricks/sdk-go/forecasting/v1" ) // Slice with functions to override default command behavior. @@ -54,13 +60,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createExperimentOverrides []func( *cobra.Command, - *ml.CreateForecastingExperimentRequest, + *forecasting.CreateForecastingExperimentRequest, ) func newCreateExperiment() *cobra.Command { cmd := &cobra.Command{} + var createExperimentReq forecasting.CreateForecastingExperimentRequest - var createExperimentReq ml.CreateForecastingExperimentRequest var createExperimentJson flags.JsonFlag var createExperimentSkipWait bool @@ -71,16 +77,16 @@ func newCreateExperiment() *cobra.Command { cmd.Flags().Var(&createExperimentJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createExperimentReq.CustomWeightsColumn, "custom-weights-column", createExperimentReq.CustomWeightsColumn, `The column in the training table used to customize weights for each time series.`) - cmd.Flags().StringVar(&createExperimentReq.ExperimentPath, "experiment-path", createExperimentReq.ExperimentPath, `The path in the workspace to store the created experiment.`) - cmd.Flags().StringVar(&createExperimentReq.FutureFeatureDataPath, "future-feature-data-path", createExperimentReq.FutureFeatureDataPath, `The fully qualified path of a Unity Catalog table, formatted as catalog_name.schema_name.table_name, used to store future feature data for predictions.`) + flags.StringPtrVar(cmd.Flags(), &createExperimentReq.CustomWeightsColumn, "custom-weights-column", `The column in the training table used to customize weights for each time series.`) + flags.StringPtrVar(cmd.Flags(), &createExperimentReq.ExperimentPath, "experiment-path", `The path in the workspace to store the created experiment.`) + flags.StringPtrVar(cmd.Flags(), &createExperimentReq.FutureFeatureDataPath, "future-feature-data-path", `The fully qualified path of a Unity Catalog table, formatted as catalog_name.schema_name.table_name, used to store future feature data for predictions.`) // TODO: array: holiday_regions // TODO: array: include_features - cmd.Flags().Int64Var(&createExperimentReq.MaxRuntime, "max-runtime", createExperimentReq.MaxRuntime, `The maximum duration for the experiment in minutes.`) - cmd.Flags().StringVar(&createExperimentReq.PredictionDataPath, "prediction-data-path", createExperimentReq.PredictionDataPath, `The fully qualified path of a Unity Catalog table, formatted as catalog_name.schema_name.table_name, used to store predictions.`) - cmd.Flags().StringVar(&createExperimentReq.PrimaryMetric, "primary-metric", createExperimentReq.PrimaryMetric, `The evaluation metric used to optimize the forecasting model.`) - cmd.Flags().StringVar(&createExperimentReq.RegisterTo, "register-to", createExperimentReq.RegisterTo, `The fully qualified path of a Unity Catalog model, formatted as catalog_name.schema_name.model_name, used to store the best model.`) - cmd.Flags().StringVar(&createExperimentReq.SplitColumn, "split-column", createExperimentReq.SplitColumn, `// The column in the training table used for custom data splits.`) + flags.Int64PtrVar(cmd.Flags(), &createExperimentReq.MaxRuntime, "max-runtime", `The maximum duration for the experiment in minutes.`) + flags.StringPtrVar(cmd.Flags(), &createExperimentReq.PredictionDataPath, "prediction-data-path", `The fully qualified path of a Unity Catalog table, formatted as catalog_name.schema_name.table_name, used to store predictions.`) + flags.StringPtrVar(cmd.Flags(), &createExperimentReq.PrimaryMetric, "primary-metric", `The evaluation metric used to optimize the forecasting model.`) + flags.StringPtrVar(cmd.Flags(), &createExperimentReq.RegisterTo, "register-to", `The fully qualified path of a Unity Catalog model, formatted as catalog_name.schema_name.model_name, used to store the best model.`) + flags.StringPtrVar(cmd.Flags(), &createExperimentReq.SplitColumn, "split-column", `// The column in the training table used for custom data splits.`) // TODO: array: timeseries_identifier_columns // TODO: array: training_frameworks @@ -127,6 +133,7 @@ func newCreateExperiment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createExperimentJson.Unmarshal(&createExperimentReq) @@ -141,43 +148,59 @@ func newCreateExperiment() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createExperimentReq.TrainDataPath = args[0] + createExperimentReq.TrainDataPath = new(args[0]) } if !cmd.Flags().Changed("json") { - createExperimentReq.TargetColumn = args[1] + createExperimentReq.TargetColumn = new(args[1]) } if !cmd.Flags().Changed("json") { - createExperimentReq.TimeColumn = args[2] + createExperimentReq.TimeColumn = new(args[2]) } if !cmd.Flags().Changed("json") { - createExperimentReq.ForecastGranularity = args[3] + createExperimentReq.ForecastGranularity = new(args[3]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[4], &createExperimentReq.ForecastHorizon) + var createExperimentForecastHorizonArg int64 + _, err = fmt.Sscan(args[4], &createExperimentForecastHorizonArg) if err != nil { return fmt.Errorf("invalid FORECAST_HORIZON: %s", args[4]) } - + createExperimentReq.ForecastHorizon = &createExperimentForecastHorizonArg } - wait, err := w.Forecasting.CreateExperiment(ctx, createExperimentReq) + sdkReq, err := forecasting.CreateForecastingExperimentRequestToSDK(&createExperimentReq) if err != nil { return err } if createExperimentSkipWait { - return cmdio.Render(ctx, wait.Response) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var current forecasting.CreateForecastingExperimentResponse + err = api.Do(ctx, "POST", "/api/2.0/automl/create-forecasting-experiment", auth.WorkspaceIDHeaders(w.Config), nil, &createExperimentReq, ¤t) + if err != nil { + return err + } + return cmdio.Render(ctx, current) + } + wait, err := w.Forecasting.CreateForecastingExperiment(ctx, *sdkReq) + if err != nil { + return err } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *ml.ForecastingExperiment) { - status := i.State - statusMessage := fmt.Sprintf("current status: %s", status) - sp.Update(statusMessage) - }).GetWithTimeout(createExperimentTimeout) + sp.Update("Waiting for create-experiment to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createExperimentTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := forecasting.ForecastingExperimentFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -198,13 +221,12 @@ func newCreateExperiment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getExperimentOverrides []func( *cobra.Command, - *ml.GetForecastingExperimentRequest, + *sdkforecasting.GetForecastingExperimentRequest, ) func newGetExperiment() *cobra.Command { cmd := &cobra.Command{} - - var getExperimentReq ml.GetForecastingExperimentRequest + var getExperimentReq sdkforecasting.GetForecastingExperimentRequest cmd.Use = "get-experiment EXPERIMENT_ID" cmd.Short = `Get a forecasting experiment.` @@ -228,15 +250,21 @@ func newGetExperiment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getExperimentReq.ExperimentId = args[0] + getExperimentReq.ExperimentId = new(args[0]) - response, err := w.Forecasting.GetExperiment(ctx, getExperimentReq) + sdkReq := &getExperimentReq + response, err := w.Forecasting.GetForecastingExperiment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := forecasting.ForecastingExperimentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/functions/functions.go b/cmd/workspace/functions/functions.go index 4b00519ea87..4560a3d08f9 100644 --- a/cmd/workspace/functions/functions.go +++ b/cmd/workspace/functions/functions.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucfunctions "github.com/databricks/cli/libs/sdktypes/uc/functions/v1" + sdkucfunctions "github.com/databricks/sdk-go/uc/functions/v1" ) // Slice with functions to override default command behavior. @@ -57,13 +60,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateFunctionRequest, + *ucfunctions.CreateFunctionRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq ucfunctions.CreateFunctionRequest - var createReq catalog.CreateFunctionRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -88,6 +91,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -104,12 +108,20 @@ func newCreate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Functions.Create(ctx, createReq) + sdkReq, err := ucfunctions.CreateFunctionRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Functions.CreateFunction(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucfunctions.FunctionInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -130,15 +142,14 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteFunctionRequest, + *ucfunctions.DeleteFunctionRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq ucfunctions.DeleteFunctionRequest - var deleteReq catalog.DeleteFunctionRequest - - cmd.Flags().BoolVar(&deleteReq.Force, "force", deleteReq.Force, `Force deletion even if the function is notempty.`) + flags.BoolPtrVar(cmd.Flags(), &deleteReq.Force, "force", `Force deletion even if the function is notempty.`) cmd.Use = "delete NAME" cmd.Short = `Delete a function.` @@ -163,11 +174,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Functions drop-down.") - names, err := w.Functions.FunctionInfoNameToFullNameMap(ctx, catalog.ListFunctionsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Functions.ListFunctionsIter(ctx, sdkucfunctions.ListFunctionsRequest{}), []string{"Name"}, []string{"FullName"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Functions drop-down. Please manually specify required arguments. Original error: %w", err) @@ -181,12 +193,18 @@ func newDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the fully-qualified name of the function (of the form __catalog_name__.__schema_name__.__function__name__) ") } - deleteReq.Name = args[0] + deleteReq.FullNameArg = new(args[0]) - err = w.Functions.Delete(ctx, deleteReq) + sdkReq, err := ucfunctions.DeleteFunctionRequestToSDK(&deleteReq) if err != nil { return err } + response, err := w.Functions.DeleteFunction(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -208,15 +226,14 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetFunctionRequest, + *ucfunctions.GetFunctionRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq ucfunctions.GetFunctionRequest - var getReq catalog.GetFunctionRequest - - cmd.Flags().BoolVar(&getReq.IncludeBrowse, "include-browse", getReq.IncludeBrowse, `Whether to include functions in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeBrowse, "include-browse", `Whether to include functions in the response for which the principal can only access selective metadata for.`) cmd.Use = "get NAME" cmd.Short = `Get a function.` @@ -242,11 +259,12 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Functions drop-down.") - names, err := w.Functions.FunctionInfoNameToFullNameMap(ctx, catalog.ListFunctionsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Functions.ListFunctionsIter(ctx, sdkucfunctions.ListFunctionsRequest{}), []string{"Name"}, []string{"FullName"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Functions drop-down. Please manually specify required arguments. Original error: %w", err) @@ -260,14 +278,22 @@ func newGet() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the fully-qualified name of the function (of the form __catalog_name__.__schema_name__.__function__name__)") } - getReq.Name = args[0] + getReq.FullNameArg = new(args[0]) - response, err := w.Functions.Get(ctx, getReq) + sdkReq, err := ucfunctions.GetFunctionRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.Functions.GetFunction(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucfunctions.FunctionInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -288,27 +314,27 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListFunctionsRequest, + *ucfunctions.ListFunctionsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq ucfunctions.ListFunctionsRequest - var listReq catalog.ListFunctionsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().BoolVar(&listReq.IncludeBrowse, "include-browse", listReq.IncludeBrowse, `Whether to include functions in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeBrowse, "include-browse", `Whether to include functions in the response for which the principal can only access selective metadata for.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of functions to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of functions to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list CATALOG_NAME SCHEMA_NAME" @@ -348,19 +374,23 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.CatalogName = args[0] - listReq.SchemaName = args[1] + listReq.CatalogName = new(args[0]) + listReq.SchemaName = new(args[1]) - response := w.Functions.List(ctx, listReq) + sdkReq, err := ucfunctions.ListFunctionsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Functions.ListFunctionsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucfunctions.FunctionInfoFromSDK)) } // Disable completions since they are not applicable. @@ -381,18 +411,18 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateFunction, + *ucfunctions.UpdateFunctionRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucfunctions.UpdateFunctionRequest - var updateReq catalog.UpdateFunction 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.Owner, "owner", updateReq.Owner, `Username of current owner of the function.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `Username of current owner of the function.`) cmd.Use = "update NAME" cmd.Short = `Update a function.` @@ -419,6 +449,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -435,7 +466,7 @@ func newUpdate() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Functions drop-down.") - names, err := w.Functions.FunctionInfoNameToFullNameMap(ctx, catalog.ListFunctionsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Functions.ListFunctionsIter(ctx, sdkucfunctions.ListFunctionsRequest{}), []string{"Name"}, []string{"FullName"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Functions drop-down. Please manually specify required arguments. Original error: %w", err) @@ -449,14 +480,22 @@ func newUpdate() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the fully-qualified name of the function (of the form __catalog_name__.__schema_name__.__function__name__)") } - updateReq.Name = args[0] + updateReq.FullNameArg = new(args[0]) - response, err := w.Functions.Update(ctx, updateReq) + sdkReq, err := ucfunctions.UpdateFunctionRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Functions.UpdateFunction(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucfunctions.FunctionInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/genie/genie.go b/cmd/workspace/genie/genie.go index 4d4e9dda5ac..b647881fb8e 100644 --- a/cmd/workspace/genie/genie.go +++ b/cmd/workspace/genie/genie.go @@ -7,12 +7,21 @@ import ( "fmt" "time" + "net/url" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/dashboards" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + genie "github.com/databricks/cli/libs/sdktypes/genie/v1" + sdkgenie "github.com/databricks/sdk-go/genie/v1" ) // Slice with functions to override default command behavior. @@ -82,13 +91,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createMessageOverrides []func( *cobra.Command, - *dashboards.GenieCreateConversationMessageRequest, + *genie.GenieCreateConversationMessageRequest, ) func newCreateMessage() *cobra.Command { cmd := &cobra.Command{} + var createMessageReq genie.GenieCreateConversationMessageRequest - var createMessageReq dashboards.GenieCreateConversationMessageRequest var createMessageJson flags.JsonFlag var createMessageSkipWait bool @@ -99,7 +108,7 @@ func newCreateMessage() *cobra.Command { cmd.Flags().Var(&createMessageJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createMessageReq.EnableVisualization, "enable-visualization", createMessageReq.EnableVisualization, `Enable visualization generation.`) + flags.BoolPtrVar(cmd.Flags(), &createMessageReq.EnableVisualization, "enable-visualization", `Enable visualization generation.`) cmd.Use = "create-message SPACE_ID CONVERSATION_ID CONTENT" cmd.Short = `Chat mode: Send a message.` @@ -134,6 +143,7 @@ func newCreateMessage() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createMessageJson.Unmarshal(&createMessageReq) @@ -147,30 +157,45 @@ func newCreateMessage() *cobra.Command { } } } - createMessageReq.SpaceId = args[0] - createMessageReq.ConversationId = args[1] + createMessageReq.SpaceId = new(args[0]) + createMessageReq.ConversationId = new(args[1]) if !cmd.Flags().Changed("json") { - createMessageReq.Content = args[2] + createMessageReq.Content = new(args[2]) } - wait, err := w.Genie.CreateMessage(ctx, createMessageReq) + sdkReq, err := genie.GenieCreateConversationMessageRequestToSDK(&createMessageReq) if err != nil { return err } if createMessageSkipWait { - return cmdio.Render(ctx, wait.Response) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var current genie.GenieMessage + err = api.Do(ctx, "POST", fmt.Sprintf("/api/2.0/genie/spaces/%s/conversations/%s/messages", url.PathEscape(fmt.Sprint(utils.Deref(createMessageReq.SpaceId))), url.PathEscape(fmt.Sprint(utils.Deref(createMessageReq.ConversationId)))), auth.WorkspaceIDHeaders(w.Config), nil, &createMessageReq, ¤t) + if err != nil { + return err + } + return cmdio.Render(ctx, current) + } + wait, err := w.Genie.GenieCreateConversationMessage(ctx, *sdkReq) + if err != nil { + return err } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *dashboards.GenieMessage) { - status := i.Status - statusMessage := fmt.Sprintf("current status: %s", status) - sp.Update(statusMessage) - }).GetWithTimeout(createMessageTimeout) + sp.Update("Waiting for create-message to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createMessageTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := genie.GenieMessageFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -191,13 +216,13 @@ func newCreateMessage() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createMessageCommentOverrides []func( *cobra.Command, - *dashboards.GenieCreateMessageCommentRequest, + *genie.GenieCreateMessageCommentRequest, ) func newCreateMessageComment() *cobra.Command { cmd := &cobra.Command{} + var createMessageCommentReq genie.GenieCreateMessageCommentRequest - var createMessageCommentReq dashboards.GenieCreateMessageCommentRequest var createMessageCommentJson flags.JsonFlag cmd.Flags().Var(&createMessageCommentJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -236,6 +261,7 @@ Add a comment to a message. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createMessageCommentJson.Unmarshal(&createMessageCommentReq) @@ -249,19 +275,27 @@ Add a comment to a message. } } } - createMessageCommentReq.SpaceId = args[0] - createMessageCommentReq.ConversationId = args[1] - createMessageCommentReq.MessageId = args[2] + createMessageCommentReq.SpaceId = new(args[0]) + createMessageCommentReq.ConversationId = new(args[1]) + createMessageCommentReq.MessageId = new(args[2]) if !cmd.Flags().Changed("json") { - createMessageCommentReq.Content = args[3] + createMessageCommentReq.Content = new(args[3]) } - response, err := w.Genie.CreateMessageComment(ctx, createMessageCommentReq) + sdkReq, err := genie.GenieCreateMessageCommentRequestToSDK(&createMessageCommentReq) + if err != nil { + return err + } + response, err := w.Genie.GenieCreateMessageComment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieMessageCommentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -282,20 +316,20 @@ Add a comment to a message. // Functions can be added from the `init()` function in manually curated files in this directory. var createSpaceOverrides []func( *cobra.Command, - *dashboards.GenieCreateSpaceRequest, + *genie.GenieCreateSpaceRequest, ) func newCreateSpace() *cobra.Command { cmd := &cobra.Command{} + var createSpaceReq genie.GenieCreateSpaceRequest - var createSpaceReq dashboards.GenieCreateSpaceRequest var createSpaceJson flags.JsonFlag cmd.Flags().Var(&createSpaceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createSpaceReq.Description, "description", createSpaceReq.Description, `Optional description.`) - cmd.Flags().StringVar(&createSpaceReq.ParentPath, "parent-path", createSpaceReq.ParentPath, `Parent folder path where the space will be registered.`) - cmd.Flags().StringVar(&createSpaceReq.Title, "title", createSpaceReq.Title, `Optional title override.`) + flags.StringPtrVar(cmd.Flags(), &createSpaceReq.Description, "description", `Optional description.`) + flags.StringPtrVar(cmd.Flags(), &createSpaceReq.ParentPath, "parent-path", `Parent folder path where the space will be registered.`) + flags.StringPtrVar(cmd.Flags(), &createSpaceReq.Title, "title", `Optional title override.`) cmd.Use = "create-space WAREHOUSE_ID SERIALIZED_SPACE" cmd.Short = `Create a Genie space.` @@ -331,6 +365,7 @@ func newCreateSpace() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createSpaceJson.Unmarshal(&createSpaceReq) @@ -345,18 +380,26 @@ func newCreateSpace() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createSpaceReq.WarehouseId = args[0] + createSpaceReq.WarehouseId = new(args[0]) } if !cmd.Flags().Changed("json") { - createSpaceReq.SerializedSpace = args[1] + createSpaceReq.SerializedSpace = new(args[1]) } - response, err := w.Genie.CreateSpace(ctx, createSpaceReq) + sdkReq, err := genie.GenieCreateSpaceRequestToSDK(&createSpaceReq) + if err != nil { + return err + } + response, err := w.Genie.CreateSpace(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieSpaceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -377,13 +420,12 @@ func newCreateSpace() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteConversationOverrides []func( *cobra.Command, - *dashboards.GenieDeleteConversationRequest, + *sdkgenie.GenieDeleteConversationRequest, ) func newDeleteConversation() *cobra.Command { cmd := &cobra.Command{} - - var deleteConversationReq dashboards.GenieDeleteConversationRequest + var deleteConversationReq sdkgenie.GenieDeleteConversationRequest cmd.Use = "delete-conversation SPACE_ID CONVERSATION_ID" cmd.Short = `Delete a conversation.` @@ -406,11 +448,13 @@ func newDeleteConversation() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteConversationReq.SpaceId = args[0] - deleteConversationReq.ConversationId = args[1] + deleteConversationReq.SpaceId = new(args[0]) + deleteConversationReq.ConversationId = new(args[1]) - err = w.Genie.DeleteConversation(ctx, deleteConversationReq) + sdkReq := &deleteConversationReq + err = w.Genie.GenieDeleteConversation(ctx, *sdkReq) if err != nil { return err } @@ -435,13 +479,12 @@ func newDeleteConversation() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteConversationMessageOverrides []func( *cobra.Command, - *dashboards.GenieDeleteConversationMessageRequest, + *sdkgenie.GenieDeleteConversationMessageRequest, ) func newDeleteConversationMessage() *cobra.Command { cmd := &cobra.Command{} - - var deleteConversationMessageReq dashboards.GenieDeleteConversationMessageRequest + var deleteConversationMessageReq sdkgenie.GenieDeleteConversationMessageRequest cmd.Use = "delete-conversation-message SPACE_ID CONVERSATION_ID MESSAGE_ID" cmd.Short = `Delete a conversation message.` @@ -465,12 +508,14 @@ func newDeleteConversationMessage() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteConversationMessageReq.SpaceId = args[0] - deleteConversationMessageReq.ConversationId = args[1] - deleteConversationMessageReq.MessageId = args[2] + deleteConversationMessageReq.SpaceId = new(args[0]) + deleteConversationMessageReq.ConversationId = new(args[1]) + deleteConversationMessageReq.MessageId = new(args[2]) - err = w.Genie.DeleteConversationMessage(ctx, deleteConversationMessageReq) + sdkReq := &deleteConversationMessageReq + err = w.Genie.GenieDeleteConversationMessage(ctx, *sdkReq) if err != nil { return err } @@ -495,13 +540,12 @@ func newDeleteConversationMessage() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var downloadMessageAttachmentVisualizationOverrides []func( *cobra.Command, - *dashboards.DownloadMessageAttachmentVisualizationRequest, + *sdkgenie.DownloadMessageAttachmentVisualizationRequest, ) func newDownloadMessageAttachmentVisualization() *cobra.Command { cmd := &cobra.Command{} - - var downloadMessageAttachmentVisualizationReq dashboards.DownloadMessageAttachmentVisualizationRequest + var downloadMessageAttachmentVisualizationReq sdkgenie.DownloadMessageAttachmentVisualizationRequest cmd.Use = "download-message-attachment-visualization NAME" cmd.Short = `Download an attachment visualization.` @@ -528,16 +572,18 @@ func newDownloadMessageAttachmentVisualization() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - downloadMessageAttachmentVisualizationReq.Name = args[0] + downloadMessageAttachmentVisualizationReq.Name = new(args[0]) - response, err := w.Genie.DownloadMessageAttachmentVisualization(ctx, downloadMessageAttachmentVisualizationReq) + sdkReq := &downloadMessageAttachmentVisualizationReq + response, err := w.Genie.DownloadMessageAttachmentVisualization(ctx, *sdkReq) if err != nil { return err } - defer response.Contents.Close() - return cmdio.Render(ctx, response.Contents) + _ = response + return nil } // Disable completions since they are not applicable. @@ -558,13 +604,12 @@ func newDownloadMessageAttachmentVisualization() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var executeMessageAttachmentQueryOverrides []func( *cobra.Command, - *dashboards.GenieExecuteMessageAttachmentQueryRequest, + *genie.GenieExecuteMessageAttachmentQueryRequest, ) func newExecuteMessageAttachmentQuery() *cobra.Command { cmd := &cobra.Command{} - - var executeMessageAttachmentQueryReq dashboards.GenieExecuteMessageAttachmentQueryRequest + var executeMessageAttachmentQueryReq genie.GenieExecuteMessageAttachmentQueryRequest cmd.Use = "execute-message-attachment-query SPACE_ID CONVERSATION_ID MESSAGE_ID ATTACHMENT_ID" cmd.Short = `Execute an attachment SQL query.` @@ -592,18 +637,27 @@ func newExecuteMessageAttachmentQuery() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - executeMessageAttachmentQueryReq.SpaceId = args[0] - executeMessageAttachmentQueryReq.ConversationId = args[1] - executeMessageAttachmentQueryReq.MessageId = args[2] - executeMessageAttachmentQueryReq.AttachmentId = args[3] + executeMessageAttachmentQueryReq.SpaceId = new(args[0]) + executeMessageAttachmentQueryReq.ConversationId = new(args[1]) + executeMessageAttachmentQueryReq.MessageId = new(args[2]) + executeMessageAttachmentQueryReq.AttachmentId = new(args[3]) - response, err := w.Genie.ExecuteMessageAttachmentQuery(ctx, executeMessageAttachmentQueryReq) + sdkReq, err := genie.GenieExecuteMessageAttachmentQueryRequestToSDK(&executeMessageAttachmentQueryReq) + if err != nil { + return err + } + response, err := w.Genie.GenieExecuteMessageAttachmentQuery(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieGetMessageQueryResultResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -624,13 +678,12 @@ func newExecuteMessageAttachmentQuery() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var executeMessageQueryOverrides []func( *cobra.Command, - *dashboards.GenieExecuteMessageQueryRequest, + *genie.GenieExecuteMessageQueryRequest, ) func newExecuteMessageQuery() *cobra.Command { cmd := &cobra.Command{} - - var executeMessageQueryReq dashboards.GenieExecuteMessageQueryRequest + var executeMessageQueryReq genie.GenieExecuteMessageQueryRequest cmd.Use = "execute-message-query SPACE_ID CONVERSATION_ID MESSAGE_ID" cmd.Short = `[Deprecated] Execute SQL query in a conversation message.` @@ -660,17 +713,26 @@ func newExecuteMessageQuery() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - executeMessageQueryReq.SpaceId = args[0] - executeMessageQueryReq.ConversationId = args[1] - executeMessageQueryReq.MessageId = args[2] + executeMessageQueryReq.SpaceId = new(args[0]) + executeMessageQueryReq.ConversationId = new(args[1]) + executeMessageQueryReq.MessageId = new(args[2]) - response, err := w.Genie.ExecuteMessageQuery(ctx, executeMessageQueryReq) + sdkReq, err := genie.GenieExecuteMessageQueryRequestToSDK(&executeMessageQueryReq) + if err != nil { + return err + } + response, err := w.Genie.GenieExecuteMessageQuery(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieGetMessageQueryResultResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -691,13 +753,12 @@ func newExecuteMessageQuery() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var generateDownloadFullQueryResultOverrides []func( *cobra.Command, - *dashboards.GenieGenerateDownloadFullQueryResultRequest, + *genie.GenieGenerateDownloadFullQueryResultRequest, ) func newGenerateDownloadFullQueryResult() *cobra.Command { cmd := &cobra.Command{} - - var generateDownloadFullQueryResultReq dashboards.GenieGenerateDownloadFullQueryResultRequest + var generateDownloadFullQueryResultReq genie.GenieGenerateDownloadFullQueryResultRequest cmd.Use = "generate-download-full-query-result SPACE_ID CONVERSATION_ID MESSAGE_ID ATTACHMENT_ID" cmd.Short = `Start a full query-result download.` @@ -744,18 +805,27 @@ func newGenerateDownloadFullQueryResult() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - generateDownloadFullQueryResultReq.SpaceId = args[0] - generateDownloadFullQueryResultReq.ConversationId = args[1] - generateDownloadFullQueryResultReq.MessageId = args[2] - generateDownloadFullQueryResultReq.AttachmentId = args[3] + generateDownloadFullQueryResultReq.SpaceId = new(args[0]) + generateDownloadFullQueryResultReq.ConversationId = new(args[1]) + generateDownloadFullQueryResultReq.MessageId = new(args[2]) + generateDownloadFullQueryResultReq.AttachmentId = new(args[3]) - response, err := w.Genie.GenerateDownloadFullQueryResult(ctx, generateDownloadFullQueryResultReq) + sdkReq, err := genie.GenieGenerateDownloadFullQueryResultRequestToSDK(&generateDownloadFullQueryResultReq) + if err != nil { + return err + } + response, err := w.Genie.GenieGenerateDownloadFullQueryResult(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieGenerateDownloadFullQueryResultResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -776,13 +846,12 @@ func newGenerateDownloadFullQueryResult() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var genieCancelResponseOverrides []func( *cobra.Command, - *dashboards.GenieCancelResponseRequest, + *genie.GenieCancelResponseRequest, ) func newGenieCancelResponse() *cobra.Command { cmd := &cobra.Command{} - - var genieCancelResponseReq dashboards.GenieCancelResponseRequest + var genieCancelResponseReq genie.GenieCancelResponseRequest cmd.Use = "genie-cancel-response AGENT_ID CONVERSATION_ID RESPONSE_ID" cmd.Short = `Agent mode: Cancel a response.` @@ -811,17 +880,26 @@ func newGenieCancelResponse() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - genieCancelResponseReq.AgentId = args[0] - genieCancelResponseReq.ConversationId = args[1] - genieCancelResponseReq.ResponseId = args[2] + genieCancelResponseReq.AgentId = new(args[0]) + genieCancelResponseReq.ConversationId = new(args[1]) + genieCancelResponseReq.ResponseId = new(args[2]) - response, err := w.Genie.GenieCancelResponse(ctx, genieCancelResponseReq) + sdkReq, err := genie.GenieCancelResponseRequestToSDK(&genieCancelResponseReq) + if err != nil { + return err + } + response, err := w.Genie.GenieCancelResponse(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieMessageFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -842,13 +920,13 @@ func newGenieCancelResponse() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var genieCreateEvalRunOverrides []func( *cobra.Command, - *dashboards.GenieCreateEvalRunRequest, + *genie.GenieCreateEvalRunRequest, ) func newGenieCreateEvalRun() *cobra.Command { cmd := &cobra.Command{} + var genieCreateEvalRunReq genie.GenieCreateEvalRunRequest - 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`) @@ -881,6 +959,7 @@ Start a benchmark evaluation run. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := genieCreateEvalRunJson.Unmarshal(&genieCreateEvalRunReq) @@ -894,14 +973,22 @@ Start a benchmark evaluation run. } } } - genieCreateEvalRunReq.SpaceId = args[0] + genieCreateEvalRunReq.SpaceId = new(args[0]) - response, err := w.Genie.GenieCreateEvalRun(ctx, genieCreateEvalRunReq) + sdkReq, err := genie.GenieCreateEvalRunRequestToSDK(&genieCreateEvalRunReq) + if err != nil { + return err + } + response, err := w.Genie.GenieCreateEvalRun(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieEvalRunResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -922,13 +1009,12 @@ Start a benchmark evaluation run. // Functions can be added from the `init()` function in manually curated files in this directory. var genieGetEvalResultDetailsOverrides []func( *cobra.Command, - *dashboards.GenieGetEvalResultDetailsRequest, + *sdkgenie.GenieGetEvalResultDetailsRequest, ) func newGenieGetEvalResultDetails() *cobra.Command { cmd := &cobra.Command{} - - var genieGetEvalResultDetailsReq dashboards.GenieGetEvalResultDetailsRequest + var genieGetEvalResultDetailsReq sdkgenie.GenieGetEvalResultDetailsRequest cmd.Use = "genie-get-eval-result-details SPACE_ID EVAL_RUN_ID RESULT_ID" cmd.Short = `*Beta* Get benchmark evaluation result details.` @@ -957,17 +1043,23 @@ Get benchmark evaluation result details. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - genieGetEvalResultDetailsReq.SpaceId = args[0] - genieGetEvalResultDetailsReq.EvalRunId = args[1] - genieGetEvalResultDetailsReq.ResultId = args[2] + genieGetEvalResultDetailsReq.SpaceId = new(args[0]) + genieGetEvalResultDetailsReq.EvalRunId = new(args[1]) + genieGetEvalResultDetailsReq.ResultId = new(args[2]) - response, err := w.Genie.GenieGetEvalResultDetails(ctx, genieGetEvalResultDetailsReq) + sdkReq := &genieGetEvalResultDetailsReq + response, err := w.Genie.GenieGetEvalResultDetails(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieEvalResultDetailsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -988,13 +1080,12 @@ Get benchmark evaluation result details. // Functions can be added from the `init()` function in manually curated files in this directory. var genieGetEvalRunOverrides []func( *cobra.Command, - *dashboards.GenieGetEvalRunRequest, + *sdkgenie.GenieGetEvalRunRequest, ) func newGenieGetEvalRun() *cobra.Command { cmd := &cobra.Command{} - - var genieGetEvalRunReq dashboards.GenieGetEvalRunRequest + var genieGetEvalRunReq sdkgenie.GenieGetEvalRunRequest cmd.Use = "genie-get-eval-run SPACE_ID EVAL_RUN_ID" cmd.Short = `*Beta* Get a benchmark evaluation run.` @@ -1022,16 +1113,22 @@ Get a benchmark evaluation run. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - genieGetEvalRunReq.SpaceId = args[0] - genieGetEvalRunReq.EvalRunId = args[1] + genieGetEvalRunReq.SpaceId = new(args[0]) + genieGetEvalRunReq.EvalRunId = new(args[1]) - response, err := w.Genie.GenieGetEvalRun(ctx, genieGetEvalRunReq) + sdkReq := &genieGetEvalRunReq + response, err := w.Genie.GenieGetEvalRun(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieEvalRunResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1052,16 +1149,15 @@ Get a benchmark evaluation run. // Functions can be added from the `init()` function in manually curated files in this directory. var genieListEvalResultsOverrides []func( *cobra.Command, - *dashboards.GenieListEvalResultsRequest, + *genie.GenieListEvalResultsRequest, ) func newGenieListEvalResults() *cobra.Command { cmd := &cobra.Command{} + var genieListEvalResultsReq genie.GenieListEvalResultsRequest - 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.`) + flags.IntPtrVar(cmd.Flags(), &genieListEvalResultsReq.PageSize, "page-size", `Maximum number of eval results to return per page.`) + flags.StringPtrVar(cmd.Flags(), &genieListEvalResultsReq.PageToken, "page-token", `Opaque token to retrieve the next page of results.`) cmd.Use = "genie-list-eval-results SPACE_ID EVAL_RUN_ID" cmd.Short = `*Beta* List results for a benchmark evaluation run.` @@ -1089,16 +1185,25 @@ List results for a benchmark evaluation run. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - genieListEvalResultsReq.SpaceId = args[0] - genieListEvalResultsReq.EvalRunId = args[1] + genieListEvalResultsReq.SpaceId = new(args[0]) + genieListEvalResultsReq.EvalRunId = new(args[1]) - response, err := w.Genie.GenieListEvalResults(ctx, genieListEvalResultsReq) + sdkReq, err := genie.GenieListEvalResultsRequestToSDK(&genieListEvalResultsReq) + if err != nil { + return err + } + response, err := w.Genie.GenieListEvalResults(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieListEvalResultsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1119,16 +1224,15 @@ List results for a benchmark evaluation run. // Functions can be added from the `init()` function in manually curated files in this directory. var genieListEvalRunsOverrides []func( *cobra.Command, - *dashboards.GenieListEvalRunsRequest, + *genie.GenieListEvalRunsRequest, ) func newGenieListEvalRuns() *cobra.Command { cmd := &cobra.Command{} + var genieListEvalRunsReq genie.GenieListEvalRunsRequest - 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.`) + flags.IntPtrVar(cmd.Flags(), &genieListEvalRunsReq.PageSize, "page-size", `Maximum number of evaluation runs to return per page.`) + flags.StringPtrVar(cmd.Flags(), &genieListEvalRunsReq.PageToken, "page-token", `Token to get the next page of results.`) cmd.Use = "genie-list-eval-runs SPACE_ID" cmd.Short = `*Beta* List benchmark evaluation runs.` @@ -1155,15 +1259,24 @@ List benchmark evaluation runs. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - genieListEvalRunsReq.SpaceId = args[0] + genieListEvalRunsReq.SpaceId = new(args[0]) - response, err := w.Genie.GenieListEvalRuns(ctx, genieListEvalRunsReq) + sdkReq, err := genie.GenieListEvalRunsRequestToSDK(&genieListEvalRunsReq) + if err != nil { + return err + } + response, err := w.Genie.GenieListEvalRuns(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieListEvalRunsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1184,13 +1297,12 @@ List benchmark evaluation runs. // Functions can be added from the `init()` function in manually curated files in this directory. var getDownloadFullQueryResultOverrides []func( *cobra.Command, - *dashboards.GenieGetDownloadFullQueryResultRequest, + *genie.GenieGetDownloadFullQueryResultRequest, ) func newGetDownloadFullQueryResult() *cobra.Command { cmd := &cobra.Command{} - - var getDownloadFullQueryResultReq dashboards.GenieGetDownloadFullQueryResultRequest + var getDownloadFullQueryResultReq genie.GenieGetDownloadFullQueryResultRequest cmd.Use = "get-download-full-query-result SPACE_ID CONVERSATION_ID MESSAGE_ID ATTACHMENT_ID DOWNLOAD_ID DOWNLOAD_ID_SIGNATURE" cmd.Short = `Get full query-result download status.` @@ -1241,20 +1353,29 @@ func newGetDownloadFullQueryResult() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getDownloadFullQueryResultReq.SpaceId = args[0] - getDownloadFullQueryResultReq.ConversationId = args[1] - getDownloadFullQueryResultReq.MessageId = args[2] - getDownloadFullQueryResultReq.AttachmentId = args[3] - getDownloadFullQueryResultReq.DownloadId = args[4] - getDownloadFullQueryResultReq.DownloadIdSignature = args[5] + getDownloadFullQueryResultReq.SpaceId = new(args[0]) + getDownloadFullQueryResultReq.ConversationId = new(args[1]) + getDownloadFullQueryResultReq.MessageId = new(args[2]) + getDownloadFullQueryResultReq.AttachmentId = new(args[3]) + getDownloadFullQueryResultReq.DownloadId = new(args[4]) + getDownloadFullQueryResultReq.DownloadIdSignature = new(args[5]) - response, err := w.Genie.GetDownloadFullQueryResult(ctx, getDownloadFullQueryResultReq) + sdkReq, err := genie.GenieGetDownloadFullQueryResultRequestToSDK(&getDownloadFullQueryResultReq) + if err != nil { + return err + } + response, err := w.Genie.GenieGetDownloadFullQueryResult(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieGetDownloadFullQueryResultResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1275,13 +1396,12 @@ func newGetDownloadFullQueryResult() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getMessageOverrides []func( *cobra.Command, - *dashboards.GenieGetConversationMessageRequest, + *sdkgenie.GenieGetConversationMessageRequest, ) func newGetMessage() *cobra.Command { cmd := &cobra.Command{} - - var getMessageReq dashboards.GenieGetConversationMessageRequest + var getMessageReq sdkgenie.GenieGetConversationMessageRequest cmd.Use = "get-message SPACE_ID CONVERSATION_ID MESSAGE_ID" cmd.Short = `Get a conversation message.` @@ -1310,17 +1430,23 @@ func newGetMessage() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getMessageReq.SpaceId = args[0] - getMessageReq.ConversationId = args[1] - getMessageReq.MessageId = args[2] + getMessageReq.SpaceId = new(args[0]) + getMessageReq.ConversationId = new(args[1]) + getMessageReq.MessageId = new(args[2]) - response, err := w.Genie.GetMessage(ctx, getMessageReq) + sdkReq := &getMessageReq + response, err := w.Genie.GenieGetConversationMessage(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieMessageFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1341,13 +1467,12 @@ func newGetMessage() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getMessageAttachmentQueryResultOverrides []func( *cobra.Command, - *dashboards.GenieGetMessageAttachmentQueryResultRequest, + *sdkgenie.GenieGetMessageAttachmentQueryResultRequest, ) func newGetMessageAttachmentQueryResult() *cobra.Command { cmd := &cobra.Command{} - - var getMessageAttachmentQueryResultReq dashboards.GenieGetMessageAttachmentQueryResultRequest + var getMessageAttachmentQueryResultReq sdkgenie.GenieGetMessageAttachmentQueryResultRequest cmd.Use = "get-message-attachment-query-result SPACE_ID CONVERSATION_ID MESSAGE_ID ATTACHMENT_ID" cmd.Short = `Get an attachment SQL result.` @@ -1376,18 +1501,24 @@ func newGetMessageAttachmentQueryResult() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getMessageAttachmentQueryResultReq.SpaceId = args[0] - getMessageAttachmentQueryResultReq.ConversationId = args[1] - getMessageAttachmentQueryResultReq.MessageId = args[2] - getMessageAttachmentQueryResultReq.AttachmentId = args[3] + getMessageAttachmentQueryResultReq.SpaceId = new(args[0]) + getMessageAttachmentQueryResultReq.ConversationId = new(args[1]) + getMessageAttachmentQueryResultReq.MessageId = new(args[2]) + getMessageAttachmentQueryResultReq.AttachmentId = new(args[3]) - response, err := w.Genie.GetMessageAttachmentQueryResult(ctx, getMessageAttachmentQueryResultReq) + sdkReq := &getMessageAttachmentQueryResultReq + response, err := w.Genie.GenieGetMessageAttachmentQueryResult(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieGetMessageQueryResultResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1408,13 +1539,12 @@ func newGetMessageAttachmentQueryResult() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getMessageQueryResultOverrides []func( *cobra.Command, - *dashboards.GenieGetMessageQueryResultRequest, + *sdkgenie.GenieGetMessageQueryResultRequest, ) func newGetMessageQueryResult() *cobra.Command { cmd := &cobra.Command{} - - var getMessageQueryResultReq dashboards.GenieGetMessageQueryResultRequest + var getMessageQueryResultReq sdkgenie.GenieGetMessageQueryResultRequest cmd.Use = "get-message-query-result SPACE_ID CONVERSATION_ID MESSAGE_ID" cmd.Short = `[Deprecated] Get conversation message SQL query result.` @@ -1444,17 +1574,23 @@ func newGetMessageQueryResult() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getMessageQueryResultReq.SpaceId = args[0] - getMessageQueryResultReq.ConversationId = args[1] - getMessageQueryResultReq.MessageId = args[2] + getMessageQueryResultReq.SpaceId = new(args[0]) + getMessageQueryResultReq.ConversationId = new(args[1]) + getMessageQueryResultReq.MessageId = new(args[2]) - response, err := w.Genie.GetMessageQueryResult(ctx, getMessageQueryResultReq) + sdkReq := &getMessageQueryResultReq + response, err := w.Genie.GenieGetMessageQueryResult(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieGetMessageQueryResultResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1475,13 +1611,12 @@ func newGetMessageQueryResult() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getMessageQueryResultByAttachmentOverrides []func( *cobra.Command, - *dashboards.GenieGetQueryResultByAttachmentRequest, + *sdkgenie.GenieGetQueryResultByAttachmentRequest, ) func newGetMessageQueryResultByAttachment() *cobra.Command { cmd := &cobra.Command{} - - var getMessageQueryResultByAttachmentReq dashboards.GenieGetQueryResultByAttachmentRequest + var getMessageQueryResultByAttachmentReq sdkgenie.GenieGetQueryResultByAttachmentRequest cmd.Use = "get-message-query-result-by-attachment SPACE_ID CONVERSATION_ID MESSAGE_ID ATTACHMENT_ID" cmd.Short = `[Deprecated] Get conversation message SQL query result.` @@ -1512,18 +1647,24 @@ func newGetMessageQueryResultByAttachment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getMessageQueryResultByAttachmentReq.SpaceId = args[0] - getMessageQueryResultByAttachmentReq.ConversationId = args[1] - getMessageQueryResultByAttachmentReq.MessageId = args[2] - getMessageQueryResultByAttachmentReq.AttachmentId = args[3] + getMessageQueryResultByAttachmentReq.SpaceId = new(args[0]) + getMessageQueryResultByAttachmentReq.ConversationId = new(args[1]) + getMessageQueryResultByAttachmentReq.MessageId = new(args[2]) + getMessageQueryResultByAttachmentReq.AttachmentId = new(args[3]) - response, err := w.Genie.GetMessageQueryResultByAttachment(ctx, getMessageQueryResultByAttachmentReq) + sdkReq := &getMessageQueryResultByAttachmentReq + response, err := w.Genie.GenieGetQueryResultByAttachment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieGetMessageQueryResultResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1544,15 +1685,14 @@ func newGetMessageQueryResultByAttachment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getSpaceOverrides []func( *cobra.Command, - *dashboards.GenieGetSpaceRequest, + *genie.GenieGetSpaceRequest, ) func newGetSpace() *cobra.Command { cmd := &cobra.Command{} + var getSpaceReq genie.GenieGetSpaceRequest - var getSpaceReq dashboards.GenieGetSpaceRequest - - cmd.Flags().BoolVar(&getSpaceReq.IncludeSerializedSpace, "include-serialized-space", getSpaceReq.IncludeSerializedSpace, `Whether to include the serialized space export in the response.`) + flags.BoolPtrVar(cmd.Flags(), &getSpaceReq.IncludeSerializedSpace, "include-serialized-space", `Whether to include the serialized space export in the response.`) cmd.Use = "get-space SPACE_ID" cmd.Short = `Get a Genie space.` @@ -1576,15 +1716,24 @@ func newGetSpace() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSpaceReq.SpaceId = args[0] + getSpaceReq.SpaceId = new(args[0]) - response, err := w.Genie.GetSpace(ctx, getSpaceReq) + sdkReq, err := genie.GenieGetSpaceRequestToSDK(&getSpaceReq) + if err != nil { + return err + } + response, err := w.Genie.GenieGetSpace(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieSpaceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1605,16 +1754,15 @@ func newGetSpace() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listConversationCommentsOverrides []func( *cobra.Command, - *dashboards.GenieListConversationCommentsRequest, + *genie.GenieListConversationCommentsRequest, ) func newListConversationComments() *cobra.Command { cmd := &cobra.Command{} + var listConversationCommentsReq genie.GenieListConversationCommentsRequest - var listConversationCommentsReq dashboards.GenieListConversationCommentsRequest - - cmd.Flags().IntVar(&listConversationCommentsReq.PageSize, "page-size", listConversationCommentsReq.PageSize, `Maximum number of comments to return per page.`) - cmd.Flags().StringVar(&listConversationCommentsReq.PageToken, "page-token", listConversationCommentsReq.PageToken, `Pagination token for getting the next page of results.`) + flags.IntPtrVar(cmd.Flags(), &listConversationCommentsReq.PageSize, "page-size", `Maximum number of comments to return per page.`) + flags.StringPtrVar(cmd.Flags(), &listConversationCommentsReq.PageToken, "page-token", `Pagination token for getting the next page of results.`) cmd.Use = "list-conversation-comments SPACE_ID CONVERSATION_ID" cmd.Short = `*Public Preview* List all comments in a conversation.` @@ -1641,16 +1789,25 @@ List all comments in a conversation. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listConversationCommentsReq.SpaceId = args[0] - listConversationCommentsReq.ConversationId = args[1] + listConversationCommentsReq.SpaceId = new(args[0]) + listConversationCommentsReq.ConversationId = new(args[1]) - response, err := w.Genie.ListConversationComments(ctx, listConversationCommentsReq) + sdkReq, err := genie.GenieListConversationCommentsRequestToSDK(&listConversationCommentsReq) + if err != nil { + return err + } + response, err := w.Genie.GenieListConversationComments(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieListConversationCommentsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1671,16 +1828,15 @@ List all comments in a conversation. // Functions can be added from the `init()` function in manually curated files in this directory. var listConversationMessagesOverrides []func( *cobra.Command, - *dashboards.GenieListConversationMessagesRequest, + *genie.GenieListConversationMessagesRequest, ) func newListConversationMessages() *cobra.Command { cmd := &cobra.Command{} + var listConversationMessagesReq genie.GenieListConversationMessagesRequest - 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.`) + flags.IntPtrVar(cmd.Flags(), &listConversationMessagesReq.PageSize, "page-size", `Maximum number of messages to return per page.`) + flags.StringPtrVar(cmd.Flags(), &listConversationMessagesReq.PageToken, "page-token", `Token to get the next page of results.`) cmd.Use = "list-conversation-messages SPACE_ID CONVERSATION_ID" cmd.Short = `List conversation messages.` @@ -1707,16 +1863,25 @@ func newListConversationMessages() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listConversationMessagesReq.SpaceId = args[0] - listConversationMessagesReq.ConversationId = args[1] + listConversationMessagesReq.SpaceId = new(args[0]) + listConversationMessagesReq.ConversationId = new(args[1]) - response, err := w.Genie.ListConversationMessages(ctx, listConversationMessagesReq) + sdkReq, err := genie.GenieListConversationMessagesRequestToSDK(&listConversationMessagesReq) + if err != nil { + return err + } + response, err := w.Genie.GenieListConversationMessages(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieListConversationMessagesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1737,17 +1902,16 @@ func newListConversationMessages() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listConversationsOverrides []func( *cobra.Command, - *dashboards.GenieListConversationsRequest, + *genie.GenieListConversationsRequest, ) func newListConversations() *cobra.Command { cmd := &cobra.Command{} + var listConversationsReq genie.GenieListConversationsRequest - 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.`) + flags.BoolPtrVar(cmd.Flags(), &listConversationsReq.IncludeAll, "include-all", `Include all conversations in the space across all users.`) + flags.IntPtrVar(cmd.Flags(), &listConversationsReq.PageSize, "page-size", `Maximum number of conversations to return per page.`) + flags.StringPtrVar(cmd.Flags(), &listConversationsReq.PageToken, "page-token", `Token to get the next page of results.`) cmd.Use = "list-conversations SPACE_ID" cmd.Short = `List conversations.` @@ -1771,15 +1935,24 @@ func newListConversations() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listConversationsReq.SpaceId = args[0] + listConversationsReq.SpaceId = new(args[0]) - response, err := w.Genie.ListConversations(ctx, listConversationsReq) + sdkReq, err := genie.GenieListConversationsRequestToSDK(&listConversationsReq) + if err != nil { + return err + } + response, err := w.Genie.GenieListConversations(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieListConversationsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1800,16 +1973,15 @@ func newListConversations() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listMessageCommentsOverrides []func( *cobra.Command, - *dashboards.GenieListMessageCommentsRequest, + *genie.GenieListMessageCommentsRequest, ) func newListMessageComments() *cobra.Command { cmd := &cobra.Command{} + var listMessageCommentsReq genie.GenieListMessageCommentsRequest - var listMessageCommentsReq dashboards.GenieListMessageCommentsRequest - - cmd.Flags().IntVar(&listMessageCommentsReq.PageSize, "page-size", listMessageCommentsReq.PageSize, `Maximum number of comments to return per page.`) - cmd.Flags().StringVar(&listMessageCommentsReq.PageToken, "page-token", listMessageCommentsReq.PageToken, `Pagination token for getting the next page of results.`) + flags.IntPtrVar(cmd.Flags(), &listMessageCommentsReq.PageSize, "page-size", `Maximum number of comments to return per page.`) + flags.StringPtrVar(cmd.Flags(), &listMessageCommentsReq.PageToken, "page-token", `Pagination token for getting the next page of results.`) cmd.Use = "list-message-comments SPACE_ID CONVERSATION_ID MESSAGE_ID" cmd.Short = `*Public Preview* List comments on a message.` @@ -1837,17 +2009,26 @@ List comments on a message. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listMessageCommentsReq.SpaceId = args[0] - listMessageCommentsReq.ConversationId = args[1] - listMessageCommentsReq.MessageId = args[2] + listMessageCommentsReq.SpaceId = new(args[0]) + listMessageCommentsReq.ConversationId = new(args[1]) + listMessageCommentsReq.MessageId = new(args[2]) - response, err := w.Genie.ListMessageComments(ctx, listMessageCommentsReq) + sdkReq, err := genie.GenieListMessageCommentsRequestToSDK(&listMessageCommentsReq) + if err != nil { + return err + } + response, err := w.Genie.GenieListMessageComments(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieListMessageCommentsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1868,16 +2049,15 @@ List comments on a message. // Functions can be added from the `init()` function in manually curated files in this directory. var listSpacesOverrides []func( *cobra.Command, - *dashboards.GenieListSpacesRequest, + *genie.GenieListSpacesRequest, ) func newListSpaces() *cobra.Command { cmd := &cobra.Command{} + var listSpacesReq genie.GenieListSpacesRequest - var listSpacesReq dashboards.GenieListSpacesRequest - - cmd.Flags().IntVar(&listSpacesReq.PageSize, "page-size", listSpacesReq.PageSize, `Maximum number of spaces to return per page.`) - cmd.Flags().StringVar(&listSpacesReq.PageToken, "page-token", listSpacesReq.PageToken, `Pagination token for getting the next page of results.`) + flags.IntPtrVar(cmd.Flags(), &listSpacesReq.PageSize, "page-size", `Maximum number of spaces to return per page.`) + flags.StringPtrVar(cmd.Flags(), &listSpacesReq.PageToken, "page-token", `Pagination token for getting the next page of results.`) cmd.Use = "list-spaces" cmd.Short = `List Genie spaces.` @@ -1898,13 +2078,22 @@ func newListSpaces() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response, err := w.Genie.ListSpaces(ctx, listSpacesReq) + sdkReq, err := genie.GenieListSpacesRequestToSDK(&listSpacesReq) + if err != nil { + return err + } + response, err := w.Genie.GenieListSpaces(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieListSpacesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1925,18 +2114,18 @@ func newListSpaces() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var sendMessageFeedbackOverrides []func( *cobra.Command, - *dashboards.GenieSendMessageFeedbackRequest, + *genie.GenieSendMessageFeedbackRequest, ) func newSendMessageFeedback() *cobra.Command { cmd := &cobra.Command{} + var sendMessageFeedbackReq genie.GenieSendMessageFeedbackRequest - 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.Comment, "comment", sendMessageFeedbackReq.Comment, `Optional text feedback that will be stored as a comment.`) + flags.StringPtrVar(cmd.Flags(), &sendMessageFeedbackReq.Comment, "comment", `Optional text feedback that will be stored as a comment.`) cmd.Use = "send-message-feedback SPACE_ID CONVERSATION_ID MESSAGE_ID RATING" cmd.Short = `Send feedback on a message.` @@ -1971,6 +2160,7 @@ func newSendMessageFeedback() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := sendMessageFeedbackJson.Unmarshal(&sendMessageFeedbackReq) @@ -1984,18 +2174,18 @@ func newSendMessageFeedback() *cobra.Command { } } } - sendMessageFeedbackReq.SpaceId = args[0] - sendMessageFeedbackReq.ConversationId = args[1] - sendMessageFeedbackReq.MessageId = args[2] + sendMessageFeedbackReq.SpaceId = new(args[0]) + sendMessageFeedbackReq.ConversationId = new(args[1]) + sendMessageFeedbackReq.MessageId = new(args[2]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &sendMessageFeedbackReq.Rating) - if err != nil { - return fmt.Errorf("invalid RATING: %s", args[3]) - } - + sendMessageFeedbackReq.Rating = genie.GenieFeedbackRating(args[3]) } - err = w.Genie.SendMessageFeedback(ctx, sendMessageFeedbackReq) + sdkReq, err := genie.GenieSendMessageFeedbackRequestToSDK(&sendMessageFeedbackReq) + if err != nil { + return err + } + err = w.Genie.GenieSendMessageFeedback(ctx, *sdkReq) if err != nil { return err } @@ -2020,13 +2210,13 @@ func newSendMessageFeedback() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var startConversationOverrides []func( *cobra.Command, - *dashboards.GenieStartConversationMessageRequest, + *genie.GenieStartConversationRequest, ) func newStartConversation() *cobra.Command { cmd := &cobra.Command{} + var startConversationReq genie.GenieStartConversationRequest - var startConversationReq dashboards.GenieStartConversationMessageRequest var startConversationJson flags.JsonFlag var startConversationSkipWait bool @@ -2037,7 +2227,7 @@ func newStartConversation() *cobra.Command { cmd.Flags().Var(&startConversationJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&startConversationReq.EnableVisualization, "enable-visualization", startConversationReq.EnableVisualization, `Enable visualization generation.`) + flags.BoolPtrVar(cmd.Flags(), &startConversationReq.EnableVisualization, "enable-visualization", `Enable visualization generation.`) cmd.Use = "start-conversation SPACE_ID CONTENT" cmd.Short = `Chat mode: Start a conversation.` @@ -2070,6 +2260,7 @@ func newStartConversation() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := startConversationJson.Unmarshal(&startConversationReq) @@ -2083,29 +2274,44 @@ func newStartConversation() *cobra.Command { } } } - startConversationReq.SpaceId = args[0] + startConversationReq.SpaceId = new(args[0]) if !cmd.Flags().Changed("json") { - startConversationReq.Content = args[1] + startConversationReq.Content = new(args[1]) } - wait, err := w.Genie.StartConversation(ctx, startConversationReq) + sdkReq, err := genie.GenieStartConversationRequestToSDK(&startConversationReq) if err != nil { return err } if startConversationSkipWait { - return cmdio.Render(ctx, wait.Response) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var current genie.GenieStartConversationResponse + err = api.Do(ctx, "POST", fmt.Sprintf("/api/2.0/genie/spaces/%s/start-conversation", url.PathEscape(fmt.Sprint(utils.Deref(startConversationReq.SpaceId)))), auth.WorkspaceIDHeaders(w.Config), nil, &startConversationReq, ¤t) + if err != nil { + return err + } + return cmdio.Render(ctx, current) + } + wait, err := w.Genie.GenieStartConversation(ctx, *sdkReq) + if err != nil { + return err } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *dashboards.GenieMessage) { - status := i.Status - statusMessage := fmt.Sprintf("current status: %s", status) - sp.Update(statusMessage) - }).GetWithTimeout(startConversationTimeout) + sp.Update("Waiting for start-conversation to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(startConversationTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := genie.GenieMessageFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2126,13 +2332,12 @@ func newStartConversation() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var trashSpaceOverrides []func( *cobra.Command, - *dashboards.GenieTrashSpaceRequest, + *sdkgenie.GenieTrashSpaceRequest, ) func newTrashSpace() *cobra.Command { cmd := &cobra.Command{} - - var trashSpaceReq dashboards.GenieTrashSpaceRequest + var trashSpaceReq sdkgenie.GenieTrashSpaceRequest cmd.Use = "trash-space SPACE_ID" cmd.Short = `Trash a Genie space.` @@ -2156,10 +2361,12 @@ func newTrashSpace() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - trashSpaceReq.SpaceId = args[0] + trashSpaceReq.SpaceId = new(args[0]) - err = w.Genie.TrashSpace(ctx, trashSpaceReq) + sdkReq := &trashSpaceReq + err = w.Genie.GenieTrashSpace(ctx, *sdkReq) if err != nil { return err } @@ -2184,23 +2391,23 @@ func newTrashSpace() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateSpaceOverrides []func( *cobra.Command, - *dashboards.GenieUpdateSpaceRequest, + *genie.GenieUpdateSpaceRequest, ) func newUpdateSpace() *cobra.Command { cmd := &cobra.Command{} + var updateSpaceReq genie.GenieUpdateSpaceRequest - var updateSpaceReq dashboards.GenieUpdateSpaceRequest var updateSpaceJson flags.JsonFlag cmd.Flags().Var(&updateSpaceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateSpaceReq.Description, "description", updateSpaceReq.Description, `Optional description.`) - cmd.Flags().StringVar(&updateSpaceReq.Etag, "etag", updateSpaceReq.Etag, `ETag returned by a previous GET or UPDATE.`) - cmd.Flags().StringVar(&updateSpaceReq.ParentPath, "parent-path", updateSpaceReq.ParentPath, `Parent workspace folder path to move this Genie space under.`) - cmd.Flags().StringVar(&updateSpaceReq.SerializedSpace, "serialized-space", updateSpaceReq.SerializedSpace, `The contents of the Genie Space in serialized string form (full replacement).`) - cmd.Flags().StringVar(&updateSpaceReq.Title, "title", updateSpaceReq.Title, `Optional title override.`) - cmd.Flags().StringVar(&updateSpaceReq.WarehouseId, "warehouse-id", updateSpaceReq.WarehouseId, `Optional warehouse override.`) + flags.StringPtrVar(cmd.Flags(), &updateSpaceReq.Description, "description", `Optional description.`) + flags.StringPtrVar(cmd.Flags(), &updateSpaceReq.Etag, "etag", `ETag returned by a previous GET or UPDATE.`) + flags.StringPtrVar(cmd.Flags(), &updateSpaceReq.ParentPath, "parent-path", `Parent workspace folder path to move this Genie space under.`) + flags.StringPtrVar(cmd.Flags(), &updateSpaceReq.SerializedSpace, "serialized-space", `The contents of the Genie Space in serialized string form (full replacement).`) + flags.StringPtrVar(cmd.Flags(), &updateSpaceReq.Title, "title", `Optional title override.`) + flags.StringPtrVar(cmd.Flags(), &updateSpaceReq.WarehouseId, "warehouse-id", `Optional warehouse override.`) cmd.Use = "update-space SPACE_ID" cmd.Short = `Update a Genie space.` @@ -2224,6 +2431,7 @@ func newUpdateSpace() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateSpaceJson.Unmarshal(&updateSpaceReq) @@ -2237,14 +2445,22 @@ func newUpdateSpace() *cobra.Command { } } } - updateSpaceReq.SpaceId = args[0] + updateSpaceReq.SpaceId = new(args[0]) - response, err := w.Genie.UpdateSpace(ctx, updateSpaceReq) + sdkReq, err := genie.GenieUpdateSpaceRequestToSDK(&updateSpaceReq) + if err != nil { + return err + } + response, err := w.Genie.UpdateSpace(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := genie.GenieSpaceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/git-credentials/git-credentials.go b/cmd/workspace/git-credentials/git-credentials.go index 9288c2b5941..36377e5a670 100644 --- a/cmd/workspace/git-credentials/git-credentials.go +++ b/cmd/workspace/git-credentials/git-credentials.go @@ -10,8 +10,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/workspace" "github.com/spf13/cobra" + + gitcredentials "github.com/databricks/cli/libs/sdktypes/gitcredentials/v1" ) // Slice with functions to override default command behavior. @@ -57,23 +58,23 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *workspace.CreateCredentialsRequest, + *gitcredentials.CreateCredentialsRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq gitcredentials.CreateCredentialsRequest - var createReq workspace.CreateCredentialsRequest 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.GitEmail, "git-email", createReq.GitEmail, `The authenticating email associated with your Git provider user account.`) - cmd.Flags().StringVar(&createReq.GitUsername, "git-username", createReq.GitUsername, `The username provided with your Git provider account and associated with the credential.`) - cmd.Flags().BoolVar(&createReq.IsDefaultForProvider, "is-default-for-provider", createReq.IsDefaultForProvider, `if the credential is the default for the given provider.`) - cmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `the name of the git credential, used for identification and ease of lookup.`) - cmd.Flags().StringVar(&createReq.PersonalAccessToken, "personal-access-token", createReq.PersonalAccessToken, `The personal access token used to authenticate to the corresponding Git provider.`) - cmd.Flags().Int64Var(&createReq.PrincipalId, "principal-id", createReq.PrincipalId, `The ID of the service principal whose credentials will be modified.`) + flags.StringPtrVar(cmd.Flags(), &createReq.GitEmail, "git-email", `The authenticating email associated with your Git provider user account.`) + flags.StringPtrVar(cmd.Flags(), &createReq.GitUsername, "git-username", `The username provided with your Git provider account and associated with the credential.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.IsDefaultForProvider, "is-default-for-provider", `if the credential is the default for the given provider.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Name, "name", `the name of the git credential, used for identification and ease of lookup.`) + flags.StringPtrVar(cmd.Flags(), &createReq.PersonalAccessToken, "personal-access-token", `The personal access token used to authenticate to the corresponding Git provider.`) + flags.Int64PtrVar(cmd.Flags(), &createReq.PrincipalId, "principal-id", `The ID of the service principal whose credentials will be modified.`) cmd.Use = "create GIT_PROVIDER" cmd.Short = `Create a credential entry.` @@ -109,6 +110,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -123,15 +125,23 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.GitProvider = args[0] + createReq.GitProvider = new(args[0]) } - response, err := w.GitCredentials.Create(ctx, createReq) + sdkReq, err := gitcredentials.CreateCredentialsRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.GitCredentials.CreateCredentials(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := gitcredentials.CreateCredentialsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -152,15 +162,14 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *workspace.DeleteCredentialsRequest, + *gitcredentials.DeleteCredentialsRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq gitcredentials.DeleteCredentialsRequest - var deleteReq workspace.DeleteCredentialsRequest - - cmd.Flags().Int64Var(&deleteReq.PrincipalId, "principal-id", deleteReq.PrincipalId, `The ID of the service principal whose credentials will be modified.`) + flags.Int64PtrVar(cmd.Flags(), &deleteReq.PrincipalId, "principal-id", `The ID of the service principal whose credentials will be modified.`) cmd.Use = "delete CREDENTIAL_ID" cmd.Short = `Delete a credential.` @@ -175,37 +184,34 @@ func newDelete() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No CREDENTIAL_ID argument specified. Loading names for Git Credentials drop-down.") - names, err := w.GitCredentials.CredentialInfoGitProviderToCredentialIdMap(ctx, workspace.ListCredentialsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Git Credentials drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID for the corresponding credential to access") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id for the corresponding credential to access") - } - _, err = fmt.Sscan(args[0], &deleteReq.CredentialId) + var deleteCredentialIdArg int64 + _, err = fmt.Sscan(args[0], &deleteCredentialIdArg) if err != nil { return fmt.Errorf("invalid CREDENTIAL_ID: %s", args[0]) } + deleteReq.Id = &deleteCredentialIdArg - err = w.GitCredentials.Delete(ctx, deleteReq) + sdkReq, err := gitcredentials.DeleteCredentialsRequestToSDK(&deleteReq) + if err != nil { + return err + } + response, err := w.GitCredentials.DeleteCredentials(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -227,15 +233,14 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *workspace.GetCredentialsRequest, + *gitcredentials.GetCredentialsRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq gitcredentials.GetCredentialsRequest - var getReq workspace.GetCredentialsRequest - - cmd.Flags().Int64Var(&getReq.PrincipalId, "principal-id", getReq.PrincipalId, `The ID of the service principal whose credentials will be modified.`) + flags.Int64PtrVar(cmd.Flags(), &getReq.PrincipalId, "principal-id", `The ID of the service principal whose credentials will be modified.`) cmd.Use = "get CREDENTIAL_ID" cmd.Short = `Get a credential entry.` @@ -250,39 +255,38 @@ func newGet() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No CREDENTIAL_ID argument specified. Loading names for Git Credentials drop-down.") - names, err := w.GitCredentials.CredentialInfoGitProviderToCredentialIdMap(ctx, workspace.ListCredentialsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Git Credentials drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID for the corresponding credential to access") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id for the corresponding credential to access") - } - _, err = fmt.Sscan(args[0], &getReq.CredentialId) + var getCredentialIdArg int64 + _, err = fmt.Sscan(args[0], &getCredentialIdArg) if err != nil { return fmt.Errorf("invalid CREDENTIAL_ID: %s", args[0]) } + getReq.Id = &getCredentialIdArg - response, err := w.GitCredentials.Get(ctx, getReq) + sdkReq, err := gitcredentials.GetCredentialsRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.GitCredentials.GetCredentials(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := gitcredentials.GetCredentialsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -303,19 +307,19 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *workspace.ListCredentialsRequest, + *gitcredentials.ListCredentialsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq gitcredentials.ListCredentialsRequest - var listReq workspace.ListCredentialsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().Int64Var(&listReq.PrincipalId, "principal-id", listReq.PrincipalId, `The ID of the service principal whose credentials will be listed.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.PrincipalId, "principal-id", `The ID of the service principal whose credentials will be listed.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) @@ -341,8 +345,16 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.GitCredentials.List(ctx, listReq) + sdkReq, err := gitcredentials.ListCredentialsRequestToSDK(&listReq) + if err != nil { + return err + } + response, err := w.GitCredentials.ListCredentials(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -350,7 +362,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := gitcredentials.ListCredentialsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.Credentials) } // Disable completions since they are not applicable. @@ -371,23 +387,23 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *workspace.UpdateCredentialsRequest, + *gitcredentials.UpdateCredentialsRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq gitcredentials.UpdateCredentialsRequest - var updateReq workspace.UpdateCredentialsRequest 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.GitEmail, "git-email", updateReq.GitEmail, `The authenticating email associated with your Git provider user account.`) - cmd.Flags().StringVar(&updateReq.GitUsername, "git-username", updateReq.GitUsername, `The username provided with your Git provider account and associated with the credential.`) - cmd.Flags().BoolVar(&updateReq.IsDefaultForProvider, "is-default-for-provider", updateReq.IsDefaultForProvider, `if the credential is the default for the given provider.`) - cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `the name of the git credential, used for identification and ease of lookup.`) - cmd.Flags().StringVar(&updateReq.PersonalAccessToken, "personal-access-token", updateReq.PersonalAccessToken, `The personal access token used to authenticate to the corresponding Git provider.`) - cmd.Flags().Int64Var(&updateReq.PrincipalId, "principal-id", updateReq.PrincipalId, `The ID of the service principal whose credentials will be modified.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.GitEmail, "git-email", `The authenticating email associated with your Git provider user account.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.GitUsername, "git-username", `The username provided with your Git provider account and associated with the credential.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.IsDefaultForProvider, "is-default-for-provider", `if the credential is the default for the given provider.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Name, "name", `the name of the git credential, used for identification and ease of lookup.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.PersonalAccessToken, "personal-access-token", `The personal access token used to authenticate to the corresponding Git provider.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.PrincipalId, "principal-id", `The ID of the service principal whose credentials will be modified.`) cmd.Use = "update CREDENTIAL_ID GIT_PROVIDER" cmd.Short = `Update a credential.` @@ -423,6 +439,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -436,19 +453,26 @@ func newUpdate() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &updateReq.CredentialId) + var updateCredentialIdArg int64 + _, err = fmt.Sscan(args[0], &updateCredentialIdArg) if err != nil { return fmt.Errorf("invalid CREDENTIAL_ID: %s", args[0]) } - + updateReq.Id = &updateCredentialIdArg if !cmd.Flags().Changed("json") { - updateReq.GitProvider = args[1] + updateReq.GitProvider = new(args[1]) } - err = w.GitCredentials.Update(ctx, updateReq) + sdkReq, err := gitcredentials.UpdateCredentialsRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.GitCredentials.UpdateCredentials(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } diff --git a/cmd/workspace/global-init-scripts/global-init-scripts.go b/cmd/workspace/global-init-scripts/global-init-scripts.go index 674173ea22b..a40a9c7a95a 100644 --- a/cmd/workspace/global-init-scripts/global-init-scripts.go +++ b/cmd/workspace/global-init-scripts/global-init-scripts.go @@ -10,8 +10,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" + + globalinitscripts "github.com/databricks/cli/libs/sdktypes/globalinitscripts/v2" + sdkglobalinitscripts "github.com/databricks/sdk-go/globalinitscripts/v2" ) // Slice with functions to override default command behavior. @@ -60,19 +62,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *compute.GlobalInitScriptCreateRequest, + *globalinitscripts.CreateGlobalInitScriptRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq globalinitscripts.CreateGlobalInitScriptRequest - var createReq compute.GlobalInitScriptCreateRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createReq.Enabled, "enabled", createReq.Enabled, `Specifies whether the script is enabled.`) - cmd.Flags().IntVar(&createReq.Position, "position", createReq.Position, `The position of a global init script, where 0 represents the first script to run, 1 is the second script to run, in ascending order.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.Enabled, "enabled", `Specifies whether the script is enabled.`) + flags.IntPtrVar(cmd.Flags(), &createReq.Position, "position", `The position of a global init script, where 0 represents the first script to run, 1 is the second script to run, in ascending order.`) cmd.Use = "create NAME SCRIPT" cmd.Short = `Create init script.` @@ -104,6 +106,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -118,18 +121,26 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Name = args[0] + createReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createReq.Script = args[1] + _ = args[1] // TODO: complex arg: script } - response, err := w.GlobalInitScripts.Create(ctx, createReq) + sdkReq, err := globalinitscripts.CreateGlobalInitScriptRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.GlobalInitScripts.CreateGlobalInitScript(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := globalinitscripts.CreateGlobalInitScriptResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -150,13 +161,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *compute.DeleteGlobalInitScriptRequest, + *sdkglobalinitscripts.DeleteGlobalInitScriptRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq compute.DeleteGlobalInitScriptRequest + var deleteReq sdkglobalinitscripts.DeleteGlobalInitScriptRequest cmd.Use = "delete SCRIPT_ID" cmd.Short = `Delete init script.` @@ -171,34 +181,26 @@ func newDelete() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No SCRIPT_ID argument specified. Loading names for Global Init Scripts drop-down.") - names, err := w.GlobalInitScripts.GlobalInitScriptDetailsNameToScriptIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Global Init Scripts drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID of the global init script") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id of the global init script") - } - deleteReq.ScriptId = args[0] + deleteReq.ScriptId = new(args[0]) - err = w.GlobalInitScripts.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.GlobalInitScripts.DeleteGlobalInitScript(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -220,13 +222,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *compute.GetGlobalInitScriptRequest, + *sdkglobalinitscripts.GetGlobalInitScriptRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq compute.GetGlobalInitScriptRequest + var getReq sdkglobalinitscripts.GetGlobalInitScriptRequest cmd.Use = "get SCRIPT_ID" cmd.Short = `Get an init script.` @@ -241,36 +242,30 @@ func newGet() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No SCRIPT_ID argument specified. Loading names for Global Init Scripts drop-down.") - names, err := w.GlobalInitScripts.GlobalInitScriptDetailsNameToScriptIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Global Init Scripts drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID of the global init script") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id of the global init script") - } - getReq.ScriptId = args[0] + getReq.ScriptId = new(args[0]) - response, err := w.GlobalInitScripts.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.GlobalInitScripts.GetGlobalInitScript(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := globalinitscripts.GlobalInitScriptDetailsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -322,7 +317,14 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response := w.GlobalInitScripts.List(ctx) + _ = w + + sdkReq := &sdkglobalinitscripts.ListGlobalInitScriptsRequest{} + + response, err := w.GlobalInitScripts.ListGlobalInitScripts(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -330,7 +332,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := globalinitscripts.ListGlobalInitScriptsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.Scripts) } // Disable completions since they are not applicable. @@ -351,19 +357,19 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *compute.GlobalInitScriptUpdateRequest, + *globalinitscripts.UpdateGlobalInitScriptRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq globalinitscripts.UpdateGlobalInitScriptRequest - var updateReq compute.GlobalInitScriptUpdateRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&updateReq.Enabled, "enabled", updateReq.Enabled, `Specifies whether the script is enabled.`) - cmd.Flags().IntVar(&updateReq.Position, "position", updateReq.Position, `The position of a script, where 0 represents the first script to run, 1 is the second script to run, in ascending order.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Enabled, "enabled", `Specifies whether the script is enabled.`) + flags.IntPtrVar(cmd.Flags(), &updateReq.Position, "position", `The position of a script, where 0 represents the first script to run, 1 is the second script to run, in ascending order.`) cmd.Use = "update SCRIPT_ID NAME SCRIPT" cmd.Short = `Update init script.` @@ -397,6 +403,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -410,18 +417,24 @@ func newUpdate() *cobra.Command { } } } - updateReq.ScriptId = args[0] + updateReq.ScriptId = new(args[0]) if !cmd.Flags().Changed("json") { - updateReq.Name = args[1] + updateReq.Name = new(args[1]) } if !cmd.Flags().Changed("json") { - updateReq.Script = args[2] + _ = args[2] // TODO: complex arg: script } - err = w.GlobalInitScripts.Update(ctx, updateReq) + sdkReq, err := globalinitscripts.UpdateGlobalInitScriptRequestToSDK(&updateReq) if err != nil { return err } + response, err := w.GlobalInitScripts.UpdateGlobalInitScript(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } diff --git a/cmd/workspace/grants/grants.go b/cmd/workspace/grants/grants.go index 800e48fe5d2..3685c4e09b7 100644 --- a/cmd/workspace/grants/grants.go +++ b/cmd/workspace/grants/grants.go @@ -7,10 +7,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucgrants "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" ) // Slice with functions to override default command behavior. @@ -60,17 +62,16 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetGrantRequest, + *ucgrants.GetPermissionsRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq ucgrants.GetPermissionsRequest - var getReq catalog.GetGrantRequest - - cmd.Flags().IntVar(&getReq.MaxResults, "max-results", getReq.MaxResults, `Specifies the maximum number of privileges to return (page length).`) - cmd.Flags().StringVar(&getReq.PageToken, "page-token", getReq.PageToken, `Opaque pagination token to go to next page based on previous query.`) - cmd.Flags().StringVar(&getReq.Principal, "principal", getReq.Principal, `If provided, only the permissions for the specified principal (user or group) are returned.`) + flags.IntPtrVar(cmd.Flags(), &getReq.MaxResults, "max-results", `Specifies the maximum number of privileges to return (page length).`) + flags.StringPtrVar(cmd.Flags(), &getReq.PageToken, "page-token", `Opaque pagination token to go to next page based on previous query.`) + flags.StringPtrVar(cmd.Flags(), &getReq.Principal, "principal", `If provided, only the permissions for the specified principal (user or group) are returned.`) cmd.Use = "get SECURABLE_TYPE FULL_NAME" cmd.Short = `Get permissions.` @@ -103,16 +104,25 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.SecurableType = args[0] - getReq.FullName = args[1] + getReq.SecurableType = new(args[0]) + getReq.SecurableFullName = new(args[1]) - response, err := w.Grants.Get(ctx, getReq) + sdkReq, err := ucgrants.GetPermissionsRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.Grants.GetPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucgrants.GetPermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -133,17 +143,16 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getEffectiveOverrides []func( *cobra.Command, - *catalog.GetEffectiveRequest, + *ucgrants.GetEffectivePermissionsRequest, ) func newGetEffective() *cobra.Command { cmd := &cobra.Command{} + var getEffectiveReq ucgrants.GetEffectivePermissionsRequest - var getEffectiveReq catalog.GetEffectiveRequest - - cmd.Flags().IntVar(&getEffectiveReq.MaxResults, "max-results", getEffectiveReq.MaxResults, `Specifies the maximum number of privileges to return (page length).`) - cmd.Flags().StringVar(&getEffectiveReq.PageToken, "page-token", getEffectiveReq.PageToken, `Opaque token for the next page of results (pagination).`) - cmd.Flags().StringVar(&getEffectiveReq.Principal, "principal", getEffectiveReq.Principal, `If provided, only the effective permissions for the specified principal (user or group) are returned.`) + flags.IntPtrVar(cmd.Flags(), &getEffectiveReq.MaxResults, "max-results", `Specifies the maximum number of privileges to return (page length).`) + flags.StringPtrVar(cmd.Flags(), &getEffectiveReq.PageToken, "page-token", `Opaque token for the next page of results (pagination).`) + flags.StringPtrVar(cmd.Flags(), &getEffectiveReq.Principal, "principal", `If provided, only the effective permissions for the specified principal (user or group) are returned.`) cmd.Use = "get-effective SECURABLE_TYPE FULL_NAME" cmd.Short = `Get effective permissions.` @@ -177,16 +186,25 @@ func newGetEffective() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getEffectiveReq.SecurableType = args[0] - getEffectiveReq.FullName = args[1] + getEffectiveReq.SecurableType = new(args[0]) + getEffectiveReq.SecurableFullName = new(args[1]) - response, err := w.Grants.GetEffective(ctx, getEffectiveReq) + sdkReq, err := ucgrants.GetEffectivePermissionsRequestToSDK(&getEffectiveReq) + if err != nil { + return err + } + response, err := w.Grants.GetEffectivePermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucgrants.GetEffectivePermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -207,26 +225,26 @@ func newGetEffective() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListPrivilegeAssignmentsRequest, + *ucgrants.ListPrivilegeAssignmentsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq ucgrants.ListPrivilegeAssignmentsRequest - var listReq catalog.ListPrivilegeAssignmentsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `Specifies the maximum number of privilege assignments to return (page length).`) - cmd.Flags().StringVar(&listReq.Principal, "principal", listReq.Principal, `If provided, only the permissions for the specified principal (user or group) are returned.`) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", `Specifies the maximum number of privilege assignments to return (page length).`) + flags.StringPtrVar(cmd.Flags(), &listReq.Principal, "principal", `If provided, only the permissions for the specified principal (user or group) are returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list SECURABLE_TYPE FULL_NAME" @@ -253,19 +271,23 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.SecurableType = args[0] - listReq.FullName = args[1] + listReq.SecurableType = new(args[0]) + listReq.FullName = new(args[1]) - response := w.Grants.List(ctx, listReq) + sdkReq, err := ucgrants.ListPrivilegeAssignmentsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Grants.ListPrivilegeAssignmentsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucgrants.PrivilegeAssignmentFromSDK)) } // Disable completions since they are not applicable. @@ -286,26 +308,26 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listEffectiveOverrides []func( *cobra.Command, - *catalog.ListEffectivePrivilegeAssignmentsRequest, + *ucgrants.ListEffectivePrivilegeAssignmentsRequest, ) func newListEffective() *cobra.Command { cmd := &cobra.Command{} + var listEffectiveReq ucgrants.ListEffectivePrivilegeAssignmentsRequest - var listEffectiveReq catalog.ListEffectivePrivilegeAssignmentsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listEffectiveLimit int - cmd.Flags().IntVar(&listEffectiveReq.PageSize, "page-size", listEffectiveReq.PageSize, `Specifies the maximum number of privilege assignments to return (page length).`) - cmd.Flags().StringVar(&listEffectiveReq.Principal, "principal", listEffectiveReq.Principal, `If provided, only the effective permissions for the specified principal (user or group) are returned.`) + flags.IntPtrVar(cmd.Flags(), &listEffectiveReq.PageSize, "page-size", `Specifies the maximum number of privilege assignments to return (page length).`) + flags.StringPtrVar(cmd.Flags(), &listEffectiveReq.Principal, "principal", `If provided, only the effective permissions for the specified principal (user or group) are returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listEffectiveLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listEffectiveReq.PageToken, "page-token", listEffectiveReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listEffectiveReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-effective SECURABLE_TYPE FULL_NAME" @@ -332,19 +354,23 @@ func newListEffective() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listEffectiveReq.SecurableType = args[0] - listEffectiveReq.FullName = args[1] + listEffectiveReq.SecurableType = new(args[0]) + listEffectiveReq.FullName = new(args[1]) - response := w.Grants.ListEffective(ctx, listEffectiveReq) + sdkReq, err := ucgrants.ListEffectivePrivilegeAssignmentsRequestToSDK(&listEffectiveReq) + if err != nil { + return err + } if listEffectiveLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listEffectiveLimit) } if listEffectiveLimit > 0 { ctx = cmdio.WithLimit(ctx, listEffectiveLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Grants.ListEffectivePrivilegeAssignmentsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucgrants.EffectivePrivilegeAssignmentFromSDK)) } // Disable completions since they are not applicable. @@ -365,19 +391,19 @@ func newListEffective() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdatePermissions, + *ucgrants.UpdatePermissionsRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucgrants.UpdatePermissionsRequest - var updateReq catalog.UpdatePermissions var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: changes - cmd.Flags().BoolVar(&updateReq.OmitPermissionsInResponse, "omit-permissions-in-response", updateReq.OmitPermissionsInResponse, `Optional, default false.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.OmitPermissionsInResponse, "omit-permissions-in-response", `Optional, default false.`) cmd.Use = "update SECURABLE_TYPE FULL_NAME" cmd.Short = `Update permissions.` @@ -402,6 +428,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -415,15 +442,23 @@ func newUpdate() *cobra.Command { } } } - updateReq.SecurableType = args[0] - updateReq.FullName = args[1] + updateReq.SecurableType = new(args[0]) + updateReq.SecurableFullName = new(args[1]) - response, err := w.Grants.Update(ctx, updateReq) + sdkReq, err := ucgrants.UpdatePermissionsRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Grants.UpdatePermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucgrants.UpdatePermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/groups-v2/groups-v2.go b/cmd/workspace/groups-v2/groups-v2.go index 64b5439cb7a..4bc709e4e0e 100644 --- a/cmd/workspace/groups-v2/groups-v2.go +++ b/cmd/workspace/groups-v2/groups-v2.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" + + scim "github.com/databricks/cli/libs/sdktypes/scim/v1" + sdkscim "github.com/databricks/sdk-go/scim/v1" ) // Slice with functions to override default command behavior. @@ -60,22 +63,22 @@ Groups simplify identity management, making it easier to assign access to // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *iam.CreateGroupRequest, + *scim.CreateGroupRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq scim.CreateGroupRequest - var createReq iam.CreateGroupRequest 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.DisplayName, "display-name", createReq.DisplayName, `String that represents a human-readable group name.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DisplayName, "display-name", `String that represents a human-readable group name.`) // TODO: array: entitlements - cmd.Flags().StringVar(&createReq.ExternalId, "external-id", createReq.ExternalId, ``) + flags.StringPtrVar(cmd.Flags(), &createReq.ExternalId, "external-id", ``) // TODO: array: groups - cmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Databricks group ID.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Id, "id", `Databricks group ID.`) // TODO: array: members // TODO: complex arg: meta // TODO: array: roles @@ -103,6 +106,7 @@ Create a new group. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -117,12 +121,20 @@ Create a new group. } } - response, err := w.GroupsV2.Create(ctx, createReq) + sdkReq, err := scim.CreateGroupRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Scim.CreateGroup(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.GroupFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -143,13 +155,12 @@ Create a new group. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *iam.DeleteGroupRequest, + *sdkscim.DeleteGroupRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq iam.DeleteGroupRequest + var deleteReq sdkscim.DeleteGroupRequest cmd.Use = "delete ID" cmd.Short = `*Public Preview* Delete a group.` @@ -175,10 +186,12 @@ Delete a group. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = w.GroupsV2.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = w.Scim.DeleteGroup(ctx, *sdkReq) if err != nil { return err } @@ -203,13 +216,12 @@ Delete a group. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *iam.GetGroupRequest, + *sdkscim.GetGroupRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq iam.GetGroupRequest + var getReq sdkscim.GetGroupRequest cmd.Use = "get ID" cmd.Short = `*Public Preview* Get group details.` @@ -235,15 +247,21 @@ Get group details. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.GroupsV2.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Scim.GetGroup(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.GroupFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -264,31 +282,31 @@ Get group details. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *iam.ListGroupsRequest, + *scim.ListGroupsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq scim.ListGroupsRequest - var listReq iam.ListGroupsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.Attributes, "attributes", listReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().StringVar(&listReq.ExcludedAttributes, "excluded-attributes", listReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&listReq.Filter, "filter", listReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&listReq.SortBy, "sort-by", listReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) + flags.StringPtrVar(cmd.Flags(), &listReq.Attributes, "attributes", `Comma-separated list of attributes to return in response.`) + flags.StringPtrVar(cmd.Flags(), &listReq.ExcludedAttributes, "excluded-attributes", `Comma-separated list of attributes to exclude in response.`) + flags.StringPtrVar(cmd.Flags(), &listReq.Filter, "filter", `Query by which the results have to be filtered.`) + flags.StringPtrVar(cmd.Flags(), &listReq.SortBy, "sort-by", `Attribute to sort the results.`) + flags.EnumVar(cmd.Flags(), &listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`, "ListSortOrder", "ascending", "descending") // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().Int64Var(&listReq.StartIndex, "start-index", listReq.StartIndex, `Specifies the index of the first result.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.StartIndex, "start-index", `Specifies the index of the first result.`) cmd.Flags().Lookup("start-index").Hidden = true - cmd.Flags().Int64Var(&listReq.Count, "count", listReq.Count, `Number of results per API page.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.Count, "count", `Number of results per API page.`) cmd.Flags().Lookup("count").Hidden = true cmd.Use = "list" @@ -312,16 +330,20 @@ List group details. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.GroupsV2.List(ctx, listReq) + sdkReq, err := scim.ListGroupsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Scim.ListGroupsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, scim.GroupFromSDK)) } // Disable completions since they are not applicable. @@ -342,13 +364,13 @@ List group details. // Functions can be added from the `init()` function in manually curated files in this directory. var patchOverrides []func( *cobra.Command, - *iam.PatchGroupRequest, + *scim.PatchGroupRequest, ) func newPatch() *cobra.Command { cmd := &cobra.Command{} + var patchReq scim.PatchGroupRequest - var patchReq iam.PatchGroupRequest var patchJson flags.JsonFlag cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -380,6 +402,7 @@ Update group details. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -393,9 +416,13 @@ Update group details. } } } - patchReq.Id = args[0] + patchReq.Id = new(args[0]) - err = w.GroupsV2.Patch(ctx, patchReq) + sdkReq, err := scim.PatchGroupRequestToSDK(&patchReq) + if err != nil { + return err + } + err = w.Scim.PatchGroup(ctx, *sdkReq) if err != nil { return err } @@ -420,20 +447,20 @@ Update group details. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *iam.UpdateGroupRequest, + *scim.UpdateGroupRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq scim.UpdateGroupRequest - var updateReq iam.UpdateGroupRequest 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.DisplayName, "display-name", updateReq.DisplayName, `String that represents a human-readable group name.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.DisplayName, "display-name", `String that represents a human-readable group name.`) // TODO: array: entitlements - cmd.Flags().StringVar(&updateReq.ExternalId, "external-id", updateReq.ExternalId, ``) + flags.StringPtrVar(cmd.Flags(), &updateReq.ExternalId, "external-id", ``) // TODO: array: groups // TODO: array: members // TODO: complex arg: meta @@ -464,6 +491,7 @@ Replace a group. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -477,9 +505,13 @@ Replace a group. } } } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - err = w.GroupsV2.Update(ctx, updateReq) + sdkReq, err := scim.UpdateGroupRequestToSDK(&updateReq) + if err != nil { + return err + } + err = w.Scim.UpdateGroup(ctx, *sdkReq) if err != nil { return err } diff --git a/cmd/workspace/groups/groups.go b/cmd/workspace/groups/groups.go index 595c03218bb..428870fca4a 100755 --- a/cmd/workspace/groups/groups.go +++ b/cmd/workspace/groups/groups.go @@ -2,17 +2,11 @@ // but are now manually maintained because the v2 API versions have taken // over as the generated commands. See https://github.com/databricks/cli/pull/4722. -//nolint:staticcheck,perfsprint package groups 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/iam" + groups_v2 "github.com/databricks/cli/cmd/workspace/groups-v2" "github.com/spf13/cobra" ) @@ -20,6 +14,11 @@ import ( // Functions can be added from the `init()` function in manually curated files in this directory. var cmdOverrides []func(*cobra.Command) +// Slices with functions to override the behavior of individual commands. +var listOverrides []func(*cobra.Command) + +// The commands are the groups-v2 commands (same API) presented under their +// original names and help text. func New() *cobra.Command { cmd := &cobra.Command{ Use: "groups", @@ -38,469 +37,100 @@ func New() *cobra.Command { RunE: root.ReportUnknownSubcommand, } - // Add methods - cmd.AddCommand(newCreate()) - cmd.AddCommand(newDelete()) - cmd.AddCommand(newGet()) - cmd.AddCommand(newList()) - cmd.AddCommand(newPatch()) - 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, - *iam.Group, -) - -func newCreate() *cobra.Command { - cmd := &cobra.Command{} - - var createReq iam.Group - 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.DisplayName, "display-name", createReq.DisplayName, `String that represents a human-readable group name.`) - // TODO: array: entitlements - cmd.Flags().StringVar(&createReq.ExternalId, "external-id", createReq.ExternalId, ``) - // TODO: array: groups - cmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Databricks group ID.`) - // TODO: array: members - // TODO: complex arg: meta - // TODO: array: roles - // TODO: array: schemas - - cmd.Use = "create" - cmd.Short = `Create a new group.` - cmd.Long = `Create a new group. - - Creates a group in the Databricks workspace with a unique name, using the - supplied group details.` - - 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 := createJson.Unmarshal(&createReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err + v2 := groups_v2.New() + for _, sub := range v2.Commands() { + doc, ok := commandDocs[sub.Name()] + if !ok { + continue + } + v2.RemoveCommand(sub) + sub.Use = doc.use + if doc.short != "" { + sub.Short = doc.short + sub.Long = doc.long + } + sub.Hidden = doc.hidden + if sub.Name() == "list" { + // These were regular flags of the original commands. + for _, name := range []string{"count", "start-index"} { + if f := sub.Flags().Lookup(name); f != nil { + f.Hidden = false } } + for _, fn := range listOverrides { + fn(sub) + } } - - response, err := w.Groups.Create(ctx, createReq) - if err != nil { - return err - } - return cmdio.Render(ctx, response) + cmd.AddCommand(sub) } - // 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) + for _, fn := range cmdOverrides { + fn(cmd) } 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, - *iam.DeleteGroupRequest, -) - -func newDelete() *cobra.Command { - cmd := &cobra.Command{} +type commandDoc struct { + use, short, long string + hidden bool +} - var deleteReq iam.DeleteGroupRequest +var commandDocs = map[string]commandDoc{ + "create": { + use: "create", + short: `Create a new group.`, + long: `Create a new group. - cmd.Use = "delete ID" - cmd.Short = `Delete a group.` - cmd.Long = `Delete a group. + Creates a group in the Databricks workspace with a unique name, using the + supplied group details.`, + }, + "delete": { + use: "delete ID", + short: `Delete a group.`, + long: `Delete a group. Deletes a group from the Databricks workspace. Arguments: - ID: Unique ID for a group in the Databricks workspace.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Groups drop-down.") - names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID for a group in the Databricks workspace") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id for a group in the databricks workspace") - } - deleteReq.Id = args[0] - - err = w.Groups.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, - *iam.GetGroupRequest, -) - -func newGet() *cobra.Command { - cmd := &cobra.Command{} - - var getReq iam.GetGroupRequest - - cmd.Use = "get ID" - cmd.Short = `Get group details.` - cmd.Long = `Get group details. + ID: Unique ID for a group in the Databricks workspace.`, + }, + "get": { + use: "get ID", + short: `Get group details.`, + long: `Get group details. Gets the information for a specific group in the Databricks workspace. Arguments: - ID: Unique ID for a group in the Databricks workspace.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Groups drop-down.") - names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID for a group in the Databricks workspace") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id for a group in the databricks workspace") - } - getReq.Id = args[0] - - response, err := w.Groups.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, - *iam.ListGroupsRequest, -) - -func newList() *cobra.Command { - cmd := &cobra.Command{} - - var listReq iam.ListGroupsRequest - - cmd.Flags().StringVar(&listReq.Attributes, "attributes", listReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().Int64Var(&listReq.Count, "count", listReq.Count, `Desired number of results per page.`) - cmd.Flags().StringVar(&listReq.ExcludedAttributes, "excluded-attributes", listReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&listReq.Filter, "filter", listReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&listReq.SortBy, "sort-by", listReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) - cmd.Flags().Int64Var(&listReq.StartIndex, "start-index", listReq.StartIndex, `Specifies the index of the first result.`) - - cmd.Use = "list" - cmd.Short = `List group details.` - cmd.Long = `List group details. - - Gets all details of the groups associated with the Databricks 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.Groups.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 patch 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 patchOverrides []func( - *cobra.Command, - *iam.PartialUpdate, -) - -func newPatch() *cobra.Command { - cmd := &cobra.Command{} - - var patchReq iam.PartialUpdate - var patchJson flags.JsonFlag - - cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - // TODO: array: Operations - // TODO: array: schemas - - cmd.Use = "patch ID" - cmd.Short = `Update group details.` - cmd.Long = `Update group details. + ID: Unique ID for a group in the Databricks workspace.`, + }, + "list": { + use: "list", + short: `List group details.`, + long: `List group details. + + Gets all details of the groups associated with the Databricks workspace.`, + }, + "patch": { + use: "patch ID", + short: `Update group details.`, + long: `Update group details. Partially updates the details of a group. Arguments: - ID: Unique ID in the Databricks workspace.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if cmd.Flags().Changed("json") { - diags := patchJson.Unmarshal(&patchReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Groups drop-down.") - names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID in the Databricks workspace") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id in the databricks workspace") - } - patchReq.Id = args[0] - - err = w.Groups.Patch(ctx, patchReq) - 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 patchOverrides { - fn(cmd, &patchReq) - } - - 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, - *iam.Group, -) - -func newUpdate() *cobra.Command { - cmd := &cobra.Command{} - - var updateReq iam.Group - 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.DisplayName, "display-name", updateReq.DisplayName, `String that represents a human-readable group name.`) - // TODO: array: entitlements - cmd.Flags().StringVar(&updateReq.ExternalId, "external-id", updateReq.ExternalId, ``) - // TODO: array: groups - cmd.Flags().StringVar(&updateReq.Id, "id", updateReq.Id, `Databricks group ID.`) - // TODO: array: members - // TODO: complex arg: meta - // TODO: array: roles - // TODO: array: schemas - - cmd.Use = "update ID" - cmd.Short = `Replace a group.` - cmd.Long = `Replace a group. + ID: Unique ID in the Databricks workspace.`, + }, + "update": { + use: "update ID", + short: `Replace a group.`, + long: `Replace a group. Updates the details of a group by replacing the entire group entity. Arguments: - ID: Databricks group ID` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if cmd.Flags().Changed("json") { - diags := updateJson.Unmarshal(&updateReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Groups drop-down.") - names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks group ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks group id") - } - updateReq.Id = args[0] - - err = w.Groups.Update(ctx, updateReq) - 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 updateOverrides { - fn(cmd, &updateReq) - } - - return cmd + ID: Databricks group ID`, + }, } - -// end service Groups diff --git a/cmd/workspace/groups/overrides.go b/cmd/workspace/groups/overrides.go index db9c7610ccf..2ec551b0034 100644 --- a/cmd/workspace/groups/overrides.go +++ b/cmd/workspace/groups/overrides.go @@ -2,12 +2,12 @@ package groups import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *iam.ListGroupsRequest) { - listReq.Attributes = "id,displayName" +func listOverride(listCmd *cobra.Command) { + // Request only the columns the template shows unless --attributes is given. + _ = listCmd.Flags().Lookup("attributes").Value.Set("id,displayName") listCmd.Annotations["template"] = cmdio.Heredoc(` {{range .}}{{.Id|green}} {{.DisplayName}} {{end}}`) diff --git a/cmd/workspace/instance-pools/instance-pools.go b/cmd/workspace/instance-pools/instance-pools.go index 5a2b996c2e0..72998722a54 100644 --- a/cmd/workspace/instance-pools/instance-pools.go +++ b/cmd/workspace/instance-pools/instance-pools.go @@ -10,8 +10,12 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + instancepools "github.com/databricks/cli/libs/sdktypes/instancepools/v2" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdkinstancepools "github.com/databricks/sdk-go/instancepools/v2" ) // Slice with functions to override default command behavior. @@ -73,13 +77,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *compute.CreateInstancePool, + *instancepools.CreateInstancePoolRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq instancepools.CreateInstancePoolRequest - var createReq compute.CreateInstancePool var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -88,16 +92,16 @@ func newCreate() *cobra.Command { // TODO: complex arg: azure_attributes // TODO: map via StringToStringVar: custom_tags // TODO: complex arg: disk_spec - cmd.Flags().BoolVar(&createReq.EnableElasticDisk, "enable-elastic-disk", createReq.EnableElasticDisk, `Autoscaling Local Storage: when enabled, this instances in this pool will dynamically acquire additional disk space when its Spark workers are running low on disk space.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.EnableElasticDisk, "enable-elastic-disk", `Autoscaling Local Storage: when enabled, this instances in this pool will dynamically acquire additional disk space when its Spark workers are running low on disk space.`) // TODO: complex arg: gcp_attributes - cmd.Flags().IntVar(&createReq.IdleInstanceAutoterminationMinutes, "idle-instance-autotermination-minutes", createReq.IdleInstanceAutoterminationMinutes, `Automatically terminates the extra instances in the pool cache after they are inactive for this time in minutes if min_idle_instances requirement is already met.`) - cmd.Flags().IntVar(&createReq.MaxCapacity, "max-capacity", createReq.MaxCapacity, `Maximum number of outstanding instances to keep in the pool, including both instances used by clusters and idle instances.`) - cmd.Flags().IntVar(&createReq.MinIdleInstances, "min-idle-instances", createReq.MinIdleInstances, `Minimum number of idle instances to keep in the instance pool.`) + flags.IntPtrVar(cmd.Flags(), &createReq.IdleInstanceAutoterminationMinutes, "idle-instance-autotermination-minutes", `Automatically terminates the extra instances in the pool cache after they are inactive for this time in minutes if min_idle_instances requirement is already met.`) + flags.IntPtrVar(cmd.Flags(), &createReq.MaxCapacity, "max-capacity", `Maximum number of outstanding instances to keep in the pool, including both instances used by clusters and idle instances.`) + flags.IntPtrVar(cmd.Flags(), &createReq.MinIdleInstances, "min-idle-instances", `Minimum number of idle instances to keep in the instance pool.`) // TODO: complex arg: node_type_flexibility // TODO: array: preloaded_docker_images // TODO: array: preloaded_spark_versions - cmd.Flags().IntVar(&createReq.RemoteDiskThroughput, "remote-disk-throughput", createReq.RemoteDiskThroughput, `If set, what the configurable throughput (in Mb/s) for the remote disk is.`) - cmd.Flags().IntVar(&createReq.TotalInitialRemoteDiskSize, "total-initial-remote-disk-size", createReq.TotalInitialRemoteDiskSize, `If set, what the total initial volume size (in GB) of the remote disks should be.`) + flags.IntPtrVar(cmd.Flags(), &createReq.RemoteDiskThroughput, "remote-disk-throughput", `If set, what the configurable throughput (in Mb/s) for the remote disk is.`) + flags.IntPtrVar(cmd.Flags(), &createReq.TotalInitialRemoteDiskSize, "total-initial-remote-disk-size", `If set, what the total initial volume size (in GB) of the remote disks should be.`) cmd.Use = "create INSTANCE_POOL_NAME NODE_TYPE_ID" cmd.Short = `Create a new instance pool.` @@ -136,6 +140,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -150,18 +155,26 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.InstancePoolName = args[0] + createReq.InstancePoolName = new(args[0]) } if !cmd.Flags().Changed("json") { - createReq.NodeTypeId = args[1] + createReq.NodeTypeId = new(args[1]) } - response, err := w.InstancePools.Create(ctx, createReq) + sdkReq, err := instancepools.CreateInstancePoolRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.InstancePools.CreateInstancePool(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := instancepools.CreateInstancePoolResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -182,13 +195,13 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *compute.DeleteInstancePool, + *instancepools.DeleteInstancePoolRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq instancepools.DeleteInstancePoolRequest - var deleteReq compute.DeleteInstancePool var deleteJson flags.JsonFlag cmd.Flags().Var(&deleteJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -215,13 +228,15 @@ func newDelete() *cobra.Command { } return nil } - 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) + _ = w if cmd.Flags().Changed("json") { diags := deleteJson.Unmarshal(&deleteReq) @@ -234,31 +249,21 @@ func newDelete() *cobra.Command { return err } } - } else { - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down.") - names, err := w.InstancePools.InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Instance Pools drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The instance pool to be terminated") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the instance pool to be terminated") - } - deleteReq.InstancePoolId = args[0] + } + if !cmd.Flags().Changed("json") { + deleteReq.InstancePoolId = new(args[0]) } - err = w.InstancePools.Delete(ctx, deleteReq) + sdkReq, err := instancepools.DeleteInstancePoolRequestToSDK(&deleteReq) + if err != nil { + return err + } + response, err := w.InstancePools.DeleteInstancePool(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -280,23 +285,23 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var editOverrides []func( *cobra.Command, - *compute.EditInstancePool, + *instancepools.EditInstancePoolRequest, ) func newEdit() *cobra.Command { cmd := &cobra.Command{} + var editReq instancepools.EditInstancePoolRequest - var editReq compute.EditInstancePool var editJson flags.JsonFlag cmd.Flags().Var(&editJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: map via StringToStringVar: custom_tags - cmd.Flags().IntVar(&editReq.IdleInstanceAutoterminationMinutes, "idle-instance-autotermination-minutes", editReq.IdleInstanceAutoterminationMinutes, `Automatically terminates the extra instances in the pool cache after they are inactive for this time in minutes if min_idle_instances requirement is already met.`) - cmd.Flags().IntVar(&editReq.MaxCapacity, "max-capacity", editReq.MaxCapacity, `Maximum number of outstanding instances to keep in the pool, including both instances used by clusters and idle instances.`) - cmd.Flags().IntVar(&editReq.MinIdleInstances, "min-idle-instances", editReq.MinIdleInstances, `Minimum number of idle instances to keep in the instance pool.`) - cmd.Flags().IntVar(&editReq.RemoteDiskThroughput, "remote-disk-throughput", editReq.RemoteDiskThroughput, `If set, what the configurable throughput (in Mb/s) for the remote disk is.`) - cmd.Flags().IntVar(&editReq.TotalInitialRemoteDiskSize, "total-initial-remote-disk-size", editReq.TotalInitialRemoteDiskSize, `If set, what the total initial volume size (in GB) of the remote disks should be.`) + flags.IntPtrVar(cmd.Flags(), &editReq.IdleInstanceAutoterminationMinutes, "idle-instance-autotermination-minutes", `Automatically terminates the extra instances in the pool cache after they are inactive for this time in minutes if min_idle_instances requirement is already met.`) + flags.IntPtrVar(cmd.Flags(), &editReq.MaxCapacity, "max-capacity", `Maximum number of outstanding instances to keep in the pool, including both instances used by clusters and idle instances.`) + flags.IntPtrVar(cmd.Flags(), &editReq.MinIdleInstances, "min-idle-instances", `Minimum number of idle instances to keep in the instance pool.`) + flags.IntPtrVar(cmd.Flags(), &editReq.RemoteDiskThroughput, "remote-disk-throughput", `If set, what the configurable throughput (in Mb/s) for the remote disk is.`) + flags.IntPtrVar(cmd.Flags(), &editReq.TotalInitialRemoteDiskSize, "total-initial-remote-disk-size", `If set, what the total initial volume size (in GB) of the remote disks should be.`) cmd.Use = "edit INSTANCE_POOL_ID INSTANCE_POOL_NAME NODE_TYPE_ID" cmd.Short = `Edit an existing instance pool.` @@ -336,6 +341,7 @@ func newEdit() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := editJson.Unmarshal(&editReq) @@ -350,19 +356,25 @@ func newEdit() *cobra.Command { } } if !cmd.Flags().Changed("json") { - editReq.InstancePoolId = args[0] + editReq.InstancePoolId = new(args[0]) } if !cmd.Flags().Changed("json") { - editReq.InstancePoolName = args[1] + editReq.InstancePoolName = new(args[1]) } if !cmd.Flags().Changed("json") { - editReq.NodeTypeId = args[2] + editReq.NodeTypeId = new(args[2]) } - err = w.InstancePools.Edit(ctx, editReq) + sdkReq, err := instancepools.EditInstancePoolRequestToSDK(&editReq) + if err != nil { + return err + } + response, err := w.InstancePools.EditInstancePool(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -384,13 +396,12 @@ func newEdit() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *compute.GetInstancePoolRequest, + *instancepools.GetInstancePoolRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq compute.GetInstancePoolRequest + var getReq instancepools.GetInstancePoolRequest cmd.Use = "get INSTANCE_POOL_ID" cmd.Short = `Get instance pool information.` @@ -405,36 +416,33 @@ func newGet() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down.") - names, err := w.InstancePools.InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Instance Pools drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The canonical unique identifier for the instance pool") - if err != nil { - return err - } - args = append(args, id) + getReq.InstancePoolId = new(args[0]) + + sdkReq, err := instancepools.GetInstancePoolRequestToSDK(&getReq) + if err != nil { + return err } - if len(args) != 1 { - return errors.New("expected to have the canonical unique identifier for the instance pool") + response, err := w.InstancePools.GetInstancePool(ctx, *sdkReq) + if err != nil { + return err } - getReq.InstancePoolId = args[0] - response, err := w.InstancePools.Get(ctx, getReq) + out, err := instancepools.GetInstancePoolResponseFromSDK(response) if err != nil { return err } - - return cmdio.Render(ctx, response) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -455,13 +463,12 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *compute.GetInstancePoolPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq compute.GetInstancePoolPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels INSTANCE_POOL_ID" cmd.Short = `Get instance pool permission levels.` @@ -476,36 +483,32 @@ func newGetPermissionLevels() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down.") - names, err := w.InstancePools.InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Instance Pools drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The instance pool for which to get or manage permissions") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the instance pool for which to get or manage permissions") - } - getPermissionLevelsReq.InstancePoolId = args[0] + getPermissionLevelsReq.RequestObjectId = new(args[0]) - response, err := w.InstancePools.GetPermissionLevels(ctx, getPermissionLevelsReq) + getPermissionLevelsReq.RequestObjectType = new("instance-pools") + + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -526,13 +529,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *compute.GetInstancePoolPermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq compute.GetInstancePoolPermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions INSTANCE_POOL_ID" cmd.Short = `Get instance pool permissions.` @@ -548,36 +550,32 @@ func newGetPermissions() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down.") - names, err := w.InstancePools.InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Instance Pools drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The instance pool for which to get or manage permissions") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the instance pool for which to get or manage permissions") - } - getPermissionsReq.InstancePoolId = args[0] + getPermissionsReq.RequestObjectId = new(args[0]) + + getPermissionsReq.RequestObjectType = new("instance-pools") - response, err := w.InstancePools.GetPermissions(ctx, getPermissionsReq) + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -626,7 +624,14 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response := w.InstancePools.List(ctx) + _ = w + + sdkReq := &sdkinstancepools.ListInstancePoolsRequest{} + + response, err := w.InstancePools.ListInstancePools(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -634,7 +639,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := instancepools.ListInstancePoolsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.InstancePools) } // Disable completions since they are not applicable. @@ -655,13 +664,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *compute.InstancePoolPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq compute.InstancePoolPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -683,10 +692,16 @@ func newSetPermissions() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -700,31 +715,24 @@ func newSetPermissions() *cobra.Command { } } } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down.") - names, err := w.InstancePools.InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Instance Pools drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The instance pool for which to get or manage permissions") - if err != nil { - return err - } - args = append(args, id) + setPermissionsReq.RequestObjectId = new(args[0]) + + setPermissionsReq.RequestObjectType = new("instance-pools") + + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err } - if len(args) != 1 { - return errors.New("expected to have the instance pool for which to get or manage permissions") + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) + if err != nil { + return err } - setPermissionsReq.InstancePoolId = args[0] - response, err := w.InstancePools.SetPermissions(ctx, setPermissionsReq) + out, err := accessmanagement.PermissionsResponseFromSDK(response) if err != nil { return err } - - return cmdio.Render(ctx, response) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -745,13 +753,13 @@ func newSetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *compute.InstancePoolPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq compute.InstancePoolPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -772,10 +780,16 @@ func newUpdatePermissions() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -789,31 +803,24 @@ func newUpdatePermissions() *cobra.Command { } } } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down.") - names, err := w.InstancePools.InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Instance Pools drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The instance pool for which to get or manage permissions") - if err != nil { - return err - } - args = append(args, id) + updatePermissionsReq.RequestObjectId = new(args[0]) + + updatePermissionsReq.RequestObjectType = new("instance-pools") + + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err } - if len(args) != 1 { - return errors.New("expected to have the instance pool for which to get or manage permissions") + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) + if err != nil { + return err } - updatePermissionsReq.InstancePoolId = args[0] - response, err := w.InstancePools.UpdatePermissions(ctx, updatePermissionsReq) + out, err := accessmanagement.PermissionsResponseFromSDK(response) if err != nil { return err } - - return cmdio.Render(ctx, response) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/instance-profiles/instance-profiles.go b/cmd/workspace/instance-profiles/instance-profiles.go index 8ddbdaf8f2f..e3a2af71e89 100644 --- a/cmd/workspace/instance-profiles/instance-profiles.go +++ b/cmd/workspace/instance-profiles/instance-profiles.go @@ -10,8 +10,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" + + instanceprofiles "github.com/databricks/cli/libs/sdktypes/instanceprofiles/v2" + sdkinstanceprofiles "github.com/databricks/sdk-go/instanceprofiles/v2" ) // Slice with functions to override default command behavior. @@ -56,20 +58,20 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var addOverrides []func( *cobra.Command, - *compute.AddInstanceProfile, + *instanceprofiles.AddInstanceProfileRequest, ) func newAdd() *cobra.Command { cmd := &cobra.Command{} + var addReq instanceprofiles.AddInstanceProfileRequest - var addReq compute.AddInstanceProfile var addJson flags.JsonFlag cmd.Flags().Var(&addJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&addReq.IamRoleArn, "iam-role-arn", addReq.IamRoleArn, `The AWS IAM role ARN of the role associated with the instance profile.`) - cmd.Flags().BoolVar(&addReq.IsMetaInstanceProfile, "is-meta-instance-profile", addReq.IsMetaInstanceProfile, `Boolean flag indicating whether the instance profile should only be used in credential passthrough scenarios.`) - cmd.Flags().BoolVar(&addReq.SkipValidation, "skip-validation", addReq.SkipValidation, `By default, Databricks validates that it has sufficient permissions to launch instances with the instance profile.`) + flags.StringPtrVar(cmd.Flags(), &addReq.IamRoleArn, "iam-role-arn", `The AWS IAM role ARN of the role associated with the instance profile.`) + flags.BoolPtrVar(cmd.Flags(), &addReq.IsMetaInstanceProfile, "is-meta-instance-profile", `Boolean flag indicating whether the instance profile should only be used in credential passthrough scenarios.`) + flags.BoolPtrVar(cmd.Flags(), &addReq.SkipValidation, "skip-validation", `By default, Databricks validates that it has sufficient permissions to launch instances with the instance profile.`) cmd.Use = "add INSTANCE_PROFILE_ARN" cmd.Short = `Register an instance profile.` @@ -104,6 +106,7 @@ func newAdd() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := addJson.Unmarshal(&addReq) @@ -118,13 +121,19 @@ func newAdd() *cobra.Command { } } if !cmd.Flags().Changed("json") { - addReq.InstanceProfileArn = args[0] + addReq.InstanceProfileArn = new(args[0]) } - err = w.InstanceProfiles.Add(ctx, addReq) + sdkReq, err := instanceprofiles.AddInstanceProfileRequestToSDK(&addReq) + if err != nil { + return err + } + response, err := w.InstanceProfiles.AddInstanceProfile(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -146,19 +155,19 @@ func newAdd() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var editOverrides []func( *cobra.Command, - *compute.InstanceProfile, + *instanceprofiles.EditInstanceProfileRequest, ) func newEdit() *cobra.Command { cmd := &cobra.Command{} + var editReq instanceprofiles.EditInstanceProfileRequest - var editReq compute.InstanceProfile var editJson flags.JsonFlag cmd.Flags().Var(&editJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&editReq.IamRoleArn, "iam-role-arn", editReq.IamRoleArn, `The AWS IAM role ARN of the role associated with the instance profile.`) - cmd.Flags().BoolVar(&editReq.IsMetaInstanceProfile, "is-meta-instance-profile", editReq.IsMetaInstanceProfile, `Boolean flag indicating whether the instance profile should only be used in credential passthrough scenarios.`) + flags.StringPtrVar(cmd.Flags(), &editReq.IamRoleArn, "iam-role-arn", `The AWS IAM role ARN of the role associated with the instance profile.`) + flags.BoolPtrVar(cmd.Flags(), &editReq.IsMetaInstanceProfile, "is-meta-instance-profile", `Boolean flag indicating whether the instance profile should only be used in credential passthrough scenarios.`) cmd.Use = "edit INSTANCE_PROFILE_ARN" cmd.Short = `Edit an instance profile.` @@ -204,6 +213,7 @@ func newEdit() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := editJson.Unmarshal(&editReq) @@ -218,13 +228,19 @@ func newEdit() *cobra.Command { } } if !cmd.Flags().Changed("json") { - editReq.InstanceProfileArn = args[0] + editReq.InstanceProfileArn = new(args[0]) } - err = w.InstanceProfiles.Edit(ctx, editReq) + sdkReq, err := instanceprofiles.EditInstanceProfileRequestToSDK(&editReq) if err != nil { return err } + response, err := w.InstanceProfiles.EditInstanceProfile(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -276,7 +292,14 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response := w.InstanceProfiles.List(ctx) + _ = w + + sdkReq := &sdkinstanceprofiles.ListInstanceProfilesRequest{} + + response, err := w.InstanceProfiles.ListInstanceProfiles(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -284,7 +307,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := instanceprofiles.ListInstanceProfilesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.InstanceProfiles) } // Disable completions since they are not applicable. @@ -305,13 +332,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var removeOverrides []func( *cobra.Command, - *compute.RemoveInstanceProfile, + *instanceprofiles.RemoveInstanceProfileRequest, ) func newRemove() *cobra.Command { cmd := &cobra.Command{} + var removeReq instanceprofiles.RemoveInstanceProfileRequest - var removeReq compute.RemoveInstanceProfile var removeJson flags.JsonFlag cmd.Flags().Var(&removeJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -348,6 +375,7 @@ func newRemove() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := removeJson.Unmarshal(&removeReq) @@ -362,13 +390,19 @@ func newRemove() *cobra.Command { } } if !cmd.Flags().Changed("json") { - removeReq.InstanceProfileArn = args[0] + removeReq.InstanceProfileArn = new(args[0]) } - err = w.InstanceProfiles.Remove(ctx, removeReq) + sdkReq, err := instanceprofiles.RemoveInstanceProfileRequestToSDK(&removeReq) if err != nil { return err } + response, err := w.InstanceProfiles.RemoveInstanceProfile(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } diff --git a/cmd/workspace/ip-access-lists/ip-access-lists.go b/cmd/workspace/ip-access-lists/ip-access-lists.go index 2916a1d55b0..c32a5670377 100644 --- a/cmd/workspace/ip-access-lists/ip-access-lists.go +++ b/cmd/workspace/ip-access-lists/ip-access-lists.go @@ -10,8 +10,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" + + networking "github.com/databricks/cli/libs/sdktypes/networking/v1" + sdknetworking "github.com/databricks/sdk-go/networking/v1" ) // Slice with functions to override default command behavior. @@ -73,13 +75,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *settings.CreateIpAccessList, + *networking.CreateIpAccessListRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq networking.CreateIpAccessListRequest - var createReq settings.CreateIpAccessList var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -134,6 +136,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -148,22 +151,26 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Label = args[0] + createReq.Label = new(args[0]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createReq.ListType) - if err != nil { - return fmt.Errorf("invalid LIST_TYPE: %s", args[1]) - } - + createReq.ListType = networking.IpAccessListType(args[1]) } - response, err := w.IpAccessLists.Create(ctx, createReq) + sdkReq, err := networking.CreateIpAccessListRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Networking.CreateIpAccessList(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.CreateIpAccessListResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -184,13 +191,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteIpAccessListRequest, + *sdknetworking.DeleteIpAccessListRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq settings.DeleteIpAccessListRequest + var deleteReq sdknetworking.DeleteIpAccessListRequest cmd.Use = "delete IP_ACCESS_LIST_ID" cmd.Short = `Delete access list.` @@ -205,34 +211,26 @@ func newDelete() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No IP_ACCESS_LIST_ID argument specified. Loading names for Ip Access Lists drop-down.") - names, err := w.IpAccessLists.IpAccessListInfoLabelToListIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id for the corresponding ip access list") - } - deleteReq.IpAccessListId = args[0] + deleteReq.ListId = new(args[0]) - err = w.IpAccessLists.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Networking.DeleteIpAccessList(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -254,13 +252,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetIpAccessListRequest, + *sdknetworking.GetIpAccessListRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq settings.GetIpAccessListRequest + var getReq sdknetworking.GetIpAccessListRequest cmd.Use = "get IP_ACCESS_LIST_ID" cmd.Short = `Get access list.` @@ -275,36 +272,30 @@ func newGet() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No IP_ACCESS_LIST_ID argument specified. Loading names for Ip Access Lists drop-down.") - names, err := w.IpAccessLists.IpAccessListInfoLabelToListIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id for the corresponding ip access list") - } - getReq.IpAccessListId = args[0] + getReq.ListId = new(args[0]) - response, err := w.IpAccessLists.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Networking.GetIpAccessList(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := networking.GetIpAccessListResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -353,7 +344,14 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response := w.IpAccessLists.List(ctx) + _ = w + + sdkReq := &sdknetworking.ListIpAccessLists{} + + response, err := w.Networking.ListIpAccessLists(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -361,7 +359,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := networking.ListIpAccessListsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.IpAccessLists) } // Disable completions since they are not applicable. @@ -382,13 +384,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var replaceOverrides []func( *cobra.Command, - *settings.ReplaceIpAccessList, + *networking.ReplaceIpAccessListRequest, ) func newReplace() *cobra.Command { cmd := &cobra.Command{} + var replaceReq networking.ReplaceIpAccessListRequest - var replaceReq settings.ReplaceIpAccessList var replaceJson flags.JsonFlag cmd.Flags().Var(&replaceJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -441,6 +443,7 @@ func newReplace() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := replaceJson.Unmarshal(&replaceReq) @@ -454,30 +457,36 @@ func newReplace() *cobra.Command { } } } - replaceReq.IpAccessListId = args[0] + replaceReq.ListId = new(args[0]) if !cmd.Flags().Changed("json") { - replaceReq.Label = args[1] + replaceReq.Label = new(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &replaceReq.ListType) - if err != nil { - return fmt.Errorf("invalid LIST_TYPE: %s", args[2]) - } - + replaceReq.ListType = networking.IpAccessListType(args[2]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &replaceReq.Enabled) + var replaceEnabledArg bool + _, err = fmt.Sscan(args[3], &replaceEnabledArg) if err != nil { return fmt.Errorf("invalid ENABLED: %s", args[3]) } + replaceReq.Enabled = &replaceEnabledArg + } + sdkReq, err := networking.ReplaceIpAccessListRequestToSDK(&replaceReq) + if err != nil { + return err + } + response, err := w.Networking.ReplaceIpAccessList(ctx, *sdkReq) + if err != nil { + return err } - err = w.IpAccessLists.Replace(ctx, replaceReq) + out, err := networking.ReplaceIpAccessListResponseFromSDK(response) if err != nil { return err } - return nil + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -498,21 +507,21 @@ func newReplace() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateIpAccessList, + *networking.UpdateIpAccessListRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq networking.UpdateIpAccessListRequest - var updateReq settings.UpdateIpAccessList var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&updateReq.Enabled, "enabled", updateReq.Enabled, `Specifies whether this IP access list is enabled.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Enabled, "enabled", `Specifies whether this IP access list is enabled.`) // TODO: array: ip_addresses - cmd.Flags().StringVar(&updateReq.Label, "label", updateReq.Label, `Label for the IP access list.`) - cmd.Flags().Var(&updateReq.ListType, "list-type", `Supported values: [ALLOW, BLOCK]`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Label, "label", `Label for the IP access list.`) + flags.EnumVar(cmd.Flags(), &updateReq.ListType, "list-type", `Supported values: [ALLOW, BLOCK]`, "ListType", "ALLOW", "BLOCK") cmd.Use = "update IP_ACCESS_LIST_ID" cmd.Short = `Update access list.` @@ -544,10 +553,16 @@ func newUpdate() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -561,30 +576,22 @@ func newUpdate() *cobra.Command { } } } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No IP_ACCESS_LIST_ID argument specified. Loading names for Ip Access Lists drop-down.") - names, err := w.IpAccessLists.IpAccessListInfoLabelToListIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list") - if err != nil { - return err - } - args = append(args, id) + updateReq.ListId = new(args[0]) + + sdkReq, err := networking.UpdateIpAccessListRequestToSDK(&updateReq) + if err != nil { + return err } - if len(args) != 1 { - return errors.New("expected to have the id for the corresponding ip access list") + response, err := w.Networking.UpdateIpAccessList(ctx, *sdkReq) + if err != nil { + return err } - updateReq.IpAccessListId = args[0] - err = w.IpAccessLists.Update(ctx, updateReq) + out, err := networking.UpdateIpAccessListResponseFromSDK(response) if err != nil { return err } - return nil + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/jobs/jobs.go b/cmd/workspace/jobs/jobs.go index d1c7b68169e..e6bc9c424ee 100644 --- a/cmd/workspace/jobs/jobs.go +++ b/cmd/workspace/jobs/jobs.go @@ -8,11 +8,19 @@ import ( "time" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" ) // Slice with functions to override default command behavior. @@ -85,19 +93,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var cancelAllRunsOverrides []func( *cobra.Command, - *jobs.CancelAllRuns, + *jobs.CancelAllRunsRequest, ) func newCancelAllRuns() *cobra.Command { cmd := &cobra.Command{} + var cancelAllRunsReq jobs.CancelAllRunsRequest - var cancelAllRunsReq jobs.CancelAllRuns var cancelAllRunsJson flags.JsonFlag cmd.Flags().Var(&cancelAllRunsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&cancelAllRunsReq.AllQueuedRuns, "all-queued-runs", cancelAllRunsReq.AllQueuedRuns, `Optional boolean parameter to cancel all queued runs.`) - cmd.Flags().Int64Var(&cancelAllRunsReq.JobId, "job-id", cancelAllRunsReq.JobId, `The canonical identifier of the job to cancel all runs of.`) + flags.BoolPtrVar(cmd.Flags(), &cancelAllRunsReq.AllQueuedRuns, "all-queued-runs", `Optional boolean parameter to cancel all queued runs.`) + flags.Int64PtrVar(cmd.Flags(), &cancelAllRunsReq.JobId, "job-id", `The canonical identifier of the job to cancel all runs of.`) cmd.Use = "cancel-all-runs" cmd.Short = `Cancel all runs of a job.` @@ -119,6 +127,7 @@ func newCancelAllRuns() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := cancelAllRunsJson.Unmarshal(&cancelAllRunsReq) @@ -133,10 +142,16 @@ func newCancelAllRuns() *cobra.Command { } } - err = w.Jobs.CancelAllRuns(ctx, cancelAllRunsReq) + sdkReq, err := jobs.CancelAllRunsRequestToSDK(&cancelAllRunsReq) if err != nil { return err } + response, err := w.Jobs.CancelAllRuns(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -158,13 +173,13 @@ func newCancelAllRuns() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var cancelRunOverrides []func( *cobra.Command, - *jobs.CancelRun, + *jobs.CancelRunRequest, ) func newCancelRun() *cobra.Command { cmd := &cobra.Command{} + var cancelRunReq jobs.CancelRunRequest - var cancelRunReq jobs.CancelRun var cancelRunJson flags.JsonFlag var cancelRunSkipWait bool @@ -204,6 +219,7 @@ func newCancelRun() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := cancelRunJson.Unmarshal(&cancelRunReq) @@ -220,7 +236,7 @@ func newCancelRun() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No RUN_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -234,37 +250,47 @@ func newCancelRun() *cobra.Command { if len(args) != 1 { return errors.New("expected to have this field is required") } - _, err = fmt.Sscan(args[0], &cancelRunReq.RunId) + var cancelRunRunIdArg int64 + _, err = fmt.Sscan(args[0], &cancelRunRunIdArg) if err != nil { return fmt.Errorf("invalid RUN_ID: %s", args[0]) } - + cancelRunReq.RunId = &cancelRunRunIdArg } - wait, err := w.Jobs.CancelRun(ctx, cancelRunReq) + sdkReq, err := jobs.CancelRunRequestToSDK(&cancelRunReq) if err != nil { return err } - if cancelRunSkipWait { - return nil + wait, err := w.Jobs.CancelRun(ctx, *sdkReq) + if err != nil { + return err } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *jobs.Run) { - if i.State == nil { - return + if cancelRunSkipWait { + // Render the current state, as of right after the call. + current, err := w.Jobs.GetRun(ctx, sdkjobs.GetRunRequest{RunId: new(wait.GetRunId())}) + if err != nil { + return err } - status := i.State.LifeCycleState - statusMessage := fmt.Sprintf("current status: %s", status) - if i.State != nil { - statusMessage = i.State.StateMessage + out, err := jobs.GetRunResponseFromSDK(current) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(cancelRunTimeout) + return cmdio.Render(ctx, out) + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for cancel-run to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(cancelRunTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := jobs.GetRunResponseFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -285,13 +311,13 @@ func newCancelRun() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *jobs.CreateJob, + *jobs.CreateJobRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq jobs.CreateJobRequest - var createReq jobs.CreateJob var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -308,6 +334,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -324,12 +351,20 @@ func newCreate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Jobs.Create(ctx, createReq) + sdkReq, err := jobs.CreateJobRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Jobs.CreateJob(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := jobs.CreateJobResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -350,13 +385,13 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *jobs.DeleteJob, + *jobs.DeleteJobRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq jobs.DeleteJobRequest - var deleteReq jobs.DeleteJob var deleteJson flags.JsonFlag cmd.Flags().Var(&deleteJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -389,6 +424,7 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deleteJson.Unmarshal(&deleteReq) @@ -405,7 +441,7 @@ func newDelete() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No JOB_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -419,17 +455,24 @@ func newDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the canonical identifier of the job to delete") } - _, err = fmt.Sscan(args[0], &deleteReq.JobId) + var deleteJobIdArg int64 + _, err = fmt.Sscan(args[0], &deleteJobIdArg) if err != nil { return fmt.Errorf("invalid JOB_ID: %s", args[0]) } - + deleteReq.JobId = &deleteJobIdArg } - err = w.Jobs.Delete(ctx, deleteReq) + sdkReq, err := jobs.DeleteJobRequestToSDK(&deleteReq) if err != nil { return err } + response, err := w.Jobs.DeleteJob(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -451,13 +494,13 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteRunOverrides []func( *cobra.Command, - *jobs.DeleteRun, + *jobs.DeleteRunRequest, ) func newDeleteRun() *cobra.Command { cmd := &cobra.Command{} + var deleteRunReq jobs.DeleteRunRequest - var deleteRunReq jobs.DeleteRun var deleteRunJson flags.JsonFlag cmd.Flags().Var(&deleteRunJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -490,6 +533,7 @@ func newDeleteRun() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deleteRunJson.Unmarshal(&deleteRunReq) @@ -506,7 +550,7 @@ func newDeleteRun() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No RUN_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -520,17 +564,24 @@ func newDeleteRun() *cobra.Command { if len(args) != 1 { return errors.New("expected to have id of the run to delete") } - _, err = fmt.Sscan(args[0], &deleteRunReq.RunId) + var deleteRunRunIdArg int64 + _, err = fmt.Sscan(args[0], &deleteRunRunIdArg) if err != nil { return fmt.Errorf("invalid RUN_ID: %s", args[0]) } - + deleteRunReq.RunId = &deleteRunRunIdArg } - err = w.Jobs.DeleteRun(ctx, deleteRunReq) + sdkReq, err := jobs.DeleteRunRequestToSDK(&deleteRunReq) if err != nil { return err } + response, err := w.Jobs.DeleteRun(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -557,10 +608,9 @@ var exportRunOverrides []func( func newExportRun() *cobra.Command { cmd := &cobra.Command{} - var exportRunReq jobs.ExportRunRequest - cmd.Flags().Var(&exportRunReq.ViewsToExport, "views-to-export", `Which views to export (CODE, DASHBOARDS, or ALL). Supported values: [ALL, CODE, DASHBOARDS]`) + flags.EnumVar(cmd.Flags(), &exportRunReq.ViewsToExport, "views-to-export", `Which views to export (CODE, DASHBOARDS, or ALL). Supported values: [ALL, CODE, DASHBOARDS]`, "ViewsToExport", "ALL", "CODE", "DASHBOARDS") cmd.Use = "export-run RUN_ID" cmd.Short = `Export and retrieve a job run.` @@ -579,11 +629,12 @@ func newExportRun() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No RUN_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -597,17 +648,27 @@ func newExportRun() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the canonical identifier for the run") } - _, err = fmt.Sscan(args[0], &exportRunReq.RunId) + var exportRunRunIdArg int64 + _, err = fmt.Sscan(args[0], &exportRunRunIdArg) if err != nil { return fmt.Errorf("invalid RUN_ID: %s", args[0]) } + exportRunReq.RunId = &exportRunRunIdArg - response, err := w.Jobs.ExportRun(ctx, exportRunReq) + sdkReq, err := jobs.ExportRunRequestToSDK(&exportRunReq) + if err != nil { + return err + } + response, err := w.Jobs.ExportRun(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := jobs.ExportRunResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -633,11 +694,10 @@ var getOverrides []func( func newGet() *cobra.Command { cmd := &cobra.Command{} - var getReq jobs.GetJobRequest - cmd.Flags().BoolVar(&getReq.IncludeTriggerState, "include-trigger-state", getReq.IncludeTriggerState, `Flag that indicates that trigger state should be included in the response.`) - cmd.Flags().StringVar(&getReq.PageToken, "page-token", getReq.PageToken, `Use next_page_token returned from the previous GetJob response to request the next page of the job's array properties.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeTriggerState, "include-trigger-state", `Flag that indicates that trigger state should be included in the response.`) + flags.StringPtrVar(cmd.Flags(), &getReq.PageToken, "page-token", `Use next_page_token returned from the previous GetJob response to request the next page of the job's array properties.`) cmd.Use = "get JOB_ID" cmd.Short = `Get a single job.` @@ -666,11 +726,12 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No JOB_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -684,17 +745,27 @@ func newGet() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the canonical identifier of the job to retrieve information about") } - _, err = fmt.Sscan(args[0], &getReq.JobId) + var getJobIdArg int64 + _, err = fmt.Sscan(args[0], &getJobIdArg) if err != nil { return fmt.Errorf("invalid JOB_ID: %s", args[0]) } + getReq.JobId = &getJobIdArg - response, err := w.Jobs.Get(ctx, getReq) + sdkReq, err := jobs.GetJobRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.Jobs.GetJob(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := jobs.GetJobResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -715,13 +786,12 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *jobs.GetJobPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq jobs.GetJobPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels JOB_ID" cmd.Short = `Get job permission levels.` @@ -740,11 +810,12 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No JOB_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -758,14 +829,21 @@ func newGetPermissionLevels() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the job for which to get or manage permissions") } - getPermissionLevelsReq.JobId = args[0] + getPermissionLevelsReq.RequestObjectId = new(args[0]) + + getPermissionLevelsReq.RequestObjectType = new("jobs") - response, err := w.Jobs.GetPermissionLevels(ctx, getPermissionLevelsReq) + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -786,13 +864,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *jobs.GetJobPermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq jobs.GetJobPermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions JOB_ID" cmd.Short = `Get job permissions.` @@ -812,11 +889,12 @@ func newGetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No JOB_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -830,14 +908,21 @@ func newGetPermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the job for which to get or manage permissions") } - getPermissionsReq.JobId = args[0] + getPermissionsReq.RequestObjectId = new(args[0]) - response, err := w.Jobs.GetPermissions(ctx, getPermissionsReq) + getPermissionsReq.RequestObjectType = new("jobs") + + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -863,12 +948,11 @@ var getRunOverrides []func( func newGetRun() *cobra.Command { cmd := &cobra.Command{} - var getRunReq jobs.GetRunRequest - cmd.Flags().BoolVar(&getRunReq.IncludeHistory, "include-history", getRunReq.IncludeHistory, `Whether to include the repair history in the response.`) - cmd.Flags().BoolVar(&getRunReq.IncludeResolvedValues, "include-resolved-values", getRunReq.IncludeResolvedValues, `Whether to include resolved parameter values in the response.`) - cmd.Flags().StringVar(&getRunReq.PageToken, "page-token", getRunReq.PageToken, `Use next_page_token returned from the previous GetRun response to request the next page of the run's array properties.`) + flags.BoolPtrVar(cmd.Flags(), &getRunReq.IncludeHistory, "include-history", `Whether to include the repair history in the response.`) + flags.BoolPtrVar(cmd.Flags(), &getRunReq.IncludeResolvedValues, "include-resolved-values", `Whether to include resolved parameter values in the response.`) + flags.StringPtrVar(cmd.Flags(), &getRunReq.PageToken, "page-token", `Use next_page_token returned from the previous GetRun response to request the next page of the run's array properties.`) cmd.Use = "get-run RUN_ID" cmd.Short = `Get a single job run.` @@ -897,11 +981,12 @@ func newGetRun() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No RUN_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -915,17 +1000,27 @@ func newGetRun() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the canonical identifier of the run for which to retrieve the metadata") } - _, err = fmt.Sscan(args[0], &getRunReq.RunId) + var getRunRunIdArg int64 + _, err = fmt.Sscan(args[0], &getRunRunIdArg) if err != nil { return fmt.Errorf("invalid RUN_ID: %s", args[0]) } + getRunReq.RunId = &getRunRunIdArg - response, err := w.Jobs.GetRun(ctx, getRunReq) + sdkReq, err := jobs.GetRunRequestToSDK(&getRunReq) + if err != nil { + return err + } + response, err := w.Jobs.GetRun(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := jobs.GetRunResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -951,7 +1046,6 @@ var getRunOutputOverrides []func( func newGetRunOutput() *cobra.Command { cmd := &cobra.Command{} - var getRunOutputReq jobs.GetRunOutputRequest cmd.Use = "get-run-output RUN_ID" @@ -980,11 +1074,12 @@ func newGetRunOutput() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No RUN_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -998,17 +1093,27 @@ func newGetRunOutput() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the canonical identifier for the run") } - _, err = fmt.Sscan(args[0], &getRunOutputReq.RunId) + var getRunOutputRunIdArg int64 + _, err = fmt.Sscan(args[0], &getRunOutputRunIdArg) if err != nil { return fmt.Errorf("invalid RUN_ID: %s", args[0]) } + getRunOutputReq.RunId = &getRunOutputRunIdArg - response, err := w.Jobs.GetRunOutput(ctx, getRunOutputReq) + sdkReq, err := jobs.GetRunOutputRequestToSDK(&getRunOutputReq) + if err != nil { + return err + } + response, err := w.Jobs.GetRunOutput(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := jobs.GetRunOutputResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1034,24 +1139,24 @@ var listOverrides []func( func newList() *cobra.Command { cmd := &cobra.Command{} - var listReq jobs.ListJobsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().BoolVar(&listReq.ExpandTasks, "expand-tasks", listReq.ExpandTasks, `Whether to include task and cluster details in the response.`) - cmd.Flags().IntVar(&listReq.Limit, "page-size", listReq.Limit, `The number of jobs to return.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.ExpandTasks, "expand-tasks", `Whether to include task and cluster details in the response.`) + flags.IntPtrVar(cmd.Flags(), &listReq.Limit, "page-size", `The number of jobs to return.`) cmd.Flags().Lookup("page-size").Hidden = true - cmd.Flags().StringVar(&listReq.Name, "name", listReq.Name, `A filter on the list based on the exact (case insensitive) job name.`) - cmd.Flags().IntVar(&listReq.Offset, "offset", listReq.Offset, `The offset of the first job to return, relative to the most recently created job.`) + flags.StringPtrVar(cmd.Flags(), &listReq.Name, "name", `A filter on the list based on the exact (case insensitive) job name.`) + flags.IntPtrVar(cmd.Flags(), &listReq.Offset, "offset", `The offset of the first job to return, relative to the most recently created job.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -1073,16 +1178,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Jobs.List(ctx, listReq) + sdkReq, err := jobs.ListJobsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Jobs.ListJobsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, jobs.BaseJobFromSDK)) } // Disable completions since they are not applicable. @@ -1108,29 +1217,29 @@ var listRunsOverrides []func( func newListRuns() *cobra.Command { cmd := &cobra.Command{} - var listRunsReq jobs.ListRunsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listRunsLimit int - cmd.Flags().BoolVar(&listRunsReq.ActiveOnly, "active-only", listRunsReq.ActiveOnly, `If active_only is true, only active runs are included in the results; otherwise, lists both active and completed runs.`) - cmd.Flags().BoolVar(&listRunsReq.CompletedOnly, "completed-only", listRunsReq.CompletedOnly, `If completed_only is true, only completed runs are included in the results; otherwise, lists both active and completed runs.`) - cmd.Flags().BoolVar(&listRunsReq.ExpandTasks, "expand-tasks", listRunsReq.ExpandTasks, `Whether to include task and cluster details in the response.`) - cmd.Flags().Int64Var(&listRunsReq.JobId, "job-id", listRunsReq.JobId, `The job for which to list runs.`) - cmd.Flags().IntVar(&listRunsReq.Limit, "page-size", listRunsReq.Limit, `The number of runs to return.`) + flags.BoolPtrVar(cmd.Flags(), &listRunsReq.ActiveOnly, "active-only", `If active_only is true, only active runs are included in the results; otherwise, lists both active and completed runs.`) + flags.BoolPtrVar(cmd.Flags(), &listRunsReq.CompletedOnly, "completed-only", `If completed_only is true, only completed runs are included in the results; otherwise, lists both active and completed runs.`) + flags.BoolPtrVar(cmd.Flags(), &listRunsReq.ExpandTasks, "expand-tasks", `Whether to include task and cluster details in the response.`) + flags.Int64PtrVar(cmd.Flags(), &listRunsReq.JobId, "job-id", `The job for which to list runs.`) + flags.IntPtrVar(cmd.Flags(), &listRunsReq.Limit, "page-size", `The number of runs to return.`) cmd.Flags().Lookup("page-size").Hidden = true - cmd.Flags().IntVar(&listRunsReq.Offset, "offset", listRunsReq.Offset, `The offset of the first run to return, relative to the most recent run.`) - cmd.Flags().Var(&listRunsReq.RunType, "run-type", `The type of runs to return. Supported values: [JOB_RUN, SUBMIT_RUN, WORKFLOW_RUN]`) - cmd.Flags().Int64Var(&listRunsReq.StartTimeFrom, "start-time-from", listRunsReq.StartTimeFrom, `Show runs that started _at or after_ this value.`) - cmd.Flags().Int64Var(&listRunsReq.StartTimeTo, "start-time-to", listRunsReq.StartTimeTo, `Show runs that started _at or before_ this value.`) + flags.IntPtrVar(cmd.Flags(), &listRunsReq.Offset, "offset", `The offset of the first run to return, relative to the most recent run.`) + flags.EnumVar(cmd.Flags(), &listRunsReq.RunType, "run-type", `The type of runs to return. Supported values: [JOB_RUN, SUBMIT_RUN, WORKFLOW_RUN]`, "RunType", "JOB_RUN", "SUBMIT_RUN", "WORKFLOW_RUN") + flags.Int64PtrVar(cmd.Flags(), &listRunsReq.StartTimeFrom, "start-time-from", `Show runs that started _at or after_ this value.`) + flags.Int64PtrVar(cmd.Flags(), &listRunsReq.StartTimeTo, "start-time-to", `Show runs that started _at or before_ this value.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listRunsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listRunsReq.PageToken, "page-token", listRunsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listRunsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-runs" @@ -1153,16 +1262,20 @@ func newListRuns() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Jobs.ListRuns(ctx, listRunsReq) + sdkReq, err := jobs.ListRunsRequestToSDK(&listRunsReq) + if err != nil { + return err + } if listRunsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listRunsLimit) } if listRunsLimit > 0 { ctx = cmdio.WithLimit(ctx, listRunsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Jobs.ListRunsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, jobs.BaseRunFromSDK)) } // Disable completions since they are not applicable. @@ -1183,13 +1296,13 @@ func newListRuns() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var repairRunOverrides []func( *cobra.Command, - *jobs.RepairRun, + *jobs.RepairRunRequest, ) func newRepairRun() *cobra.Command { cmd := &cobra.Command{} + var repairRunReq jobs.RepairRunRequest - var repairRunReq jobs.RepairRun var repairRunJson flags.JsonFlag var repairRunSkipWait bool @@ -1203,14 +1316,14 @@ func newRepairRun() *cobra.Command { // TODO: array: dbt_commands // TODO: array: jar_params // TODO: map via StringToStringVar: job_parameters - cmd.Flags().Int64Var(&repairRunReq.LatestRepairId, "latest-repair-id", repairRunReq.LatestRepairId, `The ID of the latest repair.`) + flags.Int64PtrVar(cmd.Flags(), &repairRunReq.LatestRepairId, "latest-repair-id", `The ID of the latest repair.`) // TODO: map via StringToStringVar: notebook_params - cmd.Flags().Var(&repairRunReq.PerformanceTarget, "performance-target", `The performance mode on a serverless job. Supported values: [PERFORMANCE_OPTIMIZED, STANDARD]`) + flags.EnumVar(cmd.Flags(), &repairRunReq.PerformanceTarget, "performance-target", `The performance mode on a serverless job. Supported values: [PERFORMANCE_OPTIMIZED, STANDARD]`, "PerformanceTarget", "PERFORMANCE_OPTIMIZED", "STANDARD") // TODO: complex arg: pipeline_params // TODO: map via StringToStringVar: python_named_params // TODO: array: python_params - cmd.Flags().BoolVar(&repairRunReq.RerunAllFailedTasks, "rerun-all-failed-tasks", repairRunReq.RerunAllFailedTasks, `If true, repair all failed tasks.`) - cmd.Flags().BoolVar(&repairRunReq.RerunDependentTasks, "rerun-dependent-tasks", repairRunReq.RerunDependentTasks, `If true, repair all tasks that depend on the tasks in rerun_tasks, even if they were previously successful.`) + flags.BoolPtrVar(cmd.Flags(), &repairRunReq.RerunAllFailedTasks, "rerun-all-failed-tasks", `If true, repair all failed tasks.`) + flags.BoolPtrVar(cmd.Flags(), &repairRunReq.RerunDependentTasks, "rerun-dependent-tasks", `If true, repair all tasks that depend on the tasks in rerun_tasks, even if they were previously successful.`) // TODO: array: rerun_tasks // TODO: array: spark_submit_params // TODO: map via StringToStringVar: sql_params @@ -1245,6 +1358,7 @@ func newRepairRun() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := repairRunJson.Unmarshal(&repairRunReq) @@ -1261,7 +1375,7 @@ func newRepairRun() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No RUN_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1275,37 +1389,48 @@ func newRepairRun() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the job run id of the run to repair") } - _, err = fmt.Sscan(args[0], &repairRunReq.RunId) + var repairRunRunIdArg int64 + _, err = fmt.Sscan(args[0], &repairRunRunIdArg) if err != nil { return fmt.Errorf("invalid RUN_ID: %s", args[0]) } + repairRunReq.RunId = &repairRunRunIdArg } - wait, err := w.Jobs.RepairRun(ctx, repairRunReq) + sdkReq, err := jobs.RepairRunRequestToSDK(&repairRunReq) if err != nil { return err } if repairRunSkipWait { - return cmdio.Render(ctx, wait.Response) - } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *jobs.Run) { - if i.State == nil { - return + api, err := apiclient.New(w.Config) + if err != nil { + return err } - status := i.State.LifeCycleState - statusMessage := fmt.Sprintf("current status: %s", status) - if i.State != nil { - statusMessage = i.State.StateMessage + var current jobs.RepairRunResponse + err = api.Do(ctx, "POST", "/api/2.2/jobs/runs/repair", auth.WorkspaceIDHeaders(w.Config), nil, &repairRunReq, ¤t) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(repairRunTimeout) + return cmdio.Render(ctx, current) + } + wait, err := w.Jobs.Repair(ctx, *sdkReq) + if err != nil { + return err + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for repair-run to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(repairRunTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := jobs.GetRunResponseFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1326,13 +1451,13 @@ func newRepairRun() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var resetOverrides []func( *cobra.Command, - *jobs.ResetJob, + *jobs.ResetJobRequest, ) func newReset() *cobra.Command { cmd := &cobra.Command{} + var resetReq jobs.ResetJobRequest - var resetReq jobs.ResetJob var resetJson flags.JsonFlag cmd.Flags().Var(&resetJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1352,6 +1477,7 @@ func newReset() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := resetJson.Unmarshal(&resetReq) @@ -1368,10 +1494,16 @@ func newReset() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - err = w.Jobs.Reset(ctx, resetReq) + sdkReq, err := jobs.ResetJobRequestToSDK(&resetReq) if err != nil { return err } + response, err := w.Jobs.ResetJob(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -1393,13 +1525,13 @@ func newReset() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var runNowOverrides []func( *cobra.Command, - *jobs.RunNow, + *jobs.RunNowRequest, ) func newRunNow() *cobra.Command { cmd := &cobra.Command{} + var runNowReq jobs.RunNowRequest - var runNowReq jobs.RunNow var runNowJson flags.JsonFlag var runNowSkipWait bool @@ -1411,12 +1543,12 @@ func newRunNow() *cobra.Command { cmd.Flags().Var(&runNowJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: dbt_commands - cmd.Flags().StringVar(&runNowReq.IdempotencyToken, "idempotency-token", runNowReq.IdempotencyToken, `An optional token to guarantee the idempotency of job run requests.`) + flags.StringPtrVar(cmd.Flags(), &runNowReq.IdempotencyToken, "idempotency-token", `An optional token to guarantee the idempotency of job run requests.`) // TODO: array: jar_params // TODO: map via StringToStringVar: job_parameters // TODO: map via StringToStringVar: notebook_params // TODO: array: only - cmd.Flags().Var(&runNowReq.PerformanceTarget, "performance-target", `The performance mode on a serverless job. Supported values: [PERFORMANCE_OPTIMIZED, STANDARD]`) + flags.EnumVar(cmd.Flags(), &runNowReq.PerformanceTarget, "performance-target", `The performance mode on a serverless job. Supported values: [PERFORMANCE_OPTIMIZED, STANDARD]`, "PerformanceTarget", "PERFORMANCE_OPTIMIZED", "STANDARD") // TODO: complex arg: pipeline_params // TODO: map via StringToStringVar: python_named_params // TODO: array: python_params @@ -1452,6 +1584,7 @@ func newRunNow() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := runNowJson.Unmarshal(&runNowReq) @@ -1468,7 +1601,7 @@ func newRunNow() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No JOB_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1482,37 +1615,48 @@ func newRunNow() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the id of the job to be executed") } - _, err = fmt.Sscan(args[0], &runNowReq.JobId) + var runNowJobIdArg int64 + _, err = fmt.Sscan(args[0], &runNowJobIdArg) if err != nil { return fmt.Errorf("invalid JOB_ID: %s", args[0]) } + runNowReq.JobId = &runNowJobIdArg } - wait, err := w.Jobs.RunNow(ctx, runNowReq) + sdkReq, err := jobs.RunNowRequestToSDK(&runNowReq) if err != nil { return err } if runNowSkipWait { - return cmdio.Render(ctx, wait.Response) - } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *jobs.Run) { - if i.State == nil { - return + api, err := apiclient.New(w.Config) + if err != nil { + return err } - status := i.State.LifeCycleState - statusMessage := fmt.Sprintf("current status: %s", status) - if i.State != nil { - statusMessage = i.State.StateMessage + var current jobs.RunNowResponse + err = api.Do(ctx, "POST", "/api/2.2/jobs/run-now", auth.WorkspaceIDHeaders(w.Config), nil, &runNowReq, ¤t) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(runNowTimeout) + return cmdio.Render(ctx, current) + } + wait, err := w.Jobs.RunNow(ctx, *sdkReq) + if err != nil { + return err + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for run-now to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(runNowTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := jobs.GetRunResponseFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1533,13 +1677,13 @@ func newRunNow() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *jobs.JobPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq jobs.JobPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1565,6 +1709,7 @@ func newSetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -1581,7 +1726,7 @@ func newSetPermissions() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No JOB_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1595,14 +1740,24 @@ func newSetPermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the job for which to get or manage permissions") } - setPermissionsReq.JobId = args[0] + setPermissionsReq.RequestObjectId = new(args[0]) - response, err := w.Jobs.SetPermissions(ctx, setPermissionsReq) + setPermissionsReq.RequestObjectType = new("jobs") + + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1623,13 +1778,13 @@ func newSetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var submitOverrides []func( *cobra.Command, - *jobs.SubmitRun, + *jobs.SubmitRunRequest, ) func newSubmit() *cobra.Command { cmd := &cobra.Command{} + var submitReq jobs.SubmitRunRequest - var submitReq jobs.SubmitRun var submitJson flags.JsonFlag var submitSkipWait bool @@ -1641,21 +1796,21 @@ func newSubmit() *cobra.Command { cmd.Flags().Var(&submitJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: access_control_list - cmd.Flags().StringVar(&submitReq.BudgetPolicyId, "budget-policy-id", submitReq.BudgetPolicyId, `The user specified id of the budget policy to use for this one-time run.`) + flags.StringPtrVar(cmd.Flags(), &submitReq.BudgetPolicyId, "budget-policy-id", `The user specified id of the budget policy to use for this one-time run.`) // TODO: complex arg: email_notifications // TODO: array: environment_variables // TODO: array: environments // TODO: complex arg: git_source // TODO: complex arg: health - cmd.Flags().StringVar(&submitReq.IdempotencyToken, "idempotency-token", submitReq.IdempotencyToken, `An optional token that can be used to guarantee the idempotency of job run requests.`) + flags.StringPtrVar(cmd.Flags(), &submitReq.IdempotencyToken, "idempotency-token", `An optional token that can be used to guarantee the idempotency of job run requests.`) // TODO: complex arg: notification_settings - cmd.Flags().Var(&submitReq.PerformanceTarget, "performance-target", `The performance mode on a serverless one-time run. Supported values: [PERFORMANCE_OPTIMIZED, STANDARD]`) + flags.EnumVar(cmd.Flags(), &submitReq.PerformanceTarget, "performance-target", `The performance mode on a serverless one-time run. Supported values: [PERFORMANCE_OPTIMIZED, STANDARD]`, "PerformanceTarget", "PERFORMANCE_OPTIMIZED", "STANDARD") // TODO: complex arg: queue // TODO: complex arg: run_as - cmd.Flags().StringVar(&submitReq.RunName, "run-name", submitReq.RunName, `An optional name for the run.`) + flags.StringPtrVar(cmd.Flags(), &submitReq.RunName, "run-name", `An optional name for the run.`) // TODO: array: tasks - cmd.Flags().IntVar(&submitReq.TimeoutSeconds, "timeout-seconds", submitReq.TimeoutSeconds, `An optional timeout applied to each run of this job.`) - cmd.Flags().StringVar(&submitReq.UsagePolicyId, "usage-policy-id", submitReq.UsagePolicyId, `The user specified id of the usage policy to use for this one-time run.`) + flags.IntPtrVar(cmd.Flags(), &submitReq.TimeoutSeconds, "timeout-seconds", `An optional timeout applied to each run of this job.`) + flags.StringPtrVar(cmd.Flags(), &submitReq.UsagePolicyId, "usage-policy-id", `The user specified id of the usage policy to use for this one-time run.`) // TODO: complex arg: webhook_notifications cmd.Use = "submit" @@ -1687,6 +1842,7 @@ func newSubmit() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := submitJson.Unmarshal(&submitReq) @@ -1701,30 +1857,39 @@ func newSubmit() *cobra.Command { } } - wait, err := w.Jobs.Submit(ctx, submitReq) + sdkReq, err := jobs.SubmitRunRequestToSDK(&submitReq) if err != nil { return err } if submitSkipWait { - return cmdio.Render(ctx, wait.Response) - } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *jobs.Run) { - if i.State == nil { - return + api, err := apiclient.New(w.Config) + if err != nil { + return err } - status := i.State.LifeCycleState - statusMessage := fmt.Sprintf("current status: %s", status) - if i.State != nil { - statusMessage = i.State.StateMessage + var current jobs.SubmitRunResponse + err = api.Do(ctx, "POST", "/api/2.2/jobs/runs/submit", auth.WorkspaceIDHeaders(w.Config), nil, &submitReq, ¤t) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(submitTimeout) + return cmdio.Render(ctx, current) + } + wait, err := w.Jobs.SubmitRun(ctx, *sdkReq) + if err != nil { + return err + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for submit to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(submitTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := jobs.GetRunResponseFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1745,13 +1910,13 @@ func newSubmit() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *jobs.UpdateJob, + *jobs.UpdateJobRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq jobs.UpdateJobRequest - var updateReq jobs.UpdateJob var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1788,6 +1953,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -1804,7 +1970,7 @@ func newUpdate() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No JOB_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1818,17 +1984,25 @@ func newUpdate() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the canonical identifier of the job to update") } - _, err = fmt.Sscan(args[0], &updateReq.JobId) + var updateJobIdArg int64 + _, err = fmt.Sscan(args[0], &updateJobIdArg) if err != nil { return fmt.Errorf("invalid JOB_ID: %s", args[0]) } + updateReq.JobId = &updateJobIdArg } - err = w.Jobs.Update(ctx, updateReq) + sdkReq, err := jobs.UpdateJobRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Jobs.UpdateJob(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -1850,13 +2024,13 @@ func newUpdate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *jobs.JobPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq jobs.JobPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1881,6 +2055,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -1897,7 +2072,7 @@ func newUpdatePermissions() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No JOB_ID argument specified. Loading names for Jobs drop-down.") - names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Jobs.ListJobsIter(ctx, sdkjobs.ListJobsRequest{}), []string{"Settings", "Name"}, []string{"JobId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1911,14 +2086,24 @@ func newUpdatePermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the job for which to get or manage permissions") } - updatePermissionsReq.JobId = args[0] + updatePermissionsReq.RequestObjectId = new(args[0]) + + updatePermissionsReq.RequestObjectType = new("jobs") - response, err := w.Jobs.UpdatePermissions(ctx, updatePermissionsReq) + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/jobs/overrides.go b/cmd/workspace/jobs/overrides.go index ee7d205517c..d716c4a92b2 100644 --- a/cmd/workspace/jobs/overrides.go +++ b/cmd/workspace/jobs/overrides.go @@ -2,7 +2,7 @@ package jobs import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/jobs" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/spf13/cobra" ) diff --git a/cmd/workspace/knowledge-assistants/knowledge-assistants.go b/cmd/workspace/knowledge-assistants/knowledge-assistants.go index 3714ee727e8..c355f2ef24f 100644 --- a/cmd/workspace/knowledge-assistants/knowledge-assistants.go +++ b/cmd/workspace/knowledge-assistants/knowledge-assistants.go @@ -5,15 +5,18 @@ package knowledge_assistants import ( "errors" "fmt" - "strings" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "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" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + knowledgeassistants "github.com/databricks/cli/libs/sdktypes/knowledgeassistants/v1" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdkknowledgeassistants "github.com/databricks/sdk-go/knowledgeassistants/v1" ) // Slice with functions to override default command behavior. @@ -76,15 +79,15 @@ var createExampleOverrides []func( func newCreateExample() *cobra.Command { cmd := &cobra.Command{} - var createExampleReq knowledgeassistants.CreateExampleRequest - createExampleReq.Example = knowledgeassistants.Example{} + createExampleReq.Example = &knowledgeassistants.Example{} + var createExampleJson flags.JsonFlag cmd.Flags().Var(&createExampleJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: guidelines - cmd.Flags().StringVar(&createExampleReq.Example.Name, "name", createExampleReq.Example.Name, `Full resource name: knowledge-assistants/{knowledge_assistant_id}/examples/{example_id}.`) + flags.StringPtrVar(cmd.Flags(), &createExampleReq.Example.Name, "name", `Full resource name: knowledge-assistants/{knowledge_assistant_id}/examples/{example_id}.`) cmd.Use = "create-example PARENT QUESTION" cmd.Short = `*Beta* Create an example for a Knowledge Assistant.` @@ -119,6 +122,7 @@ Create an example for a Knowledge Assistant. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createExampleJson.Unmarshal(&createExampleReq.Example) @@ -132,17 +136,25 @@ Create an example for a Knowledge Assistant. } } } - createExampleReq.Parent = args[0] + createExampleReq.Parent = new(args[0]) if !cmd.Flags().Changed("json") { - createExampleReq.Example.Question = args[1] + createExampleReq.Example.Question = new(args[1]) } - response, err := w.KnowledgeAssistants.CreateExample(ctx, createExampleReq) + sdkReq, err := knowledgeassistants.CreateExampleRequestToSDK(&createExampleReq) + if err != nil { + return err + } + response, err := w.KnowledgeAssistants.CreateExample(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := knowledgeassistants.ExampleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -168,15 +180,15 @@ var createKnowledgeAssistantOverrides []func( func newCreateKnowledgeAssistant() *cobra.Command { cmd := &cobra.Command{} - var createKnowledgeAssistantReq knowledgeassistants.CreateKnowledgeAssistantRequest - createKnowledgeAssistantReq.KnowledgeAssistant = knowledgeassistants.KnowledgeAssistant{} + 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.`) + flags.StringPtrVar(cmd.Flags(), &createKnowledgeAssistantReq.KnowledgeAssistant.Instructions, "instructions", `Additional global instructions on how the agent should generate answers.`) + flags.StringPtrVar(cmd.Flags(), &createKnowledgeAssistantReq.KnowledgeAssistant.Name, "name", `The resource name of the Knowledge Assistant.`) cmd.Use = "create-knowledge-assistant DISPLAY_NAME DESCRIPTION" cmd.Short = `*Beta* Create a Knowledge Assistant.` @@ -214,6 +226,7 @@ Create a Knowledge Assistant. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createKnowledgeAssistantJson.Unmarshal(&createKnowledgeAssistantReq.KnowledgeAssistant) @@ -228,18 +241,26 @@ Create a Knowledge Assistant. } } if !cmd.Flags().Changed("json") { - createKnowledgeAssistantReq.KnowledgeAssistant.DisplayName = args[0] + createKnowledgeAssistantReq.KnowledgeAssistant.DisplayName = new(args[0]) } if !cmd.Flags().Changed("json") { - createKnowledgeAssistantReq.KnowledgeAssistant.Description = args[1] + createKnowledgeAssistantReq.KnowledgeAssistant.Description = new(args[1]) } - response, err := w.KnowledgeAssistants.CreateKnowledgeAssistant(ctx, createKnowledgeAssistantReq) + sdkReq, err := knowledgeassistants.CreateKnowledgeAssistantRequestToSDK(&createKnowledgeAssistantReq) + if err != nil { + return err + } + response, err := w.KnowledgeAssistants.CreateKnowledgeAssistant(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := knowledgeassistants.KnowledgeAssistantFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -265,9 +286,9 @@ var createKnowledgeSourceOverrides []func( func newCreateKnowledgeSource() *cobra.Command { cmd := &cobra.Command{} - var createKnowledgeSourceReq knowledgeassistants.CreateKnowledgeSourceRequest - createKnowledgeSourceReq.KnowledgeSource = knowledgeassistants.KnowledgeSource{} + 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`) @@ -275,7 +296,7 @@ func newCreateKnowledgeSource() *cobra.Command { // 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}.`) + flags.StringPtrVar(cmd.Flags(), &createKnowledgeSourceReq.KnowledgeSource.Name, "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 = `*Beta* Create a Knowledge Source.` @@ -318,6 +339,7 @@ Create a Knowledge Source. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createKnowledgeSourceJson.Unmarshal(&createKnowledgeSourceReq.KnowledgeSource) @@ -331,23 +353,31 @@ Create a Knowledge Source. } } } - createKnowledgeSourceReq.Parent = args[0] + createKnowledgeSourceReq.Parent = new(args[0]) if !cmd.Flags().Changed("json") { - createKnowledgeSourceReq.KnowledgeSource.DisplayName = args[1] + createKnowledgeSourceReq.KnowledgeSource.DisplayName = new(args[1]) } if !cmd.Flags().Changed("json") { - createKnowledgeSourceReq.KnowledgeSource.Description = args[2] + createKnowledgeSourceReq.KnowledgeSource.Description = new(args[2]) } if !cmd.Flags().Changed("json") { - createKnowledgeSourceReq.KnowledgeSource.SourceType = args[3] + createKnowledgeSourceReq.KnowledgeSource.SourceType = new(args[3]) } - response, err := w.KnowledgeAssistants.CreateKnowledgeSource(ctx, createKnowledgeSourceReq) + sdkReq, err := knowledgeassistants.CreateKnowledgeSourceRequestToSDK(&createKnowledgeSourceReq) + if err != nil { + return err + } + response, err := w.KnowledgeAssistants.CreateKnowledgeSource(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := knowledgeassistants.KnowledgeSourceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -368,13 +398,12 @@ Create a Knowledge Source. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteExampleOverrides []func( *cobra.Command, - *knowledgeassistants.DeleteExampleRequest, + *sdkknowledgeassistants.DeleteExampleRequest, ) func newDeleteExample() *cobra.Command { cmd := &cobra.Command{} - - var deleteExampleReq knowledgeassistants.DeleteExampleRequest + var deleteExampleReq sdkknowledgeassistants.DeleteExampleRequest cmd.Use = "delete-example NAME" cmd.Short = `*Beta* Delete an example from a Knowledge Assistant.` @@ -401,10 +430,12 @@ Delete an example from a Knowledge Assistant. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteExampleReq.Name = args[0] + deleteExampleReq.Name = new(args[0]) - err = w.KnowledgeAssistants.DeleteExample(ctx, deleteExampleReq) + sdkReq := &deleteExampleReq + err = w.KnowledgeAssistants.DeleteExample(ctx, *sdkReq) if err != nil { return err } @@ -429,13 +460,12 @@ Delete an example from a Knowledge Assistant. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteKnowledgeAssistantOverrides []func( *cobra.Command, - *knowledgeassistants.DeleteKnowledgeAssistantRequest, + *sdkknowledgeassistants.DeleteKnowledgeAssistantRequest, ) func newDeleteKnowledgeAssistant() *cobra.Command { cmd := &cobra.Command{} - - var deleteKnowledgeAssistantReq knowledgeassistants.DeleteKnowledgeAssistantRequest + var deleteKnowledgeAssistantReq sdkknowledgeassistants.DeleteKnowledgeAssistantRequest cmd.Use = "delete-knowledge-assistant NAME" cmd.Short = `*Beta* Delete a Knowledge Assistant.` @@ -462,10 +492,12 @@ Delete a Knowledge Assistant. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteKnowledgeAssistantReq.Name = args[0] + deleteKnowledgeAssistantReq.Name = new(args[0]) - err = w.KnowledgeAssistants.DeleteKnowledgeAssistant(ctx, deleteKnowledgeAssistantReq) + sdkReq := &deleteKnowledgeAssistantReq + err = w.KnowledgeAssistants.DeleteKnowledgeAssistant(ctx, *sdkReq) if err != nil { return err } @@ -490,13 +522,12 @@ Delete a Knowledge Assistant. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteKnowledgeSourceOverrides []func( *cobra.Command, - *knowledgeassistants.DeleteKnowledgeSourceRequest, + *sdkknowledgeassistants.DeleteKnowledgeSourceRequest, ) func newDeleteKnowledgeSource() *cobra.Command { cmd := &cobra.Command{} - - var deleteKnowledgeSourceReq knowledgeassistants.DeleteKnowledgeSourceRequest + var deleteKnowledgeSourceReq sdkknowledgeassistants.DeleteKnowledgeSourceRequest cmd.Use = "delete-knowledge-source NAME" cmd.Short = `*Beta* Delete a Knowledge Source.` @@ -523,10 +554,12 @@ Delete a Knowledge Source. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteKnowledgeSourceReq.Name = args[0] + deleteKnowledgeSourceReq.Name = new(args[0]) - err = w.KnowledgeAssistants.DeleteKnowledgeSource(ctx, deleteKnowledgeSourceReq) + sdkReq := &deleteKnowledgeSourceReq + err = w.KnowledgeAssistants.DeleteKnowledgeSource(ctx, *sdkReq) if err != nil { return err } @@ -551,13 +584,12 @@ Delete a Knowledge Source. // Functions can be added from the `init()` function in manually curated files in this directory. var getExampleOverrides []func( *cobra.Command, - *knowledgeassistants.GetExampleRequest, + *sdkknowledgeassistants.GetExampleRequest, ) func newGetExample() *cobra.Command { cmd := &cobra.Command{} - - var getExampleReq knowledgeassistants.GetExampleRequest + var getExampleReq sdkknowledgeassistants.GetExampleRequest cmd.Use = "get-example NAME" cmd.Short = `*Beta* Get an example from a Knowledge Assistant.` @@ -584,15 +616,21 @@ Get an example from a Knowledge Assistant. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getExampleReq.Name = args[0] + getExampleReq.Name = new(args[0]) - response, err := w.KnowledgeAssistants.GetExample(ctx, getExampleReq) + sdkReq := &getExampleReq + response, err := w.KnowledgeAssistants.GetExample(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := knowledgeassistants.ExampleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -613,13 +651,12 @@ Get an example from a Knowledge Assistant. // Functions can be added from the `init()` function in manually curated files in this directory. var getKnowledgeAssistantOverrides []func( *cobra.Command, - *knowledgeassistants.GetKnowledgeAssistantRequest, + *sdkknowledgeassistants.GetKnowledgeAssistantRequest, ) func newGetKnowledgeAssistant() *cobra.Command { cmd := &cobra.Command{} - - var getKnowledgeAssistantReq knowledgeassistants.GetKnowledgeAssistantRequest + var getKnowledgeAssistantReq sdkknowledgeassistants.GetKnowledgeAssistantRequest cmd.Use = "get-knowledge-assistant NAME" cmd.Short = `*Beta* Get a Knowledge Assistant.` @@ -646,15 +683,21 @@ Get a Knowledge Assistant. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getKnowledgeAssistantReq.Name = args[0] + getKnowledgeAssistantReq.Name = new(args[0]) - response, err := w.KnowledgeAssistants.GetKnowledgeAssistant(ctx, getKnowledgeAssistantReq) + sdkReq := &getKnowledgeAssistantReq + response, err := w.KnowledgeAssistants.GetKnowledgeAssistant(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := knowledgeassistants.KnowledgeAssistantFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -675,13 +718,12 @@ Get a Knowledge Assistant. // Functions can be added from the `init()` function in manually curated files in this directory. var getKnowledgeSourceOverrides []func( *cobra.Command, - *knowledgeassistants.GetKnowledgeSourceRequest, + *sdkknowledgeassistants.GetKnowledgeSourceRequest, ) func newGetKnowledgeSource() *cobra.Command { cmd := &cobra.Command{} - - var getKnowledgeSourceReq knowledgeassistants.GetKnowledgeSourceRequest + var getKnowledgeSourceReq sdkknowledgeassistants.GetKnowledgeSourceRequest cmd.Use = "get-knowledge-source NAME" cmd.Short = `*Beta* Get a Knowledge Source.` @@ -708,15 +750,21 @@ Get a Knowledge Source. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getKnowledgeSourceReq.Name = args[0] + getKnowledgeSourceReq.Name = new(args[0]) - response, err := w.KnowledgeAssistants.GetKnowledgeSource(ctx, getKnowledgeSourceReq) + sdkReq := &getKnowledgeSourceReq + response, err := w.KnowledgeAssistants.GetKnowledgeSource(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := knowledgeassistants.KnowledgeSourceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -737,13 +785,12 @@ Get a Knowledge Source. // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *knowledgeassistants.GetKnowledgeAssistantPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq knowledgeassistants.GetKnowledgeAssistantPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels KNOWLEDGE_ASSISTANT_ID" cmd.Short = `*Beta* Get knowledge assistant permission levels.` @@ -769,15 +816,23 @@ Get knowledge assistant permission levels. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getPermissionLevelsReq.RequestObjectId = new(args[0]) - getPermissionLevelsReq.KnowledgeAssistantId = args[0] + getPermissionLevelsReq.RequestObjectType = new("knowledge-assistants") - response, err := w.KnowledgeAssistants.GetPermissionLevels(ctx, getPermissionLevelsReq) + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -798,13 +853,12 @@ Get knowledge assistant permission levels. // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *knowledgeassistants.GetKnowledgeAssistantPermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq knowledgeassistants.GetKnowledgeAssistantPermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions KNOWLEDGE_ASSISTANT_ID" cmd.Short = `*Beta* Get knowledge assistant permissions.` @@ -831,15 +885,23 @@ Get knowledge assistant permissions. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getPermissionsReq.KnowledgeAssistantId = args[0] + getPermissionsReq.RequestObjectId = new(args[0]) - response, err := w.KnowledgeAssistants.GetPermissions(ctx, getPermissionsReq) + getPermissionsReq.RequestObjectType = new("knowledge-assistants") + + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -865,20 +927,20 @@ var listExamplesOverrides []func( func newListExamples() *cobra.Command { cmd := &cobra.Command{} - var listExamplesReq knowledgeassistants.ListExamplesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listExamplesLimit int - cmd.Flags().IntVar(&listExamplesReq.PageSize, "page-size", listExamplesReq.PageSize, `The maximum number of examples to return.`) + flags.IntPtrVar(cmd.Flags(), &listExamplesReq.PageSize, "page-size", `The maximum number of examples to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listExamplesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listExamplesReq.PageToken, "page-token", listExamplesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listExamplesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-examples PARENT" @@ -906,18 +968,22 @@ List examples for a Knowledge Assistant. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listExamplesReq.Parent = args[0] + listExamplesReq.Parent = new(args[0]) - response := w.KnowledgeAssistants.ListExamples(ctx, listExamplesReq) + sdkReq, err := knowledgeassistants.ListExamplesRequestToSDK(&listExamplesReq) + if err != nil { + return err + } if listExamplesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listExamplesLimit) } if listExamplesLimit > 0 { ctx = cmdio.WithLimit(ctx, listExamplesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.KnowledgeAssistants.ListExamplesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, knowledgeassistants.ExampleFromSDK)) } // Disable completions since they are not applicable. @@ -943,20 +1009,20 @@ var listKnowledgeAssistantsOverrides []func( func newListKnowledgeAssistants() *cobra.Command { cmd := &cobra.Command{} - var listKnowledgeAssistantsReq knowledgeassistants.ListKnowledgeAssistantsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listKnowledgeAssistantsLimit int - cmd.Flags().IntVar(&listKnowledgeAssistantsReq.PageSize, "page-size", listKnowledgeAssistantsReq.PageSize, `The maximum number of knowledge assistants to return.`) + flags.IntPtrVar(cmd.Flags(), &listKnowledgeAssistantsReq.PageSize, "page-size", `The maximum number of knowledge assistants to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listKnowledgeAssistantsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listKnowledgeAssistantsReq.PageToken, "page-token", listKnowledgeAssistantsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listKnowledgeAssistantsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-knowledge-assistants" @@ -980,16 +1046,20 @@ List Knowledge Assistants. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.KnowledgeAssistants.ListKnowledgeAssistants(ctx, listKnowledgeAssistantsReq) + sdkReq, err := knowledgeassistants.ListKnowledgeAssistantsRequestToSDK(&listKnowledgeAssistantsReq) + if err != nil { + return err + } if listKnowledgeAssistantsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listKnowledgeAssistantsLimit) } if listKnowledgeAssistantsLimit > 0 { ctx = cmdio.WithLimit(ctx, listKnowledgeAssistantsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.KnowledgeAssistants.ListKnowledgeAssistantsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, knowledgeassistants.KnowledgeAssistantFromSDK)) } // Disable completions since they are not applicable. @@ -1015,20 +1085,20 @@ var listKnowledgeSourcesOverrides []func( func newListKnowledgeSources() *cobra.Command { cmd := &cobra.Command{} - var listKnowledgeSourcesReq knowledgeassistants.ListKnowledgeSourcesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listKnowledgeSourcesLimit int - cmd.Flags().IntVar(&listKnowledgeSourcesReq.PageSize, "page-size", listKnowledgeSourcesReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listKnowledgeSourcesReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listKnowledgeSourcesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listKnowledgeSourcesReq.PageToken, "page-token", listKnowledgeSourcesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listKnowledgeSourcesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-knowledge-sources PARENT" @@ -1056,18 +1126,22 @@ List Knowledge Sources. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listKnowledgeSourcesReq.Parent = args[0] + listKnowledgeSourcesReq.Parent = new(args[0]) - response := w.KnowledgeAssistants.ListKnowledgeSources(ctx, listKnowledgeSourcesReq) + sdkReq, err := knowledgeassistants.ListKnowledgeSourcesRequestToSDK(&listKnowledgeSourcesReq) + if err != nil { + return err + } if listKnowledgeSourcesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listKnowledgeSourcesLimit) } if listKnowledgeSourcesLimit > 0 { ctx = cmdio.WithLimit(ctx, listKnowledgeSourcesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.KnowledgeAssistants.ListKnowledgeSourcesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, knowledgeassistants.KnowledgeSourceFromSDK)) } // Disable completions since they are not applicable. @@ -1088,13 +1162,13 @@ List Knowledge Sources. // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *knowledgeassistants.KnowledgeAssistantPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq knowledgeassistants.KnowledgeAssistantPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1127,6 +1201,7 @@ Set knowledge assistant permissions. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -1140,14 +1215,24 @@ Set knowledge assistant permissions. } } } - setPermissionsReq.KnowledgeAssistantId = args[0] + setPermissionsReq.RequestObjectId = new(args[0]) + + setPermissionsReq.RequestObjectType = new("knowledge-assistants") - response, err := w.KnowledgeAssistants.SetPermissions(ctx, setPermissionsReq) + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1173,7 +1258,6 @@ var syncKnowledgeSourcesOverrides []func( func newSyncKnowledgeSources() *cobra.Command { cmd := &cobra.Command{} - var syncKnowledgeSourcesReq knowledgeassistants.SyncKnowledgeSourcesRequest cmd.Use = "sync-knowledge-sources NAME" @@ -1202,10 +1286,15 @@ Syncs all Knowledge Sources for a Knowledge Assistant. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - syncKnowledgeSourcesReq.Name = args[0] + syncKnowledgeSourcesReq.Name = new(args[0]) - err = w.KnowledgeAssistants.SyncKnowledgeSources(ctx, syncKnowledgeSourcesReq) + sdkReq, err := knowledgeassistants.SyncKnowledgeSourcesRequestToSDK(&syncKnowledgeSourcesReq) + if err != nil { + return err + } + err = w.KnowledgeAssistants.SyncKnowledgeSources(ctx, *sdkReq) if err != nil { return err } @@ -1235,15 +1324,15 @@ var updateExampleOverrides []func( func newUpdateExample() *cobra.Command { cmd := &cobra.Command{} - var updateExampleReq knowledgeassistants.UpdateExampleRequest - updateExampleReq.Example = knowledgeassistants.Example{} + updateExampleReq.Example = &knowledgeassistants.Example{} + var updateExampleJson flags.JsonFlag cmd.Flags().Var(&updateExampleJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: guidelines - cmd.Flags().StringVar(&updateExampleReq.Example.Name, "name", updateExampleReq.Example.Name, `Full resource name: knowledge-assistants/{knowledge_assistant_id}/examples/{example_id}.`) + flags.StringPtrVar(cmd.Flags(), &updateExampleReq.Name, "name", `Full resource name: knowledge-assistants/{knowledge_assistant_id}/examples/{example_id}.`) cmd.Use = "update-example NAME UPDATE_MASK QUESTION" cmd.Short = `*Beta* Update an example in a Knowledge Assistant.` @@ -1280,6 +1369,7 @@ Update an example in a Knowledge Assistant. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateExampleJson.Unmarshal(&updateExampleReq.Example) @@ -1293,21 +1383,28 @@ Update an example in a Knowledge Assistant. } } } - updateExampleReq.Name = args[0] + updateExampleReq.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateExampleReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateExampleReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - updateExampleReq.Example.Question = args[2] + updateExampleReq.Example.Question = new(args[2]) } - response, err := w.KnowledgeAssistants.UpdateExample(ctx, updateExampleReq) + sdkReq, err := knowledgeassistants.UpdateExampleRequestToSDK(&updateExampleReq) + if err != nil { + return err + } + response, err := w.KnowledgeAssistants.UpdateExample(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := knowledgeassistants.ExampleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1333,15 +1430,15 @@ var updateKnowledgeAssistantOverrides []func( func newUpdateKnowledgeAssistant() *cobra.Command { cmd := &cobra.Command{} - var updateKnowledgeAssistantReq knowledgeassistants.UpdateKnowledgeAssistantRequest - updateKnowledgeAssistantReq.KnowledgeAssistant = knowledgeassistants.KnowledgeAssistant{} + 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.`) + flags.StringPtrVar(cmd.Flags(), &updateKnowledgeAssistantReq.KnowledgeAssistant.Instructions, "instructions", `Additional global instructions on how the agent should generate answers.`) + flags.StringPtrVar(cmd.Flags(), &updateKnowledgeAssistantReq.KnowledgeAssistant.Name, "name", `The resource name of the Knowledge Assistant.`) cmd.Use = "update-knowledge-assistant NAME UPDATE_MASK DISPLAY_NAME DESCRIPTION" cmd.Short = `*Beta* Update a Knowledge Assistant.` @@ -1384,6 +1481,7 @@ Update a Knowledge Assistant. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateKnowledgeAssistantJson.Unmarshal(&updateKnowledgeAssistantReq.KnowledgeAssistant) @@ -1397,24 +1495,31 @@ Update a Knowledge Assistant. } } } - updateKnowledgeAssistantReq.Name = args[0] + updateKnowledgeAssistantReq.KnowledgeAssistant.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateKnowledgeAssistantReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateKnowledgeAssistantReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - updateKnowledgeAssistantReq.KnowledgeAssistant.DisplayName = args[2] + updateKnowledgeAssistantReq.KnowledgeAssistant.DisplayName = new(args[2]) } if !cmd.Flags().Changed("json") { - updateKnowledgeAssistantReq.KnowledgeAssistant.Description = args[3] + updateKnowledgeAssistantReq.KnowledgeAssistant.Description = new(args[3]) } - response, err := w.KnowledgeAssistants.UpdateKnowledgeAssistant(ctx, updateKnowledgeAssistantReq) + sdkReq, err := knowledgeassistants.UpdateKnowledgeAssistantRequestToSDK(&updateKnowledgeAssistantReq) + if err != nil { + return err + } + response, err := w.KnowledgeAssistants.UpdateKnowledgeAssistant(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := knowledgeassistants.KnowledgeAssistantFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1440,9 +1545,9 @@ var updateKnowledgeSourceOverrides []func( func newUpdateKnowledgeSource() *cobra.Command { cmd := &cobra.Command{} - var updateKnowledgeSourceReq knowledgeassistants.UpdateKnowledgeSourceRequest - updateKnowledgeSourceReq.KnowledgeSource = knowledgeassistants.KnowledgeSource{} + 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`) @@ -1450,7 +1555,7 @@ func newUpdateKnowledgeSource() *cobra.Command { // 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}.`) + flags.StringPtrVar(cmd.Flags(), &updateKnowledgeSourceReq.Name, "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 = `*Beta* Update a Knowledge Source.` @@ -1496,6 +1601,7 @@ Update a Knowledge Source. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateKnowledgeSourceJson.Unmarshal(&updateKnowledgeSourceReq.KnowledgeSource) @@ -1509,27 +1615,34 @@ Update a Knowledge Source. } } } - updateKnowledgeSourceReq.Name = args[0] + updateKnowledgeSourceReq.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateKnowledgeSourceReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateKnowledgeSourceReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - updateKnowledgeSourceReq.KnowledgeSource.DisplayName = args[2] + updateKnowledgeSourceReq.KnowledgeSource.DisplayName = new(args[2]) } if !cmd.Flags().Changed("json") { - updateKnowledgeSourceReq.KnowledgeSource.Description = args[3] + updateKnowledgeSourceReq.KnowledgeSource.Description = new(args[3]) } if !cmd.Flags().Changed("json") { - updateKnowledgeSourceReq.KnowledgeSource.SourceType = args[4] + updateKnowledgeSourceReq.KnowledgeSource.SourceType = new(args[4]) } - response, err := w.KnowledgeAssistants.UpdateKnowledgeSource(ctx, updateKnowledgeSourceReq) + sdkReq, err := knowledgeassistants.UpdateKnowledgeSourceRequestToSDK(&updateKnowledgeSourceReq) + if err != nil { + return err + } + response, err := w.KnowledgeAssistants.UpdateKnowledgeSource(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := knowledgeassistants.KnowledgeSourceFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1550,13 +1663,13 @@ Update a Knowledge Source. // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *knowledgeassistants.KnowledgeAssistantPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq knowledgeassistants.KnowledgeAssistantPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1588,6 +1701,7 @@ Update knowledge assistant permissions. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -1601,14 +1715,24 @@ Update knowledge assistant permissions. } } } - updatePermissionsReq.KnowledgeAssistantId = args[0] + updatePermissionsReq.RequestObjectId = new(args[0]) + + updatePermissionsReq.RequestObjectType = new("knowledge-assistants") - response, err := w.KnowledgeAssistants.UpdatePermissions(ctx, updatePermissionsReq) + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/lakeview-embedded/lakeview-embedded.go b/cmd/workspace/lakeview-embedded/lakeview-embedded.go index 76a4d5b35b7..fa7f6f10003 100644 --- a/cmd/workspace/lakeview-embedded/lakeview-embedded.go +++ b/cmd/workspace/lakeview-embedded/lakeview-embedded.go @@ -6,8 +6,10 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/dashboards" + "github.com/databricks/cli/libs/flags" "github.com/spf13/cobra" + + lakeview "github.com/databricks/cli/libs/sdktypes/lakeview/v1" ) // Slice with functions to override default command behavior. @@ -44,16 +46,15 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPublishedDashboardTokenInfoOverrides []func( *cobra.Command, - *dashboards.GetPublishedDashboardTokenInfoRequest, + *lakeview.GetPublishedDashboardTokenInfoRequest, ) func newGetPublishedDashboardTokenInfo() *cobra.Command { cmd := &cobra.Command{} + var getPublishedDashboardTokenInfoReq lakeview.GetPublishedDashboardTokenInfoRequest - var getPublishedDashboardTokenInfoReq dashboards.GetPublishedDashboardTokenInfoRequest - - cmd.Flags().StringVar(&getPublishedDashboardTokenInfoReq.ExternalValue, "external-value", getPublishedDashboardTokenInfoReq.ExternalValue, `Provided external value to be included in the custom claim.`) - cmd.Flags().StringVar(&getPublishedDashboardTokenInfoReq.ExternalViewerId, "external-viewer-id", getPublishedDashboardTokenInfoReq.ExternalViewerId, `Provided external viewer id to be included in the custom claim.`) + flags.StringPtrVar(cmd.Flags(), &getPublishedDashboardTokenInfoReq.ExternalValue, "external-value", `Provided external value to be included in the custom claim.`) + flags.StringPtrVar(cmd.Flags(), &getPublishedDashboardTokenInfoReq.ExternalViewerId, "external-viewer-id", `Provided external viewer id to be included in the custom claim.`) cmd.Use = "get-published-dashboard-token-info DASHBOARD_ID" cmd.Short = `*Public Preview* Read information of a published dashboard to mint an OAuth token.` @@ -86,15 +87,24 @@ Read information of a published dashboard to mint an OAuth token. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getPublishedDashboardTokenInfoReq.DashboardId = args[0] + getPublishedDashboardTokenInfoReq.DashboardId = new(args[0]) - response, err := w.LakeviewEmbedded.GetPublishedDashboardTokenInfo(ctx, getPublishedDashboardTokenInfoReq) + sdkReq, err := lakeview.GetPublishedDashboardTokenInfoRequestToSDK(&getPublishedDashboardTokenInfoReq) + if err != nil { + return err + } + response, err := w.Lakeview.GetPublishedDashboardTokenInfo(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.GetPublishedDashboardTokenInfoResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/lakeview/lakeview.go b/cmd/workspace/lakeview/lakeview.go index f7b2d2f3c46..f0bfb582d2e 100644 --- a/cmd/workspace/lakeview/lakeview.go +++ b/cmd/workspace/lakeview/lakeview.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/dashboards" "github.com/spf13/cobra" + + lakeview "github.com/databricks/cli/libs/sdktypes/lakeview/v1" + sdklakeview "github.com/databricks/sdk-go/lakeview/v1" ) // Slice with functions to override default command behavior. @@ -68,23 +71,23 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *dashboards.CreateDashboardRequest, + *lakeview.CreateDashboardRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq lakeview.CreateDashboardRequest + createReq.Dashboard = &lakeview.DashboardCreate{} - var createReq dashboards.CreateDashboardRequest - createReq.Dashboard = dashboards.Dashboard{} 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.DatasetCatalog, "dataset-catalog", createReq.DatasetCatalog, `Sets the default catalog for all datasets in this dashboard.`) - cmd.Flags().StringVar(&createReq.DatasetSchema, "dataset-schema", createReq.DatasetSchema, `Sets the default schema for all datasets in this dashboard.`) - cmd.Flags().StringVar(&createReq.Dashboard.DisplayName, "display-name", createReq.Dashboard.DisplayName, `The display name of the dashboard.`) - cmd.Flags().StringVar(&createReq.Dashboard.SerializedDashboard, "serialized-dashboard", createReq.Dashboard.SerializedDashboard, `The contents of the dashboard in serialized string form.`) - cmd.Flags().StringVar(&createReq.Dashboard.WarehouseId, "warehouse-id", createReq.Dashboard.WarehouseId, `The warehouse ID used to run the dashboard.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DatasetCatalog, "dataset-catalog", `Sets the default catalog for all datasets in this dashboard.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DatasetSchema, "dataset-schema", `Sets the default schema for all datasets in this dashboard.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Dashboard.DisplayName, "display-name", `The display name of the dashboard.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Dashboard.SerializedDashboard, "serialized-dashboard", `The contents of the dashboard in serialized string form.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Dashboard.WarehouseId, "warehouse-id", `The warehouse ID used to run the dashboard.`) cmd.Use = "create" cmd.Short = `Create dashboard.` @@ -110,6 +113,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.Dashboard) @@ -124,12 +128,20 @@ func newCreate() *cobra.Command { } } - response, err := w.Lakeview.Create(ctx, createReq) + sdkReq, err := lakeview.CreateDashboardRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Lakeview.CreateDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.DashboardFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -150,21 +162,21 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createScheduleOverrides []func( *cobra.Command, - *dashboards.CreateScheduleRequest, + *lakeview.CreateScheduleRequest, ) func newCreateSchedule() *cobra.Command { cmd := &cobra.Command{} + var createScheduleReq lakeview.CreateScheduleRequest + createScheduleReq.Schedule = &lakeview.ScheduleCreate{} - var createScheduleReq dashboards.CreateScheduleRequest - createScheduleReq.Schedule = dashboards.Schedule{} var createScheduleJson flags.JsonFlag cmd.Flags().Var(&createScheduleJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createScheduleReq.Schedule.DisplayName, "display-name", createScheduleReq.Schedule.DisplayName, `The display name for schedule.`) - cmd.Flags().Var(&createScheduleReq.Schedule.PauseStatus, "pause-status", `The status indicates whether this schedule is paused or not. Supported values: [PAUSED, UNPAUSED]`) - cmd.Flags().StringVar(&createScheduleReq.Schedule.WarehouseId, "warehouse-id", createScheduleReq.Schedule.WarehouseId, `The warehouse id to run the dashboard with for the schedule.`) + flags.StringPtrVar(cmd.Flags(), &createScheduleReq.Schedule.DisplayName, "display-name", `The display name for schedule.`) + flags.EnumVar(cmd.Flags(), &createScheduleReq.Schedule.PauseStatus, "pause-status", `The status indicates whether this schedule is paused or not. Supported values: [PAUSED, UNPAUSED]`, "SchedulePauseStatus", "PAUSED", "UNPAUSED") + flags.StringPtrVar(cmd.Flags(), &createScheduleReq.Schedule.WarehouseId, "warehouse-id", `The warehouse id to run the dashboard with for the schedule.`) cmd.Use = "create-schedule DASHBOARD_ID CRON_SCHEDULE" cmd.Short = `Create dashboard schedule.` @@ -202,6 +214,7 @@ func newCreateSchedule() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createScheduleJson.Unmarshal(&createScheduleReq.Schedule) @@ -215,21 +228,25 @@ func newCreateSchedule() *cobra.Command { } } } - createScheduleReq.DashboardId = args[0] + createScheduleReq.Schedule.DashboardId = new(args[0]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createScheduleReq.Schedule.CronSchedule) - if err != nil { - return fmt.Errorf("invalid CRON_SCHEDULE: %s", args[1]) - } - + _ = args[1] // TODO: complex arg: cron_schedule } - response, err := w.Lakeview.CreateSchedule(ctx, createScheduleReq) + sdkReq, err := lakeview.CreateScheduleRequestToSDK(&createScheduleReq) + if err != nil { + return err + } + response, err := w.Lakeview.CreateSchedule(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.ScheduleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -250,19 +267,19 @@ func newCreateSchedule() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createSubscriptionOverrides []func( *cobra.Command, - *dashboards.CreateSubscriptionRequest, + *lakeview.CreateSubscriptionRequest, ) func newCreateSubscription() *cobra.Command { cmd := &cobra.Command{} + var createSubscriptionReq lakeview.CreateSubscriptionRequest + createSubscriptionReq.Subscription = &lakeview.SubscriptionCreate{} - var createSubscriptionReq dashboards.CreateSubscriptionRequest - createSubscriptionReq.Subscription = dashboards.Subscription{} var createSubscriptionJson flags.JsonFlag cmd.Flags().Var(&createSubscriptionJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createSubscriptionReq.Subscription.SkipNotify, "skip-notify", createSubscriptionReq.Subscription.SkipNotify, `Controls whether notifications are sent to the subscriber for scheduled dashboard refreshes.`) + flags.BoolPtrVar(cmd.Flags(), &createSubscriptionReq.Subscription.SkipNotify, "skip-notify", `Controls whether notifications are sent to the subscriber for scheduled dashboard refreshes.`) cmd.Use = "create-subscription DASHBOARD_ID SCHEDULE_ID SUBSCRIBER" cmd.Short = `Create schedule subscription.` @@ -304,6 +321,7 @@ func newCreateSubscription() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createSubscriptionJson.Unmarshal(&createSubscriptionReq.Subscription) @@ -317,22 +335,26 @@ func newCreateSubscription() *cobra.Command { } } } - createSubscriptionReq.DashboardId = args[0] - createSubscriptionReq.ScheduleId = args[1] + createSubscriptionReq.Subscription.DashboardId = new(args[0]) + createSubscriptionReq.Subscription.ScheduleId = new(args[1]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &createSubscriptionReq.Subscription.Subscriber) - if err != nil { - return fmt.Errorf("invalid SUBSCRIBER: %s", args[2]) - } - + _ = args[2] // TODO: complex arg: subscriber } - response, err := w.Lakeview.CreateSubscription(ctx, createSubscriptionReq) + sdkReq, err := lakeview.CreateSubscriptionRequestToSDK(&createSubscriptionReq) + if err != nil { + return err + } + response, err := w.Lakeview.CreateSubscription(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.SubscriptionFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -353,15 +375,14 @@ func newCreateSubscription() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteScheduleOverrides []func( *cobra.Command, - *dashboards.DeleteScheduleRequest, + *lakeview.DeleteScheduleRequest, ) func newDeleteSchedule() *cobra.Command { cmd := &cobra.Command{} + var deleteScheduleReq lakeview.DeleteScheduleRequest - var deleteScheduleReq dashboards.DeleteScheduleRequest - - cmd.Flags().StringVar(&deleteScheduleReq.Etag, "etag", deleteScheduleReq.Etag, `The etag for the schedule.`) + flags.StringPtrVar(cmd.Flags(), &deleteScheduleReq.Etag, "etag", `The etag for the schedule.`) cmd.Use = "delete-schedule DASHBOARD_ID SCHEDULE_ID" cmd.Short = `Delete dashboard schedule.` @@ -391,11 +412,16 @@ func newDeleteSchedule() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteScheduleReq.DashboardId = args[0] - deleteScheduleReq.ScheduleId = args[1] + deleteScheduleReq.DashboardId = new(args[0]) + deleteScheduleReq.ScheduleId = new(args[1]) - err = w.Lakeview.DeleteSchedule(ctx, deleteScheduleReq) + sdkReq, err := lakeview.DeleteScheduleRequestToSDK(&deleteScheduleReq) + if err != nil { + return err + } + err = w.Lakeview.DeleteSchedule(ctx, *sdkReq) if err != nil { return err } @@ -420,15 +446,14 @@ func newDeleteSchedule() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteSubscriptionOverrides []func( *cobra.Command, - *dashboards.DeleteSubscriptionRequest, + *lakeview.DeleteSubscriptionRequest, ) func newDeleteSubscription() *cobra.Command { cmd := &cobra.Command{} + var deleteSubscriptionReq lakeview.DeleteSubscriptionRequest - var deleteSubscriptionReq dashboards.DeleteSubscriptionRequest - - cmd.Flags().StringVar(&deleteSubscriptionReq.Etag, "etag", deleteSubscriptionReq.Etag, `The etag for the subscription.`) + flags.StringPtrVar(cmd.Flags(), &deleteSubscriptionReq.Etag, "etag", `The etag for the subscription.`) cmd.Use = "delete-subscription DASHBOARD_ID SCHEDULE_ID SUBSCRIPTION_ID" cmd.Short = `Delete schedule subscription.` @@ -462,12 +487,17 @@ func newDeleteSubscription() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteSubscriptionReq.DashboardId = args[0] - deleteSubscriptionReq.ScheduleId = args[1] - deleteSubscriptionReq.SubscriptionId = args[2] + deleteSubscriptionReq.DashboardId = new(args[0]) + deleteSubscriptionReq.ScheduleId = new(args[1]) + deleteSubscriptionReq.SubscriptionId = new(args[2]) - err = w.Lakeview.DeleteSubscription(ctx, deleteSubscriptionReq) + sdkReq, err := lakeview.DeleteSubscriptionRequestToSDK(&deleteSubscriptionReq) + if err != nil { + return err + } + err = w.Lakeview.DeleteSubscription(ctx, *sdkReq) if err != nil { return err } @@ -492,13 +522,12 @@ func newDeleteSubscription() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *dashboards.GetDashboardRequest, + *sdklakeview.GetDashboardRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq dashboards.GetDashboardRequest + var getReq sdklakeview.GetDashboardRequest cmd.Use = "get DASHBOARD_ID" cmd.Short = `Get dashboard.` @@ -527,15 +556,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.DashboardId = args[0] + getReq.DashboardId = new(args[0]) - response, err := w.Lakeview.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Lakeview.GetDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.DashboardFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -556,13 +591,12 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPublishedOverrides []func( *cobra.Command, - *dashboards.GetPublishedDashboardRequest, + *sdklakeview.GetPublishedDashboardRequest, ) func newGetPublished() *cobra.Command { cmd := &cobra.Command{} - - var getPublishedReq dashboards.GetPublishedDashboardRequest + var getPublishedReq sdklakeview.GetPublishedDashboardRequest cmd.Use = "get-published DASHBOARD_ID" cmd.Short = `Get published dashboard.` @@ -592,15 +626,21 @@ func newGetPublished() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getPublishedReq.DashboardId = args[0] + getPublishedReq.DashboardId = new(args[0]) - response, err := w.Lakeview.GetPublished(ctx, getPublishedReq) + sdkReq := &getPublishedReq + response, err := w.Lakeview.GetPublishedDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.PublishedDashboardFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -621,13 +661,12 @@ func newGetPublished() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getScheduleOverrides []func( *cobra.Command, - *dashboards.GetScheduleRequest, + *sdklakeview.GetScheduleRequest, ) func newGetSchedule() *cobra.Command { cmd := &cobra.Command{} - - var getScheduleReq dashboards.GetScheduleRequest + var getScheduleReq sdklakeview.GetScheduleRequest cmd.Use = "get-schedule DASHBOARD_ID SCHEDULE_ID" cmd.Short = `Get dashboard schedule.` @@ -660,16 +699,22 @@ func newGetSchedule() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getScheduleReq.DashboardId = args[0] - getScheduleReq.ScheduleId = args[1] + getScheduleReq.DashboardId = new(args[0]) + getScheduleReq.ScheduleId = new(args[1]) - response, err := w.Lakeview.GetSchedule(ctx, getScheduleReq) + sdkReq := &getScheduleReq + response, err := w.Lakeview.GetSchedule(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.ScheduleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -690,13 +735,12 @@ func newGetSchedule() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getSubscriptionOverrides []func( *cobra.Command, - *dashboards.GetSubscriptionRequest, + *sdklakeview.GetSubscriptionRequest, ) func newGetSubscription() *cobra.Command { cmd := &cobra.Command{} - - var getSubscriptionReq dashboards.GetSubscriptionRequest + var getSubscriptionReq sdklakeview.GetSubscriptionRequest cmd.Use = "get-subscription DASHBOARD_ID SCHEDULE_ID SUBSCRIPTION_ID" cmd.Short = `Get schedule subscription.` @@ -730,17 +774,23 @@ func newGetSubscription() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSubscriptionReq.DashboardId = args[0] - getSubscriptionReq.ScheduleId = args[1] - getSubscriptionReq.SubscriptionId = args[2] + getSubscriptionReq.DashboardId = new(args[0]) + getSubscriptionReq.ScheduleId = new(args[1]) + getSubscriptionReq.SubscriptionId = new(args[2]) - response, err := w.Lakeview.GetSubscription(ctx, getSubscriptionReq) + sdkReq := &getSubscriptionReq + response, err := w.Lakeview.GetSubscription(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.SubscriptionFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -761,27 +811,27 @@ func newGetSubscription() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *dashboards.ListDashboardsRequest, + *lakeview.ListDashboardsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq lakeview.ListDashboardsRequest - var listReq dashboards.ListDashboardsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `The number of dashboards to return per page.`) - cmd.Flags().BoolVar(&listReq.ShowTrashed, "show-trashed", listReq.ShowTrashed, `The flag to include dashboards located in the trash.`) - cmd.Flags().Var(&listReq.View, "view", `DASHBOARD_VIEW_BASIC only includes summary metadata from the dashboard. Supported values: [DASHBOARD_VIEW_BASIC]`) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", `The number of dashboards to return per page.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.ShowTrashed, "show-trashed", `The flag to include dashboards located in the trash.`) + flags.EnumVar(cmd.Flags(), &listReq.View, "view", `DASHBOARD_VIEW_BASIC only includes summary metadata from the dashboard. Supported values: [DASHBOARD_VIEW_BASIC]`, "DashboardView", "DASHBOARD_VIEW_BASIC") // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -808,16 +858,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Lakeview.List(ctx, listReq) + sdkReq, err := lakeview.ListDashboardsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Lakeview.ListDashboardsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, lakeview.DashboardFromSDK)) } // Disable completions since they are not applicable. @@ -838,25 +892,25 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listSchedulesOverrides []func( *cobra.Command, - *dashboards.ListSchedulesRequest, + *lakeview.ListSchedulesRequest, ) func newListSchedules() *cobra.Command { cmd := &cobra.Command{} + var listSchedulesReq lakeview.ListSchedulesRequest - var listSchedulesReq dashboards.ListSchedulesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSchedulesLimit int - cmd.Flags().IntVar(&listSchedulesReq.PageSize, "page-size", listSchedulesReq.PageSize, `The number of schedules to return per page.`) + flags.IntPtrVar(cmd.Flags(), &listSchedulesReq.PageSize, "page-size", `The number of schedules to return per page.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listSchedulesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSchedulesReq.PageToken, "page-token", listSchedulesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSchedulesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-schedules DASHBOARD_ID" @@ -889,18 +943,22 @@ func newListSchedules() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listSchedulesReq.DashboardId = args[0] + listSchedulesReq.DashboardId = new(args[0]) - response := w.Lakeview.ListSchedules(ctx, listSchedulesReq) + sdkReq, err := lakeview.ListSchedulesRequestToSDK(&listSchedulesReq) + if err != nil { + return err + } if listSchedulesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSchedulesLimit) } if listSchedulesLimit > 0 { ctx = cmdio.WithLimit(ctx, listSchedulesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Lakeview.ListSchedulesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, lakeview.ScheduleFromSDK)) } // Disable completions since they are not applicable. @@ -921,25 +979,25 @@ func newListSchedules() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listSubscriptionsOverrides []func( *cobra.Command, - *dashboards.ListSubscriptionsRequest, + *lakeview.ListSubscriptionsRequest, ) func newListSubscriptions() *cobra.Command { cmd := &cobra.Command{} + var listSubscriptionsReq lakeview.ListSubscriptionsRequest - var listSubscriptionsReq dashboards.ListSubscriptionsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSubscriptionsLimit int - cmd.Flags().IntVar(&listSubscriptionsReq.PageSize, "page-size", listSubscriptionsReq.PageSize, `The number of subscriptions to return per page.`) + flags.IntPtrVar(cmd.Flags(), &listSubscriptionsReq.PageSize, "page-size", `The number of subscriptions to return per page.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listSubscriptionsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSubscriptionsReq.PageToken, "page-token", listSubscriptionsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSubscriptionsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-subscriptions DASHBOARD_ID SCHEDULE_ID" @@ -973,19 +1031,23 @@ func newListSubscriptions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listSubscriptionsReq.DashboardId = args[0] - listSubscriptionsReq.ScheduleId = args[1] + listSubscriptionsReq.DashboardId = new(args[0]) + listSubscriptionsReq.ScheduleId = new(args[1]) - response := w.Lakeview.ListSubscriptions(ctx, listSubscriptionsReq) + sdkReq, err := lakeview.ListSubscriptionsRequestToSDK(&listSubscriptionsReq) + if err != nil { + return err + } if listSubscriptionsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSubscriptionsLimit) } if listSubscriptionsLimit > 0 { ctx = cmdio.WithLimit(ctx, listSubscriptionsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Lakeview.ListSubscriptionsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, lakeview.SubscriptionFromSDK)) } // Disable completions since they are not applicable. @@ -1006,20 +1068,20 @@ func newListSubscriptions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var migrateOverrides []func( *cobra.Command, - *dashboards.MigrateDashboardRequest, + *lakeview.MigrateDashboardRequest, ) func newMigrate() *cobra.Command { cmd := &cobra.Command{} + var migrateReq lakeview.MigrateDashboardRequest - var migrateReq dashboards.MigrateDashboardRequest var migrateJson flags.JsonFlag cmd.Flags().Var(&migrateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&migrateReq.DisplayName, "display-name", migrateReq.DisplayName, `Display name for the new Lakeview dashboard.`) - cmd.Flags().StringVar(&migrateReq.ParentPath, "parent-path", migrateReq.ParentPath, `The workspace path of the folder to contain the migrated Lakeview dashboard.`) - cmd.Flags().BoolVar(&migrateReq.UpdateParameterSyntax, "update-parameter-syntax", migrateReq.UpdateParameterSyntax, `Flag to indicate if mustache parameter syntax ({{ param }}) should be auto-updated to named syntax (:param) when converting datasets in the dashboard.`) + flags.StringPtrVar(cmd.Flags(), &migrateReq.DisplayName, "display-name", `Display name for the new Lakeview dashboard.`) + flags.StringPtrVar(cmd.Flags(), &migrateReq.ParentPath, "parent-path", `The workspace path of the folder to contain the migrated Lakeview dashboard.`) + flags.BoolPtrVar(cmd.Flags(), &migrateReq.UpdateParameterSyntax, "update-parameter-syntax", `Flag to indicate if mustache parameter syntax ({{ param }}) should be auto-updated to named syntax (:param) when converting datasets in the dashboard.`) cmd.Use = "migrate SOURCE_DASHBOARD_ID" cmd.Short = `Migrate dashboard.` @@ -1051,6 +1113,7 @@ func newMigrate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := migrateJson.Unmarshal(&migrateReq) @@ -1065,15 +1128,23 @@ func newMigrate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - migrateReq.SourceDashboardId = args[0] + migrateReq.SourceDashboardId = new(args[0]) } - response, err := w.Lakeview.Migrate(ctx, migrateReq) + sdkReq, err := lakeview.MigrateDashboardRequestToSDK(&migrateReq) + if err != nil { + return err + } + response, err := w.Lakeview.MigrateDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.DashboardFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1094,19 +1165,19 @@ func newMigrate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var publishOverrides []func( *cobra.Command, - *dashboards.PublishRequest, + *lakeview.PublishDashboardRequest, ) func newPublish() *cobra.Command { cmd := &cobra.Command{} + var publishReq lakeview.PublishDashboardRequest - var publishReq dashboards.PublishRequest var publishJson flags.JsonFlag cmd.Flags().Var(&publishJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&publishReq.EmbedCredentials, "embed-credentials", publishReq.EmbedCredentials, `Flag to indicate if the publisher's credentials should be embedded in the published dashboard.`) - cmd.Flags().StringVar(&publishReq.WarehouseId, "warehouse-id", publishReq.WarehouseId, `The ID of the warehouse that can be used to override the warehouse which was set in the draft.`) + flags.BoolPtrVar(cmd.Flags(), &publishReq.EmbedCredentials, "embed-credentials", `Flag to indicate if the publisher's credentials should be embedded in the published dashboard.`) + flags.StringPtrVar(cmd.Flags(), &publishReq.WarehouseId, "warehouse-id", `The ID of the warehouse that can be used to override the warehouse which was set in the draft.`) cmd.Use = "publish DASHBOARD_ID" cmd.Short = `Publish dashboard.` @@ -1135,6 +1206,7 @@ func newPublish() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := publishJson.Unmarshal(&publishReq) @@ -1148,14 +1220,22 @@ func newPublish() *cobra.Command { } } } - publishReq.DashboardId = args[0] + publishReq.DashboardId = new(args[0]) - response, err := w.Lakeview.Publish(ctx, publishReq) + sdkReq, err := lakeview.PublishDashboardRequestToSDK(&publishReq) + if err != nil { + return err + } + response, err := w.Lakeview.PublishDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.PublishedDashboardFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1176,13 +1256,13 @@ func newPublish() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var revertOverrides []func( *cobra.Command, - *dashboards.RevertDashboardRequest, + *lakeview.RevertDashboardRequest, ) func newRevert() *cobra.Command { cmd := &cobra.Command{} + var revertReq lakeview.RevertDashboardRequest - var revertReq dashboards.RevertDashboardRequest var revertJson flags.JsonFlag cmd.Flags().Var(&revertJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1214,6 +1294,7 @@ func newRevert() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := revertJson.Unmarshal(&revertReq) @@ -1227,14 +1308,22 @@ func newRevert() *cobra.Command { } } } - revertReq.DashboardId = args[0] + revertReq.DashboardId = new(args[0]) - response, err := w.Lakeview.Revert(ctx, revertReq) + sdkReq, err := lakeview.RevertDashboardRequestToSDK(&revertReq) + if err != nil { + return err + } + response, err := w.Lakeview.RevertDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.RevertDashboardResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1255,13 +1344,12 @@ func newRevert() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var trashOverrides []func( *cobra.Command, - *dashboards.TrashDashboardRequest, + *sdklakeview.TrashDashboardRequest, ) func newTrash() *cobra.Command { cmd := &cobra.Command{} - - var trashReq dashboards.TrashDashboardRequest + var trashReq sdklakeview.TrashDashboardRequest cmd.Use = "trash DASHBOARD_ID" cmd.Short = `Trash dashboard.` @@ -1290,13 +1378,17 @@ func newTrash() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - trashReq.DashboardId = args[0] + trashReq.DashboardId = new(args[0]) - err = w.Lakeview.Trash(ctx, trashReq) + sdkReq := &trashReq + response, err := w.Lakeview.TrashDashboard(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -1318,13 +1410,12 @@ func newTrash() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var unpublishOverrides []func( *cobra.Command, - *dashboards.UnpublishDashboardRequest, + *sdklakeview.UnpublishDashboardRequest, ) func newUnpublish() *cobra.Command { cmd := &cobra.Command{} - - var unpublishReq dashboards.UnpublishDashboardRequest + var unpublishReq sdklakeview.UnpublishDashboardRequest cmd.Use = "unpublish DASHBOARD_ID" cmd.Short = `Unpublish dashboard.` @@ -1353,13 +1444,17 @@ func newUnpublish() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - unpublishReq.DashboardId = args[0] + unpublishReq.DashboardId = new(args[0]) - err = w.Lakeview.Unpublish(ctx, unpublishReq) + sdkReq := &unpublishReq + response, err := w.Lakeview.UnpublishDashboard(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -1381,23 +1476,23 @@ func newUnpublish() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *dashboards.UpdateDashboardRequest, + *lakeview.UpdateDashboardRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq lakeview.UpdateDashboardRequest + updateReq.Dashboard = &lakeview.Dashboard{} - var updateReq dashboards.UpdateDashboardRequest - updateReq.Dashboard = dashboards.Dashboard{} 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.DatasetCatalog, "dataset-catalog", updateReq.DatasetCatalog, `Sets the default catalog for all datasets in this dashboard.`) - cmd.Flags().StringVar(&updateReq.DatasetSchema, "dataset-schema", updateReq.DatasetSchema, `Sets the default schema for all datasets in this dashboard.`) - cmd.Flags().StringVar(&updateReq.Dashboard.DisplayName, "display-name", updateReq.Dashboard.DisplayName, `The display name of the dashboard.`) - cmd.Flags().StringVar(&updateReq.Dashboard.SerializedDashboard, "serialized-dashboard", updateReq.Dashboard.SerializedDashboard, `The contents of the dashboard in serialized string form.`) - cmd.Flags().StringVar(&updateReq.Dashboard.WarehouseId, "warehouse-id", updateReq.Dashboard.WarehouseId, `The warehouse ID used to run the dashboard.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.DatasetCatalog, "dataset-catalog", `Sets the default catalog for all datasets in this dashboard.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.DatasetSchema, "dataset-schema", `Sets the default schema for all datasets in this dashboard.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Dashboard.DisplayName, "display-name", `The display name of the dashboard.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Dashboard.SerializedDashboard, "serialized-dashboard", `The contents of the dashboard in serialized string form.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Dashboard.WarehouseId, "warehouse-id", `The warehouse ID used to run the dashboard.`) cmd.Use = "update DASHBOARD_ID" cmd.Short = `Update dashboard.` @@ -1426,6 +1521,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.Dashboard) @@ -1439,14 +1535,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.DashboardId = args[0] + updateReq.Dashboard.DashboardId = new(args[0]) - response, err := w.Lakeview.Update(ctx, updateReq) + sdkReq, err := lakeview.UpdateDashboardRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Lakeview.UpdateDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.DashboardFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1467,21 +1571,21 @@ func newUpdate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateScheduleOverrides []func( *cobra.Command, - *dashboards.UpdateScheduleRequest, + *lakeview.UpdateScheduleRequest, ) func newUpdateSchedule() *cobra.Command { cmd := &cobra.Command{} + var updateScheduleReq lakeview.UpdateScheduleRequest + updateScheduleReq.Schedule = &lakeview.Schedule{} - var updateScheduleReq dashboards.UpdateScheduleRequest - updateScheduleReq.Schedule = dashboards.Schedule{} var updateScheduleJson flags.JsonFlag cmd.Flags().Var(&updateScheduleJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateScheduleReq.Schedule.DisplayName, "display-name", updateScheduleReq.Schedule.DisplayName, `The display name for schedule.`) - cmd.Flags().Var(&updateScheduleReq.Schedule.PauseStatus, "pause-status", `The status indicates whether this schedule is paused or not. Supported values: [PAUSED, UNPAUSED]`) - cmd.Flags().StringVar(&updateScheduleReq.Schedule.WarehouseId, "warehouse-id", updateScheduleReq.Schedule.WarehouseId, `The warehouse id to run the dashboard with for the schedule.`) + flags.StringPtrVar(cmd.Flags(), &updateScheduleReq.Schedule.DisplayName, "display-name", `The display name for schedule.`) + flags.EnumVar(cmd.Flags(), &updateScheduleReq.Schedule.PauseStatus, "pause-status", `The status indicates whether this schedule is paused or not. Supported values: [PAUSED, UNPAUSED]`, "SchedulePauseStatus", "PAUSED", "UNPAUSED") + flags.StringPtrVar(cmd.Flags(), &updateScheduleReq.Schedule.WarehouseId, "warehouse-id", `The warehouse id to run the dashboard with for the schedule.`) cmd.Use = "update-schedule DASHBOARD_ID SCHEDULE_ID CRON_SCHEDULE" cmd.Short = `Update dashboard schedule.` @@ -1520,6 +1624,7 @@ func newUpdateSchedule() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateScheduleJson.Unmarshal(&updateScheduleReq.Schedule) @@ -1533,22 +1638,26 @@ func newUpdateSchedule() *cobra.Command { } } } - updateScheduleReq.DashboardId = args[0] - updateScheduleReq.ScheduleId = args[1] + updateScheduleReq.Schedule.DashboardId = new(args[0]) + updateScheduleReq.Schedule.ScheduleId = new(args[1]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &updateScheduleReq.Schedule.CronSchedule) - if err != nil { - return fmt.Errorf("invalid CRON_SCHEDULE: %s", args[2]) - } - + _ = args[2] // TODO: complex arg: cron_schedule } - response, err := w.Lakeview.UpdateSchedule(ctx, updateScheduleReq) + sdkReq, err := lakeview.UpdateScheduleRequestToSDK(&updateScheduleReq) + if err != nil { + return err + } + response, err := w.Lakeview.UpdateSchedule(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := lakeview.ScheduleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/lakeview/overrides.go b/cmd/workspace/lakeview/overrides.go index 6ffb641aa97..1b4b6938ed1 100644 --- a/cmd/workspace/lakeview/overrides.go +++ b/cmd/workspace/lakeview/overrides.go @@ -1,15 +1,17 @@ package lakeview import ( - "github.com/databricks/databricks-sdk-go/service/dashboards" + lakeview "github.com/databricks/cli/libs/sdktypes/lakeview/v1" "github.com/spf13/cobra" ) -func publishOverride(cmd *cobra.Command, req *dashboards.PublishRequest) { +func publishOverride(cmd *cobra.Command, req *lakeview.PublishDashboardRequest) { originalRunE := cmd.RunE cmd.RunE = func(cmd *cobra.Command, args []string) error { - // Force send embed_credentials even when false, otherwise the API defaults to true. - req.ForceSendFields = append(req.ForceSendFields, "EmbedCredentials") + // Always send embed_credentials, otherwise the API defaults to true. + if req.EmbedCredentials == nil { + req.EmbedCredentials = new(false) + } return originalRunE(cmd, args) } } diff --git a/cmd/workspace/libraries/libraries.go b/cmd/workspace/libraries/libraries.go index 92b71e73019..5b6849dc5a8 100644 --- a/cmd/workspace/libraries/libraries.go +++ b/cmd/workspace/libraries/libraries.go @@ -10,8 +10,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" + + clusterlibraries "github.com/databricks/cli/libs/sdktypes/clusterlibraries/v2" + sdkclusterlibraries "github.com/databricks/sdk-go/clusterlibraries/v2" ) // Slice with functions to override default command behavior. @@ -95,7 +97,14 @@ func newAllClusterStatuses() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response := w.Libraries.AllClusterStatuses(ctx) + _ = w + + sdkReq := &sdkclusterlibraries.ListAllClusterLibraryStatusesRequest{} + + response, err := w.Libraries.AllClusterStatuses(ctx, *sdkReq) + if err != nil { + return err + } if allClusterStatusesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", allClusterStatusesLimit) } @@ -103,7 +112,11 @@ func newAllClusterStatuses() *cobra.Command { ctx = cmdio.WithLimit(ctx, allClusterStatusesLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := clusterlibraries.ListAllClusterLibraryStatusesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.Statuses) } // Disable completions since they are not applicable. @@ -124,13 +137,13 @@ func newAllClusterStatuses() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var clusterStatusOverrides []func( *cobra.Command, - *compute.ClusterStatus, + *clusterlibraries.ClusterStatusRequest, ) func newClusterStatus() *cobra.Command { cmd := &cobra.Command{} + var clusterStatusReq clusterlibraries.ClusterStatusRequest - var clusterStatusReq compute.ClusterStatus // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -169,10 +182,18 @@ func newClusterStatus() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - clusterStatusReq.ClusterId = args[0] + clusterStatusReq.ClusterId = new(args[0]) - response := w.Libraries.ClusterStatus(ctx, clusterStatusReq) + sdkReq, err := clusterlibraries.ClusterStatusRequestToSDK(&clusterStatusReq) + if err != nil { + return err + } + response, err := w.Libraries.ClusterStatus(ctx, *sdkReq) + if err != nil { + return err + } if clusterStatusLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", clusterStatusLimit) } @@ -180,7 +201,11 @@ func newClusterStatus() *cobra.Command { ctx = cmdio.WithLimit(ctx, clusterStatusLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := clusterlibraries.ClusterLibraryStatusesFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.LibraryStatuses) } // Disable completions since they are not applicable. @@ -201,13 +226,13 @@ func newClusterStatus() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var installOverrides []func( *cobra.Command, - *compute.InstallLibraries, + *clusterlibraries.InstallLibrariesRequest, ) func newInstall() *cobra.Command { cmd := &cobra.Command{} + var installReq clusterlibraries.InstallLibrariesRequest - var installReq compute.InstallLibraries var installJson flags.JsonFlag cmd.Flags().Var(&installJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -227,6 +252,7 @@ func newInstall() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := installJson.Unmarshal(&installReq) @@ -243,10 +269,16 @@ func newInstall() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - err = w.Libraries.Install(ctx, installReq) + sdkReq, err := clusterlibraries.InstallLibrariesRequestToSDK(&installReq) if err != nil { return err } + response, err := w.Libraries.InstallLibraries(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -268,13 +300,13 @@ func newInstall() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var uninstallOverrides []func( *cobra.Command, - *compute.UninstallLibraries, + *clusterlibraries.UninstallLibrariesRequest, ) func newUninstall() *cobra.Command { cmd := &cobra.Command{} + var uninstallReq clusterlibraries.UninstallLibrariesRequest - var uninstallReq compute.UninstallLibraries var uninstallJson flags.JsonFlag cmd.Flags().Var(&uninstallJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -295,6 +327,7 @@ func newUninstall() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := uninstallJson.Unmarshal(&uninstallReq) @@ -311,10 +344,16 @@ func newUninstall() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - err = w.Libraries.Uninstall(ctx, uninstallReq) + sdkReq, err := clusterlibraries.UninstallLibrariesRequestToSDK(&uninstallReq) + if err != nil { + return err + } + response, err := w.Libraries.UninstallLibraries(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } diff --git a/cmd/workspace/llm-proxy-partner-powered-workspace/llm-proxy-partner-powered-workspace.go b/cmd/workspace/llm-proxy-partner-powered-workspace/llm-proxy-partner-powered-workspace.go index e7186373e02..0ea8bfd5e02 100644 --- a/cmd/workspace/llm-proxy-partner-powered-workspace/llm-proxy-partner-powered-workspace.go +++ b/cmd/workspace/llm-proxy-partner-powered-workspace/llm-proxy-partner-powered-workspace.go @@ -5,11 +5,14 @@ package llm_proxy_partner_powered_workspace import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -52,15 +55,16 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteLlmProxyPartnerPoweredWorkspaceRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeleteLlmProxyPartnerPoweredWorkspaceRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `Delete the enable partner powered AI features workspace setting.` @@ -82,12 +86,24 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := "/api/2.0/settings/types/llm_proxy_partner_powered/names/default" - response, err := w.Settings.LlmProxyPartnerPoweredWorkspace().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -109,15 +125,16 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetLlmProxyPartnerPoweredWorkspaceRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetLlmProxyPartnerPoweredWorkspaceRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `Get the enable partner powered AI features workspace setting.` @@ -138,12 +155,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/llm_proxy_partner_powered/names/default" - response, err := w.Settings.LlmProxyPartnerPoweredWorkspace().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -165,13 +194,16 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateLlmProxyPartnerPoweredWorkspaceRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateLlmProxyPartnerPoweredWorkspaceRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -190,6 +222,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -206,11 +239,24 @@ func newUpdate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.LlmProxyPartnerPoweredWorkspace().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/llm_proxy_partner_powered/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/materialized-features/materialized-features.go b/cmd/workspace/materialized-features/materialized-features.go index 8da35540e24..03c86559c95 100644 --- a/cmd/workspace/materialized-features/materialized-features.go +++ b/cmd/workspace/materialized-features/materialized-features.go @@ -6,11 +6,14 @@ import ( "errors" "fmt" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/ml" "github.com/spf13/cobra" ) @@ -57,19 +60,23 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createFeatureTagOverrides []func( *cobra.Command, - *ml.CreateFeatureTagRequest, + *map[string]any, ) func newCreateFeatureTag() *cobra.Command { cmd := &cobra.Command{} + var createFeatureTagReq map[string]any + createFeatureTagReq = map[string]any{} + var createFeatureTagFeatureNameRaw string + var createFeatureTagTableNameRaw string + var createFeatureTagKeyRaw string + var createFeatureTagValueRaw string - var createFeatureTagReq ml.CreateFeatureTagRequest - createFeatureTagReq.FeatureTag = ml.FeatureTag{} var createFeatureTagJson flags.JsonFlag cmd.Flags().Var(&createFeatureTagJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createFeatureTagReq.FeatureTag.Value, "value", createFeatureTagReq.FeatureTag.Value, ``) + cmd.Flags().StringVar(&createFeatureTagValueRaw, "value", createFeatureTagValueRaw, ``) cmd.Use = "create-feature-tag TABLE_NAME FEATURE_NAME KEY" cmd.Short = `Create a feature tag.` @@ -97,9 +104,10 @@ func newCreateFeatureTag() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := createFeatureTagJson.Unmarshal(&createFeatureTagReq.FeatureTag) + diags := createFeatureTagJson.Unmarshal(&createFeatureTagReq) if diags.HasError() { return diags.Error() } @@ -110,17 +118,30 @@ func newCreateFeatureTag() *cobra.Command { } } } - createFeatureTagReq.TableName = args[0] - createFeatureTagReq.FeatureName = args[1] + createFeatureTagTableNameRaw = args[0] + createFeatureTagFeatureNameRaw = args[1] if !cmd.Flags().Changed("json") { - createFeatureTagReq.FeatureTag.Key = args[2] + createFeatureTagKeyRaw = args[2] + } + + rawQuery := map[string]any{} + if cmd.Flags().Changed("key") || createFeatureTagKeyRaw != "" { + createFeatureTagReq["key"] = createFeatureTagKeyRaw } + if cmd.Flags().Changed("value") || createFeatureTagValueRaw != "" { + createFeatureTagReq["value"] = createFeatureTagValueRaw + } + rawPath := fmt.Sprintf("/api/2.0/feature-store/feature-tables/%s/features/%s/tags", fmt.Sprint(createFeatureTagTableNameRaw), fmt.Sprint(createFeatureTagFeatureNameRaw)) - response, err := w.MaterializedFeatures.CreateFeatureTag(ctx, createFeatureTagReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createFeatureTagReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -142,13 +163,16 @@ func newCreateFeatureTag() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteFeatureTagOverrides []func( *cobra.Command, - *ml.DeleteFeatureTagRequest, + *map[string]any, ) func newDeleteFeatureTag() *cobra.Command { cmd := &cobra.Command{} - - var deleteFeatureTagReq ml.DeleteFeatureTagRequest + var deleteFeatureTagReq map[string]any + deleteFeatureTagReq = map[string]any{} + var deleteFeatureTagFeatureNameRaw string + var deleteFeatureTagKeyRaw string + var deleteFeatureTagTableNameRaw string cmd.Use = "delete-feature-tag TABLE_NAME FEATURE_NAME KEY" cmd.Short = `Delete a feature tag.` @@ -174,12 +198,21 @@ func newDeleteFeatureTag() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteFeatureTagReq.TableName = args[0] - deleteFeatureTagReq.FeatureName = args[1] - deleteFeatureTagReq.Key = args[2] + deleteFeatureTagTableNameRaw = args[0] + deleteFeatureTagFeatureNameRaw = args[1] + deleteFeatureTagKeyRaw = args[2] - err = w.MaterializedFeatures.DeleteFeatureTag(ctx, deleteFeatureTagReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/feature-store/feature-tables/%s/features/%s/tags/%s", fmt.Sprint(deleteFeatureTagTableNameRaw), fmt.Sprint(deleteFeatureTagFeatureNameRaw), fmt.Sprint(deleteFeatureTagKeyRaw)) + + maps.Copy(rawQuery, deleteFeatureTagReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -204,13 +237,15 @@ func newDeleteFeatureTag() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getFeatureLineageOverrides []func( *cobra.Command, - *ml.GetFeatureLineageRequest, + *map[string]any, ) func newGetFeatureLineage() *cobra.Command { cmd := &cobra.Command{} - - var getFeatureLineageReq ml.GetFeatureLineageRequest + var getFeatureLineageReq map[string]any + getFeatureLineageReq = map[string]any{} + var getFeatureLineageFeatureNameRaw string + var getFeatureLineageTableNameRaw string cmd.Use = "get-feature-lineage TABLE_NAME FEATURE_NAME" cmd.Short = `Get Feature Lineage.` @@ -233,15 +268,24 @@ func newGetFeatureLineage() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getFeatureLineageTableNameRaw = args[0] + getFeatureLineageFeatureNameRaw = args[1] - getFeatureLineageReq.TableName = args[0] - getFeatureLineageReq.FeatureName = args[1] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/feature-store/feature-tables/%s/features/%s/lineage", fmt.Sprint(getFeatureLineageTableNameRaw), fmt.Sprint(getFeatureLineageFeatureNameRaw)) - response, err := w.MaterializedFeatures.GetFeatureLineage(ctx, getFeatureLineageReq) + maps.Copy(rawQuery, getFeatureLineageReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -263,13 +307,16 @@ func newGetFeatureLineage() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getFeatureTagOverrides []func( *cobra.Command, - *ml.GetFeatureTagRequest, + *map[string]any, ) func newGetFeatureTag() *cobra.Command { cmd := &cobra.Command{} - - var getFeatureTagReq ml.GetFeatureTagRequest + var getFeatureTagReq map[string]any + getFeatureTagReq = map[string]any{} + var getFeatureTagFeatureNameRaw string + var getFeatureTagKeyRaw string + var getFeatureTagTableNameRaw string cmd.Use = "get-feature-tag TABLE_NAME FEATURE_NAME KEY" cmd.Short = `Get a feature tag.` @@ -290,16 +337,25 @@ func newGetFeatureTag() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getFeatureTagTableNameRaw = args[0] + getFeatureTagFeatureNameRaw = args[1] + getFeatureTagKeyRaw = args[2] - getFeatureTagReq.TableName = args[0] - getFeatureTagReq.FeatureName = args[1] - getFeatureTagReq.Key = args[2] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/feature-store/feature-tables/%s/features/%s/tags/%s", fmt.Sprint(getFeatureTagTableNameRaw), fmt.Sprint(getFeatureTagFeatureNameRaw), fmt.Sprint(getFeatureTagKeyRaw)) - response, err := w.MaterializedFeatures.GetFeatureTag(ctx, getFeatureTagReq) + maps.Copy(rawQuery, getFeatureTagReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -321,25 +377,30 @@ func newGetFeatureTag() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listFeatureTagsOverrides []func( *cobra.Command, - *ml.ListFeatureTagsRequest, + *map[string]any, ) func newListFeatureTags() *cobra.Command { cmd := &cobra.Command{} + var listFeatureTagsReq map[string]any + listFeatureTagsReq = map[string]any{} + var listFeatureTagsFeatureNameRaw string + var listFeatureTagsPageSizeRaw int + var listFeatureTagsPageTokenRaw string + var listFeatureTagsTableNameRaw string - var listFeatureTagsReq ml.ListFeatureTagsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listFeatureTagsLimit int - cmd.Flags().IntVar(&listFeatureTagsReq.PageSize, "page-size", listFeatureTagsReq.PageSize, `The maximum number of results to return.`) + cmd.Flags().IntVar(&listFeatureTagsPageSizeRaw, "page-size", listFeatureTagsPageSizeRaw, `The maximum number of results to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listFeatureTagsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listFeatureTagsReq.PageToken, "page-token", listFeatureTagsReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listFeatureTagsPageTokenRaw, "page-token", listFeatureTagsPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-feature-tags TABLE_NAME FEATURE_NAME" @@ -361,19 +422,34 @@ func newListFeatureTags() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listFeatureTagsReq.TableName = args[0] - listFeatureTagsReq.FeatureName = args[1] + listFeatureTagsTableNameRaw = args[0] + listFeatureTagsFeatureNameRaw = args[1] - response := w.MaterializedFeatures.ListFeatureTags(ctx, listFeatureTagsReq) - if listFeatureTagsLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listFeatureTagsLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("page-size") || listFeatureTagsPageSizeRaw != 0 { + rawQuery["page_size"] = listFeatureTagsPageSizeRaw } - if listFeatureTagsLimit > 0 { - ctx = cmdio.WithLimit(ctx, listFeatureTagsLimit) + if cmd.Flags().Changed("page-token") || listFeatureTagsPageTokenRaw != "" { + rawQuery["page_token"] = listFeatureTagsPageTokenRaw } + rawPath := fmt.Sprintf("/api/2.0/feature-store/feature-tables/%s/features/%s/tags", fmt.Sprint(listFeatureTagsTableNameRaw), fmt.Sprint(listFeatureTagsFeatureNameRaw)) - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listFeatureTagsReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) + if err != nil { + return err + } + if listFeatureTagsLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listFeatureTagsLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -394,20 +470,25 @@ func newListFeatureTags() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateFeatureTagOverrides []func( *cobra.Command, - *ml.UpdateFeatureTagRequest, + *map[string]any, ) func newUpdateFeatureTag() *cobra.Command { cmd := &cobra.Command{} + var updateFeatureTagReq map[string]any + updateFeatureTagReq = map[string]any{} + var updateFeatureTagFeatureNameRaw string + var updateFeatureTagKeyRaw string + var updateFeatureTagTableNameRaw string + var updateFeatureTagUpdateMaskRaw string + var updateFeatureTagValueRaw string - var updateFeatureTagReq ml.UpdateFeatureTagRequest - updateFeatureTagReq.FeatureTag = ml.FeatureTag{} var updateFeatureTagJson flags.JsonFlag cmd.Flags().Var(&updateFeatureTagJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateFeatureTagReq.UpdateMask, "update-mask", updateFeatureTagReq.UpdateMask, `The list of fields to update.`) - cmd.Flags().StringVar(&updateFeatureTagReq.FeatureTag.Value, "value", updateFeatureTagReq.FeatureTag.Value, ``) + cmd.Flags().StringVar(&updateFeatureTagUpdateMaskRaw, "update-mask", updateFeatureTagUpdateMaskRaw, `The list of fields to update.`) + cmd.Flags().StringVar(&updateFeatureTagValueRaw, "value", updateFeatureTagValueRaw, ``) cmd.Use = "update-feature-tag TABLE_NAME FEATURE_NAME KEY" cmd.Short = `Update a feature tag.` @@ -428,9 +509,10 @@ func newUpdateFeatureTag() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := updateFeatureTagJson.Unmarshal(&updateFeatureTagReq.FeatureTag) + diags := updateFeatureTagJson.Unmarshal(&updateFeatureTagReq) if diags.HasError() { return diags.Error() } @@ -441,15 +523,31 @@ func newUpdateFeatureTag() *cobra.Command { } } } - updateFeatureTagReq.TableName = args[0] - updateFeatureTagReq.FeatureName = args[1] - updateFeatureTagReq.Key = args[2] + updateFeatureTagTableNameRaw = args[0] + updateFeatureTagFeatureNameRaw = args[1] + updateFeatureTagKeyRaw = args[2] - response, err := w.MaterializedFeatures.UpdateFeatureTag(ctx, updateFeatureTagReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("update-mask") || updateFeatureTagUpdateMaskRaw != "" { + rawQuery["update_mask"] = updateFeatureTagUpdateMaskRaw + } + if cmd.Flags().Changed("key") || updateFeatureTagKeyRaw != "" { + updateFeatureTagReq["key"] = updateFeatureTagKeyRaw + } + if cmd.Flags().Changed("value") || updateFeatureTagValueRaw != "" { + updateFeatureTagReq["value"] = updateFeatureTagValueRaw + } + rawPath := fmt.Sprintf("/api/2.0/feature-store/feature-tables/%s/features/%s/tags/%s", fmt.Sprint(updateFeatureTagTableNameRaw), fmt.Sprint(updateFeatureTagFeatureNameRaw), fmt.Sprint(updateFeatureTagKeyRaw)) + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateFeatureTagReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/metastores/metastores.go b/cmd/workspace/metastores/metastores.go index 6a1ef18de8c..21271a2f43e 100644 --- a/cmd/workspace/metastores/metastores.go +++ b/cmd/workspace/metastores/metastores.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucmetastores "github.com/databricks/cli/libs/sdktypes/uc/metastores/v1" + sdkucmetastores "github.com/databricks/sdk-go/uc/metastores/v1" ) // Slice with functions to override default command behavior. @@ -69,13 +72,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var assignOverrides []func( *cobra.Command, - *catalog.CreateMetastoreAssignment, + *ucmetastores.CreateMetastoreAssignmentRequest, ) func newAssign() *cobra.Command { cmd := &cobra.Command{} + var assignReq ucmetastores.CreateMetastoreAssignmentRequest - var assignReq catalog.CreateMetastoreAssignment var assignJson flags.JsonFlag cmd.Flags().Var(&assignJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -115,6 +118,7 @@ func newAssign() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := assignJson.Unmarshal(&assignReq) @@ -128,22 +132,29 @@ func newAssign() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &assignReq.WorkspaceId) + var assignWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &assignWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - + assignReq.WorkspaceId = &assignWorkspaceIdArg if !cmd.Flags().Changed("json") { - assignReq.MetastoreId = args[1] + assignReq.MetastoreId = new(args[1]) } if !cmd.Flags().Changed("json") { - assignReq.DefaultCatalogName = args[2] + assignReq.DefaultCatalogName = new(args[2]) } - err = w.Metastores.Assign(ctx, assignReq) + sdkReq, err := ucmetastores.CreateMetastoreAssignmentRequestToSDK(&assignReq) if err != nil { return err } + response, err := w.Metastores.CreateMetastoreAssignment(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -165,20 +176,20 @@ func newAssign() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateMetastore, + *ucmetastores.CreateMetastoreRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq ucmetastores.CreateMetastoreRequest - var createReq catalog.CreateMetastore var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createReq.ExternalAccessEnabled, "external-access-enabled", createReq.ExternalAccessEnabled, `Whether to allow non-DBR clients to directly access entities under the metastore.`) - cmd.Flags().StringVar(&createReq.Region, "region", createReq.Region, `Cloud region which the metastore serves (e.g., us-west-2, westus).`) - cmd.Flags().StringVar(&createReq.StorageRoot, "storage-root", createReq.StorageRoot, `The storage root URL for metastore.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.ExternalAccessEnabled, "external-access-enabled", `Whether to allow non-DBR clients to directly access entities under the metastore.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Region, "region", `Cloud region which the metastore serves (e.g., us-west-2, westus).`) + flags.StringPtrVar(cmd.Flags(), &createReq.StorageRoot, "storage-root", `The storage root URL for metastore.`) cmd.Use = "create NAME" cmd.Short = `Create a metastore.` @@ -213,6 +224,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -227,15 +239,23 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Name = args[0] + createReq.Name = new(args[0]) } - response, err := w.Metastores.Create(ctx, createReq) + sdkReq, err := ucmetastores.CreateMetastoreRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Metastores.CreateMetastore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucmetastores.MetastoreInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -275,12 +295,20 @@ func newCurrent() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.Metastores.Current(ctx) + _ = w + + sdkReq := &sdkucmetastores.GetCurrentMetastoreAssignmentRequest{} + + response, err := w.Metastores.GetCurrentMetastoreAssignment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucmetastores.MetastoreAssignmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -301,15 +329,14 @@ func newCurrent() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteMetastoreRequest, + *ucmetastores.DeleteMetastoreRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq ucmetastores.DeleteMetastoreRequest - var deleteReq catalog.DeleteMetastoreRequest - - cmd.Flags().BoolVar(&deleteReq.Force, "force", deleteReq.Force, `Force deletion even if the metastore is not empty.`) + flags.BoolPtrVar(cmd.Flags(), &deleteReq.Force, "force", `Force deletion even if the metastore is not empty.`) cmd.Use = "delete ID" cmd.Short = `Delete a metastore.` @@ -333,13 +360,20 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = w.Metastores.Delete(ctx, deleteReq) + sdkReq, err := ucmetastores.DeleteMetastoreRequestToSDK(&deleteReq) if err != nil { return err } + response, err := w.Metastores.DeleteMetastore(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -361,13 +395,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetMetastoreRequest, + *sdkucmetastores.GetMetastoreRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq catalog.GetMetastoreRequest + var getReq sdkucmetastores.GetMetastoreRequest cmd.Use = "get ID" cmd.Short = `Get a metastore.` @@ -392,15 +425,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.Metastores.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Metastores.GetMetastore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucmetastores.MetastoreInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -421,13 +460,13 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListMetastoresRequest, + *ucmetastores.ListMetastoresRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq ucmetastores.ListMetastoresRequest - var listReq catalog.ListMetastoresRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -437,9 +476,9 @@ func newList() *cobra.Command { cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of metastores to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of metastores to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list" @@ -471,16 +510,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Metastores.List(ctx, listReq) + sdkReq, err := ucmetastores.ListMetastoresRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Metastores.ListMetastoresIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucmetastores.MetastoreInfoFromSDK)) } // Disable completions since they are not applicable. @@ -521,12 +564,20 @@ func newSummary() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.Metastores.Summary(ctx) + _ = w + + sdkReq := &sdkucmetastores.GetMetastoreSummaryRequest{} + + response, err := w.Metastores.GetMetastoreSummary(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucmetastores.GetMetastoreSummaryResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -547,13 +598,12 @@ func newSummary() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var unassignOverrides []func( *cobra.Command, - *catalog.UnassignRequest, + *ucmetastores.DeleteMetastoreAssignmentRequest, ) func newUnassign() *cobra.Command { cmd := &cobra.Command{} - - var unassignReq catalog.UnassignRequest + var unassignReq ucmetastores.DeleteMetastoreAssignmentRequest cmd.Use = "unassign WORKSPACE_ID METASTORE_ID" cmd.Short = `Delete an assignment.` @@ -578,18 +628,26 @@ func newUnassign() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - _, err = fmt.Sscan(args[0], &unassignReq.WorkspaceId) + var unassignWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &unassignWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + unassignReq.WorkspaceId = &unassignWorkspaceIdArg + unassignReq.MetastoreId = new(args[1]) - unassignReq.MetastoreId = args[1] - - err = w.Metastores.Unassign(ctx, unassignReq) + sdkReq, err := ucmetastores.DeleteMetastoreAssignmentRequestToSDK(&unassignReq) if err != nil { return err } + response, err := w.Metastores.DeleteMetastoreAssignment(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -611,25 +669,25 @@ func newUnassign() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateMetastore, + *ucmetastores.UpdateMetastoreRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucmetastores.UpdateMetastoreRequest - var updateReq catalog.UpdateMetastore 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.DeltaSharingOrganizationName, "delta-sharing-organization-name", updateReq.DeltaSharingOrganizationName, `The organization name of a Delta Sharing entity, to be used in Databricks-to-Databricks Delta Sharing as the official name.`) - cmd.Flags().Int64Var(&updateReq.DeltaSharingRecipientTokenLifetimeInSeconds, "delta-sharing-recipient-token-lifetime-in-seconds", updateReq.DeltaSharingRecipientTokenLifetimeInSeconds, `The lifetime of delta sharing recipient token in seconds.`) - cmd.Flags().Var(&updateReq.DeltaSharingScope, "delta-sharing-scope", `The scope of Delta Sharing enabled for the metastore. Supported values: [INTERNAL, INTERNAL_AND_EXTERNAL]`) - cmd.Flags().BoolVar(&updateReq.ExternalAccessEnabled, "external-access-enabled", updateReq.ExternalAccessEnabled, `Whether to allow non-DBR clients to directly access entities under the metastore.`) - cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the metastore.`) - cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `The owner of the metastore.`) - cmd.Flags().StringVar(&updateReq.PrivilegeModelVersion, "privilege-model-version", updateReq.PrivilegeModelVersion, `Privilege model version of the metastore, of the form major.minor (e.g., 1.0).`) - cmd.Flags().StringVar(&updateReq.StorageRootCredentialId, "storage-root-credential-id", updateReq.StorageRootCredentialId, `UUID of storage credential to access the metastore storage_root.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.DeltaSharingOrganizationName, "delta-sharing-organization-name", `The organization name of a Delta Sharing entity, to be used in Databricks-to-Databricks Delta Sharing as the official name.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.DeltaSharingRecipientTokenLifetimeInSeconds, "delta-sharing-recipient-token-lifetime-in-seconds", `The lifetime of delta sharing recipient token in seconds.`) + flags.EnumVar(cmd.Flags(), &updateReq.DeltaSharingScope, "delta-sharing-scope", `The scope of Delta Sharing enabled for the metastore. Supported values: [INTERNAL, INTERNAL_AND_EXTERNAL]`, "DeltaSharingScopeEnum", "INTERNAL", "INTERNAL_AND_EXTERNAL") + flags.BoolPtrVar(cmd.Flags(), &updateReq.ExternalAccessEnabled, "external-access-enabled", `Whether to allow non-DBR clients to directly access entities under the metastore.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.NewName, "new-name", `New name for the metastore.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `The owner of the metastore.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.PrivilegeModelVersion, "privilege-model-version", `Privilege model version of the metastore, of the form major.minor (e.g., 1.0).`) + flags.StringPtrVar(cmd.Flags(), &updateReq.StorageRootCredentialId, "storage-root-credential-id", `UUID of storage credential to access the metastore storage_root.`) cmd.Use = "update ID" cmd.Short = `Update a metastore.` @@ -655,6 +713,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -668,14 +727,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - response, err := w.Metastores.Update(ctx, updateReq) + sdkReq, err := ucmetastores.UpdateMetastoreRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Metastores.UpdateMetastore(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucmetastores.MetastoreInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -696,19 +763,19 @@ func newUpdate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateAssignmentOverrides []func( *cobra.Command, - *catalog.UpdateMetastoreAssignment, + *ucmetastores.UpdateMetastoreAssignmentRequest, ) func newUpdateAssignment() *cobra.Command { cmd := &cobra.Command{} + var updateAssignmentReq ucmetastores.UpdateMetastoreAssignmentRequest - var updateAssignmentReq catalog.UpdateMetastoreAssignment var updateAssignmentJson flags.JsonFlag cmd.Flags().Var(&updateAssignmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateAssignmentReq.DefaultCatalogName, "default-catalog-name", updateAssignmentReq.DefaultCatalogName, `The name of the default catalog in the metastore.`) - cmd.Flags().StringVar(&updateAssignmentReq.MetastoreId, "metastore-id", updateAssignmentReq.MetastoreId, `The unique ID of the metastore.`) + flags.StringPtrVar(cmd.Flags(), &updateAssignmentReq.DefaultCatalogName, "default-catalog-name", `The name of the default catalog in the metastore.`) + flags.StringPtrVar(cmd.Flags(), &updateAssignmentReq.MetastoreId, "metastore-id", `The unique ID of the metastore.`) cmd.Use = "update-assignment WORKSPACE_ID" cmd.Short = `Update an assignment.` @@ -735,6 +802,7 @@ func newUpdateAssignment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateAssignmentJson.Unmarshal(&updateAssignmentReq) @@ -748,15 +816,23 @@ func newUpdateAssignment() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &updateAssignmentReq.WorkspaceId) + var updateAssignmentWorkspaceIdArg int64 + _, err = fmt.Sscan(args[0], &updateAssignmentWorkspaceIdArg) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } + updateAssignmentReq.WorkspaceId = &updateAssignmentWorkspaceIdArg - err = w.Metastores.UpdateAssignment(ctx, updateAssignmentReq) + sdkReq, err := ucmetastores.UpdateMetastoreAssignmentRequestToSDK(&updateAssignmentReq) + if err != nil { + return err + } + response, err := w.Metastores.UpdateMetastoreAssignment(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } diff --git a/cmd/workspace/metastores/overrides.go b/cmd/workspace/metastores/overrides.go index 4f81c5ce5b6..c15ae4b3080 100644 --- a/cmd/workspace/metastores/overrides.go +++ b/cmd/workspace/metastores/overrides.go @@ -2,11 +2,11 @@ package metastores import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/catalog" + ucmetastores "github.com/databricks/cli/libs/sdktypes/uc/metastores/v1" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, req *catalog.ListMetastoresRequest) { +func listOverride(listCmd *cobra.Command, req *ucmetastores.ListMetastoresRequest) { listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "ID"}} {{header "Name"}} {{"Region"}}`) listCmd.Annotations["template"] = cmdio.Heredoc(` diff --git a/cmd/workspace/model-registry/model-registry.go b/cmd/workspace/model-registry/model-registry.go index 2c88d8d7dc1..965f3b4fa55 100644 --- a/cmd/workspace/model-registry/model-registry.go +++ b/cmd/workspace/model-registry/model-registry.go @@ -8,10 +8,14 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/ml" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + modelregistry "github.com/databricks/cli/libs/sdktypes/modelregistry/v1" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" ) // Slice with functions to override default command behavior. @@ -90,18 +94,18 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var approveTransitionRequestOverrides []func( *cobra.Command, - *ml.ApproveTransitionRequest, + *modelregistry.ApproveTransitionRequest, ) func newApproveTransitionRequest() *cobra.Command { cmd := &cobra.Command{} + var approveTransitionRequestReq modelregistry.ApproveTransitionRequest - var approveTransitionRequestReq ml.ApproveTransitionRequest var approveTransitionRequestJson flags.JsonFlag cmd.Flags().Var(&approveTransitionRequestJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&approveTransitionRequestReq.Comment, "comment", approveTransitionRequestReq.Comment, `User-provided comment on the action.`) + flags.StringPtrVar(cmd.Flags(), &approveTransitionRequestReq.Comment, "comment", `User-provided comment on the action.`) cmd.Use = "approve-transition-request NAME VERSION STAGE ARCHIVE_EXISTING_VERSIONS" cmd.Short = `Approve transition request.` @@ -144,6 +148,7 @@ func newApproveTransitionRequest() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := approveTransitionRequestJson.Unmarshal(&approveTransitionRequestReq) @@ -158,28 +163,37 @@ func newApproveTransitionRequest() *cobra.Command { } } if !cmd.Flags().Changed("json") { - approveTransitionRequestReq.Name = args[0] + approveTransitionRequestReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - approveTransitionRequestReq.Version = args[1] + approveTransitionRequestReq.Version = new(args[1]) } if !cmd.Flags().Changed("json") { - approveTransitionRequestReq.Stage = args[2] + approveTransitionRequestReq.Stage = new(args[2]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &approveTransitionRequestReq.ArchiveExistingVersions) + var approveTransitionRequestArchiveExistingVersionsArg bool + _, err = fmt.Sscan(args[3], &approveTransitionRequestArchiveExistingVersionsArg) if err != nil { return fmt.Errorf("invalid ARCHIVE_EXISTING_VERSIONS: %s", args[3]) } - + approveTransitionRequestReq.ArchiveExistingVersions = &approveTransitionRequestArchiveExistingVersionsArg } - response, err := w.ModelRegistry.ApproveTransitionRequest(ctx, approveTransitionRequestReq) + sdkReq, err := modelregistry.ApproveTransitionRequestToSDK(&approveTransitionRequestReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.ApproveTransitionRequest(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.ApproveTransitionResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -200,13 +214,13 @@ func newApproveTransitionRequest() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createCommentOverrides []func( *cobra.Command, - *ml.CreateComment, + *modelregistry.CreateCommentRequest, ) func newCreateComment() *cobra.Command { cmd := &cobra.Command{} + var createCommentReq modelregistry.CreateCommentRequest - var createCommentReq ml.CreateComment var createCommentJson flags.JsonFlag cmd.Flags().Var(&createCommentJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -244,6 +258,7 @@ func newCreateComment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createCommentJson.Unmarshal(&createCommentReq) @@ -258,21 +273,29 @@ func newCreateComment() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createCommentReq.Name = args[0] + createCommentReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createCommentReq.Version = args[1] + createCommentReq.Version = new(args[1]) } if !cmd.Flags().Changed("json") { - createCommentReq.Comment = args[2] + createCommentReq.Comment = new(args[2]) } - response, err := w.ModelRegistry.CreateComment(ctx, createCommentReq) + sdkReq, err := modelregistry.CreateCommentRequestToSDK(&createCommentReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.CreateComment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.CreateCommentResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -293,18 +316,18 @@ func newCreateComment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createModelOverrides []func( *cobra.Command, - *ml.CreateModelRequest, + *modelregistry.CreateRegisteredModelRequest, ) func newCreateModel() *cobra.Command { cmd := &cobra.Command{} + var createModelReq modelregistry.CreateRegisteredModelRequest - var createModelReq ml.CreateModelRequest var createModelJson flags.JsonFlag cmd.Flags().Var(&createModelJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createModelReq.Description, "description", createModelReq.Description, `Optional description for registered model.`) + flags.StringPtrVar(cmd.Flags(), &createModelReq.Description, "description", `Optional description for registered model.`) // TODO: array: tags cmd.Use = "create-model NAME" @@ -338,6 +361,7 @@ func newCreateModel() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createModelJson.Unmarshal(&createModelReq) @@ -352,15 +376,23 @@ func newCreateModel() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createModelReq.Name = args[0] + createModelReq.Name = new(args[0]) } - response, err := w.ModelRegistry.CreateModel(ctx, createModelReq) + sdkReq, err := modelregistry.CreateRegisteredModelRequestToSDK(&createModelReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.CreateRegisteredModel(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.CreateRegisteredModelResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -381,20 +413,20 @@ func newCreateModel() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createModelVersionOverrides []func( *cobra.Command, - *ml.CreateModelVersionRequest, + *modelregistry.CreateModelVersionRequest, ) func newCreateModelVersion() *cobra.Command { cmd := &cobra.Command{} + var createModelVersionReq modelregistry.CreateModelVersionRequest - var createModelVersionReq ml.CreateModelVersionRequest var createModelVersionJson flags.JsonFlag cmd.Flags().Var(&createModelVersionJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createModelVersionReq.Description, "description", createModelVersionReq.Description, `Optional description for model version.`) - cmd.Flags().StringVar(&createModelVersionReq.RunId, "run-id", createModelVersionReq.RunId, `MLflow run ID for correlation, if source was generated by an experiment run in MLflow tracking server.`) - cmd.Flags().StringVar(&createModelVersionReq.RunLink, "run-link", createModelVersionReq.RunLink, `MLflow run link - this is the exact link of the run that generated this model version, potentially hosted at another instance of MLflow.`) + flags.StringPtrVar(cmd.Flags(), &createModelVersionReq.Description, "description", `Optional description for model version.`) + flags.StringPtrVar(cmd.Flags(), &createModelVersionReq.RunId, "run-id", `MLflow run ID for correlation, if source was generated by an experiment run in MLflow tracking server.`) + flags.StringPtrVar(cmd.Flags(), &createModelVersionReq.RunLink, "run-link", `MLflow run link - this is the exact link of the run that generated this model version, potentially hosted at another instance of MLflow.`) // TODO: array: tags cmd.Use = "create-model-version NAME SOURCE" @@ -427,6 +459,7 @@ func newCreateModelVersion() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createModelVersionJson.Unmarshal(&createModelVersionReq) @@ -441,18 +474,26 @@ func newCreateModelVersion() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createModelVersionReq.Name = args[0] + createModelVersionReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createModelVersionReq.Source = args[1] + createModelVersionReq.Source = new(args[1]) } - response, err := w.ModelRegistry.CreateModelVersion(ctx, createModelVersionReq) + sdkReq, err := modelregistry.CreateModelVersionRequestToSDK(&createModelVersionReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.CreateModelVersion(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.CreateModelVersionResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -473,18 +514,18 @@ func newCreateModelVersion() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createTransitionRequestOverrides []func( *cobra.Command, - *ml.CreateTransitionRequest, + *modelregistry.CreateTransitionRequest, ) func newCreateTransitionRequest() *cobra.Command { cmd := &cobra.Command{} + var createTransitionRequestReq modelregistry.CreateTransitionRequest - var createTransitionRequestReq ml.CreateTransitionRequest var createTransitionRequestJson flags.JsonFlag cmd.Flags().Var(&createTransitionRequestJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createTransitionRequestReq.Comment, "comment", createTransitionRequestReq.Comment, `User-provided comment on the action.`) + flags.StringPtrVar(cmd.Flags(), &createTransitionRequestReq.Comment, "comment", `User-provided comment on the action.`) cmd.Use = "create-transition-request NAME VERSION STAGE" cmd.Short = `Make a transition request.` @@ -525,6 +566,7 @@ func newCreateTransitionRequest() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createTransitionRequestJson.Unmarshal(&createTransitionRequestReq) @@ -539,21 +581,29 @@ func newCreateTransitionRequest() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createTransitionRequestReq.Name = args[0] + createTransitionRequestReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createTransitionRequestReq.Version = args[1] + createTransitionRequestReq.Version = new(args[1]) } if !cmd.Flags().Changed("json") { - createTransitionRequestReq.Stage = args[2] + createTransitionRequestReq.Stage = new(args[2]) } - response, err := w.ModelRegistry.CreateTransitionRequest(ctx, createTransitionRequestReq) + sdkReq, err := modelregistry.CreateTransitionRequestToSDK(&createTransitionRequestReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.CreateTransitionRequest(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.CreateTransitionResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -574,22 +624,22 @@ func newCreateTransitionRequest() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createWebhookOverrides []func( *cobra.Command, - *ml.CreateRegistryWebhook, + *modelregistry.CreateRegistryWebhookRequest, ) func newCreateWebhook() *cobra.Command { cmd := &cobra.Command{} + var createWebhookReq modelregistry.CreateRegistryWebhookRequest - var createWebhookReq ml.CreateRegistryWebhook var createWebhookJson flags.JsonFlag cmd.Flags().Var(&createWebhookJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createWebhookReq.Description, "description", createWebhookReq.Description, `User-specified description for the webhook.`) + flags.StringPtrVar(cmd.Flags(), &createWebhookReq.Description, "description", `User-specified description for the webhook.`) // TODO: complex arg: http_url_spec // TODO: complex arg: job_spec - cmd.Flags().StringVar(&createWebhookReq.ModelName, "model-name", createWebhookReq.ModelName, `If model name is not specified, a registry-wide webhook is created that listens for the specified events across all versions of all registered models.`) - cmd.Flags().Var(&createWebhookReq.Status, "status", `Enable or disable triggering the webhook, or put the webhook into test mode. Supported values: [ACTIVE, DISABLED, TEST_MODE]`) + flags.StringPtrVar(cmd.Flags(), &createWebhookReq.ModelName, "model-name", `If model name is not specified, a registry-wide webhook is created that listens for the specified events across all versions of all registered models.`) + flags.EnumVar(cmd.Flags(), &createWebhookReq.Status, "status", `Enable or disable triggering the webhook, or put the webhook into test mode. Supported values: [ACTIVE, DISABLED, TEST_MODE]`, "RegistryWebhookStatus", "ACTIVE", "DISABLED", "TEST_MODE") cmd.Use = "create-webhook" cmd.Short = `Create a webhook.` @@ -605,6 +655,7 @@ func newCreateWebhook() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createWebhookJson.Unmarshal(&createWebhookReq) @@ -621,12 +672,20 @@ func newCreateWebhook() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.ModelRegistry.CreateWebhook(ctx, createWebhookReq) + sdkReq, err := modelregistry.CreateRegistryWebhookRequestToSDK(&createWebhookReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.CreateRegistryWebhook(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.CreateRegistryWebhookResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -647,13 +706,12 @@ func newCreateWebhook() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteCommentOverrides []func( *cobra.Command, - *ml.DeleteCommentRequest, + *modelregistry.DeleteCommentRequest, ) func newDeleteComment() *cobra.Command { cmd := &cobra.Command{} - - var deleteCommentReq ml.DeleteCommentRequest + var deleteCommentReq modelregistry.DeleteCommentRequest cmd.Use = "delete-comment ID" cmd.Short = `Delete a comment.` @@ -677,13 +735,20 @@ func newDeleteComment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteCommentReq.Id = args[0] + deleteCommentReq.Id = new(args[0]) - err = w.ModelRegistry.DeleteComment(ctx, deleteCommentReq) + sdkReq, err := modelregistry.DeleteCommentRequestToSDK(&deleteCommentReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.DeleteComment(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -705,13 +770,12 @@ func newDeleteComment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteModelOverrides []func( *cobra.Command, - *ml.DeleteModelRequest, + *modelregistry.DeleteRegisteredModelRequest, ) func newDeleteModel() *cobra.Command { cmd := &cobra.Command{} - - var deleteModelReq ml.DeleteModelRequest + var deleteModelReq modelregistry.DeleteRegisteredModelRequest cmd.Use = "delete-model NAME" cmd.Short = `Delete a model.` @@ -735,13 +799,20 @@ func newDeleteModel() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteModelReq.Name = args[0] + deleteModelReq.Name = new(args[0]) - err = w.ModelRegistry.DeleteModel(ctx, deleteModelReq) + sdkReq, err := modelregistry.DeleteRegisteredModelRequestToSDK(&deleteModelReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.DeleteRegisteredModel(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -763,13 +834,12 @@ func newDeleteModel() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteModelTagOverrides []func( *cobra.Command, - *ml.DeleteModelTagRequest, + *modelregistry.DeleteRegisteredModelTagRequest, ) func newDeleteModelTag() *cobra.Command { cmd := &cobra.Command{} - - var deleteModelTagReq ml.DeleteModelTagRequest + var deleteModelTagReq modelregistry.DeleteRegisteredModelTagRequest cmd.Use = "delete-model-tag NAME KEY" cmd.Short = `Delete a model tag.` @@ -795,14 +865,21 @@ func newDeleteModelTag() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteModelTagReq.Name = args[0] - deleteModelTagReq.Key = args[1] + deleteModelTagReq.Name = new(args[0]) + deleteModelTagReq.Key = new(args[1]) - err = w.ModelRegistry.DeleteModelTag(ctx, deleteModelTagReq) + sdkReq, err := modelregistry.DeleteRegisteredModelTagRequestToSDK(&deleteModelTagReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.DeleteRegisteredModelTag(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -824,13 +901,12 @@ func newDeleteModelTag() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteModelVersionOverrides []func( *cobra.Command, - *ml.DeleteModelVersionRequest, + *modelregistry.DeleteModelVersionRequest, ) func newDeleteModelVersion() *cobra.Command { cmd := &cobra.Command{} - - var deleteModelVersionReq ml.DeleteModelVersionRequest + var deleteModelVersionReq modelregistry.DeleteModelVersionRequest cmd.Use = "delete-model-version NAME VERSION" cmd.Short = `Delete a model version.` @@ -855,14 +931,21 @@ func newDeleteModelVersion() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteModelVersionReq.Name = args[0] - deleteModelVersionReq.Version = args[1] + deleteModelVersionReq.Name = new(args[0]) + deleteModelVersionReq.Version = new(args[1]) - err = w.ModelRegistry.DeleteModelVersion(ctx, deleteModelVersionReq) + sdkReq, err := modelregistry.DeleteModelVersionRequestToSDK(&deleteModelVersionReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.DeleteModelVersion(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -884,13 +967,12 @@ func newDeleteModelVersion() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteModelVersionTagOverrides []func( *cobra.Command, - *ml.DeleteModelVersionTagRequest, + *modelregistry.DeleteModelVersionTagRequest, ) func newDeleteModelVersionTag() *cobra.Command { cmd := &cobra.Command{} - - var deleteModelVersionTagReq ml.DeleteModelVersionTagRequest + var deleteModelVersionTagReq modelregistry.DeleteModelVersionTagRequest cmd.Use = "delete-model-version-tag NAME VERSION KEY" cmd.Short = `Delete a model version tag.` @@ -917,15 +999,22 @@ func newDeleteModelVersionTag() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteModelVersionTagReq.Name = args[0] - deleteModelVersionTagReq.Version = args[1] - deleteModelVersionTagReq.Key = args[2] + deleteModelVersionTagReq.Name = new(args[0]) + deleteModelVersionTagReq.Version = new(args[1]) + deleteModelVersionTagReq.Key = new(args[2]) - err = w.ModelRegistry.DeleteModelVersionTag(ctx, deleteModelVersionTagReq) + sdkReq, err := modelregistry.DeleteModelVersionTagRequestToSDK(&deleteModelVersionTagReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.DeleteModelVersionTag(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -947,15 +1036,14 @@ func newDeleteModelVersionTag() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteTransitionRequestOverrides []func( *cobra.Command, - *ml.DeleteTransitionRequestRequest, + *modelregistry.DeleteTransitionRequest, ) func newDeleteTransitionRequest() *cobra.Command { cmd := &cobra.Command{} + var deleteTransitionRequestReq modelregistry.DeleteTransitionRequest - var deleteTransitionRequestReq ml.DeleteTransitionRequestRequest - - cmd.Flags().StringVar(&deleteTransitionRequestReq.Comment, "comment", deleteTransitionRequestReq.Comment, `User-provided comment on the action.`) + flags.StringPtrVar(cmd.Flags(), &deleteTransitionRequestReq.Comment, "comment", `User-provided comment on the action.`) cmd.Use = "delete-transition-request NAME VERSION STAGE CREATOR" cmd.Short = `Delete a transition request.` @@ -992,18 +1080,27 @@ func newDeleteTransitionRequest() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteTransitionRequestReq.Name = args[0] - deleteTransitionRequestReq.Version = args[1] - deleteTransitionRequestReq.Stage = args[2] - deleteTransitionRequestReq.Creator = args[3] + deleteTransitionRequestReq.Name = new(args[0]) + deleteTransitionRequestReq.Version = new(args[1]) + deleteTransitionRequestReq.Stage = new(args[2]) + deleteTransitionRequestReq.Creator = new(args[3]) - response, err := w.ModelRegistry.DeleteTransitionRequest(ctx, deleteTransitionRequestReq) + sdkReq, err := modelregistry.DeleteTransitionRequestToSDK(&deleteTransitionRequestReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.DeleteTransitionRequest(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.DeleteTransitionResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1024,13 +1121,12 @@ func newDeleteTransitionRequest() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteWebhookOverrides []func( *cobra.Command, - *ml.DeleteWebhookRequest, + *modelregistry.DeleteRegistryWebhookRequest, ) func newDeleteWebhook() *cobra.Command { cmd := &cobra.Command{} - - var deleteWebhookReq ml.DeleteWebhookRequest + var deleteWebhookReq modelregistry.DeleteRegistryWebhookRequest cmd.Use = "delete-webhook ID" cmd.Short = `Delete a webhook.` @@ -1054,13 +1150,20 @@ func newDeleteWebhook() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteWebhookReq.Id = args[0] + deleteWebhookReq.Id = new(args[0]) - err = w.ModelRegistry.DeleteWebhook(ctx, deleteWebhookReq) + sdkReq, err := modelregistry.DeleteRegistryWebhookRequestToSDK(&deleteWebhookReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.DeleteRegistryWebhook(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -1082,13 +1185,13 @@ func newDeleteWebhook() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getLatestVersionsOverrides []func( *cobra.Command, - *ml.GetLatestVersionsRequest, + *modelregistry.ListLatestVersionsRequest, ) func newGetLatestVersions() *cobra.Command { cmd := &cobra.Command{} + var getLatestVersionsReq modelregistry.ListLatestVersionsRequest - var getLatestVersionsReq ml.GetLatestVersionsRequest var getLatestVersionsJson flags.JsonFlag // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO @@ -1133,6 +1236,7 @@ func newGetLatestVersions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := getLatestVersionsJson.Unmarshal(&getLatestVersionsReq) @@ -1147,10 +1251,17 @@ func newGetLatestVersions() *cobra.Command { } } if !cmd.Flags().Changed("json") { - getLatestVersionsReq.Name = args[0] + getLatestVersionsReq.Name = new(args[0]) } - response := w.ModelRegistry.GetLatestVersions(ctx, getLatestVersionsReq) + sdkReq, err := modelregistry.ListLatestVersionsRequestToSDK(&getLatestVersionsReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.ListLatestVersions(ctx, *sdkReq) + if err != nil { + return err + } if getLatestVersionsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", getLatestVersionsLimit) } @@ -1158,7 +1269,11 @@ func newGetLatestVersions() *cobra.Command { ctx = cmdio.WithLimit(ctx, getLatestVersionsLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := modelregistry.GetLatestVersionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.ModelVersions) } // Disable completions since they are not applicable. @@ -1179,13 +1294,12 @@ func newGetLatestVersions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getModelOverrides []func( *cobra.Command, - *ml.GetModelRequest, + *modelregistry.GetRegisteredModelDatabricksRequest, ) func newGetModel() *cobra.Command { cmd := &cobra.Command{} - - var getModelReq ml.GetModelRequest + var getModelReq modelregistry.GetRegisteredModelDatabricksRequest cmd.Use = "get-model NAME" cmd.Short = `Get model.` @@ -1213,15 +1327,24 @@ func newGetModel() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getModelReq.Name = args[0] + getModelReq.Name = new(args[0]) - response, err := w.ModelRegistry.GetModel(ctx, getModelReq) + sdkReq, err := modelregistry.GetRegisteredModelDatabricksRequestToSDK(&getModelReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.GetRegisteredModelDatabricks(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.GetRegisteredModelDatabricksResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1242,13 +1365,12 @@ func newGetModel() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getModelVersionOverrides []func( *cobra.Command, - *ml.GetModelVersionRequest, + *modelregistry.GetModelVersionRequest, ) func newGetModelVersion() *cobra.Command { cmd := &cobra.Command{} - - var getModelVersionReq ml.GetModelVersionRequest + var getModelVersionReq modelregistry.GetModelVersionRequest cmd.Use = "get-model-version NAME VERSION" cmd.Short = `Get a model version.` @@ -1271,16 +1393,25 @@ func newGetModelVersion() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getModelVersionReq.Name = args[0] - getModelVersionReq.Version = args[1] + getModelVersionReq.Name = new(args[0]) + getModelVersionReq.Version = new(args[1]) - response, err := w.ModelRegistry.GetModelVersion(ctx, getModelVersionReq) + sdkReq, err := modelregistry.GetModelVersionRequestToSDK(&getModelVersionReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.GetModelVersion(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.GetModelVersionResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1301,13 +1432,12 @@ func newGetModelVersion() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getModelVersionDownloadUriOverrides []func( *cobra.Command, - *ml.GetModelVersionDownloadUriRequest, + *modelregistry.GetModelVersionDownloadUriRequest, ) func newGetModelVersionDownloadUri() *cobra.Command { cmd := &cobra.Command{} - - var getModelVersionDownloadUriReq ml.GetModelVersionDownloadUriRequest + var getModelVersionDownloadUriReq modelregistry.GetModelVersionDownloadUriRequest cmd.Use = "get-model-version-download-uri NAME VERSION" cmd.Short = `Get a model version URI.` @@ -1332,16 +1462,25 @@ func newGetModelVersionDownloadUri() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getModelVersionDownloadUriReq.Name = args[0] - getModelVersionDownloadUriReq.Version = args[1] + getModelVersionDownloadUriReq.Name = new(args[0]) + getModelVersionDownloadUriReq.Version = new(args[1]) - response, err := w.ModelRegistry.GetModelVersionDownloadUri(ctx, getModelVersionDownloadUriReq) + sdkReq, err := modelregistry.GetModelVersionDownloadUriRequestToSDK(&getModelVersionDownloadUriReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.GetModelVersionDownloadUri(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.GetModelVersionDownloadUriResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1362,13 +1501,12 @@ func newGetModelVersionDownloadUri() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *ml.GetRegisteredModelPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq ml.GetRegisteredModelPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels REGISTERED_MODEL_ID" cmd.Short = `Get registered model permission levels.` @@ -1392,15 +1530,23 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getPermissionLevelsReq.RegisteredModelId = args[0] + getPermissionLevelsReq.RequestObjectId = new(args[0]) - response, err := w.ModelRegistry.GetPermissionLevels(ctx, getPermissionLevelsReq) + getPermissionLevelsReq.RequestObjectType = new("registered-models") + + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1421,13 +1567,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *ml.GetRegisteredModelPermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq ml.GetRegisteredModelPermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions REGISTERED_MODEL_ID" cmd.Short = `Get registered model permissions.` @@ -1452,15 +1597,23 @@ func newGetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getPermissionsReq.RequestObjectId = new(args[0]) - getPermissionsReq.RegisteredModelId = args[0] + getPermissionsReq.RequestObjectType = new("registered-models") - response, err := w.ModelRegistry.GetPermissions(ctx, getPermissionsReq) + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1481,25 +1634,25 @@ func newGetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listModelsOverrides []func( *cobra.Command, - *ml.ListModelsRequest, + *modelregistry.ListRegisteredModelsRequest, ) func newListModels() *cobra.Command { cmd := &cobra.Command{} + var listModelsReq modelregistry.ListRegisteredModelsRequest - var listModelsReq ml.ListModelsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listModelsLimit int - cmd.Flags().Int64Var(&listModelsReq.MaxResults, "max-results", listModelsReq.MaxResults, `Maximum number of registered models desired.`) + flags.Int64PtrVar(cmd.Flags(), &listModelsReq.MaxResults, "max-results", `Maximum number of registered models desired.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listModelsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listModelsReq.PageToken, "page-token", listModelsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listModelsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-models" @@ -1522,16 +1675,20 @@ func newListModels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ModelRegistry.ListModels(ctx, listModelsReq) + sdkReq, err := modelregistry.ListRegisteredModelsRequestToSDK(&listModelsReq) + if err != nil { + return err + } if listModelsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listModelsLimit) } if listModelsLimit > 0 { ctx = cmdio.WithLimit(ctx, listModelsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.ModelRegistry.ListRegisteredModelsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, modelregistry.RegisteredModelFromSDK)) } // Disable completions since they are not applicable. @@ -1552,13 +1709,13 @@ func newListModels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listTransitionRequestsOverrides []func( *cobra.Command, - *ml.ListTransitionRequestsRequest, + *modelregistry.ListTransitionRequest, ) func newListTransitionRequests() *cobra.Command { cmd := &cobra.Command{} + var listTransitionRequestsReq modelregistry.ListTransitionRequest - var listTransitionRequestsReq ml.ListTransitionRequestsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -1592,11 +1749,19 @@ func newListTransitionRequests() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listTransitionRequestsReq.Name = args[0] - listTransitionRequestsReq.Version = args[1] + listTransitionRequestsReq.Name = new(args[0]) + listTransitionRequestsReq.Version = new(args[1]) - response := w.ModelRegistry.ListTransitionRequests(ctx, listTransitionRequestsReq) + sdkReq, err := modelregistry.ListTransitionRequestToSDK(&listTransitionRequestsReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.ListTransitionRequests(ctx, *sdkReq) + if err != nil { + return err + } if listTransitionRequestsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listTransitionRequestsLimit) } @@ -1604,7 +1769,11 @@ func newListTransitionRequests() *cobra.Command { ctx = cmdio.WithLimit(ctx, listTransitionRequestsLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := modelregistry.ListTransitionResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.Requests) } // Disable completions since they are not applicable. @@ -1625,27 +1794,27 @@ func newListTransitionRequests() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listWebhooksOverrides []func( *cobra.Command, - *ml.ListWebhooksRequest, + *modelregistry.ListRegistryWebhooksRequest, ) func newListWebhooks() *cobra.Command { cmd := &cobra.Command{} + var listWebhooksReq modelregistry.ListRegistryWebhooksRequest - var listWebhooksReq ml.ListWebhooksRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listWebhooksLimit int // TODO: array: events - cmd.Flags().Int64Var(&listWebhooksReq.MaxResults, "max-results", listWebhooksReq.MaxResults, ``) - cmd.Flags().StringVar(&listWebhooksReq.ModelName, "model-name", listWebhooksReq.ModelName, `Registered model name If not specified, all webhooks associated with the specified events are listed, regardless of their associated model.`) + flags.Int64PtrVar(cmd.Flags(), &listWebhooksReq.MaxResults, "max-results", ``) + flags.StringPtrVar(cmd.Flags(), &listWebhooksReq.ModelName, "model-name", `Registered model name If not specified, all webhooks associated with the specified events are listed, regardless of their associated model.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listWebhooksLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listWebhooksReq.PageToken, "page-token", listWebhooksReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listWebhooksReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-webhooks" @@ -1667,16 +1836,20 @@ func newListWebhooks() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ModelRegistry.ListWebhooks(ctx, listWebhooksReq) + sdkReq, err := modelregistry.ListRegistryWebhooksRequestToSDK(&listWebhooksReq) + if err != nil { + return err + } if listWebhooksLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listWebhooksLimit) } if listWebhooksLimit > 0 { ctx = cmdio.WithLimit(ctx, listWebhooksLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.ModelRegistry.ListRegistryWebhooksIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, modelregistry.RegistryWebhookFromSDK)) } // Disable completions since they are not applicable. @@ -1697,18 +1870,18 @@ func newListWebhooks() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var rejectTransitionRequestOverrides []func( *cobra.Command, - *ml.RejectTransitionRequest, + *modelregistry.RejectTransitionRequest, ) func newRejectTransitionRequest() *cobra.Command { cmd := &cobra.Command{} + var rejectTransitionRequestReq modelregistry.RejectTransitionRequest - var rejectTransitionRequestReq ml.RejectTransitionRequest var rejectTransitionRequestJson flags.JsonFlag cmd.Flags().Var(&rejectTransitionRequestJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&rejectTransitionRequestReq.Comment, "comment", rejectTransitionRequestReq.Comment, `User-provided comment on the action.`) + flags.StringPtrVar(cmd.Flags(), &rejectTransitionRequestReq.Comment, "comment", `User-provided comment on the action.`) cmd.Use = "reject-transition-request NAME VERSION STAGE" cmd.Short = `Reject a transition request.` @@ -1749,6 +1922,7 @@ func newRejectTransitionRequest() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := rejectTransitionRequestJson.Unmarshal(&rejectTransitionRequestReq) @@ -1763,21 +1937,29 @@ func newRejectTransitionRequest() *cobra.Command { } } if !cmd.Flags().Changed("json") { - rejectTransitionRequestReq.Name = args[0] + rejectTransitionRequestReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - rejectTransitionRequestReq.Version = args[1] + rejectTransitionRequestReq.Version = new(args[1]) } if !cmd.Flags().Changed("json") { - rejectTransitionRequestReq.Stage = args[2] + rejectTransitionRequestReq.Stage = new(args[2]) } - response, err := w.ModelRegistry.RejectTransitionRequest(ctx, rejectTransitionRequestReq) + sdkReq, err := modelregistry.RejectTransitionRequestToSDK(&rejectTransitionRequestReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.RejectTransitionRequest(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.RejectTransitionResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1798,18 +1980,18 @@ func newRejectTransitionRequest() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var renameModelOverrides []func( *cobra.Command, - *ml.RenameModelRequest, + *modelregistry.RenameRegisteredModelRequest, ) func newRenameModel() *cobra.Command { cmd := &cobra.Command{} + var renameModelReq modelregistry.RenameRegisteredModelRequest - var renameModelReq ml.RenameModelRequest var renameModelJson flags.JsonFlag cmd.Flags().Var(&renameModelJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&renameModelReq.NewName, "new-name", renameModelReq.NewName, `If provided, updates the name for this registered_model.`) + flags.StringPtrVar(cmd.Flags(), &renameModelReq.NewName, "new-name", `If provided, updates the name for this registered_model.`) cmd.Use = "rename-model NAME" cmd.Short = `Rename a model.` @@ -1840,6 +2022,7 @@ func newRenameModel() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := renameModelJson.Unmarshal(&renameModelReq) @@ -1854,15 +2037,23 @@ func newRenameModel() *cobra.Command { } } if !cmd.Flags().Changed("json") { - renameModelReq.Name = args[0] + renameModelReq.Name = new(args[0]) } - response, err := w.ModelRegistry.RenameModel(ctx, renameModelReq) + sdkReq, err := modelregistry.RenameRegisteredModelRequestToSDK(&renameModelReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.RenameRegisteredModel(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.RenameRegisteredModelResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1883,27 +2074,27 @@ func newRenameModel() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var searchModelVersionsOverrides []func( *cobra.Command, - *ml.SearchModelVersionsRequest, + *modelregistry.SearchModelVersionsRequest, ) func newSearchModelVersions() *cobra.Command { cmd := &cobra.Command{} + var searchModelVersionsReq modelregistry.SearchModelVersionsRequest - var searchModelVersionsReq ml.SearchModelVersionsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var searchModelVersionsLimit int - cmd.Flags().StringVar(&searchModelVersionsReq.Filter, "filter", searchModelVersionsReq.Filter, `String filter condition, like "name='my-model-name'".`) - cmd.Flags().Int64Var(&searchModelVersionsReq.MaxResults, "max-results", searchModelVersionsReq.MaxResults, `Maximum number of models desired.`) + flags.StringPtrVar(cmd.Flags(), &searchModelVersionsReq.Filter, "filter", `String filter condition, like "name='my-model-name'".`) + flags.Int64PtrVar(cmd.Flags(), &searchModelVersionsReq.MaxResults, "max-results", `Maximum number of models desired.`) // TODO: array: order_by // Limit flag for total result capping. cmd.Flags().IntVar(&searchModelVersionsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&searchModelVersionsReq.PageToken, "page-token", searchModelVersionsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &searchModelVersionsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "search-model-versions" @@ -1925,16 +2116,20 @@ func newSearchModelVersions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ModelRegistry.SearchModelVersions(ctx, searchModelVersionsReq) + sdkReq, err := modelregistry.SearchModelVersionsRequestToSDK(&searchModelVersionsReq) + if err != nil { + return err + } if searchModelVersionsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", searchModelVersionsLimit) } if searchModelVersionsLimit > 0 { ctx = cmdio.WithLimit(ctx, searchModelVersionsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.ModelRegistry.SearchModelVersionsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, modelregistry.ModelVersionFromSDK)) } // Disable completions since they are not applicable. @@ -1955,27 +2150,27 @@ func newSearchModelVersions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var searchModelsOverrides []func( *cobra.Command, - *ml.SearchModelsRequest, + *modelregistry.SearchRegisteredModelsRequest, ) func newSearchModels() *cobra.Command { cmd := &cobra.Command{} + var searchModelsReq modelregistry.SearchRegisteredModelsRequest - var searchModelsReq ml.SearchModelsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var searchModelsLimit int - cmd.Flags().StringVar(&searchModelsReq.Filter, "filter", searchModelsReq.Filter, `String filter condition, like "name LIKE 'my-model-name'".`) - cmd.Flags().Int64Var(&searchModelsReq.MaxResults, "max-results", searchModelsReq.MaxResults, `Maximum number of models desired.`) + flags.StringPtrVar(cmd.Flags(), &searchModelsReq.Filter, "filter", `String filter condition, like "name LIKE 'my-model-name'".`) + flags.Int64PtrVar(cmd.Flags(), &searchModelsReq.MaxResults, "max-results", `Maximum number of models desired.`) // TODO: array: order_by // Limit flag for total result capping. cmd.Flags().IntVar(&searchModelsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&searchModelsReq.PageToken, "page-token", searchModelsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &searchModelsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "search-models" @@ -1997,16 +2192,20 @@ func newSearchModels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ModelRegistry.SearchModels(ctx, searchModelsReq) + sdkReq, err := modelregistry.SearchRegisteredModelsRequestToSDK(&searchModelsReq) + if err != nil { + return err + } if searchModelsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", searchModelsLimit) } if searchModelsLimit > 0 { ctx = cmdio.WithLimit(ctx, searchModelsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.ModelRegistry.SearchRegisteredModelsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, modelregistry.RegisteredModelFromSDK)) } // Disable completions since they are not applicable. @@ -2027,13 +2226,13 @@ func newSearchModels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setModelTagOverrides []func( *cobra.Command, - *ml.SetModelTagRequest, + *modelregistry.SetRegisteredModelTagRequest, ) func newSetModelTag() *cobra.Command { cmd := &cobra.Command{} + var setModelTagReq modelregistry.SetRegisteredModelTagRequest - var setModelTagReq ml.SetModelTagRequest var setModelTagJson flags.JsonFlag cmd.Flags().Var(&setModelTagJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2074,6 +2273,7 @@ func newSetModelTag() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setModelTagJson.Unmarshal(&setModelTagReq) @@ -2088,19 +2288,25 @@ func newSetModelTag() *cobra.Command { } } if !cmd.Flags().Changed("json") { - setModelTagReq.Name = args[0] + setModelTagReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - setModelTagReq.Key = args[1] + setModelTagReq.Key = new(args[1]) } if !cmd.Flags().Changed("json") { - setModelTagReq.Value = args[2] + setModelTagReq.Value = new(args[2]) } - err = w.ModelRegistry.SetModelTag(ctx, setModelTagReq) + sdkReq, err := modelregistry.SetRegisteredModelTagRequestToSDK(&setModelTagReq) if err != nil { return err } + response, err := w.ModelRegistry.SetRegisteredModelTag(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -2122,13 +2328,13 @@ func newSetModelTag() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setModelVersionTagOverrides []func( *cobra.Command, - *ml.SetModelVersionTagRequest, + *modelregistry.SetModelVersionTagRequest, ) func newSetModelVersionTag() *cobra.Command { cmd := &cobra.Command{} + var setModelVersionTagReq modelregistry.SetModelVersionTagRequest - var setModelVersionTagReq ml.SetModelVersionTagRequest var setModelVersionTagJson flags.JsonFlag cmd.Flags().Var(&setModelVersionTagJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2170,6 +2376,7 @@ func newSetModelVersionTag() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setModelVersionTagJson.Unmarshal(&setModelVersionTagReq) @@ -2184,22 +2391,28 @@ func newSetModelVersionTag() *cobra.Command { } } if !cmd.Flags().Changed("json") { - setModelVersionTagReq.Name = args[0] + setModelVersionTagReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - setModelVersionTagReq.Version = args[1] + setModelVersionTagReq.Version = new(args[1]) } if !cmd.Flags().Changed("json") { - setModelVersionTagReq.Key = args[2] + setModelVersionTagReq.Key = new(args[2]) } if !cmd.Flags().Changed("json") { - setModelVersionTagReq.Value = args[3] + setModelVersionTagReq.Value = new(args[3]) } - err = w.ModelRegistry.SetModelVersionTag(ctx, setModelVersionTagReq) + sdkReq, err := modelregistry.SetModelVersionTagRequestToSDK(&setModelVersionTagReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.SetModelVersionTag(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -2221,13 +2434,13 @@ func newSetModelVersionTag() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *ml.RegisteredModelPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq ml.RegisteredModelPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2258,6 +2471,7 @@ func newSetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -2271,14 +2485,24 @@ func newSetPermissions() *cobra.Command { } } } - setPermissionsReq.RegisteredModelId = args[0] + setPermissionsReq.RequestObjectId = new(args[0]) + + setPermissionsReq.RequestObjectType = new("registered-models") - response, err := w.ModelRegistry.SetPermissions(ctx, setPermissionsReq) + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2299,18 +2523,18 @@ func newSetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var testRegistryWebhookOverrides []func( *cobra.Command, - *ml.TestRegistryWebhookRequest, + *modelregistry.TestRegistryWebhookRequest, ) func newTestRegistryWebhook() *cobra.Command { cmd := &cobra.Command{} + var testRegistryWebhookReq modelregistry.TestRegistryWebhookRequest - var testRegistryWebhookReq ml.TestRegistryWebhookRequest var testRegistryWebhookJson flags.JsonFlag cmd.Flags().Var(&testRegistryWebhookJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Var(&testRegistryWebhookReq.Event, "event", `If event is specified, the test trigger uses the specified event. Supported values: [ + flags.EnumVar(cmd.Flags(), &testRegistryWebhookReq.Event, "event", `If event is specified, the test trigger uses the specified event. Supported values: [ COMMENT_CREATED, MODEL_VERSION_CREATED, MODEL_VERSION_TAG_SET, @@ -2323,7 +2547,7 @@ func newTestRegistryWebhook() *cobra.Command { TRANSITION_REQUEST_TO_ARCHIVED_CREATED, TRANSITION_REQUEST_TO_PRODUCTION_CREATED, TRANSITION_REQUEST_TO_STAGING_CREATED, -]`) +]`, "RegistryWebhookEvent", "COMMENT_CREATED", "MODEL_VERSION_CREATED", "MODEL_VERSION_TAG_SET", "MODEL_VERSION_TRANSITIONED_STAGE", "MODEL_VERSION_TRANSITIONED_TO_ARCHIVED", "MODEL_VERSION_TRANSITIONED_TO_PRODUCTION", "MODEL_VERSION_TRANSITIONED_TO_STAGING", "REGISTERED_MODEL_CREATED", "TRANSITION_REQUEST_CREATED", "TRANSITION_REQUEST_TO_ARCHIVED_CREATED", "TRANSITION_REQUEST_TO_PRODUCTION_CREATED", "TRANSITION_REQUEST_TO_STAGING_CREATED") cmd.Use = "test-registry-webhook ID" cmd.Short = `Test a webhook.` @@ -2354,6 +2578,7 @@ func newTestRegistryWebhook() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := testRegistryWebhookJson.Unmarshal(&testRegistryWebhookReq) @@ -2368,15 +2593,23 @@ func newTestRegistryWebhook() *cobra.Command { } } if !cmd.Flags().Changed("json") { - testRegistryWebhookReq.Id = args[0] + testRegistryWebhookReq.Id = new(args[0]) } - response, err := w.ModelRegistry.TestRegistryWebhook(ctx, testRegistryWebhookReq) + sdkReq, err := modelregistry.TestRegistryWebhookRequestToSDK(&testRegistryWebhookReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.TestRegistryWebhook(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.TestRegistryWebhookResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2397,18 +2630,18 @@ func newTestRegistryWebhook() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var transitionStageOverrides []func( *cobra.Command, - *ml.TransitionModelVersionStageDatabricks, + *modelregistry.TransitionModelVersionStageDatabricksRequest, ) func newTransitionStage() *cobra.Command { cmd := &cobra.Command{} + var transitionStageReq modelregistry.TransitionModelVersionStageDatabricksRequest - var transitionStageReq ml.TransitionModelVersionStageDatabricks var transitionStageJson flags.JsonFlag cmd.Flags().Var(&transitionStageJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&transitionStageReq.Comment, "comment", transitionStageReq.Comment, `User-provided comment on the action.`) + flags.StringPtrVar(cmd.Flags(), &transitionStageReq.Comment, "comment", `User-provided comment on the action.`) cmd.Use = "transition-stage NAME VERSION STAGE ARCHIVE_EXISTING_VERSIONS" cmd.Short = `Transition a stage.` @@ -2455,6 +2688,7 @@ func newTransitionStage() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := transitionStageJson.Unmarshal(&transitionStageReq) @@ -2469,28 +2703,37 @@ func newTransitionStage() *cobra.Command { } } if !cmd.Flags().Changed("json") { - transitionStageReq.Name = args[0] + transitionStageReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - transitionStageReq.Version = args[1] + transitionStageReq.Version = new(args[1]) } if !cmd.Flags().Changed("json") { - transitionStageReq.Stage = args[2] + transitionStageReq.Stage = new(args[2]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &transitionStageReq.ArchiveExistingVersions) + var transitionStageArchiveExistingVersionsArg bool + _, err = fmt.Sscan(args[3], &transitionStageArchiveExistingVersionsArg) if err != nil { return fmt.Errorf("invalid ARCHIVE_EXISTING_VERSIONS: %s", args[3]) } - + transitionStageReq.ArchiveExistingVersions = &transitionStageArchiveExistingVersionsArg } - response, err := w.ModelRegistry.TransitionStage(ctx, transitionStageReq) + sdkReq, err := modelregistry.TransitionModelVersionStageDatabricksRequestToSDK(&transitionStageReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.TransitionModelVersionStageDatabricks(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.TransitionModelVersionStageDatabricksResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2511,13 +2754,13 @@ func newTransitionStage() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateCommentOverrides []func( *cobra.Command, - *ml.UpdateComment, + *modelregistry.UpdateCommentRequest, ) func newUpdateComment() *cobra.Command { cmd := &cobra.Command{} + var updateCommentReq modelregistry.UpdateCommentRequest - var updateCommentReq ml.UpdateComment var updateCommentJson flags.JsonFlag cmd.Flags().Var(&updateCommentJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2552,6 +2795,7 @@ func newUpdateComment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateCommentJson.Unmarshal(&updateCommentReq) @@ -2566,18 +2810,26 @@ func newUpdateComment() *cobra.Command { } } if !cmd.Flags().Changed("json") { - updateCommentReq.Id = args[0] + updateCommentReq.Id = new(args[0]) } if !cmd.Flags().Changed("json") { - updateCommentReq.Comment = args[1] + updateCommentReq.Comment = new(args[1]) } - response, err := w.ModelRegistry.UpdateComment(ctx, updateCommentReq) + sdkReq, err := modelregistry.UpdateCommentRequestToSDK(&updateCommentReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.UpdateComment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.UpdateCommentResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2598,18 +2850,18 @@ func newUpdateComment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateModelOverrides []func( *cobra.Command, - *ml.UpdateModelRequest, + *modelregistry.UpdateRegisteredModelRequest, ) func newUpdateModel() *cobra.Command { cmd := &cobra.Command{} + var updateModelReq modelregistry.UpdateRegisteredModelRequest - var updateModelReq ml.UpdateModelRequest var updateModelJson flags.JsonFlag cmd.Flags().Var(&updateModelJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateModelReq.Description, "description", updateModelReq.Description, `If provided, updates the description for this registered_model.`) + flags.StringPtrVar(cmd.Flags(), &updateModelReq.Description, "description", `If provided, updates the description for this registered_model.`) cmd.Use = "update-model NAME" cmd.Short = `Update model.` @@ -2640,6 +2892,7 @@ func newUpdateModel() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateModelJson.Unmarshal(&updateModelReq) @@ -2654,15 +2907,23 @@ func newUpdateModel() *cobra.Command { } } if !cmd.Flags().Changed("json") { - updateModelReq.Name = args[0] + updateModelReq.Name = new(args[0]) } - response, err := w.ModelRegistry.UpdateModel(ctx, updateModelReq) + sdkReq, err := modelregistry.UpdateRegisteredModelRequestToSDK(&updateModelReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.UpdateRegisteredModel(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.UpdateRegisteredModelResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2683,18 +2944,18 @@ func newUpdateModel() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateModelVersionOverrides []func( *cobra.Command, - *ml.UpdateModelVersionRequest, + *modelregistry.UpdateModelVersionRequest, ) func newUpdateModelVersion() *cobra.Command { cmd := &cobra.Command{} + var updateModelVersionReq modelregistry.UpdateModelVersionRequest - var updateModelVersionReq ml.UpdateModelVersionRequest var updateModelVersionJson flags.JsonFlag cmd.Flags().Var(&updateModelVersionJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateModelVersionReq.Description, "description", updateModelVersionReq.Description, `If provided, updates the description for this registered_model.`) + flags.StringPtrVar(cmd.Flags(), &updateModelVersionReq.Description, "description", `If provided, updates the description for this registered_model.`) cmd.Use = "update-model-version NAME VERSION" cmd.Short = `Update model version.` @@ -2726,6 +2987,7 @@ func newUpdateModelVersion() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateModelVersionJson.Unmarshal(&updateModelVersionReq) @@ -2740,18 +3002,26 @@ func newUpdateModelVersion() *cobra.Command { } } if !cmd.Flags().Changed("json") { - updateModelVersionReq.Name = args[0] + updateModelVersionReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - updateModelVersionReq.Version = args[1] + updateModelVersionReq.Version = new(args[1]) } - response, err := w.ModelRegistry.UpdateModelVersion(ctx, updateModelVersionReq) + sdkReq, err := modelregistry.UpdateModelVersionRequestToSDK(&updateModelVersionReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.UpdateModelVersion(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.UpdateModelVersionResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2772,13 +3042,13 @@ func newUpdateModelVersion() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *ml.RegisteredModelPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq ml.RegisteredModelPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2808,6 +3078,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -2821,14 +3092,24 @@ func newUpdatePermissions() *cobra.Command { } } } - updatePermissionsReq.RegisteredModelId = args[0] + updatePermissionsReq.RequestObjectId = new(args[0]) - response, err := w.ModelRegistry.UpdatePermissions(ctx, updatePermissionsReq) + updatePermissionsReq.RequestObjectType = new("registered-models") + + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2849,22 +3130,22 @@ func newUpdatePermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateWebhookOverrides []func( *cobra.Command, - *ml.UpdateRegistryWebhook, + *modelregistry.UpdateRegistryWebhookRequest, ) func newUpdateWebhook() *cobra.Command { cmd := &cobra.Command{} + var updateWebhookReq modelregistry.UpdateRegistryWebhookRequest - var updateWebhookReq ml.UpdateRegistryWebhook var updateWebhookJson flags.JsonFlag cmd.Flags().Var(&updateWebhookJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateWebhookReq.Description, "description", updateWebhookReq.Description, `User-specified description for the webhook.`) + flags.StringPtrVar(cmd.Flags(), &updateWebhookReq.Description, "description", `User-specified description for the webhook.`) // TODO: array: events // TODO: complex arg: http_url_spec // TODO: complex arg: job_spec - cmd.Flags().Var(&updateWebhookReq.Status, "status", `Supported values: [ACTIVE, DISABLED, TEST_MODE]`) + flags.EnumVar(cmd.Flags(), &updateWebhookReq.Status, "status", `Supported values: [ACTIVE, DISABLED, TEST_MODE]`, "RegistryWebhookStatus", "ACTIVE", "DISABLED", "TEST_MODE") cmd.Use = "update-webhook ID" cmd.Short = `Update a webhook.` @@ -2895,6 +3176,7 @@ func newUpdateWebhook() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateWebhookJson.Unmarshal(&updateWebhookReq) @@ -2909,15 +3191,23 @@ func newUpdateWebhook() *cobra.Command { } } if !cmd.Flags().Changed("json") { - updateWebhookReq.Id = args[0] + updateWebhookReq.Id = new(args[0]) } - response, err := w.ModelRegistry.UpdateWebhook(ctx, updateWebhookReq) + sdkReq, err := modelregistry.UpdateRegistryWebhookRequestToSDK(&updateWebhookReq) + if err != nil { + return err + } + response, err := w.ModelRegistry.UpdateRegistryWebhook(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelregistry.UpdateRegistryWebhookResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/model-versions/model-versions.go b/cmd/workspace/model-versions/model-versions.go index 3d6e21a7f46..682865a61f1 100644 --- a/cmd/workspace/model-versions/model-versions.go +++ b/cmd/workspace/model-versions/model-versions.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucregisteredmodels "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1" + sdkucregisteredmodels "github.com/databricks/sdk-go/uc/registeredmodels/v1" ) // Slice with functions to override default command behavior. @@ -57,13 +60,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteModelVersionRequest, + *sdkucregisteredmodels.DeleteModelVersionRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq catalog.DeleteModelVersionRequest + var deleteReq sdkucregisteredmodels.DeleteModelVersionRequest cmd.Use = "delete FULL_NAME VERSION" cmd.Short = `Delete a Model Version.` @@ -94,17 +96,23 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.FullName = args[0] - _, err = fmt.Sscan(args[1], &deleteReq.Version) + deleteReq.FullNameArg = new(args[0]) + var deleteVersionArg int64 + _, err = fmt.Sscan(args[1], &deleteVersionArg) if err != nil { return fmt.Errorf("invalid VERSION: %s", args[1]) } + deleteReq.VersionArg = &deleteVersionArg - err = w.ModelVersions.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.RegisteredModels.DeleteModelVersion(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -126,16 +134,15 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetModelVersionRequest, + *ucregisteredmodels.GetModelVersionRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq ucregisteredmodels.GetModelVersionRequest - var getReq catalog.GetModelVersionRequest - - cmd.Flags().BoolVar(&getReq.IncludeAliases, "include-aliases", getReq.IncludeAliases, `Whether to include aliases associated with the model version in the response.`) - cmd.Flags().BoolVar(&getReq.IncludeBrowse, "include-browse", getReq.IncludeBrowse, `Whether to include model versions in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeAliases, "include-aliases", `Whether to include aliases associated with the model version in the response.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeBrowse, "include-browse", `Whether to include model versions in the response for which the principal can only access selective metadata for.`) cmd.Use = "get FULL_NAME VERSION" cmd.Short = `Get a Model Version.` @@ -165,19 +172,30 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.FullName = args[0] - _, err = fmt.Sscan(args[1], &getReq.Version) + getReq.FullNameArg = new(args[0]) + var getVersionArg int64 + _, err = fmt.Sscan(args[1], &getVersionArg) if err != nil { return fmt.Errorf("invalid VERSION: %s", args[1]) } + getReq.VersionArg = &getVersionArg - response, err := w.ModelVersions.Get(ctx, getReq) + sdkReq, err := ucregisteredmodels.GetModelVersionRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.RegisteredModels.GetModelVersion(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucregisteredmodels.ModelVersionInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -198,15 +216,14 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getByAliasOverrides []func( *cobra.Command, - *catalog.GetByAliasRequest, + *ucregisteredmodels.GetModelVersionByAliasRequest, ) func newGetByAlias() *cobra.Command { cmd := &cobra.Command{} + var getByAliasReq ucregisteredmodels.GetModelVersionByAliasRequest - var getByAliasReq catalog.GetByAliasRequest - - cmd.Flags().BoolVar(&getByAliasReq.IncludeAliases, "include-aliases", getByAliasReq.IncludeAliases, `Whether to include aliases associated with the model version in the response.`) + flags.BoolPtrVar(cmd.Flags(), &getByAliasReq.IncludeAliases, "include-aliases", `Whether to include aliases associated with the model version in the response.`) cmd.Use = "get-by-alias FULL_NAME ALIAS" cmd.Short = `Get Model Version By Alias.` @@ -236,16 +253,25 @@ func newGetByAlias() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getByAliasReq.FullName = args[0] - getByAliasReq.Alias = args[1] + getByAliasReq.FullNameArg = new(args[0]) + getByAliasReq.AliasArg = new(args[1]) - response, err := w.ModelVersions.GetByAlias(ctx, getByAliasReq) + sdkReq, err := ucregisteredmodels.GetModelVersionByAliasRequestToSDK(&getByAliasReq) + if err != nil { + return err + } + response, err := w.RegisteredModels.GetModelVersionByAlias(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucregisteredmodels.ModelVersionInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -266,26 +292,26 @@ func newGetByAlias() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListModelVersionsRequest, + *ucregisteredmodels.ListModelVersionsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq ucregisteredmodels.ListModelVersionsRequest - var listReq catalog.ListModelVersionsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().BoolVar(&listReq.IncludeBrowse, "include-browse", listReq.IncludeBrowse, `Whether to include model versions in the response for which the principal can only access selective metadata for.`) - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of model versions to return.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeBrowse, "include-browse", `Whether to include model versions in the response for which the principal can only access selective metadata for.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of model versions to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list FULL_NAME" @@ -328,18 +354,22 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.FullName = args[0] + listReq.FullNameArg = new(args[0]) - response := w.ModelVersions.List(ctx, listReq) + sdkReq, err := ucregisteredmodels.ListModelVersionsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.RegisteredModels.ListModelVersionsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucregisteredmodels.ModelVersionInfoFromSDK)) } // Disable completions since they are not applicable. @@ -360,34 +390,34 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateModelVersionRequest, + *ucregisteredmodels.UpdateModelVersionRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucregisteredmodels.UpdateModelVersionRequest - var updateReq catalog.UpdateModelVersionRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: aliases - cmd.Flags().StringVar(&updateReq.CatalogName, "catalog-name", updateReq.CatalogName, `The name of the catalog containing the model version.`) - cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `The comment attached to the model version.`) - cmd.Flags().Int64Var(&updateReq.CreatedAt, "created-at", updateReq.CreatedAt, ``) - cmd.Flags().StringVar(&updateReq.CreatedBy, "created-by", updateReq.CreatedBy, `The identifier of the user who created the model version.`) - cmd.Flags().StringVar(&updateReq.Id, "id", updateReq.Id, `The unique identifier of the model version.`) - cmd.Flags().StringVar(&updateReq.MetastoreId, "metastore-id", updateReq.MetastoreId, `The unique identifier of the metastore containing the model version.`) - cmd.Flags().StringVar(&updateReq.ModelName, "model-name", updateReq.ModelName, `The name of the parent registered model of the model version, relative to parent schema.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CatalogName, "catalog-name", `The name of the catalog containing the model version.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Comment, "comment", `The comment attached to the model version.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.CreatedAt, "created-at", ``) + flags.StringPtrVar(cmd.Flags(), &updateReq.CreatedBy, "created-by", `The identifier of the user who created the model version.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Id, "id", `The unique identifier of the model version.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.MetastoreId, "metastore-id", `The unique identifier of the metastore containing the model version.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.ModelName, "model-name", `The name of the parent registered model of the model version, relative to parent schema.`) // TODO: complex arg: model_version_dependencies - cmd.Flags().StringVar(&updateReq.RunId, "run-id", updateReq.RunId, `MLflow run ID used when creating the model version, if source was generated by an experiment run stored in an MLflow tracking server.`) - cmd.Flags().IntVar(&updateReq.RunWorkspaceId, "run-workspace-id", updateReq.RunWorkspaceId, `ID of the Databricks workspace containing the MLflow run that generated this model version, if applicable.`) - cmd.Flags().StringVar(&updateReq.SchemaName, "schema-name", updateReq.SchemaName, `The name of the schema containing the model version, relative to parent catalog.`) - cmd.Flags().StringVar(&updateReq.Source, "source", updateReq.Source, `URI indicating the location of the source artifacts (files) for the model version.`) - cmd.Flags().Var(&updateReq.Status, "status", `Current status of the model version. Supported values: [FAILED_REGISTRATION, MODEL_VERSION_STATUS_UNKNOWN, PENDING_REGISTRATION, READY]`) - cmd.Flags().StringVar(&updateReq.StorageLocation, "storage-location", updateReq.StorageLocation, `The storage location on the cloud under which model version data files are stored.`) - cmd.Flags().Int64Var(&updateReq.UpdatedAt, "updated-at", updateReq.UpdatedAt, ``) - cmd.Flags().StringVar(&updateReq.UpdatedBy, "updated-by", updateReq.UpdatedBy, `The identifier of the user who updated the model version last time.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.RunId, "run-id", `MLflow run ID used when creating the model version, if source was generated by an experiment run stored in an MLflow tracking server.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.RunWorkspaceId, "run-workspace-id", `ID of the Databricks workspace containing the MLflow run that generated this model version, if applicable.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.SchemaName, "schema-name", `The name of the schema containing the model version, relative to parent catalog.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Source, "source", `URI indicating the location of the source artifacts (files) for the model version.`) + flags.EnumVar(cmd.Flags(), &updateReq.Status, "status", `Current status of the model version. Supported values: [FAILED_REGISTRATION, MODEL_VERSION_STATUS_UNKNOWN, PENDING_REGISTRATION, READY]`, "ModelVersionInfoStatus", "FAILED_REGISTRATION", "MODEL_VERSION_STATUS_UNKNOWN", "PENDING_REGISTRATION", "READY") + flags.StringPtrVar(cmd.Flags(), &updateReq.StorageLocation, "storage-location", `The storage location on the cloud under which model version data files are stored.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.UpdatedAt, "updated-at", ``) + flags.StringPtrVar(cmd.Flags(), &updateReq.UpdatedBy, "updated-by", `The identifier of the user who updated the model version last time.`) cmd.Use = "update FULL_NAME VERSION" cmd.Short = `Update a Model Version.` @@ -419,6 +449,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -432,18 +463,28 @@ func newUpdate() *cobra.Command { } } } - updateReq.FullName = args[0] - _, err = fmt.Sscan(args[1], &updateReq.Version) + updateReq.FullNameArg = new(args[0]) + var updateVersionArg int64 + _, err = fmt.Sscan(args[1], &updateVersionArg) if err != nil { return fmt.Errorf("invalid VERSION: %s", args[1]) } + updateReq.VersionArg = &updateVersionArg - response, err := w.ModelVersions.Update(ctx, updateReq) + sdkReq, err := ucregisteredmodels.UpdateModelVersionRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.RegisteredModels.UpdateModelVersion(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucregisteredmodels.ModelVersionInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/notification-destinations/notification-destinations.go b/cmd/workspace/notification-destinations/notification-destinations.go index e463527466a..9a24e4b605f 100644 --- a/cmd/workspace/notification-destinations/notification-destinations.go +++ b/cmd/workspace/notification-destinations/notification-destinations.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" + + notificationdestinations "github.com/databricks/cli/libs/sdktypes/notificationdestinations/v1" + sdknotificationdestinations "github.com/databricks/sdk-go/notificationdestinations/v1" ) // Slice with functions to override default command behavior. @@ -55,19 +58,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *settings.CreateNotificationDestinationRequest, + *notificationdestinations.CreateNotificationDestinationRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq notificationdestinations.CreateNotificationDestinationRequest - var createReq settings.CreateNotificationDestinationRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: config - cmd.Flags().StringVar(&createReq.DisplayName, "display-name", createReq.DisplayName, `The display name for the notification destination.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DisplayName, "display-name", `The display name for the notification destination.`) cmd.Use = "create" cmd.Short = `Create a notification destination.` @@ -88,6 +91,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -102,12 +106,20 @@ func newCreate() *cobra.Command { } } - response, err := w.NotificationDestinations.Create(ctx, createReq) + sdkReq, err := notificationdestinations.CreateNotificationDestinationRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.NotificationDestinations.CreateNotificationDestination(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := notificationdestinations.NotificationDestinationFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -128,13 +140,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteNotificationDestinationRequest, + *sdknotificationdestinations.DeleteNotificationDestinationRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq settings.DeleteNotificationDestinationRequest + var deleteReq sdknotificationdestinations.DeleteNotificationDestinationRequest cmd.Use = "delete ID" cmd.Short = `Delete a notification destination.` @@ -155,13 +166,17 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = w.NotificationDestinations.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.NotificationDestinations.DeleteNotificationDestination(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -183,13 +198,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetNotificationDestinationRequest, + *sdknotificationdestinations.GetNotificationDestinationRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq settings.GetNotificationDestinationRequest + var getReq sdknotificationdestinations.GetNotificationDestinationRequest cmd.Use = "get ID" cmd.Short = `Get a notification destination.` @@ -210,15 +224,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.NotificationDestinations.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.NotificationDestinations.GetNotificationDestination(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := notificationdestinations.NotificationDestinationFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -239,25 +259,25 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *settings.ListNotificationDestinationsRequest, + *notificationdestinations.ListNotificationDestinationsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq notificationdestinations.ListNotificationDestinationsRequest - var listReq settings.ListNotificationDestinationsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().Int64Var(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.Int64PtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -279,16 +299,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.NotificationDestinations.List(ctx, listReq) + sdkReq, err := notificationdestinations.ListNotificationDestinationsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.NotificationDestinations.ListNotificationDestinationsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, notificationdestinations.ListNotificationDestinationsResultFromSDK)) } // Disable completions since they are not applicable. @@ -309,19 +333,19 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateNotificationDestinationRequest, + *notificationdestinations.UpdateNotificationDestinationRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq notificationdestinations.UpdateNotificationDestinationRequest - var updateReq settings.UpdateNotificationDestinationRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: config - cmd.Flags().StringVar(&updateReq.DisplayName, "display-name", updateReq.DisplayName, `The display name for the notification destination.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.DisplayName, "display-name", `The display name for the notification destination.`) cmd.Use = "update ID" cmd.Short = `Update a notification destination.` @@ -346,6 +370,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -359,14 +384,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - response, err := w.NotificationDestinations.Update(ctx, updateReq) + sdkReq, err := notificationdestinations.UpdateNotificationDestinationRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.NotificationDestinations.UpdateNotificationDestination(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := notificationdestinations.NotificationDestinationFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/online-tables/online-tables.go b/cmd/workspace/online-tables/online-tables.go index d634450328e..ace34ae40ae 100644 --- a/cmd/workspace/online-tables/online-tables.go +++ b/cmd/workspace/online-tables/online-tables.go @@ -3,15 +3,20 @@ package online_tables import ( - "fmt" "time" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + uconlinetables "github.com/databricks/cli/libs/sdktypes/uc/onlinetables/v1" + sdkuconlinetables "github.com/databricks/sdk-go/uc/onlinetables/v1" ) // Slice with functions to override default command behavior. @@ -53,14 +58,14 @@ Online tables provide lower latency and higher QPS access to data from Delta // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateOnlineTableRequest, + *uconlinetables.CreateOnlineTableRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq uconlinetables.CreateOnlineTableRequest + createReq.Table = &uconlinetables.OnlineTable{} - var createReq catalog.CreateOnlineTableRequest - createReq.Table = catalog.OnlineTable{} var createJson flags.JsonFlag var createSkipWait bool @@ -71,7 +76,7 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createReq.Table.Name, "name", createReq.Table.Name, `Full three-part (catalog, schema, table) name of the table.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Table.Name, "name", `Full three-part (catalog, schema, table) name of the table.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -96,6 +101,7 @@ Create an Online Table. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.Table) @@ -110,24 +116,39 @@ Create an Online Table. } } - wait, err := w.OnlineTables.Create(ctx, createReq) + sdkReq, err := uconlinetables.CreateOnlineTableRequestToSDK(&createReq) if err != nil { return err } if createSkipWait { - return cmdio.Render(ctx, wait.Response) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var current uconlinetables.OnlineTable + err = api.Do(ctx, "POST", "/api/2.0/online-tables", auth.WorkspaceIDHeaders(w.Config), nil, createReq.Table, ¤t) + if err != nil { + return err + } + return cmdio.Render(ctx, current) + } + wait, err := w.OnlineTables.CreateOnlineTable(ctx, *sdkReq) + if err != nil { + return err } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *catalog.OnlineTable) { - status := i.UnityCatalogProvisioningState - statusMessage := fmt.Sprintf("current status: %s", status) - sp.Update(statusMessage) - }).GetWithTimeout(createTimeout) + sp.Update("Waiting for create to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := uconlinetables.OnlineTableFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -148,13 +169,12 @@ Create an Online Table. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteOnlineTableRequest, + *sdkuconlinetables.DeleteOnlineTableRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq catalog.DeleteOnlineTableRequest + var deleteReq sdkuconlinetables.DeleteOnlineTableRequest cmd.Use = "delete NAME" cmd.Short = `*Public Preview* Delete an Online Table.` @@ -182,10 +202,12 @@ Delete an Online Table. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Name = args[0] + deleteReq.Name = new(args[0]) - err = w.OnlineTables.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = w.OnlineTables.DeleteOnlineTable(ctx, *sdkReq) if err != nil { return err } @@ -210,13 +232,12 @@ Delete an Online Table. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetOnlineTableRequest, + *sdkuconlinetables.GetOnlineTableRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq catalog.GetOnlineTableRequest + var getReq sdkuconlinetables.GetOnlineTableRequest cmd.Use = "get NAME" cmd.Short = `*Public Preview* Get an Online Table.` @@ -242,15 +263,21 @@ Get an Online Table. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Name = args[0] + getReq.Name = new(args[0]) - response, err := w.OnlineTables.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.OnlineTables.GetOnlineTable(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uconlinetables.OnlineTableFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/permission-migration/permission-migration.go b/cmd/workspace/permission-migration/permission-migration.go index 3c9b6741b28..06217d943ed 100644 --- a/cmd/workspace/permission-migration/permission-migration.go +++ b/cmd/workspace/permission-migration/permission-migration.go @@ -7,10 +7,11 @@ import ( "fmt" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/iam" "github.com/spf13/cobra" ) @@ -52,18 +53,23 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var migratePermissionsOverrides []func( *cobra.Command, - *iam.MigratePermissionsRequest, + *map[string]any, ) func newMigratePermissions() *cobra.Command { cmd := &cobra.Command{} + var migratePermissionsReq map[string]any + migratePermissionsReq = map[string]any{} + var migratePermissionsFromWorkspaceGroupNameRaw string + var migratePermissionsSizeRaw int + var migratePermissionsToAccountGroupNameRaw string + var migratePermissionsWorkspaceIdRaw int64 - var migratePermissionsReq iam.MigratePermissionsRequest var migratePermissionsJson flags.JsonFlag cmd.Flags().Var(&migratePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().IntVar(&migratePermissionsReq.Size, "size", migratePermissionsReq.Size, `The maximum number of permissions that will be migrated.`) + cmd.Flags().IntVar(&migratePermissionsSizeRaw, "size", migratePermissionsSizeRaw, `The maximum number of permissions that will be migrated.`) cmd.Use = "migrate-permissions WORKSPACE_ID FROM_WORKSPACE_GROUP_NAME TO_ACCOUNT_GROUP_NAME" cmd.Short = `Migrate Permissions.` @@ -95,6 +101,7 @@ func newMigratePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := migratePermissionsJson.Unmarshal(&migratePermissionsReq) @@ -109,24 +116,42 @@ func newMigratePermissions() *cobra.Command { } } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[0], &migratePermissionsReq.WorkspaceId) + _, err = fmt.Sscan(args[0], &migratePermissionsWorkspaceIdRaw) if err != nil { return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) } - } if !cmd.Flags().Changed("json") { - migratePermissionsReq.FromWorkspaceGroupName = args[1] + migratePermissionsFromWorkspaceGroupNameRaw = args[1] } if !cmd.Flags().Changed("json") { - migratePermissionsReq.ToAccountGroupName = args[2] + migratePermissionsToAccountGroupNameRaw = args[2] + } + + rawQuery := map[string]any{} + if cmd.Flags().Changed("from-workspace-group-name") || migratePermissionsFromWorkspaceGroupNameRaw != "" { + migratePermissionsReq["from_workspace_group_name"] = migratePermissionsFromWorkspaceGroupNameRaw + } + if cmd.Flags().Changed("size") || migratePermissionsSizeRaw != 0 { + migratePermissionsReq["size"] = migratePermissionsSizeRaw + } + if cmd.Flags().Changed("to-account-group-name") || migratePermissionsToAccountGroupNameRaw != "" { + migratePermissionsReq["to_account_group_name"] = migratePermissionsToAccountGroupNameRaw } + if cmd.Flags().Changed("workspace-id") || migratePermissionsWorkspaceIdRaw != 0 { + migratePermissionsReq["workspace_id"] = migratePermissionsWorkspaceIdRaw + } + rawPath := "/api/2.0/permissionmigration" - response, err := w.PermissionMigration.MigratePermissions(ctx, migratePermissionsReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, migratePermissionsReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/permissions/permissions.go b/cmd/workspace/permissions/permissions.go index 02bd53c875d..676d9109f51 100644 --- a/cmd/workspace/permissions/permissions.go +++ b/cmd/workspace/permissions/permissions.go @@ -7,8 +7,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" ) // Slice with functions to override default command behavior. @@ -78,13 +80,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *iam.GetPermissionRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq iam.GetPermissionRequest + var getReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get REQUEST_OBJECT_TYPE REQUEST_OBJECT_ID" cmd.Short = `Get object permissions.` @@ -115,16 +116,22 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.RequestObjectType = args[0] - getReq.RequestObjectId = args[1] + getReq.RequestObjectType = new(args[0]) + getReq.RequestObjectId = new(args[1]) - response, err := w.Permissions.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -145,13 +152,12 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *iam.GetPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq iam.GetPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels REQUEST_OBJECT_TYPE REQUEST_OBJECT_ID" cmd.Short = `Get object permission levels.` @@ -181,16 +187,22 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getPermissionLevelsReq.RequestObjectType = args[0] - getPermissionLevelsReq.RequestObjectId = args[1] + getPermissionLevelsReq.RequestObjectType = new(args[0]) + getPermissionLevelsReq.RequestObjectId = new(args[1]) - response, err := w.Permissions.GetPermissionLevels(ctx, getPermissionLevelsReq) + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -211,13 +223,13 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setOverrides []func( *cobra.Command, - *iam.SetObjectPermissions, + *accessmanagement.SetObjectPermissionsRequest, ) func newSet() *cobra.Command { cmd := &cobra.Command{} + var setReq accessmanagement.SetObjectPermissionsRequest - var setReq iam.SetObjectPermissions var setJson flags.JsonFlag cmd.Flags().Var(&setJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -254,6 +266,7 @@ func newSet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setJson.Unmarshal(&setReq) @@ -267,15 +280,23 @@ func newSet() *cobra.Command { } } } - setReq.RequestObjectType = args[0] - setReq.RequestObjectId = args[1] + setReq.RequestObjectType = new(args[0]) + setReq.RequestObjectId = new(args[1]) - response, err := w.Permissions.Set(ctx, setReq) + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -296,13 +317,13 @@ func newSet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *iam.UpdateObjectPermissions, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq accessmanagement.UpdateObjectPermissionsRequest - var updateReq iam.UpdateObjectPermissions var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -338,6 +359,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -351,15 +373,23 @@ func newUpdate() *cobra.Command { } } } - updateReq.RequestObjectType = args[0] - updateReq.RequestObjectId = args[1] + updateReq.RequestObjectType = new(args[0]) + updateReq.RequestObjectId = new(args[1]) - response, err := w.Permissions.Update(ctx, updateReq) + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/pipelines/overrides.go b/cmd/workspace/pipelines/overrides.go index 08c36deabe2..f4f2352f739 100644 --- a/cmd/workspace/pipelines/overrides.go +++ b/cmd/workspace/pipelines/overrides.go @@ -5,7 +5,7 @@ import ( "slices" pipelinesCli "github.com/databricks/cli/cmd/pipelines" - "github.com/databricks/databricks-sdk-go/service/pipelines" + pipelines "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/spf13/cobra" ) @@ -43,7 +43,7 @@ func init() { }) // 'stop' command is different in context of bundle vs. management command - stopOverrides = append(stopOverrides, func(cmd *cobra.Command, req *pipelines.StopRequest) { + stopOverrides = append(stopOverrides, func(cmd *cobra.Command, req *pipelines.StopPipelineRequest) { originalRunE := cmd.RunE cmd.RunE = func(cmd *cobra.Command, args []string) error { // For compatibility, if argument looks like pipeline ID, use API diff --git a/cmd/workspace/pipelines/pipelines.go b/cmd/workspace/pipelines/pipelines.go index fdbe1756026..a18dca2e051 100644 --- a/cmd/workspace/pipelines/pipelines.go +++ b/cmd/workspace/pipelines/pipelines.go @@ -9,10 +9,16 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/pipelines" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + pipelines "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdkpipelines "github.com/databricks/sdk-go/pipelines/v2" ) // Slice with functions to override default command behavior. @@ -83,7 +89,6 @@ var applyEnvironmentOverrides []func( func newApplyEnvironment() *cobra.Command { cmd := &cobra.Command{} - var applyEnvironmentReq pipelines.ApplyEnvironmentRequest cmd.Use = "apply-environment PIPELINE_ID" @@ -103,11 +108,12 @@ Apply the latest environment to the pipeline. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No PIPELINE_ID argument specified. Loading names for Pipelines drop-down.") - names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Pipelines.ListIter(ctx, sdkpipelines.ListPipelinesRequest{}), []string{"Name"}, []string{"PipelineId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) @@ -121,14 +127,19 @@ Apply the latest environment to the pipeline. if len(args) != 1 { return errors.New("expected to have ") } - applyEnvironmentReq.PipelineId = args[0] + applyEnvironmentReq.PipelineId = new(args[0]) - response, err := w.Pipelines.ApplyEnvironment(ctx, applyEnvironmentReq) + sdkReq, err := pipelines.ApplyEnvironmentRequestToSDK(&applyEnvironmentReq) + if err != nil { + return err + } + response, err := w.Pipelines.ApplyEnvironment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. @@ -154,8 +165,8 @@ var cloneOverrides []func( func newClone() *cobra.Command { cmd := &cobra.Command{} - var cloneReq pipelines.ClonePipelineRequest + var cloneJson flags.JsonFlag cmd.Flags().Var(&cloneJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -184,6 +195,7 @@ func newClone() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := cloneJson.Unmarshal(&cloneReq) @@ -199,14 +211,22 @@ func newClone() *cobra.Command { } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - cloneReq.PipelineId = args[0] + cloneReq.PipelineId = new(args[0]) - response, err := w.Pipelines.Clone(ctx, cloneReq) + sdkReq, err := pipelines.ClonePipelineRequestToSDK(&cloneReq) + if err != nil { + return err + } + response, err := w.Pipelines.Clone(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := pipelines.ClonePipelineResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -227,13 +247,13 @@ func newClone() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *pipelines.CreatePipeline, + *pipelines.CreatePipelineRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq pipelines.CreatePipelineRequest - var createReq pipelines.CreatePipeline var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -253,6 +273,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -269,12 +290,20 @@ func newCreate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Pipelines.Create(ctx, createReq) + sdkReq, err := pipelines.CreatePipelineRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Pipelines.Create(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := pipelines.CreatePipelineResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -300,11 +329,10 @@ var deleteOverrides []func( func newDelete() *cobra.Command { cmd := &cobra.Command{} - var deleteReq pipelines.DeletePipelineRequest - cmd.Flags().BoolVar(&deleteReq.Cascade, "cascade", deleteReq.Cascade, `If false, pipeline deletion will not cascade to its datasets (MVs, STs, Views).`) - cmd.Flags().BoolVar(&deleteReq.Force, "force", deleteReq.Force, `If true, deletion will proceed even if resource cleanup fails.`) + flags.BoolPtrVar(cmd.Flags(), &deleteReq.Cascade, "cascade", `If false, pipeline deletion will not cascade to its datasets (MVs, STs, Views).`) + flags.BoolPtrVar(cmd.Flags(), &deleteReq.Force, "force", `If true, deletion will proceed even if resource cleanup fails.`) cmd.Use = "delete PIPELINE_ID" cmd.Short = `Delete a pipeline.` @@ -322,11 +350,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No PIPELINE_ID argument specified. Loading names for Pipelines drop-down.") - names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Pipelines.ListIter(ctx, sdkpipelines.ListPipelinesRequest{}), []string{"Name"}, []string{"PipelineId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) @@ -340,12 +369,18 @@ func newDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - deleteReq.PipelineId = args[0] + deleteReq.PipelineId = new(args[0]) - err = w.Pipelines.Delete(ctx, deleteReq) + sdkReq, err := pipelines.DeletePipelineRequestToSDK(&deleteReq) + if err != nil { + return err + } + response, err := w.Pipelines.Delete(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -367,13 +402,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *pipelines.GetPipelineRequest, + *sdkpipelines.GetPipelineRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq pipelines.GetPipelineRequest + var getReq sdkpipelines.GetPipelineRequest cmd.Use = "get PIPELINE_ID" cmd.Short = `Get a pipeline.` @@ -387,11 +421,12 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No PIPELINE_ID argument specified. Loading names for Pipelines drop-down.") - names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Pipelines.ListIter(ctx, sdkpipelines.ListPipelinesRequest{}), []string{"Name"}, []string{"PipelineId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) @@ -405,14 +440,19 @@ func newGet() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - getReq.PipelineId = args[0] + getReq.PipelineId = new(args[0]) - response, err := w.Pipelines.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Pipelines.Get(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := pipelines.GetPipelineResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -433,13 +473,12 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *pipelines.GetPipelinePermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq pipelines.GetPipelinePermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels PIPELINE_ID" cmd.Short = `Get pipeline permission levels.` @@ -458,11 +497,12 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No PIPELINE_ID argument specified. Loading names for Pipelines drop-down.") - names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Pipelines.ListIter(ctx, sdkpipelines.ListPipelinesRequest{}), []string{"Name"}, []string{"PipelineId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) @@ -476,14 +516,21 @@ func newGetPermissionLevels() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the pipeline for which to get or manage permissions") } - getPermissionLevelsReq.PipelineId = args[0] + getPermissionLevelsReq.RequestObjectId = new(args[0]) + + getPermissionLevelsReq.RequestObjectType = new("pipelines") - response, err := w.Pipelines.GetPermissionLevels(ctx, getPermissionLevelsReq) + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -504,13 +551,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *pipelines.GetPipelinePermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq pipelines.GetPipelinePermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions PIPELINE_ID" cmd.Short = `Get pipeline permissions.` @@ -530,11 +576,12 @@ func newGetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No PIPELINE_ID argument specified. Loading names for Pipelines drop-down.") - names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Pipelines.ListIter(ctx, sdkpipelines.ListPipelinesRequest{}), []string{"Name"}, []string{"PipelineId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) @@ -548,14 +595,21 @@ func newGetPermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the pipeline for which to get or manage permissions") } - getPermissionsReq.PipelineId = args[0] + getPermissionsReq.RequestObjectId = new(args[0]) - response, err := w.Pipelines.GetPermissions(ctx, getPermissionsReq) + getPermissionsReq.RequestObjectType = new("pipelines") + + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -576,13 +630,12 @@ func newGetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getUpdateOverrides []func( *cobra.Command, - *pipelines.GetUpdateRequest, + *sdkpipelines.GetUpdateRequest, ) func newGetUpdate() *cobra.Command { cmd := &cobra.Command{} - - var getUpdateReq pipelines.GetUpdateRequest + var getUpdateReq sdkpipelines.GetUpdateRequest cmd.Use = "get-update PIPELINE_ID UPDATE_ID" cmd.Short = `Get a pipeline update.` @@ -607,16 +660,22 @@ func newGetUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getUpdateReq.PipelineId = args[0] - getUpdateReq.UpdateId = args[1] + getUpdateReq.PipelineId = new(args[0]) + getUpdateReq.UpdateId = new(args[1]) - response, err := w.Pipelines.GetUpdate(ctx, getUpdateReq) + sdkReq := &getUpdateReq + response, err := w.Pipelines.GetUpdate(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := pipelines.GetUpdateResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -642,22 +701,22 @@ var listPipelineEventsOverrides []func( func newListPipelineEvents() *cobra.Command { cmd := &cobra.Command{} - var listPipelineEventsReq pipelines.ListPipelineEventsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listPipelineEventsLimit int - cmd.Flags().StringVar(&listPipelineEventsReq.Filter, "filter", listPipelineEventsReq.Filter, `Criteria to select a subset of results, expressed using a SQL-like syntax.`) - cmd.Flags().IntVar(&listPipelineEventsReq.MaxResults, "max-results", listPipelineEventsReq.MaxResults, `Max number of entries to return in a single page.`) + flags.StringPtrVar(cmd.Flags(), &listPipelineEventsReq.Filter, "filter", `Criteria to select a subset of results, expressed using a SQL-like syntax.`) + flags.IntPtrVar(cmd.Flags(), &listPipelineEventsReq.MaxResults, "max-results", `Max number of entries to return in a single page.`) // TODO: array: order_by // Limit flag for total result capping. cmd.Flags().IntVar(&listPipelineEventsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listPipelineEventsReq.PageToken, "page-token", listPipelineEventsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listPipelineEventsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-pipeline-events PIPELINE_ID" @@ -677,11 +736,12 @@ func newListPipelineEvents() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No PIPELINE_ID argument specified. Loading names for Pipelines drop-down.") - names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Pipelines.ListIter(ctx, sdkpipelines.ListPipelinesRequest{}), []string{"Name"}, []string{"PipelineId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) @@ -695,17 +755,20 @@ func newListPipelineEvents() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the pipeline to return events for") } - listPipelineEventsReq.PipelineId = args[0] + listPipelineEventsReq.PipelineId = new(args[0]) - response := w.Pipelines.ListPipelineEvents(ctx, listPipelineEventsReq) + sdkReq, err := pipelines.ListPipelineEventsRequestToSDK(&listPipelineEventsReq) + if err != nil { + return err + } if listPipelineEventsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listPipelineEventsLimit) } if listPipelineEventsLimit > 0 { ctx = cmdio.WithLimit(ctx, listPipelineEventsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Pipelines.EventsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, pipelines.PipelineEventFromSDK)) } // Disable completions since they are not applicable. @@ -731,22 +794,22 @@ var listPipelinesOverrides []func( func newListPipelines() *cobra.Command { cmd := &cobra.Command{} - var listPipelinesReq pipelines.ListPipelinesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listPipelinesLimit int - cmd.Flags().StringVar(&listPipelinesReq.Filter, "filter", listPipelinesReq.Filter, `Select a subset of results based on the specified criteria.`) - cmd.Flags().IntVar(&listPipelinesReq.MaxResults, "max-results", listPipelinesReq.MaxResults, `The maximum number of entries to return in a single page.`) + flags.StringPtrVar(cmd.Flags(), &listPipelinesReq.Filter, "filter", `Select a subset of results based on the specified criteria.`) + flags.IntPtrVar(cmd.Flags(), &listPipelinesReq.MaxResults, "max-results", `The maximum number of entries to return in a single page.`) // TODO: array: order_by // Limit flag for total result capping. cmd.Flags().IntVar(&listPipelinesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listPipelinesReq.PageToken, "page-token", listPipelinesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listPipelinesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-pipelines" @@ -768,16 +831,20 @@ func newListPipelines() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Pipelines.ListPipelines(ctx, listPipelinesReq) + sdkReq, err := pipelines.ListPipelinesRequestToSDK(&listPipelinesReq) + if err != nil { + return err + } if listPipelinesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listPipelinesLimit) } if listPipelinesLimit > 0 { ctx = cmdio.WithLimit(ctx, listPipelinesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Pipelines.ListIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, pipelines.PipelineStateInfoFromSDK)) } // Disable completions since they are not applicable. @@ -803,12 +870,11 @@ var listUpdatesOverrides []func( func newListUpdates() *cobra.Command { cmd := &cobra.Command{} - var listUpdatesReq pipelines.ListUpdatesRequest - cmd.Flags().IntVar(&listUpdatesReq.MaxResults, "max-results", listUpdatesReq.MaxResults, `Max number of entries to return in a single page.`) - cmd.Flags().StringVar(&listUpdatesReq.PageToken, "page-token", listUpdatesReq.PageToken, `Page token returned by previous call.`) - cmd.Flags().StringVar(&listUpdatesReq.UntilUpdateId, "until-update-id", listUpdatesReq.UntilUpdateId, `If present, returns updates until and including this update_id.`) + flags.IntPtrVar(cmd.Flags(), &listUpdatesReq.MaxResults, "max-results", `Max number of entries to return in a single page.`) + flags.StringPtrVar(cmd.Flags(), &listUpdatesReq.PageToken, "page-token", `Page token returned by previous call.`) + flags.StringPtrVar(cmd.Flags(), &listUpdatesReq.UntilUpdateId, "until-update-id", `If present, returns updates until and including this update_id.`) cmd.Use = "list-updates PIPELINE_ID" cmd.Short = `List pipeline updates.` @@ -827,11 +893,12 @@ func newListUpdates() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No PIPELINE_ID argument specified. Loading names for Pipelines drop-down.") - names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Pipelines.ListIter(ctx, sdkpipelines.ListPipelinesRequest{}), []string{"Name"}, []string{"PipelineId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) @@ -845,14 +912,22 @@ func newListUpdates() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the pipeline to return updates for") } - listUpdatesReq.PipelineId = args[0] + listUpdatesReq.PipelineId = new(args[0]) - response, err := w.Pipelines.ListUpdates(ctx, listUpdatesReq) + sdkReq, err := pipelines.ListUpdatesRequestToSDK(&listUpdatesReq) + if err != nil { + return err + } + response, err := w.Pipelines.ListUpdates(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := pipelines.ListUpdatesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -873,13 +948,13 @@ func newListUpdates() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *pipelines.PipelinePermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq pipelines.PipelinePermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -905,6 +980,7 @@ func newSetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -921,7 +997,7 @@ func newSetPermissions() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No PIPELINE_ID argument specified. Loading names for Pipelines drop-down.") - names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Pipelines.ListIter(ctx, sdkpipelines.ListPipelinesRequest{}), []string{"Name"}, []string{"PipelineId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) @@ -935,14 +1011,24 @@ func newSetPermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the pipeline for which to get or manage permissions") } - setPermissionsReq.PipelineId = args[0] + setPermissionsReq.RequestObjectId = new(args[0]) + + setPermissionsReq.RequestObjectType = new("pipelines") - response, err := w.Pipelines.SetPermissions(ctx, setPermissionsReq) + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -963,18 +1049,18 @@ func newSetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var startUpdateOverrides []func( *cobra.Command, - *pipelines.StartUpdate, + *pipelines.StartUpdateRequest, ) func newStartUpdate() *cobra.Command { cmd := &cobra.Command{} + var startUpdateReq pipelines.StartUpdateRequest - var startUpdateReq pipelines.StartUpdate var startUpdateJson flags.JsonFlag cmd.Flags().Var(&startUpdateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Var(&startUpdateReq.Cause, "cause", `Supported values: [ + flags.EnumVar(cmd.Flags(), &startUpdateReq.Cause, "cause", `Supported values: [ API_CALL, INFRASTRUCTURE_MAINTENANCE, JOB_TASK, @@ -982,16 +1068,16 @@ func newStartUpdate() *cobra.Command { SCHEMA_CHANGE, SERVICE_UPGRADE, USER_ACTION, -]`) - cmd.Flags().BoolVar(&startUpdateReq.Development, "development", startUpdateReq.Development, `Whether the update is started in the development mode.`) - cmd.Flags().BoolVar(&startUpdateReq.FullRefresh, "full-refresh", startUpdateReq.FullRefresh, `If true, this update will reset all tables before running.`) +]`, "StartUpdateCause", "API_CALL", "INFRASTRUCTURE_MAINTENANCE", "JOB_TASK", "RETRY_ON_FAILURE", "SCHEMA_CHANGE", "SERVICE_UPGRADE", "USER_ACTION") + flags.BoolPtrVar(cmd.Flags(), &startUpdateReq.Development, "development", `Whether the update is started in the development mode.`) + flags.BoolPtrVar(cmd.Flags(), &startUpdateReq.FullRefresh, "full-refresh", `If true, this update will reset all tables before running.`) // TODO: array: full_refresh_selection // TODO: map via StringToStringVar: parameters // TODO: array: refresh_selection // TODO: array: replace_where_overrides // TODO: array: reset_checkpoint_selection // TODO: complex arg: rewind_spec - cmd.Flags().BoolVar(&startUpdateReq.ValidateOnly, "validate-only", startUpdateReq.ValidateOnly, `If true, this update only validates the correctness of pipeline source code but does not materialize or publish any datasets.`) + flags.BoolPtrVar(cmd.Flags(), &startUpdateReq.ValidateOnly, "validate-only", `If true, this update only validates the correctness of pipeline source code but does not materialize or publish any datasets.`) cmd.Use = "start-update PIPELINE_ID" cmd.Short = `Start a pipeline.` @@ -1008,6 +1094,7 @@ func newStartUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := startUpdateJson.Unmarshal(&startUpdateReq) @@ -1024,7 +1111,7 @@ func newStartUpdate() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No PIPELINE_ID argument specified. Loading names for Pipelines drop-down.") - names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Pipelines.ListIter(ctx, sdkpipelines.ListPipelinesRequest{}), []string{"Name"}, []string{"PipelineId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1038,14 +1125,22 @@ func newStartUpdate() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - startUpdateReq.PipelineId = args[0] + startUpdateReq.PipelineId = new(args[0]) - response, err := w.Pipelines.StartUpdate(ctx, startUpdateReq) + sdkReq, err := pipelines.StartUpdateRequestToSDK(&startUpdateReq) + if err != nil { + return err + } + response, err := w.Pipelines.Start(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := pipelines.StartUpdateResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1066,13 +1161,12 @@ func newStartUpdate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var stopOverrides []func( *cobra.Command, - *pipelines.StopRequest, + *pipelines.StopPipelineRequest, ) func newStop() *cobra.Command { cmd := &cobra.Command{} - - var stopReq pipelines.StopRequest + var stopReq pipelines.StopPipelineRequest var stopSkipWait bool var stopTimeout time.Duration @@ -1095,11 +1189,12 @@ func newStop() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No PIPELINE_ID argument specified. Loading names for Pipelines drop-down.") - names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Pipelines.ListIter(ctx, sdkpipelines.ListPipelinesRequest{}), []string{"Name"}, []string{"PipelineId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1113,25 +1208,41 @@ func newStop() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - stopReq.PipelineId = args[0] + stopReq.PipelineId = new(args[0]) - wait, err := w.Pipelines.Stop(ctx, stopReq) + sdkReq, err := pipelines.StopPipelineRequestToSDK(&stopReq) + if err != nil { + return err + } + wait, err := w.Pipelines.Stop(ctx, *sdkReq) if err != nil { return err } if stopSkipWait { - return nil + // Render the current state, as of right after the call. + current, err := w.Pipelines.Get(ctx, sdkpipelines.GetPipelineRequest{PipelineId: new(wait.GetPipelineId())}) + if err != nil { + return err + } + out, err := pipelines.GetPipelineResponseFromSDK(current) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *pipelines.GetPipelineResponse) { - statusMessage := i.Cause - sp.Update(statusMessage) - }).GetWithTimeout(stopTimeout) + sp.Update("Waiting for stop to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(stopTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := pipelines.GetPipelineResponseFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1152,51 +1263,51 @@ func newStop() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *pipelines.EditPipeline, + *pipelines.EditPipelineRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq pipelines.EditPipelineRequest - var updateReq pipelines.EditPipeline var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&updateReq.AllowDuplicateNames, "allow-duplicate-names", updateReq.AllowDuplicateNames, `If false, deployment will fail if name has changed and conflicts the name of another pipeline.`) - cmd.Flags().StringVar(&updateReq.BudgetPolicyId, "budget-policy-id", updateReq.BudgetPolicyId, `Budget policy of this pipeline.`) - cmd.Flags().StringVar(&updateReq.Catalog, "catalog", updateReq.Catalog, `A catalog in Unity Catalog to publish data from this pipeline to.`) - cmd.Flags().StringVar(&updateReq.Channel, "channel", updateReq.Channel, `SDP Release Channel that specifies which version to use.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.AllowDuplicateNames, "allow-duplicate-names", `If false, deployment will fail if name has changed and conflicts the name of another pipeline.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.BudgetPolicyId, "budget-policy-id", `Budget policy of this pipeline.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Catalog, "catalog", `A catalog in Unity Catalog to publish data from this pipeline to.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Channel, "channel", `SDP Release Channel that specifies which version to use.`) // TODO: array: clusters // TODO: map via StringToStringVar: configuration - cmd.Flags().BoolVar(&updateReq.Continuous, "continuous", updateReq.Continuous, `Whether the pipeline is continuous or triggered.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Continuous, "continuous", `Whether the pipeline is continuous or triggered.`) // TODO: complex arg: deployment - cmd.Flags().BoolVar(&updateReq.Development, "development", updateReq.Development, `Whether the pipeline is in Development mode.`) - cmd.Flags().StringVar(&updateReq.Edition, "edition", updateReq.Edition, `Pipeline product edition.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Development, "development", `Whether the pipeline is in Development mode.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Edition, "edition", `Pipeline product edition.`) // TODO: complex arg: environment // TODO: complex arg: event_log - cmd.Flags().Int64Var(&updateReq.ExpectedLastModified, "expected-last-modified", updateReq.ExpectedLastModified, `If present, the last-modified time of the pipeline settings before the edit.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.ExpectedLastModified, "expected-last-modified", `If present, the last-modified time of the pipeline settings before the edit.`) // TODO: complex arg: filters // TODO: complex arg: gateway_definition - cmd.Flags().StringVar(&updateReq.Id, "id", updateReq.Id, `Unique identifier for this pipeline.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Id, "id", `Unique identifier for this pipeline.`) // TODO: complex arg: ingestion_definition // TODO: array: libraries - cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `Friendly identifier for this pipeline.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Name, "name", `Friendly identifier for this pipeline.`) // TODO: array: notifications // TODO: map via StringToStringVar: parameters - cmd.Flags().StringVar(&updateReq.ParentPath, "parent-path", updateReq.ParentPath, `Path of the pipeline parent folder in workspace file tree.`) - cmd.Flags().BoolVar(&updateReq.Photon, "photon", updateReq.Photon, `Whether Photon is enabled for this pipeline.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.ParentPath, "parent-path", `Path of the pipeline parent folder in workspace file tree.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Photon, "photon", `Whether Photon is enabled for this pipeline.`) // TODO: complex arg: restart_window - cmd.Flags().StringVar(&updateReq.RootPath, "root-path", updateReq.RootPath, `Root path for this pipeline.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.RootPath, "root-path", `Root path for this pipeline.`) // TODO: complex arg: run_as - cmd.Flags().StringVar(&updateReq.Schema, "schema", updateReq.Schema, `The default schema (database) where tables are read from or published to.`) - cmd.Flags().BoolVar(&updateReq.Serverless, "serverless", updateReq.Serverless, `Whether serverless compute is enabled for this pipeline.`) - cmd.Flags().StringVar(&updateReq.ServerlessComputeId, "serverless-compute-id", updateReq.ServerlessComputeId, `Serverless compute ID specified by the user for serverless pipelines.`) - cmd.Flags().StringVar(&updateReq.Storage, "storage", updateReq.Storage, `DBFS root directory for storing checkpoints and tables.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Schema, "schema", `The default schema (database) where tables are read from or published to.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Serverless, "serverless", `Whether serverless compute is enabled for this pipeline.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.ServerlessComputeId, "serverless-compute-id", `Serverless compute ID specified by the user for serverless pipelines.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Storage, "storage", `DBFS root directory for storing checkpoints and tables.`) // TODO: map via StringToStringVar: tags - cmd.Flags().StringVar(&updateReq.Target, "target", updateReq.Target, `Target schema (database) to add tables in this pipeline to.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Target, "target", `Target schema (database) to add tables in this pipeline to.`) // TODO: complex arg: trigger - cmd.Flags().StringVar(&updateReq.UsagePolicyId, "usage-policy-id", updateReq.UsagePolicyId, `Usage policy of this pipeline.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.UsagePolicyId, "usage-policy-id", `Usage policy of this pipeline.`) cmd.Use = "update PIPELINE_ID" cmd.Short = `Edit a pipeline.` @@ -1215,6 +1326,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -1231,7 +1343,7 @@ func newUpdate() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No PIPELINE_ID argument specified. Loading names for Pipelines drop-down.") - names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Pipelines.ListIter(ctx, sdkpipelines.ListPipelinesRequest{}), []string{"Name"}, []string{"PipelineId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1245,12 +1357,18 @@ func newUpdate() *cobra.Command { if len(args) != 1 { return errors.New("expected to have unique identifier for this pipeline") } - updateReq.PipelineId = args[0] + updateReq.PipelineId = new(args[0]) - err = w.Pipelines.Update(ctx, updateReq) + sdkReq, err := pipelines.EditPipelineRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Pipelines.Edit(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -1272,13 +1390,13 @@ func newUpdate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *pipelines.PipelinePermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq pipelines.PipelinePermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1303,6 +1421,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -1319,7 +1438,7 @@ func newUpdatePermissions() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No PIPELINE_ID argument specified. Loading names for Pipelines drop-down.") - names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Pipelines.ListIter(ctx, sdkpipelines.ListPipelinesRequest{}), []string{"Name"}, []string{"PipelineId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1333,14 +1452,24 @@ func newUpdatePermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the pipeline for which to get or manage permissions") } - updatePermissionsReq.PipelineId = args[0] + updatePermissionsReq.RequestObjectId = new(args[0]) + + updatePermissionsReq.RequestObjectType = new("pipelines") - response, err := w.Pipelines.UpdatePermissions(ctx, updatePermissionsReq) + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/policies/policies.go b/cmd/workspace/policies/policies.go index 34607a8e956..851abddb20e 100644 --- a/cmd/workspace/policies/policies.go +++ b/cmd/workspace/policies/policies.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucabacpolicies "github.com/databricks/cli/libs/sdktypes/uc/abacpolicies/v1" + sdkucabacpolicies "github.com/databricks/sdk-go/uc/abacpolicies/v1" ) // Slice with functions to override default command behavior. @@ -59,27 +62,27 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createPolicyOverrides []func( *cobra.Command, - *catalog.CreatePolicyRequest, + *ucabacpolicies.CreatePolicyRequest, ) func newCreatePolicy() *cobra.Command { cmd := &cobra.Command{} + var createPolicyReq ucabacpolicies.CreatePolicyRequest + createPolicyReq.PolicyInfo = &ucabacpolicies.PolicyInfo{} - var createPolicyReq catalog.CreatePolicyRequest - createPolicyReq.PolicyInfo = catalog.PolicyInfo{} var createPolicyJson flags.JsonFlag cmd.Flags().Var(&createPolicyJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: column_mask - cmd.Flags().StringVar(&createPolicyReq.PolicyInfo.Comment, "comment", createPolicyReq.PolicyInfo.Comment, `Optional description of the policy.`) + flags.StringPtrVar(cmd.Flags(), &createPolicyReq.PolicyInfo.Comment, "comment", `Optional description of the policy.`) // TODO: complex arg: deny // TODO: array: except_principals // TODO: complex arg: grant // TODO: array: match_columns - cmd.Flags().StringVar(&createPolicyReq.PolicyInfo.Name, "name", createPolicyReq.PolicyInfo.Name, `Name of the policy.`) - cmd.Flags().StringVar(&createPolicyReq.PolicyInfo.OnSecurableFullname, "on-securable-fullname", createPolicyReq.PolicyInfo.OnSecurableFullname, `Full name of the securable on which the policy is defined.`) - cmd.Flags().Var(&createPolicyReq.PolicyInfo.OnSecurableType, "on-securable-type", `Type of the securable on which the policy is defined. Supported values: [ + flags.StringPtrVar(cmd.Flags(), &createPolicyReq.PolicyInfo.Name, "name", `Name of the policy.`) + flags.StringPtrVar(cmd.Flags(), &createPolicyReq.PolicyInfo.OnSecurableFullname, "on-securable-fullname", `Full name of the securable on which the policy is defined.`) + flags.EnumVar(cmd.Flags(), &createPolicyReq.PolicyInfo.OnSecurableType, "on-securable-type", `Type of the securable on which the policy is defined. Supported values: [ AGENT_SERVICE, CATALOG, CLEAN_ROOM, @@ -103,9 +106,9 @@ func newCreatePolicy() *cobra.Command { STORAGE_CREDENTIAL, TABLE, VOLUME, -]`) +]`, "SecurableType", "AGENT_SERVICE", "CATALOG", "CLEAN_ROOM", "CONNECTION", "CREDENTIAL", "EXTERNAL_LOCATION", "EXTERNAL_METADATA", "FUNCTION", "MCP_SERVICE", "METASTORE", "MODEL", "MODEL_PROVIDER_SERVICE", "MODEL_SERVICE", "PIPELINE", "PROVIDER", "RECIPIENT", "SCHEMA", "SHARE", "SKILL", "STAGING_TABLE", "STORAGE_CREDENTIAL", "TABLE", "VOLUME") // TODO: complex arg: row_filter - cmd.Flags().StringVar(&createPolicyReq.PolicyInfo.WhenCondition, "when-condition", createPolicyReq.PolicyInfo.WhenCondition, `Optional condition when the policy should take effect.`) + flags.StringPtrVar(cmd.Flags(), &createPolicyReq.PolicyInfo.WhenCondition, "when-condition", `Optional condition when the policy should take effect.`) cmd.Use = "create-policy TO_PRINCIPALS FOR_SECURABLE_TYPE POLICY_TYPE" cmd.Short = `Create an ABAC policy.` @@ -167,6 +170,7 @@ func newCreatePolicy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createPolicyJson.Unmarshal(&createPolicyReq.PolicyInfo) @@ -181,33 +185,29 @@ func newCreatePolicy() *cobra.Command { } } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[0], &createPolicyReq.PolicyInfo.ToPrincipals) - if err != nil { - return fmt.Errorf("invalid TO_PRINCIPALS: %s", args[0]) - } - + _ = args[0] // TODO: complex arg: to_principals } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createPolicyReq.PolicyInfo.ForSecurableType) - if err != nil { - return fmt.Errorf("invalid FOR_SECURABLE_TYPE: %s", args[1]) - } - + createPolicyReq.PolicyInfo.ForSecurableType = ucabacpolicies.SecurableType(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &createPolicyReq.PolicyInfo.PolicyType) - if err != nil { - return fmt.Errorf("invalid POLICY_TYPE: %s", args[2]) - } - + createPolicyReq.PolicyInfo.PolicyType = ucabacpolicies.PolicyType(args[2]) } - response, err := w.Policies.CreatePolicy(ctx, createPolicyReq) + sdkReq, err := ucabacpolicies.CreatePolicyRequestToSDK(&createPolicyReq) + if err != nil { + return err + } + response, err := w.AbacPolicies.CreatePolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucabacpolicies.PolicyInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -228,13 +228,12 @@ func newCreatePolicy() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deletePolicyOverrides []func( *cobra.Command, - *catalog.DeletePolicyRequest, + *sdkucabacpolicies.DeletePolicyRequest, ) func newDeletePolicy() *cobra.Command { cmd := &cobra.Command{} - - var deletePolicyReq catalog.DeletePolicyRequest + var deletePolicyReq sdkucabacpolicies.DeletePolicyRequest cmd.Use = "delete-policy ON_SECURABLE_TYPE ON_SECURABLE_FULLNAME NAME" cmd.Short = `Delete an ABAC policy.` @@ -261,17 +260,20 @@ func newDeletePolicy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deletePolicyReq.OnSecurableType = args[0] - deletePolicyReq.OnSecurableFullname = args[1] - deletePolicyReq.Name = args[2] + deletePolicyReq.OnSecurableType = new(args[0]) + deletePolicyReq.OnSecurableFullname = new(args[1]) + deletePolicyReq.Name = new(args[2]) - response, err := w.Policies.DeletePolicy(ctx, deletePolicyReq) + sdkReq := &deletePolicyReq + response, err := w.AbacPolicies.DeletePolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. @@ -292,13 +294,12 @@ func newDeletePolicy() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPolicyOverrides []func( *cobra.Command, - *catalog.GetPolicyRequest, + *sdkucabacpolicies.GetPolicyRequest, ) func newGetPolicy() *cobra.Command { cmd := &cobra.Command{} - - var getPolicyReq catalog.GetPolicyRequest + var getPolicyReq sdkucabacpolicies.GetPolicyRequest cmd.Use = "get-policy ON_SECURABLE_TYPE ON_SECURABLE_FULLNAME NAME" cmd.Short = `Get an ABAC policy.` @@ -324,17 +325,23 @@ func newGetPolicy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getPolicyReq.OnSecurableType = args[0] - getPolicyReq.OnSecurableFullname = args[1] - getPolicyReq.Name = args[2] + getPolicyReq.OnSecurableType = new(args[0]) + getPolicyReq.OnSecurableFullname = new(args[1]) + getPolicyReq.Name = new(args[2]) - response, err := w.Policies.GetPolicy(ctx, getPolicyReq) + sdkReq := &getPolicyReq + response, err := w.AbacPolicies.GetPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucabacpolicies.PolicyInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -355,26 +362,26 @@ func newGetPolicy() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listPoliciesOverrides []func( *cobra.Command, - *catalog.ListPoliciesRequest, + *ucabacpolicies.ListPoliciesRequest, ) func newListPolicies() *cobra.Command { cmd := &cobra.Command{} + var listPoliciesReq ucabacpolicies.ListPoliciesRequest - var listPoliciesReq catalog.ListPoliciesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listPoliciesLimit int - cmd.Flags().BoolVar(&listPoliciesReq.IncludeInherited, "include-inherited", listPoliciesReq.IncludeInherited, `Optional.`) - cmd.Flags().IntVar(&listPoliciesReq.MaxResults, "max-results", listPoliciesReq.MaxResults, `Optional.`) + flags.BoolPtrVar(cmd.Flags(), &listPoliciesReq.IncludeInherited, "include-inherited", `Optional.`) + flags.IntPtrVar(cmd.Flags(), &listPoliciesReq.MaxResults, "max-results", `Optional.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listPoliciesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listPoliciesReq.PageToken, "page-token", listPoliciesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listPoliciesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-policies ON_SECURABLE_TYPE ON_SECURABLE_FULLNAME" @@ -406,19 +413,23 @@ func newListPolicies() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listPoliciesReq.OnSecurableType = args[0] - listPoliciesReq.OnSecurableFullname = args[1] + listPoliciesReq.OnSecurableType = new(args[0]) + listPoliciesReq.OnSecurableFullname = new(args[1]) - response := w.Policies.ListPolicies(ctx, listPoliciesReq) + sdkReq, err := ucabacpolicies.ListPoliciesRequestToSDK(&listPoliciesReq) + if err != nil { + return err + } if listPoliciesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listPoliciesLimit) } if listPoliciesLimit > 0 { ctx = cmdio.WithLimit(ctx, listPoliciesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.AbacPolicies.ListPoliciesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucabacpolicies.PolicyInfoFromSDK)) } // Disable completions since they are not applicable. @@ -439,28 +450,28 @@ func newListPolicies() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePolicyOverrides []func( *cobra.Command, - *catalog.UpdatePolicyRequest, + *ucabacpolicies.UpdatePolicyRequest, ) func newUpdatePolicy() *cobra.Command { cmd := &cobra.Command{} + var updatePolicyReq ucabacpolicies.UpdatePolicyRequest + updatePolicyReq.PolicyInfo = &ucabacpolicies.PolicyInfo{} - var updatePolicyReq catalog.UpdatePolicyRequest - updatePolicyReq.PolicyInfo = catalog.PolicyInfo{} var updatePolicyJson flags.JsonFlag cmd.Flags().Var(&updatePolicyJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updatePolicyReq.UpdateMask, "update-mask", updatePolicyReq.UpdateMask, `Optional.`) + flags.StringPtrVar(cmd.Flags(), &updatePolicyReq.UpdateMask, "update-mask", `Optional.`) // TODO: complex arg: column_mask - cmd.Flags().StringVar(&updatePolicyReq.PolicyInfo.Comment, "comment", updatePolicyReq.PolicyInfo.Comment, `Optional description of the policy.`) + flags.StringPtrVar(cmd.Flags(), &updatePolicyReq.PolicyInfo.Comment, "comment", `Optional description of the policy.`) // TODO: complex arg: deny // TODO: array: except_principals // TODO: complex arg: grant // TODO: array: match_columns - cmd.Flags().StringVar(&updatePolicyReq.PolicyInfo.Name, "name", updatePolicyReq.PolicyInfo.Name, `Name of the policy.`) - cmd.Flags().StringVar(&updatePolicyReq.PolicyInfo.OnSecurableFullname, "on-securable-fullname", updatePolicyReq.PolicyInfo.OnSecurableFullname, `Full name of the securable on which the policy is defined.`) - cmd.Flags().Var(&updatePolicyReq.PolicyInfo.OnSecurableType, "on-securable-type", `Type of the securable on which the policy is defined. Supported values: [ + flags.StringPtrVar(cmd.Flags(), &updatePolicyReq.Name, "name", `Name of the policy.`) + flags.StringPtrVar(cmd.Flags(), &updatePolicyReq.OnSecurableFullname, "on-securable-fullname", `Full name of the securable on which the policy is defined.`) + flags.EnumPtrVar(cmd.Flags(), &updatePolicyReq.OnSecurableType, "on-securable-type", `Type of the securable on which the policy is defined. Supported values: [ AGENT_SERVICE, CATALOG, CLEAN_ROOM, @@ -484,9 +495,9 @@ func newUpdatePolicy() *cobra.Command { STORAGE_CREDENTIAL, TABLE, VOLUME, -]`) +]`, "SecurableType", "AGENT_SERVICE", "CATALOG", "CLEAN_ROOM", "CONNECTION", "CREDENTIAL", "EXTERNAL_LOCATION", "EXTERNAL_METADATA", "FUNCTION", "MCP_SERVICE", "METASTORE", "MODEL", "MODEL_PROVIDER_SERVICE", "MODEL_SERVICE", "PIPELINE", "PROVIDER", "RECIPIENT", "SCHEMA", "SHARE", "SKILL", "STAGING_TABLE", "STORAGE_CREDENTIAL", "TABLE", "VOLUME") // TODO: complex arg: row_filter - cmd.Flags().StringVar(&updatePolicyReq.PolicyInfo.WhenCondition, "when-condition", updatePolicyReq.PolicyInfo.WhenCondition, `Optional condition when the policy should take effect.`) + flags.StringPtrVar(cmd.Flags(), &updatePolicyReq.PolicyInfo.WhenCondition, "when-condition", `Optional condition when the policy should take effect.`) cmd.Use = "update-policy ON_SECURABLE_TYPE ON_SECURABLE_FULLNAME NAME TO_PRINCIPALS FOR_SECURABLE_TYPE POLICY_TYPE" cmd.Short = `Update an ABAC policy.` @@ -551,6 +562,7 @@ func newUpdatePolicy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePolicyJson.Unmarshal(&updatePolicyReq.PolicyInfo) @@ -564,37 +576,33 @@ func newUpdatePolicy() *cobra.Command { } } } - updatePolicyReq.OnSecurableType = args[0] - updatePolicyReq.OnSecurableFullname = args[1] - updatePolicyReq.Name = args[2] + updatePolicyReq.OnSecurableType = new(args[0]) + updatePolicyReq.OnSecurableFullname = new(args[1]) + updatePolicyReq.Name = new(args[2]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updatePolicyReq.PolicyInfo.ToPrincipals) - if err != nil { - return fmt.Errorf("invalid TO_PRINCIPALS: %s", args[3]) - } - + _ = args[3] // TODO: complex arg: to_principals } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[4], &updatePolicyReq.PolicyInfo.ForSecurableType) - if err != nil { - return fmt.Errorf("invalid FOR_SECURABLE_TYPE: %s", args[4]) - } - + updatePolicyReq.PolicyInfo.ForSecurableType = ucabacpolicies.SecurableType(args[4]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[5], &updatePolicyReq.PolicyInfo.PolicyType) - if err != nil { - return fmt.Errorf("invalid POLICY_TYPE: %s", args[5]) - } - + updatePolicyReq.PolicyInfo.PolicyType = ucabacpolicies.PolicyType(args[5]) } - response, err := w.Policies.UpdatePolicy(ctx, updatePolicyReq) + sdkReq, err := ucabacpolicies.UpdatePolicyRequestToSDK(&updatePolicyReq) + if err != nil { + return err + } + response, err := w.AbacPolicies.UpdatePolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucabacpolicies.PolicyInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/policy-compliance-for-clusters/policy-compliance-for-clusters.go b/cmd/workspace/policy-compliance-for-clusters/policy-compliance-for-clusters.go index e18a23b556f..f59cdbfb632 100644 --- a/cmd/workspace/policy-compliance-for-clusters/policy-compliance-for-clusters.go +++ b/cmd/workspace/policy-compliance-for-clusters/policy-compliance-for-clusters.go @@ -8,10 +8,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" + + clusters "github.com/databricks/cli/libs/sdktypes/clusters/v2" ) // Slice with functions to override default command behavior. @@ -60,18 +62,18 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var cancelPendingClusterEnforcementOverrides []func( *cobra.Command, - *compute.CancelPendingClusterEnforcementRequest, + *clusters.CancelPendingClusterEnforcementRequest, ) func newCancelPendingClusterEnforcement() *cobra.Command { cmd := &cobra.Command{} + var cancelPendingClusterEnforcementReq clusters.CancelPendingClusterEnforcementRequest - var cancelPendingClusterEnforcementReq compute.CancelPendingClusterEnforcementRequest var cancelPendingClusterEnforcementJson flags.JsonFlag cmd.Flags().Var(&cancelPendingClusterEnforcementJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&cancelPendingClusterEnforcementReq.AllowMissing, "allow-missing", cancelPendingClusterEnforcementReq.AllowMissing, `If true and no pending enforcement exists, the request will succeed but no action will be taken.`) + flags.BoolPtrVar(cmd.Flags(), &cancelPendingClusterEnforcementReq.AllowMissing, "allow-missing", `If true and no pending enforcement exists, the request will succeed but no action will be taken.`) cmd.Use = "cancel-pending-cluster-enforcement CLUSTER_ID" cmd.Short = `Cancel pending policy enforcement for a cluster.` @@ -105,6 +107,7 @@ func newCancelPendingClusterEnforcement() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := cancelPendingClusterEnforcementJson.Unmarshal(&cancelPendingClusterEnforcementReq) @@ -119,15 +122,20 @@ func newCancelPendingClusterEnforcement() *cobra.Command { } } if !cmd.Flags().Changed("json") { - cancelPendingClusterEnforcementReq.ClusterId = args[0] + cancelPendingClusterEnforcementReq.ClusterId = new(args[0]) } - response, err := w.PolicyComplianceForClusters.CancelPendingClusterEnforcement(ctx, cancelPendingClusterEnforcementReq) + sdkReq, err := clusters.CancelPendingClusterEnforcementRequestToSDK(&cancelPendingClusterEnforcementReq) + if err != nil { + return err + } + response, err := w.Clusters.CancelPendingClusterEnforcement(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. @@ -148,19 +156,19 @@ func newCancelPendingClusterEnforcement() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var enforceComplianceOverrides []func( *cobra.Command, - *compute.EnforceClusterComplianceRequest, + *clusters.EnforcePolicyComplianceForClusterRequest, ) func newEnforceCompliance() *cobra.Command { cmd := &cobra.Command{} + var enforceComplianceReq clusters.EnforcePolicyComplianceForClusterRequest - var enforceComplianceReq compute.EnforceClusterComplianceRequest var enforceComplianceJson flags.JsonFlag cmd.Flags().Var(&enforceComplianceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Var(&enforceComplianceReq.EnforceMode, "enforce-mode", `Determines how changes should be made to clusters that are not in TERMINATED state. Supported values: [ENFORCE_IMMEDIATELY, WAIT_FOR_TERMINATION]`) - cmd.Flags().BoolVar(&enforceComplianceReq.ValidateOnly, "validate-only", enforceComplianceReq.ValidateOnly, `If set, previews the changes that would be made to a cluster to enforce compliance but does not update the cluster.`) + flags.EnumVar(cmd.Flags(), &enforceComplianceReq.EnforceMode, "enforce-mode", `Determines how changes should be made to clusters that are not in TERMINATED state. Supported values: [ENFORCE_IMMEDIATELY, WAIT_FOR_TERMINATION]`, "EnforcePolicyComplianceForClusterEnforceMode", "ENFORCE_IMMEDIATELY", "WAIT_FOR_TERMINATION") + flags.BoolPtrVar(cmd.Flags(), &enforceComplianceReq.ValidateOnly, "validate-only", `If set, previews the changes that would be made to a cluster to enforce compliance but does not update the cluster.`) cmd.Use = "enforce-compliance CLUSTER_ID" cmd.Short = `Enforce cluster policy compliance.` @@ -201,6 +209,7 @@ func newEnforceCompliance() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := enforceComplianceJson.Unmarshal(&enforceComplianceReq) @@ -215,15 +224,23 @@ func newEnforceCompliance() *cobra.Command { } } if !cmd.Flags().Changed("json") { - enforceComplianceReq.ClusterId = args[0] + enforceComplianceReq.ClusterId = new(args[0]) } - response, err := w.PolicyComplianceForClusters.EnforceCompliance(ctx, enforceComplianceReq) + sdkReq, err := clusters.EnforcePolicyComplianceForClusterRequestToSDK(&enforceComplianceReq) + if err != nil { + return err + } + response, err := w.Clusters.EnforcePolicyComplianceForCluster(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := clusters.EnforcePolicyComplianceForClusterResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -244,13 +261,12 @@ func newEnforceCompliance() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getComplianceOverrides []func( *cobra.Command, - *compute.GetClusterComplianceRequest, + *clusters.GetPolicyComplianceForClusterRequest, ) func newGetCompliance() *cobra.Command { cmd := &cobra.Command{} - - var getComplianceReq compute.GetClusterComplianceRequest + var getComplianceReq clusters.GetPolicyComplianceForClusterRequest cmd.Use = "get-compliance CLUSTER_ID" cmd.Short = `Get cluster policy compliance.` @@ -275,15 +291,24 @@ func newGetCompliance() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getComplianceReq.ClusterId = args[0] + getComplianceReq.ClusterId = new(args[0]) - response, err := w.PolicyComplianceForClusters.GetCompliance(ctx, getComplianceReq) + sdkReq, err := clusters.GetPolicyComplianceForClusterRequestToSDK(&getComplianceReq) + if err != nil { + return err + } + response, err := w.Clusters.GetPolicyComplianceForCluster(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := clusters.GetPolicyComplianceForClusterResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -304,25 +329,25 @@ func newGetCompliance() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listComplianceOverrides []func( *cobra.Command, - *compute.ListClusterCompliancesRequest, + *clusters.ListClusterComplianceForPolicyRequest, ) func newListCompliance() *cobra.Command { cmd := &cobra.Command{} + var listComplianceReq clusters.ListClusterComplianceForPolicyRequest - var listComplianceReq compute.ListClusterCompliancesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listComplianceLimit int - cmd.Flags().IntVar(&listComplianceReq.PageSize, "page-size", listComplianceReq.PageSize, `Use this field to specify the maximum number of results to be returned by the server.`) + flags.IntPtrVar(cmd.Flags(), &listComplianceReq.PageSize, "page-size", `Use this field to specify the maximum number of results to be returned by the server.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listComplianceLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listComplianceReq.PageToken, "page-token", listComplianceReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listComplianceReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-compliance POLICY_ID" @@ -349,18 +374,22 @@ func newListCompliance() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listComplianceReq.PolicyId = args[0] + listComplianceReq.PolicyId = new(args[0]) - response := w.PolicyComplianceForClusters.ListCompliance(ctx, listComplianceReq) + sdkReq, err := clusters.ListClusterComplianceForPolicyRequestToSDK(&listComplianceReq) + if err != nil { + return err + } if listComplianceLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listComplianceLimit) } if listComplianceLimit > 0 { ctx = cmdio.WithLimit(ctx, listComplianceLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Clusters.ListClusterComplianceForPolicyIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, clusters.ClusterComplianceFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/policy-compliance-for-jobs/policy-compliance-for-jobs.go b/cmd/workspace/policy-compliance-for-jobs/policy-compliance-for-jobs.go index 7925735e472..9c45c30adcb 100644 --- a/cmd/workspace/policy-compliance-for-jobs/policy-compliance-for-jobs.go +++ b/cmd/workspace/policy-compliance-for-jobs/policy-compliance-for-jobs.go @@ -8,10 +8,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/spf13/cobra" + + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" ) // Slice with functions to override default command behavior. @@ -62,18 +64,18 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var enforceComplianceOverrides []func( *cobra.Command, - *jobs.EnforcePolicyComplianceRequest, + *jobs.EnforcePolicyComplianceForJob, ) func newEnforceCompliance() *cobra.Command { cmd := &cobra.Command{} + var enforceComplianceReq jobs.EnforcePolicyComplianceForJob - var enforceComplianceReq jobs.EnforcePolicyComplianceRequest var enforceComplianceJson flags.JsonFlag cmd.Flags().Var(&enforceComplianceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&enforceComplianceReq.ValidateOnly, "validate-only", enforceComplianceReq.ValidateOnly, `If set, previews changes made to the job to comply with its policy, but does not update the job.`) + flags.BoolPtrVar(cmd.Flags(), &enforceComplianceReq.ValidateOnly, "validate-only", `If set, previews changes made to the job to comply with its policy, but does not update the job.`) cmd.Use = "enforce-compliance JOB_ID" cmd.Short = `Enforce job policy compliance.` @@ -107,6 +109,7 @@ func newEnforceCompliance() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := enforceComplianceJson.Unmarshal(&enforceComplianceReq) @@ -121,19 +124,28 @@ func newEnforceCompliance() *cobra.Command { } } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[0], &enforceComplianceReq.JobId) + var enforceComplianceJobIdArg int64 + _, err = fmt.Sscan(args[0], &enforceComplianceJobIdArg) if err != nil { return fmt.Errorf("invalid JOB_ID: %s", args[0]) } - + enforceComplianceReq.JobId = &enforceComplianceJobIdArg } - response, err := w.PolicyComplianceForJobs.EnforceCompliance(ctx, enforceComplianceReq) + sdkReq, err := jobs.EnforcePolicyComplianceForJobToSDK(&enforceComplianceReq) + if err != nil { + return err + } + response, err := w.Jobs.EnforcePolicyComplianceForJob(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := jobs.EnforcePolicyComplianceResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -154,13 +166,12 @@ func newEnforceCompliance() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getComplianceOverrides []func( *cobra.Command, - *jobs.GetPolicyComplianceRequest, + *jobs.GetPolicyComplianceForJobRequest, ) func newGetCompliance() *cobra.Command { cmd := &cobra.Command{} - - var getComplianceReq jobs.GetPolicyComplianceRequest + var getComplianceReq jobs.GetPolicyComplianceForJobRequest cmd.Use = "get-compliance JOB_ID" cmd.Short = `Get job policy compliance.` @@ -186,18 +197,29 @@ func newGetCompliance() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - _, err = fmt.Sscan(args[0], &getComplianceReq.JobId) + var getComplianceJobIdArg int64 + _, err = fmt.Sscan(args[0], &getComplianceJobIdArg) if err != nil { return fmt.Errorf("invalid JOB_ID: %s", args[0]) } + getComplianceReq.JobId = &getComplianceJobIdArg - response, err := w.PolicyComplianceForJobs.GetCompliance(ctx, getComplianceReq) + sdkReq, err := jobs.GetPolicyComplianceForJobRequestToSDK(&getComplianceReq) + if err != nil { + return err + } + response, err := w.Jobs.GetPolicyComplianceForJob(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := jobs.GetPolicyComplianceForJobResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -218,25 +240,25 @@ func newGetCompliance() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listComplianceOverrides []func( *cobra.Command, - *jobs.ListJobComplianceRequest, + *jobs.ListJobComplianceForPolicy, ) func newListCompliance() *cobra.Command { cmd := &cobra.Command{} + var listComplianceReq jobs.ListJobComplianceForPolicy - var listComplianceReq jobs.ListJobComplianceRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listComplianceLimit int - cmd.Flags().IntVar(&listComplianceReq.PageSize, "page-size", listComplianceReq.PageSize, `Use this field to specify the maximum number of results to be returned by the server.`) + flags.IntPtrVar(cmd.Flags(), &listComplianceReq.PageSize, "page-size", `Use this field to specify the maximum number of results to be returned by the server.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listComplianceLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listComplianceReq.PageToken, "page-token", listComplianceReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listComplianceReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-compliance POLICY_ID" @@ -264,18 +286,22 @@ func newListCompliance() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listComplianceReq.PolicyId = args[0] + listComplianceReq.PolicyId = new(args[0]) - response := w.PolicyComplianceForJobs.ListCompliance(ctx, listComplianceReq) + sdkReq, err := jobs.ListJobComplianceForPolicyToSDK(&listComplianceReq) + if err != nil { + return err + } if listComplianceLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listComplianceLimit) } if listComplianceLimit > 0 { ctx = cmdio.WithLimit(ctx, listComplianceLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Jobs.ListJobComplianceForPolicyIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, jobs.ListJobComplianceForPolicy_JobComplianceFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/policy-families/policy-families.go b/cmd/workspace/policy-families/policy-families.go index d760aaf7db6..98f7d460428 100644 --- a/cmd/workspace/policy-families/policy-families.go +++ b/cmd/workspace/policy-families/policy-families.go @@ -7,9 +7,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/cli/libs/flags" "github.com/spf13/cobra" + + policyfamilies "github.com/databricks/cli/libs/sdktypes/policyfamilies/v2" ) // Slice with functions to override default command behavior. @@ -55,15 +58,14 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *compute.GetPolicyFamilyRequest, + *policyfamilies.GetPolicyFamilyRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq policyfamilies.GetPolicyFamilyRequest - var getReq compute.GetPolicyFamilyRequest - - cmd.Flags().Int64Var(&getReq.Version, "version", getReq.Version, `The version number for the family to fetch.`) + flags.Int64PtrVar(cmd.Flags(), &getReq.Version, "version", `The version number for the family to fetch.`) cmd.Use = "get POLICY_FAMILY_ID" cmd.Short = `Get policy family information.` @@ -88,15 +90,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.PolicyFamilyId = args[0] + getReq.PolicyFamilyId = new(args[0]) - response, err := w.PolicyFamilies.Get(ctx, getReq) + sdkReq, err := policyfamilies.GetPolicyFamilyRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.PolicyFamilies.GetPolicyFamily(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := policyfamilies.PolicyFamilyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -117,25 +128,25 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *compute.ListPolicyFamiliesRequest, + *policyfamilies.ListPolicyFamiliesRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq policyfamilies.ListPolicyFamiliesRequest - var listReq compute.ListPolicyFamiliesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().Int64Var(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of policy families to return.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of policy families to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -158,16 +169,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.PolicyFamilies.List(ctx, listReq) + sdkReq, err := policyfamilies.ListPolicyFamiliesRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.PolicyFamilies.ListPolicyFamiliesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, policyfamilies.PolicyFamilyFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/postgres/overrides.go b/cmd/workspace/postgres/overrides.go index abbde499eb8..19ec5a53107 100644 --- a/cmd/workspace/postgres/overrides.go +++ b/cmd/workspace/postgres/overrides.go @@ -5,14 +5,13 @@ import ( "fmt" "math" "regexp" - "slices" "strconv" "strings" "time" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/common/types/duration" - "github.com/databricks/databricks-sdk-go/service/postgres" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/sdk-go/core/types" "github.com/spf13/cobra" ) @@ -187,7 +186,7 @@ func reconcileBranchExpiration(spec *postgres.BranchSpec, ttlChanged bool, ttl s if spec == nil { spec = &postgres.BranchSpec{} } - spec.NoExpiry = true + spec.NoExpiry = new(true) case jsonHasExpiration: // Expiration comes from --json; leave spec for the generated RunE to merge. } @@ -196,18 +195,17 @@ func reconcileBranchExpiration(spec *postgres.BranchSpec, ttlChanged bool, ttl s // specHasExpiration reports whether a decoded BranchSpec sets an expiration: // spec.ttl, spec.expire_time, or spec.no_expiry. no_expiry present as false still -// counts as "set" (detected via ForceSendFields, which the SDK decode populates -// for explicit zero values), so combining it with --no-expiry is caught as a -// conflict instead of the json silently overriding the flag on the wire. +// counts as "set" (the pointer is non-nil for explicit values), so combining it +// with --no-expiry is caught as a conflict instead of the json silently +// overriding the flag on the wire. func specHasExpiration(s *postgres.BranchSpec) bool { - return s != nil && (s.Ttl != nil || s.ExpireTime != nil || s.NoExpiry || - slices.Contains(s.ForceSendFields, "NoExpiry")) + return s != nil && (s.Ttl != nil || s.ExpireTime != nil || s.NoExpiry != nil) } -// parseTTL parses the --ttl value into a *duration.Duration. It accepts the REST +// parseTTL parses the --ttl value into a *types.Duration. It accepts the REST // API's protobuf-duration form ("604800s"), Go-style durations ("168h"), and the -// day/week extension ("7d", "3w"); duration.New re-serializes to the API form. -func parseTTL(s string) (*duration.Duration, error) { +// day/week extension ("7d", "3w"); types.NewFromDuration re-serializes to the API form. +func parseTTL(s string) (*types.Duration, error) { if s == "" { return nil, errors.New("--ttl must not be empty; use e.g. 604800s, 168h, or 7d for 7 days") } @@ -218,7 +216,7 @@ func parseTTL(s string) (*duration.Duration, error) { if d <= 0 { return nil, fmt.Errorf("invalid --ttl %q: must be a positive duration", s) } - return duration.New(d), nil + return types.NewFromDuration(d), nil } // ttlComponent matches one leading "" component of a duration diff --git a/cmd/workspace/postgres/overrides_test.go b/cmd/workspace/postgres/overrides_test.go index 3154a20336a..9b7cae381eb 100644 --- a/cmd/workspace/postgres/overrides_test.go +++ b/cmd/workspace/postgres/overrides_test.go @@ -5,9 +5,9 @@ import ( "time" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/common/types/duration" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/service/postgres" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/types" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -84,7 +84,7 @@ func TestReconcileBranchExpiration(t *testing.T) { check: func(t *testing.T, spec *postgres.BranchSpec) { require.NotNil(t, spec.Ttl) assert.Equal(t, sevenDays, spec.Ttl.AsDuration()) - assert.False(t, spec.NoExpiry) + assert.Nil(t, spec.NoExpiry) }, }, { @@ -101,12 +101,12 @@ func TestReconcileBranchExpiration(t *testing.T) { noExpiryChanged: true, noExpiry: true, check: func(t *testing.T, spec *postgres.BranchSpec) { - assert.True(t, spec.NoExpiry) + assert.True(t, utils.Deref(spec.NoExpiry)) }, }, { name: "non-expiration spec field is not an expiration source", - spec: &postgres.BranchSpec{SourceBranch: "projects/p/branches/main"}, + spec: &postgres.BranchSpec{SourceBranch: new("projects/p/branches/main")}, wantErr: "a branch expiration is required", }, { @@ -211,12 +211,12 @@ func TestSpecHasExpiration(t *testing.T) { }{ {"nil spec", nil, false}, {"empty spec", &postgres.BranchSpec{}, false}, - {"ttl set", &postgres.BranchSpec{Ttl: duration.New(sevenDays)}, true}, - {"expire_time set", &postgres.BranchSpec{ExpireTime: sdktime.New(time.Now())}, true}, - {"no_expiry true", &postgres.BranchSpec{NoExpiry: true}, true}, - {"no_expiry false, unset", &postgres.BranchSpec{NoExpiry: false}, false}, - {"no_expiry false, explicitly set", &postgres.BranchSpec{NoExpiry: false, ForceSendFields: []string{"NoExpiry"}}, true}, - {"non-expiration field only", &postgres.BranchSpec{SourceBranch: "projects/p/branches/main"}, false}, + {"ttl set", &postgres.BranchSpec{Ttl: types.NewFromDuration(sevenDays)}, true}, + {"expire_time set", &postgres.BranchSpec{ExpireTime: types.NewFromTime(time.Now())}, true}, + {"no_expiry true", &postgres.BranchSpec{NoExpiry: new(true)}, true}, + {"no_expiry unset", &postgres.BranchSpec{}, false}, + {"no_expiry false, explicitly set", &postgres.BranchSpec{NoExpiry: new(false)}, true}, + {"non-expiration field only", &postgres.BranchSpec{SourceBranch: new("projects/p/branches/main")}, false}, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { diff --git a/cmd/workspace/postgres/postgres.go b/cmd/workspace/postgres/postgres.go index 24642a376f3..4ab259faa65 100644 --- a/cmd/workspace/postgres/postgres.go +++ b/cmd/workspace/postgres/postgres.go @@ -6,19 +6,21 @@ import ( "encoding/json" "errors" "fmt" - "strings" "time" + "strconv" + "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/common/types/duration" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/experimental/api" - "github.com/databricks/databricks-sdk-go/service/postgres" + sdkcoretypes "github.com/databricks/sdk-go/core/types" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + sdkpostgres "github.com/databricks/sdk-go/postgres/v1" ) // Slice with functions to override default command behavior. @@ -121,9 +123,9 @@ var createBranchOverrides []func( func newCreateBranch() *cobra.Command { cmd := &cobra.Command{} - var createBranchReq postgres.CreateBranchRequest - createBranchReq.Branch = postgres.Branch{} + createBranchReq.Branch = &postgres.Branch{} + var createBranchJson flags.JsonFlag var createBranchSkipWait bool @@ -134,8 +136,8 @@ func newCreateBranch() *cobra.Command { cmd.Flags().Var(&createBranchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createBranchReq.ReplaceExisting, "replace-existing", createBranchReq.ReplaceExisting, `If true, update the branch if it already exists instead of returning an error.`) - cmd.Flags().StringVar(&createBranchReq.Branch.Name, "name", createBranchReq.Branch.Name, `Output only.`) + flags.BoolPtrVar(cmd.Flags(), &createBranchReq.ReplaceExisting, "replace-existing", `If true, update the branch if it already exists instead of returning an error.`) + flags.StringPtrVar(cmd.Flags(), &createBranchReq.Branch.Name, "name", `Output only.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -172,6 +174,7 @@ func newCreateBranch() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createBranchJson.Unmarshal(&createBranchReq.Branch) @@ -185,28 +188,26 @@ func newCreateBranch() *cobra.Command { } } } - createBranchReq.Parent = args[0] - createBranchReq.BranchId = args[1] + createBranchReq.Parent = new(args[0]) + createBranchReq.BranchId = new(args[1]) + sdkReq, err := postgres.CreateBranchRequestToSDK(&createBranchReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case createBranchSkipWait: - wait, err := w.Postgres.CreateBranch(ctx, createBranchReq) + wait, err := w.Postgres.CreateBranch(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.CreateBranch(ctx, createBranchReq) + wait, err := w.Postgres.CreateBranch(ctx, *sdkReq) if err != nil { return err } @@ -216,13 +217,17 @@ func newCreateBranch() *cobra.Command { sp.Update("Waiting for create-branch to complete...") // Wait for completion. - opts := api.WithTimeout(createBranchTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(createBranchTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.BranchFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -249,9 +254,9 @@ var createCatalogOverrides []func( func newCreateCatalog() *cobra.Command { cmd := &cobra.Command{} - var createCatalogReq postgres.CreateCatalogRequest - createCatalogReq.Catalog = postgres.Catalog{} + createCatalogReq.Catalog = &postgres.Catalog{} + var createCatalogJson flags.JsonFlag var createCatalogSkipWait bool @@ -262,7 +267,7 @@ func newCreateCatalog() *cobra.Command { cmd.Flags().Var(&createCatalogJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createCatalogReq.Catalog.Name, "name", createCatalogReq.Catalog.Name, `Output only.`) + flags.StringPtrVar(cmd.Flags(), &createCatalogReq.Catalog.Name, "name", `Output only.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -294,6 +299,7 @@ func newCreateCatalog() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createCatalogJson.Unmarshal(&createCatalogReq.Catalog) @@ -307,27 +313,25 @@ func newCreateCatalog() *cobra.Command { } } } - createCatalogReq.CatalogId = args[0] + createCatalogReq.CatalogId = new(args[0]) + sdkReq, err := postgres.CreateCatalogRequestToSDK(&createCatalogReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case createCatalogSkipWait: - wait, err := w.Postgres.CreateCatalog(ctx, createCatalogReq) + wait, err := w.Postgres.CreateCatalog(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.CreateCatalog(ctx, createCatalogReq) + wait, err := w.Postgres.CreateCatalog(ctx, *sdkReq) if err != nil { return err } @@ -337,13 +341,17 @@ func newCreateCatalog() *cobra.Command { sp.Update("Waiting for create-catalog to complete...") // Wait for completion. - opts := api.WithTimeout(createCatalogTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(createCatalogTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.CatalogFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -370,9 +378,9 @@ var createCdfConfigOverrides []func( func newCreateCdfConfig() *cobra.Command { cmd := &cobra.Command{} - var createCdfConfigReq postgres.CreateCdfConfigRequest - createCdfConfigReq.CdfConfig = postgres.CdfConfig{} + createCdfConfigReq.CdfConfig = &postgres.CdfConfig{} + var createCdfConfigJson flags.JsonFlag var createCdfConfigSkipWait bool @@ -383,8 +391,8 @@ func newCreateCdfConfig() *cobra.Command { cmd.Flags().Var(&createCdfConfigJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createCdfConfigReq.CdfConfigId, "cdf-config-id", createCdfConfigReq.CdfConfigId, `The user-specified id for the CdfConfig, forming the final segment of its resource name.`) - cmd.Flags().StringVar(&createCdfConfigReq.CdfConfig.Name, "name", createCdfConfigReq.CdfConfig.Name, `Output only.`) + flags.StringPtrVar(cmd.Flags(), &createCdfConfigReq.CdfConfigId, "cdf-config-id", `The user-specified id for the CdfConfig, forming the final segment of its resource name.`) + flags.StringPtrVar(cmd.Flags(), &createCdfConfigReq.CdfConfig.Name, "name", `Output only.`) cmd.Use = "create-cdf-config PARENT CATALOG SCHEMA POSTGRES_SCHEMA" cmd.Short = `*Beta* Create a change data feed configuration.` @@ -432,6 +440,7 @@ Create a change data feed configuration. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createCdfConfigJson.Unmarshal(&createCdfConfigReq.CdfConfig) @@ -445,36 +454,34 @@ Create a change data feed configuration. } } } - createCdfConfigReq.Parent = args[0] + createCdfConfigReq.Parent = new(args[0]) if !cmd.Flags().Changed("json") { - createCdfConfigReq.CdfConfig.Catalog = args[1] + createCdfConfigReq.CdfConfig.Catalog = new(args[1]) } if !cmd.Flags().Changed("json") { - createCdfConfigReq.CdfConfig.Schema = args[2] + createCdfConfigReq.CdfConfig.Schema = new(args[2]) } if !cmd.Flags().Changed("json") { - createCdfConfigReq.CdfConfig.PostgresSchema = args[3] + createCdfConfigReq.CdfConfig.PostgresSchema = new(args[3]) } + sdkReq, err := postgres.CreateCdfConfigRequestToSDK(&createCdfConfigReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case createCdfConfigSkipWait: - wait, err := w.Postgres.CreateCdfConfig(ctx, createCdfConfigReq) + wait, err := w.Postgres.CreateCdfConfig(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.CreateCdfConfig(ctx, createCdfConfigReq) + wait, err := w.Postgres.CreateCdfConfig(ctx, *sdkReq) if err != nil { return err } @@ -484,13 +491,17 @@ Create a change data feed configuration. sp.Update("Waiting for create-cdf-config to complete...") // Wait for completion. - opts := api.WithTimeout(createCdfConfigTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(createCdfConfigTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.CdfConfigFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -517,9 +528,9 @@ var createDataApiOverrides []func( func newCreateDataApi() *cobra.Command { cmd := &cobra.Command{} - var createDataApiReq postgres.CreateDataApiRequest - createDataApiReq.DataApi = postgres.DataApi{} + createDataApiReq.DataApi = &postgres.DataApi{} + var createDataApiJson flags.JsonFlag var createDataApiSkipWait bool @@ -530,7 +541,7 @@ func newCreateDataApi() *cobra.Command { cmd.Flags().Var(&createDataApiJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createDataApiReq.DataApi.Name, "name", createDataApiReq.DataApi.Name, `Resource name: projects/{project_id}/branches/{branch_id}/databases/{database_id}/data-api.`) + flags.StringPtrVar(cmd.Flags(), &createDataApiReq.DataApi.Name, "name", `Resource name: projects/{project_id}/branches/{branch_id}/databases/{database_id}/data-api.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -563,6 +574,7 @@ func newCreateDataApi() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createDataApiJson.Unmarshal(&createDataApiReq.DataApi) @@ -576,27 +588,25 @@ func newCreateDataApi() *cobra.Command { } } } - createDataApiReq.Parent = args[0] + createDataApiReq.Parent = new(args[0]) + sdkReq, err := postgres.CreateDataApiRequestToSDK(&createDataApiReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case createDataApiSkipWait: - wait, err := w.Postgres.CreateDataApi(ctx, createDataApiReq) + wait, err := w.Postgres.CreateDataApi(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.CreateDataApi(ctx, createDataApiReq) + wait, err := w.Postgres.CreateDataApi(ctx, *sdkReq) if err != nil { return err } @@ -606,13 +616,17 @@ func newCreateDataApi() *cobra.Command { sp.Update("Waiting for create-data-api to complete...") // Wait for completion. - opts := api.WithTimeout(createDataApiTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(createDataApiTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.DataApiFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -639,9 +653,9 @@ var createDatabaseOverrides []func( func newCreateDatabase() *cobra.Command { cmd := &cobra.Command{} - var createDatabaseReq postgres.CreateDatabaseRequest - createDatabaseReq.Database = postgres.Database{} + createDatabaseReq.Database = &postgres.Database{} + var createDatabaseJson flags.JsonFlag var createDatabaseSkipWait bool @@ -652,9 +666,9 @@ func newCreateDatabase() *cobra.Command { cmd.Flags().Var(&createDatabaseJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createDatabaseReq.DatabaseId, "database-id", createDatabaseReq.DatabaseId, `The ID to use for the Database, which will become the final component of the database's resource name.`) - cmd.Flags().BoolVar(&createDatabaseReq.ReplaceExisting, "replace-existing", createDatabaseReq.ReplaceExisting, `If true, update the database if it already exists instead of returning an error.`) - cmd.Flags().StringVar(&createDatabaseReq.Database.Name, "name", createDatabaseReq.Database.Name, `The resource name of the database.`) + flags.StringPtrVar(cmd.Flags(), &createDatabaseReq.DatabaseId, "database-id", `The ID to use for the Database, which will become the final component of the database's resource name.`) + flags.BoolPtrVar(cmd.Flags(), &createDatabaseReq.ReplaceExisting, "replace-existing", `If true, update the database if it already exists instead of returning an error.`) + flags.StringPtrVar(cmd.Flags(), &createDatabaseReq.Database.Name, "name", `The resource name of the database.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -689,6 +703,7 @@ func newCreateDatabase() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createDatabaseJson.Unmarshal(&createDatabaseReq.Database) @@ -702,27 +717,25 @@ func newCreateDatabase() *cobra.Command { } } } - createDatabaseReq.Parent = args[0] + createDatabaseReq.Parent = new(args[0]) + sdkReq, err := postgres.CreateDatabaseRequestToSDK(&createDatabaseReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case createDatabaseSkipWait: - wait, err := w.Postgres.CreateDatabase(ctx, createDatabaseReq) + wait, err := w.Postgres.CreateDatabase(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.CreateDatabase(ctx, createDatabaseReq) + wait, err := w.Postgres.CreateDatabase(ctx, *sdkReq) if err != nil { return err } @@ -732,13 +745,17 @@ func newCreateDatabase() *cobra.Command { sp.Update("Waiting for create-database to complete...") // Wait for completion. - opts := api.WithTimeout(createDatabaseTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(createDatabaseTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.DatabaseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -765,9 +782,9 @@ var createEndpointOverrides []func( func newCreateEndpoint() *cobra.Command { cmd := &cobra.Command{} - var createEndpointReq postgres.CreateEndpointRequest - createEndpointReq.Endpoint = postgres.Endpoint{} + createEndpointReq.Endpoint = &postgres.Endpoint{} + var createEndpointJson flags.JsonFlag var createEndpointSkipWait bool @@ -778,8 +795,8 @@ func newCreateEndpoint() *cobra.Command { cmd.Flags().Var(&createEndpointJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createEndpointReq.ReplaceExisting, "replace-existing", createEndpointReq.ReplaceExisting, `If true, update the endpoint if it already exists instead of returning an error.`) - cmd.Flags().StringVar(&createEndpointReq.Endpoint.Name, "name", createEndpointReq.Endpoint.Name, `Output only.`) + flags.BoolPtrVar(cmd.Flags(), &createEndpointReq.ReplaceExisting, "replace-existing", `If true, update the endpoint if it already exists instead of returning an error.`) + flags.StringPtrVar(cmd.Flags(), &createEndpointReq.Endpoint.Name, "name", `Output only.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -816,6 +833,7 @@ func newCreateEndpoint() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createEndpointJson.Unmarshal(&createEndpointReq.Endpoint) @@ -829,28 +847,26 @@ func newCreateEndpoint() *cobra.Command { } } } - createEndpointReq.Parent = args[0] - createEndpointReq.EndpointId = args[1] + createEndpointReq.Parent = new(args[0]) + createEndpointReq.EndpointId = new(args[1]) + sdkReq, err := postgres.CreateEndpointRequestToSDK(&createEndpointReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case createEndpointSkipWait: - wait, err := w.Postgres.CreateEndpoint(ctx, createEndpointReq) + wait, err := w.Postgres.CreateEndpoint(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.CreateEndpoint(ctx, createEndpointReq) + wait, err := w.Postgres.CreateEndpoint(ctx, *sdkReq) if err != nil { return err } @@ -860,13 +876,17 @@ func newCreateEndpoint() *cobra.Command { sp.Update("Waiting for create-endpoint to complete...") // Wait for completion. - opts := api.WithTimeout(createEndpointTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(createEndpointTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.EndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -893,9 +913,9 @@ var createProjectOverrides []func( func newCreateProject() *cobra.Command { cmd := &cobra.Command{} - var createProjectReq postgres.CreateProjectRequest - createProjectReq.Project = postgres.Project{} + createProjectReq.Project = &postgres.Project{} + var createProjectJson flags.JsonFlag var createProjectSkipWait bool @@ -908,7 +928,7 @@ func newCreateProject() *cobra.Command { // TODO: complex arg: initial_branch_spec // TODO: complex arg: initial_endpoint_spec - cmd.Flags().StringVar(&createProjectReq.Project.Name, "name", createProjectReq.Project.Name, `Output only.`) + flags.StringPtrVar(cmd.Flags(), &createProjectReq.Project.Name, "name", `Output only.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -943,6 +963,7 @@ func newCreateProject() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createProjectJson.Unmarshal(&createProjectReq.Project) @@ -956,27 +977,25 @@ func newCreateProject() *cobra.Command { } } } - createProjectReq.ProjectId = args[0] + createProjectReq.ProjectId = new(args[0]) + sdkReq, err := postgres.CreateProjectRequestToSDK(&createProjectReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case createProjectSkipWait: - wait, err := w.Postgres.CreateProject(ctx, createProjectReq) + wait, err := w.Postgres.CreateProject(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.CreateProject(ctx, createProjectReq) + wait, err := w.Postgres.CreateProject(ctx, *sdkReq) if err != nil { return err } @@ -986,13 +1005,17 @@ func newCreateProject() *cobra.Command { sp.Update("Waiting for create-project to complete...") // Wait for completion. - opts := api.WithTimeout(createProjectTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(createProjectTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.ProjectFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -1019,9 +1042,9 @@ var createRoleOverrides []func( func newCreateRole() *cobra.Command { cmd := &cobra.Command{} - var createRoleReq postgres.CreateRoleRequest - createRoleReq.Role = postgres.Role{} + createRoleReq.Role = &postgres.Role{} + var createRoleJson flags.JsonFlag var createRoleSkipWait bool @@ -1032,9 +1055,9 @@ func newCreateRole() *cobra.Command { cmd.Flags().Var(&createRoleJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createRoleReq.ReplaceExisting, "replace-existing", createRoleReq.ReplaceExisting, `If true, update the role if it already exists instead of returning an error.`) - cmd.Flags().StringVar(&createRoleReq.RoleId, "role-id", createRoleReq.RoleId, `The ID to use for the Role, which will become the final component of the role's resource name.`) - cmd.Flags().StringVar(&createRoleReq.Role.Name, "name", createRoleReq.Role.Name, `Output only.`) + flags.BoolPtrVar(cmd.Flags(), &createRoleReq.ReplaceExisting, "replace-existing", `If true, update the role if it already exists instead of returning an error.`) + flags.StringPtrVar(cmd.Flags(), &createRoleReq.RoleId, "role-id", `The ID to use for the Role, which will become the final component of the role's resource name.`) + flags.StringPtrVar(cmd.Flags(), &createRoleReq.Role.Name, "name", `Output only.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -1066,6 +1089,7 @@ func newCreateRole() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createRoleJson.Unmarshal(&createRoleReq.Role) @@ -1079,27 +1103,25 @@ func newCreateRole() *cobra.Command { } } } - createRoleReq.Parent = args[0] + createRoleReq.Parent = new(args[0]) + sdkReq, err := postgres.CreateRoleRequestToSDK(&createRoleReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case createRoleSkipWait: - wait, err := w.Postgres.CreateRole(ctx, createRoleReq) + wait, err := w.Postgres.CreateRole(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.CreateRole(ctx, createRoleReq) + wait, err := w.Postgres.CreateRole(ctx, *sdkReq) if err != nil { return err } @@ -1109,13 +1131,17 @@ func newCreateRole() *cobra.Command { sp.Update("Waiting for create-role to complete...") // Wait for completion. - opts := api.WithTimeout(createRoleTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(createRoleTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.RoleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -1142,9 +1168,9 @@ var createSnapshotOverrides []func( func newCreateSnapshot() *cobra.Command { cmd := &cobra.Command{} - var createSnapshotReq postgres.CreateSnapshotRequest - createSnapshotReq.Snapshot = postgres.Snapshot{} + createSnapshotReq.Snapshot = &postgres.Snapshot{} + var createSnapshotJson flags.JsonFlag var createSnapshotSkipWait bool @@ -1155,7 +1181,7 @@ func newCreateSnapshot() *cobra.Command { cmd.Flags().Var(&createSnapshotJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createSnapshotReq.Snapshot.Name, "name", createSnapshotReq.Snapshot.Name, `The resource name of the snapshot.`) + flags.StringPtrVar(cmd.Flags(), &createSnapshotReq.Snapshot.Name, "name", `The resource name of the snapshot.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -1191,6 +1217,7 @@ Create a Snapshot. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createSnapshotJson.Unmarshal(&createSnapshotReq.Snapshot) @@ -1204,28 +1231,26 @@ Create a Snapshot. } } } - createSnapshotReq.Parent = args[0] - createSnapshotReq.SnapshotId = args[1] + createSnapshotReq.Parent = new(args[0]) + createSnapshotReq.SnapshotId = new(args[1]) + sdkReq, err := postgres.CreateSnapshotRequestToSDK(&createSnapshotReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case createSnapshotSkipWait: - wait, err := w.Postgres.CreateSnapshot(ctx, createSnapshotReq) + wait, err := w.Postgres.CreateSnapshot(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.CreateSnapshot(ctx, createSnapshotReq) + wait, err := w.Postgres.CreateSnapshot(ctx, *sdkReq) if err != nil { return err } @@ -1235,13 +1260,17 @@ Create a Snapshot. sp.Update("Waiting for create-snapshot to complete...") // Wait for completion. - opts := api.WithTimeout(createSnapshotTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(createSnapshotTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.SnapshotFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -1268,9 +1297,9 @@ var createSyncedTableOverrides []func( func newCreateSyncedTable() *cobra.Command { cmd := &cobra.Command{} - var createSyncedTableReq postgres.CreateSyncedTableRequest - createSyncedTableReq.SyncedTable = postgres.SyncedTable{} + createSyncedTableReq.SyncedTable = &postgres.SyncedTable{} + var createSyncedTableJson flags.JsonFlag var createSyncedTableSkipWait bool @@ -1281,7 +1310,7 @@ func newCreateSyncedTable() *cobra.Command { cmd.Flags().Var(&createSyncedTableJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createSyncedTableReq.SyncedTable.Name, "name", createSyncedTableReq.SyncedTable.Name, `Output only.`) + flags.StringPtrVar(cmd.Flags(), &createSyncedTableReq.SyncedTable.Name, "name", `Output only.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -1323,6 +1352,7 @@ func newCreateSyncedTable() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createSyncedTableJson.Unmarshal(&createSyncedTableReq.SyncedTable) @@ -1336,27 +1366,25 @@ func newCreateSyncedTable() *cobra.Command { } } } - createSyncedTableReq.SyncedTableId = args[0] + createSyncedTableReq.SyncedTableId = new(args[0]) + sdkReq, err := postgres.CreateSyncedTableRequestToSDK(&createSyncedTableReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case createSyncedTableSkipWait: - wait, err := w.Postgres.CreateSyncedTable(ctx, createSyncedTableReq) + wait, err := w.Postgres.CreateSyncedTable(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.CreateSyncedTable(ctx, createSyncedTableReq) + wait, err := w.Postgres.CreateSyncedTable(ctx, *sdkReq) if err != nil { return err } @@ -1366,13 +1394,17 @@ func newCreateSyncedTable() *cobra.Command { sp.Update("Waiting for create-synced-table to complete...") // Wait for completion. - opts := api.WithTimeout(createSyncedTableTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(createSyncedTableTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.SyncedTableFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -1399,7 +1431,6 @@ var deleteBranchOverrides []func( func newDeleteBranch() *cobra.Command { cmd := &cobra.Command{} - var deleteBranchReq postgres.DeleteBranchRequest var deleteBranchSkipWait bool @@ -1408,7 +1439,7 @@ func newDeleteBranch() *cobra.Command { cmd.Flags().BoolVar(&deleteBranchSkipWait, "no-wait", deleteBranchSkipWait, `do not wait to reach DONE state`) cmd.Flags().DurationVar(&deleteBranchTimeout, "timeout", 0, `maximum amount of time to reach DONE state`) - cmd.Flags().BoolVar(&deleteBranchReq.Purge, "purge", deleteBranchReq.Purge, `If true, permanently delete the branch; if false, soft delete.`) + flags.BoolPtrVar(cmd.Flags(), &deleteBranchReq.Purge, "purge", `If true, permanently delete the branch; if false, soft delete.`) cmd.Use = "delete-branch NAME" cmd.Short = `Delete a Branch.` @@ -1438,28 +1469,27 @@ func newDeleteBranch() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteBranchReq.Name = args[0] + deleteBranchReq.Name = new(args[0]) + sdkReq, err := postgres.DeleteBranchRequestToSDK(&deleteBranchReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case deleteBranchSkipWait: - wait, err := w.Postgres.DeleteBranch(ctx, deleteBranchReq) + wait, err := w.Postgres.DeleteBranch(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.DeleteBranch(ctx, deleteBranchReq) + wait, err := w.Postgres.DeleteBranch(ctx, *sdkReq) if err != nil { return err } @@ -1469,13 +1499,14 @@ func newDeleteBranch() *cobra.Command { sp.Update("Waiting for delete-branch to complete...") // Wait for completion. - opts := api.WithTimeout(deleteBranchTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(deleteBranchTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -1498,13 +1529,12 @@ func newDeleteBranch() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteCatalogOverrides []func( *cobra.Command, - *postgres.DeleteCatalogRequest, + *sdkpostgres.DeleteCatalogRequest, ) func newDeleteCatalog() *cobra.Command { cmd := &cobra.Command{} - - var deleteCatalogReq postgres.DeleteCatalogRequest + var deleteCatalogReq sdkpostgres.DeleteCatalogRequest var deleteCatalogSkipWait bool var deleteCatalogTimeout time.Duration @@ -1539,28 +1569,24 @@ func newDeleteCatalog() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteCatalogReq.Name = args[0] + deleteCatalogReq.Name = new(args[0]) + sdkReq := &deleteCatalogReq // Determine which mode to execute based on flags. switch { case deleteCatalogSkipWait: - wait, err := w.Postgres.DeleteCatalog(ctx, deleteCatalogReq) + wait, err := w.Postgres.DeleteCatalog(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.DeleteCatalog(ctx, deleteCatalogReq) + wait, err := w.Postgres.DeleteCatalog(ctx, *sdkReq) if err != nil { return err } @@ -1570,13 +1596,14 @@ func newDeleteCatalog() *cobra.Command { sp.Update("Waiting for delete-catalog to complete...") // Wait for completion. - opts := api.WithTimeout(deleteCatalogTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(deleteCatalogTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -1604,7 +1631,6 @@ var deleteCdfConfigOverrides []func( func newDeleteCdfConfig() *cobra.Command { cmd := &cobra.Command{} - var deleteCdfConfigReq postgres.DeleteCdfConfigRequest var deleteCdfConfigSkipWait bool @@ -1613,7 +1639,7 @@ func newDeleteCdfConfig() *cobra.Command { cmd.Flags().BoolVar(&deleteCdfConfigSkipWait, "no-wait", deleteCdfConfigSkipWait, `do not wait to reach DONE state`) cmd.Flags().DurationVar(&deleteCdfConfigTimeout, "timeout", 0, `maximum amount of time to reach DONE state`) - cmd.Flags().BoolVar(&deleteCdfConfigReq.Force, "force", deleteCdfConfigReq.Force, `When true, also drops the replicated Delta tables in Unity Catalog.`) + flags.BoolPtrVar(cmd.Flags(), &deleteCdfConfigReq.Force, "force", `When true, also drops the replicated Delta tables in Unity Catalog.`) cmd.Use = "delete-cdf-config NAME" cmd.Short = `*Beta* Delete a change data feed configuration.` @@ -1647,28 +1673,27 @@ Delete a change data feed configuration. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteCdfConfigReq.Name = args[0] + deleteCdfConfigReq.Name = new(args[0]) + sdkReq, err := postgres.DeleteCdfConfigRequestToSDK(&deleteCdfConfigReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case deleteCdfConfigSkipWait: - wait, err := w.Postgres.DeleteCdfConfig(ctx, deleteCdfConfigReq) + wait, err := w.Postgres.DeleteCdfConfig(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.DeleteCdfConfig(ctx, deleteCdfConfigReq) + wait, err := w.Postgres.DeleteCdfConfig(ctx, *sdkReq) if err != nil { return err } @@ -1678,13 +1703,14 @@ Delete a change data feed configuration. sp.Update("Waiting for delete-cdf-config to complete...") // Wait for completion. - opts := api.WithTimeout(deleteCdfConfigTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(deleteCdfConfigTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -1707,13 +1733,12 @@ Delete a change data feed configuration. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteDataApiOverrides []func( *cobra.Command, - *postgres.DeleteDataApiRequest, + *sdkpostgres.DeleteDataApiRequest, ) func newDeleteDataApi() *cobra.Command { cmd := &cobra.Command{} - - var deleteDataApiReq postgres.DeleteDataApiRequest + var deleteDataApiReq sdkpostgres.DeleteDataApiRequest var deleteDataApiSkipWait bool var deleteDataApiTimeout time.Duration @@ -1750,28 +1775,24 @@ func newDeleteDataApi() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteDataApiReq.Name = args[0] + deleteDataApiReq.Name = new(args[0]) + sdkReq := &deleteDataApiReq // Determine which mode to execute based on flags. switch { case deleteDataApiSkipWait: - wait, err := w.Postgres.DeleteDataApi(ctx, deleteDataApiReq) + wait, err := w.Postgres.DeleteDataApi(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.DeleteDataApi(ctx, deleteDataApiReq) + wait, err := w.Postgres.DeleteDataApi(ctx, *sdkReq) if err != nil { return err } @@ -1781,13 +1802,14 @@ func newDeleteDataApi() *cobra.Command { sp.Update("Waiting for delete-data-api to complete...") // Wait for completion. - opts := api.WithTimeout(deleteDataApiTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(deleteDataApiTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -1810,13 +1832,12 @@ func newDeleteDataApi() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteDatabaseOverrides []func( *cobra.Command, - *postgres.DeleteDatabaseRequest, + *sdkpostgres.DeleteDatabaseRequest, ) func newDeleteDatabase() *cobra.Command { cmd := &cobra.Command{} - - var deleteDatabaseReq postgres.DeleteDatabaseRequest + var deleteDatabaseReq sdkpostgres.DeleteDatabaseRequest var deleteDatabaseSkipWait bool var deleteDatabaseTimeout time.Duration @@ -1850,28 +1871,24 @@ func newDeleteDatabase() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteDatabaseReq.Name = args[0] + deleteDatabaseReq.Name = new(args[0]) + sdkReq := &deleteDatabaseReq // Determine which mode to execute based on flags. switch { case deleteDatabaseSkipWait: - wait, err := w.Postgres.DeleteDatabase(ctx, deleteDatabaseReq) + wait, err := w.Postgres.DeleteDatabase(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.DeleteDatabase(ctx, deleteDatabaseReq) + wait, err := w.Postgres.DeleteDatabase(ctx, *sdkReq) if err != nil { return err } @@ -1881,13 +1898,14 @@ func newDeleteDatabase() *cobra.Command { sp.Update("Waiting for delete-database to complete...") // Wait for completion. - opts := api.WithTimeout(deleteDatabaseTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(deleteDatabaseTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -1910,13 +1928,12 @@ func newDeleteDatabase() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteEndpointOverrides []func( *cobra.Command, - *postgres.DeleteEndpointRequest, + *sdkpostgres.DeleteEndpointRequest, ) func newDeleteEndpoint() *cobra.Command { cmd := &cobra.Command{} - - var deleteEndpointReq postgres.DeleteEndpointRequest + var deleteEndpointReq sdkpostgres.DeleteEndpointRequest var deleteEndpointSkipWait bool var deleteEndpointTimeout time.Duration @@ -1952,28 +1969,24 @@ func newDeleteEndpoint() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteEndpointReq.Name = args[0] + deleteEndpointReq.Name = new(args[0]) + sdkReq := &deleteEndpointReq // Determine which mode to execute based on flags. switch { case deleteEndpointSkipWait: - wait, err := w.Postgres.DeleteEndpoint(ctx, deleteEndpointReq) + wait, err := w.Postgres.DeleteEndpoint(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.DeleteEndpoint(ctx, deleteEndpointReq) + wait, err := w.Postgres.DeleteEndpoint(ctx, *sdkReq) if err != nil { return err } @@ -1983,13 +1996,14 @@ func newDeleteEndpoint() *cobra.Command { sp.Update("Waiting for delete-endpoint to complete...") // Wait for completion. - opts := api.WithTimeout(deleteEndpointTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(deleteEndpointTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -2017,7 +2031,6 @@ var deleteProjectOverrides []func( func newDeleteProject() *cobra.Command { cmd := &cobra.Command{} - var deleteProjectReq postgres.DeleteProjectRequest var deleteProjectSkipWait bool @@ -2026,7 +2039,7 @@ func newDeleteProject() *cobra.Command { cmd.Flags().BoolVar(&deleteProjectSkipWait, "no-wait", deleteProjectSkipWait, `do not wait to reach DONE state`) cmd.Flags().DurationVar(&deleteProjectTimeout, "timeout", 0, `maximum amount of time to reach DONE state`) - cmd.Flags().BoolVar(&deleteProjectReq.Purge, "purge", deleteProjectReq.Purge, `If true, permanently deletes the project (hard delete).`) + flags.BoolPtrVar(cmd.Flags(), &deleteProjectReq.Purge, "purge", `If true, permanently deletes the project (hard delete).`) cmd.Use = "delete-project NAME" cmd.Short = `Delete a Project.` @@ -2056,28 +2069,27 @@ func newDeleteProject() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteProjectReq.Name = args[0] + deleteProjectReq.Name = new(args[0]) + sdkReq, err := postgres.DeleteProjectRequestToSDK(&deleteProjectReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case deleteProjectSkipWait: - wait, err := w.Postgres.DeleteProject(ctx, deleteProjectReq) + wait, err := w.Postgres.DeleteProject(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.DeleteProject(ctx, deleteProjectReq) + wait, err := w.Postgres.DeleteProject(ctx, *sdkReq) if err != nil { return err } @@ -2087,13 +2099,14 @@ func newDeleteProject() *cobra.Command { sp.Update("Waiting for delete-project to complete...") // Wait for completion. - opts := api.WithTimeout(deleteProjectTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(deleteProjectTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -2121,7 +2134,6 @@ var deleteRoleOverrides []func( func newDeleteRole() *cobra.Command { cmd := &cobra.Command{} - var deleteRoleReq postgres.DeleteRoleRequest var deleteRoleSkipWait bool @@ -2130,7 +2142,7 @@ func newDeleteRole() *cobra.Command { cmd.Flags().BoolVar(&deleteRoleSkipWait, "no-wait", deleteRoleSkipWait, `do not wait to reach DONE state`) cmd.Flags().DurationVar(&deleteRoleTimeout, "timeout", 0, `maximum amount of time to reach DONE state`) - cmd.Flags().StringVar(&deleteRoleReq.ReassignOwnedTo, "reassign-owned-to", deleteRoleReq.ReassignOwnedTo, `Reassign objects.`) + flags.StringPtrVar(cmd.Flags(), &deleteRoleReq.ReassignOwnedTo, "reassign-owned-to", `Reassign objects.`) cmd.Use = "delete-role NAME" cmd.Short = `Delete a Postgres Role from a Branch.` @@ -2160,28 +2172,27 @@ func newDeleteRole() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteRoleReq.Name = args[0] + deleteRoleReq.Name = new(args[0]) + sdkReq, err := postgres.DeleteRoleRequestToSDK(&deleteRoleReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case deleteRoleSkipWait: - wait, err := w.Postgres.DeleteRole(ctx, deleteRoleReq) + wait, err := w.Postgres.DeleteRole(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.DeleteRole(ctx, deleteRoleReq) + wait, err := w.Postgres.DeleteRole(ctx, *sdkReq) if err != nil { return err } @@ -2191,13 +2202,14 @@ func newDeleteRole() *cobra.Command { sp.Update("Waiting for delete-role to complete...") // Wait for completion. - opts := api.WithTimeout(deleteRoleTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(deleteRoleTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -2220,13 +2232,12 @@ func newDeleteRole() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteSnapshotOverrides []func( *cobra.Command, - *postgres.DeleteSnapshotRequest, + *sdkpostgres.DeleteSnapshotRequest, ) func newDeleteSnapshot() *cobra.Command { cmd := &cobra.Command{} - - var deleteSnapshotReq postgres.DeleteSnapshotRequest + var deleteSnapshotReq sdkpostgres.DeleteSnapshotRequest var deleteSnapshotSkipWait bool var deleteSnapshotTimeout time.Duration @@ -2264,28 +2275,24 @@ Delete a Snapshot. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteSnapshotReq.Name = args[0] + deleteSnapshotReq.Name = new(args[0]) + sdkReq := &deleteSnapshotReq // Determine which mode to execute based on flags. switch { case deleteSnapshotSkipWait: - wait, err := w.Postgres.DeleteSnapshot(ctx, deleteSnapshotReq) + wait, err := w.Postgres.DeleteSnapshot(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.DeleteSnapshot(ctx, deleteSnapshotReq) + wait, err := w.Postgres.DeleteSnapshot(ctx, *sdkReq) if err != nil { return err } @@ -2295,13 +2302,14 @@ Delete a Snapshot. sp.Update("Waiting for delete-snapshot to complete...") // Wait for completion. - opts := api.WithTimeout(deleteSnapshotTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(deleteSnapshotTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -2324,13 +2332,12 @@ Delete a Snapshot. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteSyncedTableOverrides []func( *cobra.Command, - *postgres.DeleteSyncedTableRequest, + *sdkpostgres.DeleteSyncedTableRequest, ) func newDeleteSyncedTable() *cobra.Command { cmd := &cobra.Command{} - - var deleteSyncedTableReq postgres.DeleteSyncedTableRequest + var deleteSyncedTableReq sdkpostgres.DeleteSyncedTableRequest var deleteSyncedTableSkipWait bool var deleteSyncedTableTimeout time.Duration @@ -2367,28 +2374,24 @@ func newDeleteSyncedTable() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteSyncedTableReq.Name = args[0] + deleteSyncedTableReq.Name = new(args[0]) + sdkReq := &deleteSyncedTableReq // Determine which mode to execute based on flags. switch { case deleteSyncedTableSkipWait: - wait, err := w.Postgres.DeleteSyncedTable(ctx, deleteSyncedTableReq) + wait, err := w.Postgres.DeleteSyncedTable(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.DeleteSyncedTable(ctx, deleteSyncedTableReq) + wait, err := w.Postgres.DeleteSyncedTable(ctx, *sdkReq) if err != nil { return err } @@ -2398,13 +2401,14 @@ func newDeleteSyncedTable() *cobra.Command { sp.Update("Waiting for delete-synced-table to complete...") // Wait for completion. - opts := api.WithTimeout(deleteSyncedTableTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(deleteSyncedTableTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -2432,8 +2436,8 @@ var generateDatabaseCredentialOverrides []func( func newGenerateDatabaseCredential() *cobra.Command { cmd := &cobra.Command{} - var generateDatabaseCredentialReq postgres.GenerateDatabaseCredentialRequest + var generateDatabaseCredentialJson flags.JsonFlag cmd.Flags().Var(&generateDatabaseCredentialJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2472,6 +2476,7 @@ func newGenerateDatabaseCredential() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := generateDatabaseCredentialJson.Unmarshal(&generateDatabaseCredentialReq) @@ -2486,13 +2491,12 @@ func newGenerateDatabaseCredential() *cobra.Command { } } if !cmd.Flags().Changed("json") { - generateDatabaseCredentialReq.Endpoint = args[0] + generateDatabaseCredentialReq.Endpoint = new(args[0]) } if expireTimeParam != "" { - expireTimeBytes := []byte(fmt.Sprintf("\"%s\"", expireTimeParam)) - var expireTimeField sdktime.Time - err = json.Unmarshal(expireTimeBytes, &expireTimeField) + var expireTimeField sdkcoretypes.Time + err = json.Unmarshal([]byte(strconv.Quote(expireTimeParam)), &expireTimeField) if err != nil { return fmt.Errorf("invalid EXPIRE_TIME: %s", expireTimeParam) } @@ -2500,21 +2504,28 @@ func newGenerateDatabaseCredential() *cobra.Command { } if ttlParam != "" { - ttlBytes := []byte(fmt.Sprintf("\"%s\"", ttlParam)) - var ttlField duration.Duration - err = json.Unmarshal(ttlBytes, &ttlField) + var ttlField sdkcoretypes.Duration + err = json.Unmarshal([]byte(strconv.Quote(ttlParam)), &ttlField) if err != nil { return fmt.Errorf("invalid TTL: %s", ttlParam) } generateDatabaseCredentialReq.Ttl = &ttlField } - response, err := w.Postgres.GenerateDatabaseCredential(ctx, generateDatabaseCredentialReq) + sdkReq, err := postgres.GenerateDatabaseCredentialRequestToSDK(&generateDatabaseCredentialReq) + if err != nil { + return err + } + response, err := w.Postgres.GenerateDatabaseCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.DatabaseCredentialFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2535,13 +2546,12 @@ func newGenerateDatabaseCredential() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getBranchOverrides []func( *cobra.Command, - *postgres.GetBranchRequest, + *sdkpostgres.GetBranchRequest, ) func newGetBranch() *cobra.Command { cmd := &cobra.Command{} - - var getBranchReq postgres.GetBranchRequest + var getBranchReq sdkpostgres.GetBranchRequest cmd.Use = "get-branch NAME" cmd.Short = `Get a Branch.` @@ -2566,15 +2576,21 @@ func newGetBranch() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getBranchReq.Name = args[0] + getBranchReq.Name = new(args[0]) - response, err := w.Postgres.GetBranch(ctx, getBranchReq) + sdkReq := &getBranchReq + response, err := w.Postgres.GetBranch(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.BranchFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2595,13 +2611,12 @@ func newGetBranch() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getCatalogOverrides []func( *cobra.Command, - *postgres.GetCatalogRequest, + *sdkpostgres.GetCatalogRequest, ) func newGetCatalog() *cobra.Command { cmd := &cobra.Command{} - - var getCatalogReq postgres.GetCatalogRequest + var getCatalogReq sdkpostgres.GetCatalogRequest cmd.Use = "get-catalog NAME" cmd.Short = `Get a Database Catalog.` @@ -2625,15 +2640,21 @@ func newGetCatalog() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getCatalogReq.Name = args[0] + getCatalogReq.Name = new(args[0]) - response, err := w.Postgres.GetCatalog(ctx, getCatalogReq) + sdkReq := &getCatalogReq + response, err := w.Postgres.GetCatalog(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.CatalogFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2654,13 +2675,12 @@ func newGetCatalog() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getCdfConfigOverrides []func( *cobra.Command, - *postgres.GetCdfConfigRequest, + *sdkpostgres.GetCdfConfigRequest, ) func newGetCdfConfig() *cobra.Command { cmd := &cobra.Command{} - - var getCdfConfigReq postgres.GetCdfConfigRequest + var getCdfConfigReq sdkpostgres.GetCdfConfigRequest cmd.Use = "get-cdf-config NAME" cmd.Short = `*Beta* Get a change data feed configuration.` @@ -2688,15 +2708,21 @@ Get a change data feed configuration. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getCdfConfigReq.Name = args[0] + getCdfConfigReq.Name = new(args[0]) - response, err := w.Postgres.GetCdfConfig(ctx, getCdfConfigReq) + sdkReq := &getCdfConfigReq + response, err := w.Postgres.GetCdfConfig(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.CdfConfigFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2717,13 +2743,12 @@ Get a change data feed configuration. // Functions can be added from the `init()` function in manually curated files in this directory. var getCdfStatusOverrides []func( *cobra.Command, - *postgres.GetCdfStatusRequest, + *sdkpostgres.GetCdfStatusRequest, ) func newGetCdfStatus() *cobra.Command { cmd := &cobra.Command{} - - var getCdfStatusReq postgres.GetCdfStatusRequest + var getCdfStatusReq sdkpostgres.GetCdfStatusRequest cmd.Use = "get-cdf-status NAME" cmd.Short = `*Beta* Get a change data feed status.` @@ -2751,15 +2776,21 @@ Get a change data feed status. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getCdfStatusReq.Name = args[0] + getCdfStatusReq.Name = new(args[0]) - response, err := w.Postgres.GetCdfStatus(ctx, getCdfStatusReq) + sdkReq := &getCdfStatusReq + response, err := w.Postgres.GetCdfStatus(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.CdfStatusFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2780,13 +2811,12 @@ Get a change data feed status. // Functions can be added from the `init()` function in manually curated files in this directory. var getDataApiOverrides []func( *cobra.Command, - *postgres.GetDataApiRequest, + *sdkpostgres.GetDataApiRequest, ) func newGetDataApi() *cobra.Command { cmd := &cobra.Command{} - - var getDataApiReq postgres.GetDataApiRequest + var getDataApiReq sdkpostgres.GetDataApiRequest cmd.Use = "get-data-api NAME" cmd.Short = `Get Data API configuration.` @@ -2814,15 +2844,21 @@ func newGetDataApi() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getDataApiReq.Name = args[0] + getDataApiReq.Name = new(args[0]) - response, err := w.Postgres.GetDataApi(ctx, getDataApiReq) + sdkReq := &getDataApiReq + response, err := w.Postgres.GetDataApi(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.DataApiFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2843,13 +2879,12 @@ func newGetDataApi() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getDatabaseOverrides []func( *cobra.Command, - *postgres.GetDatabaseRequest, + *sdkpostgres.GetDatabaseRequest, ) func newGetDatabase() *cobra.Command { cmd := &cobra.Command{} - - var getDatabaseReq postgres.GetDatabaseRequest + var getDatabaseReq sdkpostgres.GetDatabaseRequest cmd.Use = "get-database NAME" cmd.Short = `Get a Database.` @@ -2872,15 +2907,21 @@ func newGetDatabase() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getDatabaseReq.Name = args[0] + getDatabaseReq.Name = new(args[0]) - response, err := w.Postgres.GetDatabase(ctx, getDatabaseReq) + sdkReq := &getDatabaseReq + response, err := w.Postgres.GetDatabase(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.DatabaseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2901,13 +2942,12 @@ func newGetDatabase() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getEndpointOverrides []func( *cobra.Command, - *postgres.GetEndpointRequest, + *sdkpostgres.GetEndpointRequest, ) func newGetEndpoint() *cobra.Command { cmd := &cobra.Command{} - - var getEndpointReq postgres.GetEndpointRequest + var getEndpointReq sdkpostgres.GetEndpointRequest cmd.Use = "get-endpoint NAME" cmd.Short = `Get an Endpoint.` @@ -2933,15 +2973,21 @@ func newGetEndpoint() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getEndpointReq.Name = args[0] + getEndpointReq.Name = new(args[0]) - response, err := w.Postgres.GetEndpoint(ctx, getEndpointReq) + sdkReq := &getEndpointReq + response, err := w.Postgres.GetEndpoint(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.EndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -2962,13 +3008,12 @@ func newGetEndpoint() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOperationOverrides []func( *cobra.Command, - *postgres.GetOperationRequest, + *sdkpostgres.GetBranchRequest, ) func newGetOperation() *cobra.Command { cmd := &cobra.Command{} - - var getOperationReq postgres.GetOperationRequest + var getOperationReq sdkpostgres.GetBranchRequest cmd.Use = "get-operation NAME" cmd.Short = `Get an Operation.` @@ -2992,15 +3037,21 @@ func newGetOperation() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getOperationReq.Name = args[0] + getOperationReq.Name = new(args[0]) - response, err := w.Postgres.GetOperation(ctx, getOperationReq) + sdkReq := &getOperationReq + response, err := w.Postgres.GetBranch(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.BranchFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -3021,13 +3072,12 @@ func newGetOperation() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getProjectOverrides []func( *cobra.Command, - *postgres.GetProjectRequest, + *sdkpostgres.GetProjectRequest, ) func newGetProject() *cobra.Command { cmd := &cobra.Command{} - - var getProjectReq postgres.GetProjectRequest + var getProjectReq sdkpostgres.GetProjectRequest cmd.Use = "get-project NAME" cmd.Short = `Get a Project.` @@ -3052,15 +3102,21 @@ func newGetProject() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getProjectReq.Name = args[0] + getProjectReq.Name = new(args[0]) - response, err := w.Postgres.GetProject(ctx, getProjectReq) + sdkReq := &getProjectReq + response, err := w.Postgres.GetProject(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.ProjectFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -3081,13 +3137,12 @@ func newGetProject() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getRoleOverrides []func( *cobra.Command, - *postgres.GetRoleRequest, + *sdkpostgres.GetRoleRequest, ) func newGetRole() *cobra.Command { cmd := &cobra.Command{} - - var getRoleReq postgres.GetRoleRequest + var getRoleReq sdkpostgres.GetRoleRequest cmd.Use = "get-role NAME" cmd.Short = `Get a Postgres Role for a Branch.` @@ -3113,15 +3168,21 @@ func newGetRole() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getRoleReq.Name = args[0] + getRoleReq.Name = new(args[0]) - response, err := w.Postgres.GetRole(ctx, getRoleReq) + sdkReq := &getRoleReq + response, err := w.Postgres.GetRole(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.RoleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -3142,13 +3203,12 @@ func newGetRole() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getSnapshotOverrides []func( *cobra.Command, - *postgres.GetSnapshotRequest, + *sdkpostgres.GetSnapshotRequest, ) func newGetSnapshot() *cobra.Command { cmd := &cobra.Command{} - - var getSnapshotReq postgres.GetSnapshotRequest + var getSnapshotReq sdkpostgres.GetSnapshotRequest cmd.Use = "get-snapshot NAME" cmd.Short = `*Beta* Get a Snapshot.` @@ -3175,15 +3235,21 @@ Get a Snapshot. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSnapshotReq.Name = args[0] + getSnapshotReq.Name = new(args[0]) - response, err := w.Postgres.GetSnapshot(ctx, getSnapshotReq) + sdkReq := &getSnapshotReq + response, err := w.Postgres.GetSnapshot(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.SnapshotFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -3204,13 +3270,12 @@ Get a Snapshot. // Functions can be added from the `init()` function in manually curated files in this directory. var getSnapshotScheduleOverrides []func( *cobra.Command, - *postgres.GetSnapshotScheduleRequest, + *sdkpostgres.GetSnapshotScheduleRequest, ) func newGetSnapshotSchedule() *cobra.Command { cmd := &cobra.Command{} - - var getSnapshotScheduleReq postgres.GetSnapshotScheduleRequest + var getSnapshotScheduleReq sdkpostgres.GetSnapshotScheduleRequest cmd.Use = "get-snapshot-schedule NAME" cmd.Short = `*Beta* Get a Snapshot Schedule.` @@ -3238,15 +3303,21 @@ Get a Snapshot Schedule. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSnapshotScheduleReq.Name = args[0] + getSnapshotScheduleReq.Name = new(args[0]) - response, err := w.Postgres.GetSnapshotSchedule(ctx, getSnapshotScheduleReq) + sdkReq := &getSnapshotScheduleReq + response, err := w.Postgres.GetSnapshotSchedule(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.SnapshotScheduleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -3267,13 +3338,12 @@ Get a Snapshot Schedule. // Functions can be added from the `init()` function in manually curated files in this directory. var getSyncedTableOverrides []func( *cobra.Command, - *postgres.GetSyncedTableRequest, + *sdkpostgres.GetSyncedTableRequest, ) func newGetSyncedTable() *cobra.Command { cmd := &cobra.Command{} - - var getSyncedTableReq postgres.GetSyncedTableRequest + var getSyncedTableReq sdkpostgres.GetSyncedTableRequest cmd.Use = "get-synced-table NAME" cmd.Short = `Get a Synced Database Table.` @@ -3299,15 +3369,21 @@ func newGetSyncedTable() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSyncedTableReq.Name = args[0] + getSyncedTableReq.Name = new(args[0]) - response, err := w.Postgres.GetSyncedTable(ctx, getSyncedTableReq) + sdkReq := &getSyncedTableReq + response, err := w.Postgres.GetSyncedTable(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := postgres.SyncedTableFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -3333,21 +3409,21 @@ var listBranchesOverrides []func( func newListBranches() *cobra.Command { cmd := &cobra.Command{} - var listBranchesReq postgres.ListBranchesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listBranchesLimit int - cmd.Flags().IntVar(&listBranchesReq.PageSize, "page-size", listBranchesReq.PageSize, `Upper bound for items returned.`) - cmd.Flags().BoolVar(&listBranchesReq.ShowDeleted, "show-deleted", listBranchesReq.ShowDeleted, `Whether to include soft-deleted branches in the response.`) + flags.IntPtrVar(cmd.Flags(), &listBranchesReq.PageSize, "page-size", `Upper bound for items returned.`) + flags.BoolPtrVar(cmd.Flags(), &listBranchesReq.ShowDeleted, "show-deleted", `Whether to include soft-deleted branches in the response.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listBranchesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listBranchesReq.PageToken, "page-token", listBranchesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listBranchesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-branches PARENT" @@ -3373,18 +3449,22 @@ func newListBranches() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listBranchesReq.Parent = args[0] + listBranchesReq.Parent = new(args[0]) - response := w.Postgres.ListBranches(ctx, listBranchesReq) + sdkReq, err := postgres.ListBranchesRequestToSDK(&listBranchesReq) + if err != nil { + return err + } if listBranchesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listBranchesLimit) } if listBranchesLimit > 0 { ctx = cmdio.WithLimit(ctx, listBranchesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Postgres.ListBranchesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, postgres.BranchFromSDK)) } // Disable completions since they are not applicable. @@ -3410,20 +3490,20 @@ var listCdfConfigsOverrides []func( func newListCdfConfigs() *cobra.Command { cmd := &cobra.Command{} - var listCdfConfigsReq postgres.ListCdfConfigsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listCdfConfigsLimit int - cmd.Flags().IntVar(&listCdfConfigsReq.PageSize, "page-size", listCdfConfigsReq.PageSize, `Maximum number of CdfConfigs to return.`) + flags.IntPtrVar(cmd.Flags(), &listCdfConfigsReq.PageSize, "page-size", `Maximum number of CdfConfigs to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listCdfConfigsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listCdfConfigsReq.PageToken, "page-token", listCdfConfigsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listCdfConfigsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-cdf-configs PARENT" @@ -3453,18 +3533,22 @@ List change data feed configurations. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listCdfConfigsReq.Parent = args[0] + listCdfConfigsReq.Parent = new(args[0]) - response := w.Postgres.ListCdfConfigs(ctx, listCdfConfigsReq) + sdkReq, err := postgres.ListCdfConfigsRequestToSDK(&listCdfConfigsReq) + if err != nil { + return err + } if listCdfConfigsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listCdfConfigsLimit) } if listCdfConfigsLimit > 0 { ctx = cmdio.WithLimit(ctx, listCdfConfigsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Postgres.ListCdfConfigsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, postgres.CdfConfigFromSDK)) } // Disable completions since they are not applicable. @@ -3490,20 +3574,20 @@ var listCdfStatusesOverrides []func( func newListCdfStatuses() *cobra.Command { cmd := &cobra.Command{} - var listCdfStatusesReq postgres.ListCdfStatusesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listCdfStatusesLimit int - cmd.Flags().IntVar(&listCdfStatusesReq.PageSize, "page-size", listCdfStatusesReq.PageSize, `Maximum number of CdfStatuses to return.`) + flags.IntPtrVar(cmd.Flags(), &listCdfStatusesReq.PageSize, "page-size", `Maximum number of CdfStatuses to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listCdfStatusesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listCdfStatusesReq.PageToken, "page-token", listCdfStatusesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listCdfStatusesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-cdf-statuses PARENT" @@ -3533,18 +3617,22 @@ List change data feed statuses. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listCdfStatusesReq.Parent = args[0] + listCdfStatusesReq.Parent = new(args[0]) - response := w.Postgres.ListCdfStatuses(ctx, listCdfStatusesReq) + sdkReq, err := postgres.ListCdfStatusesRequestToSDK(&listCdfStatusesReq) + if err != nil { + return err + } if listCdfStatusesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listCdfStatusesLimit) } if listCdfStatusesLimit > 0 { ctx = cmdio.WithLimit(ctx, listCdfStatusesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Postgres.ListCdfStatusesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, postgres.CdfStatusFromSDK)) } // Disable completions since they are not applicable. @@ -3570,20 +3658,20 @@ var listDatabasesOverrides []func( func newListDatabases() *cobra.Command { cmd := &cobra.Command{} - var listDatabasesReq postgres.ListDatabasesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listDatabasesLimit int - cmd.Flags().IntVar(&listDatabasesReq.PageSize, "page-size", listDatabasesReq.PageSize, `Upper bound for items returned.`) + flags.IntPtrVar(cmd.Flags(), &listDatabasesReq.PageSize, "page-size", `Upper bound for items returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listDatabasesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listDatabasesReq.PageToken, "page-token", listDatabasesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listDatabasesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-databases PARENT" @@ -3609,18 +3697,22 @@ func newListDatabases() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listDatabasesReq.Parent = args[0] + listDatabasesReq.Parent = new(args[0]) - response := w.Postgres.ListDatabases(ctx, listDatabasesReq) + sdkReq, err := postgres.ListDatabasesRequestToSDK(&listDatabasesReq) + if err != nil { + return err + } if listDatabasesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listDatabasesLimit) } if listDatabasesLimit > 0 { ctx = cmdio.WithLimit(ctx, listDatabasesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Postgres.ListDatabasesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, postgres.DatabaseFromSDK)) } // Disable completions since they are not applicable. @@ -3646,20 +3738,20 @@ var listEndpointsOverrides []func( func newListEndpoints() *cobra.Command { cmd := &cobra.Command{} - var listEndpointsReq postgres.ListEndpointsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listEndpointsLimit int - cmd.Flags().IntVar(&listEndpointsReq.PageSize, "page-size", listEndpointsReq.PageSize, `Upper bound for items returned.`) + flags.IntPtrVar(cmd.Flags(), &listEndpointsReq.PageSize, "page-size", `Upper bound for items returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listEndpointsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listEndpointsReq.PageToken, "page-token", listEndpointsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listEndpointsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-endpoints PARENT" @@ -3685,18 +3777,22 @@ func newListEndpoints() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listEndpointsReq.Parent = args[0] + listEndpointsReq.Parent = new(args[0]) - response := w.Postgres.ListEndpoints(ctx, listEndpointsReq) + sdkReq, err := postgres.ListEndpointsRequestToSDK(&listEndpointsReq) + if err != nil { + return err + } if listEndpointsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listEndpointsLimit) } if listEndpointsLimit > 0 { ctx = cmdio.WithLimit(ctx, listEndpointsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Postgres.ListEndpointsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, postgres.EndpointFromSDK)) } // Disable completions since they are not applicable. @@ -3722,21 +3818,21 @@ var listProjectsOverrides []func( func newListProjects() *cobra.Command { cmd := &cobra.Command{} - var listProjectsReq postgres.ListProjectsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listProjectsLimit int - cmd.Flags().IntVar(&listProjectsReq.PageSize, "page-size", listProjectsReq.PageSize, `Upper bound for items returned.`) - cmd.Flags().BoolVar(&listProjectsReq.ShowDeleted, "show-deleted", listProjectsReq.ShowDeleted, `Whether to include soft-deleted projects in the response.`) + flags.IntPtrVar(cmd.Flags(), &listProjectsReq.PageSize, "page-size", `Upper bound for items returned.`) + flags.BoolPtrVar(cmd.Flags(), &listProjectsReq.ShowDeleted, "show-deleted", `Whether to include soft-deleted projects in the response.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listProjectsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listProjectsReq.PageToken, "page-token", listProjectsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listProjectsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-projects" @@ -3759,16 +3855,20 @@ func newListProjects() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Postgres.ListProjects(ctx, listProjectsReq) + sdkReq, err := postgres.ListProjectsRequestToSDK(&listProjectsReq) + if err != nil { + return err + } if listProjectsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listProjectsLimit) } if listProjectsLimit > 0 { ctx = cmdio.WithLimit(ctx, listProjectsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Postgres.ListProjectsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, postgres.ProjectFromSDK)) } // Disable completions since they are not applicable. @@ -3794,20 +3894,20 @@ var listRolesOverrides []func( func newListRoles() *cobra.Command { cmd := &cobra.Command{} - var listRolesReq postgres.ListRolesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listRolesLimit int - cmd.Flags().IntVar(&listRolesReq.PageSize, "page-size", listRolesReq.PageSize, `Upper bound for items returned.`) + flags.IntPtrVar(cmd.Flags(), &listRolesReq.PageSize, "page-size", `Upper bound for items returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listRolesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listRolesReq.PageToken, "page-token", listRolesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listRolesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-roles PARENT" @@ -3833,18 +3933,22 @@ func newListRoles() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listRolesReq.Parent = args[0] + listRolesReq.Parent = new(args[0]) - response := w.Postgres.ListRoles(ctx, listRolesReq) + sdkReq, err := postgres.ListRolesRequestToSDK(&listRolesReq) + if err != nil { + return err + } if listRolesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listRolesLimit) } if listRolesLimit > 0 { ctx = cmdio.WithLimit(ctx, listRolesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Postgres.ListRolesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, postgres.RoleFromSDK)) } // Disable completions since they are not applicable. @@ -3870,20 +3974,20 @@ var listSnapshotsOverrides []func( func newListSnapshots() *cobra.Command { cmd := &cobra.Command{} - var listSnapshotsReq postgres.ListSnapshotsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSnapshotsLimit int - cmd.Flags().IntVar(&listSnapshotsReq.PageSize, "page-size", listSnapshotsReq.PageSize, `Maximum number of snapshots to return per page.`) + flags.IntPtrVar(cmd.Flags(), &listSnapshotsReq.PageSize, "page-size", `Maximum number of snapshots to return per page.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listSnapshotsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSnapshotsReq.PageToken, "page-token", listSnapshotsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSnapshotsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-snapshots PARENT" @@ -3910,18 +4014,22 @@ List Snapshots. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listSnapshotsReq.Parent = args[0] + listSnapshotsReq.Parent = new(args[0]) - response := w.Postgres.ListSnapshots(ctx, listSnapshotsReq) + sdkReq, err := postgres.ListSnapshotsRequestToSDK(&listSnapshotsReq) + if err != nil { + return err + } if listSnapshotsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSnapshotsLimit) } if listSnapshotsLimit > 0 { ctx = cmdio.WithLimit(ctx, listSnapshotsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Postgres.ListSnapshotsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, postgres.SnapshotFromSDK)) } // Disable completions since they are not applicable. @@ -3947,7 +4055,6 @@ var undeleteBranchOverrides []func( func newUndeleteBranch() *cobra.Command { cmd := &cobra.Command{} - var undeleteBranchReq postgres.UndeleteBranchRequest var undeleteBranchSkipWait bool @@ -3987,28 +4094,27 @@ func newUndeleteBranch() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - undeleteBranchReq.Name = args[0] + undeleteBranchReq.Name = new(args[0]) + sdkReq, err := postgres.UndeleteBranchRequestToSDK(&undeleteBranchReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case undeleteBranchSkipWait: - wait, err := w.Postgres.UndeleteBranch(ctx, undeleteBranchReq) + wait, err := w.Postgres.UndeleteBranch(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.UndeleteBranch(ctx, undeleteBranchReq) + wait, err := w.Postgres.UndeleteBranch(ctx, *sdkReq) if err != nil { return err } @@ -4018,13 +4124,14 @@ func newUndeleteBranch() *cobra.Command { sp.Update("Waiting for undelete-branch to complete...") // Wait for completion. - opts := api.WithTimeout(undeleteBranchTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(undeleteBranchTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -4052,7 +4159,6 @@ var undeleteProjectOverrides []func( func newUndeleteProject() *cobra.Command { cmd := &cobra.Command{} - var undeleteProjectReq postgres.UndeleteProjectRequest var undeleteProjectSkipWait bool @@ -4091,28 +4197,27 @@ Undelete a Project. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - undeleteProjectReq.Name = args[0] + undeleteProjectReq.Name = new(args[0]) + sdkReq, err := postgres.UndeleteProjectRequestToSDK(&undeleteProjectReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case undeleteProjectSkipWait: - wait, err := w.Postgres.UndeleteProject(ctx, undeleteProjectReq) + wait, err := w.Postgres.UndeleteProject(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.UndeleteProject(ctx, undeleteProjectReq) + wait, err := w.Postgres.UndeleteProject(ctx, *sdkReq) if err != nil { return err } @@ -4122,13 +4227,14 @@ Undelete a Project. sp.Update("Waiting for undelete-project to complete...") // Wait for completion. - opts := api.WithTimeout(undeleteProjectTimeout) - - err = wait.Wait(ctx, opts) + response := struct{}{} + err = wait.Wait(ctx, lro.WithTimeout(undeleteProjectTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() + + _ = response return nil } } @@ -4156,9 +4262,9 @@ var updateBranchOverrides []func( func newUpdateBranch() *cobra.Command { cmd := &cobra.Command{} - var updateBranchReq postgres.UpdateBranchRequest - updateBranchReq.Branch = postgres.Branch{} + updateBranchReq.Branch = &postgres.Branch{} + var updateBranchJson flags.JsonFlag var updateBranchSkipWait bool @@ -4169,7 +4275,7 @@ func newUpdateBranch() *cobra.Command { cmd.Flags().Var(&updateBranchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateBranchReq.Branch.Name, "name", updateBranchReq.Branch.Name, `Output only.`) + flags.StringPtrVar(cmd.Flags(), &updateBranchReq.Branch.Name, "name", `Output only.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -4203,6 +4309,7 @@ func newUpdateBranch() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateBranchJson.Unmarshal(&updateBranchReq.Branch) @@ -4216,31 +4323,28 @@ func newUpdateBranch() *cobra.Command { } } } - updateBranchReq.Name = args[0] + updateBranchReq.Branch.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateBranchReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateBranchReq.UpdateMask = new(args[1]) } + sdkReq, err := postgres.UpdateBranchRequestToSDK(&updateBranchReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case updateBranchSkipWait: - wait, err := w.Postgres.UpdateBranch(ctx, updateBranchReq) + wait, err := w.Postgres.UpdateBranch(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.UpdateBranch(ctx, updateBranchReq) + wait, err := w.Postgres.UpdateBranch(ctx, *sdkReq) if err != nil { return err } @@ -4250,13 +4354,17 @@ func newUpdateBranch() *cobra.Command { sp.Update("Waiting for update-branch to complete...") // Wait for completion. - opts := api.WithTimeout(updateBranchTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(updateBranchTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.BranchFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -4283,9 +4391,9 @@ var updateDataApiOverrides []func( func newUpdateDataApi() *cobra.Command { cmd := &cobra.Command{} - var updateDataApiReq postgres.UpdateDataApiRequest - updateDataApiReq.DataApi = postgres.DataApi{} + updateDataApiReq.DataApi = &postgres.DataApi{} + var updateDataApiJson flags.JsonFlag var updateDataApiSkipWait bool @@ -4296,7 +4404,7 @@ func newUpdateDataApi() *cobra.Command { cmd.Flags().Var(&updateDataApiJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateDataApiReq.DataApi.Name, "name", updateDataApiReq.DataApi.Name, `Resource name: projects/{project_id}/branches/{branch_id}/databases/{database_id}/data-api.`) + flags.StringPtrVar(cmd.Flags(), &updateDataApiReq.DataApi.Name, "name", `Resource name: projects/{project_id}/branches/{branch_id}/databases/{database_id}/data-api.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -4332,6 +4440,7 @@ func newUpdateDataApi() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateDataApiJson.Unmarshal(&updateDataApiReq.DataApi) @@ -4345,31 +4454,28 @@ func newUpdateDataApi() *cobra.Command { } } } - updateDataApiReq.Name = args[0] + updateDataApiReq.DataApi.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateDataApiReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateDataApiReq.UpdateMask = new(args[1]) } + sdkReq, err := postgres.UpdateDataApiRequestToSDK(&updateDataApiReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case updateDataApiSkipWait: - wait, err := w.Postgres.UpdateDataApi(ctx, updateDataApiReq) + wait, err := w.Postgres.UpdateDataApi(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.UpdateDataApi(ctx, updateDataApiReq) + wait, err := w.Postgres.UpdateDataApi(ctx, *sdkReq) if err != nil { return err } @@ -4379,13 +4485,17 @@ func newUpdateDataApi() *cobra.Command { sp.Update("Waiting for update-data-api to complete...") // Wait for completion. - opts := api.WithTimeout(updateDataApiTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(updateDataApiTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.DataApiFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -4412,9 +4522,9 @@ var updateDatabaseOverrides []func( func newUpdateDatabase() *cobra.Command { cmd := &cobra.Command{} - var updateDatabaseReq postgres.UpdateDatabaseRequest - updateDatabaseReq.Database = postgres.Database{} + updateDatabaseReq.Database = &postgres.Database{} + var updateDatabaseJson flags.JsonFlag var updateDatabaseSkipWait bool @@ -4425,7 +4535,7 @@ func newUpdateDatabase() *cobra.Command { cmd.Flags().Var(&updateDatabaseJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateDatabaseReq.Database.Name, "name", updateDatabaseReq.Database.Name, `The resource name of the database.`) + flags.StringPtrVar(cmd.Flags(), &updateDatabaseReq.Database.Name, "name", `The resource name of the database.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -4456,6 +4566,7 @@ func newUpdateDatabase() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateDatabaseJson.Unmarshal(&updateDatabaseReq.Database) @@ -4469,31 +4580,28 @@ func newUpdateDatabase() *cobra.Command { } } } - updateDatabaseReq.Name = args[0] + updateDatabaseReq.Database.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateDatabaseReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateDatabaseReq.UpdateMask = new(args[1]) } + sdkReq, err := postgres.UpdateDatabaseRequestToSDK(&updateDatabaseReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case updateDatabaseSkipWait: - wait, err := w.Postgres.UpdateDatabase(ctx, updateDatabaseReq) + wait, err := w.Postgres.UpdateDatabase(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.UpdateDatabase(ctx, updateDatabaseReq) + wait, err := w.Postgres.UpdateDatabase(ctx, *sdkReq) if err != nil { return err } @@ -4503,13 +4611,17 @@ func newUpdateDatabase() *cobra.Command { sp.Update("Waiting for update-database to complete...") // Wait for completion. - opts := api.WithTimeout(updateDatabaseTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(updateDatabaseTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.DatabaseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -4536,9 +4648,9 @@ var updateEndpointOverrides []func( func newUpdateEndpoint() *cobra.Command { cmd := &cobra.Command{} - var updateEndpointReq postgres.UpdateEndpointRequest - updateEndpointReq.Endpoint = postgres.Endpoint{} + updateEndpointReq.Endpoint = &postgres.Endpoint{} + var updateEndpointJson flags.JsonFlag var updateEndpointSkipWait bool @@ -4549,7 +4661,7 @@ func newUpdateEndpoint() *cobra.Command { cmd.Flags().Var(&updateEndpointJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateEndpointReq.Endpoint.Name, "name", updateEndpointReq.Endpoint.Name, `Output only.`) + flags.StringPtrVar(cmd.Flags(), &updateEndpointReq.Endpoint.Name, "name", `Output only.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -4583,6 +4695,7 @@ func newUpdateEndpoint() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateEndpointJson.Unmarshal(&updateEndpointReq.Endpoint) @@ -4596,31 +4709,28 @@ func newUpdateEndpoint() *cobra.Command { } } } - updateEndpointReq.Name = args[0] + updateEndpointReq.Endpoint.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateEndpointReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateEndpointReq.UpdateMask = new(args[1]) } + sdkReq, err := postgres.UpdateEndpointRequestToSDK(&updateEndpointReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case updateEndpointSkipWait: - wait, err := w.Postgres.UpdateEndpoint(ctx, updateEndpointReq) + wait, err := w.Postgres.UpdateEndpoint(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.UpdateEndpoint(ctx, updateEndpointReq) + wait, err := w.Postgres.UpdateEndpoint(ctx, *sdkReq) if err != nil { return err } @@ -4630,13 +4740,17 @@ func newUpdateEndpoint() *cobra.Command { sp.Update("Waiting for update-endpoint to complete...") // Wait for completion. - opts := api.WithTimeout(updateEndpointTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(updateEndpointTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.EndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -4663,9 +4777,9 @@ var updateProjectOverrides []func( func newUpdateProject() *cobra.Command { cmd := &cobra.Command{} - var updateProjectReq postgres.UpdateProjectRequest - updateProjectReq.Project = postgres.Project{} + updateProjectReq.Project = &postgres.Project{} + var updateProjectJson flags.JsonFlag var updateProjectSkipWait bool @@ -4678,7 +4792,7 @@ func newUpdateProject() *cobra.Command { // TODO: complex arg: initial_branch_spec // TODO: complex arg: initial_endpoint_spec - cmd.Flags().StringVar(&updateProjectReq.Project.Name, "name", updateProjectReq.Project.Name, `Output only.`) + flags.StringPtrVar(cmd.Flags(), &updateProjectReq.Project.Name, "name", `Output only.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -4711,6 +4825,7 @@ func newUpdateProject() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateProjectJson.Unmarshal(&updateProjectReq.Project) @@ -4724,31 +4839,28 @@ func newUpdateProject() *cobra.Command { } } } - updateProjectReq.Name = args[0] + updateProjectReq.Project.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateProjectReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateProjectReq.UpdateMask = new(args[1]) } + sdkReq, err := postgres.UpdateProjectRequestToSDK(&updateProjectReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case updateProjectSkipWait: - wait, err := w.Postgres.UpdateProject(ctx, updateProjectReq) + wait, err := w.Postgres.UpdateProject(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.UpdateProject(ctx, updateProjectReq) + wait, err := w.Postgres.UpdateProject(ctx, *sdkReq) if err != nil { return err } @@ -4758,13 +4870,17 @@ func newUpdateProject() *cobra.Command { sp.Update("Waiting for update-project to complete...") // Wait for completion. - opts := api.WithTimeout(updateProjectTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(updateProjectTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.ProjectFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -4791,9 +4907,9 @@ var updateRoleOverrides []func( func newUpdateRole() *cobra.Command { cmd := &cobra.Command{} - var updateRoleReq postgres.UpdateRoleRequest - updateRoleReq.Role = postgres.Role{} + updateRoleReq.Role = &postgres.Role{} + var updateRoleJson flags.JsonFlag var updateRoleSkipWait bool @@ -4804,7 +4920,7 @@ func newUpdateRole() *cobra.Command { cmd.Flags().Var(&updateRoleJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateRoleReq.Role.Name, "name", updateRoleReq.Role.Name, `Output only.`) + flags.StringPtrVar(cmd.Flags(), &updateRoleReq.Role.Name, "name", `Output only.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -4837,6 +4953,7 @@ func newUpdateRole() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateRoleJson.Unmarshal(&updateRoleReq.Role) @@ -4850,31 +4967,28 @@ func newUpdateRole() *cobra.Command { } } } - updateRoleReq.Name = args[0] + updateRoleReq.Role.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateRoleReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateRoleReq.UpdateMask = new(args[1]) } + sdkReq, err := postgres.UpdateRoleRequestToSDK(&updateRoleReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case updateRoleSkipWait: - wait, err := w.Postgres.UpdateRole(ctx, updateRoleReq) + wait, err := w.Postgres.UpdateRole(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.UpdateRole(ctx, updateRoleReq) + wait, err := w.Postgres.UpdateRole(ctx, *sdkReq) if err != nil { return err } @@ -4884,13 +4998,17 @@ func newUpdateRole() *cobra.Command { sp.Update("Waiting for update-role to complete...") // Wait for completion. - opts := api.WithTimeout(updateRoleTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(updateRoleTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.RoleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } @@ -4917,9 +5035,9 @@ var updateSnapshotScheduleOverrides []func( func newUpdateSnapshotSchedule() *cobra.Command { cmd := &cobra.Command{} - var updateSnapshotScheduleReq postgres.UpdateSnapshotScheduleRequest - updateSnapshotScheduleReq.SnapshotSchedule = postgres.SnapshotSchedule{} + updateSnapshotScheduleReq.SnapshotSchedule = &postgres.SnapshotSchedule{} + var updateSnapshotScheduleJson flags.JsonFlag var updateSnapshotScheduleSkipWait bool @@ -4930,7 +5048,7 @@ func newUpdateSnapshotSchedule() *cobra.Command { cmd.Flags().Var(&updateSnapshotScheduleJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateSnapshotScheduleReq.SnapshotSchedule.Name, "name", updateSnapshotScheduleReq.SnapshotSchedule.Name, `The resource name of the branch's snapshot schedule.`) + flags.StringPtrVar(cmd.Flags(), &updateSnapshotScheduleReq.SnapshotSchedule.Name, "name", `The resource name of the branch's snapshot schedule.`) // TODO: array: schedule cmd.Use = "update-snapshot-schedule NAME UPDATE_MASK" @@ -4966,6 +5084,7 @@ Update a Snapshot Schedule. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateSnapshotScheduleJson.Unmarshal(&updateSnapshotScheduleReq.SnapshotSchedule) @@ -4979,31 +5098,28 @@ Update a Snapshot Schedule. } } } - updateSnapshotScheduleReq.Name = args[0] + updateSnapshotScheduleReq.SnapshotSchedule.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateSnapshotScheduleReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateSnapshotScheduleReq.UpdateMask = new(args[1]) } + sdkReq, err := postgres.UpdateSnapshotScheduleRequestToSDK(&updateSnapshotScheduleReq) + if err != nil { + return err + } // Determine which mode to execute based on flags. switch { case updateSnapshotScheduleSkipWait: - wait, err := w.Postgres.UpdateSnapshotSchedule(ctx, updateSnapshotScheduleReq) + wait, err := w.Postgres.UpdateSnapshotSchedule(ctx, *sdkReq) if err != nil { return err } // Return operation immediately without waiting. - operation, err := w.Postgres.GetOperation(ctx, postgres.GetOperationRequest{ - Name: wait.Name(), - }) - if err != nil { - return err - } - return cmdio.Render(ctx, operation) + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) default: - wait, err := w.Postgres.UpdateSnapshotSchedule(ctx, updateSnapshotScheduleReq) + wait, err := w.Postgres.UpdateSnapshotSchedule(ctx, *sdkReq) if err != nil { return err } @@ -5013,13 +5129,17 @@ Update a Snapshot Schedule. sp.Update("Waiting for update-snapshot-schedule to complete...") // Wait for completion. - opts := api.WithTimeout(updateSnapshotScheduleTimeout) - response, err := wait.Wait(ctx, opts) + response, err := wait.Wait(ctx, lro.WithTimeout(updateSnapshotScheduleTimeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - return cmdio.Render(ctx, response) + + out, err := postgres.SnapshotScheduleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } diff --git a/cmd/workspace/provider-exchange-filters/provider-exchange-filters.go b/cmd/workspace/provider-exchange-filters/provider-exchange-filters.go index c67cac764b0..52a0e8cead0 100644 --- a/cmd/workspace/provider-exchange-filters/provider-exchange-filters.go +++ b/cmd/workspace/provider-exchange-filters/provider-exchange-filters.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" + + marketplaces "github.com/databricks/cli/libs/sdktypes/marketplaces/v1" + sdkmarketplaces "github.com/databricks/sdk-go/marketplaces/v1" ) // Slice with functions to override default command behavior. @@ -53,13 +56,13 @@ Marketplace exchanges filters curate which groups can access an exchange.`, // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *marketplace.CreateExchangeFilterRequest, + *marketplaces.CreateExchangeFilterRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq marketplaces.CreateExchangeFilterRequest - var createReq marketplace.CreateExchangeFilterRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -80,6 +83,7 @@ Create a new exchange filter. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -96,12 +100,20 @@ Create a new exchange filter. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.ProviderExchangeFilters.Create(ctx, createReq) + sdkReq, err := marketplaces.CreateExchangeFilterRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Marketplaces.CreateExchangeFilter(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.CreateExchangeFilterResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -122,13 +134,12 @@ Create a new exchange filter. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *marketplace.DeleteExchangeFilterRequest, + *sdkmarketplaces.DeleteExchangeFilterRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq marketplace.DeleteExchangeFilterRequest + var deleteReq sdkmarketplaces.DeleteExchangeFilterRequest cmd.Use = "delete ID" cmd.Short = `*Public Preview* Delete an exchange filter.` @@ -146,11 +157,12 @@ Delete an exchange filter. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Provider Exchange Filters drop-down.") - names, err := w.ProviderExchangeFilters.ExchangeFilterNameToIdMap(ctx, marketplace.ListExchangeFiltersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Marketplaces.ListExchangeFiltersIter(ctx, sdkmarketplaces.ListExchangeFiltersRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Provider Exchange Filters drop-down. Please manually specify required arguments. Original error: %w", err) @@ -164,12 +176,15 @@ Delete an exchange filter. if len(args) != 1 { return errors.New("expected to have ") } - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = w.ProviderExchangeFilters.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Marketplaces.DeleteExchangeFilter(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -191,25 +206,25 @@ Delete an exchange filter. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *marketplace.ListExchangeFiltersRequest, + *marketplaces.ListExchangeFiltersRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq marketplaces.ListExchangeFiltersRequest - var listReq marketplace.ListExchangeFiltersRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list EXCHANGE_ID" @@ -233,18 +248,22 @@ List exchange filters. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.ExchangeId = args[0] + listReq.ExchangeId = new(args[0]) - response := w.ProviderExchangeFilters.List(ctx, listReq) + sdkReq, err := marketplaces.ListExchangeFiltersRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.ListExchangeFiltersIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.ExchangeFilterFromSDK)) } // Disable completions since they are not applicable. @@ -265,13 +284,13 @@ List exchange filters. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *marketplace.UpdateExchangeFilterRequest, + *marketplaces.UpdateExchangeFilterRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq marketplaces.UpdateExchangeFilterRequest - var updateReq marketplace.UpdateExchangeFilterRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -297,6 +316,7 @@ Update exchange filter. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -312,14 +332,22 @@ Update exchange filter. } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - response, err := w.ProviderExchangeFilters.Update(ctx, updateReq) + sdkReq, err := marketplaces.UpdateExchangeFilterRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Marketplaces.UpdateExchangeFilter(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.UpdateExchangeFilterResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/provider-exchanges/provider-exchanges.go b/cmd/workspace/provider-exchanges/provider-exchanges.go index 7c8484fce1b..c73dcda2a40 100644 --- a/cmd/workspace/provider-exchanges/provider-exchanges.go +++ b/cmd/workspace/provider-exchanges/provider-exchanges.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" + + marketplaces "github.com/databricks/cli/libs/sdktypes/marketplaces/v1" + sdkmarketplaces "github.com/databricks/sdk-go/marketplaces/v1" ) // Slice with functions to override default command behavior. @@ -59,13 +62,13 @@ Marketplace exchanges allow providers to share their listings with a curated // Functions can be added from the `init()` function in manually curated files in this directory. var addListingToExchangeOverrides []func( *cobra.Command, - *marketplace.AddExchangeForListingRequest, + *marketplaces.AddExchangeForListingRequest, ) func newAddListingToExchange() *cobra.Command { cmd := &cobra.Command{} + var addListingToExchangeReq marketplaces.AddExchangeForListingRequest - var addListingToExchangeReq marketplace.AddExchangeForListingRequest var addListingToExchangeJson flags.JsonFlag cmd.Flags().Var(&addListingToExchangeJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -98,6 +101,7 @@ Add an exchange for listing. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := addListingToExchangeJson.Unmarshal(&addListingToExchangeReq) @@ -112,18 +116,26 @@ Add an exchange for listing. } } if !cmd.Flags().Changed("json") { - addListingToExchangeReq.ListingId = args[0] + addListingToExchangeReq.ListingId = new(args[0]) } if !cmd.Flags().Changed("json") { - addListingToExchangeReq.ExchangeId = args[1] + addListingToExchangeReq.ExchangeId = new(args[1]) } - response, err := w.ProviderExchanges.AddListingToExchange(ctx, addListingToExchangeReq) + sdkReq, err := marketplaces.AddExchangeForListingRequestToSDK(&addListingToExchangeReq) + if err != nil { + return err + } + response, err := w.Marketplaces.AddExchangeForListing(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.AddExchangeForListingResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -144,13 +156,13 @@ Add an exchange for listing. // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *marketplace.CreateExchangeRequest, + *marketplaces.CreateExchangeRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq marketplaces.CreateExchangeRequest - var createReq marketplace.CreateExchangeRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -171,6 +183,7 @@ Create an exchange. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -187,12 +200,20 @@ Create an exchange. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.ProviderExchanges.Create(ctx, createReq) + sdkReq, err := marketplaces.CreateExchangeRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Marketplaces.CreateExchange(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.CreateExchangeResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -213,13 +234,12 @@ Create an exchange. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *marketplace.DeleteExchangeRequest, + *sdkmarketplaces.DeleteExchangeRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq marketplace.DeleteExchangeRequest + var deleteReq sdkmarketplaces.DeleteExchangeRequest cmd.Use = "delete ID" cmd.Short = `*Public Preview* Delete an exchange.` @@ -242,13 +262,17 @@ Delete an exchange. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = w.ProviderExchanges.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Marketplaces.DeleteExchange(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -270,13 +294,12 @@ Delete an exchange. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteListingFromExchangeOverrides []func( *cobra.Command, - *marketplace.RemoveExchangeForListingRequest, + *sdkmarketplaces.RemoveExchangeForListingRequest, ) func newDeleteListingFromExchange() *cobra.Command { cmd := &cobra.Command{} - - var deleteListingFromExchangeReq marketplace.RemoveExchangeForListingRequest + var deleteListingFromExchangeReq sdkmarketplaces.RemoveExchangeForListingRequest cmd.Use = "delete-listing-from-exchange ID" cmd.Short = `*Public Preview* Remove an exchange for listing.` @@ -299,13 +322,17 @@ Remove an exchange for listing. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteListingFromExchangeReq.Id = args[0] + deleteListingFromExchangeReq.Id = new(args[0]) - err = w.ProviderExchanges.DeleteListingFromExchange(ctx, deleteListingFromExchangeReq) + sdkReq := &deleteListingFromExchangeReq + response, err := w.Marketplaces.RemoveExchangeForListing(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -327,13 +354,12 @@ Remove an exchange for listing. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *marketplace.GetExchangeRequest, + *sdkmarketplaces.GetExchangeRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq marketplace.GetExchangeRequest + var getReq sdkmarketplaces.GetExchangeRequest cmd.Use = "get ID" cmd.Short = `*Public Preview* Get an exchange.` @@ -354,15 +380,21 @@ Get an exchange.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.ProviderExchanges.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Marketplaces.GetExchange(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.GetExchangeResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -383,25 +415,25 @@ Get an exchange.` // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *marketplace.ListExchangesRequest, + *marketplaces.ListExchangesRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq marketplaces.ListExchangesRequest - var listReq marketplace.ListExchangesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -425,16 +457,20 @@ List exchanges. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ProviderExchanges.List(ctx, listReq) + sdkReq, err := marketplaces.ListExchangesRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.ListExchangesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.ExchangeFromSDK)) } // Disable completions since they are not applicable. @@ -455,25 +491,25 @@ List exchanges. // Functions can be added from the `init()` function in manually curated files in this directory. var listExchangesForListingOverrides []func( *cobra.Command, - *marketplace.ListExchangesForListingRequest, + *marketplaces.ListExchangesForListingRequest, ) func newListExchangesForListing() *cobra.Command { cmd := &cobra.Command{} + var listExchangesForListingReq marketplaces.ListExchangesForListingRequest - var listExchangesForListingReq marketplace.ListExchangesForListingRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listExchangesForListingLimit int - cmd.Flags().IntVar(&listExchangesForListingReq.PageSize, "page-size", listExchangesForListingReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listExchangesForListingReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listExchangesForListingLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listExchangesForListingReq.PageToken, "page-token", listExchangesForListingReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listExchangesForListingReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-exchanges-for-listing LISTING_ID" @@ -497,18 +533,22 @@ List exchanges for listing. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listExchangesForListingReq.ListingId = args[0] + listExchangesForListingReq.ListingId = new(args[0]) - response := w.ProviderExchanges.ListExchangesForListing(ctx, listExchangesForListingReq) + sdkReq, err := marketplaces.ListExchangesForListingRequestToSDK(&listExchangesForListingReq) + if err != nil { + return err + } if listExchangesForListingLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listExchangesForListingLimit) } if listExchangesForListingLimit > 0 { ctx = cmdio.WithLimit(ctx, listExchangesForListingLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.ListExchangesForListingIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.ExchangeListingFromSDK)) } // Disable completions since they are not applicable. @@ -529,25 +569,25 @@ List exchanges for listing. // Functions can be added from the `init()` function in manually curated files in this directory. var listListingsForExchangeOverrides []func( *cobra.Command, - *marketplace.ListListingsForExchangeRequest, + *marketplaces.ListListingsForExchangeRequest, ) func newListListingsForExchange() *cobra.Command { cmd := &cobra.Command{} + var listListingsForExchangeReq marketplaces.ListListingsForExchangeRequest - var listListingsForExchangeReq marketplace.ListListingsForExchangeRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listListingsForExchangeLimit int - cmd.Flags().IntVar(&listListingsForExchangeReq.PageSize, "page-size", listListingsForExchangeReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listListingsForExchangeReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listListingsForExchangeLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listListingsForExchangeReq.PageToken, "page-token", listListingsForExchangeReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listListingsForExchangeReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-listings-for-exchange EXCHANGE_ID" @@ -571,18 +611,22 @@ List listings for exchange. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listListingsForExchangeReq.ExchangeId = args[0] + listListingsForExchangeReq.ExchangeId = new(args[0]) - response := w.ProviderExchanges.ListListingsForExchange(ctx, listListingsForExchangeReq) + sdkReq, err := marketplaces.ListListingsForExchangeRequestToSDK(&listListingsForExchangeReq) + if err != nil { + return err + } if listListingsForExchangeLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listListingsForExchangeLimit) } if listListingsForExchangeLimit > 0 { ctx = cmdio.WithLimit(ctx, listListingsForExchangeLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.ListListingsForExchangeIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.ExchangeListingFromSDK)) } // Disable completions since they are not applicable. @@ -603,13 +647,13 @@ List listings for exchange. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *marketplace.UpdateExchangeRequest, + *marketplaces.UpdateExchangeRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq marketplaces.UpdateExchangeRequest - var updateReq marketplace.UpdateExchangeRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -635,6 +679,7 @@ Update exchange. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -650,14 +695,22 @@ Update exchange. } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - response, err := w.ProviderExchanges.Update(ctx, updateReq) + sdkReq, err := marketplaces.UpdateExchangeRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Marketplaces.UpdateExchange(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.UpdateExchangeResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/provider-files/provider-files.go b/cmd/workspace/provider-files/provider-files.go index 6322769d366..00f38721d7e 100644 --- a/cmd/workspace/provider-files/provider-files.go +++ b/cmd/workspace/provider-files/provider-files.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" + + marketplaces "github.com/databricks/cli/libs/sdktypes/marketplaces/v1" + sdkmarketplaces "github.com/databricks/sdk-go/marketplaces/v1" ) // Slice with functions to override default command behavior. @@ -54,18 +57,18 @@ Marketplace offers a set of file APIs for various purposes such as preview // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *marketplace.CreateFileRequest, + *marketplaces.CreateFileRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq marketplaces.CreateFileRequest - var createReq marketplace.CreateFileRequest 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.DisplayName, "display-name", createReq.DisplayName, ``) + flags.StringPtrVar(cmd.Flags(), &createReq.DisplayName, "display-name", ``) cmd.Use = "create" cmd.Short = `*Public Preview* Create a file.` @@ -84,6 +87,7 @@ Create a file. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -100,12 +104,20 @@ Create a file. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.ProviderFiles.Create(ctx, createReq) + sdkReq, err := marketplaces.CreateFileRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Marketplaces.CreateFile(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.CreateFileResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -126,13 +138,12 @@ Create a file. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *marketplace.DeleteFileRequest, + *sdkmarketplaces.DeleteFileRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq marketplace.DeleteFileRequest + var deleteReq sdkmarketplaces.DeleteFileRequest cmd.Use = "delete FILE_ID" cmd.Short = `*Public Preview* Delete a file.` @@ -150,11 +161,12 @@ Delete a file. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No FILE_ID argument specified. Loading names for Provider Files drop-down.") - names, err := w.ProviderFiles.FileInfoDisplayNameToIdMap(ctx, marketplace.ListFilesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Marketplaces.ListFilesIter(ctx, sdkmarketplaces.ListFilesRequest{}), []string{"DisplayName"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Provider Files drop-down. Please manually specify required arguments. Original error: %w", err) @@ -168,12 +180,15 @@ Delete a file. if len(args) != 1 { return errors.New("expected to have ") } - deleteReq.FileId = args[0] + deleteReq.FileId = new(args[0]) - err = w.ProviderFiles.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Marketplaces.DeleteFile(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -195,13 +210,12 @@ Delete a file. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *marketplace.GetFileRequest, + *sdkmarketplaces.GetFileRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq marketplace.GetFileRequest + var getReq sdkmarketplaces.GetFileRequest cmd.Use = "get FILE_ID" cmd.Short = `*Public Preview* Get a file.` @@ -219,11 +233,12 @@ Get a file. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No FILE_ID argument specified. Loading names for Provider Files drop-down.") - names, err := w.ProviderFiles.FileInfoDisplayNameToIdMap(ctx, marketplace.ListFilesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Marketplaces.ListFilesIter(ctx, sdkmarketplaces.ListFilesRequest{}), []string{"DisplayName"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Provider Files drop-down. Please manually specify required arguments. Original error: %w", err) @@ -237,14 +252,19 @@ Get a file. if len(args) != 1 { return errors.New("expected to have ") } - getReq.FileId = args[0] + getReq.FileId = new(args[0]) - response, err := w.ProviderFiles.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Marketplaces.GetFile(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.GetFileResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -265,13 +285,13 @@ Get a file. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *marketplace.ListFilesRequest, + *marketplaces.ListFilesRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq marketplaces.ListFilesRequest - var listReq marketplace.ListFilesRequest var listJson flags.JsonFlag // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO @@ -280,13 +300,13 @@ func newList() *cobra.Command { cmd.Flags().Var(&listJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -305,6 +325,7 @@ List files. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := listJson.Unmarshal(&listReq) @@ -321,15 +342,18 @@ List files. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response := w.ProviderFiles.List(ctx, listReq) + sdkReq, err := marketplaces.ListFilesRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.ListFilesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.FileInfoFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/provider-listings/provider-listings.go b/cmd/workspace/provider-listings/provider-listings.go index 844f87041ce..176a9c2ef25 100644 --- a/cmd/workspace/provider-listings/provider-listings.go +++ b/cmd/workspace/provider-listings/provider-listings.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" + + marketplaces "github.com/databricks/cli/libs/sdktypes/marketplaces/v1" + sdkmarketplaces "github.com/databricks/sdk-go/marketplaces/v1" ) // Slice with functions to override default command behavior. @@ -55,13 +58,13 @@ Listings are the core entities in the Marketplace. They represent the products // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *marketplace.CreateListingRequest, + *marketplaces.CreateListingRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq marketplaces.CreateListingRequest - var createReq marketplace.CreateListingRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -82,6 +85,7 @@ Create a listing. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -98,12 +102,20 @@ Create a listing. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.ProviderListings.Create(ctx, createReq) + sdkReq, err := marketplaces.CreateListingRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Marketplaces.CreateListing(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.CreateListingResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -124,13 +136,12 @@ Create a listing. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *marketplace.DeleteListingRequest, + *sdkmarketplaces.DeleteListingRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq marketplace.DeleteListingRequest + var deleteReq sdkmarketplaces.DeleteListingRequest cmd.Use = "delete ID" cmd.Short = `*Public Preview* Delete a listing.` @@ -148,11 +159,12 @@ Delete a listing. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Provider Listings drop-down.") - names, err := w.ProviderListings.ListingSummaryNameToIdMap(ctx, marketplace.GetListingsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Marketplaces.ListListingsIter(ctx, sdkmarketplaces.ListListingsRequest{}), []string{"Summary", "Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Provider Listings drop-down. Please manually specify required arguments. Original error: %w", err) @@ -166,12 +178,15 @@ Delete a listing. if len(args) != 1 { return errors.New("expected to have ") } - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = w.ProviderListings.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Marketplaces.DeleteListing(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -193,13 +208,12 @@ Delete a listing. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *marketplace.GetListingRequest, + *sdkmarketplaces.GetListingRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq marketplace.GetListingRequest + var getReq sdkmarketplaces.GetListingRequest cmd.Use = "get ID" cmd.Short = `*Public Preview* Get a listing.` @@ -217,11 +231,12 @@ Get a listing. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Provider Listings drop-down.") - names, err := w.ProviderListings.ListingSummaryNameToIdMap(ctx, marketplace.GetListingsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Marketplaces.ListListingsIter(ctx, sdkmarketplaces.ListListingsRequest{}), []string{"Summary", "Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Provider Listings drop-down. Please manually specify required arguments. Original error: %w", err) @@ -235,14 +250,19 @@ Get a listing. if len(args) != 1 { return errors.New("expected to have ") } - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.ProviderListings.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Marketplaces.GetListing(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.GetListingResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -263,25 +283,25 @@ Get a listing. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *marketplace.GetListingsRequest, + *marketplaces.ListListingsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq marketplaces.ListListingsRequest - var listReq marketplace.GetListingsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -305,16 +325,20 @@ List listings. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ProviderListings.List(ctx, listReq) + sdkReq, err := marketplaces.ListListingsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.ListListingsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.ListingFromSDK)) } // Disable completions since they are not applicable. @@ -335,13 +359,13 @@ List listings. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *marketplace.UpdateListingRequest, + *marketplaces.UpdateListingRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq marketplaces.UpdateListingRequest - var updateReq marketplace.UpdateListingRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -367,6 +391,7 @@ Update listing. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -382,14 +407,22 @@ Update listing. } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - response, err := w.ProviderListings.Update(ctx, updateReq) + sdkReq, err := marketplaces.UpdateListingRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Marketplaces.UpdateListing(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.UpdateListingResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/provider-personalization-requests/provider-personalization-requests.go b/cmd/workspace/provider-personalization-requests/provider-personalization-requests.go index b86741b6b2a..a5f87a3f778 100644 --- a/cmd/workspace/provider-personalization-requests/provider-personalization-requests.go +++ b/cmd/workspace/provider-personalization-requests/provider-personalization-requests.go @@ -8,10 +8,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" + + marketplaces "github.com/databricks/cli/libs/sdktypes/marketplaces/v1" ) // Slice with functions to override default command behavior. @@ -52,25 +54,25 @@ Personalization requests are an alternate to instantly available listings. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *marketplace.ListAllPersonalizationRequestsRequest, + *marketplaces.GetPersonalizationRequestsForProviderRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq marketplaces.GetPersonalizationRequestsForProviderRequest - var listReq marketplace.ListAllPersonalizationRequestsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -95,16 +97,20 @@ All personalization requests across all listings. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ProviderPersonalizationRequests.List(ctx, listReq) + sdkReq, err := marketplaces.GetPersonalizationRequestsForProviderRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.GetPersonalizationRequestsForProviderIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.PersonalizationRequestFromSDK)) } // Disable completions since they are not applicable. @@ -125,18 +131,18 @@ All personalization requests across all listings. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *marketplace.UpdatePersonalizationRequestRequest, + *marketplaces.UpdatePersonalizationRequestStatusRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq marketplaces.UpdatePersonalizationRequestStatusRequest - var updateReq marketplace.UpdatePersonalizationRequestRequest 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.Reason, "reason", updateReq.Reason, ``) + flags.StringPtrVar(cmd.Flags(), &updateReq.Reason, "reason", ``) // TODO: complex arg: share cmd.Use = "update LISTING_ID REQUEST_ID STATUS" @@ -168,6 +174,7 @@ Update personalization request status. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -181,22 +188,26 @@ Update personalization request status. } } } - updateReq.ListingId = args[0] - updateReq.RequestId = args[1] + updateReq.ListingId = new(args[0]) + updateReq.RequestId = new(args[1]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &updateReq.Status) - if err != nil { - return fmt.Errorf("invalid STATUS: %s", args[2]) - } - + updateReq.Status = marketplaces.PersonalizationRequestStatus(args[2]) } - response, err := w.ProviderPersonalizationRequests.Update(ctx, updateReq) + sdkReq, err := marketplaces.UpdatePersonalizationRequestStatusRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Marketplaces.UpdatePersonalizationRequestStatus(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.UpdatePersonalizationRequestStatusResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go b/cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go index a85c1878af7..0521d892229 100644 --- a/cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go +++ b/cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go @@ -7,8 +7,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" + + marketplaces "github.com/databricks/cli/libs/sdktypes/marketplaces/v1" + sdkmarketplaces "github.com/databricks/sdk-go/marketplaces/v1" ) // Slice with functions to override default command behavior. @@ -72,12 +74,20 @@ Create provider analytics dashboard. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.ProviderProviderAnalyticsDashboards.Create(ctx) + _ = w + + sdkReq := &sdkmarketplaces.CreateProviderAnalyticsDashboardRequest{} + + response, err := w.Marketplaces.CreateProviderAnalyticsDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.CreateProviderAnalyticsDashboardResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -117,12 +127,20 @@ Get provider analytics dashboard.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.ProviderProviderAnalyticsDashboards.Get(ctx) + _ = w + + sdkReq := &sdkmarketplaces.ListProviderAnalyticsDashboardRequest{} + + response, err := w.Marketplaces.ListProviderAnalyticsDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.ListProviderAnalyticsDashboardResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -162,12 +180,20 @@ Get latest version of provider analytics dashboard.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.ProviderProviderAnalyticsDashboards.GetLatestVersion(ctx) + _ = w + + sdkReq := &sdkmarketplaces.GetLatestVersionProviderAnalyticsDashboardRequest{} + + response, err := w.Marketplaces.GetLatestVersionProviderAnalyticsDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.GetLatestVersionProviderAnalyticsDashboardResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -188,18 +214,18 @@ Get latest version of provider analytics dashboard.` // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *marketplace.UpdateProviderAnalyticsDashboardRequest, + *marketplaces.UpdateProviderAnalyticsDashboardRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq marketplaces.UpdateProviderAnalyticsDashboardRequest - var updateReq marketplace.UpdateProviderAnalyticsDashboardRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Int64Var(&updateReq.Version, "version", updateReq.Version, `this is the version of the dashboard template we want to update our user to current expectation is that it should be equal to latest version of the dashboard template.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.Version, "version", `this is the version of the dashboard template we want to update our user to current expectation is that it should be equal to latest version of the dashboard template.`) cmd.Use = "update ID" cmd.Short = `*Public Preview* Update provider analytics dashboard.` @@ -223,6 +249,7 @@ Update provider analytics dashboard. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -236,14 +263,22 @@ Update provider analytics dashboard. } } } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - response, err := w.ProviderProviderAnalyticsDashboards.Update(ctx, updateReq) + sdkReq, err := marketplaces.UpdateProviderAnalyticsDashboardRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Marketplaces.UpdateProviderAnalyticsDashboard(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.UpdateProviderAnalyticsDashboardResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/provider-providers/provider-providers.go b/cmd/workspace/provider-providers/provider-providers.go index 92fb2ea916a..75ef219d830 100644 --- a/cmd/workspace/provider-providers/provider-providers.go +++ b/cmd/workspace/provider-providers/provider-providers.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" + + marketplaces "github.com/databricks/cli/libs/sdktypes/marketplaces/v1" + sdkmarketplaces "github.com/databricks/sdk-go/marketplaces/v1" ) // Slice with functions to override default command behavior. @@ -54,13 +57,13 @@ Providers are entities that manage assets in Marketplace.`, // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *marketplace.CreateProviderRequest, + *marketplaces.CreateProviderRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq marketplaces.CreateProviderRequest - var createReq marketplace.CreateProviderRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -81,6 +84,7 @@ Create a provider. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -97,12 +101,20 @@ Create a provider. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.ProviderProviders.Create(ctx, createReq) + sdkReq, err := marketplaces.CreateProviderRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Marketplaces.CreateProvider(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.CreateProviderResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -123,13 +135,12 @@ Create a provider. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *marketplace.DeleteProviderRequest, + *sdkmarketplaces.DeleteProviderRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq marketplace.DeleteProviderRequest + var deleteReq sdkmarketplaces.DeleteProviderRequest cmd.Use = "delete ID" cmd.Short = `*Public Preview* Delete provider.` @@ -147,11 +158,12 @@ Delete provider. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Provider Providers drop-down.") - names, err := w.ProviderProviders.ProviderInfoNameToIdMap(ctx, marketplace.ListProvidersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Marketplaces.ListProvidersIter(ctx, sdkmarketplaces.ListProvidersRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Provider Providers drop-down. Please manually specify required arguments. Original error: %w", err) @@ -165,12 +177,15 @@ Delete provider. if len(args) != 1 { return errors.New("expected to have ") } - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = w.ProviderProviders.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Marketplaces.DeleteProvider(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -192,13 +207,12 @@ Delete provider. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *marketplace.GetProviderRequest, + *sdkmarketplaces.GetProviderRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq marketplace.GetProviderRequest + var getReq sdkmarketplaces.GetProviderRequest cmd.Use = "get ID" cmd.Short = `*Public Preview* Get provider.` @@ -216,11 +230,12 @@ Get provider. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Provider Providers drop-down.") - names, err := w.ProviderProviders.ProviderInfoNameToIdMap(ctx, marketplace.ListProvidersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Marketplaces.ListProvidersIter(ctx, sdkmarketplaces.ListProvidersRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Provider Providers drop-down. Please manually specify required arguments. Original error: %w", err) @@ -234,14 +249,19 @@ Get provider. if len(args) != 1 { return errors.New("expected to have ") } - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.ProviderProviders.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Marketplaces.GetProvider(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.GetProviderResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -262,25 +282,25 @@ Get provider. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *marketplace.ListProvidersRequest, + *marketplaces.ListProvidersRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq marketplaces.ListProvidersRequest - var listReq marketplace.ListProvidersRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -304,16 +324,20 @@ List providers. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ProviderProviders.List(ctx, listReq) + sdkReq, err := marketplaces.ListProvidersRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Marketplaces.ListProvidersIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, marketplaces.ProviderInfoFromSDK)) } // Disable completions since they are not applicable. @@ -334,13 +358,13 @@ List providers. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *marketplace.UpdateProviderRequest, + *marketplaces.UpdateProviderRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq marketplaces.UpdateProviderRequest - var updateReq marketplace.UpdateProviderRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -366,6 +390,7 @@ Update provider. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -381,14 +406,22 @@ Update provider. } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - response, err := w.ProviderProviders.Update(ctx, updateReq) + sdkReq, err := marketplaces.UpdateProviderRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Marketplaces.UpdateProvider(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := marketplaces.UpdateProviderResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/providers/providers.go b/cmd/workspace/providers/providers.go index 8d234ff712b..4ebeb365611 100644 --- a/cmd/workspace/providers/providers.go +++ b/cmd/workspace/providers/providers.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/sharing" "github.com/spf13/cobra" + + sharing "github.com/databricks/cli/libs/sdktypes/sharing/v1" + sdksharing "github.com/databricks/sdk-go/sharing/v1" ) // Slice with functions to override default command behavior. @@ -56,19 +59,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *sharing.CreateProvider, + *sharing.CreateProviderRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq sharing.CreateProviderRequest - var createReq sharing.CreateProvider 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.Comment, "comment", createReq.Comment, `Description about the provider.`) - cmd.Flags().StringVar(&createReq.RecipientProfileStr, "recipient-profile-str", createReq.RecipientProfileStr, `This field is required when the __authentication_type__ is **TOKEN**, **OAUTH_CLIENT_CREDENTIALS** or not provided.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Comment, "comment", `Description about the provider.`) + flags.StringPtrVar(cmd.Flags(), &createReq.RecipientProfileStr, "recipient-profile-str", `This field is required when the __authentication_type__ is **TOKEN**, **OAUTH_CLIENT_CREDENTIALS** or not provided.`) cmd.Use = "create NAME AUTHENTICATION_TYPE" cmd.Short = `Create an auth provider.` @@ -102,6 +105,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -116,22 +120,26 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Name = args[0] + createReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createReq.AuthenticationType) - if err != nil { - return fmt.Errorf("invalid AUTHENTICATION_TYPE: %s", args[1]) - } - + createReq.AuthenticationType = sharing.DeltaSharingAuthenticationType(args[1]) } - response, err := w.Providers.Create(ctx, createReq) + sdkReq, err := sharing.CreateProviderRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Sharing.CreateProvider(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.ProviderInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -152,13 +160,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sharing.DeleteProviderRequest, + *sdksharing.DeleteProviderRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sharing.DeleteProviderRequest + var deleteReq sdksharing.DeleteProviderRequest cmd.Use = "delete NAME" cmd.Short = `Delete a provider.` @@ -178,11 +185,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Providers drop-down.") - names, err := w.Providers.ProviderInfoNameToMetastoreIdMap(ctx, sharing.ListProvidersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Sharing.ListProvidersIter(ctx, sdksharing.ListProvidersRequest{}), []string{"Name"}, []string{"MetastoreId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Providers drop-down. Please manually specify required arguments. Original error: %w", err) @@ -196,12 +204,15 @@ func newDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have name of the provider") } - deleteReq.Name = args[0] + deleteReq.NameArg = new(args[0]) - err = w.Providers.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Sharing.DeleteProvider(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -223,13 +234,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *sharing.GetProviderRequest, + *sdksharing.GetProviderRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq sharing.GetProviderRequest + var getReq sdksharing.GetProviderRequest cmd.Use = "get NAME" cmd.Short = `Get a provider.` @@ -250,11 +260,12 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Providers drop-down.") - names, err := w.Providers.ProviderInfoNameToMetastoreIdMap(ctx, sharing.ListProvidersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Sharing.ListProvidersIter(ctx, sdksharing.ListProvidersRequest{}), []string{"Name"}, []string{"MetastoreId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Providers drop-down. Please manually specify required arguments. Original error: %w", err) @@ -268,14 +279,19 @@ func newGet() *cobra.Command { if len(args) != 1 { return errors.New("expected to have name of the provider") } - getReq.Name = args[0] + getReq.NameArg = new(args[0]) - response, err := w.Providers.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Sharing.GetProvider(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.ProviderInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -301,22 +317,22 @@ var listOverrides []func( func newList() *cobra.Command { cmd := &cobra.Command{} - var listReq sharing.ListProvidersRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.DataProviderGlobalMetastoreId, "data-provider-global-metastore-id", listReq.DataProviderGlobalMetastoreId, `If not provided, all providers will be returned.`) + flags.StringPtrVar(cmd.Flags(), &listReq.DataProviderGlobalMetastoreId, "data-provider-global-metastore-id", `If not provided, all providers will be returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of providers to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of providers to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list" @@ -343,16 +359,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Providers.List(ctx, listReq) + sdkReq, err := sharing.ListProvidersRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Sharing.ListProvidersIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, sharing.ProviderInfoFromSDK)) } // Disable completions since they are not applicable. @@ -378,13 +398,12 @@ var listProviderShareAssetsOverrides []func( func newListProviderShareAssets() *cobra.Command { cmd := &cobra.Command{} - var listProviderShareAssetsReq sharing.ListProviderShareAssetsRequest - cmd.Flags().IntVar(&listProviderShareAssetsReq.FunctionMaxResults, "function-max-results", listProviderShareAssetsReq.FunctionMaxResults, `Maximum number of functions to return.`) - cmd.Flags().IntVar(&listProviderShareAssetsReq.NotebookMaxResults, "notebook-max-results", listProviderShareAssetsReq.NotebookMaxResults, `Maximum number of notebooks to return.`) - cmd.Flags().IntVar(&listProviderShareAssetsReq.TableMaxResults, "table-max-results", listProviderShareAssetsReq.TableMaxResults, `Maximum number of tables to return.`) - cmd.Flags().IntVar(&listProviderShareAssetsReq.VolumeMaxResults, "volume-max-results", listProviderShareAssetsReq.VolumeMaxResults, `Maximum number of volumes to return.`) + flags.IntPtrVar(cmd.Flags(), &listProviderShareAssetsReq.FunctionMaxResults, "function-max-results", `Maximum number of functions to return.`) + flags.IntPtrVar(cmd.Flags(), &listProviderShareAssetsReq.NotebookMaxResults, "notebook-max-results", `Maximum number of notebooks to return.`) + flags.IntPtrVar(cmd.Flags(), &listProviderShareAssetsReq.TableMaxResults, "table-max-results", `Maximum number of tables to return.`) + flags.IntPtrVar(cmd.Flags(), &listProviderShareAssetsReq.VolumeMaxResults, "volume-max-results", `Maximum number of volumes to return.`) cmd.Use = "list-provider-share-assets PROVIDER_NAME SHARE_NAME" cmd.Short = `List assets by provider share.` @@ -410,16 +429,25 @@ func newListProviderShareAssets() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listProviderShareAssetsReq.ProviderName = args[0] - listProviderShareAssetsReq.ShareName = args[1] + listProviderShareAssetsReq.ProviderNameArg = new(args[0]) + listProviderShareAssetsReq.ShareNameArg = new(args[1]) - response, err := w.Providers.ListProviderShareAssets(ctx, listProviderShareAssetsReq) + sdkReq, err := sharing.ListProviderShareAssetsRequestToSDK(&listProviderShareAssetsReq) + if err != nil { + return err + } + response, err := w.Sharing.ListProviderShareAssets(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.ListProviderShareAssetsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -440,13 +468,13 @@ func newListProviderShareAssets() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listSharesOverrides []func( *cobra.Command, - *sharing.ListSharesRequest, + *sharing.ListProviderSharesRequest, ) func newListShares() *cobra.Command { cmd := &cobra.Command{} + var listSharesReq sharing.ListProviderSharesRequest - var listSharesReq sharing.ListSharesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -456,9 +484,9 @@ func newListShares() *cobra.Command { cmd.Flags().IntVar(&listSharesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSharesReq.PageToken, "page-token", listSharesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSharesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listSharesReq.MaxResults, "max-results", listSharesReq.MaxResults, `Maximum number of shares to return.`) + flags.IntPtrVar(cmd.Flags(), &listSharesReq.MaxResults, "max-results", `Maximum number of shares to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list-shares NAME" @@ -480,11 +508,12 @@ func newListShares() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Providers drop-down.") - names, err := w.Providers.ProviderInfoNameToMetastoreIdMap(ctx, sharing.ListProvidersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Sharing.ListProvidersIter(ctx, sdksharing.ListProvidersRequest{}), []string{"Name"}, []string{"MetastoreId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Providers drop-down. Please manually specify required arguments. Original error: %w", err) @@ -498,17 +527,20 @@ func newListShares() *cobra.Command { if len(args) != 1 { return errors.New("expected to have name of the provider in which to list shares") } - listSharesReq.Name = args[0] + listSharesReq.ProviderNameArg = new(args[0]) - response := w.Providers.ListShares(ctx, listSharesReq) + sdkReq, err := sharing.ListProviderSharesRequestToSDK(&listSharesReq) + if err != nil { + return err + } if listSharesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSharesLimit) } if listSharesLimit > 0 { ctx = cmdio.WithLimit(ctx, listSharesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Sharing.ListProviderSharesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, sharing.ProviderShareFromSDK)) } // Disable completions since they are not applicable. @@ -529,21 +561,21 @@ func newListShares() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *sharing.UpdateProvider, + *sharing.UpdateProviderRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq sharing.UpdateProviderRequest - var updateReq sharing.UpdateProvider 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.Comment, "comment", updateReq.Comment, `Description about the provider.`) - cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the provider.`) - cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of Provider owner.`) - cmd.Flags().StringVar(&updateReq.RecipientProfileStr, "recipient-profile-str", updateReq.RecipientProfileStr, `This field is required when the __authentication_type__ is **TOKEN**, **OAUTH_CLIENT_CREDENTIALS** or not provided.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Comment, "comment", `Description about the provider.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.NewName, "new-name", `New name for the provider.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `Username of Provider owner.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.RecipientProfileStr, "recipient-profile-str", `This field is required when the __authentication_type__ is **TOKEN**, **OAUTH_CLIENT_CREDENTIALS** or not provided.`) cmd.Use = "update NAME" cmd.Short = `Update a provider.` @@ -565,6 +597,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -581,7 +614,7 @@ func newUpdate() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Providers drop-down.") - names, err := w.Providers.ProviderInfoNameToMetastoreIdMap(ctx, sharing.ListProvidersRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Sharing.ListProvidersIter(ctx, sdksharing.ListProvidersRequest{}), []string{"Name"}, []string{"MetastoreId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Providers drop-down. Please manually specify required arguments. Original error: %w", err) @@ -595,14 +628,22 @@ func newUpdate() *cobra.Command { if len(args) != 1 { return errors.New("expected to have name of the provider") } - updateReq.Name = args[0] + updateReq.NameArg = new(args[0]) - response, err := w.Providers.Update(ctx, updateReq) + sdkReq, err := sharing.UpdateProviderRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Sharing.UpdateProvider(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.ProviderInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go index b9a515c72cb..29d331ed328 100644 --- a/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go +++ b/cmd/workspace/quality-monitor-v2/quality-monitor-v2.go @@ -6,12 +6,17 @@ import ( "errors" "fmt" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/qualitymonitorv2" "github.com/spf13/cobra" + + domains "github.com/databricks/cli/libs/sdktypes/domains/v1" ) // Slice with functions to override default command behavior. @@ -56,14 +61,16 @@ Deprecated: Please use the Data Quality Monitoring API instead (REST: // Functions can be added from the `init()` function in manually curated files in this directory. var createQualityMonitorOverrides []func( *cobra.Command, - *qualitymonitorv2.CreateQualityMonitorRequest, + *map[string]any, ) func newCreateQualityMonitor() *cobra.Command { cmd := &cobra.Command{} + var createQualityMonitorReq map[string]any + createQualityMonitorReq = map[string]any{} + var createQualityMonitorObjectIdRaw string + var createQualityMonitorObjectTypeRaw string - var createQualityMonitorReq qualitymonitorv2.CreateQualityMonitorRequest - createQualityMonitorReq.QualityMonitor = qualitymonitorv2.QualityMonitor{} var createQualityMonitorJson flags.JsonFlag cmd.Flags().Var(&createQualityMonitorJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -104,9 +111,10 @@ Create a quality monitor. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := createQualityMonitorJson.Unmarshal(&createQualityMonitorReq.QualityMonitor) + diags := createQualityMonitorJson.Unmarshal(&createQualityMonitorReq) if diags.HasError() { return diags.Error() } @@ -118,17 +126,30 @@ Create a quality monitor. } } if !cmd.Flags().Changed("json") { - createQualityMonitorReq.QualityMonitor.ObjectType = args[0] + createQualityMonitorObjectTypeRaw = args[0] } if !cmd.Flags().Changed("json") { - createQualityMonitorReq.QualityMonitor.ObjectId = args[1] + createQualityMonitorObjectIdRaw = args[1] + } + + rawQuery := map[string]any{} + if cmd.Flags().Changed("object-id") || createQualityMonitorObjectIdRaw != "" { + createQualityMonitorReq["object_id"] = createQualityMonitorObjectIdRaw + } + if cmd.Flags().Changed("object-type") || createQualityMonitorObjectTypeRaw != "" { + createQualityMonitorReq["object_type"] = createQualityMonitorObjectTypeRaw } + rawPath := "/api/2.0/quality-monitors" - response, err := w.QualityMonitorV2.CreateQualityMonitor(ctx, createQualityMonitorReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createQualityMonitorReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -150,13 +171,15 @@ Create a quality monitor. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteQualityMonitorOverrides []func( *cobra.Command, - *qualitymonitorv2.DeleteQualityMonitorRequest, + *map[string]any, ) func newDeleteQualityMonitor() *cobra.Command { cmd := &cobra.Command{} - - var deleteQualityMonitorReq qualitymonitorv2.DeleteQualityMonitorRequest + var deleteQualityMonitorReq map[string]any + deleteQualityMonitorReq = map[string]any{} + var deleteQualityMonitorObjectIdRaw string + var deleteQualityMonitorObjectTypeRaw string cmd.Use = "delete-quality-monitor OBJECT_TYPE OBJECT_ID" cmd.Short = `*Beta* Delete a quality monitor.` @@ -184,11 +207,20 @@ Delete a quality monitor. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + deleteQualityMonitorObjectTypeRaw = args[0] + deleteQualityMonitorObjectIdRaw = args[1] - deleteQualityMonitorReq.ObjectType = args[0] - deleteQualityMonitorReq.ObjectId = args[1] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/quality-monitors/%s/%s", fmt.Sprint(deleteQualityMonitorObjectTypeRaw), fmt.Sprint(deleteQualityMonitorObjectIdRaw)) - err = w.QualityMonitorV2.DeleteQualityMonitor(ctx, deleteQualityMonitorReq) + maps.Copy(rawQuery, deleteQualityMonitorReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -213,13 +245,15 @@ Delete a quality monitor. // Functions can be added from the `init()` function in manually curated files in this directory. var getQualityMonitorOverrides []func( *cobra.Command, - *qualitymonitorv2.GetQualityMonitorRequest, + *map[string]any, ) func newGetQualityMonitor() *cobra.Command { cmd := &cobra.Command{} - - var getQualityMonitorReq qualitymonitorv2.GetQualityMonitorRequest + var getQualityMonitorReq map[string]any + getQualityMonitorReq = map[string]any{} + var getQualityMonitorObjectIdRaw string + var getQualityMonitorObjectTypeRaw string cmd.Use = "get-quality-monitor OBJECT_TYPE OBJECT_ID" cmd.Short = `*Beta* Read a quality monitor.` @@ -247,15 +281,24 @@ Read a quality monitor. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getQualityMonitorReq.ObjectType = args[0] - getQualityMonitorReq.ObjectId = args[1] + getQualityMonitorObjectTypeRaw = args[0] + getQualityMonitorObjectIdRaw = args[1] - response, err := w.QualityMonitorV2.GetQualityMonitor(ctx, getQualityMonitorReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/quality-monitors/%s/%s", fmt.Sprint(getQualityMonitorObjectTypeRaw), fmt.Sprint(getQualityMonitorObjectIdRaw)) + + maps.Copy(rawQuery, getQualityMonitorReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -277,26 +320,25 @@ Read a quality monitor. // Functions can be added from the `init()` function in manually curated files in this directory. var listQualityMonitorOverrides []func( *cobra.Command, - *qualitymonitorv2.ListQualityMonitorRequest, + *domains.DeleteDomainRequest, ) func newListQualityMonitor() *cobra.Command { cmd := &cobra.Command{} + var listQualityMonitorReq domains.DeleteDomainRequest - var listQualityMonitorReq qualitymonitorv2.ListQualityMonitorRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listQualityMonitorLimit int - cmd.Flags().IntVar(&listQualityMonitorReq.PageSize, "page-size", listQualityMonitorReq.PageSize, ``) + // TODO: field not in sdk-go request: page_size // Limit flag for total result capping. cmd.Flags().IntVar(&listQualityMonitorLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listQualityMonitorReq.PageToken, "page-token", listQualityMonitorReq.PageToken, `Pagination token.`) - cmd.Flags().Lookup("page-token").Hidden = true + // TODO: field not in sdk-go request: page_token cmd.Use = "list-quality-monitor" cmd.Short = `*Beta* List quality monitors.` @@ -320,16 +362,19 @@ List quality monitors. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.QualityMonitorV2.ListQualityMonitor(ctx, listQualityMonitorReq) - if listQualityMonitorLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listQualityMonitorLimit) + listQualityMonitorReq.Name = new("quality-monitors") + + sdkReq, err := domains.DeleteDomainRequestToSDK(&listQualityMonitorReq) + if err != nil { + return err } - if listQualityMonitorLimit > 0 { - ctx = cmdio.WithLimit(ctx, listQualityMonitorLimit) + err = w.Domains.DeleteDomain(ctx, *sdkReq) + if err != nil { + return err } - - return cmdio.RenderIterator(ctx, response) + return nil } // Disable completions since they are not applicable. @@ -350,14 +395,16 @@ List quality monitors. // Functions can be added from the `init()` function in manually curated files in this directory. var updateQualityMonitorOverrides []func( *cobra.Command, - *qualitymonitorv2.UpdateQualityMonitorRequest, + *map[string]any, ) func newUpdateQualityMonitor() *cobra.Command { cmd := &cobra.Command{} + var updateQualityMonitorReq map[string]any + updateQualityMonitorReq = map[string]any{} + var updateQualityMonitorObjectIdRaw string + var updateQualityMonitorObjectTypeRaw string - var updateQualityMonitorReq qualitymonitorv2.UpdateQualityMonitorRequest - updateQualityMonitorReq.QualityMonitor = qualitymonitorv2.QualityMonitor{} var updateQualityMonitorJson flags.JsonFlag cmd.Flags().Var(&updateQualityMonitorJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -401,9 +448,10 @@ Update a quality monitor. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := updateQualityMonitorJson.Unmarshal(&updateQualityMonitorReq.QualityMonitor) + diags := updateQualityMonitorJson.Unmarshal(&updateQualityMonitorReq) if diags.HasError() { return diags.Error() } @@ -414,20 +462,33 @@ Update a quality monitor. } } } - updateQualityMonitorReq.ObjectType = args[0] - updateQualityMonitorReq.ObjectId = args[1] + updateQualityMonitorObjectTypeRaw = args[0] + updateQualityMonitorObjectIdRaw = args[1] if !cmd.Flags().Changed("json") { - updateQualityMonitorReq.QualityMonitor.ObjectType = args[2] + updateQualityMonitorObjectTypeRaw = args[2] } if !cmd.Flags().Changed("json") { - updateQualityMonitorReq.QualityMonitor.ObjectId = args[3] + updateQualityMonitorObjectIdRaw = args[3] + } + + rawQuery := map[string]any{} + if cmd.Flags().Changed("object-id") || updateQualityMonitorObjectIdRaw != "" { + updateQualityMonitorReq["object_id"] = updateQualityMonitorObjectIdRaw + } + if cmd.Flags().Changed("object-type") || updateQualityMonitorObjectTypeRaw != "" { + updateQualityMonitorReq["object_type"] = updateQualityMonitorObjectTypeRaw } + rawPath := fmt.Sprintf("/api/2.0/quality-monitors/%s/%s", fmt.Sprint(updateQualityMonitorObjectTypeRaw), fmt.Sprint(updateQualityMonitorObjectIdRaw)) - response, err := w.QualityMonitorV2.UpdateQualityMonitor(ctx, updateQualityMonitorReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PUT", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateQualityMonitorReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/quality-monitors/quality-monitors.go b/cmd/workspace/quality-monitors/quality-monitors.go index c8d43ee3b7f..e5031f013dc 100644 --- a/cmd/workspace/quality-monitors/quality-monitors.go +++ b/cmd/workspace/quality-monitors/quality-monitors.go @@ -10,8 +10,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + qualitymonitors "github.com/databricks/cli/libs/qualitymonitors" ) // Slice with functions to override default command behavior. @@ -66,13 +67,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var cancelRefreshOverrides []func( *cobra.Command, - *catalog.CancelRefreshRequest, + *qualitymonitors.CancelRefreshRequest, ) func newCancelRefresh() *cobra.Command { cmd := &cobra.Command{} - - var cancelRefreshReq catalog.CancelRefreshRequest + var cancelRefreshReq qualitymonitors.CancelRefreshRequest cmd.Use = "cancel-refresh TABLE_NAME REFRESH_ID" cmd.Short = `Cancel refresh.` @@ -102,12 +102,15 @@ func newCancelRefresh() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w cancelRefreshReq.TableName = args[0] - _, err = fmt.Sscan(args[1], &cancelRefreshReq.RefreshId) + var cancelRefreshRefreshIdArg int64 + _, err = fmt.Sscan(args[1], &cancelRefreshRefreshIdArg) if err != nil { return fmt.Errorf("invalid REFRESH_ID: %s", args[1]) } + cancelRefreshReq.RefreshId = cancelRefreshRefreshIdArg err = w.QualityMonitors.CancelRefresh(ctx, cancelRefreshReq) if err != nil { @@ -134,13 +137,13 @@ func newCancelRefresh() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateMonitor, + *qualitymonitors.CreateMonitor, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq qualitymonitors.CreateMonitor - var createReq catalog.CreateMonitor var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -205,6 +208,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -230,7 +234,6 @@ func newCreate() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -252,13 +255,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteQualityMonitorRequest, + *qualitymonitors.DeleteQualityMonitorRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq catalog.DeleteQualityMonitorRequest + var deleteReq qualitymonitors.DeleteQualityMonitorRequest cmd.Use = "delete TABLE_NAME" cmd.Short = `Delete a table monitor.` @@ -296,6 +298,7 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w deleteReq.TableName = args[0] @@ -303,7 +306,6 @@ func newDelete() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -325,13 +327,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetQualityMonitorRequest, + *qualitymonitors.GetQualityMonitorRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq catalog.GetQualityMonitorRequest + var getReq qualitymonitors.GetQualityMonitorRequest cmd.Use = "get TABLE_NAME" cmd.Short = `Get a table monitor.` @@ -368,6 +369,7 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w getReq.TableName = args[0] @@ -375,7 +377,6 @@ func newGet() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -397,13 +398,12 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getRefreshOverrides []func( *cobra.Command, - *catalog.GetRefreshRequest, + *qualitymonitors.GetRefreshRequest, ) func newGetRefresh() *cobra.Command { cmd := &cobra.Command{} - - var getRefreshReq catalog.GetRefreshRequest + var getRefreshReq qualitymonitors.GetRefreshRequest cmd.Use = "get-refresh TABLE_NAME REFRESH_ID" cmd.Short = `Get refresh.` @@ -439,18 +439,20 @@ func newGetRefresh() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w getRefreshReq.TableName = args[0] - _, err = fmt.Sscan(args[1], &getRefreshReq.RefreshId) + var getRefreshRefreshIdArg int64 + _, err = fmt.Sscan(args[1], &getRefreshRefreshIdArg) if err != nil { return fmt.Errorf("invalid REFRESH_ID: %s", args[1]) } + getRefreshReq.RefreshId = getRefreshRefreshIdArg response, err := w.QualityMonitors.GetRefresh(ctx, getRefreshReq) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -472,13 +474,12 @@ func newGetRefresh() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listRefreshesOverrides []func( *cobra.Command, - *catalog.ListRefreshesRequest, + *qualitymonitors.ListRefreshesRequest, ) func newListRefreshes() *cobra.Command { cmd := &cobra.Command{} - - var listRefreshesReq catalog.ListRefreshesRequest + var listRefreshesReq qualitymonitors.ListRefreshesRequest cmd.Use = "list-refreshes TABLE_NAME" cmd.Short = `List refreshes.` @@ -514,6 +515,7 @@ func newListRefreshes() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w listRefreshesReq.TableName = args[0] @@ -521,7 +523,6 @@ func newListRefreshes() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -543,13 +544,13 @@ func newListRefreshes() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var regenerateDashboardOverrides []func( *cobra.Command, - *catalog.RegenerateDashboardRequest, + *qualitymonitors.RegenerateDashboardRequest, ) func newRegenerateDashboard() *cobra.Command { cmd := &cobra.Command{} + var regenerateDashboardReq qualitymonitors.RegenerateDashboardRequest - var regenerateDashboardReq catalog.RegenerateDashboardRequest var regenerateDashboardJson flags.JsonFlag cmd.Flags().Var(®enerateDashboardJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -594,6 +595,7 @@ func newRegenerateDashboard() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := regenerateDashboardJson.Unmarshal(®enerateDashboardReq) @@ -613,7 +615,6 @@ func newRegenerateDashboard() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -635,13 +636,12 @@ func newRegenerateDashboard() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var runRefreshOverrides []func( *cobra.Command, - *catalog.RunRefreshRequest, + *qualitymonitors.RunRefreshRequest, ) func newRunRefresh() *cobra.Command { cmd := &cobra.Command{} - - var runRefreshReq catalog.RunRefreshRequest + var runRefreshReq qualitymonitors.RunRefreshRequest cmd.Use = "run-refresh TABLE_NAME" cmd.Short = `Run refresh.` @@ -677,6 +677,7 @@ func newRunRefresh() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w runRefreshReq.TableName = args[0] @@ -684,7 +685,6 @@ func newRunRefresh() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -706,13 +706,13 @@ func newRunRefresh() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateMonitor, + *qualitymonitors.UpdateMonitor, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq qualitymonitors.UpdateMonitor - var updateReq catalog.UpdateMonitor var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -774,6 +774,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -796,7 +797,6 @@ func newUpdate() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/queries-legacy/queries-legacy.go b/cmd/workspace/queries-legacy/queries-legacy.go index c82909cdca8..6af21083bca 100644 --- a/cmd/workspace/queries-legacy/queries-legacy.go +++ b/cmd/workspace/queries-legacy/queries-legacy.go @@ -5,11 +5,14 @@ package queries_legacy import ( "fmt" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/sql" "github.com/spf13/cobra" ) @@ -60,24 +63,31 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *sql.QueryPostContent, + *map[string]any, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq map[string]any + createReq = map[string]any{} + var createDataSourceIdRaw string + var createDescriptionRaw string + var createNameRaw string + var createParentRaw string + var createQueryRaw string + var createRunAsRoleRaw string - var createReq sql.QueryPostContent 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.DataSourceId, "data-source-id", createReq.DataSourceId, `Data source ID maps to the ID of the data source used by the resource and is distinct from the warehouse ID.`) - cmd.Flags().StringVar(&createReq.Description, "description", createReq.Description, `General description that conveys additional information about this query such as usage notes.`) - cmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `The title of this query that appears in list views, widget headings, and on the query page.`) + cmd.Flags().StringVar(&createDataSourceIdRaw, "data-source-id", createDataSourceIdRaw, `Data source ID maps to the ID of the data source used by the resource and is distinct from the warehouse ID.`) + cmd.Flags().StringVar(&createDescriptionRaw, "description", createDescriptionRaw, `General description that conveys additional information about this query such as usage notes.`) + cmd.Flags().StringVar(&createNameRaw, "name", createNameRaw, `The title of this query that appears in list views, widget headings, and on the query page.`) // TODO: any: options - cmd.Flags().StringVar(&createReq.Parent, "parent", createReq.Parent, `The identifier of the workspace folder containing the object.`) - cmd.Flags().StringVar(&createReq.Query, "query", createReq.Query, `The text of the query to be run.`) - cmd.Flags().Var(&createReq.RunAsRole, "run-as-role", `Sets the **Run as** role for the object. Supported values: [owner, viewer]`) + cmd.Flags().StringVar(&createParentRaw, "parent", createParentRaw, `The identifier of the workspace folder containing the object.`) + cmd.Flags().StringVar(&createQueryRaw, "query", createQueryRaw, `The text of the query to be run.`) + flags.EnumVar(cmd.Flags(), &createRunAsRoleRaw, "run-as-role", `Sets the **Run as** role for the object. Supported values: [owner, viewer]`, "RunAsRole", "owner", "viewer") // TODO: array: tags cmd.Use = "create" @@ -112,6 +122,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -126,11 +137,36 @@ func newCreate() *cobra.Command { } } - response, err := w.QueriesLegacy.Create(ctx, createReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("data-source-id") || createDataSourceIdRaw != "" { + createReq["data_source_id"] = createDataSourceIdRaw + } + if cmd.Flags().Changed("description") || createDescriptionRaw != "" { + createReq["description"] = createDescriptionRaw + } + if cmd.Flags().Changed("name") || createNameRaw != "" { + createReq["name"] = createNameRaw + } + if cmd.Flags().Changed("parent") || createParentRaw != "" { + createReq["parent"] = createParentRaw + } + if cmd.Flags().Changed("query") || createQueryRaw != "" { + createReq["query"] = createQueryRaw + } + if cmd.Flags().Changed("run-as-role") || createRunAsRoleRaw != "" { + createReq["run_as_role"] = createRunAsRoleRaw + } + rawPath := "/api/2.0/preview/sql/queries" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -152,13 +188,14 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sql.DeleteQueriesLegacyRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sql.DeleteQueriesLegacyRequest + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteQueryIdRaw string cmd.Use = "delete QUERY_ID" cmd.Short = `Delete a query.` @@ -186,10 +223,19 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.QueryId = args[0] + deleteQueryIdRaw = args[0] - err = w.QueriesLegacy.Delete(ctx, deleteReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/preview/sql/queries/%s", fmt.Sprint(deleteQueryIdRaw)) + + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -214,13 +260,14 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *sql.GetQueriesLegacyRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq sql.GetQueriesLegacyRequest + var getReq map[string]any + getReq = map[string]any{} + var getQueryIdRaw string cmd.Use = "get QUERY_ID" cmd.Short = `Get a query definition.` @@ -247,14 +294,23 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getQueryIdRaw = args[0] - getReq.QueryId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/preview/sql/queries/%s", fmt.Sprint(getQueryIdRaw)) - response, err := w.QueriesLegacy.Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -276,28 +332,33 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *sql.ListQueriesLegacyRequest, + *map[string]any, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq map[string]any + listReq = map[string]any{} + var listOrderRaw string + var listPageRaw int + var listPageSizeRaw int + var listQRaw string - var listReq sql.ListQueriesLegacyRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.Order, "order", listReq.Order, `Name of query attribute to order by.`) - cmd.Flags().StringVar(&listReq.Q, "q", listReq.Q, `Full text search term.`) + cmd.Flags().StringVar(&listOrderRaw, "order", listOrderRaw, `Name of query attribute to order by.`) + cmd.Flags().StringVar(&listQRaw, "q", listQRaw, `Full text search term.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().IntVar(&listReq.Page, "page", listReq.Page, `Page number to retrieve.`) + cmd.Flags().IntVar(&listPageRaw, "page", listPageRaw, `Page number to retrieve.`) cmd.Flags().Lookup("page").Hidden = true - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `Number of results per API page.`) + cmd.Flags().IntVar(&listPageSizeRaw, "page-size", listPageSizeRaw, `Number of results per API page.`) cmd.Flags().Lookup("page-size").Hidden = true cmd.Use = "list" @@ -328,16 +389,37 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.QueriesLegacy.List(ctx, listReq) - if listLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("order") || listOrderRaw != "" { + rawQuery["order"] = listOrderRaw + } + if cmd.Flags().Changed("page") || listPageRaw != 0 { + rawQuery["page"] = listPageRaw } - if listLimit > 0 { - ctx = cmdio.WithLimit(ctx, listLimit) + if cmd.Flags().Changed("page-size") || listPageSizeRaw != 0 { + rawQuery["page_size"] = listPageSizeRaw } + if cmd.Flags().Changed("q") || listQRaw != "" { + rawQuery["q"] = listQRaw + } + rawPath := "/api/2.0/preview/sql/queries" - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) + if err != nil { + return err + } + if listLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -358,13 +440,14 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var restoreOverrides []func( *cobra.Command, - *sql.RestoreQueriesLegacyRequest, + *map[string]any, ) func newRestore() *cobra.Command { cmd := &cobra.Command{} - - var restoreReq sql.RestoreQueriesLegacyRequest + var restoreReq map[string]any + restoreReq = map[string]any{} + var restoreQueryIdRaw string cmd.Use = "restore QUERY_ID" cmd.Short = `Restore a query.` @@ -391,10 +474,18 @@ func newRestore() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + restoreQueryIdRaw = args[0] - restoreReq.QueryId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/preview/sql/queries/trash/%s", fmt.Sprint(restoreQueryIdRaw)) - err = w.QueriesLegacy.Restore(ctx, restoreReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, restoreReq, nil) if err != nil { return err } @@ -419,23 +510,30 @@ func newRestore() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *sql.QueryEditContent, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateDataSourceIdRaw string + var updateDescriptionRaw string + var updateNameRaw string + var updateQueryRaw string + var updateQueryIdRaw string + var updateRunAsRoleRaw string - var updateReq sql.QueryEditContent 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.DataSourceId, "data-source-id", updateReq.DataSourceId, `Data source ID maps to the ID of the data source used by the resource and is distinct from the warehouse ID.`) - cmd.Flags().StringVar(&updateReq.Description, "description", updateReq.Description, `General description that conveys additional information about this query such as usage notes.`) - cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `The title of this query that appears in list views, widget headings, and on the query page.`) + cmd.Flags().StringVar(&updateDataSourceIdRaw, "data-source-id", updateDataSourceIdRaw, `Data source ID maps to the ID of the data source used by the resource and is distinct from the warehouse ID.`) + cmd.Flags().StringVar(&updateDescriptionRaw, "description", updateDescriptionRaw, `General description that conveys additional information about this query such as usage notes.`) + cmd.Flags().StringVar(&updateNameRaw, "name", updateNameRaw, `The title of this query that appears in list views, widget headings, and on the query page.`) // TODO: any: options - cmd.Flags().StringVar(&updateReq.Query, "query", updateReq.Query, `The text of the query to be run.`) - cmd.Flags().Var(&updateReq.RunAsRole, "run-as-role", `Sets the **Run as** role for the object. Supported values: [owner, viewer]`) + cmd.Flags().StringVar(&updateQueryRaw, "query", updateQueryRaw, `The text of the query to be run.`) + flags.EnumVar(cmd.Flags(), &updateRunAsRoleRaw, "run-as-role", `Sets the **Run as** role for the object. Supported values: [owner, viewer]`, "RunAsRole", "owner", "viewer") // TODO: array: tags cmd.Use = "update QUERY_ID" @@ -464,6 +562,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -477,13 +576,35 @@ func newUpdate() *cobra.Command { } } } - updateReq.QueryId = args[0] + updateQueryIdRaw = args[0] - response, err := w.QueriesLegacy.Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("data-source-id") || updateDataSourceIdRaw != "" { + updateReq["data_source_id"] = updateDataSourceIdRaw + } + if cmd.Flags().Changed("description") || updateDescriptionRaw != "" { + updateReq["description"] = updateDescriptionRaw + } + if cmd.Flags().Changed("name") || updateNameRaw != "" { + updateReq["name"] = updateNameRaw + } + if cmd.Flags().Changed("query") || updateQueryRaw != "" { + updateReq["query"] = updateQueryRaw + } + if cmd.Flags().Changed("run-as-role") || updateRunAsRoleRaw != "" { + updateReq["run_as_role"] = updateRunAsRoleRaw + } + rawPath := fmt.Sprintf("/api/2.0/preview/sql/queries/%s", fmt.Sprint(updateQueryIdRaw)) + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/queries/overrides.go b/cmd/workspace/queries/overrides.go index 666cdfed53c..7079bd7c49d 100644 --- a/cmd/workspace/queries/overrides.go +++ b/cmd/workspace/queries/overrides.go @@ -2,11 +2,11 @@ package queries import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/sql" + queries "github.com/databricks/cli/libs/sdktypes/queries/v1" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *sql.ListQueriesRequest) { +func listOverride(listCmd *cobra.Command, listReq *queries.ListQueriesRequest) { // TODO: figure out colored/non-colored headers and colspan shifts listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "ID"}} {{header "Name"}} {{header "Author"}}`) diff --git a/cmd/workspace/queries/queries.go b/cmd/workspace/queries/queries.go index e0eb80cb58c..c85ae3f46b9 100644 --- a/cmd/workspace/queries/queries.go +++ b/cmd/workspace/queries/queries.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" + + queries "github.com/databricks/cli/libs/sdktypes/queries/v1" + sdkqueries "github.com/databricks/sdk-go/queries/v1" ) // Slice with functions to override default command behavior. @@ -56,18 +59,18 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *sql.CreateQueryRequest, + *queries.CreateQueryRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq queries.CreateQueryRequest - var createReq sql.CreateQueryRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createReq.AutoResolveDisplayName, "auto-resolve-display-name", createReq.AutoResolveDisplayName, `If true, automatically resolve query display name conflicts.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.AutoResolveDisplayName, "auto-resolve-display-name", `If true, automatically resolve query display name conflicts.`) // TODO: complex arg: query cmd.Use = "create" @@ -89,6 +92,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -103,12 +107,20 @@ func newCreate() *cobra.Command { } } - response, err := w.Queries.Create(ctx, createReq) + sdkReq, err := queries.CreateQueryRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Queries.CreateQuery(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := queries.QueryFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -129,13 +141,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sql.TrashQueryRequest, + *sdkqueries.TrashQueryRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sql.TrashQueryRequest + var deleteReq sdkqueries.TrashQueryRequest cmd.Use = "delete ID" cmd.Short = `Delete a query.` @@ -154,11 +165,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Queries drop-down.") - names, err := w.Queries.ListQueryObjectsResponseQueryDisplayNameToIdMap(ctx, sql.ListQueriesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Queries.ListQueriesIter(ctx, sdkqueries.ListQueriesRequest{}), []string{"DisplayName"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Queries drop-down. Please manually specify required arguments. Original error: %w", err) @@ -172,12 +184,15 @@ func newDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = w.Queries.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Queries.TrashQuery(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -199,13 +214,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *sql.GetQueryRequest, + *sdkqueries.GetQueryRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq sql.GetQueryRequest + var getReq sdkqueries.GetQueryRequest cmd.Use = "get ID" cmd.Short = `Get a query.` @@ -221,11 +235,12 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Queries drop-down.") - names, err := w.Queries.ListQueryObjectsResponseQueryDisplayNameToIdMap(ctx, sql.ListQueriesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Queries.ListQueriesIter(ctx, sdkqueries.ListQueriesRequest{}), []string{"DisplayName"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Queries drop-down. Please manually specify required arguments. Original error: %w", err) @@ -239,14 +254,19 @@ func newGet() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.Queries.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Queries.GetQuery(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := queries.QueryFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -267,25 +287,25 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *sql.ListQueriesRequest, + *queries.ListQueriesRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq queries.ListQueriesRequest - var listReq sql.ListQueriesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -309,16 +329,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Queries.List(ctx, listReq) + sdkReq, err := queries.ListQueriesRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Queries.ListQueriesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, queries.ListQueryObjectsResponseQueryFromSDK)) } // Disable completions since they are not applicable. @@ -339,25 +363,25 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listVisualizationsOverrides []func( *cobra.Command, - *sql.ListVisualizationsForQueryRequest, + *queries.ListVisualizationsForQueryRequest, ) func newListVisualizations() *cobra.Command { cmd := &cobra.Command{} + var listVisualizationsReq queries.ListVisualizationsForQueryRequest - var listVisualizationsReq sql.ListVisualizationsForQueryRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listVisualizationsLimit int - cmd.Flags().IntVar(&listVisualizationsReq.PageSize, "page-size", listVisualizationsReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listVisualizationsReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listVisualizationsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listVisualizationsReq.PageToken, "page-token", listVisualizationsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listVisualizationsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-visualizations ID" @@ -377,11 +401,12 @@ func newListVisualizations() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Queries drop-down.") - names, err := w.Queries.ListQueryObjectsResponseQueryDisplayNameToIdMap(ctx, sql.ListQueriesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Queries.ListQueriesIter(ctx, sdkqueries.ListQueriesRequest{}), []string{"DisplayName"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Queries drop-down. Please manually specify required arguments. Original error: %w", err) @@ -395,17 +420,20 @@ func newListVisualizations() *cobra.Command { if len(args) != 1 { return errors.New("expected to have ") } - listVisualizationsReq.Id = args[0] + listVisualizationsReq.Id = new(args[0]) - response := w.Queries.ListVisualizations(ctx, listVisualizationsReq) + sdkReq, err := queries.ListVisualizationsForQueryRequestToSDK(&listVisualizationsReq) + if err != nil { + return err + } if listVisualizationsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listVisualizationsLimit) } if listVisualizationsLimit > 0 { ctx = cmdio.WithLimit(ctx, listVisualizationsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Queries.ListVisualizationsForQueryIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, queries.VisualizationFromSDK)) } // Disable completions since they are not applicable. @@ -426,18 +454,18 @@ func newListVisualizations() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *sql.UpdateQueryRequest, + *queries.UpdateQueryRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq queries.UpdateQueryRequest - var updateReq sql.UpdateQueryRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&updateReq.AutoResolveDisplayName, "auto-resolve-display-name", updateReq.AutoResolveDisplayName, `If true, automatically resolve alert display name conflicts.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.AutoResolveDisplayName, "auto-resolve-display-name", `If true, automatically resolve alert display name conflicts.`) // TODO: complex arg: query cmd.Use = "update ID UPDATE_MASK" @@ -480,6 +508,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -493,17 +522,25 @@ func newUpdate() *cobra.Command { } } } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) if !cmd.Flags().Changed("json") { - updateReq.UpdateMask = args[1] + updateReq.UpdateMask = new(args[1]) } - response, err := w.Queries.Update(ctx, updateReq) + sdkReq, err := queries.UpdateQueryRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Queries.UpdateQuery(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := queries.QueryFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/query-history/overrides.go b/cmd/workspace/query-history/overrides.go index cd161ea503b..3ce97ea18a7 100644 --- a/cmd/workspace/query-history/overrides.go +++ b/cmd/workspace/query-history/overrides.go @@ -2,11 +2,11 @@ package query_history import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/sql" + queryhistory "github.com/databricks/cli/libs/sdktypes/queryhistory/v1" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *sql.ListQueryHistoryRequest) { +func listOverride(listCmd *cobra.Command, listReq *queryhistory.ListQueriesRequest) { // TODO: figure out the right format listCmd.Annotations["template"] = cmdio.Heredoc(` {{range .Res}}{{.UserName}} {{cyan "%s" .Status}} {{.QueryText}} diff --git a/cmd/workspace/query-history/query-history.go b/cmd/workspace/query-history/query-history.go index fc9b0a1aa6e..4e6654f370a 100644 --- a/cmd/workspace/query-history/query-history.go +++ b/cmd/workspace/query-history/query-history.go @@ -6,8 +6,10 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/flags" "github.com/spf13/cobra" + + queryhistory "github.com/databricks/cli/libs/sdktypes/queryhistory/v1" ) // Slice with functions to override default command behavior. @@ -45,18 +47,17 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *sql.ListQueryHistoryRequest, + *queryhistory.ListQueriesRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} - - var listReq sql.ListQueryHistoryRequest + var listReq queryhistory.ListQueriesRequest // TODO: complex arg: filter_by - cmd.Flags().BoolVar(&listReq.IncludeMetrics, "include-metrics", listReq.IncludeMetrics, `Whether to include the query metrics with each query.`) - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Limit the number of results returned in one page.`) - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `A token that can be used to get the next page of results.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeMetrics, "include-metrics", `Whether to include the query metrics with each query.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Limit the number of results returned in one page.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `A token that can be used to get the next page of results.`) cmd.Use = "list" cmd.Short = `List Queries.` @@ -82,13 +83,22 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response, err := w.QueryHistory.List(ctx, listReq) + sdkReq, err := queryhistory.ListQueriesRequestToSDK(&listReq) + if err != nil { + return err + } + response, err := w.QueryHistory.ListQueries(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := queryhistory.ListQueriesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go b/cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go index 59a1594c7bf..dbcb70aa95b 100644 --- a/cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go +++ b/cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go @@ -4,12 +4,16 @@ package query_visualizations_legacy import ( "errors" + "fmt" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/sql" "github.com/spf13/cobra" ) @@ -59,19 +63,24 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *sql.CreateQueryVisualizationsLegacyRequest, + *map[string]any, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq map[string]any + createReq = map[string]any{} + var createDescriptionRaw string + var createNameRaw string + var createQueryIdRaw string + var createTypeRaw string - var createReq sql.CreateQueryVisualizationsLegacyRequest 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.Description, "description", createReq.Description, `A short description of this visualization.`) - cmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `The name of the visualization that appears on dashboards and the query screen.`) + cmd.Flags().StringVar(&createDescriptionRaw, "description", createDescriptionRaw, `A short description of this visualization.`) + cmd.Flags().StringVar(&createNameRaw, "name", createNameRaw, `The name of the visualization that appears on dashboards and the query screen.`) cmd.Use = "create" cmd.Short = `Add visualization to a query.` @@ -92,6 +101,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -108,11 +118,30 @@ func newCreate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.QueryVisualizationsLegacy.Create(ctx, createReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("description") || createDescriptionRaw != "" { + createReq["description"] = createDescriptionRaw + } + if cmd.Flags().Changed("name") || createNameRaw != "" { + createReq["name"] = createNameRaw + } + if cmd.Flags().Changed("query-id") || createQueryIdRaw != "" { + createReq["query_id"] = createQueryIdRaw + } + if cmd.Flags().Changed("type") || createTypeRaw != "" { + createReq["type"] = createTypeRaw + } + rawPath := "/api/2.0/preview/sql/visualizations" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -134,13 +163,14 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sql.DeleteQueryVisualizationsLegacyRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sql.DeleteQueryVisualizationsLegacyRequest + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteIdRaw string cmd.Use = "delete ID" cmd.Short = `Remove visualization.` @@ -169,10 +199,19 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + deleteIdRaw = args[0] - deleteReq.Id = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/preview/sql/visualizations/%s", fmt.Sprint(deleteIdRaw)) - err = w.QueryVisualizationsLegacy.Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -197,25 +236,32 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *sql.LegacyVisualization, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateCreatedAtRaw string + var updateDescriptionRaw string + var updateIdRaw string + var updateNameRaw string + var updateTypeRaw string + var updateUpdatedAtRaw string - var updateReq sql.LegacyVisualization 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.CreatedAt, "created-at", updateReq.CreatedAt, ``) - cmd.Flags().StringVar(&updateReq.Description, "description", updateReq.Description, `A short description of this visualization.`) - cmd.Flags().StringVar(&updateReq.Id, "id", updateReq.Id, `The UUID for this visualization.`) - cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `The name of the visualization that appears on dashboards and the query screen.`) + cmd.Flags().StringVar(&updateCreatedAtRaw, "created-at", updateCreatedAtRaw, ``) + cmd.Flags().StringVar(&updateDescriptionRaw, "description", updateDescriptionRaw, `A short description of this visualization.`) + cmd.Flags().StringVar(&updateIdRaw, "id", updateIdRaw, `The UUID for this visualization.`) + cmd.Flags().StringVar(&updateNameRaw, "name", updateNameRaw, `The name of the visualization that appears on dashboards and the query screen.`) // TODO: any: options // TODO: complex arg: query - cmd.Flags().StringVar(&updateReq.Type, "type", updateReq.Type, `The type of visualization: chart, table, pivot table, and so on.`) - cmd.Flags().StringVar(&updateReq.UpdatedAt, "updated-at", updateReq.UpdatedAt, ``) + cmd.Flags().StringVar(&updateTypeRaw, "type", updateTypeRaw, `The type of visualization: chart, table, pivot table, and so on.`) + cmd.Flags().StringVar(&updateUpdatedAtRaw, "updated-at", updateUpdatedAtRaw, ``) cmd.Use = "update" cmd.Short = `Edit existing visualization.` @@ -241,6 +287,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -255,11 +302,36 @@ func newUpdate() *cobra.Command { } } - response, err := w.QueryVisualizationsLegacy.Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("created-at") || updateCreatedAtRaw != "" { + updateReq["created_at"] = updateCreatedAtRaw + } + if cmd.Flags().Changed("description") || updateDescriptionRaw != "" { + updateReq["description"] = updateDescriptionRaw + } + if cmd.Flags().Changed("id") || updateIdRaw != "" { + updateReq["id"] = updateIdRaw + } + if cmd.Flags().Changed("name") || updateNameRaw != "" { + updateReq["name"] = updateNameRaw + } + if cmd.Flags().Changed("type") || updateTypeRaw != "" { + updateReq["type"] = updateTypeRaw + } + if cmd.Flags().Changed("updated-at") || updateUpdatedAtRaw != "" { + updateReq["updated_at"] = updateUpdatedAtRaw + } + rawPath := fmt.Sprintf("/api/2.0/preview/sql/visualizations/%s", fmt.Sprint(updateIdRaw)) + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/query-visualizations/query-visualizations.go b/cmd/workspace/query-visualizations/query-visualizations.go index 4e2b50c8687..8a583a7e730 100644 --- a/cmd/workspace/query-visualizations/query-visualizations.go +++ b/cmd/workspace/query-visualizations/query-visualizations.go @@ -4,12 +4,16 @@ package query_visualizations import ( "errors" + "fmt" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/sql" "github.com/spf13/cobra" ) @@ -54,13 +58,14 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *sql.CreateVisualizationRequest, + *map[string]any, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq map[string]any + createReq = map[string]any{} - var createReq sql.CreateVisualizationRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -86,6 +91,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -100,11 +106,18 @@ func newCreate() *cobra.Command { } } - response, err := w.QueryVisualizations.Create(ctx, createReq) + rawQuery := map[string]any{} + rawPath := "/api/2.0/sql/visualizations" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -126,13 +139,14 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sql.DeleteVisualizationRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sql.DeleteVisualizationRequest + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteIdRaw string cmd.Use = "delete ID" cmd.Short = `Remove a visualization.` @@ -153,10 +167,19 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Id = args[0] + deleteIdRaw = args[0] - err = w.QueryVisualizations.Delete(ctx, deleteReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/sql/visualizations/%s", fmt.Sprint(deleteIdRaw)) + + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -181,13 +204,16 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *sql.UpdateVisualizationRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateIdRaw string + var updateUpdateMaskRaw string - var updateReq sql.UpdateVisualizationRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -234,6 +260,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -247,16 +274,26 @@ func newUpdate() *cobra.Command { } } } - updateReq.Id = args[0] + updateIdRaw = args[0] if !cmd.Flags().Changed("json") { - updateReq.UpdateMask = args[1] + updateUpdateMaskRaw = args[1] + } + + rawQuery := map[string]any{} + if cmd.Flags().Changed("update-mask") || updateUpdateMaskRaw != "" { + updateReq["update_mask"] = updateUpdateMaskRaw } + rawPath := fmt.Sprintf("/api/2.0/sql/visualizations/%s", fmt.Sprint(updateIdRaw)) - response, err := w.QueryVisualizations.Update(ctx, updateReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/recipient-activation/recipient-activation.go b/cmd/workspace/recipient-activation/recipient-activation.go index 0260cd5785f..c23cf46f273 100644 --- a/cmd/workspace/recipient-activation/recipient-activation.go +++ b/cmd/workspace/recipient-activation/recipient-activation.go @@ -6,8 +6,10 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/sharing" "github.com/spf13/cobra" + + sharing "github.com/databricks/cli/libs/sdktypes/sharing/v1" + sdksharing "github.com/databricks/sdk-go/sharing/v1" ) // Slice with functions to override default command behavior. @@ -54,13 +56,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getActivationUrlInfoOverrides []func( *cobra.Command, - *sharing.GetActivationUrlInfoRequest, + *sdksharing.GetActivationUrlInfoRequest, ) func newGetActivationUrlInfo() *cobra.Command { cmd := &cobra.Command{} - - var getActivationUrlInfoReq sharing.GetActivationUrlInfoRequest + var getActivationUrlInfoReq sdksharing.GetActivationUrlInfoRequest cmd.Use = "get-activation-url-info ACTIVATION_URL" cmd.Short = `Get a share activation URL.` @@ -84,13 +85,17 @@ func newGetActivationUrlInfo() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getActivationUrlInfoReq.ActivationUrl = args[0] + getActivationUrlInfoReq.ActivationUrl = new(args[0]) - err = w.RecipientActivation.GetActivationUrlInfo(ctx, getActivationUrlInfoReq) + sdkReq := &getActivationUrlInfoReq + response, err := w.Sharing.GetActivationUrlInfo(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -112,13 +117,12 @@ func newGetActivationUrlInfo() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var retrieveTokenOverrides []func( *cobra.Command, - *sharing.RetrieveTokenRequest, + *sdksharing.RetrieveTokenRequest, ) func newRetrieveToken() *cobra.Command { cmd := &cobra.Command{} - - var retrieveTokenReq sharing.RetrieveTokenRequest + var retrieveTokenReq sdksharing.RetrieveTokenRequest cmd.Use = "retrieve-token ACTIVATION_URL" cmd.Short = `Get an access token.` @@ -143,15 +147,21 @@ func newRetrieveToken() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - retrieveTokenReq.ActivationUrl = args[0] + retrieveTokenReq.ActivationUrl = new(args[0]) - response, err := w.RecipientActivation.RetrieveToken(ctx, retrieveTokenReq) + sdkReq := &retrieveTokenReq + response, err := w.Sharing.RetrieveAccessToken(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.RetrieveTokenResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/recipient-federation-policies/recipient-federation-policies.go b/cmd/workspace/recipient-federation-policies/recipient-federation-policies.go index 8da45672e62..4ae8c62f729 100644 --- a/cmd/workspace/recipient-federation-policies/recipient-federation-policies.go +++ b/cmd/workspace/recipient-federation-policies/recipient-federation-policies.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/sharing" "github.com/spf13/cobra" + + sharing "github.com/databricks/cli/libs/sdktypes/sharing/v1" + sdksharing "github.com/databricks/sdk-go/sharing/v1" ) // Slice with functions to override default command behavior. @@ -81,15 +84,15 @@ var createOverrides []func( func newCreate() *cobra.Command { cmd := &cobra.Command{} - var createReq sharing.CreateFederationPolicyRequest - createReq.Policy = sharing.FederationPolicy{} + createReq.Policy = &sharing.FederationPolicy{} + 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.Policy.Comment, "comment", createReq.Policy.Comment, `Description of the policy.`) - cmd.Flags().StringVar(&createReq.Policy.Name, "name", createReq.Policy.Name, `Name of the federation policy.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Policy.Comment, "comment", `Description of the policy.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Policy.Name, "name", `Name of the federation policy.`) // TODO: complex arg: oidc_policy cmd.Use = "create RECIPIENT_NAME" @@ -142,6 +145,7 @@ Create recipient federation policy. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.Policy) @@ -155,14 +159,22 @@ Create recipient federation policy. } } } - createReq.RecipientName = args[0] + createReq.RecipientName = new(args[0]) - response, err := w.RecipientFederationPolicies.Create(ctx, createReq) + sdkReq, err := sharing.CreateFederationPolicyRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Sharing.CreateFederationPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.FederationPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -183,13 +195,12 @@ Create recipient federation policy. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sharing.DeleteFederationPolicyRequest, + *sdksharing.DeleteFederationPolicyRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sharing.DeleteFederationPolicyRequest + var deleteReq sdksharing.DeleteFederationPolicyRequest cmd.Use = "delete RECIPIENT_NAME NAME" cmd.Short = `*Public Preview* Delete recipient federation policy.` @@ -218,11 +229,13 @@ Delete recipient federation policy. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.RecipientName = args[0] - deleteReq.Name = args[1] + deleteReq.RecipientName = new(args[0]) + deleteReq.Name = new(args[1]) - err = w.RecipientFederationPolicies.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = w.Sharing.DeleteFederationPolicy(ctx, *sdkReq) if err != nil { return err } @@ -247,13 +260,12 @@ Delete recipient federation policy. // Functions can be added from the `init()` function in manually curated files in this directory. var getFederationPolicyOverrides []func( *cobra.Command, - *sharing.GetFederationPolicyRequest, + *sdksharing.GetFederationPolicyRequest, ) func newGetFederationPolicy() *cobra.Command { cmd := &cobra.Command{} - - var getFederationPolicyReq sharing.GetFederationPolicyRequest + var getFederationPolicyReq sdksharing.GetFederationPolicyRequest cmd.Use = "get-federation-policy RECIPIENT_NAME NAME" cmd.Short = `*Public Preview* Get recipient federation policy.` @@ -283,16 +295,22 @@ Get recipient federation policy. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getFederationPolicyReq.RecipientName = args[0] - getFederationPolicyReq.Name = args[1] + getFederationPolicyReq.RecipientName = new(args[0]) + getFederationPolicyReq.Name = new(args[1]) - response, err := w.RecipientFederationPolicies.GetFederationPolicy(ctx, getFederationPolicyReq) + sdkReq := &getFederationPolicyReq + response, err := w.Sharing.GetFederationPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.FederationPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -318,20 +336,20 @@ var listOverrides []func( func newList() *cobra.Command { cmd := &cobra.Command{} - var listReq sharing.ListFederationPoliciesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list RECIPIENT_NAME" @@ -361,18 +379,22 @@ List recipient federation policies. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.RecipientName = args[0] + listReq.RecipientName = new(args[0]) - response := w.RecipientFederationPolicies.List(ctx, listReq) + sdkReq, err := sharing.ListFederationPoliciesRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Sharing.ListFederationPoliciesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, sharing.FederationPolicyFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/recipients/recipients.go b/cmd/workspace/recipients/recipients.go index ca02fb4d904..e6a14a4836d 100644 --- a/cmd/workspace/recipients/recipients.go +++ b/cmd/workspace/recipients/recipients.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/sharing" "github.com/spf13/cobra" + + sharing "github.com/databricks/cli/libs/sdktypes/sharing/v1" + sdksharing "github.com/databricks/sdk-go/sharing/v1" ) // Slice with functions to override default command behavior. @@ -70,24 +73,24 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *sharing.CreateRecipient, + *sharing.CreateRecipientRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq sharing.CreateRecipientRequest - var createReq sharing.CreateRecipient 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.Comment, "comment", createReq.Comment, `Description about the recipient.`) - cmd.Flags().StringVar(&createReq.DataRecipientGlobalMetastoreId, "data-recipient-global-metastore-id", createReq.DataRecipientGlobalMetastoreId, `The global Unity Catalog metastore id provided by the data recipient.`) - cmd.Flags().Int64Var(&createReq.ExpirationTime, "expiration-time", createReq.ExpirationTime, `Expiration timestamp of the token, in epoch milliseconds.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Comment, "comment", `Description about the recipient.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DataRecipientGlobalMetastoreId, "data-recipient-global-metastore-id", `The global Unity Catalog metastore id provided by the data recipient.`) + flags.Int64PtrVar(cmd.Flags(), &createReq.ExpirationTime, "expiration-time", `Expiration timestamp of the token, in epoch milliseconds.`) // TODO: complex arg: ip_access_list - cmd.Flags().StringVar(&createReq.Owner, "owner", createReq.Owner, `Username of the recipient owner.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Owner, "owner", `Username of the recipient owner.`) // TODO: complex arg: properties_kvpairs - cmd.Flags().StringVar(&createReq.SharingCode, "sharing-code", createReq.SharingCode, `The one-time sharing code provided by the data recipient.`) + flags.StringPtrVar(cmd.Flags(), &createReq.SharingCode, "sharing-code", `The one-time sharing code provided by the data recipient.`) cmd.Use = "create NAME AUTHENTICATION_TYPE" cmd.Short = `Create a share recipient.` @@ -122,6 +125,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -136,22 +140,26 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Name = args[0] + createReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createReq.AuthenticationType) - if err != nil { - return fmt.Errorf("invalid AUTHENTICATION_TYPE: %s", args[1]) - } - + createReq.AuthenticationType = sharing.DeltaSharingAuthenticationType(args[1]) } - response, err := w.Recipients.Create(ctx, createReq) + sdkReq, err := sharing.CreateRecipientRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Sharing.CreateRecipient(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.RecipientInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -172,13 +180,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sharing.DeleteRecipientRequest, + *sdksharing.DeleteRecipientRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sharing.DeleteRecipientRequest + var deleteReq sdksharing.DeleteRecipientRequest cmd.Use = "delete NAME" cmd.Short = `Delete a share recipient.` @@ -203,13 +210,17 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Name = args[0] + deleteReq.Name = new(args[0]) - err = w.Recipients.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Sharing.DeleteRecipient(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -231,13 +242,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *sharing.GetRecipientRequest, + *sdksharing.GetRecipientRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq sharing.GetRecipientRequest + var getReq sdksharing.GetRecipientRequest cmd.Use = "get NAME" cmd.Short = `Get a share recipient.` @@ -263,15 +273,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Name = args[0] + getReq.Name = new(args[0]) - response, err := w.Recipients.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Sharing.GetRecipient(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.RecipientInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -297,22 +313,22 @@ var listOverrides []func( func newList() *cobra.Command { cmd := &cobra.Command{} - var listReq sharing.ListRecipientsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.DataRecipientGlobalMetastoreId, "data-recipient-global-metastore-id", listReq.DataRecipientGlobalMetastoreId, `If not provided, all recipients will be returned.`) + flags.StringPtrVar(cmd.Flags(), &listReq.DataRecipientGlobalMetastoreId, "data-recipient-global-metastore-id", `If not provided, all recipients will be returned.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of recipients to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of recipients to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list" @@ -337,16 +353,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Recipients.List(ctx, listReq) + sdkReq, err := sharing.ListRecipientsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Sharing.ListRecipientsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, sharing.RecipientInfoFromSDK)) } // Disable completions since they are not applicable. @@ -367,13 +387,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var rotateTokenOverrides []func( *cobra.Command, - *sharing.RotateRecipientToken, + *sharing.RotateRecipientTokenRequest, ) func newRotateToken() *cobra.Command { cmd := &cobra.Command{} + var rotateTokenReq sharing.RotateRecipientTokenRequest - var rotateTokenReq sharing.RotateRecipientToken var rotateTokenJson flags.JsonFlag cmd.Flags().Var(&rotateTokenJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -412,6 +432,7 @@ func newRotateToken() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := rotateTokenJson.Unmarshal(&rotateTokenReq) @@ -425,21 +446,30 @@ func newRotateToken() *cobra.Command { } } } - rotateTokenReq.Name = args[0] + rotateTokenReq.Name = new(args[0]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &rotateTokenReq.ExistingTokenExpireInSeconds) + var rotateTokenExistingTokenExpireInSecondsArg int64 + _, err = fmt.Sscan(args[1], &rotateTokenExistingTokenExpireInSecondsArg) if err != nil { return fmt.Errorf("invalid EXISTING_TOKEN_EXPIRE_IN_SECONDS: %s", args[1]) } - + rotateTokenReq.ExistingTokenExpireInSeconds = &rotateTokenExistingTokenExpireInSecondsArg } - response, err := w.Recipients.RotateToken(ctx, rotateTokenReq) + sdkReq, err := sharing.RotateRecipientTokenRequestToSDK(&rotateTokenReq) + if err != nil { + return err + } + response, err := w.Sharing.RotateRecipientToken(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.RecipientInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -460,16 +490,15 @@ func newRotateToken() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var sharePermissionsOverrides []func( *cobra.Command, - *sharing.SharePermissionsRequest, + *sharing.ListRecipientSharePermissionsRequest, ) func newSharePermissions() *cobra.Command { cmd := &cobra.Command{} + var sharePermissionsReq sharing.ListRecipientSharePermissionsRequest - var sharePermissionsReq sharing.SharePermissionsRequest - - cmd.Flags().IntVar(&sharePermissionsReq.MaxResults, "max-results", sharePermissionsReq.MaxResults, `Maximum number of permissions to return.`) - cmd.Flags().StringVar(&sharePermissionsReq.PageToken, "page-token", sharePermissionsReq.PageToken, `Opaque pagination token to go to next page based on previous query.`) + flags.IntPtrVar(cmd.Flags(), &sharePermissionsReq.MaxResults, "max-results", `Maximum number of permissions to return.`) + flags.StringPtrVar(cmd.Flags(), &sharePermissionsReq.PageToken, "page-token", `Opaque pagination token to go to next page based on previous query.`) cmd.Use = "share-permissions NAME" cmd.Short = `Get recipient share permissions.` @@ -495,15 +524,24 @@ func newSharePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - sharePermissionsReq.Name = args[0] + sharePermissionsReq.Name = new(args[0]) - response, err := w.Recipients.SharePermissions(ctx, sharePermissionsReq) + sdkReq, err := sharing.ListRecipientSharePermissionsRequestToSDK(&sharePermissionsReq) + if err != nil { + return err + } + response, err := w.Sharing.ListRecipientSharePermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.GetRecipientSharePermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -524,22 +562,22 @@ func newSharePermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *sharing.UpdateRecipient, + *sharing.UpdateRecipientRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq sharing.UpdateRecipientRequest - var updateReq sharing.UpdateRecipient 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.Comment, "comment", updateReq.Comment, `Description about the recipient.`) - cmd.Flags().Int64Var(&updateReq.ExpirationTime, "expiration-time", updateReq.ExpirationTime, `Expiration timestamp of the token, in epoch milliseconds.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Comment, "comment", `Description about the recipient.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.ExpirationTime, "expiration-time", `Expiration timestamp of the token, in epoch milliseconds.`) // TODO: complex arg: ip_access_list - cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the recipient.`) - cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of the recipient owner.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.NewName, "new-name", `New name for the recipient.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `Username of the recipient owner.`) // TODO: complex arg: properties_kvpairs cmd.Use = "update NAME" @@ -566,6 +604,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -579,14 +618,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.Name = args[0] + updateReq.NameArg = new(args[0]) - response, err := w.Recipients.Update(ctx, updateReq) + sdkReq, err := sharing.UpdateRecipientRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Sharing.UpdateRecipient(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.RecipientInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/redash-config/redash-config.go b/cmd/workspace/redash-config/redash-config.go index 5497537c8a7..7f0fcb3c83e 100644 --- a/cmd/workspace/redash-config/redash-config.go +++ b/cmd/workspace/redash-config/redash-config.go @@ -3,7 +3,11 @@ package redash_config import ( + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/spf13/cobra" @@ -63,11 +67,21 @@ func newGetConfig() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.RedashConfig.GetConfig(ctx) + _ = w + getConfigReq := map[string]any{} + rawQuery := map[string]any{} + rawPath := "/api/2.0/redash-v2/config" + + maps.Copy(rawQuery, getConfigReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/registered-models/registered-models.go b/cmd/workspace/registered-models/registered-models.go index 43e7acccda1..0b8da254917 100644 --- a/cmd/workspace/registered-models/registered-models.go +++ b/cmd/workspace/registered-models/registered-models.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucregisteredmodels "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1" + sdkucregisteredmodels "github.com/databricks/sdk-go/uc/registeredmodels/v1" ) // Slice with functions to override default command behavior. @@ -82,30 +85,30 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateRegisteredModelRequest, + *ucregisteredmodels.CreateRegisteredModelRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq ucregisteredmodels.CreateRegisteredModelRequest - var createReq catalog.CreateRegisteredModelRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: aliases - cmd.Flags().StringVar(&createReq.CatalogName, "catalog-name", createReq.CatalogName, `The name of the catalog where the schema and the registered model reside.`) - cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `The comment attached to the registered model.`) - cmd.Flags().Int64Var(&createReq.CreatedAt, "created-at", createReq.CreatedAt, `Creation timestamp of the registered model in milliseconds since the Unix epoch.`) - cmd.Flags().StringVar(&createReq.CreatedBy, "created-by", createReq.CreatedBy, `The identifier of the user who created the registered model.`) - cmd.Flags().StringVar(&createReq.FullName, "full-name", createReq.FullName, `The three-level (fully qualified) name of the registered model.`) - cmd.Flags().StringVar(&createReq.MetastoreId, "metastore-id", createReq.MetastoreId, `The unique identifier of the metastore.`) - cmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `The name of the registered model.`) - cmd.Flags().StringVar(&createReq.Owner, "owner", createReq.Owner, `The identifier of the user who owns the registered model.`) - cmd.Flags().StringVar(&createReq.SchemaName, "schema-name", createReq.SchemaName, `The name of the schema where the registered model resides.`) - cmd.Flags().StringVar(&createReq.StorageLocation, "storage-location", createReq.StorageLocation, `The storage location on the cloud under which model version data files are stored.`) - cmd.Flags().Int64Var(&createReq.UpdatedAt, "updated-at", createReq.UpdatedAt, `Last-update timestamp of the registered model in milliseconds since the Unix epoch.`) - cmd.Flags().StringVar(&createReq.UpdatedBy, "updated-by", createReq.UpdatedBy, `The identifier of the user who updated the registered model last time.`) + flags.StringPtrVar(cmd.Flags(), &createReq.CatalogName, "catalog-name", `The name of the catalog where the schema and the registered model reside.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Comment, "comment", `The comment attached to the registered model.`) + flags.Int64PtrVar(cmd.Flags(), &createReq.CreatedAt, "created-at", `Creation timestamp of the registered model in milliseconds since the Unix epoch.`) + flags.StringPtrVar(cmd.Flags(), &createReq.CreatedBy, "created-by", `The identifier of the user who created the registered model.`) + flags.StringPtrVar(cmd.Flags(), &createReq.FullName, "full-name", `The three-level (fully qualified) name of the registered model.`) + flags.StringPtrVar(cmd.Flags(), &createReq.MetastoreId, "metastore-id", `The unique identifier of the metastore.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Name, "name", `The name of the registered model.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Owner, "owner", `The identifier of the user who owns the registered model.`) + flags.StringPtrVar(cmd.Flags(), &createReq.SchemaName, "schema-name", `The name of the schema where the registered model resides.`) + flags.StringPtrVar(cmd.Flags(), &createReq.StorageLocation, "storage-location", `The storage location on the cloud under which model version data files are stored.`) + flags.Int64PtrVar(cmd.Flags(), &createReq.UpdatedAt, "updated-at", `Last-update timestamp of the registered model in milliseconds since the Unix epoch.`) + flags.StringPtrVar(cmd.Flags(), &createReq.UpdatedBy, "updated-by", `The identifier of the user who updated the registered model last time.`) cmd.Use = "create" cmd.Short = `Create a Registered Model.` @@ -137,6 +140,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -151,12 +155,20 @@ func newCreate() *cobra.Command { } } - response, err := w.RegisteredModels.Create(ctx, createReq) + sdkReq, err := ucregisteredmodels.CreateRegisteredModelRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.RegisteredModels.CreateRegisteredModel(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucregisteredmodels.RegisteredModelInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -177,13 +189,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteRegisteredModelRequest, + *sdkucregisteredmodels.DeleteRegisteredModelRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq catalog.DeleteRegisteredModelRequest + var deleteReq sdkucregisteredmodels.DeleteRegisteredModelRequest cmd.Use = "delete FULL_NAME" cmd.Short = `Delete a Registered Model.` @@ -208,11 +219,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No FULL_NAME argument specified. Loading names for Registered Models drop-down.") - names, err := w.RegisteredModels.RegisteredModelInfoNameToFullNameMap(ctx, catalog.ListRegisteredModelsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.RegisteredModels.ListRegisteredModelsIter(ctx, sdkucregisteredmodels.ListRegisteredModelsRequest{}), []string{"Name"}, []string{"FullName"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Registered Models drop-down. Please manually specify required arguments. Original error: %w", err) @@ -226,12 +238,15 @@ func newDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the three-level (fully qualified) name of the registered model") } - deleteReq.FullName = args[0] + deleteReq.FullNameArg = new(args[0]) - err = w.RegisteredModels.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.RegisteredModels.DeleteRegisteredModel(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -253,13 +268,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteAliasOverrides []func( *cobra.Command, - *catalog.DeleteAliasRequest, + *sdkucregisteredmodels.DeleteRegisteredModelAliasRequest, ) func newDeleteAlias() *cobra.Command { cmd := &cobra.Command{} - - var deleteAliasReq catalog.DeleteAliasRequest + var deleteAliasReq sdkucregisteredmodels.DeleteRegisteredModelAliasRequest cmd.Use = "delete-alias FULL_NAME ALIAS" cmd.Short = `Delete a Registered Model Alias.` @@ -289,14 +303,18 @@ func newDeleteAlias() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteAliasReq.FullName = args[0] - deleteAliasReq.Alias = args[1] + deleteAliasReq.FullNameArg = new(args[0]) + deleteAliasReq.AliasArg = new(args[1]) - err = w.RegisteredModels.DeleteAlias(ctx, deleteAliasReq) + sdkReq := &deleteAliasReq + response, err := w.RegisteredModels.DeleteRegisteredModelAlias(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -318,16 +336,15 @@ func newDeleteAlias() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetRegisteredModelRequest, + *ucregisteredmodels.GetRegisteredModelRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq ucregisteredmodels.GetRegisteredModelRequest - var getReq catalog.GetRegisteredModelRequest - - cmd.Flags().BoolVar(&getReq.IncludeAliases, "include-aliases", getReq.IncludeAliases, `Whether to include registered model aliases in the response.`) - cmd.Flags().BoolVar(&getReq.IncludeBrowse, "include-browse", getReq.IncludeBrowse, `Whether to include registered models in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeAliases, "include-aliases", `Whether to include registered model aliases in the response.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeBrowse, "include-browse", `Whether to include registered models in the response for which the principal can only access selective metadata for.`) cmd.Use = "get FULL_NAME" cmd.Short = `Get a Registered Model.` @@ -351,11 +368,12 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No FULL_NAME argument specified. Loading names for Registered Models drop-down.") - names, err := w.RegisteredModels.RegisteredModelInfoNameToFullNameMap(ctx, catalog.ListRegisteredModelsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.RegisteredModels.ListRegisteredModelsIter(ctx, sdkucregisteredmodels.ListRegisteredModelsRequest{}), []string{"Name"}, []string{"FullName"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Registered Models drop-down. Please manually specify required arguments. Original error: %w", err) @@ -369,14 +387,22 @@ func newGet() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the three-level (fully qualified) name of the registered model") } - getReq.FullName = args[0] + getReq.FullNameArg = new(args[0]) - response, err := w.RegisteredModels.Get(ctx, getReq) + sdkReq, err := ucregisteredmodels.GetRegisteredModelRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.RegisteredModels.GetRegisteredModel(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucregisteredmodels.RegisteredModelInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -397,28 +423,28 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListRegisteredModelsRequest, + *ucregisteredmodels.ListRegisteredModelsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq ucregisteredmodels.ListRegisteredModelsRequest - var listReq catalog.ListRegisteredModelsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.CatalogName, "catalog-name", listReq.CatalogName, `The identifier of the catalog under which to list registered models.`) - cmd.Flags().BoolVar(&listReq.IncludeBrowse, "include-browse", listReq.IncludeBrowse, `Whether to include registered models in the response for which the principal can only access selective metadata for.`) - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Max number of registered models to return.`) - cmd.Flags().StringVar(&listReq.SchemaName, "schema-name", listReq.SchemaName, `The identifier of the schema under which to list registered models.`) + flags.StringPtrVar(cmd.Flags(), &listReq.CatalogName, "catalog-name", `The identifier of the catalog under which to list registered models.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeBrowse, "include-browse", `Whether to include registered models in the response for which the principal can only access selective metadata for.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Max number of registered models to return.`) + flags.StringPtrVar(cmd.Flags(), &listReq.SchemaName, "schema-name", `The identifier of the schema under which to list registered models.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -456,16 +482,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.RegisteredModels.List(ctx, listReq) + sdkReq, err := ucregisteredmodels.ListRegisteredModelsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.RegisteredModels.ListRegisteredModelsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucregisteredmodels.RegisteredModelInfoFromSDK)) } // Disable completions since they are not applicable. @@ -486,13 +516,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setAliasOverrides []func( *cobra.Command, - *catalog.SetRegisteredModelAliasRequest, + *ucregisteredmodels.SetRegisteredModelAliasRequest, ) func newSetAlias() *cobra.Command { cmd := &cobra.Command{} + var setAliasReq ucregisteredmodels.SetRegisteredModelAliasRequest - var setAliasReq catalog.SetRegisteredModelAliasRequest var setAliasJson flags.JsonFlag cmd.Flags().Var(&setAliasJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -533,6 +563,7 @@ func newSetAlias() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setAliasJson.Unmarshal(&setAliasReq) @@ -546,22 +577,31 @@ func newSetAlias() *cobra.Command { } } } - setAliasReq.FullName = args[0] - setAliasReq.Alias = args[1] + setAliasReq.FullNameArg = new(args[0]) + setAliasReq.AliasArg = new(args[1]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &setAliasReq.VersionNum) + var setAliasVersionNumArg int64 + _, err = fmt.Sscan(args[2], &setAliasVersionNumArg) if err != nil { return fmt.Errorf("invalid VERSION_NUM: %s", args[2]) } - + setAliasReq.VersionNum = &setAliasVersionNumArg } - response, err := w.RegisteredModels.SetAlias(ctx, setAliasReq) + sdkReq, err := ucregisteredmodels.SetRegisteredModelAliasRequestToSDK(&setAliasReq) + if err != nil { + return err + } + response, err := w.RegisteredModels.SetRegisteredModelAlias(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucregisteredmodels.RegisteredModelAliasInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -582,30 +622,30 @@ func newSetAlias() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateRegisteredModelRequest, + *ucregisteredmodels.UpdateRegisteredModelRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucregisteredmodels.UpdateRegisteredModelRequest - var updateReq catalog.UpdateRegisteredModelRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: aliases - cmd.Flags().StringVar(&updateReq.CatalogName, "catalog-name", updateReq.CatalogName, `The name of the catalog where the schema and the registered model reside.`) - cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `The comment attached to the registered model.`) - cmd.Flags().Int64Var(&updateReq.CreatedAt, "created-at", updateReq.CreatedAt, `Creation timestamp of the registered model in milliseconds since the Unix epoch.`) - cmd.Flags().StringVar(&updateReq.CreatedBy, "created-by", updateReq.CreatedBy, `The identifier of the user who created the registered model.`) - cmd.Flags().StringVar(&updateReq.MetastoreId, "metastore-id", updateReq.MetastoreId, `The unique identifier of the metastore.`) - cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `The name of the registered model.`) - cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the registered model.`) - cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `The identifier of the user who owns the registered model.`) - cmd.Flags().StringVar(&updateReq.SchemaName, "schema-name", updateReq.SchemaName, `The name of the schema where the registered model resides.`) - cmd.Flags().StringVar(&updateReq.StorageLocation, "storage-location", updateReq.StorageLocation, `The storage location on the cloud under which model version data files are stored.`) - cmd.Flags().Int64Var(&updateReq.UpdatedAt, "updated-at", updateReq.UpdatedAt, `Last-update timestamp of the registered model in milliseconds since the Unix epoch.`) - cmd.Flags().StringVar(&updateReq.UpdatedBy, "updated-by", updateReq.UpdatedBy, `The identifier of the user who updated the registered model last time.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CatalogName, "catalog-name", `The name of the catalog where the schema and the registered model reside.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Comment, "comment", `The comment attached to the registered model.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.CreatedAt, "created-at", `Creation timestamp of the registered model in milliseconds since the Unix epoch.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.CreatedBy, "created-by", `The identifier of the user who created the registered model.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.MetastoreId, "metastore-id", `The unique identifier of the metastore.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Name, "name", `The name of the registered model.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.NewName, "new-name", `New name for the registered model.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `The identifier of the user who owns the registered model.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.SchemaName, "schema-name", `The name of the schema where the registered model resides.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.StorageLocation, "storage-location", `The storage location on the cloud under which model version data files are stored.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.UpdatedAt, "updated-at", `Last-update timestamp of the registered model in milliseconds since the Unix epoch.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.UpdatedBy, "updated-by", `The identifier of the user who updated the registered model last time.`) cmd.Use = "update FULL_NAME" cmd.Short = `Update a Registered Model.` @@ -632,6 +672,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -648,7 +689,7 @@ func newUpdate() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No FULL_NAME argument specified. Loading names for Registered Models drop-down.") - names, err := w.RegisteredModels.RegisteredModelInfoNameToFullNameMap(ctx, catalog.ListRegisteredModelsRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.RegisteredModels.ListRegisteredModelsIter(ctx, sdkucregisteredmodels.ListRegisteredModelsRequest{}), []string{"Name"}, []string{"FullName"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Registered Models drop-down. Please manually specify required arguments. Original error: %w", err) @@ -662,14 +703,22 @@ func newUpdate() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the three-level (fully qualified) name of the registered model") } - updateReq.FullName = args[0] + updateReq.FullNameArg = new(args[0]) - response, err := w.RegisteredModels.Update(ctx, updateReq) + sdkReq, err := ucregisteredmodels.UpdateRegisteredModelRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.RegisteredModels.UpdateRegisteredModel(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucregisteredmodels.RegisteredModelInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/repos/overrides.go b/cmd/workspace/repos/overrides.go index ca10dbd0fb3..2b30ecc2f1d 100644 --- a/cmd/workspace/repos/overrides.go +++ b/cmd/workspace/repos/overrides.go @@ -8,21 +8,23 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdkclients" + repos "github.com/databricks/cli/libs/sdktypes/repos/v1" + sdkrepos "github.com/databricks/sdk-go/repos/v1" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *workspace.ListReposRequest) { +func listOverride(listCmd *cobra.Command, listReq *repos.ListReposRequest) { listCmd.Annotations["template"] = cmdio.Heredoc(` {{range .}}{{green "%d" .Id}} {{.Path}} {{.Branch|blue}} {{.Url|cyan}} {{end}}`) } -func createOverride(createCmd *cobra.Command, createReq *workspace.CreateRepoRequest) { +func createOverride(createCmd *cobra.Command, createReq *repos.CreateRepoRequest) { createCmd.Use = "create URL [PROVIDER]" createCmd.Args = func(cmd *cobra.Command, args []string) error { // If the provider argument is not specified, we try to detect it from the URL. @@ -49,36 +51,46 @@ func createOverride(createCmd *cobra.Command, createReq *workspace.CreateRepoReq } } } else { - createReq.Url = args[0] + createReq.Url = new(args[0]) if len(args) > 1 { - createReq.Provider = args[1] + createReq.Provider = new(args[1]) } else { - createReq.Provider = DetectProvider(createReq.Url) - if createReq.Provider == "" { + provider := DetectProvider(args[0]) + if provider == "" { return fmt.Errorf( - "could not detect provider from URL %q; please specify", createReq.Url) + "could not detect provider from URL %q; please specify", args[0]) } + createReq.Provider = new(provider) } } - response, err := w.Repos.Create(ctx, *createReq) + sdkReq, err := repos.CreateRepoRequestToSDK(createReq) if err != nil { return err } - return cmdio.Render(ctx, response) + response, err := w.Repos.CreateRepo(ctx, *sdkReq) + if err != nil { + return err + } + out, err := repos.CreateRepoResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } -func deleteOverride(deleteCmd *cobra.Command, deleteReq *workspace.DeleteRepoRequest) { +func deleteOverride(deleteCmd *cobra.Command, deleteReq *sdkrepos.DeleteRepoRequest) { deleteCmd.Use = "delete REPO_ID_OR_PATH" deleteCmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - deleteReq.RepoId, err = repoArgumentToRepoID(ctx, w, args) + id, err := repoArgumentToRepoID(ctx, w, args) if err != nil { return err } - err = w.Repos.Delete(ctx, *deleteReq) + deleteReq.Id = &id + _, err = w.Repos.DeleteRepo(ctx, *deleteReq) if err != nil { return err } @@ -86,25 +98,30 @@ func deleteOverride(deleteCmd *cobra.Command, deleteReq *workspace.DeleteRepoReq } } -func getOverride(getCmd *cobra.Command, getReq *workspace.GetRepoRequest) { +func getOverride(getCmd *cobra.Command, getReq *sdkrepos.GetRepoRequest) { getCmd.Use = "get REPO_ID_OR_PATH" getCmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - getReq.RepoId, err = repoArgumentToRepoID(ctx, w, args) + id, err := repoArgumentToRepoID(ctx, w, args) if err != nil { return err } + getReq.Id = &id - response, err := w.Repos.Get(ctx, *getReq) + response, err := w.Repos.GetRepo(ctx, *getReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := repos.GetRepoResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } } -func updateOverride(updateCmd *cobra.Command, updateReq *workspace.UpdateRepoRequest) { +func updateOverride(updateCmd *cobra.Command, updateReq *repos.UpdateRepoRequest) { updateCmd.Use = "update REPO_ID_OR_PATH" updateJson := updateCmd.Flag("json").Value.(*flags.JsonFlag) @@ -124,13 +141,18 @@ func updateOverride(updateCmd *cobra.Command, updateReq *workspace.UpdateRepoReq } } } else { - updateReq.RepoId, err = repoArgumentToRepoID(ctx, w, args) + id, err := repoArgumentToRepoID(ctx, w, args) if err != nil { return err } + updateReq.Id = &id } - err = w.Repos.Update(ctx, *updateReq) + sdkReq, err := repos.UpdateRepoRequestToSDK(updateReq) + if err != nil { + return err + } + _, err = w.Repos.UpdateRepo(ctx, *sdkReq) if err != nil { return err } @@ -138,12 +160,12 @@ func updateOverride(updateCmd *cobra.Command, updateReq *workspace.UpdateRepoReq } } -func repoArgumentToRepoID(ctx context.Context, w *databricks.WorkspaceClient, args []string) (int64, error) { +func repoArgumentToRepoID(ctx context.Context, w *sdkclients.Clients, args []string) (int64, error) { // ---- Begin copy from cmd/workspace/repos/repos.go ---- if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No REPO_ID argument specified. Loading names for Repos drop-down.") - names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Repos.ListReposIter(ctx, sdkrepos.ListReposRequest{}), []string{"Path"}, []string{"Id"}) sp.Close() if err != nil { return 0, fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err) diff --git a/cmd/workspace/repos/repos.go b/cmd/workspace/repos/repos.go index ba5d95363fe..ad3875d05ed 100644 --- a/cmd/workspace/repos/repos.go +++ b/cmd/workspace/repos/repos.go @@ -8,10 +8,15 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/workspace" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + repos "github.com/databricks/cli/libs/sdktypes/repos/v1" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdkrepos "github.com/databricks/sdk-go/repos/v1" ) // Slice with functions to override default command behavior. @@ -65,19 +70,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *workspace.CreateRepoRequest, + *repos.CreateRepoRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq repos.CreateRepoRequest - var createReq workspace.CreateRepoRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Int64Var(&createReq.GitCredentialId, "git-credential-id", createReq.GitCredentialId, `Git credential ID to use when cloning the repository.`) - cmd.Flags().StringVar(&createReq.Path, "path", createReq.Path, `Desired path for the repo in the workspace.`) + flags.Int64PtrVar(cmd.Flags(), &createReq.GitCredentialId, "git-credential-id", `Git credential ID to use when cloning the repository.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Path, "path", `Desired path for the repo in the workspace.`) // TODO: complex arg: sparse_checkout cmd.Use = "create URL PROVIDER" @@ -116,6 +121,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -130,18 +136,26 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Url = args[0] + createReq.Url = new(args[0]) } if !cmd.Flags().Changed("json") { - createReq.Provider = args[1] + createReq.Provider = new(args[1]) } - response, err := w.Repos.Create(ctx, createReq) + sdkReq, err := repos.CreateRepoRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Repos.CreateRepo(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := repos.CreateRepoResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -162,13 +176,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *workspace.DeleteRepoRequest, + *sdkrepos.DeleteRepoRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq workspace.DeleteRepoRequest + var deleteReq sdkrepos.DeleteRepoRequest cmd.Use = "delete REPO_ID" cmd.Short = `Delete a repo.` @@ -187,11 +200,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No REPO_ID argument specified. Loading names for Repos drop-down.") - names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Repos.ListReposIter(ctx, sdkrepos.ListReposRequest{}), []string{"Path"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err) @@ -205,15 +219,20 @@ func newDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the id for the corresponding repo to delete") } - _, err = fmt.Sscan(args[0], &deleteReq.RepoId) + var deleteRepoIdArg int64 + _, err = fmt.Sscan(args[0], &deleteRepoIdArg) if err != nil { return fmt.Errorf("invalid REPO_ID: %s", args[0]) } + deleteReq.Id = &deleteRepoIdArg - err = w.Repos.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Repos.DeleteRepo(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -235,13 +254,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *workspace.GetRepoRequest, + *sdkrepos.GetRepoRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq workspace.GetRepoRequest + var getReq sdkrepos.GetRepoRequest cmd.Use = "get REPO_ID" cmd.Short = `Get a repo.` @@ -260,11 +278,12 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No REPO_ID argument specified. Loading names for Repos drop-down.") - names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Repos.ListReposIter(ctx, sdkrepos.ListReposRequest{}), []string{"Path"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err) @@ -278,17 +297,24 @@ func newGet() *cobra.Command { if len(args) != 1 { return errors.New("expected to have id of the git folder (repo) object in the workspace") } - _, err = fmt.Sscan(args[0], &getReq.RepoId) + var getRepoIdArg int64 + _, err = fmt.Sscan(args[0], &getRepoIdArg) if err != nil { return fmt.Errorf("invalid REPO_ID: %s", args[0]) } + getReq.Id = &getRepoIdArg - response, err := w.Repos.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Repos.GetRepo(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := repos.GetRepoResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -309,13 +335,12 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *workspace.GetRepoPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq workspace.GetRepoPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels REPO_ID" cmd.Short = `Get repo permission levels.` @@ -334,11 +359,12 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No REPO_ID argument specified. Loading names for Repos drop-down.") - names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Repos.ListReposIter(ctx, sdkrepos.ListReposRequest{}), []string{"Path"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err) @@ -352,14 +378,21 @@ func newGetPermissionLevels() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the repo for which to get or manage permissions") } - getPermissionLevelsReq.RepoId = args[0] + getPermissionLevelsReq.RequestObjectId = new(args[0]) + + getPermissionLevelsReq.RequestObjectType = new("repos") - response, err := w.Repos.GetPermissionLevels(ctx, getPermissionLevelsReq) + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -380,13 +413,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *workspace.GetRepoPermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq workspace.GetRepoPermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions REPO_ID" cmd.Short = `Get repo permissions.` @@ -406,11 +438,12 @@ func newGetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No REPO_ID argument specified. Loading names for Repos drop-down.") - names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Repos.ListReposIter(ctx, sdkrepos.ListReposRequest{}), []string{"Path"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err) @@ -424,14 +457,21 @@ func newGetPermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the repo for which to get or manage permissions") } - getPermissionsReq.RepoId = args[0] + getPermissionsReq.RequestObjectId = new(args[0]) + + getPermissionsReq.RequestObjectType = new("repos") - response, err := w.Repos.GetPermissions(ctx, getPermissionsReq) + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -452,25 +492,25 @@ func newGetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *workspace.ListReposRequest, + *repos.ListReposRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq repos.ListReposRequest - var listReq workspace.ListReposRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.PathPrefix, "path-prefix", listReq.PathPrefix, `Filters repos that have paths starting with the given path prefix.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PathPrefix, "path-prefix", `Filters repos that have paths starting with the given path prefix.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.NextPageToken, "next-page-token", listReq.NextPageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.NextPageToken, "next-page-token", `Pagination token.`) cmd.Flags().Lookup("next-page-token").Hidden = true cmd.Use = "list" @@ -498,16 +538,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Repos.List(ctx, listReq) + sdkReq, err := repos.ListReposRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Repos.ListReposIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, repos.RepoInfoFromSDK)) } // Disable completions since they are not applicable. @@ -528,13 +572,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *workspace.RepoPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq workspace.RepoPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -560,6 +604,7 @@ func newSetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -576,7 +621,7 @@ func newSetPermissions() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No REPO_ID argument specified. Loading names for Repos drop-down.") - names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Repos.ListReposIter(ctx, sdkrepos.ListReposRequest{}), []string{"Path"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err) @@ -590,14 +635,24 @@ func newSetPermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the repo for which to get or manage permissions") } - setPermissionsReq.RepoId = args[0] + setPermissionsReq.RequestObjectId = new(args[0]) + + setPermissionsReq.RequestObjectType = new("repos") - response, err := w.Repos.SetPermissions(ctx, setPermissionsReq) + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -618,22 +673,22 @@ func newSetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *workspace.UpdateRepoRequest, + *repos.UpdateRepoRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq repos.UpdateRepoRequest - var updateReq workspace.UpdateRepoRequest 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.Branch, "branch", updateReq.Branch, `Branch that the local version of the repo is checked out to.`) - cmd.Flags().BoolVar(&updateReq.DangerouslyForceDiscardAll, "dangerously-force-discard-all", updateReq.DangerouslyForceDiscardAll, `WARNING: DESTRUCTIVE AND IRREVERSIBLE.`) - cmd.Flags().Int64Var(&updateReq.GitCredentialId, "git-credential-id", updateReq.GitCredentialId, `Git credential ID to use for this update operation.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Branch, "branch", `Branch that the local version of the repo is checked out to.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.DangerouslyForceDiscardAll, "dangerously-force-discard-all", `WARNING: DESTRUCTIVE AND IRREVERSIBLE.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.GitCredentialId, "git-credential-id", `Git credential ID to use for this update operation.`) // TODO: complex arg: sparse_checkout - cmd.Flags().StringVar(&updateReq.Tag, "tag", updateReq.Tag, `Tag that the local version of the repo is checked out to.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Tag, "tag", `Tag that the local version of the repo is checked out to.`) cmd.Use = "update REPO_ID" cmd.Short = `Update a repo.` @@ -653,6 +708,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -669,7 +725,7 @@ func newUpdate() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No REPO_ID argument specified. Loading names for Repos drop-down.") - names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Repos.ListReposIter(ctx, sdkrepos.ListReposRequest{}), []string{"Path"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err) @@ -683,15 +739,23 @@ func newUpdate() *cobra.Command { if len(args) != 1 { return errors.New("expected to have id of the git folder (repo) object in the workspace") } - _, err = fmt.Sscan(args[0], &updateReq.RepoId) + var updateRepoIdArg int64 + _, err = fmt.Sscan(args[0], &updateRepoIdArg) if err != nil { return fmt.Errorf("invalid REPO_ID: %s", args[0]) } + updateReq.Id = &updateRepoIdArg - err = w.Repos.Update(ctx, updateReq) + sdkReq, err := repos.UpdateRepoRequestToSDK(&updateReq) if err != nil { return err } + response, err := w.Repos.UpdateRepo(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -713,13 +777,13 @@ func newUpdate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *workspace.RepoPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq workspace.RepoPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -744,6 +808,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -760,7 +825,7 @@ func newUpdatePermissions() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No REPO_ID argument specified. Loading names for Repos drop-down.") - names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Repos.ListReposIter(ctx, sdkrepos.ListReposRequest{}), []string{"Path"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err) @@ -774,14 +839,24 @@ func newUpdatePermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the repo for which to get or manage permissions") } - updatePermissionsReq.RepoId = args[0] + updatePermissionsReq.RequestObjectId = new(args[0]) + + updatePermissionsReq.RequestObjectType = new("repos") - response, err := w.Repos.UpdatePermissions(ctx, updatePermissionsReq) + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/resource-quotas/resource-quotas.go b/cmd/workspace/resource-quotas/resource-quotas.go index b58233280e4..32310b705bd 100644 --- a/cmd/workspace/resource-quotas/resource-quotas.go +++ b/cmd/workspace/resource-quotas/resource-quotas.go @@ -7,9 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/libs/flags" "github.com/spf13/cobra" + + ucresourcequotas "github.com/databricks/cli/libs/sdktypes/uc/resourcequotas/v1" + sdkucresourcequotas "github.com/databricks/sdk-go/uc/resourcequotas/v1" ) // Slice with functions to override default command behavior. @@ -54,13 +58,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getQuotaOverrides []func( *cobra.Command, - *catalog.GetQuotaRequest, + *sdkucresourcequotas.GetQuotaRequest, ) func newGetQuota() *cobra.Command { cmd := &cobra.Command{} - - var getQuotaReq catalog.GetQuotaRequest + var getQuotaReq sdkucresourcequotas.GetQuotaRequest cmd.Use = "get-quota PARENT_SECURABLE_TYPE PARENT_FULL_NAME QUOTA_NAME" cmd.Short = `Get information for a single resource quota.` @@ -91,17 +94,23 @@ func newGetQuota() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getQuotaReq.ParentSecurableType = args[0] - getQuotaReq.ParentFullName = args[1] - getQuotaReq.QuotaName = args[2] + getQuotaReq.ParentSecurableType = new(args[0]) + getQuotaReq.ParentFullName = new(args[1]) + getQuotaReq.QuotaName = new(args[2]) - response, err := w.ResourceQuotas.GetQuota(ctx, getQuotaReq) + sdkReq := &getQuotaReq + response, err := w.ResourceQuotas.GetQuota(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucresourcequotas.GetQuotaResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -122,25 +131,25 @@ func newGetQuota() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listQuotasOverrides []func( *cobra.Command, - *catalog.ListQuotasRequest, + *ucresourcequotas.ListQuotasRequest, ) func newListQuotas() *cobra.Command { cmd := &cobra.Command{} + var listQuotasReq ucresourcequotas.ListQuotasRequest - var listQuotasReq catalog.ListQuotasRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listQuotasLimit int - cmd.Flags().IntVar(&listQuotasReq.MaxResults, "max-results", listQuotasReq.MaxResults, `The number of quotas to return.`) + flags.IntPtrVar(cmd.Flags(), &listQuotasReq.MaxResults, "max-results", `The number of quotas to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listQuotasLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listQuotasReq.PageToken, "page-token", listQuotasReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listQuotasReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-quotas" @@ -169,16 +178,20 @@ func newListQuotas() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ResourceQuotas.ListQuotas(ctx, listQuotasReq) + sdkReq, err := ucresourcequotas.ListQuotasRequestToSDK(&listQuotasReq) + if err != nil { + return err + } if listQuotasLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listQuotasLimit) } if listQuotasLimit > 0 { ctx = cmdio.WithLimit(ctx, listQuotasLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.ResourceQuotas.ListQuotasIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucresourcequotas.QuotaInfoFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/restrict-workspace-admins/restrict-workspace-admins.go b/cmd/workspace/restrict-workspace-admins/restrict-workspace-admins.go index ca07a765514..9b8ef962046 100644 --- a/cmd/workspace/restrict-workspace-admins/restrict-workspace-admins.go +++ b/cmd/workspace/restrict-workspace-admins/restrict-workspace-admins.go @@ -5,11 +5,14 @@ package restrict_workspace_admins import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -61,15 +64,16 @@ The Restrict Workspace Admins setting lets you control the capabilities of // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteRestrictWorkspaceAdminsSettingRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeleteRestrictWorkspaceAdminsSettingRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `*Public Preview* Delete the restrict workspace admins setting.` @@ -96,12 +100,24 @@ Delete the restrict workspace admins setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := "/api/2.0/settings/types/restrict_workspace_admins/names/default" - response, err := w.Settings.RestrictWorkspaceAdmins().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -123,15 +139,16 @@ Delete the restrict workspace admins setting. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetRestrictWorkspaceAdminsSettingRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetRestrictWorkspaceAdminsSettingRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `*Public Preview* Get the restrict workspace admins setting.` @@ -154,12 +171,24 @@ Get the restrict workspace admins setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/restrict_workspace_admins/names/default" - response, err := w.Settings.RestrictWorkspaceAdmins().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -181,13 +210,16 @@ Get the restrict workspace admins setting. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateRestrictWorkspaceAdminsSettingRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateRestrictWorkspaceAdminsSettingRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -212,6 +244,7 @@ Update the restrict workspace admins setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -228,11 +261,24 @@ Update the restrict workspace admins setting. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.RestrictWorkspaceAdmins().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/restrict_workspace_admins/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/rfa/rfa.go b/cmd/workspace/rfa/rfa.go index 75bfec74dd4..3fd473e301a 100644 --- a/cmd/workspace/rfa/rfa.go +++ b/cmd/workspace/rfa/rfa.go @@ -4,14 +4,15 @@ package rfa import ( "errors" - "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" + + ucrfa "github.com/databricks/cli/libs/sdktypes/uc/rfa/v1" + sdkucrfa "github.com/databricks/sdk-go/uc/rfa/v1" ) // Slice with functions to override default command behavior. @@ -56,13 +57,13 @@ Request for Access enables users to request access for Unity Catalog // Functions can be added from the `init()` function in manually curated files in this directory. var batchCreateAccessRequestsOverrides []func( *cobra.Command, - *catalog.BatchCreateAccessRequestsRequest, + *ucrfa.BatchCreateAccessRequestsRequest, ) func newBatchCreateAccessRequests() *cobra.Command { cmd := &cobra.Command{} + var batchCreateAccessRequestsReq ucrfa.BatchCreateAccessRequestsRequest - 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`) @@ -98,6 +99,7 @@ Create Access Requests. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := batchCreateAccessRequestsJson.Unmarshal(&batchCreateAccessRequestsReq) @@ -112,12 +114,20 @@ Create Access Requests. } } - response, err := w.Rfa.BatchCreateAccessRequests(ctx, batchCreateAccessRequestsReq) + sdkReq, err := ucrfa.BatchCreateAccessRequestsRequestToSDK(&batchCreateAccessRequestsReq) + if err != nil { + return err + } + response, err := w.Rfa.BatchCreateAccessRequests(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucrfa.BatchCreateAccessRequestsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -138,13 +148,12 @@ Create Access Requests. // Functions can be added from the `init()` function in manually curated files in this directory. var getAccessRequestDestinationsOverrides []func( *cobra.Command, - *catalog.GetAccessRequestDestinationsRequest, + *sdkucrfa.GetAccessRequestDestinationsRequest, ) func newGetAccessRequestDestinations() *cobra.Command { cmd := &cobra.Command{} - - var getAccessRequestDestinationsReq catalog.GetAccessRequestDestinationsRequest + var getAccessRequestDestinationsReq sdkucrfa.GetAccessRequestDestinationsRequest cmd.Use = "get-access-request-destinations SECURABLE_TYPE FULL_NAME" cmd.Short = `*Public Preview* Get Access Request Destinations.` @@ -178,16 +187,22 @@ Get Access Request Destinations. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getAccessRequestDestinationsReq.SecurableType = args[0] - getAccessRequestDestinationsReq.FullName = args[1] + getAccessRequestDestinationsReq.SecurableType = new(args[0]) + getAccessRequestDestinationsReq.FullName = new(args[1]) - response, err := w.Rfa.GetAccessRequestDestinations(ctx, getAccessRequestDestinationsReq) + sdkReq := &getAccessRequestDestinationsReq + response, err := w.Rfa.GetAccessRequestDestinations(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucrfa.AccessRequestDestinationsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -208,14 +223,14 @@ Get Access Request Destinations. // Functions can be added from the `init()` function in manually curated files in this directory. var updateAccessRequestDestinationsOverrides []func( *cobra.Command, - *catalog.UpdateAccessRequestDestinationsRequest, + *ucrfa.UpdateAccessRequestDestinationsRequest, ) func newUpdateAccessRequestDestinations() *cobra.Command { cmd := &cobra.Command{} + var updateAccessRequestDestinationsReq ucrfa.UpdateAccessRequestDestinationsRequest + updateAccessRequestDestinationsReq.AccessRequestDestinations = &ucrfa.AccessRequestDestinations{} - 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`) @@ -276,6 +291,7 @@ Update Access Request Destinations. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateAccessRequestDestinationsJson.Unmarshal(&updateAccessRequestDestinationsReq.AccessRequestDestinations) @@ -289,21 +305,25 @@ Update Access Request Destinations. } } } - updateAccessRequestDestinationsReq.UpdateMask = args[0] + updateAccessRequestDestinationsReq.UpdateMask = new(args[0]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &updateAccessRequestDestinationsReq.AccessRequestDestinations.Securable) - if err != nil { - return fmt.Errorf("invalid SECURABLE: %s", args[1]) - } - + _ = args[1] // TODO: complex arg: securable } - response, err := w.Rfa.UpdateAccessRequestDestinations(ctx, updateAccessRequestDestinationsReq) + sdkReq, err := ucrfa.UpdateAccessRequestDestinationsRequestToSDK(&updateAccessRequestDestinationsReq) + if err != nil { + return err + } + response, err := w.Rfa.UpdateAccessRequestDestinations(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucrfa.AccessRequestDestinationsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/sandbox/sandbox.go b/cmd/workspace/sandbox/sandbox.go index 4c2539c5945..071529e9ab2 100644 --- a/cmd/workspace/sandbox/sandbox.go +++ b/cmd/workspace/sandbox/sandbox.go @@ -6,16 +6,19 @@ import ( "encoding/json" "errors" "fmt" - "strings" + + "strconv" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/common/types/duration" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - "github.com/databricks/databricks-sdk-go/service/sandbox" + sdkcoretypes "github.com/databricks/sdk-go/core/types" "github.com/spf13/cobra" + + sandbox "github.com/databricks/cli/libs/sdktypes/sandbox/v1" + sdksandbox "github.com/databricks/sdk-go/sandbox/v1" ) // Slice with functions to override default command behavior. @@ -68,15 +71,15 @@ var createSandboxOverrides []func( func newCreateSandbox() *cobra.Command { cmd := &cobra.Command{} - var createSandboxReq sandbox.CreateSandboxRequest - createSandboxReq.Sandbox = sandbox.Sandbox{} + createSandboxReq.Sandbox = &sandbox.Sandbox{} + var createSandboxJson flags.JsonFlag cmd.Flags().Var(&createSandboxJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createSandboxReq.Sandbox.DisplayName, "display-name", createSandboxReq.Sandbox.DisplayName, `Human-readable display label for the sandbox.`) - cmd.Flags().StringVar(&createSandboxReq.Sandbox.Name, "name", createSandboxReq.Sandbox.Name, `The sandbox resource name, in the form sandboxes/{sandbox_id}.`) + flags.StringPtrVar(cmd.Flags(), &createSandboxReq.Sandbox.DisplayName, "display-name", `Human-readable display label for the sandbox.`) + flags.StringPtrVar(cmd.Flags(), &createSandboxReq.Sandbox.Name, "name", `The sandbox resource name, in the form sandboxes/{sandbox_id}.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -105,6 +108,7 @@ Create a sandbox. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createSandboxJson.Unmarshal(&createSandboxReq.Sandbox) @@ -118,14 +122,22 @@ Create a sandbox. } } } - createSandboxReq.SandboxId = args[0] + createSandboxReq.SandboxId = new(args[0]) - response, err := w.Sandbox.CreateSandbox(ctx, createSandboxReq) + sdkReq, err := sandbox.CreateSandboxRequestToSDK(&createSandboxReq) + if err != nil { + return err + } + response, err := w.Sandbox.CreateSandbox(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sandbox.SandboxFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -146,13 +158,12 @@ Create a sandbox. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteSandboxOverrides []func( *cobra.Command, - *sandbox.DeleteSandboxRequest, + *sdksandbox.DeleteSandboxRequest, ) func newDeleteSandbox() *cobra.Command { cmd := &cobra.Command{} - - var deleteSandboxReq sandbox.DeleteSandboxRequest + var deleteSandboxReq sdksandbox.DeleteSandboxRequest cmd.Use = "delete-sandbox NAME" cmd.Short = `*Beta* Delete a sandbox.` @@ -175,10 +186,12 @@ Delete a sandbox. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteSandboxReq.Name = args[0] + deleteSandboxReq.Name = new(args[0]) - err = w.Sandbox.DeleteSandbox(ctx, deleteSandboxReq) + sdkReq := &deleteSandboxReq + err = w.Sandbox.DeleteSandbox(ctx, *sdkReq) if err != nil { return err } @@ -208,8 +221,8 @@ var executeCommandSyncOverrides []func( func newExecuteCommandSync() *cobra.Command { cmd := &cobra.Command{} - var executeCommandSyncReq sandbox.ExecuteCommandSyncRequest + var executeCommandSyncJson flags.JsonFlag cmd.Flags().Var(&executeCommandSyncJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -253,6 +266,7 @@ Run a command in a sandbox and wait for its result. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := executeCommandSyncJson.Unmarshal(&executeCommandSyncReq) @@ -266,27 +280,34 @@ Run a command in a sandbox and wait for its result. } } } - executeCommandSyncReq.Name = args[0] + executeCommandSyncReq.Name = new(args[0]) if !cmd.Flags().Changed("json") { - executeCommandSyncReq.Cmd = args[1] + executeCommandSyncReq.Cmd = new(args[1]) } if executionTimeoutParam != "" { - executionTimeoutBytes := []byte(fmt.Sprintf("\"%s\"", executionTimeoutParam)) - var executionTimeoutField duration.Duration - err = json.Unmarshal(executionTimeoutBytes, &executionTimeoutField) + var executionTimeoutField sdkcoretypes.Duration + err = json.Unmarshal([]byte(strconv.Quote(executionTimeoutParam)), &executionTimeoutField) if err != nil { return fmt.Errorf("invalid EXECUTION_TIMEOUT: %s", executionTimeoutParam) } executeCommandSyncReq.ExecutionTimeout = &executionTimeoutField } - response, err := w.Sandbox.ExecuteCommandSync(ctx, executeCommandSyncReq) + sdkReq, err := sandbox.ExecuteCommandSyncRequestToSDK(&executeCommandSyncReq) + if err != nil { + return err + } + response, err := w.Sandbox.ExecuteCommandSync(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sandbox.ExecuteCommandSyncResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -307,13 +328,12 @@ Run a command in a sandbox and wait for its result. // Functions can be added from the `init()` function in manually curated files in this directory. var getSandboxOverrides []func( *cobra.Command, - *sandbox.GetSandboxRequest, + *sdksandbox.GetSandboxRequest, ) func newGetSandbox() *cobra.Command { cmd := &cobra.Command{} - - var getSandboxReq sandbox.GetSandboxRequest + var getSandboxReq sdksandbox.GetSandboxRequest cmd.Use = "get-sandbox NAME" cmd.Short = `*Beta* Get a sandbox.` @@ -336,15 +356,21 @@ Get a sandbox. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSandboxReq.Name = args[0] + getSandboxReq.Name = new(args[0]) - response, err := w.Sandbox.GetSandbox(ctx, getSandboxReq) + sdkReq := &getSandboxReq + response, err := w.Sandbox.GetSandbox(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sandbox.SandboxFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -370,11 +396,10 @@ var listCommandsOverrides []func( func newListCommands() *cobra.Command { cmd := &cobra.Command{} - var listCommandsReq sandbox.ListCommandsRequest - cmd.Flags().IntVar(&listCommandsReq.PageSize, "page-size", listCommandsReq.PageSize, `Maximum number of commands to return.`) - cmd.Flags().StringVar(&listCommandsReq.PageToken, "page-token", listCommandsReq.PageToken, `Page token returned by a previous ListCommands call.`) + flags.IntPtrVar(cmd.Flags(), &listCommandsReq.PageSize, "page-size", `Maximum number of commands to return.`) + flags.StringPtrVar(cmd.Flags(), &listCommandsReq.PageToken, "page-token", `Page token returned by a previous ListCommands call.`) cmd.Use = "list-commands PARENT" cmd.Short = `*Beta* List the tracked command executions in a sandbox.` @@ -400,15 +425,24 @@ List the tracked command executions in a sandbox. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listCommandsReq.Parent = args[0] + listCommandsReq.Parent = new(args[0]) - response, err := w.Sandbox.ListCommands(ctx, listCommandsReq) + sdkReq, err := sandbox.ListCommandsRequestToSDK(&listCommandsReq) + if err != nil { + return err + } + response, err := w.Sandbox.ListCommands(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sandbox.ListCommandsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -434,20 +468,20 @@ var listSandboxesOverrides []func( func newListSandboxes() *cobra.Command { cmd := &cobra.Command{} - var listSandboxesReq sandbox.ListSandboxesRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSandboxesLimit int - cmd.Flags().IntVar(&listSandboxesReq.PageSize, "page-size", listSandboxesReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listSandboxesReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listSandboxesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSandboxesReq.PageToken, "page-token", listSandboxesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSandboxesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-sandboxes" @@ -471,16 +505,20 @@ List sandboxes. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Sandbox.ListSandboxes(ctx, listSandboxesReq) + sdkReq, err := sandbox.ListSandboxesRequestToSDK(&listSandboxesReq) + if err != nil { + return err + } if listSandboxesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSandboxesLimit) } if listSandboxesLimit > 0 { ctx = cmdio.WithLimit(ctx, listSandboxesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Sandbox.ListSandboxesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, sandbox.SandboxFromSDK)) } // Disable completions since they are not applicable. @@ -506,7 +544,6 @@ var startSandboxOverrides []func( func newStartSandbox() *cobra.Command { cmd := &cobra.Command{} - var startSandboxReq sandbox.StartSandboxRequest cmd.Use = "start-sandbox NAME" @@ -535,15 +572,24 @@ Start a sandbox. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - startSandboxReq.Name = args[0] + startSandboxReq.Name = new(args[0]) - response, err := w.Sandbox.StartSandbox(ctx, startSandboxReq) + sdkReq, err := sandbox.StartSandboxRequestToSDK(&startSandboxReq) + if err != nil { + return err + } + response, err := w.Sandbox.StartSandbox(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sandbox.SandboxFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -569,7 +615,6 @@ var stopSandboxOverrides []func( func newStopSandbox() *cobra.Command { cmd := &cobra.Command{} - var stopSandboxReq sandbox.StopSandboxRequest cmd.Use = "stop-sandbox NAME" @@ -598,15 +643,24 @@ Stop a sandbox. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - stopSandboxReq.Name = args[0] + stopSandboxReq.Name = new(args[0]) - response, err := w.Sandbox.StopSandbox(ctx, stopSandboxReq) + sdkReq, err := sandbox.StopSandboxRequestToSDK(&stopSandboxReq) + if err != nil { + return err + } + response, err := w.Sandbox.StopSandbox(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sandbox.SandboxFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -632,15 +686,15 @@ var updateSandboxOverrides []func( func newUpdateSandbox() *cobra.Command { cmd := &cobra.Command{} - var updateSandboxReq sandbox.UpdateSandboxRequest - updateSandboxReq.Sandbox = sandbox.Sandbox{} + updateSandboxReq.Sandbox = &sandbox.Sandbox{} + var updateSandboxJson flags.JsonFlag cmd.Flags().Var(&updateSandboxJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateSandboxReq.Sandbox.DisplayName, "display-name", updateSandboxReq.Sandbox.DisplayName, `Human-readable display label for the sandbox.`) - cmd.Flags().StringVar(&updateSandboxReq.Sandbox.Name, "name", updateSandboxReq.Sandbox.Name, `The sandbox resource name, in the form sandboxes/{sandbox_id}.`) + flags.StringPtrVar(cmd.Flags(), &updateSandboxReq.Sandbox.DisplayName, "display-name", `Human-readable display label for the sandbox.`) + flags.StringPtrVar(cmd.Flags(), &updateSandboxReq.Name, "name", `The sandbox resource name, in the form sandboxes/{sandbox_id}.`) // TODO: complex arg: spec // TODO: complex arg: status @@ -675,6 +729,7 @@ Update a sandbox. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateSandboxJson.Unmarshal(&updateSandboxReq.Sandbox) @@ -688,18 +743,25 @@ Update a sandbox. } } } - updateSandboxReq.Name = args[0] + updateSandboxReq.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateSandboxReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateSandboxReq.UpdateMask = new(args[1]) } - response, err := w.Sandbox.UpdateSandbox(ctx, updateSandboxReq) + sdkReq, err := sandbox.UpdateSandboxRequestToSDK(&updateSandboxReq) + if err != nil { + return err + } + response, err := w.Sandbox.UpdateSandbox(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sandbox.SandboxFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/schemas/overrides.go b/cmd/workspace/schemas/overrides.go index ba4c65ce735..8d0db47c933 100644 --- a/cmd/workspace/schemas/overrides.go +++ b/cmd/workspace/schemas/overrides.go @@ -2,11 +2,11 @@ package schemas import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/catalog" + ucschemas "github.com/databricks/cli/libs/sdktypes/uc/schemas/v1" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *catalog.ListSchemasRequest) { +func listOverride(listCmd *cobra.Command, listReq *ucschemas.ListSchemasRequest) { listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "Full Name"}} {{header "Owner"}} {{header "Comment"}}`) listCmd.Annotations["template"] = cmdio.Heredoc(` diff --git a/cmd/workspace/schemas/schemas.go b/cmd/workspace/schemas/schemas.go index 709452cd3a9..50641f1a148 100644 --- a/cmd/workspace/schemas/schemas.go +++ b/cmd/workspace/schemas/schemas.go @@ -8,10 +8,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucschemas "github.com/databricks/cli/libs/sdktypes/uc/schemas/v1" ) // Slice with functions to override default command behavior. @@ -56,21 +58,21 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateSchema, + *ucschemas.CreateSchemaRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq ucschemas.CreateSchemaRequest - var createReq catalog.CreateSchema 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.Comment, "comment", createReq.Comment, `User-provided free-form text description.`) - cmd.Flags().Int64Var(&createReq.CustomMaxRetentionHours, "custom-max-retention-hours", createReq.CustomMaxRetentionHours, `Custom maximum retention period in hours for the schema.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Comment, "comment", `User-provided free-form text description.`) + flags.Int64PtrVar(cmd.Flags(), &createReq.CustomMaxRetentionHours, "custom-max-retention-hours", `Custom maximum retention period in hours for the schema.`) // TODO: map via StringToStringVar: properties - cmd.Flags().StringVar(&createReq.StorageRoot, "storage-root", createReq.StorageRoot, `Storage root URL for managed tables within schema.`) + flags.StringPtrVar(cmd.Flags(), &createReq.StorageRoot, "storage-root", `Storage root URL for managed tables within schema.`) cmd.Use = "create NAME CATALOG_NAME" cmd.Short = `Create a schema.` @@ -104,6 +106,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -118,18 +121,26 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Name = args[0] + createReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createReq.CatalogName = args[1] + createReq.CatalogName = new(args[1]) } - response, err := w.Schemas.Create(ctx, createReq) + sdkReq, err := ucschemas.CreateSchemaRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Schemas.CreateSchema(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucschemas.SchemaInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -150,15 +161,14 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteSchemaRequest, + *ucschemas.DeleteSchemaRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq ucschemas.DeleteSchemaRequest - var deleteReq catalog.DeleteSchemaRequest - - cmd.Flags().BoolVar(&deleteReq.Force, "force", deleteReq.Force, `Force deletion even if the schema is not empty.`) + flags.BoolPtrVar(cmd.Flags(), &deleteReq.Force, "force", `Force deletion even if the schema is not empty.`) cmd.Use = "delete FULL_NAME" cmd.Short = `Delete a schema.` @@ -183,13 +193,20 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.FullName = args[0] + deleteReq.FullNameArg = new(args[0]) - err = w.Schemas.Delete(ctx, deleteReq) + sdkReq, err := ucschemas.DeleteSchemaRequestToSDK(&deleteReq) if err != nil { return err } + response, err := w.Schemas.DeleteSchema(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -211,15 +228,14 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetSchemaRequest, + *ucschemas.GetSchemaRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq ucschemas.GetSchemaRequest - var getReq catalog.GetSchemaRequest - - cmd.Flags().BoolVar(&getReq.IncludeBrowse, "include-browse", getReq.IncludeBrowse, `Whether to include schemas in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeBrowse, "include-browse", `Whether to include schemas in the response for which the principal can only access selective metadata for.`) cmd.Use = "get FULL_NAME" cmd.Short = `Get a schema.` @@ -245,15 +261,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.FullName = args[0] + getReq.FullNameArg = new(args[0]) - response, err := w.Schemas.Get(ctx, getReq) + sdkReq, err := ucschemas.GetSchemaRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.Schemas.GetSchema(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucschemas.SchemaInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -274,27 +299,27 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListSchemasRequest, + *ucschemas.ListSchemasRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq ucschemas.ListSchemasRequest - var listReq catalog.ListSchemasRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().BoolVar(&listReq.IncludeBrowse, "include-browse", listReq.IncludeBrowse, `Whether to include schemas in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeBrowse, "include-browse", `Whether to include schemas in the response for which the principal can only access selective metadata for.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of schemas to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of schemas to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list CATALOG_NAME" @@ -331,18 +356,22 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.CatalogName = args[0] + listReq.CatalogName = new(args[0]) - response := w.Schemas.List(ctx, listReq) + sdkReq, err := ucschemas.ListSchemasRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Schemas.ListSchemasIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucschemas.SchemaInfoFromSDK)) } // Disable completions since they are not applicable. @@ -363,22 +392,22 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateSchema, + *ucschemas.UpdateSchemaRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucschemas.UpdateSchemaRequest - var updateReq catalog.UpdateSchema 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.Comment, "comment", updateReq.Comment, `User-provided free-form text description.`) - cmd.Flags().Int64Var(&updateReq.CustomMaxRetentionHours, "custom-max-retention-hours", updateReq.CustomMaxRetentionHours, `Custom maximum retention period in hours for the schema.`) - cmd.Flags().Var(&updateReq.EnablePredictiveOptimization, "enable-predictive-optimization", `Whether predictive optimization should be enabled for this object and objects under it. Supported values: [DISABLE, ENABLE, INHERIT]`) - cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the schema.`) - cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of current owner of schema.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Comment, "comment", `User-provided free-form text description.`) + flags.Int64PtrVar(cmd.Flags(), &updateReq.CustomMaxRetentionHours, "custom-max-retention-hours", `Custom maximum retention period in hours for the schema.`) + flags.EnumPtrVar(cmd.Flags(), &updateReq.EnablePredictiveOptimization, "enable-predictive-optimization", `Whether predictive optimization should be enabled for this object and objects under it. Supported values: [DISABLE, ENABLE, INHERIT]`, "EnablePredictiveOptimization", "DISABLE", "ENABLE", "INHERIT") + flags.StringPtrVar(cmd.Flags(), &updateReq.NewName, "new-name", `New name for the schema.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `Username of current owner of schema.`) // TODO: map via StringToStringVar: properties cmd.Use = "update FULL_NAME" @@ -407,6 +436,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -420,14 +450,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.FullName = args[0] + updateReq.FullNameArg = new(args[0]) - response, err := w.Schemas.Update(ctx, updateReq) + sdkReq, err := ucschemas.UpdateSchemaRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Schemas.UpdateSchema(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucschemas.SchemaInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/secrets-uc/secrets-uc.go b/cmd/workspace/secrets-uc/secrets-uc.go index d2609bc1d86..1496befd8b3 100644 --- a/cmd/workspace/secrets-uc/secrets-uc.go +++ b/cmd/workspace/secrets-uc/secrets-uc.go @@ -6,16 +6,19 @@ import ( "encoding/json" "errors" "fmt" - "strings" + + "strconv" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/service/catalog" + sdkcoretypes "github.com/databricks/sdk-go/core/types" "github.com/spf13/cobra" + + ucsecrets "github.com/databricks/cli/libs/sdktypes/uc/secrets/v1" + sdkucsecrets "github.com/databricks/sdk-go/uc/secrets/v1" ) // Slice with functions to override default command behavior. @@ -61,22 +64,22 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createSecretOverrides []func( *cobra.Command, - *catalog.CreateSecretRequest, + *ucsecrets.CreateSecretRequest, ) func newCreateSecret() *cobra.Command { cmd := &cobra.Command{} + var createSecretReq ucsecrets.CreateSecretRequest + createSecretReq.Secret = &ucsecrets.Secret{} - var createSecretReq catalog.CreateSecretRequest - createSecretReq.Secret = catalog.Secret{} var createSecretJson flags.JsonFlag cmd.Flags().Var(&createSecretJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createSecretReq.Secret.Comment, "comment", createSecretReq.Secret.Comment, `User-provided free-form text description of the secret.`) + flags.StringPtrVar(cmd.Flags(), &createSecretReq.Secret.Comment, "comment", `User-provided free-form text description of the secret.`) var expireTimeParam string cmd.Flags().StringVar(&expireTimeParam, "expire-time", expireTimeParam, `User-provided expiration time of the secret.`) - cmd.Flags().StringVar(&createSecretReq.Secret.Owner, "owner", createSecretReq.Secret.Owner, `The owner of the secret.`) + flags.StringPtrVar(cmd.Flags(), &createSecretReq.Secret.Owner, "owner", `The owner of the secret.`) cmd.Use = "create-secret NAME CATALOG_NAME SCHEMA_NAME VALUE" cmd.Short = `Create a secret.` @@ -121,6 +124,7 @@ func newCreateSecret() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createSecretJson.Unmarshal(&createSecretReq.Secret) @@ -135,34 +139,41 @@ func newCreateSecret() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createSecretReq.Secret.Name = args[0] + createSecretReq.Secret.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createSecretReq.Secret.CatalogName = args[1] + createSecretReq.Secret.CatalogName = new(args[1]) } if !cmd.Flags().Changed("json") { - createSecretReq.Secret.SchemaName = args[2] + createSecretReq.Secret.SchemaName = new(args[2]) } if !cmd.Flags().Changed("json") { - createSecretReq.Secret.Value = args[3] + createSecretReq.Secret.Value = new(args[3]) } if expireTimeParam != "" { - expireTimeBytes := []byte(fmt.Sprintf("\"%s\"", expireTimeParam)) - var expireTimeField sdktime.Time - err = json.Unmarshal(expireTimeBytes, &expireTimeField) + var expireTimeField sdkcoretypes.Time + err = json.Unmarshal([]byte(strconv.Quote(expireTimeParam)), &expireTimeField) if err != nil { return fmt.Errorf("invalid EXPIRE_TIME: %s", expireTimeParam) } createSecretReq.Secret.ExpireTime = &expireTimeField } - response, err := w.SecretsUc.CreateSecret(ctx, createSecretReq) + sdkReq, err := ucsecrets.CreateSecretRequestToSDK(&createSecretReq) + if err != nil { + return err + } + response, err := w.SecretsUc.CreateSecret(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucsecrets.SecretFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -183,13 +194,12 @@ func newCreateSecret() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteSecretOverrides []func( *cobra.Command, - *catalog.DeleteSecretRequest, + *sdkucsecrets.DeleteSecretRequest, ) func newDeleteSecret() *cobra.Command { cmd := &cobra.Command{} - - var deleteSecretReq catalog.DeleteSecretRequest + var deleteSecretReq sdkucsecrets.DeleteSecretRequest cmd.Use = "delete-secret FULL_NAME" cmd.Short = `Delete a secret.` @@ -216,10 +226,12 @@ func newDeleteSecret() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteSecretReq.FullName = args[0] + deleteSecretReq.FullName = new(args[0]) - err = w.SecretsUc.DeleteSecret(ctx, deleteSecretReq) + sdkReq := &deleteSecretReq + err = w.SecretsUc.DeleteSecret(ctx, *sdkReq) if err != nil { return err } @@ -244,15 +256,14 @@ func newDeleteSecret() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getSecretOverrides []func( *cobra.Command, - *catalog.GetSecretRequest, + *ucsecrets.GetSecretRequest, ) func newGetSecret() *cobra.Command { cmd := &cobra.Command{} + var getSecretReq ucsecrets.GetSecretRequest - var getSecretReq catalog.GetSecretRequest - - cmd.Flags().BoolVar(&getSecretReq.IncludeValue, "include-value", getSecretReq.IncludeValue, `Whether to include the secret value in the response.`) + flags.BoolPtrVar(cmd.Flags(), &getSecretReq.IncludeValue, "include-value", `Whether to include the secret value in the response.`) cmd.Use = "get-secret FULL_NAME" cmd.Short = `Get a secret.` @@ -284,15 +295,24 @@ func newGetSecret() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSecretReq.FullName = args[0] + getSecretReq.FullName = new(args[0]) - response, err := w.SecretsUc.GetSecret(ctx, getSecretReq) + sdkReq, err := ucsecrets.GetSecretRequestToSDK(&getSecretReq) + if err != nil { + return err + } + response, err := w.SecretsUc.GetSecret(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucsecrets.SecretFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -313,27 +333,27 @@ func newGetSecret() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listSecretsOverrides []func( *cobra.Command, - *catalog.ListSecretsRequest, + *ucsecrets.ListSecretsRequest, ) func newListSecrets() *cobra.Command { cmd := &cobra.Command{} + var listSecretsReq ucsecrets.ListSecretsRequest - var listSecretsReq catalog.ListSecretsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSecretsLimit int - cmd.Flags().StringVar(&listSecretsReq.CatalogName, "catalog-name", listSecretsReq.CatalogName, `The name of the catalog under which to list secrets.`) - cmd.Flags().IntVar(&listSecretsReq.PageSize, "page-size", listSecretsReq.PageSize, `Maximum number of secrets to return.`) - cmd.Flags().StringVar(&listSecretsReq.SchemaName, "schema-name", listSecretsReq.SchemaName, `The name of the schema under which to list secrets.`) + flags.StringPtrVar(cmd.Flags(), &listSecretsReq.CatalogName, "catalog-name", `The name of the catalog under which to list secrets.`) + flags.IntPtrVar(cmd.Flags(), &listSecretsReq.PageSize, "page-size", `Maximum number of secrets to return.`) + flags.StringPtrVar(cmd.Flags(), &listSecretsReq.SchemaName, "schema-name", `The name of the schema under which to list secrets.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listSecretsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSecretsReq.PageToken, "page-token", listSecretsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSecretsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-secrets" @@ -362,16 +382,20 @@ func newListSecrets() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.SecretsUc.ListSecrets(ctx, listSecretsReq) + sdkReq, err := ucsecrets.ListSecretsRequestToSDK(&listSecretsReq) + if err != nil { + return err + } if listSecretsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSecretsLimit) } if listSecretsLimit > 0 { ctx = cmdio.WithLimit(ctx, listSecretsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.SecretsUc.ListSecretsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucsecrets.SecretFromSDK)) } // Disable completions since they are not applicable. @@ -392,22 +416,22 @@ func newListSecrets() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateSecretOverrides []func( *cobra.Command, - *catalog.UpdateSecretRequest, + *ucsecrets.UpdateSecretRequest, ) func newUpdateSecret() *cobra.Command { cmd := &cobra.Command{} + var updateSecretReq ucsecrets.UpdateSecretRequest + updateSecretReq.Secret = &ucsecrets.Secret{} - var updateSecretReq catalog.UpdateSecretRequest - updateSecretReq.Secret = catalog.Secret{} var updateSecretJson flags.JsonFlag cmd.Flags().Var(&updateSecretJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateSecretReq.Secret.Comment, "comment", updateSecretReq.Secret.Comment, `User-provided free-form text description of the secret.`) + flags.StringPtrVar(cmd.Flags(), &updateSecretReq.Secret.Comment, "comment", `User-provided free-form text description of the secret.`) var expireTimeParam string cmd.Flags().StringVar(&expireTimeParam, "expire-time", expireTimeParam, `User-provided expiration time of the secret.`) - cmd.Flags().StringVar(&updateSecretReq.Secret.Owner, "owner", updateSecretReq.Secret.Owner, `The owner of the secret.`) + flags.StringPtrVar(cmd.Flags(), &updateSecretReq.Secret.Owner, "owner", `The owner of the secret.`) cmd.Use = "update-secret FULL_NAME UPDATE_MASK NAME CATALOG_NAME SCHEMA_NAME VALUE" cmd.Short = `Update a secret.` @@ -460,6 +484,7 @@ func newUpdateSecret() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateSecretJson.Unmarshal(&updateSecretReq.Secret) @@ -473,40 +498,46 @@ func newUpdateSecret() *cobra.Command { } } } - updateSecretReq.FullName = args[0] + updateSecretReq.FullName = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateSecretReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateSecretReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - updateSecretReq.Secret.Name = args[2] + updateSecretReq.Secret.Name = new(args[2]) } if !cmd.Flags().Changed("json") { - updateSecretReq.Secret.CatalogName = args[3] + updateSecretReq.Secret.CatalogName = new(args[3]) } if !cmd.Flags().Changed("json") { - updateSecretReq.Secret.SchemaName = args[4] + updateSecretReq.Secret.SchemaName = new(args[4]) } if !cmd.Flags().Changed("json") { - updateSecretReq.Secret.Value = args[5] + updateSecretReq.Secret.Value = new(args[5]) } if expireTimeParam != "" { - expireTimeBytes := []byte(fmt.Sprintf("\"%s\"", expireTimeParam)) - var expireTimeField sdktime.Time - err = json.Unmarshal(expireTimeBytes, &expireTimeField) + var expireTimeField sdkcoretypes.Time + err = json.Unmarshal([]byte(strconv.Quote(expireTimeParam)), &expireTimeField) if err != nil { return fmt.Errorf("invalid EXPIRE_TIME: %s", expireTimeParam) } updateSecretReq.Secret.ExpireTime = &expireTimeField } - response, err := w.SecretsUc.UpdateSecret(ctx, updateSecretReq) + sdkReq, err := ucsecrets.UpdateSecretRequestToSDK(&updateSecretReq) + if err != nil { + return err + } + response, err := w.SecretsUc.UpdateSecret(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucsecrets.SecretFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/secrets/overrides.go b/cmd/workspace/secrets/overrides.go index b215f17a7f7..037ad384612 100644 --- a/cmd/workspace/secrets/overrides.go +++ b/cmd/workspace/secrets/overrides.go @@ -2,7 +2,7 @@ package secrets import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/workspace" + secrets "github.com/databricks/cli/libs/sdktypes/secrets/v1" "github.com/spf13/cobra" ) @@ -18,7 +18,7 @@ func listScopesOverride(listScopesCmd *cobra.Command) { {{end}}`) } -func listSecretsOverride(listSecretsCommand *cobra.Command, _ *workspace.ListSecretsRequest) { +func listSecretsOverride(listSecretsCommand *cobra.Command, _ *secrets.ListSecretsRequest) { listSecretsCommand.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "Key"}} {{header "Last Updated Timestamp"}}`) listSecretsCommand.Annotations["template"] = cmdio.Heredoc(` diff --git a/cmd/workspace/secrets/put_secret.go b/cmd/workspace/secrets/put_secret.go index 040f43f75b1..92e66f022a5 100644 --- a/cmd/workspace/secrets/put_secret.go +++ b/cmd/workspace/secrets/put_secret.go @@ -1,7 +1,6 @@ package secrets import ( - "encoding/base64" "errors" "io" @@ -10,20 +9,21 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/workspace" + secrets "github.com/databricks/cli/libs/sdktypes/secrets/v1" "github.com/spf13/cobra" ) func newPutSecret() *cobra.Command { cmd := &cobra.Command{} - var putSecretReq workspace.PutSecret + var putSecretReq secrets.PutSecretRequest var putSecretJson flags.JsonFlag + var bytesValue, stringValue string cmd.Flags().Var(&putSecretJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&putSecretReq.BytesValue, "bytes-value", putSecretReq.BytesValue, `If specified, value will be stored as bytes.`) - cmd.Flags().StringVar(&putSecretReq.StringValue, "string-value", putSecretReq.StringValue, `If specified, note that the value will be stored in UTF-8 (MB4) form.`) + cmd.Flags().StringVar(&bytesValue, "bytes-value", bytesValue, `If specified, value will be stored as bytes.`) + cmd.Flags().StringVar(&stringValue, "string-value", stringValue, `If specified, note that the value will be stored in UTF-8 (MB4) form.`) cmd.Use = "put-secret SCOPE KEY" cmd.Short = `Add a secret.` @@ -82,26 +82,30 @@ func newPutSecret() *cobra.Command { } } } else { - putSecretReq.Scope = args[0] - putSecretReq.Key = args[1] + putSecretReq.Scope = new(args[0]) + putSecretReq.Key = new(args[1]) + // bytes_value is base64 on the wire; the request type encodes it. switch { case bytesValueChanged: - // Bytes value set; encode as base64. - putSecretReq.BytesValue = base64.StdEncoding.EncodeToString([]byte(putSecretReq.BytesValue)) + putSecretReq.BytesValue = []byte(bytesValue) case stringValueChanged: - // String value set; nothing to do. + putSecretReq.StringValue = new(stringValue) default: // Neither is specified; read secret value from stdin. bytes, err := promptSecret(cmd) if err != nil { return err } - putSecretReq.BytesValue = base64.StdEncoding.EncodeToString(bytes) + putSecretReq.BytesValue = bytes } } - err = w.Secrets.PutSecret(ctx, putSecretReq) + sdkReq, err := secrets.PutSecretRequestToSDK(&putSecretReq) + if err != nil { + return err + } + _, err = w.Secrets.PutSecret(ctx, *sdkReq) if err != nil { return err } diff --git a/cmd/workspace/secrets/secrets.go b/cmd/workspace/secrets/secrets.go index e3268ccfe6e..f61d20ca882 100644 --- a/cmd/workspace/secrets/secrets.go +++ b/cmd/workspace/secrets/secrets.go @@ -10,8 +10,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/workspace" "github.com/spf13/cobra" + + secrets "github.com/databricks/cli/libs/sdktypes/secrets/v1" + sdksecrets "github.com/databricks/sdk-go/secrets/v1" ) // Slice with functions to override default command behavior. @@ -68,20 +70,20 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createScopeOverrides []func( *cobra.Command, - *workspace.CreateScope, + *secrets.CreateScopeRequest, ) func newCreateScope() *cobra.Command { cmd := &cobra.Command{} + var createScopeReq secrets.CreateScopeRequest - var createScopeReq workspace.CreateScope var createScopeJson flags.JsonFlag cmd.Flags().Var(&createScopeJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: backend_azure_keyvault - cmd.Flags().StringVar(&createScopeReq.InitialManagePrincipal, "initial-manage-principal", createScopeReq.InitialManagePrincipal, `The principal that is initially granted MANAGE permission to the created scope.`) - cmd.Flags().Var(&createScopeReq.ScopeBackendType, "scope-backend-type", `The backend type the scope will be created with. Supported values: [AZURE_KEYVAULT, DATABRICKS]`) + flags.StringPtrVar(cmd.Flags(), &createScopeReq.InitialManagePrincipal, "initial-manage-principal", `The principal that is initially granted MANAGE permission to the created scope.`) + flags.EnumVar(cmd.Flags(), &createScopeReq.ScopeBackendType, "scope-backend-type", `The backend type the scope will be created with. Supported values: [AZURE_KEYVAULT, DATABRICKS]`, "ScopeBackendType", "AZURE_KEYVAULT", "DATABRICKS") cmd.Use = "create-scope SCOPE" cmd.Short = `Create a new secret scope.` @@ -148,6 +150,7 @@ func newCreateScope() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createScopeJson.Unmarshal(&createScopeReq) @@ -162,13 +165,19 @@ func newCreateScope() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createScopeReq.Scope = args[0] + createScopeReq.Scope = new(args[0]) } - err = w.Secrets.CreateScope(ctx, createScopeReq) + sdkReq, err := secrets.CreateScopeRequestToSDK(&createScopeReq) + if err != nil { + return err + } + response, err := w.Secrets.CreateScope(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -190,13 +199,13 @@ func newCreateScope() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteAclOverrides []func( *cobra.Command, - *workspace.DeleteAcl, + *secrets.DeleteAclRequest, ) func newDeleteAcl() *cobra.Command { cmd := &cobra.Command{} + var deleteAclReq secrets.DeleteAclRequest - var deleteAclReq workspace.DeleteAcl var deleteAclJson flags.JsonFlag cmd.Flags().Var(&deleteAclJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -244,6 +253,7 @@ func newDeleteAcl() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deleteAclJson.Unmarshal(&deleteAclReq) @@ -258,16 +268,22 @@ func newDeleteAcl() *cobra.Command { } } if !cmd.Flags().Changed("json") { - deleteAclReq.Scope = args[0] + deleteAclReq.Scope = new(args[0]) } if !cmd.Flags().Changed("json") { - deleteAclReq.Principal = args[1] + deleteAclReq.Principal = new(args[1]) } - err = w.Secrets.DeleteAcl(ctx, deleteAclReq) + sdkReq, err := secrets.DeleteAclRequestToSDK(&deleteAclReq) + if err != nil { + return err + } + response, err := w.Secrets.DeleteAcl(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -289,13 +305,13 @@ func newDeleteAcl() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteScopeOverrides []func( *cobra.Command, - *workspace.DeleteScope, + *secrets.DeleteScopeRequest, ) func newDeleteScope() *cobra.Command { cmd := &cobra.Command{} + var deleteScopeReq secrets.DeleteScopeRequest - var deleteScopeReq workspace.DeleteScope var deleteScopeJson flags.JsonFlag cmd.Flags().Var(&deleteScopeJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -340,6 +356,7 @@ func newDeleteScope() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deleteScopeJson.Unmarshal(&deleteScopeReq) @@ -354,13 +371,19 @@ func newDeleteScope() *cobra.Command { } } if !cmd.Flags().Changed("json") { - deleteScopeReq.Scope = args[0] + deleteScopeReq.Scope = new(args[0]) } - err = w.Secrets.DeleteScope(ctx, deleteScopeReq) + sdkReq, err := secrets.DeleteScopeRequestToSDK(&deleteScopeReq) + if err != nil { + return err + } + response, err := w.Secrets.DeleteScope(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -382,13 +405,13 @@ func newDeleteScope() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteSecretOverrides []func( *cobra.Command, - *workspace.DeleteSecret, + *secrets.DeleteSecretRequest, ) func newDeleteSecret() *cobra.Command { cmd := &cobra.Command{} + var deleteSecretReq secrets.DeleteSecretRequest - var deleteSecretReq workspace.DeleteSecret var deleteSecretJson flags.JsonFlag cmd.Flags().Var(&deleteSecretJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -435,6 +458,7 @@ func newDeleteSecret() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deleteSecretJson.Unmarshal(&deleteSecretReq) @@ -449,16 +473,22 @@ func newDeleteSecret() *cobra.Command { } } if !cmd.Flags().Changed("json") { - deleteSecretReq.Scope = args[0] + deleteSecretReq.Scope = new(args[0]) } if !cmd.Flags().Changed("json") { - deleteSecretReq.Key = args[1] + deleteSecretReq.Key = new(args[1]) } - err = w.Secrets.DeleteSecret(ctx, deleteSecretReq) + sdkReq, err := secrets.DeleteSecretRequestToSDK(&deleteSecretReq) + if err != nil { + return err + } + response, err := w.Secrets.DeleteSecret(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -480,13 +510,12 @@ func newDeleteSecret() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getAclOverrides []func( *cobra.Command, - *workspace.GetAclRequest, + *secrets.GetAclRequest, ) func newGetAcl() *cobra.Command { cmd := &cobra.Command{} - - var getAclReq workspace.GetAclRequest + var getAclReq secrets.GetAclRequest cmd.Use = "get-acl SCOPE PRINCIPAL" cmd.Short = `Get secret ACL details.` @@ -524,16 +553,25 @@ func newGetAcl() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getAclReq.Scope = args[0] - getAclReq.Principal = args[1] + getAclReq.Scope = new(args[0]) + getAclReq.Principal = new(args[1]) - response, err := w.Secrets.GetAcl(ctx, getAclReq) + sdkReq, err := secrets.GetAclRequestToSDK(&getAclReq) + if err != nil { + return err + } + response, err := w.Secrets.GetAcl(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := secrets.AclItemFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -554,13 +592,12 @@ func newGetAcl() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getSecretOverrides []func( *cobra.Command, - *workspace.GetSecretRequest, + *secrets.GetSecretRequest, ) func newGetSecret() *cobra.Command { cmd := &cobra.Command{} - - var getSecretReq workspace.GetSecretRequest + var getSecretReq secrets.GetSecretRequest cmd.Use = "get-secret SCOPE KEY" cmd.Short = `Get a secret.` @@ -611,16 +648,25 @@ func newGetSecret() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSecretReq.Scope = args[0] - getSecretReq.Key = args[1] + getSecretReq.Scope = new(args[0]) + getSecretReq.Key = new(args[1]) - response, err := w.Secrets.GetSecret(ctx, getSecretReq) + sdkReq, err := secrets.GetSecretRequestToSDK(&getSecretReq) + if err != nil { + return err + } + response, err := w.Secrets.GetSecret(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := secrets.GetSecretResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -641,13 +687,13 @@ func newGetSecret() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listAclsOverrides []func( *cobra.Command, - *workspace.ListAclsRequest, + *secrets.ListAclsRequest, ) func newListAcls() *cobra.Command { cmd := &cobra.Command{} + var listAclsReq secrets.ListAclsRequest - var listAclsReq workspace.ListAclsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -693,10 +739,18 @@ func newListAcls() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listAclsReq.Scope = args[0] + listAclsReq.Scope = new(args[0]) - response := w.Secrets.ListAcls(ctx, listAclsReq) + sdkReq, err := secrets.ListAclsRequestToSDK(&listAclsReq) + if err != nil { + return err + } + response, err := w.Secrets.ListAcls(ctx, *sdkReq) + if err != nil { + return err + } if listAclsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listAclsLimit) } @@ -704,7 +758,11 @@ func newListAcls() *cobra.Command { ctx = cmdio.WithLimit(ctx, listAclsLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := secrets.ListAclsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.Items) } // Disable completions since they are not applicable. @@ -763,7 +821,14 @@ func newListScopes() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response := w.Secrets.ListScopes(ctx) + _ = w + + sdkReq := &sdksecrets.ListScopesRequest{} + + response, err := w.Secrets.ListScopes(ctx, *sdkReq) + if err != nil { + return err + } if listScopesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listScopesLimit) } @@ -771,7 +836,11 @@ func newListScopes() *cobra.Command { ctx = cmdio.WithLimit(ctx, listScopesLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := secrets.ListScopesResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.Scopes) } // Disable completions since they are not applicable. @@ -792,13 +861,13 @@ func newListScopes() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listSecretsOverrides []func( *cobra.Command, - *workspace.ListSecretsRequest, + *secrets.ListSecretsRequest, ) func newListSecrets() *cobra.Command { cmd := &cobra.Command{} + var listSecretsReq secrets.ListSecretsRequest - var listSecretsReq workspace.ListSecretsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -847,10 +916,18 @@ func newListSecrets() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listSecretsReq.Scope = args[0] + listSecretsReq.Scope = new(args[0]) - response := w.Secrets.ListSecrets(ctx, listSecretsReq) + sdkReq, err := secrets.ListSecretsRequestToSDK(&listSecretsReq) + if err != nil { + return err + } + response, err := w.Secrets.ListSecrets(ctx, *sdkReq) + if err != nil { + return err + } if listSecretsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSecretsLimit) } @@ -858,7 +935,11 @@ func newListSecrets() *cobra.Command { ctx = cmdio.WithLimit(ctx, listSecretsLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := secrets.ListSecretsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.Secrets) } // Disable completions since they are not applicable. @@ -879,13 +960,13 @@ func newListSecrets() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var putAclOverrides []func( *cobra.Command, - *workspace.PutAcl, + *secrets.PutAclRequest, ) func newPutAcl() *cobra.Command { cmd := &cobra.Command{} + var putAclReq secrets.PutAclRequest - var putAclReq workspace.PutAcl var putAclJson flags.JsonFlag cmd.Flags().Var(&putAclJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -954,6 +1035,7 @@ func newPutAcl() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := putAclJson.Unmarshal(&putAclReq) @@ -968,23 +1050,25 @@ func newPutAcl() *cobra.Command { } } if !cmd.Flags().Changed("json") { - putAclReq.Scope = args[0] + putAclReq.Scope = new(args[0]) } if !cmd.Flags().Changed("json") { - putAclReq.Principal = args[1] + putAclReq.Principal = new(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &putAclReq.Permission) - if err != nil { - return fmt.Errorf("invalid PERMISSION: %s", args[2]) - } - + putAclReq.Permission = secrets.AclPermission(args[2]) } - err = w.Secrets.PutAcl(ctx, putAclReq) + sdkReq, err := secrets.PutAclRequestToSDK(&putAclReq) if err != nil { return err } + response, err := w.Secrets.PutAcl(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } diff --git a/cmd/workspace/service-principal-secrets-proxy/service-principal-secrets-proxy.go b/cmd/workspace/service-principal-secrets-proxy/service-principal-secrets-proxy.go index 1f0fde3cee8..96938a39c0b 100644 --- a/cmd/workspace/service-principal-secrets-proxy/service-principal-secrets-proxy.go +++ b/cmd/workspace/service-principal-secrets-proxy/service-principal-secrets-proxy.go @@ -7,10 +7,12 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/oauth2" "github.com/spf13/cobra" + + authentication "github.com/databricks/cli/libs/sdktypes/authentication/v1" ) // Slice with functions to override default command behavior. @@ -63,18 +65,18 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *oauth2.CreateServicePrincipalSecretRequest, + *authentication.CreateServicePrincipalSecretRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq authentication.CreateServicePrincipalSecretRequest - var createReq oauth2.CreateServicePrincipalSecretRequest 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.Lifetime, "lifetime", createReq.Lifetime, `The lifetime of the secret in seconds.`) + flags.JSONStringPtrVar(cmd.Flags(), &createReq.Lifetime, "lifetime", `The lifetime of the secret in seconds.`) cmd.Use = "create SERVICE_PRINCIPAL_ID" cmd.Short = `Create service principal secret.` @@ -98,6 +100,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -111,14 +114,22 @@ func newCreate() *cobra.Command { } } } - createReq.ServicePrincipalId = args[0] + createReq.ServicePrincipal = new(args[0]) - response, err := w.ServicePrincipalSecretsProxy.Create(ctx, createReq) + sdkReq, err := authentication.CreateServicePrincipalSecretRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Authentication.CreateServicePrincipalSecretProxy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := authentication.CreateServicePrincipalSecretResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -139,13 +150,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *oauth2.DeleteServicePrincipalSecretRequest, + *authentication.DeleteServicePrincipalSecretRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq oauth2.DeleteServicePrincipalSecretRequest + var deleteReq authentication.DeleteServicePrincipalSecretRequest cmd.Use = "delete SERVICE_PRINCIPAL_ID SECRET_ID" cmd.Short = `Delete service principal secret.` @@ -170,14 +180,21 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.ServicePrincipalId = args[0] - deleteReq.SecretId = args[1] + deleteReq.ServicePrincipal = new(args[0]) + deleteReq.SecretId = new(args[1]) - err = w.ServicePrincipalSecretsProxy.Delete(ctx, deleteReq) + sdkReq, err := authentication.DeleteServicePrincipalSecretRequestToSDK(&deleteReq) if err != nil { return err } + response, err := w.Authentication.DeleteServicePrincipalSecretProxy(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -199,25 +216,25 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *oauth2.ListServicePrincipalSecretsRequest, + *authentication.ListServicePrincipalSecretsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq authentication.ListServicePrincipalSecretsRequest - var listReq oauth2.ListServicePrincipalSecretsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list SERVICE_PRINCIPAL_ID" @@ -244,18 +261,22 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.ServicePrincipalId = args[0] + listReq.ServicePrincipal = new(args[0]) - response := w.ServicePrincipalSecretsProxy.List(ctx, listReq) + sdkReq, err := authentication.ListServicePrincipalSecretsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Authentication.ListServicePrincipalSecretsProxyIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, authentication.ServicePrincipalSecretFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/service-principals-v2/service-principals-v2.go b/cmd/workspace/service-principals-v2/service-principals-v2.go index 2bce2b79cbf..f9216418e96 100644 --- a/cmd/workspace/service-principals-v2/service-principals-v2.go +++ b/cmd/workspace/service-principals-v2/service-principals-v2.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" + + scim "github.com/databricks/cli/libs/sdktypes/scim/v1" + sdkscim "github.com/databricks/sdk-go/scim/v1" ) // Slice with functions to override default command behavior. @@ -59,24 +62,24 @@ Identities for use with jobs, automated tools, and systems such as scripts, // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *iam.CreateServicePrincipalRequest, + *scim.CreateServicePrincipalRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq scim.CreateServicePrincipalRequest - var createReq iam.CreateServicePrincipalRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createReq.Active, "active", createReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&createReq.ApplicationId, "application-id", createReq.ApplicationId, `UUID relating to the service principal.`) - cmd.Flags().StringVar(&createReq.DisplayName, "display-name", createReq.DisplayName, `String that represents a concatenation of given and family names.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.Active, "active", `If this user is active.`) + flags.StringPtrVar(cmd.Flags(), &createReq.ApplicationId, "application-id", `UUID relating to the service principal.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DisplayName, "display-name", `String that represents a concatenation of given and family names.`) // TODO: array: entitlements - cmd.Flags().StringVar(&createReq.ExternalId, "external-id", createReq.ExternalId, ``) + flags.StringPtrVar(cmd.Flags(), &createReq.ExternalId, "external-id", ``) // TODO: array: groups - cmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Databricks service principal ID.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Id, "id", `Databricks service principal ID.`) // TODO: array: roles // TODO: array: schemas @@ -101,6 +104,7 @@ Create a service principal. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -115,12 +119,20 @@ Create a service principal. } } - response, err := w.ServicePrincipalsV2.Create(ctx, createReq) + sdkReq, err := scim.CreateServicePrincipalRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Scim.CreateServicePrincipal(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.ServicePrincipalFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -141,13 +153,12 @@ Create a service principal. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *iam.DeleteServicePrincipalRequest, + *sdkscim.DeleteServicePrincipalRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq iam.DeleteServicePrincipalRequest + var deleteReq sdkscim.DeleteServicePrincipalRequest cmd.Use = "delete ID" cmd.Short = `*Public Preview* Delete a service principal.` @@ -173,10 +184,12 @@ Delete a service principal. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = w.ServicePrincipalsV2.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = w.Scim.DeleteServicePrincipal(ctx, *sdkReq) if err != nil { return err } @@ -201,13 +214,12 @@ Delete a service principal. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *iam.GetServicePrincipalRequest, + *sdkscim.GetServicePrincipalRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq iam.GetServicePrincipalRequest + var getReq sdkscim.GetServicePrincipalRequest cmd.Use = "get ID" cmd.Short = `*Public Preview* Get service principal details.` @@ -234,15 +246,21 @@ Get service principal details. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.ServicePrincipalsV2.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Scim.GetServicePrincipal(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.ServicePrincipalFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -263,31 +281,31 @@ Get service principal details. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *iam.ListServicePrincipalsRequest, + *scim.ListServicePrincipalsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq scim.ListServicePrincipalsRequest - var listReq iam.ListServicePrincipalsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.Attributes, "attributes", listReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().StringVar(&listReq.ExcludedAttributes, "excluded-attributes", listReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&listReq.Filter, "filter", listReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&listReq.SortBy, "sort-by", listReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) + flags.StringPtrVar(cmd.Flags(), &listReq.Attributes, "attributes", `Comma-separated list of attributes to return in response.`) + flags.StringPtrVar(cmd.Flags(), &listReq.ExcludedAttributes, "excluded-attributes", `Comma-separated list of attributes to exclude in response.`) + flags.StringPtrVar(cmd.Flags(), &listReq.Filter, "filter", `Query by which the results have to be filtered.`) + flags.StringPtrVar(cmd.Flags(), &listReq.SortBy, "sort-by", `Attribute to sort the results.`) + flags.EnumVar(cmd.Flags(), &listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`, "ListSortOrder", "ascending", "descending") // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().Int64Var(&listReq.StartIndex, "start-index", listReq.StartIndex, `Specifies the index of the first result.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.StartIndex, "start-index", `Specifies the index of the first result.`) cmd.Flags().Lookup("start-index").Hidden = true - cmd.Flags().Int64Var(&listReq.Count, "count", listReq.Count, `Number of results per API page.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.Count, "count", `Number of results per API page.`) cmd.Flags().Lookup("count").Hidden = true cmd.Use = "list" @@ -311,16 +329,20 @@ List service principals. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.ServicePrincipalsV2.List(ctx, listReq) + sdkReq, err := scim.ListServicePrincipalsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Scim.ListServicePrincipalsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, scim.ServicePrincipalFromSDK)) } // Disable completions since they are not applicable. @@ -341,13 +363,13 @@ List service principals. // Functions can be added from the `init()` function in manually curated files in this directory. var patchOverrides []func( *cobra.Command, - *iam.PatchServicePrincipalRequest, + *scim.PatchServicePrincipalRequest, ) func newPatch() *cobra.Command { cmd := &cobra.Command{} + var patchReq scim.PatchServicePrincipalRequest - var patchReq iam.PatchServicePrincipalRequest var patchJson flags.JsonFlag cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -380,6 +402,7 @@ Update service principal details. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -393,9 +416,13 @@ Update service principal details. } } } - patchReq.Id = args[0] + patchReq.Id = new(args[0]) - err = w.ServicePrincipalsV2.Patch(ctx, patchReq) + sdkReq, err := scim.PatchServicePrincipalRequestToSDK(&patchReq) + if err != nil { + return err + } + err = w.Scim.PatchServicePrincipal(ctx, *sdkReq) if err != nil { return err } @@ -420,22 +447,22 @@ Update service principal details. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *iam.UpdateServicePrincipalRequest, + *scim.UpdateServicePrincipalRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq scim.UpdateServicePrincipalRequest - var updateReq iam.UpdateServicePrincipalRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&updateReq.Active, "active", updateReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&updateReq.ApplicationId, "application-id", updateReq.ApplicationId, `UUID relating to the service principal.`) - cmd.Flags().StringVar(&updateReq.DisplayName, "display-name", updateReq.DisplayName, `String that represents a concatenation of given and family names.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Active, "active", `If this user is active.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.ApplicationId, "application-id", `UUID relating to the service principal.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.DisplayName, "display-name", `String that represents a concatenation of given and family names.`) // TODO: array: entitlements - cmd.Flags().StringVar(&updateReq.ExternalId, "external-id", updateReq.ExternalId, ``) + flags.StringPtrVar(cmd.Flags(), &updateReq.ExternalId, "external-id", ``) // TODO: array: groups // TODO: array: roles // TODO: array: schemas @@ -466,6 +493,7 @@ Replace service principal. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -479,9 +507,13 @@ Replace service principal. } } } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - err = w.ServicePrincipalsV2.Update(ctx, updateReq) + sdkReq, err := scim.UpdateServicePrincipalRequestToSDK(&updateReq) + if err != nil { + return err + } + err = w.Scim.UpdateServicePrincipal(ctx, *sdkReq) if err != nil { return err } diff --git a/cmd/workspace/service-principals/overrides.go b/cmd/workspace/service-principals/overrides.go index 185549b7c5e..480f2b66db0 100644 --- a/cmd/workspace/service-principals/overrides.go +++ b/cmd/workspace/service-principals/overrides.go @@ -2,11 +2,10 @@ package service_principals import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *iam.ListServicePrincipalsRequest) { +func listOverride(listCmd *cobra.Command) { listCmd.Annotations["template"] = cmdio.Heredoc(` {{range .}}{{.Id|green}} {{.ApplicationId}} {{.DisplayName}} {{range .Groups}}{{.Display}} {{end}} {{if .Active}}{{"ACTIVE"|green}}{{else}}DISABLED{{end}} {{end}}`) diff --git a/cmd/workspace/service-principals/service-principals.go b/cmd/workspace/service-principals/service-principals.go index 76737b45176..c46207f3577 100755 --- a/cmd/workspace/service-principals/service-principals.go +++ b/cmd/workspace/service-principals/service-principals.go @@ -2,17 +2,11 @@ // but are now manually maintained because the v2 API versions have taken // over as the generated commands. See https://github.com/databricks/cli/pull/4722. -//nolint:staticcheck,perfsprint package service_principals 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/iam" + service_principals_v2 "github.com/databricks/cli/cmd/workspace/service-principals-v2" "github.com/spf13/cobra" ) @@ -20,6 +14,11 @@ import ( // Functions can be added from the `init()` function in manually curated files in this directory. var cmdOverrides []func(*cobra.Command) +// Slices with functions to override the behavior of individual commands. +var listOverrides []func(*cobra.Command) + +// The commands are the service-principals-v2 commands (same API) presented under their +// original names and help text. func New() *cobra.Command { cmd := &cobra.Command{ Use: "service-principals", @@ -37,472 +36,103 @@ func New() *cobra.Command { RunE: root.ReportUnknownSubcommand, } - // Add methods - cmd.AddCommand(newCreate()) - cmd.AddCommand(newDelete()) - cmd.AddCommand(newGet()) - cmd.AddCommand(newList()) - cmd.AddCommand(newPatch()) - 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, - *iam.ServicePrincipal, -) - -func newCreate() *cobra.Command { - cmd := &cobra.Command{} - - var createReq iam.ServicePrincipal - var createJson flags.JsonFlag - - cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - cmd.Flags().BoolVar(&createReq.Active, "active", createReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&createReq.ApplicationId, "application-id", createReq.ApplicationId, `UUID relating to the service principal.`) - cmd.Flags().StringVar(&createReq.DisplayName, "display-name", createReq.DisplayName, `String that represents a concatenation of given and family names.`) - // TODO: array: entitlements - cmd.Flags().StringVar(&createReq.ExternalId, "external-id", createReq.ExternalId, ``) - // TODO: array: groups - cmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Databricks service principal ID.`) - // TODO: array: roles - // TODO: array: schemas - - cmd.Use = "create" - cmd.Short = `Create a service principal.` - cmd.Long = `Create a service principal. - - Creates a new service principal in the Databricks 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) - - if cmd.Flags().Changed("json") { - diags := createJson.Unmarshal(&createReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err + v2 := service_principals_v2.New() + for _, sub := range v2.Commands() { + doc, ok := commandDocs[sub.Name()] + if !ok { + continue + } + v2.RemoveCommand(sub) + sub.Use = doc.use + if doc.short != "" { + sub.Short = doc.short + sub.Long = doc.long + } + sub.Hidden = doc.hidden + if sub.Name() == "list" { + // These were regular flags of the original commands. + for _, name := range []string{"count", "start-index"} { + if f := sub.Flags().Lookup(name); f != nil { + f.Hidden = false } } + for _, fn := range listOverrides { + fn(sub) + } } - - response, err := w.ServicePrincipals.Create(ctx, createReq) - if err != nil { - return err - } - return cmdio.Render(ctx, response) + cmd.AddCommand(sub) } - // 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) + for _, fn := range cmdOverrides { + fn(cmd) } 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, - *iam.DeleteServicePrincipalRequest, -) - -func newDelete() *cobra.Command { - cmd := &cobra.Command{} +type commandDoc struct { + use, short, long string + hidden bool +} - var deleteReq iam.DeleteServicePrincipalRequest +var commandDocs = map[string]commandDoc{ + "create": { + use: "create", + short: `Create a service principal.`, + long: `Create a service principal. - cmd.Use = "delete ID" - cmd.Short = `Delete a service principal.` - cmd.Long = `Delete a service principal. + Creates a new service principal in the Databricks workspace.`, + }, + "delete": { + use: "delete ID", + short: `Delete a service principal.`, + long: `Delete a service principal. Delete a single service principal in the Databricks workspace. Arguments: - ID: Unique ID for a service principal in the Databricks workspace.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Service Principals drop-down.") - names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID for a service principal in the Databricks workspace") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id for a service principal in the databricks workspace") - } - deleteReq.Id = args[0] - - err = w.ServicePrincipals.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, - *iam.GetServicePrincipalRequest, -) - -func newGet() *cobra.Command { - cmd := &cobra.Command{} - - var getReq iam.GetServicePrincipalRequest - - cmd.Use = "get ID" - cmd.Short = `Get service principal details.` - cmd.Long = `Get service principal details. + ID: Unique ID for a service principal in the Databricks workspace.`, + }, + "get": { + use: "get ID", + short: `Get service principal details.`, + long: `Get service principal details. Gets the details for a single service principal define in the Databricks workspace. Arguments: - ID: Unique ID for a service principal in the Databricks workspace.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Service Principals drop-down.") - names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID for a service principal in the Databricks workspace") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id for a service principal in the databricks workspace") - } - getReq.Id = args[0] - - response, err := w.ServicePrincipals.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, - *iam.ListServicePrincipalsRequest, -) - -func newList() *cobra.Command { - cmd := &cobra.Command{} - - var listReq iam.ListServicePrincipalsRequest - - cmd.Flags().StringVar(&listReq.Attributes, "attributes", listReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().Int64Var(&listReq.Count, "count", listReq.Count, `Desired number of results per page.`) - cmd.Flags().StringVar(&listReq.ExcludedAttributes, "excluded-attributes", listReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&listReq.Filter, "filter", listReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&listReq.SortBy, "sort-by", listReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) - cmd.Flags().Int64Var(&listReq.StartIndex, "start-index", listReq.StartIndex, `Specifies the index of the first result.`) - - cmd.Use = "list" - cmd.Short = `List service principals.` - cmd.Long = `List service principals. - - Gets the set of service principals associated with a Databricks 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.ServicePrincipals.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 patch 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 patchOverrides []func( - *cobra.Command, - *iam.PartialUpdate, -) - -func newPatch() *cobra.Command { - cmd := &cobra.Command{} - - var patchReq iam.PartialUpdate - var patchJson flags.JsonFlag - - cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - // TODO: array: Operations - // TODO: array: schemas - - cmd.Use = "patch ID" - cmd.Short = `Update service principal details.` - cmd.Long = `Update service principal details. + ID: Unique ID for a service principal in the Databricks workspace.`, + }, + "list": { + use: "list", + short: `List service principals.`, + long: `List service principals. + + Gets the set of service principals associated with a Databricks workspace.`, + }, + "patch": { + use: "patch ID", + short: `Update service principal details.`, + long: `Update service principal details. Partially updates the details of a single service principal in the Databricks workspace. Arguments: - ID: Unique ID in the Databricks workspace.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if cmd.Flags().Changed("json") { - diags := patchJson.Unmarshal(&patchReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Service Principals drop-down.") - names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID in the Databricks workspace") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id in the databricks workspace") - } - patchReq.Id = args[0] - - err = w.ServicePrincipals.Patch(ctx, patchReq) - 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 patchOverrides { - fn(cmd, &patchReq) - } - - 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, - *iam.ServicePrincipal, -) - -func newUpdate() *cobra.Command { - cmd := &cobra.Command{} - - var updateReq iam.ServicePrincipal - var updateJson flags.JsonFlag - - cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - cmd.Flags().BoolVar(&updateReq.Active, "active", updateReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&updateReq.ApplicationId, "application-id", updateReq.ApplicationId, `UUID relating to the service principal.`) - cmd.Flags().StringVar(&updateReq.DisplayName, "display-name", updateReq.DisplayName, `String that represents a concatenation of given and family names.`) - // TODO: array: entitlements - cmd.Flags().StringVar(&updateReq.ExternalId, "external-id", updateReq.ExternalId, ``) - // TODO: array: groups - cmd.Flags().StringVar(&updateReq.Id, "id", updateReq.Id, `Databricks service principal ID.`) - // TODO: array: roles - // TODO: array: schemas - - cmd.Use = "update ID" - cmd.Short = `Replace service principal.` - cmd.Long = `Replace service principal. + ID: Unique ID in the Databricks workspace.`, + }, + "update": { + use: "update ID", + short: `Replace service principal.`, + long: `Replace service principal. Updates the details of a single service principal. This action replaces the existing service principal with the same name. Arguments: - ID: Databricks service principal ID.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if cmd.Flags().Changed("json") { - diags := updateJson.Unmarshal(&updateReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Service Principals drop-down.") - names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks service principal ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks service principal id") - } - updateReq.Id = args[0] - - err = w.ServicePrincipals.Update(ctx, updateReq) - 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 updateOverrides { - fn(cmd, &updateReq) - } - - return cmd + ID: Databricks service principal ID.`, + }, } - -// end service ServicePrincipals diff --git a/cmd/workspace/serving-endpoints/serving-endpoints.go b/cmd/workspace/serving-endpoints/serving-endpoints.go index 7c837c5d2dd..ec7dc7e89fd 100644 --- a/cmd/workspace/serving-endpoints/serving-endpoints.go +++ b/cmd/workspace/serving-endpoints/serving-endpoints.go @@ -7,12 +7,24 @@ import ( "fmt" "time" + "net/url" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/serving" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + modelserving "github.com/databricks/cli/libs/sdktypes/modelserving/v1" + modelservingquery "github.com/databricks/cli/libs/sdktypes/modelservingquery/v1" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdkmodelserving "github.com/databricks/sdk-go/modelserving/v1" ) // Slice with functions to override default command behavior. @@ -82,13 +94,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var buildLogsOverrides []func( *cobra.Command, - *serving.BuildLogsRequest, + *sdkmodelserving.GetServedModelBuildLogsRequest, ) func newBuildLogs() *cobra.Command { cmd := &cobra.Command{} - - var buildLogsReq serving.BuildLogsRequest + var buildLogsReq sdkmodelserving.GetServedModelBuildLogsRequest cmd.Use = "build-logs NAME SERVED_MODEL_NAME" cmd.Short = `Get build logs for a served model.` @@ -115,16 +126,22 @@ func newBuildLogs() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - buildLogsReq.Name = args[0] - buildLogsReq.ServedModelName = args[1] + buildLogsReq.Name = new(args[0]) + buildLogsReq.ServedModelName = new(args[1]) - response, err := w.ServingEndpoints.BuildLogs(ctx, buildLogsReq) + sdkReq := &buildLogsReq + response, err := w.ServingEndpoints.GetServedModelBuildLogs(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelserving.GetServedModelBuildLogsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -145,13 +162,13 @@ func newBuildLogs() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *serving.CreateServingEndpoint, + *modelserving.CreateInferenceEndpointRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq modelserving.CreateInferenceEndpointRequest - var createReq serving.CreateServingEndpoint var createJson flags.JsonFlag var createSkipWait bool @@ -163,12 +180,12 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: ai_gateway - cmd.Flags().StringVar(&createReq.BudgetPolicyId, "budget-policy-id", createReq.BudgetPolicyId, `The budget policy to be applied to the serving endpoint.`) + flags.StringPtrVar(cmd.Flags(), &createReq.BudgetPolicyId, "budget-policy-id", `The budget policy to be applied to the serving endpoint.`) // TODO: complex arg: config - cmd.Flags().StringVar(&createReq.Description, "description", createReq.Description, ``) + flags.StringPtrVar(cmd.Flags(), &createReq.Description, "description", ``) // TODO: complex arg: email_notifications // TODO: array: rate_limits - cmd.Flags().BoolVar(&createReq.RouteOptimized, "route-optimized", createReq.RouteOptimized, `Enable route optimization for the serving endpoint.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.RouteOptimized, "route-optimized", `Enable route optimization for the serving endpoint.`) // TODO: array: tags // TODO: complex arg: telemetry_config @@ -201,6 +218,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -215,27 +233,42 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Name = args[0] + createReq.Name = new(args[0]) } - wait, err := w.ServingEndpoints.Create(ctx, createReq) + sdkReq, err := modelserving.CreateInferenceEndpointRequestToSDK(&createReq) if err != nil { return err } if createSkipWait { - return cmdio.Render(ctx, wait.Response) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var current modelserving.InferenceEndpointDetailed + err = api.Do(ctx, "POST", "/api/2.0/serving-endpoints", auth.WorkspaceIDHeaders(w.Config), nil, &createReq, ¤t) + if err != nil { + return err + } + return cmdio.Render(ctx, current) + } + wait, err := w.ServingEndpoints.CreateInferenceEndpoint(ctx, *sdkReq) + if err != nil { + return err } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *serving.ServingEndpointDetailed) { - status := i.State.ConfigUpdate - statusMessage := fmt.Sprintf("current status: %s", status) - sp.Update(statusMessage) - }).GetWithTimeout(createTimeout) + sp.Update("Waiting for create to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := modelserving.InferenceEndpointDetailedFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -256,13 +289,13 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createProvisionedThroughputEndpointOverrides []func( *cobra.Command, - *serving.CreatePtEndpointRequest, + *modelserving.CreatePtEndpointRequest, ) func newCreateProvisionedThroughputEndpoint() *cobra.Command { cmd := &cobra.Command{} + var createProvisionedThroughputEndpointReq modelserving.CreatePtEndpointRequest - var createProvisionedThroughputEndpointReq serving.CreatePtEndpointRequest var createProvisionedThroughputEndpointJson flags.JsonFlag var createProvisionedThroughputEndpointSkipWait bool @@ -274,7 +307,7 @@ func newCreateProvisionedThroughputEndpoint() *cobra.Command { cmd.Flags().Var(&createProvisionedThroughputEndpointJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: ai_gateway - cmd.Flags().StringVar(&createProvisionedThroughputEndpointReq.BudgetPolicyId, "budget-policy-id", createProvisionedThroughputEndpointReq.BudgetPolicyId, `The budget policy associated with the endpoint.`) + flags.StringPtrVar(cmd.Flags(), &createProvisionedThroughputEndpointReq.BudgetPolicyId, "budget-policy-id", `The budget policy associated with the endpoint.`) // TODO: complex arg: email_notifications // TODO: array: tags @@ -292,6 +325,7 @@ Create a new PT serving endpoint.` cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createProvisionedThroughputEndpointJson.Unmarshal(&createProvisionedThroughputEndpointReq) @@ -308,24 +342,39 @@ Create a new PT serving endpoint.` return errors.New("please provide command input in JSON format by specifying the --json flag") } - wait, err := w.ServingEndpoints.CreateProvisionedThroughputEndpoint(ctx, createProvisionedThroughputEndpointReq) + sdkReq, err := modelserving.CreatePtEndpointRequestToSDK(&createProvisionedThroughputEndpointReq) if err != nil { return err } if createProvisionedThroughputEndpointSkipWait { - return cmdio.Render(ctx, wait.Response) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var current modelserving.InferenceEndpointDetailed + err = api.Do(ctx, "POST", "/api/2.0/serving-endpoints/pt", auth.WorkspaceIDHeaders(w.Config), nil, &createProvisionedThroughputEndpointReq, ¤t) + if err != nil { + return err + } + return cmdio.Render(ctx, current) + } + wait, err := w.ServingEndpoints.CreateProvisionedThroughputInferenceEndpoint(ctx, *sdkReq) + if err != nil { + return err } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *serving.ServingEndpointDetailed) { - status := i.State.ConfigUpdate - statusMessage := fmt.Sprintf("current status: %s", status) - sp.Update(statusMessage) - }).GetWithTimeout(createProvisionedThroughputEndpointTimeout) + sp.Update("Waiting for create-provisioned-throughput-endpoint to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createProvisionedThroughputEndpointTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := modelserving.InferenceEndpointDetailedFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -346,13 +395,12 @@ Create a new PT serving endpoint.` // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *serving.DeleteServingEndpointRequest, + *sdkmodelserving.DeleteInferenceEndpointRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq serving.DeleteServingEndpointRequest + var deleteReq sdkmodelserving.DeleteInferenceEndpointRequest cmd.Use = "delete NAME" cmd.Short = `Delete a serving endpoint.` @@ -371,13 +419,17 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Name = args[0] + deleteReq.Name = new(args[0]) - err = w.ServingEndpoints.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.ServingEndpoints.DeleteInferenceEndpoint(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -399,13 +451,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var exportMetricsOverrides []func( *cobra.Command, - *serving.ExportMetricsRequest, + *sdkmodelserving.GetExportEndpointMetricsRequest, ) func newExportMetrics() *cobra.Command { cmd := &cobra.Command{} - - var exportMetricsReq serving.ExportMetricsRequest + var exportMetricsReq sdkmodelserving.GetExportEndpointMetricsRequest cmd.Use = "export-metrics NAME" cmd.Short = `Get metrics of a serving endpoint.` @@ -431,16 +482,18 @@ func newExportMetrics() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - exportMetricsReq.Name = args[0] + exportMetricsReq.Name = new(args[0]) - response, err := w.ServingEndpoints.ExportMetrics(ctx, exportMetricsReq) + sdkReq := &exportMetricsReq + response, err := w.ServingEndpoints.GetExportEndpointMetrics(ctx, *sdkReq) if err != nil { return err } - defer response.Contents.Close() - return cmdio.Render(ctx, response.Contents) + _ = response + return nil } // Disable completions since they are not applicable. @@ -461,13 +514,12 @@ func newExportMetrics() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *serving.GetServingEndpointRequest, + *sdkmodelserving.GetInferenceEndpointRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq serving.GetServingEndpointRequest + var getReq sdkmodelserving.GetInferenceEndpointRequest cmd.Use = "get NAME" cmd.Short = `Get a single serving endpoint.` @@ -491,15 +543,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Name = args[0] + getReq.Name = new(args[0]) - response, err := w.ServingEndpoints.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.ServingEndpoints.GetInferenceEndpoint(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelserving.InferenceEndpointDetailedFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -520,13 +578,12 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOpenApiOverrides []func( *cobra.Command, - *serving.GetOpenApiRequest, + *sdkmodelserving.GetInferenceEndpointSchemaRequest, ) func newGetOpenApi() *cobra.Command { cmd := &cobra.Command{} - - var getOpenApiReq serving.GetOpenApiRequest + var getOpenApiReq sdkmodelserving.GetInferenceEndpointSchemaRequest cmd.Use = "get-open-api NAME" cmd.Short = `*Public Preview* Get the schema for a serving endpoint.` @@ -555,16 +612,18 @@ Get the schema for a serving endpoint. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getOpenApiReq.Name = args[0] + getOpenApiReq.Name = new(args[0]) - response, err := w.ServingEndpoints.GetOpenApi(ctx, getOpenApiReq) + sdkReq := &getOpenApiReq + response, err := w.ServingEndpoints.GetInferenceEndpointSchema(ctx, *sdkReq) if err != nil { return err } - defer response.Contents.Close() - return cmdio.Render(ctx, response.Contents) + _ = response + return nil } // Disable completions since they are not applicable. @@ -585,13 +644,12 @@ Get the schema for a serving endpoint. // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *serving.GetServingEndpointPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq serving.GetServingEndpointPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels SERVING_ENDPOINT_ID" cmd.Short = `Get serving endpoint permission levels.` @@ -615,15 +673,23 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getPermissionLevelsReq.ServingEndpointId = args[0] + getPermissionLevelsReq.RequestObjectId = new(args[0]) - response, err := w.ServingEndpoints.GetPermissionLevels(ctx, getPermissionLevelsReq) + getPermissionLevelsReq.RequestObjectType = new("serving-endpoints") + + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -644,13 +710,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *serving.GetServingEndpointPermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq serving.GetServingEndpointPermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions SERVING_ENDPOINT_ID" cmd.Short = `Get serving endpoint permissions.` @@ -675,15 +740,23 @@ func newGetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getPermissionsReq.RequestObjectId = new(args[0]) - getPermissionsReq.ServingEndpointId = args[0] + getPermissionsReq.RequestObjectType = new("serving-endpoints") - response, err := w.ServingEndpoints.GetPermissions(ctx, getPermissionsReq) + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -704,18 +777,17 @@ func newGetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var httpRequestOverrides []func( *cobra.Command, - *serving.ExternalFunctionRequest, + *modelserving.ExternalFunctionRequest, ) func newHttpRequest() *cobra.Command { cmd := &cobra.Command{} + var httpRequestReq modelserving.ExternalFunctionRequest - var httpRequestReq serving.ExternalFunctionRequest - - cmd.Flags().StringVar(&httpRequestReq.Headers, "headers", httpRequestReq.Headers, `Additional headers for the request.`) - cmd.Flags().StringVar(&httpRequestReq.Json, "json", httpRequestReq.Json, `The JSON payload to send in the request body.`) - cmd.Flags().StringVar(&httpRequestReq.Params, "params", httpRequestReq.Params, `Query parameters for the request.`) - cmd.Flags().StringVar(&httpRequestReq.SubDomain, "sub-domain", httpRequestReq.SubDomain, `Optional subdomain to prepend to the connection URL's host.`) + flags.StringPtrVar(cmd.Flags(), &httpRequestReq.Headers, "headers", `Additional headers for the request.`) + flags.StringPtrVar(cmd.Flags(), &httpRequestReq.Json, "json", `The JSON payload to send in the request body.`) + flags.StringPtrVar(cmd.Flags(), &httpRequestReq.Params, "params", `Query parameters for the request.`) + flags.StringPtrVar(cmd.Flags(), &httpRequestReq.SubDomain, "sub-domain", `Optional subdomain to prepend to the connection URL's host.`) cmd.Use = "http-request CONNECTION_NAME METHOD PATH" cmd.Short = `Make external services call using the credentials stored in UC Connection.` @@ -744,22 +816,23 @@ func newHttpRequest() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - httpRequestReq.ConnectionName = args[0] - _, err = fmt.Sscan(args[1], &httpRequestReq.Method) + httpRequestReq.ConnectionName = new(args[0]) + httpRequestReq.Method = modelserving.ExternalFunctionRequest_HttpMethod(args[1]) + httpRequestReq.Path = new(args[2]) + + sdkReq, err := modelserving.ExternalFunctionRequestToSDK(&httpRequestReq) if err != nil { - return fmt.Errorf("invalid METHOD: %s", args[1]) + return err } - - httpRequestReq.Path = args[2] - - response, err := w.ServingEndpoints.HttpRequest(ctx, httpRequestReq) + response, err := w.ServingEndpoints.HttpRequest(ctx, *sdkReq) if err != nil { return err } - defer response.Contents.Close() - return cmdio.Render(ctx, response.Contents) + _ = response + return nil } // Disable completions since they are not applicable. @@ -806,7 +879,14 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response := w.ServingEndpoints.List(ctx) + _ = w + + sdkReq := &sdkmodelserving.ListInferenceEndpointsRequest{} + + response, err := w.ServingEndpoints.ListInferenceEndpoints(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -814,7 +894,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := modelserving.ListInferenceEndpointsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.Endpoints) } // Disable completions since they are not applicable. @@ -835,13 +919,12 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var logsOverrides []func( *cobra.Command, - *serving.LogsRequest, + *sdkmodelserving.GetServedModelLogsRequest, ) func newLogs() *cobra.Command { cmd := &cobra.Command{} - - var logsReq serving.LogsRequest + var logsReq sdkmodelserving.GetServedModelLogsRequest cmd.Use = "logs NAME SERVED_MODEL_NAME" cmd.Short = `Get the latest logs for a served model.` @@ -868,16 +951,22 @@ func newLogs() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - logsReq.Name = args[0] - logsReq.ServedModelName = args[1] + logsReq.Name = new(args[0]) + logsReq.ServedModelName = new(args[1]) - response, err := w.ServingEndpoints.Logs(ctx, logsReq) + sdkReq := &logsReq + response, err := w.ServingEndpoints.GetServedModelLogs(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelserving.GetServedModelLogsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -898,13 +987,13 @@ func newLogs() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var patchOverrides []func( *cobra.Command, - *serving.PatchServingEndpointTags, + *modelserving.PatchInferenceEndpointTagsRequest, ) func newPatch() *cobra.Command { cmd := &cobra.Command{} + var patchReq modelserving.PatchInferenceEndpointTagsRequest - var patchReq serving.PatchServingEndpointTags var patchJson flags.JsonFlag cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -936,6 +1025,7 @@ func newPatch() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -949,14 +1039,22 @@ func newPatch() *cobra.Command { } } } - patchReq.Name = args[0] + patchReq.Name = new(args[0]) - response, err := w.ServingEndpoints.Patch(ctx, patchReq) + sdkReq, err := modelserving.PatchInferenceEndpointTagsRequestToSDK(&patchReq) + if err != nil { + return err + } + response, err := w.ServingEndpoints.PatchInferenceEndpointTags(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelserving.PatchInferenceEndpointTagsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -977,13 +1075,13 @@ func newPatch() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var patchTelemetryConfigOverrides []func( *cobra.Command, - *serving.PatchTelemetryConfigRequest, + *modelserving.PatchInferenceEndpointTelemetryConfigRequest, ) func newPatchTelemetryConfig() *cobra.Command { cmd := &cobra.Command{} + var patchTelemetryConfigReq modelserving.PatchInferenceEndpointTelemetryConfigRequest - var patchTelemetryConfigReq serving.PatchTelemetryConfigRequest var patchTelemetryConfigJson flags.JsonFlag cmd.Flags().Var(&patchTelemetryConfigJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1013,6 +1111,7 @@ func newPatchTelemetryConfig() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := patchTelemetryConfigJson.Unmarshal(&patchTelemetryConfigReq) @@ -1026,14 +1125,22 @@ func newPatchTelemetryConfig() *cobra.Command { } } } - patchTelemetryConfigReq.Name = args[0] + patchTelemetryConfigReq.Name = new(args[0]) - response, err := w.ServingEndpoints.PatchTelemetryConfig(ctx, patchTelemetryConfigReq) + sdkReq, err := modelserving.PatchInferenceEndpointTelemetryConfigRequestToSDK(&patchTelemetryConfigReq) + if err != nil { + return err + } + response, err := w.ServingEndpoints.PatchInferenceEndpointTelemetryConfig(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelserving.InferenceEndpointDetailedFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1054,13 +1161,13 @@ func newPatchTelemetryConfig() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var putOverrides []func( *cobra.Command, - *serving.PutRequest, + *modelserving.PutInferenceEndpointRateLimitsRequest, ) func newPut() *cobra.Command { cmd := &cobra.Command{} + var putReq modelserving.PutInferenceEndpointRateLimitsRequest - var putReq serving.PutRequest var putJson flags.JsonFlag cmd.Flags().Var(&putJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1092,6 +1199,7 @@ Update rate limits of a serving endpoint. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := putJson.Unmarshal(&putReq) @@ -1105,14 +1213,22 @@ Update rate limits of a serving endpoint. } } } - putReq.Name = args[0] + putReq.Name = new(args[0]) - response, err := w.ServingEndpoints.Put(ctx, putReq) + sdkReq, err := modelserving.PutInferenceEndpointRateLimitsRequestToSDK(&putReq) + if err != nil { + return err + } + response, err := w.ServingEndpoints.PutInferenceEndpointRateLimits(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelserving.PutInferenceEndpointRateLimitsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1133,13 +1249,13 @@ Update rate limits of a serving endpoint. // Functions can be added from the `init()` function in manually curated files in this directory. var putAiGatewayOverrides []func( *cobra.Command, - *serving.PutAiGatewayRequest, + *modelserving.PutInferenceEndpointAiGatewayRequest, ) func newPutAiGateway() *cobra.Command { cmd := &cobra.Command{} + var putAiGatewayReq modelserving.PutInferenceEndpointAiGatewayRequest - var putAiGatewayReq serving.PutAiGatewayRequest var putAiGatewayJson flags.JsonFlag cmd.Flags().Var(&putAiGatewayJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1175,6 +1291,7 @@ func newPutAiGateway() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := putAiGatewayJson.Unmarshal(&putAiGatewayReq) @@ -1188,14 +1305,22 @@ func newPutAiGateway() *cobra.Command { } } } - putAiGatewayReq.Name = args[0] + putAiGatewayReq.Name = new(args[0]) - response, err := w.ServingEndpoints.PutAiGateway(ctx, putAiGatewayReq) + sdkReq, err := modelserving.PutInferenceEndpointAiGatewayRequestToSDK(&putAiGatewayReq) + if err != nil { + return err + } + response, err := w.ServingEndpoints.PutInferenceEndpointAiGateway(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelserving.PutInferenceEndpointAiGatewayResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1216,31 +1341,31 @@ func newPutAiGateway() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var queryOverrides []func( *cobra.Command, - *serving.QueryEndpointInput, + *modelservingquery.QueryEndpointRequest, ) func newQuery() *cobra.Command { cmd := &cobra.Command{} + var queryReq modelservingquery.QueryEndpointRequest - var queryReq serving.QueryEndpointInput var queryJson flags.JsonFlag cmd.Flags().Var(&queryJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&queryReq.ClientRequestId, "client-request-id", queryReq.ClientRequestId, `Optional user-provided request identifier that will be recorded in the inference table and the usage tracking table.`) + flags.StringPtrVar(cmd.Flags(), &queryReq.ClientRequestId, "client-request-id", `Optional user-provided request identifier that will be recorded in the inference table and the usage tracking table.`) // TODO: array: dataframe_records // TODO: complex arg: dataframe_split // TODO: map via StringToStringVar: extra_params // TODO: any: input // TODO: any: inputs // TODO: array: instances - cmd.Flags().IntVar(&queryReq.MaxTokens, "max-tokens", queryReq.MaxTokens, `The max tokens field used ONLY for __completions__ and __chat external & foundation model__ serving endpoints.`) + flags.IntPtrVar(cmd.Flags(), &queryReq.MaxTokens, "max-tokens", `The max tokens field used ONLY for __completions__ and __chat external & foundation model__ serving endpoints.`) // TODO: array: messages - cmd.Flags().IntVar(&queryReq.N, "n", queryReq.N, `The n (number of candidates) field used ONLY for __completions__ and __chat external & foundation model__ serving endpoints.`) + flags.IntPtrVar(cmd.Flags(), &queryReq.N, "n", `The n (number of candidates) field used ONLY for __completions__ and __chat external & foundation model__ serving endpoints.`) // TODO: any: prompt // TODO: array: stop - cmd.Flags().BoolVar(&queryReq.Stream, "stream", queryReq.Stream, `The stream field used ONLY for __completions__ and __chat external & foundation model__ serving endpoints.`) - cmd.Flags().Float64Var(&queryReq.Temperature, "temperature", queryReq.Temperature, `The temperature field used ONLY for __completions__ and __chat external & foundation model__ serving endpoints.`) + flags.BoolPtrVar(cmd.Flags(), &queryReq.Stream, "stream", `The stream field used ONLY for __completions__ and __chat external & foundation model__ serving endpoints.`) + flags.Float64PtrVar(cmd.Flags(), &queryReq.Temperature, "temperature", `The temperature field used ONLY for __completions__ and __chat external & foundation model__ serving endpoints.`) // TODO: map via StringToStringVar: usage_context cmd.Use = "query NAME" @@ -1266,6 +1391,7 @@ func newQuery() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := queryJson.Unmarshal(&queryReq) @@ -1279,14 +1405,22 @@ func newQuery() *cobra.Command { } } } - queryReq.Name = args[0] + queryReq.Name = new(args[0]) - response, err := w.ServingEndpoints.Query(ctx, queryReq) + sdkReq, err := modelservingquery.QueryEndpointRequestToSDK(&queryReq) + if err != nil { + return err + } + response, err := w.ServingQuery.Query(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelservingquery.QueryEndpointResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1307,13 +1441,13 @@ func newQuery() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *serving.ServingEndpointPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq serving.ServingEndpointPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1344,6 +1478,7 @@ func newSetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -1357,14 +1492,24 @@ func newSetPermissions() *cobra.Command { } } } - setPermissionsReq.ServingEndpointId = args[0] + setPermissionsReq.RequestObjectId = new(args[0]) + + setPermissionsReq.RequestObjectType = new("serving-endpoints") - response, err := w.ServingEndpoints.SetPermissions(ctx, setPermissionsReq) + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1385,13 +1530,13 @@ func newSetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateConfigOverrides []func( *cobra.Command, - *serving.EndpointCoreConfigInput, + *modelserving.PutInferenceEndpointConfigRequest, ) func newUpdateConfig() *cobra.Command { cmd := &cobra.Command{} + var updateConfigReq modelserving.PutInferenceEndpointConfigRequest - var updateConfigReq serving.EndpointCoreConfigInput var updateConfigJson flags.JsonFlag var updateConfigSkipWait bool @@ -1432,6 +1577,7 @@ func newUpdateConfig() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateConfigJson.Unmarshal(&updateConfigReq) @@ -1445,26 +1591,41 @@ func newUpdateConfig() *cobra.Command { } } } - updateConfigReq.Name = args[0] + updateConfigReq.Name = new(args[0]) - wait, err := w.ServingEndpoints.UpdateConfig(ctx, updateConfigReq) + sdkReq, err := modelserving.PutInferenceEndpointConfigRequestToSDK(&updateConfigReq) if err != nil { return err } if updateConfigSkipWait { - return cmdio.Render(ctx, wait.Response) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var current modelserving.InferenceEndpointDetailed + err = api.Do(ctx, "PUT", fmt.Sprintf("/api/2.0/serving-endpoints/%s/config", url.PathEscape(fmt.Sprint(utils.Deref(updateConfigReq.Name)))), auth.WorkspaceIDHeaders(w.Config), nil, &updateConfigReq, ¤t) + if err != nil { + return err + } + return cmdio.Render(ctx, current) + } + wait, err := w.ServingEndpoints.PutInferenceEndpointConfig(ctx, *sdkReq) + if err != nil { + return err } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *serving.ServingEndpointDetailed) { - status := i.State.ConfigUpdate - statusMessage := fmt.Sprintf("current status: %s", status) - sp.Update(statusMessage) - }).GetWithTimeout(updateConfigTimeout) + sp.Update("Waiting for update-config to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(updateConfigTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := modelserving.InferenceEndpointDetailedFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1485,13 +1646,13 @@ func newUpdateConfig() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateNotificationsOverrides []func( *cobra.Command, - *serving.UpdateInferenceEndpointNotifications, + *modelserving.UpdateInferenceEndpointNotificationsRequest, ) func newUpdateNotifications() *cobra.Command { cmd := &cobra.Command{} + var updateNotificationsReq modelserving.UpdateInferenceEndpointNotificationsRequest - var updateNotificationsReq serving.UpdateInferenceEndpointNotifications var updateNotificationsJson flags.JsonFlag cmd.Flags().Var(&updateNotificationsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1521,6 +1682,7 @@ func newUpdateNotifications() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateNotificationsJson.Unmarshal(&updateNotificationsReq) @@ -1534,14 +1696,22 @@ func newUpdateNotifications() *cobra.Command { } } } - updateNotificationsReq.Name = args[0] + updateNotificationsReq.Name = new(args[0]) - response, err := w.ServingEndpoints.UpdateNotifications(ctx, updateNotificationsReq) + sdkReq, err := modelserving.UpdateInferenceEndpointNotificationsRequestToSDK(&updateNotificationsReq) + if err != nil { + return err + } + response, err := w.ServingEndpoints.UpdateInferenceEndpointNotifications(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := modelserving.UpdateInferenceEndpointNotificationsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1562,13 +1732,13 @@ func newUpdateNotifications() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *serving.ServingEndpointPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq serving.ServingEndpointPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1598,6 +1768,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -1611,14 +1782,24 @@ func newUpdatePermissions() *cobra.Command { } } } - updatePermissionsReq.ServingEndpointId = args[0] + updatePermissionsReq.RequestObjectId = new(args[0]) + + updatePermissionsReq.RequestObjectType = new("serving-endpoints") - response, err := w.ServingEndpoints.UpdatePermissions(ctx, updatePermissionsReq) + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1639,13 +1820,13 @@ func newUpdatePermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateProvisionedThroughputEndpointConfigOverrides []func( *cobra.Command, - *serving.UpdateProvisionedThroughputEndpointConfigRequest, + *modelserving.PutPtEndpointConfigRequest, ) func newUpdateProvisionedThroughputEndpointConfig() *cobra.Command { cmd := &cobra.Command{} + var updateProvisionedThroughputEndpointConfigReq modelserving.PutPtEndpointConfigRequest - var updateProvisionedThroughputEndpointConfigReq serving.UpdateProvisionedThroughputEndpointConfigRequest var updateProvisionedThroughputEndpointConfigJson flags.JsonFlag var updateProvisionedThroughputEndpointConfigSkipWait bool @@ -1682,6 +1863,7 @@ Update config of a PT serving endpoint. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateProvisionedThroughputEndpointConfigJson.Unmarshal(&updateProvisionedThroughputEndpointConfigReq) @@ -1697,26 +1879,41 @@ Update config of a PT serving endpoint. } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateProvisionedThroughputEndpointConfigReq.Name = args[0] + updateProvisionedThroughputEndpointConfigReq.Name = new(args[0]) - wait, err := w.ServingEndpoints.UpdateProvisionedThroughputEndpointConfig(ctx, updateProvisionedThroughputEndpointConfigReq) + sdkReq, err := modelserving.PutPtEndpointConfigRequestToSDK(&updateProvisionedThroughputEndpointConfigReq) if err != nil { return err } if updateProvisionedThroughputEndpointConfigSkipWait { - return cmdio.Render(ctx, wait.Response) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var current modelserving.InferenceEndpointDetailed + err = api.Do(ctx, "PUT", fmt.Sprintf("/api/2.0/serving-endpoints/pt/%s/config", url.PathEscape(fmt.Sprint(utils.Deref(updateProvisionedThroughputEndpointConfigReq.Name)))), auth.WorkspaceIDHeaders(w.Config), nil, &updateProvisionedThroughputEndpointConfigReq, ¤t) + if err != nil { + return err + } + return cmdio.Render(ctx, current) + } + wait, err := w.ServingEndpoints.PutProvisionedThroughputInferenceEndpointConfig(ctx, *sdkReq) + if err != nil { + return err } sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *serving.ServingEndpointDetailed) { - status := i.State.ConfigUpdate - statusMessage := fmt.Sprintf("current status: %s", status) - sp.Update(statusMessage) - }).GetWithTimeout(updateProvisionedThroughputEndpointConfigTimeout) + sp.Update("Waiting for update-provisioned-throughput-endpoint-config to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(updateProvisionedThroughputEndpointConfigTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := modelserving.InferenceEndpointDetailedFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/shares/overrides.go b/cmd/workspace/shares/overrides.go index a959f45cdb4..3067ae2164a 100644 --- a/cmd/workspace/shares/overrides.go +++ b/cmd/workspace/shares/overrides.go @@ -3,8 +3,10 @@ package shares import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/sharing" + "github.com/databricks/cli/libs/flags" + sharing "github.com/databricks/cli/libs/sdktypes/sharing/v1" "github.com/spf13/cobra" ) @@ -13,8 +15,8 @@ func newList() *cobra.Command { var listReq sharing.ListSharesRequest - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of shares to return.`) - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Opaque pagination token to go to next page based on previous query.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of shares to return.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Opaque pagination token to go to next page based on previous query.`) cmd.Use = "list" cmd.Short = `List shares (Deprecated).` @@ -36,9 +38,12 @@ func newList() *cobra.Command { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - //nolint:staticcheck // this API is deprecated but we still need to expose this in the CLI. - response := w.Shares.List(ctx, listReq) - return cmdio.RenderIterator(ctx, response) + sdkReq, err := sharing.ListSharesRequestToSDK(&listReq) + if err != nil { + return err + } + response := w.Sharing.ListSharesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, sharing.ShareInfoFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/shares/shares.go b/cmd/workspace/shares/shares.go index 4f3869ae300..7a697f0a1f9 100644 --- a/cmd/workspace/shares/shares.go +++ b/cmd/workspace/shares/shares.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/sharing" "github.com/spf13/cobra" + + sharing "github.com/databricks/cli/libs/sdktypes/sharing/v1" + sdksharing "github.com/databricks/sdk-go/sharing/v1" ) // Slice with functions to override default command behavior. @@ -58,19 +61,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *sharing.CreateShare, + *sharing.CreateShareRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq sharing.CreateShareRequest - var createReq sharing.CreateShare 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.Comment, "comment", createReq.Comment, `User-provided free-form text description.`) - cmd.Flags().StringVar(&createReq.StorageRoot, "storage-root", createReq.StorageRoot, `Storage root URL for the share.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Comment, "comment", `User-provided free-form text description.`) + flags.StringPtrVar(cmd.Flags(), &createReq.StorageRoot, "storage-root", `Storage root URL for the share.`) cmd.Use = "create NAME" cmd.Short = `Create a share.` @@ -103,6 +106,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -117,15 +121,23 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Name = args[0] + createReq.Name = new(args[0]) } - response, err := w.Shares.Create(ctx, createReq) + sdkReq, err := sharing.CreateShareRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Sharing.CreateShare(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.ShareInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -146,13 +158,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sharing.DeleteShareRequest, + *sdksharing.DeleteShareRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sharing.DeleteShareRequest + var deleteReq sdksharing.DeleteShareRequest cmd.Use = "delete NAME" cmd.Short = `Delete a share.` @@ -177,13 +188,17 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Name = args[0] + deleteReq.Name = new(args[0]) - err = w.Shares.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Sharing.DeleteShare(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -210,10 +225,9 @@ var getOverrides []func( func newGet() *cobra.Command { cmd := &cobra.Command{} - var getReq sharing.GetShareRequest - cmd.Flags().BoolVar(&getReq.IncludeSharedData, "include-shared-data", getReq.IncludeSharedData, `Query for data to include in the share.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeSharedData, "include-shared-data", `Query for data to include in the share.`) cmd.Use = "get NAME" cmd.Short = `Get a share.` @@ -238,15 +252,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Name = args[0] + getReq.Name = new(args[0]) - response, err := w.Shares.Get(ctx, getReq) + sdkReq, err := sharing.GetShareRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.Sharing.GetShare(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.ShareInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -267,13 +290,13 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listSharesOverrides []func( *cobra.Command, - *sharing.SharesListRequest, + *sharing.ListSharesRequest, ) func newListShares() *cobra.Command { cmd := &cobra.Command{} + var listSharesReq sharing.ListSharesRequest - var listSharesReq sharing.SharesListRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -283,9 +306,9 @@ func newListShares() *cobra.Command { cmd.Flags().IntVar(&listSharesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSharesReq.PageToken, "page-token", listSharesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSharesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listSharesReq.MaxResults, "max-results", listSharesReq.MaxResults, `Maximum number of shares to return.`) + flags.IntPtrVar(cmd.Flags(), &listSharesReq.MaxResults, "max-results", `Maximum number of shares to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list-shares" @@ -310,16 +333,20 @@ func newListShares() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Shares.ListShares(ctx, listSharesReq) + sdkReq, err := sharing.ListSharesRequestToSDK(&listSharesReq) + if err != nil { + return err + } if listSharesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSharesLimit) } if listSharesLimit > 0 { ctx = cmdio.WithLimit(ctx, listSharesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Sharing.ListSharesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, sharing.ShareInfoFromSDK)) } // Disable completions since they are not applicable. @@ -340,16 +367,15 @@ func newListShares() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var sharePermissionsOverrides []func( *cobra.Command, - *sharing.SharePermissionsRequest, + *sharing.ListSharePermissionsRequest, ) func newSharePermissions() *cobra.Command { cmd := &cobra.Command{} + var sharePermissionsReq sharing.ListSharePermissionsRequest - var sharePermissionsReq sharing.SharePermissionsRequest - - cmd.Flags().IntVar(&sharePermissionsReq.MaxResults, "max-results", sharePermissionsReq.MaxResults, `Maximum number of permissions to return.`) - cmd.Flags().StringVar(&sharePermissionsReq.PageToken, "page-token", sharePermissionsReq.PageToken, `Opaque pagination token to go to next page based on previous query.`) + flags.IntPtrVar(cmd.Flags(), &sharePermissionsReq.MaxResults, "max-results", `Maximum number of permissions to return.`) + flags.StringPtrVar(cmd.Flags(), &sharePermissionsReq.PageToken, "page-token", `Opaque pagination token to go to next page based on previous query.`) cmd.Use = "share-permissions NAME" cmd.Short = `Get permissions.` @@ -374,15 +400,24 @@ func newSharePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - sharePermissionsReq.Name = args[0] + sharePermissionsReq.Name = new(args[0]) - response, err := w.Shares.SharePermissions(ctx, sharePermissionsReq) + sdkReq, err := sharing.ListSharePermissionsRequestToSDK(&sharePermissionsReq) + if err != nil { + return err + } + response, err := w.Sharing.ListSharePermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.GetSharePermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -403,21 +438,21 @@ func newSharePermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *sharing.UpdateShare, + *sharing.UpdateShareRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq sharing.UpdateShareRequest - var updateReq sharing.UpdateShare 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.Comment, "comment", updateReq.Comment, `User-provided free-form text description.`) - cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the share.`) - cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of current owner of share.`) - cmd.Flags().StringVar(&updateReq.StorageRoot, "storage-root", updateReq.StorageRoot, `Storage root URL for the share.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Comment, "comment", `User-provided free-form text description.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.NewName, "new-name", `New name for the share.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `Username of current owner of share.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.StorageRoot, "storage-root", `Storage root URL for the share.`) // TODO: array: updates cmd.Use = "update NAME" @@ -458,6 +493,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -471,14 +507,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.Name = args[0] + updateReq.NameArg = new(args[0]) - response, err := w.Shares.Update(ctx, updateReq) + sdkReq, err := sharing.UpdateShareRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Sharing.UpdateShare(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.ShareInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -499,19 +543,19 @@ func newUpdate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *sharing.UpdateSharePermissions, + *sharing.UpdateSharePermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq sharing.UpdateSharePermissionsRequest - var updatePermissionsReq sharing.UpdateSharePermissions var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: changes - cmd.Flags().BoolVar(&updatePermissionsReq.OmitPermissionsList, "omit-permissions-list", updatePermissionsReq.OmitPermissionsList, `Optional.`) + flags.BoolPtrVar(cmd.Flags(), &updatePermissionsReq.OmitPermissionsList, "omit-permissions-list", `Optional.`) cmd.Use = "update-permissions NAME" cmd.Short = `Update permissions.` @@ -540,6 +584,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -553,14 +598,22 @@ func newUpdatePermissions() *cobra.Command { } } } - updatePermissionsReq.Name = args[0] + updatePermissionsReq.Name = new(args[0]) - response, err := w.Shares.UpdatePermissions(ctx, updatePermissionsReq) + sdkReq, err := sharing.UpdateSharePermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.Sharing.UpdateSharePermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := sharing.UpdateSharePermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/sql-results-download/sql-results-download.go b/cmd/workspace/sql-results-download/sql-results-download.go index 84e177a4b8b..3e026d533ab 100644 --- a/cmd/workspace/sql-results-download/sql-results-download.go +++ b/cmd/workspace/sql-results-download/sql-results-download.go @@ -5,11 +5,14 @@ package sql_results_download import ( "errors" + "maps" + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/settings" "github.com/spf13/cobra" ) @@ -52,15 +55,16 @@ Controls whether users within the workspace are allowed to download results // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteSqlResultsDownloadRequest, + *map[string]any, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq map[string]any + deleteReq = map[string]any{} + var deleteEtagRaw string - var deleteReq settings.DeleteSqlResultsDownloadRequest - - cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&deleteEtagRaw, "etag", deleteEtagRaw, `etag used for versioning.`) cmd.Use = "delete" cmd.Short = `*Public Preview* Delete the SQL Results Download setting.` @@ -83,12 +87,24 @@ Delete the SQL Results Download setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || deleteEtagRaw != "" { + rawQuery["etag"] = deleteEtagRaw + } + rawPath := "/api/2.0/settings/types/sql_results_download/names/default" - response, err := w.Settings.SqlResultsDownload().Delete(ctx, deleteReq) + maps.Copy(rawQuery, deleteReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -110,15 +126,16 @@ Delete the SQL Results Download setting. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetSqlResultsDownloadRequest, + *map[string]any, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq map[string]any + getReq = map[string]any{} + var getEtagRaw string - var getReq settings.GetSqlResultsDownloadRequest - - cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`) + cmd.Flags().StringVar(&getEtagRaw, "etag", getEtagRaw, `etag used for versioning.`) cmd.Use = "get" cmd.Short = `*Public Preview* Get the SQL Results Download setting.` @@ -141,12 +158,24 @@ Get the SQL Results Download setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + rawQuery := map[string]any{} + if cmd.Flags().Changed("etag") || getEtagRaw != "" { + rawQuery["etag"] = getEtagRaw + } + rawPath := "/api/2.0/settings/types/sql_results_download/names/default" - response, err := w.Settings.SqlResultsDownload().Get(ctx, getReq) + maps.Copy(rawQuery, getReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -168,13 +197,16 @@ Get the SQL Results Download setting. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateSqlResultsDownloadRequest, + *map[string]any, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq map[string]any + updateReq = map[string]any{} + var updateAllowMissingRaw bool + var updateFieldMaskRaw string - var updateReq settings.UpdateSqlResultsDownloadRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -195,6 +227,7 @@ Update the SQL Results Download setting. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -211,11 +244,24 @@ Update the SQL Results Download setting. return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.SqlResultsDownload().Update(ctx, updateReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("allow-missing") || updateAllowMissingRaw != false { + updateReq["allow_missing"] = updateAllowMissingRaw + } + if cmd.Flags().Changed("field-mask") || updateFieldMaskRaw != "" { + updateReq["field_mask"] = updateFieldMaskRaw + } + rawPath := "/api/2.0/settings/types/sql_results_download/names/default" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/storage-credentials/overrides.go b/cmd/workspace/storage-credentials/overrides.go index 92dec91ebc3..aa4ddc35815 100644 --- a/cmd/workspace/storage-credentials/overrides.go +++ b/cmd/workspace/storage-credentials/overrides.go @@ -2,11 +2,11 @@ package storage_credentials import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/catalog" + uccredentials "github.com/databricks/cli/libs/sdktypes/uc/credentials/v1" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *catalog.ListStorageCredentialsRequest) { +func listOverride(listCmd *cobra.Command, listReq *uccredentials.ListStorageCredentialsRequest) { listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "ID"}} {{header "Name"}} {{header "Credentials"}}`) listCmd.Annotations["template"] = cmdio.Heredoc(` diff --git a/cmd/workspace/storage-credentials/storage-credentials.go b/cmd/workspace/storage-credentials/storage-credentials.go index ff64940025f..3d91e3c0e7c 100644 --- a/cmd/workspace/storage-credentials/storage-credentials.go +++ b/cmd/workspace/storage-credentials/storage-credentials.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + uccredentials "github.com/databricks/cli/libs/sdktypes/uc/credentials/v1" + sdkuccredentials "github.com/databricks/sdk-go/uc/credentials/v1" ) // Slice with functions to override default command behavior. @@ -65,13 +68,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateStorageCredential, + *uccredentials.CreateStorageCredentialRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq uccredentials.CreateStorageCredentialRequest - var createReq catalog.CreateStorageCredential var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -80,10 +83,10 @@ func newCreate() *cobra.Command { // TODO: complex arg: azure_managed_identity // TODO: complex arg: azure_service_principal // TODO: complex arg: cloudflare_api_token - cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `Comment associated with the credential.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Comment, "comment", `Comment associated with the credential.`) // TODO: complex arg: databricks_gcp_service_account - cmd.Flags().BoolVar(&createReq.ReadOnly, "read-only", createReq.ReadOnly, `Whether the credential is usable only for read operations.`) - cmd.Flags().BoolVar(&createReq.SkipValidation, "skip-validation", createReq.SkipValidation, `Supplying true to this argument skips validation of the created credential.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.ReadOnly, "read-only", `Whether the credential is usable only for read operations.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.SkipValidation, "skip-validation", `Supplying true to this argument skips validation of the created credential.`) cmd.Use = "create NAME" cmd.Short = `Create a storage credential.` @@ -118,6 +121,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -132,15 +136,23 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.Name = args[0] + createReq.Name = new(args[0]) } - response, err := w.StorageCredentials.Create(ctx, createReq) + sdkReq, err := uccredentials.CreateStorageCredentialRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Credentials.CreateStorageCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.StorageCredentialInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -161,15 +173,14 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteStorageCredentialRequest, + *uccredentials.DeleteStorageCredentialRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq uccredentials.DeleteStorageCredentialRequest - var deleteReq catalog.DeleteStorageCredentialRequest - - cmd.Flags().BoolVar(&deleteReq.Force, "force", deleteReq.Force, `Force an update even if there are dependent external locations or external tables (when purpose is **STORAGE**) or dependent services (when purpose is **SERVICE**).`) + flags.BoolPtrVar(cmd.Flags(), &deleteReq.Force, "force", `Force an update even if there are dependent external locations or external tables (when purpose is **STORAGE**) or dependent services (when purpose is **SERVICE**).`) cmd.Use = "delete NAME" cmd.Short = `Delete a credential.` @@ -194,13 +205,20 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Name = args[0] + deleteReq.NameArg = new(args[0]) - err = w.StorageCredentials.Delete(ctx, deleteReq) + sdkReq, err := uccredentials.DeleteStorageCredentialRequestToSDK(&deleteReq) if err != nil { return err } + response, err := w.Credentials.DeleteStorageCredential(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -222,13 +240,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetStorageCredentialRequest, + *sdkuccredentials.GetStorageCredentialRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq catalog.GetStorageCredentialRequest + var getReq sdkuccredentials.GetStorageCredentialRequest cmd.Use = "get NAME" cmd.Short = `Get a credential.` @@ -254,15 +271,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Name = args[0] + getReq.NameArg = new(args[0]) - response, err := w.StorageCredentials.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Credentials.GetStorageCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.StorageCredentialInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -283,27 +306,27 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListStorageCredentialsRequest, + *uccredentials.ListStorageCredentialsRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq uccredentials.ListStorageCredentialsRequest - var listReq catalog.ListStorageCredentialsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().BoolVar(&listReq.IncludeUnbound, "include-unbound", listReq.IncludeUnbound, `Whether to include credentials not bound to the workspace.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeUnbound, "include-unbound", `Whether to include credentials not bound to the workspace.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of storage credentials to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of storage credentials to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list" @@ -337,16 +360,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.StorageCredentials.List(ctx, listReq) + sdkReq, err := uccredentials.ListStorageCredentialsRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Credentials.ListStorageCredentialsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, uccredentials.StorageCredentialInfoFromSDK)) } // Disable completions since they are not applicable. @@ -367,13 +394,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateStorageCredential, + *uccredentials.UpdateStorageCredentialRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq uccredentials.UpdateStorageCredentialRequest - var updateReq catalog.UpdateStorageCredential var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -382,14 +409,14 @@ func newUpdate() *cobra.Command { // TODO: complex arg: azure_managed_identity // TODO: complex arg: azure_service_principal // TODO: complex arg: cloudflare_api_token - cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `Comment associated with the credential.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Comment, "comment", `Comment associated with the credential.`) // TODO: complex arg: databricks_gcp_service_account - cmd.Flags().BoolVar(&updateReq.Force, "force", updateReq.Force, `Force update even if there are dependent external locations or external tables.`) - cmd.Flags().Var(&updateReq.IsolationMode, "isolation-mode", `Whether the current securable is accessible from all workspaces or a specific set of workspaces. Supported values: [ISOLATION_MODE_ISOLATED, ISOLATION_MODE_OPEN]`) - cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the storage credential.`) - cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of current owner of credential.`) - cmd.Flags().BoolVar(&updateReq.ReadOnly, "read-only", updateReq.ReadOnly, `Whether the credential is usable only for read operations.`) - cmd.Flags().BoolVar(&updateReq.SkipValidation, "skip-validation", updateReq.SkipValidation, `Supplying true to this argument skips validation of the updated credential.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Force, "force", `Force update even if there are dependent external locations or external tables.`) + flags.EnumVar(cmd.Flags(), &updateReq.IsolationMode, "isolation-mode", `Whether the current securable is accessible from all workspaces or a specific set of workspaces. Supported values: [ISOLATION_MODE_ISOLATED, ISOLATION_MODE_OPEN]`, "IsolationMode", "ISOLATION_MODE_ISOLATED", "ISOLATION_MODE_OPEN") + flags.StringPtrVar(cmd.Flags(), &updateReq.NewName, "new-name", `New name for the storage credential.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `Username of current owner of credential.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.ReadOnly, "read-only", `Whether the credential is usable only for read operations.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.SkipValidation, "skip-validation", `Supplying true to this argument skips validation of the updated credential.`) cmd.Use = "update NAME" cmd.Short = `Update a credential.` @@ -416,6 +443,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -429,14 +457,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.Name = args[0] + updateReq.NameArg = new(args[0]) - response, err := w.StorageCredentials.Update(ctx, updateReq) + sdkReq, err := uccredentials.UpdateStorageCredentialRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Credentials.UpdateStorageCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.StorageCredentialInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -457,13 +493,13 @@ func newUpdate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var validateOverrides []func( *cobra.Command, - *catalog.ValidateStorageCredential, + *uccredentials.ValidateStorageCredentialRequest, ) func newValidate() *cobra.Command { cmd := &cobra.Command{} + var validateReq uccredentials.ValidateStorageCredentialRequest - var validateReq catalog.ValidateStorageCredential var validateJson flags.JsonFlag cmd.Flags().Var(&validateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -473,10 +509,10 @@ func newValidate() *cobra.Command { // TODO: complex arg: azure_service_principal // TODO: complex arg: cloudflare_api_token // TODO: complex arg: databricks_gcp_service_account - cmd.Flags().StringVar(&validateReq.ExternalLocationName, "external-location-name", validateReq.ExternalLocationName, `The name of an existing external location to validate.`) - cmd.Flags().BoolVar(&validateReq.ReadOnly, "read-only", validateReq.ReadOnly, `Whether the storage credential is only usable for read operations.`) - cmd.Flags().StringVar(&validateReq.StorageCredentialName, "storage-credential-name", validateReq.StorageCredentialName, `Required.`) - cmd.Flags().StringVar(&validateReq.Url, "url", validateReq.Url, `The external location url to validate.`) + flags.StringPtrVar(cmd.Flags(), &validateReq.ExternalLocationName, "external-location-name", `The name of an existing external location to validate.`) + flags.BoolPtrVar(cmd.Flags(), &validateReq.ReadOnly, "read-only", `Whether the storage credential is only usable for read operations.`) + flags.StringPtrVar(cmd.Flags(), &validateReq.StorageCredentialName, "storage-credential-name", `Required.`) + flags.StringPtrVar(cmd.Flags(), &validateReq.Url, "url", `The external location url to validate.`) cmd.Use = "validate" cmd.Short = `Validate a storage credential.` @@ -508,6 +544,7 @@ func newValidate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := validateJson.Unmarshal(&validateReq) @@ -522,12 +559,20 @@ func newValidate() *cobra.Command { } } - response, err := w.StorageCredentials.Validate(ctx, validateReq) + sdkReq, err := uccredentials.ValidateStorageCredentialRequestToSDK(&validateReq) + if err != nil { + return err + } + response, err := w.Credentials.ValidateStorageCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.ValidateStorageCredentialResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/supervisor-agents/supervisor-agents.go b/cmd/workspace/supervisor-agents/supervisor-agents.go index 3e02f84325c..17989b6020d 100644 --- a/cmd/workspace/supervisor-agents/supervisor-agents.go +++ b/cmd/workspace/supervisor-agents/supervisor-agents.go @@ -5,15 +5,20 @@ package supervisor_agents import ( "errors" "fmt" - "strings" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "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/supervisoragents" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + knowledgeassistants "github.com/databricks/cli/libs/sdktypes/knowledgeassistants/v1" + supervisoragents "github.com/databricks/cli/libs/sdktypes/supervisoragents/v1" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdkknowledgeassistants "github.com/databricks/sdk-go/knowledgeassistants/v1" + sdksupervisoragents "github.com/databricks/sdk-go/supervisoragents/v1" ) // Slice with functions to override default command behavior. @@ -70,19 +75,19 @@ Manage Supervisor Agents and related resources.`, // Functions can be added from the `init()` function in manually curated files in this directory. var createExampleOverrides []func( *cobra.Command, - *supervisoragents.CreateExampleRequest, + *knowledgeassistants.CreateExampleRequest, ) func newCreateExample() *cobra.Command { cmd := &cobra.Command{} + var createExampleReq knowledgeassistants.CreateExampleRequest + createExampleReq.Example = &knowledgeassistants.Example{} - var createExampleReq supervisoragents.CreateExampleRequest - createExampleReq.Example = supervisoragents.Example{} var createExampleJson flags.JsonFlag cmd.Flags().Var(&createExampleJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createExampleReq.Example.Name, "name", createExampleReq.Example.Name, `Full resource name: supervisor-agents/{supervisor_agent_id}/examples/{example_id}.`) + flags.StringPtrVar(cmd.Flags(), &createExampleReq.Example.Name, "name", `Full resource name: supervisor-agents/{supervisor_agent_id}/examples/{example_id}.`) cmd.Use = "create-example PARENT QUESTION GUIDELINES" cmd.Short = `*Beta* Create an example for a Supervisor Agent.` @@ -118,6 +123,7 @@ Create an example for a Supervisor Agent. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createExampleJson.Unmarshal(&createExampleReq.Example) @@ -131,24 +137,28 @@ Create an example for a Supervisor Agent. } } } - createExampleReq.Parent = args[0] + createExampleReq.Parent = new(args[0]) if !cmd.Flags().Changed("json") { - createExampleReq.Example.Question = args[1] + createExampleReq.Example.Question = new(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &createExampleReq.Example.Guidelines) - if err != nil { - return fmt.Errorf("invalid GUIDELINES: %s", args[2]) - } - + _ = args[2] // TODO: complex arg: guidelines } - response, err := w.SupervisorAgents.CreateExample(ctx, createExampleReq) + sdkReq, err := knowledgeassistants.CreateExampleRequestToSDK(&createExampleReq) + if err != nil { + return err + } + response, err := w.KnowledgeAssistants.CreateExample(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := knowledgeassistants.ExampleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -174,16 +184,16 @@ var createSupervisorAgentOverrides []func( func newCreateSupervisorAgent() *cobra.Command { cmd := &cobra.Command{} - var createSupervisorAgentReq supervisoragents.CreateSupervisorAgentRequest - createSupervisorAgentReq.SupervisorAgent = supervisoragents.SupervisorAgent{} + createSupervisorAgentReq.SupervisorAgent = &supervisoragents.SupervisorAgent{} + var createSupervisorAgentJson flags.JsonFlag cmd.Flags().Var(&createSupervisorAgentJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createSupervisorAgentReq.SupervisorAgent.Description, "description", createSupervisorAgentReq.SupervisorAgent.Description, `Description of what this agent can do (user-facing).`) - cmd.Flags().StringVar(&createSupervisorAgentReq.SupervisorAgent.Instructions, "instructions", createSupervisorAgentReq.SupervisorAgent.Instructions, `Optional natural-language instructions for the supervisor agent.`) - cmd.Flags().StringVar(&createSupervisorAgentReq.SupervisorAgent.Name, "name", createSupervisorAgentReq.SupervisorAgent.Name, `The resource name of the SupervisorAgent.`) + flags.StringPtrVar(cmd.Flags(), &createSupervisorAgentReq.SupervisorAgent.Description, "description", `Description of what this agent can do (user-facing).`) + flags.StringPtrVar(cmd.Flags(), &createSupervisorAgentReq.SupervisorAgent.Instructions, "instructions", `Optional natural-language instructions for the supervisor agent.`) + flags.StringPtrVar(cmd.Flags(), &createSupervisorAgentReq.SupervisorAgent.Name, "name", `The resource name of the SupervisorAgent.`) cmd.Use = "create-supervisor-agent DISPLAY_NAME" cmd.Short = `*Beta* Create a Supervisor Agent.` @@ -216,6 +226,7 @@ Create a Supervisor Agent. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createSupervisorAgentJson.Unmarshal(&createSupervisorAgentReq.SupervisorAgent) @@ -230,15 +241,23 @@ Create a Supervisor Agent. } } if !cmd.Flags().Changed("json") { - createSupervisorAgentReq.SupervisorAgent.DisplayName = args[0] + createSupervisorAgentReq.SupervisorAgent.DisplayName = new(args[0]) } - response, err := w.SupervisorAgents.CreateSupervisorAgent(ctx, createSupervisorAgentReq) + sdkReq, err := supervisoragents.CreateSupervisorAgentRequestToSDK(&createSupervisorAgentReq) + if err != nil { + return err + } + response, err := w.SupervisorAgents.CreateSupervisorAgent(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := supervisoragents.SupervisorAgentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -264,18 +283,18 @@ var createToolOverrides []func( func newCreateTool() *cobra.Command { cmd := &cobra.Command{} - var createToolReq supervisoragents.CreateToolRequest - createToolReq.Tool = supervisoragents.Tool{} + createToolReq.Tool = &supervisoragents.Tool{} + var createToolJson flags.JsonFlag cmd.Flags().Var(&createToolJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: app - cmd.Flags().StringVar(&createToolReq.Tool.Description, "description", createToolReq.Tool.Description, `Description of what this tool does (user-facing).`) + flags.StringPtrVar(cmd.Flags(), &createToolReq.Tool.Description, "description", `Description of what this tool does (user-facing).`) // TODO: complex arg: genie_space // TODO: complex arg: knowledge_assistant - cmd.Flags().StringVar(&createToolReq.Tool.Name, "name", createToolReq.Tool.Name, `Full resource name: supervisor-agents/{supervisor_agent_id}/tools/{tool_id}.`) + flags.StringPtrVar(cmd.Flags(), &createToolReq.Tool.Name, "name", `Full resource name: supervisor-agents/{supervisor_agent_id}/tools/{tool_id}.`) // TODO: complex arg: uc_connection // TODO: complex arg: uc_function // TODO: complex arg: volume @@ -329,6 +348,7 @@ Create a Tool. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createToolJson.Unmarshal(&createToolReq.Tool) @@ -342,18 +362,26 @@ Create a Tool. } } } - createToolReq.Parent = args[0] - createToolReq.ToolId = args[1] + createToolReq.Parent = new(args[0]) + createToolReq.ToolId = new(args[1]) if !cmd.Flags().Changed("json") { - createToolReq.Tool.ToolType = args[2] + createToolReq.Tool.ToolType = new(args[2]) } - response, err := w.SupervisorAgents.CreateTool(ctx, createToolReq) + sdkReq, err := supervisoragents.CreateToolRequestToSDK(&createToolReq) + if err != nil { + return err + } + response, err := w.SupervisorAgents.CreateTool(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := supervisoragents.ToolFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -374,13 +402,12 @@ Create a Tool. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteExampleOverrides []func( *cobra.Command, - *supervisoragents.DeleteExampleRequest, + *sdkknowledgeassistants.DeleteExampleRequest, ) func newDeleteExample() *cobra.Command { cmd := &cobra.Command{} - - var deleteExampleReq supervisoragents.DeleteExampleRequest + var deleteExampleReq sdkknowledgeassistants.DeleteExampleRequest cmd.Use = "delete-example NAME" cmd.Short = `*Beta* Delete an example from a Supervisor Agent.` @@ -407,10 +434,12 @@ Delete an example from a Supervisor Agent. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteExampleReq.Name = args[0] + deleteExampleReq.Name = new(args[0]) - err = w.SupervisorAgents.DeleteExample(ctx, deleteExampleReq) + sdkReq := &deleteExampleReq + err = w.KnowledgeAssistants.DeleteExample(ctx, *sdkReq) if err != nil { return err } @@ -435,13 +464,12 @@ Delete an example from a Supervisor Agent. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteSupervisorAgentOverrides []func( *cobra.Command, - *supervisoragents.DeleteSupervisorAgentRequest, + *sdksupervisoragents.DeleteSupervisorAgentRequest, ) func newDeleteSupervisorAgent() *cobra.Command { cmd := &cobra.Command{} - - var deleteSupervisorAgentReq supervisoragents.DeleteSupervisorAgentRequest + var deleteSupervisorAgentReq sdksupervisoragents.DeleteSupervisorAgentRequest cmd.Use = "delete-supervisor-agent NAME" cmd.Short = `*Beta* Delete a Supervisor Agent.` @@ -468,10 +496,12 @@ Delete a Supervisor Agent. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteSupervisorAgentReq.Name = args[0] + deleteSupervisorAgentReq.Name = new(args[0]) - err = w.SupervisorAgents.DeleteSupervisorAgent(ctx, deleteSupervisorAgentReq) + sdkReq := &deleteSupervisorAgentReq + err = w.SupervisorAgents.DeleteSupervisorAgent(ctx, *sdkReq) if err != nil { return err } @@ -496,13 +526,12 @@ Delete a Supervisor Agent. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteToolOverrides []func( *cobra.Command, - *supervisoragents.DeleteToolRequest, + *sdksupervisoragents.DeleteToolRequest, ) func newDeleteTool() *cobra.Command { cmd := &cobra.Command{} - - var deleteToolReq supervisoragents.DeleteToolRequest + var deleteToolReq sdksupervisoragents.DeleteToolRequest cmd.Use = "delete-tool NAME" cmd.Short = `*Beta* Delete a Tool.` @@ -529,10 +558,12 @@ Delete a Tool. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteToolReq.Name = args[0] + deleteToolReq.Name = new(args[0]) - err = w.SupervisorAgents.DeleteTool(ctx, deleteToolReq) + sdkReq := &deleteToolReq + err = w.SupervisorAgents.DeleteTool(ctx, *sdkReq) if err != nil { return err } @@ -557,13 +588,12 @@ Delete a Tool. // Functions can be added from the `init()` function in manually curated files in this directory. var getExampleOverrides []func( *cobra.Command, - *supervisoragents.GetExampleRequest, + *sdkknowledgeassistants.GetExampleRequest, ) func newGetExample() *cobra.Command { cmd := &cobra.Command{} - - var getExampleReq supervisoragents.GetExampleRequest + var getExampleReq sdkknowledgeassistants.GetExampleRequest cmd.Use = "get-example NAME" cmd.Short = `*Beta* Get an example from a Supervisor Agent.` @@ -590,15 +620,21 @@ Get an example from a Supervisor Agent. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getExampleReq.Name = args[0] + getExampleReq.Name = new(args[0]) - response, err := w.SupervisorAgents.GetExample(ctx, getExampleReq) + sdkReq := &getExampleReq + response, err := w.KnowledgeAssistants.GetExample(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := knowledgeassistants.ExampleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -619,13 +655,12 @@ Get an example from a Supervisor Agent. // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *supervisoragents.GetSupervisorAgentPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq supervisoragents.GetSupervisorAgentPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels SUPERVISOR_AGENT_ID" cmd.Short = `*Beta* Get supervisor agent permission levels.` @@ -651,15 +686,23 @@ Get supervisor agent permission levels. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getPermissionLevelsReq.SupervisorAgentId = args[0] + getPermissionLevelsReq.RequestObjectId = new(args[0]) - response, err := w.SupervisorAgents.GetPermissionLevels(ctx, getPermissionLevelsReq) + getPermissionLevelsReq.RequestObjectType = new("supervisor-agents") + + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -680,13 +723,12 @@ Get supervisor agent permission levels. // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *supervisoragents.GetSupervisorAgentPermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq supervisoragents.GetSupervisorAgentPermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions SUPERVISOR_AGENT_ID" cmd.Short = `*Beta* Get supervisor agent permissions.` @@ -713,15 +755,23 @@ Get supervisor agent permissions. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getPermissionsReq.RequestObjectId = new(args[0]) - getPermissionsReq.SupervisorAgentId = args[0] + getPermissionsReq.RequestObjectType = new("supervisor-agents") - response, err := w.SupervisorAgents.GetPermissions(ctx, getPermissionsReq) + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -742,13 +792,12 @@ Get supervisor agent permissions. // Functions can be added from the `init()` function in manually curated files in this directory. var getSupervisorAgentOverrides []func( *cobra.Command, - *supervisoragents.GetSupervisorAgentRequest, + *sdksupervisoragents.GetSupervisorAgentRequest, ) func newGetSupervisorAgent() *cobra.Command { cmd := &cobra.Command{} - - var getSupervisorAgentReq supervisoragents.GetSupervisorAgentRequest + var getSupervisorAgentReq sdksupervisoragents.GetSupervisorAgentRequest cmd.Use = "get-supervisor-agent NAME" cmd.Short = `*Beta* Get a Supervisor Agent.` @@ -775,15 +824,21 @@ Get a Supervisor Agent. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getSupervisorAgentReq.Name = args[0] + getSupervisorAgentReq.Name = new(args[0]) - response, err := w.SupervisorAgents.GetSupervisorAgent(ctx, getSupervisorAgentReq) + sdkReq := &getSupervisorAgentReq + response, err := w.SupervisorAgents.GetSupervisorAgent(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := supervisoragents.SupervisorAgentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -804,13 +859,12 @@ Get a Supervisor Agent. // Functions can be added from the `init()` function in manually curated files in this directory. var getToolOverrides []func( *cobra.Command, - *supervisoragents.GetToolRequest, + *sdksupervisoragents.GetToolRequest, ) func newGetTool() *cobra.Command { cmd := &cobra.Command{} - - var getToolReq supervisoragents.GetToolRequest + var getToolReq sdksupervisoragents.GetToolRequest cmd.Use = "get-tool NAME" cmd.Short = `*Beta* Get a Tool.` @@ -837,15 +891,21 @@ Get a Tool. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getToolReq.Name = args[0] + getToolReq.Name = new(args[0]) - response, err := w.SupervisorAgents.GetTool(ctx, getToolReq) + sdkReq := &getToolReq + response, err := w.SupervisorAgents.GetTool(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := supervisoragents.ToolFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -866,25 +926,25 @@ Get a Tool. // Functions can be added from the `init()` function in manually curated files in this directory. var listExamplesOverrides []func( *cobra.Command, - *supervisoragents.ListExamplesRequest, + *knowledgeassistants.ListExamplesRequest, ) func newListExamples() *cobra.Command { cmd := &cobra.Command{} + var listExamplesReq knowledgeassistants.ListExamplesRequest - var listExamplesReq supervisoragents.ListExamplesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listExamplesLimit int - cmd.Flags().IntVar(&listExamplesReq.PageSize, "page-size", listExamplesReq.PageSize, `The maximum number of examples to return.`) + flags.IntPtrVar(cmd.Flags(), &listExamplesReq.PageSize, "page-size", `The maximum number of examples to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listExamplesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listExamplesReq.PageToken, "page-token", listExamplesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listExamplesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-examples PARENT" @@ -912,18 +972,22 @@ List examples for a Supervisor Agent. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listExamplesReq.Parent = args[0] + listExamplesReq.Parent = new(args[0]) - response := w.SupervisorAgents.ListExamples(ctx, listExamplesReq) + sdkReq, err := knowledgeassistants.ListExamplesRequestToSDK(&listExamplesReq) + if err != nil { + return err + } if listExamplesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listExamplesLimit) } if listExamplesLimit > 0 { ctx = cmdio.WithLimit(ctx, listExamplesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.KnowledgeAssistants.ListExamplesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, knowledgeassistants.ExampleFromSDK)) } // Disable completions since they are not applicable. @@ -949,20 +1013,20 @@ var listSupervisorAgentsOverrides []func( func newListSupervisorAgents() *cobra.Command { cmd := &cobra.Command{} - var listSupervisorAgentsReq supervisoragents.ListSupervisorAgentsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSupervisorAgentsLimit int - cmd.Flags().IntVar(&listSupervisorAgentsReq.PageSize, "page-size", listSupervisorAgentsReq.PageSize, `The maximum number of supervisor agents to return.`) + flags.IntPtrVar(cmd.Flags(), &listSupervisorAgentsReq.PageSize, "page-size", `The maximum number of supervisor agents to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listSupervisorAgentsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSupervisorAgentsReq.PageToken, "page-token", listSupervisorAgentsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSupervisorAgentsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-supervisor-agents" @@ -986,16 +1050,20 @@ List Supervisor Agents. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.SupervisorAgents.ListSupervisorAgents(ctx, listSupervisorAgentsReq) + sdkReq, err := supervisoragents.ListSupervisorAgentsRequestToSDK(&listSupervisorAgentsReq) + if err != nil { + return err + } if listSupervisorAgentsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSupervisorAgentsLimit) } if listSupervisorAgentsLimit > 0 { ctx = cmdio.WithLimit(ctx, listSupervisorAgentsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.SupervisorAgents.ListSupervisorAgentsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, supervisoragents.SupervisorAgentFromSDK)) } // Disable completions since they are not applicable. @@ -1021,20 +1089,20 @@ var listToolsOverrides []func( func newListTools() *cobra.Command { cmd := &cobra.Command{} - var listToolsReq supervisoragents.ListToolsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listToolsLimit int - cmd.Flags().IntVar(&listToolsReq.PageSize, "page-size", listToolsReq.PageSize, ``) + flags.IntPtrVar(cmd.Flags(), &listToolsReq.PageSize, "page-size", ``) // Limit flag for total result capping. cmd.Flags().IntVar(&listToolsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listToolsReq.PageToken, "page-token", listToolsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listToolsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-tools PARENT" @@ -1062,18 +1130,22 @@ List Tools. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listToolsReq.Parent = args[0] + listToolsReq.Parent = new(args[0]) - response := w.SupervisorAgents.ListTools(ctx, listToolsReq) + sdkReq, err := supervisoragents.ListToolsRequestToSDK(&listToolsReq) + if err != nil { + return err + } if listToolsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listToolsLimit) } if listToolsLimit > 0 { ctx = cmdio.WithLimit(ctx, listToolsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.SupervisorAgents.ListToolsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, supervisoragents.ToolFromSDK)) } // Disable completions since they are not applicable. @@ -1094,13 +1166,13 @@ List Tools. // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *supervisoragents.SupervisorAgentPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq supervisoragents.SupervisorAgentPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1133,6 +1205,7 @@ Set supervisor agent permissions. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -1146,14 +1219,24 @@ Set supervisor agent permissions. } } } - setPermissionsReq.SupervisorAgentId = args[0] + setPermissionsReq.RequestObjectId = new(args[0]) - response, err := w.SupervisorAgents.SetPermissions(ctx, setPermissionsReq) + setPermissionsReq.RequestObjectType = new("supervisor-agents") + + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1174,19 +1257,19 @@ Set supervisor agent permissions. // Functions can be added from the `init()` function in manually curated files in this directory. var updateExampleOverrides []func( *cobra.Command, - *supervisoragents.UpdateExampleRequest, + *knowledgeassistants.UpdateExampleRequest, ) func newUpdateExample() *cobra.Command { cmd := &cobra.Command{} + var updateExampleReq knowledgeassistants.UpdateExampleRequest + updateExampleReq.Example = &knowledgeassistants.Example{} - var updateExampleReq supervisoragents.UpdateExampleRequest - updateExampleReq.Example = supervisoragents.Example{} var updateExampleJson flags.JsonFlag cmd.Flags().Var(&updateExampleJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateExampleReq.Example.Name, "name", updateExampleReq.Example.Name, `Full resource name: supervisor-agents/{supervisor_agent_id}/examples/{example_id}.`) + flags.StringPtrVar(cmd.Flags(), &updateExampleReq.Name, "name", `Full resource name: supervisor-agents/{supervisor_agent_id}/examples/{example_id}.`) cmd.Use = "update-example NAME UPDATE_MASK QUESTION GUIDELINES" cmd.Short = `*Beta* Update an example in a Supervisor Agent.` @@ -1224,6 +1307,7 @@ Update an example in a Supervisor Agent. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateExampleJson.Unmarshal(&updateExampleReq.Example) @@ -1237,28 +1321,31 @@ Update an example in a Supervisor Agent. } } } - updateExampleReq.Name = args[0] + updateExampleReq.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateExampleReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateExampleReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - updateExampleReq.Example.Question = args[2] + updateExampleReq.Example.Question = new(args[2]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updateExampleReq.Example.Guidelines) - if err != nil { - return fmt.Errorf("invalid GUIDELINES: %s", args[3]) - } - + _ = args[3] // TODO: complex arg: guidelines } - response, err := w.SupervisorAgents.UpdateExample(ctx, updateExampleReq) + sdkReq, err := knowledgeassistants.UpdateExampleRequestToSDK(&updateExampleReq) + if err != nil { + return err + } + response, err := w.KnowledgeAssistants.UpdateExample(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := knowledgeassistants.ExampleFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1279,13 +1366,13 @@ Update an example in a Supervisor Agent. // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *supervisoragents.SupervisorAgentPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq supervisoragents.SupervisorAgentPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1317,6 +1404,7 @@ Update supervisor agent permissions. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -1330,14 +1418,24 @@ Update supervisor agent permissions. } } } - updatePermissionsReq.SupervisorAgentId = args[0] + updatePermissionsReq.RequestObjectId = new(args[0]) + + updatePermissionsReq.RequestObjectType = new("supervisor-agents") - response, err := w.SupervisorAgents.UpdatePermissions(ctx, updatePermissionsReq) + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1363,16 +1461,16 @@ var updateSupervisorAgentOverrides []func( func newUpdateSupervisorAgent() *cobra.Command { cmd := &cobra.Command{} - var updateSupervisorAgentReq supervisoragents.UpdateSupervisorAgentRequest - updateSupervisorAgentReq.SupervisorAgent = supervisoragents.SupervisorAgent{} + updateSupervisorAgentReq.SupervisorAgent = &supervisoragents.SupervisorAgent{} + var updateSupervisorAgentJson flags.JsonFlag cmd.Flags().Var(&updateSupervisorAgentJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateSupervisorAgentReq.SupervisorAgent.Description, "description", updateSupervisorAgentReq.SupervisorAgent.Description, `Description of what this agent can do (user-facing).`) - cmd.Flags().StringVar(&updateSupervisorAgentReq.SupervisorAgent.Instructions, "instructions", updateSupervisorAgentReq.SupervisorAgent.Instructions, `Optional natural-language instructions for the supervisor agent.`) - cmd.Flags().StringVar(&updateSupervisorAgentReq.SupervisorAgent.Name, "name", updateSupervisorAgentReq.SupervisorAgent.Name, `The resource name of the SupervisorAgent.`) + flags.StringPtrVar(cmd.Flags(), &updateSupervisorAgentReq.SupervisorAgent.Description, "description", `Description of what this agent can do (user-facing).`) + flags.StringPtrVar(cmd.Flags(), &updateSupervisorAgentReq.SupervisorAgent.Instructions, "instructions", `Optional natural-language instructions for the supervisor agent.`) + flags.StringPtrVar(cmd.Flags(), &updateSupervisorAgentReq.SupervisorAgent.Name, "name", `The resource name of the SupervisorAgent.`) cmd.Use = "update-supervisor-agent NAME UPDATE_MASK DISPLAY_NAME" cmd.Short = `*Beta* Update a Supervisor Agent.` @@ -1409,6 +1507,7 @@ Update a Supervisor Agent. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateSupervisorAgentJson.Unmarshal(&updateSupervisorAgentReq.SupervisorAgent) @@ -1422,21 +1521,28 @@ Update a Supervisor Agent. } } } - updateSupervisorAgentReq.Name = args[0] + updateSupervisorAgentReq.SupervisorAgent.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateSupervisorAgentReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateSupervisorAgentReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - updateSupervisorAgentReq.SupervisorAgent.DisplayName = args[2] + updateSupervisorAgentReq.SupervisorAgent.DisplayName = new(args[2]) } - response, err := w.SupervisorAgents.UpdateSupervisorAgent(ctx, updateSupervisorAgentReq) + sdkReq, err := supervisoragents.UpdateSupervisorAgentRequestToSDK(&updateSupervisorAgentReq) + if err != nil { + return err + } + response, err := w.SupervisorAgents.UpdateSupervisorAgent(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := supervisoragents.SupervisorAgentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1462,18 +1568,18 @@ var updateToolOverrides []func( func newUpdateTool() *cobra.Command { cmd := &cobra.Command{} - var updateToolReq supervisoragents.UpdateToolRequest - updateToolReq.Tool = supervisoragents.Tool{} + updateToolReq.Tool = &supervisoragents.Tool{} + var updateToolJson flags.JsonFlag cmd.Flags().Var(&updateToolJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: app - cmd.Flags().StringVar(&updateToolReq.Tool.Description, "description", updateToolReq.Tool.Description, `Description of what this tool does (user-facing).`) + flags.StringPtrVar(cmd.Flags(), &updateToolReq.Tool.Description, "description", `Description of what this tool does (user-facing).`) // TODO: complex arg: genie_space // TODO: complex arg: knowledge_assistant - cmd.Flags().StringVar(&updateToolReq.Tool.Name, "name", updateToolReq.Tool.Name, `Full resource name: supervisor-agents/{supervisor_agent_id}/tools/{tool_id}.`) + flags.StringPtrVar(cmd.Flags(), &updateToolReq.Tool.Name, "name", `Full resource name: supervisor-agents/{supervisor_agent_id}/tools/{tool_id}.`) // TODO: complex arg: uc_connection // TODO: complex arg: uc_function // TODO: complex arg: volume @@ -1521,6 +1627,7 @@ Update a Tool. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateToolJson.Unmarshal(&updateToolReq.Tool) @@ -1534,21 +1641,28 @@ Update a Tool. } } } - updateToolReq.Name = args[0] + updateToolReq.Tool.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateToolReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateToolReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - updateToolReq.Tool.ToolType = args[2] + updateToolReq.Tool.ToolType = new(args[2]) } - response, err := w.SupervisorAgents.UpdateTool(ctx, updateToolReq) + sdkReq, err := supervisoragents.UpdateToolRequestToSDK(&updateToolReq) + if err != nil { + return err + } + response, err := w.SupervisorAgents.UpdateTool(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := supervisoragents.ToolFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/system-schemas/system-schemas.go b/cmd/workspace/system-schemas/system-schemas.go index f29cd30a16d..35a6ef60b18 100644 --- a/cmd/workspace/system-schemas/system-schemas.go +++ b/cmd/workspace/system-schemas/system-schemas.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucsystemschemas "github.com/databricks/cli/libs/sdktypes/uc/systemschemas/v1" + sdkucsystemschemas "github.com/databricks/sdk-go/uc/systemschemas/v1" ) // Slice with functions to override default command behavior. @@ -53,13 +56,12 @@ A system schema is a schema that lives within the system catalog. A system // Functions can be added from the `init()` function in manually curated files in this directory. var disableOverrides []func( *cobra.Command, - *catalog.DisableRequest, + *sdkucsystemschemas.DisableSystemSchemaRequest, ) func newDisable() *cobra.Command { cmd := &cobra.Command{} - - var disableReq catalog.DisableRequest + var disableReq sdkucsystemschemas.DisableSystemSchemaRequest cmd.Use = "disable METASTORE_ID SCHEMA_NAME" cmd.Short = `*Public Preview* Disable a system schema.` @@ -87,14 +89,18 @@ Disable a system schema. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - disableReq.MetastoreId = args[0] - disableReq.SchemaName = args[1] + disableReq.MetastoreId = new(args[0]) + disableReq.Schema = new(args[1]) - err = w.SystemSchemas.Disable(ctx, disableReq) + sdkReq := &disableReq + response, err := w.SystemSchemas.DisableSystemSchema(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -116,18 +122,18 @@ Disable a system schema. // Functions can be added from the `init()` function in manually curated files in this directory. var enableOverrides []func( *cobra.Command, - *catalog.EnableRequest, + *ucsystemschemas.EnableSystemSchemaRequest, ) func newEnable() *cobra.Command { cmd := &cobra.Command{} + var enableReq ucsystemschemas.EnableSystemSchemaRequest - var enableReq catalog.EnableRequest var enableJson flags.JsonFlag cmd.Flags().Var(&enableJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&enableReq.CatalogName, "catalog-name", enableReq.CatalogName, `the catalog for which the system schema is to enabled in.`) + flags.StringPtrVar(cmd.Flags(), &enableReq.CatalogName, "catalog-name", `the catalog for which the system schema is to enabled in.`) cmd.Use = "enable METASTORE_ID SCHEMA_NAME" cmd.Short = `*Public Preview* Enable a system schema.` @@ -155,6 +161,7 @@ Enable a system schema. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := enableJson.Unmarshal(&enableReq) @@ -168,13 +175,19 @@ Enable a system schema. } } } - enableReq.MetastoreId = args[0] - enableReq.SchemaName = args[1] + enableReq.MetastoreId = new(args[0]) + enableReq.Schema = new(args[1]) - err = w.SystemSchemas.Enable(ctx, enableReq) + sdkReq, err := ucsystemschemas.EnableSystemSchemaRequestToSDK(&enableReq) + if err != nil { + return err + } + response, err := w.SystemSchemas.EnableSystemSchema(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -196,13 +209,13 @@ Enable a system schema. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListSystemSchemasRequest, + *ucsystemschemas.ListSystemSchemasRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq ucsystemschemas.ListSystemSchemasRequest - var listReq catalog.ListSystemSchemasRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -212,9 +225,9 @@ func newList() *cobra.Command { cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of schemas to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of schemas to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list METASTORE_ID" @@ -250,18 +263,22 @@ List system schemas. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.MetastoreId = args[0] + listReq.MetastoreId = new(args[0]) - response := w.SystemSchemas.List(ctx, listReq) + sdkReq, err := ucsystemschemas.ListSystemSchemasRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.SystemSchemas.ListSystemSchemasIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucsystemschemas.SystemSchemaInfoFromSDK)) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/table-constraints/table-constraints.go b/cmd/workspace/table-constraints/table-constraints.go index 021cd317763..4aa49ae298a 100644 --- a/cmd/workspace/table-constraints/table-constraints.go +++ b/cmd/workspace/table-constraints/table-constraints.go @@ -10,8 +10,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + uctables "github.com/databricks/cli/libs/sdktypes/uc/tables/v1" ) // Slice with functions to override default command behavior. @@ -61,13 +62,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateTableConstraint, + *uctables.CreateTableConstraintRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq uctables.CreateTableConstraintRequest - var createReq catalog.CreateTableConstraint var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -95,6 +96,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -111,12 +113,20 @@ func newCreate() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - response, err := w.TableConstraints.Create(ctx, createReq) + sdkReq, err := uctables.CreateTableConstraintRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Tables.CreateTableConstraint(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uctables.TableConstraintFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -137,13 +147,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteTableConstraintRequest, + *uctables.DeleteTableConstraintRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq catalog.DeleteTableConstraintRequest + var deleteReq uctables.DeleteTableConstraintRequest cmd.Use = "delete FULL_NAME CONSTRAINT_NAME CASCADE" cmd.Short = `Delete a table constraint.` @@ -179,18 +188,27 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.FullName = args[0] - deleteReq.ConstraintName = args[1] - _, err = fmt.Sscan(args[2], &deleteReq.Cascade) + deleteReq.FullNameArg = new(args[0]) + deleteReq.ConstraintName = new(args[1]) + var deleteCascadeArg bool + _, err = fmt.Sscan(args[2], &deleteCascadeArg) if err != nil { return fmt.Errorf("invalid CASCADE: %s", args[2]) } + deleteReq.Cascade = &deleteCascadeArg - err = w.TableConstraints.Delete(ctx, deleteReq) + sdkReq, err := uctables.DeleteTableConstraintRequestToSDK(&deleteReq) + if err != nil { + return err + } + response, err := w.Tables.DeleteTableConstraint(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } diff --git a/cmd/workspace/tables/overrides.go b/cmd/workspace/tables/overrides.go index a0849ada7f4..54a4db6fd08 100644 --- a/cmd/workspace/tables/overrides.go +++ b/cmd/workspace/tables/overrides.go @@ -2,11 +2,11 @@ package tables import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/catalog" + uctables "github.com/databricks/cli/libs/sdktypes/uc/tables/v1" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *catalog.ListTablesRequest) { +func listOverride(listCmd *cobra.Command, listReq *uctables.ListTablesRequest) { listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "Full Name"}} {{header "Table Type"}}`) listCmd.Annotations["template"] = cmdio.Heredoc(` diff --git a/cmd/workspace/tables/tables.go b/cmd/workspace/tables/tables.go index 38a13f87171..8b05414d15f 100644 --- a/cmd/workspace/tables/tables.go +++ b/cmd/workspace/tables/tables.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + uctables "github.com/databricks/cli/libs/sdktypes/uc/tables/v1" + sdkuctables "github.com/databricks/sdk-go/uc/tables/v1" ) // Slice with functions to override default command behavior. @@ -62,13 +65,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateTableRequest, + *uctables.CreateTableRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq uctables.CreateTableRequest - var createReq catalog.CreateTableRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -178,6 +181,7 @@ Create a table. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -192,38 +196,38 @@ Create a table. } } if !cmd.Flags().Changed("json") { - createReq.Name = args[0] + createReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createReq.CatalogName = args[1] + createReq.CatalogName = new(args[1]) } if !cmd.Flags().Changed("json") { - createReq.SchemaName = args[2] + createReq.SchemaName = new(args[2]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &createReq.TableType) - if err != nil { - return fmt.Errorf("invalid TABLE_TYPE: %s", args[3]) - } - + createReq.TableType = uctables.TableType(args[3]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[4], &createReq.DataSourceFormat) - if err != nil { - return fmt.Errorf("invalid DATA_SOURCE_FORMAT: %s", args[4]) - } - + createReq.DataSourceFormat = uctables.DataSourceFormat(args[4]) } if !cmd.Flags().Changed("json") { - createReq.StorageLocation = args[5] + createReq.StorageLocation = new(args[5]) } - response, err := w.Tables.Create(ctx, createReq) + sdkReq, err := uctables.CreateTableRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Tables.CreateTable(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uctables.TableInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -244,13 +248,12 @@ Create a table. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteTableRequest, + *sdkuctables.DeleteTableRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq catalog.DeleteTableRequest + var deleteReq sdkuctables.DeleteTableRequest cmd.Use = "delete FULL_NAME" cmd.Short = `Delete a table.` @@ -278,13 +281,17 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.FullName = args[0] + deleteReq.FullNameArg = new(args[0]) - err = w.Tables.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Tables.DeleteTable(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -306,13 +313,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var existsOverrides []func( *cobra.Command, - *catalog.ExistsRequest, + *sdkuctables.TableExistsRequest, ) func newExists() *cobra.Command { cmd := &cobra.Command{} - - var existsReq catalog.ExistsRequest + var existsReq sdkuctables.TableExistsRequest cmd.Use = "exists FULL_NAME" cmd.Short = `Get boolean reflecting if table exists.` @@ -343,15 +349,21 @@ func newExists() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - existsReq.FullName = args[0] + existsReq.FullNameArg = new(args[0]) - response, err := w.Tables.Exists(ctx, existsReq) + sdkReq := &existsReq + response, err := w.Tables.TableExists(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uctables.TableExistsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -372,17 +384,16 @@ func newExists() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetTableRequest, + *uctables.GetTableRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq uctables.GetTableRequest - var getReq catalog.GetTableRequest - - cmd.Flags().BoolVar(&getReq.IncludeBrowse, "include-browse", getReq.IncludeBrowse, `Whether to include tables in the response for which the principal can only access selective metadata for.`) - cmd.Flags().BoolVar(&getReq.IncludeDeltaMetadata, "include-delta-metadata", getReq.IncludeDeltaMetadata, `Whether delta metadata should be included in the response.`) - cmd.Flags().BoolVar(&getReq.IncludeManifestCapabilities, "include-manifest-capabilities", getReq.IncludeManifestCapabilities, `Whether to include a manifest containing table capabilities in the response.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeBrowse, "include-browse", `Whether to include tables in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeDeltaMetadata, "include-delta-metadata", `Whether delta metadata should be included in the response.`) + flags.BoolPtrVar(cmd.Flags(), &getReq.IncludeManifestCapabilities, "include-manifest-capabilities", `Whether to include a manifest containing table capabilities in the response.`) cmd.Use = "get FULL_NAME" cmd.Short = `Get a table.` @@ -412,15 +423,24 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.FullName = args[0] + getReq.FullNameArg = new(args[0]) - response, err := w.Tables.Get(ctx, getReq) + sdkReq, err := uctables.GetTableRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.Tables.GetTable(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uctables.TableInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -441,31 +461,31 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListTablesRequest, + *uctables.ListTablesRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq uctables.ListTablesRequest - var listReq catalog.ListTablesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().BoolVar(&listReq.IncludeBrowse, "include-browse", listReq.IncludeBrowse, `Whether to include tables in the response for which the principal can only access selective metadata for.`) - cmd.Flags().BoolVar(&listReq.IncludeManifestCapabilities, "include-manifest-capabilities", listReq.IncludeManifestCapabilities, `Whether to include a manifest containing table capabilities in the response.`) - cmd.Flags().BoolVar(&listReq.OmitColumns, "omit-columns", listReq.OmitColumns, `Whether to omit the columns of the table from the response or not.`) - cmd.Flags().BoolVar(&listReq.OmitProperties, "omit-properties", listReq.OmitProperties, `Whether to omit the properties of the table from the response or not.`) - cmd.Flags().BoolVar(&listReq.OmitUsername, "omit-username", listReq.OmitUsername, `Whether to omit the username of the table (e.g.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeBrowse, "include-browse", `Whether to include tables in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeManifestCapabilities, "include-manifest-capabilities", `Whether to include a manifest containing table capabilities in the response.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.OmitColumns, "omit-columns", `Whether to omit the columns of the table from the response or not.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.OmitProperties, "omit-properties", `Whether to omit the properties of the table from the response or not.`) + flags.BoolPtrVar(cmd.Flags(), &listReq.OmitUsername, "omit-username", `Whether to omit the username of the table (e.g.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of tables to return.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of tables to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "list CATALOG_NAME SCHEMA_NAME" @@ -507,19 +527,23 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.CatalogName = args[0] - listReq.SchemaName = args[1] + listReq.CatalogName = new(args[0]) + listReq.SchemaName = new(args[1]) - response := w.Tables.List(ctx, listReq) + sdkReq, err := uctables.ListTablesRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Tables.ListTablesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, uctables.TableInfoFromSDK)) } // Disable completions since they are not applicable. @@ -540,28 +564,28 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listSummariesOverrides []func( *cobra.Command, - *catalog.ListSummariesRequest, + *uctables.ListTableSummariesRequest, ) func newListSummaries() *cobra.Command { cmd := &cobra.Command{} + var listSummariesReq uctables.ListTableSummariesRequest - var listSummariesReq catalog.ListSummariesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listSummariesLimit int - cmd.Flags().BoolVar(&listSummariesReq.IncludeManifestCapabilities, "include-manifest-capabilities", listSummariesReq.IncludeManifestCapabilities, `Whether to include a manifest containing table capabilities in the response.`) - cmd.Flags().IntVar(&listSummariesReq.MaxResults, "max-results", listSummariesReq.MaxResults, `Maximum number of summaries for tables to return.`) - cmd.Flags().StringVar(&listSummariesReq.SchemaNamePattern, "schema-name-pattern", listSummariesReq.SchemaNamePattern, `A sql LIKE pattern (% and _) for schema names.`) - cmd.Flags().StringVar(&listSummariesReq.TableNamePattern, "table-name-pattern", listSummariesReq.TableNamePattern, `A sql LIKE pattern (% and _) for table names.`) + flags.BoolPtrVar(cmd.Flags(), &listSummariesReq.IncludeManifestCapabilities, "include-manifest-capabilities", `Whether to include a manifest containing table capabilities in the response.`) + flags.IntPtrVar(cmd.Flags(), &listSummariesReq.MaxResults, "max-results", `Maximum number of summaries for tables to return.`) + flags.StringPtrVar(cmd.Flags(), &listSummariesReq.SchemaNamePattern, "schema-name-pattern", `A sql LIKE pattern (% and _) for schema names.`) + flags.StringPtrVar(cmd.Flags(), &listSummariesReq.TableNamePattern, "table-name-pattern", `A sql LIKE pattern (% and _) for table names.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listSummariesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listSummariesReq.PageToken, "page-token", listSummariesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listSummariesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-summaries CATALOG_NAME" @@ -601,18 +625,22 @@ func newListSummaries() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listSummariesReq.CatalogName = args[0] + listSummariesReq.CatalogName = new(args[0]) - response := w.Tables.ListSummaries(ctx, listSummariesReq) + sdkReq, err := uctables.ListTableSummariesRequestToSDK(&listSummariesReq) + if err != nil { + return err + } if listSummariesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listSummariesLimit) } if listSummariesLimit > 0 { ctx = cmdio.WithLimit(ctx, listSummariesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Tables.ListTableSummariesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, uctables.TableSummaryFromSDK)) } // Disable completions since they are not applicable. @@ -633,18 +661,18 @@ func newListSummaries() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateTableRequest, + *uctables.UpdateTableRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq uctables.UpdateTableRequest - var updateReq catalog.UpdateTableRequest 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.Owner, "owner", updateReq.Owner, `Username of current owner of table.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `Username of current owner of table.`) cmd.Use = "update FULL_NAME" cmd.Short = `Update a table owner.` @@ -675,6 +703,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -688,12 +717,18 @@ func newUpdate() *cobra.Command { } } } - updateReq.FullName = args[0] + updateReq.FullNameArg = new(args[0]) - err = w.Tables.Update(ctx, updateReq) + sdkReq, err := uctables.UpdateTableRequestToSDK(&updateReq) if err != nil { return err } + response, err := w.Tables.UpdateTable(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } diff --git a/cmd/workspace/tag-policies/tag-policies.go b/cmd/workspace/tag-policies/tag-policies.go index 82c31bd1fb4..8d58330b85d 100644 --- a/cmd/workspace/tag-policies/tag-policies.go +++ b/cmd/workspace/tag-policies/tag-policies.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/tags" "github.com/spf13/cobra" + + tagpolicies "github.com/databricks/cli/libs/sdktypes/tagpolicies/v1" + sdktagpolicies "github.com/databricks/sdk-go/tagpolicies/v1" ) // Slice with functions to override default command behavior. @@ -58,19 +61,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createTagPolicyOverrides []func( *cobra.Command, - *tags.CreateTagPolicyRequest, + *tagpolicies.CreateTagPolicyRequest, ) func newCreateTagPolicy() *cobra.Command { cmd := &cobra.Command{} + var createTagPolicyReq tagpolicies.CreateTagPolicyRequest + createTagPolicyReq.TagPolicy = &tagpolicies.TagPolicy{} - 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, ``) + flags.StringPtrVar(cmd.Flags(), &createTagPolicyReq.TagPolicy.Description, "description", ``) // TODO: array: values cmd.Use = "create-tag-policy TAG_KEY" @@ -104,6 +107,7 @@ func newCreateTagPolicy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createTagPolicyJson.Unmarshal(&createTagPolicyReq.TagPolicy) @@ -118,15 +122,23 @@ func newCreateTagPolicy() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createTagPolicyReq.TagPolicy.TagKey = args[0] + createTagPolicyReq.TagPolicy.TagKey = new(args[0]) } - response, err := w.TagPolicies.CreateTagPolicy(ctx, createTagPolicyReq) + sdkReq, err := tagpolicies.CreateTagPolicyRequestToSDK(&createTagPolicyReq) + if err != nil { + return err + } + response, err := w.TagPolicies.CreateTagPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := tagpolicies.TagPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -147,13 +159,12 @@ func newCreateTagPolicy() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteTagPolicyOverrides []func( *cobra.Command, - *tags.DeleteTagPolicyRequest, + *sdktagpolicies.DeleteTagPolicyRequest, ) func newDeleteTagPolicy() *cobra.Command { cmd := &cobra.Command{} - - var deleteTagPolicyReq tags.DeleteTagPolicyRequest + var deleteTagPolicyReq sdktagpolicies.DeleteTagPolicyRequest cmd.Use = "delete-tag-policy TAG_KEY" cmd.Short = `Delete a tag policy.` @@ -178,10 +189,12 @@ func newDeleteTagPolicy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteTagPolicyReq.TagKey = args[0] + deleteTagPolicyReq.TagKey = new(args[0]) - err = w.TagPolicies.DeleteTagPolicy(ctx, deleteTagPolicyReq) + sdkReq := &deleteTagPolicyReq + err = w.TagPolicies.DeleteTagPolicy(ctx, *sdkReq) if err != nil { return err } @@ -206,13 +219,12 @@ func newDeleteTagPolicy() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getTagPolicyOverrides []func( *cobra.Command, - *tags.GetTagPolicyRequest, + *sdktagpolicies.GetTagPolicyRequest, ) func newGetTagPolicy() *cobra.Command { cmd := &cobra.Command{} - - var getTagPolicyReq tags.GetTagPolicyRequest + var getTagPolicyReq sdktagpolicies.GetTagPolicyRequest cmd.Use = "get-tag-policy TAG_KEY" cmd.Short = `Get a tag policy.` @@ -238,15 +250,21 @@ func newGetTagPolicy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getTagPolicyReq.TagKey = args[0] + getTagPolicyReq.TagKey = new(args[0]) - response, err := w.TagPolicies.GetTagPolicy(ctx, getTagPolicyReq) + sdkReq := &getTagPolicyReq + response, err := w.TagPolicies.GetTagPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := tagpolicies.TagPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -267,25 +285,25 @@ func newGetTagPolicy() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listTagPoliciesOverrides []func( *cobra.Command, - *tags.ListTagPoliciesRequest, + *tagpolicies.ListTagPoliciesRequest, ) func newListTagPolicies() *cobra.Command { cmd := &cobra.Command{} + var listTagPoliciesReq tagpolicies.ListTagPoliciesRequest - var listTagPoliciesReq tags.ListTagPoliciesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listTagPoliciesLimit int - cmd.Flags().IntVar(&listTagPoliciesReq.PageSize, "page-size", listTagPoliciesReq.PageSize, `The maximum number of results to return in this request.`) + flags.IntPtrVar(cmd.Flags(), &listTagPoliciesReq.PageSize, "page-size", `The maximum number of results to return in this request.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listTagPoliciesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listTagPoliciesReq.PageToken, "page-token", listTagPoliciesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listTagPoliciesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-tag-policies" @@ -312,16 +330,20 @@ func newListTagPolicies() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.TagPolicies.ListTagPolicies(ctx, listTagPoliciesReq) + sdkReq, err := tagpolicies.ListTagPoliciesRequestToSDK(&listTagPoliciesReq) + if err != nil { + return err + } if listTagPoliciesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listTagPoliciesLimit) } if listTagPoliciesLimit > 0 { ctx = cmdio.WithLimit(ctx, listTagPoliciesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.TagPolicies.ListTagPoliciesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, tagpolicies.TagPolicyFromSDK)) } // Disable completions since they are not applicable. @@ -342,19 +364,19 @@ func newListTagPolicies() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateTagPolicyOverrides []func( *cobra.Command, - *tags.UpdateTagPolicyRequest, + *tagpolicies.UpdateTagPolicyRequest, ) func newUpdateTagPolicy() *cobra.Command { cmd := &cobra.Command{} + var updateTagPolicyReq tagpolicies.UpdateTagPolicyRequest + updateTagPolicyReq.TagPolicy = &tagpolicies.TagPolicy{} - 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, ``) + flags.StringPtrVar(cmd.Flags(), &updateTagPolicyReq.TagPolicy.Description, "description", ``) // TODO: array: values cmd.Use = "update-tag-policy TAG_KEY UPDATE_MASK" @@ -395,6 +417,7 @@ func newUpdateTagPolicy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateTagPolicyJson.Unmarshal(&updateTagPolicyReq.TagPolicy) @@ -408,15 +431,23 @@ func newUpdateTagPolicy() *cobra.Command { } } } - updateTagPolicyReq.TagKey = args[0] - updateTagPolicyReq.UpdateMask = args[1] + updateTagPolicyReq.TagPolicy.TagKey = new(args[0]) + updateTagPolicyReq.UpdateMask = new(args[1]) - response, err := w.TagPolicies.UpdateTagPolicy(ctx, updateTagPolicyReq) + sdkReq, err := tagpolicies.UpdateTagPolicyRequestToSDK(&updateTagPolicyReq) + if err != nil { + return err + } + response, err := w.TagPolicies.UpdateTagPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := tagpolicies.TagPolicyFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/temporary-path-credentials/temporary-path-credentials.go b/cmd/workspace/temporary-path-credentials/temporary-path-credentials.go index aae3cdd0d0d..b388d1064f1 100644 --- a/cmd/workspace/temporary-path-credentials/temporary-path-credentials.go +++ b/cmd/workspace/temporary-path-credentials/temporary-path-credentials.go @@ -4,14 +4,14 @@ package temporary_path_credentials import ( "errors" - "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" + + uccredentials "github.com/databricks/cli/libs/sdktypes/uc/credentials/v1" ) // Slice with functions to override default command behavior. @@ -72,18 +72,18 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var generateTemporaryPathCredentialsOverrides []func( *cobra.Command, - *catalog.GenerateTemporaryPathCredentialRequest, + *uccredentials.GenerateTemporaryPathCredentialRequest, ) func newGenerateTemporaryPathCredentials() *cobra.Command { cmd := &cobra.Command{} + var generateTemporaryPathCredentialsReq uccredentials.GenerateTemporaryPathCredentialRequest - var generateTemporaryPathCredentialsReq catalog.GenerateTemporaryPathCredentialRequest var generateTemporaryPathCredentialsJson flags.JsonFlag cmd.Flags().Var(&generateTemporaryPathCredentialsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&generateTemporaryPathCredentialsReq.DryRun, "dry-run", generateTemporaryPathCredentialsReq.DryRun, `Optional.`) + flags.BoolPtrVar(cmd.Flags(), &generateTemporaryPathCredentialsReq.DryRun, "dry-run", `Optional.`) cmd.Use = "generate-temporary-path-credentials URL OPERATION" cmd.Short = `Generate a temporary path credential.` @@ -125,6 +125,7 @@ func newGenerateTemporaryPathCredentials() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := generateTemporaryPathCredentialsJson.Unmarshal(&generateTemporaryPathCredentialsReq) @@ -139,22 +140,26 @@ func newGenerateTemporaryPathCredentials() *cobra.Command { } } if !cmd.Flags().Changed("json") { - generateTemporaryPathCredentialsReq.Url = args[0] + generateTemporaryPathCredentialsReq.Url = new(args[0]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &generateTemporaryPathCredentialsReq.Operation) - if err != nil { - return fmt.Errorf("invalid OPERATION: %s", args[1]) - } - + generateTemporaryPathCredentialsReq.Operation = uccredentials.PathOperation(args[1]) } - response, err := w.TemporaryPathCredentials.GenerateTemporaryPathCredentials(ctx, generateTemporaryPathCredentialsReq) + sdkReq, err := uccredentials.GenerateTemporaryPathCredentialRequestToSDK(&generateTemporaryPathCredentialsReq) + if err != nil { + return err + } + response, err := w.Credentials.GenerateTemporaryPathCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.GenerateTemporaryPathCredentialResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/temporary-table-credentials/temporary-table-credentials.go b/cmd/workspace/temporary-table-credentials/temporary-table-credentials.go index 7ec127cbb05..e2667b217b6 100644 --- a/cmd/workspace/temporary-table-credentials/temporary-table-credentials.go +++ b/cmd/workspace/temporary-table-credentials/temporary-table-credentials.go @@ -7,8 +7,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + uccredentials "github.com/databricks/cli/libs/sdktypes/uc/credentials/v1" ) // Slice with functions to override default command behavior. @@ -61,19 +62,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var generateTemporaryTableCredentialsOverrides []func( *cobra.Command, - *catalog.GenerateTemporaryTableCredentialRequest, + *uccredentials.GenerateTemporaryTableCredentialRequest, ) func newGenerateTemporaryTableCredentials() *cobra.Command { cmd := &cobra.Command{} + var generateTemporaryTableCredentialsReq uccredentials.GenerateTemporaryTableCredentialRequest - var generateTemporaryTableCredentialsReq catalog.GenerateTemporaryTableCredentialRequest var generateTemporaryTableCredentialsJson flags.JsonFlag cmd.Flags().Var(&generateTemporaryTableCredentialsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Var(&generateTemporaryTableCredentialsReq.Operation, "operation", `The operation performed against the table data, either READ or READ_WRITE. Supported values: [READ, READ_WRITE]`) - cmd.Flags().StringVar(&generateTemporaryTableCredentialsReq.TableId, "table-id", generateTemporaryTableCredentialsReq.TableId, `UUID of the table to read or write.`) + flags.EnumVar(cmd.Flags(), &generateTemporaryTableCredentialsReq.Operation, "operation", `The operation performed against the table data, either READ or READ_WRITE. Supported values: [READ, READ_WRITE]`, "TableOperation", "READ", "READ_WRITE") + flags.StringPtrVar(cmd.Flags(), &generateTemporaryTableCredentialsReq.TableId, "table-id", `UUID of the table to read or write.`) cmd.Use = "generate-temporary-table-credentials" cmd.Short = `Generate a temporary table credential.` @@ -97,6 +98,7 @@ func newGenerateTemporaryTableCredentials() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := generateTemporaryTableCredentialsJson.Unmarshal(&generateTemporaryTableCredentialsReq) @@ -111,12 +113,20 @@ func newGenerateTemporaryTableCredentials() *cobra.Command { } } - response, err := w.TemporaryTableCredentials.GenerateTemporaryTableCredentials(ctx, generateTemporaryTableCredentialsReq) + sdkReq, err := uccredentials.GenerateTemporaryTableCredentialRequestToSDK(&generateTemporaryTableCredentialsReq) + if err != nil { + return err + } + response, err := w.Credentials.GenerateTemporaryTableCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.GenerateTemporaryTableCredentialResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/temporary-volume-credentials/temporary-volume-credentials.go b/cmd/workspace/temporary-volume-credentials/temporary-volume-credentials.go index d503dba3a08..a2a436fc6be 100644 --- a/cmd/workspace/temporary-volume-credentials/temporary-volume-credentials.go +++ b/cmd/workspace/temporary-volume-credentials/temporary-volume-credentials.go @@ -7,8 +7,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + uccredentials "github.com/databricks/cli/libs/sdktypes/uc/credentials/v1" ) // Slice with functions to override default command behavior. @@ -63,19 +64,19 @@ Temporary Volume Credentials are short-lived, downscoped credentials used to // Functions can be added from the `init()` function in manually curated files in this directory. var generateTemporaryVolumeCredentialsOverrides []func( *cobra.Command, - *catalog.GenerateTemporaryVolumeCredentialRequest, + *uccredentials.GenerateTemporaryVolumeCredentialRequest, ) func newGenerateTemporaryVolumeCredentials() *cobra.Command { cmd := &cobra.Command{} + var generateTemporaryVolumeCredentialsReq uccredentials.GenerateTemporaryVolumeCredentialRequest - var generateTemporaryVolumeCredentialsReq catalog.GenerateTemporaryVolumeCredentialRequest var generateTemporaryVolumeCredentialsJson flags.JsonFlag cmd.Flags().Var(&generateTemporaryVolumeCredentialsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Var(&generateTemporaryVolumeCredentialsReq.Operation, "operation", `The operation performed against the volume data, either READ_VOLUME or WRITE_VOLUME. Supported values: [READ_VOLUME, WRITE_VOLUME]`) - cmd.Flags().StringVar(&generateTemporaryVolumeCredentialsReq.VolumeId, "volume-id", generateTemporaryVolumeCredentialsReq.VolumeId, `Id of the volume to read or write.`) + flags.EnumVar(cmd.Flags(), &generateTemporaryVolumeCredentialsReq.Operation, "operation", `The operation performed against the volume data, either READ_VOLUME or WRITE_VOLUME. Supported values: [READ_VOLUME, WRITE_VOLUME]`, "VolumeOperation", "READ_VOLUME", "WRITE_VOLUME") + flags.StringPtrVar(cmd.Flags(), &generateTemporaryVolumeCredentialsReq.VolumeId, "volume-id", `Id of the volume to read or write.`) cmd.Use = "generate-temporary-volume-credentials" cmd.Short = `*Public Preview* Generate a temporary volume credential.` @@ -101,6 +102,7 @@ Generate a temporary volume credential. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := generateTemporaryVolumeCredentialsJson.Unmarshal(&generateTemporaryVolumeCredentialsReq) @@ -115,12 +117,20 @@ Generate a temporary volume credential. } } - response, err := w.TemporaryVolumeCredentials.GenerateTemporaryVolumeCredentials(ctx, generateTemporaryVolumeCredentialsReq) + sdkReq, err := uccredentials.GenerateTemporaryVolumeCredentialRequestToSDK(&generateTemporaryVolumeCredentialsReq) + if err != nil { + return err + } + response, err := w.Credentials.GenerateTemporaryVolumeCredential(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := uccredentials.GenerateTemporaryVolumeCredentialResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/token-management/overrides.go b/cmd/workspace/token-management/overrides.go index 8122c1a1b39..89343d2d011 100644 --- a/cmd/workspace/token-management/overrides.go +++ b/cmd/workspace/token-management/overrides.go @@ -2,11 +2,11 @@ package token_management import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/settings" + tokenmanagement "github.com/databricks/cli/libs/sdktypes/tokenmanagement/v1" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *settings.ListTokenManagementRequest) { +func listOverride(listCmd *cobra.Command, listReq *tokenmanagement.ListTokensRequest) { listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "ID"}} {{header "Created By"}} {{header "Comment"}}`) listCmd.Annotations["template"] = cmdio.Heredoc(` diff --git a/cmd/workspace/token-management/token-management.go b/cmd/workspace/token-management/token-management.go index ebbcdd9d8dd..0c72063e356 100644 --- a/cmd/workspace/token-management/token-management.go +++ b/cmd/workspace/token-management/token-management.go @@ -10,8 +10,12 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + tokenmanagement "github.com/databricks/cli/libs/sdktypes/tokenmanagement/v1" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdktokenmanagement "github.com/databricks/sdk-go/tokenmanagement/v1" ) // Slice with functions to override default command behavior. @@ -58,20 +62,20 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOboTokenOverrides []func( *cobra.Command, - *settings.CreateOboTokenRequest, + *tokenmanagement.CreateOnBehalfOfTokenRequest, ) func newCreateOboToken() *cobra.Command { cmd := &cobra.Command{} + var createOboTokenReq tokenmanagement.CreateOnBehalfOfTokenRequest - var createOboTokenReq settings.CreateOboTokenRequest var createOboTokenJson flags.JsonFlag cmd.Flags().Var(&createOboTokenJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createOboTokenReq.AutoscopeEnabled, "autoscope-enabled", createOboTokenReq.AutoscopeEnabled, `Whether to enable autoscoping for this token.`) - cmd.Flags().StringVar(&createOboTokenReq.Comment, "comment", createOboTokenReq.Comment, `Comment that describes the purpose of the token.`) - cmd.Flags().Int64Var(&createOboTokenReq.LifetimeSeconds, "lifetime-seconds", createOboTokenReq.LifetimeSeconds, `The number of seconds before the token expires.`) + flags.BoolPtrVar(cmd.Flags(), &createOboTokenReq.AutoscopeEnabled, "autoscope-enabled", `Whether to enable autoscoping for this token.`) + flags.StringPtrVar(cmd.Flags(), &createOboTokenReq.Comment, "comment", `Comment that describes the purpose of the token.`) + flags.Int64PtrVar(cmd.Flags(), &createOboTokenReq.LifetimeSeconds, "lifetime-seconds", `The number of seconds before the token expires.`) // TODO: array: scopes cmd.Use = "create-obo-token APPLICATION_ID" @@ -95,13 +99,15 @@ func newCreateOboToken() *cobra.Command { } return nil } - 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) + _ = w if cmd.Flags().Changed("json") { diags := createOboTokenJson.Unmarshal(&createOboTokenReq) @@ -114,34 +120,25 @@ func newCreateOboToken() *cobra.Command { return err } } - } else { - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No APPLICATION_ID argument specified. Loading names for Token Management drop-down.") - names, err := w.TokenManagement.TokenInfoCommentToTokenIdMap(ctx, settings.ListTokenManagementRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Token Management drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Application ID of the service principal") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have application id of the service principal") - } - createOboTokenReq.ApplicationId = args[0] - + } + if !cmd.Flags().Changed("json") { + createOboTokenReq.ApplicationId = new(args[0]) } - response, err := w.TokenManagement.CreateOboToken(ctx, createOboTokenReq) + sdkReq, err := tokenmanagement.CreateOnBehalfOfTokenRequestToSDK(&createOboTokenReq) + if err != nil { + return err + } + response, err := w.TokenManagement.CreateOnBehalfOfToken(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := tokenmanagement.CreateOnBehalfOfTokenResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -162,13 +159,12 @@ func newCreateOboToken() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.DeleteTokenManagementRequest, + *sdktokenmanagement.RevokeTokenRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq settings.DeleteTokenManagementRequest + var deleteReq sdktokenmanagement.RevokeTokenRequest cmd.Use = "delete TOKEN_ID" cmd.Short = `Delete a token.` @@ -183,34 +179,26 @@ func newDelete() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No TOKEN_ID argument specified. Loading names for Token Management drop-down.") - names, err := w.TokenManagement.TokenInfoCommentToTokenIdMap(ctx, settings.ListTokenManagementRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Token Management drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID of the token to revoke") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id of the token to revoke") - } - deleteReq.TokenId = args[0] + deleteReq.TokenId = new(args[0]) - err = w.TokenManagement.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.TokenManagement.DeleteToken(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -232,13 +220,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetTokenManagementRequest, + *sdktokenmanagement.GetTokenRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq settings.GetTokenManagementRequest + var getReq sdktokenmanagement.GetTokenRequest cmd.Use = "get TOKEN_ID" cmd.Short = `Get token info.` @@ -253,36 +240,30 @@ func newGet() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No TOKEN_ID argument specified. Loading names for Token Management drop-down.") - names, err := w.TokenManagement.TokenInfoCommentToTokenIdMap(ctx, settings.ListTokenManagementRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Token Management drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID of the token to get") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id of the token to get") - } - getReq.TokenId = args[0] + getReq.TokenId = new(args[0]) - response, err := w.TokenManagement.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.TokenManagement.GetToken(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := tokenmanagement.GetTokenResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -322,12 +303,22 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.TokenManagement.GetPermissionLevels(ctx) + _ = w + + sdkReq := &sdkaccessmanagement.ListPermissionLevelsRequest{} + sdkReq.RequestObjectType = new("authorization") + sdkReq.RequestObjectId = new("tokens") + + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -368,12 +359,22 @@ func newGetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.TokenManagement.GetPermissions(ctx) + _ = w + + sdkReq := &sdkaccessmanagement.GetObjectPermissionsRequest{} + sdkReq.RequestObjectType = new("authorization") + sdkReq.RequestObjectId = new("tokens") + + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -394,20 +395,20 @@ func newGetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *settings.ListTokenManagementRequest, + *tokenmanagement.ListTokensRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq tokenmanagement.ListTokensRequest - var listReq settings.ListTokenManagementRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().Int64Var(&listReq.CreatedById, "created-by-id", listReq.CreatedById, `User ID of the user that created the token.`) - cmd.Flags().StringVar(&listReq.CreatedByUsername, "created-by-username", listReq.CreatedByUsername, `Username of the user that created the token.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.CreatedById, "created-by-id", `User ID of the user that created the token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.CreatedByUsername, "created-by-username", `Username of the user that created the token.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) @@ -433,8 +434,16 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.TokenManagement.List(ctx, listReq) + sdkReq, err := tokenmanagement.ListTokensRequestToSDK(&listReq) + if err != nil { + return err + } + response, err := w.TokenManagement.ListTokens(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -442,7 +451,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := tokenmanagement.ListTokensResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.TokenInfos) } // Disable completions since they are not applicable. @@ -463,13 +476,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *settings.TokenPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq settings.TokenPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -497,6 +510,7 @@ func newSetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -511,12 +525,23 @@ func newSetPermissions() *cobra.Command { } } - response, err := w.TokenManagement.SetPermissions(ctx, setPermissionsReq) + setPermissionsReq.RequestObjectType = new("authorization") + setPermissionsReq.RequestObjectId = new("tokens") + + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -537,13 +562,13 @@ func newSetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *settings.TokenPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq settings.TokenPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -570,6 +595,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -584,12 +610,23 @@ func newUpdatePermissions() *cobra.Command { } } - response, err := w.TokenManagement.UpdatePermissions(ctx, updatePermissionsReq) + updatePermissionsReq.RequestObjectType = new("authorization") + updatePermissionsReq.RequestObjectId = new("tokens") + + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -610,13 +647,13 @@ func newUpdatePermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateTokenManagementOverrides []func( *cobra.Command, - *settings.UpdateTokenManagementRequest, + *tokenmanagement.UpdateTokenRequest, ) func newUpdateTokenManagement() *cobra.Command { cmd := &cobra.Command{} + var updateTokenManagementReq tokenmanagement.UpdateTokenRequest - var updateTokenManagementReq settings.UpdateTokenManagementRequest var updateTokenManagementJson flags.JsonFlag cmd.Flags().Var(&updateTokenManagementJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -643,6 +680,7 @@ func newUpdateTokenManagement() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateTokenManagementJson.Unmarshal(&updateTokenManagementReq) @@ -658,14 +696,22 @@ func newUpdateTokenManagement() *cobra.Command { } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateTokenManagementReq.TokenId = args[0] + updateTokenManagementReq.Token.TokenId = new(args[0]) - response, err := w.TokenManagement.UpdateTokenManagement(ctx, updateTokenManagementReq) + sdkReq, err := tokenmanagement.UpdateTokenRequestToSDK(&updateTokenManagementReq) + if err != nil { + return err + } + response, err := w.TokenManagement.UpdateToken(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := tokenmanagement.AdminTokenInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/tokens/tokens.go b/cmd/workspace/tokens/tokens.go index 40ca4b786e9..972387a11f0 100644 --- a/cmd/workspace/tokens/tokens.go +++ b/cmd/workspace/tokens/tokens.go @@ -10,8 +10,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" + + tokens "github.com/databricks/cli/libs/sdktypes/tokens/v1" + sdktokens "github.com/databricks/sdk-go/tokens/v1" ) // Slice with functions to override default command behavior. @@ -52,20 +54,20 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *settings.CreateTokenRequest, + *tokens.CreateTokenRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq tokens.CreateTokenRequest - var createReq settings.CreateTokenRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createReq.AutoscopeEnabled, "autoscope-enabled", createReq.AutoscopeEnabled, `Whether to enable autoscoping for this token.`) - cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `Optional description to attach to the token.`) - cmd.Flags().Int64Var(&createReq.LifetimeSeconds, "lifetime-seconds", createReq.LifetimeSeconds, `The lifetime of the token, in seconds.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.AutoscopeEnabled, "autoscope-enabled", `Whether to enable autoscoping for this token.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Comment, "comment", `Optional description to attach to the token.`) + flags.Int64PtrVar(cmd.Flags(), &createReq.LifetimeSeconds, "lifetime-seconds", `The lifetime of the token, in seconds.`) // TODO: array: scopes cmd.Use = "create" @@ -90,6 +92,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -104,12 +107,20 @@ func newCreate() *cobra.Command { } } - response, err := w.Tokens.Create(ctx, createReq) + sdkReq, err := tokens.CreateTokenRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Tokens.CreateToken(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := tokens.CreateTokenResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -130,13 +141,13 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *settings.RevokeTokenRequest, + *tokens.RevokeTokenRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq tokens.RevokeTokenRequest - var deleteReq settings.RevokeTokenRequest var deleteJson flags.JsonFlag cmd.Flags().Var(&deleteJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -165,13 +176,15 @@ func newDelete() *cobra.Command { } return nil } - 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) + _ = w if cmd.Flags().Changed("json") { diags := deleteJson.Unmarshal(&deleteReq) @@ -184,31 +197,21 @@ func newDelete() *cobra.Command { return err } } - } else { - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No TOKEN_ID argument specified. Loading names for Tokens drop-down.") - names, err := w.Tokens.PublicTokenInfoCommentToTokenIdMap(ctx) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Tokens drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The ID of the token to be revoked") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the id of the token to be revoked") - } - deleteReq.TokenId = args[0] + } + if !cmd.Flags().Changed("json") { + deleteReq.TokenId = new(args[0]) } - err = w.Tokens.Delete(ctx, deleteReq) + sdkReq, err := tokens.RevokeTokenRequestToSDK(&deleteReq) if err != nil { return err } + response, err := w.Tokens.RevokeToken(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -258,7 +261,14 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response := w.Tokens.List(ctx) + _ = w + + sdkReq := &sdktokens.ListTokensRequest{} + + response, err := w.Tokens.ListTokens(ctx, *sdkReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } @@ -266,7 +276,11 @@ func newList() *cobra.Command { ctx = cmdio.WithLimit(ctx, listLimit) } - return cmdio.RenderIterator(ctx, response) + out, err := tokens.ListTokensResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out.TokenInfos) } // Disable completions since they are not applicable. @@ -287,13 +301,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateTokenRequest, + *tokens.UpdateTokenRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq tokens.UpdateTokenRequest - var updateReq settings.UpdateTokenRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -323,6 +337,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -338,14 +353,19 @@ func newUpdate() *cobra.Command { } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateReq.TokenId = args[0] + updateReq.TokenId = new(args[0]) - response, err := w.Tokens.Update(ctx, updateReq) + sdkReq, err := tokens.UpdateTokenRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Tokens.UpdateToken(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + _ = response + return nil } // Disable completions since they are not applicable. diff --git a/cmd/workspace/users-v2/users-v2.go b/cmd/workspace/users-v2/users-v2.go index b3c3b08b6b5..c94bd0e905d 100644 --- a/cmd/workspace/users-v2/users-v2.go +++ b/cmd/workspace/users-v2/users-v2.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" + + scim "github.com/databricks/cli/libs/sdktypes/scim/v1" + sdkscim "github.com/databricks/sdk-go/scim/v1" ) // Slice with functions to override default command behavior. @@ -68,28 +71,28 @@ User identities recognized by Databricks and represented by email addresses. // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *iam.CreateUserRequest, + *scim.CreateUserRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq scim.CreateUserRequest - var createReq iam.CreateUserRequest var createJson flags.JsonFlag cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&createReq.Active, "active", createReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&createReq.DisplayName, "display-name", createReq.DisplayName, `String that represents a concatenation of given and family names.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.Active, "active", `If this user is active.`) + flags.StringPtrVar(cmd.Flags(), &createReq.DisplayName, "display-name", `String that represents a concatenation of given and family names.`) // TODO: array: emails // TODO: array: entitlements - cmd.Flags().StringVar(&createReq.ExternalId, "external-id", createReq.ExternalId, `External ID is not currently supported.`) + flags.StringPtrVar(cmd.Flags(), &createReq.ExternalId, "external-id", `External ID is not currently supported.`) // TODO: array: groups - cmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Databricks user ID.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Id, "id", `Databricks user ID.`) // TODO: complex arg: name // TODO: array: roles // TODO: array: schemas - cmd.Flags().StringVar(&createReq.UserName, "user-name", createReq.UserName, `Email address of the Databricks user.`) + flags.StringPtrVar(cmd.Flags(), &createReq.UserName, "user-name", `Email address of the Databricks user.`) cmd.Use = "create" cmd.Short = `*Public Preview* Create a new user.` @@ -113,6 +116,7 @@ Create a new user. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -127,12 +131,20 @@ Create a new user. } } - response, err := w.UsersV2.Create(ctx, createReq) + sdkReq, err := scim.CreateUserRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Scim.CreateUser(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.UserFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -153,13 +165,12 @@ Create a new user. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *iam.DeleteUserRequest, + *sdkscim.DeleteUserRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq iam.DeleteUserRequest + var deleteReq sdkscim.DeleteUserRequest cmd.Use = "delete ID" cmd.Short = `*Public Preview* Delete a user.` @@ -186,10 +197,12 @@ Delete a user. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = w.UsersV2.Delete(ctx, deleteReq) + sdkReq := &deleteReq + err = w.Scim.DeleteUser(ctx, *sdkReq) if err != nil { return err } @@ -214,21 +227,20 @@ Delete a user. // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *iam.GetUserRequest, + *scim.GetUserRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} + var getReq scim.GetUserRequest - var getReq iam.GetUserRequest - - cmd.Flags().StringVar(&getReq.Attributes, "attributes", getReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().IntVar(&getReq.Count, "count", getReq.Count, `Desired number of results per page.`) - cmd.Flags().StringVar(&getReq.ExcludedAttributes, "excluded-attributes", getReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&getReq.Filter, "filter", getReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&getReq.SortBy, "sort-by", getReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&getReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) - cmd.Flags().IntVar(&getReq.StartIndex, "start-index", getReq.StartIndex, `Specifies the index of the first result.`) + flags.StringPtrVar(cmd.Flags(), &getReq.Attributes, "attributes", `Comma-separated list of attributes to return in response.`) + flags.IntPtrVar(cmd.Flags(), &getReq.Count, "count", `Desired number of results per page.`) + flags.StringPtrVar(cmd.Flags(), &getReq.ExcludedAttributes, "excluded-attributes", `Comma-separated list of attributes to exclude in response.`) + flags.StringPtrVar(cmd.Flags(), &getReq.Filter, "filter", `Query by which the results have to be filtered.`) + flags.StringPtrVar(cmd.Flags(), &getReq.SortBy, "sort-by", `Attribute to sort the results.`) + flags.EnumVar(cmd.Flags(), &getReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`, "GetSortOrder", "ascending", "descending") + flags.IntPtrVar(cmd.Flags(), &getReq.StartIndex, "start-index", `Specifies the index of the first result.`) cmd.Use = "get ID" cmd.Short = `*Public Preview* Get user details.` @@ -254,15 +266,24 @@ Get user details. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.UsersV2.Get(ctx, getReq) + sdkReq, err := scim.GetUserRequestToSDK(&getReq) + if err != nil { + return err + } + response, err := w.Scim.GetUser(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.UserFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -283,13 +304,12 @@ Get user details. // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *iam.GetPasswordPermissionLevelsRequest, + *sdkscim.GetPasswordPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq iam.GetPasswordPermissionLevelsRequest + var getPermissionLevelsReq sdkscim.GetPasswordPermissionLevelsRequest cmd.Use = "get-permission-levels" cmd.Short = `*Public Preview* Get password permission levels.` @@ -307,13 +327,19 @@ Get password permission levels. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response, err := w.UsersV2.GetPermissionLevels(ctx, getPermissionLevelsReq) + sdkReq := &getPermissionLevelsReq + response, err := w.Scim.GetPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.GetPasswordPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -334,13 +360,12 @@ Get password permission levels. // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *iam.GetPasswordPermissionsRequest, + *sdkscim.GetPasswordPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq iam.GetPasswordPermissionsRequest + var getPermissionsReq sdkscim.GetPasswordPermissionsRequest cmd.Use = "get-permissions" cmd.Short = `*Public Preview* Get password permissions.` @@ -359,13 +384,19 @@ Get password permissions. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response, err := w.UsersV2.GetPermissions(ctx, getPermissionsReq) + sdkReq := &getPermissionsReq + response, err := w.Scim.GetPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.PasswordPermissionsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -386,31 +417,31 @@ Get password permissions. // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *iam.ListUsersRequest, + *scim.ListUsersRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq scim.ListUsersRequest - var listReq iam.ListUsersRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().StringVar(&listReq.Attributes, "attributes", listReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().StringVar(&listReq.ExcludedAttributes, "excluded-attributes", listReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&listReq.Filter, "filter", listReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&listReq.SortBy, "sort-by", listReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) + flags.StringPtrVar(cmd.Flags(), &listReq.Attributes, "attributes", `Comma-separated list of attributes to return in response.`) + flags.StringPtrVar(cmd.Flags(), &listReq.ExcludedAttributes, "excluded-attributes", `Comma-separated list of attributes to exclude in response.`) + flags.StringPtrVar(cmd.Flags(), &listReq.Filter, "filter", `Query by which the results have to be filtered.`) + flags.StringPtrVar(cmd.Flags(), &listReq.SortBy, "sort-by", `Attribute to sort the results.`) + flags.EnumVar(cmd.Flags(), &listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`, "ListSortOrder", "ascending", "descending") // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().Int64Var(&listReq.StartIndex, "start-index", listReq.StartIndex, `Specifies the index of the first result.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.StartIndex, "start-index", `Specifies the index of the first result.`) cmd.Flags().Lookup("start-index").Hidden = true - cmd.Flags().Int64Var(&listReq.Count, "count", listReq.Count, `Number of results per API page.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.Count, "count", `Number of results per API page.`) cmd.Flags().Lookup("count").Hidden = true cmd.Use = "list" @@ -434,16 +465,20 @@ List users. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.UsersV2.List(ctx, listReq) + sdkReq, err := scim.ListUsersRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Scim.ListUsersIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, scim.UserFromSDK)) } // Disable completions since they are not applicable. @@ -464,13 +499,13 @@ List users. // Functions can be added from the `init()` function in manually curated files in this directory. var patchOverrides []func( *cobra.Command, - *iam.PatchUserRequest, + *scim.PatchUserRequest, ) func newPatch() *cobra.Command { cmd := &cobra.Command{} + var patchReq scim.PatchUserRequest - var patchReq iam.PatchUserRequest var patchJson flags.JsonFlag cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -504,6 +539,7 @@ Update user details. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -517,9 +553,13 @@ Update user details. } } } - patchReq.Id = args[0] + patchReq.Id = new(args[0]) - err = w.UsersV2.Patch(ctx, patchReq) + sdkReq, err := scim.PatchUserRequestToSDK(&patchReq) + if err != nil { + return err + } + err = w.Scim.PatchUser(ctx, *sdkReq) if err != nil { return err } @@ -544,13 +584,13 @@ Update user details. // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *iam.PasswordPermissionsRequest, + *scim.PasswordPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq scim.PasswordPermissionsRequest - var setPermissionsReq iam.PasswordPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -580,6 +620,7 @@ Set password permissions. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -594,12 +635,20 @@ Set password permissions. } } - response, err := w.UsersV2.SetPermissions(ctx, setPermissionsReq) + sdkReq, err := scim.PasswordPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.Scim.SetPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.PasswordPermissionsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -620,27 +669,27 @@ Set password permissions. // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *iam.UpdateUserRequest, + *scim.UpdateUserRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq scim.UpdateUserRequest - var updateReq iam.UpdateUserRequest var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&updateReq.Active, "active", updateReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&updateReq.DisplayName, "display-name", updateReq.DisplayName, `String that represents a concatenation of given and family names.`) + flags.BoolPtrVar(cmd.Flags(), &updateReq.Active, "active", `If this user is active.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.DisplayName, "display-name", `String that represents a concatenation of given and family names.`) // TODO: array: emails // TODO: array: entitlements - cmd.Flags().StringVar(&updateReq.ExternalId, "external-id", updateReq.ExternalId, `External ID is not currently supported.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.ExternalId, "external-id", `External ID is not currently supported.`) // TODO: array: groups // TODO: complex arg: name // TODO: array: roles // TODO: array: schemas - cmd.Flags().StringVar(&updateReq.UserName, "user-name", updateReq.UserName, `Email address of the Databricks user.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.UserName, "user-name", `Email address of the Databricks user.`) cmd.Use = "update ID" cmd.Short = `*Public Preview* Replace a user.` @@ -668,6 +717,7 @@ Replace a user. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -681,9 +731,13 @@ Replace a user. } } } - updateReq.Id = args[0] + updateReq.Id = new(args[0]) - err = w.UsersV2.Update(ctx, updateReq) + sdkReq, err := scim.UpdateUserRequestToSDK(&updateReq) + if err != nil { + return err + } + err = w.Scim.UpdateUser(ctx, *sdkReq) if err != nil { return err } @@ -708,13 +762,13 @@ Replace a user. // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *iam.PasswordPermissionsRequest, + *scim.PasswordPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq scim.PasswordPermissionsRequest - var updatePermissionsReq iam.PasswordPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -743,6 +797,7 @@ Update password permissions. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -757,12 +812,20 @@ Update password permissions. } } - response, err := w.UsersV2.UpdatePermissions(ctx, updatePermissionsReq) + sdkReq, err := scim.PasswordPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.Scim.UpdatePermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := scim.PasswordPermissionsFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/users/overrides.go b/cmd/workspace/users/overrides.go index a985ccf8cdf..a94ff10f93a 100644 --- a/cmd/workspace/users/overrides.go +++ b/cmd/workspace/users/overrides.go @@ -2,12 +2,12 @@ package users import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *iam.ListUsersRequest) { - listReq.Attributes = "id,userName,groups,active" +func listOverride(listCmd *cobra.Command) { + // Request only the columns the template shows unless --attributes is given. + _ = listCmd.Flags().Lookup("attributes").Value.Set("id,userName,groups,active") listCmd.Annotations["template"] = cmdio.Heredoc(` {{range .}}{{.Id|green}} {{.UserName}} {{range .Groups}}{{.Display}} {{end}} {{if .Active}}{{"ACTIVE"|green}}{{else}}DISABLED{{end}} {{end}}`) diff --git a/cmd/workspace/users/users.go b/cmd/workspace/users/users.go index c9ea8059428..be0bcf26378 100755 --- a/cmd/workspace/users/users.go +++ b/cmd/workspace/users/users.go @@ -2,17 +2,11 @@ // but are now manually maintained because the v2 API versions have taken // over as the generated commands. See https://github.com/databricks/cli/pull/4722. -//nolint:staticcheck,perfsprint package users 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/iam" + users_v2 "github.com/databricks/cli/cmd/workspace/users-v2" "github.com/spf13/cobra" ) @@ -20,6 +14,11 @@ import ( // Functions can be added from the `init()` function in manually curated files in this directory. var cmdOverrides []func(*cobra.Command) +// Slices with functions to override the behavior of individual commands. +var listOverrides []func(*cobra.Command) + +// The commands are the users-v2 commands (same API) presented under their +// original names and help text. func New() *cobra.Command { cmd := &cobra.Command{ Use: "users", @@ -42,713 +41,134 @@ func New() *cobra.Command { RunE: root.ReportUnknownSubcommand, } - // Add methods - cmd.AddCommand(newCreate()) - cmd.AddCommand(newDelete()) - cmd.AddCommand(newGet()) - cmd.AddCommand(newGetPermissionLevels()) - cmd.AddCommand(newGetPermissions()) - cmd.AddCommand(newList()) - cmd.AddCommand(newPatch()) - cmd.AddCommand(newSetPermissions()) - cmd.AddCommand(newUpdate()) - cmd.AddCommand(newUpdatePermissions()) - - // 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, - *iam.User, -) - -func newCreate() *cobra.Command { - cmd := &cobra.Command{} - - var createReq iam.User - var createJson flags.JsonFlag - - cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - cmd.Flags().BoolVar(&createReq.Active, "active", createReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&createReq.DisplayName, "display-name", createReq.DisplayName, `String that represents a concatenation of given and family names.`) - // TODO: array: emails - // TODO: array: entitlements - cmd.Flags().StringVar(&createReq.ExternalId, "external-id", createReq.ExternalId, `External ID is not currently supported.`) - // TODO: array: groups - cmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Databricks user ID.`) - // TODO: complex arg: name - // TODO: array: roles - // TODO: array: schemas - cmd.Flags().StringVar(&createReq.UserName, "user-name", createReq.UserName, `Email address of the Databricks user.`) - - cmd.Use = "create" - cmd.Short = `Create a new user.` - cmd.Long = `Create a new user. - - Creates a new user in the Databricks workspace. This new user will also be - added to the Databricks 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) - - if cmd.Flags().Changed("json") { - diags := createJson.Unmarshal(&createReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err + v2 := users_v2.New() + for _, sub := range v2.Commands() { + doc, ok := commandDocs[sub.Name()] + if !ok { + continue + } + v2.RemoveCommand(sub) + sub.Use = doc.use + if doc.short != "" { + sub.Short = doc.short + sub.Long = doc.long + } + sub.Hidden = doc.hidden + if sub.Name() == "list" { + // These were regular flags of the original commands. + for _, name := range []string{"count", "start-index"} { + if f := sub.Flags().Lookup(name); f != nil { + f.Hidden = false } } + for _, fn := range listOverrides { + fn(sub) + } } - - response, err := w.Users.Create(ctx, createReq) - if err != nil { - return err - } - return cmdio.Render(ctx, response) + cmd.AddCommand(sub) } - // 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) + for _, fn := range cmdOverrides { + fn(cmd) } 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, - *iam.DeleteUserRequest, -) - -func newDelete() *cobra.Command { - cmd := &cobra.Command{} +type commandDoc struct { + use, short, long string + hidden bool +} - var deleteReq iam.DeleteUserRequest +var commandDocs = map[string]commandDoc{ + "create": { + use: "create", + short: `Create a new user.`, + long: `Create a new user. - cmd.Use = "delete ID" - cmd.Short = `Delete a user.` - cmd.Long = `Delete a user. + Creates a new user in the Databricks workspace. This new user will also be + added to the Databricks account.`, + }, + "delete": { + use: "delete ID", + short: `Delete a user.`, + long: `Delete a user. Deletes a user. Deleting a user from a Databricks workspace also removes objects associated with the user. Arguments: - ID: Unique ID for a user in the Databricks workspace.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Users drop-down.") - names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID for a user in the Databricks workspace") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id for a user in the databricks workspace") - } - deleteReq.Id = args[0] - - err = w.Users.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, - *iam.GetUserRequest, -) - -func newGet() *cobra.Command { - cmd := &cobra.Command{} - - var getReq iam.GetUserRequest - - cmd.Flags().StringVar(&getReq.Attributes, "attributes", getReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().IntVar(&getReq.Count, "count", getReq.Count, `Desired number of results per page.`) - cmd.Flags().StringVar(&getReq.ExcludedAttributes, "excluded-attributes", getReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&getReq.Filter, "filter", getReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&getReq.SortBy, "sort-by", getReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&getReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) - cmd.Flags().IntVar(&getReq.StartIndex, "start-index", getReq.StartIndex, `Specifies the index of the first result.`) - - cmd.Use = "get ID" - cmd.Short = `Get user details.` - cmd.Long = `Get user details. + ID: Unique ID for a user in the Databricks workspace.`, + }, + "get": { + use: "get ID", + short: `Get user details.`, + long: `Get user details. Gets information for a specific user in Databricks workspace. Arguments: - ID: Unique ID for a user in the Databricks workspace.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Users drop-down.") - names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID for a user in the Databricks workspace") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id for a user in the databricks workspace") - } - getReq.Id = args[0] - - response, err := w.Users.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 get-permission-levels 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 getPermissionLevelsOverrides []func( - *cobra.Command, -) - -func newGetPermissionLevels() *cobra.Command { - cmd := &cobra.Command{} - - cmd.Use = "get-permission-levels" - cmd.Short = `Get password permission levels.` - cmd.Long = `Get password permission levels. - - Gets the permission levels that a user can have on an object.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - response, err := w.Users.GetPermissionLevels(ctx) - 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 getPermissionLevelsOverrides { - fn(cmd) - } - - return cmd -} - -// start get-permissions 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 getPermissionsOverrides []func( - *cobra.Command, -) - -func newGetPermissions() *cobra.Command { - cmd := &cobra.Command{} - - cmd.Use = "get-permissions" - cmd.Short = `Get password permissions.` - cmd.Long = `Get password permissions. + ID: Unique ID for a user in the Databricks workspace.`, + }, + "get-permission-levels": { + use: "get-permission-levels", + short: `Get password permission levels.`, + long: `Get password permission levels. + + Gets the permission levels that a user can have on an object.`, + }, + "get-permissions": { + use: "get-permissions", + short: `Get password permissions.`, + long: `Get password permissions. Gets the permissions of all passwords. Passwords can inherit permissions from - their root object.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - response, err := w.Users.GetPermissions(ctx) - 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 getPermissionsOverrides { - fn(cmd) - } - - 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, - *iam.ListUsersRequest, -) - -func newList() *cobra.Command { - cmd := &cobra.Command{} - - var listReq iam.ListUsersRequest - - cmd.Flags().StringVar(&listReq.Attributes, "attributes", listReq.Attributes, `Comma-separated list of attributes to return in response.`) - cmd.Flags().Int64Var(&listReq.Count, "count", listReq.Count, `Desired number of results per page.`) - cmd.Flags().StringVar(&listReq.ExcludedAttributes, "excluded-attributes", listReq.ExcludedAttributes, `Comma-separated list of attributes to exclude in response.`) - cmd.Flags().StringVar(&listReq.Filter, "filter", listReq.Filter, `Query by which the results have to be filtered.`) - cmd.Flags().StringVar(&listReq.SortBy, "sort-by", listReq.SortBy, `Attribute to sort the results.`) - cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order to sort the results. Supported values: [ascending, descending]`) - cmd.Flags().Int64Var(&listReq.StartIndex, "start-index", listReq.StartIndex, `Specifies the index of the first result.`) - - cmd.Use = "list" - cmd.Short = `List users.` - cmd.Long = `List users. - - Gets details for all the users associated with a Databricks 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.Users.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 patch 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 patchOverrides []func( - *cobra.Command, - *iam.PartialUpdate, -) - -func newPatch() *cobra.Command { - cmd := &cobra.Command{} - - var patchReq iam.PartialUpdate - var patchJson flags.JsonFlag - - cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - // TODO: array: Operations - // TODO: array: schemas - - cmd.Use = "patch ID" - cmd.Short = `Update user details.` - cmd.Long = `Update user details. + their root object.`, + }, + "list": { + use: "list", + short: `List users.`, + long: `List users. + + Gets details for all the users associated with a Databricks workspace.`, + }, + "patch": { + use: "patch ID", + short: `Update user details.`, + long: `Update user details. Partially updates a user resource by applying the supplied operations on specific user attributes. Arguments: - ID: Unique ID in the Databricks workspace.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if cmd.Flags().Changed("json") { - diags := patchJson.Unmarshal(&patchReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Users drop-down.") - names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Unique ID in the Databricks workspace") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have unique id in the databricks workspace") - } - patchReq.Id = args[0] - - err = w.Users.Patch(ctx, patchReq) - 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 patchOverrides { - fn(cmd, &patchReq) - } - - return cmd -} - -// start set-permissions 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 setPermissionsOverrides []func( - *cobra.Command, - *iam.PasswordPermissionsRequest, -) - -func newSetPermissions() *cobra.Command { - cmd := &cobra.Command{} - - var setPermissionsReq iam.PasswordPermissionsRequest - var setPermissionsJson flags.JsonFlag - - cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - // TODO: array: access_control_list - - cmd.Use = "set-permissions" - cmd.Short = `Set password permissions.` - cmd.Long = `Set password permissions. + ID: Unique ID in the Databricks workspace.`, + }, + "set-permissions": { + use: "set-permissions", + short: `Set password permissions.`, + long: `Set password permissions. Sets permissions on an object, replacing existing permissions if they exist. Deletes all direct permissions if none are specified. Objects can inherit - permissions from their root object.` - - 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 := setPermissionsJson.Unmarshal(&setPermissionsReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - - response, err := w.Users.SetPermissions(ctx, setPermissionsReq) - 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 setPermissionsOverrides { - fn(cmd, &setPermissionsReq) - } - - 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, - *iam.User, -) - -func newUpdate() *cobra.Command { - cmd := &cobra.Command{} - - var updateReq iam.User - var updateJson flags.JsonFlag - - cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - cmd.Flags().BoolVar(&updateReq.Active, "active", updateReq.Active, `If this user is active.`) - cmd.Flags().StringVar(&updateReq.DisplayName, "display-name", updateReq.DisplayName, `String that represents a concatenation of given and family names.`) - // TODO: array: emails - // TODO: array: entitlements - cmd.Flags().StringVar(&updateReq.ExternalId, "external-id", updateReq.ExternalId, `External ID is not currently supported.`) - // TODO: array: groups - cmd.Flags().StringVar(&updateReq.Id, "id", updateReq.Id, `Databricks user ID.`) - // TODO: complex arg: name - // TODO: array: roles - // TODO: array: schemas - cmd.Flags().StringVar(&updateReq.UserName, "user-name", updateReq.UserName, `Email address of the Databricks user.`) - - cmd.Use = "update ID" - cmd.Short = `Replace a user.` - cmd.Long = `Replace a user. + permissions from their root object.`, + }, + "update": { + use: "update ID", + short: `Replace a user.`, + long: `Replace a user. Replaces a user's information with the data supplied in request. Arguments: - ID: Databricks user ID.` - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := cmdctx.WorkspaceClient(ctx) - - if cmd.Flags().Changed("json") { - diags := updateJson.Unmarshal(&updateReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No ID argument specified. Loading names for Users drop-down.") - names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "Databricks user ID") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return fmt.Errorf("expected to have databricks user id") - } - updateReq.Id = args[0] - - err = w.Users.Update(ctx, updateReq) - 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 updateOverrides { - fn(cmd, &updateReq) - } - - return cmd -} - -// start update-permissions 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 updatePermissionsOverrides []func( - *cobra.Command, - *iam.PasswordPermissionsRequest, -) - -func newUpdatePermissions() *cobra.Command { - cmd := &cobra.Command{} - - var updatePermissionsReq iam.PasswordPermissionsRequest - var updatePermissionsJson flags.JsonFlag - - cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - // TODO: array: access_control_list - - cmd.Use = "update-permissions" - cmd.Short = `Update password permissions.` - cmd.Long = `Update password permissions. + ID: Databricks user ID.`, + }, + "update-permissions": { + use: "update-permissions", + short: `Update password permissions.`, + long: `Update password permissions. Updates the permissions on all passwords. Passwords can inherit permissions - from their root object.` - - 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 := updatePermissionsJson.Unmarshal(&updatePermissionsReq) - if diags.HasError() { - return diags.Error() - } - if len(diags) > 0 { - err := cmdio.RenderDiagnostics(ctx, diags) - if err != nil { - return err - } - } - } - - response, err := w.Users.UpdatePermissions(ctx, updatePermissionsReq) - 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 updatePermissionsOverrides { - fn(cmd, &updatePermissionsReq) - } - - return cmd + from their root object.`, + }, } - -// end service Users diff --git a/cmd/workspace/vector-search-endpoints/vector-search-endpoints.go b/cmd/workspace/vector-search-endpoints/vector-search-endpoints.go index bc4e7d83428..855287f08e0 100644 --- a/cmd/workspace/vector-search-endpoints/vector-search-endpoints.go +++ b/cmd/workspace/vector-search-endpoints/vector-search-endpoints.go @@ -8,11 +8,19 @@ import ( "time" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + vectorsearch "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdkvectorsearch "github.com/databricks/sdk-go/vectorsearch/v1" ) // Slice with functions to override default command behavior. @@ -60,13 +68,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createEndpointOverrides []func( *cobra.Command, - *vectorsearch.CreateEndpoint, + *vectorsearch.CreateEndpointRequest, ) func newCreateEndpoint() *cobra.Command { cmd := &cobra.Command{} + var createEndpointReq vectorsearch.CreateEndpointRequest - var createEndpointReq vectorsearch.CreateEndpoint var createEndpointJson flags.JsonFlag var createEndpointSkipWait bool @@ -77,9 +85,9 @@ func newCreateEndpoint() *cobra.Command { cmd.Flags().Var(&createEndpointJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createEndpointReq.BudgetPolicyId, "budget-policy-id", createEndpointReq.BudgetPolicyId, `The budget policy id to be applied.`) - cmd.Flags().Int64Var(&createEndpointReq.TargetQps, "target-qps", createEndpointReq.TargetQps, `Target QPS for the endpoint.`) - cmd.Flags().StringVar(&createEndpointReq.UsagePolicyId, "usage-policy-id", createEndpointReq.UsagePolicyId, `The usage policy id to be applied once we've migrated to usage policies.`) + flags.StringPtrVar(cmd.Flags(), &createEndpointReq.BudgetPolicyId, "budget-policy-id", `The budget policy id to be applied.`) + flags.Int64PtrVar(cmd.Flags(), &createEndpointReq.TargetQps, "target-qps", `Target QPS for the endpoint.`) + flags.StringPtrVar(cmd.Flags(), &createEndpointReq.UsagePolicyId, "usage-policy-id", `The usage policy id to be applied once we've migrated to usage policies.`) cmd.Use = "create-endpoint NAME ENDPOINT_TYPE" cmd.Short = `Create an endpoint.` @@ -112,6 +120,7 @@ func newCreateEndpoint() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createEndpointJson.Unmarshal(&createEndpointReq) @@ -126,40 +135,45 @@ func newCreateEndpoint() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createEndpointReq.Name = args[0] + createEndpointReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createEndpointReq.EndpointType) - if err != nil { - return fmt.Errorf("invalid ENDPOINT_TYPE: %s", args[1]) - } - + createEndpointReq.EndpointType = vectorsearch.EndpointType(args[1]) } - wait, err := w.VectorSearchEndpoints.CreateEndpoint(ctx, createEndpointReq) + sdkReq, err := vectorsearch.CreateEndpointRequestToSDK(&createEndpointReq) if err != nil { return err } if createEndpointSkipWait { - return cmdio.Render(ctx, wait.Response) - } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *vectorsearch.EndpointInfo) { - if i.EndpointStatus == nil { - return + api, err := apiclient.New(w.Config) + if err != nil { + return err } - status := i.EndpointStatus.State - statusMessage := fmt.Sprintf("current status: %s", status) - if i.EndpointStatus != nil { - statusMessage = i.EndpointStatus.Message + var current vectorsearch.Endpoint + err = api.Do(ctx, "POST", "/api/2.0/vector-search/endpoints", auth.WorkspaceIDHeaders(w.Config), nil, &createEndpointReq, ¤t) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(createEndpointTimeout) + return cmdio.Render(ctx, current) + } + wait, err := w.VectorSearch.CreateEndpoint(ctx, *sdkReq) + if err != nil { + return err + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for create-endpoint to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createEndpointTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := vectorsearch.EndpointFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -180,13 +194,12 @@ func newCreateEndpoint() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteEndpointOverrides []func( *cobra.Command, - *vectorsearch.DeleteEndpointRequest, + *sdkvectorsearch.DeleteEndpointRequest, ) func newDeleteEndpoint() *cobra.Command { cmd := &cobra.Command{} - - var deleteEndpointReq vectorsearch.DeleteEndpointRequest + var deleteEndpointReq sdkvectorsearch.DeleteEndpointRequest cmd.Use = "delete-endpoint ENDPOINT_NAME" cmd.Short = `Delete an endpoint.` @@ -210,13 +223,17 @@ func newDeleteEndpoint() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteEndpointReq.EndpointName = args[0] + deleteEndpointReq.Name = new(args[0]) - err = w.VectorSearchEndpoints.DeleteEndpoint(ctx, deleteEndpointReq) + sdkReq := &deleteEndpointReq + response, err := w.VectorSearch.DeleteEndpoint(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -238,13 +255,12 @@ func newDeleteEndpoint() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getEndpointOverrides []func( *cobra.Command, - *vectorsearch.GetEndpointRequest, + *sdkvectorsearch.GetEndpointRequest, ) func newGetEndpoint() *cobra.Command { cmd := &cobra.Command{} - - var getEndpointReq vectorsearch.GetEndpointRequest + var getEndpointReq sdkvectorsearch.GetEndpointRequest cmd.Use = "get-endpoint ENDPOINT_NAME" cmd.Short = `Get an endpoint.` @@ -268,15 +284,21 @@ func newGetEndpoint() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getEndpointReq.EndpointName = args[0] + getEndpointReq.Name = new(args[0]) - response, err := w.VectorSearchEndpoints.GetEndpoint(ctx, getEndpointReq) + sdkReq := &getEndpointReq + response, err := w.VectorSearch.GetEndpoint(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := vectorsearch.EndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -297,13 +319,12 @@ func newGetEndpoint() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *vectorsearch.GetVectorSearchEndpointPermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq vectorsearch.GetVectorSearchEndpointPermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels ENDPOINT_ID" cmd.Short = `Get vector search endpoint permission levels.` @@ -327,15 +348,23 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getPermissionLevelsReq.RequestObjectId = new(args[0]) - getPermissionLevelsReq.EndpointId = args[0] + getPermissionLevelsReq.RequestObjectType = new("vector-search-endpoints") - response, err := w.VectorSearchEndpoints.GetPermissionLevels(ctx, getPermissionLevelsReq) + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -356,13 +385,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *vectorsearch.GetVectorSearchEndpointPermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq vectorsearch.GetVectorSearchEndpointPermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions ENDPOINT_ID" cmd.Short = `Get vector search endpoint permissions.` @@ -387,15 +415,23 @@ func newGetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getPermissionsReq.RequestObjectId = new(args[0]) - getPermissionsReq.EndpointId = args[0] + getPermissionsReq.RequestObjectType = new("vector-search-endpoints") - response, err := w.VectorSearchEndpoints.GetPermissions(ctx, getPermissionsReq) + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -421,8 +457,8 @@ var listEndpointsOverrides []func( func newListEndpoints() *cobra.Command { cmd := &cobra.Command{} - var listEndpointsReq vectorsearch.ListEndpointsRequest + // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -432,7 +468,7 @@ func newListEndpoints() *cobra.Command { cmd.Flags().IntVar(&listEndpointsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listEndpointsReq.PageToken, "page-token", listEndpointsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listEndpointsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-endpoints" @@ -454,16 +490,20 @@ func newListEndpoints() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.VectorSearchEndpoints.ListEndpoints(ctx, listEndpointsReq) + sdkReq, err := vectorsearch.ListEndpointsRequestToSDK(&listEndpointsReq) + if err != nil { + return err + } if listEndpointsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listEndpointsLimit) } if listEndpointsLimit > 0 { ctx = cmdio.WithLimit(ctx, listEndpointsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.VectorSearch.ListEndpointsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, vectorsearch.EndpointFromSDK)) } // Disable completions since they are not applicable. @@ -489,13 +529,13 @@ var patchEndpointOverrides []func( func newPatchEndpoint() *cobra.Command { cmd := &cobra.Command{} - var patchEndpointReq vectorsearch.PatchEndpointRequest + var patchEndpointJson flags.JsonFlag cmd.Flags().Var(&patchEndpointJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Int64Var(&patchEndpointReq.TargetQps, "target-qps", patchEndpointReq.TargetQps, `Target QPS for the endpoint.`) + flags.Int64PtrVar(cmd.Flags(), &patchEndpointReq.TargetQps, "target-qps", `Target QPS for the endpoint.`) cmd.Use = "patch-endpoint ENDPOINT_NAME" cmd.Short = `*Public Preview* Update an endpoint.` @@ -521,6 +561,7 @@ Update an endpoint. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := patchEndpointJson.Unmarshal(&patchEndpointReq) @@ -534,14 +575,22 @@ Update an endpoint. } } } - patchEndpointReq.EndpointName = args[0] + patchEndpointReq.Name = new(args[0]) - response, err := w.VectorSearchEndpoints.PatchEndpoint(ctx, patchEndpointReq) + sdkReq, err := vectorsearch.PatchEndpointRequestToSDK(&patchEndpointReq) + if err != nil { + return err + } + response, err := w.VectorSearch.PatchEndpoint(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := vectorsearch.EndpointFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -567,17 +616,17 @@ var retrieveUserVisibleMetricsOverrides []func( func newRetrieveUserVisibleMetrics() *cobra.Command { cmd := &cobra.Command{} - var retrieveUserVisibleMetricsReq vectorsearch.RetrieveUserVisibleMetricsRequest + var retrieveUserVisibleMetricsJson flags.JsonFlag cmd.Flags().Var(&retrieveUserVisibleMetricsJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&retrieveUserVisibleMetricsReq.EndTime, "end-time", retrieveUserVisibleMetricsReq.EndTime, `End time for metrics query.`) - cmd.Flags().IntVar(&retrieveUserVisibleMetricsReq.GranularityInSeconds, "granularity-in-seconds", retrieveUserVisibleMetricsReq.GranularityInSeconds, `Granularity in seconds.`) + flags.JSONStringPtrVar(cmd.Flags(), &retrieveUserVisibleMetricsReq.EndTime, "end-time", `End time for metrics query.`) + flags.IntPtrVar(cmd.Flags(), &retrieveUserVisibleMetricsReq.GranularityInSeconds, "granularity-in-seconds", `Granularity in seconds.`) // TODO: array: metrics - cmd.Flags().StringVar(&retrieveUserVisibleMetricsReq.PageToken, "page-token", retrieveUserVisibleMetricsReq.PageToken, `Token for pagination.`) - cmd.Flags().StringVar(&retrieveUserVisibleMetricsReq.StartTime, "start-time", retrieveUserVisibleMetricsReq.StartTime, `Start time for metrics query.`) + flags.StringPtrVar(cmd.Flags(), &retrieveUserVisibleMetricsReq.PageToken, "page-token", `Token for pagination.`) + flags.JSONStringPtrVar(cmd.Flags(), &retrieveUserVisibleMetricsReq.StartTime, "start-time", `Start time for metrics query.`) cmd.Use = "retrieve-user-visible-metrics NAME" cmd.Short = `Retrieve user-visible metrics for an endpoint.` @@ -601,6 +650,7 @@ func newRetrieveUserVisibleMetrics() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := retrieveUserVisibleMetricsJson.Unmarshal(&retrieveUserVisibleMetricsReq) @@ -614,14 +664,22 @@ func newRetrieveUserVisibleMetrics() *cobra.Command { } } } - retrieveUserVisibleMetricsReq.Name = args[0] + retrieveUserVisibleMetricsReq.Name = new(args[0]) - response, err := w.VectorSearchEndpoints.RetrieveUserVisibleMetrics(ctx, retrieveUserVisibleMetricsReq) + sdkReq, err := vectorsearch.RetrieveUserVisibleMetricsRequestToSDK(&retrieveUserVisibleMetricsReq) + if err != nil { + return err + } + response, err := w.VectorSearch.RetrieveUserVisibleMetrics(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := vectorsearch.RetrieveUserVisibleMetricsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -642,13 +700,13 @@ func newRetrieveUserVisibleMetrics() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *vectorsearch.VectorSearchEndpointPermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq vectorsearch.VectorSearchEndpointPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -679,6 +737,7 @@ func newSetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -692,14 +751,24 @@ func newSetPermissions() *cobra.Command { } } } - setPermissionsReq.EndpointId = args[0] + setPermissionsReq.RequestObjectId = new(args[0]) + + setPermissionsReq.RequestObjectType = new("vector-search-endpoints") - response, err := w.VectorSearchEndpoints.SetPermissions(ctx, setPermissionsReq) + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -725,8 +794,8 @@ var updateEndpointBudgetPolicyOverrides []func( func newUpdateEndpointBudgetPolicy() *cobra.Command { cmd := &cobra.Command{} - var updateEndpointBudgetPolicyReq vectorsearch.PatchEndpointBudgetPolicyRequest + var updateEndpointBudgetPolicyJson flags.JsonFlag cmd.Flags().Var(&updateEndpointBudgetPolicyJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -763,6 +832,7 @@ Update the budget policy of an endpoint. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateEndpointBudgetPolicyJson.Unmarshal(&updateEndpointBudgetPolicyReq) @@ -776,17 +846,25 @@ Update the budget policy of an endpoint. } } } - updateEndpointBudgetPolicyReq.EndpointName = args[0] + updateEndpointBudgetPolicyReq.Name = new(args[0]) if !cmd.Flags().Changed("json") { - updateEndpointBudgetPolicyReq.BudgetPolicyId = args[1] + updateEndpointBudgetPolicyReq.BudgetPolicyId = new(args[1]) } - response, err := w.VectorSearchEndpoints.UpdateEndpointBudgetPolicy(ctx, updateEndpointBudgetPolicyReq) + sdkReq, err := vectorsearch.PatchEndpointBudgetPolicyRequestToSDK(&updateEndpointBudgetPolicyReq) + if err != nil { + return err + } + response, err := w.VectorSearch.PatchEndpointBudgetPolicy(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := vectorsearch.PatchEndpointBudgetPolicyResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -812,8 +890,8 @@ var updateEndpointCustomTagsOverrides []func( func newUpdateEndpointCustomTags() *cobra.Command { cmd := &cobra.Command{} - var updateEndpointCustomTagsReq vectorsearch.UpdateEndpointCustomTagsRequest + var updateEndpointCustomTagsJson flags.JsonFlag cmd.Flags().Var(&updateEndpointCustomTagsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -841,6 +919,7 @@ func newUpdateEndpointCustomTags() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateEndpointCustomTagsJson.Unmarshal(&updateEndpointCustomTagsReq) @@ -856,14 +935,22 @@ func newUpdateEndpointCustomTags() *cobra.Command { } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - updateEndpointCustomTagsReq.EndpointName = args[0] + updateEndpointCustomTagsReq.Name = new(args[0]) - response, err := w.VectorSearchEndpoints.UpdateEndpointCustomTags(ctx, updateEndpointCustomTagsReq) + sdkReq, err := vectorsearch.UpdateEndpointCustomTagsRequestToSDK(&updateEndpointCustomTagsReq) + if err != nil { + return err + } + response, err := w.VectorSearch.UpdateEndpointCustomTags(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := vectorsearch.UpdateEndpointCustomTagsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -884,13 +971,13 @@ func newUpdateEndpointCustomTags() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *vectorsearch.VectorSearchEndpointPermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq vectorsearch.VectorSearchEndpointPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -920,6 +1007,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -933,14 +1021,24 @@ func newUpdatePermissions() *cobra.Command { } } } - updatePermissionsReq.EndpointId = args[0] + updatePermissionsReq.RequestObjectId = new(args[0]) - response, err := w.VectorSearchEndpoints.UpdatePermissions(ctx, updatePermissionsReq) + updatePermissionsReq.RequestObjectType = new("vector-search-endpoints") + + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/vector-search-indexes/vector-search-indexes.go b/cmd/workspace/vector-search-indexes/vector-search-indexes.go index a1b9bddfcfa..47b6d739ce8 100644 --- a/cmd/workspace/vector-search-indexes/vector-search-indexes.go +++ b/cmd/workspace/vector-search-indexes/vector-search-indexes.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" "github.com/spf13/cobra" + + vectorsearch "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" + sdkvectorsearch "github.com/databricks/sdk-go/vectorsearch/v1" ) // Slice with functions to override default command behavior. @@ -70,15 +73,15 @@ var createIndexOverrides []func( func newCreateIndex() *cobra.Command { cmd := &cobra.Command{} - var createIndexReq vectorsearch.CreateVectorIndexRequest + var createIndexJson flags.JsonFlag cmd.Flags().Var(&createIndexJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: delta_sync_index_spec // TODO: complex arg: direct_access_index_spec - cmd.Flags().Var(&createIndexReq.IndexSubtype, "index-subtype", `The subtype of the index. Supported values: [FULL_TEXT, HYBRID, VECTOR]`) + flags.EnumVar(cmd.Flags(), &createIndexReq.IndexSubtype, "index-subtype", `The subtype of the index. Supported values: [FULL_TEXT, HYBRID, VECTOR]`, "IndexSubtype", "FULL_TEXT", "HYBRID", "VECTOR") cmd.Use = "create-index NAME ENDPOINT_NAME PRIMARY_KEY INDEX_TYPE" cmd.Short = `Create an index.` @@ -113,6 +116,7 @@ func newCreateIndex() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createIndexJson.Unmarshal(&createIndexReq) @@ -127,28 +131,32 @@ func newCreateIndex() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createIndexReq.Name = args[0] + createIndexReq.Name = new(args[0]) } if !cmd.Flags().Changed("json") { - createIndexReq.EndpointName = args[1] + createIndexReq.EndpointName = new(args[1]) } if !cmd.Flags().Changed("json") { - createIndexReq.PrimaryKey = args[2] + createIndexReq.PrimaryKey = new(args[2]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &createIndexReq.IndexType) - if err != nil { - return fmt.Errorf("invalid INDEX_TYPE: %s", args[3]) - } - + createIndexReq.IndexType = vectorsearch.VectorIndexType(args[3]) } - response, err := w.VectorSearchIndexes.CreateIndex(ctx, createIndexReq) + sdkReq, err := vectorsearch.CreateVectorIndexRequestToSDK(&createIndexReq) + if err != nil { + return err + } + response, err := w.VectorSearch.CreateVectorIndex(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := vectorsearch.VectorIndexFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -174,8 +182,8 @@ var deleteDataVectorIndexOverrides []func( func newDeleteDataVectorIndex() *cobra.Command { cmd := &cobra.Command{} - var deleteDataVectorIndexReq vectorsearch.DeleteDataVectorIndexRequest + var deleteDataVectorIndexJson flags.JsonFlag cmd.Flags().Var(&deleteDataVectorIndexJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -203,6 +211,7 @@ func newDeleteDataVectorIndex() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := deleteDataVectorIndexJson.Unmarshal(&deleteDataVectorIndexReq) @@ -218,14 +227,22 @@ func newDeleteDataVectorIndex() *cobra.Command { } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - deleteDataVectorIndexReq.IndexName = args[0] + deleteDataVectorIndexReq.Name = new(args[0]) - response, err := w.VectorSearchIndexes.DeleteDataVectorIndex(ctx, deleteDataVectorIndexReq) + sdkReq, err := vectorsearch.DeleteDataVectorIndexRequestToSDK(&deleteDataVectorIndexReq) + if err != nil { + return err + } + response, err := w.VectorSearch.DeleteDataVectorIndex(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := vectorsearch.DeleteDataVectorIndexResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -246,13 +263,12 @@ func newDeleteDataVectorIndex() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteIndexOverrides []func( *cobra.Command, - *vectorsearch.DeleteIndexRequest, + *sdkvectorsearch.DeleteVectorIndexRequest, ) func newDeleteIndex() *cobra.Command { cmd := &cobra.Command{} - - var deleteIndexReq vectorsearch.DeleteIndexRequest + var deleteIndexReq sdkvectorsearch.DeleteVectorIndexRequest cmd.Use = "delete-index INDEX_NAME" cmd.Short = `Delete an index.` @@ -274,13 +290,17 @@ func newDeleteIndex() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteIndexReq.IndexName = args[0] + deleteIndexReq.Name = new(args[0]) - err = w.VectorSearchIndexes.DeleteIndex(ctx, deleteIndexReq) + sdkReq := &deleteIndexReq + response, err := w.VectorSearch.DeleteVectorIndex(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -302,15 +322,14 @@ func newDeleteIndex() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getIndexOverrides []func( *cobra.Command, - *vectorsearch.GetIndexRequest, + *vectorsearch.GetVectorIndexRequest, ) func newGetIndex() *cobra.Command { cmd := &cobra.Command{} + var getIndexReq vectorsearch.GetVectorIndexRequest - var getIndexReq vectorsearch.GetIndexRequest - - cmd.Flags().BoolVar(&getIndexReq.EnsureRerankerCompatible, "ensure-reranker-compatible", getIndexReq.EnsureRerankerCompatible, `If true, the URL returned for the index is guaranteed to be compatible with the reranker.`) + flags.BoolPtrVar(cmd.Flags(), &getIndexReq.EnsureRerankerCompatible, "ensure-reranker-compatible", `If true, the URL returned for the index is guaranteed to be compatible with the reranker.`) cmd.Use = "get-index INDEX_NAME" cmd.Short = `Get an index.` @@ -332,15 +351,24 @@ func newGetIndex() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getIndexReq.IndexName = args[0] + getIndexReq.Name = new(args[0]) - response, err := w.VectorSearchIndexes.GetIndex(ctx, getIndexReq) + sdkReq, err := vectorsearch.GetVectorIndexRequestToSDK(&getIndexReq) + if err != nil { + return err + } + response, err := w.VectorSearch.GetVectorIndex(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := vectorsearch.VectorIndexFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -361,13 +389,13 @@ func newGetIndex() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listIndexesOverrides []func( *cobra.Command, - *vectorsearch.ListIndexesRequest, + *vectorsearch.ListVectorIndexRequest, ) func newListIndexes() *cobra.Command { cmd := &cobra.Command{} + var listIndexesReq vectorsearch.ListVectorIndexRequest - var listIndexesReq vectorsearch.ListIndexesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -377,7 +405,7 @@ func newListIndexes() *cobra.Command { cmd.Flags().IntVar(&listIndexesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listIndexesReq.PageToken, "page-token", listIndexesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listIndexesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-indexes ENDPOINT_NAME" @@ -402,18 +430,22 @@ func newListIndexes() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listIndexesReq.EndpointName = args[0] + listIndexesReq.EndpointName = new(args[0]) - response := w.VectorSearchIndexes.ListIndexes(ctx, listIndexesReq) + sdkReq, err := vectorsearch.ListVectorIndexRequestToSDK(&listIndexesReq) + if err != nil { + return err + } if listIndexesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listIndexesLimit) } if listIndexesLimit > 0 { ctx = cmdio.WithLimit(ctx, listIndexesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.VectorSearch.ListVectorIndexIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, vectorsearch.MiniVectorIndexFromSDK)) } // Disable completions since they are not applicable. @@ -439,22 +471,22 @@ var queryIndexOverrides []func( func newQueryIndex() *cobra.Command { cmd := &cobra.Command{} - var queryIndexReq vectorsearch.QueryVectorIndexRequest + var queryIndexJson flags.JsonFlag cmd.Flags().Var(&queryIndexJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: columns_to_rerank // TODO: array: facets - cmd.Flags().StringVar(&queryIndexReq.FiltersJson, "filters-json", queryIndexReq.FiltersJson, `JSON string representing query filters.`) - cmd.Flags().IntVar(&queryIndexReq.NumResults, "num-results", queryIndexReq.NumResults, `Number of results to return.`) + flags.StringPtrVar(cmd.Flags(), &queryIndexReq.FiltersJson, "filters-json", `JSON string representing query filters.`) + flags.IntPtrVar(cmd.Flags(), &queryIndexReq.NumResults, "num-results", `Number of results to return.`) // TODO: array: query_columns - cmd.Flags().StringVar(&queryIndexReq.QueryText, "query-text", queryIndexReq.QueryText, `Query text.`) - cmd.Flags().StringVar(&queryIndexReq.QueryType, "query-type", queryIndexReq.QueryType, `The query type to use.`) + flags.StringPtrVar(cmd.Flags(), &queryIndexReq.QueryText, "query-text", `Query text.`) + flags.StringPtrVar(cmd.Flags(), &queryIndexReq.QueryType, "query-type", `The query type to use.`) // TODO: array: query_vector // TODO: complex arg: reranker - cmd.Flags().Float64Var(&queryIndexReq.ScoreThreshold, "score-threshold", queryIndexReq.ScoreThreshold, `Threshold for the approximate nearest neighbor search.`) + flags.Float32PtrVar(cmd.Flags(), &queryIndexReq.ScoreThreshold, "score-threshold", `Threshold for the approximate nearest neighbor search.`) // TODO: array: sort_columns cmd.Use = "query-index INDEX_NAME" @@ -479,6 +511,7 @@ func newQueryIndex() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := queryIndexJson.Unmarshal(&queryIndexReq) @@ -494,14 +527,22 @@ func newQueryIndex() *cobra.Command { } else { return errors.New("please provide command input in JSON format by specifying the --json flag") } - queryIndexReq.IndexName = args[0] + queryIndexReq.Name = new(args[0]) - response, err := w.VectorSearchIndexes.QueryIndex(ctx, queryIndexReq) + sdkReq, err := vectorsearch.QueryVectorIndexRequestToSDK(&queryIndexReq) + if err != nil { + return err + } + response, err := w.VectorSearch.QueryVectorIndex(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := vectorsearch.QueryVectorIndexResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -527,14 +568,14 @@ var queryNextPageOverrides []func( func newQueryNextPage() *cobra.Command { cmd := &cobra.Command{} - var queryNextPageReq vectorsearch.QueryVectorIndexNextPageRequest + var queryNextPageJson flags.JsonFlag cmd.Flags().Var(&queryNextPageJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&queryNextPageReq.EndpointName, "endpoint-name", queryNextPageReq.EndpointName, `Name of the endpoint.`) - cmd.Flags().StringVar(&queryNextPageReq.PageToken, "page-token", queryNextPageReq.PageToken, `Page token returned from previous QueryVectorIndex or QueryVectorIndexNextPage API.`) + flags.StringPtrVar(cmd.Flags(), &queryNextPageReq.EndpointName, "endpoint-name", `Name of the endpoint.`) + flags.StringPtrVar(cmd.Flags(), &queryNextPageReq.PageToken, "page-token", `Page token returned from previous QueryVectorIndex or QueryVectorIndexNextPage API.`) cmd.Use = "query-next-page INDEX_NAME" cmd.Short = `Query next page.` @@ -559,6 +600,7 @@ func newQueryNextPage() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := queryNextPageJson.Unmarshal(&queryNextPageReq) @@ -572,14 +614,22 @@ func newQueryNextPage() *cobra.Command { } } } - queryNextPageReq.IndexName = args[0] + queryNextPageReq.Name = new(args[0]) - response, err := w.VectorSearchIndexes.QueryNextPage(ctx, queryNextPageReq) + sdkReq, err := vectorsearch.QueryVectorIndexNextPageRequestToSDK(&queryNextPageReq) + if err != nil { + return err + } + response, err := w.VectorSearch.QueryVectorIndexNextPage(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := vectorsearch.QueryVectorIndexResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -605,14 +655,14 @@ var scanIndexOverrides []func( func newScanIndex() *cobra.Command { cmd := &cobra.Command{} - var scanIndexReq vectorsearch.ScanVectorIndexRequest + var scanIndexJson flags.JsonFlag cmd.Flags().Var(&scanIndexJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&scanIndexReq.LastPrimaryKey, "last-primary-key", scanIndexReq.LastPrimaryKey, `Primary key of the last entry returned in the previous scan.`) - cmd.Flags().IntVar(&scanIndexReq.NumResults, "num-results", scanIndexReq.NumResults, `Number of results to return.`) + flags.StringPtrVar(cmd.Flags(), &scanIndexReq.LastPrimaryKey, "last-primary-key", `Primary key of the last entry returned in the previous scan.`) + flags.IntPtrVar(cmd.Flags(), &scanIndexReq.NumResults, "num-results", `Number of results to return.`) cmd.Use = "scan-index INDEX_NAME" cmd.Short = `Scan an index.` @@ -637,6 +687,7 @@ func newScanIndex() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := scanIndexJson.Unmarshal(&scanIndexReq) @@ -650,14 +701,22 @@ func newScanIndex() *cobra.Command { } } } - scanIndexReq.IndexName = args[0] + scanIndexReq.Name = new(args[0]) - response, err := w.VectorSearchIndexes.ScanIndex(ctx, scanIndexReq) + sdkReq, err := vectorsearch.ScanVectorIndexRequestToSDK(&scanIndexReq) + if err != nil { + return err + } + response, err := w.VectorSearch.ScanVectorIndex(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := vectorsearch.ScanVectorIndexResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -678,13 +737,12 @@ func newScanIndex() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var syncIndexOverrides []func( *cobra.Command, - *vectorsearch.SyncIndexRequest, + *vectorsearch.SyncVectorIndexRequest, ) func newSyncIndex() *cobra.Command { cmd := &cobra.Command{} - - var syncIndexReq vectorsearch.SyncIndexRequest + var syncIndexReq vectorsearch.SyncVectorIndexRequest cmd.Use = "sync-index INDEX_NAME" cmd.Short = `Synchronize an index.` @@ -708,13 +766,20 @@ func newSyncIndex() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - syncIndexReq.IndexName = args[0] + syncIndexReq.Name = new(args[0]) - err = w.VectorSearchIndexes.SyncIndex(ctx, syncIndexReq) + sdkReq, err := vectorsearch.SyncVectorIndexRequestToSDK(&syncIndexReq) if err != nil { return err } + response, err := w.VectorSearch.SyncVectorIndex(ctx, *sdkReq) + if err != nil { + return err + } + + _ = response return nil } @@ -741,8 +806,8 @@ var upsertDataVectorIndexOverrides []func( func newUpsertDataVectorIndex() *cobra.Command { cmd := &cobra.Command{} - var upsertDataVectorIndexReq vectorsearch.UpsertDataVectorIndexRequest + var upsertDataVectorIndexJson flags.JsonFlag cmd.Flags().Var(&upsertDataVectorIndexJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -778,6 +843,7 @@ func newUpsertDataVectorIndex() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := upsertDataVectorIndexJson.Unmarshal(&upsertDataVectorIndexReq) @@ -791,17 +857,25 @@ func newUpsertDataVectorIndex() *cobra.Command { } } } - upsertDataVectorIndexReq.IndexName = args[0] + upsertDataVectorIndexReq.Name = new(args[0]) if !cmd.Flags().Changed("json") { - upsertDataVectorIndexReq.InputsJson = args[1] + upsertDataVectorIndexReq.InputsJson = new(args[1]) } - response, err := w.VectorSearchIndexes.UpsertDataVectorIndex(ctx, upsertDataVectorIndexReq) + sdkReq, err := vectorsearch.UpsertDataVectorIndexRequestToSDK(&upsertDataVectorIndexReq) + if err != nil { + return err + } + response, err := w.VectorSearch.UpsertDataVectorIndex(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := vectorsearch.UpsertDataVectorIndexResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/volumes/volumes.go b/cmd/workspace/volumes/volumes.go index 1361f293c8c..4e6df6b3d19 100644 --- a/cmd/workspace/volumes/volumes.go +++ b/cmd/workspace/volumes/volumes.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucvolumes "github.com/databricks/cli/libs/sdktypes/uc/volumes/v1" + sdkucvolumes "github.com/databricks/sdk-go/uc/volumes/v1" ) // Slice with functions to override default command behavior. @@ -59,19 +62,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *catalog.CreateVolumeRequestContent, + *ucvolumes.CreateVolumeRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq ucvolumes.CreateVolumeRequest - var createReq catalog.CreateVolumeRequestContent 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.Comment, "comment", createReq.Comment, `The comment attached to the volume.`) - cmd.Flags().StringVar(&createReq.StorageLocation, "storage-location", createReq.StorageLocation, `The storage location on the cloud.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Comment, "comment", `The comment attached to the volume.`) + flags.StringPtrVar(cmd.Flags(), &createReq.StorageLocation, "storage-location", `The storage location on the cloud.`) cmd.Use = "create CATALOG_NAME SCHEMA_NAME NAME VOLUME_TYPE" cmd.Short = `Create a Volume.` @@ -128,6 +131,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -142,28 +146,32 @@ func newCreate() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createReq.CatalogName = args[0] + createReq.CatalogName = new(args[0]) } if !cmd.Flags().Changed("json") { - createReq.SchemaName = args[1] + createReq.SchemaName = new(args[1]) } if !cmd.Flags().Changed("json") { - createReq.Name = args[2] + createReq.Name = new(args[2]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &createReq.VolumeType) - if err != nil { - return fmt.Errorf("invalid VOLUME_TYPE: %s", args[3]) - } - + createReq.VolumeType = ucvolumes.VolumeType(args[3]) } - response, err := w.Volumes.Create(ctx, createReq) + sdkReq, err := ucvolumes.CreateVolumeRequestToSDK(&createReq) + if err != nil { + return err + } + response, err := w.Volumes.CreateVolume(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucvolumes.VolumeInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -184,13 +192,12 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *catalog.DeleteVolumeRequest, + *sdkucvolumes.DeleteVolumeRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq catalog.DeleteVolumeRequest + var deleteReq sdkucvolumes.DeleteVolumeRequest cmd.Use = "delete NAME" cmd.Short = `Delete a Volume.` @@ -213,11 +220,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Volumes drop-down.") - names, err := w.Volumes.VolumeInfoNameToVolumeIdMap(ctx, catalog.ListVolumesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Volumes.ListVolumesIter(ctx, sdkucvolumes.ListVolumesRequest{}), []string{"Name"}, []string{"VolumeId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Volumes drop-down. Please manually specify required arguments. Original error: %w", err) @@ -231,12 +239,15 @@ func newDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the three-level (fully qualified) name of the volume") } - deleteReq.Name = args[0] + deleteReq.FullNameArg = new(args[0]) - err = w.Volumes.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Volumes.DeleteVolume(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -258,26 +269,26 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *catalog.ListVolumesRequest, + *ucvolumes.ListVolumesRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq ucvolumes.ListVolumesRequest - var listReq catalog.ListVolumesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().BoolVar(&listReq.IncludeBrowse, "include-browse", listReq.IncludeBrowse, `Whether to include volumes in the response for which the principal can only access selective metadata for.`) - cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Maximum number of volumes to return (page length).`) + flags.BoolPtrVar(cmd.Flags(), &listReq.IncludeBrowse, "include-browse", `Whether to include volumes in the response for which the principal can only access selective metadata for.`) + flags.IntPtrVar(cmd.Flags(), &listReq.MaxResults, "max-results", `Maximum number of volumes to return (page length).`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list CATALOG_NAME SCHEMA_NAME" @@ -318,19 +329,23 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listReq.CatalogName = args[0] - listReq.SchemaName = args[1] + listReq.CatalogName = new(args[0]) + listReq.SchemaName = new(args[1]) - response := w.Volumes.List(ctx, listReq) + sdkReq, err := ucvolumes.ListVolumesRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Volumes.ListVolumesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucvolumes.VolumeInfoFromSDK)) } // Disable completions since they are not applicable. @@ -351,15 +366,14 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var readOverrides []func( *cobra.Command, - *catalog.ReadVolumeRequest, + *ucvolumes.GetVolumeRequest, ) func newRead() *cobra.Command { cmd := &cobra.Command{} + var readReq ucvolumes.GetVolumeRequest - var readReq catalog.ReadVolumeRequest - - cmd.Flags().BoolVar(&readReq.IncludeBrowse, "include-browse", readReq.IncludeBrowse, `Whether to include volumes in the response for which the principal can only access selective metadata for.`) + flags.BoolPtrVar(cmd.Flags(), &readReq.IncludeBrowse, "include-browse", `Whether to include volumes in the response for which the principal can only access selective metadata for.`) cmd.Use = "read NAME" cmd.Short = `Get a Volume.` @@ -383,11 +397,12 @@ func newRead() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Volumes drop-down.") - names, err := w.Volumes.VolumeInfoNameToVolumeIdMap(ctx, catalog.ListVolumesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Volumes.ListVolumesIter(ctx, sdkucvolumes.ListVolumesRequest{}), []string{"Name"}, []string{"VolumeId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Volumes drop-down. Please manually specify required arguments. Original error: %w", err) @@ -401,14 +416,22 @@ func newRead() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the three-level (fully qualified) name of the volume") } - readReq.Name = args[0] + readReq.FullNameArg = new(args[0]) - response, err := w.Volumes.Read(ctx, readReq) + sdkReq, err := ucvolumes.GetVolumeRequestToSDK(&readReq) + if err != nil { + return err + } + response, err := w.Volumes.GetVolume(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucvolumes.VolumeInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -429,20 +452,20 @@ func newRead() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateVolumeRequestContent, + *ucvolumes.UpdateVolumeRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucvolumes.UpdateVolumeRequest - var updateReq catalog.UpdateVolumeRequestContent 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.Comment, "comment", updateReq.Comment, `The comment attached to the volume.`) - cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the volume.`) - cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `The identifier of the user who owns the volume.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Comment, "comment", `The comment attached to the volume.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.NewName, "new-name", `New name for the volume.`) + flags.StringPtrVar(cmd.Flags(), &updateReq.Owner, "owner", `The identifier of the user who owns the volume.`) cmd.Use = "update NAME" cmd.Short = `Update a Volume.` @@ -468,6 +491,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -484,7 +508,7 @@ func newUpdate() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Volumes drop-down.") - names, err := w.Volumes.VolumeInfoNameToVolumeIdMap(ctx, catalog.ListVolumesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Volumes.ListVolumesIter(ctx, sdkucvolumes.ListVolumesRequest{}), []string{"Name"}, []string{"VolumeId"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Volumes drop-down. Please manually specify required arguments. Original error: %w", err) @@ -498,14 +522,22 @@ func newUpdate() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the three-level (fully qualified) name of the volume") } - updateReq.Name = args[0] + updateReq.FullNameArg = new(args[0]) - response, err := w.Volumes.Update(ctx, updateReq) + sdkReq, err := ucvolumes.UpdateVolumeRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.Volumes.UpdateVolume(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucvolumes.VolumeInfoFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/warehouses/overrides.go b/cmd/workspace/warehouses/overrides.go index 9457557d00b..31d00673350 100644 --- a/cmd/workspace/warehouses/overrides.go +++ b/cmd/workspace/warehouses/overrides.go @@ -2,11 +2,11 @@ package warehouses import ( "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/sql" + warehouses "github.com/databricks/cli/libs/sdktypes/warehouses/v1" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *sql.ListWarehousesRequest) { +func listOverride(listCmd *cobra.Command, listReq *warehouses.ListWarehousesRequest) { listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "ID"}} {{header "Name"}} {{header "Size"}} {{header "State"}}`) listCmd.Annotations["template"] = cmdio.Heredoc(` diff --git a/cmd/workspace/warehouses/warehouses.go b/cmd/workspace/warehouses/warehouses.go index d3f33c1190e..48d11d03b30 100644 --- a/cmd/workspace/warehouses/warehouses.go +++ b/cmd/workspace/warehouses/warehouses.go @@ -5,16 +5,22 @@ package warehouses import ( "errors" "fmt" - "strings" "time" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "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/sql" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + warehouses "github.com/databricks/cli/libs/sdktypes/warehouses/v1" + sdkaccessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + sdkwarehouses "github.com/databricks/sdk-go/warehouses/v1" ) // Slice with functions to override default command behavior. @@ -70,13 +76,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *sql.CreateWarehouseRequest, + *warehouses.CreateWarehouseRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} + var createReq warehouses.CreateWarehouseRequest - var createReq sql.CreateWarehouseRequest var createJson flags.JsonFlag var createSkipWait bool @@ -87,20 +93,20 @@ func newCreate() *cobra.Command { cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().IntVar(&createReq.AutoStopMins, "auto-stop-mins", createReq.AutoStopMins, `The amount of time in minutes that a SQL warehouse must be idle (i.e., no RUNNING queries) before it is automatically stopped.`) + flags.IntPtrVar(cmd.Flags(), &createReq.AutoStopMins, "auto-stop-mins", `The amount of time in minutes that a SQL warehouse must be idle (i.e., no RUNNING queries) before it is automatically stopped.`) // TODO: complex arg: channel - cmd.Flags().StringVar(&createReq.ClusterSize, "cluster-size", createReq.ClusterSize, `Size of the clusters allocated for this warehouse.`) - cmd.Flags().StringVar(&createReq.CreatorName, "creator-name", createReq.CreatorName, `warehouse creator name.`) - cmd.Flags().BoolVar(&createReq.EnablePhoton, "enable-photon", createReq.EnablePhoton, `Configures whether the warehouse should use Photon optimized clusters.`) - cmd.Flags().BoolVar(&createReq.EnableServerlessCompute, "enable-serverless-compute", createReq.EnableServerlessCompute, `Configures whether the warehouse should use serverless compute.`) - cmd.Flags().StringVar(&createReq.InstanceProfileArn, "instance-profile-arn", createReq.InstanceProfileArn, `Deprecated.`) - cmd.Flags().IntVar(&createReq.MaxNumClusters, "max-num-clusters", createReq.MaxNumClusters, `Maximum number of clusters that the autoscaler will create to handle concurrent queries.`) - cmd.Flags().IntVar(&createReq.MinNumClusters, "min-num-clusters", createReq.MinNumClusters, `Minimum number of available clusters that will be maintained for this SQL warehouse.`) - cmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `Logical name for the cluster.`) - cmd.Flags().Var(&createReq.SpotInstancePolicy, "spot-instance-policy", `Configurations whether the endpoint should use spot instances. Supported values: [COST_OPTIMIZED, POLICY_UNSPECIFIED, RELIABILITY_OPTIMIZED]`) - cmd.Flags().IntVar(&createReq.StatementTimeout, "statement-timeout", createReq.StatementTimeout, `Warehouse statement timeout in seconds.`) + flags.StringPtrVar(cmd.Flags(), &createReq.ClusterSize, "cluster-size", `Size of the clusters allocated for this warehouse.`) + flags.StringPtrVar(cmd.Flags(), &createReq.CreatorName, "creator-name", `warehouse creator name.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.EnablePhoton, "enable-photon", `Configures whether the warehouse should use Photon optimized clusters.`) + flags.BoolPtrVar(cmd.Flags(), &createReq.EnableServerlessCompute, "enable-serverless-compute", `Configures whether the warehouse should use serverless compute.`) + flags.StringPtrVar(cmd.Flags(), &createReq.InstanceProfileArn, "instance-profile-arn", `Deprecated.`) + flags.IntPtrVar(cmd.Flags(), &createReq.MaxNumClusters, "max-num-clusters", `Maximum number of clusters that the autoscaler will create to handle concurrent queries.`) + flags.IntPtrVar(cmd.Flags(), &createReq.MinNumClusters, "min-num-clusters", `Minimum number of available clusters that will be maintained for this SQL warehouse.`) + flags.StringPtrVar(cmd.Flags(), &createReq.Name, "name", `Logical name for the cluster.`) + flags.EnumVar(cmd.Flags(), &createReq.SpotInstancePolicy, "spot-instance-policy", `Configurations whether the endpoint should use spot instances. Supported values: [COST_OPTIMIZED, POLICY_UNSPECIFIED, RELIABILITY_OPTIMIZED]`, "SpotInstancePolicy", "COST_OPTIMIZED", "POLICY_UNSPECIFIED", "RELIABILITY_OPTIMIZED") + flags.IntPtrVar(cmd.Flags(), &createReq.StatementTimeout, "statement-timeout", `Warehouse statement timeout in seconds.`) // TODO: complex arg: tags - cmd.Flags().Var(&createReq.WarehouseType, "warehouse-type", `Warehouse type: PRO or CLASSIC. Supported values: [CLASSIC, PRO, TYPE_UNSPECIFIED]`) + flags.EnumVar(cmd.Flags(), &createReq.WarehouseType, "warehouse-type", `Warehouse type: PRO or CLASSIC. Supported values: [CLASSIC, PRO, TYPE_UNSPECIFIED]`, "CreateWarehouseRequestWarehouseType", "CLASSIC", "PRO", "TYPE_UNSPECIFIED") cmd.Use = "create" cmd.Short = `Create a warehouse.` @@ -121,6 +127,7 @@ func newCreate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -135,30 +142,39 @@ func newCreate() *cobra.Command { } } - wait, err := w.Warehouses.Create(ctx, createReq) + sdkReq, err := warehouses.CreateWarehouseRequestToSDK(&createReq) if err != nil { return err } if createSkipWait { - return cmdio.Render(ctx, wait.Response) - } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *sql.GetWarehouseResponse) { - if i.Health == nil { - return + api, err := apiclient.New(w.Config) + if err != nil { + return err } - status := i.State - statusMessage := fmt.Sprintf("current status: %s", status) - if i.Health != nil { - statusMessage = i.Health.Summary + var current warehouses.CreateWarehouseResponse + err = api.Do(ctx, "POST", "/api/2.0/sql/warehouses", auth.WorkspaceIDHeaders(w.Config), nil, &createReq, ¤t) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(createTimeout) + return cmdio.Render(ctx, current) + } + wait, err := w.Warehouses.CreateWarehouse(ctx, *sdkReq) + if err != nil { + return err + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for create to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(createTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := warehouses.GetWarehouseResponseFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -179,20 +195,20 @@ func newCreate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createDefaultWarehouseOverrideOverrides []func( *cobra.Command, - *sql.CreateDefaultWarehouseOverrideRequest, + *warehouses.CreateDefaultWarehouseOverrideRequest, ) func newCreateDefaultWarehouseOverride() *cobra.Command { cmd := &cobra.Command{} + var createDefaultWarehouseOverrideReq warehouses.CreateDefaultWarehouseOverrideRequest + createDefaultWarehouseOverrideReq.DefaultWarehouseOverride = &warehouses.DefaultWarehouseOverride{} - var createDefaultWarehouseOverrideReq sql.CreateDefaultWarehouseOverrideRequest - createDefaultWarehouseOverrideReq.DefaultWarehouseOverride = sql.DefaultWarehouseOverride{} var createDefaultWarehouseOverrideJson flags.JsonFlag cmd.Flags().Var(&createDefaultWarehouseOverrideJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createDefaultWarehouseOverrideReq.DefaultWarehouseOverride.Name, "name", createDefaultWarehouseOverrideReq.DefaultWarehouseOverride.Name, `The resource name of the default warehouse override.`) - cmd.Flags().StringVar(&createDefaultWarehouseOverrideReq.DefaultWarehouseOverride.WarehouseId, "warehouse-id", createDefaultWarehouseOverrideReq.DefaultWarehouseOverride.WarehouseId, `The specific warehouse ID when type is CUSTOM.`) + flags.StringPtrVar(cmd.Flags(), &createDefaultWarehouseOverrideReq.DefaultWarehouseOverride.Name, "name", `The resource name of the default warehouse override.`) + flags.StringPtrVar(cmd.Flags(), &createDefaultWarehouseOverrideReq.DefaultWarehouseOverride.WarehouseId, "warehouse-id", `The specific warehouse ID when type is CUSTOM.`) cmd.Use = "create-default-warehouse-override DEFAULT_WAREHOUSE_OVERRIDE_ID TYPE" cmd.Short = `*Beta* Create default warehouse override.` @@ -230,6 +246,7 @@ Create default warehouse override. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createDefaultWarehouseOverrideJson.Unmarshal(&createDefaultWarehouseOverrideReq.DefaultWarehouseOverride) @@ -243,21 +260,25 @@ Create default warehouse override. } } } - createDefaultWarehouseOverrideReq.DefaultWarehouseOverrideId = args[0] + createDefaultWarehouseOverrideReq.DefaultWarehouseOverrideId = new(args[0]) if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createDefaultWarehouseOverrideReq.DefaultWarehouseOverride.Type) - if err != nil { - return fmt.Errorf("invalid TYPE: %s", args[1]) - } - + createDefaultWarehouseOverrideReq.DefaultWarehouseOverride.Type = warehouses.DefaultWarehouseOverrideType(args[1]) } - response, err := w.Warehouses.CreateDefaultWarehouseOverride(ctx, createDefaultWarehouseOverrideReq) + sdkReq, err := warehouses.CreateDefaultWarehouseOverrideRequestToSDK(&createDefaultWarehouseOverrideReq) + if err != nil { + return err + } + response, err := w.Warehouses.CreateDefaultWarehouseOverride(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := warehouses.DefaultWarehouseOverrideFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -278,13 +299,12 @@ Create default warehouse override. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *sql.DeleteWarehouseRequest, + *sdkwarehouses.DeleteWarehouseRequest, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} - - var deleteReq sql.DeleteWarehouseRequest + var deleteReq sdkwarehouses.DeleteWarehouseRequest cmd.Use = "delete ID" cmd.Short = `Delete a warehouse.` @@ -303,11 +323,12 @@ func newDelete() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Warehouses drop-down.") - names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Warehouses.ListWarehousesIter(ctx, sdkwarehouses.ListWarehousesRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) @@ -321,12 +342,15 @@ func newDelete() *cobra.Command { if len(args) != 1 { return errors.New("expected to have required") } - deleteReq.Id = args[0] + deleteReq.Id = new(args[0]) - err = w.Warehouses.Delete(ctx, deleteReq) + sdkReq := &deleteReq + response, err := w.Warehouses.DeleteWarehouse(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -348,13 +372,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteDefaultWarehouseOverrideOverrides []func( *cobra.Command, - *sql.DeleteDefaultWarehouseOverrideRequest, + *sdkwarehouses.DeleteDefaultWarehouseOverrideRequest, ) func newDeleteDefaultWarehouseOverride() *cobra.Command { cmd := &cobra.Command{} - - var deleteDefaultWarehouseOverrideReq sql.DeleteDefaultWarehouseOverrideRequest + var deleteDefaultWarehouseOverrideReq sdkwarehouses.DeleteDefaultWarehouseOverrideRequest cmd.Use = "delete-default-warehouse-override NAME" cmd.Short = `*Beta* Delete default warehouse override.` @@ -380,11 +403,12 @@ Delete default warehouse override. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Warehouses drop-down.") - names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Warehouses.ListWarehousesIter(ctx, sdkwarehouses.ListWarehousesRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) @@ -398,9 +422,10 @@ Delete default warehouse override. if len(args) != 1 { return errors.New("expected to have required") } - deleteDefaultWarehouseOverrideReq.Name = args[0] + deleteDefaultWarehouseOverrideReq.Name = new(args[0]) - err = w.Warehouses.DeleteDefaultWarehouseOverride(ctx, deleteDefaultWarehouseOverrideReq) + sdkReq := &deleteDefaultWarehouseOverrideReq + err = w.Warehouses.DeleteDefaultWarehouseOverride(ctx, *sdkReq) if err != nil { return err } @@ -425,13 +450,13 @@ Delete default warehouse override. // Functions can be added from the `init()` function in manually curated files in this directory. var editOverrides []func( *cobra.Command, - *sql.EditWarehouseRequest, + *warehouses.EditWarehouseRequest, ) func newEdit() *cobra.Command { cmd := &cobra.Command{} + var editReq warehouses.EditWarehouseRequest - var editReq sql.EditWarehouseRequest var editJson flags.JsonFlag var editSkipWait bool @@ -442,20 +467,20 @@ func newEdit() *cobra.Command { cmd.Flags().Var(&editJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().IntVar(&editReq.AutoStopMins, "auto-stop-mins", editReq.AutoStopMins, `The amount of time in minutes that a SQL warehouse must be idle (i.e., no RUNNING queries) before it is automatically stopped.`) + flags.IntPtrVar(cmd.Flags(), &editReq.AutoStopMins, "auto-stop-mins", `The amount of time in minutes that a SQL warehouse must be idle (i.e., no RUNNING queries) before it is automatically stopped.`) // TODO: complex arg: channel - cmd.Flags().StringVar(&editReq.ClusterSize, "cluster-size", editReq.ClusterSize, `Size of the clusters allocated for this warehouse.`) - cmd.Flags().StringVar(&editReq.CreatorName, "creator-name", editReq.CreatorName, `warehouse creator name.`) - cmd.Flags().BoolVar(&editReq.EnablePhoton, "enable-photon", editReq.EnablePhoton, `Configures whether the warehouse should use Photon optimized clusters.`) - cmd.Flags().BoolVar(&editReq.EnableServerlessCompute, "enable-serverless-compute", editReq.EnableServerlessCompute, `Configures whether the warehouse should use serverless compute.`) - cmd.Flags().StringVar(&editReq.InstanceProfileArn, "instance-profile-arn", editReq.InstanceProfileArn, `Deprecated.`) - cmd.Flags().IntVar(&editReq.MaxNumClusters, "max-num-clusters", editReq.MaxNumClusters, `Maximum number of clusters that the autoscaler will create to handle concurrent queries.`) - cmd.Flags().IntVar(&editReq.MinNumClusters, "min-num-clusters", editReq.MinNumClusters, `Minimum number of available clusters that will be maintained for this SQL warehouse.`) - cmd.Flags().StringVar(&editReq.Name, "name", editReq.Name, `Logical name for the cluster.`) - cmd.Flags().Var(&editReq.SpotInstancePolicy, "spot-instance-policy", `Configurations whether the endpoint should use spot instances. Supported values: [COST_OPTIMIZED, POLICY_UNSPECIFIED, RELIABILITY_OPTIMIZED]`) - cmd.Flags().IntVar(&editReq.StatementTimeout, "statement-timeout", editReq.StatementTimeout, `Warehouse statement timeout in seconds.`) + flags.StringPtrVar(cmd.Flags(), &editReq.ClusterSize, "cluster-size", `Size of the clusters allocated for this warehouse.`) + flags.StringPtrVar(cmd.Flags(), &editReq.CreatorName, "creator-name", `warehouse creator name.`) + flags.BoolPtrVar(cmd.Flags(), &editReq.EnablePhoton, "enable-photon", `Configures whether the warehouse should use Photon optimized clusters.`) + flags.BoolPtrVar(cmd.Flags(), &editReq.EnableServerlessCompute, "enable-serverless-compute", `Configures whether the warehouse should use serverless compute.`) + flags.StringPtrVar(cmd.Flags(), &editReq.InstanceProfileArn, "instance-profile-arn", `Deprecated.`) + flags.IntPtrVar(cmd.Flags(), &editReq.MaxNumClusters, "max-num-clusters", `Maximum number of clusters that the autoscaler will create to handle concurrent queries.`) + flags.IntPtrVar(cmd.Flags(), &editReq.MinNumClusters, "min-num-clusters", `Minimum number of available clusters that will be maintained for this SQL warehouse.`) + flags.StringPtrVar(cmd.Flags(), &editReq.Name, "name", `Logical name for the cluster.`) + flags.EnumVar(cmd.Flags(), &editReq.SpotInstancePolicy, "spot-instance-policy", `Configurations whether the endpoint should use spot instances. Supported values: [COST_OPTIMIZED, POLICY_UNSPECIFIED, RELIABILITY_OPTIMIZED]`, "SpotInstancePolicy", "COST_OPTIMIZED", "POLICY_UNSPECIFIED", "RELIABILITY_OPTIMIZED") + flags.IntPtrVar(cmd.Flags(), &editReq.StatementTimeout, "statement-timeout", `Warehouse statement timeout in seconds.`) // TODO: complex arg: tags - cmd.Flags().Var(&editReq.WarehouseType, "warehouse-type", `Warehouse type: PRO or CLASSIC. Supported values: [CLASSIC, PRO, TYPE_UNSPECIFIED]`) + flags.EnumVar(cmd.Flags(), &editReq.WarehouseType, "warehouse-type", `Warehouse type: PRO or CLASSIC. Supported values: [CLASSIC, PRO, TYPE_UNSPECIFIED]`, "EditWarehouseRequestWarehouseType", "CLASSIC", "PRO", "TYPE_UNSPECIFIED") cmd.Use = "edit ID" cmd.Short = `Update a warehouse.` @@ -474,6 +499,7 @@ func newEdit() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := editJson.Unmarshal(&editReq) @@ -490,7 +516,7 @@ func newEdit() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Warehouses drop-down.") - names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Warehouses.ListWarehousesIter(ctx, sdkwarehouses.ListWarehousesRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) @@ -504,32 +530,41 @@ func newEdit() *cobra.Command { if len(args) != 1 { return errors.New("expected to have required") } - editReq.Id = args[0] + editReq.Id = new(args[0]) - wait, err := w.Warehouses.Edit(ctx, editReq) + sdkReq, err := warehouses.EditWarehouseRequestToSDK(&editReq) if err != nil { return err } - if editSkipWait { - return nil + wait, err := w.Warehouses.EditWarehouse(ctx, *sdkReq) + if err != nil { + return err } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *sql.GetWarehouseResponse) { - if i.Health == nil { - return + if editSkipWait { + // Render the current state, as of right after the call. + current, err := w.Warehouses.GetWarehouse(ctx, sdkwarehouses.GetWarehouseRequest{Id: new(wait.GetId())}) + if err != nil { + return err } - status := i.State - statusMessage := fmt.Sprintf("current status: %s", status) - if i.Health != nil { - statusMessage = i.Health.Summary + out, err := warehouses.GetWarehouseResponseFromSDK(current) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(editTimeout) + return cmdio.Render(ctx, out) + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for edit to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(editTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := warehouses.GetWarehouseResponseFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -550,13 +585,12 @@ func newEdit() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *sql.GetWarehouseRequest, + *sdkwarehouses.GetWarehouseRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq sql.GetWarehouseRequest + var getReq sdkwarehouses.GetWarehouseRequest cmd.Use = "get ID" cmd.Short = `Get warehouse info.` @@ -575,11 +609,12 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Warehouses drop-down.") - names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Warehouses.ListWarehousesIter(ctx, sdkwarehouses.ListWarehousesRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) @@ -593,14 +628,19 @@ func newGet() *cobra.Command { if len(args) != 1 { return errors.New("expected to have required") } - getReq.Id = args[0] + getReq.Id = new(args[0]) - response, err := w.Warehouses.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.Warehouses.GetWarehouse(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := warehouses.GetWarehouseResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -621,13 +661,12 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getDefaultWarehouseOverrideOverrides []func( *cobra.Command, - *sql.GetDefaultWarehouseOverrideRequest, + *sdkwarehouses.GetDefaultWarehouseOverrideRequest, ) func newGetDefaultWarehouseOverride() *cobra.Command { cmd := &cobra.Command{} - - var getDefaultWarehouseOverrideReq sql.GetDefaultWarehouseOverrideRequest + var getDefaultWarehouseOverrideReq sdkwarehouses.GetDefaultWarehouseOverrideRequest cmd.Use = "get-default-warehouse-override NAME" cmd.Short = `*Beta* Get default warehouse override.` @@ -653,11 +692,12 @@ Get default warehouse override. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No NAME argument specified. Loading names for Warehouses drop-down.") - names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Warehouses.ListWarehousesIter(ctx, sdkwarehouses.ListWarehousesRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) @@ -671,14 +711,19 @@ Get default warehouse override. if len(args) != 1 { return errors.New("expected to have required") } - getDefaultWarehouseOverrideReq.Name = args[0] + getDefaultWarehouseOverrideReq.Name = new(args[0]) - response, err := w.Warehouses.GetDefaultWarehouseOverride(ctx, getDefaultWarehouseOverrideReq) + sdkReq := &getDefaultWarehouseOverrideReq + response, err := w.Warehouses.GetDefaultWarehouseOverride(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := warehouses.DefaultWarehouseOverrideFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -699,13 +744,12 @@ Get default warehouse override. // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *sql.GetWarehousePermissionLevelsRequest, + *sdkaccessmanagement.ListPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq sql.GetWarehousePermissionLevelsRequest + var getPermissionLevelsReq sdkaccessmanagement.ListPermissionLevelsRequest cmd.Use = "get-permission-levels WAREHOUSE_ID" cmd.Short = `Get SQL warehouse permission levels.` @@ -724,11 +768,12 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No WAREHOUSE_ID argument specified. Loading names for Warehouses drop-down.") - names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Warehouses.ListWarehousesIter(ctx, sdkwarehouses.ListWarehousesRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) @@ -742,14 +787,21 @@ func newGetPermissionLevels() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the sql warehouse for which to get or manage permissions") } - getPermissionLevelsReq.WarehouseId = args[0] + getPermissionLevelsReq.RequestObjectId = new(args[0]) + + getPermissionLevelsReq.RequestObjectType = new("warehouses") - response, err := w.Warehouses.GetPermissionLevels(ctx, getPermissionLevelsReq) + sdkReq := &getPermissionLevelsReq + response, err := w.AccessManagement.ListPermissionLevels(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.ListPermissionLevelsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -770,13 +822,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *sql.GetWarehousePermissionsRequest, + *sdkaccessmanagement.GetObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq sql.GetWarehousePermissionsRequest + var getPermissionsReq sdkaccessmanagement.GetObjectPermissionsRequest cmd.Use = "get-permissions WAREHOUSE_ID" cmd.Short = `Get SQL warehouse permissions.` @@ -796,11 +847,12 @@ func newGetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No WAREHOUSE_ID argument specified. Loading names for Warehouses drop-down.") - names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Warehouses.ListWarehousesIter(ctx, sdkwarehouses.ListWarehousesRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) @@ -814,14 +866,21 @@ func newGetPermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the sql warehouse for which to get or manage permissions") } - getPermissionsReq.WarehouseId = args[0] + getPermissionsReq.RequestObjectId = new(args[0]) - response, err := w.Warehouses.GetPermissions(ctx, getPermissionsReq) + getPermissionsReq.RequestObjectType = new("warehouses") + + sdkReq := &getPermissionsReq + response, err := w.AccessManagement.GetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -862,12 +921,20 @@ func newGetWorkspaceWarehouseConfig() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) - response, err := w.Warehouses.GetWorkspaceWarehouseConfig(ctx) + _ = w + + sdkReq := &sdkwarehouses.GetWorkspaceWarehouseConfigRequest{} + + response, err := w.Warehouses.GetWorkspaceWarehouseConfig(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := warehouses.GetWorkspaceWarehouseConfigResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -888,26 +955,26 @@ func newGetWorkspaceWarehouseConfig() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *sql.ListWarehousesRequest, + *warehouses.ListWarehousesRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq warehouses.ListWarehousesRequest - var listReq sql.ListWarehousesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listLimit int - cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `The max number of warehouses to return.`) - cmd.Flags().IntVar(&listReq.RunAsUserId, "run-as-user-id", listReq.RunAsUserId, `Deprecated: this field is ignored by the server.`) + flags.IntPtrVar(cmd.Flags(), &listReq.PageSize, "page-size", `The max number of warehouses to return.`) + flags.Int64PtrVar(cmd.Flags(), &listReq.RunAsUserId, "run-as-user-id", `Deprecated: this field is ignored by the server.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list" @@ -929,16 +996,20 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Warehouses.List(ctx, listReq) + sdkReq, err := warehouses.ListWarehousesRequestToSDK(&listReq) + if err != nil { + return err + } if listLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listLimit) } if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Warehouses.ListWarehousesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, warehouses.EndpointInfoFromSDK)) } // Disable completions since they are not applicable. @@ -959,25 +1030,25 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listDefaultWarehouseOverridesOverrides []func( *cobra.Command, - *sql.ListDefaultWarehouseOverridesRequest, + *warehouses.ListDefaultWarehouseOverridesRequest, ) func newListDefaultWarehouseOverrides() *cobra.Command { cmd := &cobra.Command{} + var listDefaultWarehouseOverridesReq warehouses.ListDefaultWarehouseOverridesRequest - var listDefaultWarehouseOverridesReq sql.ListDefaultWarehouseOverridesRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listDefaultWarehouseOverridesLimit int - cmd.Flags().IntVar(&listDefaultWarehouseOverridesReq.PageSize, "page-size", listDefaultWarehouseOverridesReq.PageSize, `The maximum number of overrides to return.`) + flags.IntPtrVar(cmd.Flags(), &listDefaultWarehouseOverridesReq.PageSize, "page-size", `The maximum number of overrides to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listDefaultWarehouseOverridesLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listDefaultWarehouseOverridesReq.PageToken, "page-token", listDefaultWarehouseOverridesReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listDefaultWarehouseOverridesReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-default-warehouse-overrides" @@ -1002,16 +1073,20 @@ List default warehouse overrides. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.Warehouses.ListDefaultWarehouseOverrides(ctx, listDefaultWarehouseOverridesReq) + sdkReq, err := warehouses.ListDefaultWarehouseOverridesRequestToSDK(&listDefaultWarehouseOverridesReq) + if err != nil { + return err + } if listDefaultWarehouseOverridesLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listDefaultWarehouseOverridesLimit) } if listDefaultWarehouseOverridesLimit > 0 { ctx = cmdio.WithLimit(ctx, listDefaultWarehouseOverridesLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Warehouses.ListDefaultWarehouseOverridesIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, warehouses.DefaultWarehouseOverrideFromSDK)) } // Disable completions since they are not applicable. @@ -1032,13 +1107,13 @@ List default warehouse overrides. // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *sql.WarehousePermissionsRequest, + *accessmanagement.SetObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq accessmanagement.SetObjectPermissionsRequest - var setPermissionsReq sql.WarehousePermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1064,6 +1139,7 @@ func newSetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -1080,7 +1156,7 @@ func newSetPermissions() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No WAREHOUSE_ID argument specified. Loading names for Warehouses drop-down.") - names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Warehouses.ListWarehousesIter(ctx, sdkwarehouses.ListWarehousesRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1094,14 +1170,24 @@ func newSetPermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the sql warehouse for which to get or manage permissions") } - setPermissionsReq.WarehouseId = args[0] + setPermissionsReq.RequestObjectId = new(args[0]) - response, err := w.Warehouses.SetPermissions(ctx, setPermissionsReq) + setPermissionsReq.RequestObjectType = new("warehouses") + + sdkReq, err := accessmanagement.SetObjectPermissionsRequestToSDK(&setPermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.SetObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1122,13 +1208,13 @@ func newSetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setWorkspaceWarehouseConfigOverrides []func( *cobra.Command, - *sql.SetWorkspaceWarehouseConfigRequest, + *warehouses.SetWorkspaceWarehouseConfigRequest, ) func newSetWorkspaceWarehouseConfig() *cobra.Command { cmd := &cobra.Command{} + var setWorkspaceWarehouseConfigReq warehouses.SetWorkspaceWarehouseConfigRequest - var setWorkspaceWarehouseConfigReq sql.SetWorkspaceWarehouseConfigRequest var setWorkspaceWarehouseConfigJson flags.JsonFlag cmd.Flags().Var(&setWorkspaceWarehouseConfigJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1136,12 +1222,12 @@ func newSetWorkspaceWarehouseConfig() *cobra.Command { // TODO: complex arg: channel // TODO: complex arg: config_param // TODO: array: data_access_config - cmd.Flags().BoolVar(&setWorkspaceWarehouseConfigReq.EnableServerlessCompute, "enable-serverless-compute", setWorkspaceWarehouseConfigReq.EnableServerlessCompute, `Deprecated: only setting this to true is allowed.`) + flags.BoolPtrVar(cmd.Flags(), &setWorkspaceWarehouseConfigReq.EnableServerlessCompute, "enable-serverless-compute", `Deprecated: only setting this to true is allowed.`) // TODO: array: enabled_warehouse_types // TODO: complex arg: global_param - cmd.Flags().StringVar(&setWorkspaceWarehouseConfigReq.GoogleServiceAccount, "google-service-account", setWorkspaceWarehouseConfigReq.GoogleServiceAccount, `GCP only: Google Service Account used to pass to cluster to access Google Cloud Storage.`) - cmd.Flags().StringVar(&setWorkspaceWarehouseConfigReq.InstanceProfileArn, "instance-profile-arn", setWorkspaceWarehouseConfigReq.InstanceProfileArn, `AWS Only: The instance profile used to pass an IAM role to the SQL warehouses.`) - cmd.Flags().Var(&setWorkspaceWarehouseConfigReq.SecurityPolicy, "security-policy", `Security policy for warehouses. Supported values: [DATA_ACCESS_CONTROL, NONE, PASSTHROUGH]`) + flags.StringPtrVar(cmd.Flags(), &setWorkspaceWarehouseConfigReq.GoogleServiceAccount, "google-service-account", `GCP only: Google Service Account used to pass to cluster to access Google Cloud Storage.`) + flags.StringPtrVar(cmd.Flags(), &setWorkspaceWarehouseConfigReq.InstanceProfileArn, "instance-profile-arn", `AWS Only: The instance profile used to pass an IAM role to the SQL warehouses.`) + flags.EnumVar(cmd.Flags(), &setWorkspaceWarehouseConfigReq.SecurityPolicy, "security-policy", `Security policy for warehouses. Supported values: [DATA_ACCESS_CONTROL, NONE, PASSTHROUGH]`, "SetWorkspaceWarehouseConfigRequestSecurityPolicy", "DATA_ACCESS_CONTROL", "NONE", "PASSTHROUGH") // TODO: complex arg: sql_configuration_parameters cmd.Use = "set-workspace-warehouse-config" @@ -1164,6 +1250,7 @@ func newSetWorkspaceWarehouseConfig() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setWorkspaceWarehouseConfigJson.Unmarshal(&setWorkspaceWarehouseConfigReq) @@ -1178,10 +1265,16 @@ func newSetWorkspaceWarehouseConfig() *cobra.Command { } } - err = w.Warehouses.SetWorkspaceWarehouseConfig(ctx, setWorkspaceWarehouseConfigReq) + sdkReq, err := warehouses.SetWorkspaceWarehouseConfigRequestToSDK(&setWorkspaceWarehouseConfigReq) + if err != nil { + return err + } + response, err := w.Warehouses.SetWorkspaceWarehouseConfig(ctx, *sdkReq) if err != nil { return err } + + _ = response return nil } @@ -1203,13 +1296,12 @@ func newSetWorkspaceWarehouseConfig() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var startOverrides []func( *cobra.Command, - *sql.StartRequest, + *warehouses.StartRequest, ) func newStart() *cobra.Command { cmd := &cobra.Command{} - - var startReq sql.StartRequest + var startReq warehouses.StartRequest var startSkipWait bool var startTimeout time.Duration @@ -1234,11 +1326,12 @@ func newStart() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Warehouses drop-down.") - names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Warehouses.ListWarehousesIter(ctx, sdkwarehouses.ListWarehousesRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1252,32 +1345,41 @@ func newStart() *cobra.Command { if len(args) != 1 { return errors.New("expected to have required") } - startReq.Id = args[0] + startReq.Id = new(args[0]) - wait, err := w.Warehouses.Start(ctx, startReq) + sdkReq, err := warehouses.StartRequestToSDK(&startReq) if err != nil { return err } - if startSkipWait { - return nil + wait, err := w.Warehouses.StartWarehouse(ctx, *sdkReq) + if err != nil { + return err } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *sql.GetWarehouseResponse) { - if i.Health == nil { - return + if startSkipWait { + // Render the current state, as of right after the call. + current, err := w.Warehouses.GetWarehouse(ctx, sdkwarehouses.GetWarehouseRequest{Id: new(wait.GetId())}) + if err != nil { + return err } - status := i.State - statusMessage := fmt.Sprintf("current status: %s", status) - if i.Health != nil { - statusMessage = i.Health.Summary + out, err := warehouses.GetWarehouseResponseFromSDK(current) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(startTimeout) + return cmdio.Render(ctx, out) + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for start to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(startTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := warehouses.GetWarehouseResponseFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1298,13 +1400,12 @@ func newStart() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var stopOverrides []func( *cobra.Command, - *sql.StopRequest, + *warehouses.StopRequest, ) func newStop() *cobra.Command { cmd := &cobra.Command{} - - var stopReq sql.StopRequest + var stopReq warehouses.StopRequest var stopSkipWait bool var stopTimeout time.Duration @@ -1329,11 +1430,12 @@ func newStop() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No ID argument specified. Loading names for Warehouses drop-down.") - names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Warehouses.ListWarehousesIter(ctx, sdkwarehouses.ListWarehousesRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1347,32 +1449,41 @@ func newStop() *cobra.Command { if len(args) != 1 { return errors.New("expected to have required") } - stopReq.Id = args[0] + stopReq.Id = new(args[0]) - wait, err := w.Warehouses.Stop(ctx, stopReq) + sdkReq, err := warehouses.StopRequestToSDK(&stopReq) if err != nil { return err } - if stopSkipWait { - return nil + wait, err := w.Warehouses.StopWarehouse(ctx, *sdkReq) + if err != nil { + return err } - sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *sql.GetWarehouseResponse) { - if i.Health == nil { - return + if stopSkipWait { + // Render the current state, as of right after the call. + current, err := w.Warehouses.GetWarehouse(ctx, sdkwarehouses.GetWarehouseRequest{Id: new(wait.GetId())}) + if err != nil { + return err } - status := i.State - statusMessage := fmt.Sprintf("current status: %s", status) - if i.Health != nil { - statusMessage = i.Health.Summary + out, err := warehouses.GetWarehouseResponseFromSDK(current) + if err != nil { + return err } - sp.Update(statusMessage) - }).GetWithTimeout(stopTimeout) + return cmdio.Render(ctx, out) + } + sp := cmdio.NewSpinner(ctx) + sp.Update("Waiting for stop to complete...") + response, err := wait.Wait(ctx, lro.WithTimeout(stopTimeout)) sp.Close() + if err != nil { + return &cmdgen.WaitError{Err: err} + } + + out, err := warehouses.GetWarehouseResponseFromSDK(response) if err != nil { return err } - return cmdio.Render(ctx, info) + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1393,21 +1504,21 @@ func newStop() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateDefaultWarehouseOverrideOverrides []func( *cobra.Command, - *sql.UpdateDefaultWarehouseOverrideRequest, + *warehouses.UpdateDefaultWarehouseOverrideRequest, ) func newUpdateDefaultWarehouseOverride() *cobra.Command { cmd := &cobra.Command{} + var updateDefaultWarehouseOverrideReq warehouses.UpdateDefaultWarehouseOverrideRequest + updateDefaultWarehouseOverrideReq.DefaultWarehouseOverride = &warehouses.DefaultWarehouseOverride{} - var updateDefaultWarehouseOverrideReq sql.UpdateDefaultWarehouseOverrideRequest - updateDefaultWarehouseOverrideReq.DefaultWarehouseOverride = sql.DefaultWarehouseOverride{} var updateDefaultWarehouseOverrideJson flags.JsonFlag cmd.Flags().Var(&updateDefaultWarehouseOverrideJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().BoolVar(&updateDefaultWarehouseOverrideReq.AllowMissing, "allow-missing", updateDefaultWarehouseOverrideReq.AllowMissing, `If set to true, and the override is not found, a new override will be created.`) - cmd.Flags().StringVar(&updateDefaultWarehouseOverrideReq.DefaultWarehouseOverride.Name, "name", updateDefaultWarehouseOverrideReq.DefaultWarehouseOverride.Name, `The resource name of the default warehouse override.`) - cmd.Flags().StringVar(&updateDefaultWarehouseOverrideReq.DefaultWarehouseOverride.WarehouseId, "warehouse-id", updateDefaultWarehouseOverrideReq.DefaultWarehouseOverride.WarehouseId, `The specific warehouse ID when type is CUSTOM.`) + flags.BoolPtrVar(cmd.Flags(), &updateDefaultWarehouseOverrideReq.AllowMissing, "allow-missing", `If set to true, and the override is not found, a new override will be created.`) + flags.StringPtrVar(cmd.Flags(), &updateDefaultWarehouseOverrideReq.DefaultWarehouseOverride.Name, "name", `The resource name of the default warehouse override.`) + flags.StringPtrVar(cmd.Flags(), &updateDefaultWarehouseOverrideReq.DefaultWarehouseOverride.WarehouseId, "warehouse-id", `The specific warehouse ID when type is CUSTOM.`) cmd.Use = "update-default-warehouse-override NAME UPDATE_MASK TYPE" cmd.Short = `*Beta* Update default warehouse override.` @@ -1447,6 +1558,7 @@ Update default warehouse override. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateDefaultWarehouseOverrideJson.Unmarshal(&updateDefaultWarehouseOverrideReq.DefaultWarehouseOverride) @@ -1460,25 +1572,28 @@ Update default warehouse override. } } } - updateDefaultWarehouseOverrideReq.Name = args[0] + updateDefaultWarehouseOverrideReq.DefaultWarehouseOverride.Name = new(args[0]) if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateDefaultWarehouseOverrideReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateDefaultWarehouseOverrideReq.UpdateMask = new(args[1]) } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &updateDefaultWarehouseOverrideReq.DefaultWarehouseOverride.Type) - if err != nil { - return fmt.Errorf("invalid TYPE: %s", args[2]) - } - + updateDefaultWarehouseOverrideReq.DefaultWarehouseOverride.Type = warehouses.DefaultWarehouseOverrideType(args[2]) } - response, err := w.Warehouses.UpdateDefaultWarehouseOverride(ctx, updateDefaultWarehouseOverrideReq) + sdkReq, err := warehouses.UpdateDefaultWarehouseOverrideRequestToSDK(&updateDefaultWarehouseOverrideReq) + if err != nil { + return err + } + response, err := w.Warehouses.UpdateDefaultWarehouseOverride(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := warehouses.DefaultWarehouseOverrideFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -1499,13 +1614,13 @@ Update default warehouse override. // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *sql.WarehousePermissionsRequest, + *accessmanagement.UpdateObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq accessmanagement.UpdateObjectPermissionsRequest - var updatePermissionsReq sql.WarehousePermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -1530,6 +1645,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -1546,7 +1662,7 @@ func newUpdatePermissions() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No WAREHOUSE_ID argument specified. Loading names for Warehouses drop-down.") - names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) + names, err := cmdgen.NamedIdMap(ctx, w.Warehouses.ListWarehousesIter(ctx, sdkwarehouses.ListWarehousesRequest{}), []string{"Name"}, []string{"Id"}) sp.Close() if err != nil { return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) @@ -1560,14 +1676,24 @@ func newUpdatePermissions() *cobra.Command { if len(args) != 1 { return errors.New("expected to have the sql warehouse for which to get or manage permissions") } - updatePermissionsReq.WarehouseId = args[0] + updatePermissionsReq.RequestObjectId = new(args[0]) + + updatePermissionsReq.RequestObjectType = new("warehouses") - response, err := w.Warehouses.UpdatePermissions(ctx, updatePermissionsReq) + sdkReq, err := accessmanagement.UpdateObjectPermissionsRequestToSDK(&updatePermissionsReq) + if err != nil { + return err + } + response, err := w.AccessManagement.UpdateObjectPermissions(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := accessmanagement.PermissionsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/workspace-bindings/workspace-bindings.go b/cmd/workspace/workspace-bindings/workspace-bindings.go index eac23b59514..db5134b9d72 100644 --- a/cmd/workspace/workspace-bindings/workspace-bindings.go +++ b/cmd/workspace/workspace-bindings/workspace-bindings.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" + + ucworkspacebindings "github.com/databricks/cli/libs/sdktypes/uc/workspacebindings/v1" + sdkucworkspacebindings "github.com/databricks/sdk-go/uc/workspacebindings/v1" ) // Slice with functions to override default command behavior. @@ -68,13 +71,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *catalog.GetWorkspaceBindingRequest, + *sdkucworkspacebindings.GetCatalogWorkspaceBindingsRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - - var getReq catalog.GetWorkspaceBindingRequest + var getReq sdkucworkspacebindings.GetCatalogWorkspaceBindingsRequest cmd.Use = "get NAME" cmd.Short = `Get catalog workspace bindings.` @@ -99,15 +101,21 @@ func newGet() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getReq.Name = args[0] + getReq.CatalogName = new(args[0]) - response, err := w.WorkspaceBindings.Get(ctx, getReq) + sdkReq := &getReq + response, err := w.WorkspaceBindings.GetCatalogWorkspaceBindings(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucworkspacebindings.GetCatalogWorkspaceBindingsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -128,13 +136,13 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getBindingsOverrides []func( *cobra.Command, - *catalog.GetBindingsRequest, + *ucworkspacebindings.GetWorkspaceBindingsRequest, ) func newGetBindings() *cobra.Command { cmd := &cobra.Command{} + var getBindingsReq ucworkspacebindings.GetWorkspaceBindingsRequest - var getBindingsReq catalog.GetBindingsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -144,9 +152,9 @@ func newGetBindings() *cobra.Command { cmd.Flags().IntVar(&getBindingsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&getBindingsReq.PageToken, "page-token", getBindingsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &getBindingsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true - cmd.Flags().IntVar(&getBindingsReq.MaxResults, "max-results", getBindingsReq.MaxResults, `Maximum number of workspace bindings to return.`) + flags.IntPtrVar(cmd.Flags(), &getBindingsReq.MaxResults, "max-results", `Maximum number of workspace bindings to return.`) cmd.Flags().Lookup("max-results").Hidden = true cmd.Use = "get-bindings SECURABLE_TYPE SECURABLE_NAME" @@ -182,19 +190,23 @@ func newGetBindings() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getBindingsReq.SecurableType = args[0] - getBindingsReq.SecurableName = args[1] + getBindingsReq.SecurableType = new(args[0]) + getBindingsReq.SecurableFullName = new(args[1]) - response := w.WorkspaceBindings.GetBindings(ctx, getBindingsReq) + sdkReq, err := ucworkspacebindings.GetWorkspaceBindingsRequestToSDK(&getBindingsReq) + if err != nil { + return err + } if getBindingsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", getBindingsLimit) } if getBindingsLimit > 0 { ctx = cmdio.WithLimit(ctx, getBindingsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.WorkspaceBindings.GetWorkspaceBindingsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, ucworkspacebindings.WorkspaceBindingInfoFromSDK)) } // Disable completions since they are not applicable. @@ -215,13 +227,13 @@ func newGetBindings() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *catalog.UpdateWorkspaceBindings, + *ucworkspacebindings.UpdateCatalogWorkspaceBindingsRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} + var updateReq ucworkspacebindings.UpdateCatalogWorkspaceBindingsRequest - var updateReq catalog.UpdateWorkspaceBindings var updateJson flags.JsonFlag cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -252,6 +264,7 @@ func newUpdate() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -265,14 +278,22 @@ func newUpdate() *cobra.Command { } } } - updateReq.Name = args[0] + updateReq.CatalogName = new(args[0]) - response, err := w.WorkspaceBindings.Update(ctx, updateReq) + sdkReq, err := ucworkspacebindings.UpdateCatalogWorkspaceBindingsRequestToSDK(&updateReq) + if err != nil { + return err + } + response, err := w.WorkspaceBindings.UpdateCatalogWorkspaceBindings(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucworkspacebindings.UpdateCatalogWorkspaceBindingsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -293,13 +314,13 @@ func newUpdate() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateBindingsOverrides []func( *cobra.Command, - *catalog.UpdateWorkspaceBindingsParameters, + *ucworkspacebindings.UpdateWorkspaceBindingsRequest, ) func newUpdateBindings() *cobra.Command { cmd := &cobra.Command{} + var updateBindingsReq ucworkspacebindings.UpdateWorkspaceBindingsRequest - var updateBindingsReq catalog.UpdateWorkspaceBindingsParameters var updateBindingsJson flags.JsonFlag cmd.Flags().Var(&updateBindingsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -332,6 +353,7 @@ func newUpdateBindings() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateBindingsJson.Unmarshal(&updateBindingsReq) @@ -345,15 +367,23 @@ func newUpdateBindings() *cobra.Command { } } } - updateBindingsReq.SecurableType = args[0] - updateBindingsReq.SecurableName = args[1] + updateBindingsReq.SecurableType = new(args[0]) + updateBindingsReq.SecurableFullName = new(args[1]) - response, err := w.WorkspaceBindings.UpdateBindings(ctx, updateBindingsReq) + sdkReq, err := ucworkspacebindings.UpdateWorkspaceBindingsRequestToSDK(&updateBindingsReq) + if err != nil { + return err + } + response, err := w.WorkspaceBindings.UpdateWorkspaceBindings(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := ucworkspacebindings.UpdateWorkspaceBindingsResponseFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/workspace-conf/workspace-conf.go b/cmd/workspace/workspace-conf/workspace-conf.go index 8da40a559d7..9e9413b0a8e 100644 --- a/cmd/workspace/workspace-conf/workspace-conf.go +++ b/cmd/workspace/workspace-conf/workspace-conf.go @@ -9,8 +9,10 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" + + domains "github.com/databricks/cli/libs/sdktypes/domains/v1" + sdkdomains "github.com/databricks/sdk-go/domains/v1" ) // Slice with functions to override default command behavior. @@ -48,13 +50,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getStatusOverrides []func( *cobra.Command, - *settings.GetStatusRequest, + *sdkdomains.GetDomainRequest, ) func newGetStatus() *cobra.Command { cmd := &cobra.Command{} - - var getStatusReq settings.GetStatusRequest + var getStatusReq sdkdomains.GetDomainRequest cmd.Use = "get-status KEYS" cmd.Short = `Check configuration status.` @@ -75,15 +76,23 @@ func newGetStatus() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getStatusReq.Keys = args[0] + _ = args[0] // TODO: field not in sdk-go request: keys - response, err := w.WorkspaceConf.GetStatus(ctx, getStatusReq) + getStatusReq.Name = new("workspace-conf") + + sdkReq := &getStatusReq + response, err := w.Domains.GetDomain(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := domains.DomainFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -104,13 +113,13 @@ func newGetStatus() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setStatusOverrides []func( *cobra.Command, - *settings.WorkspaceConf, + *domains.UpdateDomainRequest, ) func newSetStatus() *cobra.Command { cmd := &cobra.Command{} + var setStatusReq domains.UpdateDomainRequest - var setStatusReq settings.WorkspaceConf var setStatusJson flags.JsonFlag cmd.Flags().Var(&setStatusJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -130,6 +139,7 @@ func newSetStatus() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setStatusJson.Unmarshal(&setStatusReq) @@ -146,11 +156,22 @@ func newSetStatus() *cobra.Command { return errors.New("please provide command input in JSON format by specifying the --json flag") } - err = w.WorkspaceConf.SetStatus(ctx, setStatusReq) + setStatusReq.Domain.Name = new("workspace-conf") + + sdkReq, err := domains.UpdateDomainRequestToSDK(&setStatusReq) + if err != nil { + return err + } + response, err := w.Domains.UpdateDomain(ctx, *sdkReq) + if err != nil { + return err + } + + out, err := domains.DomainFromSDK(response) if err != nil { return err } - return nil + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. 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 794ab2066f9..2fe189c2c1a 100644 --- a/cmd/workspace/workspace-entity-tag-assignments/workspace-entity-tag-assignments.go +++ b/cmd/workspace/workspace-entity-tag-assignments/workspace-entity-tag-assignments.go @@ -8,10 +8,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/tags" "github.com/spf13/cobra" + + tagassignments "github.com/databricks/cli/libs/sdktypes/tagassignments/v1" + sdktagassignments "github.com/databricks/sdk-go/tagassignments/v1" ) // Slice with functions to override default command behavior. @@ -52,19 +55,19 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createTagAssignmentOverrides []func( *cobra.Command, - *tags.CreateTagAssignmentRequest, + *tagassignments.CreateTagAssignmentRequest, ) func newCreateTagAssignment() *cobra.Command { cmd := &cobra.Command{} + var createTagAssignmentReq tagassignments.CreateTagAssignmentRequest + createTagAssignmentReq.TagAssignment = &tagassignments.TagAssignment{} - var createTagAssignmentReq tags.CreateTagAssignmentRequest - createTagAssignmentReq.TagAssignment = tags.TagAssignment{} var createTagAssignmentJson flags.JsonFlag cmd.Flags().Var(&createTagAssignmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createTagAssignmentReq.TagAssignment.TagValue, "tag-value", createTagAssignmentReq.TagAssignment.TagValue, `The value of the tag.`) + flags.StringPtrVar(cmd.Flags(), &createTagAssignmentReq.TagAssignment.TagValue, "tag-value", `The value of the tag.`) cmd.Use = "create-tag-assignment ENTITY_TYPE ENTITY_ID TAG_KEY" cmd.Short = `Create a tag assignment for an entity.` @@ -100,6 +103,7 @@ func newCreateTagAssignment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := createTagAssignmentJson.Unmarshal(&createTagAssignmentReq.TagAssignment) @@ -114,21 +118,29 @@ func newCreateTagAssignment() *cobra.Command { } } if !cmd.Flags().Changed("json") { - createTagAssignmentReq.TagAssignment.EntityType = args[0] + createTagAssignmentReq.TagAssignment.EntityType = new(args[0]) } if !cmd.Flags().Changed("json") { - createTagAssignmentReq.TagAssignment.EntityId = args[1] + createTagAssignmentReq.TagAssignment.EntityId = new(args[1]) } if !cmd.Flags().Changed("json") { - createTagAssignmentReq.TagAssignment.TagKey = args[2] + createTagAssignmentReq.TagAssignment.TagKey = new(args[2]) } - response, err := w.WorkspaceEntityTagAssignments.CreateTagAssignment(ctx, createTagAssignmentReq) + sdkReq, err := tagassignments.CreateTagAssignmentRequestToSDK(&createTagAssignmentReq) + if err != nil { + return err + } + response, err := w.TagAssignments.CreateTagAssignment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := tagassignments.TagAssignmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -149,13 +161,12 @@ func newCreateTagAssignment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteTagAssignmentOverrides []func( *cobra.Command, - *tags.DeleteTagAssignmentRequest, + *sdktagassignments.DeleteTagAssignmentRequest, ) func newDeleteTagAssignment() *cobra.Command { cmd := &cobra.Command{} - - var deleteTagAssignmentReq tags.DeleteTagAssignmentRequest + var deleteTagAssignmentReq sdktagassignments.DeleteTagAssignmentRequest cmd.Use = "delete-tag-assignment ENTITY_TYPE ENTITY_ID TAG_KEY" cmd.Short = `Delete a tag assignment for an entity.` @@ -184,12 +195,14 @@ func newDeleteTagAssignment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - deleteTagAssignmentReq.EntityType = args[0] - deleteTagAssignmentReq.EntityId = args[1] - deleteTagAssignmentReq.TagKey = args[2] + deleteTagAssignmentReq.EntityType = new(args[0]) + deleteTagAssignmentReq.EntityId = new(args[1]) + deleteTagAssignmentReq.TagKey = new(args[2]) - err = w.WorkspaceEntityTagAssignments.DeleteTagAssignment(ctx, deleteTagAssignmentReq) + sdkReq := &deleteTagAssignmentReq + err = w.TagAssignments.DeleteTagAssignment(ctx, *sdkReq) if err != nil { return err } @@ -214,13 +227,12 @@ func newDeleteTagAssignment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getTagAssignmentOverrides []func( *cobra.Command, - *tags.GetTagAssignmentRequest, + *sdktagassignments.GetTagAssignmentRequest, ) func newGetTagAssignment() *cobra.Command { cmd := &cobra.Command{} - - var getTagAssignmentReq tags.GetTagAssignmentRequest + var getTagAssignmentReq sdktagassignments.GetTagAssignmentRequest cmd.Use = "get-tag-assignment ENTITY_TYPE ENTITY_ID TAG_KEY" cmd.Short = `Get a tag assignment for an entity.` @@ -249,17 +261,23 @@ func newGetTagAssignment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getTagAssignmentReq.EntityType = args[0] - getTagAssignmentReq.EntityId = args[1] - getTagAssignmentReq.TagKey = args[2] + getTagAssignmentReq.EntityType = new(args[0]) + getTagAssignmentReq.EntityId = new(args[1]) + getTagAssignmentReq.TagKey = new(args[2]) - response, err := w.WorkspaceEntityTagAssignments.GetTagAssignment(ctx, getTagAssignmentReq) + sdkReq := &getTagAssignmentReq + response, err := w.TagAssignments.GetTagAssignment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := tagassignments.TagAssignmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -280,25 +298,25 @@ func newGetTagAssignment() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listTagAssignmentsOverrides []func( *cobra.Command, - *tags.ListTagAssignmentsRequest, + *tagassignments.ListTagAssignmentsRequest, ) func newListTagAssignments() *cobra.Command { cmd := &cobra.Command{} + var listTagAssignmentsReq tagassignments.ListTagAssignmentsRequest - var listTagAssignmentsReq tags.ListTagAssignmentsRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listTagAssignmentsLimit int - cmd.Flags().IntVar(&listTagAssignmentsReq.PageSize, "page-size", listTagAssignmentsReq.PageSize, `Optional.`) + flags.IntPtrVar(cmd.Flags(), &listTagAssignmentsReq.PageSize, "page-size", `Optional.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listTagAssignmentsLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listTagAssignmentsReq.PageToken, "page-token", listTagAssignmentsReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listTagAssignmentsReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-tag-assignments ENTITY_TYPE ENTITY_ID" @@ -326,19 +344,23 @@ func newListTagAssignments() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - listTagAssignmentsReq.EntityType = args[0] - listTagAssignmentsReq.EntityId = args[1] + listTagAssignmentsReq.EntityType = new(args[0]) + listTagAssignmentsReq.EntityId = new(args[1]) - response := w.WorkspaceEntityTagAssignments.ListTagAssignments(ctx, listTagAssignmentsReq) + sdkReq, err := tagassignments.ListTagAssignmentsRequestToSDK(&listTagAssignmentsReq) + if err != nil { + return err + } if listTagAssignmentsLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listTagAssignmentsLimit) } if listTagAssignmentsLimit > 0 { ctx = cmdio.WithLimit(ctx, listTagAssignmentsLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.TagAssignments.ListTagAssignmentsIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, tagassignments.TagAssignmentFromSDK)) } // Disable completions since they are not applicable. @@ -359,19 +381,19 @@ func newListTagAssignments() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateTagAssignmentOverrides []func( *cobra.Command, - *tags.UpdateTagAssignmentRequest, + *tagassignments.UpdateTagAssignmentRequest, ) func newUpdateTagAssignment() *cobra.Command { cmd := &cobra.Command{} + var updateTagAssignmentReq tagassignments.UpdateTagAssignmentRequest + updateTagAssignmentReq.TagAssignment = &tagassignments.TagAssignment{} - var updateTagAssignmentReq tags.UpdateTagAssignmentRequest - updateTagAssignmentReq.TagAssignment = tags.TagAssignment{} var updateTagAssignmentJson flags.JsonFlag cmd.Flags().Var(&updateTagAssignmentJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateTagAssignmentReq.TagAssignment.TagValue, "tag-value", updateTagAssignmentReq.TagAssignment.TagValue, `The value of the tag.`) + flags.StringPtrVar(cmd.Flags(), &updateTagAssignmentReq.TagAssignment.TagValue, "tag-value", `The value of the tag.`) cmd.Use = "update-tag-assignment ENTITY_TYPE ENTITY_ID TAG_KEY UPDATE_MASK" cmd.Short = `Update a tag assignment for an entity.` @@ -411,6 +433,7 @@ func newUpdateTagAssignment() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updateTagAssignmentJson.Unmarshal(&updateTagAssignmentReq.TagAssignment) @@ -424,17 +447,25 @@ func newUpdateTagAssignment() *cobra.Command { } } } - updateTagAssignmentReq.EntityType = args[0] - updateTagAssignmentReq.EntityId = args[1] - updateTagAssignmentReq.TagKey = args[2] - updateTagAssignmentReq.UpdateMask = args[3] + updateTagAssignmentReq.TagAssignment.EntityType = new(args[0]) + updateTagAssignmentReq.TagAssignment.EntityId = new(args[1]) + updateTagAssignmentReq.TagAssignment.TagKey = new(args[2]) + updateTagAssignmentReq.UpdateMask = new(args[3]) - response, err := w.WorkspaceEntityTagAssignments.UpdateTagAssignment(ctx, updateTagAssignmentReq) + sdkReq, err := tagassignments.UpdateTagAssignmentRequestToSDK(&updateTagAssignmentReq) + if err != nil { + return err + } + response, err := w.TagAssignments.UpdateTagAssignment(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := tagassignments.TagAssignmentFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/workspace-iam-v2/workspace-iam-v2.go b/cmd/workspace/workspace-iam-v2/workspace-iam-v2.go index c09fcdd3749..f7cb9949769 100644 --- a/cmd/workspace/workspace-iam-v2/workspace-iam-v2.go +++ b/cmd/workspace/workspace-iam-v2/workspace-iam-v2.go @@ -5,14 +5,15 @@ package workspace_iam_v2 import ( "errors" "fmt" - "strings" + + "maps" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "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/iamv2" "github.com/spf13/cobra" ) @@ -91,14 +92,20 @@ These APIs are used to manage identities and the workspace access of these // Functions can be added from the `init()` function in manually curated files in this directory. var createDirectGroupMemberProxyOverrides []func( *cobra.Command, - *iamv2.CreateDirectGroupMemberProxyRequest, + *map[string]any, ) func newCreateDirectGroupMemberProxy() *cobra.Command { cmd := &cobra.Command{} + var createDirectGroupMemberProxyReq map[string]any + createDirectGroupMemberProxyReq = map[string]any{} + var createDirectGroupMemberProxyGroupIdRaw int64 + var createDirectGroupMemberProxyDisplayNameRaw string + var createDirectGroupMemberProxyExternalIdRaw string + var createDirectGroupMemberProxyMembershipSourceRaw string + var createDirectGroupMemberProxyPrincipalIdRaw int64 + var createDirectGroupMemberProxyPrincipalTypeRaw string - var createDirectGroupMemberProxyReq iamv2.CreateDirectGroupMemberProxyRequest - createDirectGroupMemberProxyReq.DirectGroupMember = iamv2.DirectGroupMember{} var createDirectGroupMemberProxyJson flags.JsonFlag cmd.Flags().Var(&createDirectGroupMemberProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -135,9 +142,10 @@ Create a direct group membership. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := createDirectGroupMemberProxyJson.Unmarshal(&createDirectGroupMemberProxyReq.DirectGroupMember) + diags := createDirectGroupMemberProxyJson.Unmarshal(&createDirectGroupMemberProxyReq) if diags.HasError() { return diags.Error() } @@ -148,24 +156,47 @@ Create a direct group membership. } } } - _, err = fmt.Sscan(args[0], &createDirectGroupMemberProxyReq.GroupId) + _, err = fmt.Sscan(args[0], &createDirectGroupMemberProxyGroupIdRaw) if err != nil { return fmt.Errorf("invalid GROUP_ID: %s", args[0]) } - if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createDirectGroupMemberProxyReq.DirectGroupMember.PrincipalId) + _, err = fmt.Sscan(args[1], &createDirectGroupMemberProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("display-name") || createDirectGroupMemberProxyDisplayNameRaw != "" { + createDirectGroupMemberProxyReq["display_name"] = createDirectGroupMemberProxyDisplayNameRaw + } + if cmd.Flags().Changed("external-id") || createDirectGroupMemberProxyExternalIdRaw != "" { + createDirectGroupMemberProxyReq["external_id"] = createDirectGroupMemberProxyExternalIdRaw + } + if cmd.Flags().Changed("group-id") || createDirectGroupMemberProxyGroupIdRaw != 0 { + createDirectGroupMemberProxyReq["group_id"] = createDirectGroupMemberProxyGroupIdRaw + } + if cmd.Flags().Changed("membership-source") || createDirectGroupMemberProxyMembershipSourceRaw != "" { + createDirectGroupMemberProxyReq["membership_source"] = createDirectGroupMemberProxyMembershipSourceRaw } + if cmd.Flags().Changed("principal-id") || createDirectGroupMemberProxyPrincipalIdRaw != 0 { + createDirectGroupMemberProxyReq["principal_id"] = createDirectGroupMemberProxyPrincipalIdRaw + } + if cmd.Flags().Changed("principal-type") || createDirectGroupMemberProxyPrincipalTypeRaw != "" { + createDirectGroupMemberProxyReq["principal_type"] = createDirectGroupMemberProxyPrincipalTypeRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/groups/%s/direct-members", fmt.Sprint(createDirectGroupMemberProxyGroupIdRaw)) - response, err := w.WorkspaceIamV2.CreateDirectGroupMemberProxy(ctx, createDirectGroupMemberProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createDirectGroupMemberProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -187,20 +218,24 @@ Create a direct group membership. // Functions can be added from the `init()` function in manually curated files in this directory. var createGroupProxyOverrides []func( *cobra.Command, - *iamv2.CreateGroupProxyRequest, + *map[string]any, ) func newCreateGroupProxy() *cobra.Command { cmd := &cobra.Command{} + var createGroupProxyReq map[string]any + createGroupProxyReq = map[string]any{} + var createGroupProxyAccountIdRaw string + var createGroupProxyExternalIdRaw string + var createGroupProxyGroupIdRaw string + var createGroupProxyGroupNameRaw string - var createGroupProxyReq iamv2.CreateGroupProxyRequest - createGroupProxyReq.Group = iamv2.Group{} var createGroupProxyJson flags.JsonFlag cmd.Flags().Var(&createGroupProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createGroupProxyReq.Group.ExternalId, "external-id", createGroupProxyReq.Group.ExternalId, `ExternalId of the group in the customer's IdP.`) - cmd.Flags().StringVar(&createGroupProxyReq.Group.GroupName, "group-name", createGroupProxyReq.Group.GroupName, `Display name of the group.`) + cmd.Flags().StringVar(&createGroupProxyExternalIdRaw, "external-id", createGroupProxyExternalIdRaw, `ExternalId of the group in the customer's IdP.`) + cmd.Flags().StringVar(&createGroupProxyGroupNameRaw, "group-name", createGroupProxyGroupNameRaw, `Display name of the group.`) cmd.Use = "create-group-proxy" cmd.Short = `*Beta* Create a group in the account.` @@ -231,9 +266,10 @@ Create a group in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := createGroupProxyJson.Unmarshal(&createGroupProxyReq.Group) + diags := createGroupProxyJson.Unmarshal(&createGroupProxyReq) if diags.HasError() { return diags.Error() } @@ -245,11 +281,30 @@ Create a group in the account. } } - response, err := w.WorkspaceIamV2.CreateGroupProxy(ctx, createGroupProxyReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || createGroupProxyAccountIdRaw != "" { + createGroupProxyReq["account_id"] = createGroupProxyAccountIdRaw + } + if cmd.Flags().Changed("external-id") || createGroupProxyExternalIdRaw != "" { + createGroupProxyReq["external_id"] = createGroupProxyExternalIdRaw + } + if cmd.Flags().Changed("group-id") || createGroupProxyGroupIdRaw != "" { + createGroupProxyReq["group_id"] = createGroupProxyGroupIdRaw + } + if cmd.Flags().Changed("group-name") || createGroupProxyGroupNameRaw != "" { + createGroupProxyReq["group_name"] = createGroupProxyGroupNameRaw + } + rawPath := "/api/2.0/identity/groups" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createGroupProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -271,19 +326,25 @@ Create a group in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var createServicePrincipalProxyOverrides []func( *cobra.Command, - *iamv2.CreateServicePrincipalProxyRequest, + *map[string]any, ) func newCreateServicePrincipalProxy() *cobra.Command { cmd := &cobra.Command{} + var createServicePrincipalProxyReq map[string]any + createServicePrincipalProxyReq = map[string]any{} + var createServicePrincipalProxyAccountIdRaw string + var createServicePrincipalProxyAccountSpStatusRaw string + var createServicePrincipalProxyApplicationIdRaw string + var createServicePrincipalProxyDisplayNameRaw string + var createServicePrincipalProxyExternalIdRaw string + var createServicePrincipalProxyServicePrincipalIdRaw string - var createServicePrincipalProxyReq iamv2.CreateServicePrincipalProxyRequest - createServicePrincipalProxyReq.ServicePrincipal = iamv2.ServicePrincipal{} var createServicePrincipalProxyJson flags.JsonFlag cmd.Flags().Var(&createServicePrincipalProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createServicePrincipalProxyReq.ServicePrincipal.ExternalId, "external-id", createServicePrincipalProxyReq.ServicePrincipal.ExternalId, `ExternalId of the service principal in the customer's IdP.`) + cmd.Flags().StringVar(&createServicePrincipalProxyExternalIdRaw, "external-id", createServicePrincipalProxyExternalIdRaw, `ExternalId of the service principal in the customer's IdP.`) cmd.Use = "create-service-principal-proxy DISPLAY_NAME ACCOUNT_SP_STATUS" cmd.Short = `*Beta* Create a service principal in the account.` @@ -326,9 +387,10 @@ Create a service principal in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := createServicePrincipalProxyJson.Unmarshal(&createServicePrincipalProxyReq.ServicePrincipal) + diags := createServicePrincipalProxyJson.Unmarshal(&createServicePrincipalProxyReq) if diags.HasError() { return diags.Error() } @@ -340,21 +402,42 @@ Create a service principal in the account. } } if !cmd.Flags().Changed("json") { - createServicePrincipalProxyReq.ServicePrincipal.DisplayName = args[0] + createServicePrincipalProxyDisplayNameRaw = args[0] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createServicePrincipalProxyReq.ServicePrincipal.AccountSpStatus) - if err != nil { - return fmt.Errorf("invalid ACCOUNT_SP_STATUS: %s", args[1]) - } + createServicePrincipalProxyAccountSpStatusRaw = args[1] + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || createServicePrincipalProxyAccountIdRaw != "" { + createServicePrincipalProxyReq["account_id"] = createServicePrincipalProxyAccountIdRaw + } + if cmd.Flags().Changed("account-sp-status") || createServicePrincipalProxyAccountSpStatusRaw != "" { + createServicePrincipalProxyReq["account_sp_status"] = createServicePrincipalProxyAccountSpStatusRaw + } + if cmd.Flags().Changed("application-id") || createServicePrincipalProxyApplicationIdRaw != "" { + createServicePrincipalProxyReq["application_id"] = createServicePrincipalProxyApplicationIdRaw + } + if cmd.Flags().Changed("display-name") || createServicePrincipalProxyDisplayNameRaw != "" { + createServicePrincipalProxyReq["display_name"] = createServicePrincipalProxyDisplayNameRaw } + if cmd.Flags().Changed("external-id") || createServicePrincipalProxyExternalIdRaw != "" { + createServicePrincipalProxyReq["external_id"] = createServicePrincipalProxyExternalIdRaw + } + if cmd.Flags().Changed("service-principal-id") || createServicePrincipalProxyServicePrincipalIdRaw != "" { + createServicePrincipalProxyReq["service_principal_id"] = createServicePrincipalProxyServicePrincipalIdRaw + } + rawPath := "/api/2.0/identity/service-principals" - response, err := w.WorkspaceIamV2.CreateServicePrincipalProxy(ctx, createServicePrincipalProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createServicePrincipalProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -376,19 +459,24 @@ Create a service principal in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var createUserProxyOverrides []func( *cobra.Command, - *iamv2.CreateUserProxyRequest, + *map[string]any, ) func newCreateUserProxy() *cobra.Command { cmd := &cobra.Command{} + var createUserProxyReq map[string]any + createUserProxyReq = map[string]any{} + var createUserProxyAccountIdRaw string + var createUserProxyAccountUserStatusRaw string + var createUserProxyExternalIdRaw string + var createUserProxyUserIdRaw string + var createUserProxyUsernameRaw string - var createUserProxyReq iamv2.CreateUserProxyRequest - createUserProxyReq.User = iamv2.User{} var createUserProxyJson flags.JsonFlag cmd.Flags().Var(&createUserProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&createUserProxyReq.User.ExternalId, "external-id", createUserProxyReq.User.ExternalId, `ExternalId of the user in the customer's IdP.`) + cmd.Flags().StringVar(&createUserProxyExternalIdRaw, "external-id", createUserProxyExternalIdRaw, `ExternalId of the user in the customer's IdP.`) cmd.Use = "create-user-proxy USERNAME FULL_NAME ACCOUNT_USER_STATUS" cmd.Short = `*Beta* Create a user in the account.` @@ -432,9 +520,10 @@ Create a user in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := createUserProxyJson.Unmarshal(&createUserProxyReq.User) + diags := createUserProxyJson.Unmarshal(&createUserProxyReq) if diags.HasError() { return diags.Error() } @@ -446,28 +535,42 @@ Create a user in the account. } } if !cmd.Flags().Changed("json") { - createUserProxyReq.User.Username = args[0] + createUserProxyUsernameRaw = args[0] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[1], &createUserProxyReq.User.FullName) - if err != nil { - return fmt.Errorf("invalid FULL_NAME: %s", args[1]) - } - + createUserProxyReq["full_name"] = args[1] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &createUserProxyReq.User.AccountUserStatus) - if err != nil { - return fmt.Errorf("invalid ACCOUNT_USER_STATUS: %s", args[2]) - } + createUserProxyAccountUserStatusRaw = args[2] + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || createUserProxyAccountIdRaw != "" { + createUserProxyReq["account_id"] = createUserProxyAccountIdRaw + } + if cmd.Flags().Changed("account-user-status") || createUserProxyAccountUserStatusRaw != "" { + createUserProxyReq["account_user_status"] = createUserProxyAccountUserStatusRaw + } + if cmd.Flags().Changed("external-id") || createUserProxyExternalIdRaw != "" { + createUserProxyReq["external_id"] = createUserProxyExternalIdRaw + } + if cmd.Flags().Changed("user-id") || createUserProxyUserIdRaw != "" { + createUserProxyReq["user_id"] = createUserProxyUserIdRaw } + if cmd.Flags().Changed("username") || createUserProxyUsernameRaw != "" { + createUserProxyReq["username"] = createUserProxyUsernameRaw + } + rawPath := "/api/2.0/identity/users" - response, err := w.WorkspaceIamV2.CreateUserProxy(ctx, createUserProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createUserProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -489,14 +592,18 @@ Create a user in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var createWorkspaceAssignmentDetailProxyOverrides []func( *cobra.Command, - *iamv2.CreateWorkspaceAssignmentDetailProxyRequest, + *map[string]any, ) func newCreateWorkspaceAssignmentDetailProxy() *cobra.Command { cmd := &cobra.Command{} + var createWorkspaceAssignmentDetailProxyReq map[string]any + createWorkspaceAssignmentDetailProxyReq = map[string]any{} + var createWorkspaceAssignmentDetailProxyAccountIdRaw string + var createWorkspaceAssignmentDetailProxyPrincipalIdRaw int64 + var createWorkspaceAssignmentDetailProxyPrincipalTypeRaw string + var createWorkspaceAssignmentDetailProxyWorkspaceIdRaw int64 - var createWorkspaceAssignmentDetailProxyReq iamv2.CreateWorkspaceAssignmentDetailProxyRequest - createWorkspaceAssignmentDetailProxyReq.WorkspaceAssignmentDetail = iamv2.WorkspaceAssignmentDetail{} var createWorkspaceAssignmentDetailProxyJson flags.JsonFlag cmd.Flags().Var(&createWorkspaceAssignmentDetailProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -537,9 +644,10 @@ func newCreateWorkspaceAssignmentDetailProxy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := createWorkspaceAssignmentDetailProxyJson.Unmarshal(&createWorkspaceAssignmentDetailProxyReq.WorkspaceAssignmentDetail) + diags := createWorkspaceAssignmentDetailProxyJson.Unmarshal(&createWorkspaceAssignmentDetailProxyReq) if diags.HasError() { return diags.Error() } @@ -551,18 +659,36 @@ func newCreateWorkspaceAssignmentDetailProxy() *cobra.Command { } } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[0], &createWorkspaceAssignmentDetailProxyReq.WorkspaceAssignmentDetail.PrincipalId) + _, err = fmt.Sscan(args[0], &createWorkspaceAssignmentDetailProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || createWorkspaceAssignmentDetailProxyAccountIdRaw != "" { + createWorkspaceAssignmentDetailProxyReq["account_id"] = createWorkspaceAssignmentDetailProxyAccountIdRaw } + if cmd.Flags().Changed("principal-id") || createWorkspaceAssignmentDetailProxyPrincipalIdRaw != 0 { + createWorkspaceAssignmentDetailProxyReq["principal_id"] = createWorkspaceAssignmentDetailProxyPrincipalIdRaw + } + if cmd.Flags().Changed("principal-type") || createWorkspaceAssignmentDetailProxyPrincipalTypeRaw != "" { + createWorkspaceAssignmentDetailProxyReq["principal_type"] = createWorkspaceAssignmentDetailProxyPrincipalTypeRaw + } + if cmd.Flags().Changed("workspace-id") || createWorkspaceAssignmentDetailProxyWorkspaceIdRaw != 0 { + createWorkspaceAssignmentDetailProxyReq["workspace_id"] = createWorkspaceAssignmentDetailProxyWorkspaceIdRaw + } + rawPath := "/api/2.0/identity/workspace-assignment-details" - response, err := w.WorkspaceIamV2.CreateWorkspaceAssignmentDetailProxy(ctx, createWorkspaceAssignmentDetailProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createWorkspaceAssignmentDetailProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -584,14 +710,18 @@ func newCreateWorkspaceAssignmentDetailProxy() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createWorkspaceAssignmentProxyOverrides []func( *cobra.Command, - *iamv2.CreateWorkspaceAssignmentProxyRequest, + *map[string]any, ) func newCreateWorkspaceAssignmentProxy() *cobra.Command { cmd := &cobra.Command{} + var createWorkspaceAssignmentProxyReq map[string]any + createWorkspaceAssignmentProxyReq = map[string]any{} + var createWorkspaceAssignmentProxyAccountIdRaw string + var createWorkspaceAssignmentProxyPrincipalIdRaw int64 + var createWorkspaceAssignmentProxyPrincipalTypeRaw string + var createWorkspaceAssignmentProxyWorkspaceIdRaw int64 - var createWorkspaceAssignmentProxyReq iamv2.CreateWorkspaceAssignmentProxyRequest - createWorkspaceAssignmentProxyReq.WorkspaceAssignment = iamv2.WorkspaceAssignment{} var createWorkspaceAssignmentProxyJson flags.JsonFlag cmd.Flags().Var(&createWorkspaceAssignmentProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -634,9 +764,10 @@ Create a workspace assignment for a workspace. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := createWorkspaceAssignmentProxyJson.Unmarshal(&createWorkspaceAssignmentProxyReq.WorkspaceAssignment) + diags := createWorkspaceAssignmentProxyJson.Unmarshal(&createWorkspaceAssignmentProxyReq) if diags.HasError() { return diags.Error() } @@ -648,18 +779,36 @@ Create a workspace assignment for a workspace. } } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[0], &createWorkspaceAssignmentProxyReq.WorkspaceAssignment.PrincipalId) + _, err = fmt.Sscan(args[0], &createWorkspaceAssignmentProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || createWorkspaceAssignmentProxyAccountIdRaw != "" { + createWorkspaceAssignmentProxyReq["account_id"] = createWorkspaceAssignmentProxyAccountIdRaw + } + if cmd.Flags().Changed("principal-id") || createWorkspaceAssignmentProxyPrincipalIdRaw != 0 { + createWorkspaceAssignmentProxyReq["principal_id"] = createWorkspaceAssignmentProxyPrincipalIdRaw + } + if cmd.Flags().Changed("principal-type") || createWorkspaceAssignmentProxyPrincipalTypeRaw != "" { + createWorkspaceAssignmentProxyReq["principal_type"] = createWorkspaceAssignmentProxyPrincipalTypeRaw } + if cmd.Flags().Changed("workspace-id") || createWorkspaceAssignmentProxyWorkspaceIdRaw != 0 { + createWorkspaceAssignmentProxyReq["workspace_id"] = createWorkspaceAssignmentProxyWorkspaceIdRaw + } + rawPath := "/api/2.0/identity/workspace-assignments" - response, err := w.WorkspaceIamV2.CreateWorkspaceAssignmentProxy(ctx, createWorkspaceAssignmentProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, createWorkspaceAssignmentProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -681,13 +830,15 @@ Create a workspace assignment for a workspace. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteDirectGroupMemberProxyOverrides []func( *cobra.Command, - *iamv2.DeleteDirectGroupMemberProxyRequest, + *map[string]any, ) func newDeleteDirectGroupMemberProxy() *cobra.Command { cmd := &cobra.Command{} - - var deleteDirectGroupMemberProxyReq iamv2.DeleteDirectGroupMemberProxyRequest + var deleteDirectGroupMemberProxyReq map[string]any + deleteDirectGroupMemberProxyReq = map[string]any{} + var deleteDirectGroupMemberProxyGroupIdRaw int64 + var deleteDirectGroupMemberProxyPrincipalIdRaw int64 cmd.Use = "delete-direct-group-member-proxy GROUP_ID PRINCIPAL_ID" cmd.Short = `*Beta* Delete a direct group membership.` @@ -714,18 +865,26 @@ Delete a direct group membership. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - _, err = fmt.Sscan(args[0], &deleteDirectGroupMemberProxyReq.GroupId) + _, err = fmt.Sscan(args[0], &deleteDirectGroupMemberProxyGroupIdRaw) if err != nil { return fmt.Errorf("invalid GROUP_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &deleteDirectGroupMemberProxyReq.PrincipalId) + _, err = fmt.Sscan(args[1], &deleteDirectGroupMemberProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } - err = w.WorkspaceIamV2.DeleteDirectGroupMemberProxy(ctx, deleteDirectGroupMemberProxyReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/groups/%s/direct-members/%s", fmt.Sprint(deleteDirectGroupMemberProxyGroupIdRaw), fmt.Sprint(deleteDirectGroupMemberProxyPrincipalIdRaw)) + + maps.Copy(rawQuery, deleteDirectGroupMemberProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -750,13 +909,14 @@ Delete a direct group membership. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteGroupProxyOverrides []func( *cobra.Command, - *iamv2.DeleteGroupProxyRequest, + *map[string]any, ) func newDeleteGroupProxy() *cobra.Command { cmd := &cobra.Command{} - - var deleteGroupProxyReq iamv2.DeleteGroupProxyRequest + var deleteGroupProxyReq map[string]any + deleteGroupProxyReq = map[string]any{} + var deleteGroupProxyGroupIdRaw string cmd.Use = "delete-group-proxy GROUP_ID" cmd.Short = `*Beta* Delete a group in the account.` @@ -783,10 +943,19 @@ Delete a group in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + deleteGroupProxyGroupIdRaw = args[0] - deleteGroupProxyReq.GroupId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/groups/%s", fmt.Sprint(deleteGroupProxyGroupIdRaw)) - err = w.WorkspaceIamV2.DeleteGroupProxy(ctx, deleteGroupProxyReq) + maps.Copy(rawQuery, deleteGroupProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -811,13 +980,14 @@ Delete a group in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteServicePrincipalProxyOverrides []func( *cobra.Command, - *iamv2.DeleteServicePrincipalProxyRequest, + *map[string]any, ) func newDeleteServicePrincipalProxy() *cobra.Command { cmd := &cobra.Command{} - - var deleteServicePrincipalProxyReq iamv2.DeleteServicePrincipalProxyRequest + var deleteServicePrincipalProxyReq map[string]any + deleteServicePrincipalProxyReq = map[string]any{} + var deleteServicePrincipalProxyServicePrincipalIdRaw string cmd.Use = "delete-service-principal-proxy SERVICE_PRINCIPAL_ID" cmd.Short = `*Beta* Delete a service principal in the account.` @@ -844,10 +1014,19 @@ Delete a service principal in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + deleteServicePrincipalProxyServicePrincipalIdRaw = args[0] - deleteServicePrincipalProxyReq.ServicePrincipalId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/service-principals/%s", fmt.Sprint(deleteServicePrincipalProxyServicePrincipalIdRaw)) - err = w.WorkspaceIamV2.DeleteServicePrincipalProxy(ctx, deleteServicePrincipalProxyReq) + maps.Copy(rawQuery, deleteServicePrincipalProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -872,13 +1051,14 @@ Delete a service principal in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteUserProxyOverrides []func( *cobra.Command, - *iamv2.DeleteUserProxyRequest, + *map[string]any, ) func newDeleteUserProxy() *cobra.Command { cmd := &cobra.Command{} - - var deleteUserProxyReq iamv2.DeleteUserProxyRequest + var deleteUserProxyReq map[string]any + deleteUserProxyReq = map[string]any{} + var deleteUserProxyUserIdRaw string cmd.Use = "delete-user-proxy USER_ID" cmd.Short = `*Beta* Delete a user in the account.` @@ -905,10 +1085,19 @@ Delete a user in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + deleteUserProxyUserIdRaw = args[0] - deleteUserProxyReq.UserId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/users/%s", fmt.Sprint(deleteUserProxyUserIdRaw)) - err = w.WorkspaceIamV2.DeleteUserProxy(ctx, deleteUserProxyReq) + maps.Copy(rawQuery, deleteUserProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -933,13 +1122,14 @@ Delete a user in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var deleteWorkspaceAssignmentDetailProxyOverrides []func( *cobra.Command, - *iamv2.DeleteWorkspaceAssignmentDetailProxyRequest, + *map[string]any, ) func newDeleteWorkspaceAssignmentDetailProxy() *cobra.Command { cmd := &cobra.Command{} - - var deleteWorkspaceAssignmentDetailProxyReq iamv2.DeleteWorkspaceAssignmentDetailProxyRequest + var deleteWorkspaceAssignmentDetailProxyReq map[string]any + deleteWorkspaceAssignmentDetailProxyReq = map[string]any{} + var deleteWorkspaceAssignmentDetailProxyPrincipalIdRaw int64 cmd.Use = "delete-workspace-assignment-detail-proxy PRINCIPAL_ID" cmd.Short = `Delete a workspace assignment detail for a workspace.` @@ -971,13 +1161,22 @@ func newDeleteWorkspaceAssignmentDetailProxy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - _, err = fmt.Sscan(args[0], &deleteWorkspaceAssignmentDetailProxyReq.PrincipalId) + _, err = fmt.Sscan(args[0], &deleteWorkspaceAssignmentDetailProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } - err = w.WorkspaceIamV2.DeleteWorkspaceAssignmentDetailProxy(ctx, deleteWorkspaceAssignmentDetailProxyReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/workspace-assignment-details/%s", fmt.Sprint(deleteWorkspaceAssignmentDetailProxyPrincipalIdRaw)) + + maps.Copy(rawQuery, deleteWorkspaceAssignmentDetailProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -1002,13 +1201,14 @@ func newDeleteWorkspaceAssignmentDetailProxy() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteWorkspaceAssignmentProxyOverrides []func( *cobra.Command, - *iamv2.DeleteWorkspaceAssignmentProxyRequest, + *map[string]any, ) func newDeleteWorkspaceAssignmentProxy() *cobra.Command { cmd := &cobra.Command{} - - var deleteWorkspaceAssignmentProxyReq iamv2.DeleteWorkspaceAssignmentProxyRequest + var deleteWorkspaceAssignmentProxyReq map[string]any + deleteWorkspaceAssignmentProxyReq = map[string]any{} + var deleteWorkspaceAssignmentProxyPrincipalIdRaw int64 cmd.Use = "delete-workspace-assignment-proxy PRINCIPAL_ID" cmd.Short = `*Beta* Delete a workspace assignment for a workspace.` @@ -1038,13 +1238,22 @@ Delete a workspace assignment for a workspace. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - _, err = fmt.Sscan(args[0], &deleteWorkspaceAssignmentProxyReq.PrincipalId) + _, err = fmt.Sscan(args[0], &deleteWorkspaceAssignmentProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } - err = w.WorkspaceIamV2.DeleteWorkspaceAssignmentProxy(ctx, deleteWorkspaceAssignmentProxyReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/workspace-assignments/%s", fmt.Sprint(deleteWorkspaceAssignmentProxyPrincipalIdRaw)) + + maps.Copy(rawQuery, deleteWorkspaceAssignmentProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + err = api.Do(ctx, "DELETE", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, nil) if err != nil { return err } @@ -1069,13 +1278,15 @@ Delete a workspace assignment for a workspace. // Functions can be added from the `init()` function in manually curated files in this directory. var getDirectGroupMemberProxyOverrides []func( *cobra.Command, - *iamv2.GetDirectGroupMemberProxyRequest, + *map[string]any, ) func newGetDirectGroupMemberProxy() *cobra.Command { cmd := &cobra.Command{} - - var getDirectGroupMemberProxyReq iamv2.GetDirectGroupMemberProxyRequest + var getDirectGroupMemberProxyReq map[string]any + getDirectGroupMemberProxyReq = map[string]any{} + var getDirectGroupMemberProxyGroupIdRaw int64 + var getDirectGroupMemberProxyPrincipalIdRaw int64 cmd.Use = "get-direct-group-member-proxy GROUP_ID PRINCIPAL_ID" cmd.Short = `*Beta* Get a direct group member.` @@ -1103,22 +1314,30 @@ Get a direct group member. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - _, err = fmt.Sscan(args[0], &getDirectGroupMemberProxyReq.GroupId) + _, err = fmt.Sscan(args[0], &getDirectGroupMemberProxyGroupIdRaw) if err != nil { return fmt.Errorf("invalid GROUP_ID: %s", args[0]) } - - _, err = fmt.Sscan(args[1], &getDirectGroupMemberProxyReq.PrincipalId) + _, err = fmt.Sscan(args[1], &getDirectGroupMemberProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } - response, err := w.WorkspaceIamV2.GetDirectGroupMemberProxy(ctx, getDirectGroupMemberProxyReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/groups/%s/direct-members/%s", fmt.Sprint(getDirectGroupMemberProxyGroupIdRaw), fmt.Sprint(getDirectGroupMemberProxyPrincipalIdRaw)) + + maps.Copy(rawQuery, getDirectGroupMemberProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1140,13 +1359,14 @@ Get a direct group member. // Functions can be added from the `init()` function in manually curated files in this directory. var getExternalGroupProxyOverrides []func( *cobra.Command, - *iamv2.GetExternalGroupProxyRequest, + *map[string]any, ) func newGetExternalGroupProxy() *cobra.Command { cmd := &cobra.Command{} - - var getExternalGroupProxyReq iamv2.GetExternalGroupProxyRequest + var getExternalGroupProxyReq map[string]any + getExternalGroupProxyReq = map[string]any{} + var getExternalGroupProxyNameRaw string cmd.Use = "get-external-group-proxy NAME" cmd.Short = `*Beta* Get an external group in the account.` @@ -1176,14 +1396,23 @@ Get an external group in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getExternalGroupProxyReq.Name = args[0] + getExternalGroupProxyNameRaw = args[0] - response, err := w.WorkspaceIamV2.GetExternalGroupProxy(ctx, getExternalGroupProxyReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/%s", fmt.Sprint(getExternalGroupProxyNameRaw)) + + maps.Copy(rawQuery, getExternalGroupProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1205,13 +1434,14 @@ Get an external group in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var getExternalServicePrincipalProxyOverrides []func( *cobra.Command, - *iamv2.GetExternalServicePrincipalProxyRequest, + *map[string]any, ) func newGetExternalServicePrincipalProxy() *cobra.Command { cmd := &cobra.Command{} - - var getExternalServicePrincipalProxyReq iamv2.GetExternalServicePrincipalProxyRequest + var getExternalServicePrincipalProxyReq map[string]any + getExternalServicePrincipalProxyReq = map[string]any{} + var getExternalServicePrincipalProxyNameRaw string cmd.Use = "get-external-service-principal-proxy NAME" cmd.Short = `*Beta* Get an external service principal in the account.` @@ -1242,14 +1472,23 @@ Get an external service principal in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getExternalServicePrincipalProxyNameRaw = args[0] - getExternalServicePrincipalProxyReq.Name = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/%s", fmt.Sprint(getExternalServicePrincipalProxyNameRaw)) - response, err := w.WorkspaceIamV2.GetExternalServicePrincipalProxy(ctx, getExternalServicePrincipalProxyReq) + maps.Copy(rawQuery, getExternalServicePrincipalProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1271,13 +1510,14 @@ Get an external service principal in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var getExternalUserProxyOverrides []func( *cobra.Command, - *iamv2.GetExternalUserProxyRequest, + *map[string]any, ) func newGetExternalUserProxy() *cobra.Command { cmd := &cobra.Command{} - - var getExternalUserProxyReq iamv2.GetExternalUserProxyRequest + var getExternalUserProxyReq map[string]any + getExternalUserProxyReq = map[string]any{} + var getExternalUserProxyNameRaw string cmd.Use = "get-external-user-proxy NAME" cmd.Short = `*Beta* Get an external user in the account.` @@ -1307,14 +1547,23 @@ Get an external user in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getExternalUserProxyReq.Name = args[0] + getExternalUserProxyNameRaw = args[0] - response, err := w.WorkspaceIamV2.GetExternalUserProxy(ctx, getExternalUserProxyReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/%s", fmt.Sprint(getExternalUserProxyNameRaw)) + + maps.Copy(rawQuery, getExternalUserProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1336,13 +1585,14 @@ Get an external user in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var getGroupProxyOverrides []func( *cobra.Command, - *iamv2.GetGroupProxyRequest, + *map[string]any, ) func newGetGroupProxy() *cobra.Command { cmd := &cobra.Command{} - - var getGroupProxyReq iamv2.GetGroupProxyRequest + var getGroupProxyReq map[string]any + getGroupProxyReq = map[string]any{} + var getGroupProxyGroupIdRaw string cmd.Use = "get-group-proxy GROUP_ID" cmd.Short = `*Beta* Get a group in the account.` @@ -1369,14 +1619,23 @@ Get a group in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getGroupProxyGroupIdRaw = args[0] - getGroupProxyReq.GroupId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/groups/%s", fmt.Sprint(getGroupProxyGroupIdRaw)) - response, err := w.WorkspaceIamV2.GetGroupProxy(ctx, getGroupProxyReq) + maps.Copy(rawQuery, getGroupProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1398,13 +1657,14 @@ Get a group in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var getServicePrincipalProxyOverrides []func( *cobra.Command, - *iamv2.GetServicePrincipalProxyRequest, + *map[string]any, ) func newGetServicePrincipalProxy() *cobra.Command { cmd := &cobra.Command{} - - var getServicePrincipalProxyReq iamv2.GetServicePrincipalProxyRequest + var getServicePrincipalProxyReq map[string]any + getServicePrincipalProxyReq = map[string]any{} + var getServicePrincipalProxyServicePrincipalIdRaw string cmd.Use = "get-service-principal-proxy SERVICE_PRINCIPAL_ID" cmd.Short = `*Beta* Get a service principal in the account.` @@ -1431,14 +1691,23 @@ Get a service principal in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getServicePrincipalProxyServicePrincipalIdRaw = args[0] - getServicePrincipalProxyReq.ServicePrincipalId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/service-principals/%s", fmt.Sprint(getServicePrincipalProxyServicePrincipalIdRaw)) - response, err := w.WorkspaceIamV2.GetServicePrincipalProxy(ctx, getServicePrincipalProxyReq) + maps.Copy(rawQuery, getServicePrincipalProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1460,13 +1729,14 @@ Get a service principal in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var getUserProxyOverrides []func( *cobra.Command, - *iamv2.GetUserProxyRequest, + *map[string]any, ) func newGetUserProxy() *cobra.Command { cmd := &cobra.Command{} - - var getUserProxyReq iamv2.GetUserProxyRequest + var getUserProxyReq map[string]any + getUserProxyReq = map[string]any{} + var getUserProxyUserIdRaw string cmd.Use = "get-user-proxy USER_ID" cmd.Short = `*Beta* Get a user in the account.` @@ -1493,14 +1763,23 @@ Get a user in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w + + getUserProxyUserIdRaw = args[0] - getUserProxyReq.UserId = args[0] + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/users/%s", fmt.Sprint(getUserProxyUserIdRaw)) - response, err := w.WorkspaceIamV2.GetUserProxy(ctx, getUserProxyReq) + maps.Copy(rawQuery, getUserProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1522,15 +1801,17 @@ Get a user in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var getWorkspaceAccessDetailLocalOverrides []func( *cobra.Command, - *iamv2.GetWorkspaceAccessDetailLocalRequest, + *map[string]any, ) func newGetWorkspaceAccessDetailLocal() *cobra.Command { cmd := &cobra.Command{} + var getWorkspaceAccessDetailLocalReq map[string]any + getWorkspaceAccessDetailLocalReq = map[string]any{} + var getWorkspaceAccessDetailLocalPrincipalIdRaw int64 + var getWorkspaceAccessDetailLocalViewRaw string - var getWorkspaceAccessDetailLocalReq iamv2.GetWorkspaceAccessDetailLocalRequest - - cmd.Flags().Var(&getWorkspaceAccessDetailLocalReq.View, "view", `Controls what fields are returned. Supported values: [BASIC, FULL]`) + flags.EnumVar(cmd.Flags(), &getWorkspaceAccessDetailLocalViewRaw, "view", `Controls what fields are returned. Supported values: [BASIC, FULL]`, "WorkspaceAccessDetailView", "BASIC", "FULL") cmd.Use = "get-workspace-access-detail-local PRINCIPAL_ID" cmd.Short = `*Beta* Get workspace access details for a principal.` @@ -1562,17 +1843,29 @@ Get workspace access details for a principal. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - _, err = fmt.Sscan(args[0], &getWorkspaceAccessDetailLocalReq.PrincipalId) + _, err = fmt.Sscan(args[0], &getWorkspaceAccessDetailLocalPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } - response, err := w.WorkspaceIamV2.GetWorkspaceAccessDetailLocal(ctx, getWorkspaceAccessDetailLocalReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("view") || getWorkspaceAccessDetailLocalViewRaw != "" { + rawQuery["view"] = getWorkspaceAccessDetailLocalViewRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/workspace-access-details/%s", fmt.Sprint(getWorkspaceAccessDetailLocalPrincipalIdRaw)) + + maps.Copy(rawQuery, getWorkspaceAccessDetailLocalReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1594,13 +1887,14 @@ Get workspace access details for a principal. // Functions can be added from the `init()` function in manually curated files in this directory. var getWorkspaceAssignmentDetailProxyOverrides []func( *cobra.Command, - *iamv2.GetWorkspaceAssignmentDetailProxyRequest, + *map[string]any, ) func newGetWorkspaceAssignmentDetailProxy() *cobra.Command { cmd := &cobra.Command{} - - var getWorkspaceAssignmentDetailProxyReq iamv2.GetWorkspaceAssignmentDetailProxyRequest + var getWorkspaceAssignmentDetailProxyReq map[string]any + getWorkspaceAssignmentDetailProxyReq = map[string]any{} + var getWorkspaceAssignmentDetailProxyPrincipalIdRaw int64 cmd.Use = "get-workspace-assignment-detail-proxy PRINCIPAL_ID" cmd.Short = `Get workspace assignment details for a principal.` @@ -1628,17 +1922,26 @@ func newGetWorkspaceAssignmentDetailProxy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - _, err = fmt.Sscan(args[0], &getWorkspaceAssignmentDetailProxyReq.PrincipalId) + _, err = fmt.Sscan(args[0], &getWorkspaceAssignmentDetailProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } - response, err := w.WorkspaceIamV2.GetWorkspaceAssignmentDetailProxy(ctx, getWorkspaceAssignmentDetailProxyReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/workspace-assignment-details/%s", fmt.Sprint(getWorkspaceAssignmentDetailProxyPrincipalIdRaw)) + + maps.Copy(rawQuery, getWorkspaceAssignmentDetailProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1660,13 +1963,14 @@ func newGetWorkspaceAssignmentDetailProxy() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getWorkspaceAssignmentProxyOverrides []func( *cobra.Command, - *iamv2.GetWorkspaceAssignmentProxyRequest, + *map[string]any, ) func newGetWorkspaceAssignmentProxy() *cobra.Command { cmd := &cobra.Command{} - - var getWorkspaceAssignmentProxyReq iamv2.GetWorkspaceAssignmentProxyRequest + var getWorkspaceAssignmentProxyReq map[string]any + getWorkspaceAssignmentProxyReq = map[string]any{} + var getWorkspaceAssignmentProxyPrincipalIdRaw int64 cmd.Use = "get-workspace-assignment-proxy PRINCIPAL_ID" cmd.Short = `*Beta* Get a workspace assignment for a principal.` @@ -1693,17 +1997,26 @@ Get a workspace assignment for a principal. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - _, err = fmt.Sscan(args[0], &getWorkspaceAssignmentProxyReq.PrincipalId) + _, err = fmt.Sscan(args[0], &getWorkspaceAssignmentProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } - response, err := w.WorkspaceIamV2.GetWorkspaceAssignmentProxy(ctx, getWorkspaceAssignmentProxyReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/workspace-assignments/%s", fmt.Sprint(getWorkspaceAssignmentProxyPrincipalIdRaw)) + + maps.Copy(rawQuery, getWorkspaceAssignmentProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1725,13 +2038,14 @@ Get a workspace assignment for a principal. // Functions can be added from the `init()` function in manually curated files in this directory. var getWorkspaceIdentityDetailOverrides []func( *cobra.Command, - *iamv2.GetWorkspaceIdentityDetailRequest, + *map[string]any, ) func newGetWorkspaceIdentityDetail() *cobra.Command { cmd := &cobra.Command{} - - var getWorkspaceIdentityDetailReq iamv2.GetWorkspaceIdentityDetailRequest + var getWorkspaceIdentityDetailReq map[string]any + getWorkspaceIdentityDetailReq = map[string]any{} + var getWorkspaceIdentityDetailPrincipalIdRaw int64 cmd.Use = "get-workspace-identity-detail PRINCIPAL_ID" cmd.Short = `*Beta* Get workspace identity details for a principal.` @@ -1758,17 +2072,26 @@ Get workspace identity details for a principal. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - _, err = fmt.Sscan(args[0], &getWorkspaceIdentityDetailReq.PrincipalId) + _, err = fmt.Sscan(args[0], &getWorkspaceIdentityDetailPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } - response, err := w.WorkspaceIamV2.GetWorkspaceIdentityDetail(ctx, getWorkspaceIdentityDetailReq) + rawQuery := map[string]any{} + rawPath := fmt.Sprintf("/api/2.0/identity/workspace-identity-details/%s", fmt.Sprint(getWorkspaceIdentityDetailPrincipalIdRaw)) + + maps.Copy(rawQuery, getWorkspaceIdentityDetailReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -1790,25 +2113,29 @@ Get workspace identity details for a principal. // Functions can be added from the `init()` function in manually curated files in this directory. var listDirectGroupMembersProxyOverrides []func( *cobra.Command, - *iamv2.ListDirectGroupMembersProxyRequest, + *map[string]any, ) func newListDirectGroupMembersProxy() *cobra.Command { cmd := &cobra.Command{} + var listDirectGroupMembersProxyReq map[string]any + listDirectGroupMembersProxyReq = map[string]any{} + var listDirectGroupMembersProxyGroupIdRaw int64 + var listDirectGroupMembersProxyPageSizeRaw int + var listDirectGroupMembersProxyPageTokenRaw string - var listDirectGroupMembersProxyReq iamv2.ListDirectGroupMembersProxyRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listDirectGroupMembersProxyLimit int - cmd.Flags().IntVar(&listDirectGroupMembersProxyReq.PageSize, "page-size", listDirectGroupMembersProxyReq.PageSize, `The maximum number of members to return.`) + cmd.Flags().IntVar(&listDirectGroupMembersProxyPageSizeRaw, "page-size", listDirectGroupMembersProxyPageSizeRaw, `The maximum number of members to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listDirectGroupMembersProxyLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listDirectGroupMembersProxyReq.PageToken, "page-token", listDirectGroupMembersProxyReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listDirectGroupMembersProxyPageTokenRaw, "page-token", listDirectGroupMembersProxyPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-direct-group-members-proxy GROUP_ID" @@ -1837,21 +2164,36 @@ List direct group members. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - _, err = fmt.Sscan(args[0], &listDirectGroupMembersProxyReq.GroupId) + _, err = fmt.Sscan(args[0], &listDirectGroupMembersProxyGroupIdRaw) if err != nil { return fmt.Errorf("invalid GROUP_ID: %s", args[0]) } - response := w.WorkspaceIamV2.ListDirectGroupMembersProxy(ctx, listDirectGroupMembersProxyReq) - if listDirectGroupMembersProxyLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listDirectGroupMembersProxyLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("page-size") || listDirectGroupMembersProxyPageSizeRaw != 0 { + rawQuery["page_size"] = listDirectGroupMembersProxyPageSizeRaw } - if listDirectGroupMembersProxyLimit > 0 { - ctx = cmdio.WithLimit(ctx, listDirectGroupMembersProxyLimit) + if cmd.Flags().Changed("page-token") || listDirectGroupMembersProxyPageTokenRaw != "" { + rawQuery["page_token"] = listDirectGroupMembersProxyPageTokenRaw } + rawPath := fmt.Sprintf("/api/2.0/identity/groups/%s/direct-members", fmt.Sprint(listDirectGroupMembersProxyGroupIdRaw)) - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listDirectGroupMembersProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) + if err != nil { + return err + } + if listDirectGroupMembersProxyLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listDirectGroupMembersProxyLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -1872,26 +2214,30 @@ List direct group members. // Functions can be added from the `init()` function in manually curated files in this directory. var listGroupsProxyOverrides []func( *cobra.Command, - *iamv2.ListGroupsProxyRequest, + *map[string]any, ) func newListGroupsProxy() *cobra.Command { cmd := &cobra.Command{} + var listGroupsProxyReq map[string]any + listGroupsProxyReq = map[string]any{} + var listGroupsProxyFilterRaw string + var listGroupsProxyPageSizeRaw int + var listGroupsProxyPageTokenRaw string - var listGroupsProxyReq iamv2.ListGroupsProxyRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listGroupsProxyLimit int - cmd.Flags().StringVar(&listGroupsProxyReq.Filter, "filter", listGroupsProxyReq.Filter, `Optional.`) - cmd.Flags().IntVar(&listGroupsProxyReq.PageSize, "page-size", listGroupsProxyReq.PageSize, `The maximum number of groups to return.`) + cmd.Flags().StringVar(&listGroupsProxyFilterRaw, "filter", listGroupsProxyFilterRaw, `Optional.`) + cmd.Flags().IntVar(&listGroupsProxyPageSizeRaw, "page-size", listGroupsProxyPageSizeRaw, `The maximum number of groups to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listGroupsProxyLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listGroupsProxyReq.PageToken, "page-token", listGroupsProxyReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listGroupsProxyPageTokenRaw, "page-token", listGroupsProxyPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-groups-proxy" @@ -1916,16 +2262,34 @@ List groups in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.WorkspaceIamV2.ListGroupsProxy(ctx, listGroupsProxyReq) - if listGroupsProxyLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listGroupsProxyLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("filter") || listGroupsProxyFilterRaw != "" { + rawQuery["filter"] = listGroupsProxyFilterRaw } - if listGroupsProxyLimit > 0 { - ctx = cmdio.WithLimit(ctx, listGroupsProxyLimit) + if cmd.Flags().Changed("page-size") || listGroupsProxyPageSizeRaw != 0 { + rawQuery["page_size"] = listGroupsProxyPageSizeRaw } + if cmd.Flags().Changed("page-token") || listGroupsProxyPageTokenRaw != "" { + rawQuery["page_token"] = listGroupsProxyPageTokenRaw + } + rawPath := "/api/2.0/identity/groups" - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listGroupsProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) + if err != nil { + return err + } + if listGroupsProxyLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listGroupsProxyLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -1946,26 +2310,30 @@ List groups in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var listServicePrincipalsProxyOverrides []func( *cobra.Command, - *iamv2.ListServicePrincipalsProxyRequest, + *map[string]any, ) func newListServicePrincipalsProxy() *cobra.Command { cmd := &cobra.Command{} + var listServicePrincipalsProxyReq map[string]any + listServicePrincipalsProxyReq = map[string]any{} + var listServicePrincipalsProxyFilterRaw string + var listServicePrincipalsProxyPageSizeRaw int + var listServicePrincipalsProxyPageTokenRaw string - var listServicePrincipalsProxyReq iamv2.ListServicePrincipalsProxyRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listServicePrincipalsProxyLimit int - cmd.Flags().StringVar(&listServicePrincipalsProxyReq.Filter, "filter", listServicePrincipalsProxyReq.Filter, `Optional.`) - cmd.Flags().IntVar(&listServicePrincipalsProxyReq.PageSize, "page-size", listServicePrincipalsProxyReq.PageSize, `The maximum number of SPs to return.`) + cmd.Flags().StringVar(&listServicePrincipalsProxyFilterRaw, "filter", listServicePrincipalsProxyFilterRaw, `Optional.`) + cmd.Flags().IntVar(&listServicePrincipalsProxyPageSizeRaw, "page-size", listServicePrincipalsProxyPageSizeRaw, `The maximum number of SPs to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listServicePrincipalsProxyLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listServicePrincipalsProxyReq.PageToken, "page-token", listServicePrincipalsProxyReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listServicePrincipalsProxyPageTokenRaw, "page-token", listServicePrincipalsProxyPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-service-principals-proxy" @@ -1991,16 +2359,34 @@ List service principals in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.WorkspaceIamV2.ListServicePrincipalsProxy(ctx, listServicePrincipalsProxyReq) - if listServicePrincipalsProxyLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listServicePrincipalsProxyLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("filter") || listServicePrincipalsProxyFilterRaw != "" { + rawQuery["filter"] = listServicePrincipalsProxyFilterRaw } - if listServicePrincipalsProxyLimit > 0 { - ctx = cmdio.WithLimit(ctx, listServicePrincipalsProxyLimit) + if cmd.Flags().Changed("page-size") || listServicePrincipalsProxyPageSizeRaw != 0 { + rawQuery["page_size"] = listServicePrincipalsProxyPageSizeRaw } + if cmd.Flags().Changed("page-token") || listServicePrincipalsProxyPageTokenRaw != "" { + rawQuery["page_token"] = listServicePrincipalsProxyPageTokenRaw + } + rawPath := "/api/2.0/identity/service-principals" - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listServicePrincipalsProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) + if err != nil { + return err + } + if listServicePrincipalsProxyLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listServicePrincipalsProxyLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -2021,16 +2407,19 @@ List service principals in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var listTransitiveParentGroupsProxyOverrides []func( *cobra.Command, - *iamv2.ListTransitiveParentGroupsProxyRequest, + *map[string]any, ) func newListTransitiveParentGroupsProxy() *cobra.Command { cmd := &cobra.Command{} + var listTransitiveParentGroupsProxyReq map[string]any + listTransitiveParentGroupsProxyReq = map[string]any{} + var listTransitiveParentGroupsProxyPageSizeRaw int + var listTransitiveParentGroupsProxyPageTokenRaw string + var listTransitiveParentGroupsProxyPrincipalIdRaw int64 - var listTransitiveParentGroupsProxyReq iamv2.ListTransitiveParentGroupsProxyRequest - - cmd.Flags().IntVar(&listTransitiveParentGroupsProxyReq.PageSize, "page-size", listTransitiveParentGroupsProxyReq.PageSize, `The maximum number of parent groups to return.`) - cmd.Flags().StringVar(&listTransitiveParentGroupsProxyReq.PageToken, "page-token", listTransitiveParentGroupsProxyReq.PageToken, `A page token, received from a previous ListTransitiveParentGroups call.`) + cmd.Flags().IntVar(&listTransitiveParentGroupsProxyPageSizeRaw, "page-size", listTransitiveParentGroupsProxyPageSizeRaw, `The maximum number of parent groups to return.`) + cmd.Flags().StringVar(&listTransitiveParentGroupsProxyPageTokenRaw, "page-token", listTransitiveParentGroupsProxyPageTokenRaw, `A page token, received from a previous ListTransitiveParentGroups call.`) cmd.Use = "list-transitive-parent-groups-proxy PRINCIPAL_ID" cmd.Short = `*Beta* List all transitive parent groups of a principal.` @@ -2057,17 +2446,32 @@ List all transitive parent groups of a principal. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - _, err = fmt.Sscan(args[0], &listTransitiveParentGroupsProxyReq.PrincipalId) + _, err = fmt.Sscan(args[0], &listTransitiveParentGroupsProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } - response, err := w.WorkspaceIamV2.ListTransitiveParentGroupsProxy(ctx, listTransitiveParentGroupsProxyReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("page-size") || listTransitiveParentGroupsProxyPageSizeRaw != 0 { + rawQuery["page_size"] = listTransitiveParentGroupsProxyPageSizeRaw + } + if cmd.Flags().Changed("page-token") || listTransitiveParentGroupsProxyPageTokenRaw != "" { + rawQuery["page_token"] = listTransitiveParentGroupsProxyPageTokenRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/principals/%s/transitive-parent-groups", fmt.Sprint(listTransitiveParentGroupsProxyPrincipalIdRaw)) + + maps.Copy(rawQuery, listTransitiveParentGroupsProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2089,26 +2493,30 @@ List all transitive parent groups of a principal. // Functions can be added from the `init()` function in manually curated files in this directory. var listUsersProxyOverrides []func( *cobra.Command, - *iamv2.ListUsersProxyRequest, + *map[string]any, ) func newListUsersProxy() *cobra.Command { cmd := &cobra.Command{} + var listUsersProxyReq map[string]any + listUsersProxyReq = map[string]any{} + var listUsersProxyFilterRaw string + var listUsersProxyPageSizeRaw int + var listUsersProxyPageTokenRaw string - var listUsersProxyReq iamv2.ListUsersProxyRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listUsersProxyLimit int - cmd.Flags().StringVar(&listUsersProxyReq.Filter, "filter", listUsersProxyReq.Filter, `Optional.`) - cmd.Flags().IntVar(&listUsersProxyReq.PageSize, "page-size", listUsersProxyReq.PageSize, `The maximum number of users to return.`) + cmd.Flags().StringVar(&listUsersProxyFilterRaw, "filter", listUsersProxyFilterRaw, `Optional.`) + cmd.Flags().IntVar(&listUsersProxyPageSizeRaw, "page-size", listUsersProxyPageSizeRaw, `The maximum number of users to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listUsersProxyLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listUsersProxyReq.PageToken, "page-token", listUsersProxyReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listUsersProxyPageTokenRaw, "page-token", listUsersProxyPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-users-proxy" @@ -2133,16 +2541,34 @@ List users in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.WorkspaceIamV2.ListUsersProxy(ctx, listUsersProxyReq) - if listUsersProxyLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listUsersProxyLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("filter") || listUsersProxyFilterRaw != "" { + rawQuery["filter"] = listUsersProxyFilterRaw + } + if cmd.Flags().Changed("page-size") || listUsersProxyPageSizeRaw != 0 { + rawQuery["page_size"] = listUsersProxyPageSizeRaw } - if listUsersProxyLimit > 0 { - ctx = cmdio.WithLimit(ctx, listUsersProxyLimit) + if cmd.Flags().Changed("page-token") || listUsersProxyPageTokenRaw != "" { + rawQuery["page_token"] = listUsersProxyPageTokenRaw } + rawPath := "/api/2.0/identity/users" - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listUsersProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) + if err != nil { + return err + } + if listUsersProxyLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listUsersProxyLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -2163,25 +2589,28 @@ List users in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var listWorkspaceAssignmentDetailsProxyOverrides []func( *cobra.Command, - *iamv2.ListWorkspaceAssignmentDetailsProxyRequest, + *map[string]any, ) func newListWorkspaceAssignmentDetailsProxy() *cobra.Command { cmd := &cobra.Command{} + var listWorkspaceAssignmentDetailsProxyReq map[string]any + listWorkspaceAssignmentDetailsProxyReq = map[string]any{} + var listWorkspaceAssignmentDetailsProxyPageSizeRaw int + var listWorkspaceAssignmentDetailsProxyPageTokenRaw string - var listWorkspaceAssignmentDetailsProxyReq iamv2.ListWorkspaceAssignmentDetailsProxyRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listWorkspaceAssignmentDetailsProxyLimit int - cmd.Flags().IntVar(&listWorkspaceAssignmentDetailsProxyReq.PageSize, "page-size", listWorkspaceAssignmentDetailsProxyReq.PageSize, `The maximum number of workspace assignment details to return.`) + cmd.Flags().IntVar(&listWorkspaceAssignmentDetailsProxyPageSizeRaw, "page-size", listWorkspaceAssignmentDetailsProxyPageSizeRaw, `The maximum number of workspace assignment details to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listWorkspaceAssignmentDetailsProxyLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listWorkspaceAssignmentDetailsProxyReq.PageToken, "page-token", listWorkspaceAssignmentDetailsProxyReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listWorkspaceAssignmentDetailsProxyPageTokenRaw, "page-token", listWorkspaceAssignmentDetailsProxyPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-workspace-assignment-details-proxy" @@ -2209,16 +2638,31 @@ func newListWorkspaceAssignmentDetailsProxy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.WorkspaceIamV2.ListWorkspaceAssignmentDetailsProxy(ctx, listWorkspaceAssignmentDetailsProxyReq) - if listWorkspaceAssignmentDetailsProxyLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listWorkspaceAssignmentDetailsProxyLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("page-size") || listWorkspaceAssignmentDetailsProxyPageSizeRaw != 0 { + rawQuery["page_size"] = listWorkspaceAssignmentDetailsProxyPageSizeRaw } - if listWorkspaceAssignmentDetailsProxyLimit > 0 { - ctx = cmdio.WithLimit(ctx, listWorkspaceAssignmentDetailsProxyLimit) + if cmd.Flags().Changed("page-token") || listWorkspaceAssignmentDetailsProxyPageTokenRaw != "" { + rawQuery["page_token"] = listWorkspaceAssignmentDetailsProxyPageTokenRaw } + rawPath := "/api/2.0/identity/workspace-assignment-details" - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listWorkspaceAssignmentDetailsProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) + if err != nil { + return err + } + if listWorkspaceAssignmentDetailsProxyLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listWorkspaceAssignmentDetailsProxyLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -2239,25 +2683,28 @@ func newListWorkspaceAssignmentDetailsProxy() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listWorkspaceAssignmentsProxyOverrides []func( *cobra.Command, - *iamv2.ListWorkspaceAssignmentsProxyRequest, + *map[string]any, ) func newListWorkspaceAssignmentsProxy() *cobra.Command { cmd := &cobra.Command{} + var listWorkspaceAssignmentsProxyReq map[string]any + listWorkspaceAssignmentsProxyReq = map[string]any{} + var listWorkspaceAssignmentsProxyPageSizeRaw int + var listWorkspaceAssignmentsProxyPageTokenRaw string - var listWorkspaceAssignmentsProxyReq iamv2.ListWorkspaceAssignmentsProxyRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listWorkspaceAssignmentsProxyLimit int - cmd.Flags().IntVar(&listWorkspaceAssignmentsProxyReq.PageSize, "page-size", listWorkspaceAssignmentsProxyReq.PageSize, `The maximum number of workspace assignments to return.`) + cmd.Flags().IntVar(&listWorkspaceAssignmentsProxyPageSizeRaw, "page-size", listWorkspaceAssignmentsProxyPageSizeRaw, `The maximum number of workspace assignments to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listWorkspaceAssignmentsProxyLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listWorkspaceAssignmentsProxyReq.PageToken, "page-token", listWorkspaceAssignmentsProxyReq.PageToken, `Pagination token.`) + cmd.Flags().StringVar(&listWorkspaceAssignmentsProxyPageTokenRaw, "page-token", listWorkspaceAssignmentsProxyPageTokenRaw, `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-workspace-assignments-proxy" @@ -2284,16 +2731,31 @@ List workspace assignments for a workspace. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.WorkspaceIamV2.ListWorkspaceAssignmentsProxy(ctx, listWorkspaceAssignmentsProxyReq) - if listWorkspaceAssignmentsProxyLimit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", listWorkspaceAssignmentsProxyLimit) + rawQuery := map[string]any{} + if cmd.Flags().Changed("page-size") || listWorkspaceAssignmentsProxyPageSizeRaw != 0 { + rawQuery["page_size"] = listWorkspaceAssignmentsProxyPageSizeRaw } - if listWorkspaceAssignmentsProxyLimit > 0 { - ctx = cmdio.WithLimit(ctx, listWorkspaceAssignmentsProxyLimit) + if cmd.Flags().Changed("page-token") || listWorkspaceAssignmentsProxyPageTokenRaw != "" { + rawQuery["page_token"] = listWorkspaceAssignmentsProxyPageTokenRaw } + rawPath := "/api/2.0/identity/workspace-assignments" - return cmdio.RenderIterator(ctx, response) + maps.Copy(rawQuery, listWorkspaceAssignmentsProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "GET", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, nil, &response) + if err != nil { + return err + } + if listWorkspaceAssignmentsProxyLimit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", listWorkspaceAssignmentsProxyLimit) + } + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. @@ -2314,13 +2776,15 @@ List workspace assignments for a workspace. // Functions can be added from the `init()` function in manually curated files in this directory. var resolveGroupProxyOverrides []func( *cobra.Command, - *iamv2.ResolveGroupProxyRequest, + *map[string]any, ) func newResolveGroupProxy() *cobra.Command { cmd := &cobra.Command{} + var resolveGroupProxyReq map[string]any + resolveGroupProxyReq = map[string]any{} + var resolveGroupProxyExternalIdRaw string - var resolveGroupProxyReq iamv2.ResolveGroupProxyRequest var resolveGroupProxyJson flags.JsonFlag cmd.Flags().Var(&resolveGroupProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2359,6 +2823,7 @@ Resolve an external group in the Databricks account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := resolveGroupProxyJson.Unmarshal(&resolveGroupProxyReq) @@ -2373,14 +2838,24 @@ Resolve an external group in the Databricks account. } } if !cmd.Flags().Changed("json") { - resolveGroupProxyReq.ExternalId = args[0] + resolveGroupProxyExternalIdRaw = args[0] + } + + rawQuery := map[string]any{} + if cmd.Flags().Changed("external-id") || resolveGroupProxyExternalIdRaw != "" { + resolveGroupProxyReq["external_id"] = resolveGroupProxyExternalIdRaw } + rawPath := "/api/2.0/identity/groups/resolve-by-external-id" - response, err := w.WorkspaceIamV2.ResolveGroupProxy(ctx, resolveGroupProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, resolveGroupProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2402,13 +2877,15 @@ Resolve an external group in the Databricks account. // Functions can be added from the `init()` function in manually curated files in this directory. var resolveServicePrincipalProxyOverrides []func( *cobra.Command, - *iamv2.ResolveServicePrincipalProxyRequest, + *map[string]any, ) func newResolveServicePrincipalProxy() *cobra.Command { cmd := &cobra.Command{} + var resolveServicePrincipalProxyReq map[string]any + resolveServicePrincipalProxyReq = map[string]any{} + var resolveServicePrincipalProxyExternalIdRaw string - var resolveServicePrincipalProxyReq iamv2.ResolveServicePrincipalProxyRequest var resolveServicePrincipalProxyJson flags.JsonFlag cmd.Flags().Var(&resolveServicePrincipalProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2447,6 +2924,7 @@ Resolve an external service principal in the Databricks account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := resolveServicePrincipalProxyJson.Unmarshal(&resolveServicePrincipalProxyReq) @@ -2461,14 +2939,24 @@ Resolve an external service principal in the Databricks account. } } if !cmd.Flags().Changed("json") { - resolveServicePrincipalProxyReq.ExternalId = args[0] + resolveServicePrincipalProxyExternalIdRaw = args[0] + } + + rawQuery := map[string]any{} + if cmd.Flags().Changed("external-id") || resolveServicePrincipalProxyExternalIdRaw != "" { + resolveServicePrincipalProxyReq["external_id"] = resolveServicePrincipalProxyExternalIdRaw } + rawPath := "/api/2.0/identity/service-principals/resolve-by-external-id" - response, err := w.WorkspaceIamV2.ResolveServicePrincipalProxy(ctx, resolveServicePrincipalProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, resolveServicePrincipalProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2490,13 +2978,15 @@ Resolve an external service principal in the Databricks account. // Functions can be added from the `init()` function in manually curated files in this directory. var resolveUserProxyOverrides []func( *cobra.Command, - *iamv2.ResolveUserProxyRequest, + *map[string]any, ) func newResolveUserProxy() *cobra.Command { cmd := &cobra.Command{} + var resolveUserProxyReq map[string]any + resolveUserProxyReq = map[string]any{} + var resolveUserProxyExternalIdRaw string - var resolveUserProxyReq iamv2.ResolveUserProxyRequest var resolveUserProxyJson flags.JsonFlag cmd.Flags().Var(&resolveUserProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2534,6 +3024,7 @@ Resolve an external user in the Databricks account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := resolveUserProxyJson.Unmarshal(&resolveUserProxyReq) @@ -2548,14 +3039,24 @@ Resolve an external user in the Databricks account. } } if !cmd.Flags().Changed("json") { - resolveUserProxyReq.ExternalId = args[0] + resolveUserProxyExternalIdRaw = args[0] } - response, err := w.WorkspaceIamV2.ResolveUserProxy(ctx, resolveUserProxyReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("external-id") || resolveUserProxyExternalIdRaw != "" { + resolveUserProxyReq["external_id"] = resolveUserProxyExternalIdRaw + } + rawPath := "/api/2.0/identity/users/resolve-by-external-id" + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "POST", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, resolveUserProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2577,20 +3078,25 @@ Resolve an external user in the Databricks account. // Functions can be added from the `init()` function in manually curated files in this directory. var updateGroupProxyOverrides []func( *cobra.Command, - *iamv2.UpdateGroupProxyRequest, + *map[string]any, ) func newUpdateGroupProxy() *cobra.Command { cmd := &cobra.Command{} + var updateGroupProxyReq map[string]any + updateGroupProxyReq = map[string]any{} + var updateGroupProxyGroupIdRaw string + var updateGroupProxyUpdateMaskRaw string + var updateGroupProxyAccountIdRaw string + var updateGroupProxyExternalIdRaw string + var updateGroupProxyGroupNameRaw string - var updateGroupProxyReq iamv2.UpdateGroupProxyRequest - updateGroupProxyReq.Group = iamv2.Group{} var updateGroupProxyJson flags.JsonFlag cmd.Flags().Var(&updateGroupProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateGroupProxyReq.Group.ExternalId, "external-id", updateGroupProxyReq.Group.ExternalId, `ExternalId of the group in the customer's IdP.`) - cmd.Flags().StringVar(&updateGroupProxyReq.Group.GroupName, "group-name", updateGroupProxyReq.Group.GroupName, `Display name of the group.`) + cmd.Flags().StringVar(&updateGroupProxyExternalIdRaw, "external-id", updateGroupProxyExternalIdRaw, `ExternalId of the group in the customer's IdP.`) + cmd.Flags().StringVar(&updateGroupProxyGroupNameRaw, "group-name", updateGroupProxyGroupNameRaw, `Display name of the group.`) cmd.Use = "update-group-proxy GROUP_ID UPDATE_MASK" cmd.Short = `*Beta* Update a group in the account.` @@ -2624,9 +3130,10 @@ Update a group in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := updateGroupProxyJson.Unmarshal(&updateGroupProxyReq.Group) + diags := updateGroupProxyJson.Unmarshal(&updateGroupProxyReq) if diags.HasError() { return diags.Error() } @@ -2637,14 +3144,36 @@ Update a group in the account. } } } - updateGroupProxyReq.GroupId = args[0] - updateGroupProxyReq.UpdateMask = args[1] + updateGroupProxyGroupIdRaw = args[0] + updateGroupProxyUpdateMaskRaw = args[1] - response, err := w.WorkspaceIamV2.UpdateGroupProxy(ctx, updateGroupProxyReq) + rawQuery := map[string]any{} + if cmd.Flags().Changed("update-mask") || updateGroupProxyUpdateMaskRaw != "" { + rawQuery["update_mask"] = updateGroupProxyUpdateMaskRaw + } + if cmd.Flags().Changed("account-id") || updateGroupProxyAccountIdRaw != "" { + updateGroupProxyReq["account_id"] = updateGroupProxyAccountIdRaw + } + if cmd.Flags().Changed("external-id") || updateGroupProxyExternalIdRaw != "" { + updateGroupProxyReq["external_id"] = updateGroupProxyExternalIdRaw + } + if cmd.Flags().Changed("group-id") || updateGroupProxyGroupIdRaw != "" { + updateGroupProxyReq["group_id"] = updateGroupProxyGroupIdRaw + } + if cmd.Flags().Changed("group-name") || updateGroupProxyGroupNameRaw != "" { + updateGroupProxyReq["group_name"] = updateGroupProxyGroupNameRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/groups/%s", fmt.Sprint(updateGroupProxyGroupIdRaw)) + + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateGroupProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2666,19 +3195,26 @@ Update a group in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var updateServicePrincipalProxyOverrides []func( *cobra.Command, - *iamv2.UpdateServicePrincipalProxyRequest, + *map[string]any, ) func newUpdateServicePrincipalProxy() *cobra.Command { cmd := &cobra.Command{} + var updateServicePrincipalProxyReq map[string]any + updateServicePrincipalProxyReq = map[string]any{} + var updateServicePrincipalProxyServicePrincipalIdRaw string + var updateServicePrincipalProxyUpdateMaskRaw string + var updateServicePrincipalProxyAccountIdRaw string + var updateServicePrincipalProxyAccountSpStatusRaw string + var updateServicePrincipalProxyApplicationIdRaw string + var updateServicePrincipalProxyDisplayNameRaw string + var updateServicePrincipalProxyExternalIdRaw string - var updateServicePrincipalProxyReq iamv2.UpdateServicePrincipalProxyRequest - updateServicePrincipalProxyReq.ServicePrincipal = iamv2.ServicePrincipal{} var updateServicePrincipalProxyJson flags.JsonFlag cmd.Flags().Var(&updateServicePrincipalProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateServicePrincipalProxyReq.ServicePrincipal.ExternalId, "external-id", updateServicePrincipalProxyReq.ServicePrincipal.ExternalId, `ExternalId of the service principal in the customer's IdP.`) + cmd.Flags().StringVar(&updateServicePrincipalProxyExternalIdRaw, "external-id", updateServicePrincipalProxyExternalIdRaw, `ExternalId of the service principal in the customer's IdP.`) cmd.Use = "update-service-principal-proxy SERVICE_PRINCIPAL_ID UPDATE_MASK DISPLAY_NAME ACCOUNT_SP_STATUS" cmd.Short = `*Beta* Update a service principal in the account.` @@ -2721,9 +3257,10 @@ Update a service principal in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := updateServicePrincipalProxyJson.Unmarshal(&updateServicePrincipalProxyReq.ServicePrincipal) + diags := updateServicePrincipalProxyJson.Unmarshal(&updateServicePrincipalProxyReq) if diags.HasError() { return diags.Error() } @@ -2734,24 +3271,48 @@ Update a service principal in the account. } } } - updateServicePrincipalProxyReq.ServicePrincipalId = args[0] - updateServicePrincipalProxyReq.UpdateMask = args[1] + updateServicePrincipalProxyServicePrincipalIdRaw = args[0] + updateServicePrincipalProxyUpdateMaskRaw = args[1] if !cmd.Flags().Changed("json") { - updateServicePrincipalProxyReq.ServicePrincipal.DisplayName = args[2] + updateServicePrincipalProxyDisplayNameRaw = args[2] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updateServicePrincipalProxyReq.ServicePrincipal.AccountSpStatus) - if err != nil { - return fmt.Errorf("invalid ACCOUNT_SP_STATUS: %s", args[3]) - } + updateServicePrincipalProxyAccountSpStatusRaw = args[3] + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("update-mask") || updateServicePrincipalProxyUpdateMaskRaw != "" { + rawQuery["update_mask"] = updateServicePrincipalProxyUpdateMaskRaw + } + if cmd.Flags().Changed("account-id") || updateServicePrincipalProxyAccountIdRaw != "" { + updateServicePrincipalProxyReq["account_id"] = updateServicePrincipalProxyAccountIdRaw + } + if cmd.Flags().Changed("account-sp-status") || updateServicePrincipalProxyAccountSpStatusRaw != "" { + updateServicePrincipalProxyReq["account_sp_status"] = updateServicePrincipalProxyAccountSpStatusRaw } + if cmd.Flags().Changed("application-id") || updateServicePrincipalProxyApplicationIdRaw != "" { + updateServicePrincipalProxyReq["application_id"] = updateServicePrincipalProxyApplicationIdRaw + } + if cmd.Flags().Changed("display-name") || updateServicePrincipalProxyDisplayNameRaw != "" { + updateServicePrincipalProxyReq["display_name"] = updateServicePrincipalProxyDisplayNameRaw + } + if cmd.Flags().Changed("external-id") || updateServicePrincipalProxyExternalIdRaw != "" { + updateServicePrincipalProxyReq["external_id"] = updateServicePrincipalProxyExternalIdRaw + } + if cmd.Flags().Changed("service-principal-id") || updateServicePrincipalProxyServicePrincipalIdRaw != "" { + updateServicePrincipalProxyReq["service_principal_id"] = updateServicePrincipalProxyServicePrincipalIdRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/service-principals/%s", fmt.Sprint(updateServicePrincipalProxyServicePrincipalIdRaw)) - response, err := w.WorkspaceIamV2.UpdateServicePrincipalProxy(ctx, updateServicePrincipalProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateServicePrincipalProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2773,19 +3334,25 @@ Update a service principal in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var updateUserProxyOverrides []func( *cobra.Command, - *iamv2.UpdateUserProxyRequest, + *map[string]any, ) func newUpdateUserProxy() *cobra.Command { cmd := &cobra.Command{} + var updateUserProxyReq map[string]any + updateUserProxyReq = map[string]any{} + var updateUserProxyUpdateMaskRaw string + var updateUserProxyUserIdRaw string + var updateUserProxyAccountIdRaw string + var updateUserProxyAccountUserStatusRaw string + var updateUserProxyExternalIdRaw string + var updateUserProxyUsernameRaw string - var updateUserProxyReq iamv2.UpdateUserProxyRequest - updateUserProxyReq.User = iamv2.User{} var updateUserProxyJson flags.JsonFlag cmd.Flags().Var(&updateUserProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateUserProxyReq.User.ExternalId, "external-id", updateUserProxyReq.User.ExternalId, `ExternalId of the user in the customer's IdP.`) + cmd.Flags().StringVar(&updateUserProxyExternalIdRaw, "external-id", updateUserProxyExternalIdRaw, `ExternalId of the user in the customer's IdP.`) cmd.Use = "update-user-proxy USER_ID UPDATE_MASK USERNAME FULL_NAME ACCOUNT_USER_STATUS" cmd.Short = `*Beta* Update a user in the account.` @@ -2830,9 +3397,10 @@ Update a user in the account. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := updateUserProxyJson.Unmarshal(&updateUserProxyReq.User) + diags := updateUserProxyJson.Unmarshal(&updateUserProxyReq) if diags.HasError() { return diags.Error() } @@ -2843,31 +3411,48 @@ Update a user in the account. } } } - updateUserProxyReq.UserId = args[0] - updateUserProxyReq.UpdateMask = args[1] + updateUserProxyUserIdRaw = args[0] + updateUserProxyUpdateMaskRaw = args[1] if !cmd.Flags().Changed("json") { - updateUserProxyReq.User.Username = args[2] + updateUserProxyUsernameRaw = args[2] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[3], &updateUserProxyReq.User.FullName) - if err != nil { - return fmt.Errorf("invalid FULL_NAME: %s", args[3]) - } - + updateUserProxyReq["full_name"] = args[3] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[4], &updateUserProxyReq.User.AccountUserStatus) - if err != nil { - return fmt.Errorf("invalid ACCOUNT_USER_STATUS: %s", args[4]) - } + updateUserProxyAccountUserStatusRaw = args[4] + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("update-mask") || updateUserProxyUpdateMaskRaw != "" { + rawQuery["update_mask"] = updateUserProxyUpdateMaskRaw + } + if cmd.Flags().Changed("account-id") || updateUserProxyAccountIdRaw != "" { + updateUserProxyReq["account_id"] = updateUserProxyAccountIdRaw + } + if cmd.Flags().Changed("account-user-status") || updateUserProxyAccountUserStatusRaw != "" { + updateUserProxyReq["account_user_status"] = updateUserProxyAccountUserStatusRaw } + if cmd.Flags().Changed("external-id") || updateUserProxyExternalIdRaw != "" { + updateUserProxyReq["external_id"] = updateUserProxyExternalIdRaw + } + if cmd.Flags().Changed("user-id") || updateUserProxyUserIdRaw != "" { + updateUserProxyReq["user_id"] = updateUserProxyUserIdRaw + } + if cmd.Flags().Changed("username") || updateUserProxyUsernameRaw != "" { + updateUserProxyReq["username"] = updateUserProxyUsernameRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/users/%s", fmt.Sprint(updateUserProxyUserIdRaw)) - response, err := w.WorkspaceIamV2.UpdateUserProxy(ctx, updateUserProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateUserProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2889,14 +3474,18 @@ Update a user in the account. // Functions can be added from the `init()` function in manually curated files in this directory. var updateWorkspaceAssignmentDetailProxyOverrides []func( *cobra.Command, - *iamv2.UpdateWorkspaceAssignmentDetailProxyRequest, + *map[string]any, ) func newUpdateWorkspaceAssignmentDetailProxy() *cobra.Command { cmd := &cobra.Command{} + var updateWorkspaceAssignmentDetailProxyReq map[string]any + updateWorkspaceAssignmentDetailProxyReq = map[string]any{} + var updateWorkspaceAssignmentDetailProxyPrincipalIdRaw int64 + var updateWorkspaceAssignmentDetailProxyAccountIdRaw string + var updateWorkspaceAssignmentDetailProxyPrincipalTypeRaw string + var updateWorkspaceAssignmentDetailProxyWorkspaceIdRaw int64 - var updateWorkspaceAssignmentDetailProxyReq iamv2.UpdateWorkspaceAssignmentDetailProxyRequest - updateWorkspaceAssignmentDetailProxyReq.WorkspaceAssignmentDetail = iamv2.WorkspaceAssignmentDetail{} var updateWorkspaceAssignmentDetailProxyJson flags.JsonFlag cmd.Flags().Var(&updateWorkspaceAssignmentDetailProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -2941,9 +3530,10 @@ func newUpdateWorkspaceAssignmentDetailProxy() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := updateWorkspaceAssignmentDetailProxyJson.Unmarshal(&updateWorkspaceAssignmentDetailProxyReq.WorkspaceAssignmentDetail) + diags := updateWorkspaceAssignmentDetailProxyJson.Unmarshal(&updateWorkspaceAssignmentDetailProxyReq) if diags.HasError() { return diags.Error() } @@ -2954,28 +3544,44 @@ func newUpdateWorkspaceAssignmentDetailProxy() *cobra.Command { } } } - _, err = fmt.Sscan(args[0], &updateWorkspaceAssignmentDetailProxyReq.PrincipalId) + _, err = fmt.Sscan(args[0], &updateWorkspaceAssignmentDetailProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } - if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateWorkspaceAssignmentDetailProxyReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateWorkspaceAssignmentDetailProxyReq["update_mask"] = args[1] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &updateWorkspaceAssignmentDetailProxyReq.WorkspaceAssignmentDetail.PrincipalId) + _, err = fmt.Sscan(args[2], &updateWorkspaceAssignmentDetailProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[2]) } + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || updateWorkspaceAssignmentDetailProxyAccountIdRaw != "" { + updateWorkspaceAssignmentDetailProxyReq["account_id"] = updateWorkspaceAssignmentDetailProxyAccountIdRaw + } + if cmd.Flags().Changed("principal-id") || updateWorkspaceAssignmentDetailProxyPrincipalIdRaw != 0 { + updateWorkspaceAssignmentDetailProxyReq["principal_id"] = updateWorkspaceAssignmentDetailProxyPrincipalIdRaw } + if cmd.Flags().Changed("principal-type") || updateWorkspaceAssignmentDetailProxyPrincipalTypeRaw != "" { + updateWorkspaceAssignmentDetailProxyReq["principal_type"] = updateWorkspaceAssignmentDetailProxyPrincipalTypeRaw + } + if cmd.Flags().Changed("workspace-id") || updateWorkspaceAssignmentDetailProxyWorkspaceIdRaw != 0 { + updateWorkspaceAssignmentDetailProxyReq["workspace_id"] = updateWorkspaceAssignmentDetailProxyWorkspaceIdRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/workspace-assignment-details/%s", fmt.Sprint(updateWorkspaceAssignmentDetailProxyPrincipalIdRaw)) - response, err := w.WorkspaceIamV2.UpdateWorkspaceAssignmentDetailProxy(ctx, updateWorkspaceAssignmentDetailProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateWorkspaceAssignmentDetailProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -2997,14 +3603,18 @@ func newUpdateWorkspaceAssignmentDetailProxy() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateWorkspaceAssignmentProxyOverrides []func( *cobra.Command, - *iamv2.UpdateWorkspaceAssignmentProxyRequest, + *map[string]any, ) func newUpdateWorkspaceAssignmentProxy() *cobra.Command { cmd := &cobra.Command{} + var updateWorkspaceAssignmentProxyReq map[string]any + updateWorkspaceAssignmentProxyReq = map[string]any{} + var updateWorkspaceAssignmentProxyPrincipalIdRaw int64 + var updateWorkspaceAssignmentProxyAccountIdRaw string + var updateWorkspaceAssignmentProxyPrincipalTypeRaw string + var updateWorkspaceAssignmentProxyWorkspaceIdRaw int64 - var updateWorkspaceAssignmentProxyReq iamv2.UpdateWorkspaceAssignmentProxyRequest - updateWorkspaceAssignmentProxyReq.WorkspaceAssignment = iamv2.WorkspaceAssignment{} var updateWorkspaceAssignmentProxyJson flags.JsonFlag cmd.Flags().Var(&updateWorkspaceAssignmentProxyJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -3048,9 +3658,10 @@ Update a workspace assignment for a workspace. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := updateWorkspaceAssignmentProxyJson.Unmarshal(&updateWorkspaceAssignmentProxyReq.WorkspaceAssignment) + diags := updateWorkspaceAssignmentProxyJson.Unmarshal(&updateWorkspaceAssignmentProxyReq) if diags.HasError() { return diags.Error() } @@ -3061,28 +3672,44 @@ Update a workspace assignment for a workspace. } } } - _, err = fmt.Sscan(args[0], &updateWorkspaceAssignmentProxyReq.PrincipalId) + _, err = fmt.Sscan(args[0], &updateWorkspaceAssignmentProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } - if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateWorkspaceAssignmentProxyReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateWorkspaceAssignmentProxyReq["update_mask"] = args[1] } if !cmd.Flags().Changed("json") { - _, err = fmt.Sscan(args[2], &updateWorkspaceAssignmentProxyReq.WorkspaceAssignment.PrincipalId) + _, err = fmt.Sscan(args[2], &updateWorkspaceAssignmentProxyPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[2]) } + } + rawQuery := map[string]any{} + if cmd.Flags().Changed("account-id") || updateWorkspaceAssignmentProxyAccountIdRaw != "" { + updateWorkspaceAssignmentProxyReq["account_id"] = updateWorkspaceAssignmentProxyAccountIdRaw + } + if cmd.Flags().Changed("principal-id") || updateWorkspaceAssignmentProxyPrincipalIdRaw != 0 { + updateWorkspaceAssignmentProxyReq["principal_id"] = updateWorkspaceAssignmentProxyPrincipalIdRaw + } + if cmd.Flags().Changed("principal-type") || updateWorkspaceAssignmentProxyPrincipalTypeRaw != "" { + updateWorkspaceAssignmentProxyReq["principal_type"] = updateWorkspaceAssignmentProxyPrincipalTypeRaw } + if cmd.Flags().Changed("workspace-id") || updateWorkspaceAssignmentProxyWorkspaceIdRaw != 0 { + updateWorkspaceAssignmentProxyReq["workspace_id"] = updateWorkspaceAssignmentProxyWorkspaceIdRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/workspace-assignments/%s", fmt.Sprint(updateWorkspaceAssignmentProxyPrincipalIdRaw)) - response, err := w.WorkspaceIamV2.UpdateWorkspaceAssignmentProxy(ctx, updateWorkspaceAssignmentProxyReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateWorkspaceAssignmentProxyReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -3104,19 +3731,23 @@ Update a workspace assignment for a workspace. // Functions can be added from the `init()` function in manually curated files in this directory. var updateWorkspaceIdentityDetailOverrides []func( *cobra.Command, - *iamv2.UpdateWorkspaceIdentityDetailRequest, + *map[string]any, ) func newUpdateWorkspaceIdentityDetail() *cobra.Command { cmd := &cobra.Command{} + var updateWorkspaceIdentityDetailReq map[string]any + updateWorkspaceIdentityDetailReq = map[string]any{} + var updateWorkspaceIdentityDetailPrincipalIdRaw int64 + var updateWorkspaceIdentityDetailAssignmentTypeRaw string + var updateWorkspaceIdentityDetailPrincipalTypeRaw string + var updateWorkspaceIdentityDetailWorkspaceIdentityStatusRaw string - var updateWorkspaceIdentityDetailReq iamv2.UpdateWorkspaceIdentityDetailRequest - updateWorkspaceIdentityDetailReq.WorkspaceIdentityDetail = iamv2.WorkspaceIdentityDetail{} var updateWorkspaceIdentityDetailJson flags.JsonFlag cmd.Flags().Var(&updateWorkspaceIdentityDetailJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().Var(&updateWorkspaceIdentityDetailReq.WorkspaceIdentityDetail.WorkspaceIdentityStatus, "workspace-identity-status", `The activity status of an identity in a Databricks workspace. Supported values: [ACTIVE, INACTIVE]`) + flags.EnumVar(cmd.Flags(), &updateWorkspaceIdentityDetailWorkspaceIdentityStatusRaw, "workspace-identity-status", `The activity status of an identity in a Databricks workspace. Supported values: [ACTIVE, INACTIVE]`, "State", "ACTIVE", "INACTIVE") cmd.Use = "update-workspace-identity-detail PRINCIPAL_ID UPDATE_MASK" cmd.Short = `*Beta* Update workspace identity details for a principal.` @@ -3143,9 +3774,10 @@ Update workspace identity details for a principal. cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { - diags := updateWorkspaceIdentityDetailJson.Unmarshal(&updateWorkspaceIdentityDetailReq.WorkspaceIdentityDetail) + diags := updateWorkspaceIdentityDetailJson.Unmarshal(&updateWorkspaceIdentityDetailReq) if diags.HasError() { return diags.Error() } @@ -3156,21 +3788,38 @@ Update workspace identity details for a principal. } } } - _, err = fmt.Sscan(args[0], &updateWorkspaceIdentityDetailReq.PrincipalId) + _, err = fmt.Sscan(args[0], &updateWorkspaceIdentityDetailPrincipalIdRaw) if err != nil { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[0]) } - if args[1] != "" { - updateMaskArray := strings.Split(args[1], ",") - updateWorkspaceIdentityDetailReq.UpdateMask = *fieldmask.New(updateMaskArray) + updateWorkspaceIdentityDetailReq["update_mask"] = args[1] + } + + rawQuery := map[string]any{} + if cmd.Flags().Changed("assignment-type") || updateWorkspaceIdentityDetailAssignmentTypeRaw != "" { + updateWorkspaceIdentityDetailReq["assignment_type"] = updateWorkspaceIdentityDetailAssignmentTypeRaw + } + if cmd.Flags().Changed("principal-id") || updateWorkspaceIdentityDetailPrincipalIdRaw != 0 { + updateWorkspaceIdentityDetailReq["principal_id"] = updateWorkspaceIdentityDetailPrincipalIdRaw + } + if cmd.Flags().Changed("principal-type") || updateWorkspaceIdentityDetailPrincipalTypeRaw != "" { + updateWorkspaceIdentityDetailReq["principal_type"] = updateWorkspaceIdentityDetailPrincipalTypeRaw } + if cmd.Flags().Changed("workspace-identity-status") || updateWorkspaceIdentityDetailWorkspaceIdentityStatusRaw != "" { + updateWorkspaceIdentityDetailReq["workspace_identity_status"] = updateWorkspaceIdentityDetailWorkspaceIdentityStatusRaw + } + rawPath := fmt.Sprintf("/api/2.0/identity/workspace-identity-details/%s", fmt.Sprint(updateWorkspaceIdentityDetailPrincipalIdRaw)) - response, err := w.WorkspaceIamV2.UpdateWorkspaceIdentityDetail(ctx, updateWorkspaceIdentityDetailReq) + api, err := apiclient.New(w.Config) + if err != nil { + return err + } + var response any + err = api.Do(ctx, "PATCH", rawPath, auth.WorkspaceIDHeaders(w.Config), rawQuery, updateWorkspaceIdentityDetailReq, &response) if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/cmd/workspace/workspace-settings-v2/workspace-settings-v2.go b/cmd/workspace/workspace-settings-v2/workspace-settings-v2.go index a9c54d16d03..21b865c1ee3 100644 --- a/cmd/workspace/workspace-settings-v2/workspace-settings-v2.go +++ b/cmd/workspace/workspace-settings-v2/workspace-settings-v2.go @@ -7,10 +7,13 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/settingsv2" "github.com/spf13/cobra" + + settings "github.com/databricks/cli/libs/sdktypes/settings/v2" + sdksettings "github.com/databricks/sdk-go/settings/v2" ) // Slice with functions to override default command behavior. @@ -49,13 +52,12 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPublicWorkspaceSettingOverrides []func( *cobra.Command, - *settingsv2.GetPublicWorkspaceSettingRequest, + *sdksettings.GetPublicWorkspaceSettingRequest, ) func newGetPublicWorkspaceSetting() *cobra.Command { cmd := &cobra.Command{} - - var getPublicWorkspaceSettingReq settingsv2.GetPublicWorkspaceSettingRequest + var getPublicWorkspaceSettingReq sdksettings.GetPublicWorkspaceSettingRequest cmd.Use = "get-public-workspace-setting NAME" cmd.Short = `Get a workspace setting.` @@ -81,15 +83,21 @@ func newGetPublicWorkspaceSetting() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - getPublicWorkspaceSettingReq.Name = args[0] + getPublicWorkspaceSettingReq.Name = new(args[0]) - response, err := w.WorkspaceSettingsV2.GetPublicWorkspaceSetting(ctx, getPublicWorkspaceSettingReq) + sdkReq := &getPublicWorkspaceSettingReq + response, err := w.Settings.GetPublicWorkspaceSetting(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := settings.SettingFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. @@ -110,25 +118,25 @@ func newGetPublicWorkspaceSetting() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listWorkspaceSettingsMetadataOverrides []func( *cobra.Command, - *settingsv2.ListWorkspaceSettingsMetadataRequest, + *settings.ListWorkspaceSettingsMetadataRequest, ) func newListWorkspaceSettingsMetadata() *cobra.Command { cmd := &cobra.Command{} + var listWorkspaceSettingsMetadataReq settings.ListWorkspaceSettingsMetadataRequest - var listWorkspaceSettingsMetadataReq settingsv2.ListWorkspaceSettingsMetadataRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. var listWorkspaceSettingsMetadataLimit int - cmd.Flags().IntVar(&listWorkspaceSettingsMetadataReq.PageSize, "page-size", listWorkspaceSettingsMetadataReq.PageSize, `The maximum number of settings to return.`) + flags.IntPtrVar(cmd.Flags(), &listWorkspaceSettingsMetadataReq.PageSize, "page-size", `The maximum number of settings to return.`) // Limit flag for total result capping. cmd.Flags().IntVar(&listWorkspaceSettingsMetadataLimit, "limit", 0, `Maximum number of results to return.`) // Hidden pagination flags (internal API parameters). - cmd.Flags().StringVar(&listWorkspaceSettingsMetadataReq.PageToken, "page-token", listWorkspaceSettingsMetadataReq.PageToken, `Pagination token.`) + flags.StringPtrVar(cmd.Flags(), &listWorkspaceSettingsMetadataReq.PageToken, "page-token", `Pagination token.`) cmd.Flags().Lookup("page-token").Hidden = true cmd.Use = "list-workspace-settings-metadata" @@ -152,16 +160,20 @@ func newListWorkspaceSettingsMetadata() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w - response := w.WorkspaceSettingsV2.ListWorkspaceSettingsMetadata(ctx, listWorkspaceSettingsMetadataReq) + sdkReq, err := settings.ListWorkspaceSettingsMetadataRequestToSDK(&listWorkspaceSettingsMetadataReq) + if err != nil { + return err + } if listWorkspaceSettingsMetadataLimit < 0 { return fmt.Errorf("--limit must be a non-negative integer, got %d", listWorkspaceSettingsMetadataLimit) } if listWorkspaceSettingsMetadataLimit > 0 { ctx = cmdio.WithLimit(ctx, listWorkspaceSettingsMetadataLimit) } - - return cmdio.RenderIterator(ctx, response) + response := w.Settings.ListWorkspaceSettingsMetadataIter(ctx, *sdkReq) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, settings.SettingsMetadataFromSDK)) } // Disable completions since they are not applicable. @@ -182,14 +194,14 @@ func newListWorkspaceSettingsMetadata() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var patchPublicWorkspaceSettingOverrides []func( *cobra.Command, - *settingsv2.PatchPublicWorkspaceSettingRequest, + *settings.PatchPublicWorkspaceSettingRequest, ) func newPatchPublicWorkspaceSetting() *cobra.Command { cmd := &cobra.Command{} + var patchPublicWorkspaceSettingReq settings.PatchPublicWorkspaceSettingRequest + patchPublicWorkspaceSettingReq.Setting = &settings.Setting{} - 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`) @@ -213,7 +225,7 @@ func newPatchPublicWorkspaceSetting() *cobra.Command { // TODO: complex arg: effective_string_val // TODO: complex arg: effective_workspace_label // TODO: complex arg: integer_val - cmd.Flags().StringVar(&patchPublicWorkspaceSettingReq.Setting.Name, "name", patchPublicWorkspaceSettingReq.Setting.Name, `Name of the setting.`) + flags.StringPtrVar(cmd.Flags(), &patchPublicWorkspaceSettingReq.Name, "name", `Name of the setting.`) // TODO: complex arg: operational_email_custom_recipient // TODO: complex arg: personal_compute // TODO: complex arg: restrict_workspace_admins @@ -248,6 +260,7 @@ func newPatchPublicWorkspaceSetting() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := patchPublicWorkspaceSettingJson.Unmarshal(&patchPublicWorkspaceSettingReq.Setting) @@ -261,14 +274,22 @@ func newPatchPublicWorkspaceSetting() *cobra.Command { } } } - patchPublicWorkspaceSettingReq.Name = args[0] + patchPublicWorkspaceSettingReq.Name = new(args[0]) - response, err := w.WorkspaceSettingsV2.PatchPublicWorkspaceSetting(ctx, patchPublicWorkspaceSettingReq) + sdkReq, err := settings.PatchPublicWorkspaceSettingRequestToSDK(&patchPublicWorkspaceSettingReq) + if err != nil { + return err + } + response, err := w.Settings.PatchPublicWorkspaceSetting(ctx, *sdkReq) if err != nil { return err } - return cmdio.Render(ctx, response) + out, err := settings.SettingFromSDK(response) + if err != nil { + return err + } + return cmdio.Render(ctx, out) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/workspace/export_dir.go b/cmd/workspace/workspace/export_dir.go index 362b6e4e30b..5c50149f7e3 100644 --- a/cmd/workspace/workspace/export_dir.go +++ b/cmd/workspace/workspace/export_dir.go @@ -2,7 +2,6 @@ package workspace import ( "context" - "errors" "fmt" "io" "io/fs" @@ -13,13 +12,13 @@ import ( "slices" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/filer" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/notebook" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/workspaceapi" "github.com/spf13/cobra" ) @@ -31,18 +30,19 @@ type exportDirOptions struct { // isFileSizeError checks if the error is due to file size limits. func isFileSizeError(err error) bool { - aerr, ok := errors.AsType[*apierr.APIError](err) - if !ok || aerr.StatusCode != http.StatusBadRequest { + aerr, ok := apierrs.Get(err) + if !ok || aerr.HTTPStatusCode() != http.StatusBadRequest { return false } - // Check ErrorCode field - if aerr.ErrorCode == "MAX_NOTEBOOK_SIZE_EXCEEDED" || aerr.ErrorCode == "MAX_READ_SIZE_EXCEEDED" { + // Check error_code field + code := apierrs.ErrorCode(err) + if code == "MAX_NOTEBOOK_SIZE_EXCEEDED" || code == "MAX_READ_SIZE_EXCEEDED" { return true } // Check ErrorInfo.Reason field - details := aerr.ErrorDetails() + details := aerr.Details() if details.ErrorInfo != nil { reason := details.ErrorInfo.Reason if reason == "MAX_NOTEBOOK_SIZE_EXCEEDED" || reason == "MAX_READ_SIZE_EXCEEDED" { @@ -55,15 +55,15 @@ func isFileSizeError(err error) bool { // Object types that cannot be exported via the workspace export API. // These will be skipped with a warning during export-dir. -var nonExportableTypes = []workspace.ObjectType{ - workspace.ObjectTypeLibrary, - workspace.ObjectTypeRepo, +var nonExportableTypes = []workspaceapi.ObjectType{ + workspaceapi.ObjectTypeLibrary, + workspaceapi.ObjectTypeRepo, // MLFLOW_EXPERIMENT is not defined as a constant in the SDK - workspace.ObjectType("MLFLOW_EXPERIMENT"), + workspaceapi.ObjectType("MLFLOW_EXPERIMENT"), } // isNonExportable checks if an object type cannot be exported. -func isNonExportable(objectType workspace.ObjectType) bool { +func isNonExportable(objectType workspaceapi.ObjectType) bool { return slices.Contains(nonExportableTypes, objectType) } @@ -92,7 +92,7 @@ func (opts *exportDirOptions) callback(ctx context.Context, workspaceFiler filer if err != nil { return err } - objectInfo := info.Sys().(workspace.ObjectInfo) + objectInfo := info.Sys().(workspaceapi.ObjectInfo) // Skip non-exportable objects (e.g., MLFLOW_EXPERIMENT, LIBRARY) if isNonExportable(objectInfo.ObjectType) { diff --git a/cmd/workspace/workspace/overrides.go b/cmd/workspace/workspace/overrides.go index 74186ebaf70..bbd165687db 100644 --- a/cmd/workspace/workspace/overrides.go +++ b/cmd/workspace/workspace/overrides.go @@ -8,14 +8,14 @@ import ( "os" "strings" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/workspaceapi" "github.com/spf13/cobra" ) -func listOverride(listCmd *cobra.Command, listReq *workspace.ListWorkspaceRequest) { +func listOverride(listCmd *cobra.Command, listReq *workspaceapi.ListWorkspaceRequest) { listReq.Path = "/" listCmd.Annotations["headerTemplate"] = cmdio.Heredoc(` {{header "ID"}} {{header "Type"}} {{header "Language"}} {{header "Path"}}`) @@ -24,7 +24,7 @@ func listOverride(listCmd *cobra.Command, listReq *workspace.ListWorkspaceReques {{end}}`) } -func exportOverride(exportCmd *cobra.Command, exportReq *workspace.ExportRequest) { +func exportOverride(exportCmd *cobra.Command, exportReq *workspaceapi.ExportRequest) { // The export command prints the contents of the file to stdout by default. exportCmd.Annotations["template"] = `{{.Content | b64_decode}}` exportCmd.Use = "export SOURCE_PATH" @@ -57,20 +57,20 @@ func exportOverride(exportCmd *cobra.Command, exportReq *workspace.ExportRequest } // Give better errors / hints for common API errors. -func wrapImportAPIErrors(err error, importReq *workspace.Import) error { - apiErr, ok := errors.AsType[*apierr.APIError](err) +func wrapImportAPIErrors(err error, importReq *workspaceapi.Import) error { + apiErr, ok := apierrs.Get(err) if !ok { return err } - isFormatSource := importReq.Format == workspace.ImportFormatSource || importReq.Format == "" - if isFormatSource && apiErr.StatusCode == http.StatusBadRequest && - strings.Contains(apiErr.Message, "The zip file may not be valid or may be an unsupported version.") { + isFormatSource := importReq.Format == workspaceapi.ImportFormatSource || importReq.Format == "" + if isFormatSource && apiErr.HTTPStatusCode() == http.StatusBadRequest && + strings.Contains(apiErr.Message(), "The zip file may not be valid or may be an unsupported version.") { return fmt.Errorf("%w Hint: Objects imported using format=SOURCE are expected to be zip encoded databricks source notebook(s) by default. Please specify a language using the --language flag if you are trying to import a single uncompressed notebook", err) } return err } -func importOverride(importCmd *cobra.Command, importReq *workspace.Import) { +func importOverride(importCmd *cobra.Command, importReq *workspaceapi.Import) { var filePath string importCmd.Use = "import TARGET_PATH" importCmd.Flags().StringVar(&filePath, "file", "", `Path of local file to import`) diff --git a/cmd/workspace/workspace/workspace.go b/cmd/workspace/workspace/workspace.go index 97c47f80ac0..b4ac2a7d3b0 100644 --- a/cmd/workspace/workspace/workspace.go +++ b/cmd/workspace/workspace/workspace.go @@ -10,8 +10,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/service/workspace" "github.com/spf13/cobra" + + workspaceapi "github.com/databricks/cli/libs/workspaceapi" ) // Slice with functions to override default command behavior. @@ -62,13 +63,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var deleteOverrides []func( *cobra.Command, - *workspace.Delete, + *workspaceapi.Delete, ) func newDelete() *cobra.Command { cmd := &cobra.Command{} + var deleteReq workspaceapi.Delete - var deleteReq workspace.Delete var deleteJson flags.JsonFlag cmd.Flags().Var(&deleteJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -103,13 +104,15 @@ func newDelete() *cobra.Command { } return nil } - 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) + _ = w if cmd.Flags().Changed("json") { diags := deleteJson.Unmarshal(&deleteReq) @@ -122,26 +125,9 @@ func newDelete() *cobra.Command { return err } } - } else { - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No PATH argument specified. Loading names for Workspace drop-down.") - names, err := w.Workspace.ObjectInfoPathToObjectIdMap(ctx, workspace.ListWorkspaceRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Workspace drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The absolute path of the notebook or directory") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the absolute path of the notebook or directory") - } + } + if !cmd.Flags().Changed("json") { deleteReq.Path = args[0] - } err = w.Workspace.Delete(ctx, deleteReq) @@ -169,13 +155,12 @@ func newDelete() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var exportOverrides []func( *cobra.Command, - *workspace.ExportRequest, + *workspaceapi.ExportRequest, ) func newExport() *cobra.Command { cmd := &cobra.Command{} - - var exportReq workspace.ExportRequest + var exportReq workspaceapi.ExportRequest cmd.Flags().Var(&exportReq.Format, "format", `This specifies the format of the exported file. Supported values: [ AUTO, @@ -208,35 +193,23 @@ func newExport() *cobra.Command { cmd.Annotations["launch_stage"] = "GA" cmd.Annotations["launch_stage_display"] = "GA" + 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) + _ = w - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No PATH argument specified. Loading names for Workspace drop-down.") - names, err := w.Workspace.ObjectInfoPathToObjectIdMap(ctx, workspace.ListWorkspaceRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Workspace drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The absolute path of the object or directory") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the absolute path of the object or directory") - } exportReq.Path = args[0] response, err := w.Workspace.Export(ctx, exportReq) if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -258,13 +231,12 @@ func newExport() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionLevelsOverrides []func( *cobra.Command, - *workspace.GetWorkspaceObjectPermissionLevelsRequest, + *workspaceapi.GetWorkspaceObjectPermissionLevelsRequest, ) func newGetPermissionLevels() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionLevelsReq workspace.GetWorkspaceObjectPermissionLevelsRequest + var getPermissionLevelsReq workspaceapi.GetWorkspaceObjectPermissionLevelsRequest cmd.Use = "get-permission-levels WORKSPACE_OBJECT_TYPE WORKSPACE_OBJECT_ID" cmd.Short = `Get workspace object permission levels.` @@ -291,6 +263,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w getPermissionLevelsReq.WorkspaceObjectType = args[0] getPermissionLevelsReq.WorkspaceObjectId = args[1] @@ -299,7 +272,6 @@ func newGetPermissionLevels() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -321,13 +293,12 @@ func newGetPermissionLevels() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getPermissionsOverrides []func( *cobra.Command, - *workspace.GetWorkspaceObjectPermissionsRequest, + *workspaceapi.GetWorkspaceObjectPermissionsRequest, ) func newGetPermissions() *cobra.Command { cmd := &cobra.Command{} - - var getPermissionsReq workspace.GetWorkspaceObjectPermissionsRequest + var getPermissionsReq workspaceapi.GetWorkspaceObjectPermissionsRequest cmd.Use = "get-permissions WORKSPACE_OBJECT_TYPE WORKSPACE_OBJECT_ID" cmd.Short = `Get workspace object permissions.` @@ -355,6 +326,7 @@ func newGetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w getPermissionsReq.WorkspaceObjectType = args[0] getPermissionsReq.WorkspaceObjectId = args[1] @@ -363,7 +335,6 @@ func newGetPermissions() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -385,13 +356,12 @@ func newGetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getStatusOverrides []func( *cobra.Command, - *workspace.GetStatusRequest, + *workspaceapi.GetStatusRequest, ) func newGetStatus() *cobra.Command { cmd := &cobra.Command{} - - var getStatusReq workspace.GetStatusRequest + var getStatusReq workspaceapi.GetStatusRequest cmd.Use = "get-status PATH" cmd.Short = `Get status.` @@ -416,6 +386,7 @@ func newGetStatus() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w getStatusReq.Path = args[0] @@ -423,7 +394,6 @@ func newGetStatus() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -445,13 +415,13 @@ func newGetStatus() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var importOverrides []func( *cobra.Command, - *workspace.Import, + *workspaceapi.Import, ) func newImport() *cobra.Command { cmd := &cobra.Command{} + var importReq workspaceapi.Import - var importReq workspace.Import var importJson flags.JsonFlag cmd.Flags().Var(&importJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -504,6 +474,7 @@ func newImport() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := importJson.Unmarshal(&importReq) @@ -546,13 +517,13 @@ func newImport() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var listOverrides []func( *cobra.Command, - *workspace.ListWorkspaceRequest, + *workspaceapi.ListWorkspaceRequest, ) func newList() *cobra.Command { cmd := &cobra.Command{} + var listReq workspaceapi.ListWorkspaceRequest - var listReq workspace.ListWorkspaceRequest // Registered for all paginated methods. Validated at call time in the // method-call template. Paginated list methods never have Wait or LRO // branches, so the method-call path is always reached. @@ -589,6 +560,7 @@ func newList() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w listReq.Path = args[0] @@ -599,8 +571,7 @@ func newList() *cobra.Command { if listLimit > 0 { ctx = cmdio.WithLimit(ctx, listLimit) } - - return cmdio.RenderIterator(ctx, response) + return cmdio.RenderListing(ctx, response) } // Disable completions since they are not applicable. @@ -621,13 +592,13 @@ func newList() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var mkdirsOverrides []func( *cobra.Command, - *workspace.Mkdirs, + *workspaceapi.Mkdirs, ) func newMkdirs() *cobra.Command { cmd := &cobra.Command{} + var mkdirsReq workspaceapi.Mkdirs - var mkdirsReq workspace.Mkdirs var mkdirsJson flags.JsonFlag cmd.Flags().Var(&mkdirsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -660,13 +631,15 @@ func newMkdirs() *cobra.Command { } return nil } - 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) + _ = w if cmd.Flags().Changed("json") { diags := mkdirsJson.Unmarshal(&mkdirsReq) @@ -679,24 +652,8 @@ func newMkdirs() *cobra.Command { return err } } - } else { - if len(args) == 0 { - sp := cmdio.NewSpinner(ctx) - sp.Update("No PATH argument specified. Loading names for Workspace drop-down.") - names, err := w.Workspace.ObjectInfoPathToObjectIdMap(ctx, workspace.ListWorkspaceRequest{}) - sp.Close() - if err != nil { - return fmt.Errorf("failed to load names for Workspace drop-down. Please manually specify required arguments. Original error: %w", err) - } - id, err := cmdio.Select(ctx, names, "The absolute path of the directory") - if err != nil { - return err - } - args = append(args, id) - } - if len(args) != 1 { - return errors.New("expected to have the absolute path of the directory") - } + } + if !cmd.Flags().Changed("json") { mkdirsReq.Path = args[0] } @@ -725,13 +682,13 @@ func newMkdirs() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var setPermissionsOverrides []func( *cobra.Command, - *workspace.WorkspaceObjectPermissionsRequest, + *workspaceapi.WorkspaceObjectPermissionsRequest, ) func newSetPermissions() *cobra.Command { cmd := &cobra.Command{} + var setPermissionsReq workspaceapi.WorkspaceObjectPermissionsRequest - var setPermissionsReq workspace.WorkspaceObjectPermissionsRequest var setPermissionsJson flags.JsonFlag cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -765,6 +722,7 @@ func newSetPermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -785,7 +743,6 @@ func newSetPermissions() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } @@ -807,13 +764,13 @@ func newSetPermissions() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updatePermissionsOverrides []func( *cobra.Command, - *workspace.WorkspaceObjectPermissionsRequest, + *workspaceapi.WorkspaceObjectPermissionsRequest, ) func newUpdatePermissions() *cobra.Command { cmd := &cobra.Command{} + var updatePermissionsReq workspaceapi.WorkspaceObjectPermissionsRequest - var updatePermissionsReq workspace.WorkspaceObjectPermissionsRequest var updatePermissionsJson flags.JsonFlag cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`) @@ -846,6 +803,7 @@ func newUpdatePermissions() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := cmdctx.WorkspaceClient(ctx) + _ = w if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -866,7 +824,6 @@ func newUpdatePermissions() *cobra.Command { if err != nil { return err } - return cmdio.Render(ctx, response) } diff --git a/experimental/aitools/cmd/batch.go b/experimental/aitools/cmd/batch.go index cd1890ceb10..7a6f58bd598 100644 --- a/experimental/aitools/cmd/batch.go +++ b/experimental/aitools/cmd/batch.go @@ -13,7 +13,7 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/sqlexec" - "github.com/databricks/databricks-sdk-go/service/sql" + sql "github.com/databricks/sdk-go/statementexecution/v1" "golang.org/x/sync/errgroup" ) @@ -30,13 +30,13 @@ var errInvalidBatchConcurrency = errors.New("--concurrency must be at least 1") // statement did not produce usable rows, regardless of state, so consumers // can branch on `error == null` alone. type batchResult struct { - SQL string `json:"sql"` - StatementID string `json:"statement_id,omitempty"` - State sql.StatementState `json:"state,omitempty"` - ElapsedMs int64 `json:"elapsed_ms"` - Columns []string `json:"columns,omitempty"` - Rows [][]string `json:"rows,omitempty"` - Error *batchResultError `json:"error,omitempty"` + SQL string `json:"sql"` + StatementID string `json:"statement_id,omitempty"` + State sql.StatementStatus_State `json:"state,omitempty"` + ElapsedMs int64 `json:"elapsed_ms"` + Columns []string `json:"columns,omitempty"` + Rows [][]string `json:"rows,omitempty"` + Error *batchResultError `json:"error,omitempty"` } // batchResultError captures user-visible error info for a failed statement. @@ -58,7 +58,7 @@ type batchResultError struct { // params, if non-nil, are bound on every statement. The same parameter set is // reused across the batch, so callers must ensure each SQL uses only markers // that are covered. -func executeBatch(ctx context.Context, api sql.StatementExecutionInterface, warehouseID string, sqls []string, params []sql.StatementParameterListItem, concurrency int) []batchResult { +func executeBatch(ctx context.Context, api sqlexec.API, warehouseID string, sqls []string, params []sql.StatementParameter, concurrency int) []batchResult { client := sqlexec.New(api, warehouseID) pollCtx, pollCancel := context.WithCancel(ctx) @@ -122,17 +122,17 @@ func executeBatch(ctx context.Context, api sql.StatementExecutionInterface, ware // runOneBatchQuery submits one SQL, polls to completion, and returns its // batchResult. All errors are encoded into the result; never returns an error. -func runOneBatchQuery(ctx context.Context, client *sqlexec.Client, sqlStr string, params []sql.StatementParameterListItem, statementIDs []string, idx int) batchResult { +func runOneBatchQuery(ctx context.Context, client *sqlexec.Client, sqlStr string, params []sql.StatementParameter, statementIDs []string, idx int) batchResult { start := time.Now() result := batchResult{SQL: sqlStr} stmt, err := client.Submit(ctx, sqlStr, sqlexec.WithParameters(params)) if err != nil { if ctx.Err() != nil { - result.State = sql.StatementStateCanceled + result.State = sql.StatementStatus_State_Canceled result.Error = &batchResultError{Message: "submission cancelled"} } else { - result.State = sql.StatementStateFailed + result.State = sql.StatementStatus_State_Failed result.Error = &batchResultError{Message: err.Error()} } result.ElapsedMs = time.Since(start).Milliseconds() @@ -145,10 +145,10 @@ func runOneBatchQuery(ctx context.Context, client *sqlexec.Client, sqlStr string stmt, err = client.Poll(ctx, stmt) if err != nil { if ctx.Err() != nil { - result.State = sql.StatementStateCanceled + result.State = sql.StatementStatus_State_Canceled result.Error = &batchResultError{Message: "cancelled"} } else { - result.State = sql.StatementStateFailed + result.State = sql.StatementStatus_State_Failed result.Error = &batchResultError{Message: err.Error()} } result.ElapsedMs = time.Since(start).Milliseconds() @@ -189,12 +189,14 @@ func cancelInFlight(ctx context.Context, client *sqlexec.Client, statementIDs [] continue } switch results[i].State { - case sql.StatementStateSucceeded, sql.StatementStateFailed, sql.StatementStateClosed: + case sql.StatementStatus_State_Succeeded, sql.StatementStatus_State_Failed, sql.StatementStatus_State_Closed: continue - case sql.StatementStateCanceled, sql.StatementStatePending, sql.StatementStateRunning: + case sql.StatementStatus_State_Canceled, sql.StatementStatus_State_Pending, sql.StatementStatus_State_Running: // Either still running server-side, or our internal "canceled" // marker meaning the goroutine bailed without telling the server. // Either way, send CancelExecution. + case sql.StatementStatus_State_Unspecified: + // Unknown status; treat as still running } // Detach from the inbound ctx (which is typically already cancelled by // the time we reach this sweep): WithoutCancel keeps the caller's diff --git a/experimental/aitools/cmd/batch_test.go b/experimental/aitools/cmd/batch_test.go index 8288a43da5d..edfbace458e 100644 --- a/experimental/aitools/cmd/batch_test.go +++ b/experimental/aitools/cmd/batch_test.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/databricks/cli/libs/cmdio" - mocksql "github.com/databricks/databricks-sdk-go/experimental/mocks/service/sql" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/utils" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -21,7 +21,7 @@ func TestRenderBatchJSON(t *testing.T) { { SQL: "SELECT 1", StatementID: "stmt-1", - State: sql.StatementStateSucceeded, + State: sql.StatementStatus_State_Succeeded, ElapsedMs: 42, Columns: []string{"n"}, Rows: [][]string{{"1"}}, @@ -29,7 +29,7 @@ func TestRenderBatchJSON(t *testing.T) { { SQL: "SELECT bad_syntax", StatementID: "stmt-2", - State: sql.StatementStateFailed, + State: sql.StatementStatus_State_Failed, ElapsedMs: 12, Error: &batchResultError{ Message: "near 'bad_syntax': syntax error", @@ -58,18 +58,18 @@ func TestRenderBatchJSON(t *testing.T) { func TestExecuteBatchAllSucceed(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) sqls := []string{"SELECT 1", "SELECT 2", "SELECT 3"} for i, sqlStr := range sqls { sid := fmt.Sprintf("stmt-%d", i+1) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.Statement == sqlStr + return utils.Deref(req.Statement) == sqlStr })).Return(&sql.StatementResponse{ - StatementId: sid, - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, - Manifest: &sql.ResultManifest{Schema: &sql.ResultSchema{Columns: []sql.ColumnInfo{{Name: "n"}}}}, - Result: &sql.ResultData{DataArray: [][]string{{strconv.Itoa(i + 1)}}}, + StatementId: new(sid), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, + Manifest: &sql.ResultManifest{Schema: &sql.Schema{Columns: []sql.ColumnInfo{{Name: new("n")}}}}, + Result: &sql.ResultData{DataArray: rows([][]string{{strconv.Itoa(i + 1)}})}, }, nil).Once() } @@ -78,7 +78,7 @@ func TestExecuteBatchAllSucceed(t *testing.T) { require.Len(t, results, 3) for i, r := range results { assert.Equal(t, sqls[i], r.SQL, "result %d sql", i) - assert.Equal(t, sql.StatementStateSucceeded, r.State, "result %d state", i) + assert.Equal(t, sql.StatementStatus_State_Succeeded, r.State, "result %d state", i) assert.Nil(t, r.Error, "result %d error", i) assert.Equal(t, []string{"n"}, r.Columns, "result %d columns", i) assert.Equal(t, [][]string{{strconv.Itoa(i + 1)}}, r.Rows, "result %d rows", i) @@ -88,17 +88,17 @@ func TestExecuteBatchAllSucceed(t *testing.T) { func TestExecuteBatchPassesParametersToAllStatements(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) - params := []sql.StatementParameterListItem{ - {Name: "since", Type: "DATE", Value: "2026-01-01"}, + params := []sql.StatementParameter{ + {Name: new("since"), Type: new("DATE"), Value: new("2026-01-01")}, } mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { return assert.ObjectsAreEqual(params, req.Parameters) })).Return(&sql.StatementResponse{ - StatementId: "stmt", - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, + StatementId: new("stmt"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, }, nil).Times(2) results := executeBatch(ctx, mockAPI, "wh-1", []string{"SELECT 1 WHERE 1=1 AND :since IS NOT NULL", "SELECT 2 WHERE :since IS NOT NULL"}, params, 8) @@ -107,26 +107,26 @@ func TestExecuteBatchPassesParametersToAllStatements(t *testing.T) { func TestExecuteBatchPartialFailure(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.Statement == "SELECT 1" + return utils.Deref(req.Statement) == "SELECT 1" })).Return(&sql.StatementResponse{ - StatementId: "stmt-good", - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, - Manifest: &sql.ResultManifest{Schema: &sql.ResultSchema{Columns: []sql.ColumnInfo{{Name: "n"}}}}, - Result: &sql.ResultData{DataArray: [][]string{{"1"}}}, + StatementId: new("stmt-good"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, + Manifest: &sql.ResultManifest{Schema: &sql.Schema{Columns: []sql.ColumnInfo{{Name: new("n")}}}}, + Result: &sql.ResultData{DataArray: rows([][]string{{"1"}})}, }, nil).Once() mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.Statement == "SELECT bad" + return utils.Deref(req.Statement) == "SELECT bad" })).Return(&sql.StatementResponse{ - StatementId: "stmt-bad", + StatementId: new("stmt-bad"), Status: &sql.StatementStatus{ - State: sql.StatementStateFailed, + State: sql.StatementStatus_State_Failed, Error: &sql.ServiceError{ ErrorCode: "SYNTAX_ERROR", - Message: "near 'bad': syntax error", + Message: new("near 'bad': syntax error"), }, }, }, nil).Once() @@ -135,10 +135,10 @@ func TestExecuteBatchPartialFailure(t *testing.T) { require.Len(t, results, 2) assert.Nil(t, results[0].Error) - assert.Equal(t, sql.StatementStateSucceeded, results[0].State) + assert.Equal(t, sql.StatementStatus_State_Succeeded, results[0].State) require.NotNil(t, results[1].Error) - assert.Equal(t, sql.StatementStateFailed, results[1].State) + assert.Equal(t, sql.StatementStatus_State_Failed, results[1].State) assert.Equal(t, "SYNTAX_ERROR", results[1].Error.ErrorCode) assert.Contains(t, results[1].Error.Message, "syntax error") } @@ -147,17 +147,17 @@ func TestExecuteBatchSubmissionFailure(t *testing.T) { // ExecuteStatement transport error is encoded into the per-result error, // not propagated up to abort siblings. ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.Statement == "SELECT good" + return utils.Deref(req.Statement) == "SELECT good" })).Return(&sql.StatementResponse{ - StatementId: "stmt-good", - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, + StatementId: new("stmt-good"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, }, nil).Once() mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.Statement == "SELECT broken" + return utils.Deref(req.Statement) == "SELECT broken" })).Return(nil, errors.New("network unreachable")).Once() results := executeBatch(ctx, mockAPI, "wh-123", []string{"SELECT good", "SELECT broken"}, nil, 8) @@ -173,13 +173,13 @@ func TestExecuteBatchSubmissionFailure(t *testing.T) { func TestExecuteBatchSetsOnWaitTimeoutContinue(t *testing.T) { // Guards against a silent SDK default flip from CONTINUE to CANCEL. ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.WaitTimeout == "0s" && req.OnWaitTimeout == sql.ExecuteStatementRequestOnWaitTimeoutContinue + return utils.Deref(req.WaitTimeout) == "0s" && req.OnWaitTimeout == sql.TimeoutAction_Continue })).Return(&sql.StatementResponse{ - StatementId: "stmt-x", - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, + StatementId: new("stmt-x"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, }, nil).Times(2) results := executeBatch(ctx, mockAPI, "wh-123", []string{"q1", "q2"}, nil, 8) @@ -190,27 +190,27 @@ func TestExecuteBatchPreservesInputOrder(t *testing.T) { // Index 0 is slow (PENDING then SUCCEEDED on first poll); 1 and 2 are // immediate. Despite the staggered completion, results stay in input order. ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.Statement == "SELECT 'slow'" + return utils.Deref(req.Statement) == "SELECT 'slow'" })).Return(&sql.StatementResponse{ - StatementId: "stmt-slow", - Status: &sql.StatementStatus{State: sql.StatementStatePending}, + StatementId: new("stmt-slow"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Pending}, }, nil).Once() - mockAPI.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-slow").Return(&sql.StatementResponse{ - StatementId: "stmt-slow", - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, + mockAPI.EXPECT().GetStatementResult(mock.Anything, "stmt-slow").Return(&sql.StatementResponse{ + StatementId: new("stmt-slow"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, }, nil).Once() for i, sqlStr := range []string{"SELECT 'fast1'", "SELECT 'fast2'"} { sid := fmt.Sprintf("stmt-fast-%d", i+1) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.Statement == sqlStr + return utils.Deref(req.Statement) == sqlStr })).Return(&sql.StatementResponse{ - StatementId: sid, - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, + StatementId: new(sid), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, }, nil).Once() } @@ -220,7 +220,7 @@ func TestExecuteBatchPreservesInputOrder(t *testing.T) { require.Len(t, results, 3) for i, r := range results { assert.Equal(t, sqls[i], r.SQL, "result %d", i) - assert.Equal(t, sql.StatementStateSucceeded, r.State, "result %d", i) + assert.Equal(t, sql.StatementStatus_State_Succeeded, r.State, "result %d", i) } } @@ -230,7 +230,7 @@ func TestExecuteBatchContextCancellationCancelsInFlight(t *testing.T) { // carry a NON-cancelled context, otherwise the SDK short-circuits on // ctx.Err() and never reaches the warehouse. ctx, cancel := context.WithCancel(cmdio.MockDiscard(t.Context())) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) aliveCtx := mock.MatchedBy(func(c context.Context) bool { return c.Err() == nil @@ -239,15 +239,13 @@ func TestExecuteBatchContextCancellationCancelsInFlight(t *testing.T) { for i, sqlStr := range []string{"q1", "q2", "q3"} { sid := fmt.Sprintf("stmt-%d", i+1) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.Statement == sqlStr + return utils.Deref(req.Statement) == sqlStr })).Return(&sql.StatementResponse{ - StatementId: sid, - Status: &sql.StatementStatus{State: sql.StatementStatePending}, + StatementId: new(sid), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Pending}, }, nil).Once() - mockAPI.EXPECT().CancelExecution(aliveCtx, sql.CancelExecutionRequest{ - StatementId: sid, - }).Return(nil).Once() + mockAPI.EXPECT().CancelStatement(aliveCtx, sid).Return(nil).Once() } cancel() @@ -256,7 +254,7 @@ func TestExecuteBatchContextCancellationCancelsInFlight(t *testing.T) { require.Len(t, results, 3) for i, r := range results { - assert.Equal(t, sql.StatementStateCanceled, r.State, "result %d state", i) + assert.Equal(t, sql.StatementStatus_State_Canceled, r.State, "result %d state", i) require.NotNil(t, r.Error, "result %d error", i) } } diff --git a/experimental/aitools/cmd/discover_schema.go b/experimental/aitools/cmd/discover_schema.go index 28f8bcb730b..5077a61c581 100644 --- a/experimental/aitools/cmd/discover_schema.go +++ b/experimental/aitools/cmd/discover_schema.go @@ -20,8 +20,6 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/sqlexec" - "github.com/databricks/databricks-sdk-go" - dbsql "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" "golang.org/x/sync/errgroup" ) @@ -49,7 +47,7 @@ func newSQLGate(limit int) *sqlGate { // when polling completes (or the caller's context is cancelled). On success it // returns the assembled result; a terminal non-success state is surfaced as the // CLI-facing query error. -func (g *sqlGate) run(ctx context.Context, w *databricks.WorkspaceClient, warehouseID, statement string) (*sqlexec.Result, error) { +func (g *sqlGate) run(ctx context.Context, api sqlexec.API, warehouseID, statement string) (*sqlexec.Result, error) { // If the caller cancelled before we even tried, don't enter the select: // when the gate has free slots both cases are ready and Go picks one // pseudo-randomly. Without this early-out we'd occasionally submit a @@ -64,7 +62,7 @@ func (g *sqlGate) run(ctx context.Context, w *databricks.WorkspaceClient, wareho return nil, ctx.Err() } - client := sqlexec.New(w.StatementExecution, warehouseID) + client := sqlexec.New(api, warehouseID) stmt, err := client.Submit(ctx, statement) if err != nil { @@ -162,7 +160,7 @@ CancelExecution before the command exits.`, gate := newSQLGate(concurrency) - output, anyFailed := runDiscoverSchemas(pollCtx, gate, w, warehouseID, args) + output, anyFailed := runDiscoverSchemas(pollCtx, gate, w.StatementExecution, warehouseID, args) if pollCtx.Err() != nil { cancelDiscoverInFlight(ctx, w.StatementExecution, gate.trackedIDs()) @@ -188,13 +186,13 @@ CancelExecution before the command exits.`, // runDiscoverSchemas discovers schemas for tables concurrently and returns the // rendered output. The bool is true if any table failed; per-table errors are // inlined into the output so one bad table doesn't abort the others. -func runDiscoverSchemas(ctx context.Context, gate *sqlGate, w *databricks.WorkspaceClient, warehouseID string, tables []string) (string, bool) { +func runDiscoverSchemas(ctx context.Context, gate *sqlGate, api sqlexec.API, warehouseID string, tables []string) (string, bool) { results := make([]string, len(tables)) var anyFailed atomic.Bool g := new(errgroup.Group) for i, table := range tables { g.Go(func() error { - result, err := discoverTable(ctx, gate, w, warehouseID, table) + result, err := discoverTable(ctx, gate, api, warehouseID, table) if err != nil { results[i] = fmt.Sprintf("Error discovering %s: %v", table, err) anyFailed.Store(true) @@ -230,7 +228,7 @@ func runDiscoverSchemas(ctx context.Context, gate *sqlGate, w *databricks.Worksp // Statements that already finished server-side return an error which we just // swallow at warn level; the alternative (per-statement state tracking) isn't // worth the bookkeeping here. -func cancelDiscoverInFlight(ctx context.Context, api dbsql.StatementExecutionInterface, ids []string) { +func cancelDiscoverInFlight(ctx context.Context, api sqlexec.API, ids []string) { if len(ids) == 0 { cmdio.LogString(ctx, "discover-schema cancelled.") return @@ -247,14 +245,14 @@ func cancelDiscoverInFlight(ctx context.Context, api dbsql.StatementExecutionInt cmdio.LogString(ctx, fmt.Sprintf("discover-schema cancelled; sent CancelExecution for %d statement(s).", len(ids))) } -func discoverTable(ctx context.Context, gate *sqlGate, w *databricks.WorkspaceClient, warehouseID, table string) (string, error) { +func discoverTable(ctx context.Context, gate *sqlGate, api sqlexec.API, warehouseID, table string) (string, error) { quoted, err := quoteTableName(table) if err != nil { return "", err } // 1. describe table - get columns and types - descResult, err := gate.run(ctx, w, warehouseID, "DESCRIBE TABLE "+quoted) + descResult, err := gate.run(ctx, api, warehouseID, "DESCRIBE TABLE "+quoted) if err != nil { return "", fmt.Errorf("describe table: %w", err) } @@ -288,11 +286,11 @@ func discoverTable(ctx context.Context, gate *sqlGate, w *databricks.WorkspaceCl g := new(errgroup.Group) g.Go(func() error { - sampleResult, sampleErr = gate.run(ctx, w, warehouseID, sampleSQL) + sampleResult, sampleErr = gate.run(ctx, api, warehouseID, sampleSQL) return nil }) g.Go(func() error { - nullResult, nullErr = gate.run(ctx, w, warehouseID, nullSQL) + nullResult, nullErr = gate.run(ctx, api, warehouseID, nullSQL) return nil }) _ = g.Wait() diff --git a/experimental/aitools/cmd/discover_schema_test.go b/experimental/aitools/cmd/discover_schema_test.go index d0fae4b24c2..f895e0ce671 100644 --- a/experimental/aitools/cmd/discover_schema_test.go +++ b/experimental/aitools/cmd/discover_schema_test.go @@ -11,9 +11,8 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/sqlexec" - "github.com/databricks/databricks-sdk-go" - mocksql "github.com/databricks/databricks-sdk-go/experimental/mocks/service/sql" - dbsql "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/utils" + dbsql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -68,19 +67,19 @@ func TestParseDescribeResultSkipsMetadataRows(t *testing.T) { func TestSQLGateRunPinsOnWaitTimeoutAndRecordsID(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return req.Statement == "SELECT 1" && - req.WaitTimeout == "0s" && - req.OnWaitTimeout == dbsql.ExecuteStatementRequestOnWaitTimeoutContinue + return utils.Deref(req.Statement) == "SELECT 1" && + utils.Deref(req.WaitTimeout) == "0s" && + req.OnWaitTimeout == dbsql.TimeoutAction_Continue })).Return(&dbsql.StatementResponse{ - StatementId: "stmt-1", - Status: &dbsql.StatementStatus{State: dbsql.StatementStateSucceeded}, - Result: &dbsql.ResultData{DataArray: [][]string{{"1"}}}, + StatementId: new("stmt-1"), + Status: &dbsql.StatementStatus{State: dbsql.StatementStatus_State_Succeeded}, + Result: &dbsql.ResultData{DataArray: rows([][]string{{"1"}})}, }, nil).Once() - w := &databricks.WorkspaceClient{StatementExecution: mockAPI} + w := mockAPI gate := newSQLGate(2) result, err := gate.run(ctx, w, "wh-1", "SELECT 1") @@ -91,17 +90,17 @@ func TestSQLGateRunPinsOnWaitTimeoutAndRecordsID(t *testing.T) { func TestSQLGateRunPropagatesFailedState(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.Anything).Return(&dbsql.StatementResponse{ - StatementId: "stmt-1", + StatementId: new("stmt-1"), Status: &dbsql.StatementStatus{ - State: dbsql.StatementStateFailed, - Error: &dbsql.ServiceError{ErrorCode: "SYNTAX_ERROR", Message: "near 'oops'"}, + State: dbsql.StatementStatus_State_Failed, + Error: &dbsql.ServiceError{ErrorCode: "SYNTAX_ERROR", Message: new("near 'oops'")}, }, }, nil).Once() - w := &databricks.WorkspaceClient{StatementExecution: mockAPI} + w := mockAPI gate := newSQLGate(2) _, err := gate.run(ctx, w, "wh-1", "SELECT oops") @@ -113,12 +112,12 @@ func TestSQLGateRunPropagatesFailedState(t *testing.T) { func TestSQLGateRunWrapsTransportError(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.Anything). Return(nil, errors.New("network unreachable")).Once() - w := &databricks.WorkspaceClient{StatementExecution: mockAPI} + w := mockAPI gate := newSQLGate(2) _, err := gate.run(ctx, w, "wh-1", "SELECT 1") @@ -134,8 +133,8 @@ func TestSQLGateRunRespectsCancelledContext(t *testing.T) { ctx, cancel := context.WithCancel(cmdio.MockDiscard(t.Context())) cancel() - mockAPI := mocksql.NewMockStatementExecutionInterface(t) - w := &databricks.WorkspaceClient{StatementExecution: mockAPI} + mockAPI := newMockStatementAPI(t) + w := mockAPI gate := newSQLGate(2) _, err := gate.run(ctx, w, "wh-1", "SELECT 1") @@ -148,17 +147,17 @@ func TestDiscoverTableRunsSampleAndNullsConcurrently(t *testing.T) { // would time out and return an error, which would surface as // "SAMPLE DATA: Error - " or "NULL COUNTS: Error - " in the output. ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return strings.HasPrefix(req.Statement, "DESCRIBE TABLE") + return strings.HasPrefix(utils.Deref(req.Statement), "DESCRIBE TABLE") })).Return(&dbsql.StatementResponse{ - StatementId: "stmt-desc", - Status: &dbsql.StatementStatus{State: dbsql.StatementStateSucceeded}, - Result: &dbsql.ResultData{DataArray: [][]string{ + StatementId: new("stmt-desc"), + Status: &dbsql.StatementStatus{State: dbsql.StatementStatus_State_Succeeded}, + Result: &dbsql.ResultData{DataArray: rows([][]string{ {"id", "BIGINT", ""}, {"name", "STRING", ""}, - }}, + })}, }, nil).Once() const numProbes = 2 @@ -176,22 +175,22 @@ func TestDiscoverTableRunsSampleAndNullsConcurrently(t *testing.T) { return nil, errors.New("probe timeout: not running concurrently") } return &dbsql.StatementResponse{ - StatementId: "stmt-probe-" + req.Statement[:7], - Status: &dbsql.StatementStatus{State: dbsql.StatementStateSucceeded}, - Manifest: &dbsql.ResultManifest{Schema: &dbsql.ResultSchema{Columns: []dbsql.ColumnInfo{{Name: "x"}}}}, - Result: &dbsql.ResultData{DataArray: [][]string{{"0"}}}, + StatementId: new("stmt-probe-" + (*req.Statement)[:7]), + Status: &dbsql.StatementStatus{State: dbsql.StatementStatus_State_Succeeded}, + Manifest: &dbsql.ResultManifest{Schema: &dbsql.Schema{Columns: []dbsql.ColumnInfo{{Name: new("x")}}}}, + Result: &dbsql.ResultData{DataArray: rows([][]string{{"0"}})}, }, nil } mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return strings.HasPrefix(req.Statement, "SELECT *") + return strings.HasPrefix(utils.Deref(req.Statement), "SELECT *") })).RunAndReturn(probe).Once() mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return strings.Contains(req.Statement, "SUM(CASE WHEN") + return strings.Contains(utils.Deref(req.Statement), "SUM(CASE WHEN") })).RunAndReturn(probe).Once() - w := &databricks.WorkspaceClient{StatementExecution: mockAPI} + w := mockAPI gate := newSQLGate(8) out, err := discoverTable(ctx, gate, w, "wh-1", "main.public.orders") @@ -205,36 +204,36 @@ func TestDiscoverTableRunsSampleAndNullsConcurrently(t *testing.T) { func TestDiscoverTableSampleErrorDoesNotAbortNullCounts(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return strings.HasPrefix(req.Statement, "DESCRIBE TABLE") + return strings.HasPrefix(utils.Deref(req.Statement), "DESCRIBE TABLE") })).Return(&dbsql.StatementResponse{ - StatementId: "stmt-desc", - Status: &dbsql.StatementStatus{State: dbsql.StatementStateSucceeded}, - Result: &dbsql.ResultData{DataArray: [][]string{{"id", "BIGINT", ""}}}, + StatementId: new("stmt-desc"), + Status: &dbsql.StatementStatus{State: dbsql.StatementStatus_State_Succeeded}, + Result: &dbsql.ResultData{DataArray: rows([][]string{{"id", "BIGINT", ""}})}, }, nil).Once() mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return strings.HasPrefix(req.Statement, "SELECT *") + return strings.HasPrefix(utils.Deref(req.Statement), "SELECT *") })).Return(&dbsql.StatementResponse{ - StatementId: "stmt-sample", + StatementId: new("stmt-sample"), Status: &dbsql.StatementStatus{ - State: dbsql.StatementStateFailed, - Error: &dbsql.ServiceError{ErrorCode: "PERM", Message: "permission denied"}, + State: dbsql.StatementStatus_State_Failed, + Error: &dbsql.ServiceError{ErrorCode: "PERM", Message: new("permission denied")}, }, }, nil).Once() mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return strings.Contains(req.Statement, "SUM(CASE WHEN") + return strings.Contains(utils.Deref(req.Statement), "SUM(CASE WHEN") })).Return(&dbsql.StatementResponse{ - StatementId: "stmt-null", - Status: &dbsql.StatementStatus{State: dbsql.StatementStateSucceeded}, - Manifest: &dbsql.ResultManifest{Schema: &dbsql.ResultSchema{Columns: []dbsql.ColumnInfo{{Name: "total_rows"}, {Name: "id_nulls"}}}}, - Result: &dbsql.ResultData{DataArray: [][]string{{"100", "0"}}}, + StatementId: new("stmt-null"), + Status: &dbsql.StatementStatus{State: dbsql.StatementStatus_State_Succeeded}, + Manifest: &dbsql.ResultManifest{Schema: &dbsql.Schema{Columns: []dbsql.ColumnInfo{{Name: new("total_rows")}, {Name: new("id_nulls")}}}}, + Result: &dbsql.ResultData{DataArray: rows([][]string{{"100", "0"}})}, }, nil).Once() - w := &databricks.WorkspaceClient{StatementExecution: mockAPI} + w := mockAPI gate := newSQLGate(8) out, err := discoverTable(ctx, gate, w, "wh-1", "main.public.orders") @@ -251,39 +250,39 @@ func TestDiscoverTableEscapesBackticksInColumnNames(t *testing.T) { // escaping in the null-counts SQL the embedded backtick would terminate // the quoted identifier mid-string and produce a PARSE_SYNTAX_ERROR. ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return strings.HasPrefix(req.Statement, "DESCRIBE TABLE") + return strings.HasPrefix(utils.Deref(req.Statement), "DESCRIBE TABLE") })).Return(&dbsql.StatementResponse{ - StatementId: "stmt-desc", - Status: &dbsql.StatementStatus{State: dbsql.StatementStateSucceeded}, - Result: &dbsql.ResultData{DataArray: [][]string{ + StatementId: new("stmt-desc"), + Status: &dbsql.StatementStatus{State: dbsql.StatementStatus_State_Succeeded}, + Result: &dbsql.ResultData{DataArray: rows([][]string{ {"weird`col", "STRING", ""}, - }}, + })}, }, nil).Once() mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return strings.HasPrefix(req.Statement, "SELECT *") + return strings.HasPrefix(utils.Deref(req.Statement), "SELECT *") })).Return(&dbsql.StatementResponse{ - StatementId: "stmt-sample", - Status: &dbsql.StatementStatus{State: dbsql.StatementStateSucceeded}, + StatementId: new("stmt-sample"), + Status: &dbsql.StatementStatus{State: dbsql.StatementStatus_State_Succeeded}, }, nil).Once() // Null-counts SQL must escape the embedded backtick. Both the identifier // and the alias positions must use the doubled form. mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return strings.Contains(req.Statement, "`weird``col`") && - strings.Contains(req.Statement, "`weird``col_nulls`") && - !strings.Contains(req.Statement, "`weird`col`") + return strings.Contains(utils.Deref(req.Statement), "`weird``col`") && + strings.Contains(utils.Deref(req.Statement), "`weird``col_nulls`") && + !strings.Contains(utils.Deref(req.Statement), "`weird`col`") })).Return(&dbsql.StatementResponse{ - StatementId: "stmt-null", - Status: &dbsql.StatementStatus{State: dbsql.StatementStateSucceeded}, - Manifest: &dbsql.ResultManifest{Schema: &dbsql.ResultSchema{Columns: []dbsql.ColumnInfo{{Name: "total_rows"}, {Name: "weird`col_nulls"}}}}, - Result: &dbsql.ResultData{DataArray: [][]string{{"5", "0"}}}, + StatementId: new("stmt-null"), + Status: &dbsql.StatementStatus{State: dbsql.StatementStatus_State_Succeeded}, + Manifest: &dbsql.ResultManifest{Schema: &dbsql.Schema{Columns: []dbsql.ColumnInfo{{Name: new("total_rows")}, {Name: new("weird`col_nulls")}}}}, + Result: &dbsql.ResultData{DataArray: rows([][]string{{"5", "0"}})}, }, nil).Once() - w := &databricks.WorkspaceClient{StatementExecution: mockAPI} + w := mockAPI gate := newSQLGate(8) out, err := discoverTable(ctx, gate, w, "wh-1", "main.public.orders") @@ -294,12 +293,10 @@ func TestDiscoverTableEscapesBackticksInColumnNames(t *testing.T) { func TestCancelDiscoverInFlightCallsAPIPerID(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) for _, id := range []string{"stmt-a", "stmt-b", "stmt-c"} { - mockAPI.EXPECT().CancelExecution(mock.Anything, dbsql.CancelExecutionRequest{ - StatementId: id, - }).Return(nil).Once() + mockAPI.EXPECT().CancelStatement(mock.Anything, id).Return(nil).Once() } cancelDiscoverInFlight(ctx, mockAPI, []string{"stmt-a", "stmt-b", "stmt-c"}) @@ -331,17 +328,17 @@ func TestRunDiscoverSchemasFlagsTableFailureForExitCode(t *testing.T) { // return so the caller can produce a non-zero exit. Without this signal // scripts and CI parse stdout to detect failure, which is brittle. ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.Anything).Return(&dbsql.StatementResponse{ - StatementId: "stmt-bad", + StatementId: new("stmt-bad"), Status: &dbsql.StatementStatus{ - State: dbsql.StatementStateFailed, - Error: &dbsql.ServiceError{ErrorCode: "TABLE_OR_VIEW_NOT_FOUND", Message: "no such table"}, + State: dbsql.StatementStatus_State_Failed, + Error: &dbsql.ServiceError{ErrorCode: "TABLE_OR_VIEW_NOT_FOUND", Message: new("no such table")}, }, }, nil).Once() - w := &databricks.WorkspaceClient{StatementExecution: mockAPI} + w := mockAPI output, anyFailed := runDiscoverSchemas(ctx, newSQLGate(8), w, "wh-1", []string{"main.public.missing"}) assert.True(t, anyFailed) @@ -351,33 +348,33 @@ func TestRunDiscoverSchemasFlagsTableFailureForExitCode(t *testing.T) { func TestRunDiscoverSchemasAllSucceedReturnsFalse(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return strings.HasPrefix(req.Statement, "DESCRIBE TABLE") + return strings.HasPrefix(utils.Deref(req.Statement), "DESCRIBE TABLE") })).Return(&dbsql.StatementResponse{ - StatementId: "stmt-desc", - Status: &dbsql.StatementStatus{State: dbsql.StatementStateSucceeded}, - Result: &dbsql.ResultData{DataArray: [][]string{{"id", "BIGINT", ""}}}, + StatementId: new("stmt-desc"), + Status: &dbsql.StatementStatus{State: dbsql.StatementStatus_State_Succeeded}, + Result: &dbsql.ResultData{DataArray: rows([][]string{{"id", "BIGINT", ""}})}, }, nil).Once() mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return strings.HasPrefix(req.Statement, "SELECT *") + return strings.HasPrefix(utils.Deref(req.Statement), "SELECT *") })).Return(&dbsql.StatementResponse{ - StatementId: "stmt-sample", - Status: &dbsql.StatementStatus{State: dbsql.StatementStateSucceeded}, + StatementId: new("stmt-sample"), + Status: &dbsql.StatementStatus{State: dbsql.StatementStatus_State_Succeeded}, }, nil).Once() mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req dbsql.ExecuteStatementRequest) bool { - return strings.Contains(req.Statement, "SUM(CASE WHEN") + return strings.Contains(utils.Deref(req.Statement), "SUM(CASE WHEN") })).Return(&dbsql.StatementResponse{ - StatementId: "stmt-null", - Status: &dbsql.StatementStatus{State: dbsql.StatementStateSucceeded}, - Manifest: &dbsql.ResultManifest{Schema: &dbsql.ResultSchema{Columns: []dbsql.ColumnInfo{{Name: "total_rows"}, {Name: "id_nulls"}}}}, - Result: &dbsql.ResultData{DataArray: [][]string{{"7", "0"}}}, + StatementId: new("stmt-null"), + Status: &dbsql.StatementStatus{State: dbsql.StatementStatus_State_Succeeded}, + Manifest: &dbsql.ResultManifest{Schema: &dbsql.Schema{Columns: []dbsql.ColumnInfo{{Name: new("total_rows")}, {Name: new("id_nulls")}}}}, + Result: &dbsql.ResultData{DataArray: rows([][]string{{"7", "0"}})}, }, nil).Once() - w := &databricks.WorkspaceClient{StatementExecution: mockAPI} + w := mockAPI output, anyFailed := runDiscoverSchemas(ctx, newSQLGate(8), w, "wh-1", []string{"main.public.orders"}) assert.False(t, anyFailed) diff --git a/experimental/aitools/cmd/get_default_warehouse.go b/experimental/aitools/cmd/get_default_warehouse.go index 446541e9d91..54c2976a3b7 100644 --- a/experimental/aitools/cmd/get_default_warehouse.go +++ b/experimental/aitools/cmd/get_default_warehouse.go @@ -6,14 +6,15 @@ import ( "github.com/databricks/cli/experimental/aitools/lib/session" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/utils" + sql "github.com/databricks/sdk-go/warehouses/v1" "github.com/spf13/cobra" ) type warehouseInfo struct { - Id string `json:"id"` - Name string `json:"name"` - State sql.State `json:"state"` + Id string `json:"id"` + Name string `json:"name"` + State sql.EndpointState `json:"state"` } func newGetDefaultWarehouseCmd() *cobra.Command { @@ -49,8 +50,8 @@ Returns warehouse ID of the default warehouse. Use --output json to get the full } info := warehouseInfo{ - Id: warehouse.Id, - Name: warehouse.Name, + Id: utils.Deref(warehouse.Id), + Name: utils.Deref(warehouse.Name), State: warehouse.State, } diff --git a/experimental/aitools/cmd/mock_statement_api_test.go b/experimental/aitools/cmd/mock_statement_api_test.go new file mode 100644 index 00000000000..5dfa792285c --- /dev/null +++ b/experimental/aitools/cmd/mock_statement_api_test.go @@ -0,0 +1,102 @@ +package aitools + +import ( + "context" + "encoding/json" + + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/options/call" + sql "github.com/databricks/sdk-go/statementexecution/v1" + "github.com/stretchr/testify/mock" +) + +// mockStatementAPI is a testify mock of sqlexec.API. Expectations match on the +// request (ExecuteStatement) or on the statement ID and chunk index. +type mockStatementAPI struct { + mock.Mock +} + +func newMockStatementAPI(t interface { + mock.TestingT + Cleanup(func()) +}, +) *mockStatementAPI { + m := &mockStatementAPI{} + m.Test(t) + t.Cleanup(func() { m.AssertExpectations(t) }) + return m +} + +func (m *mockStatementAPI) ExecuteStatement(ctx context.Context, req sql.ExecuteStatementRequest, _ ...call.Option) (*sql.StatementResponse, error) { + args := m.Called(ctx, req) + if f, ok := args.Get(0).(func(context.Context, sql.ExecuteStatementRequest) (*sql.StatementResponse, error)); ok { + return f(ctx, req) + } + resp, _ := args.Get(0).(*sql.StatementResponse) + return resp, args.Error(1) +} + +func (m *mockStatementAPI) GetStatementResult(ctx context.Context, req sql.GetStatementResultRequest, _ ...call.Option) (*sql.StatementResponse, error) { + args := m.Called(ctx, utils.Deref(req.StatementId)) + resp, _ := args.Get(0).(*sql.StatementResponse) + return resp, args.Error(1) +} + +func (m *mockStatementAPI) GetResultData(ctx context.Context, req sql.GetResultDataRequest, _ ...call.Option) (*sql.ResultData, error) { + args := m.Called(ctx, utils.Deref(req.StatementId), utils.Deref(req.ChunkIndex)) + resp, _ := args.Get(0).(*sql.ResultData) + return resp, args.Error(1) +} + +func (m *mockStatementAPI) CancelStatement(ctx context.Context, req sql.CancelStatementRequest, _ ...call.Option) (*sql.CancelStatementResponse, error) { + args := m.Called(ctx, utils.Deref(req.StatementId)) + return &sql.CancelStatementResponse{}, args.Error(0) +} + +func (m *mockStatementAPI) EXPECT() mockStatementAPIExpecter { + return mockStatementAPIExpecter{m: &m.Mock} +} + +type mockStatementAPIExpecter struct { + m *mock.Mock +} + +func (e mockStatementAPIExpecter) ExecuteStatement(ctx, req any) executeStatementCall { + return executeStatementCall{e.m.On("ExecuteStatement", ctx, req)} +} + +func (e mockStatementAPIExpecter) GetStatementResult(ctx, statementID any) *mock.Call { + return e.m.On("GetStatementResult", ctx, statementID) +} + +func (e mockStatementAPIExpecter) GetResultData(ctx, statementID, chunkIndex any) *mock.Call { + return e.m.On("GetResultData", ctx, statementID, chunkIndex) +} + +func (e mockStatementAPIExpecter) CancelStatement(ctx, statementID any) *mock.Call { + return e.m.On("CancelStatement", ctx, statementID) +} + +type executeStatementCall struct { + *mock.Call +} + +// RunAndReturn answers each matching call with f. +func (c executeStatementCall) RunAndReturn(f func(context.Context, sql.ExecuteStatementRequest) (*sql.StatementResponse, error)) *mock.Call { + return c.Return(f, nil) +} + +// rows encodes cells the way the API returns JSON_ARRAY results. +func rows(data [][]string) [][]json.RawMessage { + if data == nil { + return nil + } + out := make([][]json.RawMessage, len(data)) + for i, row := range data { + out[i] = make([]json.RawMessage, len(row)) + for j, cell := range row { + out[i][j], _ = json.Marshal(cell) + } + } + return out +} diff --git a/experimental/aitools/cmd/params.go b/experimental/aitools/cmd/params.go index 5edc9e17fca..96d1e46eb9f 100644 --- a/experimental/aitools/cmd/params.go +++ b/experimental/aitools/cmd/params.go @@ -4,23 +4,24 @@ import ( "fmt" "strings" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/utils" + sql "github.com/databricks/sdk-go/statementexecution/v1" ) // parseParams converts --param flag values into SDK parameter list items for // the Databricks SQL Statement Execution API. Each input is either // "name=value" (defaults to STRING server-side) or "name:TYPE=value" (typed, -// e.g. "since:DATE=2026-01-01"). An empty value becomes NULL on the wire -// because StatementParameterListItem.Value uses omitempty. +// e.g. "since:DATE=2026-01-01"). An empty value is left unset, which the API +// treats as NULL. // // The Databricks API only supports named markers (`:name`), not positional // `?`, and parameter names must be unique within a statement. -func parseParams(raw []string) ([]sql.StatementParameterListItem, error) { +func parseParams(raw []string) ([]sql.StatementParameter, error) { if len(raw) == 0 { return nil, nil } - out := make([]sql.StatementParameterListItem, 0, len(raw)) + out := make([]sql.StatementParameter, 0, len(raw)) seen := make(map[string]struct{}, len(raw)) for _, s := range raw { lhs, value, ok := strings.Cut(s, "=") @@ -40,10 +41,10 @@ func parseParams(raw []string) ([]sql.StatementParameterListItem, error) { } seen[name] = struct{}{} - out = append(out, sql.StatementParameterListItem{ - Name: name, - Type: typ, - Value: value, + out = append(out, sql.StatementParameter{ + Name: new(name), + Type: utils.NonZero(typ), + Value: utils.NonZero(value), }) } return out, nil diff --git a/experimental/aitools/cmd/params_test.go b/experimental/aitools/cmd/params_test.go index e4a56f8a878..a1bf3ec1978 100644 --- a/experimental/aitools/cmd/params_test.go +++ b/experimental/aitools/cmd/params_test.go @@ -3,7 +3,7 @@ package aitools import ( "testing" - "github.com/databricks/databricks-sdk-go/service/sql" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -12,7 +12,7 @@ func TestParseParams(t *testing.T) { tests := []struct { name string in []string - want []sql.StatementParameterListItem + want []sql.StatementParameter }{ { name: "nil input returns nil", @@ -27,52 +27,52 @@ func TestParseParams(t *testing.T) { { name: "single string param defaults type to empty (server-side STRING)", in: []string{"name=alice"}, - want: []sql.StatementParameterListItem{ - {Name: "name", Value: "alice"}, + want: []sql.StatementParameter{ + {Name: new("name"), Value: new("alice")}, }, }, { name: "typed param splits name and type on first colon", in: []string{"since:DATE=2026-01-01"}, - want: []sql.StatementParameterListItem{ - {Name: "since", Type: "DATE", Value: "2026-01-01"}, + want: []sql.StatementParameter{ + {Name: new("since"), Type: new("DATE"), Value: new("2026-01-01")}, }, }, { name: "value can contain = and :", in: []string{"clause=ts >= '2026-01-01T00:00:00'"}, - want: []sql.StatementParameterListItem{ - {Name: "clause", Value: "ts >= '2026-01-01T00:00:00'"}, + want: []sql.StatementParameter{ + {Name: new("clause"), Value: new("ts >= '2026-01-01T00:00:00'")}, }, }, { name: "decimal type with parens preserved", in: []string{"amount:DECIMAL(10,2)=42.50"}, - want: []sql.StatementParameterListItem{ - {Name: "amount", Type: "DECIMAL(10,2)", Value: "42.50"}, + want: []sql.StatementParameter{ + {Name: new("amount"), Type: new("DECIMAL(10,2)"), Value: new("42.50")}, }, }, { - name: "empty value becomes NULL on the wire via omitempty", + name: "empty value becomes NULL on the wire as an unset value", in: []string{"opt="}, - want: []sql.StatementParameterListItem{ - {Name: "opt", Value: ""}, + want: []sql.StatementParameter{ + {Name: new("opt")}, }, }, { name: "whitespace around name and type is trimmed", in: []string{" name : INT =42"}, - want: []sql.StatementParameterListItem{ - {Name: "name", Type: "INT", Value: "42"}, + want: []sql.StatementParameter{ + {Name: new("name"), Type: new("INT"), Value: new("42")}, }, }, { name: "multiple params preserve input order", in: []string{"a=1", "b:INT=2", "c=three"}, - want: []sql.StatementParameterListItem{ - {Name: "a", Value: "1"}, - {Name: "b", Type: "INT", Value: "2"}, - {Name: "c", Value: "three"}, + want: []sql.StatementParameter{ + {Name: new("a"), Value: new("1")}, + {Name: new("b"), Type: new("INT"), Value: new("2")}, + {Name: new("c"), Value: new("three")}, }, }, } diff --git a/experimental/aitools/cmd/query.go b/experimental/aitools/cmd/query.go index 5fbe8eebe80..feb2fb1e0af 100644 --- a/experimental/aitools/cmd/query.go +++ b/experimental/aitools/cmd/query.go @@ -18,7 +18,7 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/sqlexec" - "github.com/databricks/databricks-sdk-go/service/sql" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/spf13/cobra" ) @@ -64,7 +64,7 @@ func newQueryCmd() *cobra.Command { var outputFormat string var concurrency int var paramFlags []string - var params []sql.StatementParameterListItem + var params []sql.StatementParameter cmd := &cobra.Command{ Use: "query [SQL | file.sql]...", @@ -239,7 +239,7 @@ func resolveSQLs(ctx context.Context, cmd *cobra.Command, args, filePaths []stri // rejecting incompatible output formats before invoking this. // // params, if non-nil, are applied to every statement in the batch. -func runBatch(ctx context.Context, cmd *cobra.Command, api sql.StatementExecutionInterface, warehouseID string, sqls []string, params []sql.StatementParameterListItem, concurrency int) error { +func runBatch(ctx context.Context, cmd *cobra.Command, api sqlexec.API, warehouseID string, sqls []string, params []sql.StatementParameter, concurrency int) error { results := executeBatch(ctx, api, warehouseID, sqls, params, concurrency) if err := renderBatchJSON(cmd.OutOrStdout(), results); err != nil { return err @@ -269,7 +269,7 @@ func resolveWarehouseID(ctx context.Context, w any, flagValue string) (string, e // executeAndPoll submits a SQL statement asynchronously and polls until completion. // It shows a spinner in interactive mode and supports Ctrl+C cancellation. -func executeAndPoll(ctx context.Context, client *sqlexec.Client, statement string, params []sql.StatementParameterListItem) (*sqlexec.Statement, error) { +func executeAndPoll(ctx context.Context, client *sqlexec.Client, statement string, params []sql.StatementParameter) (*sqlexec.Statement, error) { // Submit asynchronously to get the statement ID immediately for cancellation. stmt, err := client.Submit(ctx, statement, sqlexec.WithParameters(params)) if err != nil { @@ -360,7 +360,7 @@ func presentQueryError(err error) error { } switch se.State { - case sql.StatementStateFailed: + case sql.StatementStatus_State_Failed: msg := "query failed" // The engine populates Code only when the backend returned a // ServiceError; otherwise Message is a synthesized state string we @@ -373,9 +373,9 @@ func presentQueryError(err error) error { } } return errors.New(msg) - case sql.StatementStateCanceled: + case sql.StatementStatus_State_Canceled: return errors.New("query was cancelled") - case sql.StatementStateClosed: + case sql.StatementStatus_State_Closed: return errors.New("query was closed before results could be fetched") default: return err diff --git a/experimental/aitools/cmd/query_test.go b/experimental/aitools/cmd/query_test.go index 66e70b238ee..ffb4df82132 100644 --- a/experimental/aitools/cmd/query_test.go +++ b/experimental/aitools/cmd/query_test.go @@ -13,8 +13,8 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/sqlexec" - mocksql "github.com/databricks/databricks-sdk-go/experimental/mocks/service/sql" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/utils" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -46,39 +46,39 @@ func TestCleanSQL(t *testing.T) { func TestExecuteAndPollImmediateSuccess(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.WarehouseId == "wh-123" && req.Statement == "SELECT 1" && - req.WaitTimeout == "0s" && - req.OnWaitTimeout == sql.ExecuteStatementRequestOnWaitTimeoutContinue + return utils.Deref(req.WarehouseId) == "wh-123" && utils.Deref(req.Statement) == "SELECT 1" && + utils.Deref(req.WaitTimeout) == "0s" && + req.OnWaitTimeout == sql.TimeoutAction_Continue })).Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, - Manifest: &sql.ResultManifest{Schema: &sql.ResultSchema{Columns: []sql.ColumnInfo{{Name: "1"}}}}, - Result: &sql.ResultData{DataArray: [][]string{{"1"}}}, + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, + Manifest: &sql.ResultManifest{Schema: &sql.Schema{Columns: []sql.ColumnInfo{{Name: new("1")}}}}, + Result: &sql.ResultData{DataArray: rows([][]string{{"1"}})}, }, nil) stmt, err := executeAndPoll(ctx, sqlexec.New(mockAPI, "wh-123"), "SELECT 1", nil) require.NoError(t, err) - assert.Equal(t, sql.StatementStateSucceeded, stmt.State) + assert.Equal(t, sql.StatementStatus_State_Succeeded, stmt.State) assert.Equal(t, "stmt-1", stmt.ID) } func TestExecuteAndPollPassesParameters(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) - params := []sql.StatementParameterListItem{ - {Name: "name", Value: "alice"}, - {Name: "since", Type: "DATE", Value: "2026-01-01"}, + params := []sql.StatementParameter{ + {Name: new("name"), Value: new("alice")}, + {Name: new("since"), Type: new("DATE"), Value: new("2026-01-01")}, } mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { return assert.ObjectsAreEqual(params, req.Parameters) })).Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, }, nil) _, err := executeAndPoll(ctx, sqlexec.New(mockAPI, "wh-123"), "SELECT * FROM t WHERE name = :name AND ts > :since", params) @@ -87,15 +87,15 @@ func TestExecuteAndPollPassesParameters(t *testing.T) { func TestExecuteAndPollImmediateFailure(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.Anything).Return(&sql.StatementResponse{ - StatementId: "stmt-1", + StatementId: new("stmt-1"), Status: &sql.StatementStatus{ - State: sql.StatementStateFailed, + State: sql.StatementStatus_State_Failed, Error: &sql.ServiceError{ ErrorCode: "SYNTAX_ERROR", - Message: "near 'SELCT': syntax error", + Message: new("near 'SELCT': syntax error"), }, }, }, nil) @@ -108,31 +108,31 @@ func TestExecuteAndPollImmediateFailure(t *testing.T) { func TestExecuteAndPollWithPolling(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.Anything).Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStatePending}, + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Pending}, }, nil) // First poll: still RUNNING. - mockAPI.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStateRunning}, + mockAPI.EXPECT().GetStatementResult(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Running}, }, nil).Once() // Second poll: SUCCEEDED. - mockAPI.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, - Manifest: &sql.ResultManifest{Schema: &sql.ResultSchema{Columns: []sql.ColumnInfo{{Name: "result"}}}}, - Result: &sql.ResultData{DataArray: [][]string{{"42"}}}, + mockAPI.EXPECT().GetStatementResult(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, + Manifest: &sql.ResultManifest{Schema: &sql.Schema{Columns: []sql.ColumnInfo{{Name: new("result")}}}}, + Result: &sql.ResultData{DataArray: rows([][]string{{"42"}})}, }, nil).Once() client := sqlexec.New(mockAPI, "wh-123") stmt, err := executeAndPoll(ctx, client, "SELECT 42", nil) require.NoError(t, err) - assert.Equal(t, sql.StatementStateSucceeded, stmt.State) + assert.Equal(t, sql.StatementStatus_State_Succeeded, stmt.State) result, err := client.Results(ctx, stmt) require.NoError(t, err) @@ -141,18 +141,18 @@ func TestExecuteAndPollWithPolling(t *testing.T) { func TestExecuteAndPollFailsDuringPolling(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.Anything).Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStatePending}, + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Pending}, }, nil) - mockAPI.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ - StatementId: "stmt-1", + mockAPI.EXPECT().GetStatementResult(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ + StatementId: new("stmt-1"), Status: &sql.StatementStatus{ - State: sql.StatementStateFailed, - Error: &sql.ServiceError{ErrorCode: "RESOURCE_EXHAUSTED", Message: "warehouse unavailable"}, + State: sql.StatementStatus_State_Failed, + Error: &sql.ServiceError{ErrorCode: "RESOURCE_EXHAUSTED", Message: new("warehouse unavailable")}, }, }, nil).Once() @@ -163,21 +163,19 @@ func TestExecuteAndPollFailsDuringPolling(t *testing.T) { func TestExecuteAndPollCancelledContextCallsCancelExecution(t *testing.T) { ctx, cancel := context.WithCancel(cmdio.MockDiscard(t.Context())) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.Anything).Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStatePending}, + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Pending}, }, nil) // CancelExecution must be called when context is cancelled (not just on // signal). Assert the RPC's own ctx is NOT cancelled, otherwise the SDK // would short-circuit on ctx.Err() and never reach the warehouse. - mockAPI.EXPECT().CancelExecution(mock.MatchedBy(func(c context.Context) bool { + mockAPI.EXPECT().CancelStatement(mock.MatchedBy(func(c context.Context) bool { return c.Err() == nil - }), sql.CancelExecutionRequest{ - StatementId: "stmt-1", - }).Return(nil).Once() + }), "stmt-1").Return(nil).Once() cancel() @@ -200,25 +198,25 @@ func TestPresentQueryError(t *testing.T) { assert.Equal(t, plain, presentQueryError(plain)) err := presentQueryError(&sqlexec.StatementError{ - State: sql.StatementStateFailed, + State: sql.StatementStatus_State_Failed, Code: "ERR", Message: "bad", }) require.Error(t, err) assert.Contains(t, err.Error(), "query failed: ERR bad") - err = presentQueryError(&sqlexec.StatementError{State: sql.StatementStateCanceled}) + err = presentQueryError(&sqlexec.StatementError{State: sql.StatementStatus_State_Canceled}) require.Error(t, err) assert.Contains(t, err.Error(), "cancelled") - err = presentQueryError(&sqlexec.StatementError{State: sql.StatementStateClosed}) + err = presentQueryError(&sqlexec.StatementError{State: sql.StatementStatus_State_Closed}) require.Error(t, err) assert.Contains(t, err.Error(), "closed") } func TestPresentQueryErrorMapKeyHint(t *testing.T) { err := presentQueryError(&sqlexec.StatementError{ - State: sql.StatementStateFailed, + State: sql.StatementStatus_State_Failed, Code: "BAD_REQUEST", Message: "[UNRESOLVED_MAP_KEY.WITH_SUGGESTION] Cannot resolve column", }) diff --git a/experimental/aitools/cmd/statement.go b/experimental/aitools/cmd/statement.go index 13d2f70e316..81eafe8a160 100644 --- a/experimental/aitools/cmd/statement.go +++ b/experimental/aitools/cmd/statement.go @@ -7,7 +7,7 @@ import ( "io" "github.com/databricks/cli/libs/sqlexec" - "github.com/databricks/databricks-sdk-go/service/sql" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/spf13/cobra" ) @@ -16,12 +16,12 @@ import ( // the output tight: `submit` doesn't emit columns/rows, `cancel` doesn't emit a // warehouse_id, etc. type statementInfo struct { - StatementID string `json:"statement_id"` - State sql.StatementState `json:"state,omitempty"` - WarehouseID string `json:"warehouse_id,omitempty"` - Columns []string `json:"columns,omitempty"` - Rows [][]string `json:"rows,omitempty"` - Error *batchResultError `json:"error,omitempty"` + StatementID string `json:"statement_id"` + State sql.StatementStatus_State `json:"state,omitempty"` + WarehouseID string `json:"warehouse_id,omitempty"` + Columns []string `json:"columns,omitempty"` + Rows [][]string `json:"rows,omitempty"` + Error *batchResultError `json:"error,omitempty"` } func renderStatementInfo(w io.Writer, info statementInfo) error { diff --git a/experimental/aitools/cmd/statement_cancel.go b/experimental/aitools/cmd/statement_cancel.go index 912f20d83d6..e680d6f417e 100644 --- a/experimental/aitools/cmd/statement_cancel.go +++ b/experimental/aitools/cmd/statement_cancel.go @@ -6,7 +6,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/sqlexec" - "github.com/databricks/databricks-sdk-go/service/sql" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/spf13/cobra" ) @@ -40,7 +40,7 @@ the server-side state if you need certainty.`, // cancelStatementExecution issues CancelExecution and reports state=CANCELED on success. // CancelExecution returns no body; the actual server-side state is verified // asynchronously. Use 'statement status' to confirm if certainty is required. -func cancelStatementExecution(ctx context.Context, api sql.StatementExecutionInterface, statementID string) (statementInfo, error) { +func cancelStatementExecution(ctx context.Context, api sqlexec.API, statementID string) (statementInfo, error) { // Cancel doesn't use the warehouse ID. client := sqlexec.New(api, "") if err := client.Cancel(ctx, statementID); err != nil { @@ -48,6 +48,6 @@ func cancelStatementExecution(ctx context.Context, api sql.StatementExecutionInt } return statementInfo{ StatementID: statementID, - State: sql.StatementStateCanceled, + State: sql.StatementStatus_State_Canceled, }, nil } diff --git a/experimental/aitools/cmd/statement_get.go b/experimental/aitools/cmd/statement_get.go index fe011464a0c..b8d2507beaa 100644 --- a/experimental/aitools/cmd/statement_get.go +++ b/experimental/aitools/cmd/statement_get.go @@ -7,7 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/sqlexec" - "github.com/databricks/databricks-sdk-go/service/sql" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/spf13/cobra" ) @@ -42,7 +42,7 @@ invoked the synchronous path.)`, // Non-zero exit when the statement reached a non-success terminal // state OR a chunk-fetch failure prevented assembling the rows. // In both cases the failure detail is already in the JSON output. - if info.State != sql.StatementStateSucceeded || info.Error != nil { + if info.State != sql.StatementStatus_State_Succeeded || info.Error != nil { return root.ErrAlreadyPrinted } return nil @@ -58,7 +58,7 @@ invoked the synchronous path.)`, // Context cancellation propagates from the poll WITHOUT cancelling the // server-side statement (intentional: 'get' is a poll-only operation; use // 'cancel' to terminate explicitly). -func getStatementResult(ctx context.Context, api sql.StatementExecutionInterface, statementID string) (statementInfo, error) { +func getStatementResult(ctx context.Context, api sqlexec.API, statementID string) (statementInfo, error) { // Get/Poll don't use the warehouse ID. client := sqlexec.New(api, "") @@ -80,7 +80,7 @@ func getStatementResult(ctx context.Context, api sql.StatementExecutionInterface Error: statementError(stmt.Err()), } - if info.State == sql.StatementStateSucceeded { + if info.State == sql.StatementStatus_State_Succeeded { result, err := client.Results(ctx, stmt) if err != nil { // The query succeeded server-side but a later chunk fetch failed diff --git a/experimental/aitools/cmd/statement_status.go b/experimental/aitools/cmd/statement_status.go index 91ea9c36408..d47e5475267 100644 --- a/experimental/aitools/cmd/statement_status.go +++ b/experimental/aitools/cmd/statement_status.go @@ -6,7 +6,6 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/sqlexec" - "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" ) @@ -37,7 +36,7 @@ without blocking. For a blocking poll-until-terminal call, use } // getStatementStatus performs a single GET against the Statements API, no polling. -func getStatementStatus(ctx context.Context, api sql.StatementExecutionInterface, statementID string) (statementInfo, error) { +func getStatementStatus(ctx context.Context, api sqlexec.API, statementID string) (statementInfo, error) { // Get doesn't use the warehouse ID. client := sqlexec.New(api, "") stmt, err := client.Get(ctx, statementID) diff --git a/experimental/aitools/cmd/statement_submit.go b/experimental/aitools/cmd/statement_submit.go index 716f6550ee0..5ef7a7dca89 100644 --- a/experimental/aitools/cmd/statement_submit.go +++ b/experimental/aitools/cmd/statement_submit.go @@ -7,7 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/sqlexec" - "github.com/databricks/databricks-sdk-go/service/sql" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/spf13/cobra" ) @@ -19,7 +19,7 @@ func newStatementSubmitCmd() *cobra.Command { // work and the documented "validates input before WorkspaceClient" claim // in the PR description is actually true. var sqlStatement string - var params []sql.StatementParameterListItem + var params []sql.StatementParameter cmd := &cobra.Command{ Use: "submit [SQL | file.sql]", @@ -85,7 +85,7 @@ bind values.`, } // submitStatement issues an asynchronous ExecuteStatement and returns the handle. -func submitStatement(ctx context.Context, api sql.StatementExecutionInterface, statement, warehouseID string, params []sql.StatementParameterListItem) (statementInfo, error) { +func submitStatement(ctx context.Context, api sqlexec.API, statement, warehouseID string, params []sql.StatementParameter) (statementInfo, error) { client := sqlexec.New(api, warehouseID) stmt, err := client.Submit(ctx, statement, sqlexec.WithParameters(params)) if err != nil { diff --git a/experimental/aitools/cmd/statement_test.go b/experimental/aitools/cmd/statement_test.go index e6905b3f20d..4befdd075fb 100644 --- a/experimental/aitools/cmd/statement_test.go +++ b/experimental/aitools/cmd/statement_test.go @@ -10,8 +10,8 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/sqlexec" - mocksql "github.com/databricks/databricks-sdk-go/experimental/mocks/service/sql" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/utils" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -19,37 +19,37 @@ import ( func TestSubmitStatementReturnsHandle(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.WarehouseId == "wh-1" && req.Statement == "SELECT 1" && - req.WaitTimeout == "0s" && - req.OnWaitTimeout == sql.ExecuteStatementRequestOnWaitTimeoutContinue + return utils.Deref(req.WarehouseId) == "wh-1" && utils.Deref(req.Statement) == "SELECT 1" && + utils.Deref(req.WaitTimeout) == "0s" && + req.OnWaitTimeout == sql.TimeoutAction_Continue })).Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStatePending}, + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Pending}, }, nil).Once() info, err := submitStatement(ctx, mockAPI, "SELECT 1", "wh-1", nil) require.NoError(t, err) assert.Equal(t, "stmt-1", info.StatementID) - assert.Equal(t, sql.StatementStatePending, info.State) + assert.Equal(t, sql.StatementStatus_State_Pending, info.State) assert.Equal(t, "wh-1", info.WarehouseID) } func TestSubmitStatementPassesParameters(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) - params := []sql.StatementParameterListItem{ - {Name: "since", Type: "DATE", Value: "2026-01-01"}, + params := []sql.StatementParameter{ + {Name: new("since"), Type: new("DATE"), Value: new("2026-01-01")}, } mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { return assert.ObjectsAreEqual(params, req.Parameters) })).Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStatePending}, + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Pending}, }, nil).Once() info, err := submitStatement(ctx, mockAPI, "SELECT * FROM events WHERE ts > :since", "wh-1", params) @@ -59,7 +59,7 @@ func TestSubmitStatementPassesParameters(t *testing.T) { func TestSubmitStatementWrapsTransportError(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) mockAPI.EXPECT().ExecuteStatement(mock.Anything, mock.Anything). Return(nil, errors.New("network unreachable")).Once() @@ -72,24 +72,24 @@ func TestSubmitStatementWrapsTransportError(t *testing.T) { func TestGetStatementResultPolls(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) - mockAPI.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStateRunning}, + mockAPI.EXPECT().GetStatementResult(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Running}, }, nil).Once() - mockAPI.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, - Manifest: &sql.ResultManifest{Schema: &sql.ResultSchema{Columns: []sql.ColumnInfo{{Name: "n"}}}, TotalChunkCount: 1}, - Result: &sql.ResultData{DataArray: [][]string{{"42"}}}, + mockAPI.EXPECT().GetStatementResult(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, + Manifest: &sql.ResultManifest{Schema: &sql.Schema{Columns: []sql.ColumnInfo{{Name: new("n")}}}, TotalChunkCount: new(1)}, + Result: &sql.ResultData{DataArray: rows([][]string{{"42"}})}, }, nil).Once() info, err := getStatementResult(ctx, mockAPI, "stmt-1") require.NoError(t, err) assert.Equal(t, "stmt-1", info.StatementID) - assert.Equal(t, sql.StatementStateSucceeded, info.State) + assert.Equal(t, sql.StatementStatus_State_Succeeded, info.State) assert.Equal(t, []string{"n"}, info.Columns) assert.Equal(t, [][]string{{"42"}}, info.Rows) assert.Nil(t, info.Error) @@ -97,22 +97,22 @@ func TestGetStatementResultPolls(t *testing.T) { func TestGetStatementResultFailedStateReportsError(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) - mockAPI.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ - StatementId: "stmt-1", + mockAPI.EXPECT().GetStatementResult(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ + StatementId: new("stmt-1"), Status: &sql.StatementStatus{ - State: sql.StatementStateFailed, + State: sql.StatementStatus_State_Failed, Error: &sql.ServiceError{ ErrorCode: "SYNTAX_ERROR", - Message: "near 'bad': syntax error", + Message: new("near 'bad': syntax error"), }, }, }, nil).Once() info, err := getStatementResult(ctx, mockAPI, "stmt-1") require.NoError(t, err) - assert.Equal(t, sql.StatementStateFailed, info.State) + assert.Equal(t, sql.StatementStatus_State_Failed, info.State) assert.Nil(t, info.Rows) require.NotNil(t, info.Error) assert.Equal(t, "SYNTAX_ERROR", info.Error.ErrorCode) @@ -124,11 +124,11 @@ func TestGetStatementResultDoesNotCancelServerSideOnContextCancel(t *testing.T) // trigger CancelExecution. The mock asserts (via t.Cleanup) that no // unexpected calls happen. ctx, cancel := context.WithCancel(cmdio.MockDiscard(t.Context())) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) - mockAPI.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStatePending}, + mockAPI.EXPECT().GetStatementResult(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Pending}, }, nil).Once() cancel() @@ -144,24 +144,24 @@ func TestGetStatementResultChunkFetchFailureRendersPartialInfo(t *testing.T) { // statement_id, instead of returning a raw Go error that RunE would // discard along with the populated info. ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) - mockAPI.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, + mockAPI.EXPECT().GetStatementResult(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, Manifest: &sql.ResultManifest{ - Schema: &sql.ResultSchema{Columns: []sql.ColumnInfo{{Name: "n"}}}, - TotalChunkCount: 2, + Schema: &sql.Schema{Columns: []sql.ColumnInfo{{Name: new("n")}}}, + TotalChunkCount: new(2), }, - Result: &sql.ResultData{DataArray: [][]string{{"1"}}}, + Result: &sql.ResultData{DataArray: rows([][]string{{"1"}})}, }, nil).Once() - mockAPI.EXPECT().GetStatementResultChunkNByStatementIdAndChunkIndex(mock.Anything, "stmt-1", 1). + mockAPI.EXPECT().GetResultData(mock.Anything, "stmt-1", 1). Return(nil, errors.New("network blip")).Once() info, err := getStatementResult(ctx, mockAPI, "stmt-1") require.NoError(t, err) - assert.Equal(t, sql.StatementStateSucceeded, info.State) + assert.Equal(t, sql.StatementStatus_State_Succeeded, info.State) require.NotNil(t, info.Error) assert.Contains(t, info.Error.Message, "fetch result rows") assert.Contains(t, info.Error.Message, "network blip") @@ -172,61 +172,59 @@ func TestGetStatementResultChunkFetchFailureRendersPartialInfo(t *testing.T) { func TestGetStatementStatusSinglePoll(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) - mockAPI.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStateRunning}, + mockAPI.EXPECT().GetStatementResult(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Running}, }, nil).Once() info, err := getStatementStatus(ctx, mockAPI, "stmt-1") require.NoError(t, err) assert.Equal(t, "stmt-1", info.StatementID) - assert.Equal(t, sql.StatementStateRunning, info.State) + assert.Equal(t, sql.StatementStatus_State_Running, info.State) assert.Nil(t, info.Error) } func TestGetStatementStatusReportsError(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) - mockAPI.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ - StatementId: "stmt-1", + mockAPI.EXPECT().GetStatementResult(mock.Anything, "stmt-1").Return(&sql.StatementResponse{ + StatementId: new("stmt-1"), Status: &sql.StatementStatus{ - State: sql.StatementStateFailed, + State: sql.StatementStatus_State_Failed, Error: &sql.ServiceError{ ErrorCode: "TIMEOUT", - Message: "warehouse timed out", + Message: new("warehouse timed out"), }, }, }, nil).Once() info, err := getStatementStatus(ctx, mockAPI, "stmt-1") require.NoError(t, err) - assert.Equal(t, sql.StatementStateFailed, info.State) + assert.Equal(t, sql.StatementStatus_State_Failed, info.State) require.NotNil(t, info.Error) assert.Equal(t, "TIMEOUT", info.Error.ErrorCode) } func TestCancelStatementExecutionCallsAPI(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) - mockAPI.EXPECT().CancelExecution(mock.Anything, sql.CancelExecutionRequest{ - StatementId: "stmt-1", - }).Return(nil).Once() + mockAPI.EXPECT().CancelStatement(mock.Anything, "stmt-1").Return(nil).Once() info, err := cancelStatementExecution(ctx, mockAPI, "stmt-1") require.NoError(t, err) assert.Equal(t, "stmt-1", info.StatementID) - assert.Equal(t, sql.StatementStateCanceled, info.State) + assert.Equal(t, sql.StatementStatus_State_Canceled, info.State) } func TestCancelStatementExecutionWrapsAPIError(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - mockAPI := mocksql.NewMockStatementExecutionInterface(t) + mockAPI := newMockStatementAPI(t) - mockAPI.EXPECT().CancelExecution(mock.Anything, mock.Anything). + mockAPI.EXPECT().CancelStatement(mock.Anything, mock.Anything). Return(errors.New("not found")).Once() _, err := cancelStatementExecution(ctx, mockAPI, "stmt-1") @@ -246,7 +244,7 @@ func TestRenderStatementInfo(t *testing.T) { name: "full payload renders every populated field", info: statementInfo{ StatementID: "stmt-1", - State: sql.StatementStateSucceeded, + State: sql.StatementStatus_State_Succeeded, WarehouseID: "wh-1", Columns: []string{"n"}, Rows: [][]string{{"42"}}, @@ -263,7 +261,7 @@ func TestRenderStatementInfo(t *testing.T) { name: "cancel-style payload omits unset fields", info: statementInfo{ StatementID: "stmt-1", - State: sql.StatementStateCanceled, + State: sql.StatementStatus_State_Canceled, }, mustHave: []string{ `"statement_id": "stmt-1"`, @@ -321,23 +319,23 @@ func TestStatementError(t *testing.T) { }, { name: "failed with backend error preserves both fields", - err: &sqlexec.StatementError{State: sql.StatementStateFailed, Code: "SYNTAX_ERROR", Message: "near 'bad'"}, + err: &sqlexec.StatementError{State: sql.StatementStatus_State_Failed, Code: "SYNTAX_ERROR", Message: "near 'bad'"}, wantMsg: "near 'bad'", wantCode: "SYNTAX_ERROR", }, { name: "failed without backend error surfaces synthesized message", - err: &sqlexec.StatementError{State: sql.StatementStateFailed, Message: "statement reached terminal state FAILED"}, + err: &sqlexec.StatementError{State: sql.StatementStatus_State_Failed, Message: "statement reached terminal state FAILED"}, wantMsg: "statement reached terminal state FAILED", }, { name: "canceled without backend error surfaces synthesized message", - err: &sqlexec.StatementError{State: sql.StatementStateCanceled, Message: "statement reached terminal state CANCELED"}, + err: &sqlexec.StatementError{State: sql.StatementStatus_State_Canceled, Message: "statement reached terminal state CANCELED"}, wantMsg: "statement reached terminal state CANCELED", }, { name: "closed without backend error surfaces synthesized message", - err: &sqlexec.StatementError{State: sql.StatementStateClosed, Message: "statement reached terminal state CLOSED"}, + err: &sqlexec.StatementError{State: sql.StatementStatus_State_Closed, Message: "statement reached terminal state CLOSED"}, wantMsg: "statement reached terminal state CLOSED", }, } diff --git a/experimental/aitools/lib/middlewares/databricks_client.go b/experimental/aitools/lib/middlewares/databricks_client.go index 6abf360e032..0eb116984f2 100644 --- a/experimental/aitools/lib/middlewares/databricks_client.go +++ b/experimental/aitools/lib/middlewares/databricks_client.go @@ -8,7 +8,7 @@ import ( "github.com/databricks/cli/experimental/aitools/lib/session" "github.com/databricks/cli/libs/databrickscfg/profile" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" ) const ( @@ -25,7 +25,7 @@ func GetAvailableProfiles(ctx context.Context) profile.Profiles { return profiles } -func GetDatabricksClient(ctx context.Context) (*databricks.WorkspaceClient, error) { +func GetDatabricksClient(ctx context.Context) (*sdkclients.Clients, error) { sess, err := session.GetSession(ctx) if err != nil { return nil, err @@ -34,7 +34,7 @@ func GetDatabricksClient(ctx context.Context) (*databricks.WorkspaceClient, erro if !ok { return nil, newAuthError(ctx) } - return w.(*databricks.WorkspaceClient), nil + return w.(*sdkclients.Clients), nil } func newAuthError(ctx context.Context) error { diff --git a/experimental/aitools/lib/middlewares/warehouse.go b/experimental/aitools/lib/middlewares/warehouse.go index fc42c2d03c9..80bb7e897ac 100644 --- a/experimental/aitools/lib/middlewares/warehouse.go +++ b/experimental/aitools/lib/middlewares/warehouse.go @@ -7,8 +7,9 @@ import ( "github.com/databricks/cli/experimental/aitools/lib/session" "github.com/databricks/cli/libs/databrickscfg/cfgpickers" "github.com/databricks/cli/libs/env" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + sql "github.com/databricks/sdk-go/warehouses/v1" ) // GetWarehouseEndpoint returns the resolved warehouse endpoint. @@ -31,8 +32,8 @@ func GetWarehouseEndpoint(ctx context.Context, autoStart bool) (*sql.EndpointInf endpoint = warehouse.(*sql.EndpointInfo) - if autoStart && (endpoint.State == sql.StateStopped || endpoint.State == sql.StateStopping) { - endpoint, err = startWarehouse(ctx, endpoint.Id) + if autoStart && (endpoint.State == sql.EndpointState_Stopped || endpoint.State == sql.EndpointState_Stopping) { + endpoint, err = startWarehouse(ctx, utils.Deref(endpoint.Id)) if err != nil { return nil, err } @@ -49,7 +50,7 @@ func GetWarehouseID(ctx context.Context, autoStart bool) (string, error) { if err != nil { return "", err } - return warehouse.Id, nil + return utils.Deref(warehouse.Id), nil } func startWarehouse(ctx context.Context, id string) (*sql.EndpointInfo, error) { @@ -57,11 +58,11 @@ func startWarehouse(ctx context.Context, id string) (*sql.EndpointInfo, error) { if err != nil { return nil, fmt.Errorf("get databricks client: %w", err) } - wait, err := w.Warehouses.Start(ctx, sql.StartRequest{Id: id}) + wait, err := w.Warehouses.StartWarehouse(ctx, sql.StartRequest{Id: new(id)}) if err != nil { return nil, fmt.Errorf("start warehouse %s: %w", id, err) } - resp, err := wait.Get() + resp, err := wait.Wait(ctx) if err != nil { return nil, fmt.Errorf("wait for warehouse %s to start: %w", id, err) } @@ -84,12 +85,12 @@ func getDefaultWarehouse(ctx context.Context) (*sql.EndpointInfo, error) { // 1. DATABRICKS_WAREHOUSE_ID env var // 2. User's default warehouse override (CUSTOM type only) // 3. Server-side default / first usable warehouse by state -func resolveWarehouse(ctx context.Context, w *databricks.WorkspaceClient) (*sql.EndpointInfo, error) { +func resolveWarehouse(ctx context.Context, w *sdkclients.Clients) (*sql.EndpointInfo, error) { // first resolve DATABRICKS_WAREHOUSE_ID env variable warehouseID := env.Get(ctx, "DATABRICKS_WAREHOUSE_ID") if warehouseID != "" { - warehouse, err := w.Warehouses.Get(ctx, sql.GetWarehouseRequest{ - Id: warehouseID, + warehouse, err := w.Warehouses.GetWarehouse(ctx, sql.GetWarehouseRequest{ + Id: new(warehouseID), }) if err != nil { return nil, fmt.Errorf("get warehouse: %w", err) @@ -104,13 +105,13 @@ func resolveWarehouse(ctx context.Context, w *databricks.WorkspaceClient) (*sql. // Check user's default warehouse override (set via the SQL UI or CLI). // Only CUSTOM overrides are used; LAST_SELECTED requires UI state we don't have. override, err := w.Warehouses.GetDefaultWarehouseOverride(ctx, sql.GetDefaultWarehouseOverrideRequest{ - Name: "default-warehouse-overrides/me", + Name: new("default-warehouse-overrides/me"), }) - if err == nil && override.Type == sql.DefaultWarehouseOverrideTypeCustom && override.WarehouseId != "" { - warehouse, err := w.Warehouses.Get(ctx, sql.GetWarehouseRequest{ + if err == nil && override.Type == sql.DefaultWarehouseOverrideType_Custom && utils.Deref(override.WarehouseId) != "" { + warehouse, err := w.Warehouses.GetWarehouse(ctx, sql.GetWarehouseRequest{ Id: override.WarehouseId, }) - if err == nil && warehouse.State != sql.StateDeleted && warehouse.State != sql.StateDeleting { + if err == nil && warehouse.State != sql.EndpointState_Deleted && warehouse.State != sql.EndpointState_Deleting { return &sql.EndpointInfo{ Id: warehouse.Id, Name: warehouse.Name, diff --git a/experimental/postgres/cmd/internal/target/autoscaling.go b/experimental/postgres/cmd/internal/target/autoscaling.go index 3e496611d6b..9d3e88c3274 100644 --- a/experimental/postgres/cmd/internal/target/autoscaling.go +++ b/experimental/postgres/cmd/internal/target/autoscaling.go @@ -5,45 +5,47 @@ import ( "errors" "fmt" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/listing" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + postgres "github.com/databricks/sdk-go/postgres/v1" ) // ListProjects returns all autoscaling projects in the workspace. -func ListProjects(ctx context.Context, w *databricks.WorkspaceClient) ([]postgres.Project, error) { - return w.Postgres.ListProjectsAll(ctx, postgres.ListProjectsRequest{}) +func ListProjects(ctx context.Context, w *sdkclients.Clients) ([]postgres.Project, error) { + return listing.Collect(w.Postgres.ListProjectsIter(ctx, postgres.ListProjectsRequest{})) } // ListBranches returns all branches under the given project. // projectName is the SDK resource name like "projects/foo". -func ListBranches(ctx context.Context, w *databricks.WorkspaceClient, projectName string) ([]postgres.Branch, error) { - return w.Postgres.ListBranchesAll(ctx, postgres.ListBranchesRequest{Parent: projectName}) +func ListBranches(ctx context.Context, w *sdkclients.Clients, projectName string) ([]postgres.Branch, error) { + return listing.Collect(w.Postgres.ListBranchesIter(ctx, postgres.ListBranchesRequest{Parent: new(projectName)})) } // ListEndpoints returns all endpoints under the given branch. // branchName is the SDK resource name like "projects/foo/branches/bar". -func ListEndpoints(ctx context.Context, w *databricks.WorkspaceClient, branchName string) ([]postgres.Endpoint, error) { - return w.Postgres.ListEndpointsAll(ctx, postgres.ListEndpointsRequest{Parent: branchName}) +func ListEndpoints(ctx context.Context, w *sdkclients.Clients, branchName string) ([]postgres.Endpoint, error) { + return listing.Collect(w.Postgres.ListEndpointsIter(ctx, postgres.ListEndpointsRequest{Parent: new(branchName)})) } // GetProject fetches a single project by ID. Unlike GetProvisioned, the // Postgres autoscaling API populates the Name field on the response so we do // not need to patch it. -func GetProject(ctx context.Context, w *databricks.WorkspaceClient, projectID string) (*postgres.Project, error) { - return w.Postgres.GetProject(ctx, postgres.GetProjectRequest{Name: pathSegmentProjects + "/" + projectID}) +func GetProject(ctx context.Context, w *sdkclients.Clients, projectID string) (*postgres.Project, error) { + return w.Postgres.GetProject(ctx, postgres.GetProjectRequest{Name: new(pathSegmentProjects + "/" + projectID)}) } // GetEndpoint fetches a single endpoint by ID, given its parent IDs. Unlike // GetProvisioned, the Postgres autoscaling API populates the Name field. -func GetEndpoint(ctx context.Context, w *databricks.WorkspaceClient, projectID, branchID, endpointID string) (*postgres.Endpoint, error) { +func GetEndpoint(ctx context.Context, w *sdkclients.Clients, projectID, branchID, endpointID string) (*postgres.Endpoint, error) { name := fmt.Sprintf("projects/%s/branches/%s/endpoints/%s", projectID, branchID, endpointID) - return w.Postgres.GetEndpoint(ctx, postgres.GetEndpointRequest{Name: name}) + return w.Postgres.GetEndpoint(ctx, postgres.GetEndpointRequest{Name: new(name)}) } // AutoSelectProject returns the trailing project ID (e.g. "foo", not // "projects/foo") if exactly one project exists. Returns an *AmbiguousError // carrying the choices if there are multiple, or a plain error if there are none. -func AutoSelectProject(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { +func AutoSelectProject(ctx context.Context, w *sdkclients.Clients) (string, error) { projects, err := ListProjects(ctx, w) if err != nil { return "", err @@ -52,15 +54,15 @@ func AutoSelectProject(ctx context.Context, w *databricks.WorkspaceClient) (stri return "", errors.New("no Lakebase Autoscaling projects found in workspace") } if len(projects) == 1 { - return extractID(projects[0].Name, pathSegmentProjects), nil + return extractID(utils.Deref(projects[0].Name), pathSegmentProjects), nil } choices := make([]Choice, 0, len(projects)) for _, p := range projects { - id := extractID(p.Name, pathSegmentProjects) + id := extractID(utils.Deref(p.Name), pathSegmentProjects) var display string - if p.Status != nil && p.Status.DisplayName != "" && p.Status.DisplayName != id { - display = p.Status.DisplayName + if p.Status != nil && utils.Deref(p.Status.DisplayName) != "" && utils.Deref(p.Status.DisplayName) != id { + display = utils.Deref(p.Status.DisplayName) } choices = append(choices, Choice{ID: id, DisplayName: display}) } @@ -70,7 +72,7 @@ func AutoSelectProject(ctx context.Context, w *databricks.WorkspaceClient) (stri // AutoSelectBranch returns the trailing branch ID under projectName if // exactly one branch exists. Returns an *AmbiguousError if there are multiple. // projectName is the SDK resource name (e.g. "projects/foo"). -func AutoSelectBranch(ctx context.Context, w *databricks.WorkspaceClient, projectName string) (string, error) { +func AutoSelectBranch(ctx context.Context, w *sdkclients.Clients, projectName string) (string, error) { branches, err := ListBranches(ctx, w, projectName) if err != nil { return "", err @@ -79,12 +81,12 @@ func AutoSelectBranch(ctx context.Context, w *databricks.WorkspaceClient, projec return "", errors.New("no branches found in project") } if len(branches) == 1 { - return extractID(branches[0].Name, pathSegmentBranches), nil + return extractID(utils.Deref(branches[0].Name), pathSegmentBranches), nil } choices := make([]Choice, 0, len(branches)) for _, b := range branches { - id := extractID(b.Name, pathSegmentBranches) + id := extractID(utils.Deref(b.Name), pathSegmentBranches) choices = append(choices, Choice{ID: id}) } return "", &AmbiguousError{Kind: KindBranch, Parent: projectName, FlagHint: "--branch", Choices: choices} @@ -93,7 +95,7 @@ func AutoSelectBranch(ctx context.Context, w *databricks.WorkspaceClient, projec // AutoSelectEndpoint returns the trailing endpoint ID under branchName if // exactly one endpoint exists. Returns an *AmbiguousError if there are multiple. // branchName is the SDK resource name (e.g. "projects/foo/branches/bar"). -func AutoSelectEndpoint(ctx context.Context, w *databricks.WorkspaceClient, branchName string) (string, error) { +func AutoSelectEndpoint(ctx context.Context, w *sdkclients.Clients, branchName string) (string, error) { endpoints, err := ListEndpoints(ctx, w, branchName) if err != nil { return "", err @@ -102,12 +104,12 @@ func AutoSelectEndpoint(ctx context.Context, w *databricks.WorkspaceClient, bran return "", errors.New("no endpoints found in branch") } if len(endpoints) == 1 { - return extractID(endpoints[0].Name, pathSegmentEndpoints), nil + return extractID(utils.Deref(endpoints[0].Name), pathSegmentEndpoints), nil } choices := make([]Choice, 0, len(endpoints)) for _, e := range endpoints { - id := extractID(e.Name, pathSegmentEndpoints) + id := extractID(utils.Deref(e.Name), pathSegmentEndpoints) choices = append(choices, Choice{ID: id}) } return "", &AmbiguousError{Kind: KindEndpoint, Parent: branchName, FlagHint: "--endpoint", Choices: choices} @@ -116,12 +118,12 @@ func AutoSelectEndpoint(ctx context.Context, w *databricks.WorkspaceClient, bran // AutoscalingCredential issues a short-lived OAuth token that can be used to // authenticate to the given autoscaling endpoint. endpointName is the SDK // resource name (e.g. "projects/foo/branches/bar/endpoints/baz"). -func AutoscalingCredential(ctx context.Context, w *databricks.WorkspaceClient, endpointName string) (string, error) { +func AutoscalingCredential(ctx context.Context, w *sdkclients.Clients, endpointName string) (string, error) { cred, err := w.Postgres.GenerateDatabaseCredential(ctx, postgres.GenerateDatabaseCredentialRequest{ - Endpoint: endpointName, + Endpoint: new(endpointName), }) if err != nil { return "", fmt.Errorf("failed to get database credentials: %w", err) } - return cred.Token, nil + return utils.Deref(cred.Token), nil } diff --git a/experimental/postgres/cmd/internal/target/provisioned.go b/experimental/postgres/cmd/internal/target/provisioned.go index 786e86d2886..e2248e8c6b2 100644 --- a/experimental/postgres/cmd/internal/target/provisioned.go +++ b/experimental/postgres/cmd/internal/target/provisioned.go @@ -4,34 +4,35 @@ import ( "context" "fmt" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/database" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + database "github.com/databricks/sdk-go/database/v1" "github.com/google/uuid" ) // GetProvisioned fetches a single provisioned instance by name. // The Name field on the response can be empty; this function ensures it is // populated from the input so downstream callers do not have to re-set it. -func GetProvisioned(ctx context.Context, w *databricks.WorkspaceClient, name string) (*database.DatabaseInstance, error) { - instance, err := w.Database.GetDatabaseInstance(ctx, database.GetDatabaseInstanceRequest{Name: name}) +func GetProvisioned(ctx context.Context, w *sdkclients.Clients, name string) (*database.DatabaseInstance, error) { + instance, err := w.Database.GetDatabaseInstance(ctx, database.GetDatabaseInstanceRequest{Name: new(name)}) if err != nil { return nil, fmt.Errorf("failed to get database instance: %w", err) } - if instance.Name == "" { - instance.Name = name + if utils.Deref(instance.Name) == "" { + instance.Name = new(name) } return instance, nil } // ProvisionedCredential issues a short-lived OAuth token for the provisioned // instance with the given name. -func ProvisionedCredential(ctx context.Context, w *databricks.WorkspaceClient, instanceName string) (string, error) { +func ProvisionedCredential(ctx context.Context, w *sdkclients.Clients, instanceName string) (string, error) { cred, err := w.Database.GenerateDatabaseCredential(ctx, database.GenerateDatabaseCredentialRequest{ InstanceNames: []string{instanceName}, - RequestId: uuid.NewString(), + RequestId: new(uuid.NewString()), }) if err != nil { return "", fmt.Errorf("failed to get database credentials: %w", err) } - return cred.Token, nil + return utils.Deref(cred.Token), nil } diff --git a/experimental/postgres/cmd/targeting.go b/experimental/postgres/cmd/targeting.go index cf1290ad578..336889ef8a9 100644 --- a/experimental/postgres/cmd/targeting.go +++ b/experimental/postgres/cmd/targeting.go @@ -7,10 +7,11 @@ import ( "github.com/databricks/cli/experimental/postgres/cmd/internal/target" "github.com/databricks/cli/libs/cmdctx" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/database" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + database "github.com/databricks/sdk-go/database/v1" + postgres "github.com/databricks/sdk-go/postgres/v1" + sdkscim "github.com/databricks/sdk-go/scim/v1" ) // resolvedTarget carries everything the query command needs to dial Postgres: @@ -104,32 +105,32 @@ func resolveTarget(ctx context.Context, f targetingFlags) (*resolvedTarget, erro // resolveProvisioned looks up a provisioned instance and issues a token. The // instance must be in the AVAILABLE state; transitional states return an // error pointing the user at the lifecycle they are waiting on. -func resolveProvisioned(ctx context.Context, w *databricks.WorkspaceClient, instanceName string) (*resolvedTarget, error) { +func resolveProvisioned(ctx context.Context, w *sdkclients.Clients, instanceName string) (*resolvedTarget, error) { instance, err := target.GetProvisioned(ctx, w, instanceName) if err != nil { return nil, err } - if instance.State != database.DatabaseInstanceStateAvailable { - return nil, fmt.Errorf("database instance %q is not ready for accepting connections (state: %s)", instance.Name, instance.State) + if instance.State != database.DatabaseInstance_State_Available { + return nil, fmt.Errorf("database instance %q is not ready for accepting connections (state: %s)", utils.Deref(instance.Name), instance.State) } - user, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + user, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) if err != nil { return nil, fmt.Errorf("failed to get current user: %w", err) } - token, err := target.ProvisionedCredential(ctx, w, instance.Name) + token, err := target.ProvisionedCredential(ctx, w, utils.Deref(instance.Name)) if err != nil { return nil, err } return &resolvedTarget{ Kind: kindProvisioned, - Host: instance.ReadWriteDns, - Username: user.UserName, + Host: utils.Deref(instance.ReadWriteDns), + Username: utils.Deref(user.UserName), Token: token, - DisplayName: instance.Name, + DisplayName: utils.Deref(instance.Name), }, nil } @@ -137,7 +138,7 @@ func resolveProvisioned(ctx context.Context, w *databricks.WorkspaceClient, inst // issues a short-lived OAuth token. Missing branch/endpoint IDs are // auto-selected when exactly one candidate exists; ambiguity propagates as an // AmbiguousError with the list of choices. -func resolveAutoscaling(ctx context.Context, w *databricks.WorkspaceClient, spec target.AutoscalingSpec) (*resolvedTarget, error) { +func resolveAutoscaling(ctx context.Context, w *sdkclients.Clients, spec target.AutoscalingSpec) (*resolvedTarget, error) { if spec.ProjectID == "" { var err error spec.ProjectID, err = target.AutoSelectProject(ctx, w) @@ -152,14 +153,14 @@ func resolveAutoscaling(ctx context.Context, w *databricks.WorkspaceClient, spec } if spec.BranchID == "" { - spec.BranchID, err = target.AutoSelectBranch(ctx, w, project.Name) + spec.BranchID, err = target.AutoSelectBranch(ctx, w, utils.Deref(project.Name)) if err != nil { return nil, err } } if spec.EndpointID == "" { - branchName := project.Name + "/branches/" + spec.BranchID + branchName := utils.Deref(project.Name) + "/branches/" + spec.BranchID spec.EndpointID, err = target.AutoSelectEndpoint(ctx, w, branchName) if err != nil { return nil, err @@ -175,22 +176,22 @@ func resolveAutoscaling(ctx context.Context, w *databricks.WorkspaceClient, spec return nil, err } - user, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + user, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) if err != nil { return nil, fmt.Errorf("failed to get current user: %w", err) } - token, err := target.AutoscalingCredential(ctx, w, endpoint.Name) + token, err := target.AutoscalingCredential(ctx, w, utils.Deref(endpoint.Name)) if err != nil { return nil, err } return &resolvedTarget{ Kind: kindAutoscaling, - Host: endpoint.Status.Hosts.Host, - Username: user.UserName, + Host: utils.Deref(endpoint.Status.Hosts.Host), + Username: utils.Deref(user.UserName), Token: token, - DisplayName: endpoint.Name, + DisplayName: utils.Deref(endpoint.Name), }, nil } @@ -201,11 +202,11 @@ func checkEndpointReady(endpoint *postgres.Endpoint) error { if endpoint.Status == nil { return errors.New("endpoint status is not available") } - if endpoint.Status.Hosts == nil || endpoint.Status.Hosts.Host == "" { + if endpoint.Status.Hosts == nil || utils.Deref(endpoint.Status.Hosts.Host) == "" { return errors.New("endpoint host information is not available") } switch endpoint.Status.CurrentState { - case postgres.EndpointStatusStateActive, postgres.EndpointStatusStateIdle: + case postgres.EndpointStatus_State_Active, postgres.EndpointStatus_State_Idle: return nil default: return fmt.Errorf("endpoint is not ready for accepting connections (state: %s)", endpoint.Status.CurrentState) diff --git a/experimental/ssh/internal/client/agentshim.go b/experimental/ssh/internal/client/agentshim.go index d596a4e49d9..c6dcc3fed0e 100644 --- a/experimental/ssh/internal/client/agentshim.go +++ b/experimental/ssh/internal/client/agentshim.go @@ -8,6 +8,7 @@ import ( "fmt" "io" "net/http" + "net/url" "os" "os/exec" "path/filepath" @@ -17,20 +18,17 @@ import ( "time" "github.com/databricks/cli/internal/build" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/dbr" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/telemetry" "github.com/databricks/cli/libs/telemetry/protos" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/httpclient" - "github.com/databricks/databricks-sdk-go/listing" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/sdk-go/aigateway/v1" ) const ( @@ -117,7 +115,7 @@ func agentByName(name string) (agentSpec, bool) { return agentSpec{}, false } -func RunAgentShim(ctx context.Context, client *databricks.WorkspaceClient, agentName string, agentArgs []string) (retErr error) { +func RunAgentShim(ctx context.Context, client *sdkclients.Clients, agentName string, agentArgs []string) (retErr error) { // Report the outcome of the launch. Setup runs from here to the exec below, so time it // from here too. Each failing step sets outcome.errorCategory; the returned error is // picked up via the named return. @@ -296,24 +294,25 @@ type gatewayProbe struct { resourceAvailable bool } -func probeAIGateway(ctx context.Context, wsclient *databricks.WorkspaceClient) error { +func probeAIGateway(ctx context.Context, wsclient *sdkclients.Clients) error { host := strings.TrimRight(wsclient.Config.Host, "/") - // build a client with retries disabled so a transient 429/503 fails fast - // instead of looping on the SDK's default 5-minute retry budget before the - // slow first-run bootstrap even starts. - apiClient, err := newProbeAPIClient(wsclient.Config) + // disable retries so a transient 429/503 fails fast instead of looping on + // the default 5-minute retry budget before the slow first-run bootstrap + // even starts. + ctx = apiclient.WithMaxAttempts(ctx, 1) + apiClient, err := apiclient.New(wsclient.Config) if err != nil { // this probe is best effort, so don't block log.Debugf(ctx, "Skipping Unity AI Gateway check: %s", err) return nil } - modelSvc := probeModelServices(ctx, apiClient) + modelSvc := probeModelServices(ctx, wsclient) // A 401 (or a 400 "invalid token") can't be rescued by trying another API, // so surface it before the fallback probe. if !modelSvc.reachable && looksLikeDefinitiveAuthFailure(modelSvc.err) { - return aiGatewayAuthError(host, modelSvc.err.Error()) + return aiGatewayAuthError(host, apierrs.ErrorString(modelSvc.err)) } if modelSvc.resourceAvailable { return nil @@ -333,65 +332,49 @@ func probeAIGateway(ctx context.Context, wsclient *databricks.WorkspaceClient) e // unconfirmed "empty". return nil case looksLikeDefinitiveAuthFailure(legacy.err): - return aiGatewayAuthError(host, legacy.err.Error()) + return aiGatewayAuthError(host, apierrs.ErrorString(legacy.err)) case looksLikeScopeFailure(modelSvc.err): - return aiGatewayScopeError(host, modelSvc.err.Error()) + return aiGatewayScopeError(host, apierrs.ErrorString(modelSvc.err)) case looksLikeScopeFailure(legacy.err): - return aiGatewayScopeError(host, legacy.err.Error()) + return aiGatewayScopeError(host, apierrs.ErrorString(legacy.err)) case looksLikeTransient(modelSvc.err) || looksLikeTransient(legacy.err): // A rate-limit/5xx/network blip is not "disabled" — tell the user to retry // rather than sending them to the enablement docs. return categorize(protos.SshAgentShimErrorCategoryGatewayTransientError, versionNeutralGatewayError( - fmt.Sprintf("could not verify the Databricks Unity AI Gateway on %s: the probe hit a transient error (model services: %s; legacy endpoints: %s). Retry in a moment", host, modelSvc.err.Error(), legacy.err.Error()), + fmt.Sprintf("could not verify the Databricks Unity AI Gateway on %s: the probe hit a transient error (model services: %s; legacy endpoints: %s). Retry in a moment", host, apierrs.ErrorString(modelSvc.err), apierrs.ErrorString(legacy.err)), )) - case errors.Is(modelSvc.err, apierr.ErrPermissionDenied): + case apierrs.Is(modelSvc.err, apierrs.ErrPermissionDenied): return categorize(protos.SshAgentShimErrorCategoryGatewayPermissionDenied, versionNeutralGatewayError( - fmt.Sprintf("model service access could not be verified on %s (%s). The legacy endpoint fallback also failed (%s). The model service probe requires permission to list Unity Catalog model services. Verify USE CATALOG on `system`, and USE SCHEMA and EXECUTE on `system.ai`", host, modelSvc.err.Error(), legacy.err.Error()), + fmt.Sprintf("model service access could not be verified on %s (%s). The legacy endpoint fallback also failed (%s). The model service probe requires permission to list Unity Catalog model services. Verify USE CATALOG on `system`, and USE SCHEMA and EXECUTE on `system.ai`", host, apierrs.ErrorString(modelSvc.err), apierrs.ErrorString(legacy.err)), )) - case errors.Is(legacy.err, apierr.ErrPermissionDenied): + case apierrs.Is(legacy.err, apierrs.ErrPermissionDenied): return categorize(protos.SshAgentShimErrorCategoryGatewayPermissionDenied, versionNeutralGatewayError( - fmt.Sprintf("legacy endpoint access could not be verified on %s (%s). The model service probe also failed (%s). Verify the caller's workspace permissions for the legacy endpoints listing", host, legacy.err.Error(), modelSvc.err.Error()), + fmt.Sprintf("legacy endpoint access could not be verified on %s (%s). The model service probe also failed (%s). Verify the caller's workspace permissions for the legacy endpoints listing", host, apierrs.ErrorString(legacy.err), apierrs.ErrorString(modelSvc.err)), )) default: return categorize(protos.SshAgentShimErrorCategoryGatewayNotEnabled, versionNeutralGatewayError( - fmt.Sprintf("the Databricks Unity AI Gateway is not enabled on this workspace (%s): neither model services (%s) nor legacy endpoints (%s) are available. See %s", host, modelSvc.err.Error(), legacy.err.Error(), aiGatewayDocsURL), + fmt.Sprintf("the Databricks Unity AI Gateway is not enabled on this workspace (%s): neither model services (%s) nor legacy endpoints (%s) are available. See %s", host, apierrs.ErrorString(modelSvc.err), apierrs.ErrorString(legacy.err), aiGatewayDocsURL), )) } } -// newProbeAPIClient builds a low-level client from cfg with the SDK's retries -// turned off, so the gateway preflight is one-shot. Clearing ErrorRetriable and -// TransientErrors makes a retriable status (429, 503, ...) surface on the first -// attempt rather than looping until the retry budget expires; it mirrors -// client.New, which builds the retrying client the rest of the CLI uses. -func newProbeAPIClient(cfg *config.Config) (*client.DatabricksClient, error) { - clientCfg, err := config.HTTPClientConfigFromConfig(cfg) - if err != nil { - return nil, err - } - clientCfg.ErrorRetriable = func(context.Context, error) bool { return false } - clientCfg.TransientErrors = nil - return client.NewWithClient(cfg, httpclient.NewApiClient(clientCfg)) -} - -func probeModelServices(ctx context.Context, apiClient *client.DatabricksClient) gatewayProbe { - it := catalog.NewAiGateway(apiClient).ListModelServices(ctx, catalog.ListModelServicesRequest{PageSize: modelServiceProbePageSize}) - _, err := it.Next(ctx) - if err != nil { - if err == listing.ErrNoMoreItems { - // endpoint is reachable but there are no results - return gatewayProbe{reachable: true} +func probeModelServices(ctx context.Context, w *sdkclients.Clients) gatewayProbe { + // The first model service is enough; a page error before it is a probe failure. + for _, err := range w.AiGateway.ListModelServicesIter(ctx, aigateway.ListModelServicesRequest{PageSize: new(modelServiceProbePageSize)}) { + if err != nil { + return gatewayProbe{err: err} } - return gatewayProbe{err: err} + return gatewayProbe{reachable: true, resourceAvailable: true} } - return gatewayProbe{reachable: true, resourceAvailable: true} + // endpoint is reachable but there are no results + return gatewayProbe{reachable: true} } type legacyEndpointsResponse struct { Endpoints []any `json:"endpoints"` } -func probeLegacyEndpoints(ctx context.Context, apiClient *client.DatabricksClient) gatewayProbe { +func probeLegacyEndpoints(ctx context.Context, apiClient *apiclient.Client) gatewayProbe { var resp legacyEndpointsResponse err := apiClient.Do(ctx, http.MethodGet, legacyEndpointsPath, auth.WorkspaceIDHeaders(apiClient.Config), map[string]any{ "page_size": "1", @@ -422,25 +405,27 @@ func versionNeutralGatewayError(reason string) error { // preflight still tries the fallback before giving up. func looksLikeDefinitiveAuthFailure(err error) bool { // HTTP 401 - if errors.Is(err, apierr.ErrUnauthenticated) { + if apierrs.Is(err, apierrs.ErrUnauthenticated) { return true } - return errors.Is(err, apierr.ErrBadRequest) && strings.Contains(strings.ToLower(err.Error()), "invalid token") + return apierrs.Is(err, apierrs.ErrBadRequest) && strings.Contains(strings.ToLower(apierrs.ErrorString(err)), "invalid token") } // matches a 403 that reports the OAuth token is missing a required scope (which // re-login can fix), as opposed to a plain permission 403. func looksLikeScopeFailure(err error) bool { reason := strings.ToLower(err.Error()) - return errors.Is(err, apierr.ErrPermissionDenied) && strings.Contains(reason, "oauth token") && strings.Contains(reason, "required scopes") + return apierrs.Is(err, apierrs.ErrPermissionDenied) && strings.Contains(reason, "oauth token") && strings.Contains(reason, "required scopes") } func looksLikeTransient(err error) bool { - return strings.HasPrefix(err.Error(), "network error") || - errors.Is(err, apierr.ErrTooManyRequests) || // HTTP 429 - errors.Is(err, apierr.ErrInternalError) || // HTTP 500 - errors.Is(err, apierr.ErrTemporarilyUnavailable) || // HTTP 503 - errors.Is(err, apierr.ErrDeadlineExceeded) // HTTP 504 + // Transport failures (DNS, connection reset, ...) surface as *url.Error. + _, isNetworkError := errors.AsType[*url.Error](err) + return isNetworkError || + apierrs.Is(err, apierrs.ErrTooManyRequests) || // HTTP 429 + apierrs.Is(err, apierrs.ErrInternalError) || // HTTP 500 + apierrs.Is(err, apierrs.ErrTemporarilyUnavailable) || // HTTP 503 + apierrs.Is(err, apierrs.ErrDeadlineExceeded) // HTTP 504 } func aiGatewayAuthError(host, reason string) error { diff --git a/experimental/ssh/internal/client/agentshim_test.go b/experimental/ssh/internal/client/agentshim_test.go index 283d4288fbe..f2fd96d8941 100644 --- a/experimental/ssh/internal/client/agentshim_test.go +++ b/experimental/ssh/internal/client/agentshim_test.go @@ -20,9 +20,10 @@ import ( "testing" "time" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/telemetry/protos" - "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -393,9 +394,9 @@ func TestAgentSystemContext(t *testing.T) { assert.Contains(t, agentSystemContext(""), "working directory is the user's Databricks workspace home directory") } -func newProbeClient(t *testing.T, host string) *databricks.WorkspaceClient { +func newProbeClient(t *testing.T, host string) *sdkclients.Clients { t.Helper() - w, err := databricks.NewWorkspaceClient((*databricks.Config)(&config.Config{ + w, err := sdkclients.New(t.Context(), (&config.Config{ Host: host, Token: "test-token", // The fake gateway server has no /.well-known/databricks-config, so skip @@ -556,9 +557,7 @@ func TestProbeModelServicesPageError(t *testing.T) { }, nil) defer srv.Close() - apiClient, err := newProbeAPIClient(newProbeClient(t, srv.URL).Config) - require.NoError(t, err) - probe := probeModelServices(t.Context(), apiClient) + probe := probeModelServices(apiclient.WithMaxAttempts(t.Context(), 1), newProbeClient(t, srv.URL)) assert.False(t, probe.reachable) assert.False(t, probe.resourceAvailable) assert.Error(t, probe.err) diff --git a/experimental/ssh/internal/client/capabilities_test.go b/experimental/ssh/internal/client/capabilities_test.go index 022f625f98f..f46590f1156 100644 --- a/experimental/ssh/internal/client/capabilities_test.go +++ b/experimental/ssh/internal/client/capabilities_test.go @@ -6,7 +6,8 @@ import ( "testing" "time" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/require" ) @@ -29,7 +30,7 @@ func TestServerSupportsResumeGivesUpOnAStalledServer(t *testing.T) { defer server.Close() defer close(stalled) - client, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "test-token", WorkspaceID: "123", AuthType: "pat"}) + client, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "test-token", WorkspaceID: "123", AuthType: "pat"}) require.NoError(t, err) done := make(chan bool, 1) diff --git a/experimental/ssh/internal/client/client.go b/experimental/ssh/internal/client/client.go index 81ee1439718..cd0804528c8 100644 --- a/experimental/ssh/internal/client/client.go +++ b/experimental/ssh/internal/client/client.go @@ -27,18 +27,21 @@ import ( "github.com/databricks/cli/experimental/ssh/internal/vscode" sshWorkspace "github.com/databricks/cli/experimental/ssh/internal/workspace" "github.com/databricks/cli/internal/build" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/listing" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/telemetry" "github.com/databricks/cli/libs/telemetry/protos" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/retries" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/environments" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/workspaceapi" + compute "github.com/databricks/sdk-go/clusters/v2" + "github.com/databricks/sdk-go/environments/v1" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" + sdkscim "github.com/databricks/sdk-go/scim/v1" "github.com/gorilla/websocket" ) @@ -303,7 +306,7 @@ func (o *ClientOptions) ToProxyCommand() (string, error) { return proxyCommand, nil } -func Run(ctx context.Context, client *databricks.WorkspaceClient, opts ClientOptions) (retErr error) { +func Run(ctx context.Context, client *sdkclients.Clients, opts ClientOptions) (retErr error) { ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -524,7 +527,7 @@ func Run(ctx context.Context, client *databricks.WorkspaceClient, opts ClientOpt // here replaces whatever was recorded for this session name before, so a key left by an // earlier instance - or by the same name in another workspace, since a name is unique only // within one - can no longer fail an otherwise valid connection. -func pinServerHostKey(ctx context.Context, client *databricks.WorkspaceClient, sessionID, secretScopeName string, opts ClientOptions) (string, error) { +func pinServerHostKey(ctx context.Context, client *sdkclients.Clients, sessionID, secretScopeName string, opts ClientOptions) (string, error) { knownHostsPath, err := sshconfig.GetKnownHostsPath(ctx, sessionID, opts.KnownHostsDir) if err != nil { return "", err @@ -543,14 +546,14 @@ func pinServerHostKey(ctx context.Context, client *databricks.WorkspaceClient, s return knownHostsPath, nil } -func runIDE(ctx context.Context, client *databricks.WorkspaceClient, userName, keyPath, knownHostsPath string, serverPort int, clusterID string, opts ClientOptions) error { +func runIDE(ctx context.Context, client *sdkclients.Clients, userName, keyPath, knownHostsPath string, serverPort int, clusterID string, opts ClientOptions) error { connectionName := opts.SessionIdentifier() if connectionName == "" { return errors.New("connection name is required for IDE integration") } // Get Databricks user name for the workspace path - currentUser, err := client.CurrentUser.Me(ctx, iam.MeRequest{}) + currentUser, err := client.Scim.Me(ctx, sdkscim.MeRequest{}) if err != nil { return fmt.Errorf("failed to get current user: %w", err) } @@ -566,7 +569,7 @@ func runIDE(ctx context.Context, client *databricks.WorkspaceClient, userName, k return fmt.Errorf("failed to ensure SSH config entry: %w", err) } - return vscode.LaunchIDE(ctx, opts.IDE, connectionName, currentUser.UserName) + return vscode.LaunchIDE(ctx, opts.IDE, connectionName, utils.Deref(currentUser.UserName)) } func ensureSSHConfigEntry(ctx context.Context, configPath, hostName, userName, keyPath, knownHostsPath string, serverPort int, clusterID string, opts ClientOptions) error { @@ -616,7 +619,7 @@ type serverMetadata struct { // sessionID is the unique identifier for the session (cluster ID for dedicated clusters, connection name for serverless). // For dedicated clusters, clusterID should be the same as sessionID. // For serverless, clusterID is read from the workspace metadata. -func getServerMetadata(ctx context.Context, client *databricks.WorkspaceClient, sessionID, clusterID, version, liteswap string) (serverMetadata, error) { +func getServerMetadata(ctx context.Context, client *sdkclients.Clients, sessionID, clusterID, version, liteswap string) (serverMetadata, error) { wsMetadata, err := sshWorkspace.GetWorkspaceMetadata(ctx, client, version, sessionID) if err != nil { return serverMetadata{}, errors.Join(errServerMetadata, err) @@ -667,7 +670,7 @@ func getServerMetadata(ctx context.Context, client *databricks.WorkspaceClient, // newDriverProxyRequest builds an authenticated GET request to one of the SSH server's // HTTP endpoints behind the workspace driver proxy. -func newDriverProxyRequest(ctx context.Context, client *databricks.WorkspaceClient, clusterID string, port int, endpoint, liteswap string) (*http.Request, error) { +func newDriverProxyRequest(ctx context.Context, client *sdkclients.Clients, clusterID string, port int, endpoint, liteswap string) (*http.Request, error) { workspaceID, err := auth.ResolveWorkspaceID(ctx, client) if err != nil { return nil, err @@ -689,7 +692,7 @@ func newDriverProxyRequest(ctx context.Context, client *databricks.WorkspaceClie // fetchServerErrorLogs fetches recent warning/error log lines from the running SSH // server's /logs endpoint. It is best-effort: any failure (including older server // versions that don't serve /logs) yields an empty string. -func fetchServerErrorLogs(ctx context.Context, client *databricks.WorkspaceClient, clusterID string, serverPort int, liteswap string) string { +func fetchServerErrorLogs(ctx context.Context, client *sdkclients.Clients, clusterID string, serverPort int, liteswap string) string { req, err := newDriverProxyRequest(ctx, client, clusterID, serverPort, "logs", liteswap) if err != nil { log.Debugf(ctx, "Failed to build server logs request: %v", err) @@ -716,7 +719,7 @@ func fetchServerErrorLogs(ctx context.Context, client *databricks.WorkspaceClien // Assemble the SubmitRun request that bootstraps the SSH server. // Extracted from submitSSHTunnelJob so this logic can be unit tested. -func buildSSHServerSubmitRun(version, secretScopeName, jobNotebookPath, baseEnvironment string, opts ClientOptions) jobs.SubmitRun { +func buildSSHServerSubmitRun(version, secretScopeName, jobNotebookPath, baseEnvironment string, opts ClientOptions) jobs.SubmitRunRequest { sessionID := opts.SessionIdentifier() baseParams := map[string]string{ @@ -735,45 +738,45 @@ func buildSSHServerSubmitRun(version, secretScopeName, jobNotebookPath, baseEnvi "keepDetachedProcesses": strconv.FormatBool(opts.KeepDetachedProcesses), } - task := jobs.SubmitTask{ - TaskKey: sshServerTaskKey, + task := jobs.RunTaskSettings{ + TaskKey: new(sshServerTaskKey), NotebookTask: &jobs.NotebookTask{ - NotebookPath: jobNotebookPath, + NotebookPath: new(jobNotebookPath), BaseParameters: baseParams, }, - TimeoutSeconds: int(opts.ServerTimeout.Seconds()), + TimeoutSeconds: utils.NonZero(int(opts.ServerTimeout.Seconds())), } if opts.IsServerlessMode() { - task.EnvironmentKey = serverlessEnvironmentKey + task.EnvironmentKey = new(serverlessEnvironmentKey) if opts.Accelerator != "" { task.Compute = &jobs.Compute{ - HardwareAccelerator: compute.HardwareAcceleratorType(opts.Accelerator), + HardwareAccelerator: jobs.HardwareAcceleratorType(opts.Accelerator), } } } else { - task.ExistingClusterId = opts.ClusterID + task.ExistingClusterId = utils.NonZero(opts.ClusterID) } - submitRequest := jobs.SubmitRun{ - RunName: "ssh-server-bootstrap-" + sessionID, - TimeoutSeconds: int(opts.ServerTimeout.Seconds()), - Tasks: []jobs.SubmitTask{task}, - BudgetPolicyId: opts.UsagePolicyID, + submitRequest := jobs.SubmitRunRequest{ + RunName: new("ssh-server-bootstrap-" + sessionID), + TimeoutSeconds: utils.NonZero(int(opts.ServerTimeout.Seconds())), + Tasks: []jobs.RunTaskSettings{task}, + BudgetPolicyId: utils.NonZero(opts.UsagePolicyID), } if opts.IsServerlessMode() { // base_environment and environment_version are mutually exclusive: a custom // base environment carries its own version, so we don't also set one. - var spec compute.Environment + var spec jobs.Environment if baseEnvironment != "" { - spec.BaseEnvironment = baseEnvironment + spec.BaseEnvironment = new(baseEnvironment) } else { - spec.EnvironmentVersion = strconv.Itoa(max(opts.EnvironmentVersion, minEnvironmentVersion)) + spec.EnvironmentVersion = new(strconv.Itoa(max(opts.EnvironmentVersion, minEnvironmentVersion))) } submitRequest.Environments = []jobs.JobEnvironment{ { - EnvironmentKey: serverlessEnvironmentKey, + EnvironmentKey: new(serverlessEnvironmentKey), Spec: &spec, }, } @@ -785,7 +788,7 @@ func buildSSHServerSubmitRun(version, secretScopeName, jobNotebookPath, baseEnvi // submitSSHTunnelJob submits the bootstrap job and waits for the SSH server task to start. // It returns the job run ID (when known) so callers can fetch and surface the run's error // details if the server never comes up. -func submitSSHTunnelJob(ctx context.Context, client *databricks.WorkspaceClient, version, secretScopeName string, opts ClientOptions) (int64, error) { +func submitSSHTunnelJob(ctx context.Context, client *sdkclients.Clients, version, secretScopeName string, opts ClientOptions) (int64, error) { sessionID := opts.SessionIdentifier() contentDir, err := sshWorkspace.GetWorkspaceContentDir(ctx, client, version, sessionID) if err != nil { @@ -801,11 +804,11 @@ func submitSSHTunnelJob(ctx context.Context, client *databricks.WorkspaceClient, notebookContent := "# Databricks notebook source\n" + sshServerBootstrapScript encodedContent := base64.StdEncoding.EncodeToString([]byte(notebookContent)) - err = client.Workspace.Import(ctx, workspace.Import{ + err = client.Workspace.Import(ctx, workspaceapi.Import{ Path: jobNotebookPath, - Format: workspace.ImportFormatSource, + Format: workspaceapi.ImportFormatSource, Content: encodedContent, - Language: workspace.LanguagePython, + Language: workspaceapi.LanguagePython, Overwrite: true, }) if err != nil { @@ -827,15 +830,20 @@ func submitSSHTunnelJob(ctx context.Context, client *databricks.WorkspaceClient, submitRequest := buildSSHServerSubmitRun(version, secretScopeName, jobNotebookPath, baseEnvironment, opts) - waiter, err := client.Jobs.Submit(ctx, submitRequest) + sdkRequest, err := jobs.SubmitRunRequestToSDK(&submitRequest) if err != nil { return 0, fmt.Errorf("failed to submit job: %w", err) } + waiter, err := client.Jobs.SubmitRun(ctx, *sdkRequest) + if err != nil { + return 0, fmt.Errorf("failed to submit job: %w", err) + } + runID := waiter.GetRunId() - cmdio.LogString(ctx, fmt.Sprintf("Job submitted successfully with run ID: %d", waiter.RunId)) + cmdio.LogString(ctx, fmt.Sprintf("Job submitted successfully with run ID: %d", runID)) // Return the run ID even on error so callers can fetch the run's failure details. - return waiter.RunId, waitForJobToStart(ctx, client, waiter.RunId, opts) + return runID, waitForJobToStart(ctx, client, runID, opts) } // resolveBaseEnvironment maps the user-provided --base-environment value to a @@ -843,20 +851,20 @@ func submitSSHTunnelJob(ctx context.Context, client *databricks.WorkspaceClient, // "workspace-base-environments/" prefix is a resource ID; both are passed through // verbatim. Anything else is treated as a display name and resolved to its resource ID // via the workspace base environments listing. -func resolveBaseEnvironment(ctx context.Context, client *databricks.WorkspaceClient, input string) (string, error) { +func resolveBaseEnvironment(ctx context.Context, client *sdkclients.Clients, input string) (string, error) { if strings.HasPrefix(input, "/") || strings.HasPrefix(input, "workspace-base-environments/") { return input, nil } - envs, err := client.Environments.ListWorkspaceBaseEnvironmentsAll(ctx, environments.ListWorkspaceBaseEnvironmentsRequest{}) + envs, err := listing.Collect(client.Environments.ListWorkspaceBaseEnvironmentsIter(ctx, environments.ListWorkspaceBaseEnvironmentsRequest{})) if err != nil { return "", fmt.Errorf("failed to list workspace base environments: %w", err) } var matches []string for _, e := range envs { - if e.DisplayName == input { - matches = append(matches, e.Name) + if utils.Deref(e.DisplayName) == input { + matches = append(matches, utils.Deref(e.Name)) } } switch len(matches) { @@ -986,7 +994,7 @@ func buildSSHArgs(userName, privateKeyPath, knownHostsPath, proxyCommand, hostNa return sshArgs } -func spawnSSHClient(ctx context.Context, client *databricks.WorkspaceClient, userName, privateKeyPath, knownHostsPath string, serverPort int, clusterID, version string, opts ClientOptions) error { +func spawnSSHClient(ctx context.Context, client *sdkclients.Clients, userName, privateKeyPath, knownHostsPath string, serverPort int, clusterID, version string, opts ClientOptions) error { // Create a copy with metadata for the ProxyCommand optsWithMetadata := opts optsWithMetadata.ServerMetadata = FormatMetadata(userName, serverPort, clusterID) @@ -1003,10 +1011,10 @@ func spawnSSHClient(ctx context.Context, client *databricks.WorkspaceClient, use // OS home. Only needed for an interactive session; skip the lookup otherwise. var wsHome string if len(opts.AdditionalArgs) == 0 { - if currentUser, err := client.CurrentUser.Me(ctx, iam.MeRequest{}); err != nil { + if currentUser, err := client.Scim.Me(ctx, sdkscim.MeRequest{}); err != nil { log.Warnf(ctx, "Failed to resolve current user for workspace home directory: %v", err) } else { - wsHome = "/Workspace/Users/" + currentUser.UserName + wsHome = "/Workspace/Users/" + utils.Deref(currentUser.UserName) } } @@ -1043,7 +1051,7 @@ func spawnSSHClient(ctx context.Context, client *databricks.WorkspaceClient, use return err } -func runSSHProxy(ctx context.Context, client *databricks.WorkspaceClient, serverPort int, clusterID string, opts ClientOptions) error { +func runSSHProxy(ctx context.Context, client *sdkclients.Clients, serverPort int, clusterID string, opts ClientOptions) error { resumable := serverSupportsResume(ctx, client, clusterID, serverPort, opts.Liteswap) if !resumable { log.Infof(ctx, "The SSH server does not support session resume, a dropped connection will end the session") @@ -1064,7 +1072,7 @@ func runSSHProxy(ctx context.Context, client *databricks.WorkspaceClient, server var capabilitiesProbeTimeout = 10 * time.Second // serverSupportsResume reports whether the running SSH server speaks the resume protocol. -func serverSupportsResume(ctx context.Context, client *databricks.WorkspaceClient, clusterID string, serverPort int, liteswap string) bool { +func serverSupportsResume(ctx context.Context, client *sdkclients.Clients, clusterID string, serverPort int, liteswap string) bool { req, err := newDriverProxyRequest(ctx, client, clusterID, serverPort, "capabilities", liteswap) if err != nil { log.Debugf(ctx, "Failed to build the server capabilities request: %v", err) @@ -1102,14 +1110,14 @@ func serverSupportsResume(ctx context.Context, client *databricks.WorkspaceClien // set. Legacy/auto/unknown modes fall back to their raw value. func accessModeUILabel(mode compute.DataSecurityMode, singleUserName string) string { switch mode { - case compute.DataSecurityModeSingleUser, compute.DataSecurityModeDataSecurityModeDedicated: + case compute.DataSecurityMode_SingleUser, compute.DataSecurityMode_DataSecurityModeDedicated: if singleUserName == "" { return "Dedicated (group)" } return "Dedicated (single user)" - case compute.DataSecurityModeUserIsolation, compute.DataSecurityModeDataSecurityModeStandard: + case compute.DataSecurityMode_UserIsolation, compute.DataSecurityMode_DataSecurityModeStandard: return "Standard" - case compute.DataSecurityModeNone: + case compute.DataSecurityMode_None: return "No isolation" default: return string(mode) @@ -1120,37 +1128,38 @@ func accessModeUILabel(mode compute.DataSecurityMode, singleUserName string) str // The SSH tunnel runs as a job that attaches as a single user, so the cluster must be in // Dedicated access mode and assigned to one user (single_user_name set), not a group. We fail // early with an actionable message rather than letting the connection fail later. -func ValidateClusterAccess(ctx context.Context, client *databricks.WorkspaceClient, clusterID string) error { - clusterInfo, err := client.Clusters.Get(ctx, compute.GetClusterRequest{ClusterId: clusterID}) +func ValidateClusterAccess(ctx context.Context, client *sdkclients.Clients, clusterID string) error { + clusterInfo, err := client.Clusters.GetCluster(ctx, compute.GetClusterRequest{ClusterId: new(clusterID)}) if err != nil { return fmt.Errorf("failed to get cluster information for cluster ID '%s': %w", clusterID, err) } // SINGLE_USER is the legacy alias for the newer DATA_SECURITY_MODE_DEDICATED enum; the API // may return either for a dedicated cluster, so accept both. - isDedicated := clusterInfo.DataSecurityMode == compute.DataSecurityModeSingleUser || - clusterInfo.DataSecurityMode == compute.DataSecurityModeDataSecurityModeDedicated - if !isDedicated || clusterInfo.SingleUserName == "" { - return fmt.Errorf("cluster '%s' must be a dedicated single-user cluster. Current access mode: %s. Please reconfigure it to Dedicated (single user) access mode", clusterID, accessModeUILabel(clusterInfo.DataSecurityMode, clusterInfo.SingleUserName)) + isDedicated := clusterInfo.DataSecurityMode == compute.DataSecurityMode_SingleUser || + clusterInfo.DataSecurityMode == compute.DataSecurityMode_DataSecurityModeDedicated + singleUserName := utils.Deref(clusterInfo.SingleUserName) + if !isDedicated || singleUserName == "" { + return fmt.Errorf("cluster '%s' must be a dedicated single-user cluster. Current access mode: %s. Please reconfigure it to Dedicated (single user) access mode", clusterID, accessModeUILabel(clusterInfo.DataSecurityMode, singleUserName)) } return nil } -func checkClusterState(ctx context.Context, client *databricks.WorkspaceClient, clusterID string, autoStart bool) error { +func checkClusterState(ctx context.Context, client *sdkclients.Clients, clusterID string, autoStart bool) error { sp := cmdio.NewSpinner(ctx, cmdio.WithElapsedTime()) defer sp.Close() if autoStart { sp.Update("Waiting for compute to start...") - err := client.Clusters.EnsureClusterIsRunning(ctx, clusterID) + err := client.EnsureClusterIsRunning(ctx, clusterID) if err != nil { return fmt.Errorf("failed to ensure that the cluster is running: %w", err) } } else { sp.Update("Checking cluster state...") - cluster, err := client.Clusters.GetByClusterId(ctx, clusterID) + cluster, err := client.Clusters.GetCluster(ctx, compute.GetClusterRequest{ClusterId: new(clusterID)}) if err != nil { return fmt.Errorf("failed to get cluster info: %w", err) } - if cluster.State != compute.StateRunning { + if cluster.State != compute.ClusterState_ClusterState_Running { return fmt.Errorf("cluster %s is not running, current state: %s. Use --auto-start-cluster to start it automatically", clusterID, cluster.State) } } @@ -1159,7 +1168,7 @@ func checkClusterState(ctx context.Context, client *databricks.WorkspaceClient, // waitForJobToStart polls the task status until the SSH server task is in RUNNING state or terminates. // Returns an error if the task fails to start or if polling times out. -func waitForJobToStart(ctx context.Context, client *databricks.WorkspaceClient, runID int64, opts ClientOptions) error { +func waitForJobToStart(ctx context.Context, client *sdkclients.Clients, runID int64, opts ClientOptions) error { waitingMessage := "Waiting for compute to start..." if opts.Accelerator != "" { // GPU capacity is acquired on demand and the wait varies a lot by accelerator @@ -1177,31 +1186,28 @@ func waitForJobToStart(ctx context.Context, client *databricks.WorkspaceClient, sp := cmdio.NewSpinner(ctx, cmdio.WithElapsedTime()) defer sp.Close() sp.Update(waitingMessage) - var prevState jobs.RunLifecycleStateV2State + var prevState jobs.RunLifecycleStateV2_State - _, err := retries.Poll(ctx, opts.TaskStartupTimeout, func() (*jobs.RunTask, *retries.Err) { - run, err := client.Jobs.GetRun(ctx, jobs.GetRunRequest{ - RunId: runID, - }) + ctx, cancel := context.WithTimeout(ctx, opts.TaskStartupTimeout) + defer cancel() + lastStatus := "" + for attempt := 1; ; attempt++ { + run, err := getRun(ctx, client, runID) if err != nil { - return nil, retries.Halt(fmt.Errorf("failed to get job run status: %w", err)) - } - - // Find the SSH server task - var sshTask *jobs.RunTask - for i := range run.Tasks { - if run.Tasks[i].TaskKey == sshServerTaskKey { - sshTask = &run.Tasks[i] - break + if ctx.Err() != nil && lastStatus != "" { + return fmt.Errorf("timed out after %s: %s", opts.TaskStartupTimeout, lastStatus) } + return fmt.Errorf("failed to get job run status: %w", err) } + // Find the SSH server task + sshTask := findSSHServerTask(run) if sshTask == nil { - return nil, retries.Halt(fmt.Errorf("SSH server task '%s' not found in job run", sshServerTaskKey)) + return fmt.Errorf("SSH server task '%s' not found in job run", sshServerTaskKey) } if sshTask.Status == nil { - return nil, retries.Halt(errors.New("task status is nil")) + return errors.New("task status is nil") } currentState := sshTask.Status.State @@ -1213,21 +1219,43 @@ func waitForJobToStart(ctx context.Context, client *databricks.WorkspaceClient, } // Check if task is running - if currentState == jobs.RunLifecycleStateV2StateRunning { - return sshTask, nil + if currentState == jobs.RunLifecycleStateV2_State_Running { + return nil } // Check for terminal failure states. Surface the run's actual error (e.g. a notebook // traceback or "Could not reach driver") instead of a generic message. - if currentState == jobs.RunLifecycleStateV2StateTerminated { - return nil, retries.Halt(fmt.Errorf("ssh server bootstrap job failed:\n%s", describeRunFailure(ctx, client, runID))) + if currentState == jobs.RunLifecycleStateV2_State_Terminated { + return fmt.Errorf("ssh server bootstrap job failed:\n%s", describeRunFailure(ctx, client, runID)) } // Continue polling for other states - return nil, retries.Continues(fmt.Sprintf("waiting for task to start (current state: %s)", currentState)) - }) + lastStatus = fmt.Sprintf("waiting for task to start (current state: %s)", currentState) + select { + case <-ctx.Done(): + return fmt.Errorf("timed out after %s: %s", opts.TaskStartupTimeout, lastStatus) + case <-time.After(min(time.Duration(attempt)*time.Second, 10*time.Second)): + } + } +} - return err +// findSSHServerTask returns the SSH server task of the run, or nil. +func findSSHServerTask(run *jobs.GetRunResponse) *jobs.RunTask { + for i := range run.Tasks { + if utils.Deref(run.Tasks[i].TaskKey) == sshServerTaskKey { + return &run.Tasks[i] + } + } + return nil +} + +// getRun fetches a job run as its JSON-capable mirror. +func getRun(ctx context.Context, client *sdkclients.Clients, runID int64) (*jobs.GetRunResponse, error) { + run, err := client.Jobs.GetRun(ctx, sdkjobs.GetRunRequest{RunId: new(runID)}) + if err != nil { + return nil, err + } + return jobs.GetRunResponseFromSDK(run) } // maxRunFailureTraceBytes bounds how much of a failed run's error trace we print to the @@ -1237,41 +1265,35 @@ const maxRunFailureTraceBytes = 2000 // describeRunFailure fetches a failed bootstrap run's error details and formats them for the // terminal. It is best-effort: any API error is folded into the returned text rather than // propagated, so callers can always embed the result in their own error. -func describeRunFailure(ctx context.Context, client *databricks.WorkspaceClient, runID int64) string { +func describeRunFailure(ctx context.Context, client *sdkclients.Clients, runID int64) string { if runID == 0 { return " (no job run ID available)" } - run, err := client.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: runID}) + run, err := getRun(ctx, client, runID) if err != nil { - return fmt.Sprintf(" could not fetch job run %d: %v", runID, err) + return fmt.Sprintf(" could not fetch job run %d: %s", runID, apierrs.ErrorString(err)) } var b strings.Builder // Locate the SSH server task to read its termination reason and per-task run output. - var sshTask *jobs.RunTask - for i := range run.Tasks { - if run.Tasks[i].TaskKey == sshServerTaskKey { - sshTask = &run.Tasks[i] - break - } - } + sshTask := findSSHServerTask(run) if sshTask != nil && sshTask.Status != nil && sshTask.Status.TerminationDetails != nil { - if msg := strings.TrimSpace(sshTask.Status.TerminationDetails.Message); msg != "" { + if msg := strings.TrimSpace(utils.Deref(sshTask.Status.TerminationDetails.Message)); msg != "" { fmt.Fprintf(&b, " %s\n", msg) } } // The notebook error/traceback carries the real cause (e.g. a Python exception). outputRunID := runID - if sshTask != nil && sshTask.RunId != 0 { - outputRunID = sshTask.RunId + if sshTask != nil && utils.Deref(sshTask.RunId) != 0 { + outputRunID = *sshTask.RunId } - if output, err := client.Jobs.GetRunOutput(ctx, jobs.GetRunOutputRequest{RunId: outputRunID}); err == nil && output != nil { - e := strings.TrimSpace(output.Error) - trace := strings.TrimSpace(output.ErrorTrace) + if output, err := client.Jobs.GetRunOutput(ctx, sdkjobs.GetRunOutputRequest{RunId: new(outputRunID)}); err == nil && output != nil { + e := strings.TrimSpace(utils.Deref(output.Error)) + trace := strings.TrimSpace(utils.Deref(output.ErrorTrace)) // Notebook tracebacks end with the same message as Error; skip Error then so the // server-log tail the bootstrap embeds in the message isn't printed twice. if e != "" && !strings.Contains(trace, e) { @@ -1282,8 +1304,8 @@ func describeRunFailure(ctx context.Context, client *databricks.WorkspaceClient, } } - if run.RunPageUrl != "" { - fmt.Fprintf(&b, " See the full job logs: %s", run.RunPageUrl) + if utils.Deref(run.RunPageUrl) != "" { + fmt.Fprintf(&b, " See the full job logs: %s", *run.RunPageUrl) } if b.Len() == 0 { @@ -1294,19 +1316,19 @@ func describeRunFailure(ctx context.Context, client *databricks.WorkspaceClient, // runFailureIfTerminated reports whether the bootstrap run has reached a terminal state (so the // SSH server will never come up), returning a formatted failure description when it has. -func runFailureIfTerminated(ctx context.Context, client *databricks.WorkspaceClient, runID int64) (string, bool) { +func runFailureIfTerminated(ctx context.Context, client *sdkclients.Clients, runID int64) (string, bool) { if runID == 0 { return "", false } - run, err := client.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: runID}) + run, err := getRun(ctx, client, runID) if err != nil { return "", false } for i := range run.Tasks { - if run.Tasks[i].TaskKey != sshServerTaskKey { + if utils.Deref(run.Tasks[i].TaskKey) != sshServerTaskKey { continue } - if run.Tasks[i].Status != nil && run.Tasks[i].Status.State == jobs.RunLifecycleStateV2StateTerminated { + if run.Tasks[i].Status != nil && run.Tasks[i].Status.State == jobs.RunLifecycleStateV2_State_Terminated { return describeRunFailure(ctx, client, runID), true } return "", false @@ -1375,7 +1397,7 @@ func keepDetachedMatches(stored, requested bool) bool { return !requested || stored } -func ensureSSHServerIsRunning(ctx context.Context, client *databricks.WorkspaceClient, version, secretScopeName string, opts ClientOptions) (string, int, string, error) { +func ensureSSHServerIsRunning(ctx context.Context, client *sdkclients.Clients, version, secretScopeName string, opts ClientOptions) (string, int, string, error) { sessionID := opts.SessionIdentifier() // For dedicated clusters, use clusterID; for serverless, it will be read from metadata clusterID := opts.ClusterID diff --git a/experimental/ssh/internal/client/client_internal_test.go b/experimental/ssh/internal/client/client_internal_test.go index ce7888d151e..dd87245c712 100644 --- a/experimental/ssh/internal/client/client_internal_test.go +++ b/experimental/ssh/internal/client/client_internal_test.go @@ -15,25 +15,19 @@ import ( "github.com/databricks/cli/experimental/ssh/internal/sshconfig" "github.com/databricks/cli/experimental/ssh/internal/vscode" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/telemetry/protos" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/environments" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/utils" + compute "github.com/databricks/sdk-go/clusters/v2" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) func TestValidateClusterAccessSingleUser(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - m := mocks.NewMockWorkspaceClient(t) - m.GetMockClustersAPI().EXPECT().Get(ctx, compute.GetClusterRequest{ClusterId: "cluster-123"}).Return(&compute.ClusterDetails{ - DataSecurityMode: compute.DataSecurityModeSingleUser, - SingleUserName: "me@example.com", - }, nil) + m := newFakeClients(t, map[string]any{"GET /api/2.1/clusters/get": `{"data_security_mode":"SINGLE_USER","single_user_name":"me@example.com"}`}) - err := ValidateClusterAccess(ctx, m.WorkspaceClient, "cluster-123") + err := ValidateClusterAccess(ctx, m, "cluster-123") assert.NoError(t, err) } @@ -41,24 +35,17 @@ func TestValidateClusterAccessSingleUser(t *testing.T) { // legacy SINGLE_USER alias) must still pass validation. func TestValidateClusterAccessDedicatedEnum(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - m := mocks.NewMockWorkspaceClient(t) - m.GetMockClustersAPI().EXPECT().Get(ctx, compute.GetClusterRequest{ClusterId: "cluster-123"}).Return(&compute.ClusterDetails{ - DataSecurityMode: compute.DataSecurityModeDataSecurityModeDedicated, - SingleUserName: "me@example.com", - }, nil) + m := newFakeClients(t, map[string]any{"GET /api/2.1/clusters/get": `{"data_security_mode":"DATA_SECURITY_MODE_DEDICATED","single_user_name":"me@example.com"}`}) - err := ValidateClusterAccess(ctx, m.WorkspaceClient, "cluster-123") + err := ValidateClusterAccess(ctx, m, "cluster-123") assert.NoError(t, err) } func TestValidateClusterAccessInvalidAccessMode(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - m := mocks.NewMockWorkspaceClient(t) - m.GetMockClustersAPI().EXPECT().Get(ctx, compute.GetClusterRequest{ClusterId: "cluster-123"}).Return(&compute.ClusterDetails{ - DataSecurityMode: compute.DataSecurityModeUserIsolation, - }, nil) + m := newFakeClients(t, map[string]any{"GET /api/2.1/clusters/get": `{"data_security_mode":"USER_ISOLATION"}`}) - err := ValidateClusterAccess(ctx, m.WorkspaceClient, "cluster-123") + err := ValidateClusterAccess(ctx, m, "cluster-123") assert.Error(t, err) assert.Contains(t, err.Error(), "must be a dedicated single-user cluster") // The error surfaces the UI label ("Standard"), not the raw API enum (USER_ISOLATION). @@ -70,12 +57,9 @@ func TestValidateClusterAccessInvalidAccessMode(t *testing.T) { // reports the mode specifically as "Dedicated (group)". func TestValidateClusterAccessDedicatedGroup(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - m := mocks.NewMockWorkspaceClient(t) - m.GetMockClustersAPI().EXPECT().Get(ctx, compute.GetClusterRequest{ClusterId: "cluster-123"}).Return(&compute.ClusterDetails{ - DataSecurityMode: compute.DataSecurityModeDataSecurityModeDedicated, - }, nil) + m := newFakeClients(t, map[string]any{"GET /api/2.1/clusters/get": `{"data_security_mode":"DATA_SECURITY_MODE_DEDICATED"}`}) - err := ValidateClusterAccess(ctx, m.WorkspaceClient, "cluster-123") + err := ValidateClusterAccess(ctx, m, "cluster-123") assert.Error(t, err) assert.Contains(t, err.Error(), "must be a dedicated single-user cluster") assert.Contains(t, err.Error(), "Current access mode: Dedicated (group)") @@ -87,14 +71,14 @@ func TestAccessModeUILabel(t *testing.T) { singleUserName string want string }{ - {compute.DataSecurityModeSingleUser, "me@example.com", "Dedicated (single user)"}, - {compute.DataSecurityModeDataSecurityModeDedicated, "me@example.com", "Dedicated (single user)"}, - {compute.DataSecurityModeDataSecurityModeDedicated, "", "Dedicated (group)"}, - {compute.DataSecurityModeUserIsolation, "", "Standard"}, - {compute.DataSecurityModeDataSecurityModeStandard, "", "Standard"}, - {compute.DataSecurityModeNone, "", "No isolation"}, + {compute.DataSecurityMode_SingleUser, "me@example.com", "Dedicated (single user)"}, + {compute.DataSecurityMode_DataSecurityModeDedicated, "me@example.com", "Dedicated (single user)"}, + {compute.DataSecurityMode_DataSecurityModeDedicated, "", "Dedicated (group)"}, + {compute.DataSecurityMode_UserIsolation, "", "Standard"}, + {compute.DataSecurityMode_DataSecurityModeStandard, "", "Standard"}, + {compute.DataSecurityMode_None, "", "No isolation"}, // Legacy/unknown modes fall back to the raw API value. - {compute.DataSecurityModeLegacyTableAcl, "", "LEGACY_TABLE_ACL"}, + {compute.DataSecurityMode_LegacyTableAcl, "", "LEGACY_TABLE_ACL"}, } for _, tt := range tests { assert.Equal(t, tt.want, accessModeUILabel(tt.mode, tt.singleUserName), "mode=%s", tt.mode) @@ -103,25 +87,24 @@ func TestAccessModeUILabel(t *testing.T) { func TestValidateClusterAccessClusterNotFound(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - m := mocks.NewMockWorkspaceClient(t) - m.GetMockClustersAPI().EXPECT().Get(ctx, compute.GetClusterRequest{ClusterId: "nonexistent"}).Return(nil, errors.New("cluster not found")) + m := newFakeClients(t, map[string]any{"GET /api/2.1/clusters/get": apiError{404, "cluster not found"}}) - err := ValidateClusterAccess(ctx, m.WorkspaceClient, "nonexistent") + err := ValidateClusterAccess(ctx, m, "nonexistent") assert.Error(t, err) assert.Contains(t, err.Error(), "failed to get cluster information for cluster ID 'nonexistent'") } // terminatedRun builds a job run whose SSH server task has terminated, for the failure-surfacing tests. -func terminatedRun(runID, taskRunID int64, message, pageURL string) *jobs.Run { - return &jobs.Run{ - RunId: runID, - RunPageUrl: pageURL, +func terminatedRun(runID, taskRunID int64, message, pageURL string) *jobs.GetRunResponse { + return &jobs.GetRunResponse{ + RunId: new(runID), + RunPageUrl: new(pageURL), Tasks: []jobs.RunTask{{ - TaskKey: sshServerTaskKey, - RunId: taskRunID, + TaskKey: new(sshServerTaskKey), + RunId: new(taskRunID), Status: &jobs.RunStatus{ - State: jobs.RunLifecycleStateV2StateTerminated, - TerminationDetails: &jobs.TerminationDetails{Message: message}, + State: jobs.RunLifecycleStateV2_State_Terminated, + TerminationDetails: &jobs.TerminationDetails{Message: utils.NonZero(message)}, }, }}, } @@ -132,56 +115,39 @@ func TestResolveBaseEnvironment(t *testing.T) { // Paths and resource IDs are passed through without hitting the API. t.Run("env.yaml path passthrough", func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - got, err := resolveBaseEnvironment(ctx, m.WorkspaceClient, "/Workspace/path/to/env.yaml") + m := newFakeClients(t, nil) + got, err := resolveBaseEnvironment(ctx, m, "/Workspace/path/to/env.yaml") require.NoError(t, err) assert.Equal(t, "/Workspace/path/to/env.yaml", got) }) t.Run("resource ID passthrough", func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - got, err := resolveBaseEnvironment(ctx, m.WorkspaceClient, "workspace-base-environments/dbe_123") + m := newFakeClients(t, nil) + got, err := resolveBaseEnvironment(ctx, m, "workspace-base-environments/dbe_123") require.NoError(t, err) assert.Equal(t, "workspace-base-environments/dbe_123", got) }) t.Run("display name resolves to resource ID", func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockEnvironmentsAPI().EXPECT(). - ListWorkspaceBaseEnvironmentsAll(mock.Anything, environments.ListWorkspaceBaseEnvironmentsRequest{}). - Return([]environments.WorkspaceBaseEnvironment{ - {DisplayName: "other", Name: "workspace-base-environments/dbe_other"}, - {DisplayName: "my-env", Name: "workspace-base-environments/dbe_mine"}, - }, nil) - - got, err := resolveBaseEnvironment(ctx, m.WorkspaceClient, "my-env") + m := newFakeClients(t, map[string]any{"GET /api/environments/v1/workspace-base-environments": `{"workspace_base_environments":[{"display_name":"other","name":"workspace-base-environments/dbe_other"},{"display_name":"my-env","name":"workspace-base-environments/dbe_mine"}]}`}) + + got, err := resolveBaseEnvironment(ctx, m, "my-env") require.NoError(t, err) assert.Equal(t, "workspace-base-environments/dbe_mine", got) }) t.Run("display name not found", func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockEnvironmentsAPI().EXPECT(). - ListWorkspaceBaseEnvironmentsAll(mock.Anything, environments.ListWorkspaceBaseEnvironmentsRequest{}). - Return([]environments.WorkspaceBaseEnvironment{ - {DisplayName: "other", Name: "workspace-base-environments/dbe_other"}, - }, nil) - - _, err := resolveBaseEnvironment(ctx, m.WorkspaceClient, "my-env") + m := newFakeClients(t, map[string]any{"GET /api/environments/v1/workspace-base-environments": `{"workspace_base_environments":[{"display_name":"other","name":"workspace-base-environments/dbe_other"}]}`}) + + _, err := resolveBaseEnvironment(ctx, m, "my-env") require.Error(t, err) assert.Contains(t, err.Error(), `no workspace base environment found with display name "my-env"`) }) t.Run("display name ambiguous", func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - m.GetMockEnvironmentsAPI().EXPECT(). - ListWorkspaceBaseEnvironmentsAll(mock.Anything, environments.ListWorkspaceBaseEnvironmentsRequest{}). - Return([]environments.WorkspaceBaseEnvironment{ - {DisplayName: "my-env", Name: "workspace-base-environments/dbe_1"}, - {DisplayName: "my-env", Name: "workspace-base-environments/dbe_2"}, - }, nil) - - _, err := resolveBaseEnvironment(ctx, m.WorkspaceClient, "my-env") + m := newFakeClients(t, map[string]any{"GET /api/environments/v1/workspace-base-environments": `{"workspace_base_environments":[{"display_name":"my-env","name":"workspace-base-environments/dbe_1"},{"display_name":"my-env","name":"workspace-base-environments/dbe_2"}]}`}) + + _, err := resolveBaseEnvironment(ctx, m, "my-env") require.Error(t, err) assert.Contains(t, err.Error(), `multiple workspace base environments found with display name "my-env"`) }) @@ -189,14 +155,12 @@ func TestResolveBaseEnvironment(t *testing.T) { func TestDescribeRunFailureIncludesMessageTraceAndURL(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockJobsAPI() - api.EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{RunId: 1}).Return( - terminatedRun(1, 99, "Could not reach driver of cluster 0605-x.", "https://example.test/run/1"), nil) - api.EXPECT().GetRunOutput(mock.Anything, jobs.GetRunOutputRequest{RunId: 99}).Return( - &jobs.RunOutput{Error: "Run failed with error message", ErrorTrace: "Traceback (most recent call last): boom"}, nil) - - out := describeRunFailure(ctx, m.WorkspaceClient, 1) + m := newFakeClients(t, map[string]any{ + "GET /api/2.2/jobs/runs/get?run_id=1": terminatedRun(1, 99, "Could not reach driver of cluster 0605-x.", "https://example.test/run/1"), + "GET /api/2.2/jobs/runs/get-output?run_id=99": &jobs.GetRunOutputResponse{Error: new("Run failed with error message"), ErrorTrace: new("Traceback (most recent call last): boom")}, + }) + + out := describeRunFailure(ctx, m, 1) assert.Contains(t, out, "Could not reach driver of cluster 0605-x.") assert.Contains(t, out, "Run failed with error message") assert.Contains(t, out, "Traceback (most recent call last): boom") @@ -205,15 +169,13 @@ func TestDescribeRunFailureIncludesMessageTraceAndURL(t *testing.T) { func TestDescribeRunFailureTruncatesLongTrace(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockJobsAPI() longTrace := strings.Repeat("x", maxRunFailureTraceBytes+500) + "TAIL_MARKER" - api.EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{RunId: 1}).Return( - terminatedRun(1, 99, "", "https://example.test/run/1"), nil) - api.EXPECT().GetRunOutput(mock.Anything, jobs.GetRunOutputRequest{RunId: 99}).Return( - &jobs.RunOutput{ErrorTrace: longTrace}, nil) + m := newFakeClients(t, map[string]any{ + "GET /api/2.2/jobs/runs/get?run_id=1": terminatedRun(1, 99, "", "https://example.test/run/1"), + "GET /api/2.2/jobs/runs/get-output?run_id=99": &jobs.GetRunOutputResponse{ErrorTrace: new(longTrace)}, + }) - out := describeRunFailure(ctx, m.WorkspaceClient, 1) + out := describeRunFailure(ctx, m, 1) assert.Contains(t, out, "...") assert.Contains(t, out, "TAIL_MARKER") // The leading run of 'x' is dropped by truncation. @@ -222,30 +184,26 @@ func TestDescribeRunFailureTruncatesLongTrace(t *testing.T) { func TestDescribeRunFailureDeduplicatesErrorInTrace(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockJobsAPI() errMsg := "SSH server exited with code 1. Last server logs:\nLOG_MARKER" - api.EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{RunId: 1}).Return( - terminatedRun(1, 99, "", "https://example.test/run/1"), nil) - api.EXPECT().GetRunOutput(mock.Anything, jobs.GetRunOutputRequest{RunId: 99}).Return( - &jobs.RunOutput{Error: errMsg, ErrorTrace: "Traceback (most recent call last):\n boom\nRuntimeError: " + errMsg}, nil) + m := newFakeClients(t, map[string]any{ + "GET /api/2.2/jobs/runs/get?run_id=1": terminatedRun(1, 99, "", "https://example.test/run/1"), + "GET /api/2.2/jobs/runs/get-output?run_id=99": &jobs.GetRunOutputResponse{Error: new(errMsg), ErrorTrace: new("Traceback (most recent call last):\n boom\nRuntimeError: " + errMsg)}, + }) - out := describeRunFailure(ctx, m.WorkspaceClient, 1) + out := describeRunFailure(ctx, m, 1) assert.Contains(t, out, "Traceback (most recent call last):") assert.Equal(t, 1, strings.Count(out, "LOG_MARKER")) } func TestDescribeRunFailureTruncatesLongError(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockJobsAPI() longError := strings.Repeat("x", maxRunFailureTraceBytes+500) + "TAIL_MARKER" - api.EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{RunId: 1}).Return( - terminatedRun(1, 99, "", "https://example.test/run/1"), nil) - api.EXPECT().GetRunOutput(mock.Anything, jobs.GetRunOutputRequest{RunId: 99}).Return( - &jobs.RunOutput{Error: longError}, nil) + m := newFakeClients(t, map[string]any{ + "GET /api/2.2/jobs/runs/get?run_id=1": terminatedRun(1, 99, "", "https://example.test/run/1"), + "GET /api/2.2/jobs/runs/get-output?run_id=99": &jobs.GetRunOutputResponse{Error: new(longError)}, + }) - out := describeRunFailure(ctx, m.WorkspaceClient, 1) + out := describeRunFailure(ctx, m, 1) assert.Contains(t, out, "...") assert.Contains(t, out, "TAIL_MARKER") assert.NotContains(t, out, strings.Repeat("x", maxRunFailureTraceBytes+1)) @@ -253,8 +211,8 @@ func TestDescribeRunFailureTruncatesLongError(t *testing.T) { func TestDescribeRunFailureNoRunID(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - m := mocks.NewMockWorkspaceClient(t) - out := describeRunFailure(ctx, m.WorkspaceClient, 0) + m := newFakeClients(t, nil) + out := describeRunFailure(ctx, m, 0) assert.Contains(t, out, "no job run ID") } @@ -262,44 +220,40 @@ func TestRunFailureIfTerminated(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) t.Run("terminated", func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockJobsAPI() - api.EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{RunId: 1}).Return( - terminatedRun(1, 99, "boom", "https://example.test/run/1"), nil) - api.EXPECT().GetRunOutput(mock.Anything, jobs.GetRunOutputRequest{RunId: 99}).Return( - &jobs.RunOutput{}, nil) - - desc, terminated := runFailureIfTerminated(ctx, m.WorkspaceClient, 1) + m := newFakeClients(t, map[string]any{ + "GET /api/2.2/jobs/runs/get?run_id=1": terminatedRun(1, 99, "boom", "https://example.test/run/1"), + "GET /api/2.2/jobs/runs/get-output?run_id=99": &jobs.GetRunOutputResponse{}, + }) + + desc, terminated := runFailureIfTerminated(ctx, m, 1) assert.True(t, terminated) assert.Contains(t, desc, "boom") }) t.Run("still running", func(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockJobsAPI() - api.EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{RunId: 1}).Return(&jobs.Run{ - RunId: 1, - Tasks: []jobs.RunTask{{ - TaskKey: sshServerTaskKey, - Status: &jobs.RunStatus{State: jobs.RunLifecycleStateV2StateRunning}, - }}, - }, nil) - - _, terminated := runFailureIfTerminated(ctx, m.WorkspaceClient, 1) + m := newFakeClients(t, map[string]any{ + "GET /api/2.2/jobs/runs/get?run_id=1": &jobs.GetRunResponse{ + RunId: new(int64(1)), + Tasks: []jobs.RunTask{{ + TaskKey: new(sshServerTaskKey), + Status: &jobs.RunStatus{State: jobs.RunLifecycleStateV2_State_Running}, + }}, + }, + }) + + _, terminated := runFailureIfTerminated(ctx, m, 1) assert.False(t, terminated) }) } func TestWaitForJobToStartSurfacesFailure(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - m := mocks.NewMockWorkspaceClient(t) - api := m.GetMockJobsAPI() - api.EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{RunId: 1}).Return( - terminatedRun(1, 99, "Could not reach driver of cluster 0605-x.", "https://example.test/run/1"), nil) - api.EXPECT().GetRunOutput(mock.Anything, jobs.GetRunOutputRequest{RunId: 99}).Return( - &jobs.RunOutput{}, nil) - - err := waitForJobToStart(ctx, m.WorkspaceClient, 1, ClientOptions{TaskStartupTimeout: 30 * time.Second}) + m := newFakeClients(t, map[string]any{ + "GET /api/2.2/jobs/runs/get?run_id=1": terminatedRun(1, 99, "Could not reach driver of cluster 0605-x.", "https://example.test/run/1"), + "GET /api/2.2/jobs/runs/get-output?run_id=99": &jobs.GetRunOutputResponse{}, + }) + + err := waitForJobToStart(ctx, m, 1, ClientOptions{TaskStartupTimeout: 30 * time.Second}) require.Error(t, err) assert.Contains(t, err.Error(), "ssh server bootstrap job failed") assert.Contains(t, err.Error(), "Could not reach driver of cluster 0605-x.") diff --git a/experimental/ssh/internal/client/fake_api_test.go b/experimental/ssh/internal/client/fake_api_test.go new file mode 100644 index 00000000000..395e7e07b27 --- /dev/null +++ b/experimental/ssh/internal/client/fake_api_test.go @@ -0,0 +1,54 @@ +package client + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/databricks-sdk-go/config" + "github.com/stretchr/testify/require" +) + +// apiError is a fake API error response. +type apiError struct { + status int + message string +} + +// newFakeClients returns clients for a server answering the given routes, +// keyed "METHOD /path" or "METHOD /path?query" (exact raw query). Values are +// JSON-encoded, except raw strings, which are written as is, and apiError. +// Unknown requests fail the test. +func newFakeClients(t *testing.T, routes map[string]any) *sdkclients.Clients { + t.Helper() + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/.well-known/databricks-config" { + http.NotFound(w, r) + return + } + resp, ok := routes[r.Method+" "+r.URL.Path+"?"+r.URL.RawQuery] + if !ok { + resp, ok = routes[r.Method+" "+r.URL.Path] + } + if !ok { + t.Errorf("unexpected request %s %s", r.Method, r.URL) + w.WriteHeader(http.StatusNotImplemented) + return + } + switch v := resp.(type) { + case apiError: + w.WriteHeader(v.status) + _ = json.NewEncoder(w).Encode(map[string]string{"error_code": "TEST", "message": v.message}) + case string: + _, _ = w.Write([]byte(v)) + default: + _ = json.NewEncoder(w).Encode(v) + } + })) + t.Cleanup(srv.Close) + w, err := sdkclients.New(t.Context(), &config.Config{Host: srv.URL, Token: "token"}) + require.NoError(t, err) + return w +} diff --git a/experimental/ssh/internal/client/releases.go b/experimental/ssh/internal/client/releases.go index 874a66bba2b..c546f7c1035 100644 --- a/experimental/ssh/internal/client/releases.go +++ b/experimental/ssh/internal/client/releases.go @@ -19,15 +19,15 @@ import ( "github.com/databricks/cli/internal/build" "github.com/databricks/cli/libs/filer" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/sdk-go/core/apierr" "golang.org/x/net/http2" ) type releaseProvider func(ctx context.Context, architecture, version, releasesDir string) (io.ReadCloser, error) -func UploadTunnelReleases(ctx context.Context, client *databricks.WorkspaceClient, version, releasesDir string) error { +func UploadTunnelReleases(ctx context.Context, client *sdkclients.Clients, version, releasesDir string) error { versionedDir, err := workspace.GetWorkspaceVersionedDir(ctx, client, version) if err != nil { return fmt.Errorf("failed to get versioned directory: %w", err) @@ -37,7 +37,7 @@ func UploadTunnelReleases(ctx context.Context, client *databricks.WorkspaceClien // buys us nothing, and some corporate proxies reset large HTTP/2 request bodies // with RST_STREAM(NO_ERROR), which aborts the upload. Forcing HTTP/1.1 only for // this client keeps the rest of the connect flow on HTTP/2. - uploadClient, err := newHTTP11WorkspaceClient(client.Config) + uploadClient, err := newHTTP11WorkspaceClient(ctx, client.Config) if err != nil { return fmt.Errorf("failed to create upload client: %w", err) } @@ -58,7 +58,7 @@ func UploadTunnelReleases(ctx context.Context, client *databricks.WorkspaceClien // on its config. config.Config embeds a sync.Mutex and cannot be copied by value, // so we reconstruct a fresh config from src's public attributes rather than clone // the struct; the client then re-resolves auth from those attributes. -func newHTTP11WorkspaceClient(src *config.Config) (*databricks.WorkspaceClient, error) { +func newHTTP11WorkspaceClient(ctx context.Context, src *config.Config) (*sdkclients.Clients, error) { cfg := &config.Config{} for _, attr := range config.ConfigAttributes { if attr.IsZero(src) { @@ -69,7 +69,7 @@ func newHTTP11WorkspaceClient(src *config.Config) (*databricks.WorkspaceClient, } } cfg.HTTPTransport = newHTTP11Transport(src) - return databricks.NewWorkspaceClient((*databricks.Config)(cfg)) + return sdkclients.New(ctx, cfg) } // newHTTP11Transport builds a fresh HTTP/1.1-only transport, mirroring the SDK's @@ -159,7 +159,7 @@ func uploadReleases(ctx context.Context, workspaceFiler filer.Filer, getRelease // as a string that still preserves the "stream error ... stream ID" shape. func isProxyUploadError(err error) bool { if aerr, ok := errors.AsType[*apierr.APIError](err); ok { - return aerr.StatusCode == http.StatusRequestEntityTooLarge + return aerr.HTTPStatusCode() == http.StatusRequestEntityTooLarge } if errors.Is(err, syscall.ECONNRESET) { return true diff --git a/experimental/ssh/internal/client/releases_test.go b/experimental/ssh/internal/client/releases_test.go index 81984741834..82ab3755695 100644 --- a/experimental/ssh/internal/client/releases_test.go +++ b/experimental/ssh/internal/client/releases_test.go @@ -11,8 +11,8 @@ import ( "testing" "github.com/databricks/cli/libs/filer" - "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/sdk-go/core/apierr" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/net/http2" @@ -26,7 +26,7 @@ func TestIsProxyUploadError(t *testing.T) { }{ { name: "413 request entity too large", - err: &apierr.APIError{StatusCode: http.StatusRequestEntityTooLarge, Message: "request too large"}, + err: apierr.FromHTTPError(http.StatusRequestEntityTooLarge, nil, []byte(`{"message":"request too large"}`)), want: true, }, { @@ -46,7 +46,7 @@ func TestIsProxyUploadError(t *testing.T) { }, { name: "non-413 API error", - err: &apierr.APIError{StatusCode: http.StatusForbidden, Message: "permission denied"}, + err: apierr.FromHTTPError(http.StatusForbidden, nil, []byte(`{"message":"permission denied"}`)), want: false, }, { @@ -82,7 +82,7 @@ func TestNewHTTP11WorkspaceClient(t *testing.T) { InsecureSkipVerify: true, } - w, err := newHTTP11WorkspaceClient(src) + w, err := newHTTP11WorkspaceClient(t.Context(), src) require.NoError(t, err) // Auth-relevant attributes are carried over to the reconstructed config. diff --git a/experimental/ssh/internal/client/submit_internal_test.go b/experimental/ssh/internal/client/submit_internal_test.go index d4247cbc2e1..90f43dc1eec 100644 --- a/experimental/ssh/internal/client/submit_internal_test.go +++ b/experimental/ssh/internal/client/submit_internal_test.go @@ -4,7 +4,8 @@ import ( "testing" "time" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -22,13 +23,13 @@ func TestBuildSSHServerSubmitRun(t *testing.T) { got := buildSSHServerSubmitRun("v1", "scope", notebookPath, "", opts) // Usage policy flows onto the run and into the base params the server reads. - assert.Equal(t, "pol-1", got.BudgetPolicyId) + assert.Equal(t, "pol-1", utils.Deref(got.BudgetPolicyId)) assert.Equal(t, "pol-1", got.Tasks[0].NotebookTask.BaseParameters["usagePolicyId"]) assert.Equal(t, "true", got.Tasks[0].NotebookTask.BaseParameters["serverless"]) // Serverless runs on an environment, not an existing cluster. - assert.Equal(t, serverlessEnvironmentKey, got.Tasks[0].EnvironmentKey) - assert.Empty(t, got.Tasks[0].ExistingClusterId) + assert.Equal(t, serverlessEnvironmentKey, utils.Deref(got.Tasks[0].EnvironmentKey)) + assert.Empty(t, utils.Deref(got.Tasks[0].ExistingClusterId)) assert.Len(t, got.Environments, 1) assert.Nil(t, got.Tasks[0].Compute) }) @@ -41,7 +42,7 @@ func TestBuildSSHServerSubmitRun(t *testing.T) { } got := buildSSHServerSubmitRun("v1", "scope", notebookPath, "", opts) - assert.Equal(t, compute.HardwareAcceleratorType("GPU_1xA10"), got.Tasks[0].Compute.HardwareAccelerator) + assert.Equal(t, jobs.HardwareAcceleratorType("GPU_1xA10"), got.Tasks[0].Compute.HardwareAccelerator) }) t.Run("serverless with base environment", func(t *testing.T) { @@ -55,8 +56,8 @@ func TestBuildSSHServerSubmitRun(t *testing.T) { // A resolved base environment carries its own version, so environment_version is not set. require.Len(t, got.Environments, 1) - assert.Equal(t, "workspace-base-environments/dbe_123", got.Environments[0].Spec.BaseEnvironment) - assert.Empty(t, got.Environments[0].Spec.EnvironmentVersion) + assert.Equal(t, "workspace-base-environments/dbe_123", utils.Deref(got.Environments[0].Spec.BaseEnvironment)) + assert.Empty(t, utils.Deref(got.Environments[0].Spec.EnvironmentVersion)) }) t.Run("dedicated cluster", func(t *testing.T) { @@ -67,10 +68,10 @@ func TestBuildSSHServerSubmitRun(t *testing.T) { got := buildSSHServerSubmitRun("v1", "scope", notebookPath, "", opts) // Usage policy is serverless-only; a dedicated run carries none and targets the cluster. - assert.Empty(t, got.BudgetPolicyId) + assert.Empty(t, utils.Deref(got.BudgetPolicyId)) assert.Empty(t, got.Tasks[0].NotebookTask.BaseParameters["usagePolicyId"]) - assert.Equal(t, "abc-123", got.Tasks[0].ExistingClusterId) - assert.Empty(t, got.Tasks[0].EnvironmentKey) + assert.Equal(t, "abc-123", utils.Deref(got.Tasks[0].ExistingClusterId)) + assert.Empty(t, utils.Deref(got.Tasks[0].EnvironmentKey)) assert.Empty(t, got.Environments) // False is what tells the bootstrap to sweep detached work as it always has. assert.Equal(t, "false", got.Tasks[0].NotebookTask.BaseParameters["keepDetachedProcesses"]) @@ -86,8 +87,8 @@ func TestBuildSSHServerSubmitRun(t *testing.T) { assert.Equal(t, "true", got.Tasks[0].NotebookTask.BaseParameters["keepDetachedProcesses"]) // The hold happens inside the run, so the run's own timeout is what bounds it. - assert.Equal(t, int(24*time.Hour.Seconds()), got.TimeoutSeconds) - assert.Equal(t, int(24*time.Hour.Seconds()), got.Tasks[0].TimeoutSeconds) + assert.Equal(t, int(24*time.Hour.Seconds()), utils.Deref(got.TimeoutSeconds)) + assert.Equal(t, int(24*time.Hour.Seconds()), utils.Deref(got.Tasks[0].TimeoutSeconds)) }) t.Run("server lifecycle", func(t *testing.T) { @@ -103,8 +104,8 @@ func TestBuildSSHServerSubmitRun(t *testing.T) { // widget at startup, and the run's timeout caps the tunnel's lifetime. assert.Equal(t, "25", got.Tasks[0].NotebookTask.BaseParameters["maxClients"]) assert.Equal(t, "15m0s", got.Tasks[0].NotebookTask.BaseParameters["shutdownDelay"]) - assert.Equal(t, 48*60*60, got.TimeoutSeconds) - assert.Equal(t, 48*60*60, got.Tasks[0].TimeoutSeconds) + assert.Equal(t, 48*60*60, utils.Deref(got.TimeoutSeconds)) + assert.Equal(t, 48*60*60, utils.Deref(got.Tasks[0].TimeoutSeconds)) }) } @@ -129,7 +130,7 @@ func TestServerTimeoutNeverSubmitsUnboundedRun(t *testing.T) { continue } got := buildSSHServerSubmitRun("v1", "scope", notebookPath, "", opts) - assert.NotZero(t, got.TimeoutSeconds, "--server-timeout=%s passed Validate but submits timeout_seconds: 0 (no timeout)", d) - assert.NotZero(t, got.Tasks[0].TimeoutSeconds, "--server-timeout=%s passed Validate but submits a task with timeout_seconds: 0", d) + assert.NotZero(t, utils.Deref(got.TimeoutSeconds), "--server-timeout=%s passed Validate but submits timeout_seconds: 0 (no timeout)", d) + assert.NotZero(t, utils.Deref(got.Tasks[0].TimeoutSeconds), "--server-timeout=%s passed Validate but submits a task with timeout_seconds: 0", d) } } diff --git a/experimental/ssh/internal/client/websockets.go b/experimental/ssh/internal/client/websockets.go index 51cd28c50fe..94d433cdad1 100644 --- a/experimental/ssh/internal/client/websockets.go +++ b/experimental/ssh/internal/client/websockets.go @@ -10,11 +10,11 @@ import ( "github.com/databricks/cli/experimental/ssh/internal/proxy" "github.com/databricks/cli/libs/auth" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/gorilla/websocket" ) -func createWebsocketConnection(ctx context.Context, client *databricks.WorkspaceClient, dial proxy.DialRequest, clusterID string, serverPort int, liteswap string) (*websocket.Conn, error) { +func createWebsocketConnection(ctx context.Context, client *sdkclients.Clients, dial proxy.DialRequest, clusterID string, serverPort int, liteswap string) (*websocket.Conn, error) { proxyURL, err := getProxyURL(ctx, client, dial, clusterID, serverPort) if err != nil { return nil, fmt.Errorf("failed to get proxy URL: %w", err) @@ -49,7 +49,7 @@ func createWebsocketConnection(ctx context.Context, client *databricks.Workspace return conn, nil } -func getProxyURL(ctx context.Context, client *databricks.WorkspaceClient, dial proxy.DialRequest, clusterID string, serverPort int) (string, error) { +func getProxyURL(ctx context.Context, client *sdkclients.Clients, dial proxy.DialRequest, clusterID string, serverPort int) (string, error) { workspaceID, err := auth.ResolveWorkspaceID(ctx, client) if err != nil { return "", fmt.Errorf("failed to get current workspace ID: %w", err) diff --git a/experimental/ssh/internal/client/websockets_test.go b/experimental/ssh/internal/client/websockets_test.go index 05d15636688..6a1a9edb8bd 100644 --- a/experimental/ssh/internal/client/websockets_test.go +++ b/experimental/ssh/internal/client/websockets_test.go @@ -11,7 +11,8 @@ import ( "time" "github.com/databricks/cli/experimental/ssh/internal/proxy" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/databricks-sdk-go/config" "github.com/gorilla/websocket" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -38,7 +39,7 @@ func TestServerSupportsResume(t *testing.T) { }) server := httptest.NewServer(mux) defer server.Close() - client, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "test-token", WorkspaceID: "123", AuthType: "pat"}) + client, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "test-token", WorkspaceID: "123", AuthType: "pat"}) require.NoError(t, err) assert.Equal(t, tc.want, serverSupportsResume(t.Context(), client, "cluster", 7772, "")) }) @@ -65,7 +66,7 @@ func TestCreateWebsocketConnectionReattachRejected(t *testing.T) { }) server := httptest.NewServer(mux) defer server.Close() - client, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "test-token", WorkspaceID: "123", AuthType: "pat"}) + client, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "test-token", WorkspaceID: "123", AuthType: "pat"}) require.NoError(t, err) ctx, cancel := context.WithTimeout(t.Context(), time.Second) defer cancel() @@ -105,7 +106,7 @@ func TestCreateWebsocketConnectionRetriesRequestTimeout(t *testing.T) { }) server := httptest.NewServer(mux) defer server.Close() - client, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "test-token", WorkspaceID: "123", AuthType: "pat"}) + client, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "test-token", WorkspaceID: "123", AuthType: "pat"}) require.NoError(t, err) ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second) defer cancel() diff --git a/experimental/ssh/internal/keys/keys.go b/experimental/ssh/internal/keys/keys.go index 1fafdef16fc..d5352534d6d 100644 --- a/experimental/ssh/internal/keys/keys.go +++ b/experimental/ssh/internal/keys/keys.go @@ -11,7 +11,7 @@ import ( "path/filepath" "github.com/databricks/cli/libs/env" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "golang.org/x/crypto/ssh" ) @@ -62,7 +62,7 @@ func SaveSSHKeyPair(keyPath string, privateKeyBytes, publicKeyBytes []byte) erro return nil } -func CheckAndGenerateSSHKeyPairFromSecrets(ctx context.Context, client *databricks.WorkspaceClient, secretScopeName, privateKeyName, publicKeyName string) ([]byte, []byte, error) { +func CheckAndGenerateSSHKeyPairFromSecrets(ctx context.Context, client *sdkclients.Clients, secretScopeName, privateKeyName, publicKeyName string) ([]byte, []byte, error) { privateKeyBytes, err := GetSecret(ctx, client, secretScopeName, privateKeyName) if err != nil { privateKeyBytes, publicKeyBytes, err := generateSSHKeyPair() diff --git a/experimental/ssh/internal/keys/secrets.go b/experimental/ssh/internal/keys/secrets.go index 6409770a4d7..2cc94a1a6e0 100644 --- a/experimental/ssh/internal/keys/secrets.go +++ b/experimental/ssh/internal/keys/secrets.go @@ -2,29 +2,29 @@ package keys import ( "context" - "encoding/base64" - "errors" "fmt" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + sdkscim "github.com/databricks/sdk-go/scim/v1" + "github.com/databricks/sdk-go/secrets/v1" ) // CreateKeysSecretScope creates or retrieves the secret scope for SSH keys. // sessionID is the unique identifier for the session (cluster ID for dedicated clusters, connection name for serverless). -func CreateKeysSecretScope(ctx context.Context, client *databricks.WorkspaceClient, sessionID string) (string, error) { - me, err := client.CurrentUser.Me(ctx, iam.MeRequest{}) +func CreateKeysSecretScope(ctx context.Context, client *sdkclients.Clients, sessionID string) (string, error) { + me, err := client.Scim.Me(ctx, sdkscim.MeRequest{}) if err != nil { return "", fmt.Errorf("failed to get current user: %w", err) } - secretScopeName := fmt.Sprintf("%s-%s-ssh-tunnel-keys", me.UserName, sessionID) + secretScopeName := fmt.Sprintf("%s-%s-ssh-tunnel-keys", utils.Deref(me.UserName), sessionID) // Do not create the scope if it already exists. // We can instead filter out "resource already exists" errors from CreateScope, // but that API can also lead to "limit exceeded" errors, even if the scope does actually exist. - scope, err := client.Secrets.ListSecretsByScope(ctx, secretScopeName) - if err != nil && !errors.Is(err, databricks.ErrResourceDoesNotExist) { + scope, err := client.Secrets.ListSecrets(ctx, secrets.ListSecretsRequest{Scope: new(secretScopeName)}) + if err != nil && !apierrs.Is(err, apierrs.ErrResourceDoesNotExist) { return "", fmt.Errorf("failed to check if secret scope %s exists: %w", secretScopeName, err) } @@ -32,8 +32,8 @@ func CreateKeysSecretScope(ctx context.Context, client *databricks.WorkspaceClie return secretScopeName, nil } - err = client.Secrets.CreateScope(ctx, workspace.CreateScope{ - Scope: secretScopeName, + _, err = client.Secrets.CreateScope(ctx, secrets.CreateScopeRequest{ + Scope: new(secretScopeName), }) if err != nil { return "", fmt.Errorf("failed to create secrets scope: %w", err) @@ -41,27 +41,23 @@ func CreateKeysSecretScope(ctx context.Context, client *databricks.WorkspaceClie return secretScopeName, nil } -func GetSecret(ctx context.Context, client *databricks.WorkspaceClient, scope, key string) ([]byte, error) { - resp, err := client.Secrets.GetSecret(ctx, workspace.GetSecretRequest{ - Scope: scope, - Key: key, +func GetSecret(ctx context.Context, client *sdkclients.Clients, scope, key string) ([]byte, error) { + resp, err := client.Secrets.GetSecret(ctx, secrets.GetSecretRequest{ + Scope: new(scope), + Key: new(key), }) if err != nil { return nil, fmt.Errorf("failed to get secret %s from scope %s: %w", key, scope, err) } - - value, err := base64.StdEncoding.DecodeString(resp.Value) - if err != nil { - return nil, fmt.Errorf("failed to decode secret key from base64: %w", err) - } - return value, nil + // The API returns the value base64-encoded; sdk-go decodes it. + return resp.Value, nil } -func putSecret(ctx context.Context, client *databricks.WorkspaceClient, scope, key, value string) error { - err := client.Secrets.PutSecret(ctx, workspace.PutSecret{ - Scope: scope, - Key: key, - StringValue: value, +func putSecret(ctx context.Context, client *sdkclients.Clients, scope, key, value string) error { + _, err := client.Secrets.PutSecret(ctx, secrets.PutSecretRequest{ + Scope: new(scope), + Key: new(key), + Value: &secrets.PutSecretRequest_Value_StringValue{StringValue: value}, }) if err != nil { return fmt.Errorf("failed to store secret %s in scope %s: %w", key, scope, err) diff --git a/experimental/ssh/internal/server/fuse.go b/experimental/ssh/internal/server/fuse.go index 23366728ab0..d0649da4cb2 100644 --- a/experimental/ssh/internal/server/fuse.go +++ b/experimental/ssh/internal/server/fuse.go @@ -10,11 +10,12 @@ import ( "github.com/databricks/cli/experimental/ssh/internal/fuse" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + sdkscim "github.com/databricks/sdk-go/scim/v1" ) -func startFuseRegistration(ctx context.Context, client *databricks.WorkspaceClient, serverless bool) { +func startFuseRegistration(ctx context.Context, client *sdkclients.Clients, serverless bool) { // Serverless rejects non-root UIDs on the daemon ports; the bootstrap REPL's own registration already covers the server's descendants. if serverless { log.Info(ctx, "Skipping SSH filesystem registration on serverless; /Workspace and /Volumes access depends on the bootstrap notebook") @@ -27,7 +28,7 @@ func startFuseRegistration(ctx context.Context, client *databricks.WorkspaceClie } } -func registerFuseCredentials(ctx context.Context, client *databricks.WorkspaceClient) error { +func registerFuseCredentials(ctx context.Context, client *sdkclients.Clients) error { self, err := fuse.Self() if err != nil { return err @@ -40,19 +41,19 @@ func registerFuseCredentials(ctx context.Context, client *databricks.WorkspaceCl return fuse.KeepRegistered(ctx, fuseClient, workspaceToken(client), userID, notebookDir) } -func fuseUserInfo(ctx context.Context, client *databricks.WorkspaceClient) (userID, notebookDir string) { +func fuseUserInfo(ctx context.Context, client *sdkclients.Clients) (userID, notebookDir string) { // User metadata is optional. Limit its lookup before publishing the server port. userCtx, cancel := context.WithTimeout(ctx, 2*time.Second) defer cancel() - me, err := client.CurrentUser.Me(userCtx, iam.MeRequest{}) + me, err := client.Scim.Me(userCtx, sdkscim.MeRequest{}) if err != nil { log.Debugf(ctx, "Registering filesystem credentials without user metadata: %v", err) return "", "" } - return me.Id, "/Users/" + me.UserName + return utils.Deref(me.Id), "/Users/" + utils.Deref(me.UserName) } -func workspaceToken(client *databricks.WorkspaceClient) fuse.TokenFunc { +func workspaceToken(client *sdkclients.Clients) fuse.TokenFunc { return func(ctx context.Context) (string, error) { req, err := http.NewRequestWithContext(ctx, http.MethodGet, client.Config.Host, nil) if err != nil { diff --git a/experimental/ssh/internal/server/fuse_test.go b/experimental/ssh/internal/server/fuse_test.go index 393c5ddaa35..2e5b48b0a23 100644 --- a/experimental/ssh/internal/server/fuse_test.go +++ b/experimental/ssh/internal/server/fuse_test.go @@ -14,7 +14,7 @@ import ( "github.com/databricks/cli/experimental/ssh/internal/server" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" "github.com/databricks/databricks-sdk-go/config/credentials" "github.com/stretchr/testify/assert" @@ -32,7 +32,7 @@ func (c testCredentials) Configure(context.Context, *config.Config) (credentials func TestWorkspaceToken(t *testing.T) { for _, header := range []string{"Bearer token-one", "Basic private-credential", "Bearer ", ""} { t.Run(header, func(t *testing.T) { - c, err := databricks.NewWorkspaceClient(&databricks.Config{ + c, err := sdkclients.New(t.Context(), &config.Config{ Host: "https://workspace.test", HostMetadataResolver: noHostMetadata, Token: "stale-config-token", Credentials: testCredentials{authenticate: func(r *http.Request) error { r.Header.Set("Authorization", header) @@ -56,7 +56,7 @@ func TestWorkspaceToken(t *testing.T) { func TestWorkspaceTokenRefreshAndFailure(t *testing.T) { value := "first" var authErr error - c, err := databricks.NewWorkspaceClient(&databricks.Config{ + c, err := sdkclients.New(t.Context(), &config.Config{ Host: "https://workspace.test", HostMetadataResolver: noHostMetadata, Credentials: testCredentials{authenticate: func(r *http.Request) error { r.Header.Set("Authorization", "Bearer "+value) @@ -95,7 +95,7 @@ func TestFuseUserInfo(t *testing.T) { } { t.Run(tc.name, func(t *testing.T) { synctest.Test(t, func(t *testing.T) { - c, err := databricks.NewWorkspaceClient(&databricks.Config{ + c, err := sdkclients.New(t.Context(), &config.Config{ Host: "https://workspace.test", HostMetadataResolver: noHostMetadata, Token: "test-token", HTTPTransport: roundTripFunc(func(r *http.Request) (*http.Response, error) { assert.Equal(t, "/api/2.0/preview/scim/v2/Me", r.URL.Path) @@ -118,7 +118,7 @@ func TestFuseUserInfo(t *testing.T) { } func TestStartFuseRegistrationSkipsServerless(t *testing.T) { - c, err := databricks.NewWorkspaceClient(&databricks.Config{ + c, err := sdkclients.New(t.Context(), &config.Config{ Host: "https://workspace.test", HostMetadataResolver: noHostMetadata, Token: "test-token", HTTPTransport: roundTripFunc(func(r *http.Request) (*http.Response, error) { t.Errorf("unexpected request: %s %s", r.Method, r.URL) diff --git a/experimental/ssh/internal/server/server.go b/experimental/ssh/internal/server/server.go index 39f0938b773..a85e0a24174 100644 --- a/experimental/ssh/internal/server/server.go +++ b/experimental/ssh/internal/server/server.go @@ -22,9 +22,9 @@ import ( "github.com/databricks/cli/experimental/ssh/internal/workspace" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/telemetry" "github.com/databricks/cli/libs/telemetry/protos" - "github.com/databricks/databricks-sdk-go" ) //go:embed jupyter-init.py @@ -65,7 +65,7 @@ type ServerOptions struct { PortRange int } -func Run(ctx context.Context, client *databricks.WorkspaceClient, opts ServerOptions) error { +func Run(ctx context.Context, client *sdkclients.Clients, opts ServerOptions) error { ctx, logBuf := captureWarnLogs(ctx) ctx, cancel := context.WithCancel(ctx) defer cancel() diff --git a/experimental/ssh/internal/server/sshd.go b/experimental/ssh/internal/server/sshd.go index 01fd0e3cdb0..640c45722b7 100644 --- a/experimental/ssh/internal/server/sshd.go +++ b/experimental/ssh/internal/server/sshd.go @@ -15,7 +15,7 @@ import ( "github.com/databricks/cli/experimental/ssh/internal/keys" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" ) // clientAliveIntervalSeconds is how often sshd asks the client to confirm it is still there. It @@ -30,7 +30,7 @@ import ( // client has gone away after ~90s instead of holding it open until the server's shutdown delay. const clientAliveIntervalSeconds = 30 -func prepareSSHDConfig(ctx context.Context, client *databricks.WorkspaceClient, opts ServerOptions) (string, error) { +func prepareSSHDConfig(ctx context.Context, client *sdkclients.Clients, opts ServerOptions) (string, error) { clientPublicKey, err := keys.GetSecret(ctx, client, opts.SecretScopeName, opts.AuthorizedKeySecretName) if err != nil { return "", fmt.Errorf("failed to get client public key: %w", err) diff --git a/experimental/ssh/internal/setup/setup.go b/experimental/ssh/internal/setup/setup.go index bdfd88cc3c3..347cd678f78 100644 --- a/experimental/ssh/internal/setup/setup.go +++ b/experimental/ssh/internal/setup/setup.go @@ -4,14 +4,17 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" "time" sshclient "github.com/databricks/cli/experimental/ssh/internal/client" "github.com/databricks/cli/experimental/ssh/internal/keys" "github.com/databricks/cli/experimental/ssh/internal/sshconfig" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/cli/libs/sdkclients" ) type SetupOptions struct { @@ -68,17 +71,51 @@ func generateHostConfig(ctx context.Context, opts SetupOptions, proxyCommand str return hostConfig, nil } +// userClusterNamesToIDs maps the names of clusters created through the UI or +// API to their IDs. It is a raw call because sdk-go models neither the +// filter_by request parameter nor pagination of the full listing here. +func userClusterNamesToIDs(ctx context.Context, client *sdkclients.Clients) (map[string]string, error) { + api, err := apiclient.New(client.Config) + if err != nil { + return nil, err + } + mapping := map[string]string{} + pageToken := "" + for { + query := url.Values{"filter_by.cluster_sources": {"API", "UI"}} + if pageToken != "" { + query.Set("page_token", pageToken) + } + var resp struct { + Clusters []struct { + ClusterID string `json:"cluster_id"` + ClusterName string `json:"cluster_name"` + } `json:"clusters"` + NextPageToken string `json:"next_page_token"` + } + if err := api.Do(ctx, http.MethodGet, "/api/2.1/clusters/list?"+query.Encode(), auth.WorkspaceIDHeaders(client.Config), nil, nil, &resp); err != nil { + return nil, err + } + for _, c := range resp.Clusters { + if _, duplicate := mapping[c.ClusterName]; duplicate { + return nil, fmt.Errorf("duplicate .ClusterName: %s", c.ClusterName) + } + mapping[c.ClusterName] = c.ClusterID + } + if resp.NextPageToken == "" { + return mapping, nil + } + pageToken = resp.NextPageToken + } +} + // clusterSelectionPrompt is a package-level var so tests can replace it with a mock. var clusterSelectionPrompt = defaultClusterSelectionPrompt -func defaultClusterSelectionPrompt(ctx context.Context, client *databricks.WorkspaceClient) (string, error) { +func defaultClusterSelectionPrompt(ctx context.Context, client *sdkclients.Clients) (string, error) { sp := cmdio.NewSpinner(ctx) sp.Update("Loading clusters.") - clusters, err := client.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{ - FilterBy: &compute.ListClustersFilterBy{ - ClusterSources: []compute.ClusterSource{compute.ClusterSourceApi, compute.ClusterSourceUi}, - }, - }) + clusters, err := userClusterNamesToIDs(ctx, client) sp.Close() if err != nil { return "", fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify cluster argument. Original error: %w", err) @@ -90,7 +127,7 @@ func defaultClusterSelectionPrompt(ctx context.Context, client *databricks.Works return id, nil } -func Setup(ctx context.Context, client *databricks.WorkspaceClient, opts SetupOptions) error { +func Setup(ctx context.Context, client *sdkclients.Clients, opts SetupOptions) error { // Reject invalid server-lifecycle flag values before the cluster picker and // cluster-access check: these values don't depend on cluster details. if opts.MaxClients < 1 { diff --git a/experimental/ssh/internal/setup/setup_test.go b/experimental/ssh/internal/setup/setup_test.go index 0846b6caae6..de4f4991195 100644 --- a/experimental/ssh/internal/setup/setup_test.go +++ b/experimental/ssh/internal/setup/setup_test.go @@ -11,9 +11,8 @@ import ( "github.com/databricks/cli/experimental/ssh/internal/client" "github.com/databricks/cli/experimental/ssh/internal/sshconfig" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/cli/libs/httpfixtures" + "github.com/databricks/cli/libs/sdkclients" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -181,13 +180,7 @@ func TestSetup_SuccessfulWithNewConfigFile(t *testing.T) { configPath := filepath.Join(tmpDir, "ssh_config") - m := mocks.NewMockWorkspaceClient(t) - clustersAPI := m.GetMockClustersAPI() - - clustersAPI.EXPECT().Get(ctx, compute.GetClusterRequest{ClusterId: "cluster-123"}).Return(&compute.ClusterDetails{ - DataSecurityMode: compute.DataSecurityModeSingleUser, - SingleUserName: "me@example.com", - }, nil) + m := clustersClients(t, "cluster-123", `{"data_security_mode":"SINGLE_USER","single_user_name":"me@example.com"}`) opts := SetupOptions{ HostName: "test-host", @@ -200,7 +193,7 @@ func TestSetup_SuccessfulWithNewConfigFile(t *testing.T) { Profile: "test-profile", } - err := Setup(ctx, m.WorkspaceClient, opts) + err := Setup(ctx, m, opts) assert.NoError(t, err) // Check that main config has Include directive @@ -238,12 +231,7 @@ func TestSetup_AutoApproveRecreatesExistingHost(t *testing.T) { configPath := filepath.Join(tmpDir, "ssh_config") - m := mocks.NewMockWorkspaceClient(t) - clustersAPI := m.GetMockClustersAPI() - clustersAPI.EXPECT().Get(ctx, compute.GetClusterRequest{ClusterId: "cluster-123"}).Return(&compute.ClusterDetails{ - DataSecurityMode: compute.DataSecurityModeSingleUser, - SingleUserName: "me@example.com", - }, nil) + m := clustersClients(t, "cluster-123", `{"data_security_mode":"SINGLE_USER","single_user_name":"me@example.com"}`) opts := SetupOptions{ HostName: "test-host", @@ -256,7 +244,7 @@ func TestSetup_AutoApproveRecreatesExistingHost(t *testing.T) { AutoApprove: true, } - err := Setup(ctx, m.WorkspaceClient, opts) + err := Setup(ctx, m, opts) assert.NoError(t, err) // Host config should be recreated (no longer contains the stale User). @@ -273,11 +261,7 @@ func TestSetup_SerializesServerLifecycleFlags(t *testing.T) { t.Setenv("HOME", tmpDir) t.Setenv("USERPROFILE", tmpDir) - m := mocks.NewMockWorkspaceClient(t) - m.GetMockClustersAPI().EXPECT().Get(ctx, compute.GetClusterRequest{ClusterId: "cluster-123"}).Return(&compute.ClusterDetails{ - DataSecurityMode: compute.DataSecurityModeSingleUser, - SingleUserName: "me@example.com", - }, nil) + m := clustersClients(t, "cluster-123", `{"data_security_mode":"SINGLE_USER","single_user_name":"me@example.com"}`) opts := SetupOptions{ HostName: "test-host", @@ -290,7 +274,7 @@ func TestSetup_SerializesServerLifecycleFlags(t *testing.T) { KeepDetachedProcesses: true, } - require.NoError(t, Setup(ctx, m.WorkspaceClient, opts)) + require.NoError(t, Setup(ctx, m, opts)) // The ProxyCommand is the invocation that submits the server job, so every value fixed at // submission has to reach the persisted host config or the user's choice is silently dropped. @@ -332,7 +316,7 @@ func TestSetup_RejectsUnusableServerLifecycleFlags(t *testing.T) { t.Setenv("USERPROFILE", tmpDir) // Validation fires before any cluster API calls, so no mock expectations needed. - m := mocks.NewMockWorkspaceClient(t) + m := clustersClients(t, "", "") opts := tt.opts opts.HostName = "test-host" @@ -340,7 +324,7 @@ func TestSetup_RejectsUnusableServerLifecycleFlags(t *testing.T) { opts.SSHConfigPath = filepath.Join(tmpDir, "ssh_config") opts.SSHKeysDir = tmpDir - assert.EqualError(t, Setup(ctx, m.WorkspaceClient, opts), tt.wantErr) + assert.EqualError(t, Setup(ctx, m, opts), tt.wantErr) // Nothing is written when the values are rejected. _, err := os.Stat(filepath.Join(tmpDir, ".databricks", "ssh-tunnel-configs", "test-host")) @@ -362,17 +346,12 @@ func TestSetup_PromptsForClusterWhenNotProvided(t *testing.T) { origPrompt := clusterSelectionPrompt t.Cleanup(func() { clusterSelectionPrompt = origPrompt }) promptCalled := false - clusterSelectionPrompt = func(_ context.Context, _ *databricks.WorkspaceClient) (string, error) { + clusterSelectionPrompt = func(_ context.Context, _ *sdkclients.Clients) (string, error) { promptCalled = true return "picked-cluster", nil } - m := mocks.NewMockWorkspaceClient(t) - clustersAPI := m.GetMockClustersAPI() - clustersAPI.EXPECT().Get(ctx, compute.GetClusterRequest{ClusterId: "picked-cluster"}).Return(&compute.ClusterDetails{ - DataSecurityMode: compute.DataSecurityModeSingleUser, - SingleUserName: "me@example.com", - }, nil) + m := clustersClients(t, "picked-cluster", `{"data_security_mode":"SINGLE_USER","single_user_name":"me@example.com"}`) opts := SetupOptions{ HostName: "test-host", @@ -383,7 +362,7 @@ func TestSetup_PromptsForClusterWhenNotProvided(t *testing.T) { ServerTimeout: 24 * time.Hour, } - err := Setup(ctx, m.WorkspaceClient, opts) + err := Setup(ctx, m, opts) require.NoError(t, err) assert.True(t, promptCalled, "cluster picker should run when ClusterID is empty") @@ -409,13 +388,7 @@ func TestSetup_SuccessfulWithExistingConfigFile(t *testing.T) { err := os.WriteFile(configPath, []byte(existingContent), 0o600) require.NoError(t, err) - m := mocks.NewMockWorkspaceClient(t) - clustersAPI := m.GetMockClustersAPI() - - clustersAPI.EXPECT().Get(ctx, compute.GetClusterRequest{ClusterId: "cluster-456"}).Return(&compute.ClusterDetails{ - DataSecurityMode: compute.DataSecurityModeSingleUser, - SingleUserName: "me@example.com", - }, nil) + m := clustersClients(t, "cluster-456", `{"data_security_mode":"SINGLE_USER","single_user_name":"me@example.com"}`) opts := SetupOptions{ HostName: "new-host", @@ -427,7 +400,7 @@ func TestSetup_SuccessfulWithExistingConfigFile(t *testing.T) { ServerTimeout: 24 * time.Hour, } - err = Setup(ctx, m.WorkspaceClient, opts) + err = Setup(ctx, m, opts) assert.NoError(t, err) // Check that main config has Include directive and preserves existing content @@ -448,3 +421,21 @@ func TestSetup_SuccessfulWithExistingConfigFile(t *testing.T) { assert.Contains(t, hostConfigStr, "Host new-host") assert.Contains(t, hostConfigStr, "--cluster=cluster-456") } + +// clustersClients returns clients whose clusters/get for clusterID answers +// with body. An empty clusterID expects no requests. +func clustersClients(t *testing.T, clusterID, body string) *sdkclients.Clients { + t.Helper() + var fixtures httpfixtures.Fixtures + if clusterID != "" { + fixtures = append(fixtures, httpfixtures.Fixture{ + Method: "GET", + Resource: "/api/2.1/clusters/get?cluster_id=" + clusterID, + Response: body, + }) + } + cfg, _ := fixtures.Config(t) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) + return w +} diff --git a/experimental/ssh/internal/workspace/workspace.go b/experimental/ssh/internal/workspace/workspace.go index c67adb6bac4..c0e655e4c44 100644 --- a/experimental/ssh/internal/workspace/workspace.go +++ b/experimental/ssh/internal/workspace/workspace.go @@ -9,8 +9,9 @@ import ( "path/filepath" "github.com/databricks/cli/libs/filer" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + sdkscim "github.com/databricks/sdk-go/scim/v1" ) const metadataFileName = "metadata.json" @@ -29,15 +30,15 @@ type WorkspaceMetadata struct { KeepDetachedProcesses bool `json:"keep_detached_processes,omitempty"` } -func getWorkspaceRootDir(ctx context.Context, client *databricks.WorkspaceClient) (string, error) { - me, err := client.CurrentUser.Me(ctx, iam.MeRequest{}) +func getWorkspaceRootDir(ctx context.Context, client *sdkclients.Clients) (string, error) { + me, err := client.Scim.Me(ctx, sdkscim.MeRequest{}) if err != nil { return "", fmt.Errorf("failed to get current user: %w", err) } - return fmt.Sprintf("/Workspace/Users/%s/.databricks/ssh-tunnel", me.UserName), nil + return fmt.Sprintf("/Workspace/Users/%s/.databricks/ssh-tunnel", utils.Deref(me.UserName)), nil } -func GetWorkspaceVersionedDir(ctx context.Context, client *databricks.WorkspaceClient, version string) (string, error) { +func GetWorkspaceVersionedDir(ctx context.Context, client *sdkclients.Clients, version string) (string, error) { contentDir, err := getWorkspaceRootDir(ctx, client) if err != nil { return "", fmt.Errorf("failed to get workspace root directory: %w", err) @@ -47,7 +48,7 @@ func GetWorkspaceVersionedDir(ctx context.Context, client *databricks.WorkspaceC // GetWorkspaceContentDir returns the directory for storing session content. // sessionID is the unique identifier for the session (cluster ID for dedicated clusters, connection name for serverless). -func GetWorkspaceContentDir(ctx context.Context, client *databricks.WorkspaceClient, version, sessionID string) (string, error) { +func GetWorkspaceContentDir(ctx context.Context, client *sdkclients.Clients, version, sessionID string) (string, error) { contentDir, err := GetWorkspaceVersionedDir(ctx, client, version) if err != nil { return "", fmt.Errorf("failed to get versioned workspace directory: %w", err) @@ -57,7 +58,7 @@ func GetWorkspaceContentDir(ctx context.Context, client *databricks.WorkspaceCli // GetWorkspaceMetadata loads session metadata from the workspace. // sessionID is the unique identifier for the session (cluster ID for dedicated clusters, connection name for serverless). -func GetWorkspaceMetadata(ctx context.Context, client *databricks.WorkspaceClient, version, sessionID string) (*WorkspaceMetadata, error) { +func GetWorkspaceMetadata(ctx context.Context, client *sdkclients.Clients, version, sessionID string) (*WorkspaceMetadata, error) { contentDir, err := GetWorkspaceContentDir(ctx, client, version, sessionID) if err != nil { return nil, fmt.Errorf("failed to get workspace content directory: %w", err) @@ -87,7 +88,7 @@ func GetWorkspaceMetadata(ctx context.Context, client *databricks.WorkspaceClien // SaveWorkspaceMetadata saves session metadata to the workspace. // sessionID is the unique identifier for the session (cluster ID for dedicated clusters, connection name for serverless). -func SaveWorkspaceMetadata(ctx context.Context, client *databricks.WorkspaceClient, version, sessionID string, metadata *WorkspaceMetadata) error { +func SaveWorkspaceMetadata(ctx context.Context, client *sdkclients.Clients, version, sessionID string, metadata *WorkspaceMetadata) error { metadataBytes, err := json.Marshal(metadata) if err != nil { return fmt.Errorf("failed to marshal metadata: %w", err) diff --git a/go.mod b/go.mod index d6385c07216..e7eed53fc67 100644 --- a/go.mod +++ b/go.mod @@ -14,10 +14,97 @@ require ( github.com/charmbracelet/lipgloss v1.1.0 // MIT github.com/charmbracelet/x/ansi v0.11.8 // MIT github.com/databricks/databricks-sdk-go v0.188.0 // Apache-2.0 - github.com/databricks/sdk-go/auth v0.0.1-dev.8 // Apache-2.0 - github.com/databricks/sdk-go/core v0.0.1-dev.8 // Apache-2.0 - github.com/databricks/sdk-go/files v0.0.1-dev.10 // Apache-2.0 - github.com/databricks/sdk-go/options v0.0.1-dev.9 // Apache-2.0 + github.com/databricks/sdk-go/accessmanagement v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/agentkit v0.1.0 // Apache-2.0 + github.com/databricks/sdk-go/aifunctions v0.4.0 // Apache-2.0 + github.com/databricks/sdk-go/aigateway v0.9.0 // Apache-2.0 + github.com/databricks/sdk-go/aisearch v0.4.0 // Apache-2.0 + github.com/databricks/sdk-go/alerts v0.4.0 // Apache-2.0 + github.com/databricks/sdk-go/apps v0.6.0 // Apache-2.0 + github.com/databricks/sdk-go/auth v0.2.0 // Apache-2.0 + github.com/databricks/sdk-go/authentication v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/budgetpolicy v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/budgets v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/cleanrooms v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/clusterlibraries v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/clusterpolicies v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/clusters v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/commandexecution v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/core v0.1.0 // Apache-2.0 + github.com/databricks/sdk-go/customllms v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/database v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/dataclassification v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/dataquality v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/disasterrecovery v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/domains v0.4.0 // Apache-2.0 + github.com/databricks/sdk-go/environments v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/experiments v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/features v0.9.0 // Apache-2.0 + github.com/databricks/sdk-go/featurestore v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/files v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/forecasting v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/genie v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/gitcredentials v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/globalinitscripts v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/instancepools v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/instanceprofiles v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/jobs v0.4.0 // Apache-2.0 + github.com/databricks/sdk-go/keyconfigurations v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/knowledgeassistants v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/lakeview v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/logdelivery v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/marketplaces v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/modelregistry v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/modelserving v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/modelservingquery v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/networking v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/notificationdestinations v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/oauth v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/options v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/pipelines v0.5.0 // Apache-2.0 + github.com/databricks/sdk-go/policyfamilies v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/postgres v0.5.0 // Apache-2.0 + github.com/databricks/sdk-go/queries v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/queryhistory v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/repos v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/sandbox v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/scim v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/secrets v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/settings v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/sharing v0.4.0 // Apache-2.0 + github.com/databricks/sdk-go/statementexecution v0.4.0 // Apache-2.0 + github.com/databricks/sdk-go/storageconfigurations v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/supervisoragents v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/tagassignments v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/tagpolicies v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/tokenmanagement v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/tokens v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/abacpolicies v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/artifactallowlists v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/catalogs v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/connections v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/credentials v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/entitytagassignments v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/externallineage v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/externallocations v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/externalmetadata v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/functions v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/grants v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/metastores v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/onlinetables v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/registeredmodels v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/resourcequotas v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/rfa v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/schemas v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/secrets v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/systemschemas v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/tables v0.4.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/volumes v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/uc/workspacebindings v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/usagedashboards v0.3.0 // Apache-2.0 + github.com/databricks/sdk-go/vectorsearch v0.4.0 // Apache-2.0 + github.com/databricks/sdk-go/warehouses v0.5.0 // Apache-2.0 + github.com/databricks/sdk-go/workspaces v0.3.0 // Apache-2.0 github.com/google/jsonschema-go v0.4.3 // MIT github.com/google/uuid v1.6.0 // BSD-3-Clause github.com/gorilla/websocket v1.5.3 // BSD-2-Clause diff --git a/go.sum b/go.sum index f82cd6140de..d61dd9cdacd 100644 --- a/go.sum +++ b/go.sum @@ -61,14 +61,188 @@ github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMF github.com/danieljoos/wincred v1.2.3/go.mod h1:6qqX0WNrS4RzPZ1tnroDzq9kY3fu1KwE7MRLQK4X0bs= github.com/databricks/databricks-sdk-go v0.188.0 h1:1nxBqlctGnPzlReyziG199abHs9cR/KNjsCnSM+oDGA= github.com/databricks/databricks-sdk-go v0.188.0/go.mod h1:udBw6nxkaqa0fgPQ7ZW1kGFkltQncYx+qFJeVFmxtz8= -github.com/databricks/sdk-go/auth v0.0.1-dev.8 h1:iMOsshXRZvOrOUVZdcAc4MWQ64mqcenf9Nl803OA8Lc= -github.com/databricks/sdk-go/auth v0.0.1-dev.8/go.mod h1:YliptECFkvwuHLoHiKRqo9Drx5RVM9u5J40UDmEq0iQ= -github.com/databricks/sdk-go/core v0.0.1-dev.8 h1:xUjpesiEAFvFtrMlV16+20Wx65VoE/ptr5KTFRFrFwQ= -github.com/databricks/sdk-go/core v0.0.1-dev.8/go.mod h1:7Ckau34bOsaZhHJE6r7ORNa+/kO33jIs6DfrJL6UbsM= -github.com/databricks/sdk-go/files v0.0.1-dev.10 h1:huvKmRLqdYD4gImdpvv5VeACqoH0t25Uy+j3dbI7CIs= -github.com/databricks/sdk-go/files v0.0.1-dev.10/go.mod h1:a7NleaunwaJzS685rZMLpEUcS5x9A1ydsxrYdqQjq2Q= -github.com/databricks/sdk-go/options v0.0.1-dev.9 h1:lFwZKjUr2nsrYKUTICO+UsT12jKVus9ARvJkabWNwyA= -github.com/databricks/sdk-go/options v0.0.1-dev.9/go.mod h1:c74TPXhjRn3Zitpc9/brPEdvKS7lLURtlWjVOw4m2k4= +github.com/databricks/sdk-go/accessmanagement v0.3.0 h1:u5zUzJfDVf9ltGxzMwr9KMcY/QDhm30yA5/U62lXTXo= +github.com/databricks/sdk-go/accessmanagement v0.3.0/go.mod h1:nqSNKZFD5ZEnR2xc2e9bGt6+ltJKLBkKnPV9TBwegq4= +github.com/databricks/sdk-go/agentkit v0.1.0 h1:tppUae8xxcLQIW13zuPHRaSjqH6WXcIlMpN1pijc8SY= +github.com/databricks/sdk-go/agentkit v0.1.0/go.mod h1:k9KFhuyMNlQmHdAppFaZZ/i7OkK4Aq3PPNEQx9AlC6g= +github.com/databricks/sdk-go/aifunctions v0.4.0 h1:ur9c+SdHS1+iQj6nX/HPQKWXaPRbJ20gIDsrZ2fYONA= +github.com/databricks/sdk-go/aifunctions v0.4.0/go.mod h1:VKROuQVg89d0YgItiUm/pdpSSsSMVNIOj22XP1W4QI4= +github.com/databricks/sdk-go/aigateway v0.9.0 h1:4gq6C+SpXk95VqzwrkWwXUTS3v383Qnp5pYuGdyBua4= +github.com/databricks/sdk-go/aigateway v0.9.0/go.mod h1:q1VZkzp5Oj30rl/sTj1RjNahf5nml0T7Orl/6L051gA= +github.com/databricks/sdk-go/aisearch v0.4.0 h1:Z0ZWDH84AWsjoP1GFOw+MCJwxtujFUtVI06suADWhRw= +github.com/databricks/sdk-go/aisearch v0.4.0/go.mod h1:I/EDjySWpFQYp13zQV/d+0umHuPq8WD++DJiAkuOMEY= +github.com/databricks/sdk-go/alerts v0.4.0 h1:ZO2NaUWU/m7SYCOVUaA4oA2AiOUt3DPlu+CO7kO3v34= +github.com/databricks/sdk-go/alerts v0.4.0/go.mod h1:THC3QqAaXwe7xb0GVC+fxOuocWPm2FShRtj51YaB6YY= +github.com/databricks/sdk-go/apps v0.6.0 h1:qwrFnTpI7DIhwupz4jMZcvaY9DttrD3jnL1BWLqzAxo= +github.com/databricks/sdk-go/apps v0.6.0/go.mod h1:RhQ8eCL9uvGoBgcId7t+dXbnUtNkL/rgibhdeNWpylM= +github.com/databricks/sdk-go/auth v0.2.0 h1:543fVMvJ6pVxBymfjGGkkmfiHDbUqX7y9lZseEcE4tQ= +github.com/databricks/sdk-go/auth v0.2.0/go.mod h1:eNJdFzBAfu1y32a3wPcTnjaUkjhS9VfyCNblKFPIPEo= +github.com/databricks/sdk-go/authentication v0.3.0 h1:pEfHy0/ni0BZFc6ew09/NcSowFKCCEYiVGuKsaZAF1Q= +github.com/databricks/sdk-go/authentication v0.3.0/go.mod h1:Hb6Uu8eCxCGTT8m6+GfRotsx79fQmDGL/xnuNVn8scQ= +github.com/databricks/sdk-go/budgetpolicy v0.3.0 h1:vvTEvZQy72wLpq5e6oHWTS0UiffwD1H75euhV6pJKEo= +github.com/databricks/sdk-go/budgetpolicy v0.3.0/go.mod h1:wpgOjh1gDluI3GuGJBeeWZFmomJK7fSUeUFBoqD6098= +github.com/databricks/sdk-go/budgets v0.3.0 h1:gisBq3IvO6sXpRuKq6TJ2OlrxwoRDi568PFlzSB+JN0= +github.com/databricks/sdk-go/budgets v0.3.0/go.mod h1:gL+M10ZzpmdbTzRGnDrriKout5Ub7gHhQpRJbeZAsEM= +github.com/databricks/sdk-go/cleanrooms v0.3.0 h1:kuFPg+yAChpJ82ulZwiWkeMLMQknnnk7qL3IeHhImbo= +github.com/databricks/sdk-go/cleanrooms v0.3.0/go.mod h1:vo1Vo9RVS4mMT9uR39DR15x3qVX23z4jThp1LjOj7II= +github.com/databricks/sdk-go/clusterlibraries v0.3.0 h1:1XuQ5bXXr8uVOnsCwnHg2RcCaym7FSeSnDfVDzYjmcI= +github.com/databricks/sdk-go/clusterlibraries v0.3.0/go.mod h1:sUsJc+s7R0i7ejGQpMilqCnqXPs+KYIkoNrn47ZctYc= +github.com/databricks/sdk-go/clusterpolicies v0.3.0 h1:NER69VYu3u6yPh9jFX8stzegtpsnU3lY4p02q3xA0tQ= +github.com/databricks/sdk-go/clusterpolicies v0.3.0/go.mod h1:n31+KvexjIu7Y1xCuXfyYNCYgldTzaLjELuM77p1qtk= +github.com/databricks/sdk-go/clusters v0.3.0 h1:wH4ZGhNX28/LRhC7CLAgnBnFBqGTSUVqDbME0QupcME= +github.com/databricks/sdk-go/clusters v0.3.0/go.mod h1:uAhTcUG5Ja/XxTW7e15XvIe5PM1VGJf5Feb/Bt8PTyI= +github.com/databricks/sdk-go/commandexecution v0.3.0 h1:nujddu+H3gP6ZMmTjzyczVNwIUcgADLLvdd165EiVZo= +github.com/databricks/sdk-go/commandexecution v0.3.0/go.mod h1:9NVkpkyhqEVwj16rCYWMZyhf5/bLwXN0l1g/ZQaj8Ys= +github.com/databricks/sdk-go/core v0.1.0 h1:ZolzW/KVIJy1xXQ0zTsu/QYsEB4vQAEApbbq4D3RGHc= +github.com/databricks/sdk-go/core v0.1.0/go.mod h1:7Ckau34bOsaZhHJE6r7ORNa+/kO33jIs6DfrJL6UbsM= +github.com/databricks/sdk-go/customllms v0.3.0 h1:U8lQQEJki7QbUB11RCPYWDWdObbvgeBRE8Gfw7hPOcU= +github.com/databricks/sdk-go/customllms v0.3.0/go.mod h1:jSLvcNarmuw4vl6MBlCLw2T1B+98hvlbdRVO7tcAtxE= +github.com/databricks/sdk-go/database v0.3.0 h1:SXFAix0a+4XpC4ZQryRaSO+ADQ4Z+3u8ArCNWEN7viM= +github.com/databricks/sdk-go/database v0.3.0/go.mod h1:w/2mojF2v+wHZGwIcK8XVx/mwS8V0GaSQY2ktCwIxag= +github.com/databricks/sdk-go/dataclassification v0.3.0 h1:pi3I08FbpFIoOvviDzXVRVbDw+B0zVhTAg6z6ozaOFY= +github.com/databricks/sdk-go/dataclassification v0.3.0/go.mod h1:1/RdldSGO0ar1mEaB2jNlzlUU/aPBtSkTtYjo+rRWd4= +github.com/databricks/sdk-go/dataquality v0.3.0 h1:V41lWFkDCgdWVFKphxFrFx6DMN5ya2A7J6nVszn/YUg= +github.com/databricks/sdk-go/dataquality v0.3.0/go.mod h1:2wpsy+e9SqLr6SjauMn/NMWVArQYJoGRjEGpEN5lXmQ= +github.com/databricks/sdk-go/disasterrecovery v0.3.0 h1:+bpZovqD3aCalctMymPUnMbBVepxSGLcKUn1iKkvO9E= +github.com/databricks/sdk-go/disasterrecovery v0.3.0/go.mod h1:XEMXdaWhgMHjFpIwIQBkDFj705OamS4kkqh5cdPXEto= +github.com/databricks/sdk-go/domains v0.4.0 h1:WJFox4UUy6X0PBBrHLzBXTdrnky+f064vIPAEzvLgzg= +github.com/databricks/sdk-go/domains v0.4.0/go.mod h1:eLPyfOQdUX6Oq3wciyTjkxu7bJRelz5XquYhsHWQbJI= +github.com/databricks/sdk-go/environments v0.3.0 h1:IzLyjqNoXRwTgHyl2tSzD38dmOag/V+85E+Q2UQuX+E= +github.com/databricks/sdk-go/environments v0.3.0/go.mod h1:Oy48UskLT+JMeNYadNsFsLxsWnuM8gNXW0CTJRVfBSU= +github.com/databricks/sdk-go/experiments v0.3.0 h1:G0vPuM6FY49r5Rmxn8hCMFZzAoGzUTnNiwwKqyDLqeQ= +github.com/databricks/sdk-go/experiments v0.3.0/go.mod h1:UFb78rurnsimo8a/Wp6aJnTbE5tzyi5w5jWvH0yXD9w= +github.com/databricks/sdk-go/features v0.9.0 h1:OcfkFsWR7Ooq8wS0qaaT5hs4F9ygl58n2e2PsMIYgFY= +github.com/databricks/sdk-go/features v0.9.0/go.mod h1:f0G1b3C3kldjARBfaDorQaXqLH5H9h09Z++2vZnIp0Q= +github.com/databricks/sdk-go/featurestore v0.3.0 h1:BIE2Buxeinp/MTV721EdJ6QrVPh2UDwbEBCHn3ubQV8= +github.com/databricks/sdk-go/featurestore v0.3.0/go.mod h1:i5bd4nqSwZUclbX9IR5VWCIA6pbU5kkHCURkf9JBED8= +github.com/databricks/sdk-go/files v0.3.0 h1:fAQEIEGbwGkRfcgwuSgC3sXD94mD4Y9Mv2yEQyzV0mQ= +github.com/databricks/sdk-go/files v0.3.0/go.mod h1:ji3JavhhCfFdHRxppdgxHst5Vjx8pfbYmP1oUxK3X10= +github.com/databricks/sdk-go/forecasting v0.3.0 h1:l1WNX2OcT5h58zjacxeRfYfjo5CFdvORTOZc+Xy0EoU= +github.com/databricks/sdk-go/forecasting v0.3.0/go.mod h1:tp1SDVYZPfSMDSo/8bjs51Nv0agr5JKHkzR5k3Ou1kQ= +github.com/databricks/sdk-go/genie v0.3.0 h1:FyRhbwk8H4DA25a7dc+UwTF9nhehnUnntinDORzLE/Q= +github.com/databricks/sdk-go/genie v0.3.0/go.mod h1:NV5LmsBpK3Gy59o+OwbRR/eVRR+KtZMOfNMr+OZzxPs= +github.com/databricks/sdk-go/gitcredentials v0.3.0 h1:Rq3PBBGdmThjXB9L1HfuIAIAARPStw9IrJ0TKCFru7c= +github.com/databricks/sdk-go/gitcredentials v0.3.0/go.mod h1:cxYewF+QiP4+1sxmG8K0B32ywIF96mYJi+JmcUoytiw= +github.com/databricks/sdk-go/globalinitscripts v0.3.0 h1:MwuNKbnEw6x3Syg/749RNKfycB/gLoLKvndz9VTBT+s= +github.com/databricks/sdk-go/globalinitscripts v0.3.0/go.mod h1:SSEPamWDwN1g1aKrqyRxyof05ouwNm/ItNPip4m6fz8= +github.com/databricks/sdk-go/instancepools v0.3.0 h1:HPTPhSwlpzd3/PWe825emoL8v1q+B/w0fsf77ixaRu0= +github.com/databricks/sdk-go/instancepools v0.3.0/go.mod h1:s0HNVWSvOEB21DARXW+GnVorPqbiPNop1McXtCnEmtA= +github.com/databricks/sdk-go/instanceprofiles v0.3.0 h1:dXQ0JsFsmPxxnVn18qHx/76y8iTO006kFArxKzPalqk= +github.com/databricks/sdk-go/instanceprofiles v0.3.0/go.mod h1:xm+s/2V3iS9fRns9iHO870+WOshOzqr7o37aPkMXyYY= +github.com/databricks/sdk-go/jobs v0.4.0 h1:m1S5fhE3WzxAaSSbVkcaCQ+B3tRx6cT+/Tx6HngduZs= +github.com/databricks/sdk-go/jobs v0.4.0/go.mod h1:ecN+Qe+o92ucWZnvhyYVHHLjmRXEpOvGq6wqxzhJOns= +github.com/databricks/sdk-go/keyconfigurations v0.3.0 h1:KVHcc660fk0oZyXrsYtF8IFmHKUxIpclB5ei4OiXFZc= +github.com/databricks/sdk-go/keyconfigurations v0.3.0/go.mod h1:v8SByYiL5/5PFsy1JAv+Cyz0lpDsS6bs8RsusNfTTU0= +github.com/databricks/sdk-go/knowledgeassistants v0.3.0 h1:rre7B7RtmZ7W+axzs6Ruxoyd/Pm8wKn7mYZGNM/brU0= +github.com/databricks/sdk-go/knowledgeassistants v0.3.0/go.mod h1:3hOGN9xDP6A9/O8bAi39M2Gx3vd8EodbPT4+Zn4G8SI= +github.com/databricks/sdk-go/lakeview v0.3.0 h1:6U8tEcLvAVJQeQUTfeJIcZaWOzMm55GXrRe1urfh+WY= +github.com/databricks/sdk-go/lakeview v0.3.0/go.mod h1:LEnY4QsvhUsbEEC/eyT5XI+kzqNlBLuAgQYX+bdNZac= +github.com/databricks/sdk-go/logdelivery v0.3.0 h1:e/pUrLCgBPFhw+2h930iD5YCdIi8Bfe5Iza6yZMheps= +github.com/databricks/sdk-go/logdelivery v0.3.0/go.mod h1:X3rGnUZpkBbDKAx7/JlzSjP8sr5K9E9eRq6wcCil+Sk= +github.com/databricks/sdk-go/marketplaces v0.3.0 h1:Jih6QosPysgsDeUVLJOC9Hdk5+y8e/1gTn9wwr2I6PE= +github.com/databricks/sdk-go/marketplaces v0.3.0/go.mod h1:125aq1PK58/6yPgIIOG5Scrnn6NTNfEn0tn4cgUknUg= +github.com/databricks/sdk-go/modelregistry v0.3.0 h1:XdStpCsaC+v7YJcMXiEnfJuUfrcMItEIpXq/nSCYwXw= +github.com/databricks/sdk-go/modelregistry v0.3.0/go.mod h1:i5NuGGW4ZmG8OavLVyzl35PmbdESLu4hB0ZslsSG+e8= +github.com/databricks/sdk-go/modelserving v0.3.0 h1:NVjunOQ+4zQ89ZTySt8KSWTUkstt11rEoCLewMI9c4w= +github.com/databricks/sdk-go/modelserving v0.3.0/go.mod h1:GbpaVMm4+j0c/fMEmrMrV/YVWlhoIX1oNzsK6jc75x0= +github.com/databricks/sdk-go/modelservingquery v0.3.0 h1:cPn9pJz3K6DrxxJ8wm11jl3vJ9bQ+oYBv3/B2M7sQBM= +github.com/databricks/sdk-go/modelservingquery v0.3.0/go.mod h1:mopPUkDPhBFJqzcCCymOEe9KlcXSmbwJ/yHXRtRRkqE= +github.com/databricks/sdk-go/networking v0.3.0 h1:CuYiN2+6dgG5tNj5QEKAjuhVqAer+ZzNWqz0Ey2LMDA= +github.com/databricks/sdk-go/networking v0.3.0/go.mod h1:uZthaxYkPkUrF0+QQxVT4l+FPDgPr/+Iz9/5h21PF1U= +github.com/databricks/sdk-go/notificationdestinations v0.3.0 h1:uHbPDhwiYnGiHiR+osEZ/4ov5h6I8lw4IQxHKBvqML4= +github.com/databricks/sdk-go/notificationdestinations v0.3.0/go.mod h1:J4jEVGsx0qRlMix9BJMLEqXvNGVq2RJErlPPO7zrY1w= +github.com/databricks/sdk-go/oauth v0.3.0 h1:4fHNeM6fyuWcaevg1HVcLemWtywxfh16vR1qMgCvZ9I= +github.com/databricks/sdk-go/oauth v0.3.0/go.mod h1:yCaQBW09Aw6IFod2OvyRL/HW+Cl+s/mY/sBkMXQRZqI= +github.com/databricks/sdk-go/options v0.3.0 h1:9Gr76jyel9t+cr1vK/7+WjusAVgcJbsfERjRPe11GBg= +github.com/databricks/sdk-go/options v0.3.0/go.mod h1:ntPpJ7v48ryM431YlP3W6FjmdgMn1n/tVoPj8BocNXg= +github.com/databricks/sdk-go/pipelines v0.5.0 h1:vjMhsl6ZY6FZD+e41/Q3C/ebvqm5LSF7fpCU/JAcOoc= +github.com/databricks/sdk-go/pipelines v0.5.0/go.mod h1:lYsXQ2eqh7zIfLBr6C4FYxhxju58g3upOL23YdDr2bM= +github.com/databricks/sdk-go/policyfamilies v0.3.0 h1:IZOoz6o917NTN57DNl+ER1E9wpeuD5erJeuAV3axepA= +github.com/databricks/sdk-go/policyfamilies v0.3.0/go.mod h1:Kjr1rczRCpXbRibG4VRSL4a0pHmx+eLLNK2QJKSk/04= +github.com/databricks/sdk-go/postgres v0.5.0 h1:osuIPIG+eyzqpLqRzYiklBPxD5RvXT/1dO7zE8gLrEM= +github.com/databricks/sdk-go/postgres v0.5.0/go.mod h1:KCfxsoGpju64Y5uAya+aEPVihEaUJtVYqccl+61bXkM= +github.com/databricks/sdk-go/queries v0.3.0 h1:aEQCWZ8BYVftFdpHDJeL6qmIelrd1l3Y/7ZB92XadmU= +github.com/databricks/sdk-go/queries v0.3.0/go.mod h1:EFO6DqaWGbd4sVz7AMxrqtX6c3Q2VDBd2eIrYxntkIc= +github.com/databricks/sdk-go/queryhistory v0.3.0 h1:FjEIZTS3b3wg8xr4BHtboPGrHkIbp7UjyIXCXkcL1ok= +github.com/databricks/sdk-go/queryhistory v0.3.0/go.mod h1:OE9auOrxNnHFzcG4k0OaxEv4I7Oas5Fi49XRkshBJqI= +github.com/databricks/sdk-go/repos v0.3.0 h1:iHKFWUxxSaW8UPaZcAh+wtkGiomuzAhw6TtY4YAL5Zw= +github.com/databricks/sdk-go/repos v0.3.0/go.mod h1:/1+dGL9v2vl0utf6CfMkyBGjrIxCJech2QApaP3/Wnk= +github.com/databricks/sdk-go/sandbox v0.3.0 h1:f0J/DWKZQ3/VlXk8oowB4QUKzOdUEL4xQ9wH1sPFxeg= +github.com/databricks/sdk-go/sandbox v0.3.0/go.mod h1:ODQ9ESihw+WUuJ/qx3nZW6qohRT+d5ujpiwrn3wWQX4= +github.com/databricks/sdk-go/scim v0.3.0 h1:21oRCGDKMR0JlgHncj28W/BCx9RT5YhQByyx6Suc+yM= +github.com/databricks/sdk-go/scim v0.3.0/go.mod h1:vqC+znGtGkK+TZdok84uqnz+aI/GSazuTiCEImxFxlg= +github.com/databricks/sdk-go/secrets v0.3.0 h1:47Y5OTJXGCbAnCCRETol6OYbZgsQF/sJsES9cXSECsA= +github.com/databricks/sdk-go/secrets v0.3.0/go.mod h1:WlgIE7Imspld6eD+eEpK4b4JHjzsOF5ctXJmAzT9uHA= +github.com/databricks/sdk-go/settings v0.3.0 h1:nhDHaBuk7Z3tasxDWeruahGxS8XFJfqQ9V3sA5XXtUI= +github.com/databricks/sdk-go/settings v0.3.0/go.mod h1:TIb2LPIbEXgoNDxxOc0RH5spwUKlGWbsDmhX7FiMN7k= +github.com/databricks/sdk-go/sharing v0.4.0 h1:nhDIeTfKKAkiSiVNn5aAzNonywdKsLbiHyRCMX6jvD0= +github.com/databricks/sdk-go/sharing v0.4.0/go.mod h1:EpqNCrhFf/X0SQULIDk6Vgn3+Rr5TirJ2vD6qXpCzM4= +github.com/databricks/sdk-go/statementexecution v0.4.0 h1:MzkMPJDrnu1P5CUtpN5sKh1d2d8PcUw5qhxeDOeyJRg= +github.com/databricks/sdk-go/statementexecution v0.4.0/go.mod h1:QdAqb+/Tsl3GzdQb/aRyQjsTI493vH/djoQVmucai8M= +github.com/databricks/sdk-go/storageconfigurations v0.3.0 h1:sr5F5hhSjVpOV/RmojO9JloKTHWLY6wBuZyqSFA3krA= +github.com/databricks/sdk-go/storageconfigurations v0.3.0/go.mod h1:Lh5L/mHvt4KghljpZm6N8wY8KP4nspCVNFAysRTpDco= +github.com/databricks/sdk-go/supervisoragents v0.3.0 h1:dGpmiXQoIqVc8oWDpO7JGPi96Hv+yzPlEQSRy0N1Ebk= +github.com/databricks/sdk-go/supervisoragents v0.3.0/go.mod h1:yLGQeS3OZszPRi7/yclCUt5b/AVpgJnA1rnXFOWTnKY= +github.com/databricks/sdk-go/tagassignments v0.3.0 h1:a9mm7q6OeUxr5WshziljM2mmWQnjCWGLvK6gk4Wexc8= +github.com/databricks/sdk-go/tagassignments v0.3.0/go.mod h1:kEWoJNPsYla/PNvZwRa70zhbt3jBvoLeJZ7zIK9dSMI= +github.com/databricks/sdk-go/tagpolicies v0.3.0 h1:1aBiUP5n2+NOHHxKU924OEAAkJ0QvJa7By+IdJSuWSY= +github.com/databricks/sdk-go/tagpolicies v0.3.0/go.mod h1:PgYQfJZHmDYv4CLwzqsXQcPNUZqb8dFvF9b0EYdoV6k= +github.com/databricks/sdk-go/tokenmanagement v0.3.0 h1:R7dR/ZPheHHsLknu8fCtDmY3lK4udg7k6B692m7IF7k= +github.com/databricks/sdk-go/tokenmanagement v0.3.0/go.mod h1:TfXqjC+eCKfwMEvoLAoKr3oEmQwCXV6vvRGr8QnBaVE= +github.com/databricks/sdk-go/tokens v0.3.0 h1:PsQs1lWNAY5Hjv2fatYYfeGChyAEXJ7gcgmhciXJ8gs= +github.com/databricks/sdk-go/tokens v0.3.0/go.mod h1:QIFg0zJ3RHbLaupzG78PgVhkKKGNhjzuM1ZE1OmqpCM= +github.com/databricks/sdk-go/uc/abacpolicies v0.3.0 h1:WnvTjw9VLwH8strbXWnLJV0BkQB4IOWUwRFOoac5ZJc= +github.com/databricks/sdk-go/uc/abacpolicies v0.3.0/go.mod h1:jTzx6UEwc9pIaIzBNyDc4QF2z40VAPSSXvehxnN+bYY= +github.com/databricks/sdk-go/uc/artifactallowlists v0.3.0 h1:28kvr857IdzIgC2ILMw7mNtZLvUWEj5l4dgJSH8FDoU= +github.com/databricks/sdk-go/uc/artifactallowlists v0.3.0/go.mod h1:/CbMla+FVjx0DMoBHBa3KXmLzpfjgfdI2NSD/bCcKpM= +github.com/databricks/sdk-go/uc/catalogs v0.3.0 h1:N/VV9ibbHdwgfxO7zKciy4Uu4hZ1w+uL/ddAvd+NiaM= +github.com/databricks/sdk-go/uc/catalogs v0.3.0/go.mod h1:T9C6LtD/HBdheLEqDd9cscBQMe/j/cTubgVlRL1Fhug= +github.com/databricks/sdk-go/uc/connections v0.3.0 h1:rwj2jgdXj/uTnu6z2VpdZSuGmkEWaRuy+IraoZ/q4mU= +github.com/databricks/sdk-go/uc/connections v0.3.0/go.mod h1:BMX+U0E5p3zDqJ4aGqcUqG0H4tmR8/dSRm07VFmuh4M= +github.com/databricks/sdk-go/uc/credentials v0.3.0 h1:83/OrZi9xgnDwmhQe+RwhUDwpup0x9yHtmTAZIw8qwU= +github.com/databricks/sdk-go/uc/credentials v0.3.0/go.mod h1:RweY/7+fJe321cIAPZnxavEi9Oq2hGAQRE8hC9kg+VY= +github.com/databricks/sdk-go/uc/entitytagassignments v0.3.0 h1:qCfev7j0Tf5nATcamFLPLqDl6LFDrLgduC5MpQWviu4= +github.com/databricks/sdk-go/uc/entitytagassignments v0.3.0/go.mod h1:6H+zZz1qL00WqlBqhTHIh9jVMi5ICudCV+2vTcCoSy8= +github.com/databricks/sdk-go/uc/externallineage v0.3.0 h1:8bYWhyi33jyf+dmh6peh4hKey2T76BvTHKtesaQz94I= +github.com/databricks/sdk-go/uc/externallineage v0.3.0/go.mod h1:NZy5Z5BVYMzNYhwE/E99+VhUiTfgkAN6/iu11LYM02Y= +github.com/databricks/sdk-go/uc/externallocations v0.3.0 h1:4dR3jAomFtz+rkOK1MvvUUjYBKWjJn+XSP7A1WVohKY= +github.com/databricks/sdk-go/uc/externallocations v0.3.0/go.mod h1:hTwzTaGlCk6yYJj14mtmcGhlXaasqGxD9AVnrLNdXrM= +github.com/databricks/sdk-go/uc/externalmetadata v0.3.0 h1:LAhCVWDH+piluHJySQIAaNRGzOA7/7qtZv0riIhUtBo= +github.com/databricks/sdk-go/uc/externalmetadata v0.3.0/go.mod h1:rkUyT6b1fJxQSq/tL4LtiDGWkoyDIdO6z7zHeibT6u0= +github.com/databricks/sdk-go/uc/functions v0.3.0 h1:d6eJsRFHfwn7+uJdoQxXC0msF/MMLX9WbX8LAkht42E= +github.com/databricks/sdk-go/uc/functions v0.3.0/go.mod h1:140XLGeU724MrAUQjAFF+UqJ5d0DiPjScG6rlzm5/Kk= +github.com/databricks/sdk-go/uc/grants v0.3.0 h1:KisDzM4f2FW01E3eY7XGeWmVkMSG+glFaSiksAw9C2w= +github.com/databricks/sdk-go/uc/grants v0.3.0/go.mod h1:N92sMA3MFFMoPUcr9O2Ls4C3CyjQZNrZ1BLkk2QVvg0= +github.com/databricks/sdk-go/uc/metastores v0.3.0 h1:QqUu5NlWkpcou5L25FLrCfYhJP23hDgz3dsQMeRA3oQ= +github.com/databricks/sdk-go/uc/metastores v0.3.0/go.mod h1:Re+KVnN+1eUeOmMzrA19C5hRhyNr3gzFkifQtp/uapQ= +github.com/databricks/sdk-go/uc/onlinetables v0.3.0 h1:WhYo+0XOT5KsnMOVzVSM60jLSPNE+RoKzAL7EGwdz9s= +github.com/databricks/sdk-go/uc/onlinetables v0.3.0/go.mod h1:yq4jiR6sO4HOGEkZ46Pqk9HunDMepd3Ide9GAR+F1KY= +github.com/databricks/sdk-go/uc/registeredmodels v0.3.0 h1:wNCGjjkKgTquIFgsvtnnufR63EWJIrvRsL1MrI9WAsg= +github.com/databricks/sdk-go/uc/registeredmodels v0.3.0/go.mod h1:1s3IT1Z0GGNCfnz1NlDJZBLSxH/oVIOzmoKryoWRpw4= +github.com/databricks/sdk-go/uc/resourcequotas v0.3.0 h1:/ylDbemQCP5E4rcTtWt6Aq5ch5MUvzdAz/BdBNLdvYQ= +github.com/databricks/sdk-go/uc/resourcequotas v0.3.0/go.mod h1:DsJqxRa8wyBcgL/qCXg77MjRY5AyqMU6wVGQSY7ILHw= +github.com/databricks/sdk-go/uc/rfa v0.3.0 h1:I3deMlPOqcyhdrnU5LWpbiJvCKlJIikH7ZnnCXWR8MQ= +github.com/databricks/sdk-go/uc/rfa v0.3.0/go.mod h1:dQUTFspuhLSKk1ErvgNrOgfcXBkJKw6s1KuFiTZbraA= +github.com/databricks/sdk-go/uc/schemas v0.3.0 h1:l+ql2hd1fopbjxxthYnoOPt0cTR7eQJNhtPkhPrVWjw= +github.com/databricks/sdk-go/uc/schemas v0.3.0/go.mod h1:NJMxsssTOy1QPb4OrXebMGMsoY52LdrdH5brwjaUkes= +github.com/databricks/sdk-go/uc/secrets v0.3.0 h1:QjlhjbcQzH+BSt/QQQr7LPvMetjXynrJoCND3cYvrso= +github.com/databricks/sdk-go/uc/secrets v0.3.0/go.mod h1:HnyRG1PoCeDGcTS6cDiYBmGIzxf2sKWW/3M5Dy7CtrU= +github.com/databricks/sdk-go/uc/systemschemas v0.3.0 h1:BMyypBySFhQ80Y4teOOgj1LdIPYanaSeDF+4a0cFBa4= +github.com/databricks/sdk-go/uc/systemschemas v0.3.0/go.mod h1:rOAeKeF2cd2ox9IxueCctyMYkyk1vQrygiMdfNSTe6Y= +github.com/databricks/sdk-go/uc/tables v0.4.0 h1:ZBOf05oHiPUAHeAQ3lZ+HqrhAbIOA+HaMpCGNkoV+ws= +github.com/databricks/sdk-go/uc/tables v0.4.0/go.mod h1:2esIYnOlSWg7IgTazOKm8uHouu5MR/BzVjHbOv3KQuo= +github.com/databricks/sdk-go/uc/volumes v0.3.0 h1:n4JrMlWEsYYrlEHVxp0SMLGZf1QWuA9L+hef3+TfZ/M= +github.com/databricks/sdk-go/uc/volumes v0.3.0/go.mod h1:aKlmG3axKQE8FDWE025yvCN2MEFiBrSxUngY6ufD1Lk= +github.com/databricks/sdk-go/uc/workspacebindings v0.3.0 h1:mvnxdJZHjK1buk/U3lAppmPgtffwtQ4av4h9ELhcxZY= +github.com/databricks/sdk-go/uc/workspacebindings v0.3.0/go.mod h1:ZGf42MEn6sepyChCkTn7xs8dJEc2S9P46TYOWDLzBVk= +github.com/databricks/sdk-go/usagedashboards v0.3.0 h1:C3+jQ79oviM25aSIZ7W+zJ/7C0sS4q5ZOJC+4FNhf5s= +github.com/databricks/sdk-go/usagedashboards v0.3.0/go.mod h1:DERlEWYr63UdVpqjh1gEtI6NBmFyuEdywT5EIGET+Tk= +github.com/databricks/sdk-go/vectorsearch v0.4.0 h1:5t2DNcRHFst9lohGdrqpQSJr0k2BrqQ/SIM25pvgZYA= +github.com/databricks/sdk-go/vectorsearch v0.4.0/go.mod h1:qvyJyHzOUzgBcZrqKPxlHVle0s1uINU4EE6Ad4GR7jU= +github.com/databricks/sdk-go/warehouses v0.5.0 h1:laj414avlX19Vv4dhI7l6SSSROk5RPemcGP9dqarMPk= +github.com/databricks/sdk-go/warehouses v0.5.0/go.mod h1:AQGTsyi23C+UyJnapOIER3ll67AejxmBhNJyHM+nifA= +github.com/databricks/sdk-go/workspaces v0.3.0 h1:4KD9W0L2coTf8DFkCYXN4fU4ezzT8DzJUZx6co0hy6E= +github.com/databricks/sdk-go/workspaces v0.3.0/go.mod h1:8YBeKfQMmjm+wjT1ullOJvJtg91yEFlHes13O3PNgD4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= diff --git a/integration/assumptions/dashboard_assumptions_test.go b/integration/assumptions/dashboard_assumptions_test.go index 111482a6f81..2c7b4a535f5 100644 --- a/integration/assumptions/dashboard_assumptions_test.go +++ b/integration/assumptions/dashboard_assumptions_test.go @@ -6,13 +6,14 @@ import ( "github.com/databricks/cli/integration/internal/acc" "github.com/databricks/cli/internal/testutil" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/convert" "github.com/databricks/cli/libs/dyn/merge" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/dashboards" - "github.com/databricks/databricks-sdk-go/service/workspace" - + "github.com/databricks/cli/libs/sdktypes/lakeview/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/workspaceapi" + sdklakeview "github.com/databricks/sdk-go/lakeview/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -30,22 +31,24 @@ func TestDashboardAssumptions_WorkspaceImport(t *testing.T) { dir := acc.TemporaryWorkspaceDir(wt, "dashboard-assumptions-") - dashboard, err := wt.W.Lakeview.Create(ctx, dashboards.CreateDashboardRequest{ - Dashboard: dashboards.Dashboard{ - DisplayName: dashboardName, - ParentPath: dir, - SerializedDashboard: string(dashboardPayload), - WarehouseId: warehouseId, + created, err := wt.W.Lakeview.CreateDashboard(ctx, sdklakeview.CreateDashboardRequest{ + Dashboard: &sdklakeview.DashboardCreate{ + DisplayName: new(dashboardName), + ParentPath: new(dir), + SerializedDashboard: new(string(dashboardPayload)), + WarehouseId: new(warehouseId), }, }) require.NoError(t, err) - t.Logf("Dashboard ID (per Lakeview API): %s", dashboard.DashboardId) + dashboard, err := lakeview.DashboardFromSDK(created) + require.NoError(t, err) + t.Logf("Dashboard ID (per Lakeview API): %s", utils.Deref(dashboard.DashboardId)) // Overwrite the dashboard via the workspace API. { - err := wt.W.Workspace.Import(ctx, workspace.Import{ - Format: workspace.ImportFormatAuto, - Path: dashboard.Path, + err := wt.W.Workspace.Import(ctx, workspaceapi.Import{ + Format: workspaceapi.ImportFormatAuto, + Path: utils.Deref(dashboard.Path), Content: base64.StdEncoding.EncodeToString(dashboardPayload), Overwrite: true, }) @@ -54,37 +57,39 @@ func TestDashboardAssumptions_WorkspaceImport(t *testing.T) { // Cross-check consistency with the workspace object. { - obj, err := wt.W.Workspace.GetStatusByPath(ctx, dashboard.Path) + obj, err := wt.W.Workspace.GetStatusByPath(ctx, utils.Deref(dashboard.Path)) require.NoError(t, err) // Confirm that the resource ID included in the response is equal to the dashboard ID. - require.Equal(t, dashboard.DashboardId, obj.ResourceId) + require.Equal(t, utils.Deref(dashboard.DashboardId), obj.ResourceId) t.Logf("Dashboard ID (per workspace object status): %s", obj.ResourceId) } // Try to overwrite the dashboard via the Lakeview API (and expect failure). { - _, err := wt.W.Lakeview.Create(ctx, dashboards.CreateDashboardRequest{ - Dashboard: dashboards.Dashboard{ - DisplayName: dashboardName, - ParentPath: dir, - SerializedDashboard: string(dashboardPayload), + _, err := wt.W.Lakeview.CreateDashboard(ctx, sdklakeview.CreateDashboardRequest{ + Dashboard: &sdklakeview.DashboardCreate{ + DisplayName: new(dashboardName), + ParentPath: new(dir), + SerializedDashboard: new(string(dashboardPayload)), }, }) // Lakeview returns the generic gRPC error_code ALREADY_EXISTS, not // Databricks' RESOURCE_ALREADY_EXISTS, so the SDK unwraps to // ErrAlreadyExists rather than ErrResourceAlreadyExists. Assert the // common 409 parent to stay resilient to either code. - require.ErrorIs(t, err, apierr.ErrResourceConflict) + require.True(t, apierrs.Is(err, apierrs.ErrResourceConflict), "unexpected error: %v", err) } // Retrieve the dashboard object and confirm that only select fields were updated by the import. { previousDashboard := dashboard - currentDashboard, err := wt.W.Lakeview.Get(ctx, dashboards.GetDashboardRequest{ + got, err := wt.W.Lakeview.GetDashboard(ctx, sdklakeview.GetDashboardRequest{ DashboardId: dashboard.DashboardId, }) require.NoError(t, err) + currentDashboard, err := lakeview.DashboardFromSDK(got) + require.NoError(t, err) // Convert the dashboard object to a [dyn.Value] to make comparison easier. previous, err := convert.FromTyped(previousDashboard, dyn.NilValue) diff --git a/integration/bundle/init_test.go b/integration/bundle/init_test.go index ff8b7de2c87..6c5b9c9077a 100644 --- a/integration/bundle/init_test.go +++ b/integration/bundle/init_test.go @@ -10,7 +10,7 @@ import ( "github.com/databricks/cli/internal/testcli" "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/iamutil" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -26,7 +26,7 @@ func TestBundleInitHelpers(t *testing.T) { ctx, wt := acc.WorkspaceTest(t) w := wt.W - me, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + me, err := iamutil.GetCurrentUser(ctx, w) require.NoError(t, err) var smallestNode string @@ -51,7 +51,7 @@ func TestBundleInitHelpers(t *testing.T) { }, { funcName: "{{user_name}}", - expected: me.UserName, + expected: utils.Deref(me.UserName), }, { funcName: "{{workspace_host}}", diff --git a/integration/cmd/sync/sync_test.go b/integration/cmd/sync/sync_test.go index b58d00ca2d0..e24f3e5b659 100644 --- a/integration/cmd/sync/sync_test.go +++ b/integration/cmd/sync/sync_test.go @@ -18,13 +18,15 @@ import ( "github.com/databricks/cli/integration/internal/acc" "github.com/databricks/cli/internal/testcli" "github.com/databricks/cli/internal/testutil" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/filer" + "github.com/databricks/cli/libs/iamutil" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/sync" "github.com/databricks/cli/libs/testfile" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/workspaceapi" + "github.com/databricks/sdk-go/repos/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -36,20 +38,20 @@ var ( // This test needs auth env vars to run. // Please run using the deco env test or deco env shell -func setupRepo(t *testing.T, wsc *databricks.WorkspaceClient, ctx context.Context) (localRoot, remoteRoot string) { - me, err := wsc.CurrentUser.Me(ctx, iam.MeRequest{}) +func setupRepo(t *testing.T, wsc *sdkclients.Clients, ctx context.Context) (localRoot, remoteRoot string) { + me, err := iamutil.GetCurrentUser(ctx, wsc) require.NoError(t, err) - repoPath := fmt.Sprintf("/Repos/%s/%s", me.UserName, testutil.RandomName("empty-repo-sync-integration-")) + repoPath := fmt.Sprintf("/Repos/%s/%s", utils.Deref(me.UserName), testutil.RandomName("empty-repo-sync-integration-")) - repoInfo, err := wsc.Repos.Create(ctx, workspace.CreateRepoRequest{ - Path: repoPath, - Url: repoUrl, - Provider: "gitHub", + repoInfo, err := wsc.Repos.CreateRepo(ctx, repos.CreateRepoRequest{ + Path: new(repoPath), + Url: new(repoUrl), + Provider: new("gitHub"), }) require.NoError(t, err) t.Cleanup(func() { - err := wsc.Repos.DeleteByRepoId(context.WithoutCancel(ctx), repoInfo.Id) + _, err := wsc.Repos.DeleteRepo(context.WithoutCancel(ctx), repos.DeleteRepoRequest{Id: repoInfo.Id}) assert.NoError(t, err) }) @@ -67,7 +69,7 @@ func setupRepo(t *testing.T, wsc *databricks.WorkspaceClient, ctx context.Contex type syncTest struct { t *testing.T c *testcli.Runner - w *databricks.WorkspaceClient + w *sdkclients.Clients f filer.Filer localRoot string remoteRoot string @@ -126,13 +128,13 @@ func (a *syncTest) waitForCompletionMarker() { func (a *syncTest) remoteDirContent(ctx context.Context, relativeDir string, expectedFiles []string) { remoteDir := path.Join(a.remoteRoot, relativeDir) a.c.Eventually(func() bool { - objects, err := a.w.Workspace.ListAll(ctx, workspace.ListWorkspaceRequest{ + objects, err := a.w.Workspace.ListAll(ctx, workspaceapi.ListWorkspaceRequest{ Path: remoteDir, }) require.NoError(a.t, err) return len(objects) == len(expectedFiles) }, 30*time.Second, 5*time.Second) - objects, err := a.w.Workspace.ListAll(ctx, workspace.ListWorkspaceRequest{ + objects, err := a.w.Workspace.ListAll(ctx, workspaceapi.ListWorkspaceRequest{ Path: remoteDir, }) require.NoError(a.t, err) @@ -154,7 +156,7 @@ func (a *syncTest) remoteFileContent(ctx context.Context, relativePath, expected // Remove leading "/" so we can use it in the URL. urlPath := "/api/2.0/workspace-files/" + strings.TrimLeft(filePath, "/") - apiClient, err := client.New(a.w.Config) + apiClient, err := apiclient.New(a.w.Config) require.NoError(a.t, err) var res []byte @@ -488,11 +490,11 @@ func TestSyncEnsureRemotePathIsUsableIfRepoDoesntExist(t *testing.T) { ctx, wt := acc.WorkspaceTest(t) wsc := wt.W - me, err := wsc.CurrentUser.Me(ctx, iam.MeRequest{}) + me, err := iamutil.GetCurrentUser(ctx, wsc) require.NoError(t, err) // Hypothetical repo path doesn't exist. - nonExistingRepoPath := fmt.Sprintf("/Repos/%s/%s", me.UserName, testutil.RandomName("doesnt-exist-")) + nonExistingRepoPath := fmt.Sprintf("/Repos/%s/%s", utils.Deref(me.UserName), testutil.RandomName("doesnt-exist-")) err = sync.EnsureRemotePathIsUsable(ctx, wsc, nonExistingRepoPath, nil, false) assert.ErrorContains(t, err, " does not exist; please create it first") @@ -520,23 +522,23 @@ func TestSyncEnsureRemotePathIsUsableIfRepoExists(t *testing.T) { // Verify that the directory has been created. info, err := wsc.Workspace.GetStatusByPath(ctx, nestedPath) require.NoError(t, err) - require.Equal(t, workspace.ObjectTypeDirectory, info.ObjectType) + require.Equal(t, workspaceapi.ObjectTypeDirectory, info.ObjectType) } func TestSyncEnsureRemotePathIsUsableInWorkspace(t *testing.T) { ctx, wt := acc.WorkspaceTest(t) wsc := wt.W - me, err := wsc.CurrentUser.Me(ctx, iam.MeRequest{}) + me, err := iamutil.GetCurrentUser(ctx, wsc) require.NoError(t, err) - remotePath := fmt.Sprintf("/Users/%s/%s", me.UserName, testutil.RandomName("ensure-path-exists-test-")) + remotePath := fmt.Sprintf("/Users/%s/%s", utils.Deref(me.UserName), testutil.RandomName("ensure-path-exists-test-")) err = sync.EnsureRemotePathIsUsable(ctx, wsc, remotePath, me, false) assert.NoError(t, err) // Clean up directory after test. defer func() { - err := wsc.Workspace.Delete(ctx, workspace.Delete{ + err := wsc.Workspace.Delete(ctx, workspaceapi.Delete{ Path: remotePath, }) assert.NoError(t, err) @@ -545,5 +547,5 @@ func TestSyncEnsureRemotePathIsUsableInWorkspace(t *testing.T) { // Verify that the directory has been created. info, err := wsc.Workspace.GetStatusByPath(ctx, remotePath) require.NoError(t, err) - require.Equal(t, workspace.ObjectTypeDirectory, info.ObjectType) + require.Equal(t, workspaceapi.ObjectTypeDirectory, info.ObjectType) } diff --git a/integration/cmd/workspace/workspace_test.go b/integration/cmd/workspace/workspace_test.go index 53456ff8d7a..f098e967028 100644 --- a/integration/cmd/workspace/workspace_test.go +++ b/integration/cmd/workspace/workspace_test.go @@ -14,7 +14,7 @@ import ( "github.com/databricks/cli/integration/internal/acc" "github.com/databricks/cli/internal/testcli" "github.com/databricks/cli/libs/filer" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/workspaceapi" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -75,10 +75,10 @@ func assertFilerFileContents(t *testing.T, ctx context.Context, f filer.Filer, p assert.Contains(t, string(b), content) } -func assertWorkspaceFileType(t *testing.T, ctx context.Context, f filer.Filer, path string, fileType workspace.ObjectType) { +func assertWorkspaceFileType(t *testing.T, ctx context.Context, f filer.Filer, path string, fileType workspaceapi.ObjectType) { info, err := f.Stat(ctx, path) require.NoError(t, err) - assert.Equal(t, fileType, info.Sys().(workspace.ObjectInfo).ObjectType) + assert.Equal(t, fileType, info.Sys().(workspaceapi.ObjectInfo).ObjectType) } func TestExportDir(t *testing.T) { @@ -323,14 +323,14 @@ func TestImportFileUsingContentFormatSource(t *testing.T) { testcli.RequireSuccessfulRun(t, ctx, "workspace", "import", path.Join(targetDir, "pyScript"), "--content", base64.StdEncoding.EncodeToString([]byte("print(1)")), "--language=PYTHON") assertFilerFileContents(t, ctx, workspaceFiler, "pyScript", "print(1)") - assertWorkspaceFileType(t, ctx, workspaceFiler, "pyScript", workspace.ObjectTypeNotebook) + assertWorkspaceFileType(t, ctx, workspaceFiler, "pyScript", workspaceapi.ObjectTypeNotebook) // Import with content = `# Databricks notebook source\nprint(1)`. Uploaded as a notebook with the content just being print(1) testcli.RequireSuccessfulRun(t, ctx, "workspace", "import", path.Join(targetDir, "pyNb"), "--content", base64.StdEncoding.EncodeToString([]byte("`# Databricks notebook source\nprint(1)")), "--language=PYTHON") assertFilerFileContents(t, ctx, workspaceFiler, "pyNb", "print(1)") - assertWorkspaceFileType(t, ctx, workspaceFiler, "pyNb", workspace.ObjectTypeNotebook) + assertWorkspaceFileType(t, ctx, workspaceFiler, "pyNb", workspaceapi.ObjectTypeNotebook) } func TestImportFileUsingContentFormatAuto(t *testing.T) { @@ -340,30 +340,30 @@ func TestImportFileUsingContentFormatAuto(t *testing.T) { testcli.RequireSuccessfulRun(t, ctx, "workspace", "import", path.Join(targetDir, "py-nb-as-file"), "--content", base64.StdEncoding.EncodeToString([]byte("`# Databricks notebook source\nprint(1)")), "--format=AUTO") assertFilerFileContents(t, ctx, workspaceFiler, "py-nb-as-file", "# Databricks notebook source\nprint(1)") - assertWorkspaceFileType(t, ctx, workspaceFiler, "py-nb-as-file", workspace.ObjectTypeFile) + assertWorkspaceFileType(t, ctx, workspaceFiler, "py-nb-as-file", workspaceapi.ObjectTypeFile) // Content = `# Databricks notebook source\nprint(1)`. Upload as notebook if path has py extension testcli.RequireSuccessfulRun(t, ctx, "workspace", "import", path.Join(targetDir, "py-nb-as-notebook.py"), "--content", base64.StdEncoding.EncodeToString([]byte("`# Databricks notebook source\nprint(1)")), "--format=AUTO") assertFilerFileContents(t, ctx, workspaceFiler, "py-nb-as-notebook", "# Databricks notebook source\nprint(1)") - assertWorkspaceFileType(t, ctx, workspaceFiler, "py-nb-as-notebook", workspace.ObjectTypeNotebook) + assertWorkspaceFileType(t, ctx, workspaceFiler, "py-nb-as-notebook", workspaceapi.ObjectTypeNotebook) // Content = `print(1)`. Upload as file if content is not notebook (even if path has .py extension) testcli.RequireSuccessfulRun(t, ctx, "workspace", "import", path.Join(targetDir, "not-a-notebook.py"), "--content", base64.StdEncoding.EncodeToString([]byte("print(1)")), "--format=AUTO") assertFilerFileContents(t, ctx, workspaceFiler, "not-a-notebook.py", "print(1)") - assertWorkspaceFileType(t, ctx, workspaceFiler, "not-a-notebook.py", workspace.ObjectTypeFile) + assertWorkspaceFileType(t, ctx, workspaceFiler, "not-a-notebook.py", workspaceapi.ObjectTypeFile) } func TestImportFileFormatSource(t *testing.T) { ctx, workspaceFiler, targetDir := setupWorkspaceImportExportTest(t) testcli.RequireSuccessfulRun(t, ctx, "workspace", "import", path.Join(targetDir, "pyNotebook"), "--file", "./testdata/import_dir/pyNotebook.py", "--language=PYTHON") assertFilerFileContents(t, ctx, workspaceFiler, "pyNotebook", "# Databricks notebook source\nprint(\"python\")") - assertWorkspaceFileType(t, ctx, workspaceFiler, "pyNotebook", workspace.ObjectTypeNotebook) + assertWorkspaceFileType(t, ctx, workspaceFiler, "pyNotebook", workspaceapi.ObjectTypeNotebook) testcli.RequireSuccessfulRun(t, ctx, "workspace", "import", path.Join(targetDir, "scalaNotebook"), "--file", "./testdata/import_dir/scalaNotebook.scala", "--language=SCALA") assertFilerFileContents(t, ctx, workspaceFiler, "scalaNotebook", "// Databricks notebook source\nprintln(\"scala\")") - assertWorkspaceFileType(t, ctx, workspaceFiler, "scalaNotebook", workspace.ObjectTypeNotebook) + assertWorkspaceFileType(t, ctx, workspaceFiler, "scalaNotebook", workspaceapi.ObjectTypeNotebook) // Upload a non-zip archive without a specifying a format: expect API to throw an error that the uploaded item is not a zip archive _, _, err := testcli.RequireErrorRun(t, ctx, "workspace", "import", path.Join(targetDir, "scalaNotebook-error"), "--file", "./testdata/import_dir/scalaNotebook.scala") @@ -377,15 +377,15 @@ func TestImportFileFormatAuto(t *testing.T) { testcli.RequireSuccessfulRun(t, ctx, "workspace", "import", path.Join(targetDir, "py-nb-as-file"), "--file", "./testdata/import_dir/pyNotebook.py", "--format=AUTO") assertFilerFileContents(t, ctx, workspaceFiler, "py-nb-as-file", "# Databricks notebook source") assertFilerFileContents(t, ctx, workspaceFiler, "py-nb-as-file", "print(\"python\")") - assertWorkspaceFileType(t, ctx, workspaceFiler, "py-nb-as-file", workspace.ObjectTypeFile) + assertWorkspaceFileType(t, ctx, workspaceFiler, "py-nb-as-file", workspaceapi.ObjectTypeFile) // Upload as notebook if path has extension testcli.RequireSuccessfulRun(t, ctx, "workspace", "import", path.Join(targetDir, "py-nb-as-notebook.py"), "--file", "./testdata/import_dir/pyNotebook.py", "--format=AUTO") assertFilerFileContents(t, ctx, workspaceFiler, "py-nb-as-notebook", "# Databricks notebook source\nprint(\"python\")") - assertWorkspaceFileType(t, ctx, workspaceFiler, "py-nb-as-notebook", workspace.ObjectTypeNotebook) + assertWorkspaceFileType(t, ctx, workspaceFiler, "py-nb-as-notebook", workspaceapi.ObjectTypeNotebook) // Upload as file if content is not notebook (even if path has .py extension) testcli.RequireSuccessfulRun(t, ctx, "workspace", "import", path.Join(targetDir, "not-a-notebook.py"), "--file", "./testdata/import_dir/file-a", "--format=AUTO") assertFilerFileContents(t, ctx, workspaceFiler, "not-a-notebook.py", "hello, world") - assertWorkspaceFileType(t, ctx, workspaceFiler, "not-a-notebook.py", workspace.ObjectTypeFile) + assertWorkspaceFileType(t, ctx, workspaceFiler, "not-a-notebook.py", workspaceapi.ObjectTypeFile) } diff --git a/integration/internal/acc/fixtures.go b/integration/internal/acc/fixtures.go index ff1949ee6ca..696b302338f 100644 --- a/integration/internal/acc/fixtures.go +++ b/integration/internal/acc/fixtures.go @@ -3,24 +3,28 @@ package acc import ( "context" "fmt" + "net/http" "github.com/databricks/cli/internal/testutil" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/files" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/workspaceapi" + "github.com/databricks/sdk-go/repos/v1" + sdkscim "github.com/databricks/sdk-go/scim/v1" + "github.com/databricks/sdk-go/uc/schemas/v1" + "github.com/databricks/sdk-go/uc/volumes/v1" "github.com/stretchr/testify/require" ) func TemporaryWorkspaceDir(t *WorkspaceT, name ...string) string { ctx := t.ctx - me, err := t.W.CurrentUser.Me(ctx, iam.MeRequest{}) + me, err := t.W.Scim.Me(ctx, sdkscim.MeRequest{}) require.NoError(t, err) // Prefix the name with "integration-test-" to make it easier to identify. name = append([]string{"integration-test-"}, name...) - basePath := fmt.Sprintf("/Users/%s/%s", me.UserName, testutil.RandomName(name...)) + basePath := fmt.Sprintf("/Users/%s/%s", utils.Deref(me.UserName), testutil.RandomName(name...)) t.Logf("Creating workspace directory %s", basePath) err = t.W.Workspace.MkdirsByPath(ctx, basePath) @@ -29,11 +33,11 @@ func TemporaryWorkspaceDir(t *WorkspaceT, name ...string) string { // Remove test directory on test completion. t.Cleanup(func() { t.Logf("Removing workspace directory %s", basePath) - err := t.W.Workspace.Delete(context.WithoutCancel(ctx), workspace.Delete{ + err := t.W.Workspace.Delete(context.WithoutCancel(ctx), workspaceapi.Delete{ Path: basePath, Recursive: true, }) - if err == nil || apierr.IsMissing(err) { + if err == nil || apierrs.IsMissing(err) { return } t.Logf("Unable to remove temporary workspace directory %s: %#v", basePath, err) @@ -50,16 +54,15 @@ func TemporaryDbfsDir(t *WorkspaceT, name ...string) string { path := "/tmp/" + testutil.RandomName(name...) t.Logf("Creating DBFS directory %s", path) - err := t.W.Dbfs.MkdirsByPath(ctx, path) + api, err := apiclient.New(t.W.Config) + require.NoError(t, err) + err = api.Do(ctx, http.MethodPost, "/api/2.0/dbfs/mkdirs", nil, nil, map[string]any{"path": path}, nil) require.NoError(t, err) t.Cleanup(func() { t.Logf("Removing DBFS directory %s", path) - err := t.W.Dbfs.Delete(context.WithoutCancel(ctx), files.Delete{ - Path: path, - Recursive: true, - }) - if err == nil || apierr.IsMissing(err) { + err := api.Do(context.WithoutCancel(ctx), http.MethodPost, "/api/2.0/dbfs/delete", nil, nil, map[string]any{"path": path, "recursive": true}, nil) + if err == nil || apierrs.IsMissing(err) { return } t.Logf("Unable to remove temporary DBFS directory %s: %#v", path, err) @@ -70,26 +73,26 @@ func TemporaryDbfsDir(t *WorkspaceT, name ...string) string { func TemporaryRepo(t *WorkspaceT, url string) string { ctx := t.ctx - me, err := t.W.CurrentUser.Me(ctx, iam.MeRequest{}) + me, err := t.W.Scim.Me(ctx, sdkscim.MeRequest{}) require.NoError(t, err) // Prefix the path with "integration-test-" to make it easier to identify. - path := fmt.Sprintf("/Repos/%s/%s", me.UserName, testutil.RandomName("integration-test-")) + path := fmt.Sprintf("/Repos/%s/%s", utils.Deref(me.UserName), testutil.RandomName("integration-test-")) t.Logf("Creating repo: %s", path) - resp, err := t.W.Repos.Create(ctx, workspace.CreateRepoRequest{ - Url: url, - Path: path, - Provider: "gitHub", + resp, err := t.W.Repos.CreateRepo(ctx, repos.CreateRepoRequest{ + Url: new(url), + Path: new(path), + Provider: new("gitHub"), }) require.NoError(t, err) t.Cleanup(func() { t.Logf("Removing repo: %s", path) - err := t.W.Repos.Delete(context.WithoutCancel(ctx), workspace.DeleteRepoRequest{ - RepoId: resp.Id, + _, err := t.W.Repos.DeleteRepo(context.WithoutCancel(ctx), repos.DeleteRepoRequest{ + Id: resp.Id, }) - if err == nil || apierr.IsMissing(err) { + if err == nil || apierrs.IsMissing(err) { return } t.Logf("Unable to remove repo %s: %#v", path, err) @@ -104,32 +107,32 @@ func TemporaryVolume(t *WorkspaceT) string { w := t.W // Create a schema - schema, err := w.Schemas.Create(ctx, catalog.CreateSchema{ - CatalogName: "main", - Name: testutil.RandomName("test-schema-"), + schema, err := w.Schemas.CreateSchema(ctx, schemas.CreateSchemaRequest{ + CatalogName: new("main"), + Name: new(testutil.RandomName("test-schema-")), }) require.NoError(t, err) t.Cleanup(func() { - err := w.Schemas.Delete(context.WithoutCancel(ctx), catalog.DeleteSchemaRequest{ - FullName: schema.FullName, + _, err := w.Schemas.DeleteSchema(context.WithoutCancel(ctx), schemas.DeleteSchemaRequest{ + FullNameArg: schema.FullName, }) require.NoError(t, err) }) // Create a volume - volume, err := w.Volumes.Create(ctx, catalog.CreateVolumeRequestContent{ - CatalogName: "main", + volume, err := w.Volumes.CreateVolume(ctx, volumes.CreateVolumeRequest{ + CatalogName: new("main"), SchemaName: schema.Name, - Name: "my-volume", - VolumeType: catalog.VolumeTypeManaged, + Name: new("my-volume"), + VolumeType: volumes.VolumeType_Managed, }) require.NoError(t, err) t.Cleanup(func() { - err := w.Volumes.Delete(context.WithoutCancel(ctx), catalog.DeleteVolumeRequest{ - Name: volume.FullName, + _, err := w.Volumes.DeleteVolume(context.WithoutCancel(ctx), volumes.DeleteVolumeRequest{ + FullNameArg: volume.FullName, }) require.NoError(t, err) }) - return fmt.Sprintf("/Volumes/%s/%s/%s", "main", schema.Name, volume.Name) + return fmt.Sprintf("/Volumes/%s/%s/%s", "main", utils.Deref(schema.Name), utils.Deref(volume.Name)) } diff --git a/integration/internal/acc/workspace.go b/integration/internal/acc/workspace.go index 60804509124..17d31f4d42c 100644 --- a/integration/internal/acc/workspace.go +++ b/integration/internal/acc/workspace.go @@ -4,19 +4,17 @@ import ( "context" "github.com/databricks/cli/internal/testutil" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/compute" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/require" ) type WorkspaceT struct { testutil.TestingT - W *databricks.WorkspaceClient + W *sdkclients.Clients ctx context.Context - - exec *compute.CommandExecutorV2 } func WorkspaceTest(t testutil.TestingT) (context.Context, *WorkspaceT) { @@ -25,7 +23,7 @@ func WorkspaceTest(t testutil.TestingT) (context.Context, *WorkspaceT) { t.Logf("CLOUD_ENV=%s", testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")) - w, err := databricks.NewWorkspaceClient() + w, err := sdkclients.New(t.Context(), &config.Config{}) require.NoError(t, err) wt := &WorkspaceT{ @@ -42,30 +40,7 @@ func WorkspaceTest(t testutil.TestingT) (context.Context, *WorkspaceT) { func (t *WorkspaceT) TestClusterID() string { t.Helper() clusterID := testutil.GetEnvOrSkipTest(t, "TEST_BRICKS_CLUSTER_ID") - err := t.W.Clusters.EnsureClusterIsRunning(t.ctx, clusterID) + err := t.W.EnsureClusterIsRunning(t.ctx, clusterID) require.NoError(t, err, "Unexpected error from EnsureClusterIsRunning for clusterID=%s", clusterID) return clusterID } - -func (t *WorkspaceT) RunPython(code string) (string, error) { - t.Helper() - var err error - - // Create command executor only once per test. - if t.exec == nil { - t.exec, err = t.W.CommandExecution.Start(t.ctx, t.TestClusterID(), compute.LanguagePython) - require.NoError(t, err, "Unexpected error from CommandExecution.Start(clusterID=%v)", t.TestClusterID()) - - t.Cleanup(func() { - err := t.exec.Destroy(context.WithoutCancel(t.ctx)) - require.NoError(t, err) - }) - } - - results, err := t.exec.Execute(t.ctx, code) - require.NoError(t, err, "Unexpected error from Execute(%v)", code) - require.NotEqual(t, compute.ResultTypeError, results.ResultType, results.Cause) - output, ok := results.Data.(string) - require.True(t, ok, "unexpected type %T", results.Data) - return output, nil -} diff --git a/integration/libs/filer/helpers_test.go b/integration/libs/filer/helpers_test.go index baca230b791..1eb0dd9d74b 100644 --- a/integration/libs/filer/helpers_test.go +++ b/integration/libs/filer/helpers_test.go @@ -9,9 +9,8 @@ import ( "github.com/databricks/cli/integration/internal/acc" "github.com/databricks/cli/internal/testutil" - "github.com/databricks/cli/libs/filer" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/sdk-go/core/apierr" "github.com/stretchr/testify/require" ) @@ -32,8 +31,8 @@ func setupWsfsFiler(t testutil.TestingT) (filer.Filer, string) { // Check if we can use this API here, skip test if we cannot. _, err = f.Read(ctx, "we_use_this_call_to_test_if_this_api_is_enabled") - if aerr, ok := errors.AsType[*apierr.APIError](err); ok && aerr.StatusCode == http.StatusBadRequest { - t.Skip(aerr.Message) + if aerr, ok := errors.AsType[*apierr.APIError](err); ok && aerr.HTTPStatusCode() == http.StatusBadRequest { + t.Skip(aerr.Message()) } return f, tmpdir diff --git a/integration/libs/sqlexec/sqlexec_test.go b/integration/libs/sqlexec/sqlexec_test.go index a091b437c5f..b7565b54be0 100644 --- a/integration/libs/sqlexec/sqlexec_test.go +++ b/integration/libs/sqlexec/sqlexec_test.go @@ -6,7 +6,7 @@ import ( "github.com/databricks/cli/integration/internal/acc" "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/sqlexec" - "github.com/databricks/databricks-sdk-go/service/sql" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -44,9 +44,9 @@ func TestSQLExecColumnsAndRows(t *testing.T) { func TestSQLExecParameters(t *testing.T) { wt, c := newClient(t) - r, err := c.Execute(wt.Context(), "SELECT :n AS n, :s AS s", sqlexec.WithParameters([]sql.StatementParameterListItem{ - {Name: "n", Type: "INT", Value: "42"}, - {Name: "s", Value: "hello"}, + r, err := c.Execute(wt.Context(), "SELECT :n AS n, :s AS s", sqlexec.WithParameters([]sql.StatementParameter{ + {Name: new("n"), Type: new("INT"), Value: new("42")}, + {Name: new("s"), Value: new("hello")}, })) require.NoError(t, err) assert.Equal(t, [][]string{{"42", "hello"}}, r.Rows) @@ -55,8 +55,8 @@ func TestSQLExecParameters(t *testing.T) { func TestSQLExecNullParameter(t *testing.T) { wt, c := newClient(t) // An empty value is sent as SQL NULL (StatementParameterListItem.Value is omitempty). - got, err := c.ExecuteScalar(wt.Context(), "SELECT :maybe IS NULL", sqlexec.WithParameters([]sql.StatementParameterListItem{ - {Name: "maybe", Value: ""}, + got, err := c.ExecuteScalar(wt.Context(), "SELECT :maybe IS NULL", sqlexec.WithParameters([]sql.StatementParameter{ + {Name: new("maybe"), Value: new("")}, })) require.NoError(t, err) assert.Equal(t, "true", got) @@ -67,7 +67,7 @@ func TestSQLExecFailedStatement(t *testing.T) { _, err := c.Execute(wt.Context(), "SELECT * FROM a_table_that_does_not_exist_zzz") var se *sqlexec.StatementError require.ErrorAs(t, err, &se) - assert.Equal(t, sql.StatementStateFailed, se.State) + assert.Equal(t, sql.StatementStatus_State_Failed, se.State) assert.NotEmpty(t, se.Code) assert.NotEmpty(t, se.Message) // The API populates status.sql_state (SQLSTATE) on failures, e.g. 42P01 for @@ -89,12 +89,12 @@ func TestSQLExecSubmitAndCancel(t *testing.T) { // CANCELED statement or one that finished before the cancel landed. stmt, err = c.Poll(ctx, stmt) require.NoError(t, err) - if stmt.State == sql.StatementStateCanceled { + if stmt.State == sql.StatementStatus_State_Canceled { require.Error(t, stmt.Err()) var se *sqlexec.StatementError require.ErrorAs(t, stmt.Err(), &se) - assert.Equal(t, sql.StatementStateCanceled, se.State) + assert.Equal(t, sql.StatementStatus_State_Canceled, se.State) } else { - assert.Equal(t, sql.StatementStateSucceeded, stmt.State) + assert.Equal(t, sql.StatementStatus_State_Succeeded, stmt.State) } } diff --git a/integration/libs/tags/tags_test.go b/integration/libs/tags/tags_test.go index f5b353fc5fa..e43e373345e 100644 --- a/integration/libs/tags/tags_test.go +++ b/integration/libs/tags/tags_test.go @@ -7,34 +7,36 @@ import ( "github.com/databricks/cli/integration/internal/acc" "github.com/databricks/cli/internal/testutil" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" "github.com/stretchr/testify/require" ) func testTags(t *testing.T, tags map[string]string) error { ctx, wt := acc.WorkspaceTest(t) - resp, err := wt.W.Jobs.Create(ctx, jobs.CreateJob{ - Name: testutil.RandomName("test-tags-"), - Tasks: []jobs.Task{ + req, err := jobs.CreateJobRequestToSDK(&jobs.CreateJobRequest{ + Name: new(testutil.RandomName("test-tags-")), + Tasks: []jobs.TaskSettings{ { - TaskKey: "test", - NewCluster: &compute.ClusterSpec{ - SparkVersion: "13.3.x-scala2.12", - NumWorkers: 1, - NodeTypeId: testutil.GetCloud(t).NodeTypeID(), + TaskKey: new("test"), + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new("13.3.x-scala2.12"), + NumWorkers: new(1), + NodeTypeId: new(testutil.GetCloud(t).NodeTypeID()), }, SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: "/doesnt_exist.py", + PythonFile: new("/doesnt_exist.py"), }, }, }, Tags: tags, }) + require.NoError(t, err) + resp, err := wt.W.Jobs.CreateJob(ctx, *req) if resp != nil { t.Cleanup(func() { - _ = wt.W.Jobs.DeleteByJobId(context.WithoutCancel(ctx), resp.JobId) + _, _ = wt.W.Jobs.DeleteJob(context.WithoutCancel(ctx), sdkjobs.DeleteJobRequest{JobId: resp.JobId}) // Cannot enable errchecking there, tests fail with: // Error: Received unexpected error: // Job 0 does not exist. diff --git a/integration/libs/telemetry/telemetry_test.go b/integration/libs/telemetry/telemetry_test.go index d329c238e56..10071a10192 100644 --- a/integration/libs/telemetry/telemetry_test.go +++ b/integration/libs/telemetry/telemetry_test.go @@ -6,9 +6,9 @@ import ( "time" "github.com/databricks/cli/integration/internal/acc" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/telemetry" "github.com/databricks/cli/libs/telemetry/protos" - "github.com/databricks/databricks-sdk-go/client" "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -18,7 +18,7 @@ func TestTelemetryEndpoint(t *testing.T) { ctx, wt := acc.WorkspaceTest(t) w := wt.W - apiClient, err := client.New(w.Config) + apiClient, err := apiclient.New(w.Config) require.NoError(t, err) logs := []protos.FrontendLog{ diff --git a/integration/python/python_tasks_test.go b/integration/python/python_tasks_test.go index 8862fd5c22a..d1b582ccb8b 100644 --- a/integration/python/python_tasks_test.go +++ b/integration/python/python_tasks_test.go @@ -15,10 +15,10 @@ import ( "github.com/databricks/cli/integration/internal/acc" "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/filer" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/workspaceapi" + "github.com/databricks/sdk-go/options/lro" "github.com/stretchr/testify/require" ) @@ -48,7 +48,7 @@ type testOutput struct { } type testFiles struct { - w *databricks.WorkspaceClient + w *sdkclients.Clients pyNotebookPath string sparkPythonPath string wheelPath string @@ -121,7 +121,7 @@ func runPythonTasks(t *testing.T, tw *testFiles, opts testOpts) { w := tw.w nodeTypeId := testutil.GetCloud(t).NodeTypeID() - var tasks []jobs.SubmitTask + var tasks []jobs.RunTaskSettings if opts.includeNotebookTasks { tasks = append(tasks, GenerateNotebookTasks(tw.pyNotebookPath, sparkVersions, nodeTypeId)...) } @@ -139,16 +139,18 @@ func runPythonTasks(t *testing.T, tw *testFiles, opts testOpts) { } ctx := t.Context() - run, err := w.Jobs.Submit(ctx, jobs.SubmitRun{ - RunName: opts.name, + req, err := jobs.SubmitRunRequestToSDK(&jobs.SubmitRunRequest{ + RunName: new(opts.name), Tasks: tasks, }) require.NoError(t, err) + run, err := w.Jobs.SubmitRun(ctx, *req) + require.NoError(t, err) - _, err = w.Jobs.WaitGetRunJobTerminatedOrSkipped(ctx, run.RunId, time.Hour, nil) + _, err = run.Wait(ctx, lro.WithTimeout(time.Hour)) require.NoError(t, err) - output, err := output.GetJobOutput(ctx, w, run.RunId) + output, err := output.GetJobOutput(ctx, w, run.GetRunId()) require.NoError(t, err) result := make(map[string]testOutput, 0) @@ -179,20 +181,20 @@ func prepareWorkspaceFiles(t *testing.T) *testFiles { baseDir := acc.TemporaryWorkspaceDir(wt, "python-tasks-") pyNotebookPath := path.Join(baseDir, "test.py") - err = w.Workspace.Import(ctx, workspace.Import{ + err = w.Workspace.Import(ctx, workspaceapi.Import{ Path: pyNotebookPath, Overwrite: true, - Language: workspace.LanguagePython, - Format: workspace.ImportFormatSource, + Language: workspaceapi.LanguagePython, + Format: workspaceapi.ImportFormatSource, Content: base64.StdEncoding.EncodeToString([]byte(PY_CONTENT)), }) require.NoError(t, err) sparkPythonPath := path.Join(baseDir, "spark.py") - err = w.Workspace.Import(ctx, workspace.Import{ + err = w.Workspace.Import(ctx, workspaceapi.Import{ Path: sparkPythonPath, Overwrite: true, - Format: workspace.ImportFormatAuto, + Format: workspaceapi.ImportFormatAuto, Content: base64.StdEncoding.EncodeToString([]byte(SPARK_PY_CONTENT)), }) require.NoError(t, err) @@ -201,10 +203,10 @@ func prepareWorkspaceFiles(t *testing.T) *testFiles { require.NoError(t, err) wheelPath := path.Join(baseDir, "my_test_code-0.0.1-py3-none-any.whl") - err = w.Workspace.Import(ctx, workspace.Import{ + err = w.Workspace.Import(ctx, workspaceapi.Import{ Path: path.Join(baseDir, "my_test_code-0.0.1-py3-none-any.whl"), Overwrite: true, - Format: workspace.ImportFormatAuto, + Format: workspaceapi.ImportFormatAuto, Content: base64.StdEncoding.EncodeToString(raw), }) require.NoError(t, err) @@ -262,19 +264,19 @@ func prepareRepoFiles(t *testing.T) *testFiles { } } -func GenerateNotebookTasks(notebookPath string, versions []string, nodeTypeId string) []jobs.SubmitTask { - var tasks []jobs.SubmitTask +func GenerateNotebookTasks(notebookPath string, versions []string, nodeTypeId string) []jobs.RunTaskSettings { + var tasks []jobs.RunTaskSettings for i := range versions { - task := jobs.SubmitTask{ - TaskKey: "notebook_" + strings.ReplaceAll(versions[i], ".", "_"), + task := jobs.RunTaskSettings{ + TaskKey: new("notebook_" + strings.ReplaceAll(versions[i], ".", "_")), NotebookTask: &jobs.NotebookTask{ - NotebookPath: notebookPath, + NotebookPath: new(notebookPath), }, - NewCluster: &compute.ClusterSpec{ - SparkVersion: versions[i], - NumWorkers: 1, - NodeTypeId: nodeTypeId, - DataSecurityMode: compute.DataSecurityModeUserIsolation, + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new(versions[i]), + NumWorkers: new(1), + NodeTypeId: new(nodeTypeId), + DataSecurityMode: jobs.DataSecurityMode_UserIsolation, }, } tasks = append(tasks, task) @@ -283,19 +285,19 @@ func GenerateNotebookTasks(notebookPath string, versions []string, nodeTypeId st return tasks } -func GenerateSparkPythonTasks(notebookPath string, versions []string, nodeTypeId string) []jobs.SubmitTask { - var tasks []jobs.SubmitTask +func GenerateSparkPythonTasks(notebookPath string, versions []string, nodeTypeId string) []jobs.RunTaskSettings { + var tasks []jobs.RunTaskSettings for i := range versions { - task := jobs.SubmitTask{ - TaskKey: "spark_" + strings.ReplaceAll(versions[i], ".", "_"), + task := jobs.RunTaskSettings{ + TaskKey: new("spark_" + strings.ReplaceAll(versions[i], ".", "_")), SparkPythonTask: &jobs.SparkPythonTask{ - PythonFile: notebookPath, + PythonFile: new(notebookPath), }, - NewCluster: &compute.ClusterSpec{ - SparkVersion: versions[i], - NumWorkers: 1, - NodeTypeId: nodeTypeId, - DataSecurityMode: compute.DataSecurityModeUserIsolation, + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new(versions[i]), + NumWorkers: new(1), + NodeTypeId: new(nodeTypeId), + DataSecurityMode: jobs.DataSecurityMode_UserIsolation, }, } tasks = append(tasks, task) @@ -304,23 +306,23 @@ func GenerateSparkPythonTasks(notebookPath string, versions []string, nodeTypeId return tasks } -func GenerateWheelTasks(wheelPath string, versions []string, nodeTypeId string) []jobs.SubmitTask { - var tasks []jobs.SubmitTask +func GenerateWheelTasks(wheelPath string, versions []string, nodeTypeId string) []jobs.RunTaskSettings { + var tasks []jobs.RunTaskSettings for i := range versions { - task := jobs.SubmitTask{ - TaskKey: "whl_" + strings.ReplaceAll(versions[i], ".", "_"), + task := jobs.RunTaskSettings{ + TaskKey: new("whl_" + strings.ReplaceAll(versions[i], ".", "_")), PythonWheelTask: &jobs.PythonWheelTask{ - PackageName: "my_test_code", - EntryPoint: "run", + PackageName: new("my_test_code"), + EntryPoint: new("run"), }, - NewCluster: &compute.ClusterSpec{ - SparkVersion: versions[i], - NumWorkers: 1, - NodeTypeId: nodeTypeId, - DataSecurityMode: compute.DataSecurityModeUserIsolation, + NewCluster: &jobs.ClusterSpec_NewCluster{ + SparkVersion: new(versions[i]), + NumWorkers: new(1), + NodeTypeId: new(nodeTypeId), + DataSecurityMode: jobs.DataSecurityMode_UserIsolation, }, - Libraries: []compute.Library{ - {Whl: wheelPath}, + Libraries: []jobs.Library{ + {Whl: new(wheelPath)}, }, } tasks = append(tasks, task) diff --git a/internal/build/notice_test.go b/internal/build/notice_test.go index abe1d39287d..c9c86aacf02 100644 --- a/internal/build/notice_test.go +++ b/internal/build/notice_test.go @@ -22,10 +22,12 @@ var moduleToGitHub = map[string]string{ // Modules excluded from NOTICE requirements (Databricks-owned). var noticeExclude = map[string]bool{ "github.com/databricks/databricks-sdk-go": true, - "github.com/databricks/sdk-go/core": true, - "github.com/databricks/sdk-go/auth": true, - "github.com/databricks/sdk-go/files": true, - "github.com/databricks/sdk-go/options": true, +} + +// isExcludedFromNotice reports whether module path is a Databricks SDK, which +// is covered by the Databricks notice at the top of NOTICE. +func isExcludedFromNotice(path string) bool { + return noticeExclude[path] || strings.HasPrefix(path, "github.com/databricks/sdk-go/") } // Expected order of license sections in the NOTICE file. @@ -130,7 +132,7 @@ func TestNoticeFileCompleteness(t *testing.T) { // Build expected: license → sorted list of slugs. expected := map[string][]string{} for _, r := range modFile.Require { - if r.Indirect || noticeExclude[r.Mod.Path] { + if r.Indirect || isExcludedFromNotice(r.Mod.Path) { continue } slug := githubSlugFromModule(r.Mod.Path) diff --git a/internal/cligen/bind.go b/internal/cligen/bind.go new file mode 100644 index 00000000000..ffa59623a57 --- /dev/null +++ b/internal/cligen/bind.go @@ -0,0 +1,998 @@ +package main + +import ( + "fmt" + "slices" + "strconv" + "strings" +) + +// MethodBind is the code-level binding of a command to the API: either an +// sdk-go client method with JSON mirror request/response types ("sdk"), or a +// plain REST call through libs/apiclient with untyped JSON ("raw") for +// endpoints sdk-go does not have. +type MethodBind struct { + Kind string + + svc *ServiceJSON + method *MethodJSON + sdk *SdkMethod + pkg *SdkPackage + // pathConsts are literal values for sdk-go path parameters (by position). + pathConsts map[int]string + + // reqVar is the request variable, e.g. "getReq". + reqVar string + // bodyGo is the Go name of the request body field (RequestBodyField). + bodyGo string + // bodyType is the mirror type of the body field without pointer. + bodyType string + bodyPtr bool + + fields map[string]*fieldBind + // direct is set when the request has no mirror type (no JSON body) and + // flags bind to the sdk-go request type itself. + direct bool + + // Raw. + Verb string + + // Legacy (hand-written client with the previous SDK's API). + legacy *legacyPkg + legacyM *legacyMethod +} + +type fieldBind struct { + // expr is the Go expression of the field relative to the request + // variable, e.g. ".Project.DisplayName". Empty when unmapped. + expr string + // kind is one of string, bool, int, int64, float64, enum, time, duration, + // fieldmask, object, complex. + kind string + ptr bool + // enumType is the qualified mirror enum type. + enumType string + // raw: where the value goes ("path", "query", "body"). +} + +func (b *MethodBind) IsSdk() bool { return b.Kind == "sdk" } +func (b *MethodBind) IsRaw() bool { return b.Kind == "raw" } +func (b *MethodBind) IsLegacy() bool { return b.Kind == "legacy" } + +func (b *MethodBind) LegacyCall() string { + return b.client() + "." + b.legacy.clientField + "." + b.legacyM.name +} + +func (b *MethodBind) LegacyKind() string { return b.legacyM.kind } + +func (b *MethodBind) allFields() []*FieldJSON { + all := append([]*FieldJSON{}, b.method.AllFields...) + all = append(all, b.method.RequiredPositionalArguments...) + if b.method.Request != nil { + all = append(all, b.method.Request.RequiredFields...) + } + return all +} + +func (b *MethodBind) client() string { + if b.svc.IsAccounts { + return "a" + } + return "w" +} + +// ClientExpr is the sdk-go client, e.g. "w.Jobs". +func (b *MethodBind) ClientExpr() string { return b.client() + "." + b.pkg.ClientField } + +func (b *MethodBind) SdkMethod() string { return b.sdk.Name } + +// MirrorAlias is the import alias of the mirror package. +func (b *MethodBind) MirrorAlias() string { + if b.pkg == nil { + return "" + } + return b.pkg.MirrorAlias +} + +// HasRequest reports whether the command has a request variable that flags, +// --json and overrides bind to. +func (b *MethodBind) HasRequest() bool { + if b.method.IsLegacyEmptyRequest { + return false + } + if b.IsRaw() { + return true + } + if b.IsLegacy() { + return b.legacyM.request != "" + } + return b.sdk.Request != "" +} + +// ReqType is the request variable's type. +func (b *MethodBind) ReqType() string { + if b.IsRaw() { + return "map[string]any" + } + if b.IsLegacy() { + return b.legacy.alias + "." + b.legacyM.request + } + if b.direct { + return b.pkg.SdkAlias + "." + b.sdk.Request + } + return b.pkg.MirrorAlias + "." + b.sdk.Request +} + +func (b *MethodBind) ReqVar() string { return b.reqVar } + +// ReqInit initializes the request body object, if any. +func (b *MethodBind) ReqInit() string { + if b.IsRaw() { + return b.reqVar + " = map[string]any{}" + } + if b.bodyGo == "" { + return "" + } + amp := "" + if b.bodyPtr { + amp = "&" + } + alias := b.MirrorAlias() + if b.IsLegacy() { + alias = b.legacy.alias + } + return fmt.Sprintf("%s.%s = %s%s.%s{}", b.reqVar, b.bodyGo, amp, alias, b.bodyType) +} + +// JsonTarget is the value --json is unmarshalled into. +func (b *MethodBind) JsonTarget() string { + if !b.IsRaw() && b.bodyGo != "" { + return "&" + b.reqVar + "." + b.bodyGo + } + return "&" + b.reqVar +} + +// SdkReq converts the mirror request into the sdk-go request and binds it to +// sdkReq; empty when the method has no request. +func (b *MethodBind) SdkReq() string { + if b.sdk.Request == "" { + return "" + } + if !b.HasRequest() { + return fmt.Sprintf("sdkReq := &%s.%s{}\n", b.pkg.SdkAlias, b.sdk.Request) + b.pathConstsOn("sdkReq") + } + if b.direct { + return "sdkReq := &" + b.reqVar + } + return fmt.Sprintf(`sdkReq, err := %s.%sToSDK(&%s) + if err != nil { + return err + }`, b.pkg.MirrorAlias, b.sdk.Request, b.reqVar) +} + +// CallArgs are the arguments of the sdk-go call after ctx. +func (b *MethodBind) CallArgs() string { + if b.sdk.Request == "" { + return "" + } + return ", *sdkReq" +} + +// SdkKind is "resp", "err", "iter", "waiter" or "op". +func (b *MethodBind) SdkKind() string { + if b.method.Pagination != nil && b.sdk.Iter != "" { + return "iter" + } + return b.sdk.Kind +} + +func (b *MethodBind) IterMethod() string { return b.sdk.Iter } + +func (b *MethodBind) HasResult() bool { + return b.sdk.Result != "" && b.pkg.structs[b.sdk.Result] != nil +} + +// FromSDK is the converter of the call result (response, wait result or list item). +func (b *MethodBind) FromSDK() string { + t := b.sdk.Result + if b.SdkKind() == "iter" { + t = b.sdk.ItemType + } + return b.pkg.MirrorAlias + "." + t + "FromSDK" +} + +// WaiterIDs renders the identifiers of a waiter, printed by --no-wait, as +// map entries keyed by their JSON names (e.g. "run_id": wait.GetRunId()). +func (b *MethodBind) WaiterIDs() string { + var parts []string + for _, g := range b.sdk.WaiterIDs { + parts = append(parts, fmt.Sprintf("%q: wait.%s()", snakeName(strings.TrimPrefix(g, "Get")), g)) + } + return strings.Join(parts, ", ") +} + +// HasNoWaitCall reports whether --no-wait can send the request directly and +// render the API's immediate response, as the previous SDK's waiters exposed +// it (sdk-go waiters only keep the identifiers). +func (b *MethodBind) HasNoWaitCall() bool { + if b.direct || b.sdk.baseResult == "" || b.pkg.structs[b.sdk.baseResult] == nil || b.sdk.Request == "" { + return false + } + for _, f := range b.sdk.pathFields { + if f == "" || strings.Contains(f, ".") { + return false + } + } + return true +} + +// NoWaitCall sends the request of a waiter method through libs/apiclient and +// decodes the immediate response into `current`. +func (b *MethodBind) NoWaitCall() string { + path := strings.ReplaceAll(b.sdk.path, "{}", "%s") + var args []string + for _, f := range b.sdk.pathFields { + args = append(args, fmt.Sprintf("url.PathEscape(fmt.Sprint(utils.Deref(%s.%s)))", b.reqVar, f)) + } + pathExpr := strconv.Quote(b.sdk.path) + if len(args) > 0 { + pathExpr = fmt.Sprintf("fmt.Sprintf(%q, %s)", path, strings.Join(args, ", ")) + } + body := "nil" + if b.sdk.hasBody { + body = "&" + b.reqVar + if b.sdk.bodyGo != "" { + body = b.reqVar + "." + b.sdk.bodyGo + } + } + query := "nil" + if len(b.sdk.queryFields) > 0 { + var names []string + for name := range b.sdk.queryFields { + names = append(names, name) + } + slices.Sort(names) + var parts []string + for _, name := range names { + parts = append(parts, fmt.Sprintf("%q: %s.%s", name, b.reqVar, b.sdk.queryFields[name])) + } + query = "map[string]any{" + strings.Join(parts, ", ") + "}" + } + return fmt.Sprintf(`api, err := apiclient.New(%s.Config) + if err != nil { + return err + } + var current %s.%s + err = api.Do(ctx, %q, %s, %s, %s, %s, ¤t) + if err != nil { + return err + } + return cmdio.Render(ctx, current)`, b.client(), b.pkg.MirrorAlias, b.sdk.baseResult, b.sdk.verb, pathExpr, b.RawHeaders(), query, body) +} + +// ListItems is the Go field holding the items of a list response, for list +// methods that sdk-go does not page through (no ...Iter method). The previous +// SDK returned these items as a list, which is what the commands render. +func (b *MethodBind) ListItems() string { + if b.method.Pagination == nil || b.sdk.Kind != "resp" || b.sdk.Iter != "" { + return "" + } + st := b.pkg.structs[b.sdk.Result] + if st == nil { + return "" + } + field := "" + for _, f := range st.Fields { + if strings.HasPrefix(f.Type, "[]") && f.Type != "[]byte" { + if field != "" { + return "" + } + field = f.GoName + } + } + return field +} + +// PollCall returns the call fetching the current state of a waiter's +// resource (used by --no-wait), or "" if the poll method is unknown. +func (b *MethodBind) PollCall() string { + pm := b.pollMethod() + if pm == nil { + return "" + } + var fields []string + for _, g := range b.sdk.WaiterIDs { + fields = append(fields, fmt.Sprintf("%s: new(wait.%s())", strings.TrimPrefix(g, "Get"), g)) + } + return fmt.Sprintf("%s.%s(ctx, %s.%s{%s})", b.ClientExpr(), pm.Name, b.pkg.SdkAlias, pm.Request, strings.Join(fields, ", ")) +} + +func (b *MethodBind) PollFromSDK() string { + return b.pkg.MirrorAlias + "." + b.pollMethod().Result + "FromSDK" +} + +func (b *MethodBind) pollMethod() *SdkMethod { + if b.sdk.pollRequest == "" { + return nil + } + var names []string + for name := range b.pkg.methods { + names = append(names, name) + } + slices.Sort(names) + for _, name := range names { + m := b.pkg.methods[name] + if m.Request == b.sdk.pollRequest && m.Kind == "resp" && m.Result == b.sdk.Result && b.pkg.structs[m.Result] != nil { + return m + } + } + return nil +} + +// GetOperation returns the sdk-go method polling the operation of an LRO, if +// there is one with the name cli.json uses. +func (b *MethodBind) GetOperation() string { + lro := b.method.LongRunningOperation + if lro == nil || lro.GetOperation == nil { + return "" + } + if m := b.pkg.methods[lro.GetOperation.PascalName]; m != nil && m.Request != "" && m.Kind == "resp" && b.pkg.structs[m.Result] != nil { + return m.Name + } + return "" +} + +func (b *MethodBind) GetOperationRequest() string { + return b.pkg.SdkAlias + "." + b.pkg.methods[b.GetOperation()].Request +} + +func (b *MethodBind) GetOperationFromSDK() string { + return b.pkg.MirrorAlias + "." + b.pkg.methods[b.GetOperation()].Result + "FromSDK" +} + +// field returns the binding of a cli.json field. +func (b *MethodBind) field(f *FieldJSON) *fieldBind { + if fb, ok := b.fields[f.Name]; ok { + return fb + } + return &fieldBind{} +} + +// Mapped reports whether the field has a Go destination and a flag-able kind. +func (b *MethodBind) Mapped(f *FieldJSON) bool { + fb := b.field(f) + if b.IsRaw() { + return true + } + return fb.expr != "" +} + +func (b *MethodBind) target(f *FieldJSON) string { + return b.reqVar + b.field(f).expr +} + +func rawVar(f *FieldJSON, m *MethodJSON) string { + return m.CamelName() + f.PascalName() + "Raw" +} + +func flagFunc(kind string, ptr bool) string { + name := map[string]string{"string": "String", "bool": "Bool", "int": "Int", "int64": "Int64", "float64": "Float64", "float32": "Float32"}[kind] + if ptr { + return "flags." + name + "PtrVar" + } + return name + "Var" +} + +func rawKind(f *FieldJSON) string { + e := f.Entity + switch { + case e == nil: + return "complex" + case e.IsString: + return "string" + case e.IsBool: + return "bool" + case e.IsInt64: + return "int64" + case e.IsInt: + return "int" + case e.IsFloat64: + return "float64" + case len(e.Enum) > 0: + return "enum" + case e.IsTimestamp: + return "time" + case e.IsDuration: + return "duration" + case e.IsFieldMask: + return "fieldmask" + case e.IsObject: + return "object" + } + return "complex" +} + +func enumValues(f *FieldJSON) string { + var vs []string + for _, e := range f.Entity.Enum { + vs = append(vs, strconv.Quote(e.Content)) + } + return strings.Join(vs, ", ") +} + +// RawDecls declares the variables raw flags are bound to. +func (b *MethodBind) RawDecls() string { + if !b.IsRaw() { + return "" + } + var sb strings.Builder + seen := map[string]bool{} + for _, f := range b.method.AllFields { + if seen[f.Name] { + continue + } + seen[f.Name] = true + k := rawKind(f) + goType := map[string]string{"string": "string", "bool": "bool", "int": "int", "int64": "int64", "float64": "float64", "enum": "string"}[k] + if goType == "" { + continue + } + fmt.Fprintf(&sb, "var %s %s\n", rawVar(f, b.method), goType) + } + return sb.String() +} + +// FlagDef returns the statement registering a flag for field f. +func (b *MethodBind) FlagDef(f *FieldJSON, name, usage string) string { + usage = "`" + usage + "`" + if b.IsRaw() { + k := rawKind(f) + v := rawVar(f, b.method) + switch k { + case "string", "bool", "int", "int64", "float64": + return fmt.Sprintf("cmd.Flags().%s(&%s, %q, %s, %s)", flagFunc(k, false), v, name, v, usage) + case "enum": + return fmt.Sprintf("flags.EnumVar(cmd.Flags(), &%s, %q, %s, %q, %s)", v, name, usage, f.Entity.PascalName, enumValues(f)) + } + return "// TODO: complex arg: " + f.Name + } + fb := b.field(f) + if fb.expr == "" { + return "// TODO: field not in sdk-go request: " + f.Name + } + t := b.target(f) + switch fb.kind { + case "string", "bool", "int", "int64", "float64", "float32": + if fb.kind == "string" && f.Entity != nil && len(f.Entity.Enum) > 0 && fb.ptr { + return fmt.Sprintf("flags.EnumPtrVar(cmd.Flags(), &%s, %q, %s, %q, %s)", t, name, usage, f.Entity.PascalName, enumValues(f)) + } + if fb.ptr { + return fmt.Sprintf("%s(cmd.Flags(), &%s, %q, %s)", flagFunc(fb.kind, true), t, name, usage) + } + return fmt.Sprintf("cmd.Flags().%s(&%s, %q, %s, %s)", flagFunc(fb.kind, false), t, name, t, usage) + case "legacyenum": + return fmt.Sprintf("cmd.Flags().Var(&%s, %q, %s)", t, name, usage) + case "bytes": + return fmt.Sprintf("flags.Base64Var(cmd.Flags(), &%s, %q, %s)", t, name, usage) + case "time", "duration": + // cli.json describes the field as a plain string; parse it the way the + // API's JSON encodes it. + return fmt.Sprintf("flags.JSONStringPtrVar(cmd.Flags(), &%s, %q, %s)", t, name, usage) + case "enum": + typ := f.Entity.PascalName + if typ == "" { + typ = fb.enumType[strings.Index(fb.enumType, ".")+1:] + } + vals := "" + if f.Entity != nil && len(f.Entity.Enum) > 0 { + vals = ", " + enumValues(f) + } + if fb.ptr { + return fmt.Sprintf("flags.EnumPtrVar(cmd.Flags(), &%s, %q, %s, %q%s)", t, name, usage, typ, vals) + } + return fmt.Sprintf("flags.EnumVar(cmd.Flags(), &%s, %q, %s, %q%s)", t, name, usage, typ, vals) + } + return "// TODO: complex arg: " + f.Name +} + +// ArgScan assigns positional argument src (e.g. "args[0]") to field f. +func (b *MethodBind) ArgScan(f *FieldJSON, src string) string { + if b.IsRaw() { + v := rawVar(f, b.method) + switch k := rawKind(f); k { + case "string", "enum": + return fmt.Sprintf("%s = %s", v, src) + case "bool", "int", "int64", "float64": + return fmt.Sprintf(`_, err = fmt.Sscan(%s, &%s) + if err != nil { + return fmt.Errorf("invalid %s: %%s", %s) + }`, src, v, f.ConstantName(), src) + case "time", "duration", "fieldmask": + return b.WellKnown(f, src) + } + return fmt.Sprintf("%s[%q] = %s", b.reqVar, f.Name, src) + } + fb := b.field(f) + if fb.expr == "" { + return "_ = " + src + " // TODO: field not in sdk-go request: " + f.Name + } + t := b.target(f) + switch fb.kind { + case "string": + if fb.ptr { + return fmt.Sprintf("%s = new(%s)", t, src) + } + return fmt.Sprintf("%s = %s", t, src) + case "enum": + if fb.ptr { + return fmt.Sprintf("%s = new(%s(%s))", t, fb.enumType, src) + } + return fmt.Sprintf("%s = %s(%s)", t, fb.enumType, src) + case "legacyenum": + return fmt.Sprintf(`_, err = fmt.Sscan(%s, &%s) + if err != nil { + return fmt.Errorf("invalid %s: %%s", %s) + }`, src, t, f.ConstantName(), src) + case "bool", "int", "int64", "float64": + v := b.method.CamelName() + f.PascalName() + "Arg" + assign := v + if fb.ptr { + assign = "&" + v + } + return fmt.Sprintf(`var %s %s + _, err = fmt.Sscan(%s, &%s) + if err != nil { + return fmt.Errorf("invalid %s: %%s", %s) + } + %s = %s`, v, fb.kind, src, v, f.ConstantName(), src, t, assign) + case "time", "duration", "fieldmask": + return b.WellKnown(f, src) + } + return "_ = " + src + " // TODO: complex arg: " + f.Name +} + +// WellKnown parses a timestamp, duration or field mask string src into f. +func (b *MethodBind) WellKnown(f *FieldJSON, src string) string { + if b.IsRaw() { + return fmt.Sprintf("%s[%q] = %s", b.reqVar, f.Name, src) + } + fb := b.field(f) + if fb.expr == "" { + return "_ = " + src + } + t := b.target(f) + switch fb.kind { + case "fieldmask", "string": + if fb.ptr { + return fmt.Sprintf("%s = new(%s)", t, src) + } + return fmt.Sprintf("%s = %s", t, src) + case "time", "duration": + typ := "sdkcoretypes.Time" + if fb.kind == "duration" { + typ = "sdkcoretypes.Duration" + } + v := f.CamelName() + "Field" + amp := "&" + if !fb.ptr { + amp = "" + } + return fmt.Sprintf(`var %s %s + err = json.Unmarshal([]byte(strconv.Quote(%s)), &%s) + if err != nil { + return fmt.Errorf("invalid %s: %%s", %s) + } + %s = %s%s`, v, typ, src, v, f.ConstantName(), src, t, amp, v) + } + return "_ = " + src +} + +// RawAssemble moves flag values that were set into the raw request and +// computes the path and query parameters. +func (b *MethodBind) RawAssemble() string { + var sb strings.Builder + if !b.HasRequest() { + fmt.Fprintf(&sb, "%s := map[string]any{}\n", b.reqVar) + } + sb.WriteString("rawQuery := map[string]any{}\n") + for _, f := range b.method.AllFields { + k := rawKind(f) + v := rawVar(f, b.method) + loc := "body" + if f.IsQuery { + loc = "query" + } + if f.IsPath { + continue + } + switch k { + case "string", "bool", "int", "int64", "float64", "enum": + dst := b.reqVar + if loc == "query" { + dst = "rawQuery" + } + fmt.Fprintf(&sb, "if cmd.Flags().Changed(%q) || %s != %s {\n%s[%q] = %s\n}\n", f.KebabName(), v, zeroOf(k), dst, f.Name, v) + } + } + // Path. + params := pathParams(b.method.Path) + byName := map[string]*FieldJSON{} + for _, f := range b.method.AllFields { + byName[f.Name] = f + } + path := pathParamRe.ReplaceAllString(b.method.Path, "%s") + var args []string + for _, p := range params { + if p == "account_id" { + args = append(args, b.client()+".Config.AccountID") + continue + } + f := byName[p] + if f == nil { + args = append(args, `""`) + continue + } + args = append(args, fmt.Sprintf("fmt.Sprint(%s)", rawVar(f, b.method))) + } + if len(args) == 0 { + fmt.Fprintf(&sb, "rawPath := %q\n", b.method.Path) + } else { + fmt.Fprintf(&sb, "rawPath := fmt.Sprintf(%q, %s)\n", path, strings.Join(args, ", ")) + } + return sb.String() +} + +func zeroOf(k string) string { + switch k { + case "bool": + return "false" + case "string", "enum": + return `""` + } + return "0" +} + +// RawBody is the request body argument of the raw call. +func (b *MethodBind) RawBody() string { + switch b.Verb { + case "GET", "DELETE", "HEAD": + return "nil" + } + return b.reqVar +} + +// RawQuery merges body fields into the query for verbs without a body. +func (b *MethodBind) RawQuery() string { + switch b.Verb { + case "GET", "DELETE", "HEAD": + return "maps.Copy(rawQuery, " + b.reqVar + ")" + } + return "" +} + +func (b *MethodBind) RawHeaders() string { + if b.svc.IsAccounts { + return "nil" + } + return "auth.WorkspaceIDHeaders(w.Config)" +} + +// bindAll computes the binding of every method. +func bindAll(batch *CommandsBlock, idx *sdkIndex, legacy map[string]*legacyPkg) error { + for _, s := range batch.Services { + for _, m := range s.Methods { + b := &MethodBind{svc: s, method: m, reqVar: m.CamelName() + "Req", fields: map[string]*fieldBind{}} + m.Bind = b + if lp := legacy[s.Name]; lp != nil && b.bindLegacy(lp) { + continue + } + sm, consts := idx.match(s, m) + if sm == nil { + b.Kind = "raw" + b.Verb = methodVerb(s, m) + if b.Verb == "" { + if strings.HasPrefix(m.Name, "List") || strings.HasPrefix(m.Name, "Get") { + b.Verb = "GET" + } else { + return fmt.Errorf("%s.%s: no sdk-go method and no HTTP verb", s.Name, m.Name) + } + } + debugf("RAW %s.%s %s %s\n", s.Name, m.Name, b.Verb, m.Path) + continue + } + b.Kind = "sdk" + b.sdk = sm + b.pkg = sm.Pkg + b.pathConsts = consts + b.bindFields() + } + } + return nil +} + +func (b *MethodBind) bindFields() { + req := b.pkg.structs[b.sdk.Request] + if req == nil { + model := b.pkg.models[b.sdk.Request] + if model == nil { + return + } + b.direct = true + req = &MirrorStruct{Fields: model.Fields, byJSON: map[string]*MirrorField{}} + for name, goName := range b.sdk.queryFields { + for _, f := range model.Fields { + if f.GoName == goName { + req.byJSON[name] = f + } + } + } + } + var body *MirrorStruct + if rb := b.method.RequestBodyField; rb != nil { + if bf := req.byJSON[rb.Name]; bf != nil { + b.bodyGo = bf.GoName + b.bodyPtr = strings.HasPrefix(bf.Type, "*") + b.bodyType = strings.TrimPrefix(bf.Type, "*") + body = b.pkg.structs[b.bodyType] + } + } + // Path parameters by position. + cliParams := pathParams(b.method.Path) + pathGo := map[string]string{} + // sdk-go path parameters line up with cli.json ones, except that a + // literal segment of the cli.json path may fill an sdk-go parameter + // (pathConsts) and the account ID is implicit in sdk-go (field ""). + j := 0 + for i, sf := range b.sdk.pathFields { + if _, isConst := b.pathConsts[i]; isConst { + continue + } + for j < len(cliParams) && cliParams[j] == "account_id" && sf != "" { + j++ + } + if j >= len(cliParams) { + break + } + if sf != "" { + pathGo[cliParams[j]] = sf + } + j++ + } + for _, f := range b.allFields() { + if _, ok := b.fields[f.Name]; ok { + continue + } + fb := &fieldBind{} + b.fields[f.Name] = fb + var mf *MirrorField + var prefix string + if goPath, ok := pathGo[f.Name]; ok && f.IsPath { + mf, prefix = b.resolveGoPath(req, goPath) + } + if mf == nil && body != nil && !f.IsPath && !f.IsQuery { + if mf = body.byJSON[f.Name]; mf != nil { + prefix = "." + b.bodyGo + } + } + if mf == nil { + mf = req.byJSON[f.Name] + } + if mf == nil && body != nil { + if mf = body.byJSON[f.Name]; mf != nil { + prefix = "." + b.bodyGo + } + } + if mf == nil { + debugf("UNMAPPED %s.%s field %s\n", b.svc.Name, b.method.Name, f.Name) + continue + } + fb.expr = prefix + "." + mf.GoName + fb.ptr = strings.HasPrefix(mf.Type, "*") + base := strings.TrimPrefix(mf.Type, "*") + switch { + case base == "string" || base == "bool" || base == "int" || base == "int64" || base == "float64" || base == "float32": + fb.kind = base + if f.Entity != nil && f.Entity.IsFieldMask { + fb.kind = "fieldmask" + } + case base == "[]byte": + fb.kind = "bytes" + case base == "types.Time": + fb.kind = "time" + case base == "types.Duration": + fb.kind = "duration" + case strings.HasPrefix(base, "[]") || strings.HasPrefix(base, "map[") || strings.Contains(base, "."): + fb.kind = "complex" + case b.pkg.structs[base] != nil: + fb.kind = "object" + default: + fb.kind = "enum" + fb.enumType = b.pkg.MirrorAlias + "." + base + if b.direct { + fb.enumType = b.pkg.SdkAlias + "." + base + } + } + } +} + +// resolveGoPath follows a dotted Go field path ("Project.Name") from the +// request struct, returning the leaf field and the expression prefix. +func (b *MethodBind) resolveGoPath(req *MirrorStruct, goPath string) (*MirrorField, string) { + parts := strings.Split(goPath, ".") + cur := req + prefix := "" + for i, p := range parts { + var found *MirrorField + for _, f := range cur.Fields { + if f.GoName == p { + found = f + } + } + if found == nil { + return nil, "" + } + if i == len(parts)-1 { + return found, prefix + } + prefix += "." + p + cur = b.pkg.structs[strings.TrimPrefix(found.Type, "*")] + if cur == nil { + return nil, "" + } + } + return nil, "" +} + +// PathConsts assigns literal path parameter values (e.g. the object type of +// the typed permission endpoints) to the request. +func (b *MethodBind) PathConsts() string { + if !b.HasRequest() { + return "" + } + return b.pathConstsOn(b.reqVar) +} + +func (b *MethodBind) pathConstsOn(v string) string { + if len(b.pathConsts) == 0 { + return "" + } + var keys []int + for k := range b.pathConsts { + keys = append(keys, k) + } + slices.Sort(keys) + var sb strings.Builder + for _, k := range keys { + if k >= len(b.sdk.pathFields) || b.sdk.pathFields[k] == "" { + continue + } + fmt.Fprintf(&sb, "%s.%s = new(%q)\n", v, b.sdk.pathFields[k], b.pathConsts[k]) + } + return sb.String() +} + +// NamedIdMap returns the expression collecting the name to id map for the +// interactive prompt of service s, or "" if it cannot be derived. +func (s *ServiceJSON) NamedIdMapCall() string { + if s.List == nil || s.List.NamedIdMap == nil { + return "" + } + var list *MethodJSON + for _, m := range s.Methods { + if m.Name == "List" && list == nil { + list = m + } + // The service names its list method by request type when it is not + // called List (e.g. Pipelines.ListPipelines). + if s.List.Request != nil && m.Request != nil && m.Request.PascalName == s.List.Request.PascalName { + list = m + break + } + } + if list == nil || list.Bind == nil || !list.Bind.IsSdk() || list.Bind.sdk.Iter == "" { + return "" + } + b := list.Bind + item := b.pkg.structs[b.sdk.ItemType] + if item == nil { + return "" + } + name := strings.TrimSuffix(s.List.NamedIdMap.PascalName, "Map") + before, after, ok := strings.CutLast(name, "To") + if !ok { + return "" + } + left, right := before, after + namePath := b.findPath(item, left, true) + idPath := b.findPath(item, right, false) + if namePath == nil || idPath == nil { + return "" + } + req := "" + if b.sdk.Request != "" { + req = ", " + b.pkg.SdkAlias + "." + b.sdk.Request + "{}" + } + q := func(p []string) string { + var out []string + for _, x := range p { + out = append(out, strconv.Quote(x)) + } + return "[]string{" + strings.Join(out, ", ") + "}" + } + return fmt.Sprintf("cmdgen.NamedIdMap(ctx, %s.%s.%s(ctx%s), %s, %s)", b.client(), b.pkg.ClientField, b.sdk.Iter, req, q(namePath), q(idPath)) +} + +// findPath finds a Go field path in st whose concatenated names equal s +// (exactly, or as a suffix when allowPrefix is set, to skip the old type name). +func (b *MethodBind) findPath(st *MirrorStruct, s string, allowPrefix bool) []string { + for start := 0; start < len(s); start++ { + if start > 0 && !allowPrefix { + break + } + if s[start] < 'A' || s[start] > 'Z' { + continue + } + if p := b.walkPath(st, s[start:], 0); p != nil { + return p + } + } + return nil +} + +func (b *MethodBind) walkPath(st *MirrorStruct, s string, depth int) []string { + if st == nil || depth > 2 { + return nil + } + for _, f := range st.Fields { + if !strings.HasPrefix(s, f.GoName) { + continue + } + rest := s[len(f.GoName):] + if rest == "" { + return []string{f.GoName} + } + if p := b.walkPath(b.pkg.structs[strings.TrimPrefix(f.Type, "*")], rest, depth+1); p != nil { + return append([]string{f.GoName}, p...) + } + } + return nil +} + +// Imports of a service file: mirror and sdk-go packages used by its methods. +func (s *ServiceJSON) BindImports() []string { + seen := map[string]bool{} + var out []string + for _, m := range s.Methods { + if m.Bind != nil && m.Bind.IsLegacy() { + imp := fmt.Sprintf("%s %q", m.Bind.legacy.alias, m.Bind.legacy.importPath) + if !seen[imp] { + seen[imp] = true + out = append(out, imp) + } + } + if m.Bind == nil || !m.Bind.IsSdk() { + continue + } + p := m.Bind.pkg + for _, imp := range []string{ + fmt.Sprintf("%s %q", p.MirrorAlias, p.MirrorPath), + fmt.Sprintf("%s %q", p.SdkAlias, p.ImportPath), + } { + if !seen[imp] { + seen[imp] = true + out = append(out, imp) + } + } + } + slices.Sort(out) + return out +} + +// HasWaitResult is false for waits and calls that produce nothing. +func (b *MethodBind) HasWaitResult() bool { + switch b.sdk.Kind { + case "waiter", "op": + return b.sdk.Result != "" + } + return true +} diff --git a/internal/cligen/cli_json_test.go b/internal/cligen/cli_json_test.go index 2aeec36e2d9..7f44564e8b4 100644 --- a/internal/cligen/cli_json_test.go +++ b/internal/cligen/cli_json_test.go @@ -112,6 +112,18 @@ func TestCliJSONIsInterpretable(t *testing.T) { } } + idx, err := loadSdkIndex("../..") + if err != nil { + t.Fatal(err) + } + legacy, err := loadLegacy("../..") + if err != nil { + t.Fatal(err) + } + if err := bindAll(cmds, idx, legacy); err != nil { + t.Fatal(err) + } + // --- interpretation proof: every file renders to valid Go --- serviceTmpl := parseTemplate("service", "templates/service.go.tmpl") rendered := 0 diff --git a/internal/cligen/cligen.go b/internal/cligen/cligen.go index 200392f8b68..6e0dd59a457 100644 --- a/internal/cligen/cligen.go +++ b/internal/cligen/cligen.go @@ -71,6 +71,17 @@ func Generate(jsonPath, targetDir string) ([]string, error) { if err := batch.Resolve(); err != nil { return nil, fmt.Errorf("%s: %w", jsonPath, err) } + idx, err := loadSdkIndex(targetDir) + if err != nil { + return nil, err + } + legacy, err := loadLegacy(targetDir) + if err != nil { + return nil, err + } + if err := bindAll(batch, idx, legacy); err != nil { + return nil, err + } var filenames []string diff --git a/internal/cligen/format_test.go b/internal/cligen/format_test.go index 4d946074903..ede270e0425 100644 --- a/internal/cligen/format_test.go +++ b/internal/cligen/format_test.go @@ -121,7 +121,7 @@ func TestImportName(t *testing.T) { import ( "encoding/json" "github.com/databricks/cli/libs/cmdio" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" + sdkcoretypes "github.com/databricks/sdk-go/core/types" ) ` fset := token.NewFileSet() @@ -129,7 +129,7 @@ import ( if err != nil { t.Fatal(err) } - want := []string{"json", "cmdio", "sdktime"} + want := []string{"json", "cmdio", "sdkcoretypes"} for i, imp := range f.Imports { if got := importName(imp); got != want[i] { t.Errorf("importName(%s) = %q, want %q", imp.Path.Value, got, want[i]) diff --git a/internal/cligen/http_verbs.json b/internal/cligen/http_verbs.json new file mode 100644 index 00000000000..eb8b9f2f499 --- /dev/null +++ b/internal/cligen/http_verbs.json @@ -0,0 +1,1357 @@ +{ +"agentbricks.agentbricks.CancelOptimize": "POST", +"agentbricks.agentbricks.CreateCustomLlm": "POST", +"agentbricks.agentbricks.DeleteCustomLlm": "DELETE", +"agentbricks.agentbricks.GetCustomLlm": "GET", +"agentbricks.agentbricks.StartOptimize": "POST", +"agentbricks.agentbricks.UpdateCustomLlm": "PATCH", +"agentkit.agentkit.AppendSessionItems": "POST", +"agentkit.agentkit.ClearSessionItems": "POST", +"agentkit.agentkit.CreateMemory": "POST", +"agentkit.agentkit.CreateMemoryStore": "POST", +"agentkit.agentkit.CreateSession": "POST", +"agentkit.agentkit.CreateSessionStore": "POST", +"agentkit.agentkit.DeleteMemory": "DELETE", +"agentkit.agentkit.DeleteMemoryStore": "DELETE", +"agentkit.agentkit.DeleteSession": "DELETE", +"agentkit.agentkit.DeleteSessionStore": "DELETE", +"agentkit.agentkit.ExtractMemories": "POST", +"agentkit.agentkit.ForkSession": "POST", +"agentkit.agentkit.GetMemory": "GET", +"agentkit.agentkit.GetMemoryStore": "GET", +"agentkit.agentkit.GetSession": "GET", +"agentkit.agentkit.GetSessionStore": "GET", +"agentkit.agentkit.PopSessionItem": "POST", +"agentkit.agentkit.UpdateMemory": "PATCH", +"agentkit.agentkit.UpdateMemoryStore": "PATCH", +"agentkit.agentkit.UpdateSession": "PATCH", +"agentkit.agentkit.UpdateSessionStore": "PATCH", +"agentkit.agentkit.internalListMemories": "GET", +"agentkit.agentkit.internalListMemoryStores": "GET", +"agentkit.agentkit.internalListSessionItems": "GET", +"agentkit.agentkit.internalListSessionStores": "GET", +"agentkit.agentkit.internalListSessions": "GET", +"agentkit.agentkit.internalSearchMemories": "POST", +"aifunctions.aifunctions.AiClassify": "POST", +"aifunctions.aifunctions.AiDecide": "POST", +"aifunctions.aifunctions.AiExtract": "POST", +"aifunctions.aifunctions.AiParseDocument": "POST", +"aisearch.aisearch.CreateEndpoint": "POST", +"aisearch.aisearch.CreateIndex": "POST", +"aisearch.aisearch.DeleteEndpoint": "DELETE", +"aisearch.aisearch.DeleteIndex": "DELETE", +"aisearch.aisearch.GetEndpoint": "GET", +"aisearch.aisearch.GetIndex": "GET", +"aisearch.aisearch.QueryIndex": "POST", +"aisearch.aisearch.RemoveData": "POST", +"aisearch.aisearch.ScanIndex": "POST", +"aisearch.aisearch.SyncIndex": "POST", +"aisearch.aisearch.UpdateEndpoint": "PATCH", +"aisearch.aisearch.UpsertData": "POST", +"aisearch.aisearch.internalListEndpoints": "GET", +"aisearch.aisearch.internalListIndexes": "GET", +"apps.apps.Create": "POST", +"apps.apps.CreateSpace": "POST", +"apps.apps.CreateUpdate": "POST", +"apps.apps.Delete": "DELETE", +"apps.apps.DeleteAppThumbnail": "DELETE", +"apps.apps.DeleteSpace": "DELETE", +"apps.apps.Deploy": "POST", +"apps.apps.Get": "GET", +"apps.apps.GetDeployment": "GET", +"apps.apps.GetPermissionLevels": "GET", +"apps.apps.GetPermissions": "GET", +"apps.apps.GetSpace": "GET", +"apps.apps.GetSpaceOperation": "GET", +"apps.apps.GetUpdate": "GET", +"apps.apps.SetPermissions": "PUT", +"apps.apps.Start": "POST", +"apps.apps.Stop": "POST", +"apps.apps.Update": "PATCH", +"apps.apps.UpdateAppThumbnail": "PATCH", +"apps.apps.UpdatePermissions": "PATCH", +"apps.apps.UpdateSpace": "PATCH", +"apps.apps.internalList": "GET", +"apps.apps.internalListDeployments": "GET", +"apps.apps.internalListSpaces": "GET", +"apps.appssettings.CreateCustomTemplate": "POST", +"apps.appssettings.DeleteCustomTemplate": "DELETE", +"apps.appssettings.GetCustomTemplate": "GET", +"apps.appssettings.UpdateCustomTemplate": "PUT", +"apps.appssettings.internalListCustomTemplates": "GET", +"billing.billableusage.Download": "GET", +"billing.budgetpolicy.Create": "POST", +"billing.budgetpolicy.Delete": "DELETE", +"billing.budgetpolicy.Get": "GET", +"billing.budgetpolicy.Update": "PATCH", +"billing.budgetpolicy.internalList": "GET", +"billing.budgets.Create": "POST", +"billing.budgets.Delete": "DELETE", +"billing.budgets.Get": "GET", +"billing.budgets.Update": "PUT", +"billing.budgets.internalList": "GET", +"billing.logdelivery.Create": "POST", +"billing.logdelivery.Get": "GET", +"billing.logdelivery.PatchStatus": "PATCH", +"billing.logdelivery.internalList": "GET", +"billing.usagedashboards.Create": "POST", +"billing.usagedashboards.Get": "GET", +"bundle.bundle.CompleteVersion": "POST", +"bundle.bundle.CreateDeployment": "POST", +"bundle.bundle.CreateOperation": "POST", +"bundle.bundle.CreateVersion": "POST", +"bundle.bundle.DeleteDeployment": "DELETE", +"bundle.bundle.GetDeployment": "GET", +"bundle.bundle.GetOperation": "GET", +"bundle.bundle.GetResource": "GET", +"bundle.bundle.GetVersion": "GET", +"bundle.bundle.Heartbeat": "POST", +"bundle.bundle.internalListDeployments": "GET", +"bundle.bundle.internalListOperations": "GET", +"bundle.bundle.internalListResources": "GET", +"bundle.bundle.internalListVersions": "GET", +"bundledeployments.bundledeployments.CompleteVersion": "POST", +"bundledeployments.bundledeployments.CreateDeployment": "POST", +"bundledeployments.bundledeployments.CreateVersion": "POST", +"bundledeployments.bundledeployments.DeleteDeployment": "DELETE", +"bundledeployments.bundledeployments.GetDeployment": "GET", +"bundledeployments.bundledeployments.GetOperation": "GET", +"bundledeployments.bundledeployments.GetResource": "GET", +"bundledeployments.bundledeployments.GetVersion": "GET", +"bundledeployments.bundledeployments.Heartbeat": "POST", +"bundledeployments.bundledeployments.UpdateDeployment": "PATCH", +"bundledeployments.bundledeployments.UpdateOperation": "PATCH", +"bundledeployments.bundledeployments.internalListDeployments": "GET", +"bundledeployments.bundledeployments.internalListOperations": "GET", +"bundledeployments.bundledeployments.internalListResources": "GET", +"bundledeployments.bundledeployments.internalListVersions": "GET", +"catalog.accountmetastoreassignments.Create": "POST", +"catalog.accountmetastoreassignments.Delete": "DELETE", +"catalog.accountmetastoreassignments.Get": "GET", +"catalog.accountmetastoreassignments.Update": "PUT", +"catalog.accountmetastoreassignments.internalList": "GET", +"catalog.accountmetastores.Create": "POST", +"catalog.accountmetastores.Delete": "DELETE", +"catalog.accountmetastores.Get": "GET", +"catalog.accountmetastores.Update": "PUT", +"catalog.accountmetastores.internalList": "GET", +"catalog.accountstoragecredentials.Create": "POST", +"catalog.accountstoragecredentials.Delete": "DELETE", +"catalog.accountstoragecredentials.Get": "GET", +"catalog.accountstoragecredentials.Update": "PUT", +"catalog.accountstoragecredentials.internalList": "GET", +"catalog.aigateway.CreateMcpService": "POST", +"catalog.aigateway.CreateMcpServiceUserMappedCredential": "POST", +"catalog.aigateway.CreateModelProviderService": "POST", +"catalog.aigateway.CreateModelService": "POST", +"catalog.aigateway.CreateSkill": "POST", +"catalog.aigateway.DeleteMcpService": "DELETE", +"catalog.aigateway.DeleteMcpServiceUserMappedCredential": "DELETE", +"catalog.aigateway.DeleteModelProviderService": "DELETE", +"catalog.aigateway.DeleteModelService": "DELETE", +"catalog.aigateway.DeleteSkill": "DELETE", +"catalog.aigateway.FinalizeSkill": "POST", +"catalog.aigateway.GetMcpService": "GET", +"catalog.aigateway.GetMcpServiceUserMappedCredential": "GET", +"catalog.aigateway.GetModelProviderService": "GET", +"catalog.aigateway.GetModelService": "GET", +"catalog.aigateway.GetSkill": "GET", +"catalog.aigateway.UpdateMcpService": "PATCH", +"catalog.aigateway.UpdateModelProviderService": "PATCH", +"catalog.aigateway.UpdateModelService": "PATCH", +"catalog.aigateway.UpdateSkill": "PATCH", +"catalog.aigateway.internalListMcpServices": "GET", +"catalog.aigateway.internalListModelProviderServices": "GET", +"catalog.aigateway.internalListModelServices": "GET", +"catalog.aigateway.internalListSkills": "GET", +"catalog.artifactallowlists.Get": "GET", +"catalog.artifactallowlists.Update": "PUT", +"catalog.catalogs.Create": "POST", +"catalog.catalogs.Delete": "DELETE", +"catalog.catalogs.Get": "GET", +"catalog.catalogs.Update": "PATCH", +"catalog.catalogs.internalList": "GET", +"catalog.connections.Create": "POST", +"catalog.connections.Delete": "DELETE", +"catalog.connections.Get": "GET", +"catalog.connections.Update": "PATCH", +"catalog.connections.internalList": "GET", +"catalog.credentials.CreateCredential": "POST", +"catalog.credentials.DeleteCredential": "DELETE", +"catalog.credentials.GenerateTemporaryServiceCredential": "POST", +"catalog.credentials.GetCredential": "GET", +"catalog.credentials.UpdateCredential": "PATCH", +"catalog.credentials.ValidateCredential": "POST", +"catalog.credentials.internalListCredentials": "GET", +"catalog.entitytagassignments.Create": "POST", +"catalog.entitytagassignments.Delete": "DELETE", +"catalog.entitytagassignments.Get": "GET", +"catalog.entitytagassignments.Update": "PATCH", +"catalog.entitytagassignments.internalList": "GET", +"catalog.externallineage.CreateExternalLineageRelationship": "POST", +"catalog.externallineage.DeleteExternalLineageRelationship": "DELETE", +"catalog.externallineage.UpdateExternalLineageRelationship": "PATCH", +"catalog.externallineage.internalListExternalLineageRelationships": "GET", +"catalog.externallocations.Create": "POST", +"catalog.externallocations.Delete": "DELETE", +"catalog.externallocations.Get": "GET", +"catalog.externallocations.Update": "PATCH", +"catalog.externallocations.internalList": "GET", +"catalog.externalmetadata.CreateExternalMetadata": "POST", +"catalog.externalmetadata.DeleteExternalMetadata": "DELETE", +"catalog.externalmetadata.GetExternalMetadata": "GET", +"catalog.externalmetadata.UpdateExternalMetadata": "PATCH", +"catalog.externalmetadata.internalListExternalMetadata": "GET", +"catalog.functions.Create": "POST", +"catalog.functions.Delete": "DELETE", +"catalog.functions.Get": "GET", +"catalog.functions.Update": "PATCH", +"catalog.functions.internalList": "GET", +"catalog.grants.Get": "GET", +"catalog.grants.GetEffective": "GET", +"catalog.grants.Update": "PATCH", +"catalog.grants.internalList": "GET", +"catalog.grants.internalListEffective": "GET", +"catalog.metastores.Assign": "PUT", +"catalog.metastores.Create": "POST", +"catalog.metastores.Current": "GET", +"catalog.metastores.Delete": "DELETE", +"catalog.metastores.Get": "GET", +"catalog.metastores.Summary": "GET", +"catalog.metastores.Unassign": "DELETE", +"catalog.metastores.Update": "PATCH", +"catalog.metastores.UpdateAssignment": "PATCH", +"catalog.metastores.internalList": "GET", +"catalog.modelversions.Delete": "DELETE", +"catalog.modelversions.Get": "GET", +"catalog.modelversions.GetByAlias": "GET", +"catalog.modelversions.Update": "PATCH", +"catalog.modelversions.internalList": "GET", +"catalog.onlinetables.Create": "POST", +"catalog.onlinetables.Delete": "DELETE", +"catalog.onlinetables.Get": "GET", +"catalog.policies.CreatePolicy": "POST", +"catalog.policies.DeletePolicy": "DELETE", +"catalog.policies.GetPolicy": "GET", +"catalog.policies.UpdatePolicy": "PATCH", +"catalog.policies.internalListPolicies": "GET", +"catalog.qualitymonitors.CancelRefresh": "POST", +"catalog.qualitymonitors.Create": "POST", +"catalog.qualitymonitors.Delete": "DELETE", +"catalog.qualitymonitors.Get": "GET", +"catalog.qualitymonitors.GetRefresh": "GET", +"catalog.qualitymonitors.ListRefreshes": "GET", +"catalog.qualitymonitors.RegenerateDashboard": "POST", +"catalog.qualitymonitors.RunRefresh": "POST", +"catalog.qualitymonitors.Update": "PUT", +"catalog.registeredmodels.Create": "POST", +"catalog.registeredmodels.Delete": "DELETE", +"catalog.registeredmodels.DeleteAlias": "DELETE", +"catalog.registeredmodels.Get": "GET", +"catalog.registeredmodels.SetAlias": "PUT", +"catalog.registeredmodels.Update": "PATCH", +"catalog.registeredmodels.internalList": "GET", +"catalog.resourcequotas.GetQuota": "GET", +"catalog.resourcequotas.internalListQuotas": "GET", +"catalog.rfa.BatchCreateAccessRequests": "POST", +"catalog.rfa.GetAccessRequestDestinations": "GET", +"catalog.rfa.UpdateAccessRequestDestinations": "PATCH", +"catalog.schemas.Create": "POST", +"catalog.schemas.Delete": "DELETE", +"catalog.schemas.Get": "GET", +"catalog.schemas.Update": "PATCH", +"catalog.schemas.internalList": "GET", +"catalog.secretsuc.CreateSecret": "POST", +"catalog.secretsuc.DeleteSecret": "DELETE", +"catalog.secretsuc.GetSecret": "GET", +"catalog.secretsuc.UpdateSecret": "PATCH", +"catalog.secretsuc.internalListSecrets": "GET", +"catalog.storagecredentials.Create": "POST", +"catalog.storagecredentials.Delete": "DELETE", +"catalog.storagecredentials.Get": "GET", +"catalog.storagecredentials.Update": "PATCH", +"catalog.storagecredentials.Validate": "POST", +"catalog.storagecredentials.internalList": "GET", +"catalog.systemschemas.Disable": "DELETE", +"catalog.systemschemas.Enable": "PUT", +"catalog.systemschemas.internalList": "GET", +"catalog.tableconstraints.Create": "POST", +"catalog.tableconstraints.Delete": "DELETE", +"catalog.tables.Create": "POST", +"catalog.tables.Delete": "DELETE", +"catalog.tables.Exists": "GET", +"catalog.tables.Get": "GET", +"catalog.tables.Update": "PATCH", +"catalog.tables.internalList": "GET", +"catalog.tables.internalListSummaries": "GET", +"catalog.temporarypathcredentials.GenerateTemporaryPathCredentials": "POST", +"catalog.temporarytablecredentials.GenerateTemporaryTableCredentials": "POST", +"catalog.temporaryvolumecredentials.GenerateTemporaryVolumeCredentials": "POST", +"catalog.volumes.Create": "POST", +"catalog.volumes.Delete": "DELETE", +"catalog.volumes.Read": "GET", +"catalog.volumes.Update": "PATCH", +"catalog.volumes.internalList": "GET", +"catalog.workspacebindings.Get": "GET", +"catalog.workspacebindings.Update": "PATCH", +"catalog.workspacebindings.UpdateBindings": "PATCH", +"catalog.workspacebindings.internalGetBindings": "GET", +"cleanrooms.cleanroomassetrevisions.Get": "GET", +"cleanrooms.cleanroomassetrevisions.internalList": "GET", +"cleanrooms.cleanroomassets.Create": "POST", +"cleanrooms.cleanroomassets.CreateCleanRoomAssetReview": "POST", +"cleanrooms.cleanroomassets.Delete": "DELETE", +"cleanrooms.cleanroomassets.Get": "GET", +"cleanrooms.cleanroomassets.Update": "PATCH", +"cleanrooms.cleanroomassets.internalList": "GET", +"cleanrooms.cleanroomautoapprovalrules.Create": "POST", +"cleanrooms.cleanroomautoapprovalrules.Delete": "DELETE", +"cleanrooms.cleanroomautoapprovalrules.Get": "GET", +"cleanrooms.cleanroomautoapprovalrules.Update": "PATCH", +"cleanrooms.cleanroomautoapprovalrules.internalList": "GET", +"cleanrooms.cleanrooms.Create": "POST", +"cleanrooms.cleanrooms.CreateOutputCatalog": "POST", +"cleanrooms.cleanrooms.Delete": "DELETE", +"cleanrooms.cleanrooms.Get": "GET", +"cleanrooms.cleanrooms.Update": "PATCH", +"cleanrooms.cleanrooms.internalList": "GET", +"cleanrooms.cleanroomtaskruns.internalList": "GET", +"cleanrooms.cleanroomtaskruns.internalListCleanRoomTaskRunsHandler": "GET", +"compute.clusterpolicies.Create": "POST", +"compute.clusterpolicies.Delete": "POST", +"compute.clusterpolicies.Edit": "POST", +"compute.clusterpolicies.Get": "GET", +"compute.clusterpolicies.GetPermissionLevels": "GET", +"compute.clusterpolicies.GetPermissions": "GET", +"compute.clusterpolicies.SetPermissions": "PUT", +"compute.clusterpolicies.UpdatePermissions": "PATCH", +"compute.clusterpolicies.internalList": "GET", +"compute.clusters.ChangeOwner": "POST", +"compute.clusters.Create": "POST", +"compute.clusters.Delete": "POST", +"compute.clusters.Edit": "POST", +"compute.clusters.Get": "GET", +"compute.clusters.GetPermissionLevels": "GET", +"compute.clusters.GetPermissions": "GET", +"compute.clusters.ListNodeTypes": "GET", +"compute.clusters.ListZones": "GET", +"compute.clusters.PermanentDelete": "POST", +"compute.clusters.Pin": "POST", +"compute.clusters.Resize": "POST", +"compute.clusters.Restart": "POST", +"compute.clusters.SetPermissions": "PUT", +"compute.clusters.SparkVersions": "GET", +"compute.clusters.Start": "POST", +"compute.clusters.Unpin": "POST", +"compute.clusters.Update": "POST", +"compute.clusters.UpdatePermissions": "PATCH", +"compute.clusters.internalEvents": "POST", +"compute.clusters.internalList": "GET", +"compute.commandexecution.Cancel": "POST", +"compute.commandexecution.CommandStatus": "GET", +"compute.commandexecution.ContextStatus": "GET", +"compute.commandexecution.Create": "POST", +"compute.commandexecution.Destroy": "POST", +"compute.commandexecution.Execute": "POST", +"compute.globalinitscripts.Create": "POST", +"compute.globalinitscripts.Delete": "DELETE", +"compute.globalinitscripts.Get": "GET", +"compute.globalinitscripts.Update": "PATCH", +"compute.globalinitscripts.internalList": "GET", +"compute.instancepools.Create": "POST", +"compute.instancepools.Delete": "POST", +"compute.instancepools.Edit": "POST", +"compute.instancepools.Get": "GET", +"compute.instancepools.GetPermissionLevels": "GET", +"compute.instancepools.GetPermissions": "GET", +"compute.instancepools.SetPermissions": "PUT", +"compute.instancepools.UpdatePermissions": "PATCH", +"compute.instancepools.internalList": "GET", +"compute.instanceprofiles.Add": "POST", +"compute.instanceprofiles.Edit": "POST", +"compute.instanceprofiles.Remove": "POST", +"compute.instanceprofiles.internalList": "GET", +"compute.libraries.Install": "POST", +"compute.libraries.Uninstall": "POST", +"compute.libraries.internalAllClusterStatuses": "GET", +"compute.libraries.internalClusterStatus": "GET", +"compute.policycomplianceforclusters.CancelPendingClusterEnforcement": "POST", +"compute.policycomplianceforclusters.EnforceCompliance": "POST", +"compute.policycomplianceforclusters.GetCompliance": "GET", +"compute.policycomplianceforclusters.internalListCompliance": "GET", +"compute.policyfamilies.Get": "GET", +"compute.policyfamilies.internalList": "GET", +"dashboards.genie.CreateMessage": "POST", +"dashboards.genie.CreateMessageComment": "POST", +"dashboards.genie.CreateSpace": "POST", +"dashboards.genie.DeleteConversation": "DELETE", +"dashboards.genie.DeleteConversationMessage": "DELETE", +"dashboards.genie.DownloadMessageAttachmentVisualization": "GET", +"dashboards.genie.ExecuteMessageAttachmentQuery": "POST", +"dashboards.genie.ExecuteMessageQuery": "POST", +"dashboards.genie.GenerateDownloadFullQueryResult": "POST", +"dashboards.genie.GenieCancelResponse": "POST", +"dashboards.genie.GenieCreateEvalRun": "POST", +"dashboards.genie.GenieGetEvalResultDetails": "GET", +"dashboards.genie.GenieGetEvalRun": "GET", +"dashboards.genie.GenieListEvalResults": "GET", +"dashboards.genie.GenieListEvalRuns": "GET", +"dashboards.genie.GetDownloadFullQueryResult": "GET", +"dashboards.genie.GetMessage": "GET", +"dashboards.genie.GetMessageAttachmentQueryResult": "GET", +"dashboards.genie.GetMessageQueryResult": "GET", +"dashboards.genie.GetMessageQueryResultByAttachment": "GET", +"dashboards.genie.GetSpace": "GET", +"dashboards.genie.ListConversationComments": "GET", +"dashboards.genie.ListConversationMessages": "GET", +"dashboards.genie.ListConversations": "GET", +"dashboards.genie.ListMessageComments": "GET", +"dashboards.genie.ListSpaces": "GET", +"dashboards.genie.SendMessageFeedback": "POST", +"dashboards.genie.StartConversation": "POST", +"dashboards.genie.TrashSpace": "DELETE", +"dashboards.genie.UpdateSpace": "PATCH", +"dashboards.lakeview.Create": "POST", +"dashboards.lakeview.CreateSchedule": "POST", +"dashboards.lakeview.CreateSubscription": "POST", +"dashboards.lakeview.DeleteSchedule": "DELETE", +"dashboards.lakeview.DeleteSubscription": "DELETE", +"dashboards.lakeview.Get": "GET", +"dashboards.lakeview.GetPublished": "GET", +"dashboards.lakeview.GetSchedule": "GET", +"dashboards.lakeview.GetSubscription": "GET", +"dashboards.lakeview.Migrate": "POST", +"dashboards.lakeview.Publish": "POST", +"dashboards.lakeview.Revert": "POST", +"dashboards.lakeview.Trash": "DELETE", +"dashboards.lakeview.Unpublish": "DELETE", +"dashboards.lakeview.Update": "PATCH", +"dashboards.lakeview.UpdateSchedule": "PUT", +"dashboards.lakeview.internalList": "GET", +"dashboards.lakeview.internalListSchedules": "GET", +"dashboards.lakeview.internalListSubscriptions": "GET", +"dashboards.lakeviewembedded.GetPublishedDashboardTokenInfo": "GET", +"database.database.CreateDatabaseCatalog": "POST", +"database.database.CreateDatabaseInstance": "POST", +"database.database.CreateDatabaseInstanceRole": "POST", +"database.database.CreateDatabaseTable": "POST", +"database.database.CreateSyncedDatabaseTable": "POST", +"database.database.DeleteDatabaseCatalog": "DELETE", +"database.database.DeleteDatabaseInstance": "DELETE", +"database.database.DeleteDatabaseInstanceRole": "DELETE", +"database.database.DeleteDatabaseTable": "DELETE", +"database.database.DeleteSyncedDatabaseTable": "DELETE", +"database.database.FindDatabaseInstanceByUid": "GET", +"database.database.GenerateDatabaseCredential": "POST", +"database.database.GetDatabaseCatalog": "GET", +"database.database.GetDatabaseInstance": "GET", +"database.database.GetDatabaseInstanceRole": "GET", +"database.database.GetDatabaseTable": "GET", +"database.database.GetSyncedDatabaseTable": "GET", +"database.database.UpdateDatabaseCatalog": "PATCH", +"database.database.UpdateDatabaseInstance": "PATCH", +"database.database.UpdateSyncedDatabaseTable": "PATCH", +"database.database.internalListDatabaseCatalogs": "GET", +"database.database.internalListDatabaseInstanceRoles": "GET", +"database.database.internalListDatabaseInstances": "GET", +"database.database.internalListSyncedDatabaseTables": "GET", +"dataclassification.dataclassification.CreateCatalogConfig": "POST", +"dataclassification.dataclassification.DeleteCatalogConfig": "DELETE", +"dataclassification.dataclassification.GetCatalogConfig": "GET", +"dataclassification.dataclassification.UpdateCatalogConfig": "PATCH", +"dataquality.dataquality.CancelRefresh": "POST", +"dataquality.dataquality.CreateMonitor": "POST", +"dataquality.dataquality.CreateRefresh": "POST", +"dataquality.dataquality.DeleteMonitor": "DELETE", +"dataquality.dataquality.DeleteRefresh": "DELETE", +"dataquality.dataquality.GetMonitor": "GET", +"dataquality.dataquality.GetRefresh": "GET", +"dataquality.dataquality.UpdateMonitor": "PATCH", +"dataquality.dataquality.UpdateRefresh": "PATCH", +"dataquality.dataquality.internalListMonitor": "GET", +"dataquality.dataquality.internalListRefresh": "GET", +"disasterrecovery.disasterrecovery.CreateFailoverGroup": "POST", +"disasterrecovery.disasterrecovery.CreateStableUrl": "POST", +"disasterrecovery.disasterrecovery.DeleteFailoverGroup": "DELETE", +"disasterrecovery.disasterrecovery.DeleteStableUrl": "DELETE", +"disasterrecovery.disasterrecovery.FailoverFailoverGroup": "POST", +"disasterrecovery.disasterrecovery.GetFailoverGroup": "GET", +"disasterrecovery.disasterrecovery.GetStableUrl": "GET", +"disasterrecovery.disasterrecovery.UpdateFailoverGroup": "PATCH", +"disasterrecovery.disasterrecovery.internalListFailoverGroups": "GET", +"disasterrecovery.disasterrecovery.internalListStableUrls": "GET", +"domains.domains.CreateDomain": "POST", +"domains.domains.DeleteDomain": "DELETE", +"domains.domains.GetDomain": "GET", +"domains.domains.UpdateDomain": "PATCH", +"domains.domains.internalListDomains": "GET", +"environments.environments.CreateWorkspaceBaseEnvironment": "POST", +"environments.environments.DeleteWorkspaceBaseEnvironment": "DELETE", +"environments.environments.GetDefaultWorkspaceBaseEnvironment": "GET", +"environments.environments.GetOperation": "GET", +"environments.environments.GetWorkspaceBaseEnvironment": "GET", +"environments.environments.RefreshWorkspaceBaseEnvironment": "POST", +"environments.environments.UpdateDefaultWorkspaceBaseEnvironment": "PATCH", +"environments.environments.UpdateWorkspaceBaseEnvironment": "PATCH", +"environments.environments.internalListWorkspaceBaseEnvironments": "GET", +"files.dbfs.AddBlock": "POST", +"files.dbfs.Close": "POST", +"files.dbfs.Create": "POST", +"files.dbfs.Delete": "POST", +"files.dbfs.GetStatus": "GET", +"files.dbfs.Mkdirs": "POST", +"files.dbfs.Move": "POST", +"files.dbfs.Put": "POST", +"files.dbfs.Read": "GET", +"files.dbfs.internalList": "GET", +"files.files.CreateDirectory": "PUT", +"files.files.Delete": "DELETE", +"files.files.DeleteDirectory": "DELETE", +"files.files.Download": "GET", +"files.files.GetDirectoryMetadata": "HEAD", +"files.files.GetMetadata": "HEAD", +"files.files.Upload": "PUT", +"files.files.internalListDirectoryContents": "GET", +"iam.accesscontrol.CheckPolicy": "GET", +"iam.accountaccesscontrol.GetAssignableRolesForResource": "GET", +"iam.accountaccesscontrol.GetRuleSet": "GET", +"iam.accountaccesscontrol.UpdateRuleSet": "PUT", +"iam.accountaccesscontrolproxy.GetAssignableRolesForResource": "GET", +"iam.accountaccesscontrolproxy.GetRuleSet": "GET", +"iam.accountaccesscontrolproxy.UpdateRuleSet": "PUT", +"iam.accountgroupsv2.Create": "POST", +"iam.accountgroupsv2.Delete": "DELETE", +"iam.accountgroupsv2.Get": "GET", +"iam.accountgroupsv2.Patch": "PATCH", +"iam.accountgroupsv2.Update": "PUT", +"iam.accountgroupsv2.internalList": "GET", +"iam.accountserviceprincipalsv2.Create": "POST", +"iam.accountserviceprincipalsv2.Delete": "DELETE", +"iam.accountserviceprincipalsv2.Get": "GET", +"iam.accountserviceprincipalsv2.Patch": "PATCH", +"iam.accountserviceprincipalsv2.Update": "PUT", +"iam.accountserviceprincipalsv2.internalList": "GET", +"iam.accountusersv2.Create": "POST", +"iam.accountusersv2.Delete": "DELETE", +"iam.accountusersv2.Get": "GET", +"iam.accountusersv2.Patch": "PATCH", +"iam.accountusersv2.Update": "PUT", +"iam.accountusersv2.internalList": "GET", +"iam.currentuser.Me": "GET", +"iam.groupsv2.Create": "POST", +"iam.groupsv2.Delete": "DELETE", +"iam.groupsv2.Get": "GET", +"iam.groupsv2.Patch": "PATCH", +"iam.groupsv2.Update": "PUT", +"iam.groupsv2.internalList": "GET", +"iam.permissionmigration.MigratePermissions": "POST", +"iam.permissions.Get": "GET", +"iam.permissions.GetPermissionLevels": "GET", +"iam.permissions.Set": "PUT", +"iam.permissions.Update": "PATCH", +"iam.serviceprincipalsv2.Create": "POST", +"iam.serviceprincipalsv2.Delete": "DELETE", +"iam.serviceprincipalsv2.Get": "GET", +"iam.serviceprincipalsv2.Patch": "PATCH", +"iam.serviceprincipalsv2.Update": "PUT", +"iam.serviceprincipalsv2.internalList": "GET", +"iam.usersv2.Create": "POST", +"iam.usersv2.Delete": "DELETE", +"iam.usersv2.Get": "GET", +"iam.usersv2.GetPermissionLevels": "GET", +"iam.usersv2.GetPermissions": "GET", +"iam.usersv2.Patch": "PATCH", +"iam.usersv2.SetPermissions": "PUT", +"iam.usersv2.Update": "PUT", +"iam.usersv2.UpdatePermissions": "PATCH", +"iam.usersv2.internalList": "GET", +"iam.workspaceassignment.Delete": "DELETE", +"iam.workspaceassignment.Get": "GET", +"iam.workspaceassignment.Update": "PUT", +"iam.workspaceassignment.internalList": "GET", +"iamv2.accountiamv2.CreateDirectGroupMember": "POST", +"iamv2.accountiamv2.CreateGroup": "POST", +"iamv2.accountiamv2.CreateIdentityVisibilityFilter": "POST", +"iamv2.accountiamv2.CreateServicePrincipal": "POST", +"iamv2.accountiamv2.CreateUser": "POST", +"iamv2.accountiamv2.CreateWorkspaceAssignment": "POST", +"iamv2.accountiamv2.CreateWorkspaceAssignmentDetail": "POST", +"iamv2.accountiamv2.DeleteDirectGroupMember": "DELETE", +"iamv2.accountiamv2.DeleteGroup": "DELETE", +"iamv2.accountiamv2.DeleteIdentityVisibilityFilter": "DELETE", +"iamv2.accountiamv2.DeleteServicePrincipal": "DELETE", +"iamv2.accountiamv2.DeleteUser": "DELETE", +"iamv2.accountiamv2.DeleteWorkspaceAssignment": "DELETE", +"iamv2.accountiamv2.DeleteWorkspaceAssignmentDetail": "DELETE", +"iamv2.accountiamv2.GetDirectGroupMember": "GET", +"iamv2.accountiamv2.GetExternalGroup": "GET", +"iamv2.accountiamv2.GetExternalServicePrincipal": "GET", +"iamv2.accountiamv2.GetExternalUser": "GET", +"iamv2.accountiamv2.GetGroup": "GET", +"iamv2.accountiamv2.GetIdentityVisibilityFilter": "GET", +"iamv2.accountiamv2.GetServicePrincipal": "GET", +"iamv2.accountiamv2.GetUser": "GET", +"iamv2.accountiamv2.GetWorkspaceAccessDetail": "GET", +"iamv2.accountiamv2.GetWorkspaceAssignment": "GET", +"iamv2.accountiamv2.GetWorkspaceAssignmentDetail": "GET", +"iamv2.accountiamv2.ListTransitiveParentGroups": "GET", +"iamv2.accountiamv2.ResolveGroup": "POST", +"iamv2.accountiamv2.ResolveServicePrincipal": "POST", +"iamv2.accountiamv2.ResolveUser": "POST", +"iamv2.accountiamv2.UpdateGroup": "PATCH", +"iamv2.accountiamv2.UpdateServicePrincipal": "PATCH", +"iamv2.accountiamv2.UpdateUser": "PATCH", +"iamv2.accountiamv2.UpdateWorkspaceAssignment": "PATCH", +"iamv2.accountiamv2.UpdateWorkspaceAssignmentDetail": "PATCH", +"iamv2.accountiamv2.internalListDirectGroupMembers": "GET", +"iamv2.accountiamv2.internalListGroups": "GET", +"iamv2.accountiamv2.internalListIdentityVisibilityFilters": "GET", +"iamv2.accountiamv2.internalListServicePrincipals": "GET", +"iamv2.accountiamv2.internalListUsers": "GET", +"iamv2.accountiamv2.internalListWorkspaceAssignmentDetails": "GET", +"iamv2.accountiamv2.internalListWorkspaceAssignments": "GET", +"iamv2.workspaceiamv2.CreateDirectGroupMemberProxy": "POST", +"iamv2.workspaceiamv2.CreateGroupProxy": "POST", +"iamv2.workspaceiamv2.CreateServicePrincipalProxy": "POST", +"iamv2.workspaceiamv2.CreateUserProxy": "POST", +"iamv2.workspaceiamv2.CreateWorkspaceAssignmentDetailProxy": "POST", +"iamv2.workspaceiamv2.CreateWorkspaceAssignmentProxy": "POST", +"iamv2.workspaceiamv2.DeleteDirectGroupMemberProxy": "DELETE", +"iamv2.workspaceiamv2.DeleteGroupProxy": "DELETE", +"iamv2.workspaceiamv2.DeleteServicePrincipalProxy": "DELETE", +"iamv2.workspaceiamv2.DeleteUserProxy": "DELETE", +"iamv2.workspaceiamv2.DeleteWorkspaceAssignmentDetailProxy": "DELETE", +"iamv2.workspaceiamv2.DeleteWorkspaceAssignmentProxy": "DELETE", +"iamv2.workspaceiamv2.GetDirectGroupMemberProxy": "GET", +"iamv2.workspaceiamv2.GetExternalGroupProxy": "GET", +"iamv2.workspaceiamv2.GetExternalServicePrincipalProxy": "GET", +"iamv2.workspaceiamv2.GetExternalUserProxy": "GET", +"iamv2.workspaceiamv2.GetGroupProxy": "GET", +"iamv2.workspaceiamv2.GetServicePrincipalProxy": "GET", +"iamv2.workspaceiamv2.GetUserProxy": "GET", +"iamv2.workspaceiamv2.GetWorkspaceAccessDetailLocal": "GET", +"iamv2.workspaceiamv2.GetWorkspaceAssignmentDetailProxy": "GET", +"iamv2.workspaceiamv2.GetWorkspaceAssignmentProxy": "GET", +"iamv2.workspaceiamv2.GetWorkspaceIdentityDetail": "GET", +"iamv2.workspaceiamv2.ListTransitiveParentGroupsProxy": "GET", +"iamv2.workspaceiamv2.ResolveGroupProxy": "POST", +"iamv2.workspaceiamv2.ResolveServicePrincipalProxy": "POST", +"iamv2.workspaceiamv2.ResolveUserProxy": "POST", +"iamv2.workspaceiamv2.UpdateGroupProxy": "PATCH", +"iamv2.workspaceiamv2.UpdateServicePrincipalProxy": "PATCH", +"iamv2.workspaceiamv2.UpdateUserProxy": "PATCH", +"iamv2.workspaceiamv2.UpdateWorkspaceAssignmentDetailProxy": "PATCH", +"iamv2.workspaceiamv2.UpdateWorkspaceAssignmentProxy": "PATCH", +"iamv2.workspaceiamv2.UpdateWorkspaceIdentityDetail": "PATCH", +"iamv2.workspaceiamv2.internalListDirectGroupMembersProxy": "GET", +"iamv2.workspaceiamv2.internalListGroupsProxy": "GET", +"iamv2.workspaceiamv2.internalListServicePrincipalsProxy": "GET", +"iamv2.workspaceiamv2.internalListUsersProxy": "GET", +"iamv2.workspaceiamv2.internalListWorkspaceAssignmentDetailsProxy": "GET", +"iamv2.workspaceiamv2.internalListWorkspaceAssignmentsProxy": "GET", +"jobs.jobs.CancelAllRuns": "POST", +"jobs.jobs.CancelRun": "POST", +"jobs.jobs.Create": "POST", +"jobs.jobs.Delete": "POST", +"jobs.jobs.DeleteRun": "POST", +"jobs.jobs.ExportRun": "GET", +"jobs.jobs.Get": "GET", +"jobs.jobs.GetPermissionLevels": "GET", +"jobs.jobs.GetPermissions": "GET", +"jobs.jobs.GetRun": "GET", +"jobs.jobs.GetRunOutput": "GET", +"jobs.jobs.RepairRun": "POST", +"jobs.jobs.Reset": "POST", +"jobs.jobs.RunNow": "POST", +"jobs.jobs.SetPermissions": "PUT", +"jobs.jobs.Submit": "POST", +"jobs.jobs.Update": "POST", +"jobs.jobs.UpdatePermissions": "PATCH", +"jobs.jobs.internalList": "GET", +"jobs.jobs.internalListRuns": "GET", +"jobs.policycomplianceforjobs.EnforceCompliance": "POST", +"jobs.policycomplianceforjobs.GetCompliance": "GET", +"jobs.policycomplianceforjobs.internalListCompliance": "GET", +"knowledgeassistants.knowledgeassistants.CreateExample": "POST", +"knowledgeassistants.knowledgeassistants.CreateKnowledgeAssistant": "POST", +"knowledgeassistants.knowledgeassistants.CreateKnowledgeSource": "POST", +"knowledgeassistants.knowledgeassistants.DeleteExample": "DELETE", +"knowledgeassistants.knowledgeassistants.DeleteKnowledgeAssistant": "DELETE", +"knowledgeassistants.knowledgeassistants.DeleteKnowledgeSource": "DELETE", +"knowledgeassistants.knowledgeassistants.GetExample": "GET", +"knowledgeassistants.knowledgeassistants.GetKnowledgeAssistant": "GET", +"knowledgeassistants.knowledgeassistants.GetKnowledgeSource": "GET", +"knowledgeassistants.knowledgeassistants.GetPermissionLevels": "GET", +"knowledgeassistants.knowledgeassistants.GetPermissions": "GET", +"knowledgeassistants.knowledgeassistants.SetPermissions": "PUT", +"knowledgeassistants.knowledgeassistants.SyncKnowledgeSources": "POST", +"knowledgeassistants.knowledgeassistants.UpdateExample": "PATCH", +"knowledgeassistants.knowledgeassistants.UpdateKnowledgeAssistant": "PATCH", +"knowledgeassistants.knowledgeassistants.UpdateKnowledgeSource": "PATCH", +"knowledgeassistants.knowledgeassistants.UpdatePermissions": "PATCH", +"knowledgeassistants.knowledgeassistants.internalListExamples": "GET", +"knowledgeassistants.knowledgeassistants.internalListKnowledgeAssistants": "GET", +"knowledgeassistants.knowledgeassistants.internalListKnowledgeSources": "GET", +"marketplace.consumerfulfillments.internalGet": "GET", +"marketplace.consumerfulfillments.internalList": "GET", +"marketplace.consumerinstallations.Create": "POST", +"marketplace.consumerinstallations.Delete": "DELETE", +"marketplace.consumerinstallations.Update": "PUT", +"marketplace.consumerinstallations.internalList": "GET", +"marketplace.consumerinstallations.internalListListingInstallations": "GET", +"marketplace.consumerlistings.BatchGet": "GET", +"marketplace.consumerlistings.Get": "GET", +"marketplace.consumerlistings.internalList": "GET", +"marketplace.consumerlistings.internalSearch": "GET", +"marketplace.consumerpersonalizationrequests.Create": "POST", +"marketplace.consumerpersonalizationrequests.Get": "GET", +"marketplace.consumerpersonalizationrequests.internalList": "GET", +"marketplace.consumerproviders.BatchGet": "GET", +"marketplace.consumerproviders.Get": "GET", +"marketplace.consumerproviders.internalList": "GET", +"marketplace.providerexchangefilters.Create": "POST", +"marketplace.providerexchangefilters.Delete": "DELETE", +"marketplace.providerexchangefilters.Update": "PUT", +"marketplace.providerexchangefilters.internalList": "GET", +"marketplace.providerexchanges.AddListingToExchange": "POST", +"marketplace.providerexchanges.Create": "POST", +"marketplace.providerexchanges.Delete": "DELETE", +"marketplace.providerexchanges.DeleteListingFromExchange": "DELETE", +"marketplace.providerexchanges.Get": "GET", +"marketplace.providerexchanges.Update": "PUT", +"marketplace.providerexchanges.internalList": "GET", +"marketplace.providerexchanges.internalListExchangesForListing": "GET", +"marketplace.providerexchanges.internalListListingsForExchange": "GET", +"marketplace.providerfiles.Create": "POST", +"marketplace.providerfiles.Delete": "DELETE", +"marketplace.providerfiles.Get": "GET", +"marketplace.providerfiles.internalList": "GET", +"marketplace.providerlistings.Create": "POST", +"marketplace.providerlistings.Delete": "DELETE", +"marketplace.providerlistings.Get": "GET", +"marketplace.providerlistings.Update": "PUT", +"marketplace.providerlistings.internalList": "GET", +"marketplace.providerpersonalizationrequests.Update": "PUT", +"marketplace.providerpersonalizationrequests.internalList": "GET", +"marketplace.providerprovideranalyticsdashboards.Create": "POST", +"marketplace.providerprovideranalyticsdashboards.Get": "GET", +"marketplace.providerprovideranalyticsdashboards.GetLatestVersion": "GET", +"marketplace.providerprovideranalyticsdashboards.Update": "PUT", +"marketplace.providerproviders.Create": "POST", +"marketplace.providerproviders.Delete": "DELETE", +"marketplace.providerproviders.Get": "GET", +"marketplace.providerproviders.Update": "PUT", +"marketplace.providerproviders.internalList": "GET", +"mason.mason.AppendSessionItems": "POST", +"mason.mason.ClearSessionItems": "POST", +"mason.mason.CreateMemory": "POST", +"mason.mason.CreateMemoryStore": "POST", +"mason.mason.CreateSession": "POST", +"mason.mason.CreateSessionStore": "POST", +"mason.mason.DeleteMemory": "DELETE", +"mason.mason.DeleteMemoryStore": "DELETE", +"mason.mason.DeleteSession": "DELETE", +"mason.mason.DeleteSessionStore": "DELETE", +"mason.mason.ExtractMemories": "POST", +"mason.mason.ForkSession": "POST", +"mason.mason.GetMemory": "GET", +"mason.mason.GetMemoryStore": "GET", +"mason.mason.GetSession": "GET", +"mason.mason.GetSessionStore": "GET", +"mason.mason.PopSessionItem": "POST", +"mason.mason.UpdateMemory": "PATCH", +"mason.mason.UpdateMemoryStore": "PATCH", +"mason.mason.UpdateSession": "PATCH", +"mason.mason.UpdateSessionStore": "PATCH", +"mason.mason.internalListMemories": "GET", +"mason.mason.internalListMemoryStores": "GET", +"mason.mason.internalListSessionItems": "GET", +"mason.mason.internalListSessionStores": "GET", +"mason.mason.internalListSessions": "GET", +"mason.mason.internalSearchMemories": "POST", +"ml.experiments.CreateExperiment": "POST", +"ml.experiments.CreateLoggedModel": "POST", +"ml.experiments.CreateRun": "POST", +"ml.experiments.DeleteExperiment": "POST", +"ml.experiments.DeleteLoggedModel": "DELETE", +"ml.experiments.DeleteLoggedModelTag": "DELETE", +"ml.experiments.DeleteRun": "POST", +"ml.experiments.DeleteRuns": "POST", +"ml.experiments.DeleteTag": "POST", +"ml.experiments.FinalizeLoggedModel": "PATCH", +"ml.experiments.GetByName": "GET", +"ml.experiments.GetExperiment": "GET", +"ml.experiments.GetLoggedModel": "GET", +"ml.experiments.GetPermissionLevels": "GET", +"ml.experiments.GetPermissions": "GET", +"ml.experiments.GetRun": "GET", +"ml.experiments.LogBatch": "POST", +"ml.experiments.LogInputs": "POST", +"ml.experiments.LogLoggedModelParams": "POST", +"ml.experiments.LogMetric": "POST", +"ml.experiments.LogModel": "POST", +"ml.experiments.LogOutputs": "POST", +"ml.experiments.LogParam": "POST", +"ml.experiments.RestoreExperiment": "POST", +"ml.experiments.RestoreRun": "POST", +"ml.experiments.RestoreRuns": "POST", +"ml.experiments.SearchLoggedModels": "POST", +"ml.experiments.SetExperimentTag": "POST", +"ml.experiments.SetLoggedModelTags": "PATCH", +"ml.experiments.SetPermissions": "PUT", +"ml.experiments.SetTag": "POST", +"ml.experiments.UpdateExperiment": "POST", +"ml.experiments.UpdatePermissions": "PATCH", +"ml.experiments.UpdateRun": "POST", +"ml.experiments.internalGetHistory": "GET", +"ml.experiments.internalListArtifacts": "GET", +"ml.experiments.internalListExperiments": "GET", +"ml.experiments.internalSearchExperiments": "POST", +"ml.experiments.internalSearchRuns": "POST", +"ml.featureengineering.BackfillFeatures": "POST", +"ml.featureengineering.BatchCreateMaterializedFeatures": "POST", +"ml.featureengineering.CancelOperation": "POST", +"ml.featureengineering.CreateFeature": "POST", +"ml.featureengineering.CreateKafkaConfig": "POST", +"ml.featureengineering.CreateMaterializedFeature": "POST", +"ml.featureengineering.CreateStream": "POST", +"ml.featureengineering.DeleteFeature": "DELETE", +"ml.featureengineering.DeleteKafkaConfig": "DELETE", +"ml.featureengineering.DeleteMaterializedFeature": "DELETE", +"ml.featureengineering.DeleteStream": "DELETE", +"ml.featureengineering.GetFeature": "GET", +"ml.featureengineering.GetKafkaConfig": "GET", +"ml.featureengineering.GetMaterializedFeature": "GET", +"ml.featureengineering.GetOperation": "GET", +"ml.featureengineering.GetStream": "GET", +"ml.featureengineering.PurgeFeatureEntities": "POST", +"ml.featureengineering.UpdateFeature": "PATCH", +"ml.featureengineering.UpdateKafkaConfig": "PATCH", +"ml.featureengineering.UpdateMaterializedFeature": "PATCH", +"ml.featureengineering.UpdateStream": "PATCH", +"ml.featureengineering.internalListFeatures": "GET", +"ml.featureengineering.internalListKafkaConfigs": "GET", +"ml.featureengineering.internalListMaterializedFeatures": "GET", +"ml.featureengineering.internalListStreams": "GET", +"ml.featurestore.CreateOnlineStore": "POST", +"ml.featurestore.DeleteOnlineStore": "DELETE", +"ml.featurestore.DeleteOnlineTable": "DELETE", +"ml.featurestore.GetOnlineStore": "GET", +"ml.featurestore.PublishTable": "POST", +"ml.featurestore.UpdateOnlineStore": "PATCH", +"ml.featurestore.internalListOnlineStores": "GET", +"ml.forecasting.CreateExperiment": "POST", +"ml.forecasting.GetExperiment": "GET", +"ml.materializedfeatures.CreateFeatureTag": "POST", +"ml.materializedfeatures.DeleteFeatureTag": "DELETE", +"ml.materializedfeatures.GetFeatureLineage": "GET", +"ml.materializedfeatures.GetFeatureTag": "GET", +"ml.materializedfeatures.UpdateFeatureTag": "PATCH", +"ml.materializedfeatures.internalListFeatureTags": "GET", +"ml.modelregistry.ApproveTransitionRequest": "POST", +"ml.modelregistry.CreateComment": "POST", +"ml.modelregistry.CreateModel": "POST", +"ml.modelregistry.CreateModelVersion": "POST", +"ml.modelregistry.CreateTransitionRequest": "POST", +"ml.modelregistry.CreateWebhook": "POST", +"ml.modelregistry.DeleteComment": "DELETE", +"ml.modelregistry.DeleteModel": "DELETE", +"ml.modelregistry.DeleteModelTag": "DELETE", +"ml.modelregistry.DeleteModelVersion": "DELETE", +"ml.modelregistry.DeleteModelVersionTag": "DELETE", +"ml.modelregistry.DeleteTransitionRequest": "DELETE", +"ml.modelregistry.DeleteWebhook": "DELETE", +"ml.modelregistry.GetModel": "GET", +"ml.modelregistry.GetModelVersion": "GET", +"ml.modelregistry.GetModelVersionDownloadUri": "GET", +"ml.modelregistry.GetPermissionLevels": "GET", +"ml.modelregistry.GetPermissions": "GET", +"ml.modelregistry.RejectTransitionRequest": "POST", +"ml.modelregistry.RenameModel": "POST", +"ml.modelregistry.SetModelTag": "POST", +"ml.modelregistry.SetModelVersionTag": "POST", +"ml.modelregistry.SetPermissions": "PUT", +"ml.modelregistry.TestRegistryWebhook": "POST", +"ml.modelregistry.TransitionStage": "POST", +"ml.modelregistry.UpdateComment": "PATCH", +"ml.modelregistry.UpdateModel": "PATCH", +"ml.modelregistry.UpdateModelVersion": "PATCH", +"ml.modelregistry.UpdatePermissions": "PATCH", +"ml.modelregistry.UpdateWebhook": "PATCH", +"ml.modelregistry.internalGetLatestVersions": "POST", +"ml.modelregistry.internalListModels": "GET", +"ml.modelregistry.internalListTransitionRequests": "GET", +"ml.modelregistry.internalListWebhooks": "GET", +"ml.modelregistry.internalSearchModelVersions": "GET", +"ml.modelregistry.internalSearchModels": "GET", +"networking.endpoints.CreateEndpoint": "POST", +"networking.endpoints.DeleteEndpoint": "DELETE", +"networking.endpoints.GetEndpoint": "GET", +"networking.endpoints.internalListEndpoints": "GET", +"networking.privatenetworkgateways.CreatePrivateNetworkGateway": "POST", +"networking.privatenetworkgateways.DeletePrivateNetworkGateway": "DELETE", +"networking.privatenetworkgateways.GetPrivateNetworkGateway": "GET", +"networking.privatenetworkgateways.GetPrivateNetworkGatewayOperation": "GET", +"networking.privatenetworkgateways.UpdatePrivateNetworkGateway": "PATCH", +"networking.privatenetworkgateways.internalListPrivateNetworkGateways": "GET", +"oauth2.accountfederationpolicy.Create": "POST", +"oauth2.accountfederationpolicy.Delete": "DELETE", +"oauth2.accountfederationpolicy.Get": "GET", +"oauth2.accountfederationpolicy.Update": "PATCH", +"oauth2.accountfederationpolicy.internalList": "GET", +"oauth2.customappintegration.Create": "POST", +"oauth2.customappintegration.Delete": "DELETE", +"oauth2.customappintegration.Get": "GET", +"oauth2.customappintegration.Update": "PATCH", +"oauth2.customappintegration.internalList": "GET", +"oauth2.oauthpublishedapps.internalList": "GET", +"oauth2.publishedappintegration.Create": "POST", +"oauth2.publishedappintegration.Delete": "DELETE", +"oauth2.publishedappintegration.Get": "GET", +"oauth2.publishedappintegration.Update": "PATCH", +"oauth2.publishedappintegration.internalList": "GET", +"oauth2.serviceprincipalfederationpolicy.Create": "POST", +"oauth2.serviceprincipalfederationpolicy.Delete": "DELETE", +"oauth2.serviceprincipalfederationpolicy.Get": "GET", +"oauth2.serviceprincipalfederationpolicy.Update": "PATCH", +"oauth2.serviceprincipalfederationpolicy.internalList": "GET", +"oauth2.serviceprincipalsecrets.Create": "POST", +"oauth2.serviceprincipalsecrets.Delete": "DELETE", +"oauth2.serviceprincipalsecrets.internalList": "GET", +"oauth2.serviceprincipalsecretsproxy.Create": "POST", +"oauth2.serviceprincipalsecretsproxy.Delete": "DELETE", +"oauth2.serviceprincipalsecretsproxy.internalList": "GET", +"pipelines.pipelines.ApplyEnvironment": "POST", +"pipelines.pipelines.Clone": "POST", +"pipelines.pipelines.Create": "POST", +"pipelines.pipelines.Delete": "DELETE", +"pipelines.pipelines.Get": "GET", +"pipelines.pipelines.GetPermissionLevels": "GET", +"pipelines.pipelines.GetPermissions": "GET", +"pipelines.pipelines.GetUpdate": "GET", +"pipelines.pipelines.ListUpdates": "GET", +"pipelines.pipelines.SetPermissions": "PUT", +"pipelines.pipelines.StartUpdate": "POST", +"pipelines.pipelines.Stop": "POST", +"pipelines.pipelines.Update": "PUT", +"pipelines.pipelines.UpdatePermissions": "PATCH", +"pipelines.pipelines.internalListPipelineEvents": "GET", +"pipelines.pipelines.internalListPipelines": "GET", +"postgres.postgres.CreateBranch": "POST", +"postgres.postgres.CreateCatalog": "POST", +"postgres.postgres.CreateCdfConfig": "POST", +"postgres.postgres.CreateDataApi": "POST", +"postgres.postgres.CreateDatabase": "POST", +"postgres.postgres.CreateEndpoint": "POST", +"postgres.postgres.CreateProject": "POST", +"postgres.postgres.CreateRole": "POST", +"postgres.postgres.CreateSnapshot": "POST", +"postgres.postgres.CreateSyncedTable": "POST", +"postgres.postgres.DeleteBranch": "DELETE", +"postgres.postgres.DeleteCatalog": "DELETE", +"postgres.postgres.DeleteCdfConfig": "DELETE", +"postgres.postgres.DeleteDataApi": "DELETE", +"postgres.postgres.DeleteDatabase": "DELETE", +"postgres.postgres.DeleteEndpoint": "DELETE", +"postgres.postgres.DeleteProject": "DELETE", +"postgres.postgres.DeleteRole": "DELETE", +"postgres.postgres.DeleteSnapshot": "DELETE", +"postgres.postgres.DeleteSyncedTable": "DELETE", +"postgres.postgres.GenerateDatabaseCredential": "POST", +"postgres.postgres.GetBranch": "GET", +"postgres.postgres.GetCatalog": "GET", +"postgres.postgres.GetCdfConfig": "GET", +"postgres.postgres.GetCdfStatus": "GET", +"postgres.postgres.GetDataApi": "GET", +"postgres.postgres.GetDatabase": "GET", +"postgres.postgres.GetEndpoint": "GET", +"postgres.postgres.GetOperation": "GET", +"postgres.postgres.GetProject": "GET", +"postgres.postgres.GetRole": "GET", +"postgres.postgres.GetSnapshot": "GET", +"postgres.postgres.GetSnapshotSchedule": "GET", +"postgres.postgres.GetSyncedTable": "GET", +"postgres.postgres.UndeleteBranch": "POST", +"postgres.postgres.UndeleteProject": "POST", +"postgres.postgres.UpdateBranch": "PATCH", +"postgres.postgres.UpdateDataApi": "PATCH", +"postgres.postgres.UpdateDatabase": "PATCH", +"postgres.postgres.UpdateEndpoint": "PATCH", +"postgres.postgres.UpdateProject": "PATCH", +"postgres.postgres.UpdateRole": "PATCH", +"postgres.postgres.UpdateSnapshotSchedule": "PATCH", +"postgres.postgres.internalListBranches": "GET", +"postgres.postgres.internalListCdfConfigs": "GET", +"postgres.postgres.internalListCdfStatuses": "GET", +"postgres.postgres.internalListDatabases": "GET", +"postgres.postgres.internalListEndpoints": "GET", +"postgres.postgres.internalListProjects": "GET", +"postgres.postgres.internalListRoles": "GET", +"postgres.postgres.internalListSnapshots": "GET", +"provisioning.credentials.Create": "POST", +"provisioning.credentials.Delete": "DELETE", +"provisioning.credentials.Get": "GET", +"provisioning.credentials.List": "GET", +"provisioning.encryptionkeys.Create": "POST", +"provisioning.encryptionkeys.Delete": "DELETE", +"provisioning.encryptionkeys.Get": "GET", +"provisioning.encryptionkeys.List": "GET", +"provisioning.networks.Create": "POST", +"provisioning.networks.Delete": "DELETE", +"provisioning.networks.Get": "GET", +"provisioning.networks.List": "GET", +"provisioning.privateaccess.Create": "POST", +"provisioning.privateaccess.Delete": "DELETE", +"provisioning.privateaccess.Get": "GET", +"provisioning.privateaccess.List": "GET", +"provisioning.privateaccess.Replace": "PUT", +"provisioning.storage.Create": "POST", +"provisioning.storage.Delete": "DELETE", +"provisioning.storage.Get": "GET", +"provisioning.storage.List": "GET", +"provisioning.vpcendpoints.Create": "POST", +"provisioning.vpcendpoints.Delete": "DELETE", +"provisioning.vpcendpoints.Get": "GET", +"provisioning.vpcendpoints.List": "GET", +"provisioning.workspaces.Create": "POST", +"provisioning.workspaces.Delete": "DELETE", +"provisioning.workspaces.Get": "GET", +"provisioning.workspaces.List": "GET", +"provisioning.workspaces.Update": "PATCH", +"qualitymonitorv2.qualitymonitorv2.CreateQualityMonitor": "POST", +"qualitymonitorv2.qualitymonitorv2.DeleteQualityMonitor": "DELETE", +"qualitymonitorv2.qualitymonitorv2.GetQualityMonitor": "GET", +"qualitymonitorv2.qualitymonitorv2.UpdateQualityMonitor": "PUT", +"qualitymonitorv2.qualitymonitorv2.internalListQualityMonitor": "GET", +"sandbox.sandbox.CreateSandbox": "POST", +"sandbox.sandbox.DeleteSandbox": "DELETE", +"sandbox.sandbox.ExecuteCommandSync": "POST", +"sandbox.sandbox.GetSandbox": "GET", +"sandbox.sandbox.ListCommands": "GET", +"sandbox.sandbox.StartSandbox": "POST", +"sandbox.sandbox.StopSandbox": "POST", +"sandbox.sandbox.UpdateSandbox": "PATCH", +"sandbox.sandbox.internalListSandboxes": "GET", +"serving.servingendpoints.BuildLogs": "GET", +"serving.servingendpoints.Create": "POST", +"serving.servingendpoints.CreateProvisionedThroughputEndpoint": "POST", +"serving.servingendpoints.Delete": "DELETE", +"serving.servingendpoints.ExportMetrics": "GET", +"serving.servingendpoints.Get": "GET", +"serving.servingendpoints.GetOpenApi": "GET", +"serving.servingendpoints.GetPermissionLevels": "GET", +"serving.servingendpoints.GetPermissions": "GET", +"serving.servingendpoints.HttpRequest": "POST", +"serving.servingendpoints.Logs": "GET", +"serving.servingendpoints.Patch": "PATCH", +"serving.servingendpoints.PatchTelemetryConfig": "PATCH", +"serving.servingendpoints.Put": "PUT", +"serving.servingendpoints.PutAiGateway": "PUT", +"serving.servingendpoints.Query": "POST", +"serving.servingendpoints.SetPermissions": "PUT", +"serving.servingendpoints.UpdateConfig": "PUT", +"serving.servingendpoints.UpdateNotifications": "PATCH", +"serving.servingendpoints.UpdatePermissions": "PATCH", +"serving.servingendpoints.UpdateProvisionedThroughputEndpointConfig": "PUT", +"serving.servingendpoints.internalList": "GET", +"serving.servingendpointsdataplane.Query": "POST", +"settings.accountipaccesslists.Create": "POST", +"settings.accountipaccesslists.Delete": "DELETE", +"settings.accountipaccesslists.Get": "GET", +"settings.accountipaccesslists.Replace": "PUT", +"settings.accountipaccesslists.Update": "PATCH", +"settings.accountipaccesslists.internalList": "GET", +"settings.aibidashboardembeddingaccesspolicy.Delete": "DELETE", +"settings.aibidashboardembeddingaccesspolicy.Get": "GET", +"settings.aibidashboardembeddingaccesspolicy.Update": "PATCH", +"settings.aibidashboardembeddingapproveddomains.Delete": "DELETE", +"settings.aibidashboardembeddingapproveddomains.Get": "GET", +"settings.aibidashboardembeddingapproveddomains.Update": "PATCH", +"settings.automaticclusterupdate.Get": "GET", +"settings.automaticclusterupdate.Update": "PATCH", +"settings.compliancesecurityprofile.Get": "GET", +"settings.compliancesecurityprofile.Update": "PATCH", +"settings.credentialsmanager.ExchangeToken": "POST", +"settings.cspenablementaccount.Get": "GET", +"settings.cspenablementaccount.Update": "PATCH", +"settings.dashboardemailsubscriptions.Delete": "DELETE", +"settings.dashboardemailsubscriptions.Get": "GET", +"settings.dashboardemailsubscriptions.Update": "PATCH", +"settings.defaultnamespace.Delete": "DELETE", +"settings.defaultnamespace.Get": "GET", +"settings.defaultnamespace.Update": "PATCH", +"settings.defaultwarehouseid.Delete": "DELETE", +"settings.defaultwarehouseid.Get": "GET", +"settings.defaultwarehouseid.Update": "PATCH", +"settings.disablelegacyaccess.Delete": "DELETE", +"settings.disablelegacyaccess.Get": "GET", +"settings.disablelegacyaccess.Update": "PATCH", +"settings.disablelegacydbfs.Delete": "DELETE", +"settings.disablelegacydbfs.Get": "GET", +"settings.disablelegacydbfs.Update": "PATCH", +"settings.disablelegacyfeatures.Delete": "DELETE", +"settings.disablelegacyfeatures.Get": "GET", +"settings.disablelegacyfeatures.Update": "PATCH", +"settings.enableexportnotebook.GetEnableExportNotebook": "GET", +"settings.enableexportnotebook.PatchEnableExportNotebook": "PATCH", +"settings.enableipaccesslists.Delete": "DELETE", +"settings.enableipaccesslists.Get": "GET", +"settings.enableipaccesslists.Update": "PATCH", +"settings.enablenotebooktableclipboard.GetEnableNotebookTableClipboard": "GET", +"settings.enablenotebooktableclipboard.PatchEnableNotebookTableClipboard": "PATCH", +"settings.enableresultsdownloading.GetEnableResultsDownloading": "GET", +"settings.enableresultsdownloading.PatchEnableResultsDownloading": "PATCH", +"settings.enhancedsecuritymonitoring.Get": "GET", +"settings.enhancedsecuritymonitoring.Update": "PATCH", +"settings.esmenablementaccount.Get": "GET", +"settings.esmenablementaccount.Update": "PATCH", +"settings.ipaccesslists.Create": "POST", +"settings.ipaccesslists.Delete": "DELETE", +"settings.ipaccesslists.Get": "GET", +"settings.ipaccesslists.Replace": "PUT", +"settings.ipaccesslists.Update": "PATCH", +"settings.ipaccesslists.internalList": "GET", +"settings.llmproxypartnerpoweredaccount.Get": "GET", +"settings.llmproxypartnerpoweredaccount.Update": "PATCH", +"settings.llmproxypartnerpoweredenforce.Get": "GET", +"settings.llmproxypartnerpoweredenforce.Update": "PATCH", +"settings.llmproxypartnerpoweredworkspace.Delete": "DELETE", +"settings.llmproxypartnerpoweredworkspace.Get": "GET", +"settings.llmproxypartnerpoweredworkspace.Update": "PATCH", +"settings.networkconnectivity.CreateNetworkConnectivityConfiguration": "POST", +"settings.networkconnectivity.CreatePrivateEndpointRule": "POST", +"settings.networkconnectivity.DeleteNetworkConnectivityConfiguration": "DELETE", +"settings.networkconnectivity.DeletePrivateEndpointRule": "DELETE", +"settings.networkconnectivity.GetNetworkConnectivityConfiguration": "GET", +"settings.networkconnectivity.GetPrivateEndpointRule": "GET", +"settings.networkconnectivity.UpdatePrivateEndpointRule": "PATCH", +"settings.networkconnectivity.internalListNetworkConnectivityConfigurations": "GET", +"settings.networkconnectivity.internalListPrivateEndpointRules": "GET", +"settings.networkpolicies.CreateNetworkPolicyRpc": "POST", +"settings.networkpolicies.DeleteNetworkPolicyRpc": "DELETE", +"settings.networkpolicies.GetNetworkPolicyRpc": "GET", +"settings.networkpolicies.UpdateNetworkPolicyRpc": "PUT", +"settings.networkpolicies.internalListNetworkPoliciesRpc": "GET", +"settings.notificationdestinations.Create": "POST", +"settings.notificationdestinations.Delete": "DELETE", +"settings.notificationdestinations.Get": "GET", +"settings.notificationdestinations.Update": "PATCH", +"settings.notificationdestinations.internalList": "GET", +"settings.personalcompute.Delete": "DELETE", +"settings.personalcompute.Get": "GET", +"settings.personalcompute.Update": "PATCH", +"settings.restrictworkspaceadmins.Delete": "DELETE", +"settings.restrictworkspaceadmins.Get": "GET", +"settings.restrictworkspaceadmins.Update": "PATCH", +"settings.sqlresultsdownload.Delete": "DELETE", +"settings.sqlresultsdownload.Get": "GET", +"settings.sqlresultsdownload.Update": "PATCH", +"settings.tokenmanagement.CreateOboToken": "POST", +"settings.tokenmanagement.Delete": "DELETE", +"settings.tokenmanagement.Get": "GET", +"settings.tokenmanagement.GetPermissionLevels": "GET", +"settings.tokenmanagement.GetPermissions": "GET", +"settings.tokenmanagement.SetPermissions": "PUT", +"settings.tokenmanagement.UpdatePermissions": "PATCH", +"settings.tokenmanagement.UpdateTokenManagement": "PATCH", +"settings.tokenmanagement.internalList": "GET", +"settings.tokens.Create": "POST", +"settings.tokens.Delete": "POST", +"settings.tokens.Update": "PATCH", +"settings.tokens.internalList": "GET", +"settings.workspaceconf.GetStatus": "GET", +"settings.workspaceconf.SetStatus": "PATCH", +"settings.workspacenetworkconfiguration.GetWorkspaceNetworkOptionRpc": "GET", +"settings.workspacenetworkconfiguration.UpdateWorkspaceNetworkOptionRpc": "PUT", +"settingsv2.accountsettingsv2.GetPublicAccountSetting": "GET", +"settingsv2.accountsettingsv2.GetPublicAccountUserPreference": "GET", +"settingsv2.accountsettingsv2.PatchPublicAccountSetting": "PATCH", +"settingsv2.accountsettingsv2.PatchPublicAccountUserPreference": "PATCH", +"settingsv2.accountsettingsv2.internalListAccountSettingsMetadata": "GET", +"settingsv2.accountsettingsv2.internalListAccountUserPreferencesMetadata": "GET", +"settingsv2.workspacesettingsv2.GetPublicWorkspaceSetting": "GET", +"settingsv2.workspacesettingsv2.PatchPublicWorkspaceSetting": "PATCH", +"settingsv2.workspacesettingsv2.internalListWorkspaceSettingsMetadata": "GET", +"sharing.providers.Create": "POST", +"sharing.providers.Delete": "DELETE", +"sharing.providers.Get": "GET", +"sharing.providers.ListProviderShareAssets": "GET", +"sharing.providers.Update": "PATCH", +"sharing.providers.internalList": "GET", +"sharing.providers.internalListShares": "GET", +"sharing.recipientactivation.GetActivationUrlInfo": "GET", +"sharing.recipientactivation.RetrieveToken": "GET", +"sharing.recipientfederationpolicies.Create": "POST", +"sharing.recipientfederationpolicies.Delete": "DELETE", +"sharing.recipientfederationpolicies.GetFederationPolicy": "GET", +"sharing.recipientfederationpolicies.internalList": "GET", +"sharing.recipients.Create": "POST", +"sharing.recipients.Delete": "DELETE", +"sharing.recipients.Get": "GET", +"sharing.recipients.RotateToken": "POST", +"sharing.recipients.SharePermissions": "GET", +"sharing.recipients.Update": "PATCH", +"sharing.recipients.internalList": "GET", +"sharing.shares.Create": "POST", +"sharing.shares.Delete": "DELETE", +"sharing.shares.Get": "GET", +"sharing.shares.SharePermissions": "GET", +"sharing.shares.Update": "PATCH", +"sharing.shares.UpdatePermissions": "PATCH", +"sharing.shares.internalListShares": "GET", +"sql.alerts.Create": "POST", +"sql.alerts.Delete": "DELETE", +"sql.alerts.Get": "GET", +"sql.alerts.Update": "PATCH", +"sql.alerts.internalList": "GET", +"sql.alertslegacy.Create": "POST", +"sql.alertslegacy.Delete": "DELETE", +"sql.alertslegacy.Get": "GET", +"sql.alertslegacy.List": "GET", +"sql.alertslegacy.Update": "PUT", +"sql.alertsv2.CreateAlert": "POST", +"sql.alertsv2.GetAlert": "GET", +"sql.alertsv2.TrashAlert": "DELETE", +"sql.alertsv2.UpdateAlert": "PATCH", +"sql.alertsv2.internalListAlerts": "GET", +"sql.dashboards.Delete": "DELETE", +"sql.dashboards.Get": "GET", +"sql.dashboards.Restore": "POST", +"sql.dashboards.Update": "POST", +"sql.dashboards.internalList": "GET", +"sql.dashboardwidgets.Create": "POST", +"sql.dashboardwidgets.Delete": "DELETE", +"sql.dashboardwidgets.Update": "POST", +"sql.datasources.List": "GET", +"sql.dbsqlpermissions.Get": "GET", +"sql.dbsqlpermissions.Set": "POST", +"sql.dbsqlpermissions.TransferOwnership": "POST", +"sql.queries.Create": "POST", +"sql.queries.Delete": "DELETE", +"sql.queries.Get": "GET", +"sql.queries.Update": "PATCH", +"sql.queries.internalList": "GET", +"sql.queries.internalListVisualizations": "GET", +"sql.querieslegacy.Create": "POST", +"sql.querieslegacy.Delete": "DELETE", +"sql.querieslegacy.Get": "GET", +"sql.querieslegacy.Restore": "POST", +"sql.querieslegacy.Update": "POST", +"sql.querieslegacy.internalList": "GET", +"sql.queryhistory.List": "GET", +"sql.queryvisualizations.Create": "POST", +"sql.queryvisualizations.Delete": "DELETE", +"sql.queryvisualizations.Update": "PATCH", +"sql.queryvisualizationslegacy.Create": "POST", +"sql.queryvisualizationslegacy.Delete": "DELETE", +"sql.queryvisualizationslegacy.Update": "POST", +"sql.redashconfig.GetConfig": "GET", +"sql.statementexecution.CancelExecution": "POST", +"sql.statementexecution.ExecuteStatement": "POST", +"sql.statementexecution.GetStatement": "GET", +"sql.statementexecution.GetStatementResultChunkN": "GET", +"sql.warehouses.Create": "POST", +"sql.warehouses.CreateDefaultWarehouseOverride": "POST", +"sql.warehouses.Delete": "DELETE", +"sql.warehouses.DeleteDefaultWarehouseOverride": "DELETE", +"sql.warehouses.Edit": "POST", +"sql.warehouses.Get": "GET", +"sql.warehouses.GetDefaultWarehouseOverride": "GET", +"sql.warehouses.GetPermissionLevels": "GET", +"sql.warehouses.GetPermissions": "GET", +"sql.warehouses.GetWorkspaceWarehouseConfig": "GET", +"sql.warehouses.SetPermissions": "PUT", +"sql.warehouses.SetWorkspaceWarehouseConfig": "PUT", +"sql.warehouses.Start": "POST", +"sql.warehouses.Stop": "POST", +"sql.warehouses.UpdateDefaultWarehouseOverride": "PATCH", +"sql.warehouses.UpdatePermissions": "PATCH", +"sql.warehouses.internalList": "GET", +"sql.warehouses.internalListDefaultWarehouseOverrides": "GET", +"supervisoragents.supervisoragents.CreateExample": "POST", +"supervisoragents.supervisoragents.CreateSupervisorAgent": "POST", +"supervisoragents.supervisoragents.CreateTool": "POST", +"supervisoragents.supervisoragents.DeleteExample": "DELETE", +"supervisoragents.supervisoragents.DeleteSupervisorAgent": "DELETE", +"supervisoragents.supervisoragents.DeleteTool": "DELETE", +"supervisoragents.supervisoragents.GetExample": "GET", +"supervisoragents.supervisoragents.GetPermissionLevels": "GET", +"supervisoragents.supervisoragents.GetPermissions": "GET", +"supervisoragents.supervisoragents.GetSupervisorAgent": "GET", +"supervisoragents.supervisoragents.GetTool": "GET", +"supervisoragents.supervisoragents.SetPermissions": "PUT", +"supervisoragents.supervisoragents.UpdateExample": "PATCH", +"supervisoragents.supervisoragents.UpdatePermissions": "PATCH", +"supervisoragents.supervisoragents.UpdateSupervisorAgent": "PATCH", +"supervisoragents.supervisoragents.UpdateTool": "PATCH", +"supervisoragents.supervisoragents.internalListExamples": "GET", +"supervisoragents.supervisoragents.internalListSupervisorAgents": "GET", +"supervisoragents.supervisoragents.internalListTools": "GET", +"tags.tagpolicies.CreateTagPolicy": "POST", +"tags.tagpolicies.DeleteTagPolicy": "DELETE", +"tags.tagpolicies.GetTagPolicy": "GET", +"tags.tagpolicies.UpdateTagPolicy": "PATCH", +"tags.tagpolicies.internalListTagPolicies": "GET", +"tags.workspaceentitytagassignments.CreateTagAssignment": "POST", +"tags.workspaceentitytagassignments.DeleteTagAssignment": "DELETE", +"tags.workspaceentitytagassignments.GetTagAssignment": "GET", +"tags.workspaceentitytagassignments.UpdateTagAssignment": "PATCH", +"tags.workspaceentitytagassignments.internalListTagAssignments": "GET", +"vectorsearch.vectorsearchendpoints.CreateEndpoint": "POST", +"vectorsearch.vectorsearchendpoints.DeleteEndpoint": "DELETE", +"vectorsearch.vectorsearchendpoints.GetEndpoint": "GET", +"vectorsearch.vectorsearchendpoints.GetPermissionLevels": "GET", +"vectorsearch.vectorsearchendpoints.GetPermissions": "GET", +"vectorsearch.vectorsearchendpoints.PatchEndpoint": "PATCH", +"vectorsearch.vectorsearchendpoints.RetrieveUserVisibleMetrics": "POST", +"vectorsearch.vectorsearchendpoints.SetPermissions": "PUT", +"vectorsearch.vectorsearchendpoints.UpdateEndpointBudgetPolicy": "PATCH", +"vectorsearch.vectorsearchendpoints.UpdateEndpointCustomTags": "PATCH", +"vectorsearch.vectorsearchendpoints.UpdatePermissions": "PATCH", +"vectorsearch.vectorsearchendpoints.internalListEndpoints": "GET", +"vectorsearch.vectorsearchindexes.CreateIndex": "POST", +"vectorsearch.vectorsearchindexes.DeleteDataVectorIndex": "DELETE", +"vectorsearch.vectorsearchindexes.DeleteIndex": "DELETE", +"vectorsearch.vectorsearchindexes.GetIndex": "GET", +"vectorsearch.vectorsearchindexes.QueryIndex": "POST", +"vectorsearch.vectorsearchindexes.QueryNextPage": "POST", +"vectorsearch.vectorsearchindexes.ScanIndex": "POST", +"vectorsearch.vectorsearchindexes.SyncIndex": "POST", +"vectorsearch.vectorsearchindexes.UpsertDataVectorIndex": "POST", +"vectorsearch.vectorsearchindexes.internalListIndexes": "GET", +"workspace.gitcredentials.Create": "POST", +"workspace.gitcredentials.Delete": "DELETE", +"workspace.gitcredentials.Get": "GET", +"workspace.gitcredentials.Update": "PATCH", +"workspace.gitcredentials.internalList": "GET", +"workspace.repos.Create": "POST", +"workspace.repos.Delete": "DELETE", +"workspace.repos.Get": "GET", +"workspace.repos.GetPermissionLevels": "GET", +"workspace.repos.GetPermissions": "GET", +"workspace.repos.SetPermissions": "PUT", +"workspace.repos.Update": "PATCH", +"workspace.repos.UpdatePermissions": "PATCH", +"workspace.repos.internalList": "GET", +"workspace.secrets.CreateScope": "POST", +"workspace.secrets.DeleteAcl": "POST", +"workspace.secrets.DeleteScope": "POST", +"workspace.secrets.DeleteSecret": "POST", +"workspace.secrets.GetAcl": "GET", +"workspace.secrets.GetSecret": "GET", +"workspace.secrets.PutAcl": "POST", +"workspace.secrets.PutSecret": "POST", +"workspace.secrets.internalListAcls": "GET", +"workspace.secrets.internalListScopes": "GET", +"workspace.secrets.internalListSecrets": "GET", +"workspace.workspace.Delete": "POST", +"workspace.workspace.Export": "GET", +"workspace.workspace.GetPermissionLevels": "GET", +"workspace.workspace.GetPermissions": "GET", +"workspace.workspace.GetStatus": "GET", +"workspace.workspace.Import": "POST", +"workspace.workspace.Mkdirs": "POST", +"workspace.workspace.SetPermissions": "PUT", +"workspace.workspace.UpdatePermissions": "PATCH", +"workspace.workspace.internalList": "GET" +} \ No newline at end of file diff --git a/internal/cligen/legacybind.go b/internal/cligen/legacybind.go new file mode 100644 index 00000000000..8cad5148547 --- /dev/null +++ b/internal/cligen/legacybind.go @@ -0,0 +1,206 @@ +package main + +import ( + "go/ast" + "go/parser" + "go/token" + "os" + "path/filepath" + "reflect" + "strconv" + "strings" +) + +// legacyPackages are hand-written CLI clients for APIs that sdk-go does not +// have. They keep the previous SDK's method and type names (value fields, +// enums implementing pflag.Value), so commands bind to them the way they +// bound to the previous SDK. +var legacyPackages = []struct { + service, dir, alias, clientField string +}{ + {"Workspace", "libs/workspaceapi", "workspaceapi", "Workspace"}, + {"QualityMonitors", "libs/qualitymonitors", "qualitymonitors", "QualityMonitors"}, + {"BundleDeployments", "libs/bundledeployments", "bundledeployments", "BundleDeployments"}, +} + +type legacyPkg struct { + alias, importPath, clientField string + methods map[string]*legacyMethod + structs map[string]*MirrorStruct + // allFields are all fields of each struct, including untagged ones. + allFields map[string][]*MirrorField + enums map[string]bool +} + +type legacyMethod struct { + name, request string + // kind is "resp", "err" or "listing". + kind string +} + +func loadLegacy(repoRoot string) (map[string]*legacyPkg, error) { + out := map[string]*legacyPkg{} + for _, lp := range legacyPackages { + p := &legacyPkg{ + alias: lp.alias, + importPath: "github.com/databricks/cli/" + lp.dir, + clientField: lp.clientField, + methods: map[string]*legacyMethod{}, + structs: map[string]*MirrorStruct{}, + allFields: map[string][]*MirrorField{}, + enums: map[string]bool{}, + } + files, err := filepath.Glob(filepath.Join(repoRoot, lp.dir, "*.go")) + if err != nil { + return nil, err + } + for _, fn := range files { + if strings.HasSuffix(fn, "_test.go") { + continue + } + src, err := os.ReadFile(fn) + if err != nil { + return nil, err + } + f, err := parser.ParseFile(token.NewFileSet(), fn, src, 0) + if err != nil { + return nil, err + } + for _, d := range f.Decls { + switch d := d.(type) { + case *ast.FuncDecl: + if d.Recv == nil || !d.Name.IsExported() { + continue + } + if d.Name.Name == "Set" { + p.enums[strings.TrimPrefix(exprString(d.Recv.List[0].Type), "*")] = true + continue + } + params := d.Type.Params.List + if len(params) < 1 || exprString(params[0].Type) != "context.Context" { + continue + } + m := &legacyMethod{name: d.Name.Name, kind: "resp"} + if len(params) == 2 && len(params[1].Names) <= 1 { + if id, ok := params[1].Type.(*ast.Ident); ok { + m.request = id.Name + } + } + if len(params) > 2 || len(params) == 2 && m.request == "" { + continue + } + res := d.Type.Results.List + switch { + case len(res) == 1 && exprString(res[0].Type) == "error": + m.kind = "err" + case len(res) == 1 && strings.HasPrefix(exprString(res[0].Type), "listing.Iterator["): + m.kind = "listing" + case len(res) != 2: + continue + } + p.methods[m.name] = m + case *ast.GenDecl: + if d.Tok != token.TYPE { + continue + } + for _, spec := range d.Specs { + ts := spec.(*ast.TypeSpec) + st, ok := ts.Type.(*ast.StructType) + if !ok { + continue + } + ms := &MirrorStruct{byJSON: map[string]*MirrorField{}} + for _, fl := range st.Fields.List { + for _, n := range fl.Names { + p.allFields[ts.Name.Name] = append(p.allFields[ts.Name.Name], &MirrorField{GoName: n.Name, Type: exprString(fl.Type)}) + } + if fl.Tag == nil || len(fl.Names) != 1 { + continue + } + tag, _ := strconv.Unquote(fl.Tag.Value) + name, _, _ := strings.Cut(reflect.StructTag(tag).Get("json"), ",") + if name == "" || name == "-" { + // Query parameters are tagged for the query encoder only. + name, _, _ = strings.Cut(reflect.StructTag(tag).Get("url"), ",") + } + if name == "" || name == "-" { + continue + } + mf := &MirrorField{GoName: fl.Names[0].Name, JSON: name, Type: exprString(fl.Type)} + ms.Fields = append(ms.Fields, mf) + ms.byJSON[name] = mf + } + p.structs[ts.Name.Name] = ms + } + } + } + } + out[lp.service] = p + } + return out, nil +} + +// bindLegacy binds m to a hand-written client method with the same name. +func (b *MethodBind) bindLegacy(p *legacyPkg) bool { + lm := p.methods[b.method.Name] + if lm == nil { + return false + } + if b.method.Pagination != nil && lm.kind != "listing" { + return false + } + b.Kind = "legacy" + b.legacy = p + b.legacyM = lm + req := p.structs[lm.request] + if req == nil { + return true + } + var body *MirrorStruct + if rb := b.method.RequestBodyField; rb != nil { + if bf := req.byJSON[rb.Name]; bf != nil { + b.bodyGo = bf.GoName + b.bodyPtr = strings.HasPrefix(bf.Type, "*") + b.bodyType = strings.TrimPrefix(bf.Type, "*") + body = p.structs[b.bodyType] + } + } + for _, f := range b.allFields() { + if _, ok := b.fields[f.Name]; ok { + continue + } + fb := &fieldBind{} + b.fields[f.Name] = fb + mf, prefix := req.byJSON[f.Name], "" + if body != nil && !f.IsPath && !f.IsQuery { + if bmf := body.byJSON[f.Name]; bmf != nil { + mf, prefix = bmf, "."+b.bodyGo + } + } + if mf == nil { + // Path parameters carry no wire name; the hand-written types keep + // the previous SDK's Go field names. + for _, rf := range p.allFields[lm.request] { + if rf.GoName == f.PascalName() { + mf = rf + } + } + } + if mf == nil { + continue + } + fb.expr = prefix + "." + mf.GoName + fb.ptr = strings.HasPrefix(mf.Type, "*") + base := strings.TrimPrefix(mf.Type, "*") + switch { + case base == "string" || base == "bool" || base == "int" || base == "int64" || base == "float64": + fb.kind = base + case p.enums[base]: + fb.kind = "legacyenum" + fb.enumType = p.alias + "." + base + default: + fb.kind = "complex" + } + } + return true +} diff --git a/internal/cligen/model.go b/internal/cligen/model.go index ae5ce44dd63..cd24bc9a1e9 100644 --- a/internal/cligen/model.go +++ b/internal/cligen/model.go @@ -3,6 +3,7 @@ package main import ( "fmt" "slices" + "strings" ) // This file defines the CLI-side view of the "commands" block of the cli.json @@ -163,6 +164,9 @@ type MethodJSON struct { Pagination *PaginationJSON `json:"pagination,omitempty"` Wait *WaitJSON `json:"wait,omitempty"` LongRunningOperation *LROJSON `json:"long_running_operation,omitempty"` + + // Bind is computed from the sdk-go sources (see bind.go). + Bind *MethodBind `json:"-"` } func (m *MethodJSON) KebabName() string { return kebabName(m.Name) } @@ -353,3 +357,48 @@ func (c *CommandsBlock) Resolve() error { } return nil } + +// FlagUsage is the help text of a flag for this field. +func (f *FieldJSON) FlagUsage(hasFieldMask bool) string { + u := strings.TrimSuffix(strings.ReplaceAll(f.Summary(), "`", ""), ".") + if f.Summary() != "" { + u += "." + } + if hasFieldMask { + u += " Wire name: '" + f.Name + "'." + } + return u +} + +// EnumFlagUsage is the help text of an enum flag for this field. +func (f *FieldJSON) EnumFlagUsage(hasFieldMask bool) string { + u := strings.TrimSuffix(strings.ReplaceAll(f.Summary(), "`", ""), ".") + if f.Summary() != "" { + u += ". " + } + u += "Supported values: " + printArray(f.Entity.Enum) + if hasFieldMask { + u += ". Wire name: '" + f.Name + "'." + } + return u +} + +func printArray(es []*EnumEntryJSON) string { + var sb strings.Builder + sb.WriteString("[") + if len(es) <= 5 { + for i, e := range es { + if i > 0 { + sb.WriteString(", ") + } + sb.WriteString(e.Content) + } + } else { + for _, e := range es { + sb.WriteString("\n " + e.Content + ",") + } + sb.WriteString("\n") + } + sb.WriteString("]") + return sb.String() +} diff --git a/internal/cligen/sdkbind.go b/internal/cligen/sdkbind.go new file mode 100644 index 00000000000..6e0c6d260f1 --- /dev/null +++ b/internal/cligen/sdkbind.go @@ -0,0 +1,637 @@ +package main + +// This file binds cli.json methods (old SDK naming) to sdk-go client methods. +// +// cli.json describes commands in terms of the REST API: the path, the request +// fields by wire name and their flags. The generated commands call sdk-go +// clients and bind flags and --json to the JSON mirror types in libs/sdktypes, +// so for every method we need the sdk-go module, client method, request and +// response types, and the Go field name behind every wire field. All of this is +// read from the sources of the sdk-go modules required by go.mod and from the +// generated mirrors, matching methods by their normalized HTTP path. + +import ( + "cmp" + _ "embed" + "encoding/json" + "fmt" + "go/ast" + "go/parser" + "go/printer" + "go/token" + "os" + "os/exec" + "path/filepath" + "reflect" + "regexp" + "slices" + "strconv" + "strings" +) + +const ( + sdkModulePrefix = "github.com/databricks/sdk-go/" + mirrorPrefix = "github.com/databricks/cli/libs/sdktypes/" + sdkClientsFile = "libs/sdkclients/services.go" + sdkTypesDir = "libs/sdktypes" + mirrorTypesFile = "types.generated.go" + sdkClientFileName = "client.go" +) + +// SdkPackage is one versioned sdk-go package (e.g. jobs/v2). +type SdkPackage struct { + // Rel is the path relative to the sdk-go module root, e.g. "uc/tables/v1". + Rel string + ImportPath string + MirrorPath string + MirrorAlias string + SdkAlias string + ClientField string + + methods map[string]*SdkMethod + structs map[string]*MirrorStruct + // models are the sdk-go model structs, for requests without a mirror (no + // JSON body); their JSON names are only known for query parameters. + models map[string]*MirrorStruct +} + +// MirrorStruct is a struct type of a libs/sdktypes mirror package. +type MirrorStruct struct { + Fields []*MirrorField + byJSON map[string]*MirrorField +} + +type MirrorField struct { + GoName string + JSON string + // Type is the Go type expression as written in the mirror package. + Type string +} + +// SdkMethod is an exported method of an sdk-go client. +type SdkMethod struct { + Pkg *SdkPackage + Name string + // Request is the request type name, "" for methods without a request. + Request string + // Kind is "resp", "err", "iter", "waiter" or "op". + Kind string + // Result is the response type (resp), or what Wait returns (waiter, op). + Result string + // Iter is the name of the companion ...Iter method and ItemType its element type. + Iter string + ItemType string + // WaiterIDs name the getters of a waiter's identifiers, e.g. "GetRunId". + WaiterIDs []string + // pollRequest is the request type of the method a waiter polls. + pollRequest string + // baseResult is the response type of the call that starts a wait. + baseResult string + // hasBody is set when a JSON body is sent; bodyGo is the request field + // sent as the body, or "" for the whole request. + hasBody bool + bodyGo string + + verb string + path string + pathFields []string + // queryFields maps query parameter names to request Go fields. + queryFields map[string]string +} + +type sdkIndex struct { + pkgs []*SdkPackage + byPath map[string][]*SdkMethod +} + +func goListDirs(pkgs []string) (map[string]string, error) { + args := append([]string{"list", "-f", "{{.ImportPath}} {{.Dir}}"}, pkgs...) + out, err := exec.Command("go", args...).Output() + if err != nil { + if ee, ok := err.(*exec.ExitError); ok { + return nil, fmt.Errorf("go list: %w: %s", err, ee.Stderr) + } + return nil, fmt.Errorf("go list: %w", err) + } + dirs := map[string]string{} + for line := range strings.SplitSeq(strings.TrimSpace(string(out)), "\n") { + p, d, ok := strings.Cut(line, " ") + if ok { + dirs[p] = d + } + } + return dirs, nil +} + +// loadSdkIndex reads libs/sdkclients/services.go for the client field of every +// sdk-go package, the sdk-go client sources and the mirror types. +func loadSdkIndex(repoRoot string) (*sdkIndex, error) { + fset := token.NewFileSet() + sf, err := parser.ParseFile(fset, filepath.Join(repoRoot, sdkClientsFile), nil, 0) + if err != nil { + return nil, err + } + aliasToPath := map[string]string{} + for _, imp := range sf.Imports { + p, _ := strconv.Unquote(imp.Path.Value) + if !strings.HasPrefix(p, sdkModulePrefix) || imp.Name == nil { + continue + } + aliasToPath[imp.Name.Name] = p + } + idx := &sdkIndex{byPath: map[string][]*SdkMethod{}} + var importPaths []string + ast.Inspect(sf, func(n ast.Node) bool { + ts, ok := n.(*ast.TypeSpec) + if !ok || ts.Name.Name != "services" { + return true + } + for _, f := range ts.Type.(*ast.StructType).Fields.List { + sel := f.Type.(*ast.StarExpr).X.(*ast.SelectorExpr) + alias := sel.X.(*ast.Ident).Name + p := aliasToPath[alias] + rel := strings.TrimPrefix(p, sdkModulePrefix) + idx.pkgs = append(idx.pkgs, &SdkPackage{ + Rel: rel, + ImportPath: p, + MirrorPath: mirrorPrefix + rel, + MirrorAlias: alias, + SdkAlias: "sdk" + alias, + ClientField: f.Names[0].Name, + methods: map[string]*SdkMethod{}, + structs: map[string]*MirrorStruct{}, + models: map[string]*MirrorStruct{}, + }) + importPaths = append(importPaths, p) + } + return false + }) + dirs, err := goListDirs(importPaths) + if err != nil { + return nil, err + } + for _, p := range idx.pkgs { + if err := p.loadMethods(dirs[p.ImportPath]); err != nil { + return nil, fmt.Errorf("%s: %w", p.Rel, err) + } + if err := p.loadModels(filepath.Join(dirs[p.ImportPath], "model.go")); err != nil { + return nil, fmt.Errorf("%s: %w", p.Rel, err) + } + if err := p.loadMirror(filepath.Join(repoRoot, sdkTypesDir, p.Rel, mirrorTypesFile)); err != nil { + return nil, fmt.Errorf("%s: %w", p.Rel, err) + } + for _, m := range p.methods { + if m.path != "" && m.Kind != "iter" { + idx.byPath[m.path] = append(idx.byPath[m.path], m) + } + } + } + for k := range idx.byPath { + ms := idx.byPath[k] + slices.SortFunc(ms, func(a, b *SdkMethod) int { + if a.Pkg.Rel != b.Pkg.Rel { + return cmp.Compare(a.Pkg.Rel, b.Pkg.Rel) + } + return cmp.Compare(a.Name, b.Name) + }) + } + return idx, nil +} + +func exprString(e ast.Expr) string { + var sb strings.Builder + _ = printer.Fprint(&sb, token.NewFileSet(), e) + return sb.String() +} + +func (p *SdkPackage) loadMirror(path string) error { + f, err := parser.ParseFile(token.NewFileSet(), path, nil, 0) + if err != nil { + return err + } + for _, d := range f.Decls { + gd, ok := d.(*ast.GenDecl) + if !ok || gd.Tok != token.TYPE { + continue + } + for _, spec := range gd.Specs { + ts := spec.(*ast.TypeSpec) + st, ok := ts.Type.(*ast.StructType) + if !ok { + continue + } + ms := &MirrorStruct{byJSON: map[string]*MirrorField{}} + for _, fl := range st.Fields.List { + if fl.Tag == nil || len(fl.Names) != 1 { + continue + } + tag, _ := strconv.Unquote(fl.Tag.Value) + name, _, _ := strings.Cut(reflect.StructTag(tag).Get("json"), ",") + if name == "" || name == "-" { + continue + } + mf := &MirrorField{GoName: fl.Names[0].Name, JSON: name, Type: exprString(fl.Type)} + ms.Fields = append(ms.Fields, mf) + ms.byJSON[name] = mf + } + p.structs[ts.Name.Name] = ms + } + } + return nil +} + +func (p *SdkPackage) loadModels(path string) error { + f, err := parser.ParseFile(token.NewFileSet(), path, nil, 0) + if err != nil { + return err + } + for _, d := range f.Decls { + gd, ok := d.(*ast.GenDecl) + if !ok || gd.Tok != token.TYPE { + continue + } + for _, spec := range gd.Specs { + ts := spec.(*ast.TypeSpec) + st, ok := ts.Type.(*ast.StructType) + if !ok { + continue + } + ms := &MirrorStruct{byJSON: map[string]*MirrorField{}} + for _, fl := range st.Fields.List { + for _, n := range fl.Names { + ms.Fields = append(ms.Fields, &MirrorField{GoName: n.Name, Type: exprString(fl.Type)}) + } + } + p.models[ts.Name.Name] = ms + } + } + return nil +} + +var reqIdentRe = regexp.MustCompile(`^\*?req\.([A-Z][\w.]*)$`) + +func (p *SdkPackage) loadMethods(dir string) error { + f, err := parser.ParseFile(token.NewFileSet(), filepath.Join(dir, sdkClientFileName), nil, 0) + if err != nil { + return err + } + all := map[string]*ast.FuncDecl{} + waiters := map[string]*ast.FuncDecl{} + for _, d := range f.Decls { + fd, ok := d.(*ast.FuncDecl) + if !ok || fd.Recv == nil { + continue + } + recv := exprString(fd.Recv.List[0].Type) + switch { + case recv == "*internalClient": + all[fd.Name.Name] = fd + case strings.HasSuffix(recv, "Waiter") || strings.HasSuffix(recv, "Operation"): + waiters[strings.TrimPrefix(recv, "*")+"."+fd.Name.Name] = fd + } + } + var impl *ast.FuncDecl + for name, fd := range all { + if !ast.IsExported(name) { + continue + } + m := &SdkMethod{Pkg: p, Name: name} + params := fd.Type.Params.List + if len(params) >= 2 { + if id, ok := params[1].Type.(*ast.Ident); ok { + m.Request = id.Name + } + } + results := fd.Type.Results.List + first := exprString(results[0].Type) + switch { + case len(results) == 1: + if strings.HasPrefix(first, "iter.Seq2[") { + m.Kind = "iter" + m.ItemType = strings.TrimPrefix(strings.TrimSuffix(strings.TrimPrefix(first, "iter.Seq2["), ", error]"), "*") + } else { + m.Kind = "err" + } + case strings.HasSuffix(first, "Waiter"): + m.Kind = "waiter" + m.Result = waitResult(waiters, strings.TrimPrefix(first, "*")) + m.pollRequest = waiterPollRequest(f, strings.TrimPrefix(first, "*")) + for _, d := range f.Decls { + fd, ok := d.(*ast.FuncDecl) + if !ok || fd.Recv == nil || exprString(fd.Recv.List[0].Type) != first { + continue + } + if strings.HasPrefix(fd.Name.Name, "Get") && fd.Type.Results.NumFields() == 1 { + m.WaiterIDs = append(m.WaiterIDs, fd.Name.Name) + } + } + case strings.HasSuffix(first, "Operation"): + m.Kind = "op" + m.Result = waitResult(waiters, strings.TrimPrefix(first, "*")) + default: + m.Kind = "resp" + m.Result = strings.TrimPrefix(first, "*") + } + impl = fd + ast.Inspect(fd.Body, func(n ast.Node) bool { + call, ok := n.(*ast.CallExpr) + if !ok { + return true + } + if sel, ok := call.Fun.(*ast.SelectorExpr); ok { + if x, ok := sel.X.(*ast.Ident); ok && x.Name == "c" && strings.HasSuffix(sel.Sel.Name, "Base") { + if b := all[sel.Sel.Name]; b != nil { + impl = b + } + } + } + return true + }) + if impl != fd && impl.Type.Results.NumFields() == 2 { + m.baseResult = strings.TrimPrefix(exprString(impl.Type.Results.List[0].Type), "*") + } + m.verb, m.path, m.pathFields = httpRoute(impl) + m.queryFields = queryRoute(impl) + m.hasBody, m.bodyGo = bodyRoute(impl) + p.methods[name] = m + } + for name, m := range p.methods { + if it, ok := p.methods[name+"Iter"]; ok && it.Kind == "iter" { + m.Iter = it.Name + m.ItemType = it.ItemType + } + } + return nil +} + +// waiterPollRequest returns the request type of the waiter's poll function, +// from its `poll func(context.Context, GetXRequest, ...call.Option) (...)` field. +func waiterPollRequest(f *ast.File, waiter string) string { + req := "" + ast.Inspect(f, func(n ast.Node) bool { + ts, ok := n.(*ast.TypeSpec) + if !ok || ts.Name.Name != waiter { + return true + } + for _, fl := range ts.Type.(*ast.StructType).Fields.List { + ft, ok := fl.Type.(*ast.FuncType) + if ok && len(fl.Names) == 1 && fl.Names[0].Name == "poll" && len(ft.Params.List) >= 2 { + req = exprString(ft.Params.List[1].Type) + } + } + return false + }) + return req +} + +func waitResult(waiters map[string]*ast.FuncDecl, typ string) string { + if wf := waiters[typ+".Wait"]; wf != nil && wf.Type.Results.NumFields() == 2 { + return strings.TrimPrefix(exprString(wf.Type.Results.List[0].Type), "*") + } + return "" +} + +// httpRoute extracts the HTTP verb, the normalized path ("{}" per path +// parameter) and the request field behind every path parameter ("" for the +// implicit account ID) from a generated sdk-go method body. +func httpRoute(fd *ast.FuncDecl) (string, string, []string) { + var verb, path string + var fields []string + ast.Inspect(fd.Body, func(n ast.Node) bool { + switch x := n.(type) { + case *ast.KeyValueExpr: + if k, ok := x.Key.(*ast.Ident); ok && k.Name == "Method" { + if lit, ok := x.Value.(*ast.BasicLit); ok && verb == "" { + verb, _ = strconv.Unquote(lit.Value) + } + } + case *ast.AssignStmt: + if len(x.Lhs) == 1 && exprString(x.Lhs[0]) == "baseURL.Path" { + if lit, ok := x.Rhs[0].(*ast.BasicLit); ok { + path, _ = strconv.Unquote(lit.Value) + } + } + } + return true + }) + if path != "" { + return verb, path, nil + } + var sb strings.Builder + var walk func(stmts []ast.Stmt) + walk = func(stmts []ast.Stmt) { + for _, s := range stmts { + switch x := s.(type) { + case *ast.ExprStmt: + call, ok := x.X.(*ast.CallExpr) + if !ok { + continue + } + sel, ok := call.Fun.(*ast.SelectorExpr) + if !ok || exprString(sel.X) != "pb" { + continue + } + switch sel.Sel.Name { + case "literal": + v, _ := strconv.Unquote(call.Args[0].(*ast.BasicLit).Value) + sb.WriteString(v) + case "singleSegment", "multiSegments": + sb.WriteString("{}") + field := "" + if m := reqIdentRe.FindStringSubmatch(exprString(call.Args[0])); m != nil { + field = m[1] + } + fields = append(fields, field) + } + case *ast.IfStmt: + // `if req.X == nil { pb.singleSegment("") } else { pb.singleSegment(*req.X) }` + if x.Else != nil { + if eb, ok := x.Else.(*ast.BlockStmt); ok { + walk(eb.List) + continue + } + } + walk(x.Body.List) + } + } + } + walk(fd.Body.List) + return verb, sb.String(), fields +} + +// bodyRoute finds the `json.Marshal(wireReq...)` call of a method body. +func bodyRoute(fd *ast.FuncDecl) (bool, string) { + found, field := false, "" + ast.Inspect(fd.Body, func(n ast.Node) bool { + call, ok := n.(*ast.CallExpr) + if !ok || exprString(call.Fun) != "json.Marshal" || len(call.Args) != 1 { + return true + } + arg := exprString(call.Args[0]) + if arg == "wireReq" || strings.HasPrefix(arg, "wireReq.") { + found, field = true, strings.TrimPrefix(strings.TrimPrefix(arg, "wireReq"), ".") + } + return true + }) + return found, field +} + +var queryFieldRe = regexp.MustCompile(`^(?:req|wireReq)\.([A-Z][\w.]*)$`) + +// queryRoute maps query parameter names to request fields from the +// `addQueryValue(queryParams, "name", req.Field)` calls of a method body. +func queryRoute(fd *ast.FuncDecl) map[string]string { + out := map[string]string{} + ast.Inspect(fd.Body, func(n ast.Node) bool { + call, ok := n.(*ast.CallExpr) + if !ok || exprString(call.Fun) != "addQueryValue" || len(call.Args) != 3 { + return true + } + lit, ok := call.Args[1].(*ast.BasicLit) + if !ok { + return true + } + name, _ := strconv.Unquote(lit.Value) + if m := queryFieldRe.FindStringSubmatch(exprString(call.Args[2])); m != nil { + out[name] = m[1] + } + return true + }) + return out +} + +var pathParamRe = regexp.MustCompile(`\{[^}]*\}`) + +func normPath(p string) string { + return pathParamRe.ReplaceAllString(p, "{}") +} + +func pathParams(p string) []string { + var out []string + for _, m := range pathParamRe.FindAllString(p, -1) { + name := strings.Trim(m, "{}") + name = strings.TrimSuffix(name, "...") + name, _, _ = strings.Cut(name, "=") + out = append(out, name) + } + return out +} + +//go:embed http_verbs.json +var httpVerbsJSON []byte + +// httpVerbs maps ".." to the HTTP verb of +// every method of the previous SDK. cli.json carries paths but no verbs; this +// table was extracted once from databricks-sdk-go v0.188.0 (service/*/impl.go) +// and is frozen: methods added to cli.json later need an entry here. +var httpVerbs = func() map[string]string { + m := map[string]string{} + if err := json.Unmarshal(httpVerbsJSON, &m); err != nil { + panic(err) + } + return m +}() + +func methodVerb(svc *ServiceJSON, m *MethodJSON) string { + return httpVerbs[svc.Package.Name+"."+strings.ToLower(svc.Name)+"."+m.Name] +} + +func leadingWord(s string) string { + for i := 1; i < len(s); i++ { + if s[i] >= 'A' && s[i] <= 'Z' { + return s[:i] + } + } + return s +} + +// pathMatch reports whether an sdk-go path matches a cli.json path. Exact +// matches return no constants. Otherwise an sdk-go parameter may stand for a +// literal segment of the cli.json path (the typed permission endpoints, e.g. +// /permissions/jobs/{job_id} served by /permissions/{type}/{id}); the literal +// is returned for that parameter position. +func pathMatch(sdkPath, cliPath string) (bool, map[int]string) { + if sdkPath == cliPath { + return true, nil + } + ss := strings.Split(sdkPath, "/") + cs := strings.Split(cliPath, "/") + if len(ss) != len(cs) { + return false, nil + } + consts := map[int]string{} + param := 0 + for i := range ss { + switch { + case ss[i] == "{}" && cs[i] == "{}": + param++ + case ss[i] == "{}": + consts[param] = cs[i] + param++ + case ss[i] != cs[i]: + return false, nil + } + } + return len(consts) > 0, consts +} + +// match finds the sdk-go method for a cli.json method by HTTP verb and path. +// It also returns literal values for sdk-go path parameters that cli.json has +// as fixed path segments. +func (idx *sdkIndex) match(svc *ServiceJSON, m *MethodJSON) (*SdkMethod, map[int]string) { + verb := methodVerb(svc, m) + np := normPath(m.Path) + type cand struct { + m *SdkMethod + consts map[int]string + } + var cands []cand + for _, c := range idx.byPath[np] { + cands = append(cands, cand{c, nil}) + } + if len(cands) == 0 { + for p, ms := range idx.byPath { + if ok, consts := pathMatch(p, np); ok && consts != nil { + for _, c := range ms { + cands = append(cands, cand{c, consts}) + } + } + } + } + var best cand + bestScore := -1 + for _, c := range cands { + if verb != "" && c.m.verb != verb { + continue + } + score := 0 + switch { + case c.m.Name == m.Name: + score += 100 + case strings.HasPrefix(c.m.Name, m.Name): + score += 60 + case leadingWord(c.m.Name) == leadingWord(m.Name): + score += 40 + } + if m.Pagination != nil && c.m.Iter != "" { + score += 10 + } + // Prefer a stable choice when several modules serve the same route. + if score > bestScore || score == bestScore && c.m.Pkg.Rel+c.m.Name < best.m.Pkg.Rel+best.m.Name { + best, bestScore = c, score + } + } + if best.m == nil { + return nil, nil + } + return best.m, best.consts +} + +// debugBindings prints the binding of every method to stderr when +// CLIGEN_DEBUG is set. +func debugf(format string, args ...any) { + //nolint:forbidigo + if os.Getenv("CLIGEN_DEBUG") != "" { + fmt.Fprintf(os.Stderr, format, args...) + } +} diff --git a/internal/cligen/templates/service.go.tmpl b/internal/cligen/templates/service.go.tmpl index f17bcedde67..359ab5322af 100644 --- a/internal/cligen/templates/service.go.tmpl +++ b/internal/cligen/templates/service.go.tmpl @@ -9,16 +9,24 @@ import ( "strings" "time" + "maps" + "net/url" + "strconv" + + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdgen" "github.com/databricks/cli/libs/flags" + "github.com/databricks/cli/libs/utils" "github.com/databricks/cli/cmd/root" - "github.com/databricks/databricks-sdk-go/experimental/api" - "github.com/databricks/databricks-sdk-go/common/types/duration" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/service/{{.Package.Name}}" + sdkcoretypes "github.com/databricks/sdk-go/core/types" + "github.com/databricks/sdk-go/options/lro" "github.com/spf13/cobra" + {{range .BindImports}} + {{.}} + {{- end}} {{range .Subservices -}} {{.SnakeName}} "github.com/databricks/cli/cmd/{{ if .ParentService.IsAccounts }}account{{ else }}workspace{{ end }}/{{.KebabName}}" @@ -131,8 +139,8 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var {{.CamelName}}Overrides []func( *cobra.Command, - {{- if not .IsLegacyEmptyRequest }} - *{{$.Package.Name}}.{{.Request.PascalName}}, + {{- if and (not .IsLegacyEmptyRequest) .Bind.HasRequest }} + *{{.Bind.ReqType}}, {{- end }} ) @@ -144,10 +152,13 @@ func new{{.PascalName}}() *cobra.Command { {{- $canUseJson := and .CanUseJson (not (in $excludeFromJson .KebabName )) -}} {{- if not .IsLegacyEmptyRequest}} - var {{.CamelName}}Req {{$.Package.Name}}.{{.Request.PascalName}} - {{- if .RequestBodyField }} - {{.CamelName}}Req.{{.RequestBodyField.PascalName}} = {{ if .RequestBodyField.IsOptionalObject }}&{{end}}{{$.Package.Name}}.{{.RequestBodyField.Entity.PascalName}}{} + {{- if .Bind.HasRequest }} + var {{.Bind.ReqVar}} {{.Bind.ReqType}} + {{- with .Bind.ReqInit }} + {{.}} {{- end }} + {{- end }} + {{.Bind.RawDecls}} {{- if $canUseJson}} var {{.CamelName}}Json flags.JsonFlag {{- end}} @@ -213,18 +224,20 @@ func new{{.PascalName}}() *cobra.Command { {{- /* The API field is named "limit" but isn't a declared pagination field (e.g. jobs.List.Limit). Rename to --page-size to avoid colliding with the --limit result capping flag. */ -}} - cmd.Flags().{{template "arg-type" .Entity}}(&{{- template "request-body-obj" (dict "Method" $method "Field" .)}}, "page-size", {{- template "request-body-obj" (dict "Method" $method "Field" .)}}, `{{.Summary | without "`" | trimSuffix "."}}{{if .Summary}}.{{end}}`) + {{$method.Bind.FlagDef . "page-size" (.FlagUsage false)}} + {{- if $method.Bind.Mapped .}} cmd.Flags().Lookup("page-size").Hidden = true + {{- end}} {{else if .Entity.IsObject}}{{if not (eq . $method.RequestBodyField) }}// TODO: complex arg: {{.Name}}{{end}} {{else if .Entity.IsAny }}// TODO: any: {{.Name}} {{else if .Entity.ArrayValue }}// TODO: array: {{.Name}} {{else if .Entity.MapValue }}// TODO: map via StringToStringVar: {{.Name}} {{else if .IsComputed -}} {{else if .IsOutputOnly -}} - {{else if .Entity.Enum }}cmd.Flags().Var(&{{- template "request-body-obj" (dict "Method" $method "Field" .)}}, "{{.KebabName}}", `{{.Summary | without "`" | trimSuffix "."}}{{if .Summary}}. {{end}}Supported values: {{template "printArray" .Entity.Enum}}{{if $hasFieldMask}}. Wire name: '{{.Name}}'.{{end}}`) + {{else if .Entity.Enum }}{{$method.Bind.FlagDef . .KebabName (.EnumFlagUsage $hasFieldMask)}} {{else if or .Entity.IsDuration .Entity.IsTimestamp .Entity.IsFieldMask}} var {{.CamelName}}Param string cmd.Flags().StringVar(&{{.CamelName}}Param, "{{.KebabName}}", {{.CamelName}}Param, `{{.Summary | without "`" | trimSuffix "."}}{{if .Summary}}.{{end}}{{if $hasFieldMask}} Wire name: '{{.Name}}'.{{end}}`) - {{else}}cmd.Flags().{{template "arg-type" .Entity}}(&{{- template "request-body-obj" (dict "Method" $method "Field" .)}}, "{{.KebabName}}", {{- template "request-body-obj" (dict "Method" $method "Field" .)}}, `{{.Summary | without "`" | trimSuffix "."}}{{if .Summary}}.{{end}}{{if $hasFieldMask}} Wire name: '{{.Name}}'.{{end}}`) + {{else}}{{$method.Bind.FlagDef . .KebabName (.FlagUsage $hasFieldMask)}} {{end}} {{- end -}} {{- end}} @@ -242,26 +255,36 @@ func new{{.PascalName}}() *cobra.Command { {{- if eq .Path "/api/2.1/clusters/events" }} {{- $method := . }} {{- range .AllFields }}{{ if eq .Name "offset" }} - cmd.Flags().{{template "arg-type" .Entity}}(&{{$method.CamelName}}Req.{{.PascalName}}, "{{.KebabName}}", {{$method.CamelName}}Req.{{.PascalName}}, `{{.Summary | without "`" | trimSuffix "."}}{{if .Summary}}.{{end}}`) + {{$method.Bind.FlagDef . .KebabName (.FlagUsage false)}} + {{- if $method.Bind.Mapped .}} cmd.Flags().Lookup("{{.KebabName}}").Hidden = true + {{- end}} {{- end }}{{ end }} {{- else if and .Pagination.Token .Pagination.Token.PollField }} - cmd.Flags().{{template "arg-type" .Pagination.Token.PollField.Entity}}(&{{.CamelName}}Req.{{.Pagination.Token.PollField.PascalName}}, "{{.Pagination.Token.PollField.KebabName}}", {{.CamelName}}Req.{{.Pagination.Token.PollField.PascalName}}, `Pagination token.`) + {{.Bind.FlagDef .Pagination.Token.PollField .Pagination.Token.PollField.KebabName "Pagination token."}} + {{- if .Bind.Mapped .Pagination.Token.PollField}} cmd.Flags().Lookup("{{.Pagination.Token.PollField.KebabName}}").Hidden = true + {{- end}} {{- end }} {{- if .Pagination.Offset }} - cmd.Flags().{{template "arg-type" .Pagination.Offset.Entity}}(&{{.CamelName}}Req.{{.Pagination.Offset.PascalName}}, "{{.Pagination.Offset.KebabName}}", {{.CamelName}}Req.{{.Pagination.Offset.PascalName}}, `{{.Pagination.Offset.Summary | without "`" | trimSuffix "."}}{{if .Pagination.Offset.Summary}}.{{end}}`) + {{.Bind.FlagDef .Pagination.Offset .Pagination.Offset.KebabName (.Pagination.Offset.FlagUsage false)}} + {{- if .Bind.Mapped .Pagination.Offset}} cmd.Flags().Lookup("{{.Pagination.Offset.KebabName}}").Hidden = true + {{- end}} {{- end }} {{- if .Pagination.Limit }} {{- if ne .Pagination.Limit.KebabName "limit" }} - cmd.Flags().{{template "arg-type" .Pagination.Limit.Entity}}(&{{.CamelName}}Req.{{.Pagination.Limit.PascalName}}, "{{.Pagination.Limit.KebabName}}", {{.CamelName}}Req.{{.Pagination.Limit.PascalName}}, `Number of results per API page.`) + {{.Bind.FlagDef .Pagination.Limit .Pagination.Limit.KebabName "Number of results per API page."}} + {{- if .Bind.Mapped .Pagination.Limit}} cmd.Flags().Lookup("{{.Pagination.Limit.KebabName}}").Hidden = true + {{- end}} {{- end }} {{- end }} {{- if .Pagination.MaxResults }} - cmd.Flags().{{template "arg-type" .Pagination.MaxResults.Entity}}(&{{.CamelName}}Req.{{.Pagination.MaxResults.PascalName}}, "{{.Pagination.MaxResults.KebabName}}", {{.CamelName}}Req.{{.Pagination.MaxResults.PascalName}}, `{{.Pagination.MaxResults.Summary | without "`" | trimSuffix "."}}{{if .Pagination.MaxResults.Summary}}.{{end}}`) + {{.Bind.FlagDef .Pagination.MaxResults .Pagination.MaxResults.KebabName (.Pagination.MaxResults.FlagUsage false)}} + {{- if .Bind.Mapped .Pagination.MaxResults}} cmd.Flags().Lookup("{{.Pagination.MaxResults.KebabName}}").Hidden = true + {{- end}} {{- end }} {{- end }} @@ -279,7 +302,7 @@ func new{{.PascalName}}() *cobra.Command { {{- $hasPosArgs := .HasRequiredPositionalArguments -}} {{- $hasSinglePosArg := and $hasPosArgs (and (eq 1 (len .RequiredPositionalArguments)) (eq 1 (len $request.RequiredFields))) -}} - {{- $serviceHasNamedIdMap := and (and $.List $.List.NamedIdMap) (not (eq .PascalName "List")) -}} + {{- $serviceHasNamedIdMap := and (and (and $.List $.List.NamedIdMap) (not (eq .PascalName "List"))) (ne $.NamedIdMapCall "") -}} {{- $hasIdPrompt := and (not $noPrompt) (and $hasSinglePosArg $serviceHasNamedIdMap) -}} {{- $wait := and .Wait (and (not .IsCrudRead) (not (eq .SnakeName "get_run"))) -}} {{- $hasRequiredArgs := and (not $hasIdPrompt) $hasPosArgs -}} @@ -359,10 +382,11 @@ func new{{.PascalName}}() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() {{if $.IsAccounts}}a := cmdctx.AccountClient(ctx){{else}}w := cmdctx.WorkspaceClient(ctx){{end}} + _ = {{if $.IsAccounts}}a{{else}}w{{end}} {{- if not .IsLegacyEmptyRequest }} {{ if $canUseJson }} if cmd.Flags().Changed("json") { - diags := {{.CamelName}}Json.Unmarshal(&{{.CamelName}}Req{{ if .RequestBodyField }}.{{.RequestBodyField.PascalName}}{{ end }}) + diags := {{.CamelName}}Json.Unmarshal({{.Bind.JsonTarget}}) if diags.HasError() { return diags.Error() } @@ -382,7 +406,7 @@ func new{{.PascalName}}() *cobra.Command { if len(args) == 0 { sp := cmdio.NewSpinner(ctx) sp.Update("No{{range $request.RequiredFields}} {{.ConstantName}}{{end}} argument specified. Loading names for {{$.TitleName}} drop-down.") - names, err := {{if $.IsAccounts}}a{{else}}w{{end}}.{{($.TrimPrefix "account").PascalName}}.{{$.List.NamedIdMap.PascalName}}(ctx{{if not $.List.IsLegacyEmptyRequest}}, {{$.Package.Name}}.{{$.List.Request.PascalName}}{}{{end}}) + names, err := {{$.NamedIdMapCall}} sp.Close() if err != nil { return fmt.Errorf("failed to load names for {{$.TitleName}} drop-down. Please manually specify required arguments. Original error: %w", err) @@ -406,7 +430,7 @@ func new{{.PascalName}}() *cobra.Command { {{- if and (not .Required) (not .IsComputed) (not .IsOutputOnly)}} {{if or .Entity.IsDuration .Entity.IsTimestamp .Entity.IsFieldMask}} if {{.CamelName}}Param != "" { - {{template "parse-well-known-type" (dict "Method" $method "Field" . "SourceValue" (printf "%sParam" .CamelName))}} + {{$method.Bind.WellKnown . (printf "%sParam" .CamelName)}} } {{- end -}} {{- end -}} @@ -417,26 +441,69 @@ func new{{.PascalName}}() *cobra.Command { {{- end}} {{end}} - {{if .LongRunningOperation -}} + {{- if .Bind.IsRaw }} + {{template "raw-call" (dict "Method" . "Service" $)}} + {{- else if .Bind.IsLegacy }} + {{- if eq .Bind.LegacyKind "listing" }} + response := {{.Bind.LegacyCall}}(ctx{{if .Bind.HasRequest}}, {{.Bind.ReqVar}}{{end}}) + {{- if .Pagination }} + if {{.CamelName}}Limit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", {{.CamelName}}Limit) + } + if {{.CamelName}}Limit > 0 { + ctx = cmdio.WithLimit(ctx, {{.CamelName}}Limit) + } + {{- end }} + return cmdio.RenderListing(ctx, response) + {{- else if eq .Bind.LegacyKind "err" }} + err = {{.Bind.LegacyCall}}(ctx{{if .Bind.HasRequest}}, {{.Bind.ReqVar}}{{end}}) + if err != nil { + return err + } + return nil + {{- else }} + response, err := {{.Bind.LegacyCall}}(ctx{{if .Bind.HasRequest}}, {{.Bind.ReqVar}}{{end}}) + if err != nil { + return err + } + {{- if .IsResponseByteStream }} + defer response.{{.ResponseBodyField.PascalName}}.Close() + return cmdio.Render(ctx, response.{{.ResponseBodyField.PascalName}}) + {{- else }} + return cmdio.Render(ctx, response) + {{- end }} + {{- end }} + {{- else }} + {{.Bind.PathConsts}} + {{.Bind.SdkReq}} + {{- if and .LongRunningOperation (eq .Bind.SdkKind "op") }} // Determine which mode to execute based on flags. switch { case {{.CamelName}}SkipWait: - wait, err := {{if $.IsAccounts}}a{{else}}w{{end}}.{{$.PascalName}}.{{.PascalName}}(ctx{{if not .IsLegacyEmptyRequest}}, {{.CamelName}}Req{{end}}) + wait, err := {{.Bind.ClientExpr}}.{{.Bind.SdkMethod}}(ctx{{.Bind.CallArgs}}) if err != nil { return err } // Return operation immediately without waiting. - operation, err := {{if $.IsAccounts}}a{{else}}w{{end}}.{{$.PascalName}}.{{.LongRunningOperation.GetOperation.PascalName}}(ctx, {{$.Package.Name}}.{{.LongRunningOperation.GetOperation.Request.PascalName}}{ + {{- if .Bind.GetOperation }} + operation, err := {{.Bind.ClientExpr}}.{{.Bind.GetOperation}}(ctx, {{.Bind.GetOperationRequest}}{ Name: wait.Name(), }) if err != nil { return err } - return cmdio.Render(ctx, operation) + out, err := {{.Bind.GetOperationFromSDK}}(operation) + if err != nil { + return err + } + return cmdio.Render(ctx, out) + {{- else }} + return cmdio.Render(ctx, map[string]any{"name": wait.Name()}) + {{- end }} default: - wait, err := {{if $.IsAccounts}}a{{else}}w{{end}}.{{$.PascalName}}.{{.PascalName}}(ctx{{if not .IsLegacyEmptyRequest}}, {{.CamelName}}Req{{end}}) + wait, err := {{.Bind.ClientExpr}}.{{.Bind.SdkMethod}}(ctx{{.Bind.CallArgs}}) if err != nil { return err } @@ -446,63 +513,100 @@ func new{{.PascalName}}() *cobra.Command { sp.Update("Waiting for {{.KebabName}} to complete...") // Wait for completion. - opts := api.WithTimeout({{.CamelName}}Timeout) - {{ if not .LongRunningOperation.ResponseType.IsEmptyResponse -}} - response, err := wait.Wait(ctx, opts) - {{- else }} - err = wait.Wait(ctx, opts) - {{- end }} + {{if .Bind.HasWaitResult}}response, err :={{else}}response := struct{}{} + err ={{end}} wait.Wait(ctx, lro.WithTimeout({{.CamelName}}Timeout)) if err != nil { - return err + return &cmdgen.WaitError{Err: err} } sp.Close() - {{if not .LongRunningOperation.ResponseType.IsEmptyResponse -}} - return cmdio.Render(ctx, response) - {{- else -}} - return nil - {{- end }} + {{template "render-result" .}} + } + {{- else if eq .Bind.SdkKind "waiter" }} + {{- if and (or .Wait .LongRunningOperation) .Bind.HasNoWaitCall }} + if {{.CamelName}}SkipWait { + {{.Bind.NoWaitCall}} } - {{else if $wait -}} - wait, err := {{if $.IsAccounts}}a{{else}}w{{end}}.{{$.PascalName}}.{{.PascalName}}(ctx{{if not .IsLegacyEmptyRequest}}, {{.CamelName}}Req{{end}}) + {{- end }} + wait, err := {{.Bind.ClientExpr}}.{{.Bind.SdkMethod}}(ctx{{.Bind.CallArgs}}) if err != nil { return err } + {{- if or .Wait .LongRunningOperation }} + {{- if not .Bind.HasNoWaitCall }} if {{.CamelName}}SkipWait { - {{if not .Response.IsEmptyResponse -}} - return cmdio.Render(ctx, wait.Response) - {{- else -}} + {{- if .Bind.PollCall }} + // Render the current state, as of right after the call. + current, err := {{.Bind.PollCall}} + if err != nil { + return err + } + out, err := {{.Bind.PollFromSDK}}(current) + if err != nil { + return err + } + return cmdio.Render(ctx, out) + {{- else if .Bind.WaiterIDs }} + return cmdio.Render(ctx, map[string]any{ {{- .Bind.WaiterIDs -}} }) + {{- else }} return nil - {{- end}} + {{- end }} } + {{- end }} sp := cmdio.NewSpinner(ctx) - info, err := wait.OnProgress(func(i *{{$.Package.Name}}.{{.Wait.Poll.Response.PascalName}}) { - {{if .Wait.MessagePath -}} - {{if .Wait.ComplexMessagePath -}} - if i.{{.Wait.MessagePathHead.PascalName}} == nil { - return - } - status := i{{range .Wait.StatusPath}}.{{.PascalName}}{{end}} - statusMessage := fmt.Sprintf("current status: %s", status) - if i.{{.Wait.MessagePathHead.PascalName}} != nil { - statusMessage = i{{range .Wait.MessagePath}}.{{.PascalName}}{{end}} - } - {{- else -}} - statusMessage := i{{range .Wait.MessagePath}}.{{.PascalName}}{{end}} - {{- end}} - {{- else -}} - status := i{{range .Wait.StatusPath}}.{{.PascalName}}{{end}} - statusMessage := fmt.Sprintf("current status: %s", status) - {{- end}} - sp.Update(statusMessage) - }).GetWithTimeout({{.CamelName}}Timeout) + sp.Update("Waiting for {{.KebabName}} to complete...") + {{if .Bind.HasWaitResult}}response, err :={{else}}response := struct{}{} + err ={{end}} wait.Wait(ctx, lro.WithTimeout({{.CamelName}}Timeout)) sp.Close() + {{- else }} + {{if .Bind.HasWaitResult}}response, err :={{else}}response := struct{}{} + err ={{end}} wait.Wait(ctx) + {{- end }} + if err != nil { + return &cmdgen.WaitError{Err: err} + } + {{template "render-result" .}} + {{- else if eq .Bind.SdkKind "op" }} + wait, err := {{.Bind.ClientExpr}}.{{.Bind.SdkMethod}}(ctx{{.Bind.CallArgs}}) if err != nil { return err } - return cmdio.Render(ctx, info) - {{- else -}} - {{template "method-call" (dict "Method" . "Service" $)}} - {{end -}} + {{if .Bind.HasWaitResult}}response, err :={{else}}response := struct{}{} + err ={{end}} wait.Wait(ctx) + if err != nil { + return &cmdgen.WaitError{Err: err} + } + {{template "render-result" .}} + {{- else if eq .Bind.SdkKind "iter" }} + if {{.CamelName}}Limit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", {{.CamelName}}Limit) + } + if {{.CamelName}}Limit > 0 { + ctx = cmdio.WithLimit(ctx, {{.CamelName}}Limit) + } + response := {{.Bind.ClientExpr}}.{{.Bind.IterMethod}}(ctx{{.Bind.CallArgs}}) + return cmdio.RenderIterator(ctx, cmdgen.MapSeq(response, {{.Bind.FromSDK}})) + {{- else if eq .Bind.SdkKind "err" }} + err = {{.Bind.ClientExpr}}.{{.Bind.SdkMethod}}(ctx{{.Bind.CallArgs}}) + if err != nil { + return err + } + return nil + {{- else }} + response, err := {{.Bind.ClientExpr}}.{{.Bind.SdkMethod}}(ctx{{.Bind.CallArgs}}) + if err != nil { + return err + } + {{- if .Pagination }} + if {{.CamelName}}Limit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", {{.CamelName}}Limit) + } + if {{.CamelName}}Limit > 0 { + ctx = cmdio.WithLimit(ctx, {{.CamelName}}Limit) + } + {{- end }} + {{template "render-result" .}} + {{- end }} + {{- end }} } // Disable completions since they are not applicable. @@ -511,7 +615,7 @@ func new{{.PascalName}}() *cobra.Command { // Apply optional overrides to this command. for _, fn := range {{.CamelName}}Overrides { - fn(cmd{{if not .IsLegacyEmptyRequest}}, &{{.CamelName}}Req{{end}}) + fn(cmd{{if and (not .IsLegacyEmptyRequest) .Bind.HasRequest}}, &{{.Bind.ReqVar}}{{end}}) } return cmd @@ -520,87 +624,53 @@ func new{{.PascalName}}() *cobra.Command { {{end}} // end service {{.Name}}{{end}} -{{- define "method-call" -}} - {{- $method := .Method -}} - {{- $service := .Service -}} - - {{if not $method.Response.IsEmptyResponse -}} - response{{ if not $method.Pagination}}, err{{end}} := - {{- else -}} - err = - {{- end}} - {{- if $service.IsAccounts}}a{{else}}w{{end}}. - {{- if $service.HasParent }} - {{- ($service.ParentService.TrimPrefix "account").PascalName }}. - {{- ($service.TrimPrefix "account").PascalName}}(). - {{- else}} - {{- ($service.TrimPrefix "account").PascalName}}. - {{- end}} - {{- $method.PascalName}}(ctx{{if not $method.IsLegacyEmptyRequest}}, {{$method.CamelName}}Req{{end}}) - {{- if not (and $method.Response $method.Pagination) }} +{{- define "render-result" -}} + {{- if not .Bind.HasWaitResult }} + _ = response + return nil + {{- else if .Bind.HasResult }} + out, err := {{.Bind.FromSDK}}(response) if err != nil { return err } - {{- end}} - {{ if not $method.Response.IsEmptyResponse -}} - {{- if $method.Pagination -}} - if {{$method.CamelName}}Limit < 0 { - return fmt.Errorf("--limit must be a non-negative integer, got %d", {{$method.CamelName}}Limit) - } - if {{$method.CamelName}}Limit > 0 { - ctx = cmdio.WithLimit(ctx, {{$method.CamelName}}Limit) - } - {{- end }} - {{ if $method.IsResponseByteStream -}} - defer response.{{$method.ResponseBodyField.PascalName}}.Close() - return cmdio.Render{{ if $method.Pagination}}Iterator{{end}}(ctx, response.{{$method.ResponseBodyField.PascalName}}) - {{- else }} - return cmdio.Render{{ if $method.Pagination}}Iterator{{end}}(ctx, response) - {{- end -}} - {{ else -}} + {{- if .Bind.ListItems }} + return cmdio.Render(ctx, out.{{.Bind.ListItems}}) + {{- else }} + return cmdio.Render(ctx, out) + {{- end }} + {{- else }} + _ = response return nil - {{- end -}} -{{- end -}} - -{{- define "arg-type" -}} - {{- if .IsString}}StringVar - {{- /* The following Well Known Types are expressed as strings in JSON */}} - {{- else if .IsTimestamp}}StringVar - {{- else if .IsDuration}}StringVar - {{- else if .IsFieldMask}}StringVar - {{- else if .IsBool}}BoolVar - {{- else if .IsInt64}}Int64Var - {{- else if .IsFloat64}}Float64Var - {{- else if .IsInt}}IntVar - {{- else if .Enum }}StringVar - {{- else}}/* NOT PRIMITIVE */ - {{- end -}} + {{- end }} {{- end -}} -{{- define "parse-well-known-type" -}} - {{- $field := .Field -}} +{{- define "raw-call" -}} {{- $method := .Method -}} - {{- $sourceValue := .SourceValue -}} - {{- if $field.Entity.IsTimestamp -}} - {{$field.CamelName}}Bytes := []byte(fmt.Sprintf("\"%s\"", {{$sourceValue}})) - var {{$field.CamelName}}Field sdktime.Time - err = json.Unmarshal({{$field.CamelName}}Bytes, &{{$field.CamelName}}Field) + {{$method.Bind.RawAssemble}} + {{$method.Bind.RawQuery}} + api, err := apiclient.New({{if .Service.IsAccounts}}a{{else}}w{{end}}.Config) if err != nil { - return fmt.Errorf("invalid {{$field.ConstantName}}: %s", {{$sourceValue}}) + return err } - {{template "request-body-obj" (dict "Method" $method "Field" $field)}} = {{if not $field.Required}}&{{end}}{{$field.CamelName}}Field - {{- else if $field.Entity.IsDuration -}} - {{$field.CamelName}}Bytes := []byte(fmt.Sprintf("\"%s\"", {{$sourceValue}})) - var {{$field.CamelName}}Field duration.Duration - err = json.Unmarshal({{$field.CamelName}}Bytes, &{{$field.CamelName}}Field) + {{- if $method.Response.IsEmptyResponse }} + err = api.Do(ctx, "{{$method.Bind.Verb}}", rawPath, {{$method.Bind.RawHeaders}}, rawQuery, {{$method.Bind.RawBody}}, nil) if err != nil { - return fmt.Errorf("invalid {{$field.ConstantName}}: %s", {{$sourceValue}}) + return err } - {{template "request-body-obj" (dict "Method" $method "Field" $field)}} = {{if not $field.Required}}&{{end}}{{$field.CamelName}}Field - {{- else if $field.Entity.IsFieldMask -}} - {{$field.CamelName}}Array := strings.Split({{$sourceValue}}, ",") - {{template "request-body-obj" (dict "Method" $method "Field" $field)}} = {{if $field.Required}}*{{end}}fieldmask.New({{$field.CamelName}}Array) - {{- end -}} + return nil + {{- else }} + var response any + err = api.Do(ctx, "{{$method.Bind.Verb}}", rawPath, {{$method.Bind.RawHeaders}}, rawQuery, {{$method.Bind.RawBody}}, &response) + if err != nil { + return err + } + {{- if $method.Pagination }} + if {{$method.CamelName}}Limit < 0 { + return fmt.Errorf("--limit must be a non-negative integer, got %d", {{$method.CamelName}}Limit) + } + {{- end }} + return cmdio.Render(ctx, response) + {{- end }} {{- end -}} {{- define "args-scan" -}} @@ -613,25 +683,14 @@ func new{{.PascalName}}() *cobra.Command { {{- if $optionalIfJsonIsUsed }} if !cmd.Flags().Changed("json") { {{- end }} - {{if and (not $field.Entity.IsString) (not $field.Entity.IsFieldMask) (not $field.Entity.IsTimestamp) (not $field.Entity.IsDuration) -}} - _, err = fmt.Sscan(args[{{$arg}}], &{{- template "request-body-obj" (dict "Method" $method "Field" $field)}}) - if err != nil { - return fmt.Errorf("invalid {{$field.ConstantName}}: %s", args[{{$arg}}]) - } - {{else if or $field.Entity.IsTimestamp $field.Entity.IsDuration $field.Entity.IsFieldMask -}} + {{- if or $field.Entity.IsTimestamp $field.Entity.IsDuration $field.Entity.IsFieldMask }} if args[{{$arg}}] != "" { - {{template "parse-well-known-type" (dict "Method" $method "Field" $field "SourceValue" (printf "args[%d]" $arg))}} + {{$method.Bind.ArgScan $field (printf "args[%d]" $arg)}} } - {{- else -}} - {{- template "request-body-obj" (dict "Method" $method "Field" $field)}} = args[{{$arg}}] - {{- end -}} + {{- else }} + {{$method.Bind.ArgScan $field (printf "args[%d]" $arg)}} + {{- end }} {{- if $optionalIfJsonIsUsed }} } {{- end }} {{- end -}} - -{{- define "request-body-obj" -}} - {{- $method := .Method -}} - {{- $field := .Field -}} - {{$method.CamelName}}Req{{ if (and $method.RequestBodyField (and (not $field.IsPath) (not $field.IsQuery))) }}.{{$method.RequestBodyField.PascalName}}{{end}}.{{$field.PascalName}} -{{- end -}} diff --git a/internal/sdkconvgen/main.go b/internal/sdkconvgen/main.go new file mode 100644 index 00000000000..bd7e261ac0e --- /dev/null +++ b/internal/sdkconvgen/main.go @@ -0,0 +1,95 @@ +// sdkconvgen generates the registry of sdk-go oneof wrapper types used by +// libs/sdktypes/sdkconv. +// +// sdk-go models a oneof as an unexported interface field holding a pointer to +// a wrapper struct (Parent_Field_Alt). Reflection cannot enumerate the types +// implementing an interface, so sdkconv needs this list to convert JSON +// mirrors (flattened oneofs) back into sdk-go types. +// +// Usage: go run ./internal/sdkconvgen ... +package main + +import ( + "bytes" + "fmt" + "go/ast" + "go/format" + "go/parser" + "go/token" + "os" + "os/exec" + "path/filepath" + "slices" + "strings" +) + +func main() { + if len(os.Args) < 3 { + fmt.Fprintln(os.Stderr, "usage: sdkconvgen ...") + os.Exit(2) + } + pkgs := os.Args[2:] + slices.Sort(pkgs) + + var imports, entries bytes.Buffer + for _, pkg := range pkgs { + names, err := wrappers(pkg) + if err != nil { + fmt.Fprintf(os.Stderr, "%s: %v\n", pkg, err) + os.Exit(1) + } + if len(names) == 0 { + continue + } + alias := strings.NewReplacer("/", "", "-", "").Replace(strings.TrimPrefix(pkg, "github.com/databricks/sdk-go/")) + fmt.Fprintf(&imports, "\t%s %q\n", alias, pkg) + for _, n := range names { + fmt.Fprintf(&entries, "\t(*%s.%s)(nil),\n", alias, n) + } + } + + var buf bytes.Buffer + buf.WriteString("// Code generated by internal/sdkconvgen. DO NOT EDIT.\n\npackage sdkconv\n\nimport (\n") + buf.Write(imports.Bytes()) + buf.WriteString(")\n\n// oneofWrappers lists the oneof wrapper types of every sdk-go package.\nvar oneofWrappers = []any{\n") + buf.Write(entries.Bytes()) + buf.WriteString("}\n") + + src, err := format.Source(buf.Bytes()) + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } + if err := os.WriteFile(os.Args[1], src, 0o644); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} + +// wrappers returns the names of types with a `func (*T) isX()` marker method. +func wrappers(pkg string) ([]string, error) { + out, err := exec.Command("go", "list", "-f", "{{.Dir}}", pkg).Output() + if err != nil { + return nil, fmt.Errorf("go list: %w", err) + } + f, err := parser.ParseFile(token.NewFileSet(), filepath.Join(strings.TrimSpace(string(out)), "model.go"), nil, 0) + if err != nil { + return nil, err + } + var names []string + for _, d := range f.Decls { + fd, ok := d.(*ast.FuncDecl) + if !ok || fd.Recv == nil || !strings.HasPrefix(fd.Name.Name, "is") || fd.Type.Params.NumFields() != 0 { + continue + } + star, ok := fd.Recv.List[0].Type.(*ast.StarExpr) + if !ok { + continue + } + if id, ok := star.X.(*ast.Ident); ok && id.IsExported() { + names = append(names, id.Name) + } + } + slices.Sort(names) + return names, nil +} diff --git a/internal/sdktypesgen/convert.go b/internal/sdktypesgen/convert.go new file mode 100644 index 00000000000..608ead0dd17 --- /dev/null +++ b/internal/sdktypesgen/convert.go @@ -0,0 +1,300 @@ +package main + +import ( + "fmt" + "go/ast" + "go/types" + "slices" + "strings" +) + +// oneofAlt is one implementation of a oneof interface in the sdk package: +// +// type Parent_Field_Alt struct{ Alt T } +// func (*Parent_Field_Alt) isParent_Field() {} +type oneofAlt struct { + wrapper string + field string + typ string + wireType string +} + +func nillable(t string) bool { + return strings.HasPrefix(t, "*") || strings.HasPrefix(t, "[]") || strings.HasPrefix(t, "map[") || t == "json.RawMessage" || t == "any" +} + +func (g *converterGen) isEnum(t string) bool { + return slices.Contains(g.m.aliasTypes, t) +} + +func (g *converterGen) isSet(expr, wireType string) string { + if g.isEnum(wireType) { + return expr + ` != ""` + } + return expr + " != nil" +} + +// converterGen synthesizes ToSDK and FromSDK for every mirror type. +// sdk-go's wire.go only has the directions sdk-go itself needs (requests are +// only encoded, responses only decoded), while the CLI needs both for every +// type, so converters are derived from the model and mirror struct shapes. +type converterGen struct { + m *model + // mirror struct name -> ordered fields (name, type) of the mirror struct. + mirrorFields map[string][][2]string + // oneof interface name -> implementations. + oneofs map[string][]oneofAlt + // Whether a helper is needed in the output. + // mirror struct name -> Go field name -> JSON name. + jsonNames map[string]map[string]string + curJSON map[string]string + needSlice bool + needFieldMask bool + b strings.Builder + tmp int +} + +func exprString(e ast.Expr) string { return types.ExprString(e) } + +func (g *converterGen) isMirror(name string) bool { + _, ok := g.mirrorFields[name] + return ok +} + +func (g *converterGen) p(format string, args ...any) { + fmt.Fprintf(&g.b, format, args...) + g.b.WriteString("\n") +} + +func (g *converterGen) newVar(prefix string) string { + g.tmp++ + return fmt.Sprintf("%s%d", prefix, g.tmp) +} + +// sdkType renders a model type expression as seen from the mirror package. +func (g *converterGen) sdkType(t string) string { + prefix := "" + var prefixSb78 strings.Builder + for strings.HasPrefix(t, "*") || strings.HasPrefix(t, "[]") { + if t[0] == '*' { + prefixSb78.WriteString("*") + t = t[1:] + } else { + prefixSb78.WriteString("[]") + t = t[2:] + } + } + prefix += prefixSb78.String() + if g.m.decls[t] { + return prefix + "sdk." + t + } + return prefix + t +} + +// conv emits statements converting src (of model type mt on the model side) +// in the given direction and returns the expression holding the result. +// errCtx names the field in error messages. +func (g *converterGen) conv(src, mt, dir, errCtx string) string { + errCheck := func(v string) { + g.p("if err != nil {\nreturn nil, fmt.Errorf(\"%%s: %%w\", %q, err)\n}", errCtx) + _ = v + } + switch { + case strings.HasPrefix(mt, "*types.FieldMask["): + g.needFieldMask = true + if dir == "FromSDK" { + return fmt.Sprintf("fieldMaskToString(%s)", src) + } + elem := strings.TrimSuffix(strings.TrimPrefix(mt, "*types.FieldMask["), "]") + v := g.newVar("mask") + g.p("%s, err := fieldMaskFromString[%s](%s)", v, g.sdkType(elem), src) + errCheck(v) + return v + case strings.HasPrefix(mt, "*") && g.isMirror(mt[1:]): + v := g.newVar("conv") + g.p("%s, err := %s%s(%s)", v, mt[1:], dir, src) + errCheck(v) + return v + case g.isMirror(mt): + v := g.newVar("conv") + g.p("%s, err := %s%s(&%s)", v, mt, dir, src) + errCheck(v) + return "*" + v + case strings.HasPrefix(mt, "[]") && g.isMirror(mt[2:]): + g.needSlice = true + v := g.newVar("conv") + g.p("%s, err := convertSlice(%s, %s%s)", v, src, mt[2:], dir) + errCheck(v) + return v + default: + return src + } +} + +func (g *converterGen) generate(name string) { + mst := g.m.structs[name] + g.curJSON = g.jsonNames[name] + wireFields := map[string]string{} + for _, f := range g.mirrorFields[name] { + wireFields[f[0]] = f[1] + } + for _, dir := range []string{"ToSDK", "FromSDK"} { + in, out := name, "sdk."+name + inVar := "w" + if dir == "FromSDK" { + in, out = out, in + inVar = "v" + } + if dir == "ToSDK" { + g.p("// %sToSDK converts the mirror to the sdk-go type.", name) + } else { + g.p("// %sFromSDK converts the sdk-go type to the mirror.", name) + } + g.p("func %s%s(%s *%s) (*%s, error) {", name, dir, inVar, in, out) + g.p("if %s == nil {\nreturn nil, nil\n}", inVar) + g.p("out := &%s{}", out) + for _, field := range mst.Fields.List { + if len(field.Names) != 1 { + continue + } + fname := field.Names[0].Name + ft := exprString(field.Type) + ctx := name + "." + fname + if alts, ok := g.oneofs[ft]; ok { + g.oneof(dir, inVar, fname, ctx, alts, wireFields) + continue + } + if _, ok := wireFields[fname]; !ok { + continue + } + val := g.conv(inVar+"."+fname, ft, dir, ctx) + g.p("out.%s = %s", fname, val) + } + g.p("return out, nil\n}\n") + } +} + +func (g *converterGen) oneof(dir, inVar, fname, ctx string, alts []oneofAlt, wireFields map[string]string) { + var present []oneofAlt + for _, a := range alts { + wt, ok := wireFields[a.field] + if !ok { + continue + } + if !nillable(wt) && !g.isEnum(wt) { + panic(fmt.Sprintf("%s: oneof member %s has non-nillable mirror type %s", ctx, a.field, wt)) + } + a.wireType = wt + present = append(present, a) + } + if len(present) == 0 { + return + } + if dir == "ToSDK" { + g.p("{\nvar members []string") + for _, a := range present { + g.p("if %s {\nmembers = append(members, %q)\n}", g.isSet("w."+a.field, a.wireType), g.curJSON[a.field]) + } + g.p("if len(members) > 1 {\nreturn nil, fmt.Errorf(\"only one of %%s can be set\", strings.Join(members, \", \"))\n}\n}") + g.p("switch {") + for _, a := range present { + g.p("case %s:", g.isSet("w."+a.field, a.wireType)) + var val string + switch { + case g.isEnum(a.wireType): + val = "w." + a.field + case nillable(a.typ) || g.isMirror(a.typ): + src := "w." + a.field + if g.isMirror(a.typ) { + // Value-typed message member: the mirror holds a pointer. + v := g.conv(src, "*"+a.typ, dir, ctx) + val = "*" + v + } else { + val = g.conv(src, a.typ, dir, ctx) + } + default: + val = "*w." + a.field + } + g.p("out.%s = &sdk.%s{%s: %s}", fname, a.wrapper, a.field, val) + } + g.p("}") + return + } + g.p("switch value := v.%s.(type) {", fname) + for _, a := range present { + g.p("case *sdk.%s:", a.wrapper) + g.p("if value != nil {") + var val string + switch { + case g.isEnum(a.wireType): + val = "value." + a.field + case g.isMirror(a.typ): + val = g.conv("&value."+a.field, "*"+a.typ, dir, ctx) + case nillable(a.typ): + val = g.conv("value."+a.field, a.typ, dir, ctx) + default: + val = "new(value." + a.field + ")" + } + g.p("out.%s = %s", a.field, val) + g.p("}") + } + g.p("}") +} + +func (g *converterGen) helpers() string { + var b strings.Builder + if g.needSlice { + b.WriteString(` +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} +`) + } + if g.needFieldMask { + b.WriteString(` +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} +`) + } + return b.String() +} + +func generateConverters(m *model, mirrorFields map[string][][2]string, jsonNames map[string]map[string]string, oneofs map[string][]oneofAlt) string { + g := &converterGen{m: m, mirrorFields: mirrorFields, jsonNames: jsonNames, oneofs: oneofs} + var names []string + for n := range mirrorFields { + names = append(names, n) + } + slices.Sort(names) + for _, n := range names { + g.generate(n) + } + return g.b.String() + g.helpers() +} diff --git a/internal/sdktypesgen/main.go b/internal/sdktypesgen/main.go new file mode 100644 index 00000000000..277b510a4d0 --- /dev/null +++ b/internal/sdktypesgen/main.go @@ -0,0 +1,498 @@ +// sdktypesgen generates JSON-capable mirrors of the sdk-go model types. +// +// The sdk-go model types carry no JSON tags and model oneofs as unexported +// interfaces, so they cannot be used for bundle configuration, deployment state +// or the test server, all of which rely on encoding/json and struct tags. Every +// sdk-go package already contains the JSON representation in its unexported +// wire.go: one tagged struct per model type with oneofs flattened, plus +// converters in both directions. This tool copies wire.go into a CLI package, +// exporting the wire structs under the model type names and the converters as +// ToSDK / FromSDK. +// +// Usage: go run ./internal/sdktypesgen ... +// e.g. go run ./internal/sdktypesgen libs/sdktypes github.com/databricks/sdk-go/jobs/v2 +package main + +import ( + "bytes" + "errors" + "fmt" + "go/ast" + "go/format" + "go/parser" + "go/printer" + "go/token" + "os" + "os/exec" + "path/filepath" + "reflect" + "slices" + "strconv" + "strings" +) + +const sdkModulePrefix = "github.com/databricks/sdk-go/" + +func main() { + if len(os.Args) < 3 { + fmt.Fprintln(os.Stderr, "usage: sdktypesgen ...") + os.Exit(2) + } + outRoot := os.Args[1] + for _, pkg := range os.Args[2:] { + if err := generate(outRoot, pkg); err != nil { + fmt.Fprintf(os.Stderr, "%s: %v\n", pkg, err) + os.Exit(1) + } + } +} + +func packageDir(pkg string) (string, error) { + out, err := exec.Command("go", "list", "-f", "{{.Dir}}", pkg).Output() + if err != nil { + return "", fmt.Errorf("go list %s: %w", pkg, err) + } + return strings.TrimSpace(string(out)), nil +} + +type model struct { + // All exported top-level names declared in model.go. + decls map[string]bool + // Struct types declared in model.go. + structs map[string]*ast.StructType + // Doc comments of model types and their fields. + typeDocs map[string]*ast.CommentGroup + fieldDocs map[string]map[string]*ast.CommentGroup + // Non-struct named types (enums, etc.) and constants, re-exported as aliases. + aliasTypes []string + consts []string + // Oneof interface name -> implementations. + oneofs map[string][]oneofAlt +} + +func parseModel(fset *token.FileSet, path string) (*model, string, error) { + f, err := parser.ParseFile(fset, path, nil, parser.ParseComments) + if err != nil { + return nil, "", err + } + m := &model{ + decls: map[string]bool{}, + structs: map[string]*ast.StructType{}, + typeDocs: map[string]*ast.CommentGroup{}, + fieldDocs: map[string]map[string]*ast.CommentGroup{}, + oneofs: map[string][]oneofAlt{}, + } + for _, d := range f.Decls { + if fd, ok := d.(*ast.FuncDecl); ok { + // func (*Parent_Field_Alt) isParent_Field() {} + if fd.Recv != nil && strings.HasPrefix(fd.Name.Name, "is") && len(fd.Recv.List) == 1 { + if recv := starIdent(fd.Recv.List[0].Type); recv != "" { + m.oneofs[fd.Name.Name] = append(m.oneofs[fd.Name.Name], oneofAlt{wrapper: recv}) + } + } + continue + } + gd, ok := d.(*ast.GenDecl) + if !ok { + continue + } + for _, spec := range gd.Specs { + switch s := spec.(type) { + case *ast.TypeSpec: + if !s.Name.IsExported() { + continue + } + m.decls[s.Name.Name] = true + doc := s.Doc + if doc == nil { + doc = gd.Doc + } + m.typeDocs[s.Name.Name] = doc + switch t := s.Type.(type) { + case *ast.StructType: + m.structs[s.Name.Name] = t + docs := map[string]*ast.CommentGroup{} + for _, field := range t.Fields.List { + for _, n := range field.Names { + docs[n.Name] = field.Doc + } + } + m.fieldDocs[s.Name.Name] = docs + case *ast.InterfaceType: + default: + if s.TypeParams == nil { + m.aliasTypes = append(m.aliasTypes, s.Name.Name) + } + } + case *ast.ValueSpec: + for _, n := range s.Names { + if n.IsExported() { + m.decls[n.Name] = true + if gd.Tok == token.CONST { + m.consts = append(m.consts, n.Name) + } + } + } + } + } + } + for iface, alts := range m.oneofs { + for i, a := range alts { + st := m.structs[a.wrapper] + if st == nil || len(st.Fields.List) != 1 || len(st.Fields.List[0].Names) != 1 { + return nil, "", fmt.Errorf("unexpected oneof wrapper %s", a.wrapper) + } + alts[i].field = st.Fields.List[0].Names[0].Name + alts[i].typ = exprString(st.Fields.List[0].Type) + } + m.oneofs[iface] = alts + } + return m, f.Name.Name, nil +} + +func generate(outRoot, pkg string) error { + if !strings.HasPrefix(pkg, sdkModulePrefix) { + return errors.New("not an sdk-go package") + } + dir, err := packageDir(pkg) + if err != nil { + return err + } + fset := token.NewFileSet() + m, pkgName, err := parseModel(fset, filepath.Join(dir, "model.go")) + if err != nil { + return err + } + wf, err := parser.ParseFile(fset, filepath.Join(dir, "wire.go"), nil, parser.ParseComments) + if err != nil { + return err + } + + // Map wire struct names to model names using the converter signatures: + // func fooToWire(v *Foo) (*fooWire, error) + // func fooFromWire(w *fooWire) (*Foo, error) + wireToModel := map[string]string{} + funcRename := map[string]string{} + for _, d := range wf.Decls { + fd, ok := d.(*ast.FuncDecl) + if !ok || fd.Recv != nil || fd.Type.Params.NumFields() != 1 || fd.Type.Results.NumFields() != 2 { + continue + } + in := starIdent(fd.Type.Params.List[0].Type) + out := starIdent(fd.Type.Results.List[0].Type) + name := fd.Name.Name + switch { + case strings.HasSuffix(name, "ToWire") && m.structs[in] != nil && strings.HasSuffix(out, "Wire"): + wireToModel[out] = in + funcRename[name] = in + "FromSDK" + case strings.HasSuffix(name, "FromWire") && m.structs[out] != nil && strings.HasSuffix(in, "Wire"): + wireToModel[in] = out + funcRename[name] = out + "ToSDK" + } + } + + var decls []ast.Decl + for _, d := range wf.Decls { + switch d := d.(type) { + case *ast.GenDecl: + if d.Tok == token.IMPORT { + continue + } + if d.Tok == token.TYPE { + ts := d.Specs[0].(*ast.TypeSpec) + if ts.Name.Name == "wireInt64" { + continue + } + if mn, ok := wireToModel[ts.Name.Name]; ok { + attachDocs(d, ts, mn, m) + } + } + decls = append(decls, d) + case *ast.FuncDecl: + // Converters are synthesized below; the remaining functions are + // helpers for the wire converters or wireInt64 decoding. + } + } + + aliasSet := map[string]bool{} + for _, a := range m.aliasTypes { + aliasSet[a] = true + } + mirrorFields := map[string][][2]string{} + jsonNames := map[string]map[string]string{} + for _, d := range decls { + rewrite(d, wireToModel, funcRename, m.decls, aliasSet) + gd := d.(*ast.GenDecl) + if gd.Tok != token.TYPE { + continue + } + ts := gd.Specs[0].(*ast.TypeSpec) + st, ok := ts.Type.(*ast.StructType) + if !ok || !m.decls[ts.Name.Name] { + continue + } + var fields [][2]string + names := map[string]string{} + for _, f := range st.Fields.List { + for _, n := range f.Names { + fields = append(fields, [2]string{n.Name, exprString(f.Type)}) + names[n.Name] = jsonName(f) + } + } + mirrorFields[ts.Name.Name] = fields + jsonNames[ts.Name.Name] = names + } + + var buf bytes.Buffer + fmt.Fprintf(&buf, "// Code generated by internal/sdktypesgen from %s. DO NOT EDIT.\n\n", pkg) + fmt.Fprintf(&buf, "package %s\n\n", pkgName) + imports := map[string]string{ + "sdk": pkg, + "fmt": "fmt", + "strings": "strings", + "types": "github.com/databricks/sdk-go/core/types", + } + for _, imp := range wf.Imports { + p, _ := strconv.Unquote(imp.Path.Value) + name := filepath.Base(p) + if imp.Name != nil { + name = imp.Name.Name + } + imports[name] = p + } + buf.WriteString("import (\n") + var names []string + for n := range imports { + names = append(names, n) + } + slices.Sort(names) + for _, n := range names { + fmt.Fprintf(&buf, "\t%s %q\n", n, imports[n]) + } + buf.WriteString(")\n\n") + + if len(m.aliasTypes) > 0 { + buf.WriteString("type (\n") + for _, a := range m.aliasTypes { + fmt.Fprintf(&buf, "\t%s = sdk.%s\n", a, a) + } + buf.WriteString(")\n\n") + } + if len(m.consts) > 0 { + buf.WriteString("const (\n") + for _, c := range m.consts { + fmt.Fprintf(&buf, "\t%s = sdk.%s\n", c, c) + } + buf.WriteString(")\n\n") + } + + cfg := printer.Config{Mode: printer.UseSpaces | printer.TabIndent, Tabwidth: 8} + for _, d := range decls { + if writeStruct(&buf, d.(*ast.GenDecl)) { + continue + } + if err := cfg.Fprint(&buf, fset, d); err != nil { + return err + } + buf.WriteString("\n\n") + } + buf.WriteString(generateConverters(m, mirrorFields, jsonNames, m.oneofs)) + + src, err := pruneImports(buf.Bytes()) + if err != nil { + return fmt.Errorf("format: %w\n%s", err, buf.String()) + } + + outDir := filepath.Join(outRoot, strings.TrimPrefix(pkg, sdkModulePrefix)) + if err := os.MkdirAll(outDir, 0o755); err != nil { + return err + } + return os.WriteFile(filepath.Join(outDir, "types.generated.go"), src, 0o644) +} + +func starIdent(e ast.Expr) string { + if s, ok := e.(*ast.StarExpr); ok { + e = s.X + } + if id, ok := e.(*ast.Ident); ok { + return id.Name + } + return "" +} + +// attachDocs copies the model's type and field doc comments onto the mirror. +// Comments are rendered as text so the printer does not need positions from +// model.go. +func attachDocs(gd *ast.GenDecl, ts *ast.TypeSpec, modelName string, m *model) { + gd.Doc = cloneComment(m.typeDocs[modelName], gd.Pos()-1) + st, ok := ts.Type.(*ast.StructType) + if !ok { + return + } + docs := m.fieldDocs[modelName] + for _, f := range st.Fields.List { + if len(f.Names) == 1 { + f.Doc = cloneComment(docs[f.Names[0].Name], f.Pos()-1) + } + } +} + +func cloneComment(cg *ast.CommentGroup, pos token.Pos) *ast.CommentGroup { + if cg == nil { + return nil + } + var list []*ast.Comment + for _, c := range cg.List { + list = append(list, &ast.Comment{Slash: pos, Text: c.Text}) + } + return &ast.CommentGroup{List: list} +} + +// rewrite renames wire types and converters to their exported mirror names and +// qualifies references to model declarations with the sdk package. +func rewrite(n ast.Node, wireToModel, funcRename map[string]string, modelDecls, aliasTypes map[string]bool) { + skip := map[*ast.Ident]bool{} + inTypeDecl := false + if gd, ok := n.(*ast.GenDecl); ok && gd.Tok == token.TYPE { + inTypeDecl = true + } + ast.Inspect(n, func(node ast.Node) bool { + switch x := node.(type) { + case *ast.SelectorExpr: + skip[x.Sel] = true + case *ast.KeyValueExpr: + if id, ok := x.Key.(*ast.Ident); ok { + skip[id] = true + } + case *ast.Field: + for _, id := range x.Names { + skip[id] = true + } + } + return true + }) + ast.Inspect(n, func(node ast.Node) bool { + // Qualify via SelectorExpr replacement on parent nodes is awkward with + // ast.Inspect, so encode the qualifier into the identifier name; the + // printer emits it verbatim. + id, ok := node.(*ast.Ident) + if !ok || skip[id] { + return true + } + switch { + case id.Name == "wireInt64": + id.Name = "int64" + case wireToModel[id.Name] != "": + id.Name = wireToModel[id.Name] + case funcRename[id.Name] != "": + id.Name = funcRename[id.Name] + case modelDecls[id.Name]: + if inTypeDecl && aliasTypes[id.Name] { + return true + } + id.Name = "sdk." + id.Name + } + return true + }) +} + +func pruneImports(src []byte) ([]byte, error) { + fset := token.NewFileSet() + f, err := parser.ParseFile(fset, "", src, parser.ParseComments) + if err != nil { + return nil, err + } + used := map[string]bool{} + ast.Inspect(f, func(n ast.Node) bool { + if sel, ok := n.(*ast.SelectorExpr); ok { + if id, ok := sel.X.(*ast.Ident); ok { + used[id.Name] = true + } + } + return true + }) + var specs []ast.Spec + for _, d := range f.Decls { + gd, ok := d.(*ast.GenDecl) + if !ok || gd.Tok != token.IMPORT { + continue + } + for _, s := range gd.Specs { + is := s.(*ast.ImportSpec) + name := filepath.Base(strings.Trim(is.Path.Value, `"`)) + if is.Name != nil { + name = is.Name.Name + } + if used[name] { + specs = append(specs, s) + } + } + gd.Specs = specs + } + var out bytes.Buffer + if err := format.Node(&out, fset, f); err != nil { + return nil, err + } + return format.Source(out.Bytes()) +} + +// writeStruct renders a struct type declaration with its fields sorted by JSON +// name, the order the previous SDK used. Serialized output (bundle config, +// state, request bodies) follows struct field order, so this keeps it stable. +// The declaration is rendered as text because the printer places comments by +// position and the fields are reordered. +func writeStruct(buf *bytes.Buffer, gd *ast.GenDecl) bool { + if gd.Tok != token.TYPE { + return false + } + ts := gd.Specs[0].(*ast.TypeSpec) + st, ok := ts.Type.(*ast.StructType) + if !ok { + return false + } + writeComment(buf, gd.Doc) + fmt.Fprintf(buf, "type %s struct {\n", ts.Name.Name) + fields := slices.Clone(st.Fields.List) + slices.SortStableFunc(fields, func(a, b *ast.Field) int { + return strings.Compare(jsonName(a), jsonName(b)) + }) + for _, f := range fields { + writeComment(buf, f.Doc) + var names []string + for _, n := range f.Names { + names = append(names, n.Name) + } + buf.WriteString(strings.Join(names, ", ")) + if len(names) > 0 { + buf.WriteString(" ") + } + buf.WriteString(exprString(f.Type)) + if f.Tag != nil { + buf.WriteString(" " + f.Tag.Value) + } + buf.WriteString("\n") + } + buf.WriteString("}\n\n") + return true +} + +func writeComment(buf *bytes.Buffer, cg *ast.CommentGroup) { + if cg == nil { + return + } + for _, c := range cg.List { + buf.WriteString(c.Text + "\n") + } +} + +func jsonName(f *ast.Field) string { + if f.Tag == nil { + return "" + } + tag, err := strconv.Unquote(f.Tag.Value) + if err != nil { + return "" + } + name, _, _ := strings.Cut(reflect.StructTag(tag).Get("json"), ",") + return name +} diff --git a/libs/apiclient/apiclient.go b/libs/apiclient/apiclient.go new file mode 100644 index 00000000000..066731902a0 --- /dev/null +++ b/libs/apiclient/apiclient.go @@ -0,0 +1,269 @@ +// Package apiclient issues hand-written REST calls with the CLI's resolved +// authentication, for endpoints that have no sdk-go client (or need raw access, +// e.g. `databricks api`). +package apiclient + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "maps" + "net/http" + "net/url" + "reflect" + "slices" + "strings" + + "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/sdk-go/core/apierr" +) + +// ErrHTMLContent is returned when a JSON response was expected but the server +// returned an HTML page, which usually means the host is not a Databricks API. +var ErrHTMLContent = errors.New("received HTML response instead of JSON") + +type Client struct { + Config *config.Config + + host string + httpClient *http.Client +} + +// New returns a client for cfg. cfg must already be resolved. +func New(cfg *config.Config) (*Client, error) { + if err := cfg.EnsureResolved(); err != nil { + return nil, err + } + return &Client{ + Config: cfg, + host: strings.TrimSuffix(cfg.CanonicalHostName(), "/"), + httpClient: HTTPClient(cfg), + }, nil +} + +// Do sends a request to path (relative to the host, or an absolute URL). +// +// For GET, DELETE and HEAD, request is encoded into the query string; for +// other methods it is the body: []byte, string and io.Reader are sent as is, +// anything else is JSON-encoded. queryParams are always added to the query. +// +// response may be nil, *[]byte, *bytes.Buffer, *io.ReadCloser (caller closes), +// or a value to JSON-decode into. Non-2xx responses are returned as +// *apierr.APIError. +func (c *Client) Do(ctx context.Context, method, path string, headers map[string]string, queryParams map[string]any, request, response any) error { + reqURL, err := c.url(path) + if err != nil { + return err + } + query := reqURL.Query() + if err := addQuery(query, queryParams); err != nil { + return err + } + + var body io.Reader + contentType := "" + if request != nil { + switch method { + case http.MethodGet, http.MethodDelete, http.MethodHead: + if err := addQuery(query, request); err != nil { + return err + } + default: + switch v := request.(type) { + case []byte: + body = bytes.NewReader(v) + case string: + body = strings.NewReader(v) + case io.Reader: + body = v + default: + data, err := json.Marshal(request) + if err != nil { + return fmt.Errorf("request marshal: %w", err) + } + body = bytes.NewReader(data) + contentType = "application/json" + } + } + } + reqURL.RawQuery = encodeQuery(query) + + req, err := http.NewRequestWithContext(ctx, method, reqURL.String(), body) + if err != nil { + return err + } + if contentType != "" { + req.Header.Set("Content-Type", contentType) + } + switch response.(type) { + case nil, *bytes.Buffer, *io.ReadCloser, *[]byte: + default: + req.Header.Set("Accept", "application/json") + } + for k, v := range headers { + req.Header.Set(k, v) + } + if err := c.Config.Authenticate(req); err != nil { + return err + } + + resp, err := c.httpClient.Do(req) + if err != nil { + return err + } + if rc, ok := response.(*io.ReadCloser); ok && resp.StatusCode < 400 { + *rc = resp.Body + return nil + } + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return fmt.Errorf("failed to read response body: %w", err) + } + if apiErr := apierr.FromHTTPError(resp.StatusCode, resp.Header, respBody); apiErr != nil { + return apiErr + } + return decodeResponse(respBody, response) +} + +func (c *Client) url(path string) (*url.URL, error) { + if strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://") { + return url.Parse(path) + } + if !strings.HasPrefix(path, "/") { + path = "/" + path + } + return url.Parse(c.host + path) +} + +func decodeResponse(body []byte, response any) error { + switch v := response.(type) { + case nil: + return nil + case *bytes.Buffer: + _, err := v.Write(body) + return err + case *[]byte: + *v = body + return nil + } + if len(body) == 0 { + return nil + } + if err := json.Unmarshal(body, response); err != nil { + if syntaxErr, ok := errors.AsType[*json.SyntaxError](err); ok && syntaxErr != nil && strings.HasPrefix(string(body), "<") { + return ErrHTMLContent + } + return fmt.Errorf("failed to unmarshal response body: %w", err) + } + return nil +} + +// addQuery adds v (a map, url.Values, or a JSON-encodable struct) to query. +// Zero values are skipped, matching what the APIs expect for optional fields. +func addQuery(query url.Values, v any) error { + switch x := v.(type) { + case nil: + return nil + case url.Values: + for k, vs := range x { + for _, s := range vs { + query.Add(k, s) + } + } + return nil + case map[string]string: + for _, k := range slices.Sorted(maps.Keys(x)) { + if x[k] != "" { + query.Add(k, x[k]) + } + } + return nil + case map[string]any: + // Like the previous SDK: nil values are skipped, everything else + // (including zero values such as 0 or false) is formatted with %v. + for _, k := range slices.Sorted(maps.Keys(x)) { + if v, ok := derefValue(x[k]); ok { + query.Add(k, fmt.Sprintf("%v", v)) + } + } + return nil + } + data, err := json.Marshal(v) + if err != nil { + return err + } + dec := json.NewDecoder(bytes.NewReader(data)) + dec.UseNumber() + var decoded any + if err := dec.Decode(&decoded); err != nil { + return err + } + if decoded == nil { + return nil + } + m, ok := decoded.(map[string]any) + if !ok { + return fmt.Errorf("unsupported query parameters: %T", v) + } + flatten(query, "", m) + return nil +} + +// derefValue follows pointers (optional fields of request types are pointers) +// and reports false for nil. +func derefValue(v any) (any, bool) { + rv := reflect.ValueOf(v) + for rv.Kind() == reflect.Pointer { + if rv.IsNil() { + return nil, false + } + rv = rv.Elem() + } + if !rv.IsValid() { + return nil, false + } + return rv.Interface(), true +} + +func flatten(query url.Values, prefix string, m map[string]any) { + for k, v := range m { + var key string + if prefix != "" { + key = prefix + "." + k + } else { + key = k + } + switch x := v.(type) { + case nil: + case map[string]any: + flatten(query, key, x) + case []any: + for _, item := range x { + query.Add(key, fmt.Sprint(item)) + } + case string: + if x != "" { + query.Add(key, x) + } + case bool: + if x { + query.Add(key, "true") + } + case json.Number: + if x.String() != "0" { + query.Add(key, x.String()) + } + default: + query.Add(key, fmt.Sprint(x)) + } + } +} + +// encodeQuery is url.Values.Encode with spaces as %20, as the old SDK did. +func encodeQuery(q url.Values) string { + return strings.ReplaceAll(q.Encode(), "+", "%20") +} diff --git a/libs/apiclient/apiclienttest/server.go b/libs/apiclient/apiclienttest/server.go new file mode 100644 index 00000000000..22e0e841a7a --- /dev/null +++ b/libs/apiclient/apiclienttest/server.go @@ -0,0 +1,35 @@ +// Package apiclienttest helps test hand-written API clients against an +// httptest server. +package apiclienttest + +import ( + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/databricks-sdk-go/config" + "github.com/stretchr/testify/require" +) + +// New starts a server with handler and returns a PAT-authenticated client for it. +func New(t *testing.T, handler http.HandlerFunc) *apiclient.Client { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // Config resolution probes host metadata; report it as absent. + if strings.HasPrefix(r.URL.Path, "/.well-known/") { + http.NotFound(w, r) + return + } + handler(w, r) + })) + t.Cleanup(srv.Close) + c, err := apiclient.New(&config.Config{ + Host: srv.URL, + Token: "token", + WorkspaceID: "123", + Loaders: []config.Loader{config.ConfigAttributes}, + }) + require.NoError(t, err) + return c +} diff --git a/libs/filer/files_client_auth.go b/libs/apiclient/credentials.go similarity index 66% rename from libs/filer/files_client_auth.go rename to libs/apiclient/credentials.go index 6ed9098532f..9ba3df50359 100644 --- a/libs/filer/files_client_auth.go +++ b/libs/apiclient/credentials.go @@ -1,4 +1,4 @@ -package filer +package apiclient import ( "context" @@ -9,27 +9,27 @@ import ( ) // configCredentials adapts the CLI's resolved SDK config into the credentials -// interface expected by the files/v2 client. It signs a throwaway +// interface expected by the sdk-go clients. It signs a throwaway // request with config.Authenticate and hands the resulting headers to the -// client, so the files/v2 client reuses the exact auth the rest of the CLI +// client, so the sdk-go clients reuses the exact auth the rest of the CLI // already resolved instead of re-reading a profile. -type configCredentials struct { +type credentials struct { cfg *config.Config } // Name reports the resolved auth mechanism (e.g. "pat", "oauth-m2m"), which the -// files/v2 client folds into its User-Agent. The CLI resolves auth when it +// sdk-go clients folds into its User-Agent. The CLI resolves auth when it // builds the workspace client, so AuthType is normally set before the filer is -// created; fall back to "unk" when it is empty because the files/v2 client +// created; fall back to "unk" when it is empty because the sdk-go clients // rejects an empty auth name with an "invalid value" error at construction. -func (c configCredentials) Name() string { +func (c credentials) Name() string { if c.cfg.AuthType == "" { return "unk" } return c.cfg.AuthType } -func (c configCredentials) AuthHeaders(ctx context.Context) ([]sdkauth.Header, error) { +func (c credentials) AuthHeaders(ctx context.Context) ([]sdkauth.Header, error) { // The URL is irrelevant: config.Authenticate only reads it to pick the auth // scheme, and every files/v2 request targets the same workspace host. req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.cfg.Host, nil) @@ -48,3 +48,8 @@ func (c configCredentials) AuthHeaders(ctx context.Context) ([]sdkauth.Header, e } return headers, nil } + +// NewCredentials returns sdk-go credentials that sign requests with cfg. +func NewCredentials(cfg *config.Config) sdkauth.Credentials { + return credentials{cfg: cfg} +} diff --git a/libs/apiclient/errorbody.go b/libs/apiclient/errorbody.go new file mode 100644 index 00000000000..dd0395319a6 --- /dev/null +++ b/libs/apiclient/errorbody.go @@ -0,0 +1,71 @@ +package apiclient + +import ( + "bytes" + "encoding/json" + "io" + "net/http" + "regexp" + "strings" +) + +var ( + stringErrorRegex = regexp.MustCompile(`^([A-Z_]+): (.*)$`) + htmlMessageRegex = regexp.MustCompile(`
(.*)
`) +) + +// normalizeErrorBody rewrites error responses that are not JSON objects into +// the standard {"error_code", "message"} shape, so sdk-go reports the same +// message and error code as the previous SDK did: proxies and some legacy +// endpoints answer with an empty body, plain text or an HTML page. +func normalizeErrorBody(resp *http.Response) error { + if resp.StatusCode < 400 || resp.Body == nil { + return nil + } + body, err := io.ReadAll(resp.Body) + _ = resp.Body.Close() + if err != nil { + return err + } + if normalized, ok := errorBodyFromText(resp, body); ok { + body = normalized + resp.Header.Set("Content-Type", "application/json") + resp.Header.Del("Content-Length") + resp.ContentLength = int64(len(body)) + } + resp.Body = io.NopCloser(bytes.NewReader(body)) + return nil +} + +func errorBodyFromText(resp *http.Response, body []byte) ([]byte, bool) { + var obj map[string]json.RawMessage + if json.Unmarshal(body, &obj) == nil { + return nil, false + } + var errorCode, message string + trimmed := bytes.TrimSpace(body) + switch { + case len(trimmed) == 0: + message = http.StatusText(resp.StatusCode) + case stringErrorRegex.Match(trimmed): + m := stringErrorRegex.FindSubmatch(trimmed) + errorCode, message = string(m[1]), string(m[2]) + case htmlMessageRegex.Match(body): + message = strings.Trim(string(htmlMessageRegex.FindSubmatch(body)[1]), " .") + errorCode = "UNKNOWN" + if _, status, ok := strings.Cut(resp.Status, " "); ok && strings.TrimSpace(status) != "" { + errorCode = strings.ReplaceAll(strings.ToUpper(strings.Trim(status, " .")), " ", "_") + } + default: + errorCode, message = "UNKNOWN", string(body) + } + out := map[string]string{"message": message} + if errorCode != "" { + out["error_code"] = errorCode + } + data, err := json.Marshal(out) + if err != nil { + return nil, false + } + return data, true +} diff --git a/libs/apiclient/errorbody_test.go b/libs/apiclient/errorbody_test.go new file mode 100644 index 00000000000..58b03c62b69 --- /dev/null +++ b/libs/apiclient/errorbody_test.go @@ -0,0 +1,35 @@ +package apiclient_test + +import ( + "net/http" + "testing" + + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/apiclient/apiclienttest" + "github.com/databricks/cli/libs/apierrs" + "github.com/stretchr/testify/assert" +) + +func TestNonJSONErrorBodies(t *testing.T) { + for _, tc := range []struct { + status int + body string + message string + errorCode string + }{ + {http.StatusNotFound, "", "Not Found", ""}, + {http.StatusInternalServerError, "INJECTED", "INJECTED", "UNKNOWN"}, + {http.StatusBadRequest, "INVALID_STATE: cluster is terminated", "cluster is terminated", "INVALID_STATE"}, + {http.StatusServiceUnavailable, "
Worker environment not ready.
", "Worker environment not ready", "SERVICE_UNAVAILABLE"}, + {http.StatusBadRequest, `{"error_code":"BAD","message":"json"}`, "json", "BAD"}, + } { + c := apiclienttest.New(t, func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(tc.status) + _, _ = w.Write([]byte(tc.body)) + }) + ctx := apiclient.WithMaxAttempts(t.Context(), 1) + err := c.Do(ctx, http.MethodGet, "/api/2.0/x", nil, nil, nil, nil) + assert.Equal(t, tc.message, apierrs.Message(err), tc.body) + assert.Equal(t, tc.errorCode, apierrs.ErrorCode(err), tc.body) + } +} diff --git a/libs/apiclient/max_attempts_test.go b/libs/apiclient/max_attempts_test.go new file mode 100644 index 00000000000..2194f3465ec --- /dev/null +++ b/libs/apiclient/max_attempts_test.go @@ -0,0 +1,25 @@ +package apiclient_test + +import ( + "net/http" + "sync/atomic" + "testing" + + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/apiclient/apiclienttest" + "github.com/databricks/cli/libs/apierrs" + "github.com/stretchr/testify/assert" +) + +func TestWithMaxAttemptsStopsRetrying(t *testing.T) { + var calls atomic.Int32 + c := apiclienttest.New(t, func(w http.ResponseWriter, r *http.Request) { + calls.Add(1) + w.WriteHeader(http.StatusServiceUnavailable) + }) + + ctx := apiclient.WithMaxAttempts(t.Context(), 2) + err := c.Do(ctx, http.MethodGet, "/api/2.0/x", nil, nil, nil, nil) + assert.True(t, apierrs.Is(err, apierrs.ErrTemporarilyUnavailable)) + assert.Equal(t, int32(2), calls.Load()) +} diff --git a/libs/apiclient/query_test.go b/libs/apiclient/query_test.go new file mode 100644 index 00000000000..84ea870745d --- /dev/null +++ b/libs/apiclient/query_test.go @@ -0,0 +1,21 @@ +package apiclient_test + +import ( + "net/http" + "testing" + + "github.com/databricks/cli/libs/apiclient/apiclienttest" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestQueryParamsDereferencePointers(t *testing.T) { + var query string + c := apiclienttest.New(t, func(w http.ResponseWriter, r *http.Request) { + query = r.URL.RawQuery + }) + var unset *bool + err := c.Do(t.Context(), http.MethodPost, "/api/2.0/x", nil, map[string]any{"no_compute": new(true), "skip": unset}, nil, nil) + require.NoError(t, err) + assert.Equal(t, "no_compute=true", query) +} diff --git a/libs/apiclient/timeout.go b/libs/apiclient/timeout.go new file mode 100644 index 00000000000..c7fd2ddb158 --- /dev/null +++ b/libs/apiclient/timeout.go @@ -0,0 +1,90 @@ +package apiclient + +import ( + "context" + "io" + "sync" + "time" +) + +// Ported from github.com/databricks/databricks-sdk-go/httpclient/timeout_context.go. +// +// The HTTP timeout is an inactivity timeout, as in the previous SDK: it is +// extended every time the request or response body is read, so large uploads +// and downloads are not cut off by a fixed deadline. + +const defaultHTTPTimeout = 60 * time.Second + +type timeoutTicker struct { + cancel context.CancelFunc + done <-chan struct{} + timeout time.Duration + lock sync.Mutex + deadline time.Time +} + +func newTimeoutContext(ctx context.Context, timeout time.Duration) (context.Context, *timeoutTicker) { + ctx, cancel := context.WithCancel(ctx) + t := &timeoutTicker{ + cancel: cancel, + done: ctx.Done(), + timeout: timeout, + deadline: time.Now().Add(timeout), + } + go t.run() + return ctx, t +} + +// Tick extends the deadline to now plus the timeout. +func (t *timeoutTicker) Tick() { + t.lock.Lock() + defer t.lock.Unlock() + t.deadline = time.Now().Add(t.timeout) +} + +func (t *timeoutTicker) Cancel() { + t.cancel() +} + +func (t *timeoutTicker) currentDeadline() time.Time { + t.lock.Lock() + defer t.lock.Unlock() + return t.deadline +} + +func (t *timeoutTicker) run() { + for { + ttl := time.Until(t.currentDeadline()) + if ttl <= 0 { + t.cancel() + return + } + timer := time.NewTimer(ttl) + select { + case <-timer.C: + case <-t.done: + timer.Stop() + return + } + } +} + +// tickingReadCloser extends the timeout on every read and, if cancelOnClose +// is set, releases the timeout context when closed. +type tickingReadCloser struct { + rc io.ReadCloser + t *timeoutTicker + cancelOnClose bool +} + +func (r tickingReadCloser) Read(p []byte) (int, error) { + defer r.t.Tick() + return r.rc.Read(p) +} + +func (r tickingReadCloser) Close() error { + if r.cancelOnClose { + defer r.t.Cancel() + } + return r.rc.Close() +} diff --git a/libs/apiclient/timeout_test.go b/libs/apiclient/timeout_test.go new file mode 100644 index 00000000000..4fd1cd30448 --- /dev/null +++ b/libs/apiclient/timeout_test.go @@ -0,0 +1,35 @@ +package apiclient_test + +import ( + "net/http" + "testing" + "time" + + "github.com/databricks/cli/libs/apiclient/apiclienttest" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestHTTPTimeoutIsInactivityTimeout(t *testing.T) { + c := apiclienttest.New(t, func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/slow" { + time.Sleep(2 * time.Second) + return + } + // Streams for longer than the timeout, but never stays silent that long. + flusher := w.(http.Flusher) + for range 4 { + _, _ = w.Write([]byte("x")) + flusher.Flush() + time.Sleep(500 * time.Millisecond) + } + }) + c.Config.HTTPTimeoutSeconds = 1 + + var body []byte + require.NoError(t, c.Do(t.Context(), http.MethodGet, "/stream", nil, nil, nil, &body)) + assert.Equal(t, "xxxx", string(body)) + + err := c.Do(t.Context(), http.MethodGet, "/slow", nil, nil, nil, nil) + assert.ErrorContains(t, err, "request timed out after 1s of inactivity") +} diff --git a/libs/apiclient/transport.go b/libs/apiclient/transport.go new file mode 100644 index 00000000000..547a446cb9a --- /dev/null +++ b/libs/apiclient/transport.go @@ -0,0 +1,226 @@ +package apiclient + +import ( + "bytes" + "cmp" + "context" + "crypto/tls" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "strconv" + "strings" + "time" + + "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/databricks-sdk-go/logger" + "github.com/databricks/databricks-sdk-go/logger/httplog" + "github.com/databricks/databricks-sdk-go/useragent" + "github.com/databricks/sdk-go/core/apierr" +) + +// transport makes sdk-go requests look like the ones the CLI always sent: the +// User-Agent is composed from the CLI's context (command, exec id, auth type, +// CI/CD and agent detection), the config's Headers hook is applied, and +// requests are dumped at debug level. +type transport struct { + cfg *config.Config + base http.RoundTripper +} + +func newTransport(cfg *config.Config) http.RoundTripper { + return &transport{cfg: cfg, base: baseTransport(cfg)} +} + +func baseTransport(cfg *config.Config) http.RoundTripper { + if cfg.HTTPTransport != nil { + return cfg.HTTPTransport + } + t := http.DefaultTransport.(*http.Transport).Clone() + if cfg.InsecureSkipVerify { + t.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + } + return t +} + +func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) { + ctx := useragent.InContext(req.Context(), useragent.AuthKey, t.cfg.AuthType) + for _, kv := range [][2]string{ + {useragent.CicdKey, useragent.CiCdProvider()}, + {useragent.RuntimeKey, useragent.Runtime()}, + {useragent.AgentKey, useragent.AgentProvider()}, + {useragent.MetaHarnessKey, useragent.MetaHarnessProvider()}, + } { + if kv[1] != "" { + //nolint:fatcontext + ctx = useragent.InContext(ctx, kv[0], kv[1]) + } + } + req = req.Clone(ctx) + req.Header.Set("User-Agent", useragent.FromContext(ctx)) + if t.cfg.Headers != nil { + if err := t.cfg.Headers(req); err != nil { + return nil, err + } + } + + return t.retry(ctx, req) +} + +// retry re-sends requests rejected with 429 or 503, as the previous SDK did +// for every call. sdk-go retries nothing by default. +func (t *transport) retry(ctx context.Context, req *http.Request) (*http.Response, error) { + timeout := time.Duration(t.cfg.RetryTimeoutSeconds) * time.Second + if timeout <= 0 { + timeout = defaultRetryTimeout + } + deadline := time.Now().Add(timeout) + maxAttempts, _ := ctx.Value(maxAttemptsKey{}).(int) + for attempt := 0; ; attempt++ { + resp, err := t.send(ctx, req) + if err != nil || !isRetriable(resp) || maxAttempts > 0 && attempt+1 >= maxAttempts { + return resp, err + } + wait := retryDelay(resp, attempt) + if time.Now().Add(wait).After(deadline) || req.Body != nil && req.GetBody == nil { + return resp, nil + } + _ = resp.Body.Close() + logger.Debugf(ctx, "retrying %s %s after %s: status %d", req.Method, req.URL.Path, wait, resp.StatusCode) + select { + case <-ctx.Done(): + return nil, ctx.Err() + case <-time.After(wait): + } + if req.GetBody != nil { + body, err := req.GetBody() + if err != nil { + return nil, err + } + req = req.Clone(ctx) + req.Body = body + } + } +} + +const defaultRetryTimeout = 5 * time.Minute + +// defaultDebugTruncateBytes is the previous SDK's default for how much of each +// request and response body value is logged at debug level. +const defaultDebugTruncateBytes = 96 + +type maxAttemptsKey struct{} + +// WithMaxAttempts caps how many times requests made with ctx are sent when +// the server answers 429 or 503, for callers where such an answer is not +// transient (e.g. a feature unavailable in a region). +func WithMaxAttempts(ctx context.Context, n int) context.Context { + return context.WithValue(ctx, maxAttemptsKey{}, n) +} + +func isRetriable(resp *http.Response) bool { + return resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode == http.StatusServiceUnavailable +} + +func retryDelay(resp *http.Response, attempt int) time.Duration { + if s, err := strconv.Atoi(resp.Header.Get("Retry-After")); err == nil && s >= 0 { + return time.Duration(s) * time.Second + } + return min(time.Duration(attempt+1)*time.Second, 10*time.Second) +} + +func (t *transport) send(ctx context.Context, req *http.Request) (*http.Response, error) { + timeout := time.Duration(t.cfg.HTTPTimeoutSeconds) * time.Second + if timeout <= 0 { + timeout = defaultHTTPTimeout + } + timeoutCtx, ticker := newTimeoutContext(ctx, timeout) + req = req.WithContext(timeoutCtx) + if req.Body != nil && req.Body != http.NoBody { + req.Body = tickingReadCloser{rc: req.Body, t: ticker} + } + resp, err := t.sendLogged(ctx, req) + if err != nil { + ticker.Cancel() + if ctx.Err() == nil && timeoutCtx.Err() != nil { + return nil, fmt.Errorf("request timed out after %s of inactivity", timeout) + } + return nil, err + } + if err := normalizeErrorBody(resp); err != nil { + ticker.Cancel() + return nil, err + } + if resp.Body != nil { + resp.Body = tickingReadCloser{rc: resp.Body, t: ticker, cancelOnClose: true} + } else { + ticker.Cancel() + } + if resp != nil && resp.StatusCode >= 400 { + // sdk-go errors keep the response headers but not the request; record + // it so error messages can name the failing endpoint (see RequestOf). + resp.Header.Set(requestHeader, req.Method+" "+req.URL.String()) + } + return resp, err +} + +// requestHeader is a synthetic response header carrying the request line of +// a failed call. It is never sent to the server. +const requestHeader = "X-Databricks-Cli-Request" + +// RequestOf returns the method and URL of the request that produced the API +// error in err's chain, when it was sent through this package's transport. +func RequestOf(err error) (method string, u *url.URL, ok bool) { + apiErr, isAPIErr := errors.AsType[*apierr.APIError](err) + if !isAPIErr { + return "", nil, false + } + method, rawURL, ok := strings.Cut(apiErr.HTTPHeader().Get(requestHeader), " ") + if !ok { + return "", nil, false + } + u, parseErr := url.Parse(rawURL) + if parseErr != nil { + return "", nil, false + } + return method, u, true +} + +func (t *transport) sendLogged(ctx context.Context, req *http.Request) (*http.Response, error) { + if !logger.Get(ctx).Enabled(ctx, logger.LevelDebug) { + return t.base.RoundTrip(req) + } + + var reqBody []byte + if req.Body != nil && req.GetBody != nil { + if body, err := req.GetBody(); err == nil { + reqBody, _ = io.ReadAll(body) + } + } + resp, err := t.base.RoundTrip(req) + var respBody []byte + if resp != nil && resp.Body != nil { + respBody, _ = io.ReadAll(resp.Body) + _ = resp.Body.Close() + resp.Body = io.NopCloser(bytes.NewReader(respBody)) + } + logger.Debugf(ctx, "%s", httplog.RoundTripStringer{ + Request: req, + Response: resp, + Err: err, + RequestBody: reqBody, + ResponseBody: respBody, + DebugHeaders: t.cfg.DebugHeaders, + DebugTruncateBytes: cmp.Or(t.cfg.DebugTruncateBytes, defaultDebugTruncateBytes), + DebugAuthorizationHeader: true, + }.String()) + return resp, err +} + +// HTTPClient returns an http.Client that sends requests the way sdk-go clients +// built by libs/sdkclients do. It does not authenticate requests. +func HTTPClient(cfg *config.Config) *http.Client { + return &http.Client{Transport: newTransport(cfg)} +} diff --git a/libs/apiclient/urlquery.go b/libs/apiclient/urlquery.go new file mode 100644 index 00000000000..124e9449555 --- /dev/null +++ b/libs/apiclient/urlquery.go @@ -0,0 +1,84 @@ +package apiclient + +import ( + "fmt" + "net/url" + "reflect" + "strings" +) + +// URLQuery encodes the fields of a request struct that carry `url` tags into +// query parameters, the way the previous SDK encoded GET/DELETE requests: +// `url:"-"` and untagged fields are skipped, `omitempty` drops zero values and +// nested structs use dotted keys. Pass the result as Do's request argument for +// GET, DELETE and HEAD. +func URLQuery(v any) url.Values { + q := url.Values{} + encodeStruct(q, "", reflect.ValueOf(v)) + return q +} + +// queryEncoder is implemented by types with a custom query encoding, such as +// field masks. +type queryEncoder interface { + EncodeValues(key string, v *url.Values) error +} + +func encodeStruct(q url.Values, prefix string, v reflect.Value) { + for v.Kind() == reflect.Pointer { + if v.IsNil() { + return + } + v = v.Elem() + } + if v.Kind() != reflect.Struct { + return + } + t := v.Type() + for i := range t.NumField() { + field := t.Field(i) + tag, ok := field.Tag.Lookup("url") + if !ok || tag == "-" || !field.IsExported() { + continue + } + name, opts, _ := strings.Cut(tag, ",") + if name == "" { + name = field.Name + } + if prefix != "" { + name = prefix + "." + name + } + fv := v.Field(i) + if strings.Contains(opts, "omitempty") && fv.IsZero() { + continue + } + encodeValue(q, name, fv) + } +} + +func encodeValue(q url.Values, key string, v reflect.Value) { + if v.CanAddr() { + if enc, ok := reflect.TypeAssert[queryEncoder](v.Addr()); ok { + _ = enc.EncodeValues(key, &q) + return + } + } + if enc, ok := reflect.TypeAssert[queryEncoder](v); ok { + _ = enc.EncodeValues(key, &q) + return + } + switch v.Kind() { + case reflect.Pointer: + if !v.IsNil() { + encodeValue(q, key, v.Elem()) + } + case reflect.Struct: + encodeStruct(q, key, v) + case reflect.Slice, reflect.Array: + for i := range v.Len() { + encodeValue(q, key, v.Index(i)) + } + default: + q.Add(key, fmt.Sprint(v.Interface())) + } +} diff --git a/libs/apiclient/workspace_id.go b/libs/apiclient/workspace_id.go new file mode 100644 index 00000000000..dc5d68c5b2a --- /dev/null +++ b/libs/apiclient/workspace_id.go @@ -0,0 +1,14 @@ +package apiclient + +// workspaceIDNone mirrors profile.WorkspaceIDNone; libs/databrickscfg/profile +// cannot be imported here because it (transitively) depends on this package. +const workspaceIDNone = "none" + +// AddWorkspaceIDHeader sets the workspace routing header that unified +// ("SPOG") hosts need. The CLI's "none" sentinel means "no workspace ID" and +// is not forwarded. +func (c *Client) AddWorkspaceIDHeader(headers map[string]string) { + if id := c.Config.WorkspaceID; id != "" && id != workspaceIDNone { + headers["X-Databricks-Workspace-Id"] = id + } +} diff --git a/libs/apierrs/apierrs.go b/libs/apierrs/apierrs.go new file mode 100644 index 00000000000..2ea68864e70 --- /dev/null +++ b/libs/apierrs/apierrs.go @@ -0,0 +1,151 @@ +// Package apierrs classifies Databricks API errors returned by sdk-go. +// +// sdk-go maps an error response to one canonical code and drops the legacy +// error_code strings many APIs still return (e.g. RESOURCE_DOES_NOT_EXIST with +// HTTP 400 from Jobs). The CLI branches on those, so this package keeps the +// classification the previous SDK used: one sentinel per HTTP status and per +// error_code, with error_code sentinels refining the status ones. +package apierrs + +import ( + "encoding/json" + "errors" + "regexp" + + "github.com/databricks/sdk-go/core/apierr" +) + +type sentinel struct { + parent *sentinel + message string +} + +func (s *sentinel) Error() string { return s.message } + +var ( + ErrBadRequest = &sentinel{message: "the request is invalid"} + ErrUnauthenticated = &sentinel{message: "the request does not have valid authentication (AuthN) credentials for the operation"} + ErrPermissionDenied = &sentinel{message: "the caller does not have permission to execute the specified operation"} + ErrNotFound = &sentinel{message: "the operation was performed on a resource that does not exist"} + ErrResourceConflict = &sentinel{message: "maps to all HTTP 409 (Conflict) responses"} + ErrTooManyRequests = &sentinel{message: "maps to HTTP code: 429 Too Many Requests"} + ErrCancelled = &sentinel{message: "the operation was explicitly canceled by the caller"} + ErrInternalError = &sentinel{message: "some invariants expected by the underlying system have been broken"} + ErrNotImplemented = &sentinel{message: "the operation is not implemented or is not supported/enabled in this service"} + ErrTemporarilyUnavailable = &sentinel{message: "the service is currently unavailable"} + ErrDeadlineExceeded = &sentinel{message: "the deadline expired before the operation could complete"} + ErrInvalidState = &sentinel{parent: ErrBadRequest, message: "unexpected state"} + ErrInvalidParameterValue = &sentinel{parent: ErrBadRequest, message: "supplied value for a parameter was invalid"} + ErrResourceDoesNotExist = &sentinel{parent: ErrNotFound, message: "operation was performed on a resource that does not exist"} + ErrAborted = &sentinel{parent: ErrResourceConflict, message: "the operation was aborted, typically due to a concurrency issue such as a sequencer check failure"} + ErrAlreadyExists = &sentinel{parent: ErrResourceConflict, message: "operation was rejected due a conflict with an existing resource"} + ErrResourceAlreadyExists = &sentinel{parent: ErrResourceConflict, message: "operation was rejected due a conflict with an existing resource"} + ErrResourceExhausted = &sentinel{parent: ErrTooManyRequests, message: "operation is rejected due to per-user rate limiting"} + ErrRequestLimitExceeded = &sentinel{parent: ErrTooManyRequests, message: "cluster request was rejected because it would exceed a resource limit"} + ErrUnknown = &sentinel{parent: ErrInternalError, message: "this error is used as a fallback if the platform-side mapping is missing some reason"} + ErrDataLoss = &sentinel{parent: ErrInternalError, message: "unrecoverable data loss or corruption"} +) + +var statusCodeMapping = map[int]*sentinel{ + 400: ErrBadRequest, + 401: ErrUnauthenticated, + 403: ErrPermissionDenied, + 404: ErrNotFound, + 409: ErrResourceConflict, + 429: ErrTooManyRequests, + 499: ErrCancelled, + 500: ErrInternalError, + 501: ErrNotImplemented, + 503: ErrTemporarilyUnavailable, + 504: ErrDeadlineExceeded, +} + +var errorCodeMapping = map[string]*sentinel{ + "INVALID_STATE": ErrInvalidState, + "INVALID_PARAMETER_VALUE": ErrInvalidParameterValue, + "RESOURCE_DOES_NOT_EXIST": ErrResourceDoesNotExist, + "ABORTED": ErrAborted, + "ALREADY_EXISTS": ErrAlreadyExists, + "RESOURCE_ALREADY_EXISTS": ErrResourceAlreadyExists, + "RESOURCE_EXHAUSTED": ErrResourceExhausted, + "REQUEST_LIMIT_EXCEEDED": ErrRequestLimitExceeded, + "UNKNOWN": ErrUnknown, + "DATA_LOSS": ErrDataLoss, +} + +// Clusters, Jobs and Runs GET endpoints report a missing object as 400 +// INVALID_PARAMETER_VALUE; the previous SDK reclassified these by message. +var missingObjectMessage = regexp.MustCompile(`(Cluster .* does not exist|Job .* does not exist|Run .* does not exist|Run: .* in job: .* doesn't exist)`) + +// Get returns the API error in err's chain. +func Get(err error) (*apierr.APIError, bool) { + return errors.AsType[*apierr.APIError](err) +} + +// StatusCode returns the HTTP status code of the API error in err's chain, or +// 0 if there is none. +func StatusCode(err error) int { + if e, ok := Get(err); ok { + return max(e.HTTPStatusCode(), 0) + } + return 0 +} + +// ErrorCode returns the error_code string of the API error in err's chain as +// sent by the server (e.g. "RESOURCE_DOES_NOT_EXIST"), or "" if there is none. +func ErrorCode(err error) string { + e, ok := Get(err) + if !ok { + return "" + } + var body struct { + ErrorCode any `json:"error_code"` + } + if json.Unmarshal(e.HTTPBody(), &body) != nil { + return "" + } + s, _ := body.ErrorCode.(string) + return s +} + +// Message returns the server-provided message of the API error in err's +// chain, or err.Error() if there is none. +func Message(err error) string { + if e, ok := Get(err); ok { + return e.Message() + } + return err.Error() +} + +// classify returns the most specific sentinel for e. +func classify(e *apierr.APIError) *sentinel { + code := ErrorCode(e) + if e.HTTPStatusCode() == 400 && code == "INVALID_PARAMETER_VALUE" && missingObjectMessage.MatchString(e.Message()) { + return ErrResourceDoesNotExist + } + if s, ok := errorCodeMapping[code]; ok { + return s + } + return statusCodeMapping[e.HTTPStatusCode()] +} + +// Is reports whether err is an API error of the given class, e.g. +// Is(err, ErrNotFound) holds for 404 responses and RESOURCE_DOES_NOT_EXIST. +// target must be one of the sentinels of this package. +func Is(err, target error) bool { + e, ok := Get(err) + if !ok { + return false + } + for s := classify(e); s != nil; s = s.parent { + if s == target { + return true + } + } + return false +} + +// IsMissing reports whether err says the requested resource does not exist. +func IsMissing(err error) bool { + return Is(err, ErrNotFound) +} diff --git a/libs/apierrs/format.go b/libs/apierrs/format.go new file mode 100644 index 00000000000..b267b0530ff --- /dev/null +++ b/libs/apierrs/format.go @@ -0,0 +1,53 @@ +package apierrs + +import ( + "strings" + + "github.com/databricks/sdk-go/core/apierr" +) + +// ErrorString returns err.Error() with every API error in err's tree rendered +// as just its server message. +// +// sdk-go renders API errors as "databricks-api error: "; the CLI has +// always shown only the message, so user-visible error text goes through here. +func ErrorString(err error) string { + msg := err.Error() + for _, apiErr := range all(err) { + msg = strings.Replace(msg, apiErr.Error(), apiErr.Message(), 1) + } + return msg +} + +// errorPrefix is what sdk-go's APIError.Error prepends to the server message. +const errorPrefix = "databricks-api error: " + +// StripPrefix removes sdk-go's API error prefix from text that already embeds +// formatted errors, such as log messages and diagnostics built with %v or %s. +func StripPrefix(s string) string { + return strings.ReplaceAll(s, errorPrefix, "") +} + +// all returns the API errors in err's tree, including joined errors. +func all(err error) []*apierr.APIError { + var result []*apierr.APIError + var walk func(error) + walk = func(e error) { + if e == nil { + return + } + if apiErr, ok := e.(*apierr.APIError); ok { + result = append(result, apiErr) + } + switch x := e.(type) { + case interface{ Unwrap() error }: + walk(x.Unwrap()) + case interface{ Unwrap() []error }: + for _, inner := range x.Unwrap() { + walk(inner) + } + } + } + walk(err) + return result +} diff --git a/libs/apierrs/format_test.go b/libs/apierrs/format_test.go new file mode 100644 index 00000000000..68b0fc89510 --- /dev/null +++ b/libs/apierrs/format_test.go @@ -0,0 +1,19 @@ +package apierrs + +import ( + "errors" + "fmt" + "testing" + + "github.com/databricks/sdk-go/core/apierr" + "github.com/stretchr/testify/assert" +) + +func TestErrorStringStripsSDKPrefix(t *testing.T) { + apiErr := apierr.FromHTTPError(404, nil, []byte(`{"error_code":"RESOURCE_DOES_NOT_EXIST","message":"Job 123 does not exist."}`)) + + assert.Equal(t, "Job 123 does not exist.", ErrorString(apiErr)) + assert.Equal(t, "cannot read job: Job 123 does not exist.", ErrorString(fmt.Errorf("cannot read job: %w", apiErr))) + assert.Equal(t, "a\nJob 123 does not exist.", ErrorString(errors.Join(errors.New("a"), apiErr))) + assert.Equal(t, "plain", ErrorString(errors.New("plain"))) +} diff --git a/libs/apps/generator/generator_internal_test.go b/libs/apps/generator/generator_internal_test.go index f89eef32b07..67d38d67f7a 100644 --- a/libs/apps/generator/generator_internal_test.go +++ b/libs/apps/generator/generator_internal_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/databricks/cli/libs/apps/manifest" - "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/cli/libs/sdktypes/apps/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/libs/apps/prompt/listers.go b/libs/apps/prompt/listers.go index 4bc2b1e301e..1baefe477d7 100644 --- a/libs/apps/prompt/listers.go +++ b/libs/apps/prompt/listers.go @@ -4,28 +4,34 @@ import ( "context" "errors" "fmt" + "iter" "maps" "net/http" "net/url" "strconv" "strings" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/listing" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/listing" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/dashboards" - "github.com/databricks/databricks-sdk-go/service/database" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" - "github.com/databricks/databricks-sdk-go/service/postgres" - "github.com/databricks/databricks-sdk-go/service/serving" - "github.com/databricks/databricks-sdk-go/service/sql" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/database/v1" + "github.com/databricks/sdk-go/experiments/v1" + "github.com/databricks/sdk-go/genie/v1" + "github.com/databricks/sdk-go/jobs/v2" + "github.com/databricks/sdk-go/modelserving/v1" + "github.com/databricks/sdk-go/postgres/v1" + "github.com/databricks/sdk-go/secrets/v1" + "github.com/databricks/sdk-go/uc/catalogs/v1" + "github.com/databricks/sdk-go/uc/connections/v1" + "github.com/databricks/sdk-go/uc/functions/v1" + "github.com/databricks/sdk-go/uc/schemas/v1" + "github.com/databricks/sdk-go/uc/volumes/v1" + "github.com/databricks/sdk-go/vectorsearch/v1" + "github.com/databricks/sdk-go/warehouses/v1" ) // maxListResults caps the number of items returned by listers to avoid @@ -46,7 +52,7 @@ func capResults(items []ListItem) []ListItem { return items } -func workspaceClient(ctx context.Context) (*databricks.WorkspaceClient, error) { +func workspaceClient(ctx context.Context) (*sdkclients.Clients, error) { w := cmdctx.WorkspaceClient(ctx) if w == nil { return nil, errors.New("no workspace client available") @@ -60,14 +66,13 @@ func ListSecretScopes(ctx context.Context) ([]ListItem, error) { if err != nil { return nil, err } - iter := w.Secrets.ListScopes(ctx) - scopes, err := listing.ToSlice(ctx, iter) + resp, err := w.Secrets.ListScopes(ctx, secrets.ListScopesRequest{}) if err != nil { return nil, err } - out := make([]ListItem, 0, len(scopes)) - for _, s := range scopes { - out = append(out, ListItem{ID: s.Name, Label: s.Name}) + out := make([]ListItem, 0, len(resp.Scopes)) + for _, s := range resp.Scopes { + out = append(out, ListItem{ID: utils.Deref(s.Name), Label: utils.Deref(s.Name)}) } return out, nil } @@ -78,14 +83,13 @@ func ListSecretKeys(ctx context.Context, scope string) ([]ListItem, error) { if err != nil { return nil, err } - iter := w.Secrets.ListSecrets(ctx, workspace.ListSecretsRequest{Scope: scope}) - keys, err := listing.ToSlice(ctx, iter) + resp, err := w.Secrets.ListSecrets(ctx, secrets.ListSecretsRequest{Scope: new(scope)}) if err != nil { return nil, err } - out := make([]ListItem, 0, len(keys)) - for _, k := range keys { - out = append(out, ListItem{ID: k.Key, Label: k.Key}) + out := make([]ListItem, 0, len(resp.Secrets)) + for _, k := range resp.Secrets { + out = append(out, ListItem{ID: utils.Deref(k.Key), Label: utils.Deref(k.Key)}) } return out, nil } @@ -96,14 +100,13 @@ func ListSchemas(ctx context.Context, catalogName string) ([]ListItem, error) { if err != nil { return nil, err } - schemaIter := w.Schemas.List(ctx, catalog.ListSchemasRequest{CatalogName: catalogName}) - schemas, err := listing.ToSlice(ctx, schemaIter) + schemas, err := collectAll(w.Schemas.ListSchemasIter(ctx, schemas.ListSchemasRequest{CatalogName: new(catalogName)})) if err != nil { return nil, err } out := make([]ListItem, 0, min(len(schemas), maxListResults)) for _, s := range schemas { - out = append(out, ListItem{ID: s.Name, Label: s.Name}) + out = append(out, ListItem{ID: utils.Deref(s.Name), Label: utils.Deref(s.Name)}) } return capResults(out), nil } @@ -114,18 +117,17 @@ func ListVolumesInSchema(ctx context.Context, catalogName, schemaName string) ([ if err != nil { return nil, err } - volIter := w.Volumes.List(ctx, catalog.ListVolumesRequest{ - CatalogName: catalogName, - SchemaName: schemaName, - }) - vols, err := listing.ToSlice(ctx, volIter) + vols, err := collectAll(w.Volumes.ListVolumesIter(ctx, volumes.ListVolumesRequest{ + CatalogName: new(catalogName), + SchemaName: new(schemaName), + })) if err != nil { return nil, err } out := make([]ListItem, 0, min(len(vols), maxListResults)) for _, v := range vols { - volumePath := fmt.Sprintf("/Volumes/%s/%s/%s", catalogName, schemaName, v.Name) - out = append(out, ListItem{ID: volumePath, Label: v.Name}) + volumePath := fmt.Sprintf("/Volumes/%s/%s/%s", catalogName, schemaName, utils.Deref(v.Name)) + out = append(out, ListItem{ID: volumePath, Label: utils.Deref(v.Name)}) } return capResults(out), nil } @@ -136,21 +138,20 @@ func ListFunctionsInSchema(ctx context.Context, catalogName, schemaName string) if err != nil { return nil, err } - fnIter := w.Functions.List(ctx, catalog.ListFunctionsRequest{ - CatalogName: catalogName, - SchemaName: schemaName, - }) - fns, err := listing.ToSlice(ctx, fnIter) + fns, err := collectAll(w.Functions.ListFunctionsIter(ctx, functions.ListFunctionsRequest{ + CatalogName: new(catalogName), + SchemaName: new(schemaName), + })) if err != nil { return nil, err } out := make([]ListItem, 0, min(len(fns), maxListResults)) for _, f := range fns { - fullName := f.FullName + fullName := utils.Deref(f.FullName) if fullName == "" { - fullName = fmt.Sprintf("%s.%s.%s", catalogName, schemaName, f.Name) + fullName = fmt.Sprintf("%s.%s.%s", catalogName, schemaName, utils.Deref(f.Name)) } - out = append(out, ListItem{ID: fullName, Label: f.Name}) + out = append(out, ListItem{ID: fullName, Label: utils.Deref(f.Name)}) } return capResults(out), nil } @@ -169,7 +170,7 @@ func ListDatabases(ctx context.Context, instanceName string) ([]ListItem, error) if err != nil { return nil, err } - api, err := client.New(w.Config) + api, err := apiclient.New(w.Config) if err != nil { return nil, err } @@ -210,26 +211,25 @@ func ListPostgresBranches(ctx context.Context, projectName string) ([]ListItem, if err != nil { return nil, err } - iter := w.Postgres.ListBranches(ctx, postgres.ListBranchesRequest{Parent: projectName}) - branches, err := listing.ToSlice(ctx, iter) + branches, err := collectAll(w.Postgres.ListBranchesIter(ctx, postgres.ListBranchesRequest{Parent: new(projectName)})) if err != nil { return nil, err } out := make([]ListItem, 0, len(branches)) for _, b := range branches { - label := extractIDFromName(b.Name, "branches") + label := extractIDFromName(utils.Deref(b.Name), "branches") if b.Status != nil { - if b.Status.Default { + if utils.Deref(b.Status.Default) { label += " (default)" } - if b.Status.IsProtected { + if utils.Deref(b.Status.IsProtected) { label += " (protected)" } - if b.Status.CurrentState == postgres.BranchStatusStateArchived { + if b.Status.CurrentState == postgres.BranchStatus_State_Archived { label += " (archived)" } } - out = append(out, ListItem{ID: b.Name, Label: label}) + out = append(out, ListItem{ID: utils.Deref(b.Name), Label: label}) } return out, nil } @@ -240,31 +240,29 @@ func ListPostgresDatabases(ctx context.Context, branchName string) ([]ListItem, if err != nil { return nil, err } - iter := w.Postgres.ListDatabases(ctx, postgres.ListDatabasesRequest{Parent: branchName}) - databases, err := listing.ToSlice(ctx, iter) + databases, err := collectAll(w.Postgres.ListDatabasesIter(ctx, postgres.ListDatabasesRequest{Parent: new(branchName)})) if err != nil { return nil, err } out := make([]ListItem, 0, len(databases)) for _, db := range databases { - label := extractIDFromName(db.Name, "databases") - if db.Status != nil && db.Status.PostgresDatabase != "" { - label = db.Status.PostgresDatabase + label := extractIDFromName(utils.Deref(db.Name), "databases") + if db.Status != nil && utils.Deref(db.Status.PostgresDatabase) != "" { + label = *db.Status.PostgresDatabase } - out = append(out, ListItem{ID: db.Name, Label: label}) + out = append(out, ListItem{ID: utils.Deref(db.Name), Label: label}) } return out, nil } // ListPostgresEndpoints returns endpoints for a branch as raw Endpoint objects. // Returns raw objects (not ListItem) since we need multiple fields (Name, Status.Hosts.Host). -func ListPostgresEndpoints(ctx context.Context, branchName string) ([]postgres.Endpoint, error) { +func ListPostgresEndpoints(ctx context.Context, branchName string) ([]*postgres.Endpoint, error) { w, err := workspaceClient(ctx) if err != nil { return nil, err } - iter := w.Postgres.ListEndpoints(ctx, postgres.ListEndpointsRequest{Parent: branchName}) - return listing.ToSlice(ctx, iter) + return collectAll(w.Postgres.ListEndpointsIter(ctx, postgres.ListEndpointsRequest{Parent: new(branchName)})) } // --------------------------------------------------------------------------- @@ -278,13 +276,13 @@ func ListSQLWarehouses(ctx context.Context) (*PagedFetcher, error) { if err != nil { return nil, err } - iter := w.Warehouses.List(ctx, sql.ListWarehousesRequest{PageSize: pageSize}) - mapFn := func(wh sql.EndpointInfo) ListItem { - label := wh.Name + iter := listing.FromSeq(w.Warehouses.ListWarehousesIter(ctx, warehouses.ListWarehousesRequest{PageSize: new(pageSize)})) + mapFn := func(wh *warehouses.EndpointInfo) ListItem { + label := utils.Deref(wh.Name) if wh.State != "" { - label = fmt.Sprintf("%s (%s)", wh.Name, wh.State) + label = fmt.Sprintf("%s (%s)", utils.Deref(wh.Name), wh.State) } - return ListItem{ID: wh.Id, Label: label} + return ListItem{ID: utils.Deref(wh.Id), Label: label} } items, hasMore, err := collectN(ctx, iter, pageSize, mapFn) if err != nil { @@ -306,10 +304,10 @@ func ListJobs(ctx context.Context) (*PagedFetcher, error) { return nil, err } apiLimit := min(pageSize, 100) - iter := w.Jobs.List(ctx, jobs.ListJobsRequest{Limit: apiLimit}) - mapFn := func(j jobs.BaseJob) ListItem { - label := j.Settings.Name - id := strconv.FormatInt(j.JobId, 10) + iter := listing.FromSeq(w.Jobs.ListJobsIter(ctx, jobs.ListJobsRequest{Limit: new(apiLimit)})) + mapFn := func(j *jobs.BaseJob) ListItem { + label := jobName(j) + id := strconv.FormatInt(utils.Deref(j.JobId), 10) if label == "" { label = id } @@ -334,15 +332,14 @@ func SearchJobs(ctx context.Context, name string) ([]ListItem, error) { if err != nil { return nil, err } - iter := w.Jobs.List(ctx, jobs.ListJobsRequest{Name: name}) - jobList, err := listing.ToSlice(ctx, iter) + jobList, err := collectAll(w.Jobs.ListJobsIter(ctx, jobs.ListJobsRequest{Name: new(name)})) if err != nil { return nil, err } out := make([]ListItem, 0, len(jobList)) for _, j := range jobList { - label := j.Settings.Name - id := strconv.FormatInt(j.JobId, 10) + label := jobName(j) + id := strconv.FormatInt(utils.Deref(j.JobId), 10) if label == "" { label = id } @@ -357,15 +354,19 @@ func ListServingEndpoints(ctx context.Context) (*PagedFetcher, error) { if err != nil { return nil, err } - iter := w.ServingEndpoints.List(ctx) - mapFn := func(e serving.ServingEndpoint) ListItem { - name := e.Name + resp, err := w.ServingEndpoints.ListInferenceEndpoints(ctx, modelserving.ListInferenceEndpointsRequest{}) + if err != nil { + return nil, err + } + iter := listing.SliceIterator[modelserving.InferenceEndpoint](resp.Endpoints) + mapFn := func(e modelserving.InferenceEndpoint) ListItem { + name := utils.Deref(e.Name) if name == "" { - name = e.Id + name = utils.Deref(e.Id) } - return ListItem{ID: e.Name, Label: name} + return ListItem{ID: utils.Deref(e.Name), Label: name} } - items, hasMore, err := collectN(ctx, iter, pageSize, mapFn) + items, hasMore, err := collectN(ctx, &iter, pageSize, mapFn) if err != nil { return nil, err } @@ -373,7 +374,7 @@ func ListServingEndpoints(ctx context.Context) (*PagedFetcher, error) { Items: items, HasMore: hasMore, loadMore: func(ctx context.Context) ([]ListItem, bool, error) { - return collectN(ctx, iter, pageSize, mapFn) + return collectN(ctx, &iter, pageSize, mapFn) }, }, nil } @@ -384,13 +385,13 @@ func ListExperiments(ctx context.Context) (*PagedFetcher, error) { if err != nil { return nil, err } - iter := w.Experiments.ListExperiments(ctx, ml.ListExperimentsRequest{MaxResults: int64(pageSize)}) - mapFn := func(e ml.Experiment) ListItem { - label := e.Name + iter := listing.FromSeq(w.Experiments.ListExperimentsIter(ctx, experiments.ListExperimentsRequest{MaxResults: new(int64(pageSize))})) + mapFn := func(e *experiments.Experiment) ListItem { + label := utils.Deref(e.Name) if label == "" { - label = e.ExperimentId + label = utils.Deref(e.ExperimentId) } - return ListItem{ID: e.ExperimentId, Label: label} + return ListItem{ID: utils.Deref(e.ExperimentId), Label: label} } items, hasMore, err := collectN(ctx, iter, pageSize, mapFn) if err != nil { @@ -413,24 +414,24 @@ func ListGenieSpaces(ctx context.Context) (*PagedFetcher, error) { } var nextToken string fetchPage := func(ctx context.Context) ([]ListItem, bool, error) { - req := dashboards.GenieListSpacesRequest{PageToken: nextToken, PageSize: pageSize} - resp, err := w.Genie.ListSpaces(ctx, req) + req := genie.GenieListSpacesRequest{PageToken: new(nextToken), PageSize: new(pageSize)} + resp, err := w.Genie.GenieListSpaces(ctx, req) if err != nil { return nil, false, err } items := make([]ListItem, 0, len(resp.Spaces)) for _, s := range resp.Spaces { - id := s.SpaceId - label := s.Title + id := utils.Deref(s.SpaceId) + label := utils.Deref(s.Title) if label == "" { - label = s.Description + label = utils.Deref(s.Description) } if label == "" { label = id } items = append(items, ListItem{ID: id, Label: label}) } - nextToken = resp.NextPageToken + nextToken = utils.Deref(resp.NextPageToken) return items, nextToken != "", nil } items, hasMore, err := fetchPage(ctx) @@ -450,13 +451,13 @@ func ListConnections(ctx context.Context) (*PagedFetcher, error) { if err != nil { return nil, err } - iter := w.Connections.List(ctx, catalog.ListConnectionsRequest{MaxResults: pageSize}) - mapFn := func(c catalog.ConnectionInfo) ListItem { - name := c.Name + iter := listing.FromSeq(w.Connections.ListConnectionsIter(ctx, connections.ListConnectionsRequest{MaxResults: new(pageSize)})) + mapFn := func(c *connections.ConnectionInfo) ListItem { + name := utils.Deref(c.Name) if name == "" { - name = c.FullName + name = utils.Deref(c.FullName) } - return ListItem{ID: c.FullName, Label: name} + return ListItem{ID: utils.Deref(c.FullName), Label: name} } items, hasMore, err := collectN(ctx, iter, pageSize, mapFn) if err != nil { @@ -482,26 +483,25 @@ func ListVectorSearchIndexes(ctx context.Context) (*PagedFetcher, error) { return nil, err } var out []ListItem - epIter := w.VectorSearchEndpoints.ListEndpoints(ctx, vectorsearch.ListEndpointsRequest{}) - endpoints, err := listing.ToSlice(ctx, epIter) + endpoints, err := collectAll(w.VectorSearch.ListEndpointsIter(ctx, vectorsearch.ListEndpointsRequest{})) if err != nil { return nil, err } capped := false for _, ep := range endpoints { - indexIter := w.VectorSearchIndexes.ListIndexes(ctx, vectorsearch.ListIndexesRequest{EndpointName: ep.Name}) - indexes, err := listing.ToSlice(ctx, indexIter) + epName := utils.Deref(ep.Name) + indexes, err := collectAll(w.VectorSearch.ListVectorIndexIter(ctx, vectorsearch.ListVectorIndexRequest{EndpointName: ep.Name})) if err != nil { - log.Warnf(ctx, "Failed to list indexes for endpoint %q: %v", ep.Name, err) + log.Warnf(ctx, "Failed to list indexes for endpoint %q: %v", epName, err) continue } for _, idx := range indexes { - label := idx.Name + label := utils.Deref(idx.Name) if label == "" { - label = ep.Name + "/ (unnamed)" + label = epName + "/ (unnamed)" } - id := ep.Name + "/" + idx.Name - out = append(out, ListItem{ID: id, Label: fmt.Sprintf("%s / %s", ep.Name, label)}) + id := epName + "/" + utils.Deref(idx.Name) + out = append(out, ListItem{ID: id, Label: fmt.Sprintf("%s / %s", epName, label)}) if len(out) >= maxTotalResults { capped = true break @@ -525,9 +525,9 @@ func ListCatalogs(ctx context.Context) (*PagedFetcher, error) { if err != nil { return nil, err } - iter := w.Catalogs.List(ctx, catalog.ListCatalogsRequest{MaxResults: pageSize}) - mapFn := func(c catalog.CatalogInfo) ListItem { - return ListItem{ID: c.Name, Label: c.Name} + iter := listing.FromSeq(w.Catalogs.ListCatalogsIter(ctx, catalogs.ListCatalogsRequest{MaxResults: new(pageSize)})) + mapFn := func(c *catalogs.CatalogInfo) ListItem { + return ListItem{ID: utils.Deref(c.Name), Label: utils.Deref(c.Name)} } items, hasMore, err := collectN(ctx, iter, pageSize, mapFn) if err != nil { @@ -549,9 +549,9 @@ func ListDatabaseInstances(ctx context.Context) (*PagedFetcher, error) { return nil, err } apiLimit := min(pageSize, 100) - iter := w.Database.ListDatabaseInstances(ctx, database.ListDatabaseInstancesRequest{PageSize: apiLimit}) - mapFn := func(inst database.DatabaseInstance) ListItem { - return ListItem{ID: inst.Name, Label: inst.Name} + iter := listing.FromSeq(w.Database.ListDatabaseInstancesIter(ctx, database.ListDatabaseInstancesRequest{PageSize: new(apiLimit)})) + mapFn := func(inst *database.DatabaseInstance) ListItem { + return ListItem{ID: utils.Deref(inst.Name), Label: utils.Deref(inst.Name)} } items, hasMore, err := collectN(ctx, iter, apiLimit, mapFn) if err != nil { @@ -573,13 +573,13 @@ func ListPostgresProjects(ctx context.Context) (*PagedFetcher, error) { return nil, err } apiLimit := min(pageSize, 100) - iter := w.Postgres.ListProjects(ctx, postgres.ListProjectsRequest{PageSize: apiLimit}) - mapFn := func(p postgres.Project) ListItem { - label := p.Name - if p.Status != nil && p.Status.DisplayName != "" { - label = p.Status.DisplayName + iter := listing.FromSeq(w.Postgres.ListProjectsIter(ctx, postgres.ListProjectsRequest{PageSize: new(apiLimit)})) + mapFn := func(p *postgres.Project) ListItem { + label := utils.Deref(p.Name) + if p.Status != nil && utils.Deref(p.Status.DisplayName) != "" { + label = *p.Status.DisplayName } - return ListItem{ID: p.Name, Label: label} + return ListItem{ID: utils.Deref(p.Name), Label: label} } items, hasMore, err := collectN(ctx, iter, apiLimit, mapFn) if err != nil { @@ -593,3 +593,23 @@ func ListPostgresProjects(ctx context.Context) (*PagedFetcher, error) { }, }, nil } + +// jobName returns the job's configured name, or "" when it has none. +func jobName(j *jobs.BaseJob) string { + if j.Settings == nil { + return "" + } + return utils.Deref(j.Settings.Name) +} + +// collectAll drains an sdk-go list sequence. +func collectAll[T any](seq iter.Seq2[*T, error]) ([]*T, error) { + var out []*T + for v, err := range seq { + if err != nil { + return nil, err + } + out = append(out, v) + } + return out, nil +} diff --git a/libs/apps/prompt/paged.go b/libs/apps/prompt/paged.go index 97300e1f01d..48c9cf3f162 100644 --- a/libs/apps/prompt/paged.go +++ b/libs/apps/prompt/paged.go @@ -3,7 +3,7 @@ package prompt import ( "context" - "github.com/databricks/databricks-sdk-go/listing" + "github.com/databricks/cli/libs/listing" ) const ( diff --git a/libs/apps/prompt/prompt.go b/libs/apps/prompt/prompt.go index 6bbbaaa2d28..e21b480614d 100644 --- a/libs/apps/prompt/prompt.go +++ b/libs/apps/prompt/prompt.go @@ -17,9 +17,9 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go/listing" - "github.com/databricks/databricks-sdk-go/service/apps" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/apps/v1" + "github.com/databricks/sdk-go/postgres/v1" ) // DefaultAppDescription is the default description for new apps. @@ -989,10 +989,10 @@ func ResolvePostgresValues(ctx context.Context, r manifest.Resource, branchName, return nil, fmt.Errorf("resolving endpoint details: %w", err) } for _, ep := range endpoints { - if ep.Status != nil && ep.Status.EndpointType == postgres.EndpointTypeEndpointTypeReadWrite { - endpointPath = ep.Name - if ep.Status.Hosts != nil && ep.Status.Hosts.Host != "" { - host = ep.Status.Hosts.Host + if ep.Status != nil && ep.Status.EndpointType == postgres.EndpointType_EndpointTypeReadWrite { + endpointPath = utils.Deref(ep.Name) + if ep.Status.Hosts != nil && utils.Deref(ep.Status.Hosts.Host) != "" { + host = *ep.Status.Hosts.Host } break } @@ -1124,14 +1124,13 @@ func RunWithSpinnerCtx(ctx context.Context, title string, action func() error) e } // ListAllApps fetches all apps the user has access to from the workspace. -func ListAllApps(ctx context.Context) ([]apps.App, error) { +func ListAllApps(ctx context.Context) ([]*apps.App, error) { w := cmdctx.WorkspaceClient(ctx) if w == nil { return nil, errors.New("no workspace client available") } - iter := w.Apps.List(ctx, apps.ListAppsRequest{}) - return listing.ToSlice(ctx, iter) + return collectAll(w.Apps.ListAppsIter(ctx, apps.ListAppsRequest{})) } // PromptForAppSelection shows a picker to select an existing app. @@ -1142,7 +1141,7 @@ func PromptForAppSelection(ctx context.Context, title string) (string, error) { } // Fetch all apps the user has access to - var existingApps []apps.App + var existingApps []*apps.App err := RunWithSpinnerCtx(ctx, "Fetching apps...", func() error { var fetchErr error existingApps, fetchErr = ListAllApps(ctx) @@ -1161,15 +1160,15 @@ func PromptForAppSelection(ctx context.Context, title string) (string, error) { // Build options options := make([]huh.Option[string], 0, len(existingApps)) for _, app := range existingApps { - label := app.Name - if app.Description != "" { - desc := app.Description + label := utils.Deref(app.Name) + if utils.Deref(app.Description) != "" { + desc := *app.Description if len(desc) > 40 { desc = desc[:37] + "..." } label += " — " + desc } - options = append(options, huh.NewOption(label, app.Name)) + options = append(options, huh.NewOption(label, utils.Deref(app.Name))) } var selected string diff --git a/libs/apps/prompt/resolve_postgres_test.go b/libs/apps/prompt/resolve_postgres_test.go index bb1c82e4c2d..55fbab2e0c2 100644 --- a/libs/apps/prompt/resolve_postgres_test.go +++ b/libs/apps/prompt/resolve_postgres_test.go @@ -2,21 +2,27 @@ package prompt_test import ( "context" - "errors" + "net/http" "testing" "github.com/databricks/cli/libs/apps/manifest" "github.com/databricks/cli/libs/apps/prompt" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/listing" - "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/cli/libs/httpfixtures" + "github.com/databricks/cli/libs/sdkclients" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) +const ( + testBranch = "projects/p1/branches/main" + endpointsResource = "/api/2.0/postgres/" + testBranch + "/endpoints" + databasesResource = "/api/2.0/postgres/" + testBranch + "/databases" + readWriteEndpoint = `{"endpoints":[{"name":"projects/p1/branches/main/endpoints/ep1","status":{"endpoint_type":"ENDPOINT_TYPE_READ_WRITE","hosts":{"host":"my-host.example.com"}}}]}` + unavailableResponse = `{"error_code":"TEMPORARILY_UNAVAILABLE","message":"API unavailable"}` +) + func newPostgresResource() manifest.Resource { return manifest.Resource{ ResourceKey: "postgres", @@ -30,40 +36,22 @@ func newPostgresResource() manifest.Resource { } } -func TestResolvePostgresValuesHappyPath(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), m.WorkspaceClient) - - branchName := "projects/p1/branches/main" - dbName := "projects/p1/branches/main/databases/mydb" - - // Mock ListEndpoints - endpoints := listing.SliceIterator[postgres.Endpoint]{ - { - Name: "projects/p1/branches/main/endpoints/ep1", - Status: &postgres.EndpointStatus{ - EndpointType: postgres.EndpointTypeEndpointTypeReadWrite, - Hosts: &postgres.EndpointHosts{Host: "my-host.example.com"}, - }, - }, - } - m.GetMockPostgresAPI().EXPECT(). - ListEndpoints(mock.Anything, postgres.ListEndpointsRequest{Parent: branchName}). - Return(&endpoints).Once() +// postgresContext serves the fixtures and returns a context with a workspace +// client pointing at them. Unexpected requests fail the test. +func postgresContext(t *testing.T, fixtures httpfixtures.Fixtures) context.Context { + cfg, _ := fixtures.Config(t) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) + return cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), w) +} - // Mock ListDatabases - databases := listing.SliceIterator[postgres.Database]{ - { - Name: dbName, - Status: &postgres.DatabaseDatabaseStatus{PostgresDatabase: "my_pg_db"}, - }, - } - m.GetMockPostgresAPI().EXPECT(). - ListDatabases(mock.Anything, postgres.ListDatabasesRequest{Parent: branchName}). - Return(&databases).Once() +func TestResolvePostgresValuesHappyPath(t *testing.T) { + ctx := postgresContext(t, httpfixtures.Fixtures{ + {Method: "GET", Resource: endpointsResource, Response: readWriteEndpoint}, + {Method: "GET", Resource: databasesResource, Response: `{"databases":[{"name":"projects/p1/branches/main/databases/mydb","status":{"postgres_database":"my_pg_db"}}]}`}, + }) - r := newPostgresResource() - result, err := prompt.ResolvePostgresValues(ctx, r, branchName, dbName, "") + result, err := prompt.ResolvePostgresValues(ctx, newPostgresResource(), testBranch, testBranch+"/databases/mydb", "") require.NoError(t, err) assert.Equal(t, map[string]string{ @@ -74,37 +62,12 @@ func TestResolvePostgresValuesHappyPath(t *testing.T) { } func TestResolvePostgresValuesNoReadWriteEndpoint(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), m.WorkspaceClient) - - branchName := "projects/p1/branches/main" - dbName := "projects/p1/branches/main/databases/mydb" - - // Return only a read-only endpoint. - endpoints := listing.SliceIterator[postgres.Endpoint]{ - { - Name: "projects/p1/branches/main/endpoints/ep1", - Status: &postgres.EndpointStatus{ - EndpointType: postgres.EndpointTypeEndpointTypeReadOnly, - }, - }, - } - m.GetMockPostgresAPI().EXPECT(). - ListEndpoints(mock.Anything, postgres.ListEndpointsRequest{Parent: branchName}). - Return(&endpoints).Once() + ctx := postgresContext(t, httpfixtures.Fixtures{ + {Method: "GET", Resource: endpointsResource, Response: `{"endpoints":[{"name":"projects/p1/branches/main/endpoints/ep1","status":{"endpoint_type":"ENDPOINT_TYPE_READ_ONLY"}}]}`}, + {Method: "GET", Resource: databasesResource, Response: `{"databases":[{"name":"projects/p1/branches/main/databases/mydb","status":{"postgres_database":"my_pg_db"}}]}`}, + }) - databases := listing.SliceIterator[postgres.Database]{ - { - Name: dbName, - Status: &postgres.DatabaseDatabaseStatus{PostgresDatabase: "my_pg_db"}, - }, - } - m.GetMockPostgresAPI().EXPECT(). - ListDatabases(mock.Anything, postgres.ListDatabasesRequest{Parent: branchName}). - Return(&databases).Once() - - r := newPostgresResource() - result, err := prompt.ResolvePostgresValues(ctx, r, branchName, dbName, "") + result, err := prompt.ResolvePostgresValues(ctx, newPostgresResource(), testBranch, testBranch+"/databases/mydb", "") require.NoError(t, err) // host and endpointPath should be empty since no ReadWrite endpoint found. @@ -116,38 +79,12 @@ func TestResolvePostgresValuesNoReadWriteEndpoint(t *testing.T) { } func TestResolvePostgresValuesDatabaseNotFound(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), m.WorkspaceClient) - - branchName := "projects/p1/branches/main" - dbName := "projects/p1/branches/main/databases/nonexistent" + ctx := postgresContext(t, httpfixtures.Fixtures{ + {Method: "GET", Resource: endpointsResource, Response: readWriteEndpoint}, + {Method: "GET", Resource: databasesResource, Response: `{"databases":[{"name":"projects/p1/branches/main/databases/other","status":{"postgres_database":"other_db"}}]}`}, + }) - endpoints := listing.SliceIterator[postgres.Endpoint]{ - { - Name: "projects/p1/branches/main/endpoints/ep1", - Status: &postgres.EndpointStatus{ - EndpointType: postgres.EndpointTypeEndpointTypeReadWrite, - Hosts: &postgres.EndpointHosts{Host: "my-host.example.com"}, - }, - }, - } - m.GetMockPostgresAPI().EXPECT(). - ListEndpoints(mock.Anything, postgres.ListEndpointsRequest{Parent: branchName}). - Return(&endpoints).Once() - - // Return databases that don't match dbName. - databases := listing.SliceIterator[postgres.Database]{ - { - Name: "projects/p1/branches/main/databases/other", - Status: &postgres.DatabaseDatabaseStatus{PostgresDatabase: "other_db"}, - }, - } - m.GetMockPostgresAPI().EXPECT(). - ListDatabases(mock.Anything, postgres.ListDatabasesRequest{Parent: branchName}). - Return(&databases).Once() - - r := newPostgresResource() - result, err := prompt.ResolvePostgresValues(ctx, r, branchName, dbName, "") + result, err := prompt.ResolvePostgresValues(ctx, newPostgresResource(), testBranch, testBranch+"/databases/nonexistent", "") require.NoError(t, err) // databaseName should be empty since no match. @@ -159,29 +96,12 @@ func TestResolvePostgresValuesDatabaseNotFound(t *testing.T) { } func TestResolvePostgresValuesSkipsDatabaseListWhenNameProvided(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), m.WorkspaceClient) - - branchName := "projects/p1/branches/main" - dbName := "projects/p1/branches/main/databases/mydb" + // No databases fixture: listing databases would fail the test. + ctx := postgresContext(t, httpfixtures.Fixtures{ + {Method: "GET", Resource: endpointsResource, Response: readWriteEndpoint}, + }) - endpoints := listing.SliceIterator[postgres.Endpoint]{ - { - Name: "projects/p1/branches/main/endpoints/ep1", - Status: &postgres.EndpointStatus{ - EndpointType: postgres.EndpointTypeEndpointTypeReadWrite, - Hosts: &postgres.EndpointHosts{Host: "my-host.example.com"}, - }, - }, - } - m.GetMockPostgresAPI().EXPECT(). - ListEndpoints(mock.Anything, postgres.ListEndpointsRequest{Parent: branchName}). - Return(&endpoints).Once() - - // ListDatabases should NOT be called since pgDatabaseName is pre-provided. - - r := newPostgresResource() - result, err := prompt.ResolvePostgresValues(ctx, r, branchName, dbName, "my_pg_db") + result, err := prompt.ResolvePostgresValues(ctx, newPostgresResource(), testBranch, testBranch+"/databases/mydb", "my_pg_db") require.NoError(t, err) assert.Equal(t, map[string]string{ @@ -192,65 +112,22 @@ func TestResolvePostgresValuesSkipsDatabaseListWhenNameProvided(t *testing.T) { } func TestResolvePostgresValuesEndpointAPIError(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), m.WorkspaceClient) - - branchName := "projects/p1/branches/main" - - // Return an iterator that yields an error. - m.GetMockPostgresAPI().EXPECT(). - ListEndpoints(mock.Anything, postgres.ListEndpointsRequest{Parent: branchName}). - RunAndReturn(func(_ context.Context, _ postgres.ListEndpointsRequest) listing.Iterator[postgres.Endpoint] { - return &errorIterator[postgres.Endpoint]{err: errors.New("API unavailable")} - }).Once() + ctx := postgresContext(t, httpfixtures.Fixtures{ + {Method: "GET", Resource: endpointsResource, Status: http.StatusBadRequest, Response: unavailableResponse}, + }) - r := newPostgresResource() - _, err := prompt.ResolvePostgresValues(ctx, r, branchName, "some-db", "") + _, err := prompt.ResolvePostgresValues(ctx, newPostgresResource(), testBranch, "some-db", "") require.Error(t, err) assert.Contains(t, err.Error(), "resolving endpoint details") } func TestResolvePostgresValuesDatabaseAPIError(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), m.WorkspaceClient) + ctx := postgresContext(t, httpfixtures.Fixtures{ + {Method: "GET", Resource: endpointsResource, Response: readWriteEndpoint}, + {Method: "GET", Resource: databasesResource, Status: http.StatusBadRequest, Response: unavailableResponse}, + }) - branchName := "projects/p1/branches/main" - - // Endpoints succeed. - endpoints := listing.SliceIterator[postgres.Endpoint]{ - { - Name: "projects/p1/branches/main/endpoints/ep1", - Status: &postgres.EndpointStatus{ - EndpointType: postgres.EndpointTypeEndpointTypeReadWrite, - Hosts: &postgres.EndpointHosts{Host: "my-host.example.com"}, - }, - }, - } - m.GetMockPostgresAPI().EXPECT(). - ListEndpoints(mock.Anything, postgres.ListEndpointsRequest{Parent: branchName}). - Return(&endpoints).Once() - - // ListDatabases returns an error. - m.GetMockPostgresAPI().EXPECT(). - ListDatabases(mock.Anything, postgres.ListDatabasesRequest{Parent: branchName}). - RunAndReturn(func(_ context.Context, _ postgres.ListDatabasesRequest) listing.Iterator[postgres.Database] { - return &errorIterator[postgres.Database]{err: errors.New("API unavailable")} - }).Once() - - r := newPostgresResource() - _, err := prompt.ResolvePostgresValues(ctx, r, branchName, "some-db", "") + _, err := prompt.ResolvePostgresValues(ctx, newPostgresResource(), testBranch, "some-db", "") require.Error(t, err) assert.Contains(t, err.Error(), "resolving database name") } - -// errorIterator is a test helper that always returns an error. -type errorIterator[T any] struct { - err error -} - -func (e *errorIterator[T]) HasNext(_ context.Context) bool { return true } - -func (e *errorIterator[T]) Next(_ context.Context) (T, error) { - var zero T - return zero, e.err -} diff --git a/libs/apps/runlocal/headers.go b/libs/apps/runlocal/headers.go index 9655e51ba28..8937f3cbc2f 100644 --- a/libs/apps/runlocal/headers.go +++ b/libs/apps/runlocal/headers.go @@ -1,24 +1,25 @@ package runlocal import ( - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/scim/v1" "github.com/google/uuid" ) -func GetXHeaders(user *iam.User) map[string]string { +func GetXHeaders(user *scim.User) map[string]string { return map[string]string{ "X-Forwarded-Host": "localhost", - "X-Forwarded-Preferred-Username": user.DisplayName, - "X-Forwarded-User": user.UserName, + "X-Forwarded-Preferred-Username": utils.Deref(user.DisplayName), + "X-Forwarded-User": utils.Deref(user.UserName), "X-Forwarded-Email": getEmail(user), "X-Real-Ip": "127.0.0.1", "X-Request-Id": uuid.New().String(), } } -func getEmail(user *iam.User) string { +func getEmail(user *scim.User) string { if len(user.Emails) > 0 { - return user.Emails[0].Value + return utils.Deref(user.Emails[0].Value) } - return user.UserName + return utils.Deref(user.UserName) } diff --git a/libs/apps/vite/bridge.go b/libs/apps/vite/bridge.go index 7b658e83c7d..c08c0662698 100644 --- a/libs/apps/vite/bridge.go +++ b/libs/apps/vite/bridge.go @@ -19,8 +19,9 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/apps" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/apps/v1" "github.com/gorilla/websocket" "golang.org/x/sync/errgroup" ) @@ -77,7 +78,7 @@ type prioritizedMessage struct { type Bridge struct { ctx context.Context - w *databricks.WorkspaceClient + w *sdkclients.Clients appName string // Atomic because reconnects swap the connection while the writer goroutine reads it. tunnelConn atomic.Pointer[websocket.Conn] @@ -98,7 +99,7 @@ type Bridge struct { // NewBridge constructs a development bridge to a remote app. When autoApprove is // true, inbound connection requests from viewers are approved without prompting // on stdin. -func NewBridge(ctx context.Context, w *databricks.WorkspaceClient, appName string, port int, autoApprove bool) *Bridge { +func NewBridge(ctx context.Context, w *sdkclients.Clients, appName string, port int, autoApprove bool) *Bridge { // Configure HTTP client optimized for local high-volume requests transport := &http.Transport{ MaxIdleConns: 100, @@ -156,18 +157,18 @@ func (vb *Bridge) getAuthHeaders(wsURL string) (http.Header, error) { } func (vb *Bridge) GetAppDomain() (*url.URL, error) { - app, err := vb.w.Apps.Get(vb.ctx, apps.GetAppRequest{ - Name: vb.appName, + app, err := vb.w.Apps.GetApp(vb.ctx, apps.GetAppRequest{ + Name: new(vb.appName), }) if err != nil { return nil, fmt.Errorf("failed to get app: %w", err) } - if app.Url == "" { + if utils.Deref(app.Url) == "" { return nil, errors.New("app URL is empty") } - return url.Parse(app.Url) + return url.Parse(*app.Url) } func (vb *Bridge) connectToTunnel(appDomain *url.URL) error { diff --git a/libs/apps/vite/bridge_test.go b/libs/apps/vite/bridge_test.go index cadd70f0828..68f2e3d8d5e 100644 --- a/libs/apps/vite/bridge_test.go +++ b/libs/apps/vite/bridge_test.go @@ -11,7 +11,7 @@ import ( "time" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/gorilla/websocket" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -151,7 +151,7 @@ func TestBridgeMessageSerialization(t *testing.T) { func TestBridgeHandleMessage(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - w := &databricks.WorkspaceClient{} + w := &sdkclients.Clients{} vb := NewBridge(ctx, w, "test-app", 5173, false) @@ -220,7 +220,7 @@ func TestBridgeHandleFileReadRequest(t *testing.T) { t.Run("successful file read", func(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - w := &databricks.WorkspaceClient{} + w := &sdkclients.Clients{} // Create a mock tunnel connection using httptest received := make(chan []byte, 1) @@ -277,7 +277,7 @@ func TestBridgeHandleFileReadRequest(t *testing.T) { t.Run("file not found", func(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - w := &databricks.WorkspaceClient{} + w := &sdkclients.Clients{} received := make(chan []byte, 1) upgrader := websocket.Upgrader{} @@ -330,7 +330,7 @@ func TestBridgeHandleFileReadRequest(t *testing.T) { func TestBridgeStop(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - w := &databricks.WorkspaceClient{} + w := &sdkclients.Clients{} vb := NewBridge(ctx, w, "test-app", 5173, false) @@ -350,7 +350,7 @@ func TestBridgeStop(t *testing.T) { func TestNewBridge(t *testing.T) { ctx := t.Context() - w := &databricks.WorkspaceClient{} + w := &sdkclients.Clients{} appName := "test-app" vb := NewBridge(ctx, w, appName, 5173, false) @@ -366,7 +366,7 @@ func TestNewBridge(t *testing.T) { func TestNewBridge_AutoApprove(t *testing.T) { ctx := t.Context() - w := &databricks.WorkspaceClient{} + w := &sdkclients.Clients{} vb := NewBridge(ctx, w, "test-app", 5173, true) @@ -401,7 +401,7 @@ func newWSConn(t *testing.T) *websocket.Conn { func TestBridgeSetTunnelConnSwapDuringWrites(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - w := &databricks.WorkspaceClient{} + w := &sdkclients.Clients{} conn1 := newWSConn(t) conn2 := newWSConn(t) @@ -441,7 +441,7 @@ func TestBridgeSetTunnelConnSwapDuringWrites(t *testing.T) { func TestBridgeConnectionRequestSendDoesNotBlockAfterStop(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - w := &databricks.WorkspaceClient{} + w := &sdkclients.Clients{} vb := NewBridge(ctx, w, "test-app", 5173, false) @@ -467,7 +467,7 @@ func TestBridgeConnectionRequestSendDoesNotBlockAfterStop(t *testing.T) { func TestBridgeConnectionRequestSequentialPrompts(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - w := &databricks.WorkspaceClient{} + w := &sdkclients.Clients{} vb := NewBridge(ctx, w, "test-app", 5173, false) go vb.readStdinLines(strings.NewReader("y\nn\n")) @@ -494,7 +494,7 @@ func TestBridgeConnectionRequestSequentialPrompts(t *testing.T) { func TestBridgeHandleConnectionRequest_AutoApproveSkipsStdin(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - w := &databricks.WorkspaceClient{} + w := &sdkclients.Clients{} received := make(chan []byte, 1) upgrader := websocket.Upgrader{} diff --git a/libs/apps/vite/validate_dir_test.go b/libs/apps/vite/validate_dir_test.go index 3a1c810ab43..c38a5f9a654 100644 --- a/libs/apps/vite/validate_dir_test.go +++ b/libs/apps/vite/validate_dir_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/gorilla/websocket" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -120,7 +120,7 @@ func TestBridgeHandleDirListRequest(t *testing.T) { t.Run("only returns sql files", func(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - w := &databricks.WorkspaceClient{} + w := &sdkclients.Clients{} received := make(chan []byte, 1) upgrader := websocket.Upgrader{} @@ -183,7 +183,7 @@ func TestBridgeHandleDirListRequest(t *testing.T) { t.Run("returns error for invalid path", func(t *testing.T) { ctx := cmdio.MockDiscard(t.Context()) - w := &databricks.WorkspaceClient{} + w := &sdkclients.Clients{} received := make(chan []byte, 1) upgrader := websocket.Upgrader{} diff --git a/libs/auth/error.go b/libs/auth/error.go index fdb5f256f43..82dc8ecaf81 100644 --- a/libs/auth/error.go +++ b/libs/auth/error.go @@ -8,8 +8,8 @@ import ( "strings" "github.com/databricks/cli/libs/auth/u2m" - "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/sdk-go/core/apierr" ) // Auth type names returned by credential providers. @@ -89,7 +89,7 @@ func EnrichAuthError(ctx context.Context, cfg *config.Config, err error) error { if !ok { return err } - if apiErr.StatusCode != http.StatusUnauthorized && apiErr.StatusCode != http.StatusForbidden { + if apiErr.HTTPStatusCode() != http.StatusUnauthorized && apiErr.HTTPStatusCode() != http.StatusForbidden { return err } @@ -108,7 +108,7 @@ func EnrichAuthError(ctx context.Context, cfg *config.Config, err error) error { fmt.Fprint(&b, "\n\nNext steps:") - if apiErr.StatusCode == http.StatusUnauthorized { + if apiErr.HTTPStatusCode() == http.StatusUnauthorized { writeReauthSteps(ctx, cfg, &b) } else { fmt.Fprint(&b, "\n - Verify you have the required permissions for this operation") diff --git a/libs/auth/error_test.go b/libs/auth/error_test.go index ce8f0df1b63..622083047c3 100644 --- a/libs/auth/error_test.go +++ b/libs/auth/error_test.go @@ -5,8 +5,10 @@ import ( "strings" "testing" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/sdk-go/core/apierr" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -43,24 +45,20 @@ func TestEnrichAuthError_NonAPIError(t *testing.T) { func TestEnrichAuthError_NonAuthStatusCode(t *testing.T) { cfg := &config.Config{Profile: "test", Host: "https://example.com"} - original := &apierr.APIError{StatusCode: 404, Message: "not found"} + original := apierr.FromHTTPError(404, nil, []byte(`{"message":"not found"}`)) result := EnrichAuthError(t.Context(), cfg, original) assert.Equal(t, original, result) } func TestEnrichAuthError_PreservesOriginalError(t *testing.T) { cfg := &config.Config{Host: "https://example.com", AuthType: "pat"} - original := &apierr.APIError{ - StatusCode: 403, - ErrorCode: "PERMISSION_DENIED", - Message: "User does not have permission", - } + original := apierr.FromHTTPError(403, nil, []byte(`{"error_code":"PERMISSION_DENIED","message":"User does not have permission"}`)) result := EnrichAuthError(t.Context(), cfg, original) var unwrapped *apierr.APIError require.ErrorAs(t, result, &unwrapped) - assert.Equal(t, 403, unwrapped.StatusCode) - assert.Equal(t, "PERMISSION_DENIED", unwrapped.ErrorCode) + assert.Equal(t, 403, unwrapped.HTTPStatusCode()) + assert.Equal(t, "PERMISSION_DENIED", apierrs.ErrorCode(unwrapped)) } func TestEnrichAuthError(t *testing.T) { @@ -250,14 +248,11 @@ func TestEnrichAuthError(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - original := &apierr.APIError{ - StatusCode: tt.statusCode, - ErrorCode: "TEST_ERROR", - Message: "test error message", - } + original := apierr.FromHTTPError(tt.statusCode, nil, []byte(`{"error_code":"TEST_ERROR","message":"test error message"}`)) result := EnrichAuthError(t.Context(), tt.cfg, original) - assert.Equal(t, tt.wantMsg, result.Error()) + // The enrichment is appended to the original error's own text. + assert.Equal(t, strings.Replace(tt.wantMsg, "test error message", original.Error(), 1), result.Error()) }) } } @@ -303,18 +298,18 @@ func TestAppendAccountHostHint(t *testing.T) { func TestAppendAccountHostHintPreservesErrorChain(t *testing.T) { cfg := &config.Config{Host: "https://accounts.test", Profile: "acc"} - original := &apierr.APIError{StatusCode: 400, Message: "Unable to load OAuth Config"} + original := apierr.FromHTTPError(400, nil, []byte(`{"message":"Unable to load OAuth Config"}`)) result := AppendAccountHostHint(cfg, original) var unwrapped *apierr.APIError require.ErrorAs(t, result, &unwrapped) - assert.Equal(t, 400, unwrapped.StatusCode) + assert.Equal(t, 400, unwrapped.HTTPStatusCode()) } func TestAppendAccountHostHintComposesWithEnrichAuthError(t *testing.T) { cfg := &config.Config{Host: "https://accounts.test", Profile: "acc", AuthType: AuthTypePat} - original := &apierr.APIError{StatusCode: 403, Message: "permission denied"} + original := apierr.FromHTTPError(403, nil, []byte(`{"message":"permission denied"}`)) // Same composition order as cmd/root.Execute: enrichment first, hint last. result := AppendAccountHostHint(cfg, EnrichAuthError(t.Context(), cfg, original)) diff --git a/libs/auth/workspace_id.go b/libs/auth/workspace_id.go index 84313e3f3aa..0352c3aa04d 100644 --- a/libs/auth/workspace_id.go +++ b/libs/auth/workspace_id.go @@ -2,10 +2,14 @@ package auth import ( "context" + "io" + "net/http" "strconv" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/databrickscfg/profile" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/sdk-go/core/apierr" ) // ResolveWorkspaceID returns the workspace ID as a string, preferring the @@ -17,21 +21,45 @@ import ( // CLI-only "none" sentinel is treated as unset so it never leaks as a // routing identifier. // -// The fallback path delegates to w.CurrentWorkspaceID, which reads the -// X-Databricks-Org-Id response header on /api/2.0/preview/scim/v2/Me and -// parses it as int64. The numeric constraint is enforced by the SDK on -// that path; the helper just stringifies the result. -// -// Compared to calling w.CurrentWorkspaceID directly, the string return -// type lets callers pass the value to URL builders, env vars, and other -// string-typed sinks without a manual strconv.FormatInt step. -func ResolveWorkspaceID(ctx context.Context, w *databricks.WorkspaceClient) (string, error) { +// The fallback path reads the X-Databricks-Org-Id response header on +// /api/2.0/preview/scim/v2/Me and requires it to be an int64; the helper +// returns it as a string so callers can pass it to URL builders, env vars, +// and other string-typed sinks. +func ResolveWorkspaceID(ctx context.Context, w *sdkclients.Clients) (string, error) { if id := w.Config.WorkspaceID; id != "" && id != profile.WorkspaceIDNone { return id, nil } - id, err := w.CurrentWorkspaceID(ctx) + id, err := currentWorkspaceID(ctx, w) if err != nil { return "", err } return strconv.FormatInt(id, 10), nil } + +// currentWorkspaceID asks /Me for the workspace ID. It is a raw call because +// the ID is only in a response header, which sdk-go does not expose. +func currentWorkspaceID(ctx context.Context, w *sdkclients.Clients) (int64, error) { + req, err := http.NewRequestWithContext(ctx, http.MethodGet, w.Config.CanonicalHostName()+"/api/2.0/preview/scim/v2/Me?excludedAttributes=entitlements", nil) + if err != nil { + return 0, err + } + for k, v := range WorkspaceIDHeaders(w.Config) { + req.Header.Set(k, v) + } + if err := w.Config.Authenticate(req); err != nil { + return 0, err + } + resp, err := apiclient.HTTPClient(w.Config).Do(req) + if err != nil { + return 0, err + } + defer resp.Body.Close() + body, err := io.ReadAll(resp.Body) + if err != nil { + return 0, err + } + if apiErr := apierr.FromHTTPError(resp.StatusCode, resp.Header, body); apiErr != nil { + return 0, apiErr + } + return strconv.ParseInt(resp.Header.Get("X-Databricks-Org-Id"), 10, 64) +} diff --git a/libs/auth/workspace_id_test.go b/libs/auth/workspace_id_test.go index fd0a32aa194..f4cffecc338 100644 --- a/libs/auth/workspace_id_test.go +++ b/libs/auth/workspace_id_test.go @@ -5,8 +5,9 @@ import ( "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/databrickscfg/profile" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -21,7 +22,7 @@ func TestResolveWorkspaceID_FastPathReturnsConfiguredValue(t *testing.T) { }) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{ + w, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", WorkspaceID: "12345", @@ -45,7 +46,7 @@ func TestResolveWorkspaceID_FastPathPassesThroughNonNumericValue(t *testing.T) { testserver.AddDefaultHandlers(server) const connID = "123e4567-e89b-12d3-a456-426614174000" - w, err := databricks.NewWorkspaceClient(&databricks.Config{ + w, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", WorkspaceID: connID, @@ -63,7 +64,7 @@ func TestResolveWorkspaceID_NoneSentinelFallsThroughToAPI(t *testing.T) { server := testserver.New(t) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{ + w, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", WorkspaceID: profile.WorkspaceIDNone, @@ -90,7 +91,7 @@ func TestResolveWorkspaceID_FallbackHitsMeAndStringifiesResponse(t *testing.T) { server := testserver.New(t) testserver.AddDefaultHandlers(server) - w, err := databricks.NewWorkspaceClient(&databricks.Config{ + w, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", }) diff --git a/libs/bundledeployments/client.go b/libs/bundledeployments/client.go new file mode 100644 index 00000000000..6f976bf0b92 --- /dev/null +++ b/libs/bundledeployments/client.go @@ -0,0 +1,58 @@ +// Package bundledeployments is a client for the bundle deployments API +// (/api/2.0/bundle/...), which sdk-go does not provide. +package bundledeployments + +import ( + "encoding/json" + "errors" + "net/url" + "strings" + + "github.com/databricks/cli/libs/apiclient" +) + +// Client calls the bundle deployments API. +type Client struct { + bundleDeploymentsImpl +} + +func New(c *apiclient.Client) *Client { + return &Client{bundleDeploymentsImpl{client: c}} +} + +func addWorkspaceID(c *apiclient.Client, headers map[string]string) { + c.AddWorkspaceIDHeader(headers) +} + +// FieldMask is a list of field paths, encoded as a comma-separated string. +type FieldMask struct { + Paths []string +} + +func (f FieldMask) MarshalJSON() ([]byte, error) { + return json.Marshal(strings.Join(f.Paths, ",")) +} + +func (f *FieldMask) UnmarshalJSON(data []byte) error { + if f == nil { + return errors.New("FieldMask.UnmarshalJSON on nil pointer") + } + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + if s != "" { + f.Paths = strings.Split(s, ",") + } else { + f.Paths = []string{} + } + return nil +} + +func (f *FieldMask) EncodeValues(key string, v *url.Values) error { + if f == nil || len(f.Paths) == 0 { + return nil + } + v.Set(key, strings.Join(f.Paths, ",")) + return nil +} diff --git a/libs/bundledeployments/client_test.go b/libs/bundledeployments/client_test.go new file mode 100644 index 00000000000..51e984d7b92 --- /dev/null +++ b/libs/bundledeployments/client_test.go @@ -0,0 +1,45 @@ +package bundledeployments + +import ( + "encoding/json" + "io" + "net/http" + "testing" + + "github.com/databricks/cli/libs/apiclient/apiclienttest" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestUpdateDeploymentSendsMaskAndBody(t *testing.T) { + c := New(apiclienttest.New(t, func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, http.MethodPatch, r.Method) + assert.Equal(t, "/api/2.0/bundle/deployments/d1", r.URL.Path) + assert.Equal(t, "display_name,mode", r.URL.Query().Get("update_mask")) + body, _ := io.ReadAll(r.Body) + assert.JSONEq(t, `{"display_name":"x"}`, string(body)) + _, _ = w.Write([]byte(`{"name":"deployments/d1","display_name":"x"}`)) + })) + d, err := c.UpdateDeployment(t.Context(), UpdateDeploymentRequest{ + Name: "deployments/d1", + Deployment: Deployment{DisplayName: "x"}, + UpdateMask: FieldMask{Paths: []string{"display_name", "mode"}}, + }) + require.NoError(t, err) + assert.Equal(t, "deployments/d1", d.Name) +} + +func TestListResourcesAllPaginates(t *testing.T) { + c := New(apiclienttest.New(t, func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, "/api/2.0/bundle/deployments/d1/resources", r.URL.Path) + resp := ListResourcesResponse{Resources: []Resource{{Name: "r1"}}, NextPageToken: "p2"} + if r.URL.Query().Get("page_token") == "p2" { + resp = ListResourcesResponse{Resources: []Resource{{Name: "r2"}}} + } + _ = json.NewEncoder(w).Encode(resp) + })) + res, err := c.ListResourcesAll(t.Context(), ListResourcesRequest{Parent: "deployments/d1"}) + require.NoError(t, err) + require.Len(t, res, 2) + assert.Equal(t, "r2", res[1].Name) +} diff --git a/libs/bundledeployments/impl.go b/libs/bundledeployments/impl.go new file mode 100644 index 00000000000..40f91d751a6 --- /dev/null +++ b/libs/bundledeployments/impl.go @@ -0,0 +1,363 @@ +// Code ported from github.com/databricks/databricks-sdk-go. + +package bundledeployments + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "reflect" + "slices" + "strings" + + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/listing" +) + +// unexported type that holds implementations of just BundleDeployments API methods +type bundleDeploymentsImpl struct { + client *apiclient.Client +} + +func (a *bundleDeploymentsImpl) CompleteVersion(ctx context.Context, request CompleteVersionRequest) (*Version, error) { + var version Version + path := fmt.Sprintf("/api/2.0/bundle/%v/complete", request.Name) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPost, path, headers, queryParams, request, &version) + return &version, err +} + +func (a *bundleDeploymentsImpl) CreateDeployment(ctx context.Context, request CreateDeploymentRequest) (*Deployment, error) { + var deployment Deployment + path := "/api/2.0/bundle/deployments" + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPost, path, headers, queryParams, request.Deployment, &deployment) + return &deployment, err +} + +func (a *bundleDeploymentsImpl) CreateVersion(ctx context.Context, request CreateVersionRequest) (*Version, error) { + var version Version + path := fmt.Sprintf("/api/2.0/bundle/%v/versions", request.Parent) + queryParams := make(map[string]any) + + if request.VersionId != "" { + queryParams["version_id"] = request.VersionId + } + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPost, path, headers, queryParams, request.Version, &version) + return &version, err +} + +func (a *bundleDeploymentsImpl) DeleteDeployment(ctx context.Context, request DeleteDeploymentRequest) error { + path := fmt.Sprintf("/api/2.0/bundle/%v", request.Name) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodDelete, path, headers, queryParams, apiclient.URLQuery(request), nil) + return err +} + +func (a *bundleDeploymentsImpl) GetDeployment(ctx context.Context, request GetDeploymentRequest) (*Deployment, error) { + var deployment Deployment + path := fmt.Sprintf("/api/2.0/bundle/%v", request.Name) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &deployment) + return &deployment, err +} + +func (a *bundleDeploymentsImpl) GetOperation(ctx context.Context, request GetOperationRequest) (*Operation, error) { + var operation Operation + path := fmt.Sprintf("/api/2.0/bundle/%v", request.Name) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &operation) + return &operation, err +} + +func (a *bundleDeploymentsImpl) GetResource(ctx context.Context, request GetResourceRequest) (*Resource, error) { + var resource Resource + path := fmt.Sprintf("/api/2.0/bundle/%v", request.Name) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &resource) + return &resource, err +} + +func (a *bundleDeploymentsImpl) GetVersion(ctx context.Context, request GetVersionRequest) (*Version, error) { + var version Version + path := fmt.Sprintf("/api/2.0/bundle/%v", request.Name) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &version) + return &version, err +} + +func (a *bundleDeploymentsImpl) Heartbeat(ctx context.Context, request HeartbeatRequest) (*HeartbeatResponse, error) { + var heartbeatResponse HeartbeatResponse + path := fmt.Sprintf("/api/2.0/bundle/%v/heartbeat", request.Name) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPost, path, headers, queryParams, request, &heartbeatResponse) + return &heartbeatResponse, err +} + +// Lists deployments in the workspace. +func (a *bundleDeploymentsImpl) ListDeployments(ctx context.Context, request ListDeploymentsRequest) listing.Iterator[Deployment] { + getNextPage := func(ctx context.Context, req ListDeploymentsRequest) (*ListDeploymentsResponse, error) { + return a.internalListDeployments(ctx, req) + } + getItems := func(resp *ListDeploymentsResponse) []Deployment { + return resp.Deployments + } + getNextReq := func(resp *ListDeploymentsResponse) *ListDeploymentsRequest { + if resp.NextPageToken == "" { + return nil + } + request.PageToken = resp.NextPageToken + return &request + } + iterator := listing.NewIterator( + &request, + getNextPage, + getItems, + getNextReq) + return iterator +} + +// Lists deployments in the workspace. +func (a *bundleDeploymentsImpl) ListDeploymentsAll(ctx context.Context, request ListDeploymentsRequest) ([]Deployment, error) { + iterator := a.ListDeployments(ctx, request) + return listing.ToSlice[Deployment](ctx, iterator) +} + +func (a *bundleDeploymentsImpl) internalListDeployments(ctx context.Context, request ListDeploymentsRequest) (*ListDeploymentsResponse, error) { + var listDeploymentsResponse ListDeploymentsResponse + path := "/api/2.0/bundle/deployments" + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &listDeploymentsResponse) + return &listDeploymentsResponse, err +} + +// Lists resource operations under a version. +func (a *bundleDeploymentsImpl) ListOperations(ctx context.Context, request ListOperationsRequest) listing.Iterator[Operation] { + getNextPage := func(ctx context.Context, req ListOperationsRequest) (*ListOperationsResponse, error) { + return a.internalListOperations(ctx, req) + } + getItems := func(resp *ListOperationsResponse) []Operation { + return resp.Operations + } + getNextReq := func(resp *ListOperationsResponse) *ListOperationsRequest { + if resp.NextPageToken == "" { + return nil + } + request.PageToken = resp.NextPageToken + return &request + } + iterator := listing.NewIterator( + &request, + getNextPage, + getItems, + getNextReq) + return iterator +} + +// Lists resource operations under a version. +func (a *bundleDeploymentsImpl) ListOperationsAll(ctx context.Context, request ListOperationsRequest) ([]Operation, error) { + iterator := a.ListOperations(ctx, request) + return listing.ToSlice[Operation](ctx, iterator) +} + +func (a *bundleDeploymentsImpl) internalListOperations(ctx context.Context, request ListOperationsRequest) (*ListOperationsResponse, error) { + var listOperationsResponse ListOperationsResponse + path := fmt.Sprintf("/api/2.0/bundle/%v/operations", request.Parent) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &listOperationsResponse) + return &listOperationsResponse, err +} + +// Lists resources under a deployment. +func (a *bundleDeploymentsImpl) ListResources(ctx context.Context, request ListResourcesRequest) listing.Iterator[Resource] { + getNextPage := func(ctx context.Context, req ListResourcesRequest) (*ListResourcesResponse, error) { + return a.internalListResources(ctx, req) + } + getItems := func(resp *ListResourcesResponse) []Resource { + return resp.Resources + } + getNextReq := func(resp *ListResourcesResponse) *ListResourcesRequest { + if resp.NextPageToken == "" { + return nil + } + request.PageToken = resp.NextPageToken + return &request + } + iterator := listing.NewIterator( + &request, + getNextPage, + getItems, + getNextReq) + return iterator +} + +// Lists resources under a deployment. +func (a *bundleDeploymentsImpl) ListResourcesAll(ctx context.Context, request ListResourcesRequest) ([]Resource, error) { + iterator := a.ListResources(ctx, request) + return listing.ToSlice[Resource](ctx, iterator) +} + +func (a *bundleDeploymentsImpl) internalListResources(ctx context.Context, request ListResourcesRequest) (*ListResourcesResponse, error) { + var listResourcesResponse ListResourcesResponse + path := fmt.Sprintf("/api/2.0/bundle/%v/resources", request.Parent) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &listResourcesResponse) + return &listResourcesResponse, err +} + +// Lists versions under a deployment, ordered numerically by version_id +// descending (most recent first). +func (a *bundleDeploymentsImpl) ListVersions(ctx context.Context, request ListVersionsRequest) listing.Iterator[Version] { + getNextPage := func(ctx context.Context, req ListVersionsRequest) (*ListVersionsResponse, error) { + return a.internalListVersions(ctx, req) + } + getItems := func(resp *ListVersionsResponse) []Version { + return resp.Versions + } + getNextReq := func(resp *ListVersionsResponse) *ListVersionsRequest { + if resp.NextPageToken == "" { + return nil + } + request.PageToken = resp.NextPageToken + return &request + } + iterator := listing.NewIterator( + &request, + getNextPage, + getItems, + getNextReq) + return iterator +} + +// Lists versions under a deployment, ordered numerically by version_id +// descending (most recent first). +func (a *bundleDeploymentsImpl) ListVersionsAll(ctx context.Context, request ListVersionsRequest) ([]Version, error) { + iterator := a.ListVersions(ctx, request) + return listing.ToSlice[Version](ctx, iterator) +} + +func (a *bundleDeploymentsImpl) internalListVersions(ctx context.Context, request ListVersionsRequest) (*ListVersionsResponse, error) { + var listVersionsResponse ListVersionsResponse + path := fmt.Sprintf("/api/2.0/bundle/%v/versions", request.Parent) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &listVersionsResponse) + return &listVersionsResponse, err +} + +func (a *bundleDeploymentsImpl) UpdateDeployment(ctx context.Context, request UpdateDeploymentRequest) (*Deployment, error) { + var deployment Deployment + path := fmt.Sprintf("/api/2.0/bundle/%v", request.Name) + queryParams := make(map[string]any) + + updateMaskJson, updateMaskMarshallError := json.Marshal(request.UpdateMask) + if updateMaskMarshallError != nil { + return nil, updateMaskMarshallError + } + + queryParams["update_mask"] = strings.Trim(string(updateMaskJson), `"`) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + body, err := withMaskedFields(request.Deployment, request.UpdateMask.Paths) + if err != nil { + return nil, err + } + err = a.client.Do(ctx, http.MethodPatch, path, headers, queryParams, body, &deployment) + return &deployment, err +} + +func (a *bundleDeploymentsImpl) UpdateOperation(ctx context.Context, request UpdateOperationRequest) (*Operation, error) { + var operation Operation + path := fmt.Sprintf("/api/2.0/bundle/%v", request.Name) + queryParams := make(map[string]any) + + updateMaskJson, updateMaskMarshallError := json.Marshal(request.UpdateMask) + if updateMaskMarshallError != nil { + return nil, updateMaskMarshallError + } + + queryParams["update_mask"] = strings.Trim(string(updateMaskJson), `"`) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + // sequence_id is the optimistic-concurrency precondition; 0 is a real value. + body, err := withMaskedFields(request.Operation, append(slices.Clone(request.UpdateMask.Paths), "sequence_id")) + if err != nil { + return nil, err + } + err = a.client.Do(ctx, http.MethodPatch, path, headers, queryParams, body, &operation) + return &operation, err +} + +// withMaskedFields encodes v as a JSON object in which every top-level field +// named in paths is present, even when empty: for an update, an empty value in +// the mask means "clear it", and omitempty would drop it. state is the +// exception: an absent state is how a cleared resource is reported. +func withMaskedFields(v any, paths []string) (map[string]any, error) { + data, err := json.Marshal(v) + if err != nil { + return nil, err + } + var body map[string]any + if err := json.Unmarshal(data, &body); err != nil { + return nil, err + } + rv := reflect.ValueOf(v) + rt := rv.Type() + for i := range rt.NumField() { + name, _, _ := strings.Cut(rt.Field(i).Tag.Get("json"), ",") + if name == "" || name == "-" || name == "state" || !slices.Contains(paths, name) { + continue + } + if _, ok := body[name]; !ok { + body[name] = rv.Field(i).Interface() + } + } + return body, nil +} diff --git a/libs/bundledeployments/model.go b/libs/bundledeployments/model.go new file mode 100644 index 00000000000..3761954fcf1 --- /dev/null +++ b/libs/bundledeployments/model.go @@ -0,0 +1,966 @@ +// Code ported from github.com/databricks/databricks-sdk-go /service/bundledeployments/model.go. + +package bundledeployments + +import ( + "bytes" + "encoding/json" + "fmt" + "strconv" + + "github.com/databricks/sdk-go/core/types" +) + +// A request to complete a Version. +type CompleteVersionRequest struct { + // The reason for completing the version. Must be VERSION_COMPLETE_SUCCESS + // or VERSION_COMPLETE_FAILURE. + CompletionReason VersionComplete `json:"completion_reason"` + // If true, force-completes the version even if the caller is not the + // original creator. + Force bool `json:"force,omitempty"` + // The name of the version to complete. Format: + // deployments/{deployment_id}/versions/{version_id} + Name string `json:"-" url:"-"` +} + +type CreateDeploymentRequest struct { + // The deployment to create. `initial_parent_path` is required. + // `display_name`, `target_name`, `deployment_mode`, and `workspace_info` + // may be set; every other field is assigned by the service and ignored on + // input. + Deployment Deployment `json:"deployment"` +} + +type CreateVersionRequest struct { + // The parent deployment where this version will be created. Format: + // deployments/{deployment_id} + Parent string `json:"-" url:"-"` + // The version to create. + Version Version `json:"version"` + // The ID to use for the version, which becomes the final component of the + // version's resource name. A numeric string (base-10, fits in a signed + // 64-bit integer) chosen by the caller; must be greater than or equal to 1. + // Must be numerically greater than the deployment's most recent version + // (see `version.previous_version_id`); it does not need to start at 1 or + // increase by exactly 1. If the value is not numerically greater, the + // server returns `INVALID_PARAMETER_VALUE`. + VersionId string `json:"-" url:"version_id"` +} + +// Dashboard-specific per-resource metadata. Set only for dashboard resources. +type DashboardMetadata struct { + // Path of the file that declares this dashboard, relative to the bundle's + // workspace.file_path (Deployment.workspace_info.file_path) — join the + // two to get the file's absolute workspace path. + // + // For now this lives only on the dashboard metadata, and is a single string + // because it was a single string (`relative_path`) in the legacy bundle + // metadata.json. We may generalize it in the future: lifting it to a + // top-level field on Resource/Operation (every resource type has a + // definition location) and converting it to a repeated field, since a + // resource can be declared across multiple files/locations. + DefinitionPath string `json:"definition_path,omitempty"` + // Path of the dashboard's source artifact (its `.lvdash.json`), relative to + // the deployment root. + SourcePath string `json:"source_path,omitempty"` +} + +type DeleteDeploymentRequest struct { + // Resource name of the deployment to delete. Format: + // deployments/{deployment_id} + Name string `json:"-" url:"-"` +} + +// A bundle deployment registered with the control plane. +type Deployment struct { + // When the deployment was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // The user who created the deployment (email or principal name). Empty if + // authoritative deployment metadata does not identify a creator or the + // principal cannot be resolved. + CreatedBy string `json:"created_by,omitempty"` + // Bundle target deployment mode (development or production). + DeploymentMode DeploymentMode `json:"deployment_mode,omitempty"` + // When deletion was recorded. Unset if deletion has not been recorded. This + // response metadata does not determine the deployment's lifecycle status. + DestroyTime *types.Time `json:"destroy_time,omitempty"` + // The user who destroyed the deployment (email or principal name). Unset if + // the deployment has not been destroyed. + DestroyedBy string `json:"destroyed_by,omitempty"` + // Human-readable name for the deployment, up to 256 characters. + DisplayName string `json:"display_name,omitempty"` + // Git provenance of the deployment's source, derived from the latest + // version. + GitInfo *GitInfo `json:"git_info,omitempty"` + // The workspace path of the existing folder where the deployment is + // initially created. Must be absolute and canonical, with single + // separators, no `.` or `..` segments, and no trailing slash unless the + // path is `/`. It may contain at most 24 path segments, excluding an + // optional leading `/Workspace` segment. The complete path may contain up + // to 1,024 characters, and each segment may contain up to 511 characters. + // This field is input only and is not returned in create, get, or list + // responses. + InitialParentPath string `json:"initial_parent_path,omitempty"` + // The version_id of the most recent version that completed successfully. + // Unset until a version has completed successfully. Unlike last_version_id, + // it is not advanced when a version fails, so it always points at the last + // known-good deployment state (or is unset if there has never been one). + LastSuccessfulVersionId string `json:"last_successful_version_id,omitempty"` + // The version_id of the most recent deployment version. + LastVersionId string `json:"last_version_id,omitempty"` + // Resource name of the deployment. Format: deployments/{deployment_id} + Name string `json:"name,omitempty"` + // Current status of the deployment. + Status DeploymentStatus `json:"status,omitempty"` + // The bundle target name associated with this deployment. + TargetName string `json:"target_name,omitempty"` + // When the deployment was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` + // The user who most recently updated the deployment (email or principal + // name). Empty if authoritative deployment metadata does not identify a + // modifier or the principal cannot be resolved. + UpdatedBy string `json:"updated_by,omitempty"` + // Workspace location of the deployment. + WorkspaceInfo *WorkspaceInfo `json:"workspace_info,omitempty"` +} + +// Bundle target deployment mode. Mirrors the `mode` field on a bundle target in +// `databricks.yml` (see +// https://docs.databricks.com/dev-tools/bundles/deployment-modes). +type DeploymentMode string + +const DeploymentModeDeploymentModeDevelopment DeploymentMode = `DEPLOYMENT_MODE_DEVELOPMENT` + +const DeploymentModeDeploymentModeProduction DeploymentMode = `DEPLOYMENT_MODE_PRODUCTION` + +// String representation for [fmt.Print] +func (f *DeploymentMode) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *DeploymentMode) Set(v string) error { + switch v { + case `DEPLOYMENT_MODE_DEVELOPMENT`, `DEPLOYMENT_MODE_PRODUCTION`: + *f = DeploymentMode(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "DEPLOYMENT_MODE_DEVELOPMENT", "DEPLOYMENT_MODE_PRODUCTION"`, v) + } +} + +// Values returns all possible values for DeploymentMode. +// +// There is no guarantee on the order of the values in the slice. +func (f *DeploymentMode) Values() []DeploymentMode { + return []DeploymentMode{ + DeploymentModeDeploymentModeDevelopment, + DeploymentModeDeploymentModeProduction, + } +} + +// Type always returns DeploymentMode to satisfy [pflag.Value] interface +func (f *DeploymentMode) Type() string { + return "DeploymentMode" +} + +// Type of a deployment resource. +type DeploymentResourceType string + +const DeploymentResourceTypeDeploymentResourceTypeAlert DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_ALERT` + +const DeploymentResourceTypeDeploymentResourceTypeApp DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_APP` + +const DeploymentResourceTypeDeploymentResourceTypeCatalog DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_CATALOG` + +const DeploymentResourceTypeDeploymentResourceTypeCluster DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_CLUSTER` + +const DeploymentResourceTypeDeploymentResourceTypeClusterPolicy DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_CLUSTER_POLICY` + +const DeploymentResourceTypeDeploymentResourceTypeDashboard DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_DASHBOARD` + +const DeploymentResourceTypeDeploymentResourceTypeDatabaseCatalog DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_DATABASE_CATALOG` + +const DeploymentResourceTypeDeploymentResourceTypeDatabaseInstance DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_DATABASE_INSTANCE` + +const DeploymentResourceTypeDeploymentResourceTypeExperiment DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_EXPERIMENT` + +const DeploymentResourceTypeDeploymentResourceTypeExternalLocation DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_EXTERNAL_LOCATION` + +const DeploymentResourceTypeDeploymentResourceTypeGenieSpace DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_GENIE_SPACE` + +const DeploymentResourceTypeDeploymentResourceTypeInstancePool DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_INSTANCE_POOL` + +const DeploymentResourceTypeDeploymentResourceTypeJob DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_JOB` + +const DeploymentResourceTypeDeploymentResourceTypeJobRun DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_JOB_RUN` + +const DeploymentResourceTypeDeploymentResourceTypeModel DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_MODEL` + +const DeploymentResourceTypeDeploymentResourceTypeModelServingEndpoint DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_MODEL_SERVING_ENDPOINT` + +const DeploymentResourceTypeDeploymentResourceTypePipeline DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_PIPELINE` + +const DeploymentResourceTypeDeploymentResourceTypePostgresBranch DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_BRANCH` + +const DeploymentResourceTypeDeploymentResourceTypePostgresCatalog DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_CATALOG` + +const DeploymentResourceTypeDeploymentResourceTypePostgresDatabase DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_DATABASE` + +const DeploymentResourceTypeDeploymentResourceTypePostgresEndpoint DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_ENDPOINT` + +const DeploymentResourceTypeDeploymentResourceTypePostgresProject DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_PROJECT` + +const DeploymentResourceTypeDeploymentResourceTypePostgresRole DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_ROLE` + +const DeploymentResourceTypeDeploymentResourceTypePostgresSyncedTable DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_SYNCED_TABLE` + +const DeploymentResourceTypeDeploymentResourceTypeQualityMonitor DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_QUALITY_MONITOR` + +const DeploymentResourceTypeDeploymentResourceTypeRegisteredModel DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_REGISTERED_MODEL` + +const DeploymentResourceTypeDeploymentResourceTypeSchema DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_SCHEMA` + +const DeploymentResourceTypeDeploymentResourceTypeSecret DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_SECRET` + +const DeploymentResourceTypeDeploymentResourceTypeSecretScope DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_SECRET_SCOPE` + +const DeploymentResourceTypeDeploymentResourceTypeSqlWarehouse DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_SQL_WAREHOUSE` + +const DeploymentResourceTypeDeploymentResourceTypeSyncedDatabaseTable DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_SYNCED_DATABASE_TABLE` + +const DeploymentResourceTypeDeploymentResourceTypeVectorSearchEndpoint DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_VECTOR_SEARCH_ENDPOINT` + +const DeploymentResourceTypeDeploymentResourceTypeVectorSearchIndex DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_VECTOR_SEARCH_INDEX` + +const DeploymentResourceTypeDeploymentResourceTypeVolume DeploymentResourceType = `DEPLOYMENT_RESOURCE_TYPE_VOLUME` + +// String representation for [fmt.Print] +func (f *DeploymentResourceType) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *DeploymentResourceType) Set(v string) error { + switch v { + case `DEPLOYMENT_RESOURCE_TYPE_ALERT`, `DEPLOYMENT_RESOURCE_TYPE_APP`, `DEPLOYMENT_RESOURCE_TYPE_CATALOG`, `DEPLOYMENT_RESOURCE_TYPE_CLUSTER`, `DEPLOYMENT_RESOURCE_TYPE_CLUSTER_POLICY`, `DEPLOYMENT_RESOURCE_TYPE_DASHBOARD`, `DEPLOYMENT_RESOURCE_TYPE_DATABASE_CATALOG`, `DEPLOYMENT_RESOURCE_TYPE_DATABASE_INSTANCE`, `DEPLOYMENT_RESOURCE_TYPE_EXPERIMENT`, `DEPLOYMENT_RESOURCE_TYPE_EXTERNAL_LOCATION`, `DEPLOYMENT_RESOURCE_TYPE_GENIE_SPACE`, `DEPLOYMENT_RESOURCE_TYPE_INSTANCE_POOL`, `DEPLOYMENT_RESOURCE_TYPE_JOB`, `DEPLOYMENT_RESOURCE_TYPE_JOB_RUN`, `DEPLOYMENT_RESOURCE_TYPE_MODEL`, `DEPLOYMENT_RESOURCE_TYPE_MODEL_SERVING_ENDPOINT`, `DEPLOYMENT_RESOURCE_TYPE_PIPELINE`, `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_BRANCH`, `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_CATALOG`, `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_DATABASE`, `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_ENDPOINT`, `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_PROJECT`, `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_ROLE`, `DEPLOYMENT_RESOURCE_TYPE_POSTGRES_SYNCED_TABLE`, `DEPLOYMENT_RESOURCE_TYPE_QUALITY_MONITOR`, `DEPLOYMENT_RESOURCE_TYPE_REGISTERED_MODEL`, `DEPLOYMENT_RESOURCE_TYPE_SCHEMA`, `DEPLOYMENT_RESOURCE_TYPE_SECRET`, `DEPLOYMENT_RESOURCE_TYPE_SECRET_SCOPE`, `DEPLOYMENT_RESOURCE_TYPE_SQL_WAREHOUSE`, `DEPLOYMENT_RESOURCE_TYPE_SYNCED_DATABASE_TABLE`, `DEPLOYMENT_RESOURCE_TYPE_VECTOR_SEARCH_ENDPOINT`, `DEPLOYMENT_RESOURCE_TYPE_VECTOR_SEARCH_INDEX`, `DEPLOYMENT_RESOURCE_TYPE_VOLUME`: + *f = DeploymentResourceType(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "DEPLOYMENT_RESOURCE_TYPE_ALERT", "DEPLOYMENT_RESOURCE_TYPE_APP", "DEPLOYMENT_RESOURCE_TYPE_CATALOG", "DEPLOYMENT_RESOURCE_TYPE_CLUSTER", "DEPLOYMENT_RESOURCE_TYPE_CLUSTER_POLICY", "DEPLOYMENT_RESOURCE_TYPE_DASHBOARD", "DEPLOYMENT_RESOURCE_TYPE_DATABASE_CATALOG", "DEPLOYMENT_RESOURCE_TYPE_DATABASE_INSTANCE", "DEPLOYMENT_RESOURCE_TYPE_EXPERIMENT", "DEPLOYMENT_RESOURCE_TYPE_EXTERNAL_LOCATION", "DEPLOYMENT_RESOURCE_TYPE_GENIE_SPACE", "DEPLOYMENT_RESOURCE_TYPE_INSTANCE_POOL", "DEPLOYMENT_RESOURCE_TYPE_JOB", "DEPLOYMENT_RESOURCE_TYPE_JOB_RUN", "DEPLOYMENT_RESOURCE_TYPE_MODEL", "DEPLOYMENT_RESOURCE_TYPE_MODEL_SERVING_ENDPOINT", "DEPLOYMENT_RESOURCE_TYPE_PIPELINE", "DEPLOYMENT_RESOURCE_TYPE_POSTGRES_BRANCH", "DEPLOYMENT_RESOURCE_TYPE_POSTGRES_CATALOG", "DEPLOYMENT_RESOURCE_TYPE_POSTGRES_DATABASE", "DEPLOYMENT_RESOURCE_TYPE_POSTGRES_ENDPOINT", "DEPLOYMENT_RESOURCE_TYPE_POSTGRES_PROJECT", "DEPLOYMENT_RESOURCE_TYPE_POSTGRES_ROLE", "DEPLOYMENT_RESOURCE_TYPE_POSTGRES_SYNCED_TABLE", "DEPLOYMENT_RESOURCE_TYPE_QUALITY_MONITOR", "DEPLOYMENT_RESOURCE_TYPE_REGISTERED_MODEL", "DEPLOYMENT_RESOURCE_TYPE_SCHEMA", "DEPLOYMENT_RESOURCE_TYPE_SECRET", "DEPLOYMENT_RESOURCE_TYPE_SECRET_SCOPE", "DEPLOYMENT_RESOURCE_TYPE_SQL_WAREHOUSE", "DEPLOYMENT_RESOURCE_TYPE_SYNCED_DATABASE_TABLE", "DEPLOYMENT_RESOURCE_TYPE_VECTOR_SEARCH_ENDPOINT", "DEPLOYMENT_RESOURCE_TYPE_VECTOR_SEARCH_INDEX", "DEPLOYMENT_RESOURCE_TYPE_VOLUME"`, v) + } +} + +// Values returns all possible values for DeploymentResourceType. +// +// There is no guarantee on the order of the values in the slice. +func (f *DeploymentResourceType) Values() []DeploymentResourceType { + return []DeploymentResourceType{ + DeploymentResourceTypeDeploymentResourceTypeAlert, + DeploymentResourceTypeDeploymentResourceTypeApp, + DeploymentResourceTypeDeploymentResourceTypeCatalog, + DeploymentResourceTypeDeploymentResourceTypeCluster, + DeploymentResourceTypeDeploymentResourceTypeClusterPolicy, + DeploymentResourceTypeDeploymentResourceTypeDashboard, + DeploymentResourceTypeDeploymentResourceTypeDatabaseCatalog, + DeploymentResourceTypeDeploymentResourceTypeDatabaseInstance, + DeploymentResourceTypeDeploymentResourceTypeExperiment, + DeploymentResourceTypeDeploymentResourceTypeExternalLocation, + DeploymentResourceTypeDeploymentResourceTypeGenieSpace, + DeploymentResourceTypeDeploymentResourceTypeInstancePool, + DeploymentResourceTypeDeploymentResourceTypeJob, + DeploymentResourceTypeDeploymentResourceTypeJobRun, + DeploymentResourceTypeDeploymentResourceTypeModel, + DeploymentResourceTypeDeploymentResourceTypeModelServingEndpoint, + DeploymentResourceTypeDeploymentResourceTypePipeline, + DeploymentResourceTypeDeploymentResourceTypePostgresBranch, + DeploymentResourceTypeDeploymentResourceTypePostgresCatalog, + DeploymentResourceTypeDeploymentResourceTypePostgresDatabase, + DeploymentResourceTypeDeploymentResourceTypePostgresEndpoint, + DeploymentResourceTypeDeploymentResourceTypePostgresProject, + DeploymentResourceTypeDeploymentResourceTypePostgresRole, + DeploymentResourceTypeDeploymentResourceTypePostgresSyncedTable, + DeploymentResourceTypeDeploymentResourceTypeQualityMonitor, + DeploymentResourceTypeDeploymentResourceTypeRegisteredModel, + DeploymentResourceTypeDeploymentResourceTypeSchema, + DeploymentResourceTypeDeploymentResourceTypeSecret, + DeploymentResourceTypeDeploymentResourceTypeSecretScope, + DeploymentResourceTypeDeploymentResourceTypeSqlWarehouse, + DeploymentResourceTypeDeploymentResourceTypeSyncedDatabaseTable, + DeploymentResourceTypeDeploymentResourceTypeVectorSearchEndpoint, + DeploymentResourceTypeDeploymentResourceTypeVectorSearchIndex, + DeploymentResourceTypeDeploymentResourceTypeVolume, + } +} + +// Type always returns DeploymentResourceType to satisfy [pflag.Value] interface +func (f *DeploymentResourceType) Type() string { + return "DeploymentResourceType" +} + +// Status of a deployment. +type DeploymentStatus string + +const DeploymentStatusDeploymentStatusActive DeploymentStatus = `DEPLOYMENT_STATUS_ACTIVE` + +const DeploymentStatusDeploymentStatusDeleted DeploymentStatus = `DEPLOYMENT_STATUS_DELETED` + +const DeploymentStatusDeploymentStatusFailed DeploymentStatus = `DEPLOYMENT_STATUS_FAILED` + +const DeploymentStatusDeploymentStatusInProgress DeploymentStatus = `DEPLOYMENT_STATUS_IN_PROGRESS` + +// String representation for [fmt.Print] +func (f *DeploymentStatus) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *DeploymentStatus) Set(v string) error { + switch v { + case `DEPLOYMENT_STATUS_ACTIVE`, `DEPLOYMENT_STATUS_DELETED`, `DEPLOYMENT_STATUS_FAILED`, `DEPLOYMENT_STATUS_IN_PROGRESS`: + *f = DeploymentStatus(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "DEPLOYMENT_STATUS_ACTIVE", "DEPLOYMENT_STATUS_DELETED", "DEPLOYMENT_STATUS_FAILED", "DEPLOYMENT_STATUS_IN_PROGRESS"`, v) + } +} + +// Values returns all possible values for DeploymentStatus. +// +// There is no guarantee on the order of the values in the slice. +func (f *DeploymentStatus) Values() []DeploymentStatus { + return []DeploymentStatus{ + DeploymentStatusDeploymentStatusActive, + DeploymentStatusDeploymentStatusDeleted, + DeploymentStatusDeploymentStatusFailed, + DeploymentStatusDeploymentStatusInProgress, + } +} + +// Type always returns DeploymentStatus to satisfy [pflag.Value] interface +func (f *DeploymentStatus) Type() string { + return "DeploymentStatus" +} + +type GetDeploymentRequest struct { + // Resource name of the deployment to retrieve. Format: + // deployments/{deployment_id} + Name string `json:"-" url:"-"` +} + +type GetOperationRequest struct { + // The name of the resource operation to retrieve. Format: + // deployments/{deployment_id}/versions/{version_id}/operations/{resource_key} + Name string `json:"-" url:"-"` +} + +type GetResourceRequest struct { + // The name of the resource to retrieve. Format: + // deployments/{deployment_id}/resources/{resource_key} + Name string `json:"-" url:"-"` +} + +type GetVersionRequest struct { + // The name of the version to retrieve. Format: + // deployments/{deployment_id}/versions/{version_id} + Name string `json:"-" url:"-"` +} + +// Git provenance of a bundle's source, captured at deploy time. Lets consumers +// link a deployed resource back to its source in version control. +type GitInfo struct { + // Branch the source was deployed from. + Branch string `json:"branch,omitempty"` + // Commit SHA of the deployed source. + Commit string `json:"commit,omitempty"` + // URL of the git remote the source was deployed from. + OriginUrl string `json:"origin_url,omitempty"` +} + +// A request to send a heartbeat for a Version. +type HeartbeatRequest struct { + // The version whose lock to renew. Format: + // deployments/{deployment_id}/versions/{version_id} + Name string `json:"-" url:"-"` +} + +// Response for Heartbeat. +type HeartbeatResponse struct { + // The new lock expiry time after renewal. + ExpireTime *types.Time `json:"expire_time,omitempty"` +} + +type ListDeploymentsRequest struct { + // The maximum number of deployments to return. The service may return fewer + // than this value. If unspecified, at most 20 deployments will be returned. + // The maximum value is 1000; values above 1000 will be coerced to 1000. + PageSize int `json:"-" url:"page_size,omitempty"` + // A page token, received from a previous `ListDeployments` call. Provide + // this to retrieve the subsequent page. + PageToken string `json:"-" url:"page_token,omitempty"` +} + +// Response for ListDeployments. +type ListDeploymentsResponse struct { + // The deployments from the queried workspace. + Deployments []Deployment `json:"deployments,omitempty"` + // A token, which can be sent as `page_token` to retrieve the next page. If + // this field is omitted, there are no subsequent pages. + NextPageToken string `json:"next_page_token,omitempty"` +} + +type ListOperationsRequest struct { + // The maximum number of operations to return. The service may return fewer + // than this value. If unspecified, at most 50 operations will be returned. + // The maximum value is 1000; values above 1000 will be coerced to 1000. + PageSize int `json:"-" url:"page_size,omitempty"` + // A page token, received from a previous `ListOperations` call. Provide + // this to retrieve the subsequent page. + PageToken string `json:"-" url:"page_token,omitempty"` + // The parent version. Format: + // deployments/{deployment_id}/versions/{version_id} + Parent string `json:"-" url:"-"` +} + +// Response for ListOperations. +type ListOperationsResponse struct { + // A token, which can be sent as `page_token` to retrieve the next page. If + // this field is omitted, there are no subsequent pages. + NextPageToken string `json:"next_page_token,omitempty"` + // The resource operations under the specified version. + Operations []Operation `json:"operations,omitempty"` +} + +type ListResourcesRequest struct { + // The maximum number of resources to return. The service may return fewer + // than this value. If unspecified, at most 50 resources will be returned. + // The maximum value is 1000; values above 1000 will be coerced to 1000. + PageSize int `json:"-" url:"page_size,omitempty"` + // A page token, received from a previous `ListResources` call. Provide this + // to retrieve the subsequent page. + PageToken string `json:"-" url:"page_token,omitempty"` + // The parent deployment. Format: deployments/{deployment_id} + Parent string `json:"-" url:"-"` +} + +// Response for ListResources. +type ListResourcesResponse struct { + // A token, which can be sent as `page_token` to retrieve the next page. If + // this field is omitted, there are no subsequent pages. + NextPageToken string `json:"next_page_token,omitempty"` + // The resources under the specified deployment. + Resources []Resource `json:"resources,omitempty"` +} + +type ListVersionsRequest struct { + // The maximum number of versions to return. The service may return fewer + // than this value. If unspecified, at most 20 versions will be returned. + // The maximum value is 100; values above 100 will be coerced to 100. + PageSize int `json:"-" url:"page_size,omitempty"` + // A page token, received from a previous `ListVersions` call. Provide this + // to retrieve the subsequent page. + PageToken string `json:"-" url:"page_token,omitempty"` + // The parent deployment. Format: deployments/{deployment_id} + Parent string `json:"-" url:"-"` +} + +// Response for ListVersions. +type ListVersionsResponse struct { + // A token, which can be sent as `page_token` to retrieve the next page. If + // this field is omitted, there are no subsequent pages. + NextPageToken string `json:"next_page_token,omitempty"` + // The versions under the specified deployment. + Versions []Version `json:"versions,omitempty"` +} + +// An operation on a single resource performed during a version. The full set of +// operations for a version is recorded when the version is created: each +// carries its `resource_key` and `action_type` and starts in +// `OPERATION_STATUS_PENDING`. As each resource is applied, its operation is +// updated (via UpdateOperation) to record the result of applying the change to +// the workspace. `state`, `error_message`, `resource_id`, `status`, and +// `dashboard_metadata` may be updated afterwards, guarded by `sequence_id` for +// optimistic concurrency control; all other fields are immutable once recorded. +type Operation struct { + // The type of operation performed on this resource. Set when the version is + // created and immutable thereafter. + ActionType OperationActionType `json:"action_type,omitempty"` + // When the operation was recorded. + CreateTime *types.Time `json:"create_time,omitempty"` + // Dashboard-specific metadata; set only for dashboard resources. Mutable: + // may be set or updated via UpdateOperation as the resource is applied, and + // is mirrored onto the corresponding deployment-level resource. + DashboardMetadata *DashboardMetadata `json:"dashboard_metadata,omitempty"` + // Error message if the operation failed. Set when status is + // OPERATION_STATUS_FAILED. Captures the error encountered while applying + // the resource to the workspace. Mutable: may be updated after creation via + // UpdateOperation; setting it to an empty string clears it. After an update + // is applied, an operation whose status is OPERATION_STATUS_SUCCEEDED + // cannot carry an error_message. + ErrorMessage string `json:"error_message,omitempty"` + // Resource name of the operation. Format: + // deployments/{deployment_id}/versions/{version_id}/operations/{resource_key} + Name string `json:"name,omitempty"` + // ID of the actual resource in the workspace (e.g. the job ID, pipeline + // ID). Required whenever `state` is set, because state records a resource + // that exists. A CREATE or RECREATE that has not produced its resource yet + // records neither. Mutable: may be filled in (or corrected) later via + // UpdateOperation once the ID is known. + ResourceId string `json:"resource_id,omitempty"` + // Resource identifier within the bundle (e.g. "jobs.foo", "pipelines.bar", + // "jobs.foo.permissions", "files."). Can be an arbitrary UTF-8 + // encoded string key. This key links the operation to the corresponding + // deployment-level Resource. Set when the version is created and immutable + // thereafter. + ResourceKey string `json:"resource_key,omitempty"` + // The type of the deployment resource this operation applies to. Derived + // from the `resource_key` prefix (e.g. "jobs" → JOB); the caller does not + // set this field. + ResourceType DeploymentResourceType `json:"resource_type,omitempty"` + // Monotonically increasing revision used for optimistic concurrency control + // (the AIP-154 concurrency token for this resource, realized as a sequence + // number rather than an opaque etag). The server assigns 0 when the + // operation is created and increments it on every successful + // UpdateOperation, so a never-updated operation is at 0 and the first + // successful update makes it 1. It is OPTIONAL rather than OUTPUT_ONLY + // because it is dual-purpose: GetOperation returns the current value, and + // UpdateOperation reads the caller-supplied value as a precondition. The + // caller must echo the value it last observed; if it no longer matches the + // server's value, the update is rejected with ABORTED so the caller can + // re-read and retry. + SequenceId int64 `json:"sequence_id,omitempty"` + // Serialized local config state after the operation. Its presence records + // whether the resource still exists. Explicitly clearing state removes the + // resource; omitting it from the update mask leaves resource state + // unchanged. State is stored only on Resources. UpdateOperation accepts + // state but omits it from its response, as do subsequent GetOperation and + // ListOperations. + // + // Mutable: may be updated after creation via UpdateOperation. When + // updating, the caller must echo the last-observed `sequence_id` as a + // concurrency precondition. + // + // The string is not parsed; it is projected onto the corresponding + // Resource's state. It is deliberately not google.protobuf.Value, whose + // only numeric case is `double number_value`, so parsing the client's JSON + // into it rewrites every integer as a double - `1` reads back as `1.0`, + // which no longer deserializes into an integer field - and silently loses + // precision above 2^53, which is within range for IDs the client records. + // + // A string rather than bytes: the payload is always UTF-8 JSON, and proto3 + // JSON maps bytes to base64, which inflates every request and response by a + // third and makes state unreadable in logs and API responses. Both generate + // the same OpenAPI schema ("type": "string"), so the SDKs are identical + // either way. + State string `json:"state,omitempty"` + // Status of the operation. Starts as OPERATION_STATUS_PENDING when the + // version is created and moves to a terminal status once the resource is + // applied. Mutable: updated via UpdateOperation, e.g. when an operation + // recorded as failed is retried and eventually succeeds. + Status OperationStatus `json:"status,omitempty"` + // When the operation was last updated. Set to `create_time` when the + // operation is created and to the server timestamp on each successful + // UpdateOperation. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +// Type of action performed on a resource during a deployment. +type OperationActionType string + +const OperationActionTypeOperationActionTypeBind OperationActionType = `OPERATION_ACTION_TYPE_BIND` + +const OperationActionTypeOperationActionTypeBindAndUpdate OperationActionType = `OPERATION_ACTION_TYPE_BIND_AND_UPDATE` + +const OperationActionTypeOperationActionTypeCreate OperationActionType = `OPERATION_ACTION_TYPE_CREATE` + +const OperationActionTypeOperationActionTypeDelete OperationActionType = `OPERATION_ACTION_TYPE_DELETE` + +const OperationActionTypeOperationActionTypeInitialRegister OperationActionType = `OPERATION_ACTION_TYPE_INITIAL_REGISTER` + +const OperationActionTypeOperationActionTypeRecreate OperationActionType = `OPERATION_ACTION_TYPE_RECREATE` + +const OperationActionTypeOperationActionTypeResize OperationActionType = `OPERATION_ACTION_TYPE_RESIZE` + +const OperationActionTypeOperationActionTypeUpdate OperationActionType = `OPERATION_ACTION_TYPE_UPDATE` + +const OperationActionTypeOperationActionTypeUpdateWithId OperationActionType = `OPERATION_ACTION_TYPE_UPDATE_WITH_ID` + +// String representation for [fmt.Print] +func (f *OperationActionType) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *OperationActionType) Set(v string) error { + switch v { + case `OPERATION_ACTION_TYPE_BIND`, `OPERATION_ACTION_TYPE_BIND_AND_UPDATE`, `OPERATION_ACTION_TYPE_CREATE`, `OPERATION_ACTION_TYPE_DELETE`, `OPERATION_ACTION_TYPE_INITIAL_REGISTER`, `OPERATION_ACTION_TYPE_RECREATE`, `OPERATION_ACTION_TYPE_RESIZE`, `OPERATION_ACTION_TYPE_UPDATE`, `OPERATION_ACTION_TYPE_UPDATE_WITH_ID`: + *f = OperationActionType(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "OPERATION_ACTION_TYPE_BIND", "OPERATION_ACTION_TYPE_BIND_AND_UPDATE", "OPERATION_ACTION_TYPE_CREATE", "OPERATION_ACTION_TYPE_DELETE", "OPERATION_ACTION_TYPE_INITIAL_REGISTER", "OPERATION_ACTION_TYPE_RECREATE", "OPERATION_ACTION_TYPE_RESIZE", "OPERATION_ACTION_TYPE_UPDATE", "OPERATION_ACTION_TYPE_UPDATE_WITH_ID"`, v) + } +} + +// Values returns all possible values for OperationActionType. +// +// There is no guarantee on the order of the values in the slice. +func (f *OperationActionType) Values() []OperationActionType { + return []OperationActionType{ + OperationActionTypeOperationActionTypeBind, + OperationActionTypeOperationActionTypeBindAndUpdate, + OperationActionTypeOperationActionTypeCreate, + OperationActionTypeOperationActionTypeDelete, + OperationActionTypeOperationActionTypeInitialRegister, + OperationActionTypeOperationActionTypeRecreate, + OperationActionTypeOperationActionTypeResize, + OperationActionTypeOperationActionTypeUpdate, + OperationActionTypeOperationActionTypeUpdateWithId, + } +} + +// Type always returns OperationActionType to satisfy [pflag.Value] interface +func (f *OperationActionType) Type() string { + return "OperationActionType" +} + +// Status of a resource operation. +type OperationStatus string + +const OperationStatusOperationStatusFailed OperationStatus = `OPERATION_STATUS_FAILED` + +const OperationStatusOperationStatusPending OperationStatus = `OPERATION_STATUS_PENDING` + +const OperationStatusOperationStatusSucceeded OperationStatus = `OPERATION_STATUS_SUCCEEDED` + +// String representation for [fmt.Print] +func (f *OperationStatus) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *OperationStatus) Set(v string) error { + switch v { + case `OPERATION_STATUS_FAILED`, `OPERATION_STATUS_PENDING`, `OPERATION_STATUS_SUCCEEDED`: + *f = OperationStatus(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "OPERATION_STATUS_FAILED", "OPERATION_STATUS_PENDING", "OPERATION_STATUS_SUCCEEDED"`, v) + } +} + +// Values returns all possible values for OperationStatus. +// +// There is no guarantee on the order of the values in the slice. +func (f *OperationStatus) Values() []OperationStatus { + return []OperationStatus{ + OperationStatusOperationStatusFailed, + OperationStatusOperationStatusPending, + OperationStatusOperationStatusSucceeded, + } +} + +// Type always returns OperationStatus to satisfy [pflag.Value] interface +func (f *OperationStatus) Type() string { + return "OperationStatus" +} + +// A resource managed by a deployment. Resources are implicitly created, +// updated, or deleted when operations are recorded on a version. +type Resource struct { + // Dashboard-specific metadata; set only for dashboard resources. + DashboardMetadata *DashboardMetadata `json:"dashboard_metadata,omitempty"` + // The action performed on this resource during the last version. + LastActionType OperationActionType `json:"last_action_type,omitempty"` + // The version_id of the last version where this resource was updated. + LastVersionId string `json:"last_version_id,omitempty"` + // Resource name. Format: + // deployments/{deployment_id}/resources/{resource_key} + Name string `json:"name,omitempty"` + // ID that references the actual resource in the workspace (e.g. the job ID, + // pipeline ID). + ResourceId string `json:"resource_id,omitempty"` + // Resource identifier within the bundle (e.g. "jobs.foo", "pipelines.bar", + // "jobs.foo.permissions"). + ResourceKey string `json:"resource_key,omitempty"` + // The type of the deployment resource. + ResourceType DeploymentResourceType `json:"resource_type"` + // Serialized local config state (what the CLI deployed). Opaque to this + // service; see Operation.state for why this is a string and not + // google.protobuf.Value. + State string `json:"state,omitempty"` + // When the last operation that updated this resource's recorded state was + // applied. Pairs with last_action_type and last_version_id (all three + // advance together on that write). + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +// A resource operation to record when a version is created. Each staged +// operation identifies the resource it applies to and the action planned for +// it; the server records the operation in `OPERATION_STATUS_PENDING`, and its +// outcome is filled in later via UpdateOperation. +type StagedOperation struct { + // The type of operation planned for this resource. + ActionType OperationActionType `json:"action_type"` + // The key identifying the resource this operation applies to (e.g. + // "jobs.foo", "pipelines.bar"). Becomes the final component of the + // operation's name and must be unique among the operations in the version. + ResourceKey string `json:"resource_key"` +} + +type UpdateDeploymentRequest struct { + // The deployment to update. Its `name` selects the deployment; the fields + // named in `update_mask` carry the new values. All other fields are + // ignored. + Deployment Deployment `json:"deployment"` + // Resource name of the deployment. Format: deployments/{deployment_id} + Name string `json:"-" url:"-"` + // The fields to update; supported paths are `display_name`, + // `deployment_mode`, `target_name`, and `workspace_info`. An empty mask or + // any other path returns INVALID_PARAMETER_VALUE. + UpdateMask FieldMask `json:"-" url:"update_mask"` +} + +type UpdateOperationRequest struct { + // Resource name of the operation. Format: + // deployments/{deployment_id}/versions/{version_id}/operations/{resource_key} + Name string `json:"-" url:"-"` + // The operation to update. Its `name` selects the operation; the fields + // named in `update_mask` carry the new values; and `sequence_id` carries + // the optimistic-concurrency precondition (see the field docs on + // Operation). All other fields are ignored. + Operation Operation `json:"operation"` + // The set of fields to update. Required; supported paths are `state`, + // `error_message`, `resource_id`, `status`, and `dashboard_metadata`. An + // empty mask or any other path is rejected with INVALID_PARAMETER_VALUE. + UpdateMask FieldMask `json:"-" url:"update_mask"` +} + +// A single invocation of a deploy or destroy command against a deployment. +// Creating a version acquires an exclusive lock on the parent deployment. +type Version struct { + // CLI version used to initiate the version. + CliVersion string `json:"cli_version"` + // When the version completed. Unset while the version is in progress. + CompleteTime *types.Time `json:"complete_time,omitempty"` + // The user who completed the version (email or principal name). May differ + // from `created_by` when another user force-completes the version. + CompletedBy string `json:"completed_by,omitempty"` + // Why the version was completed. Unset while in progress. Set when status + // transitions to COMPLETED. + CompletionReason VersionComplete `json:"completion_reason,omitempty"` + // When the version was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // The user who created the version (email or principal name). + CreatedBy string `json:"created_by,omitempty"` + // Bundle target deployment mode (development or production), captured at + // the time of this version. + DeploymentMode DeploymentMode `json:"deployment_mode,omitempty"` + // Display name for the deployment, captured at the time of this version. Up + // to 256 characters. When present, creating the version updates the + // deployment display name. An empty value clears it; an absent value leaves + // the current deployment display name unchanged. + DisplayName string `json:"display_name,omitempty"` + // Git provenance of the source, captured at the time of this version. + GitInfo *GitInfo `json:"git_info,omitempty"` + // Resource name of the version. Format: + // deployments/{deployment_id}/versions/{version_id} + Name string `json:"name,omitempty"` + // The full operation plan for this version: one PENDING operation per + // entry, recorded in the same transaction. Input only -- supplied on create + // and never returned by create/get/list; read the recorded operations via + // ListOperations. + Operations []StagedOperation `json:"operations,omitempty"` + // The version_id this version was created on top of — the deployment's + // most recent version at creation time. Leave unset when creating the first + // version (the deployment has no prior versions). Set by the client on + // creation and immutable thereafter. + // + // Acts as an optimistic-concurrency precondition: the server requires it to + // equal the deployment's current most-recent version (and to be unset when + // the deployment has no versions) and returns `INVALID_PARAMETER_VALUE` on + // mismatch, so a deploy racing against a concurrent deploy is rejected + // rather than silently overwriting it. + PreviousVersionId string `json:"previous_version_id,omitempty"` + // Status of the version: IN_PROGRESS or COMPLETED. + Status VersionStatus `json:"status,omitempty"` + // Target name of the deployment, captured at the time of this version. + TargetName string `json:"target_name,omitempty"` + // Version identifier within the parent deployment, assigned by the client + // on creation. A numeric string (base-10, fits in a signed 64-bit integer) + // that is greater than or equal to 1. Version IDs are strictly increasing + // within a deployment but are not required to start at 1 or to be + // contiguous. + VersionId string `json:"version_id,omitempty"` + // Type of version (deploy or destroy). + VersionType VersionType `json:"version_type"` + // Workspace location of the deployment, captured at the time of this + // version. + WorkspaceInfo *WorkspaceInfo `json:"workspace_info,omitempty"` +} + +// Reason why a version was completed. +type VersionComplete string + +const VersionCompleteVersionCompleteFailure VersionComplete = `VERSION_COMPLETE_FAILURE` + +const VersionCompleteVersionCompleteForceAbort VersionComplete = `VERSION_COMPLETE_FORCE_ABORT` + +const VersionCompleteVersionCompleteLeaseExpired VersionComplete = `VERSION_COMPLETE_LEASE_EXPIRED` + +const VersionCompleteVersionCompleteSuccess VersionComplete = `VERSION_COMPLETE_SUCCESS` + +// String representation for [fmt.Print] +func (f *VersionComplete) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *VersionComplete) Set(v string) error { + switch v { + case `VERSION_COMPLETE_FAILURE`, `VERSION_COMPLETE_FORCE_ABORT`, `VERSION_COMPLETE_LEASE_EXPIRED`, `VERSION_COMPLETE_SUCCESS`: + *f = VersionComplete(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "VERSION_COMPLETE_FAILURE", "VERSION_COMPLETE_FORCE_ABORT", "VERSION_COMPLETE_LEASE_EXPIRED", "VERSION_COMPLETE_SUCCESS"`, v) + } +} + +// Values returns all possible values for VersionComplete. +// +// There is no guarantee on the order of the values in the slice. +func (f *VersionComplete) Values() []VersionComplete { + return []VersionComplete{ + VersionCompleteVersionCompleteFailure, + VersionCompleteVersionCompleteForceAbort, + VersionCompleteVersionCompleteLeaseExpired, + VersionCompleteVersionCompleteSuccess, + } +} + +// Type always returns VersionComplete to satisfy [pflag.Value] interface +func (f *VersionComplete) Type() string { + return "VersionComplete" +} + +// Status of a version. +type VersionStatus string + +const VersionStatusVersionStatusCompleted VersionStatus = `VERSION_STATUS_COMPLETED` + +const VersionStatusVersionStatusInProgress VersionStatus = `VERSION_STATUS_IN_PROGRESS` + +// String representation for [fmt.Print] +func (f *VersionStatus) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *VersionStatus) Set(v string) error { + switch v { + case `VERSION_STATUS_COMPLETED`, `VERSION_STATUS_IN_PROGRESS`: + *f = VersionStatus(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "VERSION_STATUS_COMPLETED", "VERSION_STATUS_IN_PROGRESS"`, v) + } +} + +// Values returns all possible values for VersionStatus. +// +// There is no guarantee on the order of the values in the slice. +func (f *VersionStatus) Values() []VersionStatus { + return []VersionStatus{ + VersionStatusVersionStatusCompleted, + VersionStatusVersionStatusInProgress, + } +} + +// Type always returns VersionStatus to satisfy [pflag.Value] interface +func (f *VersionStatus) Type() string { + return "VersionStatus" +} + +// Type of version. +type VersionType string + +const VersionTypeVersionTypeDeploy VersionType = `VERSION_TYPE_DEPLOY` + +const VersionTypeVersionTypeDestroy VersionType = `VERSION_TYPE_DESTROY` + +// String representation for [fmt.Print] +func (f *VersionType) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *VersionType) Set(v string) error { + switch v { + case `VERSION_TYPE_DEPLOY`, `VERSION_TYPE_DESTROY`: + *f = VersionType(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "VERSION_TYPE_DEPLOY", "VERSION_TYPE_DESTROY"`, v) + } +} + +// Values returns all possible values for VersionType. +// +// There is no guarantee on the order of the values in the slice. +func (f *VersionType) Values() []VersionType { + return []VersionType{ + VersionTypeVersionTypeDeploy, + VersionTypeVersionTypeDestroy, + } +} + +// Type always returns VersionType to satisfy [pflag.Value] interface +func (f *VersionType) Type() string { + return "VersionType" +} + +// Workspace location of a bundle deployment, captured at deploy time. +type WorkspaceInfo struct { + // Path of the bundle root (the directory containing databricks.yml) + // relative to git_folder_path. Empty when the deployment is not from a + // Databricks Git folder. + BundleRootPath string `json:"bundle_root_path,omitempty"` + // Absolute workspace path where the deployed bundle files live. Mirrors the + // workspace.file_path field in DABs bundle config. + FilePath string `json:"file_path,omitempty"` + // When deployed from a Databricks Git folder, the absolute workspace path + // of that folder; empty for local deploys. + GitFolderPath string `json:"git_folder_path,omitempty"` + // Absolute workspace path of the deployment root — the base path the + // deployed files live under. Mirrors workspace.root_path in the DABs bundle + // config; file_path is its files subdirectory. + RootPath string `json:"root_path,omitempty"` + // Whether files are served directly from the source sync root instead of + // being copied into file_path. + SourceLinked bool `json:"source_linked,omitempty"` +} + +// UnmarshalJSON accepts sequence_id as a JSON string, which is how the service +// encodes int64 values, as well as a number. +func (o *Operation) UnmarshalJSON(data []byte) error { + type operation Operation + var raw struct { + *operation + SequenceId json.Number `json:"sequence_id,omitempty"` + } + raw.operation = (*operation)(o) + dec := json.NewDecoder(bytes.NewReader(data)) + dec.UseNumber() + if err := dec.Decode(&raw); err != nil { + return err + } + o.SequenceId = 0 + if raw.SequenceId != "" { + n, err := strconv.ParseInt(raw.SequenceId.String(), 10, 64) + if err != nil { + return fmt.Errorf("sequence_id: %w", err) + } + o.SequenceId = n + } + return nil +} diff --git a/libs/bundledeployments/model_test.go b/libs/bundledeployments/model_test.go new file mode 100644 index 00000000000..ff2109959f8 --- /dev/null +++ b/libs/bundledeployments/model_test.go @@ -0,0 +1,21 @@ +package bundledeployments + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestOperationUnmarshalSequenceId(t *testing.T) { + for input, want := range map[string]int64{ + `{"sequence_id":"5","resource_key":"a"}`: 5, + `{"sequence_id":7}`: 7, + `{}`: 0, + } { + var o Operation + require.NoError(t, json.Unmarshal([]byte(input), &o)) + assert.Equal(t, want, o.SequenceId, input) + } +} diff --git a/libs/cmdctx/account_client.go b/libs/cmdctx/account_client.go index 198326e5fbe..8d1ab519cec 100644 --- a/libs/cmdctx/account_client.go +++ b/libs/cmdctx/account_client.go @@ -3,18 +3,18 @@ package cmdctx import ( "context" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" ) -func SetAccountClient(ctx context.Context, a *databricks.AccountClient) context.Context { +func SetAccountClient(ctx context.Context, a *sdkclients.Clients) context.Context { if v := ctx.Value(accountClientKey); v != nil { panic("cmdctx.SetAccountClient called twice on the same context.") } return context.WithValue(ctx, accountClientKey, a) } -func AccountClient(ctx context.Context) *databricks.AccountClient { - a, ok := ctx.Value(accountClientKey).(*databricks.AccountClient) +func AccountClient(ctx context.Context) *sdkclients.Clients { + a, ok := ctx.Value(accountClientKey).(*sdkclients.Clients) if !ok { panic("cmdctx.AccountClient called without calling cmdctx.SetAccountClient first") } diff --git a/libs/cmdctx/account_client_test.go b/libs/cmdctx/account_client_test.go index 6472b1a2921..33e8d702f24 100644 --- a/libs/cmdctx/account_client_test.go +++ b/libs/cmdctx/account_client_test.go @@ -3,14 +3,14 @@ package cmdctx import ( "testing" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" ) func TestCommandAccountClient(t *testing.T) { ctx := t.Context() - client := &databricks.AccountClient{ + client := &sdkclients.Clients{ Config: &config.Config{ AccountID: "test-account", }, diff --git a/libs/cmdctx/workspace_client.go b/libs/cmdctx/workspace_client.go index 915ea0337c7..f6e9a4203c3 100644 --- a/libs/cmdctx/workspace_client.go +++ b/libs/cmdctx/workspace_client.go @@ -3,22 +3,22 @@ package cmdctx import ( "context" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" ) -func SetWorkspaceClient(ctx context.Context, w *databricks.WorkspaceClient) context.Context { +func SetWorkspaceClient(ctx context.Context, w *sdkclients.Clients) context.Context { if v := ctx.Value(workspaceClientKey); v != nil { panic("cmdctx.SetWorkspaceClient called twice on the same context.") } return context.WithValue(ctx, workspaceClientKey, w) } -func WorkspaceClient(ctx context.Context) *databricks.WorkspaceClient { +func WorkspaceClient(ctx context.Context) *sdkclients.Clients { v := ctx.Value(workspaceClientKey) if v == nil { panic("cmdctx.WorkspaceClient called without calling cmdctx.SetWorkspaceClient first.") } - return v.(*databricks.WorkspaceClient) + return v.(*sdkclients.Clients) } // HasWorkspaceClient reports whether a workspace client was configured on the diff --git a/libs/cmdctx/workspace_client_test.go b/libs/cmdctx/workspace_client_test.go index 3f2942d8e81..a19f8b890e4 100644 --- a/libs/cmdctx/workspace_client_test.go +++ b/libs/cmdctx/workspace_client_test.go @@ -4,14 +4,14 @@ import ( "testing" "github.com/databricks/cli/libs/cmdctx" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" ) func TestCommandWorkspaceClient(t *testing.T) { ctx := t.Context() - client := &databricks.WorkspaceClient{ + client := &sdkclients.Clients{ Config: &config.Config{ Host: "https://test.test", }, @@ -41,7 +41,7 @@ func TestHasWorkspaceClient(t *testing.T) { ctx := t.Context() assert.False(t, cmdctx.HasWorkspaceClient(ctx)) - client := &databricks.WorkspaceClient{ + client := &sdkclients.Clients{ Config: &config.Config{ Host: "https://test.test", }, diff --git a/libs/cmdgen/cmdgen.go b/libs/cmdgen/cmdgen.go new file mode 100644 index 00000000000..172b505d927 --- /dev/null +++ b/libs/cmdgen/cmdgen.go @@ -0,0 +1,83 @@ +// Package cmdgen holds runtime helpers for the generated commands in +// cmd/workspace and cmd/account (see internal/cligen). +package cmdgen + +import ( + "context" + "fmt" + "iter" + "reflect" +) + +// MapSeq converts the elements of an sdk-go list iterator, typically into the +// JSON mirror types of libs/sdktypes so that rendering matches the API's JSON. +func MapSeq[S, T any](seq iter.Seq2[*S, error], conv func(*S) (*T, error)) iter.Seq2[*T, error] { + return func(yield func(*T, error) bool) { + for s, err := range seq { + if err != nil { + yield(nil, err) + return + } + t, err := conv(s) + if !yield(t, err) || err != nil { + return + } + } + } +} + +// NamedIdMap lists all items of seq and maps the value at namePath to the value +// at idPath (Go field names, following pointers), for interactive drop-downs. +func NamedIdMap[T any](ctx context.Context, seq iter.Seq2[*T, error], namePath, idPath []string) (map[string]string, error) { + out := map[string]string{} + for item, err := range seq { + if err != nil { + return nil, err + } + name, ok1 := fieldString(reflect.ValueOf(item), namePath) + id, ok2 := fieldString(reflect.ValueOf(item), idPath) + if !ok1 || !ok2 { + continue + } + if _, dup := out[name]; dup { + return nil, fmt.Errorf("duplicate name: %s", name) + } + out[name] = id + } + return out, nil +} + +func fieldString(v reflect.Value, path []string) (string, bool) { + for _, p := range path { + for v.Kind() == reflect.Pointer { + if v.IsNil() { + return "", false + } + v = v.Elem() + } + if v.Kind() != reflect.Struct { + return "", false + } + v = v.FieldByName(p) + if !v.IsValid() { + return "", false + } + } + for v.Kind() == reflect.Pointer { + if v.IsNil() { + return "", false + } + v = v.Elem() + } + return fmt.Sprint(v.Interface()), true +} + +// WaitError marks an error that occurred while waiting for a long-running +// operation to complete, as opposed to an error of the call starting it. +type WaitError struct { + Err error +} + +func (e *WaitError) Error() string { return e.Err.Error() } + +func (e *WaitError) Unwrap() error { return e.Err } diff --git a/libs/cmdio/paged_template.go b/libs/cmdio/paged_template.go index c922c079143..4046d8ed008 100644 --- a/libs/cmdio/paged_template.go +++ b/libs/cmdio/paged_template.go @@ -9,8 +9,9 @@ import ( "text/template" "unicode/utf8" + "github.com/databricks/cli/libs/listing" + tea "github.com/charmbracelet/bubbletea" - "github.com/databricks/databricks-sdk-go/listing" ) // ansiCSIPattern matches ANSI SGR escape sequences so colored cells diff --git a/libs/cmdio/paged_template_test.go b/libs/cmdio/paged_template_test.go index 03a5fc1c9d5..83e9bc8aba3 100644 --- a/libs/cmdio/paged_template_test.go +++ b/libs/cmdio/paged_template_test.go @@ -11,8 +11,9 @@ import ( "strings" "testing" + "github.com/databricks/cli/libs/listing" + "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/listing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/libs/cmdio/pager.go b/libs/cmdio/pager.go index 0ecb330e5cd..f768bdbca8c 100644 --- a/libs/cmdio/pager.go +++ b/libs/cmdio/pager.go @@ -6,10 +6,11 @@ import ( "strings" "time" + "github.com/databricks/cli/libs/listing" + bubblespinner "github.com/charmbracelet/bubbles/spinner" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" - "github.com/databricks/databricks-sdk-go/listing" ) // pagerFallbackPageSize is used before the first WindowSizeMsg arrives, @@ -131,7 +132,7 @@ func (m *pagerModel[T]) doFetch(ctx context.Context, pageSize, limit, total int) if err != nil { return batchMsg{err: err} } - buf = append(buf, n) + buf = append(buf, templateData(n)) } lines, err := m.pager.flushLines(buf) if err != nil { diff --git a/libs/cmdio/pager_test.go b/libs/cmdio/pager_test.go index 503172e7176..e2c918472ca 100644 --- a/libs/cmdio/pager_test.go +++ b/libs/cmdio/pager_test.go @@ -7,8 +7,9 @@ import ( "testing" "text/template" + "github.com/databricks/cli/libs/listing" + tea "github.com/charmbracelet/bubbletea" - "github.com/databricks/databricks-sdk-go/listing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/libs/cmdio/render.go b/libs/cmdio/render.go index 6464814d4a0..83917372ea6 100644 --- a/libs/cmdio/render.go +++ b/libs/cmdio/render.go @@ -8,15 +8,18 @@ import ( "errors" "fmt" "io" + "iter" "maps" "strings" "text/tabwriter" "text/template" "time" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/listing" + "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/listing" ) // Heredoc is the equivalent of compute.TrimLeadingWhitespace @@ -150,7 +153,7 @@ func (ir iteratorRenderer[T]) renderTemplate(ctx context.Context, t *template.Te if err != nil { return err } - buf = append(buf, n) + buf = append(buf, templateData(n)) if len(buf) == cap(buf) { err = t.Execute(w, buf) if err != nil { @@ -194,7 +197,7 @@ func (d defaultRenderer) renderJson(ctx context.Context, w writeFlusher) error { } func (d defaultRenderer) renderTemplate(_ context.Context, t *template.Template, w *tabwriter.Writer) error { - return t.Execute(w, d.t) + return t.Execute(w, templateData(d.t)) } // Returns something implementing one of the following interfaces: @@ -279,7 +282,19 @@ func Render(ctx context.Context, v any) error { // pipeline (same colors, same alignment as the non-paged path; widths are // locked from the first batch so columns stay aligned across pages). // Piped output and JSON output keep the existing non-paged behavior. -func RenderIterator[T any](ctx context.Context, i listing.Iterator[T]) error { +func RenderIterator[T any](ctx context.Context, seq iter.Seq2[T, error]) error { + i := listing.FromSeq(seq) + defer i.Close() + return renderPullIterator(ctx, i) +} + +// RenderListing is RenderIterator for the pull-style iterators returned by +// the CLI's hand-written API clients (libs/listing). +func RenderListing[T any](ctx context.Context, i listing.Iterator[T]) error { + return renderPullIterator[T](ctx, i) +} + +func renderPullIterator[T any](ctx context.Context, i listing.Iterator[T]) error { c := fromContext(ctx) if c.capabilities.SupportsPager() && c.outputFormat == flags.OutputText && c.template != "" { return renderIteratorPagedTemplate(ctx, i, c.in, c.out, c.headerTemplate, c.template) @@ -480,6 +495,9 @@ func renderDiagnostics(ctx context.Context, out io.Writer, diags diag.Diagnostic t = recommendationT } + d.Summary = apierrs.StripPrefix(d.Summary) + d.Detail = apierrs.StripPrefix(d.Detail) + // Render the diagnostic with the appropriate template. err := t.Execute(out, d) if err != nil { diff --git a/libs/cmdio/render_test.go b/libs/cmdio/render_test.go index dc8eec6dd2d..9d9491378ac 100644 --- a/libs/cmdio/render_test.go +++ b/libs/cmdio/render_test.go @@ -2,16 +2,13 @@ package cmdio import ( "bytes" - "context" "encoding/json" - "errors" "fmt" + "iter" "strings" "testing" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go/listing" - "github.com/databricks/databricks-sdk-go/service/provisioning" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -26,36 +23,25 @@ type testCase struct { errMessage string } -var dummyWorkspace1 = provisioning.Workspace{ +// workspace stands in for an API list item. +type workspace struct { + WorkspaceId int64 `json:"workspace_id,omitempty"` + WorkspaceName string `json:"workspace_name,omitempty"` +} + +var dummyWorkspace1 = workspace{ WorkspaceId: 123, WorkspaceName: "abc", } -var dummyWorkspace2 = provisioning.Workspace{ +var dummyWorkspace2 = workspace{ WorkspaceId: 456, WorkspaceName: "def", } -type dummyIterator struct { - items []*provisioning.Workspace -} - -func (d *dummyIterator) HasNext(_ context.Context) bool { - return len(d.items) > 0 -} - -func (d *dummyIterator) Next(ctx context.Context) (*provisioning.Workspace, error) { - if !d.HasNext(ctx) { - return nil, errors.New("no more items") - } - item := d.items[0] - d.items = d.items[1:] - return item, nil -} - -func makeWorkspaces(count int) []*provisioning.Workspace { - res := make([]*provisioning.Workspace, 0, count) - next := []*provisioning.Workspace{&dummyWorkspace1, &dummyWorkspace2} +func makeWorkspaces(count int) []*workspace { + res := make([]*workspace, 0, count) + next := []*workspace{&dummyWorkspace1, &dummyWorkspace2} for range count { n := next[0] next = append(next[1:], n) @@ -64,11 +50,14 @@ func makeWorkspaces(count int) []*provisioning.Workspace { return res } -func makeIterator(count int) listing.Iterator[*provisioning.Workspace] { - items := make([]*provisioning.Workspace, 0, count) - items = append(items, makeWorkspaces(count)...) - return &dummyIterator{ - items: items, +func makeIterator(count int) iter.Seq2[*workspace, error] { + items := makeWorkspaces(count) + return func(yield func(*workspace, error) bool) { + for _, item := range items { + if !yield(item, nil) { + return + } + } } } @@ -268,7 +257,7 @@ func TestRender(t *testing.T) { cmdIO := NewIO(ctx, c.outputFormat, nil, output, output, c.headerTemplate, c.template) ctx = InContext(ctx, cmdIO) var err error - if vv, ok := c.v.(listing.Iterator[*provisioning.Workspace]); ok { + if vv, ok := c.v.(iter.Seq2[*workspace, error]); ok { err = RenderIterator(ctx, vv) } else { err = Render(ctx, c.v) diff --git a/libs/cmdio/select.go b/libs/cmdio/select.go index 2d481139bae..a1ac4c60c8b 100644 --- a/libs/cmdio/select.go +++ b/libs/cmdio/select.go @@ -347,7 +347,7 @@ func (m *selectModel) View() string { // shutdown, so we park the cursor on an empty row below the content. if m.submitted { if !m.hideSelected { - if err := m.selectedTpl.Execute(&b, m.items[m.originalIndex()]); err != nil { + if err := m.selectedTpl.Execute(&b, templateData(m.items[m.originalIndex()])); err != nil { fmt.Fprintf(&b, "[selected template error: %v]", err) } b.WriteString("\n") @@ -402,7 +402,7 @@ func (m *selectModel) View() string { if i == m.cursor { tpl = m.activeTpl } - if err := tpl.Execute(&b, m.items[m.matches[i]]); err != nil { + if err := tpl.Execute(&b, templateData(m.items[m.matches[i]])); err != nil { fmt.Fprintf(&b, "[template error: %v]", err) } b.WriteString("\n") diff --git a/libs/cmdio/template_data.go b/libs/cmdio/template_data.go new file mode 100644 index 00000000000..ccc5e6c3130 --- /dev/null +++ b/libs/cmdio/template_data.go @@ -0,0 +1,210 @@ +package cmdio + +import ( + "reflect" + "sync" +) + +// templateData returns a view of v for text/template in which pointers to +// scalars are replaced by the values they point to (zero values when nil). +// +// API types represent optional fields as pointers. Templates were written for +// value fields: text/template prints a nil pointer as "", treats a +// pointer to false or "" as true in {{if}}, and template functions taking an +// int64 reject an *int64. Structs (and slices and maps of them) containing +// such pointers are copied into equivalent struct types with value fields; +// types without them are passed through unchanged and keep their methods. +func templateData(v any) any { + if v == nil { + return nil + } + rv := reflect.ValueOf(v) + return viewValue(rv, viewType(rv.Type())).Interface() +} + +func isScalar(k reflect.Kind) bool { + switch k { + case reflect.String, reflect.Bool, + reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + reflect.Float32, reflect.Float64: + return true + default: + return false + } +} + +// structView describes the view of a struct type: the view type and, for +// each of its fields, the index path of the source field. Embedded structs +// are flattened into their parent so promoted fields stay accessible by name. +type structView struct { + typ reflect.Type + indexes [][]int +} + +var ( + viewTypes sync.Map // reflect.Type -> reflect.Type + structViews sync.Map // reflect.Type -> *structView +) + +func viewType(t reflect.Type) reflect.Type { + if cached, ok := viewTypes.Load(t); ok { + return cached.(reflect.Type) + } + // Store the type itself first so recursive types terminate. + viewTypes.Store(t, t) + vt := computeViewType(t) + viewTypes.Store(t, vt) + return vt +} + +func computeViewType(t reflect.Type) reflect.Type { + //nolint:exhaustive + switch t.Kind() { + case reflect.Pointer: + elem := t.Elem() + if isScalar(elem.Kind()) { + return elem + } + if ev := viewType(elem); ev != elem { + return reflect.PointerTo(ev) + } + case reflect.Struct: + if sv := buildStructView(t); sv != nil { + return sv.typ + } + case reflect.Slice: + if ev := viewType(t.Elem()); ev != t.Elem() { + return reflect.SliceOf(ev) + } + case reflect.Map: + if ev := viewType(t.Elem()); ev != t.Elem() { + return reflect.MapOf(t.Key(), ev) + } + } + return t +} + +// buildStructView returns the view of struct type t, or nil if no field of t +// (including promoted ones) needs a different type. +func buildStructView(t reflect.Type) *structView { + var fields []reflect.StructField + var indexes [][]int + seen := map[string]bool{} + changed := false + + var collect func(t reflect.Type, prefix []int) + collect = func(t reflect.Type, prefix []int) { + var embedded []reflect.StructField + for i := range t.NumField() { + f := t.Field(i) + index := append(append([]int{}, prefix...), i) + if f.Anonymous { + ft := f.Type + if ft.Kind() == reflect.Pointer { + ft = ft.Elem() + } + if ft.Kind() == reflect.Struct { + f.Index = index + embedded = append(embedded, f) + continue + } + } + if !f.IsExported() || seen[f.Name] { + continue + } + seen[f.Name] = true + ft := viewType(f.Type) + if ft != f.Type { + changed = true + } + fields = append(fields, reflect.StructField{Name: f.Name, Type: ft, Tag: f.Tag}) + indexes = append(indexes, index) + } + // Fields of embedded structs are promoted after the parent's own fields, + // which take precedence, as in Go. + for _, f := range embedded { + ft := f.Type + if ft.Kind() == reflect.Pointer { + ft = ft.Elem() + } + collect(ft, f.Index) + } + } + collect(t, nil) + + if !changed { + return nil + } + sv := &structView{typ: reflect.StructOf(fields), indexes: indexes} + structViews.Store(t, sv) + return sv +} + +func viewValue(v reflect.Value, vt reflect.Type) reflect.Value { + if v.Type() == vt { + return v + } + //nolint:exhaustive + switch v.Kind() { + case reflect.Pointer: + if vt.Kind() != reflect.Pointer { + // Pointer to scalar: dereference, or zero value when nil. + if v.IsNil() { + return reflect.Zero(vt) + } + return v.Elem() + } + if v.IsNil() { + return reflect.Zero(vt) + } + out := reflect.New(vt.Elem()) + out.Elem().Set(viewValue(v.Elem(), vt.Elem())) + return out + case reflect.Struct: + cached, _ := structViews.Load(v.Type()) + sv := cached.(*structView) + out := reflect.New(vt).Elem() + for i, index := range sv.indexes { + if src, ok := fieldByIndex(v, index); ok { + out.Field(i).Set(viewValue(src, vt.Field(i).Type)) + } + } + return out + case reflect.Slice: + if v.IsNil() { + return reflect.Zero(vt) + } + out := reflect.MakeSlice(vt, v.Len(), v.Len()) + for i := range v.Len() { + out.Index(i).Set(viewValue(v.Index(i), vt.Elem())) + } + return out + case reflect.Map: + if v.IsNil() { + return reflect.Zero(vt) + } + out := reflect.MakeMapWithSize(vt, v.Len()) + iter := v.MapRange() + for iter.Next() { + out.SetMapIndex(iter.Key(), viewValue(iter.Value(), vt.Elem())) + } + return out + } + return v +} + +// fieldByIndex is reflect.Value.FieldByIndex that reports false instead of +// panicking when it would step through a nil embedded pointer. +func fieldByIndex(v reflect.Value, index []int) (reflect.Value, bool) { + for i, x := range index { + if i > 0 && v.Kind() == reflect.Pointer { + if v.IsNil() { + return reflect.Value{}, false + } + v = v.Elem() + } + v = v.Field(x) + } + return v, true +} diff --git a/libs/cmdio/template_data_test.go b/libs/cmdio/template_data_test.go new file mode 100644 index 00000000000..a24c3224549 --- /dev/null +++ b/libs/cmdio/template_data_test.go @@ -0,0 +1,69 @@ +package cmdio + +import ( + "bytes" + "testing" + "text/template" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +type templateDataInner struct { + Name *string +} + +type templateDataBase struct { + Base *string +} + +type templateDataOuter struct { + templateDataBase + Flag *bool + Count *int64 + Unset *string + Inner *templateDataInner + Nested []templateDataInner + ByKey map[string]templateDataInner + Plain string +} + +func renderTemplateData(t *testing.T, tmpl string, data any) string { + t.Helper() + tt := template.Must(template.New("t").Funcs(template.FuncMap{ + "plus1": func(v int64) int64 { return v + 1 }, + }).Parse(tmpl)) + var buf bytes.Buffer + require.NoError(t, tt.Execute(&buf, templateData(data))) + return buf.String() +} + +func TestTemplateDataDereferencesScalars(t *testing.T) { + data := templateDataOuter{ + Base: new("base"), + Flag: new(false), + Count: new(int64(41)), + Inner: &templateDataInner{Name: new("in")}, + Nested: []templateDataInner{{Name: new("a")}, {}}, + ByKey: map[string]templateDataInner{"k": {Name: new("v")}}, + Plain: "p", + } + got := renderTemplateData(t, `{{if .Flag}}T{{else}}F{{end}} {{plus1 .Count}} [{{.Unset}}] {{.Inner.Name}} {{range .Nested}}<{{.Name}}>{{end}} {{(index .ByKey "k").Name}} {{.Plain}} {{.Base}}`, data) + assert.Equal(t, "F 42 [] in <> v p base", got) +} + +func TestTemplateDataNilStructPointerIsFalsy(t *testing.T) { + got := renderTemplateData(t, `{{if .Inner}}set{{else}}unset{{end}}`, &templateDataOuter{}) + assert.Equal(t, "unset", got) +} + +type templateDataWithMethod struct { + Name string +} + +func (v templateDataWithMethod) Upper() string { return "UP-" + v.Name } + +func TestTemplateDataKeepsTypesWithoutPointers(t *testing.T) { + got := renderTemplateData(t, `{{.Upper}}`, templateDataWithMethod{Name: "x"}) + assert.Equal(t, "UP-x", got) +} diff --git a/libs/databrickscfg/cfgpickers/clusters.go b/libs/databrickscfg/cfgpickers/clusters.go index 0c752f3a4b1..5280baf2ea0 100644 --- a/libs/databrickscfg/cfgpickers/clusters.go +++ b/libs/databrickscfg/cfgpickers/clusters.go @@ -4,13 +4,19 @@ import ( "context" "errors" "fmt" + "net/http" + "net/url" "regexp" "strings" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdkclients" + mirror "github.com/databricks/cli/libs/sdktypes/clusters/v2" + "github.com/databricks/cli/libs/utils" + compute "github.com/databricks/sdk-go/clusters/v2" + "github.com/databricks/sdk-go/scim/v1" "golang.org/x/mod/semver" ) @@ -25,20 +31,20 @@ func canonicalVersion(v string) string { return semver.Canonical("v" + strings.TrimPrefix(v, "v")) } -func GetRuntimeVersion(cluster compute.ClusterDetails) (string, bool) { +func GetRuntimeVersion(cluster compute.ClusterInfo) (string, bool) { // Snapshots are checked first: dbrVersionRegex now matches major-only versions // like "14.x-...", which would otherwise swallow "14.x-snapshot-..." here. - if match := dbrSnapshotVersionRegex.FindStringSubmatch(cluster.SparkVersion); len(match) > 1 { + if match := dbrSnapshotVersionRegex.FindStringSubmatch(utils.Deref(cluster.SparkVersion)); len(match) > 1 { // we return 14.999 for 14.x-snapshot for semver.Compare() to work properly return match[1] + ".999", true } - if match := dbrVersionRegex.FindStringSubmatch(cluster.SparkVersion); len(match) > 1 { + if match := dbrVersionRegex.FindStringSubmatch(utils.Deref(cluster.SparkVersion)); len(match) > 1 { return match[1], true } return "", false } -func IsCompatibleWithUC(cluster compute.ClusterDetails, minVersion string) bool { +func IsCompatibleWithUC(cluster compute.ClusterInfo, minVersion string) bool { minVersion = canonicalVersion(minVersion) if semver.Compare(minUcRuntime, minVersion) >= 0 { return false @@ -52,7 +58,7 @@ func IsCompatibleWithUC(cluster compute.ClusterDetails, minVersion string) bool return false } switch cluster.DataSecurityMode { - case compute.DataSecurityModeUserIsolation, compute.DataSecurityModeSingleUser: + case compute.DataSecurityMode_UserIsolation, compute.DataSecurityMode_SingleUser: return true default: return false @@ -62,7 +68,7 @@ func IsCompatibleWithUC(cluster compute.ClusterDetails, minVersion string) bool var ErrNoCompatibleClusters = errors.New("no compatible clusters found") type compatibleCluster struct { - compute.ClusterDetails + compute.ClusterInfo versionName string // renderedState caches the colorized ClusterDetails.State for display in // SelectOptions templates, which can't access ctx-bound color helpers. @@ -71,9 +77,9 @@ type compatibleCluster struct { func (v compatibleCluster) Access() string { switch v.DataSecurityMode { - case compute.DataSecurityModeUserIsolation: + case compute.DataSecurityMode_UserIsolation: return "Shared" - case compute.DataSecurityModeSingleUser: + case compute.DataSecurityMode_SingleUser: return "Assigned" default: return "Unknown" @@ -89,16 +95,23 @@ func (v compatibleCluster) State() string { return v.renderedState } -type clusterFilter func(cluster *compute.ClusterDetails, me *iam.User) bool +type clusterFilter func(cluster *Cluster, me *scim.User) bool // Filter function to check if a cluster is created through the UI or an API call. -func isUsableCluster(cluster *compute.ClusterDetails) bool { - return cluster.ClusterSource == compute.ClusterSourceUi || cluster.ClusterSource == compute.ClusterSourceApi +// Cluster is a cluster as listed for the picker. sdk-go does not model +// cluster_source, which the picker filters on, so it is carried separately. +type Cluster struct { + compute.ClusterInfo + Source string } -func WithDatabricksConnect(minVersion string) func(*compute.ClusterDetails, *iam.User) bool { - return func(cluster *compute.ClusterDetails, me *iam.User) bool { - if !IsCompatibleWithUC(*cluster, minVersion) { +func isUsableCluster(cluster *Cluster) bool { + return cluster.Source == "UI" || cluster.Source == "API" +} + +func WithDatabricksConnect(minVersion string) func(*Cluster, *scim.User) bool { + return func(cluster *Cluster, me *scim.User) bool { + if !IsCompatibleWithUC(cluster.ClusterInfo, minVersion) { return false } // Only clusters created through the UI or an API call are usable for DBConnect. @@ -106,7 +119,7 @@ func WithDatabricksConnect(minVersion string) func(*compute.ClusterDetails, *iam if !isUsableCluster(cluster) { return false } - if cluster.SingleUserName != "" && cluster.SingleUserName != me.UserName { + if utils.Deref(cluster.SingleUserName) != "" && utils.Deref(cluster.SingleUserName) != utils.Deref(me.UserName) { return false } return true @@ -115,42 +128,32 @@ func WithDatabricksConnect(minVersion string) func(*compute.ClusterDetails, *iam // WithoutSystemClusters removes clusters created for system purposes (e.g. job runs, pipeline maintenance, etc.). // It does this by keeping only clusters created through the UI or an API call. -func WithoutSystemClusters() func(*compute.ClusterDetails, *iam.User) bool { - return func(cluster *compute.ClusterDetails, me *iam.User) bool { +func WithoutSystemClusters() func(*Cluster, *scim.User) bool { + return func(cluster *Cluster, me *scim.User) bool { return isUsableCluster(cluster) } } -func loadInteractiveClusters(ctx context.Context, w *databricks.WorkspaceClient, filters []clusterFilter) ([]compatibleCluster, error) { +func loadInteractiveClusters(ctx context.Context, w *sdkclients.Clients, filters []clusterFilter) ([]compatibleCluster, error) { sp := cmdio.NewSpinner(ctx) sp.Update("Loading list of clusters to select from") defer sp.Close() - all, err := w.Clusters.ListAll(ctx, compute.ListClustersRequest{ - // Maximum page size to optimize for load time. - PageSize: 100, - - // Filter out system clusters. - FilterBy: &compute.ListClustersFilterBy{ - ClusterSources: []compute.ClusterSource{ - compute.ClusterSourceApi, - compute.ClusterSourceUi, - }, - }, - }) + // Filters out system clusters, with the maximum page size to optimize for load time. + all, err := listUserClusters(ctx, w) if err != nil { return nil, fmt.Errorf("list clusters: %w", err) } - me, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) + me, err := w.Scim.Me(ctx, scim.MeRequest{}) if err != nil { return nil, fmt.Errorf("current user: %w", err) } versions := map[string]string{} - sv, err := w.Clusters.SparkVersions(ctx) + sv, err := w.Clusters.ListSparkVersions(ctx, compute.GetSparkVersionsRequest{}) if err != nil { return nil, fmt.Errorf("list runtime versions: %w", err) } for _, v := range sv.Versions { - versions[v.Key] = v.Name + versions[utils.Deref(v.Key)] = utils.Deref(v.Name) } var compatible []compatibleCluster for _, cluster := range all { @@ -165,23 +168,23 @@ func loadInteractiveClusters(ctx context.Context, w *databricks.WorkspaceClient, } var renderedState string switch cluster.State { - case compute.StateRunning, compute.StateResizing: - renderedState = cmdio.Green(ctx, cluster.State.String()) - case compute.StateError, compute.StateTerminated, compute.StateTerminating, compute.StateUnknown: - renderedState = cmdio.Red(ctx, cluster.State.String()) + case compute.ClusterState_ClusterState_Running, compute.ClusterState_ClusterState_Resizing: + renderedState = cmdio.Green(ctx, string(cluster.State)) + case compute.ClusterState_ClusterState_Error, compute.ClusterState_ClusterState_Terminated, compute.ClusterState_ClusterState_Terminating, compute.ClusterState_ClusterState_Unknown: + renderedState = cmdio.Red(ctx, string(cluster.State)) default: - renderedState = cmdio.Blue(ctx, cluster.State.String()) + renderedState = cmdio.Blue(ctx, string(cluster.State)) } compatible = append(compatible, compatibleCluster{ - ClusterDetails: cluster, - versionName: versions[cluster.SparkVersion], - renderedState: renderedState, + ClusterInfo: cluster.ClusterInfo, + versionName: versions[utils.Deref(cluster.SparkVersion)], + renderedState: renderedState, }) } return compatible, nil } -func AskForCluster(ctx context.Context, w *databricks.WorkspaceClient, filters ...clusterFilter) (string, error) { +func AskForCluster(ctx context.Context, w *sdkclients.Clients, filters ...clusterFilter) (string, error) { compatible, err := loadInteractiveClusters(ctx, w, filters) if err != nil { return "", fmt.Errorf("load: %w", err) @@ -190,13 +193,13 @@ func AskForCluster(ctx context.Context, w *databricks.WorkspaceClient, filters . return "", ErrNoCompatibleClusters } if len(compatible) == 1 { - return compatible[0].ClusterId, nil + return utils.Deref(compatible[0].ClusterId), nil } i, err := cmdio.RunSelect(ctx, cmdio.SelectOptions{ Label: "Choose compatible cluster", Items: compatible, Searcher: func(input string, idx int) bool { - lower := strings.ToLower(compatible[idx].ClusterName) + lower := strings.ToLower(utils.Deref(compatible[idx].ClusterName)) return strings.Contains(lower, strings.ToLower(input)) }, StartInSearchMode: true, @@ -208,5 +211,49 @@ func AskForCluster(ctx context.Context, w *databricks.WorkspaceClient, filters . if err != nil { return "", err } - return compatible[i].ClusterId, nil + return utils.Deref(compatible[i].ClusterId), nil +} + +// listUserClusters lists clusters created through the UI or API. It is a raw +// call because sdk-go models neither the filter_by request parameter nor the +// cluster_source response field. +func listUserClusters(ctx context.Context, w *sdkclients.Clients) ([]Cluster, error) { + api, err := apiclient.New(w.Config) + if err != nil { + return nil, err + } + type listedCluster struct { + mirror.ClusterInfo + ClusterSource string `json:"cluster_source,omitempty"` + } + var all []Cluster + pageToken := "" + for { + query := url.Values{ + "filter_by.cluster_sources": {"API", "UI"}, + "page_size": {"100"}, + } + if pageToken != "" { + query.Set("page_token", pageToken) + } + var resp struct { + Clusters []listedCluster `json:"clusters"` + NextPageToken string `json:"next_page_token"` + } + err := api.Do(ctx, http.MethodGet, "/api/2.1/clusters/list?"+query.Encode(), auth.WorkspaceIDHeaders(w.Config), nil, nil, &resp) + if err != nil { + return nil, err + } + for i := range resp.Clusters { + info, err := mirror.ClusterInfoToSDK(&resp.Clusters[i].ClusterInfo) + if err != nil { + return nil, err + } + all = append(all, Cluster{ClusterInfo: *info, Source: resp.Clusters[i].ClusterSource}) + } + if resp.NextPageToken == "" { + return all, nil + } + pageToken = resp.NextPageToken + } } diff --git a/libs/databrickscfg/cfgpickers/clusters_test.go b/libs/databrickscfg/cfgpickers/clusters_test.go index 1c462eace05..d31d2f3ac5b 100644 --- a/libs/databrickscfg/cfgpickers/clusters_test.go +++ b/libs/databrickscfg/cfgpickers/clusters_test.go @@ -4,34 +4,33 @@ import ( "testing" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/qa" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/httpfixtures" + "github.com/databricks/cli/libs/sdkclients" + compute "github.com/databricks/sdk-go/clusters/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestIsCompatible(t *testing.T) { - require.True(t, IsCompatibleWithUC(compute.ClusterDetails{ - SparkVersion: "13.2.x-aarch64-scala2.12", - DataSecurityMode: compute.DataSecurityModeUserIsolation, + require.True(t, IsCompatibleWithUC(compute.ClusterInfo{ + SparkVersion: new("13.2.x-aarch64-scala2.12"), + DataSecurityMode: compute.DataSecurityMode_UserIsolation, }, "13.0")) - require.False(t, IsCompatibleWithUC(compute.ClusterDetails{ - SparkVersion: "13.2.x-aarch64-scala2.12", - DataSecurityMode: compute.DataSecurityModeNone, + require.False(t, IsCompatibleWithUC(compute.ClusterInfo{ + SparkVersion: new("13.2.x-aarch64-scala2.12"), + DataSecurityMode: compute.DataSecurityMode_None, }, "13.0")) - require.False(t, IsCompatibleWithUC(compute.ClusterDetails{ - SparkVersion: "9.1.x-photon-scala2.12", - DataSecurityMode: compute.DataSecurityModeNone, + require.False(t, IsCompatibleWithUC(compute.ClusterInfo{ + SparkVersion: new("9.1.x-photon-scala2.12"), + DataSecurityMode: compute.DataSecurityMode_None, }, "13.0")) - require.False(t, IsCompatibleWithUC(compute.ClusterDetails{ - SparkVersion: "9.1.x-photon-scala2.12", - DataSecurityMode: compute.DataSecurityModeNone, + require.False(t, IsCompatibleWithUC(compute.ClusterInfo{ + SparkVersion: new("9.1.x-photon-scala2.12"), + DataSecurityMode: compute.DataSecurityMode_None, }, "10.0")) - require.False(t, IsCompatibleWithUC(compute.ClusterDetails{ - SparkVersion: "custom-9.1.x-photon-scala2.12", - DataSecurityMode: compute.DataSecurityModeNone, + require.False(t, IsCompatibleWithUC(compute.ClusterInfo{ + SparkVersion: new("custom-9.1.x-photon-scala2.12"), + DataSecurityMode: compute.DataSecurityMode_None, }, "14.0")) } @@ -48,23 +47,23 @@ func TestGetRuntimeVersion(t *testing.T) { {"custom-9.1.x-photon-scala2.12", "", false}, } for _, tc := range tests { - got, ok := GetRuntimeVersion(compute.ClusterDetails{SparkVersion: tc.sparkVersion}) + got, ok := GetRuntimeVersion(compute.ClusterInfo{SparkVersion: new(tc.sparkVersion)}) assert.Equal(t, tc.wantOk, ok, tc.sparkVersion) assert.Equal(t, tc.want, got, tc.sparkVersion) } } func TestIsCompatibleWithMajorOnlyVersion(t *testing.T) { - require.True(t, IsCompatibleWithUC(compute.ClusterDetails{ - SparkVersion: "19.x-scala2.13", - DataSecurityMode: compute.DataSecurityModeUserIsolation, + require.True(t, IsCompatibleWithUC(compute.ClusterInfo{ + SparkVersion: new("19.x-scala2.13"), + DataSecurityMode: compute.DataSecurityMode_UserIsolation, }, "13.0")) } func TestIsCompatibleWithSnapshots(t *testing.T) { - require.True(t, IsCompatibleWithUC(compute.ClusterDetails{ - SparkVersion: "14.x-snapshot-cpu-ml-scala2.12", - DataSecurityMode: compute.DataSecurityModeUserIsolation, + require.True(t, IsCompatibleWithUC(compute.ClusterInfo{ + SparkVersion: new("14.x-snapshot-cpu-ml-scala2.12"), + DataSecurityMode: compute.DataSecurityMode_UserIsolation, }, "14.0")) } @@ -77,7 +76,7 @@ func TestWithoutSystemClusters(t *testing.T) { "PIPELINE", "SOME_UNKNOWN_VALUE", } { - assert.False(t, fn(&compute.ClusterDetails{ClusterSource: compute.ClusterSource(v)}, nil)) + assert.False(t, fn(&Cluster{Source: v}, nil)) } // Sources to include. @@ -85,59 +84,27 @@ func TestWithoutSystemClusters(t *testing.T) { "UI", "API", } { - assert.True(t, fn(&compute.ClusterDetails{ClusterSource: compute.ClusterSource(v)}, nil)) + assert.True(t, fn(&Cluster{Source: v}, nil)) + } +} + +const clustersListResource = "/api/2.1/clusters/list?filter_by.cluster_sources=API&filter_by.cluster_sources=UI&page_size=100" + +func clusterFixtures(clustersJSON string) httpfixtures.Fixtures { + return httpfixtures.Fixtures{ + {Method: "GET", Resource: clustersListResource, Response: `{"clusters":` + clustersJSON + `}`}, + {Method: "GET", Resource: "/api/2.0/preview/scim/v2/Me", Response: `{"userName":"serge"}`}, + {Method: "GET", Resource: "/api/2.1/clusters/spark-versions", Response: `{"versions":[{"key":"14.5.x-whatever","name":"14.5 (Awesome)"}]}`}, } } func TestFirstCompatibleCluster(t *testing.T) { - cfg, server := qa.HTTPFixtures{ - { - Method: "GET", - Resource: "/api/2.1/clusters/list?filter_by.cluster_sources=API&filter_by.cluster_sources=UI&page_size=100", - Response: compute.ListClustersResponse{ - Clusters: []compute.ClusterDetails{ - { - ClusterId: "abc-id", - ClusterName: "first shared", - ClusterSource: compute.ClusterSourceApi, - DataSecurityMode: compute.DataSecurityModeUserIsolation, - SparkVersion: "12.2.x-whatever", - State: compute.StateRunning, - }, - { - ClusterId: "bcd-id", - ClusterName: "second personal", - ClusterSource: compute.ClusterSourceUi, - DataSecurityMode: compute.DataSecurityModeSingleUser, - SparkVersion: "14.5.x-whatever", - State: compute.StateRunning, - SingleUserName: "serge", - }, - }, - }, - }, - { - Method: "GET", - Resource: "/api/2.0/preview/scim/v2/Me?", - Response: iam.User{ - UserName: "serge", - }, - }, - { - Method: "GET", - Resource: "/api/2.1/clusters/spark-versions", - Response: compute.GetSparkVersionsResponse{ - Versions: []compute.SparkVersion{ - { - Key: "14.5.x-whatever", - Name: "14.5 (Awesome)", - }, - }, - }, - }, - }.Config(t) - defer server.Close() - w := databricks.Must(databricks.NewWorkspaceClient((*databricks.Config)(cfg))) + cfg, _ := clusterFixtures(`[ + {"cluster_id":"abc-id","cluster_name":"first shared","cluster_source":"API","data_security_mode":"USER_ISOLATION","spark_version":"12.2.x-whatever","state":"RUNNING"}, + {"cluster_id":"bcd-id","cluster_name":"second personal","cluster_source":"UI","data_security_mode":"SINGLE_USER","spark_version":"14.5.x-whatever","state":"RUNNING","single_user_name":"serge"} + ]`).Config(t) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) ctx := cmdio.MockDiscard(t.Context()) @@ -147,46 +114,13 @@ func TestFirstCompatibleCluster(t *testing.T) { } func TestNoCompatibleClusters(t *testing.T) { - cfg, server := qa.HTTPFixtures{ - { - Method: "GET", - Resource: "/api/2.1/clusters/list?filter_by.cluster_sources=API&filter_by.cluster_sources=UI&page_size=100", - Response: compute.ListClustersResponse{ - Clusters: []compute.ClusterDetails{ - { - ClusterId: "abc-id", - ClusterName: "first shared", - DataSecurityMode: compute.DataSecurityModeUserIsolation, - SparkVersion: "12.2.x-whatever", - State: compute.StateRunning, - }, - }, - }, - }, - { - Method: "GET", - Resource: "/api/2.0/preview/scim/v2/Me?", - Response: iam.User{ - UserName: "serge", - }, - }, - { - Method: "GET", - Resource: "/api/2.1/clusters/spark-versions", - Response: compute.GetSparkVersionsResponse{ - Versions: []compute.SparkVersion{ - { - Key: "14.5.x-whatever", - Name: "14.5 (Awesome)", - }, - }, - }, - }, - }.Config(t) - defer server.Close() - w := databricks.Must(databricks.NewWorkspaceClient((*databricks.Config)(cfg))) + cfg, _ := clusterFixtures(`[ + {"cluster_id":"abc-id","cluster_name":"first shared","data_security_mode":"USER_ISOLATION","spark_version":"12.2.x-whatever","state":"RUNNING"} + ]`).Config(t) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) ctx := cmdio.MockDiscard(t.Context()) - _, err := AskForCluster(ctx, w, WithDatabricksConnect("13.1")) + _, err = AskForCluster(ctx, w, WithDatabricksConnect("13.1")) require.Equal(t, ErrNoCompatibleClusters, err) } diff --git a/libs/databrickscfg/cfgpickers/warehouses.go b/libs/databrickscfg/cfgpickers/warehouses.go index 67bdcb7f73a..718d6d75314 100644 --- a/libs/databrickscfg/cfgpickers/warehouses.go +++ b/libs/databrickscfg/cfgpickers/warehouses.go @@ -8,21 +8,22 @@ import ( "slices" "strings" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/httpclient" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/sdkclients" + mirror "github.com/databricks/cli/libs/sdktypes/warehouses/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/apierr" + sql "github.com/databricks/sdk-go/warehouses/v1" ) var ErrNoCompatibleWarehouses = errors.New("no compatible warehouses") type warehouseFilter func(sql.EndpointInfo) bool -func WithWarehouseTypes(types ...sql.EndpointInfoWarehouseType) func(sql.EndpointInfo) bool { - allowed := map[sql.EndpointInfoWarehouseType]bool{} +func WithWarehouseTypes(types ...sql.WarehouseType) func(sql.EndpointInfo) bool { + allowed := map[sql.WarehouseType]bool{} for _, v := range types { allowed[v] = true } @@ -31,8 +32,8 @@ func WithWarehouseTypes(types ...sql.EndpointInfoWarehouseType) func(sql.Endpoin } } -func AskForWarehouse(ctx context.Context, w *databricks.WorkspaceClient, filters ...warehouseFilter) (string, error) { - all, err := w.Warehouses.ListAll(ctx, sql.ListWarehousesRequest{}) +func AskForWarehouse(ctx context.Context, w *sdkclients.Clients, filters ...warehouseFilter) (string, error) { + all, err := listAllWarehouses(ctx, w) if err != nil { return "", fmt.Errorf("list warehouses: %w", err) } @@ -50,16 +51,16 @@ func AskForWarehouse(ctx context.Context, w *databricks.WorkspaceClient, filters } var state string switch warehouse.State { - case sql.StateRunning: - state = cmdio.Green(ctx, warehouse.State.String()) - case sql.StateStopped, sql.StateDeleted, sql.StateStopping, sql.StateDeleting: - state = cmdio.Red(ctx, warehouse.State.String()) + case sql.EndpointState_Running: + state = cmdio.Green(ctx, string(warehouse.State)) + case sql.EndpointState_Stopped, sql.EndpointState_Deleted, sql.EndpointState_Stopping, sql.EndpointState_Deleting: + state = cmdio.Red(ctx, string(warehouse.State)) default: - state = cmdio.Blue(ctx, warehouse.State.String()) + state = cmdio.Blue(ctx, string(warehouse.State)) } - visibleTouser := fmt.Sprintf("%s (%s %s)", warehouse.Name, state, warehouse.WarehouseType) - names[visibleTouser] = warehouse.Id - lastWarehouseID = warehouse.Id + visibleTouser := fmt.Sprintf("%s (%s %s)", utils.Deref(warehouse.Name), state, warehouse.WarehouseType) + names[visibleTouser] = utils.Deref(warehouse.Id) + lastWarehouseID = utils.Deref(warehouse.Id) } if len(names) == 0 { return "", ErrNoCompatibleWarehouses @@ -75,22 +76,22 @@ func AskForWarehouse(ctx context.Context, w *databricks.WorkspaceClient, filters func sortWarehousesByState(all []sql.EndpointInfo) []sql.EndpointInfo { var warehouses []sql.EndpointInfo for _, wh := range all { - if wh.State != sql.StateDeleted && wh.State != sql.StateDeleting { + if wh.State != sql.EndpointState_Deleted && wh.State != sql.EndpointState_Deleting { warehouses = append(warehouses, wh) } } - priorities := map[sql.State]int{ - sql.StateRunning: 1, - sql.StateStarting: 2, - sql.StateStopped: 3, - sql.StateStopping: 4, + priorities := map[sql.EndpointState]int{ + sql.EndpointState_Running: 1, + sql.EndpointState_Starting: 2, + sql.EndpointState_Stopped: 3, + sql.EndpointState_Stopping: 4, } slices.SortFunc(warehouses, func(a, b sql.EndpointInfo) int { if n := cmp.Compare(priorities[a.State], priorities[b.State]); n != 0 { return n } - return cmp.Compare(strings.ToLower(a.Name), strings.ToLower(b.Name)) + return cmp.Compare(strings.ToLower(utils.Deref(a.Name)), strings.ToLower(utils.Deref(b.Name))) }) return warehouses @@ -100,10 +101,10 @@ func sortWarehousesByState(all []sql.EndpointInfo) []sql.EndpointInfo { // It tries the following in order: // 1. The "default" warehouse via API (server-side convention, not yet fully rolled out) // 2. The first usable warehouse sorted by state (running first) -func GetDefaultWarehouse(ctx context.Context, w *databricks.WorkspaceClient) (*sql.EndpointInfo, error) { +func GetDefaultWarehouse(ctx context.Context, w *sdkclients.Clients) (*sql.EndpointInfo, error) { // Try the "default" warehouse convention first // This is a new server-side feature that may not be available everywhere yet - warehouse, err := w.Warehouses.Get(ctx, sql.GetWarehouseRequest{Id: "default"}) + warehouse, err := w.Warehouses.GetWarehouse(ctx, sql.GetWarehouseRequest{Id: new("default")}) if err == nil { return &sql.EndpointInfo{ Id: warehouse.Id, @@ -112,7 +113,7 @@ func GetDefaultWarehouse(ctx context.Context, w *databricks.WorkspaceClient) (*s }, nil } apiErr, ok := errors.AsType[*apierr.APIError](err) - if !ok || apiErr.StatusCode >= 500 { + if !ok || apiErr.HTTPStatusCode() >= 500 { return nil, fmt.Errorf("get default warehouse: %w", err) } @@ -129,32 +130,31 @@ func GetDefaultWarehouse(ctx context.Context, w *databricks.WorkspaceClient) (*s // listUsableWarehouses returns warehouses the user has permission to use. // This uses the skip_cannot_use=true parameter to filter out inaccessible warehouses. -func listUsableWarehouses(ctx context.Context, w *databricks.WorkspaceClient) ([]sql.EndpointInfo, error) { +func listUsableWarehouses(ctx context.Context, w *sdkclients.Clients) ([]sql.EndpointInfo, error) { // The SDK doesn't expose skip_cannot_use parameter, so we use the raw API - clientCfg, err := config.HTTPClientConfigFromConfig(w.Config) + apiClient, err := apiclient.New(w.Config) if err != nil { - return nil, fmt.Errorf("create HTTP client config: %w", err) + return nil, fmt.Errorf("create API client: %w", err) } - apiClient := httpclient.NewApiClient(clientCfg) - var response sql.ListWarehousesResponse - opts := []httpclient.DoOption{httpclient.WithResponseUnmarshal(&response)} - for name, value := range auth.WorkspaceIDHeaders(w.Config) { - opts = append(opts, httpclient.WithRequestHeader(name, value)) + var response mirror.ListWarehousesResponse + err = apiClient.Do(ctx, "GET", "/api/2.0/sql/warehouses?skip_cannot_use=true", auth.WorkspaceIDHeaders(w.Config), nil, nil, &response) + if err != nil { + return nil, fmt.Errorf("list warehouses: %w", err) } - err = apiClient.Do(ctx, "GET", "/api/2.0/sql/warehouses?skip_cannot_use=true", opts...) + converted, err := mirror.ListWarehousesResponseToSDK(&response) if err != nil { return nil, fmt.Errorf("list warehouses: %w", err) } - return response.Warehouses, nil + return converted.Warehouses, nil } // SelectWarehouse prompts the user to select a SQL warehouse and returns the warehouse ID. // Warehouses are sorted by state (running first) so the default selection is the best available. // In non-interactive mode, returns the first (best) warehouse automatically. // The description parameter is shown before the picker (if non-empty). -func SelectWarehouse(ctx context.Context, w *databricks.WorkspaceClient, description string, filters ...warehouseFilter) (string, error) { - all, err := w.Warehouses.ListAll(ctx, sql.ListWarehousesRequest{}) +func SelectWarehouse(ctx context.Context, w *sdkclients.Clients, description string, filters ...warehouseFilter) (string, error) { + all, err := listAllWarehouses(ctx, w) if err != nil { return "", fmt.Errorf("list warehouses: %w", err) } @@ -182,30 +182,30 @@ func SelectWarehouse(ctx context.Context, w *databricks.WorkspaceClient, descrip } if len(warehouses) == 1 || !cmdio.IsPromptSupported(ctx) { - return warehouses[0].Id, nil + return utils.Deref(warehouses[0].Id), nil } // The first warehouse (sorted by state, then alphabetically) is the default - defaultId := warehouses[0].Id + defaultId := utils.Deref(warehouses[0].Id) // Sort by running state first, then alphabetically for display slices.SortFunc(warehouses, func(a, b sql.EndpointInfo) int { - aRunning := a.State == sql.StateRunning - bRunning := b.State == sql.StateRunning + aRunning := a.State == sql.EndpointState_Running + bRunning := b.State == sql.EndpointState_Running if aRunning != bRunning { if aRunning { return -1 } return 1 } - return cmp.Compare(strings.ToLower(a.Name), strings.ToLower(b.Name)) + return cmp.Compare(strings.ToLower(utils.Deref(a.Name)), strings.ToLower(utils.Deref(b.Name))) }) // Build options for the picker (● = running, ○ = not running) var items []cmdio.Tuple for _, warehouse := range warehouses { var icon string - if warehouse.State == sql.StateRunning { + if warehouse.State == sql.EndpointState_Running { icon = cmdio.Green(ctx, "●") } else { icon = cmdio.HiBlack(ctx, "○") @@ -213,15 +213,15 @@ func SelectWarehouse(ctx context.Context, w *databricks.WorkspaceClient, descrip // Show type info in gray typeInfo := strings.ToLower(string(warehouse.WarehouseType)) - if warehouse.EnableServerlessCompute { + if utils.Deref(warehouse.EnableServerlessCompute) { typeInfo = "serverless" } - name := fmt.Sprintf("%s %s %s", icon, warehouse.Name, cmdio.HiBlack(ctx, typeInfo)) - if warehouse.Id == defaultId { + name := fmt.Sprintf("%s %s %s", icon, utils.Deref(warehouse.Name), cmdio.HiBlack(ctx, typeInfo)) + if utils.Deref(warehouse.Id) == defaultId { name += cmdio.HiBlack(ctx, " [DEFAULT]") } - items = append(items, cmdio.Tuple{Name: name, Id: warehouse.Id}) + items = append(items, cmdio.Tuple{Name: name, Id: utils.Deref(warehouse.Id)}) } if description != "" { @@ -233,11 +233,22 @@ func SelectWarehouse(ctx context.Context, w *databricks.WorkspaceClient, descrip } for _, wh := range warehouses { - if wh.Id == warehouseId { - cmdio.LogString(ctx, fmt.Sprintf("warehouse_id: %s (%s)", warehouseId, wh.Name)) + if utils.Deref(wh.Id) == warehouseId { + cmdio.LogString(ctx, fmt.Sprintf("warehouse_id: %s (%s)", warehouseId, utils.Deref(wh.Name))) break } } return warehouseId, nil } + +func listAllWarehouses(ctx context.Context, w *sdkclients.Clients) ([]sql.EndpointInfo, error) { + var all []sql.EndpointInfo + for wh, err := range w.Warehouses.ListWarehousesIter(ctx, sql.ListWarehousesRequest{}) { + if err != nil { + return nil, err + } + all = append(all, *wh) + } + return all, nil +} diff --git a/libs/databrickscfg/cfgpickers/warehouses_test.go b/libs/databrickscfg/cfgpickers/warehouses_test.go index 818c8f6a81a..294c576d907 100644 --- a/libs/databrickscfg/cfgpickers/warehouses_test.go +++ b/libs/databrickscfg/cfgpickers/warehouses_test.go @@ -4,63 +4,42 @@ import ( "testing" "github.com/databricks/cli/libs/cmdio" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/qa" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/httpfixtures" + "github.com/databricks/cli/libs/sdkclients" + sql "github.com/databricks/sdk-go/warehouses/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestFirstCompatibleWarehouse(t *testing.T) { - cfg, server := qa.HTTPFixtures{ + cfg, _ := httpfixtures.Fixtures{ { Method: "GET", - Resource: "/api/2.0/sql/warehouses?", - Response: sql.ListWarehousesResponse{ - Warehouses: []sql.EndpointInfo{ - { - Id: "efg-id", - Name: "First PRO Warehouse", - WarehouseType: sql.EndpointInfoWarehouseTypePro, - }, - { - Id: "ghe-id", - Name: "Second UNKNOWN Warehouse", - WarehouseType: sql.EndpointInfoWarehouseTypeTypeUnspecified, - }, - }, - }, + Resource: "/api/2.0/sql/warehouses", + Response: `{"warehouses":[{"id":"efg-id","name":"First PRO Warehouse","warehouse_type":"PRO"},{"id":"ghe-id","name":"Second UNKNOWN Warehouse","warehouse_type":"TYPE_UNSPECIFIED"}]}`, }, }.Config(t) - defer server.Close() - w := databricks.Must(databricks.NewWorkspaceClient((*databricks.Config)(cfg))) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) ctx := cmdio.MockDiscard(t.Context()) - clusterID, err := AskForWarehouse(ctx, w, WithWarehouseTypes(sql.EndpointInfoWarehouseTypePro)) + clusterID, err := AskForWarehouse(ctx, w, WithWarehouseTypes(sql.WarehouseType_Pro)) require.NoError(t, err) assert.Equal(t, "efg-id", clusterID) } func TestNoCompatibleWarehouses(t *testing.T) { - cfg, server := qa.HTTPFixtures{ + cfg, _ := httpfixtures.Fixtures{ { Method: "GET", - Resource: "/api/2.0/sql/warehouses?", - Response: sql.ListWarehousesResponse{ - Warehouses: []sql.EndpointInfo{ - { - Id: "efg-id", - Name: "...", - WarehouseType: sql.EndpointInfoWarehouseTypeClassic, - }, - }, - }, + Resource: "/api/2.0/sql/warehouses", + Response: `{"warehouses":[{"id":"efg-id","name":"...","warehouse_type":"CLASSIC"}]}`, }, }.Config(t) - defer server.Close() - w := databricks.Must(databricks.NewWorkspaceClient((*databricks.Config)(cfg))) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) ctx := cmdio.MockDiscard(t.Context()) - _, err := AskForWarehouse(ctx, w, WithWarehouseTypes(sql.EndpointInfoWarehouseTypePro)) + _, err = AskForWarehouse(ctx, w, WithWarehouseTypes(sql.WarehouseType_Pro)) assert.Equal(t, ErrNoCompatibleWarehouses, err) } diff --git a/libs/dbfs/dbfs.go b/libs/dbfs/dbfs.go new file mode 100644 index 00000000000..1bdb0edeb74 --- /dev/null +++ b/libs/dbfs/dbfs.go @@ -0,0 +1,214 @@ +// Package dbfs provides streaming file handles over the DBFS API, built on the +// sdk-go files client. It ports the handle helpers of the previous SDK +// (DbfsAPI.Open, ReadFile, WriteFile), which sdk-go lacks. +package dbfs + +import ( + "bufio" + "context" + "errors" + "fmt" + "io" + + "github.com/databricks/cli/libs/utils" + files "github.com/databricks/sdk-go/files/v2" +) + +// FileMode conveys user intent when opening a file. +type FileMode int + +const ( + // Exactly one of FileModeRead or FileModeWrite must be specified. + FileModeRead FileMode = 1 << iota + FileModeWrite + FileModeOverwrite +) + +// Maximum read or write length for the DBFS API. +const maxBlockSize = 1024 * 1024 + +// Handle is returned by [Open]. +type Handle interface { + io.ReadWriteCloser + io.WriterTo + io.ReaderFrom +} + +type reader struct { + size int64 + offset int64 +} + +type writer struct { + handle int64 +} + +type handle struct { + ctx context.Context + api *files.Client + path string + reader *reader + writer *writer +} + +func (h *handle) errorf(format string, a ...any) error { + return fmt.Errorf("dbfs %s: %s", h.path, fmt.Sprintf(format, a...)) +} + +func (h *handle) wrap(err error) error { + if err == nil { + return nil + } + return fmt.Errorf("dbfs %s: %w", h.path, err) +} + +func (h *handle) Read(p []byte) (int, error) { + r := h.reader + if r == nil { + return 0, errors.New("dbfs: file not open for reading") + } + var ntotal int + for ntotal < len(p) { + if r.offset >= r.size { + return ntotal, io.EOF + } + chunk := p[ntotal:] + if len(chunk) > maxBlockSize { + chunk = chunk[:maxBlockSize] + } + res, err := h.api.Read(h.ctx, files.ReadRequest{ + Path: new(h.path), + Length: new(int64(len(chunk))), + Offset: new(r.offset), + }) + if err != nil { + return ntotal, h.wrap(err) + } + // Reading past the size checked above means the file was modified or + // truncated concurrently; the contents would be corrupted. + if utils.Deref(res.BytesRead) == 0 { + return ntotal, h.errorf("unexpected EOF at offset %d (size %d)", r.offset, r.size) + } + n := copy(chunk, res.Data) + ntotal += n + r.offset += int64(n) + } + return ntotal, nil +} + +func (h *handle) Write(p []byte) (int, error) { + w := h.writer + if w == nil { + return 0, errors.New("dbfs: file not open for writing") + } + var ntotal int + for ntotal < len(p) { + chunk := p[ntotal:] + if len(chunk) > maxBlockSize { + chunk = chunk[:maxBlockSize] + } + _, err := h.api.AddBlock(h.ctx, files.AddBlockRequest{ + Handle: new(w.handle), + Data: chunk, + }) + if err != nil { + return ntotal, h.wrap(err) + } + ntotal += len(chunk) + } + return ntotal, nil +} + +func (h *handle) Close() error { + w := h.writer + if w == nil { + return errors.New("dbfs: file not open for writing") + } + _, err := h.api.Close(h.ctx, files.CloseRequest{Handle: new(w.handle)}) + return h.wrap(err) +} + +// WriteTo maximizes throughput by reading in chunks of the DBFS maximum size. +func (h *handle) WriteTo(w io.Writer) (int64, error) { + if h.reader == nil { + return 0, errors.New("dbfs: file not open for reading") + } + // Plain io.Reader/io.Writer wrappers avoid recursing into WriteTo/ReadFrom. + ior := struct{ io.Reader }{h} + iow := struct{ io.Writer }{w} + return bufio.NewReaderSize(ior, maxBlockSize).WriteTo(iow) +} + +// ReadFrom maximizes throughput by writing in chunks of the DBFS maximum size. +func (h *handle) ReadFrom(r io.Reader) (int64, error) { + if h.writer == nil { + return 0, errors.New("dbfs: file not open for writing") + } + ior := struct{ io.Reader }{r} + iow := struct{ io.Writer }{h} + bw := bufio.NewWriterSize(iow, maxBlockSize) + n, err := bw.ReadFrom(ior) + if err != nil { + return n, err + } + return n, bw.Flush() +} + +// Open opens a remote DBFS file for reading or writing. A file opened for +// writing must always be closed. +func Open(ctx context.Context, api *files.Client, path string, mode FileMode) (Handle, error) { + h := &handle{ctx: ctx, api: api, path: path} + isRead := mode&FileModeRead != 0 + isWrite := mode&FileModeWrite != 0 + if isRead == isWrite { + return nil, errors.New("dbfs open: must specify dbfs.FileModeRead or dbfs.FileModeWrite") + } + if isRead { + res, err := api.GetStatus(ctx, files.GetStatusRequest{Path: new(path)}) + if err != nil { + return nil, fmt.Errorf("dbfs open: %w", err) + } + if utils.Deref(res.IsDir) { + return nil, errors.New("dbfs open: cannot open directory for reading") + } + h.reader = &reader{size: utils.Deref(res.FileSize)} + } else { + res, err := api.Create(ctx, files.CreateRequest{ + Path: new(path), + Overwrite: new(mode&FileModeOverwrite != 0), + }) + if err != nil { + return nil, fmt.Errorf("dbfs open: %w", err) + } + h.writer = &writer{handle: utils.Deref(res.Handle)} + } + return h, nil +} + +// ReadFile is identical to [os.ReadFile] but for DBFS. +func ReadFile(ctx context.Context, api *files.Client, name string) ([]byte, error) { + h, err := Open(ctx, api, name, FileModeRead) + if err != nil { + return nil, err + } + buf := make([]byte, h.(*handle).reader.size) + _, err = h.Read(buf) + if err != nil && err != io.EOF { + return nil, err + } + return buf, nil +} + +// WriteFile is identical to [os.WriteFile] but for DBFS. +func WriteFile(ctx context.Context, api *files.Client, name string, data []byte) error { + h, err := Open(ctx, api, name, FileModeWrite|FileModeOverwrite) + if err != nil { + return err + } + _, err = h.Write(data) + cerr := h.Close() + if err == nil { + err = cerr + } + return err +} diff --git a/libs/dbfs/dbfs_test.go b/libs/dbfs/dbfs_test.go new file mode 100644 index 00000000000..74810d52d85 --- /dev/null +++ b/libs/dbfs/dbfs_test.go @@ -0,0 +1,84 @@ +package dbfs + +import ( + "bytes" + "encoding/json" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/databricks-sdk-go/config" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// fakeDBFS stores files written via create/add-block/close and serves reads. +type fakeDBFS struct { + files map[string][]byte + handles map[int64]string + next int64 +} + +func (f *fakeDBFS) ServeHTTP(w http.ResponseWriter, r *http.Request) { + var req map[string]any + if r.Method == http.MethodPost { + _ = json.NewDecoder(r.Body).Decode(&req) + } + q := r.URL.Query() + reply := func(v any) { _ = json.NewEncoder(w).Encode(v) } + switch r.URL.Path { + case "/api/2.0/dbfs/create": + f.next++ + f.handles[f.next] = req["path"].(string) + f.files[req["path"].(string)] = nil + reply(map[string]any{"handle": f.next}) + case "/api/2.0/dbfs/add-block": + var data []byte + _ = json.Unmarshal([]byte(`"`+req["data"].(string)+`"`), &data) + p := f.handles[int64(req["handle"].(float64))] + f.files[p] = append(f.files[p], data...) + reply(map[string]any{}) + case "/api/2.0/dbfs/close": + reply(map[string]any{}) + case "/api/2.0/dbfs/get-status": + data, ok := f.files[q.Get("path")] + if !ok { + w.WriteHeader(http.StatusNotFound) + reply(map[string]any{"error_code": "RESOURCE_DOES_NOT_EXIST", "message": "nope"}) + return + } + reply(map[string]any{"path": q.Get("path"), "file_size": len(data)}) + case "/api/2.0/dbfs/read": + data := f.files[q.Get("path")] + var off, n int + _ = json.Unmarshal([]byte(q.Get("offset")), &off) + _ = json.Unmarshal([]byte(q.Get("length")), &n) + chunk := data[min(off, len(data)):min(off+n, len(data))] + reply(map[string]any{"bytes_read": len(chunk), "data": chunk}) + default: + http.NotFound(w, r) + } +} + +func TestWriteReadRoundTrip(t *testing.T) { + fake := &fakeDBFS{files: map[string][]byte{}, handles: map[int64]string{}} + srv := httptest.NewServer(fake) + t.Cleanup(srv.Close) + ctx := t.Context() + c, err := sdkclients.New(ctx, &config.Config{Host: srv.URL, Token: "t", Loaders: []config.Loader{config.ConfigAttributes}}) + require.NoError(t, err) + + content := bytes.Repeat([]byte("abc"), maxBlockSize) + require.NoError(t, WriteFile(ctx, c.Files, "/tmp/x", content)) + assert.Equal(t, content, fake.files["/tmp/x"]) + + got, err := ReadFile(ctx, c.Files, "/tmp/x") + require.NoError(t, err) + assert.Equal(t, content, got) + + _, err = Open(ctx, c.Files, "/tmp/missing", FileModeRead) + require.Error(t, err) + assert.True(t, strings.HasPrefix(err.Error(), "dbfs open: ")) +} diff --git a/libs/diag/diagnostic.go b/libs/diag/diagnostic.go index 9356cc9ddd6..828ce38c5d0 100644 --- a/libs/diag/diagnostic.go +++ b/libs/diag/diagnostic.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/structs/structpath" ) @@ -62,7 +63,7 @@ func WarningFromErr(err error) Diagnostics { return []Diagnostic{ { Severity: Warning, - Summary: err.Error(), + Summary: apierrs.ErrorString(err), }, } } diff --git a/libs/diag/sdk_error.go b/libs/diag/sdk_error.go index d190498d6bf..080e1293096 100644 --- a/libs/diag/sdk_error.go +++ b/libs/diag/sdk_error.go @@ -3,19 +3,21 @@ package diag import ( "errors" "fmt" - "strconv" + "net/http" "strings" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/sdk-go/core/apierr" ) func FormatAPIErrorSummary(e error) string { apiErr, ok := errors.AsType[*apierr.APIError](e) if !ok { - return e.Error() + return apierrs.ErrorString(e) } - extra := strings.TrimSpace(fmt.Sprintf("%d %s", apiErr.StatusCode, apiErr.ErrorCode)) - return e.Error() + " (" + extra + ")" + extra := strings.TrimSpace(fmt.Sprintf("%d %s", apiErr.HTTPStatusCode(), apierrs.ErrorCode(apiErr))) + return apierrs.ErrorString(e) + " (" + extra + ")" } func FormatAPIErrorDetails(e error) string { @@ -25,20 +27,10 @@ func FormatAPIErrorDetails(e error) string { } endpoint := "n/a" - httpStatus := "" - w := apiErr.ResponseWrapper - if w != nil { - resp := w.Response - if resp != nil { - httpStatus = resp.Status - req := resp.Request - if req != nil { - endpoint = fmt.Sprintf("%s %s", req.Method, req.URL) - } - } + if method, u, ok := apiclient.RequestOf(apiErr); ok { + endpoint = fmt.Sprintf("%s %s", method, u) } - if len(httpStatus) == 0 { - httpStatus = strconv.Itoa(apiErr.StatusCode) - } - return fmt.Sprintf("Endpoint: %s\nHTTP Status: %s\nAPI error_code: %s\nAPI message: %s", endpoint, httpStatus, apiErr.ErrorCode, apiErr.Message) + status := apiErr.HTTPStatusCode() + httpStatus := fmt.Sprintf("%d %s", status, http.StatusText(status)) + return fmt.Sprintf("Endpoint: %s\nHTTP Status: %s\nAPI error_code: %s\nAPI message: %s", endpoint, strings.TrimSpace(httpStatus), apierrs.ErrorCode(apiErr), apiErr.Message()) } diff --git a/libs/diag/sdk_error_test.go b/libs/diag/sdk_error_test.go index 6b51714bf87..a142c9246eb 100644 --- a/libs/diag/sdk_error_test.go +++ b/libs/diag/sdk_error_test.go @@ -4,17 +4,16 @@ import ( "errors" "fmt" "net/http" - "net/url" "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/common" + "github.com/databricks/sdk-go/core/apierr" "github.com/stretchr/testify/assert" ) func TestFormatAPIError(t *testing.T) { - u, _ := url.Parse("https://example.com/api/2.0/foo") - request := &http.Request{Method: http.MethodPost, URL: u} + body := []byte(`{"error_code":"TEST_ERROR","message":"api error message"}`) + withRequest := http.Header{} + withRequest.Set("X-Databricks-Cli-Request", "POST https://example.test/api/2.0/foo") cases := []struct { name string @@ -29,50 +28,22 @@ func TestFormatAPIError(t *testing.T) { expectedDetails: "", }, { - name: "apierr no wrapper", - err: &apierr.APIError{ - Message: "api error message", - ErrorCode: "TEST_ERROR", - StatusCode: 400, - }, - expectedSummary: "api error message (400 TEST_ERROR)", - expectedDetails: "Endpoint: n/a\nHTTP Status: 400\nAPI error_code: TEST_ERROR\nAPI message: api error message", - }, - { - name: "apierr with Response only", - err: &apierr.APIError{ - Message: "api error message", - ErrorCode: "TEST_ERROR", - StatusCode: 400, - ResponseWrapper: &common.ResponseWrapper{ - Response: &http.Response{Status: "400 Bad Request"}, - }, - }, + name: "apierr without request", + err: apierr.FromHTTPError(400, nil, body), expectedSummary: "api error message (400 TEST_ERROR)", expectedDetails: "Endpoint: n/a\nHTTP Status: 400 Bad Request\nAPI error_code: TEST_ERROR\nAPI message: api error message", }, { - name: "apierr with full Response+Request", - err: &apierr.APIError{ - Message: "api error message", - ErrorCode: "TEST_ERROR", - StatusCode: 400, - ResponseWrapper: &common.ResponseWrapper{ - Response: &http.Response{Status: "400 Bad Request", Request: request}, - }, - }, + name: "apierr with request", + err: apierr.FromHTTPError(400, withRequest, body), expectedSummary: "api error message (400 TEST_ERROR)", - expectedDetails: "Endpoint: POST https://example.com/api/2.0/foo\nHTTP Status: 400 Bad Request\nAPI error_code: TEST_ERROR\nAPI message: api error message", + expectedDetails: "Endpoint: POST https://example.test/api/2.0/foo\nHTTP Status: 400 Bad Request\nAPI error_code: TEST_ERROR\nAPI message: api error message", }, { - name: "wrapped apierr", - err: fmt.Errorf("wrapped: %w", &apierr.APIError{ - Message: "api error message", - ErrorCode: "TEST_ERROR", - StatusCode: 500, - }), + name: "wrapped apierr", + err: fmt.Errorf("wrapped: %w", apierr.FromHTTPError(500, nil, body)), expectedSummary: "wrapped: api error message (500 TEST_ERROR)", - expectedDetails: "Endpoint: n/a\nHTTP Status: 500\nAPI error_code: TEST_ERROR\nAPI message: api error message", + expectedDetails: "Endpoint: n/a\nHTTP Status: 500 Internal Server Error\nAPI error_code: TEST_ERROR\nAPI message: api error message", }, } diff --git a/libs/dms/fields.go b/libs/dms/fields.go index aa244d3e24b..119e5931d9b 100644 --- a/libs/dms/fields.go +++ b/libs/dms/fields.go @@ -1,6 +1,6 @@ package dms -import "github.com/databricks/databricks-sdk-go/common/types/fieldmask" +import "github.com/databricks/cli/libs/bundledeployments" // Fields is the set of operation fields an update writes, sent as its update mask. The // service rejects any other path, so this is the whole vocabulary. @@ -51,12 +51,12 @@ func (f Fields) Has(other Fields) bool { } // Mask renders f as the update_mask the service expects, always in the same order. -func (f Fields) Mask() fieldmask.FieldMask { +func (f Fields) Mask() bundledeployments.FieldMask { names := make([]string, 0, len(wireNames)) for _, w := range wireNames { if f.Has(w.field) { names = append(names, w.name) } } - return fieldmask.FieldMask{Paths: names} + return bundledeployments.FieldMask{Paths: names} } diff --git a/libs/dms/metadata.go b/libs/dms/metadata.go index f9e23a67db0..64cd1ee9abc 100644 --- a/libs/dms/metadata.go +++ b/libs/dms/metadata.go @@ -5,8 +5,8 @@ import ( "strconv" "strings" + "github.com/databricks/cli/libs/bundledeployments" "github.com/databricks/cli/libs/structs/structdiff" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" ) // VersionType identifies the kind of deployment a version records. @@ -110,7 +110,7 @@ func DeploymentIDFromName(name string) (string, error) { } // DeploymentUpdate builds the deployment with only the masked fields. -// A masked field must be sent even when empty (empty = clear it), so ForceSendFields stops omitempty dropping it. +// A masked field is sent even when empty (empty = clear it); the client force-sends every masked field. func DeploymentUpdate(metadata Metadata, mask string) bundledeployments.Deployment { full := metadata.Deployment() var dep bundledeployments.Deployment @@ -118,16 +118,12 @@ func DeploymentUpdate(metadata Metadata, mask string) bundledeployments.Deployme switch path { case "display_name": dep.DisplayName = full.DisplayName - dep.ForceSendFields = append(dep.ForceSendFields, "DisplayName") case "target_name": dep.TargetName = full.TargetName - dep.ForceSendFields = append(dep.ForceSendFields, "TargetName") case "deployment_mode": dep.DeploymentMode = full.DeploymentMode - dep.ForceSendFields = append(dep.ForceSendFields, "DeploymentMode") case "workspace_info": dep.WorkspaceInfo = full.WorkspaceInfo - dep.ForceSendFields = append(dep.ForceSendFields, "WorkspaceInfo") } } return dep diff --git a/libs/dms/operation.go b/libs/dms/operation.go index 3bb2f0b00d8..1c22561d824 100644 --- a/libs/dms/operation.go +++ b/libs/dms/operation.go @@ -5,8 +5,8 @@ import ( "fmt" "unicode/utf8" + "github.com/databricks/cli/libs/bundledeployments" "github.com/databricks/cli/libs/diag" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" ) // StatePrefix is the "resources." that bundle keys carry but DMS keys don't @@ -146,26 +146,22 @@ func (u OperationUpdate) Merge(newer OperationUpdate) OperationUpdate { } // operation builds the request body from the masked fields, plus the sequence_id check. -// Force-send them (empty = clear, and 0 is a real sequence_id); never force state, since a missing state means the resource is gone. +// The client force-sends them (empty = clear, and 0 is a real sequence_id) except state, since a missing state means the resource is gone. func (u OperationUpdate) operation(sequenceID int64) bundledeployments.Operation { operation := bundledeployments.Operation{ - SequenceId: sequenceID, - ForceSendFields: []string{"SequenceId"}, + SequenceId: sequenceID, } if u.Fields.Has(FieldState) && u.State != nil { operation.State = string(u.State) } if u.Fields.Has(FieldErrorMessage) { operation.ErrorMessage = u.ErrorMessage - operation.ForceSendFields = append(operation.ForceSendFields, "ErrorMessage") } if u.Fields.Has(FieldResourceID) { operation.ResourceId = u.ResourceID - operation.ForceSendFields = append(operation.ForceSendFields, "ResourceId") } if u.Fields.Has(FieldStatus) { operation.Status = u.Status - operation.ForceSendFields = append(operation.ForceSendFields, "Status") } return operation } diff --git a/libs/dms/operation_buffer.go b/libs/dms/operation_buffer.go index efecb3a330a..efea1e147ba 100644 --- a/libs/dms/operation_buffer.go +++ b/libs/dms/operation_buffer.go @@ -6,8 +6,8 @@ import ( "fmt" "sync" + "github.com/databricks/cli/libs/bundledeployments" "github.com/databricks/cli/libs/cmdctx" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" ) // bufferedOperations caps how far ahead of the service a deploy may get; DMS is what the next diff --git a/libs/dms/operation_buffer_test.go b/libs/dms/operation_buffer_test.go index 49af18c3255..c6227047ef2 100644 --- a/libs/dms/operation_buffer_test.go +++ b/libs/dms/operation_buffer_test.go @@ -7,7 +7,7 @@ import ( "sync" "testing" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" + "github.com/databricks/cli/libs/bundledeployments" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/libs/dms/operation_test.go b/libs/dms/operation_test.go index 2bae9a81144..de6812a4a2b 100644 --- a/libs/dms/operation_test.go +++ b/libs/dms/operation_test.go @@ -7,7 +7,7 @@ import ( "testing" "unicode/utf8" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" + "github.com/databricks/cli/libs/bundledeployments" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/libs/dockercredentials/workspace.go b/libs/dockercredentials/workspace.go index 3c1ed0f810e..28f8b3c9ac4 100644 --- a/libs/dockercredentials/workspace.go +++ b/libs/dockercredentials/workspace.go @@ -7,13 +7,15 @@ import ( "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/databrickscfg/profile" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/options/call" + "github.com/databricks/sdk-go/uc/metastores/v1" ) // WorkspaceID uses the selected profile's ID, resolving it only when absent. // The client is only needed for profiles without an ID. -func WorkspaceID(ctx context.Context, p profile.Profile, w *databricks.WorkspaceClient) (string, error) { +func WorkspaceID(ctx context.Context, p profile.Profile, w *sdkclients.Clients) (string, error) { if p.WorkspaceID != "" && p.WorkspaceID != profile.WorkspaceIDNone { return p.WorkspaceID, nil } @@ -28,12 +30,18 @@ func WorkspaceID(ctx context.Context, p profile.Profile, w *databricks.Workspace } // WorkspaceRegion obtains and validates the region returned by the workspace's metastore. -func WorkspaceRegion(ctx context.Context, p profile.Profile, metastores catalog.MetastoresInterface) (string, error) { - summary, err := metastores.Summary(ctx) +// MetastoreSummarizer is the part of the metastores client WorkspaceRegion +// needs; *metastores.Client implements it. +type MetastoreSummarizer interface { + GetMetastoreSummary(ctx context.Context, req metastores.GetMetastoreSummaryRequest, opts ...call.Option) (*metastores.GetMetastoreSummaryResponse, error) +} + +func WorkspaceRegion(ctx context.Context, p profile.Profile, api MetastoreSummarizer) (string, error) { + summary, err := api.GetMetastoreSummary(ctx, metastores.GetMetastoreSummaryRequest{}) if err != nil { return "", RewriteProfileError(ctx, p, fmt.Errorf("resolve workspace region for profile %q: %w", p.Name, err)) } - region := strings.TrimSpace(summary.Region) + region := strings.TrimSpace(utils.Deref(summary.Region)) if region == "" { return "", fmt.Errorf("resolve workspace region for profile %q: metastore summary did not include a region", p.Name) } diff --git a/libs/dockercredentials/workspace_test.go b/libs/dockercredentials/workspace_test.go index 3375ff08902..e180de8015c 100644 --- a/libs/dockercredentials/workspace_test.go +++ b/libs/dockercredentials/workspace_test.go @@ -1,6 +1,7 @@ package dockercredentials_test import ( + "context" "errors" "net/http" "testing" @@ -8,12 +9,12 @@ import ( "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/databrickscfg/profile" "github.com/databricks/cli/libs/dockercredentials" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" - mockcatalog "github.com/databricks/databricks-sdk-go/experimental/mocks/service/catalog" - "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/sdk-go/options/call" + "github.com/databricks/sdk-go/uc/metastores/v1" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) @@ -31,7 +32,7 @@ func TestWorkspaceID(t *testing.T) { assert.Empty(t, req.Headers.Get(auth.WorkspaceIDHeader)) return testserver.Response{Headers: http.Header{"X-Databricks-Org-Id": {"456"}}, Body: map[string]any{}} }) - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "test-token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "test-token"}) require.NoError(t, err) w.Config.WorkspaceID = "ambient-id" got, err := dockercredentials.WorkspaceID(t.Context(), profile.Profile{Name: "workspace", WorkspaceID: id}, w) @@ -53,9 +54,8 @@ func TestWorkspaceRegion(t *testing.T) { {name: "error", err: wantErr, wantError: "summary failed"}, } { t.Run(tt.name, func(t *testing.T) { - metastores := mockcatalog.NewMockMetastoresInterface(t) - metastores.EXPECT().Summary(mock.Anything).Return(&catalog.GetMetastoreSummaryResponse{Region: tt.region}, tt.err) - got, err := dockercredentials.WorkspaceRegion(t.Context(), profile.Profile{Name: "workspace"}, metastores) + api := fakeSummarizer{resp: &metastores.GetMetastoreSummaryResponse{Region: new(tt.region)}, err: tt.err} + got, err := dockercredentials.WorkspaceRegion(t.Context(), profile.Profile{Name: "workspace"}, api) if tt.wantError != "" { assert.ErrorContains(t, err, `resolve workspace region for profile "workspace": `+tt.wantError) if tt.err != nil { @@ -68,3 +68,12 @@ func TestWorkspaceRegion(t *testing.T) { }) } } + +type fakeSummarizer struct { + resp *metastores.GetMetastoreSummaryResponse + err error +} + +func (f fakeSummarizer) GetMetastoreSummary(context.Context, metastores.GetMetastoreSummaryRequest, ...call.Option) (*metastores.GetMetastoreSummaryResponse, error) { + return f.resp, f.err +} diff --git a/libs/dyn/convert/end_to_end_test.go b/libs/dyn/convert/end_to_end_test.go index e3ea273cb04..23a812d4f60 100644 --- a/libs/dyn/convert/end_to_end_test.go +++ b/libs/dyn/convert/end_to_end_test.go @@ -113,59 +113,3 @@ func TestAdditional(t *testing.T) { }) }) } - -func TestEndToEndForceSendFields(t *testing.T) { - type Inner struct { - InnerField string `json:"inner_field"` - ForceSendFields []string `json:"-"` - } - type Outer struct { - OuterField string `json:"outer_field"` - Inner - } - - // Test with zero value in embedded struct - src := Outer{ - OuterField: "outer_value", - Inner: Inner{ - InnerField: "", // Zero value - ForceSendFields: []string{"InnerField"}, // Should be preserved - }, - } - - assertFromTypedToTypedEqual(t, src) -} - -func TestEndToEndPointerForceSendFields(t *testing.T) { - type NewCluster struct { - NumWorkers int `json:"num_workers"` - SparkVersion string `json:"spark_version"` - ForceSendFields []string `json:"-"` - } - type JobCluster struct { - JobClusterKey string `json:"job_cluster_key"` - NewCluster *NewCluster `json:"new_cluster"` - } - type JobSettings struct { - JobClusters []JobCluster `json:"job_clusters"` - Name string `json:"name"` - ForceSendFields []string `json:"-"` - } - - // Test with zero value in pointer embedded struct (like acceptance test) - src := JobSettings{ - Name: "test-job", - JobClusters: []JobCluster{ - { - JobClusterKey: "key", - NewCluster: &NewCluster{ - NumWorkers: 0, // Zero value - SparkVersion: "13.3.x-scala2.12", - ForceSendFields: []string{"NumWorkers"}, // Should be preserved - }, - }, - }, - } - - assertFromTypedToTypedEqual(t, src) -} diff --git a/libs/dyn/convert/from_typed.go b/libs/dyn/convert/from_typed.go index 66451124293..6bf3e25530b 100644 --- a/libs/dyn/convert/from_typed.go +++ b/libs/dyn/convert/from_typed.go @@ -60,7 +60,7 @@ func fromTyped(src any, ref dyn.Value, options ...fromTypedOptions) (dyn.Value, switch srcv.Kind() { case reflect.Struct: // Handle SDK native types using JSON marshaling. - if slices.Contains(sdkNativeTypes, srcv.Type()) { + if isSDKNativeType(srcv.Type()) { v, err = fromTypedSDKNative(srcv, ref, options...) } else { v, err = fromTypedStruct(srcv, ref, options...) @@ -111,7 +111,6 @@ func fromTypedStruct(src reflect.Value, ref dyn.Value, options ...fromTypedOptio for _, fieldval := range info.FieldValues(src) { k := fieldval.Key v := fieldval.Value - isForced := fieldval.IsForced pair, ok := refm.GetPairByString(k) refloc := pair.Key.Locations() refv := pair.Value @@ -133,24 +132,16 @@ func fromTypedStruct(src reflect.Value, ref dyn.Value, options ...fromTypedOptio return dyn.InvalidValue, err } - // Either if the key was set in the reference, the field is not zero-valued, OR it's forced - if ok || nv.Kind() != dyn.KindNil || isForced { + // Either if the key was set in the reference or the field is not zero-valued + if ok || nv.Kind() != dyn.KindNil { // If v isZero, it could be because it's a variable reference; so we check that nv is zero as well - // BUT: always include if it's forced - if v.Kind() != reflect.Struct && v.IsZero() && nv.IsZero() && !info.ForceEmpty[k] && !isForced { - continue - } - - // If the field is forced but nv is nil, convert it to the appropriate zero value - if isForced && nv.Kind() == dyn.KindNil { - // Convert the zero value using proper recursive conversion instead of dyn.V() directly - // This prevents "not handled" panics for complex types like structs, slices, maps, etc. - // Use refv to preserve location information from the original reference - var err error - nv, err = fromTyped(v.Interface(), refv, includeZeroValues) - if err != nil { - return dyn.InvalidValue, err + if v.Kind() != reflect.Struct && v.IsZero() && nv.IsZero() && !info.ForceEmpty[k] { + // A zero scalar that was explicitly set in the reference (e.g. `name: ""`) + // is kept, so that typed round trips do not drop it. + if !ok || !info.KeepExplicitZero[k] || !isZeroScalar(refv) { + continue } + nv = refv } out.SetLoc(k, refloc, nv) @@ -360,3 +351,12 @@ func fromTypedFloat(src reflect.Value, ref dyn.Value, options ...fromTypedOption return dyn.InvalidValue, fmt.Errorf("cannot convert float field to dynamic type %#v: src=%#v ref=%#v", ref.Kind().String(), src, ref.AsAny()) } + +func isZeroScalar(v dyn.Value) bool { + switch v.Kind() { + case dyn.KindString, dyn.KindBool, dyn.KindInt, dyn.KindFloat: + return v.IsZero() + default: + return false + } +} diff --git a/libs/dyn/convert/from_typed_test.go b/libs/dyn/convert/from_typed_test.go index 3420c46cbd7..b652d9279a4 100644 --- a/libs/dyn/convert/from_typed_test.go +++ b/libs/dyn/convert/from_typed_test.go @@ -131,13 +131,12 @@ func TestFromTypedStructSetFieldsIntoExistingFields(t *testing.T) { func TestFromTypedStructZeroFieldsIntoExistingFields(t *testing.T) { type Tmp struct { - Foo string `json:"foo"` - Bar string `json:"bar,omitempty"` - BazBugz string `json:"baz_bugs,omitempty"` - ForceSendFields []string `json:"-"` + Foo string `json:"foo"` + Bar string `json:"bar,omitempty"` + BazBugz *string `json:"baz_bugs,omitempty"` } - src := Tmp{ForceSendFields: []string{"BazBugz"}} + src := Tmp{BazBugz: new("")} ref := dyn.V(map[string]dyn.Value{ "foo": dyn.V("foo_old"), @@ -155,13 +154,12 @@ func TestFromTypedStructZeroFieldsIntoExistingFields(t *testing.T) { func TestFromTypedStructZeroFieldsIntoExistingFieldsFloat64(t *testing.T) { type Tmp struct { - Foo float64 `json:"foo"` - Bar float64 `json:"bar,omitempty"` - BazBugz float64 `json:"baz_bugs,omitempty"` - ForceSendFields []string `json:"-"` + Foo float64 `json:"foo"` + Bar float64 `json:"bar,omitempty"` + BazBugz *float64 `json:"baz_bugs,omitempty"` } - src := Tmp{ForceSendFields: []string{"BazBugz"}} + src := Tmp{BazBugz: new(0.0)} ref := dyn.V(map[string]dyn.Value{ "foo": dyn.V(1.2), @@ -839,89 +837,3 @@ func TestFromTypedNilSliceRetainsLocation(t *testing.T) { require.NoError(t, err) assert.Equal(t, dyn.NewValue(nil, []diag.Location{{File: "foobar"}}), nv) } - -func TestFromTypedForceSendFieldsComplexTypes(t *testing.T) { - type Inner struct { - Value string `json:"value"` - } - - tests := []struct { - name string - src any - }{ - { - name: "struct_pointer", - src: struct { - Field *Inner `json:"field"` - ForceSendFields []string `json:"-"` - }{Field: nil, ForceSendFields: []string{"Field"}}, - }, - { - name: "struct_value", - src: struct { - Field Inner `json:"field"` - ForceSendFields []string `json:"-"` - }{Field: Inner{}, ForceSendFields: []string{"Field"}}, - }, - { - name: "slice", - src: struct { - Field []string `json:"field"` - ForceSendFields []string `json:"-"` - }{Field: nil, ForceSendFields: []string{"Field"}}, - }, - { - name: "map", - src: struct { - Field map[string]string `json:"field"` - ForceSendFields []string `json:"-"` - }{Field: nil, ForceSendFields: []string{"Field"}}, - }, - { - name: "interface", - src: struct { - Field any `json:"field"` - ForceSendFields []string `json:"-"` - }{Field: (*string)(nil), ForceSendFields: []string{"Field"}}, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - nv, err := FromTyped(tt.src, dyn.NilValue) - require.NoError(t, err) - - // All should include the field because it's in ForceSendFields - field := nv.Get("field") - assert.True(t, field.IsValid(), "field should be present due to ForceSendFields") - }) - } -} - -// Test embedded structs with ForceSendFields (separate test due to different structure) -func TestFromTypedForceSendFieldsEmbedded(t *testing.T) { - type Inner struct { - Field *string `json:"field"` - ForceSendFields []string `json:"-"` - } - type Outer struct { - Inner - Other string `json:"other"` - } - - src := Outer{ - Field: nil, - ForceSendFields: []string{"Field"}, - Other: "value", - } - - nv, err := FromTyped(src, dyn.NilValue) - require.NoError(t, err) - - // Both fields should be present - field := nv.Get("field") - other := nv.Get("other") - assert.True(t, field.IsValid(), "embedded field should be present due to ForceSendFields") - assert.Equal(t, dyn.KindNil, field.Kind(), "embedded field should be present due to ForceSendFields") - assert.Equal(t, dyn.V("value"), other) -} diff --git a/libs/dyn/convert/normalize.go b/libs/dyn/convert/normalize.go index e41ed4a0a87..0946cd1f5f7 100644 --- a/libs/dyn/convert/normalize.go +++ b/libs/dyn/convert/normalize.go @@ -55,7 +55,7 @@ func (n normalizeOptions) normalizeType(typ reflect.Type, src dyn.Value, seen [] switch typ.Kind() { case reflect.Struct: // Handle SDK native types as strings since they use custom JSON marshaling. - if slices.Contains(sdkNativeTypes, typ) { + if isSDKNativeType(typ) { return n.normalizeString(reflect.TypeFor[string](), src, path) } return n.normalizeStruct(typ, src, append(seen, typ), path) diff --git a/libs/dyn/convert/pointer_scalar_test.go b/libs/dyn/convert/pointer_scalar_test.go new file mode 100644 index 00000000000..3630594bd82 --- /dev/null +++ b/libs/dyn/convert/pointer_scalar_test.go @@ -0,0 +1,128 @@ +package convert + +import ( + "testing" + + "github.com/databricks/cli/libs/dyn" + assert "github.com/databricks/cli/libs/dyn/dynassert" + "github.com/stretchr/testify/require" +) + +type pointerScalarEnum string + +type pointerScalars struct { + S *string `json:"s,omitempty"` + I *int `json:"i,omitempty"` + I64 *int64 `json:"i64,omitempty"` + B *bool `json:"b,omitempty"` + F *float64 `json:"f,omitempty"` + E pointerScalarEnum `json:"e,omitempty"` + N *pointerScalarsSub `json:"n,omitempty"` +} + +type pointerScalarsSub struct { + B *bool `json:"b,omitempty"` +} + +func TestFromTypedPointerScalarsNil(t *testing.T) { + nv, err := FromTyped(pointerScalars{}, dyn.NilValue) + require.NoError(t, err) + assert.Equal(t, dyn.NilValue, nv) +} + +func TestFromTypedPointerScalarsZero(t *testing.T) { + src := pointerScalars{ + S: new(""), + I: new(0), + I64: new(int64(0)), + B: new(false), + F: new(0.0), + N: &pointerScalarsSub{B: new(false)}, + } + nv, err := FromTyped(src, dyn.NilValue) + require.NoError(t, err) + assert.Equal(t, dyn.V(map[string]dyn.Value{ + "s": dyn.V(""), + "i": dyn.V(int64(0)), + "i64": dyn.V(int64(0)), + "b": dyn.V(false), + "f": dyn.V(0.0), + "n": dyn.V(map[string]dyn.Value{"b": dyn.V(false)}), + }), nv) +} + +func TestFromTypedPointerScalarsSet(t *testing.T) { + src := pointerScalars{S: new("x"), I: new(3), B: new(true), E: "A"} + nv, err := FromTyped(src, dyn.NilValue) + require.NoError(t, err) + assert.Equal(t, dyn.V(map[string]dyn.Value{ + "s": dyn.V("x"), + "i": dyn.V(int64(3)), + "b": dyn.V(true), + "e": dyn.V("A"), + }), nv) +} + +func TestFromTypedPointerScalarsClearedField(t *testing.T) { + // A field present in the reference but now nil is dropped. + ref := dyn.V(map[string]dyn.Value{"s": dyn.V("old"), "b": dyn.V(true)}) + nv, err := FromTyped(pointerScalars{B: new(false)}, ref) + require.NoError(t, err) + assert.Equal(t, dyn.V(map[string]dyn.Value{"b": dyn.V(false)}), nv) +} + +func TestToTypedPointerScalars(t *testing.T) { + var out pointerScalars + err := ToTyped(&out, dyn.V(map[string]dyn.Value{ + "s": dyn.V(""), + "i": dyn.V(int64(0)), + "i64": dyn.V(int64(5)), + "b": dyn.V(false), + "f": dyn.V(0.0), + "e": dyn.V("B"), + "n": dyn.V(map[string]dyn.Value{"b": dyn.V(true)}), + })) + require.NoError(t, err) + assert.Equal(t, pointerScalars{ + S: new(""), + I: new(0), + I64: new(int64(5)), + B: new(false), + F: new(0.0), + E: "B", + N: &pointerScalarsSub{B: new(true)}, + }, out) +} + +func TestToTypedPointerScalarsMissing(t *testing.T) { + out := pointerScalars{S: new("previous")} + err := ToTyped(&out, dyn.V(map[string]dyn.Value{"b": dyn.V(true)})) + require.NoError(t, err) + assert.Equal(t, pointerScalars{B: new(true)}, out) +} + +func TestPointerScalarsRoundTrip(t *testing.T) { + src := pointerScalars{S: new(""), B: new(false), I: new(0)} + nv, err := FromTyped(src, dyn.NilValue) + require.NoError(t, err) + var out pointerScalars + require.NoError(t, ToTyped(&out, nv)) + assert.Equal(t, src, out) +} + +func TestNormalizePointerScalars(t *testing.T) { + vin := dyn.V(map[string]dyn.Value{ + "s": dyn.V(""), + "i": dyn.V("7"), + "b": dyn.V(false), + "e": dyn.V("C"), + }) + vout, diags := Normalize(pointerScalars{}, vin) + require.Empty(t, diags) + assert.Equal(t, dyn.V(map[string]dyn.Value{ + "s": dyn.V(""), + "i": dyn.V(int64(7)), + "b": dyn.V(false), + "e": dyn.V("C"), + }), vout) +} diff --git a/libs/dyn/convert/sdk_native_types.go b/libs/dyn/convert/sdk_native_types.go index b67d9b2b1e3..8e6b3876262 100644 --- a/libs/dyn/convert/sdk_native_types.go +++ b/libs/dyn/convert/sdk_native_types.go @@ -8,22 +8,22 @@ import ( "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/dyn/dynvar" - sdkduration "github.com/databricks/databricks-sdk-go/common/types/duration" - sdkfieldmask "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" ) -// sdkNativeTypes is a list of SDK native types that use custom JSON marshaling -// and should be treated as strings in dyn.Value. These types all implement -// json.Marshaler and json.Unmarshaler interfaces. -var sdkNativeTypes = []reflect.Type{ - reflect.TypeFor[sdkduration.Duration](), // Protobuf duration format (e.g., "300s") - reflect.TypeFor[sdktime.Time](), // RFC3339 timestamp format (e.g., "2023-12-25T10:30:00Z") - reflect.TypeFor[sdkfieldmask.FieldMask](), // Comma-separated paths (e.g., "name,age,email") +// sdkTypesPkgPath is the package of the SDK native types: types.Time (RFC3339 +// timestamp, e.g. "2023-12-25T10:30:00Z"), types.Duration (protobuf duration, +// e.g. "300s") and types.FieldMask[T] (comma-separated paths). They use custom +// JSON marshaling to a string and are treated as strings in dyn.Value. +const sdkTypesPkgPath = "github.com/databricks/sdk-go/core/types" + +// isSDKNativeType reports whether typ is one of the SDK native types. FieldMask +// is generic, so its instantiations are matched by package rather than by type. +func isSDKNativeType(typ reflect.Type) bool { + return typ.Kind() == reflect.Struct && typ.PkgPath() == sdkTypesPkgPath } // fromTypedSDKNative converts SDK native types to dyn.Value. -// SDK native types (duration.Duration, time.Time, fieldmask.FieldMask) use +// SDK native types (types.Time, types.Duration, types.FieldMask[T]) use // custom JSON marshaling with string representations. func fromTypedSDKNative(src reflect.Value, ref dyn.Value, options ...fromTypedOptions) (dyn.Value, error) { // Check that the reference value is compatible or nil. @@ -66,7 +66,7 @@ func fromTypedSDKNative(src reflect.Value, ref dyn.Value, options ...fromTypedOp } // toTypedSDKNative converts a dyn.Value to an SDK native type. -// SDK native types (duration.Duration, time.Time, fieldmask.FieldMask) use +// SDK native types (types.Time, types.Duration, types.FieldMask[T]) use // custom JSON marshaling with string representations. func toTypedSDKNative(dst reflect.Value, src dyn.Value) error { switch src.Kind() { diff --git a/libs/dyn/convert/sdk_native_types_test.go b/libs/dyn/convert/sdk_native_types_test.go index cd3d14fa129..56ffee68d88 100644 --- a/libs/dyn/convert/sdk_native_types_test.go +++ b/libs/dyn/convert/sdk_native_types_test.go @@ -7,9 +7,7 @@ import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" - sdkduration "github.com/databricks/databricks-sdk-go/common/types/duration" - sdkfieldmask "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" + "github.com/databricks/sdk-go/core/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -31,12 +29,12 @@ func TestDurationRoundtrip(t *testing.T) { t.Run(tt.name, func(t *testing.T) { // Test value type t.Run("value", func(t *testing.T) { - src := *sdkduration.New(tt.duration) + src := *types.NewFromDuration(tt.duration) dynValue, err := FromTyped(src, dyn.NilValue) require.NoError(t, err) assert.Equal(t, tt.expectedString, dynValue.MustString()) - var out sdkduration.Duration + var out types.Duration err = ToTyped(&out, dynValue) require.NoError(t, err) assert.Equal(t, src.AsDuration(), out.AsDuration()) @@ -44,12 +42,12 @@ func TestDurationRoundtrip(t *testing.T) { // Test pointer type t.Run("pointer", func(t *testing.T) { - src := *sdkduration.New(tt.duration) + src := *types.NewFromDuration(tt.duration) dynValue, err := FromTyped(&src, dyn.NilValue) require.NoError(t, err) assert.Equal(t, tt.expectedString, dynValue.MustString()) - var out *sdkduration.Duration + var out *types.Duration err = ToTyped(&out, dynValue) require.NoError(t, err) require.NotNil(t, out) @@ -86,12 +84,17 @@ func TestTimeRoundtrip(t *testing.T) { t.Run(tt.name, func(t *testing.T) { // Test value type t.Run("value", func(t *testing.T) { - src := *sdktime.New(tt.time) + src := *types.NewFromTime(tt.time) dynValue, err := FromTyped(src, dyn.NilValue) require.NoError(t, err) + if reflect.ValueOf(src).IsZero() { + // The epoch is the zero value of types.Time; by value it means "unset". + assert.Equal(t, dyn.NilValue, dynValue) + return + } assert.Equal(t, tt.expectedString, dynValue.MustString()) - var out sdktime.Time + var out types.Time err = ToTyped(&out, dynValue) require.NoError(t, err) assert.Equal(t, src.AsTime(), out.AsTime()) @@ -99,12 +102,12 @@ func TestTimeRoundtrip(t *testing.T) { // Test pointer type t.Run("pointer", func(t *testing.T) { - src := *sdktime.New(tt.time) + src := *types.NewFromTime(tt.time) dynValue, err := FromTyped(&src, dyn.NilValue) require.NoError(t, err) assert.Equal(t, tt.expectedString, dynValue.MustString()) - var out *sdktime.Time + var out *types.Time err = ToTyped(&out, dynValue) require.NoError(t, err) require.NotNil(t, out) @@ -121,37 +124,37 @@ func TestFieldMaskRoundtrip(t *testing.T) { expectedString string }{ {"single", []string{"name"}, "name"}, - {"multiple", []string{"name", "age", "email"}, "name,age,email"}, - {"nested", []string{"user.name", "user.email"}, "user.name,user.email"}, + {"multiple", []string{"name", "age", "email"}, "age,email,name"}, + {"nested", []string{"user.name", "user.email"}, "user.email,user.name"}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // Test value type t.Run("value", func(t *testing.T) { - src := *sdkfieldmask.New(tt.paths) + src := *newFieldMask(t, tt.paths...) dynValue, err := FromTyped(src, dyn.NilValue) require.NoError(t, err) assert.Equal(t, tt.expectedString, dynValue.MustString()) - var out sdkfieldmask.FieldMask + var out fieldMask err = ToTyped(&out, dynValue) require.NoError(t, err) - assert.Equal(t, src.Paths, out.Paths) + assert.Equal(t, src.String(), out.String()) }) // Test pointer type t.Run("pointer", func(t *testing.T) { - src := *sdkfieldmask.New(tt.paths) + src := *newFieldMask(t, tt.paths...) dynValue, err := FromTyped(&src, dyn.NilValue) require.NoError(t, err) assert.Equal(t, tt.expectedString, dynValue.MustString()) - var out *sdkfieldmask.FieldMask + var out *fieldMask err = ToTyped(&out, dynValue) require.NoError(t, err) require.NotNil(t, out) - assert.Equal(t, src.Paths, out.Paths) + assert.Equal(t, src.String(), out.String()) }) }) } @@ -164,9 +167,9 @@ func TestNilValues(t *testing.T) { name string typ any }{ - {"duration", (*sdkduration.Duration)(nil)}, - {"time", (*sdktime.Time)(nil)}, - {"fieldmask", (*sdkfieldmask.FieldMask)(nil)}, + {"duration", (*types.Duration)(nil)}, + {"time", (*types.Time)(nil)}, + {"fieldmask", (*fieldMask)(nil)}, } t.Run("from_typed", func(t *testing.T) { @@ -203,31 +206,31 @@ func TestToTypedErrors(t *testing.T) { }{ { name: "duration_wrong_type", - destValue: new(sdkduration.Duration), + destValue: new(types.Duration), input: wrongTypeInput, expectedError: "expected a string", }, { name: "duration_invalid_format", - destValue: new(sdkduration.Duration), + destValue: new(types.Duration), input: dyn.V("7d"), - expectedError: "invalid google.protobuf.Duration value", + expectedError: "parse duration", }, { name: "time_wrong_type", - destValue: new(sdktime.Time), + destValue: new(types.Time), input: wrongTypeInput, expectedError: "expected a string", }, { name: "time_invalid_format", - destValue: new(sdktime.Time), + destValue: new(types.Time), input: dyn.V("not-a-time"), - expectedError: "invalid google.protobuf.Timestamp value", + expectedError: "parse timestamp", }, { name: "fieldmask_wrong_type", - destValue: new(sdkfieldmask.FieldMask), + destValue: new(fieldMask), input: wrongTypeInput, expectedError: "expected a string", }, @@ -249,15 +252,15 @@ func TestFromTypedVariableReferences(t *testing.T) { }{ { name: "duration", - src: *sdkduration.New(5 * time.Minute), + src: *types.NewFromDuration(5 * time.Minute), }, { name: "time", - src: *sdktime.New(time.Date(2023, 12, 25, 10, 30, 0, 0, time.UTC)), + src: *types.NewFromTime(time.Date(2023, 12, 25, 10, 30, 0, 0, time.UTC)), }, { name: "fieldmask", - src: *sdkfieldmask.New([]string{"name", "age"}), + src: *newFieldMask(t, []string{"name", "age"}...), }, } @@ -279,18 +282,18 @@ func TestToTypedVariableReferences(t *testing.T) { }{ { name: "duration", - dst: sdkduration.New(5 * time.Minute), - zero: sdkduration.Duration{}, + dst: types.NewFromDuration(5 * time.Minute), + zero: types.Duration{}, }, { name: "time", - dst: sdktime.New(time.Date(2023, 12, 25, 10, 30, 0, 0, time.UTC)), - zero: sdktime.Time{}, + dst: types.NewFromTime(time.Date(2023, 12, 25, 10, 30, 0, 0, time.UTC)), + zero: types.Time{}, }, { name: "fieldmask", - dst: sdkfieldmask.New([]string{"name", "age"}), - zero: sdkfieldmask.FieldMask{}, + dst: newFieldMask(t, []string{"name", "age"}...), + zero: fieldMask{}, }, } @@ -305,14 +308,14 @@ func TestToTypedVariableReferences(t *testing.T) { func TestSpecialCases(t *testing.T) { t.Run("duration_zero", func(t *testing.T) { - var src sdkduration.Duration + var src types.Duration nv, err := FromTyped(src, dyn.NilValue) require.NoError(t, err) assert.Equal(t, dyn.NilValue, nv) }) t.Run("fieldmask_empty_fromtyped", func(t *testing.T) { - src := sdkfieldmask.New([]string{}) + src := newFieldMask(t, []string{}...) nv, err := FromTyped(src, dyn.NilValue) require.NoError(t, err) // Empty field mask marshals to empty string @@ -320,10 +323,10 @@ func TestSpecialCases(t *testing.T) { }) t.Run("fieldmask_empty_totyped", func(t *testing.T) { - var out sdkfieldmask.FieldMask + var out fieldMask err := ToTyped(&out, dyn.V("")) require.NoError(t, err) - assert.Empty(t, out.Paths) + assert.Empty(t, out.String()) }) } @@ -331,16 +334,16 @@ func TestSpecialCases(t *testing.T) { func TestSDKTypesRoundTripWithPostgresBranchSpec(t *testing.T) { type BranchSpec struct { - ExpireTime *sdktime.Time `json:"expire_time,omitempty"` - SourceBranchTime *sdktime.Time `json:"source_branch_time,omitempty"` - Ttl *sdkduration.Duration `json:"ttl,omitempty"` - IsProtected bool `json:"is_protected,omitempty"` + ExpireTime *types.Time `json:"expire_time,omitempty"` + SourceBranchTime *types.Time `json:"source_branch_time,omitempty"` + Ttl *types.Duration `json:"ttl,omitempty"` + IsProtected bool `json:"is_protected,omitempty"` } original := BranchSpec{ - ExpireTime: sdktime.New(time.Date(2024, 12, 31, 23, 59, 59, 0, time.UTC)), - SourceBranchTime: sdktime.New(time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)), - Ttl: sdkduration.New(7 * 24 * time.Hour), + ExpireTime: types.NewFromTime(time.Date(2024, 12, 31, 23, 59, 59, 0, time.UTC)), + SourceBranchTime: types.NewFromTime(time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)), + Ttl: types.NewFromDuration(7 * 24 * time.Hour), IsProtected: true, } @@ -365,32 +368,32 @@ func TestSDKTypesRoundTripWithPostgresBranchSpec(t *testing.T) { func TestSDKTypesRoundTripWithUpdateRequest(t *testing.T) { type UpdateRequest struct { - Name string `json:"name"` - UpdateMask sdkfieldmask.FieldMask `json:"update_mask"` + Name string `json:"name"` + UpdateMask fieldMask `json:"update_mask"` } original := UpdateRequest{ Name: "projects/123/branches/456", - UpdateMask: *sdkfieldmask.New([]string{"spec.ttl", "spec.is_protected"}), + UpdateMask: *newFieldMask(t, []string{"spec.ttl", "spec.is_protected"}...), } dynValue, err := FromTyped(original, dyn.NilValue) require.NoError(t, err) assert.Equal(t, "projects/123/branches/456", dynValue.Get("name").MustString()) - assert.Equal(t, "spec.ttl,spec.is_protected", dynValue.Get("update_mask").MustString()) + assert.Equal(t, "spec.is_protected,spec.ttl", dynValue.Get("update_mask").MustString()) var roundtrip UpdateRequest err = ToTyped(&roundtrip, dynValue) require.NoError(t, err) assert.Equal(t, original.Name, roundtrip.Name) - assert.Equal(t, []string{"spec.ttl", "spec.is_protected"}, roundtrip.UpdateMask.Paths) + assert.Equal(t, "spec.is_protected,spec.ttl", roundtrip.UpdateMask.String()) } func TestSDKTypesNormalizeWithStruct(t *testing.T) { type BranchSpec struct { - ExpireTime *sdktime.Time `json:"expire_time,omitempty"` - Ttl *sdkduration.Duration `json:"ttl,omitempty"` - IsProtected bool `json:"is_protected,omitempty"` + ExpireTime *types.Time `json:"expire_time,omitempty"` + Ttl *types.Duration `json:"ttl,omitempty"` + IsProtected bool `json:"is_protected,omitempty"` } var typ BranchSpec @@ -415,3 +418,31 @@ func TestSDKTypesNormalizeWithStruct(t *testing.T) { assert.Equal(t, 7*24*time.Hour, out.Ttl.AsDuration()) assert.True(t, out.IsProtected) } + +type fieldMaskUser struct { + Name *string `fieldmask:"name"` + Email *string `fieldmask:"email"` +} + +type fieldMaskSpec struct { + Ttl *string `fieldmask:"ttl"` + IsProtected *bool `fieldmask:"is_protected"` +} + +// fieldMaskTarget mirrors the fieldmask tags sdk-go generates on its models, +// which types.FieldMask validates paths against. +type fieldMaskTarget struct { + Name *string `fieldmask:"name"` + Age *int `fieldmask:"age"` + Email *string `fieldmask:"email"` + User *fieldMaskUser `fieldmask:"user"` + Spec *fieldMaskSpec `fieldmask:"spec"` +} + +type fieldMask = types.FieldMask[fieldMaskTarget] + +func newFieldMask(t *testing.T, paths ...string) *fieldMask { + m, err := types.NewFieldMask[fieldMaskTarget](paths...) + require.NoError(t, err) + return m +} diff --git a/libs/dyn/convert/struct_info.go b/libs/dyn/convert/struct_info.go index 69e8f868ed5..d5439132447 100644 --- a/libs/dyn/convert/struct_info.go +++ b/libs/dyn/convert/struct_info.go @@ -2,7 +2,7 @@ package convert import ( "reflect" - "slices" + "strings" "sync" "github.com/databricks/cli/libs/dyn" @@ -28,15 +28,9 @@ type structInfo struct { // Maps JSON-name of the field to Golang struct name GolangNames map[string]string - // ForceSendFieldsIndex maps the JSON-name of the field to the index path (for - // use with [reflect.Value.FieldByIndex]) of the ForceSendFields slice that - // governs it: the one declared by the struct that also declares the field. - // The path is static per type, so we resolve it once here rather than walking - // the value at conversion time. It can be more than one element deep because a - // field's declaring struct may be embedded several levels down (e.g. - // PostgresProject -> PostgresProjectConfig -> ProjectSpec). A field whose - // declaring struct has no ForceSendFields has no entry. - ForceSendFieldsIndex map[string][]int + // Tracks fields of API types whose explicitly set zero value is kept on a + // round trip through the typed representation (see [keepsExplicitZero]). + KeepExplicitZero map[string]bool } // structInfoCache caches type information. @@ -64,10 +58,11 @@ func getStructInfo(typ reflect.Type) structInfo { // buildStructInfo populates a new [structInfo] for the given type. func buildStructInfo(typ reflect.Type) structInfo { out := structInfo{ - Fields: make(map[string][]int), - ForceEmpty: make(map[string]bool), - GolangNames: make(map[string]string), - ForceSendFieldsIndex: make(map[string][]int), + Fields: make(map[string][]int), + ForceEmpty: make(map[string]bool), + GolangNames: make(map[string]string), + + KeepExplicitZero: make(map[string]bool), } // Queue holds the indexes of the structs to visit. @@ -87,15 +82,6 @@ func buildStructInfo(typ reflect.Type) structInfo { styp = styp.Elem() } - // Index path to the ForceSendFields declared by this struct, if any. All - // fields declared directly by this struct are governed by it. The len==1 - // check excludes a ForceSendFields promoted from an embedded struct: that - // one governs the embedded struct's own fields, which we visit separately. - var forceSendFieldsIndex []int - if sf, ok := styp.FieldByName("ForceSendFields"); ok && len(sf.Index) == 1 { - forceSendFieldsIndex = append(slices.Clone(prefix), sf.Index...) - } - nf := styp.NumField() for j := range nf { sf := styp.Field(j) @@ -133,12 +119,10 @@ func buildStructInfo(typ reflect.Type) structInfo { out.ForceEmpty[name] = true } out.GolangNames[name] = sf.Name - - // The field is declared directly in this struct, so it is governed by - // this struct's ForceSendFields (if it has one). - if forceSendFieldsIndex != nil { - out.ForceSendFieldsIndex[name] = forceSendFieldsIndex + if keepsExplicitZero(styp) { + out.KeepExplicitZero[name] = true } + } } @@ -146,9 +130,8 @@ func buildStructInfo(typ reflect.Type) structInfo { } type FieldValue struct { - Key string - Value reflect.Value - IsForced bool + Key string + Value reflect.Value } func (s *structInfo) FieldValues(v reflect.Value) []FieldValue { @@ -158,17 +141,9 @@ func (s *structInfo) FieldValues(v reflect.Value) []FieldValue { fv := fieldByIndex(v, s.Fields[k]) if fv.IsValid() { - isForced := true - - // TODO: we should use isEmptyForOmitEmpty instead of IsZero() - if fv.IsZero() { - isForced = s.isForceSend(v, k) - } - out = append(out, FieldValue{ - Key: k, - Value: fv, - IsForced: isForced, + Key: k, + Value: fv, }) } } @@ -176,20 +151,6 @@ func (s *structInfo) FieldValues(v reflect.Value) []FieldValue { return out } -// isForceSend reports whether the field named k is listed in the ForceSendFields -// that governs it (see structInfo.ForceSendFieldsIndex). -func (s *structInfo) isForceSend(v reflect.Value, k string) bool { - index, ok := s.ForceSendFieldsIndex[k] - if !ok { - return false - } - fsf := fieldByIndex(v, index) - if !fsf.IsValid() { - return false - } - return slices.Contains(fsf.Interface().([]string), s.GolangNames[k]) -} - // fieldByIndex resolves the value at the given index path, dereferencing embedded // pointer structs on the way. It returns an invalid value if a nil pointer is met. func fieldByIndex(v reflect.Value, index []int) reflect.Value { @@ -209,3 +170,13 @@ func fieldByIndex(v reflect.Value, index []int) reflect.Value { // Type of [dyn.Value]. var configValueType = reflect.TypeFor[dyn.Value]() + +// keepsExplicitZero reports whether fields declared by typ keep an explicitly +// set zero value (e.g. `parent_path: ""`). This holds for API types: the +// sdk-go mirrors and the bundle resource types built on them. The previous SDK +// tracked such values in ForceSendFields; CLI-only types never did. +func keepsExplicitZero(typ reflect.Type) bool { + pkg := typ.PkgPath() + return strings.HasPrefix(pkg, "github.com/databricks/cli/libs/sdktypes/") || + pkg == "github.com/databricks/cli/bundle/config/resources" +} diff --git a/libs/dyn/convert/to_typed.go b/libs/dyn/convert/to_typed.go index 87b0fe7d8ca..bb638911fc5 100644 --- a/libs/dyn/convert/to_typed.go +++ b/libs/dyn/convert/to_typed.go @@ -3,7 +3,6 @@ package convert import ( "fmt" "reflect" - "slices" "strconv" "github.com/databricks/cli/libs/dyn" @@ -41,7 +40,7 @@ func ToTyped(dst any, src dyn.Value) error { switch dstv.Kind() { case reflect.Struct: // Handle SDK native types using JSON unmarshaling. - if slices.Contains(sdkNativeTypes, dstv.Type()) { + if isSDKNativeType(dstv.Type()) { return toTypedSDKNative(dstv, src) } return toTypedStruct(dstv, src) @@ -93,17 +92,6 @@ func toTypedStruct(dst reflect.Value, src dyn.Value) error { if err != nil { return err } - - if pv.IsZero() { - // The field's zero value must still serialize, so append its Go name - // to the ForceSendFields of the struct that declares it. That struct - // shares a prefix with the field's index path, so it is already - // allocated by the walk above. - if fsfIndex, ok := info.ForceSendFieldsIndex[jsonKey]; ok { - fsf := getOrNewFieldByIndex(dst, fsfIndex) - fsf.Set(reflect.Append(fsf, reflect.ValueOf(info.GolangNames[jsonKey]))) - } - } } // Populate field(s) for [dyn.Value], if any. diff --git a/libs/dyn/convert/to_typed_test.go b/libs/dyn/convert/to_typed_test.go index a838dfab33f..c6255c44727 100644 --- a/libs/dyn/convert/to_typed_test.go +++ b/libs/dyn/convert/to_typed_test.go @@ -80,28 +80,6 @@ func TestToTypedStructClearFields(t *testing.T) { assert.Equal(t, Tmp{}, out) } -func TestToTypedStructClearFieldsForceSend(t *testing.T) { - type Tmp struct { - Foo string `json:"foo"` - Bar string `json:"bar,omitempty"` - ForceSendFields []string `json:"-"` - } - - // Struct value with non-empty fields. - out := Tmp{ - Foo: "baz", - Bar: "qux", - } - - // Value is an empty map. - v := dyn.V(map[string]dyn.Value{}) - - // The previously set fields should be cleared. - err := ToTyped(&out, v) - require.NoError(t, err) - assert.Equal(t, Tmp{}, out) -} - func TestToTypedStructZeroFields(t *testing.T) { type Tmp struct { Foo string `json:"foo"` @@ -126,33 +104,6 @@ func TestToTypedStructZeroFields(t *testing.T) { assert.Equal(t, Tmp{}, out) } -func TestToTypedStructZeroFieldsForceSend(t *testing.T) { - type Tmp struct { - Foo string `json:"foo"` - Bar string `json:"bar,omitempty"` - NumWorkers int `json:"num_workers,omitempty"` - ForceSendFields []string `json:"-"` - } - - // Struct value with non-empty fields. - out := Tmp{ - Foo: "baz", - Bar: "qux", - } - - // Value is an empty map. - m := dyn.Mapping{} - m.SetLoc("foo", nil, dyn.V("")) - m.SetLoc("bar", nil, dyn.V("")) - m.SetLoc("num_workers", nil, dyn.V(int64(0))) - v := dyn.V(m) - - // The previously set fields should be cleared. - err := ToTyped(&out, v) - require.NoError(t, err) - assert.Equal(t, Tmp{ForceSendFields: []string{"Foo", "Bar", "NumWorkers"}}, out) -} - func TestToTypedStructAnonymousByValue(t *testing.T) { type Bar struct { Bar string `json:"bar"` @@ -626,165 +577,3 @@ func TestToTypedAnyWithNil(t *testing.T) { require.NoError(t, err) assert.Nil(t, out) } - -func TestToTypedEmbeddedStructForceSendFields(t *testing.T) { - type Inner struct { - InnerField string `json:"inner_field"` - ForceSendFields []string `json:"-"` - } - - type Outer struct { - OuterField string `json:"outer_field"` - Inner - } - - var out Outer - m := dyn.Mapping{} - m.SetLoc("outer_field", nil, dyn.V("")) - m.SetLoc("inner_field", nil, dyn.V("")) - v := dyn.V(m) - - err := ToTyped(&out, v) - require.NoError(t, err) - - // Bug: ForceSendFields contains "OuterField" which belongs to outer struct - // Expected: ForceSendFields should only contain "InnerField" - assert.Equal(t, []string{"InnerField"}, out.ForceSendFields) -} - -func TestToTypedMultipleEmbeddedStructsForceSendFields(t *testing.T) { - type First struct { - FirstField string `json:"first_field"` - ForceSendFields []string `json:"-"` - } - - type Second struct { - SecondField string `json:"second_field"` - ForceSendFields []string `json:"-"` - } - - type Outer struct { - OuterField string `json:"outer_field"` - First - Second - } - - var out Outer - m := dyn.Mapping{} - m.SetLoc("outer_field", nil, dyn.V("")) - m.SetLoc("first_field", nil, dyn.V("")) - m.SetLoc("second_field", nil, dyn.V("")) - v := dyn.V(m) - - err := ToTyped(&out, v) - require.NoError(t, err) - - // Each embedded struct should only get its own fields in ForceSendFields - assert.Equal(t, []string{"FirstField"}, out.First.ForceSendFields) - assert.Equal(t, []string{"SecondField"}, out.Second.ForceSendFields) -} - -func TestToTypedMixedForceSendFields(t *testing.T) { - type First struct { - FirstField string `json:"first_field"` - // No ForceSendFields - } - - type Second struct { - SecondField string `json:"second_field"` - ForceSendFields []string `json:"-"` - } - - type Outer struct { - OuterField string `json:"outer_field"` - ForceSendFields []string `json:"-"` - First - Second - } - - var out Outer - m := dyn.Mapping{} - m.SetLoc("outer_field", nil, dyn.V("")) - m.SetLoc("first_field", nil, dyn.V("")) - m.SetLoc("second_field", nil, dyn.V("")) - v := dyn.V(m) - - err := ToTyped(&out, v) - require.NoError(t, err) - - // Outer should get its own direct fields - assert.Equal(t, []string{"OuterField"}, out.ForceSendFields) - // First has no ForceSendFields field, so nothing to check - // Second should get its own field - assert.Equal(t, []string{"SecondField"}, out.Second.ForceSendFields) -} - -func TestToTypedFieldByNameBugRegressionTest(t *testing.T) { - // This test reproduces the EXACT bug: only direct field is zero, embedded fields are non-zero - // The bug occurred because dst.FieldByName("ForceSendFields") finds embedded ForceSendFields - // instead of direct ForceSendFields (which doesn't exist) - type BaseResource struct { - ID string `json:"id,omitempty"` - } - - type JobSettings struct { - Name string `json:"name"` - ForceSendFields []string `json:"-"` - } - - type Job struct { - BaseResource // embedded at [0] - JobSettings // embedded at [1], has ForceSendFields - Permissions []string `json:"permissions,omitempty"` // direct at [2] - } - - var out Job - m := dyn.Mapping{} - // Non-zero JobSettings fields - these should NOT go to ForceSendFields - m.SetLoc("name", nil, dyn.V("test-job")) - // Zero direct field - this SHOULD trigger the bug with old code - m.SetLoc("permissions", nil, dyn.V([]dyn.Value{})) - v := dyn.V(m) - - err := ToTyped(&out, v) - require.NoError(t, err) - - // "Permissions" should be dropped, JobSettings.ForceSendFields stays empty - assert.Empty(t, out.ForceSendFields) - assert.Equal(t, "test-job", out.Name) - assert.Empty(t, out.Permissions) -} - -func TestToTypedDeeplyEmbeddedStructForceSendFields(t *testing.T) { - // Mirrors resources.PostgresProject -> PostgresProjectConfig -> ProjectSpec: - // Spec is embedded two levels down and Wrapper shadows ForceSendFields to keep - // its own direct field out of Spec's ForceSendFields. A zero-value spec field - // must route to Spec.ForceSendFields, not Wrapper's, otherwise the SDK marshaler - // fails with "field ... cannot be found in struct". - type Spec struct { - SpecField bool `json:"spec_field,omitempty"` - ForceSendFields []string `json:"-"` - } - - type Wrapper struct { - Spec - WrapperField string `json:"wrapper_field,omitempty"` - ForceSendFields []string `json:"-"` - } - - type Outer struct { - Wrapper - } - - var out Outer - m := dyn.Mapping{} - m.SetLoc("spec_field", nil, dyn.V(false)) - m.SetLoc("wrapper_field", nil, dyn.V("")) - v := dyn.V(m) - - err := ToTyped(&out, v) - require.NoError(t, err) - - assert.Equal(t, []string{"SpecField"}, out.Spec.ForceSendFields) - assert.Equal(t, []string{"WrapperField"}, out.ForceSendFields) -} diff --git a/libs/dyn/jsonloader/json_test.go b/libs/dyn/jsonloader/json_test.go index e274de559ce..6f3ac06e9a7 100644 --- a/libs/dyn/jsonloader/json_test.go +++ b/libs/dyn/jsonloader/json_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/databricks/cli/libs/dyn/convert" - "github.com/databricks/databricks-sdk-go/service/jobs" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -48,7 +48,7 @@ func TestJsonLoader(t *testing.T) { v, err := LoadJSON([]byte(jsonData), "(inline)") assert.NoError(t, err) - var r jobs.ResetJob + var r jobs.ResetJobRequest err = convert.ToTyped(&r, v) assert.NoError(t, err) } @@ -153,9 +153,9 @@ func TestJsonLoaderMixedNumbersToTyped(t *testing.T) { v, err := LoadJSON([]byte(mixedNumbersData), "(inline)") require.NoError(t, err) - var r jobs.ResetJob + var r jobs.ResetJobRequest err = convert.ToTyped(&r, v) require.NoError(t, err) - assert.Equal(t, int64(123456789012345678), r.JobId) - assert.Equal(t, 100, r.NewSettings.TimeoutSeconds) + assert.Equal(t, new(int64(123456789012345678)), r.JobId) + assert.Equal(t, new(100), r.NewSettings.TimeoutSeconds) } diff --git a/libs/dyn/yamlsaver/utils_test.go b/libs/dyn/yamlsaver/utils_test.go index 8b056e0076f..6720015f733 100644 --- a/libs/dyn/yamlsaver/utils_test.go +++ b/libs/dyn/yamlsaver/utils_test.go @@ -11,12 +11,11 @@ import ( func TestConvertToMap(t *testing.T) { type test struct { - Name string `json:"name"` - Map map[string]string `json:"map"` - List []string `json:"list"` - LongNameField string `json:"long_name_field"` - ForceSendFields []string `json:"-"` - Format string `json:"format"` + Name string `json:"name"` + Map map[string]string `json:"map"` + List []string `json:"list"` + LongNameField string `json:"long_name_field"` + Format string `json:"format"` } v := &test{ @@ -25,10 +24,7 @@ func TestConvertToMap(t *testing.T) { "key2": "value2", "key1": "value1", }, - List: []string{"a", "b", "c"}, - ForceSendFields: []string{ - "Name", - }, + List: []string{"a", "b", "c"}, LongNameField: "long name goes here", } result, err := ConvertToMapValue(v, nil, []string{"format"}, map[string]dyn.Value{}) @@ -56,12 +52,11 @@ func TestConvertToMap(t *testing.T) { func TestConvertToMapValueWithOrder(t *testing.T) { type test struct { - Name string `json:"name"` - Map map[string]string `json:"map"` - List []string `json:"list"` - LongNameField string `json:"long_name_field"` - ForceSendFields []string `json:"-"` - Format string `json:"format"` + Name string `json:"name"` + Map map[string]string `json:"map"` + List []string `json:"list"` + LongNameField string `json:"long_name_field"` + Format string `json:"format"` } v := &test{ @@ -70,10 +65,7 @@ func TestConvertToMapValueWithOrder(t *testing.T) { "key1": "value1", "key2": "value2", }, - List: []string{"a", "b", "c"}, - ForceSendFields: []string{ - "Name", - }, + List: []string{"a", "b", "c"}, LongNameField: "long name goes here", } result, err := ConvertToMapValue(v, NewOrder([]string{"list", "name", "map"}), []string{"format"}, map[string]dyn.Value{}) diff --git a/libs/filer/completer/completer_test.go b/libs/filer/completer/completer_test.go index 7ee3ae0b64c..ab863a73f66 100644 --- a/libs/filer/completer/completer_test.go +++ b/libs/filer/completer/completer_test.go @@ -7,7 +7,7 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/fakefs" "github.com/databricks/cli/libs/filer" - "github.com/databricks/databricks-sdk-go/experimental/mocks" + "github.com/databricks/cli/libs/sdkclients" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" ) @@ -15,7 +15,7 @@ import ( func setupCompleter(t *testing.T, onlyDirs bool) *completer { ctx := t.Context() // Needed to make type context.valueCtx for mockFilerForPath - ctx = cmdctx.SetWorkspaceClient(ctx, mocks.NewMockWorkspaceClient(t).WorkspaceClient) + ctx = cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{}) fakeFiler := filer.NewFakeFiler(map[string]fakefs.FileInfo{ "dir": {FakeName: "root", FakeDir: true}, diff --git a/libs/filer/dbfs_client.go b/libs/filer/dbfs_client.go index f5d6c5993e4..a5ebe1300f0 100644 --- a/libs/filer/dbfs_client.go +++ b/libs/filer/dbfs_client.go @@ -12,9 +12,12 @@ import ( "strings" "time" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/files" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/dbfs" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/apierr" + files "github.com/databricks/sdk-go/files/v2" ) // Type that implements fs.DirEntry for DBFS. @@ -36,27 +39,27 @@ type dbfsFileInfo struct { } func (info dbfsFileInfo) Name() string { - return path.Base(info.fi.Path) + return path.Base(utils.Deref(info.fi.Path)) } func (info dbfsFileInfo) Size() int64 { - return info.fi.FileSize + return utils.Deref(info.fi.FileSize) } func (info dbfsFileInfo) Mode() fs.FileMode { mode := fs.ModePerm - if info.fi.IsDir { + if utils.Deref(info.fi.IsDir) { mode |= fs.ModeDir } return mode } func (info dbfsFileInfo) ModTime() time.Time { - return time.UnixMilli(info.fi.ModificationTime) + return time.UnixMilli(utils.Deref(info.fi.ModificationTime)) } func (info dbfsFileInfo) IsDir() bool { - return info.fi.IsDir + return utils.Deref(info.fi.IsDir) } func (info dbfsFileInfo) Sys() any { @@ -65,13 +68,13 @@ func (info dbfsFileInfo) Sys() any { // DbfsClient implements the [Filer] interface for the DBFS backend. type DbfsClient struct { - workspaceClient *databricks.WorkspaceClient + workspaceClient *sdkclients.Clients // File operations will be relative to this path. root WorkspaceRootPath } -func NewDbfsClient(w *databricks.WorkspaceClient, root string) (Filer, error) { +func NewDbfsClient(w *sdkclients.Clients, root string) (Filer, error) { return &DbfsClient{ workspaceClient: w, @@ -85,10 +88,7 @@ func (w *DbfsClient) Write(ctx context.Context, name string, reader io.Reader, m return err } - fileMode := files.FileModeWrite - if slices.Contains(mode, OverwriteIfExists) { - fileMode |= files.FileModeOverwrite - } + overwrite := slices.Contains(mode, OverwriteIfExists) // Issue info call before write because it automatically creates parent directories. // @@ -96,7 +96,7 @@ func (w *DbfsClient) Write(ctx context.Context, name string, reader io.Reader, m // and apply the same semantics for the WSFS filer. // if !slices.Contains(mode, CreateParentDirectories) { - _, err = w.workspaceClient.Dbfs.GetStatusByPath(ctx, path.Dir(absPath)) + _, err = w.workspaceClient.Files.GetStatus(ctx, files.GetStatusRequest{Path: new(path.Dir(absPath))}) if err != nil { aerr, ok := errors.AsType[*apierr.APIError](err) if !ok { @@ -104,8 +104,8 @@ func (w *DbfsClient) Write(ctx context.Context, name string, reader io.Reader, m } // This API returns a 404 if the file doesn't exist. - if aerr.StatusCode == http.StatusNotFound { - if aerr.ErrorCode == "RESOURCE_DOES_NOT_EXIST" { + if aerr.HTTPStatusCode() == http.StatusNotFound { + if apierrs.ErrorCode(aerr) == "RESOURCE_DOES_NOT_EXIST" { return noSuchDirectoryError{path.Dir(absPath)} } } @@ -114,7 +114,11 @@ func (w *DbfsClient) Write(ctx context.Context, name string, reader io.Reader, m } } - handle, err := w.workspaceClient.Dbfs.Open(ctx, absPath, fileMode) + fileMode := dbfs.FileModeWrite + if overwrite { + fileMode |= dbfs.FileModeOverwrite + } + handle, err := dbfs.Open(ctx, w.workspaceClient.Files, absPath, fileMode) if err != nil { aerr, ok := errors.AsType[*apierr.APIError](err) if !ok { @@ -122,8 +126,8 @@ func (w *DbfsClient) Write(ctx context.Context, name string, reader io.Reader, m } // This API returns a 400 if the file already exists. - if aerr.StatusCode == http.StatusBadRequest { - if aerr.ErrorCode == "RESOURCE_ALREADY_EXISTS" { + if aerr.HTTPStatusCode() == http.StatusBadRequest { + if apierrs.ErrorCode(aerr) == "RESOURCE_ALREADY_EXISTS" { return fileAlreadyExistsError{absPath} } } @@ -146,7 +150,7 @@ func (w *DbfsClient) Read(ctx context.Context, name string) (io.ReadCloser, erro return nil, err } - handle, err := w.workspaceClient.Dbfs.Open(ctx, absPath, files.FileModeRead) + handle, err := dbfs.Open(ctx, w.workspaceClient.Files, absPath, dbfs.FileModeRead) if err != nil { // Return error if file is a directory if strings.Contains(err.Error(), "cannot open directory for reading") { @@ -159,8 +163,8 @@ func (w *DbfsClient) Read(ctx context.Context, name string) (io.ReadCloser, erro } // This API returns a 404 if the file doesn't exist. - if aerr.StatusCode == http.StatusNotFound { - if aerr.ErrorCode == "RESOURCE_DOES_NOT_EXIST" { + if aerr.HTTPStatusCode() == http.StatusNotFound { + if apierrs.ErrorCode(aerr) == "RESOURCE_DOES_NOT_EXIST" { return nil, fileDoesNotExistError{absPath} } } @@ -188,7 +192,7 @@ func (w *DbfsClient) Delete(ctx context.Context, name string, mode ...DeleteMode // For discussion: we could decide this is actually convenient, remove the call below, // and apply the same semantics for the WSFS filer. // - _, err = w.workspaceClient.Dbfs.GetStatusByPath(ctx, absPath) + _, err = w.workspaceClient.Files.GetStatus(ctx, files.GetStatusRequest{Path: new(absPath)}) if err != nil { aerr, ok := errors.AsType[*apierr.APIError](err) if !ok { @@ -196,8 +200,8 @@ func (w *DbfsClient) Delete(ctx context.Context, name string, mode ...DeleteMode } // This API returns a 404 if the file doesn't exist. - if aerr.StatusCode == http.StatusNotFound { - if aerr.ErrorCode == "RESOURCE_DOES_NOT_EXIST" { + if aerr.HTTPStatusCode() == http.StatusNotFound { + if apierrs.ErrorCode(aerr) == "RESOURCE_DOES_NOT_EXIST" { return fileDoesNotExistError{absPath} } } @@ -207,9 +211,9 @@ func (w *DbfsClient) Delete(ctx context.Context, name string, mode ...DeleteMode recursive := slices.Contains(mode, DeleteRecursively) - err = w.workspaceClient.Dbfs.Delete(ctx, files.Delete{ - Path: absPath, - Recursive: recursive, + _, err = w.workspaceClient.Files.Delete(ctx, files.DeleteRequest{ + Path: new(absPath), + Recursive: new(recursive), }) // Return early on success. @@ -223,16 +227,16 @@ func (w *DbfsClient) Delete(ctx context.Context, name string, mode ...DeleteMode return err } - switch aerr.StatusCode { + switch aerr.HTTPStatusCode() { case http.StatusBadRequest: // Anecdotally, this error is returned when attempting to delete a non-empty directory. - if aerr.ErrorCode == "IO_ERROR" { + if apierrs.ErrorCode(aerr) == "IO_ERROR" { return directoryNotEmptyError{absPath} } // Since 17th december we are observing the backend return an error_code of BAD_REQUEST // instead of IO_ERROR. Doing direct comparison on the error string instead. - if strings.Contains(aerr.Message, "Directory is not empty. Use recursive delete or remove contents first.") { + if strings.Contains(aerr.Message(), "Directory is not empty. Use recursive delete or remove contents first.") { return directoryNotEmptyError{absPath} } } @@ -246,7 +250,7 @@ func (w *DbfsClient) ReadDir(ctx context.Context, name string) ([]fs.DirEntry, e return nil, err } - res, err := w.workspaceClient.Dbfs.ListByPath(ctx, absPath) + res, err := w.workspaceClient.Files.List(ctx, files.ListStatusRequest{Path: new(absPath)}) if err != nil { aerr, ok := errors.AsType[*apierr.APIError](err) if !ok { @@ -254,8 +258,8 @@ func (w *DbfsClient) ReadDir(ctx context.Context, name string) ([]fs.DirEntry, e } // This API returns a 404 if the file doesn't exist. - if aerr.StatusCode == http.StatusNotFound { - if aerr.ErrorCode == "RESOURCE_DOES_NOT_EXIST" { + if aerr.HTTPStatusCode() == http.StatusNotFound { + if apierrs.ErrorCode(aerr) == "RESOURCE_DOES_NOT_EXIST" { return nil, noSuchDirectoryError{absPath} } } @@ -263,7 +267,7 @@ func (w *DbfsClient) ReadDir(ctx context.Context, name string) ([]fs.DirEntry, e return nil, err } - if len(res.Files) == 1 && res.Files[0].Path == absPath { + if len(res.Files) == 1 && utils.Deref(res.Files[0].Path) == absPath { return nil, notADirectory{absPath} } @@ -283,7 +287,8 @@ func (w *DbfsClient) Mkdir(ctx context.Context, name string) error { return err } - return w.workspaceClient.Dbfs.MkdirsByPath(ctx, dirPath) + _, err = w.workspaceClient.Files.Mkdirs(ctx, files.MkDirsRequest{Path: new(dirPath)}) + return err } func (w *DbfsClient) Stat(ctx context.Context, name string) (fs.FileInfo, error) { @@ -292,7 +297,7 @@ func (w *DbfsClient) Stat(ctx context.Context, name string) (fs.FileInfo, error) return nil, err } - info, err := w.workspaceClient.Dbfs.GetStatusByPath(ctx, absPath) + info, err := w.workspaceClient.Files.GetStatus(ctx, files.GetStatusRequest{Path: new(absPath)}) if err != nil { aerr, ok := errors.AsType[*apierr.APIError](err) if !ok { @@ -300,8 +305,8 @@ func (w *DbfsClient) Stat(ctx context.Context, name string) (fs.FileInfo, error) } // This API returns a 404 if the file doesn't exist. - if aerr.StatusCode == http.StatusNotFound { - if aerr.ErrorCode == "RESOURCE_DOES_NOT_EXIST" { + if aerr.HTTPStatusCode() == http.StatusNotFound { + if apierrs.ErrorCode(aerr) == "RESOURCE_DOES_NOT_EXIST" { return nil, fileDoesNotExistError{absPath} } } @@ -309,5 +314,5 @@ func (w *DbfsClient) Stat(ctx context.Context, name string) (fs.FileInfo, error) return nil, err } - return dbfsFileInfo{*info}, nil + return dbfsFileInfo{files.FileInfo{Path: info.Path, IsDir: info.IsDir, FileSize: info.FileSize, ModificationTime: info.ModificationTime}}, nil } diff --git a/libs/filer/errors_test.go b/libs/filer/errors_test.go index e12fe946450..2bd24b4b754 100644 --- a/libs/filer/errors_test.go +++ b/libs/filer/errors_test.go @@ -4,7 +4,8 @@ import ( "io/fs" "testing" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/sdk-go/core/apierr" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -100,12 +101,12 @@ func TestPermissionError_Error(t *testing.T) { func TestPermissionError_Unwrap(t *testing.T) { // A wrapped API error must remain matchable as fs.ErrPermission while also // being reachable via errors.As so callers can inspect its error_code. - apiErr := &apierr.APIError{StatusCode: 403, ErrorCode: "MAX_CHILD_NODE_SIZE_EXCEEDED"} + apiErr := apierr.FromHTTPError(403, nil, []byte(`{"error_code":"MAX_CHILD_NODE_SIZE_EXCEEDED"}`)) err := permissionError{path: "/test/path", err: apiErr} assert.ErrorIs(t, err, fs.ErrPermission) var got *apierr.APIError require.ErrorAs(t, err, &got) - assert.Equal(t, "MAX_CHILD_NODE_SIZE_EXCEEDED", got.ErrorCode) + assert.Equal(t, "MAX_CHILD_NODE_SIZE_EXCEEDED", apierrs.ErrorCode(got)) } diff --git a/libs/filer/files_client.go b/libs/filer/files_client.go index 1638acb73bd..1e792b0eb32 100644 --- a/libs/filer/files_client.go +++ b/libs/filer/files_client.go @@ -11,9 +11,10 @@ import ( "slices" "time" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/databrickscfg/profile" "github.com/databricks/cli/libs/env" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/databricks-sdk-go/config" "github.com/databricks/sdk-go/core/apierr" files "github.com/databricks/sdk-go/files/v2" @@ -154,7 +155,7 @@ type FilesClient struct { transferClient *http.Client } -func NewFilesClient(ctx context.Context, w *databricks.WorkspaceClient, root string) (Filer, error) { +func NewFilesClient(ctx context.Context, w *sdkclients.Clients, root string) (Filer, error) { c, err := newFilesAPIClient(ctx, w.Config) if err != nil { return nil, err @@ -192,7 +193,7 @@ func newTransferClient(n int) *http.Client { func newFilesAPIClient(ctx context.Context, cfg *config.Config) (*files.Client, error) { copts := []client.Option{ client.WithHost(cfg.Host), - client.WithCredentials(configCredentials{cfg: cfg}), + client.WithCredentials(apiclient.NewCredentials(cfg)), client.WithoutConfigFile(), client.WithoutEnv(), } diff --git a/libs/filer/files_client_test.go b/libs/filer/files_client_test.go index c259d4a9f14..7997c9b3151 100644 --- a/libs/filer/files_client_test.go +++ b/libs/filer/files_client_test.go @@ -13,8 +13,9 @@ import ( cliauth "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/databrickscfg/profile" "github.com/databricks/cli/libs/env" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/databricks-sdk-go/config" files "github.com/databricks/sdk-go/files/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -28,7 +29,7 @@ func TestNewFilesAPIClientDoesNotResolveAmbientConfig(t *testing.T) { return "" }) - workspaceClient, err := databricks.NewWorkspaceClient(&databricks.Config{ + workspaceClient, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "resolved-token", WorkspaceID: profile.WorkspaceIDNone, @@ -89,7 +90,7 @@ func deleteDirectoryWithError(t *testing.T, statusCode int, errorCode, reason st }) testserver.AddDefaultHandlers(server) - client, err := databricks.NewWorkspaceClient(&databricks.Config{ + client, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", }) @@ -120,7 +121,7 @@ func newTestFilesClient(t *testing.T) Filer { server := testserver.New(t) testserver.AddDefaultHandlers(server) - client, err := databricks.NewWorkspaceClient(&databricks.Config{ + client, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", }) diff --git a/libs/filer/workspace_files_cache.go b/libs/filer/workspace_files_cache.go index 3f7175f0486..de33fc333b4 100644 --- a/libs/filer/workspace_files_cache.go +++ b/libs/filer/workspace_files_cache.go @@ -11,7 +11,7 @@ import ( "time" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go/service/workspace" + workspace "github.com/databricks/cli/libs/workspaceapi" ) // This readahead cache is designed to optimize file system operations by caching the results of diff --git a/libs/filer/workspace_files_cache_test.go b/libs/filer/workspace_files_cache_test.go index 38d028ac8ba..db88cc9451b 100644 --- a/libs/filer/workspace_files_cache_test.go +++ b/libs/filer/workspace_files_cache_test.go @@ -7,7 +7,7 @@ import ( "io/fs" "testing" - "github.com/databricks/databricks-sdk-go/service/workspace" + workspace "github.com/databricks/cli/libs/workspaceapi" "github.com/stretchr/testify/assert" ) diff --git a/libs/filer/workspace_files_client.go b/libs/filer/workspace_files_client.go index f6a32369f88..4aa076b8a91 100644 --- a/libs/filer/workspace_files_client.go +++ b/libs/filer/workspace_files_client.go @@ -15,13 +15,13 @@ import ( "strings" "time" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/notebook" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/marshal" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdkclients" + workspace "github.com/databricks/cli/libs/workspaceapi" + "github.com/databricks/sdk-go/core/apierr" ) // Type that implements fs.DirEntry for WSFS. @@ -89,26 +89,11 @@ func (info wsfsFileInfo) WorkspaceObjectInfo() workspace.ObjectInfo { return info.ObjectInfo } -// UnmarshalJSON is a custom unmarshaller for the wsfsFileInfo struct. -// It must be defined for this type because otherwise the implementation -// of the embedded ObjectInfo type will be used. -func (info *wsfsFileInfo) UnmarshalJSON(b []byte) error { - return marshal.Unmarshal(b, info) -} - -// MarshalJSON is a custom marshaller for the wsfsFileInfo struct. -// It must be defined for this type because otherwise the implementation -// of the embedded ObjectInfo type will be used. -func (info *wsfsFileInfo) MarshalJSON() ([]byte, error) { - return marshal.Marshal(info) -} - -// Interface for *client.DatabricksClient from the Databricks Go SDK. Abstracted -// as an interface to allow for mocking in tests. +// Interface for *apiclient.Client. Abstracted as an interface to allow for +// mocking in tests. type apiClient interface { Do(ctx context.Context, method, path string, - headers map[string]string, queryString map[string]any, request, response any, - visitors ...func(*http.Request) error) error + headers map[string]string, queryString map[string]any, request, response any) error } // Extensions that format=AUTO imports as the same asset type the legacy import-file @@ -149,7 +134,7 @@ func importRequest(absPath string, content []byte) (string, []workspace.UploadOp // NOTE: This API is available for files under /Repos if a workspace has files-in-repos enabled. // It can access any workspace path if files-in-workspace is enabled. type WorkspaceFilesClient struct { - workspaceClient *databricks.WorkspaceClient + workspaceClient *sdkclients.Clients apiClient apiClient // File operations will be relative to this path. @@ -168,8 +153,8 @@ func (w *WorkspaceFilesClient) workspaceIDHeaders() map[string]string { return auth.WorkspaceIDHeaders(w.workspaceClient.Config) } -func NewWorkspaceFilesClient(w *databricks.WorkspaceClient, root string) (Filer, error) { - apiClient, err := client.New(w.Config) +func NewWorkspaceFilesClient(w *sdkclients.Clients, root string) (Filer, error) { + apiClient, err := apiclient.New(w.Config) if err != nil { return nil, err } @@ -221,7 +206,7 @@ func (w *WorkspaceFilesClient) Write(ctx context.Context, name string, reader io } // Parent directory does not exist. - if errors.Is(err, apierr.ErrNotFound) { + if apierrs.Is(err, apierrs.ErrNotFound) { if !slices.Contains(mode, CreateParentDirectories) { return noSuchDirectoryError{path.Dir(absPath)} } @@ -229,7 +214,7 @@ func (w *WorkspaceFilesClient) Write(ctx context.Context, name string, reader io // Create parent directory. err = w.workspaceClient.Workspace.MkdirsByPath(ctx, path.Dir(absPath)) if err != nil { - if errors.Is(err, apierr.ErrPermissionDenied) { + if apierrs.Is(err, apierrs.ErrPermissionDenied) { return permissionError{absPath, err} } return fmt.Errorf("unable to mkdir to write file %s: %w", absPath, err) @@ -242,22 +227,22 @@ func (w *WorkspaceFilesClient) Write(ctx context.Context, name string, reader io // Path already taken. ErrResourceConflict covers every 409 (including the // bare 409 with only a message); ErrResourceAlreadyExists covers the 400 // RESOURCE_ALREADY_EXISTS, which no status maps to a conflict. - if errors.Is(err, apierr.ErrResourceConflict) || errors.Is(err, apierr.ErrResourceAlreadyExists) { + if apierrs.Is(err, apierrs.ErrResourceConflict) || apierrs.Is(err, apierrs.ErrResourceAlreadyExists) { return fileAlreadyExistsError{absPath} } // Overwrite rejected because the existing object's node type differs from // the upload. The collision carries an AIP-193 ErrorInfo with a stable // reason, so branch on it rather than the message text. - if errors.Is(err, apierr.ErrInvalidParameterValue) { + if apierrs.Is(err, apierrs.ErrInvalidParameterValue) { if aerr, ok := errors.AsType[*apierr.APIError](err); ok { - if info := aerr.ErrorDetails().ErrorInfo; info != nil && info.Reason == "WORKSPACE_OBJECT_TYPE_MISMATCH" { + if info := aerr.Details().ErrorInfo; info != nil && info.Reason == "WORKSPACE_OBJECT_TYPE_MISMATCH" { return fileAlreadyExistsError{absPath} } } } // Caller has read access but no write access. - if errors.Is(err, apierr.ErrPermissionDenied) { + if apierrs.Is(err, apierrs.ErrPermissionDenied) { return permissionError{absPath, err} } @@ -320,9 +305,9 @@ func (w *WorkspaceFilesClient) Delete(ctx context.Context, name string, mode ... return err } - switch aerr.StatusCode { + switch aerr.HTTPStatusCode() { case http.StatusBadRequest: - if aerr.ErrorCode == "DIRECTORY_NOT_EMPTY" { + if apierrs.ErrorCode(aerr) == "DIRECTORY_NOT_EMPTY" { return directoryNotEmptyError{absPath} } case http.StatusNotFound: @@ -355,7 +340,7 @@ func (w *WorkspaceFilesClient) ReadDir(ctx context.Context, name string) ([]fs.D // NOTE: This API returns a 404 if the specified path does not exist, // but can also do so if we don't have read access. - if aerr.StatusCode == http.StatusNotFound { + if aerr.HTTPStatusCode() == http.StatusNotFound { return nil, noSuchDirectoryError{path.Dir(absPath)} } return nil, err @@ -406,7 +391,7 @@ func (w *WorkspaceFilesClient) Stat(ctx context.Context, name string) (fs.FileIn } // This API returns a 404 if the specified path does not exist. - if aerr.StatusCode == http.StatusNotFound { + if aerr.HTTPStatusCode() == http.StatusNotFound { return nil, fileDoesNotExistError{absPath} } diff --git a/libs/filer/workspace_files_client_test.go b/libs/filer/workspace_files_client_test.go index 81832694d15..8c08cbcb77f 100644 --- a/libs/filer/workspace_files_client_test.go +++ b/libs/filer/workspace_files_client_test.go @@ -9,11 +9,11 @@ import ( "testing" "time" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" + workspace "github.com/databricks/cli/libs/workspaceapi" "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/sdk-go/core/apierr" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -88,7 +88,7 @@ func TestWorkspaceFilesClientWorkspaceIDHeaders(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { w := &WorkspaceFilesClient{ - workspaceClient: &databricks.WorkspaceClient{ + workspaceClient: &sdkclients.Clients{ Config: &config.Config{ WorkspaceID: tc.workspaceID, }, @@ -113,17 +113,17 @@ func TestWorkspaceFilesClientWriteErrorMapping(t *testing.T) { tests := []struct { name string mode []WriteMode - apiErr *apierr.APIError + apiErr apiErrorSpec expectErrTarget any }{ { name: "404 without create-parent maps to noSuchDirectoryError", - apiErr: &apierr.APIError{StatusCode: http.StatusNotFound, Message: "not found"}, + apiErr: apiErrorSpec{StatusCode: http.StatusNotFound, Message: "not found"}, expectErrTarget: noSuchDirectoryError{}, }, { name: "400 RESOURCE_ALREADY_EXISTS maps to fileAlreadyExistsError", - apiErr: &apierr.APIError{ + apiErr: apiErrorSpec{ StatusCode: http.StatusBadRequest, ErrorCode: "RESOURCE_ALREADY_EXISTS", Message: "/dir/file.txt already exists. Please pass overwrite=true to overwrite it.", @@ -132,7 +132,7 @@ func TestWorkspaceFilesClientWriteErrorMapping(t *testing.T) { }, { name: "409 ALREADY_EXISTS (concurrent contention) maps to fileAlreadyExistsError", - apiErr: &apierr.APIError{ + apiErr: apiErrorSpec{ StatusCode: http.StatusConflict, ErrorCode: "ALREADY_EXISTS", Message: "Node with name /dir/file.txt already exists. Please pass overwrite=true to update it.", @@ -143,7 +143,7 @@ func TestWorkspaceFilesClientWriteErrorMapping(t *testing.T) { // A 409 carrying no error_code unwraps to ErrResourceConflict only, // not to ErrAlreadyExists; the testserver returns exactly this shape. name: "409 without error_code maps to fileAlreadyExistsError", - apiErr: &apierr.APIError{ + apiErr: apiErrorSpec{ StatusCode: http.StatusConflict, Message: "Node with name /dir/file.txt already exists.", }, @@ -151,7 +151,7 @@ func TestWorkspaceFilesClientWriteErrorMapping(t *testing.T) { }, { name: "400 INVALID_PARAMETER_VALUE other message passes through", - apiErr: &apierr.APIError{ + apiErr: apiErrorSpec{ StatusCode: http.StatusBadRequest, ErrorCode: "INVALID_PARAMETER_VALUE", Message: "some other validation failure", @@ -160,12 +160,12 @@ func TestWorkspaceFilesClientWriteErrorMapping(t *testing.T) { }, { name: "403 maps to permissionError", - apiErr: &apierr.APIError{StatusCode: http.StatusForbidden, Message: "denied"}, + apiErr: apiErrorSpec{StatusCode: http.StatusForbidden, Message: "denied"}, expectErrTarget: permissionError{}, }, { name: "500 passes through", - apiErr: &apierr.APIError{StatusCode: http.StatusInternalServerError, Message: "boom"}, + apiErr: apiErrorSpec{StatusCode: http.StatusInternalServerError, Message: "boom"}, expectErrTarget: nil, }, } @@ -184,7 +184,7 @@ func TestWorkspaceFilesClientWriteErrorMapping(t *testing.T) { }) testserver.AddDefaultHandlers(server) - client, err := databricks.NewWorkspaceClient(&databricks.Config{ + client, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", }) @@ -207,13 +207,20 @@ func TestWorkspaceFilesClientWriteErrorMapping(t *testing.T) { // and the message names the file that failed to upload. var aerr *apierr.APIError require.ErrorAs(t, err, &aerr) - assert.Equal(t, tc.apiErr.StatusCode, aerr.StatusCode) + assert.Equal(t, tc.apiErr.StatusCode, aerr.HTTPStatusCode()) assert.Contains(t, err.Error(), "/dir/file.txt") } }) } } +// apiErrorSpec describes an error response for a test server to return. +type apiErrorSpec struct { + StatusCode int + ErrorCode string + Message string +} + // writeWithImportError exercises Write through a real HTTP roundtrip so the // SDK parses AIP-193 error details from the response body (the errorDetails // field on apierr.APIError is unexported and only populated during response @@ -230,7 +237,7 @@ func writeWithImportError(t *testing.T, body map[string]any) error { }) testserver.AddDefaultHandlers(server) - client, err := databricks.NewWorkspaceClient(&databricks.Config{ + client, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", }) @@ -281,7 +288,7 @@ func TestWorkspaceFilesClientWriteUnrelatedReasonPassesThrough(t *testing.T) { }) var aerr *apierr.APIError require.ErrorAs(t, err, &aerr) - assert.Equal(t, http.StatusBadRequest, aerr.StatusCode) + assert.Equal(t, http.StatusBadRequest, aerr.HTTPStatusCode()) } // Confirms a workspace get-status payload unmarshals into wsfsFileInfo and that @@ -338,7 +345,7 @@ func statWithError(t *testing.T, statusCode int, errorCode string) error { }) testserver.AddDefaultHandlers(server) - client, err := databricks.NewWorkspaceClient(&databricks.Config{ + client, err := sdkclients.New(t.Context(), &config.Config{ Host: server.URL, Token: "testtoken", }) @@ -358,7 +365,7 @@ func TestWorkspaceFilesClientStatForbidden(t *testing.T) { err := statWithError(t, 403, "PERMISSION_DENIED") var apiErr *apierr.APIError require.ErrorAs(t, err, &apiErr) - assert.Equal(t, 403, apiErr.StatusCode) + assert.Equal(t, 403, apiErr.HTTPStatusCode()) } // Confirms a 500 from get-status surfaces as an APIError and is not treated as @@ -367,7 +374,7 @@ func TestWorkspaceFilesClientStatInternalError(t *testing.T) { err := statWithError(t, 500, "INTERNAL_ERROR") var apiErr *apierr.APIError require.ErrorAs(t, err, &apiErr) - assert.Equal(t, 500, apiErr.StatusCode) + assert.Equal(t, 500, apiErr.HTTPStatusCode()) } // Confirms RESOURCE_DOES_NOT_EXIST maps to fs.ErrNotExist so the filer plugs diff --git a/libs/filer/workspace_files_extensions_client.go b/libs/filer/workspace_files_extensions_client.go index 29adbdbddf6..75bbf86f076 100644 --- a/libs/filer/workspace_files_extensions_client.go +++ b/libs/filer/workspace_files_extensions_client.go @@ -12,12 +12,12 @@ import ( "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/notebook" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdkclients" + workspace "github.com/databricks/cli/libs/workspaceapi" ) type WorkspaceFilesExtensionsClient struct { - workspaceClient *databricks.WorkspaceClient + workspaceClient *sdkclients.Clients wsfs Filer root string @@ -172,7 +172,7 @@ func (e ReadOnlyError) Error() string { // The underlying import API we use to upload notebooks and files returns opaque internal // errors for namespace clashes (e.g. a file and a notebook or a directory and a notebook). // Thus users of these methods should be careful to avoid such clashes. -func NewWorkspaceFilesExtensionsClient(w *databricks.WorkspaceClient, root string) (Filer, error) { +func NewWorkspaceFilesExtensionsClient(w *sdkclients.Clients, root string) (Filer, error) { filer, err := NewWorkspaceFilesClient(w, root) if err != nil { return nil, err @@ -187,7 +187,7 @@ func NewWorkspaceFilesExtensionsClient(w *databricks.WorkspaceClient, root strin }, nil } -func NewReadOnlyWorkspaceFilesExtensionsClient(ctx context.Context, w *databricks.WorkspaceClient, root string) (Filer, error) { +func NewReadOnlyWorkspaceFilesExtensionsClient(ctx context.Context, w *sdkclients.Clients, root string) (Filer, error) { filer, err := NewWorkspaceFilesClient(w, root) if err != nil { return nil, err diff --git a/libs/filer/workspace_files_extensions_client_test.go b/libs/filer/workspace_files_extensions_client_test.go index 6d7c37a9ada..54876e1acc2 100644 --- a/libs/filer/workspace_files_extensions_client_test.go +++ b/libs/filer/workspace_files_extensions_client_test.go @@ -5,22 +5,23 @@ import ( "net/http" "testing" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/httpfixtures" + "github.com/databricks/cli/libs/sdkclients" + workspace "github.com/databricks/cli/libs/workspaceapi" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" ) -// Mocks client.DatabricksClient from the databricks-sdk-go package. +// Mocks the apiClient interface (*apiclient.Client). type mockApiClient struct { mock.Mock } func (m *mockApiClient) Do(ctx context.Context, method, path string, headers map[string]string, queryString map[string]any, request, response any, - visitors ...func(*http.Request) error, ) error { - args := m.Called(ctx, method, path, headers, request, response, visitors) + args := m.Called(ctx, method, path, headers, request, response) // Set the http response from a value provided in the mock call. p := response.(*wsfsFileInfo) @@ -139,25 +140,27 @@ func TestFilerWorkspaceFilesExtensionsErrorsOnDupName(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - mockedWorkspaceClient := mocks.NewMockWorkspaceClient(t) mockedApiClient := mockApiClient{} - // Mock the workspace API's ListAll method. - workspaceApi := mockedWorkspaceClient.GetMockWorkspaceAPI() - workspaceApi.EXPECT().ListAll(mock.Anything, workspace.ListWorkspaceRequest{ - Path: "/dir", - }).Return([]workspace.ObjectInfo{ - { - Path: tc.filePath, - Language: tc.language, - ObjectType: workspace.ObjectTypeFile, - }, - { - Path: tc.notebookPath, - Language: tc.language, - ObjectType: workspace.ObjectTypeNotebook, - }, - }, nil) + // Serve the workspace list call made by ReadDir. + cfg, _ := httpfixtures.Fixtures{{ + Method: "GET", + Resource: "/api/2.0/workspace/list?path=%2Fdir", + Response: workspace.ListResponse{Objects: []workspace.ObjectInfo{ + { + Path: tc.filePath, + Language: tc.language, + ObjectType: workspace.ObjectTypeFile, + }, + { + Path: tc.notebookPath, + Language: tc.language, + ObjectType: workspace.ObjectTypeNotebook, + }, + }}, + }}.Config(t) + workspaceClient, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) // Mock bespoke API calls to /api/2.0/workspace/get-status, that are // used to figure out the right file extension for the notebook. @@ -171,20 +174,20 @@ func TestFilerWorkspaceFilesExtensionsErrorsOnDupName(t *testing.T) { mockedApiClient.On("Do", mock.Anything, http.MethodGet, "/api/2.0/workspace/get-status", map[string]string(nil), map[string]string{ "path": tc.notebookPath, "return_export_info": "true", - }, mock.AnythingOfType("*filer.wsfsFileInfo"), []func(*http.Request) error(nil)).Return(nil, statNotebook) + }, mock.AnythingOfType("*filer.wsfsFileInfo")).Return(nil, statNotebook) workspaceFilesClient := WorkspaceFilesClient{ - workspaceClient: mockedWorkspaceClient.WorkspaceClient, + workspaceClient: workspaceClient, apiClient: &mockedApiClient, root: NewWorkspaceRootPath("/dir"), } workspaceFilesExtensionsClient := WorkspaceFilesExtensionsClient{ - workspaceClient: mockedWorkspaceClient.WorkspaceClient, + workspaceClient: workspaceClient, wsfs: &workspaceFilesClient, } - _, err := workspaceFilesExtensionsClient.ReadDir(t.Context(), "/") + _, err = workspaceFilesExtensionsClient.ReadDir(t.Context(), "/") if tc.expectedError == "" { assert.NoError(t, err) @@ -194,7 +197,6 @@ func TestFilerWorkspaceFilesExtensionsErrorsOnDupName(t *testing.T) { } // assert the mocked methods were actually called, as a sanity check. - workspaceApi.AssertNumberOfCalls(t, "ListAll", 1) mockedApiClient.AssertNumberOfCalls(t, "Do", 1) }) } @@ -227,23 +229,26 @@ func TestFilerWorkspaceFilesExtensionsReadDirWithUnmappedLanguage(t *testing.T) }, } { t.Run(tc.name, func(t *testing.T) { - mockedWorkspaceClient := mocks.NewMockWorkspaceClient(t) mockedApiClient := mockApiClient{} - workspaceApi := mockedWorkspaceClient.GetMockWorkspaceAPI() - workspaceApi.EXPECT().ListAll(mock.Anything, workspace.ListWorkspaceRequest{ - Path: "/dir", - }).Return([]workspace.ObjectInfo{ - { - Path: "/dir/bar.py", - ObjectType: workspace.ObjectTypeFile, - }, - { - Path: "/dir/foo", - Language: tc.language, - ObjectType: workspace.ObjectTypeNotebook, - }, - }, nil) + // Serve the workspace list call made by ReadDir. + cfg, _ := httpfixtures.Fixtures{{ + Method: "GET", + Resource: "/api/2.0/workspace/list?path=%2Fdir", + Response: workspace.ListResponse{Objects: []workspace.ObjectInfo{ + { + Path: "/dir/bar.py", + ObjectType: workspace.ObjectTypeFile, + }, + { + Path: "/dir/foo", + Language: tc.language, + ObjectType: workspace.ObjectTypeNotebook, + }, + }}, + }}.Config(t) + workspaceClient, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) // Mock the get-status call used to figure out the notebook's file extension. statNotebook := wsfsFileInfo{ @@ -256,16 +261,16 @@ func TestFilerWorkspaceFilesExtensionsReadDirWithUnmappedLanguage(t *testing.T) mockedApiClient.On("Do", mock.Anything, http.MethodGet, "/api/2.0/workspace/get-status", map[string]string(nil), map[string]string{ "path": "/dir/foo", "return_export_info": "true", - }, mock.AnythingOfType("*filer.wsfsFileInfo"), []func(*http.Request) error(nil)).Return(nil, statNotebook) + }, mock.AnythingOfType("*filer.wsfsFileInfo")).Return(nil, statNotebook) workspaceFilesClient := WorkspaceFilesClient{ - workspaceClient: mockedWorkspaceClient.WorkspaceClient, + workspaceClient: workspaceClient, apiClient: &mockedApiClient, root: NewWorkspaceRootPath("/dir"), } workspaceFilesExtensionsClient := WorkspaceFilesExtensionsClient{ - workspaceClient: mockedWorkspaceClient.WorkspaceClient, + workspaceClient: workspaceClient, wsfs: &workspaceFilesClient, } @@ -278,7 +283,6 @@ func TestFilerWorkspaceFilesExtensionsReadDirWithUnmappedLanguage(t *testing.T) } assert.Equal(t, tc.expectedNames, names) - workspaceApi.AssertNumberOfCalls(t, "ListAll", 1) mockedApiClient.AssertNumberOfCalls(t, "Do", 1) }) } diff --git a/libs/flags/json_flag.go b/libs/flags/json_flag.go index 3ea4834a5f2..f0df8a3b86f 100644 --- a/libs/flags/json_flag.go +++ b/libs/flags/json_flag.go @@ -10,7 +10,6 @@ import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn/convert" "github.com/databricks/cli/libs/dyn/jsonloader" - "github.com/databricks/databricks-sdk-go/marshal" ) type JsonFlag struct { @@ -91,24 +90,10 @@ func (j *JsonFlag) Unmarshal(v any) diag.Diagnostics { return diags.Extend(diag.FromErr(err)) } - kind := reflect.ValueOf(v).Kind() - if kind == reflect.Pointer { - kind = reflect.ValueOf(v).Elem().Kind() - } - - if kind == reflect.Struct { - // Finally unmarshal the normalized data to the output. - // It will fill in the ForceSendFields field if the struct contains it. - err = marshal.Unmarshal(data, v) - if err != nil { - return diags.Extend(diag.FromErr(err)) - } - } else { - // If the output is not a struct, just unmarshal the data to the output. - err = json.Unmarshal(data, v) - if err != nil { - return diags.Extend(diag.FromErr(err)) - } + // Finally unmarshal the normalized data to the output. + err = json.Unmarshal(data, v) + if err != nil { + return diags.Extend(diag.FromErr(err)) } return diags diff --git a/libs/flags/json_flag_test.go b/libs/flags/json_flag_test.go index 675e1014922..8cbf0977df7 100644 --- a/libs/flags/json_flag_test.go +++ b/libs/flags/json_flag_test.go @@ -7,8 +7,8 @@ import ( "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -131,7 +131,7 @@ const jsonData = ` func TestJsonUnmarshalForRequest(t *testing.T) { var body JsonFlag - var r jobs.ResetJob + var r jobs.ResetJobRequest err := body.Set(jsonData) require.NoError(t, err) @@ -139,16 +139,16 @@ func TestJsonUnmarshalForRequest(t *testing.T) { assert.NoError(t, diags.Error()) assert.Empty(t, diags) - assert.Equal(t, int64(123), r.JobId) - assert.Equal(t, "new job", r.NewSettings.Name) - assert.Equal(t, 0, r.NewSettings.TimeoutSeconds) - assert.Equal(t, 1, r.NewSettings.MaxConcurrentRuns) + assert.Equal(t, new(int64(123)), r.JobId) + assert.Equal(t, new("new job"), r.NewSettings.Name) + assert.Equal(t, new(0), r.NewSettings.TimeoutSeconds) + assert.Equal(t, new(1), r.NewSettings.MaxConcurrentRuns) assert.Len(t, r.NewSettings.Tasks, 1) - assert.Equal(t, "new task", r.NewSettings.Tasks[0].TaskKey) - assert.Equal(t, 0, r.NewSettings.Tasks[0].TimeoutSeconds) - assert.Equal(t, 0, r.NewSettings.Tasks[0].MaxRetries) - assert.Equal(t, 0, r.NewSettings.Tasks[0].MinRetryIntervalMillis) - assert.True(t, r.NewSettings.Tasks[0].RetryOnTimeout) + assert.Equal(t, new("new task"), r.NewSettings.Tasks[0].TaskKey) + assert.Equal(t, new(0), r.NewSettings.Tasks[0].TimeoutSeconds) + assert.Equal(t, new(0), r.NewSettings.Tasks[0].MaxRetries) + assert.Equal(t, new(0), r.NewSettings.Tasks[0].MinRetryIntervalMillis) + assert.Equal(t, new(true), r.NewSettings.Tasks[0].RetryOnTimeout) } const incorrectJsonData = `{ @@ -184,7 +184,7 @@ const incorrectJsonData = `{ func TestJsonUnmarshalRequestMismatch(t *testing.T) { var body JsonFlag - var r jobs.ResetJob + var r jobs.ResetJobRequest err := body.Set(incorrectJsonData) require.NoError(t, err) @@ -239,7 +239,7 @@ const wrontTypeJsonData = `{ func TestJsonUnmarshalWrongTypeReportsCorrectLocation(t *testing.T) { var body JsonFlag - var r jobs.ResetJob + var r jobs.ResetJobRequest err := body.Set(`{ "job_id": [1, 2, 3] } @@ -267,7 +267,7 @@ func TestJsonUnmarshalWrongTypeReportsCorrectLocation(t *testing.T) { func TestJsonUnmarshalArrayInsteadOfIntReportsCorrectLocation(t *testing.T) { var body JsonFlag - var r jobs.ResetJob + var r jobs.ResetJobRequest err := body.Set(wrontTypeJsonData) require.NoError(t, err) @@ -289,10 +289,10 @@ func TestJsonUnmarshalArrayInsteadOfIntReportsCorrectLocation(t *testing.T) { }) } -func TestJsonUnmarshalForRequestWithForceSendFields(t *testing.T) { +func TestJsonUnmarshalForRequestExplicitZeroValues(t *testing.T) { var body JsonFlag - var r jobs.ResetJob + var r jobs.ResetJobRequest err := body.Set(jsonData) require.NoError(t, err) @@ -300,10 +300,9 @@ func TestJsonUnmarshalForRequestWithForceSendFields(t *testing.T) { assert.NoError(t, diags.Error()) assert.Empty(t, diags) - assert.False(t, r.NewSettings.NotificationSettings.NoAlertForSkippedRuns) - assert.False(t, r.NewSettings.NotificationSettings.NoAlertForCanceledRuns) - assert.NotContains(t, r.NewSettings.NotificationSettings.ForceSendFields, "NoAlertForSkippedRuns") - assert.Contains(t, r.NewSettings.NotificationSettings.ForceSendFields, "NoAlertForCanceledRuns") + // Unset fields stay nil, explicit zero values are kept so they are sent. + assert.Nil(t, r.NewSettings.NotificationSettings.NoAlertForSkippedRuns) + assert.Equal(t, new(false), r.NewSettings.NotificationSettings.NoAlertForCanceledRuns) } func TestRejectWrappedJSON(t *testing.T) { diff --git a/libs/flags/optional.go b/libs/flags/optional.go new file mode 100644 index 00000000000..9a5fb717f34 --- /dev/null +++ b/libs/flags/optional.go @@ -0,0 +1,164 @@ +package flags + +import ( + "encoding/base64" + "encoding/json" + "fmt" + "slices" + "strconv" + "strings" + + "github.com/spf13/pflag" +) + +// optionalValue is a flag bound to an optional (pointer) request field. The +// pointer stays nil unless the flag is set, so unset flags are not sent. +type optionalValue[T any] struct { + p **T + typ string + parse func(string) (T, error) +} + +func (v *optionalValue[T]) String() string { + if *v.p == nil { + switch v.typ { + case "bool": + return "false" + case "string": + return "" + } + return "0" + } + return fmt.Sprint(**v.p) +} + +func (v *optionalValue[T]) Set(s string) error { + x, err := v.parse(s) + if err != nil { + return err + } + *v.p = &x + return nil +} + +func (v *optionalValue[T]) Type() string { return v.typ } + +type optionalBool struct{ optionalValue[bool] } + +func (*optionalBool) IsBoolFlag() bool { return true } + +// StringPtrVar defines a string flag that sets *p only when the flag is used. +func StringPtrVar(fs *pflag.FlagSet, p **string, name, usage string) { + fs.Var(&optionalValue[string]{p: p, typ: "string", parse: func(s string) (string, error) { return s, nil }}, name, usage) +} + +// BoolPtrVar defines a bool flag that sets *p only when the flag is used. +func BoolPtrVar(fs *pflag.FlagSet, p **bool, name, usage string) { + fs.Var(&optionalBool{optionalValue[bool]{p: p, typ: "bool", parse: strconv.ParseBool}}, name, usage) + fs.Lookup(name).NoOptDefVal = "true" +} + +// IntPtrVar defines an int flag that sets *p only when the flag is used. +func IntPtrVar(fs *pflag.FlagSet, p **int, name, usage string) { + fs.Var(&optionalValue[int]{p: p, typ: "int", parse: strconv.Atoi}, name, usage) +} + +// Int64PtrVar defines an int64 flag that sets *p only when the flag is used. +func Int64PtrVar(fs *pflag.FlagSet, p **int64, name, usage string) { + fs.Var(&optionalValue[int64]{p: p, typ: "int64", parse: func(s string) (int64, error) { + return strconv.ParseInt(s, 0, 64) + }}, name, usage) +} + +// Float64PtrVar defines a float64 flag that sets *p only when the flag is used. +func Float64PtrVar(fs *pflag.FlagSet, p **float64, name, usage string) { + fs.Var(&optionalValue[float64]{p: p, typ: "float64", parse: func(s string) (float64, error) { + return strconv.ParseFloat(s, 64) + }}, name, usage) +} + +// enumValue binds a flag to a string enum and validates the given value. +type enumValue[T ~string] struct { + p *T + typ string + values []string +} + +func (v *enumValue[T]) String() string { return string(*v.p) } + +func (v *enumValue[T]) Set(s string) error { + if len(v.values) > 0 && !slices.Contains(v.values, s) { + return fmt.Errorf(`value "%s" is not one of "%s"`, s, strings.Join(v.values, `", "`)) + } + *v.p = T(s) + return nil +} + +func (v *enumValue[T]) Type() string { return v.typ } + +// EnumVar defines a flag for a string enum. typ is shown in help output and +// values (when non-empty) are the accepted values. +func EnumVar[T ~string](fs *pflag.FlagSet, p *T, name, usage, typ string, values ...string) { + fs.Var(&enumValue[T]{p: p, typ: typ, values: values}, name, usage) +} + +// ParseEnum validates s against values (when non-empty) for a positional +// enum argument. +func ParseEnum[T ~string](s string, values ...string) (T, error) { + if len(values) > 0 && !slices.Contains(values, s) { + return "", fmt.Errorf(`value "%s" is not one of "%s"`, s, strings.Join(values, `", "`)) + } + return T(s), nil +} + +// Float32PtrVar defines a float32 flag that sets *p only when the flag is used. +// It reports the float64 type so help output shows "float" like pflag.Float64Var. +func Float32PtrVar(fs *pflag.FlagSet, p **float32, name, usage string) { + fs.Var(&optionalValue[float32]{p: p, typ: "float64", parse: func(s string) (float32, error) { + f, err := strconv.ParseFloat(s, 32) + return float32(f), err + }}, name, usage) +} + +// EnumPtrVar defines a flag for an optional string enum: *p is set only when +// the flag is used. +func EnumPtrVar[T ~string](fs *pflag.FlagSet, p **T, name, usage, typ string, values ...string) { + fs.Var(&optionalValue[T]{p: p, typ: typ, parse: func(s string) (T, error) { + return ParseEnum[T](s, values...) + }}, name, usage) +} + +// JSONStringPtrVar defines a flag for a value that the API encodes as a JSON +// string (e.g. a timestamp or a duration): the flag value is decoded as that +// JSON string and *p is set only when the flag is used. +func JSONStringPtrVar[T any](fs *pflag.FlagSet, p **T, name, usage string) { + fs.Var(&optionalValue[T]{p: p, typ: "string", parse: func(s string) (T, error) { + var v T + err := json.Unmarshal([]byte(strconv.Quote(s)), &v) + return v, err + }}, name, usage) +} + +type base64Value struct{ p *[]byte } + +func (v *base64Value) String() string { return base64.StdEncoding.EncodeToString(*v.p) } + +func (v *base64Value) Set(s string) error { + b, err := base64.StdEncoding.DecodeString(s) + if err != nil { + b, err = base64.URLEncoding.DecodeString(s) + } + if err != nil { + return fmt.Errorf("invalid base64 value: %w", err) + } + *v.p = b + return nil +} + +func (*base64Value) Type() string { return "string" } + +// Base64Var defines a flag for a bytes field the API exchanges as base64 +// (e.g. an etag): the flag takes the base64 string as returned by the API. +func Base64Var(fs *pflag.FlagSet, p *[]byte, name, usage string) { + fs.Var(&base64Value{p: p}, name, usage) +} diff --git a/libs/genie/client.go b/libs/genie/client.go index 73522afde5a..18d8840df33 100644 --- a/libs/genie/client.go +++ b/libs/genie/client.go @@ -7,11 +7,13 @@ import ( "io" "maps" + "github.com/databricks/cli/libs/apierrs" + + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/genie/agentstream" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/client" "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/sdk-go/core/apierr" ) // genieResponsesPath is the backend route. The server-side tool is still named @@ -64,7 +66,7 @@ func BuildRequest(question, warehouseID, conversationID string) GenieRequest { func PostStream(ctx context.Context, cfg *config.Config, req GenieRequest) (io.ReadCloser, error) { cfg.HTTPTimeoutSeconds = StreamingTimeoutSeconds - api, err := client.New(cfg) + api, err := apiclient.New(cfg) if err != nil { return nil, err } @@ -83,15 +85,15 @@ func PostStream(ctx context.Context, cfg *config.Config, req GenieRequest) (io.R // plain ErrNotFound). A 404 RESOURCE_DOES_NOT_EXIST is excluded: it refers // to something the request named (e.g. the warehouse) and must keep the // backend's own message instead of blaming the endpoint. - if errors.Is(err, apierr.ErrNotFound) && !errors.Is(err, apierr.ErrResourceDoesNotExist) { + if apierrs.Is(err, apierrs.ErrNotFound) && !apierrs.Is(err, apierrs.ErrResourceDoesNotExist) { return nil, fmt.Errorf("the Genie API is not available on this workspace: %w; the endpoint may have moved since this CLI release: %s", err, agentstream.UpdateCLIAdvice) } // A request body the backend cannot interpret (e.g. after its expected // request shape changed) surfaces as a 500 INTERNAL_ERROR with an empty // message (observed live), leaving the user a blank error. Transient // backend faults share the status code, hence the hedged advice. - if errors.Is(err, apierr.ErrInternalError) { - if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.Message == "" { + if apierrs.Is(err, apierrs.ErrInternalError) { + if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.Message() == "" { // An empty message would render as "request: ;" mid-sentence, so // the observed no-details shape gets its own wording. The %w // keeps the error chain and renders as nothing. diff --git a/libs/genie/client_test.go b/libs/genie/client_test.go index 28cecffc003..4da4861eb6b 100644 --- a/libs/genie/client_test.go +++ b/libs/genie/client_test.go @@ -8,8 +8,9 @@ import ( "net/http/httptest" "testing" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/genie/agentstream" - "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -148,7 +149,7 @@ func TestPostStream_EndpointGone(t *testing.T) { cfg := &config.Config{Host: srv.URL, Token: "dummy"} _, err := PostStream(t.Context(), cfg, BuildRequest("q", "", "")) require.Error(t, err) - assert.ErrorIs(t, err, apierr.ErrNotFound) + assert.True(t, apierrs.Is(err, apierrs.ErrNotFound)) assert.Contains(t, err.Error(), "No API found") assert.Contains(t, err.Error(), "update the Databricks CLI to the latest version") } @@ -167,7 +168,7 @@ func TestPostStream_ResourceNotFound(t *testing.T) { cfg := &config.Config{Host: srv.URL, Token: "dummy"} _, err := PostStream(t.Context(), cfg, BuildRequest("q", "wh-missing", "")) require.Error(t, err) - assert.ErrorIs(t, err, apierr.ErrResourceDoesNotExist) + assert.True(t, apierrs.Is(err, apierrs.ErrResourceDoesNotExist)) assert.Contains(t, err.Error(), "Warehouse wh-missing does not exist") assert.NotContains(t, err.Error(), "update the Databricks CLI") } @@ -201,7 +202,7 @@ func TestPostStream_InternalErrorEmptyMessage(t *testing.T) { cfg := &config.Config{Host: srv.URL, Token: "dummy"} _, err := PostStream(t.Context(), cfg, BuildRequest("q", "", "")) require.Error(t, err) - assert.ErrorIs(t, err, apierr.ErrInternalError) + assert.True(t, apierrs.Is(err, apierrs.ErrInternalError)) assert.Contains(t, err.Error(), "could not process the request (500 with no details)") assert.Contains(t, err.Error(), "update the Databricks CLI to the latest version") } diff --git a/libs/git/info.go b/libs/git/info.go index 03f64cb43d7..4d7870d5486 100644 --- a/libs/git/info.go +++ b/libs/git/info.go @@ -8,15 +8,16 @@ import ( "path" "strings" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/dbr" "github.com/databricks/cli/libs/folders" "github.com/databricks/cli/libs/log" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" "github.com/databricks/cli/libs/vfs" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/client" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/sdk-go/repos/v1" ) type RepositoryInfo struct { @@ -48,7 +49,7 @@ type response struct { // - If we could determine git worktree root but there were errors when reading metadata (origin, branch, commit), those errors // will be logged as warnings, RepositoryInfo is guaranteed to have non-empty WorktreeRoot and other fields on best effort basis. // - In successful case, all fields are set to proper git repository metadata. -func FetchRepositoryInfo(ctx context.Context, path string, w *databricks.WorkspaceClient) (RepositoryInfo, error) { +func FetchRepositoryInfo(ctx context.Context, path string, w *sdkclients.Clients) (RepositoryInfo, error) { var info RepositoryInfo var err error if strings.HasPrefix(path, "/Workspace/") && dbr.RunsOnRuntime(ctx) { @@ -67,7 +68,7 @@ func FetchRepositoryInfo(ctx context.Context, path string, w *databricks.Workspa return info, err } -func fetchRepositoryInfoFromWorkspace(ctx context.Context, path string, w *databricks.WorkspaceClient) (RepositoryInfo, error) { +func fetchRepositoryInfoFromWorkspace(ctx context.Context, path string, w *sdkclients.Clients) (RepositoryInfo, error) { info, err := FetchRepositoryInfoAPI(ctx, path, w) if err == nil && info.WorktreeRoot == "" { // Fall back to Git information from .git for unsupported Git folders like worktree folders @@ -82,10 +83,10 @@ func fetchRepositoryInfoFromWorkspace(ctx context.Context, path string, w *datab // // A path that does not exist is reported as fs.ErrNotExist; callers that treat // that as "no repository here" must normalize it the way FetchRepositoryInfo does. -func FetchRepositoryInfoAPI(ctx context.Context, path string, w *databricks.WorkspaceClient) (RepositoryInfo, error) { +func FetchRepositoryInfoAPI(ctx context.Context, path string, w *sdkclients.Clients) (RepositoryInfo, error) { result := RepositoryInfo{} - apiClient, err := client.New(w.Config) + apiClient, err := apiclient.New(w.Config) if err != nil { return result, err } @@ -111,7 +112,7 @@ func FetchRepositoryInfoAPI(ctx context.Context, path string, w *databricks.Work // Normalize it to fs.ErrNotExist, the same signal fetchRepositoryInfoDotGit // produces for a missing local path, so FetchRepositoryInfo can treat // "no path" as "no repository" uniformly. - if apierr.IsMissing(err) { + if apierrs.IsMissing(err) { return result, fs.ErrNotExist } return result, err @@ -131,13 +132,13 @@ func FetchRepositoryInfoAPI(ctx context.Context, path string, w *databricks.Work // Repos API still has the metadata, and git_info.id identifies the Git // folder root even when the queried path is a subdirectory of it. if gi.ID != 0 && gi.Branch == "" && gi.HeadCommitID == "" && gi.URL == "" { - repo, err := w.Repos.Get(ctx, workspace.GetRepoRequest{RepoId: gi.ID}) + repo, err := w.Repos.GetRepo(ctx, repos.GetRepoRequest{Id: new(gi.ID)}) if err != nil { log.Warnf(ctx, "failed to load git info for repo %d: %s", gi.ID, err) } else { - result.OriginURL = repo.Url - result.LatestCommit = repo.HeadCommitId - result.CurrentBranch = repo.Branch + result.OriginURL = utils.Deref(repo.Url) + result.LatestCommit = utils.Deref(repo.HeadCommitId) + result.CurrentBranch = utils.Deref(repo.Branch) } } } else { diff --git a/libs/git/info_test.go b/libs/git/info_test.go index 973ba69ddef..09204075cbc 100644 --- a/libs/git/info_test.go +++ b/libs/git/info_test.go @@ -9,9 +9,9 @@ import ( "testing" "github.com/databricks/cli/internal/testutil" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/qa" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/httpfixtures" + "github.com/databricks/cli/libs/sdkclients" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -39,12 +39,13 @@ func TestFetchRepositoryInfoFromWorkspace(t *testing.T) { testutil.WriteFile(t, filepath.Join(malformed, ".git"), "invalid gitfile") for _, tc := range []struct { - name string - path string - body string - status int - want RepositoryInfo - wantErr error + name string + path string + body string + status int + want RepositoryInfo + wantErr error + wantAPIErr error }{ {name: "worktree", path: worktree, want: want}, {name: "subdirectory", path: filepath.Dir(file), want: want}, @@ -61,7 +62,7 @@ func TestFetchRepositoryInfoFromWorkspace(t *testing.T) { {name: "malformed gitfile", path: malformed, want: RepositoryInfo{WorktreeRoot: malformed}}, { name: "permission denied", path: worktree, status: http.StatusForbidden, - body: `{"error_code":"PERMISSION_DENIED","message":"denied"}`, wantErr: apierr.ErrPermissionDenied, + body: `{"error_code":"PERMISSION_DENIED","message":"denied"}`, wantAPIErr: apierrs.ErrPermissionDenied, }, { name: "workspace path missing", path: worktree, status: http.StatusNotFound, @@ -73,17 +74,21 @@ func TestFetchRepositoryInfoFromWorkspace(t *testing.T) { if body == "" { body = `{}` } - cfg, server := qa.HTTPFixtures{{ + cfg, _ := httpfixtures.Fixtures{{ Method: "GET", Resource: "/api/2.0/workspace/get-status?path=" + url.QueryEscape(tc.path) + "&return_git_info=true", Response: body, Status: tc.status, }}.Config(t) - t.Cleanup(server.Close) - w := databricks.Must(databricks.NewWorkspaceClient((*databricks.Config)(cfg))) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) got, err := fetchRepositoryInfoFromWorkspace(t.Context(), tc.path, w) - require.ErrorIs(t, err, tc.wantErr) + if tc.wantAPIErr != nil { + assert.True(t, apierrs.Is(err, tc.wantAPIErr), "got %v", err) + } else { + require.ErrorIs(t, err, tc.wantErr) + } assert.Equal(t, tc.want, got) }) } diff --git a/libs/httpfixtures/httpfixtures.go b/libs/httpfixtures/httpfixtures.go new file mode 100644 index 00000000000..6e1cb96e6ae --- /dev/null +++ b/libs/httpfixtures/httpfixtures.go @@ -0,0 +1,107 @@ +// Package httpfixtures serves canned HTTP responses to unit tests that call +// the Databricks API, replacing the previous SDK's qa.HTTPFixtures. +package httpfixtures + +import ( + "encoding/json" + "io" + "net/http" + "net/http/httptest" + "net/url" + "reflect" + "testing" + + "github.com/databricks/databricks-sdk-go/config" + "github.com/stretchr/testify/assert" +) + +// Fixture is one expected request and the response to send for it. +type Fixture struct { + Method string + // Resource is the request path, optionally with a query string. Query + // parameters are compared regardless of their order. + Resource string + // Response is written as is if it is a string and JSON-encoded otherwise. + Response any + // Status defaults to 200. + Status int + // ExpectedRequest, if set, is compared as JSON against the request body. + ExpectedRequest any + // ReuseRequest lets the fixture match more than one request. + ReuseRequest bool +} + +type Fixtures []Fixture + +// hostMetadata answers config resolution's host metadata lookup so tests do +// not depend on it unless they stub it themselves. +var hostMetadata = Fixture{ + Method: "GET", + Resource: "/.well-known/databricks-config", + ReuseRequest: true, + Status: 404, + Response: `{"error_code":"NOT_FOUND","message":"host metadata endpoint auto-stubbed by httpfixtures"}`, +} + +func (f Fixture) matches(req *http.Request) bool { + if f.Method != req.Method { + return false + } + want, err := url.Parse(f.Resource) + if err != nil || want.Path != req.URL.Path { + return false + } + got := req.URL.Query() + wantQuery := want.Query() + if len(got) == 0 && len(wantQuery) == 0 { + return true + } + return reflect.DeepEqual(got, wantQuery) +} + +// Config starts a server for the fixtures and returns a PAT config for it. +// Requests that match no fixture fail the test. +func (fixtures Fixtures) Config(t *testing.T) (*config.Config, *httptest.Server) { + fixtures = append(Fixtures{hostMetadata}, fixtures...) + used := make([]bool, len(fixtures)) + server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + for i, fixture := range fixtures { + if used[i] || !fixture.matches(req) { + continue + } + if !fixture.ReuseRequest { + used[i] = true + } + if fixture.ExpectedRequest != nil { + body, err := io.ReadAll(req.Body) + assert.NoError(t, err) + expected, err := json.Marshal(fixture.ExpectedRequest) + assert.NoError(t, err) + assert.JSONEq(t, string(expected), string(body), "request body for %s %s", req.Method, req.URL) + } + status := fixture.Status + if status == 0 { + status = http.StatusOK + } + rw.WriteHeader(status) + switch r := fixture.Response.(type) { + case nil: + case string: + _, _ = rw.Write([]byte(r)) + default: + data, err := json.Marshal(r) + assert.NoError(t, err) + _, _ = rw.Write(data) + } + return + } + assert.Fail(t, "missing fixture for "+req.Method+" "+req.URL.String()) + rw.WriteHeader(http.StatusNotImplemented) + })) + t.Cleanup(server.Close) + return &config.Config{ + Credentials: config.PatCredentials{}, + Host: server.URL, + Token: "x", + }, server +} diff --git a/libs/iamutil/current_user.go b/libs/iamutil/current_user.go index 2908c8e19a2..015596fddd8 100644 --- a/libs/iamutil/current_user.go +++ b/libs/iamutil/current_user.go @@ -6,33 +6,35 @@ import ( "net/http" "time" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/retries" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/sdk-go/core/apierr" + sdkscim "github.com/databricks/sdk-go/scim/v1" ) -// meRetryTimeout bounds how long GetCurrentUser retries transient 500s. const meRetryTimeout = 30 * time.Second -// GetCurrentUser returns the current user, retrying on HTTP 500 responses. -// -// CurrentUser.Me is a read-only endpoint, so retrying any 500 is safe. The -// Databricks SCIM API intermittently returns "500 TEMPORARILY_UNAVAILABLE" (a -// condition it otherwise serves as 503), and the SDK retries 503 but not 500 — -// see the "some API's recommend retries on HTTP 500, but we'll add that later" -// comment on (*apierr.APIError).IsRetriable in databricks-sdk-go/apierr. This -// call runs at the start of every bundle command, so an unretried 500 fails the -// whole command; we close that gap here. -func GetCurrentUser(ctx context.Context, w *databricks.WorkspaceClient) (*iam.User, error) { - return retries.Poll(ctx, meRetryTimeout, func() (*iam.User, *retries.Err) { - user, err := w.CurrentUser.Me(ctx, iam.MeRequest{}) +// meRetryInterval is the pause between attempts while the SCIM Me endpoint +// returns 500, which it does transiently right after workspace creation. +const meRetryInterval = time.Second + +// GetCurrentUser returns the authenticated user. It is returned as the +// JSON-capable mirror type because callers store it in bundle configuration. +func GetCurrentUser(ctx context.Context, w *sdkclients.Clients) (*scim.User, error) { + deadline := time.Now().Add(meRetryTimeout) + for { + user, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) if err == nil { - return user, nil + return scim.UserFromSDK(user) + } + apiErr, ok := errors.AsType[*apierr.APIError](err) + if !ok || apiErr.HTTPStatusCode() != http.StatusInternalServerError || time.Now().Add(meRetryInterval).After(deadline) { + return nil, err } - if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.StatusCode == http.StatusInternalServerError { - return nil, retries.Continue(err) + select { + case <-ctx.Done(): + return nil, ctx.Err() + case <-time.After(meRetryInterval): } - return nil, retries.Halt(err) - }) + } } diff --git a/libs/iamutil/current_user_test.go b/libs/iamutil/current_user_test.go index decf8eef936..e34ed4f58e1 100644 --- a/libs/iamutil/current_user_test.go +++ b/libs/iamutil/current_user_test.go @@ -4,36 +4,38 @@ import ( "net/http" "testing" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/experimental/mocks" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/httpfixtures" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/utils" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" ) +const mePath = "/api/2.0/preview/scim/v2/Me" + func TestGetCurrentUserRetriesOn500(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - me := m.GetMockCurrentUserAPI().EXPECT().Me(mock.Anything, mock.Anything) - me.Return(nil, &apierr.APIError{StatusCode: http.StatusInternalServerError, ErrorCode: "TEMPORARILY_UNAVAILABLE"}).Once() - me.Return(&iam.User{UserName: "test-user"}, nil).Once() + cfg, _ := httpfixtures.Fixtures{ + {Method: "GET", Resource: mePath, Status: http.StatusInternalServerError, Response: `{"error_code":"TEMPORARILY_UNAVAILABLE"}`}, + {Method: "GET", Resource: mePath, Response: `{"userName":"test-user"}`}, + }.Config(t) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) - user, err := GetCurrentUser(t.Context(), m.WorkspaceClient) + user, err := GetCurrentUser(t.Context(), w) require.NoError(t, err) - assert.Equal(t, "test-user", user.UserName) + assert.Equal(t, "test-user", utils.Deref(user.UserName)) } func TestGetCurrentUserDoesNotRetryOn403(t *testing.T) { - m := mocks.NewMockWorkspaceClient(t) - // A non-500 error must fail immediately, without a retry (Once enforces it). - m.GetMockCurrentUserAPI().EXPECT(). - Me(mock.Anything, mock.Anything). - Return(nil, &apierr.APIError{StatusCode: http.StatusForbidden, Message: "denied"}). - Once() + // A non-500 error must fail immediately; a second request would match no fixture. + cfg, _ := httpfixtures.Fixtures{ + {Method: "GET", Resource: mePath, Status: http.StatusForbidden, Response: `{"message":"denied"}`}, + }.Config(t) + w, err := sdkclients.New(t.Context(), cfg) + require.NoError(t, err) - _, err := GetCurrentUser(t.Context(), m.WorkspaceClient) + _, err = GetCurrentUser(t.Context(), w) require.Error(t, err) - var apiErr *apierr.APIError - require.ErrorAs(t, err, &apiErr) - assert.Equal(t, http.StatusForbidden, apiErr.StatusCode) + assert.Equal(t, http.StatusForbidden, apierrs.StatusCode(err)) } diff --git a/libs/iamutil/service_principal.go b/libs/iamutil/service_principal.go index 0ae578baf19..9493ba3419a 100644 --- a/libs/iamutil/service_principal.go +++ b/libs/iamutil/service_principal.go @@ -1,7 +1,8 @@ package iamutil import ( - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/libs/utils" "github.com/google/uuid" ) @@ -10,8 +11,8 @@ import ( // it's a service principal. Unfortunately, the service principal listing API is too // slow for our purposes. And the "users" and "service principals get" APIs // only allow access by workspace admins. -func IsServicePrincipal(user *iam.User) bool { - return IsServicePrincipalName(user.UserName) +func IsServicePrincipal(user *scim.User) bool { + return IsServicePrincipalName(utils.Deref(user.UserName)) } func IsServicePrincipalName(userName string) bool { diff --git a/libs/iamutil/service_principal_test.go b/libs/iamutil/service_principal_test.go index 07e07669203..db3d31b0c67 100644 --- a/libs/iamutil/service_principal_test.go +++ b/libs/iamutil/service_principal_test.go @@ -3,21 +3,21 @@ package iamutil import ( "testing" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/stretchr/testify/assert" ) func TestIsServicePrincipal_ValidUUID(t *testing.T) { - user := &iam.User{ - UserName: "8b948b2e-d2b5-4b9e-8274-11b596f3b652", + user := &scim.User{ + UserName: new("8b948b2e-d2b5-4b9e-8274-11b596f3b652"), } isSP := IsServicePrincipal(user) assert.True(t, isSP, "Expected user ID to be recognized as a service principal") } func TestIsServicePrincipal_InvalidUUID(t *testing.T) { - user := &iam.User{ - UserName: "invalid", + user := &scim.User{ + UserName: new("invalid"), } isSP := IsServicePrincipal(user) assert.False(t, isSP, "Expected user ID to not be recognized as a service principal") diff --git a/libs/iamutil/user.go b/libs/iamutil/user.go index 2018a9e25ff..2a645951aee 100644 --- a/libs/iamutil/user.go +++ b/libs/iamutil/user.go @@ -3,17 +3,18 @@ package iamutil import ( "strings" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/databricks/cli/libs/textutil" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/utils" ) // Get a short-form username, based on the user's primary email address. // We leave the full range of unicode letters in tact, but remove all "special" characters, // including dots, which are not supported in e.g. experiment names. -func GetShortUserName(user *iam.User) string { - name := user.UserName - if IsServicePrincipal(user) && user.DisplayName != "" { - name = user.DisplayName +func GetShortUserName(user *scim.User) string { + name := utils.Deref(user.UserName) + if IsServicePrincipal(user) && utils.Deref(user.DisplayName) != "" { + name = *user.DisplayName } local, _, _ := strings.Cut(name, "@") return textutil.NormalizeString(local) @@ -21,7 +22,7 @@ func GetShortUserName(user *iam.User) string { // GetShortUserDomainFriendlyName returns a dns-friendly for of the user name based on short name // We replace all non-alphanumeric characters with a dash (following Databricks Apps' naming requirements) -func GetShortUserDomainFriendlyName(user *iam.User) string { +func GetShortUserDomainFriendlyName(user *scim.User) string { name := GetShortUserName(user) return strings.ToLower(textutil.Chain( textutil.NormalizeMarks(), diff --git a/libs/iamutil/user_test.go b/libs/iamutil/user_test.go index 7d23286bd08..08e1eed1d8a 100644 --- a/libs/iamutil/user_test.go +++ b/libs/iamutil/user_test.go @@ -3,104 +3,104 @@ package iamutil import ( "testing" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/stretchr/testify/assert" ) func TestGetShortUserName(t *testing.T) { tests := []struct { name string - user *iam.User + user *scim.User expected string }{ { - user: &iam.User{ - UserName: "test.user.1234@example.com", + user: &scim.User{ + UserName: new("test.user.1234@example.com"), }, expected: "test_user_1234", }, { - user: &iam.User{ - UserName: "tést.üser@example.com", + user: &scim.User{ + UserName: new("tést.üser@example.com"), }, expected: "tést_üser", }, { - user: &iam.User{ - UserName: "test$.user@example.com", + user: &scim.User{ + UserName: new("test$.user@example.com"), }, expected: "test_user", }, { - user: &iam.User{ - UserName: `jöhn.dœ@domain.com`, // Using non-ASCII characters. + user: &scim.User{ + UserName: new(`jöhn.dœ@domain.com`), // Using non-ASCII characters. }, expected: "jöhn_dœ", }, { - user: &iam.User{ - UserName: `first+tag@email.com`, // The plus (+) sign is used for "sub-addressing" in some email services. + user: &scim.User{ + UserName: new(`first+tag@email.com`), // The plus (+) sign is used for "sub-addressing" in some email services. }, expected: "first_tag", }, { - user: &iam.User{ - UserName: `email@sub.domain.com`, // Using a sub-domain. + user: &scim.User{ + UserName: new(`email@sub.domain.com`), // Using a sub-domain. }, expected: "email", }, { - user: &iam.User{ - UserName: `"_quoted"@domain.com`, // Quoted strings can be part of the local-part. + user: &scim.User{ + UserName: new(`"_quoted"@domain.com`), // Quoted strings can be part of the local-part. }, expected: "quoted", }, { - user: &iam.User{ - UserName: `name-o'mally@website.org`, // Single quote in the local-part. + user: &scim.User{ + UserName: new(`name-o'mally@website.org`), // Single quote in the local-part. }, expected: "name_o_mally", }, { - user: &iam.User{ - UserName: `user%domain@external.com`, // Percent sign can be used for email routing in legacy systems. + user: &scim.User{ + UserName: new(`user%domain@external.com`), // Percent sign can be used for email routing in legacy systems. }, expected: "user_domain", }, { - user: &iam.User{ - UserName: `long.name.with.dots@domain.net`, // Multiple dots in the local-part. + user: &scim.User{ + UserName: new(`long.name.with.dots@domain.net`), // Multiple dots in the local-part. }, expected: "long_name_with_dots", }, { - user: &iam.User{ - UserName: `me&you@together.com`, // Using an ampersand (&) in the local-part. + user: &scim.User{ + UserName: new(`me&you@together.com`), // Using an ampersand (&) in the local-part. }, expected: "me_you", }, { - user: &iam.User{ - UserName: `user!def!xyz@domain.org`, // The exclamation mark can be valid in some legacy systems. + user: &scim.User{ + UserName: new(`user!def!xyz@domain.org`), // The exclamation mark can be valid in some legacy systems. }, expected: "user_def_xyz", }, { - user: &iam.User{ - UserName: `admin@ιντερνετ.com`, // Domain in non-ASCII characters (IDN or Internationalized Domain Name). + user: &scim.User{ + UserName: new(`admin@ιντερνετ.com`), // Domain in non-ASCII characters (IDN or Internationalized Domain Name). }, expected: "admin", }, { - user: &iam.User{ - UserName: `1706906c-c0a2-4c25-9f57-3a7aa3cb8123`, - DisplayName: "my-service-principal", + user: &scim.User{ + UserName: new(`1706906c-c0a2-4c25-9f57-3a7aa3cb8123`), + DisplayName: new("my-service-principal"), }, expected: "my_service_principal", }, { - user: &iam.User{ - UserName: `1706906c-c0a2-4c25-9f57-3a7aa3cb8123`, + user: &scim.User{ + UserName: new(`1706906c-c0a2-4c25-9f57-3a7aa3cb8123`), // This service princpal has DisplayName (it's an optional property) }, expected: "1706906c_c0a2_4c25_9f57_3a7aa3cb8123", @@ -115,114 +115,114 @@ func TestGetShortUserName(t *testing.T) { func TestGetShortUserDomainFriendlyName(t *testing.T) { tests := []struct { name string - user *iam.User + user *scim.User expected string }{ { name: "basic email with dots", - user: &iam.User{ - UserName: "test.user.1234@example.com", + user: &scim.User{ + UserName: new("test.user.1234@example.com"), }, expected: "test-user-1234", }, { name: "email with underscores", - user: &iam.User{ - UserName: "test_user@example.com", + user: &scim.User{ + UserName: new("test_user@example.com"), }, expected: "test-user", }, { name: "email with special characters", - user: &iam.User{ - UserName: "test$#%user@example.com", + user: &scim.User{ + UserName: new("test$#%user@example.com"), }, expected: "test-user", }, { name: "service principal with display name", - user: &iam.User{ - UserName: `1706906c-c0a2-4c25-9f57-3a7aa3cb8123`, - DisplayName: "my_service_principal", + user: &scim.User{ + UserName: new(`1706906c-c0a2-4c25-9f57-3a7aa3cb8123`), + DisplayName: new("my_service_principal"), }, expected: "my-service-principal", }, { name: "uppercase letters should be lowercased", - user: &iam.User{ - UserName: "John.Doe@COMPANY.COM", + user: &scim.User{ + UserName: new("John.Doe@COMPANY.COM"), }, expected: "john-doe", }, { name: "mixed case with numbers", - user: &iam.User{ - UserName: "User123.Test@example.com", + user: &scim.User{ + UserName: new("User123.Test@example.com"), }, expected: "user123-test", }, { name: "unicode characters with normalization", - user: &iam.User{ - UserName: "tést.üser@example.com", + user: &scim.User{ + UserName: new("tést.üser@example.com"), }, expected: "test-user", }, { name: "complex special characters", - user: &iam.User{ - UserName: "user+tag&more@example.com", + user: &scim.User{ + UserName: new("user+tag&more@example.com"), }, expected: "user-tag-more", }, { name: "service principal with mixed case display name", - user: &iam.User{ - UserName: `1706906c-c0a2-4c25-9f57-3a7aa3cb8123`, - DisplayName: "My_Service_Principal", + user: &scim.User{ + UserName: new(`1706906c-c0a2-4c25-9f57-3a7aa3cb8123`), + DisplayName: new("My_Service_Principal"), }, expected: "my-service-principal", }, { name: "email with multiple consecutive special chars", - user: &iam.User{ - UserName: "test...user___name@example.com", + user: &scim.User{ + UserName: new("test...user___name@example.com"), }, expected: "test-user-name", }, { name: "chinese characters in email", - user: &iam.User{ - UserName: "用户.测试@example.com", + user: &scim.User{ + UserName: new("用户.测试@example.com"), }, expected: "-----", }, { name: "japanese characters in email", - user: &iam.User{ - UserName: "ユーザー.テスト@example.com", + user: &scim.User{ + UserName: new("ユーザー.テスト@example.com"), }, expected: "--------", }, { name: "emoji in email", - user: &iam.User{ - UserName: "user😀.test🚀@example.com", + user: &scim.User{ + UserName: new("user😀.test🚀@example.com"), }, expected: "user-test", }, { name: "mixed latin and chinese characters", - user: &iam.User{ - UserName: "john.李明@company.com", + user: &scim.User{ + UserName: new("john.李明@company.com"), }, expected: "john---", }, { name: "service principal with emoji display name", - user: &iam.User{ - UserName: "1706906c-c0a2-4c25-9f57-3a7aa3cb8123", - DisplayName: "bot🤖_service", + user: &scim.User{ + UserName: new("1706906c-c0a2-4c25-9f57-3a7aa3cb8123"), + DisplayName: new("bot🤖_service"), }, expected: "bot-service", }, diff --git a/libs/jsonschema/from_type.go b/libs/jsonschema/from_type.go index 08eaf715f22..1cae7774287 100644 --- a/libs/jsonschema/from_type.go +++ b/libs/jsonschema/from_type.go @@ -8,8 +8,6 @@ import ( "reflect" "slices" "strings" - - "github.com/databricks/databricks-sdk-go/common/types/duration" ) var skipTags = []string{ @@ -22,13 +20,18 @@ var skipTags = []string{ "internal", } -// sdkDurationType is the reflect.Type for the SDK's duration.Duration type. -// This type has custom JSON marshaling that represents durations as strings. -var sdkDurationType = reflect.TypeFor[duration.Duration]() +// sdkTypesPkgPath is the package of the SDK native types types.Time, +// types.Duration and types.FieldMask[T]. They have custom JSON marshaling that +// represents them as strings. +const sdkTypesPkgPath = "github.com/databricks/sdk-go/core/types" + +func isSDKNativeType(typ reflect.Type) bool { + return typ.Kind() == reflect.Struct && typ.PkgPath() == sdkTypesPkgPath +} type constructor struct { // Map of typ.PkgPath() + "." + typ.Name() to the schema for that type. - // Example key: github.com/databricks/databricks-sdk-go/service/jobs.JobSettings + // Example key: github.com/databricks/cli/libs/sdktypes/jobs/v2.JobSettings definitions map[string]Schema // Map of typ.PkgPath() + "." + typ.Name() to the corresponding type. Used to @@ -140,6 +143,11 @@ func typePath(typ reflect.Type) string { } switch { + case isSDKNativeType(typ): + // Strip type arguments of generic native types (FieldMask[T]): they all + // share one string schema and would otherwise embed a package path. + name, _, _ := strings.Cut(typ.Name(), "[") + return typ.PkgPath() + "." + name case typ.PkgPath() != "" && typ.Name() != "": return typ.PkgPath() + "." + typ.Name() case typ.Name() != "": @@ -170,8 +178,8 @@ func (c *constructor) walk(typ reflect.Type) (string, error) { var s Schema var err error - // Handle SDK's duration.Duration type as a string since it has custom JSON marshaling. - if typ == sdkDurationType { + // SDK native types are strings in JSON because of their custom marshaling. + if isSDKNativeType(typ) { s = Schema{Type: StringType} c.definitions[typPath] = s return typPath, nil diff --git a/libs/jsonschema/from_type_test.go b/libs/jsonschema/from_type_test.go index 6d1d539a6ba..8791de425ad 100644 --- a/libs/jsonschema/from_type_test.go +++ b/libs/jsonschema/from_type_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/databricks/cli/libs/jsonschema/test_types" - "github.com/databricks/databricks-sdk-go/common/types/duration" + "github.com/databricks/sdk-go/core/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -521,27 +521,30 @@ func TestTypePath(t *testing.T) { }) } -func TestFromTypeDuration(t *testing.T) { +type fieldMaskTarget struct{} + +func TestFromTypeSDKNativeTypes(t *testing.T) { type myStruct struct { - Timeout *duration.Duration `json:"timeout,omitempty"` + Timeout *types.Duration `json:"timeout,omitempty"` + CreateTime *types.Time `json:"create_time,omitempty"` + UpdateMask *types.FieldMask[fieldMaskTarget] `json:"update_mask,omitempty"` } s, err := FromType(reflect.TypeFor[myStruct](), nil) require.NoError(t, err) - // The schema should have a property for timeout with a $ref - assert.NotNil(t, s.Properties["timeout"]) - assert.NotNil(t, s.Properties["timeout"].Reference) - - // The $defs should contain a string type for duration.Duration defs := s.Definitions require.NotNil(t, defs) - - // Navigate to the duration definition - durDef := defs["github.com"].(map[string]any)["databricks"].(map[string]any)["databricks-sdk-go"].(map[string]any)["common"].(map[string]any)["types"].(map[string]any)["duration.Duration"] - require.NotNil(t, durDef) - - // duration.Duration should be represented as a string type - durSchema := durDef.(Schema) - assert.Equal(t, StringType, durSchema.Type) + typesDefs := defs["github.com"].(map[string]any)["databricks"].(map[string]any)["sdk-go"].(map[string]any)["core"].(map[string]any) + + for field, def := range map[string]string{ + "timeout": "types.Duration", + "create_time": "types.Time", + "update_mask": "types.FieldMask", + } { + require.NotNil(t, s.Properties[field], field) + require.NotNil(t, s.Properties[field].Reference, field) + assert.Equal(t, "#/$defs/github.com/databricks/sdk-go/core/"+def, *s.Properties[field].Reference) + assert.Equal(t, StringType, typesDefs[def].(Schema).Type, def) + } } diff --git a/libs/listing/collect.go b/libs/listing/collect.go new file mode 100644 index 00000000000..603ee0f2333 --- /dev/null +++ b/libs/listing/collect.go @@ -0,0 +1,16 @@ +package listing + +import "iter" + +// Collect drains an sdk-go iterator into a slice of values, stopping at the +// first error. It replaces the previous SDK's ListAll helpers. +func Collect[T any](seq iter.Seq2[*T, error]) ([]T, error) { + var result []T + for v, err := range seq { + if err != nil { + return nil, err + } + result = append(result, *v) + } + return result, nil +} diff --git a/libs/listing/collect_test.go b/libs/listing/collect_test.go new file mode 100644 index 00000000000..e4e64efa456 --- /dev/null +++ b/libs/listing/collect_test.go @@ -0,0 +1,22 @@ +package listing + +import ( + "errors" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestCollect(t *testing.T) { + a, b := 1, 2 + got, err := Collect(func(yield func(*int, error) bool) { + _ = yield(&a, nil) && yield(&b, nil) + }) + assert.NoError(t, err) + assert.Equal(t, []int{1, 2}, got) + + _, err = Collect(func(yield func(*int, error) bool) { + _ = yield(&a, nil) && yield(nil, errors.New("boom")) + }) + assert.EqualError(t, err, "boom") +} diff --git a/libs/listing/listing.go b/libs/listing/listing.go new file mode 100644 index 00000000000..aaa31587ac3 --- /dev/null +++ b/libs/listing/listing.go @@ -0,0 +1,285 @@ +// Package listing provides paginating iterators for hand-written API clients. +// Ported from github.com/databricks/databricks-sdk-go/listing. +package listing + +import ( + "context" + "errors" +) + +// Iterator[T] is an iterator over items of type T. It is similar to +// java.util.Iterator. It is not thread-safe. +type Iterator[T any] interface { + // HasNext returns true if there are more items to iterate over. HasNext + // will also return true if the iterator needs to fetch the next page of + // items from the underlying source and the request fails, even if there + // are no more items to iterate over. In this case, Next will return the + // error. + HasNext(context.Context) bool + + // Next returns the next item in the iterator. If there are no more items + // to iterate over, it returns ErrNoMoreItems. If there was an error + // fetching the next page of items, it returns that error. Once Next + // returns ErrNoMoreItems or an error, it will continue to return that + // error. + Next(context.Context) (T, error) +} + +// ToSlice returns all items from the iterator as a slice. If there was an +// error fetching items at any time, it returns that error. +func ToSlice[T any](ctx context.Context, it Iterator[T]) ([]T, error) { + var items []T + for it.HasNext(ctx) { + item, err := it.Next(ctx) + if err != nil { + return nil, err + } + items = append(items, item) + } + return items, nil +} + +// ToSliceN returns the first N items from the iterator as a slice. If there +// was an error fetching items at any time, it returns that error. If n == 0, +// it returns all items. +func ToSliceN[T any, Limit ~int | ~int64](ctx context.Context, it Iterator[T], n Limit) ([]T, error) { + if n == 0 { + return ToSlice(ctx, it) + } + var items []T + for it.HasNext(ctx) && Limit(len(items)) < n { + item, err := it.Next(ctx) + if err != nil { + return nil, err + } + items = append(items, item) + } + return items, nil +} + +// Use struct{} for Req for iterators that don't need any request structure. +type PaginatingIterator[Req, Resp, T any] struct { + // nextReq is the request to be used to fetch the next page. If nil, then + // there is no next page to fetch. + nextReq *Req + + // getNextPage fetches the next page of items, returning the deserialized + // response and error. + getNextPage func(context.Context, Req) (Resp, error) + + // getItems selects the items being iterated over from the response. + getItems func(Resp) []T + + // getNextReq is used to get the next request to be used in the next page. + // If nil, then there is no next page to fetch. + getNextReq func(Resp) *Req + + // currentPage is the current page of items. + currentPage []T + + // currentPageIdx is the index of the next item from currentPage to return. + currentPageIdx int + + // lastErr is the last error returned by getNextPage. + lastErr error +} + +var ErrNoMoreItems = errors.New("no more items") + +// Returns a new iterator. The iterator will fetch the next page of items +// lazily, when needed. nextReq is the request to be used to fetch the initial +// page. If nil, then no page will be fetched. getNextPage fetches the next +// page of items, returning the deserialized response and error. getItems +// selects the items being iterated over from the response. getNextReq is used +// to get the next request to be used in the next page. If the returned value +// is nil, then there is no next page to fetch. +func NewIterator[Req, Resp, T any]( + nextReq *Req, + getNextPage func(context.Context, Req) (Resp, error), + getItems func(Resp) []T, + getNextReq func(Resp) *Req, +) *PaginatingIterator[Req, Resp, T] { + return &PaginatingIterator[Req, Resp, T]{ + nextReq: nextReq, + getNextPage: getNextPage, + getItems: getItems, + getNextReq: getNextReq, + } +} + +func (i *PaginatingIterator[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error { + if i.currentPageIdx < len(i.currentPage) { + return nil + } + if i.nextReq == nil { + i.currentPage = nil + i.currentPageIdx = 0 + return nil + } + if i.lastErr != nil { + return i.lastErr + } + + // Keep loading pages while we have a next request and the current page is + // empty. + i.currentPage = nil + i.currentPageIdx = 0 + // Endpoints using token-based pagination may return an empty page with a + // next token. We need to keep fetching pages until we get a non-empty + // page or there are no more pages. + for i.nextReq != nil && len(i.currentPage) == 0 { + resp, err := i.getNextPage(ctx, *i.nextReq) + i.lastErr = err + if err != nil { + return err + } + if i.getNextReq != nil { + i.nextReq = i.getNextReq(resp) + } else { + i.nextReq = nil + } + i.currentPage = i.getItems(resp) + } + return nil +} + +func (i *PaginatingIterator[Req, Resp, T]) Next(ctx context.Context) (T, error) { + var t T + err := i.loadNextPageIfNeeded(ctx) + if err != nil { + return t, err + } + if i.currentPageIdx >= len(i.currentPage) { + return t, ErrNoMoreItems + } + item := i.currentPage[i.currentPageIdx] + i.currentPageIdx++ + return item, nil +} + +func (i *PaginatingIterator[Req, Resp, T]) HasNext(ctx context.Context) bool { + err := i.loadNextPageIfNeeded(ctx) + // As described in the documentation for HasNext, if there was an error + // fetching the next page, we still return true to allow the user to handle + // the error in Next. + if err != nil { + return true + } + return i.currentPageIdx < len(i.currentPage) +} + +type DeduplicatingIterator[T any, Id comparable] struct { + it Iterator[T] + getId func(T) Id + seen map[Id]struct{} + current *T +} + +func NewDedupeIterator[T any, Id comparable](it Iterator[T], getId func(T) Id) *DeduplicatingIterator[T, Id] { + return &DeduplicatingIterator[T, Id]{ + it: it, + getId: getId, + seen: make(map[Id]struct{}), + } +} + +func (i *DeduplicatingIterator[T, Id]) Next(ctx context.Context) (T, error) { + if i.current != nil { + t := *i.current + i.current = nil + return t, nil + } + for { + t, err := i.it.Next(ctx) + if err != nil { + return t, err + } + id := i.getId(t) + if _, ok := i.seen[id]; !ok { + i.seen[id] = struct{}{} + return t, nil + } + } +} + +func (i *DeduplicatingIterator[T, Id]) HasNext(ctx context.Context) bool { + if i.current != nil { + return true + } + // To compute HasNext in DeduplicatingIterator, we need to actually fetch + // the next item from the underlying iterator and compare it to seen items. + // However, the retrieved item cannot be discarded, as it needs to be + // returned by the next call to Next. So we store the item in current and + // return it in the next call to Next, after which current is set to nil. + for { + t, err := i.it.Next(ctx) + if errors.Is(err, ErrNoMoreItems) { + return false + } + if err != nil { + return true + } + id := i.getId(t) + if _, ok := i.seen[id]; !ok { + i.current = &t + i.seen[id] = struct{}{} + return true + } + } +} + +// A simple iterator over a slice. +type SliceIterator[T any] []T + +func (s *SliceIterator[T]) HasNext(_ context.Context) bool { + return len(*s) > 0 +} + +func (s *SliceIterator[T]) Next(_ context.Context) (T, error) { + var t T + if len(*s) == 0 { + return t, ErrNoMoreItems + } + v := (*s)[0] + *s = (*s)[1:] + return v, nil +} + +type limitIterator[T any] struct { + it Iterator[T] + remaining int +} + +// NewLimitIterator wraps an iterator and yields at most n items. If n <= 0, +// the inner iterator is returned unchanged (no limit is applied). Note that +// this differs from ToSliceN, where n == 0 means unlimited but negative n +// yields zero items. +func NewLimitIterator[T any](iter Iterator[T], n int) Iterator[T] { + if n <= 0 { + return iter + } + return &limitIterator[T]{ + it: iter, + remaining: n, + } +} + +func (i *limitIterator[T]) HasNext(ctx context.Context) bool { + if i.remaining <= 0 { + return false + } + return i.it.HasNext(ctx) +} + +func (i *limitIterator[T]) Next(ctx context.Context) (T, error) { + var t T + if i.remaining <= 0 { + return t, ErrNoMoreItems + } + t, err := i.it.Next(ctx) + if err != nil { + return t, err + } + i.remaining-- + return t, nil +} diff --git a/libs/listing/listing_test.go b/libs/listing/listing_test.go new file mode 100644 index 00000000000..6837683eadd --- /dev/null +++ b/libs/listing/listing_test.go @@ -0,0 +1,380 @@ +package listing_test + +import ( + "context" + "errors" + "testing" + + "github.com/databricks/cli/libs/listing" + "github.com/stretchr/testify/assert" +) + +type requestResponse struct { + req string + page map[string][]int +} + +func makeIterator(reqsAndPages []requestResponse) listing.Iterator[int] { + reqs := make([]string, len(reqsAndPages)) + pages := make(map[string]map[string][]int) + for i, reqAndPage := range reqsAndPages { + reqs[i] = reqAndPage.req + pages[reqAndPage.req] = reqAndPage.page + } + nextReq := reqs[0] + iterator := listing.NewIterator(&nextReq, + func(ctx context.Context, req string) (map[string][]int, error) { + return pages[req], nil + }, + func(resp map[string][]int) []int { + return resp["page"] + }, + func(resp map[string][]int) *string { + for i, r := range reqs { + if r == nextReq && i+1 < len(reqs) { + nextReq = reqs[i+1] + return &nextReq + } + } + return nil + }, + ) + return iterator +} + +func TestIterator(t *testing.T) { + t.Run("basic iteration", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + {req: "page3", page: map[string][]int{"page": {5, 6}}}, + } + iterator := makeIterator(rrs) + + for i := 1; iterator.HasNext(t.Context()); i++ { + item, err := iterator.Next(t.Context()) + assert.NoError(t, err) + assert.Equal(t, i, item) + } + + _, err := iterator.Next(t.Context()) + assert.ErrorIs(t, err, listing.ErrNoMoreItems) + }) + + t.Run("error propagation", func(t *testing.T) { + expectedErr := errors.New("some error") + iterator := listing.NewIterator[struct{}, []int, struct{}](&struct{}{}, + func(ctx context.Context, req struct{}) ([]int, error) { + return nil, expectedErr + }, + nil, + nil, + ) + + _, err := iterator.Next(t.Context()) + assert.ErrorIs(t, err, expectedErr) + }) + + t.Run("error propagation from HasNext", func(t *testing.T) { + expectedErr := errors.New("some error") + iterator := listing.NewIterator[struct{}, []int, struct{}](&struct{}{}, + func(ctx context.Context, req struct{}) ([]int, error) { + return nil, expectedErr + }, + nil, + nil, + ) + + b := iterator.HasNext(t.Context()) + assert.True(t, b) + // Error from HasNext is stored and returned on call to Next + _, err := iterator.Next(t.Context()) + assert.ErrorIs(t, err, expectedErr) + // Error is cached + _, err2 := iterator.Next(t.Context()) + assert.Equal(t, err, err2) + }) + + t.Run("iteration with empty page in the middle", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {}}}, + {req: "page3", page: map[string][]int{"page": {3, 4}}}, + } + iterator := makeIterator(rrs) + + for i := 1; i <= 4; i++ { + item, err := iterator.Next(t.Context()) + assert.NoError(t, err) + assert.Equal(t, i, item) + } + + _, err := iterator.Next(t.Context()) + assert.ErrorIs(t, err, listing.ErrNoMoreItems) + }) + + t.Run("iteration with empty page at the end", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + {req: "page3", page: map[string][]int{"page": {}}}, + } + iterator := makeIterator(rrs) + + for i := 1; i <= 4; i++ { + item, err := iterator.Next(t.Context()) + assert.NoError(t, err) + assert.Equal(t, i, item) + } + + _, err := iterator.Next(t.Context()) + assert.ErrorIs(t, err, listing.ErrNoMoreItems) + }) + + t.Run("ToSlice returns all items", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + {req: "page3", page: map[string][]int{"page": {5, 6}}}, + } + iterator := makeIterator(rrs) + + items, err := listing.ToSlice(t.Context(), iterator) + assert.NoError(t, err) + assert.Equal(t, []int{1, 2, 3, 4, 5, 6}, items) + }) + + t.Run("ToSliceN returns the first N items", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + {req: "page3", page: map[string][]int{"page": {5, 6}}}, + } + iterator := makeIterator(rrs) + + items, err := listing.ToSliceN(t.Context(), iterator, 3) + assert.NoError(t, err) + assert.Equal(t, []int{1, 2, 3}, items) + }) +} + +func TestDedupeIterator(t *testing.T) { + t.Run("basic iteration", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4, 4}}}, + {req: "page3", page: map[string][]int{"page": {5, 5, 6}}}, + } + iterator := makeIterator(rrs) + dedupeIterator := listing.NewDedupeIterator[int, int]( + iterator, func(a int) int { return a }) + + for i := 1; i <= 6; i++ { + item, err := dedupeIterator.Next(t.Context()) + assert.NoError(t, err) + assert.Equal(t, i, item) + } + + _, err := dedupeIterator.Next(t.Context()) + assert.ErrorIs(t, err, listing.ErrNoMoreItems) + }) + + t.Run("HasNext caches appropriately", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4, 4}}}, + {req: "page3", page: map[string][]int{"page": {5, 5, 6}}}, + } + iterator := makeIterator(rrs) + dedupeIterator := listing.NewDedupeIterator[int, int]( + iterator, func(a int) int { return a }) + + var values []int + for dedupeIterator.HasNext(t.Context()) { + assert.True(t, dedupeIterator.HasNext(t.Context())) + v, err := dedupeIterator.Next(t.Context()) + values = append(values, v) + assert.NoError(t, err) + } + assert.Equal(t, []int{1, 2, 3, 4, 5, 6}, values) + }) + + t.Run("HasNext returns true when there is an error", func(t *testing.T) { + expectedErr := errors.New("some error") + iterator := listing.NewIterator[struct{}, []int, int](&struct{}{}, + func(ctx context.Context, req struct{}) ([]int, error) { + return nil, expectedErr + }, + nil, + nil, + ) + dedupeIterator := listing.NewDedupeIterator[int, int]( + iterator, func(a int) int { return a }) + assert.True(t, dedupeIterator.HasNext(t.Context())) + _, err := dedupeIterator.Next(t.Context()) + assert.ErrorIs(t, err, expectedErr) + }) +} + +func TestSliceIterator(t *testing.T) { + t.Run("basic iteration", func(t *testing.T) { + iterator := listing.SliceIterator[int]([]int{1, 2, 3, 4, 5}) + + for i := 1; i <= 5; i++ { + assert.True(t, iterator.HasNext(t.Context())) + item, err := iterator.Next(t.Context()) + assert.NoError(t, err) + assert.Equal(t, i, item) + } + + assert.False(t, iterator.HasNext(t.Context())) + _, err := iterator.Next(t.Context()) + assert.ErrorIs(t, err, listing.ErrNoMoreItems) + }) + + t.Run("ToSlice returns all items", func(t *testing.T) { + iterator := listing.SliceIterator[int]([]int{1, 2, 3, 4, 5}) + + items, err := listing.ToSlice[int](t.Context(), &iterator) + assert.NoError(t, err) + assert.Equal(t, []int{1, 2, 3, 4, 5}, items) + }) + + t.Run("ToSliceN returns the first N items", func(t *testing.T) { + iterator := listing.SliceIterator[int]([]int{1, 2, 3, 4, 5}) + + items, err := listing.ToSliceN[int](t.Context(), &iterator, 3) + assert.NoError(t, err) + assert.Equal(t, []int{1, 2, 3}, items) + }) +} + +func TestLimitIterator(t *testing.T) { + t.Run("caps results when limit less than total", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + {req: "page3", page: map[string][]int{"page": {5, 6}}}, + } + iterator := makeIterator(rrs) + limited := listing.NewLimitIterator[int](iterator, 3) + + items, err := listing.ToSlice(t.Context(), limited) + assert.NoError(t, err) + assert.Equal(t, []int{1, 2, 3}, items) + }) + + t.Run("limit greater than total returns all items", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + } + iterator := makeIterator(rrs) + limited := listing.NewLimitIterator[int](iterator, 100) + + items, err := listing.ToSlice(t.Context(), limited) + assert.NoError(t, err) + assert.Equal(t, []int{1, 2, 3, 4}, items) + }) + + t.Run("limit of one", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + } + iterator := makeIterator(rrs) + limited := listing.NewLimitIterator[int](iterator, 1) + + items, err := listing.ToSlice(t.Context(), limited) + assert.NoError(t, err) + assert.Equal(t, []int{1}, items) + }) + + t.Run("zero limit is no-op", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + } + iterator := makeIterator(rrs) + limited := listing.NewLimitIterator[int](iterator, 0) + + items, err := listing.ToSlice(t.Context(), limited) + assert.NoError(t, err) + assert.Equal(t, []int{1, 2, 3, 4}, items) + }) + + t.Run("negative limit is no-op", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + } + iterator := makeIterator(rrs) + limited := listing.NewLimitIterator[int](iterator, -5) + + items, err := listing.ToSlice(t.Context(), limited) + assert.NoError(t, err) + assert.Equal(t, []int{1, 2, 3, 4}, items) + }) + + t.Run("Next returns ErrNoMoreItems after limit exhausted", func(t *testing.T) { + iterator := listing.SliceIterator[int]([]int{1, 2, 3, 4, 5}) + limited := listing.NewLimitIterator[int](&iterator, 2) + + item1, err := limited.Next(t.Context()) + assert.NoError(t, err) + assert.Equal(t, 1, item1) + + item2, err := limited.Next(t.Context()) + assert.NoError(t, err) + assert.Equal(t, 2, item2) + + _, err = limited.Next(t.Context()) + assert.ErrorIs(t, err, listing.ErrNoMoreItems) + }) + + t.Run("error propagation from inner iterator", func(t *testing.T) { + expectedErr := errors.New("some error") + iterator := listing.NewIterator[struct{}, []int, int](&struct{}{}, + func(ctx context.Context, req struct{}) ([]int, error) { + return nil, expectedErr + }, + nil, + nil, + ) + limited := listing.NewLimitIterator[int](iterator, 5) + + assert.True(t, limited.HasNext(t.Context())) + _, err := limited.Next(t.Context()) + assert.ErrorIs(t, err, expectedErr) + }) + + t.Run("standard HasNext/Next loop", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + {req: "page3", page: map[string][]int{"page": {5, 6}}}, + } + iterator := makeIterator(rrs) + limited := listing.NewLimitIterator[int](iterator, 4) + + var values []int + for limited.HasNext(t.Context()) { + v, err := limited.Next(t.Context()) + assert.NoError(t, err) + values = append(values, v) + } + assert.Equal(t, []int{1, 2, 3, 4}, values) + }) + + t.Run("HasNext is idempotent", func(t *testing.T) { + iterator := listing.SliceIterator[int]([]int{1, 2, 3}) + limited := listing.NewLimitIterator[int](&iterator, 2) + + assert.True(t, limited.HasNext(t.Context())) + assert.True(t, limited.HasNext(t.Context())) + + v, err := limited.Next(t.Context()) + assert.NoError(t, err) + assert.Equal(t, 1, v) + }) +} diff --git a/libs/listing/seq.go b/libs/listing/seq.go new file mode 100644 index 00000000000..68b15f7927a --- /dev/null +++ b/libs/listing/seq.go @@ -0,0 +1,51 @@ +package listing + +import ( + "context" + "iter" +) + +// SeqIterator adapts an iter.Seq2, which is what sdk-go list methods return, +// to the pull-style Iterator. +type SeqIterator[T any] struct { + next func() (T, error, bool) + stop func() + peeked bool + done bool + value T + err error +} + +// FromSeq returns an Iterator over seq. Call Close if the iterator may not be +// consumed to the end, to release the sequence. +func FromSeq[T any](seq iter.Seq2[T, error]) *SeqIterator[T] { + next, stop := iter.Pull2(seq) + return &SeqIterator[T]{next: next, stop: stop} +} + +func (s *SeqIterator[T]) HasNext(_ context.Context) bool { + if !s.peeked && !s.done { + var ok bool + s.value, s.err, ok = s.next() + s.peeked = true + if !ok { + s.done = true + s.stop() + } + } + return !s.done +} + +func (s *SeqIterator[T]) Next(ctx context.Context) (T, error) { + if !s.HasNext(ctx) { + var zero T + return zero, ErrNoMoreItems + } + s.peeked = false + return s.value, s.err +} + +// Close releases the underlying sequence. +func (s *SeqIterator[T]) Close() { + s.stop() +} diff --git a/libs/locker/locker.go b/libs/locker/locker.go index 0de7fdb4d96..a8a1ffe10c6 100644 --- a/libs/locker/locker.go +++ b/libs/locker/locker.go @@ -12,7 +12,7 @@ import ( "time" "github.com/databricks/cli/libs/filer" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" "github.com/google/uuid" ) @@ -202,7 +202,7 @@ func (locker *Locker) Unlock(ctx context.Context, opts ...UnlockOption) error { return nil } -func CreateLocker(user, targetDir string, w *databricks.WorkspaceClient) (*Locker, error) { +func CreateLocker(user, targetDir string, w *sdkclients.Clients) (*Locker, error) { filer, err := filer.NewWorkspaceFilesClient(w, targetDir) if err != nil { return nil, err diff --git a/libs/log/logger.go b/libs/log/logger.go index 0687634ec73..854adcd8d7e 100644 --- a/libs/log/logger.go +++ b/libs/log/logger.go @@ -6,6 +6,8 @@ import ( "log/slog" "runtime" "time" + + "github.com/databricks/cli/libs/apierrs" ) // GetLogger returns either the logger configured on the context, @@ -20,6 +22,7 @@ func GetLogger(ctx context.Context) *slog.Logger { // helper function to abstract logging a string message. func log(ctx context.Context, logger *slog.Logger, level slog.Level, msg string) { + msg = apierrs.StripPrefix(msg) if prefix := getPrefix(ctx); prefix != "" { msg = prefix + ": " + msg } diff --git a/libs/notebook/detect.go b/libs/notebook/detect.go index d9be548a5c6..a70081297cd 100644 --- a/libs/notebook/detect.go +++ b/libs/notebook/detect.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - "github.com/databricks/databricks-sdk-go/service/workspace" + workspace "github.com/databricks/cli/libs/workspaceapi" ) // FileInfoWithWorkspaceObjectInfo is an interface implemented by [fs.FileInfo] values that diff --git a/libs/notebook/detect_jupyter.go b/libs/notebook/detect_jupyter.go index 45233414007..e73c2514431 100644 --- a/libs/notebook/detect_jupyter.go +++ b/libs/notebook/detect_jupyter.go @@ -8,7 +8,7 @@ import ( "os" "path/filepath" - "github.com/databricks/databricks-sdk-go/service/workspace" + workspace "github.com/databricks/cli/libs/workspaceapi" ) type jupyterDatabricksMetadata struct { diff --git a/libs/notebook/detect_jupyter_test.go b/libs/notebook/detect_jupyter_test.go index af29a221493..3708ab568fe 100644 --- a/libs/notebook/detect_jupyter_test.go +++ b/libs/notebook/detect_jupyter_test.go @@ -5,7 +5,7 @@ import ( "path/filepath" "testing" - "github.com/databricks/databricks-sdk-go/service/workspace" + workspace "github.com/databricks/cli/libs/workspaceapi" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/libs/notebook/detect_test.go b/libs/notebook/detect_test.go index c774612c9bf..ac6abff912b 100644 --- a/libs/notebook/detect_test.go +++ b/libs/notebook/detect_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/databricks/cli/libs/fakefs" - "github.com/databricks/databricks-sdk-go/service/workspace" + workspace "github.com/databricks/cli/libs/workspaceapi" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/libs/notebook/ext.go b/libs/notebook/ext.go index 69d6eab6c92..d13eef27cf2 100644 --- a/libs/notebook/ext.go +++ b/libs/notebook/ext.go @@ -4,7 +4,7 @@ import ( "path" "strings" - "github.com/databricks/databricks-sdk-go/service/workspace" + workspace "github.com/databricks/cli/libs/workspaceapi" ) const ( diff --git a/libs/notebook/ext_test.go b/libs/notebook/ext_test.go index 7ccd0d33af8..501bd62ad93 100644 --- a/libs/notebook/ext_test.go +++ b/libs/notebook/ext_test.go @@ -3,7 +3,7 @@ package notebook import ( "testing" - "github.com/databricks/databricks-sdk-go/service/workspace" + workspace "github.com/databricks/cli/libs/workspaceapi" "github.com/stretchr/testify/assert" ) diff --git a/libs/qualitymonitors/client.go b/libs/qualitymonitors/client.go new file mode 100644 index 00000000000..6672edcea6d --- /dev/null +++ b/libs/qualitymonitors/client.go @@ -0,0 +1,19 @@ +// Package qualitymonitors is a client for the legacy Unity Catalog quality +// monitors API (/api/2.1/unity-catalog/tables/{table_name}/monitor), which +// sdk-go does not provide (it only has the data-quality v1 API). +package qualitymonitors + +import "github.com/databricks/cli/libs/apiclient" + +// Client calls the quality monitors API. +type Client struct { + qualityMonitorsImpl +} + +func New(c *apiclient.Client) *Client { + return &Client{qualityMonitorsImpl{client: c}} +} + +func addWorkspaceID(c *apiclient.Client, headers map[string]string) { + c.AddWorkspaceIDHeader(headers) +} diff --git a/libs/qualitymonitors/client_test.go b/libs/qualitymonitors/client_test.go new file mode 100644 index 00000000000..a3e180eb77e --- /dev/null +++ b/libs/qualitymonitors/client_test.go @@ -0,0 +1,22 @@ +package qualitymonitors + +import ( + "net/http" + "testing" + + "github.com/databricks/cli/libs/apiclient/apiclienttest" + "github.com/databricks/cli/libs/apierrs" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestGetMissingMonitor(t *testing.T) { + c := New(apiclienttest.New(t, func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, "/api/2.1/unity-catalog/tables/main.default.t/monitor", r.URL.Path) + w.WriteHeader(http.StatusNotFound) + _, _ = w.Write([]byte(`{"error_code":"RESOURCE_DOES_NOT_EXIST","message":"no monitor"}`)) + })) + _, err := c.Get(t.Context(), GetQualityMonitorRequest{TableName: "main.default.t"}) + require.Error(t, err) + assert.True(t, apierrs.Is(err, apierrs.ErrResourceDoesNotExist)) +} diff --git a/libs/qualitymonitors/impl.go b/libs/qualitymonitors/impl.go new file mode 100644 index 00000000000..598491733ee --- /dev/null +++ b/libs/qualitymonitors/impl.go @@ -0,0 +1,118 @@ +// Code ported from github.com/databricks/databricks-sdk-go. + +package qualitymonitors + +import ( + "context" + "fmt" + "net/http" + + "github.com/databricks/cli/libs/apiclient" +) + +type qualityMonitorsImpl struct { + client *apiclient.Client +} + +func (a *qualityMonitorsImpl) CancelRefresh(ctx context.Context, request CancelRefreshRequest) error { + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v/monitor/refreshes/%v/cancel", request.TableName, request.RefreshId) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPost, path, headers, queryParams, request, nil) + return err +} + +func (a *qualityMonitorsImpl) Create(ctx context.Context, request CreateMonitor) (*MonitorInfo, error) { + var monitorInfo MonitorInfo + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v/monitor", request.TableName) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPost, path, headers, queryParams, request, &monitorInfo) + return &monitorInfo, err +} + +func (a *qualityMonitorsImpl) Delete(ctx context.Context, request DeleteQualityMonitorRequest) (*DeleteMonitorResponse, error) { + var deleteMonitorResponse DeleteMonitorResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v/monitor", request.TableName) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodDelete, path, headers, queryParams, apiclient.URLQuery(request), &deleteMonitorResponse) + return &deleteMonitorResponse, err +} + +func (a *qualityMonitorsImpl) Get(ctx context.Context, request GetQualityMonitorRequest) (*MonitorInfo, error) { + var monitorInfo MonitorInfo + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v/monitor", request.TableName) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &monitorInfo) + return &monitorInfo, err +} + +func (a *qualityMonitorsImpl) GetRefresh(ctx context.Context, request GetRefreshRequest) (*MonitorRefreshInfo, error) { + var monitorRefreshInfo MonitorRefreshInfo + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v/monitor/refreshes/%v", request.TableName, request.RefreshId) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &monitorRefreshInfo) + return &monitorRefreshInfo, err +} + +func (a *qualityMonitorsImpl) ListRefreshes(ctx context.Context, request ListRefreshesRequest) (*MonitorRefreshListResponse, error) { + var monitorRefreshListResponse MonitorRefreshListResponse + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v/monitor/refreshes", request.TableName) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &monitorRefreshListResponse) + return &monitorRefreshListResponse, err +} + +func (a *qualityMonitorsImpl) RegenerateDashboard(ctx context.Context, request RegenerateDashboardRequest) (*RegenerateDashboardResponse, error) { + var regenerateDashboardResponse RegenerateDashboardResponse + path := fmt.Sprintf("/api/2.1/quality-monitoring/tables/%v/monitor/dashboard", request.TableName) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPost, path, headers, queryParams, request, ®enerateDashboardResponse) + return ®enerateDashboardResponse, err +} + +func (a *qualityMonitorsImpl) RunRefresh(ctx context.Context, request RunRefreshRequest) (*MonitorRefreshInfo, error) { + var monitorRefreshInfo MonitorRefreshInfo + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v/monitor/refreshes", request.TableName) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPost, path, headers, queryParams, request, &monitorRefreshInfo) + return &monitorRefreshInfo, err +} + +func (a *qualityMonitorsImpl) Update(ctx context.Context, request UpdateMonitor) (*MonitorInfo, error) { + var monitorInfo MonitorInfo + path := fmt.Sprintf("/api/2.1/unity-catalog/tables/%v/monitor", request.TableName) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPut, path, headers, queryParams, request, &monitorInfo) + return &monitorInfo, err +} diff --git a/libs/qualitymonitors/model.go b/libs/qualitymonitors/model.go new file mode 100644 index 00000000000..1fc1dc55419 --- /dev/null +++ b/libs/qualitymonitors/model.go @@ -0,0 +1,586 @@ +// Code ported from github.com/databricks/databricks-sdk-go /service/catalog/model.go. + +package qualitymonitors + +import ( + "fmt" +) + +type CancelRefreshRequest struct { + RefreshId int64 `json:"-" url:"-"` + // UC table name in format `catalog.schema.table_name`. table_name is case + // insensitive and spaces are disallowed. + TableName string `json:"-" url:"-"` +} + +type CreateMonitor struct { + // [Create:REQ Update:IGN] Field for specifying the absolute path to a + // custom directory to store data-monitoring assets. Normally prepopulated + // to a default user location via UI and Python APIs. + AssetsDir string `json:"assets_dir"` + // [Create:OPT Update:OPT] Baseline table name. Baseline data is used to + // compute drift from the data in the monitored `table_name`. The baseline + // table and the monitored table shall have the same schema. + BaselineTableName string `json:"baseline_table_name,omitempty"` + // [Create:OPT Update:OPT] Custom metrics. + CustomMetrics []MonitorMetric `json:"custom_metrics,omitempty"` + // [Create:OPT Update:OPT] Data classification related config. + DataClassificationConfig *MonitorDataClassificationConfig `json:"data_classification_config,omitempty"` + + InferenceLog *MonitorInferenceLog `json:"inference_log,omitempty"` + // [Create:ERR Update:IGN] The latest error message for a monitor failure. + LatestMonitorFailureMsg string `json:"latest_monitor_failure_msg,omitempty"` + // [Create:OPT Update:OPT] Field for specifying notification settings. + Notifications *MonitorNotifications `json:"notifications,omitempty"` + // [Create:REQ Update:REQ] Schema where output tables are created. Needs to + // be in 2-level format {catalog}.{schema} + OutputSchemaName string `json:"output_schema_name"` + // [Create:OPT Update:OPT] The monitor schedule. + Schedule *MonitorCronSchedule `json:"schedule,omitempty"` + // Whether to skip creating a default dashboard summarizing data quality + // metrics. + SkipBuiltinDashboard bool `json:"skip_builtin_dashboard,omitempty"` + // [Create:OPT Update:OPT] List of column expressions to slice data with for + // targeted analysis. The data is grouped by each expression independently, + // resulting in a separate slice for each predicate and its complements. For + // example `slicing_exprs=[“col_1”, “col_2 > 10”]` will generate the + // following slices: two slices for `col_2 > 10` (True and False), and one + // slice per unique value in `col1`. For high-cardinality columns, only the + // top 100 unique values by frequency will generate slices. + SlicingExprs []string `json:"slicing_exprs,omitempty"` + // Configuration for monitoring snapshot tables. + Snapshot *MonitorSnapshot `json:"snapshot,omitempty"` + // UC table name in format `catalog.schema.table_name`. This field + // corresponds to the {full_table_name_arg} arg in the endpoint path. + TableName string `json:"-" url:"-"` + // Configuration for monitoring time series tables. + TimeSeries *MonitorTimeSeries `json:"time_series,omitempty"` + // Optional argument to specify the warehouse for dashboard creation. If not + // specified, the first running warehouse will be used. + WarehouseId string `json:"warehouse_id,omitempty"` +} + +type DeleteMonitorResponse struct{} + +type DeleteQualityMonitorRequest struct { + // UC table name in format `catalog.schema.table_name`. This field + // corresponds to the {full_table_name_arg} arg in the endpoint path. + TableName string `json:"-" url:"-"` +} + +type GetQualityMonitorRequest struct { + // UC table name in format `catalog.schema.table_name`. This field + // corresponds to the {full_table_name_arg} arg in the endpoint path. + TableName string `json:"-" url:"-"` +} + +type GetRefreshRequest struct { + // ID of the refresh. + RefreshId int64 `json:"-" url:"-"` + // Full name of the table. + TableName string `json:"-" url:"-"` +} + +type ListRefreshesRequest struct { + // UC table name in format `catalog.schema.table_name`. table_name is case + // insensitive and spaces are disallowed. + TableName string `json:"-" url:"-"` +} + +type MonitorCronSchedule struct { + // Read only field that indicates whether a schedule is paused or not. + PauseStatus MonitorCronSchedulePauseStatus `json:"pause_status,omitempty"` + // The expression that determines when to run the monitor. See [examples]. + // + // [examples]: https://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html + QuartzCronExpression string `json:"quartz_cron_expression"` + // The timezone id (e.g., ``PST``) in which to evaluate the quartz + // expression. + TimezoneId string `json:"timezone_id"` +} + +// Source link: +// https://src.dev.databricks.com/databricks/universe/-/blob/elastic-spark-common/api/messages/schedule.proto +// Monitoring workflow schedule pause status. +type MonitorCronSchedulePauseStatus string + +const MonitorCronSchedulePauseStatusPaused MonitorCronSchedulePauseStatus = `PAUSED` + +const MonitorCronSchedulePauseStatusUnpaused MonitorCronSchedulePauseStatus = `UNPAUSED` + +const MonitorCronSchedulePauseStatusUnspecified MonitorCronSchedulePauseStatus = `UNSPECIFIED` + +// String representation for [fmt.Print] +func (f *MonitorCronSchedulePauseStatus) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *MonitorCronSchedulePauseStatus) Set(v string) error { + switch v { + case `PAUSED`, `UNPAUSED`, `UNSPECIFIED`: + *f = MonitorCronSchedulePauseStatus(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "PAUSED", "UNPAUSED", "UNSPECIFIED"`, v) + } +} + +// Values returns all possible values for MonitorCronSchedulePauseStatus. +// +// There is no guarantee on the order of the values in the slice. +func (f *MonitorCronSchedulePauseStatus) Values() []MonitorCronSchedulePauseStatus { + return []MonitorCronSchedulePauseStatus{ + MonitorCronSchedulePauseStatusPaused, + MonitorCronSchedulePauseStatusUnpaused, + MonitorCronSchedulePauseStatusUnspecified, + } +} + +// Type always returns MonitorCronSchedulePauseStatus to satisfy [pflag.Value] interface +func (f *MonitorCronSchedulePauseStatus) Type() string { + return "MonitorCronSchedulePauseStatus" +} + +// Data classification related configuration. +type MonitorDataClassificationConfig struct { + // Whether to enable data classification. + Enabled bool `json:"enabled,omitempty"` +} + +type MonitorDestination struct { + // The list of email addresses to send the notification to. A maximum of 5 + // email addresses is supported. + EmailAddresses []string `json:"email_addresses,omitempty"` +} + +type MonitorInferenceLog struct { + // List of granularities to use when aggregating data into time windows + // based on their timestamp. + Granularities []string `json:"granularities"` + // Column for the label. + LabelCol string `json:"label_col,omitempty"` + // Column for the model identifier. + ModelIdCol string `json:"model_id_col"` + // Column for the prediction. + PredictionCol string `json:"prediction_col"` + // Column for prediction probabilities + PredictionProbaCol string `json:"prediction_proba_col,omitempty"` + // Problem type the model aims to solve. + ProblemType MonitorInferenceLogProblemType `json:"problem_type"` + // Column for the timestamp. + TimestampCol string `json:"timestamp_col"` +} + +type MonitorInferenceLogProblemType string + +const MonitorInferenceLogProblemTypeProblemTypeClassification MonitorInferenceLogProblemType = `PROBLEM_TYPE_CLASSIFICATION` + +const MonitorInferenceLogProblemTypeProblemTypeRegression MonitorInferenceLogProblemType = `PROBLEM_TYPE_REGRESSION` + +// String representation for [fmt.Print] +func (f *MonitorInferenceLogProblemType) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *MonitorInferenceLogProblemType) Set(v string) error { + switch v { + case `PROBLEM_TYPE_CLASSIFICATION`, `PROBLEM_TYPE_REGRESSION`: + *f = MonitorInferenceLogProblemType(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "PROBLEM_TYPE_CLASSIFICATION", "PROBLEM_TYPE_REGRESSION"`, v) + } +} + +// Values returns all possible values for MonitorInferenceLogProblemType. +// +// There is no guarantee on the order of the values in the slice. +func (f *MonitorInferenceLogProblemType) Values() []MonitorInferenceLogProblemType { + return []MonitorInferenceLogProblemType{ + MonitorInferenceLogProblemTypeProblemTypeClassification, + MonitorInferenceLogProblemTypeProblemTypeRegression, + } +} + +// Type always returns MonitorInferenceLogProblemType to satisfy [pflag.Value] interface +func (f *MonitorInferenceLogProblemType) Type() string { + return "MonitorInferenceLogProblemType" +} + +type MonitorInfo struct { + // [Create:REQ Update:IGN] Field for specifying the absolute path to a + // custom directory to store data-monitoring assets. Normally prepopulated + // to a default user location via UI and Python APIs. + AssetsDir string `json:"assets_dir,omitempty"` + // [Create:OPT Update:OPT] Baseline table name. Baseline data is used to + // compute drift from the data in the monitored `table_name`. The baseline + // table and the monitored table shall have the same schema. + BaselineTableName string `json:"baseline_table_name,omitempty"` + // [Create:OPT Update:OPT] Custom metrics. + CustomMetrics []MonitorMetric `json:"custom_metrics,omitempty"` + // [Create:ERR Update:OPT] Id of dashboard that visualizes the computed + // metrics. This can be empty if the monitor is in PENDING state. + DashboardId string `json:"dashboard_id,omitempty"` + // [Create:OPT Update:OPT] Data classification related config. + DataClassificationConfig *MonitorDataClassificationConfig `json:"data_classification_config,omitempty"` + // [Create:ERR Update:IGN] Table that stores drift metrics data. Format: + // `catalog.schema.table_name`. + DriftMetricsTableName string `json:"drift_metrics_table_name"` + + InferenceLog *MonitorInferenceLog `json:"inference_log,omitempty"` + // [Create:ERR Update:IGN] The latest error message for a monitor failure. + LatestMonitorFailureMsg string `json:"latest_monitor_failure_msg,omitempty"` + // [Create:ERR Update:IGN] Represents the current monitor configuration + // version in use. The version will be represented in a numeric fashion + // (1,2,3...). The field has flexibility to take on negative values, which + // can indicate corrupted monitor_version numbers. + MonitorVersion int64 `json:"monitor_version"` + // [Create:OPT Update:OPT] Field for specifying notification settings. + Notifications *MonitorNotifications `json:"notifications,omitempty"` + // [Create:REQ Update:REQ] Schema where output tables are created. Needs to + // be in 2-level format {catalog}.{schema} + OutputSchemaName string `json:"output_schema_name"` + // [Create:ERR Update:IGN] Table that stores profile metrics data. Format: + // `catalog.schema.table_name`. + ProfileMetricsTableName string `json:"profile_metrics_table_name"` + // [Create:OPT Update:OPT] The monitor schedule. + Schedule *MonitorCronSchedule `json:"schedule,omitempty"` + // [Create:OPT Update:OPT] List of column expressions to slice data with for + // targeted analysis. The data is grouped by each expression independently, + // resulting in a separate slice for each predicate and its complements. For + // example `slicing_exprs=[“col_1”, “col_2 > 10”]` will generate the + // following slices: two slices for `col_2 > 10` (True and False), and one + // slice per unique value in `col1`. For high-cardinality columns, only the + // top 100 unique values by frequency will generate slices. + SlicingExprs []string `json:"slicing_exprs,omitempty"` + // Configuration for monitoring snapshot tables. + Snapshot *MonitorSnapshot `json:"snapshot,omitempty"` + // [Create:ERR Update:IGN] The monitor status. + Status MonitorInfoStatus `json:"status"` + // [Create:ERR Update:IGN] UC table to monitor. Format: + // `catalog.schema.table_name` + TableName string `json:"table_name"` + // Configuration for monitoring time series tables. + TimeSeries *MonitorTimeSeries `json:"time_series,omitempty"` +} + +type MonitorInfoStatus string + +const MonitorInfoStatusMonitorStatusActive MonitorInfoStatus = `MONITOR_STATUS_ACTIVE` + +const MonitorInfoStatusMonitorStatusDeletePending MonitorInfoStatus = `MONITOR_STATUS_DELETE_PENDING` + +const MonitorInfoStatusMonitorStatusError MonitorInfoStatus = `MONITOR_STATUS_ERROR` + +const MonitorInfoStatusMonitorStatusFailed MonitorInfoStatus = `MONITOR_STATUS_FAILED` + +const MonitorInfoStatusMonitorStatusPending MonitorInfoStatus = `MONITOR_STATUS_PENDING` + +// String representation for [fmt.Print] +func (f *MonitorInfoStatus) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *MonitorInfoStatus) Set(v string) error { + switch v { + case `MONITOR_STATUS_ACTIVE`, `MONITOR_STATUS_DELETE_PENDING`, `MONITOR_STATUS_ERROR`, `MONITOR_STATUS_FAILED`, `MONITOR_STATUS_PENDING`: + *f = MonitorInfoStatus(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "MONITOR_STATUS_ACTIVE", "MONITOR_STATUS_DELETE_PENDING", "MONITOR_STATUS_ERROR", "MONITOR_STATUS_FAILED", "MONITOR_STATUS_PENDING"`, v) + } +} + +// Values returns all possible values for MonitorInfoStatus. +// +// There is no guarantee on the order of the values in the slice. +func (f *MonitorInfoStatus) Values() []MonitorInfoStatus { + return []MonitorInfoStatus{ + MonitorInfoStatusMonitorStatusActive, + MonitorInfoStatusMonitorStatusDeletePending, + MonitorInfoStatusMonitorStatusError, + MonitorInfoStatusMonitorStatusFailed, + MonitorInfoStatusMonitorStatusPending, + } +} + +// Type always returns MonitorInfoStatus to satisfy [pflag.Value] interface +func (f *MonitorInfoStatus) Type() string { + return "MonitorInfoStatus" +} + +// Custom metric definition. +type MonitorMetric struct { + // Jinja template for a SQL expression that specifies how to compute the + // metric. See [create metric definition]. + // + // [create metric definition]: https://docs.databricks.com/en/lakehouse-monitoring/custom-metrics.html#create-definition + Definition string `json:"definition"` + // A list of column names in the input table the metric should be computed + // for. Can use ``":table"`` to indicate that the metric needs information + // from multiple columns. + InputColumns []string `json:"input_columns"` + // Name of the metric in the output tables. + Name string `json:"name"` + // The output type of the custom metric. + OutputDataType string `json:"output_data_type"` + // Can only be one of ``"CUSTOM_METRIC_TYPE_AGGREGATE"``, + // ``"CUSTOM_METRIC_TYPE_DERIVED"``, or ``"CUSTOM_METRIC_TYPE_DRIFT"``. The + // ``"CUSTOM_METRIC_TYPE_AGGREGATE"`` and ``"CUSTOM_METRIC_TYPE_DERIVED"`` + // metrics are computed on a single table, whereas the + // ``"CUSTOM_METRIC_TYPE_DRIFT"`` compare metrics across baseline and input + // table, or across the two consecutive time windows. - + // CUSTOM_METRIC_TYPE_AGGREGATE: only depend on the existing columns in your + // table - CUSTOM_METRIC_TYPE_DERIVED: depend on previously computed + // aggregate metrics - CUSTOM_METRIC_TYPE_DRIFT: depend on previously + // computed aggregate or derived metrics + Type MonitorMetricType `json:"type"` +} + +// Can only be one of “\"CUSTOM_METRIC_TYPE_AGGREGATE\"“, +// “\"CUSTOM_METRIC_TYPE_DERIVED\"“, or “\"CUSTOM_METRIC_TYPE_DRIFT\"“. The +// “\"CUSTOM_METRIC_TYPE_AGGREGATE\"“ and “\"CUSTOM_METRIC_TYPE_DERIVED\"“ +// metrics are computed on a single table, whereas the +// “\"CUSTOM_METRIC_TYPE_DRIFT\"“ compare metrics across baseline and input +// table, or across the two consecutive time windows. - +// CUSTOM_METRIC_TYPE_AGGREGATE: only depend on the existing columns in your +// table - CUSTOM_METRIC_TYPE_DERIVED: depend on previously computed aggregate +// metrics - CUSTOM_METRIC_TYPE_DRIFT: depend on previously computed aggregate +// or derived metrics +type MonitorMetricType string + +const MonitorMetricTypeCustomMetricTypeAggregate MonitorMetricType = `CUSTOM_METRIC_TYPE_AGGREGATE` + +const MonitorMetricTypeCustomMetricTypeDerived MonitorMetricType = `CUSTOM_METRIC_TYPE_DERIVED` + +const MonitorMetricTypeCustomMetricTypeDrift MonitorMetricType = `CUSTOM_METRIC_TYPE_DRIFT` + +// String representation for [fmt.Print] +func (f *MonitorMetricType) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *MonitorMetricType) Set(v string) error { + switch v { + case `CUSTOM_METRIC_TYPE_AGGREGATE`, `CUSTOM_METRIC_TYPE_DERIVED`, `CUSTOM_METRIC_TYPE_DRIFT`: + *f = MonitorMetricType(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "CUSTOM_METRIC_TYPE_AGGREGATE", "CUSTOM_METRIC_TYPE_DERIVED", "CUSTOM_METRIC_TYPE_DRIFT"`, v) + } +} + +// Values returns all possible values for MonitorMetricType. +// +// There is no guarantee on the order of the values in the slice. +func (f *MonitorMetricType) Values() []MonitorMetricType { + return []MonitorMetricType{ + MonitorMetricTypeCustomMetricTypeAggregate, + MonitorMetricTypeCustomMetricTypeDerived, + MonitorMetricTypeCustomMetricTypeDrift, + } +} + +// Type always returns MonitorMetricType to satisfy [pflag.Value] interface +func (f *MonitorMetricType) Type() string { + return "MonitorMetricType" +} + +type MonitorNotifications struct { + // Destinations to send notifications on failure/timeout. + OnFailure *MonitorDestination `json:"on_failure,omitempty"` + // Destinations to send notifications on new classification tag detected. + OnNewClassificationTagDetected *MonitorDestination `json:"on_new_classification_tag_detected,omitempty"` +} + +type MonitorRefreshInfo struct { + // Time at which refresh operation completed (milliseconds since 1/1/1970 + // UTC). + EndTimeMs int64 `json:"end_time_ms,omitempty"` + // An optional message to give insight into the current state of the job + // (e.g. FAILURE messages). + Message string `json:"message,omitempty"` + // Unique id of the refresh operation. + RefreshId int64 `json:"refresh_id"` + // Time at which refresh operation was initiated (milliseconds since + // 1/1/1970 UTC). + StartTimeMs int64 `json:"start_time_ms"` + // The current state of the refresh. + State MonitorRefreshInfoState `json:"state"` + // The method by which the refresh was triggered. + Trigger MonitorRefreshInfoTrigger `json:"trigger,omitempty"` +} + +// The current state of the refresh. +type MonitorRefreshInfoState string + +const MonitorRefreshInfoStateCanceled MonitorRefreshInfoState = `CANCELED` + +const MonitorRefreshInfoStateFailed MonitorRefreshInfoState = `FAILED` + +const MonitorRefreshInfoStatePending MonitorRefreshInfoState = `PENDING` + +const MonitorRefreshInfoStateRunning MonitorRefreshInfoState = `RUNNING` + +const MonitorRefreshInfoStateSuccess MonitorRefreshInfoState = `SUCCESS` + +const MonitorRefreshInfoStateUnknown MonitorRefreshInfoState = `UNKNOWN` + +// String representation for [fmt.Print] +func (f *MonitorRefreshInfoState) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *MonitorRefreshInfoState) Set(v string) error { + switch v { + case `CANCELED`, `FAILED`, `PENDING`, `RUNNING`, `SUCCESS`, `UNKNOWN`: + *f = MonitorRefreshInfoState(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "CANCELED", "FAILED", "PENDING", "RUNNING", "SUCCESS", "UNKNOWN"`, v) + } +} + +// Values returns all possible values for MonitorRefreshInfoState. +// +// There is no guarantee on the order of the values in the slice. +func (f *MonitorRefreshInfoState) Values() []MonitorRefreshInfoState { + return []MonitorRefreshInfoState{ + MonitorRefreshInfoStateCanceled, + MonitorRefreshInfoStateFailed, + MonitorRefreshInfoStatePending, + MonitorRefreshInfoStateRunning, + MonitorRefreshInfoStateSuccess, + MonitorRefreshInfoStateUnknown, + } +} + +// Type always returns MonitorRefreshInfoState to satisfy [pflag.Value] interface +func (f *MonitorRefreshInfoState) Type() string { + return "MonitorRefreshInfoState" +} + +type MonitorRefreshInfoTrigger string + +const MonitorRefreshInfoTriggerManual MonitorRefreshInfoTrigger = `MANUAL` + +const MonitorRefreshInfoTriggerSchedule MonitorRefreshInfoTrigger = `SCHEDULE` + +const MonitorRefreshInfoTriggerUnknownTrigger MonitorRefreshInfoTrigger = `UNKNOWN_TRIGGER` + +// String representation for [fmt.Print] +func (f *MonitorRefreshInfoTrigger) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *MonitorRefreshInfoTrigger) Set(v string) error { + switch v { + case `MANUAL`, `SCHEDULE`, `UNKNOWN_TRIGGER`: + *f = MonitorRefreshInfoTrigger(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "MANUAL", "SCHEDULE", "UNKNOWN_TRIGGER"`, v) + } +} + +// Values returns all possible values for MonitorRefreshInfoTrigger. +// +// There is no guarantee on the order of the values in the slice. +func (f *MonitorRefreshInfoTrigger) Values() []MonitorRefreshInfoTrigger { + return []MonitorRefreshInfoTrigger{ + MonitorRefreshInfoTriggerManual, + MonitorRefreshInfoTriggerSchedule, + MonitorRefreshInfoTriggerUnknownTrigger, + } +} + +// Type always returns MonitorRefreshInfoTrigger to satisfy [pflag.Value] interface +func (f *MonitorRefreshInfoTrigger) Type() string { + return "MonitorRefreshInfoTrigger" +} + +type MonitorRefreshListResponse struct { + // List of refreshes. + Refreshes []MonitorRefreshInfo `json:"refreshes,omitempty"` +} + +// Snapshot analysis configuration +type MonitorSnapshot struct{} + +// Time series analysis configuration. +type MonitorTimeSeries struct { + // Granularities for aggregating data into time windows based on their + // timestamp. Currently the following static granularities are supported: + // {``\"5 minutes\"``, ``\"30 minutes\"``, ``\"1 hour\"``, ``\"1 day\"``, + // ``\"\u003cn\u003e week(s)\"``, ``\"1 month\"``, ``\"1 year\"``}. + Granularities []string `json:"granularities"` + // Column for the timestamp. + TimestampCol string `json:"timestamp_col"` +} + +type RegenerateDashboardRequest struct { + // UC table name in format `catalog.schema.table_name`. This field + // corresponds to the {full_table_name_arg} arg in the endpoint path. + TableName string `json:"-" url:"-"` + // Optional argument to specify the warehouse for dashboard regeneration. If + // not specified, the first running warehouse will be used. + WarehouseId string `json:"warehouse_id,omitempty"` +} + +type RegenerateDashboardResponse struct { + DashboardId string `json:"dashboard_id,omitempty"` + // Parent folder is equivalent to {assets_dir}/{tableName} + ParentFolder string `json:"parent_folder,omitempty"` +} + +type RunRefreshRequest struct { + // UC table name in format `catalog.schema.table_name`. table_name is case + // insensitive and spaces are disallowed. + TableName string `json:"-" url:"-"` +} + +type UpdateMonitor struct { + // [Create:OPT Update:OPT] Baseline table name. Baseline data is used to + // compute drift from the data in the monitored `table_name`. The baseline + // table and the monitored table shall have the same schema. + BaselineTableName string `json:"baseline_table_name,omitempty"` + // [Create:OPT Update:OPT] Custom metrics. + CustomMetrics []MonitorMetric `json:"custom_metrics,omitempty"` + // [Create:ERR Update:OPT] Id of dashboard that visualizes the computed + // metrics. This can be empty if the monitor is in PENDING state. + DashboardId string `json:"dashboard_id,omitempty"` + // [Create:OPT Update:OPT] Data classification related config. + DataClassificationConfig *MonitorDataClassificationConfig `json:"data_classification_config,omitempty"` + + InferenceLog *MonitorInferenceLog `json:"inference_log,omitempty"` + // [Create:ERR Update:IGN] The latest error message for a monitor failure. + LatestMonitorFailureMsg string `json:"latest_monitor_failure_msg,omitempty"` + // [Create:OPT Update:OPT] Field for specifying notification settings. + Notifications *MonitorNotifications `json:"notifications,omitempty"` + // [Create:REQ Update:REQ] Schema where output tables are created. Needs to + // be in 2-level format {catalog}.{schema} + OutputSchemaName string `json:"output_schema_name"` + // [Create:OPT Update:OPT] The monitor schedule. + Schedule *MonitorCronSchedule `json:"schedule,omitempty"` + // [Create:OPT Update:OPT] List of column expressions to slice data with for + // targeted analysis. The data is grouped by each expression independently, + // resulting in a separate slice for each predicate and its complements. For + // example `slicing_exprs=[“col_1”, “col_2 > 10”]` will generate the + // following slices: two slices for `col_2 > 10` (True and False), and one + // slice per unique value in `col1`. For high-cardinality columns, only the + // top 100 unique values by frequency will generate slices. + SlicingExprs []string `json:"slicing_exprs,omitempty"` + // Configuration for monitoring snapshot tables. + Snapshot *MonitorSnapshot `json:"snapshot,omitempty"` + // UC table name in format `catalog.schema.table_name`. This field + // corresponds to the {full_table_name_arg} arg in the endpoint path. + TableName string `json:"-" url:"-"` + // Configuration for monitoring time series tables. + TimeSeries *MonitorTimeSeries `json:"time_series,omitempty"` +} diff --git a/libs/retry/filer_test.go b/libs/retry/filer_test.go index a264ce47066..3a4138a6bd3 100644 --- a/libs/retry/filer_test.go +++ b/libs/retry/filer_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/databricks/cli/libs/filer" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/sdk-go/core/apierr" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -33,7 +33,7 @@ func (f *flakyFiler) Write(ctx context.Context, path string, r io.Reader, mode . return nil } -var errTransient = &apierr.APIError{StatusCode: http.StatusGatewayTimeout, Message: "TEMPORARILY_UNAVAILABLE"} +var errTransient = apierr.FromHTTPError(http.StatusGatewayTimeout, nil, []byte(`{"message":"TEMPORARILY_UNAVAILABLE"}`)) func TestFilerRetriesSeekableReader(t *testing.T) { f := &flakyFiler{failures: 1, err: errTransient} @@ -69,7 +69,7 @@ func TestFilerGivesUp(t *testing.T) { } func TestFilerDoesNotRetryOtherErrors(t *testing.T) { - f := &flakyFiler{failures: 100, err: &apierr.APIError{StatusCode: http.StatusForbidden}} + f := &flakyFiler{failures: 100, err: apierr.FromHTTPError(http.StatusForbidden, nil, nil)} err := Filer(f).Write(testContext(t), "a", strings.NewReader("x"), filer.OverwriteIfExists) require.Error(t, err) assert.Len(t, f.bodies, 1) diff --git a/libs/retry/retry.go b/libs/retry/retry.go index 97ac0f0d6d6..27e9d1385b1 100644 --- a/libs/retry/retry.go +++ b/libs/retry/retry.go @@ -11,9 +11,11 @@ import ( "strings" "time" + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/log" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/sdk-go/core/apierr" ) // MaxRetries is the number of additional attempts made after the first one fails. @@ -37,19 +39,20 @@ func interval(ctx context.Context) time.Duration { return time.Duration(ms) * time.Millisecond } -// IsTransient returns true for 5xx and 408 errors that the SDK did not already retry. -// The SDK retries 504s matching its allTransientErrors patterns (e.g. "deadline exceeded"); -// this covers the remaining 504s like TEMPORARILY_UNAVAILABLE. +// IsTransient returns true for 5xx and 408 errors that the client transport did not already +// retry. The transport (libs/apiclient) retries 429 and 503; this covers the remaining 5xx, +// e.g. 504 TEMPORARILY_UNAVAILABLE. func IsTransient(ctx context.Context, err error) bool { apiErr, ok := errors.AsType[*apierr.APIError](err) if !ok { return false } - if apiErr.IsRetriable(ctx) { - // Already handled by SDK + status := apiErr.HTTPStatusCode() + if status == http.StatusServiceUnavailable || status == http.StatusTooManyRequests { + // Already handled by the transport return false } - return apiErr.StatusCode >= 500 || apiErr.StatusCode == http.StatusRequestTimeout + return status >= 500 || status == http.StatusRequestTimeout } // IsTransientRead returns true for errors worth retrying on an idempotent read: the transient @@ -90,14 +93,14 @@ func retryMessage(err error) string { msg := "retrying" if apiErr, ok := errors.AsType[*apierr.APIError](err); ok { endpoint := "" - if rw := apiErr.ResponseWrapper; rw != nil && rw.Response != nil && rw.Response.Request != nil { - req := rw.Response.Request - endpoint = fmt.Sprintf(" from %s %s", req.Method, req.URL.Path) + if method, u, ok := apiclient.RequestOf(err); ok { + endpoint = fmt.Sprintf(" from %s %s", method, u.Path) } - msg = fmt.Sprintf("retrying after %d %s%s", apiErr.StatusCode, http.StatusText(apiErr.StatusCode), endpoint) + status := apiErr.HTTPStatusCode() + msg = fmt.Sprintf("retrying after %d %s%s", status, http.StatusText(status), endpoint) // Include the context the caller added to the error, e.g. the path of the file being written. if err.Error() != apiErr.Error() { - msg += ": " + err.Error() + msg += ": " + apierrs.ErrorString(err) } } return msg diff --git a/libs/retry/retry_test.go b/libs/retry/retry_test.go index 0a9006cbedc..f6b807df5c7 100644 --- a/libs/retry/retry_test.go +++ b/libs/retry/retry_test.go @@ -10,28 +10,29 @@ import ( "time" "github.com/databricks/cli/libs/env" - "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/sdk-go/core/apierr" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestIsTransient(t *testing.T) { ctx := t.Context() - assert.True(t, IsTransient(ctx, &apierr.APIError{StatusCode: http.StatusGatewayTimeout, Message: "TEMPORARILY_UNAVAILABLE"})) - assert.True(t, IsTransient(ctx, &apierr.APIError{StatusCode: http.StatusInternalServerError})) - assert.True(t, IsTransient(ctx, &apierr.APIError{StatusCode: http.StatusRequestTimeout})) - // Retried by the SDK already. - assert.False(t, IsTransient(ctx, &apierr.APIError{StatusCode: http.StatusServiceUnavailable})) - assert.False(t, IsTransient(ctx, &apierr.APIError{StatusCode: http.StatusGatewayTimeout, Message: "deadline exceeded"})) - assert.False(t, IsTransient(ctx, &apierr.APIError{StatusCode: http.StatusForbidden})) + assert.True(t, IsTransient(ctx, apierr.FromHTTPError(http.StatusGatewayTimeout, nil, []byte(`{"message":"TEMPORARILY_UNAVAILABLE"}`)))) + assert.True(t, IsTransient(ctx, apierr.FromHTTPError(http.StatusInternalServerError, nil, nil))) + assert.True(t, IsTransient(ctx, apierr.FromHTTPError(http.StatusRequestTimeout, nil, nil))) + assert.True(t, IsTransient(ctx, apierr.FromHTTPError(http.StatusGatewayTimeout, nil, []byte(`{"message":"deadline exceeded"}`)))) + // Retried by the transport already. + assert.False(t, IsTransient(ctx, apierr.FromHTTPError(http.StatusServiceUnavailable, nil, nil))) + assert.False(t, IsTransient(ctx, apierr.FromHTTPError(http.StatusTooManyRequests, nil, nil))) + assert.False(t, IsTransient(ctx, apierr.FromHTTPError(http.StatusForbidden, nil, nil))) assert.False(t, IsTransient(ctx, errors.New("boom"))) } func TestIsTransientRead(t *testing.T) { ctx := t.Context() // Everything IsTransient covers is transient for a read too. - assert.True(t, IsTransientRead(ctx, &apierr.APIError{StatusCode: http.StatusInternalServerError})) - assert.True(t, IsTransientRead(ctx, &apierr.APIError{StatusCode: http.StatusRequestTimeout})) + assert.True(t, IsTransientRead(ctx, apierr.FromHTTPError(http.StatusInternalServerError, nil, nil))) + assert.True(t, IsTransientRead(ctx, apierr.FromHTTPError(http.StatusRequestTimeout, nil, nil))) // REFUSED_STREAM is the transport failure the SDK leaves unretried, so we replay the read (issue #6472). refusedStream := &url.Error{Op: "Get", URL: "https://example.test/api/2.0/workspace/get-status", Err: errors.New("stream error: stream ID 1; REFUSED_STREAM; received from peer")} assert.True(t, IsTransientRead(ctx, refusedStream)) @@ -42,9 +43,9 @@ func TestIsTransientRead(t *testing.T) { cancelled := &url.Error{Op: "Get", URL: "https://example.test/api/2.0/workspace/get-status", Err: context.Canceled} assert.False(t, IsTransientRead(ctx, cancelled)) // Not transient: retried by the SDK, client errors, and plain non-url errors. - assert.False(t, IsTransientRead(ctx, &apierr.APIError{StatusCode: http.StatusServiceUnavailable})) - assert.False(t, IsTransientRead(ctx, &apierr.APIError{StatusCode: http.StatusNotFound})) - assert.False(t, IsTransientRead(ctx, &apierr.APIError{StatusCode: http.StatusForbidden})) + assert.False(t, IsTransientRead(ctx, apierr.FromHTTPError(http.StatusServiceUnavailable, nil, nil))) + assert.False(t, IsTransientRead(ctx, apierr.FromHTTPError(http.StatusNotFound, nil, nil))) + assert.False(t, IsTransientRead(ctx, apierr.FromHTTPError(http.StatusForbidden, nil, nil))) assert.False(t, IsTransientRead(ctx, errors.New("boom"))) } @@ -110,7 +111,7 @@ func TestWithStopsOnContextCancel(t *testing.T) { } func TestRetryMessage(t *testing.T) { - apiErr := &apierr.APIError{StatusCode: http.StatusGatewayTimeout, Message: "boom"} + apiErr := apierr.FromHTTPError(http.StatusGatewayTimeout, nil, []byte(`{"message":"boom"}`)) assert.Equal(t, "retrying", retryMessage(errors.New("x"))) assert.Equal(t, "retrying after 504 Gateway Timeout", retryMessage(apiErr)) assert.Equal(t, "retrying after 504 Gateway Timeout: failed to upload /a/b: boom", retryMessage(fmt.Errorf("failed to upload /a/b: %w", apiErr))) diff --git a/libs/sdkclients/clients.go b/libs/sdkclients/clients.go new file mode 100644 index 00000000000..d68b4a4100e --- /dev/null +++ b/libs/sdkclients/clients.go @@ -0,0 +1,89 @@ +// Package sdkclients builds sdk-go API clients from the CLI's resolved +// authentication config. +// +// The CLI resolves host, profile and credentials once (libs/auth, cmd/root) +// using config.Config. Every sdk-go client built here reuses that resolution: +// requests are signed with config.Authenticate and no client re-reads +// ~/.databrickscfg or the environment. +package sdkclients + +import ( + "context" + + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/bundledeployments" + "github.com/databricks/cli/libs/databrickscfg/profile" + "github.com/databricks/cli/libs/qualitymonitors" + "github.com/databricks/cli/libs/sqllegacy" + "github.com/databricks/cli/libs/workspaceapi" + "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/sdk-go/options/client" +) + +// Clients holds the resolved config and one sdk-go client per API module. +// The same type serves workspace and account level commands; which APIs make +// sense depends on whether Config points at a workspace or an account host. +type Clients struct { + *services + + // Config is the resolved authentication config the clients were built from. + Config *config.Config + + // Hand-written clients for APIs sdk-go does not provide. + Workspace *workspaceapi.Client + BundleDeployments *bundledeployments.Client + QualityMonitors *qualitymonitors.Client + SqlLegacy *sqllegacy.Client +} + +// New returns sdk-go clients that authenticate with cfg. cfg must already be +// resolved (config.Config.EnsureResolved) and is shared, not copied, because +// config.Config embeds a sync.Mutex. +func New(ctx context.Context, cfg *config.Config) (*Clients, error) { + if err := cfg.EnsureResolved(); err != nil { + return nil, err + } + // Resolve the credentials provider up front, as the previous SDK's client + // constructor did as a side effect: callers inspect cfg.AuthType right + // after constructing clients. Errors surface on the first request. + _ = cfg.GetTokenSource() + s, err := newServices(ctx, Options(cfg)...) + if err != nil { + return nil, err + } + api, err := apiclient.New(cfg) + if err != nil { + return nil, err + } + return &Clients{ + services: s, + Config: cfg, + Workspace: workspaceapi.New(api), + BundleDeployments: bundledeployments.New(api), + QualityMonitors: qualitymonitors.New(api), + SqlLegacy: sqllegacy.New(api), + }, nil +} + +// Options returns the sdk-go client options that make a client authenticate +// and route requests the way the rest of the CLI does. +func Options(cfg *config.Config) []client.Option { + opts := []client.Option{ + client.WithHost(cfg.CanonicalHostName()), + client.WithCredentials(apiclient.NewCredentials(cfg)), + client.WithHTTPClient(apiclient.HTTPClient(cfg)), + client.WithoutConfigFile(), + client.WithoutEnv(), + } + // The workspace routing header is needed on unified ("SPOG") hosts; the + // CLI's "none" sentinel means "no workspace ID", so it is not forwarded. + if id := cfg.WorkspaceID; id != "" && id != profile.WorkspaceIDNone { + opts = append(opts, client.WithWorkspaceID(id)) + } + if cfg.AccountID != "" { + opts = append(opts, client.WithAccountID(cfg.AccountID)) + } + // cfg.HTTPTimeoutSeconds is enforced by the transport as an inactivity + // timeout (see apiclient.HTTPClient), not as a deadline for the whole call. + return opts +} diff --git a/libs/sdkclients/clusters.go b/libs/sdkclients/clusters.go new file mode 100644 index 00000000000..85fda9ce487 --- /dev/null +++ b/libs/sdkclients/clusters.go @@ -0,0 +1,49 @@ +package sdkclients + +import ( + "context" + "fmt" + "time" + + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/utils" + clusters "github.com/databricks/sdk-go/clusters/v2" +) + +const ensureClusterTimeout = 20 * time.Minute + +// EnsureClusterIsRunning starts the cluster if it is terminated and waits +// until it is running, as the previous SDK's helper of the same name did. +func (c *Clients) EnsureClusterIsRunning(ctx context.Context, clusterID string) error { + ctx, cancel := context.WithTimeout(ctx, ensureClusterTimeout) + defer cancel() + + for attempt := 1; ; attempt++ { + info, err := c.Clusters.GetCluster(ctx, clusters.GetClusterRequest{ClusterId: new(clusterID)}) + if err != nil { + return fmt.Errorf("get cluster info: %w", err) + } + switch info.State { + case clusters.ClusterState_ClusterState_Running: + return nil + case clusters.ClusterState_ClusterState_Terminated: + _, err := c.Clusters.StartCluster(ctx, clusters.StartClusterRequest{ClusterId: new(clusterID)}) + // INVALID_STATE means another process started it in the meantime. + if err != nil && apierrs.ErrorCode(err) != "INVALID_STATE" { + return fmt.Errorf("terminated -> start: %w", err) + } + case clusters.ClusterState_ClusterState_Terminating, + clusters.ClusterState_ClusterState_Pending, + clusters.ClusterState_ClusterState_Resizing, + clusters.ClusterState_ClusterState_Restarting: + default: + return fmt.Errorf("cluster %s is in %s state: %s", utils.Deref(info.ClusterName), info.State, utils.Deref(info.StateMessage)) + } + + select { + case <-ctx.Done(): + return fmt.Errorf("timed out after %s waiting for cluster %s to be running", ensureClusterTimeout, clusterID) + case <-time.After(min(time.Duration(attempt)*time.Second, 10*time.Second)): + } + } +} diff --git a/libs/sdkclients/current_workspace_id.go b/libs/sdkclients/current_workspace_id.go new file mode 100644 index 00000000000..4fad0b90226 --- /dev/null +++ b/libs/sdkclients/current_workspace_id.go @@ -0,0 +1,41 @@ +package sdkclients + +import ( + "context" + "io" + "net/http" + "strconv" + "strings" + + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/sdk-go/core/apierr" +) + +// CurrentWorkspaceID returns the ID of the workspace the clients talk to. The +// SCIM Me endpoint reports it in the X-Databricks-Org-Id response header. +func (c *Clients) CurrentWorkspaceID(ctx context.Context) (int64, error) { + url := strings.TrimSuffix(c.Config.CanonicalHostName(), "/") + "/api/2.0/preview/scim/v2/Me?excludedAttributes=entitlements" + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + if err != nil { + return 0, err + } + if id := c.Config.WorkspaceID; id != "" { + req.Header.Set("X-Databricks-Workspace-Id", id) + } + if err := c.Config.Authenticate(req); err != nil { + return 0, err + } + resp, err := apiclient.HTTPClient(c.Config).Do(req) + if err != nil { + return 0, err + } + defer resp.Body.Close() + body, err := io.ReadAll(resp.Body) + if err != nil { + return 0, err + } + if apiErr := apierr.FromHTTPError(resp.StatusCode, resp.Header, body); apiErr != nil { + return 0, apiErr + } + return strconv.ParseInt(resp.Header.Get("X-Databricks-Org-Id"), 10, 64) +} diff --git a/libs/sdkclients/services.go b/libs/sdkclients/services.go new file mode 100644 index 00000000000..6de8e2c03d9 --- /dev/null +++ b/libs/sdkclients/services.go @@ -0,0 +1,464 @@ +// One field per sdk-go API module; keep in sync with the sdk-go requirements in go.mod. + +package sdkclients + +import ( + "context" + + accessmanagement "github.com/databricks/sdk-go/accessmanagement/v1" + agentkit "github.com/databricks/sdk-go/agentkit/v1" + aifunctions "github.com/databricks/sdk-go/aifunctions/v1" + aigateway "github.com/databricks/sdk-go/aigateway/v1" + aisearch "github.com/databricks/sdk-go/aisearch/v1" + alertsv1 "github.com/databricks/sdk-go/alerts/v1" + alertsv2 "github.com/databricks/sdk-go/alerts/v2" + apps "github.com/databricks/sdk-go/apps/v1" + authentication "github.com/databricks/sdk-go/authentication/v1" + budgetpolicy "github.com/databricks/sdk-go/budgetpolicy/v1" + budgets "github.com/databricks/sdk-go/budgets/v1" + cleanrooms "github.com/databricks/sdk-go/cleanrooms/v1" + clusterlibraries "github.com/databricks/sdk-go/clusterlibraries/v2" + clusterpolicies "github.com/databricks/sdk-go/clusterpolicies/v2" + clusters "github.com/databricks/sdk-go/clusters/v2" + commandexecution "github.com/databricks/sdk-go/commandexecution/v2" + customllms "github.com/databricks/sdk-go/customllms/v1" + database "github.com/databricks/sdk-go/database/v1" + dataclassification "github.com/databricks/sdk-go/dataclassification/v1" + dataquality "github.com/databricks/sdk-go/dataquality/v1" + disasterrecovery "github.com/databricks/sdk-go/disasterrecovery/v1" + domains "github.com/databricks/sdk-go/domains/v1" + environments "github.com/databricks/sdk-go/environments/v1" + experiments "github.com/databricks/sdk-go/experiments/v1" + features "github.com/databricks/sdk-go/features/v1" + featurestore "github.com/databricks/sdk-go/featurestore/v1" + files "github.com/databricks/sdk-go/files/v2" + forecasting "github.com/databricks/sdk-go/forecasting/v1" + genie "github.com/databricks/sdk-go/genie/v1" + gitcredentials "github.com/databricks/sdk-go/gitcredentials/v1" + globalinitscripts "github.com/databricks/sdk-go/globalinitscripts/v2" + instancepools "github.com/databricks/sdk-go/instancepools/v2" + instanceprofiles "github.com/databricks/sdk-go/instanceprofiles/v2" + jobs "github.com/databricks/sdk-go/jobs/v2" + keyconfigurations "github.com/databricks/sdk-go/keyconfigurations/v1" + knowledgeassistants "github.com/databricks/sdk-go/knowledgeassistants/v1" + lakeview "github.com/databricks/sdk-go/lakeview/v1" + logdelivery "github.com/databricks/sdk-go/logdelivery/v1" + marketplaces "github.com/databricks/sdk-go/marketplaces/v1" + modelregistry "github.com/databricks/sdk-go/modelregistry/v1" + modelserving "github.com/databricks/sdk-go/modelserving/v1" + modelservingquery "github.com/databricks/sdk-go/modelservingquery/v1" + networking "github.com/databricks/sdk-go/networking/v1" + notificationdestinations "github.com/databricks/sdk-go/notificationdestinations/v1" + oauth "github.com/databricks/sdk-go/oauth/v1" + "github.com/databricks/sdk-go/options/client" + pipelines "github.com/databricks/sdk-go/pipelines/v2" + policyfamilies "github.com/databricks/sdk-go/policyfamilies/v2" + postgres "github.com/databricks/sdk-go/postgres/v1" + queries "github.com/databricks/sdk-go/queries/v1" + queryhistory "github.com/databricks/sdk-go/queryhistory/v1" + repos "github.com/databricks/sdk-go/repos/v1" + sandbox "github.com/databricks/sdk-go/sandbox/v1" + scim "github.com/databricks/sdk-go/scim/v1" + secrets "github.com/databricks/sdk-go/secrets/v1" + settings "github.com/databricks/sdk-go/settings/v2" + sharing "github.com/databricks/sdk-go/sharing/v1" + statementexecution "github.com/databricks/sdk-go/statementexecution/v1" + storageconfigurations "github.com/databricks/sdk-go/storageconfigurations/v1" + supervisoragents "github.com/databricks/sdk-go/supervisoragents/v1" + tagassignments "github.com/databricks/sdk-go/tagassignments/v1" + tagpolicies "github.com/databricks/sdk-go/tagpolicies/v1" + tokenmanagement "github.com/databricks/sdk-go/tokenmanagement/v1" + tokens "github.com/databricks/sdk-go/tokens/v1" + ucabacpolicies "github.com/databricks/sdk-go/uc/abacpolicies/v1" + ucartifactallowlists "github.com/databricks/sdk-go/uc/artifactallowlists/v1" + uccatalogs "github.com/databricks/sdk-go/uc/catalogs/v1" + ucconnections "github.com/databricks/sdk-go/uc/connections/v1" + uccredentials "github.com/databricks/sdk-go/uc/credentials/v1" + ucentitytagassignments "github.com/databricks/sdk-go/uc/entitytagassignments/v1" + ucexternallineage "github.com/databricks/sdk-go/uc/externallineage/v1" + ucexternallocations "github.com/databricks/sdk-go/uc/externallocations/v1" + ucexternalmetadata "github.com/databricks/sdk-go/uc/externalmetadata/v1" + ucfunctions "github.com/databricks/sdk-go/uc/functions/v1" + ucgrants "github.com/databricks/sdk-go/uc/grants/v1" + ucmetastores "github.com/databricks/sdk-go/uc/metastores/v1" + uconlinetables "github.com/databricks/sdk-go/uc/onlinetables/v1" + ucregisteredmodels "github.com/databricks/sdk-go/uc/registeredmodels/v1" + ucresourcequotas "github.com/databricks/sdk-go/uc/resourcequotas/v1" + ucrfa "github.com/databricks/sdk-go/uc/rfa/v1" + ucschemas "github.com/databricks/sdk-go/uc/schemas/v1" + ucsecrets "github.com/databricks/sdk-go/uc/secrets/v1" + ucsystemschemas "github.com/databricks/sdk-go/uc/systemschemas/v1" + uctables "github.com/databricks/sdk-go/uc/tables/v1" + ucvolumes "github.com/databricks/sdk-go/uc/volumes/v1" + ucworkspacebindings "github.com/databricks/sdk-go/uc/workspacebindings/v1" + usagedashboards "github.com/databricks/sdk-go/usagedashboards/v1" + vectorsearch "github.com/databricks/sdk-go/vectorsearch/v1" + warehouses "github.com/databricks/sdk-go/warehouses/v1" + workspaces "github.com/databricks/sdk-go/workspaces/v1" +) + +// services holds one sdk-go client per API module. +type services struct { + AccessManagement *accessmanagement.Client + AgentKit *agentkit.Client + AiFunctions *aifunctions.Client + AiGateway *aigateway.Client + AiSearch *aisearch.Client + AlertsV1 *alertsv1.Client + Alerts *alertsv2.Client + Apps *apps.Client + Authentication *authentication.Client + BudgetPolicy *budgetpolicy.Client + Budgets *budgets.Client + CleanRooms *cleanrooms.Client + Libraries *clusterlibraries.Client + ClusterPolicies *clusterpolicies.Client + Clusters *clusters.Client + CommandExecution *commandexecution.Client + CustomLlms *customllms.Client + Database *database.Client + DataClassification *dataclassification.Client + DataQuality *dataquality.Client + DisasterRecovery *disasterrecovery.Client + Domains *domains.Client + Environments *environments.Client + Experiments *experiments.Client + Features *features.Client + FeatureStore *featurestore.Client + Files *files.Client + Forecasting *forecasting.Client + Genie *genie.Client + GitCredentials *gitcredentials.Client + GlobalInitScripts *globalinitscripts.Client + InstancePools *instancepools.Client + InstanceProfiles *instanceprofiles.Client + Jobs *jobs.Client + KeyConfigurations *keyconfigurations.Client + KnowledgeAssistants *knowledgeassistants.Client + Lakeview *lakeview.Client + LogDelivery *logdelivery.Client + Marketplaces *marketplaces.Client + ModelRegistry *modelregistry.Client + ServingEndpoints *modelserving.Client + ServingQuery *modelservingquery.Client + Networking *networking.Client + NotificationDestinations *notificationdestinations.Client + OAuth *oauth.Client + Pipelines *pipelines.Client + PolicyFamilies *policyfamilies.Client + Postgres *postgres.Client + Queries *queries.Client + QueryHistory *queryhistory.Client + Repos *repos.Client + Sandbox *sandbox.Client + Scim *scim.Client + Secrets *secrets.Client + Settings *settings.Client + Sharing *sharing.Client + StatementExecution *statementexecution.Client + StorageConfigurations *storageconfigurations.Client + SupervisorAgents *supervisoragents.Client + TagAssignments *tagassignments.Client + TagPolicies *tagpolicies.Client + TokenManagement *tokenmanagement.Client + Tokens *tokens.Client + AbacPolicies *ucabacpolicies.Client + ArtifactAllowlists *ucartifactallowlists.Client + Catalogs *uccatalogs.Client + Connections *ucconnections.Client + Credentials *uccredentials.Client + EntityTagAssignments *ucentitytagassignments.Client + ExternalLineage *ucexternallineage.Client + ExternalLocations *ucexternallocations.Client + ExternalMetadata *ucexternalmetadata.Client + Functions *ucfunctions.Client + Grants *ucgrants.Client + Metastores *ucmetastores.Client + OnlineTables *uconlinetables.Client + RegisteredModels *ucregisteredmodels.Client + ResourceQuotas *ucresourcequotas.Client + Rfa *ucrfa.Client + Schemas *ucschemas.Client + SecretsUc *ucsecrets.Client + SystemSchemas *ucsystemschemas.Client + Tables *uctables.Client + Volumes *ucvolumes.Client + WorkspaceBindings *ucworkspacebindings.Client + UsageDashboards *usagedashboards.Client + VectorSearch *vectorsearch.Client + Warehouses *warehouses.Client + Workspaces *workspaces.Client +} + +func newServices(ctx context.Context, opts ...client.Option) (*services, error) { + c := &services{} + var err error + if c.AccessManagement, err = accessmanagement.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.AgentKit, err = agentkit.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.AiFunctions, err = aifunctions.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.AiGateway, err = aigateway.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.AiSearch, err = aisearch.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.AlertsV1, err = alertsv1.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Alerts, err = alertsv2.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Apps, err = apps.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Authentication, err = authentication.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.BudgetPolicy, err = budgetpolicy.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Budgets, err = budgets.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.CleanRooms, err = cleanrooms.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Libraries, err = clusterlibraries.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.ClusterPolicies, err = clusterpolicies.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Clusters, err = clusters.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.CommandExecution, err = commandexecution.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.CustomLlms, err = customllms.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Database, err = database.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.DataClassification, err = dataclassification.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.DataQuality, err = dataquality.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.DisasterRecovery, err = disasterrecovery.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Domains, err = domains.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Environments, err = environments.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Experiments, err = experiments.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Features, err = features.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.FeatureStore, err = featurestore.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Files, err = files.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Forecasting, err = forecasting.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Genie, err = genie.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.GitCredentials, err = gitcredentials.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.GlobalInitScripts, err = globalinitscripts.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.InstancePools, err = instancepools.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.InstanceProfiles, err = instanceprofiles.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Jobs, err = jobs.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.KeyConfigurations, err = keyconfigurations.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.KnowledgeAssistants, err = knowledgeassistants.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Lakeview, err = lakeview.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.LogDelivery, err = logdelivery.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Marketplaces, err = marketplaces.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.ModelRegistry, err = modelregistry.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.ServingEndpoints, err = modelserving.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.ServingQuery, err = modelservingquery.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Networking, err = networking.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.NotificationDestinations, err = notificationdestinations.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.OAuth, err = oauth.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Pipelines, err = pipelines.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.PolicyFamilies, err = policyfamilies.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Postgres, err = postgres.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Queries, err = queries.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.QueryHistory, err = queryhistory.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Repos, err = repos.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Sandbox, err = sandbox.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Scim, err = scim.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Secrets, err = secrets.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Settings, err = settings.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Sharing, err = sharing.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.StatementExecution, err = statementexecution.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.StorageConfigurations, err = storageconfigurations.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.SupervisorAgents, err = supervisoragents.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.TagAssignments, err = tagassignments.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.TagPolicies, err = tagpolicies.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.TokenManagement, err = tokenmanagement.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Tokens, err = tokens.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.AbacPolicies, err = ucabacpolicies.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.ArtifactAllowlists, err = ucartifactallowlists.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Catalogs, err = uccatalogs.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Connections, err = ucconnections.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Credentials, err = uccredentials.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.EntityTagAssignments, err = ucentitytagassignments.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.ExternalLineage, err = ucexternallineage.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.ExternalLocations, err = ucexternallocations.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.ExternalMetadata, err = ucexternalmetadata.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Functions, err = ucfunctions.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Grants, err = ucgrants.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Metastores, err = ucmetastores.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.OnlineTables, err = uconlinetables.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.RegisteredModels, err = ucregisteredmodels.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.ResourceQuotas, err = ucresourcequotas.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Rfa, err = ucrfa.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Schemas, err = ucschemas.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.SecretsUc, err = ucsecrets.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.SystemSchemas, err = ucsystemschemas.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Tables, err = uctables.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Volumes, err = ucvolumes.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.WorkspaceBindings, err = ucworkspacebindings.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.UsageDashboards, err = usagedashboards.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.VectorSearch, err = vectorsearch.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Warehouses, err = warehouses.NewClient(ctx, opts...); err != nil { + return nil, err + } + if c.Workspaces, err = workspaces.NewClient(ctx, opts...); err != nil { + return nil, err + } + return c, nil +} diff --git a/libs/sdktypes/accessmanagement/v1/types.generated.go b/libs/sdktypes/accessmanagement/v1/types.generated.go new file mode 100644 index 00000000000..c404a0b6481 --- /dev/null +++ b/libs/sdktypes/accessmanagement/v1/types.generated.go @@ -0,0 +1,1194 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/accessmanagement/v1. DO NOT EDIT. + +package accessmanagement + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/accessmanagement/v1" + + strings "strings" +) + +type ( + PermissionLevel = sdk.PermissionLevel + RequestAuthzIdentity = sdk.RequestAuthzIdentity + WorkspacePermission = sdk.WorkspacePermission +) + +const ( + PermissionLevel_Unspecified = sdk.PermissionLevel_Unspecified + PermissionLevel_CanRestart = sdk.PermissionLevel_CanRestart + PermissionLevel_CanAttachTo = sdk.PermissionLevel_CanAttachTo + PermissionLevel_IsOwner = sdk.PermissionLevel_IsOwner + PermissionLevel_CanManageRun = sdk.PermissionLevel_CanManageRun + PermissionLevel_CanView = sdk.PermissionLevel_CanView + PermissionLevel_CanRead = sdk.PermissionLevel_CanRead + PermissionLevel_CanRun = sdk.PermissionLevel_CanRun + PermissionLevel_CanEdit = sdk.PermissionLevel_CanEdit + PermissionLevel_CanUse = sdk.PermissionLevel_CanUse + PermissionLevel_CanManageStagingVersions = sdk.PermissionLevel_CanManageStagingVersions + PermissionLevel_CanManageProductionVersions = sdk.PermissionLevel_CanManageProductionVersions + PermissionLevel_CanEditMetadata = sdk.PermissionLevel_CanEditMetadata + PermissionLevel_CanViewMetadata = sdk.PermissionLevel_CanViewMetadata + PermissionLevel_CanBind = sdk.PermissionLevel_CanBind + PermissionLevel_CanQuery = sdk.PermissionLevel_CanQuery + PermissionLevel_CanMonitor = sdk.PermissionLevel_CanMonitor + PermissionLevel_CanCreate = sdk.PermissionLevel_CanCreate + PermissionLevel_CanMonitorOnly = sdk.PermissionLevel_CanMonitorOnly + PermissionLevel_CanCreateApp = sdk.PermissionLevel_CanCreateApp + RequestAuthzIdentity_Unspecified = sdk.RequestAuthzIdentity_Unspecified + RequestAuthzIdentity_RequestAuthzIdentityUserContext = sdk.RequestAuthzIdentity_RequestAuthzIdentityUserContext + RequestAuthzIdentity_RequestAuthzIdentityServiceIdentity = sdk.RequestAuthzIdentity_RequestAuthzIdentityServiceIdentity + WorkspacePermission_Unspecified = sdk.WorkspacePermission_Unspecified + WorkspacePermission_User = sdk.WorkspacePermission_User + WorkspacePermission_Admin = sdk.WorkspacePermission_Admin +) + +type AccessControlRequest struct { + GroupName *string `json:"group_name,omitempty"` + PermissionLevel PermissionLevel `json:"permission_level,omitempty"` + ServicePrincipalName *string `json:"service_principal_name,omitempty"` + UserName *string `json:"user_name,omitempty"` +} + +type AccessControlResponse struct { + // All permissions. + AllPermissions []Permission `json:"all_permissions,omitempty"` + // Display name of the user or service principal. + DisplayName *string `json:"display_name,omitempty"` + GroupName *string `json:"group_name,omitempty"` + ServicePrincipalName *string `json:"service_principal_name,omitempty"` + UserName *string `json:"user_name,omitempty"` +} + +// represents an identity trying to access a resource - user or a service +// principal group can be a principal of a permission set assignment but an +// actor is always a user or a service principal. +type Actor struct { + ActorId *int64 `json:"actor_id,omitempty"` +} + +type CheckPolicyRequest struct { + Actor *Actor `json:"actor,omitempty"` + AuthzIdentity RequestAuthzIdentity `json:"authz_identity,omitempty"` + ConsistencyToken *ConsistencyToken `json:"consistency_token,omitempty"` + Permission *string `json:"permission,omitempty"` + // Ex: (servicePrincipal/use, accounts//servicePrincipals/) + // Ex: (servicePrincipal.ruleSet/update, + // accounts//servicePrincipals//ruleSets/default) + Resource *string `json:"resource,omitempty"` + ResourceInfo *ResourceInfo `json:"resource_info,omitempty"` +} + +type CheckPolicyResponse struct { + ConsistencyToken *ConsistencyToken `json:"consistency_token,omitempty"` + IsPermitted *bool `json:"is_permitted,omitempty"` +} + +type ConsistencyToken struct { + Value *string `json:"value,omitempty"` +} + +type GetRuleSetRequest struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + // Etag used for versioning. The response is at least as fresh as the eTag + // provided. Etag is used for optimistic concurrency control as a way to help + // prevent simultaneous updates of a rule set from overwriting each other. It is + // strongly suggested that systems make use of the etag in the read -> modify -> + // write pattern to perform rule set updates in order to avoid race conditions + // that is get an etag from a GET rule set request, and pass it with the PUT + // update request to identify the rule set version you are updating. + // + // Examples | Summary :--- | :--- `etag=` | An empty etag can only be used in + // GET to indicate no freshness requirements. + // `etag=RENUAAABhSweA4NvVmmUYdiU717H3Tgy0UJdor3gE4a+mq/oj9NjAf8ZsQ==` | An etag + // encoded a specific version of the rule set to get or to be updated. + Etag *string `json:"etag,omitempty"` + // The ruleset name associated with the request. + // + // Examples | Summary :--- | :--- `name=accounts//ruleSets/default` + // | A name for a rule set on the account. + // `name=accounts//groups//ruleSets/default` | A name for + // a rule set on the group. + // `name=accounts//servicePrincipals//ruleSets/default` + // | A name for a rule set on the service principal. + // `name=accounts//tagPolicies//ruleSets/default` | A + // name for a rule set on the tag policy. + Name *string `json:"name,omitempty"` +} + +type GrantRule struct { + // Principals this grant rule applies to. A principal can be a user (for end + // users), a service principal (for applications and compute workloads), or an + // account group. Each principal has its own identifier format: * + // users/ * groups/ * + // servicePrincipals/ + Principals []string `json:"principals,omitempty"` + // Role that is assigned to the list of principals. + Role *string `json:"role,omitempty"` +} + +type ListAssignableRolesForResourceRequest struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + // The resource name for which assignable roles will be listed. + // + // Examples | Summary :--- | :--- `resource=accounts/` | A resource + // name for the account. `resource=accounts//groups/` | A + // resource name for the group. + // `resource=accounts//servicePrincipals/` | A resource name + // for the service principal. + // `resource=accounts//tagPolicies/` | A resource + // name for the tag policy. + Resource *string `json:"resource,omitempty"` +} + +type ListAssignableRolesForResourceResponse struct { + Roles []Role `json:"roles,omitempty"` +} + +type ListPermissionLevelsResponse struct { + // Specific permission levels + PermissionLevels []PermissionsDescription `json:"permission_levels,omitempty"` +} + +type ListWorkspacePermissionAssignmentsResponse struct { + // Array of permissions assignments defined for a workspace. + PermissionAssignments []WorkspacePermissionAssignmentOutput `json:"permission_assignments,omitempty"` +} + +type ListWorkspacePermissionsResponse struct { + // Array of permissions defined for a workspace. + Permissions []PermissionOutput `json:"permissions,omitempty"` +} + +type Permission struct { + Inherited *bool `json:"inherited,omitempty"` + InheritedFromObject []string `json:"inherited_from_object,omitempty"` + PermissionLevel PermissionLevel `json:"permission_level,omitempty"` +} + +type PermissionOutput struct { + // The results of a permissions query. + Description *string `json:"description,omitempty"` + PermissionLevel WorkspacePermission `json:"permission_level,omitempty"` +} + +type PermissionsDescription struct { + Description *string `json:"description,omitempty"` + PermissionLevel PermissionLevel `json:"permission_level,omitempty"` +} + +type PermissionsResponse struct { + AccessControlList []AccessControlResponse `json:"access_control_list,omitempty"` + ObjectId *string `json:"object_id,omitempty"` + ObjectType *string `json:"object_type,omitempty"` +} + +// Information about the principal assigned to the workspace.. +type PrincipalOutput struct { + // The display name of the principal. + DisplayName *string `json:"display_name,omitempty"` + GroupName *string `json:"group_name,omitempty"` + // The unique, opaque id of the principal. + PrincipalId *int64 `json:"principal_id,omitempty"` + ServicePrincipalName *string `json:"service_principal_name,omitempty"` + UserName *string `json:"user_name,omitempty"` +} + +type ResourceInfo struct { + // Id of the current resource. + Id *string `json:"id,omitempty"` + // The legacy acl path of the current resource. + LegacyAclPath *string `json:"legacy_acl_path,omitempty"` + // Parent resource info for the current resource. The parent may have another + // parent. + ParentResourceInfo *ResourceInfo `json:"parent_resource_info,omitempty"` +} + +type Role struct { + // Role to assign to a principal or a list of principals on a resource. + Name *string `json:"name,omitempty"` +} + +type RuleSet struct { + // Identifies the version of the rule set returned. Etag used for versioning. + // The response is at least as fresh as the eTag provided. Etag is used for + // optimistic concurrency control as a way to help prevent simultaneous updates + // of a rule set from overwriting each other. It is strongly suggested that + // systems make use of the etag in the read -> modify -> write pattern to + // perform rule set updates in order to avoid race conditions that is get an + // etag from a GET rule set request, and pass it with the PUT update request to + // identify the rule set version you are updating. + Etag *string `json:"etag,omitempty"` + GrantRules []GrantRule `json:"grant_rules,omitempty"` + // Name of the rule set. + Name *string `json:"name,omitempty"` +} + +type RuleSetUpdateRequest struct { + // Identifies the version of the rule set returned. Etag used for versioning. + // The response is at least as fresh as the eTag provided. Etag is used for + // optimistic concurrency control as a way to help prevent simultaneous updates + // of a rule set from overwriting each other. It is strongly suggested that + // systems make use of the etag in the read -> modify -> write pattern to + // perform rule set updates in order to avoid race conditions that is get an + // etag from a GET rule set request, and pass it with the PUT update request to + // identify the rule set version you are updating. + Etag *string `json:"etag,omitempty"` + GrantRules []GrantRule `json:"grant_rules,omitempty"` + // Name of the rule set. + Name *string `json:"name,omitempty"` +} + +type SetObjectPermissionsRequest struct { + AccessControlList []AccessControlRequest `json:"access_control_list,omitempty"` + // The id of the request object. + RequestObjectId *string `json:"request_object_id,omitempty"` + // The type of the request object. Can be one of the following: alerts, + // alertsv2, authorization, clusters, cluster-policies, dashboards, + // database-projects, dbsql-dashboards, directories, experiments, files, genie, + // instance-pools, jobs, knowledge-assistants, notebooks, pipelines, queries, + // registered-models, repos, serving-endpoints, supervisor-agents, + // vector-search-endpoints, or warehouses. + RequestObjectType *string `json:"request_object_type,omitempty"` +} + +type UpdateObjectPermissionsRequest struct { + AccessControlList []AccessControlRequest `json:"access_control_list,omitempty"` + // The id of the request object. + RequestObjectId *string `json:"request_object_id,omitempty"` + // The type of the request object. Can be one of the following: alerts, + // alertsv2, authorization, clusters, cluster-policies, dashboards, + // database-projects, dbsql-dashboards, directories, experiments, files, genie, + // instance-pools, jobs, knowledge-assistants, notebooks, pipelines, queries, + // registered-models, repos, serving-endpoints, supervisor-agents, + // vector-search-endpoints, or warehouses. + RequestObjectType *string `json:"request_object_type,omitempty"` +} + +type UpdateRuleSetRequest struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + // Name of the rule set. + Name *string `json:"name,omitempty"` + RuleSet *RuleSetUpdateRequest `json:"rule_set,omitempty"` +} + +type UpdateWorkspacePermissionAssignmentRequest struct { + // The account ID. + AccountId *string `json:"account_id,omitempty"` + // Array of permissions assignments to update on the workspace. Valid values are + // "USER" and "ADMIN" (case-sensitive). If both "USER" and "ADMIN" are provided, + // "ADMIN" takes precedence. Other values will be ignored. Note that excluding + // this field, or providing unsupported values, will have the same effect as + // providing an empty list, which will result in the deletion of all permissions + // for the principal. + Permissions []WorkspacePermission `json:"permissions,omitempty"` + // The ID of the user, service principal, or group. + PrincipalId *int64 `json:"principal_id,omitempty"` + // The workspace ID. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +// The output format for existing workspace PermissionAssignment records, which +// contains some info for user consumption.. +type WorkspacePermissionAssignmentOutput struct { + // Error response associated with a workspace permission assignment, if any. + Error *string `json:"error,omitempty"` + // The permissions level of the principal. + Permissions []WorkspacePermission `json:"permissions,omitempty"` + // Information about the principal assigned to the workspace. + Principal *PrincipalOutput `json:"principal,omitempty"` +} + +// AccessControlRequestToSDK converts the mirror to the sdk-go type. +func AccessControlRequestToSDK(w *AccessControlRequest) (*sdk.AccessControlRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccessControlRequest{} + { + var members []string + if w.UserName != nil { + members = append(members, "user_name") + } + if w.GroupName != nil { + members = append(members, "group_name") + } + if w.ServicePrincipalName != nil { + members = append(members, "service_principal_name") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UserName != nil: + out.PrincipalName = &sdk.AccessControlRequest_PrincipalName_UserName{UserName: *w.UserName} + case w.GroupName != nil: + out.PrincipalName = &sdk.AccessControlRequest_PrincipalName_GroupName{GroupName: *w.GroupName} + case w.ServicePrincipalName != nil: + out.PrincipalName = &sdk.AccessControlRequest_PrincipalName_ServicePrincipalName{ServicePrincipalName: *w.ServicePrincipalName} + } + out.PermissionLevel = w.PermissionLevel + return out, nil +} + +// AccessControlRequestFromSDK converts the sdk-go type to the mirror. +func AccessControlRequestFromSDK(v *sdk.AccessControlRequest) (*AccessControlRequest, error) { + if v == nil { + return nil, nil + } + out := &AccessControlRequest{} + switch value := v.PrincipalName.(type) { + case *sdk.AccessControlRequest_PrincipalName_UserName: + if value != nil { + out.UserName = new(value.UserName) + } + case *sdk.AccessControlRequest_PrincipalName_GroupName: + if value != nil { + out.GroupName = new(value.GroupName) + } + case *sdk.AccessControlRequest_PrincipalName_ServicePrincipalName: + if value != nil { + out.ServicePrincipalName = new(value.ServicePrincipalName) + } + } + out.PermissionLevel = v.PermissionLevel + return out, nil +} + +// AccessControlResponseToSDK converts the mirror to the sdk-go type. +func AccessControlResponseToSDK(w *AccessControlResponse) (*sdk.AccessControlResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccessControlResponse{} + { + var members []string + if w.UserName != nil { + members = append(members, "user_name") + } + if w.GroupName != nil { + members = append(members, "group_name") + } + if w.ServicePrincipalName != nil { + members = append(members, "service_principal_name") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UserName != nil: + out.PrincipalName = &sdk.AccessControlResponse_PrincipalName_UserName{UserName: *w.UserName} + case w.GroupName != nil: + out.PrincipalName = &sdk.AccessControlResponse_PrincipalName_GroupName{GroupName: *w.GroupName} + case w.ServicePrincipalName != nil: + out.PrincipalName = &sdk.AccessControlResponse_PrincipalName_ServicePrincipalName{ServicePrincipalName: *w.ServicePrincipalName} + } + out.DisplayName = w.DisplayName + conv1, err := convertSlice(w.AllPermissions, PermissionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccessControlResponse.AllPermissions", err) + } + out.AllPermissions = conv1 + return out, nil +} + +// AccessControlResponseFromSDK converts the sdk-go type to the mirror. +func AccessControlResponseFromSDK(v *sdk.AccessControlResponse) (*AccessControlResponse, error) { + if v == nil { + return nil, nil + } + out := &AccessControlResponse{} + switch value := v.PrincipalName.(type) { + case *sdk.AccessControlResponse_PrincipalName_UserName: + if value != nil { + out.UserName = new(value.UserName) + } + case *sdk.AccessControlResponse_PrincipalName_GroupName: + if value != nil { + out.GroupName = new(value.GroupName) + } + case *sdk.AccessControlResponse_PrincipalName_ServicePrincipalName: + if value != nil { + out.ServicePrincipalName = new(value.ServicePrincipalName) + } + } + out.DisplayName = v.DisplayName + conv2, err := convertSlice(v.AllPermissions, PermissionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccessControlResponse.AllPermissions", err) + } + out.AllPermissions = conv2 + return out, nil +} + +// ActorToSDK converts the mirror to the sdk-go type. +func ActorToSDK(w *Actor) (*sdk.Actor, error) { + if w == nil { + return nil, nil + } + out := &sdk.Actor{} + { + var members []string + if w.ActorId != nil { + members = append(members, "actor_id") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ActorId != nil: + out.Kind = &sdk.Actor_Kind_ActorId{ActorId: *w.ActorId} + } + return out, nil +} + +// ActorFromSDK converts the sdk-go type to the mirror. +func ActorFromSDK(v *sdk.Actor) (*Actor, error) { + if v == nil { + return nil, nil + } + out := &Actor{} + switch value := v.Kind.(type) { + case *sdk.Actor_Kind_ActorId: + if value != nil { + out.ActorId = new(value.ActorId) + } + } + return out, nil +} + +// CheckPolicyRequestToSDK converts the mirror to the sdk-go type. +func CheckPolicyRequestToSDK(w *CheckPolicyRequest) (*sdk.CheckPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CheckPolicyRequest{} + conv3, err := ActorToSDK(w.Actor) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CheckPolicyRequest.Actor", err) + } + out.Actor = conv3 + out.Permission = w.Permission + out.Resource = w.Resource + conv4, err := ConsistencyTokenToSDK(w.ConsistencyToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CheckPolicyRequest.ConsistencyToken", err) + } + out.ConsistencyToken = conv4 + out.AuthzIdentity = w.AuthzIdentity + conv5, err := ResourceInfoToSDK(w.ResourceInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CheckPolicyRequest.ResourceInfo", err) + } + out.ResourceInfo = conv5 + return out, nil +} + +// CheckPolicyRequestFromSDK converts the sdk-go type to the mirror. +func CheckPolicyRequestFromSDK(v *sdk.CheckPolicyRequest) (*CheckPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &CheckPolicyRequest{} + conv6, err := ActorFromSDK(v.Actor) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CheckPolicyRequest.Actor", err) + } + out.Actor = conv6 + out.Permission = v.Permission + out.Resource = v.Resource + conv7, err := ConsistencyTokenFromSDK(v.ConsistencyToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CheckPolicyRequest.ConsistencyToken", err) + } + out.ConsistencyToken = conv7 + out.AuthzIdentity = v.AuthzIdentity + conv8, err := ResourceInfoFromSDK(v.ResourceInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CheckPolicyRequest.ResourceInfo", err) + } + out.ResourceInfo = conv8 + return out, nil +} + +// CheckPolicyResponseToSDK converts the mirror to the sdk-go type. +func CheckPolicyResponseToSDK(w *CheckPolicyResponse) (*sdk.CheckPolicyResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CheckPolicyResponse{} + out.IsPermitted = w.IsPermitted + conv9, err := ConsistencyTokenToSDK(w.ConsistencyToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CheckPolicyResponse.ConsistencyToken", err) + } + out.ConsistencyToken = conv9 + return out, nil +} + +// CheckPolicyResponseFromSDK converts the sdk-go type to the mirror. +func CheckPolicyResponseFromSDK(v *sdk.CheckPolicyResponse) (*CheckPolicyResponse, error) { + if v == nil { + return nil, nil + } + out := &CheckPolicyResponse{} + out.IsPermitted = v.IsPermitted + conv10, err := ConsistencyTokenFromSDK(v.ConsistencyToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CheckPolicyResponse.ConsistencyToken", err) + } + out.ConsistencyToken = conv10 + return out, nil +} + +// ConsistencyTokenToSDK converts the mirror to the sdk-go type. +func ConsistencyTokenToSDK(w *ConsistencyToken) (*sdk.ConsistencyToken, error) { + if w == nil { + return nil, nil + } + out := &sdk.ConsistencyToken{} + out.Value = w.Value + return out, nil +} + +// ConsistencyTokenFromSDK converts the sdk-go type to the mirror. +func ConsistencyTokenFromSDK(v *sdk.ConsistencyToken) (*ConsistencyToken, error) { + if v == nil { + return nil, nil + } + out := &ConsistencyToken{} + out.Value = v.Value + return out, nil +} + +// GetRuleSetRequestToSDK converts the mirror to the sdk-go type. +func GetRuleSetRequestToSDK(w *GetRuleSetRequest) (*sdk.GetRuleSetRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetRuleSetRequest{} + out.AccountId = w.AccountId + out.Name = w.Name + out.Etag = w.Etag + return out, nil +} + +// GetRuleSetRequestFromSDK converts the sdk-go type to the mirror. +func GetRuleSetRequestFromSDK(v *sdk.GetRuleSetRequest) (*GetRuleSetRequest, error) { + if v == nil { + return nil, nil + } + out := &GetRuleSetRequest{} + out.AccountId = v.AccountId + out.Name = v.Name + out.Etag = v.Etag + return out, nil +} + +// GrantRuleToSDK converts the mirror to the sdk-go type. +func GrantRuleToSDK(w *GrantRule) (*sdk.GrantRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.GrantRule{} + out.Principals = w.Principals + out.Role = w.Role + return out, nil +} + +// GrantRuleFromSDK converts the sdk-go type to the mirror. +func GrantRuleFromSDK(v *sdk.GrantRule) (*GrantRule, error) { + if v == nil { + return nil, nil + } + out := &GrantRule{} + out.Principals = v.Principals + out.Role = v.Role + return out, nil +} + +// ListAssignableRolesForResourceRequestToSDK converts the mirror to the sdk-go type. +func ListAssignableRolesForResourceRequestToSDK(w *ListAssignableRolesForResourceRequest) (*sdk.ListAssignableRolesForResourceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAssignableRolesForResourceRequest{} + out.AccountId = w.AccountId + out.Resource = w.Resource + return out, nil +} + +// ListAssignableRolesForResourceRequestFromSDK converts the sdk-go type to the mirror. +func ListAssignableRolesForResourceRequestFromSDK(v *sdk.ListAssignableRolesForResourceRequest) (*ListAssignableRolesForResourceRequest, error) { + if v == nil { + return nil, nil + } + out := &ListAssignableRolesForResourceRequest{} + out.AccountId = v.AccountId + out.Resource = v.Resource + return out, nil +} + +// ListAssignableRolesForResourceResponseToSDK converts the mirror to the sdk-go type. +func ListAssignableRolesForResourceResponseToSDK(w *ListAssignableRolesForResourceResponse) (*sdk.ListAssignableRolesForResourceResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAssignableRolesForResourceResponse{} + conv11, err := convertSlice(w.Roles, RoleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAssignableRolesForResourceResponse.Roles", err) + } + out.Roles = conv11 + return out, nil +} + +// ListAssignableRolesForResourceResponseFromSDK converts the sdk-go type to the mirror. +func ListAssignableRolesForResourceResponseFromSDK(v *sdk.ListAssignableRolesForResourceResponse) (*ListAssignableRolesForResourceResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAssignableRolesForResourceResponse{} + conv12, err := convertSlice(v.Roles, RoleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAssignableRolesForResourceResponse.Roles", err) + } + out.Roles = conv12 + return out, nil +} + +// ListPermissionLevelsResponseToSDK converts the mirror to the sdk-go type. +func ListPermissionLevelsResponseToSDK(w *ListPermissionLevelsResponse) (*sdk.ListPermissionLevelsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPermissionLevelsResponse{} + conv13, err := convertSlice(w.PermissionLevels, PermissionsDescriptionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPermissionLevelsResponse.PermissionLevels", err) + } + out.PermissionLevels = conv13 + return out, nil +} + +// ListPermissionLevelsResponseFromSDK converts the sdk-go type to the mirror. +func ListPermissionLevelsResponseFromSDK(v *sdk.ListPermissionLevelsResponse) (*ListPermissionLevelsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListPermissionLevelsResponse{} + conv14, err := convertSlice(v.PermissionLevels, PermissionsDescriptionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPermissionLevelsResponse.PermissionLevels", err) + } + out.PermissionLevels = conv14 + return out, nil +} + +// ListWorkspacePermissionAssignmentsResponseToSDK converts the mirror to the sdk-go type. +func ListWorkspacePermissionAssignmentsResponseToSDK(w *ListWorkspacePermissionAssignmentsResponse) (*sdk.ListWorkspacePermissionAssignmentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListWorkspacePermissionAssignmentsResponse{} + conv15, err := convertSlice(w.PermissionAssignments, WorkspacePermissionAssignmentOutputToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListWorkspacePermissionAssignmentsResponse.PermissionAssignments", err) + } + out.PermissionAssignments = conv15 + return out, nil +} + +// ListWorkspacePermissionAssignmentsResponseFromSDK converts the sdk-go type to the mirror. +func ListWorkspacePermissionAssignmentsResponseFromSDK(v *sdk.ListWorkspacePermissionAssignmentsResponse) (*ListWorkspacePermissionAssignmentsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListWorkspacePermissionAssignmentsResponse{} + conv16, err := convertSlice(v.PermissionAssignments, WorkspacePermissionAssignmentOutputFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListWorkspacePermissionAssignmentsResponse.PermissionAssignments", err) + } + out.PermissionAssignments = conv16 + return out, nil +} + +// ListWorkspacePermissionsResponseToSDK converts the mirror to the sdk-go type. +func ListWorkspacePermissionsResponseToSDK(w *ListWorkspacePermissionsResponse) (*sdk.ListWorkspacePermissionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListWorkspacePermissionsResponse{} + conv17, err := convertSlice(w.Permissions, PermissionOutputToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListWorkspacePermissionsResponse.Permissions", err) + } + out.Permissions = conv17 + return out, nil +} + +// ListWorkspacePermissionsResponseFromSDK converts the sdk-go type to the mirror. +func ListWorkspacePermissionsResponseFromSDK(v *sdk.ListWorkspacePermissionsResponse) (*ListWorkspacePermissionsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListWorkspacePermissionsResponse{} + conv18, err := convertSlice(v.Permissions, PermissionOutputFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListWorkspacePermissionsResponse.Permissions", err) + } + out.Permissions = conv18 + return out, nil +} + +// PermissionToSDK converts the mirror to the sdk-go type. +func PermissionToSDK(w *Permission) (*sdk.Permission, error) { + if w == nil { + return nil, nil + } + out := &sdk.Permission{} + out.PermissionLevel = w.PermissionLevel + out.Inherited = w.Inherited + out.InheritedFromObject = w.InheritedFromObject + return out, nil +} + +// PermissionFromSDK converts the sdk-go type to the mirror. +func PermissionFromSDK(v *sdk.Permission) (*Permission, error) { + if v == nil { + return nil, nil + } + out := &Permission{} + out.PermissionLevel = v.PermissionLevel + out.Inherited = v.Inherited + out.InheritedFromObject = v.InheritedFromObject + return out, nil +} + +// PermissionOutputToSDK converts the mirror to the sdk-go type. +func PermissionOutputToSDK(w *PermissionOutput) (*sdk.PermissionOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.PermissionOutput{} + out.PermissionLevel = w.PermissionLevel + out.Description = w.Description + return out, nil +} + +// PermissionOutputFromSDK converts the sdk-go type to the mirror. +func PermissionOutputFromSDK(v *sdk.PermissionOutput) (*PermissionOutput, error) { + if v == nil { + return nil, nil + } + out := &PermissionOutput{} + out.PermissionLevel = v.PermissionLevel + out.Description = v.Description + return out, nil +} + +// PermissionsDescriptionToSDK converts the mirror to the sdk-go type. +func PermissionsDescriptionToSDK(w *PermissionsDescription) (*sdk.PermissionsDescription, error) { + if w == nil { + return nil, nil + } + out := &sdk.PermissionsDescription{} + out.PermissionLevel = w.PermissionLevel + out.Description = w.Description + return out, nil +} + +// PermissionsDescriptionFromSDK converts the sdk-go type to the mirror. +func PermissionsDescriptionFromSDK(v *sdk.PermissionsDescription) (*PermissionsDescription, error) { + if v == nil { + return nil, nil + } + out := &PermissionsDescription{} + out.PermissionLevel = v.PermissionLevel + out.Description = v.Description + return out, nil +} + +// PermissionsResponseToSDK converts the mirror to the sdk-go type. +func PermissionsResponseToSDK(w *PermissionsResponse) (*sdk.PermissionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.PermissionsResponse{} + out.ObjectId = w.ObjectId + out.ObjectType = w.ObjectType + conv19, err := convertSlice(w.AccessControlList, AccessControlResponseToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PermissionsResponse.AccessControlList", err) + } + out.AccessControlList = conv19 + return out, nil +} + +// PermissionsResponseFromSDK converts the sdk-go type to the mirror. +func PermissionsResponseFromSDK(v *sdk.PermissionsResponse) (*PermissionsResponse, error) { + if v == nil { + return nil, nil + } + out := &PermissionsResponse{} + out.ObjectId = v.ObjectId + out.ObjectType = v.ObjectType + conv20, err := convertSlice(v.AccessControlList, AccessControlResponseFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PermissionsResponse.AccessControlList", err) + } + out.AccessControlList = conv20 + return out, nil +} + +// PrincipalOutputToSDK converts the mirror to the sdk-go type. +func PrincipalOutputToSDK(w *PrincipalOutput) (*sdk.PrincipalOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.PrincipalOutput{} + { + var members []string + if w.UserName != nil { + members = append(members, "user_name") + } + if w.GroupName != nil { + members = append(members, "group_name") + } + if w.ServicePrincipalName != nil { + members = append(members, "service_principal_name") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UserName != nil: + out.PrincipalName = &sdk.PrincipalOutput_PrincipalName_UserName{UserName: *w.UserName} + case w.GroupName != nil: + out.PrincipalName = &sdk.PrincipalOutput_PrincipalName_GroupName{GroupName: *w.GroupName} + case w.ServicePrincipalName != nil: + out.PrincipalName = &sdk.PrincipalOutput_PrincipalName_ServicePrincipalName{ServicePrincipalName: *w.ServicePrincipalName} + } + out.PrincipalId = w.PrincipalId + out.DisplayName = w.DisplayName + return out, nil +} + +// PrincipalOutputFromSDK converts the sdk-go type to the mirror. +func PrincipalOutputFromSDK(v *sdk.PrincipalOutput) (*PrincipalOutput, error) { + if v == nil { + return nil, nil + } + out := &PrincipalOutput{} + switch value := v.PrincipalName.(type) { + case *sdk.PrincipalOutput_PrincipalName_UserName: + if value != nil { + out.UserName = new(value.UserName) + } + case *sdk.PrincipalOutput_PrincipalName_GroupName: + if value != nil { + out.GroupName = new(value.GroupName) + } + case *sdk.PrincipalOutput_PrincipalName_ServicePrincipalName: + if value != nil { + out.ServicePrincipalName = new(value.ServicePrincipalName) + } + } + out.PrincipalId = v.PrincipalId + out.DisplayName = v.DisplayName + return out, nil +} + +// ResourceInfoToSDK converts the mirror to the sdk-go type. +func ResourceInfoToSDK(w *ResourceInfo) (*sdk.ResourceInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResourceInfo{} + out.Id = w.Id + conv21, err := ResourceInfoToSDK(w.ParentResourceInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResourceInfo.ParentResourceInfo", err) + } + out.ParentResourceInfo = conv21 + out.LegacyAclPath = w.LegacyAclPath + return out, nil +} + +// ResourceInfoFromSDK converts the sdk-go type to the mirror. +func ResourceInfoFromSDK(v *sdk.ResourceInfo) (*ResourceInfo, error) { + if v == nil { + return nil, nil + } + out := &ResourceInfo{} + out.Id = v.Id + conv22, err := ResourceInfoFromSDK(v.ParentResourceInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResourceInfo.ParentResourceInfo", err) + } + out.ParentResourceInfo = conv22 + out.LegacyAclPath = v.LegacyAclPath + return out, nil +} + +// RoleToSDK converts the mirror to the sdk-go type. +func RoleToSDK(w *Role) (*sdk.Role, error) { + if w == nil { + return nil, nil + } + out := &sdk.Role{} + out.Name = w.Name + return out, nil +} + +// RoleFromSDK converts the sdk-go type to the mirror. +func RoleFromSDK(v *sdk.Role) (*Role, error) { + if v == nil { + return nil, nil + } + out := &Role{} + out.Name = v.Name + return out, nil +} + +// RuleSetToSDK converts the mirror to the sdk-go type. +func RuleSetToSDK(w *RuleSet) (*sdk.RuleSet, error) { + if w == nil { + return nil, nil + } + out := &sdk.RuleSet{} + out.Name = w.Name + out.Etag = w.Etag + conv23, err := convertSlice(w.GrantRules, GrantRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RuleSet.GrantRules", err) + } + out.GrantRules = conv23 + return out, nil +} + +// RuleSetFromSDK converts the sdk-go type to the mirror. +func RuleSetFromSDK(v *sdk.RuleSet) (*RuleSet, error) { + if v == nil { + return nil, nil + } + out := &RuleSet{} + out.Name = v.Name + out.Etag = v.Etag + conv24, err := convertSlice(v.GrantRules, GrantRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RuleSet.GrantRules", err) + } + out.GrantRules = conv24 + return out, nil +} + +// RuleSetUpdateRequestToSDK converts the mirror to the sdk-go type. +func RuleSetUpdateRequestToSDK(w *RuleSetUpdateRequest) (*sdk.RuleSetUpdateRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RuleSetUpdateRequest{} + out.Name = w.Name + out.Etag = w.Etag + conv25, err := convertSlice(w.GrantRules, GrantRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RuleSetUpdateRequest.GrantRules", err) + } + out.GrantRules = conv25 + return out, nil +} + +// RuleSetUpdateRequestFromSDK converts the sdk-go type to the mirror. +func RuleSetUpdateRequestFromSDK(v *sdk.RuleSetUpdateRequest) (*RuleSetUpdateRequest, error) { + if v == nil { + return nil, nil + } + out := &RuleSetUpdateRequest{} + out.Name = v.Name + out.Etag = v.Etag + conv26, err := convertSlice(v.GrantRules, GrantRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RuleSetUpdateRequest.GrantRules", err) + } + out.GrantRules = conv26 + return out, nil +} + +// SetObjectPermissionsRequestToSDK converts the mirror to the sdk-go type. +func SetObjectPermissionsRequestToSDK(w *SetObjectPermissionsRequest) (*sdk.SetObjectPermissionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SetObjectPermissionsRequest{} + out.RequestObjectType = w.RequestObjectType + out.RequestObjectId = w.RequestObjectId + conv27, err := convertSlice(w.AccessControlList, AccessControlRequestToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetObjectPermissionsRequest.AccessControlList", err) + } + out.AccessControlList = conv27 + return out, nil +} + +// SetObjectPermissionsRequestFromSDK converts the sdk-go type to the mirror. +func SetObjectPermissionsRequestFromSDK(v *sdk.SetObjectPermissionsRequest) (*SetObjectPermissionsRequest, error) { + if v == nil { + return nil, nil + } + out := &SetObjectPermissionsRequest{} + out.RequestObjectType = v.RequestObjectType + out.RequestObjectId = v.RequestObjectId + conv28, err := convertSlice(v.AccessControlList, AccessControlRequestFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetObjectPermissionsRequest.AccessControlList", err) + } + out.AccessControlList = conv28 + return out, nil +} + +// UpdateObjectPermissionsRequestToSDK converts the mirror to the sdk-go type. +func UpdateObjectPermissionsRequestToSDK(w *UpdateObjectPermissionsRequest) (*sdk.UpdateObjectPermissionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateObjectPermissionsRequest{} + out.RequestObjectType = w.RequestObjectType + out.RequestObjectId = w.RequestObjectId + conv29, err := convertSlice(w.AccessControlList, AccessControlRequestToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateObjectPermissionsRequest.AccessControlList", err) + } + out.AccessControlList = conv29 + return out, nil +} + +// UpdateObjectPermissionsRequestFromSDK converts the sdk-go type to the mirror. +func UpdateObjectPermissionsRequestFromSDK(v *sdk.UpdateObjectPermissionsRequest) (*UpdateObjectPermissionsRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateObjectPermissionsRequest{} + out.RequestObjectType = v.RequestObjectType + out.RequestObjectId = v.RequestObjectId + conv30, err := convertSlice(v.AccessControlList, AccessControlRequestFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateObjectPermissionsRequest.AccessControlList", err) + } + out.AccessControlList = conv30 + return out, nil +} + +// UpdateRuleSetRequestToSDK converts the mirror to the sdk-go type. +func UpdateRuleSetRequestToSDK(w *UpdateRuleSetRequest) (*sdk.UpdateRuleSetRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRuleSetRequest{} + out.AccountId = w.AccountId + out.Name = w.Name + conv31, err := RuleSetUpdateRequestToSDK(w.RuleSet) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRuleSetRequest.RuleSet", err) + } + out.RuleSet = conv31 + return out, nil +} + +// UpdateRuleSetRequestFromSDK converts the sdk-go type to the mirror. +func UpdateRuleSetRequestFromSDK(v *sdk.UpdateRuleSetRequest) (*UpdateRuleSetRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateRuleSetRequest{} + out.AccountId = v.AccountId + out.Name = v.Name + conv32, err := RuleSetUpdateRequestFromSDK(v.RuleSet) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRuleSetRequest.RuleSet", err) + } + out.RuleSet = conv32 + return out, nil +} + +// UpdateWorkspacePermissionAssignmentRequestToSDK converts the mirror to the sdk-go type. +func UpdateWorkspacePermissionAssignmentRequestToSDK(w *UpdateWorkspacePermissionAssignmentRequest) (*sdk.UpdateWorkspacePermissionAssignmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateWorkspacePermissionAssignmentRequest{} + out.AccountId = w.AccountId + out.WorkspaceId = w.WorkspaceId + out.PrincipalId = w.PrincipalId + out.Permissions = w.Permissions + return out, nil +} + +// UpdateWorkspacePermissionAssignmentRequestFromSDK converts the sdk-go type to the mirror. +func UpdateWorkspacePermissionAssignmentRequestFromSDK(v *sdk.UpdateWorkspacePermissionAssignmentRequest) (*UpdateWorkspacePermissionAssignmentRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateWorkspacePermissionAssignmentRequest{} + out.AccountId = v.AccountId + out.WorkspaceId = v.WorkspaceId + out.PrincipalId = v.PrincipalId + out.Permissions = v.Permissions + return out, nil +} + +// WorkspacePermissionAssignmentOutputToSDK converts the mirror to the sdk-go type. +func WorkspacePermissionAssignmentOutputToSDK(w *WorkspacePermissionAssignmentOutput) (*sdk.WorkspacePermissionAssignmentOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkspacePermissionAssignmentOutput{} + conv33, err := PrincipalOutputToSDK(w.Principal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WorkspacePermissionAssignmentOutput.Principal", err) + } + out.Principal = conv33 + out.Permissions = w.Permissions + out.Error = w.Error + return out, nil +} + +// WorkspacePermissionAssignmentOutputFromSDK converts the sdk-go type to the mirror. +func WorkspacePermissionAssignmentOutputFromSDK(v *sdk.WorkspacePermissionAssignmentOutput) (*WorkspacePermissionAssignmentOutput, error) { + if v == nil { + return nil, nil + } + out := &WorkspacePermissionAssignmentOutput{} + conv34, err := PrincipalOutputFromSDK(v.Principal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WorkspacePermissionAssignmentOutput.Principal", err) + } + out.Principal = conv34 + out.Permissions = v.Permissions + out.Error = v.Error + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/agentkit/v1/types.generated.go b/libs/sdktypes/agentkit/v1/types.generated.go new file mode 100644 index 00000000000..b4ba17d5b06 --- /dev/null +++ b/libs/sdktypes/agentkit/v1/types.generated.go @@ -0,0 +1,1648 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/agentkit/v1. DO NOT EDIT. + +package agentkit + +import ( + json "encoding/json" + fmt "fmt" + sdk "github.com/databricks/sdk-go/agentkit/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + ManagedMemoryEntrySourceType = sdk.ManagedMemoryEntrySourceType + ManagedMemoryEntryView = sdk.ManagedMemoryEntryView + StorageBackendType = sdk.StorageBackendType +) + +const ( + ManagedMemoryEntrySourceType_Unspecified = sdk.ManagedMemoryEntrySourceType_Unspecified + ManagedMemoryEntrySourceType_ManagedMemoryEntrySourceTypeAgent = sdk.ManagedMemoryEntrySourceType_ManagedMemoryEntrySourceTypeAgent + ManagedMemoryEntrySourceType_ManagedMemoryEntrySourceTypeDreamer = sdk.ManagedMemoryEntrySourceType_ManagedMemoryEntrySourceTypeDreamer + ManagedMemoryEntryView_Unspecified = sdk.ManagedMemoryEntryView_Unspecified + ManagedMemoryEntryView_ManagedMemoryEntryViewBasic = sdk.ManagedMemoryEntryView_ManagedMemoryEntryViewBasic + ManagedMemoryEntryView_ManagedMemoryEntryViewFull = sdk.ManagedMemoryEntryView_ManagedMemoryEntryViewFull + StorageBackendType_Unspecified = sdk.StorageBackendType_Unspecified + StorageBackendType_StorageBackendTypeLakebase = sdk.StorageBackendType_StorageBackendTypeLakebase +) + +// Request to append items to a session.. +type AppendSessionItemsRequest struct { + // Items to append atomically in request order. Concurrent append requests are + // serialized into one committed order without exposing a numeric sequence in + // the public contract. + Items []SessionItem `json:"items,omitempty"` + // Resource name of the containing session, in the form + // `session-stores/{session_store_id}/sessions/{session_id}`. + Parent *string `json:"parent,omitempty"` +} + +// Response containing appended items.. +type AppendSessionItemsResponse struct { + // Persisted session items with service-assigned fields. + SessionItems []SessionItem `json:"session_items,omitempty"` +} + +// Request to clear all items from a session.. +type ClearSessionItemsRequest struct { + // Resource name of the containing session, in the form + // `session-stores/{session_store_id}/sessions/{session_id}`. + Parent *string `json:"parent,omitempty"` +} + +// Request to create a managed memory entry.. +type CreateManagedMemoryEntryRequest struct { + // The managed memory entry to create. + ManagedMemoryEntry *ManagedMemoryEntry `json:"managed_memory_entry,omitempty"` + // Optional caller-selected managed memory entry ID. The service generates an ID + // when omitted. + ManagedMemoryEntryId *string `json:"managed_memory_entry_id,omitempty"` + // Managed memory store that will contain the entry, in the form + // `memory-stores/{managed_memory_store_id}`. + Parent *string `json:"parent,omitempty"` +} + +// Request to create a managed memory store.. +type CreateManagedMemoryStoreRequest struct { + // The managed memory store to create. + ManagedMemoryStore *ManagedMemoryStore `json:"managed_memory_store,omitempty"` + // Caller-provided, workspace-unique managed memory store ID. It must be 3-56 + // characters, begin with a lowercase letter, contain only lowercase letters, + // digits, and hyphens, and end with a letter or digit. + ManagedMemoryStoreId *string `json:"managed_memory_store_id,omitempty"` +} + +// Request to create a session.. +type CreateSessionRequest struct { + // Resource name of the containing session store, in the form + // `session-stores/{session_store_id}`. + Parent *string `json:"parent,omitempty"` + // The session to create. `actor_id` is required. A session with + // `parent_session_id` is a child and must use its parent's `actor_id`. + // Independent forks are created only through `ForkSession`. + Session *Session `json:"session,omitempty"` + // Optional caller-selected session ID. The service generates a UUID when this + // field is omitted. The ID must be unique; a collision returns + // `ALREADY_EXISTS`. + SessionId *string `json:"session_id,omitempty"` +} + +// Request to create a session store.. +type CreateSessionStoreRequest struct { + // The session store to create. + SessionStore *SessionStore `json:"session_store,omitempty"` + // Caller-provided, workspace-unique session store ID. It must be 3-55 + // characters, begin with a lowercase letter, and contain only lowercase + // letters, digits, and hyphens. + SessionStoreId *string `json:"session_store_id,omitempty"` +} + +// Request to synchronously extract memories from a single session.. +type ExtractMemoriesRequest struct { + // When true, extract and return the entries without writing them to the memory + // store. Defaults to false, which persists the extracted entries and returns + // them. + DryRun *bool `json:"dry_run,omitempty"` + // Instructions steering what is extracted from the session. + Instructions *string `json:"instructions,omitempty"` + // Managed memory store the extracted entries are written to, in the form + // `memory-stores/{managed_memory_store_id}`. + MemoryStore *string `json:"memory_store,omitempty"` + // Identifier of the session whose transcript is distilled into memories. + SessionId *string `json:"session_id,omitempty"` + // Session store containing the session, in the form + // `session-stores/{session_store_id}`. + SessionStore *string `json:"session_store,omitempty"` +} + +// Result of a single-session memory extraction.. +type ExtractMemoriesResponse struct { + // The memory entries written by this extraction. + Entries []ManagedMemoryEntry `json:"entries,omitempty"` + // Correlation identifier for this extraction, for logging and tracing. Not a + // fetchable resource. + Name *string `json:"name,omitempty"` +} + +// Request to fork a session.. +type ForkSessionRequest struct { + // Opaque caller-provided identifier for the application actor associated with + // the forked session. + ActorId *string `json:"actor_id,omitempty"` + // Optional metadata for the fork. + Metadata map[string]string `json:"metadata,omitempty"` + // Resource name of the containing session store, in the form + // `session-stores/{session_store_id}`. + Parent *string `json:"parent,omitempty"` + // Optional unique ID for the forked session. A collision returns + // `ALREADY_EXISTS`. + SessionId *string `json:"session_id,omitempty"` + // ID of the session to copy. + SourceSessionId *string `json:"source_session_id,omitempty"` + // Optional last item ID to copy through, inclusively. When omitted, the fork + // atomically copies all items committed before the fork operation begins. + UpToItemId *string `json:"up_to_item_id,omitempty"` +} + +// Response from forking a session.. +type ForkSessionResponse struct { + // The newly-created independent top-level session. + Session *Session `json:"session,omitempty"` +} + +// Request to retrieve a managed memory entry by resource name.. +type GetManagedMemoryEntryRequest struct { + // Resource name in the form + // `memory-stores/{managed_memory_store_id}/entries/{managed_memory_entry_id}`. + Name *string `json:"name,omitempty"` + // Controls whether the response includes memory content. Defaults to `FULL`. + View ManagedMemoryEntryView `json:"view,omitempty"` +} + +// Request to list managed memory entries for one actor, optionally restricted +// by session and path prefix, or matched by exact path regardless of session.. +type ListManagedMemoryEntriesRequest struct { + // Customer-provided identifier for the actor whose entries are listed. + ActorId *string `json:"actor_id,omitempty"` + // Maximum number of entries to return. The service may return fewer entries + // than requested. Defaults to 10; must be between 1 and 100. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token from a previous ListManagedMemoryEntries response. + PageToken *string `json:"page_token,omitempty"` + // Managed memory store whose entries are listed, in the form + // `memory-stores/{managed_memory_store_id}`. + Parent *string `json:"parent,omitempty"` + // Optional path prefix used to restrict entries within the actor partition. + PathPrefix *string `json:"path_prefix,omitempty"` + // Optional session identifier. When set, only entries with this exact + // `session_id` are returned. Omitted-session (cross-session) entries are not + // included. Ignored when path is set. + SessionId *string `json:"session_id,omitempty"` + // Controls whether each returned entry includes memory content. Defaults to + // `FULL`. + View ManagedMemoryEntryView `json:"view,omitempty"` +} + +// Response containing managed memory entries.. +type ListManagedMemoryEntriesResponse struct { + // Managed memory entries matching the request and selected response view. + ManagedMemoryEntries []ManagedMemoryEntry `json:"managed_memory_entries,omitempty"` + // Opaque pagination token. This field is omitted when there are no more + // results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to list managed memory stores in the caller's workspace.. +type ListManagedMemoryStoresRequest struct { + // Maximum number of stores to return. The service may return fewer stores than + // requested. Defaults to 10; must be between 1 and 100. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token from a previous ListManagedMemoryStores response. + PageToken *string `json:"page_token,omitempty"` +} + +// Response containing managed memory stores in the caller's workspace.. +type ListManagedMemoryStoresResponse struct { + // Managed memory stores in the caller's workspace. + ManagedMemoryStores []ManagedMemoryStore `json:"managed_memory_stores,omitempty"` + // Opaque pagination token. This field is omitted when there are no more + // results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to list items in a session.. +type ListSessionItemsRequest struct { + // Sort order. Supported values are `create_time asc` and `create_time desc`. + // The default is `create_time desc`, which returns the most recently appended + // items first. Equal timestamps are resolved by committed append order in the + // requested direction. + OrderBy *string `json:"order_by,omitempty"` + // Maximum number of items to return. Defaults to 10; must be between 1 and 100. + PageSize *int `json:"page_size,omitempty"` + // Token returned by a previous list request. + PageToken *string `json:"page_token,omitempty"` + // Resource name of the containing session, in the form + // `session-stores/{session_store_id}/sessions/{session_id}`. + Parent *string `json:"parent,omitempty"` +} + +// Response containing a page of session items.. +type ListSessionItemsResponse struct { + // Token to retrieve the next page. + NextPageToken *string `json:"next_page_token,omitempty"` + // Session items in the requested page. + SessionItems []SessionItem `json:"session_items,omitempty"` +} + +// Request to list session stores.. +type ListSessionStoresRequest struct { + // Maximum number of session stores to return. Defaults to 10; must be between 1 + // and 100. + PageSize *int `json:"page_size,omitempty"` + // Token returned by a previous list request. + PageToken *string `json:"page_token,omitempty"` +} + +// Response containing a page of session stores.. +type ListSessionStoresResponse struct { + // Token to retrieve the next page. + NextPageToken *string `json:"next_page_token,omitempty"` + // Session stores in the requested page. + SessionStores []SessionStore `json:"session_stores,omitempty"` +} + +// Request to list sessions.. +type ListSessionsRequest struct { + // Filter expression. Supported fields include `actor_id` and `metadata`; for + // example, `actor_id = "support-customer-123"`. + Filter *string `json:"filter,omitempty"` + // Sort order. Defaults to `last_activity_time desc`. Page-token continuation is + // exactly-once when ordering by `create_time` (immutable); ordering by + // `last_activity_time` is best-effort, because that value changes as a session + // gains activity, so a session updated between page requests may be repeated or + // skipped. To enumerate every session exactly once, order by `create_time`. + OrderBy *string `json:"order_by,omitempty"` + // Maximum number of sessions to return. Defaults to 10; must be between 1 and + // 100. + PageSize *int `json:"page_size,omitempty"` + // Token returned by a previous list request. + PageToken *string `json:"page_token,omitempty"` + // Resource name of the containing session store, in the form + // `session-stores/{session_store_id}`. + Parent *string `json:"parent,omitempty"` +} + +// Response containing a page of sessions.. +type ListSessionsResponse struct { + // Token to retrieve the next page. + NextPageToken *string `json:"next_page_token,omitempty"` + // Sessions in the requested page. + Sessions []Session `json:"sessions,omitempty"` +} + +// A workspace-scoped entry in a managed memory store.. +type ManagedMemoryEntry struct { + // Customer-provided identifier for the actor whose memory this entry + // represents. + ActorId *string `json:"actor_id,omitempty"` + // Optional free-form memory content. + Content *string `json:"content,omitempty"` + // Time when the entry was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Human-readable description of the memory entry. + Description *string `json:"description,omitempty"` + // Resource name in the form + // `memory-stores/{managed_memory_store_id}/entries/{managed_memory_entry_id}`. + Name *string `json:"name,omitempty"` + // Absolute, case-sensitive path identifying the entry within its actor and + // optional session. Paths must begin with `/` and must not contain empty, `.` + // or `..` segments. + Path *string `json:"path,omitempty"` + // Optional identifier for the session associated with this memory entry. When + // omitted, the entry applies across the actor's sessions. + SessionId *string `json:"session_id,omitempty"` + // Which writer created this entry. Caller sets this on Create; immutable after + // creation. + SourceType ManagedMemoryEntrySourceType `json:"source_type,omitempty"` + // Time when the entry was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +// One relevance-ranked managed memory search result.. +type ManagedMemoryEntrySearchResult struct { + // Managed memory entry matching the query. + ManagedMemoryEntry *ManagedMemoryEntry `json:"managed_memory_entry,omitempty"` + // Relevance score for the result. Higher scores are more relevant. + Score *float64 `json:"score,omitempty"` +} + +// A workspace-scoped managed memory store backed by service-managed storage.. +type ManagedMemoryStore struct { + // Time when the store was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Workspace-local user ID of the authenticated principal that created the + // store. This is immutable server-set attribution and does not grant access; + // authorization is evaluated from the authenticated request context. + CreatorUserId *string `json:"creator_user_id,omitempty"` + // Human-readable description of the memory store. + Description *string `json:"description,omitempty"` + // Deprecated compatibility alias for the caller-provided managed memory store + // ID. Canonical clients provide the ID through + // `CreateMemoryStoreRequest.managed_memory_store_id` and use `name` as the + // resource identifier. + DisplayName *string `json:"display_name,omitempty"` + // Resource name in the form `memory-stores/{managed_memory_store_id}`. + Name *string `json:"name,omitempty"` + // Deprecated alias for `creator_user_id`. This identifies the original creator, + // not a transferable owner. Use `creator_user_id` instead. + OwnerUserId *string `json:"owner_user_id,omitempty"` + // Service-managed storage backing this memory store. + StorageBackend *StorageBackend `json:"storage_backend,omitempty"` + // Time when the store was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` + // Workspace that owns the memory store. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +// Request to pop an item from a session.. +type PopSessionItemRequest struct { + // Resource name of the containing session, in the form + // `session-stores/{session_store_id}/sessions/{session_id}`. + Parent *string `json:"parent,omitempty"` +} + +// Response containing the popped item.. +type PopSessionItemResponse struct { + // Removed item, if any. + Item *SessionItem `json:"item,omitempty"` +} + +// Request to search managed memory entries by text query for one actor. Search +// returns a relevance-ranked top-N result set and does not currently paginate.. +type SearchManagedMemoryEntriesRequest struct { + // Customer-provided identifier for the actor whose entries are searched. + ActorId *string `json:"actor_id,omitempty"` + // Deprecated alias for `page_size`. When both fields are set, their values must + // match. + Limit *int `json:"limit,omitempty"` + // Maximum number of relevance-ranked entries to return. Defaults to 10 and must + // be between 1 and 100. + PageSize *int `json:"page_size,omitempty"` + // Reserved for pagination compatibility. The server currently ignores this + // field because Search returns a ranked top-N result set. + PageToken *string `json:"page_token,omitempty"` + // Managed memory store whose entries are searched, in the form + // `memory-stores/{managed_memory_store_id}`. + Parent *string `json:"parent,omitempty"` + // Optional absolute, case-sensitive path prefix used to restrict searched + // entries within the actor partition. The prefix must begin with `/` and must + // not contain empty, `.` or `..` segments. + PathPrefix *string `json:"path_prefix,omitempty"` + // Free-form search query. + Query *string `json:"query,omitempty"` + // Optional session identifier. When set, only entries with this exact + // `session_id` are searched. Omitted-session (cross-session) entries are not + // included. + SessionId *string `json:"session_id,omitempty"` + // Controls whether each returned entry includes memory content. Search scores + // are always returned. Defaults to `FULL`. + View ManagedMemoryEntryView `json:"view,omitempty"` +} + +// Response containing managed memory entries ranked by relevance.. +type SearchManagedMemoryEntriesResponse struct { + // Deprecated compatibility alias for clients migrating to `results`. This + // contains the same entries in the same order, but omits their relevance + // scores. + ManagedMemoryEntries []ManagedMemoryEntry `json:"managed_memory_entries,omitempty"` + // Opaque pagination token. Search currently returns an unpaginated ranked top-N + // result set, so the server does not populate this field. + NextPageToken *string `json:"next_page_token,omitempty"` + // Canonical matching entries and relevance scores, ordered most relevant first. + Results []ManagedMemoryEntrySearchResult `json:"results,omitempty"` +} + +// A durable logical interaction stored within a Session Store.. +type Session struct { + // Opaque caller-provided identifier for the application actor associated with + // the session. + // + // This is application data and has no authentication or + // authorization semantics. Use the same value as the Managed Memory Entry + // `actor_id` when storing memories associated with this actor. Every session + // must set it. A child session must use the same value as its parent. + ActorId *string `json:"actor_id,omitempty"` + // Time when the session was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Time when the session's item history was last mutated. + LastActivityTime *types.Time `json:"last_activity_time,omitempty"` + // Mutable caller-defined string labels. + Metadata map[string]string `json:"metadata,omitempty"` + // Resource name in the form + // `session-stores/{session_store_id}/sessions/{session_id}`. + Name *string `json:"name,omitempty"` + // Immediate parent session ID. Set only at creation for child sessions, + // immutable thereafter, and restricted to the same store. + ParentSessionId *string `json:"parent_session_id,omitempty"` + // Top-level session ID in the spawn tree. This equals `session_id` for a root + // or fork and is inherited transitively by child sessions. + RootSessionId *string `json:"root_session_id,omitempty"` + // Unique session ID. The service generates a UUID unless the caller supplies + // `CreateSessionRequest.session_id`. + SessionId *string `json:"session_id,omitempty"` + // Time when session resource fields last changed. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +// A transcript entry in a session's history.. +type SessionItem struct { + // Server-assigned time when the append commits. Values are nondecreasing within + // a session. Item listing orders by this timestamp; equal timestamps are + // resolved by committed append order. + CreateTime *types.Time `json:"create_time,omitempty"` + // Complete SDK-native, JSON-compatible item. The service stores and returns + // this value without interpreting provider-specific fields such as `type`, + // `role`, or `content`. + Data json.RawMessage `json:"data,omitempty"` + // Stable service-generated item ID. + ItemId *string `json:"item_id,omitempty"` +} + +// A workspace-scoped session store.. +type SessionStore struct { + // Time when the store was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Workspace-local user ID of the authenticated principal that created the + // store. This is immutable server-set attribution and does not grant access; + // authorization is evaluated from the authenticated request context. + CreatorUserId *string `json:"creator_user_id,omitempty"` + // Human-readable description of the session store. + Description *string `json:"description,omitempty"` + // Mutable caller-defined string labels. + Metadata map[string]string `json:"metadata,omitempty"` + // Resource name in the form `session-stores/{session_store_id}`. + Name *string `json:"name,omitempty"` + // Time when the store was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +// Service-managed storage backing a managed memory store.. +type StorageBackend struct { + // Backend-specific identifier. For Lakebase, this is the project ID. + BackendId *string `json:"backend_id,omitempty"` + // Type of the storage backend. + BackendType StorageBackendType `json:"backend_type,omitempty"` +} + +// Request to update a managed memory entry.. +type UpdateManagedMemoryEntryRequest struct { + // The managed memory entry to update. + ManagedMemoryEntry *ManagedMemoryEntry `json:"managed_memory_entry,omitempty"` + // Fields to update. Only `content` and `description` may be updated. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Request to update the description and metadata on a managed memory store.. +type UpdateManagedMemoryStoreRequest struct { + // The managed memory store to update. `name` is taken from the URL. + ManagedMemoryStore *ManagedMemoryStore `json:"managed_memory_store,omitempty"` + // Only `description` and `metadata` may be updated. Selecting `metadata` + // replaces the entire map. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Request to update a session.. +type UpdateSessionRequest struct { + // Session to update. + Session *Session `json:"session,omitempty"` + // Fields to update. Only `metadata` is mutable; any other path returns + // `INVALID_PARAMETER_VALUE`. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Request to update a session store.. +type UpdateSessionStoreRequest struct { + // Session store to update. + SessionStore *SessionStore `json:"session_store,omitempty"` + // Fields to update. Only `description` and `metadata` are mutable; any other + // path returns `INVALID_PARAMETER_VALUE`. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// AppendSessionItemsRequestToSDK converts the mirror to the sdk-go type. +func AppendSessionItemsRequestToSDK(w *AppendSessionItemsRequest) (*sdk.AppendSessionItemsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppendSessionItemsRequest{} + conv1, err := convertSlice(w.Items, SessionItemToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppendSessionItemsRequest.Items", err) + } + out.Items = conv1 + out.Parent = w.Parent + return out, nil +} + +// AppendSessionItemsRequestFromSDK converts the sdk-go type to the mirror. +func AppendSessionItemsRequestFromSDK(v *sdk.AppendSessionItemsRequest) (*AppendSessionItemsRequest, error) { + if v == nil { + return nil, nil + } + out := &AppendSessionItemsRequest{} + conv2, err := convertSlice(v.Items, SessionItemFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppendSessionItemsRequest.Items", err) + } + out.Items = conv2 + out.Parent = v.Parent + return out, nil +} + +// AppendSessionItemsResponseToSDK converts the mirror to the sdk-go type. +func AppendSessionItemsResponseToSDK(w *AppendSessionItemsResponse) (*sdk.AppendSessionItemsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppendSessionItemsResponse{} + conv3, err := convertSlice(w.SessionItems, SessionItemToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppendSessionItemsResponse.SessionItems", err) + } + out.SessionItems = conv3 + return out, nil +} + +// AppendSessionItemsResponseFromSDK converts the sdk-go type to the mirror. +func AppendSessionItemsResponseFromSDK(v *sdk.AppendSessionItemsResponse) (*AppendSessionItemsResponse, error) { + if v == nil { + return nil, nil + } + out := &AppendSessionItemsResponse{} + conv4, err := convertSlice(v.SessionItems, SessionItemFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppendSessionItemsResponse.SessionItems", err) + } + out.SessionItems = conv4 + return out, nil +} + +// ClearSessionItemsRequestToSDK converts the mirror to the sdk-go type. +func ClearSessionItemsRequestToSDK(w *ClearSessionItemsRequest) (*sdk.ClearSessionItemsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClearSessionItemsRequest{} + out.Parent = w.Parent + return out, nil +} + +// ClearSessionItemsRequestFromSDK converts the sdk-go type to the mirror. +func ClearSessionItemsRequestFromSDK(v *sdk.ClearSessionItemsRequest) (*ClearSessionItemsRequest, error) { + if v == nil { + return nil, nil + } + out := &ClearSessionItemsRequest{} + out.Parent = v.Parent + return out, nil +} + +// CreateManagedMemoryEntryRequestToSDK converts the mirror to the sdk-go type. +func CreateManagedMemoryEntryRequestToSDK(w *CreateManagedMemoryEntryRequest) (*sdk.CreateManagedMemoryEntryRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateManagedMemoryEntryRequest{} + out.Parent = w.Parent + conv5, err := ManagedMemoryEntryToSDK(w.ManagedMemoryEntry) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateManagedMemoryEntryRequest.ManagedMemoryEntry", err) + } + out.ManagedMemoryEntry = conv5 + out.ManagedMemoryEntryId = w.ManagedMemoryEntryId + return out, nil +} + +// CreateManagedMemoryEntryRequestFromSDK converts the sdk-go type to the mirror. +func CreateManagedMemoryEntryRequestFromSDK(v *sdk.CreateManagedMemoryEntryRequest) (*CreateManagedMemoryEntryRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateManagedMemoryEntryRequest{} + out.Parent = v.Parent + conv6, err := ManagedMemoryEntryFromSDK(v.ManagedMemoryEntry) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateManagedMemoryEntryRequest.ManagedMemoryEntry", err) + } + out.ManagedMemoryEntry = conv6 + out.ManagedMemoryEntryId = v.ManagedMemoryEntryId + return out, nil +} + +// CreateManagedMemoryStoreRequestToSDK converts the mirror to the sdk-go type. +func CreateManagedMemoryStoreRequestToSDK(w *CreateManagedMemoryStoreRequest) (*sdk.CreateManagedMemoryStoreRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateManagedMemoryStoreRequest{} + conv7, err := ManagedMemoryStoreToSDK(w.ManagedMemoryStore) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateManagedMemoryStoreRequest.ManagedMemoryStore", err) + } + out.ManagedMemoryStore = conv7 + out.ManagedMemoryStoreId = w.ManagedMemoryStoreId + return out, nil +} + +// CreateManagedMemoryStoreRequestFromSDK converts the sdk-go type to the mirror. +func CreateManagedMemoryStoreRequestFromSDK(v *sdk.CreateManagedMemoryStoreRequest) (*CreateManagedMemoryStoreRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateManagedMemoryStoreRequest{} + conv8, err := ManagedMemoryStoreFromSDK(v.ManagedMemoryStore) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateManagedMemoryStoreRequest.ManagedMemoryStore", err) + } + out.ManagedMemoryStore = conv8 + out.ManagedMemoryStoreId = v.ManagedMemoryStoreId + return out, nil +} + +// CreateSessionRequestToSDK converts the mirror to the sdk-go type. +func CreateSessionRequestToSDK(w *CreateSessionRequest) (*sdk.CreateSessionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateSessionRequest{} + conv9, err := SessionToSDK(w.Session) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSessionRequest.Session", err) + } + out.Session = conv9 + out.SessionId = w.SessionId + out.Parent = w.Parent + return out, nil +} + +// CreateSessionRequestFromSDK converts the sdk-go type to the mirror. +func CreateSessionRequestFromSDK(v *sdk.CreateSessionRequest) (*CreateSessionRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateSessionRequest{} + conv10, err := SessionFromSDK(v.Session) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSessionRequest.Session", err) + } + out.Session = conv10 + out.SessionId = v.SessionId + out.Parent = v.Parent + return out, nil +} + +// CreateSessionStoreRequestToSDK converts the mirror to the sdk-go type. +func CreateSessionStoreRequestToSDK(w *CreateSessionStoreRequest) (*sdk.CreateSessionStoreRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateSessionStoreRequest{} + conv11, err := SessionStoreToSDK(w.SessionStore) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSessionStoreRequest.SessionStore", err) + } + out.SessionStore = conv11 + out.SessionStoreId = w.SessionStoreId + return out, nil +} + +// CreateSessionStoreRequestFromSDK converts the sdk-go type to the mirror. +func CreateSessionStoreRequestFromSDK(v *sdk.CreateSessionStoreRequest) (*CreateSessionStoreRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateSessionStoreRequest{} + conv12, err := SessionStoreFromSDK(v.SessionStore) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSessionStoreRequest.SessionStore", err) + } + out.SessionStore = conv12 + out.SessionStoreId = v.SessionStoreId + return out, nil +} + +// ExtractMemoriesRequestToSDK converts the mirror to the sdk-go type. +func ExtractMemoriesRequestToSDK(w *ExtractMemoriesRequest) (*sdk.ExtractMemoriesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExtractMemoriesRequest{} + out.MemoryStore = w.MemoryStore + out.SessionStore = w.SessionStore + out.SessionId = w.SessionId + out.Instructions = w.Instructions + out.DryRun = w.DryRun + return out, nil +} + +// ExtractMemoriesRequestFromSDK converts the sdk-go type to the mirror. +func ExtractMemoriesRequestFromSDK(v *sdk.ExtractMemoriesRequest) (*ExtractMemoriesRequest, error) { + if v == nil { + return nil, nil + } + out := &ExtractMemoriesRequest{} + out.MemoryStore = v.MemoryStore + out.SessionStore = v.SessionStore + out.SessionId = v.SessionId + out.Instructions = v.Instructions + out.DryRun = v.DryRun + return out, nil +} + +// ExtractMemoriesResponseToSDK converts the mirror to the sdk-go type. +func ExtractMemoriesResponseToSDK(w *ExtractMemoriesResponse) (*sdk.ExtractMemoriesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExtractMemoriesResponse{} + out.Name = w.Name + conv13, err := convertSlice(w.Entries, ManagedMemoryEntryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExtractMemoriesResponse.Entries", err) + } + out.Entries = conv13 + return out, nil +} + +// ExtractMemoriesResponseFromSDK converts the sdk-go type to the mirror. +func ExtractMemoriesResponseFromSDK(v *sdk.ExtractMemoriesResponse) (*ExtractMemoriesResponse, error) { + if v == nil { + return nil, nil + } + out := &ExtractMemoriesResponse{} + out.Name = v.Name + conv14, err := convertSlice(v.Entries, ManagedMemoryEntryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExtractMemoriesResponse.Entries", err) + } + out.Entries = conv14 + return out, nil +} + +// ForkSessionRequestToSDK converts the mirror to the sdk-go type. +func ForkSessionRequestToSDK(w *ForkSessionRequest) (*sdk.ForkSessionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ForkSessionRequest{} + out.SourceSessionId = w.SourceSessionId + out.UpToItemId = w.UpToItemId + out.SessionId = w.SessionId + out.ActorId = w.ActorId + out.Metadata = w.Metadata + out.Parent = w.Parent + return out, nil +} + +// ForkSessionRequestFromSDK converts the sdk-go type to the mirror. +func ForkSessionRequestFromSDK(v *sdk.ForkSessionRequest) (*ForkSessionRequest, error) { + if v == nil { + return nil, nil + } + out := &ForkSessionRequest{} + out.SourceSessionId = v.SourceSessionId + out.UpToItemId = v.UpToItemId + out.SessionId = v.SessionId + out.ActorId = v.ActorId + out.Metadata = v.Metadata + out.Parent = v.Parent + return out, nil +} + +// ForkSessionResponseToSDK converts the mirror to the sdk-go type. +func ForkSessionResponseToSDK(w *ForkSessionResponse) (*sdk.ForkSessionResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ForkSessionResponse{} + conv15, err := SessionToSDK(w.Session) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ForkSessionResponse.Session", err) + } + out.Session = conv15 + return out, nil +} + +// ForkSessionResponseFromSDK converts the sdk-go type to the mirror. +func ForkSessionResponseFromSDK(v *sdk.ForkSessionResponse) (*ForkSessionResponse, error) { + if v == nil { + return nil, nil + } + out := &ForkSessionResponse{} + conv16, err := SessionFromSDK(v.Session) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ForkSessionResponse.Session", err) + } + out.Session = conv16 + return out, nil +} + +// GetManagedMemoryEntryRequestToSDK converts the mirror to the sdk-go type. +func GetManagedMemoryEntryRequestToSDK(w *GetManagedMemoryEntryRequest) (*sdk.GetManagedMemoryEntryRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetManagedMemoryEntryRequest{} + out.Name = w.Name + out.View = w.View + return out, nil +} + +// GetManagedMemoryEntryRequestFromSDK converts the sdk-go type to the mirror. +func GetManagedMemoryEntryRequestFromSDK(v *sdk.GetManagedMemoryEntryRequest) (*GetManagedMemoryEntryRequest, error) { + if v == nil { + return nil, nil + } + out := &GetManagedMemoryEntryRequest{} + out.Name = v.Name + out.View = v.View + return out, nil +} + +// ListManagedMemoryEntriesRequestToSDK converts the mirror to the sdk-go type. +func ListManagedMemoryEntriesRequestToSDK(w *ListManagedMemoryEntriesRequest) (*sdk.ListManagedMemoryEntriesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListManagedMemoryEntriesRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + out.ActorId = w.ActorId + out.PathPrefix = w.PathPrefix + out.SessionId = w.SessionId + out.View = w.View + return out, nil +} + +// ListManagedMemoryEntriesRequestFromSDK converts the sdk-go type to the mirror. +func ListManagedMemoryEntriesRequestFromSDK(v *sdk.ListManagedMemoryEntriesRequest) (*ListManagedMemoryEntriesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListManagedMemoryEntriesRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + out.ActorId = v.ActorId + out.PathPrefix = v.PathPrefix + out.SessionId = v.SessionId + out.View = v.View + return out, nil +} + +// ListManagedMemoryEntriesResponseToSDK converts the mirror to the sdk-go type. +func ListManagedMemoryEntriesResponseToSDK(w *ListManagedMemoryEntriesResponse) (*sdk.ListManagedMemoryEntriesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListManagedMemoryEntriesResponse{} + conv17, err := convertSlice(w.ManagedMemoryEntries, ManagedMemoryEntryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListManagedMemoryEntriesResponse.ManagedMemoryEntries", err) + } + out.ManagedMemoryEntries = conv17 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListManagedMemoryEntriesResponseFromSDK converts the sdk-go type to the mirror. +func ListManagedMemoryEntriesResponseFromSDK(v *sdk.ListManagedMemoryEntriesResponse) (*ListManagedMemoryEntriesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListManagedMemoryEntriesResponse{} + conv18, err := convertSlice(v.ManagedMemoryEntries, ManagedMemoryEntryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListManagedMemoryEntriesResponse.ManagedMemoryEntries", err) + } + out.ManagedMemoryEntries = conv18 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListManagedMemoryStoresRequestToSDK converts the mirror to the sdk-go type. +func ListManagedMemoryStoresRequestToSDK(w *ListManagedMemoryStoresRequest) (*sdk.ListManagedMemoryStoresRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListManagedMemoryStoresRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListManagedMemoryStoresRequestFromSDK converts the sdk-go type to the mirror. +func ListManagedMemoryStoresRequestFromSDK(v *sdk.ListManagedMemoryStoresRequest) (*ListManagedMemoryStoresRequest, error) { + if v == nil { + return nil, nil + } + out := &ListManagedMemoryStoresRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListManagedMemoryStoresResponseToSDK converts the mirror to the sdk-go type. +func ListManagedMemoryStoresResponseToSDK(w *ListManagedMemoryStoresResponse) (*sdk.ListManagedMemoryStoresResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListManagedMemoryStoresResponse{} + conv19, err := convertSlice(w.ManagedMemoryStores, ManagedMemoryStoreToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListManagedMemoryStoresResponse.ManagedMemoryStores", err) + } + out.ManagedMemoryStores = conv19 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListManagedMemoryStoresResponseFromSDK converts the sdk-go type to the mirror. +func ListManagedMemoryStoresResponseFromSDK(v *sdk.ListManagedMemoryStoresResponse) (*ListManagedMemoryStoresResponse, error) { + if v == nil { + return nil, nil + } + out := &ListManagedMemoryStoresResponse{} + conv20, err := convertSlice(v.ManagedMemoryStores, ManagedMemoryStoreFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListManagedMemoryStoresResponse.ManagedMemoryStores", err) + } + out.ManagedMemoryStores = conv20 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListSessionItemsRequestToSDK converts the mirror to the sdk-go type. +func ListSessionItemsRequestToSDK(w *ListSessionItemsRequest) (*sdk.ListSessionItemsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSessionItemsRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + out.OrderBy = w.OrderBy + out.Parent = w.Parent + return out, nil +} + +// ListSessionItemsRequestFromSDK converts the sdk-go type to the mirror. +func ListSessionItemsRequestFromSDK(v *sdk.ListSessionItemsRequest) (*ListSessionItemsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSessionItemsRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + out.OrderBy = v.OrderBy + out.Parent = v.Parent + return out, nil +} + +// ListSessionItemsResponseToSDK converts the mirror to the sdk-go type. +func ListSessionItemsResponseToSDK(w *ListSessionItemsResponse) (*sdk.ListSessionItemsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSessionItemsResponse{} + conv21, err := convertSlice(w.SessionItems, SessionItemToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSessionItemsResponse.SessionItems", err) + } + out.SessionItems = conv21 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSessionItemsResponseFromSDK converts the sdk-go type to the mirror. +func ListSessionItemsResponseFromSDK(v *sdk.ListSessionItemsResponse) (*ListSessionItemsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSessionItemsResponse{} + conv22, err := convertSlice(v.SessionItems, SessionItemFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSessionItemsResponse.SessionItems", err) + } + out.SessionItems = conv22 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListSessionStoresRequestToSDK converts the mirror to the sdk-go type. +func ListSessionStoresRequestToSDK(w *ListSessionStoresRequest) (*sdk.ListSessionStoresRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSessionStoresRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListSessionStoresRequestFromSDK converts the sdk-go type to the mirror. +func ListSessionStoresRequestFromSDK(v *sdk.ListSessionStoresRequest) (*ListSessionStoresRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSessionStoresRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListSessionStoresResponseToSDK converts the mirror to the sdk-go type. +func ListSessionStoresResponseToSDK(w *ListSessionStoresResponse) (*sdk.ListSessionStoresResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSessionStoresResponse{} + conv23, err := convertSlice(w.SessionStores, SessionStoreToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSessionStoresResponse.SessionStores", err) + } + out.SessionStores = conv23 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSessionStoresResponseFromSDK converts the sdk-go type to the mirror. +func ListSessionStoresResponseFromSDK(v *sdk.ListSessionStoresResponse) (*ListSessionStoresResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSessionStoresResponse{} + conv24, err := convertSlice(v.SessionStores, SessionStoreFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSessionStoresResponse.SessionStores", err) + } + out.SessionStores = conv24 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListSessionsRequestToSDK converts the mirror to the sdk-go type. +func ListSessionsRequestToSDK(w *ListSessionsRequest) (*sdk.ListSessionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSessionsRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + out.Filter = w.Filter + out.OrderBy = w.OrderBy + out.Parent = w.Parent + return out, nil +} + +// ListSessionsRequestFromSDK converts the sdk-go type to the mirror. +func ListSessionsRequestFromSDK(v *sdk.ListSessionsRequest) (*ListSessionsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSessionsRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + out.Filter = v.Filter + out.OrderBy = v.OrderBy + out.Parent = v.Parent + return out, nil +} + +// ListSessionsResponseToSDK converts the mirror to the sdk-go type. +func ListSessionsResponseToSDK(w *ListSessionsResponse) (*sdk.ListSessionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSessionsResponse{} + conv25, err := convertSlice(w.Sessions, SessionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSessionsResponse.Sessions", err) + } + out.Sessions = conv25 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSessionsResponseFromSDK converts the sdk-go type to the mirror. +func ListSessionsResponseFromSDK(v *sdk.ListSessionsResponse) (*ListSessionsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSessionsResponse{} + conv26, err := convertSlice(v.Sessions, SessionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSessionsResponse.Sessions", err) + } + out.Sessions = conv26 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ManagedMemoryEntryToSDK converts the mirror to the sdk-go type. +func ManagedMemoryEntryToSDK(w *ManagedMemoryEntry) (*sdk.ManagedMemoryEntry, error) { + if w == nil { + return nil, nil + } + out := &sdk.ManagedMemoryEntry{} + out.Name = w.Name + out.ActorId = w.ActorId + out.SessionId = w.SessionId + out.Path = w.Path + out.Content = w.Content + out.Description = w.Description + out.SourceType = w.SourceType + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + return out, nil +} + +// ManagedMemoryEntryFromSDK converts the sdk-go type to the mirror. +func ManagedMemoryEntryFromSDK(v *sdk.ManagedMemoryEntry) (*ManagedMemoryEntry, error) { + if v == nil { + return nil, nil + } + out := &ManagedMemoryEntry{} + out.Name = v.Name + out.ActorId = v.ActorId + out.SessionId = v.SessionId + out.Path = v.Path + out.Content = v.Content + out.Description = v.Description + out.SourceType = v.SourceType + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + return out, nil +} + +// ManagedMemoryEntrySearchResultToSDK converts the mirror to the sdk-go type. +func ManagedMemoryEntrySearchResultToSDK(w *ManagedMemoryEntrySearchResult) (*sdk.ManagedMemoryEntrySearchResult, error) { + if w == nil { + return nil, nil + } + out := &sdk.ManagedMemoryEntrySearchResult{} + conv27, err := ManagedMemoryEntryToSDK(w.ManagedMemoryEntry) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ManagedMemoryEntrySearchResult.ManagedMemoryEntry", err) + } + out.ManagedMemoryEntry = conv27 + out.Score = w.Score + return out, nil +} + +// ManagedMemoryEntrySearchResultFromSDK converts the sdk-go type to the mirror. +func ManagedMemoryEntrySearchResultFromSDK(v *sdk.ManagedMemoryEntrySearchResult) (*ManagedMemoryEntrySearchResult, error) { + if v == nil { + return nil, nil + } + out := &ManagedMemoryEntrySearchResult{} + conv28, err := ManagedMemoryEntryFromSDK(v.ManagedMemoryEntry) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ManagedMemoryEntrySearchResult.ManagedMemoryEntry", err) + } + out.ManagedMemoryEntry = conv28 + out.Score = v.Score + return out, nil +} + +// ManagedMemoryStoreToSDK converts the mirror to the sdk-go type. +func ManagedMemoryStoreToSDK(w *ManagedMemoryStore) (*sdk.ManagedMemoryStore, error) { + if w == nil { + return nil, nil + } + out := &sdk.ManagedMemoryStore{} + out.Name = w.Name + out.DisplayName = w.DisplayName + out.WorkspaceId = w.WorkspaceId + conv29, err := StorageBackendToSDK(w.StorageBackend) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ManagedMemoryStore.StorageBackend", err) + } + out.StorageBackend = conv29 + out.OwnerUserId = w.OwnerUserId + out.CreatorUserId = w.CreatorUserId + out.Description = w.Description + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + return out, nil +} + +// ManagedMemoryStoreFromSDK converts the sdk-go type to the mirror. +func ManagedMemoryStoreFromSDK(v *sdk.ManagedMemoryStore) (*ManagedMemoryStore, error) { + if v == nil { + return nil, nil + } + out := &ManagedMemoryStore{} + out.Name = v.Name + out.DisplayName = v.DisplayName + out.WorkspaceId = v.WorkspaceId + conv30, err := StorageBackendFromSDK(v.StorageBackend) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ManagedMemoryStore.StorageBackend", err) + } + out.StorageBackend = conv30 + out.OwnerUserId = v.OwnerUserId + out.CreatorUserId = v.CreatorUserId + out.Description = v.Description + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + return out, nil +} + +// PopSessionItemRequestToSDK converts the mirror to the sdk-go type. +func PopSessionItemRequestToSDK(w *PopSessionItemRequest) (*sdk.PopSessionItemRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PopSessionItemRequest{} + out.Parent = w.Parent + return out, nil +} + +// PopSessionItemRequestFromSDK converts the sdk-go type to the mirror. +func PopSessionItemRequestFromSDK(v *sdk.PopSessionItemRequest) (*PopSessionItemRequest, error) { + if v == nil { + return nil, nil + } + out := &PopSessionItemRequest{} + out.Parent = v.Parent + return out, nil +} + +// PopSessionItemResponseToSDK converts the mirror to the sdk-go type. +func PopSessionItemResponseToSDK(w *PopSessionItemResponse) (*sdk.PopSessionItemResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.PopSessionItemResponse{} + conv31, err := SessionItemToSDK(w.Item) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PopSessionItemResponse.Item", err) + } + out.Item = conv31 + return out, nil +} + +// PopSessionItemResponseFromSDK converts the sdk-go type to the mirror. +func PopSessionItemResponseFromSDK(v *sdk.PopSessionItemResponse) (*PopSessionItemResponse, error) { + if v == nil { + return nil, nil + } + out := &PopSessionItemResponse{} + conv32, err := SessionItemFromSDK(v.Item) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PopSessionItemResponse.Item", err) + } + out.Item = conv32 + return out, nil +} + +// SearchManagedMemoryEntriesRequestToSDK converts the mirror to the sdk-go type. +func SearchManagedMemoryEntriesRequestToSDK(w *SearchManagedMemoryEntriesRequest) (*sdk.SearchManagedMemoryEntriesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchManagedMemoryEntriesRequest{} + out.Parent = w.Parent + out.ActorId = w.ActorId + out.Query = w.Query + out.Limit = w.Limit + out.PageSize = w.PageSize + out.PageToken = w.PageToken + out.SessionId = w.SessionId + out.PathPrefix = w.PathPrefix + out.View = w.View + return out, nil +} + +// SearchManagedMemoryEntriesRequestFromSDK converts the sdk-go type to the mirror. +func SearchManagedMemoryEntriesRequestFromSDK(v *sdk.SearchManagedMemoryEntriesRequest) (*SearchManagedMemoryEntriesRequest, error) { + if v == nil { + return nil, nil + } + out := &SearchManagedMemoryEntriesRequest{} + out.Parent = v.Parent + out.ActorId = v.ActorId + out.Query = v.Query + out.Limit = v.Limit + out.PageSize = v.PageSize + out.PageToken = v.PageToken + out.SessionId = v.SessionId + out.PathPrefix = v.PathPrefix + out.View = v.View + return out, nil +} + +// SearchManagedMemoryEntriesResponseToSDK converts the mirror to the sdk-go type. +func SearchManagedMemoryEntriesResponseToSDK(w *SearchManagedMemoryEntriesResponse) (*sdk.SearchManagedMemoryEntriesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchManagedMemoryEntriesResponse{} + conv33, err := convertSlice(w.ManagedMemoryEntries, ManagedMemoryEntryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchManagedMemoryEntriesResponse.ManagedMemoryEntries", err) + } + out.ManagedMemoryEntries = conv33 + out.NextPageToken = w.NextPageToken + conv34, err := convertSlice(w.Results, ManagedMemoryEntrySearchResultToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchManagedMemoryEntriesResponse.Results", err) + } + out.Results = conv34 + return out, nil +} + +// SearchManagedMemoryEntriesResponseFromSDK converts the sdk-go type to the mirror. +func SearchManagedMemoryEntriesResponseFromSDK(v *sdk.SearchManagedMemoryEntriesResponse) (*SearchManagedMemoryEntriesResponse, error) { + if v == nil { + return nil, nil + } + out := &SearchManagedMemoryEntriesResponse{} + conv35, err := convertSlice(v.ManagedMemoryEntries, ManagedMemoryEntryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchManagedMemoryEntriesResponse.ManagedMemoryEntries", err) + } + out.ManagedMemoryEntries = conv35 + out.NextPageToken = v.NextPageToken + conv36, err := convertSlice(v.Results, ManagedMemoryEntrySearchResultFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchManagedMemoryEntriesResponse.Results", err) + } + out.Results = conv36 + return out, nil +} + +// SessionToSDK converts the mirror to the sdk-go type. +func SessionToSDK(w *Session) (*sdk.Session, error) { + if w == nil { + return nil, nil + } + out := &sdk.Session{} + out.SessionId = w.SessionId + out.ActorId = w.ActorId + out.ParentSessionId = w.ParentSessionId + out.RootSessionId = w.RootSessionId + out.Metadata = w.Metadata + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.LastActivityTime = w.LastActivityTime + out.Name = w.Name + return out, nil +} + +// SessionFromSDK converts the sdk-go type to the mirror. +func SessionFromSDK(v *sdk.Session) (*Session, error) { + if v == nil { + return nil, nil + } + out := &Session{} + out.SessionId = v.SessionId + out.ActorId = v.ActorId + out.ParentSessionId = v.ParentSessionId + out.RootSessionId = v.RootSessionId + out.Metadata = v.Metadata + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.LastActivityTime = v.LastActivityTime + out.Name = v.Name + return out, nil +} + +// SessionItemToSDK converts the mirror to the sdk-go type. +func SessionItemToSDK(w *SessionItem) (*sdk.SessionItem, error) { + if w == nil { + return nil, nil + } + out := &sdk.SessionItem{} + out.ItemId = w.ItemId + out.Data = w.Data + out.CreateTime = w.CreateTime + return out, nil +} + +// SessionItemFromSDK converts the sdk-go type to the mirror. +func SessionItemFromSDK(v *sdk.SessionItem) (*SessionItem, error) { + if v == nil { + return nil, nil + } + out := &SessionItem{} + out.ItemId = v.ItemId + out.Data = v.Data + out.CreateTime = v.CreateTime + return out, nil +} + +// SessionStoreToSDK converts the mirror to the sdk-go type. +func SessionStoreToSDK(w *SessionStore) (*sdk.SessionStore, error) { + if w == nil { + return nil, nil + } + out := &sdk.SessionStore{} + out.CreatorUserId = w.CreatorUserId + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.Description = w.Description + out.Metadata = w.Metadata + out.Name = w.Name + return out, nil +} + +// SessionStoreFromSDK converts the sdk-go type to the mirror. +func SessionStoreFromSDK(v *sdk.SessionStore) (*SessionStore, error) { + if v == nil { + return nil, nil + } + out := &SessionStore{} + out.CreatorUserId = v.CreatorUserId + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.Description = v.Description + out.Metadata = v.Metadata + out.Name = v.Name + return out, nil +} + +// StorageBackendToSDK converts the mirror to the sdk-go type. +func StorageBackendToSDK(w *StorageBackend) (*sdk.StorageBackend, error) { + if w == nil { + return nil, nil + } + out := &sdk.StorageBackend{} + out.BackendType = w.BackendType + out.BackendId = w.BackendId + return out, nil +} + +// StorageBackendFromSDK converts the sdk-go type to the mirror. +func StorageBackendFromSDK(v *sdk.StorageBackend) (*StorageBackend, error) { + if v == nil { + return nil, nil + } + out := &StorageBackend{} + out.BackendType = v.BackendType + out.BackendId = v.BackendId + return out, nil +} + +// UpdateManagedMemoryEntryRequestToSDK converts the mirror to the sdk-go type. +func UpdateManagedMemoryEntryRequestToSDK(w *UpdateManagedMemoryEntryRequest) (*sdk.UpdateManagedMemoryEntryRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateManagedMemoryEntryRequest{} + conv37, err := ManagedMemoryEntryToSDK(w.ManagedMemoryEntry) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateManagedMemoryEntryRequest.ManagedMemoryEntry", err) + } + out.ManagedMemoryEntry = conv37 + mask38, err := fieldMaskFromString[sdk.ManagedMemoryEntry](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateManagedMemoryEntryRequest.UpdateMask", err) + } + out.UpdateMask = mask38 + return out, nil +} + +// UpdateManagedMemoryEntryRequestFromSDK converts the sdk-go type to the mirror. +func UpdateManagedMemoryEntryRequestFromSDK(v *sdk.UpdateManagedMemoryEntryRequest) (*UpdateManagedMemoryEntryRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateManagedMemoryEntryRequest{} + conv39, err := ManagedMemoryEntryFromSDK(v.ManagedMemoryEntry) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateManagedMemoryEntryRequest.ManagedMemoryEntry", err) + } + out.ManagedMemoryEntry = conv39 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateManagedMemoryStoreRequestToSDK converts the mirror to the sdk-go type. +func UpdateManagedMemoryStoreRequestToSDK(w *UpdateManagedMemoryStoreRequest) (*sdk.UpdateManagedMemoryStoreRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateManagedMemoryStoreRequest{} + conv40, err := ManagedMemoryStoreToSDK(w.ManagedMemoryStore) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateManagedMemoryStoreRequest.ManagedMemoryStore", err) + } + out.ManagedMemoryStore = conv40 + mask41, err := fieldMaskFromString[sdk.ManagedMemoryStore](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateManagedMemoryStoreRequest.UpdateMask", err) + } + out.UpdateMask = mask41 + return out, nil +} + +// UpdateManagedMemoryStoreRequestFromSDK converts the sdk-go type to the mirror. +func UpdateManagedMemoryStoreRequestFromSDK(v *sdk.UpdateManagedMemoryStoreRequest) (*UpdateManagedMemoryStoreRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateManagedMemoryStoreRequest{} + conv42, err := ManagedMemoryStoreFromSDK(v.ManagedMemoryStore) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateManagedMemoryStoreRequest.ManagedMemoryStore", err) + } + out.ManagedMemoryStore = conv42 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateSessionRequestToSDK converts the mirror to the sdk-go type. +func UpdateSessionRequestToSDK(w *UpdateSessionRequest) (*sdk.UpdateSessionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateSessionRequest{} + conv43, err := SessionToSDK(w.Session) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSessionRequest.Session", err) + } + out.Session = conv43 + mask44, err := fieldMaskFromString[sdk.Session](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSessionRequest.UpdateMask", err) + } + out.UpdateMask = mask44 + return out, nil +} + +// UpdateSessionRequestFromSDK converts the sdk-go type to the mirror. +func UpdateSessionRequestFromSDK(v *sdk.UpdateSessionRequest) (*UpdateSessionRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateSessionRequest{} + conv45, err := SessionFromSDK(v.Session) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSessionRequest.Session", err) + } + out.Session = conv45 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateSessionStoreRequestToSDK converts the mirror to the sdk-go type. +func UpdateSessionStoreRequestToSDK(w *UpdateSessionStoreRequest) (*sdk.UpdateSessionStoreRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateSessionStoreRequest{} + conv46, err := SessionStoreToSDK(w.SessionStore) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSessionStoreRequest.SessionStore", err) + } + out.SessionStore = conv46 + mask47, err := fieldMaskFromString[sdk.SessionStore](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSessionStoreRequest.UpdateMask", err) + } + out.UpdateMask = mask47 + return out, nil +} + +// UpdateSessionStoreRequestFromSDK converts the sdk-go type to the mirror. +func UpdateSessionStoreRequestFromSDK(v *sdk.UpdateSessionStoreRequest) (*UpdateSessionStoreRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateSessionStoreRequest{} + conv48, err := SessionStoreFromSDK(v.SessionStore) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSessionStoreRequest.SessionStore", err) + } + out.SessionStore = conv48 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/aifunctions/v1/types.generated.go b/libs/sdktypes/aifunctions/v1/types.generated.go new file mode 100644 index 00000000000..e578239584f --- /dev/null +++ b/libs/sdktypes/aifunctions/v1/types.generated.go @@ -0,0 +1,911 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/aifunctions/v1. DO NOT EDIT. + +package aifunctions + +import ( + json "encoding/json" + fmt "fmt" + sdk "github.com/databricks/sdk-go/aifunctions/v1" +) + +// ai_classify. +type AiClassifyOptions struct { + // When true, includes a per-label confidence score in the response. + EnableConfidenceScores *bool `json:"enable_confidence_scores,omitempty"` + // When true, includes a rationale explaining each classification in the + // response. + EnableRationales *bool `json:"enable_rationales,omitempty"` + // Natural-language guidance that steers how the text is classified (up to + // 20,000 characters). + Instructions *string `json:"instructions,omitempty"` + // When true, allows more than one label to be returned per input. + Multilabel *bool `json:"multilabel,omitempty"` + // The function version to invoke. Defaults to the latest version. Supported + // versions: ["2.1"]. + Version *string `json:"version,omitempty"` +} + +type AiClassifyRequest struct { + // The content to classify. It accepts a plain string or the response object of + // [ai_parse_document](:method:AiFunctions/AiParseDocument). + Content json.RawMessage `json:"content,omitempty"` + // The label set to classify as. Either a JSON array of label strings (e.g. + // ["spam", "not_spam"]), or a JSON object mapping each label to a description + // (e.g. {"spam": "unsolicited bulk message", "not_spam": "a legitimate + // message"}). Accepts 2 to 500 labels, each 1 to 100 characters. + Labels json.RawMessage `json:"labels,omitempty"` + // Function options. Omitted fields fall back to their documented defaults. + Options *AiClassifyOptions `json:"options,omitempty"` +} + +type AiClassifyResponse struct { + // Additional metadata returned by AI Classify. + Metadata *AiClassifyResponseMetadata `json:"metadata,omitempty"` + // The function result as a JSON value. An array of per-label objects: one + // element in single-label mode (the default), or multiple elements when + // `multilabel` is true. When `enable_confidence_scores` and `enable_rationales` + // are true, `confidence_score` and `rationale` are included in each response + // value, respectively. + Response json.RawMessage `json:"response,omitempty"` +} + +type AiClassifyResponseMetadata struct { + // The resolved function version. + Version *string `json:"version,omitempty"` +} + +// ai_decide. +type AiDecideOptions struct { + // The function API version to invoke. Defaults to "1.0". Supported versions: + // ["1.0"]. + Version *string `json:"version,omitempty"` +} + +type AiDecideRequest struct { + // Function options. Omitted fields fall back to their documented defaults. + Options *AiDecideOptions `json:"options,omitempty"` + // A JSON object mapping question IDs to their definitions. Each ID must contain + // non-whitespace text; its answer is returned with the same ID in + // `response.answers`. + // + // Each definition is an object with the required fields `type` and + // `instructions`. The `criteria` field is optional for the type `noul` but is + // required for the types `choice` and `score`. + // + // The `instructions` field describes the judgment to make and can be a string, + // object, or array. Use an object or array to include supporting context + // alongside the instructions. + // + // The `type` can be one of: + // + // - `choice`: Selects one option from a defined set. Requires `criteria` to be + // an object mapping 1 to 255 nonempty option names to descriptions. The + // criteria description can be a string, object, array, or null when the name + // needs no additional detail. For example: + // + // ```json { "team": { "type": "choice", "instructions": "Which team should + // handle this ticket?", "criteria": { "billing": "Payments, charges, and + // refunds", "technical_support": null } } } ``` + // + // - `noul`: Estimates the probability that the answer to a true-or-false + // question is true. `criteria` can take the fields `true` or `false`, or both, + // with descriptions that are strings, objects, or arrays. Omit `criteria` to + // use the question alone. The instructions or at least one criteria description + // must contain non-whitespace text, a nonempty object, or a nonempty array. For + // example, both of the following are valid: + // + // ```json { "escalate": { "type": "noul", "instructions": "Does this ticket + // need escalation?", "criteria": { "true": "Suspected fraud or an exception to + // standard policy", "false": "A routine issue frontline support can resolve" } + // } } ``` + // + // or + // + // ```json { "escalate": { "type": "noul", "instructions": "Does this ticket + // need escalation?" } } ``` + // + // - `score`: Rates the state on an ordered scale. Requires `criteria` to be an + // array of 2 to 10 level descriptions, ordered from low to high. Descriptions + // must contain non-whitespace text, a nonempty object, or a nonempty array. + // Array positions define levels starting at 0. For example: + // + // ```json { "urgency": { "type": "score", "instructions": "How urgent is this + // ticket?", "criteria": [ "Routine: can wait a few days", "Time-sensitive: + // needs attention today", "Critical: needs immediate action" ] } } ``` + Questions json.RawMessage `json:"questions,omitempty"` + // A string, JSON object, or array containing the content, related context, and + // examples needed to answer the provided questions. For example, provide a + // support message, a conversation, or records describing the current state of + // an application. All questions receive this same state. + State json.RawMessage `json:"state,omitempty"` +} + +type AiDecideResponse struct { + // Metadata identifying the function API version used for this request. + Metadata *AiDecideResponseMetadata `json:"metadata,omitempty"` + // A JSON object containing an `answers` map with one answer for each question, + // keyed by the same IDs as `questions`. + // + // Each answer has a `type` matching its question and the following fields: + // + // - `choice`: choice is the highest-probability option from `criteria`. + // `probabilities` maps every option name to its probability. `confidence` is a + // number from 0 to 1 indicating how well the state supports the assessment. The + // `probabilities` values sum to 1. For example: + // + // ```json { "answers": { "team": { "type": "choice", "choice": "billing", + // "probabilities": { "billing": 0.85, "technical_support": 0.15 }, + // "confidence": 0.9 } } } ``` + // + // - `noul`: `probability` is a number from 0 to 1 estimating the probability + // that the answer is true. For example: + // + // ```json { "answers": { "escalate": { "type": "noul", "probability": 0.8 } } } + // ``` + // + // - `score`: score is the probability-weighted mean of the zero-based level + // indices. It can fall between levels, from 0 to the number of levels minus 1. + // `probabilities` maps each level index to its probability, and `legend` maps + // each index to its original description. Both maps use string keys such as + // "0", "1", and "2". `confidence` is a number from 0 to 1 indicating how well + // the state supports the assessment. The `probabilities` values sum to 1. For + // example: + // + // ```json { "answers": { "urgency": { "type": "score", "score": 1.6, + // "probabilities": { "0": 0.1, "1": 0.2, "2": 0.7 }, "legend": { "0": "Routine: + // can wait a few days", "1": "Time-sensitive: needs attention today", "2": + // "Critical: needs immediate action" }, "confidence": 0.85 } } } ``` + Response json.RawMessage `json:"response,omitempty"` +} + +type AiDecideResponseMetadata struct { + // The function API version used to evaluate the request. + Version *string `json:"version,omitempty"` +} + +// A bounding box on a source page; used by bbox-input citations.. +type AiExtractBbox struct { + // Pixel coordinates on the page image as [x0, y0, x1, y1]. + Coord []int64 `json:"coord,omitempty"` + // 0-based page index the box is on. + PageId *int64 `json:"page_id,omitempty"` +} + +// A citation locating an extracted value in the source. start/stop are set for +// span (STRING input) citations, bbox for bbox (parsed-document input) +// citations.. +type AiExtractCitation struct { + // Bounding boxes locating the citation on the source pages; set for bbox + // citations. + Bbox []AiExtractBbox `json:"bbox,omitempty"` + // Integer matching a citation_ids entry on an extracted field. + Id *int64 `json:"id,omitempty"` + // Inclusive 0-based character offset into the input string; set for span + // citations. + Start *int64 `json:"start,omitempty"` + // Exclusive 0-based character offset into the input string; set for span + // citations. + Stop *int64 `json:"stop,omitempty"` +} + +// ai_extract. +type AiExtractOptions struct { + // When true, includes citation metadata locating each extracted value in the + // source. Depending on the type of input, citations can be one of two types: + // + // For raw text (STRING) inputs, a citation is a span of text in the original + // input. Each object in `metadata.citations` has an `id` (integer matching a + // `citation_ids` entry on a field), a `start` (inclusive 0-based character + // offset into the input string), and a `stop` (exclusive 0-based character + // offset into the input string). + // + // For PDF documents and images (when using ai_extract downstream of + // ai_parse_document), a citation is a bounding box in the original input. Each + // object in `metadata.citations` has an `id` (integer matching a `citation_ids` + // entry on a field) and a `bbox` (array of {coord, page_id} objects, identical + // in shape to element.bbox in ai_parse_document output; coord is pixel + // coordinates on the page image as [x0, y0, x1, y1], and page_id is a 0-based + // page index). + EnableCitations *bool `json:"enable_citations,omitempty"` + // When true, includes a per-field confidence score in the response. + EnableConfidenceScores *bool `json:"enable_confidence_scores,omitempty"` + // Natural-language guidance that steers how data is extracted (up to 20,000 + // characters). + Instructions *string `json:"instructions,omitempty"` + // Extraction mode. Supported modes: "precision" — more powerful extraction + // for complex schemas, long documents, and reasoning-heavy extractions. + // Defaults to none (standard extraction). + Mode *string `json:"mode,omitempty"` + // The function version to invoke. Defaults to the latest version. Supported + // versions: ["2.1"]. + Version *string `json:"version,omitempty"` +} + +type AiExtractRequest struct { + // The text to extract from. It accepts a plain string or the response object of + // [ai_parse_document](:method:AiFunctions/AiParseDocument). + Content json.RawMessage `json:"content,omitempty"` + // Function options. Omitted fields fall back to their documented defaults. + Options *AiExtractOptions `json:"options,omitempty"` + // The extraction schema defining the fields to extract. Either a JSON array of + // field names, assumed to be strings (e.g. ["company", "valuation"]), or a JSON + // object mapping each field to its type/description/nullability (e.g. + // {"company": {"type": "string", "description": "the company name"}}). Accepts + // up to 256 fields, 12 levels of nesting, and 500 enum values. Supported field + // types are string, integer, number, boolean, and enum. + Schema json.RawMessage `json:"schema,omitempty"` +} + +type AiExtractResponse struct { + // Additional metadata returned by AI Extract. + Metadata *AiExtractResponseMetadata `json:"metadata,omitempty"` + // The function result as a JSON value. When `enable_confidence_scores` and + // `enable_citations` are true, `confidence` and `citation_ids` are included in + // each response field, respectively. + Response json.RawMessage `json:"response,omitempty"` +} + +type AiExtractResponseMetadata struct { + // How the source was chunked for citation offsets (span for text input, bbox + // for parsed-document input); present when citations are enabled. + ChunkType *string `json:"chunk_type,omitempty"` + // Citation objects locating each result in the source; present when citations + // are enabled. + Citations []AiExtractCitation `json:"citations,omitempty"` + // The resolved extraction mode; present when a non-default mode was used. + Mode *string `json:"mode,omitempty"` + // The resolved function version. + Version *string `json:"version,omitempty"` +} + +// Metadata about the source file; present only for file-path input.. +type AiParseDocumentFileMetadata struct { + // Last-modified timestamp of the source file, as an HTTP date string. + FileModificationTime *string `json:"file_modification_time,omitempty"` + // Base name of the source file. + FileName *string `json:"file_name,omitempty"` + // Unity Catalog volume path of the source file. + FilePath *string `json:"file_path,omitempty"` + // Size of the source file in bytes. + FileSize *int64 `json:"file_size,omitempty"` +} + +// ai_parse_document. +type AiParseDocumentOptions struct { + // Element types for which an AI-generated description is produced. Use "*" + // (default) to generate descriptions for all supported element types, "figure" + // to generate them for figures only, or "" (empty string) to generate none. + // Only figure descriptions are supported for version "2.0", so "*" and "figure" + // produce the same behavior. + DescriptionElementTypes *string `json:"description_element_types,omitempty"` + // Unity Catalog volume path where rendered page and element images are written. + ImageOutputPath *string `json:"image_output_path,omitempty"` + // Pages to parse (1-indexed), as a comma-separated list of page numbers or + // ranges (e.g. "1,3,5-10"). + PageRange *string `json:"page_range,omitempty"` + // The ai_parse_document output schema version. Supported value: "2.0". + Version *string `json:"version,omitempty"` +} + +// A single page that failed to parse while the overall request succeeded.. +type AiParseDocumentPageError struct { + // Message describing why the page failed. + ErrorMessage *string `json:"error_message,omitempty"` + // 0-based index of the page that failed. + PageId *int64 `json:"page_id,omitempty"` +} + +type AiParseDocumentRequest struct { + // The document to parse. The REST API accepts a Unity Catalog volume path to + // the source file or a base64 data URL containing the file bytes (for example, + // data:application/pdf;base64, or + // data:image/jpeg;base64,). Supported formats: PDF, DOCX, + // DOC, PPTX, PPT, JPG, JPEG, PNG, TIFF. Accepts up to 100 pages and 100 MB per + // document. + Content *string `json:"content,omitempty"` + // Function options. Omitted fields fall back to their documented defaults. + Options *AiParseDocumentOptions `json:"options,omitempty"` +} + +type AiParseDocumentResponse struct { + // The parsed document as a JSON value, containing the extracted pages and + // elements. + Document json.RawMessage `json:"document,omitempty"` + // Per-page partial-failure details; present when the request succeeds (2xx) but + // individual pages fail. + ErrorStatus []AiParseDocumentPageError `json:"error_status,omitempty"` + // Additional metadata returned by AI Parse Document. + Metadata *AiParseDocumentResponseMetadata `json:"metadata,omitempty"` +} + +type AiParseDocumentResponseMetadata struct { + // Describes the source file; present only for file-path input. + FileMetadata *AiParseDocumentFileMetadata `json:"file_metadata,omitempty"` + // Unique identifier for the parse request. + Id *string `json:"id,omitempty"` + // The resolved function version. + Version *string `json:"version,omitempty"` +} + +// AiClassifyOptionsToSDK converts the mirror to the sdk-go type. +func AiClassifyOptionsToSDK(w *AiClassifyOptions) (*sdk.AiClassifyOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiClassifyOptions{} + out.Instructions = w.Instructions + out.Version = w.Version + out.Multilabel = w.Multilabel + out.EnableConfidenceScores = w.EnableConfidenceScores + out.EnableRationales = w.EnableRationales + return out, nil +} + +// AiClassifyOptionsFromSDK converts the sdk-go type to the mirror. +func AiClassifyOptionsFromSDK(v *sdk.AiClassifyOptions) (*AiClassifyOptions, error) { + if v == nil { + return nil, nil + } + out := &AiClassifyOptions{} + out.Instructions = v.Instructions + out.Version = v.Version + out.Multilabel = v.Multilabel + out.EnableConfidenceScores = v.EnableConfidenceScores + out.EnableRationales = v.EnableRationales + return out, nil +} + +// AiClassifyRequestToSDK converts the mirror to the sdk-go type. +func AiClassifyRequestToSDK(w *AiClassifyRequest) (*sdk.AiClassifyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiClassifyRequest{} + out.Content = w.Content + out.Labels = w.Labels + conv1, err := AiClassifyOptionsToSDK(w.Options) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiClassifyRequest.Options", err) + } + out.Options = conv1 + return out, nil +} + +// AiClassifyRequestFromSDK converts the sdk-go type to the mirror. +func AiClassifyRequestFromSDK(v *sdk.AiClassifyRequest) (*AiClassifyRequest, error) { + if v == nil { + return nil, nil + } + out := &AiClassifyRequest{} + out.Content = v.Content + out.Labels = v.Labels + conv2, err := AiClassifyOptionsFromSDK(v.Options) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiClassifyRequest.Options", err) + } + out.Options = conv2 + return out, nil +} + +// AiClassifyResponseToSDK converts the mirror to the sdk-go type. +func AiClassifyResponseToSDK(w *AiClassifyResponse) (*sdk.AiClassifyResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiClassifyResponse{} + out.Response = w.Response + conv3, err := AiClassifyResponseMetadataToSDK(w.Metadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiClassifyResponse.Metadata", err) + } + out.Metadata = conv3 + return out, nil +} + +// AiClassifyResponseFromSDK converts the sdk-go type to the mirror. +func AiClassifyResponseFromSDK(v *sdk.AiClassifyResponse) (*AiClassifyResponse, error) { + if v == nil { + return nil, nil + } + out := &AiClassifyResponse{} + out.Response = v.Response + conv4, err := AiClassifyResponseMetadataFromSDK(v.Metadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiClassifyResponse.Metadata", err) + } + out.Metadata = conv4 + return out, nil +} + +// AiClassifyResponseMetadataToSDK converts the mirror to the sdk-go type. +func AiClassifyResponseMetadataToSDK(w *AiClassifyResponseMetadata) (*sdk.AiClassifyResponseMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiClassifyResponseMetadata{} + out.Version = w.Version + return out, nil +} + +// AiClassifyResponseMetadataFromSDK converts the sdk-go type to the mirror. +func AiClassifyResponseMetadataFromSDK(v *sdk.AiClassifyResponseMetadata) (*AiClassifyResponseMetadata, error) { + if v == nil { + return nil, nil + } + out := &AiClassifyResponseMetadata{} + out.Version = v.Version + return out, nil +} + +// AiDecideOptionsToSDK converts the mirror to the sdk-go type. +func AiDecideOptionsToSDK(w *AiDecideOptions) (*sdk.AiDecideOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiDecideOptions{} + out.Version = w.Version + return out, nil +} + +// AiDecideOptionsFromSDK converts the sdk-go type to the mirror. +func AiDecideOptionsFromSDK(v *sdk.AiDecideOptions) (*AiDecideOptions, error) { + if v == nil { + return nil, nil + } + out := &AiDecideOptions{} + out.Version = v.Version + return out, nil +} + +// AiDecideRequestToSDK converts the mirror to the sdk-go type. +func AiDecideRequestToSDK(w *AiDecideRequest) (*sdk.AiDecideRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiDecideRequest{} + out.State = w.State + out.Questions = w.Questions + conv5, err := AiDecideOptionsToSDK(w.Options) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiDecideRequest.Options", err) + } + out.Options = conv5 + return out, nil +} + +// AiDecideRequestFromSDK converts the sdk-go type to the mirror. +func AiDecideRequestFromSDK(v *sdk.AiDecideRequest) (*AiDecideRequest, error) { + if v == nil { + return nil, nil + } + out := &AiDecideRequest{} + out.State = v.State + out.Questions = v.Questions + conv6, err := AiDecideOptionsFromSDK(v.Options) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiDecideRequest.Options", err) + } + out.Options = conv6 + return out, nil +} + +// AiDecideResponseToSDK converts the mirror to the sdk-go type. +func AiDecideResponseToSDK(w *AiDecideResponse) (*sdk.AiDecideResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiDecideResponse{} + out.Response = w.Response + conv7, err := AiDecideResponseMetadataToSDK(w.Metadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiDecideResponse.Metadata", err) + } + out.Metadata = conv7 + return out, nil +} + +// AiDecideResponseFromSDK converts the sdk-go type to the mirror. +func AiDecideResponseFromSDK(v *sdk.AiDecideResponse) (*AiDecideResponse, error) { + if v == nil { + return nil, nil + } + out := &AiDecideResponse{} + out.Response = v.Response + conv8, err := AiDecideResponseMetadataFromSDK(v.Metadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiDecideResponse.Metadata", err) + } + out.Metadata = conv8 + return out, nil +} + +// AiDecideResponseMetadataToSDK converts the mirror to the sdk-go type. +func AiDecideResponseMetadataToSDK(w *AiDecideResponseMetadata) (*sdk.AiDecideResponseMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiDecideResponseMetadata{} + out.Version = w.Version + return out, nil +} + +// AiDecideResponseMetadataFromSDK converts the sdk-go type to the mirror. +func AiDecideResponseMetadataFromSDK(v *sdk.AiDecideResponseMetadata) (*AiDecideResponseMetadata, error) { + if v == nil { + return nil, nil + } + out := &AiDecideResponseMetadata{} + out.Version = v.Version + return out, nil +} + +// AiExtractBboxToSDK converts the mirror to the sdk-go type. +func AiExtractBboxToSDK(w *AiExtractBbox) (*sdk.AiExtractBbox, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiExtractBbox{} + out.Coord = w.Coord + out.PageId = w.PageId + return out, nil +} + +// AiExtractBboxFromSDK converts the sdk-go type to the mirror. +func AiExtractBboxFromSDK(v *sdk.AiExtractBbox) (*AiExtractBbox, error) { + if v == nil { + return nil, nil + } + out := &AiExtractBbox{} + out.Coord = v.Coord + out.PageId = v.PageId + return out, nil +} + +// AiExtractCitationToSDK converts the mirror to the sdk-go type. +func AiExtractCitationToSDK(w *AiExtractCitation) (*sdk.AiExtractCitation, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiExtractCitation{} + out.Id = w.Id + out.Start = w.Start + out.Stop = w.Stop + conv9, err := convertSlice(w.Bbox, AiExtractBboxToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiExtractCitation.Bbox", err) + } + out.Bbox = conv9 + return out, nil +} + +// AiExtractCitationFromSDK converts the sdk-go type to the mirror. +func AiExtractCitationFromSDK(v *sdk.AiExtractCitation) (*AiExtractCitation, error) { + if v == nil { + return nil, nil + } + out := &AiExtractCitation{} + out.Id = v.Id + out.Start = v.Start + out.Stop = v.Stop + conv10, err := convertSlice(v.Bbox, AiExtractBboxFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiExtractCitation.Bbox", err) + } + out.Bbox = conv10 + return out, nil +} + +// AiExtractOptionsToSDK converts the mirror to the sdk-go type. +func AiExtractOptionsToSDK(w *AiExtractOptions) (*sdk.AiExtractOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiExtractOptions{} + out.Instructions = w.Instructions + out.Version = w.Version + out.Mode = w.Mode + out.EnableCitations = w.EnableCitations + out.EnableConfidenceScores = w.EnableConfidenceScores + return out, nil +} + +// AiExtractOptionsFromSDK converts the sdk-go type to the mirror. +func AiExtractOptionsFromSDK(v *sdk.AiExtractOptions) (*AiExtractOptions, error) { + if v == nil { + return nil, nil + } + out := &AiExtractOptions{} + out.Instructions = v.Instructions + out.Version = v.Version + out.Mode = v.Mode + out.EnableCitations = v.EnableCitations + out.EnableConfidenceScores = v.EnableConfidenceScores + return out, nil +} + +// AiExtractRequestToSDK converts the mirror to the sdk-go type. +func AiExtractRequestToSDK(w *AiExtractRequest) (*sdk.AiExtractRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiExtractRequest{} + out.Content = w.Content + out.Schema = w.Schema + conv11, err := AiExtractOptionsToSDK(w.Options) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiExtractRequest.Options", err) + } + out.Options = conv11 + return out, nil +} + +// AiExtractRequestFromSDK converts the sdk-go type to the mirror. +func AiExtractRequestFromSDK(v *sdk.AiExtractRequest) (*AiExtractRequest, error) { + if v == nil { + return nil, nil + } + out := &AiExtractRequest{} + out.Content = v.Content + out.Schema = v.Schema + conv12, err := AiExtractOptionsFromSDK(v.Options) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiExtractRequest.Options", err) + } + out.Options = conv12 + return out, nil +} + +// AiExtractResponseToSDK converts the mirror to the sdk-go type. +func AiExtractResponseToSDK(w *AiExtractResponse) (*sdk.AiExtractResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiExtractResponse{} + out.Response = w.Response + conv13, err := AiExtractResponseMetadataToSDK(w.Metadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiExtractResponse.Metadata", err) + } + out.Metadata = conv13 + return out, nil +} + +// AiExtractResponseFromSDK converts the sdk-go type to the mirror. +func AiExtractResponseFromSDK(v *sdk.AiExtractResponse) (*AiExtractResponse, error) { + if v == nil { + return nil, nil + } + out := &AiExtractResponse{} + out.Response = v.Response + conv14, err := AiExtractResponseMetadataFromSDK(v.Metadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiExtractResponse.Metadata", err) + } + out.Metadata = conv14 + return out, nil +} + +// AiExtractResponseMetadataToSDK converts the mirror to the sdk-go type. +func AiExtractResponseMetadataToSDK(w *AiExtractResponseMetadata) (*sdk.AiExtractResponseMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiExtractResponseMetadata{} + out.Version = w.Version + out.Mode = w.Mode + out.ChunkType = w.ChunkType + conv15, err := convertSlice(w.Citations, AiExtractCitationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiExtractResponseMetadata.Citations", err) + } + out.Citations = conv15 + return out, nil +} + +// AiExtractResponseMetadataFromSDK converts the sdk-go type to the mirror. +func AiExtractResponseMetadataFromSDK(v *sdk.AiExtractResponseMetadata) (*AiExtractResponseMetadata, error) { + if v == nil { + return nil, nil + } + out := &AiExtractResponseMetadata{} + out.Version = v.Version + out.Mode = v.Mode + out.ChunkType = v.ChunkType + conv16, err := convertSlice(v.Citations, AiExtractCitationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiExtractResponseMetadata.Citations", err) + } + out.Citations = conv16 + return out, nil +} + +// AiParseDocumentFileMetadataToSDK converts the mirror to the sdk-go type. +func AiParseDocumentFileMetadataToSDK(w *AiParseDocumentFileMetadata) (*sdk.AiParseDocumentFileMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiParseDocumentFileMetadata{} + out.FilePath = w.FilePath + out.FileName = w.FileName + out.FileSize = w.FileSize + out.FileModificationTime = w.FileModificationTime + return out, nil +} + +// AiParseDocumentFileMetadataFromSDK converts the sdk-go type to the mirror. +func AiParseDocumentFileMetadataFromSDK(v *sdk.AiParseDocumentFileMetadata) (*AiParseDocumentFileMetadata, error) { + if v == nil { + return nil, nil + } + out := &AiParseDocumentFileMetadata{} + out.FilePath = v.FilePath + out.FileName = v.FileName + out.FileSize = v.FileSize + out.FileModificationTime = v.FileModificationTime + return out, nil +} + +// AiParseDocumentOptionsToSDK converts the mirror to the sdk-go type. +func AiParseDocumentOptionsToSDK(w *AiParseDocumentOptions) (*sdk.AiParseDocumentOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiParseDocumentOptions{} + out.Version = w.Version + out.DescriptionElementTypes = w.DescriptionElementTypes + out.ImageOutputPath = w.ImageOutputPath + out.PageRange = w.PageRange + return out, nil +} + +// AiParseDocumentOptionsFromSDK converts the sdk-go type to the mirror. +func AiParseDocumentOptionsFromSDK(v *sdk.AiParseDocumentOptions) (*AiParseDocumentOptions, error) { + if v == nil { + return nil, nil + } + out := &AiParseDocumentOptions{} + out.Version = v.Version + out.DescriptionElementTypes = v.DescriptionElementTypes + out.ImageOutputPath = v.ImageOutputPath + out.PageRange = v.PageRange + return out, nil +} + +// AiParseDocumentPageErrorToSDK converts the mirror to the sdk-go type. +func AiParseDocumentPageErrorToSDK(w *AiParseDocumentPageError) (*sdk.AiParseDocumentPageError, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiParseDocumentPageError{} + out.ErrorMessage = w.ErrorMessage + out.PageId = w.PageId + return out, nil +} + +// AiParseDocumentPageErrorFromSDK converts the sdk-go type to the mirror. +func AiParseDocumentPageErrorFromSDK(v *sdk.AiParseDocumentPageError) (*AiParseDocumentPageError, error) { + if v == nil { + return nil, nil + } + out := &AiParseDocumentPageError{} + out.ErrorMessage = v.ErrorMessage + out.PageId = v.PageId + return out, nil +} + +// AiParseDocumentRequestToSDK converts the mirror to the sdk-go type. +func AiParseDocumentRequestToSDK(w *AiParseDocumentRequest) (*sdk.AiParseDocumentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiParseDocumentRequest{} + out.Content = w.Content + conv17, err := AiParseDocumentOptionsToSDK(w.Options) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiParseDocumentRequest.Options", err) + } + out.Options = conv17 + return out, nil +} + +// AiParseDocumentRequestFromSDK converts the sdk-go type to the mirror. +func AiParseDocumentRequestFromSDK(v *sdk.AiParseDocumentRequest) (*AiParseDocumentRequest, error) { + if v == nil { + return nil, nil + } + out := &AiParseDocumentRequest{} + out.Content = v.Content + conv18, err := AiParseDocumentOptionsFromSDK(v.Options) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiParseDocumentRequest.Options", err) + } + out.Options = conv18 + return out, nil +} + +// AiParseDocumentResponseToSDK converts the mirror to the sdk-go type. +func AiParseDocumentResponseToSDK(w *AiParseDocumentResponse) (*sdk.AiParseDocumentResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiParseDocumentResponse{} + out.Document = w.Document + conv19, err := convertSlice(w.ErrorStatus, AiParseDocumentPageErrorToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiParseDocumentResponse.ErrorStatus", err) + } + out.ErrorStatus = conv19 + conv20, err := AiParseDocumentResponseMetadataToSDK(w.Metadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiParseDocumentResponse.Metadata", err) + } + out.Metadata = conv20 + return out, nil +} + +// AiParseDocumentResponseFromSDK converts the sdk-go type to the mirror. +func AiParseDocumentResponseFromSDK(v *sdk.AiParseDocumentResponse) (*AiParseDocumentResponse, error) { + if v == nil { + return nil, nil + } + out := &AiParseDocumentResponse{} + out.Document = v.Document + conv21, err := convertSlice(v.ErrorStatus, AiParseDocumentPageErrorFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiParseDocumentResponse.ErrorStatus", err) + } + out.ErrorStatus = conv21 + conv22, err := AiParseDocumentResponseMetadataFromSDK(v.Metadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiParseDocumentResponse.Metadata", err) + } + out.Metadata = conv22 + return out, nil +} + +// AiParseDocumentResponseMetadataToSDK converts the mirror to the sdk-go type. +func AiParseDocumentResponseMetadataToSDK(w *AiParseDocumentResponseMetadata) (*sdk.AiParseDocumentResponseMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiParseDocumentResponseMetadata{} + out.Id = w.Id + out.Version = w.Version + conv23, err := AiParseDocumentFileMetadataToSDK(w.FileMetadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiParseDocumentResponseMetadata.FileMetadata", err) + } + out.FileMetadata = conv23 + return out, nil +} + +// AiParseDocumentResponseMetadataFromSDK converts the sdk-go type to the mirror. +func AiParseDocumentResponseMetadataFromSDK(v *sdk.AiParseDocumentResponseMetadata) (*AiParseDocumentResponseMetadata, error) { + if v == nil { + return nil, nil + } + out := &AiParseDocumentResponseMetadata{} + out.Id = v.Id + out.Version = v.Version + conv24, err := AiParseDocumentFileMetadataFromSDK(v.FileMetadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiParseDocumentResponseMetadata.FileMetadata", err) + } + out.FileMetadata = conv24 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/aigateway/v1/types.generated.go b/libs/sdktypes/aigateway/v1/types.generated.go new file mode 100644 index 00000000000..7d207da7e6f --- /dev/null +++ b/libs/sdktypes/aigateway/v1/types.generated.go @@ -0,0 +1,3590 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/aigateway/v1. DO NOT EDIT. + +package aigateway + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/aigateway/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + ListMcpServicesRequest_View = sdk.ListMcpServicesRequest_View + ListModelProviderServicesRequest_View = sdk.ListModelProviderServicesRequest_View + ListModelServicesRequest_View = sdk.ListModelServicesRequest_View + ModelProviderServiceConfig_ExternalModelProviderType = sdk.ModelProviderServiceConfig_ExternalModelProviderType + ModelServiceConfig_DestinationConfig_DestinationType = sdk.ModelServiceConfig_DestinationConfig_DestinationType + ProvisioningInfo_State = sdk.ProvisioningInfo_State + RateLimit_RateLimitKey = sdk.RateLimit_RateLimitKey + RateLimit_RateLimitRenewalPeriod = sdk.RateLimit_RateLimitRenewalPeriod +) + +const ( + ListMcpServicesRequest_View_Unspecified = sdk.ListMcpServicesRequest_View_Unspecified + ListMcpServicesRequest_View_Full = sdk.ListMcpServicesRequest_View_Full + ListMcpServicesRequest_View_Basic = sdk.ListMcpServicesRequest_View_Basic + ListModelProviderServicesRequest_View_Unspecified = sdk.ListModelProviderServicesRequest_View_Unspecified + ListModelProviderServicesRequest_View_Full = sdk.ListModelProviderServicesRequest_View_Full + ListModelProviderServicesRequest_View_Basic = sdk.ListModelProviderServicesRequest_View_Basic + ListModelServicesRequest_View_Unspecified = sdk.ListModelServicesRequest_View_Unspecified + ListModelServicesRequest_View_Full = sdk.ListModelServicesRequest_View_Full + ListModelServicesRequest_View_Basic = sdk.ListModelServicesRequest_View_Basic + ModelProviderServiceConfig_ExternalModelProviderType_Unspecified = sdk.ModelProviderServiceConfig_ExternalModelProviderType_Unspecified + ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeOpenai = sdk.ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeOpenai + ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeAzureOpenai = sdk.ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeAzureOpenai + ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeAnthropic = sdk.ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeAnthropic + ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeAmazonBedrock = sdk.ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeAmazonBedrock + ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeCustom = sdk.ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeCustom + ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeMicrosoftFoundry = sdk.ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeMicrosoftFoundry + ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeGeminiEnterprise = sdk.ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeGeminiEnterprise + ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeBedrockMantle = sdk.ModelProviderServiceConfig_ExternalModelProviderType_ExternalModelProviderTypeBedrockMantle + ModelServiceConfig_DestinationConfig_DestinationType_Unspecified = sdk.ModelServiceConfig_DestinationConfig_DestinationType_Unspecified + ModelServiceConfig_DestinationConfig_DestinationType_DestinationTypePayPerTokenFoundationModel = sdk.ModelServiceConfig_DestinationConfig_DestinationType_DestinationTypePayPerTokenFoundationModel + ModelServiceConfig_DestinationConfig_DestinationType_DestinationTypeProvisionedThroughputFoundationModel = sdk.ModelServiceConfig_DestinationConfig_DestinationType_DestinationTypeProvisionedThroughputFoundationModel + ModelServiceConfig_DestinationConfig_DestinationType_DestinationTypeExternalFoundationModel = sdk.ModelServiceConfig_DestinationConfig_DestinationType_DestinationTypeExternalFoundationModel + ProvisioningInfo_State_Unspecified = sdk.ProvisioningInfo_State_Unspecified + ProvisioningInfo_State_Provisioning = sdk.ProvisioningInfo_State_Provisioning + ProvisioningInfo_State_Active = sdk.ProvisioningInfo_State_Active + ProvisioningInfo_State_Failed = sdk.ProvisioningInfo_State_Failed + ProvisioningInfo_State_Deleting = sdk.ProvisioningInfo_State_Deleting + ProvisioningInfo_State_Updating = sdk.ProvisioningInfo_State_Updating + ProvisioningInfo_State_Degraded = sdk.ProvisioningInfo_State_Degraded + RateLimit_RateLimitKey_Unspecified = sdk.RateLimit_RateLimitKey_Unspecified + RateLimit_RateLimitKey_RateLimitKeyUser = sdk.RateLimit_RateLimitKey_RateLimitKeyUser + RateLimit_RateLimitKey_RateLimitKeyUserGroup = sdk.RateLimit_RateLimitKey_RateLimitKeyUserGroup + RateLimit_RateLimitKey_RateLimitKeyServicePrincipal = sdk.RateLimit_RateLimitKey_RateLimitKeyServicePrincipal + RateLimit_RateLimitKey_RateLimitKeyService = sdk.RateLimit_RateLimitKey_RateLimitKeyService + RateLimit_RateLimitKey_RateLimitKeyUserDefault = sdk.RateLimit_RateLimitKey_RateLimitKeyUserDefault + RateLimit_RateLimitRenewalPeriod_Unspecified = sdk.RateLimit_RateLimitRenewalPeriod_Unspecified + RateLimit_RateLimitRenewalPeriod_RateLimitRenewalPeriodMinute = sdk.RateLimit_RateLimitRenewalPeriod_RateLimitRenewalPeriodMinute + RateLimit_RateLimitRenewalPeriod_RateLimitRenewalPeriodHour = sdk.RateLimit_RateLimitRenewalPeriod_RateLimitRenewalPeriodHour +) + +// Request to create a new MCP service.. +type CreateMcpServiceRequest struct { + // The MCP service to create. Do not set `name`; the server derives it from + // `parent` and `mcp_service_id`. `source_connection` is required. + McpService *McpService `json:"mcp_service,omitempty"` + // Name for the MCP service, e.g. "my_mcp_service". + McpServiceId *string `json:"mcp_service_id,omitempty"` + // Name of the parent schema. Format: `schemas/{catalog}.{schema}`. Each `{...}` + // component is capped at 255 characters individually. + Parent *string `json:"parent,omitempty"` +} + +// Request to log the caller in to an MCP service: create their user credential, +// or re-authenticate it if one already exists.. +type CreateMcpServiceUserMappedCredentialRequest struct { + Login *McpServiceUserMappedCredentialLogin `json:"login,omitempty"` + // Resource name of the MCP service. Format: + // `mcp-services/{catalog}.{schema}.{mcp_service}`. + Name *string `json:"name,omitempty"` +} + +// Request to create a new model provider service.. +type CreateModelProviderServiceRequest struct { + // The model provider service to create. Do not set `name`; the server derives + // it from `parent` and `model_provider_service_id`. + ModelProviderService *ModelProviderService `json:"model_provider_service,omitempty"` + // Name for the model provider service, e.g. "openai_prod". + ModelProviderServiceId *string `json:"model_provider_service_id,omitempty"` + // Name of the parent schema. Format: `schemas/{catalog}.{schema}`. Each `{...}` + // component is capped at 255 characters individually. + Parent *string `json:"parent,omitempty"` +} + +// Request to create a new model service.. +type CreateModelServiceRequest struct { + // The model service to create. Do not set `name`; the server derives it from + // `parent` and `model_service_id`. + ModelService *ModelService `json:"model_service,omitempty"` + // Name for the model service, e.g. "my_model_service". + ModelServiceId *string `json:"model_service_id,omitempty"` + // Name of the parent schema. Format: `schemas/{catalog}.{schema}`. Each `{...}` + // component is capped at 255 characters individually. + Parent *string `json:"parent,omitempty"` +} + +// Request to create a new skill.. +type CreateSkillRequest struct { + // Name of the parent schema. Format: `schemas/{catalog}.{schema}`. Each `{...}` + // component is capped at 255 characters individually. + Parent *string `json:"parent,omitempty"` + // The skill to create. `comment` is the only accepted client input and may be + // omitted. Do not set `name`; the server derives it from `parent` and + // `skill_id`. + Skill *Skill `json:"skill,omitempty"` + // Name for the skill, e.g. "basic-math". The server normalizes this identifier + // to lowercase. It is independent of the bundle name read from SKILL.md. + SkillId *string `json:"skill_id,omitempty"` +} + +// Request to delete an MCP service.. +type DeleteMcpServiceRequest struct { + // Optimistic concurrency token from the most recent read. When set, the delete + // succeeds only if the resource has not changed. Leave unset for an + // unconditional delete. For REST requests, URL-encode the base64 string + // returned by the API when setting the `etag` query parameter. + Etag []byte `json:"etag,omitempty"` + // Resource name of the MCP service. Format: + // `mcp-services/{catalog}.{schema}.{mcp_service}`. Each `{...}` component is + // capped at 255 characters individually. + Name *string `json:"name,omitempty"` +} + +// Request to delete a model provider service.. +type DeleteModelProviderServiceRequest struct { + // Optimistic concurrency token from the most recent read. When set, the delete + // succeeds only if the resource has not changed. Leave unset for an + // unconditional delete. For REST requests, URL-encode the base64 string + // returned by the API when setting the `etag` query parameter. + Etag []byte `json:"etag,omitempty"` + // Resource name of the model provider service. Format: + // `model-provider-services/{catalog}.{schema}.{model_provider_service}`. Each + // `{...}` component is capped at 255 characters individually. + Name *string `json:"name,omitempty"` +} + +// Request to delete a model service.. +type DeleteModelServiceRequest struct { + // Optimistic concurrency token from the most recent read. When set, the delete + // succeeds only if the resource has not changed. Leave unset for an + // unconditional delete. For REST requests, URL-encode the base64 string + // returned by the API when setting the `etag` query parameter. + Etag []byte `json:"etag,omitempty"` + // Resource name of the model service. Format: + // `model-services/{catalog}.{schema}.{model_service}`. Each `{...}` component + // is capped at 255 characters individually. + Name *string `json:"name,omitempty"` +} + +// Request to delete a skill.. +type DeleteSkillRequest struct { + // Optimistic concurrency token from the most recent read. When set, the delete + // succeeds only if the resource has not changed. Leave unset for an + // unconditional delete. For REST requests, URL-encode the base64 string + // returned by the API when setting the `etag` query parameter. + Etag []byte `json:"etag,omitempty"` + // Full resource name of the skill. Format: `skills/{catalog}.{schema}.{skill}`. + // Each `{...}` component is capped at 255 characters individually. + Name *string `json:"name,omitempty"` +} + +// Configuration for logging request and response payloads to a Unity Catalog +// inference table. When this configuration is present, payload logging is +// enabled by default.. +type InferenceTableConfig struct { + // Whether the referenced inference table has been deleted. The configuration + // remains visible so you can identify the broken dependency. Payload logging + // cannot continue until the table is restored or the configuration is updated. + IsDeleted *bool `json:"is_deleted,omitempty"` + // Parent Unity Catalog schema where the inference table is created, in the form + // `schemas/{catalog}.{schema}`. Required when configuring an inference table. + // After the inference table is created, this field cannot be changed. + Parent *string `json:"parent,omitempty"` + // Resolved UC table for payload logs. Format: + // `tables/{catalog}.{schema}.{table}`. + Table *string `json:"table,omitempty"` + // Prefix used to form the inference table's registered name. AI Gateway appends + // `_payload`; for example, `table_name_prefix = "orders"` creates + // `orders_payload`. If unset, the prefix defaults to the service name. Read + // `table` from the response for the resulting resource name. After the + // inference table is created, this field cannot be changed. + TableNamePrefix *string `json:"table_name_prefix,omitempty"` +} + +// Request to list MCP services. Accepts `parent`, `page_size`, `page_token`, +// and `view`.. +type ListMcpServicesRequest struct { + // Maximum number of MCP services to return. Defaults to 100 when unset or 0; + // the maximum is 200. Use `page_token` to retrieve additional pages. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token from the previous response. + PageToken *string `json:"page_token,omitempty"` + // Parent schema to list within, in the form `schemas/{catalog}.{schema}`. + // Required. Each `{...}` component is capped at 255 characters individually. + Parent *string `json:"parent,omitempty"` + // Fields to return for each service. `FULL` includes source-connection details + // and rate-limit principal names. `BASIC` omits the source connection and omits + // principal names from rate limits. Defaults to `BASIC` when unset. + View ListMcpServicesRequest_View `json:"view,omitempty"` +} + +// Response for listing MCP services.. +type ListMcpServicesResponse struct { + // The list of MCP services. + McpServices []McpService `json:"mcp_services,omitempty"` + // Pagination token for retrieving the next page. Empty when there are no more + // results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to list model provider services. Accepts `parent`, `page_size`, +// `page_token`, and `view`.. +type ListModelProviderServicesRequest struct { + // Maximum number of provider services to return. Defaults to 100 when unset or + // 0; the maximum is 200. Use `page_token` to retrieve additional pages. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token from the previous response. + PageToken *string `json:"page_token,omitempty"` + // Parent schema to list within, in the form `schemas/{catalog}.{schema}`. + // Required. Each `{...}` component is capped at 255 characters individually. + Parent *string `json:"parent,omitempty"` + // Fields to return for each service. `FULL` includes resolved + // service-credential and inference-table details and rate-limit principal + // names. `BASIC` omits those details and principal names from rate limits. + // Defaults to `BASIC` when unset. + View ListModelProviderServicesRequest_View `json:"view,omitempty"` +} + +// Response for listing model provider services.. +type ListModelProviderServicesResponse struct { + // The list of model provider services. + ModelProviderServices []ModelProviderService `json:"model_provider_services,omitempty"` + // Pagination token for retrieving the next page. Empty when there are no more + // results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to list model services.. +type ListModelServicesRequest struct { + // Maximum number of model services to return. Defaults to 100 when unset or 0; + // the maximum is 200. Use `page_token` to retrieve additional pages. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token from the previous response. + PageToken *string `json:"page_token,omitempty"` + // Parent schema to list within, in the form `schemas/{catalog}.{schema}`. + // Required. Each `{...}` component is capped at 255 characters individually. + Parent *string `json:"parent,omitempty"` + // Fields to return for each service. `FULL` includes destinations, + // inference-table details, and rate-limit principal names. `BASIC` omits + // destinations and inference-table details and omits principal names from rate + // limits. Defaults to `BASIC` when unset. + View ListModelServicesRequest_View `json:"view,omitempty"` +} + +// Response for listing model services.. +type ListModelServicesResponse struct { + // The list of model services. + ModelServices []ModelService `json:"model_services,omitempty"` + // Pagination token for retrieving the next page. Empty when there are no more + // results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to list skills. Accepts `parent`, `page_size`, and `page_token`. v1 +// supports schema-level listing only.. +type ListSkillsRequest struct { + // Maximum number of skills to return. Defaults to 100 when unset or 0; the + // maximum is 200. Use `page_token` to retrieve additional pages. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token from a previous request. + PageToken *string `json:"page_token,omitempty"` + // Name of the parent schema. Format: `schemas/{catalog}.{schema}`. Each `{...}` + // component is capped at 255 characters individually. Required: skill listing + // is schema-scoped, so `parent` must be set; an unset or empty `parent` is + // rejected with INVALID_PARAMETER_VALUE. + Parent *string `json:"parent,omitempty"` +} + +// Response for listing skills.. +type ListSkillsResponse struct { + // Pagination token for retrieving the next page of results. + NextPageToken *string `json:"next_page_token,omitempty"` + // The list of skills. + Skills []Skill `json:"skills,omitempty"` +} + +// A Unity Catalog securable that registers an MCP server through a Unity +// Catalog connection and exposes its tools for discovery, authorization, and +// invocation.. +type McpService struct { + // User-provided description. + Comment *string `json:"comment,omitempty"` + // Connection, tool selectors, and rate limits. Required on Create. On Update, + // provide this field when `update_mask` contains `config` or one of its + // subpaths. + Config *McpServiceConfig `json:"config,omitempty"` + // Time the MCP service was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Creator identity. + CreatedBy *string `json:"created_by,omitempty"` + // Owner of the MCP service. + EffectiveOwner *string `json:"effective_owner,omitempty"` + // Optimistic concurrency token returned on every read. To make an Update or + // Delete conditional, pass the last-read value in that request's `etag` field. + // In REST responses, this value is a base64 string; URL-encode it when setting + // the `etag` query parameter. + Etag []byte `json:"etag,omitempty"` + // Metastore hosting the MCP service. + MetastoreId *string `json:"metastore_id,omitempty"` + // Resource name of the MCP service. Format: + // `mcp-services/{catalog}.{schema}.{mcp_service}`. Each `{...}` component is + // capped at 255 characters individually. Server-derived on Create from `parent` + // + `mcp_service_id`; required and immutable on Update/Get/Delete. + Name *string `json:"name,omitempty"` + // Time the MCP service was last modified. + UpdateTime *types.Time `json:"update_time,omitempty"` + // Identity of the last updater. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// Operational configuration for an MCP service. Groups the source reference, +// tool selectors, and rate limits -- the fields that configure how the MCP +// service behaves at invocation time.. +type McpServiceConfig struct { + // Tool names or prefix patterns to expose from the MCP server. Use exact tool + // names or prefix patterns such as `read_*`. An empty list exposes all tools. + // At most 1,024 selectors are allowed, and each selector can contain at most + // 256 characters. + IncludeToolSelectors []string `json:"include_tool_selectors,omitempty"` + // Rate limits for tool invocations. Supported scopes are user, group, service + // principal, the service as a whole, and each user by default. Request and + // token limits are supported. Empty when no rate limit is configured. + RateLimits []RateLimit `json:"rate_limits,omitempty"` + SourceConnection *McpServiceConfig_SourceConnection `json:"source_connection,omitempty"` +} + +// Unity Catalog connection that points to the MCP server. On Create, provide +// `name` in the schema-scoped form +// `connections/{catalog}.{schema}.{connection}`. On read, the service populates +// the resolved connection metadata. If the connection is deleted, its reference +// remains visible so you can identify the broken dependency.. +type McpServiceConfig_SourceConnection struct { + // Whether the referenced connection has been deleted. The MCP service keeps the + // reference so callers can identify the broken dependency; tool invocation + // fails until the source connection is updated. + IsDeleted *bool `json:"is_deleted,omitempty"` + // Resource name of the Unity Catalog connection used to access the MCP server, + // in the form `connections/{catalog}.{schema}.{connection}`. + Name *string `json:"name,omitempty"` + // Options needed to build the U2M authorize request, returned as a flat map. + // When set, it includes: `authorization_endpoint` (OAuth authorize URL), + // `token_endpoint` (token-exchange URL), `oauth_scope` (space-separated scopes + // to request), `client_id` (OAuth client id), and `oauth_provider` (the OAuth + // provider). + Options map[string]string `json:"options,omitempty"` +} + +// A caller's per-user OAuth credential for an MCP service.. +type McpServiceUserMappedCredential struct { + // Token-expiry info for the credential, returned as a flat map: + // `access_token_expiration` (always set) and `refresh_token_expiration` (set + // when the credential has a refresh token). Both values are timestamps. + Options map[string]string `json:"options,omitempty"` + // Provisioning state of the credential. `ACTIVE` means the caller is logged in + // and the credential is usable; any other state means the login has not + // completed. + ProvisioningInfo *ProvisioningInfo `json:"provisioning_info,omitempty"` +} + +// Login input for an MCP service user credential. Carries the OAuth exchange +// fields as a flat map.. +type McpServiceUserMappedCredentialLogin struct { + // OAuth exchange fields: `pkce_verifier`, `authorization_code`, and + // `oauth_redirect_uri`. + Options map[string]string `json:"options,omitempty"` +} + +// A Unity Catalog securable that stores authentication and request +// configuration for an external model provider, such as OpenAI, Azure OpenAI, +// or Amazon Bedrock. Model service destinations reference it to send requests +// to that provider. +// +// A model provider service can be referenced by multiple model services. A +// model service can route across multiple model provider services for traffic +// splitting or failover.. +type ModelProviderService struct { + // User-provided description. + Comment *string `json:"comment,omitempty"` + // Provider authentication, exposed models, request-forwarding controls, rate + // limits, and payload logging. Required on Create. On Update, it is required + // only when `config` or one of its subpaths appears in `update_mask`. + Config *ModelProviderServiceConfig `json:"config,omitempty"` + // Time the provider service was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Creator identity. + CreatedBy *string `json:"created_by,omitempty"` + // Owner of the model provider service. + EffectiveOwner *string `json:"effective_owner,omitempty"` + // Optimistic concurrency token returned on every read. To make an Update or + // Delete conditional, pass the last-read value in that request's `etag` field. + // In REST responses, this value is a base64 string; URL-encode it when setting + // the `etag` query parameter. + Etag []byte `json:"etag,omitempty"` + // Metastore hosting the provider service. + MetastoreId *string `json:"metastore_id,omitempty"` + // Resource name of the provider service. Format: + // `model-provider-services/{catalog}.{schema}.{model_provider_service}`. Each + // `{...}` component is capped at 255 characters individually. Server-derived on + // Create from `parent` + `model_provider_service_id`; required and immutable on + // Update/Get/Delete. + Name *string `json:"name,omitempty"` + // Time the provider service was last modified. + UpdateTime *types.Time `json:"update_time,omitempty"` + // Identity of the last updater. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// Behavioral configuration for a ModelProviderService: provider authentication +// and provider-specific fields, the catalog of models this provider service can +// route to, and the passthrough policy that governs how request headers, query +// parameters, and unmanaged subpaths cross the trust boundary to the upstream +// provider.. +type ModelProviderServiceConfig struct { + // When true, accepts any model exposed by the upstream provider; `targets` is + // not required and does not restrict routability. When false, only models + // listed in `targets` are routable. Defaults to false. + AllowAllTargets *bool `json:"allow_all_targets,omitempty"` + AmazonBedrock *ModelProviderServiceConfig_AmazonBedrockProviderConfig `json:"amazon_bedrock,omitempty"` + Anthropic *ModelProviderServiceConfig_AnthropicProviderConfig `json:"anthropic,omitempty"` + AzureOpenai *ModelProviderServiceConfig_AzureOpenAiProviderConfig `json:"azure_openai,omitempty"` + BedrockMantle *ModelProviderServiceConfig_AmazonBedrockProviderConfig `json:"bedrock_mantle,omitempty"` + Custom *ModelProviderServiceConfig_CustomProviderConfig `json:"custom,omitempty"` + // Whether to forward incoming HTTP headers to the upstream provider. Defaults + // to false and is configured for the entire provider service, not per request. + // Upstream authentication is configured separately in the provider-specific + // configuration. + ForwardHeaders *bool `json:"forward_headers,omitempty"` + // Whether to forward incoming query parameters to the upstream provider. + // Defaults to false and is configured for the entire provider service, not per + // request. + ForwardQueryParameters *bool `json:"forward_query_parameters,omitempty"` + // Whether to proxy paths that AI Gateway does not recognize as configured + // provider-native API types. Defaults to false. When true, these paths are + // forwarded unchanged to the upstream provider. When false, only recognized API + // paths are served. Enabling this broadens the upstream API surface exposed + // through the provider service. AI Gateway cannot evaluate Service Policies on + // opaque unmanaged requests, so unmanaged requests are rejected whenever + // Service Policies are attached to this securable. + ForwardUnmanagedPaths *bool `json:"forward_unmanaged_paths,omitempty"` + GeminiEnterprise *ModelProviderServiceConfig_GeminiEnterpriseProviderConfig `json:"gemini_enterprise,omitempty"` + // Payload logging configuration for requests sent directly to this provider + // service. Requests routed through a model service are captured by that model + // service's inference table instead. + InferenceTable *InferenceTableConfig `json:"inference_table,omitempty"` + MicrosoftFoundry *ModelProviderServiceConfig_MicrosoftFoundryProviderConfig `json:"microsoft_foundry,omitempty"` + Openai *ModelProviderServiceConfig_OpenAiProviderConfig `json:"openai,omitempty"` + // Pricing configuration for this provider service. An explicitly empty + // configuration is retained on Create and Update and applies no adjustment. + Pricing *ModelProviderServiceConfig_ProviderPricingConfig `json:"pricing,omitempty"` + // External model provider. Required on Create and immutable thereafter. Set the + // matching provider-specific configuration, such as `openai`, `azure_openai`, + // or `amazon_bedrock`. + ProviderType ModelProviderServiceConfig_ExternalModelProviderType `json:"provider_type,omitempty"` + // Rate limits for requests sent directly to this provider service. Requests + // routed through a model service use that model service's rate limits instead. + RateLimits []RateLimit `json:"rate_limits,omitempty"` + // Models and provider-native API types exposed by this provider service. Each + // entry must include at least one `native_api_types` value. When + // `allow_all_targets` is false, at least one entry is required and model + // service destinations can reference only listed models. When + // `allow_all_targets` is true, any upstream model is routable; entries in this + // list provide API-type metadata without restricting other models. + Targets []ModelProviderServiceConfig_ModelTargetConfig `json:"targets,omitempty"` +} + +// Amazon Bedrock provider configuration.. +type ModelProviderServiceConfig_AmazonBedrockProviderConfig struct { + Direct *ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig `json:"direct,omitempty"` +} + +// Direct form of Amazon Bedrock provider config. +// +// Authentication is one of two mutually exclusive modes, exactly one of which +// must be supplied on Create: - Access keys: set `aws_access_key`, leave +// `service_credential` unset. - Unity Catalog service credential: set +// `service_credential.name` to the resource name `credentials/{name}`, leave +// `aws_access_key` unset. The credential value lives in Unity Catalog and is +// referenced by name, not held on this message. Setting more than one mode is +// rejected.. +type ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig struct { + AwsAccessKey *ModelProviderServiceConfig_AwsAccessKey `json:"aws_access_key,omitempty"` + // AWS region where the Bedrock endpoint is hosted (e.g., `us-east-1`). Required + // on Create. + Region *string `json:"region,omitempty"` + ServiceCredential *ModelProviderServiceConfig_ServiceCredential `json:"service_credential,omitempty"` +} + +// Anthropic provider configuration. Exactly one of `direct` or `relayed` must +// be set on Create; the two are mutually exclusive.. +type ModelProviderServiceConfig_AnthropicProviderConfig struct { + Direct *ModelProviderServiceConfig_AnthropicProviderDirectConfig `json:"direct,omitempty"` + Relayed *ModelProviderServiceConfig_AnthropicProviderRelayedConfig `json:"relayed,omitempty"` +} + +// Direct form of Anthropic provider config.. +type ModelProviderServiceConfig_AnthropicProviderDirectConfig struct { + ApiKey *ModelProviderServiceConfig_ProviderSecret `json:"api_key,omitempty"` +} + +// Relayed Anthropic provider configuration. Each inference request supplies the +// caller's OAuth token, which is forwarded to Anthropic. No Anthropic +// credential is stored.. +type ModelProviderServiceConfig_AnthropicProviderRelayedConfig struct { +} + +// AWS access-key-pair auth for Amazon Bedrock: a SigV4-signing key pair.. +type ModelProviderServiceConfig_AwsAccessKey struct { + // AWS access key ID. Required on Create when using access-key auth. Treated as + // username-equivalent (not a secret value): round-trips on reads and is + // scrubbed from audit logs. + AccessKeyId *string `json:"access_key_id,omitempty"` + // AWS secret access key paired with `access_key_id`. Required when creating a + // service with access-key authentication. Supply the value in + // `secret_access_key.plaintext`. + SecretAccessKey *ModelProviderServiceConfig_ProviderSecret `json:"secret_access_key,omitempty"` +} + +// Azure OpenAI provider configuration.. +type ModelProviderServiceConfig_AzureOpenAiProviderConfig struct { + Direct *ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig `json:"direct,omitempty"` +} + +// Direct form of Azure OpenAI provider config. Exactly one of three +// mutually-exclusive auth modes must be supplied on Create: - API key: set +// `api_key`, leave `entra_service_principal` and `service_credential` unset. - +// Entra ID (service principal): set `entra_service_principal`, leave `api_key` +// and `service_credential` unset. - Unity Catalog service credential: set +// `service_credential.name` to the resource name `credentials/{name}`, leave +// `api_key` and `entra_service_principal` unset. The credential value lives in +// Unity Catalog and is referenced by name, not held on this message. Only +// supported on Azure-hosted workspaces. Setting more than one mode is rejected.. +type ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig struct { + ApiKey *ModelProviderServiceConfig_ProviderSecret `json:"api_key,omitempty"` + // Full Azure OpenAI endpoint base URL, e.g. + // `https://myresource.openai.azure.com`. Required on Create. + BaseUrl *string `json:"base_url,omitempty"` + EntraServicePrincipal *ModelProviderServiceConfig_EntraServicePrincipal `json:"entra_service_principal,omitempty"` + ServiceCredential *ModelProviderServiceConfig_ServiceCredential `json:"service_credential,omitempty"` +} + +// Header-based API-key authentication for a custom provider: the secret is +// forwarded on outbound requests under a caller-chosen HTTP header, as +// `: `.. +type ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuth struct { + // HTTP header name that carries the API key on outbound requests (e.g., + // `Ocp-Apim-Subscription-Key`). The value forwarded under this header is + // supplied via `api_key_value`. + ApiKeyName *string `json:"api_key_name,omitempty"` + // Secret value forwarded under the `api_key_name` header on outbound requests. + // Supplied as inline plaintext via `ProviderSecret.plaintext`. + ApiKeyValue *ModelProviderServiceConfig_ProviderSecret `json:"api_key_value,omitempty"` +} + +// Custom OpenAI-compatible provider configuration with bearer-token +// authentication.. +type ModelProviderServiceConfig_CustomProviderConfig struct { + Direct *ModelProviderServiceConfig_CustomProviderDirectConfig `json:"direct,omitempty"` +} + +// Direct form of a custom provider configuration. Set `api_key` to send the +// secret as an `Authorization` bearer token, or `header_auth` to forward it +// under a caller-chosen HTTP header.. +type ModelProviderServiceConfig_CustomProviderDirectConfig struct { + ApiKey *ModelProviderServiceConfig_ProviderSecret `json:"api_key,omitempty"` + // Endpoint URL of the OpenAI-compatible service (e.g., + // `https://api.example.com/v1`). Required on Create. + BaseUrl *string `json:"base_url,omitempty"` + HeaderAuth *ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuth `json:"header_auth,omitempty"` +} + +// Entra ID (Azure AD) service-principal authentication. The `tenant_id` and +// `client_id` identify the service principal, and `client_secret` authenticates +// it. AI Gateway exchanges these credentials for an Entra bearer token for +// requests to Azure OpenAI or Microsoft Foundry.. +type ModelProviderServiceConfig_EntraServicePrincipal struct { + // Entra ID client (application) ID. Required on Create. + ClientId *string `json:"client_id,omitempty"` + ClientSecret *ModelProviderServiceConfig_ProviderSecret `json:"client_secret,omitempty"` + // Entra ID (Azure AD) tenant ID. Required on Create. + TenantId *string `json:"tenant_id,omitempty"` +} + +// Gemini Enterprise provider configuration.. +type ModelProviderServiceConfig_GeminiEnterpriseProviderConfig struct { + Direct *ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig `json:"direct,omitempty"` +} + +// Direct Gemini Enterprise provider configuration. An API key is required when +// creating the service.. +type ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig struct { + ApiKey *ModelProviderServiceConfig_ProviderSecret `json:"api_key,omitempty"` + // GCP project ID hosting the Gemini Enterprise endpoint. Required on Create. + ProjectId *string `json:"project_id,omitempty"` + // GCP region of the Gemini Enterprise endpoint (e.g., `us-central1`). Required + // on Create. + Region *string `json:"region,omitempty"` + ServiceCredential *ModelProviderServiceConfig_ServiceCredential `json:"service_credential,omitempty"` +} + +// Microsoft Foundry provider configuration.. +type ModelProviderServiceConfig_MicrosoftFoundryProviderConfig struct { + Direct *ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig `json:"direct,omitempty"` +} + +// Direct form of Microsoft Foundry provider config. +// +// Authentication is one of three mutually exclusive modes, exactly one of which +// must be supplied on Create: - API key: set `api_key`, leave +// `entra_service_principal` and `service_credential` unset. - Entra ID (service +// principal): set `entra_service_principal`, leave `api_key` and +// `service_credential` unset. AI Gateway exchanges these for an Entra bearer +// token on outbound requests via the OAuth2 client-credentials grant. - Unity +// Catalog service credential: set `service_credential.name` to the resource +// name `credentials/{name}`, leave `api_key` and `entra_service_principal` +// unset. The credential value lives in Unity Catalog and is referenced by name, +// not held on this message. Only supported on Azure-hosted workspaces. Setting +// more than one mode is rejected.. +type ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig struct { + ApiKey *ModelProviderServiceConfig_ProviderSecret `json:"api_key,omitempty"` + // Microsoft Foundry endpoint URL. Required on Create. + BaseUrl *string `json:"base_url,omitempty"` + EntraServicePrincipal *ModelProviderServiceConfig_EntraServicePrincipal `json:"entra_service_principal,omitempty"` + ServiceCredential *ModelProviderServiceConfig_ServiceCredential `json:"service_credential,omitempty"` +} + +// Model target configuration shared by model provider service targets and +// external model destinations on model services.. +type ModelProviderServiceConfig_ModelTargetConfig struct { + // Relative path appended to a custom provider's `base_url` for this model, such + // as `serve/openai/chat`. Nonempty values are only supported for custom model + // provider service targets; other provider types reject them. Model service + // destinations do not support this field. Do not include URI templates, + // queries, or fragments. When empty, `base_url` is used unchanged. + EndpointRoute *string `json:"endpoint_route,omitempty"` + // Provider-side model identifier, such as `gpt-5` or `claude-opus-4-7`. This + // identifies a model at the upstream provider; it is not a Unity Catalog model + // resource. + Model *string `json:"model,omitempty"` + // Provider-native API types supported by this model, such as + // `openai/v1/chat/completions`. A model provider service target requires at + // least one value. A model service destination may omit the list to use the + // matching provider service target's types when available. AI Gateway uses the + // selected types for translation. At most 64 entries of 256 characters each are + // allowed. + NativeApiTypes []string `json:"native_api_types,omitempty"` +} + +// OpenAI provider configuration.. +type ModelProviderServiceConfig_OpenAiProviderConfig struct { + Direct *ModelProviderServiceConfig_OpenAiProviderDirectConfig `json:"direct,omitempty"` +} + +// Direct (inline-credentials) form of the OpenAI provider config.. +type ModelProviderServiceConfig_OpenAiProviderDirectConfig struct { + ApiKey *ModelProviderServiceConfig_ProviderSecret `json:"api_key,omitempty"` + // Optional custom base URL. Defaults to `https://api.openai.com/v1`. Use for + // OpenAI-API-compatible third-party endpoints or in-network proxies. + BaseUrl *string `json:"base_url,omitempty"` + // Optional OpenAI organization ID. When set, the platform forwards it as the + // `OpenAI-Organization` header. + Organization *string `json:"organization,omitempty"` +} + +// Pricing adjustments applied to this provider service's external-model spend +// estimates.. +type ModelProviderServiceConfig_ProviderPricingConfig struct { + // Provider-wide adjustment to external-model spend estimates in basis points: + // 2000 = 20% off; -2000 = a 20% markup. Negative values have no lower bound + // beyond the int32 range. Values cannot exceed 10000 (100% off). An omitted + // value or zero leaves the estimate unchanged. + DefaultDiscountBasisPoints *int `json:"default_discount_basis_points,omitempty"` +} + +// A secret value supplied as part of an inline provider config. The caller +// supplies the value as inline `plaintext` on writes; the platform stores it +// encrypted. The `plaintext` field is `INPUT_ONLY` and never round-trips on +// reads.. +type ModelProviderServiceConfig_ProviderSecret struct { + Plaintext *string `json:"plaintext,omitempty"` + SecretReference *ModelProviderServiceConfig_SecretReference `json:"secret_reference,omitempty"` +} + +// Reference to a customer-owned UC Secret backing a secret-bearing provider +// field, in the `ProviderSecret.secret_reference` arm.. +type ModelProviderServiceConfig_SecretReference struct { + // Resource name of the bound UC Secret, in the form + // `secrets/{catalog}.{schema}.{secret}`. On Create the caller supplies the name + // here. On read it reflects the secret's current name at read time. + Name *string `json:"name,omitempty"` +} + +// The customer-owned Unity Catalog service credential a model provider service +// uses to authenticate to its provider, referenced by name.. +type ModelProviderServiceConfig_ServiceCredential struct { + // Resource name of the bound Unity Catalog service credential, in the form + // `credentials/{name}`. Supply this field when creating the service or + // rebinding its credential. On read, it reflects the credential's current name. + Name *string `json:"name,omitempty"` +} + +// A governed AI Gateway endpoint in Unity Catalog that routes inference +// requests to one or more destinations, such as a foundation model +// or an external model reached through a model provider service. Applies +// centralized access control, rate limits, and auditing to its traffic.. +type ModelService struct { + // User-provided description. + Comment *string `json:"comment,omitempty"` + // Destinations, routing, rate limits, and payload logging configuration. + // Required on Create. On Update, provide this field when `update_mask` contains + // `config` or one of its subpaths. + Config *ModelServiceConfig `json:"config,omitempty"` + // Time the model service was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Creator identity. + CreatedBy *string `json:"created_by,omitempty"` + // Owner of the model service. + EffectiveOwner *string `json:"effective_owner,omitempty"` + // Optimistic concurrency token returned on every read. To make an Update or + // Delete conditional, pass the last-read value in that request's `etag` field. + // In REST responses, this value is a base64 string; URL-encode it when setting + // the `etag` query parameter. + Etag []byte `json:"etag,omitempty"` + // Metastore hosting the model service. + MetastoreId *string `json:"metastore_id,omitempty"` + // Resource name of the model service. Format: + // `model-services/{catalog}.{schema}.{model_service}`. Each `{...}` component + // is capped at 255 characters individually. Server-derived on Create from + // `parent` + `model_service_id`; required and immutable on Update/Get/Delete. + Name *string `json:"name,omitempty"` + // API types supported across this service's destinations, such as + // `openai/v1/chat/completions`, `openai/v1/embeddings`, and + // `mlflow/v1/chat/completions`. Derived from the backing models and providers + // at read time. + SupportedApiTypes []string `json:"supported_api_types,omitempty"` + // Time the model service was last modified. + UpdateTime *types.Time `json:"update_time,omitempty"` + // Identity of the last updater. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// Operational configuration wrapped around the ModelService resource.. +type ModelServiceConfig struct { + // Inference table configuration for payload logging. + InferenceTable *InferenceTableConfig `json:"inference_table,omitempty"` + // Rate limits applied to requests routed through this model service. + RateLimits []RateLimit `json:"rate_limits,omitempty"` + // Routing configuration: destinations and fallback. + Routing *ModelServiceConfig_RoutingConfig `json:"routing,omitempty"` +} + +// A destination the model service can route traffic to. Exactly one of the +// per-type configs inside `type_config` must be set, and it must match +// `destination_type`.. +type ModelServiceConfig_DestinationConfig struct { + // Backing-model category. Provide the matching type-specific configuration and + // leave the other type-specific configurations unset. + DestinationType ModelServiceConfig_DestinationConfig_DestinationType `json:"destination_type,omitempty"` + ExternalModelConfig *ModelServiceConfig_ExternalModelConfig `json:"external_model_config,omitempty"` + // Whether the destination's backing model or model provider service has been + // deleted. The destination remains visible so you can identify the broken + // dependency. Requests cannot use this destination until the backing resource + // is restored or the destination is replaced. + IsDeleted *bool `json:"is_deleted,omitempty"` + // User-facing label for this destination, used in routing references. + Name *string `json:"name,omitempty"` + PayPerTokenConfig *ModelServiceConfig_PayPerTokenConfig `json:"pay_per_token_config,omitempty"` + ProvisionedThroughputConfig *ModelServiceConfig_ProvisionedThroughputConfig `json:"provisioned_throughput_config,omitempty"` + // Percentage of primary traffic sent to this destination, from 0 to 100. + // Required when there is more than one primary destination, in which case the + // primary percentages must sum to 100; a single primary destination receives + // all traffic. Fallback destinations are ordered and do not use this field. + TrafficPercentage *int `json:"traffic_percentage,omitempty"` +} + +// Configuration for an external-foundation-model destination. Provider auth and +// provider-specific cloud configuration are owned by a separate, governed +// ModelProviderService entity referenced via `model_provider_service`; the +// platform resolves the provider at invocation time.. +type ModelServiceConfig_ExternalModelConfig struct { + // Resource name of the governed ModelProviderService that owns provider auth + // and provider-specific configuration. The referenced ModelProviderService also + // carries the provider type, so this message does not surface it directly. + // Format: + // `model-provider-services/{catalog}.{schema}.{model_provider_service}`. Each + // `{...}` component is capped at 255 characters individually. + ModelProviderService *string `json:"model_provider_service,omitempty"` + // Routing target for the destination: the provider-side model selected from the + // referenced ModelProviderService's `targets` catalog, plus the unified API + // types the platform should translate to/from at request time. + Target *ModelProviderServiceConfig_ModelTargetConfig `json:"target,omitempty"` +} + +// Fallback routing applied after a primary destination fails. Fallback +// destinations are tried in the listed order.. +type ModelServiceConfig_FallbackConfig struct { + // Fallback destinations, tried in the listed order. At most 5 are allowed. + Destinations []ModelServiceConfig_DestinationConfig `json:"destinations,omitempty"` +} + +// Configuration for a pay-per-token foundation-model destination. Identifies +// the foundation model by its UC resource name; the platform resolves it to a +// Model Serving endpoint at request time.. +type ModelServiceConfig_PayPerTokenConfig struct { + // Resource name of the Unity Catalog model. Format: + // `models/{catalog}.{schema}.{model}`. + Model *string `json:"model,omitempty"` +} + +// Configuration for a provisioned-throughput foundation-model destination. +// References a pre-existing Model Serving endpoint that serves the model; +// sizing (provisioned throughput, burst scaling, model version) is owned by the +// Model Serving endpoint itself, not by this message.. +type ModelServiceConfig_ProvisionedThroughputConfig struct { + // UC model FQN of the model served by the backing endpoint (e.g., + // `system.ai.databricks-claude-opus-4-6`). Resolved from Model Serving at + // Create/Update time. + Model *string `json:"model,omitempty"` + // Name of the backing Model Serving endpoint serving the provisioned- + // throughput foundation model, in the form `serving-endpoints/{name}`. The same + // Unity Catalog model can be served on multiple Model Serving endpoints with + // different throughput, regions, or configurations. The caller selects the + // endpoint to which this destination routes. The endpoint must exist at create + // time. + ModelServingEndpoint *string `json:"model_serving_endpoint,omitempty"` +} + +// Routing configuration for a model service, nesting destinations and fallback +// under a single sub-message.. +type ModelServiceConfig_RoutingConfig struct { + // Primary routing destinations. At most 10 are allowed. At least one is + // required on Create. On Update, provide this list when replacing the full + // `config` or updating `config.routing.destinations`; other granular routing + // updates do not require resending destinations. The intermediate + // `config.routing` mask path is not supported. + Destinations []ModelServiceConfig_DestinationConfig `json:"destinations,omitempty"` + // Fallback routing applied after a primary destination fails. Fallback + // destinations are tried in the listed order. + Fallback *ModelServiceConfig_FallbackConfig `json:"fallback,omitempty"` +} + +// Status of an asynchronously provisioned resource.. +type ProvisioningInfo struct { + // The provisioning state of the resource. + State ProvisioningInfo_State `json:"state,omitempty"` +} + +// A rate limit applied to service requests. Leave `requests` or `tokens` unset +// to impose no limit on that dimension; set a value to cap that dimension +// within the renewal period.. +type RateLimit struct { + // Scope of the rate limit. Depending on this value, the limit applies to a + // principal, the service as a whole, or each user by default. + Key RateLimit_RateLimitKey `json:"key,omitempty"` + // Principal this limit applies to: user email, group name, or service principal + // application ID. Required when `key` applies to a user, group, or service + // principal; otherwise it must be unset. + Principal *string `json:"principal,omitempty"` + // Renewal period. + RenewalPeriod RateLimit_RateLimitRenewalPeriod `json:"renewal_period,omitempty"` + // Maximum requests allowed in one renewal period. Leave unset for no request + // limit. Set to `0` to deny all requests. + Requests *int64 `json:"requests,omitempty"` + // Maximum tokens allowed in one renewal period. Leave unset for no token limit. + // Set to `0` to deny all requests. + Tokens *int64 `json:"tokens,omitempty"` +} + +// A Skill is an agentskills.io bundle registered in Unity Catalog. Clients +// transfer bundle bytes through the Files API. FinalizeSkill reads the uploaded +// SKILL.md and projects its frontmatter onto the Skill metadata.. +type Skill struct { + // Name from the most recently successfully finalized SKILL.md. It may differ + // from the final component of the Skill resource name. Unset until + // FinalizeSkill succeeds. + BundleName *string `json:"bundle_name,omitempty"` + // User-provided comment for the skill. Free-text, user-editable via UpdateSkill + // (listed in its `update_mask`). DISTINCT from `description`, which is the + // server-parsed, OUTPUT_ONLY SKILL.md frontmatter value: `comment` is the + // customer's own annotation and is preserved across bundle re-uploads. When + // `comment` is in the update mask, omitting it clears the field, while an + // explicitly empty string is retained. + Comment *string `json:"comment,omitempty"` + // Time the skill was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Creator identity. + CreatedBy *string `json:"created_by,omitempty"` + // Description from the most recently successfully finalized SKILL.md. Unset + // until FinalizeSkill succeeds. + Description *string `json:"description,omitempty"` + // Owner of the skill. + EffectiveOwner *string `json:"effective_owner,omitempty"` + // Optimistic concurrency token returned on every read. To make an Update or + // Delete conditional, pass the last-read value in that request's `etag` field. + // In REST responses, this value is a base64 string; URL-encode it when setting + // the `etag` query parameter. + Etag []byte `json:"etag,omitempty"` + // Time of the most recent successful FinalizeSkill. Unset until one succeeds. + FinalizeTime *types.Time `json:"finalize_time,omitempty"` + // Metastore hosting the skill. + MetastoreId *string `json:"metastore_id,omitempty"` + // Resource name of the skill. Format: `skills/{catalog}.{schema}.{skill}`. Each + // `{...}` component is capped at 255 characters individually. Server-derived on + // Create from `parent` + `skill_id`; required and immutable on + // Update/Get/Delete. + Name *string `json:"name,omitempty"` + // Time of the most recent Skill metadata mutation. Uploading bundle files alone + // does not change this value. + UpdateTime *types.Time `json:"update_time,omitempty"` + // Identity of the last updater. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// Request to update an MCP service. `name` cannot appear in `update_mask`.. +type UpdateMcpServiceRequest struct { + // Optimistic concurrency token from the most recent read. When set, the update + // succeeds only if the resource has not changed. Leave unset for an + // unconditional update. For REST requests, URL-encode the base64 string + // returned by the API when setting the `etag` query parameter. + Etag []byte `json:"etag,omitempty"` + // The MCP service with the updated field values. `name` identifies the resource + // (`mcp-services/{catalog}.{schema}.{mcp_service}`); only fields listed in + // `update_mask` are applied. + McpService *McpService `json:"mcp_service,omitempty"` + // Fields to update. Use `config` to replace the entire configuration. The + // replacement must include every required field; any optional field you omit is + // cleared. To preserve sibling fields, use one or more granular paths: + // `comment`, `config.source_connection.name`, `config.include_tool_selectors`, + // or `config.rate_limits`. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Request to update a model provider service. `name` and `config.provider_type` +// cannot appear in `update_mask`.. +type UpdateModelProviderServiceRequest struct { + // Optimistic concurrency token from the most recent read. When set, the update + // succeeds only if the resource has not changed. Leave unset for an + // unconditional update. For REST requests, URL-encode the base64 string + // returned by the API when setting the `etag` query parameter. + Etag []byte `json:"etag,omitempty"` + // The model provider service with the updated field values. `name` identifies + // the resource + // (`model-provider-services/{catalog}.{schema}.{model_provider_service}`); only + // fields listed in `update_mask` are applied. + ModelProviderService *ModelProviderService `json:"model_provider_service,omitempty"` + // Fields to update. Use `config` to replace the entire configuration. The + // replacement must include every required field; any optional field you omit is + // cleared. To preserve sibling fields, use one or more granular paths: + // `comment`; `config.provider` to replace the active provider-specific value + // (for example, `config.openai`; the mask path remains `config.provider`); + // `config.allow_all_targets`, `config.targets`, `config.forward_headers`, + // `config.forward_query_parameters`, `config.forward_unmanaged_paths`, + // `config.rate_limits`, `config.pricing.default_discount_basis_points`, or + // `config.inference_table`. For a pricing update, an explicitly empty `pricing` + // object clears the discount but retains the object; omitting `pricing` clears + // it. `config.pricing` is not a supported mask path. The provider type is + // immutable. A `config` or `config.provider` replacement that carries no + // authentication material preserves the existing authentication binding; + // input-only plaintext does not need to be read back and re-sent. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Request to update a model service. `name` cannot appear in `update_mask`; the +// model service name is immutable.. +type UpdateModelServiceRequest struct { + // Optimistic concurrency token from the most recent read. When set, the update + // succeeds only if the resource has not changed. Leave unset for an + // unconditional update. For REST requests, URL-encode the base64 string + // returned by the API when setting the `etag` query parameter. + Etag []byte `json:"etag,omitempty"` + // The model service with the updated field values. `name` identifies the + // resource (`model-services/{catalog}.{schema}.{model_service}`); only fields + // listed in `update_mask` are applied. + ModelService *ModelService `json:"model_service,omitempty"` + // Fields to update. Use `config` to replace the entire configuration. The + // replacement must include every required field; any optional field you omit is + // cleared. To preserve sibling fields, use one or more granular paths: + // `comment`, `config.routing.destinations`, + // `config.routing.fallback.destinations`, `config.rate_limits`, or + // `config.inference_table`. Intermediate paths such as `config.routing` and + // `config.routing.fallback` are not supported. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Request to update a skill. `name` cannot appear in `update_mask`; the skill +// name is immutable.. +type UpdateSkillRequest struct { + // Optimistic concurrency token from the most recent read. When set, the update + // succeeds only if the resource has not changed. Leave unset for an + // unconditional update. For REST requests, URL-encode the base64 string + // returned by the API when setting the `etag` query parameter. + Etag []byte `json:"etag,omitempty"` + // The skill with the updated field values. `name` identifies the resource + // (`skills/{catalog}.{schema}.{skill}`); only fields listed in `update_mask` + // are applied. + Skill *Skill `json:"skill,omitempty"` + // Fields to update; validated against `skill`. REQUIRED, matching the sibling + // Update RPCs. `comment` is the only mutable field. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CreateMcpServiceRequestToSDK converts the mirror to the sdk-go type. +func CreateMcpServiceRequestToSDK(w *CreateMcpServiceRequest) (*sdk.CreateMcpServiceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateMcpServiceRequest{} + out.Parent = w.Parent + out.McpServiceId = w.McpServiceId + conv1, err := McpServiceToSDK(w.McpService) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateMcpServiceRequest.McpService", err) + } + out.McpService = conv1 + return out, nil +} + +// CreateMcpServiceRequestFromSDK converts the sdk-go type to the mirror. +func CreateMcpServiceRequestFromSDK(v *sdk.CreateMcpServiceRequest) (*CreateMcpServiceRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateMcpServiceRequest{} + out.Parent = v.Parent + out.McpServiceId = v.McpServiceId + conv2, err := McpServiceFromSDK(v.McpService) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateMcpServiceRequest.McpService", err) + } + out.McpService = conv2 + return out, nil +} + +// CreateMcpServiceUserMappedCredentialRequestToSDK converts the mirror to the sdk-go type. +func CreateMcpServiceUserMappedCredentialRequestToSDK(w *CreateMcpServiceUserMappedCredentialRequest) (*sdk.CreateMcpServiceUserMappedCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateMcpServiceUserMappedCredentialRequest{} + out.Name = w.Name + conv3, err := McpServiceUserMappedCredentialLoginToSDK(w.Login) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateMcpServiceUserMappedCredentialRequest.Login", err) + } + out.Login = conv3 + return out, nil +} + +// CreateMcpServiceUserMappedCredentialRequestFromSDK converts the sdk-go type to the mirror. +func CreateMcpServiceUserMappedCredentialRequestFromSDK(v *sdk.CreateMcpServiceUserMappedCredentialRequest) (*CreateMcpServiceUserMappedCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateMcpServiceUserMappedCredentialRequest{} + out.Name = v.Name + conv4, err := McpServiceUserMappedCredentialLoginFromSDK(v.Login) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateMcpServiceUserMappedCredentialRequest.Login", err) + } + out.Login = conv4 + return out, nil +} + +// CreateModelProviderServiceRequestToSDK converts the mirror to the sdk-go type. +func CreateModelProviderServiceRequestToSDK(w *CreateModelProviderServiceRequest) (*sdk.CreateModelProviderServiceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateModelProviderServiceRequest{} + out.Parent = w.Parent + out.ModelProviderServiceId = w.ModelProviderServiceId + conv5, err := ModelProviderServiceToSDK(w.ModelProviderService) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateModelProviderServiceRequest.ModelProviderService", err) + } + out.ModelProviderService = conv5 + return out, nil +} + +// CreateModelProviderServiceRequestFromSDK converts the sdk-go type to the mirror. +func CreateModelProviderServiceRequestFromSDK(v *sdk.CreateModelProviderServiceRequest) (*CreateModelProviderServiceRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateModelProviderServiceRequest{} + out.Parent = v.Parent + out.ModelProviderServiceId = v.ModelProviderServiceId + conv6, err := ModelProviderServiceFromSDK(v.ModelProviderService) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateModelProviderServiceRequest.ModelProviderService", err) + } + out.ModelProviderService = conv6 + return out, nil +} + +// CreateModelServiceRequestToSDK converts the mirror to the sdk-go type. +func CreateModelServiceRequestToSDK(w *CreateModelServiceRequest) (*sdk.CreateModelServiceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateModelServiceRequest{} + out.Parent = w.Parent + out.ModelServiceId = w.ModelServiceId + conv7, err := ModelServiceToSDK(w.ModelService) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateModelServiceRequest.ModelService", err) + } + out.ModelService = conv7 + return out, nil +} + +// CreateModelServiceRequestFromSDK converts the sdk-go type to the mirror. +func CreateModelServiceRequestFromSDK(v *sdk.CreateModelServiceRequest) (*CreateModelServiceRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateModelServiceRequest{} + out.Parent = v.Parent + out.ModelServiceId = v.ModelServiceId + conv8, err := ModelServiceFromSDK(v.ModelService) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateModelServiceRequest.ModelService", err) + } + out.ModelService = conv8 + return out, nil +} + +// CreateSkillRequestToSDK converts the mirror to the sdk-go type. +func CreateSkillRequestToSDK(w *CreateSkillRequest) (*sdk.CreateSkillRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateSkillRequest{} + out.Parent = w.Parent + out.SkillId = w.SkillId + conv9, err := SkillToSDK(w.Skill) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSkillRequest.Skill", err) + } + out.Skill = conv9 + return out, nil +} + +// CreateSkillRequestFromSDK converts the sdk-go type to the mirror. +func CreateSkillRequestFromSDK(v *sdk.CreateSkillRequest) (*CreateSkillRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateSkillRequest{} + out.Parent = v.Parent + out.SkillId = v.SkillId + conv10, err := SkillFromSDK(v.Skill) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSkillRequest.Skill", err) + } + out.Skill = conv10 + return out, nil +} + +// DeleteMcpServiceRequestToSDK converts the mirror to the sdk-go type. +func DeleteMcpServiceRequestToSDK(w *DeleteMcpServiceRequest) (*sdk.DeleteMcpServiceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteMcpServiceRequest{} + out.Name = w.Name + out.Etag = w.Etag + return out, nil +} + +// DeleteMcpServiceRequestFromSDK converts the sdk-go type to the mirror. +func DeleteMcpServiceRequestFromSDK(v *sdk.DeleteMcpServiceRequest) (*DeleteMcpServiceRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteMcpServiceRequest{} + out.Name = v.Name + out.Etag = v.Etag + return out, nil +} + +// DeleteModelProviderServiceRequestToSDK converts the mirror to the sdk-go type. +func DeleteModelProviderServiceRequestToSDK(w *DeleteModelProviderServiceRequest) (*sdk.DeleteModelProviderServiceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteModelProviderServiceRequest{} + out.Name = w.Name + out.Etag = w.Etag + return out, nil +} + +// DeleteModelProviderServiceRequestFromSDK converts the sdk-go type to the mirror. +func DeleteModelProviderServiceRequestFromSDK(v *sdk.DeleteModelProviderServiceRequest) (*DeleteModelProviderServiceRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteModelProviderServiceRequest{} + out.Name = v.Name + out.Etag = v.Etag + return out, nil +} + +// DeleteModelServiceRequestToSDK converts the mirror to the sdk-go type. +func DeleteModelServiceRequestToSDK(w *DeleteModelServiceRequest) (*sdk.DeleteModelServiceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteModelServiceRequest{} + out.Name = w.Name + out.Etag = w.Etag + return out, nil +} + +// DeleteModelServiceRequestFromSDK converts the sdk-go type to the mirror. +func DeleteModelServiceRequestFromSDK(v *sdk.DeleteModelServiceRequest) (*DeleteModelServiceRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteModelServiceRequest{} + out.Name = v.Name + out.Etag = v.Etag + return out, nil +} + +// DeleteSkillRequestToSDK converts the mirror to the sdk-go type. +func DeleteSkillRequestToSDK(w *DeleteSkillRequest) (*sdk.DeleteSkillRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteSkillRequest{} + out.Name = w.Name + out.Etag = w.Etag + return out, nil +} + +// DeleteSkillRequestFromSDK converts the sdk-go type to the mirror. +func DeleteSkillRequestFromSDK(v *sdk.DeleteSkillRequest) (*DeleteSkillRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteSkillRequest{} + out.Name = v.Name + out.Etag = v.Etag + return out, nil +} + +// InferenceTableConfigToSDK converts the mirror to the sdk-go type. +func InferenceTableConfigToSDK(w *InferenceTableConfig) (*sdk.InferenceTableConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.InferenceTableConfig{} + out.Parent = w.Parent + out.TableNamePrefix = w.TableNamePrefix + out.Table = w.Table + out.IsDeleted = w.IsDeleted + return out, nil +} + +// InferenceTableConfigFromSDK converts the sdk-go type to the mirror. +func InferenceTableConfigFromSDK(v *sdk.InferenceTableConfig) (*InferenceTableConfig, error) { + if v == nil { + return nil, nil + } + out := &InferenceTableConfig{} + out.Parent = v.Parent + out.TableNamePrefix = v.TableNamePrefix + out.Table = v.Table + out.IsDeleted = v.IsDeleted + return out, nil +} + +// ListMcpServicesRequestToSDK converts the mirror to the sdk-go type. +func ListMcpServicesRequestToSDK(w *ListMcpServicesRequest) (*sdk.ListMcpServicesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListMcpServicesRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + out.View = w.View + return out, nil +} + +// ListMcpServicesRequestFromSDK converts the sdk-go type to the mirror. +func ListMcpServicesRequestFromSDK(v *sdk.ListMcpServicesRequest) (*ListMcpServicesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListMcpServicesRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + out.View = v.View + return out, nil +} + +// ListMcpServicesResponseToSDK converts the mirror to the sdk-go type. +func ListMcpServicesResponseToSDK(w *ListMcpServicesResponse) (*sdk.ListMcpServicesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListMcpServicesResponse{} + conv11, err := convertSlice(w.McpServices, McpServiceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListMcpServicesResponse.McpServices", err) + } + out.McpServices = conv11 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListMcpServicesResponseFromSDK converts the sdk-go type to the mirror. +func ListMcpServicesResponseFromSDK(v *sdk.ListMcpServicesResponse) (*ListMcpServicesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListMcpServicesResponse{} + conv12, err := convertSlice(v.McpServices, McpServiceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListMcpServicesResponse.McpServices", err) + } + out.McpServices = conv12 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListModelProviderServicesRequestToSDK converts the mirror to the sdk-go type. +func ListModelProviderServicesRequestToSDK(w *ListModelProviderServicesRequest) (*sdk.ListModelProviderServicesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListModelProviderServicesRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + out.View = w.View + return out, nil +} + +// ListModelProviderServicesRequestFromSDK converts the sdk-go type to the mirror. +func ListModelProviderServicesRequestFromSDK(v *sdk.ListModelProviderServicesRequest) (*ListModelProviderServicesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListModelProviderServicesRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + out.View = v.View + return out, nil +} + +// ListModelProviderServicesResponseToSDK converts the mirror to the sdk-go type. +func ListModelProviderServicesResponseToSDK(w *ListModelProviderServicesResponse) (*sdk.ListModelProviderServicesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListModelProviderServicesResponse{} + conv13, err := convertSlice(w.ModelProviderServices, ModelProviderServiceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListModelProviderServicesResponse.ModelProviderServices", err) + } + out.ModelProviderServices = conv13 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListModelProviderServicesResponseFromSDK converts the sdk-go type to the mirror. +func ListModelProviderServicesResponseFromSDK(v *sdk.ListModelProviderServicesResponse) (*ListModelProviderServicesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListModelProviderServicesResponse{} + conv14, err := convertSlice(v.ModelProviderServices, ModelProviderServiceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListModelProviderServicesResponse.ModelProviderServices", err) + } + out.ModelProviderServices = conv14 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListModelServicesRequestToSDK converts the mirror to the sdk-go type. +func ListModelServicesRequestToSDK(w *ListModelServicesRequest) (*sdk.ListModelServicesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListModelServicesRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + out.View = w.View + return out, nil +} + +// ListModelServicesRequestFromSDK converts the sdk-go type to the mirror. +func ListModelServicesRequestFromSDK(v *sdk.ListModelServicesRequest) (*ListModelServicesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListModelServicesRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + out.View = v.View + return out, nil +} + +// ListModelServicesResponseToSDK converts the mirror to the sdk-go type. +func ListModelServicesResponseToSDK(w *ListModelServicesResponse) (*sdk.ListModelServicesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListModelServicesResponse{} + conv15, err := convertSlice(w.ModelServices, ModelServiceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListModelServicesResponse.ModelServices", err) + } + out.ModelServices = conv15 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListModelServicesResponseFromSDK converts the sdk-go type to the mirror. +func ListModelServicesResponseFromSDK(v *sdk.ListModelServicesResponse) (*ListModelServicesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListModelServicesResponse{} + conv16, err := convertSlice(v.ModelServices, ModelServiceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListModelServicesResponse.ModelServices", err) + } + out.ModelServices = conv16 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListSkillsRequestToSDK converts the mirror to the sdk-go type. +func ListSkillsRequestToSDK(w *ListSkillsRequest) (*sdk.ListSkillsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSkillsRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListSkillsRequestFromSDK converts the sdk-go type to the mirror. +func ListSkillsRequestFromSDK(v *sdk.ListSkillsRequest) (*ListSkillsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSkillsRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListSkillsResponseToSDK converts the mirror to the sdk-go type. +func ListSkillsResponseToSDK(w *ListSkillsResponse) (*sdk.ListSkillsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSkillsResponse{} + conv17, err := convertSlice(w.Skills, SkillToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSkillsResponse.Skills", err) + } + out.Skills = conv17 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSkillsResponseFromSDK converts the sdk-go type to the mirror. +func ListSkillsResponseFromSDK(v *sdk.ListSkillsResponse) (*ListSkillsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSkillsResponse{} + conv18, err := convertSlice(v.Skills, SkillFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSkillsResponse.Skills", err) + } + out.Skills = conv18 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// McpServiceToSDK converts the mirror to the sdk-go type. +func McpServiceToSDK(w *McpService) (*sdk.McpService, error) { + if w == nil { + return nil, nil + } + out := &sdk.McpService{} + out.Name = w.Name + out.EffectiveOwner = w.EffectiveOwner + out.MetastoreId = w.MetastoreId + out.CreateTime = w.CreateTime + out.CreatedBy = w.CreatedBy + out.UpdateTime = w.UpdateTime + out.UpdatedBy = w.UpdatedBy + out.Comment = w.Comment + conv19, err := McpServiceConfigToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "McpService.Config", err) + } + out.Config = conv19 + out.Etag = w.Etag + return out, nil +} + +// McpServiceFromSDK converts the sdk-go type to the mirror. +func McpServiceFromSDK(v *sdk.McpService) (*McpService, error) { + if v == nil { + return nil, nil + } + out := &McpService{} + out.Name = v.Name + out.EffectiveOwner = v.EffectiveOwner + out.MetastoreId = v.MetastoreId + out.CreateTime = v.CreateTime + out.CreatedBy = v.CreatedBy + out.UpdateTime = v.UpdateTime + out.UpdatedBy = v.UpdatedBy + out.Comment = v.Comment + conv20, err := McpServiceConfigFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "McpService.Config", err) + } + out.Config = conv20 + out.Etag = v.Etag + return out, nil +} + +// McpServiceConfigToSDK converts the mirror to the sdk-go type. +func McpServiceConfigToSDK(w *McpServiceConfig) (*sdk.McpServiceConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.McpServiceConfig{} + { + var members []string + if w.SourceConnection != nil { + members = append(members, "source_connection") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.SourceConnection != nil: + conv21, err := McpServiceConfig_SourceConnectionToSDK(w.SourceConnection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "McpServiceConfig.Source", err) + } + out.Source = &sdk.McpServiceConfig_Source_SourceConnection{SourceConnection: *conv21} + } + out.IncludeToolSelectors = w.IncludeToolSelectors + conv22, err := convertSlice(w.RateLimits, RateLimitToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "McpServiceConfig.RateLimits", err) + } + out.RateLimits = conv22 + return out, nil +} + +// McpServiceConfigFromSDK converts the sdk-go type to the mirror. +func McpServiceConfigFromSDK(v *sdk.McpServiceConfig) (*McpServiceConfig, error) { + if v == nil { + return nil, nil + } + out := &McpServiceConfig{} + switch value := v.Source.(type) { + case *sdk.McpServiceConfig_Source_SourceConnection: + if value != nil { + conv23, err := McpServiceConfig_SourceConnectionFromSDK(&value.SourceConnection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "McpServiceConfig.Source", err) + } + out.SourceConnection = conv23 + } + } + out.IncludeToolSelectors = v.IncludeToolSelectors + conv24, err := convertSlice(v.RateLimits, RateLimitFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "McpServiceConfig.RateLimits", err) + } + out.RateLimits = conv24 + return out, nil +} + +// McpServiceConfig_SourceConnectionToSDK converts the mirror to the sdk-go type. +func McpServiceConfig_SourceConnectionToSDK(w *McpServiceConfig_SourceConnection) (*sdk.McpServiceConfig_SourceConnection, error) { + if w == nil { + return nil, nil + } + out := &sdk.McpServiceConfig_SourceConnection{} + out.Name = w.Name + out.IsDeleted = w.IsDeleted + out.Options = w.Options + return out, nil +} + +// McpServiceConfig_SourceConnectionFromSDK converts the sdk-go type to the mirror. +func McpServiceConfig_SourceConnectionFromSDK(v *sdk.McpServiceConfig_SourceConnection) (*McpServiceConfig_SourceConnection, error) { + if v == nil { + return nil, nil + } + out := &McpServiceConfig_SourceConnection{} + out.Name = v.Name + out.IsDeleted = v.IsDeleted + out.Options = v.Options + return out, nil +} + +// McpServiceUserMappedCredentialToSDK converts the mirror to the sdk-go type. +func McpServiceUserMappedCredentialToSDK(w *McpServiceUserMappedCredential) (*sdk.McpServiceUserMappedCredential, error) { + if w == nil { + return nil, nil + } + out := &sdk.McpServiceUserMappedCredential{} + out.Options = w.Options + conv25, err := ProvisioningInfoToSDK(w.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "McpServiceUserMappedCredential.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv25 + return out, nil +} + +// McpServiceUserMappedCredentialFromSDK converts the sdk-go type to the mirror. +func McpServiceUserMappedCredentialFromSDK(v *sdk.McpServiceUserMappedCredential) (*McpServiceUserMappedCredential, error) { + if v == nil { + return nil, nil + } + out := &McpServiceUserMappedCredential{} + out.Options = v.Options + conv26, err := ProvisioningInfoFromSDK(v.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "McpServiceUserMappedCredential.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv26 + return out, nil +} + +// McpServiceUserMappedCredentialLoginToSDK converts the mirror to the sdk-go type. +func McpServiceUserMappedCredentialLoginToSDK(w *McpServiceUserMappedCredentialLogin) (*sdk.McpServiceUserMappedCredentialLogin, error) { + if w == nil { + return nil, nil + } + out := &sdk.McpServiceUserMappedCredentialLogin{} + out.Options = w.Options + return out, nil +} + +// McpServiceUserMappedCredentialLoginFromSDK converts the sdk-go type to the mirror. +func McpServiceUserMappedCredentialLoginFromSDK(v *sdk.McpServiceUserMappedCredentialLogin) (*McpServiceUserMappedCredentialLogin, error) { + if v == nil { + return nil, nil + } + out := &McpServiceUserMappedCredentialLogin{} + out.Options = v.Options + return out, nil +} + +// ModelProviderServiceToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceToSDK(w *ModelProviderService) (*sdk.ModelProviderService, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderService{} + out.Name = w.Name + out.EffectiveOwner = w.EffectiveOwner + out.MetastoreId = w.MetastoreId + out.CreateTime = w.CreateTime + out.CreatedBy = w.CreatedBy + out.UpdateTime = w.UpdateTime + out.UpdatedBy = w.UpdatedBy + out.Comment = w.Comment + out.Etag = w.Etag + conv27, err := ModelProviderServiceConfigToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderService.Config", err) + } + out.Config = conv27 + return out, nil +} + +// ModelProviderServiceFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceFromSDK(v *sdk.ModelProviderService) (*ModelProviderService, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderService{} + out.Name = v.Name + out.EffectiveOwner = v.EffectiveOwner + out.MetastoreId = v.MetastoreId + out.CreateTime = v.CreateTime + out.CreatedBy = v.CreatedBy + out.UpdateTime = v.UpdateTime + out.UpdatedBy = v.UpdatedBy + out.Comment = v.Comment + out.Etag = v.Etag + conv28, err := ModelProviderServiceConfigFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderService.Config", err) + } + out.Config = conv28 + return out, nil +} + +// ModelProviderServiceConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfigToSDK(w *ModelProviderServiceConfig) (*sdk.ModelProviderServiceConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig{} + out.ProviderType = w.ProviderType + { + var members []string + if w.Openai != nil { + members = append(members, "openai") + } + if w.AzureOpenai != nil { + members = append(members, "azure_openai") + } + if w.Anthropic != nil { + members = append(members, "anthropic") + } + if w.AmazonBedrock != nil { + members = append(members, "amazon_bedrock") + } + if w.Custom != nil { + members = append(members, "custom") + } + if w.MicrosoftFoundry != nil { + members = append(members, "microsoft_foundry") + } + if w.GeminiEnterprise != nil { + members = append(members, "gemini_enterprise") + } + if w.BedrockMantle != nil { + members = append(members, "bedrock_mantle") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Openai != nil: + conv29, err := ModelProviderServiceConfig_OpenAiProviderConfigToSDK(w.Openai) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.Provider = &sdk.ModelProviderServiceConfig_Provider_Openai{Openai: *conv29} + case w.AzureOpenai != nil: + conv30, err := ModelProviderServiceConfig_AzureOpenAiProviderConfigToSDK(w.AzureOpenai) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.Provider = &sdk.ModelProviderServiceConfig_Provider_AzureOpenai{AzureOpenai: *conv30} + case w.Anthropic != nil: + conv31, err := ModelProviderServiceConfig_AnthropicProviderConfigToSDK(w.Anthropic) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.Provider = &sdk.ModelProviderServiceConfig_Provider_Anthropic{Anthropic: *conv31} + case w.AmazonBedrock != nil: + conv32, err := ModelProviderServiceConfig_AmazonBedrockProviderConfigToSDK(w.AmazonBedrock) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.Provider = &sdk.ModelProviderServiceConfig_Provider_AmazonBedrock{AmazonBedrock: *conv32} + case w.Custom != nil: + conv33, err := ModelProviderServiceConfig_CustomProviderConfigToSDK(w.Custom) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.Provider = &sdk.ModelProviderServiceConfig_Provider_Custom{Custom: *conv33} + case w.MicrosoftFoundry != nil: + conv34, err := ModelProviderServiceConfig_MicrosoftFoundryProviderConfigToSDK(w.MicrosoftFoundry) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.Provider = &sdk.ModelProviderServiceConfig_Provider_MicrosoftFoundry{MicrosoftFoundry: *conv34} + case w.GeminiEnterprise != nil: + conv35, err := ModelProviderServiceConfig_GeminiEnterpriseProviderConfigToSDK(w.GeminiEnterprise) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.Provider = &sdk.ModelProviderServiceConfig_Provider_GeminiEnterprise{GeminiEnterprise: *conv35} + case w.BedrockMantle != nil: + conv36, err := ModelProviderServiceConfig_AmazonBedrockProviderConfigToSDK(w.BedrockMantle) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.Provider = &sdk.ModelProviderServiceConfig_Provider_BedrockMantle{BedrockMantle: *conv36} + } + out.AllowAllTargets = w.AllowAllTargets + conv37, err := convertSlice(w.Targets, ModelProviderServiceConfig_ModelTargetConfigToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Targets", err) + } + out.Targets = conv37 + out.ForwardHeaders = w.ForwardHeaders + out.ForwardQueryParameters = w.ForwardQueryParameters + out.ForwardUnmanagedPaths = w.ForwardUnmanagedPaths + conv38, err := convertSlice(w.RateLimits, RateLimitToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.RateLimits", err) + } + out.RateLimits = conv38 + conv39, err := InferenceTableConfigToSDK(w.InferenceTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.InferenceTable", err) + } + out.InferenceTable = conv39 + conv40, err := ModelProviderServiceConfig_ProviderPricingConfigToSDK(w.Pricing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Pricing", err) + } + out.Pricing = conv40 + return out, nil +} + +// ModelProviderServiceConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfigFromSDK(v *sdk.ModelProviderServiceConfig) (*ModelProviderServiceConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig{} + out.ProviderType = v.ProviderType + switch value := v.Provider.(type) { + case *sdk.ModelProviderServiceConfig_Provider_Openai: + if value != nil { + conv41, err := ModelProviderServiceConfig_OpenAiProviderConfigFromSDK(&value.Openai) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.Openai = conv41 + } + case *sdk.ModelProviderServiceConfig_Provider_AzureOpenai: + if value != nil { + conv42, err := ModelProviderServiceConfig_AzureOpenAiProviderConfigFromSDK(&value.AzureOpenai) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.AzureOpenai = conv42 + } + case *sdk.ModelProviderServiceConfig_Provider_Anthropic: + if value != nil { + conv43, err := ModelProviderServiceConfig_AnthropicProviderConfigFromSDK(&value.Anthropic) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.Anthropic = conv43 + } + case *sdk.ModelProviderServiceConfig_Provider_AmazonBedrock: + if value != nil { + conv44, err := ModelProviderServiceConfig_AmazonBedrockProviderConfigFromSDK(&value.AmazonBedrock) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.AmazonBedrock = conv44 + } + case *sdk.ModelProviderServiceConfig_Provider_Custom: + if value != nil { + conv45, err := ModelProviderServiceConfig_CustomProviderConfigFromSDK(&value.Custom) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.Custom = conv45 + } + case *sdk.ModelProviderServiceConfig_Provider_MicrosoftFoundry: + if value != nil { + conv46, err := ModelProviderServiceConfig_MicrosoftFoundryProviderConfigFromSDK(&value.MicrosoftFoundry) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.MicrosoftFoundry = conv46 + } + case *sdk.ModelProviderServiceConfig_Provider_GeminiEnterprise: + if value != nil { + conv47, err := ModelProviderServiceConfig_GeminiEnterpriseProviderConfigFromSDK(&value.GeminiEnterprise) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.GeminiEnterprise = conv47 + } + case *sdk.ModelProviderServiceConfig_Provider_BedrockMantle: + if value != nil { + conv48, err := ModelProviderServiceConfig_AmazonBedrockProviderConfigFromSDK(&value.BedrockMantle) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Provider", err) + } + out.BedrockMantle = conv48 + } + } + out.AllowAllTargets = v.AllowAllTargets + conv49, err := convertSlice(v.Targets, ModelProviderServiceConfig_ModelTargetConfigFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Targets", err) + } + out.Targets = conv49 + out.ForwardHeaders = v.ForwardHeaders + out.ForwardQueryParameters = v.ForwardQueryParameters + out.ForwardUnmanagedPaths = v.ForwardUnmanagedPaths + conv50, err := convertSlice(v.RateLimits, RateLimitFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.RateLimits", err) + } + out.RateLimits = conv50 + conv51, err := InferenceTableConfigFromSDK(v.InferenceTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.InferenceTable", err) + } + out.InferenceTable = conv51 + conv52, err := ModelProviderServiceConfig_ProviderPricingConfigFromSDK(v.Pricing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig.Pricing", err) + } + out.Pricing = conv52 + return out, nil +} + +// ModelProviderServiceConfig_AmazonBedrockProviderConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_AmazonBedrockProviderConfigToSDK(w *ModelProviderServiceConfig_AmazonBedrockProviderConfig) (*sdk.ModelProviderServiceConfig_AmazonBedrockProviderConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_AmazonBedrockProviderConfig{} + { + var members []string + if w.Direct != nil { + members = append(members, "direct") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Direct != nil: + conv53, err := ModelProviderServiceConfig_AmazonBedrockProviderDirectConfigToSDK(w.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AmazonBedrockProviderConfig.ProviderMode", err) + } + out.ProviderMode = &sdk.ModelProviderServiceConfig_AmazonBedrockProviderConfig_ProviderMode_Direct{Direct: *conv53} + } + return out, nil +} + +// ModelProviderServiceConfig_AmazonBedrockProviderConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_AmazonBedrockProviderConfigFromSDK(v *sdk.ModelProviderServiceConfig_AmazonBedrockProviderConfig) (*ModelProviderServiceConfig_AmazonBedrockProviderConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_AmazonBedrockProviderConfig{} + switch value := v.ProviderMode.(type) { + case *sdk.ModelProviderServiceConfig_AmazonBedrockProviderConfig_ProviderMode_Direct: + if value != nil { + conv54, err := ModelProviderServiceConfig_AmazonBedrockProviderDirectConfigFromSDK(&value.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AmazonBedrockProviderConfig.ProviderMode", err) + } + out.Direct = conv54 + } + } + return out, nil +} + +// ModelProviderServiceConfig_AmazonBedrockProviderDirectConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_AmazonBedrockProviderDirectConfigToSDK(w *ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig) (*sdk.ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig{} + out.Region = w.Region + { + var members []string + if w.ServiceCredential != nil { + members = append(members, "service_credential") + } + if w.AwsAccessKey != nil { + members = append(members, "aws_access_key") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ServiceCredential != nil: + conv55, err := ModelProviderServiceConfig_ServiceCredentialToSDK(w.ServiceCredential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig_AuthMode_ServiceCredential{ServiceCredential: *conv55} + case w.AwsAccessKey != nil: + conv56, err := ModelProviderServiceConfig_AwsAccessKeyToSDK(w.AwsAccessKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig_AuthMode_AwsAccessKey{AwsAccessKey: *conv56} + } + return out, nil +} + +// ModelProviderServiceConfig_AmazonBedrockProviderDirectConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_AmazonBedrockProviderDirectConfigFromSDK(v *sdk.ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig) (*ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig{} + out.Region = v.Region + switch value := v.AuthMode.(type) { + case *sdk.ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig_AuthMode_ServiceCredential: + if value != nil { + conv57, err := ModelProviderServiceConfig_ServiceCredentialFromSDK(&value.ServiceCredential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig.AuthMode", err) + } + out.ServiceCredential = conv57 + } + case *sdk.ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig_AuthMode_AwsAccessKey: + if value != nil { + conv58, err := ModelProviderServiceConfig_AwsAccessKeyFromSDK(&value.AwsAccessKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig.AuthMode", err) + } + out.AwsAccessKey = conv58 + } + } + return out, nil +} + +// ModelProviderServiceConfig_AnthropicProviderConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_AnthropicProviderConfigToSDK(w *ModelProviderServiceConfig_AnthropicProviderConfig) (*sdk.ModelProviderServiceConfig_AnthropicProviderConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_AnthropicProviderConfig{} + { + var members []string + if w.Direct != nil { + members = append(members, "direct") + } + if w.Relayed != nil { + members = append(members, "relayed") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Direct != nil: + conv59, err := ModelProviderServiceConfig_AnthropicProviderDirectConfigToSDK(w.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AnthropicProviderConfig.ProviderMode", err) + } + out.ProviderMode = &sdk.ModelProviderServiceConfig_AnthropicProviderConfig_ProviderMode_Direct{Direct: *conv59} + case w.Relayed != nil: + conv60, err := ModelProviderServiceConfig_AnthropicProviderRelayedConfigToSDK(w.Relayed) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AnthropicProviderConfig.ProviderMode", err) + } + out.ProviderMode = &sdk.ModelProviderServiceConfig_AnthropicProviderConfig_ProviderMode_Relayed{Relayed: *conv60} + } + return out, nil +} + +// ModelProviderServiceConfig_AnthropicProviderConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_AnthropicProviderConfigFromSDK(v *sdk.ModelProviderServiceConfig_AnthropicProviderConfig) (*ModelProviderServiceConfig_AnthropicProviderConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_AnthropicProviderConfig{} + switch value := v.ProviderMode.(type) { + case *sdk.ModelProviderServiceConfig_AnthropicProviderConfig_ProviderMode_Direct: + if value != nil { + conv61, err := ModelProviderServiceConfig_AnthropicProviderDirectConfigFromSDK(&value.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AnthropicProviderConfig.ProviderMode", err) + } + out.Direct = conv61 + } + case *sdk.ModelProviderServiceConfig_AnthropicProviderConfig_ProviderMode_Relayed: + if value != nil { + conv62, err := ModelProviderServiceConfig_AnthropicProviderRelayedConfigFromSDK(&value.Relayed) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AnthropicProviderConfig.ProviderMode", err) + } + out.Relayed = conv62 + } + } + return out, nil +} + +// ModelProviderServiceConfig_AnthropicProviderDirectConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_AnthropicProviderDirectConfigToSDK(w *ModelProviderServiceConfig_AnthropicProviderDirectConfig) (*sdk.ModelProviderServiceConfig_AnthropicProviderDirectConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_AnthropicProviderDirectConfig{} + { + var members []string + if w.ApiKey != nil { + members = append(members, "api_key") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ApiKey != nil: + conv63, err := ModelProviderServiceConfig_ProviderSecretToSDK(w.ApiKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AnthropicProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_AnthropicProviderDirectConfig_AuthMode_ApiKey{ApiKey: *conv63} + } + return out, nil +} + +// ModelProviderServiceConfig_AnthropicProviderDirectConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_AnthropicProviderDirectConfigFromSDK(v *sdk.ModelProviderServiceConfig_AnthropicProviderDirectConfig) (*ModelProviderServiceConfig_AnthropicProviderDirectConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_AnthropicProviderDirectConfig{} + switch value := v.AuthMode.(type) { + case *sdk.ModelProviderServiceConfig_AnthropicProviderDirectConfig_AuthMode_ApiKey: + if value != nil { + conv64, err := ModelProviderServiceConfig_ProviderSecretFromSDK(&value.ApiKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AnthropicProviderDirectConfig.AuthMode", err) + } + out.ApiKey = conv64 + } + } + return out, nil +} + +// ModelProviderServiceConfig_AnthropicProviderRelayedConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_AnthropicProviderRelayedConfigToSDK(w *ModelProviderServiceConfig_AnthropicProviderRelayedConfig) (*sdk.ModelProviderServiceConfig_AnthropicProviderRelayedConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_AnthropicProviderRelayedConfig{} + return out, nil +} + +// ModelProviderServiceConfig_AnthropicProviderRelayedConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_AnthropicProviderRelayedConfigFromSDK(v *sdk.ModelProviderServiceConfig_AnthropicProviderRelayedConfig) (*ModelProviderServiceConfig_AnthropicProviderRelayedConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_AnthropicProviderRelayedConfig{} + return out, nil +} + +// ModelProviderServiceConfig_AwsAccessKeyToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_AwsAccessKeyToSDK(w *ModelProviderServiceConfig_AwsAccessKey) (*sdk.ModelProviderServiceConfig_AwsAccessKey, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_AwsAccessKey{} + out.AccessKeyId = w.AccessKeyId + conv65, err := ModelProviderServiceConfig_ProviderSecretToSDK(w.SecretAccessKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AwsAccessKey.SecretAccessKey", err) + } + out.SecretAccessKey = conv65 + return out, nil +} + +// ModelProviderServiceConfig_AwsAccessKeyFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_AwsAccessKeyFromSDK(v *sdk.ModelProviderServiceConfig_AwsAccessKey) (*ModelProviderServiceConfig_AwsAccessKey, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_AwsAccessKey{} + out.AccessKeyId = v.AccessKeyId + conv66, err := ModelProviderServiceConfig_ProviderSecretFromSDK(v.SecretAccessKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AwsAccessKey.SecretAccessKey", err) + } + out.SecretAccessKey = conv66 + return out, nil +} + +// ModelProviderServiceConfig_AzureOpenAiProviderConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_AzureOpenAiProviderConfigToSDK(w *ModelProviderServiceConfig_AzureOpenAiProviderConfig) (*sdk.ModelProviderServiceConfig_AzureOpenAiProviderConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_AzureOpenAiProviderConfig{} + { + var members []string + if w.Direct != nil { + members = append(members, "direct") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Direct != nil: + conv67, err := ModelProviderServiceConfig_AzureOpenAiProviderDirectConfigToSDK(w.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AzureOpenAiProviderConfig.ProviderMode", err) + } + out.ProviderMode = &sdk.ModelProviderServiceConfig_AzureOpenAiProviderConfig_ProviderMode_Direct{Direct: *conv67} + } + return out, nil +} + +// ModelProviderServiceConfig_AzureOpenAiProviderConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_AzureOpenAiProviderConfigFromSDK(v *sdk.ModelProviderServiceConfig_AzureOpenAiProviderConfig) (*ModelProviderServiceConfig_AzureOpenAiProviderConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_AzureOpenAiProviderConfig{} + switch value := v.ProviderMode.(type) { + case *sdk.ModelProviderServiceConfig_AzureOpenAiProviderConfig_ProviderMode_Direct: + if value != nil { + conv68, err := ModelProviderServiceConfig_AzureOpenAiProviderDirectConfigFromSDK(&value.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AzureOpenAiProviderConfig.ProviderMode", err) + } + out.Direct = conv68 + } + } + return out, nil +} + +// ModelProviderServiceConfig_AzureOpenAiProviderDirectConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_AzureOpenAiProviderDirectConfigToSDK(w *ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig) (*sdk.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig{} + out.BaseUrl = w.BaseUrl + { + var members []string + if w.ApiKey != nil { + members = append(members, "api_key") + } + if w.ServiceCredential != nil { + members = append(members, "service_credential") + } + if w.EntraServicePrincipal != nil { + members = append(members, "entra_service_principal") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ApiKey != nil: + conv69, err := ModelProviderServiceConfig_ProviderSecretToSDK(w.ApiKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig_AuthMode_ApiKey{ApiKey: *conv69} + case w.ServiceCredential != nil: + conv70, err := ModelProviderServiceConfig_ServiceCredentialToSDK(w.ServiceCredential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig_AuthMode_ServiceCredential{ServiceCredential: *conv70} + case w.EntraServicePrincipal != nil: + conv71, err := ModelProviderServiceConfig_EntraServicePrincipalToSDK(w.EntraServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig_AuthMode_EntraServicePrincipal{EntraServicePrincipal: *conv71} + } + return out, nil +} + +// ModelProviderServiceConfig_AzureOpenAiProviderDirectConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_AzureOpenAiProviderDirectConfigFromSDK(v *sdk.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig) (*ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig{} + out.BaseUrl = v.BaseUrl + switch value := v.AuthMode.(type) { + case *sdk.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig_AuthMode_ApiKey: + if value != nil { + conv72, err := ModelProviderServiceConfig_ProviderSecretFromSDK(&value.ApiKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig.AuthMode", err) + } + out.ApiKey = conv72 + } + case *sdk.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig_AuthMode_ServiceCredential: + if value != nil { + conv73, err := ModelProviderServiceConfig_ServiceCredentialFromSDK(&value.ServiceCredential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig.AuthMode", err) + } + out.ServiceCredential = conv73 + } + case *sdk.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig_AuthMode_EntraServicePrincipal: + if value != nil { + conv74, err := ModelProviderServiceConfig_EntraServicePrincipalFromSDK(&value.EntraServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig.AuthMode", err) + } + out.EntraServicePrincipal = conv74 + } + } + return out, nil +} + +// ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuthToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuthToSDK(w *ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuth) (*sdk.ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuth, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuth{} + out.ApiKeyName = w.ApiKeyName + conv75, err := ModelProviderServiceConfig_ProviderSecretToSDK(w.ApiKeyValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuth.ApiKeyValue", err) + } + out.ApiKeyValue = conv75 + return out, nil +} + +// ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuthFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuthFromSDK(v *sdk.ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuth) (*ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuth, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuth{} + out.ApiKeyName = v.ApiKeyName + conv76, err := ModelProviderServiceConfig_ProviderSecretFromSDK(v.ApiKeyValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuth.ApiKeyValue", err) + } + out.ApiKeyValue = conv76 + return out, nil +} + +// ModelProviderServiceConfig_CustomProviderConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_CustomProviderConfigToSDK(w *ModelProviderServiceConfig_CustomProviderConfig) (*sdk.ModelProviderServiceConfig_CustomProviderConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_CustomProviderConfig{} + { + var members []string + if w.Direct != nil { + members = append(members, "direct") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Direct != nil: + conv77, err := ModelProviderServiceConfig_CustomProviderDirectConfigToSDK(w.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_CustomProviderConfig.ProviderMode", err) + } + out.ProviderMode = &sdk.ModelProviderServiceConfig_CustomProviderConfig_ProviderMode_Direct{Direct: *conv77} + } + return out, nil +} + +// ModelProviderServiceConfig_CustomProviderConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_CustomProviderConfigFromSDK(v *sdk.ModelProviderServiceConfig_CustomProviderConfig) (*ModelProviderServiceConfig_CustomProviderConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_CustomProviderConfig{} + switch value := v.ProviderMode.(type) { + case *sdk.ModelProviderServiceConfig_CustomProviderConfig_ProviderMode_Direct: + if value != nil { + conv78, err := ModelProviderServiceConfig_CustomProviderDirectConfigFromSDK(&value.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_CustomProviderConfig.ProviderMode", err) + } + out.Direct = conv78 + } + } + return out, nil +} + +// ModelProviderServiceConfig_CustomProviderDirectConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_CustomProviderDirectConfigToSDK(w *ModelProviderServiceConfig_CustomProviderDirectConfig) (*sdk.ModelProviderServiceConfig_CustomProviderDirectConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_CustomProviderDirectConfig{} + out.BaseUrl = w.BaseUrl + { + var members []string + if w.ApiKey != nil { + members = append(members, "api_key") + } + if w.HeaderAuth != nil { + members = append(members, "header_auth") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ApiKey != nil: + conv79, err := ModelProviderServiceConfig_ProviderSecretToSDK(w.ApiKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_CustomProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_CustomProviderDirectConfig_AuthMode_ApiKey{ApiKey: *conv79} + case w.HeaderAuth != nil: + conv80, err := ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuthToSDK(w.HeaderAuth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_CustomProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_CustomProviderDirectConfig_AuthMode_HeaderAuth{HeaderAuth: *conv80} + } + return out, nil +} + +// ModelProviderServiceConfig_CustomProviderDirectConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_CustomProviderDirectConfigFromSDK(v *sdk.ModelProviderServiceConfig_CustomProviderDirectConfig) (*ModelProviderServiceConfig_CustomProviderDirectConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_CustomProviderDirectConfig{} + out.BaseUrl = v.BaseUrl + switch value := v.AuthMode.(type) { + case *sdk.ModelProviderServiceConfig_CustomProviderDirectConfig_AuthMode_ApiKey: + if value != nil { + conv81, err := ModelProviderServiceConfig_ProviderSecretFromSDK(&value.ApiKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_CustomProviderDirectConfig.AuthMode", err) + } + out.ApiKey = conv81 + } + case *sdk.ModelProviderServiceConfig_CustomProviderDirectConfig_AuthMode_HeaderAuth: + if value != nil { + conv82, err := ModelProviderServiceConfig_CustomProviderApiKeyHeaderAuthFromSDK(&value.HeaderAuth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_CustomProviderDirectConfig.AuthMode", err) + } + out.HeaderAuth = conv82 + } + } + return out, nil +} + +// ModelProviderServiceConfig_EntraServicePrincipalToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_EntraServicePrincipalToSDK(w *ModelProviderServiceConfig_EntraServicePrincipal) (*sdk.ModelProviderServiceConfig_EntraServicePrincipal, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_EntraServicePrincipal{} + out.TenantId = w.TenantId + out.ClientId = w.ClientId + { + var members []string + if w.ClientSecret != nil { + members = append(members, "client_secret") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ClientSecret != nil: + conv83, err := ModelProviderServiceConfig_ProviderSecretToSDK(w.ClientSecret) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_EntraServicePrincipal.Credential", err) + } + out.Credential = &sdk.ModelProviderServiceConfig_EntraServicePrincipal_Credential_ClientSecret{ClientSecret: *conv83} + } + return out, nil +} + +// ModelProviderServiceConfig_EntraServicePrincipalFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_EntraServicePrincipalFromSDK(v *sdk.ModelProviderServiceConfig_EntraServicePrincipal) (*ModelProviderServiceConfig_EntraServicePrincipal, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_EntraServicePrincipal{} + out.TenantId = v.TenantId + out.ClientId = v.ClientId + switch value := v.Credential.(type) { + case *sdk.ModelProviderServiceConfig_EntraServicePrincipal_Credential_ClientSecret: + if value != nil { + conv84, err := ModelProviderServiceConfig_ProviderSecretFromSDK(&value.ClientSecret) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_EntraServicePrincipal.Credential", err) + } + out.ClientSecret = conv84 + } + } + return out, nil +} + +// ModelProviderServiceConfig_GeminiEnterpriseProviderConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_GeminiEnterpriseProviderConfigToSDK(w *ModelProviderServiceConfig_GeminiEnterpriseProviderConfig) (*sdk.ModelProviderServiceConfig_GeminiEnterpriseProviderConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_GeminiEnterpriseProviderConfig{} + { + var members []string + if w.Direct != nil { + members = append(members, "direct") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Direct != nil: + conv85, err := ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfigToSDK(w.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_GeminiEnterpriseProviderConfig.ProviderMode", err) + } + out.ProviderMode = &sdk.ModelProviderServiceConfig_GeminiEnterpriseProviderConfig_ProviderMode_Direct{Direct: *conv85} + } + return out, nil +} + +// ModelProviderServiceConfig_GeminiEnterpriseProviderConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_GeminiEnterpriseProviderConfigFromSDK(v *sdk.ModelProviderServiceConfig_GeminiEnterpriseProviderConfig) (*ModelProviderServiceConfig_GeminiEnterpriseProviderConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_GeminiEnterpriseProviderConfig{} + switch value := v.ProviderMode.(type) { + case *sdk.ModelProviderServiceConfig_GeminiEnterpriseProviderConfig_ProviderMode_Direct: + if value != nil { + conv86, err := ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfigFromSDK(&value.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_GeminiEnterpriseProviderConfig.ProviderMode", err) + } + out.Direct = conv86 + } + } + return out, nil +} + +// ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfigToSDK(w *ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig) (*sdk.ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig{} + { + var members []string + if w.ApiKey != nil { + members = append(members, "api_key") + } + if w.ServiceCredential != nil { + members = append(members, "service_credential") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ApiKey != nil: + conv87, err := ModelProviderServiceConfig_ProviderSecretToSDK(w.ApiKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig_AuthMode_ApiKey{ApiKey: *conv87} + case w.ServiceCredential != nil: + conv88, err := ModelProviderServiceConfig_ServiceCredentialToSDK(w.ServiceCredential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig_AuthMode_ServiceCredential{ServiceCredential: *conv88} + } + out.ProjectId = w.ProjectId + out.Region = w.Region + return out, nil +} + +// ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfigFromSDK(v *sdk.ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig) (*ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig{} + switch value := v.AuthMode.(type) { + case *sdk.ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig_AuthMode_ApiKey: + if value != nil { + conv89, err := ModelProviderServiceConfig_ProviderSecretFromSDK(&value.ApiKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig.AuthMode", err) + } + out.ApiKey = conv89 + } + case *sdk.ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig_AuthMode_ServiceCredential: + if value != nil { + conv90, err := ModelProviderServiceConfig_ServiceCredentialFromSDK(&value.ServiceCredential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig.AuthMode", err) + } + out.ServiceCredential = conv90 + } + } + out.ProjectId = v.ProjectId + out.Region = v.Region + return out, nil +} + +// ModelProviderServiceConfig_MicrosoftFoundryProviderConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_MicrosoftFoundryProviderConfigToSDK(w *ModelProviderServiceConfig_MicrosoftFoundryProviderConfig) (*sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderConfig{} + { + var members []string + if w.Direct != nil { + members = append(members, "direct") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Direct != nil: + conv91, err := ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfigToSDK(w.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_MicrosoftFoundryProviderConfig.ProviderMode", err) + } + out.ProviderMode = &sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderConfig_ProviderMode_Direct{Direct: *conv91} + } + return out, nil +} + +// ModelProviderServiceConfig_MicrosoftFoundryProviderConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_MicrosoftFoundryProviderConfigFromSDK(v *sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderConfig) (*ModelProviderServiceConfig_MicrosoftFoundryProviderConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_MicrosoftFoundryProviderConfig{} + switch value := v.ProviderMode.(type) { + case *sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderConfig_ProviderMode_Direct: + if value != nil { + conv92, err := ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfigFromSDK(&value.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_MicrosoftFoundryProviderConfig.ProviderMode", err) + } + out.Direct = conv92 + } + } + return out, nil +} + +// ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfigToSDK(w *ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig) (*sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig{} + out.BaseUrl = w.BaseUrl + { + var members []string + if w.ApiKey != nil { + members = append(members, "api_key") + } + if w.ServiceCredential != nil { + members = append(members, "service_credential") + } + if w.EntraServicePrincipal != nil { + members = append(members, "entra_service_principal") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ApiKey != nil: + conv93, err := ModelProviderServiceConfig_ProviderSecretToSDK(w.ApiKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig_AuthMode_ApiKey{ApiKey: *conv93} + case w.ServiceCredential != nil: + conv94, err := ModelProviderServiceConfig_ServiceCredentialToSDK(w.ServiceCredential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig_AuthMode_ServiceCredential{ServiceCredential: *conv94} + case w.EntraServicePrincipal != nil: + conv95, err := ModelProviderServiceConfig_EntraServicePrincipalToSDK(w.EntraServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig_AuthMode_EntraServicePrincipal{EntraServicePrincipal: *conv95} + } + return out, nil +} + +// ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfigFromSDK(v *sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig) (*ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig{} + out.BaseUrl = v.BaseUrl + switch value := v.AuthMode.(type) { + case *sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig_AuthMode_ApiKey: + if value != nil { + conv96, err := ModelProviderServiceConfig_ProviderSecretFromSDK(&value.ApiKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig.AuthMode", err) + } + out.ApiKey = conv96 + } + case *sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig_AuthMode_ServiceCredential: + if value != nil { + conv97, err := ModelProviderServiceConfig_ServiceCredentialFromSDK(&value.ServiceCredential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig.AuthMode", err) + } + out.ServiceCredential = conv97 + } + case *sdk.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig_AuthMode_EntraServicePrincipal: + if value != nil { + conv98, err := ModelProviderServiceConfig_EntraServicePrincipalFromSDK(&value.EntraServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig.AuthMode", err) + } + out.EntraServicePrincipal = conv98 + } + } + return out, nil +} + +// ModelProviderServiceConfig_ModelTargetConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_ModelTargetConfigToSDK(w *ModelProviderServiceConfig_ModelTargetConfig) (*sdk.ModelProviderServiceConfig_ModelTargetConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_ModelTargetConfig{} + out.Model = w.Model + out.NativeApiTypes = w.NativeApiTypes + out.EndpointRoute = w.EndpointRoute + return out, nil +} + +// ModelProviderServiceConfig_ModelTargetConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_ModelTargetConfigFromSDK(v *sdk.ModelProviderServiceConfig_ModelTargetConfig) (*ModelProviderServiceConfig_ModelTargetConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_ModelTargetConfig{} + out.Model = v.Model + out.NativeApiTypes = v.NativeApiTypes + out.EndpointRoute = v.EndpointRoute + return out, nil +} + +// ModelProviderServiceConfig_OpenAiProviderConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_OpenAiProviderConfigToSDK(w *ModelProviderServiceConfig_OpenAiProviderConfig) (*sdk.ModelProviderServiceConfig_OpenAiProviderConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_OpenAiProviderConfig{} + { + var members []string + if w.Direct != nil { + members = append(members, "direct") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Direct != nil: + conv99, err := ModelProviderServiceConfig_OpenAiProviderDirectConfigToSDK(w.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_OpenAiProviderConfig.ProviderMode", err) + } + out.ProviderMode = &sdk.ModelProviderServiceConfig_OpenAiProviderConfig_ProviderMode_Direct{Direct: *conv99} + } + return out, nil +} + +// ModelProviderServiceConfig_OpenAiProviderConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_OpenAiProviderConfigFromSDK(v *sdk.ModelProviderServiceConfig_OpenAiProviderConfig) (*ModelProviderServiceConfig_OpenAiProviderConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_OpenAiProviderConfig{} + switch value := v.ProviderMode.(type) { + case *sdk.ModelProviderServiceConfig_OpenAiProviderConfig_ProviderMode_Direct: + if value != nil { + conv100, err := ModelProviderServiceConfig_OpenAiProviderDirectConfigFromSDK(&value.Direct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_OpenAiProviderConfig.ProviderMode", err) + } + out.Direct = conv100 + } + } + return out, nil +} + +// ModelProviderServiceConfig_OpenAiProviderDirectConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_OpenAiProviderDirectConfigToSDK(w *ModelProviderServiceConfig_OpenAiProviderDirectConfig) (*sdk.ModelProviderServiceConfig_OpenAiProviderDirectConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_OpenAiProviderDirectConfig{} + { + var members []string + if w.ApiKey != nil { + members = append(members, "api_key") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ApiKey != nil: + conv101, err := ModelProviderServiceConfig_ProviderSecretToSDK(w.ApiKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_OpenAiProviderDirectConfig.AuthMode", err) + } + out.AuthMode = &sdk.ModelProviderServiceConfig_OpenAiProviderDirectConfig_AuthMode_ApiKey{ApiKey: *conv101} + } + out.Organization = w.Organization + out.BaseUrl = w.BaseUrl + return out, nil +} + +// ModelProviderServiceConfig_OpenAiProviderDirectConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_OpenAiProviderDirectConfigFromSDK(v *sdk.ModelProviderServiceConfig_OpenAiProviderDirectConfig) (*ModelProviderServiceConfig_OpenAiProviderDirectConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_OpenAiProviderDirectConfig{} + switch value := v.AuthMode.(type) { + case *sdk.ModelProviderServiceConfig_OpenAiProviderDirectConfig_AuthMode_ApiKey: + if value != nil { + conv102, err := ModelProviderServiceConfig_ProviderSecretFromSDK(&value.ApiKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_OpenAiProviderDirectConfig.AuthMode", err) + } + out.ApiKey = conv102 + } + } + out.Organization = v.Organization + out.BaseUrl = v.BaseUrl + return out, nil +} + +// ModelProviderServiceConfig_ProviderPricingConfigToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_ProviderPricingConfigToSDK(w *ModelProviderServiceConfig_ProviderPricingConfig) (*sdk.ModelProviderServiceConfig_ProviderPricingConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_ProviderPricingConfig{} + out.DefaultDiscountBasisPoints = w.DefaultDiscountBasisPoints + return out, nil +} + +// ModelProviderServiceConfig_ProviderPricingConfigFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_ProviderPricingConfigFromSDK(v *sdk.ModelProviderServiceConfig_ProviderPricingConfig) (*ModelProviderServiceConfig_ProviderPricingConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_ProviderPricingConfig{} + out.DefaultDiscountBasisPoints = v.DefaultDiscountBasisPoints + return out, nil +} + +// ModelProviderServiceConfig_ProviderSecretToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_ProviderSecretToSDK(w *ModelProviderServiceConfig_ProviderSecret) (*sdk.ModelProviderServiceConfig_ProviderSecret, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_ProviderSecret{} + { + var members []string + if w.Plaintext != nil { + members = append(members, "plaintext") + } + if w.SecretReference != nil { + members = append(members, "secret_reference") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Plaintext != nil: + out.Value = &sdk.ModelProviderServiceConfig_ProviderSecret_Value_Plaintext{Plaintext: *w.Plaintext} + case w.SecretReference != nil: + conv103, err := ModelProviderServiceConfig_SecretReferenceToSDK(w.SecretReference) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_ProviderSecret.Value", err) + } + out.Value = &sdk.ModelProviderServiceConfig_ProviderSecret_Value_SecretReference{SecretReference: *conv103} + } + return out, nil +} + +// ModelProviderServiceConfig_ProviderSecretFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_ProviderSecretFromSDK(v *sdk.ModelProviderServiceConfig_ProviderSecret) (*ModelProviderServiceConfig_ProviderSecret, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_ProviderSecret{} + switch value := v.Value.(type) { + case *sdk.ModelProviderServiceConfig_ProviderSecret_Value_Plaintext: + if value != nil { + out.Plaintext = new(value.Plaintext) + } + case *sdk.ModelProviderServiceConfig_ProviderSecret_Value_SecretReference: + if value != nil { + conv104, err := ModelProviderServiceConfig_SecretReferenceFromSDK(&value.SecretReference) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelProviderServiceConfig_ProviderSecret.Value", err) + } + out.SecretReference = conv104 + } + } + return out, nil +} + +// ModelProviderServiceConfig_SecretReferenceToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_SecretReferenceToSDK(w *ModelProviderServiceConfig_SecretReference) (*sdk.ModelProviderServiceConfig_SecretReference, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_SecretReference{} + out.Name = w.Name + return out, nil +} + +// ModelProviderServiceConfig_SecretReferenceFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_SecretReferenceFromSDK(v *sdk.ModelProviderServiceConfig_SecretReference) (*ModelProviderServiceConfig_SecretReference, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_SecretReference{} + out.Name = v.Name + return out, nil +} + +// ModelProviderServiceConfig_ServiceCredentialToSDK converts the mirror to the sdk-go type. +func ModelProviderServiceConfig_ServiceCredentialToSDK(w *ModelProviderServiceConfig_ServiceCredential) (*sdk.ModelProviderServiceConfig_ServiceCredential, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelProviderServiceConfig_ServiceCredential{} + out.Name = w.Name + return out, nil +} + +// ModelProviderServiceConfig_ServiceCredentialFromSDK converts the sdk-go type to the mirror. +func ModelProviderServiceConfig_ServiceCredentialFromSDK(v *sdk.ModelProviderServiceConfig_ServiceCredential) (*ModelProviderServiceConfig_ServiceCredential, error) { + if v == nil { + return nil, nil + } + out := &ModelProviderServiceConfig_ServiceCredential{} + out.Name = v.Name + return out, nil +} + +// ModelServiceToSDK converts the mirror to the sdk-go type. +func ModelServiceToSDK(w *ModelService) (*sdk.ModelService, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelService{} + out.Name = w.Name + out.EffectiveOwner = w.EffectiveOwner + out.MetastoreId = w.MetastoreId + out.CreateTime = w.CreateTime + out.CreatedBy = w.CreatedBy + out.UpdateTime = w.UpdateTime + out.UpdatedBy = w.UpdatedBy + out.Comment = w.Comment + conv105, err := ModelServiceConfigToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelService.Config", err) + } + out.Config = conv105 + out.Etag = w.Etag + out.SupportedApiTypes = w.SupportedApiTypes + return out, nil +} + +// ModelServiceFromSDK converts the sdk-go type to the mirror. +func ModelServiceFromSDK(v *sdk.ModelService) (*ModelService, error) { + if v == nil { + return nil, nil + } + out := &ModelService{} + out.Name = v.Name + out.EffectiveOwner = v.EffectiveOwner + out.MetastoreId = v.MetastoreId + out.CreateTime = v.CreateTime + out.CreatedBy = v.CreatedBy + out.UpdateTime = v.UpdateTime + out.UpdatedBy = v.UpdatedBy + out.Comment = v.Comment + conv106, err := ModelServiceConfigFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelService.Config", err) + } + out.Config = conv106 + out.Etag = v.Etag + out.SupportedApiTypes = v.SupportedApiTypes + return out, nil +} + +// ModelServiceConfigToSDK converts the mirror to the sdk-go type. +func ModelServiceConfigToSDK(w *ModelServiceConfig) (*sdk.ModelServiceConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelServiceConfig{} + conv107, err := ModelServiceConfig_RoutingConfigToSDK(w.Routing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig.Routing", err) + } + out.Routing = conv107 + conv108, err := convertSlice(w.RateLimits, RateLimitToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig.RateLimits", err) + } + out.RateLimits = conv108 + conv109, err := InferenceTableConfigToSDK(w.InferenceTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig.InferenceTable", err) + } + out.InferenceTable = conv109 + return out, nil +} + +// ModelServiceConfigFromSDK converts the sdk-go type to the mirror. +func ModelServiceConfigFromSDK(v *sdk.ModelServiceConfig) (*ModelServiceConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelServiceConfig{} + conv110, err := ModelServiceConfig_RoutingConfigFromSDK(v.Routing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig.Routing", err) + } + out.Routing = conv110 + conv111, err := convertSlice(v.RateLimits, RateLimitFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig.RateLimits", err) + } + out.RateLimits = conv111 + conv112, err := InferenceTableConfigFromSDK(v.InferenceTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig.InferenceTable", err) + } + out.InferenceTable = conv112 + return out, nil +} + +// ModelServiceConfig_DestinationConfigToSDK converts the mirror to the sdk-go type. +func ModelServiceConfig_DestinationConfigToSDK(w *ModelServiceConfig_DestinationConfig) (*sdk.ModelServiceConfig_DestinationConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelServiceConfig_DestinationConfig{} + out.Name = w.Name + out.DestinationType = w.DestinationType + out.TrafficPercentage = w.TrafficPercentage + { + var members []string + if w.PayPerTokenConfig != nil { + members = append(members, "pay_per_token_config") + } + if w.ProvisionedThroughputConfig != nil { + members = append(members, "provisioned_throughput_config") + } + if w.ExternalModelConfig != nil { + members = append(members, "external_model_config") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.PayPerTokenConfig != nil: + conv113, err := ModelServiceConfig_PayPerTokenConfigToSDK(w.PayPerTokenConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_DestinationConfig.TypeConfig", err) + } + out.TypeConfig = &sdk.ModelServiceConfig_DestinationConfig_TypeConfig_PayPerTokenConfig{PayPerTokenConfig: *conv113} + case w.ProvisionedThroughputConfig != nil: + conv114, err := ModelServiceConfig_ProvisionedThroughputConfigToSDK(w.ProvisionedThroughputConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_DestinationConfig.TypeConfig", err) + } + out.TypeConfig = &sdk.ModelServiceConfig_DestinationConfig_TypeConfig_ProvisionedThroughputConfig{ProvisionedThroughputConfig: *conv114} + case w.ExternalModelConfig != nil: + conv115, err := ModelServiceConfig_ExternalModelConfigToSDK(w.ExternalModelConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_DestinationConfig.TypeConfig", err) + } + out.TypeConfig = &sdk.ModelServiceConfig_DestinationConfig_TypeConfig_ExternalModelConfig{ExternalModelConfig: *conv115} + } + out.IsDeleted = w.IsDeleted + return out, nil +} + +// ModelServiceConfig_DestinationConfigFromSDK converts the sdk-go type to the mirror. +func ModelServiceConfig_DestinationConfigFromSDK(v *sdk.ModelServiceConfig_DestinationConfig) (*ModelServiceConfig_DestinationConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelServiceConfig_DestinationConfig{} + out.Name = v.Name + out.DestinationType = v.DestinationType + out.TrafficPercentage = v.TrafficPercentage + switch value := v.TypeConfig.(type) { + case *sdk.ModelServiceConfig_DestinationConfig_TypeConfig_PayPerTokenConfig: + if value != nil { + conv116, err := ModelServiceConfig_PayPerTokenConfigFromSDK(&value.PayPerTokenConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_DestinationConfig.TypeConfig", err) + } + out.PayPerTokenConfig = conv116 + } + case *sdk.ModelServiceConfig_DestinationConfig_TypeConfig_ProvisionedThroughputConfig: + if value != nil { + conv117, err := ModelServiceConfig_ProvisionedThroughputConfigFromSDK(&value.ProvisionedThroughputConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_DestinationConfig.TypeConfig", err) + } + out.ProvisionedThroughputConfig = conv117 + } + case *sdk.ModelServiceConfig_DestinationConfig_TypeConfig_ExternalModelConfig: + if value != nil { + conv118, err := ModelServiceConfig_ExternalModelConfigFromSDK(&value.ExternalModelConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_DestinationConfig.TypeConfig", err) + } + out.ExternalModelConfig = conv118 + } + } + out.IsDeleted = v.IsDeleted + return out, nil +} + +// ModelServiceConfig_ExternalModelConfigToSDK converts the mirror to the sdk-go type. +func ModelServiceConfig_ExternalModelConfigToSDK(w *ModelServiceConfig_ExternalModelConfig) (*sdk.ModelServiceConfig_ExternalModelConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelServiceConfig_ExternalModelConfig{} + out.ModelProviderService = w.ModelProviderService + conv119, err := ModelProviderServiceConfig_ModelTargetConfigToSDK(w.Target) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_ExternalModelConfig.Target", err) + } + out.Target = conv119 + return out, nil +} + +// ModelServiceConfig_ExternalModelConfigFromSDK converts the sdk-go type to the mirror. +func ModelServiceConfig_ExternalModelConfigFromSDK(v *sdk.ModelServiceConfig_ExternalModelConfig) (*ModelServiceConfig_ExternalModelConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelServiceConfig_ExternalModelConfig{} + out.ModelProviderService = v.ModelProviderService + conv120, err := ModelProviderServiceConfig_ModelTargetConfigFromSDK(v.Target) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_ExternalModelConfig.Target", err) + } + out.Target = conv120 + return out, nil +} + +// ModelServiceConfig_FallbackConfigToSDK converts the mirror to the sdk-go type. +func ModelServiceConfig_FallbackConfigToSDK(w *ModelServiceConfig_FallbackConfig) (*sdk.ModelServiceConfig_FallbackConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelServiceConfig_FallbackConfig{} + conv121, err := convertSlice(w.Destinations, ModelServiceConfig_DestinationConfigToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_FallbackConfig.Destinations", err) + } + out.Destinations = conv121 + return out, nil +} + +// ModelServiceConfig_FallbackConfigFromSDK converts the sdk-go type to the mirror. +func ModelServiceConfig_FallbackConfigFromSDK(v *sdk.ModelServiceConfig_FallbackConfig) (*ModelServiceConfig_FallbackConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelServiceConfig_FallbackConfig{} + conv122, err := convertSlice(v.Destinations, ModelServiceConfig_DestinationConfigFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_FallbackConfig.Destinations", err) + } + out.Destinations = conv122 + return out, nil +} + +// ModelServiceConfig_PayPerTokenConfigToSDK converts the mirror to the sdk-go type. +func ModelServiceConfig_PayPerTokenConfigToSDK(w *ModelServiceConfig_PayPerTokenConfig) (*sdk.ModelServiceConfig_PayPerTokenConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelServiceConfig_PayPerTokenConfig{} + out.Model = w.Model + return out, nil +} + +// ModelServiceConfig_PayPerTokenConfigFromSDK converts the sdk-go type to the mirror. +func ModelServiceConfig_PayPerTokenConfigFromSDK(v *sdk.ModelServiceConfig_PayPerTokenConfig) (*ModelServiceConfig_PayPerTokenConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelServiceConfig_PayPerTokenConfig{} + out.Model = v.Model + return out, nil +} + +// ModelServiceConfig_ProvisionedThroughputConfigToSDK converts the mirror to the sdk-go type. +func ModelServiceConfig_ProvisionedThroughputConfigToSDK(w *ModelServiceConfig_ProvisionedThroughputConfig) (*sdk.ModelServiceConfig_ProvisionedThroughputConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelServiceConfig_ProvisionedThroughputConfig{} + out.ModelServingEndpoint = w.ModelServingEndpoint + out.Model = w.Model + return out, nil +} + +// ModelServiceConfig_ProvisionedThroughputConfigFromSDK converts the sdk-go type to the mirror. +func ModelServiceConfig_ProvisionedThroughputConfigFromSDK(v *sdk.ModelServiceConfig_ProvisionedThroughputConfig) (*ModelServiceConfig_ProvisionedThroughputConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelServiceConfig_ProvisionedThroughputConfig{} + out.ModelServingEndpoint = v.ModelServingEndpoint + out.Model = v.Model + return out, nil +} + +// ModelServiceConfig_RoutingConfigToSDK converts the mirror to the sdk-go type. +func ModelServiceConfig_RoutingConfigToSDK(w *ModelServiceConfig_RoutingConfig) (*sdk.ModelServiceConfig_RoutingConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelServiceConfig_RoutingConfig{} + conv123, err := convertSlice(w.Destinations, ModelServiceConfig_DestinationConfigToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_RoutingConfig.Destinations", err) + } + out.Destinations = conv123 + conv124, err := ModelServiceConfig_FallbackConfigToSDK(w.Fallback) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_RoutingConfig.Fallback", err) + } + out.Fallback = conv124 + return out, nil +} + +// ModelServiceConfig_RoutingConfigFromSDK converts the sdk-go type to the mirror. +func ModelServiceConfig_RoutingConfigFromSDK(v *sdk.ModelServiceConfig_RoutingConfig) (*ModelServiceConfig_RoutingConfig, error) { + if v == nil { + return nil, nil + } + out := &ModelServiceConfig_RoutingConfig{} + conv125, err := convertSlice(v.Destinations, ModelServiceConfig_DestinationConfigFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_RoutingConfig.Destinations", err) + } + out.Destinations = conv125 + conv126, err := ModelServiceConfig_FallbackConfigFromSDK(v.Fallback) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelServiceConfig_RoutingConfig.Fallback", err) + } + out.Fallback = conv126 + return out, nil +} + +// ProvisioningInfoToSDK converts the mirror to the sdk-go type. +func ProvisioningInfoToSDK(w *ProvisioningInfo) (*sdk.ProvisioningInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProvisioningInfo{} + out.State = w.State + return out, nil +} + +// ProvisioningInfoFromSDK converts the sdk-go type to the mirror. +func ProvisioningInfoFromSDK(v *sdk.ProvisioningInfo) (*ProvisioningInfo, error) { + if v == nil { + return nil, nil + } + out := &ProvisioningInfo{} + out.State = v.State + return out, nil +} + +// RateLimitToSDK converts the mirror to the sdk-go type. +func RateLimitToSDK(w *RateLimit) (*sdk.RateLimit, error) { + if w == nil { + return nil, nil + } + out := &sdk.RateLimit{} + out.Key = w.Key + out.RenewalPeriod = w.RenewalPeriod + out.Principal = w.Principal + out.Requests = w.Requests + out.Tokens = w.Tokens + return out, nil +} + +// RateLimitFromSDK converts the sdk-go type to the mirror. +func RateLimitFromSDK(v *sdk.RateLimit) (*RateLimit, error) { + if v == nil { + return nil, nil + } + out := &RateLimit{} + out.Key = v.Key + out.RenewalPeriod = v.RenewalPeriod + out.Principal = v.Principal + out.Requests = v.Requests + out.Tokens = v.Tokens + return out, nil +} + +// SkillToSDK converts the mirror to the sdk-go type. +func SkillToSDK(w *Skill) (*sdk.Skill, error) { + if w == nil { + return nil, nil + } + out := &sdk.Skill{} + out.Name = w.Name + out.BundleName = w.BundleName + out.Description = w.Description + out.Etag = w.Etag + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.FinalizeTime = w.FinalizeTime + out.CreatedBy = w.CreatedBy + out.UpdatedBy = w.UpdatedBy + out.EffectiveOwner = w.EffectiveOwner + out.MetastoreId = w.MetastoreId + out.Comment = w.Comment + return out, nil +} + +// SkillFromSDK converts the sdk-go type to the mirror. +func SkillFromSDK(v *sdk.Skill) (*Skill, error) { + if v == nil { + return nil, nil + } + out := &Skill{} + out.Name = v.Name + out.BundleName = v.BundleName + out.Description = v.Description + out.Etag = v.Etag + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.FinalizeTime = v.FinalizeTime + out.CreatedBy = v.CreatedBy + out.UpdatedBy = v.UpdatedBy + out.EffectiveOwner = v.EffectiveOwner + out.MetastoreId = v.MetastoreId + out.Comment = v.Comment + return out, nil +} + +// UpdateMcpServiceRequestToSDK converts the mirror to the sdk-go type. +func UpdateMcpServiceRequestToSDK(w *UpdateMcpServiceRequest) (*sdk.UpdateMcpServiceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateMcpServiceRequest{} + conv127, err := McpServiceToSDK(w.McpService) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateMcpServiceRequest.McpService", err) + } + out.McpService = conv127 + mask128, err := fieldMaskFromString[sdk.McpService](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateMcpServiceRequest.UpdateMask", err) + } + out.UpdateMask = mask128 + out.Etag = w.Etag + return out, nil +} + +// UpdateMcpServiceRequestFromSDK converts the sdk-go type to the mirror. +func UpdateMcpServiceRequestFromSDK(v *sdk.UpdateMcpServiceRequest) (*UpdateMcpServiceRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateMcpServiceRequest{} + conv129, err := McpServiceFromSDK(v.McpService) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateMcpServiceRequest.McpService", err) + } + out.McpService = conv129 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + out.Etag = v.Etag + return out, nil +} + +// UpdateModelProviderServiceRequestToSDK converts the mirror to the sdk-go type. +func UpdateModelProviderServiceRequestToSDK(w *UpdateModelProviderServiceRequest) (*sdk.UpdateModelProviderServiceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateModelProviderServiceRequest{} + conv130, err := ModelProviderServiceToSDK(w.ModelProviderService) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateModelProviderServiceRequest.ModelProviderService", err) + } + out.ModelProviderService = conv130 + mask131, err := fieldMaskFromString[sdk.ModelProviderService](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateModelProviderServiceRequest.UpdateMask", err) + } + out.UpdateMask = mask131 + out.Etag = w.Etag + return out, nil +} + +// UpdateModelProviderServiceRequestFromSDK converts the sdk-go type to the mirror. +func UpdateModelProviderServiceRequestFromSDK(v *sdk.UpdateModelProviderServiceRequest) (*UpdateModelProviderServiceRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateModelProviderServiceRequest{} + conv132, err := ModelProviderServiceFromSDK(v.ModelProviderService) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateModelProviderServiceRequest.ModelProviderService", err) + } + out.ModelProviderService = conv132 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + out.Etag = v.Etag + return out, nil +} + +// UpdateModelServiceRequestToSDK converts the mirror to the sdk-go type. +func UpdateModelServiceRequestToSDK(w *UpdateModelServiceRequest) (*sdk.UpdateModelServiceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateModelServiceRequest{} + conv133, err := ModelServiceToSDK(w.ModelService) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateModelServiceRequest.ModelService", err) + } + out.ModelService = conv133 + mask134, err := fieldMaskFromString[sdk.ModelService](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateModelServiceRequest.UpdateMask", err) + } + out.UpdateMask = mask134 + out.Etag = w.Etag + return out, nil +} + +// UpdateModelServiceRequestFromSDK converts the sdk-go type to the mirror. +func UpdateModelServiceRequestFromSDK(v *sdk.UpdateModelServiceRequest) (*UpdateModelServiceRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateModelServiceRequest{} + conv135, err := ModelServiceFromSDK(v.ModelService) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateModelServiceRequest.ModelService", err) + } + out.ModelService = conv135 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + out.Etag = v.Etag + return out, nil +} + +// UpdateSkillRequestToSDK converts the mirror to the sdk-go type. +func UpdateSkillRequestToSDK(w *UpdateSkillRequest) (*sdk.UpdateSkillRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateSkillRequest{} + conv136, err := SkillToSDK(w.Skill) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSkillRequest.Skill", err) + } + out.Skill = conv136 + mask137, err := fieldMaskFromString[sdk.Skill](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSkillRequest.UpdateMask", err) + } + out.UpdateMask = mask137 + out.Etag = w.Etag + return out, nil +} + +// UpdateSkillRequestFromSDK converts the sdk-go type to the mirror. +func UpdateSkillRequestFromSDK(v *sdk.UpdateSkillRequest) (*UpdateSkillRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateSkillRequest{} + conv138, err := SkillFromSDK(v.Skill) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSkillRequest.Skill", err) + } + out.Skill = conv138 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + out.Etag = v.Etag + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/aisearch/v1/types.generated.go b/libs/sdktypes/aisearch/v1/types.generated.go new file mode 100644 index 00000000000..75b5764f3ed --- /dev/null +++ b/libs/sdktypes/aisearch/v1/types.generated.go @@ -0,0 +1,1670 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/aisearch/v1. DO NOT EDIT. + +package aisearch + +import ( + json "encoding/json" + fmt "fmt" + sdk "github.com/databricks/sdk-go/aisearch/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + DataModificationStatus = sdk.DataModificationStatus + EndpointType = sdk.EndpointType + IndexSubtype = sdk.IndexSubtype + IndexType = sdk.IndexType + PipelineType = sdk.PipelineType + ScalingChangeState = sdk.ScalingChangeState + ThroughputChangeRequestState = sdk.ThroughputChangeRequestState + EndpointStatus_State = sdk.EndpointStatus_State + RerankerConfig_ModelType = sdk.RerankerConfig_ModelType +) + +const ( + DataModificationStatus_Unspecified = sdk.DataModificationStatus_Unspecified + DataModificationStatus_PartialSuccess = sdk.DataModificationStatus_PartialSuccess + DataModificationStatus_Failure = sdk.DataModificationStatus_Failure + EndpointType_Unspecified = sdk.EndpointType_Unspecified + EndpointType_StorageOptimized = sdk.EndpointType_StorageOptimized + EndpointType_Standard = sdk.EndpointType_Standard + IndexSubtype_Unspecified = sdk.IndexSubtype_Unspecified + IndexSubtype_FullText = sdk.IndexSubtype_FullText + IndexSubtype_Hybrid = sdk.IndexSubtype_Hybrid + IndexType_Unspecified = sdk.IndexType_Unspecified + IndexType_DirectAccess = sdk.IndexType_DirectAccess + PipelineType_Unspecified = sdk.PipelineType_Unspecified + PipelineType_Triggered = sdk.PipelineType_Triggered + PipelineType_Continuous = sdk.PipelineType_Continuous + ScalingChangeState_Unspecified = sdk.ScalingChangeState_Unspecified + ScalingChangeState_ScalingChangeApplied = sdk.ScalingChangeState_ScalingChangeApplied + ScalingChangeState_ScalingChangeInProgress = sdk.ScalingChangeState_ScalingChangeInProgress + ThroughputChangeRequestState_Unspecified = sdk.ThroughputChangeRequestState_Unspecified + ThroughputChangeRequestState_ChangeFailed = sdk.ThroughputChangeRequestState_ChangeFailed + ThroughputChangeRequestState_ChangeReachedMinimum = sdk.ThroughputChangeRequestState_ChangeReachedMinimum + ThroughputChangeRequestState_ChangeReachedMaximum = sdk.ThroughputChangeRequestState_ChangeReachedMaximum + ThroughputChangeRequestState_ChangeInProgress = sdk.ThroughputChangeRequestState_ChangeInProgress + ThroughputChangeRequestState_ChangeAdjusted = sdk.ThroughputChangeRequestState_ChangeAdjusted + EndpointStatus_State_Unspecified = sdk.EndpointStatus_State_Unspecified + EndpointStatus_State_Online = sdk.EndpointStatus_State_Online + EndpointStatus_State_Offline = sdk.EndpointStatus_State_Offline + EndpointStatus_State_RedState = sdk.EndpointStatus_State_RedState + EndpointStatus_State_YellowState = sdk.EndpointStatus_State_YellowState + EndpointStatus_State_Deleted = sdk.EndpointStatus_State_Deleted + RerankerConfig_ModelType_Unspecified = sdk.RerankerConfig_ModelType_Unspecified + RerankerConfig_ModelType_ModelTypeBase = sdk.RerankerConfig_ModelType_ModelTypeBase + RerankerConfig_ModelType_ModelTypeFinetuned = sdk.RerankerConfig_ModelType_ModelTypeFinetuned +) + +// Column information (name and data type) for an index column. Surfaced on +// `Index.column_info`.. +type ColumnInfo struct { + // Name of the column. + Name *string `json:"name,omitempty"` + // Data type of the column (e.g., "string", "int", "array"). + TypeText *string `json:"type_text,omitempty"` +} + +// AIP-133 conformant Create. The endpoint is nested under `endpoint`; `parent` +// carries the workspace path; `endpoint_id` is the user-supplied short name. +// The server composes `Endpoint.name` from `parent` and `endpoint_id`; any +// client-supplied `endpoint.name` is ignored.. +type CreateEndpointRequest struct { + // The Endpoint resource to create. Fields other than `endpoint.name` carry the + // desired configuration; `endpoint.name` is server-assigned from `parent` and + // `endpoint_id`. + Endpoint *Endpoint `json:"endpoint,omitempty"` + // The user-supplied short name for the Endpoint, per AIP-133. The server + // composes the full `Endpoint.name` as `{parent}/endpoints/{endpoint_id}`. + // AIP-133 does not list `endpoint_id` as a fields-may-be-required entry, so we + // annotate it OPTIONAL on the wire; the server still rejects empty values with + // INVALID_PARAMETER_VALUE. + EndpointId *string `json:"endpoint_id,omitempty"` + // The Workspace where this Endpoint will be created. Format: + // `workspaces/{workspace_id}` + Parent *string `json:"parent,omitempty"` +} + +// AIP-133 conformant Create. The index is nested under `index`; `parent` +// carries the endpoint path; `index_id` is the user-supplied Unity Catalog +// table name. The server composes `Index.name` from `parent` and `index_id`; +// any client-supplied `index.name` is ignored.. +type CreateIndexRequest struct { + // The Index resource to create. Fields other than `index.name` carry the + // desired configuration; `index.name` is server-assigned from `parent` and + // `index_id`. + Index *Index `json:"index,omitempty"` + // The user-supplied Unity Catalog table name for the Index, per AIP-133. The + // server composes the full `Index.name` as `{parent}/indexes/{index_id}`. + // AIP-133 does not list `index_id` as a fields-may-be-required entry, so we + // annotate it OPTIONAL on the wire; the server still rejects empty values with + // INVALID_PARAMETER_VALUE. + IndexId *string `json:"index_id,omitempty"` + // The Endpoint where this Index will be created. Format: + // `workspaces/{workspace_id}/endpoints/{endpoint_id}` + Parent *string `json:"parent,omitempty"` +} + +// User-defined key/value tag attached to an AI Search endpoint for cost +// attribution and access control.. +type CustomTag struct { + // Key field for an AI Search endpoint tag. + Key *string `json:"key,omitempty"` + // [Optional] Value field for an AI Search endpoint tag. + Value *string `json:"value,omitempty"` +} + +// Per-row outcome of a data-plane upsert or delete operation.. +type DataModificationResult struct { + // Primary keys of rows that failed to process. + FailedPrimaryKeys []string `json:"failed_primary_keys,omitempty"` + // Count of rows processed successfully. + SuccessRowCount *int64 `json:"success_row_count,omitempty"` +} + +// Specification for a Delta Sync index — the index is kept in sync with a +// source Delta table.. +type DeltaSyncIndexSpec struct { + // [Optional] Select the columns to sync with the index. If left blank, all + // columns from the source table are synced. The primary key column and + // embedding source or vector column are always synced. + ColumnsToSync []string `json:"columns_to_sync,omitempty"` + // The columns that contain the embedding source. + EmbeddingSourceColumns []EmbeddingSourceColumn `json:"embedding_source_columns,omitempty"` + // The columns that contain the embedding vectors. + EmbeddingVectorColumns []EmbeddingVectorColumn `json:"embedding_vector_columns,omitempty"` + // [Optional] Name of the Delta table to sync the index contents and computed + // embeddings to. + EmbeddingWritebackTable *string `json:"embedding_writeback_table,omitempty"` + // The ID of the pipeline that is used to sync the index. + PipelineId *string `json:"pipeline_id,omitempty"` + // Pipeline execution mode. Required on create — the backend rejects an unset + // value. Storage Optimized endpoints accept only `TRIGGERED`; Standard + // endpoints accept both. No explicit `stage` — a REQUIRED field staged below + // its service would be dropped from combined specs while remaining in + // `required`, tripping the OpenAPI required-vs-properties consistency check. + // The field inherits the service's launch stage. + PipelineType PipelineType `json:"pipeline_type,omitempty"` + // The full name of the source Delta table. + SourceTable *string `json:"source_table,omitempty"` +} + +// Specification for a Direct Access index — the customer manages vectors and +// metadata directly.. +type DirectAccessIndexSpec struct { + // The columns that contain the embedding source. + EmbeddingSourceColumns []EmbeddingSourceColumn `json:"embedding_source_columns,omitempty"` + // The columns that contain the embedding vectors. + EmbeddingVectorColumns []EmbeddingVectorColumn `json:"embedding_vector_columns,omitempty"` + // The schema of the index in JSON format. Supported types are `integer`, + // `long`, `float`, `double`, `boolean`, `string`, `date`, `timestamp`. + // Supported types for vector columns: `array`, `array`. + SchemaJson *string `json:"schema_json,omitempty"` +} + +// Name of an embedding source column and its associated embedding model +// endpoint.. +type EmbeddingSourceColumn struct { + // Name of the embedding model endpoint, used by default for both ingestion and + // querying. + EmbeddingModelEndpoint *string `json:"embedding_model_endpoint,omitempty"` + // Name of the embedding model endpoint which, if specified, is used for + // querying (not ingestion). + ModelEndpointNameForQuery *string `json:"model_endpoint_name_for_query,omitempty"` + // Name of the source column. + Name *string `json:"name,omitempty"` +} + +// Name and dimension of an embedding vector column.. +type EmbeddingVectorColumn struct { + // Dimension of the embedding vector. + EmbeddingDimension *int `json:"embedding_dimension,omitempty"` + // Name of the column. + Name *string `json:"name,omitempty"` +} + +// An AI Search endpoint — compute infrastructure that hosts AI Search indexes +// and serves queries against them. Customers create, query, and delete +// endpoints; the system manages provisioning, scaling, and health status.. +type Endpoint struct { + // The user-selected budget policy id for the endpoint. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // Time the endpoint was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Creator of the endpoint + Creator *string `json:"creator,omitempty"` + // The custom tags assigned to the endpoint + CustomTags []CustomTag `json:"custom_tags,omitempty"` + // The budget policy id applied to the endpoint + EffectiveBudgetPolicyId *string `json:"effective_budget_policy_id,omitempty"` + // Current status of the endpoint + EndpointStatus *EndpointStatus `json:"endpoint_status,omitempty"` + // Type of endpoint. Required on create and immutable thereafter. + EndpointType EndpointType `json:"endpoint_type,omitempty"` + // Unique identifier of the endpoint + Id *string `json:"id,omitempty"` + // Number of indexes on the endpoint + IndexCount *int `json:"index_count,omitempty"` + // User who last updated the endpoint + LastUpdatedUser *string `json:"last_updated_user,omitempty"` + // Name of the AI Search endpoint. Server-assigned full resource path + // (`workspaces/{workspace}/endpoints/{endpoint}`) on output. On create, the + // user-supplied short name is conveyed via `CreateEndpointRequest.endpoint_id`; + // the server composes the full `name` and returns it on the response. + Name *string `json:"name,omitempty"` + // The client-supplied desired number of replicas for the endpoint, applied at + // create/update time. Mutually exclusive with `target_qps`. + ReplicaCount *int `json:"replica_count,omitempty"` + // Scaling information for the endpoint + ScalingInfo *EndpointScalingInfo `json:"scaling_info,omitempty"` + // Target QPS for the endpoint. Mutually exclusive with `replica_count`. + // Best-effort; the system does not guarantee this QPS will be achieved. + TargetQps *int `json:"target_qps,omitempty"` + // Throughput information for the endpoint + ThroughputInfo *EndpointThroughputInfo `json:"throughput_info,omitempty"` + // Time the endpoint was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` + // The usage policy id applied to the endpoint. + UsagePolicyId *string `json:"usage_policy_id,omitempty"` +} + +// Scaling information for a Standard endpoint: the current scaling state, the +// requested QPS target, and the progress of an in-progress scaling change.. +type EndpointScalingInfo struct { + // The requested QPS target for the endpoint. Best-effort; the system does not + // guarantee this QPS will be achieved. + RequestedTargetQps *int64 `json:"requested_target_qps,omitempty"` + // The current state of the scaling change request. + State ScalingChangeState `json:"state,omitempty"` +} + +// Lifecycle and health state of an AI Search endpoint, along with any +// human-readable detail about that state.. +type EndpointStatus struct { + // Human-readable detail about the endpoint's current state or the reason for a + // state transition. + Message *string `json:"message,omitempty"` + // Current lifecycle state of the endpoint. See `State` for the meaning of each + // value. + State EndpointStatus_State `json:"state,omitempty"` +} + +// Throughput information for an AI Search endpoint, including requested and +// current concurrency settings.. +type EndpointThroughputInfo struct { + // Additional information about the throughput change request + ChangeRequestMessage *string `json:"change_request_message,omitempty"` + // The state of the most recent throughput change request + ChangeRequestState ThroughputChangeRequestState `json:"change_request_state,omitempty"` + // The current concurrency (total CPU) allocated to the endpoint + CurrentConcurrency *float64 `json:"current_concurrency,omitempty"` + // The current utilization of concurrency as a percentage (0-100) + CurrentConcurrencyUtilizationPercentage *float64 `json:"current_concurrency_utilization_percentage,omitempty"` + // The current number of replicas allocated to the endpoint + CurrentNumReplicas *int `json:"current_num_replicas,omitempty"` + // The maximum concurrency allowed for this endpoint + MaximumConcurrencyAllowed *float64 `json:"maximum_concurrency_allowed,omitempty"` + // The minimum concurrency allowed for this endpoint + MinimalConcurrencyAllowed *float64 `json:"minimal_concurrency_allowed,omitempty"` + // The requested concurrency (total CPU) for the endpoint + RequestedConcurrency *float64 `json:"requested_concurrency,omitempty"` + // The requested number of replicas for the endpoint + RequestedNumReplicas *int `json:"requested_num_replicas,omitempty"` +} + +// Facet aggregation rows returned by a query.. +type FacetResultData struct { + // Facet rows; each row is `[facet_column_name, value_or_range, count]`. + FacetArray [][]json.RawMessage `json:"facet_array,omitempty"` + // Number of facet rows returned. + FacetRowCount *int `json:"facet_row_count,omitempty"` +} + +// An AI Search index — a searchable collection of vectors and metadata hosted +// on an AI Search endpoint. Indexes are children of endpoints; customers +// create, get, list, and delete them. The `{index}` segment of the resource +// name is the index's Unity Catalog table name.. +type Index struct { + // Creator of the index. + Creator *string `json:"creator,omitempty"` + DeltaSyncIndexSpec *DeltaSyncIndexSpec `json:"delta_sync_index_spec,omitempty"` + DirectAccessIndexSpec *DirectAccessIndexSpec `json:"direct_access_index_spec,omitempty"` + // Name of the endpoint associated with the index. Ignored on create — the + // endpoint is taken from `CreateIndexRequest.parent`; populated only on output. + Endpoint *string `json:"endpoint,omitempty"` + // The subtype of the index. Set on create and immutable thereafter. + IndexSubtype IndexSubtype `json:"index_subtype,omitempty"` + // Type of index. Required on create and immutable thereafter. + IndexType IndexType `json:"index_type,omitempty"` + // Name of the AI Search index. Server-assigned full resource path + // (`workspaces/{workspace}/endpoints/{endpoint}/indexes/{index}`) on output, + // where `{index}` is the index's Unity Catalog table name. On create, the + // user-supplied UC table name is conveyed via `CreateIndexRequest.index_id`; + // the server composes the full `name` and returns it on the response. + Name *string `json:"name,omitempty"` + // Primary key of the index. Set on create and immutable thereafter. + PrimaryKey *string `json:"primary_key,omitempty"` + // Current status of the index. + Status *IndexStatus `json:"status,omitempty"` +} + +// Lifecycle and health state of an AI Search index, along with human-readable +// detail about that state and basic indexing progress.. +type IndexStatus struct { + // Index API URL used to perform operations on the index. + IndexUrl *string `json:"index_url,omitempty"` + // Number of rows indexed. + IndexedRowCount *int64 `json:"indexed_row_count,omitempty"` + // Human-readable detail about the index's current state. + Message *string `json:"message,omitempty"` + // Whether the index is ready for search. + Ready *bool `json:"ready,omitempty"` +} + +// Request to list AI Search endpoints in a workspace, with optional pagination.. +type ListEndpointsRequest struct { + // Best-effort upper bound on the number of results to return. Honored as an + // upper bound by the shim: `page_size` only narrows the legacy backend's + // response, never widens it, so the practical cap is `min(page_size, + // legacy_fixed_page_size)`. + PageSize *int `json:"page_size,omitempty"` + // Page token from a previous response. If not provided, returns the first page. + PageToken *string `json:"page_token,omitempty"` + // The Workspace that owns this collection of endpoints. Format: + // `workspaces/{workspace_id}` + Parent *string `json:"parent,omitempty"` +} + +// Response for ListEndpoints carrying the page of endpoints and an optional +// continuation token.. +type ListEndpointsResponse struct { + // The endpoints in the workspace. + Endpoints []Endpoint `json:"endpoints,omitempty"` + // A token that can be used to get the next page of results. Empty when there + // are no more results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to list AI Search indexes on an endpoint, with optional pagination.. +type ListIndexesRequest struct { + // Best-effort upper bound on the number of results to return. Honored as an + // upper bound by the shim: `page_size` only narrows the legacy backend's + // response, never widens it, so the practical cap is `min(page_size, + // legacy_fixed_page_size)`. + PageSize *int `json:"page_size,omitempty"` + // Page token from a previous response. If not provided, returns the first page. + PageToken *string `json:"page_token,omitempty"` + // The Endpoint that owns this collection of indexes. Format: + // `workspaces/{workspace_id}/endpoints/{endpoint_id}` + Parent *string `json:"parent,omitempty"` +} + +// Response for ListIndexes carrying the page of indexes and an optional +// continuation token.. +type ListIndexesResponse struct { + // The indexes on the endpoint. The field is named `indexes` (not the irregular + // plural `indices`) to satisfy core::0132, which derives the response field + // name from the ListIndexes method. core::0158::response-plural-first-field + // independently computes the resource plural as `indices` and is satisfied via + // a scoped field exception below. + Indexes []Index `json:"indexes,omitempty"` + // A token that can be used to get the next page of results. Empty when there + // are no more results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to query (search) an AI Search index. The legacy `num_results` count +// is exposed as `max_results`; v1 returns up to `max_results` rows in a single +// response (no cursor pagination — see the note on `max_results` below).. +type QueryIndexRequest struct { + // Column names to include in each result row. + Columns []string `json:"columns,omitempty"` + // Columns whose values are sent to the reranker. + ColumnsToRerank []string `json:"columns_to_rerank,omitempty"` + // Facets to compute over the matched results (e.g. `"category TOP 5"`). + Facets []string `json:"facets,omitempty"` + // JSON string describing query filters (e.g. `{"id >": 5}`). + FiltersJson *string `json:"filters_json,omitempty"` + // Maximum number of results to return (the legacy `num_results`). Defaults to + // 10. Prefer `page_size`; when both are set, `page_size` takes precedence. + MaxResults *int `json:"max_results,omitempty"` + // Full resource name of the index to query. Format: + // `workspaces/{workspace_id}/endpoints/{endpoint_id}/indexes/{index_id}` + Name *string `json:"name,omitempty"` + // Text columns to search for `query_text`. When empty, all text columns are + // searched. + QueryColumns []string `json:"query_columns,omitempty"` + // Query text. Required for Delta Sync indexes that compute embeddings from a + // model endpoint. + QueryText *string `json:"query_text,omitempty"` + // Query type: `ANN`, `HYBRID`, or `FULL_TEXT`. Defaults to `ANN`. + QueryType *string `json:"query_type,omitempty"` + // Query vector. Required for Direct Access indexes and Delta Sync indexes with + // self-managed vectors. + QueryVector []float32 `json:"query_vector,omitempty"` + // If set, results are reranked before being returned. + Reranker *RerankerConfig `json:"reranker,omitempty"` + // Score threshold for the approximate nearest-neighbor search. Defaults to 0.0. + ScoreThreshold *float32 `json:"score_threshold,omitempty"` + // Sort clauses, e.g. `["rating DESC", "price ASC"]`. Overrides relevance + // ordering. + SortColumns []string `json:"sort_columns,omitempty"` +} + +// Response for QueryIndex carrying the matched rows and their column metadata.. +type QueryIndexResponse struct { + // Facet aggregation rows, when facets were requested. + FacetResult *FacetResultData `json:"facet_result,omitempty"` + // Metadata describing the result columns. + Manifest *ResultManifest `json:"manifest,omitempty"` + // The matched result rows. + Result *ResultData `json:"result,omitempty"` +} + +// Request to remove rows by primary key from a Direct Access AI Search index. +// Named RemoveData (not DeleteData) so the linter does not classify it as a +// standard AIP-135 Delete method — it deletes rows within an index, not the +// index resource.. +type RemoveDataRequest struct { + // Full resource name of the index. Must be a Direct Access index. Format: + // `workspaces/{workspace_id}/endpoints/{endpoint_id}/indexes/{index_id}` + Name *string `json:"name,omitempty"` + // Primary keys of the rows to remove. + PrimaryKeys []string `json:"primary_keys,omitempty"` +} + +// Response for RemoveData.. +type RemoveDataResponse struct { + // Per-row outcome of the delete. + Result *DataModificationResult `json:"result,omitempty"` + // Overall status of the delete. + Status DataModificationStatus `json:"status,omitempty"` +} + +// Configuration for reranking query results with a reranker model.. +type RerankerConfig struct { + // Reranker identifier: "databricks_reranker" for the base model, or a Model + // Serving endpoint name when `model_type` is MODEL_TYPE_FINETUNED. + Model *string `json:"model,omitempty"` + // Discriminator for how `model` is interpreted. + ModelType RerankerConfig_ModelType `json:"model_type,omitempty"` + // Parameters controlling reranking. + Parameters *RerankerConfig_RerankerParameters `json:"parameters,omitempty"` +} + +// Parameters controlling how the reranker processes results.. +type RerankerConfig_RerankerParameters struct { + // Columns whose values are concatenated and sent to the reranker. + ColumnsToRerank []string `json:"columns_to_rerank,omitempty"` +} + +// The rows of a query result set.. +type ResultData struct { + // Result rows; each row is a list of column values aligned with the manifest + // columns. + DataArray [][]json.RawMessage `json:"data_array,omitempty"` + // Number of rows in the result set. + RowCount *int `json:"row_count,omitempty"` +} + +// Metadata describing the columns of a query result set.. +type ResultManifest struct { + // Number of columns in the result set. + ColumnCount *int `json:"column_count,omitempty"` + // Information about each column in the result set. + Columns []ColumnInfo `json:"columns,omitempty"` + // Number of columns in the facet result. + FacetColumnCount *int `json:"facet_column_count,omitempty"` + // Information about each facet column. + FacetColumns []ColumnInfo `json:"facet_columns,omitempty"` +} + +// Request to scan (paginate over) the rows of an AI Search index. Models the +// legacy `num_results` / `last_primary_key` cursor as AIP-158 `page_size` / +// `page_token`.. +type ScanIndexRequest struct { + // Full resource name of the index to scan. Format: + // `workspaces/{workspace_id}/endpoints/{endpoint_id}/indexes/{index_id}` + Name *string `json:"name,omitempty"` + // Maximum number of rows to return in this page. + PageSize *int `json:"page_size,omitempty"` + // Page token from a previous response; if unset, scanning starts from the + // beginning. + PageToken *string `json:"page_token,omitempty"` +} + +// Response for ScanIndex carrying a page of rows and an optional continuation +// token.. +type ScanIndexResponse struct { + // The rows in this page, each a struct of column name to value. + Data []map[string]json.RawMessage `json:"data,omitempty"` + // Token for the next page; empty when the scan is exhausted. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to synchronize a Delta Sync AI Search index with its source Delta +// table.. +type SyncIndexRequest struct { + // Full resource name of the index to synchronize. Must be a Delta Sync index. + // Format: + // `workspaces/{workspace_id}/endpoints/{endpoint_id}/indexes/{index_id}` + Name *string `json:"name,omitempty"` +} + +// AIP-134 conformant Update. The endpoint is nested under `endpoint`; the +// resource is identified by `endpoint.name` (the full resource path). +// `update_mask` selects which fields to update. Multi-bucket masks (mixing +// fields that target different legacy mutation handlers — e.g. +// `budget_policy_id` + `custom_tags`) are supported: the server issues one +// legacy backend call per bucket, applied in deterministic order. Per-bucket +// failures are not atomic; if a later bucket fails the earlier mutations have +// already been applied. Callers wanting strict atomicity should issue separate +// requests.. +type UpdateEndpointRequest struct { + // The Endpoint resource to update. `endpoint.name` carries the full resource + // path. + Endpoint *Endpoint `json:"endpoint,omitempty"` + // The list of fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Request to upsert rows into a Direct Access AI Search index.. +type UpsertDataRequest struct { + // JSON document describing the rows to upsert. + InputsJson *string `json:"inputs_json,omitempty"` + // Full resource name of the index. Must be a Direct Access index. Format: + // `workspaces/{workspace_id}/endpoints/{endpoint_id}/indexes/{index_id}` + Name *string `json:"name,omitempty"` +} + +// Response for UpsertData.. +type UpsertDataResponse struct { + // Per-row outcome of the upsert. + Result *DataModificationResult `json:"result,omitempty"` + // Overall status of the upsert. + Status DataModificationStatus `json:"status,omitempty"` +} + +// ColumnInfoToSDK converts the mirror to the sdk-go type. +func ColumnInfoToSDK(w *ColumnInfo) (*sdk.ColumnInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnInfo{} + out.Name = w.Name + out.TypeText = w.TypeText + return out, nil +} + +// ColumnInfoFromSDK converts the sdk-go type to the mirror. +func ColumnInfoFromSDK(v *sdk.ColumnInfo) (*ColumnInfo, error) { + if v == nil { + return nil, nil + } + out := &ColumnInfo{} + out.Name = v.Name + out.TypeText = v.TypeText + return out, nil +} + +// CreateEndpointRequestToSDK converts the mirror to the sdk-go type. +func CreateEndpointRequestToSDK(w *CreateEndpointRequest) (*sdk.CreateEndpointRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateEndpointRequest{} + out.Parent = w.Parent + conv1, err := EndpointToSDK(w.Endpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateEndpointRequest.Endpoint", err) + } + out.Endpoint = conv1 + out.EndpointId = w.EndpointId + return out, nil +} + +// CreateEndpointRequestFromSDK converts the sdk-go type to the mirror. +func CreateEndpointRequestFromSDK(v *sdk.CreateEndpointRequest) (*CreateEndpointRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateEndpointRequest{} + out.Parent = v.Parent + conv2, err := EndpointFromSDK(v.Endpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateEndpointRequest.Endpoint", err) + } + out.Endpoint = conv2 + out.EndpointId = v.EndpointId + return out, nil +} + +// CreateIndexRequestToSDK converts the mirror to the sdk-go type. +func CreateIndexRequestToSDK(w *CreateIndexRequest) (*sdk.CreateIndexRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateIndexRequest{} + out.Parent = w.Parent + conv3, err := IndexToSDK(w.Index) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateIndexRequest.Index", err) + } + out.Index = conv3 + out.IndexId = w.IndexId + return out, nil +} + +// CreateIndexRequestFromSDK converts the sdk-go type to the mirror. +func CreateIndexRequestFromSDK(v *sdk.CreateIndexRequest) (*CreateIndexRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateIndexRequest{} + out.Parent = v.Parent + conv4, err := IndexFromSDK(v.Index) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateIndexRequest.Index", err) + } + out.Index = conv4 + out.IndexId = v.IndexId + return out, nil +} + +// CustomTagToSDK converts the mirror to the sdk-go type. +func CustomTagToSDK(w *CustomTag) (*sdk.CustomTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// CustomTagFromSDK converts the sdk-go type to the mirror. +func CustomTagFromSDK(v *sdk.CustomTag) (*CustomTag, error) { + if v == nil { + return nil, nil + } + out := &CustomTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// DataModificationResultToSDK converts the mirror to the sdk-go type. +func DataModificationResultToSDK(w *DataModificationResult) (*sdk.DataModificationResult, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataModificationResult{} + out.SuccessRowCount = w.SuccessRowCount + out.FailedPrimaryKeys = w.FailedPrimaryKeys + return out, nil +} + +// DataModificationResultFromSDK converts the sdk-go type to the mirror. +func DataModificationResultFromSDK(v *sdk.DataModificationResult) (*DataModificationResult, error) { + if v == nil { + return nil, nil + } + out := &DataModificationResult{} + out.SuccessRowCount = v.SuccessRowCount + out.FailedPrimaryKeys = v.FailedPrimaryKeys + return out, nil +} + +// DeltaSyncIndexSpecToSDK converts the mirror to the sdk-go type. +func DeltaSyncIndexSpecToSDK(w *DeltaSyncIndexSpec) (*sdk.DeltaSyncIndexSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeltaSyncIndexSpec{} + out.SourceTable = w.SourceTable + conv5, err := convertSlice(w.EmbeddingSourceColumns, EmbeddingSourceColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeltaSyncIndexSpec.EmbeddingSourceColumns", err) + } + out.EmbeddingSourceColumns = conv5 + conv6, err := convertSlice(w.EmbeddingVectorColumns, EmbeddingVectorColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeltaSyncIndexSpec.EmbeddingVectorColumns", err) + } + out.EmbeddingVectorColumns = conv6 + out.EmbeddingWritebackTable = w.EmbeddingWritebackTable + out.ColumnsToSync = w.ColumnsToSync + out.PipelineId = w.PipelineId + out.PipelineType = w.PipelineType + return out, nil +} + +// DeltaSyncIndexSpecFromSDK converts the sdk-go type to the mirror. +func DeltaSyncIndexSpecFromSDK(v *sdk.DeltaSyncIndexSpec) (*DeltaSyncIndexSpec, error) { + if v == nil { + return nil, nil + } + out := &DeltaSyncIndexSpec{} + out.SourceTable = v.SourceTable + conv7, err := convertSlice(v.EmbeddingSourceColumns, EmbeddingSourceColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeltaSyncIndexSpec.EmbeddingSourceColumns", err) + } + out.EmbeddingSourceColumns = conv7 + conv8, err := convertSlice(v.EmbeddingVectorColumns, EmbeddingVectorColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeltaSyncIndexSpec.EmbeddingVectorColumns", err) + } + out.EmbeddingVectorColumns = conv8 + out.EmbeddingWritebackTable = v.EmbeddingWritebackTable + out.ColumnsToSync = v.ColumnsToSync + out.PipelineId = v.PipelineId + out.PipelineType = v.PipelineType + return out, nil +} + +// DirectAccessIndexSpecToSDK converts the mirror to the sdk-go type. +func DirectAccessIndexSpecToSDK(w *DirectAccessIndexSpec) (*sdk.DirectAccessIndexSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.DirectAccessIndexSpec{} + conv9, err := convertSlice(w.EmbeddingVectorColumns, EmbeddingVectorColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectAccessIndexSpec.EmbeddingVectorColumns", err) + } + out.EmbeddingVectorColumns = conv9 + out.SchemaJson = w.SchemaJson + conv10, err := convertSlice(w.EmbeddingSourceColumns, EmbeddingSourceColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectAccessIndexSpec.EmbeddingSourceColumns", err) + } + out.EmbeddingSourceColumns = conv10 + return out, nil +} + +// DirectAccessIndexSpecFromSDK converts the sdk-go type to the mirror. +func DirectAccessIndexSpecFromSDK(v *sdk.DirectAccessIndexSpec) (*DirectAccessIndexSpec, error) { + if v == nil { + return nil, nil + } + out := &DirectAccessIndexSpec{} + conv11, err := convertSlice(v.EmbeddingVectorColumns, EmbeddingVectorColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectAccessIndexSpec.EmbeddingVectorColumns", err) + } + out.EmbeddingVectorColumns = conv11 + out.SchemaJson = v.SchemaJson + conv12, err := convertSlice(v.EmbeddingSourceColumns, EmbeddingSourceColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectAccessIndexSpec.EmbeddingSourceColumns", err) + } + out.EmbeddingSourceColumns = conv12 + return out, nil +} + +// EmbeddingSourceColumnToSDK converts the mirror to the sdk-go type. +func EmbeddingSourceColumnToSDK(w *EmbeddingSourceColumn) (*sdk.EmbeddingSourceColumn, error) { + if w == nil { + return nil, nil + } + out := &sdk.EmbeddingSourceColumn{} + out.Name = w.Name + out.EmbeddingModelEndpoint = w.EmbeddingModelEndpoint + out.ModelEndpointNameForQuery = w.ModelEndpointNameForQuery + return out, nil +} + +// EmbeddingSourceColumnFromSDK converts the sdk-go type to the mirror. +func EmbeddingSourceColumnFromSDK(v *sdk.EmbeddingSourceColumn) (*EmbeddingSourceColumn, error) { + if v == nil { + return nil, nil + } + out := &EmbeddingSourceColumn{} + out.Name = v.Name + out.EmbeddingModelEndpoint = v.EmbeddingModelEndpoint + out.ModelEndpointNameForQuery = v.ModelEndpointNameForQuery + return out, nil +} + +// EmbeddingVectorColumnToSDK converts the mirror to the sdk-go type. +func EmbeddingVectorColumnToSDK(w *EmbeddingVectorColumn) (*sdk.EmbeddingVectorColumn, error) { + if w == nil { + return nil, nil + } + out := &sdk.EmbeddingVectorColumn{} + out.Name = w.Name + out.EmbeddingDimension = w.EmbeddingDimension + return out, nil +} + +// EmbeddingVectorColumnFromSDK converts the sdk-go type to the mirror. +func EmbeddingVectorColumnFromSDK(v *sdk.EmbeddingVectorColumn) (*EmbeddingVectorColumn, error) { + if v == nil { + return nil, nil + } + out := &EmbeddingVectorColumn{} + out.Name = v.Name + out.EmbeddingDimension = v.EmbeddingDimension + return out, nil +} + +// EndpointToSDK converts the mirror to the sdk-go type. +func EndpointToSDK(w *Endpoint) (*sdk.Endpoint, error) { + if w == nil { + return nil, nil + } + out := &sdk.Endpoint{} + out.Name = w.Name + out.Creator = w.Creator + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.EndpointType = w.EndpointType + out.LastUpdatedUser = w.LastUpdatedUser + out.Id = w.Id + conv13, err := EndpointStatusToSDK(w.EndpointStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.EndpointStatus", err) + } + out.EndpointStatus = conv13 + out.IndexCount = w.IndexCount + out.BudgetPolicyId = w.BudgetPolicyId + out.EffectiveBudgetPolicyId = w.EffectiveBudgetPolicyId + conv14, err := convertSlice(w.CustomTags, CustomTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.CustomTags", err) + } + out.CustomTags = conv14 + conv15, err := EndpointThroughputInfoToSDK(w.ThroughputInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.ThroughputInfo", err) + } + out.ThroughputInfo = conv15 + conv16, err := EndpointScalingInfoToSDK(w.ScalingInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.ScalingInfo", err) + } + out.ScalingInfo = conv16 + out.UsagePolicyId = w.UsagePolicyId + out.ReplicaCount = w.ReplicaCount + out.TargetQps = w.TargetQps + return out, nil +} + +// EndpointFromSDK converts the sdk-go type to the mirror. +func EndpointFromSDK(v *sdk.Endpoint) (*Endpoint, error) { + if v == nil { + return nil, nil + } + out := &Endpoint{} + out.Name = v.Name + out.Creator = v.Creator + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.EndpointType = v.EndpointType + out.LastUpdatedUser = v.LastUpdatedUser + out.Id = v.Id + conv17, err := EndpointStatusFromSDK(v.EndpointStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.EndpointStatus", err) + } + out.EndpointStatus = conv17 + out.IndexCount = v.IndexCount + out.BudgetPolicyId = v.BudgetPolicyId + out.EffectiveBudgetPolicyId = v.EffectiveBudgetPolicyId + conv18, err := convertSlice(v.CustomTags, CustomTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.CustomTags", err) + } + out.CustomTags = conv18 + conv19, err := EndpointThroughputInfoFromSDK(v.ThroughputInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.ThroughputInfo", err) + } + out.ThroughputInfo = conv19 + conv20, err := EndpointScalingInfoFromSDK(v.ScalingInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.ScalingInfo", err) + } + out.ScalingInfo = conv20 + out.UsagePolicyId = v.UsagePolicyId + out.ReplicaCount = v.ReplicaCount + out.TargetQps = v.TargetQps + return out, nil +} + +// EndpointScalingInfoToSDK converts the mirror to the sdk-go type. +func EndpointScalingInfoToSDK(w *EndpointScalingInfo) (*sdk.EndpointScalingInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointScalingInfo{} + out.State = w.State + out.RequestedTargetQps = w.RequestedTargetQps + return out, nil +} + +// EndpointScalingInfoFromSDK converts the sdk-go type to the mirror. +func EndpointScalingInfoFromSDK(v *sdk.EndpointScalingInfo) (*EndpointScalingInfo, error) { + if v == nil { + return nil, nil + } + out := &EndpointScalingInfo{} + out.State = v.State + out.RequestedTargetQps = v.RequestedTargetQps + return out, nil +} + +// EndpointStatusToSDK converts the mirror to the sdk-go type. +func EndpointStatusToSDK(w *EndpointStatus) (*sdk.EndpointStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointStatus{} + out.State = w.State + out.Message = w.Message + return out, nil +} + +// EndpointStatusFromSDK converts the sdk-go type to the mirror. +func EndpointStatusFromSDK(v *sdk.EndpointStatus) (*EndpointStatus, error) { + if v == nil { + return nil, nil + } + out := &EndpointStatus{} + out.State = v.State + out.Message = v.Message + return out, nil +} + +// EndpointThroughputInfoToSDK converts the mirror to the sdk-go type. +func EndpointThroughputInfoToSDK(w *EndpointThroughputInfo) (*sdk.EndpointThroughputInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointThroughputInfo{} + out.RequestedConcurrency = w.RequestedConcurrency + out.CurrentConcurrency = w.CurrentConcurrency + out.CurrentConcurrencyUtilizationPercentage = w.CurrentConcurrencyUtilizationPercentage + out.MinimalConcurrencyAllowed = w.MinimalConcurrencyAllowed + out.MaximumConcurrencyAllowed = w.MaximumConcurrencyAllowed + out.ChangeRequestState = w.ChangeRequestState + out.ChangeRequestMessage = w.ChangeRequestMessage + out.RequestedNumReplicas = w.RequestedNumReplicas + out.CurrentNumReplicas = w.CurrentNumReplicas + return out, nil +} + +// EndpointThroughputInfoFromSDK converts the sdk-go type to the mirror. +func EndpointThroughputInfoFromSDK(v *sdk.EndpointThroughputInfo) (*EndpointThroughputInfo, error) { + if v == nil { + return nil, nil + } + out := &EndpointThroughputInfo{} + out.RequestedConcurrency = v.RequestedConcurrency + out.CurrentConcurrency = v.CurrentConcurrency + out.CurrentConcurrencyUtilizationPercentage = v.CurrentConcurrencyUtilizationPercentage + out.MinimalConcurrencyAllowed = v.MinimalConcurrencyAllowed + out.MaximumConcurrencyAllowed = v.MaximumConcurrencyAllowed + out.ChangeRequestState = v.ChangeRequestState + out.ChangeRequestMessage = v.ChangeRequestMessage + out.RequestedNumReplicas = v.RequestedNumReplicas + out.CurrentNumReplicas = v.CurrentNumReplicas + return out, nil +} + +// FacetResultDataToSDK converts the mirror to the sdk-go type. +func FacetResultDataToSDK(w *FacetResultData) (*sdk.FacetResultData, error) { + if w == nil { + return nil, nil + } + out := &sdk.FacetResultData{} + out.FacetRowCount = w.FacetRowCount + out.FacetArray = w.FacetArray + return out, nil +} + +// FacetResultDataFromSDK converts the sdk-go type to the mirror. +func FacetResultDataFromSDK(v *sdk.FacetResultData) (*FacetResultData, error) { + if v == nil { + return nil, nil + } + out := &FacetResultData{} + out.FacetRowCount = v.FacetRowCount + out.FacetArray = v.FacetArray + return out, nil +} + +// IndexToSDK converts the mirror to the sdk-go type. +func IndexToSDK(w *Index) (*sdk.Index, error) { + if w == nil { + return nil, nil + } + out := &sdk.Index{} + out.Name = w.Name + out.Endpoint = w.Endpoint + out.PrimaryKey = w.PrimaryKey + out.IndexType = w.IndexType + { + var members []string + if w.DirectAccessIndexSpec != nil { + members = append(members, "direct_access_index_spec") + } + if w.DeltaSyncIndexSpec != nil { + members = append(members, "delta_sync_index_spec") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DirectAccessIndexSpec != nil: + conv21, err := DirectAccessIndexSpecToSDK(w.DirectAccessIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Index.IndexSpec", err) + } + out.IndexSpec = &sdk.Index_IndexSpec_DirectAccessIndexSpec{DirectAccessIndexSpec: *conv21} + case w.DeltaSyncIndexSpec != nil: + conv22, err := DeltaSyncIndexSpecToSDK(w.DeltaSyncIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Index.IndexSpec", err) + } + out.IndexSpec = &sdk.Index_IndexSpec_DeltaSyncIndexSpec{DeltaSyncIndexSpec: *conv22} + } + conv23, err := IndexStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Index.Status", err) + } + out.Status = conv23 + out.Creator = w.Creator + out.IndexSubtype = w.IndexSubtype + return out, nil +} + +// IndexFromSDK converts the sdk-go type to the mirror. +func IndexFromSDK(v *sdk.Index) (*Index, error) { + if v == nil { + return nil, nil + } + out := &Index{} + out.Name = v.Name + out.Endpoint = v.Endpoint + out.PrimaryKey = v.PrimaryKey + out.IndexType = v.IndexType + switch value := v.IndexSpec.(type) { + case *sdk.Index_IndexSpec_DirectAccessIndexSpec: + if value != nil { + conv24, err := DirectAccessIndexSpecFromSDK(&value.DirectAccessIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Index.IndexSpec", err) + } + out.DirectAccessIndexSpec = conv24 + } + case *sdk.Index_IndexSpec_DeltaSyncIndexSpec: + if value != nil { + conv25, err := DeltaSyncIndexSpecFromSDK(&value.DeltaSyncIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Index.IndexSpec", err) + } + out.DeltaSyncIndexSpec = conv25 + } + } + conv26, err := IndexStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Index.Status", err) + } + out.Status = conv26 + out.Creator = v.Creator + out.IndexSubtype = v.IndexSubtype + return out, nil +} + +// IndexStatusToSDK converts the mirror to the sdk-go type. +func IndexStatusToSDK(w *IndexStatus) (*sdk.IndexStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.IndexStatus{} + out.Message = w.Message + out.IndexedRowCount = w.IndexedRowCount + out.Ready = w.Ready + out.IndexUrl = w.IndexUrl + return out, nil +} + +// IndexStatusFromSDK converts the sdk-go type to the mirror. +func IndexStatusFromSDK(v *sdk.IndexStatus) (*IndexStatus, error) { + if v == nil { + return nil, nil + } + out := &IndexStatus{} + out.Message = v.Message + out.IndexedRowCount = v.IndexedRowCount + out.Ready = v.Ready + out.IndexUrl = v.IndexUrl + return out, nil +} + +// ListEndpointsRequestToSDK converts the mirror to the sdk-go type. +func ListEndpointsRequestToSDK(w *ListEndpointsRequest) (*sdk.ListEndpointsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEndpointsRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListEndpointsRequestFromSDK converts the sdk-go type to the mirror. +func ListEndpointsRequestFromSDK(v *sdk.ListEndpointsRequest) (*ListEndpointsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListEndpointsRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListEndpointsResponseToSDK converts the mirror to the sdk-go type. +func ListEndpointsResponseToSDK(w *ListEndpointsResponse) (*sdk.ListEndpointsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEndpointsResponse{} + conv27, err := convertSlice(w.Endpoints, EndpointToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListEndpointsResponse.Endpoints", err) + } + out.Endpoints = conv27 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListEndpointsResponseFromSDK converts the sdk-go type to the mirror. +func ListEndpointsResponseFromSDK(v *sdk.ListEndpointsResponse) (*ListEndpointsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListEndpointsResponse{} + conv28, err := convertSlice(v.Endpoints, EndpointFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListEndpointsResponse.Endpoints", err) + } + out.Endpoints = conv28 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListIndexesRequestToSDK converts the mirror to the sdk-go type. +func ListIndexesRequestToSDK(w *ListIndexesRequest) (*sdk.ListIndexesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListIndexesRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListIndexesRequestFromSDK converts the sdk-go type to the mirror. +func ListIndexesRequestFromSDK(v *sdk.ListIndexesRequest) (*ListIndexesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListIndexesRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListIndexesResponseToSDK converts the mirror to the sdk-go type. +func ListIndexesResponseToSDK(w *ListIndexesResponse) (*sdk.ListIndexesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListIndexesResponse{} + conv29, err := convertSlice(w.Indexes, IndexToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListIndexesResponse.Indexes", err) + } + out.Indexes = conv29 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListIndexesResponseFromSDK converts the sdk-go type to the mirror. +func ListIndexesResponseFromSDK(v *sdk.ListIndexesResponse) (*ListIndexesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListIndexesResponse{} + conv30, err := convertSlice(v.Indexes, IndexFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListIndexesResponse.Indexes", err) + } + out.Indexes = conv30 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// QueryIndexRequestToSDK converts the mirror to the sdk-go type. +func QueryIndexRequestToSDK(w *QueryIndexRequest) (*sdk.QueryIndexRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryIndexRequest{} + out.Name = w.Name + out.Columns = w.Columns + out.QueryVector = w.QueryVector + out.QueryText = w.QueryText + out.FiltersJson = w.FiltersJson + out.ScoreThreshold = w.ScoreThreshold + out.QueryType = w.QueryType + out.ColumnsToRerank = w.ColumnsToRerank + conv31, err := RerankerConfigToSDK(w.Reranker) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryIndexRequest.Reranker", err) + } + out.Reranker = conv31 + out.QueryColumns = w.QueryColumns + out.SortColumns = w.SortColumns + out.Facets = w.Facets + out.MaxResults = w.MaxResults + return out, nil +} + +// QueryIndexRequestFromSDK converts the sdk-go type to the mirror. +func QueryIndexRequestFromSDK(v *sdk.QueryIndexRequest) (*QueryIndexRequest, error) { + if v == nil { + return nil, nil + } + out := &QueryIndexRequest{} + out.Name = v.Name + out.Columns = v.Columns + out.QueryVector = v.QueryVector + out.QueryText = v.QueryText + out.FiltersJson = v.FiltersJson + out.ScoreThreshold = v.ScoreThreshold + out.QueryType = v.QueryType + out.ColumnsToRerank = v.ColumnsToRerank + conv32, err := RerankerConfigFromSDK(v.Reranker) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryIndexRequest.Reranker", err) + } + out.Reranker = conv32 + out.QueryColumns = v.QueryColumns + out.SortColumns = v.SortColumns + out.Facets = v.Facets + out.MaxResults = v.MaxResults + return out, nil +} + +// QueryIndexResponseToSDK converts the mirror to the sdk-go type. +func QueryIndexResponseToSDK(w *QueryIndexResponse) (*sdk.QueryIndexResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryIndexResponse{} + conv33, err := ResultManifestToSDK(w.Manifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryIndexResponse.Manifest", err) + } + out.Manifest = conv33 + conv34, err := ResultDataToSDK(w.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryIndexResponse.Result", err) + } + out.Result = conv34 + conv35, err := FacetResultDataToSDK(w.FacetResult) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryIndexResponse.FacetResult", err) + } + out.FacetResult = conv35 + return out, nil +} + +// QueryIndexResponseFromSDK converts the sdk-go type to the mirror. +func QueryIndexResponseFromSDK(v *sdk.QueryIndexResponse) (*QueryIndexResponse, error) { + if v == nil { + return nil, nil + } + out := &QueryIndexResponse{} + conv36, err := ResultManifestFromSDK(v.Manifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryIndexResponse.Manifest", err) + } + out.Manifest = conv36 + conv37, err := ResultDataFromSDK(v.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryIndexResponse.Result", err) + } + out.Result = conv37 + conv38, err := FacetResultDataFromSDK(v.FacetResult) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryIndexResponse.FacetResult", err) + } + out.FacetResult = conv38 + return out, nil +} + +// RemoveDataRequestToSDK converts the mirror to the sdk-go type. +func RemoveDataRequestToSDK(w *RemoveDataRequest) (*sdk.RemoveDataRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RemoveDataRequest{} + out.Name = w.Name + out.PrimaryKeys = w.PrimaryKeys + return out, nil +} + +// RemoveDataRequestFromSDK converts the sdk-go type to the mirror. +func RemoveDataRequestFromSDK(v *sdk.RemoveDataRequest) (*RemoveDataRequest, error) { + if v == nil { + return nil, nil + } + out := &RemoveDataRequest{} + out.Name = v.Name + out.PrimaryKeys = v.PrimaryKeys + return out, nil +} + +// RemoveDataResponseToSDK converts the mirror to the sdk-go type. +func RemoveDataResponseToSDK(w *RemoveDataResponse) (*sdk.RemoveDataResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.RemoveDataResponse{} + out.Status = w.Status + conv39, err := DataModificationResultToSDK(w.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RemoveDataResponse.Result", err) + } + out.Result = conv39 + return out, nil +} + +// RemoveDataResponseFromSDK converts the sdk-go type to the mirror. +func RemoveDataResponseFromSDK(v *sdk.RemoveDataResponse) (*RemoveDataResponse, error) { + if v == nil { + return nil, nil + } + out := &RemoveDataResponse{} + out.Status = v.Status + conv40, err := DataModificationResultFromSDK(v.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RemoveDataResponse.Result", err) + } + out.Result = conv40 + return out, nil +} + +// RerankerConfigToSDK converts the mirror to the sdk-go type. +func RerankerConfigToSDK(w *RerankerConfig) (*sdk.RerankerConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.RerankerConfig{} + out.Model = w.Model + conv41, err := RerankerConfig_RerankerParametersToSDK(w.Parameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RerankerConfig.Parameters", err) + } + out.Parameters = conv41 + out.ModelType = w.ModelType + return out, nil +} + +// RerankerConfigFromSDK converts the sdk-go type to the mirror. +func RerankerConfigFromSDK(v *sdk.RerankerConfig) (*RerankerConfig, error) { + if v == nil { + return nil, nil + } + out := &RerankerConfig{} + out.Model = v.Model + conv42, err := RerankerConfig_RerankerParametersFromSDK(v.Parameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RerankerConfig.Parameters", err) + } + out.Parameters = conv42 + out.ModelType = v.ModelType + return out, nil +} + +// RerankerConfig_RerankerParametersToSDK converts the mirror to the sdk-go type. +func RerankerConfig_RerankerParametersToSDK(w *RerankerConfig_RerankerParameters) (*sdk.RerankerConfig_RerankerParameters, error) { + if w == nil { + return nil, nil + } + out := &sdk.RerankerConfig_RerankerParameters{} + out.ColumnsToRerank = w.ColumnsToRerank + return out, nil +} + +// RerankerConfig_RerankerParametersFromSDK converts the sdk-go type to the mirror. +func RerankerConfig_RerankerParametersFromSDK(v *sdk.RerankerConfig_RerankerParameters) (*RerankerConfig_RerankerParameters, error) { + if v == nil { + return nil, nil + } + out := &RerankerConfig_RerankerParameters{} + out.ColumnsToRerank = v.ColumnsToRerank + return out, nil +} + +// ResultDataToSDK converts the mirror to the sdk-go type. +func ResultDataToSDK(w *ResultData) (*sdk.ResultData, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResultData{} + out.RowCount = w.RowCount + out.DataArray = w.DataArray + return out, nil +} + +// ResultDataFromSDK converts the sdk-go type to the mirror. +func ResultDataFromSDK(v *sdk.ResultData) (*ResultData, error) { + if v == nil { + return nil, nil + } + out := &ResultData{} + out.RowCount = v.RowCount + out.DataArray = v.DataArray + return out, nil +} + +// ResultManifestToSDK converts the mirror to the sdk-go type. +func ResultManifestToSDK(w *ResultManifest) (*sdk.ResultManifest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResultManifest{} + out.ColumnCount = w.ColumnCount + conv43, err := convertSlice(w.Columns, ColumnInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.Columns", err) + } + out.Columns = conv43 + out.FacetColumnCount = w.FacetColumnCount + conv44, err := convertSlice(w.FacetColumns, ColumnInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.FacetColumns", err) + } + out.FacetColumns = conv44 + return out, nil +} + +// ResultManifestFromSDK converts the sdk-go type to the mirror. +func ResultManifestFromSDK(v *sdk.ResultManifest) (*ResultManifest, error) { + if v == nil { + return nil, nil + } + out := &ResultManifest{} + out.ColumnCount = v.ColumnCount + conv45, err := convertSlice(v.Columns, ColumnInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.Columns", err) + } + out.Columns = conv45 + out.FacetColumnCount = v.FacetColumnCount + conv46, err := convertSlice(v.FacetColumns, ColumnInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.FacetColumns", err) + } + out.FacetColumns = conv46 + return out, nil +} + +// ScanIndexRequestToSDK converts the mirror to the sdk-go type. +func ScanIndexRequestToSDK(w *ScanIndexRequest) (*sdk.ScanIndexRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ScanIndexRequest{} + out.Name = w.Name + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ScanIndexRequestFromSDK converts the sdk-go type to the mirror. +func ScanIndexRequestFromSDK(v *sdk.ScanIndexRequest) (*ScanIndexRequest, error) { + if v == nil { + return nil, nil + } + out := &ScanIndexRequest{} + out.Name = v.Name + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ScanIndexResponseToSDK converts the mirror to the sdk-go type. +func ScanIndexResponseToSDK(w *ScanIndexResponse) (*sdk.ScanIndexResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ScanIndexResponse{} + out.Data = w.Data + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ScanIndexResponseFromSDK converts the sdk-go type to the mirror. +func ScanIndexResponseFromSDK(v *sdk.ScanIndexResponse) (*ScanIndexResponse, error) { + if v == nil { + return nil, nil + } + out := &ScanIndexResponse{} + out.Data = v.Data + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SyncIndexRequestToSDK converts the mirror to the sdk-go type. +func SyncIndexRequestToSDK(w *SyncIndexRequest) (*sdk.SyncIndexRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncIndexRequest{} + out.Name = w.Name + return out, nil +} + +// SyncIndexRequestFromSDK converts the sdk-go type to the mirror. +func SyncIndexRequestFromSDK(v *sdk.SyncIndexRequest) (*SyncIndexRequest, error) { + if v == nil { + return nil, nil + } + out := &SyncIndexRequest{} + out.Name = v.Name + return out, nil +} + +// UpdateEndpointRequestToSDK converts the mirror to the sdk-go type. +func UpdateEndpointRequestToSDK(w *UpdateEndpointRequest) (*sdk.UpdateEndpointRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateEndpointRequest{} + conv47, err := EndpointToSDK(w.Endpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEndpointRequest.Endpoint", err) + } + out.Endpoint = conv47 + mask48, err := fieldMaskFromString[sdk.Endpoint](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEndpointRequest.UpdateMask", err) + } + out.UpdateMask = mask48 + return out, nil +} + +// UpdateEndpointRequestFromSDK converts the sdk-go type to the mirror. +func UpdateEndpointRequestFromSDK(v *sdk.UpdateEndpointRequest) (*UpdateEndpointRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateEndpointRequest{} + conv49, err := EndpointFromSDK(v.Endpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEndpointRequest.Endpoint", err) + } + out.Endpoint = conv49 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpsertDataRequestToSDK converts the mirror to the sdk-go type. +func UpsertDataRequestToSDK(w *UpsertDataRequest) (*sdk.UpsertDataRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpsertDataRequest{} + out.Name = w.Name + out.InputsJson = w.InputsJson + return out, nil +} + +// UpsertDataRequestFromSDK converts the sdk-go type to the mirror. +func UpsertDataRequestFromSDK(v *sdk.UpsertDataRequest) (*UpsertDataRequest, error) { + if v == nil { + return nil, nil + } + out := &UpsertDataRequest{} + out.Name = v.Name + out.InputsJson = v.InputsJson + return out, nil +} + +// UpsertDataResponseToSDK converts the mirror to the sdk-go type. +func UpsertDataResponseToSDK(w *UpsertDataResponse) (*sdk.UpsertDataResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpsertDataResponse{} + out.Status = w.Status + conv50, err := DataModificationResultToSDK(w.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpsertDataResponse.Result", err) + } + out.Result = conv50 + return out, nil +} + +// UpsertDataResponseFromSDK converts the sdk-go type to the mirror. +func UpsertDataResponseFromSDK(v *sdk.UpsertDataResponse) (*UpsertDataResponse, error) { + if v == nil { + return nil, nil + } + out := &UpsertDataResponse{} + out.Status = v.Status + conv51, err := DataModificationResultFromSDK(v.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpsertDataResponse.Result", err) + } + out.Result = conv51 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/alerts/v1/types.generated.go b/libs/sdktypes/alerts/v1/types.generated.go new file mode 100644 index 00000000000..dc12f218264 --- /dev/null +++ b/libs/sdktypes/alerts/v1/types.generated.go @@ -0,0 +1,747 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/alerts/v1. DO NOT EDIT. + +package alerts + +import ( + fmt "fmt" + sdk "github.com/databricks/sdk-go/alerts/v1" + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + AlertOperator = sdk.AlertOperator + AlertState = sdk.AlertState + LifecycleState = sdk.LifecycleState +) + +const ( + AlertOperator_Unspecified = sdk.AlertOperator_Unspecified + AlertOperator_GreaterThan = sdk.AlertOperator_GreaterThan + AlertOperator_GreaterThanOrEqual = sdk.AlertOperator_GreaterThanOrEqual + AlertOperator_LessThan = sdk.AlertOperator_LessThan + AlertOperator_LessThanOrEqual = sdk.AlertOperator_LessThanOrEqual + AlertOperator_Equal = sdk.AlertOperator_Equal + AlertOperator_NotEqual = sdk.AlertOperator_NotEqual + AlertOperator_IsNull = sdk.AlertOperator_IsNull + AlertState_Unspecified = sdk.AlertState_Unspecified + AlertState_Unknown = sdk.AlertState_Unknown + AlertState_Ok = sdk.AlertState_Ok + AlertState_Triggered = sdk.AlertState_Triggered + LifecycleState_Unspecified = sdk.LifecycleState_Unspecified + LifecycleState_Active = sdk.LifecycleState_Active + LifecycleState_Trashed = sdk.LifecycleState_Trashed +) + +type Alert struct { + // Trigger conditions of the alert. + Condition *AlertCondition `json:"condition,omitempty"` + // The timestamp indicating when the alert was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Custom body of alert notification, if it exists. See + // [here](/sql/user/alerts/index.html) for custom templating instructions. + CustomBody *string `json:"custom_body,omitempty"` + // Custom subject of alert notification, if it exists. This can include email + // subject entries and Slack notification headers, for example. See + // [here](/sql/user/alerts/index.html) for custom templating instructions. + CustomSubject *string `json:"custom_subject,omitempty"` + // The display name of the alert. + DisplayName *string `json:"display_name,omitempty"` + // UUID identifying the alert. + Id *string `json:"id,omitempty"` + // The workspace state of the alert. Used for tracking trashed status. + LifecycleState LifecycleState `json:"lifecycle_state,omitempty"` + // Whether to notify alert subscribers when alert returns back to normal. + NotifyOnOk *bool `json:"notify_on_ok,omitempty"` + // The owner's username. This field is set to "Unavailable" if the user has been + // deleted. + OwnerUserName *string `json:"owner_user_name,omitempty"` + // The workspace path of the folder containing the alert. + ParentPath *string `json:"parent_path,omitempty"` + // UUID of the query attached to the alert. + QueryId *string `json:"query_id,omitempty"` + // Number of seconds an alert must wait after being triggered to rearm itself. + // After rearming, it can be triggered again. If 0 or not specified, the alert + // will not be triggered again. + SecondsToRetrigger *int `json:"seconds_to_retrigger,omitempty"` + // Current state of the alert's trigger status. This field is set to UNKNOWN if + // the alert has not yet been evaluated or ran into an error during the last + // evaluation. + State AlertState `json:"state,omitempty"` + // Timestamp when the alert was last triggered, if the alert has been triggered + // before. + TriggerTime *types.Time `json:"trigger_time,omitempty"` + // The timestamp indicating when the alert was updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +type AlertCondition struct { + // Alert state if result is empty. + EmptyResultState AlertState `json:"empty_result_state,omitempty"` + // Operator used for comparison in alert evaluation. + Op AlertOperator `json:"op,omitempty"` + // Name of the column from the query result to use for comparison in alert + // evaluation. + Operand *AlertOperand `json:"operand,omitempty"` + // Threshold value used for comparison in alert evaluation. + Threshold *AlertOperand `json:"threshold,omitempty"` +} + +type AlertOperand struct { + Column *AlertOperandColumn `json:"column,omitempty"` + Value *AlertOperandValue `json:"value,omitempty"` +} + +type AlertOperandColumn struct { + Name *string `json:"name,omitempty"` +} + +type AlertOperandValue struct { + BoolValue *bool `json:"bool_value,omitempty"` + DoubleValue *float64 `json:"double_value,omitempty"` + StringValue *string `json:"string_value,omitempty"` +} + +type CreateAlertRequest struct { + Alert *CreateAlertRequestAlert `json:"alert,omitempty"` + // If true, automatically resolve alert display name conflicts. Otherwise, fail + // the request if the alert's display name conflicts with an existing alert's + // display name. + AutoResolveDisplayName *bool `json:"auto_resolve_display_name,omitempty"` +} + +type CreateAlertRequestAlert struct { + // Trigger conditions of the alert. + Condition *AlertCondition `json:"condition,omitempty"` + // Custom body of alert notification, if it exists. See + // [here](/sql/user/alerts/index.html) for custom templating instructions. + CustomBody *string `json:"custom_body,omitempty"` + // Custom subject of alert notification, if it exists. This can include email + // subject entries and Slack notification headers, for example. See + // [here](/sql/user/alerts/index.html) for custom templating instructions. + CustomSubject *string `json:"custom_subject,omitempty"` + // The display name of the alert. + DisplayName *string `json:"display_name,omitempty"` + // Whether to notify alert subscribers when alert returns back to normal. + NotifyOnOk *bool `json:"notify_on_ok,omitempty"` + // The workspace path of the folder containing the alert. + ParentPath *string `json:"parent_path,omitempty"` + // UUID of the query attached to the alert. + QueryId *string `json:"query_id,omitempty"` + // Number of seconds an alert must wait after being triggered to rearm itself. + // After rearming, it can be triggered again. If 0 or not specified, the alert + // will not be triggered again. + SecondsToRetrigger *int `json:"seconds_to_retrigger,omitempty"` +} + +type ListAlertsRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListAlertsResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + Results []ListAlertsResponseAlert `json:"results,omitempty"` +} + +type ListAlertsResponseAlert struct { + // Trigger conditions of the alert. + Condition *AlertCondition `json:"condition,omitempty"` + // The timestamp indicating when the alert was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Custom body of alert notification, if it exists. See + // [here](/sql/user/alerts/index.html) for custom templating instructions. + CustomBody *string `json:"custom_body,omitempty"` + // Custom subject of alert notification, if it exists. This can include email + // subject entries and Slack notification headers, for example. See + // [here](/sql/user/alerts/index.html) for custom templating instructions. + CustomSubject *string `json:"custom_subject,omitempty"` + // The display name of the alert. + DisplayName *string `json:"display_name,omitempty"` + // UUID identifying the alert. + Id *string `json:"id,omitempty"` + // The workspace state of the alert. Used for tracking trashed status. + LifecycleState LifecycleState `json:"lifecycle_state,omitempty"` + // Whether to notify alert subscribers when alert returns back to normal. + NotifyOnOk *bool `json:"notify_on_ok,omitempty"` + // The owner's username. This field is set to "Unavailable" if the user has been + // deleted. + OwnerUserName *string `json:"owner_user_name,omitempty"` + // UUID of the query attached to the alert. + QueryId *string `json:"query_id,omitempty"` + // Number of seconds an alert must wait after being triggered to rearm itself. + // After rearming, it can be triggered again. If 0 or not specified, the alert + // will not be triggered again. + SecondsToRetrigger *int `json:"seconds_to_retrigger,omitempty"` + // Current state of the alert's trigger status. This field is set to UNKNOWN if + // the alert has not yet been evaluated or ran into an error during the last + // evaluation. + State AlertState `json:"state,omitempty"` + // Timestamp when the alert was last triggered, if the alert has been triggered + // before. + TriggerTime *types.Time `json:"trigger_time,omitempty"` + // The timestamp indicating when the alert was updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +type UpdateAlertRequest struct { + Alert *UpdateAlertRequestAlert `json:"alert,omitempty"` + // If true, automatically resolve alert display name conflicts. Otherwise, fail + // the request if the alert's display name conflicts with an existing alert's + // display name. + AutoResolveDisplayName *bool `json:"auto_resolve_display_name,omitempty"` + Id *string `json:"id,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateAlertRequestAlert struct { + // Trigger conditions of the alert. + Condition *AlertCondition `json:"condition,omitempty"` + // Custom body of alert notification, if it exists. See + // [here](/sql/user/alerts/index.html) for custom templating instructions. + CustomBody *string `json:"custom_body,omitempty"` + // Custom subject of alert notification, if it exists. This can include email + // subject entries and Slack notification headers, for example. See + // [here](/sql/user/alerts/index.html) for custom templating instructions. + CustomSubject *string `json:"custom_subject,omitempty"` + // The display name of the alert. + DisplayName *string `json:"display_name,omitempty"` + // Whether to notify alert subscribers when alert returns back to normal. + NotifyOnOk *bool `json:"notify_on_ok,omitempty"` + // The owner's username. This field is set to "Unavailable" if the user has been + // deleted. + OwnerUserName *string `json:"owner_user_name,omitempty"` + // UUID of the query attached to the alert. + QueryId *string `json:"query_id,omitempty"` + // Number of seconds an alert must wait after being triggered to rearm itself. + // After rearming, it can be triggered again. If 0 or not specified, the alert + // will not be triggered again. + SecondsToRetrigger *int `json:"seconds_to_retrigger,omitempty"` +} + +// AlertToSDK converts the mirror to the sdk-go type. +func AlertToSDK(w *Alert) (*sdk.Alert, error) { + if w == nil { + return nil, nil + } + out := &sdk.Alert{} + out.Id = w.Id + out.DisplayName = w.DisplayName + out.QueryId = w.QueryId + out.State = w.State + out.SecondsToRetrigger = w.SecondsToRetrigger + out.LifecycleState = w.LifecycleState + out.TriggerTime = w.TriggerTime + out.CustomBody = w.CustomBody + out.CustomSubject = w.CustomSubject + conv1, err := AlertConditionToSDK(w.Condition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Alert.Condition", err) + } + out.Condition = conv1 + out.OwnerUserName = w.OwnerUserName + out.ParentPath = w.ParentPath + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.NotifyOnOk = w.NotifyOnOk + return out, nil +} + +// AlertFromSDK converts the sdk-go type to the mirror. +func AlertFromSDK(v *sdk.Alert) (*Alert, error) { + if v == nil { + return nil, nil + } + out := &Alert{} + out.Id = v.Id + out.DisplayName = v.DisplayName + out.QueryId = v.QueryId + out.State = v.State + out.SecondsToRetrigger = v.SecondsToRetrigger + out.LifecycleState = v.LifecycleState + out.TriggerTime = v.TriggerTime + out.CustomBody = v.CustomBody + out.CustomSubject = v.CustomSubject + conv2, err := AlertConditionFromSDK(v.Condition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Alert.Condition", err) + } + out.Condition = conv2 + out.OwnerUserName = v.OwnerUserName + out.ParentPath = v.ParentPath + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.NotifyOnOk = v.NotifyOnOk + return out, nil +} + +// AlertConditionToSDK converts the mirror to the sdk-go type. +func AlertConditionToSDK(w *AlertCondition) (*sdk.AlertCondition, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertCondition{} + out.Op = w.Op + conv3, err := AlertOperandToSDK(w.Operand) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertCondition.Operand", err) + } + out.Operand = conv3 + conv4, err := AlertOperandToSDK(w.Threshold) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertCondition.Threshold", err) + } + out.Threshold = conv4 + out.EmptyResultState = w.EmptyResultState + return out, nil +} + +// AlertConditionFromSDK converts the sdk-go type to the mirror. +func AlertConditionFromSDK(v *sdk.AlertCondition) (*AlertCondition, error) { + if v == nil { + return nil, nil + } + out := &AlertCondition{} + out.Op = v.Op + conv5, err := AlertOperandFromSDK(v.Operand) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertCondition.Operand", err) + } + out.Operand = conv5 + conv6, err := AlertOperandFromSDK(v.Threshold) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertCondition.Threshold", err) + } + out.Threshold = conv6 + out.EmptyResultState = v.EmptyResultState + return out, nil +} + +// AlertOperandToSDK converts the mirror to the sdk-go type. +func AlertOperandToSDK(w *AlertOperand) (*sdk.AlertOperand, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertOperand{} + { + var members []string + if w.Value != nil { + members = append(members, "value") + } + if w.Column != nil { + members = append(members, "column") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Value != nil: + conv7, err := AlertOperandValueToSDK(w.Value) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertOperand.Operand", err) + } + out.Operand = &sdk.AlertOperand_Operand_Value{Value: *conv7} + case w.Column != nil: + conv8, err := AlertOperandColumnToSDK(w.Column) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertOperand.Operand", err) + } + out.Operand = &sdk.AlertOperand_Operand_Column{Column: *conv8} + } + return out, nil +} + +// AlertOperandFromSDK converts the sdk-go type to the mirror. +func AlertOperandFromSDK(v *sdk.AlertOperand) (*AlertOperand, error) { + if v == nil { + return nil, nil + } + out := &AlertOperand{} + switch value := v.Operand.(type) { + case *sdk.AlertOperand_Operand_Value: + if value != nil { + conv9, err := AlertOperandValueFromSDK(&value.Value) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertOperand.Operand", err) + } + out.Value = conv9 + } + case *sdk.AlertOperand_Operand_Column: + if value != nil { + conv10, err := AlertOperandColumnFromSDK(&value.Column) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertOperand.Operand", err) + } + out.Column = conv10 + } + } + return out, nil +} + +// AlertOperandColumnToSDK converts the mirror to the sdk-go type. +func AlertOperandColumnToSDK(w *AlertOperandColumn) (*sdk.AlertOperandColumn, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertOperandColumn{} + out.Name = w.Name + return out, nil +} + +// AlertOperandColumnFromSDK converts the sdk-go type to the mirror. +func AlertOperandColumnFromSDK(v *sdk.AlertOperandColumn) (*AlertOperandColumn, error) { + if v == nil { + return nil, nil + } + out := &AlertOperandColumn{} + out.Name = v.Name + return out, nil +} + +// AlertOperandValueToSDK converts the mirror to the sdk-go type. +func AlertOperandValueToSDK(w *AlertOperandValue) (*sdk.AlertOperandValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertOperandValue{} + { + var members []string + if w.StringValue != nil { + members = append(members, "string_value") + } + if w.DoubleValue != nil { + members = append(members, "double_value") + } + if w.BoolValue != nil { + members = append(members, "bool_value") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.StringValue != nil: + out.ThresholdValue = &sdk.AlertOperandValue_ThresholdValue_StringValue{StringValue: *w.StringValue} + case w.DoubleValue != nil: + out.ThresholdValue = &sdk.AlertOperandValue_ThresholdValue_DoubleValue{DoubleValue: *w.DoubleValue} + case w.BoolValue != nil: + out.ThresholdValue = &sdk.AlertOperandValue_ThresholdValue_BoolValue{BoolValue: *w.BoolValue} + } + return out, nil +} + +// AlertOperandValueFromSDK converts the sdk-go type to the mirror. +func AlertOperandValueFromSDK(v *sdk.AlertOperandValue) (*AlertOperandValue, error) { + if v == nil { + return nil, nil + } + out := &AlertOperandValue{} + switch value := v.ThresholdValue.(type) { + case *sdk.AlertOperandValue_ThresholdValue_StringValue: + if value != nil { + out.StringValue = new(value.StringValue) + } + case *sdk.AlertOperandValue_ThresholdValue_DoubleValue: + if value != nil { + out.DoubleValue = new(value.DoubleValue) + } + case *sdk.AlertOperandValue_ThresholdValue_BoolValue: + if value != nil { + out.BoolValue = new(value.BoolValue) + } + } + return out, nil +} + +// CreateAlertRequestToSDK converts the mirror to the sdk-go type. +func CreateAlertRequestToSDK(w *CreateAlertRequest) (*sdk.CreateAlertRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAlertRequest{} + conv11, err := CreateAlertRequestAlertToSDK(w.Alert) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAlertRequest.Alert", err) + } + out.Alert = conv11 + out.AutoResolveDisplayName = w.AutoResolveDisplayName + return out, nil +} + +// CreateAlertRequestFromSDK converts the sdk-go type to the mirror. +func CreateAlertRequestFromSDK(v *sdk.CreateAlertRequest) (*CreateAlertRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateAlertRequest{} + conv12, err := CreateAlertRequestAlertFromSDK(v.Alert) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAlertRequest.Alert", err) + } + out.Alert = conv12 + out.AutoResolveDisplayName = v.AutoResolveDisplayName + return out, nil +} + +// CreateAlertRequestAlertToSDK converts the mirror to the sdk-go type. +func CreateAlertRequestAlertToSDK(w *CreateAlertRequestAlert) (*sdk.CreateAlertRequestAlert, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAlertRequestAlert{} + out.DisplayName = w.DisplayName + out.QueryId = w.QueryId + out.SecondsToRetrigger = w.SecondsToRetrigger + out.CustomBody = w.CustomBody + out.CustomSubject = w.CustomSubject + conv13, err := AlertConditionToSDK(w.Condition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAlertRequestAlert.Condition", err) + } + out.Condition = conv13 + out.ParentPath = w.ParentPath + out.NotifyOnOk = w.NotifyOnOk + return out, nil +} + +// CreateAlertRequestAlertFromSDK converts the sdk-go type to the mirror. +func CreateAlertRequestAlertFromSDK(v *sdk.CreateAlertRequestAlert) (*CreateAlertRequestAlert, error) { + if v == nil { + return nil, nil + } + out := &CreateAlertRequestAlert{} + out.DisplayName = v.DisplayName + out.QueryId = v.QueryId + out.SecondsToRetrigger = v.SecondsToRetrigger + out.CustomBody = v.CustomBody + out.CustomSubject = v.CustomSubject + conv14, err := AlertConditionFromSDK(v.Condition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAlertRequestAlert.Condition", err) + } + out.Condition = conv14 + out.ParentPath = v.ParentPath + out.NotifyOnOk = v.NotifyOnOk + return out, nil +} + +// ListAlertsRequestToSDK converts the mirror to the sdk-go type. +func ListAlertsRequestToSDK(w *ListAlertsRequest) (*sdk.ListAlertsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAlertsRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListAlertsRequestFromSDK converts the sdk-go type to the mirror. +func ListAlertsRequestFromSDK(v *sdk.ListAlertsRequest) (*ListAlertsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListAlertsRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListAlertsResponseToSDK converts the mirror to the sdk-go type. +func ListAlertsResponseToSDK(w *ListAlertsResponse) (*sdk.ListAlertsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAlertsResponse{} + conv15, err := convertSlice(w.Results, ListAlertsResponseAlertToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAlertsResponse.Results", err) + } + out.Results = conv15 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListAlertsResponseFromSDK converts the sdk-go type to the mirror. +func ListAlertsResponseFromSDK(v *sdk.ListAlertsResponse) (*ListAlertsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAlertsResponse{} + conv16, err := convertSlice(v.Results, ListAlertsResponseAlertFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAlertsResponse.Results", err) + } + out.Results = conv16 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListAlertsResponseAlertToSDK converts the mirror to the sdk-go type. +func ListAlertsResponseAlertToSDK(w *ListAlertsResponseAlert) (*sdk.ListAlertsResponseAlert, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAlertsResponseAlert{} + out.Id = w.Id + out.DisplayName = w.DisplayName + out.QueryId = w.QueryId + out.State = w.State + out.SecondsToRetrigger = w.SecondsToRetrigger + out.LifecycleState = w.LifecycleState + out.TriggerTime = w.TriggerTime + out.CustomBody = w.CustomBody + out.CustomSubject = w.CustomSubject + conv17, err := AlertConditionToSDK(w.Condition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAlertsResponseAlert.Condition", err) + } + out.Condition = conv17 + out.OwnerUserName = w.OwnerUserName + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.NotifyOnOk = w.NotifyOnOk + return out, nil +} + +// ListAlertsResponseAlertFromSDK converts the sdk-go type to the mirror. +func ListAlertsResponseAlertFromSDK(v *sdk.ListAlertsResponseAlert) (*ListAlertsResponseAlert, error) { + if v == nil { + return nil, nil + } + out := &ListAlertsResponseAlert{} + out.Id = v.Id + out.DisplayName = v.DisplayName + out.QueryId = v.QueryId + out.State = v.State + out.SecondsToRetrigger = v.SecondsToRetrigger + out.LifecycleState = v.LifecycleState + out.TriggerTime = v.TriggerTime + out.CustomBody = v.CustomBody + out.CustomSubject = v.CustomSubject + conv18, err := AlertConditionFromSDK(v.Condition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAlertsResponseAlert.Condition", err) + } + out.Condition = conv18 + out.OwnerUserName = v.OwnerUserName + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.NotifyOnOk = v.NotifyOnOk + return out, nil +} + +// UpdateAlertRequestToSDK converts the mirror to the sdk-go type. +func UpdateAlertRequestToSDK(w *UpdateAlertRequest) (*sdk.UpdateAlertRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAlertRequest{} + conv19, err := UpdateAlertRequestAlertToSDK(w.Alert) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAlertRequest.Alert", err) + } + out.Alert = conv19 + mask20, err := fieldMaskFromString[sdk.UpdateAlertRequestAlert](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAlertRequest.UpdateMask", err) + } + out.UpdateMask = mask20 + out.Id = w.Id + out.AutoResolveDisplayName = w.AutoResolveDisplayName + return out, nil +} + +// UpdateAlertRequestFromSDK converts the sdk-go type to the mirror. +func UpdateAlertRequestFromSDK(v *sdk.UpdateAlertRequest) (*UpdateAlertRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateAlertRequest{} + conv21, err := UpdateAlertRequestAlertFromSDK(v.Alert) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAlertRequest.Alert", err) + } + out.Alert = conv21 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + out.Id = v.Id + out.AutoResolveDisplayName = v.AutoResolveDisplayName + return out, nil +} + +// UpdateAlertRequestAlertToSDK converts the mirror to the sdk-go type. +func UpdateAlertRequestAlertToSDK(w *UpdateAlertRequestAlert) (*sdk.UpdateAlertRequestAlert, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAlertRequestAlert{} + out.DisplayName = w.DisplayName + out.QueryId = w.QueryId + out.SecondsToRetrigger = w.SecondsToRetrigger + out.CustomBody = w.CustomBody + out.CustomSubject = w.CustomSubject + conv22, err := AlertConditionToSDK(w.Condition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAlertRequestAlert.Condition", err) + } + out.Condition = conv22 + out.OwnerUserName = w.OwnerUserName + out.NotifyOnOk = w.NotifyOnOk + return out, nil +} + +// UpdateAlertRequestAlertFromSDK converts the sdk-go type to the mirror. +func UpdateAlertRequestAlertFromSDK(v *sdk.UpdateAlertRequestAlert) (*UpdateAlertRequestAlert, error) { + if v == nil { + return nil, nil + } + out := &UpdateAlertRequestAlert{} + out.DisplayName = v.DisplayName + out.QueryId = v.QueryId + out.SecondsToRetrigger = v.SecondsToRetrigger + out.CustomBody = v.CustomBody + out.CustomSubject = v.CustomSubject + conv23, err := AlertConditionFromSDK(v.Condition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAlertRequestAlert.Condition", err) + } + out.Condition = conv23 + out.OwnerUserName = v.OwnerUserName + out.NotifyOnOk = v.NotifyOnOk + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/alerts/v2/types.generated.go b/libs/sdktypes/alerts/v2/types.generated.go new file mode 100644 index 00000000000..83df62ad3d7 --- /dev/null +++ b/libs/sdktypes/alerts/v2/types.generated.go @@ -0,0 +1,879 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/alerts/v2. DO NOT EDIT. + +package alerts + +import ( + fmt "fmt" + sdk "github.com/databricks/sdk-go/alerts/v2" + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + Aggregation = sdk.Aggregation + AlertEvaluationState = sdk.AlertEvaluationState + AlertLifecycleState = sdk.AlertLifecycleState + ComparisonOperator = sdk.ComparisonOperator + CustomTemplateFormat = sdk.CustomTemplateFormat + SchedulePauseStatus = sdk.SchedulePauseStatus +) + +const ( + Aggregation_Unspecified = sdk.Aggregation_Unspecified + Aggregation_Sum = sdk.Aggregation_Sum + Aggregation_Count = sdk.Aggregation_Count + Aggregation_CountDistinct = sdk.Aggregation_CountDistinct + Aggregation_Avg = sdk.Aggregation_Avg + Aggregation_Median = sdk.Aggregation_Median + Aggregation_Min = sdk.Aggregation_Min + Aggregation_Max = sdk.Aggregation_Max + Aggregation_Stddev = sdk.Aggregation_Stddev + AlertEvaluationState_Unspecified = sdk.AlertEvaluationState_Unspecified + AlertEvaluationState_Unknown = sdk.AlertEvaluationState_Unknown + AlertEvaluationState_Triggered = sdk.AlertEvaluationState_Triggered + AlertEvaluationState_Ok = sdk.AlertEvaluationState_Ok + AlertEvaluationState_Error = sdk.AlertEvaluationState_Error + AlertLifecycleState_Unspecified = sdk.AlertLifecycleState_Unspecified + AlertLifecycleState_Active = sdk.AlertLifecycleState_Active + AlertLifecycleState_Deleted = sdk.AlertLifecycleState_Deleted + ComparisonOperator_Unspecified = sdk.ComparisonOperator_Unspecified + ComparisonOperator_LessThan = sdk.ComparisonOperator_LessThan + ComparisonOperator_GreaterThan = sdk.ComparisonOperator_GreaterThan + ComparisonOperator_Equal = sdk.ComparisonOperator_Equal + ComparisonOperator_NotEqual = sdk.ComparisonOperator_NotEqual + ComparisonOperator_GreaterThanOrEqual = sdk.ComparisonOperator_GreaterThanOrEqual + ComparisonOperator_LessThanOrEqual = sdk.ComparisonOperator_LessThanOrEqual + ComparisonOperator_IsNull = sdk.ComparisonOperator_IsNull + ComparisonOperator_IsNotNull = sdk.ComparisonOperator_IsNotNull + CustomTemplateFormat_Unspecified = sdk.CustomTemplateFormat_Unspecified + CustomTemplateFormat_Html = sdk.CustomTemplateFormat_Html + CustomTemplateFormat_Markdown = sdk.CustomTemplateFormat_Markdown + SchedulePauseStatus_Unspecified = sdk.SchedulePauseStatus_Unspecified + SchedulePauseStatus_Unpaused = sdk.SchedulePauseStatus_Unpaused + SchedulePauseStatus_Paused = sdk.SchedulePauseStatus_Paused +) + +type Alert struct { + // The timestamp indicating when the alert was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Custom description for the alert. support mustache template. + CustomDescription *string `json:"custom_description,omitempty"` + // Custom summary for the alert. support mustache template. + CustomSummary *string `json:"custom_summary,omitempty"` + // The format used to interpret the `custom_summary` and `custom_description` + // templates. + // + // `HTML` treats both templates as HTML with Mustache `{{VARIABLE_NAME}}` + // placeholders. `MARKDOWN` treats them as Markdown with allowlisted + // `@VARIABLE_NAME` placeholders and converts them to the format each + // notification destination expects, so a single template renders correctly in + // email, Slack, and Microsoft Teams. + // + // When unset, the API applies no default. Responses omit the field unless a + // format is stored, and a template with no format is rendered as HTML. + CustomTemplateFormat CustomTemplateFormat `json:"custom_template_format,omitempty"` + // The display name of the alert. + DisplayName *string `json:"display_name,omitempty"` + // The actual identity that will be used to execute the alert. This is an + // output-only field that shows the resolved run-as identity after applying + // permissions and defaults. + EffectiveRunAs *AlertRunAs `json:"effective_run_as,omitempty"` + Evaluation *AlertEvaluation `json:"evaluation,omitempty"` + // The canonical identifier of the alert to retrieve information about. + Id *string `json:"id,omitempty"` + // Indicates whether the query is trashed. + LifecycleState AlertLifecycleState `json:"lifecycle_state,omitempty"` + // The owner's username. This field is set to "Unavailable" if the user has been + // deleted. + OwnerUserName *string `json:"owner_user_name,omitempty"` + // A list of parameters to pass into the alert SQL query statement containing + // parameter markers. Static values only. + // + // Reference a parameter in the query text as `:name`. Each parameter must have + // a unique, non-empty name. Each parameter consists of a name, a value, and + // optionally a type. To represent a NULL value, the `value` field may be + // omitted or set to `null` explicitly. If the `type` field is omitted, the + // value is interpreted as a string. + // + // If the type is given, parameters will be checked for type correctness + // according to the given type. A value is correct if the provided string can be + // converted to the requested type using the `cast` function. The exact + // semantics are described in the section [`cast` function] of the SQL language + // reference. + // + // [`cast` function]: https://docs.databricks.com/sql/language-manual/functions/cast.html + Parameters []AlertStatementParameter `json:"parameters,omitempty"` + // The workspace path of the folder containing the alert. Can only be set on + // create, and cannot be updated. + ParentPath *string `json:"parent_path,omitempty"` + // Text of the query to be run. + QueryText *string `json:"query_text,omitempty"` + // Specifies the identity that will be used to run the alert. This field allows + // you to configure alerts to run as a specific user or service principal. - For + // user identity: Set `user_name` to the email of an active workspace user. + // Users can only set this to their own email. - For service principal: Set + // `service_principal_name` to the application ID. Requires the + // `servicePrincipal/user` role. If not specified, the alert will run as the + // request user. + RunAs *AlertRunAs `json:"run_as,omitempty"` + // The run as username or application ID of service principal. On Create and + // Update, this field can be set to application ID of an active service + // principal. Setting this field requires the servicePrincipal/user role. + // Deprecated: Use `run_as` field instead. This field will be removed in a + // future release. + RunAsUserName *string `json:"run_as_user_name,omitempty"` + Schedule *CronSchedule `json:"schedule,omitempty"` + // The timestamp indicating when the alert was updated. + UpdateTime *types.Time `json:"update_time,omitempty"` + // ID of the SQL warehouse attached to the alert. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type AlertEvaluation struct { + // Operator used for comparison in alert evaluation. + ComparisonOperator ComparisonOperator `json:"comparison_operator,omitempty"` + // Alert state if result is empty. Please avoid setting this field to be + // `UNKNOWN` because `UNKNOWN` state is planned to be deprecated. + EmptyResultState AlertEvaluationState `json:"empty_result_state,omitempty"` + // Timestamp of the last evaluation. + LastEvaluatedAt *types.Time `json:"last_evaluated_at,omitempty"` + // User or Notification Destination to notify when alert is triggered. + Notification *AlertNotification `json:"notification,omitempty"` + // Source column from result to use to evaluate alert + Source *AlertOperandColumn `json:"source,omitempty"` + // Latest state of alert evaluation. + State AlertEvaluationState `json:"state,omitempty"` + // Threshold to user for alert evaluation, can be a column or a value. + Threshold *AlertOperand `json:"threshold,omitempty"` +} + +type AlertNotification struct { + // Whether to notify alert subscribers when alert returns back to normal. + NotifyOnOk *bool `json:"notify_on_ok,omitempty"` + // Number of seconds an alert waits after being triggered before it is allowed + // to send another notification. If set to 0 or omitted, the alert will not send + // any further notifications after the first trigger Setting this value to 1 + // allows the alert to send a notification on every evaluation where the + // condition is met, effectively making it always retrigger for notification + // purposes. + RetriggerSeconds *int `json:"retrigger_seconds,omitempty"` + Subscriptions []AlertSubscription `json:"subscriptions,omitempty"` +} + +type AlertOperand struct { + Column *AlertOperandColumn `json:"column,omitempty"` + Value *AlertOperandValue `json:"value,omitempty"` +} + +type AlertOperandColumn struct { + // If not set, the behavior is equivalent to using `First row` in the UI. + Aggregation Aggregation `json:"aggregation,omitempty"` + Display *string `json:"display,omitempty"` + Name *string `json:"name,omitempty"` +} + +type AlertOperandValue struct { + BoolValue *bool `json:"bool_value,omitempty"` + DoubleValue *float64 `json:"double_value,omitempty"` + StringValue *string `json:"string_value,omitempty"` +} + +type AlertRunAs struct { + ServicePrincipalName *string `json:"service_principal_name,omitempty"` + UserName *string `json:"user_name,omitempty"` +} + +// A named parameter bound to the alert query. Only flat, named scalar +// parameters are supported; complex types such as ARRAY, MAP, and STRUCT are +// not.. +type AlertStatementParameter struct { + // The name of the parameter. Reference it in the query text as `:name`. + // Required, must be non-empty, and must be unique across the alert's + // parameters. + Name *string `json:"name,omitempty"` + // The SQL data type of the parameter, for example `STRING`, `INT`, or + // `DECIMAL(10, 2)`. If no type is given the type is assumed to be `STRING`. + // Complex types such as `ARRAY`, `MAP`, and `STRUCT` are not supported. + Type *string `json:"type,omitempty"` + // The value bound to the parameter, represented as a string. If omitted, the + // value is interpreted as NULL. + Value *string `json:"value,omitempty"` +} + +type AlertSubscription struct { + DestinationId *string `json:"destination_id,omitempty"` + UserEmail *string `json:"user_email,omitempty"` +} + +type CreateAlertRequest struct { + Alert *Alert `json:"alert,omitempty"` +} + +type CronSchedule struct { + // Indicate whether this schedule is paused or not. + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + // A cron expression using quartz syntax that specifies the schedule for this + // pipeline. Should use the quartz format described here: + // http://www.quartz-scheduler.org/documentation/quartz-2.1.7/tutorials/tutorial-lesson-06.html + QuartzCronSchedule *string `json:"quartz_cron_schedule,omitempty"` + // A Java timezone id. The schedule will be resolved using this timezone. This + // will be combined with the quartz_cron_schedule to determine the schedule. See + // https://docs.databricks.com/sql/language-manual/sql-ref-syntax-aux-conf-mgmt-set-timezone.html + // for details. + TimezoneId *string `json:"timezone_id,omitempty"` +} + +type ListAlertsRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListAlertsResponse struct { + Alerts []Alert `json:"alerts,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type TrashAlertRequest struct { + Id *string `json:"id,omitempty"` + // Whether to permanently delete the alert. If not set, the alert will only be + // soft deleted. + Purge *bool `json:"purge,omitempty"` +} + +type UpdateAlertRequest struct { + Alert *Alert `json:"alert,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +// AlertToSDK converts the mirror to the sdk-go type. +func AlertToSDK(w *Alert) (*sdk.Alert, error) { + if w == nil { + return nil, nil + } + out := &sdk.Alert{} + out.Id = w.Id + out.DisplayName = w.DisplayName + out.OwnerUserName = w.OwnerUserName + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.ParentPath = w.ParentPath + out.QueryText = w.QueryText + out.WarehouseId = w.WarehouseId + out.RunAsUserName = w.RunAsUserName + conv1, err := AlertEvaluationToSDK(w.Evaluation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Alert.Evaluation", err) + } + out.Evaluation = conv1 + conv2, err := CronScheduleToSDK(w.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Alert.Schedule", err) + } + out.Schedule = conv2 + out.LifecycleState = w.LifecycleState + out.CustomSummary = w.CustomSummary + out.CustomDescription = w.CustomDescription + conv3, err := AlertRunAsToSDK(w.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Alert.RunAs", err) + } + out.RunAs = conv3 + conv4, err := AlertRunAsToSDK(w.EffectiveRunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Alert.EffectiveRunAs", err) + } + out.EffectiveRunAs = conv4 + conv5, err := convertSlice(w.Parameters, AlertStatementParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Alert.Parameters", err) + } + out.Parameters = conv5 + out.CustomTemplateFormat = w.CustomTemplateFormat + return out, nil +} + +// AlertFromSDK converts the sdk-go type to the mirror. +func AlertFromSDK(v *sdk.Alert) (*Alert, error) { + if v == nil { + return nil, nil + } + out := &Alert{} + out.Id = v.Id + out.DisplayName = v.DisplayName + out.OwnerUserName = v.OwnerUserName + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.ParentPath = v.ParentPath + out.QueryText = v.QueryText + out.WarehouseId = v.WarehouseId + out.RunAsUserName = v.RunAsUserName + conv6, err := AlertEvaluationFromSDK(v.Evaluation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Alert.Evaluation", err) + } + out.Evaluation = conv6 + conv7, err := CronScheduleFromSDK(v.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Alert.Schedule", err) + } + out.Schedule = conv7 + out.LifecycleState = v.LifecycleState + out.CustomSummary = v.CustomSummary + out.CustomDescription = v.CustomDescription + conv8, err := AlertRunAsFromSDK(v.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Alert.RunAs", err) + } + out.RunAs = conv8 + conv9, err := AlertRunAsFromSDK(v.EffectiveRunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Alert.EffectiveRunAs", err) + } + out.EffectiveRunAs = conv9 + conv10, err := convertSlice(v.Parameters, AlertStatementParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Alert.Parameters", err) + } + out.Parameters = conv10 + out.CustomTemplateFormat = v.CustomTemplateFormat + return out, nil +} + +// AlertEvaluationToSDK converts the mirror to the sdk-go type. +func AlertEvaluationToSDK(w *AlertEvaluation) (*sdk.AlertEvaluation, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertEvaluation{} + conv11, err := AlertOperandColumnToSDK(w.Source) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertEvaluation.Source", err) + } + out.Source = conv11 + out.ComparisonOperator = w.ComparisonOperator + conv12, err := AlertOperandToSDK(w.Threshold) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertEvaluation.Threshold", err) + } + out.Threshold = conv12 + conv13, err := AlertNotificationToSDK(w.Notification) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertEvaluation.Notification", err) + } + out.Notification = conv13 + out.State = w.State + out.LastEvaluatedAt = w.LastEvaluatedAt + out.EmptyResultState = w.EmptyResultState + return out, nil +} + +// AlertEvaluationFromSDK converts the sdk-go type to the mirror. +func AlertEvaluationFromSDK(v *sdk.AlertEvaluation) (*AlertEvaluation, error) { + if v == nil { + return nil, nil + } + out := &AlertEvaluation{} + conv14, err := AlertOperandColumnFromSDK(v.Source) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertEvaluation.Source", err) + } + out.Source = conv14 + out.ComparisonOperator = v.ComparisonOperator + conv15, err := AlertOperandFromSDK(v.Threshold) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertEvaluation.Threshold", err) + } + out.Threshold = conv15 + conv16, err := AlertNotificationFromSDK(v.Notification) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertEvaluation.Notification", err) + } + out.Notification = conv16 + out.State = v.State + out.LastEvaluatedAt = v.LastEvaluatedAt + out.EmptyResultState = v.EmptyResultState + return out, nil +} + +// AlertNotificationToSDK converts the mirror to the sdk-go type. +func AlertNotificationToSDK(w *AlertNotification) (*sdk.AlertNotification, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertNotification{} + conv17, err := convertSlice(w.Subscriptions, AlertSubscriptionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertNotification.Subscriptions", err) + } + out.Subscriptions = conv17 + out.RetriggerSeconds = w.RetriggerSeconds + out.NotifyOnOk = w.NotifyOnOk + return out, nil +} + +// AlertNotificationFromSDK converts the sdk-go type to the mirror. +func AlertNotificationFromSDK(v *sdk.AlertNotification) (*AlertNotification, error) { + if v == nil { + return nil, nil + } + out := &AlertNotification{} + conv18, err := convertSlice(v.Subscriptions, AlertSubscriptionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertNotification.Subscriptions", err) + } + out.Subscriptions = conv18 + out.RetriggerSeconds = v.RetriggerSeconds + out.NotifyOnOk = v.NotifyOnOk + return out, nil +} + +// AlertOperandToSDK converts the mirror to the sdk-go type. +func AlertOperandToSDK(w *AlertOperand) (*sdk.AlertOperand, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertOperand{} + { + var members []string + if w.Column != nil { + members = append(members, "column") + } + if w.Value != nil { + members = append(members, "value") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Column != nil: + conv19, err := AlertOperandColumnToSDK(w.Column) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertOperand.Operand", err) + } + out.Operand = &sdk.AlertOperand_Operand_Column{Column: *conv19} + case w.Value != nil: + conv20, err := AlertOperandValueToSDK(w.Value) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertOperand.Operand", err) + } + out.Operand = &sdk.AlertOperand_Operand_Value{Value: *conv20} + } + return out, nil +} + +// AlertOperandFromSDK converts the sdk-go type to the mirror. +func AlertOperandFromSDK(v *sdk.AlertOperand) (*AlertOperand, error) { + if v == nil { + return nil, nil + } + out := &AlertOperand{} + switch value := v.Operand.(type) { + case *sdk.AlertOperand_Operand_Column: + if value != nil { + conv21, err := AlertOperandColumnFromSDK(&value.Column) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertOperand.Operand", err) + } + out.Column = conv21 + } + case *sdk.AlertOperand_Operand_Value: + if value != nil { + conv22, err := AlertOperandValueFromSDK(&value.Value) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertOperand.Operand", err) + } + out.Value = conv22 + } + } + return out, nil +} + +// AlertOperandColumnToSDK converts the mirror to the sdk-go type. +func AlertOperandColumnToSDK(w *AlertOperandColumn) (*sdk.AlertOperandColumn, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertOperandColumn{} + out.Name = w.Name + out.Display = w.Display + out.Aggregation = w.Aggregation + return out, nil +} + +// AlertOperandColumnFromSDK converts the sdk-go type to the mirror. +func AlertOperandColumnFromSDK(v *sdk.AlertOperandColumn) (*AlertOperandColumn, error) { + if v == nil { + return nil, nil + } + out := &AlertOperandColumn{} + out.Name = v.Name + out.Display = v.Display + out.Aggregation = v.Aggregation + return out, nil +} + +// AlertOperandValueToSDK converts the mirror to the sdk-go type. +func AlertOperandValueToSDK(w *AlertOperandValue) (*sdk.AlertOperandValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertOperandValue{} + { + var members []string + if w.StringValue != nil { + members = append(members, "string_value") + } + if w.DoubleValue != nil { + members = append(members, "double_value") + } + if w.BoolValue != nil { + members = append(members, "bool_value") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.StringValue != nil: + out.Value = &sdk.AlertOperandValue_Value_StringValue{StringValue: *w.StringValue} + case w.DoubleValue != nil: + out.Value = &sdk.AlertOperandValue_Value_DoubleValue{DoubleValue: *w.DoubleValue} + case w.BoolValue != nil: + out.Value = &sdk.AlertOperandValue_Value_BoolValue{BoolValue: *w.BoolValue} + } + return out, nil +} + +// AlertOperandValueFromSDK converts the sdk-go type to the mirror. +func AlertOperandValueFromSDK(v *sdk.AlertOperandValue) (*AlertOperandValue, error) { + if v == nil { + return nil, nil + } + out := &AlertOperandValue{} + switch value := v.Value.(type) { + case *sdk.AlertOperandValue_Value_StringValue: + if value != nil { + out.StringValue = new(value.StringValue) + } + case *sdk.AlertOperandValue_Value_DoubleValue: + if value != nil { + out.DoubleValue = new(value.DoubleValue) + } + case *sdk.AlertOperandValue_Value_BoolValue: + if value != nil { + out.BoolValue = new(value.BoolValue) + } + } + return out, nil +} + +// AlertRunAsToSDK converts the mirror to the sdk-go type. +func AlertRunAsToSDK(w *AlertRunAs) (*sdk.AlertRunAs, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertRunAs{} + { + var members []string + if w.UserName != nil { + members = append(members, "user_name") + } + if w.ServicePrincipalName != nil { + members = append(members, "service_principal_name") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UserName != nil: + out.Identity = &sdk.AlertRunAs_Identity_UserName{UserName: *w.UserName} + case w.ServicePrincipalName != nil: + out.Identity = &sdk.AlertRunAs_Identity_ServicePrincipalName{ServicePrincipalName: *w.ServicePrincipalName} + } + return out, nil +} + +// AlertRunAsFromSDK converts the sdk-go type to the mirror. +func AlertRunAsFromSDK(v *sdk.AlertRunAs) (*AlertRunAs, error) { + if v == nil { + return nil, nil + } + out := &AlertRunAs{} + switch value := v.Identity.(type) { + case *sdk.AlertRunAs_Identity_UserName: + if value != nil { + out.UserName = new(value.UserName) + } + case *sdk.AlertRunAs_Identity_ServicePrincipalName: + if value != nil { + out.ServicePrincipalName = new(value.ServicePrincipalName) + } + } + return out, nil +} + +// AlertStatementParameterToSDK converts the mirror to the sdk-go type. +func AlertStatementParameterToSDK(w *AlertStatementParameter) (*sdk.AlertStatementParameter, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertStatementParameter{} + out.Name = w.Name + out.Value = w.Value + out.Type = w.Type + return out, nil +} + +// AlertStatementParameterFromSDK converts the sdk-go type to the mirror. +func AlertStatementParameterFromSDK(v *sdk.AlertStatementParameter) (*AlertStatementParameter, error) { + if v == nil { + return nil, nil + } + out := &AlertStatementParameter{} + out.Name = v.Name + out.Value = v.Value + out.Type = v.Type + return out, nil +} + +// AlertSubscriptionToSDK converts the mirror to the sdk-go type. +func AlertSubscriptionToSDK(w *AlertSubscription) (*sdk.AlertSubscription, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertSubscription{} + { + var members []string + if w.UserEmail != nil { + members = append(members, "user_email") + } + if w.DestinationId != nil { + members = append(members, "destination_id") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UserEmail != nil: + out.SubscriptionType = &sdk.AlertSubscription_SubscriptionType_UserEmail{UserEmail: *w.UserEmail} + case w.DestinationId != nil: + out.SubscriptionType = &sdk.AlertSubscription_SubscriptionType_DestinationId{DestinationId: *w.DestinationId} + } + return out, nil +} + +// AlertSubscriptionFromSDK converts the sdk-go type to the mirror. +func AlertSubscriptionFromSDK(v *sdk.AlertSubscription) (*AlertSubscription, error) { + if v == nil { + return nil, nil + } + out := &AlertSubscription{} + switch value := v.SubscriptionType.(type) { + case *sdk.AlertSubscription_SubscriptionType_UserEmail: + if value != nil { + out.UserEmail = new(value.UserEmail) + } + case *sdk.AlertSubscription_SubscriptionType_DestinationId: + if value != nil { + out.DestinationId = new(value.DestinationId) + } + } + return out, nil +} + +// CreateAlertRequestToSDK converts the mirror to the sdk-go type. +func CreateAlertRequestToSDK(w *CreateAlertRequest) (*sdk.CreateAlertRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAlertRequest{} + conv23, err := AlertToSDK(w.Alert) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAlertRequest.Alert", err) + } + out.Alert = conv23 + return out, nil +} + +// CreateAlertRequestFromSDK converts the sdk-go type to the mirror. +func CreateAlertRequestFromSDK(v *sdk.CreateAlertRequest) (*CreateAlertRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateAlertRequest{} + conv24, err := AlertFromSDK(v.Alert) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAlertRequest.Alert", err) + } + out.Alert = conv24 + return out, nil +} + +// CronScheduleToSDK converts the mirror to the sdk-go type. +func CronScheduleToSDK(w *CronSchedule) (*sdk.CronSchedule, error) { + if w == nil { + return nil, nil + } + out := &sdk.CronSchedule{} + out.QuartzCronSchedule = w.QuartzCronSchedule + out.TimezoneId = w.TimezoneId + out.PauseStatus = w.PauseStatus + return out, nil +} + +// CronScheduleFromSDK converts the sdk-go type to the mirror. +func CronScheduleFromSDK(v *sdk.CronSchedule) (*CronSchedule, error) { + if v == nil { + return nil, nil + } + out := &CronSchedule{} + out.QuartzCronSchedule = v.QuartzCronSchedule + out.TimezoneId = v.TimezoneId + out.PauseStatus = v.PauseStatus + return out, nil +} + +// ListAlertsRequestToSDK converts the mirror to the sdk-go type. +func ListAlertsRequestToSDK(w *ListAlertsRequest) (*sdk.ListAlertsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAlertsRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListAlertsRequestFromSDK converts the sdk-go type to the mirror. +func ListAlertsRequestFromSDK(v *sdk.ListAlertsRequest) (*ListAlertsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListAlertsRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListAlertsResponseToSDK converts the mirror to the sdk-go type. +func ListAlertsResponseToSDK(w *ListAlertsResponse) (*sdk.ListAlertsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAlertsResponse{} + conv25, err := convertSlice(w.Alerts, AlertToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAlertsResponse.Alerts", err) + } + out.Alerts = conv25 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListAlertsResponseFromSDK converts the sdk-go type to the mirror. +func ListAlertsResponseFromSDK(v *sdk.ListAlertsResponse) (*ListAlertsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAlertsResponse{} + conv26, err := convertSlice(v.Alerts, AlertFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAlertsResponse.Alerts", err) + } + out.Alerts = conv26 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// TrashAlertRequestToSDK converts the mirror to the sdk-go type. +func TrashAlertRequestToSDK(w *TrashAlertRequest) (*sdk.TrashAlertRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.TrashAlertRequest{} + out.Id = w.Id + out.Purge = w.Purge + return out, nil +} + +// TrashAlertRequestFromSDK converts the sdk-go type to the mirror. +func TrashAlertRequestFromSDK(v *sdk.TrashAlertRequest) (*TrashAlertRequest, error) { + if v == nil { + return nil, nil + } + out := &TrashAlertRequest{} + out.Id = v.Id + out.Purge = v.Purge + return out, nil +} + +// UpdateAlertRequestToSDK converts the mirror to the sdk-go type. +func UpdateAlertRequestToSDK(w *UpdateAlertRequest) (*sdk.UpdateAlertRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAlertRequest{} + conv27, err := AlertToSDK(w.Alert) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAlertRequest.Alert", err) + } + out.Alert = conv27 + mask28, err := fieldMaskFromString[sdk.Alert](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAlertRequest.UpdateMask", err) + } + out.UpdateMask = mask28 + return out, nil +} + +// UpdateAlertRequestFromSDK converts the sdk-go type to the mirror. +func UpdateAlertRequestFromSDK(v *sdk.UpdateAlertRequest) (*UpdateAlertRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateAlertRequest{} + conv29, err := AlertFromSDK(v.Alert) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAlertRequest.Alert", err) + } + out.Alert = conv29 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/apps/v1/types.generated.go b/libs/sdktypes/apps/v1/types.generated.go new file mode 100644 index 00000000000..8bee3a45999 --- /dev/null +++ b/libs/sdktypes/apps/v1/types.generated.go @@ -0,0 +1,3133 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/apps/v1. DO NOT EDIT. + +package apps + +import ( + json "encoding/json" + fmt "fmt" + sdk "github.com/databricks/sdk-go/apps/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + ComputeSize = sdk.ComputeSize + ErrorCode = sdk.ErrorCode + SpaceUpdateState = sdk.SpaceUpdateState + AppDeployment_Mode = sdk.AppDeployment_Mode + AppDeployment_State = sdk.AppDeployment_State + AppManifest_AppResourceExperimentSpec_ExperimentPermission = sdk.AppManifest_AppResourceExperimentSpec_ExperimentPermission + AppManifest_AppResourceJobSpec_JobPermission = sdk.AppManifest_AppResourceJobSpec_JobPermission + AppManifest_AppResourceSecretSpec_SecretPermission = sdk.AppManifest_AppResourceSecretSpec_SecretPermission + AppManifest_AppResourceServingEndpointSpec_ServingEndpointPermission = sdk.AppManifest_AppResourceServingEndpointSpec_ServingEndpointPermission + AppManifest_AppResourceSqlWarehouseSpec_SqlWarehousePermission = sdk.AppManifest_AppResourceSqlWarehouseSpec_SqlWarehousePermission + AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission + AppManifest_AppResourceUcSecurableSpec_UcSecurableType = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurableType + AppResourceApp_AppPermission = sdk.AppResourceApp_AppPermission + AppResourceDatabase_DatabasePermission = sdk.AppResourceDatabase_DatabasePermission + AppResourceExperiment_ExperimentPermission = sdk.AppResourceExperiment_ExperimentPermission + AppResourceGenieSpace_GenieSpacePermission = sdk.AppResourceGenieSpace_GenieSpacePermission + AppResourceJob_JobPermission = sdk.AppResourceJob_JobPermission + AppResourcePostgres_PostgresPermission = sdk.AppResourcePostgres_PostgresPermission + AppResourceSecret_SecretPermission = sdk.AppResourceSecret_SecretPermission + AppResourceServingEndpoint_ServingEndpointPermission = sdk.AppResourceServingEndpoint_ServingEndpointPermission + AppResourceSqlWarehouse_SqlWarehousePermission = sdk.AppResourceSqlWarehouse_SqlWarehousePermission + AppResourceUcSecurable_UcSecurablePermission = sdk.AppResourceUcSecurable_UcSecurablePermission + AppResourceUcSecurable_UcSecurableType = sdk.AppResourceUcSecurable_UcSecurableType + AppUpdate_UpdateStatus_UpdateState = sdk.AppUpdate_UpdateStatus_UpdateState + ApplicationStatus_ApplicationState = sdk.ApplicationStatus_ApplicationState + ComputeStatus_ComputeState = sdk.ComputeStatus_ComputeState + SpaceStatus_SpaceState = sdk.SpaceStatus_SpaceState +) + +const ( + ComputeSize_Unspecified = sdk.ComputeSize_Unspecified + ComputeSize_Medium = sdk.ComputeSize_Medium + ComputeSize_Large = sdk.ComputeSize_Large + ComputeSize_Xlarge = sdk.ComputeSize_Xlarge + ErrorCode_Unspecified = sdk.ErrorCode_Unspecified + ErrorCode_InternalError = sdk.ErrorCode_InternalError + ErrorCode_TemporarilyUnavailable = sdk.ErrorCode_TemporarilyUnavailable + ErrorCode_IoError = sdk.ErrorCode_IoError + ErrorCode_BadRequest = sdk.ErrorCode_BadRequest + ErrorCode_ServiceUnderMaintenance = sdk.ErrorCode_ServiceUnderMaintenance + ErrorCode_WorkspaceTemporarilyUnavailable = sdk.ErrorCode_WorkspaceTemporarilyUnavailable + ErrorCode_DeadlineExceeded = sdk.ErrorCode_DeadlineExceeded + ErrorCode_Cancelled = sdk.ErrorCode_Cancelled + ErrorCode_ResourceExhausted = sdk.ErrorCode_ResourceExhausted + ErrorCode_Aborted = sdk.ErrorCode_Aborted + ErrorCode_NotFound = sdk.ErrorCode_NotFound + ErrorCode_AlreadyExists = sdk.ErrorCode_AlreadyExists + ErrorCode_Unauthenticated = sdk.ErrorCode_Unauthenticated + ErrorCode_Unavailable = sdk.ErrorCode_Unavailable + ErrorCode_InvalidParameterValue = sdk.ErrorCode_InvalidParameterValue + ErrorCode_EndpointNotFound = sdk.ErrorCode_EndpointNotFound + ErrorCode_MalformedRequest = sdk.ErrorCode_MalformedRequest + ErrorCode_InvalidState = sdk.ErrorCode_InvalidState + ErrorCode_PermissionDenied = sdk.ErrorCode_PermissionDenied + ErrorCode_FeatureDisabled = sdk.ErrorCode_FeatureDisabled + ErrorCode_CustomerUnauthorized = sdk.ErrorCode_CustomerUnauthorized + ErrorCode_RequestLimitExceeded = sdk.ErrorCode_RequestLimitExceeded + ErrorCode_ResourceConflict = sdk.ErrorCode_ResourceConflict + ErrorCode_UnparseableHttpError = sdk.ErrorCode_UnparseableHttpError + ErrorCode_NotImplemented = sdk.ErrorCode_NotImplemented + ErrorCode_DataLoss = sdk.ErrorCode_DataLoss + ErrorCode_InvalidStateTransition = sdk.ErrorCode_InvalidStateTransition + ErrorCode_CouldNotAcquireLock = sdk.ErrorCode_CouldNotAcquireLock + ErrorCode_ResourceAlreadyExists = sdk.ErrorCode_ResourceAlreadyExists + ErrorCode_ResourceDoesNotExist = sdk.ErrorCode_ResourceDoesNotExist + ErrorCode_QuotaExceeded = sdk.ErrorCode_QuotaExceeded + ErrorCode_MaxBlockSizeExceeded = sdk.ErrorCode_MaxBlockSizeExceeded + ErrorCode_MaxReadSizeExceeded = sdk.ErrorCode_MaxReadSizeExceeded + ErrorCode_PartialDelete = sdk.ErrorCode_PartialDelete + ErrorCode_MaxListSizeExceeded = sdk.ErrorCode_MaxListSizeExceeded + ErrorCode_DryRunFailed = sdk.ErrorCode_DryRunFailed + ErrorCode_ResourceLimitExceeded = sdk.ErrorCode_ResourceLimitExceeded + ErrorCode_DirectoryNotEmpty = sdk.ErrorCode_DirectoryNotEmpty + ErrorCode_DirectoryProtected = sdk.ErrorCode_DirectoryProtected + ErrorCode_MaxNotebookSizeExceeded = sdk.ErrorCode_MaxNotebookSizeExceeded + ErrorCode_MaxChildNodeSizeExceeded = sdk.ErrorCode_MaxChildNodeSizeExceeded + ErrorCode_SearchQueryTooLong = sdk.ErrorCode_SearchQueryTooLong + ErrorCode_SearchQueryTooShort = sdk.ErrorCode_SearchQueryTooShort + ErrorCode_ManagedResourceGroupDoesNotExist = sdk.ErrorCode_ManagedResourceGroupDoesNotExist + ErrorCode_PermissionNotPropagated = sdk.ErrorCode_PermissionNotPropagated + ErrorCode_DeploymentTimeout = sdk.ErrorCode_DeploymentTimeout + ErrorCode_GitConflict = sdk.ErrorCode_GitConflict + ErrorCode_GitUnknownRef = sdk.ErrorCode_GitUnknownRef + ErrorCode_GitSensitiveTokenDetected = sdk.ErrorCode_GitSensitiveTokenDetected + ErrorCode_GitUrlNotOnAllowList = sdk.ErrorCode_GitUrlNotOnAllowList + ErrorCode_GitRemoteError = sdk.ErrorCode_GitRemoteError + ErrorCode_ProjectsOperationTimeout = sdk.ErrorCode_ProjectsOperationTimeout + ErrorCode_IpynbFileInRepo = sdk.ErrorCode_IpynbFileInRepo + ErrorCode_InsecurePartnerResponse = sdk.ErrorCode_InsecurePartnerResponse + ErrorCode_MalformedPartnerResponse = sdk.ErrorCode_MalformedPartnerResponse + ErrorCode_MetastoreDoesNotExist = sdk.ErrorCode_MetastoreDoesNotExist + ErrorCode_DacDoesNotExist = sdk.ErrorCode_DacDoesNotExist + ErrorCode_CatalogDoesNotExist = sdk.ErrorCode_CatalogDoesNotExist + ErrorCode_SchemaDoesNotExist = sdk.ErrorCode_SchemaDoesNotExist + ErrorCode_TableDoesNotExist = sdk.ErrorCode_TableDoesNotExist + ErrorCode_ShareDoesNotExist = sdk.ErrorCode_ShareDoesNotExist + ErrorCode_RecipientDoesNotExist = sdk.ErrorCode_RecipientDoesNotExist + ErrorCode_StorageCredentialDoesNotExist = sdk.ErrorCode_StorageCredentialDoesNotExist + ErrorCode_ExternalLocationDoesNotExist = sdk.ErrorCode_ExternalLocationDoesNotExist + ErrorCode_PrincipalDoesNotExist = sdk.ErrorCode_PrincipalDoesNotExist + ErrorCode_ProviderDoesNotExist = sdk.ErrorCode_ProviderDoesNotExist + ErrorCode_MetastoreAlreadyExists = sdk.ErrorCode_MetastoreAlreadyExists + ErrorCode_DacAlreadyExists = sdk.ErrorCode_DacAlreadyExists + ErrorCode_CatalogAlreadyExists = sdk.ErrorCode_CatalogAlreadyExists + ErrorCode_SchemaAlreadyExists = sdk.ErrorCode_SchemaAlreadyExists + ErrorCode_TableAlreadyExists = sdk.ErrorCode_TableAlreadyExists + ErrorCode_ShareAlreadyExists = sdk.ErrorCode_ShareAlreadyExists + ErrorCode_RecipientAlreadyExists = sdk.ErrorCode_RecipientAlreadyExists + ErrorCode_StorageCredentialAlreadyExists = sdk.ErrorCode_StorageCredentialAlreadyExists + ErrorCode_ExternalLocationAlreadyExists = sdk.ErrorCode_ExternalLocationAlreadyExists + ErrorCode_ProviderAlreadyExists = sdk.ErrorCode_ProviderAlreadyExists + ErrorCode_CatalogNotEmpty = sdk.ErrorCode_CatalogNotEmpty + ErrorCode_SchemaNotEmpty = sdk.ErrorCode_SchemaNotEmpty + ErrorCode_MetastoreNotEmpty = sdk.ErrorCode_MetastoreNotEmpty + ErrorCode_ProviderShareNotAccessible = sdk.ErrorCode_ProviderShareNotAccessible + SpaceUpdateState_Unspecified = sdk.SpaceUpdateState_Unspecified + SpaceUpdateState_NotUpdated = sdk.SpaceUpdateState_NotUpdated + SpaceUpdateState_InProgress = sdk.SpaceUpdateState_InProgress + SpaceUpdateState_Succeeded = sdk.SpaceUpdateState_Succeeded + SpaceUpdateState_Failed = sdk.SpaceUpdateState_Failed + AppDeployment_Mode_Unspecified = sdk.AppDeployment_Mode_Unspecified + AppDeployment_Mode_Snapshot = sdk.AppDeployment_Mode_Snapshot + AppDeployment_Mode_AutoSync = sdk.AppDeployment_Mode_AutoSync + AppDeployment_State_Unspecified = sdk.AppDeployment_State_Unspecified + AppDeployment_State_Succeeded = sdk.AppDeployment_State_Succeeded + AppDeployment_State_Failed = sdk.AppDeployment_State_Failed + AppDeployment_State_InProgress = sdk.AppDeployment_State_InProgress + AppDeployment_State_Cancelled = sdk.AppDeployment_State_Cancelled + AppManifest_AppResourceExperimentSpec_ExperimentPermission_Unspecified = sdk.AppManifest_AppResourceExperimentSpec_ExperimentPermission_Unspecified + AppManifest_AppResourceExperimentSpec_ExperimentPermission_CanManage = sdk.AppManifest_AppResourceExperimentSpec_ExperimentPermission_CanManage + AppManifest_AppResourceExperimentSpec_ExperimentPermission_CanEdit = sdk.AppManifest_AppResourceExperimentSpec_ExperimentPermission_CanEdit + AppManifest_AppResourceExperimentSpec_ExperimentPermission_CanRead = sdk.AppManifest_AppResourceExperimentSpec_ExperimentPermission_CanRead + AppManifest_AppResourceJobSpec_JobPermission_Unspecified = sdk.AppManifest_AppResourceJobSpec_JobPermission_Unspecified + AppManifest_AppResourceJobSpec_JobPermission_CanManage = sdk.AppManifest_AppResourceJobSpec_JobPermission_CanManage + AppManifest_AppResourceJobSpec_JobPermission_IsOwner = sdk.AppManifest_AppResourceJobSpec_JobPermission_IsOwner + AppManifest_AppResourceJobSpec_JobPermission_CanManageRun = sdk.AppManifest_AppResourceJobSpec_JobPermission_CanManageRun + AppManifest_AppResourceJobSpec_JobPermission_CanView = sdk.AppManifest_AppResourceJobSpec_JobPermission_CanView + AppManifest_AppResourceSecretSpec_SecretPermission_Unspecified = sdk.AppManifest_AppResourceSecretSpec_SecretPermission_Unspecified + AppManifest_AppResourceSecretSpec_SecretPermission_Read = sdk.AppManifest_AppResourceSecretSpec_SecretPermission_Read + AppManifest_AppResourceSecretSpec_SecretPermission_Write = sdk.AppManifest_AppResourceSecretSpec_SecretPermission_Write + AppManifest_AppResourceSecretSpec_SecretPermission_Manage = sdk.AppManifest_AppResourceSecretSpec_SecretPermission_Manage + AppManifest_AppResourceServingEndpointSpec_ServingEndpointPermission_Unspecified = sdk.AppManifest_AppResourceServingEndpointSpec_ServingEndpointPermission_Unspecified + AppManifest_AppResourceServingEndpointSpec_ServingEndpointPermission_CanManage = sdk.AppManifest_AppResourceServingEndpointSpec_ServingEndpointPermission_CanManage + AppManifest_AppResourceServingEndpointSpec_ServingEndpointPermission_CanQuery = sdk.AppManifest_AppResourceServingEndpointSpec_ServingEndpointPermission_CanQuery + AppManifest_AppResourceServingEndpointSpec_ServingEndpointPermission_CanView = sdk.AppManifest_AppResourceServingEndpointSpec_ServingEndpointPermission_CanView + AppManifest_AppResourceSqlWarehouseSpec_SqlWarehousePermission_Unspecified = sdk.AppManifest_AppResourceSqlWarehouseSpec_SqlWarehousePermission_Unspecified + AppManifest_AppResourceSqlWarehouseSpec_SqlWarehousePermission_CanManage = sdk.AppManifest_AppResourceSqlWarehouseSpec_SqlWarehousePermission_CanManage + AppManifest_AppResourceSqlWarehouseSpec_SqlWarehousePermission_CanUse = sdk.AppManifest_AppResourceSqlWarehouseSpec_SqlWarehousePermission_CanUse + AppManifest_AppResourceSqlWarehouseSpec_SqlWarehousePermission_IsOwner = sdk.AppManifest_AppResourceSqlWarehouseSpec_SqlWarehousePermission_IsOwner + AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_Unspecified = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_Unspecified + AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_ReadVolume = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_ReadVolume + AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_WriteVolume = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_WriteVolume + AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_Manage = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_Manage + AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_Select = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_Select + AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_Execute = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_Execute + AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_UseConnection = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission_UseConnection + AppManifest_AppResourceUcSecurableSpec_UcSecurableType_Unspecified = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurableType_Unspecified + AppManifest_AppResourceUcSecurableSpec_UcSecurableType_Volume = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurableType_Volume + AppManifest_AppResourceUcSecurableSpec_UcSecurableType_Table = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurableType_Table + AppManifest_AppResourceUcSecurableSpec_UcSecurableType_Function = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurableType_Function + AppManifest_AppResourceUcSecurableSpec_UcSecurableType_Connection = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurableType_Connection + AppManifest_AppResourceUcSecurableSpec_UcSecurableType_ModelService = sdk.AppManifest_AppResourceUcSecurableSpec_UcSecurableType_ModelService + AppResourceApp_AppPermission_Unspecified = sdk.AppResourceApp_AppPermission_Unspecified + AppResourceApp_AppPermission_CanUse = sdk.AppResourceApp_AppPermission_CanUse + AppResourceDatabase_DatabasePermission_Unspecified = sdk.AppResourceDatabase_DatabasePermission_Unspecified + AppResourceDatabase_DatabasePermission_CanConnectAndCreate = sdk.AppResourceDatabase_DatabasePermission_CanConnectAndCreate + AppResourceExperiment_ExperimentPermission_Unspecified = sdk.AppResourceExperiment_ExperimentPermission_Unspecified + AppResourceExperiment_ExperimentPermission_CanManage = sdk.AppResourceExperiment_ExperimentPermission_CanManage + AppResourceExperiment_ExperimentPermission_CanEdit = sdk.AppResourceExperiment_ExperimentPermission_CanEdit + AppResourceExperiment_ExperimentPermission_CanRead = sdk.AppResourceExperiment_ExperimentPermission_CanRead + AppResourceGenieSpace_GenieSpacePermission_Unspecified = sdk.AppResourceGenieSpace_GenieSpacePermission_Unspecified + AppResourceGenieSpace_GenieSpacePermission_CanManage = sdk.AppResourceGenieSpace_GenieSpacePermission_CanManage + AppResourceGenieSpace_GenieSpacePermission_CanEdit = sdk.AppResourceGenieSpace_GenieSpacePermission_CanEdit + AppResourceGenieSpace_GenieSpacePermission_CanRun = sdk.AppResourceGenieSpace_GenieSpacePermission_CanRun + AppResourceGenieSpace_GenieSpacePermission_CanView = sdk.AppResourceGenieSpace_GenieSpacePermission_CanView + AppResourceJob_JobPermission_Unspecified = sdk.AppResourceJob_JobPermission_Unspecified + AppResourceJob_JobPermission_CanManage = sdk.AppResourceJob_JobPermission_CanManage + AppResourceJob_JobPermission_IsOwner = sdk.AppResourceJob_JobPermission_IsOwner + AppResourceJob_JobPermission_CanManageRun = sdk.AppResourceJob_JobPermission_CanManageRun + AppResourceJob_JobPermission_CanView = sdk.AppResourceJob_JobPermission_CanView + AppResourcePostgres_PostgresPermission_Unspecified = sdk.AppResourcePostgres_PostgresPermission_Unspecified + AppResourcePostgres_PostgresPermission_CanConnectAndCreate = sdk.AppResourcePostgres_PostgresPermission_CanConnectAndCreate + AppResourceSecret_SecretPermission_Unspecified = sdk.AppResourceSecret_SecretPermission_Unspecified + AppResourceSecret_SecretPermission_Read = sdk.AppResourceSecret_SecretPermission_Read + AppResourceSecret_SecretPermission_Write = sdk.AppResourceSecret_SecretPermission_Write + AppResourceSecret_SecretPermission_Manage = sdk.AppResourceSecret_SecretPermission_Manage + AppResourceServingEndpoint_ServingEndpointPermission_Unspecified = sdk.AppResourceServingEndpoint_ServingEndpointPermission_Unspecified + AppResourceServingEndpoint_ServingEndpointPermission_CanManage = sdk.AppResourceServingEndpoint_ServingEndpointPermission_CanManage + AppResourceServingEndpoint_ServingEndpointPermission_CanQuery = sdk.AppResourceServingEndpoint_ServingEndpointPermission_CanQuery + AppResourceServingEndpoint_ServingEndpointPermission_CanView = sdk.AppResourceServingEndpoint_ServingEndpointPermission_CanView + AppResourceSqlWarehouse_SqlWarehousePermission_Unspecified = sdk.AppResourceSqlWarehouse_SqlWarehousePermission_Unspecified + AppResourceSqlWarehouse_SqlWarehousePermission_CanManage = sdk.AppResourceSqlWarehouse_SqlWarehousePermission_CanManage + AppResourceSqlWarehouse_SqlWarehousePermission_CanUse = sdk.AppResourceSqlWarehouse_SqlWarehousePermission_CanUse + AppResourceSqlWarehouse_SqlWarehousePermission_IsOwner = sdk.AppResourceSqlWarehouse_SqlWarehousePermission_IsOwner + AppResourceUcSecurable_UcSecurablePermission_Unspecified = sdk.AppResourceUcSecurable_UcSecurablePermission_Unspecified + AppResourceUcSecurable_UcSecurablePermission_ReadVolume = sdk.AppResourceUcSecurable_UcSecurablePermission_ReadVolume + AppResourceUcSecurable_UcSecurablePermission_WriteVolume = sdk.AppResourceUcSecurable_UcSecurablePermission_WriteVolume + AppResourceUcSecurable_UcSecurablePermission_Select = sdk.AppResourceUcSecurable_UcSecurablePermission_Select + AppResourceUcSecurable_UcSecurablePermission_Execute = sdk.AppResourceUcSecurable_UcSecurablePermission_Execute + AppResourceUcSecurable_UcSecurablePermission_UseConnection = sdk.AppResourceUcSecurable_UcSecurablePermission_UseConnection + AppResourceUcSecurable_UcSecurablePermission_Modify = sdk.AppResourceUcSecurable_UcSecurablePermission_Modify + AppResourceUcSecurable_UcSecurableType_Unspecified = sdk.AppResourceUcSecurable_UcSecurableType_Unspecified + AppResourceUcSecurable_UcSecurableType_Volume = sdk.AppResourceUcSecurable_UcSecurableType_Volume + AppResourceUcSecurable_UcSecurableType_Table = sdk.AppResourceUcSecurable_UcSecurableType_Table + AppResourceUcSecurable_UcSecurableType_Function = sdk.AppResourceUcSecurable_UcSecurableType_Function + AppResourceUcSecurable_UcSecurableType_Connection = sdk.AppResourceUcSecurable_UcSecurableType_Connection + AppResourceUcSecurable_UcSecurableType_ModelService = sdk.AppResourceUcSecurable_UcSecurableType_ModelService + AppUpdate_UpdateStatus_UpdateState_Unspecified = sdk.AppUpdate_UpdateStatus_UpdateState_Unspecified + AppUpdate_UpdateStatus_UpdateState_NotUpdated = sdk.AppUpdate_UpdateStatus_UpdateState_NotUpdated + AppUpdate_UpdateStatus_UpdateState_InProgress = sdk.AppUpdate_UpdateStatus_UpdateState_InProgress + AppUpdate_UpdateStatus_UpdateState_Succeeded = sdk.AppUpdate_UpdateStatus_UpdateState_Succeeded + AppUpdate_UpdateStatus_UpdateState_Failed = sdk.AppUpdate_UpdateStatus_UpdateState_Failed + ApplicationStatus_ApplicationState_Unspecified = sdk.ApplicationStatus_ApplicationState_Unspecified + ApplicationStatus_ApplicationState_Deploying = sdk.ApplicationStatus_ApplicationState_Deploying + ApplicationStatus_ApplicationState_Running = sdk.ApplicationStatus_ApplicationState_Running + ApplicationStatus_ApplicationState_Crashed = sdk.ApplicationStatus_ApplicationState_Crashed + ApplicationStatus_ApplicationState_Unavailable = sdk.ApplicationStatus_ApplicationState_Unavailable + ComputeStatus_ComputeState_Unspecified = sdk.ComputeStatus_ComputeState_Unspecified + ComputeStatus_ComputeState_Error = sdk.ComputeStatus_ComputeState_Error + ComputeStatus_ComputeState_Deleting = sdk.ComputeStatus_ComputeState_Deleting + ComputeStatus_ComputeState_Starting = sdk.ComputeStatus_ComputeState_Starting + ComputeStatus_ComputeState_Stopping = sdk.ComputeStatus_ComputeState_Stopping + ComputeStatus_ComputeState_Updating = sdk.ComputeStatus_ComputeState_Updating + ComputeStatus_ComputeState_Stopped = sdk.ComputeStatus_ComputeState_Stopped + ComputeStatus_ComputeState_Active = sdk.ComputeStatus_ComputeState_Active + SpaceStatus_SpaceState_Unspecified = sdk.SpaceStatus_SpaceState_Unspecified + SpaceStatus_SpaceState_SpaceCreating = sdk.SpaceStatus_SpaceState_SpaceCreating + SpaceStatus_SpaceState_SpaceActive = sdk.SpaceStatus_SpaceState_SpaceActive + SpaceStatus_SpaceState_SpaceError = sdk.SpaceStatus_SpaceState_SpaceError + SpaceStatus_SpaceState_SpaceDeleting = sdk.SpaceStatus_SpaceState_SpaceDeleting + SpaceStatus_SpaceState_SpaceDeleted = sdk.SpaceStatus_SpaceState_SpaceDeleted + SpaceStatus_SpaceState_SpaceUpdating = sdk.SpaceStatus_SpaceState_SpaceUpdating +) + +// Databricks Error that is returned by all Databricks APIs.. +type ApiError struct { + Details []json.RawMessage `json:"details,omitempty"` + ErrorCode ErrorCode `json:"error_code,omitempty"` + Message *string `json:"message,omitempty"` + StackTrace *string `json:"stack_trace,omitempty"` +} + +type App struct { + // The active deployment of the app. A deployment is considered active when it + // has been deployed to the app compute. + ActiveDeployment *AppDeployment `json:"active_deployment,omitempty"` + AppStatus *ApplicationStatus `json:"app_status,omitempty"` + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // Maximum number of app instances the app is configured to run. Must be set + // together with `compute_min_instances`. + ComputeMaxInstances *int `json:"compute_max_instances,omitempty"` + // Minimum number of app instances the app is configured to run. Must be set + // together with `compute_max_instances`. + ComputeMinInstances *int `json:"compute_min_instances,omitempty"` + ComputeSize ComputeSize `json:"compute_size,omitempty"` + ComputeStatus *ComputeStatus `json:"compute_status,omitempty"` + // The creation time of the app. Formatted timestamp in ISO 6801. + CreateTime *types.Time `json:"create_time,omitempty"` + // The email of the user that created the app. + Creator *string `json:"creator,omitempty"` + // The Git source of the app's most recent active deployment, including the + // repository configuration and the resolved reference. Populated by the system + // after a Git-based deployment and used as the default reference when automatic + // deployments are enabled. + DefaultGitSource *GitSource `json:"default_git_source,omitempty"` + // The default workspace file system path of the source code from which app + // deployment are created. This field tracks the workspace source code path of + // the last active deployment. + DefaultSourceCodePath *string `json:"default_source_code_path,omitempty"` + // The description of the app. + Description *string `json:"description,omitempty"` + EffectiveBudgetPolicyId *string `json:"effective_budget_policy_id,omitempty"` + EffectiveUsagePolicyId *string `json:"effective_usage_policy_id,omitempty"` + // The effective api scopes granted to the user access token. + EffectiveUserApiScopes []string `json:"effective_user_api_scopes,omitempty"` + // Forward the user's access token to the app. Requires stopping and starting + // app compute to take effect. + ForwardUserAccessToken *bool `json:"forward_user_access_token,omitempty"` + // Git repository configuration for app deployments. When specified, deployments + // can reference code from this repository by providing only the git reference + // (branch, tag, or commit). + GitRepository *GitRepository `json:"git_repository,omitempty"` + GitSource *GitSource `json:"git_source,omitempty"` + // The unique identifier of the app. + Id *string `json:"id,omitempty"` + // The name of the app. The name must contain only lowercase alphanumeric + // characters and hyphens. It must be unique within the workspace. + Name *string `json:"name,omitempty"` + Oauth2AppClientId *string `json:"oauth2_app_client_id,omitempty"` + Oauth2AppIntegrationId *string `json:"oauth2_app_integration_id,omitempty"` + // The pending deployment of the app. A deployment is considered pending when it + // is being prepared for deployment to the app compute. + PendingDeployment *AppDeployment `json:"pending_deployment,omitempty"` + // Resources for the app. + Resources []AppResource `json:"resources,omitempty"` + ServicePrincipalClientId *string `json:"service_principal_client_id,omitempty"` + ServicePrincipalId *int64 `json:"service_principal_id,omitempty"` + ServicePrincipalName *string `json:"service_principal_name,omitempty"` + SourceCodePath *string `json:"source_code_path,omitempty"` + // Name of the space this app belongs to. + Space *string `json:"space,omitempty"` + TelemetryExportDestinations []TelemetryExportDestination `json:"telemetry_export_destinations,omitempty"` + // The URL of the thumbnail image for the app. + ThumbnailUrl *string `json:"thumbnail_url,omitempty"` + // The update time of the app. Formatted timestamp in ISO 6801. + UpdateTime *types.Time `json:"update_time,omitempty"` + // The email of the user that last updated the app. + Updater *string `json:"updater,omitempty"` + // The URL of the app once it is deployed. + Url *string `json:"url,omitempty"` + UsagePolicyId *string `json:"usage_policy_id,omitempty"` + UserApiScopes []string `json:"user_api_scopes,omitempty"` +} + +type AppDeployment struct { + // The command with which to run the app. This will override the command + // specified in the app.yaml file. + Command []string `json:"command,omitempty"` + // The creation time of the deployment. Formatted timestamp in ISO 6801. + CreateTime *types.Time `json:"create_time,omitempty"` + // The email of the user creates the deployment. + Creator *string `json:"creator,omitempty"` + // The deployment artifacts for an app. + DeploymentArtifacts *AppDeploymentArtifacts `json:"deployment_artifacts,omitempty"` + // The unique id of the deployment. + DeploymentId *string `json:"deployment_id,omitempty"` + // The environment variables to set in the app runtime environment. This will + // override the environment variables specified in the app.yaml file. + EnvVars []EnvVar `json:"env_vars,omitempty"` + // Git repository to use as the source for the app deployment. + GitSource *GitSource `json:"git_source,omitempty"` + // Deploy-time health check for the app. Verifies the app is responding to HTTP + // requests before considering the deployment successful. + HealthCheck *AppHealthCheck `json:"health_check,omitempty"` + // The mode of which the deployment will manage the source code. + Mode AppDeployment_Mode `json:"mode,omitempty"` + // The workspace file system path of the source code used to create the app + // deployment. This is different from `deployment_artifacts.source_code_path`, + // which is the path used by the deployed app. The former refers to the original + // source code location of the app in the workspace during deployment creation, + // whereas the latter provides a system generated stable snapshotted source code + // path used by the deployment. + SourceCodePath *string `json:"source_code_path,omitempty"` + // Status and status message of the deployment + Status *AppDeploymentStatus `json:"status,omitempty"` + // The update time of the deployment. Formatted timestamp in ISO 6801. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +type AppDeploymentArtifacts struct { + // The snapshotted workspace file system path of the source code loaded by the + // deployed app. + SourceCodePath *string `json:"source_code_path,omitempty"` +} + +type AppDeploymentStatus struct { + // Message corresponding with the deployment state. + Message *string `json:"message,omitempty"` + // State of the deployment. + State AppDeployment_State `json:"state,omitempty"` +} + +// Deploy-time HTTP health check configuration for an app deployment.. +type AppHealthCheck struct { + // HTTP path to probe, e.g. "/health" or "/api/status". + Path *string `json:"path,omitempty"` + // Timeout to wait for the health check to pass before failing the deployment. + // If not set, a default timeout is used. + Timeout *types.Duration `json:"timeout,omitempty"` +} + +// App manifest definition. +type AppManifest struct { + // Description of the app defined by manifest author / publisher + Description *string `json:"description,omitempty"` + // Name of the app defined by manifest author / publisher + Name *string `json:"name,omitempty"` + ResourceSpecs []AppManifest_AppResourceSpec `json:"resource_specs,omitempty"` + // The manifest schema version, for now only 1 is allowed + Version *int `json:"version,omitempty"` +} + +type AppManifest_AppResourceExperimentSpec struct { + Permission AppManifest_AppResourceExperimentSpec_ExperimentPermission `json:"permission,omitempty"` +} + +type AppManifest_AppResourceJobSpec struct { + // Permissions to grant on the Job. Supported permissions are: "CAN_MANAGE", + // "IS_OWNER", "CAN_MANAGE_RUN", "CAN_VIEW". + Permission AppManifest_AppResourceJobSpec_JobPermission `json:"permission,omitempty"` +} + +type AppManifest_AppResourceSecretSpec struct { + // Permission to grant on the secret scope. For secrets, only one permission is + // allowed. Permission must be one of: "READ", "WRITE", "MANAGE". + Permission AppManifest_AppResourceSecretSpec_SecretPermission `json:"permission,omitempty"` +} + +type AppManifest_AppResourceServingEndpointSpec struct { + // Permission to grant on the serving endpoint. Supported permissions are: + // "CAN_MANAGE", "CAN_QUERY", "CAN_VIEW". + Permission AppManifest_AppResourceServingEndpointSpec_ServingEndpointPermission `json:"permission,omitempty"` +} + +// AppResource related fields are copied from app.proto but excludes resource +// identifiers (e.g. name, id, key, scope, etc.). +type AppManifest_AppResourceSpec struct { + // Description of the App Resource. + Description *string `json:"description,omitempty"` + ExperimentSpec *AppManifest_AppResourceExperimentSpec `json:"experiment_spec,omitempty"` + JobSpec *AppManifest_AppResourceJobSpec `json:"job_spec,omitempty"` + // Name of the App Resource. + Name *string `json:"name,omitempty"` + SecretSpec *AppManifest_AppResourceSecretSpec `json:"secret_spec,omitempty"` + ServingEndpointSpec *AppManifest_AppResourceServingEndpointSpec `json:"serving_endpoint_spec,omitempty"` + SqlWarehouseSpec *AppManifest_AppResourceSqlWarehouseSpec `json:"sql_warehouse_spec,omitempty"` + UcSecurableSpec *AppManifest_AppResourceUcSecurableSpec `json:"uc_securable_spec,omitempty"` +} + +type AppManifest_AppResourceSqlWarehouseSpec struct { + // Permission to grant on the SQL warehouse. Supported permissions are: + // "CAN_MANAGE", "CAN_USE", "IS_OWNER". + Permission AppManifest_AppResourceSqlWarehouseSpec_SqlWarehousePermission `json:"permission,omitempty"` +} + +type AppManifest_AppResourceUcSecurableSpec struct { + Permission AppManifest_AppResourceUcSecurableSpec_UcSecurablePermission `json:"permission,omitempty"` + SecurableType AppManifest_AppResourceUcSecurableSpec_UcSecurableType `json:"securable_type,omitempty"` +} + +type AppResource struct { + App *AppResourceApp `json:"app,omitempty"` + Database *AppResourceDatabase `json:"database,omitempty"` + // Description of the App Resource. + Description *string `json:"description,omitempty"` + Experiment *AppResourceExperiment `json:"experiment,omitempty"` + GenieSpace *AppResourceGenieSpace `json:"genie_space,omitempty"` + Job *AppResourceJob `json:"job,omitempty"` + // Name of the App Resource. + Name *string `json:"name,omitempty"` + Postgres *AppResourcePostgres `json:"postgres,omitempty"` + Secret *AppResourceSecret `json:"secret,omitempty"` + ServingEndpoint *AppResourceServingEndpoint `json:"serving_endpoint,omitempty"` + SqlWarehouse *AppResourceSqlWarehouse `json:"sql_warehouse,omitempty"` + UcSecurable *AppResourceUcSecurable `json:"uc_securable,omitempty"` +} + +type AppResourceApp struct { + Name *string `json:"name,omitempty"` + Permission AppResourceApp_AppPermission `json:"permission,omitempty"` +} + +type AppResourceDatabase struct { + DatabaseName *string `json:"database_name,omitempty"` + InstanceName *string `json:"instance_name,omitempty"` + Permission AppResourceDatabase_DatabasePermission `json:"permission,omitempty"` +} + +type AppResourceExperiment struct { + ExperimentId *string `json:"experiment_id,omitempty"` + Permission AppResourceExperiment_ExperimentPermission `json:"permission,omitempty"` +} + +type AppResourceGenieSpace struct { + Name *string `json:"name,omitempty"` + Permission AppResourceGenieSpace_GenieSpacePermission `json:"permission,omitempty"` + SpaceId *string `json:"space_id,omitempty"` +} + +type AppResourceJob struct { + // Id of the job to grant permission on. + Id *string `json:"id,omitempty"` + // Permissions to grant on the Job. Supported permissions are: "CAN_MANAGE", + // "IS_OWNER", "CAN_MANAGE_RUN", "CAN_VIEW". + Permission AppResourceJob_JobPermission `json:"permission,omitempty"` +} + +type AppResourcePostgres struct { + Branch *string `json:"branch,omitempty"` + Database *string `json:"database,omitempty"` + Permission AppResourcePostgres_PostgresPermission `json:"permission,omitempty"` +} + +type AppResourceSecret struct { + // Key of the secret to grant permission on. + Key *string `json:"key,omitempty"` + // Permission to grant on the secret scope. For secrets, only one permission is + // allowed. Permission must be one of: "READ", "WRITE", "MANAGE". + Permission AppResourceSecret_SecretPermission `json:"permission,omitempty"` + // Scope of the secret to grant permission on. + Scope *string `json:"scope,omitempty"` +} + +type AppResourceServingEndpoint struct { + // Name of the serving endpoint to grant permission on. + Name *string `json:"name,omitempty"` + // Permission to grant on the serving endpoint. Supported permissions are: + // "CAN_MANAGE", "CAN_QUERY", "CAN_VIEW". + Permission AppResourceServingEndpoint_ServingEndpointPermission `json:"permission,omitempty"` +} + +type AppResourceSqlWarehouse struct { + // Id of the SQL warehouse to grant permission on. + Id *string `json:"id,omitempty"` + // Permission to grant on the SQL warehouse. Supported permissions are: + // "CAN_MANAGE", "CAN_USE", "IS_OWNER". + Permission AppResourceSqlWarehouse_SqlWarehousePermission `json:"permission,omitempty"` +} + +type AppResourceUcSecurable struct { + Permission AppResourceUcSecurable_UcSecurablePermission `json:"permission,omitempty"` + SecurableFullName *string `json:"securable_full_name,omitempty"` + // The securable kind from Unity Catalog. See + // https://docs.databricks.com/api/workspace/tables/get#securable_kind_manifest-securable_kind. + SecurableKind *string `json:"securable_kind,omitempty"` + SecurableType AppResourceUcSecurable_UcSecurableType `json:"securable_type,omitempty"` +} + +// The thumbnail for an app.. +type AppThumbnail struct { + // The thumbnail image bytes. + Thumbnail []byte `json:"thumbnail,omitempty"` +} + +type AppUpdate struct { + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // Maximum number of app instances the app is configured to run. Must be set + // together with `compute_min_instances`. + ComputeMaxInstances *int `json:"compute_max_instances,omitempty"` + // Minimum number of app instances the app is configured to run. Must be set + // together with `compute_max_instances`. + ComputeMinInstances *int `json:"compute_min_instances,omitempty"` + ComputeSize ComputeSize `json:"compute_size,omitempty"` + Description *string `json:"description,omitempty"` + // Forward the user's access token to the app. Requires stopping and starting + // app compute to take effect. + ForwardUserAccessToken *bool `json:"forward_user_access_token,omitempty"` + GitRepository *GitRepository `json:"git_repository,omitempty"` + Resources []AppResource `json:"resources,omitempty"` + Status *AppUpdate_UpdateStatus `json:"status,omitempty"` + TelemetryExportDestinations []TelemetryExportDestination `json:"telemetry_export_destinations,omitempty"` + UsagePolicyId *string `json:"usage_policy_id,omitempty"` + UserApiScopes []string `json:"user_api_scopes,omitempty"` +} + +type AppUpdate_UpdateStatus struct { + Message *string `json:"message,omitempty"` + State AppUpdate_UpdateStatus_UpdateState `json:"state,omitempty"` +} + +type ApplicationStatus struct { + // Application status message + Message *string `json:"message,omitempty"` + // The number of app instances whose application process is running. + RunningInstances *int `json:"running_instances,omitempty"` + // State of the application. + State ApplicationStatus_ApplicationState `json:"state,omitempty"` +} + +type AsyncUpdateAppRequest struct { + App *App `json:"app,omitempty"` + AppName *string `json:"app_name,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +type ComputeStatus struct { + // The number of active compute instances currently used and billed for this + // application. + ActiveInstances *int `json:"active_instances,omitempty"` + // Compute status message + Message *string `json:"message,omitempty"` + // State of the app compute. + State ComputeStatus_ComputeState `json:"state,omitempty"` +} + +type CreateAppDeploymentRequest struct { + // The app deployment configuration. + AppDeployment *AppDeployment `json:"app_deployment,omitempty"` + // The name of the app. + AppName *string `json:"app_name,omitempty"` +} + +type CreateAppRequest struct { + App *App `json:"app,omitempty"` + // If true, the app will not be started after creation. + NoCompute *bool `json:"no_compute,omitempty"` +} + +type CreateCustomTemplateRequest struct { + Template *CustomTemplate `json:"template,omitempty"` +} + +type CreateSpaceRequest struct { + Space *Space `json:"space,omitempty"` +} + +type CustomTemplate struct { + Creator *string `json:"creator,omitempty"` + // The description of the template. + Description *string `json:"description,omitempty"` + // The Git provider of the template. + GitProvider *string `json:"git_provider,omitempty"` + // The Git repository URL that the template resides in. + GitRepo *string `json:"git_repo,omitempty"` + // The manifest of the template. It defines fields and default values when + // installing the template. + Manifest *AppManifest `json:"manifest,omitempty"` + // The name of the template. It must contain only alphanumeric characters, + // hyphens, underscores, and whitespaces. It must be unique within the + // workspace. + Name *string `json:"name,omitempty"` + // The path to the template within the Git repository. + Path *string `json:"path,omitempty"` +} + +type EnvVar struct { + // The name of the environment variable. + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` + ValueFrom *string `json:"value_from,omitempty"` +} + +// Git repository configuration specifying the location of the repository.. +type GitRepository struct { + // When true, automatically deploys the app on push events to the branch + // configured in the app's deployment_source.git_source. + AutoDeploy *bool `json:"auto_deploy,omitempty"` + // ID of a personal access token Git credential owned by the caller, used to + // grant the app's service principal access to this repository. + CallerCredentialId *int64 `json:"caller_credential_id,omitempty"` + // Git provider. Case insensitive. Supported values: gitHub, gitHubEnterprise, + // bitbucketCloud, bitbucketServer, azureDevOpsServices, gitLab, + // gitLabEnterpriseEdition, awsCodeCommit. + Provider *string `json:"provider,omitempty"` + // URL of the Git repository. + Url *string `json:"url,omitempty"` +} + +// Complete git source specification including repository location and +// reference.. +type GitSource struct { + Branch *string `json:"branch,omitempty"` + Commit *string `json:"commit,omitempty"` + // Git repository configuration. Populated from the app's git_repository + // configuration. + GitRepository *GitRepository `json:"git_repository,omitempty"` + // The resolved commit SHA that was actually used for the deployment. This is + // populated by the system after resolving the reference (branch, tag, or + // commit). If commit is specified directly, this will match commit. If a branch + // or tag is specified, this contains the commit SHA that the branch or tag + // pointed to at deployment time. + ResolvedCommit *string `json:"resolved_commit,omitempty"` + // Relative path to the app source code within the Git repository. If not + // specified, the root of the repository is used. + SourceCodePath *string `json:"source_code_path,omitempty"` + Tag *string `json:"tag,omitempty"` +} + +type ListAppDeploymentsRequest struct { + // The name of the app. + AppName *string `json:"app_name,omitempty"` + // Upper bound for items returned. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page of apps. Requests first page if + // absent. + PageToken *string `json:"page_token,omitempty"` +} + +type ListAppDeploymentsResponse struct { + // Deployment history of the app. + AppDeployments []AppDeployment `json:"app_deployments,omitempty"` + // Pagination token to request the next page of apps. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to list all apps deployed in the workspace. +type ListAppsRequest struct { + // Upper bound for items returned. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page of apps. Requests first page if + // absent. + PageToken *string `json:"page_token,omitempty"` + // Filter apps by app space name. When specified, only apps belonging to this + // space are returned. + Space *string `json:"space,omitempty"` +} + +type ListAppsResponse struct { + Apps []App `json:"apps,omitempty"` + // Pagination token to request the next page of apps. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListCustomTemplatesRequest struct { + // Upper bound for items returned. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page of custom templates. Requests first + // page if absent. + PageToken *string `json:"page_token,omitempty"` +} + +type ListCustomTemplatesResponse struct { + // Pagination token to request the next page of custom templates. + NextPageToken *string `json:"next_page_token,omitempty"` + Templates []CustomTemplate `json:"templates,omitempty"` +} + +type ListSpacesRequest struct { + // Upper bound for items returned. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page of app spaces. Requests first page if + // absent. + PageToken *string `json:"page_token,omitempty"` +} + +type ListSpacesResponse struct { + // Pagination token to request the next page of app spaces. + NextPageToken *string `json:"next_page_token,omitempty"` + Spaces []Space `json:"spaces,omitempty"` +} + +// This resource represents a long-running operation that is the result of a +// network API call.. +type Operation struct { + // If the value is `false`, it means the operation is still in progress. If + // `true`, the operation is completed, and either `error` or `response` is + // available. + Done *bool `json:"done,omitempty"` + Error *ApiError `json:"error,omitempty"` + // Service-specific metadata associated with the operation. It typically + // contains progress information and common metadata such as create time. Some + // services might not provide such metadata. + Metadata json.RawMessage `json:"metadata,omitempty"` + // The server-assigned name, which is only unique within the same service that + // originally returns it. If you use the default HTTP mapping, the `name` should + // be a resource name ending with `operations/{unique_id}`. + Name *string `json:"name,omitempty"` + Response json.RawMessage `json:"response,omitempty"` +} + +type Space struct { + // The group whose permissions users assume via Role Authorization for apps in + // this space. When set, user tokens assume the role of this group instead of + // doing regular obo token downscoping. Set only at space creation. + AssumeGroupId *string `json:"assume_group_id,omitempty"` + // The creation time of the app space. Formatted timestamp in ISO 6801. + CreateTime *types.Time `json:"create_time,omitempty"` + // The email of the user that created the app space. + Creator *string `json:"creator,omitempty"` + // The description of the app space. + Description *string `json:"description,omitempty"` + // The effective usage policy ID used by apps in the space. + EffectiveUsagePolicyId *string `json:"effective_usage_policy_id,omitempty"` + // The effective api scopes granted to the user access token. + EffectiveUserApiScopes []string `json:"effective_user_api_scopes,omitempty"` + // The unique identifier of the app space. + Id *string `json:"id,omitempty"` + // The name of the app space. The name must contain only lowercase alphanumeric + // characters and hyphens. It must be unique within the workspace. + Name *string `json:"name,omitempty"` + // Resources for the app space. Resources configured at the space level are + // available to all apps in the space. + Resources []AppResource `json:"resources,omitempty"` + // The service principal client ID for the app space. + ServicePrincipalClientId *string `json:"service_principal_client_id,omitempty"` + // The service principal ID for the app space. + ServicePrincipalId *int64 `json:"service_principal_id,omitempty"` + // The service principal name for the app space. + ServicePrincipalName *string `json:"service_principal_name,omitempty"` + // The status of the app space. + Status *SpaceStatus `json:"status,omitempty"` + // The update time of the app space. Formatted timestamp in ISO 6801. + UpdateTime *types.Time `json:"update_time,omitempty"` + // The email of the user that last updated the app space. + Updater *string `json:"updater,omitempty"` + // The usage policy ID for managing cost at the space level. + UsagePolicyId *string `json:"usage_policy_id,omitempty"` + // OAuth scopes for apps in the space. + UserApiScopes []string `json:"user_api_scopes,omitempty"` +} + +type SpaceStatus struct { + // Message providing context about the current state. + Message *string `json:"message,omitempty"` + // The state of the app space. + State SpaceStatus_SpaceState `json:"state,omitempty"` +} + +// Tracks app space update information.. +type SpaceUpdate struct { + Description *string `json:"description,omitempty"` + Resources []AppResource `json:"resources,omitempty"` + Status *SpaceUpdateStatus `json:"status,omitempty"` + UsagePolicyId *string `json:"usage_policy_id,omitempty"` + UserApiScopes []string `json:"user_api_scopes,omitempty"` +} + +// Status of an app space update operation. +type SpaceUpdateStatus struct { + Message *string `json:"message,omitempty"` + State SpaceUpdateState `json:"state,omitempty"` +} + +type StartAppRequest struct { + // The name of the app. + Name *string `json:"name,omitempty"` +} + +type StopAppRequest struct { + // The name of the app. + Name *string `json:"name,omitempty"` +} + +// A single telemetry export destination with its configuration and status.. +type TelemetryExportDestination struct { + UnityCatalog *UnityCatalog `json:"unity_catalog,omitempty"` +} + +// Unity Catalog Destinations for OTEL telemetry export.. +type UnityCatalog struct { + // Unity Catalog table for OTEL logs. + LogsTable *string `json:"logs_table,omitempty"` + // Unity Catalog table for OTEL metrics. + MetricsTable *string `json:"metrics_table,omitempty"` + // Unity Catalog table for OTEL traces (spans). + TracesTable *string `json:"traces_table,omitempty"` +} + +type UpdateAppRequest struct { + App *App `json:"app,omitempty"` +} + +type UpdateAppThumbnailRequest struct { + // The app thumbnail to set. + AppThumbnail *AppThumbnail `json:"app_thumbnail,omitempty"` + // The name of the app. + Name *string `json:"name,omitempty"` +} + +type UpdateCustomTemplateRequest struct { + Template *CustomTemplate `json:"template,omitempty"` +} + +type UpdateSpaceRequest struct { + Space *Space `json:"space,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +// ApiErrorToSDK converts the mirror to the sdk-go type. +func ApiErrorToSDK(w *ApiError) (*sdk.ApiError, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApiError{} + out.ErrorCode = w.ErrorCode + out.Message = w.Message + out.StackTrace = w.StackTrace + out.Details = w.Details + return out, nil +} + +// ApiErrorFromSDK converts the sdk-go type to the mirror. +func ApiErrorFromSDK(v *sdk.ApiError) (*ApiError, error) { + if v == nil { + return nil, nil + } + out := &ApiError{} + out.ErrorCode = v.ErrorCode + out.Message = v.Message + out.StackTrace = v.StackTrace + out.Details = v.Details + return out, nil +} + +// AppToSDK converts the mirror to the sdk-go type. +func AppToSDK(w *App) (*sdk.App, error) { + if w == nil { + return nil, nil + } + out := &sdk.App{} + out.Name = w.Name + out.Description = w.Description + conv1, err := ComputeStatusToSDK(w.ComputeStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.ComputeStatus", err) + } + out.ComputeStatus = conv1 + conv2, err := ApplicationStatusToSDK(w.AppStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.AppStatus", err) + } + out.AppStatus = conv2 + out.Url = w.Url + conv3, err := AppDeploymentToSDK(w.ActiveDeployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.ActiveDeployment", err) + } + out.ActiveDeployment = conv3 + out.CreateTime = w.CreateTime + out.Creator = w.Creator + out.UpdateTime = w.UpdateTime + out.Updater = w.Updater + conv4, err := AppDeploymentToSDK(w.PendingDeployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.PendingDeployment", err) + } + out.PendingDeployment = conv4 + conv5, err := convertSlice(w.Resources, AppResourceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.Resources", err) + } + out.Resources = conv5 + out.ServicePrincipalId = w.ServicePrincipalId + out.ServicePrincipalName = w.ServicePrincipalName + out.DefaultSourceCodePath = w.DefaultSourceCodePath + conv6, err := GitSourceToSDK(w.DefaultGitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.DefaultGitSource", err) + } + out.DefaultGitSource = conv6 + out.BudgetPolicyId = w.BudgetPolicyId + out.EffectiveBudgetPolicyId = w.EffectiveBudgetPolicyId + out.ServicePrincipalClientId = w.ServicePrincipalClientId + out.UserApiScopes = w.UserApiScopes + out.Id = w.Id + out.EffectiveUserApiScopes = w.EffectiveUserApiScopes + out.Oauth2AppIntegrationId = w.Oauth2AppIntegrationId + out.Oauth2AppClientId = w.Oauth2AppClientId + out.ComputeSize = w.ComputeSize + out.UsagePolicyId = w.UsagePolicyId + out.EffectiveUsagePolicyId = w.EffectiveUsagePolicyId + out.ComputeMinInstances = w.ComputeMinInstances + out.ComputeMaxInstances = w.ComputeMaxInstances + conv7, err := GitRepositoryToSDK(w.GitRepository) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.GitRepository", err) + } + out.GitRepository = conv7 + conv8, err := convertSlice(w.TelemetryExportDestinations, TelemetryExportDestinationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.TelemetryExportDestinations", err) + } + out.TelemetryExportDestinations = conv8 + out.ThumbnailUrl = w.ThumbnailUrl + out.Space = w.Space + { + var members []string + if w.SourceCodePath != nil { + members = append(members, "source_code_path") + } + if w.GitSource != nil { + members = append(members, "git_source") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.SourceCodePath != nil: + out.DeploymentSource = &sdk.App_DeploymentSource_SourceCodePath{SourceCodePath: *w.SourceCodePath} + case w.GitSource != nil: + conv9, err := GitSourceToSDK(w.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.DeploymentSource", err) + } + out.DeploymentSource = &sdk.App_DeploymentSource_GitSource{GitSource: *conv9} + } + out.ForwardUserAccessToken = w.ForwardUserAccessToken + return out, nil +} + +// AppFromSDK converts the sdk-go type to the mirror. +func AppFromSDK(v *sdk.App) (*App, error) { + if v == nil { + return nil, nil + } + out := &App{} + out.Name = v.Name + out.Description = v.Description + conv10, err := ComputeStatusFromSDK(v.ComputeStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.ComputeStatus", err) + } + out.ComputeStatus = conv10 + conv11, err := ApplicationStatusFromSDK(v.AppStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.AppStatus", err) + } + out.AppStatus = conv11 + out.Url = v.Url + conv12, err := AppDeploymentFromSDK(v.ActiveDeployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.ActiveDeployment", err) + } + out.ActiveDeployment = conv12 + out.CreateTime = v.CreateTime + out.Creator = v.Creator + out.UpdateTime = v.UpdateTime + out.Updater = v.Updater + conv13, err := AppDeploymentFromSDK(v.PendingDeployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.PendingDeployment", err) + } + out.PendingDeployment = conv13 + conv14, err := convertSlice(v.Resources, AppResourceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.Resources", err) + } + out.Resources = conv14 + out.ServicePrincipalId = v.ServicePrincipalId + out.ServicePrincipalName = v.ServicePrincipalName + out.DefaultSourceCodePath = v.DefaultSourceCodePath + conv15, err := GitSourceFromSDK(v.DefaultGitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.DefaultGitSource", err) + } + out.DefaultGitSource = conv15 + out.BudgetPolicyId = v.BudgetPolicyId + out.EffectiveBudgetPolicyId = v.EffectiveBudgetPolicyId + out.ServicePrincipalClientId = v.ServicePrincipalClientId + out.UserApiScopes = v.UserApiScopes + out.Id = v.Id + out.EffectiveUserApiScopes = v.EffectiveUserApiScopes + out.Oauth2AppIntegrationId = v.Oauth2AppIntegrationId + out.Oauth2AppClientId = v.Oauth2AppClientId + out.ComputeSize = v.ComputeSize + out.UsagePolicyId = v.UsagePolicyId + out.EffectiveUsagePolicyId = v.EffectiveUsagePolicyId + out.ComputeMinInstances = v.ComputeMinInstances + out.ComputeMaxInstances = v.ComputeMaxInstances + conv16, err := GitRepositoryFromSDK(v.GitRepository) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.GitRepository", err) + } + out.GitRepository = conv16 + conv17, err := convertSlice(v.TelemetryExportDestinations, TelemetryExportDestinationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.TelemetryExportDestinations", err) + } + out.TelemetryExportDestinations = conv17 + out.ThumbnailUrl = v.ThumbnailUrl + out.Space = v.Space + switch value := v.DeploymentSource.(type) { + case *sdk.App_DeploymentSource_SourceCodePath: + if value != nil { + out.SourceCodePath = new(value.SourceCodePath) + } + case *sdk.App_DeploymentSource_GitSource: + if value != nil { + conv18, err := GitSourceFromSDK(&value.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "App.DeploymentSource", err) + } + out.GitSource = conv18 + } + } + out.ForwardUserAccessToken = v.ForwardUserAccessToken + return out, nil +} + +// AppDeploymentToSDK converts the mirror to the sdk-go type. +func AppDeploymentToSDK(w *AppDeployment) (*sdk.AppDeployment, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppDeployment{} + out.DeploymentId = w.DeploymentId + out.SourceCodePath = w.SourceCodePath + conv19, err := GitSourceToSDK(w.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppDeployment.GitSource", err) + } + out.GitSource = conv19 + out.Mode = w.Mode + conv20, err := AppDeploymentArtifactsToSDK(w.DeploymentArtifacts) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppDeployment.DeploymentArtifacts", err) + } + out.DeploymentArtifacts = conv20 + conv21, err := AppDeploymentStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppDeployment.Status", err) + } + out.Status = conv21 + out.CreateTime = w.CreateTime + out.Creator = w.Creator + out.UpdateTime = w.UpdateTime + out.Command = w.Command + conv22, err := convertSlice(w.EnvVars, EnvVarToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppDeployment.EnvVars", err) + } + out.EnvVars = conv22 + conv23, err := AppHealthCheckToSDK(w.HealthCheck) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppDeployment.HealthCheck", err) + } + out.HealthCheck = conv23 + return out, nil +} + +// AppDeploymentFromSDK converts the sdk-go type to the mirror. +func AppDeploymentFromSDK(v *sdk.AppDeployment) (*AppDeployment, error) { + if v == nil { + return nil, nil + } + out := &AppDeployment{} + out.DeploymentId = v.DeploymentId + out.SourceCodePath = v.SourceCodePath + conv24, err := GitSourceFromSDK(v.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppDeployment.GitSource", err) + } + out.GitSource = conv24 + out.Mode = v.Mode + conv25, err := AppDeploymentArtifactsFromSDK(v.DeploymentArtifacts) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppDeployment.DeploymentArtifacts", err) + } + out.DeploymentArtifacts = conv25 + conv26, err := AppDeploymentStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppDeployment.Status", err) + } + out.Status = conv26 + out.CreateTime = v.CreateTime + out.Creator = v.Creator + out.UpdateTime = v.UpdateTime + out.Command = v.Command + conv27, err := convertSlice(v.EnvVars, EnvVarFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppDeployment.EnvVars", err) + } + out.EnvVars = conv27 + conv28, err := AppHealthCheckFromSDK(v.HealthCheck) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppDeployment.HealthCheck", err) + } + out.HealthCheck = conv28 + return out, nil +} + +// AppDeploymentArtifactsToSDK converts the mirror to the sdk-go type. +func AppDeploymentArtifactsToSDK(w *AppDeploymentArtifacts) (*sdk.AppDeploymentArtifacts, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppDeploymentArtifacts{} + out.SourceCodePath = w.SourceCodePath + return out, nil +} + +// AppDeploymentArtifactsFromSDK converts the sdk-go type to the mirror. +func AppDeploymentArtifactsFromSDK(v *sdk.AppDeploymentArtifacts) (*AppDeploymentArtifacts, error) { + if v == nil { + return nil, nil + } + out := &AppDeploymentArtifacts{} + out.SourceCodePath = v.SourceCodePath + return out, nil +} + +// AppDeploymentStatusToSDK converts the mirror to the sdk-go type. +func AppDeploymentStatusToSDK(w *AppDeploymentStatus) (*sdk.AppDeploymentStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppDeploymentStatus{} + out.State = w.State + out.Message = w.Message + return out, nil +} + +// AppDeploymentStatusFromSDK converts the sdk-go type to the mirror. +func AppDeploymentStatusFromSDK(v *sdk.AppDeploymentStatus) (*AppDeploymentStatus, error) { + if v == nil { + return nil, nil + } + out := &AppDeploymentStatus{} + out.State = v.State + out.Message = v.Message + return out, nil +} + +// AppHealthCheckToSDK converts the mirror to the sdk-go type. +func AppHealthCheckToSDK(w *AppHealthCheck) (*sdk.AppHealthCheck, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppHealthCheck{} + out.Path = w.Path + out.Timeout = w.Timeout + return out, nil +} + +// AppHealthCheckFromSDK converts the sdk-go type to the mirror. +func AppHealthCheckFromSDK(v *sdk.AppHealthCheck) (*AppHealthCheck, error) { + if v == nil { + return nil, nil + } + out := &AppHealthCheck{} + out.Path = v.Path + out.Timeout = v.Timeout + return out, nil +} + +// AppManifestToSDK converts the mirror to the sdk-go type. +func AppManifestToSDK(w *AppManifest) (*sdk.AppManifest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppManifest{} + out.Version = w.Version + out.Name = w.Name + out.Description = w.Description + conv29, err := convertSlice(w.ResourceSpecs, AppManifest_AppResourceSpecToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest.ResourceSpecs", err) + } + out.ResourceSpecs = conv29 + return out, nil +} + +// AppManifestFromSDK converts the sdk-go type to the mirror. +func AppManifestFromSDK(v *sdk.AppManifest) (*AppManifest, error) { + if v == nil { + return nil, nil + } + out := &AppManifest{} + out.Version = v.Version + out.Name = v.Name + out.Description = v.Description + conv30, err := convertSlice(v.ResourceSpecs, AppManifest_AppResourceSpecFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest.ResourceSpecs", err) + } + out.ResourceSpecs = conv30 + return out, nil +} + +// AppManifest_AppResourceExperimentSpecToSDK converts the mirror to the sdk-go type. +func AppManifest_AppResourceExperimentSpecToSDK(w *AppManifest_AppResourceExperimentSpec) (*sdk.AppManifest_AppResourceExperimentSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppManifest_AppResourceExperimentSpec{} + out.Permission = w.Permission + return out, nil +} + +// AppManifest_AppResourceExperimentSpecFromSDK converts the sdk-go type to the mirror. +func AppManifest_AppResourceExperimentSpecFromSDK(v *sdk.AppManifest_AppResourceExperimentSpec) (*AppManifest_AppResourceExperimentSpec, error) { + if v == nil { + return nil, nil + } + out := &AppManifest_AppResourceExperimentSpec{} + out.Permission = v.Permission + return out, nil +} + +// AppManifest_AppResourceJobSpecToSDK converts the mirror to the sdk-go type. +func AppManifest_AppResourceJobSpecToSDK(w *AppManifest_AppResourceJobSpec) (*sdk.AppManifest_AppResourceJobSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppManifest_AppResourceJobSpec{} + out.Permission = w.Permission + return out, nil +} + +// AppManifest_AppResourceJobSpecFromSDK converts the sdk-go type to the mirror. +func AppManifest_AppResourceJobSpecFromSDK(v *sdk.AppManifest_AppResourceJobSpec) (*AppManifest_AppResourceJobSpec, error) { + if v == nil { + return nil, nil + } + out := &AppManifest_AppResourceJobSpec{} + out.Permission = v.Permission + return out, nil +} + +// AppManifest_AppResourceSecretSpecToSDK converts the mirror to the sdk-go type. +func AppManifest_AppResourceSecretSpecToSDK(w *AppManifest_AppResourceSecretSpec) (*sdk.AppManifest_AppResourceSecretSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppManifest_AppResourceSecretSpec{} + out.Permission = w.Permission + return out, nil +} + +// AppManifest_AppResourceSecretSpecFromSDK converts the sdk-go type to the mirror. +func AppManifest_AppResourceSecretSpecFromSDK(v *sdk.AppManifest_AppResourceSecretSpec) (*AppManifest_AppResourceSecretSpec, error) { + if v == nil { + return nil, nil + } + out := &AppManifest_AppResourceSecretSpec{} + out.Permission = v.Permission + return out, nil +} + +// AppManifest_AppResourceServingEndpointSpecToSDK converts the mirror to the sdk-go type. +func AppManifest_AppResourceServingEndpointSpecToSDK(w *AppManifest_AppResourceServingEndpointSpec) (*sdk.AppManifest_AppResourceServingEndpointSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppManifest_AppResourceServingEndpointSpec{} + out.Permission = w.Permission + return out, nil +} + +// AppManifest_AppResourceServingEndpointSpecFromSDK converts the sdk-go type to the mirror. +func AppManifest_AppResourceServingEndpointSpecFromSDK(v *sdk.AppManifest_AppResourceServingEndpointSpec) (*AppManifest_AppResourceServingEndpointSpec, error) { + if v == nil { + return nil, nil + } + out := &AppManifest_AppResourceServingEndpointSpec{} + out.Permission = v.Permission + return out, nil +} + +// AppManifest_AppResourceSpecToSDK converts the mirror to the sdk-go type. +func AppManifest_AppResourceSpecToSDK(w *AppManifest_AppResourceSpec) (*sdk.AppManifest_AppResourceSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppManifest_AppResourceSpec{} + out.Name = w.Name + out.Description = w.Description + { + var members []string + if w.SecretSpec != nil { + members = append(members, "secret_spec") + } + if w.SqlWarehouseSpec != nil { + members = append(members, "sql_warehouse_spec") + } + if w.ServingEndpointSpec != nil { + members = append(members, "serving_endpoint_spec") + } + if w.JobSpec != nil { + members = append(members, "job_spec") + } + if w.UcSecurableSpec != nil { + members = append(members, "uc_securable_spec") + } + if w.ExperimentSpec != nil { + members = append(members, "experiment_spec") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.SecretSpec != nil: + conv31, err := AppManifest_AppResourceSecretSpecToSDK(w.SecretSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest_AppResourceSpec.Resource", err) + } + out.Resource = &sdk.AppManifest_AppResourceSpec_Resource_SecretSpec{SecretSpec: *conv31} + case w.SqlWarehouseSpec != nil: + conv32, err := AppManifest_AppResourceSqlWarehouseSpecToSDK(w.SqlWarehouseSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest_AppResourceSpec.Resource", err) + } + out.Resource = &sdk.AppManifest_AppResourceSpec_Resource_SqlWarehouseSpec{SqlWarehouseSpec: *conv32} + case w.ServingEndpointSpec != nil: + conv33, err := AppManifest_AppResourceServingEndpointSpecToSDK(w.ServingEndpointSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest_AppResourceSpec.Resource", err) + } + out.Resource = &sdk.AppManifest_AppResourceSpec_Resource_ServingEndpointSpec{ServingEndpointSpec: *conv33} + case w.JobSpec != nil: + conv34, err := AppManifest_AppResourceJobSpecToSDK(w.JobSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest_AppResourceSpec.Resource", err) + } + out.Resource = &sdk.AppManifest_AppResourceSpec_Resource_JobSpec{JobSpec: *conv34} + case w.UcSecurableSpec != nil: + conv35, err := AppManifest_AppResourceUcSecurableSpecToSDK(w.UcSecurableSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest_AppResourceSpec.Resource", err) + } + out.Resource = &sdk.AppManifest_AppResourceSpec_Resource_UcSecurableSpec{UcSecurableSpec: *conv35} + case w.ExperimentSpec != nil: + conv36, err := AppManifest_AppResourceExperimentSpecToSDK(w.ExperimentSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest_AppResourceSpec.Resource", err) + } + out.Resource = &sdk.AppManifest_AppResourceSpec_Resource_ExperimentSpec{ExperimentSpec: *conv36} + } + return out, nil +} + +// AppManifest_AppResourceSpecFromSDK converts the sdk-go type to the mirror. +func AppManifest_AppResourceSpecFromSDK(v *sdk.AppManifest_AppResourceSpec) (*AppManifest_AppResourceSpec, error) { + if v == nil { + return nil, nil + } + out := &AppManifest_AppResourceSpec{} + out.Name = v.Name + out.Description = v.Description + switch value := v.Resource.(type) { + case *sdk.AppManifest_AppResourceSpec_Resource_SecretSpec: + if value != nil { + conv37, err := AppManifest_AppResourceSecretSpecFromSDK(&value.SecretSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest_AppResourceSpec.Resource", err) + } + out.SecretSpec = conv37 + } + case *sdk.AppManifest_AppResourceSpec_Resource_SqlWarehouseSpec: + if value != nil { + conv38, err := AppManifest_AppResourceSqlWarehouseSpecFromSDK(&value.SqlWarehouseSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest_AppResourceSpec.Resource", err) + } + out.SqlWarehouseSpec = conv38 + } + case *sdk.AppManifest_AppResourceSpec_Resource_ServingEndpointSpec: + if value != nil { + conv39, err := AppManifest_AppResourceServingEndpointSpecFromSDK(&value.ServingEndpointSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest_AppResourceSpec.Resource", err) + } + out.ServingEndpointSpec = conv39 + } + case *sdk.AppManifest_AppResourceSpec_Resource_JobSpec: + if value != nil { + conv40, err := AppManifest_AppResourceJobSpecFromSDK(&value.JobSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest_AppResourceSpec.Resource", err) + } + out.JobSpec = conv40 + } + case *sdk.AppManifest_AppResourceSpec_Resource_UcSecurableSpec: + if value != nil { + conv41, err := AppManifest_AppResourceUcSecurableSpecFromSDK(&value.UcSecurableSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest_AppResourceSpec.Resource", err) + } + out.UcSecurableSpec = conv41 + } + case *sdk.AppManifest_AppResourceSpec_Resource_ExperimentSpec: + if value != nil { + conv42, err := AppManifest_AppResourceExperimentSpecFromSDK(&value.ExperimentSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppManifest_AppResourceSpec.Resource", err) + } + out.ExperimentSpec = conv42 + } + } + return out, nil +} + +// AppManifest_AppResourceSqlWarehouseSpecToSDK converts the mirror to the sdk-go type. +func AppManifest_AppResourceSqlWarehouseSpecToSDK(w *AppManifest_AppResourceSqlWarehouseSpec) (*sdk.AppManifest_AppResourceSqlWarehouseSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppManifest_AppResourceSqlWarehouseSpec{} + out.Permission = w.Permission + return out, nil +} + +// AppManifest_AppResourceSqlWarehouseSpecFromSDK converts the sdk-go type to the mirror. +func AppManifest_AppResourceSqlWarehouseSpecFromSDK(v *sdk.AppManifest_AppResourceSqlWarehouseSpec) (*AppManifest_AppResourceSqlWarehouseSpec, error) { + if v == nil { + return nil, nil + } + out := &AppManifest_AppResourceSqlWarehouseSpec{} + out.Permission = v.Permission + return out, nil +} + +// AppManifest_AppResourceUcSecurableSpecToSDK converts the mirror to the sdk-go type. +func AppManifest_AppResourceUcSecurableSpecToSDK(w *AppManifest_AppResourceUcSecurableSpec) (*sdk.AppManifest_AppResourceUcSecurableSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppManifest_AppResourceUcSecurableSpec{} + out.SecurableType = w.SecurableType + out.Permission = w.Permission + return out, nil +} + +// AppManifest_AppResourceUcSecurableSpecFromSDK converts the sdk-go type to the mirror. +func AppManifest_AppResourceUcSecurableSpecFromSDK(v *sdk.AppManifest_AppResourceUcSecurableSpec) (*AppManifest_AppResourceUcSecurableSpec, error) { + if v == nil { + return nil, nil + } + out := &AppManifest_AppResourceUcSecurableSpec{} + out.SecurableType = v.SecurableType + out.Permission = v.Permission + return out, nil +} + +// AppResourceToSDK converts the mirror to the sdk-go type. +func AppResourceToSDK(w *AppResource) (*sdk.AppResource, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppResource{} + out.Name = w.Name + out.Description = w.Description + { + var members []string + if w.Secret != nil { + members = append(members, "secret") + } + if w.SqlWarehouse != nil { + members = append(members, "sql_warehouse") + } + if w.ServingEndpoint != nil { + members = append(members, "serving_endpoint") + } + if w.Job != nil { + members = append(members, "job") + } + if w.UcSecurable != nil { + members = append(members, "uc_securable") + } + if w.Database != nil { + members = append(members, "database") + } + if w.GenieSpace != nil { + members = append(members, "genie_space") + } + if w.Experiment != nil { + members = append(members, "experiment") + } + if w.App != nil { + members = append(members, "app") + } + if w.Postgres != nil { + members = append(members, "postgres") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Secret != nil: + conv43, err := AppResourceSecretToSDK(w.Secret) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Resource = &sdk.AppResource_Resource_Secret{Secret: *conv43} + case w.SqlWarehouse != nil: + conv44, err := AppResourceSqlWarehouseToSDK(w.SqlWarehouse) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Resource = &sdk.AppResource_Resource_SqlWarehouse{SqlWarehouse: *conv44} + case w.ServingEndpoint != nil: + conv45, err := AppResourceServingEndpointToSDK(w.ServingEndpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Resource = &sdk.AppResource_Resource_ServingEndpoint{ServingEndpoint: *conv45} + case w.Job != nil: + conv46, err := AppResourceJobToSDK(w.Job) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Resource = &sdk.AppResource_Resource_Job{Job: *conv46} + case w.UcSecurable != nil: + conv47, err := AppResourceUcSecurableToSDK(w.UcSecurable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Resource = &sdk.AppResource_Resource_UcSecurable{UcSecurable: *conv47} + case w.Database != nil: + conv48, err := AppResourceDatabaseToSDK(w.Database) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Resource = &sdk.AppResource_Resource_Database{Database: *conv48} + case w.GenieSpace != nil: + conv49, err := AppResourceGenieSpaceToSDK(w.GenieSpace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Resource = &sdk.AppResource_Resource_GenieSpace{GenieSpace: *conv49} + case w.Experiment != nil: + conv50, err := AppResourceExperimentToSDK(w.Experiment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Resource = &sdk.AppResource_Resource_Experiment{Experiment: *conv50} + case w.App != nil: + conv51, err := AppResourceAppToSDK(w.App) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Resource = &sdk.AppResource_Resource_App{App: *conv51} + case w.Postgres != nil: + conv52, err := AppResourcePostgresToSDK(w.Postgres) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Resource = &sdk.AppResource_Resource_Postgres{Postgres: *conv52} + } + return out, nil +} + +// AppResourceFromSDK converts the sdk-go type to the mirror. +func AppResourceFromSDK(v *sdk.AppResource) (*AppResource, error) { + if v == nil { + return nil, nil + } + out := &AppResource{} + out.Name = v.Name + out.Description = v.Description + switch value := v.Resource.(type) { + case *sdk.AppResource_Resource_Secret: + if value != nil { + conv53, err := AppResourceSecretFromSDK(&value.Secret) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Secret = conv53 + } + case *sdk.AppResource_Resource_SqlWarehouse: + if value != nil { + conv54, err := AppResourceSqlWarehouseFromSDK(&value.SqlWarehouse) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.SqlWarehouse = conv54 + } + case *sdk.AppResource_Resource_ServingEndpoint: + if value != nil { + conv55, err := AppResourceServingEndpointFromSDK(&value.ServingEndpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.ServingEndpoint = conv55 + } + case *sdk.AppResource_Resource_Job: + if value != nil { + conv56, err := AppResourceJobFromSDK(&value.Job) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Job = conv56 + } + case *sdk.AppResource_Resource_UcSecurable: + if value != nil { + conv57, err := AppResourceUcSecurableFromSDK(&value.UcSecurable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.UcSecurable = conv57 + } + case *sdk.AppResource_Resource_Database: + if value != nil { + conv58, err := AppResourceDatabaseFromSDK(&value.Database) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Database = conv58 + } + case *sdk.AppResource_Resource_GenieSpace: + if value != nil { + conv59, err := AppResourceGenieSpaceFromSDK(&value.GenieSpace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.GenieSpace = conv59 + } + case *sdk.AppResource_Resource_Experiment: + if value != nil { + conv60, err := AppResourceExperimentFromSDK(&value.Experiment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Experiment = conv60 + } + case *sdk.AppResource_Resource_App: + if value != nil { + conv61, err := AppResourceAppFromSDK(&value.App) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.App = conv61 + } + case *sdk.AppResource_Resource_Postgres: + if value != nil { + conv62, err := AppResourcePostgresFromSDK(&value.Postgres) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppResource.Resource", err) + } + out.Postgres = conv62 + } + } + return out, nil +} + +// AppResourceAppToSDK converts the mirror to the sdk-go type. +func AppResourceAppToSDK(w *AppResourceApp) (*sdk.AppResourceApp, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppResourceApp{} + out.Name = w.Name + out.Permission = w.Permission + return out, nil +} + +// AppResourceAppFromSDK converts the sdk-go type to the mirror. +func AppResourceAppFromSDK(v *sdk.AppResourceApp) (*AppResourceApp, error) { + if v == nil { + return nil, nil + } + out := &AppResourceApp{} + out.Name = v.Name + out.Permission = v.Permission + return out, nil +} + +// AppResourceDatabaseToSDK converts the mirror to the sdk-go type. +func AppResourceDatabaseToSDK(w *AppResourceDatabase) (*sdk.AppResourceDatabase, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppResourceDatabase{} + out.InstanceName = w.InstanceName + out.DatabaseName = w.DatabaseName + out.Permission = w.Permission + return out, nil +} + +// AppResourceDatabaseFromSDK converts the sdk-go type to the mirror. +func AppResourceDatabaseFromSDK(v *sdk.AppResourceDatabase) (*AppResourceDatabase, error) { + if v == nil { + return nil, nil + } + out := &AppResourceDatabase{} + out.InstanceName = v.InstanceName + out.DatabaseName = v.DatabaseName + out.Permission = v.Permission + return out, nil +} + +// AppResourceExperimentToSDK converts the mirror to the sdk-go type. +func AppResourceExperimentToSDK(w *AppResourceExperiment) (*sdk.AppResourceExperiment, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppResourceExperiment{} + out.ExperimentId = w.ExperimentId + out.Permission = w.Permission + return out, nil +} + +// AppResourceExperimentFromSDK converts the sdk-go type to the mirror. +func AppResourceExperimentFromSDK(v *sdk.AppResourceExperiment) (*AppResourceExperiment, error) { + if v == nil { + return nil, nil + } + out := &AppResourceExperiment{} + out.ExperimentId = v.ExperimentId + out.Permission = v.Permission + return out, nil +} + +// AppResourceGenieSpaceToSDK converts the mirror to the sdk-go type. +func AppResourceGenieSpaceToSDK(w *AppResourceGenieSpace) (*sdk.AppResourceGenieSpace, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppResourceGenieSpace{} + out.Name = w.Name + out.SpaceId = w.SpaceId + out.Permission = w.Permission + return out, nil +} + +// AppResourceGenieSpaceFromSDK converts the sdk-go type to the mirror. +func AppResourceGenieSpaceFromSDK(v *sdk.AppResourceGenieSpace) (*AppResourceGenieSpace, error) { + if v == nil { + return nil, nil + } + out := &AppResourceGenieSpace{} + out.Name = v.Name + out.SpaceId = v.SpaceId + out.Permission = v.Permission + return out, nil +} + +// AppResourceJobToSDK converts the mirror to the sdk-go type. +func AppResourceJobToSDK(w *AppResourceJob) (*sdk.AppResourceJob, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppResourceJob{} + out.Id = w.Id + out.Permission = w.Permission + return out, nil +} + +// AppResourceJobFromSDK converts the sdk-go type to the mirror. +func AppResourceJobFromSDK(v *sdk.AppResourceJob) (*AppResourceJob, error) { + if v == nil { + return nil, nil + } + out := &AppResourceJob{} + out.Id = v.Id + out.Permission = v.Permission + return out, nil +} + +// AppResourcePostgresToSDK converts the mirror to the sdk-go type. +func AppResourcePostgresToSDK(w *AppResourcePostgres) (*sdk.AppResourcePostgres, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppResourcePostgres{} + out.Branch = w.Branch + out.Database = w.Database + out.Permission = w.Permission + return out, nil +} + +// AppResourcePostgresFromSDK converts the sdk-go type to the mirror. +func AppResourcePostgresFromSDK(v *sdk.AppResourcePostgres) (*AppResourcePostgres, error) { + if v == nil { + return nil, nil + } + out := &AppResourcePostgres{} + out.Branch = v.Branch + out.Database = v.Database + out.Permission = v.Permission + return out, nil +} + +// AppResourceSecretToSDK converts the mirror to the sdk-go type. +func AppResourceSecretToSDK(w *AppResourceSecret) (*sdk.AppResourceSecret, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppResourceSecret{} + out.Scope = w.Scope + out.Key = w.Key + out.Permission = w.Permission + return out, nil +} + +// AppResourceSecretFromSDK converts the sdk-go type to the mirror. +func AppResourceSecretFromSDK(v *sdk.AppResourceSecret) (*AppResourceSecret, error) { + if v == nil { + return nil, nil + } + out := &AppResourceSecret{} + out.Scope = v.Scope + out.Key = v.Key + out.Permission = v.Permission + return out, nil +} + +// AppResourceServingEndpointToSDK converts the mirror to the sdk-go type. +func AppResourceServingEndpointToSDK(w *AppResourceServingEndpoint) (*sdk.AppResourceServingEndpoint, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppResourceServingEndpoint{} + out.Name = w.Name + out.Permission = w.Permission + return out, nil +} + +// AppResourceServingEndpointFromSDK converts the sdk-go type to the mirror. +func AppResourceServingEndpointFromSDK(v *sdk.AppResourceServingEndpoint) (*AppResourceServingEndpoint, error) { + if v == nil { + return nil, nil + } + out := &AppResourceServingEndpoint{} + out.Name = v.Name + out.Permission = v.Permission + return out, nil +} + +// AppResourceSqlWarehouseToSDK converts the mirror to the sdk-go type. +func AppResourceSqlWarehouseToSDK(w *AppResourceSqlWarehouse) (*sdk.AppResourceSqlWarehouse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppResourceSqlWarehouse{} + out.Id = w.Id + out.Permission = w.Permission + return out, nil +} + +// AppResourceSqlWarehouseFromSDK converts the sdk-go type to the mirror. +func AppResourceSqlWarehouseFromSDK(v *sdk.AppResourceSqlWarehouse) (*AppResourceSqlWarehouse, error) { + if v == nil { + return nil, nil + } + out := &AppResourceSqlWarehouse{} + out.Id = v.Id + out.Permission = v.Permission + return out, nil +} + +// AppResourceUcSecurableToSDK converts the mirror to the sdk-go type. +func AppResourceUcSecurableToSDK(w *AppResourceUcSecurable) (*sdk.AppResourceUcSecurable, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppResourceUcSecurable{} + out.SecurableFullName = w.SecurableFullName + out.SecurableType = w.SecurableType + out.Permission = w.Permission + out.SecurableKind = w.SecurableKind + return out, nil +} + +// AppResourceUcSecurableFromSDK converts the sdk-go type to the mirror. +func AppResourceUcSecurableFromSDK(v *sdk.AppResourceUcSecurable) (*AppResourceUcSecurable, error) { + if v == nil { + return nil, nil + } + out := &AppResourceUcSecurable{} + out.SecurableFullName = v.SecurableFullName + out.SecurableType = v.SecurableType + out.Permission = v.Permission + out.SecurableKind = v.SecurableKind + return out, nil +} + +// AppThumbnailToSDK converts the mirror to the sdk-go type. +func AppThumbnailToSDK(w *AppThumbnail) (*sdk.AppThumbnail, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppThumbnail{} + out.Thumbnail = w.Thumbnail + return out, nil +} + +// AppThumbnailFromSDK converts the sdk-go type to the mirror. +func AppThumbnailFromSDK(v *sdk.AppThumbnail) (*AppThumbnail, error) { + if v == nil { + return nil, nil + } + out := &AppThumbnail{} + out.Thumbnail = v.Thumbnail + return out, nil +} + +// AppUpdateToSDK converts the mirror to the sdk-go type. +func AppUpdateToSDK(w *AppUpdate) (*sdk.AppUpdate, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppUpdate{} + conv63, err := AppUpdate_UpdateStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppUpdate.Status", err) + } + out.Status = conv63 + out.Description = w.Description + out.BudgetPolicyId = w.BudgetPolicyId + conv64, err := convertSlice(w.Resources, AppResourceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppUpdate.Resources", err) + } + out.Resources = conv64 + out.UserApiScopes = w.UserApiScopes + out.ComputeSize = w.ComputeSize + out.UsagePolicyId = w.UsagePolicyId + out.ComputeMinInstances = w.ComputeMinInstances + out.ComputeMaxInstances = w.ComputeMaxInstances + conv65, err := GitRepositoryToSDK(w.GitRepository) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppUpdate.GitRepository", err) + } + out.GitRepository = conv65 + conv66, err := convertSlice(w.TelemetryExportDestinations, TelemetryExportDestinationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppUpdate.TelemetryExportDestinations", err) + } + out.TelemetryExportDestinations = conv66 + out.ForwardUserAccessToken = w.ForwardUserAccessToken + return out, nil +} + +// AppUpdateFromSDK converts the sdk-go type to the mirror. +func AppUpdateFromSDK(v *sdk.AppUpdate) (*AppUpdate, error) { + if v == nil { + return nil, nil + } + out := &AppUpdate{} + conv67, err := AppUpdate_UpdateStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppUpdate.Status", err) + } + out.Status = conv67 + out.Description = v.Description + out.BudgetPolicyId = v.BudgetPolicyId + conv68, err := convertSlice(v.Resources, AppResourceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppUpdate.Resources", err) + } + out.Resources = conv68 + out.UserApiScopes = v.UserApiScopes + out.ComputeSize = v.ComputeSize + out.UsagePolicyId = v.UsagePolicyId + out.ComputeMinInstances = v.ComputeMinInstances + out.ComputeMaxInstances = v.ComputeMaxInstances + conv69, err := GitRepositoryFromSDK(v.GitRepository) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppUpdate.GitRepository", err) + } + out.GitRepository = conv69 + conv70, err := convertSlice(v.TelemetryExportDestinations, TelemetryExportDestinationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AppUpdate.TelemetryExportDestinations", err) + } + out.TelemetryExportDestinations = conv70 + out.ForwardUserAccessToken = v.ForwardUserAccessToken + return out, nil +} + +// AppUpdate_UpdateStatusToSDK converts the mirror to the sdk-go type. +func AppUpdate_UpdateStatusToSDK(w *AppUpdate_UpdateStatus) (*sdk.AppUpdate_UpdateStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.AppUpdate_UpdateStatus{} + out.State = w.State + out.Message = w.Message + return out, nil +} + +// AppUpdate_UpdateStatusFromSDK converts the sdk-go type to the mirror. +func AppUpdate_UpdateStatusFromSDK(v *sdk.AppUpdate_UpdateStatus) (*AppUpdate_UpdateStatus, error) { + if v == nil { + return nil, nil + } + out := &AppUpdate_UpdateStatus{} + out.State = v.State + out.Message = v.Message + return out, nil +} + +// ApplicationStatusToSDK converts the mirror to the sdk-go type. +func ApplicationStatusToSDK(w *ApplicationStatus) (*sdk.ApplicationStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApplicationStatus{} + out.State = w.State + out.Message = w.Message + out.RunningInstances = w.RunningInstances + return out, nil +} + +// ApplicationStatusFromSDK converts the sdk-go type to the mirror. +func ApplicationStatusFromSDK(v *sdk.ApplicationStatus) (*ApplicationStatus, error) { + if v == nil { + return nil, nil + } + out := &ApplicationStatus{} + out.State = v.State + out.Message = v.Message + out.RunningInstances = v.RunningInstances + return out, nil +} + +// AsyncUpdateAppRequestToSDK converts the mirror to the sdk-go type. +func AsyncUpdateAppRequestToSDK(w *AsyncUpdateAppRequest) (*sdk.AsyncUpdateAppRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AsyncUpdateAppRequest{} + conv71, err := AppToSDK(w.App) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AsyncUpdateAppRequest.App", err) + } + out.App = conv71 + mask72, err := fieldMaskFromString[sdk.App](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AsyncUpdateAppRequest.UpdateMask", err) + } + out.UpdateMask = mask72 + out.AppName = w.AppName + return out, nil +} + +// AsyncUpdateAppRequestFromSDK converts the sdk-go type to the mirror. +func AsyncUpdateAppRequestFromSDK(v *sdk.AsyncUpdateAppRequest) (*AsyncUpdateAppRequest, error) { + if v == nil { + return nil, nil + } + out := &AsyncUpdateAppRequest{} + conv73, err := AppFromSDK(v.App) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AsyncUpdateAppRequest.App", err) + } + out.App = conv73 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + out.AppName = v.AppName + return out, nil +} + +// ComputeStatusToSDK converts the mirror to the sdk-go type. +func ComputeStatusToSDK(w *ComputeStatus) (*sdk.ComputeStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.ComputeStatus{} + out.State = w.State + out.Message = w.Message + out.ActiveInstances = w.ActiveInstances + return out, nil +} + +// ComputeStatusFromSDK converts the sdk-go type to the mirror. +func ComputeStatusFromSDK(v *sdk.ComputeStatus) (*ComputeStatus, error) { + if v == nil { + return nil, nil + } + out := &ComputeStatus{} + out.State = v.State + out.Message = v.Message + out.ActiveInstances = v.ActiveInstances + return out, nil +} + +// CreateAppDeploymentRequestToSDK converts the mirror to the sdk-go type. +func CreateAppDeploymentRequestToSDK(w *CreateAppDeploymentRequest) (*sdk.CreateAppDeploymentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAppDeploymentRequest{} + out.AppName = w.AppName + conv74, err := AppDeploymentToSDK(w.AppDeployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAppDeploymentRequest.AppDeployment", err) + } + out.AppDeployment = conv74 + return out, nil +} + +// CreateAppDeploymentRequestFromSDK converts the sdk-go type to the mirror. +func CreateAppDeploymentRequestFromSDK(v *sdk.CreateAppDeploymentRequest) (*CreateAppDeploymentRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateAppDeploymentRequest{} + out.AppName = v.AppName + conv75, err := AppDeploymentFromSDK(v.AppDeployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAppDeploymentRequest.AppDeployment", err) + } + out.AppDeployment = conv75 + return out, nil +} + +// CreateAppRequestToSDK converts the mirror to the sdk-go type. +func CreateAppRequestToSDK(w *CreateAppRequest) (*sdk.CreateAppRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAppRequest{} + conv76, err := AppToSDK(w.App) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAppRequest.App", err) + } + out.App = conv76 + out.NoCompute = w.NoCompute + return out, nil +} + +// CreateAppRequestFromSDK converts the sdk-go type to the mirror. +func CreateAppRequestFromSDK(v *sdk.CreateAppRequest) (*CreateAppRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateAppRequest{} + conv77, err := AppFromSDK(v.App) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAppRequest.App", err) + } + out.App = conv77 + out.NoCompute = v.NoCompute + return out, nil +} + +// CreateCustomTemplateRequestToSDK converts the mirror to the sdk-go type. +func CreateCustomTemplateRequestToSDK(w *CreateCustomTemplateRequest) (*sdk.CreateCustomTemplateRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCustomTemplateRequest{} + conv78, err := CustomTemplateToSDK(w.Template) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCustomTemplateRequest.Template", err) + } + out.Template = conv78 + return out, nil +} + +// CreateCustomTemplateRequestFromSDK converts the sdk-go type to the mirror. +func CreateCustomTemplateRequestFromSDK(v *sdk.CreateCustomTemplateRequest) (*CreateCustomTemplateRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCustomTemplateRequest{} + conv79, err := CustomTemplateFromSDK(v.Template) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCustomTemplateRequest.Template", err) + } + out.Template = conv79 + return out, nil +} + +// CreateSpaceRequestToSDK converts the mirror to the sdk-go type. +func CreateSpaceRequestToSDK(w *CreateSpaceRequest) (*sdk.CreateSpaceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateSpaceRequest{} + conv80, err := SpaceToSDK(w.Space) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSpaceRequest.Space", err) + } + out.Space = conv80 + return out, nil +} + +// CreateSpaceRequestFromSDK converts the sdk-go type to the mirror. +func CreateSpaceRequestFromSDK(v *sdk.CreateSpaceRequest) (*CreateSpaceRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateSpaceRequest{} + conv81, err := SpaceFromSDK(v.Space) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSpaceRequest.Space", err) + } + out.Space = conv81 + return out, nil +} + +// CustomTemplateToSDK converts the mirror to the sdk-go type. +func CustomTemplateToSDK(w *CustomTemplate) (*sdk.CustomTemplate, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomTemplate{} + out.Name = w.Name + out.Description = w.Description + out.GitRepo = w.GitRepo + out.Path = w.Path + conv82, err := AppManifestToSDK(w.Manifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomTemplate.Manifest", err) + } + out.Manifest = conv82 + out.GitProvider = w.GitProvider + out.Creator = w.Creator + return out, nil +} + +// CustomTemplateFromSDK converts the sdk-go type to the mirror. +func CustomTemplateFromSDK(v *sdk.CustomTemplate) (*CustomTemplate, error) { + if v == nil { + return nil, nil + } + out := &CustomTemplate{} + out.Name = v.Name + out.Description = v.Description + out.GitRepo = v.GitRepo + out.Path = v.Path + conv83, err := AppManifestFromSDK(v.Manifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomTemplate.Manifest", err) + } + out.Manifest = conv83 + out.GitProvider = v.GitProvider + out.Creator = v.Creator + return out, nil +} + +// EnvVarToSDK converts the mirror to the sdk-go type. +func EnvVarToSDK(w *EnvVar) (*sdk.EnvVar, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnvVar{} + out.Name = w.Name + { + var members []string + if w.Value != nil { + members = append(members, "value") + } + if w.ValueFrom != nil { + members = append(members, "value_from") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Value != nil: + out.Source = &sdk.EnvVar_Source_Value{Value: *w.Value} + case w.ValueFrom != nil: + out.Source = &sdk.EnvVar_Source_ValueFrom{ValueFrom: *w.ValueFrom} + } + return out, nil +} + +// EnvVarFromSDK converts the sdk-go type to the mirror. +func EnvVarFromSDK(v *sdk.EnvVar) (*EnvVar, error) { + if v == nil { + return nil, nil + } + out := &EnvVar{} + out.Name = v.Name + switch value := v.Source.(type) { + case *sdk.EnvVar_Source_Value: + if value != nil { + out.Value = new(value.Value) + } + case *sdk.EnvVar_Source_ValueFrom: + if value != nil { + out.ValueFrom = new(value.ValueFrom) + } + } + return out, nil +} + +// GitRepositoryToSDK converts the mirror to the sdk-go type. +func GitRepositoryToSDK(w *GitRepository) (*sdk.GitRepository, error) { + if w == nil { + return nil, nil + } + out := &sdk.GitRepository{} + out.Url = w.Url + out.Provider = w.Provider + out.AutoDeploy = w.AutoDeploy + out.CallerCredentialId = w.CallerCredentialId + return out, nil +} + +// GitRepositoryFromSDK converts the sdk-go type to the mirror. +func GitRepositoryFromSDK(v *sdk.GitRepository) (*GitRepository, error) { + if v == nil { + return nil, nil + } + out := &GitRepository{} + out.Url = v.Url + out.Provider = v.Provider + out.AutoDeploy = v.AutoDeploy + out.CallerCredentialId = v.CallerCredentialId + return out, nil +} + +// GitSourceToSDK converts the mirror to the sdk-go type. +func GitSourceToSDK(w *GitSource) (*sdk.GitSource, error) { + if w == nil { + return nil, nil + } + out := &sdk.GitSource{} + conv84, err := GitRepositoryToSDK(w.GitRepository) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GitSource.GitRepository", err) + } + out.GitRepository = conv84 + { + var members []string + if w.Branch != nil { + members = append(members, "branch") + } + if w.Tag != nil { + members = append(members, "tag") + } + if w.Commit != nil { + members = append(members, "commit") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Branch != nil: + out.Reference = &sdk.GitSource_Reference_Branch{Branch: *w.Branch} + case w.Tag != nil: + out.Reference = &sdk.GitSource_Reference_Tag{Tag: *w.Tag} + case w.Commit != nil: + out.Reference = &sdk.GitSource_Reference_Commit{Commit: *w.Commit} + } + out.SourceCodePath = w.SourceCodePath + out.ResolvedCommit = w.ResolvedCommit + return out, nil +} + +// GitSourceFromSDK converts the sdk-go type to the mirror. +func GitSourceFromSDK(v *sdk.GitSource) (*GitSource, error) { + if v == nil { + return nil, nil + } + out := &GitSource{} + conv85, err := GitRepositoryFromSDK(v.GitRepository) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GitSource.GitRepository", err) + } + out.GitRepository = conv85 + switch value := v.Reference.(type) { + case *sdk.GitSource_Reference_Branch: + if value != nil { + out.Branch = new(value.Branch) + } + case *sdk.GitSource_Reference_Tag: + if value != nil { + out.Tag = new(value.Tag) + } + case *sdk.GitSource_Reference_Commit: + if value != nil { + out.Commit = new(value.Commit) + } + } + out.SourceCodePath = v.SourceCodePath + out.ResolvedCommit = v.ResolvedCommit + return out, nil +} + +// ListAppDeploymentsRequestToSDK converts the mirror to the sdk-go type. +func ListAppDeploymentsRequestToSDK(w *ListAppDeploymentsRequest) (*sdk.ListAppDeploymentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAppDeploymentsRequest{} + out.AppName = w.AppName + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListAppDeploymentsRequestFromSDK converts the sdk-go type to the mirror. +func ListAppDeploymentsRequestFromSDK(v *sdk.ListAppDeploymentsRequest) (*ListAppDeploymentsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListAppDeploymentsRequest{} + out.AppName = v.AppName + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListAppDeploymentsResponseToSDK converts the mirror to the sdk-go type. +func ListAppDeploymentsResponseToSDK(w *ListAppDeploymentsResponse) (*sdk.ListAppDeploymentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAppDeploymentsResponse{} + conv86, err := convertSlice(w.AppDeployments, AppDeploymentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAppDeploymentsResponse.AppDeployments", err) + } + out.AppDeployments = conv86 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListAppDeploymentsResponseFromSDK converts the sdk-go type to the mirror. +func ListAppDeploymentsResponseFromSDK(v *sdk.ListAppDeploymentsResponse) (*ListAppDeploymentsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAppDeploymentsResponse{} + conv87, err := convertSlice(v.AppDeployments, AppDeploymentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAppDeploymentsResponse.AppDeployments", err) + } + out.AppDeployments = conv87 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListAppsRequestToSDK converts the mirror to the sdk-go type. +func ListAppsRequestToSDK(w *ListAppsRequest) (*sdk.ListAppsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAppsRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + out.Space = w.Space + return out, nil +} + +// ListAppsRequestFromSDK converts the sdk-go type to the mirror. +func ListAppsRequestFromSDK(v *sdk.ListAppsRequest) (*ListAppsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListAppsRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + out.Space = v.Space + return out, nil +} + +// ListAppsResponseToSDK converts the mirror to the sdk-go type. +func ListAppsResponseToSDK(w *ListAppsResponse) (*sdk.ListAppsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAppsResponse{} + conv88, err := convertSlice(w.Apps, AppToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAppsResponse.Apps", err) + } + out.Apps = conv88 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListAppsResponseFromSDK converts the sdk-go type to the mirror. +func ListAppsResponseFromSDK(v *sdk.ListAppsResponse) (*ListAppsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAppsResponse{} + conv89, err := convertSlice(v.Apps, AppFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAppsResponse.Apps", err) + } + out.Apps = conv89 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListCustomTemplatesRequestToSDK converts the mirror to the sdk-go type. +func ListCustomTemplatesRequestToSDK(w *ListCustomTemplatesRequest) (*sdk.ListCustomTemplatesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCustomTemplatesRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListCustomTemplatesRequestFromSDK converts the sdk-go type to the mirror. +func ListCustomTemplatesRequestFromSDK(v *sdk.ListCustomTemplatesRequest) (*ListCustomTemplatesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCustomTemplatesRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListCustomTemplatesResponseToSDK converts the mirror to the sdk-go type. +func ListCustomTemplatesResponseToSDK(w *ListCustomTemplatesResponse) (*sdk.ListCustomTemplatesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCustomTemplatesResponse{} + conv90, err := convertSlice(w.Templates, CustomTemplateToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCustomTemplatesResponse.Templates", err) + } + out.Templates = conv90 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCustomTemplatesResponseFromSDK converts the sdk-go type to the mirror. +func ListCustomTemplatesResponseFromSDK(v *sdk.ListCustomTemplatesResponse) (*ListCustomTemplatesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCustomTemplatesResponse{} + conv91, err := convertSlice(v.Templates, CustomTemplateFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCustomTemplatesResponse.Templates", err) + } + out.Templates = conv91 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListSpacesRequestToSDK converts the mirror to the sdk-go type. +func ListSpacesRequestToSDK(w *ListSpacesRequest) (*sdk.ListSpacesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSpacesRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListSpacesRequestFromSDK converts the sdk-go type to the mirror. +func ListSpacesRequestFromSDK(v *sdk.ListSpacesRequest) (*ListSpacesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSpacesRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListSpacesResponseToSDK converts the mirror to the sdk-go type. +func ListSpacesResponseToSDK(w *ListSpacesResponse) (*sdk.ListSpacesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSpacesResponse{} + conv92, err := convertSlice(w.Spaces, SpaceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSpacesResponse.Spaces", err) + } + out.Spaces = conv92 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSpacesResponseFromSDK converts the sdk-go type to the mirror. +func ListSpacesResponseFromSDK(v *sdk.ListSpacesResponse) (*ListSpacesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSpacesResponse{} + conv93, err := convertSlice(v.Spaces, SpaceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSpacesResponse.Spaces", err) + } + out.Spaces = conv93 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// OperationToSDK converts the mirror to the sdk-go type. +func OperationToSDK(w *Operation) (*sdk.Operation, error) { + if w == nil { + return nil, nil + } + out := &sdk.Operation{} + out.Name = w.Name + out.Metadata = w.Metadata + out.Done = w.Done + { + var members []string + if w.Error != nil { + members = append(members, "error") + } + if w.Response != nil { + members = append(members, "response") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Error != nil: + conv94, err := ApiErrorToSDK(w.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Operation.Result", err) + } + out.Result = &sdk.Operation_Result_Error{Error: *conv94} + case w.Response != nil: + out.Result = &sdk.Operation_Result_Response{Response: w.Response} + } + return out, nil +} + +// OperationFromSDK converts the sdk-go type to the mirror. +func OperationFromSDK(v *sdk.Operation) (*Operation, error) { + if v == nil { + return nil, nil + } + out := &Operation{} + out.Name = v.Name + out.Metadata = v.Metadata + out.Done = v.Done + switch value := v.Result.(type) { + case *sdk.Operation_Result_Error: + if value != nil { + conv95, err := ApiErrorFromSDK(&value.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Operation.Result", err) + } + out.Error = conv95 + } + case *sdk.Operation_Result_Response: + if value != nil { + out.Response = value.Response + } + } + return out, nil +} + +// SpaceToSDK converts the mirror to the sdk-go type. +func SpaceToSDK(w *Space) (*sdk.Space, error) { + if w == nil { + return nil, nil + } + out := &sdk.Space{} + out.Name = w.Name + out.Description = w.Description + conv96, err := SpaceStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Space.Status", err) + } + out.Status = conv96 + out.Id = w.Id + out.CreateTime = w.CreateTime + out.Creator = w.Creator + out.UpdateTime = w.UpdateTime + out.Updater = w.Updater + conv97, err := convertSlice(w.Resources, AppResourceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Space.Resources", err) + } + out.Resources = conv97 + out.UserApiScopes = w.UserApiScopes + out.EffectiveUserApiScopes = w.EffectiveUserApiScopes + out.ServicePrincipalId = w.ServicePrincipalId + out.ServicePrincipalName = w.ServicePrincipalName + out.ServicePrincipalClientId = w.ServicePrincipalClientId + out.UsagePolicyId = w.UsagePolicyId + out.EffectiveUsagePolicyId = w.EffectiveUsagePolicyId + out.AssumeGroupId = w.AssumeGroupId + return out, nil +} + +// SpaceFromSDK converts the sdk-go type to the mirror. +func SpaceFromSDK(v *sdk.Space) (*Space, error) { + if v == nil { + return nil, nil + } + out := &Space{} + out.Name = v.Name + out.Description = v.Description + conv98, err := SpaceStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Space.Status", err) + } + out.Status = conv98 + out.Id = v.Id + out.CreateTime = v.CreateTime + out.Creator = v.Creator + out.UpdateTime = v.UpdateTime + out.Updater = v.Updater + conv99, err := convertSlice(v.Resources, AppResourceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Space.Resources", err) + } + out.Resources = conv99 + out.UserApiScopes = v.UserApiScopes + out.EffectiveUserApiScopes = v.EffectiveUserApiScopes + out.ServicePrincipalId = v.ServicePrincipalId + out.ServicePrincipalName = v.ServicePrincipalName + out.ServicePrincipalClientId = v.ServicePrincipalClientId + out.UsagePolicyId = v.UsagePolicyId + out.EffectiveUsagePolicyId = v.EffectiveUsagePolicyId + out.AssumeGroupId = v.AssumeGroupId + return out, nil +} + +// SpaceStatusToSDK converts the mirror to the sdk-go type. +func SpaceStatusToSDK(w *SpaceStatus) (*sdk.SpaceStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.SpaceStatus{} + out.State = w.State + out.Message = w.Message + return out, nil +} + +// SpaceStatusFromSDK converts the sdk-go type to the mirror. +func SpaceStatusFromSDK(v *sdk.SpaceStatus) (*SpaceStatus, error) { + if v == nil { + return nil, nil + } + out := &SpaceStatus{} + out.State = v.State + out.Message = v.Message + return out, nil +} + +// SpaceUpdateToSDK converts the mirror to the sdk-go type. +func SpaceUpdateToSDK(w *SpaceUpdate) (*sdk.SpaceUpdate, error) { + if w == nil { + return nil, nil + } + out := &sdk.SpaceUpdate{} + conv100, err := SpaceUpdateStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SpaceUpdate.Status", err) + } + out.Status = conv100 + out.Description = w.Description + conv101, err := convertSlice(w.Resources, AppResourceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SpaceUpdate.Resources", err) + } + out.Resources = conv101 + out.UserApiScopes = w.UserApiScopes + out.UsagePolicyId = w.UsagePolicyId + return out, nil +} + +// SpaceUpdateFromSDK converts the sdk-go type to the mirror. +func SpaceUpdateFromSDK(v *sdk.SpaceUpdate) (*SpaceUpdate, error) { + if v == nil { + return nil, nil + } + out := &SpaceUpdate{} + conv102, err := SpaceUpdateStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SpaceUpdate.Status", err) + } + out.Status = conv102 + out.Description = v.Description + conv103, err := convertSlice(v.Resources, AppResourceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SpaceUpdate.Resources", err) + } + out.Resources = conv103 + out.UserApiScopes = v.UserApiScopes + out.UsagePolicyId = v.UsagePolicyId + return out, nil +} + +// SpaceUpdateStatusToSDK converts the mirror to the sdk-go type. +func SpaceUpdateStatusToSDK(w *SpaceUpdateStatus) (*sdk.SpaceUpdateStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.SpaceUpdateStatus{} + out.State = w.State + out.Message = w.Message + return out, nil +} + +// SpaceUpdateStatusFromSDK converts the sdk-go type to the mirror. +func SpaceUpdateStatusFromSDK(v *sdk.SpaceUpdateStatus) (*SpaceUpdateStatus, error) { + if v == nil { + return nil, nil + } + out := &SpaceUpdateStatus{} + out.State = v.State + out.Message = v.Message + return out, nil +} + +// StartAppRequestToSDK converts the mirror to the sdk-go type. +func StartAppRequestToSDK(w *StartAppRequest) (*sdk.StartAppRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.StartAppRequest{} + out.Name = w.Name + return out, nil +} + +// StartAppRequestFromSDK converts the sdk-go type to the mirror. +func StartAppRequestFromSDK(v *sdk.StartAppRequest) (*StartAppRequest, error) { + if v == nil { + return nil, nil + } + out := &StartAppRequest{} + out.Name = v.Name + return out, nil +} + +// StopAppRequestToSDK converts the mirror to the sdk-go type. +func StopAppRequestToSDK(w *StopAppRequest) (*sdk.StopAppRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.StopAppRequest{} + out.Name = w.Name + return out, nil +} + +// StopAppRequestFromSDK converts the sdk-go type to the mirror. +func StopAppRequestFromSDK(v *sdk.StopAppRequest) (*StopAppRequest, error) { + if v == nil { + return nil, nil + } + out := &StopAppRequest{} + out.Name = v.Name + return out, nil +} + +// TelemetryExportDestinationToSDK converts the mirror to the sdk-go type. +func TelemetryExportDestinationToSDK(w *TelemetryExportDestination) (*sdk.TelemetryExportDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.TelemetryExportDestination{} + { + var members []string + if w.UnityCatalog != nil { + members = append(members, "unity_catalog") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UnityCatalog != nil: + conv104, err := UnityCatalogToSDK(w.UnityCatalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TelemetryExportDestination.Destination", err) + } + out.Destination = &sdk.TelemetryExportDestination_Destination_UnityCatalog{UnityCatalog: *conv104} + } + return out, nil +} + +// TelemetryExportDestinationFromSDK converts the sdk-go type to the mirror. +func TelemetryExportDestinationFromSDK(v *sdk.TelemetryExportDestination) (*TelemetryExportDestination, error) { + if v == nil { + return nil, nil + } + out := &TelemetryExportDestination{} + switch value := v.Destination.(type) { + case *sdk.TelemetryExportDestination_Destination_UnityCatalog: + if value != nil { + conv105, err := UnityCatalogFromSDK(&value.UnityCatalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TelemetryExportDestination.Destination", err) + } + out.UnityCatalog = conv105 + } + } + return out, nil +} + +// UnityCatalogToSDK converts the mirror to the sdk-go type. +func UnityCatalogToSDK(w *UnityCatalog) (*sdk.UnityCatalog, error) { + if w == nil { + return nil, nil + } + out := &sdk.UnityCatalog{} + out.LogsTable = w.LogsTable + out.MetricsTable = w.MetricsTable + out.TracesTable = w.TracesTable + return out, nil +} + +// UnityCatalogFromSDK converts the sdk-go type to the mirror. +func UnityCatalogFromSDK(v *sdk.UnityCatalog) (*UnityCatalog, error) { + if v == nil { + return nil, nil + } + out := &UnityCatalog{} + out.LogsTable = v.LogsTable + out.MetricsTable = v.MetricsTable + out.TracesTable = v.TracesTable + return out, nil +} + +// UpdateAppRequestToSDK converts the mirror to the sdk-go type. +func UpdateAppRequestToSDK(w *UpdateAppRequest) (*sdk.UpdateAppRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAppRequest{} + conv106, err := AppToSDK(w.App) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAppRequest.App", err) + } + out.App = conv106 + return out, nil +} + +// UpdateAppRequestFromSDK converts the sdk-go type to the mirror. +func UpdateAppRequestFromSDK(v *sdk.UpdateAppRequest) (*UpdateAppRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateAppRequest{} + conv107, err := AppFromSDK(v.App) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAppRequest.App", err) + } + out.App = conv107 + return out, nil +} + +// UpdateAppThumbnailRequestToSDK converts the mirror to the sdk-go type. +func UpdateAppThumbnailRequestToSDK(w *UpdateAppThumbnailRequest) (*sdk.UpdateAppThumbnailRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAppThumbnailRequest{} + out.Name = w.Name + conv108, err := AppThumbnailToSDK(w.AppThumbnail) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAppThumbnailRequest.AppThumbnail", err) + } + out.AppThumbnail = conv108 + return out, nil +} + +// UpdateAppThumbnailRequestFromSDK converts the sdk-go type to the mirror. +func UpdateAppThumbnailRequestFromSDK(v *sdk.UpdateAppThumbnailRequest) (*UpdateAppThumbnailRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateAppThumbnailRequest{} + out.Name = v.Name + conv109, err := AppThumbnailFromSDK(v.AppThumbnail) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAppThumbnailRequest.AppThumbnail", err) + } + out.AppThumbnail = conv109 + return out, nil +} + +// UpdateCustomTemplateRequestToSDK converts the mirror to the sdk-go type. +func UpdateCustomTemplateRequestToSDK(w *UpdateCustomTemplateRequest) (*sdk.UpdateCustomTemplateRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCustomTemplateRequest{} + conv110, err := CustomTemplateToSDK(w.Template) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCustomTemplateRequest.Template", err) + } + out.Template = conv110 + return out, nil +} + +// UpdateCustomTemplateRequestFromSDK converts the sdk-go type to the mirror. +func UpdateCustomTemplateRequestFromSDK(v *sdk.UpdateCustomTemplateRequest) (*UpdateCustomTemplateRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateCustomTemplateRequest{} + conv111, err := CustomTemplateFromSDK(v.Template) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCustomTemplateRequest.Template", err) + } + out.Template = conv111 + return out, nil +} + +// UpdateSpaceRequestToSDK converts the mirror to the sdk-go type. +func UpdateSpaceRequestToSDK(w *UpdateSpaceRequest) (*sdk.UpdateSpaceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateSpaceRequest{} + conv112, err := SpaceToSDK(w.Space) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSpaceRequest.Space", err) + } + out.Space = conv112 + mask113, err := fieldMaskFromString[sdk.Space](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSpaceRequest.UpdateMask", err) + } + out.UpdateMask = mask113 + return out, nil +} + +// UpdateSpaceRequestFromSDK converts the sdk-go type to the mirror. +func UpdateSpaceRequestFromSDK(v *sdk.UpdateSpaceRequest) (*UpdateSpaceRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateSpaceRequest{} + conv114, err := SpaceFromSDK(v.Space) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSpaceRequest.Space", err) + } + out.Space = conv114 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/authentication/v1/types.generated.go b/libs/sdktypes/authentication/v1/types.generated.go new file mode 100644 index 00000000000..42e85249794 --- /dev/null +++ b/libs/sdktypes/authentication/v1/types.generated.go @@ -0,0 +1,832 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/authentication/v1. DO NOT EDIT. + +package authentication + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/authentication/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type CreateAccountFederationPolicyRequest struct { + // The account id for the federation policy. + AccountId *string `json:"account_id,omitempty"` + Policy *FederationPolicy `json:"policy,omitempty"` + // The identifier for the federation policy. The identifier must contain only + // lowercase alphanumeric characters, numbers, hyphens, and slashes. If + // unspecified, the id will be assigned by . + PolicyId *string `json:"policy_id,omitempty"` + // The service principal id for the federation policy. + ServicePrincipalId *int64 `json:"service_principal_id,omitempty"` +} + +type CreateServicePrincipalFederationPolicyRequest struct { + // The account id for the federation policy. + AccountId *string `json:"account_id,omitempty"` + Policy *FederationPolicy `json:"policy,omitempty"` + // The identifier for the federation policy. The identifier must contain only + // lowercase alphanumeric characters, numbers, hyphens, and slashes. If + // unspecified, the id will be assigned by . + PolicyId *string `json:"policy_id,omitempty"` + // The service principal id for the federation policy. + ServicePrincipalId *int64 `json:"service_principal_id,omitempty"` +} + +type CreateServicePrincipalSecretRequest struct { + // The account ID. + AccountId *string `json:"account_id,omitempty"` + // The lifetime of the secret in seconds. If this parameter is not provided, the + // secret will have a default lifetime of 730 days (63072000s). + Lifetime *types.Duration `json:"lifetime,omitempty"` + // OAuth API scopes to bind to the secret; a minted token cannot exceed them. + // Empty = unrestricted (all-apis). E.g. all-apis, sql, iam.groups:read. + Scopes []string `json:"scopes,omitempty"` + // The service principal ID. + ServicePrincipal *string `json:"service_principal,omitempty"` +} + +type CreateServicePrincipalSecretResponse struct { + // UTC time when the secret was created + CreateTime *string `json:"create_time,omitempty"` + // UTC time when the secret will expire. If the field is not present, the secret + // does not expire. + ExpireTime *types.Time `json:"expire_time,omitempty"` + // ID of the secret + Id *string `json:"id,omitempty"` + // OAuth API scopes bound to this secret. Empty = unrestricted (all-apis). + Scopes []string `json:"scopes,omitempty"` + // Secret Value + Secret *string `json:"secret,omitempty"` + // Secret Hash + SecretHash *string `json:"secret_hash,omitempty"` + // Status of the secret + Status *string `json:"status,omitempty"` + // UTC time when the secret was updated + UpdateTime *string `json:"update_time,omitempty"` +} + +type DeleteAccountFederationPolicyRequest struct { + // The account id for the federation policy. + AccountId *string `json:"account_id,omitempty"` + // The identifier for the federation policy. + PolicyId *string `json:"policy_id,omitempty"` + // The service principal id for the federation policy. + ServicePrincipalId *int64 `json:"service_principal_id,omitempty"` +} + +type DeleteServicePrincipalSecretRequest struct { + // The account ID. + AccountId *string `json:"account_id,omitempty"` + // The secret ID. + SecretId *string `json:"secret_id,omitempty"` + // The service principal ID. + ServicePrincipal *string `json:"service_principal,omitempty"` +} + +type FederationPolicy struct { + // Creation time of the federation policy. + CreateTime *types.Time `json:"create_time,omitempty"` + // Description of the federation policy. + Description *string `json:"description,omitempty"` + // Resource name for the federation policy. Example values include + // `accounts//federationPolicies/my-federation-policy` for Account + // Federation Policies, and + // `accounts//servicePrincipals//federationPolicies/my-federation-policy` + // for Service Principal Federation Policies. Typically an output parameter, + // which does not need to be specified in create or update requests. If + // specified in a request, must match the value in the request URL. + Name *string `json:"name,omitempty"` + OidcPolicy *OidcFederationPolicy `json:"oidc_policy,omitempty"` + // The ID of the federation policy. Output only. + PolicyId *string `json:"policy_id,omitempty"` + // The service principal ID that this federation policy applies to. Output only. + // Only set for service principal federation policies. + ServicePrincipalId *int64 `json:"service_principal_id,omitempty"` + // Unique, immutable id of the federation policy. + Uid *string `json:"uid,omitempty"` + // Last update time of the federation policy. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +type GetAccountFederationPolicyRequest struct { + // The account id for the federation policy. + AccountId *string `json:"account_id,omitempty"` + // The identifier for the federation policy. + PolicyId *string `json:"policy_id,omitempty"` + // The service principal id for the federation policy. + ServicePrincipalId *int64 `json:"service_principal_id,omitempty"` +} + +type ListAccountFederationPoliciesRequest struct { + // The account id for the federation policy. + AccountId *string `json:"account_id,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` + // The service principal id for the federation policy. + ServicePrincipalId *int64 `json:"service_principal_id,omitempty"` +} + +type ListFederationPoliciesResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + Policies []FederationPolicy `json:"policies,omitempty"` +} + +type ListServicePrincipalFederationPoliciesRequest struct { + // The account id for the federation policy. + AccountId *string `json:"account_id,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` + // The service principal id for the federation policy. + ServicePrincipalId *int64 `json:"service_principal_id,omitempty"` +} + +type ListServicePrincipalSecretsRequest struct { + // The account ID. + AccountId *string `json:"account_id,omitempty"` + PageSize *int `json:"page_size,omitempty"` + // An opaque page token which was the `next_page_token` in the response of the + // previous request to list the secrets for this service principal. Provide this + // token to retrieve the next page of secret entries. When providing a + // `page_token`, all other parameters provided to the request must match the + // previous request. To list all of the secrets for a service principal, it is + // necessary to continue requesting pages of entries until the response contains + // no `next_page_token`. Note that the number of entries returned must not be + // used to determine when the listing is complete. + PageToken *string `json:"page_token,omitempty"` + // The service principal ID. + ServicePrincipal *string `json:"service_principal,omitempty"` +} + +type ListServicePrincipalSecretsResponse struct { + // A token, which can be sent as `page_token` to retrieve the next page. + NextPageToken *string `json:"next_page_token,omitempty"` + // List of the secrets + Secrets []ServicePrincipalSecret `json:"secrets,omitempty"` +} + +// Specifies the policy to use for validating OIDC claims in your federated +// tokens.. +type OidcFederationPolicy struct { + // The allowed token audiences, as specified in the 'aud' claim of federated + // tokens. The audience identifier is intended to represent the recipient of the + // token. Can be any non-empty string value. As long as the audience in the + // token matches at least one audience in the policy, the token is considered a + // match. If audiences is unspecified, defaults to your account id. + Audiences []string `json:"audiences,omitempty"` + // The required token issuer, as specified in the 'iss' claim of federated + // tokens. + Issuer *string `json:"issuer,omitempty"` + // The public keys used to validate the signature of federated tokens, in JWKS + // format. Most use cases should not need to specify this field. If jwks_uri and + // jwks_json are both unspecified (recommended), automatically + // fetches the public keys from your issuer’s well known endpoint. Databricks + // strongly recommends relying on your issuer’s well known endpoint for + // discovering public keys. + JwksJson *string `json:"jwks_json,omitempty"` + // URL of the public keys used to validate the signature of federated tokens, in + // JWKS format. Most use cases should not need to specify this field. If + // jwks_uri and jwks_json are both unspecified (recommended), + // automatically fetches the public keys from your issuer’s well known + // endpoint. Databricks strongly recommends relying on your issuer’s well + // known endpoint for discovering public keys. + JwksUri *string `json:"jwks_uri,omitempty"` + // The required token subject, as specified in the subject claim of federated + // tokens. Must be specified for service principal federation policies. Must not + // be specified for account federation policies. + Subject *string `json:"subject,omitempty"` + // The claim that contains the subject of the token. If unspecified, the default + // value is 'sub'. + SubjectClaim *string `json:"subject_claim,omitempty"` +} + +type ServicePrincipalSecret struct { + // UTC time when the secret was created + CreateTime *string `json:"create_time,omitempty"` + // UTC time when the secret will expire. If the field is not present, the secret + // does not expire. + ExpireTime *types.Time `json:"expire_time,omitempty"` + // ID of the secret + Id *string `json:"id,omitempty"` + // OAuth API scopes bound to this secret. Empty = unrestricted (all-apis). + Scopes []string `json:"scopes,omitempty"` + // Secret Value + Secret *string `json:"secret,omitempty"` + // Secret Hash + SecretHash *string `json:"secret_hash,omitempty"` + // Status of the secret + Status *string `json:"status,omitempty"` + // UTC time when the secret was updated + UpdateTime *string `json:"update_time,omitempty"` +} + +type UpdateAccountFederationPolicyRequest struct { + // The account id for the federation policy. + AccountId *string `json:"account_id,omitempty"` + Policy *FederationPolicy `json:"policy,omitempty"` + // The identifier for the federation policy. + PolicyId *string `json:"policy_id,omitempty"` + // The service principal id for the federation policy. + ServicePrincipalId *int64 `json:"service_principal_id,omitempty"` + // The field mask specifies which fields of the policy to update. To specify + // multiple fields in the field mask, use comma as the separator (no space). The + // special value '*' indicates that all fields should be updated (full + // replacement). If unspecified, all fields that are set in the policy provided + // in the update request will overwrite the corresponding fields in the existing + // policy. Example value: 'description,oidc_policy.audiences'. + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateServicePrincipalFederationPolicyRequest struct { + // The account id for the federation policy. + AccountId *string `json:"account_id,omitempty"` + Policy *FederationPolicy `json:"policy,omitempty"` + // The identifier for the federation policy. + PolicyId *string `json:"policy_id,omitempty"` + // The service principal id for the federation policy. + ServicePrincipalId *int64 `json:"service_principal_id,omitempty"` + // The field mask specifies which fields of the policy to update. To specify + // multiple fields in the field mask, use comma as the separator (no space). The + // special value '*' indicates that all fields should be updated (full + // replacement). If unspecified, all fields that are set in the policy provided + // in the update request will overwrite the corresponding fields in the existing + // policy. Example value: 'description,oidc_policy.audiences'. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CreateAccountFederationPolicyRequestToSDK converts the mirror to the sdk-go type. +func CreateAccountFederationPolicyRequestToSDK(w *CreateAccountFederationPolicyRequest) (*sdk.CreateAccountFederationPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAccountFederationPolicyRequest{} + out.AccountId = w.AccountId + out.ServicePrincipalId = w.ServicePrincipalId + out.PolicyId = w.PolicyId + conv1, err := FederationPolicyToSDK(w.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountFederationPolicyRequest.Policy", err) + } + out.Policy = conv1 + return out, nil +} + +// CreateAccountFederationPolicyRequestFromSDK converts the sdk-go type to the mirror. +func CreateAccountFederationPolicyRequestFromSDK(v *sdk.CreateAccountFederationPolicyRequest) (*CreateAccountFederationPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateAccountFederationPolicyRequest{} + out.AccountId = v.AccountId + out.ServicePrincipalId = v.ServicePrincipalId + out.PolicyId = v.PolicyId + conv2, err := FederationPolicyFromSDK(v.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountFederationPolicyRequest.Policy", err) + } + out.Policy = conv2 + return out, nil +} + +// CreateServicePrincipalFederationPolicyRequestToSDK converts the mirror to the sdk-go type. +func CreateServicePrincipalFederationPolicyRequestToSDK(w *CreateServicePrincipalFederationPolicyRequest) (*sdk.CreateServicePrincipalFederationPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateServicePrincipalFederationPolicyRequest{} + out.AccountId = w.AccountId + out.ServicePrincipalId = w.ServicePrincipalId + out.PolicyId = w.PolicyId + conv3, err := FederationPolicyToSDK(w.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateServicePrincipalFederationPolicyRequest.Policy", err) + } + out.Policy = conv3 + return out, nil +} + +// CreateServicePrincipalFederationPolicyRequestFromSDK converts the sdk-go type to the mirror. +func CreateServicePrincipalFederationPolicyRequestFromSDK(v *sdk.CreateServicePrincipalFederationPolicyRequest) (*CreateServicePrincipalFederationPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateServicePrincipalFederationPolicyRequest{} + out.AccountId = v.AccountId + out.ServicePrincipalId = v.ServicePrincipalId + out.PolicyId = v.PolicyId + conv4, err := FederationPolicyFromSDK(v.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateServicePrincipalFederationPolicyRequest.Policy", err) + } + out.Policy = conv4 + return out, nil +} + +// CreateServicePrincipalSecretRequestToSDK converts the mirror to the sdk-go type. +func CreateServicePrincipalSecretRequestToSDK(w *CreateServicePrincipalSecretRequest) (*sdk.CreateServicePrincipalSecretRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateServicePrincipalSecretRequest{} + out.AccountId = w.AccountId + out.ServicePrincipal = w.ServicePrincipal + out.Lifetime = w.Lifetime + out.Scopes = w.Scopes + return out, nil +} + +// CreateServicePrincipalSecretRequestFromSDK converts the sdk-go type to the mirror. +func CreateServicePrincipalSecretRequestFromSDK(v *sdk.CreateServicePrincipalSecretRequest) (*CreateServicePrincipalSecretRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateServicePrincipalSecretRequest{} + out.AccountId = v.AccountId + out.ServicePrincipal = v.ServicePrincipal + out.Lifetime = v.Lifetime + out.Scopes = v.Scopes + return out, nil +} + +// CreateServicePrincipalSecretResponseToSDK converts the mirror to the sdk-go type. +func CreateServicePrincipalSecretResponseToSDK(w *CreateServicePrincipalSecretResponse) (*sdk.CreateServicePrincipalSecretResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateServicePrincipalSecretResponse{} + out.Id = w.Id + out.Secret = w.Secret + out.SecretHash = w.SecretHash + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.Status = w.Status + out.ExpireTime = w.ExpireTime + out.Scopes = w.Scopes + return out, nil +} + +// CreateServicePrincipalSecretResponseFromSDK converts the sdk-go type to the mirror. +func CreateServicePrincipalSecretResponseFromSDK(v *sdk.CreateServicePrincipalSecretResponse) (*CreateServicePrincipalSecretResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateServicePrincipalSecretResponse{} + out.Id = v.Id + out.Secret = v.Secret + out.SecretHash = v.SecretHash + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.Status = v.Status + out.ExpireTime = v.ExpireTime + out.Scopes = v.Scopes + return out, nil +} + +// DeleteAccountFederationPolicyRequestToSDK converts the mirror to the sdk-go type. +func DeleteAccountFederationPolicyRequestToSDK(w *DeleteAccountFederationPolicyRequest) (*sdk.DeleteAccountFederationPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteAccountFederationPolicyRequest{} + out.AccountId = w.AccountId + out.ServicePrincipalId = w.ServicePrincipalId + out.PolicyId = w.PolicyId + return out, nil +} + +// DeleteAccountFederationPolicyRequestFromSDK converts the sdk-go type to the mirror. +func DeleteAccountFederationPolicyRequestFromSDK(v *sdk.DeleteAccountFederationPolicyRequest) (*DeleteAccountFederationPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteAccountFederationPolicyRequest{} + out.AccountId = v.AccountId + out.ServicePrincipalId = v.ServicePrincipalId + out.PolicyId = v.PolicyId + return out, nil +} + +// DeleteServicePrincipalSecretRequestToSDK converts the mirror to the sdk-go type. +func DeleteServicePrincipalSecretRequestToSDK(w *DeleteServicePrincipalSecretRequest) (*sdk.DeleteServicePrincipalSecretRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteServicePrincipalSecretRequest{} + out.AccountId = w.AccountId + out.ServicePrincipal = w.ServicePrincipal + out.SecretId = w.SecretId + return out, nil +} + +// DeleteServicePrincipalSecretRequestFromSDK converts the sdk-go type to the mirror. +func DeleteServicePrincipalSecretRequestFromSDK(v *sdk.DeleteServicePrincipalSecretRequest) (*DeleteServicePrincipalSecretRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteServicePrincipalSecretRequest{} + out.AccountId = v.AccountId + out.ServicePrincipal = v.ServicePrincipal + out.SecretId = v.SecretId + return out, nil +} + +// FederationPolicyToSDK converts the mirror to the sdk-go type. +func FederationPolicyToSDK(w *FederationPolicy) (*sdk.FederationPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.FederationPolicy{} + out.Name = w.Name + out.Description = w.Description + { + var members []string + if w.OidcPolicy != nil { + members = append(members, "oidc_policy") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.OidcPolicy != nil: + conv5, err := OidcFederationPolicyToSDK(w.OidcPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FederationPolicy.Policy", err) + } + out.Policy = &sdk.FederationPolicy_Policy_OidcPolicy{OidcPolicy: *conv5} + } + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.Uid = w.Uid + out.ServicePrincipalId = w.ServicePrincipalId + out.PolicyId = w.PolicyId + return out, nil +} + +// FederationPolicyFromSDK converts the sdk-go type to the mirror. +func FederationPolicyFromSDK(v *sdk.FederationPolicy) (*FederationPolicy, error) { + if v == nil { + return nil, nil + } + out := &FederationPolicy{} + out.Name = v.Name + out.Description = v.Description + switch value := v.Policy.(type) { + case *sdk.FederationPolicy_Policy_OidcPolicy: + if value != nil { + conv6, err := OidcFederationPolicyFromSDK(&value.OidcPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FederationPolicy.Policy", err) + } + out.OidcPolicy = conv6 + } + } + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.Uid = v.Uid + out.ServicePrincipalId = v.ServicePrincipalId + out.PolicyId = v.PolicyId + return out, nil +} + +// GetAccountFederationPolicyRequestToSDK converts the mirror to the sdk-go type. +func GetAccountFederationPolicyRequestToSDK(w *GetAccountFederationPolicyRequest) (*sdk.GetAccountFederationPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetAccountFederationPolicyRequest{} + out.AccountId = w.AccountId + out.ServicePrincipalId = w.ServicePrincipalId + out.PolicyId = w.PolicyId + return out, nil +} + +// GetAccountFederationPolicyRequestFromSDK converts the sdk-go type to the mirror. +func GetAccountFederationPolicyRequestFromSDK(v *sdk.GetAccountFederationPolicyRequest) (*GetAccountFederationPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &GetAccountFederationPolicyRequest{} + out.AccountId = v.AccountId + out.ServicePrincipalId = v.ServicePrincipalId + out.PolicyId = v.PolicyId + return out, nil +} + +// ListAccountFederationPoliciesRequestToSDK converts the mirror to the sdk-go type. +func ListAccountFederationPoliciesRequestToSDK(w *ListAccountFederationPoliciesRequest) (*sdk.ListAccountFederationPoliciesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAccountFederationPoliciesRequest{} + out.AccountId = w.AccountId + out.ServicePrincipalId = w.ServicePrincipalId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListAccountFederationPoliciesRequestFromSDK converts the sdk-go type to the mirror. +func ListAccountFederationPoliciesRequestFromSDK(v *sdk.ListAccountFederationPoliciesRequest) (*ListAccountFederationPoliciesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListAccountFederationPoliciesRequest{} + out.AccountId = v.AccountId + out.ServicePrincipalId = v.ServicePrincipalId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListFederationPoliciesResponseToSDK converts the mirror to the sdk-go type. +func ListFederationPoliciesResponseToSDK(w *ListFederationPoliciesResponse) (*sdk.ListFederationPoliciesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListFederationPoliciesResponse{} + conv7, err := convertSlice(w.Policies, FederationPolicyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFederationPoliciesResponse.Policies", err) + } + out.Policies = conv7 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListFederationPoliciesResponseFromSDK converts the sdk-go type to the mirror. +func ListFederationPoliciesResponseFromSDK(v *sdk.ListFederationPoliciesResponse) (*ListFederationPoliciesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListFederationPoliciesResponse{} + conv8, err := convertSlice(v.Policies, FederationPolicyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFederationPoliciesResponse.Policies", err) + } + out.Policies = conv8 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListServicePrincipalFederationPoliciesRequestToSDK converts the mirror to the sdk-go type. +func ListServicePrincipalFederationPoliciesRequestToSDK(w *ListServicePrincipalFederationPoliciesRequest) (*sdk.ListServicePrincipalFederationPoliciesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListServicePrincipalFederationPoliciesRequest{} + out.AccountId = w.AccountId + out.ServicePrincipalId = w.ServicePrincipalId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListServicePrincipalFederationPoliciesRequestFromSDK converts the sdk-go type to the mirror. +func ListServicePrincipalFederationPoliciesRequestFromSDK(v *sdk.ListServicePrincipalFederationPoliciesRequest) (*ListServicePrincipalFederationPoliciesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListServicePrincipalFederationPoliciesRequest{} + out.AccountId = v.AccountId + out.ServicePrincipalId = v.ServicePrincipalId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListServicePrincipalSecretsRequestToSDK converts the mirror to the sdk-go type. +func ListServicePrincipalSecretsRequestToSDK(w *ListServicePrincipalSecretsRequest) (*sdk.ListServicePrincipalSecretsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListServicePrincipalSecretsRequest{} + out.AccountId = w.AccountId + out.ServicePrincipal = w.ServicePrincipal + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListServicePrincipalSecretsRequestFromSDK converts the sdk-go type to the mirror. +func ListServicePrincipalSecretsRequestFromSDK(v *sdk.ListServicePrincipalSecretsRequest) (*ListServicePrincipalSecretsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListServicePrincipalSecretsRequest{} + out.AccountId = v.AccountId + out.ServicePrincipal = v.ServicePrincipal + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListServicePrincipalSecretsResponseToSDK converts the mirror to the sdk-go type. +func ListServicePrincipalSecretsResponseToSDK(w *ListServicePrincipalSecretsResponse) (*sdk.ListServicePrincipalSecretsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListServicePrincipalSecretsResponse{} + conv9, err := convertSlice(w.Secrets, ServicePrincipalSecretToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListServicePrincipalSecretsResponse.Secrets", err) + } + out.Secrets = conv9 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListServicePrincipalSecretsResponseFromSDK converts the sdk-go type to the mirror. +func ListServicePrincipalSecretsResponseFromSDK(v *sdk.ListServicePrincipalSecretsResponse) (*ListServicePrincipalSecretsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListServicePrincipalSecretsResponse{} + conv10, err := convertSlice(v.Secrets, ServicePrincipalSecretFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListServicePrincipalSecretsResponse.Secrets", err) + } + out.Secrets = conv10 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// OidcFederationPolicyToSDK converts the mirror to the sdk-go type. +func OidcFederationPolicyToSDK(w *OidcFederationPolicy) (*sdk.OidcFederationPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.OidcFederationPolicy{} + out.Issuer = w.Issuer + out.Subject = w.Subject + out.Audiences = w.Audiences + out.SubjectClaim = w.SubjectClaim + out.JwksUri = w.JwksUri + out.JwksJson = w.JwksJson + return out, nil +} + +// OidcFederationPolicyFromSDK converts the sdk-go type to the mirror. +func OidcFederationPolicyFromSDK(v *sdk.OidcFederationPolicy) (*OidcFederationPolicy, error) { + if v == nil { + return nil, nil + } + out := &OidcFederationPolicy{} + out.Issuer = v.Issuer + out.Subject = v.Subject + out.Audiences = v.Audiences + out.SubjectClaim = v.SubjectClaim + out.JwksUri = v.JwksUri + out.JwksJson = v.JwksJson + return out, nil +} + +// ServicePrincipalSecretToSDK converts the mirror to the sdk-go type. +func ServicePrincipalSecretToSDK(w *ServicePrincipalSecret) (*sdk.ServicePrincipalSecret, error) { + if w == nil { + return nil, nil + } + out := &sdk.ServicePrincipalSecret{} + out.Id = w.Id + out.Secret = w.Secret + out.SecretHash = w.SecretHash + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.Status = w.Status + out.ExpireTime = w.ExpireTime + out.Scopes = w.Scopes + return out, nil +} + +// ServicePrincipalSecretFromSDK converts the sdk-go type to the mirror. +func ServicePrincipalSecretFromSDK(v *sdk.ServicePrincipalSecret) (*ServicePrincipalSecret, error) { + if v == nil { + return nil, nil + } + out := &ServicePrincipalSecret{} + out.Id = v.Id + out.Secret = v.Secret + out.SecretHash = v.SecretHash + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.Status = v.Status + out.ExpireTime = v.ExpireTime + out.Scopes = v.Scopes + return out, nil +} + +// UpdateAccountFederationPolicyRequestToSDK converts the mirror to the sdk-go type. +func UpdateAccountFederationPolicyRequestToSDK(w *UpdateAccountFederationPolicyRequest) (*sdk.UpdateAccountFederationPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAccountFederationPolicyRequest{} + out.AccountId = w.AccountId + out.ServicePrincipalId = w.ServicePrincipalId + out.PolicyId = w.PolicyId + conv11, err := FederationPolicyToSDK(w.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountFederationPolicyRequest.Policy", err) + } + out.Policy = conv11 + mask12, err := fieldMaskFromString[sdk.FederationPolicy](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountFederationPolicyRequest.UpdateMask", err) + } + out.UpdateMask = mask12 + return out, nil +} + +// UpdateAccountFederationPolicyRequestFromSDK converts the sdk-go type to the mirror. +func UpdateAccountFederationPolicyRequestFromSDK(v *sdk.UpdateAccountFederationPolicyRequest) (*UpdateAccountFederationPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateAccountFederationPolicyRequest{} + out.AccountId = v.AccountId + out.ServicePrincipalId = v.ServicePrincipalId + out.PolicyId = v.PolicyId + conv13, err := FederationPolicyFromSDK(v.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountFederationPolicyRequest.Policy", err) + } + out.Policy = conv13 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateServicePrincipalFederationPolicyRequestToSDK converts the mirror to the sdk-go type. +func UpdateServicePrincipalFederationPolicyRequestToSDK(w *UpdateServicePrincipalFederationPolicyRequest) (*sdk.UpdateServicePrincipalFederationPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateServicePrincipalFederationPolicyRequest{} + out.AccountId = w.AccountId + out.ServicePrincipalId = w.ServicePrincipalId + out.PolicyId = w.PolicyId + conv14, err := FederationPolicyToSDK(w.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateServicePrincipalFederationPolicyRequest.Policy", err) + } + out.Policy = conv14 + mask15, err := fieldMaskFromString[sdk.FederationPolicy](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateServicePrincipalFederationPolicyRequest.UpdateMask", err) + } + out.UpdateMask = mask15 + return out, nil +} + +// UpdateServicePrincipalFederationPolicyRequestFromSDK converts the sdk-go type to the mirror. +func UpdateServicePrincipalFederationPolicyRequestFromSDK(v *sdk.UpdateServicePrincipalFederationPolicyRequest) (*UpdateServicePrincipalFederationPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateServicePrincipalFederationPolicyRequest{} + out.AccountId = v.AccountId + out.ServicePrincipalId = v.ServicePrincipalId + out.PolicyId = v.PolicyId + conv16, err := FederationPolicyFromSDK(v.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateServicePrincipalFederationPolicyRequest.Policy", err) + } + out.Policy = conv16 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/budgetpolicy/v1/types.generated.go b/libs/sdktypes/budgetpolicy/v1/types.generated.go new file mode 100644 index 00000000000..04fcc3f6337 --- /dev/null +++ b/libs/sdktypes/budgetpolicy/v1/types.generated.go @@ -0,0 +1,415 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/budgetpolicy/v1. DO NOT EDIT. + +package budgetpolicy + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/budgetpolicy/v1" +) + +type ( + SortSpec_Field = sdk.SortSpec_Field +) + +const ( + SortSpec_Field_Unspecified = sdk.SortSpec_Field_Unspecified + SortSpec_Field_PolicyName = sdk.SortSpec_Field_PolicyName +) + +// Contains the BudgetPolicy details.. +type BudgetPolicy struct { + // List of workspaces that this budget policy will be exclusively bound to. An + // empty binding implies that this budget policy is open to any workspace in the + // account. + BindingWorkspaceIds []int64 `json:"binding_workspace_ids,omitempty"` + // A list of tags defined by the customer. At most 20 entries are allowed per + // policy. + CustomTags []CustomPolicyTag `json:"custom_tags,omitempty"` + // The Id of the policy. This field is generated by and globally + // unique. + PolicyId *string `json:"policy_id,omitempty"` + // The name of the policy. - Must be unique among active policies. - Can contain + // only characters from the ISO 8859-1 (latin1) set. - Can't start with reserved + // keywords such as `databricks:default-policy`. + PolicyName *string `json:"policy_name,omitempty"` +} + +// A request to create a BudgetPolicy.. +type CreateBudgetPolicyRequest struct { + // The account Id of the customer + AccountId *string `json:"account_id,omitempty"` + // The policy to create. `policy_id` needs to be empty as it will be generated + // `policy_name` must be provided, custom_tags may need to be provided depending + // on the cloud provider. All other fields are optional. + Policy *BudgetPolicy `json:"policy,omitempty"` + // A unique identifier for this request. Restricted to 36 ASCII characters. A + // random UUID is recommended. This request is only idempotent if a `request_id` + // is provided. + RequestId *string `json:"request_id,omitempty"` +} + +type CustomPolicyTag struct { + // The key of the tag. - Must be unique among all custom tags of the same policy + // - Cannot be “budget-policy-name”, “budget-policy-id” or + // "budget-policy-resolution-result" - these tags are preserved. + Key *string `json:"key,omitempty"` + // The value of the tag. + Value *string `json:"value,omitempty"` +} + +// Structured representation of a filter to be applied to a list of policies. +// All specified filters will be applied in conjunction.. +type Filter struct { + // The policy creator user id to be filtered on. If unspecified, all policies + // will be returned. + CreatorUserId *int64 `json:"creator_user_id,omitempty"` + // Deprecated: Do not use this field in new integrations. Creator filtering will + // be removed in a future version. The policy creator user name to be filtered + // on. If unspecified, all policies will be returned. + CreatorUserName *string `json:"creator_user_name,omitempty"` + // The partial name of policies to be filtered on. If unspecified, all policies + // will be returned. + PolicyName *string `json:"policy_name,omitempty"` +} + +// The limit configuration of the policy. Limit configuration provide a budget +// policy level cost control by enforcing the limit.. +type LimitConfig struct { +} + +// Request to list budget policies. Uses pagination.. +type ListBudgetPoliciesRequest struct { + // The account Id of the customer + AccountId *string `json:"account_id,omitempty"` + // A filter to apply to the list of policies. + FilterBy *Filter `json:"filter_by,omitempty"` + // The maximum number of budget policies to return. If unspecified, at most 100 + // budget policies will be returned. The maximum value is 1000; values above + // 1000 will be coerced to 1000. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous `ListServerlessPolicies` call. Provide + // this to retrieve the subsequent page. If unspecified, the first page will be + // returned. + // + // When paginating, all other parameters provided to + // `ListServerlessPoliciesRequest` must match the call that provided the page + // token. + PageToken *string `json:"page_token,omitempty"` + // The sort specification. + SortSpec *SortSpec `json:"sort_spec,omitempty"` +} + +// A list of policies.. +type ListBudgetPoliciesResponse struct { + // A token that can be sent as `page_token` to retrieve the next page. If this + // field is omitted, there are no subsequent pages. + NextPageToken *string `json:"next_page_token,omitempty"` + Policies []BudgetPolicy `json:"policies,omitempty"` + // A token that can be sent as `page_token` to retrieve the previous page. In + // this field is omitted, there are no previous pages. + PreviousPageToken *string `json:"previous_page_token,omitempty"` +} + +type SortSpec struct { + // Whether to sort in descending order. + Descending *bool `json:"descending,omitempty"` + // The filed to sort by + Field SortSpec_Field `json:"field,omitempty"` +} + +// Updates a BudgetPolicy.. +type UpdateBudgetPolicyRequest struct { + // The account Id of the customer + AccountId *string `json:"account_id,omitempty"` + // DEPRECATED. This is redundant field as LimitConfig is part of the + // BudgetPolicy + LimitConfig *LimitConfig `json:"limit_config,omitempty"` + // The policy to update. `creator_user_id` cannot be specified in the request. + // All other fields must be specified even if not changed. The `policy_id` is + // used to identify the policy to update. + Policy *BudgetPolicy `json:"policy,omitempty"` +} + +// BudgetPolicyToSDK converts the mirror to the sdk-go type. +func BudgetPolicyToSDK(w *BudgetPolicy) (*sdk.BudgetPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.BudgetPolicy{} + out.PolicyId = w.PolicyId + out.PolicyName = w.PolicyName + conv1, err := convertSlice(w.CustomTags, CustomPolicyTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BudgetPolicy.CustomTags", err) + } + out.CustomTags = conv1 + out.BindingWorkspaceIds = w.BindingWorkspaceIds + return out, nil +} + +// BudgetPolicyFromSDK converts the sdk-go type to the mirror. +func BudgetPolicyFromSDK(v *sdk.BudgetPolicy) (*BudgetPolicy, error) { + if v == nil { + return nil, nil + } + out := &BudgetPolicy{} + out.PolicyId = v.PolicyId + out.PolicyName = v.PolicyName + conv2, err := convertSlice(v.CustomTags, CustomPolicyTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BudgetPolicy.CustomTags", err) + } + out.CustomTags = conv2 + out.BindingWorkspaceIds = v.BindingWorkspaceIds + return out, nil +} + +// CreateBudgetPolicyRequestToSDK converts the mirror to the sdk-go type. +func CreateBudgetPolicyRequestToSDK(w *CreateBudgetPolicyRequest) (*sdk.CreateBudgetPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateBudgetPolicyRequest{} + out.RequestId = w.RequestId + out.AccountId = w.AccountId + conv3, err := BudgetPolicyToSDK(w.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetPolicyRequest.Policy", err) + } + out.Policy = conv3 + return out, nil +} + +// CreateBudgetPolicyRequestFromSDK converts the sdk-go type to the mirror. +func CreateBudgetPolicyRequestFromSDK(v *sdk.CreateBudgetPolicyRequest) (*CreateBudgetPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateBudgetPolicyRequest{} + out.RequestId = v.RequestId + out.AccountId = v.AccountId + conv4, err := BudgetPolicyFromSDK(v.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetPolicyRequest.Policy", err) + } + out.Policy = conv4 + return out, nil +} + +// CustomPolicyTagToSDK converts the mirror to the sdk-go type. +func CustomPolicyTagToSDK(w *CustomPolicyTag) (*sdk.CustomPolicyTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomPolicyTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// CustomPolicyTagFromSDK converts the sdk-go type to the mirror. +func CustomPolicyTagFromSDK(v *sdk.CustomPolicyTag) (*CustomPolicyTag, error) { + if v == nil { + return nil, nil + } + out := &CustomPolicyTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// FilterToSDK converts the mirror to the sdk-go type. +func FilterToSDK(w *Filter) (*sdk.Filter, error) { + if w == nil { + return nil, nil + } + out := &sdk.Filter{} + out.PolicyName = w.PolicyName + out.CreatorUserId = w.CreatorUserId + out.CreatorUserName = w.CreatorUserName + return out, nil +} + +// FilterFromSDK converts the sdk-go type to the mirror. +func FilterFromSDK(v *sdk.Filter) (*Filter, error) { + if v == nil { + return nil, nil + } + out := &Filter{} + out.PolicyName = v.PolicyName + out.CreatorUserId = v.CreatorUserId + out.CreatorUserName = v.CreatorUserName + return out, nil +} + +// LimitConfigToSDK converts the mirror to the sdk-go type. +func LimitConfigToSDK(w *LimitConfig) (*sdk.LimitConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.LimitConfig{} + return out, nil +} + +// LimitConfigFromSDK converts the sdk-go type to the mirror. +func LimitConfigFromSDK(v *sdk.LimitConfig) (*LimitConfig, error) { + if v == nil { + return nil, nil + } + out := &LimitConfig{} + return out, nil +} + +// ListBudgetPoliciesRequestToSDK converts the mirror to the sdk-go type. +func ListBudgetPoliciesRequestToSDK(w *ListBudgetPoliciesRequest) (*sdk.ListBudgetPoliciesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListBudgetPoliciesRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + conv5, err := FilterToSDK(w.FilterBy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListBudgetPoliciesRequest.FilterBy", err) + } + out.FilterBy = conv5 + conv6, err := SortSpecToSDK(w.SortSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListBudgetPoliciesRequest.SortSpec", err) + } + out.SortSpec = conv6 + out.AccountId = w.AccountId + return out, nil +} + +// ListBudgetPoliciesRequestFromSDK converts the sdk-go type to the mirror. +func ListBudgetPoliciesRequestFromSDK(v *sdk.ListBudgetPoliciesRequest) (*ListBudgetPoliciesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListBudgetPoliciesRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + conv7, err := FilterFromSDK(v.FilterBy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListBudgetPoliciesRequest.FilterBy", err) + } + out.FilterBy = conv7 + conv8, err := SortSpecFromSDK(v.SortSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListBudgetPoliciesRequest.SortSpec", err) + } + out.SortSpec = conv8 + out.AccountId = v.AccountId + return out, nil +} + +// ListBudgetPoliciesResponseToSDK converts the mirror to the sdk-go type. +func ListBudgetPoliciesResponseToSDK(w *ListBudgetPoliciesResponse) (*sdk.ListBudgetPoliciesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListBudgetPoliciesResponse{} + conv9, err := convertSlice(w.Policies, BudgetPolicyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListBudgetPoliciesResponse.Policies", err) + } + out.Policies = conv9 + out.NextPageToken = w.NextPageToken + out.PreviousPageToken = w.PreviousPageToken + return out, nil +} + +// ListBudgetPoliciesResponseFromSDK converts the sdk-go type to the mirror. +func ListBudgetPoliciesResponseFromSDK(v *sdk.ListBudgetPoliciesResponse) (*ListBudgetPoliciesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListBudgetPoliciesResponse{} + conv10, err := convertSlice(v.Policies, BudgetPolicyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListBudgetPoliciesResponse.Policies", err) + } + out.Policies = conv10 + out.NextPageToken = v.NextPageToken + out.PreviousPageToken = v.PreviousPageToken + return out, nil +} + +// SortSpecToSDK converts the mirror to the sdk-go type. +func SortSpecToSDK(w *SortSpec) (*sdk.SortSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.SortSpec{} + out.Field = w.Field + out.Descending = w.Descending + return out, nil +} + +// SortSpecFromSDK converts the sdk-go type to the mirror. +func SortSpecFromSDK(v *sdk.SortSpec) (*SortSpec, error) { + if v == nil { + return nil, nil + } + out := &SortSpec{} + out.Field = v.Field + out.Descending = v.Descending + return out, nil +} + +// UpdateBudgetPolicyRequestToSDK converts the mirror to the sdk-go type. +func UpdateBudgetPolicyRequestToSDK(w *UpdateBudgetPolicyRequest) (*sdk.UpdateBudgetPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateBudgetPolicyRequest{} + conv11, err := BudgetPolicyToSDK(w.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBudgetPolicyRequest.Policy", err) + } + out.Policy = conv11 + out.AccountId = w.AccountId + conv12, err := LimitConfigToSDK(w.LimitConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBudgetPolicyRequest.LimitConfig", err) + } + out.LimitConfig = conv12 + return out, nil +} + +// UpdateBudgetPolicyRequestFromSDK converts the sdk-go type to the mirror. +func UpdateBudgetPolicyRequestFromSDK(v *sdk.UpdateBudgetPolicyRequest) (*UpdateBudgetPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateBudgetPolicyRequest{} + conv13, err := BudgetPolicyFromSDK(v.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBudgetPolicyRequest.Policy", err) + } + out.Policy = conv13 + out.AccountId = v.AccountId + conv14, err := LimitConfigFromSDK(v.LimitConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBudgetPolicyRequest.LimitConfig", err) + } + out.LimitConfig = conv14 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/budgets/v1/types.generated.go b/libs/sdktypes/budgets/v1/types.generated.go new file mode 100644 index 00000000000..7ea444e4f72 --- /dev/null +++ b/libs/sdktypes/budgets/v1/types.generated.go @@ -0,0 +1,871 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/budgets/v1. DO NOT EDIT. + +package budgets + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/budgets/v1" +) + +type ( + ActionConfigurationType = sdk.ActionConfigurationType + AlertConfigurationQuantityType = sdk.AlertConfigurationQuantityType + AlertConfigurationScopeType = sdk.AlertConfigurationScopeType + AlertConfigurationTimePeriod = sdk.AlertConfigurationTimePeriod + AlertConfigurationTriggerType = sdk.AlertConfigurationTriggerType + BudgetResourceType = sdk.BudgetResourceType + BudgetConfigurationFilter_Operator = sdk.BudgetConfigurationFilter_Operator +) + +const ( + ActionConfigurationType_Unspecified = sdk.ActionConfigurationType_Unspecified + ActionConfigurationType_EmailNotification = sdk.ActionConfigurationType_EmailNotification + ActionConfigurationType_BlockUsage = sdk.ActionConfigurationType_BlockUsage + AlertConfigurationQuantityType_Unspecified = sdk.AlertConfigurationQuantityType_Unspecified + AlertConfigurationQuantityType_ListPriceDollarsUsd = sdk.AlertConfigurationQuantityType_ListPriceDollarsUsd + AlertConfigurationScopeType_Unspecified = sdk.AlertConfigurationScopeType_Unspecified + AlertConfigurationScopeType_AlertConfigurationScopeTypeShared = sdk.AlertConfigurationScopeType_AlertConfigurationScopeTypeShared + AlertConfigurationScopeType_AlertConfigurationScopeTypePerUser = sdk.AlertConfigurationScopeType_AlertConfigurationScopeTypePerUser + AlertConfigurationTimePeriod_Unspecified = sdk.AlertConfigurationTimePeriod_Unspecified + AlertConfigurationTimePeriod_Month = sdk.AlertConfigurationTimePeriod_Month + AlertConfigurationTriggerType_Unspecified = sdk.AlertConfigurationTriggerType_Unspecified + AlertConfigurationTriggerType_CumulativeSpendingExceeded = sdk.AlertConfigurationTriggerType_CumulativeSpendingExceeded + BudgetResourceType_Unspecified = sdk.BudgetResourceType_Unspecified + BudgetResourceType_BudgetResourceTypeAllResources = sdk.BudgetResourceType_BudgetResourceTypeAllResources + BudgetResourceType_BudgetResourceTypeUnityAiGateway = sdk.BudgetResourceType_BudgetResourceTypeUnityAiGateway + BudgetConfigurationFilter_Operator_Unspecified = sdk.BudgetConfigurationFilter_Operator_Unspecified + BudgetConfigurationFilter_Operator_In = sdk.BudgetConfigurationFilter_Operator_In +) + +type ActionConfiguration struct { + // action configuration ID. + ActionConfigurationId *string `json:"action_configuration_id,omitempty"` + // The type of the action. + ActionType ActionConfigurationType `json:"action_type,omitempty"` + // Target for the action. For example, an email address. + Target *string `json:"target,omitempty"` +} + +type AlertConfiguration struct { + // Configured actions for this alert. These define what happens when an alert + // enters a triggered state. + ActionConfigurations []ActionConfiguration `json:"action_configurations,omitempty"` + // alert configuration ID. + AlertConfigurationId *string `json:"alert_configuration_id,omitempty"` + // Per-principal threshold overrides for this alert. Only applies to per-user + // alerts (`scope_type` = `ALERT_CONFIGURATION_SCOPE_TYPE_PER_USER`); ignored + // for shared alerts. + PrincipalOverrides []PrincipalOverride `json:"principal_overrides,omitempty"` + // The threshold for the budget alert to determine if it is in a triggered + // state. The number is evaluated based on `quantity_type`. + QuantityThreshold *string `json:"quantity_threshold,omitempty"` + // The way to calculate cost for this budget alert. This is what + // `quantity_threshold` is measured in. + QuantityType AlertConfigurationQuantityType `json:"quantity_type,omitempty"` + // How the alert threshold is evaluated. Determines whether spend is tracked in + // aggregate or per individual user. + ScopeType AlertConfigurationScopeType `json:"scope_type,omitempty"` + // The time window of usage data for the budget. + TimePeriod AlertConfigurationTimePeriod `json:"time_period,omitempty"` + // The evaluation method to determine when this budget alert is in a triggered + // state. + TriggerType AlertConfigurationTriggerType `json:"trigger_type,omitempty"` +} + +type BudgetConfiguration struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + // Alerts to configure when this budget is in a triggered state. Budgets must + // have exactly one alert configuration. + AlertConfigurations []AlertConfiguration `json:"alert_configurations,omitempty"` + // budget configuration ID. + BudgetConfigurationId *string `json:"budget_configuration_id,omitempty"` + // Creation time of this budget configuration. + CreateTime *int64 `json:"create_time,omitempty"` + // Human-readable name of budget configuration. Max Length: 128 + DisplayName *string `json:"display_name,omitempty"` + // Configured filters for this budget. These are applied to your account's usage + // to limit the scope of what is considered for this budget. Leave empty to + // include all usage for this account. All provided filters must be matched for + // usage to be included. + Filter *BudgetConfigurationFilter `json:"filter,omitempty"` + // The resource scope for this budget. Determines whether the budget tracks all + // resources or a specific resource. + ResourceType BudgetResourceType `json:"resource_type,omitempty"` + // Update time of this budget configuration. + UpdateTime *int64 `json:"update_time,omitempty"` +} + +type BudgetConfigurationFilter struct { + // A list of tag keys and values that will limit the budget to usage that + // includes those specific custom tags. Tags are case-sensitive and should be + // entered exactly as they appear in your usage data. + Tags []BudgetConfigurationFilter_TagClause `json:"tags,omitempty"` + // If provided, usage must match with the provided workspace IDs. + WorkspaceId *BudgetConfigurationFilter_WorkspaceIdClause `json:"workspace_id,omitempty"` +} + +type BudgetConfigurationFilter_Clause struct { + Operator BudgetConfigurationFilter_Operator `json:"operator,omitempty"` + Values []string `json:"values,omitempty"` +} + +type BudgetConfigurationFilter_TagClause struct { + Key *string `json:"key,omitempty"` + Value *BudgetConfigurationFilter_Clause `json:"value,omitempty"` +} + +type BudgetConfigurationFilter_WorkspaceIdClause struct { + Operator BudgetConfigurationFilter_Operator `json:"operator,omitempty"` + Values []int64 `json:"values,omitempty"` +} + +type CreateBudgetConfigurationBudget struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + // Alerts to configure when this budget is in a triggered state. Budgets must + // have exactly one alert configuration. + AlertConfigurations []CreateBudgetConfigurationBudgetAlertConfigurations `json:"alert_configurations,omitempty"` + // Human-readable name of budget configuration. Max Length: 128 + DisplayName *string `json:"display_name,omitempty"` + // Configured filters for this budget. These are applied to your account's usage + // to limit the scope of what is considered for this budget. Leave empty to + // include all usage for this account. All provided filters must be matched for + // usage to be included. + Filter *BudgetConfigurationFilter `json:"filter,omitempty"` + // The resource scope for this budget. Determines whether the budget tracks all + // resources or a specific resource. + ResourceType BudgetResourceType `json:"resource_type,omitempty"` +} + +type CreateBudgetConfigurationBudgetActionConfigurations struct { + // The type of the action. + ActionType ActionConfigurationType `json:"action_type,omitempty"` + // Target for the action. For example, an email address. + Target *string `json:"target,omitempty"` +} + +type CreateBudgetConfigurationBudgetAlertConfigurations struct { + // Configured actions for this alert. These define what happens when an alert + // enters a triggered state. + ActionConfigurations []CreateBudgetConfigurationBudgetActionConfigurations `json:"action_configurations,omitempty"` + // Per-principal threshold overrides for this alert. Only applies to per-user + // alerts (`scope_type` = `ALERT_CONFIGURATION_SCOPE_TYPE_PER_USER`); ignored + // for shared alerts. + PrincipalOverrides []PrincipalOverride `json:"principal_overrides,omitempty"` + // The threshold for the budget alert to determine if it is in a triggered + // state. The number is evaluated based on `quantity_type`. + QuantityThreshold *string `json:"quantity_threshold,omitempty"` + // The way to calculate cost for this budget alert. This is what + // `quantity_threshold` is measured in. + QuantityType AlertConfigurationQuantityType `json:"quantity_type,omitempty"` + // How the alert threshold is evaluated. Determines whether spend is tracked in + // aggregate or per individual user. + ScopeType AlertConfigurationScopeType `json:"scope_type,omitempty"` + // The time window of usage data for the budget. + TimePeriod AlertConfigurationTimePeriod `json:"time_period,omitempty"` + // The evaluation method to determine when this budget alert is in a triggered + // state. + TriggerType AlertConfigurationTriggerType `json:"trigger_type,omitempty"` +} + +type CreateBudgetConfigurationRequest struct { + // Properties of the new budget configuration. + Budget *CreateBudgetConfigurationBudget `json:"budget,omitempty"` +} + +type CreateBudgetConfigurationResponse struct { + // The created budget configuration. + Budget *BudgetConfiguration `json:"budget,omitempty"` +} + +type GetBudgetConfigurationResponse struct { + Budget *BudgetConfiguration `json:"budget,omitempty"` +} + +type ListBudgetConfigurationsRequest struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + // A page token received from a previous get all budget configurations call. + // This token can be used to retrieve the subsequent page. Requests first page + // if absent. + PageToken *string `json:"page_token,omitempty"` +} + +type ListBudgetConfigurationsResponse struct { + Budgets []BudgetConfiguration `json:"budgets,omitempty"` + // Token which can be sent as `page_token` to retrieve the next page of results. + // If this field is omitted, there are no subsequent budgets. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Per-principal threshold override on a PER_USER alert: bumps the alert's +// quantity_threshold for one principal_id.. +type PrincipalOverride struct { + // Dollar amount that overrides the parent alert's quantity_threshold for this + // principal. + OverrideThreshold *string `json:"override_threshold,omitempty"` + // Account-level principal id (user, group, or service principal). + PrincipalId *int64 `json:"principal_id,omitempty"` +} + +type UpdateBudgetConfigurationBudget struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + // Alerts to configure when this budget is in a triggered state. Budgets must + // have exactly one alert configuration. + AlertConfigurations []AlertConfiguration `json:"alert_configurations,omitempty"` + // budget configuration ID. + BudgetConfigurationId *string `json:"budget_configuration_id,omitempty"` + // Human-readable name of budget configuration. Max Length: 128 + DisplayName *string `json:"display_name,omitempty"` + // Configured filters for this budget. These are applied to your account's usage + // to limit the scope of what is considered for this budget. Leave empty to + // include all usage for this account. All provided filters must be matched for + // usage to be included. + Filter *BudgetConfigurationFilter `json:"filter,omitempty"` + // The resource scope for this budget. Determines whether the budget tracks all + // resources or a specific resource. + ResourceType BudgetResourceType `json:"resource_type,omitempty"` +} + +type UpdateBudgetConfigurationRequest struct { + // The updated budget. This will overwrite the budget specified by the budget + // ID. + Budget *UpdateBudgetConfigurationBudget `json:"budget,omitempty"` + // The budget configuration ID. + BudgetId *string `json:"budget_id,omitempty"` +} + +type UpdateBudgetConfigurationResponse struct { + // The updated budget. + Budget *BudgetConfiguration `json:"budget,omitempty"` +} + +// ActionConfigurationToSDK converts the mirror to the sdk-go type. +func ActionConfigurationToSDK(w *ActionConfiguration) (*sdk.ActionConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.ActionConfiguration{} + out.ActionConfigurationId = w.ActionConfigurationId + out.ActionType = w.ActionType + out.Target = w.Target + return out, nil +} + +// ActionConfigurationFromSDK converts the sdk-go type to the mirror. +func ActionConfigurationFromSDK(v *sdk.ActionConfiguration) (*ActionConfiguration, error) { + if v == nil { + return nil, nil + } + out := &ActionConfiguration{} + out.ActionConfigurationId = v.ActionConfigurationId + out.ActionType = v.ActionType + out.Target = v.Target + return out, nil +} + +// AlertConfigurationToSDK converts the mirror to the sdk-go type. +func AlertConfigurationToSDK(w *AlertConfiguration) (*sdk.AlertConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertConfiguration{} + out.AlertConfigurationId = w.AlertConfigurationId + out.TimePeriod = w.TimePeriod + out.TriggerType = w.TriggerType + out.QuantityType = w.QuantityType + out.QuantityThreshold = w.QuantityThreshold + conv1, err := convertSlice(w.ActionConfigurations, ActionConfigurationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertConfiguration.ActionConfigurations", err) + } + out.ActionConfigurations = conv1 + out.ScopeType = w.ScopeType + conv2, err := convertSlice(w.PrincipalOverrides, PrincipalOverrideToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertConfiguration.PrincipalOverrides", err) + } + out.PrincipalOverrides = conv2 + return out, nil +} + +// AlertConfigurationFromSDK converts the sdk-go type to the mirror. +func AlertConfigurationFromSDK(v *sdk.AlertConfiguration) (*AlertConfiguration, error) { + if v == nil { + return nil, nil + } + out := &AlertConfiguration{} + out.AlertConfigurationId = v.AlertConfigurationId + out.TimePeriod = v.TimePeriod + out.TriggerType = v.TriggerType + out.QuantityType = v.QuantityType + out.QuantityThreshold = v.QuantityThreshold + conv3, err := convertSlice(v.ActionConfigurations, ActionConfigurationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertConfiguration.ActionConfigurations", err) + } + out.ActionConfigurations = conv3 + out.ScopeType = v.ScopeType + conv4, err := convertSlice(v.PrincipalOverrides, PrincipalOverrideFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertConfiguration.PrincipalOverrides", err) + } + out.PrincipalOverrides = conv4 + return out, nil +} + +// BudgetConfigurationToSDK converts the mirror to the sdk-go type. +func BudgetConfigurationToSDK(w *BudgetConfiguration) (*sdk.BudgetConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.BudgetConfiguration{} + out.BudgetConfigurationId = w.BudgetConfigurationId + out.AccountId = w.AccountId + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + conv5, err := convertSlice(w.AlertConfigurations, AlertConfigurationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BudgetConfiguration.AlertConfigurations", err) + } + out.AlertConfigurations = conv5 + conv6, err := BudgetConfigurationFilterToSDK(w.Filter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BudgetConfiguration.Filter", err) + } + out.Filter = conv6 + out.DisplayName = w.DisplayName + out.ResourceType = w.ResourceType + return out, nil +} + +// BudgetConfigurationFromSDK converts the sdk-go type to the mirror. +func BudgetConfigurationFromSDK(v *sdk.BudgetConfiguration) (*BudgetConfiguration, error) { + if v == nil { + return nil, nil + } + out := &BudgetConfiguration{} + out.BudgetConfigurationId = v.BudgetConfigurationId + out.AccountId = v.AccountId + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + conv7, err := convertSlice(v.AlertConfigurations, AlertConfigurationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BudgetConfiguration.AlertConfigurations", err) + } + out.AlertConfigurations = conv7 + conv8, err := BudgetConfigurationFilterFromSDK(v.Filter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BudgetConfiguration.Filter", err) + } + out.Filter = conv8 + out.DisplayName = v.DisplayName + out.ResourceType = v.ResourceType + return out, nil +} + +// BudgetConfigurationFilterToSDK converts the mirror to the sdk-go type. +func BudgetConfigurationFilterToSDK(w *BudgetConfigurationFilter) (*sdk.BudgetConfigurationFilter, error) { + if w == nil { + return nil, nil + } + out := &sdk.BudgetConfigurationFilter{} + conv9, err := BudgetConfigurationFilter_WorkspaceIdClauseToSDK(w.WorkspaceId) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BudgetConfigurationFilter.WorkspaceId", err) + } + out.WorkspaceId = conv9 + conv10, err := convertSlice(w.Tags, BudgetConfigurationFilter_TagClauseToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BudgetConfigurationFilter.Tags", err) + } + out.Tags = conv10 + return out, nil +} + +// BudgetConfigurationFilterFromSDK converts the sdk-go type to the mirror. +func BudgetConfigurationFilterFromSDK(v *sdk.BudgetConfigurationFilter) (*BudgetConfigurationFilter, error) { + if v == nil { + return nil, nil + } + out := &BudgetConfigurationFilter{} + conv11, err := BudgetConfigurationFilter_WorkspaceIdClauseFromSDK(v.WorkspaceId) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BudgetConfigurationFilter.WorkspaceId", err) + } + out.WorkspaceId = conv11 + conv12, err := convertSlice(v.Tags, BudgetConfigurationFilter_TagClauseFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BudgetConfigurationFilter.Tags", err) + } + out.Tags = conv12 + return out, nil +} + +// BudgetConfigurationFilter_ClauseToSDK converts the mirror to the sdk-go type. +func BudgetConfigurationFilter_ClauseToSDK(w *BudgetConfigurationFilter_Clause) (*sdk.BudgetConfigurationFilter_Clause, error) { + if w == nil { + return nil, nil + } + out := &sdk.BudgetConfigurationFilter_Clause{} + out.Operator = w.Operator + out.Values = w.Values + return out, nil +} + +// BudgetConfigurationFilter_ClauseFromSDK converts the sdk-go type to the mirror. +func BudgetConfigurationFilter_ClauseFromSDK(v *sdk.BudgetConfigurationFilter_Clause) (*BudgetConfigurationFilter_Clause, error) { + if v == nil { + return nil, nil + } + out := &BudgetConfigurationFilter_Clause{} + out.Operator = v.Operator + out.Values = v.Values + return out, nil +} + +// BudgetConfigurationFilter_TagClauseToSDK converts the mirror to the sdk-go type. +func BudgetConfigurationFilter_TagClauseToSDK(w *BudgetConfigurationFilter_TagClause) (*sdk.BudgetConfigurationFilter_TagClause, error) { + if w == nil { + return nil, nil + } + out := &sdk.BudgetConfigurationFilter_TagClause{} + out.Key = w.Key + conv13, err := BudgetConfigurationFilter_ClauseToSDK(w.Value) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BudgetConfigurationFilter_TagClause.Value", err) + } + out.Value = conv13 + return out, nil +} + +// BudgetConfigurationFilter_TagClauseFromSDK converts the sdk-go type to the mirror. +func BudgetConfigurationFilter_TagClauseFromSDK(v *sdk.BudgetConfigurationFilter_TagClause) (*BudgetConfigurationFilter_TagClause, error) { + if v == nil { + return nil, nil + } + out := &BudgetConfigurationFilter_TagClause{} + out.Key = v.Key + conv14, err := BudgetConfigurationFilter_ClauseFromSDK(v.Value) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BudgetConfigurationFilter_TagClause.Value", err) + } + out.Value = conv14 + return out, nil +} + +// BudgetConfigurationFilter_WorkspaceIdClauseToSDK converts the mirror to the sdk-go type. +func BudgetConfigurationFilter_WorkspaceIdClauseToSDK(w *BudgetConfigurationFilter_WorkspaceIdClause) (*sdk.BudgetConfigurationFilter_WorkspaceIdClause, error) { + if w == nil { + return nil, nil + } + out := &sdk.BudgetConfigurationFilter_WorkspaceIdClause{} + out.Operator = w.Operator + out.Values = w.Values + return out, nil +} + +// BudgetConfigurationFilter_WorkspaceIdClauseFromSDK converts the sdk-go type to the mirror. +func BudgetConfigurationFilter_WorkspaceIdClauseFromSDK(v *sdk.BudgetConfigurationFilter_WorkspaceIdClause) (*BudgetConfigurationFilter_WorkspaceIdClause, error) { + if v == nil { + return nil, nil + } + out := &BudgetConfigurationFilter_WorkspaceIdClause{} + out.Operator = v.Operator + out.Values = v.Values + return out, nil +} + +// CreateBudgetConfigurationBudgetToSDK converts the mirror to the sdk-go type. +func CreateBudgetConfigurationBudgetToSDK(w *CreateBudgetConfigurationBudget) (*sdk.CreateBudgetConfigurationBudget, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateBudgetConfigurationBudget{} + out.AccountId = w.AccountId + conv15, err := convertSlice(w.AlertConfigurations, CreateBudgetConfigurationBudgetAlertConfigurationsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetConfigurationBudget.AlertConfigurations", err) + } + out.AlertConfigurations = conv15 + conv16, err := BudgetConfigurationFilterToSDK(w.Filter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetConfigurationBudget.Filter", err) + } + out.Filter = conv16 + out.DisplayName = w.DisplayName + out.ResourceType = w.ResourceType + return out, nil +} + +// CreateBudgetConfigurationBudgetFromSDK converts the sdk-go type to the mirror. +func CreateBudgetConfigurationBudgetFromSDK(v *sdk.CreateBudgetConfigurationBudget) (*CreateBudgetConfigurationBudget, error) { + if v == nil { + return nil, nil + } + out := &CreateBudgetConfigurationBudget{} + out.AccountId = v.AccountId + conv17, err := convertSlice(v.AlertConfigurations, CreateBudgetConfigurationBudgetAlertConfigurationsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetConfigurationBudget.AlertConfigurations", err) + } + out.AlertConfigurations = conv17 + conv18, err := BudgetConfigurationFilterFromSDK(v.Filter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetConfigurationBudget.Filter", err) + } + out.Filter = conv18 + out.DisplayName = v.DisplayName + out.ResourceType = v.ResourceType + return out, nil +} + +// CreateBudgetConfigurationBudgetActionConfigurationsToSDK converts the mirror to the sdk-go type. +func CreateBudgetConfigurationBudgetActionConfigurationsToSDK(w *CreateBudgetConfigurationBudgetActionConfigurations) (*sdk.CreateBudgetConfigurationBudgetActionConfigurations, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateBudgetConfigurationBudgetActionConfigurations{} + out.ActionType = w.ActionType + out.Target = w.Target + return out, nil +} + +// CreateBudgetConfigurationBudgetActionConfigurationsFromSDK converts the sdk-go type to the mirror. +func CreateBudgetConfigurationBudgetActionConfigurationsFromSDK(v *sdk.CreateBudgetConfigurationBudgetActionConfigurations) (*CreateBudgetConfigurationBudgetActionConfigurations, error) { + if v == nil { + return nil, nil + } + out := &CreateBudgetConfigurationBudgetActionConfigurations{} + out.ActionType = v.ActionType + out.Target = v.Target + return out, nil +} + +// CreateBudgetConfigurationBudgetAlertConfigurationsToSDK converts the mirror to the sdk-go type. +func CreateBudgetConfigurationBudgetAlertConfigurationsToSDK(w *CreateBudgetConfigurationBudgetAlertConfigurations) (*sdk.CreateBudgetConfigurationBudgetAlertConfigurations, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateBudgetConfigurationBudgetAlertConfigurations{} + out.TimePeriod = w.TimePeriod + out.TriggerType = w.TriggerType + out.QuantityType = w.QuantityType + out.QuantityThreshold = w.QuantityThreshold + conv19, err := convertSlice(w.ActionConfigurations, CreateBudgetConfigurationBudgetActionConfigurationsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetConfigurationBudgetAlertConfigurations.ActionConfigurations", err) + } + out.ActionConfigurations = conv19 + out.ScopeType = w.ScopeType + conv20, err := convertSlice(w.PrincipalOverrides, PrincipalOverrideToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetConfigurationBudgetAlertConfigurations.PrincipalOverrides", err) + } + out.PrincipalOverrides = conv20 + return out, nil +} + +// CreateBudgetConfigurationBudgetAlertConfigurationsFromSDK converts the sdk-go type to the mirror. +func CreateBudgetConfigurationBudgetAlertConfigurationsFromSDK(v *sdk.CreateBudgetConfigurationBudgetAlertConfigurations) (*CreateBudgetConfigurationBudgetAlertConfigurations, error) { + if v == nil { + return nil, nil + } + out := &CreateBudgetConfigurationBudgetAlertConfigurations{} + out.TimePeriod = v.TimePeriod + out.TriggerType = v.TriggerType + out.QuantityType = v.QuantityType + out.QuantityThreshold = v.QuantityThreshold + conv21, err := convertSlice(v.ActionConfigurations, CreateBudgetConfigurationBudgetActionConfigurationsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetConfigurationBudgetAlertConfigurations.ActionConfigurations", err) + } + out.ActionConfigurations = conv21 + out.ScopeType = v.ScopeType + conv22, err := convertSlice(v.PrincipalOverrides, PrincipalOverrideFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetConfigurationBudgetAlertConfigurations.PrincipalOverrides", err) + } + out.PrincipalOverrides = conv22 + return out, nil +} + +// CreateBudgetConfigurationRequestToSDK converts the mirror to the sdk-go type. +func CreateBudgetConfigurationRequestToSDK(w *CreateBudgetConfigurationRequest) (*sdk.CreateBudgetConfigurationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateBudgetConfigurationRequest{} + conv23, err := CreateBudgetConfigurationBudgetToSDK(w.Budget) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetConfigurationRequest.Budget", err) + } + out.Budget = conv23 + return out, nil +} + +// CreateBudgetConfigurationRequestFromSDK converts the sdk-go type to the mirror. +func CreateBudgetConfigurationRequestFromSDK(v *sdk.CreateBudgetConfigurationRequest) (*CreateBudgetConfigurationRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateBudgetConfigurationRequest{} + conv24, err := CreateBudgetConfigurationBudgetFromSDK(v.Budget) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetConfigurationRequest.Budget", err) + } + out.Budget = conv24 + return out, nil +} + +// CreateBudgetConfigurationResponseToSDK converts the mirror to the sdk-go type. +func CreateBudgetConfigurationResponseToSDK(w *CreateBudgetConfigurationResponse) (*sdk.CreateBudgetConfigurationResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateBudgetConfigurationResponse{} + conv25, err := BudgetConfigurationToSDK(w.Budget) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetConfigurationResponse.Budget", err) + } + out.Budget = conv25 + return out, nil +} + +// CreateBudgetConfigurationResponseFromSDK converts the sdk-go type to the mirror. +func CreateBudgetConfigurationResponseFromSDK(v *sdk.CreateBudgetConfigurationResponse) (*CreateBudgetConfigurationResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateBudgetConfigurationResponse{} + conv26, err := BudgetConfigurationFromSDK(v.Budget) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBudgetConfigurationResponse.Budget", err) + } + out.Budget = conv26 + return out, nil +} + +// GetBudgetConfigurationResponseToSDK converts the mirror to the sdk-go type. +func GetBudgetConfigurationResponseToSDK(w *GetBudgetConfigurationResponse) (*sdk.GetBudgetConfigurationResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetBudgetConfigurationResponse{} + conv27, err := BudgetConfigurationToSDK(w.Budget) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetBudgetConfigurationResponse.Budget", err) + } + out.Budget = conv27 + return out, nil +} + +// GetBudgetConfigurationResponseFromSDK converts the sdk-go type to the mirror. +func GetBudgetConfigurationResponseFromSDK(v *sdk.GetBudgetConfigurationResponse) (*GetBudgetConfigurationResponse, error) { + if v == nil { + return nil, nil + } + out := &GetBudgetConfigurationResponse{} + conv28, err := BudgetConfigurationFromSDK(v.Budget) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetBudgetConfigurationResponse.Budget", err) + } + out.Budget = conv28 + return out, nil +} + +// ListBudgetConfigurationsRequestToSDK converts the mirror to the sdk-go type. +func ListBudgetConfigurationsRequestToSDK(w *ListBudgetConfigurationsRequest) (*sdk.ListBudgetConfigurationsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListBudgetConfigurationsRequest{} + out.AccountId = w.AccountId + out.PageToken = w.PageToken + return out, nil +} + +// ListBudgetConfigurationsRequestFromSDK converts the sdk-go type to the mirror. +func ListBudgetConfigurationsRequestFromSDK(v *sdk.ListBudgetConfigurationsRequest) (*ListBudgetConfigurationsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListBudgetConfigurationsRequest{} + out.AccountId = v.AccountId + out.PageToken = v.PageToken + return out, nil +} + +// ListBudgetConfigurationsResponseToSDK converts the mirror to the sdk-go type. +func ListBudgetConfigurationsResponseToSDK(w *ListBudgetConfigurationsResponse) (*sdk.ListBudgetConfigurationsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListBudgetConfigurationsResponse{} + conv29, err := convertSlice(w.Budgets, BudgetConfigurationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListBudgetConfigurationsResponse.Budgets", err) + } + out.Budgets = conv29 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListBudgetConfigurationsResponseFromSDK converts the sdk-go type to the mirror. +func ListBudgetConfigurationsResponseFromSDK(v *sdk.ListBudgetConfigurationsResponse) (*ListBudgetConfigurationsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListBudgetConfigurationsResponse{} + conv30, err := convertSlice(v.Budgets, BudgetConfigurationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListBudgetConfigurationsResponse.Budgets", err) + } + out.Budgets = conv30 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// PrincipalOverrideToSDK converts the mirror to the sdk-go type. +func PrincipalOverrideToSDK(w *PrincipalOverride) (*sdk.PrincipalOverride, error) { + if w == nil { + return nil, nil + } + out := &sdk.PrincipalOverride{} + out.PrincipalId = w.PrincipalId + out.OverrideThreshold = w.OverrideThreshold + return out, nil +} + +// PrincipalOverrideFromSDK converts the sdk-go type to the mirror. +func PrincipalOverrideFromSDK(v *sdk.PrincipalOverride) (*PrincipalOverride, error) { + if v == nil { + return nil, nil + } + out := &PrincipalOverride{} + out.PrincipalId = v.PrincipalId + out.OverrideThreshold = v.OverrideThreshold + return out, nil +} + +// UpdateBudgetConfigurationBudgetToSDK converts the mirror to the sdk-go type. +func UpdateBudgetConfigurationBudgetToSDK(w *UpdateBudgetConfigurationBudget) (*sdk.UpdateBudgetConfigurationBudget, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateBudgetConfigurationBudget{} + out.BudgetConfigurationId = w.BudgetConfigurationId + out.AccountId = w.AccountId + conv31, err := convertSlice(w.AlertConfigurations, AlertConfigurationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBudgetConfigurationBudget.AlertConfigurations", err) + } + out.AlertConfigurations = conv31 + conv32, err := BudgetConfigurationFilterToSDK(w.Filter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBudgetConfigurationBudget.Filter", err) + } + out.Filter = conv32 + out.DisplayName = w.DisplayName + out.ResourceType = w.ResourceType + return out, nil +} + +// UpdateBudgetConfigurationBudgetFromSDK converts the sdk-go type to the mirror. +func UpdateBudgetConfigurationBudgetFromSDK(v *sdk.UpdateBudgetConfigurationBudget) (*UpdateBudgetConfigurationBudget, error) { + if v == nil { + return nil, nil + } + out := &UpdateBudgetConfigurationBudget{} + out.BudgetConfigurationId = v.BudgetConfigurationId + out.AccountId = v.AccountId + conv33, err := convertSlice(v.AlertConfigurations, AlertConfigurationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBudgetConfigurationBudget.AlertConfigurations", err) + } + out.AlertConfigurations = conv33 + conv34, err := BudgetConfigurationFilterFromSDK(v.Filter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBudgetConfigurationBudget.Filter", err) + } + out.Filter = conv34 + out.DisplayName = v.DisplayName + out.ResourceType = v.ResourceType + return out, nil +} + +// UpdateBudgetConfigurationRequestToSDK converts the mirror to the sdk-go type. +func UpdateBudgetConfigurationRequestToSDK(w *UpdateBudgetConfigurationRequest) (*sdk.UpdateBudgetConfigurationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateBudgetConfigurationRequest{} + out.BudgetId = w.BudgetId + conv35, err := UpdateBudgetConfigurationBudgetToSDK(w.Budget) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBudgetConfigurationRequest.Budget", err) + } + out.Budget = conv35 + return out, nil +} + +// UpdateBudgetConfigurationRequestFromSDK converts the sdk-go type to the mirror. +func UpdateBudgetConfigurationRequestFromSDK(v *sdk.UpdateBudgetConfigurationRequest) (*UpdateBudgetConfigurationRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateBudgetConfigurationRequest{} + out.BudgetId = v.BudgetId + conv36, err := UpdateBudgetConfigurationBudgetFromSDK(v.Budget) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBudgetConfigurationRequest.Budget", err) + } + out.Budget = conv36 + return out, nil +} + +// UpdateBudgetConfigurationResponseToSDK converts the mirror to the sdk-go type. +func UpdateBudgetConfigurationResponseToSDK(w *UpdateBudgetConfigurationResponse) (*sdk.UpdateBudgetConfigurationResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateBudgetConfigurationResponse{} + conv37, err := BudgetConfigurationToSDK(w.Budget) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBudgetConfigurationResponse.Budget", err) + } + out.Budget = conv37 + return out, nil +} + +// UpdateBudgetConfigurationResponseFromSDK converts the sdk-go type to the mirror. +func UpdateBudgetConfigurationResponseFromSDK(v *sdk.UpdateBudgetConfigurationResponse) (*UpdateBudgetConfigurationResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateBudgetConfigurationResponse{} + conv38, err := BudgetConfigurationFromSDK(v.Budget) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBudgetConfigurationResponse.Budget", err) + } + out.Budget = conv38 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/cleanrooms/v1/types.generated.go b/libs/sdktypes/cleanrooms/v1/types.generated.go new file mode 100644 index 00000000000..a7c1ac45214 --- /dev/null +++ b/libs/sdktypes/cleanrooms/v1/types.generated.go @@ -0,0 +1,2955 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/cleanrooms/v1. DO NOT EDIT. + +package cleanrooms + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/cleanrooms/v1" + + strings "strings" +) + +type ( + CleanRoomTaskRunLifeCycleState = sdk.CleanRoomTaskRunLifeCycleState + CleanRoomTaskRunResultState = sdk.CleanRoomTaskRunResultState + CleanRoomTaskType = sdk.CleanRoomTaskType + ColumnTypeName = sdk.ColumnTypeName + ComplianceStandard = sdk.ComplianceStandard + CleanRoom_AccessRestricted = sdk.CleanRoom_AccessRestricted + CleanRoom_Status_Enum = sdk.CleanRoom_Status_Enum + CleanRoomAsset_AssetType = sdk.CleanRoomAsset_AssetType + CleanRoomAsset_Status_Enum = sdk.CleanRoomAsset_Status_Enum + CleanRoomAutoApprovalRule_AuthorScope = sdk.CleanRoomAutoApprovalRule_AuthorScope + CleanRoomJarAnalysisReview_JarAnalysisReviewState = sdk.CleanRoomJarAnalysisReview_JarAnalysisReviewState + CleanRoomJarAnalysisReview_JarAnalysisReviewSubReason = sdk.CleanRoomJarAnalysisReview_JarAnalysisReviewSubReason + CleanRoomNotebookReview_NotebookReviewState = sdk.CleanRoomNotebookReview_NotebookReviewState + CleanRoomNotebookReview_NotebookReviewSubReason = sdk.CleanRoomNotebookReview_NotebookReviewSubReason + CleanRoomOutputCatalog_OutputCatalogStatus = sdk.CleanRoomOutputCatalog_OutputCatalogStatus + EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationFilteringProtocol = sdk.EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationFilteringProtocol + EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationType = sdk.EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationType + EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_LogOnlyModeType = sdk.EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_LogOnlyModeType + EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_WorkloadType = sdk.EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_WorkloadType + EgressNetworkPolicy_InternetAccessPolicy_RestrictionMode = sdk.EgressNetworkPolicy_InternetAccessPolicy_RestrictionMode + EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType = sdk.EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType + PartitionSpecification_Partition_PartitionValue_PartitionValueOp = sdk.PartitionSpecification_Partition_PartitionValue_PartitionValueOp +) + +const ( + CleanRoomTaskRunLifeCycleState_Unspecified = sdk.CleanRoomTaskRunLifeCycleState_Unspecified + CleanRoomTaskRunLifeCycleState_Pending = sdk.CleanRoomTaskRunLifeCycleState_Pending + CleanRoomTaskRunLifeCycleState_Running = sdk.CleanRoomTaskRunLifeCycleState_Running + CleanRoomTaskRunLifeCycleState_Terminating = sdk.CleanRoomTaskRunLifeCycleState_Terminating + CleanRoomTaskRunLifeCycleState_Terminated = sdk.CleanRoomTaskRunLifeCycleState_Terminated + CleanRoomTaskRunLifeCycleState_Skipped = sdk.CleanRoomTaskRunLifeCycleState_Skipped + CleanRoomTaskRunLifeCycleState_InternalError = sdk.CleanRoomTaskRunLifeCycleState_InternalError + CleanRoomTaskRunLifeCycleState_Blocked = sdk.CleanRoomTaskRunLifeCycleState_Blocked + CleanRoomTaskRunLifeCycleState_WaitingForRetry = sdk.CleanRoomTaskRunLifeCycleState_WaitingForRetry + CleanRoomTaskRunLifeCycleState_Queued = sdk.CleanRoomTaskRunLifeCycleState_Queued + CleanRoomTaskRunResultState_Unspecified = sdk.CleanRoomTaskRunResultState_Unspecified + CleanRoomTaskRunResultState_Success = sdk.CleanRoomTaskRunResultState_Success + CleanRoomTaskRunResultState_Failed = sdk.CleanRoomTaskRunResultState_Failed + CleanRoomTaskRunResultState_Timedout = sdk.CleanRoomTaskRunResultState_Timedout + CleanRoomTaskRunResultState_Canceled = sdk.CleanRoomTaskRunResultState_Canceled + CleanRoomTaskRunResultState_MaximumConcurrentRunsReached = sdk.CleanRoomTaskRunResultState_MaximumConcurrentRunsReached + CleanRoomTaskRunResultState_UpstreamCanceled = sdk.CleanRoomTaskRunResultState_UpstreamCanceled + CleanRoomTaskRunResultState_UpstreamFailed = sdk.CleanRoomTaskRunResultState_UpstreamFailed + CleanRoomTaskRunResultState_Excluded = sdk.CleanRoomTaskRunResultState_Excluded + CleanRoomTaskRunResultState_Evicted = sdk.CleanRoomTaskRunResultState_Evicted + CleanRoomTaskRunResultState_SuccessWithFailures = sdk.CleanRoomTaskRunResultState_SuccessWithFailures + CleanRoomTaskRunResultState_UpstreamEvicted = sdk.CleanRoomTaskRunResultState_UpstreamEvicted + CleanRoomTaskRunResultState_Disabled = sdk.CleanRoomTaskRunResultState_Disabled + CleanRoomTaskType_Unspecified = sdk.CleanRoomTaskType_Unspecified + CleanRoomTaskType_Notebook = sdk.CleanRoomTaskType_Notebook + CleanRoomTaskType_Jar = sdk.CleanRoomTaskType_Jar + ColumnTypeName_Unspecified = sdk.ColumnTypeName_Unspecified + ColumnTypeName_Boolean = sdk.ColumnTypeName_Boolean + ColumnTypeName_Byte = sdk.ColumnTypeName_Byte + ColumnTypeName_Short = sdk.ColumnTypeName_Short + ColumnTypeName_Int = sdk.ColumnTypeName_Int + ColumnTypeName_Long = sdk.ColumnTypeName_Long + ColumnTypeName_Float = sdk.ColumnTypeName_Float + ColumnTypeName_Double = sdk.ColumnTypeName_Double + ColumnTypeName_Date = sdk.ColumnTypeName_Date + ColumnTypeName_Timestamp = sdk.ColumnTypeName_Timestamp + ColumnTypeName_String = sdk.ColumnTypeName_String + ColumnTypeName_Binary = sdk.ColumnTypeName_Binary + ColumnTypeName_Decimal = sdk.ColumnTypeName_Decimal + ColumnTypeName_Interval = sdk.ColumnTypeName_Interval + ColumnTypeName_Array = sdk.ColumnTypeName_Array + ColumnTypeName_Struct = sdk.ColumnTypeName_Struct + ColumnTypeName_Map = sdk.ColumnTypeName_Map + ColumnTypeName_Char = sdk.ColumnTypeName_Char + ColumnTypeName_Null = sdk.ColumnTypeName_Null + ColumnTypeName_UserDefinedType = sdk.ColumnTypeName_UserDefinedType + ColumnTypeName_TimestampNtz = sdk.ColumnTypeName_TimestampNtz + ColumnTypeName_Variant = sdk.ColumnTypeName_Variant + ColumnTypeName_Geometry = sdk.ColumnTypeName_Geometry + ColumnTypeName_Geography = sdk.ColumnTypeName_Geography + ColumnTypeName_TableType = sdk.ColumnTypeName_TableType + ComplianceStandard_Unspecified = sdk.ComplianceStandard_Unspecified + ComplianceStandard_None = sdk.ComplianceStandard_None + ComplianceStandard_Hipaa = sdk.ComplianceStandard_Hipaa + ComplianceStandard_PciDss = sdk.ComplianceStandard_PciDss + ComplianceStandard_FedrampModerate = sdk.ComplianceStandard_FedrampModerate + ComplianceStandard_IrapProtected = sdk.ComplianceStandard_IrapProtected + ComplianceStandard_FedrampHigh = sdk.ComplianceStandard_FedrampHigh + ComplianceStandard_FedrampIl5 = sdk.ComplianceStandard_FedrampIl5 + ComplianceStandard_ItarEar = sdk.ComplianceStandard_ItarEar + ComplianceStandard_CyberEssentialPlus = sdk.ComplianceStandard_CyberEssentialPlus + ComplianceStandard_CanadaProtectedB = sdk.ComplianceStandard_CanadaProtectedB + ComplianceStandard_Ismap = sdk.ComplianceStandard_Ismap + ComplianceStandard_Hitrust = sdk.ComplianceStandard_Hitrust + ComplianceStandard_KFsi = sdk.ComplianceStandard_KFsi + ComplianceStandard_GermanyC5 = sdk.ComplianceStandard_GermanyC5 + ComplianceStandard_GermanyTisax = sdk.ComplianceStandard_GermanyTisax + ComplianceStandard_KsaEccCccDcc = sdk.ComplianceStandard_KsaEccCccDcc + CleanRoom_AccessRestricted_Unspecified = sdk.CleanRoom_AccessRestricted_Unspecified + CleanRoom_AccessRestricted_CspMismatch = sdk.CleanRoom_AccessRestricted_CspMismatch + CleanRoom_Status_Enum_Unspecified = sdk.CleanRoom_Status_Enum_Unspecified + CleanRoom_Status_Enum_Active = sdk.CleanRoom_Status_Enum_Active + CleanRoom_Status_Enum_Provisioning = sdk.CleanRoom_Status_Enum_Provisioning + CleanRoom_Status_Enum_Deleted = sdk.CleanRoom_Status_Enum_Deleted + CleanRoom_Status_Enum_Failed = sdk.CleanRoom_Status_Enum_Failed + CleanRoomAsset_AssetType_Unspecified = sdk.CleanRoomAsset_AssetType_Unspecified + CleanRoomAsset_AssetType_Table = sdk.CleanRoomAsset_AssetType_Table + CleanRoomAsset_AssetType_NotebookFile = sdk.CleanRoomAsset_AssetType_NotebookFile + CleanRoomAsset_AssetType_Volume = sdk.CleanRoomAsset_AssetType_Volume + CleanRoomAsset_AssetType_View = sdk.CleanRoomAsset_AssetType_View + CleanRoomAsset_AssetType_ForeignTable = sdk.CleanRoomAsset_AssetType_ForeignTable + CleanRoomAsset_AssetType_JarAnalysis = sdk.CleanRoomAsset_AssetType_JarAnalysis + CleanRoomAsset_Status_Enum_Unspecified = sdk.CleanRoomAsset_Status_Enum_Unspecified + CleanRoomAsset_Status_Enum_Active = sdk.CleanRoomAsset_Status_Enum_Active + CleanRoomAsset_Status_Enum_PermissionDenied = sdk.CleanRoomAsset_Status_Enum_PermissionDenied + CleanRoomAsset_Status_Enum_Pending = sdk.CleanRoomAsset_Status_Enum_Pending + CleanRoomAutoApprovalRule_AuthorScope_Unspecified = sdk.CleanRoomAutoApprovalRule_AuthorScope_Unspecified + CleanRoomAutoApprovalRule_AuthorScope_AnyAuthor = sdk.CleanRoomAutoApprovalRule_AuthorScope_AnyAuthor + CleanRoomJarAnalysisReview_JarAnalysisReviewState_Unspecified = sdk.CleanRoomJarAnalysisReview_JarAnalysisReviewState_Unspecified + CleanRoomJarAnalysisReview_JarAnalysisReviewState_Approved = sdk.CleanRoomJarAnalysisReview_JarAnalysisReviewState_Approved + CleanRoomJarAnalysisReview_JarAnalysisReviewState_Rejected = sdk.CleanRoomJarAnalysisReview_JarAnalysisReviewState_Rejected + CleanRoomJarAnalysisReview_JarAnalysisReviewState_Pending = sdk.CleanRoomJarAnalysisReview_JarAnalysisReviewState_Pending + CleanRoomJarAnalysisReview_JarAnalysisReviewSubReason_Unspecified = sdk.CleanRoomJarAnalysisReview_JarAnalysisReviewSubReason_Unspecified + CleanRoomJarAnalysisReview_JarAnalysisReviewSubReason_AutoApproved = sdk.CleanRoomJarAnalysisReview_JarAnalysisReviewSubReason_AutoApproved + CleanRoomNotebookReview_NotebookReviewState_Unspecified = sdk.CleanRoomNotebookReview_NotebookReviewState_Unspecified + CleanRoomNotebookReview_NotebookReviewState_Approved = sdk.CleanRoomNotebookReview_NotebookReviewState_Approved + CleanRoomNotebookReview_NotebookReviewState_Rejected = sdk.CleanRoomNotebookReview_NotebookReviewState_Rejected + CleanRoomNotebookReview_NotebookReviewState_Pending = sdk.CleanRoomNotebookReview_NotebookReviewState_Pending + CleanRoomNotebookReview_NotebookReviewSubReason_Unspecified = sdk.CleanRoomNotebookReview_NotebookReviewSubReason_Unspecified + CleanRoomNotebookReview_NotebookReviewSubReason_Backfilled = sdk.CleanRoomNotebookReview_NotebookReviewSubReason_Backfilled + CleanRoomNotebookReview_NotebookReviewSubReason_AutoApproved = sdk.CleanRoomNotebookReview_NotebookReviewSubReason_AutoApproved + CleanRoomOutputCatalog_OutputCatalogStatus_Unspecified = sdk.CleanRoomOutputCatalog_OutputCatalogStatus_Unspecified + CleanRoomOutputCatalog_OutputCatalogStatus_NotEligible = sdk.CleanRoomOutputCatalog_OutputCatalogStatus_NotEligible + CleanRoomOutputCatalog_OutputCatalogStatus_NotCreated = sdk.CleanRoomOutputCatalog_OutputCatalogStatus_NotCreated + CleanRoomOutputCatalog_OutputCatalogStatus_Created = sdk.CleanRoomOutputCatalog_OutputCatalogStatus_Created + EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationFilteringProtocol_Unspecified = sdk.EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationFilteringProtocol_Unspecified + EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationFilteringProtocol_Tcp = sdk.EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationFilteringProtocol_Tcp + EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationType_Unspecified = sdk.EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationType_Unspecified + EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationType_Fqdn = sdk.EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationType_Fqdn + EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_LogOnlyModeType_Unspecified = sdk.EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_LogOnlyModeType_Unspecified + EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_LogOnlyModeType_AllServices = sdk.EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_LogOnlyModeType_AllServices + EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_LogOnlyModeType_SelectedServices = sdk.EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_LogOnlyModeType_SelectedServices + EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_WorkloadType_Unspecified = sdk.EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_WorkloadType_Unspecified + EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_WorkloadType_Dbsql = sdk.EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_WorkloadType_Dbsql + EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_WorkloadType_MlServing = sdk.EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_WorkloadType_MlServing + EgressNetworkPolicy_InternetAccessPolicy_RestrictionMode_Unspecified = sdk.EgressNetworkPolicy_InternetAccessPolicy_RestrictionMode_Unspecified + EgressNetworkPolicy_InternetAccessPolicy_RestrictionMode_FullAccess = sdk.EgressNetworkPolicy_InternetAccessPolicy_RestrictionMode_FullAccess + EgressNetworkPolicy_InternetAccessPolicy_RestrictionMode_PrivateAccessOnly = sdk.EgressNetworkPolicy_InternetAccessPolicy_RestrictionMode_PrivateAccessOnly + EgressNetworkPolicy_InternetAccessPolicy_RestrictionMode_RestrictedAccess = sdk.EgressNetworkPolicy_InternetAccessPolicy_RestrictionMode_RestrictedAccess + EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType_Unspecified = sdk.EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType_Unspecified + EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType_AwsS3 = sdk.EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType_AwsS3 + EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType_CloudflareR2 = sdk.EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType_CloudflareR2 + EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType_AzureStorage = sdk.EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType_AzureStorage + EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType_GoogleCloudStorage = sdk.EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType_GoogleCloudStorage + PartitionSpecification_Partition_PartitionValue_PartitionValueOp_Unspecified = sdk.PartitionSpecification_Partition_PartitionValue_PartitionValueOp_Unspecified + PartitionSpecification_Partition_PartitionValue_PartitionValueOp_Like = sdk.PartitionSpecification_Partition_PartitionValue_PartitionValueOp_Like +) + +type CleanRoom struct { + // Whether clean room access is restricted due to [CSP] + // + // [CSP]: https://docs.databricks.com/en/security/privacy/security-profile.html + AccessRestricted CleanRoom_AccessRestricted `json:"access_restricted,omitempty"` + Comment *string `json:"comment,omitempty"` + // When the clean room was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Whether allow task to write to shared output schema. When enabled, clean room + // task runs triggered by the current collaborator can write to the run-scoped + // shared output schema which is accessible by all collaborators. + EnableSharedOutput *bool `json:"enable_shared_output,omitempty"` + // The alias of the collaborator tied to the local clean room. + LocalCollaboratorAlias *string `json:"local_collaborator_alias,omitempty"` + // The name of the clean room. It should follow [UC securable naming + // requirements]. + // + // [UC securable naming requirements]: https://docs.databricks.com/en/data-governance/unity-catalog/index.html#securable-object-naming-requirements + Name *string `json:"name,omitempty"` + // Output catalog of the clean room. It is an output only field. Output catalog + // is manipulated using the separate CreateCleanRoomOutputCatalog API. + OutputCatalog *CleanRoomOutputCatalog `json:"output_catalog,omitempty"` + // This is the username of the owner of the local clean room + // securable for permission management. + Owner *string `json:"owner,omitempty"` + // Central clean room details. During creation, users need to specify + // cloud_vendor, region, and collaborators.global_metastore_id. This field will + // not be filled in the ListCleanRooms call. + RemoteDetailedInfo *CleanRoomRemoteDetail `json:"remote_detailed_info,omitempty"` + // Clean room status. + Status CleanRoom_Status_Enum `json:"status,omitempty"` + // When the clean room was last updated, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` +} + +// Metadata of the clean room asset. +type CleanRoomAsset struct { + // When the asset is added to the clean room, in epoch milliseconds. + AddedAt *int64 `json:"added_at,omitempty"` + // The type of the asset. + AssetType CleanRoomAsset_AssetType `json:"asset_type,omitempty"` + // The name of the clean room this asset belongs to. This field is required for + // create operations and populated by the server for responses. + CleanRoomName *string `json:"clean_room_name,omitempty"` + ForeignTable *CleanRoomAsset_ForeignTable `json:"foreign_table,omitempty"` + ForeignTableLocalDetails *CleanRoomAsset_ForeignTableLocalDetails `json:"foreign_table_local_details,omitempty"` + JarAnalysis *CleanRoomAsset_JarAnalysis `json:"jar_analysis,omitempty"` + // A fully qualified name that uniquely identifies the asset within the clean + // room. This is also the name displayed in the clean room UI. + // + // For UC securable assets (tables, volumes, etc.), the format is + // *shared_catalog*.*shared_schema*.*asset_name* + // + // For notebooks, the name is the notebook file name. For jar analyses, the name + // is the jar analysis name. For Genie spaces, the name is derived from the + // clean room; the caller does not choose it. + Name *string `json:"name,omitempty"` + Notebook *CleanRoomAsset_Notebook `json:"notebook,omitempty"` + // The alias of the collaborator who owns this asset + OwnerCollaboratorAlias *string `json:"owner_collaborator_alias,omitempty"` + // Status of the asset + Status CleanRoomAsset_Status_Enum `json:"status,omitempty"` + Table *CleanRoomAsset_Table `json:"table,omitempty"` + TableLocalDetails *CleanRoomAsset_TableLocalDetails `json:"table_local_details,omitempty"` + View *CleanRoomAsset_View `json:"view,omitempty"` + ViewLocalDetails *CleanRoomAsset_ViewLocalDetails `json:"view_local_details,omitempty"` + VolumeLocalDetails *CleanRoomAsset_VolumeLocalDetails `json:"volume_local_details,omitempty"` +} + +type CleanRoomAsset_ForeignTable struct { + // The metadata information of the columns in the foreign table + Columns []ColumnInfo `json:"columns,omitempty"` +} + +type CleanRoomAsset_ForeignTableLocalDetails struct { + // The fully qualified name of the foreign table in its owner's local metastore, + // in the format of *catalog*.*schema*.*foreign_table_name* + LocalName *string `json:"local_name,omitempty"` +} + +type CleanRoomAsset_JarAnalysis struct { + // The full paths in central to the jar files that are added to the library + // during execution (e.g. /Volumes/creator/schema/volume/folder/my_jar_file.jar) + // Only returned for the owner collaborator. + CentralJarFilePaths []string `json:"central_jar_file_paths,omitempty"` + // Optional description of the jar analysis shown to all collaborators. + Description *string `json:"description,omitempty"` + // The serverless environment version used to execute the JAR analysis (e.g. + // "4"). If not specified, uses the service-configured JAR analysis default. + EnvironmentVersion *string `json:"environment_version,omitempty"` + // Server generated etag that represents the jar analysis version. + Etag *string `json:"etag,omitempty"` + // The full name of the class containing the main method to be executed. This + // class must be contained in a JAR provided as a library The code must use + // `SparkContext.getOrCreate` to obtain a Spark context; otherwise, runs of the + // job fail + MainClassName *string `json:"main_class_name,omitempty"` + // Top-level status derived from all reviews. + ReviewState CleanRoomJarAnalysisReview_JarAnalysisReviewState `json:"review_state,omitempty"` + // All existing approvals or rejections. + Reviews []CleanRoomJarAnalysisReview `json:"reviews,omitempty"` + // Collaborators that can run the jar. + RunnerCollaboratorAliases []string `json:"runner_collaborator_aliases,omitempty"` +} + +type CleanRoomAsset_Notebook struct { + // Optional description of the notebook shown to all collaborators. + Description *string `json:"description,omitempty"` + // The serverless environment version used to execute the notebook (e.g. "4"). + // Defaults to "2" if not specified. + EnvironmentVersion *string `json:"environment_version,omitempty"` + // Server generated etag that represents the notebook version. + Etag *string `json:"etag,omitempty"` + // Base 64 representation of the notebook contents. This is the same format as + // returned by [workspace/export] with the format of **HTML**. + // + // [workspace/export]: https://docs.databricks.com/api/workspace/workspace/export + NotebookContent *string `json:"notebook_content,omitempty"` + // Top-level status derived from all reviews + ReviewState CleanRoomNotebookReview_NotebookReviewState `json:"review_state,omitempty"` + // All existing approvals or rejections + Reviews []CleanRoomNotebookReview `json:"reviews,omitempty"` + // Aliases of collaborators that can run the notebook. + RunnerCollaboratorAliases []string `json:"runner_collaborator_aliases,omitempty"` +} + +type CleanRoomAsset_Table struct { + // The metadata information of the columns in the table + Columns []ColumnInfo `json:"columns,omitempty"` +} + +type CleanRoomAsset_TableLocalDetails struct { + // The fully qualified name of the table in its owner's local metastore, in the + // format of *catalog*.*schema*.*table_name* + LocalName *string `json:"local_name,omitempty"` + // Partition filtering specification for a shared table. + Partitions []PartitionSpecification_Partition `json:"partitions,omitempty"` +} + +type CleanRoomAsset_View struct { + // The metadata information of the columns in the view + Columns []ColumnInfo `json:"columns,omitempty"` +} + +type CleanRoomAsset_ViewLocalDetails struct { + // The fully qualified name of the view in its owner's local metastore, in the + // format of *catalog*.*schema*.*view_name* + LocalName *string `json:"local_name,omitempty"` +} + +type CleanRoomAsset_VolumeLocalDetails struct { + // The fully qualified name of the volume in its owner's local metastore, in the + // format of *catalog*.*schema*.*volume_name* + LocalName *string `json:"local_name,omitempty"` +} + +type CleanRoomAutoApprovalRule struct { + AuthorCollaboratorAlias *string `json:"author_collaborator_alias,omitempty"` + AuthorScope CleanRoomAutoApprovalRule_AuthorScope `json:"author_scope,omitempty"` + // The name of the clean room this auto-approval rule belongs to. + CleanRoomName *string `json:"clean_room_name,omitempty"` + // Timestamp of when the rule was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // A generated UUID identifying the rule. + RuleId *string `json:"rule_id,omitempty"` + // The owner of the rule to whom the rule applies. + RuleOwnerCollaboratorAlias *string `json:"rule_owner_collaborator_alias,omitempty"` + RunnerCollaboratorAlias *string `json:"runner_collaborator_alias,omitempty"` +} + +// Publicly visible clean room collaborator.. +type CleanRoomCollaborator struct { + // Collaborator alias specified by the clean room creator. It is unique across + // all collaborators of this clean room, and used to derive multiple values + // internally such as catalog alias and clean room name for single metastore + // clean rooms. It should follow [UC securable naming requirements]. + // + // [UC securable naming requirements]: https://docs.databricks.com/en/data-governance/unity-catalog/index.html#securable-object-naming-requirements + CollaboratorAlias *string `json:"collaborator_alias,omitempty"` + // Generated display name for the collaborator. In the case of a single + // metastore clean room, it is the clean room name. For x-metastore clean rooms, + // it is the organization name of the metastore. It is not restricted to these + // values and could change in the future + DisplayName *string `json:"display_name,omitempty"` + // The global Unity Catalog metastore ID of the collaborator. The identifier is + // of format cloud:region:metastore-uuid. + GlobalMetastoreId *string `json:"global_metastore_id,omitempty"` + // Email of the user who is receiving the clean room "invitation". It should be + // empty for the creator of the clean room, and non-empty for the invitees of + // the clean room. It is only returned in the output when clean room creator + // calls GET + InviteRecipientEmail *string `json:"invite_recipient_email,omitempty"` + // Workspace ID of the user who is receiving the clean room "invitation". Must + // be specified if invite_recipient_email is specified. It should be empty when + // the collaborator is the creator of the clean room. + InviteRecipientWorkspaceId *int64 `json:"invite_recipient_workspace_id,omitempty"` + // [Organization + // name](:method:metastores/list#metastores-delta_sharing_organization_name) + // configured in the metastore + OrganizationName *string `json:"organization_name,omitempty"` +} + +// This only applies to a JAR Analysis as a first-class asset in the Clean Room, +// and not to Volumes. +type CleanRoomJarAnalysisReview struct { + // review comment + Comment *string `json:"comment,omitempty"` + // timestamp of when the review was submitted + CreatedAtMillis *int64 `json:"created_at_millis,omitempty"` + // review outcome + ReviewState CleanRoomJarAnalysisReview_JarAnalysisReviewState `json:"review_state,omitempty"` + // specified when the review was not explicitly made by a user + ReviewSubReason CleanRoomJarAnalysisReview_JarAnalysisReviewSubReason `json:"review_sub_reason,omitempty"` + // collaborator alias of the reviewer + ReviewerCollaboratorAlias *string `json:"reviewer_collaborator_alias,omitempty"` +} + +type CleanRoomNotebookReview struct { + // Review comment + Comment *string `json:"comment,omitempty"` + // When the review was submitted, in epoch milliseconds + CreatedAtMillis *int64 `json:"created_at_millis,omitempty"` + // Review outcome + ReviewState CleanRoomNotebookReview_NotebookReviewState `json:"review_state,omitempty"` + // Specified when the review was not explicitly made by a user + ReviewSubReason CleanRoomNotebookReview_NotebookReviewSubReason `json:"review_sub_reason,omitempty"` + // Collaborator alias of the reviewer + ReviewerCollaboratorAlias *string `json:"reviewer_collaborator_alias,omitempty"` +} + +// Stores information about a single task run.. +type CleanRoomNotebookTaskRun struct { + // Job run info of the task in the runner's local workspace. This field is only + // included in the LIST API. if the task was run within the same workspace the + // API is being called. If the task run was in a different workspace under the + // same metastore, only the workspace_id is included. + CollaboratorJobRunInfo *CollaboratorJobRunInfo `json:"collaborator_job_run_info,omitempty"` + // Etag of the notebook executed in this task run, used to identify the notebook + // version. + NotebookEtag *string `json:"notebook_etag,omitempty"` + // State of the task run. + NotebookJobRunState *CleanRoomTaskRunState `json:"notebook_job_run_state,omitempty"` + // Asset name of the notebook executed in this task run. + NotebookName *string `json:"notebook_name,omitempty"` + // The timestamp of when the notebook was last updated. + NotebookUpdatedAt *int64 `json:"notebook_updated_at,omitempty"` + // Expiration time of the output schema of the task run (if any), in epoch + // milliseconds. + OutputSchemaExpirationTime *int64 `json:"output_schema_expiration_time,omitempty"` + // Name of the output schema associated with the clean rooms notebook task run. + OutputSchemaName *string `json:"output_schema_name,omitempty"` + // Duration of the task run, in milliseconds. + RunDuration *int64 `json:"run_duration,omitempty"` + // Expiration time of the shared output schema of the task run (if any), in + // epoch milliseconds. + SharedOutputSchemaExpirationTime *int64 `json:"shared_output_schema_expiration_time,omitempty"` + // Name of the shared output schema associated with the clean rooms notebook + // task run. This schema is accessible by all collaborators when + // enable_shared_output is true. + SharedOutputSchemaName *string `json:"shared_output_schema_name,omitempty"` + // When the task run started, in epoch milliseconds. + StartTime *int64 `json:"start_time,omitempty"` +} + +type CleanRoomOutputCatalog struct { + // The name of the output catalog in UC. It should follow [UC securable naming + // requirements]. The field will always exist if status is CREATED. + // + // [UC securable naming requirements]: https://docs.databricks.com/en/data-governance/unity-catalog/index.html#securable-object-naming-requirements + CatalogName *string `json:"catalog_name,omitempty"` + Status CleanRoomOutputCatalog_OutputCatalogStatus `json:"status,omitempty"` +} + +// Publicly visible central clean room details.. +type CleanRoomRemoteDetail struct { + // Central clean room ID. + CentralCleanRoomId *string `json:"central_clean_room_id,omitempty"` + // Cloud vendor (aws,azure,gcp) of the central clean room. + CloudVendor *string `json:"cloud_vendor,omitempty"` + // Collaborators in the central clean room. There should one and only one + // collaborator in the list that satisfies the owner condition: + // + // 1. It has the creator's global_metastore_id (determined by caller of + // CreateCleanRoom). + // + // 2. Its invite_recipient_email is empty. + Collaborators []CleanRoomCollaborator `json:"collaborators,omitempty"` + ComplianceSecurityProfile *ComplianceSecurityProfile `json:"compliance_security_profile,omitempty"` + // Collaborator who creates the clean room. + Creator *CleanRoomCollaborator `json:"creator,omitempty"` + // Egress network policy to apply to the central clean room workspace. + EgressNetworkPolicy *EgressNetworkPolicy `json:"egress_network_policy,omitempty"` + // Whether to enable shared output for the central clean room. When enabled, + // clean room task runs can write to the run-scoped shared output schema which + // is accessible by all collaborators. + EnableSharedOutput *bool `json:"enable_shared_output,omitempty"` + // Alias of the provider collaborator. If set, packaged clean rooms mode is + // enabled. The consumer's experience is restricted: they can view notebook + // names and READMEs, add their own data assets, and trigger runs, but cannot + // view notebook code, provider data assets, or notebook run output. + PackageProviderCollaboratorAlias *string `json:"package_provider_collaborator_alias,omitempty"` + // Region of the central clean room. + Region *string `json:"region,omitempty"` +} + +// Stores information about a single task run.. +type CleanRoomTaskRun struct { + // Information about the analysis run (etag, updated at) + AnalysisDetails *CleanRoomTaskRun_CleanRoomTaskAnalysisDetails `json:"analysis_details,omitempty"` + // Job run info of the task in the runner's local workspace. This field is only + // included in the LIST API if the task was run within the same workspace the + // API is being called. If the task run was in a different workspace under the + // same metastore, only the workspace_id is included. + CollaboratorJobRunInfo *CollaboratorJobRunInfo `json:"collaborator_job_run_info,omitempty"` + // Name of the executable. + Name *string `json:"name,omitempty"` + // Information about run output + OutputInfo *CleanRoomTaskRun_OutputInfo `json:"output_info,omitempty"` + // Duration of the task run, in milliseconds. + RunDuration *int64 `json:"run_duration,omitempty"` + // Information about shared output accessible by all collaborators. This field + // is only populated when enable_shared_output is true. + SharedOutputInfo *CleanRoomTaskRun_OutputInfo `json:"shared_output_info,omitempty"` + // When the task run started, in epoch milliseconds. + StartTime *int64 `json:"start_time,omitempty"` + // State of the task run. + TaskRunState *CleanRoomTaskRunState `json:"task_run_state,omitempty"` + // The type of Clean Room task. + TaskType CleanRoomTaskType `json:"task_type,omitempty"` +} + +type CleanRoomTaskRun_CleanRoomTaskAnalysisDetails struct { + // Etag of the asset executed in this task run, used to identify the asset + // version. + Etag *string `json:"etag,omitempty"` + // The timestamp of when the asset was last updated. + UpdatedAt *int64 `json:"updated_at,omitempty"` +} + +type CleanRoomTaskRun_OutputInfo struct { + // Expiration time of the output schema of the task run (if any), in epoch + // milliseconds. + OutputSchemaExpirationTime *int64 `json:"output_schema_expiration_time,omitempty"` + // Name of the output schema associated with the clean room task run. + OutputSchemaName *string `json:"output_schema_name,omitempty"` +} + +// Stores the run state of the clean rooms notebook task.. +type CleanRoomTaskRunState struct { + // A value indicating the run's current lifecycle state. This field is always + // available in the response. Note: Additional states might be introduced in + // future releases. + LifeCycleState CleanRoomTaskRunLifeCycleState `json:"life_cycle_state,omitempty"` + // A value indicating the run's result. This field is only available for + // terminal lifecycle states. Note: Additional states might be introduced in + // future releases. + ResultState CleanRoomTaskRunResultState `json:"result_state,omitempty"` +} + +type CollaboratorJobRunInfo struct { + // Alias of the collaborator that triggered the task run. + CollaboratorAlias *string `json:"collaborator_alias,omitempty"` + // Job ID of the task run in the collaborator's workspace. + CollaboratorJobId *int64 `json:"collaborator_job_id,omitempty"` + // Job run ID of the task run in the collaborator's workspace. + CollaboratorJobRunId *int64 `json:"collaborator_job_run_id,omitempty"` + // Task run ID of the task run in the collaborator's workspace. + CollaboratorTaskRunId *int64 `json:"collaborator_task_run_id,omitempty"` + // ID of the collaborator's workspace that triggered the task run. + CollaboratorWorkspaceId *int64 `json:"collaborator_workspace_id,omitempty"` +} + +type ColumnInfo struct { + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + Mask *ColumnMask `json:"mask,omitempty"` + // Name of Column. + Name *string `json:"name,omitempty"` + // Whether field may be Null (default: true). + Nullable *bool `json:"nullable,omitempty"` + // Partition index for column. + PartitionIndex *int `json:"partition_index,omitempty"` + // Ordinal position of column (starting at position 0). + Position *int `json:"position,omitempty"` + // Format of IntervalType. + TypeIntervalType *string `json:"type_interval_type,omitempty"` + // Full data type specification, JSON-serialized. + TypeJson *string `json:"type_json,omitempty"` + TypeName ColumnTypeName `json:"type_name,omitempty"` + // Digits of precision; required for DecimalTypes. + TypePrecision *int `json:"type_precision,omitempty"` + // Digits to right of decimal; Required for DecimalTypes. + TypeScale *int `json:"type_scale,omitempty"` + // Full data type specification as SQL/catalogString text. + TypeText *string `json:"type_text,omitempty"` +} + +type ColumnMask struct { + // The full name of the column mask SQL UDF. + FunctionName *string `json:"function_name,omitempty"` + // The list of table columns or literals to be passed as additional arguments to + // a column mask function, carrying the type (column reference vs constant + // literal) of each argument. Deprecated: use using_column_names instead. + UsingArguments []PolicyFunctionArgument `json:"using_arguments,omitempty"` + // The list of additional table columns to be passed as input to the column mask + // function. The first arg of the mask function should be of the type of the + // column being masked and the types of the rest of the args should match the + // types of columns in 'using_column_names'. + UsingColumnNames []string `json:"using_column_names,omitempty"` +} + +// The compliance security profile used to process regulated data following +// compliance standards.. +type ComplianceSecurityProfile struct { + // The list of compliance standards that the compliance security profile is + // configured to enforce. + ComplianceStandards []ComplianceStandard `json:"compliance_standards,omitempty"` + // Whether the compliance security profile is enabled. + IsEnabled *bool `json:"is_enabled,omitempty"` +} + +type CreateCleanRoomAssetRequest struct { + Asset *CleanRoomAsset `json:"asset,omitempty"` +} + +type CreateCleanRoomAssetReviewRequest struct { + // Asset type. Can either be NOTEBOOK_FILE or JAR_ANALYSIS. + AssetType CleanRoomAsset_AssetType `json:"asset_type,omitempty"` + // Name of the clean room + CleanRoomName *string `json:"clean_room_name,omitempty"` + JarAnalysisReview *JarAnalysisVersionReview `json:"jar_analysis_review,omitempty"` + // Name of the asset + Name *string `json:"name,omitempty"` + NotebookReview *NotebookVersionReview `json:"notebook_review,omitempty"` +} + +type CreateCleanRoomAssetReviewResponse struct { + JarAnalysisReviewState CleanRoomJarAnalysisReview_JarAnalysisReviewState `json:"jar_analysis_review_state,omitempty"` + // All existing jar analysis approvals or rejections + JarAnalysisReviews []CleanRoomJarAnalysisReview `json:"jar_analysis_reviews,omitempty"` + NotebookReviewState CleanRoomNotebookReview_NotebookReviewState `json:"notebook_review_state,omitempty"` + // All existing notebook approvals or rejections + NotebookReviews []CleanRoomNotebookReview `json:"notebook_reviews,omitempty"` +} + +type CreateCleanRoomAutoApprovalRuleRequest struct { + AutoApprovalRule *CleanRoomAutoApprovalRule `json:"auto_approval_rule,omitempty"` +} + +type CreateCleanRoomOutputCatalogRequest struct { + // Name of the clean room. + CleanRoomName *string `json:"clean_room_name,omitempty"` + OutputCatalog *CleanRoomOutputCatalog `json:"output_catalog,omitempty"` +} + +type CreateCleanRoomOutputCatalogResponse struct { + OutputCatalog *CleanRoomOutputCatalog `json:"output_catalog,omitempty"` +} + +type CreateCleanRoomRequest struct { + CleanRoom *CleanRoom `json:"clean_room,omitempty"` +} + +// The network policies applying for egress traffic. This message is used by the +// UI/REST API. We translate this message to the format expected by the +// dataplane in Lakehouse Network Manager (for the format expected by the +// dataplane, see networkconfig.textproto).. +type EgressNetworkPolicy struct { + // The access policy enforced for egress traffic to the internet. + InternetAccess *EgressNetworkPolicy_InternetAccessPolicy `json:"internet_access,omitempty"` +} + +type EgressNetworkPolicy_InternetAccessPolicy struct { + AllowedInternetDestinations []EgressNetworkPolicy_InternetAccessPolicy_InternetDestination `json:"allowed_internet_destinations,omitempty"` + AllowedStorageDestinations []EgressNetworkPolicy_InternetAccessPolicy_StorageDestination `json:"allowed_storage_destinations,omitempty"` + // Optional. If not specified, assume the policy is enforced for all workloads. + LogOnlyMode *EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode `json:"log_only_mode,omitempty"` + RestrictionMode EgressNetworkPolicy_InternetAccessPolicy_RestrictionMode `json:"restriction_mode,omitempty"` +} + +// Users can specify accessible internet destinations when outbound access is +// restricted. We only support domain name (FQDN) destinations for the time +// being, though going forwards we want to support host names and IP addresses.. +type EgressNetworkPolicy_InternetAccessPolicy_InternetDestination struct { + Destination *string `json:"destination,omitempty"` + Protocol EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationFilteringProtocol `json:"protocol,omitempty"` + Type EgressNetworkPolicy_InternetAccessPolicy_InternetDestination_InternetDestinationType `json:"type,omitempty"` +} + +type EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode struct { + LogOnlyModeType EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_LogOnlyModeType `json:"log_only_mode_type,omitempty"` + Workloads []EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode_WorkloadType `json:"workloads,omitempty"` +} + +// Users can specify accessible storage destinations.. +type EgressNetworkPolicy_InternetAccessPolicy_StorageDestination struct { + AllowedPaths []string `json:"allowed_paths,omitempty"` + AzureContainer *string `json:"azure_container,omitempty"` + AzureDnsZone *string `json:"azure_dns_zone,omitempty"` + AzureStorageAccount *string `json:"azure_storage_account,omitempty"` + AzureStorageService *string `json:"azure_storage_service,omitempty"` + BucketName *string `json:"bucket_name,omitempty"` + Region *string `json:"region,omitempty"` + Type EgressNetworkPolicy_InternetAccessPolicy_StorageDestination_StorageDestinationType `json:"type,omitempty"` +} + +type JarAnalysisVersionReview struct { + // Review comment + Comment *string `json:"comment,omitempty"` + // Etag identifying the jar analysis version, with its value being a hash of an + // internally-generated UUID + Etag *string `json:"etag,omitempty"` + // Review outcome + ReviewState CleanRoomJarAnalysisReview_JarAnalysisReviewState `json:"review_state,omitempty"` +} + +type ListCleanRoomAssetRevisionsRequest struct { + // Asset type. Only NOTEBOOK_FILE is supported. + AssetType CleanRoomAsset_AssetType `json:"asset_type,omitempty"` + // Name of the clean room. + CleanRoomName *string `json:"clean_room_name,omitempty"` + // Name of the asset. + Name *string `json:"name,omitempty"` + // Maximum number of asset revisions to return. Defaults to 10. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token to go to next page based on the previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListCleanRoomAssetRevisionsResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + Revisions []CleanRoomAsset `json:"revisions,omitempty"` +} + +type ListCleanRoomAssetsRequest struct { + // Name of the clean room. + CleanRoomName *string `json:"clean_room_name,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListCleanRoomAssetsResponse struct { + // Assets in the clean room. + Assets []CleanRoomAsset `json:"assets,omitempty"` + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. page_token should be set to this value for the next request (for + // the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListCleanRoomAutoApprovalRulesRequest struct { + CleanRoomName *string `json:"clean_room_name,omitempty"` + // Maximum number of auto-approval rules to return. Defaults to 100. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListCleanRoomAutoApprovalRulesResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. page_token should be set to this value for the next request (for + // the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + Rules []CleanRoomAutoApprovalRule `json:"rules,omitempty"` +} + +type ListCleanRoomNotebookTaskRunsRequest struct { + // Name of the clean room. + CleanRoomName *string `json:"clean_room_name,omitempty"` + // Notebook name + NotebookName *string `json:"notebook_name,omitempty"` + // The maximum number of task runs to return. Currently ignored - all runs will + // be returned. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListCleanRoomNotebookTaskRunsResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. page_token should be set to this value for the next request (for + // the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // Name of the clean room. + Runs []CleanRoomNotebookTaskRun `json:"runs,omitempty"` +} + +type ListCleanRoomTaskRunsRequest struct { + // Name of the clean room. + CleanRoomName *string `json:"clean_room_name,omitempty"` + // Executable name. + Name *string `json:"name,omitempty"` + // The maximum number of task runs to return. Maximum value of 100. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` + // Filter by the type of Clean Room task. + TaskType CleanRoomTaskType `json:"task_type,omitempty"` +} + +type ListCleanRoomTaskRunsResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. page_token should be set to this value for the next request (for + // the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // Task runs in the clean room. + Runs []CleanRoomTaskRun `json:"runs,omitempty"` +} + +type ListCleanRoomsRequest struct { + // Maximum number of clean rooms to return (i.e., the page length). Defaults to + // 100. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListCleanRoomsResponse struct { + CleanRooms []CleanRoom `json:"clean_rooms,omitempty"` + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. page_token should be set to this value for the next request (for + // the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type NotebookVersionReview struct { + // Review comment + Comment *string `json:"comment,omitempty"` + // Etag identifying the notebook version + Etag *string `json:"etag,omitempty"` + // Review outcome + ReviewState CleanRoomNotebookReview_NotebookReviewState `json:"review_state,omitempty"` +} + +type PartitionSpecification_Partition struct { + // An array of partition values. + Values []PartitionSpecification_Partition_PartitionValue `json:"values,omitempty"` +} + +type PartitionSpecification_Partition_PartitionValue struct { + // The name of the partition column. + Name *string `json:"name,omitempty"` + // The operator to apply for the value. + Op PartitionSpecification_Partition_PartitionValue_PartitionValueOp `json:"op,omitempty"` + // The key of a Delta Sharing recipient's property. For example + // "databricks-account-id". When this field is set, field `value` can not be + // set. + RecipientPropertyKey *string `json:"recipient_property_key,omitempty"` + // The value of the partition column. When this value is not set, it means + // `null` value. When this field is set, field `recipient_property_key` can not + // be set. + Value *string `json:"value,omitempty"` +} + +// A positional argument passed to a row filter or column mask function. +// Distinguishes between column references and literals.. +type PolicyFunctionArgument struct { + Column *string `json:"column,omitempty"` + Constant *string `json:"constant,omitempty"` +} + +type UpdateCleanRoomAssetRequest struct { + // The asset to update. The asset's `name` and `asset_type` fields are used to + // identify the asset to update. + Asset *CleanRoomAsset `json:"asset,omitempty"` + // Name of the clean room. + CleanRoomName *string `json:"clean_room_name,omitempty"` +} + +type UpdateCleanRoomAutoApprovalRuleRequest struct { + // The auto-approval rule to update. The rule_id field is used to identify the + // rule to update. + AutoApprovalRule *CleanRoomAutoApprovalRule `json:"auto_approval_rule,omitempty"` +} + +type UpdateCleanRoomRequest struct { + CleanRoom *CleanRoom `json:"clean_room,omitempty"` + // Name of the clean room. + Name *string `json:"name,omitempty"` +} + +// CleanRoomToSDK converts the mirror to the sdk-go type. +func CleanRoomToSDK(w *CleanRoom) (*sdk.CleanRoom, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoom{} + out.Name = w.Name + conv1, err := CleanRoomRemoteDetailToSDK(w.RemoteDetailedInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoom.RemoteDetailedInfo", err) + } + out.RemoteDetailedInfo = conv1 + out.Owner = w.Owner + out.Comment = w.Comment + out.CreatedAt = w.CreatedAt + out.UpdatedAt = w.UpdatedAt + out.Status = w.Status + out.LocalCollaboratorAlias = w.LocalCollaboratorAlias + conv2, err := CleanRoomOutputCatalogToSDK(w.OutputCatalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoom.OutputCatalog", err) + } + out.OutputCatalog = conv2 + out.AccessRestricted = w.AccessRestricted + out.EnableSharedOutput = w.EnableSharedOutput + return out, nil +} + +// CleanRoomFromSDK converts the sdk-go type to the mirror. +func CleanRoomFromSDK(v *sdk.CleanRoom) (*CleanRoom, error) { + if v == nil { + return nil, nil + } + out := &CleanRoom{} + out.Name = v.Name + conv3, err := CleanRoomRemoteDetailFromSDK(v.RemoteDetailedInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoom.RemoteDetailedInfo", err) + } + out.RemoteDetailedInfo = conv3 + out.Owner = v.Owner + out.Comment = v.Comment + out.CreatedAt = v.CreatedAt + out.UpdatedAt = v.UpdatedAt + out.Status = v.Status + out.LocalCollaboratorAlias = v.LocalCollaboratorAlias + conv4, err := CleanRoomOutputCatalogFromSDK(v.OutputCatalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoom.OutputCatalog", err) + } + out.OutputCatalog = conv4 + out.AccessRestricted = v.AccessRestricted + out.EnableSharedOutput = v.EnableSharedOutput + return out, nil +} + +// CleanRoomAssetToSDK converts the mirror to the sdk-go type. +func CleanRoomAssetToSDK(w *CleanRoomAsset) (*sdk.CleanRoomAsset, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomAsset{} + out.CleanRoomName = w.CleanRoomName + out.Name = w.Name + out.AssetType = w.AssetType + out.AddedAt = w.AddedAt + out.Status = w.Status + out.OwnerCollaboratorAlias = w.OwnerCollaboratorAlias + { + var members []string + if w.TableLocalDetails != nil { + members = append(members, "table_local_details") + } + if w.VolumeLocalDetails != nil { + members = append(members, "volume_local_details") + } + if w.ViewLocalDetails != nil { + members = append(members, "view_local_details") + } + if w.ForeignTableLocalDetails != nil { + members = append(members, "foreign_table_local_details") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.TableLocalDetails != nil: + conv5, err := CleanRoomAsset_TableLocalDetailsToSDK(w.TableLocalDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.LocalDetails", err) + } + out.LocalDetails = &sdk.CleanRoomAsset_LocalDetails_TableLocalDetails{TableLocalDetails: *conv5} + case w.VolumeLocalDetails != nil: + conv6, err := CleanRoomAsset_VolumeLocalDetailsToSDK(w.VolumeLocalDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.LocalDetails", err) + } + out.LocalDetails = &sdk.CleanRoomAsset_LocalDetails_VolumeLocalDetails{VolumeLocalDetails: *conv6} + case w.ViewLocalDetails != nil: + conv7, err := CleanRoomAsset_ViewLocalDetailsToSDK(w.ViewLocalDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.LocalDetails", err) + } + out.LocalDetails = &sdk.CleanRoomAsset_LocalDetails_ViewLocalDetails{ViewLocalDetails: *conv7} + case w.ForeignTableLocalDetails != nil: + conv8, err := CleanRoomAsset_ForeignTableLocalDetailsToSDK(w.ForeignTableLocalDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.LocalDetails", err) + } + out.LocalDetails = &sdk.CleanRoomAsset_LocalDetails_ForeignTableLocalDetails{ForeignTableLocalDetails: *conv8} + } + { + var members []string + if w.Table != nil { + members = append(members, "table") + } + if w.Notebook != nil { + members = append(members, "notebook") + } + if w.View != nil { + members = append(members, "view") + } + if w.ForeignTable != nil { + members = append(members, "foreign_table") + } + if w.JarAnalysis != nil { + members = append(members, "jar_analysis") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Table != nil: + conv9, err := CleanRoomAsset_TableToSDK(w.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.Details", err) + } + out.Details = &sdk.CleanRoomAsset_Details_Table{Table: *conv9} + case w.Notebook != nil: + conv10, err := CleanRoomAsset_NotebookToSDK(w.Notebook) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.Details", err) + } + out.Details = &sdk.CleanRoomAsset_Details_Notebook{Notebook: *conv10} + case w.View != nil: + conv11, err := CleanRoomAsset_ViewToSDK(w.View) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.Details", err) + } + out.Details = &sdk.CleanRoomAsset_Details_View{View: *conv11} + case w.ForeignTable != nil: + conv12, err := CleanRoomAsset_ForeignTableToSDK(w.ForeignTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.Details", err) + } + out.Details = &sdk.CleanRoomAsset_Details_ForeignTable{ForeignTable: *conv12} + case w.JarAnalysis != nil: + conv13, err := CleanRoomAsset_JarAnalysisToSDK(w.JarAnalysis) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.Details", err) + } + out.Details = &sdk.CleanRoomAsset_Details_JarAnalysis{JarAnalysis: *conv13} + } + return out, nil +} + +// CleanRoomAssetFromSDK converts the sdk-go type to the mirror. +func CleanRoomAssetFromSDK(v *sdk.CleanRoomAsset) (*CleanRoomAsset, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomAsset{} + out.CleanRoomName = v.CleanRoomName + out.Name = v.Name + out.AssetType = v.AssetType + out.AddedAt = v.AddedAt + out.Status = v.Status + out.OwnerCollaboratorAlias = v.OwnerCollaboratorAlias + switch value := v.LocalDetails.(type) { + case *sdk.CleanRoomAsset_LocalDetails_TableLocalDetails: + if value != nil { + conv14, err := CleanRoomAsset_TableLocalDetailsFromSDK(&value.TableLocalDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.LocalDetails", err) + } + out.TableLocalDetails = conv14 + } + case *sdk.CleanRoomAsset_LocalDetails_VolumeLocalDetails: + if value != nil { + conv15, err := CleanRoomAsset_VolumeLocalDetailsFromSDK(&value.VolumeLocalDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.LocalDetails", err) + } + out.VolumeLocalDetails = conv15 + } + case *sdk.CleanRoomAsset_LocalDetails_ViewLocalDetails: + if value != nil { + conv16, err := CleanRoomAsset_ViewLocalDetailsFromSDK(&value.ViewLocalDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.LocalDetails", err) + } + out.ViewLocalDetails = conv16 + } + case *sdk.CleanRoomAsset_LocalDetails_ForeignTableLocalDetails: + if value != nil { + conv17, err := CleanRoomAsset_ForeignTableLocalDetailsFromSDK(&value.ForeignTableLocalDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.LocalDetails", err) + } + out.ForeignTableLocalDetails = conv17 + } + } + switch value := v.Details.(type) { + case *sdk.CleanRoomAsset_Details_Table: + if value != nil { + conv18, err := CleanRoomAsset_TableFromSDK(&value.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.Details", err) + } + out.Table = conv18 + } + case *sdk.CleanRoomAsset_Details_Notebook: + if value != nil { + conv19, err := CleanRoomAsset_NotebookFromSDK(&value.Notebook) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.Details", err) + } + out.Notebook = conv19 + } + case *sdk.CleanRoomAsset_Details_View: + if value != nil { + conv20, err := CleanRoomAsset_ViewFromSDK(&value.View) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.Details", err) + } + out.View = conv20 + } + case *sdk.CleanRoomAsset_Details_ForeignTable: + if value != nil { + conv21, err := CleanRoomAsset_ForeignTableFromSDK(&value.ForeignTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.Details", err) + } + out.ForeignTable = conv21 + } + case *sdk.CleanRoomAsset_Details_JarAnalysis: + if value != nil { + conv22, err := CleanRoomAsset_JarAnalysisFromSDK(&value.JarAnalysis) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset.Details", err) + } + out.JarAnalysis = conv22 + } + } + return out, nil +} + +// CleanRoomAsset_ForeignTableToSDK converts the mirror to the sdk-go type. +func CleanRoomAsset_ForeignTableToSDK(w *CleanRoomAsset_ForeignTable) (*sdk.CleanRoomAsset_ForeignTable, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomAsset_ForeignTable{} + conv23, err := convertSlice(w.Columns, ColumnInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset_ForeignTable.Columns", err) + } + out.Columns = conv23 + return out, nil +} + +// CleanRoomAsset_ForeignTableFromSDK converts the sdk-go type to the mirror. +func CleanRoomAsset_ForeignTableFromSDK(v *sdk.CleanRoomAsset_ForeignTable) (*CleanRoomAsset_ForeignTable, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomAsset_ForeignTable{} + conv24, err := convertSlice(v.Columns, ColumnInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset_ForeignTable.Columns", err) + } + out.Columns = conv24 + return out, nil +} + +// CleanRoomAsset_ForeignTableLocalDetailsToSDK converts the mirror to the sdk-go type. +func CleanRoomAsset_ForeignTableLocalDetailsToSDK(w *CleanRoomAsset_ForeignTableLocalDetails) (*sdk.CleanRoomAsset_ForeignTableLocalDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomAsset_ForeignTableLocalDetails{} + out.LocalName = w.LocalName + return out, nil +} + +// CleanRoomAsset_ForeignTableLocalDetailsFromSDK converts the sdk-go type to the mirror. +func CleanRoomAsset_ForeignTableLocalDetailsFromSDK(v *sdk.CleanRoomAsset_ForeignTableLocalDetails) (*CleanRoomAsset_ForeignTableLocalDetails, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomAsset_ForeignTableLocalDetails{} + out.LocalName = v.LocalName + return out, nil +} + +// CleanRoomAsset_JarAnalysisToSDK converts the mirror to the sdk-go type. +func CleanRoomAsset_JarAnalysisToSDK(w *CleanRoomAsset_JarAnalysis) (*sdk.CleanRoomAsset_JarAnalysis, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomAsset_JarAnalysis{} + out.Etag = w.Etag + out.Description = w.Description + out.RunnerCollaboratorAliases = w.RunnerCollaboratorAliases + conv25, err := convertSlice(w.Reviews, CleanRoomJarAnalysisReviewToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset_JarAnalysis.Reviews", err) + } + out.Reviews = conv25 + out.ReviewState = w.ReviewState + out.MainClassName = w.MainClassName + out.CentralJarFilePaths = w.CentralJarFilePaths + out.EnvironmentVersion = w.EnvironmentVersion + return out, nil +} + +// CleanRoomAsset_JarAnalysisFromSDK converts the sdk-go type to the mirror. +func CleanRoomAsset_JarAnalysisFromSDK(v *sdk.CleanRoomAsset_JarAnalysis) (*CleanRoomAsset_JarAnalysis, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomAsset_JarAnalysis{} + out.Etag = v.Etag + out.Description = v.Description + out.RunnerCollaboratorAliases = v.RunnerCollaboratorAliases + conv26, err := convertSlice(v.Reviews, CleanRoomJarAnalysisReviewFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset_JarAnalysis.Reviews", err) + } + out.Reviews = conv26 + out.ReviewState = v.ReviewState + out.MainClassName = v.MainClassName + out.CentralJarFilePaths = v.CentralJarFilePaths + out.EnvironmentVersion = v.EnvironmentVersion + return out, nil +} + +// CleanRoomAsset_NotebookToSDK converts the mirror to the sdk-go type. +func CleanRoomAsset_NotebookToSDK(w *CleanRoomAsset_Notebook) (*sdk.CleanRoomAsset_Notebook, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomAsset_Notebook{} + out.NotebookContent = w.NotebookContent + out.Etag = w.Etag + out.RunnerCollaboratorAliases = w.RunnerCollaboratorAliases + conv27, err := convertSlice(w.Reviews, CleanRoomNotebookReviewToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset_Notebook.Reviews", err) + } + out.Reviews = conv27 + out.ReviewState = w.ReviewState + out.Description = w.Description + out.EnvironmentVersion = w.EnvironmentVersion + return out, nil +} + +// CleanRoomAsset_NotebookFromSDK converts the sdk-go type to the mirror. +func CleanRoomAsset_NotebookFromSDK(v *sdk.CleanRoomAsset_Notebook) (*CleanRoomAsset_Notebook, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomAsset_Notebook{} + out.NotebookContent = v.NotebookContent + out.Etag = v.Etag + out.RunnerCollaboratorAliases = v.RunnerCollaboratorAliases + conv28, err := convertSlice(v.Reviews, CleanRoomNotebookReviewFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset_Notebook.Reviews", err) + } + out.Reviews = conv28 + out.ReviewState = v.ReviewState + out.Description = v.Description + out.EnvironmentVersion = v.EnvironmentVersion + return out, nil +} + +// CleanRoomAsset_TableToSDK converts the mirror to the sdk-go type. +func CleanRoomAsset_TableToSDK(w *CleanRoomAsset_Table) (*sdk.CleanRoomAsset_Table, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomAsset_Table{} + conv29, err := convertSlice(w.Columns, ColumnInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset_Table.Columns", err) + } + out.Columns = conv29 + return out, nil +} + +// CleanRoomAsset_TableFromSDK converts the sdk-go type to the mirror. +func CleanRoomAsset_TableFromSDK(v *sdk.CleanRoomAsset_Table) (*CleanRoomAsset_Table, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomAsset_Table{} + conv30, err := convertSlice(v.Columns, ColumnInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset_Table.Columns", err) + } + out.Columns = conv30 + return out, nil +} + +// CleanRoomAsset_TableLocalDetailsToSDK converts the mirror to the sdk-go type. +func CleanRoomAsset_TableLocalDetailsToSDK(w *CleanRoomAsset_TableLocalDetails) (*sdk.CleanRoomAsset_TableLocalDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomAsset_TableLocalDetails{} + out.LocalName = w.LocalName + conv31, err := convertSlice(w.Partitions, PartitionSpecification_PartitionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset_TableLocalDetails.Partitions", err) + } + out.Partitions = conv31 + return out, nil +} + +// CleanRoomAsset_TableLocalDetailsFromSDK converts the sdk-go type to the mirror. +func CleanRoomAsset_TableLocalDetailsFromSDK(v *sdk.CleanRoomAsset_TableLocalDetails) (*CleanRoomAsset_TableLocalDetails, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomAsset_TableLocalDetails{} + out.LocalName = v.LocalName + conv32, err := convertSlice(v.Partitions, PartitionSpecification_PartitionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset_TableLocalDetails.Partitions", err) + } + out.Partitions = conv32 + return out, nil +} + +// CleanRoomAsset_ViewToSDK converts the mirror to the sdk-go type. +func CleanRoomAsset_ViewToSDK(w *CleanRoomAsset_View) (*sdk.CleanRoomAsset_View, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomAsset_View{} + conv33, err := convertSlice(w.Columns, ColumnInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset_View.Columns", err) + } + out.Columns = conv33 + return out, nil +} + +// CleanRoomAsset_ViewFromSDK converts the sdk-go type to the mirror. +func CleanRoomAsset_ViewFromSDK(v *sdk.CleanRoomAsset_View) (*CleanRoomAsset_View, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomAsset_View{} + conv34, err := convertSlice(v.Columns, ColumnInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomAsset_View.Columns", err) + } + out.Columns = conv34 + return out, nil +} + +// CleanRoomAsset_ViewLocalDetailsToSDK converts the mirror to the sdk-go type. +func CleanRoomAsset_ViewLocalDetailsToSDK(w *CleanRoomAsset_ViewLocalDetails) (*sdk.CleanRoomAsset_ViewLocalDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomAsset_ViewLocalDetails{} + out.LocalName = w.LocalName + return out, nil +} + +// CleanRoomAsset_ViewLocalDetailsFromSDK converts the sdk-go type to the mirror. +func CleanRoomAsset_ViewLocalDetailsFromSDK(v *sdk.CleanRoomAsset_ViewLocalDetails) (*CleanRoomAsset_ViewLocalDetails, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomAsset_ViewLocalDetails{} + out.LocalName = v.LocalName + return out, nil +} + +// CleanRoomAsset_VolumeLocalDetailsToSDK converts the mirror to the sdk-go type. +func CleanRoomAsset_VolumeLocalDetailsToSDK(w *CleanRoomAsset_VolumeLocalDetails) (*sdk.CleanRoomAsset_VolumeLocalDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomAsset_VolumeLocalDetails{} + out.LocalName = w.LocalName + return out, nil +} + +// CleanRoomAsset_VolumeLocalDetailsFromSDK converts the sdk-go type to the mirror. +func CleanRoomAsset_VolumeLocalDetailsFromSDK(v *sdk.CleanRoomAsset_VolumeLocalDetails) (*CleanRoomAsset_VolumeLocalDetails, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomAsset_VolumeLocalDetails{} + out.LocalName = v.LocalName + return out, nil +} + +// CleanRoomAutoApprovalRuleToSDK converts the mirror to the sdk-go type. +func CleanRoomAutoApprovalRuleToSDK(w *CleanRoomAutoApprovalRule) (*sdk.CleanRoomAutoApprovalRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomAutoApprovalRule{} + out.CleanRoomName = w.CleanRoomName + out.RuleId = w.RuleId + out.RuleOwnerCollaboratorAlias = w.RuleOwnerCollaboratorAlias + { + var members []string + if w.AuthorCollaboratorAlias != nil { + members = append(members, "author_collaborator_alias") + } + if w.AuthorScope != "" { + members = append(members, "author_scope") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AuthorCollaboratorAlias != nil: + out.Authors = &sdk.CleanRoomAutoApprovalRule_Authors_AuthorCollaboratorAlias{AuthorCollaboratorAlias: *w.AuthorCollaboratorAlias} + case w.AuthorScope != "": + out.Authors = &sdk.CleanRoomAutoApprovalRule_Authors_AuthorScope{AuthorScope: w.AuthorScope} + } + { + var members []string + if w.RunnerCollaboratorAlias != nil { + members = append(members, "runner_collaborator_alias") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.RunnerCollaboratorAlias != nil: + out.Runners = &sdk.CleanRoomAutoApprovalRule_Runners_RunnerCollaboratorAlias{RunnerCollaboratorAlias: *w.RunnerCollaboratorAlias} + } + out.CreatedAt = w.CreatedAt + return out, nil +} + +// CleanRoomAutoApprovalRuleFromSDK converts the sdk-go type to the mirror. +func CleanRoomAutoApprovalRuleFromSDK(v *sdk.CleanRoomAutoApprovalRule) (*CleanRoomAutoApprovalRule, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomAutoApprovalRule{} + out.CleanRoomName = v.CleanRoomName + out.RuleId = v.RuleId + out.RuleOwnerCollaboratorAlias = v.RuleOwnerCollaboratorAlias + switch value := v.Authors.(type) { + case *sdk.CleanRoomAutoApprovalRule_Authors_AuthorCollaboratorAlias: + if value != nil { + out.AuthorCollaboratorAlias = new(value.AuthorCollaboratorAlias) + } + case *sdk.CleanRoomAutoApprovalRule_Authors_AuthorScope: + if value != nil { + out.AuthorScope = value.AuthorScope + } + } + switch value := v.Runners.(type) { + case *sdk.CleanRoomAutoApprovalRule_Runners_RunnerCollaboratorAlias: + if value != nil { + out.RunnerCollaboratorAlias = new(value.RunnerCollaboratorAlias) + } + } + out.CreatedAt = v.CreatedAt + return out, nil +} + +// CleanRoomCollaboratorToSDK converts the mirror to the sdk-go type. +func CleanRoomCollaboratorToSDK(w *CleanRoomCollaborator) (*sdk.CleanRoomCollaborator, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomCollaborator{} + out.GlobalMetastoreId = w.GlobalMetastoreId + out.OrganizationName = w.OrganizationName + out.InviteRecipientWorkspaceId = w.InviteRecipientWorkspaceId + out.InviteRecipientEmail = w.InviteRecipientEmail + out.CollaboratorAlias = w.CollaboratorAlias + out.DisplayName = w.DisplayName + return out, nil +} + +// CleanRoomCollaboratorFromSDK converts the sdk-go type to the mirror. +func CleanRoomCollaboratorFromSDK(v *sdk.CleanRoomCollaborator) (*CleanRoomCollaborator, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomCollaborator{} + out.GlobalMetastoreId = v.GlobalMetastoreId + out.OrganizationName = v.OrganizationName + out.InviteRecipientWorkspaceId = v.InviteRecipientWorkspaceId + out.InviteRecipientEmail = v.InviteRecipientEmail + out.CollaboratorAlias = v.CollaboratorAlias + out.DisplayName = v.DisplayName + return out, nil +} + +// CleanRoomJarAnalysisReviewToSDK converts the mirror to the sdk-go type. +func CleanRoomJarAnalysisReviewToSDK(w *CleanRoomJarAnalysisReview) (*sdk.CleanRoomJarAnalysisReview, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomJarAnalysisReview{} + out.ReviewerCollaboratorAlias = w.ReviewerCollaboratorAlias + out.CreatedAtMillis = w.CreatedAtMillis + out.ReviewState = w.ReviewState + out.Comment = w.Comment + out.ReviewSubReason = w.ReviewSubReason + return out, nil +} + +// CleanRoomJarAnalysisReviewFromSDK converts the sdk-go type to the mirror. +func CleanRoomJarAnalysisReviewFromSDK(v *sdk.CleanRoomJarAnalysisReview) (*CleanRoomJarAnalysisReview, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomJarAnalysisReview{} + out.ReviewerCollaboratorAlias = v.ReviewerCollaboratorAlias + out.CreatedAtMillis = v.CreatedAtMillis + out.ReviewState = v.ReviewState + out.Comment = v.Comment + out.ReviewSubReason = v.ReviewSubReason + return out, nil +} + +// CleanRoomNotebookReviewToSDK converts the mirror to the sdk-go type. +func CleanRoomNotebookReviewToSDK(w *CleanRoomNotebookReview) (*sdk.CleanRoomNotebookReview, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomNotebookReview{} + out.ReviewerCollaboratorAlias = w.ReviewerCollaboratorAlias + out.CreatedAtMillis = w.CreatedAtMillis + out.ReviewState = w.ReviewState + out.Comment = w.Comment + out.ReviewSubReason = w.ReviewSubReason + return out, nil +} + +// CleanRoomNotebookReviewFromSDK converts the sdk-go type to the mirror. +func CleanRoomNotebookReviewFromSDK(v *sdk.CleanRoomNotebookReview) (*CleanRoomNotebookReview, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomNotebookReview{} + out.ReviewerCollaboratorAlias = v.ReviewerCollaboratorAlias + out.CreatedAtMillis = v.CreatedAtMillis + out.ReviewState = v.ReviewState + out.Comment = v.Comment + out.ReviewSubReason = v.ReviewSubReason + return out, nil +} + +// CleanRoomNotebookTaskRunToSDK converts the mirror to the sdk-go type. +func CleanRoomNotebookTaskRunToSDK(w *CleanRoomNotebookTaskRun) (*sdk.CleanRoomNotebookTaskRun, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomNotebookTaskRun{} + out.NotebookName = w.NotebookName + out.StartTime = w.StartTime + out.RunDuration = w.RunDuration + conv35, err := CleanRoomTaskRunStateToSDK(w.NotebookJobRunState) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomNotebookTaskRun.NotebookJobRunState", err) + } + out.NotebookJobRunState = conv35 + conv36, err := CollaboratorJobRunInfoToSDK(w.CollaboratorJobRunInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomNotebookTaskRun.CollaboratorJobRunInfo", err) + } + out.CollaboratorJobRunInfo = conv36 + out.OutputSchemaName = w.OutputSchemaName + out.OutputSchemaExpirationTime = w.OutputSchemaExpirationTime + out.NotebookEtag = w.NotebookEtag + out.NotebookUpdatedAt = w.NotebookUpdatedAt + out.SharedOutputSchemaName = w.SharedOutputSchemaName + out.SharedOutputSchemaExpirationTime = w.SharedOutputSchemaExpirationTime + return out, nil +} + +// CleanRoomNotebookTaskRunFromSDK converts the sdk-go type to the mirror. +func CleanRoomNotebookTaskRunFromSDK(v *sdk.CleanRoomNotebookTaskRun) (*CleanRoomNotebookTaskRun, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomNotebookTaskRun{} + out.NotebookName = v.NotebookName + out.StartTime = v.StartTime + out.RunDuration = v.RunDuration + conv37, err := CleanRoomTaskRunStateFromSDK(v.NotebookJobRunState) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomNotebookTaskRun.NotebookJobRunState", err) + } + out.NotebookJobRunState = conv37 + conv38, err := CollaboratorJobRunInfoFromSDK(v.CollaboratorJobRunInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomNotebookTaskRun.CollaboratorJobRunInfo", err) + } + out.CollaboratorJobRunInfo = conv38 + out.OutputSchemaName = v.OutputSchemaName + out.OutputSchemaExpirationTime = v.OutputSchemaExpirationTime + out.NotebookEtag = v.NotebookEtag + out.NotebookUpdatedAt = v.NotebookUpdatedAt + out.SharedOutputSchemaName = v.SharedOutputSchemaName + out.SharedOutputSchemaExpirationTime = v.SharedOutputSchemaExpirationTime + return out, nil +} + +// CleanRoomOutputCatalogToSDK converts the mirror to the sdk-go type. +func CleanRoomOutputCatalogToSDK(w *CleanRoomOutputCatalog) (*sdk.CleanRoomOutputCatalog, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomOutputCatalog{} + out.Status = w.Status + out.CatalogName = w.CatalogName + return out, nil +} + +// CleanRoomOutputCatalogFromSDK converts the sdk-go type to the mirror. +func CleanRoomOutputCatalogFromSDK(v *sdk.CleanRoomOutputCatalog) (*CleanRoomOutputCatalog, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomOutputCatalog{} + out.Status = v.Status + out.CatalogName = v.CatalogName + return out, nil +} + +// CleanRoomRemoteDetailToSDK converts the mirror to the sdk-go type. +func CleanRoomRemoteDetailToSDK(w *CleanRoomRemoteDetail) (*sdk.CleanRoomRemoteDetail, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomRemoteDetail{} + out.CentralCleanRoomId = w.CentralCleanRoomId + out.CloudVendor = w.CloudVendor + out.Region = w.Region + conv39, err := convertSlice(w.Collaborators, CleanRoomCollaboratorToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomRemoteDetail.Collaborators", err) + } + out.Collaborators = conv39 + conv40, err := CleanRoomCollaboratorToSDK(w.Creator) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomRemoteDetail.Creator", err) + } + out.Creator = conv40 + conv41, err := EgressNetworkPolicyToSDK(w.EgressNetworkPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomRemoteDetail.EgressNetworkPolicy", err) + } + out.EgressNetworkPolicy = conv41 + conv42, err := ComplianceSecurityProfileToSDK(w.ComplianceSecurityProfile) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomRemoteDetail.ComplianceSecurityProfile", err) + } + out.ComplianceSecurityProfile = conv42 + out.EnableSharedOutput = w.EnableSharedOutput + out.PackageProviderCollaboratorAlias = w.PackageProviderCollaboratorAlias + return out, nil +} + +// CleanRoomRemoteDetailFromSDK converts the sdk-go type to the mirror. +func CleanRoomRemoteDetailFromSDK(v *sdk.CleanRoomRemoteDetail) (*CleanRoomRemoteDetail, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomRemoteDetail{} + out.CentralCleanRoomId = v.CentralCleanRoomId + out.CloudVendor = v.CloudVendor + out.Region = v.Region + conv43, err := convertSlice(v.Collaborators, CleanRoomCollaboratorFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomRemoteDetail.Collaborators", err) + } + out.Collaborators = conv43 + conv44, err := CleanRoomCollaboratorFromSDK(v.Creator) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomRemoteDetail.Creator", err) + } + out.Creator = conv44 + conv45, err := EgressNetworkPolicyFromSDK(v.EgressNetworkPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomRemoteDetail.EgressNetworkPolicy", err) + } + out.EgressNetworkPolicy = conv45 + conv46, err := ComplianceSecurityProfileFromSDK(v.ComplianceSecurityProfile) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomRemoteDetail.ComplianceSecurityProfile", err) + } + out.ComplianceSecurityProfile = conv46 + out.EnableSharedOutput = v.EnableSharedOutput + out.PackageProviderCollaboratorAlias = v.PackageProviderCollaboratorAlias + return out, nil +} + +// CleanRoomTaskRunToSDK converts the mirror to the sdk-go type. +func CleanRoomTaskRunToSDK(w *CleanRoomTaskRun) (*sdk.CleanRoomTaskRun, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomTaskRun{} + out.Name = w.Name + out.TaskType = w.TaskType + out.StartTime = w.StartTime + out.RunDuration = w.RunDuration + conv47, err := CleanRoomTaskRunStateToSDK(w.TaskRunState) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomTaskRun.TaskRunState", err) + } + out.TaskRunState = conv47 + conv48, err := CollaboratorJobRunInfoToSDK(w.CollaboratorJobRunInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomTaskRun.CollaboratorJobRunInfo", err) + } + out.CollaboratorJobRunInfo = conv48 + conv49, err := CleanRoomTaskRun_OutputInfoToSDK(w.OutputInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomTaskRun.OutputInfo", err) + } + out.OutputInfo = conv49 + conv50, err := CleanRoomTaskRun_CleanRoomTaskAnalysisDetailsToSDK(w.AnalysisDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomTaskRun.AnalysisDetails", err) + } + out.AnalysisDetails = conv50 + conv51, err := CleanRoomTaskRun_OutputInfoToSDK(w.SharedOutputInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomTaskRun.SharedOutputInfo", err) + } + out.SharedOutputInfo = conv51 + return out, nil +} + +// CleanRoomTaskRunFromSDK converts the sdk-go type to the mirror. +func CleanRoomTaskRunFromSDK(v *sdk.CleanRoomTaskRun) (*CleanRoomTaskRun, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomTaskRun{} + out.Name = v.Name + out.TaskType = v.TaskType + out.StartTime = v.StartTime + out.RunDuration = v.RunDuration + conv52, err := CleanRoomTaskRunStateFromSDK(v.TaskRunState) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomTaskRun.TaskRunState", err) + } + out.TaskRunState = conv52 + conv53, err := CollaboratorJobRunInfoFromSDK(v.CollaboratorJobRunInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomTaskRun.CollaboratorJobRunInfo", err) + } + out.CollaboratorJobRunInfo = conv53 + conv54, err := CleanRoomTaskRun_OutputInfoFromSDK(v.OutputInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomTaskRun.OutputInfo", err) + } + out.OutputInfo = conv54 + conv55, err := CleanRoomTaskRun_CleanRoomTaskAnalysisDetailsFromSDK(v.AnalysisDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomTaskRun.AnalysisDetails", err) + } + out.AnalysisDetails = conv55 + conv56, err := CleanRoomTaskRun_OutputInfoFromSDK(v.SharedOutputInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomTaskRun.SharedOutputInfo", err) + } + out.SharedOutputInfo = conv56 + return out, nil +} + +// CleanRoomTaskRunStateToSDK converts the mirror to the sdk-go type. +func CleanRoomTaskRunStateToSDK(w *CleanRoomTaskRunState) (*sdk.CleanRoomTaskRunState, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomTaskRunState{} + out.LifeCycleState = w.LifeCycleState + out.ResultState = w.ResultState + return out, nil +} + +// CleanRoomTaskRunStateFromSDK converts the sdk-go type to the mirror. +func CleanRoomTaskRunStateFromSDK(v *sdk.CleanRoomTaskRunState) (*CleanRoomTaskRunState, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomTaskRunState{} + out.LifeCycleState = v.LifeCycleState + out.ResultState = v.ResultState + return out, nil +} + +// CleanRoomTaskRun_CleanRoomTaskAnalysisDetailsToSDK converts the mirror to the sdk-go type. +func CleanRoomTaskRun_CleanRoomTaskAnalysisDetailsToSDK(w *CleanRoomTaskRun_CleanRoomTaskAnalysisDetails) (*sdk.CleanRoomTaskRun_CleanRoomTaskAnalysisDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomTaskRun_CleanRoomTaskAnalysisDetails{} + out.Etag = w.Etag + out.UpdatedAt = w.UpdatedAt + return out, nil +} + +// CleanRoomTaskRun_CleanRoomTaskAnalysisDetailsFromSDK converts the sdk-go type to the mirror. +func CleanRoomTaskRun_CleanRoomTaskAnalysisDetailsFromSDK(v *sdk.CleanRoomTaskRun_CleanRoomTaskAnalysisDetails) (*CleanRoomTaskRun_CleanRoomTaskAnalysisDetails, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomTaskRun_CleanRoomTaskAnalysisDetails{} + out.Etag = v.Etag + out.UpdatedAt = v.UpdatedAt + return out, nil +} + +// CleanRoomTaskRun_OutputInfoToSDK converts the mirror to the sdk-go type. +func CleanRoomTaskRun_OutputInfoToSDK(w *CleanRoomTaskRun_OutputInfo) (*sdk.CleanRoomTaskRun_OutputInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomTaskRun_OutputInfo{} + out.OutputSchemaName = w.OutputSchemaName + out.OutputSchemaExpirationTime = w.OutputSchemaExpirationTime + return out, nil +} + +// CleanRoomTaskRun_OutputInfoFromSDK converts the sdk-go type to the mirror. +func CleanRoomTaskRun_OutputInfoFromSDK(v *sdk.CleanRoomTaskRun_OutputInfo) (*CleanRoomTaskRun_OutputInfo, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomTaskRun_OutputInfo{} + out.OutputSchemaName = v.OutputSchemaName + out.OutputSchemaExpirationTime = v.OutputSchemaExpirationTime + return out, nil +} + +// CollaboratorJobRunInfoToSDK converts the mirror to the sdk-go type. +func CollaboratorJobRunInfoToSDK(w *CollaboratorJobRunInfo) (*sdk.CollaboratorJobRunInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.CollaboratorJobRunInfo{} + out.CollaboratorJobId = w.CollaboratorJobId + out.CollaboratorJobRunId = w.CollaboratorJobRunId + out.CollaboratorTaskRunId = w.CollaboratorTaskRunId + out.CollaboratorWorkspaceId = w.CollaboratorWorkspaceId + out.CollaboratorAlias = w.CollaboratorAlias + return out, nil +} + +// CollaboratorJobRunInfoFromSDK converts the sdk-go type to the mirror. +func CollaboratorJobRunInfoFromSDK(v *sdk.CollaboratorJobRunInfo) (*CollaboratorJobRunInfo, error) { + if v == nil { + return nil, nil + } + out := &CollaboratorJobRunInfo{} + out.CollaboratorJobId = v.CollaboratorJobId + out.CollaboratorJobRunId = v.CollaboratorJobRunId + out.CollaboratorTaskRunId = v.CollaboratorTaskRunId + out.CollaboratorWorkspaceId = v.CollaboratorWorkspaceId + out.CollaboratorAlias = v.CollaboratorAlias + return out, nil +} + +// ColumnInfoToSDK converts the mirror to the sdk-go type. +func ColumnInfoToSDK(w *ColumnInfo) (*sdk.ColumnInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnInfo{} + out.Name = w.Name + out.TypeText = w.TypeText + out.TypeName = w.TypeName + out.Position = w.Position + out.TypePrecision = w.TypePrecision + out.TypeScale = w.TypeScale + out.TypeIntervalType = w.TypeIntervalType + out.TypeJson = w.TypeJson + out.Comment = w.Comment + out.Nullable = w.Nullable + out.PartitionIndex = w.PartitionIndex + conv57, err := ColumnMaskToSDK(w.Mask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnInfo.Mask", err) + } + out.Mask = conv57 + return out, nil +} + +// ColumnInfoFromSDK converts the sdk-go type to the mirror. +func ColumnInfoFromSDK(v *sdk.ColumnInfo) (*ColumnInfo, error) { + if v == nil { + return nil, nil + } + out := &ColumnInfo{} + out.Name = v.Name + out.TypeText = v.TypeText + out.TypeName = v.TypeName + out.Position = v.Position + out.TypePrecision = v.TypePrecision + out.TypeScale = v.TypeScale + out.TypeIntervalType = v.TypeIntervalType + out.TypeJson = v.TypeJson + out.Comment = v.Comment + out.Nullable = v.Nullable + out.PartitionIndex = v.PartitionIndex + conv58, err := ColumnMaskFromSDK(v.Mask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnInfo.Mask", err) + } + out.Mask = conv58 + return out, nil +} + +// ColumnMaskToSDK converts the mirror to the sdk-go type. +func ColumnMaskToSDK(w *ColumnMask) (*sdk.ColumnMask, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnMask{} + out.FunctionName = w.FunctionName + out.UsingColumnNames = w.UsingColumnNames + conv59, err := convertSlice(w.UsingArguments, PolicyFunctionArgumentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnMask.UsingArguments", err) + } + out.UsingArguments = conv59 + return out, nil +} + +// ColumnMaskFromSDK converts the sdk-go type to the mirror. +func ColumnMaskFromSDK(v *sdk.ColumnMask) (*ColumnMask, error) { + if v == nil { + return nil, nil + } + out := &ColumnMask{} + out.FunctionName = v.FunctionName + out.UsingColumnNames = v.UsingColumnNames + conv60, err := convertSlice(v.UsingArguments, PolicyFunctionArgumentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnMask.UsingArguments", err) + } + out.UsingArguments = conv60 + return out, nil +} + +// ComplianceSecurityProfileToSDK converts the mirror to the sdk-go type. +func ComplianceSecurityProfileToSDK(w *ComplianceSecurityProfile) (*sdk.ComplianceSecurityProfile, error) { + if w == nil { + return nil, nil + } + out := &sdk.ComplianceSecurityProfile{} + out.IsEnabled = w.IsEnabled + out.ComplianceStandards = w.ComplianceStandards + return out, nil +} + +// ComplianceSecurityProfileFromSDK converts the sdk-go type to the mirror. +func ComplianceSecurityProfileFromSDK(v *sdk.ComplianceSecurityProfile) (*ComplianceSecurityProfile, error) { + if v == nil { + return nil, nil + } + out := &ComplianceSecurityProfile{} + out.IsEnabled = v.IsEnabled + out.ComplianceStandards = v.ComplianceStandards + return out, nil +} + +// CreateCleanRoomAssetRequestToSDK converts the mirror to the sdk-go type. +func CreateCleanRoomAssetRequestToSDK(w *CreateCleanRoomAssetRequest) (*sdk.CreateCleanRoomAssetRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCleanRoomAssetRequest{} + conv61, err := CleanRoomAssetToSDK(w.Asset) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomAssetRequest.Asset", err) + } + out.Asset = conv61 + return out, nil +} + +// CreateCleanRoomAssetRequestFromSDK converts the sdk-go type to the mirror. +func CreateCleanRoomAssetRequestFromSDK(v *sdk.CreateCleanRoomAssetRequest) (*CreateCleanRoomAssetRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCleanRoomAssetRequest{} + conv62, err := CleanRoomAssetFromSDK(v.Asset) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomAssetRequest.Asset", err) + } + out.Asset = conv62 + return out, nil +} + +// CreateCleanRoomAssetReviewRequestToSDK converts the mirror to the sdk-go type. +func CreateCleanRoomAssetReviewRequestToSDK(w *CreateCleanRoomAssetReviewRequest) (*sdk.CreateCleanRoomAssetReviewRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCleanRoomAssetReviewRequest{} + out.CleanRoomName = w.CleanRoomName + out.Name = w.Name + out.AssetType = w.AssetType + { + var members []string + if w.NotebookReview != nil { + members = append(members, "notebook_review") + } + if w.JarAnalysisReview != nil { + members = append(members, "jar_analysis_review") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NotebookReview != nil: + conv63, err := NotebookVersionReviewToSDK(w.NotebookReview) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomAssetReviewRequest.Review", err) + } + out.Review = &sdk.CreateCleanRoomAssetReviewRequest_Review_NotebookReview{NotebookReview: *conv63} + case w.JarAnalysisReview != nil: + conv64, err := JarAnalysisVersionReviewToSDK(w.JarAnalysisReview) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomAssetReviewRequest.Review", err) + } + out.Review = &sdk.CreateCleanRoomAssetReviewRequest_Review_JarAnalysisReview{JarAnalysisReview: *conv64} + } + return out, nil +} + +// CreateCleanRoomAssetReviewRequestFromSDK converts the sdk-go type to the mirror. +func CreateCleanRoomAssetReviewRequestFromSDK(v *sdk.CreateCleanRoomAssetReviewRequest) (*CreateCleanRoomAssetReviewRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCleanRoomAssetReviewRequest{} + out.CleanRoomName = v.CleanRoomName + out.Name = v.Name + out.AssetType = v.AssetType + switch value := v.Review.(type) { + case *sdk.CreateCleanRoomAssetReviewRequest_Review_NotebookReview: + if value != nil { + conv65, err := NotebookVersionReviewFromSDK(&value.NotebookReview) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomAssetReviewRequest.Review", err) + } + out.NotebookReview = conv65 + } + case *sdk.CreateCleanRoomAssetReviewRequest_Review_JarAnalysisReview: + if value != nil { + conv66, err := JarAnalysisVersionReviewFromSDK(&value.JarAnalysisReview) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomAssetReviewRequest.Review", err) + } + out.JarAnalysisReview = conv66 + } + } + return out, nil +} + +// CreateCleanRoomAssetReviewResponseToSDK converts the mirror to the sdk-go type. +func CreateCleanRoomAssetReviewResponseToSDK(w *CreateCleanRoomAssetReviewResponse) (*sdk.CreateCleanRoomAssetReviewResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCleanRoomAssetReviewResponse{} + conv67, err := convertSlice(w.NotebookReviews, CleanRoomNotebookReviewToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomAssetReviewResponse.NotebookReviews", err) + } + out.NotebookReviews = conv67 + conv68, err := convertSlice(w.JarAnalysisReviews, CleanRoomJarAnalysisReviewToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomAssetReviewResponse.JarAnalysisReviews", err) + } + out.JarAnalysisReviews = conv68 + { + var members []string + if w.NotebookReviewState != "" { + members = append(members, "notebook_review_state") + } + if w.JarAnalysisReviewState != "" { + members = append(members, "jar_analysis_review_state") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NotebookReviewState != "": + out.ReviewState = &sdk.CreateCleanRoomAssetReviewResponse_ReviewState_NotebookReviewState{NotebookReviewState: w.NotebookReviewState} + case w.JarAnalysisReviewState != "": + out.ReviewState = &sdk.CreateCleanRoomAssetReviewResponse_ReviewState_JarAnalysisReviewState{JarAnalysisReviewState: w.JarAnalysisReviewState} + } + return out, nil +} + +// CreateCleanRoomAssetReviewResponseFromSDK converts the sdk-go type to the mirror. +func CreateCleanRoomAssetReviewResponseFromSDK(v *sdk.CreateCleanRoomAssetReviewResponse) (*CreateCleanRoomAssetReviewResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateCleanRoomAssetReviewResponse{} + conv69, err := convertSlice(v.NotebookReviews, CleanRoomNotebookReviewFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomAssetReviewResponse.NotebookReviews", err) + } + out.NotebookReviews = conv69 + conv70, err := convertSlice(v.JarAnalysisReviews, CleanRoomJarAnalysisReviewFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomAssetReviewResponse.JarAnalysisReviews", err) + } + out.JarAnalysisReviews = conv70 + switch value := v.ReviewState.(type) { + case *sdk.CreateCleanRoomAssetReviewResponse_ReviewState_NotebookReviewState: + if value != nil { + out.NotebookReviewState = value.NotebookReviewState + } + case *sdk.CreateCleanRoomAssetReviewResponse_ReviewState_JarAnalysisReviewState: + if value != nil { + out.JarAnalysisReviewState = value.JarAnalysisReviewState + } + } + return out, nil +} + +// CreateCleanRoomAutoApprovalRuleRequestToSDK converts the mirror to the sdk-go type. +func CreateCleanRoomAutoApprovalRuleRequestToSDK(w *CreateCleanRoomAutoApprovalRuleRequest) (*sdk.CreateCleanRoomAutoApprovalRuleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCleanRoomAutoApprovalRuleRequest{} + conv71, err := CleanRoomAutoApprovalRuleToSDK(w.AutoApprovalRule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomAutoApprovalRuleRequest.AutoApprovalRule", err) + } + out.AutoApprovalRule = conv71 + return out, nil +} + +// CreateCleanRoomAutoApprovalRuleRequestFromSDK converts the sdk-go type to the mirror. +func CreateCleanRoomAutoApprovalRuleRequestFromSDK(v *sdk.CreateCleanRoomAutoApprovalRuleRequest) (*CreateCleanRoomAutoApprovalRuleRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCleanRoomAutoApprovalRuleRequest{} + conv72, err := CleanRoomAutoApprovalRuleFromSDK(v.AutoApprovalRule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomAutoApprovalRuleRequest.AutoApprovalRule", err) + } + out.AutoApprovalRule = conv72 + return out, nil +} + +// CreateCleanRoomOutputCatalogRequestToSDK converts the mirror to the sdk-go type. +func CreateCleanRoomOutputCatalogRequestToSDK(w *CreateCleanRoomOutputCatalogRequest) (*sdk.CreateCleanRoomOutputCatalogRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCleanRoomOutputCatalogRequest{} + out.CleanRoomName = w.CleanRoomName + conv73, err := CleanRoomOutputCatalogToSDK(w.OutputCatalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomOutputCatalogRequest.OutputCatalog", err) + } + out.OutputCatalog = conv73 + return out, nil +} + +// CreateCleanRoomOutputCatalogRequestFromSDK converts the sdk-go type to the mirror. +func CreateCleanRoomOutputCatalogRequestFromSDK(v *sdk.CreateCleanRoomOutputCatalogRequest) (*CreateCleanRoomOutputCatalogRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCleanRoomOutputCatalogRequest{} + out.CleanRoomName = v.CleanRoomName + conv74, err := CleanRoomOutputCatalogFromSDK(v.OutputCatalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomOutputCatalogRequest.OutputCatalog", err) + } + out.OutputCatalog = conv74 + return out, nil +} + +// CreateCleanRoomOutputCatalogResponseToSDK converts the mirror to the sdk-go type. +func CreateCleanRoomOutputCatalogResponseToSDK(w *CreateCleanRoomOutputCatalogResponse) (*sdk.CreateCleanRoomOutputCatalogResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCleanRoomOutputCatalogResponse{} + conv75, err := CleanRoomOutputCatalogToSDK(w.OutputCatalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomOutputCatalogResponse.OutputCatalog", err) + } + out.OutputCatalog = conv75 + return out, nil +} + +// CreateCleanRoomOutputCatalogResponseFromSDK converts the sdk-go type to the mirror. +func CreateCleanRoomOutputCatalogResponseFromSDK(v *sdk.CreateCleanRoomOutputCatalogResponse) (*CreateCleanRoomOutputCatalogResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateCleanRoomOutputCatalogResponse{} + conv76, err := CleanRoomOutputCatalogFromSDK(v.OutputCatalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomOutputCatalogResponse.OutputCatalog", err) + } + out.OutputCatalog = conv76 + return out, nil +} + +// CreateCleanRoomRequestToSDK converts the mirror to the sdk-go type. +func CreateCleanRoomRequestToSDK(w *CreateCleanRoomRequest) (*sdk.CreateCleanRoomRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCleanRoomRequest{} + conv77, err := CleanRoomToSDK(w.CleanRoom) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomRequest.CleanRoom", err) + } + out.CleanRoom = conv77 + return out, nil +} + +// CreateCleanRoomRequestFromSDK converts the sdk-go type to the mirror. +func CreateCleanRoomRequestFromSDK(v *sdk.CreateCleanRoomRequest) (*CreateCleanRoomRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCleanRoomRequest{} + conv78, err := CleanRoomFromSDK(v.CleanRoom) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCleanRoomRequest.CleanRoom", err) + } + out.CleanRoom = conv78 + return out, nil +} + +// EgressNetworkPolicyToSDK converts the mirror to the sdk-go type. +func EgressNetworkPolicyToSDK(w *EgressNetworkPolicy) (*sdk.EgressNetworkPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.EgressNetworkPolicy{} + conv79, err := EgressNetworkPolicy_InternetAccessPolicyToSDK(w.InternetAccess) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy.InternetAccess", err) + } + out.InternetAccess = conv79 + return out, nil +} + +// EgressNetworkPolicyFromSDK converts the sdk-go type to the mirror. +func EgressNetworkPolicyFromSDK(v *sdk.EgressNetworkPolicy) (*EgressNetworkPolicy, error) { + if v == nil { + return nil, nil + } + out := &EgressNetworkPolicy{} + conv80, err := EgressNetworkPolicy_InternetAccessPolicyFromSDK(v.InternetAccess) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy.InternetAccess", err) + } + out.InternetAccess = conv80 + return out, nil +} + +// EgressNetworkPolicy_InternetAccessPolicyToSDK converts the mirror to the sdk-go type. +func EgressNetworkPolicy_InternetAccessPolicyToSDK(w *EgressNetworkPolicy_InternetAccessPolicy) (*sdk.EgressNetworkPolicy_InternetAccessPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.EgressNetworkPolicy_InternetAccessPolicy{} + out.RestrictionMode = w.RestrictionMode + conv81, err := convertSlice(w.AllowedInternetDestinations, EgressNetworkPolicy_InternetAccessPolicy_InternetDestinationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_InternetAccessPolicy.AllowedInternetDestinations", err) + } + out.AllowedInternetDestinations = conv81 + conv82, err := convertSlice(w.AllowedStorageDestinations, EgressNetworkPolicy_InternetAccessPolicy_StorageDestinationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_InternetAccessPolicy.AllowedStorageDestinations", err) + } + out.AllowedStorageDestinations = conv82 + conv83, err := EgressNetworkPolicy_InternetAccessPolicy_LogOnlyModeToSDK(w.LogOnlyMode) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_InternetAccessPolicy.LogOnlyMode", err) + } + out.LogOnlyMode = conv83 + return out, nil +} + +// EgressNetworkPolicy_InternetAccessPolicyFromSDK converts the sdk-go type to the mirror. +func EgressNetworkPolicy_InternetAccessPolicyFromSDK(v *sdk.EgressNetworkPolicy_InternetAccessPolicy) (*EgressNetworkPolicy_InternetAccessPolicy, error) { + if v == nil { + return nil, nil + } + out := &EgressNetworkPolicy_InternetAccessPolicy{} + out.RestrictionMode = v.RestrictionMode + conv84, err := convertSlice(v.AllowedInternetDestinations, EgressNetworkPolicy_InternetAccessPolicy_InternetDestinationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_InternetAccessPolicy.AllowedInternetDestinations", err) + } + out.AllowedInternetDestinations = conv84 + conv85, err := convertSlice(v.AllowedStorageDestinations, EgressNetworkPolicy_InternetAccessPolicy_StorageDestinationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_InternetAccessPolicy.AllowedStorageDestinations", err) + } + out.AllowedStorageDestinations = conv85 + conv86, err := EgressNetworkPolicy_InternetAccessPolicy_LogOnlyModeFromSDK(v.LogOnlyMode) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_InternetAccessPolicy.LogOnlyMode", err) + } + out.LogOnlyMode = conv86 + return out, nil +} + +// EgressNetworkPolicy_InternetAccessPolicy_InternetDestinationToSDK converts the mirror to the sdk-go type. +func EgressNetworkPolicy_InternetAccessPolicy_InternetDestinationToSDK(w *EgressNetworkPolicy_InternetAccessPolicy_InternetDestination) (*sdk.EgressNetworkPolicy_InternetAccessPolicy_InternetDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.EgressNetworkPolicy_InternetAccessPolicy_InternetDestination{} + out.Destination = w.Destination + out.Type = w.Type + out.Protocol = w.Protocol + return out, nil +} + +// EgressNetworkPolicy_InternetAccessPolicy_InternetDestinationFromSDK converts the sdk-go type to the mirror. +func EgressNetworkPolicy_InternetAccessPolicy_InternetDestinationFromSDK(v *sdk.EgressNetworkPolicy_InternetAccessPolicy_InternetDestination) (*EgressNetworkPolicy_InternetAccessPolicy_InternetDestination, error) { + if v == nil { + return nil, nil + } + out := &EgressNetworkPolicy_InternetAccessPolicy_InternetDestination{} + out.Destination = v.Destination + out.Type = v.Type + out.Protocol = v.Protocol + return out, nil +} + +// EgressNetworkPolicy_InternetAccessPolicy_LogOnlyModeToSDK converts the mirror to the sdk-go type. +func EgressNetworkPolicy_InternetAccessPolicy_LogOnlyModeToSDK(w *EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode) (*sdk.EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode, error) { + if w == nil { + return nil, nil + } + out := &sdk.EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode{} + out.LogOnlyModeType = w.LogOnlyModeType + out.Workloads = w.Workloads + return out, nil +} + +// EgressNetworkPolicy_InternetAccessPolicy_LogOnlyModeFromSDK converts the sdk-go type to the mirror. +func EgressNetworkPolicy_InternetAccessPolicy_LogOnlyModeFromSDK(v *sdk.EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode) (*EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode, error) { + if v == nil { + return nil, nil + } + out := &EgressNetworkPolicy_InternetAccessPolicy_LogOnlyMode{} + out.LogOnlyModeType = v.LogOnlyModeType + out.Workloads = v.Workloads + return out, nil +} + +// EgressNetworkPolicy_InternetAccessPolicy_StorageDestinationToSDK converts the mirror to the sdk-go type. +func EgressNetworkPolicy_InternetAccessPolicy_StorageDestinationToSDK(w *EgressNetworkPolicy_InternetAccessPolicy_StorageDestination) (*sdk.EgressNetworkPolicy_InternetAccessPolicy_StorageDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.EgressNetworkPolicy_InternetAccessPolicy_StorageDestination{} + out.BucketName = w.BucketName + out.Region = w.Region + out.Type = w.Type + out.AzureStorageAccount = w.AzureStorageAccount + out.AllowedPaths = w.AllowedPaths + out.AzureStorageService = w.AzureStorageService + out.AzureDnsZone = w.AzureDnsZone + out.AzureContainer = w.AzureContainer + return out, nil +} + +// EgressNetworkPolicy_InternetAccessPolicy_StorageDestinationFromSDK converts the sdk-go type to the mirror. +func EgressNetworkPolicy_InternetAccessPolicy_StorageDestinationFromSDK(v *sdk.EgressNetworkPolicy_InternetAccessPolicy_StorageDestination) (*EgressNetworkPolicy_InternetAccessPolicy_StorageDestination, error) { + if v == nil { + return nil, nil + } + out := &EgressNetworkPolicy_InternetAccessPolicy_StorageDestination{} + out.BucketName = v.BucketName + out.Region = v.Region + out.Type = v.Type + out.AzureStorageAccount = v.AzureStorageAccount + out.AllowedPaths = v.AllowedPaths + out.AzureStorageService = v.AzureStorageService + out.AzureDnsZone = v.AzureDnsZone + out.AzureContainer = v.AzureContainer + return out, nil +} + +// JarAnalysisVersionReviewToSDK converts the mirror to the sdk-go type. +func JarAnalysisVersionReviewToSDK(w *JarAnalysisVersionReview) (*sdk.JarAnalysisVersionReview, error) { + if w == nil { + return nil, nil + } + out := &sdk.JarAnalysisVersionReview{} + out.Etag = w.Etag + out.ReviewState = w.ReviewState + out.Comment = w.Comment + return out, nil +} + +// JarAnalysisVersionReviewFromSDK converts the sdk-go type to the mirror. +func JarAnalysisVersionReviewFromSDK(v *sdk.JarAnalysisVersionReview) (*JarAnalysisVersionReview, error) { + if v == nil { + return nil, nil + } + out := &JarAnalysisVersionReview{} + out.Etag = v.Etag + out.ReviewState = v.ReviewState + out.Comment = v.Comment + return out, nil +} + +// ListCleanRoomAssetRevisionsRequestToSDK converts the mirror to the sdk-go type. +func ListCleanRoomAssetRevisionsRequestToSDK(w *ListCleanRoomAssetRevisionsRequest) (*sdk.ListCleanRoomAssetRevisionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCleanRoomAssetRevisionsRequest{} + out.CleanRoomName = w.CleanRoomName + out.Name = w.Name + out.AssetType = w.AssetType + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListCleanRoomAssetRevisionsRequestFromSDK converts the sdk-go type to the mirror. +func ListCleanRoomAssetRevisionsRequestFromSDK(v *sdk.ListCleanRoomAssetRevisionsRequest) (*ListCleanRoomAssetRevisionsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCleanRoomAssetRevisionsRequest{} + out.CleanRoomName = v.CleanRoomName + out.Name = v.Name + out.AssetType = v.AssetType + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListCleanRoomAssetRevisionsResponseToSDK converts the mirror to the sdk-go type. +func ListCleanRoomAssetRevisionsResponseToSDK(w *ListCleanRoomAssetRevisionsResponse) (*sdk.ListCleanRoomAssetRevisionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCleanRoomAssetRevisionsResponse{} + conv87, err := convertSlice(w.Revisions, CleanRoomAssetToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCleanRoomAssetRevisionsResponse.Revisions", err) + } + out.Revisions = conv87 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCleanRoomAssetRevisionsResponseFromSDK converts the sdk-go type to the mirror. +func ListCleanRoomAssetRevisionsResponseFromSDK(v *sdk.ListCleanRoomAssetRevisionsResponse) (*ListCleanRoomAssetRevisionsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCleanRoomAssetRevisionsResponse{} + conv88, err := convertSlice(v.Revisions, CleanRoomAssetFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCleanRoomAssetRevisionsResponse.Revisions", err) + } + out.Revisions = conv88 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListCleanRoomAssetsRequestToSDK converts the mirror to the sdk-go type. +func ListCleanRoomAssetsRequestToSDK(w *ListCleanRoomAssetsRequest) (*sdk.ListCleanRoomAssetsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCleanRoomAssetsRequest{} + out.CleanRoomName = w.CleanRoomName + out.PageToken = w.PageToken + return out, nil +} + +// ListCleanRoomAssetsRequestFromSDK converts the sdk-go type to the mirror. +func ListCleanRoomAssetsRequestFromSDK(v *sdk.ListCleanRoomAssetsRequest) (*ListCleanRoomAssetsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCleanRoomAssetsRequest{} + out.CleanRoomName = v.CleanRoomName + out.PageToken = v.PageToken + return out, nil +} + +// ListCleanRoomAssetsResponseToSDK converts the mirror to the sdk-go type. +func ListCleanRoomAssetsResponseToSDK(w *ListCleanRoomAssetsResponse) (*sdk.ListCleanRoomAssetsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCleanRoomAssetsResponse{} + conv89, err := convertSlice(w.Assets, CleanRoomAssetToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCleanRoomAssetsResponse.Assets", err) + } + out.Assets = conv89 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCleanRoomAssetsResponseFromSDK converts the sdk-go type to the mirror. +func ListCleanRoomAssetsResponseFromSDK(v *sdk.ListCleanRoomAssetsResponse) (*ListCleanRoomAssetsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCleanRoomAssetsResponse{} + conv90, err := convertSlice(v.Assets, CleanRoomAssetFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCleanRoomAssetsResponse.Assets", err) + } + out.Assets = conv90 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListCleanRoomAutoApprovalRulesRequestToSDK converts the mirror to the sdk-go type. +func ListCleanRoomAutoApprovalRulesRequestToSDK(w *ListCleanRoomAutoApprovalRulesRequest) (*sdk.ListCleanRoomAutoApprovalRulesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCleanRoomAutoApprovalRulesRequest{} + out.CleanRoomName = w.CleanRoomName + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListCleanRoomAutoApprovalRulesRequestFromSDK converts the sdk-go type to the mirror. +func ListCleanRoomAutoApprovalRulesRequestFromSDK(v *sdk.ListCleanRoomAutoApprovalRulesRequest) (*ListCleanRoomAutoApprovalRulesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCleanRoomAutoApprovalRulesRequest{} + out.CleanRoomName = v.CleanRoomName + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListCleanRoomAutoApprovalRulesResponseToSDK converts the mirror to the sdk-go type. +func ListCleanRoomAutoApprovalRulesResponseToSDK(w *ListCleanRoomAutoApprovalRulesResponse) (*sdk.ListCleanRoomAutoApprovalRulesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCleanRoomAutoApprovalRulesResponse{} + conv91, err := convertSlice(w.Rules, CleanRoomAutoApprovalRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCleanRoomAutoApprovalRulesResponse.Rules", err) + } + out.Rules = conv91 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCleanRoomAutoApprovalRulesResponseFromSDK converts the sdk-go type to the mirror. +func ListCleanRoomAutoApprovalRulesResponseFromSDK(v *sdk.ListCleanRoomAutoApprovalRulesResponse) (*ListCleanRoomAutoApprovalRulesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCleanRoomAutoApprovalRulesResponse{} + conv92, err := convertSlice(v.Rules, CleanRoomAutoApprovalRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCleanRoomAutoApprovalRulesResponse.Rules", err) + } + out.Rules = conv92 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListCleanRoomNotebookTaskRunsRequestToSDK converts the mirror to the sdk-go type. +func ListCleanRoomNotebookTaskRunsRequestToSDK(w *ListCleanRoomNotebookTaskRunsRequest) (*sdk.ListCleanRoomNotebookTaskRunsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCleanRoomNotebookTaskRunsRequest{} + out.CleanRoomName = w.CleanRoomName + out.NotebookName = w.NotebookName + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListCleanRoomNotebookTaskRunsRequestFromSDK converts the sdk-go type to the mirror. +func ListCleanRoomNotebookTaskRunsRequestFromSDK(v *sdk.ListCleanRoomNotebookTaskRunsRequest) (*ListCleanRoomNotebookTaskRunsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCleanRoomNotebookTaskRunsRequest{} + out.CleanRoomName = v.CleanRoomName + out.NotebookName = v.NotebookName + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListCleanRoomNotebookTaskRunsResponseToSDK converts the mirror to the sdk-go type. +func ListCleanRoomNotebookTaskRunsResponseToSDK(w *ListCleanRoomNotebookTaskRunsResponse) (*sdk.ListCleanRoomNotebookTaskRunsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCleanRoomNotebookTaskRunsResponse{} + conv93, err := convertSlice(w.Runs, CleanRoomNotebookTaskRunToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCleanRoomNotebookTaskRunsResponse.Runs", err) + } + out.Runs = conv93 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCleanRoomNotebookTaskRunsResponseFromSDK converts the sdk-go type to the mirror. +func ListCleanRoomNotebookTaskRunsResponseFromSDK(v *sdk.ListCleanRoomNotebookTaskRunsResponse) (*ListCleanRoomNotebookTaskRunsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCleanRoomNotebookTaskRunsResponse{} + conv94, err := convertSlice(v.Runs, CleanRoomNotebookTaskRunFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCleanRoomNotebookTaskRunsResponse.Runs", err) + } + out.Runs = conv94 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListCleanRoomTaskRunsRequestToSDK converts the mirror to the sdk-go type. +func ListCleanRoomTaskRunsRequestToSDK(w *ListCleanRoomTaskRunsRequest) (*sdk.ListCleanRoomTaskRunsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCleanRoomTaskRunsRequest{} + out.CleanRoomName = w.CleanRoomName + out.Name = w.Name + out.TaskType = w.TaskType + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListCleanRoomTaskRunsRequestFromSDK converts the sdk-go type to the mirror. +func ListCleanRoomTaskRunsRequestFromSDK(v *sdk.ListCleanRoomTaskRunsRequest) (*ListCleanRoomTaskRunsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCleanRoomTaskRunsRequest{} + out.CleanRoomName = v.CleanRoomName + out.Name = v.Name + out.TaskType = v.TaskType + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListCleanRoomTaskRunsResponseToSDK converts the mirror to the sdk-go type. +func ListCleanRoomTaskRunsResponseToSDK(w *ListCleanRoomTaskRunsResponse) (*sdk.ListCleanRoomTaskRunsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCleanRoomTaskRunsResponse{} + conv95, err := convertSlice(w.Runs, CleanRoomTaskRunToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCleanRoomTaskRunsResponse.Runs", err) + } + out.Runs = conv95 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCleanRoomTaskRunsResponseFromSDK converts the sdk-go type to the mirror. +func ListCleanRoomTaskRunsResponseFromSDK(v *sdk.ListCleanRoomTaskRunsResponse) (*ListCleanRoomTaskRunsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCleanRoomTaskRunsResponse{} + conv96, err := convertSlice(v.Runs, CleanRoomTaskRunFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCleanRoomTaskRunsResponse.Runs", err) + } + out.Runs = conv96 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListCleanRoomsRequestToSDK converts the mirror to the sdk-go type. +func ListCleanRoomsRequestToSDK(w *ListCleanRoomsRequest) (*sdk.ListCleanRoomsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCleanRoomsRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListCleanRoomsRequestFromSDK converts the sdk-go type to the mirror. +func ListCleanRoomsRequestFromSDK(v *sdk.ListCleanRoomsRequest) (*ListCleanRoomsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCleanRoomsRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListCleanRoomsResponseToSDK converts the mirror to the sdk-go type. +func ListCleanRoomsResponseToSDK(w *ListCleanRoomsResponse) (*sdk.ListCleanRoomsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCleanRoomsResponse{} + conv97, err := convertSlice(w.CleanRooms, CleanRoomToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCleanRoomsResponse.CleanRooms", err) + } + out.CleanRooms = conv97 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCleanRoomsResponseFromSDK converts the sdk-go type to the mirror. +func ListCleanRoomsResponseFromSDK(v *sdk.ListCleanRoomsResponse) (*ListCleanRoomsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCleanRoomsResponse{} + conv98, err := convertSlice(v.CleanRooms, CleanRoomFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCleanRoomsResponse.CleanRooms", err) + } + out.CleanRooms = conv98 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// NotebookVersionReviewToSDK converts the mirror to the sdk-go type. +func NotebookVersionReviewToSDK(w *NotebookVersionReview) (*sdk.NotebookVersionReview, error) { + if w == nil { + return nil, nil + } + out := &sdk.NotebookVersionReview{} + out.Etag = w.Etag + out.ReviewState = w.ReviewState + out.Comment = w.Comment + return out, nil +} + +// NotebookVersionReviewFromSDK converts the sdk-go type to the mirror. +func NotebookVersionReviewFromSDK(v *sdk.NotebookVersionReview) (*NotebookVersionReview, error) { + if v == nil { + return nil, nil + } + out := &NotebookVersionReview{} + out.Etag = v.Etag + out.ReviewState = v.ReviewState + out.Comment = v.Comment + return out, nil +} + +// PartitionSpecification_PartitionToSDK converts the mirror to the sdk-go type. +func PartitionSpecification_PartitionToSDK(w *PartitionSpecification_Partition) (*sdk.PartitionSpecification_Partition, error) { + if w == nil { + return nil, nil + } + out := &sdk.PartitionSpecification_Partition{} + conv99, err := convertSlice(w.Values, PartitionSpecification_Partition_PartitionValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PartitionSpecification_Partition.Values", err) + } + out.Values = conv99 + return out, nil +} + +// PartitionSpecification_PartitionFromSDK converts the sdk-go type to the mirror. +func PartitionSpecification_PartitionFromSDK(v *sdk.PartitionSpecification_Partition) (*PartitionSpecification_Partition, error) { + if v == nil { + return nil, nil + } + out := &PartitionSpecification_Partition{} + conv100, err := convertSlice(v.Values, PartitionSpecification_Partition_PartitionValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PartitionSpecification_Partition.Values", err) + } + out.Values = conv100 + return out, nil +} + +// PartitionSpecification_Partition_PartitionValueToSDK converts the mirror to the sdk-go type. +func PartitionSpecification_Partition_PartitionValueToSDK(w *PartitionSpecification_Partition_PartitionValue) (*sdk.PartitionSpecification_Partition_PartitionValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.PartitionSpecification_Partition_PartitionValue{} + out.Name = w.Name + out.Value = w.Value + out.RecipientPropertyKey = w.RecipientPropertyKey + out.Op = w.Op + return out, nil +} + +// PartitionSpecification_Partition_PartitionValueFromSDK converts the sdk-go type to the mirror. +func PartitionSpecification_Partition_PartitionValueFromSDK(v *sdk.PartitionSpecification_Partition_PartitionValue) (*PartitionSpecification_Partition_PartitionValue, error) { + if v == nil { + return nil, nil + } + out := &PartitionSpecification_Partition_PartitionValue{} + out.Name = v.Name + out.Value = v.Value + out.RecipientPropertyKey = v.RecipientPropertyKey + out.Op = v.Op + return out, nil +} + +// PolicyFunctionArgumentToSDK converts the mirror to the sdk-go type. +func PolicyFunctionArgumentToSDK(w *PolicyFunctionArgument) (*sdk.PolicyFunctionArgument, error) { + if w == nil { + return nil, nil + } + out := &sdk.PolicyFunctionArgument{} + { + var members []string + if w.Column != nil { + members = append(members, "column") + } + if w.Constant != nil { + members = append(members, "constant") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Column != nil: + out.Arg = &sdk.PolicyFunctionArgument_Arg_Column{Column: *w.Column} + case w.Constant != nil: + out.Arg = &sdk.PolicyFunctionArgument_Arg_Constant{Constant: *w.Constant} + } + return out, nil +} + +// PolicyFunctionArgumentFromSDK converts the sdk-go type to the mirror. +func PolicyFunctionArgumentFromSDK(v *sdk.PolicyFunctionArgument) (*PolicyFunctionArgument, error) { + if v == nil { + return nil, nil + } + out := &PolicyFunctionArgument{} + switch value := v.Arg.(type) { + case *sdk.PolicyFunctionArgument_Arg_Column: + if value != nil { + out.Column = new(value.Column) + } + case *sdk.PolicyFunctionArgument_Arg_Constant: + if value != nil { + out.Constant = new(value.Constant) + } + } + return out, nil +} + +// UpdateCleanRoomAssetRequestToSDK converts the mirror to the sdk-go type. +func UpdateCleanRoomAssetRequestToSDK(w *UpdateCleanRoomAssetRequest) (*sdk.UpdateCleanRoomAssetRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCleanRoomAssetRequest{} + out.CleanRoomName = w.CleanRoomName + conv101, err := CleanRoomAssetToSDK(w.Asset) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCleanRoomAssetRequest.Asset", err) + } + out.Asset = conv101 + return out, nil +} + +// UpdateCleanRoomAssetRequestFromSDK converts the sdk-go type to the mirror. +func UpdateCleanRoomAssetRequestFromSDK(v *sdk.UpdateCleanRoomAssetRequest) (*UpdateCleanRoomAssetRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateCleanRoomAssetRequest{} + out.CleanRoomName = v.CleanRoomName + conv102, err := CleanRoomAssetFromSDK(v.Asset) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCleanRoomAssetRequest.Asset", err) + } + out.Asset = conv102 + return out, nil +} + +// UpdateCleanRoomAutoApprovalRuleRequestToSDK converts the mirror to the sdk-go type. +func UpdateCleanRoomAutoApprovalRuleRequestToSDK(w *UpdateCleanRoomAutoApprovalRuleRequest) (*sdk.UpdateCleanRoomAutoApprovalRuleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCleanRoomAutoApprovalRuleRequest{} + conv103, err := CleanRoomAutoApprovalRuleToSDK(w.AutoApprovalRule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCleanRoomAutoApprovalRuleRequest.AutoApprovalRule", err) + } + out.AutoApprovalRule = conv103 + return out, nil +} + +// UpdateCleanRoomAutoApprovalRuleRequestFromSDK converts the sdk-go type to the mirror. +func UpdateCleanRoomAutoApprovalRuleRequestFromSDK(v *sdk.UpdateCleanRoomAutoApprovalRuleRequest) (*UpdateCleanRoomAutoApprovalRuleRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateCleanRoomAutoApprovalRuleRequest{} + conv104, err := CleanRoomAutoApprovalRuleFromSDK(v.AutoApprovalRule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCleanRoomAutoApprovalRuleRequest.AutoApprovalRule", err) + } + out.AutoApprovalRule = conv104 + return out, nil +} + +// UpdateCleanRoomRequestToSDK converts the mirror to the sdk-go type. +func UpdateCleanRoomRequestToSDK(w *UpdateCleanRoomRequest) (*sdk.UpdateCleanRoomRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCleanRoomRequest{} + out.Name = w.Name + conv105, err := CleanRoomToSDK(w.CleanRoom) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCleanRoomRequest.CleanRoom", err) + } + out.CleanRoom = conv105 + return out, nil +} + +// UpdateCleanRoomRequestFromSDK converts the sdk-go type to the mirror. +func UpdateCleanRoomRequestFromSDK(v *sdk.UpdateCleanRoomRequest) (*UpdateCleanRoomRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateCleanRoomRequest{} + out.Name = v.Name + conv106, err := CleanRoomFromSDK(v.CleanRoom) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCleanRoomRequest.CleanRoom", err) + } + out.CleanRoom = conv106 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/clusterlibraries/v2/types.generated.go b/libs/sdktypes/clusterlibraries/v2/types.generated.go new file mode 100644 index 00000000000..80366c44f44 --- /dev/null +++ b/libs/sdktypes/clusterlibraries/v2/types.generated.go @@ -0,0 +1,480 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/clusterlibraries/v2. DO NOT EDIT. + +package clusterlibraries + +import ( + fmt "fmt" + sdk "github.com/databricks/sdk-go/clusterlibraries/v2" + strings "strings" +) + +type ( + LibraryInstallStatus = sdk.LibraryInstallStatus +) + +const ( + LibraryInstallStatus_Unspecified = sdk.LibraryInstallStatus_Unspecified + LibraryInstallStatus_Resolving = sdk.LibraryInstallStatus_Resolving + LibraryInstallStatus_Installing = sdk.LibraryInstallStatus_Installing + LibraryInstallStatus_Installed = sdk.LibraryInstallStatus_Installed + LibraryInstallStatus_Failed = sdk.LibraryInstallStatus_Failed + LibraryInstallStatus_UninstallOnRestart = sdk.LibraryInstallStatus_UninstallOnRestart + LibraryInstallStatus_Skipped = sdk.LibraryInstallStatus_Skipped + LibraryInstallStatus_Restored = sdk.LibraryInstallStatus_Restored +) + +type ClusterLibraryStatuses struct { + // Unique identifier for the cluster. + ClusterId *string `json:"cluster_id,omitempty"` + // Status of all libraries on the cluster. + LibraryStatuses []LibraryFullStatus `json:"library_statuses,omitempty"` +} + +type ClusterStatusRequest struct { + // Unique identifier of the cluster whose status should be retrieved. + ClusterId *string `json:"cluster_id,omitempty"` +} + +type InstallLibrariesRequest struct { + // Unique identifier for the cluster on which to install these libraries. + ClusterId *string `json:"cluster_id,omitempty"` + // The libraries to install. + Libraries []Library `json:"libraries,omitempty"` +} + +type Library struct { + Cran *RCranLibrary `json:"cran,omitempty"` + Egg *string `json:"egg,omitempty"` + Jar *string `json:"jar,omitempty"` + Maven *MavenLibrary `json:"maven,omitempty"` + Pypi *PythonPyPiLibrary `json:"pypi,omitempty"` + Requirements *string `json:"requirements,omitempty"` + Whl *string `json:"whl,omitempty"` +} + +// The status of the library on a specific cluster.. +type LibraryFullStatus struct { + // Whether the library was set to be installed on all clusters via the libraries + // UI. + IsLibraryForAllClusters *bool `json:"is_library_for_all_clusters,omitempty"` + // Unique identifier for the library. + Library *Library `json:"library,omitempty"` + // All the info and warning messages that have occurred so far for this library. + Messages []string `json:"messages,omitempty"` + // Status of installing the library on the cluster. + Status LibraryInstallStatus `json:"status,omitempty"` +} + +type ListAllClusterLibraryStatusesResponse struct { + // A list of cluster statuses. + Statuses []ClusterLibraryStatuses `json:"statuses,omitempty"` +} + +type MavenLibrary struct { + // Gradle-style maven coordinates. For example: "org.jsoup:jsoup:1.7.2". + Coordinates *string `json:"coordinates,omitempty"` + // List of dependences to exclude. For example: `["slf4j:slf4j", + // "*:hadoop-client"]`. + // + // Maven dependency exclusions: + // https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html. + Exclusions []string `json:"exclusions,omitempty"` + // Maven repo to install the Maven package from. If omitted, both Maven Central + // Repository and Spark Packages are searched. + Repo *string `json:"repo,omitempty"` +} + +type PythonPyPiLibrary struct { + // The name of the pypi package to install. An optional exact version + // specification is also supported. Examples: "simplejson" and + // "simplejson==3.8.0". + Package *string `json:"package,omitempty"` + // The repository where the package can be found. If not specified, the default + // pip index is used. + Repo *string `json:"repo,omitempty"` +} + +type RCranLibrary struct { + // The name of the CRAN package to install. + Package *string `json:"package,omitempty"` + // The repository where the package can be found. If not specified, the default + // CRAN repo is used. + Repo *string `json:"repo,omitempty"` +} + +type UninstallLibrariesRequest struct { + // Unique identifier for the cluster on which to uninstall these libraries. + ClusterId *string `json:"cluster_id,omitempty"` + // The libraries to uninstall. + Libraries []Library `json:"libraries,omitempty"` +} + +// ClusterLibraryStatusesToSDK converts the mirror to the sdk-go type. +func ClusterLibraryStatusesToSDK(w *ClusterLibraryStatuses) (*sdk.ClusterLibraryStatuses, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterLibraryStatuses{} + out.ClusterId = w.ClusterId + conv1, err := convertSlice(w.LibraryStatuses, LibraryFullStatusToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLibraryStatuses.LibraryStatuses", err) + } + out.LibraryStatuses = conv1 + return out, nil +} + +// ClusterLibraryStatusesFromSDK converts the sdk-go type to the mirror. +func ClusterLibraryStatusesFromSDK(v *sdk.ClusterLibraryStatuses) (*ClusterLibraryStatuses, error) { + if v == nil { + return nil, nil + } + out := &ClusterLibraryStatuses{} + out.ClusterId = v.ClusterId + conv2, err := convertSlice(v.LibraryStatuses, LibraryFullStatusFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLibraryStatuses.LibraryStatuses", err) + } + out.LibraryStatuses = conv2 + return out, nil +} + +// ClusterStatusRequestToSDK converts the mirror to the sdk-go type. +func ClusterStatusRequestToSDK(w *ClusterStatusRequest) (*sdk.ClusterStatusRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterStatusRequest{} + out.ClusterId = w.ClusterId + return out, nil +} + +// ClusterStatusRequestFromSDK converts the sdk-go type to the mirror. +func ClusterStatusRequestFromSDK(v *sdk.ClusterStatusRequest) (*ClusterStatusRequest, error) { + if v == nil { + return nil, nil + } + out := &ClusterStatusRequest{} + out.ClusterId = v.ClusterId + return out, nil +} + +// InstallLibrariesRequestToSDK converts the mirror to the sdk-go type. +func InstallLibrariesRequestToSDK(w *InstallLibrariesRequest) (*sdk.InstallLibrariesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.InstallLibrariesRequest{} + out.ClusterId = w.ClusterId + conv3, err := convertSlice(w.Libraries, LibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstallLibrariesRequest.Libraries", err) + } + out.Libraries = conv3 + return out, nil +} + +// InstallLibrariesRequestFromSDK converts the sdk-go type to the mirror. +func InstallLibrariesRequestFromSDK(v *sdk.InstallLibrariesRequest) (*InstallLibrariesRequest, error) { + if v == nil { + return nil, nil + } + out := &InstallLibrariesRequest{} + out.ClusterId = v.ClusterId + conv4, err := convertSlice(v.Libraries, LibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstallLibrariesRequest.Libraries", err) + } + out.Libraries = conv4 + return out, nil +} + +// LibraryToSDK converts the mirror to the sdk-go type. +func LibraryToSDK(w *Library) (*sdk.Library, error) { + if w == nil { + return nil, nil + } + out := &sdk.Library{} + { + var members []string + if w.Jar != nil { + members = append(members, "jar") + } + if w.Egg != nil { + members = append(members, "egg") + } + if w.Pypi != nil { + members = append(members, "pypi") + } + if w.Maven != nil { + members = append(members, "maven") + } + if w.Cran != nil { + members = append(members, "cran") + } + if w.Whl != nil { + members = append(members, "whl") + } + if w.Requirements != nil { + members = append(members, "requirements") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Jar != nil: + out.Lib = &sdk.Library_Lib_Jar{Jar: *w.Jar} + case w.Egg != nil: + out.Lib = &sdk.Library_Lib_Egg{Egg: *w.Egg} + case w.Pypi != nil: + conv5, err := PythonPyPiLibraryToSDK(w.Pypi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Lib = &sdk.Library_Lib_Pypi{Pypi: *conv5} + case w.Maven != nil: + conv6, err := MavenLibraryToSDK(w.Maven) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Lib = &sdk.Library_Lib_Maven{Maven: *conv6} + case w.Cran != nil: + conv7, err := RCranLibraryToSDK(w.Cran) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Lib = &sdk.Library_Lib_Cran{Cran: *conv7} + case w.Whl != nil: + out.Lib = &sdk.Library_Lib_Whl{Whl: *w.Whl} + case w.Requirements != nil: + out.Lib = &sdk.Library_Lib_Requirements{Requirements: *w.Requirements} + } + return out, nil +} + +// LibraryFromSDK converts the sdk-go type to the mirror. +func LibraryFromSDK(v *sdk.Library) (*Library, error) { + if v == nil { + return nil, nil + } + out := &Library{} + switch value := v.Lib.(type) { + case *sdk.Library_Lib_Jar: + if value != nil { + out.Jar = new(value.Jar) + } + case *sdk.Library_Lib_Egg: + if value != nil { + out.Egg = new(value.Egg) + } + case *sdk.Library_Lib_Pypi: + if value != nil { + conv8, err := PythonPyPiLibraryFromSDK(&value.Pypi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Pypi = conv8 + } + case *sdk.Library_Lib_Maven: + if value != nil { + conv9, err := MavenLibraryFromSDK(&value.Maven) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Maven = conv9 + } + case *sdk.Library_Lib_Cran: + if value != nil { + conv10, err := RCranLibraryFromSDK(&value.Cran) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Cran = conv10 + } + case *sdk.Library_Lib_Whl: + if value != nil { + out.Whl = new(value.Whl) + } + case *sdk.Library_Lib_Requirements: + if value != nil { + out.Requirements = new(value.Requirements) + } + } + return out, nil +} + +// LibraryFullStatusToSDK converts the mirror to the sdk-go type. +func LibraryFullStatusToSDK(w *LibraryFullStatus) (*sdk.LibraryFullStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.LibraryFullStatus{} + conv11, err := LibraryToSDK(w.Library) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LibraryFullStatus.Library", err) + } + out.Library = conv11 + out.Status = w.Status + out.Messages = w.Messages + out.IsLibraryForAllClusters = w.IsLibraryForAllClusters + return out, nil +} + +// LibraryFullStatusFromSDK converts the sdk-go type to the mirror. +func LibraryFullStatusFromSDK(v *sdk.LibraryFullStatus) (*LibraryFullStatus, error) { + if v == nil { + return nil, nil + } + out := &LibraryFullStatus{} + conv12, err := LibraryFromSDK(v.Library) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LibraryFullStatus.Library", err) + } + out.Library = conv12 + out.Status = v.Status + out.Messages = v.Messages + out.IsLibraryForAllClusters = v.IsLibraryForAllClusters + return out, nil +} + +// ListAllClusterLibraryStatusesResponseToSDK converts the mirror to the sdk-go type. +func ListAllClusterLibraryStatusesResponseToSDK(w *ListAllClusterLibraryStatusesResponse) (*sdk.ListAllClusterLibraryStatusesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAllClusterLibraryStatusesResponse{} + conv13, err := convertSlice(w.Statuses, ClusterLibraryStatusesToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAllClusterLibraryStatusesResponse.Statuses", err) + } + out.Statuses = conv13 + return out, nil +} + +// ListAllClusterLibraryStatusesResponseFromSDK converts the sdk-go type to the mirror. +func ListAllClusterLibraryStatusesResponseFromSDK(v *sdk.ListAllClusterLibraryStatusesResponse) (*ListAllClusterLibraryStatusesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAllClusterLibraryStatusesResponse{} + conv14, err := convertSlice(v.Statuses, ClusterLibraryStatusesFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAllClusterLibraryStatusesResponse.Statuses", err) + } + out.Statuses = conv14 + return out, nil +} + +// MavenLibraryToSDK converts the mirror to the sdk-go type. +func MavenLibraryToSDK(w *MavenLibrary) (*sdk.MavenLibrary, error) { + if w == nil { + return nil, nil + } + out := &sdk.MavenLibrary{} + out.Coordinates = w.Coordinates + out.Repo = w.Repo + out.Exclusions = w.Exclusions + return out, nil +} + +// MavenLibraryFromSDK converts the sdk-go type to the mirror. +func MavenLibraryFromSDK(v *sdk.MavenLibrary) (*MavenLibrary, error) { + if v == nil { + return nil, nil + } + out := &MavenLibrary{} + out.Coordinates = v.Coordinates + out.Repo = v.Repo + out.Exclusions = v.Exclusions + return out, nil +} + +// PythonPyPiLibraryToSDK converts the mirror to the sdk-go type. +func PythonPyPiLibraryToSDK(w *PythonPyPiLibrary) (*sdk.PythonPyPiLibrary, error) { + if w == nil { + return nil, nil + } + out := &sdk.PythonPyPiLibrary{} + out.Package = w.Package + out.Repo = w.Repo + return out, nil +} + +// PythonPyPiLibraryFromSDK converts the sdk-go type to the mirror. +func PythonPyPiLibraryFromSDK(v *sdk.PythonPyPiLibrary) (*PythonPyPiLibrary, error) { + if v == nil { + return nil, nil + } + out := &PythonPyPiLibrary{} + out.Package = v.Package + out.Repo = v.Repo + return out, nil +} + +// RCranLibraryToSDK converts the mirror to the sdk-go type. +func RCranLibraryToSDK(w *RCranLibrary) (*sdk.RCranLibrary, error) { + if w == nil { + return nil, nil + } + out := &sdk.RCranLibrary{} + out.Package = w.Package + out.Repo = w.Repo + return out, nil +} + +// RCranLibraryFromSDK converts the sdk-go type to the mirror. +func RCranLibraryFromSDK(v *sdk.RCranLibrary) (*RCranLibrary, error) { + if v == nil { + return nil, nil + } + out := &RCranLibrary{} + out.Package = v.Package + out.Repo = v.Repo + return out, nil +} + +// UninstallLibrariesRequestToSDK converts the mirror to the sdk-go type. +func UninstallLibrariesRequestToSDK(w *UninstallLibrariesRequest) (*sdk.UninstallLibrariesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UninstallLibrariesRequest{} + out.ClusterId = w.ClusterId + conv15, err := convertSlice(w.Libraries, LibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UninstallLibrariesRequest.Libraries", err) + } + out.Libraries = conv15 + return out, nil +} + +// UninstallLibrariesRequestFromSDK converts the sdk-go type to the mirror. +func UninstallLibrariesRequestFromSDK(v *sdk.UninstallLibrariesRequest) (*UninstallLibrariesRequest, error) { + if v == nil { + return nil, nil + } + out := &UninstallLibrariesRequest{} + out.ClusterId = v.ClusterId + conv16, err := convertSlice(v.Libraries, LibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UninstallLibrariesRequest.Libraries", err) + } + out.Libraries = conv16 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/clusterpolicies/v2/types.generated.go b/libs/sdktypes/clusterpolicies/v2/types.generated.go new file mode 100644 index 00000000000..9d467c97a59 --- /dev/null +++ b/libs/sdktypes/clusterpolicies/v2/types.generated.go @@ -0,0 +1,655 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/clusterpolicies/v2. DO NOT EDIT. + +package clusterpolicies + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/clusterpolicies/v2" + + strings "strings" +) + +type ( + ListOrder = sdk.ListOrder + PolicySortColumn = sdk.PolicySortColumn +) + +const ( + ListOrder_Unspecified = sdk.ListOrder_Unspecified + ListOrder_Desc = sdk.ListOrder_Desc + ListOrder_Asc = sdk.ListOrder_Asc + PolicySortColumn_Unspecified = sdk.PolicySortColumn_Unspecified + PolicySortColumn_PolicyCreationTime = sdk.PolicySortColumn_PolicyCreationTime + PolicySortColumn_PolicyName = sdk.PolicySortColumn_PolicyName +) + +type CreatePolicyRequest struct { + // Policy definition document expressed in [Databricks Cluster Policy Definition + // Language]. + // + // [Databricks Cluster Policy Definition Language]: https://docs.databricks.com/administration-guide/clusters/policy-definition.html + Definition *string `json:"definition,omitempty"` + // Additional human-readable description of the cluster policy. + Description *string `json:"description,omitempty"` + // A list of libraries to be installed on the next cluster restart that uses + // this policy. The maximum number of libraries is 500. + Libraries []Library `json:"libraries,omitempty"` + // Max number of clusters per user that can be active using this policy. If not + // present, there is no max limit. + MaxClustersPerUser *int64 `json:"max_clusters_per_user,omitempty"` + // Cluster Policy name requested by the user. This has to be unique. Length must + // be between 1 and 100 characters. + Name *string `json:"name,omitempty"` + // Policy definition JSON document expressed in [Databricks Policy Definition + // Language]. The JSON document must be passed as a string and cannot be + // embedded in the requests. + // + // You can use this to customize the policy definition inherited from the policy + // family. Policy rules specified here are merged into the inherited policy + // definition. + // + // [Databricks Policy Definition Language]: https://docs.databricks.com/administration-guide/clusters/policy-definition.html + PolicyFamilyDefinitionOverrides *string `json:"policy_family_definition_overrides,omitempty"` + // ID of the policy family. The cluster policy's policy definition inherits the + // policy family's policy definition. + // + // Cannot be used with `definition`. Use `policy_family_definition_overrides` + // instead to customize the policy definition. + PolicyFamilyId *string `json:"policy_family_id,omitempty"` +} + +type CreatePolicyResponse struct { + // Canonical unique identifier for the cluster policy. + PolicyId *string `json:"policy_id,omitempty"` +} + +type DeletePolicyRequest struct { + // The ID of the policy to delete. + PolicyId *string `json:"policy_id,omitempty"` +} + +type EditPolicyRequest struct { + // Policy definition document expressed in [Databricks Cluster Policy Definition + // Language]. + // + // [Databricks Cluster Policy Definition Language]: https://docs.databricks.com/administration-guide/clusters/policy-definition.html + Definition *string `json:"definition,omitempty"` + // Additional human-readable description of the cluster policy. + Description *string `json:"description,omitempty"` + // A list of libraries to be installed on the next cluster restart that uses + // this policy. The maximum number of libraries is 500. + Libraries []Library `json:"libraries,omitempty"` + // Max number of clusters per user that can be active using this policy. If not + // present, there is no max limit. + MaxClustersPerUser *int64 `json:"max_clusters_per_user,omitempty"` + // Cluster Policy name requested by the user. This has to be unique. Length must + // be between 1 and 100 characters. + Name *string `json:"name,omitempty"` + // Policy definition JSON document expressed in [Databricks Policy Definition + // Language]. The JSON document must be passed as a string and cannot be + // embedded in the requests. + // + // You can use this to customize the policy definition inherited from the policy + // family. Policy rules specified here are merged into the inherited policy + // definition. + // + // [Databricks Policy Definition Language]: https://docs.databricks.com/administration-guide/clusters/policy-definition.html + PolicyFamilyDefinitionOverrides *string `json:"policy_family_definition_overrides,omitempty"` + // ID of the policy family. The cluster policy's policy definition inherits the + // policy family's policy definition. + // + // Cannot be used with `definition`. Use `policy_family_definition_overrides` + // instead to customize the policy definition. + PolicyFamilyId *string `json:"policy_family_id,omitempty"` + // The ID of the policy to update. + PolicyId *string `json:"policy_id,omitempty"` +} + +type GetPolicyRequest struct { + // Canonical unique identifier for the Cluster Policy. + PolicyId *string `json:"policy_id,omitempty"` +} + +type Library struct { + Cran *RCranLibrary `json:"cran,omitempty"` + Egg *string `json:"egg,omitempty"` + Jar *string `json:"jar,omitempty"` + Maven *MavenLibrary `json:"maven,omitempty"` + Pypi *PythonPyPiLibrary `json:"pypi,omitempty"` + Requirements *string `json:"requirements,omitempty"` + Whl *string `json:"whl,omitempty"` +} + +type ListPoliciesRequest struct { + // The cluster policy attribute to sort by. * `POLICY_CREATION_TIME` - Sort + // result list by policy creation time. * `POLICY_NAME` - Sort result list by + // policy name. + SortColumn PolicySortColumn `json:"sort_column,omitempty"` + // The order in which the policies get listed. * `DESC` - Sort result list in + // descending order. * `ASC` - Sort result list in ascending order. + SortOrder ListOrder `json:"sort_order,omitempty"` +} + +type ListPoliciesResponse struct { + // List of policies. + Policies []Policy `json:"policies,omitempty"` +} + +type MavenLibrary struct { + // Gradle-style maven coordinates. For example: "org.jsoup:jsoup:1.7.2". + Coordinates *string `json:"coordinates,omitempty"` + // List of dependences to exclude. For example: `["slf4j:slf4j", + // "*:hadoop-client"]`. + // + // Maven dependency exclusions: + // https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html. + Exclusions []string `json:"exclusions,omitempty"` + // Maven repo to install the Maven package from. If omitted, both Maven Central + // Repository and Spark Packages are searched. + Repo *string `json:"repo,omitempty"` +} + +// Describes a Cluster Policy entity.. +type Policy struct { + // Creation time. The timestamp (in millisecond) when this Cluster Policy was + // created. + CreatedAtTimestamp *int64 `json:"created_at_timestamp,omitempty"` + // Creator user name. The field won't be included in the response if the user + // has already been deleted. + CreatorUserName *string `json:"creator_user_name,omitempty"` + // Policy definition document expressed in [Databricks Cluster Policy Definition + // Language]. + // + // [Databricks Cluster Policy Definition Language]: https://docs.databricks.com/administration-guide/clusters/policy-definition.html + Definition *string `json:"definition,omitempty"` + // Additional human-readable description of the cluster policy. + Description *string `json:"description,omitempty"` + // If true, policy is a default policy created and managed by . + // Default policies cannot be deleted, and their policy families cannot be + // changed. + IsDefault *bool `json:"is_default,omitempty"` + // A list of libraries to be installed on the next cluster restart that uses + // this policy. The maximum number of libraries is 500. + Libraries []Library `json:"libraries,omitempty"` + // Max number of clusters per user that can be active using this policy. If not + // present, there is no max limit. + MaxClustersPerUser *int64 `json:"max_clusters_per_user,omitempty"` + // Cluster Policy name requested by the user. This has to be unique. Length must + // be between 1 and 100 characters. + Name *string `json:"name,omitempty"` + // Policy definition JSON document expressed in [Databricks Policy Definition + // Language]. The JSON document must be passed as a string and cannot be + // embedded in the requests. + // + // You can use this to customize the policy definition inherited from the policy + // family. Policy rules specified here are merged into the inherited policy + // definition. + // + // [Databricks Policy Definition Language]: https://docs.databricks.com/administration-guide/clusters/policy-definition.html + PolicyFamilyDefinitionOverrides *string `json:"policy_family_definition_overrides,omitempty"` + // ID of the policy family. The cluster policy's policy definition inherits the + // policy family's policy definition. + // + // Cannot be used with `definition`. Use `policy_family_definition_overrides` + // instead to customize the policy definition. + PolicyFamilyId *string `json:"policy_family_id,omitempty"` + // Canonical unique identifier for the Cluster Policy. + PolicyId *string `json:"policy_id,omitempty"` +} + +type PythonPyPiLibrary struct { + // The name of the pypi package to install. An optional exact version + // specification is also supported. Examples: "simplejson" and + // "simplejson==3.8.0". + Package *string `json:"package,omitempty"` + // The repository where the package can be found. If not specified, the default + // pip index is used. + Repo *string `json:"repo,omitempty"` +} + +type RCranLibrary struct { + // The name of the CRAN package to install. + Package *string `json:"package,omitempty"` + // The repository where the package can be found. If not specified, the default + // CRAN repo is used. + Repo *string `json:"repo,omitempty"` +} + +// CreatePolicyRequestToSDK converts the mirror to the sdk-go type. +func CreatePolicyRequestToSDK(w *CreatePolicyRequest) (*sdk.CreatePolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreatePolicyRequest{} + out.Name = w.Name + out.Definition = w.Definition + out.Description = w.Description + out.PolicyFamilyId = w.PolicyFamilyId + out.PolicyFamilyDefinitionOverrides = w.PolicyFamilyDefinitionOverrides + out.MaxClustersPerUser = w.MaxClustersPerUser + conv1, err := convertSlice(w.Libraries, LibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePolicyRequest.Libraries", err) + } + out.Libraries = conv1 + return out, nil +} + +// CreatePolicyRequestFromSDK converts the sdk-go type to the mirror. +func CreatePolicyRequestFromSDK(v *sdk.CreatePolicyRequest) (*CreatePolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &CreatePolicyRequest{} + out.Name = v.Name + out.Definition = v.Definition + out.Description = v.Description + out.PolicyFamilyId = v.PolicyFamilyId + out.PolicyFamilyDefinitionOverrides = v.PolicyFamilyDefinitionOverrides + out.MaxClustersPerUser = v.MaxClustersPerUser + conv2, err := convertSlice(v.Libraries, LibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePolicyRequest.Libraries", err) + } + out.Libraries = conv2 + return out, nil +} + +// CreatePolicyResponseToSDK converts the mirror to the sdk-go type. +func CreatePolicyResponseToSDK(w *CreatePolicyResponse) (*sdk.CreatePolicyResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreatePolicyResponse{} + out.PolicyId = w.PolicyId + return out, nil +} + +// CreatePolicyResponseFromSDK converts the sdk-go type to the mirror. +func CreatePolicyResponseFromSDK(v *sdk.CreatePolicyResponse) (*CreatePolicyResponse, error) { + if v == nil { + return nil, nil + } + out := &CreatePolicyResponse{} + out.PolicyId = v.PolicyId + return out, nil +} + +// DeletePolicyRequestToSDK converts the mirror to the sdk-go type. +func DeletePolicyRequestToSDK(w *DeletePolicyRequest) (*sdk.DeletePolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeletePolicyRequest{} + out.PolicyId = w.PolicyId + return out, nil +} + +// DeletePolicyRequestFromSDK converts the sdk-go type to the mirror. +func DeletePolicyRequestFromSDK(v *sdk.DeletePolicyRequest) (*DeletePolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &DeletePolicyRequest{} + out.PolicyId = v.PolicyId + return out, nil +} + +// EditPolicyRequestToSDK converts the mirror to the sdk-go type. +func EditPolicyRequestToSDK(w *EditPolicyRequest) (*sdk.EditPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.EditPolicyRequest{} + out.PolicyId = w.PolicyId + out.Name = w.Name + out.Definition = w.Definition + out.Description = w.Description + out.PolicyFamilyId = w.PolicyFamilyId + out.PolicyFamilyDefinitionOverrides = w.PolicyFamilyDefinitionOverrides + out.MaxClustersPerUser = w.MaxClustersPerUser + conv3, err := convertSlice(w.Libraries, LibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPolicyRequest.Libraries", err) + } + out.Libraries = conv3 + return out, nil +} + +// EditPolicyRequestFromSDK converts the sdk-go type to the mirror. +func EditPolicyRequestFromSDK(v *sdk.EditPolicyRequest) (*EditPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &EditPolicyRequest{} + out.PolicyId = v.PolicyId + out.Name = v.Name + out.Definition = v.Definition + out.Description = v.Description + out.PolicyFamilyId = v.PolicyFamilyId + out.PolicyFamilyDefinitionOverrides = v.PolicyFamilyDefinitionOverrides + out.MaxClustersPerUser = v.MaxClustersPerUser + conv4, err := convertSlice(v.Libraries, LibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPolicyRequest.Libraries", err) + } + out.Libraries = conv4 + return out, nil +} + +// GetPolicyRequestToSDK converts the mirror to the sdk-go type. +func GetPolicyRequestToSDK(w *GetPolicyRequest) (*sdk.GetPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPolicyRequest{} + out.PolicyId = w.PolicyId + return out, nil +} + +// GetPolicyRequestFromSDK converts the sdk-go type to the mirror. +func GetPolicyRequestFromSDK(v *sdk.GetPolicyRequest) (*GetPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &GetPolicyRequest{} + out.PolicyId = v.PolicyId + return out, nil +} + +// LibraryToSDK converts the mirror to the sdk-go type. +func LibraryToSDK(w *Library) (*sdk.Library, error) { + if w == nil { + return nil, nil + } + out := &sdk.Library{} + { + var members []string + if w.Jar != nil { + members = append(members, "jar") + } + if w.Egg != nil { + members = append(members, "egg") + } + if w.Pypi != nil { + members = append(members, "pypi") + } + if w.Maven != nil { + members = append(members, "maven") + } + if w.Cran != nil { + members = append(members, "cran") + } + if w.Whl != nil { + members = append(members, "whl") + } + if w.Requirements != nil { + members = append(members, "requirements") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Jar != nil: + out.Lib = &sdk.Library_Lib_Jar{Jar: *w.Jar} + case w.Egg != nil: + out.Lib = &sdk.Library_Lib_Egg{Egg: *w.Egg} + case w.Pypi != nil: + conv5, err := PythonPyPiLibraryToSDK(w.Pypi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Lib = &sdk.Library_Lib_Pypi{Pypi: *conv5} + case w.Maven != nil: + conv6, err := MavenLibraryToSDK(w.Maven) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Lib = &sdk.Library_Lib_Maven{Maven: *conv6} + case w.Cran != nil: + conv7, err := RCranLibraryToSDK(w.Cran) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Lib = &sdk.Library_Lib_Cran{Cran: *conv7} + case w.Whl != nil: + out.Lib = &sdk.Library_Lib_Whl{Whl: *w.Whl} + case w.Requirements != nil: + out.Lib = &sdk.Library_Lib_Requirements{Requirements: *w.Requirements} + } + return out, nil +} + +// LibraryFromSDK converts the sdk-go type to the mirror. +func LibraryFromSDK(v *sdk.Library) (*Library, error) { + if v == nil { + return nil, nil + } + out := &Library{} + switch value := v.Lib.(type) { + case *sdk.Library_Lib_Jar: + if value != nil { + out.Jar = new(value.Jar) + } + case *sdk.Library_Lib_Egg: + if value != nil { + out.Egg = new(value.Egg) + } + case *sdk.Library_Lib_Pypi: + if value != nil { + conv8, err := PythonPyPiLibraryFromSDK(&value.Pypi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Pypi = conv8 + } + case *sdk.Library_Lib_Maven: + if value != nil { + conv9, err := MavenLibraryFromSDK(&value.Maven) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Maven = conv9 + } + case *sdk.Library_Lib_Cran: + if value != nil { + conv10, err := RCranLibraryFromSDK(&value.Cran) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Cran = conv10 + } + case *sdk.Library_Lib_Whl: + if value != nil { + out.Whl = new(value.Whl) + } + case *sdk.Library_Lib_Requirements: + if value != nil { + out.Requirements = new(value.Requirements) + } + } + return out, nil +} + +// ListPoliciesRequestToSDK converts the mirror to the sdk-go type. +func ListPoliciesRequestToSDK(w *ListPoliciesRequest) (*sdk.ListPoliciesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPoliciesRequest{} + out.SortOrder = w.SortOrder + out.SortColumn = w.SortColumn + return out, nil +} + +// ListPoliciesRequestFromSDK converts the sdk-go type to the mirror. +func ListPoliciesRequestFromSDK(v *sdk.ListPoliciesRequest) (*ListPoliciesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListPoliciesRequest{} + out.SortOrder = v.SortOrder + out.SortColumn = v.SortColumn + return out, nil +} + +// ListPoliciesResponseToSDK converts the mirror to the sdk-go type. +func ListPoliciesResponseToSDK(w *ListPoliciesResponse) (*sdk.ListPoliciesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPoliciesResponse{} + conv11, err := convertSlice(w.Policies, PolicyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPoliciesResponse.Policies", err) + } + out.Policies = conv11 + return out, nil +} + +// ListPoliciesResponseFromSDK converts the sdk-go type to the mirror. +func ListPoliciesResponseFromSDK(v *sdk.ListPoliciesResponse) (*ListPoliciesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListPoliciesResponse{} + conv12, err := convertSlice(v.Policies, PolicyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPoliciesResponse.Policies", err) + } + out.Policies = conv12 + return out, nil +} + +// MavenLibraryToSDK converts the mirror to the sdk-go type. +func MavenLibraryToSDK(w *MavenLibrary) (*sdk.MavenLibrary, error) { + if w == nil { + return nil, nil + } + out := &sdk.MavenLibrary{} + out.Coordinates = w.Coordinates + out.Repo = w.Repo + out.Exclusions = w.Exclusions + return out, nil +} + +// MavenLibraryFromSDK converts the sdk-go type to the mirror. +func MavenLibraryFromSDK(v *sdk.MavenLibrary) (*MavenLibrary, error) { + if v == nil { + return nil, nil + } + out := &MavenLibrary{} + out.Coordinates = v.Coordinates + out.Repo = v.Repo + out.Exclusions = v.Exclusions + return out, nil +} + +// PolicyToSDK converts the mirror to the sdk-go type. +func PolicyToSDK(w *Policy) (*sdk.Policy, error) { + if w == nil { + return nil, nil + } + out := &sdk.Policy{} + out.PolicyId = w.PolicyId + out.CreatorUserName = w.CreatorUserName + out.CreatedAtTimestamp = w.CreatedAtTimestamp + out.IsDefault = w.IsDefault + out.Name = w.Name + out.Definition = w.Definition + out.Description = w.Description + out.PolicyFamilyId = w.PolicyFamilyId + out.PolicyFamilyDefinitionOverrides = w.PolicyFamilyDefinitionOverrides + out.MaxClustersPerUser = w.MaxClustersPerUser + conv13, err := convertSlice(w.Libraries, LibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Policy.Libraries", err) + } + out.Libraries = conv13 + return out, nil +} + +// PolicyFromSDK converts the sdk-go type to the mirror. +func PolicyFromSDK(v *sdk.Policy) (*Policy, error) { + if v == nil { + return nil, nil + } + out := &Policy{} + out.PolicyId = v.PolicyId + out.CreatorUserName = v.CreatorUserName + out.CreatedAtTimestamp = v.CreatedAtTimestamp + out.IsDefault = v.IsDefault + out.Name = v.Name + out.Definition = v.Definition + out.Description = v.Description + out.PolicyFamilyId = v.PolicyFamilyId + out.PolicyFamilyDefinitionOverrides = v.PolicyFamilyDefinitionOverrides + out.MaxClustersPerUser = v.MaxClustersPerUser + conv14, err := convertSlice(v.Libraries, LibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Policy.Libraries", err) + } + out.Libraries = conv14 + return out, nil +} + +// PythonPyPiLibraryToSDK converts the mirror to the sdk-go type. +func PythonPyPiLibraryToSDK(w *PythonPyPiLibrary) (*sdk.PythonPyPiLibrary, error) { + if w == nil { + return nil, nil + } + out := &sdk.PythonPyPiLibrary{} + out.Package = w.Package + out.Repo = w.Repo + return out, nil +} + +// PythonPyPiLibraryFromSDK converts the sdk-go type to the mirror. +func PythonPyPiLibraryFromSDK(v *sdk.PythonPyPiLibrary) (*PythonPyPiLibrary, error) { + if v == nil { + return nil, nil + } + out := &PythonPyPiLibrary{} + out.Package = v.Package + out.Repo = v.Repo + return out, nil +} + +// RCranLibraryToSDK converts the mirror to the sdk-go type. +func RCranLibraryToSDK(w *RCranLibrary) (*sdk.RCranLibrary, error) { + if w == nil { + return nil, nil + } + out := &sdk.RCranLibrary{} + out.Package = w.Package + out.Repo = w.Repo + return out, nil +} + +// RCranLibraryFromSDK converts the sdk-go type to the mirror. +func RCranLibraryFromSDK(v *sdk.RCranLibrary) (*RCranLibrary, error) { + if v == nil { + return nil, nil + } + out := &RCranLibrary{} + out.Package = v.Package + out.Repo = v.Repo + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/clusters/v2/types.generated.go b/libs/sdktypes/clusters/v2/types.generated.go new file mode 100644 index 00000000000..712af99fd6d --- /dev/null +++ b/libs/sdktypes/clusters/v2/types.generated.go @@ -0,0 +1,5827 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/clusters/v2. DO NOT EDIT. + +package clusters + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/clusters/v2" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + AwsAvailability = sdk.AwsAvailability + AzureAvailability = sdk.AzureAvailability + CloudProviderNodeStatus = sdk.CloudProviderNodeStatus + ComputeKind = sdk.ComputeKind + ConfidentialComputeType = sdk.ConfidentialComputeType + DataPlaneClusterEventType = sdk.DataPlaneClusterEventType + DataSecurityMode = sdk.DataSecurityMode + DependencyMode = sdk.DependencyMode + EbsVolumeType = sdk.EbsVolumeType + GcpAvailability = sdk.GcpAvailability + GetEventsOrder = sdk.GetEventsOrder + RuntimeEngine = sdk.RuntimeEngine + TerminationCode = sdk.TerminationCode + TerminationType = sdk.TerminationType + ClusterEventType_ClusterEventType = sdk.ClusterEventType_ClusterEventType + ClusterState_ClusterState = sdk.ClusterState_ClusterState + EnforcePolicyComplianceForClusterRequest_EnforceMode = sdk.EnforcePolicyComplianceForClusterRequest_EnforceMode + EnforcePolicyComplianceForClusterResponse_EnforceResult = sdk.EnforcePolicyComplianceForClusterResponse_EnforceResult + InitScriptExecutionDetails_InitScriptExecutionStatus = sdk.InitScriptExecutionDetails_InitScriptExecutionStatus + PendingEnforcement_EnforcementStatus = sdk.PendingEnforcement_EnforcementStatus + ResizeCause_ResizeCause = sdk.ResizeCause_ResizeCause +) + +const ( + AwsAvailability_Unspecified = sdk.AwsAvailability_Unspecified + AwsAvailability_Spot = sdk.AwsAvailability_Spot + AwsAvailability_OnDemand = sdk.AwsAvailability_OnDemand + AwsAvailability_SpotWithFallback = sdk.AwsAvailability_SpotWithFallback + AzureAvailability_Unspecified = sdk.AzureAvailability_Unspecified + AzureAvailability_SpotAzure = sdk.AzureAvailability_SpotAzure + AzureAvailability_OnDemandAzure = sdk.AzureAvailability_OnDemandAzure + AzureAvailability_SpotWithFallbackAzure = sdk.AzureAvailability_SpotWithFallbackAzure + CloudProviderNodeStatus_Unspecified = sdk.CloudProviderNodeStatus_Unspecified + CloudProviderNodeStatus_NotEnabledOnSubscription = sdk.CloudProviderNodeStatus_NotEnabledOnSubscription + CloudProviderNodeStatus_NotAvailableInRegion = sdk.CloudProviderNodeStatus_NotAvailableInRegion + ComputeKind_Unspecified = sdk.ComputeKind_Unspecified + ComputeKind_ClassicPreview = sdk.ComputeKind_ClassicPreview + ConfidentialComputeType_Unspecified = sdk.ConfidentialComputeType_Unspecified + ConfidentialComputeType_ConfidentialComputeTypeNone = sdk.ConfidentialComputeType_ConfidentialComputeTypeNone + ConfidentialComputeType_SevSnp = sdk.ConfidentialComputeType_SevSnp + DataPlaneClusterEventType_Unspecified = sdk.DataPlaneClusterEventType_Unspecified + DataPlaneClusterEventType_NodeBlacklisted = sdk.DataPlaneClusterEventType_NodeBlacklisted + DataPlaneClusterEventType_NodeExcludedDecommissioned = sdk.DataPlaneClusterEventType_NodeExcludedDecommissioned + DataSecurityMode_Unspecified = sdk.DataSecurityMode_Unspecified + DataSecurityMode_None = sdk.DataSecurityMode_None + DataSecurityMode_SingleUser = sdk.DataSecurityMode_SingleUser + DataSecurityMode_UserIsolation = sdk.DataSecurityMode_UserIsolation + DataSecurityMode_LegacyTableAcl = sdk.DataSecurityMode_LegacyTableAcl + DataSecurityMode_LegacyPassthrough = sdk.DataSecurityMode_LegacyPassthrough + DataSecurityMode_LegacySingleUser = sdk.DataSecurityMode_LegacySingleUser + DataSecurityMode_LegacySingleUserStandard = sdk.DataSecurityMode_LegacySingleUserStandard + DataSecurityMode_DataSecurityModeStandard = sdk.DataSecurityMode_DataSecurityModeStandard + DataSecurityMode_DataSecurityModeDedicated = sdk.DataSecurityMode_DataSecurityModeDedicated + DataSecurityMode_DataSecurityModeAuto = sdk.DataSecurityMode_DataSecurityModeAuto + DependencyMode_Unspecified = sdk.DependencyMode_Unspecified + DependencyMode_DependencyModeEnvironments = sdk.DependencyMode_DependencyModeEnvironments + DependencyMode_DependencyModeClusterLibraries = sdk.DependencyMode_DependencyModeClusterLibraries + DependencyMode_DependencyModeAuto = sdk.DependencyMode_DependencyModeAuto + EbsVolumeType_Unspecified = sdk.EbsVolumeType_Unspecified + EbsVolumeType_GeneralPurposeSsd = sdk.EbsVolumeType_GeneralPurposeSsd + EbsVolumeType_ThroughputOptimizedHdd = sdk.EbsVolumeType_ThroughputOptimizedHdd + GcpAvailability_Unspecified = sdk.GcpAvailability_Unspecified + GcpAvailability_PreemptibleGcp = sdk.GcpAvailability_PreemptibleGcp + GcpAvailability_OnDemandGcp = sdk.GcpAvailability_OnDemandGcp + GcpAvailability_PreemptibleWithFallbackGcp = sdk.GcpAvailability_PreemptibleWithFallbackGcp + GetEventsOrder_Unspecified = sdk.GetEventsOrder_Unspecified + GetEventsOrder_Desc = sdk.GetEventsOrder_Desc + GetEventsOrder_Asc = sdk.GetEventsOrder_Asc + RuntimeEngine_Unspecified = sdk.RuntimeEngine_Unspecified + RuntimeEngine_Standard = sdk.RuntimeEngine_Standard + RuntimeEngine_Photon = sdk.RuntimeEngine_Photon + TerminationCode_Unspecified = sdk.TerminationCode_Unspecified + TerminationCode_UserRequest = sdk.TerminationCode_UserRequest + TerminationCode_JobFinished = sdk.TerminationCode_JobFinished + TerminationCode_Inactivity = sdk.TerminationCode_Inactivity + TerminationCode_CloudProviderShutdown = sdk.TerminationCode_CloudProviderShutdown + TerminationCode_CommunicationLost = sdk.TerminationCode_CommunicationLost + TerminationCode_CloudProviderLaunchFailure = sdk.TerminationCode_CloudProviderLaunchFailure + TerminationCode_InitScriptFailure = sdk.TerminationCode_InitScriptFailure + TerminationCode_SparkStartupFailure = sdk.TerminationCode_SparkStartupFailure + TerminationCode_InvalidArgument = sdk.TerminationCode_InvalidArgument + TerminationCode_UnexpectedLaunchFailure = sdk.TerminationCode_UnexpectedLaunchFailure + TerminationCode_InternalError = sdk.TerminationCode_InternalError + TerminationCode_InstanceUnreachable = sdk.TerminationCode_InstanceUnreachable + TerminationCode_RequestRejected = sdk.TerminationCode_RequestRejected + TerminationCode_TrialExpired = sdk.TerminationCode_TrialExpired + TerminationCode_DriverUnreachable = sdk.TerminationCode_DriverUnreachable + TerminationCode_SparkError = sdk.TerminationCode_SparkError + TerminationCode_DriverUnresponsive = sdk.TerminationCode_DriverUnresponsive + TerminationCode_MetastoreComponentUnhealthy = sdk.TerminationCode_MetastoreComponentUnhealthy + TerminationCode_DbfsComponentUnhealthy = sdk.TerminationCode_DbfsComponentUnhealthy + TerminationCode_ExecutionComponentUnhealthy = sdk.TerminationCode_ExecutionComponentUnhealthy + TerminationCode_AzureResourceManagerThrottling = sdk.TerminationCode_AzureResourceManagerThrottling + TerminationCode_AzureResourceProviderThrottling = sdk.TerminationCode_AzureResourceProviderThrottling + TerminationCode_NetworkConfigurationFailure = sdk.TerminationCode_NetworkConfigurationFailure + TerminationCode_ContainerLaunchFailure = sdk.TerminationCode_ContainerLaunchFailure + TerminationCode_InstancePoolClusterFailure = sdk.TerminationCode_InstancePoolClusterFailure + TerminationCode_SkippedSlowNodes = sdk.TerminationCode_SkippedSlowNodes + TerminationCode_AttachProjectFailure = sdk.TerminationCode_AttachProjectFailure + TerminationCode_UpdateInstanceProfileFailure = sdk.TerminationCode_UpdateInstanceProfileFailure + TerminationCode_DatabaseConnectionFailure = sdk.TerminationCode_DatabaseConnectionFailure + TerminationCode_RequestThrottled = sdk.TerminationCode_RequestThrottled + TerminationCode_SelfBootstrapFailure = sdk.TerminationCode_SelfBootstrapFailure + TerminationCode_GlobalInitScriptFailure = sdk.TerminationCode_GlobalInitScriptFailure + TerminationCode_SlowImageDownload = sdk.TerminationCode_SlowImageDownload + TerminationCode_InvalidSparkImage = sdk.TerminationCode_InvalidSparkImage + TerminationCode_NpipTunnelTokenFailure = sdk.TerminationCode_NpipTunnelTokenFailure + TerminationCode_HiveMetastoreProvisioningFailure = sdk.TerminationCode_HiveMetastoreProvisioningFailure + TerminationCode_AzureInvalidDeploymentTemplate = sdk.TerminationCode_AzureInvalidDeploymentTemplate + TerminationCode_AzureUnexpectedDeploymentTemplateFailure = sdk.TerminationCode_AzureUnexpectedDeploymentTemplateFailure + TerminationCode_SubnetExhaustedFailure = sdk.TerminationCode_SubnetExhaustedFailure + TerminationCode_BootstrapTimeout = sdk.TerminationCode_BootstrapTimeout + TerminationCode_StorageDownloadFailure = sdk.TerminationCode_StorageDownloadFailure + TerminationCode_ControlPlaneRequestFailure = sdk.TerminationCode_ControlPlaneRequestFailure + TerminationCode_BootstrapTimeoutCloudProviderException = sdk.TerminationCode_BootstrapTimeoutCloudProviderException + TerminationCode_AwsInsufficientInstanceCapacityFailure = sdk.TerminationCode_AwsInsufficientInstanceCapacityFailure + TerminationCode_DockerImagePullFailure = sdk.TerminationCode_DockerImagePullFailure + TerminationCode_AzureVnetConfigurationFailure = sdk.TerminationCode_AzureVnetConfigurationFailure + TerminationCode_NpipTunnelSetupFailure = sdk.TerminationCode_NpipTunnelSetupFailure + TerminationCode_AwsAuthorizationFailure = sdk.TerminationCode_AwsAuthorizationFailure + TerminationCode_NephosResourceManagement = sdk.TerminationCode_NephosResourceManagement + TerminationCode_StsClientSetupFailure = sdk.TerminationCode_StsClientSetupFailure + TerminationCode_SecurityDaemonRegistrationException = sdk.TerminationCode_SecurityDaemonRegistrationException + TerminationCode_AwsRequestLimitExceeded = sdk.TerminationCode_AwsRequestLimitExceeded + TerminationCode_AwsInsufficientFreeAddressesInSubnetFailure = sdk.TerminationCode_AwsInsufficientFreeAddressesInSubnetFailure + TerminationCode_AwsUnsupportedFailure = sdk.TerminationCode_AwsUnsupportedFailure + TerminationCode_AzureQuotaExceededException = sdk.TerminationCode_AzureQuotaExceededException + TerminationCode_AzureOperationNotAllowedException = sdk.TerminationCode_AzureOperationNotAllowedException + TerminationCode_NfsMountFailure = sdk.TerminationCode_NfsMountFailure + TerminationCode_K8sAutoscalingFailure = sdk.TerminationCode_K8sAutoscalingFailure + TerminationCode_K8sDbrClusterLaunchTimeout = sdk.TerminationCode_K8sDbrClusterLaunchTimeout + TerminationCode_SparkImageDownloadFailure = sdk.TerminationCode_SparkImageDownloadFailure + TerminationCode_AzureVmExtensionFailure = sdk.TerminationCode_AzureVmExtensionFailure + TerminationCode_WorkspaceCancelledError = sdk.TerminationCode_WorkspaceCancelledError + TerminationCode_AwsMaxSpotInstanceCountExceededFailure = sdk.TerminationCode_AwsMaxSpotInstanceCountExceededFailure + TerminationCode_TemporarilyUnavailable = sdk.TerminationCode_TemporarilyUnavailable + TerminationCode_WorkerSetupFailure = sdk.TerminationCode_WorkerSetupFailure + TerminationCode_IpExhaustionFailure = sdk.TerminationCode_IpExhaustionFailure + TerminationCode_GcpQuotaExceeded = sdk.TerminationCode_GcpQuotaExceeded + TerminationCode_CloudProviderResourceStockout = sdk.TerminationCode_CloudProviderResourceStockout + TerminationCode_GcpServiceAccountDeleted = sdk.TerminationCode_GcpServiceAccountDeleted + TerminationCode_AzureByokKeyPermissionFailure = sdk.TerminationCode_AzureByokKeyPermissionFailure + TerminationCode_SpotInstanceTermination = sdk.TerminationCode_SpotInstanceTermination + TerminationCode_AzureEphemeralDiskFailure = sdk.TerminationCode_AzureEphemeralDiskFailure + TerminationCode_AbuseDetected = sdk.TerminationCode_AbuseDetected + TerminationCode_ImagePullPermissionDenied = sdk.TerminationCode_ImagePullPermissionDenied + TerminationCode_WorkspaceConfigurationError = sdk.TerminationCode_WorkspaceConfigurationError + TerminationCode_SecretResolutionError = sdk.TerminationCode_SecretResolutionError + TerminationCode_UnsupportedInstanceType = sdk.TerminationCode_UnsupportedInstanceType + TerminationCode_CloudProviderDiskSetupFailure = sdk.TerminationCode_CloudProviderDiskSetupFailure + TerminationCode_SshBootstrapFailure = sdk.TerminationCode_SshBootstrapFailure + TerminationCode_AwsInaccessibleKmsKeyFailure = sdk.TerminationCode_AwsInaccessibleKmsKeyFailure + TerminationCode_InitContainerNotFinished = sdk.TerminationCode_InitContainerNotFinished + TerminationCode_SparkImageDownloadThrottled = sdk.TerminationCode_SparkImageDownloadThrottled + TerminationCode_SparkImageNotFound = sdk.TerminationCode_SparkImageNotFound + TerminationCode_ClusterOperationThrottled = sdk.TerminationCode_ClusterOperationThrottled + TerminationCode_ClusterOperationTimeout = sdk.TerminationCode_ClusterOperationTimeout + TerminationCode_ServerlessLongRunningTerminated = sdk.TerminationCode_ServerlessLongRunningTerminated + TerminationCode_AzurePackedDeploymentPartialFailure = sdk.TerminationCode_AzurePackedDeploymentPartialFailure + TerminationCode_InvalidWorkerImageFailure = sdk.TerminationCode_InvalidWorkerImageFailure + TerminationCode_WorkspaceUpdate = sdk.TerminationCode_WorkspaceUpdate + TerminationCode_InvalidAwsParameter = sdk.TerminationCode_InvalidAwsParameter + TerminationCode_DriverOutOfDisk = sdk.TerminationCode_DriverOutOfDisk + TerminationCode_DriverOutOfMemory = sdk.TerminationCode_DriverOutOfMemory + TerminationCode_DriverLaunchTimeout = sdk.TerminationCode_DriverLaunchTimeout + TerminationCode_DriverUnexpectedFailure = sdk.TerminationCode_DriverUnexpectedFailure + TerminationCode_UnexpectedPodRecreation = sdk.TerminationCode_UnexpectedPodRecreation + TerminationCode_GcpInaccessibleKmsKeyFailure = sdk.TerminationCode_GcpInaccessibleKmsKeyFailure + TerminationCode_GcpKmsKeyPermissionDenied = sdk.TerminationCode_GcpKmsKeyPermissionDenied + TerminationCode_DriverEviction = sdk.TerminationCode_DriverEviction + TerminationCode_UserInitiatedVmTermination = sdk.TerminationCode_UserInitiatedVmTermination + TerminationCode_GcpIamTimeout = sdk.TerminationCode_GcpIamTimeout + TerminationCode_AwsResourceQuotaExceeded = sdk.TerminationCode_AwsResourceQuotaExceeded + TerminationCode_CloudAccountSetupFailure = sdk.TerminationCode_CloudAccountSetupFailure + TerminationCode_AwsInvalidKeyPair = sdk.TerminationCode_AwsInvalidKeyPair + TerminationCode_DriverPodCreationFailure = sdk.TerminationCode_DriverPodCreationFailure + TerminationCode_MaintenanceMode = sdk.TerminationCode_MaintenanceMode + TerminationCode_InternalCapacityFailure = sdk.TerminationCode_InternalCapacityFailure + TerminationCode_ExecutorPodUnscheduled = sdk.TerminationCode_ExecutorPodUnscheduled + TerminationCode_StorageDownloadFailureSlow = sdk.TerminationCode_StorageDownloadFailureSlow + TerminationCode_StorageDownloadFailureThrottled = sdk.TerminationCode_StorageDownloadFailureThrottled + TerminationCode_DynamicSparkConfSizeExceeded = sdk.TerminationCode_DynamicSparkConfSizeExceeded + TerminationCode_AwsInstanceProfileUpdateFailure = sdk.TerminationCode_AwsInstanceProfileUpdateFailure + TerminationCode_InstancePoolNotFound = sdk.TerminationCode_InstancePoolNotFound + TerminationCode_InstancePoolMaxCapacityReached = sdk.TerminationCode_InstancePoolMaxCapacityReached + TerminationCode_AwsInvalidKmsKeyState = sdk.TerminationCode_AwsInvalidKmsKeyState + TerminationCode_GcpInsufficientCapacity = sdk.TerminationCode_GcpInsufficientCapacity + TerminationCode_GcpApiRateQuotaExceeded = sdk.TerminationCode_GcpApiRateQuotaExceeded + TerminationCode_GcpResourceQuotaExceeded = sdk.TerminationCode_GcpResourceQuotaExceeded + TerminationCode_GcpIpSpaceExhausted = sdk.TerminationCode_GcpIpSpaceExhausted + TerminationCode_GcpServiceAccountAccessDenied = sdk.TerminationCode_GcpServiceAccountAccessDenied + TerminationCode_GcpServiceAccountNotFound = sdk.TerminationCode_GcpServiceAccountNotFound + TerminationCode_GcpForbidden = sdk.TerminationCode_GcpForbidden + TerminationCode_GcpNotFound = sdk.TerminationCode_GcpNotFound + TerminationCode_ResourceUsageBlocked = sdk.TerminationCode_ResourceUsageBlocked + TerminationCode_DataAccessConfigChanged = sdk.TerminationCode_DataAccessConfigChanged + TerminationCode_AccessTokenFailure = sdk.TerminationCode_AccessTokenFailure + TerminationCode_InvalidInstancePlacementProtocol = sdk.TerminationCode_InvalidInstancePlacementProtocol + TerminationCode_BudgetPolicyResolutionFailure = sdk.TerminationCode_BudgetPolicyResolutionFailure + TerminationCode_InPenaltyBox = sdk.TerminationCode_InPenaltyBox + TerminationCode_DisasterRecoveryReplication = sdk.TerminationCode_DisasterRecoveryReplication + TerminationCode_BootstrapTimeoutDueToMisconfig = sdk.TerminationCode_BootstrapTimeoutDueToMisconfig + TerminationCode_InstanceUnreachableDueToMisconfig = sdk.TerminationCode_InstanceUnreachableDueToMisconfig + TerminationCode_StorageDownloadFailureDueToMisconfig = sdk.TerminationCode_StorageDownloadFailureDueToMisconfig + TerminationCode_ControlPlaneRequestFailureDueToMisconfig = sdk.TerminationCode_ControlPlaneRequestFailureDueToMisconfig + TerminationCode_CloudProviderLaunchFailureDueToMisconfig = sdk.TerminationCode_CloudProviderLaunchFailureDueToMisconfig + TerminationCode_GcpSubnetNotReady = sdk.TerminationCode_GcpSubnetNotReady + TerminationCode_CloudOperationCancelled = sdk.TerminationCode_CloudOperationCancelled + TerminationCode_CloudProviderInstanceNotLaunched = sdk.TerminationCode_CloudProviderInstanceNotLaunched + TerminationCode_GcpTrustedImageProjectsViolated = sdk.TerminationCode_GcpTrustedImageProjectsViolated + TerminationCode_BudgetPolicyLimitEnforcementActivated = sdk.TerminationCode_BudgetPolicyLimitEnforcementActivated + TerminationCode_EosSparkImage = sdk.TerminationCode_EosSparkImage + TerminationCode_NoMatchedK8s = sdk.TerminationCode_NoMatchedK8s + TerminationCode_LazyAllocationTimeout = sdk.TerminationCode_LazyAllocationTimeout + TerminationCode_DriverNodeUnreachable = sdk.TerminationCode_DriverNodeUnreachable + TerminationCode_SecretCreationFailure = sdk.TerminationCode_SecretCreationFailure + TerminationCode_PodSchedulingFailure = sdk.TerminationCode_PodSchedulingFailure + TerminationCode_PodAssignmentFailure = sdk.TerminationCode_PodAssignmentFailure + TerminationCode_AllocationTimeout = sdk.TerminationCode_AllocationTimeout + TerminationCode_AllocationTimeoutNoUnallocatedClusters = sdk.TerminationCode_AllocationTimeoutNoUnallocatedClusters + TerminationCode_AllocationTimeoutNoMatchedClusters = sdk.TerminationCode_AllocationTimeoutNoMatchedClusters + TerminationCode_AllocationTimeoutNoReadyClusters = sdk.TerminationCode_AllocationTimeoutNoReadyClusters + TerminationCode_AllocationTimeoutNoWarmedUpClusters = sdk.TerminationCode_AllocationTimeoutNoWarmedUpClusters + TerminationCode_AllocationTimeoutNodeDaemonNotReady = sdk.TerminationCode_AllocationTimeoutNodeDaemonNotReady + TerminationCode_AllocationTimeoutNoHealthyClusters = sdk.TerminationCode_AllocationTimeoutNoHealthyClusters + TerminationCode_NetvisorSetupTimeout = sdk.TerminationCode_NetvisorSetupTimeout + TerminationCode_NoMatchedK8sTestingTag = sdk.TerminationCode_NoMatchedK8sTestingTag + TerminationCode_CloudProviderResourceStockoutDueToMisconfig = sdk.TerminationCode_CloudProviderResourceStockoutDueToMisconfig + TerminationCode_GkeBasedClusterTermination = sdk.TerminationCode_GkeBasedClusterTermination + TerminationCode_AllocationTimeoutNoHealthyAndWarmedUpClusters = sdk.TerminationCode_AllocationTimeoutNoHealthyAndWarmedUpClusters + TerminationCode_DockerInvalidOsException = sdk.TerminationCode_DockerInvalidOsException + TerminationCode_DockerContainerCreationException = sdk.TerminationCode_DockerContainerCreationException + TerminationCode_DockerImageTooLargeForInstanceException = sdk.TerminationCode_DockerImageTooLargeForInstanceException + TerminationCode_DnsResolutionError = sdk.TerminationCode_DnsResolutionError + TerminationCode_GcpDeniedByOrgPolicy = sdk.TerminationCode_GcpDeniedByOrgPolicy + TerminationCode_SecretPermissionDenied = sdk.TerminationCode_SecretPermissionDenied + TerminationCode_NetworkCheckNicFailure = sdk.TerminationCode_NetworkCheckNicFailure + TerminationCode_NetworkCheckDnsServerFailure = sdk.TerminationCode_NetworkCheckDnsServerFailure + TerminationCode_NetworkCheckStorageFailure = sdk.TerminationCode_NetworkCheckStorageFailure + TerminationCode_NetworkCheckMetadataEndpointFailure = sdk.TerminationCode_NetworkCheckMetadataEndpointFailure + TerminationCode_NetworkCheckControlPlaneFailure = sdk.TerminationCode_NetworkCheckControlPlaneFailure + TerminationCode_NetworkCheckMultipleComponentsFailure = sdk.TerminationCode_NetworkCheckMultipleComponentsFailure + TerminationCode_DriverUnhealthy = sdk.TerminationCode_DriverUnhealthy + TerminationCode_UsagePolicyEntitlementDenied = sdk.TerminationCode_UsagePolicyEntitlementDenied + TerminationCode_K8sActivePodQuotaExceeded = sdk.TerminationCode_K8sActivePodQuotaExceeded + TerminationCode_CloudAccountPodQuotaExceeded = sdk.TerminationCode_CloudAccountPodQuotaExceeded + TerminationCode_NetworkCheckNicFailureDueToMisconfig = sdk.TerminationCode_NetworkCheckNicFailureDueToMisconfig + TerminationCode_NetworkCheckDnsServerFailureDueToMisconfig = sdk.TerminationCode_NetworkCheckDnsServerFailureDueToMisconfig + TerminationCode_NetworkCheckStorageFailureDueToMisconfig = sdk.TerminationCode_NetworkCheckStorageFailureDueToMisconfig + TerminationCode_NetworkCheckMetadataEndpointFailureDueToMisconfig = sdk.TerminationCode_NetworkCheckMetadataEndpointFailureDueToMisconfig + TerminationCode_NetworkCheckControlPlaneFailureDueToMisconfig = sdk.TerminationCode_NetworkCheckControlPlaneFailureDueToMisconfig + TerminationCode_NetworkCheckMultipleComponentsFailureDueToMisconfig = sdk.TerminationCode_NetworkCheckMultipleComponentsFailureDueToMisconfig + TerminationCode_DbrImageResolutionFailure = sdk.TerminationCode_DbrImageResolutionFailure + TerminationCode_ControlPlaneConnectionFailure = sdk.TerminationCode_ControlPlaneConnectionFailure + TerminationCode_ControlPlaneConnectionFailureDueToMisconfig = sdk.TerminationCode_ControlPlaneConnectionFailureDueToMisconfig + TerminationCode_RateLimited = sdk.TerminationCode_RateLimited + TerminationCode_MtlsPortConnectivityFailure = sdk.TerminationCode_MtlsPortConnectivityFailure + TerminationCode_HivemetastoreConnectivityFailure = sdk.TerminationCode_HivemetastoreConnectivityFailure + TerminationType_Unspecified = sdk.TerminationType_Unspecified + TerminationType_Success = sdk.TerminationType_Success + TerminationType_ClientError = sdk.TerminationType_ClientError + TerminationType_ServiceFault = sdk.TerminationType_ServiceFault + TerminationType_CloudFailure = sdk.TerminationType_CloudFailure + ClusterEventType_ClusterEventType_Unspecified = sdk.ClusterEventType_ClusterEventType_Unspecified + ClusterEventType_ClusterEventType_Creating = sdk.ClusterEventType_ClusterEventType_Creating + ClusterEventType_ClusterEventType_Starting = sdk.ClusterEventType_ClusterEventType_Starting + ClusterEventType_ClusterEventType_Restarting = sdk.ClusterEventType_ClusterEventType_Restarting + ClusterEventType_ClusterEventType_Terminating = sdk.ClusterEventType_ClusterEventType_Terminating + ClusterEventType_ClusterEventType_Edited = sdk.ClusterEventType_ClusterEventType_Edited + ClusterEventType_ClusterEventType_Running = sdk.ClusterEventType_ClusterEventType_Running + ClusterEventType_ClusterEventType_Resizing = sdk.ClusterEventType_ClusterEventType_Resizing + ClusterEventType_ClusterEventType_NodesLost = sdk.ClusterEventType_ClusterEventType_NodesLost + ClusterEventType_ClusterEventType_UpsizeCompleted = sdk.ClusterEventType_ClusterEventType_UpsizeCompleted + ClusterEventType_ClusterEventType_InitScriptsStarted = sdk.ClusterEventType_ClusterEventType_InitScriptsStarted + ClusterEventType_ClusterEventType_InitScriptsFinished = sdk.ClusterEventType_ClusterEventType_InitScriptsFinished + ClusterEventType_ClusterEventType_DidNotExpandDisk = sdk.ClusterEventType_ClusterEventType_DidNotExpandDisk + ClusterEventType_ClusterEventType_ExpandedDisk = sdk.ClusterEventType_ClusterEventType_ExpandedDisk + ClusterEventType_ClusterEventType_FailedToExpandDisk = sdk.ClusterEventType_ClusterEventType_FailedToExpandDisk + ClusterEventType_ClusterEventType_DriverHealthy = sdk.ClusterEventType_ClusterEventType_DriverHealthy + ClusterEventType_ClusterEventType_DriverNotResponding = sdk.ClusterEventType_ClusterEventType_DriverNotResponding + ClusterEventType_ClusterEventType_DriverUnavailable = sdk.ClusterEventType_ClusterEventType_DriverUnavailable + ClusterEventType_ClusterEventType_SparkException = sdk.ClusterEventType_ClusterEventType_SparkException + ClusterEventType_ClusterEventType_MetastoreDown = sdk.ClusterEventType_ClusterEventType_MetastoreDown + ClusterEventType_ClusterEventType_DbfsDown = sdk.ClusterEventType_ClusterEventType_DbfsDown + ClusterEventType_ClusterEventType_AutoscalingStatsReport = sdk.ClusterEventType_ClusterEventType_AutoscalingStatsReport + ClusterEventType_ClusterEventType_NodeBlacklisted = sdk.ClusterEventType_ClusterEventType_NodeBlacklisted + ClusterEventType_ClusterEventType_Pinned = sdk.ClusterEventType_ClusterEventType_Pinned + ClusterEventType_ClusterEventType_Unpinned = sdk.ClusterEventType_ClusterEventType_Unpinned + ClusterEventType_ClusterEventType_NodeExcludedDecommissioned = sdk.ClusterEventType_ClusterEventType_NodeExcludedDecommissioned + ClusterEventType_ClusterEventType_AddNodesFailed = sdk.ClusterEventType_ClusterEventType_AddNodesFailed + ClusterEventType_ClusterEventType_AutoscalingBackoff = sdk.ClusterEventType_ClusterEventType_AutoscalingBackoff + ClusterEventType_ClusterEventType_AutomaticClusterUpdate = sdk.ClusterEventType_ClusterEventType_AutomaticClusterUpdate + ClusterEventType_ClusterEventType_AutoscalingFailed = sdk.ClusterEventType_ClusterEventType_AutoscalingFailed + ClusterEventType_ClusterEventType_ClusterMigrated = sdk.ClusterEventType_ClusterEventType_ClusterMigrated + ClusterEventType_ClusterEventType_DecommissionStarted = sdk.ClusterEventType_ClusterEventType_DecommissionStarted + ClusterEventType_ClusterEventType_DecommissionEnded = sdk.ClusterEventType_ClusterEventType_DecommissionEnded + ClusterEventType_ClusterEventType_DeferredPolicyEnforcementScheduled = sdk.ClusterEventType_ClusterEventType_DeferredPolicyEnforcementScheduled + ClusterEventType_ClusterEventType_DeferredPolicyEnforcementFailed = sdk.ClusterEventType_ClusterEventType_DeferredPolicyEnforcementFailed + ClusterEventType_ClusterEventType_UcVolumeMisconfigured = sdk.ClusterEventType_ClusterEventType_UcVolumeMisconfigured + ClusterState_ClusterState_Unspecified = sdk.ClusterState_ClusterState_Unspecified + ClusterState_ClusterState_Pending = sdk.ClusterState_ClusterState_Pending + ClusterState_ClusterState_Running = sdk.ClusterState_ClusterState_Running + ClusterState_ClusterState_Restarting = sdk.ClusterState_ClusterState_Restarting + ClusterState_ClusterState_Resizing = sdk.ClusterState_ClusterState_Resizing + ClusterState_ClusterState_Terminating = sdk.ClusterState_ClusterState_Terminating + ClusterState_ClusterState_Terminated = sdk.ClusterState_ClusterState_Terminated + ClusterState_ClusterState_Error = sdk.ClusterState_ClusterState_Error + ClusterState_ClusterState_Unknown = sdk.ClusterState_ClusterState_Unknown + EnforcePolicyComplianceForClusterRequest_EnforceMode_Unspecified = sdk.EnforcePolicyComplianceForClusterRequest_EnforceMode_Unspecified + EnforcePolicyComplianceForClusterRequest_EnforceMode_EnforceImmediately = sdk.EnforcePolicyComplianceForClusterRequest_EnforceMode_EnforceImmediately + EnforcePolicyComplianceForClusterRequest_EnforceMode_WaitForTermination = sdk.EnforcePolicyComplianceForClusterRequest_EnforceMode_WaitForTermination + EnforcePolicyComplianceForClusterResponse_EnforceResult_Unspecified = sdk.EnforcePolicyComplianceForClusterResponse_EnforceResult_Unspecified + EnforcePolicyComplianceForClusterResponse_EnforceResult_NoChanges = sdk.EnforcePolicyComplianceForClusterResponse_EnforceResult_NoChanges + EnforcePolicyComplianceForClusterResponse_EnforceResult_Applied = sdk.EnforcePolicyComplianceForClusterResponse_EnforceResult_Applied + EnforcePolicyComplianceForClusterResponse_EnforceResult_Deferred = sdk.EnforcePolicyComplianceForClusterResponse_EnforceResult_Deferred + InitScriptExecutionDetails_InitScriptExecutionStatus_Unspecified = sdk.InitScriptExecutionDetails_InitScriptExecutionStatus_Unspecified + InitScriptExecutionDetails_InitScriptExecutionStatus_Unknown = sdk.InitScriptExecutionDetails_InitScriptExecutionStatus_Unknown + InitScriptExecutionDetails_InitScriptExecutionStatus_FailedFetch = sdk.InitScriptExecutionDetails_InitScriptExecutionStatus_FailedFetch + InitScriptExecutionDetails_InitScriptExecutionStatus_FailedExecution = sdk.InitScriptExecutionDetails_InitScriptExecutionStatus_FailedExecution + InitScriptExecutionDetails_InitScriptExecutionStatus_NotExecuted = sdk.InitScriptExecutionDetails_InitScriptExecutionStatus_NotExecuted + InitScriptExecutionDetails_InitScriptExecutionStatus_Skipped = sdk.InitScriptExecutionDetails_InitScriptExecutionStatus_Skipped + InitScriptExecutionDetails_InitScriptExecutionStatus_Succeeded = sdk.InitScriptExecutionDetails_InitScriptExecutionStatus_Succeeded + InitScriptExecutionDetails_InitScriptExecutionStatus_FuseMountFailed = sdk.InitScriptExecutionDetails_InitScriptExecutionStatus_FuseMountFailed + PendingEnforcement_EnforcementStatus_Unspecified = sdk.PendingEnforcement_EnforcementStatus_Unspecified + PendingEnforcement_EnforcementStatus_Active = sdk.PendingEnforcement_EnforcementStatus_Active + PendingEnforcement_EnforcementStatus_Inactive = sdk.PendingEnforcement_EnforcementStatus_Inactive + ResizeCause_ResizeCause_Unspecified = sdk.ResizeCause_ResizeCause_Unspecified + ResizeCause_ResizeCause_Autoscale = sdk.ResizeCause_ResizeCause_Autoscale + ResizeCause_ResizeCause_UserRequest = sdk.ResizeCause_ResizeCause_UserRequest + ResizeCause_ResizeCause_Autorecovery = sdk.ResizeCause_ResizeCause_Autorecovery + ResizeCause_ResizeCause_ReplaceBadNodes = sdk.ResizeCause_ResizeCause_ReplaceBadNodes + ResizeCause_ResizeCause_AutoscaleV2 = sdk.ResizeCause_ResizeCause_AutoscaleV2 + ResizeCause_ResizeCause_DbrAutoscale = sdk.ResizeCause_ResizeCause_DbrAutoscale +) + +// A storage location in Adls Gen2. +type Adlsgen2Info struct { + // abfss destination, e.g. + // `abfss://@.dfs.core.windows.net/`. + Destination *string `json:"destination,omitempty"` +} + +type AutoScale struct { + // The maximum number of workers to which the cluster can scale up when + // overloaded. Note that `max_workers` must be strictly greater than + // `min_workers`. + MaxWorkers *int `json:"max_workers,omitempty"` + // The minimum number of workers to which the cluster can scale down when + // underutilized. It is also the initial number of workers the cluster will have + // after creation. + MinWorkers *int `json:"min_workers,omitempty"` +} + +// Attributes set during cluster creation which are related to Amazon Web +// Services.. +type AwsAttributes struct { + Availability AwsAvailability `json:"availability,omitempty"` + // The number of volumes launched for each instance. Users can choose up to 10 + // volumes. This feature is only enabled for supported node types. Legacy node + // types cannot specify custom EBS volumes. For node types with no instance + // store, at least one EBS volume needs to be specified; otherwise, cluster + // creation will fail. + // + // These EBS volumes will be mounted at `/ebs0`, `/ebs1`, and etc. Instance + // store volumes will be mounted at `/local_disk0`, `/local_disk1`, and etc. + // + // If EBS volumes are attached, will configure Spark to use only + // the EBS volumes for scratch storage because heterogenously sized scratch + // devices can lead to inefficient disk utilization. If no EBS volumes are + // attached, will configure Spark to use instance store volumes. + // + // Please note that if EBS volumes are specified, then the Spark configuration + // `spark.local.dir` will be overridden. + EbsVolumeCount *int `json:"ebs_volume_count,omitempty"` + // If using gp3 volumes, what IOPS to use for the disk. If this is not set, the + // maximum performance of a gp2 volume with the same volume size will be used. + EbsVolumeIops *int `json:"ebs_volume_iops,omitempty"` + // The size of each EBS volume (in GiB) launched for each instance. For general + // purpose SSD, this value must be within the range 100 - 4096. For throughput + // optimized HDD, this value must be within the range 500 - 4096. + EbsVolumeSize *int `json:"ebs_volume_size,omitempty"` + // If using gp3 volumes, what throughput to use for the disk. If this is not + // set, the maximum performance of a gp2 volume with the same volume size will + // be used. + EbsVolumeThroughput *int `json:"ebs_volume_throughput,omitempty"` + // The type of EBS volumes that will be launched with this cluster. + EbsVolumeType EbsVolumeType `json:"ebs_volume_type,omitempty"` + // The first `first_on_demand` nodes of the cluster will be placed on on-demand + // instances. If this value is greater than 0, the cluster driver node in + // particular will be placed on an on-demand instance. If this value is greater + // than or equal to the current cluster size, all nodes will be placed on + // on-demand instances. If this value is less than the current cluster size, + // `first_on_demand` nodes will be placed on on-demand instances and the + // remainder will be placed on `availability` instances. Note that this value + // does not affect cluster size and cannot currently be mutated over the + // lifetime of a cluster. + FirstOnDemand *int `json:"first_on_demand,omitempty"` + // Nodes for this cluster will only be placed on AWS instances with this + // instance profile. If ommitted, nodes will be placed on instances without an + // IAM instance profile. The instance profile must have previously been added to + // the environment by an account administrator. + // + // This feature may only be available to certain customer plans. + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // The bid price for AWS spot instances, as a percentage of the corresponding + // instance type's on-demand price. For example, if this field is set to 50, and + // the cluster needs a new `r3.xlarge` spot instance, then the bid price is half + // of the price of on-demand `r3.xlarge` instances. Similarly, if this field is + // set to 200, the bid price is twice the price of on-demand `r3.xlarge` + // instances. If not specified, the default value is 100. When spot instances + // are requested for this cluster, only spot instances whose bid price + // percentage matches this field will be considered. Note that, for safety, we + // enforce this field to be no more than 10000. + SpotBidPricePercent *int `json:"spot_bid_price_percent,omitempty"` + // Identifier for the availability zone/datacenter in which the cluster resides. + // This string will be of a form like "us-west-2a". The provided availability + // zone must be in the same region as the deployment. For example, + // "us-west-2a" is not a valid zone id if the deployment resides in + // the "us-east-1" region. This is an optional field at cluster creation, and if + // not specified, the zone "auto" will be used. If the zone specified is "auto", + // will try to place cluster in a zone with high availability, and will retry + // placement in a different AZ if there is not enough capacity. The list of + // available zones as well as the default value can be found by using the `List + // Zones` method. + ZoneId *string `json:"zone_id,omitempty"` +} + +// Attributes set during cluster creation which are related to Microsoft Azure.. +type AzureAttributes struct { + // Availability type used for all subsequent nodes past the `first_on_demand` + // ones. Note: If `first_on_demand` is zero, this availability type will be used + // for the entire cluster. + Availability AzureAvailability `json:"availability,omitempty"` + // The Azure capacity reservation group resource ID to use for launching VMs. + // When specified, VMs will be launched using the provided capacity reservation. + // + // Capacity reservations can only be specified when the workspace uses injected + // vnet (i.e. customer defined vnet not managed by databricks). Ensure the + // databricks-login-prod Enterprise Application is granted the following four + // permissions: 1. Microsoft.Compute/capacityReservationGroups/read 2. + // Microsoft.Compute/capacityReservationGroups/deploy/action 3. + // Microsoft.Compute/capacityReservationGroups/capacityReservations/read 4. + // Microsoft.Compute/capacityReservationGroups/capacityReservations/deploy/action + // + // Format: + // `/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}` + CapacityReservationGroup *string `json:"capacity_reservation_group,omitempty"` + // The first `first_on_demand` nodes of the cluster will be placed on on-demand + // instances. This value should be greater than 0, to make sure the cluster + // driver node is placed on an on-demand instance. If this value is greater than + // or equal to the current cluster size, all nodes will be placed on on-demand + // instances. If this value is less than the current cluster size, + // `first_on_demand` nodes will be placed on on-demand instances and the + // remainder will be placed on `availability` instances. Note that this value + // does not affect cluster size and cannot currently be mutated over the + // lifetime of a cluster. + FirstOnDemand *int `json:"first_on_demand,omitempty"` + // Defines values necessary to configure and run Azure Log Analytics agent + LogAnalyticsInfo *LogAnalyticsInfo `json:"log_analytics_info,omitempty"` + // The max bid price to be used for Azure spot instances. The Max price for the + // bid cannot be higher than the on-demand price of the instance. If not + // specified, the default value is -1, which specifies that the instance cannot + // be evicted on the basis of price, and only on the basis of availability. + // Further, the value should > 0 or -1. + SpotBidMaxPrice *float64 `json:"spot_bid_max_price,omitempty"` +} + +// Request to cancel the pending enforcement for a cluster.. +type CancelPendingClusterEnforcementRequest struct { + // If true and no pending enforcement exists, the request will succeed but no + // action will be taken. + AllowMissing *bool `json:"allow_missing,omitempty"` + // The ID of the cluster to cancel the pending enforcement for. + ClusterId *string `json:"cluster_id,omitempty"` +} + +type ChangeClusterOwnerRequest struct { + ClusterId *string `json:"cluster_id,omitempty"` + // New owner of the cluster_id after this RPC. + OwnerUsername *string `json:"owner_username,omitempty"` +} + +type CloneCluster struct { + // The cluster that is being cloned. + SourceClusterId *string `json:"source_cluster_id,omitempty"` +} + +type CloudProviderNodeInfo struct { + // Status as reported by the cloud provider + Status []CloudProviderNodeStatus `json:"status,omitempty"` +} + +// Common set of attributes set during cluster creation. These attributes cannot +// be changed over the lifetime of a cluster.. +type ClusterAttributes struct { + // Automatically terminates the cluster after it is inactive for this time in + // minutes. If not set, this cluster will not be automatically terminated. If + // specified, the threshold must be between 10 and 10000 minutes. Users can also + // set this value to 0 to explicitly disable automatic termination. + AutoterminationMinutes *int `json:"autotermination_minutes,omitempty"` + // Attributes related to clusters running on Amazon Web Services. If not + // specified at cluster creation, a set of default values will be used. + AwsAttributes *AwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to clusters running on Microsoft Azure. If not specified + // at cluster creation, a set of default values will be used. + AzureAttributes *AzureAttributes `json:"azure_attributes,omitempty"` + // The configuration for delivering spark logs to a long-term storage + // destination. Three kinds of destinations (DBFS, S3 and Unity Catalog volumes) + // are supported. Only one destination can be specified for one cluster. If the + // conf is given, the logs will be delivered to the destination every `5 mins`. + // The destination of driver logs is `$destination/$clusterId/driver`, while the + // destination of executor logs is `$destination/$clusterId/executor`. + ClusterLogConf *ClusterLogConf `json:"cluster_log_conf,omitempty"` + // Cluster name requested by the user. This doesn't have to be unique. If not + // specified at creation, the cluster name will be an empty string. For job + // clusters, the cluster name is automatically set based on the job and job run + // IDs. + ClusterName *string `json:"cluster_name,omitempty"` + // Additional tags for cluster resources. will tag all cluster + // resources (e.g., AWS instances and EBS volumes) with these tags in addition + // to `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + // + // - Clusters can only reuse cloud resources if the resources' tags are a subset + // of the cluster tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + DataSecurityMode DataSecurityMode `json:"data_security_mode,omitempty"` + // Controls dependency configuration for the cluster. + DependencyMode DependencyMode `json:"dependency_mode,omitempty"` + // Custom docker image BYOC + DockerImage *DockerImage `json:"docker_image,omitempty"` + // The optional ID of the instance pool for the driver of the cluster belongs. + // The pool cluster uses the instance pool with id (instance_pool_id) if the + // driver pool is not assigned. + DriverInstancePoolId *string `json:"driver_instance_pool_id,omitempty"` + // Flexible node type configuration for the driver node. + DriverNodeTypeFlexibility *NodeTypeFlexibility `json:"driver_node_type_flexibility,omitempty"` + // The node type of the Spark driver. Note that this field is optional; if + // unset, the driver node type will be set as the same value as `node_type_id` + // defined above. + // + // This field, along with node_type_id, should not be set if + // virtual_cluster_size is set. If both driver_node_type_id, node_type_id, and + // virtual_cluster_size are specified, driver_node_type_id and node_type_id take + // precedence. + DriverNodeTypeId *string `json:"driver_node_type_id,omitempty"` + // Autoscaling Local Storage: when enabled, this cluster will dynamically + // acquire additional disk space when its Spark workers are running low on disk + // space. + EnableElasticDisk *bool `json:"enable_elastic_disk,omitempty"` + // Whether to enable LUKS on cluster VMs' local disks + EnableLocalDiskEncryption *bool `json:"enable_local_disk_encryption,omitempty"` + // Attributes related to clusters running on Google Cloud Platform. If not + // specified at cluster creation, a set of default values will be used. + GcpAttributes *GcpAttributes `json:"gcp_attributes,omitempty"` + // The configuration for storing init scripts. Any number of destinations can be + // specified. The scripts are executed sequentially in the order provided. If + // `cluster_log_conf` is specified, init script logs are sent to + // `//init_scripts`. + InitScripts []InitScriptInfo `json:"init_scripts,omitempty"` + // The optional ID of the instance pool to which the cluster belongs. + InstancePoolId *string `json:"instance_pool_id,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // When set to true, will automatically set single node related + // `custom_tags`, `spark_conf`, and `num_workers` + IsSingleNode *bool `json:"is_single_node,omitempty"` + Kind ComputeKind `json:"kind,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // [clusters/listNodeTypes] API call. + // + // [clusters/listNodeTypes]: https://docs.databricks.com/api/workspace/clusters/listnodetypes + NodeTypeId *string `json:"node_type_id,omitempty"` + // The ID of the cluster policy used to create the cluster if applicable. + PolicyId *string `json:"policy_id,omitempty"` + // If set, what the configurable throughput (in Mb/s) for the remote disk is. + // Currently only supported for GCP HYPERDISK_BALANCED disks. + RemoteDiskThroughput *int `json:"remote_disk_throughput,omitempty"` + // Determines the cluster's runtime engine, either standard or Photon. + // + // This field is not compatible with legacy `spark_version` values that contain + // `-photon-`. Remove `-photon-` from the `spark_version` and set + // `runtime_engine` to `PHOTON`. + // + // If left unspecified, the runtime engine defaults to standard unless the + // spark_version contains -photon-, in which case Photon will be used. + RuntimeEngine RuntimeEngine `json:"runtime_engine,omitempty"` + // Single user name if data_security_mode is `SINGLE_USER` + SingleUserName *string `json:"single_user_name,omitempty"` + // An object containing a set of optional, user-specified Spark configuration + // key-value pairs. Users can also pass in a string of extra JVM options to the + // driver and the executors via `spark.driver.extraJavaOptions` and + // `spark.executor.extraJavaOptions` respectively. + SparkConf map[string]string `json:"spark_conf,omitempty"` + // An object containing a set of optional, user-specified environment variable + // key-value pairs. Please note that key-value pair of the form (X,Y) will be + // exported as is (i.e., `export X='Y'`) while launching the driver and workers. + // + // In order to specify an additional set of `SPARK_DAEMON_JAVA_OPTS`, we + // recommend appending them to `$SPARK_DAEMON_JAVA_OPTS` as shown in the example + // below. This ensures that all default databricks managed environmental + // variables are included as well. + // + // Example Spark environment variables: `{"SPARK_WORKER_MEMORY": "28000m", + // "SPARK_LOCAL_DIRS": "/local_disk0"}` or `{"SPARK_DAEMON_JAVA_OPTS": + // "$SPARK_DAEMON_JAVA_OPTS -Dspark.shuffle.service.enabled=true"}` + SparkEnvVars map[string]string `json:"spark_env_vars,omitempty"` + // The Spark version of the cluster, e.g. `3.3.x-scala2.11`. A list of available + // Spark versions can be retrieved by using the [clusters/sparkVersions] API + // call. + // + // [clusters/sparkVersions]: https://docs.databricks.com/api/workspace/clusters/sparkversions + SparkVersion *string `json:"spark_version,omitempty"` + // SSH public key contents that will be added to each Spark node in this + // cluster. The corresponding private keys can be used to login with the user + // name `ubuntu` on port `2200`. Up to 10 keys can be specified. + SshPublicKeys []string `json:"ssh_public_keys,omitempty"` + // If set, what the total initial volume size (in GB) of the remote disks should + // be. Supported for GCP. + TotalInitialRemoteDiskSize *int `json:"total_initial_remote_disk_size,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // `effective_spark_version` is determined by `spark_version` (DBR release), + // this field `use_ml_runtime`, and whether `node_type_id` is gpu node or not. + UseMlRuntime *bool `json:"use_ml_runtime,omitempty"` + // Flexible node type configuration for worker nodes. + WorkerNodeTypeFlexibility *NodeTypeFlexibility `json:"worker_node_type_flexibility,omitempty"` + WorkloadType *WorkloadType `json:"workload_type,omitempty"` +} + +type ClusterCompliance struct { + // Canonical unique identifier for a cluster. + ClusterId *string `json:"cluster_id,omitempty"` + // Whether this cluster is in compliance with the latest version of its policy. + IsCompliant *bool `json:"is_compliant,omitempty"` + // Information about the pending enforcement for the cluster. Only present if a + // pending enforcement is scheduled for the cluster. + PendingEnforcement *PendingEnforcement `json:"pending_enforcement,omitempty"` + // An object containing key-value mappings representing the first 200 policy + // validation errors. The keys indicate the path where the policy validation + // error is occurring. The values indicate an error message describing the + // policy validation error. + Violations map[string]string `json:"violations,omitempty"` +} + +type ClusterEvent struct { + ClusterId *string `json:"cluster_id,omitempty"` + DataPlaneEventDetails *DataPlaneEventDetails `json:"data_plane_event_details,omitempty"` + Details *EventDetails `json:"details,omitempty"` + // The timestamp when the event occurred, stored as the number of milliseconds + // since the Unix epoch. If not provided, this will be assigned by the Timeline + // service. + Timestamp *int64 `json:"timestamp,omitempty"` + Type ClusterEventType_ClusterEventType `json:"type,omitempty"` +} + +// Describes all of the metadata about a single Spark cluster in .. +type ClusterInfo struct { + Autoscale *AutoScale `json:"autoscale,omitempty"` + // Automatically terminates the cluster after it is inactive for this time in + // minutes. If not set, this cluster will not be automatically terminated. If + // specified, the threshold must be between 10 and 10000 minutes. Users can also + // set this value to 0 to explicitly disable automatic termination. + AutoterminationMinutes *int `json:"autotermination_minutes,omitempty"` + // Attributes related to clusters running on Amazon Web Services. If not + // specified at cluster creation, a set of default values will be used. + AwsAttributes *AwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to clusters running on Microsoft Azure. If not specified + // at cluster creation, a set of default values will be used. + AzureAttributes *AzureAttributes `json:"azure_attributes,omitempty"` + // Number of CPU cores available for this cluster. Note that this can be + // fractional, e.g. 7.5 cores, since certain node types are configured to share + // cores between Spark nodes on the same instance. + ClusterCores *float32 `json:"cluster_cores,omitempty"` + // Canonical identifier for the cluster. This id is retained during cluster + // restarts and resizes, while each new cluster has a globally unique id. + ClusterId *string `json:"cluster_id,omitempty"` + // The configuration for delivering spark logs to a long-term storage + // destination. Three kinds of destinations (DBFS, S3 and Unity Catalog volumes) + // are supported. Only one destination can be specified for one cluster. If the + // conf is given, the logs will be delivered to the destination every `5 mins`. + // The destination of driver logs is `$destination/$clusterId/driver`, while the + // destination of executor logs is `$destination/$clusterId/executor`. + ClusterLogConf *ClusterLogConf `json:"cluster_log_conf,omitempty"` + // Cluster log delivery status. + ClusterLogStatus *LogSyncStatus `json:"cluster_log_status,omitempty"` + // Total amount of cluster memory, in megabytes + ClusterMemoryMb *int64 `json:"cluster_memory_mb,omitempty"` + // Cluster name requested by the user. This doesn't have to be unique. If not + // specified at creation, the cluster name will be an empty string. For job + // clusters, the cluster name is automatically set based on the job and job run + // IDs. + ClusterName *string `json:"cluster_name,omitempty"` + // Creator user name. The field won't be included in the response if the user + // has already been deleted. + CreatorUserName *string `json:"creator_user_name,omitempty"` + // Additional tags for cluster resources. will tag all cluster + // resources (e.g., AWS instances and EBS volumes) with these tags in addition + // to `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + // + // - Clusters can only reuse cloud resources if the resources' tags are a subset + // of the cluster tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + DataSecurityMode DataSecurityMode `json:"data_security_mode,omitempty"` + // Tags that are added by regardless of any `custom_tags`, + // including: + // + // - Vendor: + // + // - Creator: + // + // - ClusterName: + // + // - ClusterId: + // + // - Name: < internal use> + DefaultTags map[string]string `json:"default_tags,omitempty"` + // Controls dependency configuration for the cluster. + DependencyMode DependencyMode `json:"dependency_mode,omitempty"` + // Custom docker image BYOC + DockerImage *DockerImage `json:"docker_image,omitempty"` + // Node on which the Spark driver resides. The driver node contains the Spark + // master and the application that manages the per-notebook Spark + // REPLs. + Driver *SparkInfo_SparkNode `json:"driver,omitempty"` + // The optional ID of the instance pool for the driver of the cluster belongs. + // The pool cluster uses the instance pool with id (instance_pool_id) if the + // driver pool is not assigned. + DriverInstancePoolId *string `json:"driver_instance_pool_id,omitempty"` + // Flexible node type configuration for the driver node. + DriverNodeTypeFlexibility *NodeTypeFlexibility `json:"driver_node_type_flexibility,omitempty"` + // The node type of the Spark driver. Note that this field is optional; if + // unset, the driver node type will be set as the same value as `node_type_id` + // defined above. + // + // This field, along with node_type_id, should not be set if + // virtual_cluster_size is set. If both driver_node_type_id, node_type_id, and + // virtual_cluster_size are specified, driver_node_type_id and node_type_id take + // precedence. + DriverNodeTypeId *string `json:"driver_node_type_id,omitempty"` + // Autoscaling Local Storage: when enabled, this cluster will dynamically + // acquire additional disk space when its Spark workers are running low on disk + // space. + EnableElasticDisk *bool `json:"enable_elastic_disk,omitempty"` + // Whether to enable LUKS on cluster VMs' local disks + EnableLocalDiskEncryption *bool `json:"enable_local_disk_encryption,omitempty"` + // Nodes on which the Spark executors reside. + Executors []SparkInfo_SparkNode `json:"executors,omitempty"` + // Attributes related to clusters running on Google Cloud Platform. If not + // specified at cluster creation, a set of default values will be used. + GcpAttributes *GcpAttributes `json:"gcp_attributes,omitempty"` + // The configuration for storing init scripts. Any number of destinations can be + // specified. The scripts are executed sequentially in the order provided. If + // `cluster_log_conf` is specified, init script logs are sent to + // `//init_scripts`. + InitScripts []InitScriptInfo `json:"init_scripts,omitempty"` + // The optional ID of the instance pool to which the cluster belongs. + InstancePoolId *string `json:"instance_pool_id,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // When set to true, will automatically set single node related + // `custom_tags`, `spark_conf`, and `num_workers` + IsSingleNode *bool `json:"is_single_node,omitempty"` + // Port on which Spark JDBC server is listening, in the driver nod. No service + // will be listeningon on this port in executor nodes. + JdbcPort *int `json:"jdbc_port,omitempty"` + Kind ComputeKind `json:"kind,omitempty"` + // the timestamp that the cluster was started/restarted + LastRestartedTime *int64 `json:"last_restarted_time,omitempty"` + // Time when the cluster driver last lost its state (due to a restart or driver + // failure). + LastStateLossTime *int64 `json:"last_state_loss_time,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // [clusters/listNodeTypes] API call. + // + // [clusters/listNodeTypes]: https://docs.databricks.com/api/workspace/clusters/listnodetypes + NodeTypeId *string `json:"node_type_id,omitempty"` + NumWorkers *int `json:"num_workers,omitempty"` + // The ID of the cluster policy used to create the cluster if applicable. + PolicyId *string `json:"policy_id,omitempty"` + // If set, what the configurable throughput (in Mb/s) for the remote disk is. + // Currently only supported for GCP HYPERDISK_BALANCED disks. + RemoteDiskThroughput *int `json:"remote_disk_throughput,omitempty"` + // Determines the cluster's runtime engine, either standard or Photon. + // + // This field is not compatible with legacy `spark_version` values that contain + // `-photon-`. Remove `-photon-` from the `spark_version` and set + // `runtime_engine` to `PHOTON`. + // + // If left unspecified, the runtime engine defaults to standard unless the + // spark_version contains -photon-, in which case Photon will be used. + RuntimeEngine RuntimeEngine `json:"runtime_engine,omitempty"` + // Single user name if data_security_mode is `SINGLE_USER` + SingleUserName *string `json:"single_user_name,omitempty"` + // An object containing a set of optional, user-specified Spark configuration + // key-value pairs. Users can also pass in a string of extra JVM options to the + // driver and the executors via `spark.driver.extraJavaOptions` and + // `spark.executor.extraJavaOptions` respectively. + SparkConf map[string]string `json:"spark_conf,omitempty"` + // A canonical SparkContext identifier. This value *does* change when the Spark + // driver restarts. The pair `(cluster_id, spark_context_id)` is a globally + // unique identifier over all Spark contexts. + SparkContextId *int64 `json:"spark_context_id,omitempty"` + // An object containing a set of optional, user-specified environment variable + // key-value pairs. Please note that key-value pair of the form (X,Y) will be + // exported as is (i.e., `export X='Y'`) while launching the driver and workers. + // + // In order to specify an additional set of `SPARK_DAEMON_JAVA_OPTS`, we + // recommend appending them to `$SPARK_DAEMON_JAVA_OPTS` as shown in the example + // below. This ensures that all default databricks managed environmental + // variables are included as well. + // + // Example Spark environment variables: `{"SPARK_WORKER_MEMORY": "28000m", + // "SPARK_LOCAL_DIRS": "/local_disk0"}` or `{"SPARK_DAEMON_JAVA_OPTS": + // "$SPARK_DAEMON_JAVA_OPTS -Dspark.shuffle.service.enabled=true"}` + SparkEnvVars map[string]string `json:"spark_env_vars,omitempty"` + // The Spark version of the cluster, e.g. `3.3.x-scala2.11`. A list of available + // Spark versions can be retrieved by using the [clusters/sparkVersions] API + // call. + // + // [clusters/sparkVersions]: https://docs.databricks.com/api/workspace/clusters/sparkversions + SparkVersion *string `json:"spark_version,omitempty"` + // The spec contains a snapshot of the latest user specified settings that were + // used to create/edit the cluster. Note: not included in the response of the + // ListClusters API. + Spec *ClusterInfo_ComputeSpec `json:"spec,omitempty"` + // SSH public key contents that will be added to each Spark node in this + // cluster. The corresponding private keys can be used to login with the user + // name `ubuntu` on port `2200`. Up to 10 keys can be specified. + SshPublicKeys []string `json:"ssh_public_keys,omitempty"` + // Time (in epoch milliseconds) when the cluster creation request was received + // (when the cluster entered a `PENDING` state). + StartTime *int64 `json:"start_time,omitempty"` + // Current state of the cluster. + State ClusterState_ClusterState `json:"state,omitempty"` + // A message associated with the most recent state transition (e.g., the reason + // why the cluster entered a `TERMINATED` state). + StateMessage *string `json:"state_message,omitempty"` + // Time (in epoch milliseconds) when the cluster was terminated, if applicable. + TerminatedTime *int64 `json:"terminated_time,omitempty"` + // Information about why the cluster was terminated. This field only appears + // when the cluster is in a `TERMINATING` or `TERMINATED` state. + TerminationReason *TerminationReason `json:"termination_reason,omitempty"` + // If set, what the total initial volume size (in GB) of the remote disks should + // be. Supported for GCP. + TotalInitialRemoteDiskSize *int `json:"total_initial_remote_disk_size,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // `effective_spark_version` is determined by `spark_version` (DBR release), + // this field `use_ml_runtime`, and whether `node_type_id` is gpu node or not. + UseMlRuntime *bool `json:"use_ml_runtime,omitempty"` + // Flexible node type configuration for worker nodes. + WorkerNodeTypeFlexibility *NodeTypeFlexibility `json:"worker_node_type_flexibility,omitempty"` + WorkloadType *WorkloadType `json:"workload_type,omitempty"` +} + +// Contains a snapshot of the latest user specified settings that were used to +// create/edit the cluster.. +type ClusterInfo_ComputeSpec struct { + // When set to true, fixed and default values from the policy will be used for + // fields that are omitted. When set to false, only fixed values from the policy + // will be applied. + ApplyPolicyDefaultValues *bool `json:"apply_policy_default_values,omitempty"` + Autoscale *AutoScale `json:"autoscale,omitempty"` + // Automatically terminates the cluster after it is inactive for this time in + // minutes. If not set, this cluster will not be automatically terminated. If + // specified, the threshold must be between 10 and 10000 minutes. Users can also + // set this value to 0 to explicitly disable automatic termination. + AutoterminationMinutes *int `json:"autotermination_minutes,omitempty"` + // Attributes related to clusters running on Amazon Web Services. If not + // specified at cluster creation, a set of default values will be used. + AwsAttributes *AwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to clusters running on Microsoft Azure. If not specified + // at cluster creation, a set of default values will be used. + AzureAttributes *AzureAttributes `json:"azure_attributes,omitempty"` + // The configuration for delivering spark logs to a long-term storage + // destination. Three kinds of destinations (DBFS, S3 and Unity Catalog volumes) + // are supported. Only one destination can be specified for one cluster. If the + // conf is given, the logs will be delivered to the destination every `5 mins`. + // The destination of driver logs is `$destination/$clusterId/driver`, while the + // destination of executor logs is `$destination/$clusterId/executor`. + ClusterLogConf *ClusterLogConf `json:"cluster_log_conf,omitempty"` + // Cluster name requested by the user. This doesn't have to be unique. If not + // specified at creation, the cluster name will be an empty string. For job + // clusters, the cluster name is automatically set based on the job and job run + // IDs. + ClusterName *string `json:"cluster_name,omitempty"` + // Additional tags for cluster resources. will tag all cluster + // resources (e.g., AWS instances and EBS volumes) with these tags in addition + // to `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + // + // - Clusters can only reuse cloud resources if the resources' tags are a subset + // of the cluster tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + DataSecurityMode DataSecurityMode `json:"data_security_mode,omitempty"` + // Controls dependency configuration for the cluster. + DependencyMode DependencyMode `json:"dependency_mode,omitempty"` + // Custom docker image BYOC + DockerImage *DockerImage `json:"docker_image,omitempty"` + // The optional ID of the instance pool for the driver of the cluster belongs. + // The pool cluster uses the instance pool with id (instance_pool_id) if the + // driver pool is not assigned. + DriverInstancePoolId *string `json:"driver_instance_pool_id,omitempty"` + // Flexible node type configuration for the driver node. + DriverNodeTypeFlexibility *NodeTypeFlexibility `json:"driver_node_type_flexibility,omitempty"` + // The node type of the Spark driver. Note that this field is optional; if + // unset, the driver node type will be set as the same value as `node_type_id` + // defined above. + // + // This field, along with node_type_id, should not be set if + // virtual_cluster_size is set. If both driver_node_type_id, node_type_id, and + // virtual_cluster_size are specified, driver_node_type_id and node_type_id take + // precedence. + DriverNodeTypeId *string `json:"driver_node_type_id,omitempty"` + // Autoscaling Local Storage: when enabled, this cluster will dynamically + // acquire additional disk space when its Spark workers are running low on disk + // space. + EnableElasticDisk *bool `json:"enable_elastic_disk,omitempty"` + // Whether to enable LUKS on cluster VMs' local disks + EnableLocalDiskEncryption *bool `json:"enable_local_disk_encryption,omitempty"` + // Attributes related to clusters running on Google Cloud Platform. If not + // specified at cluster creation, a set of default values will be used. + GcpAttributes *GcpAttributes `json:"gcp_attributes,omitempty"` + // The configuration for storing init scripts. Any number of destinations can be + // specified. The scripts are executed sequentially in the order provided. If + // `cluster_log_conf` is specified, init script logs are sent to + // `//init_scripts`. + InitScripts []InitScriptInfo `json:"init_scripts,omitempty"` + // The optional ID of the instance pool to which the cluster belongs. + InstancePoolId *string `json:"instance_pool_id,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // When set to true, will automatically set single node related + // `custom_tags`, `spark_conf`, and `num_workers` + IsSingleNode *bool `json:"is_single_node,omitempty"` + Kind ComputeKind `json:"kind,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // [clusters/listNodeTypes] API call. + // + // [clusters/listNodeTypes]: https://docs.databricks.com/api/workspace/clusters/listnodetypes + NodeTypeId *string `json:"node_type_id,omitempty"` + NumWorkers *int `json:"num_workers,omitempty"` + // The ID of the cluster policy used to create the cluster if applicable. + PolicyId *string `json:"policy_id,omitempty"` + // If set, what the configurable throughput (in Mb/s) for the remote disk is. + // Currently only supported for GCP HYPERDISK_BALANCED disks. + RemoteDiskThroughput *int `json:"remote_disk_throughput,omitempty"` + // Determines the cluster's runtime engine, either standard or Photon. + // + // This field is not compatible with legacy `spark_version` values that contain + // `-photon-`. Remove `-photon-` from the `spark_version` and set + // `runtime_engine` to `PHOTON`. + // + // If left unspecified, the runtime engine defaults to standard unless the + // spark_version contains -photon-, in which case Photon will be used. + RuntimeEngine RuntimeEngine `json:"runtime_engine,omitempty"` + // Single user name if data_security_mode is `SINGLE_USER` + SingleUserName *string `json:"single_user_name,omitempty"` + // An object containing a set of optional, user-specified Spark configuration + // key-value pairs. Users can also pass in a string of extra JVM options to the + // driver and the executors via `spark.driver.extraJavaOptions` and + // `spark.executor.extraJavaOptions` respectively. + SparkConf map[string]string `json:"spark_conf,omitempty"` + // An object containing a set of optional, user-specified environment variable + // key-value pairs. Please note that key-value pair of the form (X,Y) will be + // exported as is (i.e., `export X='Y'`) while launching the driver and workers. + // + // In order to specify an additional set of `SPARK_DAEMON_JAVA_OPTS`, we + // recommend appending them to `$SPARK_DAEMON_JAVA_OPTS` as shown in the example + // below. This ensures that all default databricks managed environmental + // variables are included as well. + // + // Example Spark environment variables: `{"SPARK_WORKER_MEMORY": "28000m", + // "SPARK_LOCAL_DIRS": "/local_disk0"}` or `{"SPARK_DAEMON_JAVA_OPTS": + // "$SPARK_DAEMON_JAVA_OPTS -Dspark.shuffle.service.enabled=true"}` + SparkEnvVars map[string]string `json:"spark_env_vars,omitempty"` + // The Spark version of the cluster, e.g. `3.3.x-scala2.11`. A list of available + // Spark versions can be retrieved by using the [clusters/sparkVersions] API + // call. + // + // [clusters/sparkVersions]: https://docs.databricks.com/api/workspace/clusters/sparkversions + SparkVersion *string `json:"spark_version,omitempty"` + // SSH public key contents that will be added to each Spark node in this + // cluster. The corresponding private keys can be used to login with the user + // name `ubuntu` on port `2200`. Up to 10 keys can be specified. + SshPublicKeys []string `json:"ssh_public_keys,omitempty"` + // If set, what the total initial volume size (in GB) of the remote disks should + // be. Supported for GCP. + TotalInitialRemoteDiskSize *int `json:"total_initial_remote_disk_size,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // `effective_spark_version` is determined by `spark_version` (DBR release), + // this field `use_ml_runtime`, and whether `node_type_id` is gpu node or not. + UseMlRuntime *bool `json:"use_ml_runtime,omitempty"` + // Flexible node type configuration for worker nodes. + WorkerNodeTypeFlexibility *NodeTypeFlexibility `json:"worker_node_type_flexibility,omitempty"` + WorkloadType *WorkloadType `json:"workload_type,omitempty"` +} + +// Cluster log delivery config. +type ClusterLogConf struct { + Dbfs *DbfsStorageInfo `json:"dbfs,omitempty"` + S3 *S3StorageInfo `json:"s3,omitempty"` + Volumes *VolumesStorageInfo `json:"volumes,omitempty"` +} + +type ClusterSize struct { + Autoscale *AutoScale `json:"autoscale,omitempty"` + NumWorkers *int `json:"num_workers,omitempty"` +} + +type CreateClusterRequest struct { + // When set to true, fixed and default values from the policy will be used for + // fields that are omitted. When set to false, only fixed values from the policy + // will be applied. + ApplyPolicyDefaultValues *bool `json:"apply_policy_default_values,omitempty"` + Autoscale *AutoScale `json:"autoscale,omitempty"` + // Automatically terminates the cluster after it is inactive for this time in + // minutes. If not set, this cluster will not be automatically terminated. If + // specified, the threshold must be between 10 and 10000 minutes. Users can also + // set this value to 0 to explicitly disable automatic termination. + AutoterminationMinutes *int `json:"autotermination_minutes,omitempty"` + // Attributes related to clusters running on Amazon Web Services. If not + // specified at cluster creation, a set of default values will be used. + AwsAttributes *AwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to clusters running on Microsoft Azure. If not specified + // at cluster creation, a set of default values will be used. + AzureAttributes *AzureAttributes `json:"azure_attributes,omitempty"` + // When specified, this clones libraries from a source cluster during the + // creation of a new cluster. + CloneFrom *CloneCluster `json:"clone_from,omitempty"` + // The configuration for delivering spark logs to a long-term storage + // destination. Three kinds of destinations (DBFS, S3 and Unity Catalog volumes) + // are supported. Only one destination can be specified for one cluster. If the + // conf is given, the logs will be delivered to the destination every `5 mins`. + // The destination of driver logs is `$destination/$clusterId/driver`, while the + // destination of executor logs is `$destination/$clusterId/executor`. + ClusterLogConf *ClusterLogConf `json:"cluster_log_conf,omitempty"` + // Cluster name requested by the user. This doesn't have to be unique. If not + // specified at creation, the cluster name will be an empty string. For job + // clusters, the cluster name is automatically set based on the job and job run + // IDs. + ClusterName *string `json:"cluster_name,omitempty"` + // Additional tags for cluster resources. will tag all cluster + // resources (e.g., AWS instances and EBS volumes) with these tags in addition + // to `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + // + // - Clusters can only reuse cloud resources if the resources' tags are a subset + // of the cluster tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + DataSecurityMode DataSecurityMode `json:"data_security_mode,omitempty"` + // Controls dependency configuration for the cluster. + DependencyMode DependencyMode `json:"dependency_mode,omitempty"` + // Custom docker image BYOC + DockerImage *DockerImage `json:"docker_image,omitempty"` + // The optional ID of the instance pool for the driver of the cluster belongs. + // The pool cluster uses the instance pool with id (instance_pool_id) if the + // driver pool is not assigned. + DriverInstancePoolId *string `json:"driver_instance_pool_id,omitempty"` + // Flexible node type configuration for the driver node. + DriverNodeTypeFlexibility *NodeTypeFlexibility `json:"driver_node_type_flexibility,omitempty"` + // The node type of the Spark driver. Note that this field is optional; if + // unset, the driver node type will be set as the same value as `node_type_id` + // defined above. + // + // This field, along with node_type_id, should not be set if + // virtual_cluster_size is set. If both driver_node_type_id, node_type_id, and + // virtual_cluster_size are specified, driver_node_type_id and node_type_id take + // precedence. + DriverNodeTypeId *string `json:"driver_node_type_id,omitempty"` + // Autoscaling Local Storage: when enabled, this cluster will dynamically + // acquire additional disk space when its Spark workers are running low on disk + // space. + EnableElasticDisk *bool `json:"enable_elastic_disk,omitempty"` + // Whether to enable LUKS on cluster VMs' local disks + EnableLocalDiskEncryption *bool `json:"enable_local_disk_encryption,omitempty"` + // Attributes related to clusters running on Google Cloud Platform. If not + // specified at cluster creation, a set of default values will be used. + GcpAttributes *GcpAttributes `json:"gcp_attributes,omitempty"` + // The configuration for storing init scripts. Any number of destinations can be + // specified. The scripts are executed sequentially in the order provided. If + // `cluster_log_conf` is specified, init script logs are sent to + // `//init_scripts`. + InitScripts []InitScriptInfo `json:"init_scripts,omitempty"` + // The optional ID of the instance pool to which the cluster belongs. + InstancePoolId *string `json:"instance_pool_id,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // When set to true, will automatically set single node related + // `custom_tags`, `spark_conf`, and `num_workers` + IsSingleNode *bool `json:"is_single_node,omitempty"` + Kind ComputeKind `json:"kind,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // [clusters/listNodeTypes] API call. + // + // [clusters/listNodeTypes]: https://docs.databricks.com/api/workspace/clusters/listnodetypes + NodeTypeId *string `json:"node_type_id,omitempty"` + NumWorkers *int `json:"num_workers,omitempty"` + // The ID of the cluster policy used to create the cluster if applicable. + PolicyId *string `json:"policy_id,omitempty"` + // If set, what the configurable throughput (in Mb/s) for the remote disk is. + // Currently only supported for GCP HYPERDISK_BALANCED disks. + RemoteDiskThroughput *int `json:"remote_disk_throughput,omitempty"` + // Determines the cluster's runtime engine, either standard or Photon. + // + // This field is not compatible with legacy `spark_version` values that contain + // `-photon-`. Remove `-photon-` from the `spark_version` and set + // `runtime_engine` to `PHOTON`. + // + // If left unspecified, the runtime engine defaults to standard unless the + // spark_version contains -photon-, in which case Photon will be used. + RuntimeEngine RuntimeEngine `json:"runtime_engine,omitempty"` + // Single user name if data_security_mode is `SINGLE_USER` + SingleUserName *string `json:"single_user_name,omitempty"` + // An object containing a set of optional, user-specified Spark configuration + // key-value pairs. Users can also pass in a string of extra JVM options to the + // driver and the executors via `spark.driver.extraJavaOptions` and + // `spark.executor.extraJavaOptions` respectively. + SparkConf map[string]string `json:"spark_conf,omitempty"` + // An object containing a set of optional, user-specified environment variable + // key-value pairs. Please note that key-value pair of the form (X,Y) will be + // exported as is (i.e., `export X='Y'`) while launching the driver and workers. + // + // In order to specify an additional set of `SPARK_DAEMON_JAVA_OPTS`, we + // recommend appending them to `$SPARK_DAEMON_JAVA_OPTS` as shown in the example + // below. This ensures that all default databricks managed environmental + // variables are included as well. + // + // Example Spark environment variables: `{"SPARK_WORKER_MEMORY": "28000m", + // "SPARK_LOCAL_DIRS": "/local_disk0"}` or `{"SPARK_DAEMON_JAVA_OPTS": + // "$SPARK_DAEMON_JAVA_OPTS -Dspark.shuffle.service.enabled=true"}` + SparkEnvVars map[string]string `json:"spark_env_vars,omitempty"` + // The Spark version of the cluster, e.g. `3.3.x-scala2.11`. A list of available + // Spark versions can be retrieved by using the [clusters/sparkVersions] API + // call. + // + // [clusters/sparkVersions]: https://docs.databricks.com/api/workspace/clusters/sparkversions + SparkVersion *string `json:"spark_version,omitempty"` + // SSH public key contents that will be added to each Spark node in this + // cluster. The corresponding private keys can be used to login with the user + // name `ubuntu` on port `2200`. Up to 10 keys can be specified. + SshPublicKeys []string `json:"ssh_public_keys,omitempty"` + // If set, what the total initial volume size (in GB) of the remote disks should + // be. Supported for GCP. + TotalInitialRemoteDiskSize *int `json:"total_initial_remote_disk_size,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // `effective_spark_version` is determined by `spark_version` (DBR release), + // this field `use_ml_runtime`, and whether `node_type_id` is gpu node or not. + UseMlRuntime *bool `json:"use_ml_runtime,omitempty"` + // Flexible node type configuration for worker nodes. + WorkerNodeTypeFlexibility *NodeTypeFlexibility `json:"worker_node_type_flexibility,omitempty"` + WorkloadType *WorkloadType `json:"workload_type,omitempty"` +} + +type CreateClusterResponse struct { + ClusterId *string `json:"cluster_id,omitempty"` +} + +type DataPlaneEventDetails struct { + EventType DataPlaneClusterEventType `json:"event_type,omitempty"` + ExecutorFailures *int `json:"executor_failures,omitempty"` + HostId *string `json:"host_id,omitempty"` + Timestamp *int64 `json:"timestamp,omitempty"` +} + +// A storage location in DBFS. +type DbfsStorageInfo struct { + // dbfs destination, e.g. `dbfs:/my/path` + Destination *string `json:"destination,omitempty"` +} + +type DeleteClusterRequest struct { + // The cluster to be terminated. + ClusterId *string `json:"cluster_id,omitempty"` +} + +type DockerBasicAuth struct { + // Password of the user + Password *string `json:"password,omitempty"` + // Name of the user + Username *string `json:"username,omitempty"` +} + +type DockerImage struct { + BasicAuth *DockerBasicAuth `json:"basic_auth,omitempty"` + // URL of the docker image. + Url *string `json:"url,omitempty"` +} + +type EditClusterRequest struct { + // When set to true, fixed and default values from the policy will be used for + // fields that are omitted. When set to false, only fixed values from the policy + // will be applied. + ApplyPolicyDefaultValues *bool `json:"apply_policy_default_values,omitempty"` + Autoscale *AutoScale `json:"autoscale,omitempty"` + // Automatically terminates the cluster after it is inactive for this time in + // minutes. If not set, this cluster will not be automatically terminated. If + // specified, the threshold must be between 10 and 10000 minutes. Users can also + // set this value to 0 to explicitly disable automatic termination. + AutoterminationMinutes *int `json:"autotermination_minutes,omitempty"` + // Attributes related to clusters running on Amazon Web Services. If not + // specified at cluster creation, a set of default values will be used. + AwsAttributes *AwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to clusters running on Microsoft Azure. If not specified + // at cluster creation, a set of default values will be used. + AzureAttributes *AzureAttributes `json:"azure_attributes,omitempty"` + // ID of the cluster + ClusterId *string `json:"cluster_id,omitempty"` + // The configuration for delivering spark logs to a long-term storage + // destination. Three kinds of destinations (DBFS, S3 and Unity Catalog volumes) + // are supported. Only one destination can be specified for one cluster. If the + // conf is given, the logs will be delivered to the destination every `5 mins`. + // The destination of driver logs is `$destination/$clusterId/driver`, while the + // destination of executor logs is `$destination/$clusterId/executor`. + ClusterLogConf *ClusterLogConf `json:"cluster_log_conf,omitempty"` + // Cluster name requested by the user. This doesn't have to be unique. If not + // specified at creation, the cluster name will be an empty string. For job + // clusters, the cluster name is automatically set based on the job and job run + // IDs. + ClusterName *string `json:"cluster_name,omitempty"` + // Additional tags for cluster resources. will tag all cluster + // resources (e.g., AWS instances and EBS volumes) with these tags in addition + // to `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + // + // - Clusters can only reuse cloud resources if the resources' tags are a subset + // of the cluster tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + DataSecurityMode DataSecurityMode `json:"data_security_mode,omitempty"` + // Controls dependency configuration for the cluster. + DependencyMode DependencyMode `json:"dependency_mode,omitempty"` + // Custom docker image BYOC + DockerImage *DockerImage `json:"docker_image,omitempty"` + // The optional ID of the instance pool for the driver of the cluster belongs. + // The pool cluster uses the instance pool with id (instance_pool_id) if the + // driver pool is not assigned. + DriverInstancePoolId *string `json:"driver_instance_pool_id,omitempty"` + // Flexible node type configuration for the driver node. + DriverNodeTypeFlexibility *NodeTypeFlexibility `json:"driver_node_type_flexibility,omitempty"` + // The node type of the Spark driver. Note that this field is optional; if + // unset, the driver node type will be set as the same value as `node_type_id` + // defined above. + // + // This field, along with node_type_id, should not be set if + // virtual_cluster_size is set. If both driver_node_type_id, node_type_id, and + // virtual_cluster_size are specified, driver_node_type_id and node_type_id take + // precedence. + DriverNodeTypeId *string `json:"driver_node_type_id,omitempty"` + // Autoscaling Local Storage: when enabled, this cluster will dynamically + // acquire additional disk space when its Spark workers are running low on disk + // space. + EnableElasticDisk *bool `json:"enable_elastic_disk,omitempty"` + // Whether to enable LUKS on cluster VMs' local disks + EnableLocalDiskEncryption *bool `json:"enable_local_disk_encryption,omitempty"` + // Attributes related to clusters running on Google Cloud Platform. If not + // specified at cluster creation, a set of default values will be used. + GcpAttributes *GcpAttributes `json:"gcp_attributes,omitempty"` + // The configuration for storing init scripts. Any number of destinations can be + // specified. The scripts are executed sequentially in the order provided. If + // `cluster_log_conf` is specified, init script logs are sent to + // `//init_scripts`. + InitScripts []InitScriptInfo `json:"init_scripts,omitempty"` + // The optional ID of the instance pool to which the cluster belongs. + InstancePoolId *string `json:"instance_pool_id,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // When set to true, will automatically set single node related + // `custom_tags`, `spark_conf`, and `num_workers` + IsSingleNode *bool `json:"is_single_node,omitempty"` + Kind ComputeKind `json:"kind,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // [clusters/listNodeTypes] API call. + // + // [clusters/listNodeTypes]: https://docs.databricks.com/api/workspace/clusters/listnodetypes + NodeTypeId *string `json:"node_type_id,omitempty"` + NumWorkers *int `json:"num_workers,omitempty"` + // The ID of the cluster policy used to create the cluster if applicable. + PolicyId *string `json:"policy_id,omitempty"` + // If set, what the configurable throughput (in Mb/s) for the remote disk is. + // Currently only supported for GCP HYPERDISK_BALANCED disks. + RemoteDiskThroughput *int `json:"remote_disk_throughput,omitempty"` + // Determines the cluster's runtime engine, either standard or Photon. + // + // This field is not compatible with legacy `spark_version` values that contain + // `-photon-`. Remove `-photon-` from the `spark_version` and set + // `runtime_engine` to `PHOTON`. + // + // If left unspecified, the runtime engine defaults to standard unless the + // spark_version contains -photon-, in which case Photon will be used. + RuntimeEngine RuntimeEngine `json:"runtime_engine,omitempty"` + // Single user name if data_security_mode is `SINGLE_USER` + SingleUserName *string `json:"single_user_name,omitempty"` + // An object containing a set of optional, user-specified Spark configuration + // key-value pairs. Users can also pass in a string of extra JVM options to the + // driver and the executors via `spark.driver.extraJavaOptions` and + // `spark.executor.extraJavaOptions` respectively. + SparkConf map[string]string `json:"spark_conf,omitempty"` + // An object containing a set of optional, user-specified environment variable + // key-value pairs. Please note that key-value pair of the form (X,Y) will be + // exported as is (i.e., `export X='Y'`) while launching the driver and workers. + // + // In order to specify an additional set of `SPARK_DAEMON_JAVA_OPTS`, we + // recommend appending them to `$SPARK_DAEMON_JAVA_OPTS` as shown in the example + // below. This ensures that all default databricks managed environmental + // variables are included as well. + // + // Example Spark environment variables: `{"SPARK_WORKER_MEMORY": "28000m", + // "SPARK_LOCAL_DIRS": "/local_disk0"}` or `{"SPARK_DAEMON_JAVA_OPTS": + // "$SPARK_DAEMON_JAVA_OPTS -Dspark.shuffle.service.enabled=true"}` + SparkEnvVars map[string]string `json:"spark_env_vars,omitempty"` + // The Spark version of the cluster, e.g. `3.3.x-scala2.11`. A list of available + // Spark versions can be retrieved by using the [clusters/sparkVersions] API + // call. + // + // [clusters/sparkVersions]: https://docs.databricks.com/api/workspace/clusters/sparkversions + SparkVersion *string `json:"spark_version,omitempty"` + // SSH public key contents that will be added to each Spark node in this + // cluster. The corresponding private keys can be used to login with the user + // name `ubuntu` on port `2200`. Up to 10 keys can be specified. + SshPublicKeys []string `json:"ssh_public_keys,omitempty"` + // If set, what the total initial volume size (in GB) of the remote disks should + // be. Supported for GCP. + TotalInitialRemoteDiskSize *int `json:"total_initial_remote_disk_size,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // `effective_spark_version` is determined by `spark_version` (DBR release), + // this field `use_ml_runtime`, and whether `node_type_id` is gpu node or not. + UseMlRuntime *bool `json:"use_ml_runtime,omitempty"` + // Flexible node type configuration for worker nodes. + WorkerNodeTypeFlexibility *NodeTypeFlexibility `json:"worker_node_type_flexibility,omitempty"` + WorkloadType *WorkloadType `json:"workload_type,omitempty"` +} + +type EnforcePolicyComplianceForClusterRequest struct { + // The ID of the cluster you want to enforce policy compliance on. + ClusterId *string `json:"cluster_id,omitempty"` + // Determines how changes should be made to clusters that are not in + // `TERMINATED` state. + // + // - `ENFORCE_IMMEDIATELY`: If the cluster is in a `RUNNING` state, it will be + // restarted so that the new attributes can take effect. For other states aside + // from `TERMINATED` state, the request will be rejected. - + // `WAIT_FOR_TERMINATION`: The cluster is not immediately edited. Instead, a + // pending enforcement is scheduled to update the cluster when it terminates or + // restarts. When this occurs, `enforce_result` will contain `DEFERRED`. Only + // workspace admins can use this mode. + // + // Regardless of the enforce mode, clusters in `TERMINATED` state are + // immediately edited. + EnforceMode EnforcePolicyComplianceForClusterRequest_EnforceMode `json:"enforce_mode,omitempty"` + // If set, previews the changes that would be made to a cluster to enforce + // compliance but does not update the cluster. + ValidateOnly *bool `json:"validate_only,omitempty"` +} + +type EnforcePolicyComplianceForClusterResponse struct { + // A list of changes that have been made to the cluster settings for the cluster + // to become compliant with its policy. + Changes []EnforcePolicyComplianceForClusterResponse_ClusterSettingsChange `json:"changes,omitempty"` + // Describes whether changes have been applied to the cluster. + EnforceResult EnforcePolicyComplianceForClusterResponse_EnforceResult `json:"enforce_result,omitempty"` + // Whether any changes have been made to the cluster settings for the cluster to + // become compliant with its policy. + HasChanges *bool `json:"has_changes,omitempty"` +} + +type EnforcePolicyComplianceForClusterResponse_ClusterSettings struct { + Autoscale *AutoScale `json:"autoscale,omitempty"` + // Automatically terminates the cluster after it is inactive for this time in + // minutes. If not set, this cluster will not be automatically terminated. If + // specified, the threshold must be between 10 and 10000 minutes. Users can also + // set this value to 0 to explicitly disable automatic termination. + AutoterminationMinutes *int `json:"autotermination_minutes,omitempty"` + // Attributes related to clusters running on Amazon Web Services. If not + // specified at cluster creation, a set of default values will be used. + AwsAttributes *AwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to clusters running on Microsoft Azure. If not specified + // at cluster creation, a set of default values will be used. + AzureAttributes *AzureAttributes `json:"azure_attributes,omitempty"` + // The configuration for delivering spark logs to a long-term storage + // destination. Three kinds of destinations (DBFS, S3 and Unity Catalog volumes) + // are supported. Only one destination can be specified for one cluster. If the + // conf is given, the logs will be delivered to the destination every `5 mins`. + // The destination of driver logs is `$destination/$clusterId/driver`, while the + // destination of executor logs is `$destination/$clusterId/executor`. + ClusterLogConf *ClusterLogConf `json:"cluster_log_conf,omitempty"` + // Cluster name requested by the user. This doesn't have to be unique. If not + // specified at creation, the cluster name will be an empty string. For job + // clusters, the cluster name is automatically set based on the job and job run + // IDs. + ClusterName *string `json:"cluster_name,omitempty"` + // Additional tags for cluster resources. will tag all cluster + // resources (e.g., AWS instances and EBS volumes) with these tags in addition + // to `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + // + // - Clusters can only reuse cloud resources if the resources' tags are a subset + // of the cluster tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + DataSecurityMode DataSecurityMode `json:"data_security_mode,omitempty"` + // Controls dependency configuration for the cluster. + DependencyMode DependencyMode `json:"dependency_mode,omitempty"` + // Custom docker image BYOC + DockerImage *DockerImage `json:"docker_image,omitempty"` + // The optional ID of the instance pool for the driver of the cluster belongs. + // The pool cluster uses the instance pool with id (instance_pool_id) if the + // driver pool is not assigned. + DriverInstancePoolId *string `json:"driver_instance_pool_id,omitempty"` + // Flexible node type configuration for the driver node. + DriverNodeTypeFlexibility *NodeTypeFlexibility `json:"driver_node_type_flexibility,omitempty"` + // The node type of the Spark driver. Note that this field is optional; if + // unset, the driver node type will be set as the same value as `node_type_id` + // defined above. + // + // This field, along with node_type_id, should not be set if + // virtual_cluster_size is set. If both driver_node_type_id, node_type_id, and + // virtual_cluster_size are specified, driver_node_type_id and node_type_id take + // precedence. + DriverNodeTypeId *string `json:"driver_node_type_id,omitempty"` + // Autoscaling Local Storage: when enabled, this cluster will dynamically + // acquire additional disk space when its Spark workers are running low on disk + // space. + EnableElasticDisk *bool `json:"enable_elastic_disk,omitempty"` + // Whether to enable LUKS on cluster VMs' local disks + EnableLocalDiskEncryption *bool `json:"enable_local_disk_encryption,omitempty"` + // Attributes related to clusters running on Google Cloud Platform. If not + // specified at cluster creation, a set of default values will be used. + GcpAttributes *GcpAttributes `json:"gcp_attributes,omitempty"` + // The configuration for storing init scripts. Any number of destinations can be + // specified. The scripts are executed sequentially in the order provided. If + // `cluster_log_conf` is specified, init script logs are sent to + // `//init_scripts`. + InitScripts []InitScriptInfo `json:"init_scripts,omitempty"` + // The optional ID of the instance pool to which the cluster belongs. + InstancePoolId *string `json:"instance_pool_id,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // When set to true, will automatically set single node related + // `custom_tags`, `spark_conf`, and `num_workers` + IsSingleNode *bool `json:"is_single_node,omitempty"` + Kind ComputeKind `json:"kind,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // [clusters/listNodeTypes] API call. + // + // [clusters/listNodeTypes]: https://docs.databricks.com/api/workspace/clusters/listnodetypes + NodeTypeId *string `json:"node_type_id,omitempty"` + NumWorkers *int `json:"num_workers,omitempty"` + // The ID of the cluster policy used to create the cluster if applicable. + PolicyId *string `json:"policy_id,omitempty"` + // If set, what the configurable throughput (in Mb/s) for the remote disk is. + // Currently only supported for GCP HYPERDISK_BALANCED disks. + RemoteDiskThroughput *int `json:"remote_disk_throughput,omitempty"` + // Determines the cluster's runtime engine, either standard or Photon. + // + // This field is not compatible with legacy `spark_version` values that contain + // `-photon-`. Remove `-photon-` from the `spark_version` and set + // `runtime_engine` to `PHOTON`. + // + // If left unspecified, the runtime engine defaults to standard unless the + // spark_version contains -photon-, in which case Photon will be used. + RuntimeEngine RuntimeEngine `json:"runtime_engine,omitempty"` + // Single user name if data_security_mode is `SINGLE_USER` + SingleUserName *string `json:"single_user_name,omitempty"` + // An object containing a set of optional, user-specified Spark configuration + // key-value pairs. Users can also pass in a string of extra JVM options to the + // driver and the executors via `spark.driver.extraJavaOptions` and + // `spark.executor.extraJavaOptions` respectively. + SparkConf map[string]string `json:"spark_conf,omitempty"` + // An object containing a set of optional, user-specified environment variable + // key-value pairs. Please note that key-value pair of the form (X,Y) will be + // exported as is (i.e., `export X='Y'`) while launching the driver and workers. + // + // In order to specify an additional set of `SPARK_DAEMON_JAVA_OPTS`, we + // recommend appending them to `$SPARK_DAEMON_JAVA_OPTS` as shown in the example + // below. This ensures that all default databricks managed environmental + // variables are included as well. + // + // Example Spark environment variables: `{"SPARK_WORKER_MEMORY": "28000m", + // "SPARK_LOCAL_DIRS": "/local_disk0"}` or `{"SPARK_DAEMON_JAVA_OPTS": + // "$SPARK_DAEMON_JAVA_OPTS -Dspark.shuffle.service.enabled=true"}` + SparkEnvVars map[string]string `json:"spark_env_vars,omitempty"` + // The Spark version of the cluster, e.g. `3.3.x-scala2.11`. A list of available + // Spark versions can be retrieved by using the [clusters/sparkVersions] API + // call. + // + // [clusters/sparkVersions]: https://docs.databricks.com/api/workspace/clusters/sparkversions + SparkVersion *string `json:"spark_version,omitempty"` + // SSH public key contents that will be added to each Spark node in this + // cluster. The corresponding private keys can be used to login with the user + // name `ubuntu` on port `2200`. Up to 10 keys can be specified. + SshPublicKeys []string `json:"ssh_public_keys,omitempty"` + // If set, what the total initial volume size (in GB) of the remote disks should + // be. Supported for GCP. + TotalInitialRemoteDiskSize *int `json:"total_initial_remote_disk_size,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // `effective_spark_version` is determined by `spark_version` (DBR release), + // this field `use_ml_runtime`, and whether `node_type_id` is gpu node or not. + UseMlRuntime *bool `json:"use_ml_runtime,omitempty"` + // Flexible node type configuration for worker nodes. + WorkerNodeTypeFlexibility *NodeTypeFlexibility `json:"worker_node_type_flexibility,omitempty"` + WorkloadType *WorkloadType `json:"workload_type,omitempty"` +} + +// Represents a change to the cluster settings required for the cluster to +// become compliant with its policy.. +type EnforcePolicyComplianceForClusterResponse_ClusterSettingsChange struct { + // The field where this change would be made. + Field *string `json:"field,omitempty"` + // The new value of this field after enforcing policy compliance (either a + // number, a boolean, or a string) converted to a string. This is intended to be + // read by a human. The typed new value of this field can be retrieved by + // reading the settings field in the API response. + NewValue *string `json:"new_value,omitempty"` + // The previous value of this field before enforcing policy compliance (either a + // number, a boolean, or a string) converted to a string. This is intended to be + // read by a human. The type of the field can be retrieved by reading the + // settings field in the API response. + PreviousValue *string `json:"previous_value,omitempty"` +} + +type EventDetails struct { + // * For created clusters, the attributes of the cluster. * For edited clusters, + // the new attributes of the cluster. + Attributes *ClusterAttributes `json:"attributes,omitempty"` + // The cause of a change in target size. + Cause ResizeCause_ResizeCause `json:"cause,omitempty"` + // The actual cluster size that was set in the cluster creation or edit. + ClusterSize *ClusterSize `json:"cluster_size,omitempty"` + // The current number of vCPUs in the cluster. + CurrentNumVcpus *int `json:"current_num_vcpus,omitempty"` + // The current number of nodes in the cluster. + CurrentNumWorkers *int `json:"current_num_workers,omitempty"` + DidNotExpandReason *string `json:"did_not_expand_reason,omitempty"` + // Current disk size in bytes + DiskSize *int64 `json:"disk_size,omitempty"` + // More details about the change in driver's state + DriverStateMessage *string `json:"driver_state_message,omitempty"` + // Whether or not a blocklisted node should be terminated. For ClusterEventType + // NODE_BLACKLISTED. + EnableTerminationForNodeBlocklisted *bool `json:"enable_termination_for_node_blocklisted,omitempty"` + FreeSpace *int64 `json:"free_space,omitempty"` + // List of global and cluster init scripts associated with this cluster event. + InitScripts *InitScriptEventDetails `json:"init_scripts,omitempty"` + // Instance Id where the event originated from + InstanceId *string `json:"instance_id,omitempty"` + // Unique identifier of the specific job run associated with this cluster event + // * For clusters created for jobs, this will be the same as the cluster name + JobRunName *string `json:"job_run_name,omitempty"` + // The cluster attributes before a cluster was edited. + PreviousAttributes *ClusterAttributes `json:"previous_attributes,omitempty"` + // The size of the cluster before an edit or resize. + PreviousClusterSize *ClusterSize `json:"previous_cluster_size,omitempty"` + // Previous disk size in bytes + PreviousDiskSize *int64 `json:"previous_disk_size,omitempty"` + // A termination reason: * On a TERMINATED event, this is the reason of the + // termination. * On a RESIZE_COMPLETE event, this indicates the reason that we + // failed to acquire some nodes. + Reason *TerminationReason `json:"reason,omitempty"` + // The targeted number of vCPUs in the cluster. + TargetNumVcpus *int `json:"target_num_vcpus,omitempty"` + // The targeted number of nodes in the cluster. + TargetNumWorkers *int `json:"target_num_workers,omitempty"` + // The user that caused the event to occur. (Empty if it was done by the control + // plane.) + User *string `json:"user,omitempty"` +} + +// Attributes set during cluster creation which are related to GCP.. +type GcpAttributes struct { + // This field determines whether the spark executors will be scheduled to run on + // preemptible VMs, on-demand VMs, or preemptible VMs with a fallback to + // on-demand VMs if the former is unavailable. + Availability GcpAvailability `json:"availability,omitempty"` + // Boot disk size in GB + BootDiskSize *int `json:"boot_disk_size,omitempty"` + // The confidential computing technology for this cluster's instances. Currently + // only SEV_SNP is supported, and only on N2D instance types. When not set, no + // confidential computing is applied. + ConfidentialComputeType ConfidentialComputeType `json:"confidential_compute_type,omitempty"` + // The first `first_on_demand` nodes of the cluster will be placed on on-demand + // instances. This value should be greater than 0, to make sure the cluster + // driver node is placed on an on-demand instance. If this value is greater than + // or equal to the current cluster size, all nodes will be placed on on-demand + // instances. If this value is less than the current cluster size, + // `first_on_demand` nodes will be placed on on-demand instances and the + // remainder will be placed on `availability` instances. Note that this value + // does not affect cluster size and cannot currently be mutated over the + // lifetime of a cluster. + FirstOnDemand *int `json:"first_on_demand,omitempty"` + // If provided, the cluster will impersonate the google service account when + // accessing gcloud services (like GCS). The google service account must have + // previously been added to the environment by an account + // administrator. + GoogleServiceAccount *string `json:"google_service_account,omitempty"` + // If provided, each node (workers and driver) in the cluster will have this + // number of local SSDs attached. Each local SSD is 375GB in size. Refer to [GCP + // documentation] for the supported number of local SSDs for each instance type. + // + // [GCP documentation]: https://cloud.google.com/compute/docs/disks/local-ssd#choose_number_local_ssds + LocalSsdCount *int `json:"local_ssd_count,omitempty"` + // This field determines whether the spark executors will be scheduled to run on + // preemptible VMs (when set to true) versus standard compute engine VMs (when + // set to false; default). Note: Soon to be deprecated, use the 'availability' + // field instead. + UsePreemptibleExecutors *bool `json:"use_preemptible_executors,omitempty"` + // Identifier for the availability zone in which the cluster resides. This can + // be one of the following: - "HA" => High availability, spread nodes across + // availability zones for a deployment region [default]. - "AUTO" + // => picks an availability zone to schedule the cluster on. - A + // GCP availability zone => Pick One of the available zones for (machine type + + // region) from https://cloud.google.com/compute/docs/regions-zones. + ZoneId *string `json:"zone_id,omitempty"` +} + +// A storage location in Google Cloud Platform's GCS. +type GcsStorageInfo struct { + // GCS destination/URI, e.g. `gs://my-bucket/some-prefix` + Destination *string `json:"destination,omitempty"` +} + +type GetClusterRequest struct { + // The cluster about which to retrieve information. + ClusterId *string `json:"cluster_id,omitempty"` +} + +type GetEventsResponse struct { + Events []ClusterEvent `json:"events,omitempty"` + // Deprecated: use next_page_token or prev_page_token instead. + // + // The parameters required to retrieve the next page of events. Omitted if there + // are no more events to read. + NextPage *ListEventsRequest `json:"next_page,omitempty"` + // This field represents the pagination token to retrieve the next page of + // results. If the value is "", it means no further results for the request. + NextPageToken *string `json:"next_page_token,omitempty"` + // This field represents the pagination token to retrieve the previous page of + // results. If the value is "", it means no further results for the request. + PrevPageToken *string `json:"prev_page_token,omitempty"` + // Deprecated: Returns 0 when request uses page_token. Will start returning zero + // when request uses offset/limit soon. + // + // The total number of events filtered by the start_time, end_time, and + // event_types. + TotalCount *int64 `json:"total_count,omitempty"` +} + +type GetPolicyComplianceForClusterRequest struct { + // The ID of the cluster to get the compliance status + ClusterId *string `json:"cluster_id,omitempty"` +} + +type GetPolicyComplianceForClusterResponse struct { + // Whether the cluster is compliant with its policy or not. Clusters could be + // out of compliance if the policy was updated after the cluster was last + // edited. + IsCompliant *bool `json:"is_compliant,omitempty"` + // Information about the pending enforcement for the cluster. Only present if a + // pending enforcement is scheduled for the cluster. + PendingEnforcement *PendingEnforcement `json:"pending_enforcement,omitempty"` + // An object containing key-value mappings representing the first 200 policy + // validation errors. The keys indicate the path where the policy validation + // error is occurring. The values indicate an error message describing the + // policy validation error. + Violations map[string]string `json:"violations,omitempty"` +} + +type GetSparkVersionsResponse struct { + // All the available Spark versions. + Versions []SparkVersion `json:"versions,omitempty"` +} + +type InitScriptEventDetails struct { + // The cluster scoped init scripts associated with this cluster event. + Cluster []InitScriptEventDetails_InitScriptInfoAndExecutionDetails `json:"cluster,omitempty"` + // The global init scripts associated with this cluster event. + Global []InitScriptEventDetails_InitScriptInfoAndExecutionDetails `json:"global,omitempty"` + // The private ip of the node we are reporting init script execution details for + // (we will select the execution details from only one node rather than + // reporting the execution details from every node to keep these event details + // small) + // + // This should only be defined for the INIT_SCRIPTS_FINISHED event + ReportedForNode *string `json:"reported_for_node,omitempty"` +} + +type InitScriptEventDetails_InitScriptInfoAndExecutionDetails struct { + Abfss *Adlsgen2Info `json:"abfss,omitempty"` + Dbfs *DbfsStorageInfo `json:"dbfs,omitempty"` + // Additional details regarding errors (such as a file not found message if the + // status is FAILED_FETCH). This field should only be used to provide + // *additional* information to the status field, not duplicate it. + ErrorMessage *string `json:"error_message,omitempty"` + // The number duration of the script execution in seconds + ExecutionDurationSeconds *int `json:"execution_duration_seconds,omitempty"` + File *LocalFileInfo `json:"file,omitempty"` + Gcs *GcsStorageInfo `json:"gcs,omitempty"` + S3 *S3StorageInfo `json:"s3,omitempty"` + // The current status of the script + Status InitScriptExecutionDetails_InitScriptExecutionStatus `json:"status,omitempty"` + // The stderr output from the init script execution. Only populated when init + // scripts debug is enabled and script execution fails. + Stderr *string `json:"stderr,omitempty"` + Volumes *VolumesStorageInfo `json:"volumes,omitempty"` + Workspace *WorkspaceStorageInfo `json:"workspace,omitempty"` +} + +// Config for an individual init script. +type InitScriptInfo struct { + Abfss *Adlsgen2Info `json:"abfss,omitempty"` + Dbfs *DbfsStorageInfo `json:"dbfs,omitempty"` + File *LocalFileInfo `json:"file,omitempty"` + Gcs *GcsStorageInfo `json:"gcs,omitempty"` + S3 *S3StorageInfo `json:"s3,omitempty"` + Volumes *VolumesStorageInfo `json:"volumes,omitempty"` + Workspace *WorkspaceStorageInfo `json:"workspace,omitempty"` +} + +type ListAvailableZonesResponse struct { + // The availability zone if no ``zone_id`` is provided in the cluster creation + // request. + DefaultZone *string `json:"default_zone,omitempty"` + // The list of available zones (e.g., ['us-west-2c', 'us-east-2']). + Zones []string `json:"zones,omitempty"` +} + +type ListClusterComplianceForPolicyRequest struct { + // Use this field to specify the maximum number of results to be returned by the + // server. The server may further constrain the maximum number of results + // returned in a single page. + PageSize *int `json:"page_size,omitempty"` + // A page token that can be used to navigate to the next page or previous page + // as returned by `next_page_token` or `prev_page_token`. + PageToken *string `json:"page_token,omitempty"` + // Canonical unique identifier for the cluster policy. + PolicyId *string `json:"policy_id,omitempty"` +} + +type ListClusterComplianceForPolicyResponse struct { + // A list of clusters and their policy compliance statuses. + Clusters []ClusterCompliance `json:"clusters,omitempty"` + // This field represents the pagination token to retrieve the next page of + // results. If the value is "", it means no further results for the request. + NextPageToken *string `json:"next_page_token,omitempty"` + // This field represents the pagination token to retrieve the previous page of + // results. If the value is "", it means no further results for the request. + PrevPageToken *string `json:"prev_page_token,omitempty"` +} + +type ListClustersRequest struct { + // Use this field to specify the maximum number of results to be returned by the + // server. The server may further constrain the maximum number of results + // returned in a single page. + PageSize *int `json:"page_size,omitempty"` + // Use next_page_token or prev_page_token returned from the previous request to + // list the next or previous page of clusters respectively. + PageToken *string `json:"page_token,omitempty"` +} + +type ListClustersResponse struct { + Clusters []ClusterInfo `json:"clusters,omitempty"` + // This field represents the pagination token to retrieve the next page of + // results. If the value is "", it means no further results for the request. + NextPageToken *string `json:"next_page_token,omitempty"` + // This field represents the pagination token to retrieve the previous page of + // results. If the value is "", it means no further results for the request. + PrevPageToken *string `json:"prev_page_token,omitempty"` +} + +type ListEventsRequest struct { + // The ID of the cluster to retrieve events about. + ClusterId *string `json:"cluster_id,omitempty"` + // The end time in epoch milliseconds. If empty, returns events up to the + // current time. + EndTime *int64 `json:"end_time,omitempty"` + // An optional set of event types to filter on. If empty, all event types are + // returned. + EventTypes []ClusterEventType_ClusterEventType `json:"event_types,omitempty"` + // Deprecated: use page_token in combination with page_size instead. + // + // The maximum number of events to include in a page of events. Defaults to 50, + // and maximum allowed value is 500. + Limit *int64 `json:"limit,omitempty"` + // Deprecated: use page_token in combination with page_size instead. + // + // The offset in the result set. Defaults to 0 (no offset). When an offset is + // specified and the results are requested in descending order, the end_time + // field is required. + Offset *int64 `json:"offset,omitempty"` + // The order to list events in; either "ASC" or "DESC". Defaults to "DESC". + Order GetEventsOrder `json:"order,omitempty"` + // The maximum number of events to include in a page of events. The server may + // further constrain the maximum number of results returned in a single page. If + // the page_size is empty or 0, the server will decide the number of results to + // be returned. The field has to be in the range [0,500]. If the value is + // outside the range, the server enforces 0 or 500. + PageSize *int `json:"page_size,omitempty"` + // Use next_page_token or prev_page_token returned from the previous request to + // list the next or previous page of events respectively. If page_token is + // empty, the first page is returned. + PageToken *string `json:"page_token,omitempty"` + // The start time in epoch milliseconds. If empty, returns events starting from + // the beginning of time. + StartTime *int64 `json:"start_time,omitempty"` +} + +type ListNodeTypesResponse struct { + // The list of available Spark node types. + NodeTypes []NodeType `json:"node_types,omitempty"` +} + +type LocalFileInfo struct { + // local file destination, e.g. `file:/my/local/file.sh` + Destination *string `json:"destination,omitempty"` +} + +type LogAnalyticsInfo struct { + LogAnalyticsPrimaryKey *string `json:"log_analytics_primary_key,omitempty"` + LogAnalyticsWorkspaceId *string `json:"log_analytics_workspace_id,omitempty"` +} + +// The log delivery status. +type LogSyncStatus struct { + // The timestamp of last attempt. If the last attempt fails, `last_exception` + // will contain the exception in the last attempt. + LastAttempted *int64 `json:"last_attempted,omitempty"` + // The exception thrown in the last attempt, it would be null (omitted in the + // response) if there is no exception in last attempted. + LastException *string `json:"last_exception,omitempty"` +} + +// This structure embodies the machine type that hosts spark containers Note: +// this should be an internal data structure for now It is defined in proto in +// case we want to send it over the wire in the future (which is likely). +type NodeInstanceType struct { + // Unique identifier across instance types + InstanceTypeId *string `json:"instance_type_id,omitempty"` + // Size of the individual local disks attached to this instance (i.e. per local + // disk). + LocalDiskSizeGb *int `json:"local_disk_size_gb,omitempty"` + // Number of local disks that are present on this instance. + LocalDisks *int `json:"local_disks,omitempty"` + // Size of the individual local nvme disks attached to this instance (i.e. per + // local disk). + LocalNvmeDiskSizeGb *int `json:"local_nvme_disk_size_gb,omitempty"` + // Number of local nvme disks that are present on this instance. + LocalNvmeDisks *int `json:"local_nvme_disks,omitempty"` +} + +// A description of a Spark node type including both the dimensions of the node +// and the instance type on which it will be hosted.. +type NodeType struct { + // A descriptive category for this node type. Examples include "Memory + // Optimized" and "Compute Optimized". + Category *string `json:"category,omitempty"` + // A string description associated with this node type, e.g., "r3.xlarge". + Description *string `json:"description,omitempty"` + // An optional hint at the display order of node types in the UI. Within a node + // type category, lowest numbers come first. + DisplayOrder *int `json:"display_order,omitempty"` + // An identifier for the type of hardware that this node runs on, e.g., + // "r3.2xlarge" in AWS. + InstanceTypeId *string `json:"instance_type_id,omitempty"` + // Whether the node type is deprecated. Non-deprecated node types offer greater + // performance. + IsDeprecated *bool `json:"is_deprecated,omitempty"` + // AWS specific, whether this instance supports encryption in transit, used for + // hipaa and pci workloads. + IsEncryptedInTransit *bool `json:"is_encrypted_in_transit,omitempty"` + // Whether this is an Arm-based instance. + IsGraviton *bool `json:"is_graviton,omitempty"` + // Whether this node is hidden from presentation in the UI. + IsHidden *bool `json:"is_hidden,omitempty"` + // Whether this node comes with IO cache enabled by default. + IsIoCacheEnabled *bool `json:"is_io_cache_enabled,omitempty"` + // Memory (in MB) available for this node type. + MemoryMb *int `json:"memory_mb,omitempty"` + // A collection of node type info reported by the cloud provider + NodeInfo *CloudProviderNodeInfo `json:"node_info,omitempty"` + // The NodeInstanceType object corresponding to instance_type_id + NodeInstanceType *NodeInstanceType `json:"node_instance_type,omitempty"` + // Unique identifier for this node type. + NodeTypeId *string `json:"node_type_id,omitempty"` + // Number of CPU cores available for this node type. Note that this can be + // fractional, e.g., 2.5 cores, if the number of cores on a machine instance is + // not divisible by the number of Spark nodes on that machine. + NumCores *float32 `json:"num_cores,omitempty"` + // Number of GPUs available for this node type. + NumGpus *int `json:"num_gpus,omitempty"` + PhotonDriverCapable *bool `json:"photon_driver_capable,omitempty"` + PhotonWorkerCapable *bool `json:"photon_worker_capable,omitempty"` + // Whether this node type support cluster tags. + SupportClusterTags *bool `json:"support_cluster_tags,omitempty"` + // Whether this node type support EBS volumes. EBS volumes is disabled for node + // types that we could place multiple corresponding containers on the same + // hosting instance. + SupportEbsVolumes *bool `json:"support_ebs_volumes,omitempty"` + // Whether this node type supports port forwarding. + SupportPortForwarding *bool `json:"support_port_forwarding,omitempty"` +} + +// Configuration for flexible node types, allowing fallback to alternate node +// types during cluster launch and upscale.. +type NodeTypeFlexibility struct { + // A list of node type IDs to use as fallbacks when the primary node type is + // unavailable. + AlternateNodeTypeIds []string `json:"alternate_node_type_ids,omitempty"` + // The AWS Context ID for EC2 Fleet. When set (non-empty), the value is passed + // to AWS CreateFleet API to create the EC2 Fleet. + AwsContextId *string `json:"aws_context_id,omitempty"` +} + +// Represents a pending enforcement on a cluster, which contains the changes to +// make to the cluster configuration when the cluster is next terminated or +// restarted.. +type PendingEnforcement struct { + // Whether the pending enforcement will be applied. A pending enforcement begins + // in `ACTIVE` state. If the enforcement fails to apply too many times, the + // state transitions to `INACTIVE`. Afterwards, the enforcement must be + // re-scheduled to become `ACTIVE` again. + EnforcementStatus PendingEnforcement_EnforcementStatus `json:"enforcement_status,omitempty"` + // The time the pending enforcement was initiated. + InitiateTime *types.Time `json:"initiate_time,omitempty"` + // The user who initiated the pending enforcement. + InitiatorUser *string `json:"initiator_user,omitempty"` + // A list of changes that will be made to the cluster configuration when the + // pending enforcement is applied. + TargetChanges []EnforcePolicyComplianceForClusterResponse_ClusterSettingsChange `json:"target_changes,omitempty"` + // The new configuration to apply upon cluster termination or restart. + TargetSpec *EnforcePolicyComplianceForClusterResponse_ClusterSettings `json:"target_spec,omitempty"` +} + +type PermanentDeleteClusterRequest struct { + // The cluster to be deleted. + ClusterId *string `json:"cluster_id,omitempty"` +} + +type PinClusterRequest struct { + ClusterId *string `json:"cluster_id,omitempty"` +} + +type ResizeClusterRequest struct { + Autoscale *AutoScale `json:"autoscale,omitempty"` + // The cluster to be resized. + ClusterId *string `json:"cluster_id,omitempty"` + NumWorkers *int `json:"num_workers,omitempty"` +} + +type RestartClusterRequest struct { + // The cluster to be started. + ClusterId *string `json:"cluster_id,omitempty"` + RestartUser *string `json:"restart_user,omitempty"` +} + +// A storage location in Amazon S3. +type S3StorageInfo struct { + // (Optional) Set canned access control list for the logs, e.g. + // `bucket-owner-full-control`. If `canned_cal` is set, please make sure the + // cluster iam role has `s3:PutObjectAcl` permission on the destination bucket + // and prefix. The full list of possible canned acl can be found at + // http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl. + // Please also note that by default only the object owner gets full controls. If + // you are using cross account role for writing data, you may want to set + // `bucket-owner-full-control` to make bucket owner able to read the logs. + CannedAcl *string `json:"canned_acl,omitempty"` + // S3 destination, e.g. `s3://my-bucket/some-prefix` Note that logs will be + // delivered using cluster iam role, please make sure you set cluster iam role + // and the role has write access to the destination. Please also note that you + // cannot use AWS keys to deliver logs. + Destination *string `json:"destination,omitempty"` + // (Optional) Flag to enable server side encryption, `false` by default. + EnableEncryption *bool `json:"enable_encryption,omitempty"` + // (Optional) The encryption type, it could be `sse-s3` or `sse-kms`. It will be + // used only when encryption is enabled and the default type is `sse-s3`. + EncryptionType *string `json:"encryption_type,omitempty"` + // S3 endpoint, e.g. `https://s3-us-west-2.amazonaws.com`. Either region or + // endpoint needs to be set. If both are set, endpoint will be used. + Endpoint *string `json:"endpoint,omitempty"` + // (Optional) Kms key which will be used if encryption is enabled and encryption + // type is set to `sse-kms`. + KmsKey *string `json:"kms_key,omitempty"` + // S3 region, e.g. `us-west-2`. Either region or endpoint needs to be set. If + // both are set, endpoint will be used. + Region *string `json:"region,omitempty"` +} + +// Describes a specific Spark driver or executor.. +type SparkInfo_SparkNode struct { + // The private IP address of the host instance. + HostPrivateIp *string `json:"host_private_ip,omitempty"` + // Globally unique identifier for the host instance from the cloud provider. + InstanceId *string `json:"instance_id,omitempty"` + // Attributes specific to AWS for a Spark node. + NodeAwsAttributes *SparkInfo_SparkNode_SparkNodeAwsAttributes `json:"node_aws_attributes,omitempty"` + // Globally unique identifier for this node. + NodeId *string `json:"node_id,omitempty"` + // Private IP address (typically a 10.x.x.x address) of the Spark node. Note + // that this is different from the private IP address of the host instance. + PrivateIp *string `json:"private_ip,omitempty"` + // Public DNS address of this node. This address can be used to access the Spark + // JDBC server on the driver node. To communicate with the JDBC server, traffic + // must be manually authorized by adding security group rules to the + // "worker-unmanaged" security group via the AWS console. + PublicDns *string `json:"public_dns,omitempty"` + // The timestamp (in millisecond) when the Spark node is launched. + StartTimestamp *int64 `json:"start_timestamp,omitempty"` +} + +// Attributes specific to AWS for a Spark node.. +type SparkInfo_SparkNode_SparkNodeAwsAttributes struct { + // Whether this node is on an Amazon spot instance. + IsSpot *bool `json:"is_spot,omitempty"` +} + +type SparkVersion struct { + // Spark version key, for example "2.1.x-scala2.11". This is the value which + // should be provided as the "spark_version" when creating a new cluster. Note + // that the exact Spark version may change over time for a "wildcard" version + // (i.e., "2.1.x-scala2.11" is a "wildcard" version) with minor bug fixes. + Key *string `json:"key,omitempty"` + // A descriptive name for this Spark version, for example "Spark 2.1". + Name *string `json:"name,omitempty"` +} + +type StartClusterRequest struct { + // The cluster to be started. + ClusterId *string `json:"cluster_id,omitempty"` +} + +type TerminationReason struct { + // status code indicating why the cluster was terminated + Code TerminationCode `json:"code,omitempty"` + // list of parameters that provide additional information about why the cluster + // was terminated + Parameters map[string]string `json:"parameters,omitempty"` + // type of the termination + Type TerminationType `json:"type,omitempty"` +} + +type UnpinClusterRequest struct { + ClusterId *string `json:"cluster_id,omitempty"` +} + +type UpdateClusterRequest struct { + // The cluster to be updated. + Cluster *UpdateClusterRequest_UpdateClusterResource `json:"cluster,omitempty"` + // ID of the cluster. + ClusterId *string `json:"cluster_id,omitempty"` + // Used to specify which cluster attributes and size fields to update. See + // https://google.aip.dev/161 for more details. + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateClusterRequest_UpdateClusterResource struct { + Autoscale *AutoScale `json:"autoscale,omitempty"` + // Automatically terminates the cluster after it is inactive for this time in + // minutes. If not set, this cluster will not be automatically terminated. If + // specified, the threshold must be between 10 and 10000 minutes. Users can also + // set this value to 0 to explicitly disable automatic termination. + AutoterminationMinutes *int `json:"autotermination_minutes,omitempty"` + // Attributes related to clusters running on Amazon Web Services. If not + // specified at cluster creation, a set of default values will be used. + AwsAttributes *AwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to clusters running on Microsoft Azure. If not specified + // at cluster creation, a set of default values will be used. + AzureAttributes *AzureAttributes `json:"azure_attributes,omitempty"` + // The configuration for delivering spark logs to a long-term storage + // destination. Three kinds of destinations (DBFS, S3 and Unity Catalog volumes) + // are supported. Only one destination can be specified for one cluster. If the + // conf is given, the logs will be delivered to the destination every `5 mins`. + // The destination of driver logs is `$destination/$clusterId/driver`, while the + // destination of executor logs is `$destination/$clusterId/executor`. + ClusterLogConf *ClusterLogConf `json:"cluster_log_conf,omitempty"` + // Cluster name requested by the user. This doesn't have to be unique. If not + // specified at creation, the cluster name will be an empty string. For job + // clusters, the cluster name is automatically set based on the job and job run + // IDs. + ClusterName *string `json:"cluster_name,omitempty"` + // Additional tags for cluster resources. will tag all cluster + // resources (e.g., AWS instances and EBS volumes) with these tags in addition + // to `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + // + // - Clusters can only reuse cloud resources if the resources' tags are a subset + // of the cluster tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + DataSecurityMode DataSecurityMode `json:"data_security_mode,omitempty"` + // Controls dependency configuration for the cluster. + DependencyMode DependencyMode `json:"dependency_mode,omitempty"` + // Custom docker image BYOC + DockerImage *DockerImage `json:"docker_image,omitempty"` + // The optional ID of the instance pool for the driver of the cluster belongs. + // The pool cluster uses the instance pool with id (instance_pool_id) if the + // driver pool is not assigned. + DriverInstancePoolId *string `json:"driver_instance_pool_id,omitempty"` + // Flexible node type configuration for the driver node. + DriverNodeTypeFlexibility *NodeTypeFlexibility `json:"driver_node_type_flexibility,omitempty"` + // The node type of the Spark driver. Note that this field is optional; if + // unset, the driver node type will be set as the same value as `node_type_id` + // defined above. + // + // This field, along with node_type_id, should not be set if + // virtual_cluster_size is set. If both driver_node_type_id, node_type_id, and + // virtual_cluster_size are specified, driver_node_type_id and node_type_id take + // precedence. + DriverNodeTypeId *string `json:"driver_node_type_id,omitempty"` + // Autoscaling Local Storage: when enabled, this cluster will dynamically + // acquire additional disk space when its Spark workers are running low on disk + // space. + EnableElasticDisk *bool `json:"enable_elastic_disk,omitempty"` + // Whether to enable LUKS on cluster VMs' local disks + EnableLocalDiskEncryption *bool `json:"enable_local_disk_encryption,omitempty"` + // Attributes related to clusters running on Google Cloud Platform. If not + // specified at cluster creation, a set of default values will be used. + GcpAttributes *GcpAttributes `json:"gcp_attributes,omitempty"` + // The configuration for storing init scripts. Any number of destinations can be + // specified. The scripts are executed sequentially in the order provided. If + // `cluster_log_conf` is specified, init script logs are sent to + // `//init_scripts`. + InitScripts []InitScriptInfo `json:"init_scripts,omitempty"` + // The optional ID of the instance pool to which the cluster belongs. + InstancePoolId *string `json:"instance_pool_id,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // When set to true, will automatically set single node related + // `custom_tags`, `spark_conf`, and `num_workers` + IsSingleNode *bool `json:"is_single_node,omitempty"` + Kind ComputeKind `json:"kind,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // [clusters/listNodeTypes] API call. + // + // [clusters/listNodeTypes]: https://docs.databricks.com/api/workspace/clusters/listnodetypes + NodeTypeId *string `json:"node_type_id,omitempty"` + NumWorkers *int `json:"num_workers,omitempty"` + // The ID of the cluster policy used to create the cluster if applicable. + PolicyId *string `json:"policy_id,omitempty"` + // If set, what the configurable throughput (in Mb/s) for the remote disk is. + // Currently only supported for GCP HYPERDISK_BALANCED disks. + RemoteDiskThroughput *int `json:"remote_disk_throughput,omitempty"` + // Determines the cluster's runtime engine, either standard or Photon. + // + // This field is not compatible with legacy `spark_version` values that contain + // `-photon-`. Remove `-photon-` from the `spark_version` and set + // `runtime_engine` to `PHOTON`. + // + // If left unspecified, the runtime engine defaults to standard unless the + // spark_version contains -photon-, in which case Photon will be used. + RuntimeEngine RuntimeEngine `json:"runtime_engine,omitempty"` + // Single user name if data_security_mode is `SINGLE_USER` + SingleUserName *string `json:"single_user_name,omitempty"` + // An object containing a set of optional, user-specified Spark configuration + // key-value pairs. Users can also pass in a string of extra JVM options to the + // driver and the executors via `spark.driver.extraJavaOptions` and + // `spark.executor.extraJavaOptions` respectively. + SparkConf map[string]string `json:"spark_conf,omitempty"` + // An object containing a set of optional, user-specified environment variable + // key-value pairs. Please note that key-value pair of the form (X,Y) will be + // exported as is (i.e., `export X='Y'`) while launching the driver and workers. + // + // In order to specify an additional set of `SPARK_DAEMON_JAVA_OPTS`, we + // recommend appending them to `$SPARK_DAEMON_JAVA_OPTS` as shown in the example + // below. This ensures that all default databricks managed environmental + // variables are included as well. + // + // Example Spark environment variables: `{"SPARK_WORKER_MEMORY": "28000m", + // "SPARK_LOCAL_DIRS": "/local_disk0"}` or `{"SPARK_DAEMON_JAVA_OPTS": + // "$SPARK_DAEMON_JAVA_OPTS -Dspark.shuffle.service.enabled=true"}` + SparkEnvVars map[string]string `json:"spark_env_vars,omitempty"` + // The Spark version of the cluster, e.g. `3.3.x-scala2.11`. A list of available + // Spark versions can be retrieved by using the [clusters/sparkVersions] API + // call. + // + // [clusters/sparkVersions]: https://docs.databricks.com/api/workspace/clusters/sparkversions + SparkVersion *string `json:"spark_version,omitempty"` + // SSH public key contents that will be added to each Spark node in this + // cluster. The corresponding private keys can be used to login with the user + // name `ubuntu` on port `2200`. Up to 10 keys can be specified. + SshPublicKeys []string `json:"ssh_public_keys,omitempty"` + // If set, what the total initial volume size (in GB) of the remote disks should + // be. Supported for GCP. + TotalInitialRemoteDiskSize *int `json:"total_initial_remote_disk_size,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // `effective_spark_version` is determined by `spark_version` (DBR release), + // this field `use_ml_runtime`, and whether `node_type_id` is gpu node or not. + UseMlRuntime *bool `json:"use_ml_runtime,omitempty"` + // Flexible node type configuration for worker nodes. + WorkerNodeTypeFlexibility *NodeTypeFlexibility `json:"worker_node_type_flexibility,omitempty"` + WorkloadType *WorkloadType `json:"workload_type,omitempty"` +} + +// A storage location back by UC Volumes.. +type VolumesStorageInfo struct { + // UC Volumes destination, e.g. + // `/Volumes/catalog/schema/vol1/init-scripts/setup-datadog.sh` or + // `dbfs:/Volumes/catalog/schema/vol1/init-scripts/setup-datadog.sh` + Destination *string `json:"destination,omitempty"` +} + +// Cluster Attributes showing for clusters workload types.. +type WorkloadType struct { + // defined what type of clients can use the cluster. E.g. Notebooks, Jobs + Clients *WorkloadType_ClientsTypes `json:"clients,omitempty"` +} + +type WorkloadType_ClientsTypes struct { + // With jobs set, the cluster can be used for jobs + Jobs *bool `json:"jobs,omitempty"` + // With notebooks set, this cluster can be used for notebooks + Notebooks *bool `json:"notebooks,omitempty"` +} + +// A storage location in Workspace Filesystem (WSFS). +type WorkspaceStorageInfo struct { + // wsfs destination, e.g. `workspace:/cluster-init-scripts/setup-datadog.sh` + Destination *string `json:"destination,omitempty"` +} + +// Adlsgen2InfoToSDK converts the mirror to the sdk-go type. +func Adlsgen2InfoToSDK(w *Adlsgen2Info) (*sdk.Adlsgen2Info, error) { + if w == nil { + return nil, nil + } + out := &sdk.Adlsgen2Info{} + out.Destination = w.Destination + return out, nil +} + +// Adlsgen2InfoFromSDK converts the sdk-go type to the mirror. +func Adlsgen2InfoFromSDK(v *sdk.Adlsgen2Info) (*Adlsgen2Info, error) { + if v == nil { + return nil, nil + } + out := &Adlsgen2Info{} + out.Destination = v.Destination + return out, nil +} + +// AutoScaleToSDK converts the mirror to the sdk-go type. +func AutoScaleToSDK(w *AutoScale) (*sdk.AutoScale, error) { + if w == nil { + return nil, nil + } + out := &sdk.AutoScale{} + out.MinWorkers = w.MinWorkers + out.MaxWorkers = w.MaxWorkers + return out, nil +} + +// AutoScaleFromSDK converts the sdk-go type to the mirror. +func AutoScaleFromSDK(v *sdk.AutoScale) (*AutoScale, error) { + if v == nil { + return nil, nil + } + out := &AutoScale{} + out.MinWorkers = v.MinWorkers + out.MaxWorkers = v.MaxWorkers + return out, nil +} + +// AwsAttributesToSDK converts the mirror to the sdk-go type. +func AwsAttributesToSDK(w *AwsAttributes) (*sdk.AwsAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.AwsAttributes{} + out.FirstOnDemand = w.FirstOnDemand + out.Availability = w.Availability + out.ZoneId = w.ZoneId + out.InstanceProfileArn = w.InstanceProfileArn + out.SpotBidPricePercent = w.SpotBidPricePercent + out.EbsVolumeType = w.EbsVolumeType + out.EbsVolumeCount = w.EbsVolumeCount + out.EbsVolumeSize = w.EbsVolumeSize + out.EbsVolumeIops = w.EbsVolumeIops + out.EbsVolumeThroughput = w.EbsVolumeThroughput + return out, nil +} + +// AwsAttributesFromSDK converts the sdk-go type to the mirror. +func AwsAttributesFromSDK(v *sdk.AwsAttributes) (*AwsAttributes, error) { + if v == nil { + return nil, nil + } + out := &AwsAttributes{} + out.FirstOnDemand = v.FirstOnDemand + out.Availability = v.Availability + out.ZoneId = v.ZoneId + out.InstanceProfileArn = v.InstanceProfileArn + out.SpotBidPricePercent = v.SpotBidPricePercent + out.EbsVolumeType = v.EbsVolumeType + out.EbsVolumeCount = v.EbsVolumeCount + out.EbsVolumeSize = v.EbsVolumeSize + out.EbsVolumeIops = v.EbsVolumeIops + out.EbsVolumeThroughput = v.EbsVolumeThroughput + return out, nil +} + +// AzureAttributesToSDK converts the mirror to the sdk-go type. +func AzureAttributesToSDK(w *AzureAttributes) (*sdk.AzureAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.AzureAttributes{} + conv1, err := LogAnalyticsInfoToSDK(w.LogAnalyticsInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AzureAttributes.LogAnalyticsInfo", err) + } + out.LogAnalyticsInfo = conv1 + out.FirstOnDemand = w.FirstOnDemand + out.Availability = w.Availability + out.SpotBidMaxPrice = w.SpotBidMaxPrice + out.CapacityReservationGroup = w.CapacityReservationGroup + return out, nil +} + +// AzureAttributesFromSDK converts the sdk-go type to the mirror. +func AzureAttributesFromSDK(v *sdk.AzureAttributes) (*AzureAttributes, error) { + if v == nil { + return nil, nil + } + out := &AzureAttributes{} + conv2, err := LogAnalyticsInfoFromSDK(v.LogAnalyticsInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AzureAttributes.LogAnalyticsInfo", err) + } + out.LogAnalyticsInfo = conv2 + out.FirstOnDemand = v.FirstOnDemand + out.Availability = v.Availability + out.SpotBidMaxPrice = v.SpotBidMaxPrice + out.CapacityReservationGroup = v.CapacityReservationGroup + return out, nil +} + +// CancelPendingClusterEnforcementRequestToSDK converts the mirror to the sdk-go type. +func CancelPendingClusterEnforcementRequestToSDK(w *CancelPendingClusterEnforcementRequest) (*sdk.CancelPendingClusterEnforcementRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CancelPendingClusterEnforcementRequest{} + out.ClusterId = w.ClusterId + out.AllowMissing = w.AllowMissing + return out, nil +} + +// CancelPendingClusterEnforcementRequestFromSDK converts the sdk-go type to the mirror. +func CancelPendingClusterEnforcementRequestFromSDK(v *sdk.CancelPendingClusterEnforcementRequest) (*CancelPendingClusterEnforcementRequest, error) { + if v == nil { + return nil, nil + } + out := &CancelPendingClusterEnforcementRequest{} + out.ClusterId = v.ClusterId + out.AllowMissing = v.AllowMissing + return out, nil +} + +// ChangeClusterOwnerRequestToSDK converts the mirror to the sdk-go type. +func ChangeClusterOwnerRequestToSDK(w *ChangeClusterOwnerRequest) (*sdk.ChangeClusterOwnerRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ChangeClusterOwnerRequest{} + out.ClusterId = w.ClusterId + out.OwnerUsername = w.OwnerUsername + return out, nil +} + +// ChangeClusterOwnerRequestFromSDK converts the sdk-go type to the mirror. +func ChangeClusterOwnerRequestFromSDK(v *sdk.ChangeClusterOwnerRequest) (*ChangeClusterOwnerRequest, error) { + if v == nil { + return nil, nil + } + out := &ChangeClusterOwnerRequest{} + out.ClusterId = v.ClusterId + out.OwnerUsername = v.OwnerUsername + return out, nil +} + +// CloneClusterToSDK converts the mirror to the sdk-go type. +func CloneClusterToSDK(w *CloneCluster) (*sdk.CloneCluster, error) { + if w == nil { + return nil, nil + } + out := &sdk.CloneCluster{} + out.SourceClusterId = w.SourceClusterId + return out, nil +} + +// CloneClusterFromSDK converts the sdk-go type to the mirror. +func CloneClusterFromSDK(v *sdk.CloneCluster) (*CloneCluster, error) { + if v == nil { + return nil, nil + } + out := &CloneCluster{} + out.SourceClusterId = v.SourceClusterId + return out, nil +} + +// CloudProviderNodeInfoToSDK converts the mirror to the sdk-go type. +func CloudProviderNodeInfoToSDK(w *CloudProviderNodeInfo) (*sdk.CloudProviderNodeInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.CloudProviderNodeInfo{} + out.Status = w.Status + return out, nil +} + +// CloudProviderNodeInfoFromSDK converts the sdk-go type to the mirror. +func CloudProviderNodeInfoFromSDK(v *sdk.CloudProviderNodeInfo) (*CloudProviderNodeInfo, error) { + if v == nil { + return nil, nil + } + out := &CloudProviderNodeInfo{} + out.Status = v.Status + return out, nil +} + +// ClusterAttributesToSDK converts the mirror to the sdk-go type. +func ClusterAttributesToSDK(w *ClusterAttributes) (*sdk.ClusterAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterAttributes{} + out.ClusterName = w.ClusterName + out.SparkVersion = w.SparkVersion + out.SparkConf = w.SparkConf + conv3, err := AwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.AwsAttributes", err) + } + out.AwsAttributes = conv3 + conv4, err := AzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.AzureAttributes", err) + } + out.AzureAttributes = conv4 + conv5, err := GcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.GcpAttributes", err) + } + out.GcpAttributes = conv5 + out.NodeTypeId = w.NodeTypeId + out.DriverNodeTypeId = w.DriverNodeTypeId + conv6, err := NodeTypeFlexibilityToSDK(w.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv6 + conv7, err := NodeTypeFlexibilityToSDK(w.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv7 + out.SshPublicKeys = w.SshPublicKeys + out.CustomTags = w.CustomTags + conv8, err := ClusterLogConfToSDK(w.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.ClusterLogConf", err) + } + out.ClusterLogConf = conv8 + out.SparkEnvVars = w.SparkEnvVars + out.AutoterminationMinutes = w.AutoterminationMinutes + out.EnableElasticDisk = w.EnableElasticDisk + conv9, err := convertSlice(w.InitScripts, InitScriptInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.InitScripts", err) + } + out.InitScripts = conv9 + conv10, err := DockerImageToSDK(w.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.DockerImage", err) + } + out.DockerImage = conv10 + out.InstancePoolId = w.InstancePoolId + out.SingleUserName = w.SingleUserName + out.PolicyId = w.PolicyId + out.EnableLocalDiskEncryption = w.EnableLocalDiskEncryption + out.DriverInstancePoolId = w.DriverInstancePoolId + conv11, err := WorkloadTypeToSDK(w.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.WorkloadType", err) + } + out.WorkloadType = conv11 + out.DataSecurityMode = w.DataSecurityMode + out.RuntimeEngine = w.RuntimeEngine + out.Kind = w.Kind + out.UseMlRuntime = w.UseMlRuntime + out.IsSingleNode = w.IsSingleNode + out.RemoteDiskThroughput = w.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = w.TotalInitialRemoteDiskSize + out.DependencyMode = w.DependencyMode + return out, nil +} + +// ClusterAttributesFromSDK converts the sdk-go type to the mirror. +func ClusterAttributesFromSDK(v *sdk.ClusterAttributes) (*ClusterAttributes, error) { + if v == nil { + return nil, nil + } + out := &ClusterAttributes{} + out.ClusterName = v.ClusterName + out.SparkVersion = v.SparkVersion + out.SparkConf = v.SparkConf + conv12, err := AwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.AwsAttributes", err) + } + out.AwsAttributes = conv12 + conv13, err := AzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.AzureAttributes", err) + } + out.AzureAttributes = conv13 + conv14, err := GcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.GcpAttributes", err) + } + out.GcpAttributes = conv14 + out.NodeTypeId = v.NodeTypeId + out.DriverNodeTypeId = v.DriverNodeTypeId + conv15, err := NodeTypeFlexibilityFromSDK(v.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv15 + conv16, err := NodeTypeFlexibilityFromSDK(v.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv16 + out.SshPublicKeys = v.SshPublicKeys + out.CustomTags = v.CustomTags + conv17, err := ClusterLogConfFromSDK(v.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.ClusterLogConf", err) + } + out.ClusterLogConf = conv17 + out.SparkEnvVars = v.SparkEnvVars + out.AutoterminationMinutes = v.AutoterminationMinutes + out.EnableElasticDisk = v.EnableElasticDisk + conv18, err := convertSlice(v.InitScripts, InitScriptInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.InitScripts", err) + } + out.InitScripts = conv18 + conv19, err := DockerImageFromSDK(v.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.DockerImage", err) + } + out.DockerImage = conv19 + out.InstancePoolId = v.InstancePoolId + out.SingleUserName = v.SingleUserName + out.PolicyId = v.PolicyId + out.EnableLocalDiskEncryption = v.EnableLocalDiskEncryption + out.DriverInstancePoolId = v.DriverInstancePoolId + conv20, err := WorkloadTypeFromSDK(v.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAttributes.WorkloadType", err) + } + out.WorkloadType = conv20 + out.DataSecurityMode = v.DataSecurityMode + out.RuntimeEngine = v.RuntimeEngine + out.Kind = v.Kind + out.UseMlRuntime = v.UseMlRuntime + out.IsSingleNode = v.IsSingleNode + out.RemoteDiskThroughput = v.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = v.TotalInitialRemoteDiskSize + out.DependencyMode = v.DependencyMode + return out, nil +} + +// ClusterComplianceToSDK converts the mirror to the sdk-go type. +func ClusterComplianceToSDK(w *ClusterCompliance) (*sdk.ClusterCompliance, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterCompliance{} + out.ClusterId = w.ClusterId + out.IsCompliant = w.IsCompliant + out.Violations = w.Violations + conv21, err := PendingEnforcementToSDK(w.PendingEnforcement) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterCompliance.PendingEnforcement", err) + } + out.PendingEnforcement = conv21 + return out, nil +} + +// ClusterComplianceFromSDK converts the sdk-go type to the mirror. +func ClusterComplianceFromSDK(v *sdk.ClusterCompliance) (*ClusterCompliance, error) { + if v == nil { + return nil, nil + } + out := &ClusterCompliance{} + out.ClusterId = v.ClusterId + out.IsCompliant = v.IsCompliant + out.Violations = v.Violations + conv22, err := PendingEnforcementFromSDK(v.PendingEnforcement) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterCompliance.PendingEnforcement", err) + } + out.PendingEnforcement = conv22 + return out, nil +} + +// ClusterEventToSDK converts the mirror to the sdk-go type. +func ClusterEventToSDK(w *ClusterEvent) (*sdk.ClusterEvent, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterEvent{} + out.ClusterId = w.ClusterId + out.Timestamp = w.Timestamp + out.Type = w.Type + conv23, err := EventDetailsToSDK(w.Details) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterEvent.Details", err) + } + out.Details = conv23 + conv24, err := DataPlaneEventDetailsToSDK(w.DataPlaneEventDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterEvent.DataPlaneEventDetails", err) + } + out.DataPlaneEventDetails = conv24 + return out, nil +} + +// ClusterEventFromSDK converts the sdk-go type to the mirror. +func ClusterEventFromSDK(v *sdk.ClusterEvent) (*ClusterEvent, error) { + if v == nil { + return nil, nil + } + out := &ClusterEvent{} + out.ClusterId = v.ClusterId + out.Timestamp = v.Timestamp + out.Type = v.Type + conv25, err := EventDetailsFromSDK(v.Details) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterEvent.Details", err) + } + out.Details = conv25 + conv26, err := DataPlaneEventDetailsFromSDK(v.DataPlaneEventDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterEvent.DataPlaneEventDetails", err) + } + out.DataPlaneEventDetails = conv26 + return out, nil +} + +// ClusterInfoToSDK converts the mirror to the sdk-go type. +func ClusterInfoToSDK(w *ClusterInfo) (*sdk.ClusterInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterInfo{} + out.ClusterId = w.ClusterId + out.CreatorUserName = w.CreatorUserName + out.State = w.State + out.StateMessage = w.StateMessage + out.ClusterMemoryMb = w.ClusterMemoryMb + out.ClusterCores = w.ClusterCores + out.DefaultTags = w.DefaultTags + conv27, err := LogSyncStatusToSDK(w.ClusterLogStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.ClusterLogStatus", err) + } + out.ClusterLogStatus = conv27 + conv28, err := TerminationReasonToSDK(w.TerminationReason) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.TerminationReason", err) + } + out.TerminationReason = conv28 + conv29, err := ClusterInfo_ComputeSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.Spec", err) + } + out.Spec = conv29 + conv30, err := SparkInfo_SparkNodeToSDK(w.Driver) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.Driver", err) + } + out.Driver = conv30 + conv31, err := convertSlice(w.Executors, SparkInfo_SparkNodeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.Executors", err) + } + out.Executors = conv31 + out.SparkContextId = w.SparkContextId + out.JdbcPort = w.JdbcPort + out.ClusterName = w.ClusterName + out.SparkVersion = w.SparkVersion + out.SparkConf = w.SparkConf + conv32, err := AwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.AwsAttributes", err) + } + out.AwsAttributes = conv32 + conv33, err := AzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.AzureAttributes", err) + } + out.AzureAttributes = conv33 + conv34, err := GcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.GcpAttributes", err) + } + out.GcpAttributes = conv34 + out.NodeTypeId = w.NodeTypeId + out.DriverNodeTypeId = w.DriverNodeTypeId + conv35, err := NodeTypeFlexibilityToSDK(w.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv35 + conv36, err := NodeTypeFlexibilityToSDK(w.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv36 + out.SshPublicKeys = w.SshPublicKeys + out.CustomTags = w.CustomTags + conv37, err := ClusterLogConfToSDK(w.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.ClusterLogConf", err) + } + out.ClusterLogConf = conv37 + out.SparkEnvVars = w.SparkEnvVars + out.AutoterminationMinutes = w.AutoterminationMinutes + out.EnableElasticDisk = w.EnableElasticDisk + conv38, err := convertSlice(w.InitScripts, InitScriptInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.InitScripts", err) + } + out.InitScripts = conv38 + conv39, err := DockerImageToSDK(w.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.DockerImage", err) + } + out.DockerImage = conv39 + out.InstancePoolId = w.InstancePoolId + out.SingleUserName = w.SingleUserName + out.PolicyId = w.PolicyId + out.EnableLocalDiskEncryption = w.EnableLocalDiskEncryption + out.DriverInstancePoolId = w.DriverInstancePoolId + conv40, err := WorkloadTypeToSDK(w.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.WorkloadType", err) + } + out.WorkloadType = conv40 + out.DataSecurityMode = w.DataSecurityMode + out.RuntimeEngine = w.RuntimeEngine + out.Kind = w.Kind + out.UseMlRuntime = w.UseMlRuntime + out.IsSingleNode = w.IsSingleNode + out.RemoteDiskThroughput = w.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = w.TotalInitialRemoteDiskSize + out.DependencyMode = w.DependencyMode + out.StartTime = w.StartTime + out.TerminatedTime = w.TerminatedTime + out.LastStateLossTime = w.LastStateLossTime + out.LastRestartedTime = w.LastRestartedTime + { + var members []string + if w.NumWorkers != nil { + members = append(members, "num_workers") + } + if w.Autoscale != nil { + members = append(members, "autoscale") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NumWorkers != nil: + out.Size = &sdk.ClusterInfo_Size_NumWorkers{NumWorkers: *w.NumWorkers} + case w.Autoscale != nil: + conv41, err := AutoScaleToSDK(w.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.Size", err) + } + out.Size = &sdk.ClusterInfo_Size_Autoscale{Autoscale: *conv41} + } + return out, nil +} + +// ClusterInfoFromSDK converts the sdk-go type to the mirror. +func ClusterInfoFromSDK(v *sdk.ClusterInfo) (*ClusterInfo, error) { + if v == nil { + return nil, nil + } + out := &ClusterInfo{} + out.ClusterId = v.ClusterId + out.CreatorUserName = v.CreatorUserName + out.State = v.State + out.StateMessage = v.StateMessage + out.ClusterMemoryMb = v.ClusterMemoryMb + out.ClusterCores = v.ClusterCores + out.DefaultTags = v.DefaultTags + conv42, err := LogSyncStatusFromSDK(v.ClusterLogStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.ClusterLogStatus", err) + } + out.ClusterLogStatus = conv42 + conv43, err := TerminationReasonFromSDK(v.TerminationReason) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.TerminationReason", err) + } + out.TerminationReason = conv43 + conv44, err := ClusterInfo_ComputeSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.Spec", err) + } + out.Spec = conv44 + conv45, err := SparkInfo_SparkNodeFromSDK(v.Driver) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.Driver", err) + } + out.Driver = conv45 + conv46, err := convertSlice(v.Executors, SparkInfo_SparkNodeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.Executors", err) + } + out.Executors = conv46 + out.SparkContextId = v.SparkContextId + out.JdbcPort = v.JdbcPort + out.ClusterName = v.ClusterName + out.SparkVersion = v.SparkVersion + out.SparkConf = v.SparkConf + conv47, err := AwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.AwsAttributes", err) + } + out.AwsAttributes = conv47 + conv48, err := AzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.AzureAttributes", err) + } + out.AzureAttributes = conv48 + conv49, err := GcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.GcpAttributes", err) + } + out.GcpAttributes = conv49 + out.NodeTypeId = v.NodeTypeId + out.DriverNodeTypeId = v.DriverNodeTypeId + conv50, err := NodeTypeFlexibilityFromSDK(v.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv50 + conv51, err := NodeTypeFlexibilityFromSDK(v.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv51 + out.SshPublicKeys = v.SshPublicKeys + out.CustomTags = v.CustomTags + conv52, err := ClusterLogConfFromSDK(v.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.ClusterLogConf", err) + } + out.ClusterLogConf = conv52 + out.SparkEnvVars = v.SparkEnvVars + out.AutoterminationMinutes = v.AutoterminationMinutes + out.EnableElasticDisk = v.EnableElasticDisk + conv53, err := convertSlice(v.InitScripts, InitScriptInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.InitScripts", err) + } + out.InitScripts = conv53 + conv54, err := DockerImageFromSDK(v.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.DockerImage", err) + } + out.DockerImage = conv54 + out.InstancePoolId = v.InstancePoolId + out.SingleUserName = v.SingleUserName + out.PolicyId = v.PolicyId + out.EnableLocalDiskEncryption = v.EnableLocalDiskEncryption + out.DriverInstancePoolId = v.DriverInstancePoolId + conv55, err := WorkloadTypeFromSDK(v.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.WorkloadType", err) + } + out.WorkloadType = conv55 + out.DataSecurityMode = v.DataSecurityMode + out.RuntimeEngine = v.RuntimeEngine + out.Kind = v.Kind + out.UseMlRuntime = v.UseMlRuntime + out.IsSingleNode = v.IsSingleNode + out.RemoteDiskThroughput = v.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = v.TotalInitialRemoteDiskSize + out.DependencyMode = v.DependencyMode + out.StartTime = v.StartTime + out.TerminatedTime = v.TerminatedTime + out.LastStateLossTime = v.LastStateLossTime + out.LastRestartedTime = v.LastRestartedTime + switch value := v.Size.(type) { + case *sdk.ClusterInfo_Size_NumWorkers: + if value != nil { + out.NumWorkers = new(value.NumWorkers) + } + case *sdk.ClusterInfo_Size_Autoscale: + if value != nil { + conv56, err := AutoScaleFromSDK(&value.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo.Size", err) + } + out.Autoscale = conv56 + } + } + return out, nil +} + +// ClusterInfo_ComputeSpecToSDK converts the mirror to the sdk-go type. +func ClusterInfo_ComputeSpecToSDK(w *ClusterInfo_ComputeSpec) (*sdk.ClusterInfo_ComputeSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterInfo_ComputeSpec{} + out.ApplyPolicyDefaultValues = w.ApplyPolicyDefaultValues + out.ClusterName = w.ClusterName + out.SparkVersion = w.SparkVersion + out.SparkConf = w.SparkConf + conv57, err := AwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.AwsAttributes", err) + } + out.AwsAttributes = conv57 + conv58, err := AzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.AzureAttributes", err) + } + out.AzureAttributes = conv58 + conv59, err := GcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.GcpAttributes", err) + } + out.GcpAttributes = conv59 + out.NodeTypeId = w.NodeTypeId + out.DriverNodeTypeId = w.DriverNodeTypeId + conv60, err := NodeTypeFlexibilityToSDK(w.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv60 + conv61, err := NodeTypeFlexibilityToSDK(w.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv61 + out.SshPublicKeys = w.SshPublicKeys + out.CustomTags = w.CustomTags + conv62, err := ClusterLogConfToSDK(w.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.ClusterLogConf", err) + } + out.ClusterLogConf = conv62 + out.SparkEnvVars = w.SparkEnvVars + out.AutoterminationMinutes = w.AutoterminationMinutes + out.EnableElasticDisk = w.EnableElasticDisk + conv63, err := convertSlice(w.InitScripts, InitScriptInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.InitScripts", err) + } + out.InitScripts = conv63 + conv64, err := DockerImageToSDK(w.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.DockerImage", err) + } + out.DockerImage = conv64 + out.InstancePoolId = w.InstancePoolId + out.SingleUserName = w.SingleUserName + out.PolicyId = w.PolicyId + out.EnableLocalDiskEncryption = w.EnableLocalDiskEncryption + out.DriverInstancePoolId = w.DriverInstancePoolId + conv65, err := WorkloadTypeToSDK(w.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.WorkloadType", err) + } + out.WorkloadType = conv65 + out.DataSecurityMode = w.DataSecurityMode + out.RuntimeEngine = w.RuntimeEngine + out.Kind = w.Kind + out.UseMlRuntime = w.UseMlRuntime + out.IsSingleNode = w.IsSingleNode + out.RemoteDiskThroughput = w.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = w.TotalInitialRemoteDiskSize + out.DependencyMode = w.DependencyMode + { + var members []string + if w.NumWorkers != nil { + members = append(members, "num_workers") + } + if w.Autoscale != nil { + members = append(members, "autoscale") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NumWorkers != nil: + out.Size = &sdk.ClusterInfo_ComputeSpec_Size_NumWorkers{NumWorkers: *w.NumWorkers} + case w.Autoscale != nil: + conv66, err := AutoScaleToSDK(w.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.Size", err) + } + out.Size = &sdk.ClusterInfo_ComputeSpec_Size_Autoscale{Autoscale: *conv66} + } + return out, nil +} + +// ClusterInfo_ComputeSpecFromSDK converts the sdk-go type to the mirror. +func ClusterInfo_ComputeSpecFromSDK(v *sdk.ClusterInfo_ComputeSpec) (*ClusterInfo_ComputeSpec, error) { + if v == nil { + return nil, nil + } + out := &ClusterInfo_ComputeSpec{} + out.ApplyPolicyDefaultValues = v.ApplyPolicyDefaultValues + out.ClusterName = v.ClusterName + out.SparkVersion = v.SparkVersion + out.SparkConf = v.SparkConf + conv67, err := AwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.AwsAttributes", err) + } + out.AwsAttributes = conv67 + conv68, err := AzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.AzureAttributes", err) + } + out.AzureAttributes = conv68 + conv69, err := GcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.GcpAttributes", err) + } + out.GcpAttributes = conv69 + out.NodeTypeId = v.NodeTypeId + out.DriverNodeTypeId = v.DriverNodeTypeId + conv70, err := NodeTypeFlexibilityFromSDK(v.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv70 + conv71, err := NodeTypeFlexibilityFromSDK(v.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv71 + out.SshPublicKeys = v.SshPublicKeys + out.CustomTags = v.CustomTags + conv72, err := ClusterLogConfFromSDK(v.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.ClusterLogConf", err) + } + out.ClusterLogConf = conv72 + out.SparkEnvVars = v.SparkEnvVars + out.AutoterminationMinutes = v.AutoterminationMinutes + out.EnableElasticDisk = v.EnableElasticDisk + conv73, err := convertSlice(v.InitScripts, InitScriptInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.InitScripts", err) + } + out.InitScripts = conv73 + conv74, err := DockerImageFromSDK(v.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.DockerImage", err) + } + out.DockerImage = conv74 + out.InstancePoolId = v.InstancePoolId + out.SingleUserName = v.SingleUserName + out.PolicyId = v.PolicyId + out.EnableLocalDiskEncryption = v.EnableLocalDiskEncryption + out.DriverInstancePoolId = v.DriverInstancePoolId + conv75, err := WorkloadTypeFromSDK(v.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.WorkloadType", err) + } + out.WorkloadType = conv75 + out.DataSecurityMode = v.DataSecurityMode + out.RuntimeEngine = v.RuntimeEngine + out.Kind = v.Kind + out.UseMlRuntime = v.UseMlRuntime + out.IsSingleNode = v.IsSingleNode + out.RemoteDiskThroughput = v.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = v.TotalInitialRemoteDiskSize + out.DependencyMode = v.DependencyMode + switch value := v.Size.(type) { + case *sdk.ClusterInfo_ComputeSpec_Size_NumWorkers: + if value != nil { + out.NumWorkers = new(value.NumWorkers) + } + case *sdk.ClusterInfo_ComputeSpec_Size_Autoscale: + if value != nil { + conv76, err := AutoScaleFromSDK(&value.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterInfo_ComputeSpec.Size", err) + } + out.Autoscale = conv76 + } + } + return out, nil +} + +// ClusterLogConfToSDK converts the mirror to the sdk-go type. +func ClusterLogConfToSDK(w *ClusterLogConf) (*sdk.ClusterLogConf, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterLogConf{} + { + var members []string + if w.Dbfs != nil { + members = append(members, "dbfs") + } + if w.S3 != nil { + members = append(members, "s3") + } + if w.Volumes != nil { + members = append(members, "volumes") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Dbfs != nil: + conv77, err := DbfsStorageInfoToSDK(w.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLogConf.StorageInfo", err) + } + out.StorageInfo = &sdk.ClusterLogConf_StorageInfo_Dbfs{Dbfs: *conv77} + case w.S3 != nil: + conv78, err := S3StorageInfoToSDK(w.S3) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLogConf.StorageInfo", err) + } + out.StorageInfo = &sdk.ClusterLogConf_StorageInfo_S3{S3: *conv78} + case w.Volumes != nil: + conv79, err := VolumesStorageInfoToSDK(w.Volumes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLogConf.StorageInfo", err) + } + out.StorageInfo = &sdk.ClusterLogConf_StorageInfo_Volumes{Volumes: *conv79} + } + return out, nil +} + +// ClusterLogConfFromSDK converts the sdk-go type to the mirror. +func ClusterLogConfFromSDK(v *sdk.ClusterLogConf) (*ClusterLogConf, error) { + if v == nil { + return nil, nil + } + out := &ClusterLogConf{} + switch value := v.StorageInfo.(type) { + case *sdk.ClusterLogConf_StorageInfo_Dbfs: + if value != nil { + conv80, err := DbfsStorageInfoFromSDK(&value.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLogConf.StorageInfo", err) + } + out.Dbfs = conv80 + } + case *sdk.ClusterLogConf_StorageInfo_S3: + if value != nil { + conv81, err := S3StorageInfoFromSDK(&value.S3) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLogConf.StorageInfo", err) + } + out.S3 = conv81 + } + case *sdk.ClusterLogConf_StorageInfo_Volumes: + if value != nil { + conv82, err := VolumesStorageInfoFromSDK(&value.Volumes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLogConf.StorageInfo", err) + } + out.Volumes = conv82 + } + } + return out, nil +} + +// ClusterSizeToSDK converts the mirror to the sdk-go type. +func ClusterSizeToSDK(w *ClusterSize) (*sdk.ClusterSize, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterSize{} + { + var members []string + if w.NumWorkers != nil { + members = append(members, "num_workers") + } + if w.Autoscale != nil { + members = append(members, "autoscale") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NumWorkers != nil: + out.Size = &sdk.ClusterSize_Size_NumWorkers{NumWorkers: *w.NumWorkers} + case w.Autoscale != nil: + conv83, err := AutoScaleToSDK(w.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSize.Size", err) + } + out.Size = &sdk.ClusterSize_Size_Autoscale{Autoscale: *conv83} + } + return out, nil +} + +// ClusterSizeFromSDK converts the sdk-go type to the mirror. +func ClusterSizeFromSDK(v *sdk.ClusterSize) (*ClusterSize, error) { + if v == nil { + return nil, nil + } + out := &ClusterSize{} + switch value := v.Size.(type) { + case *sdk.ClusterSize_Size_NumWorkers: + if value != nil { + out.NumWorkers = new(value.NumWorkers) + } + case *sdk.ClusterSize_Size_Autoscale: + if value != nil { + conv84, err := AutoScaleFromSDK(&value.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSize.Size", err) + } + out.Autoscale = conv84 + } + } + return out, nil +} + +// CreateClusterRequestToSDK converts the mirror to the sdk-go type. +func CreateClusterRequestToSDK(w *CreateClusterRequest) (*sdk.CreateClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateClusterRequest{} + out.ApplyPolicyDefaultValues = w.ApplyPolicyDefaultValues + conv85, err := CloneClusterToSDK(w.CloneFrom) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.CloneFrom", err) + } + out.CloneFrom = conv85 + { + var members []string + if w.NumWorkers != nil { + members = append(members, "num_workers") + } + if w.Autoscale != nil { + members = append(members, "autoscale") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NumWorkers != nil: + out.Size = &sdk.CreateClusterRequest_Size_NumWorkers{NumWorkers: *w.NumWorkers} + case w.Autoscale != nil: + conv86, err := AutoScaleToSDK(w.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.Size", err) + } + out.Size = &sdk.CreateClusterRequest_Size_Autoscale{Autoscale: *conv86} + } + out.ClusterName = w.ClusterName + out.SparkVersion = w.SparkVersion + out.SparkConf = w.SparkConf + conv87, err := AwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.AwsAttributes", err) + } + out.AwsAttributes = conv87 + conv88, err := AzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.AzureAttributes", err) + } + out.AzureAttributes = conv88 + conv89, err := GcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.GcpAttributes", err) + } + out.GcpAttributes = conv89 + out.NodeTypeId = w.NodeTypeId + out.DriverNodeTypeId = w.DriverNodeTypeId + conv90, err := NodeTypeFlexibilityToSDK(w.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv90 + conv91, err := NodeTypeFlexibilityToSDK(w.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv91 + out.SshPublicKeys = w.SshPublicKeys + out.CustomTags = w.CustomTags + conv92, err := ClusterLogConfToSDK(w.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.ClusterLogConf", err) + } + out.ClusterLogConf = conv92 + out.SparkEnvVars = w.SparkEnvVars + out.AutoterminationMinutes = w.AutoterminationMinutes + out.EnableElasticDisk = w.EnableElasticDisk + conv93, err := convertSlice(w.InitScripts, InitScriptInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.InitScripts", err) + } + out.InitScripts = conv93 + conv94, err := DockerImageToSDK(w.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.DockerImage", err) + } + out.DockerImage = conv94 + out.InstancePoolId = w.InstancePoolId + out.SingleUserName = w.SingleUserName + out.PolicyId = w.PolicyId + out.EnableLocalDiskEncryption = w.EnableLocalDiskEncryption + out.DriverInstancePoolId = w.DriverInstancePoolId + conv95, err := WorkloadTypeToSDK(w.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.WorkloadType", err) + } + out.WorkloadType = conv95 + out.DataSecurityMode = w.DataSecurityMode + out.RuntimeEngine = w.RuntimeEngine + out.Kind = w.Kind + out.UseMlRuntime = w.UseMlRuntime + out.IsSingleNode = w.IsSingleNode + out.RemoteDiskThroughput = w.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = w.TotalInitialRemoteDiskSize + out.DependencyMode = w.DependencyMode + return out, nil +} + +// CreateClusterRequestFromSDK converts the sdk-go type to the mirror. +func CreateClusterRequestFromSDK(v *sdk.CreateClusterRequest) (*CreateClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateClusterRequest{} + out.ApplyPolicyDefaultValues = v.ApplyPolicyDefaultValues + conv96, err := CloneClusterFromSDK(v.CloneFrom) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.CloneFrom", err) + } + out.CloneFrom = conv96 + switch value := v.Size.(type) { + case *sdk.CreateClusterRequest_Size_NumWorkers: + if value != nil { + out.NumWorkers = new(value.NumWorkers) + } + case *sdk.CreateClusterRequest_Size_Autoscale: + if value != nil { + conv97, err := AutoScaleFromSDK(&value.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.Size", err) + } + out.Autoscale = conv97 + } + } + out.ClusterName = v.ClusterName + out.SparkVersion = v.SparkVersion + out.SparkConf = v.SparkConf + conv98, err := AwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.AwsAttributes", err) + } + out.AwsAttributes = conv98 + conv99, err := AzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.AzureAttributes", err) + } + out.AzureAttributes = conv99 + conv100, err := GcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.GcpAttributes", err) + } + out.GcpAttributes = conv100 + out.NodeTypeId = v.NodeTypeId + out.DriverNodeTypeId = v.DriverNodeTypeId + conv101, err := NodeTypeFlexibilityFromSDK(v.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv101 + conv102, err := NodeTypeFlexibilityFromSDK(v.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv102 + out.SshPublicKeys = v.SshPublicKeys + out.CustomTags = v.CustomTags + conv103, err := ClusterLogConfFromSDK(v.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.ClusterLogConf", err) + } + out.ClusterLogConf = conv103 + out.SparkEnvVars = v.SparkEnvVars + out.AutoterminationMinutes = v.AutoterminationMinutes + out.EnableElasticDisk = v.EnableElasticDisk + conv104, err := convertSlice(v.InitScripts, InitScriptInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.InitScripts", err) + } + out.InitScripts = conv104 + conv105, err := DockerImageFromSDK(v.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.DockerImage", err) + } + out.DockerImage = conv105 + out.InstancePoolId = v.InstancePoolId + out.SingleUserName = v.SingleUserName + out.PolicyId = v.PolicyId + out.EnableLocalDiskEncryption = v.EnableLocalDiskEncryption + out.DriverInstancePoolId = v.DriverInstancePoolId + conv106, err := WorkloadTypeFromSDK(v.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateClusterRequest.WorkloadType", err) + } + out.WorkloadType = conv106 + out.DataSecurityMode = v.DataSecurityMode + out.RuntimeEngine = v.RuntimeEngine + out.Kind = v.Kind + out.UseMlRuntime = v.UseMlRuntime + out.IsSingleNode = v.IsSingleNode + out.RemoteDiskThroughput = v.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = v.TotalInitialRemoteDiskSize + out.DependencyMode = v.DependencyMode + return out, nil +} + +// CreateClusterResponseToSDK converts the mirror to the sdk-go type. +func CreateClusterResponseToSDK(w *CreateClusterResponse) (*sdk.CreateClusterResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateClusterResponse{} + out.ClusterId = w.ClusterId + return out, nil +} + +// CreateClusterResponseFromSDK converts the sdk-go type to the mirror. +func CreateClusterResponseFromSDK(v *sdk.CreateClusterResponse) (*CreateClusterResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateClusterResponse{} + out.ClusterId = v.ClusterId + return out, nil +} + +// DataPlaneEventDetailsToSDK converts the mirror to the sdk-go type. +func DataPlaneEventDetailsToSDK(w *DataPlaneEventDetails) (*sdk.DataPlaneEventDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataPlaneEventDetails{} + out.EventType = w.EventType + out.Timestamp = w.Timestamp + out.HostId = w.HostId + out.ExecutorFailures = w.ExecutorFailures + return out, nil +} + +// DataPlaneEventDetailsFromSDK converts the sdk-go type to the mirror. +func DataPlaneEventDetailsFromSDK(v *sdk.DataPlaneEventDetails) (*DataPlaneEventDetails, error) { + if v == nil { + return nil, nil + } + out := &DataPlaneEventDetails{} + out.EventType = v.EventType + out.Timestamp = v.Timestamp + out.HostId = v.HostId + out.ExecutorFailures = v.ExecutorFailures + return out, nil +} + +// DbfsStorageInfoToSDK converts the mirror to the sdk-go type. +func DbfsStorageInfoToSDK(w *DbfsStorageInfo) (*sdk.DbfsStorageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.DbfsStorageInfo{} + out.Destination = w.Destination + return out, nil +} + +// DbfsStorageInfoFromSDK converts the sdk-go type to the mirror. +func DbfsStorageInfoFromSDK(v *sdk.DbfsStorageInfo) (*DbfsStorageInfo, error) { + if v == nil { + return nil, nil + } + out := &DbfsStorageInfo{} + out.Destination = v.Destination + return out, nil +} + +// DeleteClusterRequestToSDK converts the mirror to the sdk-go type. +func DeleteClusterRequestToSDK(w *DeleteClusterRequest) (*sdk.DeleteClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteClusterRequest{} + out.ClusterId = w.ClusterId + return out, nil +} + +// DeleteClusterRequestFromSDK converts the sdk-go type to the mirror. +func DeleteClusterRequestFromSDK(v *sdk.DeleteClusterRequest) (*DeleteClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteClusterRequest{} + out.ClusterId = v.ClusterId + return out, nil +} + +// DockerBasicAuthToSDK converts the mirror to the sdk-go type. +func DockerBasicAuthToSDK(w *DockerBasicAuth) (*sdk.DockerBasicAuth, error) { + if w == nil { + return nil, nil + } + out := &sdk.DockerBasicAuth{} + out.Username = w.Username + out.Password = w.Password + return out, nil +} + +// DockerBasicAuthFromSDK converts the sdk-go type to the mirror. +func DockerBasicAuthFromSDK(v *sdk.DockerBasicAuth) (*DockerBasicAuth, error) { + if v == nil { + return nil, nil + } + out := &DockerBasicAuth{} + out.Username = v.Username + out.Password = v.Password + return out, nil +} + +// DockerImageToSDK converts the mirror to the sdk-go type. +func DockerImageToSDK(w *DockerImage) (*sdk.DockerImage, error) { + if w == nil { + return nil, nil + } + out := &sdk.DockerImage{} + out.Url = w.Url + { + var members []string + if w.BasicAuth != nil { + members = append(members, "basic_auth") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.BasicAuth != nil: + conv107, err := DockerBasicAuthToSDK(w.BasicAuth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DockerImage.CredsOneof", err) + } + out.CredsOneof = &sdk.DockerImage_CredsOneof_BasicAuth{BasicAuth: *conv107} + } + return out, nil +} + +// DockerImageFromSDK converts the sdk-go type to the mirror. +func DockerImageFromSDK(v *sdk.DockerImage) (*DockerImage, error) { + if v == nil { + return nil, nil + } + out := &DockerImage{} + out.Url = v.Url + switch value := v.CredsOneof.(type) { + case *sdk.DockerImage_CredsOneof_BasicAuth: + if value != nil { + conv108, err := DockerBasicAuthFromSDK(&value.BasicAuth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DockerImage.CredsOneof", err) + } + out.BasicAuth = conv108 + } + } + return out, nil +} + +// EditClusterRequestToSDK converts the mirror to the sdk-go type. +func EditClusterRequestToSDK(w *EditClusterRequest) (*sdk.EditClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.EditClusterRequest{} + out.ClusterId = w.ClusterId + out.ApplyPolicyDefaultValues = w.ApplyPolicyDefaultValues + { + var members []string + if w.NumWorkers != nil { + members = append(members, "num_workers") + } + if w.Autoscale != nil { + members = append(members, "autoscale") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NumWorkers != nil: + out.Size = &sdk.EditClusterRequest_Size_NumWorkers{NumWorkers: *w.NumWorkers} + case w.Autoscale != nil: + conv109, err := AutoScaleToSDK(w.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.Size", err) + } + out.Size = &sdk.EditClusterRequest_Size_Autoscale{Autoscale: *conv109} + } + out.ClusterName = w.ClusterName + out.SparkVersion = w.SparkVersion + out.SparkConf = w.SparkConf + conv110, err := AwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.AwsAttributes", err) + } + out.AwsAttributes = conv110 + conv111, err := AzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.AzureAttributes", err) + } + out.AzureAttributes = conv111 + conv112, err := GcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.GcpAttributes", err) + } + out.GcpAttributes = conv112 + out.NodeTypeId = w.NodeTypeId + out.DriverNodeTypeId = w.DriverNodeTypeId + conv113, err := NodeTypeFlexibilityToSDK(w.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv113 + conv114, err := NodeTypeFlexibilityToSDK(w.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv114 + out.SshPublicKeys = w.SshPublicKeys + out.CustomTags = w.CustomTags + conv115, err := ClusterLogConfToSDK(w.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.ClusterLogConf", err) + } + out.ClusterLogConf = conv115 + out.SparkEnvVars = w.SparkEnvVars + out.AutoterminationMinutes = w.AutoterminationMinutes + out.EnableElasticDisk = w.EnableElasticDisk + conv116, err := convertSlice(w.InitScripts, InitScriptInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.InitScripts", err) + } + out.InitScripts = conv116 + conv117, err := DockerImageToSDK(w.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.DockerImage", err) + } + out.DockerImage = conv117 + out.InstancePoolId = w.InstancePoolId + out.SingleUserName = w.SingleUserName + out.PolicyId = w.PolicyId + out.EnableLocalDiskEncryption = w.EnableLocalDiskEncryption + out.DriverInstancePoolId = w.DriverInstancePoolId + conv118, err := WorkloadTypeToSDK(w.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.WorkloadType", err) + } + out.WorkloadType = conv118 + out.DataSecurityMode = w.DataSecurityMode + out.RuntimeEngine = w.RuntimeEngine + out.Kind = w.Kind + out.UseMlRuntime = w.UseMlRuntime + out.IsSingleNode = w.IsSingleNode + out.RemoteDiskThroughput = w.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = w.TotalInitialRemoteDiskSize + out.DependencyMode = w.DependencyMode + return out, nil +} + +// EditClusterRequestFromSDK converts the sdk-go type to the mirror. +func EditClusterRequestFromSDK(v *sdk.EditClusterRequest) (*EditClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &EditClusterRequest{} + out.ClusterId = v.ClusterId + out.ApplyPolicyDefaultValues = v.ApplyPolicyDefaultValues + switch value := v.Size.(type) { + case *sdk.EditClusterRequest_Size_NumWorkers: + if value != nil { + out.NumWorkers = new(value.NumWorkers) + } + case *sdk.EditClusterRequest_Size_Autoscale: + if value != nil { + conv119, err := AutoScaleFromSDK(&value.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.Size", err) + } + out.Autoscale = conv119 + } + } + out.ClusterName = v.ClusterName + out.SparkVersion = v.SparkVersion + out.SparkConf = v.SparkConf + conv120, err := AwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.AwsAttributes", err) + } + out.AwsAttributes = conv120 + conv121, err := AzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.AzureAttributes", err) + } + out.AzureAttributes = conv121 + conv122, err := GcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.GcpAttributes", err) + } + out.GcpAttributes = conv122 + out.NodeTypeId = v.NodeTypeId + out.DriverNodeTypeId = v.DriverNodeTypeId + conv123, err := NodeTypeFlexibilityFromSDK(v.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv123 + conv124, err := NodeTypeFlexibilityFromSDK(v.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv124 + out.SshPublicKeys = v.SshPublicKeys + out.CustomTags = v.CustomTags + conv125, err := ClusterLogConfFromSDK(v.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.ClusterLogConf", err) + } + out.ClusterLogConf = conv125 + out.SparkEnvVars = v.SparkEnvVars + out.AutoterminationMinutes = v.AutoterminationMinutes + out.EnableElasticDisk = v.EnableElasticDisk + conv126, err := convertSlice(v.InitScripts, InitScriptInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.InitScripts", err) + } + out.InitScripts = conv126 + conv127, err := DockerImageFromSDK(v.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.DockerImage", err) + } + out.DockerImage = conv127 + out.InstancePoolId = v.InstancePoolId + out.SingleUserName = v.SingleUserName + out.PolicyId = v.PolicyId + out.EnableLocalDiskEncryption = v.EnableLocalDiskEncryption + out.DriverInstancePoolId = v.DriverInstancePoolId + conv128, err := WorkloadTypeFromSDK(v.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditClusterRequest.WorkloadType", err) + } + out.WorkloadType = conv128 + out.DataSecurityMode = v.DataSecurityMode + out.RuntimeEngine = v.RuntimeEngine + out.Kind = v.Kind + out.UseMlRuntime = v.UseMlRuntime + out.IsSingleNode = v.IsSingleNode + out.RemoteDiskThroughput = v.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = v.TotalInitialRemoteDiskSize + out.DependencyMode = v.DependencyMode + return out, nil +} + +// EnforcePolicyComplianceForClusterRequestToSDK converts the mirror to the sdk-go type. +func EnforcePolicyComplianceForClusterRequestToSDK(w *EnforcePolicyComplianceForClusterRequest) (*sdk.EnforcePolicyComplianceForClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnforcePolicyComplianceForClusterRequest{} + out.ClusterId = w.ClusterId + out.ValidateOnly = w.ValidateOnly + out.EnforceMode = w.EnforceMode + return out, nil +} + +// EnforcePolicyComplianceForClusterRequestFromSDK converts the sdk-go type to the mirror. +func EnforcePolicyComplianceForClusterRequestFromSDK(v *sdk.EnforcePolicyComplianceForClusterRequest) (*EnforcePolicyComplianceForClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &EnforcePolicyComplianceForClusterRequest{} + out.ClusterId = v.ClusterId + out.ValidateOnly = v.ValidateOnly + out.EnforceMode = v.EnforceMode + return out, nil +} + +// EnforcePolicyComplianceForClusterResponseToSDK converts the mirror to the sdk-go type. +func EnforcePolicyComplianceForClusterResponseToSDK(w *EnforcePolicyComplianceForClusterResponse) (*sdk.EnforcePolicyComplianceForClusterResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnforcePolicyComplianceForClusterResponse{} + out.HasChanges = w.HasChanges + conv129, err := convertSlice(w.Changes, EnforcePolicyComplianceForClusterResponse_ClusterSettingsChangeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse.Changes", err) + } + out.Changes = conv129 + out.EnforceResult = w.EnforceResult + return out, nil +} + +// EnforcePolicyComplianceForClusterResponseFromSDK converts the sdk-go type to the mirror. +func EnforcePolicyComplianceForClusterResponseFromSDK(v *sdk.EnforcePolicyComplianceForClusterResponse) (*EnforcePolicyComplianceForClusterResponse, error) { + if v == nil { + return nil, nil + } + out := &EnforcePolicyComplianceForClusterResponse{} + out.HasChanges = v.HasChanges + conv130, err := convertSlice(v.Changes, EnforcePolicyComplianceForClusterResponse_ClusterSettingsChangeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse.Changes", err) + } + out.Changes = conv130 + out.EnforceResult = v.EnforceResult + return out, nil +} + +// EnforcePolicyComplianceForClusterResponse_ClusterSettingsToSDK converts the mirror to the sdk-go type. +func EnforcePolicyComplianceForClusterResponse_ClusterSettingsToSDK(w *EnforcePolicyComplianceForClusterResponse_ClusterSettings) (*sdk.EnforcePolicyComplianceForClusterResponse_ClusterSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnforcePolicyComplianceForClusterResponse_ClusterSettings{} + out.ClusterName = w.ClusterName + out.SparkVersion = w.SparkVersion + out.SparkConf = w.SparkConf + conv131, err := AwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.AwsAttributes", err) + } + out.AwsAttributes = conv131 + conv132, err := AzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.AzureAttributes", err) + } + out.AzureAttributes = conv132 + conv133, err := GcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.GcpAttributes", err) + } + out.GcpAttributes = conv133 + out.NodeTypeId = w.NodeTypeId + out.DriverNodeTypeId = w.DriverNodeTypeId + conv134, err := NodeTypeFlexibilityToSDK(w.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv134 + conv135, err := NodeTypeFlexibilityToSDK(w.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv135 + out.SshPublicKeys = w.SshPublicKeys + out.CustomTags = w.CustomTags + conv136, err := ClusterLogConfToSDK(w.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.ClusterLogConf", err) + } + out.ClusterLogConf = conv136 + out.SparkEnvVars = w.SparkEnvVars + out.AutoterminationMinutes = w.AutoterminationMinutes + out.EnableElasticDisk = w.EnableElasticDisk + conv137, err := convertSlice(w.InitScripts, InitScriptInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.InitScripts", err) + } + out.InitScripts = conv137 + conv138, err := DockerImageToSDK(w.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.DockerImage", err) + } + out.DockerImage = conv138 + out.InstancePoolId = w.InstancePoolId + out.SingleUserName = w.SingleUserName + out.PolicyId = w.PolicyId + out.EnableLocalDiskEncryption = w.EnableLocalDiskEncryption + out.DriverInstancePoolId = w.DriverInstancePoolId + conv139, err := WorkloadTypeToSDK(w.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.WorkloadType", err) + } + out.WorkloadType = conv139 + out.DataSecurityMode = w.DataSecurityMode + out.RuntimeEngine = w.RuntimeEngine + out.Kind = w.Kind + out.UseMlRuntime = w.UseMlRuntime + out.IsSingleNode = w.IsSingleNode + out.RemoteDiskThroughput = w.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = w.TotalInitialRemoteDiskSize + out.DependencyMode = w.DependencyMode + { + var members []string + if w.NumWorkers != nil { + members = append(members, "num_workers") + } + if w.Autoscale != nil { + members = append(members, "autoscale") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NumWorkers != nil: + out.Size = &sdk.EnforcePolicyComplianceForClusterResponse_ClusterSettings_Size_NumWorkers{NumWorkers: *w.NumWorkers} + case w.Autoscale != nil: + conv140, err := AutoScaleToSDK(w.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.Size", err) + } + out.Size = &sdk.EnforcePolicyComplianceForClusterResponse_ClusterSettings_Size_Autoscale{Autoscale: *conv140} + } + return out, nil +} + +// EnforcePolicyComplianceForClusterResponse_ClusterSettingsFromSDK converts the sdk-go type to the mirror. +func EnforcePolicyComplianceForClusterResponse_ClusterSettingsFromSDK(v *sdk.EnforcePolicyComplianceForClusterResponse_ClusterSettings) (*EnforcePolicyComplianceForClusterResponse_ClusterSettings, error) { + if v == nil { + return nil, nil + } + out := &EnforcePolicyComplianceForClusterResponse_ClusterSettings{} + out.ClusterName = v.ClusterName + out.SparkVersion = v.SparkVersion + out.SparkConf = v.SparkConf + conv141, err := AwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.AwsAttributes", err) + } + out.AwsAttributes = conv141 + conv142, err := AzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.AzureAttributes", err) + } + out.AzureAttributes = conv142 + conv143, err := GcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.GcpAttributes", err) + } + out.GcpAttributes = conv143 + out.NodeTypeId = v.NodeTypeId + out.DriverNodeTypeId = v.DriverNodeTypeId + conv144, err := NodeTypeFlexibilityFromSDK(v.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv144 + conv145, err := NodeTypeFlexibilityFromSDK(v.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv145 + out.SshPublicKeys = v.SshPublicKeys + out.CustomTags = v.CustomTags + conv146, err := ClusterLogConfFromSDK(v.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.ClusterLogConf", err) + } + out.ClusterLogConf = conv146 + out.SparkEnvVars = v.SparkEnvVars + out.AutoterminationMinutes = v.AutoterminationMinutes + out.EnableElasticDisk = v.EnableElasticDisk + conv147, err := convertSlice(v.InitScripts, InitScriptInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.InitScripts", err) + } + out.InitScripts = conv147 + conv148, err := DockerImageFromSDK(v.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.DockerImage", err) + } + out.DockerImage = conv148 + out.InstancePoolId = v.InstancePoolId + out.SingleUserName = v.SingleUserName + out.PolicyId = v.PolicyId + out.EnableLocalDiskEncryption = v.EnableLocalDiskEncryption + out.DriverInstancePoolId = v.DriverInstancePoolId + conv149, err := WorkloadTypeFromSDK(v.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.WorkloadType", err) + } + out.WorkloadType = conv149 + out.DataSecurityMode = v.DataSecurityMode + out.RuntimeEngine = v.RuntimeEngine + out.Kind = v.Kind + out.UseMlRuntime = v.UseMlRuntime + out.IsSingleNode = v.IsSingleNode + out.RemoteDiskThroughput = v.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = v.TotalInitialRemoteDiskSize + out.DependencyMode = v.DependencyMode + switch value := v.Size.(type) { + case *sdk.EnforcePolicyComplianceForClusterResponse_ClusterSettings_Size_NumWorkers: + if value != nil { + out.NumWorkers = new(value.NumWorkers) + } + case *sdk.EnforcePolicyComplianceForClusterResponse_ClusterSettings_Size_Autoscale: + if value != nil { + conv150, err := AutoScaleFromSDK(&value.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceForClusterResponse_ClusterSettings.Size", err) + } + out.Autoscale = conv150 + } + } + return out, nil +} + +// EnforcePolicyComplianceForClusterResponse_ClusterSettingsChangeToSDK converts the mirror to the sdk-go type. +func EnforcePolicyComplianceForClusterResponse_ClusterSettingsChangeToSDK(w *EnforcePolicyComplianceForClusterResponse_ClusterSettingsChange) (*sdk.EnforcePolicyComplianceForClusterResponse_ClusterSettingsChange, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnforcePolicyComplianceForClusterResponse_ClusterSettingsChange{} + out.Field = w.Field + out.PreviousValue = w.PreviousValue + out.NewValue = w.NewValue + return out, nil +} + +// EnforcePolicyComplianceForClusterResponse_ClusterSettingsChangeFromSDK converts the sdk-go type to the mirror. +func EnforcePolicyComplianceForClusterResponse_ClusterSettingsChangeFromSDK(v *sdk.EnforcePolicyComplianceForClusterResponse_ClusterSettingsChange) (*EnforcePolicyComplianceForClusterResponse_ClusterSettingsChange, error) { + if v == nil { + return nil, nil + } + out := &EnforcePolicyComplianceForClusterResponse_ClusterSettingsChange{} + out.Field = v.Field + out.PreviousValue = v.PreviousValue + out.NewValue = v.NewValue + return out, nil +} + +// EventDetailsToSDK converts the mirror to the sdk-go type. +func EventDetailsToSDK(w *EventDetails) (*sdk.EventDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.EventDetails{} + out.CurrentNumWorkers = w.CurrentNumWorkers + out.TargetNumWorkers = w.TargetNumWorkers + conv151, err := ClusterAttributesToSDK(w.PreviousAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EventDetails.PreviousAttributes", err) + } + out.PreviousAttributes = conv151 + conv152, err := ClusterAttributesToSDK(w.Attributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EventDetails.Attributes", err) + } + out.Attributes = conv152 + conv153, err := ClusterSizeToSDK(w.PreviousClusterSize) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EventDetails.PreviousClusterSize", err) + } + out.PreviousClusterSize = conv153 + conv154, err := ClusterSizeToSDK(w.ClusterSize) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EventDetails.ClusterSize", err) + } + out.ClusterSize = conv154 + out.Cause = w.Cause + conv155, err := TerminationReasonToSDK(w.Reason) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EventDetails.Reason", err) + } + out.Reason = conv155 + out.User = w.User + out.PreviousDiskSize = w.PreviousDiskSize + out.DiskSize = w.DiskSize + out.FreeSpace = w.FreeSpace + out.InstanceId = w.InstanceId + out.DidNotExpandReason = w.DidNotExpandReason + out.DriverStateMessage = w.DriverStateMessage + out.JobRunName = w.JobRunName + conv156, err := InitScriptEventDetailsToSDK(w.InitScripts) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EventDetails.InitScripts", err) + } + out.InitScripts = conv156 + out.EnableTerminationForNodeBlocklisted = w.EnableTerminationForNodeBlocklisted + out.CurrentNumVcpus = w.CurrentNumVcpus + out.TargetNumVcpus = w.TargetNumVcpus + return out, nil +} + +// EventDetailsFromSDK converts the sdk-go type to the mirror. +func EventDetailsFromSDK(v *sdk.EventDetails) (*EventDetails, error) { + if v == nil { + return nil, nil + } + out := &EventDetails{} + out.CurrentNumWorkers = v.CurrentNumWorkers + out.TargetNumWorkers = v.TargetNumWorkers + conv157, err := ClusterAttributesFromSDK(v.PreviousAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EventDetails.PreviousAttributes", err) + } + out.PreviousAttributes = conv157 + conv158, err := ClusterAttributesFromSDK(v.Attributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EventDetails.Attributes", err) + } + out.Attributes = conv158 + conv159, err := ClusterSizeFromSDK(v.PreviousClusterSize) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EventDetails.PreviousClusterSize", err) + } + out.PreviousClusterSize = conv159 + conv160, err := ClusterSizeFromSDK(v.ClusterSize) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EventDetails.ClusterSize", err) + } + out.ClusterSize = conv160 + out.Cause = v.Cause + conv161, err := TerminationReasonFromSDK(v.Reason) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EventDetails.Reason", err) + } + out.Reason = conv161 + out.User = v.User + out.PreviousDiskSize = v.PreviousDiskSize + out.DiskSize = v.DiskSize + out.FreeSpace = v.FreeSpace + out.InstanceId = v.InstanceId + out.DidNotExpandReason = v.DidNotExpandReason + out.DriverStateMessage = v.DriverStateMessage + out.JobRunName = v.JobRunName + conv162, err := InitScriptEventDetailsFromSDK(v.InitScripts) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EventDetails.InitScripts", err) + } + out.InitScripts = conv162 + out.EnableTerminationForNodeBlocklisted = v.EnableTerminationForNodeBlocklisted + out.CurrentNumVcpus = v.CurrentNumVcpus + out.TargetNumVcpus = v.TargetNumVcpus + return out, nil +} + +// GcpAttributesToSDK converts the mirror to the sdk-go type. +func GcpAttributesToSDK(w *GcpAttributes) (*sdk.GcpAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpAttributes{} + out.UsePreemptibleExecutors = w.UsePreemptibleExecutors + out.GoogleServiceAccount = w.GoogleServiceAccount + out.BootDiskSize = w.BootDiskSize + out.Availability = w.Availability + out.ZoneId = w.ZoneId + out.LocalSsdCount = w.LocalSsdCount + out.FirstOnDemand = w.FirstOnDemand + out.ConfidentialComputeType = w.ConfidentialComputeType + return out, nil +} + +// GcpAttributesFromSDK converts the sdk-go type to the mirror. +func GcpAttributesFromSDK(v *sdk.GcpAttributes) (*GcpAttributes, error) { + if v == nil { + return nil, nil + } + out := &GcpAttributes{} + out.UsePreemptibleExecutors = v.UsePreemptibleExecutors + out.GoogleServiceAccount = v.GoogleServiceAccount + out.BootDiskSize = v.BootDiskSize + out.Availability = v.Availability + out.ZoneId = v.ZoneId + out.LocalSsdCount = v.LocalSsdCount + out.FirstOnDemand = v.FirstOnDemand + out.ConfidentialComputeType = v.ConfidentialComputeType + return out, nil +} + +// GcsStorageInfoToSDK converts the mirror to the sdk-go type. +func GcsStorageInfoToSDK(w *GcsStorageInfo) (*sdk.GcsStorageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcsStorageInfo{} + out.Destination = w.Destination + return out, nil +} + +// GcsStorageInfoFromSDK converts the sdk-go type to the mirror. +func GcsStorageInfoFromSDK(v *sdk.GcsStorageInfo) (*GcsStorageInfo, error) { + if v == nil { + return nil, nil + } + out := &GcsStorageInfo{} + out.Destination = v.Destination + return out, nil +} + +// GetClusterRequestToSDK converts the mirror to the sdk-go type. +func GetClusterRequestToSDK(w *GetClusterRequest) (*sdk.GetClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetClusterRequest{} + out.ClusterId = w.ClusterId + return out, nil +} + +// GetClusterRequestFromSDK converts the sdk-go type to the mirror. +func GetClusterRequestFromSDK(v *sdk.GetClusterRequest) (*GetClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &GetClusterRequest{} + out.ClusterId = v.ClusterId + return out, nil +} + +// GetEventsResponseToSDK converts the mirror to the sdk-go type. +func GetEventsResponseToSDK(w *GetEventsResponse) (*sdk.GetEventsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetEventsResponse{} + conv163, err := convertSlice(w.Events, ClusterEventToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetEventsResponse.Events", err) + } + out.Events = conv163 + conv164, err := ListEventsRequestToSDK(w.NextPage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetEventsResponse.NextPage", err) + } + out.NextPage = conv164 + out.TotalCount = w.TotalCount + out.NextPageToken = w.NextPageToken + out.PrevPageToken = w.PrevPageToken + return out, nil +} + +// GetEventsResponseFromSDK converts the sdk-go type to the mirror. +func GetEventsResponseFromSDK(v *sdk.GetEventsResponse) (*GetEventsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetEventsResponse{} + conv165, err := convertSlice(v.Events, ClusterEventFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetEventsResponse.Events", err) + } + out.Events = conv165 + conv166, err := ListEventsRequestFromSDK(v.NextPage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetEventsResponse.NextPage", err) + } + out.NextPage = conv166 + out.TotalCount = v.TotalCount + out.NextPageToken = v.NextPageToken + out.PrevPageToken = v.PrevPageToken + return out, nil +} + +// GetPolicyComplianceForClusterRequestToSDK converts the mirror to the sdk-go type. +func GetPolicyComplianceForClusterRequestToSDK(w *GetPolicyComplianceForClusterRequest) (*sdk.GetPolicyComplianceForClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPolicyComplianceForClusterRequest{} + out.ClusterId = w.ClusterId + return out, nil +} + +// GetPolicyComplianceForClusterRequestFromSDK converts the sdk-go type to the mirror. +func GetPolicyComplianceForClusterRequestFromSDK(v *sdk.GetPolicyComplianceForClusterRequest) (*GetPolicyComplianceForClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &GetPolicyComplianceForClusterRequest{} + out.ClusterId = v.ClusterId + return out, nil +} + +// GetPolicyComplianceForClusterResponseToSDK converts the mirror to the sdk-go type. +func GetPolicyComplianceForClusterResponseToSDK(w *GetPolicyComplianceForClusterResponse) (*sdk.GetPolicyComplianceForClusterResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPolicyComplianceForClusterResponse{} + out.IsCompliant = w.IsCompliant + out.Violations = w.Violations + conv167, err := PendingEnforcementToSDK(w.PendingEnforcement) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPolicyComplianceForClusterResponse.PendingEnforcement", err) + } + out.PendingEnforcement = conv167 + return out, nil +} + +// GetPolicyComplianceForClusterResponseFromSDK converts the sdk-go type to the mirror. +func GetPolicyComplianceForClusterResponseFromSDK(v *sdk.GetPolicyComplianceForClusterResponse) (*GetPolicyComplianceForClusterResponse, error) { + if v == nil { + return nil, nil + } + out := &GetPolicyComplianceForClusterResponse{} + out.IsCompliant = v.IsCompliant + out.Violations = v.Violations + conv168, err := PendingEnforcementFromSDK(v.PendingEnforcement) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPolicyComplianceForClusterResponse.PendingEnforcement", err) + } + out.PendingEnforcement = conv168 + return out, nil +} + +// GetSparkVersionsResponseToSDK converts the mirror to the sdk-go type. +func GetSparkVersionsResponseToSDK(w *GetSparkVersionsResponse) (*sdk.GetSparkVersionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetSparkVersionsResponse{} + conv169, err := convertSlice(w.Versions, SparkVersionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetSparkVersionsResponse.Versions", err) + } + out.Versions = conv169 + return out, nil +} + +// GetSparkVersionsResponseFromSDK converts the sdk-go type to the mirror. +func GetSparkVersionsResponseFromSDK(v *sdk.GetSparkVersionsResponse) (*GetSparkVersionsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetSparkVersionsResponse{} + conv170, err := convertSlice(v.Versions, SparkVersionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetSparkVersionsResponse.Versions", err) + } + out.Versions = conv170 + return out, nil +} + +// InitScriptEventDetailsToSDK converts the mirror to the sdk-go type. +func InitScriptEventDetailsToSDK(w *InitScriptEventDetails) (*sdk.InitScriptEventDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.InitScriptEventDetails{} + out.ReportedForNode = w.ReportedForNode + conv171, err := convertSlice(w.Global, InitScriptEventDetails_InitScriptInfoAndExecutionDetailsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails.Global", err) + } + out.Global = conv171 + conv172, err := convertSlice(w.Cluster, InitScriptEventDetails_InitScriptInfoAndExecutionDetailsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails.Cluster", err) + } + out.Cluster = conv172 + return out, nil +} + +// InitScriptEventDetailsFromSDK converts the sdk-go type to the mirror. +func InitScriptEventDetailsFromSDK(v *sdk.InitScriptEventDetails) (*InitScriptEventDetails, error) { + if v == nil { + return nil, nil + } + out := &InitScriptEventDetails{} + out.ReportedForNode = v.ReportedForNode + conv173, err := convertSlice(v.Global, InitScriptEventDetails_InitScriptInfoAndExecutionDetailsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails.Global", err) + } + out.Global = conv173 + conv174, err := convertSlice(v.Cluster, InitScriptEventDetails_InitScriptInfoAndExecutionDetailsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails.Cluster", err) + } + out.Cluster = conv174 + return out, nil +} + +// InitScriptEventDetails_InitScriptInfoAndExecutionDetailsToSDK converts the mirror to the sdk-go type. +func InitScriptEventDetails_InitScriptInfoAndExecutionDetailsToSDK(w *InitScriptEventDetails_InitScriptInfoAndExecutionDetails) (*sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails{} + { + var members []string + if w.Dbfs != nil { + members = append(members, "dbfs") + } + if w.S3 != nil { + members = append(members, "s3") + } + if w.File != nil { + members = append(members, "file") + } + if w.Gcs != nil { + members = append(members, "gcs") + } + if w.Abfss != nil { + members = append(members, "abfss") + } + if w.Workspace != nil { + members = append(members, "workspace") + } + if w.Volumes != nil { + members = append(members, "volumes") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Dbfs != nil: + conv175, err := DbfsStorageInfoToSDK(w.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Dbfs{Dbfs: *conv175} + case w.S3 != nil: + conv176, err := S3StorageInfoToSDK(w.S3) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_S3{S3: *conv176} + case w.File != nil: + conv177, err := LocalFileInfoToSDK(w.File) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_File{File: *conv177} + case w.Gcs != nil: + conv178, err := GcsStorageInfoToSDK(w.Gcs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Gcs{Gcs: *conv178} + case w.Abfss != nil: + conv179, err := Adlsgen2InfoToSDK(w.Abfss) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Abfss{Abfss: *conv179} + case w.Workspace != nil: + conv180, err := WorkspaceStorageInfoToSDK(w.Workspace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Workspace{Workspace: *conv180} + case w.Volumes != nil: + conv181, err := VolumesStorageInfoToSDK(w.Volumes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Volumes{Volumes: *conv181} + } + out.Status = w.Status + out.ExecutionDurationSeconds = w.ExecutionDurationSeconds + out.ErrorMessage = w.ErrorMessage + out.Stderr = w.Stderr + return out, nil +} + +// InitScriptEventDetails_InitScriptInfoAndExecutionDetailsFromSDK converts the sdk-go type to the mirror. +func InitScriptEventDetails_InitScriptInfoAndExecutionDetailsFromSDK(v *sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails) (*InitScriptEventDetails_InitScriptInfoAndExecutionDetails, error) { + if v == nil { + return nil, nil + } + out := &InitScriptEventDetails_InitScriptInfoAndExecutionDetails{} + switch value := v.StorageInfo.(type) { + case *sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Dbfs: + if value != nil { + conv182, err := DbfsStorageInfoFromSDK(&value.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.Dbfs = conv182 + } + case *sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_S3: + if value != nil { + conv183, err := S3StorageInfoFromSDK(&value.S3) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.S3 = conv183 + } + case *sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_File: + if value != nil { + conv184, err := LocalFileInfoFromSDK(&value.File) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.File = conv184 + } + case *sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Gcs: + if value != nil { + conv185, err := GcsStorageInfoFromSDK(&value.Gcs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.Gcs = conv185 + } + case *sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Abfss: + if value != nil { + conv186, err := Adlsgen2InfoFromSDK(&value.Abfss) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.Abfss = conv186 + } + case *sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Workspace: + if value != nil { + conv187, err := WorkspaceStorageInfoFromSDK(&value.Workspace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.Workspace = conv187 + } + case *sdk.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Volumes: + if value != nil { + conv188, err := VolumesStorageInfoFromSDK(&value.Volumes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptEventDetails_InitScriptInfoAndExecutionDetails.StorageInfo", err) + } + out.Volumes = conv188 + } + } + out.Status = v.Status + out.ExecutionDurationSeconds = v.ExecutionDurationSeconds + out.ErrorMessage = v.ErrorMessage + out.Stderr = v.Stderr + return out, nil +} + +// InitScriptInfoToSDK converts the mirror to the sdk-go type. +func InitScriptInfoToSDK(w *InitScriptInfo) (*sdk.InitScriptInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.InitScriptInfo{} + { + var members []string + if w.Dbfs != nil { + members = append(members, "dbfs") + } + if w.S3 != nil { + members = append(members, "s3") + } + if w.File != nil { + members = append(members, "file") + } + if w.Gcs != nil { + members = append(members, "gcs") + } + if w.Abfss != nil { + members = append(members, "abfss") + } + if w.Workspace != nil { + members = append(members, "workspace") + } + if w.Volumes != nil { + members = append(members, "volumes") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Dbfs != nil: + conv189, err := DbfsStorageInfoToSDK(w.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_Dbfs{Dbfs: *conv189} + case w.S3 != nil: + conv190, err := S3StorageInfoToSDK(w.S3) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_S3{S3: *conv190} + case w.File != nil: + conv191, err := LocalFileInfoToSDK(w.File) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_File{File: *conv191} + case w.Gcs != nil: + conv192, err := GcsStorageInfoToSDK(w.Gcs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_Gcs{Gcs: *conv192} + case w.Abfss != nil: + conv193, err := Adlsgen2InfoToSDK(w.Abfss) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_Abfss{Abfss: *conv193} + case w.Workspace != nil: + conv194, err := WorkspaceStorageInfoToSDK(w.Workspace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_Workspace{Workspace: *conv194} + case w.Volumes != nil: + conv195, err := VolumesStorageInfoToSDK(w.Volumes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_Volumes{Volumes: *conv195} + } + return out, nil +} + +// InitScriptInfoFromSDK converts the sdk-go type to the mirror. +func InitScriptInfoFromSDK(v *sdk.InitScriptInfo) (*InitScriptInfo, error) { + if v == nil { + return nil, nil + } + out := &InitScriptInfo{} + switch value := v.StorageInfo.(type) { + case *sdk.InitScriptInfo_StorageInfo_Dbfs: + if value != nil { + conv196, err := DbfsStorageInfoFromSDK(&value.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.Dbfs = conv196 + } + case *sdk.InitScriptInfo_StorageInfo_S3: + if value != nil { + conv197, err := S3StorageInfoFromSDK(&value.S3) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.S3 = conv197 + } + case *sdk.InitScriptInfo_StorageInfo_File: + if value != nil { + conv198, err := LocalFileInfoFromSDK(&value.File) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.File = conv198 + } + case *sdk.InitScriptInfo_StorageInfo_Gcs: + if value != nil { + conv199, err := GcsStorageInfoFromSDK(&value.Gcs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.Gcs = conv199 + } + case *sdk.InitScriptInfo_StorageInfo_Abfss: + if value != nil { + conv200, err := Adlsgen2InfoFromSDK(&value.Abfss) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.Abfss = conv200 + } + case *sdk.InitScriptInfo_StorageInfo_Workspace: + if value != nil { + conv201, err := WorkspaceStorageInfoFromSDK(&value.Workspace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.Workspace = conv201 + } + case *sdk.InitScriptInfo_StorageInfo_Volumes: + if value != nil { + conv202, err := VolumesStorageInfoFromSDK(&value.Volumes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.Volumes = conv202 + } + } + return out, nil +} + +// ListAvailableZonesResponseToSDK converts the mirror to the sdk-go type. +func ListAvailableZonesResponseToSDK(w *ListAvailableZonesResponse) (*sdk.ListAvailableZonesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAvailableZonesResponse{} + out.Zones = w.Zones + out.DefaultZone = w.DefaultZone + return out, nil +} + +// ListAvailableZonesResponseFromSDK converts the sdk-go type to the mirror. +func ListAvailableZonesResponseFromSDK(v *sdk.ListAvailableZonesResponse) (*ListAvailableZonesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAvailableZonesResponse{} + out.Zones = v.Zones + out.DefaultZone = v.DefaultZone + return out, nil +} + +// ListClusterComplianceForPolicyRequestToSDK converts the mirror to the sdk-go type. +func ListClusterComplianceForPolicyRequestToSDK(w *ListClusterComplianceForPolicyRequest) (*sdk.ListClusterComplianceForPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListClusterComplianceForPolicyRequest{} + out.PolicyId = w.PolicyId + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListClusterComplianceForPolicyRequestFromSDK converts the sdk-go type to the mirror. +func ListClusterComplianceForPolicyRequestFromSDK(v *sdk.ListClusterComplianceForPolicyRequest) (*ListClusterComplianceForPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &ListClusterComplianceForPolicyRequest{} + out.PolicyId = v.PolicyId + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListClusterComplianceForPolicyResponseToSDK converts the mirror to the sdk-go type. +func ListClusterComplianceForPolicyResponseToSDK(w *ListClusterComplianceForPolicyResponse) (*sdk.ListClusterComplianceForPolicyResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListClusterComplianceForPolicyResponse{} + conv203, err := convertSlice(w.Clusters, ClusterComplianceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListClusterComplianceForPolicyResponse.Clusters", err) + } + out.Clusters = conv203 + out.NextPageToken = w.NextPageToken + out.PrevPageToken = w.PrevPageToken + return out, nil +} + +// ListClusterComplianceForPolicyResponseFromSDK converts the sdk-go type to the mirror. +func ListClusterComplianceForPolicyResponseFromSDK(v *sdk.ListClusterComplianceForPolicyResponse) (*ListClusterComplianceForPolicyResponse, error) { + if v == nil { + return nil, nil + } + out := &ListClusterComplianceForPolicyResponse{} + conv204, err := convertSlice(v.Clusters, ClusterComplianceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListClusterComplianceForPolicyResponse.Clusters", err) + } + out.Clusters = conv204 + out.NextPageToken = v.NextPageToken + out.PrevPageToken = v.PrevPageToken + return out, nil +} + +// ListClustersRequestToSDK converts the mirror to the sdk-go type. +func ListClustersRequestToSDK(w *ListClustersRequest) (*sdk.ListClustersRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListClustersRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListClustersRequestFromSDK converts the sdk-go type to the mirror. +func ListClustersRequestFromSDK(v *sdk.ListClustersRequest) (*ListClustersRequest, error) { + if v == nil { + return nil, nil + } + out := &ListClustersRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListClustersResponseToSDK converts the mirror to the sdk-go type. +func ListClustersResponseToSDK(w *ListClustersResponse) (*sdk.ListClustersResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListClustersResponse{} + conv205, err := convertSlice(w.Clusters, ClusterInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListClustersResponse.Clusters", err) + } + out.Clusters = conv205 + out.NextPageToken = w.NextPageToken + out.PrevPageToken = w.PrevPageToken + return out, nil +} + +// ListClustersResponseFromSDK converts the sdk-go type to the mirror. +func ListClustersResponseFromSDK(v *sdk.ListClustersResponse) (*ListClustersResponse, error) { + if v == nil { + return nil, nil + } + out := &ListClustersResponse{} + conv206, err := convertSlice(v.Clusters, ClusterInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListClustersResponse.Clusters", err) + } + out.Clusters = conv206 + out.NextPageToken = v.NextPageToken + out.PrevPageToken = v.PrevPageToken + return out, nil +} + +// ListEventsRequestToSDK converts the mirror to the sdk-go type. +func ListEventsRequestToSDK(w *ListEventsRequest) (*sdk.ListEventsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEventsRequest{} + out.ClusterId = w.ClusterId + out.StartTime = w.StartTime + out.EndTime = w.EndTime + out.Order = w.Order + out.EventTypes = w.EventTypes + out.Offset = w.Offset + out.Limit = w.Limit + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListEventsRequestFromSDK converts the sdk-go type to the mirror. +func ListEventsRequestFromSDK(v *sdk.ListEventsRequest) (*ListEventsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListEventsRequest{} + out.ClusterId = v.ClusterId + out.StartTime = v.StartTime + out.EndTime = v.EndTime + out.Order = v.Order + out.EventTypes = v.EventTypes + out.Offset = v.Offset + out.Limit = v.Limit + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListNodeTypesResponseToSDK converts the mirror to the sdk-go type. +func ListNodeTypesResponseToSDK(w *ListNodeTypesResponse) (*sdk.ListNodeTypesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListNodeTypesResponse{} + conv207, err := convertSlice(w.NodeTypes, NodeTypeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListNodeTypesResponse.NodeTypes", err) + } + out.NodeTypes = conv207 + return out, nil +} + +// ListNodeTypesResponseFromSDK converts the sdk-go type to the mirror. +func ListNodeTypesResponseFromSDK(v *sdk.ListNodeTypesResponse) (*ListNodeTypesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListNodeTypesResponse{} + conv208, err := convertSlice(v.NodeTypes, NodeTypeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListNodeTypesResponse.NodeTypes", err) + } + out.NodeTypes = conv208 + return out, nil +} + +// LocalFileInfoToSDK converts the mirror to the sdk-go type. +func LocalFileInfoToSDK(w *LocalFileInfo) (*sdk.LocalFileInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.LocalFileInfo{} + out.Destination = w.Destination + return out, nil +} + +// LocalFileInfoFromSDK converts the sdk-go type to the mirror. +func LocalFileInfoFromSDK(v *sdk.LocalFileInfo) (*LocalFileInfo, error) { + if v == nil { + return nil, nil + } + out := &LocalFileInfo{} + out.Destination = v.Destination + return out, nil +} + +// LogAnalyticsInfoToSDK converts the mirror to the sdk-go type. +func LogAnalyticsInfoToSDK(w *LogAnalyticsInfo) (*sdk.LogAnalyticsInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.LogAnalyticsInfo{} + out.LogAnalyticsWorkspaceId = w.LogAnalyticsWorkspaceId + out.LogAnalyticsPrimaryKey = w.LogAnalyticsPrimaryKey + return out, nil +} + +// LogAnalyticsInfoFromSDK converts the sdk-go type to the mirror. +func LogAnalyticsInfoFromSDK(v *sdk.LogAnalyticsInfo) (*LogAnalyticsInfo, error) { + if v == nil { + return nil, nil + } + out := &LogAnalyticsInfo{} + out.LogAnalyticsWorkspaceId = v.LogAnalyticsWorkspaceId + out.LogAnalyticsPrimaryKey = v.LogAnalyticsPrimaryKey + return out, nil +} + +// LogSyncStatusToSDK converts the mirror to the sdk-go type. +func LogSyncStatusToSDK(w *LogSyncStatus) (*sdk.LogSyncStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.LogSyncStatus{} + out.LastAttempted = w.LastAttempted + out.LastException = w.LastException + return out, nil +} + +// LogSyncStatusFromSDK converts the sdk-go type to the mirror. +func LogSyncStatusFromSDK(v *sdk.LogSyncStatus) (*LogSyncStatus, error) { + if v == nil { + return nil, nil + } + out := &LogSyncStatus{} + out.LastAttempted = v.LastAttempted + out.LastException = v.LastException + return out, nil +} + +// NodeInstanceTypeToSDK converts the mirror to the sdk-go type. +func NodeInstanceTypeToSDK(w *NodeInstanceType) (*sdk.NodeInstanceType, error) { + if w == nil { + return nil, nil + } + out := &sdk.NodeInstanceType{} + out.InstanceTypeId = w.InstanceTypeId + out.LocalDisks = w.LocalDisks + out.LocalDiskSizeGb = w.LocalDiskSizeGb + out.LocalNvmeDiskSizeGb = w.LocalNvmeDiskSizeGb + out.LocalNvmeDisks = w.LocalNvmeDisks + return out, nil +} + +// NodeInstanceTypeFromSDK converts the sdk-go type to the mirror. +func NodeInstanceTypeFromSDK(v *sdk.NodeInstanceType) (*NodeInstanceType, error) { + if v == nil { + return nil, nil + } + out := &NodeInstanceType{} + out.InstanceTypeId = v.InstanceTypeId + out.LocalDisks = v.LocalDisks + out.LocalDiskSizeGb = v.LocalDiskSizeGb + out.LocalNvmeDiskSizeGb = v.LocalNvmeDiskSizeGb + out.LocalNvmeDisks = v.LocalNvmeDisks + return out, nil +} + +// NodeTypeToSDK converts the mirror to the sdk-go type. +func NodeTypeToSDK(w *NodeType) (*sdk.NodeType, error) { + if w == nil { + return nil, nil + } + out := &sdk.NodeType{} + out.NodeTypeId = w.NodeTypeId + out.MemoryMb = w.MemoryMb + out.NumCores = w.NumCores + out.Description = w.Description + out.InstanceTypeId = w.InstanceTypeId + out.IsDeprecated = w.IsDeprecated + out.Category = w.Category + out.SupportEbsVolumes = w.SupportEbsVolumes + out.SupportClusterTags = w.SupportClusterTags + out.NumGpus = w.NumGpus + conv209, err := NodeInstanceTypeToSDK(w.NodeInstanceType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NodeType.NodeInstanceType", err) + } + out.NodeInstanceType = conv209 + out.IsHidden = w.IsHidden + out.SupportPortForwarding = w.SupportPortForwarding + out.DisplayOrder = w.DisplayOrder + out.IsIoCacheEnabled = w.IsIoCacheEnabled + conv210, err := CloudProviderNodeInfoToSDK(w.NodeInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NodeType.NodeInfo", err) + } + out.NodeInfo = conv210 + out.PhotonWorkerCapable = w.PhotonWorkerCapable + out.PhotonDriverCapable = w.PhotonDriverCapable + out.IsEncryptedInTransit = w.IsEncryptedInTransit + out.IsGraviton = w.IsGraviton + return out, nil +} + +// NodeTypeFromSDK converts the sdk-go type to the mirror. +func NodeTypeFromSDK(v *sdk.NodeType) (*NodeType, error) { + if v == nil { + return nil, nil + } + out := &NodeType{} + out.NodeTypeId = v.NodeTypeId + out.MemoryMb = v.MemoryMb + out.NumCores = v.NumCores + out.Description = v.Description + out.InstanceTypeId = v.InstanceTypeId + out.IsDeprecated = v.IsDeprecated + out.Category = v.Category + out.SupportEbsVolumes = v.SupportEbsVolumes + out.SupportClusterTags = v.SupportClusterTags + out.NumGpus = v.NumGpus + conv211, err := NodeInstanceTypeFromSDK(v.NodeInstanceType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NodeType.NodeInstanceType", err) + } + out.NodeInstanceType = conv211 + out.IsHidden = v.IsHidden + out.SupportPortForwarding = v.SupportPortForwarding + out.DisplayOrder = v.DisplayOrder + out.IsIoCacheEnabled = v.IsIoCacheEnabled + conv212, err := CloudProviderNodeInfoFromSDK(v.NodeInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NodeType.NodeInfo", err) + } + out.NodeInfo = conv212 + out.PhotonWorkerCapable = v.PhotonWorkerCapable + out.PhotonDriverCapable = v.PhotonDriverCapable + out.IsEncryptedInTransit = v.IsEncryptedInTransit + out.IsGraviton = v.IsGraviton + return out, nil +} + +// NodeTypeFlexibilityToSDK converts the mirror to the sdk-go type. +func NodeTypeFlexibilityToSDK(w *NodeTypeFlexibility) (*sdk.NodeTypeFlexibility, error) { + if w == nil { + return nil, nil + } + out := &sdk.NodeTypeFlexibility{} + out.AlternateNodeTypeIds = w.AlternateNodeTypeIds + out.AwsContextId = w.AwsContextId + return out, nil +} + +// NodeTypeFlexibilityFromSDK converts the sdk-go type to the mirror. +func NodeTypeFlexibilityFromSDK(v *sdk.NodeTypeFlexibility) (*NodeTypeFlexibility, error) { + if v == nil { + return nil, nil + } + out := &NodeTypeFlexibility{} + out.AlternateNodeTypeIds = v.AlternateNodeTypeIds + out.AwsContextId = v.AwsContextId + return out, nil +} + +// PendingEnforcementToSDK converts the mirror to the sdk-go type. +func PendingEnforcementToSDK(w *PendingEnforcement) (*sdk.PendingEnforcement, error) { + if w == nil { + return nil, nil + } + out := &sdk.PendingEnforcement{} + conv213, err := EnforcePolicyComplianceForClusterResponse_ClusterSettingsToSDK(w.TargetSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PendingEnforcement.TargetSpec", err) + } + out.TargetSpec = conv213 + out.InitiateTime = w.InitiateTime + out.EnforcementStatus = w.EnforcementStatus + conv214, err := convertSlice(w.TargetChanges, EnforcePolicyComplianceForClusterResponse_ClusterSettingsChangeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PendingEnforcement.TargetChanges", err) + } + out.TargetChanges = conv214 + out.InitiatorUser = w.InitiatorUser + return out, nil +} + +// PendingEnforcementFromSDK converts the sdk-go type to the mirror. +func PendingEnforcementFromSDK(v *sdk.PendingEnforcement) (*PendingEnforcement, error) { + if v == nil { + return nil, nil + } + out := &PendingEnforcement{} + conv215, err := EnforcePolicyComplianceForClusterResponse_ClusterSettingsFromSDK(v.TargetSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PendingEnforcement.TargetSpec", err) + } + out.TargetSpec = conv215 + out.InitiateTime = v.InitiateTime + out.EnforcementStatus = v.EnforcementStatus + conv216, err := convertSlice(v.TargetChanges, EnforcePolicyComplianceForClusterResponse_ClusterSettingsChangeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PendingEnforcement.TargetChanges", err) + } + out.TargetChanges = conv216 + out.InitiatorUser = v.InitiatorUser + return out, nil +} + +// PermanentDeleteClusterRequestToSDK converts the mirror to the sdk-go type. +func PermanentDeleteClusterRequestToSDK(w *PermanentDeleteClusterRequest) (*sdk.PermanentDeleteClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PermanentDeleteClusterRequest{} + out.ClusterId = w.ClusterId + return out, nil +} + +// PermanentDeleteClusterRequestFromSDK converts the sdk-go type to the mirror. +func PermanentDeleteClusterRequestFromSDK(v *sdk.PermanentDeleteClusterRequest) (*PermanentDeleteClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &PermanentDeleteClusterRequest{} + out.ClusterId = v.ClusterId + return out, nil +} + +// PinClusterRequestToSDK converts the mirror to the sdk-go type. +func PinClusterRequestToSDK(w *PinClusterRequest) (*sdk.PinClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PinClusterRequest{} + out.ClusterId = w.ClusterId + return out, nil +} + +// PinClusterRequestFromSDK converts the sdk-go type to the mirror. +func PinClusterRequestFromSDK(v *sdk.PinClusterRequest) (*PinClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &PinClusterRequest{} + out.ClusterId = v.ClusterId + return out, nil +} + +// ResizeClusterRequestToSDK converts the mirror to the sdk-go type. +func ResizeClusterRequestToSDK(w *ResizeClusterRequest) (*sdk.ResizeClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResizeClusterRequest{} + out.ClusterId = w.ClusterId + { + var members []string + if w.NumWorkers != nil { + members = append(members, "num_workers") + } + if w.Autoscale != nil { + members = append(members, "autoscale") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NumWorkers != nil: + out.Size = &sdk.ResizeClusterRequest_Size_NumWorkers{NumWorkers: *w.NumWorkers} + case w.Autoscale != nil: + conv217, err := AutoScaleToSDK(w.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResizeClusterRequest.Size", err) + } + out.Size = &sdk.ResizeClusterRequest_Size_Autoscale{Autoscale: *conv217} + } + return out, nil +} + +// ResizeClusterRequestFromSDK converts the sdk-go type to the mirror. +func ResizeClusterRequestFromSDK(v *sdk.ResizeClusterRequest) (*ResizeClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &ResizeClusterRequest{} + out.ClusterId = v.ClusterId + switch value := v.Size.(type) { + case *sdk.ResizeClusterRequest_Size_NumWorkers: + if value != nil { + out.NumWorkers = new(value.NumWorkers) + } + case *sdk.ResizeClusterRequest_Size_Autoscale: + if value != nil { + conv218, err := AutoScaleFromSDK(&value.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResizeClusterRequest.Size", err) + } + out.Autoscale = conv218 + } + } + return out, nil +} + +// RestartClusterRequestToSDK converts the mirror to the sdk-go type. +func RestartClusterRequestToSDK(w *RestartClusterRequest) (*sdk.RestartClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RestartClusterRequest{} + out.ClusterId = w.ClusterId + out.RestartUser = w.RestartUser + return out, nil +} + +// RestartClusterRequestFromSDK converts the sdk-go type to the mirror. +func RestartClusterRequestFromSDK(v *sdk.RestartClusterRequest) (*RestartClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &RestartClusterRequest{} + out.ClusterId = v.ClusterId + out.RestartUser = v.RestartUser + return out, nil +} + +// S3StorageInfoToSDK converts the mirror to the sdk-go type. +func S3StorageInfoToSDK(w *S3StorageInfo) (*sdk.S3StorageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.S3StorageInfo{} + out.Destination = w.Destination + out.Region = w.Region + out.Endpoint = w.Endpoint + out.EnableEncryption = w.EnableEncryption + out.EncryptionType = w.EncryptionType + out.KmsKey = w.KmsKey + out.CannedAcl = w.CannedAcl + return out, nil +} + +// S3StorageInfoFromSDK converts the sdk-go type to the mirror. +func S3StorageInfoFromSDK(v *sdk.S3StorageInfo) (*S3StorageInfo, error) { + if v == nil { + return nil, nil + } + out := &S3StorageInfo{} + out.Destination = v.Destination + out.Region = v.Region + out.Endpoint = v.Endpoint + out.EnableEncryption = v.EnableEncryption + out.EncryptionType = v.EncryptionType + out.KmsKey = v.KmsKey + out.CannedAcl = v.CannedAcl + return out, nil +} + +// SparkInfo_SparkNodeToSDK converts the mirror to the sdk-go type. +func SparkInfo_SparkNodeToSDK(w *SparkInfo_SparkNode) (*sdk.SparkInfo_SparkNode, error) { + if w == nil { + return nil, nil + } + out := &sdk.SparkInfo_SparkNode{} + out.PrivateIp = w.PrivateIp + out.PublicDns = w.PublicDns + out.NodeId = w.NodeId + out.InstanceId = w.InstanceId + out.StartTimestamp = w.StartTimestamp + conv219, err := SparkInfo_SparkNode_SparkNodeAwsAttributesToSDK(w.NodeAwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SparkInfo_SparkNode.NodeAwsAttributes", err) + } + out.NodeAwsAttributes = conv219 + out.HostPrivateIp = w.HostPrivateIp + return out, nil +} + +// SparkInfo_SparkNodeFromSDK converts the sdk-go type to the mirror. +func SparkInfo_SparkNodeFromSDK(v *sdk.SparkInfo_SparkNode) (*SparkInfo_SparkNode, error) { + if v == nil { + return nil, nil + } + out := &SparkInfo_SparkNode{} + out.PrivateIp = v.PrivateIp + out.PublicDns = v.PublicDns + out.NodeId = v.NodeId + out.InstanceId = v.InstanceId + out.StartTimestamp = v.StartTimestamp + conv220, err := SparkInfo_SparkNode_SparkNodeAwsAttributesFromSDK(v.NodeAwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SparkInfo_SparkNode.NodeAwsAttributes", err) + } + out.NodeAwsAttributes = conv220 + out.HostPrivateIp = v.HostPrivateIp + return out, nil +} + +// SparkInfo_SparkNode_SparkNodeAwsAttributesToSDK converts the mirror to the sdk-go type. +func SparkInfo_SparkNode_SparkNodeAwsAttributesToSDK(w *SparkInfo_SparkNode_SparkNodeAwsAttributes) (*sdk.SparkInfo_SparkNode_SparkNodeAwsAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.SparkInfo_SparkNode_SparkNodeAwsAttributes{} + out.IsSpot = w.IsSpot + return out, nil +} + +// SparkInfo_SparkNode_SparkNodeAwsAttributesFromSDK converts the sdk-go type to the mirror. +func SparkInfo_SparkNode_SparkNodeAwsAttributesFromSDK(v *sdk.SparkInfo_SparkNode_SparkNodeAwsAttributes) (*SparkInfo_SparkNode_SparkNodeAwsAttributes, error) { + if v == nil { + return nil, nil + } + out := &SparkInfo_SparkNode_SparkNodeAwsAttributes{} + out.IsSpot = v.IsSpot + return out, nil +} + +// SparkVersionToSDK converts the mirror to the sdk-go type. +func SparkVersionToSDK(w *SparkVersion) (*sdk.SparkVersion, error) { + if w == nil { + return nil, nil + } + out := &sdk.SparkVersion{} + out.Key = w.Key + out.Name = w.Name + return out, nil +} + +// SparkVersionFromSDK converts the sdk-go type to the mirror. +func SparkVersionFromSDK(v *sdk.SparkVersion) (*SparkVersion, error) { + if v == nil { + return nil, nil + } + out := &SparkVersion{} + out.Key = v.Key + out.Name = v.Name + return out, nil +} + +// StartClusterRequestToSDK converts the mirror to the sdk-go type. +func StartClusterRequestToSDK(w *StartClusterRequest) (*sdk.StartClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.StartClusterRequest{} + out.ClusterId = w.ClusterId + return out, nil +} + +// StartClusterRequestFromSDK converts the sdk-go type to the mirror. +func StartClusterRequestFromSDK(v *sdk.StartClusterRequest) (*StartClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &StartClusterRequest{} + out.ClusterId = v.ClusterId + return out, nil +} + +// TerminationReasonToSDK converts the mirror to the sdk-go type. +func TerminationReasonToSDK(w *TerminationReason) (*sdk.TerminationReason, error) { + if w == nil { + return nil, nil + } + out := &sdk.TerminationReason{} + out.Code = w.Code + out.Type = w.Type + out.Parameters = w.Parameters + return out, nil +} + +// TerminationReasonFromSDK converts the sdk-go type to the mirror. +func TerminationReasonFromSDK(v *sdk.TerminationReason) (*TerminationReason, error) { + if v == nil { + return nil, nil + } + out := &TerminationReason{} + out.Code = v.Code + out.Type = v.Type + out.Parameters = v.Parameters + return out, nil +} + +// UnpinClusterRequestToSDK converts the mirror to the sdk-go type. +func UnpinClusterRequestToSDK(w *UnpinClusterRequest) (*sdk.UnpinClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UnpinClusterRequest{} + out.ClusterId = w.ClusterId + return out, nil +} + +// UnpinClusterRequestFromSDK converts the sdk-go type to the mirror. +func UnpinClusterRequestFromSDK(v *sdk.UnpinClusterRequest) (*UnpinClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &UnpinClusterRequest{} + out.ClusterId = v.ClusterId + return out, nil +} + +// UpdateClusterRequestToSDK converts the mirror to the sdk-go type. +func UpdateClusterRequestToSDK(w *UpdateClusterRequest) (*sdk.UpdateClusterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateClusterRequest{} + out.ClusterId = w.ClusterId + conv221, err := UpdateClusterRequest_UpdateClusterResourceToSDK(w.Cluster) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest.Cluster", err) + } + out.Cluster = conv221 + mask222, err := fieldMaskFromString[sdk.UpdateClusterRequest_UpdateClusterResource](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest.UpdateMask", err) + } + out.UpdateMask = mask222 + return out, nil +} + +// UpdateClusterRequestFromSDK converts the sdk-go type to the mirror. +func UpdateClusterRequestFromSDK(v *sdk.UpdateClusterRequest) (*UpdateClusterRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateClusterRequest{} + out.ClusterId = v.ClusterId + conv223, err := UpdateClusterRequest_UpdateClusterResourceFromSDK(v.Cluster) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest.Cluster", err) + } + out.Cluster = conv223 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateClusterRequest_UpdateClusterResourceToSDK converts the mirror to the sdk-go type. +func UpdateClusterRequest_UpdateClusterResourceToSDK(w *UpdateClusterRequest_UpdateClusterResource) (*sdk.UpdateClusterRequest_UpdateClusterResource, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateClusterRequest_UpdateClusterResource{} + { + var members []string + if w.NumWorkers != nil { + members = append(members, "num_workers") + } + if w.Autoscale != nil { + members = append(members, "autoscale") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NumWorkers != nil: + out.Size = &sdk.UpdateClusterRequest_UpdateClusterResource_Size_NumWorkers{NumWorkers: *w.NumWorkers} + case w.Autoscale != nil: + conv224, err := AutoScaleToSDK(w.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.Size", err) + } + out.Size = &sdk.UpdateClusterRequest_UpdateClusterResource_Size_Autoscale{Autoscale: *conv224} + } + out.ClusterName = w.ClusterName + out.SparkVersion = w.SparkVersion + out.SparkConf = w.SparkConf + conv225, err := AwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.AwsAttributes", err) + } + out.AwsAttributes = conv225 + conv226, err := AzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.AzureAttributes", err) + } + out.AzureAttributes = conv226 + conv227, err := GcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.GcpAttributes", err) + } + out.GcpAttributes = conv227 + out.NodeTypeId = w.NodeTypeId + out.DriverNodeTypeId = w.DriverNodeTypeId + conv228, err := NodeTypeFlexibilityToSDK(w.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv228 + conv229, err := NodeTypeFlexibilityToSDK(w.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv229 + out.SshPublicKeys = w.SshPublicKeys + out.CustomTags = w.CustomTags + conv230, err := ClusterLogConfToSDK(w.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.ClusterLogConf", err) + } + out.ClusterLogConf = conv230 + out.SparkEnvVars = w.SparkEnvVars + out.AutoterminationMinutes = w.AutoterminationMinutes + out.EnableElasticDisk = w.EnableElasticDisk + conv231, err := convertSlice(w.InitScripts, InitScriptInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.InitScripts", err) + } + out.InitScripts = conv231 + conv232, err := DockerImageToSDK(w.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.DockerImage", err) + } + out.DockerImage = conv232 + out.InstancePoolId = w.InstancePoolId + out.SingleUserName = w.SingleUserName + out.PolicyId = w.PolicyId + out.EnableLocalDiskEncryption = w.EnableLocalDiskEncryption + out.DriverInstancePoolId = w.DriverInstancePoolId + conv233, err := WorkloadTypeToSDK(w.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.WorkloadType", err) + } + out.WorkloadType = conv233 + out.DataSecurityMode = w.DataSecurityMode + out.RuntimeEngine = w.RuntimeEngine + out.Kind = w.Kind + out.UseMlRuntime = w.UseMlRuntime + out.IsSingleNode = w.IsSingleNode + out.RemoteDiskThroughput = w.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = w.TotalInitialRemoteDiskSize + out.DependencyMode = w.DependencyMode + return out, nil +} + +// UpdateClusterRequest_UpdateClusterResourceFromSDK converts the sdk-go type to the mirror. +func UpdateClusterRequest_UpdateClusterResourceFromSDK(v *sdk.UpdateClusterRequest_UpdateClusterResource) (*UpdateClusterRequest_UpdateClusterResource, error) { + if v == nil { + return nil, nil + } + out := &UpdateClusterRequest_UpdateClusterResource{} + switch value := v.Size.(type) { + case *sdk.UpdateClusterRequest_UpdateClusterResource_Size_NumWorkers: + if value != nil { + out.NumWorkers = new(value.NumWorkers) + } + case *sdk.UpdateClusterRequest_UpdateClusterResource_Size_Autoscale: + if value != nil { + conv234, err := AutoScaleFromSDK(&value.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.Size", err) + } + out.Autoscale = conv234 + } + } + out.ClusterName = v.ClusterName + out.SparkVersion = v.SparkVersion + out.SparkConf = v.SparkConf + conv235, err := AwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.AwsAttributes", err) + } + out.AwsAttributes = conv235 + conv236, err := AzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.AzureAttributes", err) + } + out.AzureAttributes = conv236 + conv237, err := GcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.GcpAttributes", err) + } + out.GcpAttributes = conv237 + out.NodeTypeId = v.NodeTypeId + out.DriverNodeTypeId = v.DriverNodeTypeId + conv238, err := NodeTypeFlexibilityFromSDK(v.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv238 + conv239, err := NodeTypeFlexibilityFromSDK(v.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv239 + out.SshPublicKeys = v.SshPublicKeys + out.CustomTags = v.CustomTags + conv240, err := ClusterLogConfFromSDK(v.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.ClusterLogConf", err) + } + out.ClusterLogConf = conv240 + out.SparkEnvVars = v.SparkEnvVars + out.AutoterminationMinutes = v.AutoterminationMinutes + out.EnableElasticDisk = v.EnableElasticDisk + conv241, err := convertSlice(v.InitScripts, InitScriptInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.InitScripts", err) + } + out.InitScripts = conv241 + conv242, err := DockerImageFromSDK(v.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.DockerImage", err) + } + out.DockerImage = conv242 + out.InstancePoolId = v.InstancePoolId + out.SingleUserName = v.SingleUserName + out.PolicyId = v.PolicyId + out.EnableLocalDiskEncryption = v.EnableLocalDiskEncryption + out.DriverInstancePoolId = v.DriverInstancePoolId + conv243, err := WorkloadTypeFromSDK(v.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateClusterRequest_UpdateClusterResource.WorkloadType", err) + } + out.WorkloadType = conv243 + out.DataSecurityMode = v.DataSecurityMode + out.RuntimeEngine = v.RuntimeEngine + out.Kind = v.Kind + out.UseMlRuntime = v.UseMlRuntime + out.IsSingleNode = v.IsSingleNode + out.RemoteDiskThroughput = v.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = v.TotalInitialRemoteDiskSize + out.DependencyMode = v.DependencyMode + return out, nil +} + +// VolumesStorageInfoToSDK converts the mirror to the sdk-go type. +func VolumesStorageInfoToSDK(w *VolumesStorageInfo) (*sdk.VolumesStorageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.VolumesStorageInfo{} + out.Destination = w.Destination + return out, nil +} + +// VolumesStorageInfoFromSDK converts the sdk-go type to the mirror. +func VolumesStorageInfoFromSDK(v *sdk.VolumesStorageInfo) (*VolumesStorageInfo, error) { + if v == nil { + return nil, nil + } + out := &VolumesStorageInfo{} + out.Destination = v.Destination + return out, nil +} + +// WorkloadTypeToSDK converts the mirror to the sdk-go type. +func WorkloadTypeToSDK(w *WorkloadType) (*sdk.WorkloadType, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkloadType{} + conv244, err := WorkloadType_ClientsTypesToSDK(w.Clients) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WorkloadType.Clients", err) + } + out.Clients = conv244 + return out, nil +} + +// WorkloadTypeFromSDK converts the sdk-go type to the mirror. +func WorkloadTypeFromSDK(v *sdk.WorkloadType) (*WorkloadType, error) { + if v == nil { + return nil, nil + } + out := &WorkloadType{} + conv245, err := WorkloadType_ClientsTypesFromSDK(v.Clients) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WorkloadType.Clients", err) + } + out.Clients = conv245 + return out, nil +} + +// WorkloadType_ClientsTypesToSDK converts the mirror to the sdk-go type. +func WorkloadType_ClientsTypesToSDK(w *WorkloadType_ClientsTypes) (*sdk.WorkloadType_ClientsTypes, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkloadType_ClientsTypes{} + out.Notebooks = w.Notebooks + out.Jobs = w.Jobs + return out, nil +} + +// WorkloadType_ClientsTypesFromSDK converts the sdk-go type to the mirror. +func WorkloadType_ClientsTypesFromSDK(v *sdk.WorkloadType_ClientsTypes) (*WorkloadType_ClientsTypes, error) { + if v == nil { + return nil, nil + } + out := &WorkloadType_ClientsTypes{} + out.Notebooks = v.Notebooks + out.Jobs = v.Jobs + return out, nil +} + +// WorkspaceStorageInfoToSDK converts the mirror to the sdk-go type. +func WorkspaceStorageInfoToSDK(w *WorkspaceStorageInfo) (*sdk.WorkspaceStorageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkspaceStorageInfo{} + out.Destination = w.Destination + return out, nil +} + +// WorkspaceStorageInfoFromSDK converts the sdk-go type to the mirror. +func WorkspaceStorageInfoFromSDK(v *sdk.WorkspaceStorageInfo) (*WorkspaceStorageInfo, error) { + if v == nil { + return nil, nil + } + out := &WorkspaceStorageInfo{} + out.Destination = v.Destination + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/commandexecution/v2/types.generated.go b/libs/sdktypes/commandexecution/v2/types.generated.go new file mode 100644 index 00000000000..78145485e82 --- /dev/null +++ b/libs/sdktypes/commandexecution/v2/types.generated.go @@ -0,0 +1,378 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/commandexecution/v2. DO NOT EDIT. + +package commandexecution + +import ( + json "encoding/json" + fmt "fmt" + sdk "github.com/databricks/sdk-go/commandexecution/v2" +) + +type ( + CommandStatus = sdk.CommandStatus + ContextStatus = sdk.ContextStatus + Language = sdk.Language + ResultType = sdk.ResultType +) + +const ( + CommandStatus_Unspecified = sdk.CommandStatus_Unspecified + CommandStatus_CommandCancelled = sdk.CommandStatus_CommandCancelled + CommandStatus_CommandCancelling = sdk.CommandStatus_CommandCancelling + CommandStatus_CommandError = sdk.CommandStatus_CommandError + CommandStatus_CommandFinished = sdk.CommandStatus_CommandFinished + CommandStatus_CommandQueued = sdk.CommandStatus_CommandQueued + CommandStatus_CommandRunning = sdk.CommandStatus_CommandRunning + ContextStatus_Unspecified = sdk.ContextStatus_Unspecified + ContextStatus_ContextRunning = sdk.ContextStatus_ContextRunning + ContextStatus_ContextPending = sdk.ContextStatus_ContextPending + ContextStatus_ContextError = sdk.ContextStatus_ContextError + Language_Unspecified = sdk.Language_Unspecified + Language_Python = sdk.Language_Python + Language_Scala = sdk.Language_Scala + Language_Sql = sdk.Language_Sql + Language_R = sdk.Language_R + ResultType_Unspecified = sdk.ResultType_Unspecified + ResultType_ErrorResult = sdk.ResultType_ErrorResult + ResultType_ImageResult = sdk.ResultType_ImageResult + ResultType_ImagesResult = sdk.ResultType_ImagesResult + ResultType_TableResult = sdk.ResultType_TableResult + ResultType_TextResult = sdk.ResultType_TextResult +) + +type CancelCommandRequest struct { + ClusterId *string `json:"clusterId,omitempty"` + CommandId *string `json:"commandId,omitempty"` + ContextId *string `json:"contextId,omitempty"` +} + +type CreateContextRequest struct { + // Running cluster id + ClusterId *string `json:"clusterId,omitempty"` + Language Language `json:"language,omitempty"` +} + +type CreateResponse struct { + Id *string `json:"id,omitempty"` +} + +type DestroyContextRequest struct { + ClusterId *string `json:"clusterId,omitempty"` + ContextId *string `json:"contextId,omitempty"` +} + +type ExecuteCommandRequest struct { + // Running cluster id + ClusterId *string `json:"clusterId,omitempty"` + // Executable code + Command *string `json:"command,omitempty"` + // Running context id + ContextId *string `json:"contextId,omitempty"` + Language Language `json:"language,omitempty"` +} + +// Request to get the status of a previously submitted command.. +type GetCommandStatusRequest struct { + ClusterId *string `json:"clusterId,omitempty"` + CommandId *string `json:"commandId,omitempty"` + ContextId *string `json:"contextId,omitempty"` +} + +type GetCommandStatusResponse struct { + Id *string `json:"id,omitempty"` + Results *Results `json:"results,omitempty"` + Status CommandStatus `json:"status,omitempty"` +} + +// Request to retrieve the status of an execution context.. +type GetContextStatusRequest struct { + ClusterId *string `json:"clusterId,omitempty"` + ContextId *string `json:"contextId,omitempty"` +} + +type GetContextStatusResponse struct { + Id *string `json:"id,omitempty"` + Status ContextStatus `json:"status,omitempty"` +} + +type Results struct { + // The cause of the error + Cause *string `json:"cause,omitempty"` + Data json.RawMessage `json:"data,omitempty"` + // The image data in one of the following formats: + // + // 1. A Data URL with base64-encoded image data: + // `data:image/{type};base64,{base64-data}`. Example: + // `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...` + // + // 2. A FileStore file path for large images: `/plots/{filename}.png`. Example: + // `/plots/b6a7ad70-fb2c-4353-8aed-3f1e015174a4.png` + FileName *string `json:"fileName,omitempty"` + // List of image data for multiple images. Each element follows the same format + // as file_name. + FileNames []string `json:"fileNames,omitempty"` + // true if a JSON schema is returned instead of a string representation of the + // Hive type. + IsJsonSchema *bool `json:"isJsonSchema,omitempty"` + // internal field used by SDK + Pos *int `json:"pos,omitempty"` + ResultType ResultType `json:"resultType,omitempty"` + // The table schema + Schema []map[string]json.RawMessage `json:"schema,omitempty"` + // The summary of the error + Summary *string `json:"summary,omitempty"` + // true if partial results are returned. + Truncated *bool `json:"truncated,omitempty"` +} + +// CancelCommandRequestToSDK converts the mirror to the sdk-go type. +func CancelCommandRequestToSDK(w *CancelCommandRequest) (*sdk.CancelCommandRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CancelCommandRequest{} + out.ClusterId = w.ClusterId + out.CommandId = w.CommandId + out.ContextId = w.ContextId + return out, nil +} + +// CancelCommandRequestFromSDK converts the sdk-go type to the mirror. +func CancelCommandRequestFromSDK(v *sdk.CancelCommandRequest) (*CancelCommandRequest, error) { + if v == nil { + return nil, nil + } + out := &CancelCommandRequest{} + out.ClusterId = v.ClusterId + out.CommandId = v.CommandId + out.ContextId = v.ContextId + return out, nil +} + +// CreateContextRequestToSDK converts the mirror to the sdk-go type. +func CreateContextRequestToSDK(w *CreateContextRequest) (*sdk.CreateContextRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateContextRequest{} + out.ClusterId = w.ClusterId + out.Language = w.Language + return out, nil +} + +// CreateContextRequestFromSDK converts the sdk-go type to the mirror. +func CreateContextRequestFromSDK(v *sdk.CreateContextRequest) (*CreateContextRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateContextRequest{} + out.ClusterId = v.ClusterId + out.Language = v.Language + return out, nil +} + +// CreateResponseToSDK converts the mirror to the sdk-go type. +func CreateResponseToSDK(w *CreateResponse) (*sdk.CreateResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateResponse{} + out.Id = w.Id + return out, nil +} + +// CreateResponseFromSDK converts the sdk-go type to the mirror. +func CreateResponseFromSDK(v *sdk.CreateResponse) (*CreateResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateResponse{} + out.Id = v.Id + return out, nil +} + +// DestroyContextRequestToSDK converts the mirror to the sdk-go type. +func DestroyContextRequestToSDK(w *DestroyContextRequest) (*sdk.DestroyContextRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DestroyContextRequest{} + out.ClusterId = w.ClusterId + out.ContextId = w.ContextId + return out, nil +} + +// DestroyContextRequestFromSDK converts the sdk-go type to the mirror. +func DestroyContextRequestFromSDK(v *sdk.DestroyContextRequest) (*DestroyContextRequest, error) { + if v == nil { + return nil, nil + } + out := &DestroyContextRequest{} + out.ClusterId = v.ClusterId + out.ContextId = v.ContextId + return out, nil +} + +// ExecuteCommandRequestToSDK converts the mirror to the sdk-go type. +func ExecuteCommandRequestToSDK(w *ExecuteCommandRequest) (*sdk.ExecuteCommandRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExecuteCommandRequest{} + out.ClusterId = w.ClusterId + out.ContextId = w.ContextId + out.Language = w.Language + out.Command = w.Command + return out, nil +} + +// ExecuteCommandRequestFromSDK converts the sdk-go type to the mirror. +func ExecuteCommandRequestFromSDK(v *sdk.ExecuteCommandRequest) (*ExecuteCommandRequest, error) { + if v == nil { + return nil, nil + } + out := &ExecuteCommandRequest{} + out.ClusterId = v.ClusterId + out.ContextId = v.ContextId + out.Language = v.Language + out.Command = v.Command + return out, nil +} + +// GetCommandStatusRequestToSDK converts the mirror to the sdk-go type. +func GetCommandStatusRequestToSDK(w *GetCommandStatusRequest) (*sdk.GetCommandStatusRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetCommandStatusRequest{} + out.ClusterId = w.ClusterId + out.ContextId = w.ContextId + out.CommandId = w.CommandId + return out, nil +} + +// GetCommandStatusRequestFromSDK converts the sdk-go type to the mirror. +func GetCommandStatusRequestFromSDK(v *sdk.GetCommandStatusRequest) (*GetCommandStatusRequest, error) { + if v == nil { + return nil, nil + } + out := &GetCommandStatusRequest{} + out.ClusterId = v.ClusterId + out.ContextId = v.ContextId + out.CommandId = v.CommandId + return out, nil +} + +// GetCommandStatusResponseToSDK converts the mirror to the sdk-go type. +func GetCommandStatusResponseToSDK(w *GetCommandStatusResponse) (*sdk.GetCommandStatusResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetCommandStatusResponse{} + out.Id = w.Id + out.Status = w.Status + conv1, err := ResultsToSDK(w.Results) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetCommandStatusResponse.Results", err) + } + out.Results = conv1 + return out, nil +} + +// GetCommandStatusResponseFromSDK converts the sdk-go type to the mirror. +func GetCommandStatusResponseFromSDK(v *sdk.GetCommandStatusResponse) (*GetCommandStatusResponse, error) { + if v == nil { + return nil, nil + } + out := &GetCommandStatusResponse{} + out.Id = v.Id + out.Status = v.Status + conv2, err := ResultsFromSDK(v.Results) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetCommandStatusResponse.Results", err) + } + out.Results = conv2 + return out, nil +} + +// GetContextStatusRequestToSDK converts the mirror to the sdk-go type. +func GetContextStatusRequestToSDK(w *GetContextStatusRequest) (*sdk.GetContextStatusRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetContextStatusRequest{} + out.ClusterId = w.ClusterId + out.ContextId = w.ContextId + return out, nil +} + +// GetContextStatusRequestFromSDK converts the sdk-go type to the mirror. +func GetContextStatusRequestFromSDK(v *sdk.GetContextStatusRequest) (*GetContextStatusRequest, error) { + if v == nil { + return nil, nil + } + out := &GetContextStatusRequest{} + out.ClusterId = v.ClusterId + out.ContextId = v.ContextId + return out, nil +} + +// GetContextStatusResponseToSDK converts the mirror to the sdk-go type. +func GetContextStatusResponseToSDK(w *GetContextStatusResponse) (*sdk.GetContextStatusResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetContextStatusResponse{} + out.Id = w.Id + out.Status = w.Status + return out, nil +} + +// GetContextStatusResponseFromSDK converts the sdk-go type to the mirror. +func GetContextStatusResponseFromSDK(v *sdk.GetContextStatusResponse) (*GetContextStatusResponse, error) { + if v == nil { + return nil, nil + } + out := &GetContextStatusResponse{} + out.Id = v.Id + out.Status = v.Status + return out, nil +} + +// ResultsToSDK converts the mirror to the sdk-go type. +func ResultsToSDK(w *Results) (*sdk.Results, error) { + if w == nil { + return nil, nil + } + out := &sdk.Results{} + out.Cause = w.Cause + out.Data = w.Data + out.FileName = w.FileName + out.FileNames = w.FileNames + out.IsJsonSchema = w.IsJsonSchema + out.Pos = w.Pos + out.ResultType = w.ResultType + out.Schema = w.Schema + out.Summary = w.Summary + out.Truncated = w.Truncated + return out, nil +} + +// ResultsFromSDK converts the sdk-go type to the mirror. +func ResultsFromSDK(v *sdk.Results) (*Results, error) { + if v == nil { + return nil, nil + } + out := &Results{} + out.Cause = v.Cause + out.Data = v.Data + out.FileName = v.FileName + out.FileNames = v.FileNames + out.IsJsonSchema = v.IsJsonSchema + out.Pos = v.Pos + out.ResultType = v.ResultType + out.Schema = v.Schema + out.Summary = v.Summary + out.Truncated = v.Truncated + return out, nil +} diff --git a/libs/sdktypes/customllms/v1/types.generated.go b/libs/sdktypes/customllms/v1/types.generated.go new file mode 100644 index 00000000000..c3fcd5ad2b1 --- /dev/null +++ b/libs/sdktypes/customllms/v1/types.generated.go @@ -0,0 +1,338 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/customllms/v1. DO NOT EDIT. + +package customllms + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/customllms/v1" + strings "strings" +) + +type ( + State = sdk.State +) + +const ( + State_Unspecified = sdk.State_Unspecified + State_Created = sdk.State_Created + State_Running = sdk.State_Running + State_Completed = sdk.State_Completed + State_Failed = sdk.State_Failed + State_Pending = sdk.State_Pending + State_Cancelled = sdk.State_Cancelled +) + +type CancelCustomLlmOptimizationRunRequest struct { + Id *string `json:"id,omitempty"` +} + +type CreateCustomLlmRequest struct { + // This will soon be deprecated!! Optional: UC path for agent artifacts. If you + // are using a dataset that you only have read permissions, please provide a + // destination path where you have write permissions. Please provide this in + // catalog.schema format. + AgentArtifactPath *string `json:"agent_artifact_path,omitempty"` + // Datasets used for training and evaluating the model, not for inference. + // Currently, only 1 dataset is accepted. + Datasets []Dataset `json:"datasets,omitempty"` + // Guidelines for the custom LLM to adhere to + Guidelines []string `json:"guidelines,omitempty"` + // Instructions for the custom LLM to follow + Instructions *string `json:"instructions,omitempty"` + // Name of the custom LLM. Only alphanumeric characters and dashes allowed. + Name *string `json:"name,omitempty"` +} + +type CustomLlm struct { + AgentArtifactPath *string `json:"agent_artifact_path,omitempty"` + // Creation timestamp of the custom LLM + CreationTime *types.Time `json:"creation_time,omitempty"` + // Creator of the custom LLM + Creator *string `json:"creator,omitempty"` + // Datasets used for training and evaluating the model, not for inference + Datasets []Dataset `json:"datasets,omitempty"` + // Name of the endpoint that will be used to serve the custom LLM + EndpointName *string `json:"endpoint_name,omitempty"` + // Guidelines for the custom LLM to adhere to + Guidelines []string `json:"guidelines,omitempty"` + Id *string `json:"id,omitempty"` + // Instructions for the custom LLM to follow + Instructions *string `json:"instructions,omitempty"` + // Name of the custom LLM + Name *string `json:"name,omitempty"` + // If optimization is kicked off, tracks the state of the custom LLM + OptimizationState State `json:"optimization_state,omitempty"` +} + +type Dataset struct { + Table *Table `json:"table,omitempty"` +} + +type StartCustomLlmOptimizationRunRequest struct { + // The Id of the tile. + Id *string `json:"id,omitempty"` +} + +type Table struct { + // Name of the request column + RequestCol *string `json:"request_col,omitempty"` + // Optional: Name of the response column if the data is labeled + ResponseCol *string `json:"response_col,omitempty"` + // Full UC table path in catalog.schema.table_name format + TablePath *string `json:"table_path,omitempty"` +} + +type UpdateCustomLlmRequest struct { + // The CustomLlm containing the fields which should be updated. + CustomLlm *CustomLlm `json:"custom_llm,omitempty"` + // The id of the custom llm + Id *string `json:"id,omitempty"` + // The list of the CustomLlm fields to update. These should correspond to the + // values (or lack thereof) present in `custom_llm`. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CancelCustomLlmOptimizationRunRequestToSDK converts the mirror to the sdk-go type. +func CancelCustomLlmOptimizationRunRequestToSDK(w *CancelCustomLlmOptimizationRunRequest) (*sdk.CancelCustomLlmOptimizationRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CancelCustomLlmOptimizationRunRequest{} + out.Id = w.Id + return out, nil +} + +// CancelCustomLlmOptimizationRunRequestFromSDK converts the sdk-go type to the mirror. +func CancelCustomLlmOptimizationRunRequestFromSDK(v *sdk.CancelCustomLlmOptimizationRunRequest) (*CancelCustomLlmOptimizationRunRequest, error) { + if v == nil { + return nil, nil + } + out := &CancelCustomLlmOptimizationRunRequest{} + out.Id = v.Id + return out, nil +} + +// CreateCustomLlmRequestToSDK converts the mirror to the sdk-go type. +func CreateCustomLlmRequestToSDK(w *CreateCustomLlmRequest) (*sdk.CreateCustomLlmRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCustomLlmRequest{} + out.Name = w.Name + out.Instructions = w.Instructions + conv1, err := convertSlice(w.Datasets, DatasetToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCustomLlmRequest.Datasets", err) + } + out.Datasets = conv1 + out.Guidelines = w.Guidelines + out.AgentArtifactPath = w.AgentArtifactPath + return out, nil +} + +// CreateCustomLlmRequestFromSDK converts the sdk-go type to the mirror. +func CreateCustomLlmRequestFromSDK(v *sdk.CreateCustomLlmRequest) (*CreateCustomLlmRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCustomLlmRequest{} + out.Name = v.Name + out.Instructions = v.Instructions + conv2, err := convertSlice(v.Datasets, DatasetFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCustomLlmRequest.Datasets", err) + } + out.Datasets = conv2 + out.Guidelines = v.Guidelines + out.AgentArtifactPath = v.AgentArtifactPath + return out, nil +} + +// CustomLlmToSDK converts the mirror to the sdk-go type. +func CustomLlmToSDK(w *CustomLlm) (*sdk.CustomLlm, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomLlm{} + out.Id = w.Id + out.Name = w.Name + out.EndpointName = w.EndpointName + out.Instructions = w.Instructions + conv3, err := convertSlice(w.Datasets, DatasetToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomLlm.Datasets", err) + } + out.Datasets = conv3 + out.Guidelines = w.Guidelines + out.OptimizationState = w.OptimizationState + out.Creator = w.Creator + out.CreationTime = w.CreationTime + out.AgentArtifactPath = w.AgentArtifactPath + return out, nil +} + +// CustomLlmFromSDK converts the sdk-go type to the mirror. +func CustomLlmFromSDK(v *sdk.CustomLlm) (*CustomLlm, error) { + if v == nil { + return nil, nil + } + out := &CustomLlm{} + out.Id = v.Id + out.Name = v.Name + out.EndpointName = v.EndpointName + out.Instructions = v.Instructions + conv4, err := convertSlice(v.Datasets, DatasetFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomLlm.Datasets", err) + } + out.Datasets = conv4 + out.Guidelines = v.Guidelines + out.OptimizationState = v.OptimizationState + out.Creator = v.Creator + out.CreationTime = v.CreationTime + out.AgentArtifactPath = v.AgentArtifactPath + return out, nil +} + +// DatasetToSDK converts the mirror to the sdk-go type. +func DatasetToSDK(w *Dataset) (*sdk.Dataset, error) { + if w == nil { + return nil, nil + } + out := &sdk.Dataset{} + conv5, err := TableToSDK(w.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dataset.Table", err) + } + out.Table = conv5 + return out, nil +} + +// DatasetFromSDK converts the sdk-go type to the mirror. +func DatasetFromSDK(v *sdk.Dataset) (*Dataset, error) { + if v == nil { + return nil, nil + } + out := &Dataset{} + conv6, err := TableFromSDK(v.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dataset.Table", err) + } + out.Table = conv6 + return out, nil +} + +// StartCustomLlmOptimizationRunRequestToSDK converts the mirror to the sdk-go type. +func StartCustomLlmOptimizationRunRequestToSDK(w *StartCustomLlmOptimizationRunRequest) (*sdk.StartCustomLlmOptimizationRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.StartCustomLlmOptimizationRunRequest{} + out.Id = w.Id + return out, nil +} + +// StartCustomLlmOptimizationRunRequestFromSDK converts the sdk-go type to the mirror. +func StartCustomLlmOptimizationRunRequestFromSDK(v *sdk.StartCustomLlmOptimizationRunRequest) (*StartCustomLlmOptimizationRunRequest, error) { + if v == nil { + return nil, nil + } + out := &StartCustomLlmOptimizationRunRequest{} + out.Id = v.Id + return out, nil +} + +// TableToSDK converts the mirror to the sdk-go type. +func TableToSDK(w *Table) (*sdk.Table, error) { + if w == nil { + return nil, nil + } + out := &sdk.Table{} + out.TablePath = w.TablePath + out.RequestCol = w.RequestCol + out.ResponseCol = w.ResponseCol + return out, nil +} + +// TableFromSDK converts the sdk-go type to the mirror. +func TableFromSDK(v *sdk.Table) (*Table, error) { + if v == nil { + return nil, nil + } + out := &Table{} + out.TablePath = v.TablePath + out.RequestCol = v.RequestCol + out.ResponseCol = v.ResponseCol + return out, nil +} + +// UpdateCustomLlmRequestToSDK converts the mirror to the sdk-go type. +func UpdateCustomLlmRequestToSDK(w *UpdateCustomLlmRequest) (*sdk.UpdateCustomLlmRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCustomLlmRequest{} + out.Id = w.Id + conv7, err := CustomLlmToSDK(w.CustomLlm) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCustomLlmRequest.CustomLlm", err) + } + out.CustomLlm = conv7 + mask8, err := fieldMaskFromString[sdk.CustomLlm](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCustomLlmRequest.UpdateMask", err) + } + out.UpdateMask = mask8 + return out, nil +} + +// UpdateCustomLlmRequestFromSDK converts the sdk-go type to the mirror. +func UpdateCustomLlmRequestFromSDK(v *sdk.UpdateCustomLlmRequest) (*UpdateCustomLlmRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateCustomLlmRequest{} + out.Id = v.Id + conv9, err := CustomLlmFromSDK(v.CustomLlm) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCustomLlmRequest.CustomLlm", err) + } + out.CustomLlm = conv9 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/database/v1/types.generated.go b/libs/sdktypes/database/v1/types.generated.go new file mode 100644 index 00000000000..7a447e53adf --- /dev/null +++ b/libs/sdktypes/database/v1/types.generated.go @@ -0,0 +1,2139 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/database/v1. DO NOT EDIT. + +package database + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/database/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + ProvisioningPhase = sdk.ProvisioningPhase + SyncedTableSchedulingPolicy = sdk.SyncedTableSchedulingPolicy + SyncedTableState = sdk.SyncedTableState + DatabaseInstance_State = sdk.DatabaseInstance_State + DatabaseInstanceRole_IdentityType = sdk.DatabaseInstanceRole_IdentityType + DatabaseInstanceRole_MembershipRole = sdk.DatabaseInstanceRole_MembershipRole + ProvisioningInfo_State = sdk.ProvisioningInfo_State + RequestedClaims_PermissionSet = sdk.RequestedClaims_PermissionSet + SyncedTableSpec_PgSpecificType = sdk.SyncedTableSpec_PgSpecificType +) + +const ( + ProvisioningPhase_Unspecified = sdk.ProvisioningPhase_Unspecified + ProvisioningPhase_ProvisioningPhaseMain = sdk.ProvisioningPhase_ProvisioningPhaseMain + ProvisioningPhase_ProvisioningPhaseIndexScan = sdk.ProvisioningPhase_ProvisioningPhaseIndexScan + ProvisioningPhase_ProvisioningPhaseIndexSort = sdk.ProvisioningPhase_ProvisioningPhaseIndexSort + SyncedTableSchedulingPolicy_Unspecified = sdk.SyncedTableSchedulingPolicy_Unspecified + SyncedTableSchedulingPolicy_Continuous = sdk.SyncedTableSchedulingPolicy_Continuous + SyncedTableSchedulingPolicy_Triggered = sdk.SyncedTableSchedulingPolicy_Triggered + SyncedTableSchedulingPolicy_Snapshot = sdk.SyncedTableSchedulingPolicy_Snapshot + SyncedTableState_Unspecified = sdk.SyncedTableState_Unspecified + SyncedTableState_SyncedTableProvisioning = sdk.SyncedTableState_SyncedTableProvisioning + SyncedTableState_SyncedTableProvisioningPipelineResources = sdk.SyncedTableState_SyncedTableProvisioningPipelineResources + SyncedTableState_SyncedTableProvisioningInitialSnapshot = sdk.SyncedTableState_SyncedTableProvisioningInitialSnapshot + SyncedTableState_SyncedTableOnline = sdk.SyncedTableState_SyncedTableOnline + SyncedTableState_SyncedTableOnlineContinuousUpdate = sdk.SyncedTableState_SyncedTableOnlineContinuousUpdate + SyncedTableState_SyncedTableOnlineTriggeredUpdate = sdk.SyncedTableState_SyncedTableOnlineTriggeredUpdate + SyncedTableState_SyncedTableOnlineNoPendingUpdate = sdk.SyncedTableState_SyncedTableOnlineNoPendingUpdate + SyncedTableState_SyncedTabledOffline = sdk.SyncedTableState_SyncedTabledOffline + SyncedTableState_SyncedTableOfflineFailed = sdk.SyncedTableState_SyncedTableOfflineFailed + SyncedTableState_SyncedTableOnlinePipelineFailed = sdk.SyncedTableState_SyncedTableOnlinePipelineFailed + SyncedTableState_SyncedTableOnlineUpdatingPipelineResources = sdk.SyncedTableState_SyncedTableOnlineUpdatingPipelineResources + DatabaseInstance_State_Unspecified = sdk.DatabaseInstance_State_Unspecified + DatabaseInstance_State_Starting = sdk.DatabaseInstance_State_Starting + DatabaseInstance_State_Available = sdk.DatabaseInstance_State_Available + DatabaseInstance_State_Deleting = sdk.DatabaseInstance_State_Deleting + DatabaseInstance_State_Stopped = sdk.DatabaseInstance_State_Stopped + DatabaseInstance_State_Updating = sdk.DatabaseInstance_State_Updating + DatabaseInstance_State_FailingOver = sdk.DatabaseInstance_State_FailingOver + DatabaseInstanceRole_IdentityType_Unspecified = sdk.DatabaseInstanceRole_IdentityType_Unspecified + DatabaseInstanceRole_IdentityType_PgOnly = sdk.DatabaseInstanceRole_IdentityType_PgOnly + DatabaseInstanceRole_IdentityType_User = sdk.DatabaseInstanceRole_IdentityType_User + DatabaseInstanceRole_IdentityType_ServicePrincipal = sdk.DatabaseInstanceRole_IdentityType_ServicePrincipal + DatabaseInstanceRole_IdentityType_Group = sdk.DatabaseInstanceRole_IdentityType_Group + DatabaseInstanceRole_MembershipRole_Unspecified = sdk.DatabaseInstanceRole_MembershipRole_Unspecified + DatabaseInstanceRole_MembershipRole_DatabricksSuperuser = sdk.DatabaseInstanceRole_MembershipRole_DatabricksSuperuser + ProvisioningInfo_State_Unspecified = sdk.ProvisioningInfo_State_Unspecified + ProvisioningInfo_State_Provisioning = sdk.ProvisioningInfo_State_Provisioning + ProvisioningInfo_State_Active = sdk.ProvisioningInfo_State_Active + ProvisioningInfo_State_Failed = sdk.ProvisioningInfo_State_Failed + ProvisioningInfo_State_Deleting = sdk.ProvisioningInfo_State_Deleting + ProvisioningInfo_State_Updating = sdk.ProvisioningInfo_State_Updating + ProvisioningInfo_State_Degraded = sdk.ProvisioningInfo_State_Degraded + RequestedClaims_PermissionSet_Unspecified = sdk.RequestedClaims_PermissionSet_Unspecified + RequestedClaims_PermissionSet_ReadOnly = sdk.RequestedClaims_PermissionSet_ReadOnly + SyncedTableSpec_PgSpecificType_Unspecified = sdk.SyncedTableSpec_PgSpecificType_Unspecified + SyncedTableSpec_PgSpecificType_PgSpecificTypeVector = sdk.SyncedTableSpec_PgSpecificType_PgSpecificTypeVector + SyncedTableSpec_PgSpecificType_PgSpecificTypeHalfvec = sdk.SyncedTableSpec_PgSpecificType_PgSpecificTypeHalfvec + SyncedTableSpec_PgSpecificType_PgSpecificTypeVarchar = sdk.SyncedTableSpec_PgSpecificType_PgSpecificTypeVarchar +) + +type CreateDatabaseCatalogRequest struct { + Catalog *DatabaseCatalog `json:"catalog,omitempty"` +} + +type CreateDatabaseInstanceRequest struct { + // Instance to create. + DatabaseInstance *DatabaseInstance `json:"database_instance,omitempty"` +} + +type CreateDatabaseInstanceRoleRequest struct { + DatabaseInstanceName *string `json:"database_instance_name,omitempty"` + DatabaseInstanceRole *DatabaseInstanceRole `json:"database_instance_role,omitempty"` + InstanceName *string `json:"instance_name,omitempty"` +} + +type CreateDatabaseTableRequest struct { + Table *DatabaseTable `json:"table,omitempty"` +} + +type CreateSyncedDatabaseTableRequest struct { + SyncedTable *SyncedDatabaseTable `json:"synced_table,omitempty"` +} + +type CustomTag struct { + // The key of the custom tag. + Key *string `json:"key,omitempty"` + // The value of the custom tag. + Value *string `json:"value,omitempty"` +} + +type DatabaseCatalog struct { + CreateDatabaseIfNotExists *bool `json:"create_database_if_not_exists,omitempty"` + // The name of the DatabaseInstance housing the database. + DatabaseInstanceName *string `json:"database_instance_name,omitempty"` + // The name of the database (in an instance) associated with the catalog. + DatabaseName *string `json:"database_name,omitempty"` + // The name of the catalog in UC. + Name *string `json:"name,omitempty"` + Uid *string `json:"uid,omitempty"` +} + +type DatabaseCredential struct { + ExpirationTime *types.Time `json:"expiration_time,omitempty"` + Token *string `json:"token,omitempty"` +} + +// A DatabaseInstance represents a logical Postgres instance, comprised of both +// compute and storage.. +type DatabaseInstance struct { + // The sku of the instance. Valid values are "CU_1", "CU_2", "CU_4", "CU_8". + Capacity *string `json:"capacity,omitempty"` + // The refs of the child instances. This is only available if the instance is + // parent instance. + ChildInstanceRefs []DatabaseInstanceRef `json:"child_instance_refs,omitempty"` + // The timestamp when the instance was created. + CreationTime *types.Time `json:"creation_time,omitempty"` + // The email of the creator of the instance. + Creator *string `json:"creator,omitempty"` + // Custom tags associated with the instance. This field is only included on + // create and update responses. + CustomTags []CustomTag `json:"custom_tags,omitempty"` + // Deprecated. The sku of the instance; this field will always match the value + // of capacity. This is an output only field that contains the value computed + // from the input field combined with server side defaults. Use the field + // without the effective_ prefix to set the value. + EffectiveCapacity *string `json:"effective_capacity,omitempty"` + // The recorded custom tags associated with the instance. This is an output only + // field that contains the value computed from the input field combined with + // server side defaults. Use the field without the effective_ prefix to set the + // value. + EffectiveCustomTags []CustomTag `json:"effective_custom_tags,omitempty"` + // Whether the instance has PG native password login enabled. This is an output + // only field that contains the value computed from the input field combined + // with server side defaults. Use the field without the effective_ prefix to set + // the value. + EffectiveEnablePgNativeLogin *bool `json:"effective_enable_pg_native_login,omitempty"` + // Whether secondaries serving read-only traffic are enabled. Defaults to false. + // This is an output only field that contains the value computed from the input + // field combined with server side defaults. Use the field without the + // effective_ prefix to set the value. + EffectiveEnableReadableSecondaries *bool `json:"effective_enable_readable_secondaries,omitempty"` + // The number of nodes in the instance, composed of 1 primary and 0 or more + // secondaries. Defaults to 1 primary and 0 secondaries. This is an output only + // field that contains the value computed from the input field combined with + // server side defaults. Use the field without the effective_ prefix to set the + // value. + EffectiveNodeCount *int `json:"effective_node_count,omitempty"` + // The retention window for the instance. This is the time window in days for + // which the historical data is retained. This is an output only field that + // contains the value computed from the input field combined with server side + // defaults. Use the field without the effective_ prefix to set the value. + EffectiveRetentionWindowInDays *int `json:"effective_retention_window_in_days,omitempty"` + // Whether the instance is stopped. This is an output only field that contains + // the value computed from the input field combined with server side defaults. + // Use the field without the effective_ prefix to set the value. + EffectiveStopped *bool `json:"effective_stopped,omitempty"` + // The policy that is applied to the instance. This is an output only field that + // contains the value computed from the input field combined with server side + // defaults. Use the field without the effective_ prefix to set the value. + EffectiveUsagePolicyId *string `json:"effective_usage_policy_id,omitempty"` + // Whether to enable PG native password login on the instance. Defaults to + // false. + EnablePgNativeLogin *bool `json:"enable_pg_native_login,omitempty"` + // Whether to enable secondaries to serve read-only traffic. Defaults to false. + EnableReadableSecondaries *bool `json:"enable_readable_secondaries,omitempty"` + // The name of the instance. This is the unique identifier for the instance. + Name *string `json:"name,omitempty"` + // The number of nodes in the instance, composed of 1 primary and 0 or more + // secondaries. Defaults to 1 primary and 0 secondaries. This field is input + // only, see effective_node_count for the output. + NodeCount *int `json:"node_count,omitempty"` + // The ref of the parent instance. This is only available if the instance is + // child instance. Input: For specifying the parent instance to create a child + // instance. Optional. Output: Only populated if provided as input to create a + // child instance. + ParentInstanceRef *DatabaseInstanceRef `json:"parent_instance_ref,omitempty"` + // The version of Postgres running on the instance. + PgVersion *string `json:"pg_version,omitempty"` + // The DNS endpoint to connect to the instance for read only access. This is + // only available if enable_readable_secondaries is true. + ReadOnlyDns *string `json:"read_only_dns,omitempty"` + // The DNS endpoint to connect to the instance for read+write access. + ReadWriteDns *string `json:"read_write_dns,omitempty"` + // The retention window for the instance. This is the time window in days for + // which the historical data is retained. The default value is 7 days. Valid + // values are 2 to 35 days. + RetentionWindowInDays *int `json:"retention_window_in_days,omitempty"` + // The current state of the instance. + State DatabaseInstance_State `json:"state,omitempty"` + // Whether to stop the instance. An input only param, see effective_stopped for + // the output. + Stopped *bool `json:"stopped,omitempty"` + // An immutable UUID identifier for the instance. + Uid *string `json:"uid,omitempty"` + // The desired usage policy to associate with the instance. + UsagePolicyId *string `json:"usage_policy_id,omitempty"` +} + +// DatabaseInstanceRef is a reference to a database instance. It is used in the +// DatabaseInstance object to refer to the parent instance of an instance and to +// refer the child instances of an instance. To specify as a parent instance +// during creation of an instance, the lsn and branch_time fields are optional. +// If not specified, the child instance will be created from the latest lsn of +// the parent. If both lsn and branch_time are specified, the lsn will be used +// to create the child instance.. +type DatabaseInstanceRef struct { + // Branch time of the ref database instance. For a parent ref instance, this is + // the point in time on the parent instance from which the instance was created. + // For a child ref instance, this is the point in time on the instance from + // which the child instance was created. Input: For specifying the point in time + // to create a child instance. Optional. Output: Only populated if provided as + // input to create a child instance. + BranchTime *types.Time `json:"branch_time,omitempty"` + // For a parent ref instance, this is the LSN on the parent instance from which + // the instance was created. For a child ref instance, this is the LSN on the + // instance from which the child instance was created. This is an output only + // field that contains the value computed from the input field combined with + // server side defaults. Use the field without the effective_ prefix to set the + // value. + EffectiveLsn *string `json:"effective_lsn,omitempty"` + // User-specified WAL LSN of the ref database instance. + // + // Input: For specifying the WAL LSN to create a child instance. Optional. + // Output: Only populated if provided as input to create a child instance. + Lsn *string `json:"lsn,omitempty"` + // Name of the ref database instance. + Name *string `json:"name,omitempty"` + // Id of the ref database instance. + Uid *string `json:"uid,omitempty"` +} + +// A DatabaseInstanceRole represents a Postgres role in a database instance.. +type DatabaseInstanceRole struct { + // The desired API-exposed Postgres role attribute to associate with the role. + // Optional. + Attributes *DatabaseInstanceRole_Attributes `json:"attributes,omitempty"` + // The attributes that are applied to the role. This is an output only field + // that contains the value computed from the input field combined with server + // side defaults. Use the field without the effective_ prefix to set the value. + EffectiveAttributes *DatabaseInstanceRole_Attributes `json:"effective_attributes,omitempty"` + // The type of the role. + IdentityType DatabaseInstanceRole_IdentityType `json:"identity_type,omitempty"` + InstanceName *string `json:"instance_name,omitempty"` + // An enum value for a standard role that this role is a member of. + MembershipRole DatabaseInstanceRole_MembershipRole `json:"membership_role,omitempty"` + // The name of the role. This is the unique identifier for the role in an + // instance. + Name *string `json:"name,omitempty"` +} + +// Attributes that can be granted to a Postgres role. We are only implementing a +// subset for now, see xref: +// https://www.postgresql.org/docs/16/sql-createrole.html The values follow +// Postgres keyword naming e.g. CREATEDB, BYPASSRLS, etc. which is why they +// don't include typical underscores between words. We were requested to make +// this a nested object/struct representation since these are knobs from an +// external spec.. +type DatabaseInstanceRole_Attributes struct { + Bypassrls *bool `json:"bypassrls,omitempty"` + Createdb *bool `json:"createdb,omitempty"` + Createrole *bool `json:"createrole,omitempty"` +} + +type DatabaseTable struct { + // Name of the target database instance. This is required when creating database + // tables in standard catalogs. This is optional when creating database tables + // in registered catalogs. If this field is specified when creating database + // tables in registered catalogs, the database instance name MUST match that of + // the registered catalog (or the request will be rejected). + DatabaseInstanceName *string `json:"database_instance_name,omitempty"` + // Target Postgres database object (logical database) name for this table. + // + // When creating a table in a standard catalog, this field is required. In this + // scenario, specifying this field will allow targeting an arbitrary postgres + // database. + // + // Registration of database tables via /database/tables is currently only + // supported in standard catalogs. + LogicalDatabaseName *string `json:"logical_database_name,omitempty"` + // Full three-part (catalog, schema, table) name of the table. + Name *string `json:"name,omitempty"` +} + +type DeleteDatabaseInstanceRequest struct { + // By default, an instance cannot be deleted if it has descendant instances + // created via PITR. If this flag is specified as true, all descendent instances + // will be deleted as well. + Force *bool `json:"force,omitempty"` + // Name of the instance to delete. + Name *string `json:"name,omitempty"` + // Deprecated. Omitting the field or setting it to true will result in the field + // being hard deleted. Setting a value of false will throw a bad request. + Purge *bool `json:"purge,omitempty"` +} + +type DeleteDatabaseInstanceRoleRequest struct { + // This is the AIP standard name for the equivalent of Postgres' `IF EXISTS` + // option + AllowMissing *bool `json:"allow_missing,omitempty"` + InstanceName *string `json:"instance_name,omitempty"` + Name *string `json:"name,omitempty"` + ReassignOwnedTo *string `json:"reassign_owned_to,omitempty"` +} + +type DeleteSyncedDatabaseTableRequest struct { + Name *string `json:"name,omitempty"` + // Optional. When set to true, the actual PostgreSQL table will be dropped from + // the database. + PurgeData *bool `json:"purge_data,omitempty"` +} + +type DeltaTableSyncInfo struct { + // The timestamp when the above Delta version was committed in the source Delta + // table. Note: This is the Delta commit time, not the time the data was written + // to the synced table. + DeltaCommitTimestamp *types.Time `json:"delta_commit_timestamp,omitempty"` + // The Delta Lake commit version that was last successfully synced. + DeltaCommitVersion *int64 `json:"delta_commit_version,omitempty"` +} + +type FindDatabaseInstanceByUidRequest struct { + // UID of the cluster to get. + Uid *string `json:"uid,omitempty"` +} + +// Generates a credential that can be used to access database instances. +type GenerateDatabaseCredentialRequest struct { + // A set of UC permissions to add to the credential. We verify that the caller + // has the necessary permissions in UC and include a reference in the token. + // Postgres uses that token to give the connecting user additional grants to the + // Postgres resources that correspond to the UC resources. The UC resources need + // to be something that have a Postgres counterpart. For example, a synced table + // or a table in a UC database catalog. + Claims []RequestedClaims `json:"claims,omitempty"` + // Instances to request a credential for. At least one of instance_names or + // claims must be specified. + InstanceNames []string `json:"instance_names,omitempty"` + RequestId *string `json:"request_id,omitempty"` +} + +type ListDatabaseCatalogsRequest struct { + // Name of the instance to get database catalogs for. + InstanceName *string `json:"instance_name,omitempty"` + // Upper bound for items returned. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page of synced database tables. Requests + // first page if absent. + PageToken *string `json:"page_token,omitempty"` +} + +type ListDatabaseCatalogsResponse struct { + DatabaseCatalogs []DatabaseCatalog `json:"database_catalogs,omitempty"` + // Pagination token to request the next page of database catalogs. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListDatabaseInstanceRolesRequest struct { + InstanceName *string `json:"instance_name,omitempty"` + // Upper bound for items returned. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page of Database Instances. Requests first + // page if absent. + PageToken *string `json:"page_token,omitempty"` +} + +type ListDatabaseInstanceRolesResponse struct { + // List of database instance roles. + DatabaseInstanceRoles []DatabaseInstanceRole `json:"database_instance_roles,omitempty"` + // Pagination token to request the next page of instances. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListDatabaseInstancesRequest struct { + // Upper bound for items returned. The maximum value is 100. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page of Database Instances. Requests first + // page if absent. + PageToken *string `json:"page_token,omitempty"` +} + +type ListDatabaseInstancesResponse struct { + // List of instances. + DatabaseInstances []DatabaseInstance `json:"database_instances,omitempty"` + // Pagination token to request the next page of instances. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListSyncedDatabaseTablesRequest struct { + // Name of the instance to get synced tables for. + InstanceName *string `json:"instance_name,omitempty"` + // Upper bound for items returned. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page of synced database tables. Requests + // first page if absent. + PageToken *string `json:"page_token,omitempty"` +} + +type ListSyncedDatabaseTablesResponse struct { + // Pagination token to request the next page of synced tables. + NextPageToken *string `json:"next_page_token,omitempty"` + SyncedTables []SyncedDatabaseTable `json:"synced_tables,omitempty"` +} + +// Custom fields that user can set for pipeline while creating +// SyncedDatabaseTable. Note that other fields of pipeline are still inferred by +// table def internally. +type NewPipelineSpec struct { + // Budget policy to set on the newly created pipeline. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // This field needs to be specified if the destination catalog is a managed + // postgres catalog. + // + // UC catalog for the pipeline to store intermediate files (checkpoints, event + // logs etc). This needs to be a standard catalog where the user has permissions + // to create Delta tables. + StorageCatalog *string `json:"storage_catalog,omitempty"` + // This field needs to be specified if the destination catalog is a managed + // postgres catalog. + // + // UC schema for the pipeline to store intermediate files (checkpoints, event + // logs etc). This needs to be in the standard catalog where the user has + // permissions to create Delta tables. + StorageSchema *string `json:"storage_schema,omitempty"` +} + +type RequestedClaims struct { + PermissionSet RequestedClaims_PermissionSet `json:"permission_set,omitempty"` + Resources []RequestedResource `json:"resources,omitempty"` +} + +type RequestedResource struct { + TableName *string `json:"table_name,omitempty"` + UnspecifiedResourceName *string `json:"unspecified_resource_name,omitempty"` +} + +type SyncedDatabaseTable struct { + // Synced Table data synchronization status + DataSynchronizationStatus *SyncedTableStatus `json:"data_synchronization_status,omitempty"` + // Name of the target database instance. This is required when creating synced + // database tables in standard catalogs. This is optional when creating synced + // database tables in registered catalogs. If this field is specified when + // creating synced database tables in registered catalogs, the database instance + // name MUST match that of the registered catalog (or the request will be + // rejected). + DatabaseInstanceName *string `json:"database_instance_name,omitempty"` + // The name of the database instance that this table is registered to. This + // field is always returned, and for tables inside database catalogs is inferred + // database instance associated with the catalog. This is an output only field + // that contains the value computed from the input field combined with server + // side defaults. Use the field without the effective_ prefix to set the value. + EffectiveDatabaseInstanceName *string `json:"effective_database_instance_name,omitempty"` + // The name of the logical database that this table is registered to. This is an + // output only field that contains the value computed from the input field + // combined with server side defaults. Use the field without the effective_ + // prefix to set the value. + EffectiveLogicalDatabaseName *string `json:"effective_logical_database_name,omitempty"` + // Target Postgres database object (logical database) name for this table. + // + // When creating a synced table in a registered Postgres catalog, the target + // Postgres database name is inferred to be that of the registered catalog. If + // this field is specified in this scenario, the Postgres database name MUST + // match that of the registered catalog (or the request will be rejected). + // + // When creating a synced table in a standard catalog, this field is required. + // In this scenario, specifying this field will allow targeting an arbitrary + // postgres database. Note that this has implications for the + // `create_database_objects_is_missing` field in `spec`. + LogicalDatabaseName *string `json:"logical_database_name,omitempty"` + // Full three-part (catalog, schema, table) name of the table. + Name *string `json:"name,omitempty"` + Spec *SyncedTableSpec `json:"spec,omitempty"` + // The provisioning state of the synced table entity in Unity Catalog. This is + // distinct from the state of the data synchronization pipeline (i.e. the table + // may be in "ACTIVE" but the pipeline may be in "PROVISIONING" as it runs + // asynchronously). + UnityCatalogProvisioningState ProvisioningInfo_State `json:"unity_catalog_provisioning_state,omitempty"` +} + +// Detailed status of a synced table. Shown if the synced table is in the +// SYNCED_CONTINUOUS_UPDATE or the SYNCED_UPDATING_PIPELINE_RESOURCES state.. +type SyncedTableContinuousUpdateStatus struct { + // Progress of the initial data synchronization. + InitialPipelineSyncProgress *SyncedTablePipelineProgress `json:"initial_pipeline_sync_progress,omitempty"` + // The last source table Delta version that was successfully synced to the + // synced table. + LastProcessedCommitVersion *int64 `json:"last_processed_commit_version,omitempty"` + // The end timestamp of the last time any data was synchronized from the source + // table to the synced table. This is when the data is available in the synced + // table. + Timestamp *types.Time `json:"timestamp,omitempty"` +} + +// Detailed status of a synced table. Shown if the synced table is in the +// OFFLINE_FAILED or the SYNCED_PIPELINE_FAILED state.. +type SyncedTableFailedStatus struct { + // The last source table Delta version that was successfully synced to the + // synced table. The last source table Delta version that was synced to the + // synced table. Only populated if the table is still synced and available for + // serving. + LastProcessedCommitVersion *int64 `json:"last_processed_commit_version,omitempty"` + // The end timestamp of the last time any data was synchronized from the source + // table to the synced table. Only populated if the table is still synced and + // available for serving. + Timestamp *types.Time `json:"timestamp,omitempty"` +} + +// Progress information of the Synced Table data synchronization pipeline.. +type SyncedTablePipelineProgress struct { + // The estimated time remaining to complete this update in seconds. + EstimatedCompletionTimeSeconds *float64 `json:"estimated_completion_time_seconds,omitempty"` + // The source table Delta version that was last processed by the pipeline. The + // pipeline may not have completely processed this version yet. + LatestVersionCurrentlyProcessing *int64 `json:"latest_version_currently_processing,omitempty"` + // The current phase of the data synchronization pipeline. + ProvisioningPhase ProvisioningPhase `json:"provisioning_phase,omitempty"` + // The completion ratio of this update. This is a number between 0 and 1. + SyncProgressCompletion *float64 `json:"sync_progress_completion,omitempty"` + // The number of rows that have been synced in this update. + SyncedRowCount *int64 `json:"synced_row_count,omitempty"` + // The total number of rows that need to be synced in this update. This number + // may be an estimate. + TotalRowCount *int64 `json:"total_row_count,omitempty"` +} + +type SyncedTablePosition struct { + DeltaTableSyncInfo *DeltaTableSyncInfo `json:"delta_table_sync_info,omitempty"` + // The end timestamp of the most recent successful synchronization. This is the + // time when the data is available in the synced table. + SyncEndTimestamp *types.Time `json:"sync_end_timestamp,omitempty"` + // The starting timestamp of the most recent successful synchronization from the + // source table to the destination (synced) table. Note this is the starting + // timestamp of the sync operation, not the end time. E.g., for a batch, this is + // the time when the sync operation started. + SyncStartTimestamp *types.Time `json:"sync_start_timestamp,omitempty"` +} + +// Detailed status of a synced table. Shown if the synced table is in the +// PROVISIONING_PIPELINE_RESOURCES or the PROVISIONING_INITIAL_SNAPSHOT state.. +type SyncedTableProvisioningStatus struct { + // Details about initial data synchronization. Only populated when in the + // PROVISIONING_INITIAL_SNAPSHOT state. + InitialPipelineSyncProgress *SyncedTablePipelineProgress `json:"initial_pipeline_sync_progress,omitempty"` +} + +// Specification of a synced database table.. +type SyncedTableSpec struct { + // When true, enables accelerated sync mode for the initial data load. This + // significantly improves performance for large tables. Requires workspace-level + // enablement. + AcceleratedSync *bool `json:"accelerated_sync,omitempty"` + // If true, the synced table's logical database and schema resources in PG will + // be created if they do not already exist. + CreateDatabaseObjectsIfMissing *bool `json:"create_database_objects_if_missing,omitempty"` + // At most one of existing_pipeline_id and new_pipeline_spec should be defined. + // + // If existing_pipeline_id is defined, the synced table will be bin packed into + // the existing pipeline referenced. This avoids creating a new pipeline and + // allows sharing existing compute. In this case, the scheduling_policy of this + // synced table must match the scheduling policy of the existing pipeline. + ExistingPipelineId *string `json:"existing_pipeline_id,omitempty"` + // At most one of existing_pipeline_id and new_pipeline_spec should be defined. + // + // If new_pipeline_spec is defined, a new pipeline is created for this synced + // table. The location pointed to is used to store intermediate files + // (checkpoints, event logs etc). The caller must have write permissions to + // create Delta tables in the specified catalog and schema. Again, note this + // requires write permissions, whereas the source table only requires read + // permissions. + NewPipelineSpec *NewPipelineSpec `json:"new_pipeline_spec,omitempty"` + // Primary Key columns to be used for data insert/update in the destination. + PrimaryKeyColumns []string `json:"primary_key_columns,omitempty"` + // Scheduling policy of the underlying pipeline. + SchedulingPolicy SyncedTableSchedulingPolicy `json:"scheduling_policy,omitempty"` + // Three-part (catalog, schema, table) name of the source Delta table. + SourceTableFullName *string `json:"source_table_full_name,omitempty"` + // Time series key to deduplicate (tie-break) rows with the same primary key. + TimeseriesKey *string `json:"timeseries_key,omitempty"` + // Override the default Delta->PG type mapping for specific columns. A + // TypeOverride with PG_SPECIFIC_TYPE_UNSPECIFIED is rejected; a valid pg_type + // must be set. + TypeOverrides []SyncedTableSpec_TypeOverride `json:"type_overrides,omitempty"` +} + +// Overrides the default Delta-to-PostgreSQL type mapping for a single column.. +type SyncedTableSpec_TypeOverride struct { + // Name of the source column whose target PostgreSQL type should be overridden. + ColumnName *string `json:"column_name,omitempty"` + // PostgreSQL-specific target type to use for the column. + PgType SyncedTableSpec_PgSpecificType `json:"pg_type,omitempty"` + // Size parameter for the target type, for types that take one (e.g. vector + // dimension, varchar length). Required when the chosen pg_type needs a size. + Size *int `json:"size,omitempty"` +} + +// Status of a synced table.. +type SyncedTableStatus struct { + ContinuousUpdateStatus *SyncedTableContinuousUpdateStatus `json:"continuous_update_status,omitempty"` + // The state of the synced table. + DetailedState SyncedTableState `json:"detailed_state,omitempty"` + FailedStatus *SyncedTableFailedStatus `json:"failed_status,omitempty"` + // Summary of the last successful synchronization from source to destination. + // + // Will always be present if there has been a successful sync. Even if the most + // recent syncs have failed. + // + // Limitation: The only exception is if the synced table is doing a FULL + // REFRESH, then the last sync information will not be available until the full + // refresh is complete. This limitation will be addressed in a future version. + // + // This top-level field is a convenience for consumers who want easy access to + // last sync information without having to traverse detailed_status. + LastSync *SyncedTablePosition `json:"last_sync,omitempty"` + // A text description of the current state of the synced table. + Message *string `json:"message,omitempty"` + // ID of the associated pipeline. The pipeline ID may have been provided by the + // client (in the case of bin packing), or generated by the server (when + // creating a new pipeline). + PipelineId *string `json:"pipeline_id,omitempty"` + ProvisioningStatus *SyncedTableProvisioningStatus `json:"provisioning_status,omitempty"` + TriggeredUpdateStatus *SyncedTableTriggeredUpdateStatus `json:"triggered_update_status,omitempty"` +} + +// Detailed status of a synced table. Shown if the synced table is in the +// SYNCED_TRIGGERED_UPDATE or the SYNCED_NO_PENDING_UPDATE state.. +type SyncedTableTriggeredUpdateStatus struct { + // The last source table Delta version that was successfully synced to the + // synced table. + LastProcessedCommitVersion *int64 `json:"last_processed_commit_version,omitempty"` + // The end timestamp of the last time any data was synchronized from the source + // table to the synced table. This is when the data is available in the synced + // table. + Timestamp *types.Time `json:"timestamp,omitempty"` + // Progress of the active data synchronization pipeline. + TriggeredUpdateProgress *SyncedTablePipelineProgress `json:"triggered_update_progress,omitempty"` +} + +type UpdateDatabaseCatalogRequest struct { + // Note that updating a database catalog is not yet supported. + DatabaseCatalog *DatabaseCatalog `json:"database_catalog,omitempty"` + // The list of fields to update. Setting this field is not yet supported. + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateDatabaseInstanceRequest struct { + DatabaseInstance *DatabaseInstance `json:"database_instance,omitempty"` + // The list of fields to update. If unspecified, all fields will be updated when + // possible. To wipe out custom_tags, specify custom_tags in the update_mask + // with an empty custom_tags map. + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateSyncedDatabaseTableRequest struct { + // Note that updating a synced database table is not yet supported. + SyncedTable *SyncedDatabaseTable `json:"synced_table,omitempty"` + // The list of fields to update. Setting this field is not yet supported. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CreateDatabaseCatalogRequestToSDK converts the mirror to the sdk-go type. +func CreateDatabaseCatalogRequestToSDK(w *CreateDatabaseCatalogRequest) (*sdk.CreateDatabaseCatalogRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateDatabaseCatalogRequest{} + conv1, err := DatabaseCatalogToSDK(w.Catalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDatabaseCatalogRequest.Catalog", err) + } + out.Catalog = conv1 + return out, nil +} + +// CreateDatabaseCatalogRequestFromSDK converts the sdk-go type to the mirror. +func CreateDatabaseCatalogRequestFromSDK(v *sdk.CreateDatabaseCatalogRequest) (*CreateDatabaseCatalogRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateDatabaseCatalogRequest{} + conv2, err := DatabaseCatalogFromSDK(v.Catalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDatabaseCatalogRequest.Catalog", err) + } + out.Catalog = conv2 + return out, nil +} + +// CreateDatabaseInstanceRequestToSDK converts the mirror to the sdk-go type. +func CreateDatabaseInstanceRequestToSDK(w *CreateDatabaseInstanceRequest) (*sdk.CreateDatabaseInstanceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateDatabaseInstanceRequest{} + conv3, err := DatabaseInstanceToSDK(w.DatabaseInstance) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDatabaseInstanceRequest.DatabaseInstance", err) + } + out.DatabaseInstance = conv3 + return out, nil +} + +// CreateDatabaseInstanceRequestFromSDK converts the sdk-go type to the mirror. +func CreateDatabaseInstanceRequestFromSDK(v *sdk.CreateDatabaseInstanceRequest) (*CreateDatabaseInstanceRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateDatabaseInstanceRequest{} + conv4, err := DatabaseInstanceFromSDK(v.DatabaseInstance) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDatabaseInstanceRequest.DatabaseInstance", err) + } + out.DatabaseInstance = conv4 + return out, nil +} + +// CreateDatabaseInstanceRoleRequestToSDK converts the mirror to the sdk-go type. +func CreateDatabaseInstanceRoleRequestToSDK(w *CreateDatabaseInstanceRoleRequest) (*sdk.CreateDatabaseInstanceRoleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateDatabaseInstanceRoleRequest{} + out.InstanceName = w.InstanceName + conv5, err := DatabaseInstanceRoleToSDK(w.DatabaseInstanceRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDatabaseInstanceRoleRequest.DatabaseInstanceRole", err) + } + out.DatabaseInstanceRole = conv5 + out.DatabaseInstanceName = w.DatabaseInstanceName + return out, nil +} + +// CreateDatabaseInstanceRoleRequestFromSDK converts the sdk-go type to the mirror. +func CreateDatabaseInstanceRoleRequestFromSDK(v *sdk.CreateDatabaseInstanceRoleRequest) (*CreateDatabaseInstanceRoleRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateDatabaseInstanceRoleRequest{} + out.InstanceName = v.InstanceName + conv6, err := DatabaseInstanceRoleFromSDK(v.DatabaseInstanceRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDatabaseInstanceRoleRequest.DatabaseInstanceRole", err) + } + out.DatabaseInstanceRole = conv6 + out.DatabaseInstanceName = v.DatabaseInstanceName + return out, nil +} + +// CreateDatabaseTableRequestToSDK converts the mirror to the sdk-go type. +func CreateDatabaseTableRequestToSDK(w *CreateDatabaseTableRequest) (*sdk.CreateDatabaseTableRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateDatabaseTableRequest{} + conv7, err := DatabaseTableToSDK(w.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDatabaseTableRequest.Table", err) + } + out.Table = conv7 + return out, nil +} + +// CreateDatabaseTableRequestFromSDK converts the sdk-go type to the mirror. +func CreateDatabaseTableRequestFromSDK(v *sdk.CreateDatabaseTableRequest) (*CreateDatabaseTableRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateDatabaseTableRequest{} + conv8, err := DatabaseTableFromSDK(v.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDatabaseTableRequest.Table", err) + } + out.Table = conv8 + return out, nil +} + +// CreateSyncedDatabaseTableRequestToSDK converts the mirror to the sdk-go type. +func CreateSyncedDatabaseTableRequestToSDK(w *CreateSyncedDatabaseTableRequest) (*sdk.CreateSyncedDatabaseTableRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateSyncedDatabaseTableRequest{} + conv9, err := SyncedDatabaseTableToSDK(w.SyncedTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSyncedDatabaseTableRequest.SyncedTable", err) + } + out.SyncedTable = conv9 + return out, nil +} + +// CreateSyncedDatabaseTableRequestFromSDK converts the sdk-go type to the mirror. +func CreateSyncedDatabaseTableRequestFromSDK(v *sdk.CreateSyncedDatabaseTableRequest) (*CreateSyncedDatabaseTableRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateSyncedDatabaseTableRequest{} + conv10, err := SyncedDatabaseTableFromSDK(v.SyncedTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSyncedDatabaseTableRequest.SyncedTable", err) + } + out.SyncedTable = conv10 + return out, nil +} + +// CustomTagToSDK converts the mirror to the sdk-go type. +func CustomTagToSDK(w *CustomTag) (*sdk.CustomTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// CustomTagFromSDK converts the sdk-go type to the mirror. +func CustomTagFromSDK(v *sdk.CustomTag) (*CustomTag, error) { + if v == nil { + return nil, nil + } + out := &CustomTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// DatabaseCatalogToSDK converts the mirror to the sdk-go type. +func DatabaseCatalogToSDK(w *DatabaseCatalog) (*sdk.DatabaseCatalog, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabaseCatalog{} + out.Name = w.Name + out.DatabaseInstanceName = w.DatabaseInstanceName + out.DatabaseName = w.DatabaseName + out.Uid = w.Uid + out.CreateDatabaseIfNotExists = w.CreateDatabaseIfNotExists + return out, nil +} + +// DatabaseCatalogFromSDK converts the sdk-go type to the mirror. +func DatabaseCatalogFromSDK(v *sdk.DatabaseCatalog) (*DatabaseCatalog, error) { + if v == nil { + return nil, nil + } + out := &DatabaseCatalog{} + out.Name = v.Name + out.DatabaseInstanceName = v.DatabaseInstanceName + out.DatabaseName = v.DatabaseName + out.Uid = v.Uid + out.CreateDatabaseIfNotExists = v.CreateDatabaseIfNotExists + return out, nil +} + +// DatabaseCredentialToSDK converts the mirror to the sdk-go type. +func DatabaseCredentialToSDK(w *DatabaseCredential) (*sdk.DatabaseCredential, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabaseCredential{} + out.Token = w.Token + out.ExpirationTime = w.ExpirationTime + return out, nil +} + +// DatabaseCredentialFromSDK converts the sdk-go type to the mirror. +func DatabaseCredentialFromSDK(v *sdk.DatabaseCredential) (*DatabaseCredential, error) { + if v == nil { + return nil, nil + } + out := &DatabaseCredential{} + out.Token = v.Token + out.ExpirationTime = v.ExpirationTime + return out, nil +} + +// DatabaseInstanceToSDK converts the mirror to the sdk-go type. +func DatabaseInstanceToSDK(w *DatabaseInstance) (*sdk.DatabaseInstance, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabaseInstance{} + out.Uid = w.Uid + out.Name = w.Name + out.Creator = w.Creator + out.ReadWriteDns = w.ReadWriteDns + out.CreationTime = w.CreationTime + out.State = w.State + out.PgVersion = w.PgVersion + out.Capacity = w.Capacity + out.EffectiveCapacity = w.EffectiveCapacity + out.Stopped = w.Stopped + out.EffectiveStopped = w.EffectiveStopped + out.NodeCount = w.NodeCount + out.EffectiveNodeCount = w.EffectiveNodeCount + out.EnableReadableSecondaries = w.EnableReadableSecondaries + out.EffectiveEnableReadableSecondaries = w.EffectiveEnableReadableSecondaries + out.ReadOnlyDns = w.ReadOnlyDns + out.RetentionWindowInDays = w.RetentionWindowInDays + out.EffectiveRetentionWindowInDays = w.EffectiveRetentionWindowInDays + conv11, err := DatabaseInstanceRefToSDK(w.ParentInstanceRef) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatabaseInstance.ParentInstanceRef", err) + } + out.ParentInstanceRef = conv11 + conv12, err := convertSlice(w.ChildInstanceRefs, DatabaseInstanceRefToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatabaseInstance.ChildInstanceRefs", err) + } + out.ChildInstanceRefs = conv12 + out.EnablePgNativeLogin = w.EnablePgNativeLogin + out.EffectiveEnablePgNativeLogin = w.EffectiveEnablePgNativeLogin + out.UsagePolicyId = w.UsagePolicyId + out.EffectiveUsagePolicyId = w.EffectiveUsagePolicyId + conv13, err := convertSlice(w.CustomTags, CustomTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatabaseInstance.CustomTags", err) + } + out.CustomTags = conv13 + conv14, err := convertSlice(w.EffectiveCustomTags, CustomTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatabaseInstance.EffectiveCustomTags", err) + } + out.EffectiveCustomTags = conv14 + return out, nil +} + +// DatabaseInstanceFromSDK converts the sdk-go type to the mirror. +func DatabaseInstanceFromSDK(v *sdk.DatabaseInstance) (*DatabaseInstance, error) { + if v == nil { + return nil, nil + } + out := &DatabaseInstance{} + out.Uid = v.Uid + out.Name = v.Name + out.Creator = v.Creator + out.ReadWriteDns = v.ReadWriteDns + out.CreationTime = v.CreationTime + out.State = v.State + out.PgVersion = v.PgVersion + out.Capacity = v.Capacity + out.EffectiveCapacity = v.EffectiveCapacity + out.Stopped = v.Stopped + out.EffectiveStopped = v.EffectiveStopped + out.NodeCount = v.NodeCount + out.EffectiveNodeCount = v.EffectiveNodeCount + out.EnableReadableSecondaries = v.EnableReadableSecondaries + out.EffectiveEnableReadableSecondaries = v.EffectiveEnableReadableSecondaries + out.ReadOnlyDns = v.ReadOnlyDns + out.RetentionWindowInDays = v.RetentionWindowInDays + out.EffectiveRetentionWindowInDays = v.EffectiveRetentionWindowInDays + conv15, err := DatabaseInstanceRefFromSDK(v.ParentInstanceRef) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatabaseInstance.ParentInstanceRef", err) + } + out.ParentInstanceRef = conv15 + conv16, err := convertSlice(v.ChildInstanceRefs, DatabaseInstanceRefFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatabaseInstance.ChildInstanceRefs", err) + } + out.ChildInstanceRefs = conv16 + out.EnablePgNativeLogin = v.EnablePgNativeLogin + out.EffectiveEnablePgNativeLogin = v.EffectiveEnablePgNativeLogin + out.UsagePolicyId = v.UsagePolicyId + out.EffectiveUsagePolicyId = v.EffectiveUsagePolicyId + conv17, err := convertSlice(v.CustomTags, CustomTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatabaseInstance.CustomTags", err) + } + out.CustomTags = conv17 + conv18, err := convertSlice(v.EffectiveCustomTags, CustomTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatabaseInstance.EffectiveCustomTags", err) + } + out.EffectiveCustomTags = conv18 + return out, nil +} + +// DatabaseInstanceRefToSDK converts the mirror to the sdk-go type. +func DatabaseInstanceRefToSDK(w *DatabaseInstanceRef) (*sdk.DatabaseInstanceRef, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabaseInstanceRef{} + out.Uid = w.Uid + out.Name = w.Name + out.Lsn = w.Lsn + out.EffectiveLsn = w.EffectiveLsn + out.BranchTime = w.BranchTime + return out, nil +} + +// DatabaseInstanceRefFromSDK converts the sdk-go type to the mirror. +func DatabaseInstanceRefFromSDK(v *sdk.DatabaseInstanceRef) (*DatabaseInstanceRef, error) { + if v == nil { + return nil, nil + } + out := &DatabaseInstanceRef{} + out.Uid = v.Uid + out.Name = v.Name + out.Lsn = v.Lsn + out.EffectiveLsn = v.EffectiveLsn + out.BranchTime = v.BranchTime + return out, nil +} + +// DatabaseInstanceRoleToSDK converts the mirror to the sdk-go type. +func DatabaseInstanceRoleToSDK(w *DatabaseInstanceRole) (*sdk.DatabaseInstanceRole, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabaseInstanceRole{} + out.Name = w.Name + out.IdentityType = w.IdentityType + out.MembershipRole = w.MembershipRole + conv19, err := DatabaseInstanceRole_AttributesToSDK(w.Attributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatabaseInstanceRole.Attributes", err) + } + out.Attributes = conv19 + conv20, err := DatabaseInstanceRole_AttributesToSDK(w.EffectiveAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatabaseInstanceRole.EffectiveAttributes", err) + } + out.EffectiveAttributes = conv20 + out.InstanceName = w.InstanceName + return out, nil +} + +// DatabaseInstanceRoleFromSDK converts the sdk-go type to the mirror. +func DatabaseInstanceRoleFromSDK(v *sdk.DatabaseInstanceRole) (*DatabaseInstanceRole, error) { + if v == nil { + return nil, nil + } + out := &DatabaseInstanceRole{} + out.Name = v.Name + out.IdentityType = v.IdentityType + out.MembershipRole = v.MembershipRole + conv21, err := DatabaseInstanceRole_AttributesFromSDK(v.Attributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatabaseInstanceRole.Attributes", err) + } + out.Attributes = conv21 + conv22, err := DatabaseInstanceRole_AttributesFromSDK(v.EffectiveAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatabaseInstanceRole.EffectiveAttributes", err) + } + out.EffectiveAttributes = conv22 + out.InstanceName = v.InstanceName + return out, nil +} + +// DatabaseInstanceRole_AttributesToSDK converts the mirror to the sdk-go type. +func DatabaseInstanceRole_AttributesToSDK(w *DatabaseInstanceRole_Attributes) (*sdk.DatabaseInstanceRole_Attributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabaseInstanceRole_Attributes{} + out.Createdb = w.Createdb + out.Createrole = w.Createrole + out.Bypassrls = w.Bypassrls + return out, nil +} + +// DatabaseInstanceRole_AttributesFromSDK converts the sdk-go type to the mirror. +func DatabaseInstanceRole_AttributesFromSDK(v *sdk.DatabaseInstanceRole_Attributes) (*DatabaseInstanceRole_Attributes, error) { + if v == nil { + return nil, nil + } + out := &DatabaseInstanceRole_Attributes{} + out.Createdb = v.Createdb + out.Createrole = v.Createrole + out.Bypassrls = v.Bypassrls + return out, nil +} + +// DatabaseTableToSDK converts the mirror to the sdk-go type. +func DatabaseTableToSDK(w *DatabaseTable) (*sdk.DatabaseTable, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabaseTable{} + out.Name = w.Name + out.DatabaseInstanceName = w.DatabaseInstanceName + out.LogicalDatabaseName = w.LogicalDatabaseName + return out, nil +} + +// DatabaseTableFromSDK converts the sdk-go type to the mirror. +func DatabaseTableFromSDK(v *sdk.DatabaseTable) (*DatabaseTable, error) { + if v == nil { + return nil, nil + } + out := &DatabaseTable{} + out.Name = v.Name + out.DatabaseInstanceName = v.DatabaseInstanceName + out.LogicalDatabaseName = v.LogicalDatabaseName + return out, nil +} + +// DeleteDatabaseInstanceRequestToSDK converts the mirror to the sdk-go type. +func DeleteDatabaseInstanceRequestToSDK(w *DeleteDatabaseInstanceRequest) (*sdk.DeleteDatabaseInstanceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteDatabaseInstanceRequest{} + out.Name = w.Name + out.Force = w.Force + out.Purge = w.Purge + return out, nil +} + +// DeleteDatabaseInstanceRequestFromSDK converts the sdk-go type to the mirror. +func DeleteDatabaseInstanceRequestFromSDK(v *sdk.DeleteDatabaseInstanceRequest) (*DeleteDatabaseInstanceRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteDatabaseInstanceRequest{} + out.Name = v.Name + out.Force = v.Force + out.Purge = v.Purge + return out, nil +} + +// DeleteDatabaseInstanceRoleRequestToSDK converts the mirror to the sdk-go type. +func DeleteDatabaseInstanceRoleRequestToSDK(w *DeleteDatabaseInstanceRoleRequest) (*sdk.DeleteDatabaseInstanceRoleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteDatabaseInstanceRoleRequest{} + out.InstanceName = w.InstanceName + out.Name = w.Name + out.ReassignOwnedTo = w.ReassignOwnedTo + out.AllowMissing = w.AllowMissing + return out, nil +} + +// DeleteDatabaseInstanceRoleRequestFromSDK converts the sdk-go type to the mirror. +func DeleteDatabaseInstanceRoleRequestFromSDK(v *sdk.DeleteDatabaseInstanceRoleRequest) (*DeleteDatabaseInstanceRoleRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteDatabaseInstanceRoleRequest{} + out.InstanceName = v.InstanceName + out.Name = v.Name + out.ReassignOwnedTo = v.ReassignOwnedTo + out.AllowMissing = v.AllowMissing + return out, nil +} + +// DeleteSyncedDatabaseTableRequestToSDK converts the mirror to the sdk-go type. +func DeleteSyncedDatabaseTableRequestToSDK(w *DeleteSyncedDatabaseTableRequest) (*sdk.DeleteSyncedDatabaseTableRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteSyncedDatabaseTableRequest{} + out.Name = w.Name + out.PurgeData = w.PurgeData + return out, nil +} + +// DeleteSyncedDatabaseTableRequestFromSDK converts the sdk-go type to the mirror. +func DeleteSyncedDatabaseTableRequestFromSDK(v *sdk.DeleteSyncedDatabaseTableRequest) (*DeleteSyncedDatabaseTableRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteSyncedDatabaseTableRequest{} + out.Name = v.Name + out.PurgeData = v.PurgeData + return out, nil +} + +// DeltaTableSyncInfoToSDK converts the mirror to the sdk-go type. +func DeltaTableSyncInfoToSDK(w *DeltaTableSyncInfo) (*sdk.DeltaTableSyncInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeltaTableSyncInfo{} + out.DeltaCommitVersion = w.DeltaCommitVersion + out.DeltaCommitTimestamp = w.DeltaCommitTimestamp + return out, nil +} + +// DeltaTableSyncInfoFromSDK converts the sdk-go type to the mirror. +func DeltaTableSyncInfoFromSDK(v *sdk.DeltaTableSyncInfo) (*DeltaTableSyncInfo, error) { + if v == nil { + return nil, nil + } + out := &DeltaTableSyncInfo{} + out.DeltaCommitVersion = v.DeltaCommitVersion + out.DeltaCommitTimestamp = v.DeltaCommitTimestamp + return out, nil +} + +// FindDatabaseInstanceByUidRequestToSDK converts the mirror to the sdk-go type. +func FindDatabaseInstanceByUidRequestToSDK(w *FindDatabaseInstanceByUidRequest) (*sdk.FindDatabaseInstanceByUidRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.FindDatabaseInstanceByUidRequest{} + out.Uid = w.Uid + return out, nil +} + +// FindDatabaseInstanceByUidRequestFromSDK converts the sdk-go type to the mirror. +func FindDatabaseInstanceByUidRequestFromSDK(v *sdk.FindDatabaseInstanceByUidRequest) (*FindDatabaseInstanceByUidRequest, error) { + if v == nil { + return nil, nil + } + out := &FindDatabaseInstanceByUidRequest{} + out.Uid = v.Uid + return out, nil +} + +// GenerateDatabaseCredentialRequestToSDK converts the mirror to the sdk-go type. +func GenerateDatabaseCredentialRequestToSDK(w *GenerateDatabaseCredentialRequest) (*sdk.GenerateDatabaseCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenerateDatabaseCredentialRequest{} + out.RequestId = w.RequestId + out.InstanceNames = w.InstanceNames + conv23, err := convertSlice(w.Claims, RequestedClaimsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateDatabaseCredentialRequest.Claims", err) + } + out.Claims = conv23 + return out, nil +} + +// GenerateDatabaseCredentialRequestFromSDK converts the sdk-go type to the mirror. +func GenerateDatabaseCredentialRequestFromSDK(v *sdk.GenerateDatabaseCredentialRequest) (*GenerateDatabaseCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &GenerateDatabaseCredentialRequest{} + out.RequestId = v.RequestId + out.InstanceNames = v.InstanceNames + conv24, err := convertSlice(v.Claims, RequestedClaimsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateDatabaseCredentialRequest.Claims", err) + } + out.Claims = conv24 + return out, nil +} + +// ListDatabaseCatalogsRequestToSDK converts the mirror to the sdk-go type. +func ListDatabaseCatalogsRequestToSDK(w *ListDatabaseCatalogsRequest) (*sdk.ListDatabaseCatalogsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDatabaseCatalogsRequest{} + out.InstanceName = w.InstanceName + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListDatabaseCatalogsRequestFromSDK converts the sdk-go type to the mirror. +func ListDatabaseCatalogsRequestFromSDK(v *sdk.ListDatabaseCatalogsRequest) (*ListDatabaseCatalogsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListDatabaseCatalogsRequest{} + out.InstanceName = v.InstanceName + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListDatabaseCatalogsResponseToSDK converts the mirror to the sdk-go type. +func ListDatabaseCatalogsResponseToSDK(w *ListDatabaseCatalogsResponse) (*sdk.ListDatabaseCatalogsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDatabaseCatalogsResponse{} + conv25, err := convertSlice(w.DatabaseCatalogs, DatabaseCatalogToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDatabaseCatalogsResponse.DatabaseCatalogs", err) + } + out.DatabaseCatalogs = conv25 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListDatabaseCatalogsResponseFromSDK converts the sdk-go type to the mirror. +func ListDatabaseCatalogsResponseFromSDK(v *sdk.ListDatabaseCatalogsResponse) (*ListDatabaseCatalogsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListDatabaseCatalogsResponse{} + conv26, err := convertSlice(v.DatabaseCatalogs, DatabaseCatalogFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDatabaseCatalogsResponse.DatabaseCatalogs", err) + } + out.DatabaseCatalogs = conv26 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListDatabaseInstanceRolesRequestToSDK converts the mirror to the sdk-go type. +func ListDatabaseInstanceRolesRequestToSDK(w *ListDatabaseInstanceRolesRequest) (*sdk.ListDatabaseInstanceRolesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDatabaseInstanceRolesRequest{} + out.InstanceName = w.InstanceName + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListDatabaseInstanceRolesRequestFromSDK converts the sdk-go type to the mirror. +func ListDatabaseInstanceRolesRequestFromSDK(v *sdk.ListDatabaseInstanceRolesRequest) (*ListDatabaseInstanceRolesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListDatabaseInstanceRolesRequest{} + out.InstanceName = v.InstanceName + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListDatabaseInstanceRolesResponseToSDK converts the mirror to the sdk-go type. +func ListDatabaseInstanceRolesResponseToSDK(w *ListDatabaseInstanceRolesResponse) (*sdk.ListDatabaseInstanceRolesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDatabaseInstanceRolesResponse{} + conv27, err := convertSlice(w.DatabaseInstanceRoles, DatabaseInstanceRoleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDatabaseInstanceRolesResponse.DatabaseInstanceRoles", err) + } + out.DatabaseInstanceRoles = conv27 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListDatabaseInstanceRolesResponseFromSDK converts the sdk-go type to the mirror. +func ListDatabaseInstanceRolesResponseFromSDK(v *sdk.ListDatabaseInstanceRolesResponse) (*ListDatabaseInstanceRolesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListDatabaseInstanceRolesResponse{} + conv28, err := convertSlice(v.DatabaseInstanceRoles, DatabaseInstanceRoleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDatabaseInstanceRolesResponse.DatabaseInstanceRoles", err) + } + out.DatabaseInstanceRoles = conv28 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListDatabaseInstancesRequestToSDK converts the mirror to the sdk-go type. +func ListDatabaseInstancesRequestToSDK(w *ListDatabaseInstancesRequest) (*sdk.ListDatabaseInstancesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDatabaseInstancesRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListDatabaseInstancesRequestFromSDK converts the sdk-go type to the mirror. +func ListDatabaseInstancesRequestFromSDK(v *sdk.ListDatabaseInstancesRequest) (*ListDatabaseInstancesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListDatabaseInstancesRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListDatabaseInstancesResponseToSDK converts the mirror to the sdk-go type. +func ListDatabaseInstancesResponseToSDK(w *ListDatabaseInstancesResponse) (*sdk.ListDatabaseInstancesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDatabaseInstancesResponse{} + conv29, err := convertSlice(w.DatabaseInstances, DatabaseInstanceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDatabaseInstancesResponse.DatabaseInstances", err) + } + out.DatabaseInstances = conv29 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListDatabaseInstancesResponseFromSDK converts the sdk-go type to the mirror. +func ListDatabaseInstancesResponseFromSDK(v *sdk.ListDatabaseInstancesResponse) (*ListDatabaseInstancesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListDatabaseInstancesResponse{} + conv30, err := convertSlice(v.DatabaseInstances, DatabaseInstanceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDatabaseInstancesResponse.DatabaseInstances", err) + } + out.DatabaseInstances = conv30 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListSyncedDatabaseTablesRequestToSDK converts the mirror to the sdk-go type. +func ListSyncedDatabaseTablesRequestToSDK(w *ListSyncedDatabaseTablesRequest) (*sdk.ListSyncedDatabaseTablesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSyncedDatabaseTablesRequest{} + out.InstanceName = w.InstanceName + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListSyncedDatabaseTablesRequestFromSDK converts the sdk-go type to the mirror. +func ListSyncedDatabaseTablesRequestFromSDK(v *sdk.ListSyncedDatabaseTablesRequest) (*ListSyncedDatabaseTablesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSyncedDatabaseTablesRequest{} + out.InstanceName = v.InstanceName + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListSyncedDatabaseTablesResponseToSDK converts the mirror to the sdk-go type. +func ListSyncedDatabaseTablesResponseToSDK(w *ListSyncedDatabaseTablesResponse) (*sdk.ListSyncedDatabaseTablesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSyncedDatabaseTablesResponse{} + conv31, err := convertSlice(w.SyncedTables, SyncedDatabaseTableToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSyncedDatabaseTablesResponse.SyncedTables", err) + } + out.SyncedTables = conv31 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSyncedDatabaseTablesResponseFromSDK converts the sdk-go type to the mirror. +func ListSyncedDatabaseTablesResponseFromSDK(v *sdk.ListSyncedDatabaseTablesResponse) (*ListSyncedDatabaseTablesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSyncedDatabaseTablesResponse{} + conv32, err := convertSlice(v.SyncedTables, SyncedDatabaseTableFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSyncedDatabaseTablesResponse.SyncedTables", err) + } + out.SyncedTables = conv32 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// NewPipelineSpecToSDK converts the mirror to the sdk-go type. +func NewPipelineSpecToSDK(w *NewPipelineSpec) (*sdk.NewPipelineSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.NewPipelineSpec{} + out.StorageCatalog = w.StorageCatalog + out.StorageSchema = w.StorageSchema + out.BudgetPolicyId = w.BudgetPolicyId + return out, nil +} + +// NewPipelineSpecFromSDK converts the sdk-go type to the mirror. +func NewPipelineSpecFromSDK(v *sdk.NewPipelineSpec) (*NewPipelineSpec, error) { + if v == nil { + return nil, nil + } + out := &NewPipelineSpec{} + out.StorageCatalog = v.StorageCatalog + out.StorageSchema = v.StorageSchema + out.BudgetPolicyId = v.BudgetPolicyId + return out, nil +} + +// RequestedClaimsToSDK converts the mirror to the sdk-go type. +func RequestedClaimsToSDK(w *RequestedClaims) (*sdk.RequestedClaims, error) { + if w == nil { + return nil, nil + } + out := &sdk.RequestedClaims{} + out.PermissionSet = w.PermissionSet + conv33, err := convertSlice(w.Resources, RequestedResourceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RequestedClaims.Resources", err) + } + out.Resources = conv33 + return out, nil +} + +// RequestedClaimsFromSDK converts the sdk-go type to the mirror. +func RequestedClaimsFromSDK(v *sdk.RequestedClaims) (*RequestedClaims, error) { + if v == nil { + return nil, nil + } + out := &RequestedClaims{} + out.PermissionSet = v.PermissionSet + conv34, err := convertSlice(v.Resources, RequestedResourceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RequestedClaims.Resources", err) + } + out.Resources = conv34 + return out, nil +} + +// RequestedResourceToSDK converts the mirror to the sdk-go type. +func RequestedResourceToSDK(w *RequestedResource) (*sdk.RequestedResource, error) { + if w == nil { + return nil, nil + } + out := &sdk.RequestedResource{} + { + var members []string + if w.UnspecifiedResourceName != nil { + members = append(members, "unspecified_resource_name") + } + if w.TableName != nil { + members = append(members, "table_name") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UnspecifiedResourceName != nil: + out.ResourceName = &sdk.RequestedResource_ResourceName_UnspecifiedResourceName{UnspecifiedResourceName: *w.UnspecifiedResourceName} + case w.TableName != nil: + out.ResourceName = &sdk.RequestedResource_ResourceName_TableName{TableName: *w.TableName} + } + return out, nil +} + +// RequestedResourceFromSDK converts the sdk-go type to the mirror. +func RequestedResourceFromSDK(v *sdk.RequestedResource) (*RequestedResource, error) { + if v == nil { + return nil, nil + } + out := &RequestedResource{} + switch value := v.ResourceName.(type) { + case *sdk.RequestedResource_ResourceName_UnspecifiedResourceName: + if value != nil { + out.UnspecifiedResourceName = new(value.UnspecifiedResourceName) + } + case *sdk.RequestedResource_ResourceName_TableName: + if value != nil { + out.TableName = new(value.TableName) + } + } + return out, nil +} + +// SyncedDatabaseTableToSDK converts the mirror to the sdk-go type. +func SyncedDatabaseTableToSDK(w *SyncedDatabaseTable) (*sdk.SyncedDatabaseTable, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedDatabaseTable{} + out.Name = w.Name + out.DatabaseInstanceName = w.DatabaseInstanceName + out.EffectiveDatabaseInstanceName = w.EffectiveDatabaseInstanceName + out.LogicalDatabaseName = w.LogicalDatabaseName + out.EffectiveLogicalDatabaseName = w.EffectiveLogicalDatabaseName + conv35, err := SyncedTableSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedDatabaseTable.Spec", err) + } + out.Spec = conv35 + out.UnityCatalogProvisioningState = w.UnityCatalogProvisioningState + conv36, err := SyncedTableStatusToSDK(w.DataSynchronizationStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedDatabaseTable.DataSynchronizationStatus", err) + } + out.DataSynchronizationStatus = conv36 + return out, nil +} + +// SyncedDatabaseTableFromSDK converts the sdk-go type to the mirror. +func SyncedDatabaseTableFromSDK(v *sdk.SyncedDatabaseTable) (*SyncedDatabaseTable, error) { + if v == nil { + return nil, nil + } + out := &SyncedDatabaseTable{} + out.Name = v.Name + out.DatabaseInstanceName = v.DatabaseInstanceName + out.EffectiveDatabaseInstanceName = v.EffectiveDatabaseInstanceName + out.LogicalDatabaseName = v.LogicalDatabaseName + out.EffectiveLogicalDatabaseName = v.EffectiveLogicalDatabaseName + conv37, err := SyncedTableSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedDatabaseTable.Spec", err) + } + out.Spec = conv37 + out.UnityCatalogProvisioningState = v.UnityCatalogProvisioningState + conv38, err := SyncedTableStatusFromSDK(v.DataSynchronizationStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedDatabaseTable.DataSynchronizationStatus", err) + } + out.DataSynchronizationStatus = conv38 + return out, nil +} + +// SyncedTableContinuousUpdateStatusToSDK converts the mirror to the sdk-go type. +func SyncedTableContinuousUpdateStatusToSDK(w *SyncedTableContinuousUpdateStatus) (*sdk.SyncedTableContinuousUpdateStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTableContinuousUpdateStatus{} + out.LastProcessedCommitVersion = w.LastProcessedCommitVersion + out.Timestamp = w.Timestamp + conv39, err := SyncedTablePipelineProgressToSDK(w.InitialPipelineSyncProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableContinuousUpdateStatus.InitialPipelineSyncProgress", err) + } + out.InitialPipelineSyncProgress = conv39 + return out, nil +} + +// SyncedTableContinuousUpdateStatusFromSDK converts the sdk-go type to the mirror. +func SyncedTableContinuousUpdateStatusFromSDK(v *sdk.SyncedTableContinuousUpdateStatus) (*SyncedTableContinuousUpdateStatus, error) { + if v == nil { + return nil, nil + } + out := &SyncedTableContinuousUpdateStatus{} + out.LastProcessedCommitVersion = v.LastProcessedCommitVersion + out.Timestamp = v.Timestamp + conv40, err := SyncedTablePipelineProgressFromSDK(v.InitialPipelineSyncProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableContinuousUpdateStatus.InitialPipelineSyncProgress", err) + } + out.InitialPipelineSyncProgress = conv40 + return out, nil +} + +// SyncedTableFailedStatusToSDK converts the mirror to the sdk-go type. +func SyncedTableFailedStatusToSDK(w *SyncedTableFailedStatus) (*sdk.SyncedTableFailedStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTableFailedStatus{} + out.LastProcessedCommitVersion = w.LastProcessedCommitVersion + out.Timestamp = w.Timestamp + return out, nil +} + +// SyncedTableFailedStatusFromSDK converts the sdk-go type to the mirror. +func SyncedTableFailedStatusFromSDK(v *sdk.SyncedTableFailedStatus) (*SyncedTableFailedStatus, error) { + if v == nil { + return nil, nil + } + out := &SyncedTableFailedStatus{} + out.LastProcessedCommitVersion = v.LastProcessedCommitVersion + out.Timestamp = v.Timestamp + return out, nil +} + +// SyncedTablePipelineProgressToSDK converts the mirror to the sdk-go type. +func SyncedTablePipelineProgressToSDK(w *SyncedTablePipelineProgress) (*sdk.SyncedTablePipelineProgress, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTablePipelineProgress{} + out.LatestVersionCurrentlyProcessing = w.LatestVersionCurrentlyProcessing + out.SyncedRowCount = w.SyncedRowCount + out.TotalRowCount = w.TotalRowCount + out.SyncProgressCompletion = w.SyncProgressCompletion + out.EstimatedCompletionTimeSeconds = w.EstimatedCompletionTimeSeconds + out.ProvisioningPhase = w.ProvisioningPhase + return out, nil +} + +// SyncedTablePipelineProgressFromSDK converts the sdk-go type to the mirror. +func SyncedTablePipelineProgressFromSDK(v *sdk.SyncedTablePipelineProgress) (*SyncedTablePipelineProgress, error) { + if v == nil { + return nil, nil + } + out := &SyncedTablePipelineProgress{} + out.LatestVersionCurrentlyProcessing = v.LatestVersionCurrentlyProcessing + out.SyncedRowCount = v.SyncedRowCount + out.TotalRowCount = v.TotalRowCount + out.SyncProgressCompletion = v.SyncProgressCompletion + out.EstimatedCompletionTimeSeconds = v.EstimatedCompletionTimeSeconds + out.ProvisioningPhase = v.ProvisioningPhase + return out, nil +} + +// SyncedTablePositionToSDK converts the mirror to the sdk-go type. +func SyncedTablePositionToSDK(w *SyncedTablePosition) (*sdk.SyncedTablePosition, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTablePosition{} + out.SyncStartTimestamp = w.SyncStartTimestamp + out.SyncEndTimestamp = w.SyncEndTimestamp + { + var members []string + if w.DeltaTableSyncInfo != nil { + members = append(members, "delta_table_sync_info") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DeltaTableSyncInfo != nil: + conv41, err := DeltaTableSyncInfoToSDK(w.DeltaTableSyncInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTablePosition.SourceSyncInfo", err) + } + out.SourceSyncInfo = &sdk.SyncedTablePosition_SourceSyncInfo_DeltaTableSyncInfo{DeltaTableSyncInfo: *conv41} + } + return out, nil +} + +// SyncedTablePositionFromSDK converts the sdk-go type to the mirror. +func SyncedTablePositionFromSDK(v *sdk.SyncedTablePosition) (*SyncedTablePosition, error) { + if v == nil { + return nil, nil + } + out := &SyncedTablePosition{} + out.SyncStartTimestamp = v.SyncStartTimestamp + out.SyncEndTimestamp = v.SyncEndTimestamp + switch value := v.SourceSyncInfo.(type) { + case *sdk.SyncedTablePosition_SourceSyncInfo_DeltaTableSyncInfo: + if value != nil { + conv42, err := DeltaTableSyncInfoFromSDK(&value.DeltaTableSyncInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTablePosition.SourceSyncInfo", err) + } + out.DeltaTableSyncInfo = conv42 + } + } + return out, nil +} + +// SyncedTableProvisioningStatusToSDK converts the mirror to the sdk-go type. +func SyncedTableProvisioningStatusToSDK(w *SyncedTableProvisioningStatus) (*sdk.SyncedTableProvisioningStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTableProvisioningStatus{} + conv43, err := SyncedTablePipelineProgressToSDK(w.InitialPipelineSyncProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableProvisioningStatus.InitialPipelineSyncProgress", err) + } + out.InitialPipelineSyncProgress = conv43 + return out, nil +} + +// SyncedTableProvisioningStatusFromSDK converts the sdk-go type to the mirror. +func SyncedTableProvisioningStatusFromSDK(v *sdk.SyncedTableProvisioningStatus) (*SyncedTableProvisioningStatus, error) { + if v == nil { + return nil, nil + } + out := &SyncedTableProvisioningStatus{} + conv44, err := SyncedTablePipelineProgressFromSDK(v.InitialPipelineSyncProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableProvisioningStatus.InitialPipelineSyncProgress", err) + } + out.InitialPipelineSyncProgress = conv44 + return out, nil +} + +// SyncedTableSpecToSDK converts the mirror to the sdk-go type. +func SyncedTableSpecToSDK(w *SyncedTableSpec) (*sdk.SyncedTableSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTableSpec{} + out.SchedulingPolicy = w.SchedulingPolicy + out.SourceTableFullName = w.SourceTableFullName + out.PrimaryKeyColumns = w.PrimaryKeyColumns + out.TimeseriesKey = w.TimeseriesKey + out.ExistingPipelineId = w.ExistingPipelineId + out.CreateDatabaseObjectsIfMissing = w.CreateDatabaseObjectsIfMissing + conv45, err := NewPipelineSpecToSDK(w.NewPipelineSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableSpec.NewPipelineSpec", err) + } + out.NewPipelineSpec = conv45 + out.AcceleratedSync = w.AcceleratedSync + conv46, err := convertSlice(w.TypeOverrides, SyncedTableSpec_TypeOverrideToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableSpec.TypeOverrides", err) + } + out.TypeOverrides = conv46 + return out, nil +} + +// SyncedTableSpecFromSDK converts the sdk-go type to the mirror. +func SyncedTableSpecFromSDK(v *sdk.SyncedTableSpec) (*SyncedTableSpec, error) { + if v == nil { + return nil, nil + } + out := &SyncedTableSpec{} + out.SchedulingPolicy = v.SchedulingPolicy + out.SourceTableFullName = v.SourceTableFullName + out.PrimaryKeyColumns = v.PrimaryKeyColumns + out.TimeseriesKey = v.TimeseriesKey + out.ExistingPipelineId = v.ExistingPipelineId + out.CreateDatabaseObjectsIfMissing = v.CreateDatabaseObjectsIfMissing + conv47, err := NewPipelineSpecFromSDK(v.NewPipelineSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableSpec.NewPipelineSpec", err) + } + out.NewPipelineSpec = conv47 + out.AcceleratedSync = v.AcceleratedSync + conv48, err := convertSlice(v.TypeOverrides, SyncedTableSpec_TypeOverrideFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableSpec.TypeOverrides", err) + } + out.TypeOverrides = conv48 + return out, nil +} + +// SyncedTableSpec_TypeOverrideToSDK converts the mirror to the sdk-go type. +func SyncedTableSpec_TypeOverrideToSDK(w *SyncedTableSpec_TypeOverride) (*sdk.SyncedTableSpec_TypeOverride, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTableSpec_TypeOverride{} + out.ColumnName = w.ColumnName + out.PgType = w.PgType + out.Size = w.Size + return out, nil +} + +// SyncedTableSpec_TypeOverrideFromSDK converts the sdk-go type to the mirror. +func SyncedTableSpec_TypeOverrideFromSDK(v *sdk.SyncedTableSpec_TypeOverride) (*SyncedTableSpec_TypeOverride, error) { + if v == nil { + return nil, nil + } + out := &SyncedTableSpec_TypeOverride{} + out.ColumnName = v.ColumnName + out.PgType = v.PgType + out.Size = v.Size + return out, nil +} + +// SyncedTableStatusToSDK converts the mirror to the sdk-go type. +func SyncedTableStatusToSDK(w *SyncedTableStatus) (*sdk.SyncedTableStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTableStatus{} + out.DetailedState = w.DetailedState + out.Message = w.Message + { + var members []string + if w.ProvisioningStatus != nil { + members = append(members, "provisioning_status") + } + if w.ContinuousUpdateStatus != nil { + members = append(members, "continuous_update_status") + } + if w.TriggeredUpdateStatus != nil { + members = append(members, "triggered_update_status") + } + if w.FailedStatus != nil { + members = append(members, "failed_status") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ProvisioningStatus != nil: + conv49, err := SyncedTableProvisioningStatusToSDK(w.ProvisioningStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableStatus.DetailedStatus", err) + } + out.DetailedStatus = &sdk.SyncedTableStatus_DetailedStatus_ProvisioningStatus{ProvisioningStatus: *conv49} + case w.ContinuousUpdateStatus != nil: + conv50, err := SyncedTableContinuousUpdateStatusToSDK(w.ContinuousUpdateStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableStatus.DetailedStatus", err) + } + out.DetailedStatus = &sdk.SyncedTableStatus_DetailedStatus_ContinuousUpdateStatus{ContinuousUpdateStatus: *conv50} + case w.TriggeredUpdateStatus != nil: + conv51, err := SyncedTableTriggeredUpdateStatusToSDK(w.TriggeredUpdateStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableStatus.DetailedStatus", err) + } + out.DetailedStatus = &sdk.SyncedTableStatus_DetailedStatus_TriggeredUpdateStatus{TriggeredUpdateStatus: *conv51} + case w.FailedStatus != nil: + conv52, err := SyncedTableFailedStatusToSDK(w.FailedStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableStatus.DetailedStatus", err) + } + out.DetailedStatus = &sdk.SyncedTableStatus_DetailedStatus_FailedStatus{FailedStatus: *conv52} + } + out.PipelineId = w.PipelineId + conv53, err := SyncedTablePositionToSDK(w.LastSync) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableStatus.LastSync", err) + } + out.LastSync = conv53 + return out, nil +} + +// SyncedTableStatusFromSDK converts the sdk-go type to the mirror. +func SyncedTableStatusFromSDK(v *sdk.SyncedTableStatus) (*SyncedTableStatus, error) { + if v == nil { + return nil, nil + } + out := &SyncedTableStatus{} + out.DetailedState = v.DetailedState + out.Message = v.Message + switch value := v.DetailedStatus.(type) { + case *sdk.SyncedTableStatus_DetailedStatus_ProvisioningStatus: + if value != nil { + conv54, err := SyncedTableProvisioningStatusFromSDK(&value.ProvisioningStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableStatus.DetailedStatus", err) + } + out.ProvisioningStatus = conv54 + } + case *sdk.SyncedTableStatus_DetailedStatus_ContinuousUpdateStatus: + if value != nil { + conv55, err := SyncedTableContinuousUpdateStatusFromSDK(&value.ContinuousUpdateStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableStatus.DetailedStatus", err) + } + out.ContinuousUpdateStatus = conv55 + } + case *sdk.SyncedTableStatus_DetailedStatus_TriggeredUpdateStatus: + if value != nil { + conv56, err := SyncedTableTriggeredUpdateStatusFromSDK(&value.TriggeredUpdateStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableStatus.DetailedStatus", err) + } + out.TriggeredUpdateStatus = conv56 + } + case *sdk.SyncedTableStatus_DetailedStatus_FailedStatus: + if value != nil { + conv57, err := SyncedTableFailedStatusFromSDK(&value.FailedStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableStatus.DetailedStatus", err) + } + out.FailedStatus = conv57 + } + } + out.PipelineId = v.PipelineId + conv58, err := SyncedTablePositionFromSDK(v.LastSync) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableStatus.LastSync", err) + } + out.LastSync = conv58 + return out, nil +} + +// SyncedTableTriggeredUpdateStatusToSDK converts the mirror to the sdk-go type. +func SyncedTableTriggeredUpdateStatusToSDK(w *SyncedTableTriggeredUpdateStatus) (*sdk.SyncedTableTriggeredUpdateStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTableTriggeredUpdateStatus{} + out.LastProcessedCommitVersion = w.LastProcessedCommitVersion + out.Timestamp = w.Timestamp + conv59, err := SyncedTablePipelineProgressToSDK(w.TriggeredUpdateProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableTriggeredUpdateStatus.TriggeredUpdateProgress", err) + } + out.TriggeredUpdateProgress = conv59 + return out, nil +} + +// SyncedTableTriggeredUpdateStatusFromSDK converts the sdk-go type to the mirror. +func SyncedTableTriggeredUpdateStatusFromSDK(v *sdk.SyncedTableTriggeredUpdateStatus) (*SyncedTableTriggeredUpdateStatus, error) { + if v == nil { + return nil, nil + } + out := &SyncedTableTriggeredUpdateStatus{} + out.LastProcessedCommitVersion = v.LastProcessedCommitVersion + out.Timestamp = v.Timestamp + conv60, err := SyncedTablePipelineProgressFromSDK(v.TriggeredUpdateProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTableTriggeredUpdateStatus.TriggeredUpdateProgress", err) + } + out.TriggeredUpdateProgress = conv60 + return out, nil +} + +// UpdateDatabaseCatalogRequestToSDK converts the mirror to the sdk-go type. +func UpdateDatabaseCatalogRequestToSDK(w *UpdateDatabaseCatalogRequest) (*sdk.UpdateDatabaseCatalogRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateDatabaseCatalogRequest{} + conv61, err := DatabaseCatalogToSDK(w.DatabaseCatalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDatabaseCatalogRequest.DatabaseCatalog", err) + } + out.DatabaseCatalog = conv61 + mask62, err := fieldMaskFromString[sdk.DatabaseCatalog](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDatabaseCatalogRequest.UpdateMask", err) + } + out.UpdateMask = mask62 + return out, nil +} + +// UpdateDatabaseCatalogRequestFromSDK converts the sdk-go type to the mirror. +func UpdateDatabaseCatalogRequestFromSDK(v *sdk.UpdateDatabaseCatalogRequest) (*UpdateDatabaseCatalogRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateDatabaseCatalogRequest{} + conv63, err := DatabaseCatalogFromSDK(v.DatabaseCatalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDatabaseCatalogRequest.DatabaseCatalog", err) + } + out.DatabaseCatalog = conv63 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateDatabaseInstanceRequestToSDK converts the mirror to the sdk-go type. +func UpdateDatabaseInstanceRequestToSDK(w *UpdateDatabaseInstanceRequest) (*sdk.UpdateDatabaseInstanceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateDatabaseInstanceRequest{} + conv64, err := DatabaseInstanceToSDK(w.DatabaseInstance) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDatabaseInstanceRequest.DatabaseInstance", err) + } + out.DatabaseInstance = conv64 + mask65, err := fieldMaskFromString[sdk.DatabaseInstance](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDatabaseInstanceRequest.UpdateMask", err) + } + out.UpdateMask = mask65 + return out, nil +} + +// UpdateDatabaseInstanceRequestFromSDK converts the sdk-go type to the mirror. +func UpdateDatabaseInstanceRequestFromSDK(v *sdk.UpdateDatabaseInstanceRequest) (*UpdateDatabaseInstanceRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateDatabaseInstanceRequest{} + conv66, err := DatabaseInstanceFromSDK(v.DatabaseInstance) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDatabaseInstanceRequest.DatabaseInstance", err) + } + out.DatabaseInstance = conv66 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateSyncedDatabaseTableRequestToSDK converts the mirror to the sdk-go type. +func UpdateSyncedDatabaseTableRequestToSDK(w *UpdateSyncedDatabaseTableRequest) (*sdk.UpdateSyncedDatabaseTableRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateSyncedDatabaseTableRequest{} + conv67, err := SyncedDatabaseTableToSDK(w.SyncedTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSyncedDatabaseTableRequest.SyncedTable", err) + } + out.SyncedTable = conv67 + mask68, err := fieldMaskFromString[sdk.SyncedDatabaseTable](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSyncedDatabaseTableRequest.UpdateMask", err) + } + out.UpdateMask = mask68 + return out, nil +} + +// UpdateSyncedDatabaseTableRequestFromSDK converts the sdk-go type to the mirror. +func UpdateSyncedDatabaseTableRequestFromSDK(v *sdk.UpdateSyncedDatabaseTableRequest) (*UpdateSyncedDatabaseTableRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateSyncedDatabaseTableRequest{} + conv69, err := SyncedDatabaseTableFromSDK(v.SyncedTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSyncedDatabaseTableRequest.SyncedTable", err) + } + out.SyncedTable = conv69 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/dataclassification/v1/types.generated.go b/libs/sdktypes/dataclassification/v1/types.generated.go new file mode 100644 index 00000000000..c23c6819c55 --- /dev/null +++ b/libs/sdktypes/dataclassification/v1/types.generated.go @@ -0,0 +1,287 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/dataclassification/v1. DO NOT EDIT. + +package dataclassification + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/dataclassification/v1" + strings "strings" +) + +type ( + AutoTaggingConfig_AutoTaggingMode = sdk.AutoTaggingConfig_AutoTaggingMode +) + +const ( + AutoTaggingConfig_AutoTaggingMode_Unspecified = sdk.AutoTaggingConfig_AutoTaggingMode_Unspecified + AutoTaggingConfig_AutoTaggingMode_AutoTaggingDisabled = sdk.AutoTaggingConfig_AutoTaggingMode_AutoTaggingDisabled + AutoTaggingConfig_AutoTaggingMode_AutoTaggingEnabled = sdk.AutoTaggingConfig_AutoTaggingMode_AutoTaggingEnabled +) + +// Auto-tagging configuration for a classification tag. When enabled, detected +// columns are automatically tagged with Unity Catalog tags.. +type AutoTaggingConfig struct { + // Whether auto-tagging is enabled or disabled for this classification tag. + AutoTaggingMode AutoTaggingConfig_AutoTaggingMode `json:"auto_tagging_mode,omitempty"` + // The Classification Tag. For built-in classes this is a system tag (e.g., + // "class.name", "class.location"); for custom classes it is a user-defined + // governance tag key. + ClassificationTag *string `json:"classification_tag,omitempty"` +} + +// Data Classification configuration for a Unity Catalog catalog. This message +// follows the "At Most One Resource" pattern: at most one CatalogConfig exists +// per catalog. - Full CRUD operations are supported: Create enables Data +// Classification, Delete disables it - It has no unique identifier of its own +// and uses its parent catalog's identifier (catalog_name). +type CatalogConfig struct { + // List of auto-tagging configurations for this catalog. Empty list means no + // auto-tagging is enabled. + AutoTagConfigs []AutoTaggingConfig `json:"auto_tag_configs,omitempty"` + ExcludedSchemas *CatalogConfig_SchemaNames `json:"excluded_schemas,omitempty"` + IncludedSchemas *CatalogConfig_SchemaNames `json:"included_schemas,omitempty"` + // Resource name in the format: catalogs/{catalog_name}/config. + Name *string `json:"name,omitempty"` +} + +// Wrapper message for a list of schema names.. +type CatalogConfig_SchemaNames struct { + // Schema names, each relative to the parent catalog. Must not be empty. + Names []string `json:"names,omitempty"` +} + +// Create Data Classification configuration for a catalog. Creating a config +// enables Data Classification for the catalog.. +type CreateCatalogConfigRequest struct { + // The configuration to create. + CatalogConfig *CatalogConfig `json:"catalog_config,omitempty"` + // Parent resource in the format: catalogs/{catalog_name} + Parent *string `json:"parent,omitempty"` +} + +// Request to update the Data Classification configuration for a catalog. +// +// Uses field mask to support partial updates of the configuration. Only the +// fields specified in the update_mask will be modified.. +type UpdateCatalogConfigRequest struct { + // The configuration to apply to the catalog. The name field in catalog_config + // identifies which resource to update. + CatalogConfig *CatalogConfig `json:"catalog_config,omitempty"` + // Field mask specifying which fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// AutoTaggingConfigToSDK converts the mirror to the sdk-go type. +func AutoTaggingConfigToSDK(w *AutoTaggingConfig) (*sdk.AutoTaggingConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.AutoTaggingConfig{} + out.ClassificationTag = w.ClassificationTag + out.AutoTaggingMode = w.AutoTaggingMode + return out, nil +} + +// AutoTaggingConfigFromSDK converts the sdk-go type to the mirror. +func AutoTaggingConfigFromSDK(v *sdk.AutoTaggingConfig) (*AutoTaggingConfig, error) { + if v == nil { + return nil, nil + } + out := &AutoTaggingConfig{} + out.ClassificationTag = v.ClassificationTag + out.AutoTaggingMode = v.AutoTaggingMode + return out, nil +} + +// CatalogConfigToSDK converts the mirror to the sdk-go type. +func CatalogConfigToSDK(w *CatalogConfig) (*sdk.CatalogConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.CatalogConfig{} + out.Name = w.Name + { + var members []string + if w.IncludedSchemas != nil { + members = append(members, "included_schemas") + } + if w.ExcludedSchemas != nil { + members = append(members, "excluded_schemas") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.IncludedSchemas != nil: + conv1, err := CatalogConfig_SchemaNamesToSDK(w.IncludedSchemas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CatalogConfig.SelectedSchemas", err) + } + out.SelectedSchemas = &sdk.CatalogConfig_SelectedSchemas_IncludedSchemas{IncludedSchemas: *conv1} + case w.ExcludedSchemas != nil: + conv2, err := CatalogConfig_SchemaNamesToSDK(w.ExcludedSchemas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CatalogConfig.SelectedSchemas", err) + } + out.SelectedSchemas = &sdk.CatalogConfig_SelectedSchemas_ExcludedSchemas{ExcludedSchemas: *conv2} + } + conv3, err := convertSlice(w.AutoTagConfigs, AutoTaggingConfigToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CatalogConfig.AutoTagConfigs", err) + } + out.AutoTagConfigs = conv3 + return out, nil +} + +// CatalogConfigFromSDK converts the sdk-go type to the mirror. +func CatalogConfigFromSDK(v *sdk.CatalogConfig) (*CatalogConfig, error) { + if v == nil { + return nil, nil + } + out := &CatalogConfig{} + out.Name = v.Name + switch value := v.SelectedSchemas.(type) { + case *sdk.CatalogConfig_SelectedSchemas_IncludedSchemas: + if value != nil { + conv4, err := CatalogConfig_SchemaNamesFromSDK(&value.IncludedSchemas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CatalogConfig.SelectedSchemas", err) + } + out.IncludedSchemas = conv4 + } + case *sdk.CatalogConfig_SelectedSchemas_ExcludedSchemas: + if value != nil { + conv5, err := CatalogConfig_SchemaNamesFromSDK(&value.ExcludedSchemas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CatalogConfig.SelectedSchemas", err) + } + out.ExcludedSchemas = conv5 + } + } + conv6, err := convertSlice(v.AutoTagConfigs, AutoTaggingConfigFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CatalogConfig.AutoTagConfigs", err) + } + out.AutoTagConfigs = conv6 + return out, nil +} + +// CatalogConfig_SchemaNamesToSDK converts the mirror to the sdk-go type. +func CatalogConfig_SchemaNamesToSDK(w *CatalogConfig_SchemaNames) (*sdk.CatalogConfig_SchemaNames, error) { + if w == nil { + return nil, nil + } + out := &sdk.CatalogConfig_SchemaNames{} + out.Names = w.Names + return out, nil +} + +// CatalogConfig_SchemaNamesFromSDK converts the sdk-go type to the mirror. +func CatalogConfig_SchemaNamesFromSDK(v *sdk.CatalogConfig_SchemaNames) (*CatalogConfig_SchemaNames, error) { + if v == nil { + return nil, nil + } + out := &CatalogConfig_SchemaNames{} + out.Names = v.Names + return out, nil +} + +// CreateCatalogConfigRequestToSDK converts the mirror to the sdk-go type. +func CreateCatalogConfigRequestToSDK(w *CreateCatalogConfigRequest) (*sdk.CreateCatalogConfigRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCatalogConfigRequest{} + out.Parent = w.Parent + conv7, err := CatalogConfigToSDK(w.CatalogConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCatalogConfigRequest.CatalogConfig", err) + } + out.CatalogConfig = conv7 + return out, nil +} + +// CreateCatalogConfigRequestFromSDK converts the sdk-go type to the mirror. +func CreateCatalogConfigRequestFromSDK(v *sdk.CreateCatalogConfigRequest) (*CreateCatalogConfigRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCatalogConfigRequest{} + out.Parent = v.Parent + conv8, err := CatalogConfigFromSDK(v.CatalogConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCatalogConfigRequest.CatalogConfig", err) + } + out.CatalogConfig = conv8 + return out, nil +} + +// UpdateCatalogConfigRequestToSDK converts the mirror to the sdk-go type. +func UpdateCatalogConfigRequestToSDK(w *UpdateCatalogConfigRequest) (*sdk.UpdateCatalogConfigRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCatalogConfigRequest{} + conv9, err := CatalogConfigToSDK(w.CatalogConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCatalogConfigRequest.CatalogConfig", err) + } + out.CatalogConfig = conv9 + mask10, err := fieldMaskFromString[sdk.CatalogConfig](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCatalogConfigRequest.UpdateMask", err) + } + out.UpdateMask = mask10 + return out, nil +} + +// UpdateCatalogConfigRequestFromSDK converts the sdk-go type to the mirror. +func UpdateCatalogConfigRequestFromSDK(v *sdk.UpdateCatalogConfigRequest) (*UpdateCatalogConfigRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateCatalogConfigRequest{} + conv11, err := CatalogConfigFromSDK(v.CatalogConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCatalogConfigRequest.CatalogConfig", err) + } + out.CatalogConfig = conv11 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/dataquality/v1/types.generated.go b/libs/sdktypes/dataquality/v1/types.generated.go new file mode 100644 index 00000000000..6866bb1c682 --- /dev/null +++ b/libs/sdktypes/dataquality/v1/types.generated.go @@ -0,0 +1,1138 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/dataquality/v1. DO NOT EDIT. + +package dataquality + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/dataquality/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + AggregationGranularity = sdk.AggregationGranularity + CronSchedulePauseStatus = sdk.CronSchedulePauseStatus + DataProfilingCustomMetricType = sdk.DataProfilingCustomMetricType + DataProfilingStatus = sdk.DataProfilingStatus + InferenceProblemType = sdk.InferenceProblemType + RefreshState = sdk.RefreshState + RefreshTrigger = sdk.RefreshTrigger +) + +const ( + AggregationGranularity_Unspecified = sdk.AggregationGranularity_Unspecified + AggregationGranularity_AggregationGranularity5Minutes = sdk.AggregationGranularity_AggregationGranularity5Minutes + AggregationGranularity_AggregationGranularity30Minutes = sdk.AggregationGranularity_AggregationGranularity30Minutes + AggregationGranularity_AggregationGranularity1Hour = sdk.AggregationGranularity_AggregationGranularity1Hour + AggregationGranularity_AggregationGranularity1Day = sdk.AggregationGranularity_AggregationGranularity1Day + AggregationGranularity_AggregationGranularity1Week = sdk.AggregationGranularity_AggregationGranularity1Week + AggregationGranularity_AggregationGranularity2Weeks = sdk.AggregationGranularity_AggregationGranularity2Weeks + AggregationGranularity_AggregationGranularity3Weeks = sdk.AggregationGranularity_AggregationGranularity3Weeks + AggregationGranularity_AggregationGranularity4Weeks = sdk.AggregationGranularity_AggregationGranularity4Weeks + AggregationGranularity_AggregationGranularity1Month = sdk.AggregationGranularity_AggregationGranularity1Month + AggregationGranularity_AggregationGranularity1Year = sdk.AggregationGranularity_AggregationGranularity1Year + CronSchedulePauseStatus_Unspecified = sdk.CronSchedulePauseStatus_Unspecified + CronSchedulePauseStatus_CronSchedulePauseStatusUnpaused = sdk.CronSchedulePauseStatus_CronSchedulePauseStatusUnpaused + CronSchedulePauseStatus_CronSchedulePauseStatusPaused = sdk.CronSchedulePauseStatus_CronSchedulePauseStatusPaused + DataProfilingCustomMetricType_Unspecified = sdk.DataProfilingCustomMetricType_Unspecified + DataProfilingCustomMetricType_DataProfilingCustomMetricTypeAggregate = sdk.DataProfilingCustomMetricType_DataProfilingCustomMetricTypeAggregate + DataProfilingCustomMetricType_DataProfilingCustomMetricTypeDerived = sdk.DataProfilingCustomMetricType_DataProfilingCustomMetricTypeDerived + DataProfilingCustomMetricType_DataProfilingCustomMetricTypeDrift = sdk.DataProfilingCustomMetricType_DataProfilingCustomMetricTypeDrift + DataProfilingStatus_Unspecified = sdk.DataProfilingStatus_Unspecified + DataProfilingStatus_DataProfilingStatusActive = sdk.DataProfilingStatus_DataProfilingStatusActive + DataProfilingStatus_DataProfilingStatusPending = sdk.DataProfilingStatus_DataProfilingStatusPending + DataProfilingStatus_DataProfilingStatusDeletePending = sdk.DataProfilingStatus_DataProfilingStatusDeletePending + DataProfilingStatus_DataProfilingStatusError = sdk.DataProfilingStatus_DataProfilingStatusError + DataProfilingStatus_DataProfilingStatusFailed = sdk.DataProfilingStatus_DataProfilingStatusFailed + InferenceProblemType_Unspecified = sdk.InferenceProblemType_Unspecified + InferenceProblemType_InferenceProblemTypeClassification = sdk.InferenceProblemType_InferenceProblemTypeClassification + InferenceProblemType_InferenceProblemTypeRegression = sdk.InferenceProblemType_InferenceProblemTypeRegression + RefreshState_Unspecified = sdk.RefreshState_Unspecified + RefreshState_MonitorRefreshStatePending = sdk.RefreshState_MonitorRefreshStatePending + RefreshState_MonitorRefreshStateRunning = sdk.RefreshState_MonitorRefreshStateRunning + RefreshState_MonitorRefreshStateSuccess = sdk.RefreshState_MonitorRefreshStateSuccess + RefreshState_MonitorRefreshStateFailed = sdk.RefreshState_MonitorRefreshStateFailed + RefreshState_MonitorRefreshStateCanceled = sdk.RefreshState_MonitorRefreshStateCanceled + RefreshTrigger_Unspecified = sdk.RefreshTrigger_Unspecified + RefreshTrigger_MonitorRefreshTriggerManual = sdk.RefreshTrigger_MonitorRefreshTriggerManual + RefreshTrigger_MonitorRefreshTriggerSchedule = sdk.RefreshTrigger_MonitorRefreshTriggerSchedule + RefreshTrigger_MonitorRefreshTriggerDataChange = sdk.RefreshTrigger_MonitorRefreshTriggerDataChange +) + +// Anomaly Detection Configurations.. +type AnomalyDetectionConfig struct { + // List of fully qualified table names to exclude from anomaly detection. + ExcludedTableFullNames []string `json:"excluded_table_full_names,omitempty"` +} + +// Request to cancel a refresh.. +type CancelRefreshRequest struct { + // The UUID of the request object. It is `schema_id` for `schema`, and + // `table_id` for `table`. + // + // Find the `schema_id` from either: 1. The [schema_id] of the `Schemas` + // resource. 2. In [Catalog Explorer] > select the `schema` > go to the + // `Details` tab > the `Schema ID` field. + // + // Find the `table_id` from either: 1. The [table_id] of the `Tables` resource. + // 2. In [Catalog Explorer] > select the `table` > go to the `Details` tab > the + // `Table ID` field. + // + // [Catalog Explorer]: https://docs.databricks.com/aws/en/catalog-explorer/ + // [schema_id]: https://docs.databricks.com/api/workspace/schemas/get#schema_id + // [table_id]: https://docs.databricks.com/api/workspace/tables/get#table_id + ObjectId *string `json:"object_id,omitempty"` + // The type of the monitored object. Can be one of the following: `schema` or + // `table`. + ObjectType *string `json:"object_type,omitempty"` + // Unique id of the refresh operation. + RefreshId *int64 `json:"refresh_id,omitempty"` +} + +// Response to cancelling a refresh.. +type CancelRefreshResponse struct { + // The refresh to cancel. + Refresh *Refresh `json:"refresh,omitempty"` +} + +// Request to create a Monitor.. +type CreateMonitorRequest struct { + // The monitor to create. + Monitor *Monitor `json:"monitor,omitempty"` +} + +// Request to create a refresh.. +type CreateRefreshRequest struct { + // The refresh to create + Refresh *Refresh `json:"refresh,omitempty"` +} + +// The data quality monitoring workflow cron schedule.. +type CronSchedule struct { + // Read only field that indicates whether the schedule is paused or not. + PauseStatus CronSchedulePauseStatus `json:"pause_status,omitempty"` + // The expression that determines when to run the monitor. See [examples]. + // + // [examples]: https://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html + QuartzCronExpression *string `json:"quartz_cron_expression,omitempty"` + // A Java timezone id. The schedule for a job will be resolved with respect to + // this timezone. See `Java TimeZone + // `_ for + // details. The timezone id (e.g., ``America/Los_Angeles``) in which to evaluate + // the quartz expression. + TimezoneId *string `json:"timezone_id,omitempty"` +} + +// Data Profiling Configurations.. +type DataProfilingConfig struct { + // Field for specifying the absolute path to a custom directory to store + // data-monitoring assets. Normally prepopulated to a default user location via + // UI and Python APIs. + AssetsDir *string `json:"assets_dir,omitempty"` + // Baseline table name. Baseline data is used to compute drift from the data in + // the monitored `table_name`. The baseline table and the monitored table shall + // have the same schema. + BaselineTableName *string `json:"baseline_table_name,omitempty"` + // Custom metrics. + CustomMetrics []DataProfilingCustomMetric `json:"custom_metrics,omitempty"` + // Id of dashboard that visualizes the computed metrics. This can be empty if + // the monitor is in PENDING state. + DashboardId *string `json:"dashboard_id,omitempty"` + // Table that stores drift metrics data. Format: `catalog.schema.table_name`. + DriftMetricsTableName *string `json:"drift_metrics_table_name,omitempty"` + // The warehouse for dashboard creation + EffectiveWarehouseId *string `json:"effective_warehouse_id,omitempty"` + InferenceLog *InferenceLogConfig `json:"inference_log,omitempty"` + // The latest error message for a monitor failure. + LatestMonitorFailureMessage *string `json:"latest_monitor_failure_message,omitempty"` + // Represents the current monitor configuration version in use. The version will + // be represented in a numeric fashion (1,2,3...). The field has flexibility to + // take on negative values, which can indicate corrupted monitor_version + // numbers. + MonitorVersion *int64 `json:"monitor_version,omitempty"` + // Unity Catalog table to monitor. Format: `catalog.schema.table_name` + MonitoredTableName *string `json:"monitored_table_name,omitempty"` + // Field for specifying notification settings. + NotificationSettings *NotificationSettings `json:"notification_settings,omitempty"` + // ID of the schema where output tables are created. + OutputSchemaId *string `json:"output_schema_id,omitempty"` + // Table that stores profile metrics data. Format: `catalog.schema.table_name`. + ProfileMetricsTableName *string `json:"profile_metrics_table_name,omitempty"` + // The cron schedule. + Schedule *CronSchedule `json:"schedule,omitempty"` + // Whether to skip creating a default dashboard summarizing data quality + // metrics. + SkipBuiltinDashboard *bool `json:"skip_builtin_dashboard,omitempty"` + // List of column expressions to slice data with for targeted analysis. The data + // is grouped by each expression independently, resulting in a separate slice + // for each predicate and its complements. For example + // `slicing_exprs=[“col_1”, “col_2 > 10”]` will generate the following + // slices: two slices for `col_2 > 10` (True and False), and one slice per + // unique value in `col1`. For high-cardinality columns, only the top 100 unique + // values by frequency will generate slices. + SlicingExprs []string `json:"slicing_exprs,omitempty"` + Snapshot *SnapshotConfig `json:"snapshot,omitempty"` + // The data profiling monitor status. + Status DataProfilingStatus `json:"status,omitempty"` + TimeSeries *TimeSeriesConfig `json:"time_series,omitempty"` + // Optional argument to specify the warehouse for dashboard creation. If not + // specified, the first running warehouse will be used. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +// Custom metric definition.. +type DataProfilingCustomMetric struct { + // Jinja template for a SQL expression that specifies how to compute the metric. + // See [create metric definition]. + // + // [create metric definition]: https://docs.databricks.com/en/lakehouse-monitoring/custom-metrics.html#create-definition + Definition *string `json:"definition,omitempty"` + // A list of column names in the input table the metric should be computed for. + // Can use ``":table"`` to indicate that the metric needs information from + // multiple columns. + InputColumns []string `json:"input_columns,omitempty"` + // Name of the metric in the output tables. + Name *string `json:"name,omitempty"` + // The output type of the custom metric. + OutputDataType *string `json:"output_data_type,omitempty"` + // The type of the custom metric. + Type DataProfilingCustomMetricType `json:"type,omitempty"` +} + +// Inference log configuration.. +type InferenceLogConfig struct { + // List of granularities to use when aggregating data into time windows based on + // their timestamp. + Granularities []AggregationGranularity `json:"granularities,omitempty"` + // Column for the label. + LabelColumn *string `json:"label_column,omitempty"` + // Column for the model identifier. + ModelIdColumn *string `json:"model_id_column,omitempty"` + // Column for the prediction. + PredictionColumn *string `json:"prediction_column,omitempty"` + // Problem type the model aims to solve. + ProblemType InferenceProblemType `json:"problem_type,omitempty"` + // Column for the timestamp. + TimestampColumn *string `json:"timestamp_column,omitempty"` +} + +// Request to list Monitors.. +type ListMonitorRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +// Response for listing Monitors.. +type ListMonitorResponse struct { + Monitors []Monitor `json:"monitors,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to list refreshes.. +type ListRefreshRequest struct { + // The UUID of the request object. It is `schema_id` for `schema`, and + // `table_id` for `table`. + // + // Find the `schema_id` from either: 1. The [schema_id] of the `Schemas` + // resource. 2. In [Catalog Explorer] > select the `schema` > go to the + // `Details` tab > the `Schema ID` field. + // + // Find the `table_id` from either: 1. The [table_id] of the `Tables` resource. + // 2. In [Catalog Explorer] > select the `table` > go to the `Details` tab > the + // `Table ID` field. + // + // [Catalog Explorer]: https://docs.databricks.com/aws/en/catalog-explorer/ + // [schema_id]: https://docs.databricks.com/api/workspace/schemas/get#schema_id + // [table_id]: https://docs.databricks.com/api/workspace/tables/get#table_id + ObjectId *string `json:"object_id,omitempty"` + // The type of the monitored object. Can be one of the following: `schema` or + // `table`. + ObjectType *string `json:"object_type,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +// Response for listing refreshes.. +type ListRefreshResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + Refreshes []Refresh `json:"refreshes,omitempty"` +} + +// Monitor for the data quality of unity catalog entities such as schema or +// table.. +type Monitor struct { + // Anomaly Detection Configuration, applicable to `schema` object types. + AnomalyDetectionConfig *AnomalyDetectionConfig `json:"anomaly_detection_config,omitempty"` + // Data Profiling Configuration, applicable to `table` object types. Exactly one + // `Analysis Configuration` must be present. + DataProfilingConfig *DataProfilingConfig `json:"data_profiling_config,omitempty"` + // The UUID of the request object. It is `schema_id` for `schema`, and + // `table_id` for `table`. + // + // Find the `schema_id` from either: 1. The [schema_id] of the `Schemas` + // resource. 2. In [Catalog Explorer] > select the `schema` > go to the + // `Details` tab > the `Schema ID` field. + // + // Find the `table_id` from either: 1. The [table_id] of the `Tables` resource. + // 2. In [Catalog Explorer] > select the `table` > go to the `Details` tab > the + // `Table ID` field. + // + // [Catalog Explorer]: https://docs.databricks.com/aws/en/catalog-explorer/ + // [schema_id]: https://docs.databricks.com/api/workspace/schemas/get#schema_id + // [table_id]: https://docs.databricks.com/api/workspace/tables/get#table_id + ObjectId *string `json:"object_id,omitempty"` + // The type of the monitored object. Can be one of the following: `schema` or + // `table`. + ObjectType *string `json:"object_type,omitempty"` +} + +// Destination of the data quality monitoring notification.. +type NotificationDestination struct { + // The list of email addresses to send the notification to. A maximum of 5 email + // addresses is supported. + EmailAddresses []string `json:"email_addresses,omitempty"` +} + +// Settings for sending notifications on the data quality monitoring.. +type NotificationSettings struct { + // Destinations to send notifications on failure/timeout. + OnFailure *NotificationDestination `json:"on_failure,omitempty"` +} + +// The Refresh object gives information on a refresh of the data quality +// monitoring pipeline.. +type Refresh struct { + // Time when the refresh ended (milliseconds since 1/1/1970 UTC). + EndTimeMs *int64 `json:"end_time_ms,omitempty"` + // An optional message to give insight into the current state of the refresh + // (e.g. FAILURE messages). + Message *string `json:"message,omitempty"` + // The UUID of the request object. It is `schema_id` for `schema`, and + // `table_id` for `table`. + // + // Find the `schema_id` from either: 1. The [schema_id] of the `Schemas` + // resource. 2. In [Catalog Explorer] > select the `schema` > go to the + // `Details` tab > the `Schema ID` field. + // + // Find the `table_id` from either: 1. The [table_id] of the `Tables` resource. + // 2. In [Catalog Explorer] > select the `table` > go to the `Details` tab > the + // `Table ID` field. + // + // [Catalog Explorer]: https://docs.databricks.com/aws/en/catalog-explorer/ + // [schema_id]: https://docs.databricks.com/api/workspace/schemas/get#schema_id + // [table_id]: https://docs.databricks.com/api/workspace/tables/get#table_id + ObjectId *string `json:"object_id,omitempty"` + // The type of the monitored object. Can be one of the following: `schema` or + // `table`. + ObjectType *string `json:"object_type,omitempty"` + // Unique id of the refresh operation. + RefreshId *int64 `json:"refresh_id,omitempty"` + // Time when the refresh started (milliseconds since 1/1/1970 UTC). + StartTimeMs *int64 `json:"start_time_ms,omitempty"` + // The current state of the refresh. + State RefreshState `json:"state,omitempty"` + // What triggered the refresh. + Trigger RefreshTrigger `json:"trigger,omitempty"` +} + +// Snapshot analysis configuration.. +type SnapshotConfig struct { +} + +// Time series analysis configuration.. +type TimeSeriesConfig struct { + // List of granularities to use when aggregating data into time windows based on + // their timestamp. + Granularities []AggregationGranularity `json:"granularities,omitempty"` + // Column for the timestamp. + TimestampColumn *string `json:"timestamp_column,omitempty"` +} + +// Request to update a Monitor.. +type UpdateMonitorRequest struct { + // The monitor to update. + Monitor *Monitor `json:"monitor,omitempty"` + // The UUID of the request object. It is `schema_id` for `schema`, and + // `table_id` for `table`. + // + // Find the `schema_id` from either: 1. The [schema_id] of the `Schemas` + // resource. 2. In [Catalog Explorer] > select the `schema` > go to the + // `Details` tab > the `Schema ID` field. + // + // Find the `table_id` from either: 1. The [table_id] of the `Tables` resource. + // 2. In [Catalog Explorer] > select the `table` > go to the `Details` tab > the + // `Table ID` field. + // + // [Catalog Explorer]: https://docs.databricks.com/aws/en/catalog-explorer/ + // [schema_id]: https://docs.databricks.com/api/workspace/schemas/get#schema_id + // [table_id]: https://docs.databricks.com/api/workspace/tables/get#table_id + ObjectId *string `json:"object_id,omitempty"` + // The type of the monitored object. Can be one of the following: `schema` or + // `table`. + ObjectType *string `json:"object_type,omitempty"` + // The field mask to specify which fields to update as a comma-separated list. + // Example value: + // `data_profiling_config.custom_metrics,data_profiling_config.schedule.quartz_cron_expression` + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Request to update a refresh.. +type UpdateRefreshRequest struct { + // The UUID of the request object. It is `schema_id` for `schema`, and + // `table_id` for `table`. + // + // Find the `schema_id` from either: 1. The [schema_id] of the `Schemas` + // resource. 2. In [Catalog Explorer] > select the `schema` > go to the + // `Details` tab > the `Schema ID` field. + // + // Find the `table_id` from either: 1. The [table_id] of the `Tables` resource. + // 2. In [Catalog Explorer] > select the `table` > go to the `Details` tab > the + // `Table ID` field. + // + // [Catalog Explorer]: https://docs.databricks.com/aws/en/catalog-explorer/ + // [schema_id]: https://docs.databricks.com/api/workspace/schemas/get#schema_id + // [table_id]: https://docs.databricks.com/api/workspace/tables/get#table_id + ObjectId *string `json:"object_id,omitempty"` + // The type of the monitored object. Can be one of the following: `schema` or + // `table`. + ObjectType *string `json:"object_type,omitempty"` + // The refresh to update. + Refresh *Refresh `json:"refresh,omitempty"` + // Unique id of the refresh operation. + RefreshId *int64 `json:"refresh_id,omitempty"` + // The field mask to specify which fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// AnomalyDetectionConfigToSDK converts the mirror to the sdk-go type. +func AnomalyDetectionConfigToSDK(w *AnomalyDetectionConfig) (*sdk.AnomalyDetectionConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.AnomalyDetectionConfig{} + out.ExcludedTableFullNames = w.ExcludedTableFullNames + return out, nil +} + +// AnomalyDetectionConfigFromSDK converts the sdk-go type to the mirror. +func AnomalyDetectionConfigFromSDK(v *sdk.AnomalyDetectionConfig) (*AnomalyDetectionConfig, error) { + if v == nil { + return nil, nil + } + out := &AnomalyDetectionConfig{} + out.ExcludedTableFullNames = v.ExcludedTableFullNames + return out, nil +} + +// CancelRefreshRequestToSDK converts the mirror to the sdk-go type. +func CancelRefreshRequestToSDK(w *CancelRefreshRequest) (*sdk.CancelRefreshRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CancelRefreshRequest{} + out.ObjectType = w.ObjectType + out.ObjectId = w.ObjectId + out.RefreshId = w.RefreshId + return out, nil +} + +// CancelRefreshRequestFromSDK converts the sdk-go type to the mirror. +func CancelRefreshRequestFromSDK(v *sdk.CancelRefreshRequest) (*CancelRefreshRequest, error) { + if v == nil { + return nil, nil + } + out := &CancelRefreshRequest{} + out.ObjectType = v.ObjectType + out.ObjectId = v.ObjectId + out.RefreshId = v.RefreshId + return out, nil +} + +// CancelRefreshResponseToSDK converts the mirror to the sdk-go type. +func CancelRefreshResponseToSDK(w *CancelRefreshResponse) (*sdk.CancelRefreshResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CancelRefreshResponse{} + conv1, err := RefreshToSDK(w.Refresh) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CancelRefreshResponse.Refresh", err) + } + out.Refresh = conv1 + return out, nil +} + +// CancelRefreshResponseFromSDK converts the sdk-go type to the mirror. +func CancelRefreshResponseFromSDK(v *sdk.CancelRefreshResponse) (*CancelRefreshResponse, error) { + if v == nil { + return nil, nil + } + out := &CancelRefreshResponse{} + conv2, err := RefreshFromSDK(v.Refresh) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CancelRefreshResponse.Refresh", err) + } + out.Refresh = conv2 + return out, nil +} + +// CreateMonitorRequestToSDK converts the mirror to the sdk-go type. +func CreateMonitorRequestToSDK(w *CreateMonitorRequest) (*sdk.CreateMonitorRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateMonitorRequest{} + conv3, err := MonitorToSDK(w.Monitor) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateMonitorRequest.Monitor", err) + } + out.Monitor = conv3 + return out, nil +} + +// CreateMonitorRequestFromSDK converts the sdk-go type to the mirror. +func CreateMonitorRequestFromSDK(v *sdk.CreateMonitorRequest) (*CreateMonitorRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateMonitorRequest{} + conv4, err := MonitorFromSDK(v.Monitor) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateMonitorRequest.Monitor", err) + } + out.Monitor = conv4 + return out, nil +} + +// CreateRefreshRequestToSDK converts the mirror to the sdk-go type. +func CreateRefreshRequestToSDK(w *CreateRefreshRequest) (*sdk.CreateRefreshRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRefreshRequest{} + conv5, err := RefreshToSDK(w.Refresh) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRefreshRequest.Refresh", err) + } + out.Refresh = conv5 + return out, nil +} + +// CreateRefreshRequestFromSDK converts the sdk-go type to the mirror. +func CreateRefreshRequestFromSDK(v *sdk.CreateRefreshRequest) (*CreateRefreshRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateRefreshRequest{} + conv6, err := RefreshFromSDK(v.Refresh) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRefreshRequest.Refresh", err) + } + out.Refresh = conv6 + return out, nil +} + +// CronScheduleToSDK converts the mirror to the sdk-go type. +func CronScheduleToSDK(w *CronSchedule) (*sdk.CronSchedule, error) { + if w == nil { + return nil, nil + } + out := &sdk.CronSchedule{} + out.QuartzCronExpression = w.QuartzCronExpression + out.TimezoneId = w.TimezoneId + out.PauseStatus = w.PauseStatus + return out, nil +} + +// CronScheduleFromSDK converts the sdk-go type to the mirror. +func CronScheduleFromSDK(v *sdk.CronSchedule) (*CronSchedule, error) { + if v == nil { + return nil, nil + } + out := &CronSchedule{} + out.QuartzCronExpression = v.QuartzCronExpression + out.TimezoneId = v.TimezoneId + out.PauseStatus = v.PauseStatus + return out, nil +} + +// DataProfilingConfigToSDK converts the mirror to the sdk-go type. +func DataProfilingConfigToSDK(w *DataProfilingConfig) (*sdk.DataProfilingConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataProfilingConfig{} + out.OutputSchemaId = w.OutputSchemaId + out.AssetsDir = w.AssetsDir + { + var members []string + if w.InferenceLog != nil { + members = append(members, "inference_log") + } + if w.TimeSeries != nil { + members = append(members, "time_series") + } + if w.Snapshot != nil { + members = append(members, "snapshot") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.InferenceLog != nil: + conv7, err := InferenceLogConfigToSDK(w.InferenceLog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataProfilingConfig.AnalysisConfig", err) + } + out.AnalysisConfig = &sdk.DataProfilingConfig_AnalysisConfig_InferenceLog{InferenceLog: *conv7} + case w.TimeSeries != nil: + conv8, err := TimeSeriesConfigToSDK(w.TimeSeries) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataProfilingConfig.AnalysisConfig", err) + } + out.AnalysisConfig = &sdk.DataProfilingConfig_AnalysisConfig_TimeSeries{TimeSeries: *conv8} + case w.Snapshot != nil: + conv9, err := SnapshotConfigToSDK(w.Snapshot) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataProfilingConfig.AnalysisConfig", err) + } + out.AnalysisConfig = &sdk.DataProfilingConfig_AnalysisConfig_Snapshot{Snapshot: *conv9} + } + out.SlicingExprs = w.SlicingExprs + conv10, err := convertSlice(w.CustomMetrics, DataProfilingCustomMetricToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataProfilingConfig.CustomMetrics", err) + } + out.CustomMetrics = conv10 + out.BaselineTableName = w.BaselineTableName + conv11, err := CronScheduleToSDK(w.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataProfilingConfig.Schedule", err) + } + out.Schedule = conv11 + conv12, err := NotificationSettingsToSDK(w.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataProfilingConfig.NotificationSettings", err) + } + out.NotificationSettings = conv12 + out.SkipBuiltinDashboard = w.SkipBuiltinDashboard + out.WarehouseId = w.WarehouseId + out.MonitoredTableName = w.MonitoredTableName + out.Status = w.Status + out.LatestMonitorFailureMessage = w.LatestMonitorFailureMessage + out.ProfileMetricsTableName = w.ProfileMetricsTableName + out.DriftMetricsTableName = w.DriftMetricsTableName + out.DashboardId = w.DashboardId + out.MonitorVersion = w.MonitorVersion + out.EffectiveWarehouseId = w.EffectiveWarehouseId + return out, nil +} + +// DataProfilingConfigFromSDK converts the sdk-go type to the mirror. +func DataProfilingConfigFromSDK(v *sdk.DataProfilingConfig) (*DataProfilingConfig, error) { + if v == nil { + return nil, nil + } + out := &DataProfilingConfig{} + out.OutputSchemaId = v.OutputSchemaId + out.AssetsDir = v.AssetsDir + switch value := v.AnalysisConfig.(type) { + case *sdk.DataProfilingConfig_AnalysisConfig_InferenceLog: + if value != nil { + conv13, err := InferenceLogConfigFromSDK(&value.InferenceLog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataProfilingConfig.AnalysisConfig", err) + } + out.InferenceLog = conv13 + } + case *sdk.DataProfilingConfig_AnalysisConfig_TimeSeries: + if value != nil { + conv14, err := TimeSeriesConfigFromSDK(&value.TimeSeries) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataProfilingConfig.AnalysisConfig", err) + } + out.TimeSeries = conv14 + } + case *sdk.DataProfilingConfig_AnalysisConfig_Snapshot: + if value != nil { + conv15, err := SnapshotConfigFromSDK(&value.Snapshot) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataProfilingConfig.AnalysisConfig", err) + } + out.Snapshot = conv15 + } + } + out.SlicingExprs = v.SlicingExprs + conv16, err := convertSlice(v.CustomMetrics, DataProfilingCustomMetricFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataProfilingConfig.CustomMetrics", err) + } + out.CustomMetrics = conv16 + out.BaselineTableName = v.BaselineTableName + conv17, err := CronScheduleFromSDK(v.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataProfilingConfig.Schedule", err) + } + out.Schedule = conv17 + conv18, err := NotificationSettingsFromSDK(v.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataProfilingConfig.NotificationSettings", err) + } + out.NotificationSettings = conv18 + out.SkipBuiltinDashboard = v.SkipBuiltinDashboard + out.WarehouseId = v.WarehouseId + out.MonitoredTableName = v.MonitoredTableName + out.Status = v.Status + out.LatestMonitorFailureMessage = v.LatestMonitorFailureMessage + out.ProfileMetricsTableName = v.ProfileMetricsTableName + out.DriftMetricsTableName = v.DriftMetricsTableName + out.DashboardId = v.DashboardId + out.MonitorVersion = v.MonitorVersion + out.EffectiveWarehouseId = v.EffectiveWarehouseId + return out, nil +} + +// DataProfilingCustomMetricToSDK converts the mirror to the sdk-go type. +func DataProfilingCustomMetricToSDK(w *DataProfilingCustomMetric) (*sdk.DataProfilingCustomMetric, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataProfilingCustomMetric{} + out.Name = w.Name + out.Definition = w.Definition + out.InputColumns = w.InputColumns + out.OutputDataType = w.OutputDataType + out.Type = w.Type + return out, nil +} + +// DataProfilingCustomMetricFromSDK converts the sdk-go type to the mirror. +func DataProfilingCustomMetricFromSDK(v *sdk.DataProfilingCustomMetric) (*DataProfilingCustomMetric, error) { + if v == nil { + return nil, nil + } + out := &DataProfilingCustomMetric{} + out.Name = v.Name + out.Definition = v.Definition + out.InputColumns = v.InputColumns + out.OutputDataType = v.OutputDataType + out.Type = v.Type + return out, nil +} + +// InferenceLogConfigToSDK converts the mirror to the sdk-go type. +func InferenceLogConfigToSDK(w *InferenceLogConfig) (*sdk.InferenceLogConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.InferenceLogConfig{} + out.ProblemType = w.ProblemType + out.TimestampColumn = w.TimestampColumn + out.Granularities = w.Granularities + out.PredictionColumn = w.PredictionColumn + out.LabelColumn = w.LabelColumn + out.ModelIdColumn = w.ModelIdColumn + return out, nil +} + +// InferenceLogConfigFromSDK converts the sdk-go type to the mirror. +func InferenceLogConfigFromSDK(v *sdk.InferenceLogConfig) (*InferenceLogConfig, error) { + if v == nil { + return nil, nil + } + out := &InferenceLogConfig{} + out.ProblemType = v.ProblemType + out.TimestampColumn = v.TimestampColumn + out.Granularities = v.Granularities + out.PredictionColumn = v.PredictionColumn + out.LabelColumn = v.LabelColumn + out.ModelIdColumn = v.ModelIdColumn + return out, nil +} + +// ListMonitorRequestToSDK converts the mirror to the sdk-go type. +func ListMonitorRequestToSDK(w *ListMonitorRequest) (*sdk.ListMonitorRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListMonitorRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListMonitorRequestFromSDK converts the sdk-go type to the mirror. +func ListMonitorRequestFromSDK(v *sdk.ListMonitorRequest) (*ListMonitorRequest, error) { + if v == nil { + return nil, nil + } + out := &ListMonitorRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListMonitorResponseToSDK converts the mirror to the sdk-go type. +func ListMonitorResponseToSDK(w *ListMonitorResponse) (*sdk.ListMonitorResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListMonitorResponse{} + conv19, err := convertSlice(w.Monitors, MonitorToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListMonitorResponse.Monitors", err) + } + out.Monitors = conv19 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListMonitorResponseFromSDK converts the sdk-go type to the mirror. +func ListMonitorResponseFromSDK(v *sdk.ListMonitorResponse) (*ListMonitorResponse, error) { + if v == nil { + return nil, nil + } + out := &ListMonitorResponse{} + conv20, err := convertSlice(v.Monitors, MonitorFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListMonitorResponse.Monitors", err) + } + out.Monitors = conv20 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListRefreshRequestToSDK converts the mirror to the sdk-go type. +func ListRefreshRequestToSDK(w *ListRefreshRequest) (*sdk.ListRefreshRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRefreshRequest{} + out.ObjectType = w.ObjectType + out.ObjectId = w.ObjectId + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListRefreshRequestFromSDK converts the sdk-go type to the mirror. +func ListRefreshRequestFromSDK(v *sdk.ListRefreshRequest) (*ListRefreshRequest, error) { + if v == nil { + return nil, nil + } + out := &ListRefreshRequest{} + out.ObjectType = v.ObjectType + out.ObjectId = v.ObjectId + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListRefreshResponseToSDK converts the mirror to the sdk-go type. +func ListRefreshResponseToSDK(w *ListRefreshResponse) (*sdk.ListRefreshResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRefreshResponse{} + conv21, err := convertSlice(w.Refreshes, RefreshToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRefreshResponse.Refreshes", err) + } + out.Refreshes = conv21 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListRefreshResponseFromSDK converts the sdk-go type to the mirror. +func ListRefreshResponseFromSDK(v *sdk.ListRefreshResponse) (*ListRefreshResponse, error) { + if v == nil { + return nil, nil + } + out := &ListRefreshResponse{} + conv22, err := convertSlice(v.Refreshes, RefreshFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRefreshResponse.Refreshes", err) + } + out.Refreshes = conv22 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// MonitorToSDK converts the mirror to the sdk-go type. +func MonitorToSDK(w *Monitor) (*sdk.Monitor, error) { + if w == nil { + return nil, nil + } + out := &sdk.Monitor{} + out.ObjectType = w.ObjectType + out.ObjectId = w.ObjectId + conv23, err := AnomalyDetectionConfigToSDK(w.AnomalyDetectionConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Monitor.AnomalyDetectionConfig", err) + } + out.AnomalyDetectionConfig = conv23 + conv24, err := DataProfilingConfigToSDK(w.DataProfilingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Monitor.DataProfilingConfig", err) + } + out.DataProfilingConfig = conv24 + return out, nil +} + +// MonitorFromSDK converts the sdk-go type to the mirror. +func MonitorFromSDK(v *sdk.Monitor) (*Monitor, error) { + if v == nil { + return nil, nil + } + out := &Monitor{} + out.ObjectType = v.ObjectType + out.ObjectId = v.ObjectId + conv25, err := AnomalyDetectionConfigFromSDK(v.AnomalyDetectionConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Monitor.AnomalyDetectionConfig", err) + } + out.AnomalyDetectionConfig = conv25 + conv26, err := DataProfilingConfigFromSDK(v.DataProfilingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Monitor.DataProfilingConfig", err) + } + out.DataProfilingConfig = conv26 + return out, nil +} + +// NotificationDestinationToSDK converts the mirror to the sdk-go type. +func NotificationDestinationToSDK(w *NotificationDestination) (*sdk.NotificationDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.NotificationDestination{} + out.EmailAddresses = w.EmailAddresses + return out, nil +} + +// NotificationDestinationFromSDK converts the sdk-go type to the mirror. +func NotificationDestinationFromSDK(v *sdk.NotificationDestination) (*NotificationDestination, error) { + if v == nil { + return nil, nil + } + out := &NotificationDestination{} + out.EmailAddresses = v.EmailAddresses + return out, nil +} + +// NotificationSettingsToSDK converts the mirror to the sdk-go type. +func NotificationSettingsToSDK(w *NotificationSettings) (*sdk.NotificationSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.NotificationSettings{} + conv27, err := NotificationDestinationToSDK(w.OnFailure) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NotificationSettings.OnFailure", err) + } + out.OnFailure = conv27 + return out, nil +} + +// NotificationSettingsFromSDK converts the sdk-go type to the mirror. +func NotificationSettingsFromSDK(v *sdk.NotificationSettings) (*NotificationSettings, error) { + if v == nil { + return nil, nil + } + out := &NotificationSettings{} + conv28, err := NotificationDestinationFromSDK(v.OnFailure) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NotificationSettings.OnFailure", err) + } + out.OnFailure = conv28 + return out, nil +} + +// RefreshToSDK converts the mirror to the sdk-go type. +func RefreshToSDK(w *Refresh) (*sdk.Refresh, error) { + if w == nil { + return nil, nil + } + out := &sdk.Refresh{} + out.ObjectType = w.ObjectType + out.ObjectId = w.ObjectId + out.RefreshId = w.RefreshId + out.State = w.State + out.Message = w.Message + out.StartTimeMs = w.StartTimeMs + out.EndTimeMs = w.EndTimeMs + out.Trigger = w.Trigger + return out, nil +} + +// RefreshFromSDK converts the sdk-go type to the mirror. +func RefreshFromSDK(v *sdk.Refresh) (*Refresh, error) { + if v == nil { + return nil, nil + } + out := &Refresh{} + out.ObjectType = v.ObjectType + out.ObjectId = v.ObjectId + out.RefreshId = v.RefreshId + out.State = v.State + out.Message = v.Message + out.StartTimeMs = v.StartTimeMs + out.EndTimeMs = v.EndTimeMs + out.Trigger = v.Trigger + return out, nil +} + +// SnapshotConfigToSDK converts the mirror to the sdk-go type. +func SnapshotConfigToSDK(w *SnapshotConfig) (*sdk.SnapshotConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.SnapshotConfig{} + return out, nil +} + +// SnapshotConfigFromSDK converts the sdk-go type to the mirror. +func SnapshotConfigFromSDK(v *sdk.SnapshotConfig) (*SnapshotConfig, error) { + if v == nil { + return nil, nil + } + out := &SnapshotConfig{} + return out, nil +} + +// TimeSeriesConfigToSDK converts the mirror to the sdk-go type. +func TimeSeriesConfigToSDK(w *TimeSeriesConfig) (*sdk.TimeSeriesConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.TimeSeriesConfig{} + out.TimestampColumn = w.TimestampColumn + out.Granularities = w.Granularities + return out, nil +} + +// TimeSeriesConfigFromSDK converts the sdk-go type to the mirror. +func TimeSeriesConfigFromSDK(v *sdk.TimeSeriesConfig) (*TimeSeriesConfig, error) { + if v == nil { + return nil, nil + } + out := &TimeSeriesConfig{} + out.TimestampColumn = v.TimestampColumn + out.Granularities = v.Granularities + return out, nil +} + +// UpdateMonitorRequestToSDK converts the mirror to the sdk-go type. +func UpdateMonitorRequestToSDK(w *UpdateMonitorRequest) (*sdk.UpdateMonitorRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateMonitorRequest{} + out.ObjectType = w.ObjectType + out.ObjectId = w.ObjectId + conv29, err := MonitorToSDK(w.Monitor) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateMonitorRequest.Monitor", err) + } + out.Monitor = conv29 + mask30, err := fieldMaskFromString[sdk.Monitor](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateMonitorRequest.UpdateMask", err) + } + out.UpdateMask = mask30 + return out, nil +} + +// UpdateMonitorRequestFromSDK converts the sdk-go type to the mirror. +func UpdateMonitorRequestFromSDK(v *sdk.UpdateMonitorRequest) (*UpdateMonitorRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateMonitorRequest{} + out.ObjectType = v.ObjectType + out.ObjectId = v.ObjectId + conv31, err := MonitorFromSDK(v.Monitor) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateMonitorRequest.Monitor", err) + } + out.Monitor = conv31 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateRefreshRequestToSDK converts the mirror to the sdk-go type. +func UpdateRefreshRequestToSDK(w *UpdateRefreshRequest) (*sdk.UpdateRefreshRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRefreshRequest{} + out.ObjectType = w.ObjectType + out.ObjectId = w.ObjectId + out.RefreshId = w.RefreshId + conv32, err := RefreshToSDK(w.Refresh) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRefreshRequest.Refresh", err) + } + out.Refresh = conv32 + mask33, err := fieldMaskFromString[sdk.Refresh](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRefreshRequest.UpdateMask", err) + } + out.UpdateMask = mask33 + return out, nil +} + +// UpdateRefreshRequestFromSDK converts the sdk-go type to the mirror. +func UpdateRefreshRequestFromSDK(v *sdk.UpdateRefreshRequest) (*UpdateRefreshRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateRefreshRequest{} + out.ObjectType = v.ObjectType + out.ObjectId = v.ObjectId + out.RefreshId = v.RefreshId + conv34, err := RefreshFromSDK(v.Refresh) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRefreshRequest.Refresh", err) + } + out.Refresh = conv34 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/disasterrecovery/v1/types.generated.go b/libs/sdktypes/disasterrecovery/v1/types.generated.go new file mode 100644 index 00000000000..e99523df63a --- /dev/null +++ b/libs/sdktypes/disasterrecovery/v1/types.generated.go @@ -0,0 +1,776 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/disasterrecovery/v1. DO NOT EDIT. + +package disasterrecovery + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/disasterrecovery/v1" + strings "strings" +) + +type ( + FailoverFailoverGroupRequest_FailoverType = sdk.FailoverFailoverGroupRequest_FailoverType + FailoverGroup_State = sdk.FailoverGroup_State +) + +const ( + FailoverFailoverGroupRequest_FailoverType_Unspecified = sdk.FailoverFailoverGroupRequest_FailoverType_Unspecified + FailoverFailoverGroupRequest_FailoverType_Forced = sdk.FailoverFailoverGroupRequest_FailoverType_Forced + FailoverGroup_State_Unspecified = sdk.FailoverGroup_State_Unspecified + FailoverGroup_State_Creating = sdk.FailoverGroup_State_Creating + FailoverGroup_State_CreationFailed = sdk.FailoverGroup_State_CreationFailed + FailoverGroup_State_InitialReplication = sdk.FailoverGroup_State_InitialReplication + FailoverGroup_State_Active = sdk.FailoverGroup_State_Active + FailoverGroup_State_FailingOver = sdk.FailoverGroup_State_FailingOver + FailoverGroup_State_Deleting = sdk.FailoverGroup_State_Deleting + FailoverGroup_State_FailoverFailed = sdk.FailoverGroup_State_FailoverFailed + FailoverGroup_State_DeletionFailed = sdk.FailoverGroup_State_DeletionFailed +) + +// Request to create a new failover group.. +type CreateFailoverGroupRequest struct { + // The failover group to create. + FailoverGroup *FailoverGroup `json:"failover_group,omitempty"` + // Client-provided identifier for the failover group. Used to construct the + // resource name as {parent}/failover-groups/{failover_group_id}. + FailoverGroupId *string `json:"failover_group_id,omitempty"` + // The parent resource. Format: accounts/{account_id}. + Parent *string `json:"parent,omitempty"` + // When true, validates the request without creating the failover group. + ValidateOnly *bool `json:"validate_only,omitempty"` +} + +// Request to create a new stable URL for failover-aware workspace access.. +type CreateStableUrlRequest struct { + // The parent resource. Format: accounts/{account_id}. + Parent *string `json:"parent,omitempty"` + // The stable URL to create. + StableUrl *StableUrl `json:"stable_url,omitempty"` + // Client-provided identifier for the stable URL. Used to construct the resource + // name as {parent}/stable-urls/{stable_url_id}. + StableUrlId *string `json:"stable_url_id,omitempty"` + // When true, validates the request without creating the stable URL. + ValidateOnly *bool `json:"validate_only,omitempty"` +} + +// Request to delete a failover group.. +type DeleteFailoverGroupRequest struct { + // Opaque version string for optimistic locking. If provided, must match the + // current etag. If omitted, the delete proceeds without an etag check. + Etag *string `json:"etag,omitempty"` + // The fully qualified resource name of the failover group to delete. Format: + // accounts/{account_id}/failover-groups/{failover_group_id}. + Name *string `json:"name,omitempty"` +} + +// Request to failover a failover group to a new primary region.. +type FailoverFailoverGroupRequest struct { + // Opaque version string for optimistic locking. If provided, must match the + // current etag. If omitted, the failover proceeds regardless of current state. + Etag *string `json:"etag,omitempty"` + // The type of failover to perform. + FailoverType FailoverFailoverGroupRequest_FailoverType `json:"failover_type,omitempty"` + // The fully qualified resource name of the failover group to failover. Format: + // accounts/{account_id}/failover-groups/{failover_group_id}. + Name *string `json:"name,omitempty"` + // The target primary region. Must be one of the participating regions and + // different from the current effective_primary_region. Serves as an idempotency + // check. + TargetPrimaryRegion *string `json:"target_primary_region,omitempty"` +} + +// A failover group manages disaster recovery across workspace sets, +// coordinating Unity Catalog and workspace assets replication.. +type FailoverGroup struct { + // Time at which this failover group was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Current effective primary region. Replication flows FROM workspaces in this + // region. Changes after a successful failover. + EffectivePrimaryRegion *string `json:"effective_primary_region,omitempty"` + // Opaque version string for optimistic locking. Server-generated and returned + // in responses. + Etag *string `json:"etag,omitempty"` + // Initial primary region. Used only in Create requests to set the starting + // primary region. Not returned in responses. + InitialPrimaryRegion *string `json:"initial_primary_region,omitempty"` + // Fully qualified resource name in the format + // accounts/{account_id}/failover-groups/{failover_group_id}. + Name *string `json:"name,omitempty"` + // List of all regions participating in this failover group. + Regions []string `json:"regions,omitempty"` + // The latest point in time to which data has been replicated. + ReplicationPoint *types.Time `json:"replication_point,omitempty"` + // Aggregate state of the failover group. + State FailoverGroup_State `json:"state,omitempty"` + // Unity Catalog replication configuration. + UnityCatalogAssets *UcReplicationConfig `json:"unity_catalog_assets,omitempty"` + // Time at which this failover group was last modified. + UpdateTime *types.Time `json:"update_time,omitempty"` + // Workspace sets, each containing workspaces that replicate to each other. + WorkspaceSets []WorkspaceSet `json:"workspace_sets,omitempty"` +} + +// Request to list failover groups for an account.. +type ListFailoverGroupsRequest struct { + // Maximum number of failover groups to return per page: - when set to a value + // greater than 0, the page length is the minimum of this value and a server + // configured value; - when set to 0 or unset, the page length is set to a + // server configured value (recommended); - when set to a value less than 0, an + // invalid parameter error is returned. + PageSize *int `json:"page_size,omitempty"` + // Page token received from a previous ListFailoverGroups call. Provide this to + // retrieve the subsequent page. + PageToken *string `json:"page_token,omitempty"` + // The parent resource. Format: accounts/{account_id}. + Parent *string `json:"parent,omitempty"` +} + +// Response for listing failover groups.. +type ListFailoverGroupsResponse struct { + // The failover groups for this account. + FailoverGroups []FailoverGroup `json:"failover_groups,omitempty"` + // A token that can be sent as page_token to retrieve the next page. If omitted, + // there are no subsequent pages. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to list stable URLs for an account.. +type ListStableUrlsRequest struct { + // Maximum number of stable URLs to return per page: - when set to a value + // greater than 0, the page length is the minimum of this value and a server + // configured value; - when set to 0 or unset, the page length is set to a + // server configured value (recommended); - when set to a value less than 0, an + // invalid parameter error is returned. + PageSize *int `json:"page_size,omitempty"` + // Page token received from a previous ListStableUrls call. Provide this to + // retrieve the subsequent page. + PageToken *string `json:"page_token,omitempty"` + // The parent resource. Format: accounts/{account_id}. + Parent *string `json:"parent,omitempty"` +} + +// Response for listing stable URLs.. +type ListStableUrlsResponse struct { + // A token that can be sent as page_token to retrieve the next page. If omitted, + // there are no subsequent pages. + NextPageToken *string `json:"next_page_token,omitempty"` + // The stable URLs for this account. + StableUrls []StableUrl `json:"stable_urls,omitempty"` +} + +// A location mapping identified by a name, with URIs per region. The system +// derives replication direction from effective_primary_region.. +type LocationMapping struct { + // Resource name for this location. + Name *string `json:"name,omitempty"` + // URI for each region. Each entry maps a region name to a storage URI. + UriByRegion []LocationMappingEntry `json:"uri_by_region,omitempty"` +} + +// A single entry in a location mapping, mapping a region to a storage URI. Used +// instead of map for proto2 compatibility.. +type LocationMappingEntry struct { + // The region name. + Region *string `json:"region,omitempty"` + // The storage URI for this region. + Uri *string `json:"uri,omitempty"` +} + +// A stable URL provides a failover-aware endpoint for accessing a workspace. +// Its lifecycle is independent of any failover group.. +type StableUrl struct { + // The workspace this stable URL currently routes to. Set to + // `initial_workspace_id` at creation, advanced to the failover group's primary + // while attached (including across a failover), and preserved when the stable + // URL is detached from its failover group. Read this to see where an unattached + // stable URL points: after a failover followed by a detach it reflects the + // post-failover primary, not `initial_workspace_id`. + EffectiveWorkspaceId *string `json:"effective_workspace_id,omitempty"` + // Fully qualified resource name of the FailoverGroup this stable URL is + // currently linked to, in the format + // `accounts/{account_id}/failover-groups/{failover_group_id}`. Empty when the + // stable URL is not attached to any failover group. + FailoverGroupName *string `json:"failover_group_name,omitempty"` + // The workspace this stable URL is initially bound to. Used only in Create + // requests to associate the stable URL with a workspace. Not returned in + // responses. + InitialWorkspaceId *string `json:"initial_workspace_id,omitempty"` + // Fully qualified resource name. Format: + // accounts/{account_id}/stable-urls/{stable_url_id}. + Name *string `json:"name,omitempty"` + // The stable workspace ID for this stable URL. Generated on creation and + // immutable thereafter; identifies the URL across failovers and is the same + // value embedded in the `url` (as the `w=` query parameter for SPOG URLs, or in + // the `conn-` hostname for Private-Link URLs). + StableWorkspaceId *string `json:"stable_workspace_id,omitempty"` + // The stable URL endpoint. Generated on creation and immutable thereafter. For + // non-Private-Link workspaces this is `https:///?w=`. + // For Private-Link workspaces this is the per-connection hostname. + Url *string `json:"url,omitempty"` +} + +// A Unity Catalog catalog to replicate.. +type UcCatalog struct { + // The name of the UC catalog to replicate. + Name *string `json:"name,omitempty"` +} + +// Unity Catalog replication configuration (top-level, not per-set).. +type UcReplicationConfig struct { + // UC catalogs to replicate. + Catalogs []UcCatalog `json:"catalogs,omitempty"` + // The workspace set whose workspaces will be used for data replication of all + // UC catalogs' underlying storage. + DataReplicationWorkspaceSet *string `json:"data_replication_workspace_set,omitempty"` + // Location mappings - storage URI per region for each location. + LocationMappings []LocationMapping `json:"location_mappings,omitempty"` +} + +// Request to update a failover group.. +type UpdateFailoverGroupRequest struct { + // Optional opaque version string for optimistic locking, obtained from a prior + // read of the failover group. If provided, the update is rejected unless it + // matches the failover group's current etag. If omitted, the update proceeds + // without an optimistic-lock check. + Etag *string `json:"etag,omitempty"` + // The failover group with updated fields. The name field identifies the + // resource and is populated from the URL path. + FailoverGroup *FailoverGroup `json:"failover_group,omitempty"` + // Comma-separated list of fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// A set of workspaces that replicate to each other across regions.. +type WorkspaceSet struct { + // Resource name for this workspace set. + Name *string `json:"name,omitempty"` + // Whether to enable control plane DR (notebooks, jobs, clusters, etc.) for this + // set. Defaults to false. + ReplicateWorkspaceAssets *bool `json:"replicate_workspace_assets,omitempty"` + // Resource names of stable URLs associated with this workspace set. Format: + // accounts/{account_id}/stable-urls/{stable_url_id}. The referenced stable URLs + // must already exist (via CreateStableUrl). + StableUrlNames []string `json:"stable_url_names,omitempty"` + // Workspace IDs in this set. The system derives and validates regions. All + // workspaces must be in the Mission Critical tier. + WorkspaceIds []string `json:"workspace_ids,omitempty"` +} + +// CreateFailoverGroupRequestToSDK converts the mirror to the sdk-go type. +func CreateFailoverGroupRequestToSDK(w *CreateFailoverGroupRequest) (*sdk.CreateFailoverGroupRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateFailoverGroupRequest{} + out.Parent = w.Parent + conv1, err := FailoverGroupToSDK(w.FailoverGroup) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFailoverGroupRequest.FailoverGroup", err) + } + out.FailoverGroup = conv1 + out.ValidateOnly = w.ValidateOnly + out.FailoverGroupId = w.FailoverGroupId + return out, nil +} + +// CreateFailoverGroupRequestFromSDK converts the sdk-go type to the mirror. +func CreateFailoverGroupRequestFromSDK(v *sdk.CreateFailoverGroupRequest) (*CreateFailoverGroupRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateFailoverGroupRequest{} + out.Parent = v.Parent + conv2, err := FailoverGroupFromSDK(v.FailoverGroup) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFailoverGroupRequest.FailoverGroup", err) + } + out.FailoverGroup = conv2 + out.ValidateOnly = v.ValidateOnly + out.FailoverGroupId = v.FailoverGroupId + return out, nil +} + +// CreateStableUrlRequestToSDK converts the mirror to the sdk-go type. +func CreateStableUrlRequestToSDK(w *CreateStableUrlRequest) (*sdk.CreateStableUrlRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateStableUrlRequest{} + out.Parent = w.Parent + conv3, err := StableUrlToSDK(w.StableUrl) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStableUrlRequest.StableUrl", err) + } + out.StableUrl = conv3 + out.ValidateOnly = w.ValidateOnly + out.StableUrlId = w.StableUrlId + return out, nil +} + +// CreateStableUrlRequestFromSDK converts the sdk-go type to the mirror. +func CreateStableUrlRequestFromSDK(v *sdk.CreateStableUrlRequest) (*CreateStableUrlRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateStableUrlRequest{} + out.Parent = v.Parent + conv4, err := StableUrlFromSDK(v.StableUrl) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStableUrlRequest.StableUrl", err) + } + out.StableUrl = conv4 + out.ValidateOnly = v.ValidateOnly + out.StableUrlId = v.StableUrlId + return out, nil +} + +// DeleteFailoverGroupRequestToSDK converts the mirror to the sdk-go type. +func DeleteFailoverGroupRequestToSDK(w *DeleteFailoverGroupRequest) (*sdk.DeleteFailoverGroupRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteFailoverGroupRequest{} + out.Name = w.Name + out.Etag = w.Etag + return out, nil +} + +// DeleteFailoverGroupRequestFromSDK converts the sdk-go type to the mirror. +func DeleteFailoverGroupRequestFromSDK(v *sdk.DeleteFailoverGroupRequest) (*DeleteFailoverGroupRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteFailoverGroupRequest{} + out.Name = v.Name + out.Etag = v.Etag + return out, nil +} + +// FailoverFailoverGroupRequestToSDK converts the mirror to the sdk-go type. +func FailoverFailoverGroupRequestToSDK(w *FailoverFailoverGroupRequest) (*sdk.FailoverFailoverGroupRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.FailoverFailoverGroupRequest{} + out.Name = w.Name + out.TargetPrimaryRegion = w.TargetPrimaryRegion + out.Etag = w.Etag + out.FailoverType = w.FailoverType + return out, nil +} + +// FailoverFailoverGroupRequestFromSDK converts the sdk-go type to the mirror. +func FailoverFailoverGroupRequestFromSDK(v *sdk.FailoverFailoverGroupRequest) (*FailoverFailoverGroupRequest, error) { + if v == nil { + return nil, nil + } + out := &FailoverFailoverGroupRequest{} + out.Name = v.Name + out.TargetPrimaryRegion = v.TargetPrimaryRegion + out.Etag = v.Etag + out.FailoverType = v.FailoverType + return out, nil +} + +// FailoverGroupToSDK converts the mirror to the sdk-go type. +func FailoverGroupToSDK(w *FailoverGroup) (*sdk.FailoverGroup, error) { + if w == nil { + return nil, nil + } + out := &sdk.FailoverGroup{} + out.Name = w.Name + out.EffectivePrimaryRegion = w.EffectivePrimaryRegion + out.Regions = w.Regions + conv5, err := convertSlice(w.WorkspaceSets, WorkspaceSetToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FailoverGroup.WorkspaceSets", err) + } + out.WorkspaceSets = conv5 + conv6, err := UcReplicationConfigToSDK(w.UnityCatalogAssets) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FailoverGroup.UnityCatalogAssets", err) + } + out.UnityCatalogAssets = conv6 + out.State = w.State + out.Etag = w.Etag + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.ReplicationPoint = w.ReplicationPoint + out.InitialPrimaryRegion = w.InitialPrimaryRegion + return out, nil +} + +// FailoverGroupFromSDK converts the sdk-go type to the mirror. +func FailoverGroupFromSDK(v *sdk.FailoverGroup) (*FailoverGroup, error) { + if v == nil { + return nil, nil + } + out := &FailoverGroup{} + out.Name = v.Name + out.EffectivePrimaryRegion = v.EffectivePrimaryRegion + out.Regions = v.Regions + conv7, err := convertSlice(v.WorkspaceSets, WorkspaceSetFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FailoverGroup.WorkspaceSets", err) + } + out.WorkspaceSets = conv7 + conv8, err := UcReplicationConfigFromSDK(v.UnityCatalogAssets) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FailoverGroup.UnityCatalogAssets", err) + } + out.UnityCatalogAssets = conv8 + out.State = v.State + out.Etag = v.Etag + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.ReplicationPoint = v.ReplicationPoint + out.InitialPrimaryRegion = v.InitialPrimaryRegion + return out, nil +} + +// ListFailoverGroupsRequestToSDK converts the mirror to the sdk-go type. +func ListFailoverGroupsRequestToSDK(w *ListFailoverGroupsRequest) (*sdk.ListFailoverGroupsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListFailoverGroupsRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListFailoverGroupsRequestFromSDK converts the sdk-go type to the mirror. +func ListFailoverGroupsRequestFromSDK(v *sdk.ListFailoverGroupsRequest) (*ListFailoverGroupsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListFailoverGroupsRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListFailoverGroupsResponseToSDK converts the mirror to the sdk-go type. +func ListFailoverGroupsResponseToSDK(w *ListFailoverGroupsResponse) (*sdk.ListFailoverGroupsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListFailoverGroupsResponse{} + conv9, err := convertSlice(w.FailoverGroups, FailoverGroupToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFailoverGroupsResponse.FailoverGroups", err) + } + out.FailoverGroups = conv9 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListFailoverGroupsResponseFromSDK converts the sdk-go type to the mirror. +func ListFailoverGroupsResponseFromSDK(v *sdk.ListFailoverGroupsResponse) (*ListFailoverGroupsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListFailoverGroupsResponse{} + conv10, err := convertSlice(v.FailoverGroups, FailoverGroupFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFailoverGroupsResponse.FailoverGroups", err) + } + out.FailoverGroups = conv10 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListStableUrlsRequestToSDK converts the mirror to the sdk-go type. +func ListStableUrlsRequestToSDK(w *ListStableUrlsRequest) (*sdk.ListStableUrlsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListStableUrlsRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListStableUrlsRequestFromSDK converts the sdk-go type to the mirror. +func ListStableUrlsRequestFromSDK(v *sdk.ListStableUrlsRequest) (*ListStableUrlsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListStableUrlsRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListStableUrlsResponseToSDK converts the mirror to the sdk-go type. +func ListStableUrlsResponseToSDK(w *ListStableUrlsResponse) (*sdk.ListStableUrlsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListStableUrlsResponse{} + conv11, err := convertSlice(w.StableUrls, StableUrlToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListStableUrlsResponse.StableUrls", err) + } + out.StableUrls = conv11 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListStableUrlsResponseFromSDK converts the sdk-go type to the mirror. +func ListStableUrlsResponseFromSDK(v *sdk.ListStableUrlsResponse) (*ListStableUrlsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListStableUrlsResponse{} + conv12, err := convertSlice(v.StableUrls, StableUrlFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListStableUrlsResponse.StableUrls", err) + } + out.StableUrls = conv12 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// LocationMappingToSDK converts the mirror to the sdk-go type. +func LocationMappingToSDK(w *LocationMapping) (*sdk.LocationMapping, error) { + if w == nil { + return nil, nil + } + out := &sdk.LocationMapping{} + out.Name = w.Name + conv13, err := convertSlice(w.UriByRegion, LocationMappingEntryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LocationMapping.UriByRegion", err) + } + out.UriByRegion = conv13 + return out, nil +} + +// LocationMappingFromSDK converts the sdk-go type to the mirror. +func LocationMappingFromSDK(v *sdk.LocationMapping) (*LocationMapping, error) { + if v == nil { + return nil, nil + } + out := &LocationMapping{} + out.Name = v.Name + conv14, err := convertSlice(v.UriByRegion, LocationMappingEntryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LocationMapping.UriByRegion", err) + } + out.UriByRegion = conv14 + return out, nil +} + +// LocationMappingEntryToSDK converts the mirror to the sdk-go type. +func LocationMappingEntryToSDK(w *LocationMappingEntry) (*sdk.LocationMappingEntry, error) { + if w == nil { + return nil, nil + } + out := &sdk.LocationMappingEntry{} + out.Region = w.Region + out.Uri = w.Uri + return out, nil +} + +// LocationMappingEntryFromSDK converts the sdk-go type to the mirror. +func LocationMappingEntryFromSDK(v *sdk.LocationMappingEntry) (*LocationMappingEntry, error) { + if v == nil { + return nil, nil + } + out := &LocationMappingEntry{} + out.Region = v.Region + out.Uri = v.Uri + return out, nil +} + +// StableUrlToSDK converts the mirror to the sdk-go type. +func StableUrlToSDK(w *StableUrl) (*sdk.StableUrl, error) { + if w == nil { + return nil, nil + } + out := &sdk.StableUrl{} + out.Name = w.Name + out.Url = w.Url + out.InitialWorkspaceId = w.InitialWorkspaceId + out.FailoverGroupName = w.FailoverGroupName + out.EffectiveWorkspaceId = w.EffectiveWorkspaceId + out.StableWorkspaceId = w.StableWorkspaceId + return out, nil +} + +// StableUrlFromSDK converts the sdk-go type to the mirror. +func StableUrlFromSDK(v *sdk.StableUrl) (*StableUrl, error) { + if v == nil { + return nil, nil + } + out := &StableUrl{} + out.Name = v.Name + out.Url = v.Url + out.InitialWorkspaceId = v.InitialWorkspaceId + out.FailoverGroupName = v.FailoverGroupName + out.EffectiveWorkspaceId = v.EffectiveWorkspaceId + out.StableWorkspaceId = v.StableWorkspaceId + return out, nil +} + +// UcCatalogToSDK converts the mirror to the sdk-go type. +func UcCatalogToSDK(w *UcCatalog) (*sdk.UcCatalog, error) { + if w == nil { + return nil, nil + } + out := &sdk.UcCatalog{} + out.Name = w.Name + return out, nil +} + +// UcCatalogFromSDK converts the sdk-go type to the mirror. +func UcCatalogFromSDK(v *sdk.UcCatalog) (*UcCatalog, error) { + if v == nil { + return nil, nil + } + out := &UcCatalog{} + out.Name = v.Name + return out, nil +} + +// UcReplicationConfigToSDK converts the mirror to the sdk-go type. +func UcReplicationConfigToSDK(w *UcReplicationConfig) (*sdk.UcReplicationConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.UcReplicationConfig{} + conv15, err := convertSlice(w.LocationMappings, LocationMappingToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UcReplicationConfig.LocationMappings", err) + } + out.LocationMappings = conv15 + conv16, err := convertSlice(w.Catalogs, UcCatalogToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UcReplicationConfig.Catalogs", err) + } + out.Catalogs = conv16 + out.DataReplicationWorkspaceSet = w.DataReplicationWorkspaceSet + return out, nil +} + +// UcReplicationConfigFromSDK converts the sdk-go type to the mirror. +func UcReplicationConfigFromSDK(v *sdk.UcReplicationConfig) (*UcReplicationConfig, error) { + if v == nil { + return nil, nil + } + out := &UcReplicationConfig{} + conv17, err := convertSlice(v.LocationMappings, LocationMappingFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UcReplicationConfig.LocationMappings", err) + } + out.LocationMappings = conv17 + conv18, err := convertSlice(v.Catalogs, UcCatalogFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UcReplicationConfig.Catalogs", err) + } + out.Catalogs = conv18 + out.DataReplicationWorkspaceSet = v.DataReplicationWorkspaceSet + return out, nil +} + +// UpdateFailoverGroupRequestToSDK converts the mirror to the sdk-go type. +func UpdateFailoverGroupRequestToSDK(w *UpdateFailoverGroupRequest) (*sdk.UpdateFailoverGroupRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateFailoverGroupRequest{} + conv19, err := FailoverGroupToSDK(w.FailoverGroup) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateFailoverGroupRequest.FailoverGroup", err) + } + out.FailoverGroup = conv19 + mask20, err := fieldMaskFromString[sdk.FailoverGroup](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateFailoverGroupRequest.UpdateMask", err) + } + out.UpdateMask = mask20 + out.Etag = w.Etag + return out, nil +} + +// UpdateFailoverGroupRequestFromSDK converts the sdk-go type to the mirror. +func UpdateFailoverGroupRequestFromSDK(v *sdk.UpdateFailoverGroupRequest) (*UpdateFailoverGroupRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateFailoverGroupRequest{} + conv21, err := FailoverGroupFromSDK(v.FailoverGroup) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateFailoverGroupRequest.FailoverGroup", err) + } + out.FailoverGroup = conv21 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + out.Etag = v.Etag + return out, nil +} + +// WorkspaceSetToSDK converts the mirror to the sdk-go type. +func WorkspaceSetToSDK(w *WorkspaceSet) (*sdk.WorkspaceSet, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkspaceSet{} + out.Name = w.Name + out.WorkspaceIds = w.WorkspaceIds + out.ReplicateWorkspaceAssets = w.ReplicateWorkspaceAssets + out.StableUrlNames = w.StableUrlNames + return out, nil +} + +// WorkspaceSetFromSDK converts the sdk-go type to the mirror. +func WorkspaceSetFromSDK(v *sdk.WorkspaceSet) (*WorkspaceSet, error) { + if v == nil { + return nil, nil + } + out := &WorkspaceSet{} + out.Name = v.Name + out.WorkspaceIds = v.WorkspaceIds + out.ReplicateWorkspaceAssets = v.ReplicateWorkspaceAssets + out.StableUrlNames = v.StableUrlNames + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/domains/v1/types.generated.go b/libs/sdktypes/domains/v1/types.generated.go new file mode 100644 index 00000000000..7c97d7df507 --- /dev/null +++ b/libs/sdktypes/domains/v1/types.generated.go @@ -0,0 +1,416 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/domains/v1. DO NOT EDIT. + +package domains + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/domains/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + DomainIcon_Name = sdk.DomainIcon_Name +) + +const ( + DomainIcon_Name_Unspecified = sdk.DomainIcon_Name_Unspecified + DomainIcon_Name_AddressBook = sdk.DomainIcon_Name_AddressBook + DomainIcon_Name_Alarm = sdk.DomainIcon_Name_Alarm + DomainIcon_Name_ArrowsIn = sdk.DomainIcon_Name_ArrowsIn + DomainIcon_Name_Atom = sdk.DomainIcon_Name_Atom + DomainIcon_Name_Balloon = sdk.DomainIcon_Name_Balloon + DomainIcon_Name_Bank = sdk.DomainIcon_Name_Bank + DomainIcon_Name_Barricade = sdk.DomainIcon_Name_Barricade + DomainIcon_Name_Basket = sdk.DomainIcon_Name_Basket + DomainIcon_Name_Bridge = sdk.DomainIcon_Name_Bridge + DomainIcon_Name_Cactus = sdk.DomainIcon_Name_Cactus + DomainIcon_Name_CallBell = sdk.DomainIcon_Name_CallBell + DomainIcon_Name_Carrot = sdk.DomainIcon_Name_Carrot + DomainIcon_Name_ChartPieSlice = sdk.DomainIcon_Name_ChartPieSlice + DomainIcon_Name_City = sdk.DomainIcon_Name_City + DomainIcon_Name_Cloud = sdk.DomainIcon_Name_Cloud + DomainIcon_Name_Coins = sdk.DomainIcon_Name_Coins + DomainIcon_Name_CompassRose = sdk.DomainIcon_Name_CompassRose + DomainIcon_Name_CraneTower = sdk.DomainIcon_Name_CraneTower + DomainIcon_Name_Crown = sdk.DomainIcon_Name_Crown + DomainIcon_Name_CubeTransparent = sdk.DomainIcon_Name_CubeTransparent + DomainIcon_Name_Faders = sdk.DomainIcon_Name_Faders + DomainIcon_Name_FlagBannerFold = sdk.DomainIcon_Name_FlagBannerFold + DomainIcon_Name_FlagCheckered = sdk.DomainIcon_Name_FlagCheckered + DomainIcon_Name_Gavel = sdk.DomainIcon_Name_Gavel + DomainIcon_Name_Hamburger = sdk.DomainIcon_Name_Hamburger + DomainIcon_Name_HeadCircuit = sdk.DomainIcon_Name_HeadCircuit + DomainIcon_Name_HourglassHigh = sdk.DomainIcon_Name_HourglassHigh + DomainIcon_Name_IntersectThree = sdk.DomainIcon_Name_IntersectThree + DomainIcon_Name_Microscope = sdk.DomainIcon_Name_Microscope + DomainIcon_Name_MoonStars = sdk.DomainIcon_Name_MoonStars + DomainIcon_Name_Package = sdk.DomainIcon_Name_Package + DomainIcon_Name_Parachute = sdk.DomainIcon_Name_Parachute + DomainIcon_Name_Pepper = sdk.DomainIcon_Name_Pepper + DomainIcon_Name_PiggyBank = sdk.DomainIcon_Name_PiggyBank + DomainIcon_Name_Pill = sdk.DomainIcon_Name_Pill + DomainIcon_Name_Planet = sdk.DomainIcon_Name_Planet + DomainIcon_Name_Plant = sdk.DomainIcon_Name_Plant + DomainIcon_Name_PlugsConnected = sdk.DomainIcon_Name_PlugsConnected + DomainIcon_Name_Popcorn = sdk.DomainIcon_Name_Popcorn + DomainIcon_Name_PresentationChart = sdk.DomainIcon_Name_PresentationChart + DomainIcon_Name_PuzzlePiece = sdk.DomainIcon_Name_PuzzlePiece + DomainIcon_Name_Rainbow = sdk.DomainIcon_Name_Rainbow + DomainIcon_Name_Ranking = sdk.DomainIcon_Name_Ranking + DomainIcon_Name_Receipt = sdk.DomainIcon_Name_Receipt + DomainIcon_Name_Rocket = sdk.DomainIcon_Name_Rocket + DomainIcon_Name_Ruler = sdk.DomainIcon_Name_Ruler + DomainIcon_Name_Sailboat = sdk.DomainIcon_Name_Sailboat + DomainIcon_Name_Scales = sdk.DomainIcon_Name_Scales + DomainIcon_Name_ScanSmiley = sdk.DomainIcon_Name_ScanSmiley + DomainIcon_Name_Scroll = sdk.DomainIcon_Name_Scroll + DomainIcon_Name_ShieldCheckered = sdk.DomainIcon_Name_ShieldCheckered + DomainIcon_Name_Sneaker = sdk.DomainIcon_Name_Sneaker + DomainIcon_Name_Snowflake = sdk.DomainIcon_Name_Snowflake + DomainIcon_Name_SolarRoof = sdk.DomainIcon_Name_SolarRoof + DomainIcon_Name_Speedometer = sdk.DomainIcon_Name_Speedometer + DomainIcon_Name_Stamp = sdk.DomainIcon_Name_Stamp + DomainIcon_Name_Steps = sdk.DomainIcon_Name_Steps + DomainIcon_Name_Strategy = sdk.DomainIcon_Name_Strategy + DomainIcon_Name_Sword = sdk.DomainIcon_Name_Sword + DomainIcon_Name_TelevisionSimple = sdk.DomainIcon_Name_TelevisionSimple + DomainIcon_Name_Tent = sdk.DomainIcon_Name_Tent + DomainIcon_Name_Ticket = sdk.DomainIcon_Name_Ticket + DomainIcon_Name_Tractor = sdk.DomainIcon_Name_Tractor + DomainIcon_Name_TrafficCone = sdk.DomainIcon_Name_TrafficCone + DomainIcon_Name_Train = sdk.DomainIcon_Name_Train + DomainIcon_Name_TreeEvergreen = sdk.DomainIcon_Name_TreeEvergreen + DomainIcon_Name_TreeStructure = sdk.DomainIcon_Name_TreeStructure + DomainIcon_Name_TrolleySuitcase = sdk.DomainIcon_Name_TrolleySuitcase + DomainIcon_Name_Trophy = sdk.DomainIcon_Name_Trophy + DomainIcon_Name_TruckTrailer = sdk.DomainIcon_Name_TruckTrailer + DomainIcon_Name_UsersThree = sdk.DomainIcon_Name_UsersThree + DomainIcon_Name_VectorThree = sdk.DomainIcon_Name_VectorThree +) + +type CreateDomainRequest struct { + Domain *Domain `json:"domain,omitempty"` + // Client-supplied resource ID for the new domain. If omitted, the server + // generates one. + DomainId *string `json:"domain_id,omitempty"` +} + +type DeleteDomainRequest struct { + // When false (default), DeleteDomain is rejected with FAILED_PRECONDITION if + // the domain still has Glossary pages. When true, those pages are deleted first + // and then the domain is removed. + Force *bool `json:"force,omitempty"` + // Full resource name of the domain to delete. Format: `domains/{domain_id}` + Name *string `json:"name,omitempty"` +} + +type Domain struct { + // Principal IDs of the business owners (users, groups, or service principals). + BusinessOwnerIds []int64 `json:"business_owner_ids,omitempty"` + // Timestamp when the domain was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Full description (max 4096 chars) + Description *string `json:"description,omitempty"` + // Unique identifier for the domain. If omitted at Create, the server generates + // one. + DomainId *string `json:"domain_id,omitempty"` + // Whether to mark the domain as a draft. If omitted on Create, the server + // applies a default; the resolved value is returned in `effective_draft`. + Draft *bool `json:"draft,omitempty"` + // Resolved draft state of the domain. + EffectiveDraft *bool `json:"effective_draft,omitempty"` + // Icon to display for the domain. + Icon *DomainIcon `json:"icon,omitempty"` + // Full resource name of the domain. The primary identifier for this resource. + // Format: `domains/{domain_id}` Identifies the domain on get, update, and + // delete. Not an input on create — to choose the id, set + // `CreateDomainRequest.domain_id`. + Name *string `json:"name,omitempty"` + // Domain ID of the parent. If absent, this is a top-level domain. If present, + // this domain is a subdomain of the specified parent. + ParentDomainId *string `json:"parent_domain_id,omitempty"` + // Short description (max 280 chars) + Subtitle *string `json:"subtitle,omitempty"` + // Governed tag key associated with this domain. + TagKey *string `json:"tag_key,omitempty"` + // Principal IDs of the technical owners (users, groups, or service principals). + TechnicalOwnerIds []int64 `json:"technical_owner_ids,omitempty"` + // Timestamp when the domain was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +// Icon configuration for a domain.. +type DomainIcon struct { + // Hex color code with # prefix (e.g., "#FF5733"). + Color *string `json:"color,omitempty"` + Name DomainIcon_Name `json:"name,omitempty"` +} + +type ListDomainsRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` + // Filter by parent domain. - Absent: return all domains regardless of + // hierarchy. - Present: return only direct children of the specified domain. + ParentDomainId *string `json:"parent_domain_id,omitempty"` +} + +type ListDomainsResponse struct { + Domains []Domain `json:"domains,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type UpdateDomainRequest struct { + Domain *Domain `json:"domain,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CreateDomainRequestToSDK converts the mirror to the sdk-go type. +func CreateDomainRequestToSDK(w *CreateDomainRequest) (*sdk.CreateDomainRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateDomainRequest{} + conv1, err := DomainToSDK(w.Domain) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDomainRequest.Domain", err) + } + out.Domain = conv1 + out.DomainId = w.DomainId + return out, nil +} + +// CreateDomainRequestFromSDK converts the sdk-go type to the mirror. +func CreateDomainRequestFromSDK(v *sdk.CreateDomainRequest) (*CreateDomainRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateDomainRequest{} + conv2, err := DomainFromSDK(v.Domain) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDomainRequest.Domain", err) + } + out.Domain = conv2 + out.DomainId = v.DomainId + return out, nil +} + +// DeleteDomainRequestToSDK converts the mirror to the sdk-go type. +func DeleteDomainRequestToSDK(w *DeleteDomainRequest) (*sdk.DeleteDomainRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteDomainRequest{} + out.Name = w.Name + out.Force = w.Force + return out, nil +} + +// DeleteDomainRequestFromSDK converts the sdk-go type to the mirror. +func DeleteDomainRequestFromSDK(v *sdk.DeleteDomainRequest) (*DeleteDomainRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteDomainRequest{} + out.Name = v.Name + out.Force = v.Force + return out, nil +} + +// DomainToSDK converts the mirror to the sdk-go type. +func DomainToSDK(w *Domain) (*sdk.Domain, error) { + if w == nil { + return nil, nil + } + out := &sdk.Domain{} + out.DomainId = w.DomainId + out.TagKey = w.TagKey + out.Draft = w.Draft + out.EffectiveDraft = w.EffectiveDraft + conv3, err := DomainIconToSDK(w.Icon) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Domain.Icon", err) + } + out.Icon = conv3 + out.Subtitle = w.Subtitle + out.Description = w.Description + out.CreateTime = w.CreateTime + out.TechnicalOwnerIds = w.TechnicalOwnerIds + out.BusinessOwnerIds = w.BusinessOwnerIds + out.ParentDomainId = w.ParentDomainId + out.Name = w.Name + out.UpdateTime = w.UpdateTime + return out, nil +} + +// DomainFromSDK converts the sdk-go type to the mirror. +func DomainFromSDK(v *sdk.Domain) (*Domain, error) { + if v == nil { + return nil, nil + } + out := &Domain{} + out.DomainId = v.DomainId + out.TagKey = v.TagKey + out.Draft = v.Draft + out.EffectiveDraft = v.EffectiveDraft + conv4, err := DomainIconFromSDK(v.Icon) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Domain.Icon", err) + } + out.Icon = conv4 + out.Subtitle = v.Subtitle + out.Description = v.Description + out.CreateTime = v.CreateTime + out.TechnicalOwnerIds = v.TechnicalOwnerIds + out.BusinessOwnerIds = v.BusinessOwnerIds + out.ParentDomainId = v.ParentDomainId + out.Name = v.Name + out.UpdateTime = v.UpdateTime + return out, nil +} + +// DomainIconToSDK converts the mirror to the sdk-go type. +func DomainIconToSDK(w *DomainIcon) (*sdk.DomainIcon, error) { + if w == nil { + return nil, nil + } + out := &sdk.DomainIcon{} + out.Name = w.Name + out.Color = w.Color + return out, nil +} + +// DomainIconFromSDK converts the sdk-go type to the mirror. +func DomainIconFromSDK(v *sdk.DomainIcon) (*DomainIcon, error) { + if v == nil { + return nil, nil + } + out := &DomainIcon{} + out.Name = v.Name + out.Color = v.Color + return out, nil +} + +// ListDomainsRequestToSDK converts the mirror to the sdk-go type. +func ListDomainsRequestToSDK(w *ListDomainsRequest) (*sdk.ListDomainsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDomainsRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + out.ParentDomainId = w.ParentDomainId + return out, nil +} + +// ListDomainsRequestFromSDK converts the sdk-go type to the mirror. +func ListDomainsRequestFromSDK(v *sdk.ListDomainsRequest) (*ListDomainsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListDomainsRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + out.ParentDomainId = v.ParentDomainId + return out, nil +} + +// ListDomainsResponseToSDK converts the mirror to the sdk-go type. +func ListDomainsResponseToSDK(w *ListDomainsResponse) (*sdk.ListDomainsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDomainsResponse{} + conv5, err := convertSlice(w.Domains, DomainToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDomainsResponse.Domains", err) + } + out.Domains = conv5 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListDomainsResponseFromSDK converts the sdk-go type to the mirror. +func ListDomainsResponseFromSDK(v *sdk.ListDomainsResponse) (*ListDomainsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListDomainsResponse{} + conv6, err := convertSlice(v.Domains, DomainFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDomainsResponse.Domains", err) + } + out.Domains = conv6 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// UpdateDomainRequestToSDK converts the mirror to the sdk-go type. +func UpdateDomainRequestToSDK(w *UpdateDomainRequest) (*sdk.UpdateDomainRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateDomainRequest{} + conv7, err := DomainToSDK(w.Domain) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDomainRequest.Domain", err) + } + out.Domain = conv7 + mask8, err := fieldMaskFromString[sdk.Domain](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDomainRequest.UpdateMask", err) + } + out.UpdateMask = mask8 + return out, nil +} + +// UpdateDomainRequestFromSDK converts the sdk-go type to the mirror. +func UpdateDomainRequestFromSDK(v *sdk.UpdateDomainRequest) (*UpdateDomainRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateDomainRequest{} + conv9, err := DomainFromSDK(v.Domain) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDomainRequest.Domain", err) + } + out.Domain = conv9 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/environments/v1/types.generated.go b/libs/sdktypes/environments/v1/types.generated.go new file mode 100644 index 00000000000..cd0b1d631e2 --- /dev/null +++ b/libs/sdktypes/environments/v1/types.generated.go @@ -0,0 +1,669 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/environments/v1. DO NOT EDIT. + +package environments + +import ( + json "encoding/json" + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/environments/v1" + strings "strings" +) + +type ( + BaseEnvironmentType = sdk.BaseEnvironmentType + ErrorCode = sdk.ErrorCode + WorkspaceBaseEnvironmentCache_Status = sdk.WorkspaceBaseEnvironmentCache_Status +) + +const ( + BaseEnvironmentType_Unspecified = sdk.BaseEnvironmentType_Unspecified + BaseEnvironmentType_Cpu = sdk.BaseEnvironmentType_Cpu + BaseEnvironmentType_Gpu = sdk.BaseEnvironmentType_Gpu + ErrorCode_Unspecified = sdk.ErrorCode_Unspecified + ErrorCode_InternalError = sdk.ErrorCode_InternalError + ErrorCode_TemporarilyUnavailable = sdk.ErrorCode_TemporarilyUnavailable + ErrorCode_IoError = sdk.ErrorCode_IoError + ErrorCode_BadRequest = sdk.ErrorCode_BadRequest + ErrorCode_ServiceUnderMaintenance = sdk.ErrorCode_ServiceUnderMaintenance + ErrorCode_WorkspaceTemporarilyUnavailable = sdk.ErrorCode_WorkspaceTemporarilyUnavailable + ErrorCode_DeadlineExceeded = sdk.ErrorCode_DeadlineExceeded + ErrorCode_Cancelled = sdk.ErrorCode_Cancelled + ErrorCode_ResourceExhausted = sdk.ErrorCode_ResourceExhausted + ErrorCode_Aborted = sdk.ErrorCode_Aborted + ErrorCode_NotFound = sdk.ErrorCode_NotFound + ErrorCode_AlreadyExists = sdk.ErrorCode_AlreadyExists + ErrorCode_Unauthenticated = sdk.ErrorCode_Unauthenticated + ErrorCode_Unavailable = sdk.ErrorCode_Unavailable + ErrorCode_InvalidParameterValue = sdk.ErrorCode_InvalidParameterValue + ErrorCode_EndpointNotFound = sdk.ErrorCode_EndpointNotFound + ErrorCode_MalformedRequest = sdk.ErrorCode_MalformedRequest + ErrorCode_InvalidState = sdk.ErrorCode_InvalidState + ErrorCode_PermissionDenied = sdk.ErrorCode_PermissionDenied + ErrorCode_FeatureDisabled = sdk.ErrorCode_FeatureDisabled + ErrorCode_CustomerUnauthorized = sdk.ErrorCode_CustomerUnauthorized + ErrorCode_RequestLimitExceeded = sdk.ErrorCode_RequestLimitExceeded + ErrorCode_ResourceConflict = sdk.ErrorCode_ResourceConflict + ErrorCode_UnparseableHttpError = sdk.ErrorCode_UnparseableHttpError + ErrorCode_NotImplemented = sdk.ErrorCode_NotImplemented + ErrorCode_DataLoss = sdk.ErrorCode_DataLoss + ErrorCode_InvalidStateTransition = sdk.ErrorCode_InvalidStateTransition + ErrorCode_CouldNotAcquireLock = sdk.ErrorCode_CouldNotAcquireLock + ErrorCode_ResourceAlreadyExists = sdk.ErrorCode_ResourceAlreadyExists + ErrorCode_ResourceDoesNotExist = sdk.ErrorCode_ResourceDoesNotExist + ErrorCode_QuotaExceeded = sdk.ErrorCode_QuotaExceeded + ErrorCode_MaxBlockSizeExceeded = sdk.ErrorCode_MaxBlockSizeExceeded + ErrorCode_MaxReadSizeExceeded = sdk.ErrorCode_MaxReadSizeExceeded + ErrorCode_PartialDelete = sdk.ErrorCode_PartialDelete + ErrorCode_MaxListSizeExceeded = sdk.ErrorCode_MaxListSizeExceeded + ErrorCode_DryRunFailed = sdk.ErrorCode_DryRunFailed + ErrorCode_ResourceLimitExceeded = sdk.ErrorCode_ResourceLimitExceeded + ErrorCode_DirectoryNotEmpty = sdk.ErrorCode_DirectoryNotEmpty + ErrorCode_DirectoryProtected = sdk.ErrorCode_DirectoryProtected + ErrorCode_MaxNotebookSizeExceeded = sdk.ErrorCode_MaxNotebookSizeExceeded + ErrorCode_MaxChildNodeSizeExceeded = sdk.ErrorCode_MaxChildNodeSizeExceeded + ErrorCode_SearchQueryTooLong = sdk.ErrorCode_SearchQueryTooLong + ErrorCode_SearchQueryTooShort = sdk.ErrorCode_SearchQueryTooShort + ErrorCode_ManagedResourceGroupDoesNotExist = sdk.ErrorCode_ManagedResourceGroupDoesNotExist + ErrorCode_PermissionNotPropagated = sdk.ErrorCode_PermissionNotPropagated + ErrorCode_DeploymentTimeout = sdk.ErrorCode_DeploymentTimeout + ErrorCode_GitConflict = sdk.ErrorCode_GitConflict + ErrorCode_GitUnknownRef = sdk.ErrorCode_GitUnknownRef + ErrorCode_GitSensitiveTokenDetected = sdk.ErrorCode_GitSensitiveTokenDetected + ErrorCode_GitUrlNotOnAllowList = sdk.ErrorCode_GitUrlNotOnAllowList + ErrorCode_GitRemoteError = sdk.ErrorCode_GitRemoteError + ErrorCode_ProjectsOperationTimeout = sdk.ErrorCode_ProjectsOperationTimeout + ErrorCode_IpynbFileInRepo = sdk.ErrorCode_IpynbFileInRepo + ErrorCode_InsecurePartnerResponse = sdk.ErrorCode_InsecurePartnerResponse + ErrorCode_MalformedPartnerResponse = sdk.ErrorCode_MalformedPartnerResponse + ErrorCode_MetastoreDoesNotExist = sdk.ErrorCode_MetastoreDoesNotExist + ErrorCode_DacDoesNotExist = sdk.ErrorCode_DacDoesNotExist + ErrorCode_CatalogDoesNotExist = sdk.ErrorCode_CatalogDoesNotExist + ErrorCode_SchemaDoesNotExist = sdk.ErrorCode_SchemaDoesNotExist + ErrorCode_TableDoesNotExist = sdk.ErrorCode_TableDoesNotExist + ErrorCode_ShareDoesNotExist = sdk.ErrorCode_ShareDoesNotExist + ErrorCode_RecipientDoesNotExist = sdk.ErrorCode_RecipientDoesNotExist + ErrorCode_StorageCredentialDoesNotExist = sdk.ErrorCode_StorageCredentialDoesNotExist + ErrorCode_ExternalLocationDoesNotExist = sdk.ErrorCode_ExternalLocationDoesNotExist + ErrorCode_PrincipalDoesNotExist = sdk.ErrorCode_PrincipalDoesNotExist + ErrorCode_ProviderDoesNotExist = sdk.ErrorCode_ProviderDoesNotExist + ErrorCode_MetastoreAlreadyExists = sdk.ErrorCode_MetastoreAlreadyExists + ErrorCode_DacAlreadyExists = sdk.ErrorCode_DacAlreadyExists + ErrorCode_CatalogAlreadyExists = sdk.ErrorCode_CatalogAlreadyExists + ErrorCode_SchemaAlreadyExists = sdk.ErrorCode_SchemaAlreadyExists + ErrorCode_TableAlreadyExists = sdk.ErrorCode_TableAlreadyExists + ErrorCode_ShareAlreadyExists = sdk.ErrorCode_ShareAlreadyExists + ErrorCode_RecipientAlreadyExists = sdk.ErrorCode_RecipientAlreadyExists + ErrorCode_StorageCredentialAlreadyExists = sdk.ErrorCode_StorageCredentialAlreadyExists + ErrorCode_ExternalLocationAlreadyExists = sdk.ErrorCode_ExternalLocationAlreadyExists + ErrorCode_ProviderAlreadyExists = sdk.ErrorCode_ProviderAlreadyExists + ErrorCode_CatalogNotEmpty = sdk.ErrorCode_CatalogNotEmpty + ErrorCode_SchemaNotEmpty = sdk.ErrorCode_SchemaNotEmpty + ErrorCode_MetastoreNotEmpty = sdk.ErrorCode_MetastoreNotEmpty + ErrorCode_ProviderShareNotAccessible = sdk.ErrorCode_ProviderShareNotAccessible + WorkspaceBaseEnvironmentCache_Status_Unspecified = sdk.WorkspaceBaseEnvironmentCache_Status_Unspecified + WorkspaceBaseEnvironmentCache_Status_Pending = sdk.WorkspaceBaseEnvironmentCache_Status_Pending + WorkspaceBaseEnvironmentCache_Status_Created = sdk.WorkspaceBaseEnvironmentCache_Status_Created + WorkspaceBaseEnvironmentCache_Status_Failed = sdk.WorkspaceBaseEnvironmentCache_Status_Failed + WorkspaceBaseEnvironmentCache_Status_Expired = sdk.WorkspaceBaseEnvironmentCache_Status_Expired + WorkspaceBaseEnvironmentCache_Status_Invalid = sdk.WorkspaceBaseEnvironmentCache_Status_Invalid + WorkspaceBaseEnvironmentCache_Status_Refreshing = sdk.WorkspaceBaseEnvironmentCache_Status_Refreshing +) + +// Databricks Error that is returned by all Databricks APIs.. +type ApiError struct { + Details []json.RawMessage `json:"details,omitempty"` + ErrorCode ErrorCode `json:"error_code,omitempty"` + Message *string `json:"message,omitempty"` + StackTrace *string `json:"stack_trace,omitempty"` +} + +// Request message for CreateWorkspaceBaseEnvironment.. +type CreateWorkspaceBaseEnvironmentRequest struct { + // A unique identifier for this request. A random UUID is recommended. This + // request is only idempotent if a request_id is provided. + RequestId *string `json:"request_id,omitempty"` + // Required. The workspace base environment to create. + WorkspaceBaseEnvironment *WorkspaceBaseEnvironment `json:"workspace_base_environment,omitempty"` + // The ID to use for the workspace base environment, which will become the final + // component of the resource name. This value should be 4-63 characters, and + // valid characters are /[a-z][0-9]-/. + WorkspaceBaseEnvironmentId *string `json:"workspace_base_environment_id,omitempty"` +} + +// A singleton resource representing the default workspace base environment +// configuration. This resource contains the workspace base environments that +// are used as defaults for serverless notebooks and jobs in the workspace, for +// both CPU and GPU compute types.. +type DefaultWorkspaceBaseEnvironment struct { + // The default workspace base environment for CPU compute. Format: + // workspace-base-environments/{workspace_base_environment} + CpuWorkspaceBaseEnvironment *string `json:"cpu_workspace_base_environment,omitempty"` + // The default workspace base environment for GPU compute. Format: + // workspace-base-environments/{workspace_base_environment} + GpuWorkspaceBaseEnvironment *string `json:"gpu_workspace_base_environment,omitempty"` + // The resource name of this singleton resource. Format: + // default-workspace-base-environment + Name *string `json:"name,omitempty"` +} + +// Environment specification for a WorkspaceBaseEnvironment. Contains the +// environment version and dependencies configuration.. +type EnvironmentSpec struct { + // List of pip dependencies, as supported by the version of pip in this + // environment. Each dependency is a valid pip requirements file line per + // https://pip.pypa.io/en/stable/reference/requirements-file-format/. Allowed + // dependencies include a requirement specifier, an archive URL, a local project + // path (such as WSFS or UC Volumes in ), or a VCS project URL. + Dependencies []string `json:"dependencies,omitempty"` + // Environment version used by the environment. Each version comes with a + // specific Python version and a set of Python packages. The version is a + // string, consisting of an integer. + EnvironmentVersion *string `json:"environment_version,omitempty"` +} + +// Request message for ListWorkspaceBaseEnvironments.. +type ListWorkspaceBaseEnvironmentsRequest struct { + // The maximum number of environments to return per page. Default is 1000. + PageSize *int `json:"page_size,omitempty"` + // Page token for pagination. Received from a previous + // ListWorkspaceBaseEnvironments call. + PageToken *string `json:"page_token,omitempty"` +} + +// Response message for ListWorkspaceBaseEnvironments.. +type ListWorkspaceBaseEnvironmentsResponse struct { + // Token to retrieve the next page of results. Empty if there are no more + // results. + NextPageToken *string `json:"next_page_token,omitempty"` + // The list of workspace base environments. + WorkspaceBaseEnvironments []WorkspaceBaseEnvironment `json:"workspace_base_environments,omitempty"` +} + +// This resource represents a long-running operation that is the result of a +// network API call.. +type Operation struct { + // If the value is `false`, it means the operation is still in progress. If + // `true`, the operation is completed, and either `error` or `response` is + // available. + Done *bool `json:"done,omitempty"` + Error *ApiError `json:"error,omitempty"` + // Service-specific metadata associated with the operation. It typically + // contains progress information and common metadata such as create time. Some + // services might not provide such metadata. + Metadata json.RawMessage `json:"metadata,omitempty"` + // The server-assigned name, which is only unique within the same service that + // originally returns it. If you use the default HTTP mapping, the `name` should + // be a resource name ending with `operations/{unique_id}`. + Name *string `json:"name,omitempty"` + Response json.RawMessage `json:"response,omitempty"` +} + +// Request message for RefreshWorkspaceBaseEnvironments.. +type RefreshWorkspaceBaseEnvironmentRequest struct { + // Required. The resource name of the workspace base environment to delete. + // Format: workspace-base-environments/{workspace_base_environment} + Name *string `json:"name,omitempty"` +} + +// Request message for UpdateDefaultWorkspaceBaseEnvironment.. +type UpdateDefaultWorkspaceBaseEnvironmentRequest struct { + // Required. The default workspace base environment configuration to update. + DefaultWorkspaceBaseEnvironment *DefaultWorkspaceBaseEnvironment `json:"default_workspace_base_environment,omitempty"` + // Field mask specifying which fields to update. Use comma as the separator for + // multiple fields (no space). The special value '*' indicates that all fields + // should be updated (full replacement). Valid field paths: + // cpu_workspace_base_environment, gpu_workspace_base_environment + // + // To unset one or both defaults, include the field path(s) in the mask and omit + // them from the request body. To unset both, you must list both paths + // explicitly — the wildcard '*' cannot be used to unset fields. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Request message for UpdateWorkspaceBaseEnvironment.. +type UpdateWorkspaceBaseEnvironmentRequest struct { + Name *string `json:"name,omitempty"` + // Required. The workspace base environment with updated fields. The name field + // is used to identify the environment to update. + WorkspaceBaseEnvironment *WorkspaceBaseEnvironment `json:"workspace_base_environment,omitempty"` +} + +// A WorkspaceBaseEnvironment defines a workspace-level environment +// configuration consisting of an environment version and a list of +// dependencies.. +type WorkspaceBaseEnvironment struct { + // The type of base environment (CPU or GPU). + BaseEnvironmentType BaseEnvironmentType `json:"base_environment_type,omitempty"` + // Timestamp when the environment was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // User ID of the creator. + CreatorUserId *string `json:"creator_user_id,omitempty"` + // Human-readable display name for the workspace base environment. + DisplayName *string `json:"display_name,omitempty"` + // The WSFS or UC Volumes path to the environment YAML file. + Filepath *string `json:"filepath,omitempty"` + // Whether this is the default environment for the workspace. + IsDefault *bool `json:"is_default,omitempty"` + // User ID of the last user who updated the environment. + LastUpdatedUserId *string `json:"last_updated_user_id,omitempty"` + // Status message providing additional details about the environment status. + Message *string `json:"message,omitempty"` + // The resource name of the workspace base environment. Format: + // workspace-base-environments/{workspace-base-environment} + Name *string `json:"name,omitempty"` + // The environment specification containing version and dependencies. + Spec *EnvironmentSpec `json:"spec,omitempty"` + // The status of the materialized workspace base environment. + Status WorkspaceBaseEnvironmentCache_Status `json:"status,omitempty"` + // Timestamp when the environment was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +// Metadata for the WorkspaceBaseEnvironment long-running operations. This +// message tracks the progress of the workspace base environment long-running +// process.. +type WorkspaceBaseEnvironmentOperationMetadata struct { +} + +// ApiErrorToSDK converts the mirror to the sdk-go type. +func ApiErrorToSDK(w *ApiError) (*sdk.ApiError, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApiError{} + out.ErrorCode = w.ErrorCode + out.Message = w.Message + out.StackTrace = w.StackTrace + out.Details = w.Details + return out, nil +} + +// ApiErrorFromSDK converts the sdk-go type to the mirror. +func ApiErrorFromSDK(v *sdk.ApiError) (*ApiError, error) { + if v == nil { + return nil, nil + } + out := &ApiError{} + out.ErrorCode = v.ErrorCode + out.Message = v.Message + out.StackTrace = v.StackTrace + out.Details = v.Details + return out, nil +} + +// CreateWorkspaceBaseEnvironmentRequestToSDK converts the mirror to the sdk-go type. +func CreateWorkspaceBaseEnvironmentRequestToSDK(w *CreateWorkspaceBaseEnvironmentRequest) (*sdk.CreateWorkspaceBaseEnvironmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateWorkspaceBaseEnvironmentRequest{} + conv1, err := WorkspaceBaseEnvironmentToSDK(w.WorkspaceBaseEnvironment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateWorkspaceBaseEnvironmentRequest.WorkspaceBaseEnvironment", err) + } + out.WorkspaceBaseEnvironment = conv1 + out.WorkspaceBaseEnvironmentId = w.WorkspaceBaseEnvironmentId + out.RequestId = w.RequestId + return out, nil +} + +// CreateWorkspaceBaseEnvironmentRequestFromSDK converts the sdk-go type to the mirror. +func CreateWorkspaceBaseEnvironmentRequestFromSDK(v *sdk.CreateWorkspaceBaseEnvironmentRequest) (*CreateWorkspaceBaseEnvironmentRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateWorkspaceBaseEnvironmentRequest{} + conv2, err := WorkspaceBaseEnvironmentFromSDK(v.WorkspaceBaseEnvironment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateWorkspaceBaseEnvironmentRequest.WorkspaceBaseEnvironment", err) + } + out.WorkspaceBaseEnvironment = conv2 + out.WorkspaceBaseEnvironmentId = v.WorkspaceBaseEnvironmentId + out.RequestId = v.RequestId + return out, nil +} + +// DefaultWorkspaceBaseEnvironmentToSDK converts the mirror to the sdk-go type. +func DefaultWorkspaceBaseEnvironmentToSDK(w *DefaultWorkspaceBaseEnvironment) (*sdk.DefaultWorkspaceBaseEnvironment, error) { + if w == nil { + return nil, nil + } + out := &sdk.DefaultWorkspaceBaseEnvironment{} + out.Name = w.Name + out.CpuWorkspaceBaseEnvironment = w.CpuWorkspaceBaseEnvironment + out.GpuWorkspaceBaseEnvironment = w.GpuWorkspaceBaseEnvironment + return out, nil +} + +// DefaultWorkspaceBaseEnvironmentFromSDK converts the sdk-go type to the mirror. +func DefaultWorkspaceBaseEnvironmentFromSDK(v *sdk.DefaultWorkspaceBaseEnvironment) (*DefaultWorkspaceBaseEnvironment, error) { + if v == nil { + return nil, nil + } + out := &DefaultWorkspaceBaseEnvironment{} + out.Name = v.Name + out.CpuWorkspaceBaseEnvironment = v.CpuWorkspaceBaseEnvironment + out.GpuWorkspaceBaseEnvironment = v.GpuWorkspaceBaseEnvironment + return out, nil +} + +// EnvironmentSpecToSDK converts the mirror to the sdk-go type. +func EnvironmentSpecToSDK(w *EnvironmentSpec) (*sdk.EnvironmentSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnvironmentSpec{} + out.Dependencies = w.Dependencies + out.EnvironmentVersion = w.EnvironmentVersion + return out, nil +} + +// EnvironmentSpecFromSDK converts the sdk-go type to the mirror. +func EnvironmentSpecFromSDK(v *sdk.EnvironmentSpec) (*EnvironmentSpec, error) { + if v == nil { + return nil, nil + } + out := &EnvironmentSpec{} + out.Dependencies = v.Dependencies + out.EnvironmentVersion = v.EnvironmentVersion + return out, nil +} + +// ListWorkspaceBaseEnvironmentsRequestToSDK converts the mirror to the sdk-go type. +func ListWorkspaceBaseEnvironmentsRequestToSDK(w *ListWorkspaceBaseEnvironmentsRequest) (*sdk.ListWorkspaceBaseEnvironmentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListWorkspaceBaseEnvironmentsRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListWorkspaceBaseEnvironmentsRequestFromSDK converts the sdk-go type to the mirror. +func ListWorkspaceBaseEnvironmentsRequestFromSDK(v *sdk.ListWorkspaceBaseEnvironmentsRequest) (*ListWorkspaceBaseEnvironmentsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListWorkspaceBaseEnvironmentsRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListWorkspaceBaseEnvironmentsResponseToSDK converts the mirror to the sdk-go type. +func ListWorkspaceBaseEnvironmentsResponseToSDK(w *ListWorkspaceBaseEnvironmentsResponse) (*sdk.ListWorkspaceBaseEnvironmentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListWorkspaceBaseEnvironmentsResponse{} + conv3, err := convertSlice(w.WorkspaceBaseEnvironments, WorkspaceBaseEnvironmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListWorkspaceBaseEnvironmentsResponse.WorkspaceBaseEnvironments", err) + } + out.WorkspaceBaseEnvironments = conv3 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListWorkspaceBaseEnvironmentsResponseFromSDK converts the sdk-go type to the mirror. +func ListWorkspaceBaseEnvironmentsResponseFromSDK(v *sdk.ListWorkspaceBaseEnvironmentsResponse) (*ListWorkspaceBaseEnvironmentsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListWorkspaceBaseEnvironmentsResponse{} + conv4, err := convertSlice(v.WorkspaceBaseEnvironments, WorkspaceBaseEnvironmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListWorkspaceBaseEnvironmentsResponse.WorkspaceBaseEnvironments", err) + } + out.WorkspaceBaseEnvironments = conv4 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// OperationToSDK converts the mirror to the sdk-go type. +func OperationToSDK(w *Operation) (*sdk.Operation, error) { + if w == nil { + return nil, nil + } + out := &sdk.Operation{} + out.Name = w.Name + out.Metadata = w.Metadata + out.Done = w.Done + { + var members []string + if w.Error != nil { + members = append(members, "error") + } + if w.Response != nil { + members = append(members, "response") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Error != nil: + conv5, err := ApiErrorToSDK(w.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Operation.Result", err) + } + out.Result = &sdk.Operation_Result_Error{Error: *conv5} + case w.Response != nil: + out.Result = &sdk.Operation_Result_Response{Response: w.Response} + } + return out, nil +} + +// OperationFromSDK converts the sdk-go type to the mirror. +func OperationFromSDK(v *sdk.Operation) (*Operation, error) { + if v == nil { + return nil, nil + } + out := &Operation{} + out.Name = v.Name + out.Metadata = v.Metadata + out.Done = v.Done + switch value := v.Result.(type) { + case *sdk.Operation_Result_Error: + if value != nil { + conv6, err := ApiErrorFromSDK(&value.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Operation.Result", err) + } + out.Error = conv6 + } + case *sdk.Operation_Result_Response: + if value != nil { + out.Response = value.Response + } + } + return out, nil +} + +// RefreshWorkspaceBaseEnvironmentRequestToSDK converts the mirror to the sdk-go type. +func RefreshWorkspaceBaseEnvironmentRequestToSDK(w *RefreshWorkspaceBaseEnvironmentRequest) (*sdk.RefreshWorkspaceBaseEnvironmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RefreshWorkspaceBaseEnvironmentRequest{} + out.Name = w.Name + return out, nil +} + +// RefreshWorkspaceBaseEnvironmentRequestFromSDK converts the sdk-go type to the mirror. +func RefreshWorkspaceBaseEnvironmentRequestFromSDK(v *sdk.RefreshWorkspaceBaseEnvironmentRequest) (*RefreshWorkspaceBaseEnvironmentRequest, error) { + if v == nil { + return nil, nil + } + out := &RefreshWorkspaceBaseEnvironmentRequest{} + out.Name = v.Name + return out, nil +} + +// UpdateDefaultWorkspaceBaseEnvironmentRequestToSDK converts the mirror to the sdk-go type. +func UpdateDefaultWorkspaceBaseEnvironmentRequestToSDK(w *UpdateDefaultWorkspaceBaseEnvironmentRequest) (*sdk.UpdateDefaultWorkspaceBaseEnvironmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateDefaultWorkspaceBaseEnvironmentRequest{} + conv7, err := DefaultWorkspaceBaseEnvironmentToSDK(w.DefaultWorkspaceBaseEnvironment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDefaultWorkspaceBaseEnvironmentRequest.DefaultWorkspaceBaseEnvironment", err) + } + out.DefaultWorkspaceBaseEnvironment = conv7 + mask8, err := fieldMaskFromString[sdk.DefaultWorkspaceBaseEnvironment](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDefaultWorkspaceBaseEnvironmentRequest.UpdateMask", err) + } + out.UpdateMask = mask8 + return out, nil +} + +// UpdateDefaultWorkspaceBaseEnvironmentRequestFromSDK converts the sdk-go type to the mirror. +func UpdateDefaultWorkspaceBaseEnvironmentRequestFromSDK(v *sdk.UpdateDefaultWorkspaceBaseEnvironmentRequest) (*UpdateDefaultWorkspaceBaseEnvironmentRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateDefaultWorkspaceBaseEnvironmentRequest{} + conv9, err := DefaultWorkspaceBaseEnvironmentFromSDK(v.DefaultWorkspaceBaseEnvironment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDefaultWorkspaceBaseEnvironmentRequest.DefaultWorkspaceBaseEnvironment", err) + } + out.DefaultWorkspaceBaseEnvironment = conv9 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateWorkspaceBaseEnvironmentRequestToSDK converts the mirror to the sdk-go type. +func UpdateWorkspaceBaseEnvironmentRequestToSDK(w *UpdateWorkspaceBaseEnvironmentRequest) (*sdk.UpdateWorkspaceBaseEnvironmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateWorkspaceBaseEnvironmentRequest{} + out.Name = w.Name + conv10, err := WorkspaceBaseEnvironmentToSDK(w.WorkspaceBaseEnvironment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceBaseEnvironmentRequest.WorkspaceBaseEnvironment", err) + } + out.WorkspaceBaseEnvironment = conv10 + return out, nil +} + +// UpdateWorkspaceBaseEnvironmentRequestFromSDK converts the sdk-go type to the mirror. +func UpdateWorkspaceBaseEnvironmentRequestFromSDK(v *sdk.UpdateWorkspaceBaseEnvironmentRequest) (*UpdateWorkspaceBaseEnvironmentRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateWorkspaceBaseEnvironmentRequest{} + out.Name = v.Name + conv11, err := WorkspaceBaseEnvironmentFromSDK(v.WorkspaceBaseEnvironment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceBaseEnvironmentRequest.WorkspaceBaseEnvironment", err) + } + out.WorkspaceBaseEnvironment = conv11 + return out, nil +} + +// WorkspaceBaseEnvironmentToSDK converts the mirror to the sdk-go type. +func WorkspaceBaseEnvironmentToSDK(w *WorkspaceBaseEnvironment) (*sdk.WorkspaceBaseEnvironment, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkspaceBaseEnvironment{} + out.Name = w.Name + out.DisplayName = w.DisplayName + out.Filepath = w.Filepath + out.CreatorUserId = w.CreatorUserId + out.CreateTime = w.CreateTime + out.LastUpdatedUserId = w.LastUpdatedUserId + out.UpdateTime = w.UpdateTime + out.Status = w.Status + out.Message = w.Message + out.IsDefault = w.IsDefault + out.BaseEnvironmentType = w.BaseEnvironmentType + conv12, err := EnvironmentSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WorkspaceBaseEnvironment.Spec", err) + } + out.Spec = conv12 + return out, nil +} + +// WorkspaceBaseEnvironmentFromSDK converts the sdk-go type to the mirror. +func WorkspaceBaseEnvironmentFromSDK(v *sdk.WorkspaceBaseEnvironment) (*WorkspaceBaseEnvironment, error) { + if v == nil { + return nil, nil + } + out := &WorkspaceBaseEnvironment{} + out.Name = v.Name + out.DisplayName = v.DisplayName + out.Filepath = v.Filepath + out.CreatorUserId = v.CreatorUserId + out.CreateTime = v.CreateTime + out.LastUpdatedUserId = v.LastUpdatedUserId + out.UpdateTime = v.UpdateTime + out.Status = v.Status + out.Message = v.Message + out.IsDefault = v.IsDefault + out.BaseEnvironmentType = v.BaseEnvironmentType + conv13, err := EnvironmentSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WorkspaceBaseEnvironment.Spec", err) + } + out.Spec = conv13 + return out, nil +} + +// WorkspaceBaseEnvironmentOperationMetadataToSDK converts the mirror to the sdk-go type. +func WorkspaceBaseEnvironmentOperationMetadataToSDK(w *WorkspaceBaseEnvironmentOperationMetadata) (*sdk.WorkspaceBaseEnvironmentOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkspaceBaseEnvironmentOperationMetadata{} + return out, nil +} + +// WorkspaceBaseEnvironmentOperationMetadataFromSDK converts the sdk-go type to the mirror. +func WorkspaceBaseEnvironmentOperationMetadataFromSDK(v *sdk.WorkspaceBaseEnvironmentOperationMetadata) (*WorkspaceBaseEnvironmentOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &WorkspaceBaseEnvironmentOperationMetadata{} + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/experiments/v1/types.generated.go b/libs/sdktypes/experiments/v1/types.generated.go new file mode 100644 index 00000000000..8d3fc77c167 --- /dev/null +++ b/libs/sdktypes/experiments/v1/types.generated.go @@ -0,0 +1,2990 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/experiments/v1. DO NOT EDIT. + +package experiments + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/experiments/v1" + + strings "strings" +) + +type ( + LoggedModelStatus = sdk.LoggedModelStatus + RunStatus = sdk.RunStatus + ViewType = sdk.ViewType +) + +const ( + LoggedModelStatus_Unspecified = sdk.LoggedModelStatus_Unspecified + LoggedModelStatus_LoggedModelPending = sdk.LoggedModelStatus_LoggedModelPending + LoggedModelStatus_LoggedModelReady = sdk.LoggedModelStatus_LoggedModelReady + LoggedModelStatus_LoggedModelUploadFailed = sdk.LoggedModelStatus_LoggedModelUploadFailed + RunStatus_Unspecified = sdk.RunStatus_Unspecified + RunStatus_Running = sdk.RunStatus_Running + RunStatus_Scheduled = sdk.RunStatus_Scheduled + RunStatus_Finished = sdk.RunStatus_Finished + RunStatus_Failed = sdk.RunStatus_Failed + RunStatus_Killed = sdk.RunStatus_Killed + ViewType_Unspecified = sdk.ViewType_Unspecified + ViewType_ActiveOnly = sdk.ViewType_ActiveOnly + ViewType_DeletedOnly = sdk.ViewType_DeletedOnly + ViewType_All = sdk.ViewType_All +) + +type CreateExperimentRequest struct { + // Location where all artifacts for the experiment are stored. If not provided, + // the remote server will select an appropriate default. + ArtifactLocation *string `json:"artifact_location,omitempty"` + // Experiment name. + Name *string `json:"name,omitempty"` + // A collection of tags to set on the experiment. Maximum tag size and number of + // tags per request depends on the storage backend. All storage backends are + // guaranteed to support tag keys up to 250 bytes in size and tag values up to + // 5000 bytes in size. All storage backends are also guaranteed to support up to + // 20 tags per request. + Tags []ExperimentTag `json:"tags,omitempty"` + // The location where the experiment's traces are stored. When set, the + // underlying storage is provisioned and the experiment's traces are routed to + // it. When unset, traces are stored in the default MLflow backend. This field + // cannot be updated after the experiment is created. + TraceLocation *ExperimentTraceLocation `json:"trace_location,omitempty"` +} + +type CreateExperimentResponse struct { + // Unique identifier for the experiment. + ExperimentId *string `json:"experiment_id,omitempty"` +} + +type CreateLoggedModelRequest struct { + // The ID of the experiment that owns the model. + ExperimentId *string `json:"experiment_id,omitempty"` + // The type of the model, such as ``"Agent"``, ``"Classifier"``, ``"LLM"``. + ModelType *string `json:"model_type,omitempty"` + // The name of the model (optional). If not specified one will be generated. + Name *string `json:"name,omitempty"` + // Parameters attached to the model. + Params []LoggedModelParameter `json:"params,omitempty"` + // The ID of the run that created the model. + SourceRunId *string `json:"source_run_id,omitempty"` + // Tags attached to the model. + Tags []LoggedModelTag `json:"tags,omitempty"` +} + +type CreateLoggedModelResponse struct { + // The newly created logged model. + Model *LoggedModel `json:"model,omitempty"` +} + +type CreateRunRequest struct { + // ID of the associated experiment. + ExperimentId *string `json:"experiment_id,omitempty"` + // The name of the run. + RunName *string `json:"run_name,omitempty"` + // Unix timestamp in milliseconds of when the run started. + StartTime *int64 `json:"start_time,omitempty"` + // Additional metadata for run. + Tags []RunTag `json:"tags,omitempty"` + // ID of the user executing the run. This field is deprecated as of MLflow 1.0, + // and will be removed in a future MLflow release. Use 'mlflow.user' tag + // instead. + UserId *string `json:"user_id,omitempty"` +} + +type CreateRunResponse struct { + // The newly created run. + Run *Run `json:"run,omitempty"` +} + +// Dataset. Represents a reference to data used for training, testing, or +// evaluation during the model development process.. +type Dataset struct { + // Dataset digest, e.g. an md5 hash of the dataset that uniquely identifies it + // within datasets of the same name. + Digest *string `json:"digest,omitempty"` + // The name of the dataset. E.g. “my.uc.table@2” “nyc-taxi-dataset”, + // “fantastic-elk-3” + Name *string `json:"name,omitempty"` + // The profile of the dataset. Summary statistics for the dataset, such as the + // number of rows in a table, the mean / std / mode of each column in a table, + // or the number of elements in an array. + Profile *string `json:"profile,omitempty"` + // The schema of the dataset. E.g., MLflow ColSpec JSON for a dataframe, MLflow + // TensorSpec JSON for an ndarray, or another schema format. + Schema *string `json:"schema,omitempty"` + // Source information for the dataset. Note that the source may not exactly + // reproduce the dataset if it was transformed / modified before use with + // MLflow. + Source *string `json:"source,omitempty"` + // The type of the dataset source, e.g. ‘databricks-uc-table’, ‘DBFS’, + // ‘S3’, ... + SourceType *string `json:"source_type,omitempty"` +} + +// DatasetInput. Represents a dataset and input tags.. +type DatasetInput struct { + // The dataset being used as a Run input. + Dataset *Dataset `json:"dataset,omitempty"` + // A list of tags for the dataset input, e.g. a “context” tag with value + // “training” + Tags []InputTag `json:"tags,omitempty"` +} + +type DeleteExperimentRequest struct { + // ID of the associated experiment. + ExperimentId *string `json:"experiment_id,omitempty"` +} + +type DeleteRunRequest struct { + // ID of the run to delete. + RunId *string `json:"run_id,omitempty"` +} + +type DeleteRunsRequest struct { + // The ID of the experiment containing the runs to delete. + ExperimentId *string `json:"experiment_id,omitempty"` + // An optional positive integer indicating the maximum number of runs to delete. + // The maximum allowed value for max_runs is 10000. + MaxRuns *int `json:"max_runs,omitempty"` + // The maximum creation timestamp in milliseconds since the UNIX epoch for + // deleting runs. Only runs created prior to or at this timestamp are deleted. + MaxTimestampMillis *int64 `json:"max_timestamp_millis,omitempty"` +} + +type DeleteRunsResponse struct { + // The number of runs deleted. + RunsDeleted *int `json:"runs_deleted,omitempty"` +} + +type DeleteTagRequest struct { + // Name of the tag. Maximum size is 255 bytes. Must be provided. + Key *string `json:"key,omitempty"` + // ID of the run that the tag was logged under. Must be provided. + RunId *string `json:"run_id,omitempty"` +} + +// An experiment and its metadata.. +type Experiment struct { + // Location where artifacts for the experiment are stored. + ArtifactLocation *string `json:"artifact_location,omitempty"` + // Creation time + CreationTime *int64 `json:"creation_time,omitempty"` + // Unique identifier for the experiment. + ExperimentId *string `json:"experiment_id,omitempty"` + // Last update time + LastUpdateTime *int64 `json:"last_update_time,omitempty"` + // Current life cycle stage of the experiment: "active" or "deleted". Deleted + // experiments are not returned by APIs. + LifecycleStage *string `json:"lifecycle_stage,omitempty"` + // Human readable name that identifies the experiment. + Name *string `json:"name,omitempty"` + // Tags: Additional metadata key-value pairs. + Tags []ExperimentTag `json:"tags,omitempty"` + // The location where the experiment's traces are stored. Unset when traces are + // stored in the default MLflow backend. This field cannot be updated after the + // experiment is created. + TraceLocation *ExperimentTraceLocation `json:"trace_location,omitempty"` +} + +// A tag for an experiment.. +type ExperimentTag struct { + // The tag key. + Key *string `json:"key,omitempty"` + // The tag value. + Value *string `json:"value,omitempty"` +} + +// The storage location for an experiment's traces.. +type ExperimentTraceLocation struct { + UcTraceLocation *UcTraceLocation `json:"uc_trace_location,omitempty"` +} + +// Metadata of a single artifact file or directory.. +type FileInfo struct { + // The size in bytes of the file. Unset for directories. + FileSize *int64 `json:"file_size,omitempty"` + // Whether the path is a directory. + IsDir *bool `json:"is_dir,omitempty"` + // The path relative to the root artifact directory run. + Path *string `json:"path,omitempty"` +} + +type FinalizeLoggedModelRequest struct { + // The ID of the logged model to finalize. + ModelId *string `json:"model_id,omitempty"` + // Whether or not the model is ready for use. ``"LOGGED_MODEL_UPLOAD_FAILED"`` + // indicates that something went wrong when logging the model weights / agent + // code. + Status LoggedModelStatus `json:"status,omitempty"` +} + +type FinalizeLoggedModelResponse struct { + // The updated logged model. + Model *LoggedModel `json:"model,omitempty"` +} + +type GetExperimentByNameRequest struct { + // Name of the associated experiment. + ExperimentName *string `json:"experiment_name,omitempty"` +} + +type GetExperimentByNameResponse struct { + // Experiment details. + Experiment *Experiment `json:"experiment,omitempty"` +} + +type GetExperimentRequest struct { + // ID of the associated experiment. + ExperimentId *string `json:"experiment_id,omitempty"` +} + +type GetExperimentResponse struct { + // Experiment details. + Experiment *Experiment `json:"experiment,omitempty"` + // A collection of active runs in the experiment. Note: this may not contain all + // of the experiment's active runs. + // + // This field is deprecated. Please use the "Search Runs" API to fetch runs + // within an experiment. + Runs []RunInfo `json:"runs,omitempty"` +} + +type GetLoggedModelResponse struct { + // The retrieved logged model. + Model *LoggedModel `json:"model,omitempty"` +} + +type GetMetricHistoryResponse struct { + // All logged values for this metric if `max_results` is not specified in the + // request or if the total count of metrics returned is less than the service + // level pagination threshold. Otherwise, this is one page of results. + Metrics []Metric `json:"metrics,omitempty"` + // A token that can be used to issue a query for the next page of metric history + // values. A missing token indicates that no additional metrics are available to + // fetch. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type GetRunRequest struct { + // ID of the run to fetch. Must be provided. + RunId *string `json:"run_id,omitempty"` + // [Deprecated, use `run_id` instead] ID of the run to fetch. This field will be + // removed in a future MLflow version. + RunUuid *string `json:"run_uuid,omitempty"` +} + +type GetRunResponse struct { + // Run metadata (name, start time, etc) and data (metrics, params, and tags). + Run *Run `json:"run,omitempty"` +} + +// Tag for a dataset input.. +type InputTag struct { + // The tag key. + Key *string `json:"key,omitempty"` + // The tag value. + Value *string `json:"value,omitempty"` +} + +type ListArtifactsRequest struct { + // The token indicating the page of artifact results to fetch. `page_token` is + // not supported when listing artifacts in UC Volumes. A maximum of 1000 + // artifacts will be retrieved for UC Volumes. Please call + // `/api/2.0/fs/directories{directory_path}` for listing artifacts in UC + // Volumes, which supports pagination. See [List directory contents | Files + // API](/api/workspace/files/listdirectorycontents). + PageToken *string `json:"page_token,omitempty"` + // Filter artifacts matching this path (a relative path from the root artifact + // directory). + Path *string `json:"path,omitempty"` + // ID of the run whose artifacts to list. Must be provided. + RunId *string `json:"run_id,omitempty"` + // [Deprecated, use `run_id` instead] ID of the run whose artifacts to list. + // This field will be removed in a future MLflow version. + RunUuid *string `json:"run_uuid,omitempty"` +} + +type ListArtifactsResponse struct { + // The file location and metadata for artifacts. + Files []FileInfo `json:"files,omitempty"` + // The token that can be used to retrieve the next page of artifact results. + NextPageToken *string `json:"next_page_token,omitempty"` + // The root artifact directory for the run. + RootUri *string `json:"root_uri,omitempty"` +} + +type ListExperimentsRequest struct { + // Maximum number of experiments desired. If `max_results` is unspecified, + // return all experiments. If `max_results` is too large, it'll be automatically + // capped at 1000. Callers of this endpoint are encouraged to pass max_results + // explicitly and leverage page_token to iterate through experiments. + MaxResults *int64 `json:"max_results,omitempty"` + // Token indicating the page of experiments to fetch + PageToken *string `json:"page_token,omitempty"` + // Qualifier for type of experiments to be returned. If unspecified, return only + // active experiments. + ViewType ViewType `json:"view_type,omitempty"` +} + +type ListExperimentsResponse struct { + // Paginated Experiments beginning with the first item on the requested page. + Experiments []Experiment `json:"experiments,omitempty"` + // Token that can be used to retrieve the next page of experiments. Empty token + // means no more experiment is available for retrieval. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListMetricHistoryRequest struct { + // Maximum number of Metric records to return per paginated request. Default is + // set to 25,000. If set higher than 25,000, a request Exception will be raised. + MaxResults *int `json:"max_results,omitempty"` + // Name of the metric. + MetricKey *string `json:"metric_key,omitempty"` + // Token indicating the page of metric histories to fetch. + PageToken *string `json:"page_token,omitempty"` + // ID of the run from which to fetch metric values. Must be provided. + RunId *string `json:"run_id,omitempty"` + // [Deprecated, use `run_id` instead] ID of the run from which to fetch metric + // values. This field will be removed in a future MLflow version. + RunUuid *string `json:"run_uuid,omitempty"` +} + +type LogBatchRequest struct { + // Metrics to log. A single request can contain up to 1000 metrics, and up to + // 1000 metrics, params, and tags in total. + Metrics []Metric `json:"metrics,omitempty"` + // Params to log. A single request can contain up to 100 params, and up to 1000 + // metrics, params, and tags in total. + Params []Param `json:"params,omitempty"` + // ID of the run to log under + RunId *string `json:"run_id,omitempty"` + // Tags to log. A single request can contain up to 100 tags, and up to 1000 + // metrics, params, and tags in total. + Tags []RunTag `json:"tags,omitempty"` +} + +type LogInputsRequest struct { + // Dataset inputs + Datasets []DatasetInput `json:"datasets,omitempty"` + // Model inputs + Models []ModelInput `json:"models,omitempty"` + // ID of the run to log under + RunId *string `json:"run_id,omitempty"` +} + +type LogLoggedModelParamsRequest struct { + // The ID of the logged model to log params for. + ModelId *string `json:"model_id,omitempty"` + // Parameters to attach to the model. + Params []LoggedModelParameter `json:"params,omitempty"` +} + +type LogMetricRequest struct { + // Dataset digest of the dataset associated with the metric, e.g. an md5 hash of + // the dataset that uniquely identifies it within datasets of the same name. + DatasetDigest *string `json:"dataset_digest,omitempty"` + // The name of the dataset associated with the metric. E.g. “my.uc.table@2” + // “nyc-taxi-dataset”, “fantastic-elk-3” + DatasetName *string `json:"dataset_name,omitempty"` + // Name of the metric. + Key *string `json:"key,omitempty"` + // ID of the logged model associated with the metric, if applicable + ModelId *string `json:"model_id,omitempty"` + // ID of the run under which to log the metric. Must be provided. + RunId *string `json:"run_id,omitempty"` + // [Deprecated, use `run_id` instead] ID of the run under which to log the + // metric. This field will be removed in a future MLflow version. + RunUuid *string `json:"run_uuid,omitempty"` + // Step at which to log the metric + Step *int64 `json:"step,omitempty"` + // Unix timestamp in milliseconds at the time metric was logged. + Timestamp *int64 `json:"timestamp,omitempty"` + // Double value of the metric being logged. + Value *float64 `json:"value,omitempty"` +} + +type LogModelRequest struct { + // MLmodel file in json format. + ModelJson *string `json:"model_json,omitempty"` + // ID of the run to log under + RunId *string `json:"run_id,omitempty"` +} + +type LogOutputsRequest struct { + // The model outputs from the Run. + Models []ModelOutput `json:"models,omitempty"` + // The ID of the Run from which to log outputs. + RunId *string `json:"run_id,omitempty"` +} + +type LogParamRequest struct { + // Name of the param. Maximum size is 255 bytes. + Key *string `json:"key,omitempty"` + // ID of the run under which to log the param. Must be provided. + RunId *string `json:"run_id,omitempty"` + // [Deprecated, use `run_id` instead] ID of the run under which to log the + // param. This field will be removed in a future MLflow version. + RunUuid *string `json:"run_uuid,omitempty"` + // String value of the param being logged. Maximum size is 500 bytes. + Value *string `json:"value,omitempty"` +} + +// A logged model message includes logged model attributes, tags, registration +// info, params, and linked run metrics.. +type LoggedModel struct { + // The params and metrics attached to the logged model. + Data *LoggedModelData `json:"data,omitempty"` + // The logged model attributes such as model ID, status, tags, etc. + Info *LoggedModelInfo `json:"info,omitempty"` +} + +// A LoggedModelData message includes logged model params and linked metrics.. +type LoggedModelData struct { + // Performance metrics linked to the model. + Metrics []Metric `json:"metrics,omitempty"` + // Immutable string key-value pairs of the model. + Params []LoggedModelParameter `json:"params,omitempty"` +} + +// A LoggedModelInfo includes logged model attributes, tags, and registration +// info.. +type LoggedModelInfo struct { + // The URI of the directory where model artifacts are stored. + ArtifactUri *string `json:"artifact_uri,omitempty"` + // The timestamp when the model was created in milliseconds since the UNIX + // epoch. + CreationTimestampMs *int64 `json:"creation_timestamp_ms,omitempty"` + // The ID of the user or principal that created the model. + CreatorId *int64 `json:"creator_id,omitempty"` + // The ID of the experiment that owns the model. + ExperimentId *string `json:"experiment_id,omitempty"` + // The timestamp when the model was last updated in milliseconds since the UNIX + // epoch. + LastUpdatedTimestampMs *int64 `json:"last_updated_timestamp_ms,omitempty"` + // The unique identifier for the logged model. + ModelId *string `json:"model_id,omitempty"` + // The type of model, such as ``"Agent"``, ``"Classifier"``, ``"LLM"``. + ModelType *string `json:"model_type,omitempty"` + // The name of the model. + Name *string `json:"name,omitempty"` + // The ID of the run that created the model. + SourceRunId *string `json:"source_run_id,omitempty"` + // The status of whether or not the model is ready for use. + Status LoggedModelStatus `json:"status,omitempty"` + // Details on the current model status. + StatusMessage *string `json:"status_message,omitempty"` + // Mutable string key-value pairs set on the model. + Tags []LoggedModelTag `json:"tags,omitempty"` +} + +// Parameter associated with a LoggedModel.. +type LoggedModelParameter struct { + // The key identifying this param. + Key *string `json:"key,omitempty"` + // The value of this param. + Value *string `json:"value,omitempty"` +} + +// Tag for a LoggedModel.. +type LoggedModelTag struct { + // The tag key. + Key *string `json:"key,omitempty"` + // The tag value. + Value *string `json:"value,omitempty"` +} + +// Metric associated with a run, represented as a key-value pair.. +type Metric struct { + // The dataset digest of the dataset associated with the metric, e.g. an md5 + // hash of the dataset that uniquely identifies it within datasets of the same + // name. + DatasetDigest *string `json:"dataset_digest,omitempty"` + // The name of the dataset associated with the metric. E.g. “my.uc.table@2” + // “nyc-taxi-dataset”, “fantastic-elk-3” + DatasetName *string `json:"dataset_name,omitempty"` + // The key identifying the metric. + Key *string `json:"key,omitempty"` + // The ID of the logged model or registered model version associated with the + // metric, if applicable. + ModelId *string `json:"model_id,omitempty"` + // The ID of the run containing the metric. + RunId *string `json:"run_id,omitempty"` + // The step at which the metric was logged. + Step *int64 `json:"step,omitempty"` + // The timestamp at which the metric was recorded. + Timestamp *int64 `json:"timestamp,omitempty"` + // The value of the metric. + Value *float64 `json:"value,omitempty"` +} + +// Represents a LoggedModel or Registered Model Version input to a Run.. +type ModelInput struct { + // The unique identifier of the model. + ModelId *string `json:"model_id,omitempty"` +} + +// Represents a LoggedModel output of a Run.. +type ModelOutput struct { + // The unique identifier of the model. + ModelId *string `json:"model_id,omitempty"` + // The step at which the model was produced. + Step *int64 `json:"step,omitempty"` +} + +// Param associated with a run.. +type Param struct { + // Key identifying this param. + Key *string `json:"key,omitempty"` + // Value associated with this param. + Value *string `json:"value,omitempty"` +} + +type RestoreExperimentRequest struct { + // ID of the associated experiment. + ExperimentId *string `json:"experiment_id,omitempty"` +} + +type RestoreRunRequest struct { + // ID of the run to restore. + RunId *string `json:"run_id,omitempty"` +} + +type RestoreRunsRequest struct { + // The ID of the experiment containing the runs to restore. + ExperimentId *string `json:"experiment_id,omitempty"` + // An optional positive integer indicating the maximum number of runs to + // restore. The maximum allowed value for max_runs is 10000. + MaxRuns *int `json:"max_runs,omitempty"` + // The minimum deletion timestamp in milliseconds since the UNIX epoch for + // restoring runs. Only runs deleted no earlier than this timestamp are + // restored. + MinTimestampMillis *int64 `json:"min_timestamp_millis,omitempty"` +} + +type RestoreRunsResponse struct { + // The number of runs restored. + RunsRestored *int `json:"runs_restored,omitempty"` +} + +// A single run.. +type Run struct { + // Run data. + Data *RunData `json:"data,omitempty"` + // Run metadata. + Info *RunInfo `json:"info,omitempty"` + // Run inputs. + Inputs *RunInputs `json:"inputs,omitempty"` +} + +// Run data (metrics, params, and tags).. +type RunData struct { + // Run metrics. + Metrics []Metric `json:"metrics,omitempty"` + // Run parameters. + Params []Param `json:"params,omitempty"` + // Additional metadata key-value pairs. + Tags []RunTag `json:"tags,omitempty"` +} + +// Metadata of a single run.. +type RunInfo struct { + // URI of the directory where artifacts should be uploaded. This can be a local + // path (starting with "/"), or a distributed file system (DFS) path, like + // ``s3://bucket/directory`` or ``dbfs:/my/directory``. If not set, the local + // ``./mlruns`` directory is chosen. + ArtifactUri *string `json:"artifact_uri,omitempty"` + // Unix timestamp of when the run ended in milliseconds. + EndTime *int64 `json:"end_time,omitempty"` + // The experiment ID. + ExperimentId *string `json:"experiment_id,omitempty"` + // Current life cycle stage of the experiment : OneOf("active", "deleted") + LifecycleStage *string `json:"lifecycle_stage,omitempty"` + // Unique identifier for the run. + RunId *string `json:"run_id,omitempty"` + // The name of the run. + RunName *string `json:"run_name,omitempty"` + // [Deprecated, use run_id instead] Unique identifier for the run. This field + // will be removed in a future MLflow version. + RunUuid *string `json:"run_uuid,omitempty"` + // Unix timestamp of when the run started in milliseconds. + StartTime *int64 `json:"start_time,omitempty"` + // Current status of the run. + Status RunStatus `json:"status,omitempty"` + // User who initiated the run. This field is deprecated as of MLflow 1.0, and + // will be removed in a future MLflow release. Use 'mlflow.user' tag instead. + UserId *string `json:"user_id,omitempty"` +} + +// Run inputs.. +type RunInputs struct { + // Run metrics. + DatasetInputs []DatasetInput `json:"dataset_inputs,omitempty"` + // Model inputs to the Run. + ModelInputs []ModelInput `json:"model_inputs,omitempty"` +} + +// Tag for a run.. +type RunTag struct { + // The tag key. + Key *string `json:"key,omitempty"` + // The tag value. + Value *string `json:"value,omitempty"` +} + +type SearchExperimentsRequest struct { + // String representing a SQL filter condition (e.g. "name ILIKE + // 'my-experiment%'") + Filter *string `json:"filter,omitempty"` + // Maximum number of experiments desired. Max threshold is 3000. + MaxResults *int64 `json:"max_results,omitempty"` + // List of columns for ordering search results, which can include experiment + // name and last updated timestamp with an optional "DESC" or "ASC" annotation, + // where "ASC" is the default. Tiebreaks are done by experiment id DESC. + OrderBy []string `json:"order_by,omitempty"` + // Token indicating the page of experiments to fetch + PageToken *string `json:"page_token,omitempty"` + // Qualifier for type of experiments to be returned. If unspecified, return only + // active experiments. + ViewType ViewType `json:"view_type,omitempty"` +} + +type SearchExperimentsResponse struct { + // Experiments that match the search criteria + Experiments []Experiment `json:"experiments,omitempty"` + // Token that can be used to retrieve the next page of experiments. An empty + // token means that no more experiments are available for retrieval. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type SearchLoggedModelsRequest struct { + // List of datasets on which to apply the metrics filter clauses. For example, a + // filter with `metrics.accuracy > 0.9` and dataset info with name + // "test_dataset" means we will return all logged models with accuracy > 0.9 on + // the test_dataset. Metric values from ANY dataset matching the criteria are + // considered. If no datasets are specified, then metrics across all datasets + // are considered in the filter. + Datasets []SearchLoggedModelsRequest_Dataset `json:"datasets,omitempty"` + // The IDs of the experiments in which to search for logged models. + ExperimentIds []string `json:"experiment_ids,omitempty"` + // A filter expression over logged model info and data that allows returning a + // subset of logged models. The syntax is a subset of SQL that supports AND'ing + // together binary operations. + // + // Example: ``params.alpha < 0.3 AND metrics.accuracy > 0.9``. + Filter *string `json:"filter,omitempty"` + // The maximum number of Logged Models to return. The maximum limit is 50. + MaxResults *int `json:"max_results,omitempty"` + // The list of columns for ordering the results, with additional fields for + // sorting criteria. + OrderBy []SearchLoggedModelsRequest_OrderBy `json:"order_by,omitempty"` + // The token indicating the page of logged models to fetch. + PageToken *string `json:"page_token,omitempty"` +} + +type SearchLoggedModelsRequest_Dataset struct { + // The digest of the dataset. + DatasetDigest *string `json:"dataset_digest,omitempty"` + // The name of the dataset. + DatasetName *string `json:"dataset_name,omitempty"` +} + +type SearchLoggedModelsRequest_OrderBy struct { + // Whether the search results order is ascending or not. + Ascending *bool `json:"ascending,omitempty"` + // If ``field_name`` refers to a metric, this field specifies the digest of the + // dataset associated with the metric. Only metrics associated with the + // specified dataset name and digest will be considered for ordering. This field + // may only be set if ``dataset_name`` is also set. + DatasetDigest *string `json:"dataset_digest,omitempty"` + // If ``field_name`` refers to a metric, this field specifies the name of the + // dataset associated with the metric. Only metrics associated with the + // specified dataset name will be considered for ordering. This field may only + // be set if ``field_name`` refers to a metric. + DatasetName *string `json:"dataset_name,omitempty"` + // The name of the field to order by, e.g. "metrics.accuracy". + FieldName *string `json:"field_name,omitempty"` +} + +type SearchLoggedModelsResponse struct { + // Logged models that match the search criteria. + Models []LoggedModel `json:"models,omitempty"` + // The token that can be used to retrieve the next page of logged models. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type SearchRunsRequest struct { + // List of experiment IDs to search over. + ExperimentIds []string `json:"experiment_ids,omitempty"` + // A filter expression over params, metrics, and tags, that allows returning a + // subset of runs. The syntax is a subset of SQL that supports ANDing together + // binary operations between a param, metric, or tag and a constant. + // + // Example: `metrics.rmse < 1 and params.model_class = 'LogisticRegression'` + // + // You can select columns with special characters (hyphen, space, period, etc.) + // by using double quotes: `metrics."model class" = 'LinearRegression' and + // tags."user-name" = 'Tomas'` + // + // Supported operators are `=`, `!=`, `>`, `>=`, `<`, and `<=`. + Filter *string `json:"filter,omitempty"` + // Maximum number of runs desired. Max threshold is 50000 + MaxResults *int `json:"max_results,omitempty"` + // List of columns to be ordered by, including attributes, params, metrics, and + // tags with an optional `"DESC"` or `"ASC"` annotation, where `"ASC"` is the + // default. Example: `["params.input DESC", "metrics.alpha ASC", + // "metrics.rmse"]`. Tiebreaks are done by start_time `DESC` followed by + // `run_id` for runs with the same start time (and this is the default ordering + // criterion if order_by is not provided). + OrderBy []string `json:"order_by,omitempty"` + // Token for the current page of runs. + PageToken *string `json:"page_token,omitempty"` + // Whether to display only active, only deleted, or all runs. Defaults to only + // active runs. + RunViewType ViewType `json:"run_view_type,omitempty"` +} + +type SearchRunsResponse struct { + // Token for the next page of runs. + NextPageToken *string `json:"next_page_token,omitempty"` + // Runs that match the search criteria. + Runs []Run `json:"runs,omitempty"` +} + +type SetExperimentTagRequest struct { + // ID of the experiment under which to log the tag. Must be provided. + ExperimentId *string `json:"experiment_id,omitempty"` + // Name of the tag. Keys up to 250 bytes in size are supported. + Key *string `json:"key,omitempty"` + // String value of the tag being logged. Values up to 64KB in size are + // supported. + Value *string `json:"value,omitempty"` +} + +type SetLoggedModelTagsRequest struct { + // The ID of the logged model to set the tags on. + ModelId *string `json:"model_id,omitempty"` + // The tags to set on the logged model. + Tags []LoggedModelTag `json:"tags,omitempty"` +} + +type SetTagRequest struct { + // Name of the tag. Keys up to 250 bytes in size are supported. + Key *string `json:"key,omitempty"` + // ID of the run under which to log the tag. Must be provided. + RunId *string `json:"run_id,omitempty"` + // [Deprecated, use `run_id` instead] ID of the run under which to log the tag. + // This field will be removed in a future MLflow version. + RunUuid *string `json:"run_uuid,omitempty"` + // String value of the tag being logged. Values up to 64KB in size are + // supported. + Value *string `json:"value,omitempty"` +} + +// A Unity Catalog trace storage location. Traces are stored as Delta tables in +// the specified catalog and schema.. +type UcTraceLocation struct { + // The name of the Unity Catalog catalog. + Catalog *string `json:"catalog,omitempty"` + // The trace-table prefix actually in effect: `table_prefix` if it was set on + // creation, otherwise the server-generated default. + EffectiveTablePrefix *string `json:"effective_table_prefix,omitempty"` + // The name of the Unity Catalog schema within `catalog`. + Schema *string `json:"schema,omitempty"` + // The prefix for the trace tables, which are named + // `{catalog}.{schema}.{table_prefix}_otel_*`. May only contain letters, digits, + // and underscores, and may be at most 238 characters. When unset, a + // server-generated prefix derived from the experiment ID is used and this field + // stays empty on read; the resolved value is always available in + // `effective_table_prefix`. + TablePrefix *string `json:"table_prefix,omitempty"` +} + +type UpdateExperimentRequest struct { + // ID of the associated experiment. + ExperimentId *string `json:"experiment_id,omitempty"` + // If provided, the experiment's name is changed to the new name. The new name + // must be unique. + NewName *string `json:"new_name,omitempty"` +} + +type UpdateRunRequest struct { + // Unix timestamp in milliseconds of when the run ended. + EndTime *int64 `json:"end_time,omitempty"` + // ID of the run to update. Must be provided. + RunId *string `json:"run_id,omitempty"` + // Updated name of the run. + RunName *string `json:"run_name,omitempty"` + // [Deprecated, use `run_id` instead] ID of the run to update. This field will + // be removed in a future MLflow version. + RunUuid *string `json:"run_uuid,omitempty"` + // Updated status of the run. + Status RunStatus `json:"status,omitempty"` +} + +type UpdateRunResponse struct { + // Updated metadata of the run. + RunInfo *RunInfo `json:"run_info,omitempty"` +} + +// CreateExperimentRequestToSDK converts the mirror to the sdk-go type. +func CreateExperimentRequestToSDK(w *CreateExperimentRequest) (*sdk.CreateExperimentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateExperimentRequest{} + out.Name = w.Name + out.ArtifactLocation = w.ArtifactLocation + conv1, err := convertSlice(w.Tags, ExperimentTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExperimentRequest.Tags", err) + } + out.Tags = conv1 + conv2, err := ExperimentTraceLocationToSDK(w.TraceLocation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExperimentRequest.TraceLocation", err) + } + out.TraceLocation = conv2 + return out, nil +} + +// CreateExperimentRequestFromSDK converts the sdk-go type to the mirror. +func CreateExperimentRequestFromSDK(v *sdk.CreateExperimentRequest) (*CreateExperimentRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateExperimentRequest{} + out.Name = v.Name + out.ArtifactLocation = v.ArtifactLocation + conv3, err := convertSlice(v.Tags, ExperimentTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExperimentRequest.Tags", err) + } + out.Tags = conv3 + conv4, err := ExperimentTraceLocationFromSDK(v.TraceLocation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExperimentRequest.TraceLocation", err) + } + out.TraceLocation = conv4 + return out, nil +} + +// CreateExperimentResponseToSDK converts the mirror to the sdk-go type. +func CreateExperimentResponseToSDK(w *CreateExperimentResponse) (*sdk.CreateExperimentResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateExperimentResponse{} + out.ExperimentId = w.ExperimentId + return out, nil +} + +// CreateExperimentResponseFromSDK converts the sdk-go type to the mirror. +func CreateExperimentResponseFromSDK(v *sdk.CreateExperimentResponse) (*CreateExperimentResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateExperimentResponse{} + out.ExperimentId = v.ExperimentId + return out, nil +} + +// CreateLoggedModelRequestToSDK converts the mirror to the sdk-go type. +func CreateLoggedModelRequestToSDK(w *CreateLoggedModelRequest) (*sdk.CreateLoggedModelRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateLoggedModelRequest{} + out.ExperimentId = w.ExperimentId + out.Name = w.Name + out.ModelType = w.ModelType + out.SourceRunId = w.SourceRunId + conv5, err := convertSlice(w.Params, LoggedModelParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateLoggedModelRequest.Params", err) + } + out.Params = conv5 + conv6, err := convertSlice(w.Tags, LoggedModelTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateLoggedModelRequest.Tags", err) + } + out.Tags = conv6 + return out, nil +} + +// CreateLoggedModelRequestFromSDK converts the sdk-go type to the mirror. +func CreateLoggedModelRequestFromSDK(v *sdk.CreateLoggedModelRequest) (*CreateLoggedModelRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateLoggedModelRequest{} + out.ExperimentId = v.ExperimentId + out.Name = v.Name + out.ModelType = v.ModelType + out.SourceRunId = v.SourceRunId + conv7, err := convertSlice(v.Params, LoggedModelParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateLoggedModelRequest.Params", err) + } + out.Params = conv7 + conv8, err := convertSlice(v.Tags, LoggedModelTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateLoggedModelRequest.Tags", err) + } + out.Tags = conv8 + return out, nil +} + +// CreateLoggedModelResponseToSDK converts the mirror to the sdk-go type. +func CreateLoggedModelResponseToSDK(w *CreateLoggedModelResponse) (*sdk.CreateLoggedModelResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateLoggedModelResponse{} + conv9, err := LoggedModelToSDK(w.Model) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateLoggedModelResponse.Model", err) + } + out.Model = conv9 + return out, nil +} + +// CreateLoggedModelResponseFromSDK converts the sdk-go type to the mirror. +func CreateLoggedModelResponseFromSDK(v *sdk.CreateLoggedModelResponse) (*CreateLoggedModelResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateLoggedModelResponse{} + conv10, err := LoggedModelFromSDK(v.Model) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateLoggedModelResponse.Model", err) + } + out.Model = conv10 + return out, nil +} + +// CreateRunRequestToSDK converts the mirror to the sdk-go type. +func CreateRunRequestToSDK(w *CreateRunRequest) (*sdk.CreateRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRunRequest{} + out.ExperimentId = w.ExperimentId + out.UserId = w.UserId + out.RunName = w.RunName + out.StartTime = w.StartTime + conv11, err := convertSlice(w.Tags, RunTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRunRequest.Tags", err) + } + out.Tags = conv11 + return out, nil +} + +// CreateRunRequestFromSDK converts the sdk-go type to the mirror. +func CreateRunRequestFromSDK(v *sdk.CreateRunRequest) (*CreateRunRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateRunRequest{} + out.ExperimentId = v.ExperimentId + out.UserId = v.UserId + out.RunName = v.RunName + out.StartTime = v.StartTime + conv12, err := convertSlice(v.Tags, RunTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRunRequest.Tags", err) + } + out.Tags = conv12 + return out, nil +} + +// CreateRunResponseToSDK converts the mirror to the sdk-go type. +func CreateRunResponseToSDK(w *CreateRunResponse) (*sdk.CreateRunResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRunResponse{} + conv13, err := RunToSDK(w.Run) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRunResponse.Run", err) + } + out.Run = conv13 + return out, nil +} + +// CreateRunResponseFromSDK converts the sdk-go type to the mirror. +func CreateRunResponseFromSDK(v *sdk.CreateRunResponse) (*CreateRunResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateRunResponse{} + conv14, err := RunFromSDK(v.Run) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRunResponse.Run", err) + } + out.Run = conv14 + return out, nil +} + +// DatasetToSDK converts the mirror to the sdk-go type. +func DatasetToSDK(w *Dataset) (*sdk.Dataset, error) { + if w == nil { + return nil, nil + } + out := &sdk.Dataset{} + out.Name = w.Name + out.Digest = w.Digest + out.SourceType = w.SourceType + out.Source = w.Source + out.Schema = w.Schema + out.Profile = w.Profile + return out, nil +} + +// DatasetFromSDK converts the sdk-go type to the mirror. +func DatasetFromSDK(v *sdk.Dataset) (*Dataset, error) { + if v == nil { + return nil, nil + } + out := &Dataset{} + out.Name = v.Name + out.Digest = v.Digest + out.SourceType = v.SourceType + out.Source = v.Source + out.Schema = v.Schema + out.Profile = v.Profile + return out, nil +} + +// DatasetInputToSDK converts the mirror to the sdk-go type. +func DatasetInputToSDK(w *DatasetInput) (*sdk.DatasetInput, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatasetInput{} + conv15, err := convertSlice(w.Tags, InputTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatasetInput.Tags", err) + } + out.Tags = conv15 + conv16, err := DatasetToSDK(w.Dataset) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatasetInput.Dataset", err) + } + out.Dataset = conv16 + return out, nil +} + +// DatasetInputFromSDK converts the sdk-go type to the mirror. +func DatasetInputFromSDK(v *sdk.DatasetInput) (*DatasetInput, error) { + if v == nil { + return nil, nil + } + out := &DatasetInput{} + conv17, err := convertSlice(v.Tags, InputTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatasetInput.Tags", err) + } + out.Tags = conv17 + conv18, err := DatasetFromSDK(v.Dataset) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DatasetInput.Dataset", err) + } + out.Dataset = conv18 + return out, nil +} + +// DeleteExperimentRequestToSDK converts the mirror to the sdk-go type. +func DeleteExperimentRequestToSDK(w *DeleteExperimentRequest) (*sdk.DeleteExperimentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteExperimentRequest{} + out.ExperimentId = w.ExperimentId + return out, nil +} + +// DeleteExperimentRequestFromSDK converts the sdk-go type to the mirror. +func DeleteExperimentRequestFromSDK(v *sdk.DeleteExperimentRequest) (*DeleteExperimentRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteExperimentRequest{} + out.ExperimentId = v.ExperimentId + return out, nil +} + +// DeleteRunRequestToSDK converts the mirror to the sdk-go type. +func DeleteRunRequestToSDK(w *DeleteRunRequest) (*sdk.DeleteRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteRunRequest{} + out.RunId = w.RunId + return out, nil +} + +// DeleteRunRequestFromSDK converts the sdk-go type to the mirror. +func DeleteRunRequestFromSDK(v *sdk.DeleteRunRequest) (*DeleteRunRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteRunRequest{} + out.RunId = v.RunId + return out, nil +} + +// DeleteRunsRequestToSDK converts the mirror to the sdk-go type. +func DeleteRunsRequestToSDK(w *DeleteRunsRequest) (*sdk.DeleteRunsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteRunsRequest{} + out.ExperimentId = w.ExperimentId + out.MaxTimestampMillis = w.MaxTimestampMillis + out.MaxRuns = w.MaxRuns + return out, nil +} + +// DeleteRunsRequestFromSDK converts the sdk-go type to the mirror. +func DeleteRunsRequestFromSDK(v *sdk.DeleteRunsRequest) (*DeleteRunsRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteRunsRequest{} + out.ExperimentId = v.ExperimentId + out.MaxTimestampMillis = v.MaxTimestampMillis + out.MaxRuns = v.MaxRuns + return out, nil +} + +// DeleteRunsResponseToSDK converts the mirror to the sdk-go type. +func DeleteRunsResponseToSDK(w *DeleteRunsResponse) (*sdk.DeleteRunsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteRunsResponse{} + out.RunsDeleted = w.RunsDeleted + return out, nil +} + +// DeleteRunsResponseFromSDK converts the sdk-go type to the mirror. +func DeleteRunsResponseFromSDK(v *sdk.DeleteRunsResponse) (*DeleteRunsResponse, error) { + if v == nil { + return nil, nil + } + out := &DeleteRunsResponse{} + out.RunsDeleted = v.RunsDeleted + return out, nil +} + +// DeleteTagRequestToSDK converts the mirror to the sdk-go type. +func DeleteTagRequestToSDK(w *DeleteTagRequest) (*sdk.DeleteTagRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteTagRequest{} + out.RunId = w.RunId + out.Key = w.Key + return out, nil +} + +// DeleteTagRequestFromSDK converts the sdk-go type to the mirror. +func DeleteTagRequestFromSDK(v *sdk.DeleteTagRequest) (*DeleteTagRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteTagRequest{} + out.RunId = v.RunId + out.Key = v.Key + return out, nil +} + +// ExperimentToSDK converts the mirror to the sdk-go type. +func ExperimentToSDK(w *Experiment) (*sdk.Experiment, error) { + if w == nil { + return nil, nil + } + out := &sdk.Experiment{} + out.ExperimentId = w.ExperimentId + out.Name = w.Name + out.ArtifactLocation = w.ArtifactLocation + out.LifecycleStage = w.LifecycleStage + out.LastUpdateTime = w.LastUpdateTime + out.CreationTime = w.CreationTime + conv19, err := convertSlice(w.Tags, ExperimentTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Experiment.Tags", err) + } + out.Tags = conv19 + conv20, err := ExperimentTraceLocationToSDK(w.TraceLocation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Experiment.TraceLocation", err) + } + out.TraceLocation = conv20 + return out, nil +} + +// ExperimentFromSDK converts the sdk-go type to the mirror. +func ExperimentFromSDK(v *sdk.Experiment) (*Experiment, error) { + if v == nil { + return nil, nil + } + out := &Experiment{} + out.ExperimentId = v.ExperimentId + out.Name = v.Name + out.ArtifactLocation = v.ArtifactLocation + out.LifecycleStage = v.LifecycleStage + out.LastUpdateTime = v.LastUpdateTime + out.CreationTime = v.CreationTime + conv21, err := convertSlice(v.Tags, ExperimentTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Experiment.Tags", err) + } + out.Tags = conv21 + conv22, err := ExperimentTraceLocationFromSDK(v.TraceLocation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Experiment.TraceLocation", err) + } + out.TraceLocation = conv22 + return out, nil +} + +// ExperimentTagToSDK converts the mirror to the sdk-go type. +func ExperimentTagToSDK(w *ExperimentTag) (*sdk.ExperimentTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExperimentTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// ExperimentTagFromSDK converts the sdk-go type to the mirror. +func ExperimentTagFromSDK(v *sdk.ExperimentTag) (*ExperimentTag, error) { + if v == nil { + return nil, nil + } + out := &ExperimentTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// ExperimentTraceLocationToSDK converts the mirror to the sdk-go type. +func ExperimentTraceLocationToSDK(w *ExperimentTraceLocation) (*sdk.ExperimentTraceLocation, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExperimentTraceLocation{} + { + var members []string + if w.UcTraceLocation != nil { + members = append(members, "uc_trace_location") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UcTraceLocation != nil: + conv23, err := UcTraceLocationToSDK(w.UcTraceLocation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExperimentTraceLocation.Location", err) + } + out.Location = &sdk.ExperimentTraceLocation_Location_UcTraceLocation{UcTraceLocation: *conv23} + } + return out, nil +} + +// ExperimentTraceLocationFromSDK converts the sdk-go type to the mirror. +func ExperimentTraceLocationFromSDK(v *sdk.ExperimentTraceLocation) (*ExperimentTraceLocation, error) { + if v == nil { + return nil, nil + } + out := &ExperimentTraceLocation{} + switch value := v.Location.(type) { + case *sdk.ExperimentTraceLocation_Location_UcTraceLocation: + if value != nil { + conv24, err := UcTraceLocationFromSDK(&value.UcTraceLocation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExperimentTraceLocation.Location", err) + } + out.UcTraceLocation = conv24 + } + } + return out, nil +} + +// FileInfoToSDK converts the mirror to the sdk-go type. +func FileInfoToSDK(w *FileInfo) (*sdk.FileInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.FileInfo{} + out.Path = w.Path + out.IsDir = w.IsDir + out.FileSize = w.FileSize + return out, nil +} + +// FileInfoFromSDK converts the sdk-go type to the mirror. +func FileInfoFromSDK(v *sdk.FileInfo) (*FileInfo, error) { + if v == nil { + return nil, nil + } + out := &FileInfo{} + out.Path = v.Path + out.IsDir = v.IsDir + out.FileSize = v.FileSize + return out, nil +} + +// FinalizeLoggedModelRequestToSDK converts the mirror to the sdk-go type. +func FinalizeLoggedModelRequestToSDK(w *FinalizeLoggedModelRequest) (*sdk.FinalizeLoggedModelRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.FinalizeLoggedModelRequest{} + out.ModelId = w.ModelId + out.Status = w.Status + return out, nil +} + +// FinalizeLoggedModelRequestFromSDK converts the sdk-go type to the mirror. +func FinalizeLoggedModelRequestFromSDK(v *sdk.FinalizeLoggedModelRequest) (*FinalizeLoggedModelRequest, error) { + if v == nil { + return nil, nil + } + out := &FinalizeLoggedModelRequest{} + out.ModelId = v.ModelId + out.Status = v.Status + return out, nil +} + +// FinalizeLoggedModelResponseToSDK converts the mirror to the sdk-go type. +func FinalizeLoggedModelResponseToSDK(w *FinalizeLoggedModelResponse) (*sdk.FinalizeLoggedModelResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.FinalizeLoggedModelResponse{} + conv25, err := LoggedModelToSDK(w.Model) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FinalizeLoggedModelResponse.Model", err) + } + out.Model = conv25 + return out, nil +} + +// FinalizeLoggedModelResponseFromSDK converts the sdk-go type to the mirror. +func FinalizeLoggedModelResponseFromSDK(v *sdk.FinalizeLoggedModelResponse) (*FinalizeLoggedModelResponse, error) { + if v == nil { + return nil, nil + } + out := &FinalizeLoggedModelResponse{} + conv26, err := LoggedModelFromSDK(v.Model) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FinalizeLoggedModelResponse.Model", err) + } + out.Model = conv26 + return out, nil +} + +// GetExperimentByNameRequestToSDK converts the mirror to the sdk-go type. +func GetExperimentByNameRequestToSDK(w *GetExperimentByNameRequest) (*sdk.GetExperimentByNameRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetExperimentByNameRequest{} + out.ExperimentName = w.ExperimentName + return out, nil +} + +// GetExperimentByNameRequestFromSDK converts the sdk-go type to the mirror. +func GetExperimentByNameRequestFromSDK(v *sdk.GetExperimentByNameRequest) (*GetExperimentByNameRequest, error) { + if v == nil { + return nil, nil + } + out := &GetExperimentByNameRequest{} + out.ExperimentName = v.ExperimentName + return out, nil +} + +// GetExperimentByNameResponseToSDK converts the mirror to the sdk-go type. +func GetExperimentByNameResponseToSDK(w *GetExperimentByNameResponse) (*sdk.GetExperimentByNameResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetExperimentByNameResponse{} + conv27, err := ExperimentToSDK(w.Experiment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetExperimentByNameResponse.Experiment", err) + } + out.Experiment = conv27 + return out, nil +} + +// GetExperimentByNameResponseFromSDK converts the sdk-go type to the mirror. +func GetExperimentByNameResponseFromSDK(v *sdk.GetExperimentByNameResponse) (*GetExperimentByNameResponse, error) { + if v == nil { + return nil, nil + } + out := &GetExperimentByNameResponse{} + conv28, err := ExperimentFromSDK(v.Experiment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetExperimentByNameResponse.Experiment", err) + } + out.Experiment = conv28 + return out, nil +} + +// GetExperimentRequestToSDK converts the mirror to the sdk-go type. +func GetExperimentRequestToSDK(w *GetExperimentRequest) (*sdk.GetExperimentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetExperimentRequest{} + out.ExperimentId = w.ExperimentId + return out, nil +} + +// GetExperimentRequestFromSDK converts the sdk-go type to the mirror. +func GetExperimentRequestFromSDK(v *sdk.GetExperimentRequest) (*GetExperimentRequest, error) { + if v == nil { + return nil, nil + } + out := &GetExperimentRequest{} + out.ExperimentId = v.ExperimentId + return out, nil +} + +// GetExperimentResponseToSDK converts the mirror to the sdk-go type. +func GetExperimentResponseToSDK(w *GetExperimentResponse) (*sdk.GetExperimentResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetExperimentResponse{} + conv29, err := ExperimentToSDK(w.Experiment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetExperimentResponse.Experiment", err) + } + out.Experiment = conv29 + conv30, err := convertSlice(w.Runs, RunInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetExperimentResponse.Runs", err) + } + out.Runs = conv30 + return out, nil +} + +// GetExperimentResponseFromSDK converts the sdk-go type to the mirror. +func GetExperimentResponseFromSDK(v *sdk.GetExperimentResponse) (*GetExperimentResponse, error) { + if v == nil { + return nil, nil + } + out := &GetExperimentResponse{} + conv31, err := ExperimentFromSDK(v.Experiment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetExperimentResponse.Experiment", err) + } + out.Experiment = conv31 + conv32, err := convertSlice(v.Runs, RunInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetExperimentResponse.Runs", err) + } + out.Runs = conv32 + return out, nil +} + +// GetLoggedModelResponseToSDK converts the mirror to the sdk-go type. +func GetLoggedModelResponseToSDK(w *GetLoggedModelResponse) (*sdk.GetLoggedModelResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetLoggedModelResponse{} + conv33, err := LoggedModelToSDK(w.Model) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetLoggedModelResponse.Model", err) + } + out.Model = conv33 + return out, nil +} + +// GetLoggedModelResponseFromSDK converts the sdk-go type to the mirror. +func GetLoggedModelResponseFromSDK(v *sdk.GetLoggedModelResponse) (*GetLoggedModelResponse, error) { + if v == nil { + return nil, nil + } + out := &GetLoggedModelResponse{} + conv34, err := LoggedModelFromSDK(v.Model) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetLoggedModelResponse.Model", err) + } + out.Model = conv34 + return out, nil +} + +// GetMetricHistoryResponseToSDK converts the mirror to the sdk-go type. +func GetMetricHistoryResponseToSDK(w *GetMetricHistoryResponse) (*sdk.GetMetricHistoryResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetMetricHistoryResponse{} + conv35, err := convertSlice(w.Metrics, MetricToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetMetricHistoryResponse.Metrics", err) + } + out.Metrics = conv35 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GetMetricHistoryResponseFromSDK converts the sdk-go type to the mirror. +func GetMetricHistoryResponseFromSDK(v *sdk.GetMetricHistoryResponse) (*GetMetricHistoryResponse, error) { + if v == nil { + return nil, nil + } + out := &GetMetricHistoryResponse{} + conv36, err := convertSlice(v.Metrics, MetricFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetMetricHistoryResponse.Metrics", err) + } + out.Metrics = conv36 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GetRunRequestToSDK converts the mirror to the sdk-go type. +func GetRunRequestToSDK(w *GetRunRequest) (*sdk.GetRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetRunRequest{} + out.RunId = w.RunId + out.RunUuid = w.RunUuid + return out, nil +} + +// GetRunRequestFromSDK converts the sdk-go type to the mirror. +func GetRunRequestFromSDK(v *sdk.GetRunRequest) (*GetRunRequest, error) { + if v == nil { + return nil, nil + } + out := &GetRunRequest{} + out.RunId = v.RunId + out.RunUuid = v.RunUuid + return out, nil +} + +// GetRunResponseToSDK converts the mirror to the sdk-go type. +func GetRunResponseToSDK(w *GetRunResponse) (*sdk.GetRunResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetRunResponse{} + conv37, err := RunToSDK(w.Run) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.Run", err) + } + out.Run = conv37 + return out, nil +} + +// GetRunResponseFromSDK converts the sdk-go type to the mirror. +func GetRunResponseFromSDK(v *sdk.GetRunResponse) (*GetRunResponse, error) { + if v == nil { + return nil, nil + } + out := &GetRunResponse{} + conv38, err := RunFromSDK(v.Run) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.Run", err) + } + out.Run = conv38 + return out, nil +} + +// InputTagToSDK converts the mirror to the sdk-go type. +func InputTagToSDK(w *InputTag) (*sdk.InputTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.InputTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// InputTagFromSDK converts the sdk-go type to the mirror. +func InputTagFromSDK(v *sdk.InputTag) (*InputTag, error) { + if v == nil { + return nil, nil + } + out := &InputTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// ListArtifactsRequestToSDK converts the mirror to the sdk-go type. +func ListArtifactsRequestToSDK(w *ListArtifactsRequest) (*sdk.ListArtifactsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListArtifactsRequest{} + out.RunId = w.RunId + out.RunUuid = w.RunUuid + out.Path = w.Path + out.PageToken = w.PageToken + return out, nil +} + +// ListArtifactsRequestFromSDK converts the sdk-go type to the mirror. +func ListArtifactsRequestFromSDK(v *sdk.ListArtifactsRequest) (*ListArtifactsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListArtifactsRequest{} + out.RunId = v.RunId + out.RunUuid = v.RunUuid + out.Path = v.Path + out.PageToken = v.PageToken + return out, nil +} + +// ListArtifactsResponseToSDK converts the mirror to the sdk-go type. +func ListArtifactsResponseToSDK(w *ListArtifactsResponse) (*sdk.ListArtifactsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListArtifactsResponse{} + out.RootUri = w.RootUri + conv39, err := convertSlice(w.Files, FileInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListArtifactsResponse.Files", err) + } + out.Files = conv39 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListArtifactsResponseFromSDK converts the sdk-go type to the mirror. +func ListArtifactsResponseFromSDK(v *sdk.ListArtifactsResponse) (*ListArtifactsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListArtifactsResponse{} + out.RootUri = v.RootUri + conv40, err := convertSlice(v.Files, FileInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListArtifactsResponse.Files", err) + } + out.Files = conv40 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListExperimentsRequestToSDK converts the mirror to the sdk-go type. +func ListExperimentsRequestToSDK(w *ListExperimentsRequest) (*sdk.ListExperimentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExperimentsRequest{} + out.ViewType = w.ViewType + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListExperimentsRequestFromSDK converts the sdk-go type to the mirror. +func ListExperimentsRequestFromSDK(v *sdk.ListExperimentsRequest) (*ListExperimentsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListExperimentsRequest{} + out.ViewType = v.ViewType + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListExperimentsResponseToSDK converts the mirror to the sdk-go type. +func ListExperimentsResponseToSDK(w *ListExperimentsResponse) (*sdk.ListExperimentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExperimentsResponse{} + conv41, err := convertSlice(w.Experiments, ExperimentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExperimentsResponse.Experiments", err) + } + out.Experiments = conv41 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListExperimentsResponseFromSDK converts the sdk-go type to the mirror. +func ListExperimentsResponseFromSDK(v *sdk.ListExperimentsResponse) (*ListExperimentsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListExperimentsResponse{} + conv42, err := convertSlice(v.Experiments, ExperimentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExperimentsResponse.Experiments", err) + } + out.Experiments = conv42 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListMetricHistoryRequestToSDK converts the mirror to the sdk-go type. +func ListMetricHistoryRequestToSDK(w *ListMetricHistoryRequest) (*sdk.ListMetricHistoryRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListMetricHistoryRequest{} + out.RunId = w.RunId + out.RunUuid = w.RunUuid + out.MetricKey = w.MetricKey + out.PageToken = w.PageToken + out.MaxResults = w.MaxResults + return out, nil +} + +// ListMetricHistoryRequestFromSDK converts the sdk-go type to the mirror. +func ListMetricHistoryRequestFromSDK(v *sdk.ListMetricHistoryRequest) (*ListMetricHistoryRequest, error) { + if v == nil { + return nil, nil + } + out := &ListMetricHistoryRequest{} + out.RunId = v.RunId + out.RunUuid = v.RunUuid + out.MetricKey = v.MetricKey + out.PageToken = v.PageToken + out.MaxResults = v.MaxResults + return out, nil +} + +// LogBatchRequestToSDK converts the mirror to the sdk-go type. +func LogBatchRequestToSDK(w *LogBatchRequest) (*sdk.LogBatchRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.LogBatchRequest{} + out.RunId = w.RunId + conv43, err := convertSlice(w.Metrics, MetricToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogBatchRequest.Metrics", err) + } + out.Metrics = conv43 + conv44, err := convertSlice(w.Params, ParamToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogBatchRequest.Params", err) + } + out.Params = conv44 + conv45, err := convertSlice(w.Tags, RunTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogBatchRequest.Tags", err) + } + out.Tags = conv45 + return out, nil +} + +// LogBatchRequestFromSDK converts the sdk-go type to the mirror. +func LogBatchRequestFromSDK(v *sdk.LogBatchRequest) (*LogBatchRequest, error) { + if v == nil { + return nil, nil + } + out := &LogBatchRequest{} + out.RunId = v.RunId + conv46, err := convertSlice(v.Metrics, MetricFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogBatchRequest.Metrics", err) + } + out.Metrics = conv46 + conv47, err := convertSlice(v.Params, ParamFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogBatchRequest.Params", err) + } + out.Params = conv47 + conv48, err := convertSlice(v.Tags, RunTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogBatchRequest.Tags", err) + } + out.Tags = conv48 + return out, nil +} + +// LogInputsRequestToSDK converts the mirror to the sdk-go type. +func LogInputsRequestToSDK(w *LogInputsRequest) (*sdk.LogInputsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.LogInputsRequest{} + out.RunId = w.RunId + conv49, err := convertSlice(w.Datasets, DatasetInputToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogInputsRequest.Datasets", err) + } + out.Datasets = conv49 + conv50, err := convertSlice(w.Models, ModelInputToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogInputsRequest.Models", err) + } + out.Models = conv50 + return out, nil +} + +// LogInputsRequestFromSDK converts the sdk-go type to the mirror. +func LogInputsRequestFromSDK(v *sdk.LogInputsRequest) (*LogInputsRequest, error) { + if v == nil { + return nil, nil + } + out := &LogInputsRequest{} + out.RunId = v.RunId + conv51, err := convertSlice(v.Datasets, DatasetInputFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogInputsRequest.Datasets", err) + } + out.Datasets = conv51 + conv52, err := convertSlice(v.Models, ModelInputFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogInputsRequest.Models", err) + } + out.Models = conv52 + return out, nil +} + +// LogLoggedModelParamsRequestToSDK converts the mirror to the sdk-go type. +func LogLoggedModelParamsRequestToSDK(w *LogLoggedModelParamsRequest) (*sdk.LogLoggedModelParamsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.LogLoggedModelParamsRequest{} + out.ModelId = w.ModelId + conv53, err := convertSlice(w.Params, LoggedModelParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogLoggedModelParamsRequest.Params", err) + } + out.Params = conv53 + return out, nil +} + +// LogLoggedModelParamsRequestFromSDK converts the sdk-go type to the mirror. +func LogLoggedModelParamsRequestFromSDK(v *sdk.LogLoggedModelParamsRequest) (*LogLoggedModelParamsRequest, error) { + if v == nil { + return nil, nil + } + out := &LogLoggedModelParamsRequest{} + out.ModelId = v.ModelId + conv54, err := convertSlice(v.Params, LoggedModelParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogLoggedModelParamsRequest.Params", err) + } + out.Params = conv54 + return out, nil +} + +// LogMetricRequestToSDK converts the mirror to the sdk-go type. +func LogMetricRequestToSDK(w *LogMetricRequest) (*sdk.LogMetricRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.LogMetricRequest{} + out.RunId = w.RunId + out.RunUuid = w.RunUuid + out.Key = w.Key + out.Value = w.Value + out.Timestamp = w.Timestamp + out.Step = w.Step + out.ModelId = w.ModelId + out.DatasetName = w.DatasetName + out.DatasetDigest = w.DatasetDigest + return out, nil +} + +// LogMetricRequestFromSDK converts the sdk-go type to the mirror. +func LogMetricRequestFromSDK(v *sdk.LogMetricRequest) (*LogMetricRequest, error) { + if v == nil { + return nil, nil + } + out := &LogMetricRequest{} + out.RunId = v.RunId + out.RunUuid = v.RunUuid + out.Key = v.Key + out.Value = v.Value + out.Timestamp = v.Timestamp + out.Step = v.Step + out.ModelId = v.ModelId + out.DatasetName = v.DatasetName + out.DatasetDigest = v.DatasetDigest + return out, nil +} + +// LogModelRequestToSDK converts the mirror to the sdk-go type. +func LogModelRequestToSDK(w *LogModelRequest) (*sdk.LogModelRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.LogModelRequest{} + out.RunId = w.RunId + out.ModelJson = w.ModelJson + return out, nil +} + +// LogModelRequestFromSDK converts the sdk-go type to the mirror. +func LogModelRequestFromSDK(v *sdk.LogModelRequest) (*LogModelRequest, error) { + if v == nil { + return nil, nil + } + out := &LogModelRequest{} + out.RunId = v.RunId + out.ModelJson = v.ModelJson + return out, nil +} + +// LogOutputsRequestToSDK converts the mirror to the sdk-go type. +func LogOutputsRequestToSDK(w *LogOutputsRequest) (*sdk.LogOutputsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.LogOutputsRequest{} + out.RunId = w.RunId + conv55, err := convertSlice(w.Models, ModelOutputToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogOutputsRequest.Models", err) + } + out.Models = conv55 + return out, nil +} + +// LogOutputsRequestFromSDK converts the sdk-go type to the mirror. +func LogOutputsRequestFromSDK(v *sdk.LogOutputsRequest) (*LogOutputsRequest, error) { + if v == nil { + return nil, nil + } + out := &LogOutputsRequest{} + out.RunId = v.RunId + conv56, err := convertSlice(v.Models, ModelOutputFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogOutputsRequest.Models", err) + } + out.Models = conv56 + return out, nil +} + +// LogParamRequestToSDK converts the mirror to the sdk-go type. +func LogParamRequestToSDK(w *LogParamRequest) (*sdk.LogParamRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.LogParamRequest{} + out.RunId = w.RunId + out.RunUuid = w.RunUuid + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// LogParamRequestFromSDK converts the sdk-go type to the mirror. +func LogParamRequestFromSDK(v *sdk.LogParamRequest) (*LogParamRequest, error) { + if v == nil { + return nil, nil + } + out := &LogParamRequest{} + out.RunId = v.RunId + out.RunUuid = v.RunUuid + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// LoggedModelToSDK converts the mirror to the sdk-go type. +func LoggedModelToSDK(w *LoggedModel) (*sdk.LoggedModel, error) { + if w == nil { + return nil, nil + } + out := &sdk.LoggedModel{} + conv57, err := LoggedModelInfoToSDK(w.Info) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LoggedModel.Info", err) + } + out.Info = conv57 + conv58, err := LoggedModelDataToSDK(w.Data) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LoggedModel.Data", err) + } + out.Data = conv58 + return out, nil +} + +// LoggedModelFromSDK converts the sdk-go type to the mirror. +func LoggedModelFromSDK(v *sdk.LoggedModel) (*LoggedModel, error) { + if v == nil { + return nil, nil + } + out := &LoggedModel{} + conv59, err := LoggedModelInfoFromSDK(v.Info) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LoggedModel.Info", err) + } + out.Info = conv59 + conv60, err := LoggedModelDataFromSDK(v.Data) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LoggedModel.Data", err) + } + out.Data = conv60 + return out, nil +} + +// LoggedModelDataToSDK converts the mirror to the sdk-go type. +func LoggedModelDataToSDK(w *LoggedModelData) (*sdk.LoggedModelData, error) { + if w == nil { + return nil, nil + } + out := &sdk.LoggedModelData{} + conv61, err := convertSlice(w.Params, LoggedModelParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LoggedModelData.Params", err) + } + out.Params = conv61 + conv62, err := convertSlice(w.Metrics, MetricToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LoggedModelData.Metrics", err) + } + out.Metrics = conv62 + return out, nil +} + +// LoggedModelDataFromSDK converts the sdk-go type to the mirror. +func LoggedModelDataFromSDK(v *sdk.LoggedModelData) (*LoggedModelData, error) { + if v == nil { + return nil, nil + } + out := &LoggedModelData{} + conv63, err := convertSlice(v.Params, LoggedModelParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LoggedModelData.Params", err) + } + out.Params = conv63 + conv64, err := convertSlice(v.Metrics, MetricFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LoggedModelData.Metrics", err) + } + out.Metrics = conv64 + return out, nil +} + +// LoggedModelInfoToSDK converts the mirror to the sdk-go type. +func LoggedModelInfoToSDK(w *LoggedModelInfo) (*sdk.LoggedModelInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.LoggedModelInfo{} + out.ModelId = w.ModelId + out.ExperimentId = w.ExperimentId + out.Name = w.Name + out.CreationTimestampMs = w.CreationTimestampMs + out.LastUpdatedTimestampMs = w.LastUpdatedTimestampMs + out.ArtifactUri = w.ArtifactUri + out.Status = w.Status + out.CreatorId = w.CreatorId + out.ModelType = w.ModelType + out.SourceRunId = w.SourceRunId + out.StatusMessage = w.StatusMessage + conv65, err := convertSlice(w.Tags, LoggedModelTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LoggedModelInfo.Tags", err) + } + out.Tags = conv65 + return out, nil +} + +// LoggedModelInfoFromSDK converts the sdk-go type to the mirror. +func LoggedModelInfoFromSDK(v *sdk.LoggedModelInfo) (*LoggedModelInfo, error) { + if v == nil { + return nil, nil + } + out := &LoggedModelInfo{} + out.ModelId = v.ModelId + out.ExperimentId = v.ExperimentId + out.Name = v.Name + out.CreationTimestampMs = v.CreationTimestampMs + out.LastUpdatedTimestampMs = v.LastUpdatedTimestampMs + out.ArtifactUri = v.ArtifactUri + out.Status = v.Status + out.CreatorId = v.CreatorId + out.ModelType = v.ModelType + out.SourceRunId = v.SourceRunId + out.StatusMessage = v.StatusMessage + conv66, err := convertSlice(v.Tags, LoggedModelTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LoggedModelInfo.Tags", err) + } + out.Tags = conv66 + return out, nil +} + +// LoggedModelParameterToSDK converts the mirror to the sdk-go type. +func LoggedModelParameterToSDK(w *LoggedModelParameter) (*sdk.LoggedModelParameter, error) { + if w == nil { + return nil, nil + } + out := &sdk.LoggedModelParameter{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// LoggedModelParameterFromSDK converts the sdk-go type to the mirror. +func LoggedModelParameterFromSDK(v *sdk.LoggedModelParameter) (*LoggedModelParameter, error) { + if v == nil { + return nil, nil + } + out := &LoggedModelParameter{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// LoggedModelTagToSDK converts the mirror to the sdk-go type. +func LoggedModelTagToSDK(w *LoggedModelTag) (*sdk.LoggedModelTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.LoggedModelTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// LoggedModelTagFromSDK converts the sdk-go type to the mirror. +func LoggedModelTagFromSDK(v *sdk.LoggedModelTag) (*LoggedModelTag, error) { + if v == nil { + return nil, nil + } + out := &LoggedModelTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// MetricToSDK converts the mirror to the sdk-go type. +func MetricToSDK(w *Metric) (*sdk.Metric, error) { + if w == nil { + return nil, nil + } + out := &sdk.Metric{} + out.Key = w.Key + out.Value = w.Value + out.Timestamp = w.Timestamp + out.Step = w.Step + out.DatasetName = w.DatasetName + out.DatasetDigest = w.DatasetDigest + out.ModelId = w.ModelId + out.RunId = w.RunId + return out, nil +} + +// MetricFromSDK converts the sdk-go type to the mirror. +func MetricFromSDK(v *sdk.Metric) (*Metric, error) { + if v == nil { + return nil, nil + } + out := &Metric{} + out.Key = v.Key + out.Value = v.Value + out.Timestamp = v.Timestamp + out.Step = v.Step + out.DatasetName = v.DatasetName + out.DatasetDigest = v.DatasetDigest + out.ModelId = v.ModelId + out.RunId = v.RunId + return out, nil +} + +// ModelInputToSDK converts the mirror to the sdk-go type. +func ModelInputToSDK(w *ModelInput) (*sdk.ModelInput, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelInput{} + out.ModelId = w.ModelId + return out, nil +} + +// ModelInputFromSDK converts the sdk-go type to the mirror. +func ModelInputFromSDK(v *sdk.ModelInput) (*ModelInput, error) { + if v == nil { + return nil, nil + } + out := &ModelInput{} + out.ModelId = v.ModelId + return out, nil +} + +// ModelOutputToSDK converts the mirror to the sdk-go type. +func ModelOutputToSDK(w *ModelOutput) (*sdk.ModelOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelOutput{} + out.ModelId = w.ModelId + out.Step = w.Step + return out, nil +} + +// ModelOutputFromSDK converts the sdk-go type to the mirror. +func ModelOutputFromSDK(v *sdk.ModelOutput) (*ModelOutput, error) { + if v == nil { + return nil, nil + } + out := &ModelOutput{} + out.ModelId = v.ModelId + out.Step = v.Step + return out, nil +} + +// ParamToSDK converts the mirror to the sdk-go type. +func ParamToSDK(w *Param) (*sdk.Param, error) { + if w == nil { + return nil, nil + } + out := &sdk.Param{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// ParamFromSDK converts the sdk-go type to the mirror. +func ParamFromSDK(v *sdk.Param) (*Param, error) { + if v == nil { + return nil, nil + } + out := &Param{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// RestoreExperimentRequestToSDK converts the mirror to the sdk-go type. +func RestoreExperimentRequestToSDK(w *RestoreExperimentRequest) (*sdk.RestoreExperimentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RestoreExperimentRequest{} + out.ExperimentId = w.ExperimentId + return out, nil +} + +// RestoreExperimentRequestFromSDK converts the sdk-go type to the mirror. +func RestoreExperimentRequestFromSDK(v *sdk.RestoreExperimentRequest) (*RestoreExperimentRequest, error) { + if v == nil { + return nil, nil + } + out := &RestoreExperimentRequest{} + out.ExperimentId = v.ExperimentId + return out, nil +} + +// RestoreRunRequestToSDK converts the mirror to the sdk-go type. +func RestoreRunRequestToSDK(w *RestoreRunRequest) (*sdk.RestoreRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RestoreRunRequest{} + out.RunId = w.RunId + return out, nil +} + +// RestoreRunRequestFromSDK converts the sdk-go type to the mirror. +func RestoreRunRequestFromSDK(v *sdk.RestoreRunRequest) (*RestoreRunRequest, error) { + if v == nil { + return nil, nil + } + out := &RestoreRunRequest{} + out.RunId = v.RunId + return out, nil +} + +// RestoreRunsRequestToSDK converts the mirror to the sdk-go type. +func RestoreRunsRequestToSDK(w *RestoreRunsRequest) (*sdk.RestoreRunsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RestoreRunsRequest{} + out.ExperimentId = w.ExperimentId + out.MinTimestampMillis = w.MinTimestampMillis + out.MaxRuns = w.MaxRuns + return out, nil +} + +// RestoreRunsRequestFromSDK converts the sdk-go type to the mirror. +func RestoreRunsRequestFromSDK(v *sdk.RestoreRunsRequest) (*RestoreRunsRequest, error) { + if v == nil { + return nil, nil + } + out := &RestoreRunsRequest{} + out.ExperimentId = v.ExperimentId + out.MinTimestampMillis = v.MinTimestampMillis + out.MaxRuns = v.MaxRuns + return out, nil +} + +// RestoreRunsResponseToSDK converts the mirror to the sdk-go type. +func RestoreRunsResponseToSDK(w *RestoreRunsResponse) (*sdk.RestoreRunsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.RestoreRunsResponse{} + out.RunsRestored = w.RunsRestored + return out, nil +} + +// RestoreRunsResponseFromSDK converts the sdk-go type to the mirror. +func RestoreRunsResponseFromSDK(v *sdk.RestoreRunsResponse) (*RestoreRunsResponse, error) { + if v == nil { + return nil, nil + } + out := &RestoreRunsResponse{} + out.RunsRestored = v.RunsRestored + return out, nil +} + +// RunToSDK converts the mirror to the sdk-go type. +func RunToSDK(w *Run) (*sdk.Run, error) { + if w == nil { + return nil, nil + } + out := &sdk.Run{} + conv67, err := RunInfoToSDK(w.Info) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.Info", err) + } + out.Info = conv67 + conv68, err := RunDataToSDK(w.Data) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.Data", err) + } + out.Data = conv68 + conv69, err := RunInputsToSDK(w.Inputs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.Inputs", err) + } + out.Inputs = conv69 + return out, nil +} + +// RunFromSDK converts the sdk-go type to the mirror. +func RunFromSDK(v *sdk.Run) (*Run, error) { + if v == nil { + return nil, nil + } + out := &Run{} + conv70, err := RunInfoFromSDK(v.Info) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.Info", err) + } + out.Info = conv70 + conv71, err := RunDataFromSDK(v.Data) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.Data", err) + } + out.Data = conv71 + conv72, err := RunInputsFromSDK(v.Inputs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.Inputs", err) + } + out.Inputs = conv72 + return out, nil +} + +// RunDataToSDK converts the mirror to the sdk-go type. +func RunDataToSDK(w *RunData) (*sdk.RunData, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunData{} + conv73, err := convertSlice(w.Metrics, MetricToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunData.Metrics", err) + } + out.Metrics = conv73 + conv74, err := convertSlice(w.Params, ParamToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunData.Params", err) + } + out.Params = conv74 + conv75, err := convertSlice(w.Tags, RunTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunData.Tags", err) + } + out.Tags = conv75 + return out, nil +} + +// RunDataFromSDK converts the sdk-go type to the mirror. +func RunDataFromSDK(v *sdk.RunData) (*RunData, error) { + if v == nil { + return nil, nil + } + out := &RunData{} + conv76, err := convertSlice(v.Metrics, MetricFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunData.Metrics", err) + } + out.Metrics = conv76 + conv77, err := convertSlice(v.Params, ParamFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunData.Params", err) + } + out.Params = conv77 + conv78, err := convertSlice(v.Tags, RunTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunData.Tags", err) + } + out.Tags = conv78 + return out, nil +} + +// RunInfoToSDK converts the mirror to the sdk-go type. +func RunInfoToSDK(w *RunInfo) (*sdk.RunInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunInfo{} + out.RunId = w.RunId + out.RunUuid = w.RunUuid + out.ExperimentId = w.ExperimentId + out.RunName = w.RunName + out.UserId = w.UserId + out.Status = w.Status + out.StartTime = w.StartTime + out.EndTime = w.EndTime + out.ArtifactUri = w.ArtifactUri + out.LifecycleStage = w.LifecycleStage + return out, nil +} + +// RunInfoFromSDK converts the sdk-go type to the mirror. +func RunInfoFromSDK(v *sdk.RunInfo) (*RunInfo, error) { + if v == nil { + return nil, nil + } + out := &RunInfo{} + out.RunId = v.RunId + out.RunUuid = v.RunUuid + out.ExperimentId = v.ExperimentId + out.RunName = v.RunName + out.UserId = v.UserId + out.Status = v.Status + out.StartTime = v.StartTime + out.EndTime = v.EndTime + out.ArtifactUri = v.ArtifactUri + out.LifecycleStage = v.LifecycleStage + return out, nil +} + +// RunInputsToSDK converts the mirror to the sdk-go type. +func RunInputsToSDK(w *RunInputs) (*sdk.RunInputs, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunInputs{} + conv79, err := convertSlice(w.DatasetInputs, DatasetInputToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunInputs.DatasetInputs", err) + } + out.DatasetInputs = conv79 + conv80, err := convertSlice(w.ModelInputs, ModelInputToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunInputs.ModelInputs", err) + } + out.ModelInputs = conv80 + return out, nil +} + +// RunInputsFromSDK converts the sdk-go type to the mirror. +func RunInputsFromSDK(v *sdk.RunInputs) (*RunInputs, error) { + if v == nil { + return nil, nil + } + out := &RunInputs{} + conv81, err := convertSlice(v.DatasetInputs, DatasetInputFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunInputs.DatasetInputs", err) + } + out.DatasetInputs = conv81 + conv82, err := convertSlice(v.ModelInputs, ModelInputFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunInputs.ModelInputs", err) + } + out.ModelInputs = conv82 + return out, nil +} + +// RunTagToSDK converts the mirror to the sdk-go type. +func RunTagToSDK(w *RunTag) (*sdk.RunTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// RunTagFromSDK converts the sdk-go type to the mirror. +func RunTagFromSDK(v *sdk.RunTag) (*RunTag, error) { + if v == nil { + return nil, nil + } + out := &RunTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// SearchExperimentsRequestToSDK converts the mirror to the sdk-go type. +func SearchExperimentsRequestToSDK(w *SearchExperimentsRequest) (*sdk.SearchExperimentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchExperimentsRequest{} + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + out.Filter = w.Filter + out.OrderBy = w.OrderBy + out.ViewType = w.ViewType + return out, nil +} + +// SearchExperimentsRequestFromSDK converts the sdk-go type to the mirror. +func SearchExperimentsRequestFromSDK(v *sdk.SearchExperimentsRequest) (*SearchExperimentsRequest, error) { + if v == nil { + return nil, nil + } + out := &SearchExperimentsRequest{} + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + out.Filter = v.Filter + out.OrderBy = v.OrderBy + out.ViewType = v.ViewType + return out, nil +} + +// SearchExperimentsResponseToSDK converts the mirror to the sdk-go type. +func SearchExperimentsResponseToSDK(w *SearchExperimentsResponse) (*sdk.SearchExperimentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchExperimentsResponse{} + conv83, err := convertSlice(w.Experiments, ExperimentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchExperimentsResponse.Experiments", err) + } + out.Experiments = conv83 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// SearchExperimentsResponseFromSDK converts the sdk-go type to the mirror. +func SearchExperimentsResponseFromSDK(v *sdk.SearchExperimentsResponse) (*SearchExperimentsResponse, error) { + if v == nil { + return nil, nil + } + out := &SearchExperimentsResponse{} + conv84, err := convertSlice(v.Experiments, ExperimentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchExperimentsResponse.Experiments", err) + } + out.Experiments = conv84 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SearchLoggedModelsRequestToSDK converts the mirror to the sdk-go type. +func SearchLoggedModelsRequestToSDK(w *SearchLoggedModelsRequest) (*sdk.SearchLoggedModelsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchLoggedModelsRequest{} + out.ExperimentIds = w.ExperimentIds + out.Filter = w.Filter + conv85, err := convertSlice(w.Datasets, SearchLoggedModelsRequest_DatasetToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchLoggedModelsRequest.Datasets", err) + } + out.Datasets = conv85 + out.MaxResults = w.MaxResults + conv86, err := convertSlice(w.OrderBy, SearchLoggedModelsRequest_OrderByToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchLoggedModelsRequest.OrderBy", err) + } + out.OrderBy = conv86 + out.PageToken = w.PageToken + return out, nil +} + +// SearchLoggedModelsRequestFromSDK converts the sdk-go type to the mirror. +func SearchLoggedModelsRequestFromSDK(v *sdk.SearchLoggedModelsRequest) (*SearchLoggedModelsRequest, error) { + if v == nil { + return nil, nil + } + out := &SearchLoggedModelsRequest{} + out.ExperimentIds = v.ExperimentIds + out.Filter = v.Filter + conv87, err := convertSlice(v.Datasets, SearchLoggedModelsRequest_DatasetFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchLoggedModelsRequest.Datasets", err) + } + out.Datasets = conv87 + out.MaxResults = v.MaxResults + conv88, err := convertSlice(v.OrderBy, SearchLoggedModelsRequest_OrderByFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchLoggedModelsRequest.OrderBy", err) + } + out.OrderBy = conv88 + out.PageToken = v.PageToken + return out, nil +} + +// SearchLoggedModelsRequest_DatasetToSDK converts the mirror to the sdk-go type. +func SearchLoggedModelsRequest_DatasetToSDK(w *SearchLoggedModelsRequest_Dataset) (*sdk.SearchLoggedModelsRequest_Dataset, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchLoggedModelsRequest_Dataset{} + out.DatasetName = w.DatasetName + out.DatasetDigest = w.DatasetDigest + return out, nil +} + +// SearchLoggedModelsRequest_DatasetFromSDK converts the sdk-go type to the mirror. +func SearchLoggedModelsRequest_DatasetFromSDK(v *sdk.SearchLoggedModelsRequest_Dataset) (*SearchLoggedModelsRequest_Dataset, error) { + if v == nil { + return nil, nil + } + out := &SearchLoggedModelsRequest_Dataset{} + out.DatasetName = v.DatasetName + out.DatasetDigest = v.DatasetDigest + return out, nil +} + +// SearchLoggedModelsRequest_OrderByToSDK converts the mirror to the sdk-go type. +func SearchLoggedModelsRequest_OrderByToSDK(w *SearchLoggedModelsRequest_OrderBy) (*sdk.SearchLoggedModelsRequest_OrderBy, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchLoggedModelsRequest_OrderBy{} + out.FieldName = w.FieldName + out.Ascending = w.Ascending + out.DatasetName = w.DatasetName + out.DatasetDigest = w.DatasetDigest + return out, nil +} + +// SearchLoggedModelsRequest_OrderByFromSDK converts the sdk-go type to the mirror. +func SearchLoggedModelsRequest_OrderByFromSDK(v *sdk.SearchLoggedModelsRequest_OrderBy) (*SearchLoggedModelsRequest_OrderBy, error) { + if v == nil { + return nil, nil + } + out := &SearchLoggedModelsRequest_OrderBy{} + out.FieldName = v.FieldName + out.Ascending = v.Ascending + out.DatasetName = v.DatasetName + out.DatasetDigest = v.DatasetDigest + return out, nil +} + +// SearchLoggedModelsResponseToSDK converts the mirror to the sdk-go type. +func SearchLoggedModelsResponseToSDK(w *SearchLoggedModelsResponse) (*sdk.SearchLoggedModelsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchLoggedModelsResponse{} + conv89, err := convertSlice(w.Models, LoggedModelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchLoggedModelsResponse.Models", err) + } + out.Models = conv89 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// SearchLoggedModelsResponseFromSDK converts the sdk-go type to the mirror. +func SearchLoggedModelsResponseFromSDK(v *sdk.SearchLoggedModelsResponse) (*SearchLoggedModelsResponse, error) { + if v == nil { + return nil, nil + } + out := &SearchLoggedModelsResponse{} + conv90, err := convertSlice(v.Models, LoggedModelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchLoggedModelsResponse.Models", err) + } + out.Models = conv90 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SearchRunsRequestToSDK converts the mirror to the sdk-go type. +func SearchRunsRequestToSDK(w *SearchRunsRequest) (*sdk.SearchRunsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchRunsRequest{} + out.ExperimentIds = w.ExperimentIds + out.Filter = w.Filter + out.RunViewType = w.RunViewType + out.MaxResults = w.MaxResults + out.OrderBy = w.OrderBy + out.PageToken = w.PageToken + return out, nil +} + +// SearchRunsRequestFromSDK converts the sdk-go type to the mirror. +func SearchRunsRequestFromSDK(v *sdk.SearchRunsRequest) (*SearchRunsRequest, error) { + if v == nil { + return nil, nil + } + out := &SearchRunsRequest{} + out.ExperimentIds = v.ExperimentIds + out.Filter = v.Filter + out.RunViewType = v.RunViewType + out.MaxResults = v.MaxResults + out.OrderBy = v.OrderBy + out.PageToken = v.PageToken + return out, nil +} + +// SearchRunsResponseToSDK converts the mirror to the sdk-go type. +func SearchRunsResponseToSDK(w *SearchRunsResponse) (*sdk.SearchRunsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchRunsResponse{} + conv91, err := convertSlice(w.Runs, RunToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchRunsResponse.Runs", err) + } + out.Runs = conv91 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// SearchRunsResponseFromSDK converts the sdk-go type to the mirror. +func SearchRunsResponseFromSDK(v *sdk.SearchRunsResponse) (*SearchRunsResponse, error) { + if v == nil { + return nil, nil + } + out := &SearchRunsResponse{} + conv92, err := convertSlice(v.Runs, RunFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchRunsResponse.Runs", err) + } + out.Runs = conv92 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SetExperimentTagRequestToSDK converts the mirror to the sdk-go type. +func SetExperimentTagRequestToSDK(w *SetExperimentTagRequest) (*sdk.SetExperimentTagRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SetExperimentTagRequest{} + out.ExperimentId = w.ExperimentId + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// SetExperimentTagRequestFromSDK converts the sdk-go type to the mirror. +func SetExperimentTagRequestFromSDK(v *sdk.SetExperimentTagRequest) (*SetExperimentTagRequest, error) { + if v == nil { + return nil, nil + } + out := &SetExperimentTagRequest{} + out.ExperimentId = v.ExperimentId + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// SetLoggedModelTagsRequestToSDK converts the mirror to the sdk-go type. +func SetLoggedModelTagsRequestToSDK(w *SetLoggedModelTagsRequest) (*sdk.SetLoggedModelTagsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SetLoggedModelTagsRequest{} + out.ModelId = w.ModelId + conv93, err := convertSlice(w.Tags, LoggedModelTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetLoggedModelTagsRequest.Tags", err) + } + out.Tags = conv93 + return out, nil +} + +// SetLoggedModelTagsRequestFromSDK converts the sdk-go type to the mirror. +func SetLoggedModelTagsRequestFromSDK(v *sdk.SetLoggedModelTagsRequest) (*SetLoggedModelTagsRequest, error) { + if v == nil { + return nil, nil + } + out := &SetLoggedModelTagsRequest{} + out.ModelId = v.ModelId + conv94, err := convertSlice(v.Tags, LoggedModelTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetLoggedModelTagsRequest.Tags", err) + } + out.Tags = conv94 + return out, nil +} + +// SetTagRequestToSDK converts the mirror to the sdk-go type. +func SetTagRequestToSDK(w *SetTagRequest) (*sdk.SetTagRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SetTagRequest{} + out.RunId = w.RunId + out.RunUuid = w.RunUuid + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// SetTagRequestFromSDK converts the sdk-go type to the mirror. +func SetTagRequestFromSDK(v *sdk.SetTagRequest) (*SetTagRequest, error) { + if v == nil { + return nil, nil + } + out := &SetTagRequest{} + out.RunId = v.RunId + out.RunUuid = v.RunUuid + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// UcTraceLocationToSDK converts the mirror to the sdk-go type. +func UcTraceLocationToSDK(w *UcTraceLocation) (*sdk.UcTraceLocation, error) { + if w == nil { + return nil, nil + } + out := &sdk.UcTraceLocation{} + out.Catalog = w.Catalog + out.Schema = w.Schema + out.TablePrefix = w.TablePrefix + out.EffectiveTablePrefix = w.EffectiveTablePrefix + return out, nil +} + +// UcTraceLocationFromSDK converts the sdk-go type to the mirror. +func UcTraceLocationFromSDK(v *sdk.UcTraceLocation) (*UcTraceLocation, error) { + if v == nil { + return nil, nil + } + out := &UcTraceLocation{} + out.Catalog = v.Catalog + out.Schema = v.Schema + out.TablePrefix = v.TablePrefix + out.EffectiveTablePrefix = v.EffectiveTablePrefix + return out, nil +} + +// UpdateExperimentRequestToSDK converts the mirror to the sdk-go type. +func UpdateExperimentRequestToSDK(w *UpdateExperimentRequest) (*sdk.UpdateExperimentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateExperimentRequest{} + out.ExperimentId = w.ExperimentId + out.NewName = w.NewName + return out, nil +} + +// UpdateExperimentRequestFromSDK converts the sdk-go type to the mirror. +func UpdateExperimentRequestFromSDK(v *sdk.UpdateExperimentRequest) (*UpdateExperimentRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateExperimentRequest{} + out.ExperimentId = v.ExperimentId + out.NewName = v.NewName + return out, nil +} + +// UpdateRunRequestToSDK converts the mirror to the sdk-go type. +func UpdateRunRequestToSDK(w *UpdateRunRequest) (*sdk.UpdateRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRunRequest{} + out.RunId = w.RunId + out.RunUuid = w.RunUuid + out.Status = w.Status + out.EndTime = w.EndTime + out.RunName = w.RunName + return out, nil +} + +// UpdateRunRequestFromSDK converts the sdk-go type to the mirror. +func UpdateRunRequestFromSDK(v *sdk.UpdateRunRequest) (*UpdateRunRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateRunRequest{} + out.RunId = v.RunId + out.RunUuid = v.RunUuid + out.Status = v.Status + out.EndTime = v.EndTime + out.RunName = v.RunName + return out, nil +} + +// UpdateRunResponseToSDK converts the mirror to the sdk-go type. +func UpdateRunResponseToSDK(w *UpdateRunResponse) (*sdk.UpdateRunResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRunResponse{} + conv95, err := RunInfoToSDK(w.RunInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRunResponse.RunInfo", err) + } + out.RunInfo = conv95 + return out, nil +} + +// UpdateRunResponseFromSDK converts the sdk-go type to the mirror. +func UpdateRunResponseFromSDK(v *sdk.UpdateRunResponse) (*UpdateRunResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateRunResponse{} + conv96, err := RunInfoFromSDK(v.RunInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRunResponse.RunInfo", err) + } + out.RunInfo = conv96 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/features/v1/types.generated.go b/libs/sdktypes/features/v1/types.generated.go new file mode 100644 index 00000000000..815e4070c56 --- /dev/null +++ b/libs/sdktypes/features/v1/types.generated.go @@ -0,0 +1,5540 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/features/v1. DO NOT EDIT. + +package features + +import ( + json "encoding/json" + fmt "fmt" + sdk "github.com/databricks/sdk-go/features/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + ErrorCode = sdk.ErrorCode + FunctionFunctionType = sdk.FunctionFunctionType + ScalarDataType = sdk.ScalarDataType + BackfillOperationMetadata_State = sdk.BackfillOperationMetadata_State + CronSchedule_Mode = sdk.CronSchedule_Mode + MaterializedFeature_PipelineScheduleState = sdk.MaterializedFeature_PipelineScheduleState + PurgeFeatureEntitiesMetadata_State = sdk.PurgeFeatureEntitiesMetadata_State + PurgeFeatureEntitiesResult_State = sdk.PurgeFeatureEntitiesResult_State + SchemaLocator_Format = sdk.SchemaLocator_Format + StreamingMode_StreamingModeType = sdk.StreamingMode_StreamingModeType +) + +const ( + ErrorCode_Unspecified = sdk.ErrorCode_Unspecified + ErrorCode_InternalError = sdk.ErrorCode_InternalError + ErrorCode_TemporarilyUnavailable = sdk.ErrorCode_TemporarilyUnavailable + ErrorCode_IoError = sdk.ErrorCode_IoError + ErrorCode_BadRequest = sdk.ErrorCode_BadRequest + ErrorCode_ServiceUnderMaintenance = sdk.ErrorCode_ServiceUnderMaintenance + ErrorCode_WorkspaceTemporarilyUnavailable = sdk.ErrorCode_WorkspaceTemporarilyUnavailable + ErrorCode_DeadlineExceeded = sdk.ErrorCode_DeadlineExceeded + ErrorCode_Cancelled = sdk.ErrorCode_Cancelled + ErrorCode_ResourceExhausted = sdk.ErrorCode_ResourceExhausted + ErrorCode_Aborted = sdk.ErrorCode_Aborted + ErrorCode_NotFound = sdk.ErrorCode_NotFound + ErrorCode_AlreadyExists = sdk.ErrorCode_AlreadyExists + ErrorCode_Unauthenticated = sdk.ErrorCode_Unauthenticated + ErrorCode_Unavailable = sdk.ErrorCode_Unavailable + ErrorCode_InvalidParameterValue = sdk.ErrorCode_InvalidParameterValue + ErrorCode_EndpointNotFound = sdk.ErrorCode_EndpointNotFound + ErrorCode_MalformedRequest = sdk.ErrorCode_MalformedRequest + ErrorCode_InvalidState = sdk.ErrorCode_InvalidState + ErrorCode_PermissionDenied = sdk.ErrorCode_PermissionDenied + ErrorCode_FeatureDisabled = sdk.ErrorCode_FeatureDisabled + ErrorCode_CustomerUnauthorized = sdk.ErrorCode_CustomerUnauthorized + ErrorCode_RequestLimitExceeded = sdk.ErrorCode_RequestLimitExceeded + ErrorCode_ResourceConflict = sdk.ErrorCode_ResourceConflict + ErrorCode_UnparseableHttpError = sdk.ErrorCode_UnparseableHttpError + ErrorCode_NotImplemented = sdk.ErrorCode_NotImplemented + ErrorCode_DataLoss = sdk.ErrorCode_DataLoss + ErrorCode_InvalidStateTransition = sdk.ErrorCode_InvalidStateTransition + ErrorCode_CouldNotAcquireLock = sdk.ErrorCode_CouldNotAcquireLock + ErrorCode_ResourceAlreadyExists = sdk.ErrorCode_ResourceAlreadyExists + ErrorCode_ResourceDoesNotExist = sdk.ErrorCode_ResourceDoesNotExist + ErrorCode_QuotaExceeded = sdk.ErrorCode_QuotaExceeded + ErrorCode_MaxBlockSizeExceeded = sdk.ErrorCode_MaxBlockSizeExceeded + ErrorCode_MaxReadSizeExceeded = sdk.ErrorCode_MaxReadSizeExceeded + ErrorCode_PartialDelete = sdk.ErrorCode_PartialDelete + ErrorCode_MaxListSizeExceeded = sdk.ErrorCode_MaxListSizeExceeded + ErrorCode_DryRunFailed = sdk.ErrorCode_DryRunFailed + ErrorCode_ResourceLimitExceeded = sdk.ErrorCode_ResourceLimitExceeded + ErrorCode_DirectoryNotEmpty = sdk.ErrorCode_DirectoryNotEmpty + ErrorCode_DirectoryProtected = sdk.ErrorCode_DirectoryProtected + ErrorCode_MaxNotebookSizeExceeded = sdk.ErrorCode_MaxNotebookSizeExceeded + ErrorCode_MaxChildNodeSizeExceeded = sdk.ErrorCode_MaxChildNodeSizeExceeded + ErrorCode_SearchQueryTooLong = sdk.ErrorCode_SearchQueryTooLong + ErrorCode_SearchQueryTooShort = sdk.ErrorCode_SearchQueryTooShort + ErrorCode_ManagedResourceGroupDoesNotExist = sdk.ErrorCode_ManagedResourceGroupDoesNotExist + ErrorCode_PermissionNotPropagated = sdk.ErrorCode_PermissionNotPropagated + ErrorCode_DeploymentTimeout = sdk.ErrorCode_DeploymentTimeout + ErrorCode_GitConflict = sdk.ErrorCode_GitConflict + ErrorCode_GitUnknownRef = sdk.ErrorCode_GitUnknownRef + ErrorCode_GitSensitiveTokenDetected = sdk.ErrorCode_GitSensitiveTokenDetected + ErrorCode_GitUrlNotOnAllowList = sdk.ErrorCode_GitUrlNotOnAllowList + ErrorCode_GitRemoteError = sdk.ErrorCode_GitRemoteError + ErrorCode_ProjectsOperationTimeout = sdk.ErrorCode_ProjectsOperationTimeout + ErrorCode_IpynbFileInRepo = sdk.ErrorCode_IpynbFileInRepo + ErrorCode_InsecurePartnerResponse = sdk.ErrorCode_InsecurePartnerResponse + ErrorCode_MalformedPartnerResponse = sdk.ErrorCode_MalformedPartnerResponse + ErrorCode_MetastoreDoesNotExist = sdk.ErrorCode_MetastoreDoesNotExist + ErrorCode_DacDoesNotExist = sdk.ErrorCode_DacDoesNotExist + ErrorCode_CatalogDoesNotExist = sdk.ErrorCode_CatalogDoesNotExist + ErrorCode_SchemaDoesNotExist = sdk.ErrorCode_SchemaDoesNotExist + ErrorCode_TableDoesNotExist = sdk.ErrorCode_TableDoesNotExist + ErrorCode_ShareDoesNotExist = sdk.ErrorCode_ShareDoesNotExist + ErrorCode_RecipientDoesNotExist = sdk.ErrorCode_RecipientDoesNotExist + ErrorCode_StorageCredentialDoesNotExist = sdk.ErrorCode_StorageCredentialDoesNotExist + ErrorCode_ExternalLocationDoesNotExist = sdk.ErrorCode_ExternalLocationDoesNotExist + ErrorCode_PrincipalDoesNotExist = sdk.ErrorCode_PrincipalDoesNotExist + ErrorCode_ProviderDoesNotExist = sdk.ErrorCode_ProviderDoesNotExist + ErrorCode_MetastoreAlreadyExists = sdk.ErrorCode_MetastoreAlreadyExists + ErrorCode_DacAlreadyExists = sdk.ErrorCode_DacAlreadyExists + ErrorCode_CatalogAlreadyExists = sdk.ErrorCode_CatalogAlreadyExists + ErrorCode_SchemaAlreadyExists = sdk.ErrorCode_SchemaAlreadyExists + ErrorCode_TableAlreadyExists = sdk.ErrorCode_TableAlreadyExists + ErrorCode_ShareAlreadyExists = sdk.ErrorCode_ShareAlreadyExists + ErrorCode_RecipientAlreadyExists = sdk.ErrorCode_RecipientAlreadyExists + ErrorCode_StorageCredentialAlreadyExists = sdk.ErrorCode_StorageCredentialAlreadyExists + ErrorCode_ExternalLocationAlreadyExists = sdk.ErrorCode_ExternalLocationAlreadyExists + ErrorCode_ProviderAlreadyExists = sdk.ErrorCode_ProviderAlreadyExists + ErrorCode_CatalogNotEmpty = sdk.ErrorCode_CatalogNotEmpty + ErrorCode_SchemaNotEmpty = sdk.ErrorCode_SchemaNotEmpty + ErrorCode_MetastoreNotEmpty = sdk.ErrorCode_MetastoreNotEmpty + ErrorCode_ProviderShareNotAccessible = sdk.ErrorCode_ProviderShareNotAccessible + FunctionFunctionType_Unspecified = sdk.FunctionFunctionType_Unspecified + FunctionFunctionType_Avg = sdk.FunctionFunctionType_Avg + FunctionFunctionType_Count = sdk.FunctionFunctionType_Count + FunctionFunctionType_Sum = sdk.FunctionFunctionType_Sum + FunctionFunctionType_Min = sdk.FunctionFunctionType_Min + FunctionFunctionType_Max = sdk.FunctionFunctionType_Max + FunctionFunctionType_First = sdk.FunctionFunctionType_First + FunctionFunctionType_Last = sdk.FunctionFunctionType_Last + FunctionFunctionType_ApproxCountDistinct = sdk.FunctionFunctionType_ApproxCountDistinct + FunctionFunctionType_ApproxPercentile = sdk.FunctionFunctionType_ApproxPercentile + FunctionFunctionType_StddevPop = sdk.FunctionFunctionType_StddevPop + FunctionFunctionType_StddevSamp = sdk.FunctionFunctionType_StddevSamp + FunctionFunctionType_VarPop = sdk.FunctionFunctionType_VarPop + FunctionFunctionType_VarSamp = sdk.FunctionFunctionType_VarSamp + ScalarDataType_Unspecified = sdk.ScalarDataType_Unspecified + ScalarDataType_Integer = sdk.ScalarDataType_Integer + ScalarDataType_Float = sdk.ScalarDataType_Float + ScalarDataType_Boolean = sdk.ScalarDataType_Boolean + ScalarDataType_String = sdk.ScalarDataType_String + ScalarDataType_Double = sdk.ScalarDataType_Double + ScalarDataType_Long = sdk.ScalarDataType_Long + ScalarDataType_Timestamp = sdk.ScalarDataType_Timestamp + ScalarDataType_Date = sdk.ScalarDataType_Date + ScalarDataType_Short = sdk.ScalarDataType_Short + ScalarDataType_Binary = sdk.ScalarDataType_Binary + ScalarDataType_Decimal = sdk.ScalarDataType_Decimal + BackfillOperationMetadata_State_Unspecified = sdk.BackfillOperationMetadata_State_Unspecified + BackfillOperationMetadata_State_Pending = sdk.BackfillOperationMetadata_State_Pending + BackfillOperationMetadata_State_Running = sdk.BackfillOperationMetadata_State_Running + BackfillOperationMetadata_State_Succeeded = sdk.BackfillOperationMetadata_State_Succeeded + BackfillOperationMetadata_State_Failed = sdk.BackfillOperationMetadata_State_Failed + BackfillOperationMetadata_State_Cancelled = sdk.BackfillOperationMetadata_State_Cancelled + CronSchedule_Mode_Unspecified = sdk.CronSchedule_Mode_Unspecified + CronSchedule_Mode_Manual = sdk.CronSchedule_Mode_Manual + CronSchedule_Mode_Derived = sdk.CronSchedule_Mode_Derived + MaterializedFeature_PipelineScheduleState_Unspecified = sdk.MaterializedFeature_PipelineScheduleState_Unspecified + MaterializedFeature_PipelineScheduleState_Snapshot = sdk.MaterializedFeature_PipelineScheduleState_Snapshot + MaterializedFeature_PipelineScheduleState_Active = sdk.MaterializedFeature_PipelineScheduleState_Active + MaterializedFeature_PipelineScheduleState_Paused = sdk.MaterializedFeature_PipelineScheduleState_Paused + PurgeFeatureEntitiesMetadata_State_Unspecified = sdk.PurgeFeatureEntitiesMetadata_State_Unspecified + PurgeFeatureEntitiesMetadata_State_Pending = sdk.PurgeFeatureEntitiesMetadata_State_Pending + PurgeFeatureEntitiesMetadata_State_Running = sdk.PurgeFeatureEntitiesMetadata_State_Running + PurgeFeatureEntitiesMetadata_State_Succeeded = sdk.PurgeFeatureEntitiesMetadata_State_Succeeded + PurgeFeatureEntitiesMetadata_State_Failed = sdk.PurgeFeatureEntitiesMetadata_State_Failed + PurgeFeatureEntitiesMetadata_State_Cancelled = sdk.PurgeFeatureEntitiesMetadata_State_Cancelled + PurgeFeatureEntitiesResult_State_Unspecified = sdk.PurgeFeatureEntitiesResult_State_Unspecified + PurgeFeatureEntitiesResult_State_Succeeded = sdk.PurgeFeatureEntitiesResult_State_Succeeded + PurgeFeatureEntitiesResult_State_Failed = sdk.PurgeFeatureEntitiesResult_State_Failed + PurgeFeatureEntitiesResult_State_NotApplicable = sdk.PurgeFeatureEntitiesResult_State_NotApplicable + SchemaLocator_Format_Unspecified = sdk.SchemaLocator_Format_Unspecified + SchemaLocator_Format_FormatAvro = sdk.SchemaLocator_Format_FormatAvro + SchemaLocator_Format_FormatProtobuf = sdk.SchemaLocator_Format_FormatProtobuf + SchemaLocator_Format_FormatJson = sdk.SchemaLocator_Format_FormatJson + StreamingMode_StreamingModeType_Unspecified = sdk.StreamingMode_StreamingModeType_Unspecified + StreamingMode_StreamingModeType_StreamingModeTypeRtm = sdk.StreamingMode_StreamingModeType_StreamingModeTypeRtm + StreamingMode_StreamingModeType_StreamingModeTypeMbm = sdk.StreamingMode_StreamingModeType_StreamingModeTypeMbm +) + +// An aggregation function applied over a time window.. +type AggregationFunction struct { + ApproxCountDistinct *ApproxCountDistinctFunction `json:"approx_count_distinct,omitempty"` + ApproxPercentile *ApproxPercentileFunction `json:"approx_percentile,omitempty"` + Avg *AvgFunction `json:"avg,omitempty"` + CountFunction *CountFunction `json:"count_function,omitempty"` + First *FirstFunction `json:"first,omitempty"` + FirstDistinct *FirstDistinctFunction `json:"first_distinct,omitempty"` + FirstN *FirstNFunction `json:"first_n,omitempty"` + Last *LastFunction `json:"last,omitempty"` + LastDistinct *LastDistinctFunction `json:"last_distinct,omitempty"` + LastN *LastNFunction `json:"last_n,omitempty"` + Max *MaxFunction `json:"max,omitempty"` + Min *MinFunction `json:"min,omitempty"` + StddevPop *StddevPopFunction `json:"stddev_pop,omitempty"` + StddevSamp *StddevSampFunction `json:"stddev_samp,omitempty"` + Sum *SumFunction `json:"sum,omitempty"` + // The time window over which the aggregation is computed. + TimeWindow *TimeWindow `json:"time_window,omitempty"` + VarPop *VarPopFunction `json:"var_pop,omitempty"` + VarSamp *VarSampFunction `json:"var_samp,omitempty"` +} + +// Databricks Error that is returned by all Databricks APIs.. +type ApiError struct { + Details []json.RawMessage `json:"details,omitempty"` + ErrorCode ErrorCode `json:"error_code,omitempty"` + Message *string `json:"message,omitempty"` + StackTrace *string `json:"stack_trace,omitempty"` +} + +// Computes the approximate count of distinct values.. +type ApproxCountDistinctFunction struct { + // The input column from which the approximate count of distinct values is + // computed. + Input *string `json:"input,omitempty"` + // The maximum relative standard deviation allowed (default defined by Spark). + RelativeSd *float64 `json:"relative_sd,omitempty"` +} + +// Computes the approximate percentile of values.. +type ApproxPercentileFunction struct { + // The accuracy parameter (higher is more accurate but slower). + Accuracy *int64 `json:"accuracy,omitempty"` + // The input column from which the approximate percentile is computed. + Input *string `json:"input,omitempty"` + // The percentile value to compute (between 0 and 1). + Percentile *float64 `json:"percentile,omitempty"` +} + +type AuthConfig struct { + MtlsConfig *MtlsConfig `json:"mtls_config,omitempty"` + UcServiceCredentialName *string `json:"uc_service_credential_name,omitempty"` +} + +// Computes the average of values.. +type AvgFunction struct { + // The input column from which the average is computed. For Kafka sources, use + // dot-prefixed path notation (e.g., "value.amount"). For nested fields, the + // leaf node name is used. Colon-prefixed notation (e.g., "value:amount") is + // supported for backwards compatibility but is deprecated; migrate to dot + // notation. + Input *string `json:"input,omitempty"` +} + +type BackfillFeaturesRequest struct { + // Output ranges to backfill. + BackfillRanges []BackfillRange `json:"backfill_ranges,omitempty"` + // The budget policy ID, in UUID format, used to attribute the serverless + // compute cost of this backfill. If not specified, a default budget policy may + // be applied. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // Full names of the features to backfill. + FeatureFullNames []string `json:"feature_full_names,omitempty"` + // Idempotency token for the request. + RequestId *string `json:"request_id,omitempty"` + // Custom tags to associate with this backfill. They are applied to the backfill + // job and forwarded to the underlying compute as Databricks resource tags, so + // backfill cost can be attributed in the billing system tables. These tags + // apply only to the backfill compute; they are not applied to the Unity Catalog + // Feature resources themselves, whose tags are managed separately through the + // Unity Catalog tagging API. A maximum of 25 tags is supported; keys and values + // are subject to the same limitations as Databricks resource tags. + Tags map[string]string `json:"tags,omitempty"` +} + +// Result of a completed backfill.. +type BackfillFeaturesResponse struct { +} + +// Progress and configuration for a backfill.. +type BackfillOperationMetadata struct { + // Output ranges targeted by the backfill. + BackfillRanges []BackfillRange `json:"backfill_ranges,omitempty"` + // Full names of the features targeted by the backfill. + FeatureFullNames []string `json:"feature_full_names,omitempty"` + // Current state of the backfill. + State BackfillOperationMetadata_State `json:"state,omitempty"` +} + +// A time range for a backfill.. +type BackfillRange struct { + // End of the backfill range, exclusive. If unset, defaults to the current time. + EndTime *types.Time `json:"end_time,omitempty"` + // Start of the backfill range, inclusive. If unset, defaults to the earliest + // source timestamp of the feature. + StartTime *types.Time `json:"start_time,omitempty"` +} + +type BackfillSource struct { + DeltaTableName *string `json:"delta_table_name,omitempty"` + DeltaTableSource *DeltaTableSource `json:"delta_table_source,omitempty"` +} + +type BatchCreateMaterializedFeaturesRequest struct { + // The requests to create materialized features. + Requests []CreateMaterializedFeatureRequest `json:"requests,omitempty"` +} + +type BatchCreateMaterializedFeaturesResponse struct { + // The created materialized features with assigned IDs. + MaterializedFeatures []MaterializedFeature `json:"materialized_features,omitempty"` +} + +// The request message for `CancelOperation` method.. +type CancelOperationRequest struct { + // The name of the operation resource to be cancelled. + Name *string `json:"name,omitempty"` +} + +type ColumnIdentifier struct { + // String representation of the column name using dot-prefixed path notation. + VariantExprPath *string `json:"variant_expr_path,omitempty"` +} + +// A ColumnSelection function, equivalent to the LAST() record of an entity over +// a lifetime window. +type ColumnSelection struct { + // Column name from source to select as the feature value. + Column *string `json:"column,omitempty"` +} + +type ContinuousWindow struct { + // The offset of the continuous window (must be non-positive). + Offset *types.Duration `json:"offset,omitempty"` + // The duration of the continuous window (must be positive). + WindowDuration *types.Duration `json:"window_duration,omitempty"` +} + +// Computes the count of values.. +type CountFunction struct { + // The input column from which the count is computed. For Kafka sources, use + // dot-prefixed path notation (e.g., "value.amount"). For nested fields, the + // leaf node name is used. Colon-prefixed notation (e.g., "value:amount") is + // supported for backwards compatibility but is deprecated; migrate to dot + // notation. + Input *string `json:"input,omitempty"` +} + +type CreateFeatureRequest struct { + // Feature to create. + Feature *Feature `json:"feature,omitempty"` +} + +type CreateKafkaConfigRequest struct { + KafkaConfig *KafkaConfig `json:"kafka_config,omitempty"` +} + +type CreateMaterializedFeatureRequest struct { + // The materialized feature to create. + MaterializedFeature *MaterializedFeature `json:"materialized_feature,omitempty"` +} + +// Create a Stream, a governed UC entity representing an external streaming data +// source.. +type CreateStreamRequest struct { + // The Stream to create. + Stream *Stream `json:"stream,omitempty"` +} + +// A cron-based schedule trigger for the materialization pipeline.. +type CronSchedule struct { + // The cron expression defining the schedule (e.g., "0 0 * * *" for daily at + // midnight). The schedule is interpreted in timezone_id (defaults to UTC). + // Required when mode is MANUAL (or unset). Left empty when mode is DERIVED, + // where the service computes it (aligned to UTC) from the features' window + // timing and fills it in on the response. + CronExpression *string `json:"cron_expression,omitempty"` + // How the schedule is determined. Defaults to MANUAL when unset. + Mode CronSchedule_Mode `json:"mode,omitempty"` + // A Java timezone ID. The schedule is resolved with respect to this timezone. + // Defaults to UTC when omitted. Can only be configured for MANUAL schedules; + // DERIVED schedules are always aligned to UTC. + TimezoneId *string `json:"timezone_id,omitempty"` +} + +// A CustomUdf function applies a registered Unity Catalog function row-wise to +// source columns, producing a single output column per row.. +type CustomUdf struct { + // Fully qualified 3-part Unity Catalog path of the function to apply. + FunctionPath *string `json:"function_path,omitempty"` + // Binds each UC function parameter to a source column. May be empty for + // zero-argument functions (e.g. a timestamp generator). + InputBindings []InputBinding `json:"input_bindings,omitempty"` +} + +// Specifies the data source backing a feature. Exactly one source type must be +// set.. +type DataSource struct { + DeltaTableSource *DeltaTableSource `json:"delta_table_source,omitempty"` + FeatureViewSource *FeatureViewSource `json:"feature_view_source,omitempty"` + KafkaSource *KafkaSource `json:"kafka_source,omitempty"` + // Completeness timing for this Feature's use of the source. This configuration + // is part of the Feature definition; it does not modify the underlying table or + // stream. + Lateness *SourceLateness `json:"lateness,omitempty"` + RequestSource *RequestSource `json:"request_source,omitempty"` + StreamSource *StreamSource `json:"stream_source,omitempty"` +} + +type DeltaTableSource struct { + // Schema of the resulting dataframe after transformations, in Spark StructType + // JSON format (from df.schema.json()). Required if transformation_sql is + // specified. Example: + // {"type":"struct","fields":[{"name":"col_a","type":"integer","nullable":true,"metadata":{}},{"name":"col_c","type":"integer","nullable":true,"metadata":{}}]} + DataframeSchema *string `json:"dataframe_schema,omitempty"` + EntityColumns []string `json:"entity_columns,omitempty"` + // Single WHERE clause to filter delta table before applying transformations. + // Will be row-wise evaluated, so should only include conditionals and + // projections. + FilterCondition *string `json:"filter_condition,omitempty"` + // The full three-part (catalog, schema, table) name of the Delta table. + FullName *string `json:"full_name,omitempty"` + TimeseriesColumn *string `json:"timeseries_column,omitempty"` + // A single SQL SELECT expression applied after filter_condition. Should + // contains all the columns needed (eg. "SELECT *, col_a + col_b AS col_c FROM + // x.y.z WHERE col_a > 0" would have `transformation_sql` "*, col_a + col_b AS + // col_c") If transformation_sql is not provided, all columns of the delta table + // are present in the DataSource dataframe. + TransformationSql *string `json:"transformation_sql,omitempty"` +} + +// Direct connection configs for mTLS, as Kafka Connections do not support mTLS +// yet.. +type DirectMtlsConfig struct { + // A comma-separated list of host:port pairs for the Kafka bootstrap servers. + BootstrapServers *string `json:"bootstrap_servers,omitempty"` + // Mutual-TLS authentication configuration. + MtlsConfig *MtlsConfig `json:"mtls_config,omitempty"` +} + +// Schema definitions provided directly on the Stream, as opposed to referencing +// a schema registry. To resolve schemas from a registry instead, use +// SchemaRegistryConfig.. +type DirectSchemas struct { + // Schema for the message key. This is only used for Kafka streams. For Kafka, + // at least one of payload_schema or key_schema must be specified. + KeySchema *SchemaConfig `json:"key_schema,omitempty"` + // Schema for the message payload. For Kafka, this is the value schema. Unless + // the platform supports another schema (e.g. keys for Kafka), this must be + // specified. + PayloadSchema *SchemaConfig `json:"payload_schema,omitempty"` +} + +type EntityColumn struct { + // The name of the entity column. For Kafka sources, use dot-prefixed path + // notation to reference fields within the key or value schema (e.g., + // "value.user_id", "key.partition_key"). For nested fields, the leaf node name + // (e.g., "user_id" from "value.trip_details.user_id") is what will be present + // in materialized tables and expected to match at query time. Colon-prefixed + // notation (e.g., "value:user_id") is supported for backwards compatibility but + // is deprecated; migrate to dot notation. + Name *string `json:"name,omitempty"` +} + +type Feature struct { + // Name of parent catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // Time at which this feature was created. + CreatedAt *types.Time `json:"created_at,omitempty"` + // Username of the feature creator. + CreatedBy *string `json:"created_by,omitempty"` + // The description of the feature. + Description *string `json:"description,omitempty"` + // The entity columns for the feature, used as aggregation keys and for + // query-time lookup. Optional since entities are not set for RequestSource + // features or on-demand calculated features. + Entities []EntityColumn `json:"entities,omitempty"` + FilterCondition *string `json:"filter_condition,omitempty"` + // The full three-part name (catalog, schema, name) of the feature. + FullName *string `json:"full_name,omitempty"` + // The function by which the feature is computed. + Function *Function `json:"function,omitempty"` + Inputs []string `json:"inputs,omitempty"` + // Lineage context information for this feature. WARNING: This field is + // primarily intended for internal use by systems and is + // automatically populated when features are created through + // notebooks or jobs. Users should not manually set this field as incorrect + // values may lead to inaccurate lineage tracking or unexpected behavior. This + // field will be set by feature-engineering client and should be left unset by + // SDK and terraform users. + LineageContext *LineageContext `json:"lineage_context,omitempty"` + // Name of the feature, extracted from the full three-part name + // (catalog.schema.name). + Name *string `json:"name,omitempty"` + // Name of parent schema relative to its parent catalog. + SchemaName *string `json:"schema_name,omitempty"` + // The data source of the feature. + Source *DataSource `json:"source,omitempty"` + TimeWindow *TimeWindow `json:"time_window,omitempty"` + // Column recording time, used for point-in-time joins, backfills, and + // aggregations. Optional since a timeseries column is not set for RequestSource + // features or on-demand calculated features. + TimeseriesColumn *TimeseriesColumn `json:"timeseries_column,omitempty"` +} + +// A reference to one registered upstream Feature. A message rather than a bare +// name so an upstream can later be pinned more precisely (e.g. by version) +// without a breaking type change.. +type FeatureReference struct { + // The three-part full name of the upstream Feature. + Feature *string `json:"feature,omitempty"` +} + +// A data source composed from registered upstream Features.. +type FeatureViewSource struct { + // The upstream Features this source reads. Must include at least one feature. + FeatureReferences []FeatureReference `json:"feature_references,omitempty"` +} + +// A single field definition within a FlatSchema, specifying the field name and +// its scalar data type. Does not support nested or complex types (arrays, maps, +// structs).. +type FieldDefinition struct { + // The scalar data type of the field. + DataType ScalarDataType `json:"data_type,omitempty"` + // The name of the field. + Name *string `json:"name,omitempty"` +} + +// Returns the first N distinct values, ordered by the feature's timeseries +// column.. +type FirstDistinctFunction struct { + // The input column from which the first N distinct values are returned. + Input *string `json:"input,omitempty"` + // The number of distinct values to return. + N *int64 `json:"n,omitempty"` +} + +// Returns the first value.. +type FirstFunction struct { + // The input column from which the first value is returned. + Input *string `json:"input,omitempty"` +} + +// Returns the first N values, ordered by the feature's timeseries column.. +type FirstNFunction struct { + // The input column from which the first N values are returned. + Input *string `json:"input,omitempty"` + // The number of values to return. + N *int64 `json:"n,omitempty"` +} + +// A flat (non-nested) schema for request-time fields, defined as an ordered +// list of field definitions. This schema only supports scalar types.. +type FlatSchema struct { + // The list of fields in this schema. + Fields []FieldDefinition `json:"fields,omitempty"` +} + +type Function struct { + AggregationFunction *AggregationFunction `json:"aggregation_function,omitempty"` + ColumnSelection *ColumnSelection `json:"column_selection,omitempty"` + CustomUdf *CustomUdf `json:"custom_udf,omitempty"` + ExtraParameters []FunctionExtraParameter `json:"extra_parameters,omitempty"` + FunctionType FunctionFunctionType `json:"function_type,omitempty"` +} + +type FunctionExtraParameter struct { + // The name of the parameter. + Key *string `json:"key,omitempty"` + // The value of the parameter. + Value *string `json:"value,omitempty"` +} + +// Configuration for the -managed ingestion pipeline. Groups the +// ingestion destination (required) and optional backfill source.. +type IngestionConfig struct { + // The ID of the Databricks Job that performs the historical backfill of the + // ingestion Delta table. + BackfillJobId *int64 `json:"backfill_job_id,omitempty"` + // A user-provided source for backfilling data. Historical data is used when + // creating a training set from streaming features linked to this Stream. The + // backfill data stored in this location will be copied into the ingestion table + // for offline querying and training. The schema for this source must match + // exactly that of the key and payload schemas specified for this Stream, except + // that it may omit any columns listed in excluded_columns. + BackfillSource *BackfillSource `json:"backfill_source,omitempty"` + // The ID of the budget policy used to attribute the serverless compute cost of + // this stream's managed ingestion. If not specified, a default budget policy + // may be applied. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // Column paths used to identify duplicate rows during ingestion; only one row + // per distinct combination of these values is kept. Use dot notation for nested + // fields (e.g. `value.user_id`). Empty list means every column is compared. + DeduplicationColumns []string `json:"deduplication_columns,omitempty"` + // Destination for the -managed Delta table that holds an offline + // copy of the streaming data for querying and training. This table contains + // both 1) forward-filled data from the Stream and 2) backfilled data from the + // BackfillSource (if provided). This table is created and managed by + // and is deleted when the Stream is deleted. + IngestionDestination *IngestionDestination `json:"ingestion_destination,omitempty"` + // The ID of the Databricks Job that performs the forward-fill ingestion. + IngestionJobId *int64 `json:"ingestion_job_id,omitempty"` + // The ID of the SDP pipeline that continuously copies new events from the + // streaming source into the ingestion Delta table. + IngestionPipelineId *string `json:"ingestion_pipeline_id,omitempty"` + // Custom tags to associate with this stream's managed ingestion. They are + // applied to the ingestion pipeline and its forward-fill and backfill jobs, and + // forwarded to the underlying compute as cluster tags, so ingestion cost can be + // attributed in the billing system tables. These tags apply only to the managed + // ingestion compute; they are not applied to the Stream entity itself, and are + // distinct from any Unity Catalog tags on the Stream. A maximum of 25 tags is + // supported; keys and values are subject to the same limitations as cluster + // tags. + Tags map[string]string `json:"tags,omitempty"` +} + +// Destination for the -managed Delta table that holds an offline +// copy of the streaming data for querying and training.. +type IngestionDestination struct { + DeltaTableName *string `json:"delta_table_name,omitempty"` +} + +// Binds a single UC function parameter to a source column.. +type InputBinding struct { + // Source column whose value is passed for this parameter at execution time. + Column *string `json:"column,omitempty"` + // Name of the UC function parameter. + Parameter *string `json:"parameter,omitempty"` +} + +type JobContext struct { + // The job ID where this API invoked. + JobId *int64 `json:"job_id,omitempty"` + // The job run ID where this API was invoked. + JobRunId *int64 `json:"job_run_id,omitempty"` +} + +type KafkaConfig struct { + // Authentication configuration for connection to topics. + AuthConfig *AuthConfig `json:"auth_config,omitempty"` + // A user-provided and managed source for backfilling data. Historical data is + // used when creating a training set from streaming features linked to this + // Kafka config. In the future, a separate table will be maintained by + // for forward filling data. The schema for this source must match + // exactly that of the key and value schemas specified for this Kafka config. + BackfillSource *BackfillSource `json:"backfill_source,omitempty"` + // A comma-separated list of host/port pairs pointing to Kafka cluster. + BootstrapServers *string `json:"bootstrap_servers,omitempty"` + // Catch-all for miscellaneous options. Keys should be source options or Kafka + // consumer options (kafka.*) + ExtraOptions map[string]string `json:"extra_options,omitempty"` + // Configuration for ingesting Kafka data into a -managed Delta + // table. + IngestionConfig *IngestionConfig `json:"ingestion_config,omitempty"` + // Schema configuration for extracting message keys from topics. At least one of + // key_schema and value_schema must be provided. + KeySchema *SchemaConfig `json:"key_schema,omitempty"` + // Name that uniquely identifies this Kafka config within the metastore. This + // will be the identifier used from the Feature object to reference these + // configs for a feature. Can be distinct from topic name. + Name *string `json:"name,omitempty"` + // Options to configure which Kafka topics to pull data from. + SubscriptionMode *SubscriptionMode `json:"subscription_mode,omitempty"` + // Schema configuration for extracting message values from topics. At least one + // of key_schema and value_schema must be provided. + ValueSchema *SchemaConfig `json:"value_schema,omitempty"` +} + +type KafkaSource struct { + EntityColumnIdentifiers []ColumnIdentifier `json:"entity_column_identifiers,omitempty"` + // The filter condition applied to the source data before aggregation. + FilterCondition *string `json:"filter_condition,omitempty"` + // Name of the Kafka source, used to identify it. This is used to look up the + // corresponding KafkaConfig object. Can be distinct from topic name. + Name *string `json:"name,omitempty"` + TimeseriesColumnIdentifier *ColumnIdentifier `json:"timeseries_column_identifier,omitempty"` +} + +// Kafka-specific configuration for a Stream.. +type KafkaStreamConfig struct { + // Optional Kafka source or consumer options, validated against a server-side + // allowlist at request time. Allowed keys: - `maxOffsetsPerTrigger` - + // `startingOffsets` - `includeHeaders` - `kafka.request.timeout.ms` - + // `kafka.session.timeout.ms` - `kafka.max.partition.fetch.bytes` The following + // keys are ingestion-only and are stripped before being forwarded to the + // materialization pipeline: - `maxOffsetsPerTrigger` - `startingOffsets` Auth + // and connection details belong on the parent Stream's `connection_config`, not + // here. + ExtraOptions map[string]string `json:"extra_options,omitempty"` + // Options to configure which Kafka topics to pull data from. + SubscriptionMode *KafkaSubscriptionMode `json:"subscription_mode,omitempty"` +} + +// Subscription mode for Kafka topic selection, matching standard Spark +// Structured Streaming options.. +type KafkaSubscriptionMode struct { + Assign *string `json:"assign,omitempty"` + Subscribe *string `json:"subscribe,omitempty"` + SubscribePattern *string `json:"subscribe_pattern,omitempty"` +} + +// Kinesis-specific configuration for a Stream. For the underlying connector and +// its source options, see the documentation on connecting to +// Amazon Kinesis +// (https://docs.databricks.com/aws/en/connect/streaming/kinesis).. +type KinesisStreamConfig struct { + // Optional Kinesis source options, validated against a server-side allowlist at + // request time. Allowed keys: - `consumerMode` - `consumerNamePrefix` - + // `maxFetchRate` - `minFetchPeriod` - `maxFetchDuration` - `maxRecordsPerFetch` + // - `shardsPerTask` - `fetchBufferSize` - `shardFetchInterval` `consumerMode` + // must be `efo` or `polling` (case-insensitive). `maxRecordsPerFetch` applies + // only during ingestion and does not affect the materialization pipeline. Auth + // and connection details belong on the parent Stream's `connection_config`, not + // here. + ExtraOptions map[string]string `json:"extra_options,omitempty"` + StreamArns *StreamArnList `json:"stream_arns,omitempty"` + StreamNames *StreamNameList `json:"stream_names,omitempty"` +} + +// Returns the last N distinct values, ordered by the feature's timeseries +// column.. +type LastDistinctFunction struct { + // The input column from which the last N distinct values are returned. + Input *string `json:"input,omitempty"` + // The number of distinct values to return. + N *int64 `json:"n,omitempty"` +} + +// Returns the last value.. +type LastFunction struct { + // The input column from which the last value is returned. + Input *string `json:"input,omitempty"` +} + +// Returns the last N values, ordered by the feature's timeseries column.. +type LastNFunction struct { + // The input column from which the last N values are returned. + Input *string `json:"input,omitempty"` + // The number of values to return. + N *int64 `json:"n,omitempty"` +} + +// Lineage context information for tracking where an API was invoked. This will +// allow us to track lineage, which currently uses caller entity information for +// use across the Lineage Client and Observability in Lumberjack.. +type LineageContext struct { + // Job context information including job ID and run ID. + JobContext *JobContext `json:"job_context,omitempty"` + // The notebook ID where this API was invoked. + NotebookId *int64 `json:"notebook_id,omitempty"` +} + +// Request to list features. Listing is always scoped to a single catalog and +// schema; catalog_name and schema_name are required.. +type ListFeaturesRequest struct { + // Name of parent catalog for features of interest. + CatalogName *string `json:"catalog_name,omitempty"` + // The maximum number of results to return. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page based on a previous query. + PageToken *string `json:"page_token,omitempty"` + // Name of parent schema relative to its parent catalog. + SchemaName *string `json:"schema_name,omitempty"` +} + +type ListFeaturesResponse struct { + // List of features. + Features []Feature `json:"features,omitempty"` + // Pagination token to request the next page of results for this query. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListKafkaConfigsRequest struct { + // The maximum number of results to return. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page based on a previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListKafkaConfigsResponse struct { + // List of Kafka configs. Schemas are not included in the response. + KafkaConfigs []KafkaConfig `json:"kafka_configs,omitempty"` + // Pagination token to request the next page of results for this query. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListMaterializedFeaturesRequest struct { + // Filter by feature name. If specified, only materialized features materialized + // from this feature will be returned. + FeatureName *string `json:"feature_name,omitempty"` + // The maximum number of results to return. Defaults to 100 if not specified. + // Cannot be greater than 1000. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page based on a previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListMaterializedFeaturesResponse struct { + // List of materialized features. + MaterializedFeatures []MaterializedFeature `json:"materialized_features,omitempty"` + // Pagination token to request the next page of results for this query. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// List Streams under a given parent. +// +// NOTE: Results are post-filtered by access permission on each stream's +// ingestion table. This means: - Returned results may be fewer than page_size +// (including zero) - Page token points to next unfiltered batch, not next +// filtered batch, and may point to an item that will be filtered out - Callers +// should paginate until next_page_token is empty to retrieve all accessible +// streams. +type ListStreamsRequest struct { + // The maximum number of results to return. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page based on a previous query. + PageToken *string `json:"page_token,omitempty"` + // Two-part name (catalog.schema) of the parent under which to list Streams. + Parent *string `json:"parent,omitempty"` +} + +// Response to a ListStreamsRequest. +// +// NOTE: Results are post-filtered by access permission on each stream's +// ingestion table. This means: - Returned results may be fewer than page_size +// (including zero) - Page token points to next unfiltered batch, not next +// filtered batch, and may point to an item that will be filtered out Callers +// should paginate until next_page_token is empty to retrieve all accessible +// streams.. +type ListStreamsResponse struct { + // Pagination token to request the next page of results for this query. + NextPageToken *string `json:"next_page_token,omitempty"` + // List of Streams. + Streams []Stream `json:"streams,omitempty"` +} + +// Recipients to notify when a materialization run fails.. +type MaterializationFailureNotification struct { + // IDs of the notification destinations (for example Slack, Microsoft Teams, + // PagerDuty, or a generic webhook) to notify. Not supported for streaming + // materialized features. + DestinationIds []string `json:"destination_ids,omitempty"` + // Email addresses to notify. + EmailAddresses []string `json:"email_addresses,omitempty"` + // If true, notify only when the final attempt of a run fails. If false or + // unset, notify on every failed attempt, including attempts that will be + // retried. + // + // Batch materialization does not retry failures that need a fix on your side, + // such as missing permissions or invalid configuration, so the first attempt is + // the final one. Other batch failures are retried up to twice. + // + // Streaming materialization restarts a failed update indefinitely unless the + // error cannot be retried. With this set, a streaming materialized feature + // notifies only on errors that cannot be retried, and never on failures that + // are restarted. + FinalAttemptOnly *bool `json:"final_attempt_only,omitempty"` +} + +// Notifications for the jobs and pipelines that materialize a feature, one +// field per trigger.. +type MaterializationNotifications struct { + // Who to notify when a run fails, and on which attempts. + OnFailure *MaterializationFailureNotification `json:"on_failure,omitempty"` + // Who to notify when a run succeeds. + OnSuccess *MaterializationSuccessNotification `json:"on_success,omitempty"` +} + +// Recipients to notify when a materialization run succeeds.. +type MaterializationSuccessNotification struct { + // IDs of the notification destinations (for example Slack, Microsoft Teams, + // PagerDuty, or a generic webhook) to notify. Not supported for streaming + // materialized features. + DestinationIds []string `json:"destination_ids,omitempty"` + // Email addresses to notify. + EmailAddresses []string `json:"email_addresses,omitempty"` +} + +// A materialized feature represents a feature that is continuously computed and +// stored.. +type MaterializedFeature struct { + // The ID of the budget policy used to attribute the serverless compute cost of + // this materialization. If not specified, a default budget policy may be + // applied. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + CronSchedule *string `json:"cron_schedule,omitempty"` + CronScheduleTrigger *CronSchedule `json:"cron_schedule_trigger,omitempty"` + // The full name of the feature in Unity Catalog. + FeatureName *string `json:"feature_name,omitempty"` + // True if this is an online materialized feature. False if it is an offline + // materialized feature. + IsOnline *bool `json:"is_online,omitempty"` + // The ID of the job that materializes the feature. This is present for both + // batch and streaming features. + JobId *int64 `json:"job_id,omitempty"` + // The timestamp when the pipeline last ran and updated the materialized feature + // values. If the pipeline has not run yet, this field will be null. + LastMaterializationTime *types.Time `json:"last_materialization_time,omitempty"` + // Name of the latest backfill operation on this materialized feature. Format: + // operations/{operation_id}. + LatestBackfillOperation *string `json:"latest_backfill_operation,omitempty"` + // Server-assigned unique identifier for the materialized feature. + MaterializedFeatureId *string `json:"materialized_feature_id,omitempty"` + // Notification configuration around the materialization job or pipeline + // lifecycle. They are applied to every job and pipeline that materializes this + // feature. Features which are materialized in the same pipeline will share the + // same notification. + Notifications *MaterializationNotifications `json:"notifications,omitempty"` + OfflineStoreConfig *OfflineStoreConfig `json:"offline_store_config,omitempty"` + OnlineStoreConfig *OnlineStoreConfig `json:"online_store_config,omitempty"` + // The ID of the pipeline that materializes this feature. This is only present + // for streaming features. + PipelineId *string `json:"pipeline_id,omitempty"` + // The schedule state of the materialization pipeline. Hidden from GraphQL: + // being deprecated, so not exposed to Catalog Explorer. + PipelineScheduleState MaterializedFeature_PipelineScheduleState `json:"pipeline_schedule_state,omitempty"` + StreamingMode *StreamingMode `json:"streaming_mode,omitempty"` + // The fully qualified Unity Catalog path to the table containing the + // materialized feature (Delta table or Lakebase table). Output only. + TableName *string `json:"table_name,omitempty"` + TableTrigger *TableTrigger `json:"table_trigger,omitempty"` + // Custom tags to associate with this materialization. They are applied to the + // materialization job (for batch features) or pipeline (for streaming features) + // and forwarded to the underlying compute as cluster tags, so materialization + // cost can be attributed in the billing system tables. These tags apply only to + // the materialization compute; they are not applied to the Unity Catalog + // Feature resource itself, whose tags are managed separately through the Unity + // Catalog tagging API. A maximum of 25 tags is supported; keys and values are + // subject to the same limitations as cluster tags. + Tags map[string]string `json:"tags,omitempty"` +} + +// Computes the maximum value.. +type MaxFunction struct { + // The input column from which the maximum is computed. + Input *string `json:"input,omitempty"` +} + +// Computes the minimum value.. +type MinFunction struct { + // The input column from which the minimum is computed. + Input *string `json:"input,omitempty"` +} + +// Mutual-TLS (mTLS) authentication configuration. The keystore (client +// certificate + private key) and truststore (CAs trusted to verify the broker) +// live as JKS files on Unity Catalog volumes, with their passwords stored in +// secret scopes. This matches the SSL setup pattern documented at +// https://docs.databricks.com/en/connect/streaming/kafka/authentication#use-ssl-to-connect-databricks-to-kafka.. +type MtlsConfig struct { + // Set to true only when the broker certificate's SAN intentionally does not + // match the connection endpoint — for example when reaching the cluster + // through a PrivateLink endpoint whose DNS name is not in the broker + // certificate. Skipping the hostname check removes a defense against + // man-in-the-middle attacks; do not enable casually. mTLS client authentication + // is unaffected by this option. + // + // See the Apache Kafka SSL security guide for background on this check: + // https://kafka.apache.org/42/security/encryption-and-authentication-using-ssl/#host-name-verification + DisableHostnameVerification *bool `json:"disable_hostname_verification,omitempty"` + // Secret-scope reference for the private key password. Often the same value as + // the keystore password (keytool's default), but provided as a separate field + // because Apache Kafka requires it as a distinct option + // (kafka.ssl.key.password). + KeyPasswordRef *SecretScopeReference `json:"key_password_ref,omitempty"` + // Unity Catalog volume path to the JKS keystore file containing the client + // certificate and private key. e.g. + // "/Volumes////client.jks". The materialization + // compute must have read permission on this volume. + KeystoreLocation *string `json:"keystore_location,omitempty"` + // Secret-scope reference for the JKS keystore password. + KeystorePasswordRef *SecretScopeReference `json:"keystore_password_ref,omitempty"` + // Unity Catalog volume path to the JKS truststore file containing the CA + // certificate(s) trusted to verify the Kafka broker's server certificate. e.g. + // "/Volumes////truststore.jks". + TruststoreLocation *string `json:"truststore_location,omitempty"` + // Secret-scope reference for the JKS truststore password. + TruststorePasswordRef *SecretScopeReference `json:"truststore_password_ref,omitempty"` +} + +// Configuration for offline store destination.. +type OfflineStoreConfig struct { + // The Unity Catalog catalog name. + CatalogName *string `json:"catalog_name,omitempty"` + // The Unity Catalog schema name. + SchemaName *string `json:"schema_name,omitempty"` + // Prefix for Unity Catalog table name. The materialized feature will be stored + // in a table with this prefix and a generated postfix. + TableNamePrefix *string `json:"table_name_prefix,omitempty"` +} + +// Configuration for online store destination.. +type OnlineStoreConfig struct { + // The Unity Catalog catalog name. This name is also used as the Lakebase + // logical database name. Quoting is handled by the backend where needed, do not + // pre-quote it. + CatalogName *string `json:"catalog_name,omitempty"` + // The name of the target online store. + OnlineStoreName *string `json:"online_store_name,omitempty"` + // The Unity Catalog schema name. This name is also used as the Lakebase schema + // name under the database. Quoting is handled by the backend where needed, do + // not pre-quote it. + SchemaName *string `json:"schema_name,omitempty"` + // Prefix for Unity Catalog table name. The materialized feature will be stored + // in a Lakebase table with this prefix and a generated postfix. + TableNamePrefix *string `json:"table_name_prefix,omitempty"` +} + +// This resource represents a long-running operation that is the result of a +// network API call.. +type Operation struct { + // If the value is `false`, it means the operation is still in progress. If + // `true`, the operation is completed, and either `error` or `response` is + // available. + Done *bool `json:"done,omitempty"` + Error *ApiError `json:"error,omitempty"` + // Service-specific metadata associated with the operation. It typically + // contains progress information and common metadata such as create time. Some + // services might not provide such metadata. + Metadata json.RawMessage `json:"metadata,omitempty"` + // The server-assigned name, which is only unique within the same service that + // originally returns it. If you use the default HTTP mapping, the `name` should + // be a resource name ending with `operations/{unique_id}`. + Name *string `json:"name,omitempty"` + Response json.RawMessage `json:"response,omitempty"` +} + +// A Protocol Buffer schema paired with the name of the message within it that +// describes the Kafka payload. A .proto file may declare multiple messages; +// message_name disambiguates.. +type ProtoSchemaSpec struct { + // The fully-qualified name of the message within schema_text that describes the + // Kafka payload (e.g. "Event" or "com.example.Event" if schema_text declares a + // package). Identifies which message is used to decode each Kafka record — a + // .proto file may declare multiple messages but only one represents the + // payload. Must not be empty. + MessageName *string `json:"message_name,omitempty"` + // The raw .proto file text (proto2 and proto3 syntax supported, see + // https://protobuf.dev/programming-guides/proto3/ and + // https://protobuf.dev/programming-guides/proto2/). + SchemaText *string `json:"schema_text,omitempty"` +} + +// Progress and configuration for a feature entity purge.. +type PurgeFeatureEntitiesMetadata struct { + // Time at which the purge operation was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Fully qualified name of the Unity Catalog Delta table containing the entity + // keys to purge. + EntitiesTable *string `json:"entities_table,omitempty"` + // Version of the entities table used by the purge. + EntitiesTableVersion *string `json:"entities_table_version,omitempty"` + // Fully qualified names of the features targeted by the purge. + Features []string `json:"features,omitempty"` + // ID of the job that executes this purge. + JobId *int64 `json:"job_id,omitempty"` + // Current state of the purge operation. + State PurgeFeatureEntitiesMetadata_State `json:"state,omitempty"` +} + +// Request to purge materialized feature values for entities listed in a Unity +// Catalog Delta table.. +type PurgeFeatureEntitiesRequest struct { + // The budget policy ID, in UUID format, used to attribute the serverless + // compute cost of this purge. If not specified, a default budget policy may be + // applied. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + EntitiesTable *string `json:"entities_table,omitempty"` + // Fully qualified names of the features to purge. At least one nonempty feature + // name is required. A request may contain at most 10000 features; submit + // additional features in separate requests. Duplicate features are rejected. + Features []string `json:"features,omitempty"` + // Optional UUID4 idempotency token for the request. + RequestId *string `json:"request_id,omitempty"` + // Custom tags to associate with this purge. They are applied to the purge job + // and forwarded to the underlying compute as Databricks resource tags, so purge + // cost can be attributed in the billing system tables. These tags apply only to + // the purge compute; they are not applied to the Unity Catalog Feature + // resources themselves, whose tags are managed separately through the Unity + // Catalog tagging API. A maximum of 25 tags is supported; keys and values are + // subject to the same limitations as Databricks resource tags. + Tags map[string]string `json:"tags,omitempty"` +} + +// Result of a completed feature entity purge.. +type PurgeFeatureEntitiesResponse struct { + // Operation-level error, if the purge failed outside an individual feature + // target. + Error *ApiError `json:"error,omitempty"` + // Metadata about the purge operation. + Metadata *PurgeFeatureEntitiesMetadata `json:"metadata,omitempty"` + // Per-feature purge results. + Results []PurgeFeatureEntitiesResult `json:"results,omitempty"` + // State of the purge operation. + State PurgeFeatureEntitiesMetadata_State `json:"state,omitempty"` +} + +// Result of purging one feature.. +type PurgeFeatureEntitiesResult struct { + // Error encountered while purging this feature, if any. + Error *ApiError `json:"error,omitempty"` + // Fully qualified name of the feature that was purged. + Feature *string `json:"feature,omitempty"` + // State of the offline purge for this feature. + OfflineState PurgeFeatureEntitiesResult_State `json:"offline_state,omitempty"` + // State of the online purge for this feature. + OnlineState PurgeFeatureEntitiesResult_State `json:"online_state,omitempty"` +} + +// A request-time data source whose value is provided at inference time: offline +// batch scoring or online serving endpoint. +type RequestSource struct { + DataframeSchema *string `json:"dataframe_schema,omitempty"` + FlatSchema *FlatSchema `json:"flat_schema,omitempty"` +} + +// A rolling time window with an optional non-negative delay.. +type RollingWindow struct { + // Non-negative analytic lag that evaluates the window this far in the past. Use + // this for timing variations unrelated to source lateness, such as a 30-day + // count as of one week ago. If unset, the analytic lag is zero. It composes + // with source.lateness when both are set. + Delay *types.Duration `json:"delay,omitempty"` + // The duration of the rolling window. Must be positive when set; absent means + // lifetime (aggregate over the entity's entire history). + WindowDuration *types.Duration `json:"window_duration,omitempty"` +} + +// A sawtooth window served via the hybrid batch + streaming path. The batch +// pipeline maintains daily partial aggregates for the bulk of the window while +// the streaming pipeline maintains the most recent day(s), and serving merges +// them on read. Same field shape as RollingWindow, but a distinct type so the +// control plane can explicitly identify hybrid (sawtooth) features rather than +// inferring hybrid behavior from window_duration.. +type SawtoothWindow struct { + // Delay is not currently supported for Sawtooth windows. + Delay *types.Duration `json:"delay,omitempty"` + // The duration of the window. Must be positive and span more than two days when + // set, so that both the batch (N-1 day) and stale-path (N-2 day) partial + // aggregates are well defined. The duration need not be a whole number of days + // (e.g. 3 days 15 minutes is allowed). Absent means lifetime (aggregate over + // the entity's entire history). + WindowDuration *types.Duration `json:"window_duration,omitempty"` +} + +type SchemaConfig struct { + AvroSchema *string `json:"avro_schema,omitempty"` + JsonSchema *string `json:"json_schema,omitempty"` + ProtoSchema *ProtoSchemaSpec `json:"proto_schema,omitempty"` +} + +// Schema locator for one side (payload or key) of a message. Identifies which +// schema to use in the schema registry and the serialization format.. +type SchemaLocator struct { + ConfluentSchema *SchemaLocator_ConfluentSchema `json:"confluent_schema,omitempty"` + // Serialization format for this schema. + Format SchemaLocator_Format `json:"format,omitempty"` +} + +// Confluent Schema Registry schema locator. The value to provide for `subject` +// depends on the naming strategy configured in your registry: - +// TopicNameStrategy (default): "{topic}-key" or "{topic}-value" e.g. for topic +// "transactions" use "transactions-value" for the payload and +// "transactions-key" for the key. - RecordNameStrategy: the fully-qualified +// record name e.g. "com.example.Payment" for Avro, the bare message name +// (without package) for Protobuf, or the `title` field value for JSON. - +// TopicRecordNameStrategy: "{topic}-{fully-qualified-record-name}" e.g. +// "transactions-com.example.Payment".. +type SchemaLocator_ConfluentSchema struct { + // The Confluent schema registry subject name. + Subject *string `json:"subject,omitempty"` +} + +// Configuration for resolving a Stream's schema from an external schema +// registry (e.g. Confluent).. +type SchemaRegistryConfig struct { + // Reference to the schema registry API secret in a secret scope. + // Set this only if required for authentication for the schema registry. + ApiSecretRef *SecretScopeReference `json:"api_secret_ref,omitempty"` + // Schema locator for the message key. Only used for Kafka streams. At least one + // of payload_schema_locator or key_schema_locator must be set. + KeySchemaLocator *SchemaLocator `json:"key_schema_locator,omitempty"` + // Schema locator for the message payload. For Kafka this is the value. At least + // one of payload_schema_locator or key_schema_locator must be set. + PayloadSchemaLocator *SchemaLocator `json:"payload_schema_locator,omitempty"` + // A Schema Registry UC Connection object. + UcConnection *string `json:"uc_connection,omitempty"` +} + +// Reference to an entry in a secret scope.. +type SecretScopeReference struct { + // The key within the scope. + Key *string `json:"key,omitempty"` + // The secret scope name. + Scope *string `json:"scope,omitempty"` +} + +type SlidingWindow struct { + // Non-negative analytic lag that evaluates the window this far in the past. Use + // this for timing variations unrelated to source lateness, such as a 30-day + // count as of one week ago. If unset, the analytic lag is zero. It composes + // with source.lateness when both are set. + Delay *types.Duration `json:"delay,omitempty"` + // Non-negative phase shift from the default midnight UTC alignment. For + // example, offset=22h on a 24h slide produces boundaries at 22:00 UTC (17:00 + // New York in standard time) instead of midnight UTC. If unset, the offset is + // zero. Must be shorter than slide_duration (and therefore window_duration). + Offset *types.Duration `json:"offset,omitempty"` + // The slide duration (interval by which windows advance, must be positive and + // less than duration). + SlideDuration *types.Duration `json:"slide_duration,omitempty"` + // The duration of the sliding window. Must be positive when set; absent means + // lifetime (aggregate over the entity's entire history). + WindowDuration *types.Duration `json:"window_duration,omitempty"` +} + +// Configures when event-time data from this source is considered complete for a +// Feature.. +type SourceLateness struct { + // Non-negative time to wait after a window ends before treating its source data + // as complete. Training shifts the eligible evaluation time backwards by this + // duration so it does not join data that would still have been settling online. + // Materialization waits for the duration to elapse before publishing the + // window. If unset, source data is considered settled immediately. + SettlingDelay *types.Duration `json:"settling_delay,omitempty"` +} + +// Computes the population standard deviation.. +type StddevPopFunction struct { + // The input column from which the population standard deviation is computed. + // For Kafka sources, use dot-prefixed path notation (e.g., "value.amount"). For + // nested fields, the leaf node name is used. Colon-prefixed notation (e.g., + // "value:amount") is supported for backwards compatibility but is deprecated; + // migrate to dot notation. + Input *string `json:"input,omitempty"` +} + +// Computes the sample standard deviation.. +type StddevSampFunction struct { + // The input column from which the sample standard deviation is computed. + Input *string `json:"input,omitempty"` +} + +// A Stream is a governed UC entity representing an external streaming data +// source. The source_config field determines the streaming platform source +// (e.g. Kafka, Kinesis).. +type Stream struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // Specifies how to connect and authenticate to the stream platform. + ConnectionConfig *StreamConnectionConfig `json:"connection_config,omitempty"` + // Time at which this Stream was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Username of the Stream creator. + CreatedBy *string `json:"created_by,omitempty"` + // User-provided description. + Description *string `json:"description,omitempty"` + // Column paths (dot notation, e.g. "value.email" for Kafka) to drop. A path may + // reference a struct, in which case all of its nested fields are dropped (e.g. + // "value.address" drops "value.address.city" and "value.address.zip"). These + // columns are not written to the ingestion table and cannot be referenced by + // any feature. They are dropped from ingestion, backfill, and materialization. + // For direct schemas, each column must exist in the relevant key or payload + // schema. With a schema registry, a column can be excluded before it exists. A + // column cannot also be a deduplication column in the ingestion_config. + ExcludedColumns []string `json:"excluded_columns,omitempty"` + // Configuration for streaming data ingestion: the managed table storing an + // offline copy of forward fill data and optional historical backfill. + IngestionConfig *IngestionConfig `json:"ingestion_config,omitempty"` + // Full three-part (catalog.schema.stream) name of the stream. + Name *string `json:"name,omitempty"` + // Optional SQL predicate to filter which record types from a streaming channel + // (e.g. a topic for Kafka) belong to this Stream. Events that do not match are + // not written to the ingestion table and are not used in materialization. + // Example: "value.event_type = 'transaction'". + RecordTypeFilter *string `json:"record_type_filter,omitempty"` + // Schema definitions for the stream, provided either directly on the Stream or + // resolved from an external schema registry through a UC Connection. + SchemaConfig *StreamSchemaConfig `json:"schema_config,omitempty"` + // Source-specific configuration. Determines the streaming platform source. + SourceConfig *StreamSourceConfig `json:"source_config,omitempty"` + // Time at which this Stream was last modified. + UpdateTime *types.Time `json:"update_time,omitempty"` + // Username of user who last modified the Stream. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// A list of Kinesis stream ARNs to read from.. +type StreamArnList struct { + // Kinesis stream ARNs to read from. For example, + // 'arn:aws:kinesis:us-west-2:111122223333:stream/stream-a'. + Arns []string `json:"arns,omitempty"` +} + +// Specifies how to connect and authenticate to the stream platform.. +type StreamConnectionConfig struct { + DirectMtlsConfig *DirectMtlsConfig `json:"direct_mtls_config,omitempty"` + UcConnectionName *string `json:"uc_connection_name,omitempty"` +} + +// A list of Kinesis stream names to read from.. +type StreamNameList struct { + // Kinesis stream names to read from. + Names []string `json:"names,omitempty"` +} + +// Schema definitions for the stream. Feature store supports both direct schemas +// and schema registries.. +type StreamSchemaConfig struct { + DirectSchemas *DirectSchemas `json:"direct_schemas,omitempty"` + SchemaRegistryConfig *SchemaRegistryConfig `json:"schema_registry_config,omitempty"` +} + +// A Stream entity used as a data source for a feature.. +type StreamSource struct { + // Schema of the resulting dataframe after transformations, in Spark StructType + // JSON format (from df.schema.json()). Any subsequent functions operate against + // this dataframe. + DataframeSchema *string `json:"dataframe_schema,omitempty"` + // The filter condition applied to the source data before aggregation. + FilterCondition *string `json:"filter_condition,omitempty"` + // Three-part full name of the Stream (catalog.schema.stream). + FullName *string `json:"full_name,omitempty"` + // The pipeline runs these SQL statements immediately after conversion into the + // schema specified on the Stream object. + TransformationSql *string `json:"transformation_sql,omitempty"` +} + +// Source-specific configuration. Determines the streaming platform source.. +type StreamSourceConfig struct { + KafkaStreamConfig *KafkaStreamConfig `json:"kafka_stream_config,omitempty"` + KinesisStreamConfig *KinesisStreamConfig `json:"kinesis_stream_config,omitempty"` +} + +// The streaming mode configuration for a streaming materialization pipeline.. +type StreamingMode struct { + // The desired data freshness for feature materialization, expressed as a + // duration string (e.g. "1 minute"). + FreshnessTarget *string `json:"freshness_target,omitempty"` + // The type of streaming mode used by the materialization pipeline. + Mode StreamingMode_StreamingModeType `json:"mode,omitempty"` + // Number of shuffle partitions for streaming materialization of this feature. + // Higher values process high-throughput features with more parallelism at + // higher compute cost. Materialized features which are computed together will + // use the largest value set among them. + ShufflePartitions *int `json:"shuffle_partitions,omitempty"` +} + +// Deprecated: Use KafkaSubscriptionMode instead.. +type SubscriptionMode struct { + Assign *string `json:"assign,omitempty"` + Subscribe *string `json:"subscribe,omitempty"` + SubscribePattern *string `json:"subscribe_pattern,omitempty"` +} + +// Computes the sum of values.. +type SumFunction struct { + // The input column from which the sum is computed. For Kafka sources, use + // dot-prefixed path notation (e.g., "value.amount"). For nested fields, the + // leaf node name is used. Colon-prefixed notation (e.g., "value:amount") is + // supported for backwards compatibility but is deprecated; migrate to dot + // notation. + Input *string `json:"input,omitempty"` +} + +// A trigger that fires when the upstream source table changes.. +type TableTrigger struct { +} + +type TimeWindow struct { + Continuous *ContinuousWindow `json:"continuous,omitempty"` + Rolling *RollingWindow `json:"rolling,omitempty"` + Sawtooth *SawtoothWindow `json:"sawtooth,omitempty"` + Sliding *SlidingWindow `json:"sliding,omitempty"` + // Earliest event-time boundary at which the Feature may emit an output. This + // gates outputs, not the historical inputs read by a window. For example, a + // 365-day window with start_time=2026-01-01 begins emitting partial-window + // values on that date instead of waiting for 365 days of data; a lifetime + // window produces no output before start_time. If unset, tumbling and + // fixed-duration sliding windows first emit at an offset-aligned boundary after + // a full window can be formed. If unset, lifetime sliding windows and rolling + // windows emit as soon as eligible source data exists. Not currently supported + // for sawtooth windows or for Features with a stream source. + StartTime *types.Time `json:"start_time,omitempty"` + Tumbling *TumblingWindow `json:"tumbling,omitempty"` +} + +type TimeseriesColumn struct { + // The name of the timeseries column. For Kafka sources, use dot-prefixed path + // notation to reference fields within the key or value schema (e.g., + // "value.event_timestamp"). For nested fields, the leaf node name (e.g., + // "event_timestamp" from "value.event_details.event_timestamp") is what will be + // present in materialized tables and expected to match at query time. + // Colon-prefixed notation (e.g., "value:event_timestamp") is supported for + // backwards compatibility but is deprecated; migrate to dot notation. + Name *string `json:"name,omitempty"` +} + +type TumblingWindow struct { + // Non-negative analytic lag that evaluates the window this far in the past. Use + // this for timing variations unrelated to source lateness, such as a 30-day + // count as of one week ago. If unset, the analytic lag is zero. It composes + // with source.lateness when both are set. + Delay *types.Duration `json:"delay,omitempty"` + // Non-negative phase shift from the default midnight UTC alignment. For + // example, offset=22h on a 24h window produces boundaries at 22:00 UTC (17:00 + // New York in standard time) instead of midnight UTC. If unset, the offset is + // zero. Must be shorter than window_duration. + Offset *types.Duration `json:"offset,omitempty"` + // The duration of each tumbling window (non-overlapping, fixed-duration + // windows). + WindowDuration *types.Duration `json:"window_duration,omitempty"` +} + +type UpdateFeatureRequest struct { + // Feature whose full_name identifies the target. Only description is mutable. + Feature *Feature `json:"feature,omitempty"` + // Fields to update. The only supported path is description. + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateKafkaConfigRequest struct { + // The Kafka config to update. + KafkaConfig *KafkaConfig `json:"kafka_config,omitempty"` + // The list of fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateMaterializedFeatureRequest struct { + // The materialized feature to update. + MaterializedFeature *MaterializedFeature `json:"materialized_feature,omitempty"` + // Provide the materialization feature fields which should be updated. + // Currently, only the pipeline_state field can be updated. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Update a Stream. Only fields listed in `update_mask` are mutated.. +type UpdateStreamRequest struct { + // The Stream to update. + Stream *Stream `json:"stream,omitempty"` + // The list of fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Computes the population variance.. +type VarPopFunction struct { + // The input column from which the population variance is computed. + Input *string `json:"input,omitempty"` +} + +// Computes the sample variance.. +type VarSampFunction struct { + // The input column from which the sample variance is computed. + Input *string `json:"input,omitempty"` +} + +// AggregationFunctionToSDK converts the mirror to the sdk-go type. +func AggregationFunctionToSDK(w *AggregationFunction) (*sdk.AggregationFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.AggregationFunction{} + { + var members []string + if w.Avg != nil { + members = append(members, "avg") + } + if w.CountFunction != nil { + members = append(members, "count_function") + } + if w.Sum != nil { + members = append(members, "sum") + } + if w.Min != nil { + members = append(members, "min") + } + if w.Max != nil { + members = append(members, "max") + } + if w.First != nil { + members = append(members, "first") + } + if w.Last != nil { + members = append(members, "last") + } + if w.ApproxCountDistinct != nil { + members = append(members, "approx_count_distinct") + } + if w.ApproxPercentile != nil { + members = append(members, "approx_percentile") + } + if w.StddevPop != nil { + members = append(members, "stddev_pop") + } + if w.StddevSamp != nil { + members = append(members, "stddev_samp") + } + if w.VarPop != nil { + members = append(members, "var_pop") + } + if w.VarSamp != nil { + members = append(members, "var_samp") + } + if w.FirstN != nil { + members = append(members, "first_n") + } + if w.LastN != nil { + members = append(members, "last_n") + } + if w.FirstDistinct != nil { + members = append(members, "first_distinct") + } + if w.LastDistinct != nil { + members = append(members, "last_distinct") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Avg != nil: + conv1, err := AvgFunctionToSDK(w.Avg) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_Avg{Avg: *conv1} + case w.CountFunction != nil: + conv2, err := CountFunctionToSDK(w.CountFunction) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_CountFunction{CountFunction: *conv2} + case w.Sum != nil: + conv3, err := SumFunctionToSDK(w.Sum) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_Sum{Sum: *conv3} + case w.Min != nil: + conv4, err := MinFunctionToSDK(w.Min) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_Min{Min: *conv4} + case w.Max != nil: + conv5, err := MaxFunctionToSDK(w.Max) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_Max{Max: *conv5} + case w.First != nil: + conv6, err := FirstFunctionToSDK(w.First) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_First{First: *conv6} + case w.Last != nil: + conv7, err := LastFunctionToSDK(w.Last) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_Last{Last: *conv7} + case w.ApproxCountDistinct != nil: + conv8, err := ApproxCountDistinctFunctionToSDK(w.ApproxCountDistinct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_ApproxCountDistinct{ApproxCountDistinct: *conv8} + case w.ApproxPercentile != nil: + conv9, err := ApproxPercentileFunctionToSDK(w.ApproxPercentile) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_ApproxPercentile{ApproxPercentile: *conv9} + case w.StddevPop != nil: + conv10, err := StddevPopFunctionToSDK(w.StddevPop) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_StddevPop{StddevPop: *conv10} + case w.StddevSamp != nil: + conv11, err := StddevSampFunctionToSDK(w.StddevSamp) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_StddevSamp{StddevSamp: *conv11} + case w.VarPop != nil: + conv12, err := VarPopFunctionToSDK(w.VarPop) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_VarPop{VarPop: *conv12} + case w.VarSamp != nil: + conv13, err := VarSampFunctionToSDK(w.VarSamp) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_VarSamp{VarSamp: *conv13} + case w.FirstN != nil: + conv14, err := FirstNFunctionToSDK(w.FirstN) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_FirstN{FirstN: *conv14} + case w.LastN != nil: + conv15, err := LastNFunctionToSDK(w.LastN) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_LastN{LastN: *conv15} + case w.FirstDistinct != nil: + conv16, err := FirstDistinctFunctionToSDK(w.FirstDistinct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_FirstDistinct{FirstDistinct: *conv16} + case w.LastDistinct != nil: + conv17, err := LastDistinctFunctionToSDK(w.LastDistinct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Operation = &sdk.AggregationFunction_Operation_LastDistinct{LastDistinct: *conv17} + } + conv18, err := TimeWindowToSDK(w.TimeWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.TimeWindow", err) + } + out.TimeWindow = conv18 + return out, nil +} + +// AggregationFunctionFromSDK converts the sdk-go type to the mirror. +func AggregationFunctionFromSDK(v *sdk.AggregationFunction) (*AggregationFunction, error) { + if v == nil { + return nil, nil + } + out := &AggregationFunction{} + switch value := v.Operation.(type) { + case *sdk.AggregationFunction_Operation_Avg: + if value != nil { + conv19, err := AvgFunctionFromSDK(&value.Avg) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Avg = conv19 + } + case *sdk.AggregationFunction_Operation_CountFunction: + if value != nil { + conv20, err := CountFunctionFromSDK(&value.CountFunction) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.CountFunction = conv20 + } + case *sdk.AggregationFunction_Operation_Sum: + if value != nil { + conv21, err := SumFunctionFromSDK(&value.Sum) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Sum = conv21 + } + case *sdk.AggregationFunction_Operation_Min: + if value != nil { + conv22, err := MinFunctionFromSDK(&value.Min) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Min = conv22 + } + case *sdk.AggregationFunction_Operation_Max: + if value != nil { + conv23, err := MaxFunctionFromSDK(&value.Max) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Max = conv23 + } + case *sdk.AggregationFunction_Operation_First: + if value != nil { + conv24, err := FirstFunctionFromSDK(&value.First) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.First = conv24 + } + case *sdk.AggregationFunction_Operation_Last: + if value != nil { + conv25, err := LastFunctionFromSDK(&value.Last) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.Last = conv25 + } + case *sdk.AggregationFunction_Operation_ApproxCountDistinct: + if value != nil { + conv26, err := ApproxCountDistinctFunctionFromSDK(&value.ApproxCountDistinct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.ApproxCountDistinct = conv26 + } + case *sdk.AggregationFunction_Operation_ApproxPercentile: + if value != nil { + conv27, err := ApproxPercentileFunctionFromSDK(&value.ApproxPercentile) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.ApproxPercentile = conv27 + } + case *sdk.AggregationFunction_Operation_StddevPop: + if value != nil { + conv28, err := StddevPopFunctionFromSDK(&value.StddevPop) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.StddevPop = conv28 + } + case *sdk.AggregationFunction_Operation_StddevSamp: + if value != nil { + conv29, err := StddevSampFunctionFromSDK(&value.StddevSamp) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.StddevSamp = conv29 + } + case *sdk.AggregationFunction_Operation_VarPop: + if value != nil { + conv30, err := VarPopFunctionFromSDK(&value.VarPop) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.VarPop = conv30 + } + case *sdk.AggregationFunction_Operation_VarSamp: + if value != nil { + conv31, err := VarSampFunctionFromSDK(&value.VarSamp) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.VarSamp = conv31 + } + case *sdk.AggregationFunction_Operation_FirstN: + if value != nil { + conv32, err := FirstNFunctionFromSDK(&value.FirstN) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.FirstN = conv32 + } + case *sdk.AggregationFunction_Operation_LastN: + if value != nil { + conv33, err := LastNFunctionFromSDK(&value.LastN) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.LastN = conv33 + } + case *sdk.AggregationFunction_Operation_FirstDistinct: + if value != nil { + conv34, err := FirstDistinctFunctionFromSDK(&value.FirstDistinct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.FirstDistinct = conv34 + } + case *sdk.AggregationFunction_Operation_LastDistinct: + if value != nil { + conv35, err := LastDistinctFunctionFromSDK(&value.LastDistinct) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.Operation", err) + } + out.LastDistinct = conv35 + } + } + conv36, err := TimeWindowFromSDK(v.TimeWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AggregationFunction.TimeWindow", err) + } + out.TimeWindow = conv36 + return out, nil +} + +// ApiErrorToSDK converts the mirror to the sdk-go type. +func ApiErrorToSDK(w *ApiError) (*sdk.ApiError, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApiError{} + out.ErrorCode = w.ErrorCode + out.Message = w.Message + out.StackTrace = w.StackTrace + out.Details = w.Details + return out, nil +} + +// ApiErrorFromSDK converts the sdk-go type to the mirror. +func ApiErrorFromSDK(v *sdk.ApiError) (*ApiError, error) { + if v == nil { + return nil, nil + } + out := &ApiError{} + out.ErrorCode = v.ErrorCode + out.Message = v.Message + out.StackTrace = v.StackTrace + out.Details = v.Details + return out, nil +} + +// ApproxCountDistinctFunctionToSDK converts the mirror to the sdk-go type. +func ApproxCountDistinctFunctionToSDK(w *ApproxCountDistinctFunction) (*sdk.ApproxCountDistinctFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApproxCountDistinctFunction{} + out.Input = w.Input + out.RelativeSd = w.RelativeSd + return out, nil +} + +// ApproxCountDistinctFunctionFromSDK converts the sdk-go type to the mirror. +func ApproxCountDistinctFunctionFromSDK(v *sdk.ApproxCountDistinctFunction) (*ApproxCountDistinctFunction, error) { + if v == nil { + return nil, nil + } + out := &ApproxCountDistinctFunction{} + out.Input = v.Input + out.RelativeSd = v.RelativeSd + return out, nil +} + +// ApproxPercentileFunctionToSDK converts the mirror to the sdk-go type. +func ApproxPercentileFunctionToSDK(w *ApproxPercentileFunction) (*sdk.ApproxPercentileFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApproxPercentileFunction{} + out.Input = w.Input + out.Percentile = w.Percentile + out.Accuracy = w.Accuracy + return out, nil +} + +// ApproxPercentileFunctionFromSDK converts the sdk-go type to the mirror. +func ApproxPercentileFunctionFromSDK(v *sdk.ApproxPercentileFunction) (*ApproxPercentileFunction, error) { + if v == nil { + return nil, nil + } + out := &ApproxPercentileFunction{} + out.Input = v.Input + out.Percentile = v.Percentile + out.Accuracy = v.Accuracy + return out, nil +} + +// AuthConfigToSDK converts the mirror to the sdk-go type. +func AuthConfigToSDK(w *AuthConfig) (*sdk.AuthConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.AuthConfig{} + { + var members []string + if w.UcServiceCredentialName != nil { + members = append(members, "uc_service_credential_name") + } + if w.MtlsConfig != nil { + members = append(members, "mtls_config") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UcServiceCredentialName != nil: + out.AuthConfig = &sdk.AuthConfig_AuthConfig_UcServiceCredentialName{UcServiceCredentialName: *w.UcServiceCredentialName} + case w.MtlsConfig != nil: + conv37, err := MtlsConfigToSDK(w.MtlsConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AuthConfig.AuthConfig", err) + } + out.AuthConfig = &sdk.AuthConfig_AuthConfig_MtlsConfig{MtlsConfig: *conv37} + } + return out, nil +} + +// AuthConfigFromSDK converts the sdk-go type to the mirror. +func AuthConfigFromSDK(v *sdk.AuthConfig) (*AuthConfig, error) { + if v == nil { + return nil, nil + } + out := &AuthConfig{} + switch value := v.AuthConfig.(type) { + case *sdk.AuthConfig_AuthConfig_UcServiceCredentialName: + if value != nil { + out.UcServiceCredentialName = new(value.UcServiceCredentialName) + } + case *sdk.AuthConfig_AuthConfig_MtlsConfig: + if value != nil { + conv38, err := MtlsConfigFromSDK(&value.MtlsConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AuthConfig.AuthConfig", err) + } + out.MtlsConfig = conv38 + } + } + return out, nil +} + +// AvgFunctionToSDK converts the mirror to the sdk-go type. +func AvgFunctionToSDK(w *AvgFunction) (*sdk.AvgFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.AvgFunction{} + out.Input = w.Input + return out, nil +} + +// AvgFunctionFromSDK converts the sdk-go type to the mirror. +func AvgFunctionFromSDK(v *sdk.AvgFunction) (*AvgFunction, error) { + if v == nil { + return nil, nil + } + out := &AvgFunction{} + out.Input = v.Input + return out, nil +} + +// BackfillFeaturesRequestToSDK converts the mirror to the sdk-go type. +func BackfillFeaturesRequestToSDK(w *BackfillFeaturesRequest) (*sdk.BackfillFeaturesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.BackfillFeaturesRequest{} + out.FeatureFullNames = w.FeatureFullNames + conv39, err := convertSlice(w.BackfillRanges, BackfillRangeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BackfillFeaturesRequest.BackfillRanges", err) + } + out.BackfillRanges = conv39 + out.RequestId = w.RequestId + out.Tags = w.Tags + out.BudgetPolicyId = w.BudgetPolicyId + return out, nil +} + +// BackfillFeaturesRequestFromSDK converts the sdk-go type to the mirror. +func BackfillFeaturesRequestFromSDK(v *sdk.BackfillFeaturesRequest) (*BackfillFeaturesRequest, error) { + if v == nil { + return nil, nil + } + out := &BackfillFeaturesRequest{} + out.FeatureFullNames = v.FeatureFullNames + conv40, err := convertSlice(v.BackfillRanges, BackfillRangeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BackfillFeaturesRequest.BackfillRanges", err) + } + out.BackfillRanges = conv40 + out.RequestId = v.RequestId + out.Tags = v.Tags + out.BudgetPolicyId = v.BudgetPolicyId + return out, nil +} + +// BackfillFeaturesResponseToSDK converts the mirror to the sdk-go type. +func BackfillFeaturesResponseToSDK(w *BackfillFeaturesResponse) (*sdk.BackfillFeaturesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.BackfillFeaturesResponse{} + return out, nil +} + +// BackfillFeaturesResponseFromSDK converts the sdk-go type to the mirror. +func BackfillFeaturesResponseFromSDK(v *sdk.BackfillFeaturesResponse) (*BackfillFeaturesResponse, error) { + if v == nil { + return nil, nil + } + out := &BackfillFeaturesResponse{} + return out, nil +} + +// BackfillOperationMetadataToSDK converts the mirror to the sdk-go type. +func BackfillOperationMetadataToSDK(w *BackfillOperationMetadata) (*sdk.BackfillOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.BackfillOperationMetadata{} + out.FeatureFullNames = w.FeatureFullNames + conv41, err := convertSlice(w.BackfillRanges, BackfillRangeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BackfillOperationMetadata.BackfillRanges", err) + } + out.BackfillRanges = conv41 + out.State = w.State + return out, nil +} + +// BackfillOperationMetadataFromSDK converts the sdk-go type to the mirror. +func BackfillOperationMetadataFromSDK(v *sdk.BackfillOperationMetadata) (*BackfillOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &BackfillOperationMetadata{} + out.FeatureFullNames = v.FeatureFullNames + conv42, err := convertSlice(v.BackfillRanges, BackfillRangeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BackfillOperationMetadata.BackfillRanges", err) + } + out.BackfillRanges = conv42 + out.State = v.State + return out, nil +} + +// BackfillRangeToSDK converts the mirror to the sdk-go type. +func BackfillRangeToSDK(w *BackfillRange) (*sdk.BackfillRange, error) { + if w == nil { + return nil, nil + } + out := &sdk.BackfillRange{} + out.StartTime = w.StartTime + out.EndTime = w.EndTime + return out, nil +} + +// BackfillRangeFromSDK converts the sdk-go type to the mirror. +func BackfillRangeFromSDK(v *sdk.BackfillRange) (*BackfillRange, error) { + if v == nil { + return nil, nil + } + out := &BackfillRange{} + out.StartTime = v.StartTime + out.EndTime = v.EndTime + return out, nil +} + +// BackfillSourceToSDK converts the mirror to the sdk-go type. +func BackfillSourceToSDK(w *BackfillSource) (*sdk.BackfillSource, error) { + if w == nil { + return nil, nil + } + out := &sdk.BackfillSource{} + { + var members []string + if w.DeltaTableSource != nil { + members = append(members, "delta_table_source") + } + if w.DeltaTableName != nil { + members = append(members, "delta_table_name") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DeltaTableSource != nil: + conv43, err := DeltaTableSourceToSDK(w.DeltaTableSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BackfillSource.BackfillSource", err) + } + out.BackfillSource = &sdk.BackfillSource_BackfillSource_DeltaTableSource{DeltaTableSource: *conv43} + case w.DeltaTableName != nil: + out.BackfillSource = &sdk.BackfillSource_BackfillSource_DeltaTableName{DeltaTableName: *w.DeltaTableName} + } + return out, nil +} + +// BackfillSourceFromSDK converts the sdk-go type to the mirror. +func BackfillSourceFromSDK(v *sdk.BackfillSource) (*BackfillSource, error) { + if v == nil { + return nil, nil + } + out := &BackfillSource{} + switch value := v.BackfillSource.(type) { + case *sdk.BackfillSource_BackfillSource_DeltaTableSource: + if value != nil { + conv44, err := DeltaTableSourceFromSDK(&value.DeltaTableSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BackfillSource.BackfillSource", err) + } + out.DeltaTableSource = conv44 + } + case *sdk.BackfillSource_BackfillSource_DeltaTableName: + if value != nil { + out.DeltaTableName = new(value.DeltaTableName) + } + } + return out, nil +} + +// BatchCreateMaterializedFeaturesRequestToSDK converts the mirror to the sdk-go type. +func BatchCreateMaterializedFeaturesRequestToSDK(w *BatchCreateMaterializedFeaturesRequest) (*sdk.BatchCreateMaterializedFeaturesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.BatchCreateMaterializedFeaturesRequest{} + conv45, err := convertSlice(w.Requests, CreateMaterializedFeatureRequestToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BatchCreateMaterializedFeaturesRequest.Requests", err) + } + out.Requests = conv45 + return out, nil +} + +// BatchCreateMaterializedFeaturesRequestFromSDK converts the sdk-go type to the mirror. +func BatchCreateMaterializedFeaturesRequestFromSDK(v *sdk.BatchCreateMaterializedFeaturesRequest) (*BatchCreateMaterializedFeaturesRequest, error) { + if v == nil { + return nil, nil + } + out := &BatchCreateMaterializedFeaturesRequest{} + conv46, err := convertSlice(v.Requests, CreateMaterializedFeatureRequestFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BatchCreateMaterializedFeaturesRequest.Requests", err) + } + out.Requests = conv46 + return out, nil +} + +// BatchCreateMaterializedFeaturesResponseToSDK converts the mirror to the sdk-go type. +func BatchCreateMaterializedFeaturesResponseToSDK(w *BatchCreateMaterializedFeaturesResponse) (*sdk.BatchCreateMaterializedFeaturesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.BatchCreateMaterializedFeaturesResponse{} + conv47, err := convertSlice(w.MaterializedFeatures, MaterializedFeatureToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BatchCreateMaterializedFeaturesResponse.MaterializedFeatures", err) + } + out.MaterializedFeatures = conv47 + return out, nil +} + +// BatchCreateMaterializedFeaturesResponseFromSDK converts the sdk-go type to the mirror. +func BatchCreateMaterializedFeaturesResponseFromSDK(v *sdk.BatchCreateMaterializedFeaturesResponse) (*BatchCreateMaterializedFeaturesResponse, error) { + if v == nil { + return nil, nil + } + out := &BatchCreateMaterializedFeaturesResponse{} + conv48, err := convertSlice(v.MaterializedFeatures, MaterializedFeatureFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BatchCreateMaterializedFeaturesResponse.MaterializedFeatures", err) + } + out.MaterializedFeatures = conv48 + return out, nil +} + +// CancelOperationRequestToSDK converts the mirror to the sdk-go type. +func CancelOperationRequestToSDK(w *CancelOperationRequest) (*sdk.CancelOperationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CancelOperationRequest{} + out.Name = w.Name + return out, nil +} + +// CancelOperationRequestFromSDK converts the sdk-go type to the mirror. +func CancelOperationRequestFromSDK(v *sdk.CancelOperationRequest) (*CancelOperationRequest, error) { + if v == nil { + return nil, nil + } + out := &CancelOperationRequest{} + out.Name = v.Name + return out, nil +} + +// ColumnIdentifierToSDK converts the mirror to the sdk-go type. +func ColumnIdentifierToSDK(w *ColumnIdentifier) (*sdk.ColumnIdentifier, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnIdentifier{} + out.VariantExprPath = w.VariantExprPath + return out, nil +} + +// ColumnIdentifierFromSDK converts the sdk-go type to the mirror. +func ColumnIdentifierFromSDK(v *sdk.ColumnIdentifier) (*ColumnIdentifier, error) { + if v == nil { + return nil, nil + } + out := &ColumnIdentifier{} + out.VariantExprPath = v.VariantExprPath + return out, nil +} + +// ColumnSelectionToSDK converts the mirror to the sdk-go type. +func ColumnSelectionToSDK(w *ColumnSelection) (*sdk.ColumnSelection, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnSelection{} + out.Column = w.Column + return out, nil +} + +// ColumnSelectionFromSDK converts the sdk-go type to the mirror. +func ColumnSelectionFromSDK(v *sdk.ColumnSelection) (*ColumnSelection, error) { + if v == nil { + return nil, nil + } + out := &ColumnSelection{} + out.Column = v.Column + return out, nil +} + +// ContinuousWindowToSDK converts the mirror to the sdk-go type. +func ContinuousWindowToSDK(w *ContinuousWindow) (*sdk.ContinuousWindow, error) { + if w == nil { + return nil, nil + } + out := &sdk.ContinuousWindow{} + out.WindowDuration = w.WindowDuration + out.Offset = w.Offset + return out, nil +} + +// ContinuousWindowFromSDK converts the sdk-go type to the mirror. +func ContinuousWindowFromSDK(v *sdk.ContinuousWindow) (*ContinuousWindow, error) { + if v == nil { + return nil, nil + } + out := &ContinuousWindow{} + out.WindowDuration = v.WindowDuration + out.Offset = v.Offset + return out, nil +} + +// CountFunctionToSDK converts the mirror to the sdk-go type. +func CountFunctionToSDK(w *CountFunction) (*sdk.CountFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.CountFunction{} + out.Input = w.Input + return out, nil +} + +// CountFunctionFromSDK converts the sdk-go type to the mirror. +func CountFunctionFromSDK(v *sdk.CountFunction) (*CountFunction, error) { + if v == nil { + return nil, nil + } + out := &CountFunction{} + out.Input = v.Input + return out, nil +} + +// CreateFeatureRequestToSDK converts the mirror to the sdk-go type. +func CreateFeatureRequestToSDK(w *CreateFeatureRequest) (*sdk.CreateFeatureRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateFeatureRequest{} + conv49, err := FeatureToSDK(w.Feature) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFeatureRequest.Feature", err) + } + out.Feature = conv49 + return out, nil +} + +// CreateFeatureRequestFromSDK converts the sdk-go type to the mirror. +func CreateFeatureRequestFromSDK(v *sdk.CreateFeatureRequest) (*CreateFeatureRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateFeatureRequest{} + conv50, err := FeatureFromSDK(v.Feature) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFeatureRequest.Feature", err) + } + out.Feature = conv50 + return out, nil +} + +// CreateKafkaConfigRequestToSDK converts the mirror to the sdk-go type. +func CreateKafkaConfigRequestToSDK(w *CreateKafkaConfigRequest) (*sdk.CreateKafkaConfigRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateKafkaConfigRequest{} + conv51, err := KafkaConfigToSDK(w.KafkaConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateKafkaConfigRequest.KafkaConfig", err) + } + out.KafkaConfig = conv51 + return out, nil +} + +// CreateKafkaConfigRequestFromSDK converts the sdk-go type to the mirror. +func CreateKafkaConfigRequestFromSDK(v *sdk.CreateKafkaConfigRequest) (*CreateKafkaConfigRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateKafkaConfigRequest{} + conv52, err := KafkaConfigFromSDK(v.KafkaConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateKafkaConfigRequest.KafkaConfig", err) + } + out.KafkaConfig = conv52 + return out, nil +} + +// CreateMaterializedFeatureRequestToSDK converts the mirror to the sdk-go type. +func CreateMaterializedFeatureRequestToSDK(w *CreateMaterializedFeatureRequest) (*sdk.CreateMaterializedFeatureRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateMaterializedFeatureRequest{} + conv53, err := MaterializedFeatureToSDK(w.MaterializedFeature) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateMaterializedFeatureRequest.MaterializedFeature", err) + } + out.MaterializedFeature = conv53 + return out, nil +} + +// CreateMaterializedFeatureRequestFromSDK converts the sdk-go type to the mirror. +func CreateMaterializedFeatureRequestFromSDK(v *sdk.CreateMaterializedFeatureRequest) (*CreateMaterializedFeatureRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateMaterializedFeatureRequest{} + conv54, err := MaterializedFeatureFromSDK(v.MaterializedFeature) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateMaterializedFeatureRequest.MaterializedFeature", err) + } + out.MaterializedFeature = conv54 + return out, nil +} + +// CreateStreamRequestToSDK converts the mirror to the sdk-go type. +func CreateStreamRequestToSDK(w *CreateStreamRequest) (*sdk.CreateStreamRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateStreamRequest{} + conv55, err := StreamToSDK(w.Stream) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStreamRequest.Stream", err) + } + out.Stream = conv55 + return out, nil +} + +// CreateStreamRequestFromSDK converts the sdk-go type to the mirror. +func CreateStreamRequestFromSDK(v *sdk.CreateStreamRequest) (*CreateStreamRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateStreamRequest{} + conv56, err := StreamFromSDK(v.Stream) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStreamRequest.Stream", err) + } + out.Stream = conv56 + return out, nil +} + +// CronScheduleToSDK converts the mirror to the sdk-go type. +func CronScheduleToSDK(w *CronSchedule) (*sdk.CronSchedule, error) { + if w == nil { + return nil, nil + } + out := &sdk.CronSchedule{} + out.CronExpression = w.CronExpression + out.Mode = w.Mode + out.TimezoneId = w.TimezoneId + return out, nil +} + +// CronScheduleFromSDK converts the sdk-go type to the mirror. +func CronScheduleFromSDK(v *sdk.CronSchedule) (*CronSchedule, error) { + if v == nil { + return nil, nil + } + out := &CronSchedule{} + out.CronExpression = v.CronExpression + out.Mode = v.Mode + out.TimezoneId = v.TimezoneId + return out, nil +} + +// CustomUdfToSDK converts the mirror to the sdk-go type. +func CustomUdfToSDK(w *CustomUdf) (*sdk.CustomUdf, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomUdf{} + out.FunctionPath = w.FunctionPath + conv57, err := convertSlice(w.InputBindings, InputBindingToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomUdf.InputBindings", err) + } + out.InputBindings = conv57 + return out, nil +} + +// CustomUdfFromSDK converts the sdk-go type to the mirror. +func CustomUdfFromSDK(v *sdk.CustomUdf) (*CustomUdf, error) { + if v == nil { + return nil, nil + } + out := &CustomUdf{} + out.FunctionPath = v.FunctionPath + conv58, err := convertSlice(v.InputBindings, InputBindingFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomUdf.InputBindings", err) + } + out.InputBindings = conv58 + return out, nil +} + +// DataSourceToSDK converts the mirror to the sdk-go type. +func DataSourceToSDK(w *DataSource) (*sdk.DataSource, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataSource{} + { + var members []string + if w.DeltaTableSource != nil { + members = append(members, "delta_table_source") + } + if w.KafkaSource != nil { + members = append(members, "kafka_source") + } + if w.RequestSource != nil { + members = append(members, "request_source") + } + if w.StreamSource != nil { + members = append(members, "stream_source") + } + if w.FeatureViewSource != nil { + members = append(members, "feature_view_source") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DeltaTableSource != nil: + conv59, err := DeltaTableSourceToSDK(w.DeltaTableSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataSource.DataSource", err) + } + out.DataSource = &sdk.DataSource_DataSource_DeltaTableSource{DeltaTableSource: *conv59} + case w.KafkaSource != nil: + conv60, err := KafkaSourceToSDK(w.KafkaSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataSource.DataSource", err) + } + out.DataSource = &sdk.DataSource_DataSource_KafkaSource{KafkaSource: *conv60} + case w.RequestSource != nil: + conv61, err := RequestSourceToSDK(w.RequestSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataSource.DataSource", err) + } + out.DataSource = &sdk.DataSource_DataSource_RequestSource{RequestSource: *conv61} + case w.StreamSource != nil: + conv62, err := StreamSourceToSDK(w.StreamSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataSource.DataSource", err) + } + out.DataSource = &sdk.DataSource_DataSource_StreamSource{StreamSource: *conv62} + case w.FeatureViewSource != nil: + conv63, err := FeatureViewSourceToSDK(w.FeatureViewSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataSource.DataSource", err) + } + out.DataSource = &sdk.DataSource_DataSource_FeatureViewSource{FeatureViewSource: *conv63} + } + conv64, err := SourceLatenessToSDK(w.Lateness) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataSource.Lateness", err) + } + out.Lateness = conv64 + return out, nil +} + +// DataSourceFromSDK converts the sdk-go type to the mirror. +func DataSourceFromSDK(v *sdk.DataSource) (*DataSource, error) { + if v == nil { + return nil, nil + } + out := &DataSource{} + switch value := v.DataSource.(type) { + case *sdk.DataSource_DataSource_DeltaTableSource: + if value != nil { + conv65, err := DeltaTableSourceFromSDK(&value.DeltaTableSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataSource.DataSource", err) + } + out.DeltaTableSource = conv65 + } + case *sdk.DataSource_DataSource_KafkaSource: + if value != nil { + conv66, err := KafkaSourceFromSDK(&value.KafkaSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataSource.DataSource", err) + } + out.KafkaSource = conv66 + } + case *sdk.DataSource_DataSource_RequestSource: + if value != nil { + conv67, err := RequestSourceFromSDK(&value.RequestSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataSource.DataSource", err) + } + out.RequestSource = conv67 + } + case *sdk.DataSource_DataSource_StreamSource: + if value != nil { + conv68, err := StreamSourceFromSDK(&value.StreamSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataSource.DataSource", err) + } + out.StreamSource = conv68 + } + case *sdk.DataSource_DataSource_FeatureViewSource: + if value != nil { + conv69, err := FeatureViewSourceFromSDK(&value.FeatureViewSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataSource.DataSource", err) + } + out.FeatureViewSource = conv69 + } + } + conv70, err := SourceLatenessFromSDK(v.Lateness) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataSource.Lateness", err) + } + out.Lateness = conv70 + return out, nil +} + +// DeltaTableSourceToSDK converts the mirror to the sdk-go type. +func DeltaTableSourceToSDK(w *DeltaTableSource) (*sdk.DeltaTableSource, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeltaTableSource{} + out.FullName = w.FullName + out.EntityColumns = w.EntityColumns + out.TimeseriesColumn = w.TimeseriesColumn + out.FilterCondition = w.FilterCondition + out.TransformationSql = w.TransformationSql + out.DataframeSchema = w.DataframeSchema + return out, nil +} + +// DeltaTableSourceFromSDK converts the sdk-go type to the mirror. +func DeltaTableSourceFromSDK(v *sdk.DeltaTableSource) (*DeltaTableSource, error) { + if v == nil { + return nil, nil + } + out := &DeltaTableSource{} + out.FullName = v.FullName + out.EntityColumns = v.EntityColumns + out.TimeseriesColumn = v.TimeseriesColumn + out.FilterCondition = v.FilterCondition + out.TransformationSql = v.TransformationSql + out.DataframeSchema = v.DataframeSchema + return out, nil +} + +// DirectMtlsConfigToSDK converts the mirror to the sdk-go type. +func DirectMtlsConfigToSDK(w *DirectMtlsConfig) (*sdk.DirectMtlsConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.DirectMtlsConfig{} + out.BootstrapServers = w.BootstrapServers + conv71, err := MtlsConfigToSDK(w.MtlsConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectMtlsConfig.MtlsConfig", err) + } + out.MtlsConfig = conv71 + return out, nil +} + +// DirectMtlsConfigFromSDK converts the sdk-go type to the mirror. +func DirectMtlsConfigFromSDK(v *sdk.DirectMtlsConfig) (*DirectMtlsConfig, error) { + if v == nil { + return nil, nil + } + out := &DirectMtlsConfig{} + out.BootstrapServers = v.BootstrapServers + conv72, err := MtlsConfigFromSDK(v.MtlsConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectMtlsConfig.MtlsConfig", err) + } + out.MtlsConfig = conv72 + return out, nil +} + +// DirectSchemasToSDK converts the mirror to the sdk-go type. +func DirectSchemasToSDK(w *DirectSchemas) (*sdk.DirectSchemas, error) { + if w == nil { + return nil, nil + } + out := &sdk.DirectSchemas{} + conv73, err := SchemaConfigToSDK(w.PayloadSchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectSchemas.PayloadSchema", err) + } + out.PayloadSchema = conv73 + conv74, err := SchemaConfigToSDK(w.KeySchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectSchemas.KeySchema", err) + } + out.KeySchema = conv74 + return out, nil +} + +// DirectSchemasFromSDK converts the sdk-go type to the mirror. +func DirectSchemasFromSDK(v *sdk.DirectSchemas) (*DirectSchemas, error) { + if v == nil { + return nil, nil + } + out := &DirectSchemas{} + conv75, err := SchemaConfigFromSDK(v.PayloadSchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectSchemas.PayloadSchema", err) + } + out.PayloadSchema = conv75 + conv76, err := SchemaConfigFromSDK(v.KeySchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectSchemas.KeySchema", err) + } + out.KeySchema = conv76 + return out, nil +} + +// EntityColumnToSDK converts the mirror to the sdk-go type. +func EntityColumnToSDK(w *EntityColumn) (*sdk.EntityColumn, error) { + if w == nil { + return nil, nil + } + out := &sdk.EntityColumn{} + out.Name = w.Name + return out, nil +} + +// EntityColumnFromSDK converts the sdk-go type to the mirror. +func EntityColumnFromSDK(v *sdk.EntityColumn) (*EntityColumn, error) { + if v == nil { + return nil, nil + } + out := &EntityColumn{} + out.Name = v.Name + return out, nil +} + +// FeatureToSDK converts the mirror to the sdk-go type. +func FeatureToSDK(w *Feature) (*sdk.Feature, error) { + if w == nil { + return nil, nil + } + out := &sdk.Feature{} + out.FullName = w.FullName + conv77, err := DataSourceToSDK(w.Source) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Feature.Source", err) + } + out.Source = conv77 + out.Inputs = w.Inputs + conv78, err := FunctionToSDK(w.Function) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Feature.Function", err) + } + out.Function = conv78 + conv79, err := TimeWindowToSDK(w.TimeWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Feature.TimeWindow", err) + } + out.TimeWindow = conv79 + out.Description = w.Description + out.FilterCondition = w.FilterCondition + conv80, err := LineageContextToSDK(w.LineageContext) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Feature.LineageContext", err) + } + out.LineageContext = conv80 + conv81, err := convertSlice(w.Entities, EntityColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Feature.Entities", err) + } + out.Entities = conv81 + conv82, err := TimeseriesColumnToSDK(w.TimeseriesColumn) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Feature.TimeseriesColumn", err) + } + out.TimeseriesColumn = conv82 + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.Name = w.Name + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + return out, nil +} + +// FeatureFromSDK converts the sdk-go type to the mirror. +func FeatureFromSDK(v *sdk.Feature) (*Feature, error) { + if v == nil { + return nil, nil + } + out := &Feature{} + out.FullName = v.FullName + conv83, err := DataSourceFromSDK(v.Source) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Feature.Source", err) + } + out.Source = conv83 + out.Inputs = v.Inputs + conv84, err := FunctionFromSDK(v.Function) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Feature.Function", err) + } + out.Function = conv84 + conv85, err := TimeWindowFromSDK(v.TimeWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Feature.TimeWindow", err) + } + out.TimeWindow = conv85 + out.Description = v.Description + out.FilterCondition = v.FilterCondition + conv86, err := LineageContextFromSDK(v.LineageContext) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Feature.LineageContext", err) + } + out.LineageContext = conv86 + conv87, err := convertSlice(v.Entities, EntityColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Feature.Entities", err) + } + out.Entities = conv87 + conv88, err := TimeseriesColumnFromSDK(v.TimeseriesColumn) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Feature.TimeseriesColumn", err) + } + out.TimeseriesColumn = conv88 + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.Name = v.Name + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + return out, nil +} + +// FeatureReferenceToSDK converts the mirror to the sdk-go type. +func FeatureReferenceToSDK(w *FeatureReference) (*sdk.FeatureReference, error) { + if w == nil { + return nil, nil + } + out := &sdk.FeatureReference{} + out.Feature = w.Feature + return out, nil +} + +// FeatureReferenceFromSDK converts the sdk-go type to the mirror. +func FeatureReferenceFromSDK(v *sdk.FeatureReference) (*FeatureReference, error) { + if v == nil { + return nil, nil + } + out := &FeatureReference{} + out.Feature = v.Feature + return out, nil +} + +// FeatureViewSourceToSDK converts the mirror to the sdk-go type. +func FeatureViewSourceToSDK(w *FeatureViewSource) (*sdk.FeatureViewSource, error) { + if w == nil { + return nil, nil + } + out := &sdk.FeatureViewSource{} + conv89, err := convertSlice(w.FeatureReferences, FeatureReferenceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FeatureViewSource.FeatureReferences", err) + } + out.FeatureReferences = conv89 + return out, nil +} + +// FeatureViewSourceFromSDK converts the sdk-go type to the mirror. +func FeatureViewSourceFromSDK(v *sdk.FeatureViewSource) (*FeatureViewSource, error) { + if v == nil { + return nil, nil + } + out := &FeatureViewSource{} + conv90, err := convertSlice(v.FeatureReferences, FeatureReferenceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FeatureViewSource.FeatureReferences", err) + } + out.FeatureReferences = conv90 + return out, nil +} + +// FieldDefinitionToSDK converts the mirror to the sdk-go type. +func FieldDefinitionToSDK(w *FieldDefinition) (*sdk.FieldDefinition, error) { + if w == nil { + return nil, nil + } + out := &sdk.FieldDefinition{} + out.Name = w.Name + out.DataType = w.DataType + return out, nil +} + +// FieldDefinitionFromSDK converts the sdk-go type to the mirror. +func FieldDefinitionFromSDK(v *sdk.FieldDefinition) (*FieldDefinition, error) { + if v == nil { + return nil, nil + } + out := &FieldDefinition{} + out.Name = v.Name + out.DataType = v.DataType + return out, nil +} + +// FirstDistinctFunctionToSDK converts the mirror to the sdk-go type. +func FirstDistinctFunctionToSDK(w *FirstDistinctFunction) (*sdk.FirstDistinctFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.FirstDistinctFunction{} + out.Input = w.Input + out.N = w.N + return out, nil +} + +// FirstDistinctFunctionFromSDK converts the sdk-go type to the mirror. +func FirstDistinctFunctionFromSDK(v *sdk.FirstDistinctFunction) (*FirstDistinctFunction, error) { + if v == nil { + return nil, nil + } + out := &FirstDistinctFunction{} + out.Input = v.Input + out.N = v.N + return out, nil +} + +// FirstFunctionToSDK converts the mirror to the sdk-go type. +func FirstFunctionToSDK(w *FirstFunction) (*sdk.FirstFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.FirstFunction{} + out.Input = w.Input + return out, nil +} + +// FirstFunctionFromSDK converts the sdk-go type to the mirror. +func FirstFunctionFromSDK(v *sdk.FirstFunction) (*FirstFunction, error) { + if v == nil { + return nil, nil + } + out := &FirstFunction{} + out.Input = v.Input + return out, nil +} + +// FirstNFunctionToSDK converts the mirror to the sdk-go type. +func FirstNFunctionToSDK(w *FirstNFunction) (*sdk.FirstNFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.FirstNFunction{} + out.Input = w.Input + out.N = w.N + return out, nil +} + +// FirstNFunctionFromSDK converts the sdk-go type to the mirror. +func FirstNFunctionFromSDK(v *sdk.FirstNFunction) (*FirstNFunction, error) { + if v == nil { + return nil, nil + } + out := &FirstNFunction{} + out.Input = v.Input + out.N = v.N + return out, nil +} + +// FlatSchemaToSDK converts the mirror to the sdk-go type. +func FlatSchemaToSDK(w *FlatSchema) (*sdk.FlatSchema, error) { + if w == nil { + return nil, nil + } + out := &sdk.FlatSchema{} + conv91, err := convertSlice(w.Fields, FieldDefinitionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FlatSchema.Fields", err) + } + out.Fields = conv91 + return out, nil +} + +// FlatSchemaFromSDK converts the sdk-go type to the mirror. +func FlatSchemaFromSDK(v *sdk.FlatSchema) (*FlatSchema, error) { + if v == nil { + return nil, nil + } + out := &FlatSchema{} + conv92, err := convertSlice(v.Fields, FieldDefinitionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FlatSchema.Fields", err) + } + out.Fields = conv92 + return out, nil +} + +// FunctionToSDK converts the mirror to the sdk-go type. +func FunctionToSDK(w *Function) (*sdk.Function, error) { + if w == nil { + return nil, nil + } + out := &sdk.Function{} + out.FunctionType = w.FunctionType + conv93, err := convertSlice(w.ExtraParameters, FunctionExtraParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.ExtraParameters", err) + } + out.ExtraParameters = conv93 + { + var members []string + if w.AggregationFunction != nil { + members = append(members, "aggregation_function") + } + if w.ColumnSelection != nil { + members = append(members, "column_selection") + } + if w.CustomUdf != nil { + members = append(members, "custom_udf") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AggregationFunction != nil: + conv94, err := AggregationFunctionToSDK(w.AggregationFunction) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.Function", err) + } + out.Function = &sdk.Function_Function_AggregationFunction{AggregationFunction: *conv94} + case w.ColumnSelection != nil: + conv95, err := ColumnSelectionToSDK(w.ColumnSelection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.Function", err) + } + out.Function = &sdk.Function_Function_ColumnSelection{ColumnSelection: *conv95} + case w.CustomUdf != nil: + conv96, err := CustomUdfToSDK(w.CustomUdf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.Function", err) + } + out.Function = &sdk.Function_Function_CustomUdf{CustomUdf: *conv96} + } + return out, nil +} + +// FunctionFromSDK converts the sdk-go type to the mirror. +func FunctionFromSDK(v *sdk.Function) (*Function, error) { + if v == nil { + return nil, nil + } + out := &Function{} + out.FunctionType = v.FunctionType + conv97, err := convertSlice(v.ExtraParameters, FunctionExtraParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.ExtraParameters", err) + } + out.ExtraParameters = conv97 + switch value := v.Function.(type) { + case *sdk.Function_Function_AggregationFunction: + if value != nil { + conv98, err := AggregationFunctionFromSDK(&value.AggregationFunction) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.Function", err) + } + out.AggregationFunction = conv98 + } + case *sdk.Function_Function_ColumnSelection: + if value != nil { + conv99, err := ColumnSelectionFromSDK(&value.ColumnSelection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.Function", err) + } + out.ColumnSelection = conv99 + } + case *sdk.Function_Function_CustomUdf: + if value != nil { + conv100, err := CustomUdfFromSDK(&value.CustomUdf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.Function", err) + } + out.CustomUdf = conv100 + } + } + return out, nil +} + +// FunctionExtraParameterToSDK converts the mirror to the sdk-go type. +func FunctionExtraParameterToSDK(w *FunctionExtraParameter) (*sdk.FunctionExtraParameter, error) { + if w == nil { + return nil, nil + } + out := &sdk.FunctionExtraParameter{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// FunctionExtraParameterFromSDK converts the sdk-go type to the mirror. +func FunctionExtraParameterFromSDK(v *sdk.FunctionExtraParameter) (*FunctionExtraParameter, error) { + if v == nil { + return nil, nil + } + out := &FunctionExtraParameter{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// IngestionConfigToSDK converts the mirror to the sdk-go type. +func IngestionConfigToSDK(w *IngestionConfig) (*sdk.IngestionConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionConfig{} + conv101, err := IngestionDestinationToSDK(w.IngestionDestination) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionConfig.IngestionDestination", err) + } + out.IngestionDestination = conv101 + conv102, err := BackfillSourceToSDK(w.BackfillSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionConfig.BackfillSource", err) + } + out.BackfillSource = conv102 + out.DeduplicationColumns = w.DeduplicationColumns + out.IngestionPipelineId = w.IngestionPipelineId + out.IngestionJobId = w.IngestionJobId + out.BackfillJobId = w.BackfillJobId + out.Tags = w.Tags + out.BudgetPolicyId = w.BudgetPolicyId + return out, nil +} + +// IngestionConfigFromSDK converts the sdk-go type to the mirror. +func IngestionConfigFromSDK(v *sdk.IngestionConfig) (*IngestionConfig, error) { + if v == nil { + return nil, nil + } + out := &IngestionConfig{} + conv103, err := IngestionDestinationFromSDK(v.IngestionDestination) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionConfig.IngestionDestination", err) + } + out.IngestionDestination = conv103 + conv104, err := BackfillSourceFromSDK(v.BackfillSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionConfig.BackfillSource", err) + } + out.BackfillSource = conv104 + out.DeduplicationColumns = v.DeduplicationColumns + out.IngestionPipelineId = v.IngestionPipelineId + out.IngestionJobId = v.IngestionJobId + out.BackfillJobId = v.BackfillJobId + out.Tags = v.Tags + out.BudgetPolicyId = v.BudgetPolicyId + return out, nil +} + +// IngestionDestinationToSDK converts the mirror to the sdk-go type. +func IngestionDestinationToSDK(w *IngestionDestination) (*sdk.IngestionDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionDestination{} + { + var members []string + if w.DeltaTableName != nil { + members = append(members, "delta_table_name") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DeltaTableName != nil: + out.IngestionDestination = &sdk.IngestionDestination_IngestionDestination_DeltaTableName{DeltaTableName: *w.DeltaTableName} + } + return out, nil +} + +// IngestionDestinationFromSDK converts the sdk-go type to the mirror. +func IngestionDestinationFromSDK(v *sdk.IngestionDestination) (*IngestionDestination, error) { + if v == nil { + return nil, nil + } + out := &IngestionDestination{} + switch value := v.IngestionDestination.(type) { + case *sdk.IngestionDestination_IngestionDestination_DeltaTableName: + if value != nil { + out.DeltaTableName = new(value.DeltaTableName) + } + } + return out, nil +} + +// InputBindingToSDK converts the mirror to the sdk-go type. +func InputBindingToSDK(w *InputBinding) (*sdk.InputBinding, error) { + if w == nil { + return nil, nil + } + out := &sdk.InputBinding{} + out.Parameter = w.Parameter + out.Column = w.Column + return out, nil +} + +// InputBindingFromSDK converts the sdk-go type to the mirror. +func InputBindingFromSDK(v *sdk.InputBinding) (*InputBinding, error) { + if v == nil { + return nil, nil + } + out := &InputBinding{} + out.Parameter = v.Parameter + out.Column = v.Column + return out, nil +} + +// JobContextToSDK converts the mirror to the sdk-go type. +func JobContextToSDK(w *JobContext) (*sdk.JobContext, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobContext{} + out.JobId = w.JobId + out.JobRunId = w.JobRunId + return out, nil +} + +// JobContextFromSDK converts the sdk-go type to the mirror. +func JobContextFromSDK(v *sdk.JobContext) (*JobContext, error) { + if v == nil { + return nil, nil + } + out := &JobContext{} + out.JobId = v.JobId + out.JobRunId = v.JobRunId + return out, nil +} + +// KafkaConfigToSDK converts the mirror to the sdk-go type. +func KafkaConfigToSDK(w *KafkaConfig) (*sdk.KafkaConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.KafkaConfig{} + out.Name = w.Name + out.BootstrapServers = w.BootstrapServers + conv105, err := SubscriptionModeToSDK(w.SubscriptionMode) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaConfig.SubscriptionMode", err) + } + out.SubscriptionMode = conv105 + conv106, err := AuthConfigToSDK(w.AuthConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaConfig.AuthConfig", err) + } + out.AuthConfig = conv106 + conv107, err := SchemaConfigToSDK(w.KeySchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaConfig.KeySchema", err) + } + out.KeySchema = conv107 + conv108, err := SchemaConfigToSDK(w.ValueSchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaConfig.ValueSchema", err) + } + out.ValueSchema = conv108 + out.ExtraOptions = w.ExtraOptions + conv109, err := BackfillSourceToSDK(w.BackfillSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaConfig.BackfillSource", err) + } + out.BackfillSource = conv109 + conv110, err := IngestionConfigToSDK(w.IngestionConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaConfig.IngestionConfig", err) + } + out.IngestionConfig = conv110 + return out, nil +} + +// KafkaConfigFromSDK converts the sdk-go type to the mirror. +func KafkaConfigFromSDK(v *sdk.KafkaConfig) (*KafkaConfig, error) { + if v == nil { + return nil, nil + } + out := &KafkaConfig{} + out.Name = v.Name + out.BootstrapServers = v.BootstrapServers + conv111, err := SubscriptionModeFromSDK(v.SubscriptionMode) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaConfig.SubscriptionMode", err) + } + out.SubscriptionMode = conv111 + conv112, err := AuthConfigFromSDK(v.AuthConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaConfig.AuthConfig", err) + } + out.AuthConfig = conv112 + conv113, err := SchemaConfigFromSDK(v.KeySchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaConfig.KeySchema", err) + } + out.KeySchema = conv113 + conv114, err := SchemaConfigFromSDK(v.ValueSchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaConfig.ValueSchema", err) + } + out.ValueSchema = conv114 + out.ExtraOptions = v.ExtraOptions + conv115, err := BackfillSourceFromSDK(v.BackfillSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaConfig.BackfillSource", err) + } + out.BackfillSource = conv115 + conv116, err := IngestionConfigFromSDK(v.IngestionConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaConfig.IngestionConfig", err) + } + out.IngestionConfig = conv116 + return out, nil +} + +// KafkaSourceToSDK converts the mirror to the sdk-go type. +func KafkaSourceToSDK(w *KafkaSource) (*sdk.KafkaSource, error) { + if w == nil { + return nil, nil + } + out := &sdk.KafkaSource{} + out.Name = w.Name + conv117, err := convertSlice(w.EntityColumnIdentifiers, ColumnIdentifierToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaSource.EntityColumnIdentifiers", err) + } + out.EntityColumnIdentifiers = conv117 + conv118, err := ColumnIdentifierToSDK(w.TimeseriesColumnIdentifier) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaSource.TimeseriesColumnIdentifier", err) + } + out.TimeseriesColumnIdentifier = conv118 + out.FilterCondition = w.FilterCondition + return out, nil +} + +// KafkaSourceFromSDK converts the sdk-go type to the mirror. +func KafkaSourceFromSDK(v *sdk.KafkaSource) (*KafkaSource, error) { + if v == nil { + return nil, nil + } + out := &KafkaSource{} + out.Name = v.Name + conv119, err := convertSlice(v.EntityColumnIdentifiers, ColumnIdentifierFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaSource.EntityColumnIdentifiers", err) + } + out.EntityColumnIdentifiers = conv119 + conv120, err := ColumnIdentifierFromSDK(v.TimeseriesColumnIdentifier) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaSource.TimeseriesColumnIdentifier", err) + } + out.TimeseriesColumnIdentifier = conv120 + out.FilterCondition = v.FilterCondition + return out, nil +} + +// KafkaStreamConfigToSDK converts the mirror to the sdk-go type. +func KafkaStreamConfigToSDK(w *KafkaStreamConfig) (*sdk.KafkaStreamConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.KafkaStreamConfig{} + conv121, err := KafkaSubscriptionModeToSDK(w.SubscriptionMode) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaStreamConfig.SubscriptionMode", err) + } + out.SubscriptionMode = conv121 + out.ExtraOptions = w.ExtraOptions + return out, nil +} + +// KafkaStreamConfigFromSDK converts the sdk-go type to the mirror. +func KafkaStreamConfigFromSDK(v *sdk.KafkaStreamConfig) (*KafkaStreamConfig, error) { + if v == nil { + return nil, nil + } + out := &KafkaStreamConfig{} + conv122, err := KafkaSubscriptionModeFromSDK(v.SubscriptionMode) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaStreamConfig.SubscriptionMode", err) + } + out.SubscriptionMode = conv122 + out.ExtraOptions = v.ExtraOptions + return out, nil +} + +// KafkaSubscriptionModeToSDK converts the mirror to the sdk-go type. +func KafkaSubscriptionModeToSDK(w *KafkaSubscriptionMode) (*sdk.KafkaSubscriptionMode, error) { + if w == nil { + return nil, nil + } + out := &sdk.KafkaSubscriptionMode{} + { + var members []string + if w.Assign != nil { + members = append(members, "assign") + } + if w.Subscribe != nil { + members = append(members, "subscribe") + } + if w.SubscribePattern != nil { + members = append(members, "subscribe_pattern") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Assign != nil: + out.SubscriptionMode = &sdk.KafkaSubscriptionMode_SubscriptionMode_Assign{Assign: *w.Assign} + case w.Subscribe != nil: + out.SubscriptionMode = &sdk.KafkaSubscriptionMode_SubscriptionMode_Subscribe{Subscribe: *w.Subscribe} + case w.SubscribePattern != nil: + out.SubscriptionMode = &sdk.KafkaSubscriptionMode_SubscriptionMode_SubscribePattern{SubscribePattern: *w.SubscribePattern} + } + return out, nil +} + +// KafkaSubscriptionModeFromSDK converts the sdk-go type to the mirror. +func KafkaSubscriptionModeFromSDK(v *sdk.KafkaSubscriptionMode) (*KafkaSubscriptionMode, error) { + if v == nil { + return nil, nil + } + out := &KafkaSubscriptionMode{} + switch value := v.SubscriptionMode.(type) { + case *sdk.KafkaSubscriptionMode_SubscriptionMode_Assign: + if value != nil { + out.Assign = new(value.Assign) + } + case *sdk.KafkaSubscriptionMode_SubscriptionMode_Subscribe: + if value != nil { + out.Subscribe = new(value.Subscribe) + } + case *sdk.KafkaSubscriptionMode_SubscriptionMode_SubscribePattern: + if value != nil { + out.SubscribePattern = new(value.SubscribePattern) + } + } + return out, nil +} + +// KinesisStreamConfigToSDK converts the mirror to the sdk-go type. +func KinesisStreamConfigToSDK(w *KinesisStreamConfig) (*sdk.KinesisStreamConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.KinesisStreamConfig{} + { + var members []string + if w.StreamNames != nil { + members = append(members, "stream_names") + } + if w.StreamArns != nil { + members = append(members, "stream_arns") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.StreamNames != nil: + conv123, err := StreamNameListToSDK(w.StreamNames) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KinesisStreamConfig.StreamIdentifier", err) + } + out.StreamIdentifier = &sdk.KinesisStreamConfig_StreamIdentifier_StreamNames{StreamNames: *conv123} + case w.StreamArns != nil: + conv124, err := StreamArnListToSDK(w.StreamArns) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KinesisStreamConfig.StreamIdentifier", err) + } + out.StreamIdentifier = &sdk.KinesisStreamConfig_StreamIdentifier_StreamArns{StreamArns: *conv124} + } + out.ExtraOptions = w.ExtraOptions + return out, nil +} + +// KinesisStreamConfigFromSDK converts the sdk-go type to the mirror. +func KinesisStreamConfigFromSDK(v *sdk.KinesisStreamConfig) (*KinesisStreamConfig, error) { + if v == nil { + return nil, nil + } + out := &KinesisStreamConfig{} + switch value := v.StreamIdentifier.(type) { + case *sdk.KinesisStreamConfig_StreamIdentifier_StreamNames: + if value != nil { + conv125, err := StreamNameListFromSDK(&value.StreamNames) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KinesisStreamConfig.StreamIdentifier", err) + } + out.StreamNames = conv125 + } + case *sdk.KinesisStreamConfig_StreamIdentifier_StreamArns: + if value != nil { + conv126, err := StreamArnListFromSDK(&value.StreamArns) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KinesisStreamConfig.StreamIdentifier", err) + } + out.StreamArns = conv126 + } + } + out.ExtraOptions = v.ExtraOptions + return out, nil +} + +// LastDistinctFunctionToSDK converts the mirror to the sdk-go type. +func LastDistinctFunctionToSDK(w *LastDistinctFunction) (*sdk.LastDistinctFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.LastDistinctFunction{} + out.Input = w.Input + out.N = w.N + return out, nil +} + +// LastDistinctFunctionFromSDK converts the sdk-go type to the mirror. +func LastDistinctFunctionFromSDK(v *sdk.LastDistinctFunction) (*LastDistinctFunction, error) { + if v == nil { + return nil, nil + } + out := &LastDistinctFunction{} + out.Input = v.Input + out.N = v.N + return out, nil +} + +// LastFunctionToSDK converts the mirror to the sdk-go type. +func LastFunctionToSDK(w *LastFunction) (*sdk.LastFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.LastFunction{} + out.Input = w.Input + return out, nil +} + +// LastFunctionFromSDK converts the sdk-go type to the mirror. +func LastFunctionFromSDK(v *sdk.LastFunction) (*LastFunction, error) { + if v == nil { + return nil, nil + } + out := &LastFunction{} + out.Input = v.Input + return out, nil +} + +// LastNFunctionToSDK converts the mirror to the sdk-go type. +func LastNFunctionToSDK(w *LastNFunction) (*sdk.LastNFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.LastNFunction{} + out.Input = w.Input + out.N = w.N + return out, nil +} + +// LastNFunctionFromSDK converts the sdk-go type to the mirror. +func LastNFunctionFromSDK(v *sdk.LastNFunction) (*LastNFunction, error) { + if v == nil { + return nil, nil + } + out := &LastNFunction{} + out.Input = v.Input + out.N = v.N + return out, nil +} + +// LineageContextToSDK converts the mirror to the sdk-go type. +func LineageContextToSDK(w *LineageContext) (*sdk.LineageContext, error) { + if w == nil { + return nil, nil + } + out := &sdk.LineageContext{} + out.NotebookId = w.NotebookId + conv127, err := JobContextToSDK(w.JobContext) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LineageContext.JobContext", err) + } + out.JobContext = conv127 + return out, nil +} + +// LineageContextFromSDK converts the sdk-go type to the mirror. +func LineageContextFromSDK(v *sdk.LineageContext) (*LineageContext, error) { + if v == nil { + return nil, nil + } + out := &LineageContext{} + out.NotebookId = v.NotebookId + conv128, err := JobContextFromSDK(v.JobContext) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LineageContext.JobContext", err) + } + out.JobContext = conv128 + return out, nil +} + +// ListFeaturesRequestToSDK converts the mirror to the sdk-go type. +func ListFeaturesRequestToSDK(w *ListFeaturesRequest) (*sdk.ListFeaturesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListFeaturesRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + return out, nil +} + +// ListFeaturesRequestFromSDK converts the sdk-go type to the mirror. +func ListFeaturesRequestFromSDK(v *sdk.ListFeaturesRequest) (*ListFeaturesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListFeaturesRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + return out, nil +} + +// ListFeaturesResponseToSDK converts the mirror to the sdk-go type. +func ListFeaturesResponseToSDK(w *ListFeaturesResponse) (*sdk.ListFeaturesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListFeaturesResponse{} + conv129, err := convertSlice(w.Features, FeatureToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFeaturesResponse.Features", err) + } + out.Features = conv129 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListFeaturesResponseFromSDK converts the sdk-go type to the mirror. +func ListFeaturesResponseFromSDK(v *sdk.ListFeaturesResponse) (*ListFeaturesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListFeaturesResponse{} + conv130, err := convertSlice(v.Features, FeatureFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFeaturesResponse.Features", err) + } + out.Features = conv130 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListKafkaConfigsRequestToSDK converts the mirror to the sdk-go type. +func ListKafkaConfigsRequestToSDK(w *ListKafkaConfigsRequest) (*sdk.ListKafkaConfigsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListKafkaConfigsRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListKafkaConfigsRequestFromSDK converts the sdk-go type to the mirror. +func ListKafkaConfigsRequestFromSDK(v *sdk.ListKafkaConfigsRequest) (*ListKafkaConfigsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListKafkaConfigsRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListKafkaConfigsResponseToSDK converts the mirror to the sdk-go type. +func ListKafkaConfigsResponseToSDK(w *ListKafkaConfigsResponse) (*sdk.ListKafkaConfigsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListKafkaConfigsResponse{} + conv131, err := convertSlice(w.KafkaConfigs, KafkaConfigToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListKafkaConfigsResponse.KafkaConfigs", err) + } + out.KafkaConfigs = conv131 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListKafkaConfigsResponseFromSDK converts the sdk-go type to the mirror. +func ListKafkaConfigsResponseFromSDK(v *sdk.ListKafkaConfigsResponse) (*ListKafkaConfigsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListKafkaConfigsResponse{} + conv132, err := convertSlice(v.KafkaConfigs, KafkaConfigFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListKafkaConfigsResponse.KafkaConfigs", err) + } + out.KafkaConfigs = conv132 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListMaterializedFeaturesRequestToSDK converts the mirror to the sdk-go type. +func ListMaterializedFeaturesRequestToSDK(w *ListMaterializedFeaturesRequest) (*sdk.ListMaterializedFeaturesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListMaterializedFeaturesRequest{} + out.FeatureName = w.FeatureName + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListMaterializedFeaturesRequestFromSDK converts the sdk-go type to the mirror. +func ListMaterializedFeaturesRequestFromSDK(v *sdk.ListMaterializedFeaturesRequest) (*ListMaterializedFeaturesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListMaterializedFeaturesRequest{} + out.FeatureName = v.FeatureName + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListMaterializedFeaturesResponseToSDK converts the mirror to the sdk-go type. +func ListMaterializedFeaturesResponseToSDK(w *ListMaterializedFeaturesResponse) (*sdk.ListMaterializedFeaturesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListMaterializedFeaturesResponse{} + conv133, err := convertSlice(w.MaterializedFeatures, MaterializedFeatureToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListMaterializedFeaturesResponse.MaterializedFeatures", err) + } + out.MaterializedFeatures = conv133 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListMaterializedFeaturesResponseFromSDK converts the sdk-go type to the mirror. +func ListMaterializedFeaturesResponseFromSDK(v *sdk.ListMaterializedFeaturesResponse) (*ListMaterializedFeaturesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListMaterializedFeaturesResponse{} + conv134, err := convertSlice(v.MaterializedFeatures, MaterializedFeatureFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListMaterializedFeaturesResponse.MaterializedFeatures", err) + } + out.MaterializedFeatures = conv134 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListStreamsRequestToSDK converts the mirror to the sdk-go type. +func ListStreamsRequestToSDK(w *ListStreamsRequest) (*sdk.ListStreamsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListStreamsRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListStreamsRequestFromSDK converts the sdk-go type to the mirror. +func ListStreamsRequestFromSDK(v *sdk.ListStreamsRequest) (*ListStreamsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListStreamsRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListStreamsResponseToSDK converts the mirror to the sdk-go type. +func ListStreamsResponseToSDK(w *ListStreamsResponse) (*sdk.ListStreamsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListStreamsResponse{} + conv135, err := convertSlice(w.Streams, StreamToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListStreamsResponse.Streams", err) + } + out.Streams = conv135 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListStreamsResponseFromSDK converts the sdk-go type to the mirror. +func ListStreamsResponseFromSDK(v *sdk.ListStreamsResponse) (*ListStreamsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListStreamsResponse{} + conv136, err := convertSlice(v.Streams, StreamFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListStreamsResponse.Streams", err) + } + out.Streams = conv136 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// MaterializationFailureNotificationToSDK converts the mirror to the sdk-go type. +func MaterializationFailureNotificationToSDK(w *MaterializationFailureNotification) (*sdk.MaterializationFailureNotification, error) { + if w == nil { + return nil, nil + } + out := &sdk.MaterializationFailureNotification{} + out.EmailAddresses = w.EmailAddresses + out.DestinationIds = w.DestinationIds + out.FinalAttemptOnly = w.FinalAttemptOnly + return out, nil +} + +// MaterializationFailureNotificationFromSDK converts the sdk-go type to the mirror. +func MaterializationFailureNotificationFromSDK(v *sdk.MaterializationFailureNotification) (*MaterializationFailureNotification, error) { + if v == nil { + return nil, nil + } + out := &MaterializationFailureNotification{} + out.EmailAddresses = v.EmailAddresses + out.DestinationIds = v.DestinationIds + out.FinalAttemptOnly = v.FinalAttemptOnly + return out, nil +} + +// MaterializationNotificationsToSDK converts the mirror to the sdk-go type. +func MaterializationNotificationsToSDK(w *MaterializationNotifications) (*sdk.MaterializationNotifications, error) { + if w == nil { + return nil, nil + } + out := &sdk.MaterializationNotifications{} + conv137, err := MaterializationSuccessNotificationToSDK(w.OnSuccess) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializationNotifications.OnSuccess", err) + } + out.OnSuccess = conv137 + conv138, err := MaterializationFailureNotificationToSDK(w.OnFailure) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializationNotifications.OnFailure", err) + } + out.OnFailure = conv138 + return out, nil +} + +// MaterializationNotificationsFromSDK converts the sdk-go type to the mirror. +func MaterializationNotificationsFromSDK(v *sdk.MaterializationNotifications) (*MaterializationNotifications, error) { + if v == nil { + return nil, nil + } + out := &MaterializationNotifications{} + conv139, err := MaterializationSuccessNotificationFromSDK(v.OnSuccess) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializationNotifications.OnSuccess", err) + } + out.OnSuccess = conv139 + conv140, err := MaterializationFailureNotificationFromSDK(v.OnFailure) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializationNotifications.OnFailure", err) + } + out.OnFailure = conv140 + return out, nil +} + +// MaterializationSuccessNotificationToSDK converts the mirror to the sdk-go type. +func MaterializationSuccessNotificationToSDK(w *MaterializationSuccessNotification) (*sdk.MaterializationSuccessNotification, error) { + if w == nil { + return nil, nil + } + out := &sdk.MaterializationSuccessNotification{} + out.EmailAddresses = w.EmailAddresses + out.DestinationIds = w.DestinationIds + return out, nil +} + +// MaterializationSuccessNotificationFromSDK converts the sdk-go type to the mirror. +func MaterializationSuccessNotificationFromSDK(v *sdk.MaterializationSuccessNotification) (*MaterializationSuccessNotification, error) { + if v == nil { + return nil, nil + } + out := &MaterializationSuccessNotification{} + out.EmailAddresses = v.EmailAddresses + out.DestinationIds = v.DestinationIds + return out, nil +} + +// MaterializedFeatureToSDK converts the mirror to the sdk-go type. +func MaterializedFeatureToSDK(w *MaterializedFeature) (*sdk.MaterializedFeature, error) { + if w == nil { + return nil, nil + } + out := &sdk.MaterializedFeature{} + out.MaterializedFeatureId = w.MaterializedFeatureId + out.FeatureName = w.FeatureName + { + var members []string + if w.OfflineStoreConfig != nil { + members = append(members, "offline_store_config") + } + if w.OnlineStoreConfig != nil { + members = append(members, "online_store_config") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.OfflineStoreConfig != nil: + conv141, err := OfflineStoreConfigToSDK(w.OfflineStoreConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializedFeature.Destination", err) + } + out.Destination = &sdk.MaterializedFeature_Destination_OfflineStoreConfig{OfflineStoreConfig: *conv141} + case w.OnlineStoreConfig != nil: + conv142, err := OnlineStoreConfigToSDK(w.OnlineStoreConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializedFeature.Destination", err) + } + out.Destination = &sdk.MaterializedFeature_Destination_OnlineStoreConfig{OnlineStoreConfig: *conv142} + } + out.TableName = w.TableName + out.PipelineScheduleState = w.PipelineScheduleState + out.LastMaterializationTime = w.LastMaterializationTime + out.CronSchedule = w.CronSchedule + out.IsOnline = w.IsOnline + { + var members []string + if w.CronScheduleTrigger != nil { + members = append(members, "cron_schedule_trigger") + } + if w.TableTrigger != nil { + members = append(members, "table_trigger") + } + if w.StreamingMode != nil { + members = append(members, "streaming_mode") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.CronScheduleTrigger != nil: + conv143, err := CronScheduleToSDK(w.CronScheduleTrigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializedFeature.Trigger", err) + } + out.Trigger = &sdk.MaterializedFeature_Trigger_CronScheduleTrigger{CronScheduleTrigger: *conv143} + case w.TableTrigger != nil: + conv144, err := TableTriggerToSDK(w.TableTrigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializedFeature.Trigger", err) + } + out.Trigger = &sdk.MaterializedFeature_Trigger_TableTrigger{TableTrigger: *conv144} + case w.StreamingMode != nil: + conv145, err := StreamingModeToSDK(w.StreamingMode) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializedFeature.Trigger", err) + } + out.Trigger = &sdk.MaterializedFeature_Trigger_StreamingMode{StreamingMode: *conv145} + } + out.LatestBackfillOperation = w.LatestBackfillOperation + out.Tags = w.Tags + out.BudgetPolicyId = w.BudgetPolicyId + out.PipelineId = w.PipelineId + out.JobId = w.JobId + conv146, err := MaterializationNotificationsToSDK(w.Notifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializedFeature.Notifications", err) + } + out.Notifications = conv146 + return out, nil +} + +// MaterializedFeatureFromSDK converts the sdk-go type to the mirror. +func MaterializedFeatureFromSDK(v *sdk.MaterializedFeature) (*MaterializedFeature, error) { + if v == nil { + return nil, nil + } + out := &MaterializedFeature{} + out.MaterializedFeatureId = v.MaterializedFeatureId + out.FeatureName = v.FeatureName + switch value := v.Destination.(type) { + case *sdk.MaterializedFeature_Destination_OfflineStoreConfig: + if value != nil { + conv147, err := OfflineStoreConfigFromSDK(&value.OfflineStoreConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializedFeature.Destination", err) + } + out.OfflineStoreConfig = conv147 + } + case *sdk.MaterializedFeature_Destination_OnlineStoreConfig: + if value != nil { + conv148, err := OnlineStoreConfigFromSDK(&value.OnlineStoreConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializedFeature.Destination", err) + } + out.OnlineStoreConfig = conv148 + } + } + out.TableName = v.TableName + out.PipelineScheduleState = v.PipelineScheduleState + out.LastMaterializationTime = v.LastMaterializationTime + out.CronSchedule = v.CronSchedule + out.IsOnline = v.IsOnline + switch value := v.Trigger.(type) { + case *sdk.MaterializedFeature_Trigger_CronScheduleTrigger: + if value != nil { + conv149, err := CronScheduleFromSDK(&value.CronScheduleTrigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializedFeature.Trigger", err) + } + out.CronScheduleTrigger = conv149 + } + case *sdk.MaterializedFeature_Trigger_TableTrigger: + if value != nil { + conv150, err := TableTriggerFromSDK(&value.TableTrigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializedFeature.Trigger", err) + } + out.TableTrigger = conv150 + } + case *sdk.MaterializedFeature_Trigger_StreamingMode: + if value != nil { + conv151, err := StreamingModeFromSDK(&value.StreamingMode) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializedFeature.Trigger", err) + } + out.StreamingMode = conv151 + } + } + out.LatestBackfillOperation = v.LatestBackfillOperation + out.Tags = v.Tags + out.BudgetPolicyId = v.BudgetPolicyId + out.PipelineId = v.PipelineId + out.JobId = v.JobId + conv152, err := MaterializationNotificationsFromSDK(v.Notifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MaterializedFeature.Notifications", err) + } + out.Notifications = conv152 + return out, nil +} + +// MaxFunctionToSDK converts the mirror to the sdk-go type. +func MaxFunctionToSDK(w *MaxFunction) (*sdk.MaxFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.MaxFunction{} + out.Input = w.Input + return out, nil +} + +// MaxFunctionFromSDK converts the sdk-go type to the mirror. +func MaxFunctionFromSDK(v *sdk.MaxFunction) (*MaxFunction, error) { + if v == nil { + return nil, nil + } + out := &MaxFunction{} + out.Input = v.Input + return out, nil +} + +// MinFunctionToSDK converts the mirror to the sdk-go type. +func MinFunctionToSDK(w *MinFunction) (*sdk.MinFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.MinFunction{} + out.Input = w.Input + return out, nil +} + +// MinFunctionFromSDK converts the sdk-go type to the mirror. +func MinFunctionFromSDK(v *sdk.MinFunction) (*MinFunction, error) { + if v == nil { + return nil, nil + } + out := &MinFunction{} + out.Input = v.Input + return out, nil +} + +// MtlsConfigToSDK converts the mirror to the sdk-go type. +func MtlsConfigToSDK(w *MtlsConfig) (*sdk.MtlsConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.MtlsConfig{} + out.KeystoreLocation = w.KeystoreLocation + conv153, err := SecretScopeReferenceToSDK(w.KeystorePasswordRef) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MtlsConfig.KeystorePasswordRef", err) + } + out.KeystorePasswordRef = conv153 + conv154, err := SecretScopeReferenceToSDK(w.KeyPasswordRef) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MtlsConfig.KeyPasswordRef", err) + } + out.KeyPasswordRef = conv154 + out.TruststoreLocation = w.TruststoreLocation + conv155, err := SecretScopeReferenceToSDK(w.TruststorePasswordRef) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MtlsConfig.TruststorePasswordRef", err) + } + out.TruststorePasswordRef = conv155 + out.DisableHostnameVerification = w.DisableHostnameVerification + return out, nil +} + +// MtlsConfigFromSDK converts the sdk-go type to the mirror. +func MtlsConfigFromSDK(v *sdk.MtlsConfig) (*MtlsConfig, error) { + if v == nil { + return nil, nil + } + out := &MtlsConfig{} + out.KeystoreLocation = v.KeystoreLocation + conv156, err := SecretScopeReferenceFromSDK(v.KeystorePasswordRef) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MtlsConfig.KeystorePasswordRef", err) + } + out.KeystorePasswordRef = conv156 + conv157, err := SecretScopeReferenceFromSDK(v.KeyPasswordRef) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MtlsConfig.KeyPasswordRef", err) + } + out.KeyPasswordRef = conv157 + out.TruststoreLocation = v.TruststoreLocation + conv158, err := SecretScopeReferenceFromSDK(v.TruststorePasswordRef) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MtlsConfig.TruststorePasswordRef", err) + } + out.TruststorePasswordRef = conv158 + out.DisableHostnameVerification = v.DisableHostnameVerification + return out, nil +} + +// OfflineStoreConfigToSDK converts the mirror to the sdk-go type. +func OfflineStoreConfigToSDK(w *OfflineStoreConfig) (*sdk.OfflineStoreConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.OfflineStoreConfig{} + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.TableNamePrefix = w.TableNamePrefix + return out, nil +} + +// OfflineStoreConfigFromSDK converts the sdk-go type to the mirror. +func OfflineStoreConfigFromSDK(v *sdk.OfflineStoreConfig) (*OfflineStoreConfig, error) { + if v == nil { + return nil, nil + } + out := &OfflineStoreConfig{} + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.TableNamePrefix = v.TableNamePrefix + return out, nil +} + +// OnlineStoreConfigToSDK converts the mirror to the sdk-go type. +func OnlineStoreConfigToSDK(w *OnlineStoreConfig) (*sdk.OnlineStoreConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.OnlineStoreConfig{} + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.TableNamePrefix = w.TableNamePrefix + out.OnlineStoreName = w.OnlineStoreName + return out, nil +} + +// OnlineStoreConfigFromSDK converts the sdk-go type to the mirror. +func OnlineStoreConfigFromSDK(v *sdk.OnlineStoreConfig) (*OnlineStoreConfig, error) { + if v == nil { + return nil, nil + } + out := &OnlineStoreConfig{} + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.TableNamePrefix = v.TableNamePrefix + out.OnlineStoreName = v.OnlineStoreName + return out, nil +} + +// OperationToSDK converts the mirror to the sdk-go type. +func OperationToSDK(w *Operation) (*sdk.Operation, error) { + if w == nil { + return nil, nil + } + out := &sdk.Operation{} + out.Name = w.Name + out.Metadata = w.Metadata + out.Done = w.Done + { + var members []string + if w.Error != nil { + members = append(members, "error") + } + if w.Response != nil { + members = append(members, "response") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Error != nil: + conv159, err := ApiErrorToSDK(w.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Operation.Result", err) + } + out.Result = &sdk.Operation_Result_Error{Error: *conv159} + case w.Response != nil: + out.Result = &sdk.Operation_Result_Response{Response: w.Response} + } + return out, nil +} + +// OperationFromSDK converts the sdk-go type to the mirror. +func OperationFromSDK(v *sdk.Operation) (*Operation, error) { + if v == nil { + return nil, nil + } + out := &Operation{} + out.Name = v.Name + out.Metadata = v.Metadata + out.Done = v.Done + switch value := v.Result.(type) { + case *sdk.Operation_Result_Error: + if value != nil { + conv160, err := ApiErrorFromSDK(&value.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Operation.Result", err) + } + out.Error = conv160 + } + case *sdk.Operation_Result_Response: + if value != nil { + out.Response = value.Response + } + } + return out, nil +} + +// ProtoSchemaSpecToSDK converts the mirror to the sdk-go type. +func ProtoSchemaSpecToSDK(w *ProtoSchemaSpec) (*sdk.ProtoSchemaSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProtoSchemaSpec{} + out.SchemaText = w.SchemaText + out.MessageName = w.MessageName + return out, nil +} + +// ProtoSchemaSpecFromSDK converts the sdk-go type to the mirror. +func ProtoSchemaSpecFromSDK(v *sdk.ProtoSchemaSpec) (*ProtoSchemaSpec, error) { + if v == nil { + return nil, nil + } + out := &ProtoSchemaSpec{} + out.SchemaText = v.SchemaText + out.MessageName = v.MessageName + return out, nil +} + +// PurgeFeatureEntitiesMetadataToSDK converts the mirror to the sdk-go type. +func PurgeFeatureEntitiesMetadataToSDK(w *PurgeFeatureEntitiesMetadata) (*sdk.PurgeFeatureEntitiesMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.PurgeFeatureEntitiesMetadata{} + out.Features = w.Features + out.EntitiesTable = w.EntitiesTable + out.EntitiesTableVersion = w.EntitiesTableVersion + out.CreateTime = w.CreateTime + out.State = w.State + out.JobId = w.JobId + return out, nil +} + +// PurgeFeatureEntitiesMetadataFromSDK converts the sdk-go type to the mirror. +func PurgeFeatureEntitiesMetadataFromSDK(v *sdk.PurgeFeatureEntitiesMetadata) (*PurgeFeatureEntitiesMetadata, error) { + if v == nil { + return nil, nil + } + out := &PurgeFeatureEntitiesMetadata{} + out.Features = v.Features + out.EntitiesTable = v.EntitiesTable + out.EntitiesTableVersion = v.EntitiesTableVersion + out.CreateTime = v.CreateTime + out.State = v.State + out.JobId = v.JobId + return out, nil +} + +// PurgeFeatureEntitiesRequestToSDK converts the mirror to the sdk-go type. +func PurgeFeatureEntitiesRequestToSDK(w *PurgeFeatureEntitiesRequest) (*sdk.PurgeFeatureEntitiesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PurgeFeatureEntitiesRequest{} + out.Features = w.Features + { + var members []string + if w.EntitiesTable != nil { + members = append(members, "entities_table") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.EntitiesTable != nil: + out.Entities = &sdk.PurgeFeatureEntitiesRequest_Entities_EntitiesTable{EntitiesTable: *w.EntitiesTable} + } + out.RequestId = w.RequestId + out.Tags = w.Tags + out.BudgetPolicyId = w.BudgetPolicyId + return out, nil +} + +// PurgeFeatureEntitiesRequestFromSDK converts the sdk-go type to the mirror. +func PurgeFeatureEntitiesRequestFromSDK(v *sdk.PurgeFeatureEntitiesRequest) (*PurgeFeatureEntitiesRequest, error) { + if v == nil { + return nil, nil + } + out := &PurgeFeatureEntitiesRequest{} + out.Features = v.Features + switch value := v.Entities.(type) { + case *sdk.PurgeFeatureEntitiesRequest_Entities_EntitiesTable: + if value != nil { + out.EntitiesTable = new(value.EntitiesTable) + } + } + out.RequestId = v.RequestId + out.Tags = v.Tags + out.BudgetPolicyId = v.BudgetPolicyId + return out, nil +} + +// PurgeFeatureEntitiesResponseToSDK converts the mirror to the sdk-go type. +func PurgeFeatureEntitiesResponseToSDK(w *PurgeFeatureEntitiesResponse) (*sdk.PurgeFeatureEntitiesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.PurgeFeatureEntitiesResponse{} + conv161, err := PurgeFeatureEntitiesMetadataToSDK(w.Metadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PurgeFeatureEntitiesResponse.Metadata", err) + } + out.Metadata = conv161 + conv162, err := convertSlice(w.Results, PurgeFeatureEntitiesResultToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PurgeFeatureEntitiesResponse.Results", err) + } + out.Results = conv162 + out.State = w.State + conv163, err := ApiErrorToSDK(w.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PurgeFeatureEntitiesResponse.Error", err) + } + out.Error = conv163 + return out, nil +} + +// PurgeFeatureEntitiesResponseFromSDK converts the sdk-go type to the mirror. +func PurgeFeatureEntitiesResponseFromSDK(v *sdk.PurgeFeatureEntitiesResponse) (*PurgeFeatureEntitiesResponse, error) { + if v == nil { + return nil, nil + } + out := &PurgeFeatureEntitiesResponse{} + conv164, err := PurgeFeatureEntitiesMetadataFromSDK(v.Metadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PurgeFeatureEntitiesResponse.Metadata", err) + } + out.Metadata = conv164 + conv165, err := convertSlice(v.Results, PurgeFeatureEntitiesResultFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PurgeFeatureEntitiesResponse.Results", err) + } + out.Results = conv165 + out.State = v.State + conv166, err := ApiErrorFromSDK(v.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PurgeFeatureEntitiesResponse.Error", err) + } + out.Error = conv166 + return out, nil +} + +// PurgeFeatureEntitiesResultToSDK converts the mirror to the sdk-go type. +func PurgeFeatureEntitiesResultToSDK(w *PurgeFeatureEntitiesResult) (*sdk.PurgeFeatureEntitiesResult, error) { + if w == nil { + return nil, nil + } + out := &sdk.PurgeFeatureEntitiesResult{} + out.Feature = w.Feature + out.OfflineState = w.OfflineState + out.OnlineState = w.OnlineState + conv167, err := ApiErrorToSDK(w.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PurgeFeatureEntitiesResult.Error", err) + } + out.Error = conv167 + return out, nil +} + +// PurgeFeatureEntitiesResultFromSDK converts the sdk-go type to the mirror. +func PurgeFeatureEntitiesResultFromSDK(v *sdk.PurgeFeatureEntitiesResult) (*PurgeFeatureEntitiesResult, error) { + if v == nil { + return nil, nil + } + out := &PurgeFeatureEntitiesResult{} + out.Feature = v.Feature + out.OfflineState = v.OfflineState + out.OnlineState = v.OnlineState + conv168, err := ApiErrorFromSDK(v.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PurgeFeatureEntitiesResult.Error", err) + } + out.Error = conv168 + return out, nil +} + +// RequestSourceToSDK converts the mirror to the sdk-go type. +func RequestSourceToSDK(w *RequestSource) (*sdk.RequestSource, error) { + if w == nil { + return nil, nil + } + out := &sdk.RequestSource{} + { + var members []string + if w.FlatSchema != nil { + members = append(members, "flat_schema") + } + if w.DataframeSchema != nil { + members = append(members, "dataframe_schema") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.FlatSchema != nil: + conv169, err := FlatSchemaToSDK(w.FlatSchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RequestSource.Schema", err) + } + out.Schema = &sdk.RequestSource_Schema_FlatSchema{FlatSchema: *conv169} + case w.DataframeSchema != nil: + out.Schema = &sdk.RequestSource_Schema_DataframeSchema{DataframeSchema: *w.DataframeSchema} + } + return out, nil +} + +// RequestSourceFromSDK converts the sdk-go type to the mirror. +func RequestSourceFromSDK(v *sdk.RequestSource) (*RequestSource, error) { + if v == nil { + return nil, nil + } + out := &RequestSource{} + switch value := v.Schema.(type) { + case *sdk.RequestSource_Schema_FlatSchema: + if value != nil { + conv170, err := FlatSchemaFromSDK(&value.FlatSchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RequestSource.Schema", err) + } + out.FlatSchema = conv170 + } + case *sdk.RequestSource_Schema_DataframeSchema: + if value != nil { + out.DataframeSchema = new(value.DataframeSchema) + } + } + return out, nil +} + +// RollingWindowToSDK converts the mirror to the sdk-go type. +func RollingWindowToSDK(w *RollingWindow) (*sdk.RollingWindow, error) { + if w == nil { + return nil, nil + } + out := &sdk.RollingWindow{} + out.WindowDuration = w.WindowDuration + out.Delay = w.Delay + return out, nil +} + +// RollingWindowFromSDK converts the sdk-go type to the mirror. +func RollingWindowFromSDK(v *sdk.RollingWindow) (*RollingWindow, error) { + if v == nil { + return nil, nil + } + out := &RollingWindow{} + out.WindowDuration = v.WindowDuration + out.Delay = v.Delay + return out, nil +} + +// SawtoothWindowToSDK converts the mirror to the sdk-go type. +func SawtoothWindowToSDK(w *SawtoothWindow) (*sdk.SawtoothWindow, error) { + if w == nil { + return nil, nil + } + out := &sdk.SawtoothWindow{} + out.WindowDuration = w.WindowDuration + out.Delay = w.Delay + return out, nil +} + +// SawtoothWindowFromSDK converts the sdk-go type to the mirror. +func SawtoothWindowFromSDK(v *sdk.SawtoothWindow) (*SawtoothWindow, error) { + if v == nil { + return nil, nil + } + out := &SawtoothWindow{} + out.WindowDuration = v.WindowDuration + out.Delay = v.Delay + return out, nil +} + +// SchemaConfigToSDK converts the mirror to the sdk-go type. +func SchemaConfigToSDK(w *SchemaConfig) (*sdk.SchemaConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.SchemaConfig{} + { + var members []string + if w.JsonSchema != nil { + members = append(members, "json_schema") + } + if w.AvroSchema != nil { + members = append(members, "avro_schema") + } + if w.ProtoSchema != nil { + members = append(members, "proto_schema") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.JsonSchema != nil: + out.Schema = &sdk.SchemaConfig_Schema_JsonSchema{JsonSchema: *w.JsonSchema} + case w.AvroSchema != nil: + out.Schema = &sdk.SchemaConfig_Schema_AvroSchema{AvroSchema: *w.AvroSchema} + case w.ProtoSchema != nil: + conv171, err := ProtoSchemaSpecToSDK(w.ProtoSchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaConfig.Schema", err) + } + out.Schema = &sdk.SchemaConfig_Schema_ProtoSchema{ProtoSchema: *conv171} + } + return out, nil +} + +// SchemaConfigFromSDK converts the sdk-go type to the mirror. +func SchemaConfigFromSDK(v *sdk.SchemaConfig) (*SchemaConfig, error) { + if v == nil { + return nil, nil + } + out := &SchemaConfig{} + switch value := v.Schema.(type) { + case *sdk.SchemaConfig_Schema_JsonSchema: + if value != nil { + out.JsonSchema = new(value.JsonSchema) + } + case *sdk.SchemaConfig_Schema_AvroSchema: + if value != nil { + out.AvroSchema = new(value.AvroSchema) + } + case *sdk.SchemaConfig_Schema_ProtoSchema: + if value != nil { + conv172, err := ProtoSchemaSpecFromSDK(&value.ProtoSchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaConfig.Schema", err) + } + out.ProtoSchema = conv172 + } + } + return out, nil +} + +// SchemaLocatorToSDK converts the mirror to the sdk-go type. +func SchemaLocatorToSDK(w *SchemaLocator) (*sdk.SchemaLocator, error) { + if w == nil { + return nil, nil + } + out := &sdk.SchemaLocator{} + { + var members []string + if w.ConfluentSchema != nil { + members = append(members, "confluent_schema") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ConfluentSchema != nil: + conv173, err := SchemaLocator_ConfluentSchemaToSDK(w.ConfluentSchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaLocator.RegistrySchema", err) + } + out.RegistrySchema = &sdk.SchemaLocator_RegistrySchema_ConfluentSchema{ConfluentSchema: *conv173} + } + out.Format = w.Format + return out, nil +} + +// SchemaLocatorFromSDK converts the sdk-go type to the mirror. +func SchemaLocatorFromSDK(v *sdk.SchemaLocator) (*SchemaLocator, error) { + if v == nil { + return nil, nil + } + out := &SchemaLocator{} + switch value := v.RegistrySchema.(type) { + case *sdk.SchemaLocator_RegistrySchema_ConfluentSchema: + if value != nil { + conv174, err := SchemaLocator_ConfluentSchemaFromSDK(&value.ConfluentSchema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaLocator.RegistrySchema", err) + } + out.ConfluentSchema = conv174 + } + } + out.Format = v.Format + return out, nil +} + +// SchemaLocator_ConfluentSchemaToSDK converts the mirror to the sdk-go type. +func SchemaLocator_ConfluentSchemaToSDK(w *SchemaLocator_ConfluentSchema) (*sdk.SchemaLocator_ConfluentSchema, error) { + if w == nil { + return nil, nil + } + out := &sdk.SchemaLocator_ConfluentSchema{} + out.Subject = w.Subject + return out, nil +} + +// SchemaLocator_ConfluentSchemaFromSDK converts the sdk-go type to the mirror. +func SchemaLocator_ConfluentSchemaFromSDK(v *sdk.SchemaLocator_ConfluentSchema) (*SchemaLocator_ConfluentSchema, error) { + if v == nil { + return nil, nil + } + out := &SchemaLocator_ConfluentSchema{} + out.Subject = v.Subject + return out, nil +} + +// SchemaRegistryConfigToSDK converts the mirror to the sdk-go type. +func SchemaRegistryConfigToSDK(w *SchemaRegistryConfig) (*sdk.SchemaRegistryConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.SchemaRegistryConfig{} + out.UcConnection = w.UcConnection + conv175, err := SecretScopeReferenceToSDK(w.ApiSecretRef) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaRegistryConfig.ApiSecretRef", err) + } + out.ApiSecretRef = conv175 + conv176, err := SchemaLocatorToSDK(w.PayloadSchemaLocator) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaRegistryConfig.PayloadSchemaLocator", err) + } + out.PayloadSchemaLocator = conv176 + conv177, err := SchemaLocatorToSDK(w.KeySchemaLocator) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaRegistryConfig.KeySchemaLocator", err) + } + out.KeySchemaLocator = conv177 + return out, nil +} + +// SchemaRegistryConfigFromSDK converts the sdk-go type to the mirror. +func SchemaRegistryConfigFromSDK(v *sdk.SchemaRegistryConfig) (*SchemaRegistryConfig, error) { + if v == nil { + return nil, nil + } + out := &SchemaRegistryConfig{} + out.UcConnection = v.UcConnection + conv178, err := SecretScopeReferenceFromSDK(v.ApiSecretRef) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaRegistryConfig.ApiSecretRef", err) + } + out.ApiSecretRef = conv178 + conv179, err := SchemaLocatorFromSDK(v.PayloadSchemaLocator) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaRegistryConfig.PayloadSchemaLocator", err) + } + out.PayloadSchemaLocator = conv179 + conv180, err := SchemaLocatorFromSDK(v.KeySchemaLocator) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaRegistryConfig.KeySchemaLocator", err) + } + out.KeySchemaLocator = conv180 + return out, nil +} + +// SecretScopeReferenceToSDK converts the mirror to the sdk-go type. +func SecretScopeReferenceToSDK(w *SecretScopeReference) (*sdk.SecretScopeReference, error) { + if w == nil { + return nil, nil + } + out := &sdk.SecretScopeReference{} + out.Scope = w.Scope + out.Key = w.Key + return out, nil +} + +// SecretScopeReferenceFromSDK converts the sdk-go type to the mirror. +func SecretScopeReferenceFromSDK(v *sdk.SecretScopeReference) (*SecretScopeReference, error) { + if v == nil { + return nil, nil + } + out := &SecretScopeReference{} + out.Scope = v.Scope + out.Key = v.Key + return out, nil +} + +// SlidingWindowToSDK converts the mirror to the sdk-go type. +func SlidingWindowToSDK(w *SlidingWindow) (*sdk.SlidingWindow, error) { + if w == nil { + return nil, nil + } + out := &sdk.SlidingWindow{} + out.WindowDuration = w.WindowDuration + out.SlideDuration = w.SlideDuration + out.Delay = w.Delay + out.Offset = w.Offset + return out, nil +} + +// SlidingWindowFromSDK converts the sdk-go type to the mirror. +func SlidingWindowFromSDK(v *sdk.SlidingWindow) (*SlidingWindow, error) { + if v == nil { + return nil, nil + } + out := &SlidingWindow{} + out.WindowDuration = v.WindowDuration + out.SlideDuration = v.SlideDuration + out.Delay = v.Delay + out.Offset = v.Offset + return out, nil +} + +// SourceLatenessToSDK converts the mirror to the sdk-go type. +func SourceLatenessToSDK(w *SourceLateness) (*sdk.SourceLateness, error) { + if w == nil { + return nil, nil + } + out := &sdk.SourceLateness{} + out.SettlingDelay = w.SettlingDelay + return out, nil +} + +// SourceLatenessFromSDK converts the sdk-go type to the mirror. +func SourceLatenessFromSDK(v *sdk.SourceLateness) (*SourceLateness, error) { + if v == nil { + return nil, nil + } + out := &SourceLateness{} + out.SettlingDelay = v.SettlingDelay + return out, nil +} + +// StddevPopFunctionToSDK converts the mirror to the sdk-go type. +func StddevPopFunctionToSDK(w *StddevPopFunction) (*sdk.StddevPopFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.StddevPopFunction{} + out.Input = w.Input + return out, nil +} + +// StddevPopFunctionFromSDK converts the sdk-go type to the mirror. +func StddevPopFunctionFromSDK(v *sdk.StddevPopFunction) (*StddevPopFunction, error) { + if v == nil { + return nil, nil + } + out := &StddevPopFunction{} + out.Input = v.Input + return out, nil +} + +// StddevSampFunctionToSDK converts the mirror to the sdk-go type. +func StddevSampFunctionToSDK(w *StddevSampFunction) (*sdk.StddevSampFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.StddevSampFunction{} + out.Input = w.Input + return out, nil +} + +// StddevSampFunctionFromSDK converts the sdk-go type to the mirror. +func StddevSampFunctionFromSDK(v *sdk.StddevSampFunction) (*StddevSampFunction, error) { + if v == nil { + return nil, nil + } + out := &StddevSampFunction{} + out.Input = v.Input + return out, nil +} + +// StreamToSDK converts the mirror to the sdk-go type. +func StreamToSDK(w *Stream) (*sdk.Stream, error) { + if w == nil { + return nil, nil + } + out := &sdk.Stream{} + out.Name = w.Name + out.Description = w.Description + conv181, err := StreamSourceConfigToSDK(w.SourceConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Stream.SourceConfig", err) + } + out.SourceConfig = conv181 + conv182, err := StreamConnectionConfigToSDK(w.ConnectionConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Stream.ConnectionConfig", err) + } + out.ConnectionConfig = conv182 + conv183, err := StreamSchemaConfigToSDK(w.SchemaConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Stream.SchemaConfig", err) + } + out.SchemaConfig = conv183 + conv184, err := IngestionConfigToSDK(w.IngestionConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Stream.IngestionConfig", err) + } + out.IngestionConfig = conv184 + out.RecordTypeFilter = w.RecordTypeFilter + out.ExcludedColumns = w.ExcludedColumns + out.CreateTime = w.CreateTime + out.CreatedBy = w.CreatedBy + out.UpdateTime = w.UpdateTime + out.UpdatedBy = w.UpdatedBy + out.BrowseOnly = w.BrowseOnly + return out, nil +} + +// StreamFromSDK converts the sdk-go type to the mirror. +func StreamFromSDK(v *sdk.Stream) (*Stream, error) { + if v == nil { + return nil, nil + } + out := &Stream{} + out.Name = v.Name + out.Description = v.Description + conv185, err := StreamSourceConfigFromSDK(v.SourceConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Stream.SourceConfig", err) + } + out.SourceConfig = conv185 + conv186, err := StreamConnectionConfigFromSDK(v.ConnectionConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Stream.ConnectionConfig", err) + } + out.ConnectionConfig = conv186 + conv187, err := StreamSchemaConfigFromSDK(v.SchemaConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Stream.SchemaConfig", err) + } + out.SchemaConfig = conv187 + conv188, err := IngestionConfigFromSDK(v.IngestionConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Stream.IngestionConfig", err) + } + out.IngestionConfig = conv188 + out.RecordTypeFilter = v.RecordTypeFilter + out.ExcludedColumns = v.ExcludedColumns + out.CreateTime = v.CreateTime + out.CreatedBy = v.CreatedBy + out.UpdateTime = v.UpdateTime + out.UpdatedBy = v.UpdatedBy + out.BrowseOnly = v.BrowseOnly + return out, nil +} + +// StreamArnListToSDK converts the mirror to the sdk-go type. +func StreamArnListToSDK(w *StreamArnList) (*sdk.StreamArnList, error) { + if w == nil { + return nil, nil + } + out := &sdk.StreamArnList{} + out.Arns = w.Arns + return out, nil +} + +// StreamArnListFromSDK converts the sdk-go type to the mirror. +func StreamArnListFromSDK(v *sdk.StreamArnList) (*StreamArnList, error) { + if v == nil { + return nil, nil + } + out := &StreamArnList{} + out.Arns = v.Arns + return out, nil +} + +// StreamConnectionConfigToSDK converts the mirror to the sdk-go type. +func StreamConnectionConfigToSDK(w *StreamConnectionConfig) (*sdk.StreamConnectionConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.StreamConnectionConfig{} + { + var members []string + if w.UcConnectionName != nil { + members = append(members, "uc_connection_name") + } + if w.DirectMtlsConfig != nil { + members = append(members, "direct_mtls_config") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UcConnectionName != nil: + out.ConnectionConfig = &sdk.StreamConnectionConfig_ConnectionConfig_UcConnectionName{UcConnectionName: *w.UcConnectionName} + case w.DirectMtlsConfig != nil: + conv189, err := DirectMtlsConfigToSDK(w.DirectMtlsConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StreamConnectionConfig.ConnectionConfig", err) + } + out.ConnectionConfig = &sdk.StreamConnectionConfig_ConnectionConfig_DirectMtlsConfig{DirectMtlsConfig: *conv189} + } + return out, nil +} + +// StreamConnectionConfigFromSDK converts the sdk-go type to the mirror. +func StreamConnectionConfigFromSDK(v *sdk.StreamConnectionConfig) (*StreamConnectionConfig, error) { + if v == nil { + return nil, nil + } + out := &StreamConnectionConfig{} + switch value := v.ConnectionConfig.(type) { + case *sdk.StreamConnectionConfig_ConnectionConfig_UcConnectionName: + if value != nil { + out.UcConnectionName = new(value.UcConnectionName) + } + case *sdk.StreamConnectionConfig_ConnectionConfig_DirectMtlsConfig: + if value != nil { + conv190, err := DirectMtlsConfigFromSDK(&value.DirectMtlsConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StreamConnectionConfig.ConnectionConfig", err) + } + out.DirectMtlsConfig = conv190 + } + } + return out, nil +} + +// StreamNameListToSDK converts the mirror to the sdk-go type. +func StreamNameListToSDK(w *StreamNameList) (*sdk.StreamNameList, error) { + if w == nil { + return nil, nil + } + out := &sdk.StreamNameList{} + out.Names = w.Names + return out, nil +} + +// StreamNameListFromSDK converts the sdk-go type to the mirror. +func StreamNameListFromSDK(v *sdk.StreamNameList) (*StreamNameList, error) { + if v == nil { + return nil, nil + } + out := &StreamNameList{} + out.Names = v.Names + return out, nil +} + +// StreamSchemaConfigToSDK converts the mirror to the sdk-go type. +func StreamSchemaConfigToSDK(w *StreamSchemaConfig) (*sdk.StreamSchemaConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.StreamSchemaConfig{} + { + var members []string + if w.DirectSchemas != nil { + members = append(members, "direct_schemas") + } + if w.SchemaRegistryConfig != nil { + members = append(members, "schema_registry_config") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DirectSchemas != nil: + conv191, err := DirectSchemasToSDK(w.DirectSchemas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StreamSchemaConfig.SchemaConfig", err) + } + out.SchemaConfig = &sdk.StreamSchemaConfig_SchemaConfig_DirectSchemas{DirectSchemas: *conv191} + case w.SchemaRegistryConfig != nil: + conv192, err := SchemaRegistryConfigToSDK(w.SchemaRegistryConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StreamSchemaConfig.SchemaConfig", err) + } + out.SchemaConfig = &sdk.StreamSchemaConfig_SchemaConfig_SchemaRegistryConfig{SchemaRegistryConfig: *conv192} + } + return out, nil +} + +// StreamSchemaConfigFromSDK converts the sdk-go type to the mirror. +func StreamSchemaConfigFromSDK(v *sdk.StreamSchemaConfig) (*StreamSchemaConfig, error) { + if v == nil { + return nil, nil + } + out := &StreamSchemaConfig{} + switch value := v.SchemaConfig.(type) { + case *sdk.StreamSchemaConfig_SchemaConfig_DirectSchemas: + if value != nil { + conv193, err := DirectSchemasFromSDK(&value.DirectSchemas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StreamSchemaConfig.SchemaConfig", err) + } + out.DirectSchemas = conv193 + } + case *sdk.StreamSchemaConfig_SchemaConfig_SchemaRegistryConfig: + if value != nil { + conv194, err := SchemaRegistryConfigFromSDK(&value.SchemaRegistryConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StreamSchemaConfig.SchemaConfig", err) + } + out.SchemaRegistryConfig = conv194 + } + } + return out, nil +} + +// StreamSourceToSDK converts the mirror to the sdk-go type. +func StreamSourceToSDK(w *StreamSource) (*sdk.StreamSource, error) { + if w == nil { + return nil, nil + } + out := &sdk.StreamSource{} + out.FullName = w.FullName + out.FilterCondition = w.FilterCondition + out.TransformationSql = w.TransformationSql + out.DataframeSchema = w.DataframeSchema + return out, nil +} + +// StreamSourceFromSDK converts the sdk-go type to the mirror. +func StreamSourceFromSDK(v *sdk.StreamSource) (*StreamSource, error) { + if v == nil { + return nil, nil + } + out := &StreamSource{} + out.FullName = v.FullName + out.FilterCondition = v.FilterCondition + out.TransformationSql = v.TransformationSql + out.DataframeSchema = v.DataframeSchema + return out, nil +} + +// StreamSourceConfigToSDK converts the mirror to the sdk-go type. +func StreamSourceConfigToSDK(w *StreamSourceConfig) (*sdk.StreamSourceConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.StreamSourceConfig{} + { + var members []string + if w.KafkaStreamConfig != nil { + members = append(members, "kafka_stream_config") + } + if w.KinesisStreamConfig != nil { + members = append(members, "kinesis_stream_config") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.KafkaStreamConfig != nil: + conv195, err := KafkaStreamConfigToSDK(w.KafkaStreamConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StreamSourceConfig.SourceConfig", err) + } + out.SourceConfig = &sdk.StreamSourceConfig_SourceConfig_KafkaStreamConfig{KafkaStreamConfig: *conv195} + case w.KinesisStreamConfig != nil: + conv196, err := KinesisStreamConfigToSDK(w.KinesisStreamConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StreamSourceConfig.SourceConfig", err) + } + out.SourceConfig = &sdk.StreamSourceConfig_SourceConfig_KinesisStreamConfig{KinesisStreamConfig: *conv196} + } + return out, nil +} + +// StreamSourceConfigFromSDK converts the sdk-go type to the mirror. +func StreamSourceConfigFromSDK(v *sdk.StreamSourceConfig) (*StreamSourceConfig, error) { + if v == nil { + return nil, nil + } + out := &StreamSourceConfig{} + switch value := v.SourceConfig.(type) { + case *sdk.StreamSourceConfig_SourceConfig_KafkaStreamConfig: + if value != nil { + conv197, err := KafkaStreamConfigFromSDK(&value.KafkaStreamConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StreamSourceConfig.SourceConfig", err) + } + out.KafkaStreamConfig = conv197 + } + case *sdk.StreamSourceConfig_SourceConfig_KinesisStreamConfig: + if value != nil { + conv198, err := KinesisStreamConfigFromSDK(&value.KinesisStreamConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StreamSourceConfig.SourceConfig", err) + } + out.KinesisStreamConfig = conv198 + } + } + return out, nil +} + +// StreamingModeToSDK converts the mirror to the sdk-go type. +func StreamingModeToSDK(w *StreamingMode) (*sdk.StreamingMode, error) { + if w == nil { + return nil, nil + } + out := &sdk.StreamingMode{} + out.Mode = w.Mode + out.FreshnessTarget = w.FreshnessTarget + out.ShufflePartitions = w.ShufflePartitions + return out, nil +} + +// StreamingModeFromSDK converts the sdk-go type to the mirror. +func StreamingModeFromSDK(v *sdk.StreamingMode) (*StreamingMode, error) { + if v == nil { + return nil, nil + } + out := &StreamingMode{} + out.Mode = v.Mode + out.FreshnessTarget = v.FreshnessTarget + out.ShufflePartitions = v.ShufflePartitions + return out, nil +} + +// SubscriptionModeToSDK converts the mirror to the sdk-go type. +func SubscriptionModeToSDK(w *SubscriptionMode) (*sdk.SubscriptionMode, error) { + if w == nil { + return nil, nil + } + out := &sdk.SubscriptionMode{} + { + var members []string + if w.Assign != nil { + members = append(members, "assign") + } + if w.Subscribe != nil { + members = append(members, "subscribe") + } + if w.SubscribePattern != nil { + members = append(members, "subscribe_pattern") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Assign != nil: + out.SubscriptionMode = &sdk.SubscriptionMode_SubscriptionMode_Assign{Assign: *w.Assign} + case w.Subscribe != nil: + out.SubscriptionMode = &sdk.SubscriptionMode_SubscriptionMode_Subscribe{Subscribe: *w.Subscribe} + case w.SubscribePattern != nil: + out.SubscriptionMode = &sdk.SubscriptionMode_SubscriptionMode_SubscribePattern{SubscribePattern: *w.SubscribePattern} + } + return out, nil +} + +// SubscriptionModeFromSDK converts the sdk-go type to the mirror. +func SubscriptionModeFromSDK(v *sdk.SubscriptionMode) (*SubscriptionMode, error) { + if v == nil { + return nil, nil + } + out := &SubscriptionMode{} + switch value := v.SubscriptionMode.(type) { + case *sdk.SubscriptionMode_SubscriptionMode_Assign: + if value != nil { + out.Assign = new(value.Assign) + } + case *sdk.SubscriptionMode_SubscriptionMode_Subscribe: + if value != nil { + out.Subscribe = new(value.Subscribe) + } + case *sdk.SubscriptionMode_SubscriptionMode_SubscribePattern: + if value != nil { + out.SubscribePattern = new(value.SubscribePattern) + } + } + return out, nil +} + +// SumFunctionToSDK converts the mirror to the sdk-go type. +func SumFunctionToSDK(w *SumFunction) (*sdk.SumFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.SumFunction{} + out.Input = w.Input + return out, nil +} + +// SumFunctionFromSDK converts the sdk-go type to the mirror. +func SumFunctionFromSDK(v *sdk.SumFunction) (*SumFunction, error) { + if v == nil { + return nil, nil + } + out := &SumFunction{} + out.Input = v.Input + return out, nil +} + +// TableTriggerToSDK converts the mirror to the sdk-go type. +func TableTriggerToSDK(w *TableTrigger) (*sdk.TableTrigger, error) { + if w == nil { + return nil, nil + } + out := &sdk.TableTrigger{} + return out, nil +} + +// TableTriggerFromSDK converts the sdk-go type to the mirror. +func TableTriggerFromSDK(v *sdk.TableTrigger) (*TableTrigger, error) { + if v == nil { + return nil, nil + } + out := &TableTrigger{} + return out, nil +} + +// TimeWindowToSDK converts the mirror to the sdk-go type. +func TimeWindowToSDK(w *TimeWindow) (*sdk.TimeWindow, error) { + if w == nil { + return nil, nil + } + out := &sdk.TimeWindow{} + { + var members []string + if w.Continuous != nil { + members = append(members, "continuous") + } + if w.Tumbling != nil { + members = append(members, "tumbling") + } + if w.Sliding != nil { + members = append(members, "sliding") + } + if w.Rolling != nil { + members = append(members, "rolling") + } + if w.Sawtooth != nil { + members = append(members, "sawtooth") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Continuous != nil: + conv199, err := ContinuousWindowToSDK(w.Continuous) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TimeWindow.WindowType", err) + } + out.WindowType = &sdk.TimeWindow_WindowType_Continuous{Continuous: *conv199} + case w.Tumbling != nil: + conv200, err := TumblingWindowToSDK(w.Tumbling) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TimeWindow.WindowType", err) + } + out.WindowType = &sdk.TimeWindow_WindowType_Tumbling{Tumbling: *conv200} + case w.Sliding != nil: + conv201, err := SlidingWindowToSDK(w.Sliding) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TimeWindow.WindowType", err) + } + out.WindowType = &sdk.TimeWindow_WindowType_Sliding{Sliding: *conv201} + case w.Rolling != nil: + conv202, err := RollingWindowToSDK(w.Rolling) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TimeWindow.WindowType", err) + } + out.WindowType = &sdk.TimeWindow_WindowType_Rolling{Rolling: *conv202} + case w.Sawtooth != nil: + conv203, err := SawtoothWindowToSDK(w.Sawtooth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TimeWindow.WindowType", err) + } + out.WindowType = &sdk.TimeWindow_WindowType_Sawtooth{Sawtooth: *conv203} + } + out.StartTime = w.StartTime + return out, nil +} + +// TimeWindowFromSDK converts the sdk-go type to the mirror. +func TimeWindowFromSDK(v *sdk.TimeWindow) (*TimeWindow, error) { + if v == nil { + return nil, nil + } + out := &TimeWindow{} + switch value := v.WindowType.(type) { + case *sdk.TimeWindow_WindowType_Continuous: + if value != nil { + conv204, err := ContinuousWindowFromSDK(&value.Continuous) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TimeWindow.WindowType", err) + } + out.Continuous = conv204 + } + case *sdk.TimeWindow_WindowType_Tumbling: + if value != nil { + conv205, err := TumblingWindowFromSDK(&value.Tumbling) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TimeWindow.WindowType", err) + } + out.Tumbling = conv205 + } + case *sdk.TimeWindow_WindowType_Sliding: + if value != nil { + conv206, err := SlidingWindowFromSDK(&value.Sliding) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TimeWindow.WindowType", err) + } + out.Sliding = conv206 + } + case *sdk.TimeWindow_WindowType_Rolling: + if value != nil { + conv207, err := RollingWindowFromSDK(&value.Rolling) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TimeWindow.WindowType", err) + } + out.Rolling = conv207 + } + case *sdk.TimeWindow_WindowType_Sawtooth: + if value != nil { + conv208, err := SawtoothWindowFromSDK(&value.Sawtooth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TimeWindow.WindowType", err) + } + out.Sawtooth = conv208 + } + } + out.StartTime = v.StartTime + return out, nil +} + +// TimeseriesColumnToSDK converts the mirror to the sdk-go type. +func TimeseriesColumnToSDK(w *TimeseriesColumn) (*sdk.TimeseriesColumn, error) { + if w == nil { + return nil, nil + } + out := &sdk.TimeseriesColumn{} + out.Name = w.Name + return out, nil +} + +// TimeseriesColumnFromSDK converts the sdk-go type to the mirror. +func TimeseriesColumnFromSDK(v *sdk.TimeseriesColumn) (*TimeseriesColumn, error) { + if v == nil { + return nil, nil + } + out := &TimeseriesColumn{} + out.Name = v.Name + return out, nil +} + +// TumblingWindowToSDK converts the mirror to the sdk-go type. +func TumblingWindowToSDK(w *TumblingWindow) (*sdk.TumblingWindow, error) { + if w == nil { + return nil, nil + } + out := &sdk.TumblingWindow{} + out.WindowDuration = w.WindowDuration + out.Delay = w.Delay + out.Offset = w.Offset + return out, nil +} + +// TumblingWindowFromSDK converts the sdk-go type to the mirror. +func TumblingWindowFromSDK(v *sdk.TumblingWindow) (*TumblingWindow, error) { + if v == nil { + return nil, nil + } + out := &TumblingWindow{} + out.WindowDuration = v.WindowDuration + out.Delay = v.Delay + out.Offset = v.Offset + return out, nil +} + +// UpdateFeatureRequestToSDK converts the mirror to the sdk-go type. +func UpdateFeatureRequestToSDK(w *UpdateFeatureRequest) (*sdk.UpdateFeatureRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateFeatureRequest{} + conv209, err := FeatureToSDK(w.Feature) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateFeatureRequest.Feature", err) + } + out.Feature = conv209 + mask210, err := fieldMaskFromString[sdk.Feature](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateFeatureRequest.UpdateMask", err) + } + out.UpdateMask = mask210 + return out, nil +} + +// UpdateFeatureRequestFromSDK converts the sdk-go type to the mirror. +func UpdateFeatureRequestFromSDK(v *sdk.UpdateFeatureRequest) (*UpdateFeatureRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateFeatureRequest{} + conv211, err := FeatureFromSDK(v.Feature) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateFeatureRequest.Feature", err) + } + out.Feature = conv211 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateKafkaConfigRequestToSDK converts the mirror to the sdk-go type. +func UpdateKafkaConfigRequestToSDK(w *UpdateKafkaConfigRequest) (*sdk.UpdateKafkaConfigRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateKafkaConfigRequest{} + conv212, err := KafkaConfigToSDK(w.KafkaConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateKafkaConfigRequest.KafkaConfig", err) + } + out.KafkaConfig = conv212 + mask213, err := fieldMaskFromString[sdk.KafkaConfig](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateKafkaConfigRequest.UpdateMask", err) + } + out.UpdateMask = mask213 + return out, nil +} + +// UpdateKafkaConfigRequestFromSDK converts the sdk-go type to the mirror. +func UpdateKafkaConfigRequestFromSDK(v *sdk.UpdateKafkaConfigRequest) (*UpdateKafkaConfigRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateKafkaConfigRequest{} + conv214, err := KafkaConfigFromSDK(v.KafkaConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateKafkaConfigRequest.KafkaConfig", err) + } + out.KafkaConfig = conv214 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateMaterializedFeatureRequestToSDK converts the mirror to the sdk-go type. +func UpdateMaterializedFeatureRequestToSDK(w *UpdateMaterializedFeatureRequest) (*sdk.UpdateMaterializedFeatureRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateMaterializedFeatureRequest{} + conv215, err := MaterializedFeatureToSDK(w.MaterializedFeature) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateMaterializedFeatureRequest.MaterializedFeature", err) + } + out.MaterializedFeature = conv215 + mask216, err := fieldMaskFromString[sdk.MaterializedFeature](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateMaterializedFeatureRequest.UpdateMask", err) + } + out.UpdateMask = mask216 + return out, nil +} + +// UpdateMaterializedFeatureRequestFromSDK converts the sdk-go type to the mirror. +func UpdateMaterializedFeatureRequestFromSDK(v *sdk.UpdateMaterializedFeatureRequest) (*UpdateMaterializedFeatureRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateMaterializedFeatureRequest{} + conv217, err := MaterializedFeatureFromSDK(v.MaterializedFeature) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateMaterializedFeatureRequest.MaterializedFeature", err) + } + out.MaterializedFeature = conv217 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateStreamRequestToSDK converts the mirror to the sdk-go type. +func UpdateStreamRequestToSDK(w *UpdateStreamRequest) (*sdk.UpdateStreamRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateStreamRequest{} + conv218, err := StreamToSDK(w.Stream) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStreamRequest.Stream", err) + } + out.Stream = conv218 + mask219, err := fieldMaskFromString[sdk.Stream](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStreamRequest.UpdateMask", err) + } + out.UpdateMask = mask219 + return out, nil +} + +// UpdateStreamRequestFromSDK converts the sdk-go type to the mirror. +func UpdateStreamRequestFromSDK(v *sdk.UpdateStreamRequest) (*UpdateStreamRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateStreamRequest{} + conv220, err := StreamFromSDK(v.Stream) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStreamRequest.Stream", err) + } + out.Stream = conv220 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// VarPopFunctionToSDK converts the mirror to the sdk-go type. +func VarPopFunctionToSDK(w *VarPopFunction) (*sdk.VarPopFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.VarPopFunction{} + out.Input = w.Input + return out, nil +} + +// VarPopFunctionFromSDK converts the sdk-go type to the mirror. +func VarPopFunctionFromSDK(v *sdk.VarPopFunction) (*VarPopFunction, error) { + if v == nil { + return nil, nil + } + out := &VarPopFunction{} + out.Input = v.Input + return out, nil +} + +// VarSampFunctionToSDK converts the mirror to the sdk-go type. +func VarSampFunctionToSDK(w *VarSampFunction) (*sdk.VarSampFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.VarSampFunction{} + out.Input = w.Input + return out, nil +} + +// VarSampFunctionFromSDK converts the sdk-go type to the mirror. +func VarSampFunctionFromSDK(v *sdk.VarSampFunction) (*VarSampFunction, error) { + if v == nil { + return nil, nil + } + out := &VarSampFunction{} + out.Input = v.Input + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/featurestore/v1/types.generated.go b/libs/sdktypes/featurestore/v1/types.generated.go new file mode 100644 index 00000000000..b1c5f10c3d5 --- /dev/null +++ b/libs/sdktypes/featurestore/v1/types.generated.go @@ -0,0 +1,378 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/featurestore/v1. DO NOT EDIT. + +package featurestore + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/featurestore/v1" + strings "strings" +) + +type ( + OnlineStore_State = sdk.OnlineStore_State + PublishSpec_PublishMode = sdk.PublishSpec_PublishMode +) + +const ( + OnlineStore_State_Unspecified = sdk.OnlineStore_State_Unspecified + OnlineStore_State_Starting = sdk.OnlineStore_State_Starting + OnlineStore_State_Available = sdk.OnlineStore_State_Available + OnlineStore_State_Deleting = sdk.OnlineStore_State_Deleting + OnlineStore_State_Stopped = sdk.OnlineStore_State_Stopped + OnlineStore_State_Updating = sdk.OnlineStore_State_Updating + OnlineStore_State_FailingOver = sdk.OnlineStore_State_FailingOver + PublishSpec_PublishMode_Unspecified = sdk.PublishSpec_PublishMode_Unspecified + PublishSpec_PublishMode_Continuous = sdk.PublishSpec_PublishMode_Continuous + PublishSpec_PublishMode_Triggered = sdk.PublishSpec_PublishMode_Triggered + PublishSpec_PublishMode_Snapshot = sdk.PublishSpec_PublishMode_Snapshot +) + +type CreateOnlineStoreRequest struct { + // Online store to create. + OnlineStore *OnlineStore `json:"online_store,omitempty"` +} + +type ListOnlineStoresRequest struct { + // The maximum number of results to return. Defaults to 100 if not specified. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page based on a previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListOnlineStoresResponse struct { + // Pagination token to request the next page of results for this query. + NextPageToken *string `json:"next_page_token,omitempty"` + // List of online stores. + OnlineStores []OnlineStore `json:"online_stores,omitempty"` +} + +// An OnlineStore is a logical database instance that stores and serves features +// online.. +type OnlineStore struct { + // The capacity of the online store. Valid values are "CU_1", "CU_2", "CU_4", + // "CU_8". + Capacity *string `json:"capacity,omitempty"` + // The timestamp when the online store was created. + CreationTime *types.Time `json:"creation_time,omitempty"` + // The email of the creator of the online store. + Creator *string `json:"creator,omitempty"` + // The name of the online store. This is the unique identifier for the online + // store. + Name *string `json:"name,omitempty"` + // The number of read replicas for the online store. Defaults to 0. + ReadReplicaCount *int `json:"read_replica_count,omitempty"` + // The current state of the online store. + State OnlineStore_State `json:"state,omitempty"` + // The usage policy applied to the online store to track billing. + UsagePolicyId *string `json:"usage_policy_id,omitempty"` +} + +type PublishSpec struct { + // Budget policy id used to attribute the serverless compute cost of the synced + // online-table sync pipeline. Applied only when the sync pipeline is first + // created (the initial publish of a new online table); republishing to an + // existing online table does not update it. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // Full Unity Catalog name of one of the features materialized in the source + // table, used to derive the synced online table's entity and timeseries + // columns. Required for view sources without a UC PrimaryKeyConstraint; ignored + // when the source already has one. + FullFeatureName *string `json:"full_feature_name,omitempty"` + // The name of the target online store. + OnlineStore *string `json:"online_store,omitempty"` + // The full three-part (catalog, schema, table) name of the online table. + OnlineTableName *string `json:"online_table_name,omitempty"` + // The publish mode of the pipeline that syncs the online table with the source + // table. + PublishMode PublishSpec_PublishMode `json:"publish_mode,omitempty"` + // Custom tags to apply to the synced online-table sync pipeline created for + // this publish. They are forwarded to the pipeline's compute as cluster tags so + // its cost can be attributed in the billing system tables. Applied only when + // the sync pipeline is first created (the initial publish of a new online + // table); republishing to an existing online table does not update them. + Tags map[string]string `json:"tags,omitempty"` +} + +type PublishTableRequest struct { + // The specification for publishing the online table from the source table. + PublishSpec *PublishSpec `json:"publish_spec,omitempty"` + // The full three-part (catalog, schema, table) name of the source table. + SourceTableName *string `json:"source_table_name,omitempty"` +} + +type PublishTableResponse struct { + // The full three-part (catalog, schema, table) name of the online table. + OnlineTableName *string `json:"online_table_name,omitempty"` + // The ID of the pipeline that syncs the online table with the source table. + PipelineId *string `json:"pipeline_id,omitempty"` +} + +type UpdateOnlineStoreRequest struct { + // Online store to update. + OnlineStore *OnlineStore `json:"online_store,omitempty"` + // The list of fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CreateOnlineStoreRequestToSDK converts the mirror to the sdk-go type. +func CreateOnlineStoreRequestToSDK(w *CreateOnlineStoreRequest) (*sdk.CreateOnlineStoreRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateOnlineStoreRequest{} + conv1, err := OnlineStoreToSDK(w.OnlineStore) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateOnlineStoreRequest.OnlineStore", err) + } + out.OnlineStore = conv1 + return out, nil +} + +// CreateOnlineStoreRequestFromSDK converts the sdk-go type to the mirror. +func CreateOnlineStoreRequestFromSDK(v *sdk.CreateOnlineStoreRequest) (*CreateOnlineStoreRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateOnlineStoreRequest{} + conv2, err := OnlineStoreFromSDK(v.OnlineStore) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateOnlineStoreRequest.OnlineStore", err) + } + out.OnlineStore = conv2 + return out, nil +} + +// ListOnlineStoresRequestToSDK converts the mirror to the sdk-go type. +func ListOnlineStoresRequestToSDK(w *ListOnlineStoresRequest) (*sdk.ListOnlineStoresRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListOnlineStoresRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListOnlineStoresRequestFromSDK converts the sdk-go type to the mirror. +func ListOnlineStoresRequestFromSDK(v *sdk.ListOnlineStoresRequest) (*ListOnlineStoresRequest, error) { + if v == nil { + return nil, nil + } + out := &ListOnlineStoresRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListOnlineStoresResponseToSDK converts the mirror to the sdk-go type. +func ListOnlineStoresResponseToSDK(w *ListOnlineStoresResponse) (*sdk.ListOnlineStoresResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListOnlineStoresResponse{} + conv3, err := convertSlice(w.OnlineStores, OnlineStoreToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListOnlineStoresResponse.OnlineStores", err) + } + out.OnlineStores = conv3 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListOnlineStoresResponseFromSDK converts the sdk-go type to the mirror. +func ListOnlineStoresResponseFromSDK(v *sdk.ListOnlineStoresResponse) (*ListOnlineStoresResponse, error) { + if v == nil { + return nil, nil + } + out := &ListOnlineStoresResponse{} + conv4, err := convertSlice(v.OnlineStores, OnlineStoreFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListOnlineStoresResponse.OnlineStores", err) + } + out.OnlineStores = conv4 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// OnlineStoreToSDK converts the mirror to the sdk-go type. +func OnlineStoreToSDK(w *OnlineStore) (*sdk.OnlineStore, error) { + if w == nil { + return nil, nil + } + out := &sdk.OnlineStore{} + out.Name = w.Name + out.Creator = w.Creator + out.CreationTime = w.CreationTime + out.State = w.State + out.Capacity = w.Capacity + out.ReadReplicaCount = w.ReadReplicaCount + out.UsagePolicyId = w.UsagePolicyId + return out, nil +} + +// OnlineStoreFromSDK converts the sdk-go type to the mirror. +func OnlineStoreFromSDK(v *sdk.OnlineStore) (*OnlineStore, error) { + if v == nil { + return nil, nil + } + out := &OnlineStore{} + out.Name = v.Name + out.Creator = v.Creator + out.CreationTime = v.CreationTime + out.State = v.State + out.Capacity = v.Capacity + out.ReadReplicaCount = v.ReadReplicaCount + out.UsagePolicyId = v.UsagePolicyId + return out, nil +} + +// PublishSpecToSDK converts the mirror to the sdk-go type. +func PublishSpecToSDK(w *PublishSpec) (*sdk.PublishSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.PublishSpec{} + out.OnlineStore = w.OnlineStore + out.OnlineTableName = w.OnlineTableName + out.PublishMode = w.PublishMode + out.FullFeatureName = w.FullFeatureName + out.Tags = w.Tags + out.BudgetPolicyId = w.BudgetPolicyId + return out, nil +} + +// PublishSpecFromSDK converts the sdk-go type to the mirror. +func PublishSpecFromSDK(v *sdk.PublishSpec) (*PublishSpec, error) { + if v == nil { + return nil, nil + } + out := &PublishSpec{} + out.OnlineStore = v.OnlineStore + out.OnlineTableName = v.OnlineTableName + out.PublishMode = v.PublishMode + out.FullFeatureName = v.FullFeatureName + out.Tags = v.Tags + out.BudgetPolicyId = v.BudgetPolicyId + return out, nil +} + +// PublishTableRequestToSDK converts the mirror to the sdk-go type. +func PublishTableRequestToSDK(w *PublishTableRequest) (*sdk.PublishTableRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PublishTableRequest{} + out.SourceTableName = w.SourceTableName + conv5, err := PublishSpecToSDK(w.PublishSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PublishTableRequest.PublishSpec", err) + } + out.PublishSpec = conv5 + return out, nil +} + +// PublishTableRequestFromSDK converts the sdk-go type to the mirror. +func PublishTableRequestFromSDK(v *sdk.PublishTableRequest) (*PublishTableRequest, error) { + if v == nil { + return nil, nil + } + out := &PublishTableRequest{} + out.SourceTableName = v.SourceTableName + conv6, err := PublishSpecFromSDK(v.PublishSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PublishTableRequest.PublishSpec", err) + } + out.PublishSpec = conv6 + return out, nil +} + +// PublishTableResponseToSDK converts the mirror to the sdk-go type. +func PublishTableResponseToSDK(w *PublishTableResponse) (*sdk.PublishTableResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.PublishTableResponse{} + out.OnlineTableName = w.OnlineTableName + out.PipelineId = w.PipelineId + return out, nil +} + +// PublishTableResponseFromSDK converts the sdk-go type to the mirror. +func PublishTableResponseFromSDK(v *sdk.PublishTableResponse) (*PublishTableResponse, error) { + if v == nil { + return nil, nil + } + out := &PublishTableResponse{} + out.OnlineTableName = v.OnlineTableName + out.PipelineId = v.PipelineId + return out, nil +} + +// UpdateOnlineStoreRequestToSDK converts the mirror to the sdk-go type. +func UpdateOnlineStoreRequestToSDK(w *UpdateOnlineStoreRequest) (*sdk.UpdateOnlineStoreRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateOnlineStoreRequest{} + conv7, err := OnlineStoreToSDK(w.OnlineStore) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateOnlineStoreRequest.OnlineStore", err) + } + out.OnlineStore = conv7 + mask8, err := fieldMaskFromString[sdk.OnlineStore](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateOnlineStoreRequest.UpdateMask", err) + } + out.UpdateMask = mask8 + return out, nil +} + +// UpdateOnlineStoreRequestFromSDK converts the sdk-go type to the mirror. +func UpdateOnlineStoreRequestFromSDK(v *sdk.UpdateOnlineStoreRequest) (*UpdateOnlineStoreRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateOnlineStoreRequest{} + conv9, err := OnlineStoreFromSDK(v.OnlineStore) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateOnlineStoreRequest.OnlineStore", err) + } + out.OnlineStore = conv9 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/files/v2/types.generated.go b/libs/sdktypes/files/v2/types.generated.go new file mode 100644 index 00000000000..2e5b033752b --- /dev/null +++ b/libs/sdktypes/files/v2/types.generated.go @@ -0,0 +1,635 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/files/v2. DO NOT EDIT. + +package files + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/files/v2" +) + +type AddBlockRequest struct { + // The base64-encoded data to append to the stream. This has a limit of 1 MB. + Data []byte `json:"data,omitempty"` + // The handle on an open stream. + Handle *int64 `json:"handle,omitempty"` +} + +type CloseRequest struct { + // The handle on an open stream. + Handle *int64 `json:"handle,omitempty"` +} + +type CreateRequest struct { + // The flag that specifies whether to overwrite existing file/files. + Overwrite *bool `json:"overwrite,omitempty"` + // The path of the new file. The path should be the absolute DBFS path. + Path *string `json:"path,omitempty"` +} + +type CreateResponse struct { + // Handle which should subsequently be passed into the AddBlock and Close calls + // when writing to a file through a stream. + Handle *int64 `json:"handle,omitempty"` +} + +type DeleteRequest struct { + // The path of the file or directory to delete. The path should be the absolute + // DBFS path. + Path *string `json:"path,omitempty"` + // Whether or not to recursively delete the directory's contents. Deleting empty + // directories can be done without providing the recursive flag. + Recursive *bool `json:"recursive,omitempty"` +} + +type DirectoryEntry struct { + // The length of the file in bytes. This field is omitted for directories. + FileSize *int `json:"file_size,omitempty"` + // True if the path is a directory. + IsDirectory *bool `json:"is_directory,omitempty"` + // Last modification time of given file in milliseconds since unix epoch. + LastModified *int `json:"last_modified,omitempty"` + // The name of the file or directory. This is the last component of the path. + Name *string `json:"name,omitempty"` + // The absolute path of the file or directory. + Path *string `json:"path,omitempty"` +} + +// Stores the attributes of a file or directory.. +type FileInfo struct { + // The length of the file in bytes. Set to 0 for directories. + FileSize *int64 `json:"file_size,omitempty"` + // True if the path is a directory. + IsDir *bool `json:"is_dir,omitempty"` + // Last modification time of given file in milliseconds since epoch. + ModificationTime *int64 `json:"modification_time,omitempty"` + // The absolute path of the file or directory. + Path *string `json:"path,omitempty"` +} + +type GetStatusRequest struct { + // The path of the file or directory. The path should be the absolute DBFS path. + Path *string `json:"path,omitempty"` +} + +type GetStatusResponse struct { + // The length of the file in bytes. Set to 0 for directories. + FileSize *int64 `json:"file_size,omitempty"` + // True if the path is a directory. + IsDir *bool `json:"is_dir,omitempty"` + // Last modification time of given file in milliseconds since epoch. + ModificationTime *int64 `json:"modification_time,omitempty"` + // The absolute path of the file or directory. + Path *string `json:"path,omitempty"` +} + +// List directory contents. +type ListDirectoryContentsRequest struct { + // The absolute path of a directory. + DirectoryPath *string `json:"directory_path,omitempty"` + // The maximum number of directory entries to return. The response may contain + // fewer entries. If the response contains a `next_page_token`, there may be + // more entries, even if fewer than `page_size` entries are in the response. + // + // We recommend not to set this value unless you are intentionally listing less + // than the complete directory contents. + // + // If unspecified, at most 1000 directory entries will be returned. The maximum + // value is 1000. Values above 1000 will be coerced to 1000. + PageSize *int64 `json:"page_size,omitempty"` + // An opaque page token which was the `next_page_token` in the response of the + // previous request to list the contents of this directory. Provide this token + // to retrieve the next page of directory entries. When providing a + // `page_token`, all other parameters provided to the request must match the + // previous request. To list all of the entries in a directory, it is necessary + // to continue requesting pages of entries until the response contains no + // `next_page_token`. Note that the number of entries returned must not be used + // to determine when the listing is complete. + PageToken *string `json:"page_token,omitempty"` +} + +type ListDirectoryResponse struct { + // Array of DirectoryEntry. + Contents []DirectoryEntry `json:"contents,omitempty"` + // A token, which can be sent as `page_token` to retrieve the next page. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListStatusRequest struct { + // The path of the file or directory. The path should be the absolute DBFS path. + Path *string `json:"path,omitempty"` +} + +type ListStatusResponse struct { + // A list of FileInfo's that describe contents of directory or file. See example + // above. + Files []FileInfo `json:"files,omitempty"` +} + +type MkDirsRequest struct { + // The path of the new directory. The path should be the absolute DBFS path. + Path *string `json:"path,omitempty"` +} + +type MoveRequest struct { + // The destination path of the file or directory. The path should be the + // absolute DBFS path. + DestinationPath *string `json:"destination_path,omitempty"` + // The source path of the file or directory. The path should be the absolute + // DBFS path. + SourcePath *string `json:"source_path,omitempty"` +} + +type PutRequest struct { + // This parameter might be absent, and instead a posted file will be used. + Contents []byte `json:"contents,omitempty"` + // The flag that specifies whether to overwrite existing file/files. + Overwrite *bool `json:"overwrite,omitempty"` + // The path of the new file. The path should be the absolute DBFS path. + Path *string `json:"path,omitempty"` +} + +type ReadRequest struct { + // The number of bytes to read starting from the offset. This has a limit of 1 + // MB, and a default value of 0.5 MB. + Length *int64 `json:"length,omitempty"` + // The offset to read from in bytes. + Offset *int64 `json:"offset,omitempty"` + // The path of the file to read. The path should be the absolute DBFS path. + Path *string `json:"path,omitempty"` +} + +type ReadResponse struct { + // The number of bytes read (could be less than ``length`` if we hit end of + // file). This refers to number of bytes read in unencoded version (response + // data is base64-encoded). + BytesRead *int64 `json:"bytes_read,omitempty"` + // The base64-encoded contents of the file read. + Data []byte `json:"data,omitempty"` +} + +// Upload a file. +type UploadFileRequest struct { + // The absolute path of the file. + FilePath *string `json:"file_path,omitempty"` + // If true or unspecified, an existing file will be overwritten. If false, an + // error will be returned if the path points to an existing file. + Overwrite *bool `json:"overwrite,omitempty"` +} + +// AddBlockRequestToSDK converts the mirror to the sdk-go type. +func AddBlockRequestToSDK(w *AddBlockRequest) (*sdk.AddBlockRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AddBlockRequest{} + out.Handle = w.Handle + out.Data = w.Data + return out, nil +} + +// AddBlockRequestFromSDK converts the sdk-go type to the mirror. +func AddBlockRequestFromSDK(v *sdk.AddBlockRequest) (*AddBlockRequest, error) { + if v == nil { + return nil, nil + } + out := &AddBlockRequest{} + out.Handle = v.Handle + out.Data = v.Data + return out, nil +} + +// CloseRequestToSDK converts the mirror to the sdk-go type. +func CloseRequestToSDK(w *CloseRequest) (*sdk.CloseRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CloseRequest{} + out.Handle = w.Handle + return out, nil +} + +// CloseRequestFromSDK converts the sdk-go type to the mirror. +func CloseRequestFromSDK(v *sdk.CloseRequest) (*CloseRequest, error) { + if v == nil { + return nil, nil + } + out := &CloseRequest{} + out.Handle = v.Handle + return out, nil +} + +// CreateRequestToSDK converts the mirror to the sdk-go type. +func CreateRequestToSDK(w *CreateRequest) (*sdk.CreateRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRequest{} + out.Path = w.Path + out.Overwrite = w.Overwrite + return out, nil +} + +// CreateRequestFromSDK converts the sdk-go type to the mirror. +func CreateRequestFromSDK(v *sdk.CreateRequest) (*CreateRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateRequest{} + out.Path = v.Path + out.Overwrite = v.Overwrite + return out, nil +} + +// CreateResponseToSDK converts the mirror to the sdk-go type. +func CreateResponseToSDK(w *CreateResponse) (*sdk.CreateResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateResponse{} + out.Handle = w.Handle + return out, nil +} + +// CreateResponseFromSDK converts the sdk-go type to the mirror. +func CreateResponseFromSDK(v *sdk.CreateResponse) (*CreateResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateResponse{} + out.Handle = v.Handle + return out, nil +} + +// DeleteRequestToSDK converts the mirror to the sdk-go type. +func DeleteRequestToSDK(w *DeleteRequest) (*sdk.DeleteRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteRequest{} + out.Path = w.Path + out.Recursive = w.Recursive + return out, nil +} + +// DeleteRequestFromSDK converts the sdk-go type to the mirror. +func DeleteRequestFromSDK(v *sdk.DeleteRequest) (*DeleteRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteRequest{} + out.Path = v.Path + out.Recursive = v.Recursive + return out, nil +} + +// DirectoryEntryToSDK converts the mirror to the sdk-go type. +func DirectoryEntryToSDK(w *DirectoryEntry) (*sdk.DirectoryEntry, error) { + if w == nil { + return nil, nil + } + out := &sdk.DirectoryEntry{} + out.FileSize = w.FileSize + out.IsDirectory = w.IsDirectory + out.LastModified = w.LastModified + out.Name = w.Name + out.Path = w.Path + return out, nil +} + +// DirectoryEntryFromSDK converts the sdk-go type to the mirror. +func DirectoryEntryFromSDK(v *sdk.DirectoryEntry) (*DirectoryEntry, error) { + if v == nil { + return nil, nil + } + out := &DirectoryEntry{} + out.FileSize = v.FileSize + out.IsDirectory = v.IsDirectory + out.LastModified = v.LastModified + out.Name = v.Name + out.Path = v.Path + return out, nil +} + +// FileInfoToSDK converts the mirror to the sdk-go type. +func FileInfoToSDK(w *FileInfo) (*sdk.FileInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.FileInfo{} + out.Path = w.Path + out.IsDir = w.IsDir + out.FileSize = w.FileSize + out.ModificationTime = w.ModificationTime + return out, nil +} + +// FileInfoFromSDK converts the sdk-go type to the mirror. +func FileInfoFromSDK(v *sdk.FileInfo) (*FileInfo, error) { + if v == nil { + return nil, nil + } + out := &FileInfo{} + out.Path = v.Path + out.IsDir = v.IsDir + out.FileSize = v.FileSize + out.ModificationTime = v.ModificationTime + return out, nil +} + +// GetStatusRequestToSDK converts the mirror to the sdk-go type. +func GetStatusRequestToSDK(w *GetStatusRequest) (*sdk.GetStatusRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetStatusRequest{} + out.Path = w.Path + return out, nil +} + +// GetStatusRequestFromSDK converts the sdk-go type to the mirror. +func GetStatusRequestFromSDK(v *sdk.GetStatusRequest) (*GetStatusRequest, error) { + if v == nil { + return nil, nil + } + out := &GetStatusRequest{} + out.Path = v.Path + return out, nil +} + +// GetStatusResponseToSDK converts the mirror to the sdk-go type. +func GetStatusResponseToSDK(w *GetStatusResponse) (*sdk.GetStatusResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetStatusResponse{} + out.Path = w.Path + out.IsDir = w.IsDir + out.FileSize = w.FileSize + out.ModificationTime = w.ModificationTime + return out, nil +} + +// GetStatusResponseFromSDK converts the sdk-go type to the mirror. +func GetStatusResponseFromSDK(v *sdk.GetStatusResponse) (*GetStatusResponse, error) { + if v == nil { + return nil, nil + } + out := &GetStatusResponse{} + out.Path = v.Path + out.IsDir = v.IsDir + out.FileSize = v.FileSize + out.ModificationTime = v.ModificationTime + return out, nil +} + +// ListDirectoryContentsRequestToSDK converts the mirror to the sdk-go type. +func ListDirectoryContentsRequestToSDK(w *ListDirectoryContentsRequest) (*sdk.ListDirectoryContentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDirectoryContentsRequest{} + out.DirectoryPath = w.DirectoryPath + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListDirectoryContentsRequestFromSDK converts the sdk-go type to the mirror. +func ListDirectoryContentsRequestFromSDK(v *sdk.ListDirectoryContentsRequest) (*ListDirectoryContentsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListDirectoryContentsRequest{} + out.DirectoryPath = v.DirectoryPath + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListDirectoryResponseToSDK converts the mirror to the sdk-go type. +func ListDirectoryResponseToSDK(w *ListDirectoryResponse) (*sdk.ListDirectoryResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDirectoryResponse{} + conv1, err := convertSlice(w.Contents, DirectoryEntryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDirectoryResponse.Contents", err) + } + out.Contents = conv1 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListDirectoryResponseFromSDK converts the sdk-go type to the mirror. +func ListDirectoryResponseFromSDK(v *sdk.ListDirectoryResponse) (*ListDirectoryResponse, error) { + if v == nil { + return nil, nil + } + out := &ListDirectoryResponse{} + conv2, err := convertSlice(v.Contents, DirectoryEntryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDirectoryResponse.Contents", err) + } + out.Contents = conv2 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListStatusRequestToSDK converts the mirror to the sdk-go type. +func ListStatusRequestToSDK(w *ListStatusRequest) (*sdk.ListStatusRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListStatusRequest{} + out.Path = w.Path + return out, nil +} + +// ListStatusRequestFromSDK converts the sdk-go type to the mirror. +func ListStatusRequestFromSDK(v *sdk.ListStatusRequest) (*ListStatusRequest, error) { + if v == nil { + return nil, nil + } + out := &ListStatusRequest{} + out.Path = v.Path + return out, nil +} + +// ListStatusResponseToSDK converts the mirror to the sdk-go type. +func ListStatusResponseToSDK(w *ListStatusResponse) (*sdk.ListStatusResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListStatusResponse{} + conv3, err := convertSlice(w.Files, FileInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListStatusResponse.Files", err) + } + out.Files = conv3 + return out, nil +} + +// ListStatusResponseFromSDK converts the sdk-go type to the mirror. +func ListStatusResponseFromSDK(v *sdk.ListStatusResponse) (*ListStatusResponse, error) { + if v == nil { + return nil, nil + } + out := &ListStatusResponse{} + conv4, err := convertSlice(v.Files, FileInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListStatusResponse.Files", err) + } + out.Files = conv4 + return out, nil +} + +// MkDirsRequestToSDK converts the mirror to the sdk-go type. +func MkDirsRequestToSDK(w *MkDirsRequest) (*sdk.MkDirsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.MkDirsRequest{} + out.Path = w.Path + return out, nil +} + +// MkDirsRequestFromSDK converts the sdk-go type to the mirror. +func MkDirsRequestFromSDK(v *sdk.MkDirsRequest) (*MkDirsRequest, error) { + if v == nil { + return nil, nil + } + out := &MkDirsRequest{} + out.Path = v.Path + return out, nil +} + +// MoveRequestToSDK converts the mirror to the sdk-go type. +func MoveRequestToSDK(w *MoveRequest) (*sdk.MoveRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.MoveRequest{} + out.SourcePath = w.SourcePath + out.DestinationPath = w.DestinationPath + return out, nil +} + +// MoveRequestFromSDK converts the sdk-go type to the mirror. +func MoveRequestFromSDK(v *sdk.MoveRequest) (*MoveRequest, error) { + if v == nil { + return nil, nil + } + out := &MoveRequest{} + out.SourcePath = v.SourcePath + out.DestinationPath = v.DestinationPath + return out, nil +} + +// PutRequestToSDK converts the mirror to the sdk-go type. +func PutRequestToSDK(w *PutRequest) (*sdk.PutRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PutRequest{} + out.Path = w.Path + out.Contents = w.Contents + out.Overwrite = w.Overwrite + return out, nil +} + +// PutRequestFromSDK converts the sdk-go type to the mirror. +func PutRequestFromSDK(v *sdk.PutRequest) (*PutRequest, error) { + if v == nil { + return nil, nil + } + out := &PutRequest{} + out.Path = v.Path + out.Contents = v.Contents + out.Overwrite = v.Overwrite + return out, nil +} + +// ReadRequestToSDK converts the mirror to the sdk-go type. +func ReadRequestToSDK(w *ReadRequest) (*sdk.ReadRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ReadRequest{} + out.Path = w.Path + out.Offset = w.Offset + out.Length = w.Length + return out, nil +} + +// ReadRequestFromSDK converts the sdk-go type to the mirror. +func ReadRequestFromSDK(v *sdk.ReadRequest) (*ReadRequest, error) { + if v == nil { + return nil, nil + } + out := &ReadRequest{} + out.Path = v.Path + out.Offset = v.Offset + out.Length = v.Length + return out, nil +} + +// ReadResponseToSDK converts the mirror to the sdk-go type. +func ReadResponseToSDK(w *ReadResponse) (*sdk.ReadResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ReadResponse{} + out.BytesRead = w.BytesRead + out.Data = w.Data + return out, nil +} + +// ReadResponseFromSDK converts the sdk-go type to the mirror. +func ReadResponseFromSDK(v *sdk.ReadResponse) (*ReadResponse, error) { + if v == nil { + return nil, nil + } + out := &ReadResponse{} + out.BytesRead = v.BytesRead + out.Data = v.Data + return out, nil +} + +// UploadFileRequestToSDK converts the mirror to the sdk-go type. +func UploadFileRequestToSDK(w *UploadFileRequest) (*sdk.UploadFileRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UploadFileRequest{} + out.FilePath = w.FilePath + out.Overwrite = w.Overwrite + return out, nil +} + +// UploadFileRequestFromSDK converts the sdk-go type to the mirror. +func UploadFileRequestFromSDK(v *sdk.UploadFileRequest) (*UploadFileRequest, error) { + if v == nil { + return nil, nil + } + out := &UploadFileRequest{} + out.FilePath = v.FilePath + out.Overwrite = v.Overwrite + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/forecasting/v1/types.generated.go b/libs/sdktypes/forecasting/v1/types.generated.go new file mode 100644 index 00000000000..c3283d59a5c --- /dev/null +++ b/libs/sdktypes/forecasting/v1/types.generated.go @@ -0,0 +1,193 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/forecasting/v1. DO NOT EDIT. + +package forecasting + +import ( + sdk "github.com/databricks/sdk-go/forecasting/v1" +) + +type ( + ForecastingExperiment_State = sdk.ForecastingExperiment_State +) + +const ( + ForecastingExperiment_State_Unspecified = sdk.ForecastingExperiment_State_Unspecified + ForecastingExperiment_State_Running = sdk.ForecastingExperiment_State_Running + ForecastingExperiment_State_Succeeded = sdk.ForecastingExperiment_State_Succeeded + ForecastingExperiment_State_Failed = sdk.ForecastingExperiment_State_Failed + ForecastingExperiment_State_Cancelled = sdk.ForecastingExperiment_State_Cancelled +) + +type CreateForecastingExperimentRequest struct { + // The column in the training table used to customize weights for each time + // series. + CustomWeightsColumn *string `json:"custom_weights_column,omitempty"` + // The path in the workspace to store the created experiment. + ExperimentPath *string `json:"experiment_path,omitempty"` + // The time interval between consecutive rows in the time series data. Possible + // values include: '1 second', '1 minute', '5 minutes', '10 minutes', '15 + // minutes', '30 minutes', 'Hourly', 'Daily', 'Weekly', 'Monthly', 'Quarterly', + // 'Yearly'. + ForecastGranularity *string `json:"forecast_granularity,omitempty"` + // The number of time steps into the future to make predictions, calculated as a + // multiple of forecast_granularity. This value represents how far ahead the + // model should forecast. + ForecastHorizon *int64 `json:"forecast_horizon,omitempty"` + // The fully qualified path of a Unity Catalog table, formatted as + // catalog_name.schema_name.table_name, used to store future feature data for + // predictions. + FutureFeatureDataPath *string `json:"future_feature_data_path,omitempty"` + // The region code(s) to automatically add holiday features. Currently supports + // only one region. + HolidayRegions []string `json:"holiday_regions,omitempty"` + // Specifies the list of feature columns to include in model training. These + // columns must exist in the training data and be of type string, numerical, or + // boolean. If not specified, no additional features will be included. Note: + // Certain columns are automatically handled: - Automatically excluded: + // split_column, target_column, custom_weights_column. - Automatically included: + // time_column. + IncludeFeatures []string `json:"include_features,omitempty"` + // The maximum duration for the experiment in minutes. The experiment stops + // automatically if it exceeds this limit. + MaxRuntime *int64 `json:"max_runtime,omitempty"` + // The fully qualified path of a Unity Catalog table, formatted as + // catalog_name.schema_name.table_name, used to store predictions. + PredictionDataPath *string `json:"prediction_data_path,omitempty"` + // The evaluation metric used to optimize the forecasting model. + PrimaryMetric *string `json:"primary_metric,omitempty"` + // The fully qualified path of a Unity Catalog model, formatted as + // catalog_name.schema_name.model_name, used to store the best model. + RegisterTo *string `json:"register_to,omitempty"` + // // The column in the training table used for custom data splits. Values must + // be 'train', 'validate', or 'test'. + SplitColumn *string `json:"split_column,omitempty"` + // The column in the input training table used as the prediction target for + // model training. The values in this column are used as the ground truth for + // model training. + TargetColumn *string `json:"target_column,omitempty"` + // The column in the input training table that represents each row's timestamp. + TimeColumn *string `json:"time_column,omitempty"` + // The column in the training table used to group the dataset for predicting + // individual time series. + TimeseriesIdentifierColumns []string `json:"timeseries_identifier_columns,omitempty"` + // The fully qualified path of a Unity Catalog table, formatted as + // catalog_name.schema_name.table_name, used as training data for the + // forecasting model. + TrainDataPath *string `json:"train_data_path,omitempty"` + // List of frameworks to include for model tuning. Possible values are + // 'Prophet', 'ARIMA', 'DeepAR'. An empty list includes all supported + // frameworks. + TrainingFrameworks []string `json:"training_frameworks,omitempty"` +} + +type CreateForecastingExperimentResponse struct { + // The unique ID of the created forecasting experiment + ExperimentId *string `json:"experiment_id,omitempty"` +} + +// Represents a forecasting experiment with its unique identifier, URL, and +// state.. +type ForecastingExperiment struct { + // The unique ID for the forecasting experiment. + ExperimentId *string `json:"experiment_id,omitempty"` + // The URL to the forecasting experiment page. + ExperimentPageUrl *string `json:"experiment_page_url,omitempty"` + // The current state of the forecasting experiment. + State ForecastingExperiment_State `json:"state,omitempty"` +} + +// CreateForecastingExperimentRequestToSDK converts the mirror to the sdk-go type. +func CreateForecastingExperimentRequestToSDK(w *CreateForecastingExperimentRequest) (*sdk.CreateForecastingExperimentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateForecastingExperimentRequest{} + out.TrainDataPath = w.TrainDataPath + out.TargetColumn = w.TargetColumn + out.TimeColumn = w.TimeColumn + out.ForecastGranularity = w.ForecastGranularity + out.ForecastHorizon = w.ForecastHorizon + out.PrimaryMetric = w.PrimaryMetric + out.TrainingFrameworks = w.TrainingFrameworks + out.ExperimentPath = w.ExperimentPath + out.MaxRuntime = w.MaxRuntime + out.SplitColumn = w.SplitColumn + out.CustomWeightsColumn = w.CustomWeightsColumn + out.RegisterTo = w.RegisterTo + out.HolidayRegions = w.HolidayRegions + out.TimeseriesIdentifierColumns = w.TimeseriesIdentifierColumns + out.PredictionDataPath = w.PredictionDataPath + out.IncludeFeatures = w.IncludeFeatures + out.FutureFeatureDataPath = w.FutureFeatureDataPath + return out, nil +} + +// CreateForecastingExperimentRequestFromSDK converts the sdk-go type to the mirror. +func CreateForecastingExperimentRequestFromSDK(v *sdk.CreateForecastingExperimentRequest) (*CreateForecastingExperimentRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateForecastingExperimentRequest{} + out.TrainDataPath = v.TrainDataPath + out.TargetColumn = v.TargetColumn + out.TimeColumn = v.TimeColumn + out.ForecastGranularity = v.ForecastGranularity + out.ForecastHorizon = v.ForecastHorizon + out.PrimaryMetric = v.PrimaryMetric + out.TrainingFrameworks = v.TrainingFrameworks + out.ExperimentPath = v.ExperimentPath + out.MaxRuntime = v.MaxRuntime + out.SplitColumn = v.SplitColumn + out.CustomWeightsColumn = v.CustomWeightsColumn + out.RegisterTo = v.RegisterTo + out.HolidayRegions = v.HolidayRegions + out.TimeseriesIdentifierColumns = v.TimeseriesIdentifierColumns + out.PredictionDataPath = v.PredictionDataPath + out.IncludeFeatures = v.IncludeFeatures + out.FutureFeatureDataPath = v.FutureFeatureDataPath + return out, nil +} + +// CreateForecastingExperimentResponseToSDK converts the mirror to the sdk-go type. +func CreateForecastingExperimentResponseToSDK(w *CreateForecastingExperimentResponse) (*sdk.CreateForecastingExperimentResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateForecastingExperimentResponse{} + out.ExperimentId = w.ExperimentId + return out, nil +} + +// CreateForecastingExperimentResponseFromSDK converts the sdk-go type to the mirror. +func CreateForecastingExperimentResponseFromSDK(v *sdk.CreateForecastingExperimentResponse) (*CreateForecastingExperimentResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateForecastingExperimentResponse{} + out.ExperimentId = v.ExperimentId + return out, nil +} + +// ForecastingExperimentToSDK converts the mirror to the sdk-go type. +func ForecastingExperimentToSDK(w *ForecastingExperiment) (*sdk.ForecastingExperiment, error) { + if w == nil { + return nil, nil + } + out := &sdk.ForecastingExperiment{} + out.ExperimentId = w.ExperimentId + out.ExperimentPageUrl = w.ExperimentPageUrl + out.State = w.State + return out, nil +} + +// ForecastingExperimentFromSDK converts the sdk-go type to the mirror. +func ForecastingExperimentFromSDK(v *sdk.ForecastingExperiment) (*ForecastingExperiment, error) { + if v == nil { + return nil, nil + } + out := &ForecastingExperiment{} + out.ExperimentId = v.ExperimentId + out.ExperimentPageUrl = v.ExperimentPageUrl + out.State = v.State + return out, nil +} diff --git a/libs/sdktypes/genie/v1/types.generated.go b/libs/sdktypes/genie/v1/types.generated.go new file mode 100644 index 00000000000..7402850f247 --- /dev/null +++ b/libs/sdktypes/genie/v1/types.generated.go @@ -0,0 +1,3359 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/genie/v1. DO NOT EDIT. + +package genie + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/genie/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + ColumnTypeName = sdk.ColumnTypeName + ErrorCode = sdk.ErrorCode + EvaluationStatusType = sdk.EvaluationStatusType + Format = sdk.Format + GenieConversationType = sdk.GenieConversationType + GenieEvalAssessment = sdk.GenieEvalAssessment + GenieEvalResponseType = sdk.GenieEvalResponseType + GenieFeedbackRating = sdk.GenieFeedbackRating + NullValue = sdk.NullValue + ScoreReason = sdk.ScoreReason + TextAttachmentPurpose = sdk.TextAttachmentPurpose + ThoughtType = sdk.ThoughtType + MessageError_Type = sdk.MessageError_Type + MessageStatus_MessageStatus = sdk.MessageStatus_MessageStatus + StatementStatus_State = sdk.StatementStatus_State +) + +const ( + ColumnTypeName_Unspecified = sdk.ColumnTypeName_Unspecified + ColumnTypeName_Boolean = sdk.ColumnTypeName_Boolean + ColumnTypeName_Byte = sdk.ColumnTypeName_Byte + ColumnTypeName_Short = sdk.ColumnTypeName_Short + ColumnTypeName_Int = sdk.ColumnTypeName_Int + ColumnTypeName_Long = sdk.ColumnTypeName_Long + ColumnTypeName_Float = sdk.ColumnTypeName_Float + ColumnTypeName_Double = sdk.ColumnTypeName_Double + ColumnTypeName_Date = sdk.ColumnTypeName_Date + ColumnTypeName_Timestamp = sdk.ColumnTypeName_Timestamp + ColumnTypeName_String = sdk.ColumnTypeName_String + ColumnTypeName_Binary = sdk.ColumnTypeName_Binary + ColumnTypeName_Decimal = sdk.ColumnTypeName_Decimal + ColumnTypeName_Interval = sdk.ColumnTypeName_Interval + ColumnTypeName_Array = sdk.ColumnTypeName_Array + ColumnTypeName_Struct = sdk.ColumnTypeName_Struct + ColumnTypeName_Map = sdk.ColumnTypeName_Map + ColumnTypeName_Char = sdk.ColumnTypeName_Char + ColumnTypeName_Null = sdk.ColumnTypeName_Null + ColumnTypeName_UserDefinedType = sdk.ColumnTypeName_UserDefinedType + ColumnTypeName_TimestampNtz = sdk.ColumnTypeName_TimestampNtz + ColumnTypeName_Variant = sdk.ColumnTypeName_Variant + ColumnTypeName_Geometry = sdk.ColumnTypeName_Geometry + ColumnTypeName_Geography = sdk.ColumnTypeName_Geography + ColumnTypeName_TableType = sdk.ColumnTypeName_TableType + ErrorCode_Unspecified = sdk.ErrorCode_Unspecified + ErrorCode_InternalError = sdk.ErrorCode_InternalError + ErrorCode_TemporarilyUnavailable = sdk.ErrorCode_TemporarilyUnavailable + ErrorCode_IoError = sdk.ErrorCode_IoError + ErrorCode_BadRequest = sdk.ErrorCode_BadRequest + ErrorCode_ServiceUnderMaintenance = sdk.ErrorCode_ServiceUnderMaintenance + ErrorCode_WorkspaceTemporarilyUnavailable = sdk.ErrorCode_WorkspaceTemporarilyUnavailable + ErrorCode_DeadlineExceeded = sdk.ErrorCode_DeadlineExceeded + ErrorCode_Cancelled = sdk.ErrorCode_Cancelled + ErrorCode_ResourceExhausted = sdk.ErrorCode_ResourceExhausted + ErrorCode_Aborted = sdk.ErrorCode_Aborted + ErrorCode_NotFound = sdk.ErrorCode_NotFound + ErrorCode_AlreadyExists = sdk.ErrorCode_AlreadyExists + ErrorCode_Unauthenticated = sdk.ErrorCode_Unauthenticated + ErrorCode_Unavailable = sdk.ErrorCode_Unavailable + ErrorCode_InvalidParameterValue = sdk.ErrorCode_InvalidParameterValue + ErrorCode_EndpointNotFound = sdk.ErrorCode_EndpointNotFound + ErrorCode_MalformedRequest = sdk.ErrorCode_MalformedRequest + ErrorCode_InvalidState = sdk.ErrorCode_InvalidState + ErrorCode_PermissionDenied = sdk.ErrorCode_PermissionDenied + ErrorCode_FeatureDisabled = sdk.ErrorCode_FeatureDisabled + ErrorCode_CustomerUnauthorized = sdk.ErrorCode_CustomerUnauthorized + ErrorCode_RequestLimitExceeded = sdk.ErrorCode_RequestLimitExceeded + ErrorCode_ResourceConflict = sdk.ErrorCode_ResourceConflict + ErrorCode_UnparseableHttpError = sdk.ErrorCode_UnparseableHttpError + ErrorCode_NotImplemented = sdk.ErrorCode_NotImplemented + ErrorCode_DataLoss = sdk.ErrorCode_DataLoss + ErrorCode_InvalidStateTransition = sdk.ErrorCode_InvalidStateTransition + ErrorCode_CouldNotAcquireLock = sdk.ErrorCode_CouldNotAcquireLock + ErrorCode_ResourceAlreadyExists = sdk.ErrorCode_ResourceAlreadyExists + ErrorCode_ResourceDoesNotExist = sdk.ErrorCode_ResourceDoesNotExist + ErrorCode_QuotaExceeded = sdk.ErrorCode_QuotaExceeded + ErrorCode_MaxBlockSizeExceeded = sdk.ErrorCode_MaxBlockSizeExceeded + ErrorCode_MaxReadSizeExceeded = sdk.ErrorCode_MaxReadSizeExceeded + ErrorCode_PartialDelete = sdk.ErrorCode_PartialDelete + ErrorCode_MaxListSizeExceeded = sdk.ErrorCode_MaxListSizeExceeded + ErrorCode_DryRunFailed = sdk.ErrorCode_DryRunFailed + ErrorCode_ResourceLimitExceeded = sdk.ErrorCode_ResourceLimitExceeded + ErrorCode_DirectoryNotEmpty = sdk.ErrorCode_DirectoryNotEmpty + ErrorCode_DirectoryProtected = sdk.ErrorCode_DirectoryProtected + ErrorCode_MaxNotebookSizeExceeded = sdk.ErrorCode_MaxNotebookSizeExceeded + ErrorCode_MaxChildNodeSizeExceeded = sdk.ErrorCode_MaxChildNodeSizeExceeded + ErrorCode_SearchQueryTooLong = sdk.ErrorCode_SearchQueryTooLong + ErrorCode_SearchQueryTooShort = sdk.ErrorCode_SearchQueryTooShort + ErrorCode_ManagedResourceGroupDoesNotExist = sdk.ErrorCode_ManagedResourceGroupDoesNotExist + ErrorCode_PermissionNotPropagated = sdk.ErrorCode_PermissionNotPropagated + ErrorCode_DeploymentTimeout = sdk.ErrorCode_DeploymentTimeout + ErrorCode_GitConflict = sdk.ErrorCode_GitConflict + ErrorCode_GitUnknownRef = sdk.ErrorCode_GitUnknownRef + ErrorCode_GitSensitiveTokenDetected = sdk.ErrorCode_GitSensitiveTokenDetected + ErrorCode_GitUrlNotOnAllowList = sdk.ErrorCode_GitUrlNotOnAllowList + ErrorCode_GitRemoteError = sdk.ErrorCode_GitRemoteError + ErrorCode_ProjectsOperationTimeout = sdk.ErrorCode_ProjectsOperationTimeout + ErrorCode_IpynbFileInRepo = sdk.ErrorCode_IpynbFileInRepo + ErrorCode_InsecurePartnerResponse = sdk.ErrorCode_InsecurePartnerResponse + ErrorCode_MalformedPartnerResponse = sdk.ErrorCode_MalformedPartnerResponse + ErrorCode_MetastoreDoesNotExist = sdk.ErrorCode_MetastoreDoesNotExist + ErrorCode_DacDoesNotExist = sdk.ErrorCode_DacDoesNotExist + ErrorCode_CatalogDoesNotExist = sdk.ErrorCode_CatalogDoesNotExist + ErrorCode_SchemaDoesNotExist = sdk.ErrorCode_SchemaDoesNotExist + ErrorCode_TableDoesNotExist = sdk.ErrorCode_TableDoesNotExist + ErrorCode_ShareDoesNotExist = sdk.ErrorCode_ShareDoesNotExist + ErrorCode_RecipientDoesNotExist = sdk.ErrorCode_RecipientDoesNotExist + ErrorCode_StorageCredentialDoesNotExist = sdk.ErrorCode_StorageCredentialDoesNotExist + ErrorCode_ExternalLocationDoesNotExist = sdk.ErrorCode_ExternalLocationDoesNotExist + ErrorCode_PrincipalDoesNotExist = sdk.ErrorCode_PrincipalDoesNotExist + ErrorCode_ProviderDoesNotExist = sdk.ErrorCode_ProviderDoesNotExist + ErrorCode_MetastoreAlreadyExists = sdk.ErrorCode_MetastoreAlreadyExists + ErrorCode_DacAlreadyExists = sdk.ErrorCode_DacAlreadyExists + ErrorCode_CatalogAlreadyExists = sdk.ErrorCode_CatalogAlreadyExists + ErrorCode_SchemaAlreadyExists = sdk.ErrorCode_SchemaAlreadyExists + ErrorCode_TableAlreadyExists = sdk.ErrorCode_TableAlreadyExists + ErrorCode_ShareAlreadyExists = sdk.ErrorCode_ShareAlreadyExists + ErrorCode_RecipientAlreadyExists = sdk.ErrorCode_RecipientAlreadyExists + ErrorCode_StorageCredentialAlreadyExists = sdk.ErrorCode_StorageCredentialAlreadyExists + ErrorCode_ExternalLocationAlreadyExists = sdk.ErrorCode_ExternalLocationAlreadyExists + ErrorCode_ProviderAlreadyExists = sdk.ErrorCode_ProviderAlreadyExists + ErrorCode_CatalogNotEmpty = sdk.ErrorCode_CatalogNotEmpty + ErrorCode_SchemaNotEmpty = sdk.ErrorCode_SchemaNotEmpty + ErrorCode_MetastoreNotEmpty = sdk.ErrorCode_MetastoreNotEmpty + ErrorCode_ProviderShareNotAccessible = sdk.ErrorCode_ProviderShareNotAccessible + EvaluationStatusType_Unspecified = sdk.EvaluationStatusType_Unspecified + EvaluationStatusType_Running = sdk.EvaluationStatusType_Running + EvaluationStatusType_Done = sdk.EvaluationStatusType_Done + EvaluationStatusType_NotStarted = sdk.EvaluationStatusType_NotStarted + EvaluationStatusType_EvaluationFailed = sdk.EvaluationStatusType_EvaluationFailed + EvaluationStatusType_EvaluationCancelled = sdk.EvaluationStatusType_EvaluationCancelled + EvaluationStatusType_EvaluationTimeout = sdk.EvaluationStatusType_EvaluationTimeout + Format_Unspecified = sdk.Format_Unspecified + Format_JsonArray = sdk.Format_JsonArray + Format_ArrowStream = sdk.Format_ArrowStream + Format_Csv = sdk.Format_Csv + GenieConversationType_Unspecified = sdk.GenieConversationType_Unspecified + GenieConversationType_GenieConversationTypeChat = sdk.GenieConversationType_GenieConversationTypeChat + GenieConversationType_GenieConversationTypeAgent = sdk.GenieConversationType_GenieConversationTypeAgent + GenieEvalAssessment_Unspecified = sdk.GenieEvalAssessment_Unspecified + GenieEvalAssessment_Good = sdk.GenieEvalAssessment_Good + GenieEvalAssessment_Bad = sdk.GenieEvalAssessment_Bad + GenieEvalAssessment_NeedsReview = sdk.GenieEvalAssessment_NeedsReview + GenieEvalResponseType_Unspecified = sdk.GenieEvalResponseType_Unspecified + GenieEvalResponseType_Text = sdk.GenieEvalResponseType_Text + GenieEvalResponseType_Sql = sdk.GenieEvalResponseType_Sql + GenieFeedbackRating_Unspecified = sdk.GenieFeedbackRating_Unspecified + GenieFeedbackRating_Positive = sdk.GenieFeedbackRating_Positive + GenieFeedbackRating_Negative = sdk.GenieFeedbackRating_Negative + GenieFeedbackRating_None = sdk.GenieFeedbackRating_None + NullValue_Unspecified = sdk.NullValue_Unspecified + ScoreReason_Unspecified = sdk.ScoreReason_Unspecified + ScoreReason_EmptyResult = sdk.ScoreReason_EmptyResult + ScoreReason_ResultMissingRows = sdk.ScoreReason_ResultMissingRows + ScoreReason_ResultExtraRows = sdk.ScoreReason_ResultExtraRows + ScoreReason_ResultMissingColumns = sdk.ScoreReason_ResultMissingColumns + ScoreReason_ResultExtraColumns = sdk.ScoreReason_ResultExtraColumns + ScoreReason_SingleCellDifference = sdk.ScoreReason_SingleCellDifference + ScoreReason_EmptyGoodSql = sdk.ScoreReason_EmptyGoodSql + ScoreReason_ColumnTypeDifference = sdk.ScoreReason_ColumnTypeDifference + ScoreReason_LlmJudgeMissingJoin = sdk.ScoreReason_LlmJudgeMissingJoin + ScoreReason_LlmJudgeWrongFilter = sdk.ScoreReason_LlmJudgeWrongFilter + ScoreReason_LlmJudgeWrongAggregation = sdk.ScoreReason_LlmJudgeWrongAggregation + ScoreReason_LlmJudgeWrongColumns = sdk.ScoreReason_LlmJudgeWrongColumns + ScoreReason_LlmJudgeSyntaxError = sdk.ScoreReason_LlmJudgeSyntaxError + ScoreReason_LlmJudgeSemanticError = sdk.ScoreReason_LlmJudgeSemanticError + ScoreReason_LlmJudgeOther = sdk.ScoreReason_LlmJudgeOther + ScoreReason_LlmJudgeMissingOrIncorrectFilter = sdk.ScoreReason_LlmJudgeMissingOrIncorrectFilter + ScoreReason_LlmJudgeIncompleteOrPartialOutput = sdk.ScoreReason_LlmJudgeIncompleteOrPartialOutput + ScoreReason_LlmJudgeMisinterpretationOfUserRequest = sdk.ScoreReason_LlmJudgeMisinterpretationOfUserRequest + ScoreReason_LlmJudgeInstructionComplianceOrMissingBusinessLogic = sdk.ScoreReason_LlmJudgeInstructionComplianceOrMissingBusinessLogic + ScoreReason_LlmJudgeIncorrectMetricCalculation = sdk.ScoreReason_LlmJudgeIncorrectMetricCalculation + ScoreReason_LlmJudgeIncorrectTableOrFieldUsage = sdk.ScoreReason_LlmJudgeIncorrectTableOrFieldUsage + ScoreReason_LlmJudgeIncorrectFunctionUsage = sdk.ScoreReason_LlmJudgeIncorrectFunctionUsage + ScoreReason_LlmJudgeMissingOrIncorrectJoin = sdk.ScoreReason_LlmJudgeMissingOrIncorrectJoin + ScoreReason_LlmJudgeMissingOrIncorrectAggregation = sdk.ScoreReason_LlmJudgeMissingOrIncorrectAggregation + ScoreReason_LlmJudgeFormattingError = sdk.ScoreReason_LlmJudgeFormattingError + TextAttachmentPurpose_Unspecified = sdk.TextAttachmentPurpose_Unspecified + TextAttachmentPurpose_FollowUpQuestion = sdk.TextAttachmentPurpose_FollowUpQuestion + TextAttachmentPurpose_TextAttachmentPurposeAnswer = sdk.TextAttachmentPurpose_TextAttachmentPurposeAnswer + ThoughtType_Unspecified = sdk.ThoughtType_Unspecified + ThoughtType_ThoughtTypeDescription = sdk.ThoughtType_ThoughtTypeDescription + ThoughtType_ThoughtTypeUnderstanding = sdk.ThoughtType_ThoughtTypeUnderstanding + ThoughtType_ThoughtTypeDataSourcing = sdk.ThoughtType_ThoughtTypeDataSourcing + ThoughtType_ThoughtTypeInstructions = sdk.ThoughtType_ThoughtTypeInstructions + ThoughtType_ThoughtTypeSteps = sdk.ThoughtType_ThoughtTypeSteps + MessageError_Type_Unspecified = sdk.MessageError_Type_Unspecified + MessageError_Type_UnexpectedReplyProcessException = sdk.MessageError_Type_UnexpectedReplyProcessException + MessageError_Type_GenericChatCompletionException = sdk.MessageError_Type_GenericChatCompletionException + MessageError_Type_ContextExceededException = sdk.MessageError_Type_ContextExceededException + MessageError_Type_DeploymentNotFoundException = sdk.MessageError_Type_DeploymentNotFoundException + MessageError_Type_FunctionsNotAvailableException = sdk.MessageError_Type_FunctionsNotAvailableException + MessageError_Type_InvalidCompletionRequestException = sdk.MessageError_Type_InvalidCompletionRequestException + MessageError_Type_ContentFilterException = sdk.MessageError_Type_ContentFilterException + MessageError_Type_FunctionArgumentsInvalidJsonException = sdk.MessageError_Type_FunctionArgumentsInvalidJsonException + MessageError_Type_RetryableProcessingException = sdk.MessageError_Type_RetryableProcessingException + MessageError_Type_InvalidFunctionCallException = sdk.MessageError_Type_InvalidFunctionCallException + MessageError_Type_LocalContextExceededException = sdk.MessageError_Type_LocalContextExceededException + MessageError_Type_ChatCompletionNetworkException = sdk.MessageError_Type_ChatCompletionNetworkException + MessageError_Type_InvalidChatCompletionJsonException = sdk.MessageError_Type_InvalidChatCompletionJsonException + MessageError_Type_GenericChatCompletionServiceException = sdk.MessageError_Type_GenericChatCompletionServiceException + MessageError_Type_WarehouseAccessMissingException = sdk.MessageError_Type_WarehouseAccessMissingException + MessageError_Type_WarehouseNotFoundException = sdk.MessageError_Type_WarehouseNotFoundException + MessageError_Type_NoTablesToQueryException = sdk.MessageError_Type_NoTablesToQueryException + MessageError_Type_SqlExecutionException = sdk.MessageError_Type_SqlExecutionException + MessageError_Type_ReplyProcessTimeoutException = sdk.MessageError_Type_ReplyProcessTimeoutException + MessageError_Type_CouldNotGetUcSchemaException = sdk.MessageError_Type_CouldNotGetUcSchemaException + MessageError_Type_InvalidTableIdentifierException = sdk.MessageError_Type_InvalidTableIdentifierException + MessageError_Type_TooManyTablesException = sdk.MessageError_Type_TooManyTablesException + MessageError_Type_FunctionArgumentsInvalidException = sdk.MessageError_Type_FunctionArgumentsInvalidException + MessageError_Type_GenericSqlExecApiCallException = sdk.MessageError_Type_GenericSqlExecApiCallException + MessageError_Type_ChatCompletionClientException = sdk.MessageError_Type_ChatCompletionClientException + MessageError_Type_ChatCompletionClientTimeoutException = sdk.MessageError_Type_ChatCompletionClientTimeoutException + MessageError_Type_UnknownAiModel = sdk.MessageError_Type_UnknownAiModel + MessageError_Type_TablesMissingException = sdk.MessageError_Type_TablesMissingException + MessageError_Type_MessageDeletedWhileExecutingException = sdk.MessageError_Type_MessageDeletedWhileExecutingException + MessageError_Type_MessageUpdatedWhileExecutingException = sdk.MessageError_Type_MessageUpdatedWhileExecutingException + MessageError_Type_BlockMultipleExecutionsException = sdk.MessageError_Type_BlockMultipleExecutionsException + MessageError_Type_InvalidCertifiedAnswerIdentifierException = sdk.MessageError_Type_InvalidCertifiedAnswerIdentifierException + MessageError_Type_TooManyCertifiedAnswersException = sdk.MessageError_Type_TooManyCertifiedAnswersException + MessageError_Type_RateLimitExceededGenericException = sdk.MessageError_Type_RateLimitExceededGenericException + MessageError_Type_RateLimitExceededSpecifiedWaitException = sdk.MessageError_Type_RateLimitExceededSpecifiedWaitException + MessageError_Type_FunctionCallMissingParameterException = sdk.MessageError_Type_FunctionCallMissingParameterException + MessageError_Type_InvalidCertifiedAnswerFunctionException = sdk.MessageError_Type_InvalidCertifiedAnswerFunctionException + MessageError_Type_IllegalParameterDefinitionException = sdk.MessageError_Type_IllegalParameterDefinitionException + MessageError_Type_NoQueryToVisualizeException = sdk.MessageError_Type_NoQueryToVisualizeException + MessageError_Type_NoDeploymentsAvailableToWorkspace = sdk.MessageError_Type_NoDeploymentsAvailableToWorkspace + MessageError_Type_StopProcessDueToAutoRegenerate = sdk.MessageError_Type_StopProcessDueToAutoRegenerate + MessageError_Type_FunctionArgumentsInvalidTypeException = sdk.MessageError_Type_FunctionArgumentsInvalidTypeException + MessageError_Type_MessageCancelledWhileExecutingException = sdk.MessageError_Type_MessageCancelledWhileExecutingException + MessageError_Type_CouldNotGetModelDeploymentsException = sdk.MessageError_Type_CouldNotGetModelDeploymentsException + MessageError_Type_GeneratedSqlQueryTooLongException = sdk.MessageError_Type_GeneratedSqlQueryTooLongException + MessageError_Type_MissingSqlQueryException = sdk.MessageError_Type_MissingSqlQueryException + MessageError_Type_DescribeQueryUnexpectedFailure = sdk.MessageError_Type_DescribeQueryUnexpectedFailure + MessageError_Type_DescribeQueryTimeout = sdk.MessageError_Type_DescribeQueryTimeout + MessageError_Type_DescribeQueryInvalidSqlError = sdk.MessageError_Type_DescribeQueryInvalidSqlError + MessageError_Type_InvalidSqlUnknownTableException = sdk.MessageError_Type_InvalidSqlUnknownTableException + MessageError_Type_InvalidSqlMultipleStatementsException = sdk.MessageError_Type_InvalidSqlMultipleStatementsException + MessageError_Type_InvalidSqlMultipleDatasetReferencesException = sdk.MessageError_Type_InvalidSqlMultipleDatasetReferencesException + MessageError_Type_MessageAttachmentTooLongError = sdk.MessageError_Type_MessageAttachmentTooLongError + MessageError_Type_InternalCatalogPathOverlapException = sdk.MessageError_Type_InternalCatalogPathOverlapException + MessageError_Type_InternalCatalogMissingUcPathException = sdk.MessageError_Type_InternalCatalogMissingUcPathException + MessageError_Type_ExceededMaxTokenLengthException = sdk.MessageError_Type_ExceededMaxTokenLengthException + MessageError_Type_InternalCatalogAssetCreationOngoingException = sdk.MessageError_Type_InternalCatalogAssetCreationOngoingException + MessageError_Type_InternalCatalogAssetCreationFailedException = sdk.MessageError_Type_InternalCatalogAssetCreationFailedException + MessageError_Type_InternalCatalogAssetCreationUnsupportedException = sdk.MessageError_Type_InternalCatalogAssetCreationUnsupportedException + MessageError_Type_UnsupportedConversationTypeException = sdk.MessageError_Type_UnsupportedConversationTypeException + MessageError_Type_CouldNotGetDashboardSchemaException = sdk.MessageError_Type_CouldNotGetDashboardSchemaException + MessageStatus_MessageStatus_Unspecified = sdk.MessageStatus_MessageStatus_Unspecified + MessageStatus_MessageStatus_FetchingMetadata = sdk.MessageStatus_MessageStatus_FetchingMetadata + MessageStatus_MessageStatus_FilteringContext = sdk.MessageStatus_MessageStatus_FilteringContext + MessageStatus_MessageStatus_AskingAi = sdk.MessageStatus_MessageStatus_AskingAi + MessageStatus_MessageStatus_PendingWarehouse = sdk.MessageStatus_MessageStatus_PendingWarehouse + MessageStatus_MessageStatus_ExecutingQuery = sdk.MessageStatus_MessageStatus_ExecutingQuery + MessageStatus_MessageStatus_Failed = sdk.MessageStatus_MessageStatus_Failed + MessageStatus_MessageStatus_Completed = sdk.MessageStatus_MessageStatus_Completed + MessageStatus_MessageStatus_Submitted = sdk.MessageStatus_MessageStatus_Submitted + MessageStatus_MessageStatus_QueryResultExpired = sdk.MessageStatus_MessageStatus_QueryResultExpired + MessageStatus_MessageStatus_Cancelled = sdk.MessageStatus_MessageStatus_Cancelled + StatementStatus_State_Unspecified = sdk.StatementStatus_State_Unspecified + StatementStatus_State_Pending = sdk.StatementStatus_State_Pending + StatementStatus_State_Running = sdk.StatementStatus_State_Running + StatementStatus_State_Succeeded = sdk.StatementStatus_State_Succeeded + StatementStatus_State_Failed = sdk.StatementStatus_State_Failed + StatementStatus_State_Canceled = sdk.StatementStatus_State_Canceled + StatementStatus_State_Closed = sdk.StatementStatus_State_Closed +) + +type ChunkInfo struct { + // The number of bytes in the result chunk. This field is not available when + // using `INLINE` disposition. + ByteCount *int64 `json:"byte_count,omitempty"` + // The position within the sequence of result set chunks. + ChunkIndex *int `json:"chunk_index,omitempty"` + // When fetching, provides the `chunk_index` for the _next_ chunk. If absent, + // indicates there are no more chunks. The next chunk can be fetched with a + // :method:statementexecution/getstatementresultchunkn request. + NextChunkIndex *int `json:"next_chunk_index,omitempty"` + // When fetching, provides a link to fetch the _next_ chunk. If absent, + // indicates there are no more chunks. This link is an absolute `path` to be + // joined with your `$DATABRICKS_HOST`, and should be treated as an opaque link. + // This is an alternative to using `next_chunk_index`. + NextChunkInternalLink *string `json:"next_chunk_internal_link,omitempty"` + // The number of rows within the result chunk. + RowCount *int64 `json:"row_count,omitempty"` + // The starting row offset within the result set. + RowOffset *int64 `json:"row_offset,omitempty"` +} + +type ColumnInfo struct { + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + Mask *ColumnMask `json:"mask,omitempty"` + // Name of Column. + Name *string `json:"name,omitempty"` + // Whether field may be Null (default: true). + Nullable *bool `json:"nullable,omitempty"` + // Partition index for column. + PartitionIndex *int `json:"partition_index,omitempty"` + // Ordinal position of column (starting at position 0). + Position *int `json:"position,omitempty"` + // Format of IntervalType. + TypeIntervalType *string `json:"type_interval_type,omitempty"` + // Full data type specification, JSON-serialized. + TypeJson *string `json:"type_json,omitempty"` + TypeName ColumnTypeName `json:"type_name,omitempty"` + // Digits of precision; required for DecimalTypes. + TypePrecision *int `json:"type_precision,omitempty"` + // Digits to right of decimal; Required for DecimalTypes. + TypeScale *int `json:"type_scale,omitempty"` + // Full data type specification as SQL/catalogString text. + TypeText *string `json:"type_text,omitempty"` +} + +type ColumnMask struct { + // The full name of the column mask SQL UDF. + FunctionName *string `json:"function_name,omitempty"` + // The list of table columns or literals to be passed as additional arguments to + // a column mask function, carrying the type (column reference vs constant + // literal) of each argument. Deprecated: use using_column_names instead. + UsingArguments []PolicyFunctionArgument `json:"using_arguments,omitempty"` + // The list of additional table columns to be passed as input to the column mask + // function. The first arg of the mask function should be of the type of the + // column being masked and the types of the rest of the args should match the + // types of columns in 'using_column_names'. + UsingColumnNames []string `json:"using_column_names,omitempty"` +} + +// Serialization format for DatabricksServiceException. Note the definition of +// this message should be in sync with +// DatabricksServiceExceptionWithDetailsProto defined in +// /api-base/proto/exception_with_details.proto except the later one has an +// extra error details field defined.. +type DatabricksServiceExceptionProto struct { + ErrorCode ErrorCode `json:"error_code,omitempty"` + Message *string `json:"message,omitempty"` + StackTrace *string `json:"stack_trace,omitempty"` +} + +type ExternalLink struct { + // The number of bytes in the result chunk. This field is not available when + // using `INLINE` disposition. + ByteCount *int64 `json:"byte_count,omitempty"` + // The position within the sequence of result set chunks. + ChunkIndex *int `json:"chunk_index,omitempty"` + // Indicates the date-time that the given external link will expire and becomes + // invalid, after which point a new `external_link` must be requested. + Expiration *string `json:"expiration,omitempty"` + // A short-lived cloud-storage URL pointing to a chunk of result data, hosted by + // an external service, with a short expiration time (<= 15 minutes). As this + // URL contains a temporary credential, it should be considered sensitive and + // the client should not expose this URL in a log. + ExternalLink *string `json:"external_link,omitempty"` + // HTTP headers that must be included with a GET request to the `external_link`. + // Each header is provided as a key-value pair. Headers are typically used to + // pass a decryption key to the external service. The values of these headers + // should be considered sensitive and the client should not expose these values + // in a log. + HttpHeaders map[string]string `json:"http_headers,omitempty"` + // When fetching, provides the `chunk_index` for the _next_ chunk. If absent, + // indicates there are no more chunks. The next chunk can be fetched with a + // :method:statementexecution/getstatementresultchunkn request. + NextChunkIndex *int `json:"next_chunk_index,omitempty"` + // When fetching, provides a link to fetch the _next_ chunk. If absent, + // indicates there are no more chunks. This link is an absolute `path` to be + // joined with your `$DATABRICKS_HOST`, and should be treated as an opaque link. + // This is an alternative to using `next_chunk_index`. + NextChunkInternalLink *string `json:"next_chunk_internal_link,omitempty"` + // The number of rows within the result chunk. + RowCount *int64 `json:"row_count,omitempty"` + // The starting row offset within the result set. + RowOffset *int64 `json:"row_offset,omitempty"` +} + +// Genie AI Response. +type GenieAttachment struct { + // Attachment ID + AttachmentId *string `json:"attachment_id,omitempty"` + Query *GenieQueryAttachment `json:"query,omitempty"` + SuggestedQuestions *GenieSuggestedQuestionsAttachment `json:"suggested_questions,omitempty"` + Text *TextAttachment `json:"text,omitempty"` + Viz *GenieVizAttachment `json:"viz,omitempty"` +} + +// Request to cancel an in-flight agent-mode response.. +type GenieCancelResponseRequest struct { + // The ID of the Genie agent (synonymous with the Genie space ID). + AgentId *string `json:"agent_id,omitempty"` + // The ID of the conversation containing the response. + ConversationId *string `json:"conversation_id,omitempty"` + // The ID of the response to cancel (the id from the `response.created` event). + ResponseId *string `json:"response_id,omitempty"` +} + +// A Genie conversation. Use chat-mode message endpoints for classic chats and +// agent-mode response and item endpoints for agent conversations. Conversation +// management, feedback, comments, and attachment operations support both modes.. +type GenieConversation struct { + // Conversation ID + ConversationId *string `json:"conversation_id,omitempty"` + // Timestamp when the message was created + CreatedTimestamp *int64 `json:"created_timestamp,omitempty"` + // Conversation ID. Legacy identifier, use conversation_id instead + Id *string `json:"id,omitempty"` + // Timestamp when the message was last updated + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // Genie space ID + SpaceId *string `json:"space_id,omitempty"` + // Conversation title + Title *string `json:"title,omitempty"` + // ID of the user who created the conversation + UserId *int64 `json:"user_id,omitempty"` +} + +type GenieConversationSummary struct { + // Whether this is a classic chat or an agent-mode conversation. Allows callers + // to route message retrieval (chat vs. agent endpoint) without an extra lookup. + AgentType GenieConversationType `json:"agent_type,omitempty"` + ConversationId *string `json:"conversation_id,omitempty"` + CreatedTimestamp *int64 `json:"created_timestamp,omitempty"` + Title *string `json:"title,omitempty"` +} + +type GenieCreateConversationMessageRequest struct { + // User message content. + Content *string `json:"content,omitempty"` + // The ID associated with the conversation. + ConversationId *string `json:"conversation_id,omitempty"` + // Enable visualization generation. + EnableVisualization *bool `json:"enable_visualization,omitempty"` + // The ID associated with the Genie space where the conversation is started. + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieCreateEvalRunRequest struct { + // List of benchmark question IDs to evaluate. These questions must exist in the + // specified Genie space. If none are specified, then all benchmark questions + // are evaluated. + BenchmarkQuestionIds []string `json:"benchmark_question_ids,omitempty"` + // The ID associated with the Genie space where the evaluations will be + // executed. + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieCreateMessageCommentRequest struct { + // Comment text content. + Content *string `json:"content,omitempty"` + // The ID associated with the conversation. + ConversationId *string `json:"conversation_id,omitempty"` + // The ID associated with the message. + MessageId *string `json:"message_id,omitempty"` + // The ID associated with the Genie space. + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieCreateSpaceRequest struct { + // Optional description + Description *string `json:"description,omitempty"` + // Parent folder path where the space will be registered + ParentPath *string `json:"parent_path,omitempty"` + // The contents of the Genie Space in serialized string form. Use the [Get Genie + // Space](:method:genie/getspace) API to retrieve an example response, which + // includes the `serialized_space` field. This field provides the structure of + // the JSON string that represents the space's layout and components. + SerializedSpace *string `json:"serialized_space,omitempty"` + // Optional title override + Title *string `json:"title,omitempty"` + // Warehouse to associate with the new space + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type GenieEvalResponse struct { + // The response content (either text or SQL query). + Response *string `json:"response,omitempty"` + // Type of response + ResponseType GenieEvalResponseType `json:"response_type,omitempty"` + // SQL Statement Execution response. + SqlExecutionResult *StatementResponse `json:"sql_execution_result,omitempty"` +} + +// Shows summary information for an evaluation result. For detailed information +// including SQL execution results, actual/expected responses, and assessment +// scores, use GenieGetEvalResultDetails.. +type GenieEvalResult struct { + // Stored snapshot of original benchmark answer text. + BenchmarkAnswer *string `json:"benchmark_answer,omitempty"` + // The ID of the benchmark question that was evaluated. + BenchmarkQuestionId *string `json:"benchmark_question_id,omitempty"` + // User ID who created evaluation result. + CreatedByUser *int64 `json:"created_by_user,omitempty"` + // Stored snapshot of original benchmark question text. + Question *string `json:"question,omitempty"` + // Unique identifier for this evaluation result. + ResultId *string `json:"result_id,omitempty"` + // The ID of the space the evaluation result belongs to. + SpaceId *string `json:"space_id,omitempty"` + // Current status of this evaluation result. + Status EvaluationStatusType `json:"status,omitempty"` +} + +// Shows detailed information for an evaluation result.. +type GenieEvalResultDetails struct { + // The actual response generated by Genie. + ActualResponse []GenieEvalResponse `json:"actual_response,omitempty"` + // Assessment of the evaluation result: good, bad, or needs review + Assessment GenieEvalAssessment `json:"assessment,omitempty"` + // Reasons for the assessment score. + // + // Assessment reasons describe why a Genie response was scored as BAD. + // + // Deterministic values (compared against the ground truth result): - + // EMPTY_RESULT: Genie's generated SQL results were empty for this benchmark + // question. - RESULT_MISSING_ROWS: Genie's generated SQL response is missing + // rows from the provided ground truth SQL. - RESULT_EXTRA_ROWS: Genie's + // generated SQL response has more rows than the provided ground truth SQL. - + // RESULT_MISSING_COLUMNS: Genie's generated SQL response is missing columns + // from the provided ground truth SQL. - RESULT_EXTRA_COLUMNS: Genie's generated + // SQL response has more columns than the provided ground truth SQL. - + // SINGLE_CELL_DIFFERENCE: Single value result was produced but differs from + // ground truth result. - EMPTY_GOOD_SQL: The benchmark SQL returned an empty + // result. - COLUMN_TYPE_DIFFERENCE: The values between the results match but + // the column type is different. + // + // LLM judge ratings explain the factors driving BAD results: - + // LLM_JUDGE_MISSING_OR_INCORRECT_FILTER: Genie's generated SQL is missing a + // WHERE clause condition or has incorrect filter logic that excludes/includes + // wrong data. - LLM_JUDGE_INCOMPLETE_OR_PARTIAL_OUTPUT: Genie's generated SQL + // returns only some of the requested data or columns, missing parts of what the + // ground truth SQL returns. - LLM_JUDGE_MISINTERPRETATION_OF_USER_REQUEST: + // Genie's generated SQL fundamentally misunderstands what the user is asking + // for, addressing the wrong question or goal. - + // LLM_JUDGE_INSTRUCTION_COMPLIANCE_OR_MISSING_BUSINESS_LOGIC: Genie's generated + // SQL fails to apply specified instructions or business logic that should be + // followed. - LLM_JUDGE_INCORRECT_METRIC_CALCULATION: Genie's generated SQL + // uses incorrect logic or makes wrong assumptions when calculating metrics. - + // LLM_JUDGE_INCORRECT_TABLE_OR_FIELD_USAGE: Genie's generated SQL references + // wrong tables, columns, or uses fields that don't match the ground truth SQL's + // intent. - LLM_JUDGE_INCORRECT_FUNCTION_USAGE: Genie's generated SQL uses SQL + // functions incorrectly or inappropriately (wrong parameters, wrong function + // for the task, etc.). - LLM_JUDGE_MISSING_OR_INCORRECT_JOIN: Genie's generated + // SQL is missing necessary joins between tables or has incorrect join + // conditions/types that produce wrong results. - + // LLM_JUDGE_MISSING_OR_INCORRECT_AGGREGATION: Genie's generated SQL is missing + // GROUP BY clauses or has incorrect grouping that doesn't match the requested + // aggregation level. - LLM_JUDGE_FORMATTING_ERROR: Genie's generated SQL output + // has incorrect formatting, ordering (ORDER BY), or presentation issues that + // don't match expectations. - LLM_JUDGE_OTHER: LLM judge identified an error + // that doesn't fall into other categories. + // + // Deprecated LLM judge values (kept for backward compatibility, do not use): - + // LLM_JUDGE_MISSING_JOIN (deprecated) - LLM_JUDGE_WRONG_FILTER (deprecated) - + // LLM_JUDGE_WRONG_AGGREGATION (deprecated) - LLM_JUDGE_WRONG_COLUMNS + // (deprecated) - LLM_JUDGE_SYNTAX_ERROR (deprecated) - LLM_JUDGE_SEMANTIC_ERROR + // (deprecated) + AssessmentReasons []ScoreReason `json:"assessment_reasons,omitempty"` + // The ID of the benchmark question that was evaluated. + BenchmarkQuestionId *string `json:"benchmark_question_id,omitempty"` + // Current status of the evaluation run. + EvalRunStatus EvaluationStatusType `json:"eval_run_status,omitempty"` + // The expected responses from the benchmark. + ExpectedResponse []GenieEvalResponse `json:"expected_response,omitempty"` + // Whether this evaluation was manually assessed. + ManualAssessment *bool `json:"manual_assessment,omitempty"` + // The unique identifier for the evaluation result. + ResultId *string `json:"result_id,omitempty"` + // The ID of the space the evaluation result belongs to. + SpaceId *string `json:"space_id,omitempty"` +} + +// A benchmark evaluation run. The public benchmark API currently evaluates +// chat-mode responses.. +type GenieEvalRunResponse struct { + // Timestamp when the evaluation run was created (milliseconds since epoch). + CreatedTimestamp *int64 `json:"created_timestamp,omitempty"` + // The unique identifier for the evaluation run. + EvalRunId *string `json:"eval_run_id,omitempty"` + // Current status of the evaluation run. + EvalRunStatus EvaluationStatusType `json:"eval_run_status,omitempty"` + // Timestamp when the evaluation run was last updated (milliseconds since + // epoch). + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // Number of questions answered correctly. + NumCorrect *int64 `json:"num_correct,omitempty"` + // Number of questions that have been completed. + NumDone *int64 `json:"num_done,omitempty"` + // Number of questions that need manual review. + NumNeedsReview *int64 `json:"num_needs_review,omitempty"` + // Total number of questions in the evaluation run. + NumQuestions *int64 `json:"num_questions,omitempty"` + // User ID who initiated the evaluation run. + RunByUser *int64 `json:"run_by_user,omitempty"` +} + +type GenieExecuteMessageAttachmentQueryRequest struct { + // Attachment ID + AttachmentId *string `json:"attachment_id,omitempty"` + // Conversation ID + ConversationId *string `json:"conversation_id,omitempty"` + // Message ID + MessageId *string `json:"message_id,omitempty"` + // Genie space ID + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieExecuteMessageQueryRequest struct { + // Conversation ID + ConversationId *string `json:"conversation_id,omitempty"` + // Message ID + MessageId *string `json:"message_id,omitempty"` + // Genie space ID + SpaceId *string `json:"space_id,omitempty"` +} + +// Feedback containing rating and optional comment. +type GenieFeedback struct { + // Optional feedback comment text + Comment *string `json:"comment,omitempty"` + // The feedback rating + Rating GenieFeedbackRating `json:"rating,omitempty"` +} + +type GenieGenerateDownloadFullQueryResultRequest struct { + // Attachment ID + AttachmentId *string `json:"attachment_id,omitempty"` + // Conversation ID + ConversationId *string `json:"conversation_id,omitempty"` + // Message ID + MessageId *string `json:"message_id,omitempty"` + // Genie space ID + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieGenerateDownloadFullQueryResultResponse struct { + // Download ID. Use this ID to track the download request in subsequent polling + // calls + DownloadId *string `json:"download_id,omitempty"` + // JWT signature for the download_id to ensure secure access to query results + DownloadIdSignature *string `json:"download_id_signature,omitempty"` +} + +type GenieGetDownloadFullQueryResultRequest struct { + // Attachment ID + AttachmentId *string `json:"attachment_id,omitempty"` + // Conversation ID + ConversationId *string `json:"conversation_id,omitempty"` + // Download ID. This ID is provided by the [Generate Download + // endpoint](:method:genie/generateDownloadFullQueryResult) + DownloadId *string `json:"download_id,omitempty"` + // JWT signature for the download_id to ensure secure access to query results + DownloadIdSignature *string `json:"download_id_signature,omitempty"` + // Message ID + MessageId *string `json:"message_id,omitempty"` + // Genie space ID + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieGetDownloadFullQueryResultResponse struct { + // SQL Statement Execution response. See [Get status, manifest, and result first + // chunk](:method:statementexecution/getstatement) for more details. + StatementResponse *StatementResponse `json:"statement_response,omitempty"` +} + +type GenieGetMessageQueryResultResponse struct { + // SQL Statement Execution response. See [Get status, manifest, and result first + // chunk](:method:statementexecution/getstatement) for more details. + StatementResponse *StatementResponse `json:"statement_response,omitempty"` +} + +type GenieGetSpaceRequest struct { + // Whether to include the serialized space export in the response. Requires at + // least CAN EDIT permission on the space. + IncludeSerializedSpace *bool `json:"include_serialized_space,omitempty"` + // The ID associated with the Genie space + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieListConversationCommentsRequest struct { + // The ID associated with the conversation. + ConversationId *string `json:"conversation_id,omitempty"` + // Maximum number of comments to return per page. + PageSize *int `json:"page_size,omitempty"` + // Pagination token for getting the next page of results. + PageToken *string `json:"page_token,omitempty"` + // The ID associated with the Genie space. + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieListConversationCommentsResponse struct { + // List of comments in the conversation. + Comments []GenieMessageComment `json:"comments,omitempty"` + // Token to get the next page of results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type GenieListConversationMessagesRequest struct { + // The ID of the conversation to list messages from + ConversationId *string `json:"conversation_id,omitempty"` + // Maximum number of messages to return per page + PageSize *int `json:"page_size,omitempty"` + // Token to get the next page of results + PageToken *string `json:"page_token,omitempty"` + // The ID associated with the Genie space where the conversation is located + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieListConversationMessagesResponse struct { + // List of messages in the conversation. + Messages []GenieMessage `json:"messages,omitempty"` + // The token to use for retrieving the next page of results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type GenieListConversationsRequest struct { + // Include all conversations in the space across all users. Requires at least + // CAN MANAGE permission on the space. + IncludeAll *bool `json:"include_all,omitempty"` + // Maximum number of conversations to return per page + PageSize *int `json:"page_size,omitempty"` + // Token to get the next page of results + PageToken *string `json:"page_token,omitempty"` + // The ID of the Genie space to retrieve conversations from. + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieListConversationsResponse struct { + // List of conversations in the Genie space + Conversations []GenieConversationSummary `json:"conversations,omitempty"` + // Token to get the next page of results + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type GenieListEvalResultsRequest struct { + // The unique identifier for the evaluation run. + EvalRunId *string `json:"eval_run_id,omitempty"` + // Maximum number of eval results to return per page. + PageSize *int `json:"page_size,omitempty"` + // Opaque token to retrieve the next page of results. + PageToken *string `json:"page_token,omitempty"` + // The ID associated with the Genie space where the evaluation run is located. + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieListEvalResultsResponse struct { + // List of evaluation results for the specified run. + EvalResults []GenieEvalResult `json:"eval_results,omitempty"` + // The token to use for retrieving the next page of results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type GenieListEvalRunsRequest struct { + // Maximum number of evaluation runs to return per page + PageSize *int `json:"page_size,omitempty"` + // Token to get the next page of results + PageToken *string `json:"page_token,omitempty"` + // The ID associated with the Genie space where the evaluation run is located. + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieListEvalRunsResponse struct { + // List of evaluation runs for a space on provided page token and page size + EvalRuns []GenieEvalRunResponse `json:"eval_runs,omitempty"` + // The token to use for retrieving the next page of results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type GenieListMessageCommentsRequest struct { + // The ID associated with the conversation. + ConversationId *string `json:"conversation_id,omitempty"` + // The ID associated with the message. + MessageId *string `json:"message_id,omitempty"` + // Maximum number of comments to return per page. + PageSize *int `json:"page_size,omitempty"` + // Pagination token for getting the next page of results. + PageToken *string `json:"page_token,omitempty"` + // The ID associated with the Genie space. + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieListMessageCommentsResponse struct { + // List of comments on the message. + Comments []GenieMessageComment `json:"comments,omitempty"` + // Token to get the next page of results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type GenieListSpacesRequest struct { + // Maximum number of spaces to return per page + PageSize *int `json:"page_size,omitempty"` + // Pagination token for getting the next page of results + PageToken *string `json:"page_token,omitempty"` +} + +type GenieListSpacesResponse struct { + // Token to get the next page of results + NextPageToken *string `json:"next_page_token,omitempty"` + // List of Genie spaces + Spaces []GenieSpace `json:"spaces,omitempty"` +} + +type GenieMessage struct { + // AI-generated response to the message + Attachments []GenieAttachment `json:"attachments,omitempty"` + // User message content + Content *string `json:"content,omitempty"` + // Conversation ID + ConversationId *string `json:"conversation_id,omitempty"` + // Timestamp when the message was created + CreatedTimestamp *int64 `json:"created_timestamp,omitempty"` + // Error message if Genie failed to respond to the message + Error *MessageError `json:"error,omitempty"` + // User feedback for the message if provided + Feedback *GenieFeedback `json:"feedback,omitempty"` + // Message ID. Legacy identifier, use message_id instead + Id *string `json:"id,omitempty"` + // Timestamp when the message was last updated + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // Message ID + MessageId *string `json:"message_id,omitempty"` + // The result of SQL query if the message includes a query attachment. + // Deprecated. Use `query_result_metadata` in `GenieQueryAttachment` instead. + QueryResult *Result `json:"query_result,omitempty"` + // Genie space ID + SpaceId *string `json:"space_id,omitempty"` + Status MessageStatus_MessageStatus `json:"status,omitempty"` + // ID of the user who created the message + UserId *int64 `json:"user_id,omitempty"` +} + +// A comment on a Genie conversation message.. +type GenieMessageComment struct { + // Comment text content + Content *string `json:"content,omitempty"` + // Conversation ID + ConversationId *string `json:"conversation_id,omitempty"` + // Timestamp when the comment was created + CreatedTimestamp *int64 `json:"created_timestamp,omitempty"` + // Comment ID + MessageCommentId *string `json:"message_comment_id,omitempty"` + // Message ID + MessageId *string `json:"message_id,omitempty"` + // Genie space ID + SpaceId *string `json:"space_id,omitempty"` + // ID of the user who created the comment + UserId *int64 `json:"user_id,omitempty"` +} + +type GenieQueryAttachment struct { + // Description of the query + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + // Time when the user updated the query last + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + Parameters []QueryAttachmentParameter `json:"parameters,omitempty"` + // AI generated SQL query + Query *string `json:"query,omitempty"` + // Metadata associated with the query result. + QueryResultMetadata *GenieResultMetadata `json:"query_result_metadata,omitempty"` + // Statement Execution API statement id. Use [Get status, manifest, and result + // first chunk](:method:statementexecution/getstatement) to get the full result + // data. + StatementId *string `json:"statement_id,omitempty"` + // Insights into how Genie came to generate the SQL. + Thoughts []Thought `json:"thoughts,omitempty"` + // Name of the query + Title *string `json:"title,omitempty"` +} + +type GenieResultMetadata struct { + // Indicates whether the result set is truncated. + IsTruncated *bool `json:"is_truncated,omitempty"` + // The number of rows in the result set. + RowCount *int64 `json:"row_count,omitempty"` +} + +type GenieSendMessageFeedbackRequest struct { + // Optional text feedback that will be stored as a comment. + Comment *string `json:"comment,omitempty"` + // The ID associated with the conversation. + ConversationId *string `json:"conversation_id,omitempty"` + // The ID associated with the message to provide feedback for. + MessageId *string `json:"message_id,omitempty"` + // The rating (POSITIVE, NEGATIVE, or NONE). + Rating GenieFeedbackRating `json:"rating,omitempty"` + // The ID associated with the Genie space where the message is located. + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieSpace struct { + // Time when the Genie space was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Description of the Genie Space + Description *string `json:"description,omitempty"` + // ETag for this space. Pass this value back in the update request to prevent + // overwriting concurrent changes. + Etag *string `json:"etag,omitempty"` + // Parent folder path of the Genie Space + ParentPath *string `json:"parent_path,omitempty"` + // The contents of the Genie Space in serialized string form. This field is + // excluded in List Genie spaces responses. Use the [Get Genie + // Space](:method:genie/getspace) API to retrieve an example response, which + // includes the `serialized_space` field. This field provides the structure of + // the JSON string that represents the space's layout and components. + SerializedSpace *string `json:"serialized_space,omitempty"` + // Genie space ID + SpaceId *string `json:"space_id,omitempty"` + // Title of the Genie Space + Title *string `json:"title,omitempty"` + // Time when the Genie space was last modified, matching the value shown in the + // Genie Agent UI. + UpdateTime *types.Time `json:"update_time,omitempty"` + // Warehouse associated with the Genie Space + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type GenieStartConversationRequest struct { + // The text of the message that starts the conversation. + Content *string `json:"content,omitempty"` + // Enable visualization generation. + EnableVisualization *bool `json:"enable_visualization,omitempty"` + // The ID associated with the Genie space where you want to start a + // conversation. + SpaceId *string `json:"space_id,omitempty"` +} + +type GenieStartConversationResponse struct { + Conversation *GenieConversation `json:"conversation,omitempty"` + // Conversation ID + ConversationId *string `json:"conversation_id,omitempty"` + Message *GenieMessage `json:"message,omitempty"` + // Message ID + MessageId *string `json:"message_id,omitempty"` +} + +// Follow-up questions suggested by Genie. +type GenieSuggestedQuestionsAttachment struct { + // The suggested follow-up questions + Questions []string `json:"questions,omitempty"` +} + +type GenieUpdateSpaceRequest struct { + // Optional description + Description *string `json:"description,omitempty"` + // ETag returned by a previous GET or UPDATE. When set, the update will fail if + // the space has been modified since. Omit to apply the update unconditionally. + Etag *string `json:"etag,omitempty"` + // Parent workspace folder path to move this Genie space under. + ParentPath *string `json:"parent_path,omitempty"` + // The contents of the Genie Space in serialized string form (full replacement). + // Use the [Get Genie Space](:method:genie/getspace) API to retrieve an example + // response, which includes the `serialized_space` field. This field provides + // the structure of the JSON string that represents the space's layout and + // components. + SerializedSpace *string `json:"serialized_space,omitempty"` + // Genie space ID + SpaceId *string `json:"space_id,omitempty"` + // Optional title override + Title *string `json:"title,omitempty"` + // Optional warehouse override + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +// Visualization generated by Genie for a query result. Use the attachment ID +// with the download visualization API to retrieve the rendered image.. +type GenieVizAttachment struct { + // The ID of the query attachment the visualization was generated from + QueryAttachmentId *string `json:"query_attachment_id,omitempty"` + // Name of the visualization + Title *string `json:"title,omitempty"` +} + +// copied from proto3 / Google Well Known Types, source: +// https://github.com/protocolbuffers/protobuf/blob/450d24ca820750c5db5112a6f0b0c2efb9758021/src/google/protobuf/struct.proto +// `ListValue` is a wrapper around a repeated field of values. +// +// The JSON representation for `ListValue` is JSON array.. +type ListValue struct { + // Repeated field of dynamically typed values. + Values []Value `json:"values,omitempty"` +} + +// proto compiler is too old and does not support map. This is wire +// compatible with map. See +// https://developers.google.com/protocol-buffers/docs/proto#backwards_compatibility.. +type MapStringValueEntry struct { + Key *string `json:"key,omitempty"` + Value *Value `json:"value,omitempty"` +} + +type MessageError struct { + Error *string `json:"error,omitempty"` + Type MessageError_Type `json:"type,omitempty"` +} + +// A positional argument passed to a row filter or column mask function. +// Distinguishes between column references and literals.. +type PolicyFunctionArgument struct { + Column *string `json:"column,omitempty"` + Constant *string `json:"constant,omitempty"` +} + +type QueryAttachmentParameter struct { + Keyword *string `json:"keyword,omitempty"` + SqlType *string `json:"sql_type,omitempty"` + Value *string `json:"value,omitempty"` +} + +type Result struct { + // If result is truncated + IsTruncated *bool `json:"is_truncated,omitempty"` + // Row count of the result + RowCount *int64 `json:"row_count,omitempty"` + // Statement Execution API statement id. Use [Get status, manifest, and result + // first chunk](:method:statementexecution/getstatement) to get the full result + // data. + StatementId *string `json:"statement_id,omitempty"` + // JWT corresponding to the statement contained in this result + StatementIdSignature *string `json:"statement_id_signature,omitempty"` +} + +// Contains the result data of a single chunk when using `INLINE` disposition. +// When using `EXTERNAL_LINKS` disposition, the array `external_links` is used +// instead to provide short-lived cloud-storage URLs to the result data in cloud +// storage. Exactly one of these alternatives is used. Calls to `getResultData` +// return the link for the requested chunk; `executeStatement` and +// `getStatementResult` responses can contain links for multiple chunks.. +type ResultData struct { + // The number of bytes in the result chunk. This field is not available when + // using `INLINE` disposition. + ByteCount *int64 `json:"byte_count,omitempty"` + // The position within the sequence of result set chunks. + ChunkIndex *int `json:"chunk_index,omitempty"` + // The `JSON_ARRAY` format is an array of arrays of values, where each non-null + // value is formatted as a string. Null values are encoded as JSON `null`. + DataArray []ListValue `json:"data_array,omitempty"` + ExternalLinks []ExternalLink `json:"external_links,omitempty"` + // When fetching, provides the `chunk_index` for the _next_ chunk. If absent, + // indicates there are no more chunks. The next chunk can be fetched with a + // :method:statementexecution/getstatementresultchunkn request. + NextChunkIndex *int `json:"next_chunk_index,omitempty"` + // When fetching, provides a link to fetch the _next_ chunk. If absent, + // indicates there are no more chunks. This link is an absolute `path` to be + // joined with your `$DATABRICKS_HOST`, and should be treated as an opaque link. + // This is an alternative to using `next_chunk_index`. + NextChunkInternalLink *string `json:"next_chunk_internal_link,omitempty"` + // The number of rows within the result chunk. + RowCount *int64 `json:"row_count,omitempty"` + // The starting row offset within the result set. + RowOffset *int64 `json:"row_offset,omitempty"` +} + +// The result manifest provides schema and metadata for the result set.. +type ResultManifest struct { + // Array of result set chunk metadata. + Chunks []ChunkInfo `json:"chunks,omitempty"` + Format Format `json:"format,omitempty"` + Schema *Schema `json:"schema,omitempty"` + // The total number of bytes in the result set. This field is not available when + // using `INLINE` disposition. + TotalByteCount *int64 `json:"total_byte_count,omitempty"` + // The total number of chunks that the result set has been divided into. + TotalChunkCount *int `json:"total_chunk_count,omitempty"` + // The total number of rows in the result set. + TotalRowCount *int64 `json:"total_row_count,omitempty"` + // Indicates whether the result is truncated due to `row_limit` or `byte_limit`. + Truncated *bool `json:"truncated,omitempty"` +} + +type Schema struct { + ColumnCount *int `json:"column_count,omitempty"` + Columns []ColumnInfo `json:"columns,omitempty"` +} + +type StatementResponse struct { + Manifest *ResultManifest `json:"manifest,omitempty"` + Result *ResultData `json:"result,omitempty"` + // The statement ID is returned upon successfully submitting a SQL statement, + // and is a required reference for all subsequent calls. + StatementId *string `json:"statement_id,omitempty"` + Status *StatementStatus `json:"status,omitempty"` +} + +// The status response includes execution state and if relevant, error +// information.. +type StatementStatus struct { + Error *DatabricksServiceExceptionProto `json:"error,omitempty"` + // SQLSTATE error code returned when the statement execution fails. Only + // populated when the statement status is `FAILED`. + SqlState *string `json:"sql_state,omitempty"` + // Statement execution state: - `PENDING`: waiting for warehouse - `RUNNING`: + // running - `SUCCEEDED`: execution was successful, result data available for + // fetch - `FAILED`: execution failed; reason for failure described in + // accompanying error message - `CANCELED`: user canceled; can come from + // explicit cancel call, or timeout with `on_wait_timeout=CANCEL` - `CLOSED`: + // execution successful, and statement closed; result no longer available for + // fetch + State StatementStatus_State `json:"state,omitempty"` +} + +// copied from proto3 / Google Well Known Types, source: +// https://github.com/protocolbuffers/protobuf/blob/450d24ca820750c5db5112a6f0b0c2efb9758021/src/google/protobuf/struct.proto +// `Struct` represents a structured data value, consisting of fields which map +// to dynamically typed values. In some languages, `Struct` might be supported +// by a native representation. For example, in scripting languages like JS a +// struct is represented as an object. The details of that representation are +// described together with the proto support for the language. +// +// The JSON representation for `Struct` is JSON object.. +type Struct struct { + // Unordered map of dynamically typed values. + Fields []MapStringValueEntry `json:"fields,omitempty"` +} + +// A text response on a conversation message: the answer, the final summary, or +// a clarifying follow-up question, along with optional phase and verification +// metadata.. +type TextAttachment struct { + // AI generated message + Content *string `json:"content,omitempty"` + Id *string `json:"id,omitempty"` + // Purpose of this text attachment. A completed message may contain more than + // one text attachment (for example a clarifying follow-up question alongside + // the final answer); use this field to tell them apart. + // `TEXT_ATTACHMENT_PURPOSE_ANSWER` marks the final answer/summary and + // `FOLLOW_UP_QUESTION` marks a clarifying question. + Purpose TextAttachmentPurpose `json:"purpose,omitempty"` +} + +// A single thought in the AI's reasoning process for a query.. +type Thought struct { + // The md formatted content for this thought. + Content *string `json:"content,omitempty"` + // The category of this thought. The possible values are: * + // `THOUGHT_TYPE_DESCRIPTION`: A high-level description of how the question was + // interpreted. * `THOUGHT_TYPE_UNDERSTANDING`: How ambiguous parts of the + // question were resolved. * `THOUGHT_TYPE_DATA_SOURCING`: Which tables or + // datasets were identified as relevant. * `THOUGHT_TYPE_INSTRUCTIONS`: Which + // author-defined instructions were referenced. * `THOUGHT_TYPE_STEPS`: The + // logical steps taken to compute the answer. + ThoughtType ThoughtType `json:"thought_type,omitempty"` +} + +// copied from proto3 / Google Well Known Types, source: +// https://github.com/protocolbuffers/protobuf/blob/450d24ca820750c5db5112a6f0b0c2efb9758021/src/google/protobuf/struct.proto +// `Value` represents a dynamically typed value which can be either null, a +// number, a string, a boolean, a recursive struct value, or a list of values. A +// producer of value is expected to set one of these variants. Absence of any +// variant indicates an error. +// +// The JSON representation for `Value` is JSON value.. +type Value struct { + BoolValue *bool `json:"bool_value,omitempty"` + ListValue *ListValue `json:"list_value,omitempty"` + NullValue NullValue `json:"null_value,omitempty"` + NumberValue *float64 `json:"number_value,omitempty"` + StringValue *string `json:"string_value,omitempty"` + StructValue *Struct `json:"struct_value,omitempty"` +} + +// ChunkInfoToSDK converts the mirror to the sdk-go type. +func ChunkInfoToSDK(w *ChunkInfo) (*sdk.ChunkInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ChunkInfo{} + out.ChunkIndex = w.ChunkIndex + out.RowOffset = w.RowOffset + out.RowCount = w.RowCount + out.ByteCount = w.ByteCount + out.NextChunkIndex = w.NextChunkIndex + out.NextChunkInternalLink = w.NextChunkInternalLink + return out, nil +} + +// ChunkInfoFromSDK converts the sdk-go type to the mirror. +func ChunkInfoFromSDK(v *sdk.ChunkInfo) (*ChunkInfo, error) { + if v == nil { + return nil, nil + } + out := &ChunkInfo{} + out.ChunkIndex = v.ChunkIndex + out.RowOffset = v.RowOffset + out.RowCount = v.RowCount + out.ByteCount = v.ByteCount + out.NextChunkIndex = v.NextChunkIndex + out.NextChunkInternalLink = v.NextChunkInternalLink + return out, nil +} + +// ColumnInfoToSDK converts the mirror to the sdk-go type. +func ColumnInfoToSDK(w *ColumnInfo) (*sdk.ColumnInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnInfo{} + out.Name = w.Name + out.TypeText = w.TypeText + out.TypeName = w.TypeName + out.Position = w.Position + out.TypePrecision = w.TypePrecision + out.TypeScale = w.TypeScale + out.TypeIntervalType = w.TypeIntervalType + out.TypeJson = w.TypeJson + out.Comment = w.Comment + out.Nullable = w.Nullable + out.PartitionIndex = w.PartitionIndex + conv1, err := ColumnMaskToSDK(w.Mask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnInfo.Mask", err) + } + out.Mask = conv1 + return out, nil +} + +// ColumnInfoFromSDK converts the sdk-go type to the mirror. +func ColumnInfoFromSDK(v *sdk.ColumnInfo) (*ColumnInfo, error) { + if v == nil { + return nil, nil + } + out := &ColumnInfo{} + out.Name = v.Name + out.TypeText = v.TypeText + out.TypeName = v.TypeName + out.Position = v.Position + out.TypePrecision = v.TypePrecision + out.TypeScale = v.TypeScale + out.TypeIntervalType = v.TypeIntervalType + out.TypeJson = v.TypeJson + out.Comment = v.Comment + out.Nullable = v.Nullable + out.PartitionIndex = v.PartitionIndex + conv2, err := ColumnMaskFromSDK(v.Mask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnInfo.Mask", err) + } + out.Mask = conv2 + return out, nil +} + +// ColumnMaskToSDK converts the mirror to the sdk-go type. +func ColumnMaskToSDK(w *ColumnMask) (*sdk.ColumnMask, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnMask{} + out.FunctionName = w.FunctionName + out.UsingColumnNames = w.UsingColumnNames + conv3, err := convertSlice(w.UsingArguments, PolicyFunctionArgumentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnMask.UsingArguments", err) + } + out.UsingArguments = conv3 + return out, nil +} + +// ColumnMaskFromSDK converts the sdk-go type to the mirror. +func ColumnMaskFromSDK(v *sdk.ColumnMask) (*ColumnMask, error) { + if v == nil { + return nil, nil + } + out := &ColumnMask{} + out.FunctionName = v.FunctionName + out.UsingColumnNames = v.UsingColumnNames + conv4, err := convertSlice(v.UsingArguments, PolicyFunctionArgumentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnMask.UsingArguments", err) + } + out.UsingArguments = conv4 + return out, nil +} + +// DatabricksServiceExceptionProtoToSDK converts the mirror to the sdk-go type. +func DatabricksServiceExceptionProtoToSDK(w *DatabricksServiceExceptionProto) (*sdk.DatabricksServiceExceptionProto, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabricksServiceExceptionProto{} + out.ErrorCode = w.ErrorCode + out.Message = w.Message + out.StackTrace = w.StackTrace + return out, nil +} + +// DatabricksServiceExceptionProtoFromSDK converts the sdk-go type to the mirror. +func DatabricksServiceExceptionProtoFromSDK(v *sdk.DatabricksServiceExceptionProto) (*DatabricksServiceExceptionProto, error) { + if v == nil { + return nil, nil + } + out := &DatabricksServiceExceptionProto{} + out.ErrorCode = v.ErrorCode + out.Message = v.Message + out.StackTrace = v.StackTrace + return out, nil +} + +// ExternalLinkToSDK converts the mirror to the sdk-go type. +func ExternalLinkToSDK(w *ExternalLink) (*sdk.ExternalLink, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalLink{} + out.ExternalLink = w.ExternalLink + out.Expiration = w.Expiration + out.HttpHeaders = w.HttpHeaders + out.ChunkIndex = w.ChunkIndex + out.RowOffset = w.RowOffset + out.RowCount = w.RowCount + out.ByteCount = w.ByteCount + out.NextChunkIndex = w.NextChunkIndex + out.NextChunkInternalLink = w.NextChunkInternalLink + return out, nil +} + +// ExternalLinkFromSDK converts the sdk-go type to the mirror. +func ExternalLinkFromSDK(v *sdk.ExternalLink) (*ExternalLink, error) { + if v == nil { + return nil, nil + } + out := &ExternalLink{} + out.ExternalLink = v.ExternalLink + out.Expiration = v.Expiration + out.HttpHeaders = v.HttpHeaders + out.ChunkIndex = v.ChunkIndex + out.RowOffset = v.RowOffset + out.RowCount = v.RowCount + out.ByteCount = v.ByteCount + out.NextChunkIndex = v.NextChunkIndex + out.NextChunkInternalLink = v.NextChunkInternalLink + return out, nil +} + +// GenieAttachmentToSDK converts the mirror to the sdk-go type. +func GenieAttachmentToSDK(w *GenieAttachment) (*sdk.GenieAttachment, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieAttachment{} + { + var members []string + if w.Text != nil { + members = append(members, "text") + } + if w.Query != nil { + members = append(members, "query") + } + if w.SuggestedQuestions != nil { + members = append(members, "suggested_questions") + } + if w.Viz != nil { + members = append(members, "viz") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Text != nil: + conv5, err := TextAttachmentToSDK(w.Text) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAttachment.Attachment", err) + } + out.Attachment = &sdk.GenieAttachment_Attachment_Text{Text: *conv5} + case w.Query != nil: + conv6, err := GenieQueryAttachmentToSDK(w.Query) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAttachment.Attachment", err) + } + out.Attachment = &sdk.GenieAttachment_Attachment_Query{Query: *conv6} + case w.SuggestedQuestions != nil: + conv7, err := GenieSuggestedQuestionsAttachmentToSDK(w.SuggestedQuestions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAttachment.Attachment", err) + } + out.Attachment = &sdk.GenieAttachment_Attachment_SuggestedQuestions{SuggestedQuestions: *conv7} + case w.Viz != nil: + conv8, err := GenieVizAttachmentToSDK(w.Viz) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAttachment.Attachment", err) + } + out.Attachment = &sdk.GenieAttachment_Attachment_Viz{Viz: *conv8} + } + out.AttachmentId = w.AttachmentId + return out, nil +} + +// GenieAttachmentFromSDK converts the sdk-go type to the mirror. +func GenieAttachmentFromSDK(v *sdk.GenieAttachment) (*GenieAttachment, error) { + if v == nil { + return nil, nil + } + out := &GenieAttachment{} + switch value := v.Attachment.(type) { + case *sdk.GenieAttachment_Attachment_Text: + if value != nil { + conv9, err := TextAttachmentFromSDK(&value.Text) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAttachment.Attachment", err) + } + out.Text = conv9 + } + case *sdk.GenieAttachment_Attachment_Query: + if value != nil { + conv10, err := GenieQueryAttachmentFromSDK(&value.Query) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAttachment.Attachment", err) + } + out.Query = conv10 + } + case *sdk.GenieAttachment_Attachment_SuggestedQuestions: + if value != nil { + conv11, err := GenieSuggestedQuestionsAttachmentFromSDK(&value.SuggestedQuestions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAttachment.Attachment", err) + } + out.SuggestedQuestions = conv11 + } + case *sdk.GenieAttachment_Attachment_Viz: + if value != nil { + conv12, err := GenieVizAttachmentFromSDK(&value.Viz) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieAttachment.Attachment", err) + } + out.Viz = conv12 + } + } + out.AttachmentId = v.AttachmentId + return out, nil +} + +// GenieCancelResponseRequestToSDK converts the mirror to the sdk-go type. +func GenieCancelResponseRequestToSDK(w *GenieCancelResponseRequest) (*sdk.GenieCancelResponseRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieCancelResponseRequest{} + out.AgentId = w.AgentId + out.ConversationId = w.ConversationId + out.ResponseId = w.ResponseId + return out, nil +} + +// GenieCancelResponseRequestFromSDK converts the sdk-go type to the mirror. +func GenieCancelResponseRequestFromSDK(v *sdk.GenieCancelResponseRequest) (*GenieCancelResponseRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieCancelResponseRequest{} + out.AgentId = v.AgentId + out.ConversationId = v.ConversationId + out.ResponseId = v.ResponseId + return out, nil +} + +// GenieConversationToSDK converts the mirror to the sdk-go type. +func GenieConversationToSDK(w *GenieConversation) (*sdk.GenieConversation, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieConversation{} + out.Id = w.Id + out.SpaceId = w.SpaceId + out.UserId = w.UserId + out.CreatedTimestamp = w.CreatedTimestamp + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + out.Title = w.Title + out.ConversationId = w.ConversationId + return out, nil +} + +// GenieConversationFromSDK converts the sdk-go type to the mirror. +func GenieConversationFromSDK(v *sdk.GenieConversation) (*GenieConversation, error) { + if v == nil { + return nil, nil + } + out := &GenieConversation{} + out.Id = v.Id + out.SpaceId = v.SpaceId + out.UserId = v.UserId + out.CreatedTimestamp = v.CreatedTimestamp + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + out.Title = v.Title + out.ConversationId = v.ConversationId + return out, nil +} + +// GenieConversationSummaryToSDK converts the mirror to the sdk-go type. +func GenieConversationSummaryToSDK(w *GenieConversationSummary) (*sdk.GenieConversationSummary, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieConversationSummary{} + out.ConversationId = w.ConversationId + out.Title = w.Title + out.CreatedTimestamp = w.CreatedTimestamp + out.AgentType = w.AgentType + return out, nil +} + +// GenieConversationSummaryFromSDK converts the sdk-go type to the mirror. +func GenieConversationSummaryFromSDK(v *sdk.GenieConversationSummary) (*GenieConversationSummary, error) { + if v == nil { + return nil, nil + } + out := &GenieConversationSummary{} + out.ConversationId = v.ConversationId + out.Title = v.Title + out.CreatedTimestamp = v.CreatedTimestamp + out.AgentType = v.AgentType + return out, nil +} + +// GenieCreateConversationMessageRequestToSDK converts the mirror to the sdk-go type. +func GenieCreateConversationMessageRequestToSDK(w *GenieCreateConversationMessageRequest) (*sdk.GenieCreateConversationMessageRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieCreateConversationMessageRequest{} + out.SpaceId = w.SpaceId + out.ConversationId = w.ConversationId + out.Content = w.Content + out.EnableVisualization = w.EnableVisualization + return out, nil +} + +// GenieCreateConversationMessageRequestFromSDK converts the sdk-go type to the mirror. +func GenieCreateConversationMessageRequestFromSDK(v *sdk.GenieCreateConversationMessageRequest) (*GenieCreateConversationMessageRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieCreateConversationMessageRequest{} + out.SpaceId = v.SpaceId + out.ConversationId = v.ConversationId + out.Content = v.Content + out.EnableVisualization = v.EnableVisualization + return out, nil +} + +// GenieCreateEvalRunRequestToSDK converts the mirror to the sdk-go type. +func GenieCreateEvalRunRequestToSDK(w *GenieCreateEvalRunRequest) (*sdk.GenieCreateEvalRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieCreateEvalRunRequest{} + out.SpaceId = w.SpaceId + out.BenchmarkQuestionIds = w.BenchmarkQuestionIds + return out, nil +} + +// GenieCreateEvalRunRequestFromSDK converts the sdk-go type to the mirror. +func GenieCreateEvalRunRequestFromSDK(v *sdk.GenieCreateEvalRunRequest) (*GenieCreateEvalRunRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieCreateEvalRunRequest{} + out.SpaceId = v.SpaceId + out.BenchmarkQuestionIds = v.BenchmarkQuestionIds + return out, nil +} + +// GenieCreateMessageCommentRequestToSDK converts the mirror to the sdk-go type. +func GenieCreateMessageCommentRequestToSDK(w *GenieCreateMessageCommentRequest) (*sdk.GenieCreateMessageCommentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieCreateMessageCommentRequest{} + out.SpaceId = w.SpaceId + out.ConversationId = w.ConversationId + out.MessageId = w.MessageId + out.Content = w.Content + return out, nil +} + +// GenieCreateMessageCommentRequestFromSDK converts the sdk-go type to the mirror. +func GenieCreateMessageCommentRequestFromSDK(v *sdk.GenieCreateMessageCommentRequest) (*GenieCreateMessageCommentRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieCreateMessageCommentRequest{} + out.SpaceId = v.SpaceId + out.ConversationId = v.ConversationId + out.MessageId = v.MessageId + out.Content = v.Content + return out, nil +} + +// GenieCreateSpaceRequestToSDK converts the mirror to the sdk-go type. +func GenieCreateSpaceRequestToSDK(w *GenieCreateSpaceRequest) (*sdk.GenieCreateSpaceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieCreateSpaceRequest{} + out.WarehouseId = w.WarehouseId + out.ParentPath = w.ParentPath + out.SerializedSpace = w.SerializedSpace + out.Title = w.Title + out.Description = w.Description + return out, nil +} + +// GenieCreateSpaceRequestFromSDK converts the sdk-go type to the mirror. +func GenieCreateSpaceRequestFromSDK(v *sdk.GenieCreateSpaceRequest) (*GenieCreateSpaceRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieCreateSpaceRequest{} + out.WarehouseId = v.WarehouseId + out.ParentPath = v.ParentPath + out.SerializedSpace = v.SerializedSpace + out.Title = v.Title + out.Description = v.Description + return out, nil +} + +// GenieEvalResponseToSDK converts the mirror to the sdk-go type. +func GenieEvalResponseToSDK(w *GenieEvalResponse) (*sdk.GenieEvalResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieEvalResponse{} + out.Response = w.Response + conv13, err := StatementResponseToSDK(w.SqlExecutionResult) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieEvalResponse.SqlExecutionResult", err) + } + out.SqlExecutionResult = conv13 + out.ResponseType = w.ResponseType + return out, nil +} + +// GenieEvalResponseFromSDK converts the sdk-go type to the mirror. +func GenieEvalResponseFromSDK(v *sdk.GenieEvalResponse) (*GenieEvalResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieEvalResponse{} + out.Response = v.Response + conv14, err := StatementResponseFromSDK(v.SqlExecutionResult) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieEvalResponse.SqlExecutionResult", err) + } + out.SqlExecutionResult = conv14 + out.ResponseType = v.ResponseType + return out, nil +} + +// GenieEvalResultToSDK converts the mirror to the sdk-go type. +func GenieEvalResultToSDK(w *GenieEvalResult) (*sdk.GenieEvalResult, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieEvalResult{} + out.ResultId = w.ResultId + out.SpaceId = w.SpaceId + out.BenchmarkQuestionId = w.BenchmarkQuestionId + out.Status = w.Status + out.Question = w.Question + out.BenchmarkAnswer = w.BenchmarkAnswer + out.CreatedByUser = w.CreatedByUser + return out, nil +} + +// GenieEvalResultFromSDK converts the sdk-go type to the mirror. +func GenieEvalResultFromSDK(v *sdk.GenieEvalResult) (*GenieEvalResult, error) { + if v == nil { + return nil, nil + } + out := &GenieEvalResult{} + out.ResultId = v.ResultId + out.SpaceId = v.SpaceId + out.BenchmarkQuestionId = v.BenchmarkQuestionId + out.Status = v.Status + out.Question = v.Question + out.BenchmarkAnswer = v.BenchmarkAnswer + out.CreatedByUser = v.CreatedByUser + return out, nil +} + +// GenieEvalResultDetailsToSDK converts the mirror to the sdk-go type. +func GenieEvalResultDetailsToSDK(w *GenieEvalResultDetails) (*sdk.GenieEvalResultDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieEvalResultDetails{} + out.ResultId = w.ResultId + out.SpaceId = w.SpaceId + out.BenchmarkQuestionId = w.BenchmarkQuestionId + out.EvalRunStatus = w.EvalRunStatus + out.Assessment = w.Assessment + out.ManualAssessment = w.ManualAssessment + out.AssessmentReasons = w.AssessmentReasons + conv15, err := convertSlice(w.ActualResponse, GenieEvalResponseToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieEvalResultDetails.ActualResponse", err) + } + out.ActualResponse = conv15 + conv16, err := convertSlice(w.ExpectedResponse, GenieEvalResponseToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieEvalResultDetails.ExpectedResponse", err) + } + out.ExpectedResponse = conv16 + return out, nil +} + +// GenieEvalResultDetailsFromSDK converts the sdk-go type to the mirror. +func GenieEvalResultDetailsFromSDK(v *sdk.GenieEvalResultDetails) (*GenieEvalResultDetails, error) { + if v == nil { + return nil, nil + } + out := &GenieEvalResultDetails{} + out.ResultId = v.ResultId + out.SpaceId = v.SpaceId + out.BenchmarkQuestionId = v.BenchmarkQuestionId + out.EvalRunStatus = v.EvalRunStatus + out.Assessment = v.Assessment + out.ManualAssessment = v.ManualAssessment + out.AssessmentReasons = v.AssessmentReasons + conv17, err := convertSlice(v.ActualResponse, GenieEvalResponseFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieEvalResultDetails.ActualResponse", err) + } + out.ActualResponse = conv17 + conv18, err := convertSlice(v.ExpectedResponse, GenieEvalResponseFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieEvalResultDetails.ExpectedResponse", err) + } + out.ExpectedResponse = conv18 + return out, nil +} + +// GenieEvalRunResponseToSDK converts the mirror to the sdk-go type. +func GenieEvalRunResponseToSDK(w *GenieEvalRunResponse) (*sdk.GenieEvalRunResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieEvalRunResponse{} + out.EvalRunId = w.EvalRunId + out.EvalRunStatus = w.EvalRunStatus + out.RunByUser = w.RunByUser + out.CreatedTimestamp = w.CreatedTimestamp + out.NumQuestions = w.NumQuestions + out.NumCorrect = w.NumCorrect + out.NumNeedsReview = w.NumNeedsReview + out.NumDone = w.NumDone + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + return out, nil +} + +// GenieEvalRunResponseFromSDK converts the sdk-go type to the mirror. +func GenieEvalRunResponseFromSDK(v *sdk.GenieEvalRunResponse) (*GenieEvalRunResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieEvalRunResponse{} + out.EvalRunId = v.EvalRunId + out.EvalRunStatus = v.EvalRunStatus + out.RunByUser = v.RunByUser + out.CreatedTimestamp = v.CreatedTimestamp + out.NumQuestions = v.NumQuestions + out.NumCorrect = v.NumCorrect + out.NumNeedsReview = v.NumNeedsReview + out.NumDone = v.NumDone + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + return out, nil +} + +// GenieExecuteMessageAttachmentQueryRequestToSDK converts the mirror to the sdk-go type. +func GenieExecuteMessageAttachmentQueryRequestToSDK(w *GenieExecuteMessageAttachmentQueryRequest) (*sdk.GenieExecuteMessageAttachmentQueryRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieExecuteMessageAttachmentQueryRequest{} + out.MessageId = w.MessageId + out.SpaceId = w.SpaceId + out.ConversationId = w.ConversationId + out.AttachmentId = w.AttachmentId + return out, nil +} + +// GenieExecuteMessageAttachmentQueryRequestFromSDK converts the sdk-go type to the mirror. +func GenieExecuteMessageAttachmentQueryRequestFromSDK(v *sdk.GenieExecuteMessageAttachmentQueryRequest) (*GenieExecuteMessageAttachmentQueryRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieExecuteMessageAttachmentQueryRequest{} + out.MessageId = v.MessageId + out.SpaceId = v.SpaceId + out.ConversationId = v.ConversationId + out.AttachmentId = v.AttachmentId + return out, nil +} + +// GenieExecuteMessageQueryRequestToSDK converts the mirror to the sdk-go type. +func GenieExecuteMessageQueryRequestToSDK(w *GenieExecuteMessageQueryRequest) (*sdk.GenieExecuteMessageQueryRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieExecuteMessageQueryRequest{} + out.MessageId = w.MessageId + out.SpaceId = w.SpaceId + out.ConversationId = w.ConversationId + return out, nil +} + +// GenieExecuteMessageQueryRequestFromSDK converts the sdk-go type to the mirror. +func GenieExecuteMessageQueryRequestFromSDK(v *sdk.GenieExecuteMessageQueryRequest) (*GenieExecuteMessageQueryRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieExecuteMessageQueryRequest{} + out.MessageId = v.MessageId + out.SpaceId = v.SpaceId + out.ConversationId = v.ConversationId + return out, nil +} + +// GenieFeedbackToSDK converts the mirror to the sdk-go type. +func GenieFeedbackToSDK(w *GenieFeedback) (*sdk.GenieFeedback, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieFeedback{} + out.Rating = w.Rating + out.Comment = w.Comment + return out, nil +} + +// GenieFeedbackFromSDK converts the sdk-go type to the mirror. +func GenieFeedbackFromSDK(v *sdk.GenieFeedback) (*GenieFeedback, error) { + if v == nil { + return nil, nil + } + out := &GenieFeedback{} + out.Rating = v.Rating + out.Comment = v.Comment + return out, nil +} + +// GenieGenerateDownloadFullQueryResultRequestToSDK converts the mirror to the sdk-go type. +func GenieGenerateDownloadFullQueryResultRequestToSDK(w *GenieGenerateDownloadFullQueryResultRequest) (*sdk.GenieGenerateDownloadFullQueryResultRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieGenerateDownloadFullQueryResultRequest{} + out.SpaceId = w.SpaceId + out.ConversationId = w.ConversationId + out.MessageId = w.MessageId + out.AttachmentId = w.AttachmentId + return out, nil +} + +// GenieGenerateDownloadFullQueryResultRequestFromSDK converts the sdk-go type to the mirror. +func GenieGenerateDownloadFullQueryResultRequestFromSDK(v *sdk.GenieGenerateDownloadFullQueryResultRequest) (*GenieGenerateDownloadFullQueryResultRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieGenerateDownloadFullQueryResultRequest{} + out.SpaceId = v.SpaceId + out.ConversationId = v.ConversationId + out.MessageId = v.MessageId + out.AttachmentId = v.AttachmentId + return out, nil +} + +// GenieGenerateDownloadFullQueryResultResponseToSDK converts the mirror to the sdk-go type. +func GenieGenerateDownloadFullQueryResultResponseToSDK(w *GenieGenerateDownloadFullQueryResultResponse) (*sdk.GenieGenerateDownloadFullQueryResultResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieGenerateDownloadFullQueryResultResponse{} + out.DownloadId = w.DownloadId + out.DownloadIdSignature = w.DownloadIdSignature + return out, nil +} + +// GenieGenerateDownloadFullQueryResultResponseFromSDK converts the sdk-go type to the mirror. +func GenieGenerateDownloadFullQueryResultResponseFromSDK(v *sdk.GenieGenerateDownloadFullQueryResultResponse) (*GenieGenerateDownloadFullQueryResultResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieGenerateDownloadFullQueryResultResponse{} + out.DownloadId = v.DownloadId + out.DownloadIdSignature = v.DownloadIdSignature + return out, nil +} + +// GenieGetDownloadFullQueryResultRequestToSDK converts the mirror to the sdk-go type. +func GenieGetDownloadFullQueryResultRequestToSDK(w *GenieGetDownloadFullQueryResultRequest) (*sdk.GenieGetDownloadFullQueryResultRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieGetDownloadFullQueryResultRequest{} + out.SpaceId = w.SpaceId + out.ConversationId = w.ConversationId + out.MessageId = w.MessageId + out.AttachmentId = w.AttachmentId + out.DownloadId = w.DownloadId + out.DownloadIdSignature = w.DownloadIdSignature + return out, nil +} + +// GenieGetDownloadFullQueryResultRequestFromSDK converts the sdk-go type to the mirror. +func GenieGetDownloadFullQueryResultRequestFromSDK(v *sdk.GenieGetDownloadFullQueryResultRequest) (*GenieGetDownloadFullQueryResultRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieGetDownloadFullQueryResultRequest{} + out.SpaceId = v.SpaceId + out.ConversationId = v.ConversationId + out.MessageId = v.MessageId + out.AttachmentId = v.AttachmentId + out.DownloadId = v.DownloadId + out.DownloadIdSignature = v.DownloadIdSignature + return out, nil +} + +// GenieGetDownloadFullQueryResultResponseToSDK converts the mirror to the sdk-go type. +func GenieGetDownloadFullQueryResultResponseToSDK(w *GenieGetDownloadFullQueryResultResponse) (*sdk.GenieGetDownloadFullQueryResultResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieGetDownloadFullQueryResultResponse{} + conv19, err := StatementResponseToSDK(w.StatementResponse) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieGetDownloadFullQueryResultResponse.StatementResponse", err) + } + out.StatementResponse = conv19 + return out, nil +} + +// GenieGetDownloadFullQueryResultResponseFromSDK converts the sdk-go type to the mirror. +func GenieGetDownloadFullQueryResultResponseFromSDK(v *sdk.GenieGetDownloadFullQueryResultResponse) (*GenieGetDownloadFullQueryResultResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieGetDownloadFullQueryResultResponse{} + conv20, err := StatementResponseFromSDK(v.StatementResponse) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieGetDownloadFullQueryResultResponse.StatementResponse", err) + } + out.StatementResponse = conv20 + return out, nil +} + +// GenieGetMessageQueryResultResponseToSDK converts the mirror to the sdk-go type. +func GenieGetMessageQueryResultResponseToSDK(w *GenieGetMessageQueryResultResponse) (*sdk.GenieGetMessageQueryResultResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieGetMessageQueryResultResponse{} + conv21, err := StatementResponseToSDK(w.StatementResponse) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieGetMessageQueryResultResponse.StatementResponse", err) + } + out.StatementResponse = conv21 + return out, nil +} + +// GenieGetMessageQueryResultResponseFromSDK converts the sdk-go type to the mirror. +func GenieGetMessageQueryResultResponseFromSDK(v *sdk.GenieGetMessageQueryResultResponse) (*GenieGetMessageQueryResultResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieGetMessageQueryResultResponse{} + conv22, err := StatementResponseFromSDK(v.StatementResponse) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieGetMessageQueryResultResponse.StatementResponse", err) + } + out.StatementResponse = conv22 + return out, nil +} + +// GenieGetSpaceRequestToSDK converts the mirror to the sdk-go type. +func GenieGetSpaceRequestToSDK(w *GenieGetSpaceRequest) (*sdk.GenieGetSpaceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieGetSpaceRequest{} + out.SpaceId = w.SpaceId + out.IncludeSerializedSpace = w.IncludeSerializedSpace + return out, nil +} + +// GenieGetSpaceRequestFromSDK converts the sdk-go type to the mirror. +func GenieGetSpaceRequestFromSDK(v *sdk.GenieGetSpaceRequest) (*GenieGetSpaceRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieGetSpaceRequest{} + out.SpaceId = v.SpaceId + out.IncludeSerializedSpace = v.IncludeSerializedSpace + return out, nil +} + +// GenieListConversationCommentsRequestToSDK converts the mirror to the sdk-go type. +func GenieListConversationCommentsRequestToSDK(w *GenieListConversationCommentsRequest) (*sdk.GenieListConversationCommentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListConversationCommentsRequest{} + out.SpaceId = w.SpaceId + out.ConversationId = w.ConversationId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// GenieListConversationCommentsRequestFromSDK converts the sdk-go type to the mirror. +func GenieListConversationCommentsRequestFromSDK(v *sdk.GenieListConversationCommentsRequest) (*GenieListConversationCommentsRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieListConversationCommentsRequest{} + out.SpaceId = v.SpaceId + out.ConversationId = v.ConversationId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// GenieListConversationCommentsResponseToSDK converts the mirror to the sdk-go type. +func GenieListConversationCommentsResponseToSDK(w *GenieListConversationCommentsResponse) (*sdk.GenieListConversationCommentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListConversationCommentsResponse{} + conv23, err := convertSlice(w.Comments, GenieMessageCommentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListConversationCommentsResponse.Comments", err) + } + out.Comments = conv23 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GenieListConversationCommentsResponseFromSDK converts the sdk-go type to the mirror. +func GenieListConversationCommentsResponseFromSDK(v *sdk.GenieListConversationCommentsResponse) (*GenieListConversationCommentsResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieListConversationCommentsResponse{} + conv24, err := convertSlice(v.Comments, GenieMessageCommentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListConversationCommentsResponse.Comments", err) + } + out.Comments = conv24 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GenieListConversationMessagesRequestToSDK converts the mirror to the sdk-go type. +func GenieListConversationMessagesRequestToSDK(w *GenieListConversationMessagesRequest) (*sdk.GenieListConversationMessagesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListConversationMessagesRequest{} + out.SpaceId = w.SpaceId + out.ConversationId = w.ConversationId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// GenieListConversationMessagesRequestFromSDK converts the sdk-go type to the mirror. +func GenieListConversationMessagesRequestFromSDK(v *sdk.GenieListConversationMessagesRequest) (*GenieListConversationMessagesRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieListConversationMessagesRequest{} + out.SpaceId = v.SpaceId + out.ConversationId = v.ConversationId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// GenieListConversationMessagesResponseToSDK converts the mirror to the sdk-go type. +func GenieListConversationMessagesResponseToSDK(w *GenieListConversationMessagesResponse) (*sdk.GenieListConversationMessagesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListConversationMessagesResponse{} + conv25, err := convertSlice(w.Messages, GenieMessageToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListConversationMessagesResponse.Messages", err) + } + out.Messages = conv25 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GenieListConversationMessagesResponseFromSDK converts the sdk-go type to the mirror. +func GenieListConversationMessagesResponseFromSDK(v *sdk.GenieListConversationMessagesResponse) (*GenieListConversationMessagesResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieListConversationMessagesResponse{} + conv26, err := convertSlice(v.Messages, GenieMessageFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListConversationMessagesResponse.Messages", err) + } + out.Messages = conv26 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GenieListConversationsRequestToSDK converts the mirror to the sdk-go type. +func GenieListConversationsRequestToSDK(w *GenieListConversationsRequest) (*sdk.GenieListConversationsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListConversationsRequest{} + out.SpaceId = w.SpaceId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + out.IncludeAll = w.IncludeAll + return out, nil +} + +// GenieListConversationsRequestFromSDK converts the sdk-go type to the mirror. +func GenieListConversationsRequestFromSDK(v *sdk.GenieListConversationsRequest) (*GenieListConversationsRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieListConversationsRequest{} + out.SpaceId = v.SpaceId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + out.IncludeAll = v.IncludeAll + return out, nil +} + +// GenieListConversationsResponseToSDK converts the mirror to the sdk-go type. +func GenieListConversationsResponseToSDK(w *GenieListConversationsResponse) (*sdk.GenieListConversationsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListConversationsResponse{} + conv27, err := convertSlice(w.Conversations, GenieConversationSummaryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListConversationsResponse.Conversations", err) + } + out.Conversations = conv27 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GenieListConversationsResponseFromSDK converts the sdk-go type to the mirror. +func GenieListConversationsResponseFromSDK(v *sdk.GenieListConversationsResponse) (*GenieListConversationsResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieListConversationsResponse{} + conv28, err := convertSlice(v.Conversations, GenieConversationSummaryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListConversationsResponse.Conversations", err) + } + out.Conversations = conv28 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GenieListEvalResultsRequestToSDK converts the mirror to the sdk-go type. +func GenieListEvalResultsRequestToSDK(w *GenieListEvalResultsRequest) (*sdk.GenieListEvalResultsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListEvalResultsRequest{} + out.SpaceId = w.SpaceId + out.EvalRunId = w.EvalRunId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// GenieListEvalResultsRequestFromSDK converts the sdk-go type to the mirror. +func GenieListEvalResultsRequestFromSDK(v *sdk.GenieListEvalResultsRequest) (*GenieListEvalResultsRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieListEvalResultsRequest{} + out.SpaceId = v.SpaceId + out.EvalRunId = v.EvalRunId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// GenieListEvalResultsResponseToSDK converts the mirror to the sdk-go type. +func GenieListEvalResultsResponseToSDK(w *GenieListEvalResultsResponse) (*sdk.GenieListEvalResultsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListEvalResultsResponse{} + conv29, err := convertSlice(w.EvalResults, GenieEvalResultToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListEvalResultsResponse.EvalResults", err) + } + out.EvalResults = conv29 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GenieListEvalResultsResponseFromSDK converts the sdk-go type to the mirror. +func GenieListEvalResultsResponseFromSDK(v *sdk.GenieListEvalResultsResponse) (*GenieListEvalResultsResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieListEvalResultsResponse{} + conv30, err := convertSlice(v.EvalResults, GenieEvalResultFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListEvalResultsResponse.EvalResults", err) + } + out.EvalResults = conv30 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GenieListEvalRunsRequestToSDK converts the mirror to the sdk-go type. +func GenieListEvalRunsRequestToSDK(w *GenieListEvalRunsRequest) (*sdk.GenieListEvalRunsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListEvalRunsRequest{} + out.SpaceId = w.SpaceId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// GenieListEvalRunsRequestFromSDK converts the sdk-go type to the mirror. +func GenieListEvalRunsRequestFromSDK(v *sdk.GenieListEvalRunsRequest) (*GenieListEvalRunsRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieListEvalRunsRequest{} + out.SpaceId = v.SpaceId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// GenieListEvalRunsResponseToSDK converts the mirror to the sdk-go type. +func GenieListEvalRunsResponseToSDK(w *GenieListEvalRunsResponse) (*sdk.GenieListEvalRunsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListEvalRunsResponse{} + conv31, err := convertSlice(w.EvalRuns, GenieEvalRunResponseToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListEvalRunsResponse.EvalRuns", err) + } + out.EvalRuns = conv31 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GenieListEvalRunsResponseFromSDK converts the sdk-go type to the mirror. +func GenieListEvalRunsResponseFromSDK(v *sdk.GenieListEvalRunsResponse) (*GenieListEvalRunsResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieListEvalRunsResponse{} + conv32, err := convertSlice(v.EvalRuns, GenieEvalRunResponseFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListEvalRunsResponse.EvalRuns", err) + } + out.EvalRuns = conv32 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GenieListMessageCommentsRequestToSDK converts the mirror to the sdk-go type. +func GenieListMessageCommentsRequestToSDK(w *GenieListMessageCommentsRequest) (*sdk.GenieListMessageCommentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListMessageCommentsRequest{} + out.SpaceId = w.SpaceId + out.ConversationId = w.ConversationId + out.MessageId = w.MessageId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// GenieListMessageCommentsRequestFromSDK converts the sdk-go type to the mirror. +func GenieListMessageCommentsRequestFromSDK(v *sdk.GenieListMessageCommentsRequest) (*GenieListMessageCommentsRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieListMessageCommentsRequest{} + out.SpaceId = v.SpaceId + out.ConversationId = v.ConversationId + out.MessageId = v.MessageId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// GenieListMessageCommentsResponseToSDK converts the mirror to the sdk-go type. +func GenieListMessageCommentsResponseToSDK(w *GenieListMessageCommentsResponse) (*sdk.GenieListMessageCommentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListMessageCommentsResponse{} + conv33, err := convertSlice(w.Comments, GenieMessageCommentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListMessageCommentsResponse.Comments", err) + } + out.Comments = conv33 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GenieListMessageCommentsResponseFromSDK converts the sdk-go type to the mirror. +func GenieListMessageCommentsResponseFromSDK(v *sdk.GenieListMessageCommentsResponse) (*GenieListMessageCommentsResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieListMessageCommentsResponse{} + conv34, err := convertSlice(v.Comments, GenieMessageCommentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListMessageCommentsResponse.Comments", err) + } + out.Comments = conv34 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GenieListSpacesRequestToSDK converts the mirror to the sdk-go type. +func GenieListSpacesRequestToSDK(w *GenieListSpacesRequest) (*sdk.GenieListSpacesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListSpacesRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// GenieListSpacesRequestFromSDK converts the sdk-go type to the mirror. +func GenieListSpacesRequestFromSDK(v *sdk.GenieListSpacesRequest) (*GenieListSpacesRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieListSpacesRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// GenieListSpacesResponseToSDK converts the mirror to the sdk-go type. +func GenieListSpacesResponseToSDK(w *GenieListSpacesResponse) (*sdk.GenieListSpacesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieListSpacesResponse{} + conv35, err := convertSlice(w.Spaces, GenieSpaceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListSpacesResponse.Spaces", err) + } + out.Spaces = conv35 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GenieListSpacesResponseFromSDK converts the sdk-go type to the mirror. +func GenieListSpacesResponseFromSDK(v *sdk.GenieListSpacesResponse) (*GenieListSpacesResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieListSpacesResponse{} + conv36, err := convertSlice(v.Spaces, GenieSpaceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieListSpacesResponse.Spaces", err) + } + out.Spaces = conv36 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GenieMessageToSDK converts the mirror to the sdk-go type. +func GenieMessageToSDK(w *GenieMessage) (*sdk.GenieMessage, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieMessage{} + out.Id = w.Id + out.SpaceId = w.SpaceId + out.ConversationId = w.ConversationId + out.UserId = w.UserId + out.CreatedTimestamp = w.CreatedTimestamp + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + out.Status = w.Status + out.Content = w.Content + conv37, err := convertSlice(w.Attachments, GenieAttachmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieMessage.Attachments", err) + } + out.Attachments = conv37 + conv38, err := ResultToSDK(w.QueryResult) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieMessage.QueryResult", err) + } + out.QueryResult = conv38 + conv39, err := MessageErrorToSDK(w.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieMessage.Error", err) + } + out.Error = conv39 + out.MessageId = w.MessageId + conv40, err := GenieFeedbackToSDK(w.Feedback) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieMessage.Feedback", err) + } + out.Feedback = conv40 + return out, nil +} + +// GenieMessageFromSDK converts the sdk-go type to the mirror. +func GenieMessageFromSDK(v *sdk.GenieMessage) (*GenieMessage, error) { + if v == nil { + return nil, nil + } + out := &GenieMessage{} + out.Id = v.Id + out.SpaceId = v.SpaceId + out.ConversationId = v.ConversationId + out.UserId = v.UserId + out.CreatedTimestamp = v.CreatedTimestamp + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + out.Status = v.Status + out.Content = v.Content + conv41, err := convertSlice(v.Attachments, GenieAttachmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieMessage.Attachments", err) + } + out.Attachments = conv41 + conv42, err := ResultFromSDK(v.QueryResult) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieMessage.QueryResult", err) + } + out.QueryResult = conv42 + conv43, err := MessageErrorFromSDK(v.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieMessage.Error", err) + } + out.Error = conv43 + out.MessageId = v.MessageId + conv44, err := GenieFeedbackFromSDK(v.Feedback) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieMessage.Feedback", err) + } + out.Feedback = conv44 + return out, nil +} + +// GenieMessageCommentToSDK converts the mirror to the sdk-go type. +func GenieMessageCommentToSDK(w *GenieMessageComment) (*sdk.GenieMessageComment, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieMessageComment{} + out.SpaceId = w.SpaceId + out.ConversationId = w.ConversationId + out.MessageId = w.MessageId + out.MessageCommentId = w.MessageCommentId + out.UserId = w.UserId + out.Content = w.Content + out.CreatedTimestamp = w.CreatedTimestamp + return out, nil +} + +// GenieMessageCommentFromSDK converts the sdk-go type to the mirror. +func GenieMessageCommentFromSDK(v *sdk.GenieMessageComment) (*GenieMessageComment, error) { + if v == nil { + return nil, nil + } + out := &GenieMessageComment{} + out.SpaceId = v.SpaceId + out.ConversationId = v.ConversationId + out.MessageId = v.MessageId + out.MessageCommentId = v.MessageCommentId + out.UserId = v.UserId + out.Content = v.Content + out.CreatedTimestamp = v.CreatedTimestamp + return out, nil +} + +// GenieQueryAttachmentToSDK converts the mirror to the sdk-go type. +func GenieQueryAttachmentToSDK(w *GenieQueryAttachment) (*sdk.GenieQueryAttachment, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieQueryAttachment{} + out.Title = w.Title + out.Query = w.Query + out.Description = w.Description + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + conv45, err := convertSlice(w.Parameters, QueryAttachmentParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieQueryAttachment.Parameters", err) + } + out.Parameters = conv45 + out.Id = w.Id + out.StatementId = w.StatementId + conv46, err := GenieResultMetadataToSDK(w.QueryResultMetadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieQueryAttachment.QueryResultMetadata", err) + } + out.QueryResultMetadata = conv46 + conv47, err := convertSlice(w.Thoughts, ThoughtToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieQueryAttachment.Thoughts", err) + } + out.Thoughts = conv47 + return out, nil +} + +// GenieQueryAttachmentFromSDK converts the sdk-go type to the mirror. +func GenieQueryAttachmentFromSDK(v *sdk.GenieQueryAttachment) (*GenieQueryAttachment, error) { + if v == nil { + return nil, nil + } + out := &GenieQueryAttachment{} + out.Title = v.Title + out.Query = v.Query + out.Description = v.Description + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + conv48, err := convertSlice(v.Parameters, QueryAttachmentParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieQueryAttachment.Parameters", err) + } + out.Parameters = conv48 + out.Id = v.Id + out.StatementId = v.StatementId + conv49, err := GenieResultMetadataFromSDK(v.QueryResultMetadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieQueryAttachment.QueryResultMetadata", err) + } + out.QueryResultMetadata = conv49 + conv50, err := convertSlice(v.Thoughts, ThoughtFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieQueryAttachment.Thoughts", err) + } + out.Thoughts = conv50 + return out, nil +} + +// GenieResultMetadataToSDK converts the mirror to the sdk-go type. +func GenieResultMetadataToSDK(w *GenieResultMetadata) (*sdk.GenieResultMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieResultMetadata{} + out.RowCount = w.RowCount + out.IsTruncated = w.IsTruncated + return out, nil +} + +// GenieResultMetadataFromSDK converts the sdk-go type to the mirror. +func GenieResultMetadataFromSDK(v *sdk.GenieResultMetadata) (*GenieResultMetadata, error) { + if v == nil { + return nil, nil + } + out := &GenieResultMetadata{} + out.RowCount = v.RowCount + out.IsTruncated = v.IsTruncated + return out, nil +} + +// GenieSendMessageFeedbackRequestToSDK converts the mirror to the sdk-go type. +func GenieSendMessageFeedbackRequestToSDK(w *GenieSendMessageFeedbackRequest) (*sdk.GenieSendMessageFeedbackRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieSendMessageFeedbackRequest{} + out.SpaceId = w.SpaceId + out.ConversationId = w.ConversationId + out.MessageId = w.MessageId + out.Rating = w.Rating + out.Comment = w.Comment + return out, nil +} + +// GenieSendMessageFeedbackRequestFromSDK converts the sdk-go type to the mirror. +func GenieSendMessageFeedbackRequestFromSDK(v *sdk.GenieSendMessageFeedbackRequest) (*GenieSendMessageFeedbackRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieSendMessageFeedbackRequest{} + out.SpaceId = v.SpaceId + out.ConversationId = v.ConversationId + out.MessageId = v.MessageId + out.Rating = v.Rating + out.Comment = v.Comment + return out, nil +} + +// GenieSpaceToSDK converts the mirror to the sdk-go type. +func GenieSpaceToSDK(w *GenieSpace) (*sdk.GenieSpace, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieSpace{} + out.SpaceId = w.SpaceId + out.Title = w.Title + out.Description = w.Description + out.WarehouseId = w.WarehouseId + out.ParentPath = w.ParentPath + out.SerializedSpace = w.SerializedSpace + out.Etag = w.Etag + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + return out, nil +} + +// GenieSpaceFromSDK converts the sdk-go type to the mirror. +func GenieSpaceFromSDK(v *sdk.GenieSpace) (*GenieSpace, error) { + if v == nil { + return nil, nil + } + out := &GenieSpace{} + out.SpaceId = v.SpaceId + out.Title = v.Title + out.Description = v.Description + out.WarehouseId = v.WarehouseId + out.ParentPath = v.ParentPath + out.SerializedSpace = v.SerializedSpace + out.Etag = v.Etag + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + return out, nil +} + +// GenieStartConversationRequestToSDK converts the mirror to the sdk-go type. +func GenieStartConversationRequestToSDK(w *GenieStartConversationRequest) (*sdk.GenieStartConversationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieStartConversationRequest{} + out.SpaceId = w.SpaceId + out.Content = w.Content + out.EnableVisualization = w.EnableVisualization + return out, nil +} + +// GenieStartConversationRequestFromSDK converts the sdk-go type to the mirror. +func GenieStartConversationRequestFromSDK(v *sdk.GenieStartConversationRequest) (*GenieStartConversationRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieStartConversationRequest{} + out.SpaceId = v.SpaceId + out.Content = v.Content + out.EnableVisualization = v.EnableVisualization + return out, nil +} + +// GenieStartConversationResponseToSDK converts the mirror to the sdk-go type. +func GenieStartConversationResponseToSDK(w *GenieStartConversationResponse) (*sdk.GenieStartConversationResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieStartConversationResponse{} + out.MessageId = w.MessageId + conv51, err := GenieMessageToSDK(w.Message) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieStartConversationResponse.Message", err) + } + out.Message = conv51 + out.ConversationId = w.ConversationId + conv52, err := GenieConversationToSDK(w.Conversation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieStartConversationResponse.Conversation", err) + } + out.Conversation = conv52 + return out, nil +} + +// GenieStartConversationResponseFromSDK converts the sdk-go type to the mirror. +func GenieStartConversationResponseFromSDK(v *sdk.GenieStartConversationResponse) (*GenieStartConversationResponse, error) { + if v == nil { + return nil, nil + } + out := &GenieStartConversationResponse{} + out.MessageId = v.MessageId + conv53, err := GenieMessageFromSDK(v.Message) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieStartConversationResponse.Message", err) + } + out.Message = conv53 + out.ConversationId = v.ConversationId + conv54, err := GenieConversationFromSDK(v.Conversation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenieStartConversationResponse.Conversation", err) + } + out.Conversation = conv54 + return out, nil +} + +// GenieSuggestedQuestionsAttachmentToSDK converts the mirror to the sdk-go type. +func GenieSuggestedQuestionsAttachmentToSDK(w *GenieSuggestedQuestionsAttachment) (*sdk.GenieSuggestedQuestionsAttachment, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieSuggestedQuestionsAttachment{} + out.Questions = w.Questions + return out, nil +} + +// GenieSuggestedQuestionsAttachmentFromSDK converts the sdk-go type to the mirror. +func GenieSuggestedQuestionsAttachmentFromSDK(v *sdk.GenieSuggestedQuestionsAttachment) (*GenieSuggestedQuestionsAttachment, error) { + if v == nil { + return nil, nil + } + out := &GenieSuggestedQuestionsAttachment{} + out.Questions = v.Questions + return out, nil +} + +// GenieUpdateSpaceRequestToSDK converts the mirror to the sdk-go type. +func GenieUpdateSpaceRequestToSDK(w *GenieUpdateSpaceRequest) (*sdk.GenieUpdateSpaceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieUpdateSpaceRequest{} + out.SpaceId = w.SpaceId + out.SerializedSpace = w.SerializedSpace + out.Title = w.Title + out.Description = w.Description + out.WarehouseId = w.WarehouseId + out.Etag = w.Etag + out.ParentPath = w.ParentPath + return out, nil +} + +// GenieUpdateSpaceRequestFromSDK converts the sdk-go type to the mirror. +func GenieUpdateSpaceRequestFromSDK(v *sdk.GenieUpdateSpaceRequest) (*GenieUpdateSpaceRequest, error) { + if v == nil { + return nil, nil + } + out := &GenieUpdateSpaceRequest{} + out.SpaceId = v.SpaceId + out.SerializedSpace = v.SerializedSpace + out.Title = v.Title + out.Description = v.Description + out.WarehouseId = v.WarehouseId + out.Etag = v.Etag + out.ParentPath = v.ParentPath + return out, nil +} + +// GenieVizAttachmentToSDK converts the mirror to the sdk-go type. +func GenieVizAttachmentToSDK(w *GenieVizAttachment) (*sdk.GenieVizAttachment, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieVizAttachment{} + out.Title = w.Title + out.QueryAttachmentId = w.QueryAttachmentId + return out, nil +} + +// GenieVizAttachmentFromSDK converts the sdk-go type to the mirror. +func GenieVizAttachmentFromSDK(v *sdk.GenieVizAttachment) (*GenieVizAttachment, error) { + if v == nil { + return nil, nil + } + out := &GenieVizAttachment{} + out.Title = v.Title + out.QueryAttachmentId = v.QueryAttachmentId + return out, nil +} + +// ListValueToSDK converts the mirror to the sdk-go type. +func ListValueToSDK(w *ListValue) (*sdk.ListValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListValue{} + conv55, err := convertSlice(w.Values, ValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListValue.Values", err) + } + out.Values = conv55 + return out, nil +} + +// ListValueFromSDK converts the sdk-go type to the mirror. +func ListValueFromSDK(v *sdk.ListValue) (*ListValue, error) { + if v == nil { + return nil, nil + } + out := &ListValue{} + conv56, err := convertSlice(v.Values, ValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListValue.Values", err) + } + out.Values = conv56 + return out, nil +} + +// MapStringValueEntryToSDK converts the mirror to the sdk-go type. +func MapStringValueEntryToSDK(w *MapStringValueEntry) (*sdk.MapStringValueEntry, error) { + if w == nil { + return nil, nil + } + out := &sdk.MapStringValueEntry{} + out.Key = w.Key + conv57, err := ValueToSDK(w.Value) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MapStringValueEntry.Value", err) + } + out.Value = conv57 + return out, nil +} + +// MapStringValueEntryFromSDK converts the sdk-go type to the mirror. +func MapStringValueEntryFromSDK(v *sdk.MapStringValueEntry) (*MapStringValueEntry, error) { + if v == nil { + return nil, nil + } + out := &MapStringValueEntry{} + out.Key = v.Key + conv58, err := ValueFromSDK(v.Value) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MapStringValueEntry.Value", err) + } + out.Value = conv58 + return out, nil +} + +// MessageErrorToSDK converts the mirror to the sdk-go type. +func MessageErrorToSDK(w *MessageError) (*sdk.MessageError, error) { + if w == nil { + return nil, nil + } + out := &sdk.MessageError{} + out.Error = w.Error + out.Type = w.Type + return out, nil +} + +// MessageErrorFromSDK converts the sdk-go type to the mirror. +func MessageErrorFromSDK(v *sdk.MessageError) (*MessageError, error) { + if v == nil { + return nil, nil + } + out := &MessageError{} + out.Error = v.Error + out.Type = v.Type + return out, nil +} + +// PolicyFunctionArgumentToSDK converts the mirror to the sdk-go type. +func PolicyFunctionArgumentToSDK(w *PolicyFunctionArgument) (*sdk.PolicyFunctionArgument, error) { + if w == nil { + return nil, nil + } + out := &sdk.PolicyFunctionArgument{} + { + var members []string + if w.Column != nil { + members = append(members, "column") + } + if w.Constant != nil { + members = append(members, "constant") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Column != nil: + out.Arg = &sdk.PolicyFunctionArgument_Arg_Column{Column: *w.Column} + case w.Constant != nil: + out.Arg = &sdk.PolicyFunctionArgument_Arg_Constant{Constant: *w.Constant} + } + return out, nil +} + +// PolicyFunctionArgumentFromSDK converts the sdk-go type to the mirror. +func PolicyFunctionArgumentFromSDK(v *sdk.PolicyFunctionArgument) (*PolicyFunctionArgument, error) { + if v == nil { + return nil, nil + } + out := &PolicyFunctionArgument{} + switch value := v.Arg.(type) { + case *sdk.PolicyFunctionArgument_Arg_Column: + if value != nil { + out.Column = new(value.Column) + } + case *sdk.PolicyFunctionArgument_Arg_Constant: + if value != nil { + out.Constant = new(value.Constant) + } + } + return out, nil +} + +// QueryAttachmentParameterToSDK converts the mirror to the sdk-go type. +func QueryAttachmentParameterToSDK(w *QueryAttachmentParameter) (*sdk.QueryAttachmentParameter, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryAttachmentParameter{} + out.Keyword = w.Keyword + out.Value = w.Value + out.SqlType = w.SqlType + return out, nil +} + +// QueryAttachmentParameterFromSDK converts the sdk-go type to the mirror. +func QueryAttachmentParameterFromSDK(v *sdk.QueryAttachmentParameter) (*QueryAttachmentParameter, error) { + if v == nil { + return nil, nil + } + out := &QueryAttachmentParameter{} + out.Keyword = v.Keyword + out.Value = v.Value + out.SqlType = v.SqlType + return out, nil +} + +// ResultToSDK converts the mirror to the sdk-go type. +func ResultToSDK(w *Result) (*sdk.Result, error) { + if w == nil { + return nil, nil + } + out := &sdk.Result{} + out.StatementId = w.StatementId + out.RowCount = w.RowCount + out.IsTruncated = w.IsTruncated + out.StatementIdSignature = w.StatementIdSignature + return out, nil +} + +// ResultFromSDK converts the sdk-go type to the mirror. +func ResultFromSDK(v *sdk.Result) (*Result, error) { + if v == nil { + return nil, nil + } + out := &Result{} + out.StatementId = v.StatementId + out.RowCount = v.RowCount + out.IsTruncated = v.IsTruncated + out.StatementIdSignature = v.StatementIdSignature + return out, nil +} + +// ResultDataToSDK converts the mirror to the sdk-go type. +func ResultDataToSDK(w *ResultData) (*sdk.ResultData, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResultData{} + conv59, err := convertSlice(w.ExternalLinks, ExternalLinkToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultData.ExternalLinks", err) + } + out.ExternalLinks = conv59 + conv60, err := convertSlice(w.DataArray, ListValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultData.DataArray", err) + } + out.DataArray = conv60 + out.ChunkIndex = w.ChunkIndex + out.RowOffset = w.RowOffset + out.RowCount = w.RowCount + out.ByteCount = w.ByteCount + out.NextChunkIndex = w.NextChunkIndex + out.NextChunkInternalLink = w.NextChunkInternalLink + return out, nil +} + +// ResultDataFromSDK converts the sdk-go type to the mirror. +func ResultDataFromSDK(v *sdk.ResultData) (*ResultData, error) { + if v == nil { + return nil, nil + } + out := &ResultData{} + conv61, err := convertSlice(v.ExternalLinks, ExternalLinkFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultData.ExternalLinks", err) + } + out.ExternalLinks = conv61 + conv62, err := convertSlice(v.DataArray, ListValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultData.DataArray", err) + } + out.DataArray = conv62 + out.ChunkIndex = v.ChunkIndex + out.RowOffset = v.RowOffset + out.RowCount = v.RowCount + out.ByteCount = v.ByteCount + out.NextChunkIndex = v.NextChunkIndex + out.NextChunkInternalLink = v.NextChunkInternalLink + return out, nil +} + +// ResultManifestToSDK converts the mirror to the sdk-go type. +func ResultManifestToSDK(w *ResultManifest) (*sdk.ResultManifest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResultManifest{} + out.Format = w.Format + conv63, err := SchemaToSDK(w.Schema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.Schema", err) + } + out.Schema = conv63 + out.TotalChunkCount = w.TotalChunkCount + conv64, err := convertSlice(w.Chunks, ChunkInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.Chunks", err) + } + out.Chunks = conv64 + out.TotalRowCount = w.TotalRowCount + out.TotalByteCount = w.TotalByteCount + out.Truncated = w.Truncated + return out, nil +} + +// ResultManifestFromSDK converts the sdk-go type to the mirror. +func ResultManifestFromSDK(v *sdk.ResultManifest) (*ResultManifest, error) { + if v == nil { + return nil, nil + } + out := &ResultManifest{} + out.Format = v.Format + conv65, err := SchemaFromSDK(v.Schema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.Schema", err) + } + out.Schema = conv65 + out.TotalChunkCount = v.TotalChunkCount + conv66, err := convertSlice(v.Chunks, ChunkInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.Chunks", err) + } + out.Chunks = conv66 + out.TotalRowCount = v.TotalRowCount + out.TotalByteCount = v.TotalByteCount + out.Truncated = v.Truncated + return out, nil +} + +// SchemaToSDK converts the mirror to the sdk-go type. +func SchemaToSDK(w *Schema) (*sdk.Schema, error) { + if w == nil { + return nil, nil + } + out := &sdk.Schema{} + out.ColumnCount = w.ColumnCount + conv67, err := convertSlice(w.Columns, ColumnInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Schema.Columns", err) + } + out.Columns = conv67 + return out, nil +} + +// SchemaFromSDK converts the sdk-go type to the mirror. +func SchemaFromSDK(v *sdk.Schema) (*Schema, error) { + if v == nil { + return nil, nil + } + out := &Schema{} + out.ColumnCount = v.ColumnCount + conv68, err := convertSlice(v.Columns, ColumnInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Schema.Columns", err) + } + out.Columns = conv68 + return out, nil +} + +// StatementResponseToSDK converts the mirror to the sdk-go type. +func StatementResponseToSDK(w *StatementResponse) (*sdk.StatementResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.StatementResponse{} + out.StatementId = w.StatementId + conv69, err := StatementStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementResponse.Status", err) + } + out.Status = conv69 + conv70, err := ResultManifestToSDK(w.Manifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementResponse.Manifest", err) + } + out.Manifest = conv70 + conv71, err := ResultDataToSDK(w.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementResponse.Result", err) + } + out.Result = conv71 + return out, nil +} + +// StatementResponseFromSDK converts the sdk-go type to the mirror. +func StatementResponseFromSDK(v *sdk.StatementResponse) (*StatementResponse, error) { + if v == nil { + return nil, nil + } + out := &StatementResponse{} + out.StatementId = v.StatementId + conv72, err := StatementStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementResponse.Status", err) + } + out.Status = conv72 + conv73, err := ResultManifestFromSDK(v.Manifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementResponse.Manifest", err) + } + out.Manifest = conv73 + conv74, err := ResultDataFromSDK(v.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementResponse.Result", err) + } + out.Result = conv74 + return out, nil +} + +// StatementStatusToSDK converts the mirror to the sdk-go type. +func StatementStatusToSDK(w *StatementStatus) (*sdk.StatementStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.StatementStatus{} + out.State = w.State + conv75, err := DatabricksServiceExceptionProtoToSDK(w.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementStatus.Error", err) + } + out.Error = conv75 + out.SqlState = w.SqlState + return out, nil +} + +// StatementStatusFromSDK converts the sdk-go type to the mirror. +func StatementStatusFromSDK(v *sdk.StatementStatus) (*StatementStatus, error) { + if v == nil { + return nil, nil + } + out := &StatementStatus{} + out.State = v.State + conv76, err := DatabricksServiceExceptionProtoFromSDK(v.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementStatus.Error", err) + } + out.Error = conv76 + out.SqlState = v.SqlState + return out, nil +} + +// StructToSDK converts the mirror to the sdk-go type. +func StructToSDK(w *Struct) (*sdk.Struct, error) { + if w == nil { + return nil, nil + } + out := &sdk.Struct{} + conv77, err := convertSlice(w.Fields, MapStringValueEntryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Struct.Fields", err) + } + out.Fields = conv77 + return out, nil +} + +// StructFromSDK converts the sdk-go type to the mirror. +func StructFromSDK(v *sdk.Struct) (*Struct, error) { + if v == nil { + return nil, nil + } + out := &Struct{} + conv78, err := convertSlice(v.Fields, MapStringValueEntryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Struct.Fields", err) + } + out.Fields = conv78 + return out, nil +} + +// TextAttachmentToSDK converts the mirror to the sdk-go type. +func TextAttachmentToSDK(w *TextAttachment) (*sdk.TextAttachment, error) { + if w == nil { + return nil, nil + } + out := &sdk.TextAttachment{} + out.Content = w.Content + out.Id = w.Id + out.Purpose = w.Purpose + return out, nil +} + +// TextAttachmentFromSDK converts the sdk-go type to the mirror. +func TextAttachmentFromSDK(v *sdk.TextAttachment) (*TextAttachment, error) { + if v == nil { + return nil, nil + } + out := &TextAttachment{} + out.Content = v.Content + out.Id = v.Id + out.Purpose = v.Purpose + return out, nil +} + +// ThoughtToSDK converts the mirror to the sdk-go type. +func ThoughtToSDK(w *Thought) (*sdk.Thought, error) { + if w == nil { + return nil, nil + } + out := &sdk.Thought{} + out.ThoughtType = w.ThoughtType + out.Content = w.Content + return out, nil +} + +// ThoughtFromSDK converts the sdk-go type to the mirror. +func ThoughtFromSDK(v *sdk.Thought) (*Thought, error) { + if v == nil { + return nil, nil + } + out := &Thought{} + out.ThoughtType = v.ThoughtType + out.Content = v.Content + return out, nil +} + +// ValueToSDK converts the mirror to the sdk-go type. +func ValueToSDK(w *Value) (*sdk.Value, error) { + if w == nil { + return nil, nil + } + out := &sdk.Value{} + { + var members []string + if w.NullValue != "" { + members = append(members, "null_value") + } + if w.NumberValue != nil { + members = append(members, "number_value") + } + if w.StringValue != nil { + members = append(members, "string_value") + } + if w.BoolValue != nil { + members = append(members, "bool_value") + } + if w.StructValue != nil { + members = append(members, "struct_value") + } + if w.ListValue != nil { + members = append(members, "list_value") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NullValue != "": + out.Kind = &sdk.Value_Kind_NullValue{NullValue: w.NullValue} + case w.NumberValue != nil: + out.Kind = &sdk.Value_Kind_NumberValue{NumberValue: *w.NumberValue} + case w.StringValue != nil: + out.Kind = &sdk.Value_Kind_StringValue{StringValue: *w.StringValue} + case w.BoolValue != nil: + out.Kind = &sdk.Value_Kind_BoolValue{BoolValue: *w.BoolValue} + case w.StructValue != nil: + conv79, err := StructToSDK(w.StructValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Value.Kind", err) + } + out.Kind = &sdk.Value_Kind_StructValue{StructValue: *conv79} + case w.ListValue != nil: + conv80, err := ListValueToSDK(w.ListValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Value.Kind", err) + } + out.Kind = &sdk.Value_Kind_ListValue{ListValue: *conv80} + } + return out, nil +} + +// ValueFromSDK converts the sdk-go type to the mirror. +func ValueFromSDK(v *sdk.Value) (*Value, error) { + if v == nil { + return nil, nil + } + out := &Value{} + switch value := v.Kind.(type) { + case *sdk.Value_Kind_NullValue: + if value != nil { + out.NullValue = value.NullValue + } + case *sdk.Value_Kind_NumberValue: + if value != nil { + out.NumberValue = new(value.NumberValue) + } + case *sdk.Value_Kind_StringValue: + if value != nil { + out.StringValue = new(value.StringValue) + } + case *sdk.Value_Kind_BoolValue: + if value != nil { + out.BoolValue = new(value.BoolValue) + } + case *sdk.Value_Kind_StructValue: + if value != nil { + conv81, err := StructFromSDK(&value.StructValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Value.Kind", err) + } + out.StructValue = conv81 + } + case *sdk.Value_Kind_ListValue: + if value != nil { + conv82, err := ListValueFromSDK(&value.ListValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Value.Kind", err) + } + out.ListValue = conv82 + } + } + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/gitcredentials/v1/types.generated.go b/libs/sdktypes/gitcredentials/v1/types.generated.go new file mode 100644 index 00000000000..170aaf5fe4b --- /dev/null +++ b/libs/sdktypes/gitcredentials/v1/types.generated.go @@ -0,0 +1,442 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/gitcredentials/v1. DO NOT EDIT. + +package gitcredentials + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/gitcredentials/v1" +) + +type CreateCredentialsRequest struct { + // The authenticating email associated with your Git provider user account. Used + // for authentication with the remote repository and also sets the author & + // committer identity for commits. Required for most Git providers except AWS + // CodeCommit. Learn more at + // https://docs.databricks.com/aws/en/repos/get-access-tokens-from-git-provider + GitEmail *string `json:"git_email,omitempty"` + // Git provider. This field is case-insensitive. The available Git providers are + // `gitHub`, `bitbucketCloud`, `gitLab`, `azureDevOpsServices` (Azure DevOps + // Services, including Microsoft Entra ID authentication), `gitHubEnterprise`, + // `bitbucketServer` (Bitbucket Data Center), `gitLabEnterpriseEdition` (GitLab + // Self-Managed), and `awsCodeCommit`. + GitProvider *string `json:"git_provider,omitempty"` + // The username provided with your Git provider account and associated with the + // credential. For most Git providers it is only used to set the Git committer & + // author names for commits, however it may be required for authentication + // depending on your Git provider / token requirements. Required for AWS + // CodeCommit. + GitUsername *string `json:"git_username,omitempty"` + // if the credential is the default for the given provider + IsDefaultForProvider *bool `json:"is_default_for_provider,omitempty"` + // the name of the git credential, used for identification and ease of lookup + Name *string `json:"name,omitempty"` + // The personal access token used to authenticate to the corresponding Git + // provider. For certain providers, support may exist for other types of scoped + // access tokens. [Learn more]. + // + // [Learn more]: https://docs.databricks.com/repos/get-access-tokens-from-git-provider.html + PersonalAccessToken *string `json:"personal_access_token,omitempty"` + // The ID of the service principal whose credentials will be modified. Only + // service principal managers can perform this action. + PrincipalId *int64 `json:"principal_id,omitempty"` +} + +type CreateCredentialsResponse struct { + // ID of the credential object in the workspace. + CredentialId *int64 `json:"credential_id,omitempty"` + // The authenticating email associated with your Git provider user account. Used + // for authentication with the remote repository and also sets the author & + // committer identity for commits. Required for most Git providers except AWS + // CodeCommit. Learn more at + // https://docs.databricks.com/aws/en/repos/get-access-tokens-from-git-provider + GitEmail *string `json:"git_email,omitempty"` + // The Git provider associated with the credential. + GitProvider *string `json:"git_provider,omitempty"` + // The username provided with your Git provider account and associated with the + // credential. For most Git providers it is only used to set the Git committer & + // author names for commits, however it may be required for authentication + // depending on your Git provider / token requirements. Required for AWS + // CodeCommit. + GitUsername *string `json:"git_username,omitempty"` + // if the credential is the default for the given provider + IsDefaultForProvider *bool `json:"is_default_for_provider,omitempty"` + // the name of the git credential, used for identification and ease of lookup + Name *string `json:"name,omitempty"` +} + +type Credential struct { + // ID of the credential object in the workspace. + CredentialId *int64 `json:"credential_id,omitempty"` + // The authenticating email associated with your Git provider user account. Used + // for authentication with the remote repository and also sets the author & + // committer identity for commits. Required for most Git providers except AWS + // CodeCommit. Learn more at + // https://docs.databricks.com/aws/en/repos/get-access-tokens-from-git-provider + GitEmail *string `json:"git_email,omitempty"` + // The Git provider associated with the credential. One of `gitHub`, + // `bitbucketCloud`, `gitLab`, `azureDevOpsServices` (Azure DevOps Services, + // including Microsoft Entra ID authentication), `gitHubEnterprise`, + // `bitbucketServer` (Bitbucket Data Center), `gitLabEnterpriseEdition` (GitLab + // Self-Managed), or `awsCodeCommit`. + GitProvider *string `json:"git_provider,omitempty"` + // The username provided with your Git provider account and associated with the + // credential. For most Git providers it is only used to set the Git committer & + // author names for commits, however it may be required for authentication + // depending on your Git provider / token requirements. Required for AWS + // CodeCommit. + GitUsername *string `json:"git_username,omitempty"` + // if the credential is the default for the given provider + IsDefaultForProvider *bool `json:"is_default_for_provider,omitempty"` + // the name of the git credential, used for identification and ease of lookup + Name *string `json:"name,omitempty"` +} + +type DeleteCredentialsRequest struct { + // The ID for the corresponding credential to access. + Id *int64 `json:"id,omitempty"` + // The ID of the service principal whose credentials will be modified. Only + // service principal managers can perform this action. + PrincipalId *int64 `json:"principal_id,omitempty"` +} + +type GetCredentialsRequest struct { + // The ID for the corresponding credential to access. + Id *int64 `json:"id,omitempty"` + // The ID of the service principal whose credentials will be modified. Only + // service principal managers can perform this action. + PrincipalId *int64 `json:"principal_id,omitempty"` +} + +type GetCredentialsResponse struct { + // ID of the credential object in the workspace. + CredentialId *int64 `json:"credential_id,omitempty"` + // The authenticating email associated with your Git provider user account. Used + // for authentication with the remote repository and also sets the author & + // committer identity for commits. Required for most Git providers except AWS + // CodeCommit. Learn more at + // https://docs.databricks.com/aws/en/repos/get-access-tokens-from-git-provider + GitEmail *string `json:"git_email,omitempty"` + // The Git provider associated with the credential. + GitProvider *string `json:"git_provider,omitempty"` + // The username provided with your Git provider account and associated with the + // credential. For most Git providers it is only used to set the Git committer & + // author names for commits, however it may be required for authentication + // depending on your Git provider / token requirements. Required for AWS + // CodeCommit. + GitUsername *string `json:"git_username,omitempty"` + // if the credential is the default for the given provider + IsDefaultForProvider *bool `json:"is_default_for_provider,omitempty"` + // the name of the git credential, used for identification and ease of lookup + Name *string `json:"name,omitempty"` +} + +type ListCredentialsRequest struct { + // The ID of the service principal whose credentials will be listed. Only + // service principal managers can perform this action. + PrincipalId *int64 `json:"principal_id,omitempty"` +} + +type ListCredentialsResponse struct { + // List of credentials. + Credentials []Credential `json:"credentials,omitempty"` +} + +type UpdateCredentialsRequest struct { + // The authenticating email associated with your Git provider user account. Used + // for authentication with the remote repository and also sets the author & + // committer identity for commits. Required for most Git providers except AWS + // CodeCommit. Learn more at + // https://docs.databricks.com/aws/en/repos/get-access-tokens-from-git-provider + GitEmail *string `json:"git_email,omitempty"` + // Git provider. This field is case-insensitive. The available Git providers are + // `gitHub`, `bitbucketCloud`, `gitLab`, `azureDevOpsServices` (Azure DevOps + // Services, including Microsoft Entra ID authentication), `gitHubEnterprise`, + // `bitbucketServer` (Bitbucket Data Center), `gitLabEnterpriseEdition` (GitLab + // Self-Managed), and `awsCodeCommit`. + GitProvider *string `json:"git_provider,omitempty"` + // The username provided with your Git provider account and associated with the + // credential. For most Git providers it is only used to set the Git committer & + // author names for commits, however it may be required for authentication + // depending on your Git provider / token requirements. Required for AWS + // CodeCommit. + GitUsername *string `json:"git_username,omitempty"` + // The ID for the corresponding credential to access. + Id *int64 `json:"id,omitempty"` + // if the credential is the default for the given provider + IsDefaultForProvider *bool `json:"is_default_for_provider,omitempty"` + // the name of the git credential, used for identification and ease of lookup + Name *string `json:"name,omitempty"` + // The personal access token used to authenticate to the corresponding Git + // provider. For certain providers, support may exist for other types of scoped + // access tokens. [Learn more]. + // + // [Learn more]: https://docs.databricks.com/repos/get-access-tokens-from-git-provider.html + PersonalAccessToken *string `json:"personal_access_token,omitempty"` + // The ID of the service principal whose credentials will be modified. Only + // service principal managers can perform this action. + PrincipalId *int64 `json:"principal_id,omitempty"` +} + +// CreateCredentialsRequestToSDK converts the mirror to the sdk-go type. +func CreateCredentialsRequestToSDK(w *CreateCredentialsRequest) (*sdk.CreateCredentialsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCredentialsRequest{} + out.GitProvider = w.GitProvider + out.GitUsername = w.GitUsername + out.PersonalAccessToken = w.PersonalAccessToken + out.PrincipalId = w.PrincipalId + out.Name = w.Name + out.IsDefaultForProvider = w.IsDefaultForProvider + out.GitEmail = w.GitEmail + return out, nil +} + +// CreateCredentialsRequestFromSDK converts the sdk-go type to the mirror. +func CreateCredentialsRequestFromSDK(v *sdk.CreateCredentialsRequest) (*CreateCredentialsRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCredentialsRequest{} + out.GitProvider = v.GitProvider + out.GitUsername = v.GitUsername + out.PersonalAccessToken = v.PersonalAccessToken + out.PrincipalId = v.PrincipalId + out.Name = v.Name + out.IsDefaultForProvider = v.IsDefaultForProvider + out.GitEmail = v.GitEmail + return out, nil +} + +// CreateCredentialsResponseToSDK converts the mirror to the sdk-go type. +func CreateCredentialsResponseToSDK(w *CreateCredentialsResponse) (*sdk.CreateCredentialsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCredentialsResponse{} + out.CredentialId = w.CredentialId + out.GitProvider = w.GitProvider + out.GitUsername = w.GitUsername + out.Name = w.Name + out.IsDefaultForProvider = w.IsDefaultForProvider + out.GitEmail = w.GitEmail + return out, nil +} + +// CreateCredentialsResponseFromSDK converts the sdk-go type to the mirror. +func CreateCredentialsResponseFromSDK(v *sdk.CreateCredentialsResponse) (*CreateCredentialsResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateCredentialsResponse{} + out.CredentialId = v.CredentialId + out.GitProvider = v.GitProvider + out.GitUsername = v.GitUsername + out.Name = v.Name + out.IsDefaultForProvider = v.IsDefaultForProvider + out.GitEmail = v.GitEmail + return out, nil +} + +// CredentialToSDK converts the mirror to the sdk-go type. +func CredentialToSDK(w *Credential) (*sdk.Credential, error) { + if w == nil { + return nil, nil + } + out := &sdk.Credential{} + out.CredentialId = w.CredentialId + out.GitProvider = w.GitProvider + out.GitUsername = w.GitUsername + out.Name = w.Name + out.IsDefaultForProvider = w.IsDefaultForProvider + out.GitEmail = w.GitEmail + return out, nil +} + +// CredentialFromSDK converts the sdk-go type to the mirror. +func CredentialFromSDK(v *sdk.Credential) (*Credential, error) { + if v == nil { + return nil, nil + } + out := &Credential{} + out.CredentialId = v.CredentialId + out.GitProvider = v.GitProvider + out.GitUsername = v.GitUsername + out.Name = v.Name + out.IsDefaultForProvider = v.IsDefaultForProvider + out.GitEmail = v.GitEmail + return out, nil +} + +// DeleteCredentialsRequestToSDK converts the mirror to the sdk-go type. +func DeleteCredentialsRequestToSDK(w *DeleteCredentialsRequest) (*sdk.DeleteCredentialsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteCredentialsRequest{} + out.Id = w.Id + out.PrincipalId = w.PrincipalId + return out, nil +} + +// DeleteCredentialsRequestFromSDK converts the sdk-go type to the mirror. +func DeleteCredentialsRequestFromSDK(v *sdk.DeleteCredentialsRequest) (*DeleteCredentialsRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteCredentialsRequest{} + out.Id = v.Id + out.PrincipalId = v.PrincipalId + return out, nil +} + +// GetCredentialsRequestToSDK converts the mirror to the sdk-go type. +func GetCredentialsRequestToSDK(w *GetCredentialsRequest) (*sdk.GetCredentialsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetCredentialsRequest{} + out.Id = w.Id + out.PrincipalId = w.PrincipalId + return out, nil +} + +// GetCredentialsRequestFromSDK converts the sdk-go type to the mirror. +func GetCredentialsRequestFromSDK(v *sdk.GetCredentialsRequest) (*GetCredentialsRequest, error) { + if v == nil { + return nil, nil + } + out := &GetCredentialsRequest{} + out.Id = v.Id + out.PrincipalId = v.PrincipalId + return out, nil +} + +// GetCredentialsResponseToSDK converts the mirror to the sdk-go type. +func GetCredentialsResponseToSDK(w *GetCredentialsResponse) (*sdk.GetCredentialsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetCredentialsResponse{} + out.CredentialId = w.CredentialId + out.GitProvider = w.GitProvider + out.GitUsername = w.GitUsername + out.Name = w.Name + out.IsDefaultForProvider = w.IsDefaultForProvider + out.GitEmail = w.GitEmail + return out, nil +} + +// GetCredentialsResponseFromSDK converts the sdk-go type to the mirror. +func GetCredentialsResponseFromSDK(v *sdk.GetCredentialsResponse) (*GetCredentialsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetCredentialsResponse{} + out.CredentialId = v.CredentialId + out.GitProvider = v.GitProvider + out.GitUsername = v.GitUsername + out.Name = v.Name + out.IsDefaultForProvider = v.IsDefaultForProvider + out.GitEmail = v.GitEmail + return out, nil +} + +// ListCredentialsRequestToSDK converts the mirror to the sdk-go type. +func ListCredentialsRequestToSDK(w *ListCredentialsRequest) (*sdk.ListCredentialsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCredentialsRequest{} + out.PrincipalId = w.PrincipalId + return out, nil +} + +// ListCredentialsRequestFromSDK converts the sdk-go type to the mirror. +func ListCredentialsRequestFromSDK(v *sdk.ListCredentialsRequest) (*ListCredentialsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCredentialsRequest{} + out.PrincipalId = v.PrincipalId + return out, nil +} + +// ListCredentialsResponseToSDK converts the mirror to the sdk-go type. +func ListCredentialsResponseToSDK(w *ListCredentialsResponse) (*sdk.ListCredentialsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCredentialsResponse{} + conv1, err := convertSlice(w.Credentials, CredentialToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCredentialsResponse.Credentials", err) + } + out.Credentials = conv1 + return out, nil +} + +// ListCredentialsResponseFromSDK converts the sdk-go type to the mirror. +func ListCredentialsResponseFromSDK(v *sdk.ListCredentialsResponse) (*ListCredentialsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCredentialsResponse{} + conv2, err := convertSlice(v.Credentials, CredentialFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCredentialsResponse.Credentials", err) + } + out.Credentials = conv2 + return out, nil +} + +// UpdateCredentialsRequestToSDK converts the mirror to the sdk-go type. +func UpdateCredentialsRequestToSDK(w *UpdateCredentialsRequest) (*sdk.UpdateCredentialsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCredentialsRequest{} + out.Id = w.Id + out.PersonalAccessToken = w.PersonalAccessToken + out.GitProvider = w.GitProvider + out.GitUsername = w.GitUsername + out.PrincipalId = w.PrincipalId + out.Name = w.Name + out.IsDefaultForProvider = w.IsDefaultForProvider + out.GitEmail = w.GitEmail + return out, nil +} + +// UpdateCredentialsRequestFromSDK converts the sdk-go type to the mirror. +func UpdateCredentialsRequestFromSDK(v *sdk.UpdateCredentialsRequest) (*UpdateCredentialsRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateCredentialsRequest{} + out.Id = v.Id + out.PersonalAccessToken = v.PersonalAccessToken + out.GitProvider = v.GitProvider + out.GitUsername = v.GitUsername + out.PrincipalId = v.PrincipalId + out.Name = v.Name + out.IsDefaultForProvider = v.IsDefaultForProvider + out.GitEmail = v.GitEmail + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/globalinitscripts/v2/types.generated.go b/libs/sdktypes/globalinitscripts/v2/types.generated.go new file mode 100644 index 00000000000..6f21d4f9718 --- /dev/null +++ b/libs/sdktypes/globalinitscripts/v2/types.generated.go @@ -0,0 +1,236 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/globalinitscripts/v2. DO NOT EDIT. + +package globalinitscripts + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/globalinitscripts/v2" +) + +type CreateGlobalInitScriptRequest struct { + // Specifies whether the script is enabled. The script runs only if enabled. + Enabled *bool `json:"enabled,omitempty"` + // The name of the script + Name *string `json:"name,omitempty"` + // The position of a global init script, where 0 represents the first script to + // run, 1 is the second script to run, in ascending order. + // + // If you omit the numeric position for a new global init script, it defaults to + // last position. It will run after all current scripts. Setting any value + // greater than the position of the last script is equivalent to the last + // position. Example: Take three existing scripts with positions 0, 1, and 2. + // Any position of (3) or greater puts the script in the last position. If an + // explicit position value conflicts with an existing script value, your request + // succeeds, but the original script at that position and all later scripts have + // their positions incremented by 1. + Position *int `json:"position,omitempty"` + // The Base64-encoded content of the script. + Script []byte `json:"script,omitempty"` +} + +type CreateGlobalInitScriptResponse struct { + // The global init script ID. + ScriptId *string `json:"script_id,omitempty"` +} + +type GlobalInitScriptDetails struct { + // Time when the script was created, represented as a Unix timestamp in + // milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // The username of the user who created the script. + CreatedBy *string `json:"created_by,omitempty"` + // Specifies whether the script is enabled. The script runs only if enabled. + Enabled *bool `json:"enabled,omitempty"` + // The name of the script + Name *string `json:"name,omitempty"` + // The position of a script, where 0 represents the first script to run, 1 is + // the second script to run, in ascending order. + Position *int `json:"position,omitempty"` + // The global init script ID. + ScriptId *string `json:"script_id,omitempty"` + // Time when the script was updated, represented as a Unix timestamp in + // milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // The username of the user who last updated the script + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type ListGlobalInitScriptsResponse struct { + Scripts []GlobalInitScriptDetails `json:"scripts,omitempty"` +} + +type UpdateGlobalInitScriptRequest struct { + // Specifies whether the script is enabled. The script runs only if enabled. + Enabled *bool `json:"enabled,omitempty"` + // The name of the script + Name *string `json:"name,omitempty"` + // The position of a script, where 0 represents the first script to run, 1 is + // the second script to run, in ascending order. To move the script to run + // first, set its position to 0. + // + // To move the script to the end, set its position to any value greater or equal + // to the position of the last script. Example, three existing scripts with + // positions 0, 1, and 2. Any position value of 2 or greater puts the script in + // the last position (2). + // + // If an explicit position value conflicts with an existing script, your request + // succeeds, but the original script at that position and all later scripts have + // their positions incremented by 1. + Position *int `json:"position,omitempty"` + // The Base64-encoded content of the script. + Script []byte `json:"script,omitempty"` + // The ID of the global init script. + ScriptId *string `json:"script_id,omitempty"` +} + +// CreateGlobalInitScriptRequestToSDK converts the mirror to the sdk-go type. +func CreateGlobalInitScriptRequestToSDK(w *CreateGlobalInitScriptRequest) (*sdk.CreateGlobalInitScriptRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateGlobalInitScriptRequest{} + out.Name = w.Name + out.Script = w.Script + out.Position = w.Position + out.Enabled = w.Enabled + return out, nil +} + +// CreateGlobalInitScriptRequestFromSDK converts the sdk-go type to the mirror. +func CreateGlobalInitScriptRequestFromSDK(v *sdk.CreateGlobalInitScriptRequest) (*CreateGlobalInitScriptRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateGlobalInitScriptRequest{} + out.Name = v.Name + out.Script = v.Script + out.Position = v.Position + out.Enabled = v.Enabled + return out, nil +} + +// CreateGlobalInitScriptResponseToSDK converts the mirror to the sdk-go type. +func CreateGlobalInitScriptResponseToSDK(w *CreateGlobalInitScriptResponse) (*sdk.CreateGlobalInitScriptResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateGlobalInitScriptResponse{} + out.ScriptId = w.ScriptId + return out, nil +} + +// CreateGlobalInitScriptResponseFromSDK converts the sdk-go type to the mirror. +func CreateGlobalInitScriptResponseFromSDK(v *sdk.CreateGlobalInitScriptResponse) (*CreateGlobalInitScriptResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateGlobalInitScriptResponse{} + out.ScriptId = v.ScriptId + return out, nil +} + +// GlobalInitScriptDetailsToSDK converts the mirror to the sdk-go type. +func GlobalInitScriptDetailsToSDK(w *GlobalInitScriptDetails) (*sdk.GlobalInitScriptDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.GlobalInitScriptDetails{} + out.ScriptId = w.ScriptId + out.Name = w.Name + out.Position = w.Position + out.Enabled = w.Enabled + out.CreatedBy = w.CreatedBy + out.CreatedAt = w.CreatedAt + out.UpdatedBy = w.UpdatedBy + out.UpdatedAt = w.UpdatedAt + return out, nil +} + +// GlobalInitScriptDetailsFromSDK converts the sdk-go type to the mirror. +func GlobalInitScriptDetailsFromSDK(v *sdk.GlobalInitScriptDetails) (*GlobalInitScriptDetails, error) { + if v == nil { + return nil, nil + } + out := &GlobalInitScriptDetails{} + out.ScriptId = v.ScriptId + out.Name = v.Name + out.Position = v.Position + out.Enabled = v.Enabled + out.CreatedBy = v.CreatedBy + out.CreatedAt = v.CreatedAt + out.UpdatedBy = v.UpdatedBy + out.UpdatedAt = v.UpdatedAt + return out, nil +} + +// ListGlobalInitScriptsResponseToSDK converts the mirror to the sdk-go type. +func ListGlobalInitScriptsResponseToSDK(w *ListGlobalInitScriptsResponse) (*sdk.ListGlobalInitScriptsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListGlobalInitScriptsResponse{} + conv1, err := convertSlice(w.Scripts, GlobalInitScriptDetailsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListGlobalInitScriptsResponse.Scripts", err) + } + out.Scripts = conv1 + return out, nil +} + +// ListGlobalInitScriptsResponseFromSDK converts the sdk-go type to the mirror. +func ListGlobalInitScriptsResponseFromSDK(v *sdk.ListGlobalInitScriptsResponse) (*ListGlobalInitScriptsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListGlobalInitScriptsResponse{} + conv2, err := convertSlice(v.Scripts, GlobalInitScriptDetailsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListGlobalInitScriptsResponse.Scripts", err) + } + out.Scripts = conv2 + return out, nil +} + +// UpdateGlobalInitScriptRequestToSDK converts the mirror to the sdk-go type. +func UpdateGlobalInitScriptRequestToSDK(w *UpdateGlobalInitScriptRequest) (*sdk.UpdateGlobalInitScriptRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateGlobalInitScriptRequest{} + out.ScriptId = w.ScriptId + out.Name = w.Name + out.Script = w.Script + out.Position = w.Position + out.Enabled = w.Enabled + return out, nil +} + +// UpdateGlobalInitScriptRequestFromSDK converts the sdk-go type to the mirror. +func UpdateGlobalInitScriptRequestFromSDK(v *sdk.UpdateGlobalInitScriptRequest) (*UpdateGlobalInitScriptRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateGlobalInitScriptRequest{} + out.ScriptId = v.ScriptId + out.Name = v.Name + out.Script = v.Script + out.Position = v.Position + out.Enabled = v.Enabled + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/instancepools/v2/types.generated.go b/libs/sdktypes/instancepools/v2/types.generated.go new file mode 100644 index 00000000000..0067a53a862 --- /dev/null +++ b/libs/sdktypes/instancepools/v2/types.generated.go @@ -0,0 +1,1465 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/instancepools/v2. DO NOT EDIT. + +package instancepools + +import ( + fmt "fmt" + sdk "github.com/databricks/sdk-go/instancepools/v2" + strings "strings" +) + +type ( + AwsAvailability = sdk.AwsAvailability + AzureAvailability = sdk.AzureAvailability + AzureDiskVolumeType = sdk.AzureDiskVolumeType + EbsVolumeType = sdk.EbsVolumeType + GcpAvailability = sdk.GcpAvailability + InstancePoolState = sdk.InstancePoolState +) + +const ( + AwsAvailability_Unspecified = sdk.AwsAvailability_Unspecified + AwsAvailability_Spot = sdk.AwsAvailability_Spot + AwsAvailability_OnDemand = sdk.AwsAvailability_OnDemand + AwsAvailability_SpotWithFallback = sdk.AwsAvailability_SpotWithFallback + AzureAvailability_Unspecified = sdk.AzureAvailability_Unspecified + AzureAvailability_SpotAzure = sdk.AzureAvailability_SpotAzure + AzureAvailability_OnDemandAzure = sdk.AzureAvailability_OnDemandAzure + AzureAvailability_SpotWithFallbackAzure = sdk.AzureAvailability_SpotWithFallbackAzure + AzureDiskVolumeType_Unspecified = sdk.AzureDiskVolumeType_Unspecified + AzureDiskVolumeType_PremiumLrs = sdk.AzureDiskVolumeType_PremiumLrs + AzureDiskVolumeType_StandardLrs = sdk.AzureDiskVolumeType_StandardLrs + EbsVolumeType_Unspecified = sdk.EbsVolumeType_Unspecified + EbsVolumeType_GeneralPurposeSsd = sdk.EbsVolumeType_GeneralPurposeSsd + EbsVolumeType_ThroughputOptimizedHdd = sdk.EbsVolumeType_ThroughputOptimizedHdd + GcpAvailability_Unspecified = sdk.GcpAvailability_Unspecified + GcpAvailability_PreemptibleGcp = sdk.GcpAvailability_PreemptibleGcp + GcpAvailability_OnDemandGcp = sdk.GcpAvailability_OnDemandGcp + GcpAvailability_PreemptibleWithFallbackGcp = sdk.GcpAvailability_PreemptibleWithFallbackGcp + InstancePoolState_Unspecified = sdk.InstancePoolState_Unspecified + InstancePoolState_Active = sdk.InstancePoolState_Active + InstancePoolState_Stopped = sdk.InstancePoolState_Stopped + InstancePoolState_Deleted = sdk.InstancePoolState_Deleted +) + +type CreateInstancePoolRequest struct { + // Attributes related to instance pools running on Amazon Web Services. If not + // specified at pool creation, a set of default values will be used. + AwsAttributes *InstancePoolAwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to instance pools running on Azure. If not specified at + // pool creation, a set of default values will be used. + AzureAttributes *InstancePoolAzureAttributes `json:"azure_attributes,omitempty"` + // Additional tags for pool resources. will tag all pool resources + // (e.g., AWS instances and EBS volumes) with these tags in addition to + // `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + // Defines the specification of the disks that will be attached to all spark + // containers. + DiskSpec *DiskSpec `json:"disk_spec,omitempty"` + // Autoscaling Local Storage: when enabled, this instances in this pool will + // dynamically acquire additional disk space when its Spark workers are running + // low on disk space. In AWS, this feature requires specific AWS permissions to + // function correctly - refer to the User Guide for more details. + EnableElasticDisk *bool `json:"enable_elastic_disk,omitempty"` + // Attributes related to instance pools running on Google Cloud Platform. If not + // specified at pool creation, a set of default values will be used. + GcpAttributes *InstancePoolGcpAttributes `json:"gcp_attributes,omitempty"` + // Automatically terminates the extra instances in the pool cache after they are + // inactive for this time in minutes if min_idle_instances requirement is + // already met. If not set, the extra pool instances will be automatically + // terminated after a default timeout. If specified, the threshold must be + // between 0 and 10000 minutes. Users can also set this value to 0 to instantly + // remove idle instances from the cache if min cache size could still hold. + IdleInstanceAutoterminationMinutes *int `json:"idle_instance_autotermination_minutes,omitempty"` + // Pool name requested by the user. Pool name must be unique. Length must be + // between 1 and 100 characters. + InstancePoolName *string `json:"instance_pool_name,omitempty"` + // Maximum number of outstanding instances to keep in the pool, including both + // instances used by clusters and idle instances. Clusters that require further + // instance provisioning will fail during upsize requests. + MaxCapacity *int `json:"max_capacity,omitempty"` + // Minimum number of idle instances to keep in the instance pool + MinIdleInstances *int `json:"min_idle_instances,omitempty"` + // Flexible node type configuration for the pool. + NodeTypeFlexibility *NodeTypeFlexibility `json:"node_type_flexibility,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // [clusters/listNodeTypes] API call. + // + // [clusters/listNodeTypes]: https://docs.databricks.com/api/workspace/clusters/listnodetypes + NodeTypeId *string `json:"node_type_id,omitempty"` + // Custom Docker Image BYOC + PreloadedDockerImages []DockerImage `json:"preloaded_docker_images,omitempty"` + // A list containing at most one preloaded Spark image version for the pool. + // Pool-backed clusters started with the preloaded Spark version will start + // faster. A list of available Spark versions can be retrieved by using the + // [clusters/sparkVersions] API call. + // + // [clusters/sparkVersions]: https://docs.databricks.com/api/workspace/clusters/sparkversions + PreloadedSparkVersions []string `json:"preloaded_spark_versions,omitempty"` + // If set, what the configurable throughput (in Mb/s) for the remote disk is. + // Currently only supported for GCP HYPERDISK_BALANCED types. + RemoteDiskThroughput *int `json:"remote_disk_throughput,omitempty"` + // If set, what the total initial volume size (in GB) of the remote disks should + // be. Currently only supported for GCP HYPERDISK_BALANCED types. + TotalInitialRemoteDiskSize *int `json:"total_initial_remote_disk_size,omitempty"` +} + +type CreateInstancePoolResponse struct { + // The ID of the created instance pool. + InstancePoolId *string `json:"instance_pool_id,omitempty"` +} + +type DeleteInstancePoolRequest struct { + // The instance pool to be terminated. + InstancePoolId *string `json:"instance_pool_id,omitempty"` +} + +// Describes the disks that are launched for each instance in the spark cluster. +// For example, if the cluster has 3 instances, each instance is configured to +// launch 2 disks, 100 GiB each, then will launch a total of 6 +// disks, 100 GiB each, for this cluster.. +type DiskSpec struct { + // The number of disks launched for each instance: - This feature is only + // enabled for supported node types. - Users can choose up to the limit of the + // disks supported by the node type. - For node types with no OS disk, at least + // one disk must be specified; otherwise, cluster creation will fail. + // + // If disks are attached, will configure Spark to use only the + // disks for scratch storage, because heterogenously sized scratch devices can + // lead to inefficient disk utilization. If no disks are attached, + // will configure Spark to use instance store disks. + // + // Note: If disks are specified, then the Spark configuration `spark.local.dir` + // will be overridden. + // + // Disks will be mounted at: - For AWS: `/ebs0`, `/ebs1`, and etc. - For Azure: + // `/remote_volume0`, `/remote_volume1`, and etc. + DiskCount *int `json:"disk_count,omitempty"` + DiskIops *int `json:"disk_iops,omitempty"` + // The size of each disk (in GiB) launched for each instance. Values must fall + // into the supported range for a particular instance type. + // + // For AWS: - General Purpose SSD: 100 - 4096 GiB - Throughput Optimized HDD: + // 500 - 4096 GiB + // + // For Azure: - Premium LRS (SSD): 1 - 1023 GiB - Standard LRS (HDD): 1- 1023 + // GiB + DiskSize *int `json:"disk_size,omitempty"` + DiskThroughput *int `json:"disk_throughput,omitempty"` + // The type of disks that will be launched with this cluster. + DiskType *DiskType `json:"disk_type,omitempty"` +} + +// Describes the disk type.. +type DiskType struct { + AzureDiskVolumeType AzureDiskVolumeType `json:"azure_disk_volume_type,omitempty"` + EbsVolumeType EbsVolumeType `json:"ebs_volume_type,omitempty"` +} + +type DockerBasicAuth struct { + // Password of the user + Password *string `json:"password,omitempty"` + // Name of the user + Username *string `json:"username,omitempty"` +} + +type DockerImage struct { + BasicAuth *DockerBasicAuth `json:"basic_auth,omitempty"` + // URL of the docker image. + Url *string `json:"url,omitempty"` +} + +type EditInstancePoolRequest struct { + // Attributes related to instance pools running on Amazon Web Services. If not + // specified at pool creation, a set of default values will be used. + AwsAttributes *InstancePoolAwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to instance pools running on Azure. If not specified at + // pool creation, a set of default values will be used. + AzureAttributes *InstancePoolAzureAttributes `json:"azure_attributes,omitempty"` + // Additional tags for pool resources. will tag all pool resources + // (e.g., AWS instances and EBS volumes) with these tags in addition to + // `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + // Defines the specification of the disks that will be attached to all spark + // containers. + DiskSpec *DiskSpec `json:"disk_spec,omitempty"` + // Autoscaling Local Storage: when enabled, this instances in this pool will + // dynamically acquire additional disk space when its Spark workers are running + // low on disk space. In AWS, this feature requires specific AWS permissions to + // function correctly - refer to the User Guide for more details. + EnableElasticDisk *bool `json:"enable_elastic_disk,omitempty"` + // Attributes related to instance pools running on Google Cloud Platform. If not + // specified at pool creation, a set of default values will be used. + GcpAttributes *InstancePoolGcpAttributes `json:"gcp_attributes,omitempty"` + // Automatically terminates the extra instances in the pool cache after they are + // inactive for this time in minutes if min_idle_instances requirement is + // already met. If not set, the extra pool instances will be automatically + // terminated after a default timeout. If specified, the threshold must be + // between 0 and 10000 minutes. Users can also set this value to 0 to instantly + // remove idle instances from the cache if min cache size could still hold. + IdleInstanceAutoterminationMinutes *int `json:"idle_instance_autotermination_minutes,omitempty"` + // Instance pool ID + InstancePoolId *string `json:"instance_pool_id,omitempty"` + // Pool name requested by the user. Pool name must be unique. Length must be + // between 1 and 100 characters. + InstancePoolName *string `json:"instance_pool_name,omitempty"` + // Maximum number of outstanding instances to keep in the pool, including both + // instances used by clusters and idle instances. Clusters that require further + // instance provisioning will fail during upsize requests. + MaxCapacity *int `json:"max_capacity,omitempty"` + // Minimum number of idle instances to keep in the instance pool + MinIdleInstances *int `json:"min_idle_instances,omitempty"` + // Flexible node type configuration for the pool. + NodeTypeFlexibility *NodeTypeFlexibility `json:"node_type_flexibility,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // [clusters/listNodeTypes] API call. + // + // [clusters/listNodeTypes]: https://docs.databricks.com/api/workspace/clusters/listnodetypes + NodeTypeId *string `json:"node_type_id,omitempty"` + // Custom Docker Image BYOC + PreloadedDockerImages []DockerImage `json:"preloaded_docker_images,omitempty"` + // A list containing at most one preloaded Spark image version for the pool. + // Pool-backed clusters started with the preloaded Spark version will start + // faster. A list of available Spark versions can be retrieved by using the + // [clusters/sparkVersions] API call. + // + // [clusters/sparkVersions]: https://docs.databricks.com/api/workspace/clusters/sparkversions + PreloadedSparkVersions []string `json:"preloaded_spark_versions,omitempty"` + // If set, what the configurable throughput (in Mb/s) for the remote disk is. + // Currently only supported for GCP HYPERDISK_BALANCED types. + RemoteDiskThroughput *int `json:"remote_disk_throughput,omitempty"` + // If set, what the total initial volume size (in GB) of the remote disks should + // be. Currently only supported for GCP HYPERDISK_BALANCED types. + TotalInitialRemoteDiskSize *int `json:"total_initial_remote_disk_size,omitempty"` +} + +type GetInstancePoolRequest struct { + // The canonical unique identifier for the instance pool. + InstancePoolId *string `json:"instance_pool_id,omitempty"` +} + +type GetInstancePoolResponse struct { + // Attributes related to instance pools running on Amazon Web Services. If not + // specified at pool creation, a set of default values will be used. + AwsAttributes *InstancePoolAwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to instance pools running on Azure. If not specified at + // pool creation, a set of default values will be used. + AzureAttributes *InstancePoolAzureAttributes `json:"azure_attributes,omitempty"` + // Additional tags for pool resources. will tag all pool resources + // (e.g., AWS instances and EBS volumes) with these tags in addition to + // `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + // Tags that are added by regardless of any ``custom_tags``, + // including: + // + // - Vendor: + // + // - InstancePoolCreator: + // + // - InstancePoolName: + // + // - InstancePoolId: + DefaultTags map[string]string `json:"default_tags,omitempty"` + // Defines the specification of the disks that will be attached to all spark + // containers. + DiskSpec *DiskSpec `json:"disk_spec,omitempty"` + // Autoscaling Local Storage: when enabled, this instances in this pool will + // dynamically acquire additional disk space when its Spark workers are running + // low on disk space. In AWS, this feature requires specific AWS permissions to + // function correctly - refer to the User Guide for more details. + EnableElasticDisk *bool `json:"enable_elastic_disk,omitempty"` + // Attributes related to instance pools running on Google Cloud Platform. If not + // specified at pool creation, a set of default values will be used. + GcpAttributes *InstancePoolGcpAttributes `json:"gcp_attributes,omitempty"` + // Automatically terminates the extra instances in the pool cache after they are + // inactive for this time in minutes if min_idle_instances requirement is + // already met. If not set, the extra pool instances will be automatically + // terminated after a default timeout. If specified, the threshold must be + // between 0 and 10000 minutes. Users can also set this value to 0 to instantly + // remove idle instances from the cache if min cache size could still hold. + IdleInstanceAutoterminationMinutes *int `json:"idle_instance_autotermination_minutes,omitempty"` + // Canonical unique identifier for the pool. + InstancePoolId *string `json:"instance_pool_id,omitempty"` + // Pool name requested by the user. Pool name must be unique. Length must be + // between 1 and 100 characters. + InstancePoolName *string `json:"instance_pool_name,omitempty"` + // Maximum number of outstanding instances to keep in the pool, including both + // instances used by clusters and idle instances. Clusters that require further + // instance provisioning will fail during upsize requests. + MaxCapacity *int `json:"max_capacity,omitempty"` + // Minimum number of idle instances to keep in the instance pool + MinIdleInstances *int `json:"min_idle_instances,omitempty"` + // Flexible node type configuration for the pool. + NodeTypeFlexibility *NodeTypeFlexibility `json:"node_type_flexibility,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // [clusters/listNodeTypes] API call. + // + // [clusters/listNodeTypes]: https://docs.databricks.com/api/workspace/clusters/listnodetypes + NodeTypeId *string `json:"node_type_id,omitempty"` + // Custom Docker Image BYOC + PreloadedDockerImages []DockerImage `json:"preloaded_docker_images,omitempty"` + // A list containing at most one preloaded Spark image version for the pool. + // Pool-backed clusters started with the preloaded Spark version will start + // faster. A list of available Spark versions can be retrieved by using the + // [clusters/sparkVersions] API call. + // + // [clusters/sparkVersions]: https://docs.databricks.com/api/workspace/clusters/sparkversions + PreloadedSparkVersions []string `json:"preloaded_spark_versions,omitempty"` + // If set, what the configurable throughput (in Mb/s) for the remote disk is. + // Currently only supported for GCP HYPERDISK_BALANCED types. + RemoteDiskThroughput *int `json:"remote_disk_throughput,omitempty"` + // Current state of the instance pool. + State InstancePoolState `json:"state,omitempty"` + // Usage statistics about the instance pool. + Stats *InstancePoolStats `json:"stats,omitempty"` + // Status of failed pending instances in the pool. + Status *InstancePoolStatus `json:"status,omitempty"` + // If set, what the total initial volume size (in GB) of the remote disks should + // be. Currently only supported for GCP HYPERDISK_BALANCED types. + TotalInitialRemoteDiskSize *int `json:"total_initial_remote_disk_size,omitempty"` +} + +type InstancePoolAndStats struct { + // Attributes related to instance pools running on Amazon Web Services. If not + // specified at pool creation, a set of default values will be used. + AwsAttributes *InstancePoolAwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to instance pools running on Azure. If not specified at + // pool creation, a set of default values will be used. + AzureAttributes *InstancePoolAzureAttributes `json:"azure_attributes,omitempty"` + // Additional tags for pool resources. will tag all pool resources + // (e.g., AWS instances and EBS volumes) with these tags in addition to + // `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + // Tags that are added by regardless of any ``custom_tags``, + // including: + // + // - Vendor: + // + // - InstancePoolCreator: + // + // - InstancePoolName: + // + // - InstancePoolId: + DefaultTags map[string]string `json:"default_tags,omitempty"` + // Defines the specification of the disks that will be attached to all spark + // containers. + DiskSpec *DiskSpec `json:"disk_spec,omitempty"` + // Autoscaling Local Storage: when enabled, this instances in this pool will + // dynamically acquire additional disk space when its Spark workers are running + // low on disk space. In AWS, this feature requires specific AWS permissions to + // function correctly - refer to the User Guide for more details. + EnableElasticDisk *bool `json:"enable_elastic_disk,omitempty"` + // Attributes related to instance pools running on Google Cloud Platform. If not + // specified at pool creation, a set of default values will be used. + GcpAttributes *InstancePoolGcpAttributes `json:"gcp_attributes,omitempty"` + // Automatically terminates the extra instances in the pool cache after they are + // inactive for this time in minutes if min_idle_instances requirement is + // already met. If not set, the extra pool instances will be automatically + // terminated after a default timeout. If specified, the threshold must be + // between 0 and 10000 minutes. Users can also set this value to 0 to instantly + // remove idle instances from the cache if min cache size could still hold. + IdleInstanceAutoterminationMinutes *int `json:"idle_instance_autotermination_minutes,omitempty"` + // Canonical unique identifier for the pool. + InstancePoolId *string `json:"instance_pool_id,omitempty"` + // Pool name requested by the user. Pool name must be unique. Length must be + // between 1 and 100 characters. + InstancePoolName *string `json:"instance_pool_name,omitempty"` + // Maximum number of outstanding instances to keep in the pool, including both + // instances used by clusters and idle instances. Clusters that require further + // instance provisioning will fail during upsize requests. + MaxCapacity *int `json:"max_capacity,omitempty"` + // Minimum number of idle instances to keep in the instance pool + MinIdleInstances *int `json:"min_idle_instances,omitempty"` + // Flexible node type configuration for the pool. + NodeTypeFlexibility *NodeTypeFlexibility `json:"node_type_flexibility,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // [clusters/listNodeTypes] API call. + // + // [clusters/listNodeTypes]: https://docs.databricks.com/api/workspace/clusters/listnodetypes + NodeTypeId *string `json:"node_type_id,omitempty"` + // Custom Docker Image BYOC + PreloadedDockerImages []DockerImage `json:"preloaded_docker_images,omitempty"` + // A list containing at most one preloaded Spark image version for the pool. + // Pool-backed clusters started with the preloaded Spark version will start + // faster. A list of available Spark versions can be retrieved by using the + // [clusters/sparkVersions] API call. + // + // [clusters/sparkVersions]: https://docs.databricks.com/api/workspace/clusters/sparkversions + PreloadedSparkVersions []string `json:"preloaded_spark_versions,omitempty"` + // If set, what the configurable throughput (in Mb/s) for the remote disk is. + // Currently only supported for GCP HYPERDISK_BALANCED types. + RemoteDiskThroughput *int `json:"remote_disk_throughput,omitempty"` + // Current state of the instance pool. + State InstancePoolState `json:"state,omitempty"` + // Usage statistics about the instance pool. + Stats *InstancePoolStats `json:"stats,omitempty"` + // Status of failed pending instances in the pool. + Status *InstancePoolStatus `json:"status,omitempty"` + // If set, what the total initial volume size (in GB) of the remote disks should + // be. Currently only supported for GCP HYPERDISK_BALANCED types. + TotalInitialRemoteDiskSize *int `json:"total_initial_remote_disk_size,omitempty"` +} + +// Attributes set during instance pool creation which are related to Amazon Web +// Services.. +type InstancePoolAwsAttributes struct { + // Availability type used for the instances in the pool. Supports on-demand, + // spot, and spot-with-fallback (the pool acquires spot instances first, and + // falls back to on-demand instances when spot capacity is unavailable). + // + // You can change this value on an existing pool. New clusters use the updated + // availability, and existing clusters keep the availability they launched with. + Availability AwsAvailability `json:"availability,omitempty"` + // All AWS instances belonging to the instance pool will have this instance + // profile. If omitted, instances will initially be launched with the + // workspace's default instance profile. If defined, clusters that use the pool + // will inherit the instance profile, and must not specify their own instance + // profile on cluster creation or update. If the pool does not specify an + // instance profile, clusters using the pool may specify any instance profile. + // The instance profile must have previously been added to the + // environment by an account administrator. + // + // This feature may only be available to certain customer plans. + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // Calculates the bid price for AWS spot instances, as a percentage of the + // corresponding instance type's on-demand price. For example, if this field is + // set to 50, and the cluster needs a new `r3.xlarge` spot instance, then the + // bid price is half of the price of on-demand `r3.xlarge` instances. Similarly, + // if this field is set to 200, the bid price is twice the price of on-demand + // `r3.xlarge` instances. If not specified, the default value is 100. When spot + // instances are requested for this cluster, only spot instances whose bid price + // percentage matches this field will be considered. Note that, for safety, we + // enforce this field to be no more than 10000. + // + // You can change this value on an existing pool. New clusters use the updated + // bid price, and existing clusters keep the bid price they launched with. + SpotBidPricePercent *int `json:"spot_bid_price_percent,omitempty"` + // Identifier for the availability zone/datacenter in which the cluster resides. + // This string will be of a form like "us-west-2a". The provided availability + // zone must be in the same region as the deployment. For example, + // "us-west-2a" is not a valid zone id if the deployment resides in + // the "us-east-1" region. This is an optional field at cluster creation, and if + // not specified, a default zone will be used. The list of available zones as + // well as the default value can be found by using the `List Zones` method. + // + // Set this field to "auto" to enable Auto-AZ, in which case + // selects the availability zone for each cluster independently when the cluster + // launches, and retries another zone if the cluster can't be fulfilled because + // of insufficient capacity or quota. All nodes in a cluster land in the same + // zone, and different clusters backed by the pool can run in different zones. + // + // You can change the zone on an existing pool. New clusters use the updated + // zone, and existing clusters keep the zone they launched with. + ZoneId *string `json:"zone_id,omitempty"` +} + +// Attributes set during instance pool creation which are related to Azure.. +type InstancePoolAzureAttributes struct { + // Availability type used for the instances in the pool. Supports on-demand, + // spot, and spot-with-fallback (the pool acquires spot instances first, and + // falls back to on-demand instances when spot capacity is unavailable). + // + // You can change this value on an existing pool. New clusters use the updated + // availability, and existing clusters keep the availability they launched with. + Availability AzureAvailability `json:"availability,omitempty"` + // The Azure capacity reservation group resource ID to use for launching VMs in + // this pool. When specified, VMs will be launched using the provided capacity + // reservation. + // + // NOTE: Omitting this field will clear any existing configured capacity + // reservation group on the pool. + // + // Capacity reservations can only be specified when the workspace uses injected + // vnet (i.e. customer defined vnet not managed by databricks). Ensure the + // databricks-login-prod Enterprise Application is granted the following four + // permissions: 1. Microsoft.Compute/capacityReservationGroups/read 2. + // Microsoft.Compute/capacityReservationGroups/deploy/action 3. + // Microsoft.Compute/capacityReservationGroups/capacityReservations/read 4. + // Microsoft.Compute/capacityReservationGroups/capacityReservations/deploy/action + // + // Format: + // `/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}` + CapacityReservationGroup *string `json:"capacity_reservation_group,omitempty"` + // With variable pricing, you have option to set a max price, in US dollars + // (USD) For example, the value 2 would be a max price of $2.00 USD per hour. If + // you set the max price to be -1, the VM won't be evicted based on price. The + // price for the VM will be the current price for spot or the price for a + // standard VM, which ever is less, as long as there is capacity and quota + // available. + // + // You can change this value on an existing pool. New clusters use the updated + // max price, and existing clusters keep the max price they launched with. + SpotBidMaxPrice *float64 `json:"spot_bid_max_price,omitempty"` +} + +// Attributes set during instance pool creation which are related to GCP.. +type InstancePoolGcpAttributes struct { + // Availability type for the instances in the pool. One of: + // + // - `ON_DEMAND_GCP`: the pool uses on-demand instances only. - + // `PREEMPTIBLE_GCP`: the pool uses preemptible instances only. - + // `PREEMPTIBLE_WITH_FALLBACK_GCP`: the pool acquires preemptible instances + // first, and falls back to on-demand instances when preemptible capacity is + // unavailable. + GcpAvailability GcpAvailability `json:"gcp_availability,omitempty"` + // If provided, each node in the instance pool will have this number of local + // SSDs attached. Each local SSD is 375GB in size. Refer to [GCP documentation] + // for the supported number of local SSDs for each instance type. + // + // [GCP documentation]: https://cloud.google.com/compute/docs/disks/local-ssd#choose_number_local_ssds + LocalSsdCount *int `json:"local_ssd_count,omitempty"` + // Identifier for the availability zone/datacenter in which the cluster resides. + // This string will be of a form like "us-west1-a". The provided availability + // zone must be in the same region as the workspace. For example, + // "us-west1-a" is not a valid zone id if the workspace resides in + // the "us-east1" region. This is an optional field at instance pool creation, + // and if not specified, a default zone will be used. + // + // This field can be one of the following: - "HA" => High availability, spread + // nodes across availability zones for a deployment region - "auto" + // => Auto-AZ. selects the availability zone for each cluster + // independently when the cluster launches, and retries another zone if the + // cluster can't be fulfilled because of insufficient capacity or quota. All + // nodes in a cluster land in the same zone, and different clusters backed by + // the pool can run in different zones. - A GCP availability zone => Pick One of + // the available zones for (machine type + region) from + // https://cloud.google.com/compute/docs/regions-zones (e.g. "us-west1-a"). + // + // If empty, picks an availability zone to schedule the cluster on. + // + // You can change the zone on an existing pool. New clusters use the updated + // zone, and existing clusters keep the zone they launched with. + ZoneId *string `json:"zone_id,omitempty"` +} + +type InstancePoolStats struct { + // Number of active instances in the pool that are NOT part of a cluster. + IdleCount *int `json:"idle_count,omitempty"` + // Number of pending instances in the pool that are NOT part of a cluster. + PendingIdleCount *int `json:"pending_idle_count,omitempty"` + // Number of pending instances in the pool that are part of a cluster. + PendingUsedCount *int `json:"pending_used_count,omitempty"` + // Number of active instances in the pool that are part of a cluster. + UsedCount *int `json:"used_count,omitempty"` +} + +type InstancePoolStatus struct { + // List of error messages for the failed pending instances. The + // pending_instance_errors follows FIFO with maximum length of the min_idle of + // the pool. The pending_instance_errors is emptied once the number of exiting + // available instances reaches the min_idle of the pool. + PendingInstanceErrors []PendingInstanceError `json:"pending_instance_errors,omitempty"` +} + +type ListInstancePoolsResponse struct { + InstancePools []InstancePoolAndStats `json:"instance_pools,omitempty"` +} + +// Configuration for flexible node types, allowing fallback to alternate node +// types during cluster launch and upscale.. +type NodeTypeFlexibility struct { + // A list of node type IDs to use as fallbacks when the primary node type is + // unavailable. + AlternateNodeTypeIds []string `json:"alternate_node_type_ids,omitempty"` + // The AWS Context ID for EC2 Fleet. When set (non-empty), the value is passed + // to AWS CreateFleet API to create the EC2 Fleet. + AwsContextId *string `json:"aws_context_id,omitempty"` +} + +// Error message of a failed pending instances. +type PendingInstanceError struct { + InstanceId *string `json:"instance_id,omitempty"` + Message *string `json:"message,omitempty"` +} + +// CreateInstancePoolRequestToSDK converts the mirror to the sdk-go type. +func CreateInstancePoolRequestToSDK(w *CreateInstancePoolRequest) (*sdk.CreateInstancePoolRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateInstancePoolRequest{} + out.InstancePoolName = w.InstancePoolName + out.MinIdleInstances = w.MinIdleInstances + out.MaxCapacity = w.MaxCapacity + conv1, err := InstancePoolAwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstancePoolRequest.AwsAttributes", err) + } + out.AwsAttributes = conv1 + out.NodeTypeId = w.NodeTypeId + out.CustomTags = w.CustomTags + out.IdleInstanceAutoterminationMinutes = w.IdleInstanceAutoterminationMinutes + out.EnableElasticDisk = w.EnableElasticDisk + conv2, err := DiskSpecToSDK(w.DiskSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstancePoolRequest.DiskSpec", err) + } + out.DiskSpec = conv2 + conv3, err := convertSlice(w.PreloadedDockerImages, DockerImageToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstancePoolRequest.PreloadedDockerImages", err) + } + out.PreloadedDockerImages = conv3 + out.PreloadedSparkVersions = w.PreloadedSparkVersions + conv4, err := InstancePoolAzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstancePoolRequest.AzureAttributes", err) + } + out.AzureAttributes = conv4 + conv5, err := InstancePoolGcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstancePoolRequest.GcpAttributes", err) + } + out.GcpAttributes = conv5 + conv6, err := NodeTypeFlexibilityToSDK(w.NodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstancePoolRequest.NodeTypeFlexibility", err) + } + out.NodeTypeFlexibility = conv6 + out.RemoteDiskThroughput = w.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = w.TotalInitialRemoteDiskSize + return out, nil +} + +// CreateInstancePoolRequestFromSDK converts the sdk-go type to the mirror. +func CreateInstancePoolRequestFromSDK(v *sdk.CreateInstancePoolRequest) (*CreateInstancePoolRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateInstancePoolRequest{} + out.InstancePoolName = v.InstancePoolName + out.MinIdleInstances = v.MinIdleInstances + out.MaxCapacity = v.MaxCapacity + conv7, err := InstancePoolAwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstancePoolRequest.AwsAttributes", err) + } + out.AwsAttributes = conv7 + out.NodeTypeId = v.NodeTypeId + out.CustomTags = v.CustomTags + out.IdleInstanceAutoterminationMinutes = v.IdleInstanceAutoterminationMinutes + out.EnableElasticDisk = v.EnableElasticDisk + conv8, err := DiskSpecFromSDK(v.DiskSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstancePoolRequest.DiskSpec", err) + } + out.DiskSpec = conv8 + conv9, err := convertSlice(v.PreloadedDockerImages, DockerImageFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstancePoolRequest.PreloadedDockerImages", err) + } + out.PreloadedDockerImages = conv9 + out.PreloadedSparkVersions = v.PreloadedSparkVersions + conv10, err := InstancePoolAzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstancePoolRequest.AzureAttributes", err) + } + out.AzureAttributes = conv10 + conv11, err := InstancePoolGcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstancePoolRequest.GcpAttributes", err) + } + out.GcpAttributes = conv11 + conv12, err := NodeTypeFlexibilityFromSDK(v.NodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstancePoolRequest.NodeTypeFlexibility", err) + } + out.NodeTypeFlexibility = conv12 + out.RemoteDiskThroughput = v.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = v.TotalInitialRemoteDiskSize + return out, nil +} + +// CreateInstancePoolResponseToSDK converts the mirror to the sdk-go type. +func CreateInstancePoolResponseToSDK(w *CreateInstancePoolResponse) (*sdk.CreateInstancePoolResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateInstancePoolResponse{} + out.InstancePoolId = w.InstancePoolId + return out, nil +} + +// CreateInstancePoolResponseFromSDK converts the sdk-go type to the mirror. +func CreateInstancePoolResponseFromSDK(v *sdk.CreateInstancePoolResponse) (*CreateInstancePoolResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateInstancePoolResponse{} + out.InstancePoolId = v.InstancePoolId + return out, nil +} + +// DeleteInstancePoolRequestToSDK converts the mirror to the sdk-go type. +func DeleteInstancePoolRequestToSDK(w *DeleteInstancePoolRequest) (*sdk.DeleteInstancePoolRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteInstancePoolRequest{} + out.InstancePoolId = w.InstancePoolId + return out, nil +} + +// DeleteInstancePoolRequestFromSDK converts the sdk-go type to the mirror. +func DeleteInstancePoolRequestFromSDK(v *sdk.DeleteInstancePoolRequest) (*DeleteInstancePoolRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteInstancePoolRequest{} + out.InstancePoolId = v.InstancePoolId + return out, nil +} + +// DiskSpecToSDK converts the mirror to the sdk-go type. +func DiskSpecToSDK(w *DiskSpec) (*sdk.DiskSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.DiskSpec{} + conv13, err := DiskTypeToSDK(w.DiskType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DiskSpec.DiskType", err) + } + out.DiskType = conv13 + out.DiskCount = w.DiskCount + out.DiskSize = w.DiskSize + out.DiskIops = w.DiskIops + out.DiskThroughput = w.DiskThroughput + return out, nil +} + +// DiskSpecFromSDK converts the sdk-go type to the mirror. +func DiskSpecFromSDK(v *sdk.DiskSpec) (*DiskSpec, error) { + if v == nil { + return nil, nil + } + out := &DiskSpec{} + conv14, err := DiskTypeFromSDK(v.DiskType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DiskSpec.DiskType", err) + } + out.DiskType = conv14 + out.DiskCount = v.DiskCount + out.DiskSize = v.DiskSize + out.DiskIops = v.DiskIops + out.DiskThroughput = v.DiskThroughput + return out, nil +} + +// DiskTypeToSDK converts the mirror to the sdk-go type. +func DiskTypeToSDK(w *DiskType) (*sdk.DiskType, error) { + if w == nil { + return nil, nil + } + out := &sdk.DiskType{} + { + var members []string + if w.EbsVolumeType != "" { + members = append(members, "ebs_volume_type") + } + if w.AzureDiskVolumeType != "" { + members = append(members, "azure_disk_volume_type") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.EbsVolumeType != "": + out.RemoteVolumeType = &sdk.DiskType_RemoteVolumeType_EbsVolumeType{EbsVolumeType: w.EbsVolumeType} + case w.AzureDiskVolumeType != "": + out.RemoteVolumeType = &sdk.DiskType_RemoteVolumeType_AzureDiskVolumeType{AzureDiskVolumeType: w.AzureDiskVolumeType} + } + return out, nil +} + +// DiskTypeFromSDK converts the sdk-go type to the mirror. +func DiskTypeFromSDK(v *sdk.DiskType) (*DiskType, error) { + if v == nil { + return nil, nil + } + out := &DiskType{} + switch value := v.RemoteVolumeType.(type) { + case *sdk.DiskType_RemoteVolumeType_EbsVolumeType: + if value != nil { + out.EbsVolumeType = value.EbsVolumeType + } + case *sdk.DiskType_RemoteVolumeType_AzureDiskVolumeType: + if value != nil { + out.AzureDiskVolumeType = value.AzureDiskVolumeType + } + } + return out, nil +} + +// DockerBasicAuthToSDK converts the mirror to the sdk-go type. +func DockerBasicAuthToSDK(w *DockerBasicAuth) (*sdk.DockerBasicAuth, error) { + if w == nil { + return nil, nil + } + out := &sdk.DockerBasicAuth{} + out.Username = w.Username + out.Password = w.Password + return out, nil +} + +// DockerBasicAuthFromSDK converts the sdk-go type to the mirror. +func DockerBasicAuthFromSDK(v *sdk.DockerBasicAuth) (*DockerBasicAuth, error) { + if v == nil { + return nil, nil + } + out := &DockerBasicAuth{} + out.Username = v.Username + out.Password = v.Password + return out, nil +} + +// DockerImageToSDK converts the mirror to the sdk-go type. +func DockerImageToSDK(w *DockerImage) (*sdk.DockerImage, error) { + if w == nil { + return nil, nil + } + out := &sdk.DockerImage{} + out.Url = w.Url + { + var members []string + if w.BasicAuth != nil { + members = append(members, "basic_auth") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.BasicAuth != nil: + conv15, err := DockerBasicAuthToSDK(w.BasicAuth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DockerImage.CredsOneof", err) + } + out.CredsOneof = &sdk.DockerImage_CredsOneof_BasicAuth{BasicAuth: *conv15} + } + return out, nil +} + +// DockerImageFromSDK converts the sdk-go type to the mirror. +func DockerImageFromSDK(v *sdk.DockerImage) (*DockerImage, error) { + if v == nil { + return nil, nil + } + out := &DockerImage{} + out.Url = v.Url + switch value := v.CredsOneof.(type) { + case *sdk.DockerImage_CredsOneof_BasicAuth: + if value != nil { + conv16, err := DockerBasicAuthFromSDK(&value.BasicAuth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DockerImage.CredsOneof", err) + } + out.BasicAuth = conv16 + } + } + return out, nil +} + +// EditInstancePoolRequestToSDK converts the mirror to the sdk-go type. +func EditInstancePoolRequestToSDK(w *EditInstancePoolRequest) (*sdk.EditInstancePoolRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.EditInstancePoolRequest{} + out.InstancePoolId = w.InstancePoolId + out.InstancePoolName = w.InstancePoolName + out.MinIdleInstances = w.MinIdleInstances + out.MaxCapacity = w.MaxCapacity + conv17, err := InstancePoolAwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditInstancePoolRequest.AwsAttributes", err) + } + out.AwsAttributes = conv17 + out.NodeTypeId = w.NodeTypeId + out.CustomTags = w.CustomTags + out.IdleInstanceAutoterminationMinutes = w.IdleInstanceAutoterminationMinutes + out.EnableElasticDisk = w.EnableElasticDisk + conv18, err := DiskSpecToSDK(w.DiskSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditInstancePoolRequest.DiskSpec", err) + } + out.DiskSpec = conv18 + conv19, err := convertSlice(w.PreloadedDockerImages, DockerImageToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditInstancePoolRequest.PreloadedDockerImages", err) + } + out.PreloadedDockerImages = conv19 + out.PreloadedSparkVersions = w.PreloadedSparkVersions + conv20, err := InstancePoolAzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditInstancePoolRequest.AzureAttributes", err) + } + out.AzureAttributes = conv20 + conv21, err := InstancePoolGcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditInstancePoolRequest.GcpAttributes", err) + } + out.GcpAttributes = conv21 + conv22, err := NodeTypeFlexibilityToSDK(w.NodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditInstancePoolRequest.NodeTypeFlexibility", err) + } + out.NodeTypeFlexibility = conv22 + out.RemoteDiskThroughput = w.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = w.TotalInitialRemoteDiskSize + return out, nil +} + +// EditInstancePoolRequestFromSDK converts the sdk-go type to the mirror. +func EditInstancePoolRequestFromSDK(v *sdk.EditInstancePoolRequest) (*EditInstancePoolRequest, error) { + if v == nil { + return nil, nil + } + out := &EditInstancePoolRequest{} + out.InstancePoolId = v.InstancePoolId + out.InstancePoolName = v.InstancePoolName + out.MinIdleInstances = v.MinIdleInstances + out.MaxCapacity = v.MaxCapacity + conv23, err := InstancePoolAwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditInstancePoolRequest.AwsAttributes", err) + } + out.AwsAttributes = conv23 + out.NodeTypeId = v.NodeTypeId + out.CustomTags = v.CustomTags + out.IdleInstanceAutoterminationMinutes = v.IdleInstanceAutoterminationMinutes + out.EnableElasticDisk = v.EnableElasticDisk + conv24, err := DiskSpecFromSDK(v.DiskSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditInstancePoolRequest.DiskSpec", err) + } + out.DiskSpec = conv24 + conv25, err := convertSlice(v.PreloadedDockerImages, DockerImageFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditInstancePoolRequest.PreloadedDockerImages", err) + } + out.PreloadedDockerImages = conv25 + out.PreloadedSparkVersions = v.PreloadedSparkVersions + conv26, err := InstancePoolAzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditInstancePoolRequest.AzureAttributes", err) + } + out.AzureAttributes = conv26 + conv27, err := InstancePoolGcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditInstancePoolRequest.GcpAttributes", err) + } + out.GcpAttributes = conv27 + conv28, err := NodeTypeFlexibilityFromSDK(v.NodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditInstancePoolRequest.NodeTypeFlexibility", err) + } + out.NodeTypeFlexibility = conv28 + out.RemoteDiskThroughput = v.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = v.TotalInitialRemoteDiskSize + return out, nil +} + +// GetInstancePoolRequestToSDK converts the mirror to the sdk-go type. +func GetInstancePoolRequestToSDK(w *GetInstancePoolRequest) (*sdk.GetInstancePoolRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetInstancePoolRequest{} + out.InstancePoolId = w.InstancePoolId + return out, nil +} + +// GetInstancePoolRequestFromSDK converts the sdk-go type to the mirror. +func GetInstancePoolRequestFromSDK(v *sdk.GetInstancePoolRequest) (*GetInstancePoolRequest, error) { + if v == nil { + return nil, nil + } + out := &GetInstancePoolRequest{} + out.InstancePoolId = v.InstancePoolId + return out, nil +} + +// GetInstancePoolResponseToSDK converts the mirror to the sdk-go type. +func GetInstancePoolResponseToSDK(w *GetInstancePoolResponse) (*sdk.GetInstancePoolResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetInstancePoolResponse{} + conv29, err := InstancePoolStatsToSDK(w.Stats) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.Stats", err) + } + out.Stats = conv29 + conv30, err := InstancePoolStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.Status", err) + } + out.Status = conv30 + out.InstancePoolId = w.InstancePoolId + out.DefaultTags = w.DefaultTags + out.State = w.State + out.InstancePoolName = w.InstancePoolName + out.MinIdleInstances = w.MinIdleInstances + out.MaxCapacity = w.MaxCapacity + conv31, err := InstancePoolAwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.AwsAttributes", err) + } + out.AwsAttributes = conv31 + out.NodeTypeId = w.NodeTypeId + out.CustomTags = w.CustomTags + out.IdleInstanceAutoterminationMinutes = w.IdleInstanceAutoterminationMinutes + out.EnableElasticDisk = w.EnableElasticDisk + conv32, err := DiskSpecToSDK(w.DiskSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.DiskSpec", err) + } + out.DiskSpec = conv32 + conv33, err := convertSlice(w.PreloadedDockerImages, DockerImageToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.PreloadedDockerImages", err) + } + out.PreloadedDockerImages = conv33 + out.PreloadedSparkVersions = w.PreloadedSparkVersions + conv34, err := InstancePoolAzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.AzureAttributes", err) + } + out.AzureAttributes = conv34 + conv35, err := InstancePoolGcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.GcpAttributes", err) + } + out.GcpAttributes = conv35 + conv36, err := NodeTypeFlexibilityToSDK(w.NodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.NodeTypeFlexibility", err) + } + out.NodeTypeFlexibility = conv36 + out.RemoteDiskThroughput = w.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = w.TotalInitialRemoteDiskSize + return out, nil +} + +// GetInstancePoolResponseFromSDK converts the sdk-go type to the mirror. +func GetInstancePoolResponseFromSDK(v *sdk.GetInstancePoolResponse) (*GetInstancePoolResponse, error) { + if v == nil { + return nil, nil + } + out := &GetInstancePoolResponse{} + conv37, err := InstancePoolStatsFromSDK(v.Stats) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.Stats", err) + } + out.Stats = conv37 + conv38, err := InstancePoolStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.Status", err) + } + out.Status = conv38 + out.InstancePoolId = v.InstancePoolId + out.DefaultTags = v.DefaultTags + out.State = v.State + out.InstancePoolName = v.InstancePoolName + out.MinIdleInstances = v.MinIdleInstances + out.MaxCapacity = v.MaxCapacity + conv39, err := InstancePoolAwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.AwsAttributes", err) + } + out.AwsAttributes = conv39 + out.NodeTypeId = v.NodeTypeId + out.CustomTags = v.CustomTags + out.IdleInstanceAutoterminationMinutes = v.IdleInstanceAutoterminationMinutes + out.EnableElasticDisk = v.EnableElasticDisk + conv40, err := DiskSpecFromSDK(v.DiskSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.DiskSpec", err) + } + out.DiskSpec = conv40 + conv41, err := convertSlice(v.PreloadedDockerImages, DockerImageFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.PreloadedDockerImages", err) + } + out.PreloadedDockerImages = conv41 + out.PreloadedSparkVersions = v.PreloadedSparkVersions + conv42, err := InstancePoolAzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.AzureAttributes", err) + } + out.AzureAttributes = conv42 + conv43, err := InstancePoolGcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.GcpAttributes", err) + } + out.GcpAttributes = conv43 + conv44, err := NodeTypeFlexibilityFromSDK(v.NodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetInstancePoolResponse.NodeTypeFlexibility", err) + } + out.NodeTypeFlexibility = conv44 + out.RemoteDiskThroughput = v.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = v.TotalInitialRemoteDiskSize + return out, nil +} + +// InstancePoolAndStatsToSDK converts the mirror to the sdk-go type. +func InstancePoolAndStatsToSDK(w *InstancePoolAndStats) (*sdk.InstancePoolAndStats, error) { + if w == nil { + return nil, nil + } + out := &sdk.InstancePoolAndStats{} + conv45, err := InstancePoolStatsToSDK(w.Stats) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.Stats", err) + } + out.Stats = conv45 + conv46, err := InstancePoolStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.Status", err) + } + out.Status = conv46 + out.InstancePoolId = w.InstancePoolId + out.DefaultTags = w.DefaultTags + out.State = w.State + out.InstancePoolName = w.InstancePoolName + out.MinIdleInstances = w.MinIdleInstances + out.MaxCapacity = w.MaxCapacity + conv47, err := InstancePoolAwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.AwsAttributes", err) + } + out.AwsAttributes = conv47 + out.NodeTypeId = w.NodeTypeId + out.CustomTags = w.CustomTags + out.IdleInstanceAutoterminationMinutes = w.IdleInstanceAutoterminationMinutes + out.EnableElasticDisk = w.EnableElasticDisk + conv48, err := DiskSpecToSDK(w.DiskSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.DiskSpec", err) + } + out.DiskSpec = conv48 + conv49, err := convertSlice(w.PreloadedDockerImages, DockerImageToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.PreloadedDockerImages", err) + } + out.PreloadedDockerImages = conv49 + out.PreloadedSparkVersions = w.PreloadedSparkVersions + conv50, err := InstancePoolAzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.AzureAttributes", err) + } + out.AzureAttributes = conv50 + conv51, err := InstancePoolGcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.GcpAttributes", err) + } + out.GcpAttributes = conv51 + conv52, err := NodeTypeFlexibilityToSDK(w.NodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.NodeTypeFlexibility", err) + } + out.NodeTypeFlexibility = conv52 + out.RemoteDiskThroughput = w.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = w.TotalInitialRemoteDiskSize + return out, nil +} + +// InstancePoolAndStatsFromSDK converts the sdk-go type to the mirror. +func InstancePoolAndStatsFromSDK(v *sdk.InstancePoolAndStats) (*InstancePoolAndStats, error) { + if v == nil { + return nil, nil + } + out := &InstancePoolAndStats{} + conv53, err := InstancePoolStatsFromSDK(v.Stats) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.Stats", err) + } + out.Stats = conv53 + conv54, err := InstancePoolStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.Status", err) + } + out.Status = conv54 + out.InstancePoolId = v.InstancePoolId + out.DefaultTags = v.DefaultTags + out.State = v.State + out.InstancePoolName = v.InstancePoolName + out.MinIdleInstances = v.MinIdleInstances + out.MaxCapacity = v.MaxCapacity + conv55, err := InstancePoolAwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.AwsAttributes", err) + } + out.AwsAttributes = conv55 + out.NodeTypeId = v.NodeTypeId + out.CustomTags = v.CustomTags + out.IdleInstanceAutoterminationMinutes = v.IdleInstanceAutoterminationMinutes + out.EnableElasticDisk = v.EnableElasticDisk + conv56, err := DiskSpecFromSDK(v.DiskSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.DiskSpec", err) + } + out.DiskSpec = conv56 + conv57, err := convertSlice(v.PreloadedDockerImages, DockerImageFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.PreloadedDockerImages", err) + } + out.PreloadedDockerImages = conv57 + out.PreloadedSparkVersions = v.PreloadedSparkVersions + conv58, err := InstancePoolAzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.AzureAttributes", err) + } + out.AzureAttributes = conv58 + conv59, err := InstancePoolGcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.GcpAttributes", err) + } + out.GcpAttributes = conv59 + conv60, err := NodeTypeFlexibilityFromSDK(v.NodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolAndStats.NodeTypeFlexibility", err) + } + out.NodeTypeFlexibility = conv60 + out.RemoteDiskThroughput = v.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = v.TotalInitialRemoteDiskSize + return out, nil +} + +// InstancePoolAwsAttributesToSDK converts the mirror to the sdk-go type. +func InstancePoolAwsAttributesToSDK(w *InstancePoolAwsAttributes) (*sdk.InstancePoolAwsAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.InstancePoolAwsAttributes{} + out.Availability = w.Availability + out.ZoneId = w.ZoneId + out.SpotBidPricePercent = w.SpotBidPricePercent + out.InstanceProfileArn = w.InstanceProfileArn + return out, nil +} + +// InstancePoolAwsAttributesFromSDK converts the sdk-go type to the mirror. +func InstancePoolAwsAttributesFromSDK(v *sdk.InstancePoolAwsAttributes) (*InstancePoolAwsAttributes, error) { + if v == nil { + return nil, nil + } + out := &InstancePoolAwsAttributes{} + out.Availability = v.Availability + out.ZoneId = v.ZoneId + out.SpotBidPricePercent = v.SpotBidPricePercent + out.InstanceProfileArn = v.InstanceProfileArn + return out, nil +} + +// InstancePoolAzureAttributesToSDK converts the mirror to the sdk-go type. +func InstancePoolAzureAttributesToSDK(w *InstancePoolAzureAttributes) (*sdk.InstancePoolAzureAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.InstancePoolAzureAttributes{} + out.Availability = w.Availability + out.SpotBidMaxPrice = w.SpotBidMaxPrice + out.CapacityReservationGroup = w.CapacityReservationGroup + return out, nil +} + +// InstancePoolAzureAttributesFromSDK converts the sdk-go type to the mirror. +func InstancePoolAzureAttributesFromSDK(v *sdk.InstancePoolAzureAttributes) (*InstancePoolAzureAttributes, error) { + if v == nil { + return nil, nil + } + out := &InstancePoolAzureAttributes{} + out.Availability = v.Availability + out.SpotBidMaxPrice = v.SpotBidMaxPrice + out.CapacityReservationGroup = v.CapacityReservationGroup + return out, nil +} + +// InstancePoolGcpAttributesToSDK converts the mirror to the sdk-go type. +func InstancePoolGcpAttributesToSDK(w *InstancePoolGcpAttributes) (*sdk.InstancePoolGcpAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.InstancePoolGcpAttributes{} + out.GcpAvailability = w.GcpAvailability + out.LocalSsdCount = w.LocalSsdCount + out.ZoneId = w.ZoneId + return out, nil +} + +// InstancePoolGcpAttributesFromSDK converts the sdk-go type to the mirror. +func InstancePoolGcpAttributesFromSDK(v *sdk.InstancePoolGcpAttributes) (*InstancePoolGcpAttributes, error) { + if v == nil { + return nil, nil + } + out := &InstancePoolGcpAttributes{} + out.GcpAvailability = v.GcpAvailability + out.LocalSsdCount = v.LocalSsdCount + out.ZoneId = v.ZoneId + return out, nil +} + +// InstancePoolStatsToSDK converts the mirror to the sdk-go type. +func InstancePoolStatsToSDK(w *InstancePoolStats) (*sdk.InstancePoolStats, error) { + if w == nil { + return nil, nil + } + out := &sdk.InstancePoolStats{} + out.UsedCount = w.UsedCount + out.IdleCount = w.IdleCount + out.PendingUsedCount = w.PendingUsedCount + out.PendingIdleCount = w.PendingIdleCount + return out, nil +} + +// InstancePoolStatsFromSDK converts the sdk-go type to the mirror. +func InstancePoolStatsFromSDK(v *sdk.InstancePoolStats) (*InstancePoolStats, error) { + if v == nil { + return nil, nil + } + out := &InstancePoolStats{} + out.UsedCount = v.UsedCount + out.IdleCount = v.IdleCount + out.PendingUsedCount = v.PendingUsedCount + out.PendingIdleCount = v.PendingIdleCount + return out, nil +} + +// InstancePoolStatusToSDK converts the mirror to the sdk-go type. +func InstancePoolStatusToSDK(w *InstancePoolStatus) (*sdk.InstancePoolStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.InstancePoolStatus{} + conv61, err := convertSlice(w.PendingInstanceErrors, PendingInstanceErrorToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolStatus.PendingInstanceErrors", err) + } + out.PendingInstanceErrors = conv61 + return out, nil +} + +// InstancePoolStatusFromSDK converts the sdk-go type to the mirror. +func InstancePoolStatusFromSDK(v *sdk.InstancePoolStatus) (*InstancePoolStatus, error) { + if v == nil { + return nil, nil + } + out := &InstancePoolStatus{} + conv62, err := convertSlice(v.PendingInstanceErrors, PendingInstanceErrorFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstancePoolStatus.PendingInstanceErrors", err) + } + out.PendingInstanceErrors = conv62 + return out, nil +} + +// ListInstancePoolsResponseToSDK converts the mirror to the sdk-go type. +func ListInstancePoolsResponseToSDK(w *ListInstancePoolsResponse) (*sdk.ListInstancePoolsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListInstancePoolsResponse{} + conv63, err := convertSlice(w.InstancePools, InstancePoolAndStatsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListInstancePoolsResponse.InstancePools", err) + } + out.InstancePools = conv63 + return out, nil +} + +// ListInstancePoolsResponseFromSDK converts the sdk-go type to the mirror. +func ListInstancePoolsResponseFromSDK(v *sdk.ListInstancePoolsResponse) (*ListInstancePoolsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListInstancePoolsResponse{} + conv64, err := convertSlice(v.InstancePools, InstancePoolAndStatsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListInstancePoolsResponse.InstancePools", err) + } + out.InstancePools = conv64 + return out, nil +} + +// NodeTypeFlexibilityToSDK converts the mirror to the sdk-go type. +func NodeTypeFlexibilityToSDK(w *NodeTypeFlexibility) (*sdk.NodeTypeFlexibility, error) { + if w == nil { + return nil, nil + } + out := &sdk.NodeTypeFlexibility{} + out.AlternateNodeTypeIds = w.AlternateNodeTypeIds + out.AwsContextId = w.AwsContextId + return out, nil +} + +// NodeTypeFlexibilityFromSDK converts the sdk-go type to the mirror. +func NodeTypeFlexibilityFromSDK(v *sdk.NodeTypeFlexibility) (*NodeTypeFlexibility, error) { + if v == nil { + return nil, nil + } + out := &NodeTypeFlexibility{} + out.AlternateNodeTypeIds = v.AlternateNodeTypeIds + out.AwsContextId = v.AwsContextId + return out, nil +} + +// PendingInstanceErrorToSDK converts the mirror to the sdk-go type. +func PendingInstanceErrorToSDK(w *PendingInstanceError) (*sdk.PendingInstanceError, error) { + if w == nil { + return nil, nil + } + out := &sdk.PendingInstanceError{} + out.InstanceId = w.InstanceId + out.Message = w.Message + return out, nil +} + +// PendingInstanceErrorFromSDK converts the sdk-go type to the mirror. +func PendingInstanceErrorFromSDK(v *sdk.PendingInstanceError) (*PendingInstanceError, error) { + if v == nil { + return nil, nil + } + out := &PendingInstanceError{} + out.InstanceId = v.InstanceId + out.Message = v.Message + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/instanceprofiles/v2/types.generated.go b/libs/sdktypes/instanceprofiles/v2/types.generated.go new file mode 100644 index 00000000000..93600f3846c --- /dev/null +++ b/libs/sdktypes/instanceprofiles/v2/types.generated.go @@ -0,0 +1,220 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/instanceprofiles/v2. DO NOT EDIT. + +package instanceprofiles + +import ( + fmt "fmt" + sdk "github.com/databricks/sdk-go/instanceprofiles/v2" +) + +type AddInstanceProfileRequest struct { + // The AWS IAM role ARN of the role associated with the instance profile. This + // field is required if your role name and instance profile name do not match + // and you want to use the instance profile with [Databricks SQL + // Serverless](/sql/admin/serverless.html). + // + // Otherwise, this field is optional. + IamRoleArn *string `json:"iam_role_arn,omitempty"` + // The AWS ARN of the instance profile to register with . This field + // is required. + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // Boolean flag indicating whether the instance profile should only be used in + // credential passthrough scenarios. If true, it means the instance profile + // contains an meta IAM role which could assume a wide range of roles. Therefore + // it should always be used with authorization. This field is optional, the + // default value is `false`. + IsMetaInstanceProfile *bool `json:"is_meta_instance_profile,omitempty"` + // By default, validates that it has sufficient permissions to + // launch instances with the instance profile. This validation uses AWS dry-run + // mode for the RunInstances API. If validation fails with an error message that + // does not indicate an IAM related permission issue, (e.g. “Your requested + // instance type is not supported in your requested availability zone”), you + // can pass this flag to skip the validation and forcibly add the instance + // profile. + SkipValidation *bool `json:"skip_validation,omitempty"` +} + +type EditInstanceProfileRequest struct { + // The AWS IAM role ARN of the role associated with the instance profile. This + // field is required if your role name and instance profile name do not match + // and you want to use the instance profile with [Databricks SQL + // Serverless](/sql/admin/serverless.html). + // + // Otherwise, this field is optional. + IamRoleArn *string `json:"iam_role_arn,omitempty"` + // The AWS ARN of the instance profile to register with . This field + // is required. + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // Boolean flag indicating whether the instance profile should only be used in + // credential passthrough scenarios. If true, it means the instance profile + // contains an meta IAM role which could assume a wide range of roles. Therefore + // it should always be used with authorization. This field is optional, the + // default value is `false`. + IsMetaInstanceProfile *bool `json:"is_meta_instance_profile,omitempty"` +} + +type InstanceProfile struct { + // The AWS IAM role ARN of the role associated with the instance profile. This + // field is required if your role name and instance profile name do not match + // and you want to use the instance profile with [Databricks SQL + // Serverless](/sql/admin/serverless.html). + // + // Otherwise, this field is optional. + IamRoleArn *string `json:"iam_role_arn,omitempty"` + // The AWS ARN of the instance profile to register with . This field + // is required. + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // Boolean flag indicating whether the instance profile should only be used in + // credential passthrough scenarios. If true, it means the instance profile + // contains an meta IAM role which could assume a wide range of roles. Therefore + // it should always be used with authorization. This field is optional, the + // default value is `false`. + IsMetaInstanceProfile *bool `json:"is_meta_instance_profile,omitempty"` +} + +type ListInstanceProfilesResponse struct { + // A list of instance profiles that the user can access. + InstanceProfiles []InstanceProfile `json:"instance_profiles,omitempty"` +} + +type RemoveInstanceProfileRequest struct { + // The ARN of the instance profile to remove. This field is required. + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` +} + +// AddInstanceProfileRequestToSDK converts the mirror to the sdk-go type. +func AddInstanceProfileRequestToSDK(w *AddInstanceProfileRequest) (*sdk.AddInstanceProfileRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AddInstanceProfileRequest{} + out.SkipValidation = w.SkipValidation + out.InstanceProfileArn = w.InstanceProfileArn + out.IsMetaInstanceProfile = w.IsMetaInstanceProfile + out.IamRoleArn = w.IamRoleArn + return out, nil +} + +// AddInstanceProfileRequestFromSDK converts the sdk-go type to the mirror. +func AddInstanceProfileRequestFromSDK(v *sdk.AddInstanceProfileRequest) (*AddInstanceProfileRequest, error) { + if v == nil { + return nil, nil + } + out := &AddInstanceProfileRequest{} + out.SkipValidation = v.SkipValidation + out.InstanceProfileArn = v.InstanceProfileArn + out.IsMetaInstanceProfile = v.IsMetaInstanceProfile + out.IamRoleArn = v.IamRoleArn + return out, nil +} + +// EditInstanceProfileRequestToSDK converts the mirror to the sdk-go type. +func EditInstanceProfileRequestToSDK(w *EditInstanceProfileRequest) (*sdk.EditInstanceProfileRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.EditInstanceProfileRequest{} + out.InstanceProfileArn = w.InstanceProfileArn + out.IsMetaInstanceProfile = w.IsMetaInstanceProfile + out.IamRoleArn = w.IamRoleArn + return out, nil +} + +// EditInstanceProfileRequestFromSDK converts the sdk-go type to the mirror. +func EditInstanceProfileRequestFromSDK(v *sdk.EditInstanceProfileRequest) (*EditInstanceProfileRequest, error) { + if v == nil { + return nil, nil + } + out := &EditInstanceProfileRequest{} + out.InstanceProfileArn = v.InstanceProfileArn + out.IsMetaInstanceProfile = v.IsMetaInstanceProfile + out.IamRoleArn = v.IamRoleArn + return out, nil +} + +// InstanceProfileToSDK converts the mirror to the sdk-go type. +func InstanceProfileToSDK(w *InstanceProfile) (*sdk.InstanceProfile, error) { + if w == nil { + return nil, nil + } + out := &sdk.InstanceProfile{} + out.InstanceProfileArn = w.InstanceProfileArn + out.IsMetaInstanceProfile = w.IsMetaInstanceProfile + out.IamRoleArn = w.IamRoleArn + return out, nil +} + +// InstanceProfileFromSDK converts the sdk-go type to the mirror. +func InstanceProfileFromSDK(v *sdk.InstanceProfile) (*InstanceProfile, error) { + if v == nil { + return nil, nil + } + out := &InstanceProfile{} + out.InstanceProfileArn = v.InstanceProfileArn + out.IsMetaInstanceProfile = v.IsMetaInstanceProfile + out.IamRoleArn = v.IamRoleArn + return out, nil +} + +// ListInstanceProfilesResponseToSDK converts the mirror to the sdk-go type. +func ListInstanceProfilesResponseToSDK(w *ListInstanceProfilesResponse) (*sdk.ListInstanceProfilesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListInstanceProfilesResponse{} + conv1, err := convertSlice(w.InstanceProfiles, InstanceProfileToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListInstanceProfilesResponse.InstanceProfiles", err) + } + out.InstanceProfiles = conv1 + return out, nil +} + +// ListInstanceProfilesResponseFromSDK converts the sdk-go type to the mirror. +func ListInstanceProfilesResponseFromSDK(v *sdk.ListInstanceProfilesResponse) (*ListInstanceProfilesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListInstanceProfilesResponse{} + conv2, err := convertSlice(v.InstanceProfiles, InstanceProfileFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListInstanceProfilesResponse.InstanceProfiles", err) + } + out.InstanceProfiles = conv2 + return out, nil +} + +// RemoveInstanceProfileRequestToSDK converts the mirror to the sdk-go type. +func RemoveInstanceProfileRequestToSDK(w *RemoveInstanceProfileRequest) (*sdk.RemoveInstanceProfileRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RemoveInstanceProfileRequest{} + out.InstanceProfileArn = w.InstanceProfileArn + return out, nil +} + +// RemoveInstanceProfileRequestFromSDK converts the sdk-go type to the mirror. +func RemoveInstanceProfileRequestFromSDK(v *sdk.RemoveInstanceProfileRequest) (*RemoveInstanceProfileRequest, error) { + if v == nil { + return nil, nil + } + out := &RemoveInstanceProfileRequest{} + out.InstanceProfileArn = v.InstanceProfileArn + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/jobs/v2/roundtrip_test.go b/libs/sdktypes/jobs/v2/roundtrip_test.go new file mode 100644 index 00000000000..d3d05a69755 --- /dev/null +++ b/libs/sdktypes/jobs/v2/roundtrip_test.go @@ -0,0 +1,35 @@ +package jobs + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestJobSettingsRoundTrip(t *testing.T) { + input := `{"name":"x","max_concurrent_runs":0,"tasks":[{"task_key":"a","notebook_task":{"notebook_path":"/p"},"existing_cluster_id":"c1","environment_key":"e"}],"run_as":{"service_principal_name":"sp"},"format":"MULTI_TASK"}` + var m JobSettings + require.NoError(t, json.Unmarshal([]byte(input), &m)) + s, err := JobSettingsToSDK(&m) + require.NoError(t, err) + back, err := JobSettingsFromSDK(s) + require.NoError(t, err) + out, err := json.Marshal(back) + require.NoError(t, err) + assert.JSONEq(t, input, string(out)) +} + +func TestResponseRoundTrip(t *testing.T) { + input := `{"job_id":5,"settings":{"name":"x","tasks":[{"task_key":"a","spark_python_task":{"python_file":"f.py"},"new_cluster":{"spark_version":"13","num_workers":0}}]},"trigger_state":{}}` + var m GetJobResponse + require.NoError(t, json.Unmarshal([]byte(input), &m)) + s, err := GetJobResponseToSDK(&m) + require.NoError(t, err) + back, err := GetJobResponseFromSDK(s) + require.NoError(t, err) + out, err := json.Marshal(back) + require.NoError(t, err) + assert.JSONEq(t, input, string(out)) +} diff --git a/libs/sdktypes/jobs/v2/types.generated.go b/libs/sdktypes/jobs/v2/types.generated.go new file mode 100644 index 00000000000..d4386a8bddc --- /dev/null +++ b/libs/sdktypes/jobs/v2/types.generated.go @@ -0,0 +1,13895 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/jobs/v2. DO NOT EDIT. + +package jobs + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/jobs/v2" + + strings "strings" +) + +type ( + AuthenticationMethod = sdk.AuthenticationMethod + AwsAvailability = sdk.AwsAvailability + AzureAvailability = sdk.AzureAvailability + ComputeKind = sdk.ComputeKind + ConfidentialComputeType = sdk.ConfidentialComputeType + DataSecurityMode = sdk.DataSecurityMode + DayOfWeek = sdk.DayOfWeek + DbtPlatformRunStatus = sdk.DbtPlatformRunStatus + DependencyMode = sdk.DependencyMode + EbsVolumeType = sdk.EbsVolumeType + Format = sdk.Format + GcpAvailability = sdk.GcpAvailability + HardwareAcceleratorType = sdk.HardwareAcceleratorType + JobEditMode = sdk.JobEditMode + JobsHealthMetric = sdk.JobsHealthMetric + JobsHealthOperator = sdk.JobsHealthOperator + RepairType = sdk.RepairType + RunType = sdk.RunType + RuntimeEngine = sdk.RuntimeEngine + SchedulePauseStatus = sdk.SchedulePauseStatus + Source = sdk.Source + SqlConditionTriggerMode = sdk.SqlConditionTriggerMode + StorageMode = sdk.StorageMode + TaskDependencyType = sdk.TaskDependencyType + TaskRetryMode = sdk.TaskRetryMode + TriggerType = sdk.TriggerType + ViewType = sdk.ViewType + ViewsToExport = sdk.ViewsToExport + AccessControlRequest_JobPermission = sdk.AccessControlRequest_JobPermission + AiRuntimeTask_PriorityClass = sdk.AiRuntimeTask_PriorityClass + AlertEvaluationState_AlertEvaluationState = sdk.AlertEvaluationState_AlertEvaluationState + CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState = sdk.CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState + ComputeSpec_AcceleratorType = sdk.ComputeSpec_AcceleratorType + ConditionTask_ConditionTaskOperator = sdk.ConditionTask_ConditionTaskOperator + JobDeployment_DeploymentKind = sdk.JobDeployment_DeploymentKind + JobSource_DirtyState = sdk.JobSource_DirtyState + ModelTriggerConfiguration_ModelTriggerCondition = sdk.ModelTriggerConfiguration_ModelTriggerCondition + PerformanceTarget_PerformanceTarget = sdk.PerformanceTarget_PerformanceTarget + PeriodicTriggerConfiguration_TimeUnit = sdk.PeriodicTriggerConfiguration_TimeUnit + QueueDetailsCode_Code = sdk.QueueDetailsCode_Code + RunLifeCycleState_RunLifeCycleState = sdk.RunLifeCycleState_RunLifeCycleState + RunLifecycleStateV2_State = sdk.RunLifecycleStateV2_State + RunResultState_RunResultState = sdk.RunResultState_RunResultState + SqlAlertState_SqlAlertState = sdk.SqlAlertState_SqlAlertState + SqlTask_SqlTaskQueryStatus = sdk.SqlTask_SqlTaskQueryStatus + TableTriggerConfiguration_Condition = sdk.TableTriggerConfiguration_Condition + TerminationCode_Code = sdk.TerminationCode_Code + TerminationType_Type = sdk.TerminationType_Type +) + +const ( + AuthenticationMethod_Unspecified = sdk.AuthenticationMethod_Unspecified + AuthenticationMethod_Pat = sdk.AuthenticationMethod_Pat + AwsAvailability_Unspecified = sdk.AwsAvailability_Unspecified + AwsAvailability_Spot = sdk.AwsAvailability_Spot + AwsAvailability_OnDemand = sdk.AwsAvailability_OnDemand + AwsAvailability_SpotWithFallback = sdk.AwsAvailability_SpotWithFallback + AzureAvailability_Unspecified = sdk.AzureAvailability_Unspecified + AzureAvailability_SpotAzure = sdk.AzureAvailability_SpotAzure + AzureAvailability_OnDemandAzure = sdk.AzureAvailability_OnDemandAzure + AzureAvailability_SpotWithFallbackAzure = sdk.AzureAvailability_SpotWithFallbackAzure + ComputeKind_Unspecified = sdk.ComputeKind_Unspecified + ComputeKind_ClassicPreview = sdk.ComputeKind_ClassicPreview + ConfidentialComputeType_Unspecified = sdk.ConfidentialComputeType_Unspecified + ConfidentialComputeType_ConfidentialComputeTypeNone = sdk.ConfidentialComputeType_ConfidentialComputeTypeNone + ConfidentialComputeType_SevSnp = sdk.ConfidentialComputeType_SevSnp + DataSecurityMode_Unspecified = sdk.DataSecurityMode_Unspecified + DataSecurityMode_None = sdk.DataSecurityMode_None + DataSecurityMode_SingleUser = sdk.DataSecurityMode_SingleUser + DataSecurityMode_UserIsolation = sdk.DataSecurityMode_UserIsolation + DataSecurityMode_LegacyTableAcl = sdk.DataSecurityMode_LegacyTableAcl + DataSecurityMode_LegacyPassthrough = sdk.DataSecurityMode_LegacyPassthrough + DataSecurityMode_LegacySingleUser = sdk.DataSecurityMode_LegacySingleUser + DataSecurityMode_LegacySingleUserStandard = sdk.DataSecurityMode_LegacySingleUserStandard + DataSecurityMode_DataSecurityModeStandard = sdk.DataSecurityMode_DataSecurityModeStandard + DataSecurityMode_DataSecurityModeDedicated = sdk.DataSecurityMode_DataSecurityModeDedicated + DataSecurityMode_DataSecurityModeAuto = sdk.DataSecurityMode_DataSecurityModeAuto + DayOfWeek_Unspecified = sdk.DayOfWeek_Unspecified + DayOfWeek_Monday = sdk.DayOfWeek_Monday + DayOfWeek_Tuesday = sdk.DayOfWeek_Tuesday + DayOfWeek_Wednesday = sdk.DayOfWeek_Wednesday + DayOfWeek_Thursday = sdk.DayOfWeek_Thursday + DayOfWeek_Friday = sdk.DayOfWeek_Friday + DayOfWeek_Saturday = sdk.DayOfWeek_Saturday + DayOfWeek_Sunday = sdk.DayOfWeek_Sunday + DbtPlatformRunStatus_Unspecified = sdk.DbtPlatformRunStatus_Unspecified + DbtPlatformRunStatus_Queued = sdk.DbtPlatformRunStatus_Queued + DbtPlatformRunStatus_Starting = sdk.DbtPlatformRunStatus_Starting + DbtPlatformRunStatus_Running = sdk.DbtPlatformRunStatus_Running + DbtPlatformRunStatus_Success = sdk.DbtPlatformRunStatus_Success + DbtPlatformRunStatus_Error = sdk.DbtPlatformRunStatus_Error + DbtPlatformRunStatus_Cancelled = sdk.DbtPlatformRunStatus_Cancelled + DependencyMode_Unspecified = sdk.DependencyMode_Unspecified + DependencyMode_DependencyModeEnvironments = sdk.DependencyMode_DependencyModeEnvironments + DependencyMode_DependencyModeClusterLibraries = sdk.DependencyMode_DependencyModeClusterLibraries + DependencyMode_DependencyModeAuto = sdk.DependencyMode_DependencyModeAuto + EbsVolumeType_Unspecified = sdk.EbsVolumeType_Unspecified + EbsVolumeType_GeneralPurposeSsd = sdk.EbsVolumeType_GeneralPurposeSsd + EbsVolumeType_ThroughputOptimizedHdd = sdk.EbsVolumeType_ThroughputOptimizedHdd + Format_Unspecified = sdk.Format_Unspecified + Format_MultiTask = sdk.Format_MultiTask + GcpAvailability_Unspecified = sdk.GcpAvailability_Unspecified + GcpAvailability_PreemptibleGcp = sdk.GcpAvailability_PreemptibleGcp + GcpAvailability_OnDemandGcp = sdk.GcpAvailability_OnDemandGcp + GcpAvailability_PreemptibleWithFallbackGcp = sdk.GcpAvailability_PreemptibleWithFallbackGcp + HardwareAcceleratorType_Unspecified = sdk.HardwareAcceleratorType_Unspecified + HardwareAcceleratorType_Gpu1xA10 = sdk.HardwareAcceleratorType_Gpu1xA10 + HardwareAcceleratorType_Gpu8xH100 = sdk.HardwareAcceleratorType_Gpu8xH100 + HardwareAcceleratorType_Gpu1xH100 = sdk.HardwareAcceleratorType_Gpu1xH100 + HardwareAcceleratorType_Gpu8xB300 = sdk.HardwareAcceleratorType_Gpu8xB300 + JobEditMode_Unspecified = sdk.JobEditMode_Unspecified + JobEditMode_UiLocked = sdk.JobEditMode_UiLocked + JobEditMode_Editable = sdk.JobEditMode_Editable + JobsHealthMetric_Unspecified = sdk.JobsHealthMetric_Unspecified + JobsHealthMetric_RunDurationSeconds = sdk.JobsHealthMetric_RunDurationSeconds + JobsHealthMetric_StreamingBacklogBytes = sdk.JobsHealthMetric_StreamingBacklogBytes + JobsHealthMetric_StreamingBacklogRecords = sdk.JobsHealthMetric_StreamingBacklogRecords + JobsHealthMetric_StreamingBacklogSeconds = sdk.JobsHealthMetric_StreamingBacklogSeconds + JobsHealthMetric_StreamingBacklogFiles = sdk.JobsHealthMetric_StreamingBacklogFiles + JobsHealthOperator_Unspecified = sdk.JobsHealthOperator_Unspecified + JobsHealthOperator_GreaterThan = sdk.JobsHealthOperator_GreaterThan + RepairType_Unspecified = sdk.RepairType_Unspecified + RepairType_Original = sdk.RepairType_Original + RepairType_Repair = sdk.RepairType_Repair + RunType_Unspecified = sdk.RunType_Unspecified + RunType_JobRun = sdk.RunType_JobRun + RunType_WorkflowRun = sdk.RunType_WorkflowRun + RunType_SubmitRun = sdk.RunType_SubmitRun + RuntimeEngine_Unspecified = sdk.RuntimeEngine_Unspecified + RuntimeEngine_Standard = sdk.RuntimeEngine_Standard + RuntimeEngine_Photon = sdk.RuntimeEngine_Photon + SchedulePauseStatus_Unspecified = sdk.SchedulePauseStatus_Unspecified + SchedulePauseStatus_Paused = sdk.SchedulePauseStatus_Paused + Source_Unspecified = sdk.Source_Unspecified + Source_Workspace = sdk.Source_Workspace + Source_Git = sdk.Source_Git + SqlConditionTriggerMode_Unspecified = sdk.SqlConditionTriggerMode_Unspecified + SqlConditionTriggerMode_QueryReturnsRows = sdk.SqlConditionTriggerMode_QueryReturnsRows + SqlConditionTriggerMode_ResultValueChanges = sdk.SqlConditionTriggerMode_ResultValueChanges + StorageMode_Unspecified = sdk.StorageMode_Unspecified + StorageMode_Import = sdk.StorageMode_Import + StorageMode_Dual = sdk.StorageMode_Dual + TaskDependencyType_Unspecified = sdk.TaskDependencyType_Unspecified + TaskDependencyType_AllSuccess = sdk.TaskDependencyType_AllSuccess + TaskDependencyType_AllDone = sdk.TaskDependencyType_AllDone + TaskDependencyType_NoneFailed = sdk.TaskDependencyType_NoneFailed + TaskDependencyType_AtLeastOneSuccess = sdk.TaskDependencyType_AtLeastOneSuccess + TaskDependencyType_AllFailed = sdk.TaskDependencyType_AllFailed + TaskDependencyType_AtLeastOneFailed = sdk.TaskDependencyType_AtLeastOneFailed + TaskRetryMode_Unspecified = sdk.TaskRetryMode_Unspecified + TaskRetryMode_Never = sdk.TaskRetryMode_Never + TaskRetryMode_OnFailure = sdk.TaskRetryMode_OnFailure + TriggerType_Unspecified = sdk.TriggerType_Unspecified + TriggerType_Periodic = sdk.TriggerType_Periodic + TriggerType_OneTime = sdk.TriggerType_OneTime + TriggerType_Retry = sdk.TriggerType_Retry + TriggerType_RunJobTask = sdk.TriggerType_RunJobTask + TriggerType_FileArrival = sdk.TriggerType_FileArrival + TriggerType_Continuous = sdk.TriggerType_Continuous + TriggerType_Table = sdk.TriggerType_Table + TriggerType_ContinuousRestart = sdk.TriggerType_ContinuousRestart + ViewType_Unspecified = sdk.ViewType_Unspecified + ViewType_Notebook = sdk.ViewType_Notebook + ViewType_Dashboard = sdk.ViewType_Dashboard + ViewsToExport_Unspecified = sdk.ViewsToExport_Unspecified + ViewsToExport_Code = sdk.ViewsToExport_Code + ViewsToExport_Dashboards = sdk.ViewsToExport_Dashboards + ViewsToExport_All = sdk.ViewsToExport_All + AccessControlRequest_JobPermission_Unspecified = sdk.AccessControlRequest_JobPermission_Unspecified + AccessControlRequest_JobPermission_CanView = sdk.AccessControlRequest_JobPermission_CanView + AccessControlRequest_JobPermission_CanManageRun = sdk.AccessControlRequest_JobPermission_CanManageRun + AccessControlRequest_JobPermission_IsOwner = sdk.AccessControlRequest_JobPermission_IsOwner + AccessControlRequest_JobPermission_CanManage = sdk.AccessControlRequest_JobPermission_CanManage + AiRuntimeTask_PriorityClass_Unspecified = sdk.AiRuntimeTask_PriorityClass_Unspecified + AiRuntimeTask_PriorityClass_BestEffort = sdk.AiRuntimeTask_PriorityClass_BestEffort + AiRuntimeTask_PriorityClass_Normal = sdk.AiRuntimeTask_PriorityClass_Normal + AiRuntimeTask_PriorityClass_Critical = sdk.AiRuntimeTask_PriorityClass_Critical + AlertEvaluationState_AlertEvaluationState_Unspecified = sdk.AlertEvaluationState_AlertEvaluationState_Unspecified + AlertEvaluationState_AlertEvaluationState_Unknown = sdk.AlertEvaluationState_AlertEvaluationState_Unknown + AlertEvaluationState_AlertEvaluationState_Triggered = sdk.AlertEvaluationState_AlertEvaluationState_Triggered + AlertEvaluationState_AlertEvaluationState_Ok = sdk.AlertEvaluationState_AlertEvaluationState_Ok + AlertEvaluationState_AlertEvaluationState_Error = sdk.AlertEvaluationState_AlertEvaluationState_Error + CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Unspecified = sdk.CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Unspecified + CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Pending = sdk.CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Pending + CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Running = sdk.CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Running + CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Terminating = sdk.CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Terminating + CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Terminated = sdk.CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Terminated + CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Skipped = sdk.CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Skipped + CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_InternalError = sdk.CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_InternalError + CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Blocked = sdk.CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Blocked + CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_WaitingForRetry = sdk.CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_WaitingForRetry + CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Queued = sdk.CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState_Queued + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Unspecified = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Unspecified + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Success = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Success + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Failed = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Failed + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Timedout = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Timedout + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Canceled = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Canceled + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_MaximumConcurrentRunsReached = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_MaximumConcurrentRunsReached + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_UpstreamCanceled = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_UpstreamCanceled + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_UpstreamFailed = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_UpstreamFailed + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Excluded = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Excluded + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Evicted = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Evicted + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_SuccessWithFailures = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_SuccessWithFailures + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_UpstreamEvicted = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_UpstreamEvicted + CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Disabled = sdk.CleanRoomTaskRunResultState_CleanRoomTaskRunResultState_Disabled + ComputeSpec_AcceleratorType_Unspecified = sdk.ComputeSpec_AcceleratorType_Unspecified + ComputeSpec_AcceleratorType_Gpu1xA10 = sdk.ComputeSpec_AcceleratorType_Gpu1xA10 + ComputeSpec_AcceleratorType_Gpu1xH100 = sdk.ComputeSpec_AcceleratorType_Gpu1xH100 + ComputeSpec_AcceleratorType_Gpu8xH100 = sdk.ComputeSpec_AcceleratorType_Gpu8xH100 + ComputeSpec_AcceleratorType_Gpu8xB300 = sdk.ComputeSpec_AcceleratorType_Gpu8xB300 + ConditionTask_ConditionTaskOperator_Unspecified = sdk.ConditionTask_ConditionTaskOperator_Unspecified + ConditionTask_ConditionTaskOperator_EqualTo = sdk.ConditionTask_ConditionTaskOperator_EqualTo + ConditionTask_ConditionTaskOperator_GreaterThan = sdk.ConditionTask_ConditionTaskOperator_GreaterThan + ConditionTask_ConditionTaskOperator_GreaterThanOrEqual = sdk.ConditionTask_ConditionTaskOperator_GreaterThanOrEqual + ConditionTask_ConditionTaskOperator_LessThan = sdk.ConditionTask_ConditionTaskOperator_LessThan + ConditionTask_ConditionTaskOperator_LessThanOrEqual = sdk.ConditionTask_ConditionTaskOperator_LessThanOrEqual + ConditionTask_ConditionTaskOperator_NotEqual = sdk.ConditionTask_ConditionTaskOperator_NotEqual + JobDeployment_DeploymentKind_Unspecified = sdk.JobDeployment_DeploymentKind_Unspecified + JobDeployment_DeploymentKind_Bundle = sdk.JobDeployment_DeploymentKind_Bundle + JobDeployment_DeploymentKind_SystemManaged = sdk.JobDeployment_DeploymentKind_SystemManaged + JobSource_DirtyState_Unspecified = sdk.JobSource_DirtyState_Unspecified + JobSource_DirtyState_NotSynced = sdk.JobSource_DirtyState_NotSynced + JobSource_DirtyState_Disconnected = sdk.JobSource_DirtyState_Disconnected + ModelTriggerConfiguration_ModelTriggerCondition_Unspecified = sdk.ModelTriggerConfiguration_ModelTriggerCondition_Unspecified + ModelTriggerConfiguration_ModelTriggerCondition_ModelCreated = sdk.ModelTriggerConfiguration_ModelTriggerCondition_ModelCreated + ModelTriggerConfiguration_ModelTriggerCondition_ModelVersionReady = sdk.ModelTriggerConfiguration_ModelTriggerCondition_ModelVersionReady + ModelTriggerConfiguration_ModelTriggerCondition_ModelAliasSet = sdk.ModelTriggerConfiguration_ModelTriggerCondition_ModelAliasSet + PerformanceTarget_PerformanceTarget_Unspecified = sdk.PerformanceTarget_PerformanceTarget_Unspecified + PerformanceTarget_PerformanceTarget_PerformanceOptimized = sdk.PerformanceTarget_PerformanceTarget_PerformanceOptimized + PerformanceTarget_PerformanceTarget_Standard = sdk.PerformanceTarget_PerformanceTarget_Standard + PeriodicTriggerConfiguration_TimeUnit_Unspecified = sdk.PeriodicTriggerConfiguration_TimeUnit_Unspecified + PeriodicTriggerConfiguration_TimeUnit_Hours = sdk.PeriodicTriggerConfiguration_TimeUnit_Hours + PeriodicTriggerConfiguration_TimeUnit_Days = sdk.PeriodicTriggerConfiguration_TimeUnit_Days + PeriodicTriggerConfiguration_TimeUnit_Weeks = sdk.PeriodicTriggerConfiguration_TimeUnit_Weeks + PeriodicTriggerConfiguration_TimeUnit_Minutes = sdk.PeriodicTriggerConfiguration_TimeUnit_Minutes + QueueDetailsCode_Code_Unspecified = sdk.QueueDetailsCode_Code_Unspecified + QueueDetailsCode_Code_ActiveRunsLimitReached = sdk.QueueDetailsCode_Code_ActiveRunsLimitReached + QueueDetailsCode_Code_MaxConcurrentRunsReached = sdk.QueueDetailsCode_Code_MaxConcurrentRunsReached + QueueDetailsCode_Code_ActiveRunJobTasksLimitReached = sdk.QueueDetailsCode_Code_ActiveRunJobTasksLimitReached + RunLifeCycleState_RunLifeCycleState_Unspecified = sdk.RunLifeCycleState_RunLifeCycleState_Unspecified + RunLifeCycleState_RunLifeCycleState_Pending = sdk.RunLifeCycleState_RunLifeCycleState_Pending + RunLifeCycleState_RunLifeCycleState_Running = sdk.RunLifeCycleState_RunLifeCycleState_Running + RunLifeCycleState_RunLifeCycleState_Terminating = sdk.RunLifeCycleState_RunLifeCycleState_Terminating + RunLifeCycleState_RunLifeCycleState_Terminated = sdk.RunLifeCycleState_RunLifeCycleState_Terminated + RunLifeCycleState_RunLifeCycleState_Skipped = sdk.RunLifeCycleState_RunLifeCycleState_Skipped + RunLifeCycleState_RunLifeCycleState_InternalError = sdk.RunLifeCycleState_RunLifeCycleState_InternalError + RunLifeCycleState_RunLifeCycleState_Blocked = sdk.RunLifeCycleState_RunLifeCycleState_Blocked + RunLifeCycleState_RunLifeCycleState_WaitingForRetry = sdk.RunLifeCycleState_RunLifeCycleState_WaitingForRetry + RunLifeCycleState_RunLifeCycleState_Queued = sdk.RunLifeCycleState_RunLifeCycleState_Queued + RunLifecycleStateV2_State_Unspecified = sdk.RunLifecycleStateV2_State_Unspecified + RunLifecycleStateV2_State_Blocked = sdk.RunLifecycleStateV2_State_Blocked + RunLifecycleStateV2_State_Pending = sdk.RunLifecycleStateV2_State_Pending + RunLifecycleStateV2_State_Queued = sdk.RunLifecycleStateV2_State_Queued + RunLifecycleStateV2_State_Running = sdk.RunLifecycleStateV2_State_Running + RunLifecycleStateV2_State_Terminating = sdk.RunLifecycleStateV2_State_Terminating + RunLifecycleStateV2_State_Terminated = sdk.RunLifecycleStateV2_State_Terminated + RunLifecycleStateV2_State_Waiting = sdk.RunLifecycleStateV2_State_Waiting + RunResultState_RunResultState_Unspecified = sdk.RunResultState_RunResultState_Unspecified + RunResultState_RunResultState_Success = sdk.RunResultState_RunResultState_Success + RunResultState_RunResultState_Failed = sdk.RunResultState_RunResultState_Failed + RunResultState_RunResultState_Timedout = sdk.RunResultState_RunResultState_Timedout + RunResultState_RunResultState_Canceled = sdk.RunResultState_RunResultState_Canceled + RunResultState_RunResultState_MaximumConcurrentRunsReached = sdk.RunResultState_RunResultState_MaximumConcurrentRunsReached + RunResultState_RunResultState_UpstreamCanceled = sdk.RunResultState_RunResultState_UpstreamCanceled + RunResultState_RunResultState_UpstreamFailed = sdk.RunResultState_RunResultState_UpstreamFailed + RunResultState_RunResultState_Excluded = sdk.RunResultState_RunResultState_Excluded + RunResultState_RunResultState_SuccessWithFailures = sdk.RunResultState_RunResultState_SuccessWithFailures + RunResultState_RunResultState_Disabled = sdk.RunResultState_RunResultState_Disabled + SqlAlertState_SqlAlertState_Unspecified = sdk.SqlAlertState_SqlAlertState_Unspecified + SqlAlertState_SqlAlertState_Unknown = sdk.SqlAlertState_SqlAlertState_Unknown + SqlAlertState_SqlAlertState_Ok = sdk.SqlAlertState_SqlAlertState_Ok + SqlAlertState_SqlAlertState_Triggered = sdk.SqlAlertState_SqlAlertState_Triggered + SqlTask_SqlTaskQueryStatus_Unspecified = sdk.SqlTask_SqlTaskQueryStatus_Unspecified + SqlTask_SqlTaskQueryStatus_Pending = sdk.SqlTask_SqlTaskQueryStatus_Pending + SqlTask_SqlTaskQueryStatus_Running = sdk.SqlTask_SqlTaskQueryStatus_Running + SqlTask_SqlTaskQueryStatus_Success = sdk.SqlTask_SqlTaskQueryStatus_Success + SqlTask_SqlTaskQueryStatus_Failed = sdk.SqlTask_SqlTaskQueryStatus_Failed + SqlTask_SqlTaskQueryStatus_Cancelled = sdk.SqlTask_SqlTaskQueryStatus_Cancelled + TableTriggerConfiguration_Condition_Unspecified = sdk.TableTriggerConfiguration_Condition_Unspecified + TableTriggerConfiguration_Condition_AnyUpdated = sdk.TableTriggerConfiguration_Condition_AnyUpdated + TableTriggerConfiguration_Condition_AllUpdated = sdk.TableTriggerConfiguration_Condition_AllUpdated + TerminationCode_Code_Unspecified = sdk.TerminationCode_Code_Unspecified + TerminationCode_Code_Success = sdk.TerminationCode_Code_Success + TerminationCode_Code_Canceled = sdk.TerminationCode_Code_Canceled + TerminationCode_Code_DriverError = sdk.TerminationCode_Code_DriverError + TerminationCode_Code_ClusterError = sdk.TerminationCode_Code_ClusterError + TerminationCode_Code_RepositoryCheckoutFailed = sdk.TerminationCode_Code_RepositoryCheckoutFailed + TerminationCode_Code_InvalidClusterRequest = sdk.TerminationCode_Code_InvalidClusterRequest + TerminationCode_Code_WorkspaceRunLimitExceeded = sdk.TerminationCode_Code_WorkspaceRunLimitExceeded + TerminationCode_Code_FeatureDisabled = sdk.TerminationCode_Code_FeatureDisabled + TerminationCode_Code_ClusterRequestLimitExceeded = sdk.TerminationCode_Code_ClusterRequestLimitExceeded + TerminationCode_Code_StorageAccessError = sdk.TerminationCode_Code_StorageAccessError + TerminationCode_Code_RunExecutionError = sdk.TerminationCode_Code_RunExecutionError + TerminationCode_Code_UnauthorizedError = sdk.TerminationCode_Code_UnauthorizedError + TerminationCode_Code_LibraryInstallationError = sdk.TerminationCode_Code_LibraryInstallationError + TerminationCode_Code_MaxConcurrentRunsExceeded = sdk.TerminationCode_Code_MaxConcurrentRunsExceeded + TerminationCode_Code_MaxSparkContextsExceeded = sdk.TerminationCode_Code_MaxSparkContextsExceeded + TerminationCode_Code_ResourceNotFound = sdk.TerminationCode_Code_ResourceNotFound + TerminationCode_Code_InvalidRunConfiguration = sdk.TerminationCode_Code_InvalidRunConfiguration + TerminationCode_Code_InternalError = sdk.TerminationCode_Code_InternalError + TerminationCode_Code_CloudFailure = sdk.TerminationCode_Code_CloudFailure + TerminationCode_Code_MaxJobQueueSizeExceeded = sdk.TerminationCode_Code_MaxJobQueueSizeExceeded + TerminationCode_Code_Skipped = sdk.TerminationCode_Code_Skipped + TerminationCode_Code_UserCanceled = sdk.TerminationCode_Code_UserCanceled + TerminationCode_Code_BudgetPolicyLimitExceeded = sdk.TerminationCode_Code_BudgetPolicyLimitExceeded + TerminationCode_Code_Disabled = sdk.TerminationCode_Code_Disabled + TerminationCode_Code_SuccessWithFailures = sdk.TerminationCode_Code_SuccessWithFailures + TerminationCode_Code_BreakingChange = sdk.TerminationCode_Code_BreakingChange + TerminationType_Type_Unspecified = sdk.TerminationType_Type_Unspecified + TerminationType_Type_Success = sdk.TerminationType_Type_Success + TerminationType_Type_InternalError = sdk.TerminationType_Type_InternalError + TerminationType_Type_ClientError = sdk.TerminationType_Type_ClientError + TerminationType_Type_CloudFailure = sdk.TerminationType_Type_CloudFailure +) + +type AccessControlRequest struct { + GroupName *string `json:"group_name,omitempty"` + PermissionLevel AccessControlRequest_JobPermission `json:"permission_level,omitempty"` + ServicePrincipalName *string `json:"service_principal_name,omitempty"` + UserName *string `json:"user_name,omitempty"` +} + +// A storage location in Adls Gen2. +type Adlsgen2Info struct { + // abfss destination, e.g. + // `abfss://@.dfs.core.windows.net/`. + Destination *string `json:"destination,omitempty"` +} + +// AiRuntimeTask: multi-node GPU compute task definition for Databricks AI +// Runtime workloads. +// +// Jobs-framework-level concepts (retries, per-task timeout, idempotency token, +// usage/budget policy, permissions) live on the surrounding TaskSettings / +// run-submit request and are intentionally NOT duplicated here. Users compose +// `ai_runtime_task` with the standard Jobs/DABs task wrapper to get those.. +type AiRuntimeTask struct { + // Workspace or UC volume path of the code-source archive, unpacked on each node + // and exposed through `$CODE_SOURCE`. Set by first-party tooling; not for + // direct callers. + CodeSourcePath *string `json:"code_source_path,omitempty"` + // Deployment specs for this task. Exactly one deployment is currently supported + // (a single entry where every node runs the same command); this is a + // current-Preview constraint. Role-split workloads (driver + worker, parameter + // server, separate eval node, etc.) with multiple entries are the eventual + // intent but not yet supported. + Deployments []DeploymentSpec `json:"deployments,omitempty"` + // Optional Docker image URL for a custom container image. When set, the task + // runs on the specified container image instead of the default + // client image. Format: `{organization}/{repository}:{tag}` + DockerImageUrl *string `json:"docker_image_url,omitempty"` + // MLflow experiment name for this run. If an experiment with this name already + // exists under the calling user, the run is appended to it; otherwise a new + // experiment is created. To target a specific MLflow storage location (for + // example, when running as a service principal), set + // `mlflow_experiment_directory`. + Experiment *string `json:"experiment,omitempty"` + // Optional root location for MLflow artifacts logged by the run. If this field + // isn't specified the default artifact location will be in dbfs i.e. + // `dbfs:/databricks/mlflow-tracking//...` If dbfs access is + // restricted or UC is preferred this can be a custom location in UC: + // `dbfs:/Volumes////...` The location should be unique + // for each experiment. + MlflowArtifactLocation *string `json:"mlflow_artifact_location,omitempty"` + // Optional workspace directory under which the MLflow experiment named in + // `experiment` is created. Must start with `/Workspace`. Set this when running + // as a service principal that has no default user directory; for regular users + // the experiment defaults to the user's home directory. + MlflowExperimentDirectory *string `json:"mlflow_experiment_directory,omitempty"` + // Optional display name for the MLflow run created under `experiment`. If + // omitted, MLflow generates a default name. + MlflowRun *string `json:"mlflow_run,omitempty"` + // Scheduling priority class for the workload. May only be set together with a + // pre-provisioned capacity reservation (a deployment's + // `compute.provisioned_capacity_id`); it is rejected on a workload that runs on + // on-demand capacity. + PriorityClass AiRuntimeTask_PriorityClass `json:"priority_class,omitempty"` + // Optional Unity Catalog path for a custom container image. When set, the task + // runs on the specified container image instead of the default + // client image. Format: `{catalog}.{schema}.{image_name}:{tag}` + UnityCatalogImagePath *string `json:"unity_catalog_image_path,omitempty"` +} + +// AiRuntimeTaskOutput: output identifiers for an AiRuntimeTask run — the +// MLflow experiment and run IDs the task wrote to. +// +// Run lifecycle and termination status are not on this message; they live on +// the surrounding `RunTask.status` field (see `runs.proto:RunTask.status`).. +type AiRuntimeTaskOutput struct { + // MLflow experiment ID the run was logged to. Use it to look up the experiment + // in MLflow APIs or the workspace MLflow UI. + MlflowExperimentId *string `json:"mlflow_experiment_id,omitempty"` + // MLflow run ID for this task execution. Use it to look up the run in MLflow + // APIs or the workspace MLflow UI. + MlflowRunId *string `json:"mlflow_run_id,omitempty"` + // Human-readable status message for this run, suitable for display to the user + // (for example, that the run is still waiting for GPU compute). Set by the + // server only when there is something to surface; empty otherwise. + StatusMessage *string `json:"status_message,omitempty"` +} + +type AlertTask struct { + // The alert_id is the canonical identifier of the alert. + AlertId *string `json:"alert_id,omitempty"` + // Per-run parameter overrides, keyed by parameter name, applied onto the + // alert's stored query parameters before the query is executed. Only scalar + // values are supported. Values may reference job parameters with + // `{{job.parameters.*}}`, which are resolved before the task runs. An override + // whose key does not match a stored parameter fails the task run. Limited to + // 10000 characters when serialized as JSON; keys must be 1-100 characters and + // contain only letters, digits, underscores, dashes, and periods. + Parameters map[string]string `json:"parameters,omitempty"` + // The subscribers receive alert evaluation result notifications after the alert + // task is completed. The number of subscriptions is limited to 100. + Subscribers []AlertTaskSubscriber `json:"subscribers,omitempty"` + // The warehouse_id identifies the warehouse settings used by the alert task. + WarehouseId *string `json:"warehouse_id,omitempty"` + // The workspace_path is the path to the alert file in the workspace. The path: + // * must start with "/Workspace" * must be a normalized path. User has to + // select only one of alert_id or workspace_path to identify the alert. + WorkspacePath *string `json:"workspace_path,omitempty"` +} + +type AlertTaskOutput struct { + AlertState AlertEvaluationState_AlertEvaluationState `json:"alert_state,omitempty"` +} + +// Represents a subscriber that will receive alert notifications. A subscriber +// can be either a user (via email) or a notification destination (via +// destination_id).. +type AlertTaskSubscriber struct { + DestinationId *string `json:"destination_id,omitempty"` + UserName *string `json:"user_name,omitempty"` +} + +type AutoScale struct { + // The maximum number of workers to which the cluster can scale up when + // overloaded. Note that `max_workers` must be strictly greater than + // `min_workers`. + MaxWorkers *int `json:"max_workers,omitempty"` + // The minimum number of workers to which the cluster can scale down when + // underutilized. It is also the initial number of workers the cluster will have + // after creation. + MinWorkers *int `json:"min_workers,omitempty"` +} + +// Attributes set during cluster creation which are related to Amazon Web +// Services.. +type AwsAttributes struct { + Availability AwsAvailability `json:"availability,omitempty"` + // The number of volumes launched for each instance. Users can choose up to 10 + // volumes. This feature is only enabled for supported node types. Legacy node + // types cannot specify custom EBS volumes. For node types with no instance + // store, at least one EBS volume needs to be specified; otherwise, cluster + // creation will fail. + // + // These EBS volumes will be mounted at `/ebs0`, `/ebs1`, and etc. Instance + // store volumes will be mounted at `/local_disk0`, `/local_disk1`, and etc. + // + // If EBS volumes are attached, will configure Spark to use only + // the EBS volumes for scratch storage because heterogenously sized scratch + // devices can lead to inefficient disk utilization. If no EBS volumes are + // attached, will configure Spark to use instance store volumes. + // + // Please note that if EBS volumes are specified, then the Spark configuration + // `spark.local.dir` will be overridden. + EbsVolumeCount *int `json:"ebs_volume_count,omitempty"` + // If using gp3 volumes, what IOPS to use for the disk. If this is not set, the + // maximum performance of a gp2 volume with the same volume size will be used. + EbsVolumeIops *int `json:"ebs_volume_iops,omitempty"` + // The size of each EBS volume (in GiB) launched for each instance. For general + // purpose SSD, this value must be within the range 100 - 4096. For throughput + // optimized HDD, this value must be within the range 500 - 4096. + EbsVolumeSize *int `json:"ebs_volume_size,omitempty"` + // If using gp3 volumes, what throughput to use for the disk. If this is not + // set, the maximum performance of a gp2 volume with the same volume size will + // be used. + EbsVolumeThroughput *int `json:"ebs_volume_throughput,omitempty"` + // The type of EBS volumes that will be launched with this cluster. + EbsVolumeType EbsVolumeType `json:"ebs_volume_type,omitempty"` + // The first `first_on_demand` nodes of the cluster will be placed on on-demand + // instances. If this value is greater than 0, the cluster driver node in + // particular will be placed on an on-demand instance. If this value is greater + // than or equal to the current cluster size, all nodes will be placed on + // on-demand instances. If this value is less than the current cluster size, + // `first_on_demand` nodes will be placed on on-demand instances and the + // remainder will be placed on `availability` instances. Note that this value + // does not affect cluster size and cannot currently be mutated over the + // lifetime of a cluster. + FirstOnDemand *int `json:"first_on_demand,omitempty"` + // Nodes for this cluster will only be placed on AWS instances with this + // instance profile. If ommitted, nodes will be placed on instances without an + // IAM instance profile. The instance profile must have previously been added to + // the environment by an account administrator. + // + // This feature may only be available to certain customer plans. + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // The bid price for AWS spot instances, as a percentage of the corresponding + // instance type's on-demand price. For example, if this field is set to 50, and + // the cluster needs a new `r3.xlarge` spot instance, then the bid price is half + // of the price of on-demand `r3.xlarge` instances. Similarly, if this field is + // set to 200, the bid price is twice the price of on-demand `r3.xlarge` + // instances. If not specified, the default value is 100. When spot instances + // are requested for this cluster, only spot instances whose bid price + // percentage matches this field will be considered. Note that, for safety, we + // enforce this field to be no more than 10000. + SpotBidPricePercent *int `json:"spot_bid_price_percent,omitempty"` + // Identifier for the availability zone/datacenter in which the cluster resides. + // This string will be of a form like "us-west-2a". The provided availability + // zone must be in the same region as the deployment. For example, + // "us-west-2a" is not a valid zone id if the deployment resides in + // the "us-east-1" region. This is an optional field at cluster creation, and if + // not specified, the zone "auto" will be used. If the zone specified is "auto", + // will try to place cluster in a zone with high availability, and will retry + // placement in a different AZ if there is not enough capacity. The list of + // available zones as well as the default value can be found by using the `List + // Zones` method. + ZoneId *string `json:"zone_id,omitempty"` +} + +// Attributes set during cluster creation which are related to Microsoft Azure.. +type AzureAttributes struct { + // Availability type used for all subsequent nodes past the `first_on_demand` + // ones. Note: If `first_on_demand` is zero, this availability type will be used + // for the entire cluster. + Availability AzureAvailability `json:"availability,omitempty"` + // The Azure capacity reservation group resource ID to use for launching VMs. + // When specified, VMs will be launched using the provided capacity reservation. + // + // Capacity reservations can only be specified when the workspace uses injected + // vnet (i.e. customer defined vnet not managed by databricks). Ensure the + // databricks-login-prod Enterprise Application is granted the following four + // permissions: 1. Microsoft.Compute/capacityReservationGroups/read 2. + // Microsoft.Compute/capacityReservationGroups/deploy/action 3. + // Microsoft.Compute/capacityReservationGroups/capacityReservations/read 4. + // Microsoft.Compute/capacityReservationGroups/capacityReservations/deploy/action + // + // Format: + // `/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}` + CapacityReservationGroup *string `json:"capacity_reservation_group,omitempty"` + // The first `first_on_demand` nodes of the cluster will be placed on on-demand + // instances. This value should be greater than 0, to make sure the cluster + // driver node is placed on an on-demand instance. If this value is greater than + // or equal to the current cluster size, all nodes will be placed on on-demand + // instances. If this value is less than the current cluster size, + // `first_on_demand` nodes will be placed on on-demand instances and the + // remainder will be placed on `availability` instances. Note that this value + // does not affect cluster size and cannot currently be mutated over the + // lifetime of a cluster. + FirstOnDemand *int `json:"first_on_demand,omitempty"` + // Defines values necessary to configure and run Azure Log Analytics agent + LogAnalyticsInfo *LogAnalyticsInfo `json:"log_analytics_info,omitempty"` + // The max bid price to be used for Azure spot instances. The Max price for the + // bid cannot be higher than the on-demand price of the instance. If not + // specified, the default value is -1, which specifies that the instance cannot + // be evicted on the basis of price, and only on the basis of availability. + // Further, the value should > 0 or -1. + SpotBidMaxPrice *float64 `json:"spot_bid_max_price,omitempty"` +} + +type BaseJob struct { + // The time at which this job was created in epoch milliseconds (milliseconds + // since 1/1/1970 UTC). + CreatedTime *int64 `json:"created_time,omitempty"` + // The creator user name. This field won’t be included in the response if the + // user has already been deleted. + CreatorUserName *string `json:"creator_user_name,omitempty"` + // The id of the budget policy used by this job for cost attribution purposes. + // This may be set through (in order of precedence): 1. Budget admins through + // the account or workspace console 2. Jobs UI in the job details page and Jobs + // API using `budget_policy_id` 3. Inferred default based on accessible budget + // policies of the run_as identity on job creation or modification. + EffectiveBudgetPolicyId *string `json:"effective_budget_policy_id,omitempty"` + // The id of the usage policy used by this job for cost attribution purposes. + EffectiveUsagePolicyId *string `json:"effective_usage_policy_id,omitempty"` + // Indicates if the job has more array properties (`tasks`, `job_clusters`) that + // are not shown. They can be accessed via :method:jobs/get endpoint. It is only + // relevant for API 2.2 :method:jobs/list requests with `expand_tasks=true`. + HasMore *bool `json:"has_more,omitempty"` + // The canonical identifier for this job. + JobId *int64 `json:"job_id,omitempty"` + // The email of an active workspace user or the application ID of a service + // principal that the job runs as. This value can be changed by setting the + // `run_as` field when creating or updating a job. + // + // By default, `run_as_user_name` is based on the current job settings and is + // set to the creator of the job if job access control is disabled or to the + // user with the `is_owner` permission if job access control is enabled. + RunAsUserName *string `json:"run_as_user_name,omitempty"` + // Settings for this job and all of its runs. These settings can be updated + // using the `resetJob` method. + Settings *JobSettings `json:"settings,omitempty"` + // Per-trigger runtime information for the multi-trigger surface. Same length + // and order as `JobSettings.triggers`; `trigger_details[i]` corresponds to + // `triggers[i]`. Sub-fields (`state`, `history`) are populated independently + // based on the `GetJob.include_trigger_state` / `include_trigger_history` + // flags. + TriggerDetails []TriggerDetails `json:"trigger_details,omitempty"` + // State of the trigger associated with the job. + TriggerState *TriggerState `json:"trigger_state,omitempty"` +} + +type BaseRun struct { + // The sequence number of this run attempt for a triggered job run. The initial + // attempt of a run has an attempt_number of 0. If the initial run attempt + // fails, and the job has a retry policy (`max_retries` > 0), subsequent runs + // are created with an `original_attempt_run_id` of the original attempt’s ID + // and an incrementing `attempt_number`. Runs are retried only until they + // succeed, and the maximum `attempt_number` is the same as the `max_retries` + // value for the job. + AttemptNumber *int `json:"attempt_number,omitempty"` + // The time in milliseconds it took to terminate the cluster and clean up any + // associated artifacts. The duration of a task run is the sum of the + // `setup_duration`, `execution_duration`, and the `cleanup_duration`. The + // `cleanup_duration` field is set to 0 for multitask job runs. The total + // duration of a multitask job run is the value of the `run_duration` field. + CleanupDuration *int64 `json:"cleanup_duration,omitempty"` + // The cluster used for this run. If the run is specified to use a new cluster, + // this field is set once the Jobs service has requested a cluster for the run. + ClusterInstance *ClusterInstance `json:"cluster_instance,omitempty"` + // A snapshot of the job’s cluster specification when this run was created. + ClusterSpec *ClusterSpec `json:"cluster_spec,omitempty"` + // The creator user name. This field won’t be included in the response if the + // user has already been deleted. + CreatorUserName *string `json:"creator_user_name,omitempty"` + // ID of the deployment that produced the job when this run was created. Used to + // look up deployment metadata from the Deployment Metadata service. Only set + // for job runs of jobs with a `BUNDLE` deployment. + DeploymentId *string `json:"deployment_id,omitempty"` + // Description of the run + Description *string `json:"description,omitempty"` + // The actual performance target used by the serverless run during execution. + // This can differ from the client-set performance target on the request + // depending on whether the performance mode is supported by the job type. + // + // * `PERFORMANCE_OPTIMIZED`: Prioritizes fast startup and execution times + // through rapid scaling and optimized cluster performance. * `STANDARD`: + // Enables cost-efficient execution of serverless workloads. * `COST_OPTIMIZED`: + // Enables lower job costs by optimizing compute for your selected target + // duration time. Must provide a duration target. + EffectivePerformanceTarget PerformanceTarget_PerformanceTarget `json:"effective_performance_target,omitempty"` + // The id of the usage policy used by this run for cost attribution purposes. + EffectiveUsagePolicyId *string `json:"effective_usage_policy_id,omitempty"` + // The time at which this run ended in epoch milliseconds (milliseconds since + // 1/1/1970 UTC). This field is set to 0 if the job is still running. + EndTime *int64 `json:"end_time,omitempty"` + // Snapshot of `JobSettings.environment_variables` as it was at run launch — + // the full list of named environment-variable entries the job defined. To find + // which entry a given task ran with, look at + // `RunTaskSettings.environment_variables_key`. + EnvironmentVariables []JobEnvironmentVariables `json:"environment_variables,omitempty"` + // The time in milliseconds it took to execute the commands in the JAR or + // notebook until they completed, failed, timed out, were cancelled, or + // encountered an unexpected error. The duration of a task run is the sum of the + // `setup_duration`, `execution_duration`, and the `cleanup_duration`. The + // `execution_duration` field is set to 0 for multitask job runs. The total + // duration of a multitask job run is the value of the `run_duration` field. + ExecutionDuration *int64 `json:"execution_duration,omitempty"` + // An optional specification for a remote Git repository containing the source + // code used by tasks. Version-controlled source code is supported by notebook, + // dbt, Python script, and SQL File tasks. + // + // If `git_source` is set, these tasks retrieve the file from the remote + // repository by default. However, this behavior can be overridden by setting + // `source` to `WORKSPACE` on the task. + // + // Note: dbt and SQL File tasks support only version-controlled sources. If dbt + // or SQL File tasks are used, `git_source` must be defined on the job. + GitSource *GitSource `json:"git_source,omitempty"` + // Indicates if the run has more array properties (`tasks`, `job_clusters`) that + // are not shown. They can be accessed via :method:jobs/getrun endpoint. It is + // only relevant for API 2.2 :method:jobs/listruns requests with + // `expand_tasks=true`. + HasMore *bool `json:"has_more,omitempty"` + // A list of job cluster specifications that can be shared and reused by tasks + // of this job. Libraries cannot be declared in a shared job cluster. You must + // declare dependent libraries in task settings. If more than 100 job clusters + // are available, you can paginate through them using :method:jobs/getrun. + JobClusters []JobCluster `json:"job_clusters,omitempty"` + // The canonical identifier of the job that contains this run. + JobId *int64 `json:"job_id,omitempty"` + // Job-level parameters used in the run + JobParameters []Run_JobLevelParameters `json:"job_parameters,omitempty"` + // ID of the job run that this run belongs to. For legacy and single-task job + // runs the field is populated with the job run ID. For task runs, the field is + // populated with the ID of the job run that the task run belongs to. + JobRunId *int64 `json:"job_run_id,omitempty"` + // A unique identifier for this job run. This is set to the same value as + // `run_id`. + NumberInJob *int64 `json:"number_in_job,omitempty"` + // If this run is a retry of a prior run attempt, this field contains the run_id + // of the original attempt; otherwise, it is the same as the run_id. + OriginalAttemptRunId *int64 `json:"original_attempt_run_id,omitempty"` + // The parameters used for this run. + OverridingParameters *RunParameters `json:"overriding_parameters,omitempty"` + // The time in milliseconds that the run has spent in the queue. + QueueDuration *int64 `json:"queue_duration,omitempty"` + // The repair history of the run. + RepairHistory []Repair `json:"repair_history,omitempty"` + // The time in milliseconds it took the job run and all of its repairs to + // finish. + RunDuration *int64 `json:"run_duration,omitempty"` + // The canonical identifier of the run. This ID is unique across all runs of all + // jobs. + RunId *int64 `json:"run_id,omitempty"` + // An optional name for the run. The maximum length is 4096 bytes in UTF-8 + // encoding. + RunName *string `json:"run_name,omitempty"` + // The URL to the detail page of the run. + RunPageUrl *string `json:"run_page_url,omitempty"` + RunType RunType `json:"run_type,omitempty"` + // The cron schedule that triggered this run if it was triggered by the periodic + // scheduler. + Schedule *CronSchedule `json:"schedule,omitempty"` + // The time in milliseconds it took to set up the cluster. For runs that run on + // new clusters this is the cluster creation time, for runs that run on existing + // clusters this time should be very short. The duration of a task run is the + // sum of the `setup_duration`, `execution_duration`, and the + // `cleanup_duration`. The `setup_duration` field is set to 0 for multitask job + // runs. The total duration of a multitask job run is the value of the + // `run_duration` field. + SetupDuration *int64 `json:"setup_duration,omitempty"` + // The time at which this run was started in epoch milliseconds (milliseconds + // since 1/1/1970 UTC). This may not be the time when the job task starts + // executing, for example, if the job is scheduled to run on a new cluster, this + // is the time the cluster creation call is issued. + StartTime *int64 `json:"start_time,omitempty"` + // Deprecated. Please use the `status` field instead. + State *RunState `json:"state,omitempty"` + Status *RunStatus `json:"status,omitempty"` + // The list of tasks performed by the run. Each task has its own `run_id` which + // you can use to call `JobsGetOutput` to retrieve the run results. If more than + // 100 tasks are available, you can paginate through them using + // :method:jobs/getrun. Use the `next_page_token` field at the object root to + // determine if more results are available. + Tasks []RunTask `json:"tasks,omitempty"` + Trigger TriggerType `json:"trigger,omitempty"` + TriggerInfo *RunTriggerInfo `json:"trigger_info,omitempty"` + // ID of the deployment version that produced the job when this run was created. + // Identifies a specific snapshot of the deployment in the Deployment Metadata + // service. Only set for job runs of jobs with a `BUNDLE` deployment. + VersionId *string `json:"version_id,omitempty"` +} + +type CancelAllRunsRequest struct { + // Optional boolean parameter to cancel all queued runs. If no job_id is + // provided, all queued runs in the workspace are canceled. + AllQueuedRuns *bool `json:"all_queued_runs,omitempty"` + // The canonical identifier of the job to cancel all runs of. + JobId *int64 `json:"job_id,omitempty"` +} + +type CancelRunRequest struct { + // This field is required. + RunId *int64 `json:"run_id,omitempty"` +} + +// Stores the run state of the clean rooms notebook task.. +type CleanRoomTaskRunState struct { + // A value indicating the run's current lifecycle state. This field is always + // available in the response. Note: Additional states might be introduced in + // future releases. + LifeCycleState CleanRoomTaskRunLifeCycleState_CleanRoomTaskRunLifeCycleState `json:"life_cycle_state,omitempty"` + // A value indicating the run's result. This field is only available for + // terminal lifecycle states. Note: Additional states might be introduced in + // future releases. + ResultState CleanRoomTaskRunResultState_CleanRoomTaskRunResultState `json:"result_state,omitempty"` +} + +// Clean Rooms notebook task for V1 Clean Room service (GA). Replaces the +// deprecated CleanRoomNotebookTask (defined above) which was for V0 service.. +type CleanRoomsNotebookTask struct { + // The clean room that the notebook belongs to. + CleanRoomName *string `json:"clean_room_name,omitempty"` + // Checksum to validate the freshness of the notebook resource (i.e. the + // notebook being run is the latest version). It can be fetched by calling the + // :method:cleanroomassets/get API. + Etag *string `json:"etag,omitempty"` + // Base parameters to be used for the clean room notebook job. + NotebookBaseParameters map[string]string `json:"notebook_base_parameters,omitempty"` + // Name of the notebook being run. + NotebookName *string `json:"notebook_name,omitempty"` +} + +type CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput struct { + // The run state of the clean rooms notebook task. + CleanRoomJobRunState *CleanRoomTaskRunState `json:"clean_room_job_run_state,omitempty"` + // The notebook output for the clean room run + NotebookOutput *NotebookTask_NotebookOutput `json:"notebook_output,omitempty"` + // Information on how to access the output schema for the clean room run + OutputSchemaInfo *OutputSchemaInfo `json:"output_schema_info,omitempty"` +} + +type ClusterInstance struct { + // The canonical identifier for the cluster used by a run. This field is always + // available for runs on existing clusters. For runs on new clusters, it becomes + // available once the cluster is created. This value can be used to view logs by + // browsing to `/#setting/sparkui/$cluster_id/driver-logs`. The logs continue to + // be available after the run completes. + // + // The response won’t include this field if the identifier is not available + // yet. + ClusterId *string `json:"cluster_id,omitempty"` + // The canonical identifier for the Spark context used by a run. This field is + // filled in once the run begins execution. This value can be used to view the + // Spark UI by browsing to `/#setting/sparkui/$cluster_id/$spark_context_id`. + // The Spark UI continues to be available after the run has completed. + // + // The response won’t include this field if the identifier is not available + // yet. + SparkContextId *string `json:"spark_context_id,omitempty"` +} + +// Cluster log delivery config. +type ClusterLogConf struct { + Dbfs *DbfsStorageInfo `json:"dbfs,omitempty"` + S3 *S3StorageInfo `json:"s3,omitempty"` + Volumes *VolumesStorageInfo `json:"volumes,omitempty"` +} + +type ClusterSpec struct { + ExistingClusterId *string `json:"existing_cluster_id,omitempty"` + JobClusterKey *string `json:"job_cluster_key,omitempty"` + // An optional list of libraries to be installed on the cluster. The default + // value is an empty list. + Libraries []Library `json:"libraries,omitempty"` + NewCluster *ClusterSpec_NewCluster `json:"new_cluster,omitempty"` +} + +type ClusterSpec_NewCluster struct { + ApplyPolicyDefaultValues *bool `json:"apply_policy_default_values,omitempty"` + Autoscale *AutoScale `json:"autoscale,omitempty"` + // Automatically terminates the cluster after it is inactive for this time in + // minutes. If not set, this cluster will not be automatically terminated. If + // specified, the threshold must be between 10 and 10000 minutes. Users can also + // set this value to 0 to explicitly disable automatic termination. + AutoterminationMinutes *int `json:"autotermination_minutes,omitempty"` + // Attributes related to clusters running on Amazon Web Services. If not + // specified at cluster creation, a set of default values will be used. + AwsAttributes *AwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to clusters running on Microsoft Azure. If not specified + // at cluster creation, a set of default values will be used. + AzureAttributes *AzureAttributes `json:"azure_attributes,omitempty"` + // The configuration for delivering spark logs to a long-term storage + // destination. Three kinds of destinations (DBFS, S3 and Unity Catalog volumes) + // are supported. Only one destination can be specified for one cluster. If the + // conf is given, the logs will be delivered to the destination every `5 mins`. + // The destination of driver logs is `$destination/$clusterId/driver`, while the + // destination of executor logs is `$destination/$clusterId/executor`. + ClusterLogConf *ClusterLogConf `json:"cluster_log_conf,omitempty"` + // Cluster name requested by the user. This doesn't have to be unique. If not + // specified at creation, the cluster name will be an empty string. For job + // clusters, the cluster name is automatically set based on the job and job run + // IDs. + ClusterName *string `json:"cluster_name,omitempty"` + // Additional tags for cluster resources. will tag all cluster + // resources (e.g., AWS instances and EBS volumes) with these tags in addition + // to `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + // + // - Clusters can only reuse cloud resources if the resources' tags are a subset + // of the cluster tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + DataSecurityMode DataSecurityMode `json:"data_security_mode,omitempty"` + // Controls dependency configuration for the cluster. + DependencyMode DependencyMode `json:"dependency_mode,omitempty"` + // Custom docker image BYOC + DockerImage *DockerImage `json:"docker_image,omitempty"` + // The optional ID of the instance pool for the driver of the cluster belongs. + // The pool cluster uses the instance pool with id (instance_pool_id) if the + // driver pool is not assigned. + DriverInstancePoolId *string `json:"driver_instance_pool_id,omitempty"` + // Flexible node type configuration for the driver node. + DriverNodeTypeFlexibility *NodeTypeFlexibility `json:"driver_node_type_flexibility,omitempty"` + // The node type of the Spark driver. Note that this field is optional; if + // unset, the driver node type will be set as the same value as `node_type_id` + // defined above. + // + // This field, along with node_type_id, should not be set if + // virtual_cluster_size is set. If both driver_node_type_id, node_type_id, and + // virtual_cluster_size are specified, driver_node_type_id and node_type_id take + // precedence. + DriverNodeTypeId *string `json:"driver_node_type_id,omitempty"` + // Autoscaling Local Storage: when enabled, this cluster will dynamically + // acquire additional disk space when its Spark workers are running low on disk + // space. + EnableElasticDisk *bool `json:"enable_elastic_disk,omitempty"` + // Whether to enable LUKS on cluster VMs' local disks + EnableLocalDiskEncryption *bool `json:"enable_local_disk_encryption,omitempty"` + // Attributes related to clusters running on Google Cloud Platform. If not + // specified at cluster creation, a set of default values will be used. + GcpAttributes *GcpAttributes `json:"gcp_attributes,omitempty"` + // The configuration for storing init scripts. Any number of destinations can be + // specified. The scripts are executed sequentially in the order provided. If + // `cluster_log_conf` is specified, init script logs are sent to + // `//init_scripts`. + InitScripts []InitScriptInfo `json:"init_scripts,omitempty"` + // The optional ID of the instance pool to which the cluster belongs. + InstancePoolId *string `json:"instance_pool_id,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // When set to true, will automatically set single node related + // `custom_tags`, `spark_conf`, and `num_workers` + IsSingleNode *bool `json:"is_single_node,omitempty"` + Kind ComputeKind `json:"kind,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // [clusters/listNodeTypes] API call. + // + // [clusters/listNodeTypes]: https://docs.databricks.com/api/workspace/clusters/listnodetypes + NodeTypeId *string `json:"node_type_id,omitempty"` + NumWorkers *int `json:"num_workers,omitempty"` + // The ID of the cluster policy used to create the cluster if applicable. + PolicyId *string `json:"policy_id,omitempty"` + // If set, what the configurable throughput (in Mb/s) for the remote disk is. + // Currently only supported for GCP HYPERDISK_BALANCED disks. + RemoteDiskThroughput *int `json:"remote_disk_throughput,omitempty"` + // Determines the cluster's runtime engine, either standard or Photon. + // + // This field is not compatible with legacy `spark_version` values that contain + // `-photon-`. Remove `-photon-` from the `spark_version` and set + // `runtime_engine` to `PHOTON`. + // + // If left unspecified, the runtime engine defaults to standard unless the + // spark_version contains -photon-, in which case Photon will be used. + RuntimeEngine RuntimeEngine `json:"runtime_engine,omitempty"` + // Single user name if data_security_mode is `SINGLE_USER` + SingleUserName *string `json:"single_user_name,omitempty"` + // An object containing a set of optional, user-specified Spark configuration + // key-value pairs. Users can also pass in a string of extra JVM options to the + // driver and the executors via `spark.driver.extraJavaOptions` and + // `spark.executor.extraJavaOptions` respectively. + SparkConf map[string]string `json:"spark_conf,omitempty"` + // An object containing a set of optional, user-specified environment variable + // key-value pairs. Please note that key-value pair of the form (X,Y) will be + // exported as is (i.e., `export X='Y'`) while launching the driver and workers. + // + // In order to specify an additional set of `SPARK_DAEMON_JAVA_OPTS`, we + // recommend appending them to `$SPARK_DAEMON_JAVA_OPTS` as shown in the example + // below. This ensures that all default databricks managed environmental + // variables are included as well. + // + // Example Spark environment variables: `{"SPARK_WORKER_MEMORY": "28000m", + // "SPARK_LOCAL_DIRS": "/local_disk0"}` or `{"SPARK_DAEMON_JAVA_OPTS": + // "$SPARK_DAEMON_JAVA_OPTS -Dspark.shuffle.service.enabled=true"}` + SparkEnvVars map[string]string `json:"spark_env_vars,omitempty"` + // The Spark version of the cluster, e.g. `3.3.x-scala2.11`. A list of available + // Spark versions can be retrieved by using the [clusters/sparkVersions] API + // call. + // + // [clusters/sparkVersions]: https://docs.databricks.com/api/workspace/clusters/sparkversions + SparkVersion *string `json:"spark_version,omitempty"` + // SSH public key contents that will be added to each Spark node in this + // cluster. The corresponding private keys can be used to login with the user + // name `ubuntu` on port `2200`. Up to 10 keys can be specified. + SshPublicKeys []string `json:"ssh_public_keys,omitempty"` + // If set, what the total initial volume size (in GB) of the remote disks should + // be. Supported for GCP. + TotalInitialRemoteDiskSize *int `json:"total_initial_remote_disk_size,omitempty"` + // This field can only be used when `kind = CLASSIC_PREVIEW`. + // + // `effective_spark_version` is determined by `spark_version` (DBR release), + // this field `use_ml_runtime`, and whether `node_type_id` is gpu node or not. + UseMlRuntime *bool `json:"use_ml_runtime,omitempty"` + // Flexible node type configuration for worker nodes. + WorkerNodeTypeFlexibility *NodeTypeFlexibility `json:"worker_node_type_flexibility,omitempty"` + WorkloadType *WorkloadType `json:"workload_type,omitempty"` +} + +type Compute struct { + // Hardware accelerator configuration for Serverless GPU workloads. + HardwareAccelerator HardwareAcceleratorType `json:"hardware_accelerator,omitempty"` +} + +type ComputeConfig struct { + // IDof the GPU pool to use. + GpuNodePoolId *string `json:"gpu_node_pool_id,omitempty"` + // GPU type. + GpuType *string `json:"gpu_type,omitempty"` + // Number of GPUs. + NumGpus *int `json:"num_gpus,omitempty"` +} + +// ComputeSpec: compute configuration — accelerator type and total accelerator +// count across all nodes.. +type ComputeSpec struct { + // Total number of accelerators across all nodes. Must be a positive multiple of + // the per-node accelerator count encoded in `accelerator_type`. For example, + // `GPU_8xH100` with `accelerator_count: 16` allocates 2 nodes (8 GPUs per + // node). + AcceleratorCount *int `json:"accelerator_count,omitempty"` + // Hardware accelerator type (for example, `GPU_1xA10` or `GPU_8xH100`). The + // number of accelerators per node is encoded in the enum value — `GPU_8xH100` + // means 8 H100 GPUs per node. + AcceleratorType ComputeSpec_AcceleratorType `json:"accelerator_type,omitempty"` + // Optional ID of a pre-provisioned accelerator capacity reservation to run this + // AI Runtime workload on. When set, the workload is scheduled onto the + // referenced reserved capacity instead of the on-demand capacity shared among + // all customers. + ProvisionedCapacityId *string `json:"provisioned_capacity_id,omitempty"` +} + +type ConditionTask struct { + // The left operand of the condition task. Can be either a string value or a job + // state or parameter reference. + Left *string `json:"left,omitempty"` + // * `EQUAL_TO`, `NOT_EQUAL` operators perform string comparison of their + // operands. This means that `“12.0” == “12”` will evaluate to `false`. + // * `GREATER_THAN`, `GREATER_THAN_OR_EQUAL`, `LESS_THAN`, `LESS_THAN_OR_EQUAL` + // operators perform numeric comparison of their operands. `“12.0” >= + // “12”` will evaluate to `true`, `“10.0” >= “12”` will evaluate to + // `false`. + // + // The boolean comparison to task values can be implemented with operators + // `EQUAL_TO`, `NOT_EQUAL`. If a task value was set to a boolean value, it will + // be serialized to `“true”` or `“false”` for the comparison. + Op ConditionTask_ConditionTaskOperator `json:"op,omitempty"` + // The condition expression evaluation result. Filled in if the task was + // successfully completed. Can be `"true"` or `"false"` + Outcome *string `json:"outcome,omitempty"` + // The right operand of the condition task. Can be either a string value or a + // job state or parameter reference. + Right *string `json:"right,omitempty"` +} + +type ContinuousSettings struct { + // Defines when platform-initiated maintenance may run for this job. If + // unspecified, maintenance may run at any time. + MaintenanceWindow *MaintenanceWindow `json:"maintenance_window,omitempty"` + // Indicate whether the continuous execution of the job is paused or not. + // Defaults to UNPAUSED. + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + // Indicate whether the continuous job is applying task level retries or not. + // Defaults to NEVER. + TaskRetryMode TaskRetryMode `json:"task_retry_mode,omitempty"` +} + +// Continuous trigger. Stripped-down counterpart to `ContinuousSettings`: +// `pause_status` is owned by the enclosing `TriggerConfiguration` and +// intentionally omitted here.. +type ContinuousTriggerConfiguration struct { + // Defines when platform-initiated maintenance may run for this trigger. If + // unspecified, maintenance may run at any time. + MaintenanceWindow *MaintenanceWindow `json:"maintenance_window,omitempty"` + // Whether the continuous job applies task-level retries. Defaults to NEVER. + TaskRetryMode TaskRetryMode `json:"task_retry_mode,omitempty"` +} + +type ContinuousTriggerState struct { + ConsecutiveFailures *int `json:"consecutive_failures,omitempty"` + IsBackingOff *bool `json:"is_backing_off,omitempty"` + NextAttemptMs *int64 `json:"next_attempt_ms,omitempty"` +} + +type CreateJobRequest struct { + // List of permissions to set on the job. + AccessControlList []AccessControlRequest `json:"access_control_list,omitempty"` + // The id of the user specified budget policy to use for this job. If not + // specified, a default budget policy may be applied when creating or modifying + // the job. See `effective_budget_policy_id` for the budget policy used by this + // workload. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // An optional continuous property for this job. The continuous property will + // ensure that there is always one run executing. Only one of `schedule` and + // `continuous` can be used. + // + // Pipelines started by a continuous job also run continuously, regardless of + // their own pipeline mode setting. + Continuous *ContinuousSettings `json:"continuous,omitempty"` + // Deployment information for jobs managed by external sources. + Deployment *JobDeployment `json:"deployment,omitempty"` + // An optional description for the job. The maximum length is 27700 characters + // in UTF-8 encoding. + Description *string `json:"description,omitempty"` + // An option to disable auto optimization in serverless + DisableAutoOptimization *bool `json:"disable_auto_optimization,omitempty"` + // Edit mode of the job. + // + // * `UI_LOCKED`: The job is in a locked UI state and cannot be modified. * + // `EDITABLE`: The job is in an editable state and can be modified. + EditMode JobEditMode `json:"edit_mode,omitempty"` + // An optional set of email addresses that is notified when runs of this job + // begin or complete as well as when this job is deleted. + EmailNotifications *JobEmailNotifications `json:"email_notifications,omitempty"` + // Named environment-variable entries that tasks can reference by key from + // `TaskSettings.environment_variables_key`. Each entry's `spec` holds inline + // `variables` and optional `.env` `files`. Maximum 10 entries per job. A task + // can reference at most one entry from this list. + EnvironmentVariables []JobEnvironmentVariables `json:"environment_variables,omitempty"` + // A list of task execution environment specifications that can be referenced by + // tasks that use serverless compute or a compute resource that uses + // Environments mode. For notebook tasks that use serverless compute or a + // compute resource that uses Environments mode, if the environment_key is not + // specified, the notebook environment will be used if present. If a jobs + // environment is specified, it will override the notebook environment. For + // other tasks that use serverless compute or a compute resource that uses + // Environments mode, the task environment is required to be specified using + // environment_key in the task settings. + Environments []JobEnvironment `json:"environments,omitempty"` + // Used to tell what is the format of the job. This field is ignored in + // Create/Update/Reset calls. When using the Jobs API 2.1 this value is always + // set to `"MULTI_TASK"`. + Format Format `json:"format,omitempty"` + // An optional specification for a remote Git repository containing the source + // code used by tasks. Version-controlled source code is supported by notebook, + // dbt, Python script, and SQL File tasks. + // + // If `git_source` is set, these tasks retrieve the file from the remote + // repository by default. However, this behavior can be overridden by setting + // `source` to `WORKSPACE` on the task. + // + // Note: dbt and SQL File tasks support only version-controlled sources. If dbt + // or SQL File tasks are used, `git_source` must be defined on the job. + GitSource *GitSource `json:"git_source,omitempty"` + Health *JobsHealthRules `json:"health,omitempty"` + // A list of job cluster specifications that can be shared and reused by tasks + // of this job. Libraries cannot be declared in a shared job cluster. You must + // declare dependent libraries in task settings. + JobClusters []JobCluster `json:"job_clusters,omitempty"` + // An optional maximum allowed number of concurrent runs of the job. Set this + // value if you want to be able to execute multiple runs of the same job + // concurrently. This is useful for example if you trigger your job on a + // frequent schedule and want to allow consecutive runs to overlap with each + // other, or if you want to trigger multiple runs which differ by their input + // parameters. This setting affects only new runs. For example, suppose the + // job’s concurrency is 4 and there are 4 concurrent active runs. Then setting + // the concurrency to 3 won’t kill any of the active runs. However, from then + // on, new runs are skipped unless there are fewer than 3 active runs. This + // value cannot exceed 1000. Setting this value to `0` causes all new runs to be + // skipped. + MaxConcurrentRuns *int `json:"max_concurrent_runs,omitempty"` + // An optional maximum number of times to retry an unsuccessful run. A run is + // considered to be unsuccessful if it completes with the `FAILED` result_state + // or `INTERNAL_ERROR` `life_cycle_state`. The value `-1` means to retry + // indefinitely and the value `0` means to never retry. + MaxRetries *int `json:"max_retries,omitempty"` + // An optional minimal interval in milliseconds between the start of the failed + // run and the subsequent retry run. The default behavior is that unsuccessful + // runs are immediately retried. + MinRetryIntervalMillis *int `json:"min_retry_interval_millis,omitempty"` + // An optional name for the job. The maximum length is 4096 bytes in UTF-8 + // encoding. + Name *string `json:"name,omitempty"` + // Optional notification settings that are used when sending notifications to + // each of the `email_notifications` and `webhook_notifications` for this job. + NotificationSettings *NotificationSettings `json:"notification_settings,omitempty"` + // Job-level parameter definitions + Parameters []JobLevelParameter `json:"parameters,omitempty"` + // Path of the job parent folder in workspace file tree. If absent, the job + // doesn't have a workspace object. + ParentPath *string `json:"parent_path,omitempty"` + // The performance mode on a serverless job. This field determines the level of + // compute performance or cost-efficiency for the run. The performance target + // does not apply to tasks that run on Serverless GPU compute. + // + // * `PERFORMANCE_OPTIMIZED`: Prioritizes fast startup and execution times + // through rapid scaling and optimized cluster performance. * `STANDARD`: + // Enables cost-efficient execution of serverless workloads. * `COST_OPTIMIZED`: + // Enables lower job costs by optimizing compute for your selected target + // duration time. Must provide a duration target. + PerformanceTarget PerformanceTarget_PerformanceTarget `json:"performance_target,omitempty"` + // The queue settings of the job. + Queue *QueueSettings `json:"queue,omitempty"` + // An optional policy to specify whether to retry a job when it times out. The + // default behavior is to not retry on timeout. + RetryOnTimeout *bool `json:"retry_on_timeout,omitempty"` + // The user or service principal that the job runs as, if specified in the + // request. This field indicates the explicit configuration of `run_as` for the + // job. To find the value in all cases, explicit or implicit, use + // `run_as_user_name`. + RunAs *JobRunAs `json:"run_as,omitempty"` + // An optional periodic schedule for this job. The default behavior is that the + // job only runs when triggered by clicking “Run Now” in the Jobs UI or + // sending an API request to `runNow`. + Schedule *CronSchedule `json:"schedule,omitempty"` + // A map of tags associated with the job. These are forwarded to the cluster as + // cluster tags for jobs clusters, and are subject to the same limitations as + // cluster tags. A maximum of 25 tags can be added to the job. + Tags map[string]string `json:"tags,omitempty"` + // A list of task specifications to be executed by this job. It supports up to + // 1000 elements in write endpoints (:method:jobs/create, :method:jobs/reset, + // :method:jobs/update, :method:jobs/submit). Read endpoints return only 100 + // tasks. If more than 100 tasks are available, you can paginate through them + // using :method:jobs/get. Use the `next_page_token` field at the object root to + // determine if more results are available. + Tasks []TaskSettings `json:"tasks,omitempty"` + // An optional timeout applied to each run of this job. A value of `0` means no + // timeout. + TimeoutSeconds *int `json:"timeout_seconds,omitempty"` + // A configuration to trigger a run when certain conditions are met. The default + // behavior is that the job runs only when triggered by clicking “Run Now” + // in the Jobs UI or sending an API request to `runNow`. + Trigger *TriggerSettings `json:"trigger,omitempty"` + // List of triggers attached to this job. A run starts when any active trigger + // evaluates to true. Cannot be set in the same request as the legacy + // `schedule`, `trigger`, or `continuous` fields. Gated behind the "Multiple + // Triggers" feature preview. + Triggers []TriggerConfiguration `json:"triggers,omitempty"` + // 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_usage_policy_id` for the usage policy used by this + // workload. + UsagePolicyId *string `json:"usage_policy_id,omitempty"` + // A collection of system notification IDs to notify when runs of this job begin + // or complete. + WebhookNotifications *WebhookNotifications `json:"webhook_notifications,omitempty"` +} + +// Job was created successfully. +type CreateJobResponse struct { + // The canonical identifier for the newly created job. + JobId *int64 `json:"job_id,omitempty"` +} + +type CronSchedule struct { + // Indicate whether this schedule is paused or not. + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + // A Cron expression using Quartz syntax that describes the schedule for a job. + // See [Cron Trigger] for details. This field is required. + // + // [Cron Trigger]: http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html + QuartzCronExpression *string `json:"quartz_cron_expression,omitempty"` + // SQL condition that must be satisfied before a scheduled run is triggered. The + // condition is evaluated after the cron expression fires and must return a + // truthy result for the run to proceed. + SqlCondition *SqlConditionConfiguration `json:"sql_condition,omitempty"` + // A Java timezone ID. The schedule for a job is resolved with respect to this + // timezone. See [Java TimeZone] for details. This field is required. + // + // [Java TimeZone]: https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html + TimezoneId *string `json:"timezone_id,omitempty"` +} + +// Cron schedule trigger. Stripped-down counterpart to `CronSchedule`: +// `pause_status` and `sql_condition` are owned by the enclosing +// `TriggerConfiguration` and intentionally omitted here.. +type CronTriggerConfiguration struct { + // A Cron expression using Quartz syntax that describes the schedule for this + // trigger. See [Cron Trigger] for details. + // + // [Cron Trigger]: http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html + QuartzCronExpression *string `json:"quartz_cron_expression,omitempty"` + // A Java timezone ID. The schedule is resolved with respect to this timezone. + // See [Java TimeZone] for details. + // + // [Java TimeZone]: https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html + TimezoneId *string `json:"timezone_id,omitempty"` +} + +type DashboardPageSnapshot struct { + PageDisplayName *string `json:"page_display_name,omitempty"` + WidgetErrorDetails []WidgetErrorDetail `json:"widget_error_details,omitempty"` +} + +// Configures the Lakeview Dashboard job task type.. +type DashboardTask struct { + // The identifier of the dashboard to refresh. + DashboardId *string `json:"dashboard_id,omitempty"` + // Dashboard task parameters. Used to apply dashboard filter values during + // dashboard task execution. Parameter values get applied to any dashboard + // filters that have a matching URL identifier as the parameter key. The + // parameter value format is dependent on the filter type: - For text and + // single-select filters, provide a single value (e.g. `"value"`) - For date and + // datetime filters, provide the value in ISO 8601 format (e.g. + // `"2000-01-01T00:00:00"`) - For multi-select filters, provide a JSON array of + // values (e.g. `"[\"value1\",\"value2\"]"`) - For range and date range filters, + // provide a JSON object with `start` and `end` (e.g. + // `"{\"start\":\"1\",\"end\":\"10\"}"`) + Filters map[string]string `json:"filters,omitempty"` + // Optional: subscription configuration for sending the dashboard snapshot. + Subscription *Subscription `json:"subscription,omitempty"` + // Optional: The warehouse id to execute the dashboard with for the schedule. If + // not specified, the default warehouse of the dashboard will be used. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type DashboardTaskOutput struct { + // Should only be populated for manual PDF download jobs. + PageSnapshots []DashboardPageSnapshot `json:"page_snapshots,omitempty"` +} + +// A storage location in DBFS. +type DbfsStorageInfo struct { + // dbfs destination, e.g. `dbfs:/my/path` + Destination *string `json:"destination,omitempty"` +} + +// Format of response retrieved from dbt Cloud, for inclusion in output +// Deprecated in favor of DbtPlatformJobRunStep. +type DbtCloudJobRunStep struct { + // Orders the steps in the job + Index *int `json:"index,omitempty"` + // Output of the step + Logs *string `json:"logs,omitempty"` + // Name of the step in the job + Name *string `json:"name,omitempty"` + // State of the step + Status DbtPlatformRunStatus `json:"status,omitempty"` +} + +// Deprecated in favor of DbtPlatformTask. +type DbtCloudTask struct { + // The resource name of the UC connection that authenticates the dbt Cloud for + // this task + ConnectionResourceName *string `json:"connection_resource_name,omitempty"` + // Id of the dbt Cloud job to be triggered + DbtCloudJobId *int64 `json:"dbt_cloud_job_id,omitempty"` +} + +// Deprecated in favor of DbtPlatformTaskOutput. +type DbtCloudTaskOutput struct { + // Id of the job run in dbt Cloud + DbtCloudJobRunId *int64 `json:"dbt_cloud_job_run_id,omitempty"` + // Steps of the job run as received from dbt Cloud + DbtCloudJobRunOutput []DbtCloudJobRunStep `json:"dbt_cloud_job_run_output,omitempty"` + // Url where full run details can be viewed + DbtCloudJobRunUrl *string `json:"dbt_cloud_job_run_url,omitempty"` +} + +// Format of response retrieved from dbt platform, for inclusion in output. +type DbtPlatformJobRunStep struct { + // Orders the steps in the job + Index *int `json:"index,omitempty"` + // Output of the step + Logs *string `json:"logs,omitempty"` + // Whether the logs of this step have been truncated. If true, the logs has been + // truncated to 10000 characters. + LogsTruncated *bool `json:"logs_truncated,omitempty"` + // Name of the step in the job + Name *string `json:"name,omitempty"` + // Whether the name of the job has been truncated. If true, the name has been + // truncated to 100 characters. + NameTruncated *bool `json:"name_truncated,omitempty"` + // State of the step + Status DbtPlatformRunStatus `json:"status,omitempty"` +} + +type DbtPlatformTask struct { + // The resource name of the UC connection that authenticates the dbt platform + // for this task + ConnectionResourceName *string `json:"connection_resource_name,omitempty"` + // Id of the dbt platform job to be triggered. Specified as a string for maximum + // compatibility with clients. + DbtPlatformJobId *string `json:"dbt_platform_job_id,omitempty"` +} + +type DbtPlatformTaskOutput struct { + // Id of the job run in dbt platform. Specified as a string for maximum + // compatibility with clients. + DbtPlatformJobRunId *string `json:"dbt_platform_job_run_id,omitempty"` + // Steps of the job run as received from dbt platform + DbtPlatformJobRunOutput []DbtPlatformJobRunStep `json:"dbt_platform_job_run_output,omitempty"` + // Url where full run details can be viewed + DbtPlatformJobRunUrl *string `json:"dbt_platform_job_run_url,omitempty"` + // Whether the number of steps in the output has been truncated. If true, the + // output will contain the first 20 steps of the output. + StepsTruncated *bool `json:"steps_truncated,omitempty"` +} + +type DbtTask struct { + // Optional name of the catalog to use. The value is the top level in the + // 3-level namespace of Unity Catalog (catalog / schema / relation). The catalog + // value can only be specified if a warehouse_id is specified. Requires + // dbt-databricks >= 1.1.1. + Catalog *string `json:"catalog,omitempty"` + // A list of dbt commands to execute. All commands must start with `dbt`. This + // parameter must not be empty. A maximum of up to 10 commands can be provided. + Commands []string `json:"commands,omitempty"` + // Optional (relative) path to the profiles directory. Can only be specified if + // no warehouse_id is specified. If no warehouse_id is specified and this folder + // is unset, the root directory is used. + ProfilesDirectory *string `json:"profiles_directory,omitempty"` + // Path to the project directory. Optional for Git sourced tasks, in which case + // if no value is provided, the root of the Git repository is used. + ProjectDirectory *string `json:"project_directory,omitempty"` + // Optional schema to write to. This parameter is only used when a warehouse_id + // is also provided. If not provided, the `default` schema is used. + Schema *string `json:"schema,omitempty"` + // Optional location type of the project directory. When set to `WORKSPACE`, the + // project will be retrieved from the local workspace. When set to + // `GIT`, the project will be retrieved from a Git repository defined in + // `git_source`. If the value is empty, the task will use `GIT` if `git_source` + // is defined and `WORKSPACE` otherwise. + // + // * `WORKSPACE`: Project is located in workspace. * `GIT`: Project + // is located in cloud Git provider. + Source Source `json:"source,omitempty"` + // ID of the SQL warehouse to connect to. If provided, we automatically generate + // and provide the profile and connection details to dbt. It can be overridden + // on a per-command basis by using the `--profiles-dir` command line argument. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type DbtTask_DbtTaskOutput struct { + // An optional map of headers to send when retrieving the artifact from the + // `artifacts_link`. + ArtifactsHeaders map[string]string `json:"artifacts_headers,omitempty"` + // A pre-signed URL to download the (compressed) dbt artifacts. This link is + // valid for a limited time (30 minutes). This information is only available + // after the run has finished. + ArtifactsLink *string `json:"artifacts_link,omitempty"` +} + +type DeleteJobRequest struct { + // The canonical identifier of the job to delete. This field is required. + JobId *int64 `json:"job_id,omitempty"` +} + +type DeleteRunRequest struct { + // ID of the run to delete. + RunId *int64 `json:"run_id,omitempty"` +} + +// DeploymentSpec: configuration for one deployment within an AiRuntimeTask. +// Each entry in `AiRuntimeTask.deployments` describes a group of nodes that +// share the same command and compute. Many single-program training algorithms +// use a single entry where every node runs the same command; role-split +// workloads (driver + worker, parameter server, separate eval node, etc.) use +// multiple entries.. +type DeploymentSpec struct { + // Workspace path of the script to run on each node in this deployment. Upload + // the script to this path and supply the path here. When the task runs, the + // file at this path is run on each node; if it fails, the task fails with its + // exit code. + // + // Example script contents: + // + // ```bash # Plain Python: python train.py --epochs 10 + // + // # Multi-GPU via accelerate: accelerate launch train.py --config config.yaml + // + // # Distributed via torchrun: torchrun --nproc_per_node=8 train.py ``` + CommandPath *string `json:"command_path,omitempty"` + // Compute resources allocated to each node in this deployment. + Compute *ComputeSpec `json:"compute,omitempty"` + // Optional human-readable name for this deployment (for example, `driver`, + // `worker`, `param_server`). Used for log and UI display. Distinct names are + // recommended so deployments can be told apart, but uniqueness is not enforced. + Name *string `json:"name,omitempty"` +} + +type DockerBasicAuth struct { + // Password of the user + Password *string `json:"password,omitempty"` + // Name of the user + Username *string `json:"username,omitempty"` +} + +type DockerImage struct { + BasicAuth *DockerBasicAuth `json:"basic_auth,omitempty"` + // URL of the docker image. + Url *string `json:"url,omitempty"` +} + +type EnforcePolicyComplianceForJob struct { + // The ID of the job you want to enforce policy compliance on. + JobId *int64 `json:"job_id,omitempty"` + // If set, previews changes made to the job to comply with its policy, but does + // not update the job. + ValidateOnly *bool `json:"validate_only,omitempty"` +} + +type EnforcePolicyComplianceResponse struct { + // Whether any changes have been made to the job cluster settings for the job to + // become compliant with its policies. + HasChanges *bool `json:"has_changes,omitempty"` + // A list of job cluster changes that have been made to the job’s cluster + // settings in order for all job clusters to become compliant with their + // policies. + JobClusterChanges []EnforcePolicyComplianceResponse_JobClusterSettingsChange `json:"job_cluster_changes,omitempty"` + // Updated job settings after policy enforcement. Policy enforcement only + // applies to job clusters that are created when running the job (which are + // specified in new_cluster) and does not apply to existing all-purpose + // clusters. Updated job settings are derived by applying policy default values + // to the existing job clusters in order to satisfy policy requirements. + Settings *JobSettings `json:"settings,omitempty"` +} + +// Represents a change to the job cluster's settings that would be required for +// the job clusters to become compliant with their policies.. +type EnforcePolicyComplianceResponse_JobClusterSettingsChange struct { + // The field where this change would be made, prepended with the job cluster + // key. + Field *string `json:"field,omitempty"` + // The new value of this field after enforcing policy compliance (either a + // number, a boolean, or a string) converted to a string. This is intended to be + // read by a human. The typed new value of this field can be retrieved by + // reading the settings field in the API response. + NewValue *string `json:"new_value,omitempty"` + // The previous value of this field before enforcing policy compliance (either a + // number, a boolean, or a string) converted to a string. This is intended to be + // read by a human. The type of the field can be retrieved by reading the + // settings field in the API response. + PreviousValue *string `json:"previous_value,omitempty"` +} + +// The environment entity used to preserve serverless environment side panel, +// jobs' environment for non-notebook task, and SDP's environment for classic +// and serverless pipelines. In this minimal environment spec, only pip and java +// dependencies are supported.. +type Environment struct { + // The base environment this environment is built on top of. A base environment + // defines the environment version and a list of dependencies for serverless + // compute. The value can be a file path to a custom `env.yaml` file (e.g., + // `/Workspace/path/to/env.yaml`). Support for a -provided base + // environment ID (e.g., `workspace-base-environments/databricks_ai_v4`) and + // workspace base environment ID (e.g., + // `workspace-base-environments/dbe_b849b66e-b31a-4cb5-b161-1f2b10877fb7`) is in + // Beta. Either `environment_version` or `base_environment` can be provided. For + // more information about -provided base environments, see the [list + // workspace base + // environments](:method:Environments/ListWorkspaceBaseEnvironments) API. For + // more information, see + BaseEnvironment *string `json:"base_environment,omitempty"` + // Use `environment_version` instead. + Client *string `json:"client,omitempty"` + // List of pip dependencies, as supported by the version of pip in this + // environment. Each dependency is a valid pip requirements file line per + // https://pip.pypa.io/en/stable/reference/requirements-file-format/. Allowed + // dependencies include a requirement specifier, an archive URL, a local project + // path (such as WSFS or UC Volumes in ), or a VCS project URL. + Dependencies []string `json:"dependencies,omitempty"` + // Either `environment_version` or `base_environment` needs to be provided. + // Environment version used by the environment. Each version comes with a + // specific Python version and a set of Python packages. The version is a + // string, consisting of an integer. + EnvironmentVersion *string `json:"environment_version,omitempty"` + // List of java dependencies. Each dependency is a string representing a java + // library path. For example: `/Volumes/path/to/test.jar`. + JavaDependencies []string `json:"java_dependencies,omitempty"` + // File path of pyproject.toml file that defines the project-scoped environment. + ProjectEnvironment *string `json:"project_environment,omitempty"` +} + +// Retrieves the export of a job run task.. +type ExportRunRequest struct { + // The canonical identifier for the run. This field is required. + RunId *int64 `json:"run_id,omitempty"` + // Which views to export (CODE, DASHBOARDS, or ALL). Defaults to CODE. + ViewsToExport ViewsToExport `json:"views_to_export,omitempty"` +} + +// Run was exported successfully.. +type ExportRunResponse struct { + // The exported content in HTML format (one for every view item). To extract the + // HTML notebook from the JSON response, download and run this [Python + // script](/_static/examples/extract.py). + Views []ViewItem `json:"views,omitempty"` +} + +type FileArrivalTriggerConfiguration struct { + // If set, the trigger starts a run only after the specified amount of time + // passed since the last time the trigger fired. The minimum allowed value is 60 + // seconds + MinTimeBetweenTriggersSeconds *int `json:"min_time_between_triggers_seconds,omitempty"` + // URL to be monitored for file arrivals. The path must point to the root or a + // subpath of the external location. + Url *string `json:"url,omitempty"` + // If set, the trigger starts a run only after no file activity has occurred for + // the specified amount of time. This makes it possible to wait for a batch of + // incoming files to arrive before triggering a run. The minimum allowed value + // is 60 seconds. + WaitAfterLastChangeSeconds *int `json:"wait_after_last_change_seconds,omitempty"` +} + +type FileArrivalTriggerState struct { + // Indicates whether the trigger leverages file events to detect file arrivals. + UsingFileEvents *bool `json:"using_file_events,omitempty"` +} + +type ForEachTask struct { + // An optional maximum allowed number of concurrent runs of the task. Set this + // value if you want to be able to execute multiple runs of the task + // concurrently. + Concurrency *int `json:"concurrency,omitempty"` + // Array for task to iterate on. This can be a JSON string or a reference to an + // array parameter. + Inputs *string `json:"inputs,omitempty"` + // Configuration for the task that will be run for each element in the array + Task *TaskSettings `json:"task,omitempty"` +} + +// Attributes set during cluster creation which are related to GCP.. +type GcpAttributes struct { + // This field determines whether the spark executors will be scheduled to run on + // preemptible VMs, on-demand VMs, or preemptible VMs with a fallback to + // on-demand VMs if the former is unavailable. + Availability GcpAvailability `json:"availability,omitempty"` + // Boot disk size in GB + BootDiskSize *int `json:"boot_disk_size,omitempty"` + // The confidential computing technology for this cluster's instances. Currently + // only SEV_SNP is supported, and only on N2D instance types. When not set, no + // confidential computing is applied. + ConfidentialComputeType ConfidentialComputeType `json:"confidential_compute_type,omitempty"` + // The first `first_on_demand` nodes of the cluster will be placed on on-demand + // instances. This value should be greater than 0, to make sure the cluster + // driver node is placed on an on-demand instance. If this value is greater than + // or equal to the current cluster size, all nodes will be placed on on-demand + // instances. If this value is less than the current cluster size, + // `first_on_demand` nodes will be placed on on-demand instances and the + // remainder will be placed on `availability` instances. Note that this value + // does not affect cluster size and cannot currently be mutated over the + // lifetime of a cluster. + FirstOnDemand *int `json:"first_on_demand,omitempty"` + // If provided, the cluster will impersonate the google service account when + // accessing gcloud services (like GCS). The google service account must have + // previously been added to the environment by an account + // administrator. + GoogleServiceAccount *string `json:"google_service_account,omitempty"` + // If provided, each node (workers and driver) in the cluster will have this + // number of local SSDs attached. Each local SSD is 375GB in size. Refer to [GCP + // documentation] for the supported number of local SSDs for each instance type. + // + // [GCP documentation]: https://cloud.google.com/compute/docs/disks/local-ssd#choose_number_local_ssds + LocalSsdCount *int `json:"local_ssd_count,omitempty"` + // This field determines whether the spark executors will be scheduled to run on + // preemptible VMs (when set to true) versus standard compute engine VMs (when + // set to false; default). Note: Soon to be deprecated, use the 'availability' + // field instead. + UsePreemptibleExecutors *bool `json:"use_preemptible_executors,omitempty"` + // Identifier for the availability zone in which the cluster resides. This can + // be one of the following: - "HA" => High availability, spread nodes across + // availability zones for a deployment region [default]. - "AUTO" + // => picks an availability zone to schedule the cluster on. - A + // GCP availability zone => Pick One of the available zones for (machine type + + // region) from https://cloud.google.com/compute/docs/regions-zones. + ZoneId *string `json:"zone_id,omitempty"` +} + +// A storage location in Google Cloud Platform's GCS. +type GcsStorageInfo struct { + // GCS destination/URI, e.g. `gs://my-bucket/some-prefix` + Destination *string `json:"destination,omitempty"` +} + +// DEPRECATED — use `AiRuntimeTask` for all new BYOT multi-node GPU workloads +// (see ai_runtime_task.proto). `AiRuntimeTask` is the only supported BYOT task +// type for new workloads; this proto is retained only for AIR CLI (fka SGCLI) +// pywheel backwards compatibility and will be removed once the pywheel → +// databricks-cli migration completes (post- PuPr).. +type GenAiComputeTask struct { + // Command launcher to run the actual script, e.g. bash, python etc. + Command *string `json:"command,omitempty"` + Compute *ComputeConfig `json:"compute,omitempty"` + // Runtime image + DlRuntimeImage *string `json:"dl_runtime_image,omitempty"` + // Optional string containing the name of the MLflow experiment to log the run + // to. If name is not found, backend will create the mlflow experiment using the + // name. + MlflowExperimentName *string `json:"mlflow_experiment_name,omitempty"` + // Optional location type of the training script. When set to `WORKSPACE`, the + // script will be retrieved from the local workspace. When set to + // `GIT`, the script will be retrieved from a Git repository defined in + // `git_source`. If the value is empty, the task will use `GIT` if `git_source` + // is defined and `WORKSPACE` otherwise. * `WORKSPACE`: Script is located in + // workspace. * `GIT`: Script is located in cloud Git provider. + Source Source `json:"source,omitempty"` + // The training script file path to be executed. Cloud file URIs (such as + // dbfs:/, s3:/, adls:/, gcs:/) and workspace paths are supported. For python + // files stored in the workspace, the path must be absolute and + // begin with `/`. For files stored in a remote repository, the path must be + // relative. This field is required. + TrainingScriptPath *string `json:"training_script_path,omitempty"` + // Optional string containing model parameters passed to the training script in + // yaml format. If present, then the content in yaml_parameters_file_path will + // be ignored. + YamlParameters *string `json:"yaml_parameters,omitempty"` + // Optional path to a YAML file containing model parameters passed to the + // training script. + YamlParametersFilePath *string `json:"yaml_parameters_file_path,omitempty"` +} + +// Retrieves information about a single job.. +type GetJobRequest struct { + // Flag that indicates that trigger state should be included in the response. + IncludeTriggerState *bool `json:"include_trigger_state,omitempty"` + // The canonical identifier of the job to retrieve information about. This field + // is required. + JobId *int64 `json:"job_id,omitempty"` + // Use `next_page_token` returned from the previous GetJob response to request + // the next page of the job's array properties. + PageToken *string `json:"page_token,omitempty"` +} + +// Job was retrieved successfully.. +type GetJobResponse struct { + // The time at which this job was created in epoch milliseconds (milliseconds + // since 1/1/1970 UTC). + CreatedTime *int64 `json:"created_time,omitempty"` + // The creator user name. This field won’t be included in the response if the + // user has already been deleted. + CreatorUserName *string `json:"creator_user_name,omitempty"` + // The id of the budget policy used by this job for cost attribution purposes. + // This may be set through (in order of precedence): 1. Budget admins through + // the account or workspace console 2. Jobs UI in the job details page and Jobs + // API using `budget_policy_id` 3. Inferred default based on accessible budget + // policies of the run_as identity on job creation or modification. + EffectiveBudgetPolicyId *string `json:"effective_budget_policy_id,omitempty"` + // The id of the usage policy used by this job for cost attribution purposes. + EffectiveUsagePolicyId *string `json:"effective_usage_policy_id,omitempty"` + // Indicates if the job has more array properties (`tasks`, `job_clusters`) that + // are not shown. They can be accessed via :method:jobs/get endpoint. It is only + // relevant for API 2.2 :method:jobs/list requests with `expand_tasks=true`. + HasMore *bool `json:"has_more,omitempty"` + // The canonical identifier for this job. + JobId *int64 `json:"job_id,omitempty"` + // A token that can be used to list the next page of array properties. + NextPageToken *string `json:"next_page_token,omitempty"` + // The email of an active workspace user or the application ID of a service + // principal that the job runs as. This value can be changed by setting the + // `run_as` field when creating or updating a job. + // + // By default, `run_as_user_name` is based on the current job settings and is + // set to the creator of the job if job access control is disabled or to the + // user with the `is_owner` permission if job access control is enabled. + RunAsUserName *string `json:"run_as_user_name,omitempty"` + // Settings for this job and all of its runs. These settings can be updated + // using the `resetJob` method. + Settings *JobSettings `json:"settings,omitempty"` + // Per-trigger runtime information for the multi-trigger surface. Same length + // and order as `JobSettings.triggers`; `trigger_details[i]` corresponds to + // `triggers[i]`. Sub-fields (`state`, `history`) are populated independently + // based on the `GetJob.include_trigger_state` / `include_trigger_history` + // flags. + TriggerDetails []TriggerDetails `json:"trigger_details,omitempty"` + // State of the trigger associated with the job. + TriggerState *TriggerState `json:"trigger_state,omitempty"` +} + +type GetPolicyComplianceForJobRequest struct { + // The ID of the job whose compliance status you are requesting. + JobId *int64 `json:"job_id,omitempty"` +} + +type GetPolicyComplianceForJobResponse struct { + // Whether the job is compliant with its policies or not. Jobs could be out of + // compliance if a policy they are using was updated after the job was last + // edited and some of its job clusters no longer comply with their updated + // policies. + IsCompliant *bool `json:"is_compliant,omitempty"` + // An object containing key-value mappings representing the first 200 policy + // validation errors. The keys indicate the path where the policy validation + // error is occurring. An identifier for the job cluster is prepended to the + // path. The values indicate an error message describing the policy validation + // error. + Violations map[string]string `json:"violations,omitempty"` +} + +// Retrieves both the output and the metadata of a run.. +type GetRunOutputRequest struct { + // The canonical identifier for the run. + RunId *int64 `json:"run_id,omitempty"` +} + +// Run output was retrieved successfully.. +type GetRunOutputResponse struct { + AiRuntimeTaskOutput *AiRuntimeTaskOutput `json:"ai_runtime_task_output,omitempty"` + AlertOutput *AlertTaskOutput `json:"alert_output,omitempty"` + CleanRoomsNotebookOutput *CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput `json:"clean_rooms_notebook_output,omitempty"` + DashboardOutput *DashboardTaskOutput `json:"dashboard_output,omitempty"` + DbtCloudOutput *DbtCloudTaskOutput `json:"dbt_cloud_output,omitempty"` + DbtOutput *DbtTask_DbtTaskOutput `json:"dbt_output,omitempty"` + DbtPlatformOutput *DbtPlatformTaskOutput `json:"dbt_platform_output,omitempty"` + // An error message indicating why a task failed or why output is not available. + // The message is unstructured, and its exact format is subject to change. + Error *string `json:"error,omitempty"` + // If there was an error executing the run, this field contains any available + // stack traces. + ErrorTrace *string `json:"error_trace,omitempty"` + Info *string `json:"info,omitempty"` + // The output from tasks that write to standard streams (stdout/stderr) such as + // spark_jar_task, spark_python_task, python_wheel_task. + // + // It's not supported for the notebook_task, pipeline_task or spark_submit_task. + // + // restricts this API to return the last 5 MB of these logs. + Logs *string `json:"logs,omitempty"` + // Whether the logs are truncated. + LogsTruncated *bool `json:"logs_truncated,omitempty"` + // All details of the run except for its output. + Metadata *Run `json:"metadata,omitempty"` + NotebookOutput *NotebookTask_NotebookOutput `json:"notebook_output,omitempty"` + RunJobOutput *RunJobTask_RunJobTaskOutput `json:"run_job_output,omitempty"` + SqlOutput *SqlTask_SqlOutput `json:"sql_output,omitempty"` +} + +type GetRunRequest struct { + // Whether to include the repair history in the response. + IncludeHistory *bool `json:"include_history,omitempty"` + // Whether to include resolved parameter values in the response. + IncludeResolvedValues *bool `json:"include_resolved_values,omitempty"` + // Use `next_page_token` returned from the previous GetRun response to request + // the next page of the run's array properties. + PageToken *string `json:"page_token,omitempty"` + // The canonical identifier of the run for which to retrieve the metadata. This + // field is required. + RunId *int64 `json:"run_id,omitempty"` +} + +// Run was retrieved successfully. +type GetRunResponse struct { + // The sequence number of this run attempt for a triggered job run. The initial + // attempt of a run has an attempt_number of 0. If the initial run attempt + // fails, and the job has a retry policy (`max_retries` > 0), subsequent runs + // are created with an `original_attempt_run_id` of the original attempt’s ID + // and an incrementing `attempt_number`. Runs are retried only until they + // succeed, and the maximum `attempt_number` is the same as the `max_retries` + // value for the job. + AttemptNumber *int `json:"attempt_number,omitempty"` + // The time in milliseconds it took to terminate the cluster and clean up any + // associated artifacts. The duration of a task run is the sum of the + // `setup_duration`, `execution_duration`, and the `cleanup_duration`. The + // `cleanup_duration` field is set to 0 for multitask job runs. The total + // duration of a multitask job run is the value of the `run_duration` field. + CleanupDuration *int64 `json:"cleanup_duration,omitempty"` + // The cluster used for this run. If the run is specified to use a new cluster, + // this field is set once the Jobs service has requested a cluster for the run. + ClusterInstance *ClusterInstance `json:"cluster_instance,omitempty"` + // A snapshot of the job’s cluster specification when this run was created. + ClusterSpec *ClusterSpec `json:"cluster_spec,omitempty"` + // The creator user name. This field won’t be included in the response if the + // user has already been deleted. + CreatorUserName *string `json:"creator_user_name,omitempty"` + // ID of the deployment that produced the job when this run was created. Used to + // look up deployment metadata from the Deployment Metadata service. Only set + // for job runs of jobs with a `BUNDLE` deployment. + DeploymentId *string `json:"deployment_id,omitempty"` + // Description of the run + Description *string `json:"description,omitempty"` + // The actual performance target used by the serverless run during execution. + // This can differ from the client-set performance target on the request + // depending on whether the performance mode is supported by the job type. + // + // * `PERFORMANCE_OPTIMIZED`: Prioritizes fast startup and execution times + // through rapid scaling and optimized cluster performance. * `STANDARD`: + // Enables cost-efficient execution of serverless workloads. * `COST_OPTIMIZED`: + // Enables lower job costs by optimizing compute for your selected target + // duration time. Must provide a duration target. + EffectivePerformanceTarget PerformanceTarget_PerformanceTarget `json:"effective_performance_target,omitempty"` + // The id of the usage policy used by this run for cost attribution purposes. + EffectiveUsagePolicyId *string `json:"effective_usage_policy_id,omitempty"` + // The time at which this run ended in epoch milliseconds (milliseconds since + // 1/1/1970 UTC). This field is set to 0 if the job is still running. + EndTime *int64 `json:"end_time,omitempty"` + // Snapshot of `JobSettings.environment_variables` as it was at run launch — + // the full list of named environment-variable entries the job defined. To find + // which entry a given task ran with, look at + // `RunTaskSettings.environment_variables_key`. + EnvironmentVariables []JobEnvironmentVariables `json:"environment_variables,omitempty"` + // The time in milliseconds it took to execute the commands in the JAR or + // notebook until they completed, failed, timed out, were cancelled, or + // encountered an unexpected error. The duration of a task run is the sum of the + // `setup_duration`, `execution_duration`, and the `cleanup_duration`. The + // `execution_duration` field is set to 0 for multitask job runs. The total + // duration of a multitask job run is the value of the `run_duration` field. + ExecutionDuration *int64 `json:"execution_duration,omitempty"` + // An optional specification for a remote Git repository containing the source + // code used by tasks. Version-controlled source code is supported by notebook, + // dbt, Python script, and SQL File tasks. + // + // If `git_source` is set, these tasks retrieve the file from the remote + // repository by default. However, this behavior can be overridden by setting + // `source` to `WORKSPACE` on the task. + // + // Note: dbt and SQL File tasks support only version-controlled sources. If dbt + // or SQL File tasks are used, `git_source` must be defined on the job. + GitSource *GitSource `json:"git_source,omitempty"` + // Indicates if the run has more array properties (`tasks`, `job_clusters`) that + // are not shown. They can be accessed via :method:jobs/getrun endpoint. It is + // only relevant for API 2.2 :method:jobs/listruns requests with + // `expand_tasks=true`. + HasMore *bool `json:"has_more,omitempty"` + // A list of job cluster specifications that can be shared and reused by tasks + // of this job. Libraries cannot be declared in a shared job cluster. You must + // declare dependent libraries in task settings. If more than 100 job clusters + // are available, you can paginate through them using :method:jobs/getrun. + JobClusters []JobCluster `json:"job_clusters,omitempty"` + // The canonical identifier of the job that contains this run. + JobId *int64 `json:"job_id,omitempty"` + // Job-level parameters used in the run + JobParameters []Run_JobLevelParameters `json:"job_parameters,omitempty"` + // ID of the job run that this run belongs to. For legacy and single-task job + // runs the field is populated with the job run ID. For task runs, the field is + // populated with the ID of the job run that the task run belongs to. + JobRunId *int64 `json:"job_run_id,omitempty"` + // A token that can be used to list the next page of array properties. + NextPageToken *string `json:"next_page_token,omitempty"` + // A unique identifier for this job run. This is set to the same value as + // `run_id`. + NumberInJob *int64 `json:"number_in_job,omitempty"` + // If this run is a retry of a prior run attempt, this field contains the run_id + // of the original attempt; otherwise, it is the same as the run_id. + OriginalAttemptRunId *int64 `json:"original_attempt_run_id,omitempty"` + // The parameters used for this run. + OverridingParameters *RunParameters `json:"overriding_parameters,omitempty"` + // The time in milliseconds that the run has spent in the queue. + QueueDuration *int64 `json:"queue_duration,omitempty"` + // The repair history of the run. + RepairHistory []Repair `json:"repair_history,omitempty"` + // The time in milliseconds it took the job run and all of its repairs to + // finish. + RunDuration *int64 `json:"run_duration,omitempty"` + // The canonical identifier of the run. This ID is unique across all runs of all + // jobs. + RunId *int64 `json:"run_id,omitempty"` + // An optional name for the run. The maximum length is 4096 bytes in UTF-8 + // encoding. + RunName *string `json:"run_name,omitempty"` + // The URL to the detail page of the run. + RunPageUrl *string `json:"run_page_url,omitempty"` + RunType RunType `json:"run_type,omitempty"` + // The cron schedule that triggered this run if it was triggered by the periodic + // scheduler. + Schedule *CronSchedule `json:"schedule,omitempty"` + // The time in milliseconds it took to set up the cluster. For runs that run on + // new clusters this is the cluster creation time, for runs that run on existing + // clusters this time should be very short. The duration of a task run is the + // sum of the `setup_duration`, `execution_duration`, and the + // `cleanup_duration`. The `setup_duration` field is set to 0 for multitask job + // runs. The total duration of a multitask job run is the value of the + // `run_duration` field. + SetupDuration *int64 `json:"setup_duration,omitempty"` + // The time at which this run was started in epoch milliseconds (milliseconds + // since 1/1/1970 UTC). This may not be the time when the job task starts + // executing, for example, if the job is scheduled to run on a new cluster, this + // is the time the cluster creation call is issued. + StartTime *int64 `json:"start_time,omitempty"` + // Deprecated. Please use the `status` field instead. + State *RunState `json:"state,omitempty"` + Status *RunStatus `json:"status,omitempty"` + // The list of tasks performed by the run. Each task has its own `run_id` which + // you can use to call `JobsGetOutput` to retrieve the run results. If more than + // 100 tasks are available, you can paginate through them using + // :method:jobs/getrun. Use the `next_page_token` field at the object root to + // determine if more results are available. + Tasks []RunTask `json:"tasks,omitempty"` + Trigger TriggerType `json:"trigger,omitempty"` + TriggerInfo *RunTriggerInfo `json:"trigger_info,omitempty"` + // ID of the deployment version that produced the job when this run was created. + // Identifies a specific snapshot of the deployment in the Deployment Metadata + // service. Only set for job runs of jobs with a `BUNDLE` deployment. + VersionId *string `json:"version_id,omitempty"` +} + +// Read-only state of the remote repository at the time the job was run. This +// field is only included on job runs.. +type GitMetadataSnapshot struct { + // Commit that was used to execute the run. If git_branch was specified, this + // points to the HEAD of the branch at the time of the run; if git_tag was + // specified, this points to the commit the tag points to. + UsedCommit *string `json:"used_commit,omitempty"` +} + +// An optional specification for a remote Git repository containing the source +// code used by tasks. Version-controlled source code is supported by notebook, +// dbt, Python script, and SQL File tasks. +// +// If `git_source` is set, these tasks retrieve the file from the remote +// repository by default. However, this behavior can be overridden by setting +// `source` to `WORKSPACE` on the task. +// +// Note: dbt and SQL File tasks support only version-controlled sources. If dbt +// or SQL File tasks are used, `git_source` must be defined on the job.. +type GitSource struct { + GitBranch *string `json:"git_branch,omitempty"` + GitCommit *string `json:"git_commit,omitempty"` + // Unique identifier of the service used to host the Git repository. The value + // is case insensitive. + GitProvider *string `json:"git_provider,omitempty"` + GitSnapshot *GitMetadataSnapshot `json:"git_snapshot,omitempty"` + GitTag *string `json:"git_tag,omitempty"` + // URL of the repository to be cloned by this job. + GitUrl *string `json:"git_url,omitempty"` + // The source of the job specification in the remote repository when the job is + // source controlled. + JobSource *JobSource `json:"job_source,omitempty"` + SparseCheckout *SparseCheckout `json:"sparse_checkout,omitempty"` +} + +// Config for an individual init script. +type InitScriptInfo struct { + Abfss *Adlsgen2Info `json:"abfss,omitempty"` + Dbfs *DbfsStorageInfo `json:"dbfs,omitempty"` + File *LocalFileInfo `json:"file,omitempty"` + Gcs *GcsStorageInfo `json:"gcs,omitempty"` + S3 *S3StorageInfo `json:"s3,omitempty"` + Volumes *VolumesStorageInfo `json:"volumes,omitempty"` + Workspace *WorkspaceStorageInfo `json:"workspace,omitempty"` +} + +type JobCluster struct { + // A unique name for the job cluster. This field is required and must be unique + // within the job. `JobTaskSettings` may refer to this field to determine which + // cluster to launch for the task execution. + JobClusterKey *string `json:"job_cluster_key,omitempty"` + // If new_cluster, a description of a cluster that is created for each task. + NewCluster *ClusterSpec_NewCluster `json:"new_cluster,omitempty"` + // The ID of the serverless compute object to bind this cluster to. At most one + // JobCluster per job may set this field; the rate limit defined on the + // referenced serverless compute applies across all tasks bound to this cluster. + ServerlessComputeId *string `json:"serverless_compute_id,omitempty"` +} + +type JobDeployment struct { + // ID of the deployment that manages this job. Only set when `kind` is `BUNDLE`. + // Used to look up deployment metadata from the Deployment Metadata service. + DeploymentId *string `json:"deployment_id,omitempty"` + // The kind of deployment that manages the job. + // + // * `BUNDLE`: The job is managed by Databricks Asset Bundle. * + // `SYSTEM_MANAGED`: The job is managed by and is read-only. + Kind JobDeployment_DeploymentKind `json:"kind,omitempty"` + // Path of the file that contains deployment metadata. + MetadataFilePath *string `json:"metadata_file_path,omitempty"` + // ID of the version of the deployment that produced this job. Only set when + // `kind` is `BUNDLE`. Identifies a specific snapshot of the deployment in the + // Deployment Metadata service. + VersionId *string `json:"version_id,omitempty"` +} + +type JobEmailNotifications struct { + // If true, do not send email to recipients specified in `on_failure` if the run + // is skipped. This field is `deprecated`. Please use the + // `notification_settings.no_alert_for_skipped_runs` field. + NoAlertForSkippedRuns *bool `json:"no_alert_for_skipped_runs,omitempty"` + // A list of email addresses to be notified when the duration of a run exceeds + // the threshold specified for the `RUN_DURATION_SECONDS` metric in the `health` + // field. If no rule for the `RUN_DURATION_SECONDS` metric is specified in the + // `health` field for the job, notifications are not sent. + OnDurationWarningThresholdExceeded []string `json:"on_duration_warning_threshold_exceeded,omitempty"` + // A list of email addresses to be notified when a run unsuccessfully completes. + // A run is considered to have completed unsuccessfully if it ends with an + // `INTERNAL_ERROR` `life_cycle_state` or a `FAILED`, or `TIMED_OUT` + // result_state. If this is not specified on job creation, reset, or update the + // list is empty, and notifications are not sent. + OnFailure []string `json:"on_failure,omitempty"` + // A list of email addresses to notify when platform-initiated maintenance + // completes for a continuous job. + OnMaintenanceComplete []string `json:"on_maintenance_complete,omitempty"` + // A list of email addresses to notify when platform-initiated maintenance + // starts for a continuous job. + OnMaintenanceStart []string `json:"on_maintenance_start,omitempty"` + // A list of email addresses to be notified when a run begins. If not specified + // on job creation, reset, or update, the list is empty, and notifications are + // not sent. + OnStart []string `json:"on_start,omitempty"` + // A list of email addresses to notify when any streaming backlog thresholds are + // exceeded for any stream. Streaming backlog thresholds can be set in the + // `health` field using the following metrics: `STREAMING_BACKLOG_BYTES`, + // `STREAMING_BACKLOG_RECORDS`, `STREAMING_BACKLOG_SECONDS`, or + // `STREAMING_BACKLOG_FILES`. Alerting is based on the 10-minute average of + // these metrics. If the issue persists, notifications are resent every 30 + // minutes. + OnStreamingBacklogExceeded []string `json:"on_streaming_backlog_exceeded,omitempty"` + // A list of email addresses to be notified when a run successfully completes. A + // run is considered to have completed successfully if it ends with a + // `TERMINATED` `life_cycle_state` and a `SUCCESS` result_state. If not + // specified on job creation, reset, or update, the list is empty, and + // notifications are not sent. + OnSuccess []string `json:"on_success,omitempty"` +} + +type JobEnvironment struct { + // The key of an environment. It has to be unique within a job. + EnvironmentKey *string `json:"environment_key,omitempty"` + Spec *Environment `json:"spec,omitempty"` +} + +// A named environment-variable entry, defined once at the job level and +// referenced by key from one or more tasks. Entries live on +// `JobSettings.environment_variables`, and tasks select one via +// `TaskSettings.environment_variables_key`.. +type JobEnvironmentVariables struct { + // Identifier for this entry. Must be unique within + // `JobSettings.environment_variables`. Tasks reference it from + // `TaskSettings.environment_variables_key`. + EnvironmentVariablesKey *string `json:"environment_variables_key,omitempty"` + // The environment variable specification. + Spec *JobEnvironmentVariablesSpec `json:"spec,omitempty"` +} + +// The environment variables and files associated with a job environment +// variable entry. Runtime environment variables override inline `variables`, +// which override values from `files`, on duplicate keys.. +type JobEnvironmentVariablesSpec struct { + // Workspace (`/Workspace/...`) or UC Volumes (`/Volumes/...`) paths to `.env` + // files. Maximum 5 files. Files are read, parsed, and merged at task execution + // time, not at job creation or update API call time. + // + // File format: each line containing a variable must be exactly `KEY=VALUE`. + // Empty and whitespace-only lines, and lines beginning with `#`, are ignored. + // Keys must match the same regex as inlined variable names + // (`^[A-Za-z_][A-Za-z0-9_]*$`); the value continues to the end of the line. No + // other syntax is supported — no inline comments, no quoted values, no escape + // sequences, no variable interpolation. Any other line that does not match the + // `KEY=VALUE` shape fails the run. + // + // Size limits: maximum 32,768 bytes (32 KiB) per file on disk; maximum 1,024 + // bytes (1 KiB) per `KEY=VALUE` line combined. Files or lines exceeding these + // limits fail the run. + // + // On a duplicate key, the later file wins; `variables` override values from any + // file. + Files []string `json:"files,omitempty"` + // Environment variables specified directly as key/value pairs. Maximum 20 + // entries. + // + // Each key must be 1 to 256 characters and match `^[A-Za-z_][A-Za-z0-9_]*$`: it + // must start with an ASCII letter or underscore and contain only ASCII letters, + // digits, and underscores. Each value can be any Unicode string of up to 512 + // characters, including an empty string. + Variables map[string]string `json:"variables,omitempty"` +} + +type JobLevelParameter struct { + // Default value of the parameter. + Default *string `json:"default,omitempty"` + // The name of the defined parameter. May only contain alphanumeric characters, + // `_`, `-`, and `.` + Name *string `json:"name,omitempty"` +} + +// Write-only setting. Specifies the user, service principal, or group that the +// job runs as. If not specified, the job runs as the user who created the job. +// +// One of `user_name`, `service_principal_name`, or `group_name` should be +// specified. If not, an error is thrown.. +type JobRunAs struct { + GroupName *string `json:"group_name,omitempty"` + ServicePrincipalName *string `json:"service_principal_name,omitempty"` + UserName *string `json:"user_name,omitempty"` +} + +type JobSettings struct { + // The id of the user specified budget policy to use for this job. If not + // specified, a default budget policy may be applied when creating or modifying + // the job. See `effective_budget_policy_id` for the budget policy used by this + // workload. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // An optional continuous property for this job. The continuous property will + // ensure that there is always one run executing. Only one of `schedule` and + // `continuous` can be used. + // + // Pipelines started by a continuous job also run continuously, regardless of + // their own pipeline mode setting. + Continuous *ContinuousSettings `json:"continuous,omitempty"` + // Deployment information for jobs managed by external sources. + Deployment *JobDeployment `json:"deployment,omitempty"` + // An optional description for the job. The maximum length is 27700 characters + // in UTF-8 encoding. + Description *string `json:"description,omitempty"` + // An option to disable auto optimization in serverless + DisableAutoOptimization *bool `json:"disable_auto_optimization,omitempty"` + // Edit mode of the job. + // + // * `UI_LOCKED`: The job is in a locked UI state and cannot be modified. * + // `EDITABLE`: The job is in an editable state and can be modified. + EditMode JobEditMode `json:"edit_mode,omitempty"` + // An optional set of email addresses that is notified when runs of this job + // begin or complete as well as when this job is deleted. + EmailNotifications *JobEmailNotifications `json:"email_notifications,omitempty"` + // Named environment-variable entries that tasks can reference by key from + // `TaskSettings.environment_variables_key`. Each entry's `spec` holds inline + // `variables` and optional `.env` `files`. Maximum 10 entries per job. A task + // can reference at most one entry from this list. + EnvironmentVariables []JobEnvironmentVariables `json:"environment_variables,omitempty"` + // A list of task execution environment specifications that can be referenced by + // tasks that use serverless compute or a compute resource that uses + // Environments mode. For notebook tasks that use serverless compute or a + // compute resource that uses Environments mode, if the environment_key is not + // specified, the notebook environment will be used if present. If a jobs + // environment is specified, it will override the notebook environment. For + // other tasks that use serverless compute or a compute resource that uses + // Environments mode, the task environment is required to be specified using + // environment_key in the task settings. + Environments []JobEnvironment `json:"environments,omitempty"` + // Used to tell what is the format of the job. This field is ignored in + // Create/Update/Reset calls. When using the Jobs API 2.1 this value is always + // set to `"MULTI_TASK"`. + Format Format `json:"format,omitempty"` + // An optional specification for a remote Git repository containing the source + // code used by tasks. Version-controlled source code is supported by notebook, + // dbt, Python script, and SQL File tasks. + // + // If `git_source` is set, these tasks retrieve the file from the remote + // repository by default. However, this behavior can be overridden by setting + // `source` to `WORKSPACE` on the task. + // + // Note: dbt and SQL File tasks support only version-controlled sources. If dbt + // or SQL File tasks are used, `git_source` must be defined on the job. + GitSource *GitSource `json:"git_source,omitempty"` + Health *JobsHealthRules `json:"health,omitempty"` + // A list of job cluster specifications that can be shared and reused by tasks + // of this job. Libraries cannot be declared in a shared job cluster. You must + // declare dependent libraries in task settings. + JobClusters []JobCluster `json:"job_clusters,omitempty"` + // An optional maximum allowed number of concurrent runs of the job. Set this + // value if you want to be able to execute multiple runs of the same job + // concurrently. This is useful for example if you trigger your job on a + // frequent schedule and want to allow consecutive runs to overlap with each + // other, or if you want to trigger multiple runs which differ by their input + // parameters. This setting affects only new runs. For example, suppose the + // job’s concurrency is 4 and there are 4 concurrent active runs. Then setting + // the concurrency to 3 won’t kill any of the active runs. However, from then + // on, new runs are skipped unless there are fewer than 3 active runs. This + // value cannot exceed 1000. Setting this value to `0` causes all new runs to be + // skipped. + MaxConcurrentRuns *int `json:"max_concurrent_runs,omitempty"` + // An optional maximum number of times to retry an unsuccessful run. A run is + // considered to be unsuccessful if it completes with the `FAILED` result_state + // or `INTERNAL_ERROR` `life_cycle_state`. The value `-1` means to retry + // indefinitely and the value `0` means to never retry. + MaxRetries *int `json:"max_retries,omitempty"` + // An optional minimal interval in milliseconds between the start of the failed + // run and the subsequent retry run. The default behavior is that unsuccessful + // runs are immediately retried. + MinRetryIntervalMillis *int `json:"min_retry_interval_millis,omitempty"` + // An optional name for the job. The maximum length is 4096 bytes in UTF-8 + // encoding. + Name *string `json:"name,omitempty"` + // Optional notification settings that are used when sending notifications to + // each of the `email_notifications` and `webhook_notifications` for this job. + NotificationSettings *NotificationSettings `json:"notification_settings,omitempty"` + // Job-level parameter definitions + Parameters []JobLevelParameter `json:"parameters,omitempty"` + // Path of the job parent folder in workspace file tree. If absent, the job + // doesn't have a workspace object. + ParentPath *string `json:"parent_path,omitempty"` + // The performance mode on a serverless job. This field determines the level of + // compute performance or cost-efficiency for the run. The performance target + // does not apply to tasks that run on Serverless GPU compute. + // + // * `PERFORMANCE_OPTIMIZED`: Prioritizes fast startup and execution times + // through rapid scaling and optimized cluster performance. * `STANDARD`: + // Enables cost-efficient execution of serverless workloads. * `COST_OPTIMIZED`: + // Enables lower job costs by optimizing compute for your selected target + // duration time. Must provide a duration target. + PerformanceTarget PerformanceTarget_PerformanceTarget `json:"performance_target,omitempty"` + // The queue settings of the job. + Queue *QueueSettings `json:"queue,omitempty"` + // An optional policy to specify whether to retry a job when it times out. The + // default behavior is to not retry on timeout. + RetryOnTimeout *bool `json:"retry_on_timeout,omitempty"` + // The user or service principal that the job runs as, if specified in the + // request. This field indicates the explicit configuration of `run_as` for the + // job. To find the value in all cases, explicit or implicit, use + // `run_as_user_name`. + RunAs *JobRunAs `json:"run_as,omitempty"` + // An optional periodic schedule for this job. The default behavior is that the + // job only runs when triggered by clicking “Run Now” in the Jobs UI or + // sending an API request to `runNow`. + Schedule *CronSchedule `json:"schedule,omitempty"` + // A map of tags associated with the job. These are forwarded to the cluster as + // cluster tags for jobs clusters, and are subject to the same limitations as + // cluster tags. A maximum of 25 tags can be added to the job. + Tags map[string]string `json:"tags,omitempty"` + // A list of task specifications to be executed by this job. It supports up to + // 1000 elements in write endpoints (:method:jobs/create, :method:jobs/reset, + // :method:jobs/update, :method:jobs/submit). Read endpoints return only 100 + // tasks. If more than 100 tasks are available, you can paginate through them + // using :method:jobs/get. Use the `next_page_token` field at the object root to + // determine if more results are available. + Tasks []TaskSettings `json:"tasks,omitempty"` + // An optional timeout applied to each run of this job. A value of `0` means no + // timeout. + TimeoutSeconds *int `json:"timeout_seconds,omitempty"` + // A configuration to trigger a run when certain conditions are met. The default + // behavior is that the job runs only when triggered by clicking “Run Now” + // in the Jobs UI or sending an API request to `runNow`. + Trigger *TriggerSettings `json:"trigger,omitempty"` + // List of triggers attached to this job. A run starts when any active trigger + // evaluates to true. Cannot be set in the same request as the legacy + // `schedule`, `trigger`, or `continuous` fields. Gated behind the "Multiple + // Triggers" feature preview. + Triggers []TriggerConfiguration `json:"triggers,omitempty"` + // 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_usage_policy_id` for the usage policy used by this + // workload. + UsagePolicyId *string `json:"usage_policy_id,omitempty"` + // A collection of system notification IDs to notify when runs of this job begin + // or complete. + WebhookNotifications *WebhookNotifications `json:"webhook_notifications,omitempty"` +} + +// The source of the job specification in the remote repository when the job is +// source controlled.. +type JobSource struct { + // Dirty state indicates the job is not fully synced with the job specification + // in the remote repository. + // + // Possible values are: * `NOT_SYNCED`: The job is not yet synced with the + // remote job specification. Import the remote job specification from UI to make + // the job fully synced. * `DISCONNECTED`: The job is temporary disconnected + // from the remote job specification and is allowed for live edit. Import the + // remote job specification again from UI to make the job fully synced. + DirtyState JobSource_DirtyState `json:"dirty_state,omitempty"` + ImportFromGitBranch *string `json:"import_from_git_branch,omitempty"` + // Path of the job YAML file that contains the job specification. + JobConfigPath *string `json:"job_config_path,omitempty"` +} + +type JobsHealthRule struct { + Metric JobsHealthMetric `json:"metric,omitempty"` + Op JobsHealthOperator `json:"op,omitempty"` + // Specifies the threshold value that the health metric should obey to satisfy + // the health rule. + Value *int64 `json:"value,omitempty"` +} + +// An optional set of health rules that can be defined for this job.. +type JobsHealthRules struct { + Rules []JobsHealthRule `json:"rules,omitempty"` +} + +type Library struct { + Cran *RCranLibrary `json:"cran,omitempty"` + Egg *string `json:"egg,omitempty"` + Jar *string `json:"jar,omitempty"` + Maven *MavenLibrary `json:"maven,omitempty"` + Pypi *PythonPyPiLibrary `json:"pypi,omitempty"` + Requirements *string `json:"requirements,omitempty"` + Whl *string `json:"whl,omitempty"` +} + +type ListJobComplianceForPolicy struct { + // Use this field to specify the maximum number of results to be returned by the + // server. The server may further constrain the maximum number of results + // returned in a single page. + PageSize *int `json:"page_size,omitempty"` + // A page token that can be used to navigate to the next page or previous page + // as returned by `next_page_token` or `prev_page_token`. + PageToken *string `json:"page_token,omitempty"` + // Canonical unique identifier for the cluster policy. + PolicyId *string `json:"policy_id,omitempty"` +} + +type ListJobComplianceForPolicy_JobCompliance struct { + // Whether this job is in compliance with the latest version of its policy. + IsCompliant *bool `json:"is_compliant,omitempty"` + // Canonical unique identifier for a job. + JobId *int64 `json:"job_id,omitempty"` + // An object containing key-value mappings representing the first 200 policy + // validation errors. The keys indicate the path where the policy validation + // error is occurring. An identifier for the job cluster is prepended to the + // path. The values indicate an error message describing the policy validation + // error. + Violations map[string]string `json:"violations,omitempty"` +} + +type ListJobComplianceResponse struct { + // A list of jobs and their policy compliance statuses. + Jobs []ListJobComplianceForPolicy_JobCompliance `json:"jobs,omitempty"` + // This field represents the pagination token to retrieve the next page of + // results. If this field is not in the response, it means no further results + // for the request. + NextPageToken *string `json:"next_page_token,omitempty"` + // This field represents the pagination token to retrieve the previous page of + // results. If this field is not in the response, it means no further results + // for the request. + PrevPageToken *string `json:"prev_page_token,omitempty"` +} + +// Lists all jobs.. +type ListJobsRequest struct { + // Whether to include task and cluster details in the response. Note that only + // the first 100 elements will be shown. Use :method:jobs/get to paginate + // through all tasks and clusters. + ExpandTasks *bool `json:"expand_tasks,omitempty"` + // The number of jobs to return. This value must be greater than 0 and less or + // equal to 100. The default value is 20. + Limit *int `json:"limit,omitempty"` + // A filter on the list based on the exact (case insensitive) job name. + Name *string `json:"name,omitempty"` + // The offset of the first job to return, relative to the most recently created + // job. Deprecated since June 2023. Use `page_token` to iterate through the + // pages instead. + Offset *int `json:"offset,omitempty"` + // Use `next_page_token` or `prev_page_token` returned from the previous request + // to list the next or previous page of jobs respectively. + PageToken *string `json:"page_token,omitempty"` +} + +// List of jobs was retrieved successfully.. +type ListJobsResponse struct { + // If true, additional jobs matching the provided filter are available for + // listing. + HasMore *bool `json:"has_more,omitempty"` + // The list of jobs. Only included in the response if there are jobs to list. + Jobs []BaseJob `json:"jobs,omitempty"` + // A token that can be used to list the next page of jobs (if applicable). + NextPageToken *string `json:"next_page_token,omitempty"` + // A token that can be used to list the previous page of jobs (if applicable). + PrevPageToken *string `json:"prev_page_token,omitempty"` +} + +// Lists runs from most recently started to least.. +type ListRunsRequest struct { + ActiveOnly *bool `json:"active_only,omitempty"` + CompletedOnly *bool `json:"completed_only,omitempty"` + // Whether to include task and cluster details in the response. Note that only + // the first 100 elements will be shown. Use :method:jobs/getrun to paginate + // through all tasks and clusters. + ExpandTasks *bool `json:"expand_tasks,omitempty"` + // The job for which to list runs. If omitted, the Jobs service lists runs from + // all jobs. + JobId *int64 `json:"job_id,omitempty"` + // The number of runs to return. This value must be greater than 0 and less than + // 25. The default value is 20. If a request specifies a limit of 0, the service + // instead uses the maximum limit. + Limit *int `json:"limit,omitempty"` + // The offset of the first run to return, relative to the most recent run. + // Deprecated since June 2023. Use `page_token` to iterate through the pages + // instead. + Offset *int `json:"offset,omitempty"` + // Use `next_page_token` or `prev_page_token` returned from the previous request + // to list the next or previous page of runs respectively. + PageToken *string `json:"page_token,omitempty"` + // The type of runs to return. For a description of run types, see + // :method:jobs/getRun. + RunType RunType `json:"run_type,omitempty"` + // Show runs that started _at or after_ this value. The value must be a UTC + // timestamp in milliseconds. Can be combined with _start_time_to_ to filter by + // a time range. + StartTimeFrom *int64 `json:"start_time_from,omitempty"` + // Show runs that started _at or before_ this value. The value must be a UTC + // timestamp in milliseconds. Can be combined with _start_time_from_ to filter + // by a time range. + StartTimeTo *int64 `json:"start_time_to,omitempty"` +} + +// List of runs was retrieved successfully.. +type ListRunsResponse struct { + // If true, additional runs matching the provided filter are available for + // listing. + HasMore *bool `json:"has_more,omitempty"` + // A token that can be used to list the next page of runs (if applicable). + NextPageToken *string `json:"next_page_token,omitempty"` + // A token that can be used to list the previous page of runs (if applicable). + PrevPageToken *string `json:"prev_page_token,omitempty"` + // A list of runs, from most recently started to least. Only included in the + // response if there are runs to list. + Runs []BaseRun `json:"runs,omitempty"` +} + +type LocalFileInfo struct { + // local file destination, e.g. `file:/my/local/file.sh` + Destination *string `json:"destination,omitempty"` +} + +type LogAnalyticsInfo struct { + LogAnalyticsPrimaryKey *string `json:"log_analytics_primary_key,omitempty"` + LogAnalyticsWorkspaceId *string `json:"log_analytics_workspace_id,omitempty"` +} + +// A recurring weekly time window during which platform-initiated maintenance is +// allowed to run for a continuous job.. +type MaintenanceWindow struct { + // The day of week on which maintenance is allowed to happen. This field is + // required. + DayOfWeek DayOfWeek `json:"day_of_week,omitempty"` + // An integer between 0 and 23 denoting the start hour for the maintenance + // window in the 24-hour day. Platform-initiated maintenance is triggered only + // within a one-hour window starting at this hour. This field is required. + StartHour *int `json:"start_hour,omitempty"` + // A Java timezone ID. The maintenance window is resolved with respect to this + // timezone. See [Java TimeZone] for details. This field is required. + // + // [Java TimeZone]: https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html + TimezoneId *string `json:"timezone_id,omitempty"` +} + +type MavenLibrary struct { + // Gradle-style maven coordinates. For example: "org.jsoup:jsoup:1.7.2". + Coordinates *string `json:"coordinates,omitempty"` + // List of dependences to exclude. For example: `["slf4j:slf4j", + // "*:hadoop-client"]`. + // + // Maven dependency exclusions: + // https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html. + Exclusions []string `json:"exclusions,omitempty"` + // Maven repo to install the Maven package from. If omitted, both Maven Central + // Repository and Spark Packages are searched. + Repo *string `json:"repo,omitempty"` +} + +type ModelTriggerConfiguration struct { + // Aliases of the model versions to monitor. Can only be used in conjunction + // with condition MODEL_ALIAS_SET. + Aliases []string `json:"aliases,omitempty"` + // The condition based on which to trigger a job run. + Condition ModelTriggerConfiguration_ModelTriggerCondition `json:"condition,omitempty"` + // If set, the trigger starts a run only after the specified amount of time has + // passed since the last time the trigger fired. The minimum allowed value is 60 + // seconds. + MinTimeBetweenTriggersSeconds *int `json:"min_time_between_triggers_seconds,omitempty"` + // Name of the securable to monitor ("mycatalog.myschema.mymodel" in the case of + // model-level triggers, "mycatalog.myschema" in the case of schema-level + // triggers) or empty in the case of metastore-level triggers. + SecurableName *string `json:"securable_name,omitempty"` + // If set, the trigger starts a run only after no model updates have occurred + // for the specified time and can be used to wait for a series of model updates + // before triggering a run. The minimum allowed value is 60 seconds. + WaitAfterLastChangeSeconds *int `json:"wait_after_last_change_seconds,omitempty"` +} + +// Runtime state for a model trigger. Currently empty because model triggers do +// not expose any trigger-specific runtime state.. +type ModelTriggerState struct { +} + +// Configuration for flexible node types, allowing fallback to alternate node +// types during cluster launch and upscale.. +type NodeTypeFlexibility struct { + // A list of node type IDs to use as fallbacks when the primary node type is + // unavailable. + AlternateNodeTypeIds []string `json:"alternate_node_type_ids,omitempty"` + // The AWS Context ID for EC2 Fleet. When set (non-empty), the value is passed + // to AWS CreateFleet API to create the EC2 Fleet. + AwsContextId *string `json:"aws_context_id,omitempty"` +} + +type NotebookTask struct { + // Base parameters to be used for each run of this job. If the run is initiated + // by a call to :method:jobs/run Now with parameters specified, the two + // parameters maps are merged. If the same key is specified in `base_parameters` + // and in `run-now`, the value from `run-now` is used. Use [Task parameter + // variables](/jobs.html#parameter-variables) to set parameters containing + // information about job runs. + // + // If the notebook takes a parameter that is not specified in the job’s + // `base_parameters` or the `run-now` override parameters, the default value + // from the notebook is used. + // + // Retrieve these parameters in a notebook using + // [dbutils.widgets.get](/dev-tools/databricks-utils.html#dbutils-widgets). + // + // The JSON representation of this field cannot exceed 1MB. + BaseParameters map[string]string `json:"base_parameters,omitempty"` + // The path of the notebook to be run in the workspace or remote + // repository. For notebooks stored in the workspace, the path must + // be absolute and begin with a slash. For notebooks stored in a remote + // repository, the path must be relative. This field is required. + NotebookPath *string `json:"notebook_path,omitempty"` + // Optional location type of the notebook. When set to `WORKSPACE`, the notebook + // will be retrieved from the local workspace. When set to `GIT`, + // the notebook will be retrieved from a Git repository defined in `git_source`. + // If the value is empty, the task will use `GIT` if `git_source` is defined and + // `WORKSPACE` otherwise. * `WORKSPACE`: Notebook is located in + // workspace. * `GIT`: Notebook is located in cloud Git provider. + Source Source `json:"source,omitempty"` + // Optional `warehouse_id` to run the notebook on a SQL warehouse. Classic SQL + // warehouses are NOT supported, please use serverless or pro SQL warehouses. + // + // Note that SQL warehouses only support SQL cells; if the notebook contains + // non-SQL cells, the run will fail. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type NotebookTask_NotebookOutput struct { + // The value passed to + // [dbutils.notebook.exit()](/notebooks/notebook-workflows.html#notebook-workflows-exit). + // restricts this API to return the first 5 MB of the value. For a + // larger result, your job can store the results in a cloud storage service. + // This field is absent if `dbutils.notebook.exit()` was never called. + Result *string `json:"result,omitempty"` + // Whether or not the result was truncated. + Truncated *bool `json:"truncated,omitempty"` +} + +type NotificationSettings struct { + // If true, do not send notifications to recipients specified in `on_start` for + // the retried runs and do not send notifications to recipients specified in + // `on_failure` until the last retry of the run. + AlertOnLastAttempt *bool `json:"alert_on_last_attempt,omitempty"` + // If true, do not send notifications to recipients specified in `on_failure` if + // the run is canceled. + NoAlertForCanceledRuns *bool `json:"no_alert_for_canceled_runs,omitempty"` + // If true, do not send notifications to recipients specified in `on_failure` if + // the run is skipped. + NoAlertForSkippedRuns *bool `json:"no_alert_for_skipped_runs,omitempty"` +} + +// Stores the catalog name, schema name, and the output schema expiration time +// for the clean room run.. +type OutputSchemaInfo struct { + CatalogName *string `json:"catalog_name,omitempty"` + // The expiration time for the output schema as a Unix timestamp in + // milliseconds. + ExpirationTime *int64 `json:"expiration_time,omitempty"` + SchemaName *string `json:"schema_name,omitempty"` +} + +// Per-trigger runtime state for the multi-trigger surface. Mirrors +// `TriggerConfiguration`'s trigger-type variants 1:1; each entry sets exactly +// one variant matching the corresponding trigger's type. Variants with no +// runtime state today (`schedule`, `model`) are emitted as empty messages.. +type PerTriggerState struct { + Continuous *ContinuousTriggerState `json:"continuous,omitempty"` + FileArrival *FileArrivalTriggerState `json:"file_arrival,omitempty"` + Model *ModelTriggerState `json:"model,omitempty"` + // Whether this trigger is paused or not. Mirrors the configured pause_status. + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + Periodic *PeriodicTriggerState `json:"periodic,omitempty"` + Schedule *ScheduleTriggerState `json:"schedule,omitempty"` + // State for SQL condition evaluation, can coexist with other trigger states. + SqlCondition *SqlConditionState `json:"sql_condition,omitempty"` + TableUpdate *TableTriggerState `json:"table_update,omitempty"` +} + +type PeriodicTriggerConfiguration struct { + // The interval at which the trigger should run. + Interval *int `json:"interval,omitempty"` + // The unit of time for the interval. + Unit PeriodicTriggerConfiguration_TimeUnit `json:"unit,omitempty"` +} + +type PeriodicTriggerState struct { + NextRunTime *int64 `json:"next_run_time,omitempty"` +} + +type PipelineParameters struct { + // If true, triggers a full refresh on the spark declarative pipeline. + FullRefresh *bool `json:"full_refresh,omitempty"` + // A list of tables to update with fullRefresh. + FullRefreshSelection []string `json:"full_refresh_selection,omitempty"` + // Flow names to selectively refresh. These are unioned with other selective + // refresh options (refresh_selection, full_refresh_selection) to determine the + // final set of flows to refresh. + RefreshFlowSelection []string `json:"refresh_flow_selection,omitempty"` + // A list of tables to update without fullRefresh. + RefreshSelection []string `json:"refresh_selection,omitempty"` + // A list of streaming flows to reset checkpoints without clearing data. + ResetCheckpointSelection []string `json:"reset_checkpoint_selection,omitempty"` +} + +type PipelineTask struct { + // If true, triggers a full refresh on the spark declarative pipeline. + FullRefresh *bool `json:"full_refresh,omitempty"` + // A list of tables to update with fullRefresh. + FullRefreshSelection []string `json:"full_refresh_selection,omitempty"` + // Key/value-map of parameters passed to the pipeline execution. Limited to 10k + // characters in total. + PipelineTaskParameters map[string]string `json:"parameters,omitempty"` + // The full name of the pipeline task to execute. + PipelineId *string `json:"pipeline_id,omitempty"` + // Flow names to selectively refresh. These are unioned with other selective + // refresh options (refresh_selection, full_refresh_selection) to determine the + // final set of flows to refresh. + RefreshFlowSelection []string `json:"refresh_flow_selection,omitempty"` + // A list of tables to update without fullRefresh. + RefreshSelection []string `json:"refresh_selection,omitempty"` + // A list of streaming flows to reset checkpoints without clearing data. + ResetCheckpointSelection []string `json:"reset_checkpoint_selection,omitempty"` +} + +type PowerBiModel struct { + // How the published Power BI model authenticates to + AuthenticationMethod AuthenticationMethod `json:"authentication_method,omitempty"` + // The name of the Power BI model + ModelName *string `json:"model_name,omitempty"` + // Whether to overwrite existing Power BI models + OverwriteExisting *bool `json:"overwrite_existing,omitempty"` + // The default storage mode of the Power BI model + StorageMode StorageMode `json:"storage_mode,omitempty"` + // The name of the Power BI workspace of the model + WorkspaceName *string `json:"workspace_name,omitempty"` +} + +type PowerBiTable struct { + // The catalog name in + Catalog *string `json:"catalog,omitempty"` + // The table name in + Name *string `json:"name,omitempty"` + // The schema name in + Schema *string `json:"schema,omitempty"` + // The Power BI storage mode of the table + StorageMode StorageMode `json:"storage_mode,omitempty"` +} + +type PowerBiTask struct { + // The resource name of the UC connection to authenticate from to + // Power BI + ConnectionResourceName *string `json:"connection_resource_name,omitempty"` + // The semantic model to update + PowerBiModel *PowerBiModel `json:"power_bi_model,omitempty"` + // Whether the model should be refreshed after the update + RefreshAfterUpdate *bool `json:"refresh_after_update,omitempty"` + // The tables to be exported to Power BI + Tables []PowerBiTable `json:"tables,omitempty"` + // The SQL warehouse ID to use as the Power BI data source + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type PythonOperatorTask struct { + // Fully qualified name of the main class or function. For example, + // `my_project.my_function` or `my_project.MyOperator`. + Main *string `json:"main,omitempty"` + // An ordered list of task parameters. TODO(JOBS-30885): Add limits for + // parameters. + Parameters []PythonOperatorTask_Parameter `json:"parameters,omitempty"` +} + +type PythonOperatorTask_Parameter struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +type PythonPyPiLibrary struct { + // The name of the pypi package to install. An optional exact version + // specification is also supported. Examples: "simplejson" and + // "simplejson==3.8.0". + Package *string `json:"package,omitempty"` + // The repository where the package can be found. If not specified, the default + // pip index is used. + Repo *string `json:"repo,omitempty"` +} + +type PythonWheelTask struct { + // Named entry point to use, if it does not exist in the metadata of the package + // it executes the function from the package directly using + // `$packageName.$entryPoint()` + EntryPoint *string `json:"entry_point,omitempty"` + // Command-line parameters passed to Python wheel task in the form of + // `["--name=task", "--data=dbfs:/path/to/data.json"]`. Leave it empty if + // `parameters` is not null. + NamedParameters map[string]string `json:"named_parameters,omitempty"` + // Name of the package to execute + PackageName *string `json:"package_name,omitempty"` + // Command-line parameters passed to Python wheel task. Leave it empty if + // `named_parameters` is not null. + Parameters []string `json:"parameters,omitempty"` +} + +type QueueDetails struct { + Code QueueDetailsCode_Code `json:"code,omitempty"` + // A descriptive message with the queuing details. This field is unstructured, + // and its exact format is subject to change. + Message *string `json:"message,omitempty"` +} + +type QueueSettings struct { + // If true, enable queueing for the job. This is a required field. + Enabled *bool `json:"enabled,omitempty"` +} + +type RCranLibrary struct { + // The name of the CRAN package to install. + Package *string `json:"package,omitempty"` + // The repository where the package can be found. If not specified, the default + // CRAN repo is used. + Repo *string `json:"repo,omitempty"` +} + +type Repair struct { + // The actual performance target used by the serverless run during execution. + // This can differ from the client-set performance target on the request + // depending on whether the performance mode is supported by the job type. + // + // * `PERFORMANCE_OPTIMIZED`: Prioritizes fast startup and execution times + // through rapid scaling and optimized cluster performance. * `STANDARD`: + // Enables cost-efficient execution of serverless workloads. * `COST_OPTIMIZED`: + // Enables lower job costs by optimizing compute for your selected target + // duration time. Must provide a duration target. + EffectivePerformanceTarget PerformanceTarget_PerformanceTarget `json:"effective_performance_target,omitempty"` + // The end time of the (repaired) run. + EndTime *int64 `json:"end_time,omitempty"` + // The ID of the repair. Only returned for the items that represent a repair in + // `repair_history`. + Id *int64 `json:"id,omitempty"` + // The start time of the (repaired) run. + StartTime *int64 `json:"start_time,omitempty"` + // Deprecated. Please use the `status` field instead. + State *RunState `json:"state,omitempty"` + Status *RunStatus `json:"status,omitempty"` + // The run IDs of the task runs that ran as part of this repair history item. + TaskRunIds []int64 `json:"task_run_ids,omitempty"` + // The repair history item type. Indicates whether a run is the original run or + // a repair run. + Type RepairType `json:"type,omitempty"` +} + +type RepairRunRequest struct { + // An array of commands to execute for jobs with the dbt task, for example + // `"dbt_commands": ["dbt deps", "dbt seed", "dbt deps", "dbt seed", "dbt run"]` + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + DbtCommands []string `json:"dbt_commands,omitempty"` + // A list of parameters for jobs with Spark JAR tasks, for example + // `"jar_params": ["john doe", "35"]`. The parameters are used to invoke the + // main function of the main class specified in the Spark JAR task. If not + // specified upon `run-now`, it defaults to an empty list. jar_params cannot be + // specified in conjunction with notebook_params. The JSON representation of + // this field (for example `{"jar_params":["john doe","35"]}`) cannot exceed + // 10,000 bytes. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + JarParams []string `json:"jar_params,omitempty"` + // Job-level parameters used in the run. for example `"param": "overriding_val"` + JobParameters map[string]string `json:"job_parameters,omitempty"` + // The ID of the latest repair. This parameter is not required when repairing a + // run for the first time, but must be provided on subsequent requests to repair + // the same run. + LatestRepairId *int64 `json:"latest_repair_id,omitempty"` + // A map from keys to values for jobs with notebook task, for example + // `"notebook_params": {"name": "john doe", "age": "35"}`. The map is passed to + // the notebook and is accessible through the + // [dbutils.widgets.get](/dev-tools/databricks-utils.html) function. + // + // If not specified upon `run-now`, the triggered run uses the job’s base + // parameters. + // + // notebook_params cannot be specified in conjunction with jar_params. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + // + // The JSON representation of this field (for example + // `{"notebook_params":{"name":"john doe","age":"35"}}`) cannot exceed 10,000 + // bytes. + NotebookParams map[string]string `json:"notebook_params,omitempty"` + // The performance mode on a serverless job. The performance target determines + // the level of compute performance or cost-efficiency for the run. This field + // overrides the performance target defined on the job level. + // + // * `PERFORMANCE_OPTIMIZED`: Prioritizes fast startup and execution times + // through rapid scaling and optimized cluster performance. * `STANDARD`: + // Enables cost-efficient execution of serverless workloads. * `COST_OPTIMIZED`: + // Enables lower job costs by optimizing compute for your selected target + // duration time. Must provide a duration target. + PerformanceTarget PerformanceTarget_PerformanceTarget `json:"performance_target,omitempty"` + // Controls whether the pipeline should perform a full refresh + PipelineParams *PipelineParameters `json:"pipeline_params,omitempty"` + PythonNamedParams map[string]string `json:"python_named_params,omitempty"` + // A list of parameters for jobs with Python tasks, for example + // `"python_params": ["john doe", "35"]`. The parameters are passed to Python + // file as command-line parameters. If specified upon `run-now`, it would + // overwrite the parameters specified in job setting. The JSON representation of + // this field (for example `{"python_params":["john doe","35"]}`) cannot exceed + // 10,000 bytes. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + // + // Important + // + // These parameters accept only Latin characters (ASCII character set). Using + // non-ASCII characters returns an error. Examples of invalid, non-ASCII + // characters are Chinese, Japanese kanjis, and emojis. + PythonParams []string `json:"python_params,omitempty"` + // If true, repair all failed tasks. Only one of `rerun_tasks` or + // `rerun_all_failed_tasks` can be used. + RerunAllFailedTasks *bool `json:"rerun_all_failed_tasks,omitempty"` + // If true, repair all tasks that depend on the tasks in `rerun_tasks`, even if + // they were previously successful. Can be also used in combination with + // `rerun_all_failed_tasks`. + RerunDependentTasks *bool `json:"rerun_dependent_tasks,omitempty"` + // The task keys of the task runs to repair. + RerunTasks []string `json:"rerun_tasks,omitempty"` + // The job run ID of the run to repair. The run must not be in progress. + RunId *int64 `json:"run_id,omitempty"` + // A list of parameters for jobs with spark submit task, for example + // `"spark_submit_params": ["--class", "org.apache.spark.examples.SparkPi"]`. + // The parameters are passed to spark-submit script as command-line parameters. + // If specified upon `run-now`, it would overwrite the parameters specified in + // job setting. The JSON representation of this field (for example + // `{"python_params":["john doe","35"]}`) cannot exceed 10,000 bytes. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + // + // Important + // + // These parameters accept only Latin characters (ASCII character set). Using + // non-ASCII characters returns an error. Examples of invalid, non-ASCII + // characters are Chinese, Japanese kanjis, and emojis. + SparkSubmitParams []string `json:"spark_submit_params,omitempty"` + // A map from keys to values for jobs with SQL task, for example `"sql_params": + // {"name": "john doe", "age": "35"}`. The SQL alert task does not support + // custom parameters. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + SqlParams map[string]string `json:"sql_params,omitempty"` +} + +// Run repair was initiated.. +type RepairRunResponse struct { + // The ID of the repair. Must be provided in subsequent repairs using the + // `latest_repair_id` field to ensure sequential repairs. + RepairId *int64 `json:"repair_id,omitempty"` +} + +type ResetJobRequest struct { + // The canonical identifier of the job to reset. This field is required. + JobId *int64 `json:"job_id,omitempty"` + // The new settings of the job. These settings completely replace the old + // settings. + // + // Changes to the field `JobBaseSettings.timeout_seconds` are applied to active + // runs. Changes to other fields are applied to future runs only. + NewSettings *JobSettings `json:"new_settings,omitempty"` +} + +type ResolvedValues struct { + AiRuntimeTask *ResolvedValues_AiRuntimeTaskResolvedValues `json:"ai_runtime_task,omitempty"` + ConditionTask *ResolvedValues_ConditionTaskResolvedValues `json:"condition_task,omitempty"` + DbtTask *ResolvedValues_DbtTaskResolvedValues `json:"dbt_task,omitempty"` + NotebookTask *ResolvedValues_NotebookTaskResolvedValues `json:"notebook_task,omitempty"` + PipelineTask *ResolvedValues_PipelineTaskResolvedValues `json:"pipeline_task,omitempty"` + PythonWheelTask *ResolvedValues_PythonWheelTaskResolvedValues `json:"python_wheel_task,omitempty"` + RunJobTask *ResolvedValues_RunJobTaskResolvedValues `json:"run_job_task,omitempty"` + SimulationTask *ResolvedValues_SimulationTaskResolvedValues `json:"simulation_task,omitempty"` + SparkJarTask *ResolvedValues_SparkJarTaskResolvedValues `json:"spark_jar_task,omitempty"` + SparkPythonTask *ResolvedValues_SparkPythonTaskResolvedValues `json:"spark_python_task,omitempty"` + SparkSubmitTask *ResolvedValues_SparkSubmitTaskResolvedValues `json:"spark_submit_task,omitempty"` + SqlTask *ResolvedValues_SqlTaskResolvedValues `json:"sql_task,omitempty"` +} + +// Resolved values for an AiRuntimeTask after dynamic-value substitution, so +// Jobs can expand `{{tasks..values.}}` references before submission.. +type ResolvedValues_AiRuntimeTaskResolvedValues struct { +} + +type ResolvedValues_ConditionTaskResolvedValues struct { + Left *string `json:"left,omitempty"` + Right *string `json:"right,omitempty"` +} + +type ResolvedValues_DbtTaskResolvedValues struct { + Commands []string `json:"commands,omitempty"` +} + +type ResolvedValues_NotebookTaskResolvedValues struct { + BaseParameters map[string]string `json:"base_parameters,omitempty"` +} + +type ResolvedValues_PipelineTaskResolvedValues struct { + // Key/value-map of parameters passed to the pipeline execution. Limited to 10k + // characters in total. + PipelineTaskParameters map[string]string `json:"parameters,omitempty"` +} + +type ResolvedValues_PythonWheelTaskResolvedValues struct { + NamedParameters map[string]string `json:"named_parameters,omitempty"` + Parameters []string `json:"parameters,omitempty"` +} + +type ResolvedValues_RunJobTaskResolvedValues struct { + JobParameters map[string]string `json:"job_parameters,omitempty"` + Parameters map[string]string `json:"parameters,omitempty"` +} + +type ResolvedValues_SimulationTaskResolvedValues struct { + Parameters map[string]string `json:"parameters,omitempty"` +} + +type ResolvedValues_SparkJarTaskResolvedValues struct { + Parameters []string `json:"parameters,omitempty"` +} + +type ResolvedValues_SparkPythonTaskResolvedValues struct { +} + +type ResolvedValues_SparkSubmitTaskResolvedValues struct { +} + +type ResolvedValues_SqlTaskResolvedValues struct { + Parameters map[string]string `json:"parameters,omitempty"` +} + +type Run struct { + // The sequence number of this run attempt for a triggered job run. The initial + // attempt of a run has an attempt_number of 0. If the initial run attempt + // fails, and the job has a retry policy (`max_retries` > 0), subsequent runs + // are created with an `original_attempt_run_id` of the original attempt’s ID + // and an incrementing `attempt_number`. Runs are retried only until they + // succeed, and the maximum `attempt_number` is the same as the `max_retries` + // value for the job. + AttemptNumber *int `json:"attempt_number,omitempty"` + // The time in milliseconds it took to terminate the cluster and clean up any + // associated artifacts. The duration of a task run is the sum of the + // `setup_duration`, `execution_duration`, and the `cleanup_duration`. The + // `cleanup_duration` field is set to 0 for multitask job runs. The total + // duration of a multitask job run is the value of the `run_duration` field. + CleanupDuration *int64 `json:"cleanup_duration,omitempty"` + // The cluster used for this run. If the run is specified to use a new cluster, + // this field is set once the Jobs service has requested a cluster for the run. + ClusterInstance *ClusterInstance `json:"cluster_instance,omitempty"` + // A snapshot of the job’s cluster specification when this run was created. + ClusterSpec *ClusterSpec `json:"cluster_spec,omitempty"` + // The creator user name. This field won’t be included in the response if the + // user has already been deleted. + CreatorUserName *string `json:"creator_user_name,omitempty"` + // ID of the deployment that produced the job when this run was created. Used to + // look up deployment metadata from the Deployment Metadata service. Only set + // for job runs of jobs with a `BUNDLE` deployment. + DeploymentId *string `json:"deployment_id,omitempty"` + // Description of the run + Description *string `json:"description,omitempty"` + // The actual performance target used by the serverless run during execution. + // This can differ from the client-set performance target on the request + // depending on whether the performance mode is supported by the job type. + // + // * `PERFORMANCE_OPTIMIZED`: Prioritizes fast startup and execution times + // through rapid scaling and optimized cluster performance. * `STANDARD`: + // Enables cost-efficient execution of serverless workloads. * `COST_OPTIMIZED`: + // Enables lower job costs by optimizing compute for your selected target + // duration time. Must provide a duration target. + EffectivePerformanceTarget PerformanceTarget_PerformanceTarget `json:"effective_performance_target,omitempty"` + // The id of the usage policy used by this run for cost attribution purposes. + EffectiveUsagePolicyId *string `json:"effective_usage_policy_id,omitempty"` + // The time at which this run ended in epoch milliseconds (milliseconds since + // 1/1/1970 UTC). This field is set to 0 if the job is still running. + EndTime *int64 `json:"end_time,omitempty"` + // Snapshot of `JobSettings.environment_variables` as it was at run launch — + // the full list of named environment-variable entries the job defined. To find + // which entry a given task ran with, look at + // `RunTaskSettings.environment_variables_key`. + EnvironmentVariables []JobEnvironmentVariables `json:"environment_variables,omitempty"` + // The time in milliseconds it took to execute the commands in the JAR or + // notebook until they completed, failed, timed out, were cancelled, or + // encountered an unexpected error. The duration of a task run is the sum of the + // `setup_duration`, `execution_duration`, and the `cleanup_duration`. The + // `execution_duration` field is set to 0 for multitask job runs. The total + // duration of a multitask job run is the value of the `run_duration` field. + ExecutionDuration *int64 `json:"execution_duration,omitempty"` + // An optional specification for a remote Git repository containing the source + // code used by tasks. Version-controlled source code is supported by notebook, + // dbt, Python script, and SQL File tasks. + // + // If `git_source` is set, these tasks retrieve the file from the remote + // repository by default. However, this behavior can be overridden by setting + // `source` to `WORKSPACE` on the task. + // + // Note: dbt and SQL File tasks support only version-controlled sources. If dbt + // or SQL File tasks are used, `git_source` must be defined on the job. + GitSource *GitSource `json:"git_source,omitempty"` + // Indicates if the run has more array properties (`tasks`, `job_clusters`) that + // are not shown. They can be accessed via :method:jobs/getrun endpoint. It is + // only relevant for API 2.2 :method:jobs/listruns requests with + // `expand_tasks=true`. + HasMore *bool `json:"has_more,omitempty"` + // A list of job cluster specifications that can be shared and reused by tasks + // of this job. Libraries cannot be declared in a shared job cluster. You must + // declare dependent libraries in task settings. If more than 100 job clusters + // are available, you can paginate through them using :method:jobs/getrun. + JobClusters []JobCluster `json:"job_clusters,omitempty"` + // The canonical identifier of the job that contains this run. + JobId *int64 `json:"job_id,omitempty"` + // Job-level parameters used in the run + JobParameters []Run_JobLevelParameters `json:"job_parameters,omitempty"` + // ID of the job run that this run belongs to. For legacy and single-task job + // runs the field is populated with the job run ID. For task runs, the field is + // populated with the ID of the job run that the task run belongs to. + JobRunId *int64 `json:"job_run_id,omitempty"` + // A unique identifier for this job run. This is set to the same value as + // `run_id`. + NumberInJob *int64 `json:"number_in_job,omitempty"` + // If this run is a retry of a prior run attempt, this field contains the run_id + // of the original attempt; otherwise, it is the same as the run_id. + OriginalAttemptRunId *int64 `json:"original_attempt_run_id,omitempty"` + // The parameters used for this run. + OverridingParameters *RunParameters `json:"overriding_parameters,omitempty"` + // The time in milliseconds that the run has spent in the queue. + QueueDuration *int64 `json:"queue_duration,omitempty"` + // The repair history of the run. + RepairHistory []Repair `json:"repair_history,omitempty"` + // The time in milliseconds it took the job run and all of its repairs to + // finish. + RunDuration *int64 `json:"run_duration,omitempty"` + // The canonical identifier of the run. This ID is unique across all runs of all + // jobs. + RunId *int64 `json:"run_id,omitempty"` + // An optional name for the run. The maximum length is 4096 bytes in UTF-8 + // encoding. + RunName *string `json:"run_name,omitempty"` + // The URL to the detail page of the run. + RunPageUrl *string `json:"run_page_url,omitempty"` + RunType RunType `json:"run_type,omitempty"` + // The cron schedule that triggered this run if it was triggered by the periodic + // scheduler. + Schedule *CronSchedule `json:"schedule,omitempty"` + // The time in milliseconds it took to set up the cluster. For runs that run on + // new clusters this is the cluster creation time, for runs that run on existing + // clusters this time should be very short. The duration of a task run is the + // sum of the `setup_duration`, `execution_duration`, and the + // `cleanup_duration`. The `setup_duration` field is set to 0 for multitask job + // runs. The total duration of a multitask job run is the value of the + // `run_duration` field. + SetupDuration *int64 `json:"setup_duration,omitempty"` + // The time at which this run was started in epoch milliseconds (milliseconds + // since 1/1/1970 UTC). This may not be the time when the job task starts + // executing, for example, if the job is scheduled to run on a new cluster, this + // is the time the cluster creation call is issued. + StartTime *int64 `json:"start_time,omitempty"` + // Deprecated. Please use the `status` field instead. + State *RunState `json:"state,omitempty"` + Status *RunStatus `json:"status,omitempty"` + // The list of tasks performed by the run. Each task has its own `run_id` which + // you can use to call `JobsGetOutput` to retrieve the run results. If more than + // 100 tasks are available, you can paginate through them using + // :method:jobs/getrun. Use the `next_page_token` field at the object root to + // determine if more results are available. + Tasks []RunTask `json:"tasks,omitempty"` + Trigger TriggerType `json:"trigger,omitempty"` + TriggerInfo *RunTriggerInfo `json:"trigger_info,omitempty"` + // ID of the deployment version that produced the job when this run was created. + // Identifies a specific snapshot of the deployment in the Deployment Metadata + // service. Only set for job runs of jobs with a `BUNDLE` deployment. + VersionId *string `json:"version_id,omitempty"` +} + +type Run_JobLevelParameters struct { + // The optional default value of the parameter + Default *string `json:"default,omitempty"` + // The name of the parameter + Name *string `json:"name,omitempty"` + // The value used in the run + Value *string `json:"value,omitempty"` +} + +type RunJobTask struct { + // An array of commands to execute for jobs with the dbt task, for example + // `"dbt_commands": ["dbt deps", "dbt seed", "dbt deps", "dbt seed", "dbt run"]` + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + DbtCommands []string `json:"dbt_commands,omitempty"` + // A list of parameters for jobs with Spark JAR tasks, for example + // `"jar_params": ["john doe", "35"]`. The parameters are used to invoke the + // main function of the main class specified in the Spark JAR task. If not + // specified upon `run-now`, it defaults to an empty list. jar_params cannot be + // specified in conjunction with notebook_params. The JSON representation of + // this field (for example `{"jar_params":["john doe","35"]}`) cannot exceed + // 10,000 bytes. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + JarParams []string `json:"jar_params,omitempty"` + // ID of the job to trigger. + JobId *int64 `json:"job_id,omitempty"` + // Job-level parameters used to trigger the job. + JobParameters map[string]string `json:"job_parameters,omitempty"` + // A map from keys to values for jobs with notebook task, for example + // `"notebook_params": {"name": "john doe", "age": "35"}`. The map is passed to + // the notebook and is accessible through the + // [dbutils.widgets.get](/dev-tools/databricks-utils.html) function. + // + // If not specified upon `run-now`, the triggered run uses the job’s base + // parameters. + // + // notebook_params cannot be specified in conjunction with jar_params. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + // + // The JSON representation of this field (for example + // `{"notebook_params":{"name":"john doe","age":"35"}}`) cannot exceed 10,000 + // bytes. + NotebookParams map[string]string `json:"notebook_params,omitempty"` + // Controls whether the pipeline should perform a full refresh + PipelineParams *PipelineParameters `json:"pipeline_params,omitempty"` + PythonNamedParams map[string]string `json:"python_named_params,omitempty"` + // A list of parameters for jobs with Python tasks, for example + // `"python_params": ["john doe", "35"]`. The parameters are passed to Python + // file as command-line parameters. If specified upon `run-now`, it would + // overwrite the parameters specified in job setting. The JSON representation of + // this field (for example `{"python_params":["john doe","35"]}`) cannot exceed + // 10,000 bytes. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + // + // Important + // + // These parameters accept only Latin characters (ASCII character set). Using + // non-ASCII characters returns an error. Examples of invalid, non-ASCII + // characters are Chinese, Japanese kanjis, and emojis. + PythonParams []string `json:"python_params,omitempty"` + // A list of parameters for jobs with spark submit task, for example + // `"spark_submit_params": ["--class", "org.apache.spark.examples.SparkPi"]`. + // The parameters are passed to spark-submit script as command-line parameters. + // If specified upon `run-now`, it would overwrite the parameters specified in + // job setting. The JSON representation of this field (for example + // `{"python_params":["john doe","35"]}`) cannot exceed 10,000 bytes. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + // + // Important + // + // These parameters accept only Latin characters (ASCII character set). Using + // non-ASCII characters returns an error. Examples of invalid, non-ASCII + // characters are Chinese, Japanese kanjis, and emojis. + SparkSubmitParams []string `json:"spark_submit_params,omitempty"` + // A map from keys to values for jobs with SQL task, for example `"sql_params": + // {"name": "john doe", "age": "35"}`. The SQL alert task does not support + // custom parameters. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + SqlParams map[string]string `json:"sql_params,omitempty"` +} + +type RunJobTask_RunJobTaskOutput struct { + // The run id of the triggered job run + RunId *int64 `json:"run_id,omitempty"` +} + +type RunNowRequest struct { + // An array of commands to execute for jobs with the dbt task, for example + // `"dbt_commands": ["dbt deps", "dbt seed", "dbt deps", "dbt seed", "dbt run"]` + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + DbtCommands []string `json:"dbt_commands,omitempty"` + // An optional token to guarantee the idempotency of job run requests. If a run + // with the provided token already exists, the request does not create a new run + // but returns the ID of the existing run instead. If a run with the provided + // token is deleted, an error is returned. + // + // If you specify the idempotency token, upon failure you can retry until the + // request succeeds. guarantees that exactly one run is launched + // with that idempotency token. + // + // This token must have at most 64 characters. + IdempotencyToken *string `json:"idempotency_token,omitempty"` + // A list of parameters for jobs with Spark JAR tasks, for example + // `"jar_params": ["john doe", "35"]`. The parameters are used to invoke the + // main function of the main class specified in the Spark JAR task. If not + // specified upon `run-now`, it defaults to an empty list. jar_params cannot be + // specified in conjunction with notebook_params. The JSON representation of + // this field (for example `{"jar_params":["john doe","35"]}`) cannot exceed + // 10,000 bytes. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + JarParams []string `json:"jar_params,omitempty"` + // The ID of the job to be executed + JobId *int64 `json:"job_id,omitempty"` + // Job-level parameters used in the run. for example `"param": "overriding_val"` + JobParameters map[string]string `json:"job_parameters,omitempty"` + // A map from keys to values for jobs with notebook task, for example + // `"notebook_params": {"name": "john doe", "age": "35"}`. The map is passed to + // the notebook and is accessible through the + // [dbutils.widgets.get](/dev-tools/databricks-utils.html) function. + // + // If not specified upon `run-now`, the triggered run uses the job’s base + // parameters. + // + // notebook_params cannot be specified in conjunction with jar_params. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + // + // The JSON representation of this field (for example + // `{"notebook_params":{"name":"john doe","age":"35"}}`) cannot exceed 10,000 + // bytes. + NotebookParams map[string]string `json:"notebook_params,omitempty"` + // A list of task keys to run inside of the job. If this field is not provided, + // all tasks in the job will be run. + // + // Prefix a task key with `+` to also run its upstream tasks, or suffix it with + // `+` to also run its downstream tasks. For example, `+my_task` runs `my_task` + // and everything upstream of it, `my_task+` runs `my_task` and everything + // downstream of it, and `+my_task+` runs both. A task key with no `+` runs only + // that task. + Only []string `json:"only,omitempty"` + // The performance mode on a serverless job. The performance target determines + // the level of compute performance or cost-efficiency for the run. This field + // overrides the performance target defined on the job level. + // + // * `PERFORMANCE_OPTIMIZED`: Prioritizes fast startup and execution times + // through rapid scaling and optimized cluster performance. * `STANDARD`: + // Enables cost-efficient execution of serverless workloads. * `COST_OPTIMIZED`: + // Enables lower job costs by optimizing compute for your selected target + // duration time. Must provide a duration target. + PerformanceTarget PerformanceTarget_PerformanceTarget `json:"performance_target,omitempty"` + // Controls whether the pipeline should perform a full refresh + PipelineParams *PipelineParameters `json:"pipeline_params,omitempty"` + PythonNamedParams map[string]string `json:"python_named_params,omitempty"` + // A list of parameters for jobs with Python tasks, for example + // `"python_params": ["john doe", "35"]`. The parameters are passed to Python + // file as command-line parameters. If specified upon `run-now`, it would + // overwrite the parameters specified in job setting. The JSON representation of + // this field (for example `{"python_params":["john doe","35"]}`) cannot exceed + // 10,000 bytes. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + // + // Important + // + // These parameters accept only Latin characters (ASCII character set). Using + // non-ASCII characters returns an error. Examples of invalid, non-ASCII + // characters are Chinese, Japanese kanjis, and emojis. + PythonParams []string `json:"python_params,omitempty"` + // The queue settings of the run. + Queue *QueueSettings `json:"queue,omitempty"` + // A list of parameters for jobs with spark submit task, for example + // `"spark_submit_params": ["--class", "org.apache.spark.examples.SparkPi"]`. + // The parameters are passed to spark-submit script as command-line parameters. + // If specified upon `run-now`, it would overwrite the parameters specified in + // job setting. The JSON representation of this field (for example + // `{"python_params":["john doe","35"]}`) cannot exceed 10,000 bytes. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + // + // Important + // + // These parameters accept only Latin characters (ASCII character set). Using + // non-ASCII characters returns an error. Examples of invalid, non-ASCII + // characters are Chinese, Japanese kanjis, and emojis. + SparkSubmitParams []string `json:"spark_submit_params,omitempty"` + // A map from keys to values for jobs with SQL task, for example `"sql_params": + // {"name": "john doe", "age": "35"}`. The SQL alert task does not support + // custom parameters. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + SqlParams map[string]string `json:"sql_params,omitempty"` +} + +// Run was started successfully.. +type RunNowResponse struct { + // A unique identifier for this job run. This is set to the same value as + // `run_id`. + NumberInJob *int64 `json:"number_in_job,omitempty"` + // The globally unique ID of the newly triggered run. + RunId *int64 `json:"run_id,omitempty"` +} + +type RunParameters struct { + // An array of commands to execute for jobs with the dbt task, for example + // `"dbt_commands": ["dbt deps", "dbt seed", "dbt deps", "dbt seed", "dbt run"]` + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + DbtCommands []string `json:"dbt_commands,omitempty"` + // A list of parameters for jobs with Spark JAR tasks, for example + // `"jar_params": ["john doe", "35"]`. The parameters are used to invoke the + // main function of the main class specified in the Spark JAR task. If not + // specified upon `run-now`, it defaults to an empty list. jar_params cannot be + // specified in conjunction with notebook_params. The JSON representation of + // this field (for example `{"jar_params":["john doe","35"]}`) cannot exceed + // 10,000 bytes. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + JarParams []string `json:"jar_params,omitempty"` + // A map from keys to values for jobs with notebook task, for example + // `"notebook_params": {"name": "john doe", "age": "35"}`. The map is passed to + // the notebook and is accessible through the + // [dbutils.widgets.get](/dev-tools/databricks-utils.html) function. + // + // If not specified upon `run-now`, the triggered run uses the job’s base + // parameters. + // + // notebook_params cannot be specified in conjunction with jar_params. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + // + // The JSON representation of this field (for example + // `{"notebook_params":{"name":"john doe","age":"35"}}`) cannot exceed 10,000 + // bytes. + NotebookParams map[string]string `json:"notebook_params,omitempty"` + // Controls whether the pipeline should perform a full refresh + PipelineParams *PipelineParameters `json:"pipeline_params,omitempty"` + PythonNamedParams map[string]string `json:"python_named_params,omitempty"` + // A list of parameters for jobs with Python tasks, for example + // `"python_params": ["john doe", "35"]`. The parameters are passed to Python + // file as command-line parameters. If specified upon `run-now`, it would + // overwrite the parameters specified in job setting. The JSON representation of + // this field (for example `{"python_params":["john doe","35"]}`) cannot exceed + // 10,000 bytes. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + // + // Important + // + // These parameters accept only Latin characters (ASCII character set). Using + // non-ASCII characters returns an error. Examples of invalid, non-ASCII + // characters are Chinese, Japanese kanjis, and emojis. + PythonParams []string `json:"python_params,omitempty"` + // A list of parameters for jobs with spark submit task, for example + // `"spark_submit_params": ["--class", "org.apache.spark.examples.SparkPi"]`. + // The parameters are passed to spark-submit script as command-line parameters. + // If specified upon `run-now`, it would overwrite the parameters specified in + // job setting. The JSON representation of this field (for example + // `{"python_params":["john doe","35"]}`) cannot exceed 10,000 bytes. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + // + // Important + // + // These parameters accept only Latin characters (ASCII character set). Using + // non-ASCII characters returns an error. Examples of invalid, non-ASCII + // characters are Chinese, Japanese kanjis, and emojis. + SparkSubmitParams []string `json:"spark_submit_params,omitempty"` + // A map from keys to values for jobs with SQL task, for example `"sql_params": + // {"name": "john doe", "age": "35"}`. The SQL alert task does not support + // custom parameters. + // + // ⚠ **Deprecation note** Use [job + // parameters](/jobs/job-parameters.html#job-parameter-pushdown) to pass + // information down to tasks. + SqlParams map[string]string `json:"sql_params,omitempty"` +} + +// The current state of the run.. +type RunState struct { + // A value indicating the run's current lifecycle state. This field is always + // available in the response. Note: Additional states might be introduced in + // future releases. + LifeCycleState RunLifeCycleState_RunLifeCycleState `json:"life_cycle_state,omitempty"` + // The reason indicating why the run was queued. + QueueReason *string `json:"queue_reason,omitempty"` + // A value indicating the run's result. This field is only available for + // terminal lifecycle states. Note: Additional states might be introduced in + // future releases. + ResultState RunResultState_RunResultState `json:"result_state,omitempty"` + // A descriptive message for the current state. This field is unstructured, and + // its exact format is subject to change. + StateMessage *string `json:"state_message,omitempty"` + // A value indicating whether a run was canceled manually by a user or by the + // scheduler because the run timed out. + UserCancelledOrTimedout *bool `json:"user_cancelled_or_timedout,omitempty"` +} + +// The current status of the run. +type RunStatus struct { + // If the run was queued, details about the reason for queuing the run. + QueueDetails *QueueDetails `json:"queue_details,omitempty"` + State RunLifecycleStateV2_State `json:"state,omitempty"` + // If the run is in a TERMINATING or TERMINATED state, details about the reason + // for terminating the run. + TerminationDetails *TerminationDetails `json:"termination_details,omitempty"` +} + +// Used when outputting a child run, in GetRun or ListRuns.. +type RunTask struct { + AiRuntimeTask *AiRuntimeTask `json:"ai_runtime_task,omitempty"` + AlertTask *AlertTask `json:"alert_task,omitempty"` + // The sequence number of this run attempt for a triggered job run. The initial + // attempt of a run has an attempt_number of 0. If the initial run attempt + // fails, and the job has a retry policy (`max_retries` > 0), subsequent runs + // are created with an `original_attempt_run_id` of the original attempt’s ID + // and an incrementing `attempt_number`. Runs are retried only until they + // succeed, and the maximum `attempt_number` is the same as the `max_retries` + // value for the job. + AttemptNumber *int `json:"attempt_number,omitempty"` + CleanRoomsNotebookTask *CleanRoomsNotebookTask `json:"clean_rooms_notebook_task,omitempty"` + // The time in milliseconds it took to terminate the cluster and clean up any + // associated artifacts. The duration of a task run is the sum of the + // `setup_duration`, `execution_duration`, and the `cleanup_duration`. The + // `cleanup_duration` field is set to 0 for multitask job runs. The total + // duration of a multitask job run is the value of the `run_duration` field. + CleanupDuration *int64 `json:"cleanup_duration,omitempty"` + // The cluster used for this run. If the run is specified to use a new cluster, + // this field is set once the Jobs service has requested a cluster for the run. + ClusterInstance *ClusterInstance `json:"cluster_instance,omitempty"` + // Task level compute configuration. + Compute *Compute `json:"compute,omitempty"` + ConditionTask *ConditionTask `json:"condition_task,omitempty"` + DashboardTask *DashboardTask `json:"dashboard_task,omitempty"` + DbtCloudTask *DbtCloudTask `json:"dbt_cloud_task,omitempty"` + DbtPlatformTask *DbtPlatformTask `json:"dbt_platform_task,omitempty"` + DbtTask *DbtTask `json:"dbt_task,omitempty"` + // An optional array of objects specifying the dependency graph of the task. All + // tasks specified in this field must complete successfully before executing + // this task. The key is `task_key`, and the value is the name assigned to the + // dependent task. + DependsOn []TaskDependency `json:"depends_on,omitempty"` + // An optional description for this task. + Description *string `json:"description,omitempty"` + // An option to disable auto optimization in serverless + DisableAutoOptimization *bool `json:"disable_auto_optimization,omitempty"` + // An optional flag to disable the task. If set to true, the task will not run + // even if it is part of a job. + Disabled *bool `json:"disabled,omitempty"` + // The actual performance target used by the serverless run during execution. + // This can differ from the client-set performance target on the request + // depending on whether the performance mode is supported by the job type. + // + // * `PERFORMANCE_OPTIMIZED`: Prioritizes fast startup and execution times + // through rapid scaling and optimized cluster performance. * `STANDARD`: + // Enables cost-efficient execution of serverless workloads. * `COST_OPTIMIZED`: + // Enables lower job costs by optimizing compute for your selected target + // duration time. Must provide a duration target. + EffectivePerformanceTarget PerformanceTarget_PerformanceTarget `json:"effective_performance_target,omitempty"` + // An optional set of email addresses notified when the task run begins or + // completes. The default behavior is to not send any emails. + EmailNotifications *JobEmailNotifications `json:"email_notifications,omitempty"` + // The time at which this run ended in epoch milliseconds (milliseconds since + // 1/1/1970 UTC). This field is set to 0 if the job is still running. + EndTime *int64 `json:"end_time,omitempty"` + EnvironmentKey *string `json:"environment_key,omitempty"` + // Reference to a `JobEnvironmentVariables` entry defined in + // `RunSettings.environment_variables` for one-time runs or preserved in + // `Run.environment_variables` for run snapshots. The selected entry's variables + // are applied to this task at execution time. This field supports serverless + // tasks using environment version 5 or later. + EnvironmentVariablesKey *string `json:"environment_variables_key,omitempty"` + // The time in milliseconds it took to execute the commands in the JAR or + // notebook until they completed, failed, timed out, were cancelled, or + // encountered an unexpected error. The duration of a task run is the sum of the + // `setup_duration`, `execution_duration`, and the `cleanup_duration`. The + // `execution_duration` field is set to 0 for multitask job runs. The total + // duration of a multitask job run is the value of the `run_duration` field. + ExecutionDuration *int64 `json:"execution_duration,omitempty"` + ExistingClusterId *string `json:"existing_cluster_id,omitempty"` + ForEachTask *ForEachTask `json:"for_each_task,omitempty"` + GenAiComputeTask *GenAiComputeTask `json:"gen_ai_compute_task,omitempty"` + // An optional specification for a remote Git repository containing the source + // code used by tasks. Version-controlled source code is supported by notebook, + // dbt, Python script, and SQL File tasks. If `git_source` is set, these tasks + // retrieve the file from the remote repository by default. However, this + // behavior can be overridden by setting `source` to `WORKSPACE` on the task. + // Note: dbt and SQL File tasks support only version-controlled sources. If dbt + // or SQL File tasks are used, `git_source` must be defined on the job. + GitSource *GitSource `json:"git_source,omitempty"` + Health *JobsHealthRules `json:"health,omitempty"` + JobClusterKey *string `json:"job_cluster_key,omitempty"` + // An optional list of libraries to be installed on the cluster. The default + // value is an empty list. + Libraries []Library `json:"libraries,omitempty"` + // An optional maximum number of times to retry an unsuccessful run. A run is + // considered to be unsuccessful if it completes with the `FAILED` result_state + // or `INTERNAL_ERROR` `life_cycle_state`. The value `-1` means to retry + // indefinitely and the value `0` means to never retry. + MaxRetries *int `json:"max_retries,omitempty"` + // An optional minimal interval in milliseconds between the start of the failed + // run and the subsequent retry run. The default behavior is that unsuccessful + // runs are immediately retried. + MinRetryIntervalMillis *int `json:"min_retry_interval_millis,omitempty"` + NewCluster *ClusterSpec_NewCluster `json:"new_cluster,omitempty"` + NotebookTask *NotebookTask `json:"notebook_task,omitempty"` + // Optional notification settings that are used when sending notifications to + // each of the `email_notifications` and `webhook_notifications` for this task + // run. + NotificationSettings *NotificationSettings `json:"notification_settings,omitempty"` + PipelineTask *PipelineTask `json:"pipeline_task,omitempty"` + PowerBiTask *PowerBiTask `json:"power_bi_task,omitempty"` + PythonOperatorTask *PythonOperatorTask `json:"python_operator_task,omitempty"` + PythonWheelTask *PythonWheelTask `json:"python_wheel_task,omitempty"` + // The time in milliseconds that the run has spent in the queue. + QueueDuration *int64 `json:"queue_duration,omitempty"` + // Parameter values including resolved references + ResolvedValues *ResolvedValues `json:"resolved_values,omitempty"` + // An optional policy to specify whether to retry a job when it times out. The + // default behavior is to not retry on timeout. + RetryOnTimeout *bool `json:"retry_on_timeout,omitempty"` + // The time in milliseconds it took the job run and all of its repairs to + // finish. + RunDuration *int64 `json:"run_duration,omitempty"` + // The ID of the task run. + RunId *int64 `json:"run_id,omitempty"` + // An optional value indicating the condition that determines whether the task + // should be run once its dependencies have been completed. When omitted, + // defaults to `ALL_SUCCESS`. See :method:jobs/create for a list of possible + // values. + RunIf TaskDependencyType `json:"run_if,omitempty"` + RunJobTask *RunJobTask `json:"run_job_task,omitempty"` + RunPageUrl *string `json:"run_page_url,omitempty"` + // The time in milliseconds it took to set up the cluster. For runs that run on + // new clusters this is the cluster creation time, for runs that run on existing + // clusters this time should be very short. The duration of a task run is the + // sum of the `setup_duration`, `execution_duration`, and the + // `cleanup_duration`. The `setup_duration` field is set to 0 for multitask job + // runs. The total duration of a multitask job run is the value of the + // `run_duration` field. + SetupDuration *int64 `json:"setup_duration,omitempty"` + SparkJarTask *SparkJarTask `json:"spark_jar_task,omitempty"` + SparkPythonTask *SparkPythonTask `json:"spark_python_task,omitempty"` + SparkSubmitTask *SparkSubmitTask `json:"spark_submit_task,omitempty"` + SqlTask *SqlTask `json:"sql_task,omitempty"` + // The time at which this run was started in epoch milliseconds (milliseconds + // since 1/1/1970 UTC). This may not be the time when the job task starts + // executing, for example, if the job is scheduled to run on a new cluster, this + // is the time the cluster creation call is issued. + StartTime *int64 `json:"start_time,omitempty"` + // Deprecated. Please use the `status` field instead. + State *RunState `json:"state,omitempty"` + Status *RunStatus `json:"status,omitempty"` + // A unique name for the task. This field is used to refer to this task from + // other tasks. This field is required and must be unique within its parent job. + // On Update or Reset, this field is used to reference the tasks to be updated + // or reset. + TaskKey *string `json:"task_key,omitempty"` + // An optional timeout applied to each run of this job task. A value of `0` + // means no timeout. + TimeoutSeconds *int `json:"timeout_seconds,omitempty"` + // A collection of system notification IDs to notify when the run begins or + // completes. The default behavior is to not send any system notifications. Task + // webhooks respect the task notification settings. + WebhookNotifications *WebhookNotifications `json:"webhook_notifications,omitempty"` +} + +type RunTaskSettings struct { + AiRuntimeTask *AiRuntimeTask `json:"ai_runtime_task,omitempty"` + AlertTask *AlertTask `json:"alert_task,omitempty"` + CleanRoomsNotebookTask *CleanRoomsNotebookTask `json:"clean_rooms_notebook_task,omitempty"` + // Task level compute configuration. + Compute *Compute `json:"compute,omitempty"` + ConditionTask *ConditionTask `json:"condition_task,omitempty"` + DashboardTask *DashboardTask `json:"dashboard_task,omitempty"` + DbtCloudTask *DbtCloudTask `json:"dbt_cloud_task,omitempty"` + DbtPlatformTask *DbtPlatformTask `json:"dbt_platform_task,omitempty"` + DbtTask *DbtTask `json:"dbt_task,omitempty"` + // An optional array of objects specifying the dependency graph of the task. All + // tasks specified in this field must complete successfully before executing + // this task. The key is `task_key`, and the value is the name assigned to the + // dependent task. + DependsOn []TaskDependency `json:"depends_on,omitempty"` + // An optional description for this task. + Description *string `json:"description,omitempty"` + // An option to disable auto optimization in serverless + DisableAutoOptimization *bool `json:"disable_auto_optimization,omitempty"` + // An optional flag to disable the task. If set to true, the task will not run + // even if it is part of a job. + Disabled *bool `json:"disabled,omitempty"` + // An optional set of email addresses notified when the task run begins or + // completes. The default behavior is to not send any emails. + EmailNotifications *JobEmailNotifications `json:"email_notifications,omitempty"` + EnvironmentKey *string `json:"environment_key,omitempty"` + // Reference to a `JobEnvironmentVariables` entry defined in + // `RunSettings.environment_variables` for one-time runs or preserved in + // `Run.environment_variables` for run snapshots. The selected entry's variables + // are applied to this task at execution time. This field supports serverless + // tasks using environment version 5 or later. + EnvironmentVariablesKey *string `json:"environment_variables_key,omitempty"` + ExistingClusterId *string `json:"existing_cluster_id,omitempty"` + ForEachTask *ForEachTask `json:"for_each_task,omitempty"` + GenAiComputeTask *GenAiComputeTask `json:"gen_ai_compute_task,omitempty"` + Health *JobsHealthRules `json:"health,omitempty"` + JobClusterKey *string `json:"job_cluster_key,omitempty"` + // An optional list of libraries to be installed on the cluster. The default + // value is an empty list. + Libraries []Library `json:"libraries,omitempty"` + // An optional maximum number of times to retry an unsuccessful run. A run is + // considered to be unsuccessful if it completes with the `FAILED` result_state + // or `INTERNAL_ERROR` `life_cycle_state`. The value `-1` means to retry + // indefinitely and the value `0` means to never retry. + MaxRetries *int `json:"max_retries,omitempty"` + // An optional minimal interval in milliseconds between the start of the failed + // run and the subsequent retry run. The default behavior is that unsuccessful + // runs are immediately retried. + MinRetryIntervalMillis *int `json:"min_retry_interval_millis,omitempty"` + NewCluster *ClusterSpec_NewCluster `json:"new_cluster,omitempty"` + NotebookTask *NotebookTask `json:"notebook_task,omitempty"` + // Optional notification settings that are used when sending notifications to + // each of the `email_notifications` and `webhook_notifications` for this task + // run. + NotificationSettings *NotificationSettings `json:"notification_settings,omitempty"` + PipelineTask *PipelineTask `json:"pipeline_task,omitempty"` + PowerBiTask *PowerBiTask `json:"power_bi_task,omitempty"` + PythonOperatorTask *PythonOperatorTask `json:"python_operator_task,omitempty"` + PythonWheelTask *PythonWheelTask `json:"python_wheel_task,omitempty"` + // An optional policy to specify whether to retry a job when it times out. The + // default behavior is to not retry on timeout. + RetryOnTimeout *bool `json:"retry_on_timeout,omitempty"` + // An optional value indicating the condition that determines whether the task + // should be run once its dependencies have been completed. When omitted, + // defaults to `ALL_SUCCESS`. See :method:jobs/create for a list of possible + // values. + RunIf TaskDependencyType `json:"run_if,omitempty"` + RunJobTask *RunJobTask `json:"run_job_task,omitempty"` + SparkJarTask *SparkJarTask `json:"spark_jar_task,omitempty"` + SparkPythonTask *SparkPythonTask `json:"spark_python_task,omitempty"` + SparkSubmitTask *SparkSubmitTask `json:"spark_submit_task,omitempty"` + SqlTask *SqlTask `json:"sql_task,omitempty"` + // A unique name for the task. This field is used to refer to this task from + // other tasks. This field is required and must be unique within its parent job. + // On Update or Reset, this field is used to reference the tasks to be updated + // or reset. + TaskKey *string `json:"task_key,omitempty"` + // An optional timeout applied to each run of this job task. A value of `0` + // means no timeout. + TimeoutSeconds *int `json:"timeout_seconds,omitempty"` + // A collection of system notification IDs to notify when the run begins or + // completes. The default behavior is to not send any system notifications. Task + // webhooks respect the task notification settings. + WebhookNotifications *WebhookNotifications `json:"webhook_notifications,omitempty"` +} + +// Additional details about what triggered the run. +type RunTriggerInfo struct { + // The run id of the Run Job task run + RunId *int64 `json:"run_id,omitempty"` + // SQL condition evaluation details for this run + SqlCondition *SqlConditionRunInfoDetails `json:"sql_condition,omitempty"` +} + +// A storage location in Amazon S3. +type S3StorageInfo struct { + // (Optional) Set canned access control list for the logs, e.g. + // `bucket-owner-full-control`. If `canned_cal` is set, please make sure the + // cluster iam role has `s3:PutObjectAcl` permission on the destination bucket + // and prefix. The full list of possible canned acl can be found at + // http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl. + // Please also note that by default only the object owner gets full controls. If + // you are using cross account role for writing data, you may want to set + // `bucket-owner-full-control` to make bucket owner able to read the logs. + CannedAcl *string `json:"canned_acl,omitempty"` + // S3 destination, e.g. `s3://my-bucket/some-prefix` Note that logs will be + // delivered using cluster iam role, please make sure you set cluster iam role + // and the role has write access to the destination. Please also note that you + // cannot use AWS keys to deliver logs. + Destination *string `json:"destination,omitempty"` + // (Optional) Flag to enable server side encryption, `false` by default. + EnableEncryption *bool `json:"enable_encryption,omitempty"` + // (Optional) The encryption type, it could be `sse-s3` or `sse-kms`. It will be + // used only when encryption is enabled and the default type is `sse-s3`. + EncryptionType *string `json:"encryption_type,omitempty"` + // S3 endpoint, e.g. `https://s3-us-west-2.amazonaws.com`. Either region or + // endpoint needs to be set. If both are set, endpoint will be used. + Endpoint *string `json:"endpoint,omitempty"` + // (Optional) Kms key which will be used if encryption is enabled and encryption + // type is set to `sse-kms`. + KmsKey *string `json:"kms_key,omitempty"` + // S3 region, e.g. `us-west-2`. Either region or endpoint needs to be set. If + // both are set, endpoint will be used. + Region *string `json:"region,omitempty"` +} + +// Runtime state for a schedule trigger. Currently empty because schedule +// triggers do not expose any trigger-specific runtime state.. +type ScheduleTriggerState struct { +} + +type SparkJarTask struct { + // Deprecated since 04/2016. For classic compute, provide a `jar` through the + // `libraries` field instead. For serverless compute, provide a `jar` though the + // `java_dependencies` field inside the `environments` list. + // + // See the examples of classic and serverless compute usage at the top of the + // page. + JarUri *string `json:"jar_uri,omitempty"` + // The full name of the class containing the main method to be executed. This + // class must be contained in a JAR provided as a library. + // + // The code must use `SparkContext.getOrCreate` to obtain a Spark context; + // otherwise, runs of the job fail. + MainClassName *string `json:"main_class_name,omitempty"` + // Parameters passed to the main method. + // + // Use [Task parameter variables](/jobs.html#parameter-variables) to set + // parameters containing information about job runs. + Parameters []string `json:"parameters,omitempty"` + // Deprecated. A value of `false` is no longer supported. + RunAsRepl *bool `json:"run_as_repl,omitempty"` +} + +type SparkPythonTask struct { + // Command line parameters passed to the Python file. + // + // Use [Task parameter variables](/jobs.html#parameter-variables) to set + // parameters containing information about job runs. + Parameters []string `json:"parameters,omitempty"` + // The Python file to be executed. Cloud file URIs (such as dbfs:/, s3:/, + // adls:/, gcs:/) and workspace paths are supported. For python files stored in + // the workspace, the path must be absolute and begin with `/`. For + // files stored in a remote repository, the path must be relative. This field is + // required. + PythonFile *string `json:"python_file,omitempty"` + // Optional location type of the Python file. When set to `WORKSPACE` or not + // specified, the file will be retrieved from the local workspace + // or cloud location (if the `python_file` has a URI format). When set to `GIT`, + // the Python file will be retrieved from a Git repository defined in + // `git_source`. + // + // * `WORKSPACE`: The Python file is located in a workspace or at a + // cloud filesystem URI. * `GIT`: The Python file is located in a remote Git + // repository. + Source Source `json:"source,omitempty"` +} + +type SparkSubmitTask struct { + // Command-line parameters passed to spark submit. + // + // Use [Task parameter variables](/jobs.html#parameter-variables) to set + // parameters containing information about job runs. + Parameters []string `json:"parameters,omitempty"` +} + +type SparseCheckout struct { + // List of patterns to include for sparse checkout. + Patterns []string `json:"patterns,omitempty"` +} + +type SqlConditionConfiguration struct { + // The ID of the SQL query to evaluate as the trigger condition. + SqlQueryId *string `json:"sql_query_id,omitempty"` + // Determines how the SQL query result is interpreted to decide whether the + // condition fires. Must be set to a recognized value when provided. When unset + // on an existing serialized configuration, the server preserves the original + // semantics by interpreting it as `QUERY_RETURNS_ROWS`. New configurations + // should set this explicitly — explicit + // `SQL_CONDITION_TRIGGER_MODE_UNSPECIFIED` is rejected at validation. + TriggerMode SqlConditionTriggerMode `json:"trigger_mode,omitempty"` + // The canonical identifier of the SQL warehouse to run the condition query + // against. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +// SQL condition evaluation details captured at the time the run was triggered. +type SqlConditionRunInfoDetails struct { + // Whether the last condition evaluation was satisfied (query returned truthy + // result). + ConditionEvaluationSatisfied *bool `json:"condition_evaluation_satisfied,omitempty"` + // The ID of the SQL session, used by the UI to track session context. Set for + // the QUERY_RETURNS_ROWS trigger mode. + ConditionEvaluationSqlSessionId *string `json:"condition_evaluation_sql_session_id,omitempty"` + // The SQL statement ID of the condition evaluation, set when the condition is + // evaluated by running a single SQL statement (the RESULT_VALUE_CHANGES trigger + // mode). The UI uses it to link to the query execution details. + ConditionEvaluationSqlStatementId *string `json:"condition_evaluation_sql_statement_id,omitempty"` +} + +type SqlConditionState struct { + // Whether the last condition evaluation was satisfied (query returned truthy + // result). + LatestConditionEvaluationSatisfied *bool `json:"latest_condition_evaluation_satisfied,omitempty"` + // The ID of the SQL session, used by UI to track session context. Populated for + // QUERY_RETURNS_ROWS, which executes the query through Redash. + LatestConditionEvaluationSqlSessionId *string `json:"latest_condition_evaluation_sql_session_id,omitempty"` + // The SEA statement ID of the SQL statement executed for the latest condition + // evaluation. Populated for RESULT_VALUE_CHANGES, which executes the query + // through the SQL execution API. + LatestConditionEvaluationSqlStatementId *string `json:"latest_condition_evaluation_sql_statement_id,omitempty"` +} + +type SqlTask struct { + Alert *SqlTaskAlert `json:"alert,omitempty"` + Dashboard *SqlTaskDashboard `json:"dashboard,omitempty"` + File *SqlTaskFile `json:"file,omitempty"` + // Parameters to be used for each run of this job. The SQL alert task does not + // support custom parameters. + Parameters map[string]string `json:"parameters,omitempty"` + Query *SqlTaskQuery `json:"query,omitempty"` + // The canonical identifier of the SQL warehouse. Recommended to use with + // serverless or pro SQL warehouses. Classic SQL warehouses are only supported + // for SQL alert, dashboard and query tasks and are limited to scheduled + // single-task jobs. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type SqlTask_SqlAlertOutput struct { + AlertState SqlAlertState_SqlAlertState `json:"alert_state,omitempty"` + // The link to find the output results. + OutputLink *string `json:"output_link,omitempty"` + // The text of the SQL query. Can Run permission of the SQL query associated + // with the SQL alert is required to view this field. + QueryText *string `json:"query_text,omitempty"` + // Information about SQL statements executed in the run. + SqlStatements []SqlTask_SqlStatementOutput `json:"sql_statements,omitempty"` + // The canonical identifier of the SQL warehouse. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type SqlTask_SqlDashboardOutput struct { + // The canonical identifier of the SQL warehouse. + WarehouseId *string `json:"warehouse_id,omitempty"` + // Widgets executed in the run. Only SQL query based widgets are listed. + Widgets []SqlTask_SqlDashboardWidgetOutput `json:"widgets,omitempty"` +} + +type SqlTask_SqlDashboardWidgetOutput struct { + // Time (in epoch milliseconds) when execution of the SQL widget ends. + EndTime *int64 `json:"end_time,omitempty"` + // The information about the error when execution fails. + Error *SqlTask_SqlOutputError `json:"error,omitempty"` + // The link to find the output results. + OutputLink *string `json:"output_link,omitempty"` + // Time (in epoch milliseconds) when execution of the SQL widget starts. + StartTime *int64 `json:"start_time,omitempty"` + // The execution status of the SQL widget. + Status SqlTask_SqlTaskQueryStatus `json:"status,omitempty"` + // The canonical identifier of the SQL widget. + WidgetId *string `json:"widget_id,omitempty"` + // The title of the SQL widget. + WidgetTitle *string `json:"widget_title,omitempty"` +} + +type SqlTask_SqlOutput struct { + AlertOutput *SqlTask_SqlAlertOutput `json:"alert_output,omitempty"` + DashboardOutput *SqlTask_SqlDashboardOutput `json:"dashboard_output,omitempty"` + QueryOutput *SqlTask_SqlQueryOutput `json:"query_output,omitempty"` +} + +type SqlTask_SqlOutputError struct { + // The error message when execution fails. + Message *string `json:"message,omitempty"` +} + +type SqlTask_SqlQueryOutput struct { + EndpointId *string `json:"endpoint_id,omitempty"` + // The link to find the output results. + OutputLink *string `json:"output_link,omitempty"` + // The text of the SQL query. Can Run permission of the SQL query is required to + // view this field. + QueryText *string `json:"query_text,omitempty"` + // Information about SQL statements executed in the run. + SqlStatements []SqlTask_SqlStatementOutput `json:"sql_statements,omitempty"` + // The canonical identifier of the SQL warehouse. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type SqlTask_SqlStatementOutput struct { + // A key that can be used to look up query details. + LookupKey *string `json:"lookup_key,omitempty"` +} + +type SqlTaskAlert struct { + // The canonical identifier of the SQL alert. + AlertId *string `json:"alert_id,omitempty"` + // If true, the alert notifications are not sent to subscribers. + PauseSubscriptions *bool `json:"pause_subscriptions,omitempty"` + // If specified, alert notifications are sent to subscribers. + Subscriptions []SqlTaskSubscription `json:"subscriptions,omitempty"` +} + +type SqlTaskDashboard struct { + // Subject of the email sent to subscribers of this task. + CustomSubject *string `json:"custom_subject,omitempty"` + // The canonical identifier of the SQL dashboard. + DashboardId *string `json:"dashboard_id,omitempty"` + // If true, the dashboard snapshot is not taken, and emails are not sent to + // subscribers. + PauseSubscriptions *bool `json:"pause_subscriptions,omitempty"` + // If specified, dashboard snapshots are sent to subscriptions. + Subscriptions []SqlTaskSubscription `json:"subscriptions,omitempty"` +} + +type SqlTaskFile struct { + // Path of the SQL file. Must be relative if the source is a remote Git + // repository and absolute for workspace paths. + Path *string `json:"path,omitempty"` + // Optional location type of the SQL file. When set to `WORKSPACE`, the SQL file + // will be retrieved from the local workspace. When set to `GIT`, + // the SQL file will be retrieved from a Git repository defined in `git_source`. + // If the value is empty, the task will use `GIT` if `git_source` is defined and + // `WORKSPACE` otherwise. + // + // * `WORKSPACE`: SQL file is located in workspace. * `GIT`: SQL + // file is located in cloud Git provider. + Source Source `json:"source,omitempty"` +} + +type SqlTaskQuery struct { + QueryId *string `json:"query_id,omitempty"` +} + +type SqlTaskSubscription struct { + DestinationId *string `json:"destination_id,omitempty"` + UserName *string `json:"user_name,omitempty"` +} + +type SubmitRunRequest struct { + // List of permissions to set on the job. + AccessControlList []AccessControlRequest `json:"access_control_list,omitempty"` + // The user specified id of the budget policy to use for this one-time run. If + // not specified, the run will be not be attributed to any budget policy. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // An optional set of email addresses notified when the run begins or completes. + EmailNotifications *JobEmailNotifications `json:"email_notifications,omitempty"` + // Named environment-variable entries that tasks of this one-time run can + // reference by key from `RunTaskSettings.environment_variables_key`. Each + // entry's `spec` holds inline `variables` and optional `.env` `files`. Handled + // identically to `JobSettings.environment_variables`. Maximum 10 entries. + // Entries are independent of one another — there is no cross-entry merging. + EnvironmentVariables []JobEnvironmentVariables `json:"environment_variables,omitempty"` + // A list of task execution environment specifications that can be referenced by + // tasks of this run. + Environments []JobEnvironment `json:"environments,omitempty"` + // An optional specification for a remote Git repository containing the source + // code used by tasks. Version-controlled source code is supported by notebook, + // dbt, Python script, and SQL File tasks. + // + // If `git_source` is set, these tasks retrieve the file from the remote + // repository by default. However, this behavior can be overridden by setting + // `source` to `WORKSPACE` on the task. + // + // Note: dbt and SQL File tasks support only version-controlled sources. If dbt + // or SQL File tasks are used, `git_source` must be defined on the job. + GitSource *GitSource `json:"git_source,omitempty"` + Health *JobsHealthRules `json:"health,omitempty"` + // An optional token that can be used to guarantee the idempotency of job run + // requests. If a run with the provided token already exists, the request does + // not create a new run but returns the ID of the existing run instead. If a run + // with the provided token is deleted, an error is returned. + // + // If you specify the idempotency token, upon failure you can retry until the + // request succeeds. guarantees that exactly one run is launched + // with that idempotency token. + // + // This token must have at most 64 characters. + IdempotencyToken *string `json:"idempotency_token,omitempty"` + // Optional notification settings that are used when sending notifications to + // each of the `email_notifications` and `webhook_notifications` for this run. + NotificationSettings *NotificationSettings `json:"notification_settings,omitempty"` + // The performance mode on a serverless one-time run. This field determines the + // level of compute performance or cost-efficiency for the run. The performance + // target does not apply to tasks that run on Serverless GPU compute. + // + // * `PERFORMANCE_OPTIMIZED`: Prioritizes fast startup and execution times + // through rapid scaling and optimized cluster performance. * `STANDARD`: + // Enables cost-efficient execution of serverless workloads. * `COST_OPTIMIZED`: + // Enables lower job costs by optimizing compute for your selected target + // duration time. Must provide a duration target. + PerformanceTarget PerformanceTarget_PerformanceTarget `json:"performance_target,omitempty"` + // The queue settings of the one-time run. + Queue *QueueSettings `json:"queue,omitempty"` + // Specifies the user or service principal that the job runs as. If not + // specified, the job runs as the user who submits the request. + RunAs *JobRunAs `json:"run_as,omitempty"` + // An optional name for the run. The default value is `Untitled`. + RunName *string `json:"run_name,omitempty"` + Tasks []RunTaskSettings `json:"tasks,omitempty"` + // An optional timeout applied to each run of this job. A value of `0` means no + // timeout. + TimeoutSeconds *int `json:"timeout_seconds,omitempty"` + // The user specified id of the usage policy to use for this one-time run. If + // not specified, a default usage policy may be applied when creating or + // modifying the job. + UsagePolicyId *string `json:"usage_policy_id,omitempty"` + // A collection of system notification IDs to notify when the run begins or + // completes. + WebhookNotifications *WebhookNotifications `json:"webhook_notifications,omitempty"` +} + +// Run was created and started successfully.. +type SubmitRunResponse struct { + // The canonical identifier for the newly submitted run. + RunId *int64 `json:"run_id,omitempty"` +} + +type Subscription struct { + // Optional: Allows users to specify a custom subject line on the email sent to + // subscribers. + CustomSubject *string `json:"custom_subject,omitempty"` + // When true, the subscription will not send emails. + Paused *bool `json:"paused,omitempty"` + // The list of subscribers to send the snapshot of the dashboard to. + Subscribers []Subscription_Subscriber `json:"subscribers,omitempty"` +} + +type Subscription_Subscriber struct { + DestinationId *string `json:"destination_id,omitempty"` + UserName *string `json:"user_name,omitempty"` +} + +type TableState struct { + // Whether or not the table has seen updates since either the creation of the + // trigger or the last successful evaluation of the trigger + HasSeenUpdates *bool `json:"has_seen_updates,omitempty"` + // Full table name of the table to monitor, e.g. `mycatalog.myschema.mytable` + TableName *string `json:"table_name,omitempty"` +} + +type TableTriggerConfiguration struct { + // The table(s) condition based on which to trigger a job run. + Condition TableTriggerConfiguration_Condition `json:"condition,omitempty"` + // If set, the trigger starts a run only after the specified amount of time has + // passed since the last time the trigger fired. The minimum allowed value is 60 + // seconds. + MinTimeBetweenTriggersSeconds *int `json:"min_time_between_triggers_seconds,omitempty"` + // A list of tables to monitor for changes. The table name must be in the format + // `catalog_name.schema_name.table_name`. + TableNames []string `json:"table_names,omitempty"` + // If set, the trigger starts a run only after no table updates have occurred + // for the specified time and can be used to wait for a series of table updates + // before triggering a run. The minimum allowed value is 60 seconds. + WaitAfterLastChangeSeconds *int `json:"wait_after_last_change_seconds,omitempty"` +} + +type TableTriggerState struct { + LastSeenTableStates []TableState `json:"last_seen_table_states,omitempty"` + // Indicates whether the trigger is using scalable monitoring. + UsingScalableMonitoring *bool `json:"using_scalable_monitoring,omitempty"` +} + +type TaskDependency struct { + // Can only be specified on condition task dependencies. The outcome of the + // dependent task that must be met for this task to run. + Outcome *string `json:"outcome,omitempty"` + // The name of the task this task depends on. + TaskKey *string `json:"task_key,omitempty"` +} + +type TaskSettings struct { + AiRuntimeTask *AiRuntimeTask `json:"ai_runtime_task,omitempty"` + AlertTask *AlertTask `json:"alert_task,omitempty"` + CleanRoomsNotebookTask *CleanRoomsNotebookTask `json:"clean_rooms_notebook_task,omitempty"` + // Task level compute configuration. + Compute *Compute `json:"compute,omitempty"` + ConditionTask *ConditionTask `json:"condition_task,omitempty"` + DashboardTask *DashboardTask `json:"dashboard_task,omitempty"` + DbtCloudTask *DbtCloudTask `json:"dbt_cloud_task,omitempty"` + DbtPlatformTask *DbtPlatformTask `json:"dbt_platform_task,omitempty"` + DbtTask *DbtTask `json:"dbt_task,omitempty"` + // An optional array of objects specifying the dependency graph of the task. All + // tasks specified in this field must complete before executing this task. The + // task will run only if the `run_if` condition is true. The key is `task_key`, + // and the value is the name assigned to the dependent task. + DependsOn []TaskDependency `json:"depends_on,omitempty"` + // An optional description for this task. + Description *string `json:"description,omitempty"` + // An option to disable auto optimization in serverless + DisableAutoOptimization *bool `json:"disable_auto_optimization,omitempty"` + // An optional flag to disable the task. If set to true, the task will not run + // even if it is part of a job. + Disabled *bool `json:"disabled,omitempty"` + // An optional set of email addresses that is notified when runs of this task + // begin or complete as well as when this task is deleted. The default behavior + // is to not send any emails. + EmailNotifications *JobEmailNotifications `json:"email_notifications,omitempty"` + EnvironmentKey *string `json:"environment_key,omitempty"` + // Reference to a `JobEnvironmentVariables` entry defined in + // `JobSettings.environment_variables`. The selected entry's variables are + // applied to this task at execution time. This field supports serverless tasks + // using environment version 5 or later. + EnvironmentVariablesKey *string `json:"environment_variables_key,omitempty"` + ExistingClusterId *string `json:"existing_cluster_id,omitempty"` + ForEachTask *ForEachTask `json:"for_each_task,omitempty"` + GenAiComputeTask *GenAiComputeTask `json:"gen_ai_compute_task,omitempty"` + Health *JobsHealthRules `json:"health,omitempty"` + JobClusterKey *string `json:"job_cluster_key,omitempty"` + // An optional list of libraries to be installed on the cluster. The default + // value is an empty list. + Libraries []Library `json:"libraries,omitempty"` + // An optional maximum number of times to retry an unsuccessful run. A run is + // considered to be unsuccessful if it completes with the `FAILED` result_state + // or `INTERNAL_ERROR` `life_cycle_state`. The value `-1` means to retry + // indefinitely and the value `0` means to never retry. + MaxRetries *int `json:"max_retries,omitempty"` + // An optional minimal interval in milliseconds between the start of the failed + // run and the subsequent retry run. The default behavior is that unsuccessful + // runs are immediately retried. + MinRetryIntervalMillis *int `json:"min_retry_interval_millis,omitempty"` + NewCluster *ClusterSpec_NewCluster `json:"new_cluster,omitempty"` + NotebookTask *NotebookTask `json:"notebook_task,omitempty"` + // Optional notification settings that are used when sending notifications to + // each of the `email_notifications` and `webhook_notifications` for this task. + NotificationSettings *NotificationSettings `json:"notification_settings,omitempty"` + PipelineTask *PipelineTask `json:"pipeline_task,omitempty"` + PowerBiTask *PowerBiTask `json:"power_bi_task,omitempty"` + PythonOperatorTask *PythonOperatorTask `json:"python_operator_task,omitempty"` + PythonWheelTask *PythonWheelTask `json:"python_wheel_task,omitempty"` + // An optional policy to specify whether to retry a job when it times out. The + // default behavior is to not retry on timeout. + RetryOnTimeout *bool `json:"retry_on_timeout,omitempty"` + // An optional value specifying the condition determining whether the task is + // run once its dependencies have been completed. + // + // * `ALL_SUCCESS`: All dependencies have executed and succeeded * + // `AT_LEAST_ONE_SUCCESS`: At least one dependency has succeeded * + // `NONE_FAILED`: None of the dependencies have failed and at least one was + // executed * `ALL_DONE`: All dependencies have been completed * + // `AT_LEAST_ONE_FAILED`: At least one dependency failed * `ALL_FAILED`: ALl + // dependencies have failed + RunIf TaskDependencyType `json:"run_if,omitempty"` + RunJobTask *RunJobTask `json:"run_job_task,omitempty"` + SparkJarTask *SparkJarTask `json:"spark_jar_task,omitempty"` + SparkPythonTask *SparkPythonTask `json:"spark_python_task,omitempty"` + SparkSubmitTask *SparkSubmitTask `json:"spark_submit_task,omitempty"` + SqlTask *SqlTask `json:"sql_task,omitempty"` + // A unique name for the task. This field is used to refer to this task from + // other tasks. This field is required and must be unique within its parent job. + // On Update or Reset, this field is used to reference the tasks to be updated + // or reset. + TaskKey *string `json:"task_key,omitempty"` + // An optional timeout applied to each run of this job task. A value of `0` + // means no timeout. + TimeoutSeconds *int `json:"timeout_seconds,omitempty"` + // A collection of system notification IDs to notify when runs of this task + // begin or complete. The default behavior is to not send any system + // notifications. + WebhookNotifications *WebhookNotifications `json:"webhook_notifications,omitempty"` +} + +type TerminationDetails struct { + Code TerminationCode_Code `json:"code,omitempty"` + // A descriptive message with the termination details. This field is + // unstructured and the format might change. + Message *string `json:"message,omitempty"` + Type TerminationType_Type `json:"type,omitempty"` +} + +// A single trigger attached to a job via `JobSettings.triggers`. Exactly one of +// the trigger-type fields (`periodic`, `schedule`, `continuous`, +// `file_arrival`, `table_update`, `model`, `job_completion`) must be set; +// mutual exclusivity is enforced in the API handler rather than via `oneof` so +// that codegen, validation, and JSON serialization across SDKs and Terraform +// behave consistently.. +type TriggerConfiguration struct { + // Continuous trigger configuration. + Continuous *ContinuousTriggerConfiguration `json:"continuous,omitempty"` + // File arrival trigger configuration. + FileArrival *FileArrivalTriggerConfiguration `json:"file_arrival,omitempty"` + // Model trigger configuration. + Model *ModelTriggerConfiguration `json:"model,omitempty"` + // Whether this trigger is paused. Defaults to UNPAUSED when unset; the server + // always returns an explicit value on read. + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + // Trigger type: exactly one must be set; mutual exclusivity is enforced in the + // API handler Periodic trigger configuration. + Periodic *PeriodicTriggerConfiguration `json:"periodic,omitempty"` + // Cron schedule trigger configuration. + Schedule *CronTriggerConfiguration `json:"schedule,omitempty"` + // Optional SQL condition that gates whether this trigger fires. + SqlCondition *SqlConditionConfiguration `json:"sql_condition,omitempty"` + // Table update trigger configuration. + TableUpdate *TableTriggerConfiguration `json:"table_update,omitempty"` +} + +// Per-trigger runtime details returned by `GetJob`. Same length and order as +// `JobSettings.triggers`; sub-fields are populated independently based on the +// corresponding `GetJob.include_trigger_state` / `include_trigger_history` +// flags.. +type TriggerDetails struct { + // Recent evaluation history. Populated when `GetJob.include_trigger_history` is + // set. + History *TriggerHistory `json:"history,omitempty"` + // Current runtime state. Populated when `GetJob.include_trigger_state` is set. + State *PerTriggerState `json:"state,omitempty"` +} + +type TriggerEvaluation struct { + // Human-readable description of the trigger evaluation result. Explains why the + // trigger evaluation triggered or did not trigger a run, or failed. + Description *string `json:"description,omitempty"` + // The ID of the run that was triggered by the trigger evaluation. Only returned + // if a run was triggered. + RunId *int64 `json:"run_id,omitempty"` + // Timestamp at which the trigger was evaluated. + Timestamp *int64 `json:"timestamp,omitempty"` +} + +type TriggerHistory struct { + // The last time the trigger failed to evaluate. + LastFailed *TriggerEvaluation `json:"last_failed,omitempty"` + // The last time the trigger was evaluated but did not trigger a run. + LastNotTriggered *TriggerEvaluation `json:"last_not_triggered,omitempty"` + // The last time the run was triggered due to a file arrival. + LastTriggered *TriggerEvaluation `json:"last_triggered,omitempty"` +} + +type TriggerSettings struct { + FileArrival *FileArrivalTriggerConfiguration `json:"file_arrival,omitempty"` + Model *ModelTriggerConfiguration `json:"model,omitempty"` + // Whether this trigger is paused or not. + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + Periodic *PeriodicTriggerConfiguration `json:"periodic,omitempty"` + // SQL condition that must be satisfied for the trigger to fire. Can be used in + // combination with other trigger types and runs *after* other trigger types + // conditions are evaluated. + SqlCondition *SqlConditionConfiguration `json:"sql_condition,omitempty"` + TableUpdate *TableTriggerConfiguration `json:"table_update,omitempty"` +} + +type TriggerState struct { + FileArrival *FileArrivalTriggerState `json:"file_arrival,omitempty"` + // Whether this trigger is paused or not. For continuous schedules, it can + // differ from the configured pause_status whenever a paused continuous job is + // kickstarted by an operation other than an update, such as a run-now. + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + // State for SQL condition evaluation, can coexist with other trigger states. + SqlCondition *SqlConditionState `json:"sql_condition,omitempty"` + Table *TableTriggerState `json:"table,omitempty"` +} + +type UpdateJobRequest struct { + // Remove top-level fields in the job settings. Removing nested fields is not + // supported, except for tasks and job clusters (`tasks/task_1`). This field is + // optional. + FieldsToRemove []string `json:"fields_to_remove,omitempty"` + // The canonical identifier of the job to update. This field is required. + JobId *int64 `json:"job_id,omitempty"` + // The new settings for the job. + // + // Top-level fields specified in `new_settings` are completely replaced, except + // for arrays which are merged. That is, new and existing entries are completely + // replaced based on the respective key fields, i.e. `task_key` or + // `job_cluster_key`, while previous entries are kept. + // + // Partially updating nested fields is not supported. + // + // Changes to the field `JobSettings.timeout_seconds` are applied to active + // runs. Changes to other fields are applied to future runs only. + NewSettings *JobSettings `json:"new_settings,omitempty"` +} + +type ViewItem struct { + // Content of the view. + Content *string `json:"content,omitempty"` + // Name of the view item. In the case of code view, it would be the notebook’s + // name. In the case of dashboard view, it would be the dashboard’s name. + Name *string `json:"name,omitempty"` + // Type of the view item. + Type ViewType `json:"type,omitempty"` +} + +// A storage location back by UC Volumes.. +type VolumesStorageInfo struct { + // UC Volumes destination, e.g. + // `/Volumes/catalog/schema/vol1/init-scripts/setup-datadog.sh` or + // `dbfs:/Volumes/catalog/schema/vol1/init-scripts/setup-datadog.sh` + Destination *string `json:"destination,omitempty"` +} + +type Webhook struct { + Id *string `json:"id,omitempty"` +} + +type WebhookNotifications struct { + // An optional list of system notification IDs to call when the duration of a + // run exceeds the threshold specified for the `RUN_DURATION_SECONDS` metric in + // the `health` field. A maximum of 3 destinations can be specified for the + // `on_duration_warning_threshold_exceeded` property. + OnDurationWarningThresholdExceeded []Webhook `json:"on_duration_warning_threshold_exceeded,omitempty"` + // An optional list of system notification IDs to call when the run fails. A + // maximum of 3 destinations can be specified for the `on_failure` property. + OnFailure []Webhook `json:"on_failure,omitempty"` + // An optional list of system notification IDs to call when platform-initiated + // maintenance completes for a continuous job. A maximum of 3 destinations can + // be specified for the `on_maintenance_complete` property. + OnMaintenanceComplete []Webhook `json:"on_maintenance_complete,omitempty"` + // An optional list of system notification IDs to call when platform-initiated + // maintenance starts for a continuous job. A maximum of 3 destinations can be + // specified for the `on_maintenance_start` property. + OnMaintenanceStart []Webhook `json:"on_maintenance_start,omitempty"` + // An optional list of system notification IDs to call when the run starts. A + // maximum of 3 destinations can be specified for the `on_start` property. + OnStart []Webhook `json:"on_start,omitempty"` + // An optional list of system notification IDs to call when any streaming + // backlog thresholds are exceeded for any stream. Streaming backlog thresholds + // can be set in the `health` field using the following metrics: + // `STREAMING_BACKLOG_BYTES`, `STREAMING_BACKLOG_RECORDS`, + // `STREAMING_BACKLOG_SECONDS`, or `STREAMING_BACKLOG_FILES`. Alerting is based + // on the 10-minute average of these metrics. If the issue persists, + // notifications are resent every 30 minutes. A maximum of 3 destinations can be + // specified for the `on_streaming_backlog_exceeded` property. + OnStreamingBacklogExceeded []Webhook `json:"on_streaming_backlog_exceeded,omitempty"` + // An optional list of system notification IDs to call when the run completes + // successfully. A maximum of 3 destinations can be specified for the + // `on_success` property. + OnSuccess []Webhook `json:"on_success,omitempty"` +} + +type WidgetErrorDetail struct { + Message *string `json:"message,omitempty"` +} + +// Cluster Attributes showing for clusters workload types.. +type WorkloadType struct { + // defined what type of clients can use the cluster. E.g. Notebooks, Jobs + Clients *WorkloadType_ClientsTypes `json:"clients,omitempty"` +} + +type WorkloadType_ClientsTypes struct { + // With jobs set, the cluster can be used for jobs + Jobs *bool `json:"jobs,omitempty"` + // With notebooks set, this cluster can be used for notebooks + Notebooks *bool `json:"notebooks,omitempty"` +} + +// A storage location in Workspace Filesystem (WSFS). +type WorkspaceStorageInfo struct { + // wsfs destination, e.g. `workspace:/cluster-init-scripts/setup-datadog.sh` + Destination *string `json:"destination,omitempty"` +} + +// AccessControlRequestToSDK converts the mirror to the sdk-go type. +func AccessControlRequestToSDK(w *AccessControlRequest) (*sdk.AccessControlRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccessControlRequest{} + { + var members []string + if w.UserName != nil { + members = append(members, "user_name") + } + if w.GroupName != nil { + members = append(members, "group_name") + } + if w.ServicePrincipalName != nil { + members = append(members, "service_principal_name") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UserName != nil: + out.PrincipalName = &sdk.AccessControlRequest_PrincipalName_UserName{UserName: *w.UserName} + case w.GroupName != nil: + out.PrincipalName = &sdk.AccessControlRequest_PrincipalName_GroupName{GroupName: *w.GroupName} + case w.ServicePrincipalName != nil: + out.PrincipalName = &sdk.AccessControlRequest_PrincipalName_ServicePrincipalName{ServicePrincipalName: *w.ServicePrincipalName} + } + out.PermissionLevel = w.PermissionLevel + return out, nil +} + +// AccessControlRequestFromSDK converts the sdk-go type to the mirror. +func AccessControlRequestFromSDK(v *sdk.AccessControlRequest) (*AccessControlRequest, error) { + if v == nil { + return nil, nil + } + out := &AccessControlRequest{} + switch value := v.PrincipalName.(type) { + case *sdk.AccessControlRequest_PrincipalName_UserName: + if value != nil { + out.UserName = new(value.UserName) + } + case *sdk.AccessControlRequest_PrincipalName_GroupName: + if value != nil { + out.GroupName = new(value.GroupName) + } + case *sdk.AccessControlRequest_PrincipalName_ServicePrincipalName: + if value != nil { + out.ServicePrincipalName = new(value.ServicePrincipalName) + } + } + out.PermissionLevel = v.PermissionLevel + return out, nil +} + +// Adlsgen2InfoToSDK converts the mirror to the sdk-go type. +func Adlsgen2InfoToSDK(w *Adlsgen2Info) (*sdk.Adlsgen2Info, error) { + if w == nil { + return nil, nil + } + out := &sdk.Adlsgen2Info{} + out.Destination = w.Destination + return out, nil +} + +// Adlsgen2InfoFromSDK converts the sdk-go type to the mirror. +func Adlsgen2InfoFromSDK(v *sdk.Adlsgen2Info) (*Adlsgen2Info, error) { + if v == nil { + return nil, nil + } + out := &Adlsgen2Info{} + out.Destination = v.Destination + return out, nil +} + +// AiRuntimeTaskToSDK converts the mirror to the sdk-go type. +func AiRuntimeTaskToSDK(w *AiRuntimeTask) (*sdk.AiRuntimeTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiRuntimeTask{} + out.Experiment = w.Experiment + conv1, err := convertSlice(w.Deployments, DeploymentSpecToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiRuntimeTask.Deployments", err) + } + out.Deployments = conv1 + out.CodeSourcePath = w.CodeSourcePath + out.MlflowRun = w.MlflowRun + out.MlflowExperimentDirectory = w.MlflowExperimentDirectory + out.DockerImageUrl = w.DockerImageUrl + out.MlflowArtifactLocation = w.MlflowArtifactLocation + out.PriorityClass = w.PriorityClass + out.UnityCatalogImagePath = w.UnityCatalogImagePath + return out, nil +} + +// AiRuntimeTaskFromSDK converts the sdk-go type to the mirror. +func AiRuntimeTaskFromSDK(v *sdk.AiRuntimeTask) (*AiRuntimeTask, error) { + if v == nil { + return nil, nil + } + out := &AiRuntimeTask{} + out.Experiment = v.Experiment + conv2, err := convertSlice(v.Deployments, DeploymentSpecFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiRuntimeTask.Deployments", err) + } + out.Deployments = conv2 + out.CodeSourcePath = v.CodeSourcePath + out.MlflowRun = v.MlflowRun + out.MlflowExperimentDirectory = v.MlflowExperimentDirectory + out.DockerImageUrl = v.DockerImageUrl + out.MlflowArtifactLocation = v.MlflowArtifactLocation + out.PriorityClass = v.PriorityClass + out.UnityCatalogImagePath = v.UnityCatalogImagePath + return out, nil +} + +// AiRuntimeTaskOutputToSDK converts the mirror to the sdk-go type. +func AiRuntimeTaskOutputToSDK(w *AiRuntimeTaskOutput) (*sdk.AiRuntimeTaskOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiRuntimeTaskOutput{} + out.MlflowExperimentId = w.MlflowExperimentId + out.MlflowRunId = w.MlflowRunId + out.StatusMessage = w.StatusMessage + return out, nil +} + +// AiRuntimeTaskOutputFromSDK converts the sdk-go type to the mirror. +func AiRuntimeTaskOutputFromSDK(v *sdk.AiRuntimeTaskOutput) (*AiRuntimeTaskOutput, error) { + if v == nil { + return nil, nil + } + out := &AiRuntimeTaskOutput{} + out.MlflowExperimentId = v.MlflowExperimentId + out.MlflowRunId = v.MlflowRunId + out.StatusMessage = v.StatusMessage + return out, nil +} + +// AlertTaskToSDK converts the mirror to the sdk-go type. +func AlertTaskToSDK(w *AlertTask) (*sdk.AlertTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertTask{} + out.AlertId = w.AlertId + out.WarehouseId = w.WarehouseId + out.WorkspacePath = w.WorkspacePath + conv3, err := convertSlice(w.Subscribers, AlertTaskSubscriberToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertTask.Subscribers", err) + } + out.Subscribers = conv3 + out.Parameters = w.Parameters + return out, nil +} + +// AlertTaskFromSDK converts the sdk-go type to the mirror. +func AlertTaskFromSDK(v *sdk.AlertTask) (*AlertTask, error) { + if v == nil { + return nil, nil + } + out := &AlertTask{} + out.AlertId = v.AlertId + out.WarehouseId = v.WarehouseId + out.WorkspacePath = v.WorkspacePath + conv4, err := convertSlice(v.Subscribers, AlertTaskSubscriberFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AlertTask.Subscribers", err) + } + out.Subscribers = conv4 + out.Parameters = v.Parameters + return out, nil +} + +// AlertTaskOutputToSDK converts the mirror to the sdk-go type. +func AlertTaskOutputToSDK(w *AlertTaskOutput) (*sdk.AlertTaskOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertTaskOutput{} + out.AlertState = w.AlertState + return out, nil +} + +// AlertTaskOutputFromSDK converts the sdk-go type to the mirror. +func AlertTaskOutputFromSDK(v *sdk.AlertTaskOutput) (*AlertTaskOutput, error) { + if v == nil { + return nil, nil + } + out := &AlertTaskOutput{} + out.AlertState = v.AlertState + return out, nil +} + +// AlertTaskSubscriberToSDK converts the mirror to the sdk-go type. +func AlertTaskSubscriberToSDK(w *AlertTaskSubscriber) (*sdk.AlertTaskSubscriber, error) { + if w == nil { + return nil, nil + } + out := &sdk.AlertTaskSubscriber{} + { + var members []string + if w.UserName != nil { + members = append(members, "user_name") + } + if w.DestinationId != nil { + members = append(members, "destination_id") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UserName != nil: + out.SubscriberType = &sdk.AlertTaskSubscriber_SubscriberType_UserName{UserName: *w.UserName} + case w.DestinationId != nil: + out.SubscriberType = &sdk.AlertTaskSubscriber_SubscriberType_DestinationId{DestinationId: *w.DestinationId} + } + return out, nil +} + +// AlertTaskSubscriberFromSDK converts the sdk-go type to the mirror. +func AlertTaskSubscriberFromSDK(v *sdk.AlertTaskSubscriber) (*AlertTaskSubscriber, error) { + if v == nil { + return nil, nil + } + out := &AlertTaskSubscriber{} + switch value := v.SubscriberType.(type) { + case *sdk.AlertTaskSubscriber_SubscriberType_UserName: + if value != nil { + out.UserName = new(value.UserName) + } + case *sdk.AlertTaskSubscriber_SubscriberType_DestinationId: + if value != nil { + out.DestinationId = new(value.DestinationId) + } + } + return out, nil +} + +// AutoScaleToSDK converts the mirror to the sdk-go type. +func AutoScaleToSDK(w *AutoScale) (*sdk.AutoScale, error) { + if w == nil { + return nil, nil + } + out := &sdk.AutoScale{} + out.MinWorkers = w.MinWorkers + out.MaxWorkers = w.MaxWorkers + return out, nil +} + +// AutoScaleFromSDK converts the sdk-go type to the mirror. +func AutoScaleFromSDK(v *sdk.AutoScale) (*AutoScale, error) { + if v == nil { + return nil, nil + } + out := &AutoScale{} + out.MinWorkers = v.MinWorkers + out.MaxWorkers = v.MaxWorkers + return out, nil +} + +// AwsAttributesToSDK converts the mirror to the sdk-go type. +func AwsAttributesToSDK(w *AwsAttributes) (*sdk.AwsAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.AwsAttributes{} + out.FirstOnDemand = w.FirstOnDemand + out.Availability = w.Availability + out.ZoneId = w.ZoneId + out.InstanceProfileArn = w.InstanceProfileArn + out.SpotBidPricePercent = w.SpotBidPricePercent + out.EbsVolumeType = w.EbsVolumeType + out.EbsVolumeCount = w.EbsVolumeCount + out.EbsVolumeSize = w.EbsVolumeSize + out.EbsVolumeIops = w.EbsVolumeIops + out.EbsVolumeThroughput = w.EbsVolumeThroughput + return out, nil +} + +// AwsAttributesFromSDK converts the sdk-go type to the mirror. +func AwsAttributesFromSDK(v *sdk.AwsAttributes) (*AwsAttributes, error) { + if v == nil { + return nil, nil + } + out := &AwsAttributes{} + out.FirstOnDemand = v.FirstOnDemand + out.Availability = v.Availability + out.ZoneId = v.ZoneId + out.InstanceProfileArn = v.InstanceProfileArn + out.SpotBidPricePercent = v.SpotBidPricePercent + out.EbsVolumeType = v.EbsVolumeType + out.EbsVolumeCount = v.EbsVolumeCount + out.EbsVolumeSize = v.EbsVolumeSize + out.EbsVolumeIops = v.EbsVolumeIops + out.EbsVolumeThroughput = v.EbsVolumeThroughput + return out, nil +} + +// AzureAttributesToSDK converts the mirror to the sdk-go type. +func AzureAttributesToSDK(w *AzureAttributes) (*sdk.AzureAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.AzureAttributes{} + conv5, err := LogAnalyticsInfoToSDK(w.LogAnalyticsInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AzureAttributes.LogAnalyticsInfo", err) + } + out.LogAnalyticsInfo = conv5 + out.FirstOnDemand = w.FirstOnDemand + out.Availability = w.Availability + out.SpotBidMaxPrice = w.SpotBidMaxPrice + out.CapacityReservationGroup = w.CapacityReservationGroup + return out, nil +} + +// AzureAttributesFromSDK converts the sdk-go type to the mirror. +func AzureAttributesFromSDK(v *sdk.AzureAttributes) (*AzureAttributes, error) { + if v == nil { + return nil, nil + } + out := &AzureAttributes{} + conv6, err := LogAnalyticsInfoFromSDK(v.LogAnalyticsInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AzureAttributes.LogAnalyticsInfo", err) + } + out.LogAnalyticsInfo = conv6 + out.FirstOnDemand = v.FirstOnDemand + out.Availability = v.Availability + out.SpotBidMaxPrice = v.SpotBidMaxPrice + out.CapacityReservationGroup = v.CapacityReservationGroup + return out, nil +} + +// BaseJobToSDK converts the mirror to the sdk-go type. +func BaseJobToSDK(w *BaseJob) (*sdk.BaseJob, error) { + if w == nil { + return nil, nil + } + out := &sdk.BaseJob{} + out.JobId = w.JobId + out.CreatorUserName = w.CreatorUserName + out.RunAsUserName = w.RunAsUserName + conv7, err := JobSettingsToSDK(w.Settings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseJob.Settings", err) + } + out.Settings = conv7 + out.CreatedTime = w.CreatedTime + conv8, err := TriggerStateToSDK(w.TriggerState) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseJob.TriggerState", err) + } + out.TriggerState = conv8 + out.HasMore = w.HasMore + out.EffectiveBudgetPolicyId = w.EffectiveBudgetPolicyId + out.EffectiveUsagePolicyId = w.EffectiveUsagePolicyId + conv9, err := convertSlice(w.TriggerDetails, TriggerDetailsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseJob.TriggerDetails", err) + } + out.TriggerDetails = conv9 + return out, nil +} + +// BaseJobFromSDK converts the sdk-go type to the mirror. +func BaseJobFromSDK(v *sdk.BaseJob) (*BaseJob, error) { + if v == nil { + return nil, nil + } + out := &BaseJob{} + out.JobId = v.JobId + out.CreatorUserName = v.CreatorUserName + out.RunAsUserName = v.RunAsUserName + conv10, err := JobSettingsFromSDK(v.Settings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseJob.Settings", err) + } + out.Settings = conv10 + out.CreatedTime = v.CreatedTime + conv11, err := TriggerStateFromSDK(v.TriggerState) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseJob.TriggerState", err) + } + out.TriggerState = conv11 + out.HasMore = v.HasMore + out.EffectiveBudgetPolicyId = v.EffectiveBudgetPolicyId + out.EffectiveUsagePolicyId = v.EffectiveUsagePolicyId + conv12, err := convertSlice(v.TriggerDetails, TriggerDetailsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseJob.TriggerDetails", err) + } + out.TriggerDetails = conv12 + return out, nil +} + +// BaseRunToSDK converts the mirror to the sdk-go type. +func BaseRunToSDK(w *BaseRun) (*sdk.BaseRun, error) { + if w == nil { + return nil, nil + } + out := &sdk.BaseRun{} + out.JobId = w.JobId + out.RunId = w.RunId + out.CreatorUserName = w.CreatorUserName + out.NumberInJob = w.NumberInJob + out.OriginalAttemptRunId = w.OriginalAttemptRunId + conv13, err := RunStateToSDK(w.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.State", err) + } + out.State = conv13 + conv14, err := CronScheduleToSDK(w.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.Schedule", err) + } + out.Schedule = conv14 + conv15, err := ClusterSpecToSDK(w.ClusterSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.ClusterSpec", err) + } + out.ClusterSpec = conv15 + conv16, err := ClusterInstanceToSDK(w.ClusterInstance) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.ClusterInstance", err) + } + out.ClusterInstance = conv16 + conv17, err := convertSlice(w.JobParameters, Run_JobLevelParametersToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.JobParameters", err) + } + out.JobParameters = conv17 + conv18, err := RunParametersToSDK(w.OverridingParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.OverridingParameters", err) + } + out.OverridingParameters = conv18 + out.Trigger = w.Trigger + conv19, err := RunTriggerInfoToSDK(w.TriggerInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.TriggerInfo", err) + } + out.TriggerInfo = conv19 + out.RunName = w.RunName + out.RunPageUrl = w.RunPageUrl + out.RunType = w.RunType + conv20, err := convertSlice(w.Tasks, RunTaskToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.Tasks", err) + } + out.Tasks = conv20 + out.Description = w.Description + out.AttemptNumber = w.AttemptNumber + conv21, err := convertSlice(w.JobClusters, JobClusterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.JobClusters", err) + } + out.JobClusters = conv21 + conv22, err := GitSourceToSDK(w.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.GitSource", err) + } + out.GitSource = conv22 + conv23, err := convertSlice(w.RepairHistory, RepairToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.RepairHistory", err) + } + out.RepairHistory = conv23 + conv24, err := RunStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.Status", err) + } + out.Status = conv24 + out.JobRunId = w.JobRunId + out.HasMore = w.HasMore + out.EffectivePerformanceTarget = w.EffectivePerformanceTarget + out.EffectiveUsagePolicyId = w.EffectiveUsagePolicyId + conv25, err := convertSlice(w.EnvironmentVariables, JobEnvironmentVariablesToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.EnvironmentVariables", err) + } + out.EnvironmentVariables = conv25 + out.DeploymentId = w.DeploymentId + out.VersionId = w.VersionId + out.StartTime = w.StartTime + out.SetupDuration = w.SetupDuration + out.ExecutionDuration = w.ExecutionDuration + out.CleanupDuration = w.CleanupDuration + out.EndTime = w.EndTime + out.RunDuration = w.RunDuration + out.QueueDuration = w.QueueDuration + return out, nil +} + +// BaseRunFromSDK converts the sdk-go type to the mirror. +func BaseRunFromSDK(v *sdk.BaseRun) (*BaseRun, error) { + if v == nil { + return nil, nil + } + out := &BaseRun{} + out.JobId = v.JobId + out.RunId = v.RunId + out.CreatorUserName = v.CreatorUserName + out.NumberInJob = v.NumberInJob + out.OriginalAttemptRunId = v.OriginalAttemptRunId + conv26, err := RunStateFromSDK(v.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.State", err) + } + out.State = conv26 + conv27, err := CronScheduleFromSDK(v.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.Schedule", err) + } + out.Schedule = conv27 + conv28, err := ClusterSpecFromSDK(v.ClusterSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.ClusterSpec", err) + } + out.ClusterSpec = conv28 + conv29, err := ClusterInstanceFromSDK(v.ClusterInstance) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.ClusterInstance", err) + } + out.ClusterInstance = conv29 + conv30, err := convertSlice(v.JobParameters, Run_JobLevelParametersFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.JobParameters", err) + } + out.JobParameters = conv30 + conv31, err := RunParametersFromSDK(v.OverridingParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.OverridingParameters", err) + } + out.OverridingParameters = conv31 + out.Trigger = v.Trigger + conv32, err := RunTriggerInfoFromSDK(v.TriggerInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.TriggerInfo", err) + } + out.TriggerInfo = conv32 + out.RunName = v.RunName + out.RunPageUrl = v.RunPageUrl + out.RunType = v.RunType + conv33, err := convertSlice(v.Tasks, RunTaskFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.Tasks", err) + } + out.Tasks = conv33 + out.Description = v.Description + out.AttemptNumber = v.AttemptNumber + conv34, err := convertSlice(v.JobClusters, JobClusterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.JobClusters", err) + } + out.JobClusters = conv34 + conv35, err := GitSourceFromSDK(v.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.GitSource", err) + } + out.GitSource = conv35 + conv36, err := convertSlice(v.RepairHistory, RepairFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.RepairHistory", err) + } + out.RepairHistory = conv36 + conv37, err := RunStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.Status", err) + } + out.Status = conv37 + out.JobRunId = v.JobRunId + out.HasMore = v.HasMore + out.EffectivePerformanceTarget = v.EffectivePerformanceTarget + out.EffectiveUsagePolicyId = v.EffectiveUsagePolicyId + conv38, err := convertSlice(v.EnvironmentVariables, JobEnvironmentVariablesFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BaseRun.EnvironmentVariables", err) + } + out.EnvironmentVariables = conv38 + out.DeploymentId = v.DeploymentId + out.VersionId = v.VersionId + out.StartTime = v.StartTime + out.SetupDuration = v.SetupDuration + out.ExecutionDuration = v.ExecutionDuration + out.CleanupDuration = v.CleanupDuration + out.EndTime = v.EndTime + out.RunDuration = v.RunDuration + out.QueueDuration = v.QueueDuration + return out, nil +} + +// CancelAllRunsRequestToSDK converts the mirror to the sdk-go type. +func CancelAllRunsRequestToSDK(w *CancelAllRunsRequest) (*sdk.CancelAllRunsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CancelAllRunsRequest{} + out.JobId = w.JobId + out.AllQueuedRuns = w.AllQueuedRuns + return out, nil +} + +// CancelAllRunsRequestFromSDK converts the sdk-go type to the mirror. +func CancelAllRunsRequestFromSDK(v *sdk.CancelAllRunsRequest) (*CancelAllRunsRequest, error) { + if v == nil { + return nil, nil + } + out := &CancelAllRunsRequest{} + out.JobId = v.JobId + out.AllQueuedRuns = v.AllQueuedRuns + return out, nil +} + +// CancelRunRequestToSDK converts the mirror to the sdk-go type. +func CancelRunRequestToSDK(w *CancelRunRequest) (*sdk.CancelRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CancelRunRequest{} + out.RunId = w.RunId + return out, nil +} + +// CancelRunRequestFromSDK converts the sdk-go type to the mirror. +func CancelRunRequestFromSDK(v *sdk.CancelRunRequest) (*CancelRunRequest, error) { + if v == nil { + return nil, nil + } + out := &CancelRunRequest{} + out.RunId = v.RunId + return out, nil +} + +// CleanRoomTaskRunStateToSDK converts the mirror to the sdk-go type. +func CleanRoomTaskRunStateToSDK(w *CleanRoomTaskRunState) (*sdk.CleanRoomTaskRunState, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomTaskRunState{} + out.LifeCycleState = w.LifeCycleState + out.ResultState = w.ResultState + return out, nil +} + +// CleanRoomTaskRunStateFromSDK converts the sdk-go type to the mirror. +func CleanRoomTaskRunStateFromSDK(v *sdk.CleanRoomTaskRunState) (*CleanRoomTaskRunState, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomTaskRunState{} + out.LifeCycleState = v.LifeCycleState + out.ResultState = v.ResultState + return out, nil +} + +// CleanRoomsNotebookTaskToSDK converts the mirror to the sdk-go type. +func CleanRoomsNotebookTaskToSDK(w *CleanRoomsNotebookTask) (*sdk.CleanRoomsNotebookTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomsNotebookTask{} + out.CleanRoomName = w.CleanRoomName + out.NotebookName = w.NotebookName + out.Etag = w.Etag + out.NotebookBaseParameters = w.NotebookBaseParameters + return out, nil +} + +// CleanRoomsNotebookTaskFromSDK converts the sdk-go type to the mirror. +func CleanRoomsNotebookTaskFromSDK(v *sdk.CleanRoomsNotebookTask) (*CleanRoomsNotebookTask, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomsNotebookTask{} + out.CleanRoomName = v.CleanRoomName + out.NotebookName = v.NotebookName + out.Etag = v.Etag + out.NotebookBaseParameters = v.NotebookBaseParameters + return out, nil +} + +// CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutputToSDK converts the mirror to the sdk-go type. +func CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutputToSDK(w *CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput) (*sdk.CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput{} + conv39, err := CleanRoomTaskRunStateToSDK(w.CleanRoomJobRunState) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput.CleanRoomJobRunState", err) + } + out.CleanRoomJobRunState = conv39 + conv40, err := NotebookTask_NotebookOutputToSDK(w.NotebookOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput.NotebookOutput", err) + } + out.NotebookOutput = conv40 + conv41, err := OutputSchemaInfoToSDK(w.OutputSchemaInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput.OutputSchemaInfo", err) + } + out.OutputSchemaInfo = conv41 + return out, nil +} + +// CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutputFromSDK converts the sdk-go type to the mirror. +func CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutputFromSDK(v *sdk.CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput) (*CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput, error) { + if v == nil { + return nil, nil + } + out := &CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput{} + conv42, err := CleanRoomTaskRunStateFromSDK(v.CleanRoomJobRunState) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput.CleanRoomJobRunState", err) + } + out.CleanRoomJobRunState = conv42 + conv43, err := NotebookTask_NotebookOutputFromSDK(v.NotebookOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput.NotebookOutput", err) + } + out.NotebookOutput = conv43 + conv44, err := OutputSchemaInfoFromSDK(v.OutputSchemaInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutput.OutputSchemaInfo", err) + } + out.OutputSchemaInfo = conv44 + return out, nil +} + +// ClusterInstanceToSDK converts the mirror to the sdk-go type. +func ClusterInstanceToSDK(w *ClusterInstance) (*sdk.ClusterInstance, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterInstance{} + out.ClusterId = w.ClusterId + out.SparkContextId = w.SparkContextId + return out, nil +} + +// ClusterInstanceFromSDK converts the sdk-go type to the mirror. +func ClusterInstanceFromSDK(v *sdk.ClusterInstance) (*ClusterInstance, error) { + if v == nil { + return nil, nil + } + out := &ClusterInstance{} + out.ClusterId = v.ClusterId + out.SparkContextId = v.SparkContextId + return out, nil +} + +// ClusterLogConfToSDK converts the mirror to the sdk-go type. +func ClusterLogConfToSDK(w *ClusterLogConf) (*sdk.ClusterLogConf, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterLogConf{} + { + var members []string + if w.Dbfs != nil { + members = append(members, "dbfs") + } + if w.S3 != nil { + members = append(members, "s3") + } + if w.Volumes != nil { + members = append(members, "volumes") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Dbfs != nil: + conv45, err := DbfsStorageInfoToSDK(w.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLogConf.StorageInfo", err) + } + out.StorageInfo = &sdk.ClusterLogConf_StorageInfo_Dbfs{Dbfs: *conv45} + case w.S3 != nil: + conv46, err := S3StorageInfoToSDK(w.S3) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLogConf.StorageInfo", err) + } + out.StorageInfo = &sdk.ClusterLogConf_StorageInfo_S3{S3: *conv46} + case w.Volumes != nil: + conv47, err := VolumesStorageInfoToSDK(w.Volumes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLogConf.StorageInfo", err) + } + out.StorageInfo = &sdk.ClusterLogConf_StorageInfo_Volumes{Volumes: *conv47} + } + return out, nil +} + +// ClusterLogConfFromSDK converts the sdk-go type to the mirror. +func ClusterLogConfFromSDK(v *sdk.ClusterLogConf) (*ClusterLogConf, error) { + if v == nil { + return nil, nil + } + out := &ClusterLogConf{} + switch value := v.StorageInfo.(type) { + case *sdk.ClusterLogConf_StorageInfo_Dbfs: + if value != nil { + conv48, err := DbfsStorageInfoFromSDK(&value.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLogConf.StorageInfo", err) + } + out.Dbfs = conv48 + } + case *sdk.ClusterLogConf_StorageInfo_S3: + if value != nil { + conv49, err := S3StorageInfoFromSDK(&value.S3) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLogConf.StorageInfo", err) + } + out.S3 = conv49 + } + case *sdk.ClusterLogConf_StorageInfo_Volumes: + if value != nil { + conv50, err := VolumesStorageInfoFromSDK(&value.Volumes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterLogConf.StorageInfo", err) + } + out.Volumes = conv50 + } + } + return out, nil +} + +// ClusterSpecToSDK converts the mirror to the sdk-go type. +func ClusterSpecToSDK(w *ClusterSpec) (*sdk.ClusterSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterSpec{} + { + var members []string + if w.ExistingClusterId != nil { + members = append(members, "existing_cluster_id") + } + if w.NewCluster != nil { + members = append(members, "new_cluster") + } + if w.JobClusterKey != nil { + members = append(members, "job_cluster_key") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ExistingClusterId != nil: + out.Spec = &sdk.ClusterSpec_Spec_ExistingClusterId{ExistingClusterId: *w.ExistingClusterId} + case w.NewCluster != nil: + conv51, err := ClusterSpec_NewClusterToSDK(w.NewCluster) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec.Spec", err) + } + out.Spec = &sdk.ClusterSpec_Spec_NewCluster{NewCluster: *conv51} + case w.JobClusterKey != nil: + out.Spec = &sdk.ClusterSpec_Spec_JobClusterKey{JobClusterKey: *w.JobClusterKey} + } + conv52, err := convertSlice(w.Libraries, LibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec.Libraries", err) + } + out.Libraries = conv52 + return out, nil +} + +// ClusterSpecFromSDK converts the sdk-go type to the mirror. +func ClusterSpecFromSDK(v *sdk.ClusterSpec) (*ClusterSpec, error) { + if v == nil { + return nil, nil + } + out := &ClusterSpec{} + switch value := v.Spec.(type) { + case *sdk.ClusterSpec_Spec_ExistingClusterId: + if value != nil { + out.ExistingClusterId = new(value.ExistingClusterId) + } + case *sdk.ClusterSpec_Spec_NewCluster: + if value != nil { + conv53, err := ClusterSpec_NewClusterFromSDK(&value.NewCluster) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec.Spec", err) + } + out.NewCluster = conv53 + } + case *sdk.ClusterSpec_Spec_JobClusterKey: + if value != nil { + out.JobClusterKey = new(value.JobClusterKey) + } + } + conv54, err := convertSlice(v.Libraries, LibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec.Libraries", err) + } + out.Libraries = conv54 + return out, nil +} + +// ClusterSpec_NewClusterToSDK converts the mirror to the sdk-go type. +func ClusterSpec_NewClusterToSDK(w *ClusterSpec_NewCluster) (*sdk.ClusterSpec_NewCluster, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterSpec_NewCluster{} + out.ApplyPolicyDefaultValues = w.ApplyPolicyDefaultValues + out.ClusterName = w.ClusterName + out.SparkVersion = w.SparkVersion + out.SparkConf = w.SparkConf + conv55, err := AwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.AwsAttributes", err) + } + out.AwsAttributes = conv55 + conv56, err := AzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.AzureAttributes", err) + } + out.AzureAttributes = conv56 + conv57, err := GcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.GcpAttributes", err) + } + out.GcpAttributes = conv57 + out.NodeTypeId = w.NodeTypeId + out.DriverNodeTypeId = w.DriverNodeTypeId + conv58, err := NodeTypeFlexibilityToSDK(w.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv58 + conv59, err := NodeTypeFlexibilityToSDK(w.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv59 + out.SshPublicKeys = w.SshPublicKeys + out.CustomTags = w.CustomTags + conv60, err := ClusterLogConfToSDK(w.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.ClusterLogConf", err) + } + out.ClusterLogConf = conv60 + out.SparkEnvVars = w.SparkEnvVars + out.AutoterminationMinutes = w.AutoterminationMinutes + out.EnableElasticDisk = w.EnableElasticDisk + conv61, err := convertSlice(w.InitScripts, InitScriptInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.InitScripts", err) + } + out.InitScripts = conv61 + conv62, err := DockerImageToSDK(w.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.DockerImage", err) + } + out.DockerImage = conv62 + out.InstancePoolId = w.InstancePoolId + out.SingleUserName = w.SingleUserName + out.PolicyId = w.PolicyId + out.EnableLocalDiskEncryption = w.EnableLocalDiskEncryption + out.DriverInstancePoolId = w.DriverInstancePoolId + conv63, err := WorkloadTypeToSDK(w.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.WorkloadType", err) + } + out.WorkloadType = conv63 + out.DataSecurityMode = w.DataSecurityMode + out.RuntimeEngine = w.RuntimeEngine + out.Kind = w.Kind + out.UseMlRuntime = w.UseMlRuntime + out.IsSingleNode = w.IsSingleNode + out.RemoteDiskThroughput = w.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = w.TotalInitialRemoteDiskSize + out.DependencyMode = w.DependencyMode + { + var members []string + if w.NumWorkers != nil { + members = append(members, "num_workers") + } + if w.Autoscale != nil { + members = append(members, "autoscale") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NumWorkers != nil: + out.Size = &sdk.ClusterSpec_NewCluster_Size_NumWorkers{NumWorkers: *w.NumWorkers} + case w.Autoscale != nil: + conv64, err := AutoScaleToSDK(w.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.Size", err) + } + out.Size = &sdk.ClusterSpec_NewCluster_Size_Autoscale{Autoscale: *conv64} + } + return out, nil +} + +// ClusterSpec_NewClusterFromSDK converts the sdk-go type to the mirror. +func ClusterSpec_NewClusterFromSDK(v *sdk.ClusterSpec_NewCluster) (*ClusterSpec_NewCluster, error) { + if v == nil { + return nil, nil + } + out := &ClusterSpec_NewCluster{} + out.ApplyPolicyDefaultValues = v.ApplyPolicyDefaultValues + out.ClusterName = v.ClusterName + out.SparkVersion = v.SparkVersion + out.SparkConf = v.SparkConf + conv65, err := AwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.AwsAttributes", err) + } + out.AwsAttributes = conv65 + conv66, err := AzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.AzureAttributes", err) + } + out.AzureAttributes = conv66 + conv67, err := GcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.GcpAttributes", err) + } + out.GcpAttributes = conv67 + out.NodeTypeId = v.NodeTypeId + out.DriverNodeTypeId = v.DriverNodeTypeId + conv68, err := NodeTypeFlexibilityFromSDK(v.WorkerNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.WorkerNodeTypeFlexibility", err) + } + out.WorkerNodeTypeFlexibility = conv68 + conv69, err := NodeTypeFlexibilityFromSDK(v.DriverNodeTypeFlexibility) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.DriverNodeTypeFlexibility", err) + } + out.DriverNodeTypeFlexibility = conv69 + out.SshPublicKeys = v.SshPublicKeys + out.CustomTags = v.CustomTags + conv70, err := ClusterLogConfFromSDK(v.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.ClusterLogConf", err) + } + out.ClusterLogConf = conv70 + out.SparkEnvVars = v.SparkEnvVars + out.AutoterminationMinutes = v.AutoterminationMinutes + out.EnableElasticDisk = v.EnableElasticDisk + conv71, err := convertSlice(v.InitScripts, InitScriptInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.InitScripts", err) + } + out.InitScripts = conv71 + conv72, err := DockerImageFromSDK(v.DockerImage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.DockerImage", err) + } + out.DockerImage = conv72 + out.InstancePoolId = v.InstancePoolId + out.SingleUserName = v.SingleUserName + out.PolicyId = v.PolicyId + out.EnableLocalDiskEncryption = v.EnableLocalDiskEncryption + out.DriverInstancePoolId = v.DriverInstancePoolId + conv73, err := WorkloadTypeFromSDK(v.WorkloadType) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.WorkloadType", err) + } + out.WorkloadType = conv73 + out.DataSecurityMode = v.DataSecurityMode + out.RuntimeEngine = v.RuntimeEngine + out.Kind = v.Kind + out.UseMlRuntime = v.UseMlRuntime + out.IsSingleNode = v.IsSingleNode + out.RemoteDiskThroughput = v.RemoteDiskThroughput + out.TotalInitialRemoteDiskSize = v.TotalInitialRemoteDiskSize + out.DependencyMode = v.DependencyMode + switch value := v.Size.(type) { + case *sdk.ClusterSpec_NewCluster_Size_NumWorkers: + if value != nil { + out.NumWorkers = new(value.NumWorkers) + } + case *sdk.ClusterSpec_NewCluster_Size_Autoscale: + if value != nil { + conv74, err := AutoScaleFromSDK(&value.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterSpec_NewCluster.Size", err) + } + out.Autoscale = conv74 + } + } + return out, nil +} + +// ComputeToSDK converts the mirror to the sdk-go type. +func ComputeToSDK(w *Compute) (*sdk.Compute, error) { + if w == nil { + return nil, nil + } + out := &sdk.Compute{} + out.HardwareAccelerator = w.HardwareAccelerator + return out, nil +} + +// ComputeFromSDK converts the sdk-go type to the mirror. +func ComputeFromSDK(v *sdk.Compute) (*Compute, error) { + if v == nil { + return nil, nil + } + out := &Compute{} + out.HardwareAccelerator = v.HardwareAccelerator + return out, nil +} + +// ComputeConfigToSDK converts the mirror to the sdk-go type. +func ComputeConfigToSDK(w *ComputeConfig) (*sdk.ComputeConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ComputeConfig{} + out.NumGpus = w.NumGpus + out.GpuNodePoolId = w.GpuNodePoolId + out.GpuType = w.GpuType + return out, nil +} + +// ComputeConfigFromSDK converts the sdk-go type to the mirror. +func ComputeConfigFromSDK(v *sdk.ComputeConfig) (*ComputeConfig, error) { + if v == nil { + return nil, nil + } + out := &ComputeConfig{} + out.NumGpus = v.NumGpus + out.GpuNodePoolId = v.GpuNodePoolId + out.GpuType = v.GpuType + return out, nil +} + +// ComputeSpecToSDK converts the mirror to the sdk-go type. +func ComputeSpecToSDK(w *ComputeSpec) (*sdk.ComputeSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.ComputeSpec{} + out.AcceleratorType = w.AcceleratorType + out.AcceleratorCount = w.AcceleratorCount + out.ProvisionedCapacityId = w.ProvisionedCapacityId + return out, nil +} + +// ComputeSpecFromSDK converts the sdk-go type to the mirror. +func ComputeSpecFromSDK(v *sdk.ComputeSpec) (*ComputeSpec, error) { + if v == nil { + return nil, nil + } + out := &ComputeSpec{} + out.AcceleratorType = v.AcceleratorType + out.AcceleratorCount = v.AcceleratorCount + out.ProvisionedCapacityId = v.ProvisionedCapacityId + return out, nil +} + +// ConditionTaskToSDK converts the mirror to the sdk-go type. +func ConditionTaskToSDK(w *ConditionTask) (*sdk.ConditionTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.ConditionTask{} + out.Op = w.Op + out.Left = w.Left + out.Right = w.Right + out.Outcome = w.Outcome + return out, nil +} + +// ConditionTaskFromSDK converts the sdk-go type to the mirror. +func ConditionTaskFromSDK(v *sdk.ConditionTask) (*ConditionTask, error) { + if v == nil { + return nil, nil + } + out := &ConditionTask{} + out.Op = v.Op + out.Left = v.Left + out.Right = v.Right + out.Outcome = v.Outcome + return out, nil +} + +// ContinuousSettingsToSDK converts the mirror to the sdk-go type. +func ContinuousSettingsToSDK(w *ContinuousSettings) (*sdk.ContinuousSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.ContinuousSettings{} + out.PauseStatus = w.PauseStatus + out.TaskRetryMode = w.TaskRetryMode + conv75, err := MaintenanceWindowToSDK(w.MaintenanceWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ContinuousSettings.MaintenanceWindow", err) + } + out.MaintenanceWindow = conv75 + return out, nil +} + +// ContinuousSettingsFromSDK converts the sdk-go type to the mirror. +func ContinuousSettingsFromSDK(v *sdk.ContinuousSettings) (*ContinuousSettings, error) { + if v == nil { + return nil, nil + } + out := &ContinuousSettings{} + out.PauseStatus = v.PauseStatus + out.TaskRetryMode = v.TaskRetryMode + conv76, err := MaintenanceWindowFromSDK(v.MaintenanceWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ContinuousSettings.MaintenanceWindow", err) + } + out.MaintenanceWindow = conv76 + return out, nil +} + +// ContinuousTriggerConfigurationToSDK converts the mirror to the sdk-go type. +func ContinuousTriggerConfigurationToSDK(w *ContinuousTriggerConfiguration) (*sdk.ContinuousTriggerConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.ContinuousTriggerConfiguration{} + out.TaskRetryMode = w.TaskRetryMode + conv77, err := MaintenanceWindowToSDK(w.MaintenanceWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ContinuousTriggerConfiguration.MaintenanceWindow", err) + } + out.MaintenanceWindow = conv77 + return out, nil +} + +// ContinuousTriggerConfigurationFromSDK converts the sdk-go type to the mirror. +func ContinuousTriggerConfigurationFromSDK(v *sdk.ContinuousTriggerConfiguration) (*ContinuousTriggerConfiguration, error) { + if v == nil { + return nil, nil + } + out := &ContinuousTriggerConfiguration{} + out.TaskRetryMode = v.TaskRetryMode + conv78, err := MaintenanceWindowFromSDK(v.MaintenanceWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ContinuousTriggerConfiguration.MaintenanceWindow", err) + } + out.MaintenanceWindow = conv78 + return out, nil +} + +// ContinuousTriggerStateToSDK converts the mirror to the sdk-go type. +func ContinuousTriggerStateToSDK(w *ContinuousTriggerState) (*sdk.ContinuousTriggerState, error) { + if w == nil { + return nil, nil + } + out := &sdk.ContinuousTriggerState{} + out.ConsecutiveFailures = w.ConsecutiveFailures + out.NextAttemptMs = w.NextAttemptMs + out.IsBackingOff = w.IsBackingOff + return out, nil +} + +// ContinuousTriggerStateFromSDK converts the sdk-go type to the mirror. +func ContinuousTriggerStateFromSDK(v *sdk.ContinuousTriggerState) (*ContinuousTriggerState, error) { + if v == nil { + return nil, nil + } + out := &ContinuousTriggerState{} + out.ConsecutiveFailures = v.ConsecutiveFailures + out.NextAttemptMs = v.NextAttemptMs + out.IsBackingOff = v.IsBackingOff + return out, nil +} + +// CreateJobRequestToSDK converts the mirror to the sdk-go type. +func CreateJobRequestToSDK(w *CreateJobRequest) (*sdk.CreateJobRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateJobRequest{} + conv79, err := convertSlice(w.AccessControlList, AccessControlRequestToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.AccessControlList", err) + } + out.AccessControlList = conv79 + out.Name = w.Name + out.Description = w.Description + conv80, err := JobEmailNotificationsToSDK(w.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.EmailNotifications", err) + } + out.EmailNotifications = conv80 + conv81, err := WebhookNotificationsToSDK(w.WebhookNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.WebhookNotifications", err) + } + out.WebhookNotifications = conv81 + conv82, err := NotificationSettingsToSDK(w.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.NotificationSettings", err) + } + out.NotificationSettings = conv82 + out.TimeoutSeconds = w.TimeoutSeconds + conv83, err := JobsHealthRulesToSDK(w.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Health", err) + } + out.Health = conv83 + conv84, err := CronScheduleToSDK(w.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Schedule", err) + } + out.Schedule = conv84 + conv85, err := TriggerSettingsToSDK(w.Trigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Trigger", err) + } + out.Trigger = conv85 + conv86, err := ContinuousSettingsToSDK(w.Continuous) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Continuous", err) + } + out.Continuous = conv86 + out.MaxConcurrentRuns = w.MaxConcurrentRuns + conv87, err := convertSlice(w.Tasks, TaskSettingsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Tasks", err) + } + out.Tasks = conv87 + conv88, err := convertSlice(w.JobClusters, JobClusterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.JobClusters", err) + } + out.JobClusters = conv88 + conv89, err := GitSourceToSDK(w.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.GitSource", err) + } + out.GitSource = conv89 + out.Tags = w.Tags + out.Format = w.Format + conv90, err := QueueSettingsToSDK(w.Queue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Queue", err) + } + out.Queue = conv90 + conv91, err := convertSlice(w.Parameters, JobLevelParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Parameters", err) + } + out.Parameters = conv91 + conv92, err := JobRunAsToSDK(w.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.RunAs", err) + } + out.RunAs = conv92 + out.EditMode = w.EditMode + conv93, err := JobDeploymentToSDK(w.Deployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Deployment", err) + } + out.Deployment = conv93 + conv94, err := convertSlice(w.Environments, JobEnvironmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Environments", err) + } + out.Environments = conv94 + out.BudgetPolicyId = w.BudgetPolicyId + out.UsagePolicyId = w.UsagePolicyId + out.PerformanceTarget = w.PerformanceTarget + out.ParentPath = w.ParentPath + conv95, err := convertSlice(w.Triggers, TriggerConfigurationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Triggers", err) + } + out.Triggers = conv95 + conv96, err := convertSlice(w.EnvironmentVariables, JobEnvironmentVariablesToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.EnvironmentVariables", err) + } + out.EnvironmentVariables = conv96 + out.MaxRetries = w.MaxRetries + out.MinRetryIntervalMillis = w.MinRetryIntervalMillis + out.RetryOnTimeout = w.RetryOnTimeout + out.DisableAutoOptimization = w.DisableAutoOptimization + return out, nil +} + +// CreateJobRequestFromSDK converts the sdk-go type to the mirror. +func CreateJobRequestFromSDK(v *sdk.CreateJobRequest) (*CreateJobRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateJobRequest{} + conv97, err := convertSlice(v.AccessControlList, AccessControlRequestFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.AccessControlList", err) + } + out.AccessControlList = conv97 + out.Name = v.Name + out.Description = v.Description + conv98, err := JobEmailNotificationsFromSDK(v.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.EmailNotifications", err) + } + out.EmailNotifications = conv98 + conv99, err := WebhookNotificationsFromSDK(v.WebhookNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.WebhookNotifications", err) + } + out.WebhookNotifications = conv99 + conv100, err := NotificationSettingsFromSDK(v.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.NotificationSettings", err) + } + out.NotificationSettings = conv100 + out.TimeoutSeconds = v.TimeoutSeconds + conv101, err := JobsHealthRulesFromSDK(v.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Health", err) + } + out.Health = conv101 + conv102, err := CronScheduleFromSDK(v.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Schedule", err) + } + out.Schedule = conv102 + conv103, err := TriggerSettingsFromSDK(v.Trigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Trigger", err) + } + out.Trigger = conv103 + conv104, err := ContinuousSettingsFromSDK(v.Continuous) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Continuous", err) + } + out.Continuous = conv104 + out.MaxConcurrentRuns = v.MaxConcurrentRuns + conv105, err := convertSlice(v.Tasks, TaskSettingsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Tasks", err) + } + out.Tasks = conv105 + conv106, err := convertSlice(v.JobClusters, JobClusterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.JobClusters", err) + } + out.JobClusters = conv106 + conv107, err := GitSourceFromSDK(v.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.GitSource", err) + } + out.GitSource = conv107 + out.Tags = v.Tags + out.Format = v.Format + conv108, err := QueueSettingsFromSDK(v.Queue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Queue", err) + } + out.Queue = conv108 + conv109, err := convertSlice(v.Parameters, JobLevelParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Parameters", err) + } + out.Parameters = conv109 + conv110, err := JobRunAsFromSDK(v.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.RunAs", err) + } + out.RunAs = conv110 + out.EditMode = v.EditMode + conv111, err := JobDeploymentFromSDK(v.Deployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Deployment", err) + } + out.Deployment = conv111 + conv112, err := convertSlice(v.Environments, JobEnvironmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Environments", err) + } + out.Environments = conv112 + out.BudgetPolicyId = v.BudgetPolicyId + out.UsagePolicyId = v.UsagePolicyId + out.PerformanceTarget = v.PerformanceTarget + out.ParentPath = v.ParentPath + conv113, err := convertSlice(v.Triggers, TriggerConfigurationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.Triggers", err) + } + out.Triggers = conv113 + conv114, err := convertSlice(v.EnvironmentVariables, JobEnvironmentVariablesFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateJobRequest.EnvironmentVariables", err) + } + out.EnvironmentVariables = conv114 + out.MaxRetries = v.MaxRetries + out.MinRetryIntervalMillis = v.MinRetryIntervalMillis + out.RetryOnTimeout = v.RetryOnTimeout + out.DisableAutoOptimization = v.DisableAutoOptimization + return out, nil +} + +// CreateJobResponseToSDK converts the mirror to the sdk-go type. +func CreateJobResponseToSDK(w *CreateJobResponse) (*sdk.CreateJobResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateJobResponse{} + out.JobId = w.JobId + return out, nil +} + +// CreateJobResponseFromSDK converts the sdk-go type to the mirror. +func CreateJobResponseFromSDK(v *sdk.CreateJobResponse) (*CreateJobResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateJobResponse{} + out.JobId = v.JobId + return out, nil +} + +// CronScheduleToSDK converts the mirror to the sdk-go type. +func CronScheduleToSDK(w *CronSchedule) (*sdk.CronSchedule, error) { + if w == nil { + return nil, nil + } + out := &sdk.CronSchedule{} + out.QuartzCronExpression = w.QuartzCronExpression + out.TimezoneId = w.TimezoneId + out.PauseStatus = w.PauseStatus + conv115, err := SqlConditionConfigurationToSDK(w.SqlCondition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CronSchedule.SqlCondition", err) + } + out.SqlCondition = conv115 + return out, nil +} + +// CronScheduleFromSDK converts the sdk-go type to the mirror. +func CronScheduleFromSDK(v *sdk.CronSchedule) (*CronSchedule, error) { + if v == nil { + return nil, nil + } + out := &CronSchedule{} + out.QuartzCronExpression = v.QuartzCronExpression + out.TimezoneId = v.TimezoneId + out.PauseStatus = v.PauseStatus + conv116, err := SqlConditionConfigurationFromSDK(v.SqlCondition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CronSchedule.SqlCondition", err) + } + out.SqlCondition = conv116 + return out, nil +} + +// CronTriggerConfigurationToSDK converts the mirror to the sdk-go type. +func CronTriggerConfigurationToSDK(w *CronTriggerConfiguration) (*sdk.CronTriggerConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.CronTriggerConfiguration{} + out.QuartzCronExpression = w.QuartzCronExpression + out.TimezoneId = w.TimezoneId + return out, nil +} + +// CronTriggerConfigurationFromSDK converts the sdk-go type to the mirror. +func CronTriggerConfigurationFromSDK(v *sdk.CronTriggerConfiguration) (*CronTriggerConfiguration, error) { + if v == nil { + return nil, nil + } + out := &CronTriggerConfiguration{} + out.QuartzCronExpression = v.QuartzCronExpression + out.TimezoneId = v.TimezoneId + return out, nil +} + +// DashboardPageSnapshotToSDK converts the mirror to the sdk-go type. +func DashboardPageSnapshotToSDK(w *DashboardPageSnapshot) (*sdk.DashboardPageSnapshot, error) { + if w == nil { + return nil, nil + } + out := &sdk.DashboardPageSnapshot{} + out.PageDisplayName = w.PageDisplayName + conv117, err := convertSlice(w.WidgetErrorDetails, WidgetErrorDetailToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DashboardPageSnapshot.WidgetErrorDetails", err) + } + out.WidgetErrorDetails = conv117 + return out, nil +} + +// DashboardPageSnapshotFromSDK converts the sdk-go type to the mirror. +func DashboardPageSnapshotFromSDK(v *sdk.DashboardPageSnapshot) (*DashboardPageSnapshot, error) { + if v == nil { + return nil, nil + } + out := &DashboardPageSnapshot{} + out.PageDisplayName = v.PageDisplayName + conv118, err := convertSlice(v.WidgetErrorDetails, WidgetErrorDetailFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DashboardPageSnapshot.WidgetErrorDetails", err) + } + out.WidgetErrorDetails = conv118 + return out, nil +} + +// DashboardTaskToSDK converts the mirror to the sdk-go type. +func DashboardTaskToSDK(w *DashboardTask) (*sdk.DashboardTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.DashboardTask{} + conv119, err := SubscriptionToSDK(w.Subscription) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DashboardTask.Subscription", err) + } + out.Subscription = conv119 + out.WarehouseId = w.WarehouseId + out.DashboardId = w.DashboardId + out.Filters = w.Filters + return out, nil +} + +// DashboardTaskFromSDK converts the sdk-go type to the mirror. +func DashboardTaskFromSDK(v *sdk.DashboardTask) (*DashboardTask, error) { + if v == nil { + return nil, nil + } + out := &DashboardTask{} + conv120, err := SubscriptionFromSDK(v.Subscription) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DashboardTask.Subscription", err) + } + out.Subscription = conv120 + out.WarehouseId = v.WarehouseId + out.DashboardId = v.DashboardId + out.Filters = v.Filters + return out, nil +} + +// DashboardTaskOutputToSDK converts the mirror to the sdk-go type. +func DashboardTaskOutputToSDK(w *DashboardTaskOutput) (*sdk.DashboardTaskOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.DashboardTaskOutput{} + conv121, err := convertSlice(w.PageSnapshots, DashboardPageSnapshotToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DashboardTaskOutput.PageSnapshots", err) + } + out.PageSnapshots = conv121 + return out, nil +} + +// DashboardTaskOutputFromSDK converts the sdk-go type to the mirror. +func DashboardTaskOutputFromSDK(v *sdk.DashboardTaskOutput) (*DashboardTaskOutput, error) { + if v == nil { + return nil, nil + } + out := &DashboardTaskOutput{} + conv122, err := convertSlice(v.PageSnapshots, DashboardPageSnapshotFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DashboardTaskOutput.PageSnapshots", err) + } + out.PageSnapshots = conv122 + return out, nil +} + +// DbfsStorageInfoToSDK converts the mirror to the sdk-go type. +func DbfsStorageInfoToSDK(w *DbfsStorageInfo) (*sdk.DbfsStorageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.DbfsStorageInfo{} + out.Destination = w.Destination + return out, nil +} + +// DbfsStorageInfoFromSDK converts the sdk-go type to the mirror. +func DbfsStorageInfoFromSDK(v *sdk.DbfsStorageInfo) (*DbfsStorageInfo, error) { + if v == nil { + return nil, nil + } + out := &DbfsStorageInfo{} + out.Destination = v.Destination + return out, nil +} + +// DbtCloudJobRunStepToSDK converts the mirror to the sdk-go type. +func DbtCloudJobRunStepToSDK(w *DbtCloudJobRunStep) (*sdk.DbtCloudJobRunStep, error) { + if w == nil { + return nil, nil + } + out := &sdk.DbtCloudJobRunStep{} + out.Index = w.Index + out.Name = w.Name + out.Status = w.Status + out.Logs = w.Logs + return out, nil +} + +// DbtCloudJobRunStepFromSDK converts the sdk-go type to the mirror. +func DbtCloudJobRunStepFromSDK(v *sdk.DbtCloudJobRunStep) (*DbtCloudJobRunStep, error) { + if v == nil { + return nil, nil + } + out := &DbtCloudJobRunStep{} + out.Index = v.Index + out.Name = v.Name + out.Status = v.Status + out.Logs = v.Logs + return out, nil +} + +// DbtCloudTaskToSDK converts the mirror to the sdk-go type. +func DbtCloudTaskToSDK(w *DbtCloudTask) (*sdk.DbtCloudTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.DbtCloudTask{} + out.DbtCloudJobId = w.DbtCloudJobId + out.ConnectionResourceName = w.ConnectionResourceName + return out, nil +} + +// DbtCloudTaskFromSDK converts the sdk-go type to the mirror. +func DbtCloudTaskFromSDK(v *sdk.DbtCloudTask) (*DbtCloudTask, error) { + if v == nil { + return nil, nil + } + out := &DbtCloudTask{} + out.DbtCloudJobId = v.DbtCloudJobId + out.ConnectionResourceName = v.ConnectionResourceName + return out, nil +} + +// DbtCloudTaskOutputToSDK converts the mirror to the sdk-go type. +func DbtCloudTaskOutputToSDK(w *DbtCloudTaskOutput) (*sdk.DbtCloudTaskOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.DbtCloudTaskOutput{} + out.DbtCloudJobRunId = w.DbtCloudJobRunId + out.DbtCloudJobRunUrl = w.DbtCloudJobRunUrl + conv123, err := convertSlice(w.DbtCloudJobRunOutput, DbtCloudJobRunStepToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DbtCloudTaskOutput.DbtCloudJobRunOutput", err) + } + out.DbtCloudJobRunOutput = conv123 + return out, nil +} + +// DbtCloudTaskOutputFromSDK converts the sdk-go type to the mirror. +func DbtCloudTaskOutputFromSDK(v *sdk.DbtCloudTaskOutput) (*DbtCloudTaskOutput, error) { + if v == nil { + return nil, nil + } + out := &DbtCloudTaskOutput{} + out.DbtCloudJobRunId = v.DbtCloudJobRunId + out.DbtCloudJobRunUrl = v.DbtCloudJobRunUrl + conv124, err := convertSlice(v.DbtCloudJobRunOutput, DbtCloudJobRunStepFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DbtCloudTaskOutput.DbtCloudJobRunOutput", err) + } + out.DbtCloudJobRunOutput = conv124 + return out, nil +} + +// DbtPlatformJobRunStepToSDK converts the mirror to the sdk-go type. +func DbtPlatformJobRunStepToSDK(w *DbtPlatformJobRunStep) (*sdk.DbtPlatformJobRunStep, error) { + if w == nil { + return nil, nil + } + out := &sdk.DbtPlatformJobRunStep{} + out.Index = w.Index + out.Name = w.Name + out.Status = w.Status + out.Logs = w.Logs + out.NameTruncated = w.NameTruncated + out.LogsTruncated = w.LogsTruncated + return out, nil +} + +// DbtPlatformJobRunStepFromSDK converts the sdk-go type to the mirror. +func DbtPlatformJobRunStepFromSDK(v *sdk.DbtPlatformJobRunStep) (*DbtPlatformJobRunStep, error) { + if v == nil { + return nil, nil + } + out := &DbtPlatformJobRunStep{} + out.Index = v.Index + out.Name = v.Name + out.Status = v.Status + out.Logs = v.Logs + out.NameTruncated = v.NameTruncated + out.LogsTruncated = v.LogsTruncated + return out, nil +} + +// DbtPlatformTaskToSDK converts the mirror to the sdk-go type. +func DbtPlatformTaskToSDK(w *DbtPlatformTask) (*sdk.DbtPlatformTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.DbtPlatformTask{} + out.DbtPlatformJobId = w.DbtPlatformJobId + out.ConnectionResourceName = w.ConnectionResourceName + return out, nil +} + +// DbtPlatformTaskFromSDK converts the sdk-go type to the mirror. +func DbtPlatformTaskFromSDK(v *sdk.DbtPlatformTask) (*DbtPlatformTask, error) { + if v == nil { + return nil, nil + } + out := &DbtPlatformTask{} + out.DbtPlatformJobId = v.DbtPlatformJobId + out.ConnectionResourceName = v.ConnectionResourceName + return out, nil +} + +// DbtPlatformTaskOutputToSDK converts the mirror to the sdk-go type. +func DbtPlatformTaskOutputToSDK(w *DbtPlatformTaskOutput) (*sdk.DbtPlatformTaskOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.DbtPlatformTaskOutput{} + out.DbtPlatformJobRunId = w.DbtPlatformJobRunId + out.DbtPlatformJobRunUrl = w.DbtPlatformJobRunUrl + conv125, err := convertSlice(w.DbtPlatformJobRunOutput, DbtPlatformJobRunStepToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DbtPlatformTaskOutput.DbtPlatformJobRunOutput", err) + } + out.DbtPlatformJobRunOutput = conv125 + out.StepsTruncated = w.StepsTruncated + return out, nil +} + +// DbtPlatformTaskOutputFromSDK converts the sdk-go type to the mirror. +func DbtPlatformTaskOutputFromSDK(v *sdk.DbtPlatformTaskOutput) (*DbtPlatformTaskOutput, error) { + if v == nil { + return nil, nil + } + out := &DbtPlatformTaskOutput{} + out.DbtPlatformJobRunId = v.DbtPlatformJobRunId + out.DbtPlatformJobRunUrl = v.DbtPlatformJobRunUrl + conv126, err := convertSlice(v.DbtPlatformJobRunOutput, DbtPlatformJobRunStepFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DbtPlatformTaskOutput.DbtPlatformJobRunOutput", err) + } + out.DbtPlatformJobRunOutput = conv126 + out.StepsTruncated = v.StepsTruncated + return out, nil +} + +// DbtTaskToSDK converts the mirror to the sdk-go type. +func DbtTaskToSDK(w *DbtTask) (*sdk.DbtTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.DbtTask{} + out.ProjectDirectory = w.ProjectDirectory + out.Commands = w.Commands + out.Schema = w.Schema + out.WarehouseId = w.WarehouseId + out.ProfilesDirectory = w.ProfilesDirectory + out.Catalog = w.Catalog + out.Source = w.Source + return out, nil +} + +// DbtTaskFromSDK converts the sdk-go type to the mirror. +func DbtTaskFromSDK(v *sdk.DbtTask) (*DbtTask, error) { + if v == nil { + return nil, nil + } + out := &DbtTask{} + out.ProjectDirectory = v.ProjectDirectory + out.Commands = v.Commands + out.Schema = v.Schema + out.WarehouseId = v.WarehouseId + out.ProfilesDirectory = v.ProfilesDirectory + out.Catalog = v.Catalog + out.Source = v.Source + return out, nil +} + +// DbtTask_DbtTaskOutputToSDK converts the mirror to the sdk-go type. +func DbtTask_DbtTaskOutputToSDK(w *DbtTask_DbtTaskOutput) (*sdk.DbtTask_DbtTaskOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.DbtTask_DbtTaskOutput{} + out.ArtifactsLink = w.ArtifactsLink + out.ArtifactsHeaders = w.ArtifactsHeaders + return out, nil +} + +// DbtTask_DbtTaskOutputFromSDK converts the sdk-go type to the mirror. +func DbtTask_DbtTaskOutputFromSDK(v *sdk.DbtTask_DbtTaskOutput) (*DbtTask_DbtTaskOutput, error) { + if v == nil { + return nil, nil + } + out := &DbtTask_DbtTaskOutput{} + out.ArtifactsLink = v.ArtifactsLink + out.ArtifactsHeaders = v.ArtifactsHeaders + return out, nil +} + +// DeleteJobRequestToSDK converts the mirror to the sdk-go type. +func DeleteJobRequestToSDK(w *DeleteJobRequest) (*sdk.DeleteJobRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteJobRequest{} + out.JobId = w.JobId + return out, nil +} + +// DeleteJobRequestFromSDK converts the sdk-go type to the mirror. +func DeleteJobRequestFromSDK(v *sdk.DeleteJobRequest) (*DeleteJobRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteJobRequest{} + out.JobId = v.JobId + return out, nil +} + +// DeleteRunRequestToSDK converts the mirror to the sdk-go type. +func DeleteRunRequestToSDK(w *DeleteRunRequest) (*sdk.DeleteRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteRunRequest{} + out.RunId = w.RunId + return out, nil +} + +// DeleteRunRequestFromSDK converts the sdk-go type to the mirror. +func DeleteRunRequestFromSDK(v *sdk.DeleteRunRequest) (*DeleteRunRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteRunRequest{} + out.RunId = v.RunId + return out, nil +} + +// DeploymentSpecToSDK converts the mirror to the sdk-go type. +func DeploymentSpecToSDK(w *DeploymentSpec) (*sdk.DeploymentSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeploymentSpec{} + out.CommandPath = w.CommandPath + conv127, err := ComputeSpecToSDK(w.Compute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeploymentSpec.Compute", err) + } + out.Compute = conv127 + out.Name = w.Name + return out, nil +} + +// DeploymentSpecFromSDK converts the sdk-go type to the mirror. +func DeploymentSpecFromSDK(v *sdk.DeploymentSpec) (*DeploymentSpec, error) { + if v == nil { + return nil, nil + } + out := &DeploymentSpec{} + out.CommandPath = v.CommandPath + conv128, err := ComputeSpecFromSDK(v.Compute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeploymentSpec.Compute", err) + } + out.Compute = conv128 + out.Name = v.Name + return out, nil +} + +// DockerBasicAuthToSDK converts the mirror to the sdk-go type. +func DockerBasicAuthToSDK(w *DockerBasicAuth) (*sdk.DockerBasicAuth, error) { + if w == nil { + return nil, nil + } + out := &sdk.DockerBasicAuth{} + out.Username = w.Username + out.Password = w.Password + return out, nil +} + +// DockerBasicAuthFromSDK converts the sdk-go type to the mirror. +func DockerBasicAuthFromSDK(v *sdk.DockerBasicAuth) (*DockerBasicAuth, error) { + if v == nil { + return nil, nil + } + out := &DockerBasicAuth{} + out.Username = v.Username + out.Password = v.Password + return out, nil +} + +// DockerImageToSDK converts the mirror to the sdk-go type. +func DockerImageToSDK(w *DockerImage) (*sdk.DockerImage, error) { + if w == nil { + return nil, nil + } + out := &sdk.DockerImage{} + out.Url = w.Url + { + var members []string + if w.BasicAuth != nil { + members = append(members, "basic_auth") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.BasicAuth != nil: + conv129, err := DockerBasicAuthToSDK(w.BasicAuth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DockerImage.CredsOneof", err) + } + out.CredsOneof = &sdk.DockerImage_CredsOneof_BasicAuth{BasicAuth: *conv129} + } + return out, nil +} + +// DockerImageFromSDK converts the sdk-go type to the mirror. +func DockerImageFromSDK(v *sdk.DockerImage) (*DockerImage, error) { + if v == nil { + return nil, nil + } + out := &DockerImage{} + out.Url = v.Url + switch value := v.CredsOneof.(type) { + case *sdk.DockerImage_CredsOneof_BasicAuth: + if value != nil { + conv130, err := DockerBasicAuthFromSDK(&value.BasicAuth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DockerImage.CredsOneof", err) + } + out.BasicAuth = conv130 + } + } + return out, nil +} + +// EnforcePolicyComplianceForJobToSDK converts the mirror to the sdk-go type. +func EnforcePolicyComplianceForJobToSDK(w *EnforcePolicyComplianceForJob) (*sdk.EnforcePolicyComplianceForJob, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnforcePolicyComplianceForJob{} + out.JobId = w.JobId + out.ValidateOnly = w.ValidateOnly + return out, nil +} + +// EnforcePolicyComplianceForJobFromSDK converts the sdk-go type to the mirror. +func EnforcePolicyComplianceForJobFromSDK(v *sdk.EnforcePolicyComplianceForJob) (*EnforcePolicyComplianceForJob, error) { + if v == nil { + return nil, nil + } + out := &EnforcePolicyComplianceForJob{} + out.JobId = v.JobId + out.ValidateOnly = v.ValidateOnly + return out, nil +} + +// EnforcePolicyComplianceResponseToSDK converts the mirror to the sdk-go type. +func EnforcePolicyComplianceResponseToSDK(w *EnforcePolicyComplianceResponse) (*sdk.EnforcePolicyComplianceResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnforcePolicyComplianceResponse{} + out.HasChanges = w.HasChanges + conv131, err := convertSlice(w.JobClusterChanges, EnforcePolicyComplianceResponse_JobClusterSettingsChangeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceResponse.JobClusterChanges", err) + } + out.JobClusterChanges = conv131 + conv132, err := JobSettingsToSDK(w.Settings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceResponse.Settings", err) + } + out.Settings = conv132 + return out, nil +} + +// EnforcePolicyComplianceResponseFromSDK converts the sdk-go type to the mirror. +func EnforcePolicyComplianceResponseFromSDK(v *sdk.EnforcePolicyComplianceResponse) (*EnforcePolicyComplianceResponse, error) { + if v == nil { + return nil, nil + } + out := &EnforcePolicyComplianceResponse{} + out.HasChanges = v.HasChanges + conv133, err := convertSlice(v.JobClusterChanges, EnforcePolicyComplianceResponse_JobClusterSettingsChangeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceResponse.JobClusterChanges", err) + } + out.JobClusterChanges = conv133 + conv134, err := JobSettingsFromSDK(v.Settings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnforcePolicyComplianceResponse.Settings", err) + } + out.Settings = conv134 + return out, nil +} + +// EnforcePolicyComplianceResponse_JobClusterSettingsChangeToSDK converts the mirror to the sdk-go type. +func EnforcePolicyComplianceResponse_JobClusterSettingsChangeToSDK(w *EnforcePolicyComplianceResponse_JobClusterSettingsChange) (*sdk.EnforcePolicyComplianceResponse_JobClusterSettingsChange, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnforcePolicyComplianceResponse_JobClusterSettingsChange{} + out.Field = w.Field + out.PreviousValue = w.PreviousValue + out.NewValue = w.NewValue + return out, nil +} + +// EnforcePolicyComplianceResponse_JobClusterSettingsChangeFromSDK converts the sdk-go type to the mirror. +func EnforcePolicyComplianceResponse_JobClusterSettingsChangeFromSDK(v *sdk.EnforcePolicyComplianceResponse_JobClusterSettingsChange) (*EnforcePolicyComplianceResponse_JobClusterSettingsChange, error) { + if v == nil { + return nil, nil + } + out := &EnforcePolicyComplianceResponse_JobClusterSettingsChange{} + out.Field = v.Field + out.PreviousValue = v.PreviousValue + out.NewValue = v.NewValue + return out, nil +} + +// EnvironmentToSDK converts the mirror to the sdk-go type. +func EnvironmentToSDK(w *Environment) (*sdk.Environment, error) { + if w == nil { + return nil, nil + } + out := &sdk.Environment{} + out.Client = w.Client + out.Dependencies = w.Dependencies + out.BaseEnvironment = w.BaseEnvironment + out.EnvironmentVersion = w.EnvironmentVersion + out.JavaDependencies = w.JavaDependencies + out.ProjectEnvironment = w.ProjectEnvironment + return out, nil +} + +// EnvironmentFromSDK converts the sdk-go type to the mirror. +func EnvironmentFromSDK(v *sdk.Environment) (*Environment, error) { + if v == nil { + return nil, nil + } + out := &Environment{} + out.Client = v.Client + out.Dependencies = v.Dependencies + out.BaseEnvironment = v.BaseEnvironment + out.EnvironmentVersion = v.EnvironmentVersion + out.JavaDependencies = v.JavaDependencies + out.ProjectEnvironment = v.ProjectEnvironment + return out, nil +} + +// ExportRunRequestToSDK converts the mirror to the sdk-go type. +func ExportRunRequestToSDK(w *ExportRunRequest) (*sdk.ExportRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExportRunRequest{} + out.RunId = w.RunId + out.ViewsToExport = w.ViewsToExport + return out, nil +} + +// ExportRunRequestFromSDK converts the sdk-go type to the mirror. +func ExportRunRequestFromSDK(v *sdk.ExportRunRequest) (*ExportRunRequest, error) { + if v == nil { + return nil, nil + } + out := &ExportRunRequest{} + out.RunId = v.RunId + out.ViewsToExport = v.ViewsToExport + return out, nil +} + +// ExportRunResponseToSDK converts the mirror to the sdk-go type. +func ExportRunResponseToSDK(w *ExportRunResponse) (*sdk.ExportRunResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExportRunResponse{} + conv135, err := convertSlice(w.Views, ViewItemToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExportRunResponse.Views", err) + } + out.Views = conv135 + return out, nil +} + +// ExportRunResponseFromSDK converts the sdk-go type to the mirror. +func ExportRunResponseFromSDK(v *sdk.ExportRunResponse) (*ExportRunResponse, error) { + if v == nil { + return nil, nil + } + out := &ExportRunResponse{} + conv136, err := convertSlice(v.Views, ViewItemFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExportRunResponse.Views", err) + } + out.Views = conv136 + return out, nil +} + +// FileArrivalTriggerConfigurationToSDK converts the mirror to the sdk-go type. +func FileArrivalTriggerConfigurationToSDK(w *FileArrivalTriggerConfiguration) (*sdk.FileArrivalTriggerConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.FileArrivalTriggerConfiguration{} + out.Url = w.Url + out.MinTimeBetweenTriggersSeconds = w.MinTimeBetweenTriggersSeconds + out.WaitAfterLastChangeSeconds = w.WaitAfterLastChangeSeconds + return out, nil +} + +// FileArrivalTriggerConfigurationFromSDK converts the sdk-go type to the mirror. +func FileArrivalTriggerConfigurationFromSDK(v *sdk.FileArrivalTriggerConfiguration) (*FileArrivalTriggerConfiguration, error) { + if v == nil { + return nil, nil + } + out := &FileArrivalTriggerConfiguration{} + out.Url = v.Url + out.MinTimeBetweenTriggersSeconds = v.MinTimeBetweenTriggersSeconds + out.WaitAfterLastChangeSeconds = v.WaitAfterLastChangeSeconds + return out, nil +} + +// FileArrivalTriggerStateToSDK converts the mirror to the sdk-go type. +func FileArrivalTriggerStateToSDK(w *FileArrivalTriggerState) (*sdk.FileArrivalTriggerState, error) { + if w == nil { + return nil, nil + } + out := &sdk.FileArrivalTriggerState{} + out.UsingFileEvents = w.UsingFileEvents + return out, nil +} + +// FileArrivalTriggerStateFromSDK converts the sdk-go type to the mirror. +func FileArrivalTriggerStateFromSDK(v *sdk.FileArrivalTriggerState) (*FileArrivalTriggerState, error) { + if v == nil { + return nil, nil + } + out := &FileArrivalTriggerState{} + out.UsingFileEvents = v.UsingFileEvents + return out, nil +} + +// ForEachTaskToSDK converts the mirror to the sdk-go type. +func ForEachTaskToSDK(w *ForEachTask) (*sdk.ForEachTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.ForEachTask{} + out.Inputs = w.Inputs + out.Concurrency = w.Concurrency + conv137, err := TaskSettingsToSDK(w.Task) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ForEachTask.Task", err) + } + out.Task = conv137 + return out, nil +} + +// ForEachTaskFromSDK converts the sdk-go type to the mirror. +func ForEachTaskFromSDK(v *sdk.ForEachTask) (*ForEachTask, error) { + if v == nil { + return nil, nil + } + out := &ForEachTask{} + out.Inputs = v.Inputs + out.Concurrency = v.Concurrency + conv138, err := TaskSettingsFromSDK(v.Task) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ForEachTask.Task", err) + } + out.Task = conv138 + return out, nil +} + +// GcpAttributesToSDK converts the mirror to the sdk-go type. +func GcpAttributesToSDK(w *GcpAttributes) (*sdk.GcpAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpAttributes{} + out.UsePreemptibleExecutors = w.UsePreemptibleExecutors + out.GoogleServiceAccount = w.GoogleServiceAccount + out.BootDiskSize = w.BootDiskSize + out.Availability = w.Availability + out.ZoneId = w.ZoneId + out.LocalSsdCount = w.LocalSsdCount + out.FirstOnDemand = w.FirstOnDemand + out.ConfidentialComputeType = w.ConfidentialComputeType + return out, nil +} + +// GcpAttributesFromSDK converts the sdk-go type to the mirror. +func GcpAttributesFromSDK(v *sdk.GcpAttributes) (*GcpAttributes, error) { + if v == nil { + return nil, nil + } + out := &GcpAttributes{} + out.UsePreemptibleExecutors = v.UsePreemptibleExecutors + out.GoogleServiceAccount = v.GoogleServiceAccount + out.BootDiskSize = v.BootDiskSize + out.Availability = v.Availability + out.ZoneId = v.ZoneId + out.LocalSsdCount = v.LocalSsdCount + out.FirstOnDemand = v.FirstOnDemand + out.ConfidentialComputeType = v.ConfidentialComputeType + return out, nil +} + +// GcsStorageInfoToSDK converts the mirror to the sdk-go type. +func GcsStorageInfoToSDK(w *GcsStorageInfo) (*sdk.GcsStorageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcsStorageInfo{} + out.Destination = w.Destination + return out, nil +} + +// GcsStorageInfoFromSDK converts the sdk-go type to the mirror. +func GcsStorageInfoFromSDK(v *sdk.GcsStorageInfo) (*GcsStorageInfo, error) { + if v == nil { + return nil, nil + } + out := &GcsStorageInfo{} + out.Destination = v.Destination + return out, nil +} + +// GenAiComputeTaskToSDK converts the mirror to the sdk-go type. +func GenAiComputeTaskToSDK(w *GenAiComputeTask) (*sdk.GenAiComputeTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenAiComputeTask{} + out.DlRuntimeImage = w.DlRuntimeImage + conv139, err := ComputeConfigToSDK(w.Compute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenAiComputeTask.Compute", err) + } + out.Compute = conv139 + out.Command = w.Command + out.Source = w.Source + out.TrainingScriptPath = w.TrainingScriptPath + out.YamlParametersFilePath = w.YamlParametersFilePath + out.YamlParameters = w.YamlParameters + out.MlflowExperimentName = w.MlflowExperimentName + return out, nil +} + +// GenAiComputeTaskFromSDK converts the sdk-go type to the mirror. +func GenAiComputeTaskFromSDK(v *sdk.GenAiComputeTask) (*GenAiComputeTask, error) { + if v == nil { + return nil, nil + } + out := &GenAiComputeTask{} + out.DlRuntimeImage = v.DlRuntimeImage + conv140, err := ComputeConfigFromSDK(v.Compute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenAiComputeTask.Compute", err) + } + out.Compute = conv140 + out.Command = v.Command + out.Source = v.Source + out.TrainingScriptPath = v.TrainingScriptPath + out.YamlParametersFilePath = v.YamlParametersFilePath + out.YamlParameters = v.YamlParameters + out.MlflowExperimentName = v.MlflowExperimentName + return out, nil +} + +// GetJobRequestToSDK converts the mirror to the sdk-go type. +func GetJobRequestToSDK(w *GetJobRequest) (*sdk.GetJobRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetJobRequest{} + out.JobId = w.JobId + out.IncludeTriggerState = w.IncludeTriggerState + out.PageToken = w.PageToken + return out, nil +} + +// GetJobRequestFromSDK converts the sdk-go type to the mirror. +func GetJobRequestFromSDK(v *sdk.GetJobRequest) (*GetJobRequest, error) { + if v == nil { + return nil, nil + } + out := &GetJobRequest{} + out.JobId = v.JobId + out.IncludeTriggerState = v.IncludeTriggerState + out.PageToken = v.PageToken + return out, nil +} + +// GetJobResponseToSDK converts the mirror to the sdk-go type. +func GetJobResponseToSDK(w *GetJobResponse) (*sdk.GetJobResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetJobResponse{} + out.NextPageToken = w.NextPageToken + out.JobId = w.JobId + out.CreatorUserName = w.CreatorUserName + out.RunAsUserName = w.RunAsUserName + conv141, err := JobSettingsToSDK(w.Settings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetJobResponse.Settings", err) + } + out.Settings = conv141 + out.CreatedTime = w.CreatedTime + conv142, err := TriggerStateToSDK(w.TriggerState) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetJobResponse.TriggerState", err) + } + out.TriggerState = conv142 + out.HasMore = w.HasMore + out.EffectiveBudgetPolicyId = w.EffectiveBudgetPolicyId + out.EffectiveUsagePolicyId = w.EffectiveUsagePolicyId + conv143, err := convertSlice(w.TriggerDetails, TriggerDetailsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetJobResponse.TriggerDetails", err) + } + out.TriggerDetails = conv143 + return out, nil +} + +// GetJobResponseFromSDK converts the sdk-go type to the mirror. +func GetJobResponseFromSDK(v *sdk.GetJobResponse) (*GetJobResponse, error) { + if v == nil { + return nil, nil + } + out := &GetJobResponse{} + out.NextPageToken = v.NextPageToken + out.JobId = v.JobId + out.CreatorUserName = v.CreatorUserName + out.RunAsUserName = v.RunAsUserName + conv144, err := JobSettingsFromSDK(v.Settings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetJobResponse.Settings", err) + } + out.Settings = conv144 + out.CreatedTime = v.CreatedTime + conv145, err := TriggerStateFromSDK(v.TriggerState) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetJobResponse.TriggerState", err) + } + out.TriggerState = conv145 + out.HasMore = v.HasMore + out.EffectiveBudgetPolicyId = v.EffectiveBudgetPolicyId + out.EffectiveUsagePolicyId = v.EffectiveUsagePolicyId + conv146, err := convertSlice(v.TriggerDetails, TriggerDetailsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetJobResponse.TriggerDetails", err) + } + out.TriggerDetails = conv146 + return out, nil +} + +// GetPolicyComplianceForJobRequestToSDK converts the mirror to the sdk-go type. +func GetPolicyComplianceForJobRequestToSDK(w *GetPolicyComplianceForJobRequest) (*sdk.GetPolicyComplianceForJobRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPolicyComplianceForJobRequest{} + out.JobId = w.JobId + return out, nil +} + +// GetPolicyComplianceForJobRequestFromSDK converts the sdk-go type to the mirror. +func GetPolicyComplianceForJobRequestFromSDK(v *sdk.GetPolicyComplianceForJobRequest) (*GetPolicyComplianceForJobRequest, error) { + if v == nil { + return nil, nil + } + out := &GetPolicyComplianceForJobRequest{} + out.JobId = v.JobId + return out, nil +} + +// GetPolicyComplianceForJobResponseToSDK converts the mirror to the sdk-go type. +func GetPolicyComplianceForJobResponseToSDK(w *GetPolicyComplianceForJobResponse) (*sdk.GetPolicyComplianceForJobResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPolicyComplianceForJobResponse{} + out.IsCompliant = w.IsCompliant + out.Violations = w.Violations + return out, nil +} + +// GetPolicyComplianceForJobResponseFromSDK converts the sdk-go type to the mirror. +func GetPolicyComplianceForJobResponseFromSDK(v *sdk.GetPolicyComplianceForJobResponse) (*GetPolicyComplianceForJobResponse, error) { + if v == nil { + return nil, nil + } + out := &GetPolicyComplianceForJobResponse{} + out.IsCompliant = v.IsCompliant + out.Violations = v.Violations + return out, nil +} + +// GetRunOutputRequestToSDK converts the mirror to the sdk-go type. +func GetRunOutputRequestToSDK(w *GetRunOutputRequest) (*sdk.GetRunOutputRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetRunOutputRequest{} + out.RunId = w.RunId + return out, nil +} + +// GetRunOutputRequestFromSDK converts the sdk-go type to the mirror. +func GetRunOutputRequestFromSDK(v *sdk.GetRunOutputRequest) (*GetRunOutputRequest, error) { + if v == nil { + return nil, nil + } + out := &GetRunOutputRequest{} + out.RunId = v.RunId + return out, nil +} + +// GetRunOutputResponseToSDK converts the mirror to the sdk-go type. +func GetRunOutputResponseToSDK(w *GetRunOutputResponse) (*sdk.GetRunOutputResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetRunOutputResponse{} + conv147, err := RunToSDK(w.Metadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Metadata", err) + } + out.Metadata = conv147 + out.Error = w.Error + out.Info = w.Info + { + var members []string + if w.NotebookOutput != nil { + members = append(members, "notebook_output") + } + if w.SqlOutput != nil { + members = append(members, "sql_output") + } + if w.DbtOutput != nil { + members = append(members, "dbt_output") + } + if w.RunJobOutput != nil { + members = append(members, "run_job_output") + } + if w.CleanRoomsNotebookOutput != nil { + members = append(members, "clean_rooms_notebook_output") + } + if w.DashboardOutput != nil { + members = append(members, "dashboard_output") + } + if w.DbtCloudOutput != nil { + members = append(members, "dbt_cloud_output") + } + if w.DbtPlatformOutput != nil { + members = append(members, "dbt_platform_output") + } + if w.AlertOutput != nil { + members = append(members, "alert_output") + } + if w.AiRuntimeTaskOutput != nil { + members = append(members, "ai_runtime_task_output") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NotebookOutput != nil: + conv148, err := NotebookTask_NotebookOutputToSDK(w.NotebookOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.Result = &sdk.GetRunOutputResponse_Result_NotebookOutput{NotebookOutput: *conv148} + case w.SqlOutput != nil: + conv149, err := SqlTask_SqlOutputToSDK(w.SqlOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.Result = &sdk.GetRunOutputResponse_Result_SqlOutput{SqlOutput: *conv149} + case w.DbtOutput != nil: + conv150, err := DbtTask_DbtTaskOutputToSDK(w.DbtOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.Result = &sdk.GetRunOutputResponse_Result_DbtOutput{DbtOutput: *conv150} + case w.RunJobOutput != nil: + conv151, err := RunJobTask_RunJobTaskOutputToSDK(w.RunJobOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.Result = &sdk.GetRunOutputResponse_Result_RunJobOutput{RunJobOutput: *conv151} + case w.CleanRoomsNotebookOutput != nil: + conv152, err := CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutputToSDK(w.CleanRoomsNotebookOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.Result = &sdk.GetRunOutputResponse_Result_CleanRoomsNotebookOutput{CleanRoomsNotebookOutput: *conv152} + case w.DashboardOutput != nil: + conv153, err := DashboardTaskOutputToSDK(w.DashboardOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.Result = &sdk.GetRunOutputResponse_Result_DashboardOutput{DashboardOutput: *conv153} + case w.DbtCloudOutput != nil: + conv154, err := DbtCloudTaskOutputToSDK(w.DbtCloudOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.Result = &sdk.GetRunOutputResponse_Result_DbtCloudOutput{DbtCloudOutput: *conv154} + case w.DbtPlatformOutput != nil: + conv155, err := DbtPlatformTaskOutputToSDK(w.DbtPlatformOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.Result = &sdk.GetRunOutputResponse_Result_DbtPlatformOutput{DbtPlatformOutput: *conv155} + case w.AlertOutput != nil: + conv156, err := AlertTaskOutputToSDK(w.AlertOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.Result = &sdk.GetRunOutputResponse_Result_AlertOutput{AlertOutput: *conv156} + case w.AiRuntimeTaskOutput != nil: + conv157, err := AiRuntimeTaskOutputToSDK(w.AiRuntimeTaskOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.Result = &sdk.GetRunOutputResponse_Result_AiRuntimeTaskOutput{AiRuntimeTaskOutput: *conv157} + } + out.Logs = w.Logs + out.LogsTruncated = w.LogsTruncated + out.ErrorTrace = w.ErrorTrace + return out, nil +} + +// GetRunOutputResponseFromSDK converts the sdk-go type to the mirror. +func GetRunOutputResponseFromSDK(v *sdk.GetRunOutputResponse) (*GetRunOutputResponse, error) { + if v == nil { + return nil, nil + } + out := &GetRunOutputResponse{} + conv158, err := RunFromSDK(v.Metadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Metadata", err) + } + out.Metadata = conv158 + out.Error = v.Error + out.Info = v.Info + switch value := v.Result.(type) { + case *sdk.GetRunOutputResponse_Result_NotebookOutput: + if value != nil { + conv159, err := NotebookTask_NotebookOutputFromSDK(&value.NotebookOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.NotebookOutput = conv159 + } + case *sdk.GetRunOutputResponse_Result_SqlOutput: + if value != nil { + conv160, err := SqlTask_SqlOutputFromSDK(&value.SqlOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.SqlOutput = conv160 + } + case *sdk.GetRunOutputResponse_Result_DbtOutput: + if value != nil { + conv161, err := DbtTask_DbtTaskOutputFromSDK(&value.DbtOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.DbtOutput = conv161 + } + case *sdk.GetRunOutputResponse_Result_RunJobOutput: + if value != nil { + conv162, err := RunJobTask_RunJobTaskOutputFromSDK(&value.RunJobOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.RunJobOutput = conv162 + } + case *sdk.GetRunOutputResponse_Result_CleanRoomsNotebookOutput: + if value != nil { + conv163, err := CleanRoomsNotebookTask_CleanRoomsNotebookTaskOutputFromSDK(&value.CleanRoomsNotebookOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.CleanRoomsNotebookOutput = conv163 + } + case *sdk.GetRunOutputResponse_Result_DashboardOutput: + if value != nil { + conv164, err := DashboardTaskOutputFromSDK(&value.DashboardOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.DashboardOutput = conv164 + } + case *sdk.GetRunOutputResponse_Result_DbtCloudOutput: + if value != nil { + conv165, err := DbtCloudTaskOutputFromSDK(&value.DbtCloudOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.DbtCloudOutput = conv165 + } + case *sdk.GetRunOutputResponse_Result_DbtPlatformOutput: + if value != nil { + conv166, err := DbtPlatformTaskOutputFromSDK(&value.DbtPlatformOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.DbtPlatformOutput = conv166 + } + case *sdk.GetRunOutputResponse_Result_AlertOutput: + if value != nil { + conv167, err := AlertTaskOutputFromSDK(&value.AlertOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.AlertOutput = conv167 + } + case *sdk.GetRunOutputResponse_Result_AiRuntimeTaskOutput: + if value != nil { + conv168, err := AiRuntimeTaskOutputFromSDK(&value.AiRuntimeTaskOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunOutputResponse.Result", err) + } + out.AiRuntimeTaskOutput = conv168 + } + } + out.Logs = v.Logs + out.LogsTruncated = v.LogsTruncated + out.ErrorTrace = v.ErrorTrace + return out, nil +} + +// GetRunRequestToSDK converts the mirror to the sdk-go type. +func GetRunRequestToSDK(w *GetRunRequest) (*sdk.GetRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetRunRequest{} + out.RunId = w.RunId + out.IncludeHistory = w.IncludeHistory + out.IncludeResolvedValues = w.IncludeResolvedValues + out.PageToken = w.PageToken + return out, nil +} + +// GetRunRequestFromSDK converts the sdk-go type to the mirror. +func GetRunRequestFromSDK(v *sdk.GetRunRequest) (*GetRunRequest, error) { + if v == nil { + return nil, nil + } + out := &GetRunRequest{} + out.RunId = v.RunId + out.IncludeHistory = v.IncludeHistory + out.IncludeResolvedValues = v.IncludeResolvedValues + out.PageToken = v.PageToken + return out, nil +} + +// GetRunResponseToSDK converts the mirror to the sdk-go type. +func GetRunResponseToSDK(w *GetRunResponse) (*sdk.GetRunResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetRunResponse{} + out.NextPageToken = w.NextPageToken + out.JobId = w.JobId + out.RunId = w.RunId + out.CreatorUserName = w.CreatorUserName + out.NumberInJob = w.NumberInJob + out.OriginalAttemptRunId = w.OriginalAttemptRunId + conv169, err := RunStateToSDK(w.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.State", err) + } + out.State = conv169 + conv170, err := CronScheduleToSDK(w.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.Schedule", err) + } + out.Schedule = conv170 + conv171, err := ClusterSpecToSDK(w.ClusterSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.ClusterSpec", err) + } + out.ClusterSpec = conv171 + conv172, err := ClusterInstanceToSDK(w.ClusterInstance) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.ClusterInstance", err) + } + out.ClusterInstance = conv172 + conv173, err := convertSlice(w.JobParameters, Run_JobLevelParametersToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.JobParameters", err) + } + out.JobParameters = conv173 + conv174, err := RunParametersToSDK(w.OverridingParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.OverridingParameters", err) + } + out.OverridingParameters = conv174 + out.Trigger = w.Trigger + conv175, err := RunTriggerInfoToSDK(w.TriggerInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.TriggerInfo", err) + } + out.TriggerInfo = conv175 + out.RunName = w.RunName + out.RunPageUrl = w.RunPageUrl + out.RunType = w.RunType + conv176, err := convertSlice(w.Tasks, RunTaskToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.Tasks", err) + } + out.Tasks = conv176 + out.Description = w.Description + out.AttemptNumber = w.AttemptNumber + conv177, err := convertSlice(w.JobClusters, JobClusterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.JobClusters", err) + } + out.JobClusters = conv177 + conv178, err := GitSourceToSDK(w.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.GitSource", err) + } + out.GitSource = conv178 + conv179, err := convertSlice(w.RepairHistory, RepairToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.RepairHistory", err) + } + out.RepairHistory = conv179 + conv180, err := RunStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.Status", err) + } + out.Status = conv180 + out.JobRunId = w.JobRunId + out.HasMore = w.HasMore + out.EffectivePerformanceTarget = w.EffectivePerformanceTarget + out.EffectiveUsagePolicyId = w.EffectiveUsagePolicyId + conv181, err := convertSlice(w.EnvironmentVariables, JobEnvironmentVariablesToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.EnvironmentVariables", err) + } + out.EnvironmentVariables = conv181 + out.DeploymentId = w.DeploymentId + out.VersionId = w.VersionId + out.StartTime = w.StartTime + out.SetupDuration = w.SetupDuration + out.ExecutionDuration = w.ExecutionDuration + out.CleanupDuration = w.CleanupDuration + out.EndTime = w.EndTime + out.RunDuration = w.RunDuration + out.QueueDuration = w.QueueDuration + return out, nil +} + +// GetRunResponseFromSDK converts the sdk-go type to the mirror. +func GetRunResponseFromSDK(v *sdk.GetRunResponse) (*GetRunResponse, error) { + if v == nil { + return nil, nil + } + out := &GetRunResponse{} + out.NextPageToken = v.NextPageToken + out.JobId = v.JobId + out.RunId = v.RunId + out.CreatorUserName = v.CreatorUserName + out.NumberInJob = v.NumberInJob + out.OriginalAttemptRunId = v.OriginalAttemptRunId + conv182, err := RunStateFromSDK(v.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.State", err) + } + out.State = conv182 + conv183, err := CronScheduleFromSDK(v.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.Schedule", err) + } + out.Schedule = conv183 + conv184, err := ClusterSpecFromSDK(v.ClusterSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.ClusterSpec", err) + } + out.ClusterSpec = conv184 + conv185, err := ClusterInstanceFromSDK(v.ClusterInstance) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.ClusterInstance", err) + } + out.ClusterInstance = conv185 + conv186, err := convertSlice(v.JobParameters, Run_JobLevelParametersFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.JobParameters", err) + } + out.JobParameters = conv186 + conv187, err := RunParametersFromSDK(v.OverridingParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.OverridingParameters", err) + } + out.OverridingParameters = conv187 + out.Trigger = v.Trigger + conv188, err := RunTriggerInfoFromSDK(v.TriggerInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.TriggerInfo", err) + } + out.TriggerInfo = conv188 + out.RunName = v.RunName + out.RunPageUrl = v.RunPageUrl + out.RunType = v.RunType + conv189, err := convertSlice(v.Tasks, RunTaskFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.Tasks", err) + } + out.Tasks = conv189 + out.Description = v.Description + out.AttemptNumber = v.AttemptNumber + conv190, err := convertSlice(v.JobClusters, JobClusterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.JobClusters", err) + } + out.JobClusters = conv190 + conv191, err := GitSourceFromSDK(v.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.GitSource", err) + } + out.GitSource = conv191 + conv192, err := convertSlice(v.RepairHistory, RepairFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.RepairHistory", err) + } + out.RepairHistory = conv192 + conv193, err := RunStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.Status", err) + } + out.Status = conv193 + out.JobRunId = v.JobRunId + out.HasMore = v.HasMore + out.EffectivePerformanceTarget = v.EffectivePerformanceTarget + out.EffectiveUsagePolicyId = v.EffectiveUsagePolicyId + conv194, err := convertSlice(v.EnvironmentVariables, JobEnvironmentVariablesFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRunResponse.EnvironmentVariables", err) + } + out.EnvironmentVariables = conv194 + out.DeploymentId = v.DeploymentId + out.VersionId = v.VersionId + out.StartTime = v.StartTime + out.SetupDuration = v.SetupDuration + out.ExecutionDuration = v.ExecutionDuration + out.CleanupDuration = v.CleanupDuration + out.EndTime = v.EndTime + out.RunDuration = v.RunDuration + out.QueueDuration = v.QueueDuration + return out, nil +} + +// GitMetadataSnapshotToSDK converts the mirror to the sdk-go type. +func GitMetadataSnapshotToSDK(w *GitMetadataSnapshot) (*sdk.GitMetadataSnapshot, error) { + if w == nil { + return nil, nil + } + out := &sdk.GitMetadataSnapshot{} + out.UsedCommit = w.UsedCommit + return out, nil +} + +// GitMetadataSnapshotFromSDK converts the sdk-go type to the mirror. +func GitMetadataSnapshotFromSDK(v *sdk.GitMetadataSnapshot) (*GitMetadataSnapshot, error) { + if v == nil { + return nil, nil + } + out := &GitMetadataSnapshot{} + out.UsedCommit = v.UsedCommit + return out, nil +} + +// GitSourceToSDK converts the mirror to the sdk-go type. +func GitSourceToSDK(w *GitSource) (*sdk.GitSource, error) { + if w == nil { + return nil, nil + } + out := &sdk.GitSource{} + out.GitUrl = w.GitUrl + out.GitProvider = w.GitProvider + { + var members []string + if w.GitBranch != nil { + members = append(members, "git_branch") + } + if w.GitTag != nil { + members = append(members, "git_tag") + } + if w.GitCommit != nil { + members = append(members, "git_commit") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.GitBranch != nil: + out.GitReference = &sdk.GitSource_GitReference_GitBranch{GitBranch: *w.GitBranch} + case w.GitTag != nil: + out.GitReference = &sdk.GitSource_GitReference_GitTag{GitTag: *w.GitTag} + case w.GitCommit != nil: + out.GitReference = &sdk.GitSource_GitReference_GitCommit{GitCommit: *w.GitCommit} + } + conv195, err := GitMetadataSnapshotToSDK(w.GitSnapshot) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GitSource.GitSnapshot", err) + } + out.GitSnapshot = conv195 + conv196, err := JobSourceToSDK(w.JobSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GitSource.JobSource", err) + } + out.JobSource = conv196 + conv197, err := SparseCheckoutToSDK(w.SparseCheckout) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GitSource.SparseCheckout", err) + } + out.SparseCheckout = conv197 + return out, nil +} + +// GitSourceFromSDK converts the sdk-go type to the mirror. +func GitSourceFromSDK(v *sdk.GitSource) (*GitSource, error) { + if v == nil { + return nil, nil + } + out := &GitSource{} + out.GitUrl = v.GitUrl + out.GitProvider = v.GitProvider + switch value := v.GitReference.(type) { + case *sdk.GitSource_GitReference_GitBranch: + if value != nil { + out.GitBranch = new(value.GitBranch) + } + case *sdk.GitSource_GitReference_GitTag: + if value != nil { + out.GitTag = new(value.GitTag) + } + case *sdk.GitSource_GitReference_GitCommit: + if value != nil { + out.GitCommit = new(value.GitCommit) + } + } + conv198, err := GitMetadataSnapshotFromSDK(v.GitSnapshot) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GitSource.GitSnapshot", err) + } + out.GitSnapshot = conv198 + conv199, err := JobSourceFromSDK(v.JobSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GitSource.JobSource", err) + } + out.JobSource = conv199 + conv200, err := SparseCheckoutFromSDK(v.SparseCheckout) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GitSource.SparseCheckout", err) + } + out.SparseCheckout = conv200 + return out, nil +} + +// InitScriptInfoToSDK converts the mirror to the sdk-go type. +func InitScriptInfoToSDK(w *InitScriptInfo) (*sdk.InitScriptInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.InitScriptInfo{} + { + var members []string + if w.Dbfs != nil { + members = append(members, "dbfs") + } + if w.S3 != nil { + members = append(members, "s3") + } + if w.File != nil { + members = append(members, "file") + } + if w.Gcs != nil { + members = append(members, "gcs") + } + if w.Abfss != nil { + members = append(members, "abfss") + } + if w.Workspace != nil { + members = append(members, "workspace") + } + if w.Volumes != nil { + members = append(members, "volumes") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Dbfs != nil: + conv201, err := DbfsStorageInfoToSDK(w.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_Dbfs{Dbfs: *conv201} + case w.S3 != nil: + conv202, err := S3StorageInfoToSDK(w.S3) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_S3{S3: *conv202} + case w.File != nil: + conv203, err := LocalFileInfoToSDK(w.File) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_File{File: *conv203} + case w.Gcs != nil: + conv204, err := GcsStorageInfoToSDK(w.Gcs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_Gcs{Gcs: *conv204} + case w.Abfss != nil: + conv205, err := Adlsgen2InfoToSDK(w.Abfss) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_Abfss{Abfss: *conv205} + case w.Workspace != nil: + conv206, err := WorkspaceStorageInfoToSDK(w.Workspace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_Workspace{Workspace: *conv206} + case w.Volumes != nil: + conv207, err := VolumesStorageInfoToSDK(w.Volumes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.InitScriptInfo_StorageInfo_Volumes{Volumes: *conv207} + } + return out, nil +} + +// InitScriptInfoFromSDK converts the sdk-go type to the mirror. +func InitScriptInfoFromSDK(v *sdk.InitScriptInfo) (*InitScriptInfo, error) { + if v == nil { + return nil, nil + } + out := &InitScriptInfo{} + switch value := v.StorageInfo.(type) { + case *sdk.InitScriptInfo_StorageInfo_Dbfs: + if value != nil { + conv208, err := DbfsStorageInfoFromSDK(&value.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.Dbfs = conv208 + } + case *sdk.InitScriptInfo_StorageInfo_S3: + if value != nil { + conv209, err := S3StorageInfoFromSDK(&value.S3) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.S3 = conv209 + } + case *sdk.InitScriptInfo_StorageInfo_File: + if value != nil { + conv210, err := LocalFileInfoFromSDK(&value.File) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.File = conv210 + } + case *sdk.InitScriptInfo_StorageInfo_Gcs: + if value != nil { + conv211, err := GcsStorageInfoFromSDK(&value.Gcs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.Gcs = conv211 + } + case *sdk.InitScriptInfo_StorageInfo_Abfss: + if value != nil { + conv212, err := Adlsgen2InfoFromSDK(&value.Abfss) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.Abfss = conv212 + } + case *sdk.InitScriptInfo_StorageInfo_Workspace: + if value != nil { + conv213, err := WorkspaceStorageInfoFromSDK(&value.Workspace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.Workspace = conv213 + } + case *sdk.InitScriptInfo_StorageInfo_Volumes: + if value != nil { + conv214, err := VolumesStorageInfoFromSDK(&value.Volumes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitScriptInfo.StorageInfo", err) + } + out.Volumes = conv214 + } + } + return out, nil +} + +// JobClusterToSDK converts the mirror to the sdk-go type. +func JobClusterToSDK(w *JobCluster) (*sdk.JobCluster, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobCluster{} + out.JobClusterKey = w.JobClusterKey + conv215, err := ClusterSpec_NewClusterToSDK(w.NewCluster) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobCluster.NewCluster", err) + } + out.NewCluster = conv215 + out.ServerlessComputeId = w.ServerlessComputeId + return out, nil +} + +// JobClusterFromSDK converts the sdk-go type to the mirror. +func JobClusterFromSDK(v *sdk.JobCluster) (*JobCluster, error) { + if v == nil { + return nil, nil + } + out := &JobCluster{} + out.JobClusterKey = v.JobClusterKey + conv216, err := ClusterSpec_NewClusterFromSDK(v.NewCluster) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobCluster.NewCluster", err) + } + out.NewCluster = conv216 + out.ServerlessComputeId = v.ServerlessComputeId + return out, nil +} + +// JobDeploymentToSDK converts the mirror to the sdk-go type. +func JobDeploymentToSDK(w *JobDeployment) (*sdk.JobDeployment, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobDeployment{} + out.Kind = w.Kind + out.MetadataFilePath = w.MetadataFilePath + out.DeploymentId = w.DeploymentId + out.VersionId = w.VersionId + return out, nil +} + +// JobDeploymentFromSDK converts the sdk-go type to the mirror. +func JobDeploymentFromSDK(v *sdk.JobDeployment) (*JobDeployment, error) { + if v == nil { + return nil, nil + } + out := &JobDeployment{} + out.Kind = v.Kind + out.MetadataFilePath = v.MetadataFilePath + out.DeploymentId = v.DeploymentId + out.VersionId = v.VersionId + return out, nil +} + +// JobEmailNotificationsToSDK converts the mirror to the sdk-go type. +func JobEmailNotificationsToSDK(w *JobEmailNotifications) (*sdk.JobEmailNotifications, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobEmailNotifications{} + out.OnStart = w.OnStart + out.OnSuccess = w.OnSuccess + out.OnFailure = w.OnFailure + out.OnDurationWarningThresholdExceeded = w.OnDurationWarningThresholdExceeded + out.OnStreamingBacklogExceeded = w.OnStreamingBacklogExceeded + out.OnMaintenanceStart = w.OnMaintenanceStart + out.OnMaintenanceComplete = w.OnMaintenanceComplete + out.NoAlertForSkippedRuns = w.NoAlertForSkippedRuns + return out, nil +} + +// JobEmailNotificationsFromSDK converts the sdk-go type to the mirror. +func JobEmailNotificationsFromSDK(v *sdk.JobEmailNotifications) (*JobEmailNotifications, error) { + if v == nil { + return nil, nil + } + out := &JobEmailNotifications{} + out.OnStart = v.OnStart + out.OnSuccess = v.OnSuccess + out.OnFailure = v.OnFailure + out.OnDurationWarningThresholdExceeded = v.OnDurationWarningThresholdExceeded + out.OnStreamingBacklogExceeded = v.OnStreamingBacklogExceeded + out.OnMaintenanceStart = v.OnMaintenanceStart + out.OnMaintenanceComplete = v.OnMaintenanceComplete + out.NoAlertForSkippedRuns = v.NoAlertForSkippedRuns + return out, nil +} + +// JobEnvironmentToSDK converts the mirror to the sdk-go type. +func JobEnvironmentToSDK(w *JobEnvironment) (*sdk.JobEnvironment, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobEnvironment{} + out.EnvironmentKey = w.EnvironmentKey + conv217, err := EnvironmentToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobEnvironment.Spec", err) + } + out.Spec = conv217 + return out, nil +} + +// JobEnvironmentFromSDK converts the sdk-go type to the mirror. +func JobEnvironmentFromSDK(v *sdk.JobEnvironment) (*JobEnvironment, error) { + if v == nil { + return nil, nil + } + out := &JobEnvironment{} + out.EnvironmentKey = v.EnvironmentKey + conv218, err := EnvironmentFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobEnvironment.Spec", err) + } + out.Spec = conv218 + return out, nil +} + +// JobEnvironmentVariablesToSDK converts the mirror to the sdk-go type. +func JobEnvironmentVariablesToSDK(w *JobEnvironmentVariables) (*sdk.JobEnvironmentVariables, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobEnvironmentVariables{} + out.EnvironmentVariablesKey = w.EnvironmentVariablesKey + conv219, err := JobEnvironmentVariablesSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobEnvironmentVariables.Spec", err) + } + out.Spec = conv219 + return out, nil +} + +// JobEnvironmentVariablesFromSDK converts the sdk-go type to the mirror. +func JobEnvironmentVariablesFromSDK(v *sdk.JobEnvironmentVariables) (*JobEnvironmentVariables, error) { + if v == nil { + return nil, nil + } + out := &JobEnvironmentVariables{} + out.EnvironmentVariablesKey = v.EnvironmentVariablesKey + conv220, err := JobEnvironmentVariablesSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobEnvironmentVariables.Spec", err) + } + out.Spec = conv220 + return out, nil +} + +// JobEnvironmentVariablesSpecToSDK converts the mirror to the sdk-go type. +func JobEnvironmentVariablesSpecToSDK(w *JobEnvironmentVariablesSpec) (*sdk.JobEnvironmentVariablesSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobEnvironmentVariablesSpec{} + out.Variables = w.Variables + out.Files = w.Files + return out, nil +} + +// JobEnvironmentVariablesSpecFromSDK converts the sdk-go type to the mirror. +func JobEnvironmentVariablesSpecFromSDK(v *sdk.JobEnvironmentVariablesSpec) (*JobEnvironmentVariablesSpec, error) { + if v == nil { + return nil, nil + } + out := &JobEnvironmentVariablesSpec{} + out.Variables = v.Variables + out.Files = v.Files + return out, nil +} + +// JobLevelParameterToSDK converts the mirror to the sdk-go type. +func JobLevelParameterToSDK(w *JobLevelParameter) (*sdk.JobLevelParameter, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobLevelParameter{} + out.Name = w.Name + out.Default = w.Default + return out, nil +} + +// JobLevelParameterFromSDK converts the sdk-go type to the mirror. +func JobLevelParameterFromSDK(v *sdk.JobLevelParameter) (*JobLevelParameter, error) { + if v == nil { + return nil, nil + } + out := &JobLevelParameter{} + out.Name = v.Name + out.Default = v.Default + return out, nil +} + +// JobRunAsToSDK converts the mirror to the sdk-go type. +func JobRunAsToSDK(w *JobRunAs) (*sdk.JobRunAs, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobRunAs{} + { + var members []string + if w.UserName != nil { + members = append(members, "user_name") + } + if w.ServicePrincipalName != nil { + members = append(members, "service_principal_name") + } + if w.GroupName != nil { + members = append(members, "group_name") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UserName != nil: + out.Identity = &sdk.JobRunAs_Identity_UserName{UserName: *w.UserName} + case w.ServicePrincipalName != nil: + out.Identity = &sdk.JobRunAs_Identity_ServicePrincipalName{ServicePrincipalName: *w.ServicePrincipalName} + case w.GroupName != nil: + out.Identity = &sdk.JobRunAs_Identity_GroupName{GroupName: *w.GroupName} + } + return out, nil +} + +// JobRunAsFromSDK converts the sdk-go type to the mirror. +func JobRunAsFromSDK(v *sdk.JobRunAs) (*JobRunAs, error) { + if v == nil { + return nil, nil + } + out := &JobRunAs{} + switch value := v.Identity.(type) { + case *sdk.JobRunAs_Identity_UserName: + if value != nil { + out.UserName = new(value.UserName) + } + case *sdk.JobRunAs_Identity_ServicePrincipalName: + if value != nil { + out.ServicePrincipalName = new(value.ServicePrincipalName) + } + case *sdk.JobRunAs_Identity_GroupName: + if value != nil { + out.GroupName = new(value.GroupName) + } + } + return out, nil +} + +// JobSettingsToSDK converts the mirror to the sdk-go type. +func JobSettingsToSDK(w *JobSettings) (*sdk.JobSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobSettings{} + out.Name = w.Name + out.Description = w.Description + conv221, err := JobEmailNotificationsToSDK(w.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.EmailNotifications", err) + } + out.EmailNotifications = conv221 + conv222, err := WebhookNotificationsToSDK(w.WebhookNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.WebhookNotifications", err) + } + out.WebhookNotifications = conv222 + conv223, err := NotificationSettingsToSDK(w.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.NotificationSettings", err) + } + out.NotificationSettings = conv223 + out.TimeoutSeconds = w.TimeoutSeconds + conv224, err := JobsHealthRulesToSDK(w.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Health", err) + } + out.Health = conv224 + conv225, err := CronScheduleToSDK(w.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Schedule", err) + } + out.Schedule = conv225 + conv226, err := TriggerSettingsToSDK(w.Trigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Trigger", err) + } + out.Trigger = conv226 + conv227, err := ContinuousSettingsToSDK(w.Continuous) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Continuous", err) + } + out.Continuous = conv227 + out.MaxConcurrentRuns = w.MaxConcurrentRuns + conv228, err := convertSlice(w.Tasks, TaskSettingsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Tasks", err) + } + out.Tasks = conv228 + conv229, err := convertSlice(w.JobClusters, JobClusterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.JobClusters", err) + } + out.JobClusters = conv229 + conv230, err := GitSourceToSDK(w.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.GitSource", err) + } + out.GitSource = conv230 + out.Tags = w.Tags + out.Format = w.Format + conv231, err := QueueSettingsToSDK(w.Queue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Queue", err) + } + out.Queue = conv231 + conv232, err := convertSlice(w.Parameters, JobLevelParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Parameters", err) + } + out.Parameters = conv232 + conv233, err := JobRunAsToSDK(w.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.RunAs", err) + } + out.RunAs = conv233 + out.EditMode = w.EditMode + conv234, err := JobDeploymentToSDK(w.Deployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Deployment", err) + } + out.Deployment = conv234 + conv235, err := convertSlice(w.Environments, JobEnvironmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Environments", err) + } + out.Environments = conv235 + out.BudgetPolicyId = w.BudgetPolicyId + out.UsagePolicyId = w.UsagePolicyId + out.PerformanceTarget = w.PerformanceTarget + out.ParentPath = w.ParentPath + conv236, err := convertSlice(w.Triggers, TriggerConfigurationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Triggers", err) + } + out.Triggers = conv236 + conv237, err := convertSlice(w.EnvironmentVariables, JobEnvironmentVariablesToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.EnvironmentVariables", err) + } + out.EnvironmentVariables = conv237 + out.MaxRetries = w.MaxRetries + out.MinRetryIntervalMillis = w.MinRetryIntervalMillis + out.RetryOnTimeout = w.RetryOnTimeout + out.DisableAutoOptimization = w.DisableAutoOptimization + return out, nil +} + +// JobSettingsFromSDK converts the sdk-go type to the mirror. +func JobSettingsFromSDK(v *sdk.JobSettings) (*JobSettings, error) { + if v == nil { + return nil, nil + } + out := &JobSettings{} + out.Name = v.Name + out.Description = v.Description + conv238, err := JobEmailNotificationsFromSDK(v.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.EmailNotifications", err) + } + out.EmailNotifications = conv238 + conv239, err := WebhookNotificationsFromSDK(v.WebhookNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.WebhookNotifications", err) + } + out.WebhookNotifications = conv239 + conv240, err := NotificationSettingsFromSDK(v.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.NotificationSettings", err) + } + out.NotificationSettings = conv240 + out.TimeoutSeconds = v.TimeoutSeconds + conv241, err := JobsHealthRulesFromSDK(v.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Health", err) + } + out.Health = conv241 + conv242, err := CronScheduleFromSDK(v.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Schedule", err) + } + out.Schedule = conv242 + conv243, err := TriggerSettingsFromSDK(v.Trigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Trigger", err) + } + out.Trigger = conv243 + conv244, err := ContinuousSettingsFromSDK(v.Continuous) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Continuous", err) + } + out.Continuous = conv244 + out.MaxConcurrentRuns = v.MaxConcurrentRuns + conv245, err := convertSlice(v.Tasks, TaskSettingsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Tasks", err) + } + out.Tasks = conv245 + conv246, err := convertSlice(v.JobClusters, JobClusterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.JobClusters", err) + } + out.JobClusters = conv246 + conv247, err := GitSourceFromSDK(v.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.GitSource", err) + } + out.GitSource = conv247 + out.Tags = v.Tags + out.Format = v.Format + conv248, err := QueueSettingsFromSDK(v.Queue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Queue", err) + } + out.Queue = conv248 + conv249, err := convertSlice(v.Parameters, JobLevelParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Parameters", err) + } + out.Parameters = conv249 + conv250, err := JobRunAsFromSDK(v.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.RunAs", err) + } + out.RunAs = conv250 + out.EditMode = v.EditMode + conv251, err := JobDeploymentFromSDK(v.Deployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Deployment", err) + } + out.Deployment = conv251 + conv252, err := convertSlice(v.Environments, JobEnvironmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Environments", err) + } + out.Environments = conv252 + out.BudgetPolicyId = v.BudgetPolicyId + out.UsagePolicyId = v.UsagePolicyId + out.PerformanceTarget = v.PerformanceTarget + out.ParentPath = v.ParentPath + conv253, err := convertSlice(v.Triggers, TriggerConfigurationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.Triggers", err) + } + out.Triggers = conv253 + conv254, err := convertSlice(v.EnvironmentVariables, JobEnvironmentVariablesFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobSettings.EnvironmentVariables", err) + } + out.EnvironmentVariables = conv254 + out.MaxRetries = v.MaxRetries + out.MinRetryIntervalMillis = v.MinRetryIntervalMillis + out.RetryOnTimeout = v.RetryOnTimeout + out.DisableAutoOptimization = v.DisableAutoOptimization + return out, nil +} + +// JobSourceToSDK converts the mirror to the sdk-go type. +func JobSourceToSDK(w *JobSource) (*sdk.JobSource, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobSource{} + out.JobConfigPath = w.JobConfigPath + { + var members []string + if w.ImportFromGitBranch != nil { + members = append(members, "import_from_git_branch") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ImportFromGitBranch != nil: + out.ImportFromGitReference = &sdk.JobSource_ImportFromGitReference_ImportFromGitBranch{ImportFromGitBranch: *w.ImportFromGitBranch} + } + out.DirtyState = w.DirtyState + return out, nil +} + +// JobSourceFromSDK converts the sdk-go type to the mirror. +func JobSourceFromSDK(v *sdk.JobSource) (*JobSource, error) { + if v == nil { + return nil, nil + } + out := &JobSource{} + out.JobConfigPath = v.JobConfigPath + switch value := v.ImportFromGitReference.(type) { + case *sdk.JobSource_ImportFromGitReference_ImportFromGitBranch: + if value != nil { + out.ImportFromGitBranch = new(value.ImportFromGitBranch) + } + } + out.DirtyState = v.DirtyState + return out, nil +} + +// JobsHealthRuleToSDK converts the mirror to the sdk-go type. +func JobsHealthRuleToSDK(w *JobsHealthRule) (*sdk.JobsHealthRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobsHealthRule{} + out.Metric = w.Metric + out.Op = w.Op + out.Value = w.Value + return out, nil +} + +// JobsHealthRuleFromSDK converts the sdk-go type to the mirror. +func JobsHealthRuleFromSDK(v *sdk.JobsHealthRule) (*JobsHealthRule, error) { + if v == nil { + return nil, nil + } + out := &JobsHealthRule{} + out.Metric = v.Metric + out.Op = v.Op + out.Value = v.Value + return out, nil +} + +// JobsHealthRulesToSDK converts the mirror to the sdk-go type. +func JobsHealthRulesToSDK(w *JobsHealthRules) (*sdk.JobsHealthRules, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobsHealthRules{} + conv255, err := convertSlice(w.Rules, JobsHealthRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobsHealthRules.Rules", err) + } + out.Rules = conv255 + return out, nil +} + +// JobsHealthRulesFromSDK converts the sdk-go type to the mirror. +func JobsHealthRulesFromSDK(v *sdk.JobsHealthRules) (*JobsHealthRules, error) { + if v == nil { + return nil, nil + } + out := &JobsHealthRules{} + conv256, err := convertSlice(v.Rules, JobsHealthRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "JobsHealthRules.Rules", err) + } + out.Rules = conv256 + return out, nil +} + +// LibraryToSDK converts the mirror to the sdk-go type. +func LibraryToSDK(w *Library) (*sdk.Library, error) { + if w == nil { + return nil, nil + } + out := &sdk.Library{} + { + var members []string + if w.Jar != nil { + members = append(members, "jar") + } + if w.Egg != nil { + members = append(members, "egg") + } + if w.Pypi != nil { + members = append(members, "pypi") + } + if w.Maven != nil { + members = append(members, "maven") + } + if w.Cran != nil { + members = append(members, "cran") + } + if w.Whl != nil { + members = append(members, "whl") + } + if w.Requirements != nil { + members = append(members, "requirements") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Jar != nil: + out.Lib = &sdk.Library_Lib_Jar{Jar: *w.Jar} + case w.Egg != nil: + out.Lib = &sdk.Library_Lib_Egg{Egg: *w.Egg} + case w.Pypi != nil: + conv257, err := PythonPyPiLibraryToSDK(w.Pypi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Lib = &sdk.Library_Lib_Pypi{Pypi: *conv257} + case w.Maven != nil: + conv258, err := MavenLibraryToSDK(w.Maven) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Lib = &sdk.Library_Lib_Maven{Maven: *conv258} + case w.Cran != nil: + conv259, err := RCranLibraryToSDK(w.Cran) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Lib = &sdk.Library_Lib_Cran{Cran: *conv259} + case w.Whl != nil: + out.Lib = &sdk.Library_Lib_Whl{Whl: *w.Whl} + case w.Requirements != nil: + out.Lib = &sdk.Library_Lib_Requirements{Requirements: *w.Requirements} + } + return out, nil +} + +// LibraryFromSDK converts the sdk-go type to the mirror. +func LibraryFromSDK(v *sdk.Library) (*Library, error) { + if v == nil { + return nil, nil + } + out := &Library{} + switch value := v.Lib.(type) { + case *sdk.Library_Lib_Jar: + if value != nil { + out.Jar = new(value.Jar) + } + case *sdk.Library_Lib_Egg: + if value != nil { + out.Egg = new(value.Egg) + } + case *sdk.Library_Lib_Pypi: + if value != nil { + conv260, err := PythonPyPiLibraryFromSDK(&value.Pypi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Pypi = conv260 + } + case *sdk.Library_Lib_Maven: + if value != nil { + conv261, err := MavenLibraryFromSDK(&value.Maven) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Maven = conv261 + } + case *sdk.Library_Lib_Cran: + if value != nil { + conv262, err := RCranLibraryFromSDK(&value.Cran) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Library.Lib", err) + } + out.Cran = conv262 + } + case *sdk.Library_Lib_Whl: + if value != nil { + out.Whl = new(value.Whl) + } + case *sdk.Library_Lib_Requirements: + if value != nil { + out.Requirements = new(value.Requirements) + } + } + return out, nil +} + +// ListJobComplianceForPolicyToSDK converts the mirror to the sdk-go type. +func ListJobComplianceForPolicyToSDK(w *ListJobComplianceForPolicy) (*sdk.ListJobComplianceForPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListJobComplianceForPolicy{} + out.PolicyId = w.PolicyId + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListJobComplianceForPolicyFromSDK converts the sdk-go type to the mirror. +func ListJobComplianceForPolicyFromSDK(v *sdk.ListJobComplianceForPolicy) (*ListJobComplianceForPolicy, error) { + if v == nil { + return nil, nil + } + out := &ListJobComplianceForPolicy{} + out.PolicyId = v.PolicyId + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListJobComplianceForPolicy_JobComplianceToSDK converts the mirror to the sdk-go type. +func ListJobComplianceForPolicy_JobComplianceToSDK(w *ListJobComplianceForPolicy_JobCompliance) (*sdk.ListJobComplianceForPolicy_JobCompliance, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListJobComplianceForPolicy_JobCompliance{} + out.JobId = w.JobId + out.IsCompliant = w.IsCompliant + out.Violations = w.Violations + return out, nil +} + +// ListJobComplianceForPolicy_JobComplianceFromSDK converts the sdk-go type to the mirror. +func ListJobComplianceForPolicy_JobComplianceFromSDK(v *sdk.ListJobComplianceForPolicy_JobCompliance) (*ListJobComplianceForPolicy_JobCompliance, error) { + if v == nil { + return nil, nil + } + out := &ListJobComplianceForPolicy_JobCompliance{} + out.JobId = v.JobId + out.IsCompliant = v.IsCompliant + out.Violations = v.Violations + return out, nil +} + +// ListJobComplianceResponseToSDK converts the mirror to the sdk-go type. +func ListJobComplianceResponseToSDK(w *ListJobComplianceResponse) (*sdk.ListJobComplianceResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListJobComplianceResponse{} + conv263, err := convertSlice(w.Jobs, ListJobComplianceForPolicy_JobComplianceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListJobComplianceResponse.Jobs", err) + } + out.Jobs = conv263 + out.NextPageToken = w.NextPageToken + out.PrevPageToken = w.PrevPageToken + return out, nil +} + +// ListJobComplianceResponseFromSDK converts the sdk-go type to the mirror. +func ListJobComplianceResponseFromSDK(v *sdk.ListJobComplianceResponse) (*ListJobComplianceResponse, error) { + if v == nil { + return nil, nil + } + out := &ListJobComplianceResponse{} + conv264, err := convertSlice(v.Jobs, ListJobComplianceForPolicy_JobComplianceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListJobComplianceResponse.Jobs", err) + } + out.Jobs = conv264 + out.NextPageToken = v.NextPageToken + out.PrevPageToken = v.PrevPageToken + return out, nil +} + +// ListJobsRequestToSDK converts the mirror to the sdk-go type. +func ListJobsRequestToSDK(w *ListJobsRequest) (*sdk.ListJobsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListJobsRequest{} + out.Offset = w.Offset + out.Limit = w.Limit + out.ExpandTasks = w.ExpandTasks + out.Name = w.Name + out.PageToken = w.PageToken + return out, nil +} + +// ListJobsRequestFromSDK converts the sdk-go type to the mirror. +func ListJobsRequestFromSDK(v *sdk.ListJobsRequest) (*ListJobsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListJobsRequest{} + out.Offset = v.Offset + out.Limit = v.Limit + out.ExpandTasks = v.ExpandTasks + out.Name = v.Name + out.PageToken = v.PageToken + return out, nil +} + +// ListJobsResponseToSDK converts the mirror to the sdk-go type. +func ListJobsResponseToSDK(w *ListJobsResponse) (*sdk.ListJobsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListJobsResponse{} + conv265, err := convertSlice(w.Jobs, BaseJobToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListJobsResponse.Jobs", err) + } + out.Jobs = conv265 + out.HasMore = w.HasMore + out.NextPageToken = w.NextPageToken + out.PrevPageToken = w.PrevPageToken + return out, nil +} + +// ListJobsResponseFromSDK converts the sdk-go type to the mirror. +func ListJobsResponseFromSDK(v *sdk.ListJobsResponse) (*ListJobsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListJobsResponse{} + conv266, err := convertSlice(v.Jobs, BaseJobFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListJobsResponse.Jobs", err) + } + out.Jobs = conv266 + out.HasMore = v.HasMore + out.NextPageToken = v.NextPageToken + out.PrevPageToken = v.PrevPageToken + return out, nil +} + +// ListRunsRequestToSDK converts the mirror to the sdk-go type. +func ListRunsRequestToSDK(w *ListRunsRequest) (*sdk.ListRunsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRunsRequest{} + out.JobId = w.JobId + { + var members []string + if w.ActiveOnly != nil { + members = append(members, "active_only") + } + if w.CompletedOnly != nil { + members = append(members, "completed_only") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ActiveOnly != nil: + out.StateConstraint = &sdk.ListRunsRequest_StateConstraint_ActiveOnly{ActiveOnly: *w.ActiveOnly} + case w.CompletedOnly != nil: + out.StateConstraint = &sdk.ListRunsRequest_StateConstraint_CompletedOnly{CompletedOnly: *w.CompletedOnly} + } + out.Offset = w.Offset + out.Limit = w.Limit + out.RunType = w.RunType + out.ExpandTasks = w.ExpandTasks + out.StartTimeFrom = w.StartTimeFrom + out.StartTimeTo = w.StartTimeTo + out.PageToken = w.PageToken + return out, nil +} + +// ListRunsRequestFromSDK converts the sdk-go type to the mirror. +func ListRunsRequestFromSDK(v *sdk.ListRunsRequest) (*ListRunsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListRunsRequest{} + out.JobId = v.JobId + switch value := v.StateConstraint.(type) { + case *sdk.ListRunsRequest_StateConstraint_ActiveOnly: + if value != nil { + out.ActiveOnly = new(value.ActiveOnly) + } + case *sdk.ListRunsRequest_StateConstraint_CompletedOnly: + if value != nil { + out.CompletedOnly = new(value.CompletedOnly) + } + } + out.Offset = v.Offset + out.Limit = v.Limit + out.RunType = v.RunType + out.ExpandTasks = v.ExpandTasks + out.StartTimeFrom = v.StartTimeFrom + out.StartTimeTo = v.StartTimeTo + out.PageToken = v.PageToken + return out, nil +} + +// ListRunsResponseToSDK converts the mirror to the sdk-go type. +func ListRunsResponseToSDK(w *ListRunsResponse) (*sdk.ListRunsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRunsResponse{} + conv267, err := convertSlice(w.Runs, BaseRunToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRunsResponse.Runs", err) + } + out.Runs = conv267 + out.HasMore = w.HasMore + out.NextPageToken = w.NextPageToken + out.PrevPageToken = w.PrevPageToken + return out, nil +} + +// ListRunsResponseFromSDK converts the sdk-go type to the mirror. +func ListRunsResponseFromSDK(v *sdk.ListRunsResponse) (*ListRunsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListRunsResponse{} + conv268, err := convertSlice(v.Runs, BaseRunFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRunsResponse.Runs", err) + } + out.Runs = conv268 + out.HasMore = v.HasMore + out.NextPageToken = v.NextPageToken + out.PrevPageToken = v.PrevPageToken + return out, nil +} + +// LocalFileInfoToSDK converts the mirror to the sdk-go type. +func LocalFileInfoToSDK(w *LocalFileInfo) (*sdk.LocalFileInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.LocalFileInfo{} + out.Destination = w.Destination + return out, nil +} + +// LocalFileInfoFromSDK converts the sdk-go type to the mirror. +func LocalFileInfoFromSDK(v *sdk.LocalFileInfo) (*LocalFileInfo, error) { + if v == nil { + return nil, nil + } + out := &LocalFileInfo{} + out.Destination = v.Destination + return out, nil +} + +// LogAnalyticsInfoToSDK converts the mirror to the sdk-go type. +func LogAnalyticsInfoToSDK(w *LogAnalyticsInfo) (*sdk.LogAnalyticsInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.LogAnalyticsInfo{} + out.LogAnalyticsWorkspaceId = w.LogAnalyticsWorkspaceId + out.LogAnalyticsPrimaryKey = w.LogAnalyticsPrimaryKey + return out, nil +} + +// LogAnalyticsInfoFromSDK converts the sdk-go type to the mirror. +func LogAnalyticsInfoFromSDK(v *sdk.LogAnalyticsInfo) (*LogAnalyticsInfo, error) { + if v == nil { + return nil, nil + } + out := &LogAnalyticsInfo{} + out.LogAnalyticsWorkspaceId = v.LogAnalyticsWorkspaceId + out.LogAnalyticsPrimaryKey = v.LogAnalyticsPrimaryKey + return out, nil +} + +// MaintenanceWindowToSDK converts the mirror to the sdk-go type. +func MaintenanceWindowToSDK(w *MaintenanceWindow) (*sdk.MaintenanceWindow, error) { + if w == nil { + return nil, nil + } + out := &sdk.MaintenanceWindow{} + out.StartHour = w.StartHour + out.DayOfWeek = w.DayOfWeek + out.TimezoneId = w.TimezoneId + return out, nil +} + +// MaintenanceWindowFromSDK converts the sdk-go type to the mirror. +func MaintenanceWindowFromSDK(v *sdk.MaintenanceWindow) (*MaintenanceWindow, error) { + if v == nil { + return nil, nil + } + out := &MaintenanceWindow{} + out.StartHour = v.StartHour + out.DayOfWeek = v.DayOfWeek + out.TimezoneId = v.TimezoneId + return out, nil +} + +// MavenLibraryToSDK converts the mirror to the sdk-go type. +func MavenLibraryToSDK(w *MavenLibrary) (*sdk.MavenLibrary, error) { + if w == nil { + return nil, nil + } + out := &sdk.MavenLibrary{} + out.Coordinates = w.Coordinates + out.Repo = w.Repo + out.Exclusions = w.Exclusions + return out, nil +} + +// MavenLibraryFromSDK converts the sdk-go type to the mirror. +func MavenLibraryFromSDK(v *sdk.MavenLibrary) (*MavenLibrary, error) { + if v == nil { + return nil, nil + } + out := &MavenLibrary{} + out.Coordinates = v.Coordinates + out.Repo = v.Repo + out.Exclusions = v.Exclusions + return out, nil +} + +// ModelTriggerConfigurationToSDK converts the mirror to the sdk-go type. +func ModelTriggerConfigurationToSDK(w *ModelTriggerConfiguration) (*sdk.ModelTriggerConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelTriggerConfiguration{} + out.SecurableName = w.SecurableName + out.Aliases = w.Aliases + out.Condition = w.Condition + out.MinTimeBetweenTriggersSeconds = w.MinTimeBetweenTriggersSeconds + out.WaitAfterLastChangeSeconds = w.WaitAfterLastChangeSeconds + return out, nil +} + +// ModelTriggerConfigurationFromSDK converts the sdk-go type to the mirror. +func ModelTriggerConfigurationFromSDK(v *sdk.ModelTriggerConfiguration) (*ModelTriggerConfiguration, error) { + if v == nil { + return nil, nil + } + out := &ModelTriggerConfiguration{} + out.SecurableName = v.SecurableName + out.Aliases = v.Aliases + out.Condition = v.Condition + out.MinTimeBetweenTriggersSeconds = v.MinTimeBetweenTriggersSeconds + out.WaitAfterLastChangeSeconds = v.WaitAfterLastChangeSeconds + return out, nil +} + +// ModelTriggerStateToSDK converts the mirror to the sdk-go type. +func ModelTriggerStateToSDK(w *ModelTriggerState) (*sdk.ModelTriggerState, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelTriggerState{} + return out, nil +} + +// ModelTriggerStateFromSDK converts the sdk-go type to the mirror. +func ModelTriggerStateFromSDK(v *sdk.ModelTriggerState) (*ModelTriggerState, error) { + if v == nil { + return nil, nil + } + out := &ModelTriggerState{} + return out, nil +} + +// NodeTypeFlexibilityToSDK converts the mirror to the sdk-go type. +func NodeTypeFlexibilityToSDK(w *NodeTypeFlexibility) (*sdk.NodeTypeFlexibility, error) { + if w == nil { + return nil, nil + } + out := &sdk.NodeTypeFlexibility{} + out.AlternateNodeTypeIds = w.AlternateNodeTypeIds + out.AwsContextId = w.AwsContextId + return out, nil +} + +// NodeTypeFlexibilityFromSDK converts the sdk-go type to the mirror. +func NodeTypeFlexibilityFromSDK(v *sdk.NodeTypeFlexibility) (*NodeTypeFlexibility, error) { + if v == nil { + return nil, nil + } + out := &NodeTypeFlexibility{} + out.AlternateNodeTypeIds = v.AlternateNodeTypeIds + out.AwsContextId = v.AwsContextId + return out, nil +} + +// NotebookTaskToSDK converts the mirror to the sdk-go type. +func NotebookTaskToSDK(w *NotebookTask) (*sdk.NotebookTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.NotebookTask{} + out.NotebookPath = w.NotebookPath + out.BaseParameters = w.BaseParameters + out.Source = w.Source + out.WarehouseId = w.WarehouseId + return out, nil +} + +// NotebookTaskFromSDK converts the sdk-go type to the mirror. +func NotebookTaskFromSDK(v *sdk.NotebookTask) (*NotebookTask, error) { + if v == nil { + return nil, nil + } + out := &NotebookTask{} + out.NotebookPath = v.NotebookPath + out.BaseParameters = v.BaseParameters + out.Source = v.Source + out.WarehouseId = v.WarehouseId + return out, nil +} + +// NotebookTask_NotebookOutputToSDK converts the mirror to the sdk-go type. +func NotebookTask_NotebookOutputToSDK(w *NotebookTask_NotebookOutput) (*sdk.NotebookTask_NotebookOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.NotebookTask_NotebookOutput{} + out.Result = w.Result + out.Truncated = w.Truncated + return out, nil +} + +// NotebookTask_NotebookOutputFromSDK converts the sdk-go type to the mirror. +func NotebookTask_NotebookOutputFromSDK(v *sdk.NotebookTask_NotebookOutput) (*NotebookTask_NotebookOutput, error) { + if v == nil { + return nil, nil + } + out := &NotebookTask_NotebookOutput{} + out.Result = v.Result + out.Truncated = v.Truncated + return out, nil +} + +// NotificationSettingsToSDK converts the mirror to the sdk-go type. +func NotificationSettingsToSDK(w *NotificationSettings) (*sdk.NotificationSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.NotificationSettings{} + out.NoAlertForSkippedRuns = w.NoAlertForSkippedRuns + out.NoAlertForCanceledRuns = w.NoAlertForCanceledRuns + out.AlertOnLastAttempt = w.AlertOnLastAttempt + return out, nil +} + +// NotificationSettingsFromSDK converts the sdk-go type to the mirror. +func NotificationSettingsFromSDK(v *sdk.NotificationSettings) (*NotificationSettings, error) { + if v == nil { + return nil, nil + } + out := &NotificationSettings{} + out.NoAlertForSkippedRuns = v.NoAlertForSkippedRuns + out.NoAlertForCanceledRuns = v.NoAlertForCanceledRuns + out.AlertOnLastAttempt = v.AlertOnLastAttempt + return out, nil +} + +// OutputSchemaInfoToSDK converts the mirror to the sdk-go type. +func OutputSchemaInfoToSDK(w *OutputSchemaInfo) (*sdk.OutputSchemaInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.OutputSchemaInfo{} + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.ExpirationTime = w.ExpirationTime + return out, nil +} + +// OutputSchemaInfoFromSDK converts the sdk-go type to the mirror. +func OutputSchemaInfoFromSDK(v *sdk.OutputSchemaInfo) (*OutputSchemaInfo, error) { + if v == nil { + return nil, nil + } + out := &OutputSchemaInfo{} + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.ExpirationTime = v.ExpirationTime + return out, nil +} + +// PerTriggerStateToSDK converts the mirror to the sdk-go type. +func PerTriggerStateToSDK(w *PerTriggerState) (*sdk.PerTriggerState, error) { + if w == nil { + return nil, nil + } + out := &sdk.PerTriggerState{} + { + var members []string + if w.Periodic != nil { + members = append(members, "periodic") + } + if w.Schedule != nil { + members = append(members, "schedule") + } + if w.Continuous != nil { + members = append(members, "continuous") + } + if w.FileArrival != nil { + members = append(members, "file_arrival") + } + if w.TableUpdate != nil { + members = append(members, "table_update") + } + if w.Model != nil { + members = append(members, "model") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Periodic != nil: + conv269, err := PeriodicTriggerStateToSDK(w.Periodic) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType", err) + } + out.TriggerType = &sdk.PerTriggerState_TriggerType_Periodic{Periodic: *conv269} + case w.Schedule != nil: + conv270, err := ScheduleTriggerStateToSDK(w.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType", err) + } + out.TriggerType = &sdk.PerTriggerState_TriggerType_Schedule{Schedule: *conv270} + case w.Continuous != nil: + conv271, err := ContinuousTriggerStateToSDK(w.Continuous) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType", err) + } + out.TriggerType = &sdk.PerTriggerState_TriggerType_Continuous{Continuous: *conv271} + case w.FileArrival != nil: + conv272, err := FileArrivalTriggerStateToSDK(w.FileArrival) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType", err) + } + out.TriggerType = &sdk.PerTriggerState_TriggerType_FileArrival{FileArrival: *conv272} + case w.TableUpdate != nil: + conv273, err := TableTriggerStateToSDK(w.TableUpdate) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType", err) + } + out.TriggerType = &sdk.PerTriggerState_TriggerType_TableUpdate{TableUpdate: *conv273} + case w.Model != nil: + conv274, err := ModelTriggerStateToSDK(w.Model) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType", err) + } + out.TriggerType = &sdk.PerTriggerState_TriggerType_Model{Model: *conv274} + } + conv275, err := SqlConditionStateToSDK(w.SqlCondition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.SqlCondition", err) + } + out.SqlCondition = conv275 + out.PauseStatus = w.PauseStatus + return out, nil +} + +// PerTriggerStateFromSDK converts the sdk-go type to the mirror. +func PerTriggerStateFromSDK(v *sdk.PerTriggerState) (*PerTriggerState, error) { + if v == nil { + return nil, nil + } + out := &PerTriggerState{} + switch value := v.TriggerType.(type) { + case *sdk.PerTriggerState_TriggerType_Periodic: + if value != nil { + conv276, err := PeriodicTriggerStateFromSDK(&value.Periodic) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType", err) + } + out.Periodic = conv276 + } + case *sdk.PerTriggerState_TriggerType_Schedule: + if value != nil { + conv277, err := ScheduleTriggerStateFromSDK(&value.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType", err) + } + out.Schedule = conv277 + } + case *sdk.PerTriggerState_TriggerType_Continuous: + if value != nil { + conv278, err := ContinuousTriggerStateFromSDK(&value.Continuous) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType", err) + } + out.Continuous = conv278 + } + case *sdk.PerTriggerState_TriggerType_FileArrival: + if value != nil { + conv279, err := FileArrivalTriggerStateFromSDK(&value.FileArrival) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType", err) + } + out.FileArrival = conv279 + } + case *sdk.PerTriggerState_TriggerType_TableUpdate: + if value != nil { + conv280, err := TableTriggerStateFromSDK(&value.TableUpdate) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType", err) + } + out.TableUpdate = conv280 + } + case *sdk.PerTriggerState_TriggerType_Model: + if value != nil { + conv281, err := ModelTriggerStateFromSDK(&value.Model) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.TriggerType", err) + } + out.Model = conv281 + } + } + conv282, err := SqlConditionStateFromSDK(v.SqlCondition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PerTriggerState.SqlCondition", err) + } + out.SqlCondition = conv282 + out.PauseStatus = v.PauseStatus + return out, nil +} + +// PeriodicTriggerConfigurationToSDK converts the mirror to the sdk-go type. +func PeriodicTriggerConfigurationToSDK(w *PeriodicTriggerConfiguration) (*sdk.PeriodicTriggerConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.PeriodicTriggerConfiguration{} + out.Interval = w.Interval + out.Unit = w.Unit + return out, nil +} + +// PeriodicTriggerConfigurationFromSDK converts the sdk-go type to the mirror. +func PeriodicTriggerConfigurationFromSDK(v *sdk.PeriodicTriggerConfiguration) (*PeriodicTriggerConfiguration, error) { + if v == nil { + return nil, nil + } + out := &PeriodicTriggerConfiguration{} + out.Interval = v.Interval + out.Unit = v.Unit + return out, nil +} + +// PeriodicTriggerStateToSDK converts the mirror to the sdk-go type. +func PeriodicTriggerStateToSDK(w *PeriodicTriggerState) (*sdk.PeriodicTriggerState, error) { + if w == nil { + return nil, nil + } + out := &sdk.PeriodicTriggerState{} + out.NextRunTime = w.NextRunTime + return out, nil +} + +// PeriodicTriggerStateFromSDK converts the sdk-go type to the mirror. +func PeriodicTriggerStateFromSDK(v *sdk.PeriodicTriggerState) (*PeriodicTriggerState, error) { + if v == nil { + return nil, nil + } + out := &PeriodicTriggerState{} + out.NextRunTime = v.NextRunTime + return out, nil +} + +// PipelineParametersToSDK converts the mirror to the sdk-go type. +func PipelineParametersToSDK(w *PipelineParameters) (*sdk.PipelineParameters, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelineParameters{} + out.FullRefresh = w.FullRefresh + out.RefreshSelection = w.RefreshSelection + out.FullRefreshSelection = w.FullRefreshSelection + out.ResetCheckpointSelection = w.ResetCheckpointSelection + out.RefreshFlowSelection = w.RefreshFlowSelection + return out, nil +} + +// PipelineParametersFromSDK converts the sdk-go type to the mirror. +func PipelineParametersFromSDK(v *sdk.PipelineParameters) (*PipelineParameters, error) { + if v == nil { + return nil, nil + } + out := &PipelineParameters{} + out.FullRefresh = v.FullRefresh + out.RefreshSelection = v.RefreshSelection + out.FullRefreshSelection = v.FullRefreshSelection + out.ResetCheckpointSelection = v.ResetCheckpointSelection + out.RefreshFlowSelection = v.RefreshFlowSelection + return out, nil +} + +// PipelineTaskToSDK converts the mirror to the sdk-go type. +func PipelineTaskToSDK(w *PipelineTask) (*sdk.PipelineTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelineTask{} + out.PipelineId = w.PipelineId + out.PipelineTaskParameters = w.PipelineTaskParameters + out.FullRefresh = w.FullRefresh + out.RefreshSelection = w.RefreshSelection + out.FullRefreshSelection = w.FullRefreshSelection + out.ResetCheckpointSelection = w.ResetCheckpointSelection + out.RefreshFlowSelection = w.RefreshFlowSelection + return out, nil +} + +// PipelineTaskFromSDK converts the sdk-go type to the mirror. +func PipelineTaskFromSDK(v *sdk.PipelineTask) (*PipelineTask, error) { + if v == nil { + return nil, nil + } + out := &PipelineTask{} + out.PipelineId = v.PipelineId + out.PipelineTaskParameters = v.PipelineTaskParameters + out.FullRefresh = v.FullRefresh + out.RefreshSelection = v.RefreshSelection + out.FullRefreshSelection = v.FullRefreshSelection + out.ResetCheckpointSelection = v.ResetCheckpointSelection + out.RefreshFlowSelection = v.RefreshFlowSelection + return out, nil +} + +// PowerBiModelToSDK converts the mirror to the sdk-go type. +func PowerBiModelToSDK(w *PowerBiModel) (*sdk.PowerBiModel, error) { + if w == nil { + return nil, nil + } + out := &sdk.PowerBiModel{} + out.WorkspaceName = w.WorkspaceName + out.ModelName = w.ModelName + out.StorageMode = w.StorageMode + out.AuthenticationMethod = w.AuthenticationMethod + out.OverwriteExisting = w.OverwriteExisting + return out, nil +} + +// PowerBiModelFromSDK converts the sdk-go type to the mirror. +func PowerBiModelFromSDK(v *sdk.PowerBiModel) (*PowerBiModel, error) { + if v == nil { + return nil, nil + } + out := &PowerBiModel{} + out.WorkspaceName = v.WorkspaceName + out.ModelName = v.ModelName + out.StorageMode = v.StorageMode + out.AuthenticationMethod = v.AuthenticationMethod + out.OverwriteExisting = v.OverwriteExisting + return out, nil +} + +// PowerBiTableToSDK converts the mirror to the sdk-go type. +func PowerBiTableToSDK(w *PowerBiTable) (*sdk.PowerBiTable, error) { + if w == nil { + return nil, nil + } + out := &sdk.PowerBiTable{} + out.Name = w.Name + out.Catalog = w.Catalog + out.Schema = w.Schema + out.StorageMode = w.StorageMode + return out, nil +} + +// PowerBiTableFromSDK converts the sdk-go type to the mirror. +func PowerBiTableFromSDK(v *sdk.PowerBiTable) (*PowerBiTable, error) { + if v == nil { + return nil, nil + } + out := &PowerBiTable{} + out.Name = v.Name + out.Catalog = v.Catalog + out.Schema = v.Schema + out.StorageMode = v.StorageMode + return out, nil +} + +// PowerBiTaskToSDK converts the mirror to the sdk-go type. +func PowerBiTaskToSDK(w *PowerBiTask) (*sdk.PowerBiTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.PowerBiTask{} + conv283, err := convertSlice(w.Tables, PowerBiTableToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PowerBiTask.Tables", err) + } + out.Tables = conv283 + out.WarehouseId = w.WarehouseId + conv284, err := PowerBiModelToSDK(w.PowerBiModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PowerBiTask.PowerBiModel", err) + } + out.PowerBiModel = conv284 + out.ConnectionResourceName = w.ConnectionResourceName + out.RefreshAfterUpdate = w.RefreshAfterUpdate + return out, nil +} + +// PowerBiTaskFromSDK converts the sdk-go type to the mirror. +func PowerBiTaskFromSDK(v *sdk.PowerBiTask) (*PowerBiTask, error) { + if v == nil { + return nil, nil + } + out := &PowerBiTask{} + conv285, err := convertSlice(v.Tables, PowerBiTableFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PowerBiTask.Tables", err) + } + out.Tables = conv285 + out.WarehouseId = v.WarehouseId + conv286, err := PowerBiModelFromSDK(v.PowerBiModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PowerBiTask.PowerBiModel", err) + } + out.PowerBiModel = conv286 + out.ConnectionResourceName = v.ConnectionResourceName + out.RefreshAfterUpdate = v.RefreshAfterUpdate + return out, nil +} + +// PythonOperatorTaskToSDK converts the mirror to the sdk-go type. +func PythonOperatorTaskToSDK(w *PythonOperatorTask) (*sdk.PythonOperatorTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.PythonOperatorTask{} + conv287, err := convertSlice(w.Parameters, PythonOperatorTask_ParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PythonOperatorTask.Parameters", err) + } + out.Parameters = conv287 + out.Main = w.Main + return out, nil +} + +// PythonOperatorTaskFromSDK converts the sdk-go type to the mirror. +func PythonOperatorTaskFromSDK(v *sdk.PythonOperatorTask) (*PythonOperatorTask, error) { + if v == nil { + return nil, nil + } + out := &PythonOperatorTask{} + conv288, err := convertSlice(v.Parameters, PythonOperatorTask_ParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PythonOperatorTask.Parameters", err) + } + out.Parameters = conv288 + out.Main = v.Main + return out, nil +} + +// PythonOperatorTask_ParameterToSDK converts the mirror to the sdk-go type. +func PythonOperatorTask_ParameterToSDK(w *PythonOperatorTask_Parameter) (*sdk.PythonOperatorTask_Parameter, error) { + if w == nil { + return nil, nil + } + out := &sdk.PythonOperatorTask_Parameter{} + out.Name = w.Name + out.Value = w.Value + return out, nil +} + +// PythonOperatorTask_ParameterFromSDK converts the sdk-go type to the mirror. +func PythonOperatorTask_ParameterFromSDK(v *sdk.PythonOperatorTask_Parameter) (*PythonOperatorTask_Parameter, error) { + if v == nil { + return nil, nil + } + out := &PythonOperatorTask_Parameter{} + out.Name = v.Name + out.Value = v.Value + return out, nil +} + +// PythonPyPiLibraryToSDK converts the mirror to the sdk-go type. +func PythonPyPiLibraryToSDK(w *PythonPyPiLibrary) (*sdk.PythonPyPiLibrary, error) { + if w == nil { + return nil, nil + } + out := &sdk.PythonPyPiLibrary{} + out.Package = w.Package + out.Repo = w.Repo + return out, nil +} + +// PythonPyPiLibraryFromSDK converts the sdk-go type to the mirror. +func PythonPyPiLibraryFromSDK(v *sdk.PythonPyPiLibrary) (*PythonPyPiLibrary, error) { + if v == nil { + return nil, nil + } + out := &PythonPyPiLibrary{} + out.Package = v.Package + out.Repo = v.Repo + return out, nil +} + +// PythonWheelTaskToSDK converts the mirror to the sdk-go type. +func PythonWheelTaskToSDK(w *PythonWheelTask) (*sdk.PythonWheelTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.PythonWheelTask{} + out.PackageName = w.PackageName + out.EntryPoint = w.EntryPoint + out.Parameters = w.Parameters + out.NamedParameters = w.NamedParameters + return out, nil +} + +// PythonWheelTaskFromSDK converts the sdk-go type to the mirror. +func PythonWheelTaskFromSDK(v *sdk.PythonWheelTask) (*PythonWheelTask, error) { + if v == nil { + return nil, nil + } + out := &PythonWheelTask{} + out.PackageName = v.PackageName + out.EntryPoint = v.EntryPoint + out.Parameters = v.Parameters + out.NamedParameters = v.NamedParameters + return out, nil +} + +// QueueDetailsToSDK converts the mirror to the sdk-go type. +func QueueDetailsToSDK(w *QueueDetails) (*sdk.QueueDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueueDetails{} + out.Code = w.Code + out.Message = w.Message + return out, nil +} + +// QueueDetailsFromSDK converts the sdk-go type to the mirror. +func QueueDetailsFromSDK(v *sdk.QueueDetails) (*QueueDetails, error) { + if v == nil { + return nil, nil + } + out := &QueueDetails{} + out.Code = v.Code + out.Message = v.Message + return out, nil +} + +// QueueSettingsToSDK converts the mirror to the sdk-go type. +func QueueSettingsToSDK(w *QueueSettings) (*sdk.QueueSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueueSettings{} + out.Enabled = w.Enabled + return out, nil +} + +// QueueSettingsFromSDK converts the sdk-go type to the mirror. +func QueueSettingsFromSDK(v *sdk.QueueSettings) (*QueueSettings, error) { + if v == nil { + return nil, nil + } + out := &QueueSettings{} + out.Enabled = v.Enabled + return out, nil +} + +// RCranLibraryToSDK converts the mirror to the sdk-go type. +func RCranLibraryToSDK(w *RCranLibrary) (*sdk.RCranLibrary, error) { + if w == nil { + return nil, nil + } + out := &sdk.RCranLibrary{} + out.Package = w.Package + out.Repo = w.Repo + return out, nil +} + +// RCranLibraryFromSDK converts the sdk-go type to the mirror. +func RCranLibraryFromSDK(v *sdk.RCranLibrary) (*RCranLibrary, error) { + if v == nil { + return nil, nil + } + out := &RCranLibrary{} + out.Package = v.Package + out.Repo = v.Repo + return out, nil +} + +// RepairToSDK converts the mirror to the sdk-go type. +func RepairToSDK(w *Repair) (*sdk.Repair, error) { + if w == nil { + return nil, nil + } + out := &sdk.Repair{} + out.Type = w.Type + out.StartTime = w.StartTime + out.EndTime = w.EndTime + conv289, err := RunStateToSDK(w.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Repair.State", err) + } + out.State = conv289 + out.Id = w.Id + out.TaskRunIds = w.TaskRunIds + conv290, err := RunStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Repair.Status", err) + } + out.Status = conv290 + out.EffectivePerformanceTarget = w.EffectivePerformanceTarget + return out, nil +} + +// RepairFromSDK converts the sdk-go type to the mirror. +func RepairFromSDK(v *sdk.Repair) (*Repair, error) { + if v == nil { + return nil, nil + } + out := &Repair{} + out.Type = v.Type + out.StartTime = v.StartTime + out.EndTime = v.EndTime + conv291, err := RunStateFromSDK(v.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Repair.State", err) + } + out.State = conv291 + out.Id = v.Id + out.TaskRunIds = v.TaskRunIds + conv292, err := RunStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Repair.Status", err) + } + out.Status = conv292 + out.EffectivePerformanceTarget = v.EffectivePerformanceTarget + return out, nil +} + +// RepairRunRequestToSDK converts the mirror to the sdk-go type. +func RepairRunRequestToSDK(w *RepairRunRequest) (*sdk.RepairRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RepairRunRequest{} + out.RunId = w.RunId + out.LatestRepairId = w.LatestRepairId + out.RerunTasks = w.RerunTasks + out.JobParameters = w.JobParameters + out.RerunAllFailedTasks = w.RerunAllFailedTasks + out.RerunDependentTasks = w.RerunDependentTasks + out.PerformanceTarget = w.PerformanceTarget + conv293, err := PipelineParametersToSDK(w.PipelineParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RepairRunRequest.PipelineParams", err) + } + out.PipelineParams = conv293 + out.JarParams = w.JarParams + out.NotebookParams = w.NotebookParams + out.PythonParams = w.PythonParams + out.SparkSubmitParams = w.SparkSubmitParams + out.PythonNamedParams = w.PythonNamedParams + out.SqlParams = w.SqlParams + out.DbtCommands = w.DbtCommands + return out, nil +} + +// RepairRunRequestFromSDK converts the sdk-go type to the mirror. +func RepairRunRequestFromSDK(v *sdk.RepairRunRequest) (*RepairRunRequest, error) { + if v == nil { + return nil, nil + } + out := &RepairRunRequest{} + out.RunId = v.RunId + out.LatestRepairId = v.LatestRepairId + out.RerunTasks = v.RerunTasks + out.JobParameters = v.JobParameters + out.RerunAllFailedTasks = v.RerunAllFailedTasks + out.RerunDependentTasks = v.RerunDependentTasks + out.PerformanceTarget = v.PerformanceTarget + conv294, err := PipelineParametersFromSDK(v.PipelineParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RepairRunRequest.PipelineParams", err) + } + out.PipelineParams = conv294 + out.JarParams = v.JarParams + out.NotebookParams = v.NotebookParams + out.PythonParams = v.PythonParams + out.SparkSubmitParams = v.SparkSubmitParams + out.PythonNamedParams = v.PythonNamedParams + out.SqlParams = v.SqlParams + out.DbtCommands = v.DbtCommands + return out, nil +} + +// RepairRunResponseToSDK converts the mirror to the sdk-go type. +func RepairRunResponseToSDK(w *RepairRunResponse) (*sdk.RepairRunResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.RepairRunResponse{} + out.RepairId = w.RepairId + return out, nil +} + +// RepairRunResponseFromSDK converts the sdk-go type to the mirror. +func RepairRunResponseFromSDK(v *sdk.RepairRunResponse) (*RepairRunResponse, error) { + if v == nil { + return nil, nil + } + out := &RepairRunResponse{} + out.RepairId = v.RepairId + return out, nil +} + +// ResetJobRequestToSDK converts the mirror to the sdk-go type. +func ResetJobRequestToSDK(w *ResetJobRequest) (*sdk.ResetJobRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResetJobRequest{} + out.JobId = w.JobId + conv295, err := JobSettingsToSDK(w.NewSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResetJobRequest.NewSettings", err) + } + out.NewSettings = conv295 + return out, nil +} + +// ResetJobRequestFromSDK converts the sdk-go type to the mirror. +func ResetJobRequestFromSDK(v *sdk.ResetJobRequest) (*ResetJobRequest, error) { + if v == nil { + return nil, nil + } + out := &ResetJobRequest{} + out.JobId = v.JobId + conv296, err := JobSettingsFromSDK(v.NewSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResetJobRequest.NewSettings", err) + } + out.NewSettings = conv296 + return out, nil +} + +// ResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValuesToSDK(w *ResolvedValues) (*sdk.ResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues{} + { + var members []string + if w.NotebookTask != nil { + members = append(members, "notebook_task") + } + if w.SparkJarTask != nil { + members = append(members, "spark_jar_task") + } + if w.SparkPythonTask != nil { + members = append(members, "spark_python_task") + } + if w.SparkSubmitTask != nil { + members = append(members, "spark_submit_task") + } + if w.PythonWheelTask != nil { + members = append(members, "python_wheel_task") + } + if w.DbtTask != nil { + members = append(members, "dbt_task") + } + if w.SqlTask != nil { + members = append(members, "sql_task") + } + if w.RunJobTask != nil { + members = append(members, "run_job_task") + } + if w.ConditionTask != nil { + members = append(members, "condition_task") + } + if w.SimulationTask != nil { + members = append(members, "simulation_task") + } + if w.PipelineTask != nil { + members = append(members, "pipeline_task") + } + if w.AiRuntimeTask != nil { + members = append(members, "ai_runtime_task") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NotebookTask != nil: + conv297, err := ResolvedValues_NotebookTaskResolvedValuesToSDK(w.NotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.Resolved = &sdk.ResolvedValues_Resolved_NotebookTask{NotebookTask: *conv297} + case w.SparkJarTask != nil: + conv298, err := ResolvedValues_SparkJarTaskResolvedValuesToSDK(w.SparkJarTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.Resolved = &sdk.ResolvedValues_Resolved_SparkJarTask{SparkJarTask: *conv298} + case w.SparkPythonTask != nil: + conv299, err := ResolvedValues_SparkPythonTaskResolvedValuesToSDK(w.SparkPythonTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.Resolved = &sdk.ResolvedValues_Resolved_SparkPythonTask{SparkPythonTask: *conv299} + case w.SparkSubmitTask != nil: + conv300, err := ResolvedValues_SparkSubmitTaskResolvedValuesToSDK(w.SparkSubmitTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.Resolved = &sdk.ResolvedValues_Resolved_SparkSubmitTask{SparkSubmitTask: *conv300} + case w.PythonWheelTask != nil: + conv301, err := ResolvedValues_PythonWheelTaskResolvedValuesToSDK(w.PythonWheelTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.Resolved = &sdk.ResolvedValues_Resolved_PythonWheelTask{PythonWheelTask: *conv301} + case w.DbtTask != nil: + conv302, err := ResolvedValues_DbtTaskResolvedValuesToSDK(w.DbtTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.Resolved = &sdk.ResolvedValues_Resolved_DbtTask{DbtTask: *conv302} + case w.SqlTask != nil: + conv303, err := ResolvedValues_SqlTaskResolvedValuesToSDK(w.SqlTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.Resolved = &sdk.ResolvedValues_Resolved_SqlTask{SqlTask: *conv303} + case w.RunJobTask != nil: + conv304, err := ResolvedValues_RunJobTaskResolvedValuesToSDK(w.RunJobTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.Resolved = &sdk.ResolvedValues_Resolved_RunJobTask{RunJobTask: *conv304} + case w.ConditionTask != nil: + conv305, err := ResolvedValues_ConditionTaskResolvedValuesToSDK(w.ConditionTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.Resolved = &sdk.ResolvedValues_Resolved_ConditionTask{ConditionTask: *conv305} + case w.SimulationTask != nil: + conv306, err := ResolvedValues_SimulationTaskResolvedValuesToSDK(w.SimulationTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.Resolved = &sdk.ResolvedValues_Resolved_SimulationTask{SimulationTask: *conv306} + case w.PipelineTask != nil: + conv307, err := ResolvedValues_PipelineTaskResolvedValuesToSDK(w.PipelineTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.Resolved = &sdk.ResolvedValues_Resolved_PipelineTask{PipelineTask: *conv307} + case w.AiRuntimeTask != nil: + conv308, err := ResolvedValues_AiRuntimeTaskResolvedValuesToSDK(w.AiRuntimeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.Resolved = &sdk.ResolvedValues_Resolved_AiRuntimeTask{AiRuntimeTask: *conv308} + } + return out, nil +} + +// ResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValuesFromSDK(v *sdk.ResolvedValues) (*ResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues{} + switch value := v.Resolved.(type) { + case *sdk.ResolvedValues_Resolved_NotebookTask: + if value != nil { + conv309, err := ResolvedValues_NotebookTaskResolvedValuesFromSDK(&value.NotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.NotebookTask = conv309 + } + case *sdk.ResolvedValues_Resolved_SparkJarTask: + if value != nil { + conv310, err := ResolvedValues_SparkJarTaskResolvedValuesFromSDK(&value.SparkJarTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.SparkJarTask = conv310 + } + case *sdk.ResolvedValues_Resolved_SparkPythonTask: + if value != nil { + conv311, err := ResolvedValues_SparkPythonTaskResolvedValuesFromSDK(&value.SparkPythonTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.SparkPythonTask = conv311 + } + case *sdk.ResolvedValues_Resolved_SparkSubmitTask: + if value != nil { + conv312, err := ResolvedValues_SparkSubmitTaskResolvedValuesFromSDK(&value.SparkSubmitTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.SparkSubmitTask = conv312 + } + case *sdk.ResolvedValues_Resolved_PythonWheelTask: + if value != nil { + conv313, err := ResolvedValues_PythonWheelTaskResolvedValuesFromSDK(&value.PythonWheelTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.PythonWheelTask = conv313 + } + case *sdk.ResolvedValues_Resolved_DbtTask: + if value != nil { + conv314, err := ResolvedValues_DbtTaskResolvedValuesFromSDK(&value.DbtTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.DbtTask = conv314 + } + case *sdk.ResolvedValues_Resolved_SqlTask: + if value != nil { + conv315, err := ResolvedValues_SqlTaskResolvedValuesFromSDK(&value.SqlTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.SqlTask = conv315 + } + case *sdk.ResolvedValues_Resolved_RunJobTask: + if value != nil { + conv316, err := ResolvedValues_RunJobTaskResolvedValuesFromSDK(&value.RunJobTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.RunJobTask = conv316 + } + case *sdk.ResolvedValues_Resolved_ConditionTask: + if value != nil { + conv317, err := ResolvedValues_ConditionTaskResolvedValuesFromSDK(&value.ConditionTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.ConditionTask = conv317 + } + case *sdk.ResolvedValues_Resolved_SimulationTask: + if value != nil { + conv318, err := ResolvedValues_SimulationTaskResolvedValuesFromSDK(&value.SimulationTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.SimulationTask = conv318 + } + case *sdk.ResolvedValues_Resolved_PipelineTask: + if value != nil { + conv319, err := ResolvedValues_PipelineTaskResolvedValuesFromSDK(&value.PipelineTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.PipelineTask = conv319 + } + case *sdk.ResolvedValues_Resolved_AiRuntimeTask: + if value != nil { + conv320, err := ResolvedValues_AiRuntimeTaskResolvedValuesFromSDK(&value.AiRuntimeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResolvedValues.Resolved", err) + } + out.AiRuntimeTask = conv320 + } + } + return out, nil +} + +// ResolvedValues_AiRuntimeTaskResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValues_AiRuntimeTaskResolvedValuesToSDK(w *ResolvedValues_AiRuntimeTaskResolvedValues) (*sdk.ResolvedValues_AiRuntimeTaskResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues_AiRuntimeTaskResolvedValues{} + return out, nil +} + +// ResolvedValues_AiRuntimeTaskResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValues_AiRuntimeTaskResolvedValuesFromSDK(v *sdk.ResolvedValues_AiRuntimeTaskResolvedValues) (*ResolvedValues_AiRuntimeTaskResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues_AiRuntimeTaskResolvedValues{} + return out, nil +} + +// ResolvedValues_ConditionTaskResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValues_ConditionTaskResolvedValuesToSDK(w *ResolvedValues_ConditionTaskResolvedValues) (*sdk.ResolvedValues_ConditionTaskResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues_ConditionTaskResolvedValues{} + out.Left = w.Left + out.Right = w.Right + return out, nil +} + +// ResolvedValues_ConditionTaskResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValues_ConditionTaskResolvedValuesFromSDK(v *sdk.ResolvedValues_ConditionTaskResolvedValues) (*ResolvedValues_ConditionTaskResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues_ConditionTaskResolvedValues{} + out.Left = v.Left + out.Right = v.Right + return out, nil +} + +// ResolvedValues_DbtTaskResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValues_DbtTaskResolvedValuesToSDK(w *ResolvedValues_DbtTaskResolvedValues) (*sdk.ResolvedValues_DbtTaskResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues_DbtTaskResolvedValues{} + out.Commands = w.Commands + return out, nil +} + +// ResolvedValues_DbtTaskResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValues_DbtTaskResolvedValuesFromSDK(v *sdk.ResolvedValues_DbtTaskResolvedValues) (*ResolvedValues_DbtTaskResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues_DbtTaskResolvedValues{} + out.Commands = v.Commands + return out, nil +} + +// ResolvedValues_NotebookTaskResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValues_NotebookTaskResolvedValuesToSDK(w *ResolvedValues_NotebookTaskResolvedValues) (*sdk.ResolvedValues_NotebookTaskResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues_NotebookTaskResolvedValues{} + out.BaseParameters = w.BaseParameters + return out, nil +} + +// ResolvedValues_NotebookTaskResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValues_NotebookTaskResolvedValuesFromSDK(v *sdk.ResolvedValues_NotebookTaskResolvedValues) (*ResolvedValues_NotebookTaskResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues_NotebookTaskResolvedValues{} + out.BaseParameters = v.BaseParameters + return out, nil +} + +// ResolvedValues_PipelineTaskResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValues_PipelineTaskResolvedValuesToSDK(w *ResolvedValues_PipelineTaskResolvedValues) (*sdk.ResolvedValues_PipelineTaskResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues_PipelineTaskResolvedValues{} + out.PipelineTaskParameters = w.PipelineTaskParameters + return out, nil +} + +// ResolvedValues_PipelineTaskResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValues_PipelineTaskResolvedValuesFromSDK(v *sdk.ResolvedValues_PipelineTaskResolvedValues) (*ResolvedValues_PipelineTaskResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues_PipelineTaskResolvedValues{} + out.PipelineTaskParameters = v.PipelineTaskParameters + return out, nil +} + +// ResolvedValues_PythonWheelTaskResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValues_PythonWheelTaskResolvedValuesToSDK(w *ResolvedValues_PythonWheelTaskResolvedValues) (*sdk.ResolvedValues_PythonWheelTaskResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues_PythonWheelTaskResolvedValues{} + out.Parameters = w.Parameters + out.NamedParameters = w.NamedParameters + return out, nil +} + +// ResolvedValues_PythonWheelTaskResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValues_PythonWheelTaskResolvedValuesFromSDK(v *sdk.ResolvedValues_PythonWheelTaskResolvedValues) (*ResolvedValues_PythonWheelTaskResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues_PythonWheelTaskResolvedValues{} + out.Parameters = v.Parameters + out.NamedParameters = v.NamedParameters + return out, nil +} + +// ResolvedValues_RunJobTaskResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValues_RunJobTaskResolvedValuesToSDK(w *ResolvedValues_RunJobTaskResolvedValues) (*sdk.ResolvedValues_RunJobTaskResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues_RunJobTaskResolvedValues{} + out.Parameters = w.Parameters + out.JobParameters = w.JobParameters + return out, nil +} + +// ResolvedValues_RunJobTaskResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValues_RunJobTaskResolvedValuesFromSDK(v *sdk.ResolvedValues_RunJobTaskResolvedValues) (*ResolvedValues_RunJobTaskResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues_RunJobTaskResolvedValues{} + out.Parameters = v.Parameters + out.JobParameters = v.JobParameters + return out, nil +} + +// ResolvedValues_SimulationTaskResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValues_SimulationTaskResolvedValuesToSDK(w *ResolvedValues_SimulationTaskResolvedValues) (*sdk.ResolvedValues_SimulationTaskResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues_SimulationTaskResolvedValues{} + out.Parameters = w.Parameters + return out, nil +} + +// ResolvedValues_SimulationTaskResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValues_SimulationTaskResolvedValuesFromSDK(v *sdk.ResolvedValues_SimulationTaskResolvedValues) (*ResolvedValues_SimulationTaskResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues_SimulationTaskResolvedValues{} + out.Parameters = v.Parameters + return out, nil +} + +// ResolvedValues_SparkJarTaskResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValues_SparkJarTaskResolvedValuesToSDK(w *ResolvedValues_SparkJarTaskResolvedValues) (*sdk.ResolvedValues_SparkJarTaskResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues_SparkJarTaskResolvedValues{} + out.Parameters = w.Parameters + return out, nil +} + +// ResolvedValues_SparkJarTaskResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValues_SparkJarTaskResolvedValuesFromSDK(v *sdk.ResolvedValues_SparkJarTaskResolvedValues) (*ResolvedValues_SparkJarTaskResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues_SparkJarTaskResolvedValues{} + out.Parameters = v.Parameters + return out, nil +} + +// ResolvedValues_SparkPythonTaskResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValues_SparkPythonTaskResolvedValuesToSDK(w *ResolvedValues_SparkPythonTaskResolvedValues) (*sdk.ResolvedValues_SparkPythonTaskResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues_SparkPythonTaskResolvedValues{} + return out, nil +} + +// ResolvedValues_SparkPythonTaskResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValues_SparkPythonTaskResolvedValuesFromSDK(v *sdk.ResolvedValues_SparkPythonTaskResolvedValues) (*ResolvedValues_SparkPythonTaskResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues_SparkPythonTaskResolvedValues{} + return out, nil +} + +// ResolvedValues_SparkSubmitTaskResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValues_SparkSubmitTaskResolvedValuesToSDK(w *ResolvedValues_SparkSubmitTaskResolvedValues) (*sdk.ResolvedValues_SparkSubmitTaskResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues_SparkSubmitTaskResolvedValues{} + return out, nil +} + +// ResolvedValues_SparkSubmitTaskResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValues_SparkSubmitTaskResolvedValuesFromSDK(v *sdk.ResolvedValues_SparkSubmitTaskResolvedValues) (*ResolvedValues_SparkSubmitTaskResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues_SparkSubmitTaskResolvedValues{} + return out, nil +} + +// ResolvedValues_SqlTaskResolvedValuesToSDK converts the mirror to the sdk-go type. +func ResolvedValues_SqlTaskResolvedValuesToSDK(w *ResolvedValues_SqlTaskResolvedValues) (*sdk.ResolvedValues_SqlTaskResolvedValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResolvedValues_SqlTaskResolvedValues{} + out.Parameters = w.Parameters + return out, nil +} + +// ResolvedValues_SqlTaskResolvedValuesFromSDK converts the sdk-go type to the mirror. +func ResolvedValues_SqlTaskResolvedValuesFromSDK(v *sdk.ResolvedValues_SqlTaskResolvedValues) (*ResolvedValues_SqlTaskResolvedValues, error) { + if v == nil { + return nil, nil + } + out := &ResolvedValues_SqlTaskResolvedValues{} + out.Parameters = v.Parameters + return out, nil +} + +// RunToSDK converts the mirror to the sdk-go type. +func RunToSDK(w *Run) (*sdk.Run, error) { + if w == nil { + return nil, nil + } + out := &sdk.Run{} + out.JobId = w.JobId + out.RunId = w.RunId + out.CreatorUserName = w.CreatorUserName + out.NumberInJob = w.NumberInJob + out.OriginalAttemptRunId = w.OriginalAttemptRunId + conv321, err := RunStateToSDK(w.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.State", err) + } + out.State = conv321 + conv322, err := CronScheduleToSDK(w.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.Schedule", err) + } + out.Schedule = conv322 + conv323, err := ClusterSpecToSDK(w.ClusterSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.ClusterSpec", err) + } + out.ClusterSpec = conv323 + conv324, err := ClusterInstanceToSDK(w.ClusterInstance) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.ClusterInstance", err) + } + out.ClusterInstance = conv324 + conv325, err := convertSlice(w.JobParameters, Run_JobLevelParametersToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.JobParameters", err) + } + out.JobParameters = conv325 + conv326, err := RunParametersToSDK(w.OverridingParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.OverridingParameters", err) + } + out.OverridingParameters = conv326 + out.Trigger = w.Trigger + conv327, err := RunTriggerInfoToSDK(w.TriggerInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.TriggerInfo", err) + } + out.TriggerInfo = conv327 + out.RunName = w.RunName + out.RunPageUrl = w.RunPageUrl + out.RunType = w.RunType + conv328, err := convertSlice(w.Tasks, RunTaskToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.Tasks", err) + } + out.Tasks = conv328 + out.Description = w.Description + out.AttemptNumber = w.AttemptNumber + conv329, err := convertSlice(w.JobClusters, JobClusterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.JobClusters", err) + } + out.JobClusters = conv329 + conv330, err := GitSourceToSDK(w.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.GitSource", err) + } + out.GitSource = conv330 + conv331, err := convertSlice(w.RepairHistory, RepairToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.RepairHistory", err) + } + out.RepairHistory = conv331 + conv332, err := RunStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.Status", err) + } + out.Status = conv332 + out.JobRunId = w.JobRunId + out.HasMore = w.HasMore + out.EffectivePerformanceTarget = w.EffectivePerformanceTarget + out.EffectiveUsagePolicyId = w.EffectiveUsagePolicyId + conv333, err := convertSlice(w.EnvironmentVariables, JobEnvironmentVariablesToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.EnvironmentVariables", err) + } + out.EnvironmentVariables = conv333 + out.DeploymentId = w.DeploymentId + out.VersionId = w.VersionId + out.StartTime = w.StartTime + out.SetupDuration = w.SetupDuration + out.ExecutionDuration = w.ExecutionDuration + out.CleanupDuration = w.CleanupDuration + out.EndTime = w.EndTime + out.RunDuration = w.RunDuration + out.QueueDuration = w.QueueDuration + return out, nil +} + +// RunFromSDK converts the sdk-go type to the mirror. +func RunFromSDK(v *sdk.Run) (*Run, error) { + if v == nil { + return nil, nil + } + out := &Run{} + out.JobId = v.JobId + out.RunId = v.RunId + out.CreatorUserName = v.CreatorUserName + out.NumberInJob = v.NumberInJob + out.OriginalAttemptRunId = v.OriginalAttemptRunId + conv334, err := RunStateFromSDK(v.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.State", err) + } + out.State = conv334 + conv335, err := CronScheduleFromSDK(v.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.Schedule", err) + } + out.Schedule = conv335 + conv336, err := ClusterSpecFromSDK(v.ClusterSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.ClusterSpec", err) + } + out.ClusterSpec = conv336 + conv337, err := ClusterInstanceFromSDK(v.ClusterInstance) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.ClusterInstance", err) + } + out.ClusterInstance = conv337 + conv338, err := convertSlice(v.JobParameters, Run_JobLevelParametersFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.JobParameters", err) + } + out.JobParameters = conv338 + conv339, err := RunParametersFromSDK(v.OverridingParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.OverridingParameters", err) + } + out.OverridingParameters = conv339 + out.Trigger = v.Trigger + conv340, err := RunTriggerInfoFromSDK(v.TriggerInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.TriggerInfo", err) + } + out.TriggerInfo = conv340 + out.RunName = v.RunName + out.RunPageUrl = v.RunPageUrl + out.RunType = v.RunType + conv341, err := convertSlice(v.Tasks, RunTaskFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.Tasks", err) + } + out.Tasks = conv341 + out.Description = v.Description + out.AttemptNumber = v.AttemptNumber + conv342, err := convertSlice(v.JobClusters, JobClusterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.JobClusters", err) + } + out.JobClusters = conv342 + conv343, err := GitSourceFromSDK(v.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.GitSource", err) + } + out.GitSource = conv343 + conv344, err := convertSlice(v.RepairHistory, RepairFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.RepairHistory", err) + } + out.RepairHistory = conv344 + conv345, err := RunStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.Status", err) + } + out.Status = conv345 + out.JobRunId = v.JobRunId + out.HasMore = v.HasMore + out.EffectivePerformanceTarget = v.EffectivePerformanceTarget + out.EffectiveUsagePolicyId = v.EffectiveUsagePolicyId + conv346, err := convertSlice(v.EnvironmentVariables, JobEnvironmentVariablesFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Run.EnvironmentVariables", err) + } + out.EnvironmentVariables = conv346 + out.DeploymentId = v.DeploymentId + out.VersionId = v.VersionId + out.StartTime = v.StartTime + out.SetupDuration = v.SetupDuration + out.ExecutionDuration = v.ExecutionDuration + out.CleanupDuration = v.CleanupDuration + out.EndTime = v.EndTime + out.RunDuration = v.RunDuration + out.QueueDuration = v.QueueDuration + return out, nil +} + +// RunJobTaskToSDK converts the mirror to the sdk-go type. +func RunJobTaskToSDK(w *RunJobTask) (*sdk.RunJobTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunJobTask{} + out.JobId = w.JobId + out.JobParameters = w.JobParameters + conv347, err := PipelineParametersToSDK(w.PipelineParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunJobTask.PipelineParams", err) + } + out.PipelineParams = conv347 + out.JarParams = w.JarParams + out.NotebookParams = w.NotebookParams + out.PythonParams = w.PythonParams + out.SparkSubmitParams = w.SparkSubmitParams + out.PythonNamedParams = w.PythonNamedParams + out.SqlParams = w.SqlParams + out.DbtCommands = w.DbtCommands + return out, nil +} + +// RunJobTaskFromSDK converts the sdk-go type to the mirror. +func RunJobTaskFromSDK(v *sdk.RunJobTask) (*RunJobTask, error) { + if v == nil { + return nil, nil + } + out := &RunJobTask{} + out.JobId = v.JobId + out.JobParameters = v.JobParameters + conv348, err := PipelineParametersFromSDK(v.PipelineParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunJobTask.PipelineParams", err) + } + out.PipelineParams = conv348 + out.JarParams = v.JarParams + out.NotebookParams = v.NotebookParams + out.PythonParams = v.PythonParams + out.SparkSubmitParams = v.SparkSubmitParams + out.PythonNamedParams = v.PythonNamedParams + out.SqlParams = v.SqlParams + out.DbtCommands = v.DbtCommands + return out, nil +} + +// RunJobTask_RunJobTaskOutputToSDK converts the mirror to the sdk-go type. +func RunJobTask_RunJobTaskOutputToSDK(w *RunJobTask_RunJobTaskOutput) (*sdk.RunJobTask_RunJobTaskOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunJobTask_RunJobTaskOutput{} + out.RunId = w.RunId + return out, nil +} + +// RunJobTask_RunJobTaskOutputFromSDK converts the sdk-go type to the mirror. +func RunJobTask_RunJobTaskOutputFromSDK(v *sdk.RunJobTask_RunJobTaskOutput) (*RunJobTask_RunJobTaskOutput, error) { + if v == nil { + return nil, nil + } + out := &RunJobTask_RunJobTaskOutput{} + out.RunId = v.RunId + return out, nil +} + +// RunNowRequestToSDK converts the mirror to the sdk-go type. +func RunNowRequestToSDK(w *RunNowRequest) (*sdk.RunNowRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunNowRequest{} + out.JobId = w.JobId + out.JobParameters = w.JobParameters + out.IdempotencyToken = w.IdempotencyToken + conv349, err := QueueSettingsToSDK(w.Queue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunNowRequest.Queue", err) + } + out.Queue = conv349 + out.Only = w.Only + out.PerformanceTarget = w.PerformanceTarget + conv350, err := PipelineParametersToSDK(w.PipelineParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunNowRequest.PipelineParams", err) + } + out.PipelineParams = conv350 + out.JarParams = w.JarParams + out.NotebookParams = w.NotebookParams + out.PythonParams = w.PythonParams + out.SparkSubmitParams = w.SparkSubmitParams + out.PythonNamedParams = w.PythonNamedParams + out.SqlParams = w.SqlParams + out.DbtCommands = w.DbtCommands + return out, nil +} + +// RunNowRequestFromSDK converts the sdk-go type to the mirror. +func RunNowRequestFromSDK(v *sdk.RunNowRequest) (*RunNowRequest, error) { + if v == nil { + return nil, nil + } + out := &RunNowRequest{} + out.JobId = v.JobId + out.JobParameters = v.JobParameters + out.IdempotencyToken = v.IdempotencyToken + conv351, err := QueueSettingsFromSDK(v.Queue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunNowRequest.Queue", err) + } + out.Queue = conv351 + out.Only = v.Only + out.PerformanceTarget = v.PerformanceTarget + conv352, err := PipelineParametersFromSDK(v.PipelineParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunNowRequest.PipelineParams", err) + } + out.PipelineParams = conv352 + out.JarParams = v.JarParams + out.NotebookParams = v.NotebookParams + out.PythonParams = v.PythonParams + out.SparkSubmitParams = v.SparkSubmitParams + out.PythonNamedParams = v.PythonNamedParams + out.SqlParams = v.SqlParams + out.DbtCommands = v.DbtCommands + return out, nil +} + +// RunNowResponseToSDK converts the mirror to the sdk-go type. +func RunNowResponseToSDK(w *RunNowResponse) (*sdk.RunNowResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunNowResponse{} + out.RunId = w.RunId + out.NumberInJob = w.NumberInJob + return out, nil +} + +// RunNowResponseFromSDK converts the sdk-go type to the mirror. +func RunNowResponseFromSDK(v *sdk.RunNowResponse) (*RunNowResponse, error) { + if v == nil { + return nil, nil + } + out := &RunNowResponse{} + out.RunId = v.RunId + out.NumberInJob = v.NumberInJob + return out, nil +} + +// RunParametersToSDK converts the mirror to the sdk-go type. +func RunParametersToSDK(w *RunParameters) (*sdk.RunParameters, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunParameters{} + conv353, err := PipelineParametersToSDK(w.PipelineParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunParameters.PipelineParams", err) + } + out.PipelineParams = conv353 + out.JarParams = w.JarParams + out.NotebookParams = w.NotebookParams + out.PythonParams = w.PythonParams + out.SparkSubmitParams = w.SparkSubmitParams + out.PythonNamedParams = w.PythonNamedParams + out.SqlParams = w.SqlParams + out.DbtCommands = w.DbtCommands + return out, nil +} + +// RunParametersFromSDK converts the sdk-go type to the mirror. +func RunParametersFromSDK(v *sdk.RunParameters) (*RunParameters, error) { + if v == nil { + return nil, nil + } + out := &RunParameters{} + conv354, err := PipelineParametersFromSDK(v.PipelineParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunParameters.PipelineParams", err) + } + out.PipelineParams = conv354 + out.JarParams = v.JarParams + out.NotebookParams = v.NotebookParams + out.PythonParams = v.PythonParams + out.SparkSubmitParams = v.SparkSubmitParams + out.PythonNamedParams = v.PythonNamedParams + out.SqlParams = v.SqlParams + out.DbtCommands = v.DbtCommands + return out, nil +} + +// RunStateToSDK converts the mirror to the sdk-go type. +func RunStateToSDK(w *RunState) (*sdk.RunState, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunState{} + out.LifeCycleState = w.LifeCycleState + out.ResultState = w.ResultState + out.StateMessage = w.StateMessage + out.UserCancelledOrTimedout = w.UserCancelledOrTimedout + out.QueueReason = w.QueueReason + return out, nil +} + +// RunStateFromSDK converts the sdk-go type to the mirror. +func RunStateFromSDK(v *sdk.RunState) (*RunState, error) { + if v == nil { + return nil, nil + } + out := &RunState{} + out.LifeCycleState = v.LifeCycleState + out.ResultState = v.ResultState + out.StateMessage = v.StateMessage + out.UserCancelledOrTimedout = v.UserCancelledOrTimedout + out.QueueReason = v.QueueReason + return out, nil +} + +// RunStatusToSDK converts the mirror to the sdk-go type. +func RunStatusToSDK(w *RunStatus) (*sdk.RunStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunStatus{} + out.State = w.State + conv355, err := TerminationDetailsToSDK(w.TerminationDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunStatus.TerminationDetails", err) + } + out.TerminationDetails = conv355 + conv356, err := QueueDetailsToSDK(w.QueueDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunStatus.QueueDetails", err) + } + out.QueueDetails = conv356 + return out, nil +} + +// RunStatusFromSDK converts the sdk-go type to the mirror. +func RunStatusFromSDK(v *sdk.RunStatus) (*RunStatus, error) { + if v == nil { + return nil, nil + } + out := &RunStatus{} + out.State = v.State + conv357, err := TerminationDetailsFromSDK(v.TerminationDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunStatus.TerminationDetails", err) + } + out.TerminationDetails = conv357 + conv358, err := QueueDetailsFromSDK(v.QueueDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunStatus.QueueDetails", err) + } + out.QueueDetails = conv358 + return out, nil +} + +// RunTaskToSDK converts the mirror to the sdk-go type. +func RunTaskToSDK(w *RunTask) (*sdk.RunTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunTask{} + out.RunId = w.RunId + conv359, err := RunStateToSDK(w.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.State", err) + } + out.State = conv359 + out.RunPageUrl = w.RunPageUrl + conv360, err := ClusterInstanceToSDK(w.ClusterInstance) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.ClusterInstance", err) + } + out.ClusterInstance = conv360 + out.AttemptNumber = w.AttemptNumber + conv361, err := GitSourceToSDK(w.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.GitSource", err) + } + out.GitSource = conv361 + conv362, err := ResolvedValuesToSDK(w.ResolvedValues) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.ResolvedValues", err) + } + out.ResolvedValues = conv362 + conv363, err := RunStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Status", err) + } + out.Status = conv363 + out.EffectivePerformanceTarget = w.EffectivePerformanceTarget + out.TaskKey = w.TaskKey + out.Description = w.Description + conv364, err := convertSlice(w.DependsOn, TaskDependencyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.DependsOn", err) + } + out.DependsOn = conv364 + out.RunIf = w.RunIf + out.TimeoutSeconds = w.TimeoutSeconds + conv365, err := JobEmailNotificationsToSDK(w.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.EmailNotifications", err) + } + out.EmailNotifications = conv365 + conv366, err := JobsHealthRulesToSDK(w.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Health", err) + } + out.Health = conv366 + conv367, err := NotificationSettingsToSDK(w.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.NotificationSettings", err) + } + out.NotificationSettings = conv367 + conv368, err := WebhookNotificationsToSDK(w.WebhookNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.WebhookNotifications", err) + } + out.WebhookNotifications = conv368 + { + var members []string + if w.EnvironmentKey != nil { + members = append(members, "environment_key") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.EnvironmentKey != nil: + out.EnvironmentRef = &sdk.RunTask_EnvironmentRef_EnvironmentKey{EnvironmentKey: *w.EnvironmentKey} + } + out.Disabled = w.Disabled + conv369, err := ComputeToSDK(w.Compute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Compute", err) + } + out.Compute = conv369 + out.EnvironmentVariablesKey = w.EnvironmentVariablesKey + { + var members []string + if w.NotebookTask != nil { + members = append(members, "notebook_task") + } + if w.SparkJarTask != nil { + members = append(members, "spark_jar_task") + } + if w.SparkPythonTask != nil { + members = append(members, "spark_python_task") + } + if w.SparkSubmitTask != nil { + members = append(members, "spark_submit_task") + } + if w.PipelineTask != nil { + members = append(members, "pipeline_task") + } + if w.PythonWheelTask != nil { + members = append(members, "python_wheel_task") + } + if w.DbtTask != nil { + members = append(members, "dbt_task") + } + if w.SqlTask != nil { + members = append(members, "sql_task") + } + if w.RunJobTask != nil { + members = append(members, "run_job_task") + } + if w.ConditionTask != nil { + members = append(members, "condition_task") + } + if w.ForEachTask != nil { + members = append(members, "for_each_task") + } + if w.CleanRoomsNotebookTask != nil { + members = append(members, "clean_rooms_notebook_task") + } + if w.GenAiComputeTask != nil { + members = append(members, "gen_ai_compute_task") + } + if w.AlertTask != nil { + members = append(members, "alert_task") + } + if w.PowerBiTask != nil { + members = append(members, "power_bi_task") + } + if w.DashboardTask != nil { + members = append(members, "dashboard_task") + } + if w.DbtCloudTask != nil { + members = append(members, "dbt_cloud_task") + } + if w.DbtPlatformTask != nil { + members = append(members, "dbt_platform_task") + } + if w.PythonOperatorTask != nil { + members = append(members, "python_operator_task") + } + if w.AiRuntimeTask != nil { + members = append(members, "ai_runtime_task") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NotebookTask != nil: + conv370, err := NotebookTaskToSDK(w.NotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_NotebookTask{NotebookTask: *conv370} + case w.SparkJarTask != nil: + conv371, err := SparkJarTaskToSDK(w.SparkJarTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_SparkJarTask{SparkJarTask: *conv371} + case w.SparkPythonTask != nil: + conv372, err := SparkPythonTaskToSDK(w.SparkPythonTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_SparkPythonTask{SparkPythonTask: *conv372} + case w.SparkSubmitTask != nil: + conv373, err := SparkSubmitTaskToSDK(w.SparkSubmitTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_SparkSubmitTask{SparkSubmitTask: *conv373} + case w.PipelineTask != nil: + conv374, err := PipelineTaskToSDK(w.PipelineTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_PipelineTask{PipelineTask: *conv374} + case w.PythonWheelTask != nil: + conv375, err := PythonWheelTaskToSDK(w.PythonWheelTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_PythonWheelTask{PythonWheelTask: *conv375} + case w.DbtTask != nil: + conv376, err := DbtTaskToSDK(w.DbtTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_DbtTask{DbtTask: *conv376} + case w.SqlTask != nil: + conv377, err := SqlTaskToSDK(w.SqlTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_SqlTask{SqlTask: *conv377} + case w.RunJobTask != nil: + conv378, err := RunJobTaskToSDK(w.RunJobTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_RunJobTask{RunJobTask: *conv378} + case w.ConditionTask != nil: + conv379, err := ConditionTaskToSDK(w.ConditionTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_ConditionTask{ConditionTask: *conv379} + case w.ForEachTask != nil: + conv380, err := ForEachTaskToSDK(w.ForEachTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_ForEachTask{ForEachTask: *conv380} + case w.CleanRoomsNotebookTask != nil: + conv381, err := CleanRoomsNotebookTaskToSDK(w.CleanRoomsNotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_CleanRoomsNotebookTask{CleanRoomsNotebookTask: *conv381} + case w.GenAiComputeTask != nil: + conv382, err := GenAiComputeTaskToSDK(w.GenAiComputeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_GenAiComputeTask{GenAiComputeTask: *conv382} + case w.AlertTask != nil: + conv383, err := AlertTaskToSDK(w.AlertTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_AlertTask{AlertTask: *conv383} + case w.PowerBiTask != nil: + conv384, err := PowerBiTaskToSDK(w.PowerBiTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_PowerBiTask{PowerBiTask: *conv384} + case w.DashboardTask != nil: + conv385, err := DashboardTaskToSDK(w.DashboardTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_DashboardTask{DashboardTask: *conv385} + case w.DbtCloudTask != nil: + conv386, err := DbtCloudTaskToSDK(w.DbtCloudTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_DbtCloudTask{DbtCloudTask: *conv386} + case w.DbtPlatformTask != nil: + conv387, err := DbtPlatformTaskToSDK(w.DbtPlatformTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_DbtPlatformTask{DbtPlatformTask: *conv387} + case w.PythonOperatorTask != nil: + conv388, err := PythonOperatorTaskToSDK(w.PythonOperatorTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_PythonOperatorTask{PythonOperatorTask: *conv388} + case w.AiRuntimeTask != nil: + conv389, err := AiRuntimeTaskToSDK(w.AiRuntimeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.Task = &sdk.RunTask_Task_AiRuntimeTask{AiRuntimeTask: *conv389} + } + { + var members []string + if w.ExistingClusterId != nil { + members = append(members, "existing_cluster_id") + } + if w.NewCluster != nil { + members = append(members, "new_cluster") + } + if w.JobClusterKey != nil { + members = append(members, "job_cluster_key") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ExistingClusterId != nil: + out.Spec = &sdk.RunTask_Spec_ExistingClusterId{ExistingClusterId: *w.ExistingClusterId} + case w.NewCluster != nil: + conv390, err := ClusterSpec_NewClusterToSDK(w.NewCluster) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Spec", err) + } + out.Spec = &sdk.RunTask_Spec_NewCluster{NewCluster: *conv390} + case w.JobClusterKey != nil: + out.Spec = &sdk.RunTask_Spec_JobClusterKey{JobClusterKey: *w.JobClusterKey} + } + conv391, err := convertSlice(w.Libraries, LibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Libraries", err) + } + out.Libraries = conv391 + out.MaxRetries = w.MaxRetries + out.MinRetryIntervalMillis = w.MinRetryIntervalMillis + out.RetryOnTimeout = w.RetryOnTimeout + out.DisableAutoOptimization = w.DisableAutoOptimization + out.StartTime = w.StartTime + out.SetupDuration = w.SetupDuration + out.ExecutionDuration = w.ExecutionDuration + out.CleanupDuration = w.CleanupDuration + out.EndTime = w.EndTime + out.RunDuration = w.RunDuration + out.QueueDuration = w.QueueDuration + return out, nil +} + +// RunTaskFromSDK converts the sdk-go type to the mirror. +func RunTaskFromSDK(v *sdk.RunTask) (*RunTask, error) { + if v == nil { + return nil, nil + } + out := &RunTask{} + out.RunId = v.RunId + conv392, err := RunStateFromSDK(v.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.State", err) + } + out.State = conv392 + out.RunPageUrl = v.RunPageUrl + conv393, err := ClusterInstanceFromSDK(v.ClusterInstance) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.ClusterInstance", err) + } + out.ClusterInstance = conv393 + out.AttemptNumber = v.AttemptNumber + conv394, err := GitSourceFromSDK(v.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.GitSource", err) + } + out.GitSource = conv394 + conv395, err := ResolvedValuesFromSDK(v.ResolvedValues) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.ResolvedValues", err) + } + out.ResolvedValues = conv395 + conv396, err := RunStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Status", err) + } + out.Status = conv396 + out.EffectivePerformanceTarget = v.EffectivePerformanceTarget + out.TaskKey = v.TaskKey + out.Description = v.Description + conv397, err := convertSlice(v.DependsOn, TaskDependencyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.DependsOn", err) + } + out.DependsOn = conv397 + out.RunIf = v.RunIf + out.TimeoutSeconds = v.TimeoutSeconds + conv398, err := JobEmailNotificationsFromSDK(v.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.EmailNotifications", err) + } + out.EmailNotifications = conv398 + conv399, err := JobsHealthRulesFromSDK(v.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Health", err) + } + out.Health = conv399 + conv400, err := NotificationSettingsFromSDK(v.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.NotificationSettings", err) + } + out.NotificationSettings = conv400 + conv401, err := WebhookNotificationsFromSDK(v.WebhookNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.WebhookNotifications", err) + } + out.WebhookNotifications = conv401 + switch value := v.EnvironmentRef.(type) { + case *sdk.RunTask_EnvironmentRef_EnvironmentKey: + if value != nil { + out.EnvironmentKey = new(value.EnvironmentKey) + } + } + out.Disabled = v.Disabled + conv402, err := ComputeFromSDK(v.Compute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Compute", err) + } + out.Compute = conv402 + out.EnvironmentVariablesKey = v.EnvironmentVariablesKey + switch value := v.Task.(type) { + case *sdk.RunTask_Task_NotebookTask: + if value != nil { + conv403, err := NotebookTaskFromSDK(&value.NotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.NotebookTask = conv403 + } + case *sdk.RunTask_Task_SparkJarTask: + if value != nil { + conv404, err := SparkJarTaskFromSDK(&value.SparkJarTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.SparkJarTask = conv404 + } + case *sdk.RunTask_Task_SparkPythonTask: + if value != nil { + conv405, err := SparkPythonTaskFromSDK(&value.SparkPythonTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.SparkPythonTask = conv405 + } + case *sdk.RunTask_Task_SparkSubmitTask: + if value != nil { + conv406, err := SparkSubmitTaskFromSDK(&value.SparkSubmitTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.SparkSubmitTask = conv406 + } + case *sdk.RunTask_Task_PipelineTask: + if value != nil { + conv407, err := PipelineTaskFromSDK(&value.PipelineTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.PipelineTask = conv407 + } + case *sdk.RunTask_Task_PythonWheelTask: + if value != nil { + conv408, err := PythonWheelTaskFromSDK(&value.PythonWheelTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.PythonWheelTask = conv408 + } + case *sdk.RunTask_Task_DbtTask: + if value != nil { + conv409, err := DbtTaskFromSDK(&value.DbtTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.DbtTask = conv409 + } + case *sdk.RunTask_Task_SqlTask: + if value != nil { + conv410, err := SqlTaskFromSDK(&value.SqlTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.SqlTask = conv410 + } + case *sdk.RunTask_Task_RunJobTask: + if value != nil { + conv411, err := RunJobTaskFromSDK(&value.RunJobTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.RunJobTask = conv411 + } + case *sdk.RunTask_Task_ConditionTask: + if value != nil { + conv412, err := ConditionTaskFromSDK(&value.ConditionTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.ConditionTask = conv412 + } + case *sdk.RunTask_Task_ForEachTask: + if value != nil { + conv413, err := ForEachTaskFromSDK(&value.ForEachTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.ForEachTask = conv413 + } + case *sdk.RunTask_Task_CleanRoomsNotebookTask: + if value != nil { + conv414, err := CleanRoomsNotebookTaskFromSDK(&value.CleanRoomsNotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.CleanRoomsNotebookTask = conv414 + } + case *sdk.RunTask_Task_GenAiComputeTask: + if value != nil { + conv415, err := GenAiComputeTaskFromSDK(&value.GenAiComputeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.GenAiComputeTask = conv415 + } + case *sdk.RunTask_Task_AlertTask: + if value != nil { + conv416, err := AlertTaskFromSDK(&value.AlertTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.AlertTask = conv416 + } + case *sdk.RunTask_Task_PowerBiTask: + if value != nil { + conv417, err := PowerBiTaskFromSDK(&value.PowerBiTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.PowerBiTask = conv417 + } + case *sdk.RunTask_Task_DashboardTask: + if value != nil { + conv418, err := DashboardTaskFromSDK(&value.DashboardTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.DashboardTask = conv418 + } + case *sdk.RunTask_Task_DbtCloudTask: + if value != nil { + conv419, err := DbtCloudTaskFromSDK(&value.DbtCloudTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.DbtCloudTask = conv419 + } + case *sdk.RunTask_Task_DbtPlatformTask: + if value != nil { + conv420, err := DbtPlatformTaskFromSDK(&value.DbtPlatformTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.DbtPlatformTask = conv420 + } + case *sdk.RunTask_Task_PythonOperatorTask: + if value != nil { + conv421, err := PythonOperatorTaskFromSDK(&value.PythonOperatorTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.PythonOperatorTask = conv421 + } + case *sdk.RunTask_Task_AiRuntimeTask: + if value != nil { + conv422, err := AiRuntimeTaskFromSDK(&value.AiRuntimeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Task", err) + } + out.AiRuntimeTask = conv422 + } + } + switch value := v.Spec.(type) { + case *sdk.RunTask_Spec_ExistingClusterId: + if value != nil { + out.ExistingClusterId = new(value.ExistingClusterId) + } + case *sdk.RunTask_Spec_NewCluster: + if value != nil { + conv423, err := ClusterSpec_NewClusterFromSDK(&value.NewCluster) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Spec", err) + } + out.NewCluster = conv423 + } + case *sdk.RunTask_Spec_JobClusterKey: + if value != nil { + out.JobClusterKey = new(value.JobClusterKey) + } + } + conv424, err := convertSlice(v.Libraries, LibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTask.Libraries", err) + } + out.Libraries = conv424 + out.MaxRetries = v.MaxRetries + out.MinRetryIntervalMillis = v.MinRetryIntervalMillis + out.RetryOnTimeout = v.RetryOnTimeout + out.DisableAutoOptimization = v.DisableAutoOptimization + out.StartTime = v.StartTime + out.SetupDuration = v.SetupDuration + out.ExecutionDuration = v.ExecutionDuration + out.CleanupDuration = v.CleanupDuration + out.EndTime = v.EndTime + out.RunDuration = v.RunDuration + out.QueueDuration = v.QueueDuration + return out, nil +} + +// RunTaskSettingsToSDK converts the mirror to the sdk-go type. +func RunTaskSettingsToSDK(w *RunTaskSettings) (*sdk.RunTaskSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunTaskSettings{} + out.TaskKey = w.TaskKey + out.Description = w.Description + conv425, err := convertSlice(w.DependsOn, TaskDependencyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.DependsOn", err) + } + out.DependsOn = conv425 + out.RunIf = w.RunIf + out.TimeoutSeconds = w.TimeoutSeconds + conv426, err := JobEmailNotificationsToSDK(w.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.EmailNotifications", err) + } + out.EmailNotifications = conv426 + conv427, err := JobsHealthRulesToSDK(w.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Health", err) + } + out.Health = conv427 + conv428, err := NotificationSettingsToSDK(w.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.NotificationSettings", err) + } + out.NotificationSettings = conv428 + conv429, err := WebhookNotificationsToSDK(w.WebhookNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.WebhookNotifications", err) + } + out.WebhookNotifications = conv429 + { + var members []string + if w.EnvironmentKey != nil { + members = append(members, "environment_key") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.EnvironmentKey != nil: + out.EnvironmentRef = &sdk.RunTaskSettings_EnvironmentRef_EnvironmentKey{EnvironmentKey: *w.EnvironmentKey} + } + out.Disabled = w.Disabled + conv430, err := ComputeToSDK(w.Compute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Compute", err) + } + out.Compute = conv430 + out.EnvironmentVariablesKey = w.EnvironmentVariablesKey + { + var members []string + if w.NotebookTask != nil { + members = append(members, "notebook_task") + } + if w.SparkJarTask != nil { + members = append(members, "spark_jar_task") + } + if w.SparkPythonTask != nil { + members = append(members, "spark_python_task") + } + if w.SparkSubmitTask != nil { + members = append(members, "spark_submit_task") + } + if w.PipelineTask != nil { + members = append(members, "pipeline_task") + } + if w.PythonWheelTask != nil { + members = append(members, "python_wheel_task") + } + if w.DbtTask != nil { + members = append(members, "dbt_task") + } + if w.SqlTask != nil { + members = append(members, "sql_task") + } + if w.RunJobTask != nil { + members = append(members, "run_job_task") + } + if w.ConditionTask != nil { + members = append(members, "condition_task") + } + if w.ForEachTask != nil { + members = append(members, "for_each_task") + } + if w.CleanRoomsNotebookTask != nil { + members = append(members, "clean_rooms_notebook_task") + } + if w.GenAiComputeTask != nil { + members = append(members, "gen_ai_compute_task") + } + if w.AlertTask != nil { + members = append(members, "alert_task") + } + if w.PowerBiTask != nil { + members = append(members, "power_bi_task") + } + if w.DashboardTask != nil { + members = append(members, "dashboard_task") + } + if w.DbtCloudTask != nil { + members = append(members, "dbt_cloud_task") + } + if w.DbtPlatformTask != nil { + members = append(members, "dbt_platform_task") + } + if w.PythonOperatorTask != nil { + members = append(members, "python_operator_task") + } + if w.AiRuntimeTask != nil { + members = append(members, "ai_runtime_task") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NotebookTask != nil: + conv431, err := NotebookTaskToSDK(w.NotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_NotebookTask{NotebookTask: *conv431} + case w.SparkJarTask != nil: + conv432, err := SparkJarTaskToSDK(w.SparkJarTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_SparkJarTask{SparkJarTask: *conv432} + case w.SparkPythonTask != nil: + conv433, err := SparkPythonTaskToSDK(w.SparkPythonTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_SparkPythonTask{SparkPythonTask: *conv433} + case w.SparkSubmitTask != nil: + conv434, err := SparkSubmitTaskToSDK(w.SparkSubmitTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_SparkSubmitTask{SparkSubmitTask: *conv434} + case w.PipelineTask != nil: + conv435, err := PipelineTaskToSDK(w.PipelineTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_PipelineTask{PipelineTask: *conv435} + case w.PythonWheelTask != nil: + conv436, err := PythonWheelTaskToSDK(w.PythonWheelTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_PythonWheelTask{PythonWheelTask: *conv436} + case w.DbtTask != nil: + conv437, err := DbtTaskToSDK(w.DbtTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_DbtTask{DbtTask: *conv437} + case w.SqlTask != nil: + conv438, err := SqlTaskToSDK(w.SqlTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_SqlTask{SqlTask: *conv438} + case w.RunJobTask != nil: + conv439, err := RunJobTaskToSDK(w.RunJobTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_RunJobTask{RunJobTask: *conv439} + case w.ConditionTask != nil: + conv440, err := ConditionTaskToSDK(w.ConditionTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_ConditionTask{ConditionTask: *conv440} + case w.ForEachTask != nil: + conv441, err := ForEachTaskToSDK(w.ForEachTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_ForEachTask{ForEachTask: *conv441} + case w.CleanRoomsNotebookTask != nil: + conv442, err := CleanRoomsNotebookTaskToSDK(w.CleanRoomsNotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_CleanRoomsNotebookTask{CleanRoomsNotebookTask: *conv442} + case w.GenAiComputeTask != nil: + conv443, err := GenAiComputeTaskToSDK(w.GenAiComputeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_GenAiComputeTask{GenAiComputeTask: *conv443} + case w.AlertTask != nil: + conv444, err := AlertTaskToSDK(w.AlertTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_AlertTask{AlertTask: *conv444} + case w.PowerBiTask != nil: + conv445, err := PowerBiTaskToSDK(w.PowerBiTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_PowerBiTask{PowerBiTask: *conv445} + case w.DashboardTask != nil: + conv446, err := DashboardTaskToSDK(w.DashboardTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_DashboardTask{DashboardTask: *conv446} + case w.DbtCloudTask != nil: + conv447, err := DbtCloudTaskToSDK(w.DbtCloudTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_DbtCloudTask{DbtCloudTask: *conv447} + case w.DbtPlatformTask != nil: + conv448, err := DbtPlatformTaskToSDK(w.DbtPlatformTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_DbtPlatformTask{DbtPlatformTask: *conv448} + case w.PythonOperatorTask != nil: + conv449, err := PythonOperatorTaskToSDK(w.PythonOperatorTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_PythonOperatorTask{PythonOperatorTask: *conv449} + case w.AiRuntimeTask != nil: + conv450, err := AiRuntimeTaskToSDK(w.AiRuntimeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.Task = &sdk.RunTaskSettings_Task_AiRuntimeTask{AiRuntimeTask: *conv450} + } + { + var members []string + if w.ExistingClusterId != nil { + members = append(members, "existing_cluster_id") + } + if w.NewCluster != nil { + members = append(members, "new_cluster") + } + if w.JobClusterKey != nil { + members = append(members, "job_cluster_key") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ExistingClusterId != nil: + out.Spec = &sdk.RunTaskSettings_Spec_ExistingClusterId{ExistingClusterId: *w.ExistingClusterId} + case w.NewCluster != nil: + conv451, err := ClusterSpec_NewClusterToSDK(w.NewCluster) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Spec", err) + } + out.Spec = &sdk.RunTaskSettings_Spec_NewCluster{NewCluster: *conv451} + case w.JobClusterKey != nil: + out.Spec = &sdk.RunTaskSettings_Spec_JobClusterKey{JobClusterKey: *w.JobClusterKey} + } + conv452, err := convertSlice(w.Libraries, LibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Libraries", err) + } + out.Libraries = conv452 + out.MaxRetries = w.MaxRetries + out.MinRetryIntervalMillis = w.MinRetryIntervalMillis + out.RetryOnTimeout = w.RetryOnTimeout + out.DisableAutoOptimization = w.DisableAutoOptimization + return out, nil +} + +// RunTaskSettingsFromSDK converts the sdk-go type to the mirror. +func RunTaskSettingsFromSDK(v *sdk.RunTaskSettings) (*RunTaskSettings, error) { + if v == nil { + return nil, nil + } + out := &RunTaskSettings{} + out.TaskKey = v.TaskKey + out.Description = v.Description + conv453, err := convertSlice(v.DependsOn, TaskDependencyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.DependsOn", err) + } + out.DependsOn = conv453 + out.RunIf = v.RunIf + out.TimeoutSeconds = v.TimeoutSeconds + conv454, err := JobEmailNotificationsFromSDK(v.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.EmailNotifications", err) + } + out.EmailNotifications = conv454 + conv455, err := JobsHealthRulesFromSDK(v.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Health", err) + } + out.Health = conv455 + conv456, err := NotificationSettingsFromSDK(v.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.NotificationSettings", err) + } + out.NotificationSettings = conv456 + conv457, err := WebhookNotificationsFromSDK(v.WebhookNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.WebhookNotifications", err) + } + out.WebhookNotifications = conv457 + switch value := v.EnvironmentRef.(type) { + case *sdk.RunTaskSettings_EnvironmentRef_EnvironmentKey: + if value != nil { + out.EnvironmentKey = new(value.EnvironmentKey) + } + } + out.Disabled = v.Disabled + conv458, err := ComputeFromSDK(v.Compute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Compute", err) + } + out.Compute = conv458 + out.EnvironmentVariablesKey = v.EnvironmentVariablesKey + switch value := v.Task.(type) { + case *sdk.RunTaskSettings_Task_NotebookTask: + if value != nil { + conv459, err := NotebookTaskFromSDK(&value.NotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.NotebookTask = conv459 + } + case *sdk.RunTaskSettings_Task_SparkJarTask: + if value != nil { + conv460, err := SparkJarTaskFromSDK(&value.SparkJarTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.SparkJarTask = conv460 + } + case *sdk.RunTaskSettings_Task_SparkPythonTask: + if value != nil { + conv461, err := SparkPythonTaskFromSDK(&value.SparkPythonTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.SparkPythonTask = conv461 + } + case *sdk.RunTaskSettings_Task_SparkSubmitTask: + if value != nil { + conv462, err := SparkSubmitTaskFromSDK(&value.SparkSubmitTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.SparkSubmitTask = conv462 + } + case *sdk.RunTaskSettings_Task_PipelineTask: + if value != nil { + conv463, err := PipelineTaskFromSDK(&value.PipelineTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.PipelineTask = conv463 + } + case *sdk.RunTaskSettings_Task_PythonWheelTask: + if value != nil { + conv464, err := PythonWheelTaskFromSDK(&value.PythonWheelTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.PythonWheelTask = conv464 + } + case *sdk.RunTaskSettings_Task_DbtTask: + if value != nil { + conv465, err := DbtTaskFromSDK(&value.DbtTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.DbtTask = conv465 + } + case *sdk.RunTaskSettings_Task_SqlTask: + if value != nil { + conv466, err := SqlTaskFromSDK(&value.SqlTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.SqlTask = conv466 + } + case *sdk.RunTaskSettings_Task_RunJobTask: + if value != nil { + conv467, err := RunJobTaskFromSDK(&value.RunJobTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.RunJobTask = conv467 + } + case *sdk.RunTaskSettings_Task_ConditionTask: + if value != nil { + conv468, err := ConditionTaskFromSDK(&value.ConditionTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.ConditionTask = conv468 + } + case *sdk.RunTaskSettings_Task_ForEachTask: + if value != nil { + conv469, err := ForEachTaskFromSDK(&value.ForEachTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.ForEachTask = conv469 + } + case *sdk.RunTaskSettings_Task_CleanRoomsNotebookTask: + if value != nil { + conv470, err := CleanRoomsNotebookTaskFromSDK(&value.CleanRoomsNotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.CleanRoomsNotebookTask = conv470 + } + case *sdk.RunTaskSettings_Task_GenAiComputeTask: + if value != nil { + conv471, err := GenAiComputeTaskFromSDK(&value.GenAiComputeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.GenAiComputeTask = conv471 + } + case *sdk.RunTaskSettings_Task_AlertTask: + if value != nil { + conv472, err := AlertTaskFromSDK(&value.AlertTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.AlertTask = conv472 + } + case *sdk.RunTaskSettings_Task_PowerBiTask: + if value != nil { + conv473, err := PowerBiTaskFromSDK(&value.PowerBiTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.PowerBiTask = conv473 + } + case *sdk.RunTaskSettings_Task_DashboardTask: + if value != nil { + conv474, err := DashboardTaskFromSDK(&value.DashboardTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.DashboardTask = conv474 + } + case *sdk.RunTaskSettings_Task_DbtCloudTask: + if value != nil { + conv475, err := DbtCloudTaskFromSDK(&value.DbtCloudTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.DbtCloudTask = conv475 + } + case *sdk.RunTaskSettings_Task_DbtPlatformTask: + if value != nil { + conv476, err := DbtPlatformTaskFromSDK(&value.DbtPlatformTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.DbtPlatformTask = conv476 + } + case *sdk.RunTaskSettings_Task_PythonOperatorTask: + if value != nil { + conv477, err := PythonOperatorTaskFromSDK(&value.PythonOperatorTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.PythonOperatorTask = conv477 + } + case *sdk.RunTaskSettings_Task_AiRuntimeTask: + if value != nil { + conv478, err := AiRuntimeTaskFromSDK(&value.AiRuntimeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Task", err) + } + out.AiRuntimeTask = conv478 + } + } + switch value := v.Spec.(type) { + case *sdk.RunTaskSettings_Spec_ExistingClusterId: + if value != nil { + out.ExistingClusterId = new(value.ExistingClusterId) + } + case *sdk.RunTaskSettings_Spec_NewCluster: + if value != nil { + conv479, err := ClusterSpec_NewClusterFromSDK(&value.NewCluster) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Spec", err) + } + out.NewCluster = conv479 + } + case *sdk.RunTaskSettings_Spec_JobClusterKey: + if value != nil { + out.JobClusterKey = new(value.JobClusterKey) + } + } + conv480, err := convertSlice(v.Libraries, LibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTaskSettings.Libraries", err) + } + out.Libraries = conv480 + out.MaxRetries = v.MaxRetries + out.MinRetryIntervalMillis = v.MinRetryIntervalMillis + out.RetryOnTimeout = v.RetryOnTimeout + out.DisableAutoOptimization = v.DisableAutoOptimization + return out, nil +} + +// RunTriggerInfoToSDK converts the mirror to the sdk-go type. +func RunTriggerInfoToSDK(w *RunTriggerInfo) (*sdk.RunTriggerInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.RunTriggerInfo{} + conv481, err := SqlConditionRunInfoDetailsToSDK(w.SqlCondition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTriggerInfo.SqlCondition", err) + } + out.SqlCondition = conv481 + out.RunId = w.RunId + return out, nil +} + +// RunTriggerInfoFromSDK converts the sdk-go type to the mirror. +func RunTriggerInfoFromSDK(v *sdk.RunTriggerInfo) (*RunTriggerInfo, error) { + if v == nil { + return nil, nil + } + out := &RunTriggerInfo{} + conv482, err := SqlConditionRunInfoDetailsFromSDK(v.SqlCondition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RunTriggerInfo.SqlCondition", err) + } + out.SqlCondition = conv482 + out.RunId = v.RunId + return out, nil +} + +// Run_JobLevelParametersToSDK converts the mirror to the sdk-go type. +func Run_JobLevelParametersToSDK(w *Run_JobLevelParameters) (*sdk.Run_JobLevelParameters, error) { + if w == nil { + return nil, nil + } + out := &sdk.Run_JobLevelParameters{} + out.Name = w.Name + out.Default = w.Default + out.Value = w.Value + return out, nil +} + +// Run_JobLevelParametersFromSDK converts the sdk-go type to the mirror. +func Run_JobLevelParametersFromSDK(v *sdk.Run_JobLevelParameters) (*Run_JobLevelParameters, error) { + if v == nil { + return nil, nil + } + out := &Run_JobLevelParameters{} + out.Name = v.Name + out.Default = v.Default + out.Value = v.Value + return out, nil +} + +// S3StorageInfoToSDK converts the mirror to the sdk-go type. +func S3StorageInfoToSDK(w *S3StorageInfo) (*sdk.S3StorageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.S3StorageInfo{} + out.Destination = w.Destination + out.Region = w.Region + out.Endpoint = w.Endpoint + out.EnableEncryption = w.EnableEncryption + out.EncryptionType = w.EncryptionType + out.KmsKey = w.KmsKey + out.CannedAcl = w.CannedAcl + return out, nil +} + +// S3StorageInfoFromSDK converts the sdk-go type to the mirror. +func S3StorageInfoFromSDK(v *sdk.S3StorageInfo) (*S3StorageInfo, error) { + if v == nil { + return nil, nil + } + out := &S3StorageInfo{} + out.Destination = v.Destination + out.Region = v.Region + out.Endpoint = v.Endpoint + out.EnableEncryption = v.EnableEncryption + out.EncryptionType = v.EncryptionType + out.KmsKey = v.KmsKey + out.CannedAcl = v.CannedAcl + return out, nil +} + +// ScheduleTriggerStateToSDK converts the mirror to the sdk-go type. +func ScheduleTriggerStateToSDK(w *ScheduleTriggerState) (*sdk.ScheduleTriggerState, error) { + if w == nil { + return nil, nil + } + out := &sdk.ScheduleTriggerState{} + return out, nil +} + +// ScheduleTriggerStateFromSDK converts the sdk-go type to the mirror. +func ScheduleTriggerStateFromSDK(v *sdk.ScheduleTriggerState) (*ScheduleTriggerState, error) { + if v == nil { + return nil, nil + } + out := &ScheduleTriggerState{} + return out, nil +} + +// SparkJarTaskToSDK converts the mirror to the sdk-go type. +func SparkJarTaskToSDK(w *SparkJarTask) (*sdk.SparkJarTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.SparkJarTask{} + out.JarUri = w.JarUri + out.MainClassName = w.MainClassName + out.Parameters = w.Parameters + out.RunAsRepl = w.RunAsRepl + return out, nil +} + +// SparkJarTaskFromSDK converts the sdk-go type to the mirror. +func SparkJarTaskFromSDK(v *sdk.SparkJarTask) (*SparkJarTask, error) { + if v == nil { + return nil, nil + } + out := &SparkJarTask{} + out.JarUri = v.JarUri + out.MainClassName = v.MainClassName + out.Parameters = v.Parameters + out.RunAsRepl = v.RunAsRepl + return out, nil +} + +// SparkPythonTaskToSDK converts the mirror to the sdk-go type. +func SparkPythonTaskToSDK(w *SparkPythonTask) (*sdk.SparkPythonTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.SparkPythonTask{} + out.PythonFile = w.PythonFile + out.Parameters = w.Parameters + out.Source = w.Source + return out, nil +} + +// SparkPythonTaskFromSDK converts the sdk-go type to the mirror. +func SparkPythonTaskFromSDK(v *sdk.SparkPythonTask) (*SparkPythonTask, error) { + if v == nil { + return nil, nil + } + out := &SparkPythonTask{} + out.PythonFile = v.PythonFile + out.Parameters = v.Parameters + out.Source = v.Source + return out, nil +} + +// SparkSubmitTaskToSDK converts the mirror to the sdk-go type. +func SparkSubmitTaskToSDK(w *SparkSubmitTask) (*sdk.SparkSubmitTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.SparkSubmitTask{} + out.Parameters = w.Parameters + return out, nil +} + +// SparkSubmitTaskFromSDK converts the sdk-go type to the mirror. +func SparkSubmitTaskFromSDK(v *sdk.SparkSubmitTask) (*SparkSubmitTask, error) { + if v == nil { + return nil, nil + } + out := &SparkSubmitTask{} + out.Parameters = v.Parameters + return out, nil +} + +// SparseCheckoutToSDK converts the mirror to the sdk-go type. +func SparseCheckoutToSDK(w *SparseCheckout) (*sdk.SparseCheckout, error) { + if w == nil { + return nil, nil + } + out := &sdk.SparseCheckout{} + out.Patterns = w.Patterns + return out, nil +} + +// SparseCheckoutFromSDK converts the sdk-go type to the mirror. +func SparseCheckoutFromSDK(v *sdk.SparseCheckout) (*SparseCheckout, error) { + if v == nil { + return nil, nil + } + out := &SparseCheckout{} + out.Patterns = v.Patterns + return out, nil +} + +// SqlConditionConfigurationToSDK converts the mirror to the sdk-go type. +func SqlConditionConfigurationToSDK(w *SqlConditionConfiguration) (*sdk.SqlConditionConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlConditionConfiguration{} + out.SqlQueryId = w.SqlQueryId + out.WarehouseId = w.WarehouseId + out.TriggerMode = w.TriggerMode + return out, nil +} + +// SqlConditionConfigurationFromSDK converts the sdk-go type to the mirror. +func SqlConditionConfigurationFromSDK(v *sdk.SqlConditionConfiguration) (*SqlConditionConfiguration, error) { + if v == nil { + return nil, nil + } + out := &SqlConditionConfiguration{} + out.SqlQueryId = v.SqlQueryId + out.WarehouseId = v.WarehouseId + out.TriggerMode = v.TriggerMode + return out, nil +} + +// SqlConditionRunInfoDetailsToSDK converts the mirror to the sdk-go type. +func SqlConditionRunInfoDetailsToSDK(w *SqlConditionRunInfoDetails) (*sdk.SqlConditionRunInfoDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlConditionRunInfoDetails{} + out.ConditionEvaluationSqlStatementId = w.ConditionEvaluationSqlStatementId + out.ConditionEvaluationSatisfied = w.ConditionEvaluationSatisfied + out.ConditionEvaluationSqlSessionId = w.ConditionEvaluationSqlSessionId + return out, nil +} + +// SqlConditionRunInfoDetailsFromSDK converts the sdk-go type to the mirror. +func SqlConditionRunInfoDetailsFromSDK(v *sdk.SqlConditionRunInfoDetails) (*SqlConditionRunInfoDetails, error) { + if v == nil { + return nil, nil + } + out := &SqlConditionRunInfoDetails{} + out.ConditionEvaluationSqlStatementId = v.ConditionEvaluationSqlStatementId + out.ConditionEvaluationSatisfied = v.ConditionEvaluationSatisfied + out.ConditionEvaluationSqlSessionId = v.ConditionEvaluationSqlSessionId + return out, nil +} + +// SqlConditionStateToSDK converts the mirror to the sdk-go type. +func SqlConditionStateToSDK(w *SqlConditionState) (*sdk.SqlConditionState, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlConditionState{} + out.LatestConditionEvaluationSqlStatementId = w.LatestConditionEvaluationSqlStatementId + out.LatestConditionEvaluationSatisfied = w.LatestConditionEvaluationSatisfied + out.LatestConditionEvaluationSqlSessionId = w.LatestConditionEvaluationSqlSessionId + return out, nil +} + +// SqlConditionStateFromSDK converts the sdk-go type to the mirror. +func SqlConditionStateFromSDK(v *sdk.SqlConditionState) (*SqlConditionState, error) { + if v == nil { + return nil, nil + } + out := &SqlConditionState{} + out.LatestConditionEvaluationSqlStatementId = v.LatestConditionEvaluationSqlStatementId + out.LatestConditionEvaluationSatisfied = v.LatestConditionEvaluationSatisfied + out.LatestConditionEvaluationSqlSessionId = v.LatestConditionEvaluationSqlSessionId + return out, nil +} + +// SqlTaskToSDK converts the mirror to the sdk-go type. +func SqlTaskToSDK(w *SqlTask) (*sdk.SqlTask, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTask{} + out.Parameters = w.Parameters + { + var members []string + if w.Query != nil { + members = append(members, "query") + } + if w.Dashboard != nil { + members = append(members, "dashboard") + } + if w.Alert != nil { + members = append(members, "alert") + } + if w.File != nil { + members = append(members, "file") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Query != nil: + conv483, err := SqlTaskQueryToSDK(w.Query) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask.SqlTaskType", err) + } + out.SqlTaskType = &sdk.SqlTask_SqlTaskType_Query{Query: *conv483} + case w.Dashboard != nil: + conv484, err := SqlTaskDashboardToSDK(w.Dashboard) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask.SqlTaskType", err) + } + out.SqlTaskType = &sdk.SqlTask_SqlTaskType_Dashboard{Dashboard: *conv484} + case w.Alert != nil: + conv485, err := SqlTaskAlertToSDK(w.Alert) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask.SqlTaskType", err) + } + out.SqlTaskType = &sdk.SqlTask_SqlTaskType_Alert{Alert: *conv485} + case w.File != nil: + conv486, err := SqlTaskFileToSDK(w.File) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask.SqlTaskType", err) + } + out.SqlTaskType = &sdk.SqlTask_SqlTaskType_File{File: *conv486} + } + out.WarehouseId = w.WarehouseId + return out, nil +} + +// SqlTaskFromSDK converts the sdk-go type to the mirror. +func SqlTaskFromSDK(v *sdk.SqlTask) (*SqlTask, error) { + if v == nil { + return nil, nil + } + out := &SqlTask{} + out.Parameters = v.Parameters + switch value := v.SqlTaskType.(type) { + case *sdk.SqlTask_SqlTaskType_Query: + if value != nil { + conv487, err := SqlTaskQueryFromSDK(&value.Query) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask.SqlTaskType", err) + } + out.Query = conv487 + } + case *sdk.SqlTask_SqlTaskType_Dashboard: + if value != nil { + conv488, err := SqlTaskDashboardFromSDK(&value.Dashboard) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask.SqlTaskType", err) + } + out.Dashboard = conv488 + } + case *sdk.SqlTask_SqlTaskType_Alert: + if value != nil { + conv489, err := SqlTaskAlertFromSDK(&value.Alert) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask.SqlTaskType", err) + } + out.Alert = conv489 + } + case *sdk.SqlTask_SqlTaskType_File: + if value != nil { + conv490, err := SqlTaskFileFromSDK(&value.File) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask.SqlTaskType", err) + } + out.File = conv490 + } + } + out.WarehouseId = v.WarehouseId + return out, nil +} + +// SqlTaskAlertToSDK converts the mirror to the sdk-go type. +func SqlTaskAlertToSDK(w *SqlTaskAlert) (*sdk.SqlTaskAlert, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTaskAlert{} + out.AlertId = w.AlertId + conv491, err := convertSlice(w.Subscriptions, SqlTaskSubscriptionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTaskAlert.Subscriptions", err) + } + out.Subscriptions = conv491 + out.PauseSubscriptions = w.PauseSubscriptions + return out, nil +} + +// SqlTaskAlertFromSDK converts the sdk-go type to the mirror. +func SqlTaskAlertFromSDK(v *sdk.SqlTaskAlert) (*SqlTaskAlert, error) { + if v == nil { + return nil, nil + } + out := &SqlTaskAlert{} + out.AlertId = v.AlertId + conv492, err := convertSlice(v.Subscriptions, SqlTaskSubscriptionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTaskAlert.Subscriptions", err) + } + out.Subscriptions = conv492 + out.PauseSubscriptions = v.PauseSubscriptions + return out, nil +} + +// SqlTaskDashboardToSDK converts the mirror to the sdk-go type. +func SqlTaskDashboardToSDK(w *SqlTaskDashboard) (*sdk.SqlTaskDashboard, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTaskDashboard{} + out.DashboardId = w.DashboardId + conv493, err := convertSlice(w.Subscriptions, SqlTaskSubscriptionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTaskDashboard.Subscriptions", err) + } + out.Subscriptions = conv493 + out.CustomSubject = w.CustomSubject + out.PauseSubscriptions = w.PauseSubscriptions + return out, nil +} + +// SqlTaskDashboardFromSDK converts the sdk-go type to the mirror. +func SqlTaskDashboardFromSDK(v *sdk.SqlTaskDashboard) (*SqlTaskDashboard, error) { + if v == nil { + return nil, nil + } + out := &SqlTaskDashboard{} + out.DashboardId = v.DashboardId + conv494, err := convertSlice(v.Subscriptions, SqlTaskSubscriptionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTaskDashboard.Subscriptions", err) + } + out.Subscriptions = conv494 + out.CustomSubject = v.CustomSubject + out.PauseSubscriptions = v.PauseSubscriptions + return out, nil +} + +// SqlTaskFileToSDK converts the mirror to the sdk-go type. +func SqlTaskFileToSDK(w *SqlTaskFile) (*sdk.SqlTaskFile, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTaskFile{} + out.Path = w.Path + out.Source = w.Source + return out, nil +} + +// SqlTaskFileFromSDK converts the sdk-go type to the mirror. +func SqlTaskFileFromSDK(v *sdk.SqlTaskFile) (*SqlTaskFile, error) { + if v == nil { + return nil, nil + } + out := &SqlTaskFile{} + out.Path = v.Path + out.Source = v.Source + return out, nil +} + +// SqlTaskQueryToSDK converts the mirror to the sdk-go type. +func SqlTaskQueryToSDK(w *SqlTaskQuery) (*sdk.SqlTaskQuery, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTaskQuery{} + { + var members []string + if w.QueryId != nil { + members = append(members, "query_id") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.QueryId != nil: + out.QueryType = &sdk.SqlTaskQuery_QueryType_QueryId{QueryId: *w.QueryId} + } + return out, nil +} + +// SqlTaskQueryFromSDK converts the sdk-go type to the mirror. +func SqlTaskQueryFromSDK(v *sdk.SqlTaskQuery) (*SqlTaskQuery, error) { + if v == nil { + return nil, nil + } + out := &SqlTaskQuery{} + switch value := v.QueryType.(type) { + case *sdk.SqlTaskQuery_QueryType_QueryId: + if value != nil { + out.QueryId = new(value.QueryId) + } + } + return out, nil +} + +// SqlTaskSubscriptionToSDK converts the mirror to the sdk-go type. +func SqlTaskSubscriptionToSDK(w *SqlTaskSubscription) (*sdk.SqlTaskSubscription, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTaskSubscription{} + { + var members []string + if w.UserName != nil { + members = append(members, "user_name") + } + if w.DestinationId != nil { + members = append(members, "destination_id") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UserName != nil: + out.SubscriptionType = &sdk.SqlTaskSubscription_SubscriptionType_UserName{UserName: *w.UserName} + case w.DestinationId != nil: + out.SubscriptionType = &sdk.SqlTaskSubscription_SubscriptionType_DestinationId{DestinationId: *w.DestinationId} + } + return out, nil +} + +// SqlTaskSubscriptionFromSDK converts the sdk-go type to the mirror. +func SqlTaskSubscriptionFromSDK(v *sdk.SqlTaskSubscription) (*SqlTaskSubscription, error) { + if v == nil { + return nil, nil + } + out := &SqlTaskSubscription{} + switch value := v.SubscriptionType.(type) { + case *sdk.SqlTaskSubscription_SubscriptionType_UserName: + if value != nil { + out.UserName = new(value.UserName) + } + case *sdk.SqlTaskSubscription_SubscriptionType_DestinationId: + if value != nil { + out.DestinationId = new(value.DestinationId) + } + } + return out, nil +} + +// SqlTask_SqlAlertOutputToSDK converts the mirror to the sdk-go type. +func SqlTask_SqlAlertOutputToSDK(w *SqlTask_SqlAlertOutput) (*sdk.SqlTask_SqlAlertOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTask_SqlAlertOutput{} + out.QueryText = w.QueryText + conv495, err := convertSlice(w.SqlStatements, SqlTask_SqlStatementOutputToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlAlertOutput.SqlStatements", err) + } + out.SqlStatements = conv495 + out.OutputLink = w.OutputLink + out.WarehouseId = w.WarehouseId + out.AlertState = w.AlertState + return out, nil +} + +// SqlTask_SqlAlertOutputFromSDK converts the sdk-go type to the mirror. +func SqlTask_SqlAlertOutputFromSDK(v *sdk.SqlTask_SqlAlertOutput) (*SqlTask_SqlAlertOutput, error) { + if v == nil { + return nil, nil + } + out := &SqlTask_SqlAlertOutput{} + out.QueryText = v.QueryText + conv496, err := convertSlice(v.SqlStatements, SqlTask_SqlStatementOutputFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlAlertOutput.SqlStatements", err) + } + out.SqlStatements = conv496 + out.OutputLink = v.OutputLink + out.WarehouseId = v.WarehouseId + out.AlertState = v.AlertState + return out, nil +} + +// SqlTask_SqlDashboardOutputToSDK converts the mirror to the sdk-go type. +func SqlTask_SqlDashboardOutputToSDK(w *SqlTask_SqlDashboardOutput) (*sdk.SqlTask_SqlDashboardOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTask_SqlDashboardOutput{} + conv497, err := convertSlice(w.Widgets, SqlTask_SqlDashboardWidgetOutputToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlDashboardOutput.Widgets", err) + } + out.Widgets = conv497 + out.WarehouseId = w.WarehouseId + return out, nil +} + +// SqlTask_SqlDashboardOutputFromSDK converts the sdk-go type to the mirror. +func SqlTask_SqlDashboardOutputFromSDK(v *sdk.SqlTask_SqlDashboardOutput) (*SqlTask_SqlDashboardOutput, error) { + if v == nil { + return nil, nil + } + out := &SqlTask_SqlDashboardOutput{} + conv498, err := convertSlice(v.Widgets, SqlTask_SqlDashboardWidgetOutputFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlDashboardOutput.Widgets", err) + } + out.Widgets = conv498 + out.WarehouseId = v.WarehouseId + return out, nil +} + +// SqlTask_SqlDashboardWidgetOutputToSDK converts the mirror to the sdk-go type. +func SqlTask_SqlDashboardWidgetOutputToSDK(w *SqlTask_SqlDashboardWidgetOutput) (*sdk.SqlTask_SqlDashboardWidgetOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTask_SqlDashboardWidgetOutput{} + out.WidgetId = w.WidgetId + out.WidgetTitle = w.WidgetTitle + out.OutputLink = w.OutputLink + out.Status = w.Status + conv499, err := SqlTask_SqlOutputErrorToSDK(w.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlDashboardWidgetOutput.Error", err) + } + out.Error = conv499 + out.StartTime = w.StartTime + out.EndTime = w.EndTime + return out, nil +} + +// SqlTask_SqlDashboardWidgetOutputFromSDK converts the sdk-go type to the mirror. +func SqlTask_SqlDashboardWidgetOutputFromSDK(v *sdk.SqlTask_SqlDashboardWidgetOutput) (*SqlTask_SqlDashboardWidgetOutput, error) { + if v == nil { + return nil, nil + } + out := &SqlTask_SqlDashboardWidgetOutput{} + out.WidgetId = v.WidgetId + out.WidgetTitle = v.WidgetTitle + out.OutputLink = v.OutputLink + out.Status = v.Status + conv500, err := SqlTask_SqlOutputErrorFromSDK(v.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlDashboardWidgetOutput.Error", err) + } + out.Error = conv500 + out.StartTime = v.StartTime + out.EndTime = v.EndTime + return out, nil +} + +// SqlTask_SqlOutputToSDK converts the mirror to the sdk-go type. +func SqlTask_SqlOutputToSDK(w *SqlTask_SqlOutput) (*sdk.SqlTask_SqlOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTask_SqlOutput{} + { + var members []string + if w.QueryOutput != nil { + members = append(members, "query_output") + } + if w.DashboardOutput != nil { + members = append(members, "dashboard_output") + } + if w.AlertOutput != nil { + members = append(members, "alert_output") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.QueryOutput != nil: + conv501, err := SqlTask_SqlQueryOutputToSDK(w.QueryOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlOutput.SqlOutputType", err) + } + out.SqlOutputType = &sdk.SqlTask_SqlOutput_SqlOutputType_QueryOutput{QueryOutput: *conv501} + case w.DashboardOutput != nil: + conv502, err := SqlTask_SqlDashboardOutputToSDK(w.DashboardOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlOutput.SqlOutputType", err) + } + out.SqlOutputType = &sdk.SqlTask_SqlOutput_SqlOutputType_DashboardOutput{DashboardOutput: *conv502} + case w.AlertOutput != nil: + conv503, err := SqlTask_SqlAlertOutputToSDK(w.AlertOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlOutput.SqlOutputType", err) + } + out.SqlOutputType = &sdk.SqlTask_SqlOutput_SqlOutputType_AlertOutput{AlertOutput: *conv503} + } + return out, nil +} + +// SqlTask_SqlOutputFromSDK converts the sdk-go type to the mirror. +func SqlTask_SqlOutputFromSDK(v *sdk.SqlTask_SqlOutput) (*SqlTask_SqlOutput, error) { + if v == nil { + return nil, nil + } + out := &SqlTask_SqlOutput{} + switch value := v.SqlOutputType.(type) { + case *sdk.SqlTask_SqlOutput_SqlOutputType_QueryOutput: + if value != nil { + conv504, err := SqlTask_SqlQueryOutputFromSDK(&value.QueryOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlOutput.SqlOutputType", err) + } + out.QueryOutput = conv504 + } + case *sdk.SqlTask_SqlOutput_SqlOutputType_DashboardOutput: + if value != nil { + conv505, err := SqlTask_SqlDashboardOutputFromSDK(&value.DashboardOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlOutput.SqlOutputType", err) + } + out.DashboardOutput = conv505 + } + case *sdk.SqlTask_SqlOutput_SqlOutputType_AlertOutput: + if value != nil { + conv506, err := SqlTask_SqlAlertOutputFromSDK(&value.AlertOutput) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlOutput.SqlOutputType", err) + } + out.AlertOutput = conv506 + } + } + return out, nil +} + +// SqlTask_SqlOutputErrorToSDK converts the mirror to the sdk-go type. +func SqlTask_SqlOutputErrorToSDK(w *SqlTask_SqlOutputError) (*sdk.SqlTask_SqlOutputError, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTask_SqlOutputError{} + out.Message = w.Message + return out, nil +} + +// SqlTask_SqlOutputErrorFromSDK converts the sdk-go type to the mirror. +func SqlTask_SqlOutputErrorFromSDK(v *sdk.SqlTask_SqlOutputError) (*SqlTask_SqlOutputError, error) { + if v == nil { + return nil, nil + } + out := &SqlTask_SqlOutputError{} + out.Message = v.Message + return out, nil +} + +// SqlTask_SqlQueryOutputToSDK converts the mirror to the sdk-go type. +func SqlTask_SqlQueryOutputToSDK(w *SqlTask_SqlQueryOutput) (*sdk.SqlTask_SqlQueryOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTask_SqlQueryOutput{} + out.QueryText = w.QueryText + out.EndpointId = w.EndpointId + conv507, err := convertSlice(w.SqlStatements, SqlTask_SqlStatementOutputToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlQueryOutput.SqlStatements", err) + } + out.SqlStatements = conv507 + out.OutputLink = w.OutputLink + out.WarehouseId = w.WarehouseId + return out, nil +} + +// SqlTask_SqlQueryOutputFromSDK converts the sdk-go type to the mirror. +func SqlTask_SqlQueryOutputFromSDK(v *sdk.SqlTask_SqlQueryOutput) (*SqlTask_SqlQueryOutput, error) { + if v == nil { + return nil, nil + } + out := &SqlTask_SqlQueryOutput{} + out.QueryText = v.QueryText + out.EndpointId = v.EndpointId + conv508, err := convertSlice(v.SqlStatements, SqlTask_SqlStatementOutputFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SqlTask_SqlQueryOutput.SqlStatements", err) + } + out.SqlStatements = conv508 + out.OutputLink = v.OutputLink + out.WarehouseId = v.WarehouseId + return out, nil +} + +// SqlTask_SqlStatementOutputToSDK converts the mirror to the sdk-go type. +func SqlTask_SqlStatementOutputToSDK(w *SqlTask_SqlStatementOutput) (*sdk.SqlTask_SqlStatementOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.SqlTask_SqlStatementOutput{} + out.LookupKey = w.LookupKey + return out, nil +} + +// SqlTask_SqlStatementOutputFromSDK converts the sdk-go type to the mirror. +func SqlTask_SqlStatementOutputFromSDK(v *sdk.SqlTask_SqlStatementOutput) (*SqlTask_SqlStatementOutput, error) { + if v == nil { + return nil, nil + } + out := &SqlTask_SqlStatementOutput{} + out.LookupKey = v.LookupKey + return out, nil +} + +// SubmitRunRequestToSDK converts the mirror to the sdk-go type. +func SubmitRunRequestToSDK(w *SubmitRunRequest) (*sdk.SubmitRunRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SubmitRunRequest{} + conv509, err := convertSlice(w.AccessControlList, AccessControlRequestToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.AccessControlList", err) + } + out.AccessControlList = conv509 + conv510, err := QueueSettingsToSDK(w.Queue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.Queue", err) + } + out.Queue = conv510 + conv511, err := JobRunAsToSDK(w.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.RunAs", err) + } + out.RunAs = conv511 + out.RunName = w.RunName + out.TimeoutSeconds = w.TimeoutSeconds + conv512, err := JobsHealthRulesToSDK(w.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.Health", err) + } + out.Health = conv512 + out.IdempotencyToken = w.IdempotencyToken + conv513, err := convertSlice(w.Tasks, RunTaskSettingsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.Tasks", err) + } + out.Tasks = conv513 + conv514, err := GitSourceToSDK(w.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.GitSource", err) + } + out.GitSource = conv514 + conv515, err := WebhookNotificationsToSDK(w.WebhookNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.WebhookNotifications", err) + } + out.WebhookNotifications = conv515 + conv516, err := JobEmailNotificationsToSDK(w.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.EmailNotifications", err) + } + out.EmailNotifications = conv516 + conv517, err := NotificationSettingsToSDK(w.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.NotificationSettings", err) + } + out.NotificationSettings = conv517 + conv518, err := convertSlice(w.Environments, JobEnvironmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.Environments", err) + } + out.Environments = conv518 + out.BudgetPolicyId = w.BudgetPolicyId + out.UsagePolicyId = w.UsagePolicyId + conv519, err := convertSlice(w.EnvironmentVariables, JobEnvironmentVariablesToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.EnvironmentVariables", err) + } + out.EnvironmentVariables = conv519 + out.PerformanceTarget = w.PerformanceTarget + return out, nil +} + +// SubmitRunRequestFromSDK converts the sdk-go type to the mirror. +func SubmitRunRequestFromSDK(v *sdk.SubmitRunRequest) (*SubmitRunRequest, error) { + if v == nil { + return nil, nil + } + out := &SubmitRunRequest{} + conv520, err := convertSlice(v.AccessControlList, AccessControlRequestFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.AccessControlList", err) + } + out.AccessControlList = conv520 + conv521, err := QueueSettingsFromSDK(v.Queue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.Queue", err) + } + out.Queue = conv521 + conv522, err := JobRunAsFromSDK(v.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.RunAs", err) + } + out.RunAs = conv522 + out.RunName = v.RunName + out.TimeoutSeconds = v.TimeoutSeconds + conv523, err := JobsHealthRulesFromSDK(v.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.Health", err) + } + out.Health = conv523 + out.IdempotencyToken = v.IdempotencyToken + conv524, err := convertSlice(v.Tasks, RunTaskSettingsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.Tasks", err) + } + out.Tasks = conv524 + conv525, err := GitSourceFromSDK(v.GitSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.GitSource", err) + } + out.GitSource = conv525 + conv526, err := WebhookNotificationsFromSDK(v.WebhookNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.WebhookNotifications", err) + } + out.WebhookNotifications = conv526 + conv527, err := JobEmailNotificationsFromSDK(v.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.EmailNotifications", err) + } + out.EmailNotifications = conv527 + conv528, err := NotificationSettingsFromSDK(v.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.NotificationSettings", err) + } + out.NotificationSettings = conv528 + conv529, err := convertSlice(v.Environments, JobEnvironmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.Environments", err) + } + out.Environments = conv529 + out.BudgetPolicyId = v.BudgetPolicyId + out.UsagePolicyId = v.UsagePolicyId + conv530, err := convertSlice(v.EnvironmentVariables, JobEnvironmentVariablesFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubmitRunRequest.EnvironmentVariables", err) + } + out.EnvironmentVariables = conv530 + out.PerformanceTarget = v.PerformanceTarget + return out, nil +} + +// SubmitRunResponseToSDK converts the mirror to the sdk-go type. +func SubmitRunResponseToSDK(w *SubmitRunResponse) (*sdk.SubmitRunResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.SubmitRunResponse{} + out.RunId = w.RunId + return out, nil +} + +// SubmitRunResponseFromSDK converts the sdk-go type to the mirror. +func SubmitRunResponseFromSDK(v *sdk.SubmitRunResponse) (*SubmitRunResponse, error) { + if v == nil { + return nil, nil + } + out := &SubmitRunResponse{} + out.RunId = v.RunId + return out, nil +} + +// SubscriptionToSDK converts the mirror to the sdk-go type. +func SubscriptionToSDK(w *Subscription) (*sdk.Subscription, error) { + if w == nil { + return nil, nil + } + out := &sdk.Subscription{} + conv531, err := convertSlice(w.Subscribers, Subscription_SubscriberToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Subscription.Subscribers", err) + } + out.Subscribers = conv531 + out.Paused = w.Paused + out.CustomSubject = w.CustomSubject + return out, nil +} + +// SubscriptionFromSDK converts the sdk-go type to the mirror. +func SubscriptionFromSDK(v *sdk.Subscription) (*Subscription, error) { + if v == nil { + return nil, nil + } + out := &Subscription{} + conv532, err := convertSlice(v.Subscribers, Subscription_SubscriberFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Subscription.Subscribers", err) + } + out.Subscribers = conv532 + out.Paused = v.Paused + out.CustomSubject = v.CustomSubject + return out, nil +} + +// Subscription_SubscriberToSDK converts the mirror to the sdk-go type. +func Subscription_SubscriberToSDK(w *Subscription_Subscriber) (*sdk.Subscription_Subscriber, error) { + if w == nil { + return nil, nil + } + out := &sdk.Subscription_Subscriber{} + { + var members []string + if w.UserName != nil { + members = append(members, "user_name") + } + if w.DestinationId != nil { + members = append(members, "destination_id") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UserName != nil: + out.SubscriptionType = &sdk.Subscription_Subscriber_SubscriptionType_UserName{UserName: *w.UserName} + case w.DestinationId != nil: + out.SubscriptionType = &sdk.Subscription_Subscriber_SubscriptionType_DestinationId{DestinationId: *w.DestinationId} + } + return out, nil +} + +// Subscription_SubscriberFromSDK converts the sdk-go type to the mirror. +func Subscription_SubscriberFromSDK(v *sdk.Subscription_Subscriber) (*Subscription_Subscriber, error) { + if v == nil { + return nil, nil + } + out := &Subscription_Subscriber{} + switch value := v.SubscriptionType.(type) { + case *sdk.Subscription_Subscriber_SubscriptionType_UserName: + if value != nil { + out.UserName = new(value.UserName) + } + case *sdk.Subscription_Subscriber_SubscriptionType_DestinationId: + if value != nil { + out.DestinationId = new(value.DestinationId) + } + } + return out, nil +} + +// TableStateToSDK converts the mirror to the sdk-go type. +func TableStateToSDK(w *TableState) (*sdk.TableState, error) { + if w == nil { + return nil, nil + } + out := &sdk.TableState{} + out.TableName = w.TableName + out.HasSeenUpdates = w.HasSeenUpdates + return out, nil +} + +// TableStateFromSDK converts the sdk-go type to the mirror. +func TableStateFromSDK(v *sdk.TableState) (*TableState, error) { + if v == nil { + return nil, nil + } + out := &TableState{} + out.TableName = v.TableName + out.HasSeenUpdates = v.HasSeenUpdates + return out, nil +} + +// TableTriggerConfigurationToSDK converts the mirror to the sdk-go type. +func TableTriggerConfigurationToSDK(w *TableTriggerConfiguration) (*sdk.TableTriggerConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.TableTriggerConfiguration{} + out.TableNames = w.TableNames + out.MinTimeBetweenTriggersSeconds = w.MinTimeBetweenTriggersSeconds + out.WaitAfterLastChangeSeconds = w.WaitAfterLastChangeSeconds + out.Condition = w.Condition + return out, nil +} + +// TableTriggerConfigurationFromSDK converts the sdk-go type to the mirror. +func TableTriggerConfigurationFromSDK(v *sdk.TableTriggerConfiguration) (*TableTriggerConfiguration, error) { + if v == nil { + return nil, nil + } + out := &TableTriggerConfiguration{} + out.TableNames = v.TableNames + out.MinTimeBetweenTriggersSeconds = v.MinTimeBetweenTriggersSeconds + out.WaitAfterLastChangeSeconds = v.WaitAfterLastChangeSeconds + out.Condition = v.Condition + return out, nil +} + +// TableTriggerStateToSDK converts the mirror to the sdk-go type. +func TableTriggerStateToSDK(w *TableTriggerState) (*sdk.TableTriggerState, error) { + if w == nil { + return nil, nil + } + out := &sdk.TableTriggerState{} + conv533, err := convertSlice(w.LastSeenTableStates, TableStateToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableTriggerState.LastSeenTableStates", err) + } + out.LastSeenTableStates = conv533 + out.UsingScalableMonitoring = w.UsingScalableMonitoring + return out, nil +} + +// TableTriggerStateFromSDK converts the sdk-go type to the mirror. +func TableTriggerStateFromSDK(v *sdk.TableTriggerState) (*TableTriggerState, error) { + if v == nil { + return nil, nil + } + out := &TableTriggerState{} + conv534, err := convertSlice(v.LastSeenTableStates, TableStateFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableTriggerState.LastSeenTableStates", err) + } + out.LastSeenTableStates = conv534 + out.UsingScalableMonitoring = v.UsingScalableMonitoring + return out, nil +} + +// TaskDependencyToSDK converts the mirror to the sdk-go type. +func TaskDependencyToSDK(w *TaskDependency) (*sdk.TaskDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.TaskDependency{} + out.TaskKey = w.TaskKey + out.Outcome = w.Outcome + return out, nil +} + +// TaskDependencyFromSDK converts the sdk-go type to the mirror. +func TaskDependencyFromSDK(v *sdk.TaskDependency) (*TaskDependency, error) { + if v == nil { + return nil, nil + } + out := &TaskDependency{} + out.TaskKey = v.TaskKey + out.Outcome = v.Outcome + return out, nil +} + +// TaskSettingsToSDK converts the mirror to the sdk-go type. +func TaskSettingsToSDK(w *TaskSettings) (*sdk.TaskSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.TaskSettings{} + out.TaskKey = w.TaskKey + conv535, err := convertSlice(w.DependsOn, TaskDependencyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.DependsOn", err) + } + out.DependsOn = conv535 + out.RunIf = w.RunIf + out.TimeoutSeconds = w.TimeoutSeconds + conv536, err := JobsHealthRulesToSDK(w.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Health", err) + } + out.Health = conv536 + conv537, err := JobEmailNotificationsToSDK(w.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.EmailNotifications", err) + } + out.EmailNotifications = conv537 + conv538, err := NotificationSettingsToSDK(w.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.NotificationSettings", err) + } + out.NotificationSettings = conv538 + conv539, err := WebhookNotificationsToSDK(w.WebhookNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.WebhookNotifications", err) + } + out.WebhookNotifications = conv539 + out.Description = w.Description + { + var members []string + if w.EnvironmentKey != nil { + members = append(members, "environment_key") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.EnvironmentKey != nil: + out.EnvironmentRef = &sdk.TaskSettings_EnvironmentRef_EnvironmentKey{EnvironmentKey: *w.EnvironmentKey} + } + out.Disabled = w.Disabled + conv540, err := ComputeToSDK(w.Compute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Compute", err) + } + out.Compute = conv540 + out.EnvironmentVariablesKey = w.EnvironmentVariablesKey + { + var members []string + if w.NotebookTask != nil { + members = append(members, "notebook_task") + } + if w.SparkJarTask != nil { + members = append(members, "spark_jar_task") + } + if w.SparkPythonTask != nil { + members = append(members, "spark_python_task") + } + if w.SparkSubmitTask != nil { + members = append(members, "spark_submit_task") + } + if w.PipelineTask != nil { + members = append(members, "pipeline_task") + } + if w.PythonWheelTask != nil { + members = append(members, "python_wheel_task") + } + if w.DbtTask != nil { + members = append(members, "dbt_task") + } + if w.SqlTask != nil { + members = append(members, "sql_task") + } + if w.RunJobTask != nil { + members = append(members, "run_job_task") + } + if w.ConditionTask != nil { + members = append(members, "condition_task") + } + if w.ForEachTask != nil { + members = append(members, "for_each_task") + } + if w.CleanRoomsNotebookTask != nil { + members = append(members, "clean_rooms_notebook_task") + } + if w.GenAiComputeTask != nil { + members = append(members, "gen_ai_compute_task") + } + if w.AlertTask != nil { + members = append(members, "alert_task") + } + if w.PowerBiTask != nil { + members = append(members, "power_bi_task") + } + if w.DashboardTask != nil { + members = append(members, "dashboard_task") + } + if w.DbtCloudTask != nil { + members = append(members, "dbt_cloud_task") + } + if w.DbtPlatformTask != nil { + members = append(members, "dbt_platform_task") + } + if w.PythonOperatorTask != nil { + members = append(members, "python_operator_task") + } + if w.AiRuntimeTask != nil { + members = append(members, "ai_runtime_task") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NotebookTask != nil: + conv541, err := NotebookTaskToSDK(w.NotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_NotebookTask{NotebookTask: *conv541} + case w.SparkJarTask != nil: + conv542, err := SparkJarTaskToSDK(w.SparkJarTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_SparkJarTask{SparkJarTask: *conv542} + case w.SparkPythonTask != nil: + conv543, err := SparkPythonTaskToSDK(w.SparkPythonTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_SparkPythonTask{SparkPythonTask: *conv543} + case w.SparkSubmitTask != nil: + conv544, err := SparkSubmitTaskToSDK(w.SparkSubmitTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_SparkSubmitTask{SparkSubmitTask: *conv544} + case w.PipelineTask != nil: + conv545, err := PipelineTaskToSDK(w.PipelineTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_PipelineTask{PipelineTask: *conv545} + case w.PythonWheelTask != nil: + conv546, err := PythonWheelTaskToSDK(w.PythonWheelTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_PythonWheelTask{PythonWheelTask: *conv546} + case w.DbtTask != nil: + conv547, err := DbtTaskToSDK(w.DbtTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_DbtTask{DbtTask: *conv547} + case w.SqlTask != nil: + conv548, err := SqlTaskToSDK(w.SqlTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_SqlTask{SqlTask: *conv548} + case w.RunJobTask != nil: + conv549, err := RunJobTaskToSDK(w.RunJobTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_RunJobTask{RunJobTask: *conv549} + case w.ConditionTask != nil: + conv550, err := ConditionTaskToSDK(w.ConditionTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_ConditionTask{ConditionTask: *conv550} + case w.ForEachTask != nil: + conv551, err := ForEachTaskToSDK(w.ForEachTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_ForEachTask{ForEachTask: *conv551} + case w.CleanRoomsNotebookTask != nil: + conv552, err := CleanRoomsNotebookTaskToSDK(w.CleanRoomsNotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_CleanRoomsNotebookTask{CleanRoomsNotebookTask: *conv552} + case w.GenAiComputeTask != nil: + conv553, err := GenAiComputeTaskToSDK(w.GenAiComputeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_GenAiComputeTask{GenAiComputeTask: *conv553} + case w.AlertTask != nil: + conv554, err := AlertTaskToSDK(w.AlertTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_AlertTask{AlertTask: *conv554} + case w.PowerBiTask != nil: + conv555, err := PowerBiTaskToSDK(w.PowerBiTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_PowerBiTask{PowerBiTask: *conv555} + case w.DashboardTask != nil: + conv556, err := DashboardTaskToSDK(w.DashboardTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_DashboardTask{DashboardTask: *conv556} + case w.DbtCloudTask != nil: + conv557, err := DbtCloudTaskToSDK(w.DbtCloudTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_DbtCloudTask{DbtCloudTask: *conv557} + case w.DbtPlatformTask != nil: + conv558, err := DbtPlatformTaskToSDK(w.DbtPlatformTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_DbtPlatformTask{DbtPlatformTask: *conv558} + case w.PythonOperatorTask != nil: + conv559, err := PythonOperatorTaskToSDK(w.PythonOperatorTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_PythonOperatorTask{PythonOperatorTask: *conv559} + case w.AiRuntimeTask != nil: + conv560, err := AiRuntimeTaskToSDK(w.AiRuntimeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.Task = &sdk.TaskSettings_Task_AiRuntimeTask{AiRuntimeTask: *conv560} + } + { + var members []string + if w.ExistingClusterId != nil { + members = append(members, "existing_cluster_id") + } + if w.NewCluster != nil { + members = append(members, "new_cluster") + } + if w.JobClusterKey != nil { + members = append(members, "job_cluster_key") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ExistingClusterId != nil: + out.Spec = &sdk.TaskSettings_Spec_ExistingClusterId{ExistingClusterId: *w.ExistingClusterId} + case w.NewCluster != nil: + conv561, err := ClusterSpec_NewClusterToSDK(w.NewCluster) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Spec", err) + } + out.Spec = &sdk.TaskSettings_Spec_NewCluster{NewCluster: *conv561} + case w.JobClusterKey != nil: + out.Spec = &sdk.TaskSettings_Spec_JobClusterKey{JobClusterKey: *w.JobClusterKey} + } + conv562, err := convertSlice(w.Libraries, LibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Libraries", err) + } + out.Libraries = conv562 + out.MaxRetries = w.MaxRetries + out.MinRetryIntervalMillis = w.MinRetryIntervalMillis + out.RetryOnTimeout = w.RetryOnTimeout + out.DisableAutoOptimization = w.DisableAutoOptimization + return out, nil +} + +// TaskSettingsFromSDK converts the sdk-go type to the mirror. +func TaskSettingsFromSDK(v *sdk.TaskSettings) (*TaskSettings, error) { + if v == nil { + return nil, nil + } + out := &TaskSettings{} + out.TaskKey = v.TaskKey + conv563, err := convertSlice(v.DependsOn, TaskDependencyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.DependsOn", err) + } + out.DependsOn = conv563 + out.RunIf = v.RunIf + out.TimeoutSeconds = v.TimeoutSeconds + conv564, err := JobsHealthRulesFromSDK(v.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Health", err) + } + out.Health = conv564 + conv565, err := JobEmailNotificationsFromSDK(v.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.EmailNotifications", err) + } + out.EmailNotifications = conv565 + conv566, err := NotificationSettingsFromSDK(v.NotificationSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.NotificationSettings", err) + } + out.NotificationSettings = conv566 + conv567, err := WebhookNotificationsFromSDK(v.WebhookNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.WebhookNotifications", err) + } + out.WebhookNotifications = conv567 + out.Description = v.Description + switch value := v.EnvironmentRef.(type) { + case *sdk.TaskSettings_EnvironmentRef_EnvironmentKey: + if value != nil { + out.EnvironmentKey = new(value.EnvironmentKey) + } + } + out.Disabled = v.Disabled + conv568, err := ComputeFromSDK(v.Compute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Compute", err) + } + out.Compute = conv568 + out.EnvironmentVariablesKey = v.EnvironmentVariablesKey + switch value := v.Task.(type) { + case *sdk.TaskSettings_Task_NotebookTask: + if value != nil { + conv569, err := NotebookTaskFromSDK(&value.NotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.NotebookTask = conv569 + } + case *sdk.TaskSettings_Task_SparkJarTask: + if value != nil { + conv570, err := SparkJarTaskFromSDK(&value.SparkJarTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.SparkJarTask = conv570 + } + case *sdk.TaskSettings_Task_SparkPythonTask: + if value != nil { + conv571, err := SparkPythonTaskFromSDK(&value.SparkPythonTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.SparkPythonTask = conv571 + } + case *sdk.TaskSettings_Task_SparkSubmitTask: + if value != nil { + conv572, err := SparkSubmitTaskFromSDK(&value.SparkSubmitTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.SparkSubmitTask = conv572 + } + case *sdk.TaskSettings_Task_PipelineTask: + if value != nil { + conv573, err := PipelineTaskFromSDK(&value.PipelineTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.PipelineTask = conv573 + } + case *sdk.TaskSettings_Task_PythonWheelTask: + if value != nil { + conv574, err := PythonWheelTaskFromSDK(&value.PythonWheelTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.PythonWheelTask = conv574 + } + case *sdk.TaskSettings_Task_DbtTask: + if value != nil { + conv575, err := DbtTaskFromSDK(&value.DbtTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.DbtTask = conv575 + } + case *sdk.TaskSettings_Task_SqlTask: + if value != nil { + conv576, err := SqlTaskFromSDK(&value.SqlTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.SqlTask = conv576 + } + case *sdk.TaskSettings_Task_RunJobTask: + if value != nil { + conv577, err := RunJobTaskFromSDK(&value.RunJobTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.RunJobTask = conv577 + } + case *sdk.TaskSettings_Task_ConditionTask: + if value != nil { + conv578, err := ConditionTaskFromSDK(&value.ConditionTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.ConditionTask = conv578 + } + case *sdk.TaskSettings_Task_ForEachTask: + if value != nil { + conv579, err := ForEachTaskFromSDK(&value.ForEachTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.ForEachTask = conv579 + } + case *sdk.TaskSettings_Task_CleanRoomsNotebookTask: + if value != nil { + conv580, err := CleanRoomsNotebookTaskFromSDK(&value.CleanRoomsNotebookTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.CleanRoomsNotebookTask = conv580 + } + case *sdk.TaskSettings_Task_GenAiComputeTask: + if value != nil { + conv581, err := GenAiComputeTaskFromSDK(&value.GenAiComputeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.GenAiComputeTask = conv581 + } + case *sdk.TaskSettings_Task_AlertTask: + if value != nil { + conv582, err := AlertTaskFromSDK(&value.AlertTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.AlertTask = conv582 + } + case *sdk.TaskSettings_Task_PowerBiTask: + if value != nil { + conv583, err := PowerBiTaskFromSDK(&value.PowerBiTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.PowerBiTask = conv583 + } + case *sdk.TaskSettings_Task_DashboardTask: + if value != nil { + conv584, err := DashboardTaskFromSDK(&value.DashboardTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.DashboardTask = conv584 + } + case *sdk.TaskSettings_Task_DbtCloudTask: + if value != nil { + conv585, err := DbtCloudTaskFromSDK(&value.DbtCloudTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.DbtCloudTask = conv585 + } + case *sdk.TaskSettings_Task_DbtPlatformTask: + if value != nil { + conv586, err := DbtPlatformTaskFromSDK(&value.DbtPlatformTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.DbtPlatformTask = conv586 + } + case *sdk.TaskSettings_Task_PythonOperatorTask: + if value != nil { + conv587, err := PythonOperatorTaskFromSDK(&value.PythonOperatorTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.PythonOperatorTask = conv587 + } + case *sdk.TaskSettings_Task_AiRuntimeTask: + if value != nil { + conv588, err := AiRuntimeTaskFromSDK(&value.AiRuntimeTask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Task", err) + } + out.AiRuntimeTask = conv588 + } + } + switch value := v.Spec.(type) { + case *sdk.TaskSettings_Spec_ExistingClusterId: + if value != nil { + out.ExistingClusterId = new(value.ExistingClusterId) + } + case *sdk.TaskSettings_Spec_NewCluster: + if value != nil { + conv589, err := ClusterSpec_NewClusterFromSDK(&value.NewCluster) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Spec", err) + } + out.NewCluster = conv589 + } + case *sdk.TaskSettings_Spec_JobClusterKey: + if value != nil { + out.JobClusterKey = new(value.JobClusterKey) + } + } + conv590, err := convertSlice(v.Libraries, LibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskSettings.Libraries", err) + } + out.Libraries = conv590 + out.MaxRetries = v.MaxRetries + out.MinRetryIntervalMillis = v.MinRetryIntervalMillis + out.RetryOnTimeout = v.RetryOnTimeout + out.DisableAutoOptimization = v.DisableAutoOptimization + return out, nil +} + +// TerminationDetailsToSDK converts the mirror to the sdk-go type. +func TerminationDetailsToSDK(w *TerminationDetails) (*sdk.TerminationDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.TerminationDetails{} + out.Code = w.Code + out.Type = w.Type + out.Message = w.Message + return out, nil +} + +// TerminationDetailsFromSDK converts the sdk-go type to the mirror. +func TerminationDetailsFromSDK(v *sdk.TerminationDetails) (*TerminationDetails, error) { + if v == nil { + return nil, nil + } + out := &TerminationDetails{} + out.Code = v.Code + out.Type = v.Type + out.Message = v.Message + return out, nil +} + +// TriggerConfigurationToSDK converts the mirror to the sdk-go type. +func TriggerConfigurationToSDK(w *TriggerConfiguration) (*sdk.TriggerConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.TriggerConfiguration{} + out.PauseStatus = w.PauseStatus + conv591, err := PeriodicTriggerConfigurationToSDK(w.Periodic) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.Periodic", err) + } + out.Periodic = conv591 + conv592, err := CronTriggerConfigurationToSDK(w.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.Schedule", err) + } + out.Schedule = conv592 + conv593, err := ContinuousTriggerConfigurationToSDK(w.Continuous) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.Continuous", err) + } + out.Continuous = conv593 + conv594, err := FileArrivalTriggerConfigurationToSDK(w.FileArrival) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.FileArrival", err) + } + out.FileArrival = conv594 + conv595, err := TableTriggerConfigurationToSDK(w.TableUpdate) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.TableUpdate", err) + } + out.TableUpdate = conv595 + conv596, err := ModelTriggerConfigurationToSDK(w.Model) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.Model", err) + } + out.Model = conv596 + conv597, err := SqlConditionConfigurationToSDK(w.SqlCondition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.SqlCondition", err) + } + out.SqlCondition = conv597 + return out, nil +} + +// TriggerConfigurationFromSDK converts the sdk-go type to the mirror. +func TriggerConfigurationFromSDK(v *sdk.TriggerConfiguration) (*TriggerConfiguration, error) { + if v == nil { + return nil, nil + } + out := &TriggerConfiguration{} + out.PauseStatus = v.PauseStatus + conv598, err := PeriodicTriggerConfigurationFromSDK(v.Periodic) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.Periodic", err) + } + out.Periodic = conv598 + conv599, err := CronTriggerConfigurationFromSDK(v.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.Schedule", err) + } + out.Schedule = conv599 + conv600, err := ContinuousTriggerConfigurationFromSDK(v.Continuous) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.Continuous", err) + } + out.Continuous = conv600 + conv601, err := FileArrivalTriggerConfigurationFromSDK(v.FileArrival) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.FileArrival", err) + } + out.FileArrival = conv601 + conv602, err := TableTriggerConfigurationFromSDK(v.TableUpdate) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.TableUpdate", err) + } + out.TableUpdate = conv602 + conv603, err := ModelTriggerConfigurationFromSDK(v.Model) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.Model", err) + } + out.Model = conv603 + conv604, err := SqlConditionConfigurationFromSDK(v.SqlCondition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerConfiguration.SqlCondition", err) + } + out.SqlCondition = conv604 + return out, nil +} + +// TriggerDetailsToSDK converts the mirror to the sdk-go type. +func TriggerDetailsToSDK(w *TriggerDetails) (*sdk.TriggerDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.TriggerDetails{} + conv605, err := PerTriggerStateToSDK(w.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerDetails.State", err) + } + out.State = conv605 + conv606, err := TriggerHistoryToSDK(w.History) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerDetails.History", err) + } + out.History = conv606 + return out, nil +} + +// TriggerDetailsFromSDK converts the sdk-go type to the mirror. +func TriggerDetailsFromSDK(v *sdk.TriggerDetails) (*TriggerDetails, error) { + if v == nil { + return nil, nil + } + out := &TriggerDetails{} + conv607, err := PerTriggerStateFromSDK(v.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerDetails.State", err) + } + out.State = conv607 + conv608, err := TriggerHistoryFromSDK(v.History) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerDetails.History", err) + } + out.History = conv608 + return out, nil +} + +// TriggerEvaluationToSDK converts the mirror to the sdk-go type. +func TriggerEvaluationToSDK(w *TriggerEvaluation) (*sdk.TriggerEvaluation, error) { + if w == nil { + return nil, nil + } + out := &sdk.TriggerEvaluation{} + out.Timestamp = w.Timestamp + out.Description = w.Description + out.RunId = w.RunId + return out, nil +} + +// TriggerEvaluationFromSDK converts the sdk-go type to the mirror. +func TriggerEvaluationFromSDK(v *sdk.TriggerEvaluation) (*TriggerEvaluation, error) { + if v == nil { + return nil, nil + } + out := &TriggerEvaluation{} + out.Timestamp = v.Timestamp + out.Description = v.Description + out.RunId = v.RunId + return out, nil +} + +// TriggerHistoryToSDK converts the mirror to the sdk-go type. +func TriggerHistoryToSDK(w *TriggerHistory) (*sdk.TriggerHistory, error) { + if w == nil { + return nil, nil + } + out := &sdk.TriggerHistory{} + conv609, err := TriggerEvaluationToSDK(w.LastTriggered) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerHistory.LastTriggered", err) + } + out.LastTriggered = conv609 + conv610, err := TriggerEvaluationToSDK(w.LastNotTriggered) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerHistory.LastNotTriggered", err) + } + out.LastNotTriggered = conv610 + conv611, err := TriggerEvaluationToSDK(w.LastFailed) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerHistory.LastFailed", err) + } + out.LastFailed = conv611 + return out, nil +} + +// TriggerHistoryFromSDK converts the sdk-go type to the mirror. +func TriggerHistoryFromSDK(v *sdk.TriggerHistory) (*TriggerHistory, error) { + if v == nil { + return nil, nil + } + out := &TriggerHistory{} + conv612, err := TriggerEvaluationFromSDK(v.LastTriggered) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerHistory.LastTriggered", err) + } + out.LastTriggered = conv612 + conv613, err := TriggerEvaluationFromSDK(v.LastNotTriggered) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerHistory.LastNotTriggered", err) + } + out.LastNotTriggered = conv613 + conv614, err := TriggerEvaluationFromSDK(v.LastFailed) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerHistory.LastFailed", err) + } + out.LastFailed = conv614 + return out, nil +} + +// TriggerSettingsToSDK converts the mirror to the sdk-go type. +func TriggerSettingsToSDK(w *TriggerSettings) (*sdk.TriggerSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.TriggerSettings{} + out.PauseStatus = w.PauseStatus + { + var members []string + if w.FileArrival != nil { + members = append(members, "file_arrival") + } + if w.Periodic != nil { + members = append(members, "periodic") + } + if w.TableUpdate != nil { + members = append(members, "table_update") + } + if w.Model != nil { + members = append(members, "model") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.FileArrival != nil: + conv615, err := FileArrivalTriggerConfigurationToSDK(w.FileArrival) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerSettings.Configuration", err) + } + out.Configuration = &sdk.TriggerSettings_Configuration_FileArrival{FileArrival: *conv615} + case w.Periodic != nil: + conv616, err := PeriodicTriggerConfigurationToSDK(w.Periodic) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerSettings.Configuration", err) + } + out.Configuration = &sdk.TriggerSettings_Configuration_Periodic{Periodic: *conv616} + case w.TableUpdate != nil: + conv617, err := TableTriggerConfigurationToSDK(w.TableUpdate) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerSettings.Configuration", err) + } + out.Configuration = &sdk.TriggerSettings_Configuration_TableUpdate{TableUpdate: *conv617} + case w.Model != nil: + conv618, err := ModelTriggerConfigurationToSDK(w.Model) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerSettings.Configuration", err) + } + out.Configuration = &sdk.TriggerSettings_Configuration_Model{Model: *conv618} + } + conv619, err := SqlConditionConfigurationToSDK(w.SqlCondition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerSettings.SqlCondition", err) + } + out.SqlCondition = conv619 + return out, nil +} + +// TriggerSettingsFromSDK converts the sdk-go type to the mirror. +func TriggerSettingsFromSDK(v *sdk.TriggerSettings) (*TriggerSettings, error) { + if v == nil { + return nil, nil + } + out := &TriggerSettings{} + out.PauseStatus = v.PauseStatus + switch value := v.Configuration.(type) { + case *sdk.TriggerSettings_Configuration_FileArrival: + if value != nil { + conv620, err := FileArrivalTriggerConfigurationFromSDK(&value.FileArrival) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerSettings.Configuration", err) + } + out.FileArrival = conv620 + } + case *sdk.TriggerSettings_Configuration_Periodic: + if value != nil { + conv621, err := PeriodicTriggerConfigurationFromSDK(&value.Periodic) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerSettings.Configuration", err) + } + out.Periodic = conv621 + } + case *sdk.TriggerSettings_Configuration_TableUpdate: + if value != nil { + conv622, err := TableTriggerConfigurationFromSDK(&value.TableUpdate) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerSettings.Configuration", err) + } + out.TableUpdate = conv622 + } + case *sdk.TriggerSettings_Configuration_Model: + if value != nil { + conv623, err := ModelTriggerConfigurationFromSDK(&value.Model) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerSettings.Configuration", err) + } + out.Model = conv623 + } + } + conv624, err := SqlConditionConfigurationFromSDK(v.SqlCondition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerSettings.SqlCondition", err) + } + out.SqlCondition = conv624 + return out, nil +} + +// TriggerStateToSDK converts the mirror to the sdk-go type. +func TriggerStateToSDK(w *TriggerState) (*sdk.TriggerState, error) { + if w == nil { + return nil, nil + } + out := &sdk.TriggerState{} + { + var members []string + if w.Table != nil { + members = append(members, "table") + } + if w.FileArrival != nil { + members = append(members, "file_arrival") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Table != nil: + conv625, err := TableTriggerStateToSDK(w.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerState.TriggerType", err) + } + out.TriggerType = &sdk.TriggerState_TriggerType_Table{Table: *conv625} + case w.FileArrival != nil: + conv626, err := FileArrivalTriggerStateToSDK(w.FileArrival) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerState.TriggerType", err) + } + out.TriggerType = &sdk.TriggerState_TriggerType_FileArrival{FileArrival: *conv626} + } + conv627, err := SqlConditionStateToSDK(w.SqlCondition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerState.SqlCondition", err) + } + out.SqlCondition = conv627 + out.PauseStatus = w.PauseStatus + return out, nil +} + +// TriggerStateFromSDK converts the sdk-go type to the mirror. +func TriggerStateFromSDK(v *sdk.TriggerState) (*TriggerState, error) { + if v == nil { + return nil, nil + } + out := &TriggerState{} + switch value := v.TriggerType.(type) { + case *sdk.TriggerState_TriggerType_Table: + if value != nil { + conv628, err := TableTriggerStateFromSDK(&value.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerState.TriggerType", err) + } + out.Table = conv628 + } + case *sdk.TriggerState_TriggerType_FileArrival: + if value != nil { + conv629, err := FileArrivalTriggerStateFromSDK(&value.FileArrival) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerState.TriggerType", err) + } + out.FileArrival = conv629 + } + } + conv630, err := SqlConditionStateFromSDK(v.SqlCondition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggerState.SqlCondition", err) + } + out.SqlCondition = conv630 + out.PauseStatus = v.PauseStatus + return out, nil +} + +// UpdateJobRequestToSDK converts the mirror to the sdk-go type. +func UpdateJobRequestToSDK(w *UpdateJobRequest) (*sdk.UpdateJobRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateJobRequest{} + out.JobId = w.JobId + conv631, err := JobSettingsToSDK(w.NewSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateJobRequest.NewSettings", err) + } + out.NewSettings = conv631 + out.FieldsToRemove = w.FieldsToRemove + return out, nil +} + +// UpdateJobRequestFromSDK converts the sdk-go type to the mirror. +func UpdateJobRequestFromSDK(v *sdk.UpdateJobRequest) (*UpdateJobRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateJobRequest{} + out.JobId = v.JobId + conv632, err := JobSettingsFromSDK(v.NewSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateJobRequest.NewSettings", err) + } + out.NewSettings = conv632 + out.FieldsToRemove = v.FieldsToRemove + return out, nil +} + +// ViewItemToSDK converts the mirror to the sdk-go type. +func ViewItemToSDK(w *ViewItem) (*sdk.ViewItem, error) { + if w == nil { + return nil, nil + } + out := &sdk.ViewItem{} + out.Content = w.Content + out.Name = w.Name + out.Type = w.Type + return out, nil +} + +// ViewItemFromSDK converts the sdk-go type to the mirror. +func ViewItemFromSDK(v *sdk.ViewItem) (*ViewItem, error) { + if v == nil { + return nil, nil + } + out := &ViewItem{} + out.Content = v.Content + out.Name = v.Name + out.Type = v.Type + return out, nil +} + +// VolumesStorageInfoToSDK converts the mirror to the sdk-go type. +func VolumesStorageInfoToSDK(w *VolumesStorageInfo) (*sdk.VolumesStorageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.VolumesStorageInfo{} + out.Destination = w.Destination + return out, nil +} + +// VolumesStorageInfoFromSDK converts the sdk-go type to the mirror. +func VolumesStorageInfoFromSDK(v *sdk.VolumesStorageInfo) (*VolumesStorageInfo, error) { + if v == nil { + return nil, nil + } + out := &VolumesStorageInfo{} + out.Destination = v.Destination + return out, nil +} + +// WebhookToSDK converts the mirror to the sdk-go type. +func WebhookToSDK(w *Webhook) (*sdk.Webhook, error) { + if w == nil { + return nil, nil + } + out := &sdk.Webhook{} + out.Id = w.Id + return out, nil +} + +// WebhookFromSDK converts the sdk-go type to the mirror. +func WebhookFromSDK(v *sdk.Webhook) (*Webhook, error) { + if v == nil { + return nil, nil + } + out := &Webhook{} + out.Id = v.Id + return out, nil +} + +// WebhookNotificationsToSDK converts the mirror to the sdk-go type. +func WebhookNotificationsToSDK(w *WebhookNotifications) (*sdk.WebhookNotifications, error) { + if w == nil { + return nil, nil + } + out := &sdk.WebhookNotifications{} + conv633, err := convertSlice(w.OnStart, WebhookToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnStart", err) + } + out.OnStart = conv633 + conv634, err := convertSlice(w.OnSuccess, WebhookToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnSuccess", err) + } + out.OnSuccess = conv634 + conv635, err := convertSlice(w.OnFailure, WebhookToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnFailure", err) + } + out.OnFailure = conv635 + conv636, err := convertSlice(w.OnDurationWarningThresholdExceeded, WebhookToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnDurationWarningThresholdExceeded", err) + } + out.OnDurationWarningThresholdExceeded = conv636 + conv637, err := convertSlice(w.OnStreamingBacklogExceeded, WebhookToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnStreamingBacklogExceeded", err) + } + out.OnStreamingBacklogExceeded = conv637 + conv638, err := convertSlice(w.OnMaintenanceStart, WebhookToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnMaintenanceStart", err) + } + out.OnMaintenanceStart = conv638 + conv639, err := convertSlice(w.OnMaintenanceComplete, WebhookToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnMaintenanceComplete", err) + } + out.OnMaintenanceComplete = conv639 + return out, nil +} + +// WebhookNotificationsFromSDK converts the sdk-go type to the mirror. +func WebhookNotificationsFromSDK(v *sdk.WebhookNotifications) (*WebhookNotifications, error) { + if v == nil { + return nil, nil + } + out := &WebhookNotifications{} + conv640, err := convertSlice(v.OnStart, WebhookFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnStart", err) + } + out.OnStart = conv640 + conv641, err := convertSlice(v.OnSuccess, WebhookFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnSuccess", err) + } + out.OnSuccess = conv641 + conv642, err := convertSlice(v.OnFailure, WebhookFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnFailure", err) + } + out.OnFailure = conv642 + conv643, err := convertSlice(v.OnDurationWarningThresholdExceeded, WebhookFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnDurationWarningThresholdExceeded", err) + } + out.OnDurationWarningThresholdExceeded = conv643 + conv644, err := convertSlice(v.OnStreamingBacklogExceeded, WebhookFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnStreamingBacklogExceeded", err) + } + out.OnStreamingBacklogExceeded = conv644 + conv645, err := convertSlice(v.OnMaintenanceStart, WebhookFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnMaintenanceStart", err) + } + out.OnMaintenanceStart = conv645 + conv646, err := convertSlice(v.OnMaintenanceComplete, WebhookFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WebhookNotifications.OnMaintenanceComplete", err) + } + out.OnMaintenanceComplete = conv646 + return out, nil +} + +// WidgetErrorDetailToSDK converts the mirror to the sdk-go type. +func WidgetErrorDetailToSDK(w *WidgetErrorDetail) (*sdk.WidgetErrorDetail, error) { + if w == nil { + return nil, nil + } + out := &sdk.WidgetErrorDetail{} + out.Message = w.Message + return out, nil +} + +// WidgetErrorDetailFromSDK converts the sdk-go type to the mirror. +func WidgetErrorDetailFromSDK(v *sdk.WidgetErrorDetail) (*WidgetErrorDetail, error) { + if v == nil { + return nil, nil + } + out := &WidgetErrorDetail{} + out.Message = v.Message + return out, nil +} + +// WorkloadTypeToSDK converts the mirror to the sdk-go type. +func WorkloadTypeToSDK(w *WorkloadType) (*sdk.WorkloadType, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkloadType{} + conv647, err := WorkloadType_ClientsTypesToSDK(w.Clients) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WorkloadType.Clients", err) + } + out.Clients = conv647 + return out, nil +} + +// WorkloadTypeFromSDK converts the sdk-go type to the mirror. +func WorkloadTypeFromSDK(v *sdk.WorkloadType) (*WorkloadType, error) { + if v == nil { + return nil, nil + } + out := &WorkloadType{} + conv648, err := WorkloadType_ClientsTypesFromSDK(v.Clients) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WorkloadType.Clients", err) + } + out.Clients = conv648 + return out, nil +} + +// WorkloadType_ClientsTypesToSDK converts the mirror to the sdk-go type. +func WorkloadType_ClientsTypesToSDK(w *WorkloadType_ClientsTypes) (*sdk.WorkloadType_ClientsTypes, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkloadType_ClientsTypes{} + out.Notebooks = w.Notebooks + out.Jobs = w.Jobs + return out, nil +} + +// WorkloadType_ClientsTypesFromSDK converts the sdk-go type to the mirror. +func WorkloadType_ClientsTypesFromSDK(v *sdk.WorkloadType_ClientsTypes) (*WorkloadType_ClientsTypes, error) { + if v == nil { + return nil, nil + } + out := &WorkloadType_ClientsTypes{} + out.Notebooks = v.Notebooks + out.Jobs = v.Jobs + return out, nil +} + +// WorkspaceStorageInfoToSDK converts the mirror to the sdk-go type. +func WorkspaceStorageInfoToSDK(w *WorkspaceStorageInfo) (*sdk.WorkspaceStorageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkspaceStorageInfo{} + out.Destination = w.Destination + return out, nil +} + +// WorkspaceStorageInfoFromSDK converts the sdk-go type to the mirror. +func WorkspaceStorageInfoFromSDK(v *sdk.WorkspaceStorageInfo) (*WorkspaceStorageInfo, error) { + if v == nil { + return nil, nil + } + out := &WorkspaceStorageInfo{} + out.Destination = v.Destination + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/keyconfigurations/v1/types.generated.go b/libs/sdktypes/keyconfigurations/v1/types.generated.go new file mode 100644 index 00000000000..615a8723140 --- /dev/null +++ b/libs/sdktypes/keyconfigurations/v1/types.generated.go @@ -0,0 +1,542 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/keyconfigurations/v1. DO NOT EDIT. + +package keyconfigurations + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/keyconfigurations/v1" + + strings "strings" +) + +type ( + CmkUseCase = sdk.CmkUseCase +) + +const ( + CmkUseCase_Unspecified = sdk.CmkUseCase_Unspecified + CmkUseCase_Storage = sdk.CmkUseCase_Storage +) + +type AwsKeyInfoOutput struct { + // The AWS KMS key alias. + KeyAlias *string `json:"key_alias,omitempty"` + // The AWS KMS key's Amazon Resource Name (ARN). + KeyArn *string `json:"key_arn,omitempty"` + // The AWS KMS key region. + KeyRegion *string `json:"key_region,omitempty"` + // This field applies only if the `use_cases` property includes `STORAGE`. If + // this is set to true or omitted, the key is also used to encrypt cluster EBS + // volumes. If you do not want to use this key for encrypting EBS volumes, set + // to false. + ReuseKeyForClusterVolumes *bool `json:"reuse_key_for_cluster_volumes,omitempty"` +} + +type AzureKeyInfo struct { + // The Disk Encryption Set id that is used to represent the key info used for + // Managed Disk BYOK use case + DiskEncryptionSetId *string `json:"disk_encryption_set_id,omitempty"` + // The structure to store key access credential This is set if the Managed + // Identity is being used to access the Azure Key Vault key. + KeyAccessConfiguration *KeyAccessConfiguration `json:"key_access_configuration,omitempty"` + // The name of the key in KeyVault. + KeyName *string `json:"key_name,omitempty"` + // The base URI of the KeyVault. + KeyVaultUri *string `json:"key_vault_uri,omitempty"` + // The tenant id where the KeyVault lives. + TenantId *string `json:"tenant_id,omitempty"` + // The current key version. + Version *string `json:"version,omitempty"` +} + +type CreateAwsKeyInfo struct { + // The AWS KMS key alias. + KeyAlias *string `json:"key_alias,omitempty"` + // The AWS KMS key's Amazon Resource Name (ARN). + KeyArn *string `json:"key_arn,omitempty"` + // The AWS KMS key region. + KeyRegion *string `json:"key_region,omitempty"` + // This field applies only if the `use_cases` property includes `STORAGE`. If + // this is set to true or omitted, the key is also used to encrypt cluster EBS + // volumes. If you do not want to use this key for encrypting EBS volumes, set + // to false. + ReuseKeyForClusterVolumes *bool `json:"reuse_key_for_cluster_volumes,omitempty"` +} + +type CreateAzureKeyInfo struct { + // The Disk Encryption Set id that is used to represent the key info used for + // Managed Disk BYOK use case + DiskEncryptionSetId *string `json:"disk_encryption_set_id,omitempty"` + // The structure to store key access credential This is set if the Managed + // Identity is being used to access the Azure Key Vault key. + KeyAccessConfiguration *KeyAccessConfiguration `json:"key_access_configuration,omitempty"` + // The name of the key in KeyVault. + KeyName *string `json:"key_name,omitempty"` + // The base URI of the KeyVault. + KeyVaultUri *string `json:"key_vault_uri,omitempty"` + // The tenant id where the KeyVault lives. + TenantId *string `json:"tenant_id,omitempty"` + // The current key version. + Version *string `json:"version,omitempty"` +} + +type CreateCustomerManagedKeyRequest struct { + AccountId *string `json:"account_id,omitempty"` + AwsKeyInfo *CreateAwsKeyInfo `json:"aws_key_info,omitempty"` + AzureKeyInfo *CreateAzureKeyInfo `json:"azure_key_info,omitempty"` + GcpKeyInfo *CreateGcpKeyInfo `json:"gcp_key_info,omitempty"` + // The cases that the key can be used for. + UseCases []CmkUseCase `json:"use_cases,omitempty"` +} + +type CreateGcpKeyInfo struct { + // Globally unique service account email that has access to the KMS key. The + // service account exists within the Databricks CP project. + GcpServiceAccount *GcpServiceAccount `json:"gcp_service_account,omitempty"` + // Globally unique kms key resource id of the form + // projects/testProjectId/locations/us-east4/keyRings/gcpCmkKeyRing/cryptoKeys/cmk-eastus4 + KmsKeyId *string `json:"kms_key_id,omitempty"` + // When true, will not use OAuth to grant the service account + // access to the KMS key. The customer is responsible for granting access + // manually. + Manual *bool `json:"manual,omitempty"` +} + +type CustomerManagedKey struct { + // The account ID that holds the customer-managed key. + AccountId *string `json:"account_id,omitempty"` + AwsKeyInfo *AwsKeyInfoOutput `json:"aws_key_info,omitempty"` + AzureKeyInfo *AzureKeyInfo `json:"azure_key_info,omitempty"` + // Time in epoch milliseconds when the customer key was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // ID of the encryption key configuration object. + CustomerManagedKeyId *string `json:"customer_managed_key_id,omitempty"` + GcpKeyInfo *GcpKeyInfo `json:"gcp_key_info,omitempty"` + // The cases that the key can be used for. + UseCases []CmkUseCase `json:"use_cases,omitempty"` +} + +type GcpKeyInfo struct { + // Globally unique service account email that has access to the KMS key. The + // service account exists within the Databricks CP project. + GcpServiceAccount *GcpServiceAccount `json:"gcp_service_account,omitempty"` + // Globally unique kms key resource id of the form + // projects/testProjectId/locations/us-east4/keyRings/gcpCmkKeyRing/cryptoKeys/cmk-eastus4 + KmsKeyId *string `json:"kms_key_id,omitempty"` + // When true, will not use OAuth to grant the service account + // access to the KMS key. The customer is responsible for granting access + // manually. + Manual *bool `json:"manual,omitempty"` +} + +type GcpServiceAccount struct { + ServiceAccountEmail *string `json:"service_account_email,omitempty"` +} + +// The credential ID that is used to access the key vault.. +type KeyAccessConfiguration struct { + CredentialId *string `json:"credential_id,omitempty"` +} + +// AwsKeyInfoOutputToSDK converts the mirror to the sdk-go type. +func AwsKeyInfoOutputToSDK(w *AwsKeyInfoOutput) (*sdk.AwsKeyInfoOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.AwsKeyInfoOutput{} + out.KeyArn = w.KeyArn + out.KeyAlias = w.KeyAlias + out.KeyRegion = w.KeyRegion + out.ReuseKeyForClusterVolumes = w.ReuseKeyForClusterVolumes + return out, nil +} + +// AwsKeyInfoOutputFromSDK converts the sdk-go type to the mirror. +func AwsKeyInfoOutputFromSDK(v *sdk.AwsKeyInfoOutput) (*AwsKeyInfoOutput, error) { + if v == nil { + return nil, nil + } + out := &AwsKeyInfoOutput{} + out.KeyArn = v.KeyArn + out.KeyAlias = v.KeyAlias + out.KeyRegion = v.KeyRegion + out.ReuseKeyForClusterVolumes = v.ReuseKeyForClusterVolumes + return out, nil +} + +// AzureKeyInfoToSDK converts the mirror to the sdk-go type. +func AzureKeyInfoToSDK(w *AzureKeyInfo) (*sdk.AzureKeyInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.AzureKeyInfo{} + out.KeyVaultUri = w.KeyVaultUri + out.KeyName = w.KeyName + out.Version = w.Version + out.TenantId = w.TenantId + out.DiskEncryptionSetId = w.DiskEncryptionSetId + conv1, err := KeyAccessConfigurationToSDK(w.KeyAccessConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AzureKeyInfo.KeyAccessConfiguration", err) + } + out.KeyAccessConfiguration = conv1 + return out, nil +} + +// AzureKeyInfoFromSDK converts the sdk-go type to the mirror. +func AzureKeyInfoFromSDK(v *sdk.AzureKeyInfo) (*AzureKeyInfo, error) { + if v == nil { + return nil, nil + } + out := &AzureKeyInfo{} + out.KeyVaultUri = v.KeyVaultUri + out.KeyName = v.KeyName + out.Version = v.Version + out.TenantId = v.TenantId + out.DiskEncryptionSetId = v.DiskEncryptionSetId + conv2, err := KeyAccessConfigurationFromSDK(v.KeyAccessConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AzureKeyInfo.KeyAccessConfiguration", err) + } + out.KeyAccessConfiguration = conv2 + return out, nil +} + +// CreateAwsKeyInfoToSDK converts the mirror to the sdk-go type. +func CreateAwsKeyInfoToSDK(w *CreateAwsKeyInfo) (*sdk.CreateAwsKeyInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAwsKeyInfo{} + out.KeyArn = w.KeyArn + out.KeyAlias = w.KeyAlias + out.KeyRegion = w.KeyRegion + out.ReuseKeyForClusterVolumes = w.ReuseKeyForClusterVolumes + return out, nil +} + +// CreateAwsKeyInfoFromSDK converts the sdk-go type to the mirror. +func CreateAwsKeyInfoFromSDK(v *sdk.CreateAwsKeyInfo) (*CreateAwsKeyInfo, error) { + if v == nil { + return nil, nil + } + out := &CreateAwsKeyInfo{} + out.KeyArn = v.KeyArn + out.KeyAlias = v.KeyAlias + out.KeyRegion = v.KeyRegion + out.ReuseKeyForClusterVolumes = v.ReuseKeyForClusterVolumes + return out, nil +} + +// CreateAzureKeyInfoToSDK converts the mirror to the sdk-go type. +func CreateAzureKeyInfoToSDK(w *CreateAzureKeyInfo) (*sdk.CreateAzureKeyInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAzureKeyInfo{} + out.KeyVaultUri = w.KeyVaultUri + out.KeyName = w.KeyName + out.Version = w.Version + out.TenantId = w.TenantId + out.DiskEncryptionSetId = w.DiskEncryptionSetId + conv3, err := KeyAccessConfigurationToSDK(w.KeyAccessConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAzureKeyInfo.KeyAccessConfiguration", err) + } + out.KeyAccessConfiguration = conv3 + return out, nil +} + +// CreateAzureKeyInfoFromSDK converts the sdk-go type to the mirror. +func CreateAzureKeyInfoFromSDK(v *sdk.CreateAzureKeyInfo) (*CreateAzureKeyInfo, error) { + if v == nil { + return nil, nil + } + out := &CreateAzureKeyInfo{} + out.KeyVaultUri = v.KeyVaultUri + out.KeyName = v.KeyName + out.Version = v.Version + out.TenantId = v.TenantId + out.DiskEncryptionSetId = v.DiskEncryptionSetId + conv4, err := KeyAccessConfigurationFromSDK(v.KeyAccessConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAzureKeyInfo.KeyAccessConfiguration", err) + } + out.KeyAccessConfiguration = conv4 + return out, nil +} + +// CreateCustomerManagedKeyRequestToSDK converts the mirror to the sdk-go type. +func CreateCustomerManagedKeyRequestToSDK(w *CreateCustomerManagedKeyRequest) (*sdk.CreateCustomerManagedKeyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCustomerManagedKeyRequest{} + out.AccountId = w.AccountId + { + var members []string + if w.AwsKeyInfo != nil { + members = append(members, "aws_key_info") + } + if w.GcpKeyInfo != nil { + members = append(members, "gcp_key_info") + } + if w.AzureKeyInfo != nil { + members = append(members, "azure_key_info") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsKeyInfo != nil: + conv5, err := CreateAwsKeyInfoToSDK(w.AwsKeyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCustomerManagedKeyRequest.KeyInfo", err) + } + out.KeyInfo = &sdk.CreateCustomerManagedKeyRequest_KeyInfo_AwsKeyInfo{AwsKeyInfo: *conv5} + case w.GcpKeyInfo != nil: + conv6, err := CreateGcpKeyInfoToSDK(w.GcpKeyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCustomerManagedKeyRequest.KeyInfo", err) + } + out.KeyInfo = &sdk.CreateCustomerManagedKeyRequest_KeyInfo_GcpKeyInfo{GcpKeyInfo: *conv6} + case w.AzureKeyInfo != nil: + conv7, err := CreateAzureKeyInfoToSDK(w.AzureKeyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCustomerManagedKeyRequest.KeyInfo", err) + } + out.KeyInfo = &sdk.CreateCustomerManagedKeyRequest_KeyInfo_AzureKeyInfo{AzureKeyInfo: *conv7} + } + out.UseCases = w.UseCases + return out, nil +} + +// CreateCustomerManagedKeyRequestFromSDK converts the sdk-go type to the mirror. +func CreateCustomerManagedKeyRequestFromSDK(v *sdk.CreateCustomerManagedKeyRequest) (*CreateCustomerManagedKeyRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCustomerManagedKeyRequest{} + out.AccountId = v.AccountId + switch value := v.KeyInfo.(type) { + case *sdk.CreateCustomerManagedKeyRequest_KeyInfo_AwsKeyInfo: + if value != nil { + conv8, err := CreateAwsKeyInfoFromSDK(&value.AwsKeyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCustomerManagedKeyRequest.KeyInfo", err) + } + out.AwsKeyInfo = conv8 + } + case *sdk.CreateCustomerManagedKeyRequest_KeyInfo_GcpKeyInfo: + if value != nil { + conv9, err := CreateGcpKeyInfoFromSDK(&value.GcpKeyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCustomerManagedKeyRequest.KeyInfo", err) + } + out.GcpKeyInfo = conv9 + } + case *sdk.CreateCustomerManagedKeyRequest_KeyInfo_AzureKeyInfo: + if value != nil { + conv10, err := CreateAzureKeyInfoFromSDK(&value.AzureKeyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCustomerManagedKeyRequest.KeyInfo", err) + } + out.AzureKeyInfo = conv10 + } + } + out.UseCases = v.UseCases + return out, nil +} + +// CreateGcpKeyInfoToSDK converts the mirror to the sdk-go type. +func CreateGcpKeyInfoToSDK(w *CreateGcpKeyInfo) (*sdk.CreateGcpKeyInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateGcpKeyInfo{} + out.KmsKeyId = w.KmsKeyId + conv11, err := GcpServiceAccountToSDK(w.GcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGcpKeyInfo.GcpServiceAccount", err) + } + out.GcpServiceAccount = conv11 + out.Manual = w.Manual + return out, nil +} + +// CreateGcpKeyInfoFromSDK converts the sdk-go type to the mirror. +func CreateGcpKeyInfoFromSDK(v *sdk.CreateGcpKeyInfo) (*CreateGcpKeyInfo, error) { + if v == nil { + return nil, nil + } + out := &CreateGcpKeyInfo{} + out.KmsKeyId = v.KmsKeyId + conv12, err := GcpServiceAccountFromSDK(v.GcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGcpKeyInfo.GcpServiceAccount", err) + } + out.GcpServiceAccount = conv12 + out.Manual = v.Manual + return out, nil +} + +// CustomerManagedKeyToSDK converts the mirror to the sdk-go type. +func CustomerManagedKeyToSDK(w *CustomerManagedKey) (*sdk.CustomerManagedKey, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomerManagedKey{} + out.CustomerManagedKeyId = w.CustomerManagedKeyId + out.CreationTime = w.CreationTime + out.AccountId = w.AccountId + { + var members []string + if w.AwsKeyInfo != nil { + members = append(members, "aws_key_info") + } + if w.AzureKeyInfo != nil { + members = append(members, "azure_key_info") + } + if w.GcpKeyInfo != nil { + members = append(members, "gcp_key_info") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsKeyInfo != nil: + conv13, err := AwsKeyInfoOutputToSDK(w.AwsKeyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerManagedKey.KeyInfo", err) + } + out.KeyInfo = &sdk.CustomerManagedKey_KeyInfo_AwsKeyInfo{AwsKeyInfo: *conv13} + case w.AzureKeyInfo != nil: + conv14, err := AzureKeyInfoToSDK(w.AzureKeyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerManagedKey.KeyInfo", err) + } + out.KeyInfo = &sdk.CustomerManagedKey_KeyInfo_AzureKeyInfo{AzureKeyInfo: *conv14} + case w.GcpKeyInfo != nil: + conv15, err := GcpKeyInfoToSDK(w.GcpKeyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerManagedKey.KeyInfo", err) + } + out.KeyInfo = &sdk.CustomerManagedKey_KeyInfo_GcpKeyInfo{GcpKeyInfo: *conv15} + } + out.UseCases = w.UseCases + return out, nil +} + +// CustomerManagedKeyFromSDK converts the sdk-go type to the mirror. +func CustomerManagedKeyFromSDK(v *sdk.CustomerManagedKey) (*CustomerManagedKey, error) { + if v == nil { + return nil, nil + } + out := &CustomerManagedKey{} + out.CustomerManagedKeyId = v.CustomerManagedKeyId + out.CreationTime = v.CreationTime + out.AccountId = v.AccountId + switch value := v.KeyInfo.(type) { + case *sdk.CustomerManagedKey_KeyInfo_AwsKeyInfo: + if value != nil { + conv16, err := AwsKeyInfoOutputFromSDK(&value.AwsKeyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerManagedKey.KeyInfo", err) + } + out.AwsKeyInfo = conv16 + } + case *sdk.CustomerManagedKey_KeyInfo_AzureKeyInfo: + if value != nil { + conv17, err := AzureKeyInfoFromSDK(&value.AzureKeyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerManagedKey.KeyInfo", err) + } + out.AzureKeyInfo = conv17 + } + case *sdk.CustomerManagedKey_KeyInfo_GcpKeyInfo: + if value != nil { + conv18, err := GcpKeyInfoFromSDK(&value.GcpKeyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerManagedKey.KeyInfo", err) + } + out.GcpKeyInfo = conv18 + } + } + out.UseCases = v.UseCases + return out, nil +} + +// GcpKeyInfoToSDK converts the mirror to the sdk-go type. +func GcpKeyInfoToSDK(w *GcpKeyInfo) (*sdk.GcpKeyInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpKeyInfo{} + out.KmsKeyId = w.KmsKeyId + conv19, err := GcpServiceAccountToSDK(w.GcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GcpKeyInfo.GcpServiceAccount", err) + } + out.GcpServiceAccount = conv19 + out.Manual = w.Manual + return out, nil +} + +// GcpKeyInfoFromSDK converts the sdk-go type to the mirror. +func GcpKeyInfoFromSDK(v *sdk.GcpKeyInfo) (*GcpKeyInfo, error) { + if v == nil { + return nil, nil + } + out := &GcpKeyInfo{} + out.KmsKeyId = v.KmsKeyId + conv20, err := GcpServiceAccountFromSDK(v.GcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GcpKeyInfo.GcpServiceAccount", err) + } + out.GcpServiceAccount = conv20 + out.Manual = v.Manual + return out, nil +} + +// GcpServiceAccountToSDK converts the mirror to the sdk-go type. +func GcpServiceAccountToSDK(w *GcpServiceAccount) (*sdk.GcpServiceAccount, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpServiceAccount{} + out.ServiceAccountEmail = w.ServiceAccountEmail + return out, nil +} + +// GcpServiceAccountFromSDK converts the sdk-go type to the mirror. +func GcpServiceAccountFromSDK(v *sdk.GcpServiceAccount) (*GcpServiceAccount, error) { + if v == nil { + return nil, nil + } + out := &GcpServiceAccount{} + out.ServiceAccountEmail = v.ServiceAccountEmail + return out, nil +} + +// KeyAccessConfigurationToSDK converts the mirror to the sdk-go type. +func KeyAccessConfigurationToSDK(w *KeyAccessConfiguration) (*sdk.KeyAccessConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.KeyAccessConfiguration{} + out.CredentialId = w.CredentialId + return out, nil +} + +// KeyAccessConfigurationFromSDK converts the sdk-go type to the mirror. +func KeyAccessConfigurationFromSDK(v *sdk.KeyAccessConfiguration) (*KeyAccessConfiguration, error) { + if v == nil { + return nil, nil + } + out := &KeyAccessConfiguration{} + out.CredentialId = v.CredentialId + return out, nil +} diff --git a/libs/sdktypes/knowledgeassistants/v1/types.generated.go b/libs/sdktypes/knowledgeassistants/v1/types.generated.go new file mode 100644 index 00000000000..b815c701004 --- /dev/null +++ b/libs/sdktypes/knowledgeassistants/v1/types.generated.go @@ -0,0 +1,895 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/knowledgeassistants/v1. DO NOT EDIT. + +package knowledgeassistants + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/knowledgeassistants/v1" + strings "strings" +) + +type ( + KnowledgeAssistant_State = sdk.KnowledgeAssistant_State + KnowledgeSource_State = sdk.KnowledgeSource_State +) + +const ( + KnowledgeAssistant_State_Unspecified = sdk.KnowledgeAssistant_State_Unspecified + KnowledgeAssistant_State_Creating = sdk.KnowledgeAssistant_State_Creating + KnowledgeAssistant_State_Active = sdk.KnowledgeAssistant_State_Active + KnowledgeAssistant_State_Failed = sdk.KnowledgeAssistant_State_Failed + KnowledgeSource_State_Unspecified = sdk.KnowledgeSource_State_Unspecified + KnowledgeSource_State_Updating = sdk.KnowledgeSource_State_Updating + KnowledgeSource_State_Updated = sdk.KnowledgeSource_State_Updated + KnowledgeSource_State_FailedUpdate = sdk.KnowledgeSource_State_FailedUpdate +) + +// Create an example.. +type CreateExampleRequest struct { + // The example to create under the parent Knowledge Assistant. + Example *Example `json:"example,omitempty"` + // Parent resource where this example will be created. Format: + // knowledge-assistants/{knowledge_assistant_id} + Parent *string `json:"parent,omitempty"` +} + +type CreateKnowledgeAssistantRequest struct { + // The Knowledge Assistant to create. + KnowledgeAssistant *KnowledgeAssistant `json:"knowledge_assistant,omitempty"` +} + +type CreateKnowledgeSourceRequest struct { + KnowledgeSource *KnowledgeSource `json:"knowledge_source,omitempty"` + // Parent resource where this source will be created. Format: + // knowledge-assistants/{knowledge_assistant_id} + Parent *string `json:"parent,omitempty"` +} + +// An example associated with a Knowledge Assistant. Contains a question and +// guidelines for how the assistant should respond.. +type Example struct { + // Timestamp when this example was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // The universally unique identifier (UUID) of the example. + ExampleId *string `json:"example_id,omitempty"` + // Guidelines for answering the question. Optional — examples may be created + // with just a question; the front-end form does not require guidelines. + Guidelines []string `json:"guidelines,omitempty"` + // Full resource name: + // knowledge-assistants/{knowledge_assistant_id}/examples/{example_id} + Name *string `json:"name,omitempty"` + // The example question. + Question *string `json:"question,omitempty"` + // Timestamp when this example was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +// FileTableSpec specifies a file table source configuration.. +type FileTableSpec struct { + // The name of the column containing BINARY file content to be indexed. + FileCol *string `json:"file_col,omitempty"` + // Full UC name of the table, in the format of {CATALOG}.{SCHEMA}.{TABLE_NAME}. + TableName *string `json:"table_name,omitempty"` +} + +// FilesSpec specifies a files source configuration.. +type FilesSpec struct { + // A UC volume path that includes a list of files. + Path *string `json:"path,omitempty"` +} + +// IndexSpec specifies a vector search index source configuration.. +type IndexSpec struct { + // The column that specifies a link or reference to where the information came + // from. + DocUriCol *string `json:"doc_uri_col,omitempty"` + // Full UC name of the vector search index, in the format of + // {CATALOG}.{SCHEMA}.{INDEX_NAME}. + IndexName *string `json:"index_name,omitempty"` + // The column that includes the document text for retrieval. + TextCol *string `json:"text_col,omitempty"` +} + +// Entity message that represents a knowledge assistant. Note: REQUIRED +// annotations below represent create-time requirements. For updates, required +// fields are determined by the update mask.. +type KnowledgeAssistant struct { + // Creation timestamp. + CreateTime *types.Time `json:"create_time,omitempty"` + // The creator of the Knowledge Assistant. + Creator *string `json:"creator,omitempty"` + // 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. + Description *string `json:"description,omitempty"` + // 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. + DisplayName *string `json:"display_name,omitempty"` + // The name of the knowledge assistant agent endpoint. + EndpointName *string `json:"endpoint_name,omitempty"` + // Error details when the Knowledge Assistant is in FAILED state. + ErrorInfo *string `json:"error_info,omitempty"` + // The MLflow experiment ID. + ExperimentId *string `json:"experiment_id,omitempty"` + // Deprecated: use knowledge_assistant_id instead. + Id *string `json:"id,omitempty"` + // Additional global instructions on how the agent should generate answers. + // Optional on create and update. When updating a Knowledge Assistant, include + // this field in update_mask to modify it. + Instructions *string `json:"instructions,omitempty"` + // The resource name of the Knowledge Assistant. Format: + // knowledge-assistants/{knowledge_assistant_id} + Name *string `json:"name,omitempty"` + // State of the Knowledge Assistant. Not returned in List responses. + State KnowledgeAssistant_State `json:"state,omitempty"` +} + +// KnowledgeSource represents a source of knowledge for the KnowledgeAssistant. +// Used in create/update requests and returned in Get/List responses. Note: +// REQUIRED annotations below represent create-time requirements. For updates, +// required fields are determined by the update mask.. +type KnowledgeSource struct { + // Timestamp when this knowledge source was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Description of the knowledge source. Required when creating a Knowledge + // Source. When updating a Knowledge Source, optional unless included in + // update_mask. + Description *string `json:"description,omitempty"` + // 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. + DisplayName *string `json:"display_name,omitempty"` + FileTable *FileTableSpec `json:"file_table,omitempty"` + Files *FilesSpec `json:"files,omitempty"` + Id *string `json:"id,omitempty"` + Index *IndexSpec `json:"index,omitempty"` + // Timestamp representing the cutoff before which content in this knowledge + // source is being ingested. + KnowledgeCutoffTime *types.Time `json:"knowledge_cutoff_time,omitempty"` + // Full resource name: + // knowledge-assistants/{knowledge_assistant_id}/knowledge-sources/{knowledge_source_id} + Name *string `json:"name,omitempty"` + // 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. + SourceType *string `json:"source_type,omitempty"` + State KnowledgeSource_State `json:"state,omitempty"` +} + +// List examples.. +type ListExamplesRequest struct { + // The maximum number of examples to return. If unspecified, at most 100 + // examples will be returned. The maximum value is 100; values above 100 will be + // coerced to 100. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous `ListExamples` call. Provide this to + // retrieve the subsequent page. If unspecified, the first page will be + // returned. + PageToken *string `json:"page_token,omitempty"` + // Parent resource to list from. Format: + // knowledge-assistants/{knowledge_assistant_id} + Parent *string `json:"parent,omitempty"` +} + +// A list of Knowledge Assistant examples.. +type ListExamplesResponse struct { + Examples []Example `json:"examples,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// A request to list Knowledge Assistants.. +type ListKnowledgeAssistantsRequest struct { + // The maximum number of knowledge assistants to return. If unspecified, at most + // 100 knowledge assistants will be returned. The maximum value is 100; values + // above 100 will be coerced to 100. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous `ListKnowledgeAssistants` call. + // Provide this to retrieve the subsequent page. If unspecified, the first page + // will be returned. + PageToken *string `json:"page_token,omitempty"` +} + +// A list of Knowledge Assistants.. +type ListKnowledgeAssistantsResponse struct { + KnowledgeAssistants []KnowledgeAssistant `json:"knowledge_assistants,omitempty"` + // A token that can be sent as `page_token` to retrieve the next page. If this + // field is omitted, there are no subsequent pages. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListKnowledgeSourcesRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` + // Parent resource to list from. Format: + // knowledge-assistants/{knowledge_assistant_id} + Parent *string `json:"parent,omitempty"` +} + +type ListKnowledgeSourcesResponse struct { + KnowledgeSources []KnowledgeSource `json:"knowledge_sources,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type SyncKnowledgeSourcesRequest struct { + // The resource name of the Knowledge Assistant. Format: + // knowledge-assistants/{knowledge_assistant_id} + Name *string `json:"name,omitempty"` +} + +// Update an example.. +type UpdateExampleRequest struct { + Example *Example `json:"example,omitempty"` + // The resource name of the example to update. Format: + // knowledge-assistants/{knowledge_assistant_id}/examples/{example_id} + Name *string `json:"name,omitempty"` + // Comma-delimited list of fields to update on the example. Allowed values: + // `question`, `guidelines`. Examples: - `question` - `question,guidelines` + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateKnowledgeAssistantRequest struct { + // The Knowledge Assistant update payload. Only fields listed in update_mask are + // updated. REQUIRED annotations on Knowledge Assistant fields describe + // create-time requirements and do not mean all those fields are required for + // update. + KnowledgeAssistant *KnowledgeAssistant `json:"knowledge_assistant,omitempty"` + // Comma-delimited list of fields to update on the Knowledge Assistant. Allowed + // values: `display_name`, `description`, `instructions`. Examples: - + // `display_name` - `description,instructions` + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateKnowledgeSourceRequest struct { + // The Knowledge Source update payload. Only fields listed in update_mask are + // updated. REQUIRED annotations on Knowledge Source fields describe create-time + // requirements and do not mean all those fields are required for update. + KnowledgeSource *KnowledgeSource `json:"knowledge_source,omitempty"` + // The resource name of the Knowledge Source to update. Format: + // knowledge-assistants/{knowledge_assistant_id}/knowledge-sources/{knowledge_source_id} + Name *string `json:"name,omitempty"` + // Comma-delimited list of fields to update on the Knowledge Source. Allowed + // values: `display_name`, `description`. Examples: - `display_name` - + // `display_name,description` + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CreateExampleRequestToSDK converts the mirror to the sdk-go type. +func CreateExampleRequestToSDK(w *CreateExampleRequest) (*sdk.CreateExampleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateExampleRequest{} + out.Parent = w.Parent + conv1, err := ExampleToSDK(w.Example) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExampleRequest.Example", err) + } + out.Example = conv1 + return out, nil +} + +// CreateExampleRequestFromSDK converts the sdk-go type to the mirror. +func CreateExampleRequestFromSDK(v *sdk.CreateExampleRequest) (*CreateExampleRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateExampleRequest{} + out.Parent = v.Parent + conv2, err := ExampleFromSDK(v.Example) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExampleRequest.Example", err) + } + out.Example = conv2 + return out, nil +} + +// CreateKnowledgeAssistantRequestToSDK converts the mirror to the sdk-go type. +func CreateKnowledgeAssistantRequestToSDK(w *CreateKnowledgeAssistantRequest) (*sdk.CreateKnowledgeAssistantRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateKnowledgeAssistantRequest{} + conv3, err := KnowledgeAssistantToSDK(w.KnowledgeAssistant) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateKnowledgeAssistantRequest.KnowledgeAssistant", err) + } + out.KnowledgeAssistant = conv3 + return out, nil +} + +// CreateKnowledgeAssistantRequestFromSDK converts the sdk-go type to the mirror. +func CreateKnowledgeAssistantRequestFromSDK(v *sdk.CreateKnowledgeAssistantRequest) (*CreateKnowledgeAssistantRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateKnowledgeAssistantRequest{} + conv4, err := KnowledgeAssistantFromSDK(v.KnowledgeAssistant) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateKnowledgeAssistantRequest.KnowledgeAssistant", err) + } + out.KnowledgeAssistant = conv4 + return out, nil +} + +// CreateKnowledgeSourceRequestToSDK converts the mirror to the sdk-go type. +func CreateKnowledgeSourceRequestToSDK(w *CreateKnowledgeSourceRequest) (*sdk.CreateKnowledgeSourceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateKnowledgeSourceRequest{} + out.Parent = w.Parent + conv5, err := KnowledgeSourceToSDK(w.KnowledgeSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateKnowledgeSourceRequest.KnowledgeSource", err) + } + out.KnowledgeSource = conv5 + return out, nil +} + +// CreateKnowledgeSourceRequestFromSDK converts the sdk-go type to the mirror. +func CreateKnowledgeSourceRequestFromSDK(v *sdk.CreateKnowledgeSourceRequest) (*CreateKnowledgeSourceRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateKnowledgeSourceRequest{} + out.Parent = v.Parent + conv6, err := KnowledgeSourceFromSDK(v.KnowledgeSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateKnowledgeSourceRequest.KnowledgeSource", err) + } + out.KnowledgeSource = conv6 + return out, nil +} + +// ExampleToSDK converts the mirror to the sdk-go type. +func ExampleToSDK(w *Example) (*sdk.Example, error) { + if w == nil { + return nil, nil + } + out := &sdk.Example{} + out.Name = w.Name + out.Question = w.Question + out.Guidelines = w.Guidelines + out.ExampleId = w.ExampleId + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + return out, nil +} + +// ExampleFromSDK converts the sdk-go type to the mirror. +func ExampleFromSDK(v *sdk.Example) (*Example, error) { + if v == nil { + return nil, nil + } + out := &Example{} + out.Name = v.Name + out.Question = v.Question + out.Guidelines = v.Guidelines + out.ExampleId = v.ExampleId + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + return out, nil +} + +// FileTableSpecToSDK converts the mirror to the sdk-go type. +func FileTableSpecToSDK(w *FileTableSpec) (*sdk.FileTableSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.FileTableSpec{} + out.TableName = w.TableName + out.FileCol = w.FileCol + return out, nil +} + +// FileTableSpecFromSDK converts the sdk-go type to the mirror. +func FileTableSpecFromSDK(v *sdk.FileTableSpec) (*FileTableSpec, error) { + if v == nil { + return nil, nil + } + out := &FileTableSpec{} + out.TableName = v.TableName + out.FileCol = v.FileCol + return out, nil +} + +// FilesSpecToSDK converts the mirror to the sdk-go type. +func FilesSpecToSDK(w *FilesSpec) (*sdk.FilesSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.FilesSpec{} + out.Path = w.Path + return out, nil +} + +// FilesSpecFromSDK converts the sdk-go type to the mirror. +func FilesSpecFromSDK(v *sdk.FilesSpec) (*FilesSpec, error) { + if v == nil { + return nil, nil + } + out := &FilesSpec{} + out.Path = v.Path + return out, nil +} + +// IndexSpecToSDK converts the mirror to the sdk-go type. +func IndexSpecToSDK(w *IndexSpec) (*sdk.IndexSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.IndexSpec{} + out.IndexName = w.IndexName + out.TextCol = w.TextCol + out.DocUriCol = w.DocUriCol + return out, nil +} + +// IndexSpecFromSDK converts the sdk-go type to the mirror. +func IndexSpecFromSDK(v *sdk.IndexSpec) (*IndexSpec, error) { + if v == nil { + return nil, nil + } + out := &IndexSpec{} + out.IndexName = v.IndexName + out.TextCol = v.TextCol + out.DocUriCol = v.DocUriCol + return out, nil +} + +// KnowledgeAssistantToSDK converts the mirror to the sdk-go type. +func KnowledgeAssistantToSDK(w *KnowledgeAssistant) (*sdk.KnowledgeAssistant, error) { + if w == nil { + return nil, nil + } + out := &sdk.KnowledgeAssistant{} + out.Name = w.Name + out.State = w.State + out.Id = w.Id + out.DisplayName = w.DisplayName + out.Description = w.Description + out.Instructions = w.Instructions + out.Creator = w.Creator + out.CreateTime = w.CreateTime + out.EndpointName = w.EndpointName + out.ExperimentId = w.ExperimentId + out.ErrorInfo = w.ErrorInfo + return out, nil +} + +// KnowledgeAssistantFromSDK converts the sdk-go type to the mirror. +func KnowledgeAssistantFromSDK(v *sdk.KnowledgeAssistant) (*KnowledgeAssistant, error) { + if v == nil { + return nil, nil + } + out := &KnowledgeAssistant{} + out.Name = v.Name + out.State = v.State + out.Id = v.Id + out.DisplayName = v.DisplayName + out.Description = v.Description + out.Instructions = v.Instructions + out.Creator = v.Creator + out.CreateTime = v.CreateTime + out.EndpointName = v.EndpointName + out.ExperimentId = v.ExperimentId + out.ErrorInfo = v.ErrorInfo + return out, nil +} + +// KnowledgeSourceToSDK converts the mirror to the sdk-go type. +func KnowledgeSourceToSDK(w *KnowledgeSource) (*sdk.KnowledgeSource, error) { + if w == nil { + return nil, nil + } + out := &sdk.KnowledgeSource{} + out.Name = w.Name + out.DisplayName = w.DisplayName + out.Description = w.Description + out.SourceType = w.SourceType + { + var members []string + if w.Index != nil { + members = append(members, "index") + } + if w.Files != nil { + members = append(members, "files") + } + if w.FileTable != nil { + members = append(members, "file_table") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Index != nil: + conv7, err := IndexSpecToSDK(w.Index) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KnowledgeSource.Spec", err) + } + out.Spec = &sdk.KnowledgeSource_Spec_Index{Index: *conv7} + case w.Files != nil: + conv8, err := FilesSpecToSDK(w.Files) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KnowledgeSource.Spec", err) + } + out.Spec = &sdk.KnowledgeSource_Spec_Files{Files: *conv8} + case w.FileTable != nil: + conv9, err := FileTableSpecToSDK(w.FileTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KnowledgeSource.Spec", err) + } + out.Spec = &sdk.KnowledgeSource_Spec_FileTable{FileTable: *conv9} + } + out.State = w.State + out.Id = w.Id + out.KnowledgeCutoffTime = w.KnowledgeCutoffTime + out.CreateTime = w.CreateTime + return out, nil +} + +// KnowledgeSourceFromSDK converts the sdk-go type to the mirror. +func KnowledgeSourceFromSDK(v *sdk.KnowledgeSource) (*KnowledgeSource, error) { + if v == nil { + return nil, nil + } + out := &KnowledgeSource{} + out.Name = v.Name + out.DisplayName = v.DisplayName + out.Description = v.Description + out.SourceType = v.SourceType + switch value := v.Spec.(type) { + case *sdk.KnowledgeSource_Spec_Index: + if value != nil { + conv10, err := IndexSpecFromSDK(&value.Index) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KnowledgeSource.Spec", err) + } + out.Index = conv10 + } + case *sdk.KnowledgeSource_Spec_Files: + if value != nil { + conv11, err := FilesSpecFromSDK(&value.Files) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KnowledgeSource.Spec", err) + } + out.Files = conv11 + } + case *sdk.KnowledgeSource_Spec_FileTable: + if value != nil { + conv12, err := FileTableSpecFromSDK(&value.FileTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KnowledgeSource.Spec", err) + } + out.FileTable = conv12 + } + } + out.State = v.State + out.Id = v.Id + out.KnowledgeCutoffTime = v.KnowledgeCutoffTime + out.CreateTime = v.CreateTime + return out, nil +} + +// ListExamplesRequestToSDK converts the mirror to the sdk-go type. +func ListExamplesRequestToSDK(w *ListExamplesRequest) (*sdk.ListExamplesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExamplesRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListExamplesRequestFromSDK converts the sdk-go type to the mirror. +func ListExamplesRequestFromSDK(v *sdk.ListExamplesRequest) (*ListExamplesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListExamplesRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListExamplesResponseToSDK converts the mirror to the sdk-go type. +func ListExamplesResponseToSDK(w *ListExamplesResponse) (*sdk.ListExamplesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExamplesResponse{} + conv13, err := convertSlice(w.Examples, ExampleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExamplesResponse.Examples", err) + } + out.Examples = conv13 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListExamplesResponseFromSDK converts the sdk-go type to the mirror. +func ListExamplesResponseFromSDK(v *sdk.ListExamplesResponse) (*ListExamplesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListExamplesResponse{} + conv14, err := convertSlice(v.Examples, ExampleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExamplesResponse.Examples", err) + } + out.Examples = conv14 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListKnowledgeAssistantsRequestToSDK converts the mirror to the sdk-go type. +func ListKnowledgeAssistantsRequestToSDK(w *ListKnowledgeAssistantsRequest) (*sdk.ListKnowledgeAssistantsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListKnowledgeAssistantsRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListKnowledgeAssistantsRequestFromSDK converts the sdk-go type to the mirror. +func ListKnowledgeAssistantsRequestFromSDK(v *sdk.ListKnowledgeAssistantsRequest) (*ListKnowledgeAssistantsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListKnowledgeAssistantsRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListKnowledgeAssistantsResponseToSDK converts the mirror to the sdk-go type. +func ListKnowledgeAssistantsResponseToSDK(w *ListKnowledgeAssistantsResponse) (*sdk.ListKnowledgeAssistantsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListKnowledgeAssistantsResponse{} + conv15, err := convertSlice(w.KnowledgeAssistants, KnowledgeAssistantToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListKnowledgeAssistantsResponse.KnowledgeAssistants", err) + } + out.KnowledgeAssistants = conv15 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListKnowledgeAssistantsResponseFromSDK converts the sdk-go type to the mirror. +func ListKnowledgeAssistantsResponseFromSDK(v *sdk.ListKnowledgeAssistantsResponse) (*ListKnowledgeAssistantsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListKnowledgeAssistantsResponse{} + conv16, err := convertSlice(v.KnowledgeAssistants, KnowledgeAssistantFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListKnowledgeAssistantsResponse.KnowledgeAssistants", err) + } + out.KnowledgeAssistants = conv16 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListKnowledgeSourcesRequestToSDK converts the mirror to the sdk-go type. +func ListKnowledgeSourcesRequestToSDK(w *ListKnowledgeSourcesRequest) (*sdk.ListKnowledgeSourcesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListKnowledgeSourcesRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListKnowledgeSourcesRequestFromSDK converts the sdk-go type to the mirror. +func ListKnowledgeSourcesRequestFromSDK(v *sdk.ListKnowledgeSourcesRequest) (*ListKnowledgeSourcesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListKnowledgeSourcesRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListKnowledgeSourcesResponseToSDK converts the mirror to the sdk-go type. +func ListKnowledgeSourcesResponseToSDK(w *ListKnowledgeSourcesResponse) (*sdk.ListKnowledgeSourcesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListKnowledgeSourcesResponse{} + conv17, err := convertSlice(w.KnowledgeSources, KnowledgeSourceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListKnowledgeSourcesResponse.KnowledgeSources", err) + } + out.KnowledgeSources = conv17 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListKnowledgeSourcesResponseFromSDK converts the sdk-go type to the mirror. +func ListKnowledgeSourcesResponseFromSDK(v *sdk.ListKnowledgeSourcesResponse) (*ListKnowledgeSourcesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListKnowledgeSourcesResponse{} + conv18, err := convertSlice(v.KnowledgeSources, KnowledgeSourceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListKnowledgeSourcesResponse.KnowledgeSources", err) + } + out.KnowledgeSources = conv18 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SyncKnowledgeSourcesRequestToSDK converts the mirror to the sdk-go type. +func SyncKnowledgeSourcesRequestToSDK(w *SyncKnowledgeSourcesRequest) (*sdk.SyncKnowledgeSourcesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncKnowledgeSourcesRequest{} + out.Name = w.Name + return out, nil +} + +// SyncKnowledgeSourcesRequestFromSDK converts the sdk-go type to the mirror. +func SyncKnowledgeSourcesRequestFromSDK(v *sdk.SyncKnowledgeSourcesRequest) (*SyncKnowledgeSourcesRequest, error) { + if v == nil { + return nil, nil + } + out := &SyncKnowledgeSourcesRequest{} + out.Name = v.Name + return out, nil +} + +// UpdateExampleRequestToSDK converts the mirror to the sdk-go type. +func UpdateExampleRequestToSDK(w *UpdateExampleRequest) (*sdk.UpdateExampleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateExampleRequest{} + out.Name = w.Name + conv19, err := ExampleToSDK(w.Example) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExampleRequest.Example", err) + } + out.Example = conv19 + mask20, err := fieldMaskFromString[sdk.Example](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExampleRequest.UpdateMask", err) + } + out.UpdateMask = mask20 + return out, nil +} + +// UpdateExampleRequestFromSDK converts the sdk-go type to the mirror. +func UpdateExampleRequestFromSDK(v *sdk.UpdateExampleRequest) (*UpdateExampleRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateExampleRequest{} + out.Name = v.Name + conv21, err := ExampleFromSDK(v.Example) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExampleRequest.Example", err) + } + out.Example = conv21 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateKnowledgeAssistantRequestToSDK converts the mirror to the sdk-go type. +func UpdateKnowledgeAssistantRequestToSDK(w *UpdateKnowledgeAssistantRequest) (*sdk.UpdateKnowledgeAssistantRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateKnowledgeAssistantRequest{} + conv22, err := KnowledgeAssistantToSDK(w.KnowledgeAssistant) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateKnowledgeAssistantRequest.KnowledgeAssistant", err) + } + out.KnowledgeAssistant = conv22 + mask23, err := fieldMaskFromString[sdk.KnowledgeAssistant](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateKnowledgeAssistantRequest.UpdateMask", err) + } + out.UpdateMask = mask23 + return out, nil +} + +// UpdateKnowledgeAssistantRequestFromSDK converts the sdk-go type to the mirror. +func UpdateKnowledgeAssistantRequestFromSDK(v *sdk.UpdateKnowledgeAssistantRequest) (*UpdateKnowledgeAssistantRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateKnowledgeAssistantRequest{} + conv24, err := KnowledgeAssistantFromSDK(v.KnowledgeAssistant) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateKnowledgeAssistantRequest.KnowledgeAssistant", err) + } + out.KnowledgeAssistant = conv24 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateKnowledgeSourceRequestToSDK converts the mirror to the sdk-go type. +func UpdateKnowledgeSourceRequestToSDK(w *UpdateKnowledgeSourceRequest) (*sdk.UpdateKnowledgeSourceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateKnowledgeSourceRequest{} + out.Name = w.Name + conv25, err := KnowledgeSourceToSDK(w.KnowledgeSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateKnowledgeSourceRequest.KnowledgeSource", err) + } + out.KnowledgeSource = conv25 + mask26, err := fieldMaskFromString[sdk.KnowledgeSource](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateKnowledgeSourceRequest.UpdateMask", err) + } + out.UpdateMask = mask26 + return out, nil +} + +// UpdateKnowledgeSourceRequestFromSDK converts the sdk-go type to the mirror. +func UpdateKnowledgeSourceRequestFromSDK(v *sdk.UpdateKnowledgeSourceRequest) (*UpdateKnowledgeSourceRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateKnowledgeSourceRequest{} + out.Name = v.Name + conv27, err := KnowledgeSourceFromSDK(v.KnowledgeSource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateKnowledgeSourceRequest.KnowledgeSource", err) + } + out.KnowledgeSource = conv27 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/lakeview/v1/types.generated.go b/libs/sdktypes/lakeview/v1/types.generated.go new file mode 100644 index 00000000000..38ffb6663bd --- /dev/null +++ b/libs/sdktypes/lakeview/v1/types.generated.go @@ -0,0 +1,1398 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/lakeview/v1. DO NOT EDIT. + +package lakeview + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/lakeview/v1" + + types "github.com/databricks/sdk-go/core/types" +) + +type ( + DashboardView = sdk.DashboardView + LifecycleState = sdk.LifecycleState + SchedulePauseStatus = sdk.SchedulePauseStatus +) + +const ( + DashboardView_Unspecified = sdk.DashboardView_Unspecified + DashboardView_DashboardViewBasic = sdk.DashboardView_DashboardViewBasic + LifecycleState_Unspecified = sdk.LifecycleState_Unspecified + LifecycleState_Active = sdk.LifecycleState_Active + LifecycleState_Trashed = sdk.LifecycleState_Trashed + SchedulePauseStatus_Unspecified = sdk.SchedulePauseStatus_Unspecified + SchedulePauseStatus_Unpaused = sdk.SchedulePauseStatus_Unpaused + SchedulePauseStatus_Paused = sdk.SchedulePauseStatus_Paused +) + +type AuthorizationDetails struct { + // Represents downscoped permission rules with specific access rights. This + // field is specific to `workspace_rule_set` constraint. + GrantRules []AuthorizationDetails_GrantRule `json:"grant_rules,omitempty"` + // The acl path of the tree store resource resource. + ResourceLegacyAclPath *string `json:"resource_legacy_acl_path,omitempty"` + // The resource name to which the authorization rule applies. This field is + // specific to `workspace_rule_set` constraint. Format: + // `workspaces/{workspace_id}/dashboards/{dashboard_id}` + ResourceName *string `json:"resource_name,omitempty"` + // The type of authorization downscoping policy. Ex: `workspace_rule_set` + // defines access rules for a specific workspace resource + Type *string `json:"type,omitempty"` +} + +type AuthorizationDetails_GrantRule struct { + // Permission sets for dashboard are defined in + // iam-common/rbac-common/permission-sets/definitions/TreeStoreBasePermissionSets + // Ex: `permissionSets/dashboard.runner` + PermissionSet *string `json:"permission_set,omitempty"` +} + +type CreateDashboardRequest struct { + Dashboard *DashboardCreate `json:"dashboard,omitempty"` + // Sets the default catalog for all datasets in this dashboard. Does not impact + // table references that use fully qualified catalog names (ex: + // samples.nyctaxi.trips). Leave blank to keep each dataset’s existing + // configuration. + DatasetCatalog *string `json:"dataset_catalog,omitempty"` + // Sets the default schema for all datasets in this dashboard. Does not impact + // table references that use fully qualified schema names (ex: nyctaxi.trips). + // Leave blank to keep each dataset’s existing configuration. + DatasetSchema *string `json:"dataset_schema,omitempty"` +} + +type CreateScheduleRequest struct { + // The schedule to create. A dashboard is limited to 10 schedules. + Schedule *ScheduleCreate `json:"schedule,omitempty"` +} + +type CreateSubscriptionRequest struct { + // The subscription to create. A schedule is limited to 100 subscriptions. + Subscription *SubscriptionCreate `json:"subscription,omitempty"` +} + +type CronSchedule struct { + // A cron expression using quartz syntax. EX: `0 0 8 * * ?` represents everyday + // at 8am. See [Cron Trigger] for details. + // + // [Cron Trigger]: http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html + QuartzCronExpression *string `json:"quartz_cron_expression,omitempty"` + // A Java timezone id. The schedule will be resolved with respect to this + // timezone. See [Java TimeZone] for details. + // + // [Java TimeZone]: https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html + TimezoneId *string `json:"timezone_id,omitempty"` +} + +type Dashboard struct { + // The timestamp of when the dashboard was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // UUID identifying the dashboard. + DashboardId *string `json:"dashboard_id,omitempty"` + // The display name of the dashboard. + DisplayName *string `json:"display_name,omitempty"` + // The etag for the dashboard. Can be optionally provided on updates to ensure + // that the dashboard has not been modified since the last read. This field is + // excluded in List Dashboards responses. + Etag *string `json:"etag,omitempty"` + // The state of the dashboard resource. Used for tracking trashed status. + LifecycleState LifecycleState `json:"lifecycle_state,omitempty"` + // The workspace path of the folder containing the dashboard. Includes leading + // slash and no trailing slash. This field is excluded in List Dashboards + // responses. + ParentPath *string `json:"parent_path,omitempty"` + // The workspace path of the dashboard asset, including the file name. Exported + // dashboards always have the file extension `.lvdash.json`. This field is + // excluded in List Dashboards responses. + Path *string `json:"path,omitempty"` + // The contents of the dashboard in serialized string form. This field is + // excluded in List Dashboards responses. Use the [get dashboard API] to + // retrieve an example response, which includes the `serialized_dashboard` + // field. This field provides the structure of the JSON string that represents + // the dashboard's layout and components. + // + // [get dashboard API]: https://docs.databricks.com/api/workspace/lakeview/get + SerializedDashboard *string `json:"serialized_dashboard,omitempty"` + // The timestamp of when the dashboard was last updated by the user. This field + // is excluded in List Dashboards responses. + UpdateTime *types.Time `json:"update_time,omitempty"` + // The warehouse ID used to run the dashboard. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type DashboardCreate struct { + // The timestamp of when the dashboard was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // UUID identifying the dashboard. + DashboardId *string `json:"dashboard_id,omitempty"` + // The display name of the dashboard. + DisplayName *string `json:"display_name,omitempty"` + // The state of the dashboard resource. Used for tracking trashed status. + LifecycleState LifecycleState `json:"lifecycle_state,omitempty"` + // The workspace path of the folder containing the dashboard. Includes leading + // slash and no trailing slash. This field is excluded in List Dashboards + // responses. + ParentPath *string `json:"parent_path,omitempty"` + // The workspace path of the dashboard asset, including the file name. Exported + // dashboards always have the file extension `.lvdash.json`. This field is + // excluded in List Dashboards responses. + Path *string `json:"path,omitempty"` + // The contents of the dashboard in serialized string form. This field is + // excluded in List Dashboards responses. Use the [get dashboard API] to + // retrieve an example response, which includes the `serialized_dashboard` + // field. This field provides the structure of the JSON string that represents + // the dashboard's layout and components. + // + // [get dashboard API]: https://docs.databricks.com/api/workspace/lakeview/get + SerializedDashboard *string `json:"serialized_dashboard,omitempty"` + // The timestamp of when the dashboard was last updated by the user. This field + // is excluded in List Dashboards responses. + UpdateTime *types.Time `json:"update_time,omitempty"` + // The warehouse ID used to run the dashboard. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type DeleteScheduleRequest struct { + // UUID identifying the dashboard to which the schedule belongs. + DashboardId *string `json:"dashboard_id,omitempty"` + // The etag for the schedule. Optionally, it can be provided to verify that the + // schedule has not been modified from its last retrieval. + Etag *string `json:"etag,omitempty"` + // UUID identifying the schedule. + ScheduleId *string `json:"schedule_id,omitempty"` +} + +type DeleteSubscriptionRequest struct { + // UUID identifying the dashboard which the subscription belongs. + DashboardId *string `json:"dashboard_id,omitempty"` + // The etag for the subscription. Can be optionally provided to ensure that the + // subscription has not been modified since the last read. + Etag *string `json:"etag,omitempty"` + // UUID identifying the schedule which the subscription belongs. + ScheduleId *string `json:"schedule_id,omitempty"` + // UUID identifying the subscription. + SubscriptionId *string `json:"subscription_id,omitempty"` +} + +type GetPublishedDashboardTokenInfoRequest struct { + // UUID identifying the published dashboard. + DashboardId *string `json:"dashboard_id,omitempty"` + // Provided external value to be included in the custom claim. + ExternalValue *string `json:"external_value,omitempty"` + // Provided external viewer id to be included in the custom claim. + ExternalViewerId *string `json:"external_viewer_id,omitempty"` +} + +type GetPublishedDashboardTokenInfoResponse struct { + // Authorization constraints for accessing the published dashboard. Currently + // includes `workspace_rule_set` and could be enriched with + // `unity_catalog_privileges` before oAuth token generation. + AuthorizationDetails []AuthorizationDetails `json:"authorization_details,omitempty"` + // Custom claim generated from external_value and external_viewer_id. Format: + // `urn:aibi:external_data:::` + CustomClaim *string `json:"custom_claim,omitempty"` + // Scope defining access permissions. + Scope *string `json:"scope,omitempty"` +} + +type ListDashboardsRequest struct { + // The number of dashboards to return per page. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous `ListDashboards` call. This token can + // be used to retrieve the subsequent page. + PageToken *string `json:"page_token,omitempty"` + // The flag to include dashboards located in the trash. If unspecified, only + // active dashboards will be returned. + ShowTrashed *bool `json:"show_trashed,omitempty"` + // `DASHBOARD_VIEW_BASIC` only includes summary metadata from the dashboard. + View DashboardView `json:"view,omitempty"` +} + +type ListDashboardsResponse struct { + Dashboards []Dashboard `json:"dashboards,omitempty"` + // A token, which can be sent as `page_token` to retrieve the next page. If this + // field is omitted, there are no subsequent dashboards. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListSchedulesRequest struct { + // UUID identifying the dashboard to which the schedules belongs. + DashboardId *string `json:"dashboard_id,omitempty"` + // The number of schedules to return per page. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous `ListSchedules` call. Use this to + // retrieve the subsequent page. + PageToken *string `json:"page_token,omitempty"` +} + +type ListSchedulesResponse struct { + // A token that can be used as a `page_token` in subsequent requests to retrieve + // the next page of results. If this field is omitted, there are no subsequent + // schedules. + NextPageToken *string `json:"next_page_token,omitempty"` + Schedules []Schedule `json:"schedules,omitempty"` +} + +type ListSubscriptionsRequest struct { + // UUID identifying the dashboard which the subscriptions belongs. + DashboardId *string `json:"dashboard_id,omitempty"` + // The number of subscriptions to return per page. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous `ListSubscriptions` call. Use this to + // retrieve the subsequent page. + PageToken *string `json:"page_token,omitempty"` + // UUID identifying the schedule which the subscriptions belongs. + ScheduleId *string `json:"schedule_id,omitempty"` +} + +type ListSubscriptionsResponse struct { + // A token that can be used as a `page_token` in subsequent requests to retrieve + // the next page of results. If this field is omitted, there are no subsequent + // subscriptions. + NextPageToken *string `json:"next_page_token,omitempty"` + Subscriptions []Subscription `json:"subscriptions,omitempty"` +} + +type MigrateDashboardRequest struct { + // Display name for the new Lakeview dashboard. + DisplayName *string `json:"display_name,omitempty"` + // The workspace path of the folder to contain the migrated Lakeview dashboard. + ParentPath *string `json:"parent_path,omitempty"` + // UUID of the dashboard to be migrated. + SourceDashboardId *string `json:"source_dashboard_id,omitempty"` + // Flag to indicate if mustache parameter syntax ({{ param }}) should be + // auto-updated to named syntax (:param) when converting datasets in the + // dashboard. + UpdateParameterSyntax *bool `json:"update_parameter_syntax,omitempty"` +} + +type PublishDashboardRequest struct { + // UUID identifying the dashboard to be published. + DashboardId *string `json:"dashboard_id,omitempty"` + // Flag to indicate if the publisher's credentials should be embedded in the + // published dashboard. These embedded credentials will be used to execute the + // published dashboard's queries. + EmbedCredentials *bool `json:"embed_credentials,omitempty"` + // The ID of the warehouse that can be used to override the warehouse which was + // set in the draft. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type PublishedDashboard struct { + // The display name of the published dashboard. + DisplayName *string `json:"display_name,omitempty"` + // Indicates whether credentials are embedded in the published dashboard. + EmbedCredentials *bool `json:"embed_credentials,omitempty"` + // The timestamp of when the published dashboard was last revised. + RevisionCreateTime *types.Time `json:"revision_create_time,omitempty"` + // The warehouse ID used to run the published dashboard. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +// Request to revert a dashboard draft to its last published state.. +type RevertDashboardRequest struct { + // UUID identifying the dashboard. + DashboardId *string `json:"dashboard_id,omitempty"` + // The etag for the dashboard. Optionally, it can be provided to verify that the + // dashboard has not been modified from its last retrieval. + Etag *string `json:"etag,omitempty"` +} + +// Response to revert a dashboard draft to its last published state.. +type RevertDashboardResponse struct { + // The reverted dashboard. + Dashboard *Dashboard `json:"dashboard,omitempty"` +} + +type Schedule struct { + // A timestamp indicating when the schedule was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // The cron expression describing the frequency of the periodic refresh for this + // schedule. + CronSchedule *CronSchedule `json:"cron_schedule,omitempty"` + // UUID identifying the dashboard to which the schedule belongs. + DashboardId *string `json:"dashboard_id,omitempty"` + // The display name for schedule. + DisplayName *string `json:"display_name,omitempty"` + // The etag for the schedule. Must be left empty on create, must be provided on + // updates to ensure that the schedule has not been modified since the last + // read, and can be optionally provided on delete. + Etag *string `json:"etag,omitempty"` + // The status indicates whether this schedule is paused or not. + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + // UUID identifying the schedule. + ScheduleId *string `json:"schedule_id,omitempty"` + // A timestamp indicating when the schedule was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` + // The warehouse id to run the dashboard with for the schedule. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type ScheduleCreate struct { + // A timestamp indicating when the schedule was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // The cron expression describing the frequency of the periodic refresh for this + // schedule. + CronSchedule *CronSchedule `json:"cron_schedule,omitempty"` + // UUID identifying the dashboard to which the schedule belongs. + DashboardId *string `json:"dashboard_id,omitempty"` + // The display name for schedule. + DisplayName *string `json:"display_name,omitempty"` + // The status indicates whether this schedule is paused or not. + PauseStatus SchedulePauseStatus `json:"pause_status,omitempty"` + // UUID identifying the schedule. + ScheduleId *string `json:"schedule_id,omitempty"` + // A timestamp indicating when the schedule was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` + // The warehouse id to run the dashboard with for the schedule. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type Subscription struct { + // A timestamp indicating when the subscription was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // UserId of the user who adds subscribers (users or notification destinations) + // to the dashboard's schedule. + CreatedByUserId *int64 `json:"created_by_user_id,omitempty"` + // UUID identifying the dashboard to which the subscription belongs. + DashboardId *string `json:"dashboard_id,omitempty"` + // The etag for the subscription. Must be left empty on create, can be + // optionally provided on delete to ensure that the subscription has not been + // deleted since the last read. + Etag *string `json:"etag,omitempty"` + // UUID identifying the schedule to which the subscription belongs. + ScheduleId *string `json:"schedule_id,omitempty"` + // Controls whether notifications are sent to the subscriber for scheduled + // dashboard refreshes. If not defined, defaults to false in the backend to + // match the current behavior (refresh and notify) + SkipNotify *bool `json:"skip_notify,omitempty"` + // Subscriber details for users and destinations to be added as subscribers to + // the schedule. + Subscriber *Subscription_Subscriber `json:"subscriber,omitempty"` + // UUID identifying the subscription. + SubscriptionId *string `json:"subscription_id,omitempty"` + // A timestamp indicating when the subscription was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +type Subscription_Subscriber struct { + // The destination to receive the subscription email. This parameter is mutually + // exclusive with `user_subscriber`. + DestinationSubscriber *Subscription_Subscriber_Destination `json:"destination_subscriber,omitempty"` + // The user to receive the subscription email. This parameter is mutually + // exclusive with `destination_subscriber`. + UserSubscriber *Subscription_Subscriber_User `json:"user_subscriber,omitempty"` +} + +type Subscription_Subscriber_Destination struct { + // The canonical identifier of the destination to receive email notification. + DestinationId *string `json:"destination_id,omitempty"` +} + +type Subscription_Subscriber_User struct { + // UserId of the subscriber. + UserId *int64 `json:"user_id,omitempty"` +} + +type SubscriptionCreate struct { + // A timestamp indicating when the subscription was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // UserId of the user who adds subscribers (users or notification destinations) + // to the dashboard's schedule. + CreatedByUserId *int64 `json:"created_by_user_id,omitempty"` + // UUID identifying the dashboard to which the subscription belongs. + DashboardId *string `json:"dashboard_id,omitempty"` + // UUID identifying the schedule to which the subscription belongs. + ScheduleId *string `json:"schedule_id,omitempty"` + // Controls whether notifications are sent to the subscriber for scheduled + // dashboard refreshes. If not defined, defaults to false in the backend to + // match the current behavior (refresh and notify) + SkipNotify *bool `json:"skip_notify,omitempty"` + // Subscriber details for users and destinations to be added as subscribers to + // the schedule. + Subscriber *Subscription_Subscriber `json:"subscriber,omitempty"` + // UUID identifying the subscription. + SubscriptionId *string `json:"subscription_id,omitempty"` + // A timestamp indicating when the subscription was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +type UpdateDashboardRequest struct { + Dashboard *Dashboard `json:"dashboard,omitempty"` + // Sets the default catalog for all datasets in this dashboard. Does not impact + // table references that use fully qualified catalog names (ex: + // samples.nyctaxi.trips). Leave blank to keep each dataset’s existing + // configuration. + DatasetCatalog *string `json:"dataset_catalog,omitempty"` + // Sets the default schema for all datasets in this dashboard. Does not impact + // table references that use fully qualified schema names (ex: nyctaxi.trips). + // Leave blank to keep each dataset’s existing configuration. + DatasetSchema *string `json:"dataset_schema,omitempty"` +} + +type UpdateScheduleRequest struct { + // The schedule to update. + Schedule *Schedule `json:"schedule,omitempty"` +} + +// AuthorizationDetailsToSDK converts the mirror to the sdk-go type. +func AuthorizationDetailsToSDK(w *AuthorizationDetails) (*sdk.AuthorizationDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.AuthorizationDetails{} + out.Type = w.Type + out.ResourceName = w.ResourceName + out.ResourceLegacyAclPath = w.ResourceLegacyAclPath + conv1, err := convertSlice(w.GrantRules, AuthorizationDetails_GrantRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AuthorizationDetails.GrantRules", err) + } + out.GrantRules = conv1 + return out, nil +} + +// AuthorizationDetailsFromSDK converts the sdk-go type to the mirror. +func AuthorizationDetailsFromSDK(v *sdk.AuthorizationDetails) (*AuthorizationDetails, error) { + if v == nil { + return nil, nil + } + out := &AuthorizationDetails{} + out.Type = v.Type + out.ResourceName = v.ResourceName + out.ResourceLegacyAclPath = v.ResourceLegacyAclPath + conv2, err := convertSlice(v.GrantRules, AuthorizationDetails_GrantRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AuthorizationDetails.GrantRules", err) + } + out.GrantRules = conv2 + return out, nil +} + +// AuthorizationDetails_GrantRuleToSDK converts the mirror to the sdk-go type. +func AuthorizationDetails_GrantRuleToSDK(w *AuthorizationDetails_GrantRule) (*sdk.AuthorizationDetails_GrantRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.AuthorizationDetails_GrantRule{} + out.PermissionSet = w.PermissionSet + return out, nil +} + +// AuthorizationDetails_GrantRuleFromSDK converts the sdk-go type to the mirror. +func AuthorizationDetails_GrantRuleFromSDK(v *sdk.AuthorizationDetails_GrantRule) (*AuthorizationDetails_GrantRule, error) { + if v == nil { + return nil, nil + } + out := &AuthorizationDetails_GrantRule{} + out.PermissionSet = v.PermissionSet + return out, nil +} + +// CreateDashboardRequestToSDK converts the mirror to the sdk-go type. +func CreateDashboardRequestToSDK(w *CreateDashboardRequest) (*sdk.CreateDashboardRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateDashboardRequest{} + conv3, err := DashboardCreateToSDK(w.Dashboard) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDashboardRequest.Dashboard", err) + } + out.Dashboard = conv3 + out.DatasetCatalog = w.DatasetCatalog + out.DatasetSchema = w.DatasetSchema + return out, nil +} + +// CreateDashboardRequestFromSDK converts the sdk-go type to the mirror. +func CreateDashboardRequestFromSDK(v *sdk.CreateDashboardRequest) (*CreateDashboardRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateDashboardRequest{} + conv4, err := DashboardCreateFromSDK(v.Dashboard) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDashboardRequest.Dashboard", err) + } + out.Dashboard = conv4 + out.DatasetCatalog = v.DatasetCatalog + out.DatasetSchema = v.DatasetSchema + return out, nil +} + +// CreateScheduleRequestToSDK converts the mirror to the sdk-go type. +func CreateScheduleRequestToSDK(w *CreateScheduleRequest) (*sdk.CreateScheduleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateScheduleRequest{} + conv5, err := ScheduleCreateToSDK(w.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateScheduleRequest.Schedule", err) + } + out.Schedule = conv5 + return out, nil +} + +// CreateScheduleRequestFromSDK converts the sdk-go type to the mirror. +func CreateScheduleRequestFromSDK(v *sdk.CreateScheduleRequest) (*CreateScheduleRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateScheduleRequest{} + conv6, err := ScheduleCreateFromSDK(v.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateScheduleRequest.Schedule", err) + } + out.Schedule = conv6 + return out, nil +} + +// CreateSubscriptionRequestToSDK converts the mirror to the sdk-go type. +func CreateSubscriptionRequestToSDK(w *CreateSubscriptionRequest) (*sdk.CreateSubscriptionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateSubscriptionRequest{} + conv7, err := SubscriptionCreateToSDK(w.Subscription) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSubscriptionRequest.Subscription", err) + } + out.Subscription = conv7 + return out, nil +} + +// CreateSubscriptionRequestFromSDK converts the sdk-go type to the mirror. +func CreateSubscriptionRequestFromSDK(v *sdk.CreateSubscriptionRequest) (*CreateSubscriptionRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateSubscriptionRequest{} + conv8, err := SubscriptionCreateFromSDK(v.Subscription) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSubscriptionRequest.Subscription", err) + } + out.Subscription = conv8 + return out, nil +} + +// CronScheduleToSDK converts the mirror to the sdk-go type. +func CronScheduleToSDK(w *CronSchedule) (*sdk.CronSchedule, error) { + if w == nil { + return nil, nil + } + out := &sdk.CronSchedule{} + out.QuartzCronExpression = w.QuartzCronExpression + out.TimezoneId = w.TimezoneId + return out, nil +} + +// CronScheduleFromSDK converts the sdk-go type to the mirror. +func CronScheduleFromSDK(v *sdk.CronSchedule) (*CronSchedule, error) { + if v == nil { + return nil, nil + } + out := &CronSchedule{} + out.QuartzCronExpression = v.QuartzCronExpression + out.TimezoneId = v.TimezoneId + return out, nil +} + +// DashboardToSDK converts the mirror to the sdk-go type. +func DashboardToSDK(w *Dashboard) (*sdk.Dashboard, error) { + if w == nil { + return nil, nil + } + out := &sdk.Dashboard{} + out.DashboardId = w.DashboardId + out.DisplayName = w.DisplayName + out.Path = w.Path + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.WarehouseId = w.WarehouseId + out.Etag = w.Etag + out.SerializedDashboard = w.SerializedDashboard + out.LifecycleState = w.LifecycleState + out.ParentPath = w.ParentPath + return out, nil +} + +// DashboardFromSDK converts the sdk-go type to the mirror. +func DashboardFromSDK(v *sdk.Dashboard) (*Dashboard, error) { + if v == nil { + return nil, nil + } + out := &Dashboard{} + out.DashboardId = v.DashboardId + out.DisplayName = v.DisplayName + out.Path = v.Path + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.WarehouseId = v.WarehouseId + out.Etag = v.Etag + out.SerializedDashboard = v.SerializedDashboard + out.LifecycleState = v.LifecycleState + out.ParentPath = v.ParentPath + return out, nil +} + +// DashboardCreateToSDK converts the mirror to the sdk-go type. +func DashboardCreateToSDK(w *DashboardCreate) (*sdk.DashboardCreate, error) { + if w == nil { + return nil, nil + } + out := &sdk.DashboardCreate{} + out.DashboardId = w.DashboardId + out.DisplayName = w.DisplayName + out.Path = w.Path + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.WarehouseId = w.WarehouseId + out.SerializedDashboard = w.SerializedDashboard + out.LifecycleState = w.LifecycleState + out.ParentPath = w.ParentPath + return out, nil +} + +// DashboardCreateFromSDK converts the sdk-go type to the mirror. +func DashboardCreateFromSDK(v *sdk.DashboardCreate) (*DashboardCreate, error) { + if v == nil { + return nil, nil + } + out := &DashboardCreate{} + out.DashboardId = v.DashboardId + out.DisplayName = v.DisplayName + out.Path = v.Path + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.WarehouseId = v.WarehouseId + out.SerializedDashboard = v.SerializedDashboard + out.LifecycleState = v.LifecycleState + out.ParentPath = v.ParentPath + return out, nil +} + +// DeleteScheduleRequestToSDK converts the mirror to the sdk-go type. +func DeleteScheduleRequestToSDK(w *DeleteScheduleRequest) (*sdk.DeleteScheduleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteScheduleRequest{} + out.ScheduleId = w.ScheduleId + out.DashboardId = w.DashboardId + out.Etag = w.Etag + return out, nil +} + +// DeleteScheduleRequestFromSDK converts the sdk-go type to the mirror. +func DeleteScheduleRequestFromSDK(v *sdk.DeleteScheduleRequest) (*DeleteScheduleRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteScheduleRequest{} + out.ScheduleId = v.ScheduleId + out.DashboardId = v.DashboardId + out.Etag = v.Etag + return out, nil +} + +// DeleteSubscriptionRequestToSDK converts the mirror to the sdk-go type. +func DeleteSubscriptionRequestToSDK(w *DeleteSubscriptionRequest) (*sdk.DeleteSubscriptionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteSubscriptionRequest{} + out.SubscriptionId = w.SubscriptionId + out.ScheduleId = w.ScheduleId + out.DashboardId = w.DashboardId + out.Etag = w.Etag + return out, nil +} + +// DeleteSubscriptionRequestFromSDK converts the sdk-go type to the mirror. +func DeleteSubscriptionRequestFromSDK(v *sdk.DeleteSubscriptionRequest) (*DeleteSubscriptionRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteSubscriptionRequest{} + out.SubscriptionId = v.SubscriptionId + out.ScheduleId = v.ScheduleId + out.DashboardId = v.DashboardId + out.Etag = v.Etag + return out, nil +} + +// GetPublishedDashboardTokenInfoRequestToSDK converts the mirror to the sdk-go type. +func GetPublishedDashboardTokenInfoRequestToSDK(w *GetPublishedDashboardTokenInfoRequest) (*sdk.GetPublishedDashboardTokenInfoRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPublishedDashboardTokenInfoRequest{} + out.DashboardId = w.DashboardId + out.ExternalValue = w.ExternalValue + out.ExternalViewerId = w.ExternalViewerId + return out, nil +} + +// GetPublishedDashboardTokenInfoRequestFromSDK converts the sdk-go type to the mirror. +func GetPublishedDashboardTokenInfoRequestFromSDK(v *sdk.GetPublishedDashboardTokenInfoRequest) (*GetPublishedDashboardTokenInfoRequest, error) { + if v == nil { + return nil, nil + } + out := &GetPublishedDashboardTokenInfoRequest{} + out.DashboardId = v.DashboardId + out.ExternalValue = v.ExternalValue + out.ExternalViewerId = v.ExternalViewerId + return out, nil +} + +// GetPublishedDashboardTokenInfoResponseToSDK converts the mirror to the sdk-go type. +func GetPublishedDashboardTokenInfoResponseToSDK(w *GetPublishedDashboardTokenInfoResponse) (*sdk.GetPublishedDashboardTokenInfoResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPublishedDashboardTokenInfoResponse{} + out.CustomClaim = w.CustomClaim + out.Scope = w.Scope + conv9, err := convertSlice(w.AuthorizationDetails, AuthorizationDetailsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPublishedDashboardTokenInfoResponse.AuthorizationDetails", err) + } + out.AuthorizationDetails = conv9 + return out, nil +} + +// GetPublishedDashboardTokenInfoResponseFromSDK converts the sdk-go type to the mirror. +func GetPublishedDashboardTokenInfoResponseFromSDK(v *sdk.GetPublishedDashboardTokenInfoResponse) (*GetPublishedDashboardTokenInfoResponse, error) { + if v == nil { + return nil, nil + } + out := &GetPublishedDashboardTokenInfoResponse{} + out.CustomClaim = v.CustomClaim + out.Scope = v.Scope + conv10, err := convertSlice(v.AuthorizationDetails, AuthorizationDetailsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPublishedDashboardTokenInfoResponse.AuthorizationDetails", err) + } + out.AuthorizationDetails = conv10 + return out, nil +} + +// ListDashboardsRequestToSDK converts the mirror to the sdk-go type. +func ListDashboardsRequestToSDK(w *ListDashboardsRequest) (*sdk.ListDashboardsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDashboardsRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + out.ShowTrashed = w.ShowTrashed + out.View = w.View + return out, nil +} + +// ListDashboardsRequestFromSDK converts the sdk-go type to the mirror. +func ListDashboardsRequestFromSDK(v *sdk.ListDashboardsRequest) (*ListDashboardsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListDashboardsRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + out.ShowTrashed = v.ShowTrashed + out.View = v.View + return out, nil +} + +// ListDashboardsResponseToSDK converts the mirror to the sdk-go type. +func ListDashboardsResponseToSDK(w *ListDashboardsResponse) (*sdk.ListDashboardsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDashboardsResponse{} + conv11, err := convertSlice(w.Dashboards, DashboardToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDashboardsResponse.Dashboards", err) + } + out.Dashboards = conv11 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListDashboardsResponseFromSDK converts the sdk-go type to the mirror. +func ListDashboardsResponseFromSDK(v *sdk.ListDashboardsResponse) (*ListDashboardsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListDashboardsResponse{} + conv12, err := convertSlice(v.Dashboards, DashboardFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDashboardsResponse.Dashboards", err) + } + out.Dashboards = conv12 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListSchedulesRequestToSDK converts the mirror to the sdk-go type. +func ListSchedulesRequestToSDK(w *ListSchedulesRequest) (*sdk.ListSchedulesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSchedulesRequest{} + out.DashboardId = w.DashboardId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListSchedulesRequestFromSDK converts the sdk-go type to the mirror. +func ListSchedulesRequestFromSDK(v *sdk.ListSchedulesRequest) (*ListSchedulesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSchedulesRequest{} + out.DashboardId = v.DashboardId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListSchedulesResponseToSDK converts the mirror to the sdk-go type. +func ListSchedulesResponseToSDK(w *ListSchedulesResponse) (*sdk.ListSchedulesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSchedulesResponse{} + conv13, err := convertSlice(w.Schedules, ScheduleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSchedulesResponse.Schedules", err) + } + out.Schedules = conv13 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSchedulesResponseFromSDK converts the sdk-go type to the mirror. +func ListSchedulesResponseFromSDK(v *sdk.ListSchedulesResponse) (*ListSchedulesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSchedulesResponse{} + conv14, err := convertSlice(v.Schedules, ScheduleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSchedulesResponse.Schedules", err) + } + out.Schedules = conv14 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListSubscriptionsRequestToSDK converts the mirror to the sdk-go type. +func ListSubscriptionsRequestToSDK(w *ListSubscriptionsRequest) (*sdk.ListSubscriptionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSubscriptionsRequest{} + out.DashboardId = w.DashboardId + out.ScheduleId = w.ScheduleId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListSubscriptionsRequestFromSDK converts the sdk-go type to the mirror. +func ListSubscriptionsRequestFromSDK(v *sdk.ListSubscriptionsRequest) (*ListSubscriptionsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSubscriptionsRequest{} + out.DashboardId = v.DashboardId + out.ScheduleId = v.ScheduleId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListSubscriptionsResponseToSDK converts the mirror to the sdk-go type. +func ListSubscriptionsResponseToSDK(w *ListSubscriptionsResponse) (*sdk.ListSubscriptionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSubscriptionsResponse{} + conv15, err := convertSlice(w.Subscriptions, SubscriptionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSubscriptionsResponse.Subscriptions", err) + } + out.Subscriptions = conv15 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSubscriptionsResponseFromSDK converts the sdk-go type to the mirror. +func ListSubscriptionsResponseFromSDK(v *sdk.ListSubscriptionsResponse) (*ListSubscriptionsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSubscriptionsResponse{} + conv16, err := convertSlice(v.Subscriptions, SubscriptionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSubscriptionsResponse.Subscriptions", err) + } + out.Subscriptions = conv16 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// MigrateDashboardRequestToSDK converts the mirror to the sdk-go type. +func MigrateDashboardRequestToSDK(w *MigrateDashboardRequest) (*sdk.MigrateDashboardRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.MigrateDashboardRequest{} + out.SourceDashboardId = w.SourceDashboardId + out.DisplayName = w.DisplayName + out.ParentPath = w.ParentPath + out.UpdateParameterSyntax = w.UpdateParameterSyntax + return out, nil +} + +// MigrateDashboardRequestFromSDK converts the sdk-go type to the mirror. +func MigrateDashboardRequestFromSDK(v *sdk.MigrateDashboardRequest) (*MigrateDashboardRequest, error) { + if v == nil { + return nil, nil + } + out := &MigrateDashboardRequest{} + out.SourceDashboardId = v.SourceDashboardId + out.DisplayName = v.DisplayName + out.ParentPath = v.ParentPath + out.UpdateParameterSyntax = v.UpdateParameterSyntax + return out, nil +} + +// PublishDashboardRequestToSDK converts the mirror to the sdk-go type. +func PublishDashboardRequestToSDK(w *PublishDashboardRequest) (*sdk.PublishDashboardRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PublishDashboardRequest{} + out.DashboardId = w.DashboardId + out.EmbedCredentials = w.EmbedCredentials + out.WarehouseId = w.WarehouseId + return out, nil +} + +// PublishDashboardRequestFromSDK converts the sdk-go type to the mirror. +func PublishDashboardRequestFromSDK(v *sdk.PublishDashboardRequest) (*PublishDashboardRequest, error) { + if v == nil { + return nil, nil + } + out := &PublishDashboardRequest{} + out.DashboardId = v.DashboardId + out.EmbedCredentials = v.EmbedCredentials + out.WarehouseId = v.WarehouseId + return out, nil +} + +// PublishedDashboardToSDK converts the mirror to the sdk-go type. +func PublishedDashboardToSDK(w *PublishedDashboard) (*sdk.PublishedDashboard, error) { + if w == nil { + return nil, nil + } + out := &sdk.PublishedDashboard{} + out.DisplayName = w.DisplayName + out.WarehouseId = w.WarehouseId + out.EmbedCredentials = w.EmbedCredentials + out.RevisionCreateTime = w.RevisionCreateTime + return out, nil +} + +// PublishedDashboardFromSDK converts the sdk-go type to the mirror. +func PublishedDashboardFromSDK(v *sdk.PublishedDashboard) (*PublishedDashboard, error) { + if v == nil { + return nil, nil + } + out := &PublishedDashboard{} + out.DisplayName = v.DisplayName + out.WarehouseId = v.WarehouseId + out.EmbedCredentials = v.EmbedCredentials + out.RevisionCreateTime = v.RevisionCreateTime + return out, nil +} + +// RevertDashboardRequestToSDK converts the mirror to the sdk-go type. +func RevertDashboardRequestToSDK(w *RevertDashboardRequest) (*sdk.RevertDashboardRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RevertDashboardRequest{} + out.DashboardId = w.DashboardId + out.Etag = w.Etag + return out, nil +} + +// RevertDashboardRequestFromSDK converts the sdk-go type to the mirror. +func RevertDashboardRequestFromSDK(v *sdk.RevertDashboardRequest) (*RevertDashboardRequest, error) { + if v == nil { + return nil, nil + } + out := &RevertDashboardRequest{} + out.DashboardId = v.DashboardId + out.Etag = v.Etag + return out, nil +} + +// RevertDashboardResponseToSDK converts the mirror to the sdk-go type. +func RevertDashboardResponseToSDK(w *RevertDashboardResponse) (*sdk.RevertDashboardResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.RevertDashboardResponse{} + conv17, err := DashboardToSDK(w.Dashboard) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RevertDashboardResponse.Dashboard", err) + } + out.Dashboard = conv17 + return out, nil +} + +// RevertDashboardResponseFromSDK converts the sdk-go type to the mirror. +func RevertDashboardResponseFromSDK(v *sdk.RevertDashboardResponse) (*RevertDashboardResponse, error) { + if v == nil { + return nil, nil + } + out := &RevertDashboardResponse{} + conv18, err := DashboardFromSDK(v.Dashboard) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RevertDashboardResponse.Dashboard", err) + } + out.Dashboard = conv18 + return out, nil +} + +// ScheduleToSDK converts the mirror to the sdk-go type. +func ScheduleToSDK(w *Schedule) (*sdk.Schedule, error) { + if w == nil { + return nil, nil + } + out := &sdk.Schedule{} + out.ScheduleId = w.ScheduleId + out.DashboardId = w.DashboardId + conv19, err := CronScheduleToSDK(w.CronSchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Schedule.CronSchedule", err) + } + out.CronSchedule = conv19 + out.PauseStatus = w.PauseStatus + out.DisplayName = w.DisplayName + out.Etag = w.Etag + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.WarehouseId = w.WarehouseId + return out, nil +} + +// ScheduleFromSDK converts the sdk-go type to the mirror. +func ScheduleFromSDK(v *sdk.Schedule) (*Schedule, error) { + if v == nil { + return nil, nil + } + out := &Schedule{} + out.ScheduleId = v.ScheduleId + out.DashboardId = v.DashboardId + conv20, err := CronScheduleFromSDK(v.CronSchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Schedule.CronSchedule", err) + } + out.CronSchedule = conv20 + out.PauseStatus = v.PauseStatus + out.DisplayName = v.DisplayName + out.Etag = v.Etag + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.WarehouseId = v.WarehouseId + return out, nil +} + +// ScheduleCreateToSDK converts the mirror to the sdk-go type. +func ScheduleCreateToSDK(w *ScheduleCreate) (*sdk.ScheduleCreate, error) { + if w == nil { + return nil, nil + } + out := &sdk.ScheduleCreate{} + out.ScheduleId = w.ScheduleId + out.DashboardId = w.DashboardId + conv21, err := CronScheduleToSDK(w.CronSchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ScheduleCreate.CronSchedule", err) + } + out.CronSchedule = conv21 + out.PauseStatus = w.PauseStatus + out.DisplayName = w.DisplayName + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.WarehouseId = w.WarehouseId + return out, nil +} + +// ScheduleCreateFromSDK converts the sdk-go type to the mirror. +func ScheduleCreateFromSDK(v *sdk.ScheduleCreate) (*ScheduleCreate, error) { + if v == nil { + return nil, nil + } + out := &ScheduleCreate{} + out.ScheduleId = v.ScheduleId + out.DashboardId = v.DashboardId + conv22, err := CronScheduleFromSDK(v.CronSchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ScheduleCreate.CronSchedule", err) + } + out.CronSchedule = conv22 + out.PauseStatus = v.PauseStatus + out.DisplayName = v.DisplayName + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.WarehouseId = v.WarehouseId + return out, nil +} + +// SubscriptionToSDK converts the mirror to the sdk-go type. +func SubscriptionToSDK(w *Subscription) (*sdk.Subscription, error) { + if w == nil { + return nil, nil + } + out := &sdk.Subscription{} + out.SubscriptionId = w.SubscriptionId + out.ScheduleId = w.ScheduleId + out.DashboardId = w.DashboardId + conv23, err := Subscription_SubscriberToSDK(w.Subscriber) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Subscription.Subscriber", err) + } + out.Subscriber = conv23 + out.CreatedByUserId = w.CreatedByUserId + out.Etag = w.Etag + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.SkipNotify = w.SkipNotify + return out, nil +} + +// SubscriptionFromSDK converts the sdk-go type to the mirror. +func SubscriptionFromSDK(v *sdk.Subscription) (*Subscription, error) { + if v == nil { + return nil, nil + } + out := &Subscription{} + out.SubscriptionId = v.SubscriptionId + out.ScheduleId = v.ScheduleId + out.DashboardId = v.DashboardId + conv24, err := Subscription_SubscriberFromSDK(v.Subscriber) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Subscription.Subscriber", err) + } + out.Subscriber = conv24 + out.CreatedByUserId = v.CreatedByUserId + out.Etag = v.Etag + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.SkipNotify = v.SkipNotify + return out, nil +} + +// SubscriptionCreateToSDK converts the mirror to the sdk-go type. +func SubscriptionCreateToSDK(w *SubscriptionCreate) (*sdk.SubscriptionCreate, error) { + if w == nil { + return nil, nil + } + out := &sdk.SubscriptionCreate{} + out.SubscriptionId = w.SubscriptionId + out.ScheduleId = w.ScheduleId + out.DashboardId = w.DashboardId + conv25, err := Subscription_SubscriberToSDK(w.Subscriber) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubscriptionCreate.Subscriber", err) + } + out.Subscriber = conv25 + out.CreatedByUserId = w.CreatedByUserId + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.SkipNotify = w.SkipNotify + return out, nil +} + +// SubscriptionCreateFromSDK converts the sdk-go type to the mirror. +func SubscriptionCreateFromSDK(v *sdk.SubscriptionCreate) (*SubscriptionCreate, error) { + if v == nil { + return nil, nil + } + out := &SubscriptionCreate{} + out.SubscriptionId = v.SubscriptionId + out.ScheduleId = v.ScheduleId + out.DashboardId = v.DashboardId + conv26, err := Subscription_SubscriberFromSDK(v.Subscriber) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SubscriptionCreate.Subscriber", err) + } + out.Subscriber = conv26 + out.CreatedByUserId = v.CreatedByUserId + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.SkipNotify = v.SkipNotify + return out, nil +} + +// Subscription_SubscriberToSDK converts the mirror to the sdk-go type. +func Subscription_SubscriberToSDK(w *Subscription_Subscriber) (*sdk.Subscription_Subscriber, error) { + if w == nil { + return nil, nil + } + out := &sdk.Subscription_Subscriber{} + conv27, err := Subscription_Subscriber_UserToSDK(w.UserSubscriber) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Subscription_Subscriber.UserSubscriber", err) + } + out.UserSubscriber = conv27 + conv28, err := Subscription_Subscriber_DestinationToSDK(w.DestinationSubscriber) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Subscription_Subscriber.DestinationSubscriber", err) + } + out.DestinationSubscriber = conv28 + return out, nil +} + +// Subscription_SubscriberFromSDK converts the sdk-go type to the mirror. +func Subscription_SubscriberFromSDK(v *sdk.Subscription_Subscriber) (*Subscription_Subscriber, error) { + if v == nil { + return nil, nil + } + out := &Subscription_Subscriber{} + conv29, err := Subscription_Subscriber_UserFromSDK(v.UserSubscriber) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Subscription_Subscriber.UserSubscriber", err) + } + out.UserSubscriber = conv29 + conv30, err := Subscription_Subscriber_DestinationFromSDK(v.DestinationSubscriber) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Subscription_Subscriber.DestinationSubscriber", err) + } + out.DestinationSubscriber = conv30 + return out, nil +} + +// Subscription_Subscriber_DestinationToSDK converts the mirror to the sdk-go type. +func Subscription_Subscriber_DestinationToSDK(w *Subscription_Subscriber_Destination) (*sdk.Subscription_Subscriber_Destination, error) { + if w == nil { + return nil, nil + } + out := &sdk.Subscription_Subscriber_Destination{} + out.DestinationId = w.DestinationId + return out, nil +} + +// Subscription_Subscriber_DestinationFromSDK converts the sdk-go type to the mirror. +func Subscription_Subscriber_DestinationFromSDK(v *sdk.Subscription_Subscriber_Destination) (*Subscription_Subscriber_Destination, error) { + if v == nil { + return nil, nil + } + out := &Subscription_Subscriber_Destination{} + out.DestinationId = v.DestinationId + return out, nil +} + +// Subscription_Subscriber_UserToSDK converts the mirror to the sdk-go type. +func Subscription_Subscriber_UserToSDK(w *Subscription_Subscriber_User) (*sdk.Subscription_Subscriber_User, error) { + if w == nil { + return nil, nil + } + out := &sdk.Subscription_Subscriber_User{} + out.UserId = w.UserId + return out, nil +} + +// Subscription_Subscriber_UserFromSDK converts the sdk-go type to the mirror. +func Subscription_Subscriber_UserFromSDK(v *sdk.Subscription_Subscriber_User) (*Subscription_Subscriber_User, error) { + if v == nil { + return nil, nil + } + out := &Subscription_Subscriber_User{} + out.UserId = v.UserId + return out, nil +} + +// UpdateDashboardRequestToSDK converts the mirror to the sdk-go type. +func UpdateDashboardRequestToSDK(w *UpdateDashboardRequest) (*sdk.UpdateDashboardRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateDashboardRequest{} + conv31, err := DashboardToSDK(w.Dashboard) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDashboardRequest.Dashboard", err) + } + out.Dashboard = conv31 + out.DatasetCatalog = w.DatasetCatalog + out.DatasetSchema = w.DatasetSchema + return out, nil +} + +// UpdateDashboardRequestFromSDK converts the sdk-go type to the mirror. +func UpdateDashboardRequestFromSDK(v *sdk.UpdateDashboardRequest) (*UpdateDashboardRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateDashboardRequest{} + conv32, err := DashboardFromSDK(v.Dashboard) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDashboardRequest.Dashboard", err) + } + out.Dashboard = conv32 + out.DatasetCatalog = v.DatasetCatalog + out.DatasetSchema = v.DatasetSchema + return out, nil +} + +// UpdateScheduleRequestToSDK converts the mirror to the sdk-go type. +func UpdateScheduleRequestToSDK(w *UpdateScheduleRequest) (*sdk.UpdateScheduleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateScheduleRequest{} + conv33, err := ScheduleToSDK(w.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateScheduleRequest.Schedule", err) + } + out.Schedule = conv33 + return out, nil +} + +// UpdateScheduleRequestFromSDK converts the sdk-go type to the mirror. +func UpdateScheduleRequestFromSDK(v *sdk.UpdateScheduleRequest) (*UpdateScheduleRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateScheduleRequest{} + conv34, err := ScheduleFromSDK(v.Schedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateScheduleRequest.Schedule", err) + } + out.Schedule = conv34 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/logdelivery/v1/types.generated.go b/libs/sdktypes/logdelivery/v1/types.generated.go new file mode 100644 index 00000000000..5a2247ac340 --- /dev/null +++ b/libs/sdktypes/logdelivery/v1/types.generated.go @@ -0,0 +1,582 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/logdelivery/v1. DO NOT EDIT. + +package logdelivery + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/logdelivery/v1" +) + +type ( + LogDeliveryConfigStatus = sdk.LogDeliveryConfigStatus + LogDeliveryOutputFormat = sdk.LogDeliveryOutputFormat + LogDeliveryStatusEnum = sdk.LogDeliveryStatusEnum + LogDeliveryType = sdk.LogDeliveryType +) + +const ( + LogDeliveryConfigStatus_Unspecified = sdk.LogDeliveryConfigStatus_Unspecified + LogDeliveryConfigStatus_Enabled = sdk.LogDeliveryConfigStatus_Enabled + LogDeliveryConfigStatus_Disabled = sdk.LogDeliveryConfigStatus_Disabled + LogDeliveryOutputFormat_Unspecified = sdk.LogDeliveryOutputFormat_Unspecified + LogDeliveryOutputFormat_Csv = sdk.LogDeliveryOutputFormat_Csv + LogDeliveryOutputFormat_Json = sdk.LogDeliveryOutputFormat_Json + LogDeliveryStatusEnum_Unspecified = sdk.LogDeliveryStatusEnum_Unspecified + LogDeliveryStatusEnum_Created = sdk.LogDeliveryStatusEnum_Created + LogDeliveryStatusEnum_Succeeded = sdk.LogDeliveryStatusEnum_Succeeded + LogDeliveryStatusEnum_UserFailure = sdk.LogDeliveryStatusEnum_UserFailure + LogDeliveryStatusEnum_SystemFailure = sdk.LogDeliveryStatusEnum_SystemFailure + LogDeliveryStatusEnum_NotFound = sdk.LogDeliveryStatusEnum_NotFound + LogDeliveryType_Unspecified = sdk.LogDeliveryType_Unspecified + LogDeliveryType_BillableUsage = sdk.LogDeliveryType_BillableUsage + LogDeliveryType_AuditLogs = sdk.LogDeliveryType_AuditLogs +) + +// * Log Delivery Configuration. +type CreateLogDeliveryConfigurationParams struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + // The unique UUID of log delivery configuration + ConfigId *string `json:"config_id,omitempty"` + // The optional human-readable name of the log delivery configuration. Defaults + // to empty. + ConfigName *string `json:"config_name,omitempty"` + // Time in epoch milliseconds when the log delivery configuration was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // The ID for a method:credentials/create that represents the AWS IAM role with + // policy and trust relationship as described in the main billable usage + // documentation page. See [Configure billable usage delivery]. + // + // [Configure billable usage delivery]: https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html + CredentialsId *string `json:"credentials_id,omitempty"` + // The optional delivery path prefix within Amazon S3 storage. Defaults to + // empty, which means that logs are delivered to the root of the bucket. This + // must be a valid S3 object key. This must not start or end with a slash + // character. + DeliveryPathPrefix *string `json:"delivery_path_prefix,omitempty"` + // This field applies only if log_type is BILLABLE_USAGE. This is the optional + // start month and year for delivery, specified in YYYY-MM format. Defaults to + // current year and month. BILLABLE_USAGE logs are not available for usage + // before March 2019 (2019-03). + DeliveryStartTime *string `json:"delivery_start_time,omitempty"` + // The LogDeliveryStatus of this log delivery configuration + LogDeliveryStatus *LogDeliveryStatus `json:"log_delivery_status,omitempty"` + // Log delivery type. Supported values are: * `BILLABLE_USAGE` — Configure + // [billable usage log delivery]. For the CSV schema, see the [View billable + // usage]. * `AUDIT_LOGS` — Configure [audit log delivery]. For the JSON + // schema, see [Configure audit logging] + // + // [Configure audit logging]: https://docs.databricks.com/administration-guide/account-settings/audit-logs.html + // [View billable usage]: https://docs.databricks.com/administration-guide/account-settings/usage.html + // [audit log delivery]: 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 + LogType LogDeliveryType `json:"log_type,omitempty"` + // The file type of log delivery. * If `log_type` is `BILLABLE_USAGE`, this + // value must be `CSV`. Only the CSV (comma-separated values) format is + // supported. For the schema, see the [View billable usage] * If `log_type` is + // `AUDIT_LOGS`, this value must be `JSON`. Only the JSON (JavaScript Object + // Notation) format is supported. For the schema, see the [Configuring audit + // logs]. + // + // [Configuring audit logs]: https://docs.databricks.com/administration-guide/account-settings/audit-logs.html + // [View billable usage]: https://docs.databricks.com/administration-guide/account-settings/usage.html + OutputFormat LogDeliveryOutputFormat `json:"output_format,omitempty"` + // Status of log delivery configuration. Set to `ENABLED` (enabled) or + // `DISABLED` (disabled). Defaults to `ENABLED`. You can [enable or disable the + // configuration](#operation/patch-log-delivery-config-status) later. Deletion + // of a configuration is not supported, so disable a log delivery configuration + // that is no longer needed. + Status LogDeliveryConfigStatus `json:"status,omitempty"` + // The ID for a method:storage/create that represents the S3 bucket with bucket + // policy as described in the main billable usage documentation page. See + // [Configure billable usage delivery]. + // + // [Configure billable usage delivery]: https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html + StorageConfigurationId *string `json:"storage_configuration_id,omitempty"` + // Time in epoch milliseconds when the log delivery configuration was updated. + UpdateTime *int64 `json:"update_time,omitempty"` + // Optional filter that specifies workspace IDs to deliver logs for. By default + // the workspace filter is empty and log delivery applies at the account level, + // delivering workspace-level logs for all workspaces in your account, plus + // account level logs. You can optionally set this field to an array of + // workspace IDs (each one is an `int64`) to which log delivery should apply, in + // which case only workspace-level logs relating to the specified workspaces are + // delivered. If you plan to use different log delivery configurations for + // different workspaces, set this field explicitly. Be aware that delivery + // configurations mentioning specific workspaces won't apply to new workspaces + // created in the future, and delivery won't include account level logs. For + // some types of deployments there is only one workspace per + // account ID, so this field is unnecessary. + WorkspaceIdsFilter []int64 `json:"workspace_ids_filter,omitempty"` +} + +// * Properties of the new log delivery configuration.. +type CreateLogDeliveryConfigurationRequest struct { + LogDeliveryConfiguration *CreateLogDeliveryConfigurationParams `json:"log_delivery_configuration,omitempty"` +} + +type CreateLogDeliveryConfigurationResponse struct { + // The created log delivery configuration + LogDeliveryConfiguration *LogDeliveryConfiguration `json:"log_delivery_configuration,omitempty"` +} + +type GetLogDeliveryConfigurationResponse struct { + // The fetched log delivery configuration + LogDeliveryConfiguration *LogDeliveryConfiguration `json:"log_delivery_configuration,omitempty"` +} + +// * List Log Delivery Configuration. +type ListLogDeliveryConfigurationRequest struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + // The Credentials id to filter the search results with + CredentialsId *string `json:"credentials_id,omitempty"` + // A page token received from a previous get all budget configurations call. + // This token can be used to retrieve the subsequent page. Requests first page + // if absent. + PageToken *string `json:"page_token,omitempty"` + // The log delivery status to filter the search results with + Status LogDeliveryConfigStatus `json:"status,omitempty"` + // The Storage Configuration id to filter the search results with + StorageConfigurationId *string `json:"storage_configuration_id,omitempty"` +} + +type ListLogDeliveryConfigurationResponse struct { + // Log delivery configurations were returned successfully. + LogDeliveryConfigurations []LogDeliveryConfiguration `json:"log_delivery_configurations,omitempty"` + // Token which can be sent as `page_token` to retrieve the next page of results. + // If this field is omitted, there are no subsequent budgets. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// * Log Delivery Configuration. +type LogDeliveryConfiguration struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + // The unique UUID of log delivery configuration + ConfigId *string `json:"config_id,omitempty"` + // The optional human-readable name of the log delivery configuration. Defaults + // to empty. + ConfigName *string `json:"config_name,omitempty"` + // Time in epoch milliseconds when the log delivery configuration was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // The ID for a method:credentials/create that represents the AWS IAM role with + // policy and trust relationship as described in the main billable usage + // documentation page. See [Configure billable usage delivery]. + // + // [Configure billable usage delivery]: https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html + CredentialsId *string `json:"credentials_id,omitempty"` + // The optional delivery path prefix within Amazon S3 storage. Defaults to + // empty, which means that logs are delivered to the root of the bucket. This + // must be a valid S3 object key. This must not start or end with a slash + // character. + DeliveryPathPrefix *string `json:"delivery_path_prefix,omitempty"` + // This field applies only if log_type is BILLABLE_USAGE. This is the optional + // start month and year for delivery, specified in YYYY-MM format. Defaults to + // current year and month. BILLABLE_USAGE logs are not available for usage + // before March 2019 (2019-03). + DeliveryStartTime *string `json:"delivery_start_time,omitempty"` + // The LogDeliveryStatus of this log delivery configuration + LogDeliveryStatus *LogDeliveryStatus `json:"log_delivery_status,omitempty"` + // Log delivery type. Supported values are: * `BILLABLE_USAGE` — Configure + // [billable usage log delivery]. For the CSV schema, see the [View billable + // usage]. * `AUDIT_LOGS` — Configure [audit log delivery]. For the JSON + // schema, see [Configure audit logging] + // + // [Configure audit logging]: https://docs.databricks.com/administration-guide/account-settings/audit-logs.html + // [View billable usage]: https://docs.databricks.com/administration-guide/account-settings/usage.html + // [audit log delivery]: 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 + LogType LogDeliveryType `json:"log_type,omitempty"` + // The file type of log delivery. * If `log_type` is `BILLABLE_USAGE`, this + // value must be `CSV`. Only the CSV (comma-separated values) format is + // supported. For the schema, see the [View billable usage] * If `log_type` is + // `AUDIT_LOGS`, this value must be `JSON`. Only the JSON (JavaScript Object + // Notation) format is supported. For the schema, see the [Configuring audit + // logs]. + // + // [Configuring audit logs]: https://docs.databricks.com/administration-guide/account-settings/audit-logs.html + // [View billable usage]: https://docs.databricks.com/administration-guide/account-settings/usage.html + OutputFormat LogDeliveryOutputFormat `json:"output_format,omitempty"` + // Status of log delivery configuration. Set to `ENABLED` (enabled) or + // `DISABLED` (disabled). Defaults to `ENABLED`. You can [enable or disable the + // configuration](#operation/patch-log-delivery-config-status) later. Deletion + // of a configuration is not supported, so disable a log delivery configuration + // that is no longer needed. + Status LogDeliveryConfigStatus `json:"status,omitempty"` + // The ID for a method:storage/create that represents the S3 bucket with bucket + // policy as described in the main billable usage documentation page. See + // [Configure billable usage delivery]. + // + // [Configure billable usage delivery]: https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html + StorageConfigurationId *string `json:"storage_configuration_id,omitempty"` + // Time in epoch milliseconds when the log delivery configuration was updated. + UpdateTime *int64 `json:"update_time,omitempty"` + // Optional filter that specifies workspace IDs to deliver logs for. By default + // the workspace filter is empty and log delivery applies at the account level, + // delivering workspace-level logs for all workspaces in your account, plus + // account level logs. You can optionally set this field to an array of + // workspace IDs (each one is an `int64`) to which log delivery should apply, in + // which case only workspace-level logs relating to the specified workspaces are + // delivered. If you plan to use different log delivery configurations for + // different workspaces, set this field explicitly. Be aware that delivery + // configurations mentioning specific workspaces won't apply to new workspaces + // created in the future, and delivery won't include account level logs. For + // some types of deployments there is only one workspace per + // account ID, so this field is unnecessary. + WorkspaceIdsFilter []int64 `json:"workspace_ids_filter,omitempty"` +} + +type LogDeliveryStatus struct { + // The UTC time for the latest log delivery attempt. + LastAttemptTime *string `json:"last_attempt_time,omitempty"` + // The UTC time for the latest successful log delivery. + LastSuccessfulAttemptTime *string `json:"last_successful_attempt_time,omitempty"` + // Informative message about the latest log delivery attempt. If the log + // delivery fails with USER_FAILURE, error details will be provided for fixing + // misconfigurations in cloud permissions. + Message *string `json:"message,omitempty"` + // Enum that describes the status. Possible values are: * `CREATED`: There were + // no log delivery attempts since the config was created. * `SUCCEEDED`: The + // latest attempt of log delivery has succeeded completely. * `USER_FAILURE`: + // The latest attempt of log delivery failed because of misconfiguration of + // customer provided permissions on role or storage. * `SYSTEM_FAILURE`: The + // latest attempt of log delivery failed because of an internal + // error. Contact support if it doesn't go away soon. * `NOT_FOUND`: The log + // delivery status as the configuration has been disabled since the release of + // this feature or there are no workspaces in the account. + Status LogDeliveryStatusEnum `json:"status,omitempty"` +} + +// * Update Log Delivery Configuration. +type UpdateLogDeliveryConfigurationRequest struct { + // account ID of any type. For non-E2 account types, get your + // account ID from the [Accounts Console]. + // + // [Accounts Console]: https://docs.databricks.com/administration-guide/account-settings/usage.html + AccountId *string `json:"account_id,omitempty"` + // The log delivery configuration id of customer + ConfigId *string `json:"config_id,omitempty"` + // Status of log delivery configuration. Set to `ENABLED` (enabled) or + // `DISABLED` (disabled). Defaults to `ENABLED`. You can [enable or disable the + // configuration](#operation/patch-log-delivery-config-status) later. Deletion + // of a configuration is not supported, so disable a log delivery configuration + // that is no longer needed. + Status LogDeliveryConfigStatus `json:"status,omitempty"` +} + +// CreateLogDeliveryConfigurationParamsToSDK converts the mirror to the sdk-go type. +func CreateLogDeliveryConfigurationParamsToSDK(w *CreateLogDeliveryConfigurationParams) (*sdk.CreateLogDeliveryConfigurationParams, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateLogDeliveryConfigurationParams{} + out.ConfigId = w.ConfigId + out.ConfigName = w.ConfigName + out.LogType = w.LogType + out.OutputFormat = w.OutputFormat + out.AccountId = w.AccountId + out.CredentialsId = w.CredentialsId + out.StorageConfigurationId = w.StorageConfigurationId + out.WorkspaceIdsFilter = w.WorkspaceIdsFilter + out.DeliveryPathPrefix = w.DeliveryPathPrefix + out.DeliveryStartTime = w.DeliveryStartTime + out.Status = w.Status + out.CreationTime = w.CreationTime + out.UpdateTime = w.UpdateTime + conv1, err := LogDeliveryStatusToSDK(w.LogDeliveryStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateLogDeliveryConfigurationParams.LogDeliveryStatus", err) + } + out.LogDeliveryStatus = conv1 + return out, nil +} + +// CreateLogDeliveryConfigurationParamsFromSDK converts the sdk-go type to the mirror. +func CreateLogDeliveryConfigurationParamsFromSDK(v *sdk.CreateLogDeliveryConfigurationParams) (*CreateLogDeliveryConfigurationParams, error) { + if v == nil { + return nil, nil + } + out := &CreateLogDeliveryConfigurationParams{} + out.ConfigId = v.ConfigId + out.ConfigName = v.ConfigName + out.LogType = v.LogType + out.OutputFormat = v.OutputFormat + out.AccountId = v.AccountId + out.CredentialsId = v.CredentialsId + out.StorageConfigurationId = v.StorageConfigurationId + out.WorkspaceIdsFilter = v.WorkspaceIdsFilter + out.DeliveryPathPrefix = v.DeliveryPathPrefix + out.DeliveryStartTime = v.DeliveryStartTime + out.Status = v.Status + out.CreationTime = v.CreationTime + out.UpdateTime = v.UpdateTime + conv2, err := LogDeliveryStatusFromSDK(v.LogDeliveryStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateLogDeliveryConfigurationParams.LogDeliveryStatus", err) + } + out.LogDeliveryStatus = conv2 + return out, nil +} + +// CreateLogDeliveryConfigurationRequestToSDK converts the mirror to the sdk-go type. +func CreateLogDeliveryConfigurationRequestToSDK(w *CreateLogDeliveryConfigurationRequest) (*sdk.CreateLogDeliveryConfigurationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateLogDeliveryConfigurationRequest{} + conv3, err := CreateLogDeliveryConfigurationParamsToSDK(w.LogDeliveryConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateLogDeliveryConfigurationRequest.LogDeliveryConfiguration", err) + } + out.LogDeliveryConfiguration = conv3 + return out, nil +} + +// CreateLogDeliveryConfigurationRequestFromSDK converts the sdk-go type to the mirror. +func CreateLogDeliveryConfigurationRequestFromSDK(v *sdk.CreateLogDeliveryConfigurationRequest) (*CreateLogDeliveryConfigurationRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateLogDeliveryConfigurationRequest{} + conv4, err := CreateLogDeliveryConfigurationParamsFromSDK(v.LogDeliveryConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateLogDeliveryConfigurationRequest.LogDeliveryConfiguration", err) + } + out.LogDeliveryConfiguration = conv4 + return out, nil +} + +// CreateLogDeliveryConfigurationResponseToSDK converts the mirror to the sdk-go type. +func CreateLogDeliveryConfigurationResponseToSDK(w *CreateLogDeliveryConfigurationResponse) (*sdk.CreateLogDeliveryConfigurationResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateLogDeliveryConfigurationResponse{} + conv5, err := LogDeliveryConfigurationToSDK(w.LogDeliveryConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateLogDeliveryConfigurationResponse.LogDeliveryConfiguration", err) + } + out.LogDeliveryConfiguration = conv5 + return out, nil +} + +// CreateLogDeliveryConfigurationResponseFromSDK converts the sdk-go type to the mirror. +func CreateLogDeliveryConfigurationResponseFromSDK(v *sdk.CreateLogDeliveryConfigurationResponse) (*CreateLogDeliveryConfigurationResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateLogDeliveryConfigurationResponse{} + conv6, err := LogDeliveryConfigurationFromSDK(v.LogDeliveryConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateLogDeliveryConfigurationResponse.LogDeliveryConfiguration", err) + } + out.LogDeliveryConfiguration = conv6 + return out, nil +} + +// GetLogDeliveryConfigurationResponseToSDK converts the mirror to the sdk-go type. +func GetLogDeliveryConfigurationResponseToSDK(w *GetLogDeliveryConfigurationResponse) (*sdk.GetLogDeliveryConfigurationResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetLogDeliveryConfigurationResponse{} + conv7, err := LogDeliveryConfigurationToSDK(w.LogDeliveryConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetLogDeliveryConfigurationResponse.LogDeliveryConfiguration", err) + } + out.LogDeliveryConfiguration = conv7 + return out, nil +} + +// GetLogDeliveryConfigurationResponseFromSDK converts the sdk-go type to the mirror. +func GetLogDeliveryConfigurationResponseFromSDK(v *sdk.GetLogDeliveryConfigurationResponse) (*GetLogDeliveryConfigurationResponse, error) { + if v == nil { + return nil, nil + } + out := &GetLogDeliveryConfigurationResponse{} + conv8, err := LogDeliveryConfigurationFromSDK(v.LogDeliveryConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetLogDeliveryConfigurationResponse.LogDeliveryConfiguration", err) + } + out.LogDeliveryConfiguration = conv8 + return out, nil +} + +// ListLogDeliveryConfigurationRequestToSDK converts the mirror to the sdk-go type. +func ListLogDeliveryConfigurationRequestToSDK(w *ListLogDeliveryConfigurationRequest) (*sdk.ListLogDeliveryConfigurationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListLogDeliveryConfigurationRequest{} + out.AccountId = w.AccountId + out.CredentialsId = w.CredentialsId + out.StorageConfigurationId = w.StorageConfigurationId + out.Status = w.Status + out.PageToken = w.PageToken + return out, nil +} + +// ListLogDeliveryConfigurationRequestFromSDK converts the sdk-go type to the mirror. +func ListLogDeliveryConfigurationRequestFromSDK(v *sdk.ListLogDeliveryConfigurationRequest) (*ListLogDeliveryConfigurationRequest, error) { + if v == nil { + return nil, nil + } + out := &ListLogDeliveryConfigurationRequest{} + out.AccountId = v.AccountId + out.CredentialsId = v.CredentialsId + out.StorageConfigurationId = v.StorageConfigurationId + out.Status = v.Status + out.PageToken = v.PageToken + return out, nil +} + +// ListLogDeliveryConfigurationResponseToSDK converts the mirror to the sdk-go type. +func ListLogDeliveryConfigurationResponseToSDK(w *ListLogDeliveryConfigurationResponse) (*sdk.ListLogDeliveryConfigurationResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListLogDeliveryConfigurationResponse{} + conv9, err := convertSlice(w.LogDeliveryConfigurations, LogDeliveryConfigurationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListLogDeliveryConfigurationResponse.LogDeliveryConfigurations", err) + } + out.LogDeliveryConfigurations = conv9 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListLogDeliveryConfigurationResponseFromSDK converts the sdk-go type to the mirror. +func ListLogDeliveryConfigurationResponseFromSDK(v *sdk.ListLogDeliveryConfigurationResponse) (*ListLogDeliveryConfigurationResponse, error) { + if v == nil { + return nil, nil + } + out := &ListLogDeliveryConfigurationResponse{} + conv10, err := convertSlice(v.LogDeliveryConfigurations, LogDeliveryConfigurationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListLogDeliveryConfigurationResponse.LogDeliveryConfigurations", err) + } + out.LogDeliveryConfigurations = conv10 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// LogDeliveryConfigurationToSDK converts the mirror to the sdk-go type. +func LogDeliveryConfigurationToSDK(w *LogDeliveryConfiguration) (*sdk.LogDeliveryConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.LogDeliveryConfiguration{} + out.ConfigId = w.ConfigId + out.ConfigName = w.ConfigName + out.LogType = w.LogType + out.OutputFormat = w.OutputFormat + out.AccountId = w.AccountId + out.CredentialsId = w.CredentialsId + out.StorageConfigurationId = w.StorageConfigurationId + out.WorkspaceIdsFilter = w.WorkspaceIdsFilter + out.DeliveryPathPrefix = w.DeliveryPathPrefix + out.DeliveryStartTime = w.DeliveryStartTime + out.Status = w.Status + out.CreationTime = w.CreationTime + out.UpdateTime = w.UpdateTime + conv11, err := LogDeliveryStatusToSDK(w.LogDeliveryStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogDeliveryConfiguration.LogDeliveryStatus", err) + } + out.LogDeliveryStatus = conv11 + return out, nil +} + +// LogDeliveryConfigurationFromSDK converts the sdk-go type to the mirror. +func LogDeliveryConfigurationFromSDK(v *sdk.LogDeliveryConfiguration) (*LogDeliveryConfiguration, error) { + if v == nil { + return nil, nil + } + out := &LogDeliveryConfiguration{} + out.ConfigId = v.ConfigId + out.ConfigName = v.ConfigName + out.LogType = v.LogType + out.OutputFormat = v.OutputFormat + out.AccountId = v.AccountId + out.CredentialsId = v.CredentialsId + out.StorageConfigurationId = v.StorageConfigurationId + out.WorkspaceIdsFilter = v.WorkspaceIdsFilter + out.DeliveryPathPrefix = v.DeliveryPathPrefix + out.DeliveryStartTime = v.DeliveryStartTime + out.Status = v.Status + out.CreationTime = v.CreationTime + out.UpdateTime = v.UpdateTime + conv12, err := LogDeliveryStatusFromSDK(v.LogDeliveryStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LogDeliveryConfiguration.LogDeliveryStatus", err) + } + out.LogDeliveryStatus = conv12 + return out, nil +} + +// LogDeliveryStatusToSDK converts the mirror to the sdk-go type. +func LogDeliveryStatusToSDK(w *LogDeliveryStatus) (*sdk.LogDeliveryStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.LogDeliveryStatus{} + out.Status = w.Status + out.LastAttemptTime = w.LastAttemptTime + out.LastSuccessfulAttemptTime = w.LastSuccessfulAttemptTime + out.Message = w.Message + return out, nil +} + +// LogDeliveryStatusFromSDK converts the sdk-go type to the mirror. +func LogDeliveryStatusFromSDK(v *sdk.LogDeliveryStatus) (*LogDeliveryStatus, error) { + if v == nil { + return nil, nil + } + out := &LogDeliveryStatus{} + out.Status = v.Status + out.LastAttemptTime = v.LastAttemptTime + out.LastSuccessfulAttemptTime = v.LastSuccessfulAttemptTime + out.Message = v.Message + return out, nil +} + +// UpdateLogDeliveryConfigurationRequestToSDK converts the mirror to the sdk-go type. +func UpdateLogDeliveryConfigurationRequestToSDK(w *UpdateLogDeliveryConfigurationRequest) (*sdk.UpdateLogDeliveryConfigurationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateLogDeliveryConfigurationRequest{} + out.ConfigId = w.ConfigId + out.AccountId = w.AccountId + out.Status = w.Status + return out, nil +} + +// UpdateLogDeliveryConfigurationRequestFromSDK converts the sdk-go type to the mirror. +func UpdateLogDeliveryConfigurationRequestFromSDK(v *sdk.UpdateLogDeliveryConfigurationRequest) (*UpdateLogDeliveryConfigurationRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateLogDeliveryConfigurationRequest{} + out.ConfigId = v.ConfigId + out.AccountId = v.AccountId + out.Status = v.Status + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/marketplaces/v1/types.generated.go b/libs/sdktypes/marketplaces/v1/types.generated.go new file mode 100644 index 00000000000..7aedd2ea872 --- /dev/null +++ b/libs/sdktypes/marketplaces/v1/types.generated.go @@ -0,0 +1,3852 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/marketplaces/v1. DO NOT EDIT. + +package marketplaces + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/marketplaces/v1" +) + +type ( + AssetType = sdk.AssetType + Category = sdk.Category + Cost = sdk.Cost + DataRefresh = sdk.DataRefresh + DeltaSharingRecipientType = sdk.DeltaSharingRecipientType + ExchangeFilterType = sdk.ExchangeFilterType + FileParentType = sdk.FileParentType + FileStatus = sdk.FileStatus + FulfillmentType = sdk.FulfillmentType + InstallationStatus = sdk.InstallationStatus + ListingShareType = sdk.ListingShareType + ListingStatus = sdk.ListingStatus + ListingTagType = sdk.ListingTagType + ListingType = sdk.ListingType + MarketplaceFileType = sdk.MarketplaceFileType + PersonalizationRequestStatus = sdk.PersonalizationRequestStatus + Visibility = sdk.Visibility +) + +const ( + AssetType_Unspecified = sdk.AssetType_Unspecified + AssetType_AssetTypeGitRepo = sdk.AssetType_AssetTypeGitRepo + AssetType_AssetTypeDataTable = sdk.AssetType_AssetTypeDataTable + AssetType_AssetTypeModel = sdk.AssetType_AssetTypeModel + AssetType_AssetTypeNotebook = sdk.AssetType_AssetTypeNotebook + AssetType_AssetTypeMedia = sdk.AssetType_AssetTypeMedia + AssetType_AssetTypePartnerIntegration = sdk.AssetType_AssetTypePartnerIntegration + AssetType_AssetTypeApp = sdk.AssetType_AssetTypeApp + AssetType_AssetTypeMcp = sdk.AssetType_AssetTypeMcp + Category_Unspecified = sdk.Category_Unspecified + Category_AdvertisingAndMarketing = sdk.Category_AdvertisingAndMarketing + Category_ClimateAndEnvironment = sdk.Category_ClimateAndEnvironment + Category_Commerce = sdk.Category_Commerce + Category_Demographics = sdk.Category_Demographics + Category_Economics = sdk.Category_Economics + Category_Education = sdk.Category_Education + Category_Energy = sdk.Category_Energy + Category_Financial = sdk.Category_Financial + Category_Gaming = sdk.Category_Gaming + Category_Geospatial = sdk.Category_Geospatial + Category_Health = sdk.Category_Health + Category_LookupTables = sdk.Category_LookupTables + Category_Manufacturing = sdk.Category_Manufacturing + Category_Media = sdk.Category_Media + Category_Other = sdk.Category_Other + Category_PublicSector = sdk.Category_PublicSector + Category_Retail = sdk.Category_Retail + Category_Security = sdk.Category_Security + Category_ScienceAndResearch = sdk.Category_ScienceAndResearch + Category_Sports = sdk.Category_Sports + Category_TransportationAndLogistics = sdk.Category_TransportationAndLogistics + Category_TravelAndTourism = sdk.Category_TravelAndTourism + Cost_Unspecified = sdk.Cost_Unspecified + Cost_Free = sdk.Cost_Free + Cost_Paid = sdk.Cost_Paid + DataRefresh_Unspecified = sdk.DataRefresh_Unspecified + DataRefresh_None = sdk.DataRefresh_None + DataRefresh_Second = sdk.DataRefresh_Second + DataRefresh_Minute = sdk.DataRefresh_Minute + DataRefresh_Hourly = sdk.DataRefresh_Hourly + DataRefresh_Daily = sdk.DataRefresh_Daily + DataRefresh_Weekly = sdk.DataRefresh_Weekly + DataRefresh_Monthly = sdk.DataRefresh_Monthly + DataRefresh_Quarterly = sdk.DataRefresh_Quarterly + DataRefresh_Yearly = sdk.DataRefresh_Yearly + DeltaSharingRecipientType_Unspecified = sdk.DeltaSharingRecipientType_Unspecified + DeltaSharingRecipientType_DeltaSharingRecipientTypeDatabricks = sdk.DeltaSharingRecipientType_DeltaSharingRecipientTypeDatabricks + DeltaSharingRecipientType_DeltaSharingRecipientTypeOpen = sdk.DeltaSharingRecipientType_DeltaSharingRecipientTypeOpen + ExchangeFilterType_Unspecified = sdk.ExchangeFilterType_Unspecified + ExchangeFilterType_GlobalMetastoreId = sdk.ExchangeFilterType_GlobalMetastoreId + FileParentType_Unspecified = sdk.FileParentType_Unspecified + FileParentType_Provider = sdk.FileParentType_Provider + FileParentType_Listing = sdk.FileParentType_Listing + FileParentType_ListingResource = sdk.FileParentType_ListingResource + FileStatus_Unspecified = sdk.FileStatus_Unspecified + FileStatus_FileStatusPublished = sdk.FileStatus_FileStatusPublished + FileStatus_FileStatusStaging = sdk.FileStatus_FileStatusStaging + FileStatus_FileStatusSanitizing = sdk.FileStatus_FileStatusSanitizing + FileStatus_FileStatusSanitizationFailed = sdk.FileStatus_FileStatusSanitizationFailed + FulfillmentType_Unspecified = sdk.FulfillmentType_Unspecified + FulfillmentType_RequestAccess = sdk.FulfillmentType_RequestAccess + FulfillmentType_Install = sdk.FulfillmentType_Install + InstallationStatus_Unspecified = sdk.InstallationStatus_Unspecified + InstallationStatus_Installed = sdk.InstallationStatus_Installed + InstallationStatus_Failed = sdk.InstallationStatus_Failed + ListingShareType_Unspecified = sdk.ListingShareType_Unspecified + ListingShareType_Sample = sdk.ListingShareType_Sample + ListingShareType_Full = sdk.ListingShareType_Full + ListingStatus_Unspecified = sdk.ListingStatus_Unspecified + ListingStatus_Draft = sdk.ListingStatus_Draft + ListingStatus_Pending = sdk.ListingStatus_Pending + ListingStatus_Published = sdk.ListingStatus_Published + ListingStatus_Suspended = sdk.ListingStatus_Suspended + ListingTagType_Unspecified = sdk.ListingTagType_Unspecified + ListingTagType_ListingTagTypeLanguage = sdk.ListingTagType_ListingTagTypeLanguage + ListingTagType_ListingTagTypeTask = sdk.ListingTagType_ListingTagTypeTask + ListingType_Unspecified = sdk.ListingType_Unspecified + ListingType_Standard = sdk.ListingType_Standard + ListingType_Personalized = sdk.ListingType_Personalized + MarketplaceFileType_Unspecified = sdk.MarketplaceFileType_Unspecified + MarketplaceFileType_ProviderIcon = sdk.MarketplaceFileType_ProviderIcon + MarketplaceFileType_EmbeddedNotebook = sdk.MarketplaceFileType_EmbeddedNotebook + MarketplaceFileType_App = sdk.MarketplaceFileType_App + PersonalizationRequestStatus_Unspecified = sdk.PersonalizationRequestStatus_Unspecified + PersonalizationRequestStatus_New = sdk.PersonalizationRequestStatus_New + PersonalizationRequestStatus_RequestPending = sdk.PersonalizationRequestStatus_RequestPending + PersonalizationRequestStatus_Fulfilled = sdk.PersonalizationRequestStatus_Fulfilled + PersonalizationRequestStatus_Denied = sdk.PersonalizationRequestStatus_Denied + Visibility_Unspecified = sdk.Visibility_Unspecified + Visibility_Public = sdk.Visibility_Public + Visibility_Private = sdk.Visibility_Private +) + +type AddExchangeForListingRequest struct { + ExchangeId *string `json:"exchange_id,omitempty"` + ListingId *string `json:"listing_id,omitempty"` +} + +type AddExchangeForListingResponse struct { + ExchangeForListing *ExchangeListing `json:"exchange_for_listing,omitempty"` +} + +type BatchGetListingsRequest struct { + Ids []string `json:"ids,omitempty"` +} + +type BatchGetListingsResponse struct { + Listings []Listing `json:"listings,omitempty"` +} + +type BatchGetProvidersRequest struct { + Ids []string `json:"ids,omitempty"` +} + +type BatchGetProvidersResponse struct { + Providers []ProviderInfo `json:"providers,omitempty"` +} + +type ConsumerTerms struct { + Version *string `json:"version,omitempty"` +} + +// contact info for the consumer requesting data or performing a listing +// installation. +type ContactInfo struct { + Company *string `json:"company,omitempty"` + Email *string `json:"email,omitempty"` + FirstName *string `json:"first_name,omitempty"` + LastName *string `json:"last_name,omitempty"` +} + +type CreateExchangeFilterRequest struct { + Filter *ExchangeFilter `json:"filter,omitempty"` +} + +type CreateExchangeFilterResponse struct { + FilterId *string `json:"filter_id,omitempty"` +} + +type CreateExchangeRequest struct { + Exchange *Exchange `json:"exchange,omitempty"` +} + +type CreateExchangeResponse struct { + ExchangeId *string `json:"exchange_id,omitempty"` +} + +type CreateFileRequest struct { + DisplayName *string `json:"display_name,omitempty"` + FileParent *FileParent `json:"file_parent,omitempty"` + MarketplaceFileType MarketplaceFileType `json:"marketplace_file_type,omitempty"` + MimeType *string `json:"mime_type,omitempty"` +} + +type CreateFileResponse struct { + FileInfo *FileInfo `json:"file_info,omitempty"` + // Pre-signed POST URL to blob storage + UploadUrl *string `json:"upload_url,omitempty"` +} + +type CreateInstallationRequest struct { + AcceptedConsumerTerms *ConsumerTerms `json:"accepted_consumer_terms,omitempty"` + CatalogName *string `json:"catalog_name,omitempty"` + ListingId *string `json:"listing_id,omitempty"` + RecipientType DeltaSharingRecipientType `json:"recipient_type,omitempty"` + // for git repo installations + RepoDetail *RepoInstallation `json:"repo_detail,omitempty"` + ShareName *string `json:"share_name,omitempty"` +} + +type CreateInstallationResponse struct { + Installation *InstallationDetail `json:"installation,omitempty"` +} + +type CreateListingRequest struct { + Listing *Listing `json:"listing,omitempty"` +} + +type CreateListingResponse struct { + ListingId *string `json:"listing_id,omitempty"` +} + +// Data request messages also creates a lead (maybe). +type CreatePersonalizationRequest struct { + AcceptedConsumerTerms *ConsumerTerms `json:"accepted_consumer_terms,omitempty"` + Comment *string `json:"comment,omitempty"` + Company *string `json:"company,omitempty"` + FirstName *string `json:"first_name,omitempty"` + IntendedUse *string `json:"intended_use,omitempty"` + IsFromLighthouse *bool `json:"is_from_lighthouse,omitempty"` + LastName *string `json:"last_name,omitempty"` + ListingId *string `json:"listing_id,omitempty"` + RecipientType DeltaSharingRecipientType `json:"recipient_type,omitempty"` +} + +type CreatePersonalizationResponse struct { + Id *string `json:"id,omitempty"` +} + +type CreateProviderAnalyticsDashboardRequest struct { +} + +type CreateProviderAnalyticsDashboardResponse struct { + Id *string `json:"id,omitempty"` +} + +type CreateProviderRequest struct { + Provider *ProviderInfo `json:"provider,omitempty"` +} + +type CreateProviderResponse struct { + Id *string `json:"id,omitempty"` +} + +type DataRefreshInfo struct { + Interval *int64 `json:"interval,omitempty"` + Unit DataRefresh `json:"unit,omitempty"` +} + +type Exchange struct { + Comment *string `json:"comment,omitempty"` + CreatedAt *int64 `json:"created_at,omitempty"` + CreatedBy *string `json:"created_by,omitempty"` + Filters []ExchangeFilter `json:"filters,omitempty"` + Id *string `json:"id,omitempty"` + LinkedListings []ExchangeListing `json:"linked_listings,omitempty"` + Name *string `json:"name,omitempty"` + UpdatedAt *int64 `json:"updated_at,omitempty"` + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type ExchangeFilter struct { + CreatedAt *int64 `json:"created_at,omitempty"` + CreatedBy *string `json:"created_by,omitempty"` + ExchangeId *string `json:"exchange_id,omitempty"` + FilterType ExchangeFilterType `json:"filter_type,omitempty"` + FilterValue *string `json:"filter_value,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + UpdatedAt *int64 `json:"updated_at,omitempty"` + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type ExchangeListing struct { + CreatedAt *int64 `json:"created_at,omitempty"` + CreatedBy *string `json:"created_by,omitempty"` + ExchangeId *string `json:"exchange_id,omitempty"` + ExchangeName *string `json:"exchange_name,omitempty"` + Id *string `json:"id,omitempty"` + ListingId *string `json:"listing_id,omitempty"` + ListingName *string `json:"listing_name,omitempty"` +} + +type FileInfo struct { + CreatedAt *int64 `json:"created_at,omitempty"` + // Name displayed to users for applicable files, e.g. embedded notebooks + DisplayName *string `json:"display_name,omitempty"` + DownloadLink *string `json:"download_link,omitempty"` + FileParent *FileParent `json:"file_parent,omitempty"` + Id *string `json:"id,omitempty"` + MarketplaceFileType MarketplaceFileType `json:"marketplace_file_type,omitempty"` + MimeType *string `json:"mime_type,omitempty"` + Status FileStatus `json:"status,omitempty"` + // Populated if status is in a failed state with more information on reason for + // the failure. + StatusMessage *string `json:"status_message,omitempty"` + UpdatedAt *int64 `json:"updated_at,omitempty"` +} + +type FileParent struct { + FileParentType FileParentType `json:"file_parent_type,omitempty"` + ParentId *string `json:"parent_id,omitempty"` +} + +type GetAllPersonalizationRequestsForConsumerResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + PersonalizationRequests []PersonalizationRequest `json:"personalization_requests,omitempty"` +} + +type GetExchangeResponse struct { + Exchange *Exchange `json:"exchange,omitempty"` +} + +type GetFileResponse struct { + FileInfo *FileInfo `json:"file_info,omitempty"` +} + +type GetInstallationDetailsRequest struct { + ListingId *string `json:"listing_id,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type GetLatestVersionProviderAnalyticsDashboardResponse struct { + // version here is latest logical version of the dashboard template + Version *int64 `json:"version,omitempty"` +} + +type GetListingContentMetadataRequest struct { + ListingId *string `json:"listing_id,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type GetListingContentMetadataResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + SharedDataObjects []SharedDataObject `json:"shared_data_objects,omitempty"` +} + +type GetListingResponse struct { + Listing *Listing `json:"listing,omitempty"` +} + +type GetListingsResponse struct { + Listings []Listing `json:"listings,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type GetPersonalizationRequestsForConsumerResponse struct { + PersonalizationRequests []PersonalizationRequest `json:"personalization_requests,omitempty"` +} + +type GetPersonalizationRequestsForProviderRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type GetPersonalizationRequestsForProviderResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + PersonalizationRequests []PersonalizationRequest `json:"personalization_requests,omitempty"` +} + +type GetProviderResponse struct { + Provider *ProviderInfo `json:"provider,omitempty"` +} + +type GetPublishedListingForConsumerResponse struct { + Listing *Listing `json:"listing,omitempty"` +} + +type GetPublishedListingsForConsumerResponse struct { + Listings []Listing `json:"listings,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type GetPublishedProviderForConsumerResponse struct { + Provider *ProviderInfo `json:"provider,omitempty"` +} + +type InstallationDetail struct { + CatalogName *string `json:"catalog_name,omitempty"` + ErrorMessage *string `json:"error_message,omitempty"` + Id *string `json:"id,omitempty"` + InstalledOn *int64 `json:"installed_on,omitempty"` + ListingId *string `json:"listing_id,omitempty"` + ListingName *string `json:"listing_name,omitempty"` + RecipientType DeltaSharingRecipientType `json:"recipient_type,omitempty"` + RepoName *string `json:"repo_name,omitempty"` + RepoPath *string `json:"repo_path,omitempty"` + ShareName *string `json:"share_name,omitempty"` + Status InstallationStatus `json:"status,omitempty"` + TokenDetail *TokenDetail `json:"token_detail,omitempty"` + Tokens []TokenInfo `json:"tokens,omitempty"` +} + +type ListAllInstallationsResponse struct { + Installations []InstallationDetail `json:"installations,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListExchangeFiltersRequest struct { + ExchangeId *string `json:"exchange_id,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListExchangeFiltersResponse struct { + Filters []ExchangeFilter `json:"filters,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListExchangesForListingRequest struct { + ListingId *string `json:"listing_id,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListExchangesForListingResponse struct { + ExchangeListing []ExchangeListing `json:"exchange_listing,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListExchangesRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListExchangesResponse struct { + Exchanges []Exchange `json:"exchanges,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListFilesRequest struct { + FileParent *FileParent `json:"file_parent,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListFilesResponse struct { + FileInfos []FileInfo `json:"file_infos,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListFulfillmentsResponse struct { + Fulfillments []ListingFulfillment `json:"fulfillments,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListInstallationsRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListInstallationsResponse struct { + Installations []InstallationDetail `json:"installations,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListListingFulfillmentsRequest struct { + ListingId *string `json:"listing_id,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListListingsForExchangeRequest struct { + ExchangeId *string `json:"exchange_id,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListListingsForExchangeResponse struct { + ExchangeListings []ExchangeListing `json:"exchange_listings,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListListingsRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListPersonalizationRequestsForConsumerRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListProviderAnalyticsDashboardResponse struct { + // dashboard_id will be used to open Lakeview dashboard. + DashboardId *string `json:"dashboard_id,omitempty"` + Id *string `json:"id,omitempty"` + Version *int64 `json:"version,omitempty"` +} + +type ListProvidersRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListProvidersResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + Providers []ProviderInfo `json:"providers,omitempty"` +} + +// Listing messages. +type ListPublishedListingsForConsumerRequest struct { + // Matches any of the following asset types + Assets []AssetType `json:"assets,omitempty"` + // Matches any of the following categories + Categories []Category `json:"categories,omitempty"` + // Filters each listing based on if it is free. + IsFree *bool `json:"is_free,omitempty"` + // Filters each listing based on if it is a private exchange. + IsPrivateExchange *bool `json:"is_private_exchange,omitempty"` + // Filters each listing based on whether it is a staff pick. + IsStaffPick *bool `json:"is_staff_pick,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` + // Matches any of the following provider ids + ProviderIds []string `json:"provider_ids,omitempty"` + // Matches listings with this tag + Tags *ListingTag `json:"tags,omitempty"` +} + +type ListPublishedProvidersForConsumerRequest struct { + IsFeatured *bool `json:"is_featured,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListPublishedProvidersForConsumerResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + Providers []ProviderInfo `json:"providers,omitempty"` +} + +type Listing struct { + Detail *ListingDetail `json:"detail,omitempty"` + Id *string `json:"id,omitempty"` + Summary *ListingSummary `json:"summary,omitempty"` +} + +type ListingDetail struct { + // Type of assets included in the listing. eg. GIT_REPO, DATA_TABLE, MODEL, + // NOTEBOOK + Assets []AssetType `json:"assets,omitempty"` + // The ending date timestamp for when the data spans + CollectionDateEnd *int64 `json:"collection_date_end,omitempty"` + // The starting date timestamp for when the data spans + CollectionDateStart *int64 `json:"collection_date_start,omitempty"` + // Smallest unit of time in the dataset + CollectionGranularity *DataRefreshInfo `json:"collection_granularity,omitempty"` + // Whether the dataset is free or paid + Cost Cost `json:"cost,omitempty"` + // Where/how the data is sourced + DataSource *string `json:"data_source,omitempty"` + Description *string `json:"description,omitempty"` + DocumentationLink *string `json:"documentation_link,omitempty"` + EmbeddedNotebookFileInfos []FileInfo `json:"embedded_notebook_file_infos,omitempty"` + FileIds []string `json:"file_ids,omitempty"` + // Which geo region the listing data is collected from + GeographicalCoverage *string `json:"geographical_coverage,omitempty"` + // ID 20, 21 removed don't use License of the data asset - Required for listings + // with model based assets + License *string `json:"license,omitempty"` + // What the pricing model is (e.g. paid, subscription, paid upfront); should + // only be present if cost is paid + PricingModel *string `json:"pricing_model,omitempty"` + PrivacyPolicyLink *string `json:"privacy_policy_link,omitempty"` + // size of the dataset in GB + Size *float64 `json:"size,omitempty"` + SupportLink *string `json:"support_link,omitempty"` + // Listing tags - Simple key value pair to annotate listings. When should I use + // tags vs dedicated fields? Using tags avoids the need to add new columns in + // the database for new annotations. However, this should be used sparingly + // since tags are stored as key value pair. Use tags only: 1. If the field is + // optional and won't need to have NOT NULL integrity check 2. The value is + // fairly fixed, static and low cardinality (eg. enums). 3. The value won't be + // used in filters or joins with other tables. + Tags []ListingTag `json:"tags,omitempty"` + TermsOfService *string `json:"terms_of_service,omitempty"` + // How often data is updated + UpdateFrequency *DataRefreshInfo `json:"update_frequency,omitempty"` +} + +type ListingFulfillment struct { + FulfillmentType FulfillmentType `json:"fulfillment_type,omitempty"` + ListingId *string `json:"listing_id,omitempty"` + RecipientType DeltaSharingRecipientType `json:"recipient_type,omitempty"` + RepoInfo *RepoInfo `json:"repo_info,omitempty"` + ShareInfo *ShareInfo `json:"share_info,omitempty"` +} + +type ListingSetting struct { + Visibility Visibility `json:"visibility,omitempty"` +} + +type ListingSummary struct { + Categories []Category `json:"categories,omitempty"` + CreatedAt *int64 `json:"created_at,omitempty"` + CreatedBy *string `json:"created_by,omitempty"` + CreatedById *int64 `json:"created_by_id,omitempty"` + ExchangeIds []string `json:"exchange_ids,omitempty"` + // if a git repo is being created, a listing will be initialized with this field + // as opposed to a share + GitRepo *RepoInfo `json:"git_repo,omitempty"` + ListingType ListingType `json:"listingType,omitempty"` + Name *string `json:"name,omitempty"` + ProviderId *string `json:"provider_id,omitempty"` + ProviderRegion *RegionInfo `json:"provider_region,omitempty"` + PublishedAt *int64 `json:"published_at,omitempty"` + PublishedBy *string `json:"published_by,omitempty"` + Setting *ListingSetting `json:"setting,omitempty"` + Share *ShareInfo `json:"share,omitempty"` + Status ListingStatus `json:"status,omitempty"` + Subtitle *string `json:"subtitle,omitempty"` + UpdatedAt *int64 `json:"updated_at,omitempty"` + UpdatedBy *string `json:"updated_by,omitempty"` + UpdatedById *int64 `json:"updated_by_id,omitempty"` +} + +type ListingTag struct { + // Tag name (enum) + TagName ListingTagType `json:"tag_name,omitempty"` + // String representation of the tag value. Values should be string literals (no + // complex types) + TagValues []string `json:"tag_values,omitempty"` +} + +type PersonalizationRequest struct { + Comment *string `json:"comment,omitempty"` + ConsumerRegion *RegionInfo `json:"consumer_region,omitempty"` + ContactInfo *ContactInfo `json:"contact_info,omitempty"` + CreatedAt *int64 `json:"created_at,omitempty"` + Id *string `json:"id,omitempty"` + IntendedUse *string `json:"intended_use,omitempty"` + IsFromLighthouse *bool `json:"is_from_lighthouse,omitempty"` + ListingId *string `json:"listing_id,omitempty"` + ListingName *string `json:"listing_name,omitempty"` + MetastoreId *string `json:"metastore_id,omitempty"` + ProviderId *string `json:"provider_id,omitempty"` + RecipientType DeltaSharingRecipientType `json:"recipient_type,omitempty"` + // Share information is required for data listings but should be empty/ignored + // for non-data listings (MCP and App). + Share *ShareInfo `json:"share,omitempty"` + Status PersonalizationRequestStatus `json:"status,omitempty"` + StatusMessage *string `json:"status_message,omitempty"` + UpdatedAt *int64 `json:"updated_at,omitempty"` +} + +type ProviderInfo struct { + BusinessContactEmail *string `json:"business_contact_email,omitempty"` + CompanyWebsiteLink *string `json:"company_website_link,omitempty"` + DarkModeIconFileId *string `json:"dark_mode_icon_file_id,omitempty"` + DarkModeIconFilePath *string `json:"dark_mode_icon_file_path,omitempty"` + Description *string `json:"description,omitempty"` + IconFileId *string `json:"icon_file_id,omitempty"` + IconFilePath *string `json:"icon_file_path,omitempty"` + Id *string `json:"id,omitempty"` + // is_featured is accessible by consumers only + IsFeatured *bool `json:"is_featured,omitempty"` + Name *string `json:"name,omitempty"` + PrivacyPolicyLink *string `json:"privacy_policy_link,omitempty"` + // published_by is only applicable to data aggregators (e.g. Crux) + PublishedBy *string `json:"published_by,omitempty"` + SupportContactEmail *string `json:"support_contact_email,omitempty"` + TermOfServiceLink *string `json:"term_of_service_link,omitempty"` +} + +type RegionInfo struct { + Cloud *string `json:"cloud,omitempty"` + Region *string `json:"region,omitempty"` +} + +type RepoInfo struct { + // the git repo url e.g. https://github.com/databrickslabs/dolly.git + GitRepoUrl *string `json:"git_repo_url,omitempty"` +} + +type RepoInstallation struct { + // the user-specified repo name for their installed git repo listing + RepoName *string `json:"repo_name,omitempty"` + // refers to the full url file path that navigates the user to the repo's + // entrypoint (e.g. a README.md file, or the repo file view in the unified UI) + // should just be a relative path + RepoPath *string `json:"repo_path,omitempty"` +} + +type SearchPublishedListingsForConsumerRequest struct { + // Matches any of the following asset types + Assets []AssetType `json:"assets,omitempty"` + // Matches any of the following categories + Categories []Category `json:"categories,omitempty"` + IsFree *bool `json:"is_free,omitempty"` + IsPrivateExchange *bool `json:"is_private_exchange,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` + // Matches any of the following provider ids + ProviderIds []string `json:"provider_ids,omitempty"` + // Fuzzy matches query + Query *string `json:"query,omitempty"` +} + +type SearchPublishedListingsForConsumerResponse struct { + Listings []Listing `json:"listings,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ShareInfo struct { + Name *string `json:"name,omitempty"` + Type ListingShareType `json:"type,omitempty"` +} + +type SharedDataObject struct { + // The type of the data object. Could be one of: TABLE, SCHEMA, NOTEBOOK_FILE, + // MODEL, VOLUME + DataObjectType *string `json:"data_object_type,omitempty"` + // Name of the shared object + Name *string `json:"name,omitempty"` +} + +type TokenDetail struct { + BearerToken *string `json:"bearerToken,omitempty"` + Endpoint *string `json:"endpoint,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + // These field names must follow the delta sharing protocol. Original message: + // RetrieveToken.Response in managed-catalog/api/messages/recipient.proto + ShareCredentialsVersion *int `json:"shareCredentialsVersion,omitempty"` +} + +type TokenInfo struct { + // Full activation url to retrieve the access token. It will be empty if the + // token is already retrieved. + ActivationUrl *string `json:"activation_url,omitempty"` + // Time at which this Recipient Token was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of Recipient Token creator. + CreatedBy *string `json:"created_by,omitempty"` + // Expiration timestamp of the token in epoch milliseconds. + ExpirationTime *int64 `json:"expiration_time,omitempty"` + // Unique id of the Recipient Token. + Id *string `json:"id,omitempty"` + // Time at which this Recipient Token was updated, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of Recipient Token updater. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type UpdateExchangeFilterRequest struct { + Filter *ExchangeFilter `json:"filter,omitempty"` + Id *string `json:"id,omitempty"` +} + +type UpdateExchangeFilterResponse struct { + Filter *ExchangeFilter `json:"filter,omitempty"` +} + +type UpdateExchangeRequest struct { + Exchange *Exchange `json:"exchange,omitempty"` + Id *string `json:"id,omitempty"` +} + +type UpdateExchangeResponse struct { + Exchange *Exchange `json:"exchange,omitempty"` +} + +type UpdateInstallationRequest struct { + Installation *InstallationDetail `json:"installation,omitempty"` + InstallationId *string `json:"installation_id,omitempty"` + ListingId *string `json:"listing_id,omitempty"` + RotateToken *bool `json:"rotate_token,omitempty"` +} + +type UpdateInstallationResponse struct { + Installation *InstallationDetail `json:"installation,omitempty"` +} + +type UpdateListingRequest struct { + Id *string `json:"id,omitempty"` + Listing *Listing `json:"listing,omitempty"` +} + +type UpdateListingResponse struct { + Listing *Listing `json:"listing,omitempty"` +} + +type UpdatePersonalizationRequestStatusRequest struct { + ListingId *string `json:"listing_id,omitempty"` + Reason *string `json:"reason,omitempty"` + RequestId *string `json:"request_id,omitempty"` + Share *ShareInfo `json:"share,omitempty"` + Status PersonalizationRequestStatus `json:"status,omitempty"` +} + +type UpdatePersonalizationRequestStatusResponse struct { + Request *PersonalizationRequest `json:"request,omitempty"` +} + +type UpdateProviderAnalyticsDashboardRequest struct { + // id is immutable property and can't be updated. + Id *string `json:"id,omitempty"` + // this is the version of the dashboard template we want to update our user to + // current expectation is that it should be equal to latest version of the + // dashboard template + Version *int64 `json:"version,omitempty"` +} + +type UpdateProviderAnalyticsDashboardResponse struct { + // this is newly created Lakeview dashboard for the user + DashboardId *string `json:"dashboard_id,omitempty"` + // id & version should be the same as the request + Id *string `json:"id,omitempty"` + Version *int64 `json:"version,omitempty"` +} + +type UpdateProviderRequest struct { + Id *string `json:"id,omitempty"` + Provider *ProviderInfo `json:"provider,omitempty"` +} + +type UpdateProviderResponse struct { + Provider *ProviderInfo `json:"provider,omitempty"` +} + +// AddExchangeForListingRequestToSDK converts the mirror to the sdk-go type. +func AddExchangeForListingRequestToSDK(w *AddExchangeForListingRequest) (*sdk.AddExchangeForListingRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AddExchangeForListingRequest{} + out.ListingId = w.ListingId + out.ExchangeId = w.ExchangeId + return out, nil +} + +// AddExchangeForListingRequestFromSDK converts the sdk-go type to the mirror. +func AddExchangeForListingRequestFromSDK(v *sdk.AddExchangeForListingRequest) (*AddExchangeForListingRequest, error) { + if v == nil { + return nil, nil + } + out := &AddExchangeForListingRequest{} + out.ListingId = v.ListingId + out.ExchangeId = v.ExchangeId + return out, nil +} + +// AddExchangeForListingResponseToSDK converts the mirror to the sdk-go type. +func AddExchangeForListingResponseToSDK(w *AddExchangeForListingResponse) (*sdk.AddExchangeForListingResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AddExchangeForListingResponse{} + conv1, err := ExchangeListingToSDK(w.ExchangeForListing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AddExchangeForListingResponse.ExchangeForListing", err) + } + out.ExchangeForListing = conv1 + return out, nil +} + +// AddExchangeForListingResponseFromSDK converts the sdk-go type to the mirror. +func AddExchangeForListingResponseFromSDK(v *sdk.AddExchangeForListingResponse) (*AddExchangeForListingResponse, error) { + if v == nil { + return nil, nil + } + out := &AddExchangeForListingResponse{} + conv2, err := ExchangeListingFromSDK(v.ExchangeForListing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AddExchangeForListingResponse.ExchangeForListing", err) + } + out.ExchangeForListing = conv2 + return out, nil +} + +// BatchGetListingsRequestToSDK converts the mirror to the sdk-go type. +func BatchGetListingsRequestToSDK(w *BatchGetListingsRequest) (*sdk.BatchGetListingsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.BatchGetListingsRequest{} + out.Ids = w.Ids + return out, nil +} + +// BatchGetListingsRequestFromSDK converts the sdk-go type to the mirror. +func BatchGetListingsRequestFromSDK(v *sdk.BatchGetListingsRequest) (*BatchGetListingsRequest, error) { + if v == nil { + return nil, nil + } + out := &BatchGetListingsRequest{} + out.Ids = v.Ids + return out, nil +} + +// BatchGetListingsResponseToSDK converts the mirror to the sdk-go type. +func BatchGetListingsResponseToSDK(w *BatchGetListingsResponse) (*sdk.BatchGetListingsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.BatchGetListingsResponse{} + conv3, err := convertSlice(w.Listings, ListingToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BatchGetListingsResponse.Listings", err) + } + out.Listings = conv3 + return out, nil +} + +// BatchGetListingsResponseFromSDK converts the sdk-go type to the mirror. +func BatchGetListingsResponseFromSDK(v *sdk.BatchGetListingsResponse) (*BatchGetListingsResponse, error) { + if v == nil { + return nil, nil + } + out := &BatchGetListingsResponse{} + conv4, err := convertSlice(v.Listings, ListingFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BatchGetListingsResponse.Listings", err) + } + out.Listings = conv4 + return out, nil +} + +// BatchGetProvidersRequestToSDK converts the mirror to the sdk-go type. +func BatchGetProvidersRequestToSDK(w *BatchGetProvidersRequest) (*sdk.BatchGetProvidersRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.BatchGetProvidersRequest{} + out.Ids = w.Ids + return out, nil +} + +// BatchGetProvidersRequestFromSDK converts the sdk-go type to the mirror. +func BatchGetProvidersRequestFromSDK(v *sdk.BatchGetProvidersRequest) (*BatchGetProvidersRequest, error) { + if v == nil { + return nil, nil + } + out := &BatchGetProvidersRequest{} + out.Ids = v.Ids + return out, nil +} + +// BatchGetProvidersResponseToSDK converts the mirror to the sdk-go type. +func BatchGetProvidersResponseToSDK(w *BatchGetProvidersResponse) (*sdk.BatchGetProvidersResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.BatchGetProvidersResponse{} + conv5, err := convertSlice(w.Providers, ProviderInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BatchGetProvidersResponse.Providers", err) + } + out.Providers = conv5 + return out, nil +} + +// BatchGetProvidersResponseFromSDK converts the sdk-go type to the mirror. +func BatchGetProvidersResponseFromSDK(v *sdk.BatchGetProvidersResponse) (*BatchGetProvidersResponse, error) { + if v == nil { + return nil, nil + } + out := &BatchGetProvidersResponse{} + conv6, err := convertSlice(v.Providers, ProviderInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BatchGetProvidersResponse.Providers", err) + } + out.Providers = conv6 + return out, nil +} + +// ConsumerTermsToSDK converts the mirror to the sdk-go type. +func ConsumerTermsToSDK(w *ConsumerTerms) (*sdk.ConsumerTerms, error) { + if w == nil { + return nil, nil + } + out := &sdk.ConsumerTerms{} + out.Version = w.Version + return out, nil +} + +// ConsumerTermsFromSDK converts the sdk-go type to the mirror. +func ConsumerTermsFromSDK(v *sdk.ConsumerTerms) (*ConsumerTerms, error) { + if v == nil { + return nil, nil + } + out := &ConsumerTerms{} + out.Version = v.Version + return out, nil +} + +// ContactInfoToSDK converts the mirror to the sdk-go type. +func ContactInfoToSDK(w *ContactInfo) (*sdk.ContactInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ContactInfo{} + out.FirstName = w.FirstName + out.LastName = w.LastName + out.Email = w.Email + out.Company = w.Company + return out, nil +} + +// ContactInfoFromSDK converts the sdk-go type to the mirror. +func ContactInfoFromSDK(v *sdk.ContactInfo) (*ContactInfo, error) { + if v == nil { + return nil, nil + } + out := &ContactInfo{} + out.FirstName = v.FirstName + out.LastName = v.LastName + out.Email = v.Email + out.Company = v.Company + return out, nil +} + +// CreateExchangeFilterRequestToSDK converts the mirror to the sdk-go type. +func CreateExchangeFilterRequestToSDK(w *CreateExchangeFilterRequest) (*sdk.CreateExchangeFilterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateExchangeFilterRequest{} + conv7, err := ExchangeFilterToSDK(w.Filter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExchangeFilterRequest.Filter", err) + } + out.Filter = conv7 + return out, nil +} + +// CreateExchangeFilterRequestFromSDK converts the sdk-go type to the mirror. +func CreateExchangeFilterRequestFromSDK(v *sdk.CreateExchangeFilterRequest) (*CreateExchangeFilterRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateExchangeFilterRequest{} + conv8, err := ExchangeFilterFromSDK(v.Filter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExchangeFilterRequest.Filter", err) + } + out.Filter = conv8 + return out, nil +} + +// CreateExchangeFilterResponseToSDK converts the mirror to the sdk-go type. +func CreateExchangeFilterResponseToSDK(w *CreateExchangeFilterResponse) (*sdk.CreateExchangeFilterResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateExchangeFilterResponse{} + out.FilterId = w.FilterId + return out, nil +} + +// CreateExchangeFilterResponseFromSDK converts the sdk-go type to the mirror. +func CreateExchangeFilterResponseFromSDK(v *sdk.CreateExchangeFilterResponse) (*CreateExchangeFilterResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateExchangeFilterResponse{} + out.FilterId = v.FilterId + return out, nil +} + +// CreateExchangeRequestToSDK converts the mirror to the sdk-go type. +func CreateExchangeRequestToSDK(w *CreateExchangeRequest) (*sdk.CreateExchangeRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateExchangeRequest{} + conv9, err := ExchangeToSDK(w.Exchange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExchangeRequest.Exchange", err) + } + out.Exchange = conv9 + return out, nil +} + +// CreateExchangeRequestFromSDK converts the sdk-go type to the mirror. +func CreateExchangeRequestFromSDK(v *sdk.CreateExchangeRequest) (*CreateExchangeRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateExchangeRequest{} + conv10, err := ExchangeFromSDK(v.Exchange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExchangeRequest.Exchange", err) + } + out.Exchange = conv10 + return out, nil +} + +// CreateExchangeResponseToSDK converts the mirror to the sdk-go type. +func CreateExchangeResponseToSDK(w *CreateExchangeResponse) (*sdk.CreateExchangeResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateExchangeResponse{} + out.ExchangeId = w.ExchangeId + return out, nil +} + +// CreateExchangeResponseFromSDK converts the sdk-go type to the mirror. +func CreateExchangeResponseFromSDK(v *sdk.CreateExchangeResponse) (*CreateExchangeResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateExchangeResponse{} + out.ExchangeId = v.ExchangeId + return out, nil +} + +// CreateFileRequestToSDK converts the mirror to the sdk-go type. +func CreateFileRequestToSDK(w *CreateFileRequest) (*sdk.CreateFileRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateFileRequest{} + conv11, err := FileParentToSDK(w.FileParent) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFileRequest.FileParent", err) + } + out.FileParent = conv11 + out.MarketplaceFileType = w.MarketplaceFileType + out.MimeType = w.MimeType + out.DisplayName = w.DisplayName + return out, nil +} + +// CreateFileRequestFromSDK converts the sdk-go type to the mirror. +func CreateFileRequestFromSDK(v *sdk.CreateFileRequest) (*CreateFileRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateFileRequest{} + conv12, err := FileParentFromSDK(v.FileParent) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFileRequest.FileParent", err) + } + out.FileParent = conv12 + out.MarketplaceFileType = v.MarketplaceFileType + out.MimeType = v.MimeType + out.DisplayName = v.DisplayName + return out, nil +} + +// CreateFileResponseToSDK converts the mirror to the sdk-go type. +func CreateFileResponseToSDK(w *CreateFileResponse) (*sdk.CreateFileResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateFileResponse{} + out.UploadUrl = w.UploadUrl + conv13, err := FileInfoToSDK(w.FileInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFileResponse.FileInfo", err) + } + out.FileInfo = conv13 + return out, nil +} + +// CreateFileResponseFromSDK converts the sdk-go type to the mirror. +func CreateFileResponseFromSDK(v *sdk.CreateFileResponse) (*CreateFileResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateFileResponse{} + out.UploadUrl = v.UploadUrl + conv14, err := FileInfoFromSDK(v.FileInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFileResponse.FileInfo", err) + } + out.FileInfo = conv14 + return out, nil +} + +// CreateInstallationRequestToSDK converts the mirror to the sdk-go type. +func CreateInstallationRequestToSDK(w *CreateInstallationRequest) (*sdk.CreateInstallationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateInstallationRequest{} + out.ListingId = w.ListingId + out.ShareName = w.ShareName + out.CatalogName = w.CatalogName + conv15, err := RepoInstallationToSDK(w.RepoDetail) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstallationRequest.RepoDetail", err) + } + out.RepoDetail = conv15 + out.RecipientType = w.RecipientType + conv16, err := ConsumerTermsToSDK(w.AcceptedConsumerTerms) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstallationRequest.AcceptedConsumerTerms", err) + } + out.AcceptedConsumerTerms = conv16 + return out, nil +} + +// CreateInstallationRequestFromSDK converts the sdk-go type to the mirror. +func CreateInstallationRequestFromSDK(v *sdk.CreateInstallationRequest) (*CreateInstallationRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateInstallationRequest{} + out.ListingId = v.ListingId + out.ShareName = v.ShareName + out.CatalogName = v.CatalogName + conv17, err := RepoInstallationFromSDK(v.RepoDetail) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstallationRequest.RepoDetail", err) + } + out.RepoDetail = conv17 + out.RecipientType = v.RecipientType + conv18, err := ConsumerTermsFromSDK(v.AcceptedConsumerTerms) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstallationRequest.AcceptedConsumerTerms", err) + } + out.AcceptedConsumerTerms = conv18 + return out, nil +} + +// CreateInstallationResponseToSDK converts the mirror to the sdk-go type. +func CreateInstallationResponseToSDK(w *CreateInstallationResponse) (*sdk.CreateInstallationResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateInstallationResponse{} + conv19, err := InstallationDetailToSDK(w.Installation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstallationResponse.Installation", err) + } + out.Installation = conv19 + return out, nil +} + +// CreateInstallationResponseFromSDK converts the sdk-go type to the mirror. +func CreateInstallationResponseFromSDK(v *sdk.CreateInstallationResponse) (*CreateInstallationResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateInstallationResponse{} + conv20, err := InstallationDetailFromSDK(v.Installation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInstallationResponse.Installation", err) + } + out.Installation = conv20 + return out, nil +} + +// CreateListingRequestToSDK converts the mirror to the sdk-go type. +func CreateListingRequestToSDK(w *CreateListingRequest) (*sdk.CreateListingRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateListingRequest{} + conv21, err := ListingToSDK(w.Listing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateListingRequest.Listing", err) + } + out.Listing = conv21 + return out, nil +} + +// CreateListingRequestFromSDK converts the sdk-go type to the mirror. +func CreateListingRequestFromSDK(v *sdk.CreateListingRequest) (*CreateListingRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateListingRequest{} + conv22, err := ListingFromSDK(v.Listing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateListingRequest.Listing", err) + } + out.Listing = conv22 + return out, nil +} + +// CreateListingResponseToSDK converts the mirror to the sdk-go type. +func CreateListingResponseToSDK(w *CreateListingResponse) (*sdk.CreateListingResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateListingResponse{} + out.ListingId = w.ListingId + return out, nil +} + +// CreateListingResponseFromSDK converts the sdk-go type to the mirror. +func CreateListingResponseFromSDK(v *sdk.CreateListingResponse) (*CreateListingResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateListingResponse{} + out.ListingId = v.ListingId + return out, nil +} + +// CreatePersonalizationRequestToSDK converts the mirror to the sdk-go type. +func CreatePersonalizationRequestToSDK(w *CreatePersonalizationRequest) (*sdk.CreatePersonalizationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreatePersonalizationRequest{} + out.ListingId = w.ListingId + out.Comment = w.Comment + out.IntendedUse = w.IntendedUse + out.FirstName = w.FirstName + out.LastName = w.LastName + out.Company = w.Company + out.IsFromLighthouse = w.IsFromLighthouse + out.RecipientType = w.RecipientType + conv23, err := ConsumerTermsToSDK(w.AcceptedConsumerTerms) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePersonalizationRequest.AcceptedConsumerTerms", err) + } + out.AcceptedConsumerTerms = conv23 + return out, nil +} + +// CreatePersonalizationRequestFromSDK converts the sdk-go type to the mirror. +func CreatePersonalizationRequestFromSDK(v *sdk.CreatePersonalizationRequest) (*CreatePersonalizationRequest, error) { + if v == nil { + return nil, nil + } + out := &CreatePersonalizationRequest{} + out.ListingId = v.ListingId + out.Comment = v.Comment + out.IntendedUse = v.IntendedUse + out.FirstName = v.FirstName + out.LastName = v.LastName + out.Company = v.Company + out.IsFromLighthouse = v.IsFromLighthouse + out.RecipientType = v.RecipientType + conv24, err := ConsumerTermsFromSDK(v.AcceptedConsumerTerms) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePersonalizationRequest.AcceptedConsumerTerms", err) + } + out.AcceptedConsumerTerms = conv24 + return out, nil +} + +// CreatePersonalizationResponseToSDK converts the mirror to the sdk-go type. +func CreatePersonalizationResponseToSDK(w *CreatePersonalizationResponse) (*sdk.CreatePersonalizationResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreatePersonalizationResponse{} + out.Id = w.Id + return out, nil +} + +// CreatePersonalizationResponseFromSDK converts the sdk-go type to the mirror. +func CreatePersonalizationResponseFromSDK(v *sdk.CreatePersonalizationResponse) (*CreatePersonalizationResponse, error) { + if v == nil { + return nil, nil + } + out := &CreatePersonalizationResponse{} + out.Id = v.Id + return out, nil +} + +// CreateProviderAnalyticsDashboardRequestToSDK converts the mirror to the sdk-go type. +func CreateProviderAnalyticsDashboardRequestToSDK(w *CreateProviderAnalyticsDashboardRequest) (*sdk.CreateProviderAnalyticsDashboardRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateProviderAnalyticsDashboardRequest{} + return out, nil +} + +// CreateProviderAnalyticsDashboardRequestFromSDK converts the sdk-go type to the mirror. +func CreateProviderAnalyticsDashboardRequestFromSDK(v *sdk.CreateProviderAnalyticsDashboardRequest) (*CreateProviderAnalyticsDashboardRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateProviderAnalyticsDashboardRequest{} + return out, nil +} + +// CreateProviderAnalyticsDashboardResponseToSDK converts the mirror to the sdk-go type. +func CreateProviderAnalyticsDashboardResponseToSDK(w *CreateProviderAnalyticsDashboardResponse) (*sdk.CreateProviderAnalyticsDashboardResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateProviderAnalyticsDashboardResponse{} + out.Id = w.Id + return out, nil +} + +// CreateProviderAnalyticsDashboardResponseFromSDK converts the sdk-go type to the mirror. +func CreateProviderAnalyticsDashboardResponseFromSDK(v *sdk.CreateProviderAnalyticsDashboardResponse) (*CreateProviderAnalyticsDashboardResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateProviderAnalyticsDashboardResponse{} + out.Id = v.Id + return out, nil +} + +// CreateProviderRequestToSDK converts the mirror to the sdk-go type. +func CreateProviderRequestToSDK(w *CreateProviderRequest) (*sdk.CreateProviderRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateProviderRequest{} + conv25, err := ProviderInfoToSDK(w.Provider) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateProviderRequest.Provider", err) + } + out.Provider = conv25 + return out, nil +} + +// CreateProviderRequestFromSDK converts the sdk-go type to the mirror. +func CreateProviderRequestFromSDK(v *sdk.CreateProviderRequest) (*CreateProviderRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateProviderRequest{} + conv26, err := ProviderInfoFromSDK(v.Provider) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateProviderRequest.Provider", err) + } + out.Provider = conv26 + return out, nil +} + +// CreateProviderResponseToSDK converts the mirror to the sdk-go type. +func CreateProviderResponseToSDK(w *CreateProviderResponse) (*sdk.CreateProviderResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateProviderResponse{} + out.Id = w.Id + return out, nil +} + +// CreateProviderResponseFromSDK converts the sdk-go type to the mirror. +func CreateProviderResponseFromSDK(v *sdk.CreateProviderResponse) (*CreateProviderResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateProviderResponse{} + out.Id = v.Id + return out, nil +} + +// DataRefreshInfoToSDK converts the mirror to the sdk-go type. +func DataRefreshInfoToSDK(w *DataRefreshInfo) (*sdk.DataRefreshInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataRefreshInfo{} + out.Interval = w.Interval + out.Unit = w.Unit + return out, nil +} + +// DataRefreshInfoFromSDK converts the sdk-go type to the mirror. +func DataRefreshInfoFromSDK(v *sdk.DataRefreshInfo) (*DataRefreshInfo, error) { + if v == nil { + return nil, nil + } + out := &DataRefreshInfo{} + out.Interval = v.Interval + out.Unit = v.Unit + return out, nil +} + +// ExchangeToSDK converts the mirror to the sdk-go type. +func ExchangeToSDK(w *Exchange) (*sdk.Exchange, error) { + if w == nil { + return nil, nil + } + out := &sdk.Exchange{} + out.Id = w.Id + out.Name = w.Name + out.Comment = w.Comment + conv27, err := convertSlice(w.Filters, ExchangeFilterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Exchange.Filters", err) + } + out.Filters = conv27 + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + conv28, err := convertSlice(w.LinkedListings, ExchangeListingToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Exchange.LinkedListings", err) + } + out.LinkedListings = conv28 + return out, nil +} + +// ExchangeFromSDK converts the sdk-go type to the mirror. +func ExchangeFromSDK(v *sdk.Exchange) (*Exchange, error) { + if v == nil { + return nil, nil + } + out := &Exchange{} + out.Id = v.Id + out.Name = v.Name + out.Comment = v.Comment + conv29, err := convertSlice(v.Filters, ExchangeFilterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Exchange.Filters", err) + } + out.Filters = conv29 + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + conv30, err := convertSlice(v.LinkedListings, ExchangeListingFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Exchange.LinkedListings", err) + } + out.LinkedListings = conv30 + return out, nil +} + +// ExchangeFilterToSDK converts the mirror to the sdk-go type. +func ExchangeFilterToSDK(w *ExchangeFilter) (*sdk.ExchangeFilter, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExchangeFilter{} + out.Id = w.Id + out.ExchangeId = w.ExchangeId + out.FilterValue = w.FilterValue + out.Name = w.Name + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.FilterType = w.FilterType + return out, nil +} + +// ExchangeFilterFromSDK converts the sdk-go type to the mirror. +func ExchangeFilterFromSDK(v *sdk.ExchangeFilter) (*ExchangeFilter, error) { + if v == nil { + return nil, nil + } + out := &ExchangeFilter{} + out.Id = v.Id + out.ExchangeId = v.ExchangeId + out.FilterValue = v.FilterValue + out.Name = v.Name + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.FilterType = v.FilterType + return out, nil +} + +// ExchangeListingToSDK converts the mirror to the sdk-go type. +func ExchangeListingToSDK(w *ExchangeListing) (*sdk.ExchangeListing, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExchangeListing{} + out.Id = w.Id + out.ExchangeId = w.ExchangeId + out.ExchangeName = w.ExchangeName + out.ListingId = w.ListingId + out.ListingName = w.ListingName + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + return out, nil +} + +// ExchangeListingFromSDK converts the sdk-go type to the mirror. +func ExchangeListingFromSDK(v *sdk.ExchangeListing) (*ExchangeListing, error) { + if v == nil { + return nil, nil + } + out := &ExchangeListing{} + out.Id = v.Id + out.ExchangeId = v.ExchangeId + out.ExchangeName = v.ExchangeName + out.ListingId = v.ListingId + out.ListingName = v.ListingName + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + return out, nil +} + +// FileInfoToSDK converts the mirror to the sdk-go type. +func FileInfoToSDK(w *FileInfo) (*sdk.FileInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.FileInfo{} + out.Id = w.Id + out.MarketplaceFileType = w.MarketplaceFileType + conv31, err := FileParentToSDK(w.FileParent) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileInfo.FileParent", err) + } + out.FileParent = conv31 + out.MimeType = w.MimeType + out.DownloadLink = w.DownloadLink + out.CreatedAt = w.CreatedAt + out.UpdatedAt = w.UpdatedAt + out.DisplayName = w.DisplayName + out.Status = w.Status + out.StatusMessage = w.StatusMessage + return out, nil +} + +// FileInfoFromSDK converts the sdk-go type to the mirror. +func FileInfoFromSDK(v *sdk.FileInfo) (*FileInfo, error) { + if v == nil { + return nil, nil + } + out := &FileInfo{} + out.Id = v.Id + out.MarketplaceFileType = v.MarketplaceFileType + conv32, err := FileParentFromSDK(v.FileParent) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileInfo.FileParent", err) + } + out.FileParent = conv32 + out.MimeType = v.MimeType + out.DownloadLink = v.DownloadLink + out.CreatedAt = v.CreatedAt + out.UpdatedAt = v.UpdatedAt + out.DisplayName = v.DisplayName + out.Status = v.Status + out.StatusMessage = v.StatusMessage + return out, nil +} + +// FileParentToSDK converts the mirror to the sdk-go type. +func FileParentToSDK(w *FileParent) (*sdk.FileParent, error) { + if w == nil { + return nil, nil + } + out := &sdk.FileParent{} + out.ParentId = w.ParentId + out.FileParentType = w.FileParentType + return out, nil +} + +// FileParentFromSDK converts the sdk-go type to the mirror. +func FileParentFromSDK(v *sdk.FileParent) (*FileParent, error) { + if v == nil { + return nil, nil + } + out := &FileParent{} + out.ParentId = v.ParentId + out.FileParentType = v.FileParentType + return out, nil +} + +// GetAllPersonalizationRequestsForConsumerResponseToSDK converts the mirror to the sdk-go type. +func GetAllPersonalizationRequestsForConsumerResponseToSDK(w *GetAllPersonalizationRequestsForConsumerResponse) (*sdk.GetAllPersonalizationRequestsForConsumerResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetAllPersonalizationRequestsForConsumerResponse{} + conv33, err := convertSlice(w.PersonalizationRequests, PersonalizationRequestToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetAllPersonalizationRequestsForConsumerResponse.PersonalizationRequests", err) + } + out.PersonalizationRequests = conv33 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GetAllPersonalizationRequestsForConsumerResponseFromSDK converts the sdk-go type to the mirror. +func GetAllPersonalizationRequestsForConsumerResponseFromSDK(v *sdk.GetAllPersonalizationRequestsForConsumerResponse) (*GetAllPersonalizationRequestsForConsumerResponse, error) { + if v == nil { + return nil, nil + } + out := &GetAllPersonalizationRequestsForConsumerResponse{} + conv34, err := convertSlice(v.PersonalizationRequests, PersonalizationRequestFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetAllPersonalizationRequestsForConsumerResponse.PersonalizationRequests", err) + } + out.PersonalizationRequests = conv34 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GetExchangeResponseToSDK converts the mirror to the sdk-go type. +func GetExchangeResponseToSDK(w *GetExchangeResponse) (*sdk.GetExchangeResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetExchangeResponse{} + conv35, err := ExchangeToSDK(w.Exchange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetExchangeResponse.Exchange", err) + } + out.Exchange = conv35 + return out, nil +} + +// GetExchangeResponseFromSDK converts the sdk-go type to the mirror. +func GetExchangeResponseFromSDK(v *sdk.GetExchangeResponse) (*GetExchangeResponse, error) { + if v == nil { + return nil, nil + } + out := &GetExchangeResponse{} + conv36, err := ExchangeFromSDK(v.Exchange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetExchangeResponse.Exchange", err) + } + out.Exchange = conv36 + return out, nil +} + +// GetFileResponseToSDK converts the mirror to the sdk-go type. +func GetFileResponseToSDK(w *GetFileResponse) (*sdk.GetFileResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetFileResponse{} + conv37, err := FileInfoToSDK(w.FileInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetFileResponse.FileInfo", err) + } + out.FileInfo = conv37 + return out, nil +} + +// GetFileResponseFromSDK converts the sdk-go type to the mirror. +func GetFileResponseFromSDK(v *sdk.GetFileResponse) (*GetFileResponse, error) { + if v == nil { + return nil, nil + } + out := &GetFileResponse{} + conv38, err := FileInfoFromSDK(v.FileInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetFileResponse.FileInfo", err) + } + out.FileInfo = conv38 + return out, nil +} + +// GetInstallationDetailsRequestToSDK converts the mirror to the sdk-go type. +func GetInstallationDetailsRequestToSDK(w *GetInstallationDetailsRequest) (*sdk.GetInstallationDetailsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetInstallationDetailsRequest{} + out.ListingId = w.ListingId + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// GetInstallationDetailsRequestFromSDK converts the sdk-go type to the mirror. +func GetInstallationDetailsRequestFromSDK(v *sdk.GetInstallationDetailsRequest) (*GetInstallationDetailsRequest, error) { + if v == nil { + return nil, nil + } + out := &GetInstallationDetailsRequest{} + out.ListingId = v.ListingId + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// GetLatestVersionProviderAnalyticsDashboardResponseToSDK converts the mirror to the sdk-go type. +func GetLatestVersionProviderAnalyticsDashboardResponseToSDK(w *GetLatestVersionProviderAnalyticsDashboardResponse) (*sdk.GetLatestVersionProviderAnalyticsDashboardResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetLatestVersionProviderAnalyticsDashboardResponse{} + out.Version = w.Version + return out, nil +} + +// GetLatestVersionProviderAnalyticsDashboardResponseFromSDK converts the sdk-go type to the mirror. +func GetLatestVersionProviderAnalyticsDashboardResponseFromSDK(v *sdk.GetLatestVersionProviderAnalyticsDashboardResponse) (*GetLatestVersionProviderAnalyticsDashboardResponse, error) { + if v == nil { + return nil, nil + } + out := &GetLatestVersionProviderAnalyticsDashboardResponse{} + out.Version = v.Version + return out, nil +} + +// GetListingContentMetadataRequestToSDK converts the mirror to the sdk-go type. +func GetListingContentMetadataRequestToSDK(w *GetListingContentMetadataRequest) (*sdk.GetListingContentMetadataRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetListingContentMetadataRequest{} + out.ListingId = w.ListingId + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// GetListingContentMetadataRequestFromSDK converts the sdk-go type to the mirror. +func GetListingContentMetadataRequestFromSDK(v *sdk.GetListingContentMetadataRequest) (*GetListingContentMetadataRequest, error) { + if v == nil { + return nil, nil + } + out := &GetListingContentMetadataRequest{} + out.ListingId = v.ListingId + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// GetListingContentMetadataResponseToSDK converts the mirror to the sdk-go type. +func GetListingContentMetadataResponseToSDK(w *GetListingContentMetadataResponse) (*sdk.GetListingContentMetadataResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetListingContentMetadataResponse{} + conv39, err := convertSlice(w.SharedDataObjects, SharedDataObjectToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetListingContentMetadataResponse.SharedDataObjects", err) + } + out.SharedDataObjects = conv39 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GetListingContentMetadataResponseFromSDK converts the sdk-go type to the mirror. +func GetListingContentMetadataResponseFromSDK(v *sdk.GetListingContentMetadataResponse) (*GetListingContentMetadataResponse, error) { + if v == nil { + return nil, nil + } + out := &GetListingContentMetadataResponse{} + conv40, err := convertSlice(v.SharedDataObjects, SharedDataObjectFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetListingContentMetadataResponse.SharedDataObjects", err) + } + out.SharedDataObjects = conv40 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GetListingResponseToSDK converts the mirror to the sdk-go type. +func GetListingResponseToSDK(w *GetListingResponse) (*sdk.GetListingResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetListingResponse{} + conv41, err := ListingToSDK(w.Listing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetListingResponse.Listing", err) + } + out.Listing = conv41 + return out, nil +} + +// GetListingResponseFromSDK converts the sdk-go type to the mirror. +func GetListingResponseFromSDK(v *sdk.GetListingResponse) (*GetListingResponse, error) { + if v == nil { + return nil, nil + } + out := &GetListingResponse{} + conv42, err := ListingFromSDK(v.Listing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetListingResponse.Listing", err) + } + out.Listing = conv42 + return out, nil +} + +// GetListingsResponseToSDK converts the mirror to the sdk-go type. +func GetListingsResponseToSDK(w *GetListingsResponse) (*sdk.GetListingsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetListingsResponse{} + conv43, err := convertSlice(w.Listings, ListingToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetListingsResponse.Listings", err) + } + out.Listings = conv43 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GetListingsResponseFromSDK converts the sdk-go type to the mirror. +func GetListingsResponseFromSDK(v *sdk.GetListingsResponse) (*GetListingsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetListingsResponse{} + conv44, err := convertSlice(v.Listings, ListingFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetListingsResponse.Listings", err) + } + out.Listings = conv44 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GetPersonalizationRequestsForConsumerResponseToSDK converts the mirror to the sdk-go type. +func GetPersonalizationRequestsForConsumerResponseToSDK(w *GetPersonalizationRequestsForConsumerResponse) (*sdk.GetPersonalizationRequestsForConsumerResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPersonalizationRequestsForConsumerResponse{} + conv45, err := convertSlice(w.PersonalizationRequests, PersonalizationRequestToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPersonalizationRequestsForConsumerResponse.PersonalizationRequests", err) + } + out.PersonalizationRequests = conv45 + return out, nil +} + +// GetPersonalizationRequestsForConsumerResponseFromSDK converts the sdk-go type to the mirror. +func GetPersonalizationRequestsForConsumerResponseFromSDK(v *sdk.GetPersonalizationRequestsForConsumerResponse) (*GetPersonalizationRequestsForConsumerResponse, error) { + if v == nil { + return nil, nil + } + out := &GetPersonalizationRequestsForConsumerResponse{} + conv46, err := convertSlice(v.PersonalizationRequests, PersonalizationRequestFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPersonalizationRequestsForConsumerResponse.PersonalizationRequests", err) + } + out.PersonalizationRequests = conv46 + return out, nil +} + +// GetPersonalizationRequestsForProviderRequestToSDK converts the mirror to the sdk-go type. +func GetPersonalizationRequestsForProviderRequestToSDK(w *GetPersonalizationRequestsForProviderRequest) (*sdk.GetPersonalizationRequestsForProviderRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPersonalizationRequestsForProviderRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// GetPersonalizationRequestsForProviderRequestFromSDK converts the sdk-go type to the mirror. +func GetPersonalizationRequestsForProviderRequestFromSDK(v *sdk.GetPersonalizationRequestsForProviderRequest) (*GetPersonalizationRequestsForProviderRequest, error) { + if v == nil { + return nil, nil + } + out := &GetPersonalizationRequestsForProviderRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// GetPersonalizationRequestsForProviderResponseToSDK converts the mirror to the sdk-go type. +func GetPersonalizationRequestsForProviderResponseToSDK(w *GetPersonalizationRequestsForProviderResponse) (*sdk.GetPersonalizationRequestsForProviderResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPersonalizationRequestsForProviderResponse{} + conv47, err := convertSlice(w.PersonalizationRequests, PersonalizationRequestToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPersonalizationRequestsForProviderResponse.PersonalizationRequests", err) + } + out.PersonalizationRequests = conv47 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GetPersonalizationRequestsForProviderResponseFromSDK converts the sdk-go type to the mirror. +func GetPersonalizationRequestsForProviderResponseFromSDK(v *sdk.GetPersonalizationRequestsForProviderResponse) (*GetPersonalizationRequestsForProviderResponse, error) { + if v == nil { + return nil, nil + } + out := &GetPersonalizationRequestsForProviderResponse{} + conv48, err := convertSlice(v.PersonalizationRequests, PersonalizationRequestFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPersonalizationRequestsForProviderResponse.PersonalizationRequests", err) + } + out.PersonalizationRequests = conv48 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GetProviderResponseToSDK converts the mirror to the sdk-go type. +func GetProviderResponseToSDK(w *GetProviderResponse) (*sdk.GetProviderResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetProviderResponse{} + conv49, err := ProviderInfoToSDK(w.Provider) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetProviderResponse.Provider", err) + } + out.Provider = conv49 + return out, nil +} + +// GetProviderResponseFromSDK converts the sdk-go type to the mirror. +func GetProviderResponseFromSDK(v *sdk.GetProviderResponse) (*GetProviderResponse, error) { + if v == nil { + return nil, nil + } + out := &GetProviderResponse{} + conv50, err := ProviderInfoFromSDK(v.Provider) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetProviderResponse.Provider", err) + } + out.Provider = conv50 + return out, nil +} + +// GetPublishedListingForConsumerResponseToSDK converts the mirror to the sdk-go type. +func GetPublishedListingForConsumerResponseToSDK(w *GetPublishedListingForConsumerResponse) (*sdk.GetPublishedListingForConsumerResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPublishedListingForConsumerResponse{} + conv51, err := ListingToSDK(w.Listing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPublishedListingForConsumerResponse.Listing", err) + } + out.Listing = conv51 + return out, nil +} + +// GetPublishedListingForConsumerResponseFromSDK converts the sdk-go type to the mirror. +func GetPublishedListingForConsumerResponseFromSDK(v *sdk.GetPublishedListingForConsumerResponse) (*GetPublishedListingForConsumerResponse, error) { + if v == nil { + return nil, nil + } + out := &GetPublishedListingForConsumerResponse{} + conv52, err := ListingFromSDK(v.Listing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPublishedListingForConsumerResponse.Listing", err) + } + out.Listing = conv52 + return out, nil +} + +// GetPublishedListingsForConsumerResponseToSDK converts the mirror to the sdk-go type. +func GetPublishedListingsForConsumerResponseToSDK(w *GetPublishedListingsForConsumerResponse) (*sdk.GetPublishedListingsForConsumerResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPublishedListingsForConsumerResponse{} + conv53, err := convertSlice(w.Listings, ListingToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPublishedListingsForConsumerResponse.Listings", err) + } + out.Listings = conv53 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GetPublishedListingsForConsumerResponseFromSDK converts the sdk-go type to the mirror. +func GetPublishedListingsForConsumerResponseFromSDK(v *sdk.GetPublishedListingsForConsumerResponse) (*GetPublishedListingsForConsumerResponse, error) { + if v == nil { + return nil, nil + } + out := &GetPublishedListingsForConsumerResponse{} + conv54, err := convertSlice(v.Listings, ListingFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPublishedListingsForConsumerResponse.Listings", err) + } + out.Listings = conv54 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GetPublishedProviderForConsumerResponseToSDK converts the mirror to the sdk-go type. +func GetPublishedProviderForConsumerResponseToSDK(w *GetPublishedProviderForConsumerResponse) (*sdk.GetPublishedProviderForConsumerResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPublishedProviderForConsumerResponse{} + conv55, err := ProviderInfoToSDK(w.Provider) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPublishedProviderForConsumerResponse.Provider", err) + } + out.Provider = conv55 + return out, nil +} + +// GetPublishedProviderForConsumerResponseFromSDK converts the sdk-go type to the mirror. +func GetPublishedProviderForConsumerResponseFromSDK(v *sdk.GetPublishedProviderForConsumerResponse) (*GetPublishedProviderForConsumerResponse, error) { + if v == nil { + return nil, nil + } + out := &GetPublishedProviderForConsumerResponse{} + conv56, err := ProviderInfoFromSDK(v.Provider) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPublishedProviderForConsumerResponse.Provider", err) + } + out.Provider = conv56 + return out, nil +} + +// InstallationDetailToSDK converts the mirror to the sdk-go type. +func InstallationDetailToSDK(w *InstallationDetail) (*sdk.InstallationDetail, error) { + if w == nil { + return nil, nil + } + out := &sdk.InstallationDetail{} + out.Id = w.Id + out.ListingId = w.ListingId + out.ShareName = w.ShareName + out.CatalogName = w.CatalogName + out.InstalledOn = w.InstalledOn + out.Status = w.Status + out.ErrorMessage = w.ErrorMessage + out.ListingName = w.ListingName + out.RepoName = w.RepoName + out.RepoPath = w.RepoPath + out.RecipientType = w.RecipientType + conv57, err := convertSlice(w.Tokens, TokenInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstallationDetail.Tokens", err) + } + out.Tokens = conv57 + conv58, err := TokenDetailToSDK(w.TokenDetail) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstallationDetail.TokenDetail", err) + } + out.TokenDetail = conv58 + return out, nil +} + +// InstallationDetailFromSDK converts the sdk-go type to the mirror. +func InstallationDetailFromSDK(v *sdk.InstallationDetail) (*InstallationDetail, error) { + if v == nil { + return nil, nil + } + out := &InstallationDetail{} + out.Id = v.Id + out.ListingId = v.ListingId + out.ShareName = v.ShareName + out.CatalogName = v.CatalogName + out.InstalledOn = v.InstalledOn + out.Status = v.Status + out.ErrorMessage = v.ErrorMessage + out.ListingName = v.ListingName + out.RepoName = v.RepoName + out.RepoPath = v.RepoPath + out.RecipientType = v.RecipientType + conv59, err := convertSlice(v.Tokens, TokenInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstallationDetail.Tokens", err) + } + out.Tokens = conv59 + conv60, err := TokenDetailFromSDK(v.TokenDetail) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InstallationDetail.TokenDetail", err) + } + out.TokenDetail = conv60 + return out, nil +} + +// ListAllInstallationsResponseToSDK converts the mirror to the sdk-go type. +func ListAllInstallationsResponseToSDK(w *ListAllInstallationsResponse) (*sdk.ListAllInstallationsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAllInstallationsResponse{} + conv61, err := convertSlice(w.Installations, InstallationDetailToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAllInstallationsResponse.Installations", err) + } + out.Installations = conv61 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListAllInstallationsResponseFromSDK converts the sdk-go type to the mirror. +func ListAllInstallationsResponseFromSDK(v *sdk.ListAllInstallationsResponse) (*ListAllInstallationsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAllInstallationsResponse{} + conv62, err := convertSlice(v.Installations, InstallationDetailFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAllInstallationsResponse.Installations", err) + } + out.Installations = conv62 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListExchangeFiltersRequestToSDK converts the mirror to the sdk-go type. +func ListExchangeFiltersRequestToSDK(w *ListExchangeFiltersRequest) (*sdk.ListExchangeFiltersRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExchangeFiltersRequest{} + out.ExchangeId = w.ExchangeId + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListExchangeFiltersRequestFromSDK converts the sdk-go type to the mirror. +func ListExchangeFiltersRequestFromSDK(v *sdk.ListExchangeFiltersRequest) (*ListExchangeFiltersRequest, error) { + if v == nil { + return nil, nil + } + out := &ListExchangeFiltersRequest{} + out.ExchangeId = v.ExchangeId + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListExchangeFiltersResponseToSDK converts the mirror to the sdk-go type. +func ListExchangeFiltersResponseToSDK(w *ListExchangeFiltersResponse) (*sdk.ListExchangeFiltersResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExchangeFiltersResponse{} + conv63, err := convertSlice(w.Filters, ExchangeFilterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExchangeFiltersResponse.Filters", err) + } + out.Filters = conv63 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListExchangeFiltersResponseFromSDK converts the sdk-go type to the mirror. +func ListExchangeFiltersResponseFromSDK(v *sdk.ListExchangeFiltersResponse) (*ListExchangeFiltersResponse, error) { + if v == nil { + return nil, nil + } + out := &ListExchangeFiltersResponse{} + conv64, err := convertSlice(v.Filters, ExchangeFilterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExchangeFiltersResponse.Filters", err) + } + out.Filters = conv64 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListExchangesForListingRequestToSDK converts the mirror to the sdk-go type. +func ListExchangesForListingRequestToSDK(w *ListExchangesForListingRequest) (*sdk.ListExchangesForListingRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExchangesForListingRequest{} + out.ListingId = w.ListingId + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListExchangesForListingRequestFromSDK converts the sdk-go type to the mirror. +func ListExchangesForListingRequestFromSDK(v *sdk.ListExchangesForListingRequest) (*ListExchangesForListingRequest, error) { + if v == nil { + return nil, nil + } + out := &ListExchangesForListingRequest{} + out.ListingId = v.ListingId + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListExchangesForListingResponseToSDK converts the mirror to the sdk-go type. +func ListExchangesForListingResponseToSDK(w *ListExchangesForListingResponse) (*sdk.ListExchangesForListingResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExchangesForListingResponse{} + conv65, err := convertSlice(w.ExchangeListing, ExchangeListingToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExchangesForListingResponse.ExchangeListing", err) + } + out.ExchangeListing = conv65 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListExchangesForListingResponseFromSDK converts the sdk-go type to the mirror. +func ListExchangesForListingResponseFromSDK(v *sdk.ListExchangesForListingResponse) (*ListExchangesForListingResponse, error) { + if v == nil { + return nil, nil + } + out := &ListExchangesForListingResponse{} + conv66, err := convertSlice(v.ExchangeListing, ExchangeListingFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExchangesForListingResponse.ExchangeListing", err) + } + out.ExchangeListing = conv66 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListExchangesRequestToSDK converts the mirror to the sdk-go type. +func ListExchangesRequestToSDK(w *ListExchangesRequest) (*sdk.ListExchangesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExchangesRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListExchangesRequestFromSDK converts the sdk-go type to the mirror. +func ListExchangesRequestFromSDK(v *sdk.ListExchangesRequest) (*ListExchangesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListExchangesRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListExchangesResponseToSDK converts the mirror to the sdk-go type. +func ListExchangesResponseToSDK(w *ListExchangesResponse) (*sdk.ListExchangesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExchangesResponse{} + conv67, err := convertSlice(w.Exchanges, ExchangeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExchangesResponse.Exchanges", err) + } + out.Exchanges = conv67 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListExchangesResponseFromSDK converts the sdk-go type to the mirror. +func ListExchangesResponseFromSDK(v *sdk.ListExchangesResponse) (*ListExchangesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListExchangesResponse{} + conv68, err := convertSlice(v.Exchanges, ExchangeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExchangesResponse.Exchanges", err) + } + out.Exchanges = conv68 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListFilesRequestToSDK converts the mirror to the sdk-go type. +func ListFilesRequestToSDK(w *ListFilesRequest) (*sdk.ListFilesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListFilesRequest{} + conv69, err := FileParentToSDK(w.FileParent) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFilesRequest.FileParent", err) + } + out.FileParent = conv69 + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListFilesRequestFromSDK converts the sdk-go type to the mirror. +func ListFilesRequestFromSDK(v *sdk.ListFilesRequest) (*ListFilesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListFilesRequest{} + conv70, err := FileParentFromSDK(v.FileParent) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFilesRequest.FileParent", err) + } + out.FileParent = conv70 + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListFilesResponseToSDK converts the mirror to the sdk-go type. +func ListFilesResponseToSDK(w *ListFilesResponse) (*sdk.ListFilesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListFilesResponse{} + conv71, err := convertSlice(w.FileInfos, FileInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFilesResponse.FileInfos", err) + } + out.FileInfos = conv71 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListFilesResponseFromSDK converts the sdk-go type to the mirror. +func ListFilesResponseFromSDK(v *sdk.ListFilesResponse) (*ListFilesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListFilesResponse{} + conv72, err := convertSlice(v.FileInfos, FileInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFilesResponse.FileInfos", err) + } + out.FileInfos = conv72 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListFulfillmentsResponseToSDK converts the mirror to the sdk-go type. +func ListFulfillmentsResponseToSDK(w *ListFulfillmentsResponse) (*sdk.ListFulfillmentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListFulfillmentsResponse{} + conv73, err := convertSlice(w.Fulfillments, ListingFulfillmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFulfillmentsResponse.Fulfillments", err) + } + out.Fulfillments = conv73 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListFulfillmentsResponseFromSDK converts the sdk-go type to the mirror. +func ListFulfillmentsResponseFromSDK(v *sdk.ListFulfillmentsResponse) (*ListFulfillmentsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListFulfillmentsResponse{} + conv74, err := convertSlice(v.Fulfillments, ListingFulfillmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFulfillmentsResponse.Fulfillments", err) + } + out.Fulfillments = conv74 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListInstallationsRequestToSDK converts the mirror to the sdk-go type. +func ListInstallationsRequestToSDK(w *ListInstallationsRequest) (*sdk.ListInstallationsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListInstallationsRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListInstallationsRequestFromSDK converts the sdk-go type to the mirror. +func ListInstallationsRequestFromSDK(v *sdk.ListInstallationsRequest) (*ListInstallationsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListInstallationsRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListInstallationsResponseToSDK converts the mirror to the sdk-go type. +func ListInstallationsResponseToSDK(w *ListInstallationsResponse) (*sdk.ListInstallationsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListInstallationsResponse{} + conv75, err := convertSlice(w.Installations, InstallationDetailToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListInstallationsResponse.Installations", err) + } + out.Installations = conv75 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListInstallationsResponseFromSDK converts the sdk-go type to the mirror. +func ListInstallationsResponseFromSDK(v *sdk.ListInstallationsResponse) (*ListInstallationsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListInstallationsResponse{} + conv76, err := convertSlice(v.Installations, InstallationDetailFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListInstallationsResponse.Installations", err) + } + out.Installations = conv76 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListListingFulfillmentsRequestToSDK converts the mirror to the sdk-go type. +func ListListingFulfillmentsRequestToSDK(w *ListListingFulfillmentsRequest) (*sdk.ListListingFulfillmentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListListingFulfillmentsRequest{} + out.ListingId = w.ListingId + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListListingFulfillmentsRequestFromSDK converts the sdk-go type to the mirror. +func ListListingFulfillmentsRequestFromSDK(v *sdk.ListListingFulfillmentsRequest) (*ListListingFulfillmentsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListListingFulfillmentsRequest{} + out.ListingId = v.ListingId + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListListingsForExchangeRequestToSDK converts the mirror to the sdk-go type. +func ListListingsForExchangeRequestToSDK(w *ListListingsForExchangeRequest) (*sdk.ListListingsForExchangeRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListListingsForExchangeRequest{} + out.ExchangeId = w.ExchangeId + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListListingsForExchangeRequestFromSDK converts the sdk-go type to the mirror. +func ListListingsForExchangeRequestFromSDK(v *sdk.ListListingsForExchangeRequest) (*ListListingsForExchangeRequest, error) { + if v == nil { + return nil, nil + } + out := &ListListingsForExchangeRequest{} + out.ExchangeId = v.ExchangeId + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListListingsForExchangeResponseToSDK converts the mirror to the sdk-go type. +func ListListingsForExchangeResponseToSDK(w *ListListingsForExchangeResponse) (*sdk.ListListingsForExchangeResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListListingsForExchangeResponse{} + conv77, err := convertSlice(w.ExchangeListings, ExchangeListingToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListListingsForExchangeResponse.ExchangeListings", err) + } + out.ExchangeListings = conv77 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListListingsForExchangeResponseFromSDK converts the sdk-go type to the mirror. +func ListListingsForExchangeResponseFromSDK(v *sdk.ListListingsForExchangeResponse) (*ListListingsForExchangeResponse, error) { + if v == nil { + return nil, nil + } + out := &ListListingsForExchangeResponse{} + conv78, err := convertSlice(v.ExchangeListings, ExchangeListingFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListListingsForExchangeResponse.ExchangeListings", err) + } + out.ExchangeListings = conv78 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListListingsRequestToSDK converts the mirror to the sdk-go type. +func ListListingsRequestToSDK(w *ListListingsRequest) (*sdk.ListListingsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListListingsRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListListingsRequestFromSDK converts the sdk-go type to the mirror. +func ListListingsRequestFromSDK(v *sdk.ListListingsRequest) (*ListListingsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListListingsRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListPersonalizationRequestsForConsumerRequestToSDK converts the mirror to the sdk-go type. +func ListPersonalizationRequestsForConsumerRequestToSDK(w *ListPersonalizationRequestsForConsumerRequest) (*sdk.ListPersonalizationRequestsForConsumerRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPersonalizationRequestsForConsumerRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListPersonalizationRequestsForConsumerRequestFromSDK converts the sdk-go type to the mirror. +func ListPersonalizationRequestsForConsumerRequestFromSDK(v *sdk.ListPersonalizationRequestsForConsumerRequest) (*ListPersonalizationRequestsForConsumerRequest, error) { + if v == nil { + return nil, nil + } + out := &ListPersonalizationRequestsForConsumerRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListProviderAnalyticsDashboardResponseToSDK converts the mirror to the sdk-go type. +func ListProviderAnalyticsDashboardResponseToSDK(w *ListProviderAnalyticsDashboardResponse) (*sdk.ListProviderAnalyticsDashboardResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListProviderAnalyticsDashboardResponse{} + out.Id = w.Id + out.Version = w.Version + out.DashboardId = w.DashboardId + return out, nil +} + +// ListProviderAnalyticsDashboardResponseFromSDK converts the sdk-go type to the mirror. +func ListProviderAnalyticsDashboardResponseFromSDK(v *sdk.ListProviderAnalyticsDashboardResponse) (*ListProviderAnalyticsDashboardResponse, error) { + if v == nil { + return nil, nil + } + out := &ListProviderAnalyticsDashboardResponse{} + out.Id = v.Id + out.Version = v.Version + out.DashboardId = v.DashboardId + return out, nil +} + +// ListProvidersRequestToSDK converts the mirror to the sdk-go type. +func ListProvidersRequestToSDK(w *ListProvidersRequest) (*sdk.ListProvidersRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListProvidersRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListProvidersRequestFromSDK converts the sdk-go type to the mirror. +func ListProvidersRequestFromSDK(v *sdk.ListProvidersRequest) (*ListProvidersRequest, error) { + if v == nil { + return nil, nil + } + out := &ListProvidersRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListProvidersResponseToSDK converts the mirror to the sdk-go type. +func ListProvidersResponseToSDK(w *ListProvidersResponse) (*sdk.ListProvidersResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListProvidersResponse{} + conv79, err := convertSlice(w.Providers, ProviderInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProvidersResponse.Providers", err) + } + out.Providers = conv79 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListProvidersResponseFromSDK converts the sdk-go type to the mirror. +func ListProvidersResponseFromSDK(v *sdk.ListProvidersResponse) (*ListProvidersResponse, error) { + if v == nil { + return nil, nil + } + out := &ListProvidersResponse{} + conv80, err := convertSlice(v.Providers, ProviderInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProvidersResponse.Providers", err) + } + out.Providers = conv80 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListPublishedListingsForConsumerRequestToSDK converts the mirror to the sdk-go type. +func ListPublishedListingsForConsumerRequestToSDK(w *ListPublishedListingsForConsumerRequest) (*sdk.ListPublishedListingsForConsumerRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPublishedListingsForConsumerRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + out.Assets = w.Assets + out.Categories = w.Categories + conv81, err := ListingTagToSDK(w.Tags) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPublishedListingsForConsumerRequest.Tags", err) + } + out.Tags = conv81 + out.IsFree = w.IsFree + out.IsPrivateExchange = w.IsPrivateExchange + out.IsStaffPick = w.IsStaffPick + out.ProviderIds = w.ProviderIds + return out, nil +} + +// ListPublishedListingsForConsumerRequestFromSDK converts the sdk-go type to the mirror. +func ListPublishedListingsForConsumerRequestFromSDK(v *sdk.ListPublishedListingsForConsumerRequest) (*ListPublishedListingsForConsumerRequest, error) { + if v == nil { + return nil, nil + } + out := &ListPublishedListingsForConsumerRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + out.Assets = v.Assets + out.Categories = v.Categories + conv82, err := ListingTagFromSDK(v.Tags) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPublishedListingsForConsumerRequest.Tags", err) + } + out.Tags = conv82 + out.IsFree = v.IsFree + out.IsPrivateExchange = v.IsPrivateExchange + out.IsStaffPick = v.IsStaffPick + out.ProviderIds = v.ProviderIds + return out, nil +} + +// ListPublishedProvidersForConsumerRequestToSDK converts the mirror to the sdk-go type. +func ListPublishedProvidersForConsumerRequestToSDK(w *ListPublishedProvidersForConsumerRequest) (*sdk.ListPublishedProvidersForConsumerRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPublishedProvidersForConsumerRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + out.IsFeatured = w.IsFeatured + return out, nil +} + +// ListPublishedProvidersForConsumerRequestFromSDK converts the sdk-go type to the mirror. +func ListPublishedProvidersForConsumerRequestFromSDK(v *sdk.ListPublishedProvidersForConsumerRequest) (*ListPublishedProvidersForConsumerRequest, error) { + if v == nil { + return nil, nil + } + out := &ListPublishedProvidersForConsumerRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + out.IsFeatured = v.IsFeatured + return out, nil +} + +// ListPublishedProvidersForConsumerResponseToSDK converts the mirror to the sdk-go type. +func ListPublishedProvidersForConsumerResponseToSDK(w *ListPublishedProvidersForConsumerResponse) (*sdk.ListPublishedProvidersForConsumerResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPublishedProvidersForConsumerResponse{} + conv83, err := convertSlice(w.Providers, ProviderInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPublishedProvidersForConsumerResponse.Providers", err) + } + out.Providers = conv83 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListPublishedProvidersForConsumerResponseFromSDK converts the sdk-go type to the mirror. +func ListPublishedProvidersForConsumerResponseFromSDK(v *sdk.ListPublishedProvidersForConsumerResponse) (*ListPublishedProvidersForConsumerResponse, error) { + if v == nil { + return nil, nil + } + out := &ListPublishedProvidersForConsumerResponse{} + conv84, err := convertSlice(v.Providers, ProviderInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPublishedProvidersForConsumerResponse.Providers", err) + } + out.Providers = conv84 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListingToSDK converts the mirror to the sdk-go type. +func ListingToSDK(w *Listing) (*sdk.Listing, error) { + if w == nil { + return nil, nil + } + out := &sdk.Listing{} + out.Id = w.Id + conv85, err := ListingSummaryToSDK(w.Summary) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Listing.Summary", err) + } + out.Summary = conv85 + conv86, err := ListingDetailToSDK(w.Detail) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Listing.Detail", err) + } + out.Detail = conv86 + return out, nil +} + +// ListingFromSDK converts the sdk-go type to the mirror. +func ListingFromSDK(v *sdk.Listing) (*Listing, error) { + if v == nil { + return nil, nil + } + out := &Listing{} + out.Id = v.Id + conv87, err := ListingSummaryFromSDK(v.Summary) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Listing.Summary", err) + } + out.Summary = conv87 + conv88, err := ListingDetailFromSDK(v.Detail) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Listing.Detail", err) + } + out.Detail = conv88 + return out, nil +} + +// ListingDetailToSDK converts the mirror to the sdk-go type. +func ListingDetailToSDK(w *ListingDetail) (*sdk.ListingDetail, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListingDetail{} + out.Description = w.Description + out.TermsOfService = w.TermsOfService + out.DocumentationLink = w.DocumentationLink + out.SupportLink = w.SupportLink + out.FileIds = w.FileIds + out.PrivacyPolicyLink = w.PrivacyPolicyLink + conv89, err := convertSlice(w.EmbeddedNotebookFileInfos, FileInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingDetail.EmbeddedNotebookFileInfos", err) + } + out.EmbeddedNotebookFileInfos = conv89 + out.GeographicalCoverage = w.GeographicalCoverage + out.Cost = w.Cost + out.PricingModel = w.PricingModel + conv90, err := DataRefreshInfoToSDK(w.UpdateFrequency) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingDetail.UpdateFrequency", err) + } + out.UpdateFrequency = conv90 + conv91, err := DataRefreshInfoToSDK(w.CollectionGranularity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingDetail.CollectionGranularity", err) + } + out.CollectionGranularity = conv91 + out.CollectionDateStart = w.CollectionDateStart + out.CollectionDateEnd = w.CollectionDateEnd + out.DataSource = w.DataSource + out.Size = w.Size + out.Assets = w.Assets + out.License = w.License + conv92, err := convertSlice(w.Tags, ListingTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingDetail.Tags", err) + } + out.Tags = conv92 + return out, nil +} + +// ListingDetailFromSDK converts the sdk-go type to the mirror. +func ListingDetailFromSDK(v *sdk.ListingDetail) (*ListingDetail, error) { + if v == nil { + return nil, nil + } + out := &ListingDetail{} + out.Description = v.Description + out.TermsOfService = v.TermsOfService + out.DocumentationLink = v.DocumentationLink + out.SupportLink = v.SupportLink + out.FileIds = v.FileIds + out.PrivacyPolicyLink = v.PrivacyPolicyLink + conv93, err := convertSlice(v.EmbeddedNotebookFileInfos, FileInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingDetail.EmbeddedNotebookFileInfos", err) + } + out.EmbeddedNotebookFileInfos = conv93 + out.GeographicalCoverage = v.GeographicalCoverage + out.Cost = v.Cost + out.PricingModel = v.PricingModel + conv94, err := DataRefreshInfoFromSDK(v.UpdateFrequency) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingDetail.UpdateFrequency", err) + } + out.UpdateFrequency = conv94 + conv95, err := DataRefreshInfoFromSDK(v.CollectionGranularity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingDetail.CollectionGranularity", err) + } + out.CollectionGranularity = conv95 + out.CollectionDateStart = v.CollectionDateStart + out.CollectionDateEnd = v.CollectionDateEnd + out.DataSource = v.DataSource + out.Size = v.Size + out.Assets = v.Assets + out.License = v.License + conv96, err := convertSlice(v.Tags, ListingTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingDetail.Tags", err) + } + out.Tags = conv96 + return out, nil +} + +// ListingFulfillmentToSDK converts the mirror to the sdk-go type. +func ListingFulfillmentToSDK(w *ListingFulfillment) (*sdk.ListingFulfillment, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListingFulfillment{} + out.ListingId = w.ListingId + out.FulfillmentType = w.FulfillmentType + conv97, err := ShareInfoToSDK(w.ShareInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingFulfillment.ShareInfo", err) + } + out.ShareInfo = conv97 + conv98, err := RepoInfoToSDK(w.RepoInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingFulfillment.RepoInfo", err) + } + out.RepoInfo = conv98 + out.RecipientType = w.RecipientType + return out, nil +} + +// ListingFulfillmentFromSDK converts the sdk-go type to the mirror. +func ListingFulfillmentFromSDK(v *sdk.ListingFulfillment) (*ListingFulfillment, error) { + if v == nil { + return nil, nil + } + out := &ListingFulfillment{} + out.ListingId = v.ListingId + out.FulfillmentType = v.FulfillmentType + conv99, err := ShareInfoFromSDK(v.ShareInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingFulfillment.ShareInfo", err) + } + out.ShareInfo = conv99 + conv100, err := RepoInfoFromSDK(v.RepoInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingFulfillment.RepoInfo", err) + } + out.RepoInfo = conv100 + out.RecipientType = v.RecipientType + return out, nil +} + +// ListingSettingToSDK converts the mirror to the sdk-go type. +func ListingSettingToSDK(w *ListingSetting) (*sdk.ListingSetting, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListingSetting{} + out.Visibility = w.Visibility + return out, nil +} + +// ListingSettingFromSDK converts the sdk-go type to the mirror. +func ListingSettingFromSDK(v *sdk.ListingSetting) (*ListingSetting, error) { + if v == nil { + return nil, nil + } + out := &ListingSetting{} + out.Visibility = v.Visibility + return out, nil +} + +// ListingSummaryToSDK converts the mirror to the sdk-go type. +func ListingSummaryToSDK(w *ListingSummary) (*sdk.ListingSummary, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListingSummary{} + out.Name = w.Name + out.Subtitle = w.Subtitle + out.Status = w.Status + conv101, err := ShareInfoToSDK(w.Share) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingSummary.Share", err) + } + out.Share = conv101 + conv102, err := RegionInfoToSDK(w.ProviderRegion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingSummary.ProviderRegion", err) + } + out.ProviderRegion = conv102 + conv103, err := ListingSettingToSDK(w.Setting) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingSummary.Setting", err) + } + out.Setting = conv103 + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.PublishedAt = w.PublishedAt + out.PublishedBy = w.PublishedBy + out.Categories = w.Categories + out.ListingType = w.ListingType + out.CreatedById = w.CreatedById + out.UpdatedById = w.UpdatedById + out.ProviderId = w.ProviderId + out.ExchangeIds = w.ExchangeIds + conv104, err := RepoInfoToSDK(w.GitRepo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingSummary.GitRepo", err) + } + out.GitRepo = conv104 + return out, nil +} + +// ListingSummaryFromSDK converts the sdk-go type to the mirror. +func ListingSummaryFromSDK(v *sdk.ListingSummary) (*ListingSummary, error) { + if v == nil { + return nil, nil + } + out := &ListingSummary{} + out.Name = v.Name + out.Subtitle = v.Subtitle + out.Status = v.Status + conv105, err := ShareInfoFromSDK(v.Share) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingSummary.Share", err) + } + out.Share = conv105 + conv106, err := RegionInfoFromSDK(v.ProviderRegion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingSummary.ProviderRegion", err) + } + out.ProviderRegion = conv106 + conv107, err := ListingSettingFromSDK(v.Setting) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingSummary.Setting", err) + } + out.Setting = conv107 + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.PublishedAt = v.PublishedAt + out.PublishedBy = v.PublishedBy + out.Categories = v.Categories + out.ListingType = v.ListingType + out.CreatedById = v.CreatedById + out.UpdatedById = v.UpdatedById + out.ProviderId = v.ProviderId + out.ExchangeIds = v.ExchangeIds + conv108, err := RepoInfoFromSDK(v.GitRepo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListingSummary.GitRepo", err) + } + out.GitRepo = conv108 + return out, nil +} + +// ListingTagToSDK converts the mirror to the sdk-go type. +func ListingTagToSDK(w *ListingTag) (*sdk.ListingTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListingTag{} + out.TagName = w.TagName + out.TagValues = w.TagValues + return out, nil +} + +// ListingTagFromSDK converts the sdk-go type to the mirror. +func ListingTagFromSDK(v *sdk.ListingTag) (*ListingTag, error) { + if v == nil { + return nil, nil + } + out := &ListingTag{} + out.TagName = v.TagName + out.TagValues = v.TagValues + return out, nil +} + +// PersonalizationRequestToSDK converts the mirror to the sdk-go type. +func PersonalizationRequestToSDK(w *PersonalizationRequest) (*sdk.PersonalizationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PersonalizationRequest{} + out.Id = w.Id + conv109, err := RegionInfoToSDK(w.ConsumerRegion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PersonalizationRequest.ConsumerRegion", err) + } + out.ConsumerRegion = conv109 + conv110, err := ContactInfoToSDK(w.ContactInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PersonalizationRequest.ContactInfo", err) + } + out.ContactInfo = conv110 + out.Comment = w.Comment + out.IntendedUse = w.IntendedUse + out.Status = w.Status + out.StatusMessage = w.StatusMessage + conv111, err := ShareInfoToSDK(w.Share) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PersonalizationRequest.Share", err) + } + out.Share = conv111 + out.CreatedAt = w.CreatedAt + out.ListingId = w.ListingId + out.UpdatedAt = w.UpdatedAt + out.MetastoreId = w.MetastoreId + out.ListingName = w.ListingName + out.IsFromLighthouse = w.IsFromLighthouse + out.ProviderId = w.ProviderId + out.RecipientType = w.RecipientType + return out, nil +} + +// PersonalizationRequestFromSDK converts the sdk-go type to the mirror. +func PersonalizationRequestFromSDK(v *sdk.PersonalizationRequest) (*PersonalizationRequest, error) { + if v == nil { + return nil, nil + } + out := &PersonalizationRequest{} + out.Id = v.Id + conv112, err := RegionInfoFromSDK(v.ConsumerRegion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PersonalizationRequest.ConsumerRegion", err) + } + out.ConsumerRegion = conv112 + conv113, err := ContactInfoFromSDK(v.ContactInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PersonalizationRequest.ContactInfo", err) + } + out.ContactInfo = conv113 + out.Comment = v.Comment + out.IntendedUse = v.IntendedUse + out.Status = v.Status + out.StatusMessage = v.StatusMessage + conv114, err := ShareInfoFromSDK(v.Share) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PersonalizationRequest.Share", err) + } + out.Share = conv114 + out.CreatedAt = v.CreatedAt + out.ListingId = v.ListingId + out.UpdatedAt = v.UpdatedAt + out.MetastoreId = v.MetastoreId + out.ListingName = v.ListingName + out.IsFromLighthouse = v.IsFromLighthouse + out.ProviderId = v.ProviderId + out.RecipientType = v.RecipientType + return out, nil +} + +// ProviderInfoToSDK converts the mirror to the sdk-go type. +func ProviderInfoToSDK(w *ProviderInfo) (*sdk.ProviderInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProviderInfo{} + out.Id = w.Id + out.Name = w.Name + out.Description = w.Description + out.IconFilePath = w.IconFilePath + out.BusinessContactEmail = w.BusinessContactEmail + out.SupportContactEmail = w.SupportContactEmail + out.IsFeatured = w.IsFeatured + out.PublishedBy = w.PublishedBy + out.CompanyWebsiteLink = w.CompanyWebsiteLink + out.IconFileId = w.IconFileId + out.TermOfServiceLink = w.TermOfServiceLink + out.PrivacyPolicyLink = w.PrivacyPolicyLink + out.DarkModeIconFileId = w.DarkModeIconFileId + out.DarkModeIconFilePath = w.DarkModeIconFilePath + return out, nil +} + +// ProviderInfoFromSDK converts the sdk-go type to the mirror. +func ProviderInfoFromSDK(v *sdk.ProviderInfo) (*ProviderInfo, error) { + if v == nil { + return nil, nil + } + out := &ProviderInfo{} + out.Id = v.Id + out.Name = v.Name + out.Description = v.Description + out.IconFilePath = v.IconFilePath + out.BusinessContactEmail = v.BusinessContactEmail + out.SupportContactEmail = v.SupportContactEmail + out.IsFeatured = v.IsFeatured + out.PublishedBy = v.PublishedBy + out.CompanyWebsiteLink = v.CompanyWebsiteLink + out.IconFileId = v.IconFileId + out.TermOfServiceLink = v.TermOfServiceLink + out.PrivacyPolicyLink = v.PrivacyPolicyLink + out.DarkModeIconFileId = v.DarkModeIconFileId + out.DarkModeIconFilePath = v.DarkModeIconFilePath + return out, nil +} + +// RegionInfoToSDK converts the mirror to the sdk-go type. +func RegionInfoToSDK(w *RegionInfo) (*sdk.RegionInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.RegionInfo{} + out.Cloud = w.Cloud + out.Region = w.Region + return out, nil +} + +// RegionInfoFromSDK converts the sdk-go type to the mirror. +func RegionInfoFromSDK(v *sdk.RegionInfo) (*RegionInfo, error) { + if v == nil { + return nil, nil + } + out := &RegionInfo{} + out.Cloud = v.Cloud + out.Region = v.Region + return out, nil +} + +// RepoInfoToSDK converts the mirror to the sdk-go type. +func RepoInfoToSDK(w *RepoInfo) (*sdk.RepoInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.RepoInfo{} + out.GitRepoUrl = w.GitRepoUrl + return out, nil +} + +// RepoInfoFromSDK converts the sdk-go type to the mirror. +func RepoInfoFromSDK(v *sdk.RepoInfo) (*RepoInfo, error) { + if v == nil { + return nil, nil + } + out := &RepoInfo{} + out.GitRepoUrl = v.GitRepoUrl + return out, nil +} + +// RepoInstallationToSDK converts the mirror to the sdk-go type. +func RepoInstallationToSDK(w *RepoInstallation) (*sdk.RepoInstallation, error) { + if w == nil { + return nil, nil + } + out := &sdk.RepoInstallation{} + out.RepoName = w.RepoName + out.RepoPath = w.RepoPath + return out, nil +} + +// RepoInstallationFromSDK converts the sdk-go type to the mirror. +func RepoInstallationFromSDK(v *sdk.RepoInstallation) (*RepoInstallation, error) { + if v == nil { + return nil, nil + } + out := &RepoInstallation{} + out.RepoName = v.RepoName + out.RepoPath = v.RepoPath + return out, nil +} + +// SearchPublishedListingsForConsumerRequestToSDK converts the mirror to the sdk-go type. +func SearchPublishedListingsForConsumerRequestToSDK(w *SearchPublishedListingsForConsumerRequest) (*sdk.SearchPublishedListingsForConsumerRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchPublishedListingsForConsumerRequest{} + out.Query = w.Query + out.IsFree = w.IsFree + out.IsPrivateExchange = w.IsPrivateExchange + out.ProviderIds = w.ProviderIds + out.Categories = w.Categories + out.Assets = w.Assets + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// SearchPublishedListingsForConsumerRequestFromSDK converts the sdk-go type to the mirror. +func SearchPublishedListingsForConsumerRequestFromSDK(v *sdk.SearchPublishedListingsForConsumerRequest) (*SearchPublishedListingsForConsumerRequest, error) { + if v == nil { + return nil, nil + } + out := &SearchPublishedListingsForConsumerRequest{} + out.Query = v.Query + out.IsFree = v.IsFree + out.IsPrivateExchange = v.IsPrivateExchange + out.ProviderIds = v.ProviderIds + out.Categories = v.Categories + out.Assets = v.Assets + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// SearchPublishedListingsForConsumerResponseToSDK converts the mirror to the sdk-go type. +func SearchPublishedListingsForConsumerResponseToSDK(w *SearchPublishedListingsForConsumerResponse) (*sdk.SearchPublishedListingsForConsumerResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchPublishedListingsForConsumerResponse{} + conv115, err := convertSlice(w.Listings, ListingToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchPublishedListingsForConsumerResponse.Listings", err) + } + out.Listings = conv115 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// SearchPublishedListingsForConsumerResponseFromSDK converts the sdk-go type to the mirror. +func SearchPublishedListingsForConsumerResponseFromSDK(v *sdk.SearchPublishedListingsForConsumerResponse) (*SearchPublishedListingsForConsumerResponse, error) { + if v == nil { + return nil, nil + } + out := &SearchPublishedListingsForConsumerResponse{} + conv116, err := convertSlice(v.Listings, ListingFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchPublishedListingsForConsumerResponse.Listings", err) + } + out.Listings = conv116 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ShareInfoToSDK converts the mirror to the sdk-go type. +func ShareInfoToSDK(w *ShareInfo) (*sdk.ShareInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ShareInfo{} + out.Name = w.Name + out.Type = w.Type + return out, nil +} + +// ShareInfoFromSDK converts the sdk-go type to the mirror. +func ShareInfoFromSDK(v *sdk.ShareInfo) (*ShareInfo, error) { + if v == nil { + return nil, nil + } + out := &ShareInfo{} + out.Name = v.Name + out.Type = v.Type + return out, nil +} + +// SharedDataObjectToSDK converts the mirror to the sdk-go type. +func SharedDataObjectToSDK(w *SharedDataObject) (*sdk.SharedDataObject, error) { + if w == nil { + return nil, nil + } + out := &sdk.SharedDataObject{} + out.Name = w.Name + out.DataObjectType = w.DataObjectType + return out, nil +} + +// SharedDataObjectFromSDK converts the sdk-go type to the mirror. +func SharedDataObjectFromSDK(v *sdk.SharedDataObject) (*SharedDataObject, error) { + if v == nil { + return nil, nil + } + out := &SharedDataObject{} + out.Name = v.Name + out.DataObjectType = v.DataObjectType + return out, nil +} + +// TokenDetailToSDK converts the mirror to the sdk-go type. +func TokenDetailToSDK(w *TokenDetail) (*sdk.TokenDetail, error) { + if w == nil { + return nil, nil + } + out := &sdk.TokenDetail{} + out.ShareCredentialsVersion = w.ShareCredentialsVersion + out.BearerToken = w.BearerToken + out.Endpoint = w.Endpoint + out.ExpirationTime = w.ExpirationTime + return out, nil +} + +// TokenDetailFromSDK converts the sdk-go type to the mirror. +func TokenDetailFromSDK(v *sdk.TokenDetail) (*TokenDetail, error) { + if v == nil { + return nil, nil + } + out := &TokenDetail{} + out.ShareCredentialsVersion = v.ShareCredentialsVersion + out.BearerToken = v.BearerToken + out.Endpoint = v.Endpoint + out.ExpirationTime = v.ExpirationTime + return out, nil +} + +// TokenInfoToSDK converts the mirror to the sdk-go type. +func TokenInfoToSDK(w *TokenInfo) (*sdk.TokenInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.TokenInfo{} + out.Id = w.Id + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.ActivationUrl = w.ActivationUrl + out.ExpirationTime = w.ExpirationTime + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + return out, nil +} + +// TokenInfoFromSDK converts the sdk-go type to the mirror. +func TokenInfoFromSDK(v *sdk.TokenInfo) (*TokenInfo, error) { + if v == nil { + return nil, nil + } + out := &TokenInfo{} + out.Id = v.Id + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.ActivationUrl = v.ActivationUrl + out.ExpirationTime = v.ExpirationTime + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + return out, nil +} + +// UpdateExchangeFilterRequestToSDK converts the mirror to the sdk-go type. +func UpdateExchangeFilterRequestToSDK(w *UpdateExchangeFilterRequest) (*sdk.UpdateExchangeFilterRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateExchangeFilterRequest{} + out.Id = w.Id + conv117, err := ExchangeFilterToSDK(w.Filter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExchangeFilterRequest.Filter", err) + } + out.Filter = conv117 + return out, nil +} + +// UpdateExchangeFilterRequestFromSDK converts the sdk-go type to the mirror. +func UpdateExchangeFilterRequestFromSDK(v *sdk.UpdateExchangeFilterRequest) (*UpdateExchangeFilterRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateExchangeFilterRequest{} + out.Id = v.Id + conv118, err := ExchangeFilterFromSDK(v.Filter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExchangeFilterRequest.Filter", err) + } + out.Filter = conv118 + return out, nil +} + +// UpdateExchangeFilterResponseToSDK converts the mirror to the sdk-go type. +func UpdateExchangeFilterResponseToSDK(w *UpdateExchangeFilterResponse) (*sdk.UpdateExchangeFilterResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateExchangeFilterResponse{} + conv119, err := ExchangeFilterToSDK(w.Filter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExchangeFilterResponse.Filter", err) + } + out.Filter = conv119 + return out, nil +} + +// UpdateExchangeFilterResponseFromSDK converts the sdk-go type to the mirror. +func UpdateExchangeFilterResponseFromSDK(v *sdk.UpdateExchangeFilterResponse) (*UpdateExchangeFilterResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateExchangeFilterResponse{} + conv120, err := ExchangeFilterFromSDK(v.Filter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExchangeFilterResponse.Filter", err) + } + out.Filter = conv120 + return out, nil +} + +// UpdateExchangeRequestToSDK converts the mirror to the sdk-go type. +func UpdateExchangeRequestToSDK(w *UpdateExchangeRequest) (*sdk.UpdateExchangeRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateExchangeRequest{} + out.Id = w.Id + conv121, err := ExchangeToSDK(w.Exchange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExchangeRequest.Exchange", err) + } + out.Exchange = conv121 + return out, nil +} + +// UpdateExchangeRequestFromSDK converts the sdk-go type to the mirror. +func UpdateExchangeRequestFromSDK(v *sdk.UpdateExchangeRequest) (*UpdateExchangeRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateExchangeRequest{} + out.Id = v.Id + conv122, err := ExchangeFromSDK(v.Exchange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExchangeRequest.Exchange", err) + } + out.Exchange = conv122 + return out, nil +} + +// UpdateExchangeResponseToSDK converts the mirror to the sdk-go type. +func UpdateExchangeResponseToSDK(w *UpdateExchangeResponse) (*sdk.UpdateExchangeResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateExchangeResponse{} + conv123, err := ExchangeToSDK(w.Exchange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExchangeResponse.Exchange", err) + } + out.Exchange = conv123 + return out, nil +} + +// UpdateExchangeResponseFromSDK converts the sdk-go type to the mirror. +func UpdateExchangeResponseFromSDK(v *sdk.UpdateExchangeResponse) (*UpdateExchangeResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateExchangeResponse{} + conv124, err := ExchangeFromSDK(v.Exchange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExchangeResponse.Exchange", err) + } + out.Exchange = conv124 + return out, nil +} + +// UpdateInstallationRequestToSDK converts the mirror to the sdk-go type. +func UpdateInstallationRequestToSDK(w *UpdateInstallationRequest) (*sdk.UpdateInstallationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateInstallationRequest{} + out.ListingId = w.ListingId + out.InstallationId = w.InstallationId + conv125, err := InstallationDetailToSDK(w.Installation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateInstallationRequest.Installation", err) + } + out.Installation = conv125 + out.RotateToken = w.RotateToken + return out, nil +} + +// UpdateInstallationRequestFromSDK converts the sdk-go type to the mirror. +func UpdateInstallationRequestFromSDK(v *sdk.UpdateInstallationRequest) (*UpdateInstallationRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateInstallationRequest{} + out.ListingId = v.ListingId + out.InstallationId = v.InstallationId + conv126, err := InstallationDetailFromSDK(v.Installation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateInstallationRequest.Installation", err) + } + out.Installation = conv126 + out.RotateToken = v.RotateToken + return out, nil +} + +// UpdateInstallationResponseToSDK converts the mirror to the sdk-go type. +func UpdateInstallationResponseToSDK(w *UpdateInstallationResponse) (*sdk.UpdateInstallationResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateInstallationResponse{} + conv127, err := InstallationDetailToSDK(w.Installation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateInstallationResponse.Installation", err) + } + out.Installation = conv127 + return out, nil +} + +// UpdateInstallationResponseFromSDK converts the sdk-go type to the mirror. +func UpdateInstallationResponseFromSDK(v *sdk.UpdateInstallationResponse) (*UpdateInstallationResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateInstallationResponse{} + conv128, err := InstallationDetailFromSDK(v.Installation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateInstallationResponse.Installation", err) + } + out.Installation = conv128 + return out, nil +} + +// UpdateListingRequestToSDK converts the mirror to the sdk-go type. +func UpdateListingRequestToSDK(w *UpdateListingRequest) (*sdk.UpdateListingRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateListingRequest{} + out.Id = w.Id + conv129, err := ListingToSDK(w.Listing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateListingRequest.Listing", err) + } + out.Listing = conv129 + return out, nil +} + +// UpdateListingRequestFromSDK converts the sdk-go type to the mirror. +func UpdateListingRequestFromSDK(v *sdk.UpdateListingRequest) (*UpdateListingRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateListingRequest{} + out.Id = v.Id + conv130, err := ListingFromSDK(v.Listing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateListingRequest.Listing", err) + } + out.Listing = conv130 + return out, nil +} + +// UpdateListingResponseToSDK converts the mirror to the sdk-go type. +func UpdateListingResponseToSDK(w *UpdateListingResponse) (*sdk.UpdateListingResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateListingResponse{} + conv131, err := ListingToSDK(w.Listing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateListingResponse.Listing", err) + } + out.Listing = conv131 + return out, nil +} + +// UpdateListingResponseFromSDK converts the sdk-go type to the mirror. +func UpdateListingResponseFromSDK(v *sdk.UpdateListingResponse) (*UpdateListingResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateListingResponse{} + conv132, err := ListingFromSDK(v.Listing) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateListingResponse.Listing", err) + } + out.Listing = conv132 + return out, nil +} + +// UpdatePersonalizationRequestStatusRequestToSDK converts the mirror to the sdk-go type. +func UpdatePersonalizationRequestStatusRequestToSDK(w *UpdatePersonalizationRequestStatusRequest) (*sdk.UpdatePersonalizationRequestStatusRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdatePersonalizationRequestStatusRequest{} + out.ListingId = w.ListingId + out.RequestId = w.RequestId + out.Status = w.Status + out.Reason = w.Reason + conv133, err := ShareInfoToSDK(w.Share) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePersonalizationRequestStatusRequest.Share", err) + } + out.Share = conv133 + return out, nil +} + +// UpdatePersonalizationRequestStatusRequestFromSDK converts the sdk-go type to the mirror. +func UpdatePersonalizationRequestStatusRequestFromSDK(v *sdk.UpdatePersonalizationRequestStatusRequest) (*UpdatePersonalizationRequestStatusRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdatePersonalizationRequestStatusRequest{} + out.ListingId = v.ListingId + out.RequestId = v.RequestId + out.Status = v.Status + out.Reason = v.Reason + conv134, err := ShareInfoFromSDK(v.Share) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePersonalizationRequestStatusRequest.Share", err) + } + out.Share = conv134 + return out, nil +} + +// UpdatePersonalizationRequestStatusResponseToSDK converts the mirror to the sdk-go type. +func UpdatePersonalizationRequestStatusResponseToSDK(w *UpdatePersonalizationRequestStatusResponse) (*sdk.UpdatePersonalizationRequestStatusResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdatePersonalizationRequestStatusResponse{} + conv135, err := PersonalizationRequestToSDK(w.Request) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePersonalizationRequestStatusResponse.Request", err) + } + out.Request = conv135 + return out, nil +} + +// UpdatePersonalizationRequestStatusResponseFromSDK converts the sdk-go type to the mirror. +func UpdatePersonalizationRequestStatusResponseFromSDK(v *sdk.UpdatePersonalizationRequestStatusResponse) (*UpdatePersonalizationRequestStatusResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdatePersonalizationRequestStatusResponse{} + conv136, err := PersonalizationRequestFromSDK(v.Request) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePersonalizationRequestStatusResponse.Request", err) + } + out.Request = conv136 + return out, nil +} + +// UpdateProviderAnalyticsDashboardRequestToSDK converts the mirror to the sdk-go type. +func UpdateProviderAnalyticsDashboardRequestToSDK(w *UpdateProviderAnalyticsDashboardRequest) (*sdk.UpdateProviderAnalyticsDashboardRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateProviderAnalyticsDashboardRequest{} + out.Id = w.Id + out.Version = w.Version + return out, nil +} + +// UpdateProviderAnalyticsDashboardRequestFromSDK converts the sdk-go type to the mirror. +func UpdateProviderAnalyticsDashboardRequestFromSDK(v *sdk.UpdateProviderAnalyticsDashboardRequest) (*UpdateProviderAnalyticsDashboardRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateProviderAnalyticsDashboardRequest{} + out.Id = v.Id + out.Version = v.Version + return out, nil +} + +// UpdateProviderAnalyticsDashboardResponseToSDK converts the mirror to the sdk-go type. +func UpdateProviderAnalyticsDashboardResponseToSDK(w *UpdateProviderAnalyticsDashboardResponse) (*sdk.UpdateProviderAnalyticsDashboardResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateProviderAnalyticsDashboardResponse{} + out.Id = w.Id + out.Version = w.Version + out.DashboardId = w.DashboardId + return out, nil +} + +// UpdateProviderAnalyticsDashboardResponseFromSDK converts the sdk-go type to the mirror. +func UpdateProviderAnalyticsDashboardResponseFromSDK(v *sdk.UpdateProviderAnalyticsDashboardResponse) (*UpdateProviderAnalyticsDashboardResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateProviderAnalyticsDashboardResponse{} + out.Id = v.Id + out.Version = v.Version + out.DashboardId = v.DashboardId + return out, nil +} + +// UpdateProviderRequestToSDK converts the mirror to the sdk-go type. +func UpdateProviderRequestToSDK(w *UpdateProviderRequest) (*sdk.UpdateProviderRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateProviderRequest{} + out.Id = w.Id + conv137, err := ProviderInfoToSDK(w.Provider) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateProviderRequest.Provider", err) + } + out.Provider = conv137 + return out, nil +} + +// UpdateProviderRequestFromSDK converts the sdk-go type to the mirror. +func UpdateProviderRequestFromSDK(v *sdk.UpdateProviderRequest) (*UpdateProviderRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateProviderRequest{} + out.Id = v.Id + conv138, err := ProviderInfoFromSDK(v.Provider) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateProviderRequest.Provider", err) + } + out.Provider = conv138 + return out, nil +} + +// UpdateProviderResponseToSDK converts the mirror to the sdk-go type. +func UpdateProviderResponseToSDK(w *UpdateProviderResponse) (*sdk.UpdateProviderResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateProviderResponse{} + conv139, err := ProviderInfoToSDK(w.Provider) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateProviderResponse.Provider", err) + } + out.Provider = conv139 + return out, nil +} + +// UpdateProviderResponseFromSDK converts the sdk-go type to the mirror. +func UpdateProviderResponseFromSDK(v *sdk.UpdateProviderResponse) (*UpdateProviderResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateProviderResponse{} + conv140, err := ProviderInfoFromSDK(v.Provider) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateProviderResponse.Provider", err) + } + out.Provider = conv140 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/modelregistry/v1/types.generated.go b/libs/sdktypes/modelregistry/v1/types.generated.go new file mode 100644 index 00000000000..346b9fbf26e --- /dev/null +++ b/libs/sdktypes/modelregistry/v1/types.generated.go @@ -0,0 +1,2943 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/modelregistry/v1. DO NOT EDIT. + +package modelregistry + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/modelregistry/v1" +) + +type ( + ActivityAction = sdk.ActivityAction + ActivityType = sdk.ActivityType + ModelVersionStatus = sdk.ModelVersionStatus + PermissionLevel = sdk.PermissionLevel + RegistryEmailSubscriptionType = sdk.RegistryEmailSubscriptionType + RegistryWebhookEvent = sdk.RegistryWebhookEvent + RegistryWebhookStatus = sdk.RegistryWebhookStatus +) + +const ( + ActivityAction_Unspecified = sdk.ActivityAction_Unspecified + ActivityAction_ApproveTransitionRequest = sdk.ActivityAction_ApproveTransitionRequest + ActivityAction_RejectTransitionRequest = sdk.ActivityAction_RejectTransitionRequest + ActivityAction_CancelTransitionRequest = sdk.ActivityAction_CancelTransitionRequest + ActivityAction_EditComment = sdk.ActivityAction_EditComment + ActivityAction_DeleteComment = sdk.ActivityAction_DeleteComment + ActivityType_Unspecified = sdk.ActivityType_Unspecified + ActivityType_AppliedTransition = sdk.ActivityType_AppliedTransition + ActivityType_RequestedTransition = sdk.ActivityType_RequestedTransition + ActivityType_CancelledRequest = sdk.ActivityType_CancelledRequest + ActivityType_ApprovedRequest = sdk.ActivityType_ApprovedRequest + ActivityType_RejectedRequest = sdk.ActivityType_RejectedRequest + ActivityType_NewComment = sdk.ActivityType_NewComment + ActivityType_SystemTransition = sdk.ActivityType_SystemTransition + ModelVersionStatus_Unspecified = sdk.ModelVersionStatus_Unspecified + ModelVersionStatus_PendingRegistration = sdk.ModelVersionStatus_PendingRegistration + ModelVersionStatus_FailedRegistration = sdk.ModelVersionStatus_FailedRegistration + ModelVersionStatus_Ready = sdk.ModelVersionStatus_Ready + PermissionLevel_Unspecified = sdk.PermissionLevel_Unspecified + PermissionLevel_CanEdit = sdk.PermissionLevel_CanEdit + PermissionLevel_CanRead = sdk.PermissionLevel_CanRead + PermissionLevel_CanManageStagingVersions = sdk.PermissionLevel_CanManageStagingVersions + PermissionLevel_CanManageProductionVersions = sdk.PermissionLevel_CanManageProductionVersions + PermissionLevel_CanCreateRegisteredModel = sdk.PermissionLevel_CanCreateRegisteredModel + RegistryEmailSubscriptionType_Unspecified = sdk.RegistryEmailSubscriptionType_Unspecified + RegistryEmailSubscriptionType_AllEvents = sdk.RegistryEmailSubscriptionType_AllEvents + RegistryEmailSubscriptionType_Default = sdk.RegistryEmailSubscriptionType_Default + RegistryEmailSubscriptionType_Subscribed = sdk.RegistryEmailSubscriptionType_Subscribed + RegistryEmailSubscriptionType_Unsubscribed = sdk.RegistryEmailSubscriptionType_Unsubscribed + RegistryWebhookEvent_Unspecified = sdk.RegistryWebhookEvent_Unspecified + RegistryWebhookEvent_ModelVersionCreated = sdk.RegistryWebhookEvent_ModelVersionCreated + RegistryWebhookEvent_ModelVersionTransitionedStage = sdk.RegistryWebhookEvent_ModelVersionTransitionedStage + RegistryWebhookEvent_TransitionRequestCreated = sdk.RegistryWebhookEvent_TransitionRequestCreated + RegistryWebhookEvent_CommentCreated = sdk.RegistryWebhookEvent_CommentCreated + RegistryWebhookEvent_RegisteredModelCreated = sdk.RegistryWebhookEvent_RegisteredModelCreated + RegistryWebhookEvent_ModelVersionTagSet = sdk.RegistryWebhookEvent_ModelVersionTagSet + RegistryWebhookEvent_ModelVersionTransitionedToStaging = sdk.RegistryWebhookEvent_ModelVersionTransitionedToStaging + RegistryWebhookEvent_ModelVersionTransitionedToProduction = sdk.RegistryWebhookEvent_ModelVersionTransitionedToProduction + RegistryWebhookEvent_ModelVersionTransitionedToArchived = sdk.RegistryWebhookEvent_ModelVersionTransitionedToArchived + RegistryWebhookEvent_TransitionRequestToStagingCreated = sdk.RegistryWebhookEvent_TransitionRequestToStagingCreated + RegistryWebhookEvent_TransitionRequestToProductionCreated = sdk.RegistryWebhookEvent_TransitionRequestToProductionCreated + RegistryWebhookEvent_TransitionRequestToArchivedCreated = sdk.RegistryWebhookEvent_TransitionRequestToArchivedCreated + RegistryWebhookStatus_Unspecified = sdk.RegistryWebhookStatus_Unspecified + RegistryWebhookStatus_Active = sdk.RegistryWebhookStatus_Active + RegistryWebhookStatus_Disabled = sdk.RegistryWebhookStatus_Disabled + RegistryWebhookStatus_TestMode = sdk.RegistryWebhookStatus_TestMode +) + +// For activities, this contains the activity recorded for the action. For +// comments, this contains the comment details. For transition requests, this +// contains the transition request details.. +type Activity struct { + ActivityType ActivityType `json:"activity_type,omitempty"` + // Array of actions on the activity allowed for the current viewer. + AvailableActions []ActivityAction `json:"available_actions,omitempty"` + // User-provided comment associated with the activity, comment, or transition + // request. + Comment *string `json:"comment,omitempty"` + // Creation time of the object, as a Unix timestamp in milliseconds. + CreationTimestamp *int64 `json:"creation_timestamp,omitempty"` + // Source stage of the transition (if the activity is stage transition related). + // Valid values are: * `None`: The initial stage of a model version. * + // `Staging`: Staging or pre-production stage. * `Production`: Production stage. + // * `Archived`: Archived stage. + FromStage *string `json:"from_stage,omitempty"` + // Unique identifier for the object. + Id *string `json:"id,omitempty"` + // Time of the object at last update, as a Unix timestamp in milliseconds. + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // Comment made by system, for example explaining an activity of type + // `SYSTEM_TRANSITION`. It usually describes a side effect, such as a version + // being archived as part of another version's stage transition, and may not be + // returned for some activity types. + SystemComment *string `json:"system_comment,omitempty"` + // Target stage of the transition (if the activity is stage transition related). + // Valid values are: * `None`: The initial stage of a model version. * + // `Staging`: Staging or pre-production stage. * `Production`: Production stage. + // * `Archived`: Archived stage. + ToStage *string `json:"to_stage,omitempty"` + // The username of the user that created the object. + UserId *string `json:"user_id,omitempty"` +} + +// Details required to identify and approve a model version stage transition +// request.. +type ApproveTransitionRequest struct { + // Specifies whether to archive all current model versions in the target stage. + ArchiveExistingVersions *bool `json:"archive_existing_versions,omitempty"` + // User-provided comment on the action. + Comment *string `json:"comment,omitempty"` + // Name of the model. + Name *string `json:"name,omitempty"` + // Target stage of the transition. Valid values are: * `None`: The initial stage + // of a model version. * `Staging`: Staging or pre-production stage. * + // `Production`: Production stage. * `Archived`: Archived stage. + Stage *string `json:"stage,omitempty"` + // Version of the model. + Version *string `json:"version,omitempty"` +} + +type ApproveTransitionResponse struct { + // New activity generated as a result of this operation. + Activity *Activity `json:"activity,omitempty"` +} + +// For activities, this contains the activity recorded for the action. For +// comments, this contains the comment details. For transition requests, this +// contains the transition request details.. +type CommentObject struct { + ActivityType ActivityType `json:"activity_type,omitempty"` + // Array of actions on the activity allowed for the current viewer. + AvailableActions []ActivityAction `json:"available_actions,omitempty"` + // User-provided comment associated with the activity, comment, or transition + // request. + Comment *string `json:"comment,omitempty"` + // Creation time of the object, as a Unix timestamp in milliseconds. + CreationTimestamp *int64 `json:"creation_timestamp,omitempty"` + // Source stage of the transition (if the activity is stage transition related). + // Valid values are: * `None`: The initial stage of a model version. * + // `Staging`: Staging or pre-production stage. * `Production`: Production stage. + // * `Archived`: Archived stage. + FromStage *string `json:"from_stage,omitempty"` + // Unique identifier for the object. + Id *string `json:"id,omitempty"` + // Time of the object at last update, as a Unix timestamp in milliseconds. + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // Comment made by system, for example explaining an activity of type + // `SYSTEM_TRANSITION`. It usually describes a side effect, such as a version + // being archived as part of another version's stage transition, and may not be + // returned for some activity types. + SystemComment *string `json:"system_comment,omitempty"` + // Target stage of the transition (if the activity is stage transition related). + // Valid values are: * `None`: The initial stage of a model version. * + // `Staging`: Staging or pre-production stage. * `Production`: Production stage. + // * `Archived`: Archived stage. + ToStage *string `json:"to_stage,omitempty"` + // The username of the user that created the object. + UserId *string `json:"user_id,omitempty"` +} + +// Details required to create a comment on a model version.. +type CreateCommentRequest struct { + // User-provided comment on the action. + Comment *string `json:"comment,omitempty"` + // Name of the model. + Name *string `json:"name,omitempty"` + // Version of the model. + Version *string `json:"version,omitempty"` +} + +type CreateCommentResponse struct { + // New comment object + Comment *CommentObject `json:"comment,omitempty"` +} + +type CreateModelVersionRequest struct { + // Optional description for model version. + Description *string `json:"description,omitempty"` + // Register model under this name + Name *string `json:"name,omitempty"` + // MLflow run ID for correlation, if `source` was generated by an experiment run + // in MLflow tracking server + RunId *string `json:"run_id,omitempty"` + // MLflow run link - this is the exact link of the run that generated this model + // version, potentially hosted at another instance of MLflow. + RunLink *string `json:"run_link,omitempty"` + // URI indicating the location of the model artifacts. + Source *string `json:"source,omitempty"` + // Additional metadata for model version. + Tags []ModelVersionTag `json:"tags,omitempty"` +} + +type CreateModelVersionResponse struct { + // Return new version number generated for this model in registry. + ModelVersion *ModelVersion `json:"model_version,omitempty"` +} + +type CreateRegisteredModelRequest struct { + // Optional description for registered model. + Description *string `json:"description,omitempty"` + // Register models under this name + Name *string `json:"name,omitempty"` + // Additional metadata for registered model. + Tags []RegisteredModelTag `json:"tags,omitempty"` +} + +type CreateRegisteredModelResponse struct { + RegisteredModel *RegisteredModel `json:"registered_model,omitempty"` +} + +// Details required to create a registry webhook.. +type CreateRegistryWebhookRequest struct { + // User-specified description for the webhook. + Description *string `json:"description,omitempty"` + // Events that can trigger a registry webhook: * `MODEL_VERSION_CREATED`: A new + // model version was created for the associated model. * + // `MODEL_VERSION_TRANSITIONED_STAGE`: A model version’s stage was changed. * + // `TRANSITION_REQUEST_CREATED`: A user requested a model version’s stage be + // transitioned. * `COMMENT_CREATED`: A user wrote a comment on a registered + // model. * `REGISTERED_MODEL_CREATED`: A new registered model was created. This + // event type can only be specified for a registry-wide webhook, which can be + // created by not specifying a model name in the create request. * + // `MODEL_VERSION_TAG_SET`: A user set a tag on the model version. * + // `MODEL_VERSION_TRANSITIONED_TO_STAGING`: A model version was transitioned to + // staging. * `MODEL_VERSION_TRANSITIONED_TO_PRODUCTION`: A model version was + // transitioned to production. * `MODEL_VERSION_TRANSITIONED_TO_ARCHIVED`: A + // model version was archived. * `TRANSITION_REQUEST_TO_STAGING_CREATED`: A user + // requested a model version be transitioned to staging. * + // `TRANSITION_REQUEST_TO_PRODUCTION_CREATED`: A user requested a model version + // be transitioned to production. * `TRANSITION_REQUEST_TO_ARCHIVED_CREATED`: A + // user requested a model version be archived. + Events []RegistryWebhookEvent `json:"events,omitempty"` + // External HTTPS URL called on event trigger (by using a POST request). + HttpUrlSpec *HttpUrlSpec `json:"http_url_spec,omitempty"` + // ID of the job that the webhook runs. + JobSpec *JobSpec `json:"job_spec,omitempty"` + // If model name is not specified, a registry-wide webhook is created that + // listens for the specified events across all versions of all registered + // models. + ModelName *string `json:"model_name,omitempty"` + // Enable or disable triggering the webhook, or put the webhook into test mode. + // The default is `ACTIVE`: * `ACTIVE`: Webhook is triggered when an associated + // event happens. * `DISABLED`: Webhook is not triggered. * `TEST_MODE`: Webhook + // can be triggered through the test endpoint, but is not triggered on a real + // event. + Status RegistryWebhookStatus `json:"status,omitempty"` +} + +type CreateRegistryWebhookResponse struct { + Webhook *RegistryWebhook `json:"webhook,omitempty"` +} + +// Details required to create a model version stage transition request.. +type CreateTransitionRequest struct { + // User-provided comment on the action. + Comment *string `json:"comment,omitempty"` + // Name of the model. + Name *string `json:"name,omitempty"` + // Target stage of the transition. Valid values are: * `None`: The initial stage + // of a model version. * `Staging`: Staging or pre-production stage. * + // `Production`: Production stage. * `Archived`: Archived stage. + Stage *string `json:"stage,omitempty"` + // Version of the model. + Version *string `json:"version,omitempty"` +} + +type CreateTransitionResponse struct { + // New activity generated for stage transition request. + Request *TransitionRequest `json:"request,omitempty"` +} + +type DeleteCommentRequest struct { + // Unique identifier of an activity + Id *string `json:"id,omitempty"` +} + +type DeleteModelVersionRequest struct { + // Name of the registered model + Name *string `json:"name,omitempty"` + // Model version number + Version *string `json:"version,omitempty"` +} + +type DeleteModelVersionTagRequest struct { + // Name of the tag. The name must be an exact match; wild-card deletion is not + // supported. Maximum size is 250 bytes. + Key *string `json:"key,omitempty"` + // Name of the registered model that the tag was logged under. + Name *string `json:"name,omitempty"` + // Model version number that the tag was logged under. + Version *string `json:"version,omitempty"` +} + +type DeleteRegisteredModelRequest struct { + // Registered model unique name identifier. + Name *string `json:"name,omitempty"` +} + +type DeleteRegisteredModelTagRequest struct { + // Name of the tag. The name must be an exact match; wild-card deletion is not + // supported. Maximum size is 250 bytes. + Key *string `json:"key,omitempty"` + // Name of the registered model that the tag was logged under. + Name *string `json:"name,omitempty"` +} + +// .. note:: Experimental: This entity may change or be removed in a future +// release without warning.. +type DeleteRegistryWebhookRequest struct { + // Webhook ID required to delete a registry webhook. + Id *string `json:"id,omitempty"` +} + +type DeleteTransitionRequest struct { + // User-provided comment on the action. + Comment *string `json:"comment,omitempty"` + // Username of the user who created this request. Of the transition requests + // matching the specified details, only the one transition created by this user + // will be deleted. + Creator *string `json:"creator,omitempty"` + // Name of the model. + Name *string `json:"name,omitempty"` + // Target stage of the transition request. Valid values are: * `None`: The + // initial stage of a model version. * `Staging`: Staging or pre-production + // stage. * `Production`: Production stage. * `Archived`: Archived stage. + Stage *string `json:"stage,omitempty"` + // Version of the model. + Version *string `json:"version,omitempty"` +} + +type DeleteTransitionResponse struct { + // New activity generated as a result of this operation. + Activity *Activity `json:"activity,omitempty"` +} + +// Feature list wrap all the features for a model version. +type FeatureList struct { + Features []LinkedFeature `json:"features,omitempty"` +} + +type GetLatestVersionsResponse struct { + // Latest version models for each requests stage. Only return models with + // current `READY` status. If no `stages` provided, returns the latest version + // for each stage, including `"None"`. + ModelVersions []ModelVersion `json:"model_versions,omitempty"` +} + +type GetModelVersionDownloadUriRequest struct { + // Name of the registered model + Name *string `json:"name,omitempty"` + // Model version number + Version *string `json:"version,omitempty"` +} + +type GetModelVersionDownloadUriResponse struct { + // URI corresponding to where artifacts for this model version are stored. + ArtifactUri *string `json:"artifact_uri,omitempty"` +} + +type GetModelVersionRequest struct { + // Name of the registered model + Name *string `json:"name,omitempty"` + // Model version number + Version *string `json:"version,omitempty"` +} + +type GetModelVersionResponse struct { + ModelVersion *ModelVersion `json:"model_version,omitempty"` +} + +type GetRegisteredModelDatabricksRequest struct { + // Registered model unique name identifier. + Name *string `json:"name,omitempty"` +} + +type GetRegisteredModelDatabricksResponse struct { + RegisteredModelDatabricks *RegisteredModelDatabricks `json:"registered_model_databricks,omitempty"` +} + +type HttpUrlSpec struct { + // Value of the authorization header that should be sent in the request sent by + // the wehbook. It should be of the form `" "`. If set + // to an empty string, no authorization header will be included in the request. + Authorization *string `json:"authorization,omitempty"` + // Enable/disable SSL certificate validation. Default is true. For self-signed + // certificates, this field must be false AND the destination server must + // disable certificate validation as well. For security purposes, it is + // encouraged to perform secret validation with the HMAC-encoded portion of the + // payload and acknowledge the risk associated with disabling hostname + // validation whereby it becomes more likely that requests can be maliciously + // routed to an unintended host. + EnableSslVerification *bool `json:"enable_ssl_verification,omitempty"` + // Shared secret required for HMAC encoding payload. The HMAC-encoded payload + // will be sent in the header as: { "X-Databricks-Signature": $encoded_payload + // }. + Secret *string `json:"secret,omitempty"` + // External HTTPS URL called on event trigger (by using a POST request). + Url *string `json:"url,omitempty"` +} + +type JobSpec struct { + // The personal access token used to authorize webhook's job runs. + AccessToken *string `json:"access_token,omitempty"` + // ID of the job that the webhook runs. + JobId *string `json:"job_id,omitempty"` + // URL of the workspace containing the job that this webhook runs. If not + // specified, the job’s workspace URL is assumed to be the same as the + // workspace where the webhook is created. + WorkspaceUrl *string `json:"workspace_url,omitempty"` +} + +// Feature for model version.. +type LinkedFeature struct { + // Feature name + FeatureName *string `json:"feature_name,omitempty"` + // Feature table id + FeatureTableId *string `json:"feature_table_id,omitempty"` + // Feature table name + FeatureTableName *string `json:"feature_table_name,omitempty"` +} + +type ListLatestVersionsRequest struct { + // Registered model unique name identifier. + Name *string `json:"name,omitempty"` + // List of stages. + Stages []string `json:"stages,omitempty"` +} + +type ListRegisteredModelsRequest struct { + // Maximum number of registered models desired. Max threshold is 1000. + MaxResults *int64 `json:"max_results,omitempty"` + // Pagination token to go to the next page based on a previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListRegisteredModelsResponse struct { + // Pagination token to request next page of models for the same query. + NextPageToken *string `json:"next_page_token,omitempty"` + RegisteredModels []RegisteredModel `json:"registered_models,omitempty"` +} + +type ListRegistryWebhooksRequest struct { + // Events that trigger the webhook. * `MODEL_VERSION_CREATED`: A new model + // version was created for the associated model. * + // `MODEL_VERSION_TRANSITIONED_STAGE`: A model version’s stage was changed. * + // `TRANSITION_REQUEST_CREATED`: A user requested a model version’s stage be + // transitioned. * `COMMENT_CREATED`: A user wrote a comment on a registered + // model. * `REGISTERED_MODEL_CREATED`: A new registered model was created. This + // event type can only be specified for a registry-wide webhook, which can be + // created by not specifying a model name in the create request. * + // `MODEL_VERSION_TAG_SET`: A user set a tag on the model version. * + // `MODEL_VERSION_TRANSITIONED_TO_STAGING`: A model version was transitioned to + // staging. * `MODEL_VERSION_TRANSITIONED_TO_PRODUCTION`: A model version was + // transitioned to production. * `MODEL_VERSION_TRANSITIONED_TO_ARCHIVED`: A + // model version was archived. * `TRANSITION_REQUEST_TO_STAGING_CREATED`: A user + // requested a model version be transitioned to staging. * + // `TRANSITION_REQUEST_TO_PRODUCTION_CREATED`: A user requested a model version + // be transitioned to production. * `TRANSITION_REQUEST_TO_ARCHIVED_CREATED`: A + // user requested a model version be archived. If `events` is specified, any + // webhook with one or more of the specified trigger events is included in the + // output. If `events` is not specified, webhooks of all event types are + // included in the output. + Events []RegistryWebhookEvent `json:"events,omitempty"` + MaxResults *int64 `json:"max_results,omitempty"` + // Registered model name If not specified, all webhooks associated with the + // specified events are listed, regardless of their associated model. + ModelName *string `json:"model_name,omitempty"` + // Token indicating the page of artifact results to fetch + PageToken *string `json:"page_token,omitempty"` +} + +type ListRegistryWebhooksResponse struct { + // Token that can be used to retrieve the next page of artifact results + NextPageToken *string `json:"next_page_token,omitempty"` + // Array of registry webhooks. + Webhooks []RegistryWebhook `json:"webhooks,omitempty"` +} + +type ListTransitionRequest struct { + // Name of the registered model. + Name *string `json:"name,omitempty"` + // Version of the model. + Version *string `json:"version,omitempty"` +} + +type ListTransitionResponse struct { + // Array of open transition requests. + Requests []Activity `json:"requests,omitempty"` +} + +type ModelVersion struct { + // Timestamp recorded when this `model_version` was created. + CreationTimestamp *int64 `json:"creation_timestamp,omitempty"` + // Current stage for this `model_version`. + CurrentStage *string `json:"current_stage,omitempty"` + // Description of this `model_version`. + Description *string `json:"description,omitempty"` + // Timestamp recorded when metadata for this `model_version` was last updated. + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // Unique name of the model + Name *string `json:"name,omitempty"` + // MLflow run ID used when creating `model_version`, if `source` was generated + // by an experiment run stored in MLflow tracking server. + RunId *string `json:"run_id,omitempty"` + // Run Link: Direct link to the run that generated this version + RunLink *string `json:"run_link,omitempty"` + // URI indicating the location of the source model artifacts, used when creating + // `model_version` + Source *string `json:"source,omitempty"` + // Current status of `model_version` + Status ModelVersionStatus `json:"status,omitempty"` + // Details on current `status`, if it is pending or failed. + StatusMessage *string `json:"status_message,omitempty"` + // Tags: Additional metadata key-value pairs for this `model_version`. + Tags []ModelVersionTag `json:"tags,omitempty"` + // User that created this `model_version`. + UserId *string `json:"user_id,omitempty"` + // Model's version number. + Version *string `json:"version,omitempty"` +} + +type ModelVersionDatabricks struct { + // Creation time of the object, as a Unix timestamp in milliseconds. + CreationTimestamp *int64 `json:"creation_timestamp,omitempty"` + CurrentStage *string `json:"current_stage,omitempty"` + // User-specified description for the object. + Description *string `json:"description,omitempty"` + // Email Subscription Status: This is the subscription status of the user to the + // model version Users get subscribed by interacting with the model version. + EmailSubscriptionStatus RegistryEmailSubscriptionType `json:"email_subscription_status,omitempty"` + // Feature lineage of `model_version`. + FeatureList *FeatureList `json:"feature_list,omitempty"` + // Time of the object at last update, as a Unix timestamp in milliseconds. + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // Name of the model. + Name *string `json:"name,omitempty"` + // Open requests for this `model_versions`. Gap in sequence number is + // intentional and is done in order to match field sequence numbers of + // `ModelVersion` proto message + OpenRequests []Activity `json:"open_requests,omitempty"` + PermissionLevel PermissionLevel `json:"permission_level,omitempty"` + // Unique identifier for the MLflow tracking run associated with the source + // model artifacts. + RunId *string `json:"run_id,omitempty"` + // URL of the run associated with the model artifacts. This field is set at + // model version creation time only for model versions whose source run is from + // a tracking server that is different from the registry server. + RunLink *string `json:"run_link,omitempty"` + // URI that indicates the location of the source model artifacts. This is used + // when creating the model version. + Source *string `json:"source,omitempty"` + Status ModelVersionStatus `json:"status,omitempty"` + // Details on the current status, for example why registration failed. + StatusMessage *string `json:"status_message,omitempty"` + // Array of tags that are associated with the model version. + Tags []ModelVersionTag `json:"tags,omitempty"` + // The username of the user that created the object. + UserId *string `json:"user_id,omitempty"` + // Version of the model. + Version *string `json:"version,omitempty"` +} + +type ModelVersionTag struct { + // The tag key. + Key *string `json:"key,omitempty"` + // The tag value. + Value *string `json:"value,omitempty"` +} + +type RegisteredModel struct { + // Timestamp recorded when this `registered_model` was created. + CreationTimestamp *int64 `json:"creation_timestamp,omitempty"` + // Description of this `registered_model`. + Description *string `json:"description,omitempty"` + // Timestamp recorded when metadata for this `registered_model` was last + // updated. + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // Collection of latest model versions for each stage. Only contains models with + // current `READY` status. + LatestVersions []ModelVersion `json:"latest_versions,omitempty"` + // Unique name for the model. + Name *string `json:"name,omitempty"` + // Tags: Additional metadata key-value pairs for this `registered_model`. + Tags []RegisteredModelTag `json:"tags,omitempty"` + // User that created this `registered_model` + UserId *string `json:"user_id,omitempty"` +} + +type RegisteredModelDatabricks struct { + // Creation time of the object, as a Unix timestamp in milliseconds. + CreationTimestamp *int64 `json:"creation_timestamp,omitempty"` + // User-specified description for the object. + Description *string `json:"description,omitempty"` + // Unique identifier for the object. + Id *string `json:"id,omitempty"` + // Last update time of the object, as a Unix timestamp in milliseconds. + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // Array of model versions, each the latest version for its stage. + LatestVersions []ModelVersion `json:"latest_versions,omitempty"` + // Name of the model. + Name *string `json:"name,omitempty"` + // Permission level granted for the requesting user on this registered model + PermissionLevel PermissionLevel `json:"permission_level,omitempty"` + // Array of tags associated with the model. + Tags []RegisteredModelTag `json:"tags,omitempty"` + // The username of the user that created the object. + UserId *string `json:"user_id,omitempty"` +} + +// Tag for a registered model. +type RegisteredModelTag struct { + // The tag key. + Key *string `json:"key,omitempty"` + // The tag value. + Value *string `json:"value,omitempty"` +} + +type RegistryWebhook struct { + // Creation time of the object, as a Unix timestamp in milliseconds. + CreationTimestamp *int64 `json:"creation_timestamp,omitempty"` + // User-specified description for the webhook. + Description *string `json:"description,omitempty"` + // Events that can trigger a registry webhook: * `MODEL_VERSION_CREATED`: A new + // model version was created for the associated model. * + // `MODEL_VERSION_TRANSITIONED_STAGE`: A model version’s stage was changed. * + // `TRANSITION_REQUEST_CREATED`: A user requested a model version’s stage be + // transitioned. * `COMMENT_CREATED`: A user wrote a comment on a registered + // model. * `REGISTERED_MODEL_CREATED`: A new registered model was created. This + // event type can only be specified for a registry-wide webhook, which can be + // created by not specifying a model name in the create request. * + // `MODEL_VERSION_TAG_SET`: A user set a tag on the model version. * + // `MODEL_VERSION_TRANSITIONED_TO_STAGING`: A model version was transitioned to + // staging. * `MODEL_VERSION_TRANSITIONED_TO_PRODUCTION`: A model version was + // transitioned to production. * `MODEL_VERSION_TRANSITIONED_TO_ARCHIVED`: A + // model version was archived. * `TRANSITION_REQUEST_TO_STAGING_CREATED`: A user + // requested a model version be transitioned to staging. * + // `TRANSITION_REQUEST_TO_PRODUCTION_CREATED`: A user requested a model version + // be transitioned to production. * `TRANSITION_REQUEST_TO_ARCHIVED_CREATED`: A + // user requested a model version be archived. + Events []RegistryWebhookEvent `json:"events,omitempty"` + HttpUrlSpec *HttpUrlSpec `json:"http_url_spec,omitempty"` + // Webhook ID + Id *string `json:"id,omitempty"` + JobSpec *JobSpec `json:"job_spec,omitempty"` + // Time of the object at last update, as a Unix timestamp in milliseconds. + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // Name of the model whose events would trigger this webhook. + ModelName *string `json:"model_name,omitempty"` + Status RegistryWebhookStatus `json:"status,omitempty"` +} + +// Details required to identify and reject a model version stage transition +// request.. +type RejectTransitionRequest struct { + // User-provided comment on the action. + Comment *string `json:"comment,omitempty"` + // Name of the model. + Name *string `json:"name,omitempty"` + // Target stage of the transition. Valid values are: * `None`: The initial stage + // of a model version. * `Staging`: Staging or pre-production stage. * + // `Production`: Production stage. * `Archived`: Archived stage. + Stage *string `json:"stage,omitempty"` + // Version of the model. + Version *string `json:"version,omitempty"` +} + +type RejectTransitionResponse struct { + // New activity generated as a result of this operation. + Activity *Activity `json:"activity,omitempty"` +} + +type RenameRegisteredModelRequest struct { + // Registered model unique name identifier. + Name *string `json:"name,omitempty"` + // If provided, updates the name for this `registered_model`. + NewName *string `json:"new_name,omitempty"` +} + +type RenameRegisteredModelResponse struct { + RegisteredModel *RegisteredModel `json:"registered_model,omitempty"` +} + +type SearchModelVersionsRequest struct { + // String filter condition, like "name='my-model-name'". Must be a single + // boolean condition, with string values wrapped in single quotes. + Filter *string `json:"filter,omitempty"` + // Maximum number of models desired. Max threshold is 10K. + MaxResults *int64 `json:"max_results,omitempty"` + // List of columns to be ordered by including model name, version, stage with an + // optional "DESC" or "ASC" annotation, where "ASC" is the default. Tiebreaks + // are done by latest stage transition timestamp, followed by name ASC, followed + // by version DESC. + OrderBy []string `json:"order_by,omitempty"` + // Pagination token to go to next page based on previous search query. + PageToken *string `json:"page_token,omitempty"` +} + +type SearchModelVersionsResponse struct { + // Models that match the search criteria + ModelVersions []ModelVersion `json:"model_versions,omitempty"` + // Pagination token to request next page of models for the same search query. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type SearchRegisteredModelsRequest struct { + // String filter condition, like "name LIKE 'my-model-name'". Interpreted in the + // backend automatically as "name LIKE '%my-model-name%'". Single boolean + // condition, with string values wrapped in single quotes. + Filter *string `json:"filter,omitempty"` + // Maximum number of models desired. Default is 100. Max threshold is 1000. + MaxResults *int64 `json:"max_results,omitempty"` + // List of columns for ordering search results, which can include model name and + // last updated timestamp with an optional "DESC" or "ASC" annotation, where + // "ASC" is the default. Tiebreaks are done by model name ASC. + OrderBy []string `json:"order_by,omitempty"` + // Pagination token to go to the next page based on a previous search query. + PageToken *string `json:"page_token,omitempty"` +} + +type SearchRegisteredModelsResponse struct { + // Pagination token to request the next page of models. + NextPageToken *string `json:"next_page_token,omitempty"` + // Registered Models that match the search criteria. + RegisteredModels []RegisteredModel `json:"registered_models,omitempty"` +} + +type SetModelVersionTagRequest struct { + // Name of the tag. Maximum size depends on storage backend. If a tag with this + // name already exists, its preexisting value will be replaced by the specified + // `value`. All storage backends are guaranteed to support key values up to 250 + // bytes in size. + Key *string `json:"key,omitempty"` + // Unique name of the model. + Name *string `json:"name,omitempty"` + // String value of the tag being logged. Maximum size depends on storage + // backend. All storage backends are guaranteed to support key values up to 5000 + // bytes in size. + Value *string `json:"value,omitempty"` + // Model version number. + Version *string `json:"version,omitempty"` +} + +type SetRegisteredModelTagRequest struct { + // Name of the tag. Maximum size depends on storage backend. If a tag with this + // name already exists, its preexisting value will be replaced by the specified + // `value`. All storage backends are guaranteed to support key values up to 250 + // bytes in size. + Key *string `json:"key,omitempty"` + // Unique name of the model. + Name *string `json:"name,omitempty"` + // String value of the tag being logged. Maximum size depends on storage + // backend. All storage backends are guaranteed to support key values up to 5000 + // bytes in size. + Value *string `json:"value,omitempty"` +} + +// Details required to test a registry webhook.. +type TestRegistryWebhookRequest struct { + // If `event` is specified, the test trigger uses the specified event. If + // `event` is not specified, the test trigger uses a randomly chosen event + // associated with the webhook. + Event RegistryWebhookEvent `json:"event,omitempty"` + // Webhook ID + Id *string `json:"id,omitempty"` +} + +type TestRegistryWebhookResponse struct { + // Body of the response from the webhook URL + Body *string `json:"body,omitempty"` + // Status code returned by the webhook URL + StatusCode *int `json:"status_code,omitempty"` +} + +// Details required to transition a model version's stage.. +type TransitionModelVersionStageDatabricksRequest struct { + // Specifies whether to archive all current model versions in the target stage. + ArchiveExistingVersions *bool `json:"archive_existing_versions,omitempty"` + // User-provided comment on the action. + Comment *string `json:"comment,omitempty"` + // Name of the model. + Name *string `json:"name,omitempty"` + // Target stage of the transition. Valid values are: * `None`: The initial stage + // of a model version. * `Staging`: Staging or pre-production stage. * + // `Production`: Production stage. * `Archived`: Archived stage. + Stage *string `json:"stage,omitempty"` + // Version of the model. + Version *string `json:"version,omitempty"` +} + +type TransitionModelVersionStageDatabricksResponse struct { + // Updated model version + ModelVersionDatabricks *ModelVersionDatabricks `json:"model_version_databricks,omitempty"` +} + +// For activities, this contains the activity recorded for the action. For +// comments, this contains the comment details. For transition requests, this +// contains the transition request details.. +type TransitionRequest struct { + ActivityType ActivityType `json:"activity_type,omitempty"` + // Array of actions on the activity allowed for the current viewer. + AvailableActions []ActivityAction `json:"available_actions,omitempty"` + // User-provided comment associated with the activity, comment, or transition + // request. + Comment *string `json:"comment,omitempty"` + // Creation time of the object, as a Unix timestamp in milliseconds. + CreationTimestamp *int64 `json:"creation_timestamp,omitempty"` + // Source stage of the transition (if the activity is stage transition related). + // Valid values are: * `None`: The initial stage of a model version. * + // `Staging`: Staging or pre-production stage. * `Production`: Production stage. + // * `Archived`: Archived stage. + FromStage *string `json:"from_stage,omitempty"` + // Unique identifier for the object. + Id *string `json:"id,omitempty"` + // Time of the object at last update, as a Unix timestamp in milliseconds. + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // Comment made by system, for example explaining an activity of type + // `SYSTEM_TRANSITION`. It usually describes a side effect, such as a version + // being archived as part of another version's stage transition, and may not be + // returned for some activity types. + SystemComment *string `json:"system_comment,omitempty"` + // Target stage of the transition (if the activity is stage transition related). + // Valid values are: * `None`: The initial stage of a model version. * + // `Staging`: Staging or pre-production stage. * `Production`: Production stage. + // * `Archived`: Archived stage. + ToStage *string `json:"to_stage,omitempty"` + // The username of the user that created the object. + UserId *string `json:"user_id,omitempty"` +} + +// Details required to edit a comment on a model version.. +type UpdateCommentRequest struct { + // User-provided comment on the action. + Comment *string `json:"comment,omitempty"` + // Unique identifier of an activity + Id *string `json:"id,omitempty"` +} + +type UpdateCommentResponse struct { + // Updated comment object + Comment *CommentObject `json:"comment,omitempty"` +} + +type UpdateModelVersionRequest struct { + // If provided, updates the description for this `registered_model`. + Description *string `json:"description,omitempty"` + // Name of the registered model + Name *string `json:"name,omitempty"` + // Model version number + Version *string `json:"version,omitempty"` +} + +type UpdateModelVersionResponse struct { + // Return new version number generated for this model in registry. + ModelVersion *ModelVersion `json:"model_version,omitempty"` +} + +type UpdateRegisteredModelRequest struct { + // If provided, updates the description for this `registered_model`. + Description *string `json:"description,omitempty"` + // Registered model unique name identifier. + Name *string `json:"name,omitempty"` +} + +type UpdateRegisteredModelResponse struct { + RegisteredModel *RegisteredModel `json:"registered_model,omitempty"` +} + +// Details required to update a registry webhook. Only the fields that need to +// be updated should be specified, and both `http_url_spec` and `job_spec` +// should not be specified in the same request.. +type UpdateRegistryWebhookRequest struct { + // User-specified description for the webhook. + Description *string `json:"description,omitempty"` + // Events that can trigger a registry webhook: * `MODEL_VERSION_CREATED`: A new + // model version was created for the associated model. * + // `MODEL_VERSION_TRANSITIONED_STAGE`: A model version’s stage was changed. * + // `TRANSITION_REQUEST_CREATED`: A user requested a model version’s stage be + // transitioned. * `COMMENT_CREATED`: A user wrote a comment on a registered + // model. * `REGISTERED_MODEL_CREATED`: A new registered model was created. This + // event type can only be specified for a registry-wide webhook, which can be + // created by not specifying a model name in the create request. * + // `MODEL_VERSION_TAG_SET`: A user set a tag on the model version. * + // `MODEL_VERSION_TRANSITIONED_TO_STAGING`: A model version was transitioned to + // staging. * `MODEL_VERSION_TRANSITIONED_TO_PRODUCTION`: A model version was + // transitioned to production. * `MODEL_VERSION_TRANSITIONED_TO_ARCHIVED`: A + // model version was archived. * `TRANSITION_REQUEST_TO_STAGING_CREATED`: A user + // requested a model version be transitioned to staging. * + // `TRANSITION_REQUEST_TO_PRODUCTION_CREATED`: A user requested a model version + // be transitioned to production. * `TRANSITION_REQUEST_TO_ARCHIVED_CREATED`: A + // user requested a model version be archived. + Events []RegistryWebhookEvent `json:"events,omitempty"` + HttpUrlSpec *HttpUrlSpec `json:"http_url_spec,omitempty"` + // Webhook ID + Id *string `json:"id,omitempty"` + JobSpec *JobSpec `json:"job_spec,omitempty"` + Status RegistryWebhookStatus `json:"status,omitempty"` +} + +type UpdateRegistryWebhookResponse struct { + Webhook *RegistryWebhook `json:"webhook,omitempty"` +} + +// ActivityToSDK converts the mirror to the sdk-go type. +func ActivityToSDK(w *Activity) (*sdk.Activity, error) { + if w == nil { + return nil, nil + } + out := &sdk.Activity{} + out.CreationTimestamp = w.CreationTimestamp + out.UserId = w.UserId + out.ActivityType = w.ActivityType + out.Comment = w.Comment + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + out.FromStage = w.FromStage + out.ToStage = w.ToStage + out.SystemComment = w.SystemComment + out.AvailableActions = w.AvailableActions + out.Id = w.Id + return out, nil +} + +// ActivityFromSDK converts the sdk-go type to the mirror. +func ActivityFromSDK(v *sdk.Activity) (*Activity, error) { + if v == nil { + return nil, nil + } + out := &Activity{} + out.CreationTimestamp = v.CreationTimestamp + out.UserId = v.UserId + out.ActivityType = v.ActivityType + out.Comment = v.Comment + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + out.FromStage = v.FromStage + out.ToStage = v.ToStage + out.SystemComment = v.SystemComment + out.AvailableActions = v.AvailableActions + out.Id = v.Id + return out, nil +} + +// ApproveTransitionRequestToSDK converts the mirror to the sdk-go type. +func ApproveTransitionRequestToSDK(w *ApproveTransitionRequest) (*sdk.ApproveTransitionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApproveTransitionRequest{} + out.Name = w.Name + out.Version = w.Version + out.Stage = w.Stage + out.ArchiveExistingVersions = w.ArchiveExistingVersions + out.Comment = w.Comment + return out, nil +} + +// ApproveTransitionRequestFromSDK converts the sdk-go type to the mirror. +func ApproveTransitionRequestFromSDK(v *sdk.ApproveTransitionRequest) (*ApproveTransitionRequest, error) { + if v == nil { + return nil, nil + } + out := &ApproveTransitionRequest{} + out.Name = v.Name + out.Version = v.Version + out.Stage = v.Stage + out.ArchiveExistingVersions = v.ArchiveExistingVersions + out.Comment = v.Comment + return out, nil +} + +// ApproveTransitionResponseToSDK converts the mirror to the sdk-go type. +func ApproveTransitionResponseToSDK(w *ApproveTransitionResponse) (*sdk.ApproveTransitionResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApproveTransitionResponse{} + conv1, err := ActivityToSDK(w.Activity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ApproveTransitionResponse.Activity", err) + } + out.Activity = conv1 + return out, nil +} + +// ApproveTransitionResponseFromSDK converts the sdk-go type to the mirror. +func ApproveTransitionResponseFromSDK(v *sdk.ApproveTransitionResponse) (*ApproveTransitionResponse, error) { + if v == nil { + return nil, nil + } + out := &ApproveTransitionResponse{} + conv2, err := ActivityFromSDK(v.Activity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ApproveTransitionResponse.Activity", err) + } + out.Activity = conv2 + return out, nil +} + +// CommentObjectToSDK converts the mirror to the sdk-go type. +func CommentObjectToSDK(w *CommentObject) (*sdk.CommentObject, error) { + if w == nil { + return nil, nil + } + out := &sdk.CommentObject{} + out.CreationTimestamp = w.CreationTimestamp + out.UserId = w.UserId + out.ActivityType = w.ActivityType + out.Comment = w.Comment + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + out.FromStage = w.FromStage + out.ToStage = w.ToStage + out.SystemComment = w.SystemComment + out.AvailableActions = w.AvailableActions + out.Id = w.Id + return out, nil +} + +// CommentObjectFromSDK converts the sdk-go type to the mirror. +func CommentObjectFromSDK(v *sdk.CommentObject) (*CommentObject, error) { + if v == nil { + return nil, nil + } + out := &CommentObject{} + out.CreationTimestamp = v.CreationTimestamp + out.UserId = v.UserId + out.ActivityType = v.ActivityType + out.Comment = v.Comment + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + out.FromStage = v.FromStage + out.ToStage = v.ToStage + out.SystemComment = v.SystemComment + out.AvailableActions = v.AvailableActions + out.Id = v.Id + return out, nil +} + +// CreateCommentRequestToSDK converts the mirror to the sdk-go type. +func CreateCommentRequestToSDK(w *CreateCommentRequest) (*sdk.CreateCommentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCommentRequest{} + out.Name = w.Name + out.Version = w.Version + out.Comment = w.Comment + return out, nil +} + +// CreateCommentRequestFromSDK converts the sdk-go type to the mirror. +func CreateCommentRequestFromSDK(v *sdk.CreateCommentRequest) (*CreateCommentRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCommentRequest{} + out.Name = v.Name + out.Version = v.Version + out.Comment = v.Comment + return out, nil +} + +// CreateCommentResponseToSDK converts the mirror to the sdk-go type. +func CreateCommentResponseToSDK(w *CreateCommentResponse) (*sdk.CreateCommentResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCommentResponse{} + conv3, err := CommentObjectToSDK(w.Comment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCommentResponse.Comment", err) + } + out.Comment = conv3 + return out, nil +} + +// CreateCommentResponseFromSDK converts the sdk-go type to the mirror. +func CreateCommentResponseFromSDK(v *sdk.CreateCommentResponse) (*CreateCommentResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateCommentResponse{} + conv4, err := CommentObjectFromSDK(v.Comment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCommentResponse.Comment", err) + } + out.Comment = conv4 + return out, nil +} + +// CreateModelVersionRequestToSDK converts the mirror to the sdk-go type. +func CreateModelVersionRequestToSDK(w *CreateModelVersionRequest) (*sdk.CreateModelVersionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateModelVersionRequest{} + out.Name = w.Name + out.Source = w.Source + out.RunId = w.RunId + conv5, err := convertSlice(w.Tags, ModelVersionTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateModelVersionRequest.Tags", err) + } + out.Tags = conv5 + out.RunLink = w.RunLink + out.Description = w.Description + return out, nil +} + +// CreateModelVersionRequestFromSDK converts the sdk-go type to the mirror. +func CreateModelVersionRequestFromSDK(v *sdk.CreateModelVersionRequest) (*CreateModelVersionRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateModelVersionRequest{} + out.Name = v.Name + out.Source = v.Source + out.RunId = v.RunId + conv6, err := convertSlice(v.Tags, ModelVersionTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateModelVersionRequest.Tags", err) + } + out.Tags = conv6 + out.RunLink = v.RunLink + out.Description = v.Description + return out, nil +} + +// CreateModelVersionResponseToSDK converts the mirror to the sdk-go type. +func CreateModelVersionResponseToSDK(w *CreateModelVersionResponse) (*sdk.CreateModelVersionResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateModelVersionResponse{} + conv7, err := ModelVersionToSDK(w.ModelVersion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateModelVersionResponse.ModelVersion", err) + } + out.ModelVersion = conv7 + return out, nil +} + +// CreateModelVersionResponseFromSDK converts the sdk-go type to the mirror. +func CreateModelVersionResponseFromSDK(v *sdk.CreateModelVersionResponse) (*CreateModelVersionResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateModelVersionResponse{} + conv8, err := ModelVersionFromSDK(v.ModelVersion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateModelVersionResponse.ModelVersion", err) + } + out.ModelVersion = conv8 + return out, nil +} + +// CreateRegisteredModelRequestToSDK converts the mirror to the sdk-go type. +func CreateRegisteredModelRequestToSDK(w *CreateRegisteredModelRequest) (*sdk.CreateRegisteredModelRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRegisteredModelRequest{} + out.Name = w.Name + conv9, err := convertSlice(w.Tags, RegisteredModelTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRegisteredModelRequest.Tags", err) + } + out.Tags = conv9 + out.Description = w.Description + return out, nil +} + +// CreateRegisteredModelRequestFromSDK converts the sdk-go type to the mirror. +func CreateRegisteredModelRequestFromSDK(v *sdk.CreateRegisteredModelRequest) (*CreateRegisteredModelRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateRegisteredModelRequest{} + out.Name = v.Name + conv10, err := convertSlice(v.Tags, RegisteredModelTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRegisteredModelRequest.Tags", err) + } + out.Tags = conv10 + out.Description = v.Description + return out, nil +} + +// CreateRegisteredModelResponseToSDK converts the mirror to the sdk-go type. +func CreateRegisteredModelResponseToSDK(w *CreateRegisteredModelResponse) (*sdk.CreateRegisteredModelResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRegisteredModelResponse{} + conv11, err := RegisteredModelToSDK(w.RegisteredModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRegisteredModelResponse.RegisteredModel", err) + } + out.RegisteredModel = conv11 + return out, nil +} + +// CreateRegisteredModelResponseFromSDK converts the sdk-go type to the mirror. +func CreateRegisteredModelResponseFromSDK(v *sdk.CreateRegisteredModelResponse) (*CreateRegisteredModelResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateRegisteredModelResponse{} + conv12, err := RegisteredModelFromSDK(v.RegisteredModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRegisteredModelResponse.RegisteredModel", err) + } + out.RegisteredModel = conv12 + return out, nil +} + +// CreateRegistryWebhookRequestToSDK converts the mirror to the sdk-go type. +func CreateRegistryWebhookRequestToSDK(w *CreateRegistryWebhookRequest) (*sdk.CreateRegistryWebhookRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRegistryWebhookRequest{} + out.ModelName = w.ModelName + out.Events = w.Events + out.Description = w.Description + out.Status = w.Status + conv13, err := HttpUrlSpecToSDK(w.HttpUrlSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRegistryWebhookRequest.HttpUrlSpec", err) + } + out.HttpUrlSpec = conv13 + conv14, err := JobSpecToSDK(w.JobSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRegistryWebhookRequest.JobSpec", err) + } + out.JobSpec = conv14 + return out, nil +} + +// CreateRegistryWebhookRequestFromSDK converts the sdk-go type to the mirror. +func CreateRegistryWebhookRequestFromSDK(v *sdk.CreateRegistryWebhookRequest) (*CreateRegistryWebhookRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateRegistryWebhookRequest{} + out.ModelName = v.ModelName + out.Events = v.Events + out.Description = v.Description + out.Status = v.Status + conv15, err := HttpUrlSpecFromSDK(v.HttpUrlSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRegistryWebhookRequest.HttpUrlSpec", err) + } + out.HttpUrlSpec = conv15 + conv16, err := JobSpecFromSDK(v.JobSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRegistryWebhookRequest.JobSpec", err) + } + out.JobSpec = conv16 + return out, nil +} + +// CreateRegistryWebhookResponseToSDK converts the mirror to the sdk-go type. +func CreateRegistryWebhookResponseToSDK(w *CreateRegistryWebhookResponse) (*sdk.CreateRegistryWebhookResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRegistryWebhookResponse{} + conv17, err := RegistryWebhookToSDK(w.Webhook) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRegistryWebhookResponse.Webhook", err) + } + out.Webhook = conv17 + return out, nil +} + +// CreateRegistryWebhookResponseFromSDK converts the sdk-go type to the mirror. +func CreateRegistryWebhookResponseFromSDK(v *sdk.CreateRegistryWebhookResponse) (*CreateRegistryWebhookResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateRegistryWebhookResponse{} + conv18, err := RegistryWebhookFromSDK(v.Webhook) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRegistryWebhookResponse.Webhook", err) + } + out.Webhook = conv18 + return out, nil +} + +// CreateTransitionRequestToSDK converts the mirror to the sdk-go type. +func CreateTransitionRequestToSDK(w *CreateTransitionRequest) (*sdk.CreateTransitionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateTransitionRequest{} + out.Name = w.Name + out.Version = w.Version + out.Stage = w.Stage + out.Comment = w.Comment + return out, nil +} + +// CreateTransitionRequestFromSDK converts the sdk-go type to the mirror. +func CreateTransitionRequestFromSDK(v *sdk.CreateTransitionRequest) (*CreateTransitionRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateTransitionRequest{} + out.Name = v.Name + out.Version = v.Version + out.Stage = v.Stage + out.Comment = v.Comment + return out, nil +} + +// CreateTransitionResponseToSDK converts the mirror to the sdk-go type. +func CreateTransitionResponseToSDK(w *CreateTransitionResponse) (*sdk.CreateTransitionResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateTransitionResponse{} + conv19, err := TransitionRequestToSDK(w.Request) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTransitionResponse.Request", err) + } + out.Request = conv19 + return out, nil +} + +// CreateTransitionResponseFromSDK converts the sdk-go type to the mirror. +func CreateTransitionResponseFromSDK(v *sdk.CreateTransitionResponse) (*CreateTransitionResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateTransitionResponse{} + conv20, err := TransitionRequestFromSDK(v.Request) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTransitionResponse.Request", err) + } + out.Request = conv20 + return out, nil +} + +// DeleteCommentRequestToSDK converts the mirror to the sdk-go type. +func DeleteCommentRequestToSDK(w *DeleteCommentRequest) (*sdk.DeleteCommentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteCommentRequest{} + out.Id = w.Id + return out, nil +} + +// DeleteCommentRequestFromSDK converts the sdk-go type to the mirror. +func DeleteCommentRequestFromSDK(v *sdk.DeleteCommentRequest) (*DeleteCommentRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteCommentRequest{} + out.Id = v.Id + return out, nil +} + +// DeleteModelVersionRequestToSDK converts the mirror to the sdk-go type. +func DeleteModelVersionRequestToSDK(w *DeleteModelVersionRequest) (*sdk.DeleteModelVersionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteModelVersionRequest{} + out.Name = w.Name + out.Version = w.Version + return out, nil +} + +// DeleteModelVersionRequestFromSDK converts the sdk-go type to the mirror. +func DeleteModelVersionRequestFromSDK(v *sdk.DeleteModelVersionRequest) (*DeleteModelVersionRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteModelVersionRequest{} + out.Name = v.Name + out.Version = v.Version + return out, nil +} + +// DeleteModelVersionTagRequestToSDK converts the mirror to the sdk-go type. +func DeleteModelVersionTagRequestToSDK(w *DeleteModelVersionTagRequest) (*sdk.DeleteModelVersionTagRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteModelVersionTagRequest{} + out.Name = w.Name + out.Version = w.Version + out.Key = w.Key + return out, nil +} + +// DeleteModelVersionTagRequestFromSDK converts the sdk-go type to the mirror. +func DeleteModelVersionTagRequestFromSDK(v *sdk.DeleteModelVersionTagRequest) (*DeleteModelVersionTagRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteModelVersionTagRequest{} + out.Name = v.Name + out.Version = v.Version + out.Key = v.Key + return out, nil +} + +// DeleteRegisteredModelRequestToSDK converts the mirror to the sdk-go type. +func DeleteRegisteredModelRequestToSDK(w *DeleteRegisteredModelRequest) (*sdk.DeleteRegisteredModelRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteRegisteredModelRequest{} + out.Name = w.Name + return out, nil +} + +// DeleteRegisteredModelRequestFromSDK converts the sdk-go type to the mirror. +func DeleteRegisteredModelRequestFromSDK(v *sdk.DeleteRegisteredModelRequest) (*DeleteRegisteredModelRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteRegisteredModelRequest{} + out.Name = v.Name + return out, nil +} + +// DeleteRegisteredModelTagRequestToSDK converts the mirror to the sdk-go type. +func DeleteRegisteredModelTagRequestToSDK(w *DeleteRegisteredModelTagRequest) (*sdk.DeleteRegisteredModelTagRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteRegisteredModelTagRequest{} + out.Name = w.Name + out.Key = w.Key + return out, nil +} + +// DeleteRegisteredModelTagRequestFromSDK converts the sdk-go type to the mirror. +func DeleteRegisteredModelTagRequestFromSDK(v *sdk.DeleteRegisteredModelTagRequest) (*DeleteRegisteredModelTagRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteRegisteredModelTagRequest{} + out.Name = v.Name + out.Key = v.Key + return out, nil +} + +// DeleteRegistryWebhookRequestToSDK converts the mirror to the sdk-go type. +func DeleteRegistryWebhookRequestToSDK(w *DeleteRegistryWebhookRequest) (*sdk.DeleteRegistryWebhookRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteRegistryWebhookRequest{} + out.Id = w.Id + return out, nil +} + +// DeleteRegistryWebhookRequestFromSDK converts the sdk-go type to the mirror. +func DeleteRegistryWebhookRequestFromSDK(v *sdk.DeleteRegistryWebhookRequest) (*DeleteRegistryWebhookRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteRegistryWebhookRequest{} + out.Id = v.Id + return out, nil +} + +// DeleteTransitionRequestToSDK converts the mirror to the sdk-go type. +func DeleteTransitionRequestToSDK(w *DeleteTransitionRequest) (*sdk.DeleteTransitionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteTransitionRequest{} + out.Name = w.Name + out.Version = w.Version + out.Stage = w.Stage + out.Creator = w.Creator + out.Comment = w.Comment + return out, nil +} + +// DeleteTransitionRequestFromSDK converts the sdk-go type to the mirror. +func DeleteTransitionRequestFromSDK(v *sdk.DeleteTransitionRequest) (*DeleteTransitionRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteTransitionRequest{} + out.Name = v.Name + out.Version = v.Version + out.Stage = v.Stage + out.Creator = v.Creator + out.Comment = v.Comment + return out, nil +} + +// DeleteTransitionResponseToSDK converts the mirror to the sdk-go type. +func DeleteTransitionResponseToSDK(w *DeleteTransitionResponse) (*sdk.DeleteTransitionResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteTransitionResponse{} + conv21, err := ActivityToSDK(w.Activity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeleteTransitionResponse.Activity", err) + } + out.Activity = conv21 + return out, nil +} + +// DeleteTransitionResponseFromSDK converts the sdk-go type to the mirror. +func DeleteTransitionResponseFromSDK(v *sdk.DeleteTransitionResponse) (*DeleteTransitionResponse, error) { + if v == nil { + return nil, nil + } + out := &DeleteTransitionResponse{} + conv22, err := ActivityFromSDK(v.Activity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeleteTransitionResponse.Activity", err) + } + out.Activity = conv22 + return out, nil +} + +// FeatureListToSDK converts the mirror to the sdk-go type. +func FeatureListToSDK(w *FeatureList) (*sdk.FeatureList, error) { + if w == nil { + return nil, nil + } + out := &sdk.FeatureList{} + conv23, err := convertSlice(w.Features, LinkedFeatureToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FeatureList.Features", err) + } + out.Features = conv23 + return out, nil +} + +// FeatureListFromSDK converts the sdk-go type to the mirror. +func FeatureListFromSDK(v *sdk.FeatureList) (*FeatureList, error) { + if v == nil { + return nil, nil + } + out := &FeatureList{} + conv24, err := convertSlice(v.Features, LinkedFeatureFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FeatureList.Features", err) + } + out.Features = conv24 + return out, nil +} + +// GetLatestVersionsResponseToSDK converts the mirror to the sdk-go type. +func GetLatestVersionsResponseToSDK(w *GetLatestVersionsResponse) (*sdk.GetLatestVersionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetLatestVersionsResponse{} + conv25, err := convertSlice(w.ModelVersions, ModelVersionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetLatestVersionsResponse.ModelVersions", err) + } + out.ModelVersions = conv25 + return out, nil +} + +// GetLatestVersionsResponseFromSDK converts the sdk-go type to the mirror. +func GetLatestVersionsResponseFromSDK(v *sdk.GetLatestVersionsResponse) (*GetLatestVersionsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetLatestVersionsResponse{} + conv26, err := convertSlice(v.ModelVersions, ModelVersionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetLatestVersionsResponse.ModelVersions", err) + } + out.ModelVersions = conv26 + return out, nil +} + +// GetModelVersionDownloadUriRequestToSDK converts the mirror to the sdk-go type. +func GetModelVersionDownloadUriRequestToSDK(w *GetModelVersionDownloadUriRequest) (*sdk.GetModelVersionDownloadUriRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetModelVersionDownloadUriRequest{} + out.Name = w.Name + out.Version = w.Version + return out, nil +} + +// GetModelVersionDownloadUriRequestFromSDK converts the sdk-go type to the mirror. +func GetModelVersionDownloadUriRequestFromSDK(v *sdk.GetModelVersionDownloadUriRequest) (*GetModelVersionDownloadUriRequest, error) { + if v == nil { + return nil, nil + } + out := &GetModelVersionDownloadUriRequest{} + out.Name = v.Name + out.Version = v.Version + return out, nil +} + +// GetModelVersionDownloadUriResponseToSDK converts the mirror to the sdk-go type. +func GetModelVersionDownloadUriResponseToSDK(w *GetModelVersionDownloadUriResponse) (*sdk.GetModelVersionDownloadUriResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetModelVersionDownloadUriResponse{} + out.ArtifactUri = w.ArtifactUri + return out, nil +} + +// GetModelVersionDownloadUriResponseFromSDK converts the sdk-go type to the mirror. +func GetModelVersionDownloadUriResponseFromSDK(v *sdk.GetModelVersionDownloadUriResponse) (*GetModelVersionDownloadUriResponse, error) { + if v == nil { + return nil, nil + } + out := &GetModelVersionDownloadUriResponse{} + out.ArtifactUri = v.ArtifactUri + return out, nil +} + +// GetModelVersionRequestToSDK converts the mirror to the sdk-go type. +func GetModelVersionRequestToSDK(w *GetModelVersionRequest) (*sdk.GetModelVersionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetModelVersionRequest{} + out.Name = w.Name + out.Version = w.Version + return out, nil +} + +// GetModelVersionRequestFromSDK converts the sdk-go type to the mirror. +func GetModelVersionRequestFromSDK(v *sdk.GetModelVersionRequest) (*GetModelVersionRequest, error) { + if v == nil { + return nil, nil + } + out := &GetModelVersionRequest{} + out.Name = v.Name + out.Version = v.Version + return out, nil +} + +// GetModelVersionResponseToSDK converts the mirror to the sdk-go type. +func GetModelVersionResponseToSDK(w *GetModelVersionResponse) (*sdk.GetModelVersionResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetModelVersionResponse{} + conv27, err := ModelVersionToSDK(w.ModelVersion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetModelVersionResponse.ModelVersion", err) + } + out.ModelVersion = conv27 + return out, nil +} + +// GetModelVersionResponseFromSDK converts the sdk-go type to the mirror. +func GetModelVersionResponseFromSDK(v *sdk.GetModelVersionResponse) (*GetModelVersionResponse, error) { + if v == nil { + return nil, nil + } + out := &GetModelVersionResponse{} + conv28, err := ModelVersionFromSDK(v.ModelVersion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetModelVersionResponse.ModelVersion", err) + } + out.ModelVersion = conv28 + return out, nil +} + +// GetRegisteredModelDatabricksRequestToSDK converts the mirror to the sdk-go type. +func GetRegisteredModelDatabricksRequestToSDK(w *GetRegisteredModelDatabricksRequest) (*sdk.GetRegisteredModelDatabricksRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetRegisteredModelDatabricksRequest{} + out.Name = w.Name + return out, nil +} + +// GetRegisteredModelDatabricksRequestFromSDK converts the sdk-go type to the mirror. +func GetRegisteredModelDatabricksRequestFromSDK(v *sdk.GetRegisteredModelDatabricksRequest) (*GetRegisteredModelDatabricksRequest, error) { + if v == nil { + return nil, nil + } + out := &GetRegisteredModelDatabricksRequest{} + out.Name = v.Name + return out, nil +} + +// GetRegisteredModelDatabricksResponseToSDK converts the mirror to the sdk-go type. +func GetRegisteredModelDatabricksResponseToSDK(w *GetRegisteredModelDatabricksResponse) (*sdk.GetRegisteredModelDatabricksResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetRegisteredModelDatabricksResponse{} + conv29, err := RegisteredModelDatabricksToSDK(w.RegisteredModelDatabricks) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRegisteredModelDatabricksResponse.RegisteredModelDatabricks", err) + } + out.RegisteredModelDatabricks = conv29 + return out, nil +} + +// GetRegisteredModelDatabricksResponseFromSDK converts the sdk-go type to the mirror. +func GetRegisteredModelDatabricksResponseFromSDK(v *sdk.GetRegisteredModelDatabricksResponse) (*GetRegisteredModelDatabricksResponse, error) { + if v == nil { + return nil, nil + } + out := &GetRegisteredModelDatabricksResponse{} + conv30, err := RegisteredModelDatabricksFromSDK(v.RegisteredModelDatabricks) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRegisteredModelDatabricksResponse.RegisteredModelDatabricks", err) + } + out.RegisteredModelDatabricks = conv30 + return out, nil +} + +// HttpUrlSpecToSDK converts the mirror to the sdk-go type. +func HttpUrlSpecToSDK(w *HttpUrlSpec) (*sdk.HttpUrlSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.HttpUrlSpec{} + out.Url = w.Url + out.EnableSslVerification = w.EnableSslVerification + out.Secret = w.Secret + out.Authorization = w.Authorization + return out, nil +} + +// HttpUrlSpecFromSDK converts the sdk-go type to the mirror. +func HttpUrlSpecFromSDK(v *sdk.HttpUrlSpec) (*HttpUrlSpec, error) { + if v == nil { + return nil, nil + } + out := &HttpUrlSpec{} + out.Url = v.Url + out.EnableSslVerification = v.EnableSslVerification + out.Secret = v.Secret + out.Authorization = v.Authorization + return out, nil +} + +// JobSpecToSDK converts the mirror to the sdk-go type. +func JobSpecToSDK(w *JobSpec) (*sdk.JobSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.JobSpec{} + out.JobId = w.JobId + out.WorkspaceUrl = w.WorkspaceUrl + out.AccessToken = w.AccessToken + return out, nil +} + +// JobSpecFromSDK converts the sdk-go type to the mirror. +func JobSpecFromSDK(v *sdk.JobSpec) (*JobSpec, error) { + if v == nil { + return nil, nil + } + out := &JobSpec{} + out.JobId = v.JobId + out.WorkspaceUrl = v.WorkspaceUrl + out.AccessToken = v.AccessToken + return out, nil +} + +// LinkedFeatureToSDK converts the mirror to the sdk-go type. +func LinkedFeatureToSDK(w *LinkedFeature) (*sdk.LinkedFeature, error) { + if w == nil { + return nil, nil + } + out := &sdk.LinkedFeature{} + out.FeatureTableName = w.FeatureTableName + out.FeatureName = w.FeatureName + out.FeatureTableId = w.FeatureTableId + return out, nil +} + +// LinkedFeatureFromSDK converts the sdk-go type to the mirror. +func LinkedFeatureFromSDK(v *sdk.LinkedFeature) (*LinkedFeature, error) { + if v == nil { + return nil, nil + } + out := &LinkedFeature{} + out.FeatureTableName = v.FeatureTableName + out.FeatureName = v.FeatureName + out.FeatureTableId = v.FeatureTableId + return out, nil +} + +// ListLatestVersionsRequestToSDK converts the mirror to the sdk-go type. +func ListLatestVersionsRequestToSDK(w *ListLatestVersionsRequest) (*sdk.ListLatestVersionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListLatestVersionsRequest{} + out.Name = w.Name + out.Stages = w.Stages + return out, nil +} + +// ListLatestVersionsRequestFromSDK converts the sdk-go type to the mirror. +func ListLatestVersionsRequestFromSDK(v *sdk.ListLatestVersionsRequest) (*ListLatestVersionsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListLatestVersionsRequest{} + out.Name = v.Name + out.Stages = v.Stages + return out, nil +} + +// ListRegisteredModelsRequestToSDK converts the mirror to the sdk-go type. +func ListRegisteredModelsRequestToSDK(w *ListRegisteredModelsRequest) (*sdk.ListRegisteredModelsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRegisteredModelsRequest{} + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListRegisteredModelsRequestFromSDK converts the sdk-go type to the mirror. +func ListRegisteredModelsRequestFromSDK(v *sdk.ListRegisteredModelsRequest) (*ListRegisteredModelsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListRegisteredModelsRequest{} + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListRegisteredModelsResponseToSDK converts the mirror to the sdk-go type. +func ListRegisteredModelsResponseToSDK(w *ListRegisteredModelsResponse) (*sdk.ListRegisteredModelsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRegisteredModelsResponse{} + conv31, err := convertSlice(w.RegisteredModels, RegisteredModelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRegisteredModelsResponse.RegisteredModels", err) + } + out.RegisteredModels = conv31 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListRegisteredModelsResponseFromSDK converts the sdk-go type to the mirror. +func ListRegisteredModelsResponseFromSDK(v *sdk.ListRegisteredModelsResponse) (*ListRegisteredModelsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListRegisteredModelsResponse{} + conv32, err := convertSlice(v.RegisteredModels, RegisteredModelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRegisteredModelsResponse.RegisteredModels", err) + } + out.RegisteredModels = conv32 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListRegistryWebhooksRequestToSDK converts the mirror to the sdk-go type. +func ListRegistryWebhooksRequestToSDK(w *ListRegistryWebhooksRequest) (*sdk.ListRegistryWebhooksRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRegistryWebhooksRequest{} + out.ModelName = w.ModelName + out.Events = w.Events + out.PageToken = w.PageToken + out.MaxResults = w.MaxResults + return out, nil +} + +// ListRegistryWebhooksRequestFromSDK converts the sdk-go type to the mirror. +func ListRegistryWebhooksRequestFromSDK(v *sdk.ListRegistryWebhooksRequest) (*ListRegistryWebhooksRequest, error) { + if v == nil { + return nil, nil + } + out := &ListRegistryWebhooksRequest{} + out.ModelName = v.ModelName + out.Events = v.Events + out.PageToken = v.PageToken + out.MaxResults = v.MaxResults + return out, nil +} + +// ListRegistryWebhooksResponseToSDK converts the mirror to the sdk-go type. +func ListRegistryWebhooksResponseToSDK(w *ListRegistryWebhooksResponse) (*sdk.ListRegistryWebhooksResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRegistryWebhooksResponse{} + conv33, err := convertSlice(w.Webhooks, RegistryWebhookToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRegistryWebhooksResponse.Webhooks", err) + } + out.Webhooks = conv33 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListRegistryWebhooksResponseFromSDK converts the sdk-go type to the mirror. +func ListRegistryWebhooksResponseFromSDK(v *sdk.ListRegistryWebhooksResponse) (*ListRegistryWebhooksResponse, error) { + if v == nil { + return nil, nil + } + out := &ListRegistryWebhooksResponse{} + conv34, err := convertSlice(v.Webhooks, RegistryWebhookFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRegistryWebhooksResponse.Webhooks", err) + } + out.Webhooks = conv34 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListTransitionRequestToSDK converts the mirror to the sdk-go type. +func ListTransitionRequestToSDK(w *ListTransitionRequest) (*sdk.ListTransitionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTransitionRequest{} + out.Name = w.Name + out.Version = w.Version + return out, nil +} + +// ListTransitionRequestFromSDK converts the sdk-go type to the mirror. +func ListTransitionRequestFromSDK(v *sdk.ListTransitionRequest) (*ListTransitionRequest, error) { + if v == nil { + return nil, nil + } + out := &ListTransitionRequest{} + out.Name = v.Name + out.Version = v.Version + return out, nil +} + +// ListTransitionResponseToSDK converts the mirror to the sdk-go type. +func ListTransitionResponseToSDK(w *ListTransitionResponse) (*sdk.ListTransitionResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTransitionResponse{} + conv35, err := convertSlice(w.Requests, ActivityToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTransitionResponse.Requests", err) + } + out.Requests = conv35 + return out, nil +} + +// ListTransitionResponseFromSDK converts the sdk-go type to the mirror. +func ListTransitionResponseFromSDK(v *sdk.ListTransitionResponse) (*ListTransitionResponse, error) { + if v == nil { + return nil, nil + } + out := &ListTransitionResponse{} + conv36, err := convertSlice(v.Requests, ActivityFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTransitionResponse.Requests", err) + } + out.Requests = conv36 + return out, nil +} + +// ModelVersionToSDK converts the mirror to the sdk-go type. +func ModelVersionToSDK(w *ModelVersion) (*sdk.ModelVersion, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelVersion{} + out.Name = w.Name + out.Version = w.Version + out.CreationTimestamp = w.CreationTimestamp + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + out.UserId = w.UserId + out.CurrentStage = w.CurrentStage + out.Description = w.Description + out.Source = w.Source + out.RunId = w.RunId + out.Status = w.Status + out.StatusMessage = w.StatusMessage + conv37, err := convertSlice(w.Tags, ModelVersionTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelVersion.Tags", err) + } + out.Tags = conv37 + out.RunLink = w.RunLink + return out, nil +} + +// ModelVersionFromSDK converts the sdk-go type to the mirror. +func ModelVersionFromSDK(v *sdk.ModelVersion) (*ModelVersion, error) { + if v == nil { + return nil, nil + } + out := &ModelVersion{} + out.Name = v.Name + out.Version = v.Version + out.CreationTimestamp = v.CreationTimestamp + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + out.UserId = v.UserId + out.CurrentStage = v.CurrentStage + out.Description = v.Description + out.Source = v.Source + out.RunId = v.RunId + out.Status = v.Status + out.StatusMessage = v.StatusMessage + conv38, err := convertSlice(v.Tags, ModelVersionTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelVersion.Tags", err) + } + out.Tags = conv38 + out.RunLink = v.RunLink + return out, nil +} + +// ModelVersionDatabricksToSDK converts the mirror to the sdk-go type. +func ModelVersionDatabricksToSDK(w *ModelVersionDatabricks) (*sdk.ModelVersionDatabricks, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelVersionDatabricks{} + out.Name = w.Name + out.Version = w.Version + out.CreationTimestamp = w.CreationTimestamp + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + out.UserId = w.UserId + out.CurrentStage = w.CurrentStage + out.Description = w.Description + out.Source = w.Source + out.RunId = w.RunId + out.Status = w.Status + out.StatusMessage = w.StatusMessage + conv39, err := convertSlice(w.OpenRequests, ActivityToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelVersionDatabricks.OpenRequests", err) + } + out.OpenRequests = conv39 + out.PermissionLevel = w.PermissionLevel + conv40, err := convertSlice(w.Tags, ModelVersionTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelVersionDatabricks.Tags", err) + } + out.Tags = conv40 + out.RunLink = w.RunLink + out.EmailSubscriptionStatus = w.EmailSubscriptionStatus + conv41, err := FeatureListToSDK(w.FeatureList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelVersionDatabricks.FeatureList", err) + } + out.FeatureList = conv41 + return out, nil +} + +// ModelVersionDatabricksFromSDK converts the sdk-go type to the mirror. +func ModelVersionDatabricksFromSDK(v *sdk.ModelVersionDatabricks) (*ModelVersionDatabricks, error) { + if v == nil { + return nil, nil + } + out := &ModelVersionDatabricks{} + out.Name = v.Name + out.Version = v.Version + out.CreationTimestamp = v.CreationTimestamp + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + out.UserId = v.UserId + out.CurrentStage = v.CurrentStage + out.Description = v.Description + out.Source = v.Source + out.RunId = v.RunId + out.Status = v.Status + out.StatusMessage = v.StatusMessage + conv42, err := convertSlice(v.OpenRequests, ActivityFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelVersionDatabricks.OpenRequests", err) + } + out.OpenRequests = conv42 + out.PermissionLevel = v.PermissionLevel + conv43, err := convertSlice(v.Tags, ModelVersionTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelVersionDatabricks.Tags", err) + } + out.Tags = conv43 + out.RunLink = v.RunLink + out.EmailSubscriptionStatus = v.EmailSubscriptionStatus + conv44, err := FeatureListFromSDK(v.FeatureList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelVersionDatabricks.FeatureList", err) + } + out.FeatureList = conv44 + return out, nil +} + +// ModelVersionTagToSDK converts the mirror to the sdk-go type. +func ModelVersionTagToSDK(w *ModelVersionTag) (*sdk.ModelVersionTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelVersionTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// ModelVersionTagFromSDK converts the sdk-go type to the mirror. +func ModelVersionTagFromSDK(v *sdk.ModelVersionTag) (*ModelVersionTag, error) { + if v == nil { + return nil, nil + } + out := &ModelVersionTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// RegisteredModelToSDK converts the mirror to the sdk-go type. +func RegisteredModelToSDK(w *RegisteredModel) (*sdk.RegisteredModel, error) { + if w == nil { + return nil, nil + } + out := &sdk.RegisteredModel{} + out.Name = w.Name + out.CreationTimestamp = w.CreationTimestamp + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + out.UserId = w.UserId + out.Description = w.Description + conv45, err := convertSlice(w.LatestVersions, ModelVersionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegisteredModel.LatestVersions", err) + } + out.LatestVersions = conv45 + conv46, err := convertSlice(w.Tags, RegisteredModelTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegisteredModel.Tags", err) + } + out.Tags = conv46 + return out, nil +} + +// RegisteredModelFromSDK converts the sdk-go type to the mirror. +func RegisteredModelFromSDK(v *sdk.RegisteredModel) (*RegisteredModel, error) { + if v == nil { + return nil, nil + } + out := &RegisteredModel{} + out.Name = v.Name + out.CreationTimestamp = v.CreationTimestamp + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + out.UserId = v.UserId + out.Description = v.Description + conv47, err := convertSlice(v.LatestVersions, ModelVersionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegisteredModel.LatestVersions", err) + } + out.LatestVersions = conv47 + conv48, err := convertSlice(v.Tags, RegisteredModelTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegisteredModel.Tags", err) + } + out.Tags = conv48 + return out, nil +} + +// RegisteredModelDatabricksToSDK converts the mirror to the sdk-go type. +func RegisteredModelDatabricksToSDK(w *RegisteredModelDatabricks) (*sdk.RegisteredModelDatabricks, error) { + if w == nil { + return nil, nil + } + out := &sdk.RegisteredModelDatabricks{} + out.Name = w.Name + out.CreationTimestamp = w.CreationTimestamp + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + out.UserId = w.UserId + out.Description = w.Description + conv49, err := convertSlice(w.LatestVersions, ModelVersionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegisteredModelDatabricks.LatestVersions", err) + } + out.LatestVersions = conv49 + out.Id = w.Id + out.PermissionLevel = w.PermissionLevel + conv50, err := convertSlice(w.Tags, RegisteredModelTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegisteredModelDatabricks.Tags", err) + } + out.Tags = conv50 + return out, nil +} + +// RegisteredModelDatabricksFromSDK converts the sdk-go type to the mirror. +func RegisteredModelDatabricksFromSDK(v *sdk.RegisteredModelDatabricks) (*RegisteredModelDatabricks, error) { + if v == nil { + return nil, nil + } + out := &RegisteredModelDatabricks{} + out.Name = v.Name + out.CreationTimestamp = v.CreationTimestamp + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + out.UserId = v.UserId + out.Description = v.Description + conv51, err := convertSlice(v.LatestVersions, ModelVersionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegisteredModelDatabricks.LatestVersions", err) + } + out.LatestVersions = conv51 + out.Id = v.Id + out.PermissionLevel = v.PermissionLevel + conv52, err := convertSlice(v.Tags, RegisteredModelTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegisteredModelDatabricks.Tags", err) + } + out.Tags = conv52 + return out, nil +} + +// RegisteredModelTagToSDK converts the mirror to the sdk-go type. +func RegisteredModelTagToSDK(w *RegisteredModelTag) (*sdk.RegisteredModelTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.RegisteredModelTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// RegisteredModelTagFromSDK converts the sdk-go type to the mirror. +func RegisteredModelTagFromSDK(v *sdk.RegisteredModelTag) (*RegisteredModelTag, error) { + if v == nil { + return nil, nil + } + out := &RegisteredModelTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// RegistryWebhookToSDK converts the mirror to the sdk-go type. +func RegistryWebhookToSDK(w *RegistryWebhook) (*sdk.RegistryWebhook, error) { + if w == nil { + return nil, nil + } + out := &sdk.RegistryWebhook{} + out.Id = w.Id + out.Events = w.Events + out.CreationTimestamp = w.CreationTimestamp + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + out.Description = w.Description + out.Status = w.Status + conv53, err := HttpUrlSpecToSDK(w.HttpUrlSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegistryWebhook.HttpUrlSpec", err) + } + out.HttpUrlSpec = conv53 + conv54, err := JobSpecToSDK(w.JobSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegistryWebhook.JobSpec", err) + } + out.JobSpec = conv54 + out.ModelName = w.ModelName + return out, nil +} + +// RegistryWebhookFromSDK converts the sdk-go type to the mirror. +func RegistryWebhookFromSDK(v *sdk.RegistryWebhook) (*RegistryWebhook, error) { + if v == nil { + return nil, nil + } + out := &RegistryWebhook{} + out.Id = v.Id + out.Events = v.Events + out.CreationTimestamp = v.CreationTimestamp + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + out.Description = v.Description + out.Status = v.Status + conv55, err := HttpUrlSpecFromSDK(v.HttpUrlSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegistryWebhook.HttpUrlSpec", err) + } + out.HttpUrlSpec = conv55 + conv56, err := JobSpecFromSDK(v.JobSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegistryWebhook.JobSpec", err) + } + out.JobSpec = conv56 + out.ModelName = v.ModelName + return out, nil +} + +// RejectTransitionRequestToSDK converts the mirror to the sdk-go type. +func RejectTransitionRequestToSDK(w *RejectTransitionRequest) (*sdk.RejectTransitionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RejectTransitionRequest{} + out.Name = w.Name + out.Version = w.Version + out.Stage = w.Stage + out.Comment = w.Comment + return out, nil +} + +// RejectTransitionRequestFromSDK converts the sdk-go type to the mirror. +func RejectTransitionRequestFromSDK(v *sdk.RejectTransitionRequest) (*RejectTransitionRequest, error) { + if v == nil { + return nil, nil + } + out := &RejectTransitionRequest{} + out.Name = v.Name + out.Version = v.Version + out.Stage = v.Stage + out.Comment = v.Comment + return out, nil +} + +// RejectTransitionResponseToSDK converts the mirror to the sdk-go type. +func RejectTransitionResponseToSDK(w *RejectTransitionResponse) (*sdk.RejectTransitionResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.RejectTransitionResponse{} + conv57, err := ActivityToSDK(w.Activity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RejectTransitionResponse.Activity", err) + } + out.Activity = conv57 + return out, nil +} + +// RejectTransitionResponseFromSDK converts the sdk-go type to the mirror. +func RejectTransitionResponseFromSDK(v *sdk.RejectTransitionResponse) (*RejectTransitionResponse, error) { + if v == nil { + return nil, nil + } + out := &RejectTransitionResponse{} + conv58, err := ActivityFromSDK(v.Activity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RejectTransitionResponse.Activity", err) + } + out.Activity = conv58 + return out, nil +} + +// RenameRegisteredModelRequestToSDK converts the mirror to the sdk-go type. +func RenameRegisteredModelRequestToSDK(w *RenameRegisteredModelRequest) (*sdk.RenameRegisteredModelRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RenameRegisteredModelRequest{} + out.Name = w.Name + out.NewName = w.NewName + return out, nil +} + +// RenameRegisteredModelRequestFromSDK converts the sdk-go type to the mirror. +func RenameRegisteredModelRequestFromSDK(v *sdk.RenameRegisteredModelRequest) (*RenameRegisteredModelRequest, error) { + if v == nil { + return nil, nil + } + out := &RenameRegisteredModelRequest{} + out.Name = v.Name + out.NewName = v.NewName + return out, nil +} + +// RenameRegisteredModelResponseToSDK converts the mirror to the sdk-go type. +func RenameRegisteredModelResponseToSDK(w *RenameRegisteredModelResponse) (*sdk.RenameRegisteredModelResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.RenameRegisteredModelResponse{} + conv59, err := RegisteredModelToSDK(w.RegisteredModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RenameRegisteredModelResponse.RegisteredModel", err) + } + out.RegisteredModel = conv59 + return out, nil +} + +// RenameRegisteredModelResponseFromSDK converts the sdk-go type to the mirror. +func RenameRegisteredModelResponseFromSDK(v *sdk.RenameRegisteredModelResponse) (*RenameRegisteredModelResponse, error) { + if v == nil { + return nil, nil + } + out := &RenameRegisteredModelResponse{} + conv60, err := RegisteredModelFromSDK(v.RegisteredModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RenameRegisteredModelResponse.RegisteredModel", err) + } + out.RegisteredModel = conv60 + return out, nil +} + +// SearchModelVersionsRequestToSDK converts the mirror to the sdk-go type. +func SearchModelVersionsRequestToSDK(w *SearchModelVersionsRequest) (*sdk.SearchModelVersionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchModelVersionsRequest{} + out.Filter = w.Filter + out.MaxResults = w.MaxResults + out.OrderBy = w.OrderBy + out.PageToken = w.PageToken + return out, nil +} + +// SearchModelVersionsRequestFromSDK converts the sdk-go type to the mirror. +func SearchModelVersionsRequestFromSDK(v *sdk.SearchModelVersionsRequest) (*SearchModelVersionsRequest, error) { + if v == nil { + return nil, nil + } + out := &SearchModelVersionsRequest{} + out.Filter = v.Filter + out.MaxResults = v.MaxResults + out.OrderBy = v.OrderBy + out.PageToken = v.PageToken + return out, nil +} + +// SearchModelVersionsResponseToSDK converts the mirror to the sdk-go type. +func SearchModelVersionsResponseToSDK(w *SearchModelVersionsResponse) (*sdk.SearchModelVersionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchModelVersionsResponse{} + conv61, err := convertSlice(w.ModelVersions, ModelVersionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchModelVersionsResponse.ModelVersions", err) + } + out.ModelVersions = conv61 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// SearchModelVersionsResponseFromSDK converts the sdk-go type to the mirror. +func SearchModelVersionsResponseFromSDK(v *sdk.SearchModelVersionsResponse) (*SearchModelVersionsResponse, error) { + if v == nil { + return nil, nil + } + out := &SearchModelVersionsResponse{} + conv62, err := convertSlice(v.ModelVersions, ModelVersionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchModelVersionsResponse.ModelVersions", err) + } + out.ModelVersions = conv62 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SearchRegisteredModelsRequestToSDK converts the mirror to the sdk-go type. +func SearchRegisteredModelsRequestToSDK(w *SearchRegisteredModelsRequest) (*sdk.SearchRegisteredModelsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchRegisteredModelsRequest{} + out.Filter = w.Filter + out.MaxResults = w.MaxResults + out.OrderBy = w.OrderBy + out.PageToken = w.PageToken + return out, nil +} + +// SearchRegisteredModelsRequestFromSDK converts the sdk-go type to the mirror. +func SearchRegisteredModelsRequestFromSDK(v *sdk.SearchRegisteredModelsRequest) (*SearchRegisteredModelsRequest, error) { + if v == nil { + return nil, nil + } + out := &SearchRegisteredModelsRequest{} + out.Filter = v.Filter + out.MaxResults = v.MaxResults + out.OrderBy = v.OrderBy + out.PageToken = v.PageToken + return out, nil +} + +// SearchRegisteredModelsResponseToSDK converts the mirror to the sdk-go type. +func SearchRegisteredModelsResponseToSDK(w *SearchRegisteredModelsResponse) (*sdk.SearchRegisteredModelsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.SearchRegisteredModelsResponse{} + conv63, err := convertSlice(w.RegisteredModels, RegisteredModelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchRegisteredModelsResponse.RegisteredModels", err) + } + out.RegisteredModels = conv63 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// SearchRegisteredModelsResponseFromSDK converts the sdk-go type to the mirror. +func SearchRegisteredModelsResponseFromSDK(v *sdk.SearchRegisteredModelsResponse) (*SearchRegisteredModelsResponse, error) { + if v == nil { + return nil, nil + } + out := &SearchRegisteredModelsResponse{} + conv64, err := convertSlice(v.RegisteredModels, RegisteredModelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SearchRegisteredModelsResponse.RegisteredModels", err) + } + out.RegisteredModels = conv64 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SetModelVersionTagRequestToSDK converts the mirror to the sdk-go type. +func SetModelVersionTagRequestToSDK(w *SetModelVersionTagRequest) (*sdk.SetModelVersionTagRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SetModelVersionTagRequest{} + out.Name = w.Name + out.Version = w.Version + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// SetModelVersionTagRequestFromSDK converts the sdk-go type to the mirror. +func SetModelVersionTagRequestFromSDK(v *sdk.SetModelVersionTagRequest) (*SetModelVersionTagRequest, error) { + if v == nil { + return nil, nil + } + out := &SetModelVersionTagRequest{} + out.Name = v.Name + out.Version = v.Version + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// SetRegisteredModelTagRequestToSDK converts the mirror to the sdk-go type. +func SetRegisteredModelTagRequestToSDK(w *SetRegisteredModelTagRequest) (*sdk.SetRegisteredModelTagRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SetRegisteredModelTagRequest{} + out.Name = w.Name + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// SetRegisteredModelTagRequestFromSDK converts the sdk-go type to the mirror. +func SetRegisteredModelTagRequestFromSDK(v *sdk.SetRegisteredModelTagRequest) (*SetRegisteredModelTagRequest, error) { + if v == nil { + return nil, nil + } + out := &SetRegisteredModelTagRequest{} + out.Name = v.Name + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// TestRegistryWebhookRequestToSDK converts the mirror to the sdk-go type. +func TestRegistryWebhookRequestToSDK(w *TestRegistryWebhookRequest) (*sdk.TestRegistryWebhookRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.TestRegistryWebhookRequest{} + out.Id = w.Id + out.Event = w.Event + return out, nil +} + +// TestRegistryWebhookRequestFromSDK converts the sdk-go type to the mirror. +func TestRegistryWebhookRequestFromSDK(v *sdk.TestRegistryWebhookRequest) (*TestRegistryWebhookRequest, error) { + if v == nil { + return nil, nil + } + out := &TestRegistryWebhookRequest{} + out.Id = v.Id + out.Event = v.Event + return out, nil +} + +// TestRegistryWebhookResponseToSDK converts the mirror to the sdk-go type. +func TestRegistryWebhookResponseToSDK(w *TestRegistryWebhookResponse) (*sdk.TestRegistryWebhookResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.TestRegistryWebhookResponse{} + out.StatusCode = w.StatusCode + out.Body = w.Body + return out, nil +} + +// TestRegistryWebhookResponseFromSDK converts the sdk-go type to the mirror. +func TestRegistryWebhookResponseFromSDK(v *sdk.TestRegistryWebhookResponse) (*TestRegistryWebhookResponse, error) { + if v == nil { + return nil, nil + } + out := &TestRegistryWebhookResponse{} + out.StatusCode = v.StatusCode + out.Body = v.Body + return out, nil +} + +// TransitionModelVersionStageDatabricksRequestToSDK converts the mirror to the sdk-go type. +func TransitionModelVersionStageDatabricksRequestToSDK(w *TransitionModelVersionStageDatabricksRequest) (*sdk.TransitionModelVersionStageDatabricksRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.TransitionModelVersionStageDatabricksRequest{} + out.Name = w.Name + out.Version = w.Version + out.Stage = w.Stage + out.ArchiveExistingVersions = w.ArchiveExistingVersions + out.Comment = w.Comment + return out, nil +} + +// TransitionModelVersionStageDatabricksRequestFromSDK converts the sdk-go type to the mirror. +func TransitionModelVersionStageDatabricksRequestFromSDK(v *sdk.TransitionModelVersionStageDatabricksRequest) (*TransitionModelVersionStageDatabricksRequest, error) { + if v == nil { + return nil, nil + } + out := &TransitionModelVersionStageDatabricksRequest{} + out.Name = v.Name + out.Version = v.Version + out.Stage = v.Stage + out.ArchiveExistingVersions = v.ArchiveExistingVersions + out.Comment = v.Comment + return out, nil +} + +// TransitionModelVersionStageDatabricksResponseToSDK converts the mirror to the sdk-go type. +func TransitionModelVersionStageDatabricksResponseToSDK(w *TransitionModelVersionStageDatabricksResponse) (*sdk.TransitionModelVersionStageDatabricksResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.TransitionModelVersionStageDatabricksResponse{} + conv65, err := ModelVersionDatabricksToSDK(w.ModelVersionDatabricks) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TransitionModelVersionStageDatabricksResponse.ModelVersionDatabricks", err) + } + out.ModelVersionDatabricks = conv65 + return out, nil +} + +// TransitionModelVersionStageDatabricksResponseFromSDK converts the sdk-go type to the mirror. +func TransitionModelVersionStageDatabricksResponseFromSDK(v *sdk.TransitionModelVersionStageDatabricksResponse) (*TransitionModelVersionStageDatabricksResponse, error) { + if v == nil { + return nil, nil + } + out := &TransitionModelVersionStageDatabricksResponse{} + conv66, err := ModelVersionDatabricksFromSDK(v.ModelVersionDatabricks) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TransitionModelVersionStageDatabricksResponse.ModelVersionDatabricks", err) + } + out.ModelVersionDatabricks = conv66 + return out, nil +} + +// TransitionRequestToSDK converts the mirror to the sdk-go type. +func TransitionRequestToSDK(w *TransitionRequest) (*sdk.TransitionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.TransitionRequest{} + out.CreationTimestamp = w.CreationTimestamp + out.UserId = w.UserId + out.ActivityType = w.ActivityType + out.Comment = w.Comment + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + out.FromStage = w.FromStage + out.ToStage = w.ToStage + out.SystemComment = w.SystemComment + out.AvailableActions = w.AvailableActions + out.Id = w.Id + return out, nil +} + +// TransitionRequestFromSDK converts the sdk-go type to the mirror. +func TransitionRequestFromSDK(v *sdk.TransitionRequest) (*TransitionRequest, error) { + if v == nil { + return nil, nil + } + out := &TransitionRequest{} + out.CreationTimestamp = v.CreationTimestamp + out.UserId = v.UserId + out.ActivityType = v.ActivityType + out.Comment = v.Comment + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + out.FromStage = v.FromStage + out.ToStage = v.ToStage + out.SystemComment = v.SystemComment + out.AvailableActions = v.AvailableActions + out.Id = v.Id + return out, nil +} + +// UpdateCommentRequestToSDK converts the mirror to the sdk-go type. +func UpdateCommentRequestToSDK(w *UpdateCommentRequest) (*sdk.UpdateCommentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCommentRequest{} + out.Id = w.Id + out.Comment = w.Comment + return out, nil +} + +// UpdateCommentRequestFromSDK converts the sdk-go type to the mirror. +func UpdateCommentRequestFromSDK(v *sdk.UpdateCommentRequest) (*UpdateCommentRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateCommentRequest{} + out.Id = v.Id + out.Comment = v.Comment + return out, nil +} + +// UpdateCommentResponseToSDK converts the mirror to the sdk-go type. +func UpdateCommentResponseToSDK(w *UpdateCommentResponse) (*sdk.UpdateCommentResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCommentResponse{} + conv67, err := CommentObjectToSDK(w.Comment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCommentResponse.Comment", err) + } + out.Comment = conv67 + return out, nil +} + +// UpdateCommentResponseFromSDK converts the sdk-go type to the mirror. +func UpdateCommentResponseFromSDK(v *sdk.UpdateCommentResponse) (*UpdateCommentResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateCommentResponse{} + conv68, err := CommentObjectFromSDK(v.Comment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCommentResponse.Comment", err) + } + out.Comment = conv68 + return out, nil +} + +// UpdateModelVersionRequestToSDK converts the mirror to the sdk-go type. +func UpdateModelVersionRequestToSDK(w *UpdateModelVersionRequest) (*sdk.UpdateModelVersionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateModelVersionRequest{} + out.Name = w.Name + out.Version = w.Version + out.Description = w.Description + return out, nil +} + +// UpdateModelVersionRequestFromSDK converts the sdk-go type to the mirror. +func UpdateModelVersionRequestFromSDK(v *sdk.UpdateModelVersionRequest) (*UpdateModelVersionRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateModelVersionRequest{} + out.Name = v.Name + out.Version = v.Version + out.Description = v.Description + return out, nil +} + +// UpdateModelVersionResponseToSDK converts the mirror to the sdk-go type. +func UpdateModelVersionResponseToSDK(w *UpdateModelVersionResponse) (*sdk.UpdateModelVersionResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateModelVersionResponse{} + conv69, err := ModelVersionToSDK(w.ModelVersion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateModelVersionResponse.ModelVersion", err) + } + out.ModelVersion = conv69 + return out, nil +} + +// UpdateModelVersionResponseFromSDK converts the sdk-go type to the mirror. +func UpdateModelVersionResponseFromSDK(v *sdk.UpdateModelVersionResponse) (*UpdateModelVersionResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateModelVersionResponse{} + conv70, err := ModelVersionFromSDK(v.ModelVersion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateModelVersionResponse.ModelVersion", err) + } + out.ModelVersion = conv70 + return out, nil +} + +// UpdateRegisteredModelRequestToSDK converts the mirror to the sdk-go type. +func UpdateRegisteredModelRequestToSDK(w *UpdateRegisteredModelRequest) (*sdk.UpdateRegisteredModelRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRegisteredModelRequest{} + out.Name = w.Name + out.Description = w.Description + return out, nil +} + +// UpdateRegisteredModelRequestFromSDK converts the sdk-go type to the mirror. +func UpdateRegisteredModelRequestFromSDK(v *sdk.UpdateRegisteredModelRequest) (*UpdateRegisteredModelRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateRegisteredModelRequest{} + out.Name = v.Name + out.Description = v.Description + return out, nil +} + +// UpdateRegisteredModelResponseToSDK converts the mirror to the sdk-go type. +func UpdateRegisteredModelResponseToSDK(w *UpdateRegisteredModelResponse) (*sdk.UpdateRegisteredModelResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRegisteredModelResponse{} + conv71, err := RegisteredModelToSDK(w.RegisteredModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRegisteredModelResponse.RegisteredModel", err) + } + out.RegisteredModel = conv71 + return out, nil +} + +// UpdateRegisteredModelResponseFromSDK converts the sdk-go type to the mirror. +func UpdateRegisteredModelResponseFromSDK(v *sdk.UpdateRegisteredModelResponse) (*UpdateRegisteredModelResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateRegisteredModelResponse{} + conv72, err := RegisteredModelFromSDK(v.RegisteredModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRegisteredModelResponse.RegisteredModel", err) + } + out.RegisteredModel = conv72 + return out, nil +} + +// UpdateRegistryWebhookRequestToSDK converts the mirror to the sdk-go type. +func UpdateRegistryWebhookRequestToSDK(w *UpdateRegistryWebhookRequest) (*sdk.UpdateRegistryWebhookRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRegistryWebhookRequest{} + out.Id = w.Id + out.Events = w.Events + out.Description = w.Description + out.Status = w.Status + conv73, err := HttpUrlSpecToSDK(w.HttpUrlSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRegistryWebhookRequest.HttpUrlSpec", err) + } + out.HttpUrlSpec = conv73 + conv74, err := JobSpecToSDK(w.JobSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRegistryWebhookRequest.JobSpec", err) + } + out.JobSpec = conv74 + return out, nil +} + +// UpdateRegistryWebhookRequestFromSDK converts the sdk-go type to the mirror. +func UpdateRegistryWebhookRequestFromSDK(v *sdk.UpdateRegistryWebhookRequest) (*UpdateRegistryWebhookRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateRegistryWebhookRequest{} + out.Id = v.Id + out.Events = v.Events + out.Description = v.Description + out.Status = v.Status + conv75, err := HttpUrlSpecFromSDK(v.HttpUrlSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRegistryWebhookRequest.HttpUrlSpec", err) + } + out.HttpUrlSpec = conv75 + conv76, err := JobSpecFromSDK(v.JobSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRegistryWebhookRequest.JobSpec", err) + } + out.JobSpec = conv76 + return out, nil +} + +// UpdateRegistryWebhookResponseToSDK converts the mirror to the sdk-go type. +func UpdateRegistryWebhookResponseToSDK(w *UpdateRegistryWebhookResponse) (*sdk.UpdateRegistryWebhookResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRegistryWebhookResponse{} + conv77, err := RegistryWebhookToSDK(w.Webhook) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRegistryWebhookResponse.Webhook", err) + } + out.Webhook = conv77 + return out, nil +} + +// UpdateRegistryWebhookResponseFromSDK converts the sdk-go type to the mirror. +func UpdateRegistryWebhookResponseFromSDK(v *sdk.UpdateRegistryWebhookResponse) (*UpdateRegistryWebhookResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateRegistryWebhookResponse{} + conv78, err := RegistryWebhookFromSDK(v.Webhook) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRegistryWebhookResponse.Webhook", err) + } + out.Webhook = conv78 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/modelserving/v1/types.generated.go b/libs/sdktypes/modelserving/v1/types.generated.go new file mode 100644 index 00000000000..5bb13ea3d32 --- /dev/null +++ b/libs/sdktypes/modelserving/v1/types.generated.go @@ -0,0 +1,3513 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/modelserving/v1. DO NOT EDIT. + +package modelserving + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/modelserving/v1" + + strings "strings" +) + +type ( + Behavior = sdk.Behavior + ServedModelDeploymentState = sdk.ServedModelDeploymentState + ServingEndpointDetailedPermissionLevel = sdk.ServingEndpointDetailedPermissionLevel + TelemetryFeature = sdk.TelemetryFeature + ExternalFunctionRequest_HttpMethod = sdk.ExternalFunctionRequest_HttpMethod + InferenceEndpointState_ConfigUpdateState = sdk.InferenceEndpointState_ConfigUpdateState + InferenceEndpointState_ReadyState = sdk.InferenceEndpointState_ReadyState +) + +const ( + Behavior_Unspecified = sdk.Behavior_Unspecified + Behavior_None = sdk.Behavior_None + Behavior_Block = sdk.Behavior_Block + Behavior_Mask = sdk.Behavior_Mask + ServedModelDeploymentState_Unspecified = sdk.ServedModelDeploymentState_Unspecified + ServedModelDeploymentState_DeploymentCreating = sdk.ServedModelDeploymentState_DeploymentCreating + ServedModelDeploymentState_DeploymentRecovering = sdk.ServedModelDeploymentState_DeploymentRecovering + ServedModelDeploymentState_DeploymentReady = sdk.ServedModelDeploymentState_DeploymentReady + ServedModelDeploymentState_DeploymentFailed = sdk.ServedModelDeploymentState_DeploymentFailed + ServedModelDeploymentState_DeploymentAborted = sdk.ServedModelDeploymentState_DeploymentAborted + ServedModelDeploymentState_DeploymentStopped = sdk.ServedModelDeploymentState_DeploymentStopped + ServingEndpointDetailedPermissionLevel_Unspecified = sdk.ServingEndpointDetailedPermissionLevel_Unspecified + ServingEndpointDetailedPermissionLevel_CanManage = sdk.ServingEndpointDetailedPermissionLevel_CanManage + ServingEndpointDetailedPermissionLevel_CanQuery = sdk.ServingEndpointDetailedPermissionLevel_CanQuery + ServingEndpointDetailedPermissionLevel_CanView = sdk.ServingEndpointDetailedPermissionLevel_CanView + TelemetryFeature_Unspecified = sdk.TelemetryFeature_Unspecified + TelemetryFeature_TelemetryFeatureLogs = sdk.TelemetryFeature_TelemetryFeatureLogs + TelemetryFeature_TelemetryFeatureTraces = sdk.TelemetryFeature_TelemetryFeatureTraces + TelemetryFeature_TelemetryFeatureMetrics = sdk.TelemetryFeature_TelemetryFeatureMetrics + TelemetryFeature_TelemetryFeatureInferenceTable = sdk.TelemetryFeature_TelemetryFeatureInferenceTable + ExternalFunctionRequest_HttpMethod_Unspecified = sdk.ExternalFunctionRequest_HttpMethod_Unspecified + ExternalFunctionRequest_HttpMethod_Get = sdk.ExternalFunctionRequest_HttpMethod_Get + ExternalFunctionRequest_HttpMethod_Post = sdk.ExternalFunctionRequest_HttpMethod_Post + ExternalFunctionRequest_HttpMethod_Put = sdk.ExternalFunctionRequest_HttpMethod_Put + ExternalFunctionRequest_HttpMethod_Delete = sdk.ExternalFunctionRequest_HttpMethod_Delete + ExternalFunctionRequest_HttpMethod_Patch = sdk.ExternalFunctionRequest_HttpMethod_Patch + InferenceEndpointState_ConfigUpdateState_Unspecified = sdk.InferenceEndpointState_ConfigUpdateState_Unspecified + InferenceEndpointState_ConfigUpdateState_NotUpdating = sdk.InferenceEndpointState_ConfigUpdateState_NotUpdating + InferenceEndpointState_ConfigUpdateState_InProgress = sdk.InferenceEndpointState_ConfigUpdateState_InProgress + InferenceEndpointState_ConfigUpdateState_UpdateFailed = sdk.InferenceEndpointState_ConfigUpdateState_UpdateFailed + InferenceEndpointState_ConfigUpdateState_UpdateCanceled = sdk.InferenceEndpointState_ConfigUpdateState_UpdateCanceled + InferenceEndpointState_ReadyState_Unspecified = sdk.InferenceEndpointState_ReadyState_Unspecified + InferenceEndpointState_ReadyState_Ready = sdk.InferenceEndpointState_ReadyState_Ready + InferenceEndpointState_ReadyState_NotReady = sdk.InferenceEndpointState_ReadyState_NotReady +) + +type Ai21LabsConfig struct { + // The secret key reference for an AI21 Labs API key. If you prefer + // to paste your API key directly, see `ai21labs_api_key_plaintext`. You must + // provide an API key using one of the following fields: `ai21labs_api_key` or + // `ai21labs_api_key_plaintext`. + Ai21labsApiKey *string `json:"ai21labs_api_key,omitempty"` + // An AI21 Labs API key provided as a plaintext string. If you prefer to + // reference your key using Databricks Secrets, see `ai21labs_api_key`. You must + // provide an API key using one of the following fields: `ai21labs_api_key` or + // `ai21labs_api_key_plaintext`. + Ai21labsApiKeyPlaintext *string `json:"ai21labs_api_key_plaintext,omitempty"` +} + +type AiGatewayConfig struct { + // Configuration for traffic fallback which auto fallbacks to other served + // entities if the request to a served entity fails with certain error codes, to + // increase availability. + FallbackConfig *FallbackConfig `json:"fallback_config,omitempty"` + // Configuration for AI Guardrails to prevent unwanted data and unsafe data in + // requests and responses. + Guardrails *AiGuardrails `json:"guardrails,omitempty"` + // Configuration for payload logging using inference tables. Use these tables to + // monitor and audit data being sent to and received from model APIs and to + // improve model quality. + InferenceTableConfig *InferenceTableConfig `json:"inference_table_config,omitempty"` + // Configuration for rate limits which can be set to limit endpoint traffic. + RateLimits []AiGatewayRateLimit `json:"rate_limits,omitempty"` + // Configuration to enable usage tracking using system tables. These tables + // allow you to monitor operational usage on endpoints and their associated + // costs. + UsageTrackingConfig *UsageTrackingConfig `json:"usage_tracking_config,omitempty"` +} + +type AiGatewayRateLimit struct { + // Used to specify how many calls are allowed for a key within the + // renewal_period. + Calls *int64 `json:"calls,omitempty"` + // Key field for a rate limit. Currently, 'user', 'user_group, + // 'service_principal', and 'endpoint' are supported, with 'endpoint' being the + // default if not specified. + Key *string `json:"key,omitempty"` + // Principal field for a user, user group, or service principal to apply rate + // limiting to. Accepts a user email, group name, or service principal + // application ID. + Principal *string `json:"principal,omitempty"` + // Renewal period field for a rate limit. Currently, only 'minute' is supported. + RenewalPeriod *string `json:"renewal_period,omitempty"` + // Used to specify how many tokens are allowed for a key within the + // renewal_period. + Tokens *int64 `json:"tokens,omitempty"` +} + +type AiGuardrailParameters struct { + // List of invalid keywords. AI guardrail uses keyword or string matching to + // decide if the keyword exists in the request or response content. + InvalidKeywords []string `json:"invalid_keywords,omitempty"` + // Configuration for guardrail PII filter. + Pii *PiiSettings `json:"pii,omitempty"` + // Indicates whether the safety filter is enabled. + Safety *bool `json:"safety,omitempty"` + // The list of allowed topics. Given a chat request, this guardrail flags the + // request if its topic is not in the allowed topics. + ValidTopics []string `json:"valid_topics,omitempty"` +} + +type AiGuardrails struct { + // Configuration for input guardrail filters. + Input *AiGuardrailParameters `json:"input,omitempty"` + // Configuration for output guardrail filters. + Output *AiGuardrailParameters `json:"output,omitempty"` +} + +type AmazonBedrockConfig struct { + // The secret key reference for an AWS access key ID with + // permissions to interact with Bedrock services. If you prefer to paste your + // API key directly, see `aws_access_key_id_plaintext`. You must provide an API + // key using one of the following fields: `aws_access_key_id` or + // `aws_access_key_id_plaintext`. + AwsAccessKeyId *string `json:"aws_access_key_id,omitempty"` + // An AWS access key ID with permissions to interact with Bedrock services + // provided as a plaintext string. If you prefer to reference your key using + // Databricks Secrets, see `aws_access_key_id`. You must provide an API key + // using one of the following fields: `aws_access_key_id` or + // `aws_access_key_id_plaintext`. + AwsAccessKeyIdPlaintext *string `json:"aws_access_key_id_plaintext,omitempty"` + // The AWS region to use. Bedrock has to be enabled there. + AwsRegion *string `json:"aws_region,omitempty"` + // The secret key reference for an AWS secret access key paired + // with the access key ID, with permissions to interact with Bedrock services. + // If you prefer to paste your API key directly, see + // `aws_secret_access_key_plaintext`. You must provide an API key using one of + // the following fields: `aws_secret_access_key` or + // `aws_secret_access_key_plaintext`. + AwsSecretAccessKey *string `json:"aws_secret_access_key,omitempty"` + // An AWS secret access key paired with the access key ID, with permissions to + // interact with Bedrock services provided as a plaintext string. If you prefer + // to reference your key using Databricks Secrets, see `aws_secret_access_key`. + // You must provide an API key using one of the following fields: + // `aws_secret_access_key` or `aws_secret_access_key_plaintext`. + AwsSecretAccessKeyPlaintext *string `json:"aws_secret_access_key_plaintext,omitempty"` + // The underlying provider in Amazon Bedrock. Supported values (case + // insensitive) include: Anthropic, Cohere, AI21Labs, Amazon. + BedrockProvider *string `json:"bedrock_provider,omitempty"` + // ARN of the instance profile that the external model will use to access AWS + // resources. You must authenticate using an instance profile or access keys. If + // you prefer to authenticate using access keys, see `aws_access_key_id`, + // `aws_access_key_id_plaintext`, `aws_secret_access_key` and + // `aws_secret_access_key_plaintext`. + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // The name of the Unity Catalog service credential that the external model uses + // to access AWS resources. + UcServiceCredentialName *string `json:"uc_service_credential_name,omitempty"` +} + +type AnthropicConfig struct { + // The secret key reference for an Anthropic API key. If you prefer + // to paste your API key directly, see `anthropic_api_key_plaintext`. You must + // provide an API key using one of the following fields: `anthropic_api_key` or + // `anthropic_api_key_plaintext`. + AnthropicApiKey *string `json:"anthropic_api_key,omitempty"` + // The Anthropic API key provided as a plaintext string. If you prefer to + // reference your key using Databricks Secrets, see `anthropic_api_key`. You + // must provide an API key using one of the following fields: + // `anthropic_api_key` or `anthropic_api_key_plaintext`. + AnthropicApiKeyPlaintext *string `json:"anthropic_api_key_plaintext,omitempty"` +} + +type ApiKeyAuth struct { + // The name of the API key parameter used for authentication. + Key *string `json:"key,omitempty"` + // The secret key reference for an API Key. If you prefer to paste + // your token directly, see `value_plaintext`. + Value *string `json:"value,omitempty"` + // The API Key provided as a plaintext string. If you prefer to reference your + // token using Databricks Secrets, see `value`. + ValuePlaintext *string `json:"value_plaintext,omitempty"` +} + +// Deprecated: legacy inference table configuration. Please use AI Gateway +// inference tables instead. See +// https://docs.databricks.com/aws/en/ai-gateway/inference-tables.. +type AutoCaptureConfig struct { + // The name of the catalog in Unity Catalog. NOTE: On update, you cannot change + // the catalog name if the inference table is already enabled. + CatalogName *string `json:"catalog_name,omitempty"` + // Indicates whether the inference table is enabled. + Enabled *bool `json:"enabled,omitempty"` + // The name of the schema in Unity Catalog. NOTE: On update, you cannot change + // the schema name if the inference table is already enabled. + SchemaName *string `json:"schema_name,omitempty"` + State *AutoCaptureState `json:"state,omitempty"` + // The prefix of the table in Unity Catalog. NOTE: On update, you cannot change + // the prefix name if the inference table is already enabled. + TableNamePrefix *string `json:"table_name_prefix,omitempty"` +} + +type AutoCaptureState struct { + PayloadTable *PayloadTable `json:"payload_table,omitempty"` +} + +type BearerTokenAuth struct { + // The secret key reference for a token. If you prefer to paste + // your token directly, see `token_plaintext`. + Token *string `json:"token,omitempty"` + // The token provided as a plaintext string. If you prefer to reference your + // token using Databricks Secrets, see `token`. + TokenPlaintext *string `json:"token_plaintext,omitempty"` +} + +type CohereConfig struct { + // This is an optional field to provide a customized base URL for the Cohere + // API. If left unspecified, the standard Cohere base URL is used. + CohereApiBase *string `json:"cohere_api_base,omitempty"` + // The secret key reference for a Cohere API key. If you prefer to + // paste your API key directly, see `cohere_api_key_plaintext`. You must provide + // an API key using one of the following fields: `cohere_api_key` or + // `cohere_api_key_plaintext`. + CohereApiKey *string `json:"cohere_api_key,omitempty"` + // The Cohere API key provided as a plaintext string. If you prefer to reference + // your key using Databricks Secrets, see `cohere_api_key`. You must provide an + // API key using one of the following fields: `cohere_api_key` or + // `cohere_api_key_plaintext`. + CohereApiKeyPlaintext *string `json:"cohere_api_key_plaintext,omitempty"` +} + +type CreateInferenceEndpointRequest struct { + // The AI Gateway configuration for the serving endpoint. NOTE: External model, + // provisioned throughput, and pay-per-token endpoints are fully supported; + // agent endpoints currently only support inference tables. + AiGateway *AiGatewayConfig `json:"ai_gateway,omitempty"` + // The budget policy to be applied to the serving endpoint. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // The core config of the serving endpoint. + Config *EndpointCoreConfig `json:"config,omitempty"` + Description *string `json:"description,omitempty"` + // Email notification settings. + EmailNotifications *EmailNotifications `json:"email_notifications,omitempty"` + // The name of the serving endpoint. This field is required and must be unique + // across a . An endpoint name can consist of alphanumeric + // characters, dashes, and underscores. + Name *string `json:"name,omitempty"` + // Rate limits to be applied to the serving endpoint. NOTE: this field is + // deprecated, please use AI Gateway to manage rate limits. + RateLimits []RateLimit `json:"rate_limits,omitempty"` + // Enable route optimization for the serving endpoint. + RouteOptimized *bool `json:"route_optimized,omitempty"` + // Tags to be attached to the serving endpoint and automatically propagated to + // billing logs. + Tags []EndpointTag `json:"tags,omitempty"` + // Configuration for persisting endpoint telemetry (logs, traces, and metrics) + // to Unity Catalog tables. + TelemetryConfig *TelemetryConfig `json:"telemetry_config,omitempty"` +} + +type CreatePtEndpointRequest struct { + // The AI Gateway configuration for the serving endpoint. + AiGateway *AiGatewayConfig `json:"ai_gateway,omitempty"` + // The budget policy associated with the endpoint. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // The core config of the serving endpoint. + Config *PtEndpointCoreConfig `json:"config,omitempty"` + // Email notification settings. + EmailNotifications *EmailNotifications `json:"email_notifications,omitempty"` + // The name of the serving endpoint. This field is required and must be unique + // across a . An endpoint name can consist of alphanumeric + // characters, dashes, and underscores. + Name *string `json:"name,omitempty"` + // Tags to be attached to the serving endpoint and automatically propagated to + // billing logs. + Tags []EndpointTag `json:"tags,omitempty"` +} + +// Configs needed to create a custom provider model route.. +type CustomProviderConfig struct { + // This is a field to provide API key authentication for the custom provider + // API. You can only specify one authentication method. + ApiKeyAuth *ApiKeyAuth `json:"api_key_auth,omitempty"` + // This is a field to provide bearer token authentication for the custom + // provider API. You can only specify one authentication method. + BearerTokenAuth *BearerTokenAuth `json:"bearer_token_auth,omitempty"` + // This is a field to provide the URL of the custom provider API. + CustomProviderUrl *string `json:"custom_provider_url,omitempty"` +} + +// Details necessary to query this object's API through the DataPlane APIs.. +type DataPlaneInfo struct { + // Authorization details as a string. + AuthorizationDetails *string `json:"authorization_details,omitempty"` + // The URL of the endpoint for this operation in the dataplane. + EndpointUrl *string `json:"endpoint_url,omitempty"` +} + +type DatabricksModelServingConfig struct { + // The secret key reference for a Databricks API token that + // corresponds to a user or service principal with Can Query access to the model + // serving endpoint pointed to by this external model. If you prefer to paste + // your API key directly, see `databricks_api_token_plaintext`. You must provide + // an API key using one of the following fields: `databricks_api_token` or + // `databricks_api_token_plaintext`. + DatabricksApiToken *string `json:"databricks_api_token,omitempty"` + // The Databricks API token that corresponds to a user or service principal with + // Can Query access to the model serving endpoint pointed to by this external + // model provided as a plaintext string. If you prefer to reference your key + // using Databricks Secrets, see `databricks_api_token`. You must provide an API + // key using one of the following fields: `databricks_api_token` or + // `databricks_api_token_plaintext`. + DatabricksApiTokenPlaintext *string `json:"databricks_api_token_plaintext,omitempty"` + // The URL of the workspace containing the model serving endpoint + // pointed to by this external model. + DatabricksWorkspaceUrl *string `json:"databricks_workspace_url,omitempty"` +} + +type EmailNotifications struct { + // A list of email addresses to be notified when an endpoint fails to update its + // configuration or state. + OnUpdateFailure []string `json:"on_update_failure,omitempty"` + // A list of email addresses to be notified when an endpoint successfully + // updates its configuration or state. + OnUpdateSuccess []string `json:"on_update_success,omitempty"` +} + +type EndpointCoreConfig struct { + // Configuration for legacy Inference Tables which automatically log requests + // and responses to Unity Catalog. Deprecated: please use AI Gateway inference + // tables instead. See + // https://docs.databricks.com/aws/en/ai-gateway/inference-tables. + AutoCaptureConfig *AutoCaptureConfig `json:"auto_capture_config,omitempty"` + // The list of served entities under the serving endpoint config. + ServedEntities []ServedModel `json:"served_entities,omitempty"` + // (Deprecated, use served_entities instead) The list of served models under the + // serving endpoint config. + ServedModels []ServedModel `json:"served_models,omitempty"` + // The traffic configuration associated with the serving endpoint config. + TrafficConfig *TrafficConfig `json:"traffic_config,omitempty"` +} + +type EndpointCoreConfigOutput struct { + // Configuration for legacy Inference Tables which automatically log requests + // and responses to Unity Catalog. Deprecated: please use AI Gateway inference + // tables instead. See + // https://docs.databricks.com/aws/en/ai-gateway/inference-tables. + AutoCaptureConfig *AutoCaptureConfig `json:"auto_capture_config,omitempty"` + // The config version that the serving endpoint is currently serving. + ConfigVersion *int64 `json:"config_version,omitempty"` + // The list of served entities under the serving endpoint config. + ServedEntities []ServedModel `json:"served_entities,omitempty"` + // (Deprecated, use served_entities instead) The list of served models under the + // serving endpoint config. + ServedModels []ServedModel `json:"served_models,omitempty"` + // The traffic configuration associated with the serving endpoint config. + TrafficConfig *TrafficConfig `json:"traffic_config,omitempty"` +} + +type EndpointCoreConfigSummary struct { + // The list of served entities under the serving endpoint config. + ServedEntities []ServedModelLite `json:"served_entities,omitempty"` + // (Deprecated, use served_entities instead) The list of served models under the + // serving endpoint config. + ServedModels []ServedModelLite `json:"served_models,omitempty"` +} + +type EndpointTag struct { + // Key field for a serving endpoint tag. + Key *string `json:"key,omitempty"` + // Optional value field for a serving endpoint tag. + Value *string `json:"value,omitempty"` +} + +// Simple Proto message for testing. +type ExternalFunctionRequest struct { + // The connection name to use. This is required to identify the external + // connection. + ConnectionName *string `json:"connection_name,omitempty"` + // Additional headers for the request. If not provided, only auth headers from + // connections would be passed. + Headers *string `json:"headers,omitempty"` + // The JSON payload to send in the request body. + Json *string `json:"json,omitempty"` + // The HTTP method to use (e.g., 'GET', 'POST'). + Method ExternalFunctionRequest_HttpMethod `json:"method,omitempty"` + // Query parameters for the request. + Params *string `json:"params,omitempty"` + // The relative path for the API endpoint. This is required. + Path *string `json:"path,omitempty"` + // Optional subdomain to prepend to the connection URL's host. If provided, this + // will be added as a prefix to the connection URL's host. For example, if the + // connection URL is `https://api.example.com/v1` and `sub_domain` is + // `"custom"`, the resulting URL will be `https://custom.api.example.com/v1`. + SubDomain *string `json:"sub_domain,omitempty"` +} + +type ExternalModel struct { + Ai21labsConfig *Ai21LabsConfig `json:"ai21labs_config,omitempty"` + AmazonBedrockConfig *AmazonBedrockConfig `json:"amazon_bedrock_config,omitempty"` + AnthropicConfig *AnthropicConfig `json:"anthropic_config,omitempty"` + CohereConfig *CohereConfig `json:"cohere_config,omitempty"` + CustomProviderConfig *CustomProviderConfig `json:"custom_provider_config,omitempty"` + DatabricksModelServingConfig *DatabricksModelServingConfig `json:"databricks_model_serving_config,omitempty"` + GoogleCloudVertexAiConfig *GoogleCloudVertexAiConfig `json:"google_cloud_vertex_ai_config,omitempty"` + // The name of the external model. + Name *string `json:"name,omitempty"` + OpenaiConfig *OpenAiConfig `json:"openai_config,omitempty"` + PalmConfig *PaLmConfig `json:"palm_config,omitempty"` + // The name of the provider for the external model. Currently, the supported + // providers are 'ai21labs', 'anthropic', 'amazon-bedrock', 'cohere', + // 'databricks-model-serving', 'google-cloud-vertex-ai', 'openai', 'palm', and + // 'custom'. + Provider *string `json:"provider,omitempty"` + // The task type of the external model. + Task *string `json:"task,omitempty"` +} + +type FallbackConfig struct { + // Whether to enable traffic fallback. When a served entity in the serving + // endpoint returns specific error codes (e.g. 500), the request will + // automatically be round-robin attempted with other served entities in the same + // endpoint, following the order of served entity list, until a successful + // response is returned. If all attempts fail, return the last response with the + // error code. + Enabled *bool `json:"enabled,omitempty"` +} + +// All fields are not sensitive as they are hard-coded in the system and made +// available to customers.. +type FoundationModel struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + Docs *string `json:"docs,omitempty"` + Name *string `json:"name,omitempty"` +} + +type GetServedModelBuildLogsResponse struct { + // The logs associated with building the served entity's environment. + Logs *string `json:"logs,omitempty"` +} + +type GetServedModelLogsResponse struct { + // The most recent log lines of the model server processing invocation requests. + Logs *string `json:"logs,omitempty"` +} + +type GoogleCloudVertexAiConfig struct { + // The secret key reference for a private key for the service + // account which has access to the Google Cloud Vertex AI Service. See [Best + // practices for managing service account keys]. If you prefer to paste your API + // key directly, see `private_key_plaintext`. You must provide an API key using + // one of the following fields: `private_key` or `private_key_plaintext` + // + // [Best practices for managing service account keys]: + // https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys + PrivateKey *string `json:"private_key,omitempty"` + // The private key for the service account which has access to the Google Cloud + // Vertex AI Service provided as a plaintext secret. See [Best practices for + // managing service account keys]. If you prefer to reference your key using + // Databricks Secrets, see `private_key`. You must provide an API key using one + // of the following fields: `private_key` or `private_key_plaintext`. + // + // [Best practices for managing service account keys]: + // https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys + PrivateKeyPlaintext *string `json:"private_key_plaintext,omitempty"` + // This is the Google Cloud project id that the service account is associated + // with. + ProjectId *string `json:"project_id,omitempty"` + // This is the region for the Google Cloud Vertex AI Service. See [supported + // regions] for more details. Some models are only available in specific + // regions. + // + // [supported regions]: + // https://cloud.google.com/vertex-ai/docs/general/locations + Region *string `json:"region,omitempty"` +} + +type InferenceEndpoint struct { + // The AI Gateway configuration for the serving endpoint. NOTE: External model, + // provisioned throughput, and pay-per-token endpoints are fully supported; + // agent endpoints currently only support inference tables. + AiGateway *AiGatewayConfig `json:"ai_gateway,omitempty"` + // The budget policy associated with the endpoint. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // The config that is currently being served by the endpoint. + Config *EndpointCoreConfigSummary `json:"config,omitempty"` + // The timestamp when the endpoint was created in Unix time. + CreationTimestamp *int64 `json:"creation_timestamp,omitempty"` + // The email of the user who created the serving endpoint. + Creator *string `json:"creator,omitempty"` + // Description of the endpoint + Description *string `json:"description,omitempty"` + // System-generated ID of the endpoint, included to be used by the Permissions + // API. + Id *string `json:"id,omitempty"` + // The timestamp when the endpoint was last updated by a user in Unix time. + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // The name of the serving endpoint. + Name *string `json:"name,omitempty"` + // Information corresponding to the state of the serving endpoint. + State *InferenceEndpointState `json:"state,omitempty"` + // Tags attached to the serving endpoint. + Tags []EndpointTag `json:"tags,omitempty"` + // The task type of the serving endpoint. + Task *string `json:"task,omitempty"` + // Telemetry configuration for the endpoint, including inference-table payload + // logging. + TelemetryConfig *TelemetryConfig `json:"telemetry_config,omitempty"` + // The usage policy associated with serving endpoint. + UsagePolicyId *string `json:"usage_policy_id,omitempty"` +} + +type InferenceEndpointDetailed struct { + // The AI Gateway configuration for the serving endpoint. NOTE: External model, + // provisioned throughput, and pay-per-token endpoints are fully supported; + // agent endpoints currently only support inference tables. + AiGateway *AiGatewayConfig `json:"ai_gateway,omitempty"` + // The budget policy associated with the endpoint. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // The config that is currently being served by the endpoint. + Config *EndpointCoreConfigOutput `json:"config,omitempty"` + // The timestamp when the endpoint was created in Unix time. + CreationTimestamp *int64 `json:"creation_timestamp,omitempty"` + // The email of the user who created the serving endpoint. + Creator *string `json:"creator,omitempty"` + // Information required to query DataPlane APIs. + DataPlaneInfo *ModelDataPlaneInfo `json:"data_plane_info,omitempty"` + // Description of the serving model + Description *string `json:"description,omitempty"` + // Email notification settings. + EmailNotifications *EmailNotifications `json:"email_notifications,omitempty"` + // Endpoint invocation url if route optimization is enabled for endpoint + EndpointUrl *string `json:"endpoint_url,omitempty"` + // System-generated ID of the endpoint. This is used to refer to the endpoint in + // the Permissions API + Id *string `json:"id,omitempty"` + // The timestamp when the endpoint was last updated by a user in Unix time. + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // The name of the serving endpoint. + Name *string `json:"name,omitempty"` + // The config that the endpoint is attempting to update to. + PendingConfig *PendingConfig `json:"pending_config,omitempty"` + // The permission level of the principal making the request. + PermissionLevel ServingEndpointDetailedPermissionLevel `json:"permission_level,omitempty"` + // Boolean representing if route optimization has been enabled for the endpoint + RouteOptimized *bool `json:"route_optimized,omitempty"` + // Information corresponding to the state of the serving endpoint. + State *InferenceEndpointState `json:"state,omitempty"` + // Tags attached to the serving endpoint. + Tags []EndpointTag `json:"tags,omitempty"` + // The task type of the serving endpoint. + Task *string `json:"task,omitempty"` + // Telemetry configuration for the endpoint, including inference-table payload + // logging. + TelemetryConfig *TelemetryConfig `json:"telemetry_config,omitempty"` +} + +type InferenceEndpointState struct { + // The state of an endpoint's config update. This informs the user if the + // pending_config is in progress, if the update failed, or if there is no update + // in progress. Note that if the endpoint's config_update state value is + // IN_PROGRESS, another update can not be made until the update completes or + // fails. + ConfigUpdate InferenceEndpointState_ConfigUpdateState `json:"config_update,omitempty"` + // The state of an endpoint, indicating whether or not the endpoint is + // queryable. An endpoint is READY if all of the served entities in its active + // configuration are ready. If any of the actively served entities are in a + // non-ready state, the endpoint state will be NOT_READY. + Ready InferenceEndpointState_ReadyState `json:"ready,omitempty"` +} + +type InferenceTableConfig struct { + // The name of the catalog in Unity Catalog. Required when enabling inference + // tables. NOTE: On update, you have to disable inference table first in order + // to change the catalog name. + CatalogName *string `json:"catalog_name,omitempty"` + // Indicates whether the inference table is enabled. + Enabled *bool `json:"enabled,omitempty"` + // The name of the schema in Unity Catalog. Required when enabling inference + // tables. NOTE: On update, you have to disable inference table first in order + // to change the schema name. + SchemaName *string `json:"schema_name,omitempty"` + // The prefix of the table in Unity Catalog. NOTE: On update, you have to + // disable inference table first in order to change the prefix name. + TableNamePrefix *string `json:"table_name_prefix,omitempty"` +} + +type ListInferenceEndpointsResponse struct { + // The list of endpoints. + Endpoints []InferenceEndpoint `json:"endpoints,omitempty"` +} + +// A representation of all DataPlaneInfo for operations that can be done on a +// model through Data Plane APIs.. +type ModelDataPlaneInfo struct { + // Information required to query DataPlane API 'query' endpoint. + QueryInfo *DataPlaneInfo `json:"query_info,omitempty"` +} + +// Configs needed to create an OpenAI model route.. +type OpenAiConfig struct { + // This field is only required for Azure AD OpenAI and is the Microsoft Entra + // Client ID. + MicrosoftEntraClientId *string `json:"microsoft_entra_client_id,omitempty"` + // The secret key reference for a client secret used for Microsoft + // Entra ID authentication. If you prefer to paste your client secret directly, + // see `microsoft_entra_client_secret_plaintext`. You must provide an API key + // using one of the following fields: `microsoft_entra_client_secret` or + // `microsoft_entra_client_secret_plaintext`. + MicrosoftEntraClientSecret *string `json:"microsoft_entra_client_secret,omitempty"` + // The client secret used for Microsoft Entra ID authentication provided as a + // plaintext string. If you prefer to reference your key using Databricks + // Secrets, see `microsoft_entra_client_secret`. You must provide an API key + // using one of the following fields: `microsoft_entra_client_secret` or + // `microsoft_entra_client_secret_plaintext`. + MicrosoftEntraClientSecretPlaintext *string `json:"microsoft_entra_client_secret_plaintext,omitempty"` + // This field is only required for Azure AD OpenAI and is the Microsoft Entra + // Tenant ID. + MicrosoftEntraTenantId *string `json:"microsoft_entra_tenant_id,omitempty"` + // This is a field to provide a customized base URl for the OpenAI API. For + // Azure OpenAI, this field is required, and is the base URL for the Azure + // OpenAI API service provided by Azure. For other OpenAI API types, this field + // is optional, and if left unspecified, the standard OpenAI base URL is used. + OpenaiApiBase *string `json:"openai_api_base,omitempty"` + // The secret key reference for an OpenAI API key using the OpenAI + // or Azure service. If you prefer to paste your API key directly, see + // `openai_api_key_plaintext`. You must provide an API key using one of the + // following fields: `openai_api_key` or `openai_api_key_plaintext`. + OpenaiApiKey *string `json:"openai_api_key,omitempty"` + // The OpenAI API key using the OpenAI or Azure service provided as a plaintext + // string. If you prefer to reference your key using Databricks Secrets, see + // `openai_api_key`. You must provide an API key using one of the following + // fields: `openai_api_key` or `openai_api_key_plaintext`. + OpenaiApiKeyPlaintext *string `json:"openai_api_key_plaintext,omitempty"` + // This is an optional field to specify the type of OpenAI API to use. For Azure + // OpenAI, this field is required, and adjust this parameter to represent the + // preferred security access validation protocol. For access token validation, + // use azure. For authentication using Azure Active Directory (Azure AD) use, + // azuread. + OpenaiApiType *string `json:"openai_api_type,omitempty"` + // This is an optional field to specify the OpenAI API version. For Azure + // OpenAI, this field is required, and is the version of the Azure OpenAI + // service to utilize, specified by a date. + OpenaiApiVersion *string `json:"openai_api_version,omitempty"` + // This field is only required for Azure OpenAI and is the name of the + // deployment resource for the Azure OpenAI service. + OpenaiDeploymentName *string `json:"openai_deployment_name,omitempty"` + // This is an optional field to specify the organization in OpenAI or Azure + // OpenAI. + OpenaiOrganization *string `json:"openai_organization,omitempty"` +} + +type PaLmConfig struct { + // The secret key reference for a PaLM API key. If you prefer to + // paste your API key directly, see `palm_api_key_plaintext`. You must provide + // an API key using one of the following fields: `palm_api_key` or + // `palm_api_key_plaintext`. + PalmApiKey *string `json:"palm_api_key,omitempty"` + // The PaLM API key provided as a plaintext string. If you prefer to reference + // your key using Databricks Secrets, see `palm_api_key`. You must provide an + // API key using one of the following fields: `palm_api_key` or + // `palm_api_key_plaintext`. + PalmApiKeyPlaintext *string `json:"palm_api_key_plaintext,omitempty"` +} + +type PatchInferenceEndpointTagsRequest struct { + // List of endpoint tags to add + AddTags []EndpointTag `json:"add_tags,omitempty"` + // List of tag keys to delete + DeleteTags []string `json:"delete_tags,omitempty"` + // The name of the serving endpoint who's tags to patch. This field is required. + Name *string `json:"name,omitempty"` +} + +type PatchInferenceEndpointTagsResponse struct { + Tags []EndpointTag `json:"tags,omitempty"` +} + +// Updates the telemetry configuration of a serving endpoint.. +type PatchInferenceEndpointTelemetryConfigRequest struct { + // The name of the serving endpoint whose telemetry configuration is being + // updated. This field is required. + Name *string `json:"name,omitempty"` + // The telemetry configuration to be applied to the serving endpoint. Can + // specify either a telemetry_profile_id to use an existing profile, or + // table_names to create a new profile with the specified Unity Catalog tables. + // If not provided, the telemetry configuration will be removed from the + // endpoint. + TelemetryConfig *TelemetryConfig `json:"telemetry_config,omitempty"` +} + +type PayloadTable struct { + Name *string `json:"name,omitempty"` + Status *string `json:"status,omitempty"` + StatusMessage *string `json:"status_message,omitempty"` +} + +type PendingConfig struct { + // Configuration for legacy Inference Tables which automatically log requests + // and responses to Unity Catalog. Deprecated: please use AI Gateway inference + // tables instead. See + // https://docs.databricks.com/aws/en/ai-gateway/inference-tables. + AutoCaptureConfig *AutoCaptureConfig `json:"auto_capture_config,omitempty"` + // The config version that the serving endpoint is currently serving. + ConfigVersion *int `json:"config_version,omitempty"` + // The list of served entities belonging to the last issued update to the + // serving endpoint. + ServedEntities []ServedModel `json:"served_entities,omitempty"` + // (Deprecated, use served_entities instead) The list of served models belonging + // to the last issued update to the serving endpoint. + ServedModels []ServedModel `json:"served_models,omitempty"` + // The timestamp when the update to the pending config started. + StartTime *int64 `json:"start_time,omitempty"` + // The traffic config defining how invocations to the serving endpoint should be + // routed. + TrafficConfig *TrafficConfig `json:"traffic_config,omitempty"` +} + +type PiiSettings struct { + // Configuration for input guardrail filters. + Behavior Behavior `json:"behavior,omitempty"` +} + +type PtEndpointCoreConfig struct { + // The list of served entities under the serving endpoint config. + ServedEntities []PtServedModel `json:"served_entities,omitempty"` + TrafficConfig *TrafficConfig `json:"traffic_config,omitempty"` +} + +type PtServedModel struct { + // Whether burst scaling is enabled. When enabled (default), the endpoint can + // automatically scale up beyond provisioned capacity to handle traffic spikes. + // When disabled, the endpoint maintains fixed capacity at + // provisioned_model_units. + BurstScalingEnabled *bool `json:"burst_scaling_enabled,omitempty"` + // The name of the entity to be served. The entity may be a model in the + // Databricks Model Registry, a model in the Unity Catalog (UC), or a function + // of type FEATURE_SPEC in the UC. If it is a UC object, the full name of the + // object should be given in the form of + // **catalog_name.schema_name.model_name**. + EntityName *string `json:"entity_name,omitempty"` + EntityVersion *string `json:"entity_version,omitempty"` + // The name of a served entity. It must be unique across an endpoint. A served + // entity name can consist of alphanumeric characters, dashes, and underscores. + // If not specified for an external model, this field defaults to + // external_model.name, with '.' and ':' replaced with '-', and if not specified + // for other entities, it defaults to entity_name-entity_version. + Name *string `json:"name,omitempty"` + // The number of model units to be provisioned. + ProvisionedModelUnits *int64 `json:"provisioned_model_units,omitempty"` +} + +type PutInferenceEndpointAiGatewayRequest struct { + // Configuration for traffic fallback which auto fallbacks to other served + // entities if the request to a served entity fails with certain error codes, to + // increase availability. + FallbackConfig *FallbackConfig `json:"fallback_config,omitempty"` + // Configuration for AI Guardrails to prevent unwanted data and unsafe data in + // requests and responses. + Guardrails *AiGuardrails `json:"guardrails,omitempty"` + // Configuration for payload logging using inference tables. Use these tables to + // monitor and audit data being sent to and received from model APIs and to + // improve model quality. + InferenceTableConfig *InferenceTableConfig `json:"inference_table_config,omitempty"` + // The name of the serving endpoint whose AI Gateway is being updated. This + // field is required. + Name *string `json:"name,omitempty"` + // Configuration for rate limits which can be set to limit endpoint traffic. + RateLimits []AiGatewayRateLimit `json:"rate_limits,omitempty"` + // Configuration to enable usage tracking using system tables. These tables + // allow you to monitor operational usage on endpoints and their associated + // costs. + UsageTrackingConfig *UsageTrackingConfig `json:"usage_tracking_config,omitempty"` +} + +type PutInferenceEndpointAiGatewayResponse struct { + // Configuration for traffic fallback which auto fallbacks to other served + // entities if the request to a served entity fails with certain error codes, to + // increase availability. + FallbackConfig *FallbackConfig `json:"fallback_config,omitempty"` + // Configuration for AI Guardrails to prevent unwanted data and unsafe data in + // requests and responses. + Guardrails *AiGuardrails `json:"guardrails,omitempty"` + // Configuration for payload logging using inference tables. Use these tables to + // monitor and audit data being sent to and received from model APIs and to + // improve model quality. + InferenceTableConfig *InferenceTableConfig `json:"inference_table_config,omitempty"` + // Configuration for rate limits which can be set to limit endpoint traffic. + RateLimits []AiGatewayRateLimit `json:"rate_limits,omitempty"` + // Configuration to enable usage tracking using system tables. These tables + // allow you to monitor operational usage on endpoints and their associated + // costs. + UsageTrackingConfig *UsageTrackingConfig `json:"usage_tracking_config,omitempty"` +} + +type PutInferenceEndpointConfigRequest struct { + // Configuration for legacy Inference Tables which automatically log requests + // and responses to Unity Catalog. Deprecated: please use AI Gateway inference + // tables instead. See + // https://docs.databricks.com/aws/en/ai-gateway/inference-tables. + AutoCaptureConfig *AutoCaptureConfig `json:"auto_capture_config,omitempty"` + // The name of the serving endpoint to update. This field is required. + Name *string `json:"name,omitempty"` + // The list of served entities under the serving endpoint config. + ServedEntities []ServedModel `json:"served_entities,omitempty"` + // (Deprecated, use served_entities instead) The list of served models under the + // serving endpoint config. + ServedModels []ServedModel `json:"served_models,omitempty"` + // The traffic configuration associated with the serving endpoint config. + TrafficConfig *TrafficConfig `json:"traffic_config,omitempty"` +} + +type PutInferenceEndpointRateLimitsRequest struct { + // The name of the serving endpoint whose rate limits are being updated. This + // field is required. + Name *string `json:"name,omitempty"` + // The list of endpoint rate limits. + RateLimits []RateLimit `json:"rate_limits,omitempty"` +} + +type PutInferenceEndpointRateLimitsResponse struct { + // The list of endpoint rate limits. + RateLimits []RateLimit `json:"rate_limits,omitempty"` +} + +type PutPtEndpointConfigRequest struct { + Config *PtEndpointCoreConfig `json:"config,omitempty"` + // The name of the pt endpoint to update. This field is required. + Name *string `json:"name,omitempty"` +} + +type RateLimit struct { + // Used to specify how many calls are allowed for a key within the + // renewal_period. + Calls *int64 `json:"calls,omitempty"` + // Key field for a serving endpoint rate limit. Currently, only 'user' and + // 'endpoint' are supported, with 'endpoint' being the default if not specified. + Key *string `json:"key,omitempty"` + // Renewal period field for a serving endpoint rate limit. Currently, only + // 'minute' is supported. + RenewalPeriod *string `json:"renewal_period,omitempty"` +} + +type Route struct { + ServedEntityName *string `json:"served_entity_name,omitempty"` + // The name of the served model this route configures traffic for. + ServedModelName *string `json:"served_model_name,omitempty"` + // The percentage of endpoint traffic to send to this route. It must be an + // integer between 0 and 100 inclusive. + TrafficPercentage *int `json:"traffic_percentage,omitempty"` +} + +type ServedModel struct { + // Whether burst scaling is enabled. When enabled (default), the endpoint can + // automatically scale up beyond provisioned capacity to handle traffic spikes. + // When disabled, the endpoint maintains fixed capacity at + // provisioned_model_units. + BurstScalingEnabled *bool `json:"burst_scaling_enabled,omitempty"` + CreationTimestamp *int64 `json:"creation_timestamp,omitempty"` + Creator *string `json:"creator,omitempty"` + // The name of the entity to be served. The entity may be a model in the + // Databricks Model Registry, a model in the Unity Catalog (UC), or a function + // of type FEATURE_SPEC in the UC. If it is a UC object, the full name of the + // object should be given in the form of + // **catalog_name.schema_name.model_name**. + EntityName *string `json:"entity_name,omitempty"` + EntityVersion *string `json:"entity_version,omitempty"` + // An object containing a set of optional, user-specified environment variable + // key-value pairs used for serving this entity. Note: this is an experimental + // feature and subject to change. Example entity environment variables that + // refer to secrets: `{"OPENAI_API_KEY": + // "{{secrets/my_scope/my_key}}", "DATABRICKS_TOKEN": + // "{{secrets/my_scope2/my_key2}}"}` + EnvironmentVars map[string]string `json:"environment_vars,omitempty"` + // The external model to be served. NOTE: Only one of external_model and + // (entity_name, entity_version, workload_size, workload_type, and + // scale_to_zero_enabled) can be specified with the latter set being used for + // custom model serving for a registered model. For an existing + // endpoint with external_model, it cannot be updated to an endpoint without + // external_model. If the endpoint is created without external_model, users + // cannot update it to add external_model later. The task type of all external + // models within an endpoint must be the same. + ExternalModel *ExternalModel `json:"external_model,omitempty"` + FoundationModel *FoundationModel `json:"foundation_model,omitempty"` + // ARN of the instance profile that the served entity uses to access AWS + // resources. + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // The maximum provisioned concurrency that the endpoint can scale up to. Do not + // use if workload_size is specified. + MaxProvisionedConcurrency *int `json:"max_provisioned_concurrency,omitempty"` + // The maximum tokens per second that the endpoint can scale up to. + MaxProvisionedThroughput *int `json:"max_provisioned_throughput,omitempty"` + // The minimum provisioned concurrency that the endpoint can scale down to. Do + // not use if workload_size is specified. + MinProvisionedConcurrency *int `json:"min_provisioned_concurrency,omitempty"` + // The minimum tokens per second that the endpoint can scale down to. + MinProvisionedThroughput *int `json:"min_provisioned_throughput,omitempty"` + ModelName *string `json:"model_name,omitempty"` + ModelVersion *string `json:"model_version,omitempty"` + // The name of a served entity. It must be unique across an endpoint. A served + // entity name can consist of alphanumeric characters, dashes, and underscores. + // If not specified for an external model, this field defaults to + // external_model.name, with '.' and ':' replaced with '-', and if not specified + // for other entities, it defaults to entity_name-entity_version. + Name *string `json:"name,omitempty"` + // The number of model units provisioned. + ProvisionedModelUnits *int64 `json:"provisioned_model_units,omitempty"` + // Whether the compute resources for the served entity should scale down to + // zero. + ScaleToZeroEnabled *bool `json:"scale_to_zero_enabled,omitempty"` + State *ServedModelState `json:"state,omitempty"` + // The workload size of the served entity. The workload size corresponds to a + // range of provisioned concurrency that the compute autoscales between. A + // single unit of provisioned concurrency can process one request at a time. + // Valid workload sizes are "Small" (4 - 4 provisioned concurrency), "Medium" (8 + // - 16 provisioned concurrency), and "Large" (16 - 64 provisioned concurrency). + // Additional custom workload sizes can also be used when available in the + // workspace. If scale-to-zero is enabled, the lower bound of the provisioned + // concurrency for each workload size is 0. Do not use if + // min_provisioned_concurrency and max_provisioned_concurrency are specified. + WorkloadSize *string `json:"workload_size,omitempty"` +} + +type ServedModelLite struct { + EntityName *string `json:"entity_name,omitempty"` + EntityVersion *string `json:"entity_version,omitempty"` + ExternalModel *ExternalModel `json:"external_model,omitempty"` + FoundationModel *FoundationModel `json:"foundation_model,omitempty"` + // Only one of model_name and entity_name should be populated + ModelName *string `json:"model_name,omitempty"` + // Only one of model_version and entity_version should be populated + ModelVersion *string `json:"model_version,omitempty"` + Name *string `json:"name,omitempty"` +} + +type ServedModelState struct { + Deployment ServedModelDeploymentState `json:"deployment,omitempty"` + DeploymentStateMessage *string `json:"deployment_state_message,omitempty"` +} + +type TelemetryConfig struct { + // The telemetry signals to enable for this endpoint. If empty or omitted, all + // signals are enabled; otherwise only the listed signals are enabled. + EnabledTelemetryFeatures []TelemetryFeature `json:"enabled_telemetry_features,omitempty"` + // Configuration for inference table payload logging, including sampling. + InferenceTableConfig *TelemetryInferenceTableConfig `json:"inference_table_config,omitempty"` + TableNames *UnityCatalogTableNames `json:"table_names,omitempty"` + TelemetryProfileId *string `json:"telemetry_profile_id,omitempty"` +} + +// Inference table payload logging configuration. +type TelemetryInferenceTableConfig struct { + // The full name of the inference table created for this endpoint. + Name *string `json:"name,omitempty"` + // Fraction of requests sampled for payload logging, in the range [0.0, 1.0], + // where 1.0 logs all requests. + SamplingFraction *float64 `json:"sampling_fraction,omitempty"` +} + +type TrafficConfig struct { + // The list of routes that define traffic to each served entity. + Routes []Route `json:"routes,omitempty"` +} + +type UnityCatalogTableNames struct { + // The full three-level Unity Catalog name (catalog.schema.table) of the table + // that receives exported annotations. + AnnotationsTable *string `json:"annotations_table,omitempty"` + // The full three-level Unity Catalog name (catalog.schema.table) of the table + // that receives exported logs. + LogsTable *string `json:"logs_table,omitempty"` + // The full three-level Unity Catalog name (catalog.schema.table) of the table + // that receives exported metrics. + MetricsTable *string `json:"metrics_table,omitempty"` + // The full three-level Unity Catalog name (catalog.schema.table) of the table + // that receives exported traces (spans). + TracesTable *string `json:"traces_table,omitempty"` +} + +type UpdateInferenceEndpointNotificationsRequest struct { + // The email notification settings to update. Specify email addresses to notify + // when endpoint state changes occur. + EmailNotifications *EmailNotifications `json:"email_notifications,omitempty"` + // The name of the serving endpoint whose notifications are being updated. This + // field is required. + Name *string `json:"name,omitempty"` +} + +type UpdateInferenceEndpointNotificationsResponse struct { + EmailNotifications *EmailNotifications `json:"email_notifications,omitempty"` + Name *string `json:"name,omitempty"` +} + +type UsageTrackingConfig struct { + // Whether to enable usage tracking. + Enabled *bool `json:"enabled,omitempty"` +} + +// Ai21LabsConfigToSDK converts the mirror to the sdk-go type. +func Ai21LabsConfigToSDK(w *Ai21LabsConfig) (*sdk.Ai21LabsConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.Ai21LabsConfig{} + out.Ai21labsApiKey = w.Ai21labsApiKey + out.Ai21labsApiKeyPlaintext = w.Ai21labsApiKeyPlaintext + return out, nil +} + +// Ai21LabsConfigFromSDK converts the sdk-go type to the mirror. +func Ai21LabsConfigFromSDK(v *sdk.Ai21LabsConfig) (*Ai21LabsConfig, error) { + if v == nil { + return nil, nil + } + out := &Ai21LabsConfig{} + out.Ai21labsApiKey = v.Ai21labsApiKey + out.Ai21labsApiKeyPlaintext = v.Ai21labsApiKeyPlaintext + return out, nil +} + +// AiGatewayConfigToSDK converts the mirror to the sdk-go type. +func AiGatewayConfigToSDK(w *AiGatewayConfig) (*sdk.AiGatewayConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiGatewayConfig{} + conv1, err := UsageTrackingConfigToSDK(w.UsageTrackingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGatewayConfig.UsageTrackingConfig", err) + } + out.UsageTrackingConfig = conv1 + conv2, err := InferenceTableConfigToSDK(w.InferenceTableConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGatewayConfig.InferenceTableConfig", err) + } + out.InferenceTableConfig = conv2 + conv3, err := convertSlice(w.RateLimits, AiGatewayRateLimitToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGatewayConfig.RateLimits", err) + } + out.RateLimits = conv3 + conv4, err := AiGuardrailsToSDK(w.Guardrails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGatewayConfig.Guardrails", err) + } + out.Guardrails = conv4 + conv5, err := FallbackConfigToSDK(w.FallbackConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGatewayConfig.FallbackConfig", err) + } + out.FallbackConfig = conv5 + return out, nil +} + +// AiGatewayConfigFromSDK converts the sdk-go type to the mirror. +func AiGatewayConfigFromSDK(v *sdk.AiGatewayConfig) (*AiGatewayConfig, error) { + if v == nil { + return nil, nil + } + out := &AiGatewayConfig{} + conv6, err := UsageTrackingConfigFromSDK(v.UsageTrackingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGatewayConfig.UsageTrackingConfig", err) + } + out.UsageTrackingConfig = conv6 + conv7, err := InferenceTableConfigFromSDK(v.InferenceTableConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGatewayConfig.InferenceTableConfig", err) + } + out.InferenceTableConfig = conv7 + conv8, err := convertSlice(v.RateLimits, AiGatewayRateLimitFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGatewayConfig.RateLimits", err) + } + out.RateLimits = conv8 + conv9, err := AiGuardrailsFromSDK(v.Guardrails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGatewayConfig.Guardrails", err) + } + out.Guardrails = conv9 + conv10, err := FallbackConfigFromSDK(v.FallbackConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGatewayConfig.FallbackConfig", err) + } + out.FallbackConfig = conv10 + return out, nil +} + +// AiGatewayRateLimitToSDK converts the mirror to the sdk-go type. +func AiGatewayRateLimitToSDK(w *AiGatewayRateLimit) (*sdk.AiGatewayRateLimit, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiGatewayRateLimit{} + out.Calls = w.Calls + out.Key = w.Key + out.RenewalPeriod = w.RenewalPeriod + out.Principal = w.Principal + out.Tokens = w.Tokens + return out, nil +} + +// AiGatewayRateLimitFromSDK converts the sdk-go type to the mirror. +func AiGatewayRateLimitFromSDK(v *sdk.AiGatewayRateLimit) (*AiGatewayRateLimit, error) { + if v == nil { + return nil, nil + } + out := &AiGatewayRateLimit{} + out.Calls = v.Calls + out.Key = v.Key + out.RenewalPeriod = v.RenewalPeriod + out.Principal = v.Principal + out.Tokens = v.Tokens + return out, nil +} + +// AiGuardrailParametersToSDK converts the mirror to the sdk-go type. +func AiGuardrailParametersToSDK(w *AiGuardrailParameters) (*sdk.AiGuardrailParameters, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiGuardrailParameters{} + out.Safety = w.Safety + conv11, err := PiiSettingsToSDK(w.Pii) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGuardrailParameters.Pii", err) + } + out.Pii = conv11 + out.ValidTopics = w.ValidTopics + out.InvalidKeywords = w.InvalidKeywords + return out, nil +} + +// AiGuardrailParametersFromSDK converts the sdk-go type to the mirror. +func AiGuardrailParametersFromSDK(v *sdk.AiGuardrailParameters) (*AiGuardrailParameters, error) { + if v == nil { + return nil, nil + } + out := &AiGuardrailParameters{} + out.Safety = v.Safety + conv12, err := PiiSettingsFromSDK(v.Pii) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGuardrailParameters.Pii", err) + } + out.Pii = conv12 + out.ValidTopics = v.ValidTopics + out.InvalidKeywords = v.InvalidKeywords + return out, nil +} + +// AiGuardrailsToSDK converts the mirror to the sdk-go type. +func AiGuardrailsToSDK(w *AiGuardrails) (*sdk.AiGuardrails, error) { + if w == nil { + return nil, nil + } + out := &sdk.AiGuardrails{} + conv13, err := AiGuardrailParametersToSDK(w.Input) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGuardrails.Input", err) + } + out.Input = conv13 + conv14, err := AiGuardrailParametersToSDK(w.Output) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGuardrails.Output", err) + } + out.Output = conv14 + return out, nil +} + +// AiGuardrailsFromSDK converts the sdk-go type to the mirror. +func AiGuardrailsFromSDK(v *sdk.AiGuardrails) (*AiGuardrails, error) { + if v == nil { + return nil, nil + } + out := &AiGuardrails{} + conv15, err := AiGuardrailParametersFromSDK(v.Input) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGuardrails.Input", err) + } + out.Input = conv15 + conv16, err := AiGuardrailParametersFromSDK(v.Output) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AiGuardrails.Output", err) + } + out.Output = conv16 + return out, nil +} + +// AmazonBedrockConfigToSDK converts the mirror to the sdk-go type. +func AmazonBedrockConfigToSDK(w *AmazonBedrockConfig) (*sdk.AmazonBedrockConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.AmazonBedrockConfig{} + out.AwsRegion = w.AwsRegion + out.AwsAccessKeyId = w.AwsAccessKeyId + out.AwsSecretAccessKey = w.AwsSecretAccessKey + out.BedrockProvider = w.BedrockProvider + out.AwsAccessKeyIdPlaintext = w.AwsAccessKeyIdPlaintext + out.AwsSecretAccessKeyPlaintext = w.AwsSecretAccessKeyPlaintext + out.InstanceProfileArn = w.InstanceProfileArn + out.UcServiceCredentialName = w.UcServiceCredentialName + return out, nil +} + +// AmazonBedrockConfigFromSDK converts the sdk-go type to the mirror. +func AmazonBedrockConfigFromSDK(v *sdk.AmazonBedrockConfig) (*AmazonBedrockConfig, error) { + if v == nil { + return nil, nil + } + out := &AmazonBedrockConfig{} + out.AwsRegion = v.AwsRegion + out.AwsAccessKeyId = v.AwsAccessKeyId + out.AwsSecretAccessKey = v.AwsSecretAccessKey + out.BedrockProvider = v.BedrockProvider + out.AwsAccessKeyIdPlaintext = v.AwsAccessKeyIdPlaintext + out.AwsSecretAccessKeyPlaintext = v.AwsSecretAccessKeyPlaintext + out.InstanceProfileArn = v.InstanceProfileArn + out.UcServiceCredentialName = v.UcServiceCredentialName + return out, nil +} + +// AnthropicConfigToSDK converts the mirror to the sdk-go type. +func AnthropicConfigToSDK(w *AnthropicConfig) (*sdk.AnthropicConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.AnthropicConfig{} + out.AnthropicApiKey = w.AnthropicApiKey + out.AnthropicApiKeyPlaintext = w.AnthropicApiKeyPlaintext + return out, nil +} + +// AnthropicConfigFromSDK converts the sdk-go type to the mirror. +func AnthropicConfigFromSDK(v *sdk.AnthropicConfig) (*AnthropicConfig, error) { + if v == nil { + return nil, nil + } + out := &AnthropicConfig{} + out.AnthropicApiKey = v.AnthropicApiKey + out.AnthropicApiKeyPlaintext = v.AnthropicApiKeyPlaintext + return out, nil +} + +// ApiKeyAuthToSDK converts the mirror to the sdk-go type. +func ApiKeyAuthToSDK(w *ApiKeyAuth) (*sdk.ApiKeyAuth, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApiKeyAuth{} + out.Key = w.Key + out.Value = w.Value + out.ValuePlaintext = w.ValuePlaintext + return out, nil +} + +// ApiKeyAuthFromSDK converts the sdk-go type to the mirror. +func ApiKeyAuthFromSDK(v *sdk.ApiKeyAuth) (*ApiKeyAuth, error) { + if v == nil { + return nil, nil + } + out := &ApiKeyAuth{} + out.Key = v.Key + out.Value = v.Value + out.ValuePlaintext = v.ValuePlaintext + return out, nil +} + +// AutoCaptureConfigToSDK converts the mirror to the sdk-go type. +func AutoCaptureConfigToSDK(w *AutoCaptureConfig) (*sdk.AutoCaptureConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.AutoCaptureConfig{} + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.TableNamePrefix = w.TableNamePrefix + conv17, err := AutoCaptureStateToSDK(w.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AutoCaptureConfig.State", err) + } + out.State = conv17 + out.Enabled = w.Enabled + return out, nil +} + +// AutoCaptureConfigFromSDK converts the sdk-go type to the mirror. +func AutoCaptureConfigFromSDK(v *sdk.AutoCaptureConfig) (*AutoCaptureConfig, error) { + if v == nil { + return nil, nil + } + out := &AutoCaptureConfig{} + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.TableNamePrefix = v.TableNamePrefix + conv18, err := AutoCaptureStateFromSDK(v.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AutoCaptureConfig.State", err) + } + out.State = conv18 + out.Enabled = v.Enabled + return out, nil +} + +// AutoCaptureStateToSDK converts the mirror to the sdk-go type. +func AutoCaptureStateToSDK(w *AutoCaptureState) (*sdk.AutoCaptureState, error) { + if w == nil { + return nil, nil + } + out := &sdk.AutoCaptureState{} + conv19, err := PayloadTableToSDK(w.PayloadTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AutoCaptureState.PayloadTable", err) + } + out.PayloadTable = conv19 + return out, nil +} + +// AutoCaptureStateFromSDK converts the sdk-go type to the mirror. +func AutoCaptureStateFromSDK(v *sdk.AutoCaptureState) (*AutoCaptureState, error) { + if v == nil { + return nil, nil + } + out := &AutoCaptureState{} + conv20, err := PayloadTableFromSDK(v.PayloadTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AutoCaptureState.PayloadTable", err) + } + out.PayloadTable = conv20 + return out, nil +} + +// BearerTokenAuthToSDK converts the mirror to the sdk-go type. +func BearerTokenAuthToSDK(w *BearerTokenAuth) (*sdk.BearerTokenAuth, error) { + if w == nil { + return nil, nil + } + out := &sdk.BearerTokenAuth{} + out.Token = w.Token + out.TokenPlaintext = w.TokenPlaintext + return out, nil +} + +// BearerTokenAuthFromSDK converts the sdk-go type to the mirror. +func BearerTokenAuthFromSDK(v *sdk.BearerTokenAuth) (*BearerTokenAuth, error) { + if v == nil { + return nil, nil + } + out := &BearerTokenAuth{} + out.Token = v.Token + out.TokenPlaintext = v.TokenPlaintext + return out, nil +} + +// CohereConfigToSDK converts the mirror to the sdk-go type. +func CohereConfigToSDK(w *CohereConfig) (*sdk.CohereConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.CohereConfig{} + out.CohereApiKey = w.CohereApiKey + out.CohereApiKeyPlaintext = w.CohereApiKeyPlaintext + out.CohereApiBase = w.CohereApiBase + return out, nil +} + +// CohereConfigFromSDK converts the sdk-go type to the mirror. +func CohereConfigFromSDK(v *sdk.CohereConfig) (*CohereConfig, error) { + if v == nil { + return nil, nil + } + out := &CohereConfig{} + out.CohereApiKey = v.CohereApiKey + out.CohereApiKeyPlaintext = v.CohereApiKeyPlaintext + out.CohereApiBase = v.CohereApiBase + return out, nil +} + +// CreateInferenceEndpointRequestToSDK converts the mirror to the sdk-go type. +func CreateInferenceEndpointRequestToSDK(w *CreateInferenceEndpointRequest) (*sdk.CreateInferenceEndpointRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateInferenceEndpointRequest{} + out.Name = w.Name + conv21, err := EndpointCoreConfigToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInferenceEndpointRequest.Config", err) + } + out.Config = conv21 + conv22, err := convertSlice(w.Tags, EndpointTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInferenceEndpointRequest.Tags", err) + } + out.Tags = conv22 + out.RouteOptimized = w.RouteOptimized + conv23, err := convertSlice(w.RateLimits, RateLimitToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInferenceEndpointRequest.RateLimits", err) + } + out.RateLimits = conv23 + conv24, err := AiGatewayConfigToSDK(w.AiGateway) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInferenceEndpointRequest.AiGateway", err) + } + out.AiGateway = conv24 + out.BudgetPolicyId = w.BudgetPolicyId + conv25, err := EmailNotificationsToSDK(w.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInferenceEndpointRequest.EmailNotifications", err) + } + out.EmailNotifications = conv25 + out.Description = w.Description + conv26, err := TelemetryConfigToSDK(w.TelemetryConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInferenceEndpointRequest.TelemetryConfig", err) + } + out.TelemetryConfig = conv26 + return out, nil +} + +// CreateInferenceEndpointRequestFromSDK converts the sdk-go type to the mirror. +func CreateInferenceEndpointRequestFromSDK(v *sdk.CreateInferenceEndpointRequest) (*CreateInferenceEndpointRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateInferenceEndpointRequest{} + out.Name = v.Name + conv27, err := EndpointCoreConfigFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInferenceEndpointRequest.Config", err) + } + out.Config = conv27 + conv28, err := convertSlice(v.Tags, EndpointTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInferenceEndpointRequest.Tags", err) + } + out.Tags = conv28 + out.RouteOptimized = v.RouteOptimized + conv29, err := convertSlice(v.RateLimits, RateLimitFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInferenceEndpointRequest.RateLimits", err) + } + out.RateLimits = conv29 + conv30, err := AiGatewayConfigFromSDK(v.AiGateway) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInferenceEndpointRequest.AiGateway", err) + } + out.AiGateway = conv30 + out.BudgetPolicyId = v.BudgetPolicyId + conv31, err := EmailNotificationsFromSDK(v.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInferenceEndpointRequest.EmailNotifications", err) + } + out.EmailNotifications = conv31 + out.Description = v.Description + conv32, err := TelemetryConfigFromSDK(v.TelemetryConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateInferenceEndpointRequest.TelemetryConfig", err) + } + out.TelemetryConfig = conv32 + return out, nil +} + +// CreatePtEndpointRequestToSDK converts the mirror to the sdk-go type. +func CreatePtEndpointRequestToSDK(w *CreatePtEndpointRequest) (*sdk.CreatePtEndpointRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreatePtEndpointRequest{} + out.Name = w.Name + conv33, err := PtEndpointCoreConfigToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePtEndpointRequest.Config", err) + } + out.Config = conv33 + conv34, err := convertSlice(w.Tags, EndpointTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePtEndpointRequest.Tags", err) + } + out.Tags = conv34 + conv35, err := AiGatewayConfigToSDK(w.AiGateway) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePtEndpointRequest.AiGateway", err) + } + out.AiGateway = conv35 + out.BudgetPolicyId = w.BudgetPolicyId + conv36, err := EmailNotificationsToSDK(w.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePtEndpointRequest.EmailNotifications", err) + } + out.EmailNotifications = conv36 + return out, nil +} + +// CreatePtEndpointRequestFromSDK converts the sdk-go type to the mirror. +func CreatePtEndpointRequestFromSDK(v *sdk.CreatePtEndpointRequest) (*CreatePtEndpointRequest, error) { + if v == nil { + return nil, nil + } + out := &CreatePtEndpointRequest{} + out.Name = v.Name + conv37, err := PtEndpointCoreConfigFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePtEndpointRequest.Config", err) + } + out.Config = conv37 + conv38, err := convertSlice(v.Tags, EndpointTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePtEndpointRequest.Tags", err) + } + out.Tags = conv38 + conv39, err := AiGatewayConfigFromSDK(v.AiGateway) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePtEndpointRequest.AiGateway", err) + } + out.AiGateway = conv39 + out.BudgetPolicyId = v.BudgetPolicyId + conv40, err := EmailNotificationsFromSDK(v.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePtEndpointRequest.EmailNotifications", err) + } + out.EmailNotifications = conv40 + return out, nil +} + +// CustomProviderConfigToSDK converts the mirror to the sdk-go type. +func CustomProviderConfigToSDK(w *CustomProviderConfig) (*sdk.CustomProviderConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomProviderConfig{} + out.CustomProviderUrl = w.CustomProviderUrl + conv41, err := BearerTokenAuthToSDK(w.BearerTokenAuth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomProviderConfig.BearerTokenAuth", err) + } + out.BearerTokenAuth = conv41 + conv42, err := ApiKeyAuthToSDK(w.ApiKeyAuth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomProviderConfig.ApiKeyAuth", err) + } + out.ApiKeyAuth = conv42 + return out, nil +} + +// CustomProviderConfigFromSDK converts the sdk-go type to the mirror. +func CustomProviderConfigFromSDK(v *sdk.CustomProviderConfig) (*CustomProviderConfig, error) { + if v == nil { + return nil, nil + } + out := &CustomProviderConfig{} + out.CustomProviderUrl = v.CustomProviderUrl + conv43, err := BearerTokenAuthFromSDK(v.BearerTokenAuth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomProviderConfig.BearerTokenAuth", err) + } + out.BearerTokenAuth = conv43 + conv44, err := ApiKeyAuthFromSDK(v.ApiKeyAuth) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomProviderConfig.ApiKeyAuth", err) + } + out.ApiKeyAuth = conv44 + return out, nil +} + +// DataPlaneInfoToSDK converts the mirror to the sdk-go type. +func DataPlaneInfoToSDK(w *DataPlaneInfo) (*sdk.DataPlaneInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataPlaneInfo{} + out.EndpointUrl = w.EndpointUrl + out.AuthorizationDetails = w.AuthorizationDetails + return out, nil +} + +// DataPlaneInfoFromSDK converts the sdk-go type to the mirror. +func DataPlaneInfoFromSDK(v *sdk.DataPlaneInfo) (*DataPlaneInfo, error) { + if v == nil { + return nil, nil + } + out := &DataPlaneInfo{} + out.EndpointUrl = v.EndpointUrl + out.AuthorizationDetails = v.AuthorizationDetails + return out, nil +} + +// DatabricksModelServingConfigToSDK converts the mirror to the sdk-go type. +func DatabricksModelServingConfigToSDK(w *DatabricksModelServingConfig) (*sdk.DatabricksModelServingConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabricksModelServingConfig{} + out.DatabricksApiToken = w.DatabricksApiToken + out.DatabricksWorkspaceUrl = w.DatabricksWorkspaceUrl + out.DatabricksApiTokenPlaintext = w.DatabricksApiTokenPlaintext + return out, nil +} + +// DatabricksModelServingConfigFromSDK converts the sdk-go type to the mirror. +func DatabricksModelServingConfigFromSDK(v *sdk.DatabricksModelServingConfig) (*DatabricksModelServingConfig, error) { + if v == nil { + return nil, nil + } + out := &DatabricksModelServingConfig{} + out.DatabricksApiToken = v.DatabricksApiToken + out.DatabricksWorkspaceUrl = v.DatabricksWorkspaceUrl + out.DatabricksApiTokenPlaintext = v.DatabricksApiTokenPlaintext + return out, nil +} + +// EmailNotificationsToSDK converts the mirror to the sdk-go type. +func EmailNotificationsToSDK(w *EmailNotifications) (*sdk.EmailNotifications, error) { + if w == nil { + return nil, nil + } + out := &sdk.EmailNotifications{} + out.OnUpdateSuccess = w.OnUpdateSuccess + out.OnUpdateFailure = w.OnUpdateFailure + return out, nil +} + +// EmailNotificationsFromSDK converts the sdk-go type to the mirror. +func EmailNotificationsFromSDK(v *sdk.EmailNotifications) (*EmailNotifications, error) { + if v == nil { + return nil, nil + } + out := &EmailNotifications{} + out.OnUpdateSuccess = v.OnUpdateSuccess + out.OnUpdateFailure = v.OnUpdateFailure + return out, nil +} + +// EndpointCoreConfigToSDK converts the mirror to the sdk-go type. +func EndpointCoreConfigToSDK(w *EndpointCoreConfig) (*sdk.EndpointCoreConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointCoreConfig{} + conv45, err := convertSlice(w.ServedEntities, ServedModelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfig.ServedEntities", err) + } + out.ServedEntities = conv45 + conv46, err := convertSlice(w.ServedModels, ServedModelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfig.ServedModels", err) + } + out.ServedModels = conv46 + conv47, err := TrafficConfigToSDK(w.TrafficConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfig.TrafficConfig", err) + } + out.TrafficConfig = conv47 + conv48, err := AutoCaptureConfigToSDK(w.AutoCaptureConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfig.AutoCaptureConfig", err) + } + out.AutoCaptureConfig = conv48 + return out, nil +} + +// EndpointCoreConfigFromSDK converts the sdk-go type to the mirror. +func EndpointCoreConfigFromSDK(v *sdk.EndpointCoreConfig) (*EndpointCoreConfig, error) { + if v == nil { + return nil, nil + } + out := &EndpointCoreConfig{} + conv49, err := convertSlice(v.ServedEntities, ServedModelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfig.ServedEntities", err) + } + out.ServedEntities = conv49 + conv50, err := convertSlice(v.ServedModels, ServedModelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfig.ServedModels", err) + } + out.ServedModels = conv50 + conv51, err := TrafficConfigFromSDK(v.TrafficConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfig.TrafficConfig", err) + } + out.TrafficConfig = conv51 + conv52, err := AutoCaptureConfigFromSDK(v.AutoCaptureConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfig.AutoCaptureConfig", err) + } + out.AutoCaptureConfig = conv52 + return out, nil +} + +// EndpointCoreConfigOutputToSDK converts the mirror to the sdk-go type. +func EndpointCoreConfigOutputToSDK(w *EndpointCoreConfigOutput) (*sdk.EndpointCoreConfigOutput, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointCoreConfigOutput{} + out.ConfigVersion = w.ConfigVersion + conv53, err := convertSlice(w.ServedEntities, ServedModelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfigOutput.ServedEntities", err) + } + out.ServedEntities = conv53 + conv54, err := convertSlice(w.ServedModels, ServedModelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfigOutput.ServedModels", err) + } + out.ServedModels = conv54 + conv55, err := TrafficConfigToSDK(w.TrafficConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfigOutput.TrafficConfig", err) + } + out.TrafficConfig = conv55 + conv56, err := AutoCaptureConfigToSDK(w.AutoCaptureConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfigOutput.AutoCaptureConfig", err) + } + out.AutoCaptureConfig = conv56 + return out, nil +} + +// EndpointCoreConfigOutputFromSDK converts the sdk-go type to the mirror. +func EndpointCoreConfigOutputFromSDK(v *sdk.EndpointCoreConfigOutput) (*EndpointCoreConfigOutput, error) { + if v == nil { + return nil, nil + } + out := &EndpointCoreConfigOutput{} + out.ConfigVersion = v.ConfigVersion + conv57, err := convertSlice(v.ServedEntities, ServedModelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfigOutput.ServedEntities", err) + } + out.ServedEntities = conv57 + conv58, err := convertSlice(v.ServedModels, ServedModelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfigOutput.ServedModels", err) + } + out.ServedModels = conv58 + conv59, err := TrafficConfigFromSDK(v.TrafficConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfigOutput.TrafficConfig", err) + } + out.TrafficConfig = conv59 + conv60, err := AutoCaptureConfigFromSDK(v.AutoCaptureConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfigOutput.AutoCaptureConfig", err) + } + out.AutoCaptureConfig = conv60 + return out, nil +} + +// EndpointCoreConfigSummaryToSDK converts the mirror to the sdk-go type. +func EndpointCoreConfigSummaryToSDK(w *EndpointCoreConfigSummary) (*sdk.EndpointCoreConfigSummary, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointCoreConfigSummary{} + conv61, err := convertSlice(w.ServedEntities, ServedModelLiteToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfigSummary.ServedEntities", err) + } + out.ServedEntities = conv61 + conv62, err := convertSlice(w.ServedModels, ServedModelLiteToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfigSummary.ServedModels", err) + } + out.ServedModels = conv62 + return out, nil +} + +// EndpointCoreConfigSummaryFromSDK converts the sdk-go type to the mirror. +func EndpointCoreConfigSummaryFromSDK(v *sdk.EndpointCoreConfigSummary) (*EndpointCoreConfigSummary, error) { + if v == nil { + return nil, nil + } + out := &EndpointCoreConfigSummary{} + conv63, err := convertSlice(v.ServedEntities, ServedModelLiteFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfigSummary.ServedEntities", err) + } + out.ServedEntities = conv63 + conv64, err := convertSlice(v.ServedModels, ServedModelLiteFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointCoreConfigSummary.ServedModels", err) + } + out.ServedModels = conv64 + return out, nil +} + +// EndpointTagToSDK converts the mirror to the sdk-go type. +func EndpointTagToSDK(w *EndpointTag) (*sdk.EndpointTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// EndpointTagFromSDK converts the sdk-go type to the mirror. +func EndpointTagFromSDK(v *sdk.EndpointTag) (*EndpointTag, error) { + if v == nil { + return nil, nil + } + out := &EndpointTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// ExternalFunctionRequestToSDK converts the mirror to the sdk-go type. +func ExternalFunctionRequestToSDK(w *ExternalFunctionRequest) (*sdk.ExternalFunctionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalFunctionRequest{} + out.ConnectionName = w.ConnectionName + out.Method = w.Method + out.Path = w.Path + out.Json = w.Json + out.Headers = w.Headers + out.Params = w.Params + out.SubDomain = w.SubDomain + return out, nil +} + +// ExternalFunctionRequestFromSDK converts the sdk-go type to the mirror. +func ExternalFunctionRequestFromSDK(v *sdk.ExternalFunctionRequest) (*ExternalFunctionRequest, error) { + if v == nil { + return nil, nil + } + out := &ExternalFunctionRequest{} + out.ConnectionName = v.ConnectionName + out.Method = v.Method + out.Path = v.Path + out.Json = v.Json + out.Headers = v.Headers + out.Params = v.Params + out.SubDomain = v.SubDomain + return out, nil +} + +// ExternalModelToSDK converts the mirror to the sdk-go type. +func ExternalModelToSDK(w *ExternalModel) (*sdk.ExternalModel, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalModel{} + out.Provider = w.Provider + out.Name = w.Name + out.Task = w.Task + { + var members []string + if w.Ai21labsConfig != nil { + members = append(members, "ai21labs_config") + } + if w.AnthropicConfig != nil { + members = append(members, "anthropic_config") + } + if w.AmazonBedrockConfig != nil { + members = append(members, "amazon_bedrock_config") + } + if w.CohereConfig != nil { + members = append(members, "cohere_config") + } + if w.GoogleCloudVertexAiConfig != nil { + members = append(members, "google_cloud_vertex_ai_config") + } + if w.DatabricksModelServingConfig != nil { + members = append(members, "databricks_model_serving_config") + } + if w.OpenaiConfig != nil { + members = append(members, "openai_config") + } + if w.PalmConfig != nil { + members = append(members, "palm_config") + } + if w.CustomProviderConfig != nil { + members = append(members, "custom_provider_config") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Ai21labsConfig != nil: + conv65, err := Ai21LabsConfigToSDK(w.Ai21labsConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.Config = &sdk.ExternalModel_Config_Ai21labsConfig{Ai21labsConfig: *conv65} + case w.AnthropicConfig != nil: + conv66, err := AnthropicConfigToSDK(w.AnthropicConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.Config = &sdk.ExternalModel_Config_AnthropicConfig{AnthropicConfig: *conv66} + case w.AmazonBedrockConfig != nil: + conv67, err := AmazonBedrockConfigToSDK(w.AmazonBedrockConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.Config = &sdk.ExternalModel_Config_AmazonBedrockConfig{AmazonBedrockConfig: *conv67} + case w.CohereConfig != nil: + conv68, err := CohereConfigToSDK(w.CohereConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.Config = &sdk.ExternalModel_Config_CohereConfig{CohereConfig: *conv68} + case w.GoogleCloudVertexAiConfig != nil: + conv69, err := GoogleCloudVertexAiConfigToSDK(w.GoogleCloudVertexAiConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.Config = &sdk.ExternalModel_Config_GoogleCloudVertexAiConfig{GoogleCloudVertexAiConfig: *conv69} + case w.DatabricksModelServingConfig != nil: + conv70, err := DatabricksModelServingConfigToSDK(w.DatabricksModelServingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.Config = &sdk.ExternalModel_Config_DatabricksModelServingConfig{DatabricksModelServingConfig: *conv70} + case w.OpenaiConfig != nil: + conv71, err := OpenAiConfigToSDK(w.OpenaiConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.Config = &sdk.ExternalModel_Config_OpenaiConfig{OpenaiConfig: *conv71} + case w.PalmConfig != nil: + conv72, err := PaLmConfigToSDK(w.PalmConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.Config = &sdk.ExternalModel_Config_PalmConfig{PalmConfig: *conv72} + case w.CustomProviderConfig != nil: + conv73, err := CustomProviderConfigToSDK(w.CustomProviderConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.Config = &sdk.ExternalModel_Config_CustomProviderConfig{CustomProviderConfig: *conv73} + } + return out, nil +} + +// ExternalModelFromSDK converts the sdk-go type to the mirror. +func ExternalModelFromSDK(v *sdk.ExternalModel) (*ExternalModel, error) { + if v == nil { + return nil, nil + } + out := &ExternalModel{} + out.Provider = v.Provider + out.Name = v.Name + out.Task = v.Task + switch value := v.Config.(type) { + case *sdk.ExternalModel_Config_Ai21labsConfig: + if value != nil { + conv74, err := Ai21LabsConfigFromSDK(&value.Ai21labsConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.Ai21labsConfig = conv74 + } + case *sdk.ExternalModel_Config_AnthropicConfig: + if value != nil { + conv75, err := AnthropicConfigFromSDK(&value.AnthropicConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.AnthropicConfig = conv75 + } + case *sdk.ExternalModel_Config_AmazonBedrockConfig: + if value != nil { + conv76, err := AmazonBedrockConfigFromSDK(&value.AmazonBedrockConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.AmazonBedrockConfig = conv76 + } + case *sdk.ExternalModel_Config_CohereConfig: + if value != nil { + conv77, err := CohereConfigFromSDK(&value.CohereConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.CohereConfig = conv77 + } + case *sdk.ExternalModel_Config_GoogleCloudVertexAiConfig: + if value != nil { + conv78, err := GoogleCloudVertexAiConfigFromSDK(&value.GoogleCloudVertexAiConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.GoogleCloudVertexAiConfig = conv78 + } + case *sdk.ExternalModel_Config_DatabricksModelServingConfig: + if value != nil { + conv79, err := DatabricksModelServingConfigFromSDK(&value.DatabricksModelServingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.DatabricksModelServingConfig = conv79 + } + case *sdk.ExternalModel_Config_OpenaiConfig: + if value != nil { + conv80, err := OpenAiConfigFromSDK(&value.OpenaiConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.OpenaiConfig = conv80 + } + case *sdk.ExternalModel_Config_PalmConfig: + if value != nil { + conv81, err := PaLmConfigFromSDK(&value.PalmConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.PalmConfig = conv81 + } + case *sdk.ExternalModel_Config_CustomProviderConfig: + if value != nil { + conv82, err := CustomProviderConfigFromSDK(&value.CustomProviderConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalModel.Config", err) + } + out.CustomProviderConfig = conv82 + } + } + return out, nil +} + +// FallbackConfigToSDK converts the mirror to the sdk-go type. +func FallbackConfigToSDK(w *FallbackConfig) (*sdk.FallbackConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.FallbackConfig{} + out.Enabled = w.Enabled + return out, nil +} + +// FallbackConfigFromSDK converts the sdk-go type to the mirror. +func FallbackConfigFromSDK(v *sdk.FallbackConfig) (*FallbackConfig, error) { + if v == nil { + return nil, nil + } + out := &FallbackConfig{} + out.Enabled = v.Enabled + return out, nil +} + +// FoundationModelToSDK converts the mirror to the sdk-go type. +func FoundationModelToSDK(w *FoundationModel) (*sdk.FoundationModel, error) { + if w == nil { + return nil, nil + } + out := &sdk.FoundationModel{} + out.Name = w.Name + out.DisplayName = w.DisplayName + out.Docs = w.Docs + out.Description = w.Description + return out, nil +} + +// FoundationModelFromSDK converts the sdk-go type to the mirror. +func FoundationModelFromSDK(v *sdk.FoundationModel) (*FoundationModel, error) { + if v == nil { + return nil, nil + } + out := &FoundationModel{} + out.Name = v.Name + out.DisplayName = v.DisplayName + out.Docs = v.Docs + out.Description = v.Description + return out, nil +} + +// GetServedModelBuildLogsResponseToSDK converts the mirror to the sdk-go type. +func GetServedModelBuildLogsResponseToSDK(w *GetServedModelBuildLogsResponse) (*sdk.GetServedModelBuildLogsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetServedModelBuildLogsResponse{} + out.Logs = w.Logs + return out, nil +} + +// GetServedModelBuildLogsResponseFromSDK converts the sdk-go type to the mirror. +func GetServedModelBuildLogsResponseFromSDK(v *sdk.GetServedModelBuildLogsResponse) (*GetServedModelBuildLogsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetServedModelBuildLogsResponse{} + out.Logs = v.Logs + return out, nil +} + +// GetServedModelLogsResponseToSDK converts the mirror to the sdk-go type. +func GetServedModelLogsResponseToSDK(w *GetServedModelLogsResponse) (*sdk.GetServedModelLogsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetServedModelLogsResponse{} + out.Logs = w.Logs + return out, nil +} + +// GetServedModelLogsResponseFromSDK converts the sdk-go type to the mirror. +func GetServedModelLogsResponseFromSDK(v *sdk.GetServedModelLogsResponse) (*GetServedModelLogsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetServedModelLogsResponse{} + out.Logs = v.Logs + return out, nil +} + +// GoogleCloudVertexAiConfigToSDK converts the mirror to the sdk-go type. +func GoogleCloudVertexAiConfigToSDK(w *GoogleCloudVertexAiConfig) (*sdk.GoogleCloudVertexAiConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.GoogleCloudVertexAiConfig{} + out.PrivateKey = w.PrivateKey + out.ProjectId = w.ProjectId + out.Region = w.Region + out.PrivateKeyPlaintext = w.PrivateKeyPlaintext + return out, nil +} + +// GoogleCloudVertexAiConfigFromSDK converts the sdk-go type to the mirror. +func GoogleCloudVertexAiConfigFromSDK(v *sdk.GoogleCloudVertexAiConfig) (*GoogleCloudVertexAiConfig, error) { + if v == nil { + return nil, nil + } + out := &GoogleCloudVertexAiConfig{} + out.PrivateKey = v.PrivateKey + out.ProjectId = v.ProjectId + out.Region = v.Region + out.PrivateKeyPlaintext = v.PrivateKeyPlaintext + return out, nil +} + +// InferenceEndpointToSDK converts the mirror to the sdk-go type. +func InferenceEndpointToSDK(w *InferenceEndpoint) (*sdk.InferenceEndpoint, error) { + if w == nil { + return nil, nil + } + out := &sdk.InferenceEndpoint{} + out.Name = w.Name + out.Creator = w.Creator + out.CreationTimestamp = w.CreationTimestamp + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + conv83, err := InferenceEndpointStateToSDK(w.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpoint.State", err) + } + out.State = conv83 + conv84, err := EndpointCoreConfigSummaryToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpoint.Config", err) + } + out.Config = conv84 + conv85, err := convertSlice(w.Tags, EndpointTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpoint.Tags", err) + } + out.Tags = conv85 + out.Id = w.Id + out.Task = w.Task + conv86, err := AiGatewayConfigToSDK(w.AiGateway) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpoint.AiGateway", err) + } + out.AiGateway = conv86 + out.BudgetPolicyId = w.BudgetPolicyId + out.Description = w.Description + out.UsagePolicyId = w.UsagePolicyId + conv87, err := TelemetryConfigToSDK(w.TelemetryConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpoint.TelemetryConfig", err) + } + out.TelemetryConfig = conv87 + return out, nil +} + +// InferenceEndpointFromSDK converts the sdk-go type to the mirror. +func InferenceEndpointFromSDK(v *sdk.InferenceEndpoint) (*InferenceEndpoint, error) { + if v == nil { + return nil, nil + } + out := &InferenceEndpoint{} + out.Name = v.Name + out.Creator = v.Creator + out.CreationTimestamp = v.CreationTimestamp + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + conv88, err := InferenceEndpointStateFromSDK(v.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpoint.State", err) + } + out.State = conv88 + conv89, err := EndpointCoreConfigSummaryFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpoint.Config", err) + } + out.Config = conv89 + conv90, err := convertSlice(v.Tags, EndpointTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpoint.Tags", err) + } + out.Tags = conv90 + out.Id = v.Id + out.Task = v.Task + conv91, err := AiGatewayConfigFromSDK(v.AiGateway) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpoint.AiGateway", err) + } + out.AiGateway = conv91 + out.BudgetPolicyId = v.BudgetPolicyId + out.Description = v.Description + out.UsagePolicyId = v.UsagePolicyId + conv92, err := TelemetryConfigFromSDK(v.TelemetryConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpoint.TelemetryConfig", err) + } + out.TelemetryConfig = conv92 + return out, nil +} + +// InferenceEndpointDetailedToSDK converts the mirror to the sdk-go type. +func InferenceEndpointDetailedToSDK(w *InferenceEndpointDetailed) (*sdk.InferenceEndpointDetailed, error) { + if w == nil { + return nil, nil + } + out := &sdk.InferenceEndpointDetailed{} + out.Name = w.Name + out.Creator = w.Creator + out.CreationTimestamp = w.CreationTimestamp + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + conv93, err := InferenceEndpointStateToSDK(w.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.State", err) + } + out.State = conv93 + conv94, err := EndpointCoreConfigOutputToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.Config", err) + } + out.Config = conv94 + conv95, err := PendingConfigToSDK(w.PendingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.PendingConfig", err) + } + out.PendingConfig = conv95 + out.Id = w.Id + out.PermissionLevel = w.PermissionLevel + conv96, err := convertSlice(w.Tags, EndpointTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.Tags", err) + } + out.Tags = conv96 + out.Task = w.Task + out.RouteOptimized = w.RouteOptimized + out.EndpointUrl = w.EndpointUrl + conv97, err := ModelDataPlaneInfoToSDK(w.DataPlaneInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.DataPlaneInfo", err) + } + out.DataPlaneInfo = conv97 + conv98, err := AiGatewayConfigToSDK(w.AiGateway) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.AiGateway", err) + } + out.AiGateway = conv98 + out.BudgetPolicyId = w.BudgetPolicyId + conv99, err := EmailNotificationsToSDK(w.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.EmailNotifications", err) + } + out.EmailNotifications = conv99 + out.Description = w.Description + conv100, err := TelemetryConfigToSDK(w.TelemetryConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.TelemetryConfig", err) + } + out.TelemetryConfig = conv100 + return out, nil +} + +// InferenceEndpointDetailedFromSDK converts the sdk-go type to the mirror. +func InferenceEndpointDetailedFromSDK(v *sdk.InferenceEndpointDetailed) (*InferenceEndpointDetailed, error) { + if v == nil { + return nil, nil + } + out := &InferenceEndpointDetailed{} + out.Name = v.Name + out.Creator = v.Creator + out.CreationTimestamp = v.CreationTimestamp + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + conv101, err := InferenceEndpointStateFromSDK(v.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.State", err) + } + out.State = conv101 + conv102, err := EndpointCoreConfigOutputFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.Config", err) + } + out.Config = conv102 + conv103, err := PendingConfigFromSDK(v.PendingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.PendingConfig", err) + } + out.PendingConfig = conv103 + out.Id = v.Id + out.PermissionLevel = v.PermissionLevel + conv104, err := convertSlice(v.Tags, EndpointTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.Tags", err) + } + out.Tags = conv104 + out.Task = v.Task + out.RouteOptimized = v.RouteOptimized + out.EndpointUrl = v.EndpointUrl + conv105, err := ModelDataPlaneInfoFromSDK(v.DataPlaneInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.DataPlaneInfo", err) + } + out.DataPlaneInfo = conv105 + conv106, err := AiGatewayConfigFromSDK(v.AiGateway) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.AiGateway", err) + } + out.AiGateway = conv106 + out.BudgetPolicyId = v.BudgetPolicyId + conv107, err := EmailNotificationsFromSDK(v.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.EmailNotifications", err) + } + out.EmailNotifications = conv107 + out.Description = v.Description + conv108, err := TelemetryConfigFromSDK(v.TelemetryConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InferenceEndpointDetailed.TelemetryConfig", err) + } + out.TelemetryConfig = conv108 + return out, nil +} + +// InferenceEndpointStateToSDK converts the mirror to the sdk-go type. +func InferenceEndpointStateToSDK(w *InferenceEndpointState) (*sdk.InferenceEndpointState, error) { + if w == nil { + return nil, nil + } + out := &sdk.InferenceEndpointState{} + out.Ready = w.Ready + out.ConfigUpdate = w.ConfigUpdate + return out, nil +} + +// InferenceEndpointStateFromSDK converts the sdk-go type to the mirror. +func InferenceEndpointStateFromSDK(v *sdk.InferenceEndpointState) (*InferenceEndpointState, error) { + if v == nil { + return nil, nil + } + out := &InferenceEndpointState{} + out.Ready = v.Ready + out.ConfigUpdate = v.ConfigUpdate + return out, nil +} + +// InferenceTableConfigToSDK converts the mirror to the sdk-go type. +func InferenceTableConfigToSDK(w *InferenceTableConfig) (*sdk.InferenceTableConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.InferenceTableConfig{} + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.TableNamePrefix = w.TableNamePrefix + out.Enabled = w.Enabled + return out, nil +} + +// InferenceTableConfigFromSDK converts the sdk-go type to the mirror. +func InferenceTableConfigFromSDK(v *sdk.InferenceTableConfig) (*InferenceTableConfig, error) { + if v == nil { + return nil, nil + } + out := &InferenceTableConfig{} + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.TableNamePrefix = v.TableNamePrefix + out.Enabled = v.Enabled + return out, nil +} + +// ListInferenceEndpointsResponseToSDK converts the mirror to the sdk-go type. +func ListInferenceEndpointsResponseToSDK(w *ListInferenceEndpointsResponse) (*sdk.ListInferenceEndpointsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListInferenceEndpointsResponse{} + conv109, err := convertSlice(w.Endpoints, InferenceEndpointToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListInferenceEndpointsResponse.Endpoints", err) + } + out.Endpoints = conv109 + return out, nil +} + +// ListInferenceEndpointsResponseFromSDK converts the sdk-go type to the mirror. +func ListInferenceEndpointsResponseFromSDK(v *sdk.ListInferenceEndpointsResponse) (*ListInferenceEndpointsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListInferenceEndpointsResponse{} + conv110, err := convertSlice(v.Endpoints, InferenceEndpointFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListInferenceEndpointsResponse.Endpoints", err) + } + out.Endpoints = conv110 + return out, nil +} + +// ModelDataPlaneInfoToSDK converts the mirror to the sdk-go type. +func ModelDataPlaneInfoToSDK(w *ModelDataPlaneInfo) (*sdk.ModelDataPlaneInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelDataPlaneInfo{} + conv111, err := DataPlaneInfoToSDK(w.QueryInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelDataPlaneInfo.QueryInfo", err) + } + out.QueryInfo = conv111 + return out, nil +} + +// ModelDataPlaneInfoFromSDK converts the sdk-go type to the mirror. +func ModelDataPlaneInfoFromSDK(v *sdk.ModelDataPlaneInfo) (*ModelDataPlaneInfo, error) { + if v == nil { + return nil, nil + } + out := &ModelDataPlaneInfo{} + conv112, err := DataPlaneInfoFromSDK(v.QueryInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelDataPlaneInfo.QueryInfo", err) + } + out.QueryInfo = conv112 + return out, nil +} + +// OpenAiConfigToSDK converts the mirror to the sdk-go type. +func OpenAiConfigToSDK(w *OpenAiConfig) (*sdk.OpenAiConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.OpenAiConfig{} + out.OpenaiApiKey = w.OpenaiApiKey + out.OpenaiApiType = w.OpenaiApiType + out.OpenaiApiBase = w.OpenaiApiBase + out.OpenaiApiVersion = w.OpenaiApiVersion + out.OpenaiDeploymentName = w.OpenaiDeploymentName + out.OpenaiOrganization = w.OpenaiOrganization + out.MicrosoftEntraTenantId = w.MicrosoftEntraTenantId + out.MicrosoftEntraClientId = w.MicrosoftEntraClientId + out.MicrosoftEntraClientSecret = w.MicrosoftEntraClientSecret + out.OpenaiApiKeyPlaintext = w.OpenaiApiKeyPlaintext + out.MicrosoftEntraClientSecretPlaintext = w.MicrosoftEntraClientSecretPlaintext + return out, nil +} + +// OpenAiConfigFromSDK converts the sdk-go type to the mirror. +func OpenAiConfigFromSDK(v *sdk.OpenAiConfig) (*OpenAiConfig, error) { + if v == nil { + return nil, nil + } + out := &OpenAiConfig{} + out.OpenaiApiKey = v.OpenaiApiKey + out.OpenaiApiType = v.OpenaiApiType + out.OpenaiApiBase = v.OpenaiApiBase + out.OpenaiApiVersion = v.OpenaiApiVersion + out.OpenaiDeploymentName = v.OpenaiDeploymentName + out.OpenaiOrganization = v.OpenaiOrganization + out.MicrosoftEntraTenantId = v.MicrosoftEntraTenantId + out.MicrosoftEntraClientId = v.MicrosoftEntraClientId + out.MicrosoftEntraClientSecret = v.MicrosoftEntraClientSecret + out.OpenaiApiKeyPlaintext = v.OpenaiApiKeyPlaintext + out.MicrosoftEntraClientSecretPlaintext = v.MicrosoftEntraClientSecretPlaintext + return out, nil +} + +// PaLmConfigToSDK converts the mirror to the sdk-go type. +func PaLmConfigToSDK(w *PaLmConfig) (*sdk.PaLmConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.PaLmConfig{} + out.PalmApiKey = w.PalmApiKey + out.PalmApiKeyPlaintext = w.PalmApiKeyPlaintext + return out, nil +} + +// PaLmConfigFromSDK converts the sdk-go type to the mirror. +func PaLmConfigFromSDK(v *sdk.PaLmConfig) (*PaLmConfig, error) { + if v == nil { + return nil, nil + } + out := &PaLmConfig{} + out.PalmApiKey = v.PalmApiKey + out.PalmApiKeyPlaintext = v.PalmApiKeyPlaintext + return out, nil +} + +// PatchInferenceEndpointTagsRequestToSDK converts the mirror to the sdk-go type. +func PatchInferenceEndpointTagsRequestToSDK(w *PatchInferenceEndpointTagsRequest) (*sdk.PatchInferenceEndpointTagsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchInferenceEndpointTagsRequest{} + out.Name = w.Name + conv113, err := convertSlice(w.AddTags, EndpointTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchInferenceEndpointTagsRequest.AddTags", err) + } + out.AddTags = conv113 + out.DeleteTags = w.DeleteTags + return out, nil +} + +// PatchInferenceEndpointTagsRequestFromSDK converts the sdk-go type to the mirror. +func PatchInferenceEndpointTagsRequestFromSDK(v *sdk.PatchInferenceEndpointTagsRequest) (*PatchInferenceEndpointTagsRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchInferenceEndpointTagsRequest{} + out.Name = v.Name + conv114, err := convertSlice(v.AddTags, EndpointTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchInferenceEndpointTagsRequest.AddTags", err) + } + out.AddTags = conv114 + out.DeleteTags = v.DeleteTags + return out, nil +} + +// PatchInferenceEndpointTagsResponseToSDK converts the mirror to the sdk-go type. +func PatchInferenceEndpointTagsResponseToSDK(w *PatchInferenceEndpointTagsResponse) (*sdk.PatchInferenceEndpointTagsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchInferenceEndpointTagsResponse{} + conv115, err := convertSlice(w.Tags, EndpointTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchInferenceEndpointTagsResponse.Tags", err) + } + out.Tags = conv115 + return out, nil +} + +// PatchInferenceEndpointTagsResponseFromSDK converts the sdk-go type to the mirror. +func PatchInferenceEndpointTagsResponseFromSDK(v *sdk.PatchInferenceEndpointTagsResponse) (*PatchInferenceEndpointTagsResponse, error) { + if v == nil { + return nil, nil + } + out := &PatchInferenceEndpointTagsResponse{} + conv116, err := convertSlice(v.Tags, EndpointTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchInferenceEndpointTagsResponse.Tags", err) + } + out.Tags = conv116 + return out, nil +} + +// PatchInferenceEndpointTelemetryConfigRequestToSDK converts the mirror to the sdk-go type. +func PatchInferenceEndpointTelemetryConfigRequestToSDK(w *PatchInferenceEndpointTelemetryConfigRequest) (*sdk.PatchInferenceEndpointTelemetryConfigRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchInferenceEndpointTelemetryConfigRequest{} + out.Name = w.Name + conv117, err := TelemetryConfigToSDK(w.TelemetryConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchInferenceEndpointTelemetryConfigRequest.TelemetryConfig", err) + } + out.TelemetryConfig = conv117 + return out, nil +} + +// PatchInferenceEndpointTelemetryConfigRequestFromSDK converts the sdk-go type to the mirror. +func PatchInferenceEndpointTelemetryConfigRequestFromSDK(v *sdk.PatchInferenceEndpointTelemetryConfigRequest) (*PatchInferenceEndpointTelemetryConfigRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchInferenceEndpointTelemetryConfigRequest{} + out.Name = v.Name + conv118, err := TelemetryConfigFromSDK(v.TelemetryConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchInferenceEndpointTelemetryConfigRequest.TelemetryConfig", err) + } + out.TelemetryConfig = conv118 + return out, nil +} + +// PayloadTableToSDK converts the mirror to the sdk-go type. +func PayloadTableToSDK(w *PayloadTable) (*sdk.PayloadTable, error) { + if w == nil { + return nil, nil + } + out := &sdk.PayloadTable{} + out.Name = w.Name + out.Status = w.Status + out.StatusMessage = w.StatusMessage + return out, nil +} + +// PayloadTableFromSDK converts the sdk-go type to the mirror. +func PayloadTableFromSDK(v *sdk.PayloadTable) (*PayloadTable, error) { + if v == nil { + return nil, nil + } + out := &PayloadTable{} + out.Name = v.Name + out.Status = v.Status + out.StatusMessage = v.StatusMessage + return out, nil +} + +// PendingConfigToSDK converts the mirror to the sdk-go type. +func PendingConfigToSDK(w *PendingConfig) (*sdk.PendingConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.PendingConfig{} + conv119, err := convertSlice(w.ServedEntities, ServedModelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PendingConfig.ServedEntities", err) + } + out.ServedEntities = conv119 + conv120, err := convertSlice(w.ServedModels, ServedModelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PendingConfig.ServedModels", err) + } + out.ServedModels = conv120 + conv121, err := TrafficConfigToSDK(w.TrafficConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PendingConfig.TrafficConfig", err) + } + out.TrafficConfig = conv121 + out.ConfigVersion = w.ConfigVersion + out.StartTime = w.StartTime + conv122, err := AutoCaptureConfigToSDK(w.AutoCaptureConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PendingConfig.AutoCaptureConfig", err) + } + out.AutoCaptureConfig = conv122 + return out, nil +} + +// PendingConfigFromSDK converts the sdk-go type to the mirror. +func PendingConfigFromSDK(v *sdk.PendingConfig) (*PendingConfig, error) { + if v == nil { + return nil, nil + } + out := &PendingConfig{} + conv123, err := convertSlice(v.ServedEntities, ServedModelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PendingConfig.ServedEntities", err) + } + out.ServedEntities = conv123 + conv124, err := convertSlice(v.ServedModels, ServedModelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PendingConfig.ServedModels", err) + } + out.ServedModels = conv124 + conv125, err := TrafficConfigFromSDK(v.TrafficConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PendingConfig.TrafficConfig", err) + } + out.TrafficConfig = conv125 + out.ConfigVersion = v.ConfigVersion + out.StartTime = v.StartTime + conv126, err := AutoCaptureConfigFromSDK(v.AutoCaptureConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PendingConfig.AutoCaptureConfig", err) + } + out.AutoCaptureConfig = conv126 + return out, nil +} + +// PiiSettingsToSDK converts the mirror to the sdk-go type. +func PiiSettingsToSDK(w *PiiSettings) (*sdk.PiiSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.PiiSettings{} + out.Behavior = w.Behavior + return out, nil +} + +// PiiSettingsFromSDK converts the sdk-go type to the mirror. +func PiiSettingsFromSDK(v *sdk.PiiSettings) (*PiiSettings, error) { + if v == nil { + return nil, nil + } + out := &PiiSettings{} + out.Behavior = v.Behavior + return out, nil +} + +// PtEndpointCoreConfigToSDK converts the mirror to the sdk-go type. +func PtEndpointCoreConfigToSDK(w *PtEndpointCoreConfig) (*sdk.PtEndpointCoreConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.PtEndpointCoreConfig{} + conv127, err := convertSlice(w.ServedEntities, PtServedModelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PtEndpointCoreConfig.ServedEntities", err) + } + out.ServedEntities = conv127 + conv128, err := TrafficConfigToSDK(w.TrafficConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PtEndpointCoreConfig.TrafficConfig", err) + } + out.TrafficConfig = conv128 + return out, nil +} + +// PtEndpointCoreConfigFromSDK converts the sdk-go type to the mirror. +func PtEndpointCoreConfigFromSDK(v *sdk.PtEndpointCoreConfig) (*PtEndpointCoreConfig, error) { + if v == nil { + return nil, nil + } + out := &PtEndpointCoreConfig{} + conv129, err := convertSlice(v.ServedEntities, PtServedModelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PtEndpointCoreConfig.ServedEntities", err) + } + out.ServedEntities = conv129 + conv130, err := TrafficConfigFromSDK(v.TrafficConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PtEndpointCoreConfig.TrafficConfig", err) + } + out.TrafficConfig = conv130 + return out, nil +} + +// PtServedModelToSDK converts the mirror to the sdk-go type. +func PtServedModelToSDK(w *PtServedModel) (*sdk.PtServedModel, error) { + if w == nil { + return nil, nil + } + out := &sdk.PtServedModel{} + out.Name = w.Name + out.EntityName = w.EntityName + out.EntityVersion = w.EntityVersion + out.ProvisionedModelUnits = w.ProvisionedModelUnits + out.BurstScalingEnabled = w.BurstScalingEnabled + return out, nil +} + +// PtServedModelFromSDK converts the sdk-go type to the mirror. +func PtServedModelFromSDK(v *sdk.PtServedModel) (*PtServedModel, error) { + if v == nil { + return nil, nil + } + out := &PtServedModel{} + out.Name = v.Name + out.EntityName = v.EntityName + out.EntityVersion = v.EntityVersion + out.ProvisionedModelUnits = v.ProvisionedModelUnits + out.BurstScalingEnabled = v.BurstScalingEnabled + return out, nil +} + +// PutInferenceEndpointAiGatewayRequestToSDK converts the mirror to the sdk-go type. +func PutInferenceEndpointAiGatewayRequestToSDK(w *PutInferenceEndpointAiGatewayRequest) (*sdk.PutInferenceEndpointAiGatewayRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PutInferenceEndpointAiGatewayRequest{} + out.Name = w.Name + conv131, err := UsageTrackingConfigToSDK(w.UsageTrackingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayRequest.UsageTrackingConfig", err) + } + out.UsageTrackingConfig = conv131 + conv132, err := InferenceTableConfigToSDK(w.InferenceTableConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayRequest.InferenceTableConfig", err) + } + out.InferenceTableConfig = conv132 + conv133, err := convertSlice(w.RateLimits, AiGatewayRateLimitToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayRequest.RateLimits", err) + } + out.RateLimits = conv133 + conv134, err := AiGuardrailsToSDK(w.Guardrails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayRequest.Guardrails", err) + } + out.Guardrails = conv134 + conv135, err := FallbackConfigToSDK(w.FallbackConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayRequest.FallbackConfig", err) + } + out.FallbackConfig = conv135 + return out, nil +} + +// PutInferenceEndpointAiGatewayRequestFromSDK converts the sdk-go type to the mirror. +func PutInferenceEndpointAiGatewayRequestFromSDK(v *sdk.PutInferenceEndpointAiGatewayRequest) (*PutInferenceEndpointAiGatewayRequest, error) { + if v == nil { + return nil, nil + } + out := &PutInferenceEndpointAiGatewayRequest{} + out.Name = v.Name + conv136, err := UsageTrackingConfigFromSDK(v.UsageTrackingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayRequest.UsageTrackingConfig", err) + } + out.UsageTrackingConfig = conv136 + conv137, err := InferenceTableConfigFromSDK(v.InferenceTableConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayRequest.InferenceTableConfig", err) + } + out.InferenceTableConfig = conv137 + conv138, err := convertSlice(v.RateLimits, AiGatewayRateLimitFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayRequest.RateLimits", err) + } + out.RateLimits = conv138 + conv139, err := AiGuardrailsFromSDK(v.Guardrails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayRequest.Guardrails", err) + } + out.Guardrails = conv139 + conv140, err := FallbackConfigFromSDK(v.FallbackConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayRequest.FallbackConfig", err) + } + out.FallbackConfig = conv140 + return out, nil +} + +// PutInferenceEndpointAiGatewayResponseToSDK converts the mirror to the sdk-go type. +func PutInferenceEndpointAiGatewayResponseToSDK(w *PutInferenceEndpointAiGatewayResponse) (*sdk.PutInferenceEndpointAiGatewayResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.PutInferenceEndpointAiGatewayResponse{} + conv141, err := UsageTrackingConfigToSDK(w.UsageTrackingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayResponse.UsageTrackingConfig", err) + } + out.UsageTrackingConfig = conv141 + conv142, err := InferenceTableConfigToSDK(w.InferenceTableConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayResponse.InferenceTableConfig", err) + } + out.InferenceTableConfig = conv142 + conv143, err := convertSlice(w.RateLimits, AiGatewayRateLimitToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayResponse.RateLimits", err) + } + out.RateLimits = conv143 + conv144, err := AiGuardrailsToSDK(w.Guardrails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayResponse.Guardrails", err) + } + out.Guardrails = conv144 + conv145, err := FallbackConfigToSDK(w.FallbackConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayResponse.FallbackConfig", err) + } + out.FallbackConfig = conv145 + return out, nil +} + +// PutInferenceEndpointAiGatewayResponseFromSDK converts the sdk-go type to the mirror. +func PutInferenceEndpointAiGatewayResponseFromSDK(v *sdk.PutInferenceEndpointAiGatewayResponse) (*PutInferenceEndpointAiGatewayResponse, error) { + if v == nil { + return nil, nil + } + out := &PutInferenceEndpointAiGatewayResponse{} + conv146, err := UsageTrackingConfigFromSDK(v.UsageTrackingConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayResponse.UsageTrackingConfig", err) + } + out.UsageTrackingConfig = conv146 + conv147, err := InferenceTableConfigFromSDK(v.InferenceTableConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayResponse.InferenceTableConfig", err) + } + out.InferenceTableConfig = conv147 + conv148, err := convertSlice(v.RateLimits, AiGatewayRateLimitFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayResponse.RateLimits", err) + } + out.RateLimits = conv148 + conv149, err := AiGuardrailsFromSDK(v.Guardrails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayResponse.Guardrails", err) + } + out.Guardrails = conv149 + conv150, err := FallbackConfigFromSDK(v.FallbackConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointAiGatewayResponse.FallbackConfig", err) + } + out.FallbackConfig = conv150 + return out, nil +} + +// PutInferenceEndpointConfigRequestToSDK converts the mirror to the sdk-go type. +func PutInferenceEndpointConfigRequestToSDK(w *PutInferenceEndpointConfigRequest) (*sdk.PutInferenceEndpointConfigRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PutInferenceEndpointConfigRequest{} + out.Name = w.Name + conv151, err := convertSlice(w.ServedEntities, ServedModelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointConfigRequest.ServedEntities", err) + } + out.ServedEntities = conv151 + conv152, err := convertSlice(w.ServedModels, ServedModelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointConfigRequest.ServedModels", err) + } + out.ServedModels = conv152 + conv153, err := TrafficConfigToSDK(w.TrafficConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointConfigRequest.TrafficConfig", err) + } + out.TrafficConfig = conv153 + conv154, err := AutoCaptureConfigToSDK(w.AutoCaptureConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointConfigRequest.AutoCaptureConfig", err) + } + out.AutoCaptureConfig = conv154 + return out, nil +} + +// PutInferenceEndpointConfigRequestFromSDK converts the sdk-go type to the mirror. +func PutInferenceEndpointConfigRequestFromSDK(v *sdk.PutInferenceEndpointConfigRequest) (*PutInferenceEndpointConfigRequest, error) { + if v == nil { + return nil, nil + } + out := &PutInferenceEndpointConfigRequest{} + out.Name = v.Name + conv155, err := convertSlice(v.ServedEntities, ServedModelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointConfigRequest.ServedEntities", err) + } + out.ServedEntities = conv155 + conv156, err := convertSlice(v.ServedModels, ServedModelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointConfigRequest.ServedModels", err) + } + out.ServedModels = conv156 + conv157, err := TrafficConfigFromSDK(v.TrafficConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointConfigRequest.TrafficConfig", err) + } + out.TrafficConfig = conv157 + conv158, err := AutoCaptureConfigFromSDK(v.AutoCaptureConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointConfigRequest.AutoCaptureConfig", err) + } + out.AutoCaptureConfig = conv158 + return out, nil +} + +// PutInferenceEndpointRateLimitsRequestToSDK converts the mirror to the sdk-go type. +func PutInferenceEndpointRateLimitsRequestToSDK(w *PutInferenceEndpointRateLimitsRequest) (*sdk.PutInferenceEndpointRateLimitsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PutInferenceEndpointRateLimitsRequest{} + out.Name = w.Name + conv159, err := convertSlice(w.RateLimits, RateLimitToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointRateLimitsRequest.RateLimits", err) + } + out.RateLimits = conv159 + return out, nil +} + +// PutInferenceEndpointRateLimitsRequestFromSDK converts the sdk-go type to the mirror. +func PutInferenceEndpointRateLimitsRequestFromSDK(v *sdk.PutInferenceEndpointRateLimitsRequest) (*PutInferenceEndpointRateLimitsRequest, error) { + if v == nil { + return nil, nil + } + out := &PutInferenceEndpointRateLimitsRequest{} + out.Name = v.Name + conv160, err := convertSlice(v.RateLimits, RateLimitFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointRateLimitsRequest.RateLimits", err) + } + out.RateLimits = conv160 + return out, nil +} + +// PutInferenceEndpointRateLimitsResponseToSDK converts the mirror to the sdk-go type. +func PutInferenceEndpointRateLimitsResponseToSDK(w *PutInferenceEndpointRateLimitsResponse) (*sdk.PutInferenceEndpointRateLimitsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.PutInferenceEndpointRateLimitsResponse{} + conv161, err := convertSlice(w.RateLimits, RateLimitToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointRateLimitsResponse.RateLimits", err) + } + out.RateLimits = conv161 + return out, nil +} + +// PutInferenceEndpointRateLimitsResponseFromSDK converts the sdk-go type to the mirror. +func PutInferenceEndpointRateLimitsResponseFromSDK(v *sdk.PutInferenceEndpointRateLimitsResponse) (*PutInferenceEndpointRateLimitsResponse, error) { + if v == nil { + return nil, nil + } + out := &PutInferenceEndpointRateLimitsResponse{} + conv162, err := convertSlice(v.RateLimits, RateLimitFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutInferenceEndpointRateLimitsResponse.RateLimits", err) + } + out.RateLimits = conv162 + return out, nil +} + +// PutPtEndpointConfigRequestToSDK converts the mirror to the sdk-go type. +func PutPtEndpointConfigRequestToSDK(w *PutPtEndpointConfigRequest) (*sdk.PutPtEndpointConfigRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PutPtEndpointConfigRequest{} + out.Name = w.Name + conv163, err := PtEndpointCoreConfigToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutPtEndpointConfigRequest.Config", err) + } + out.Config = conv163 + return out, nil +} + +// PutPtEndpointConfigRequestFromSDK converts the sdk-go type to the mirror. +func PutPtEndpointConfigRequestFromSDK(v *sdk.PutPtEndpointConfigRequest) (*PutPtEndpointConfigRequest, error) { + if v == nil { + return nil, nil + } + out := &PutPtEndpointConfigRequest{} + out.Name = v.Name + conv164, err := PtEndpointCoreConfigFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PutPtEndpointConfigRequest.Config", err) + } + out.Config = conv164 + return out, nil +} + +// RateLimitToSDK converts the mirror to the sdk-go type. +func RateLimitToSDK(w *RateLimit) (*sdk.RateLimit, error) { + if w == nil { + return nil, nil + } + out := &sdk.RateLimit{} + out.Calls = w.Calls + out.Key = w.Key + out.RenewalPeriod = w.RenewalPeriod + return out, nil +} + +// RateLimitFromSDK converts the sdk-go type to the mirror. +func RateLimitFromSDK(v *sdk.RateLimit) (*RateLimit, error) { + if v == nil { + return nil, nil + } + out := &RateLimit{} + out.Calls = v.Calls + out.Key = v.Key + out.RenewalPeriod = v.RenewalPeriod + return out, nil +} + +// RouteToSDK converts the mirror to the sdk-go type. +func RouteToSDK(w *Route) (*sdk.Route, error) { + if w == nil { + return nil, nil + } + out := &sdk.Route{} + out.ServedModelName = w.ServedModelName + out.TrafficPercentage = w.TrafficPercentage + out.ServedEntityName = w.ServedEntityName + return out, nil +} + +// RouteFromSDK converts the sdk-go type to the mirror. +func RouteFromSDK(v *sdk.Route) (*Route, error) { + if v == nil { + return nil, nil + } + out := &Route{} + out.ServedModelName = v.ServedModelName + out.TrafficPercentage = v.TrafficPercentage + out.ServedEntityName = v.ServedEntityName + return out, nil +} + +// ServedModelToSDK converts the mirror to the sdk-go type. +func ServedModelToSDK(w *ServedModel) (*sdk.ServedModel, error) { + if w == nil { + return nil, nil + } + out := &sdk.ServedModel{} + out.Name = w.Name + conv165, err := ExternalModelToSDK(w.ExternalModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServedModel.ExternalModel", err) + } + out.ExternalModel = conv165 + out.EntityName = w.EntityName + out.EntityVersion = w.EntityVersion + out.MinProvisionedThroughput = w.MinProvisionedThroughput + out.MaxProvisionedThroughput = w.MaxProvisionedThroughput + out.MinProvisionedConcurrency = w.MinProvisionedConcurrency + out.MaxProvisionedConcurrency = w.MaxProvisionedConcurrency + out.WorkloadSize = w.WorkloadSize + out.ProvisionedModelUnits = w.ProvisionedModelUnits + out.BurstScalingEnabled = w.BurstScalingEnabled + out.ScaleToZeroEnabled = w.ScaleToZeroEnabled + out.ModelName = w.ModelName + out.ModelVersion = w.ModelVersion + out.EnvironmentVars = w.EnvironmentVars + out.InstanceProfileArn = w.InstanceProfileArn + conv166, err := FoundationModelToSDK(w.FoundationModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServedModel.FoundationModel", err) + } + out.FoundationModel = conv166 + conv167, err := ServedModelStateToSDK(w.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServedModel.State", err) + } + out.State = conv167 + out.Creator = w.Creator + out.CreationTimestamp = w.CreationTimestamp + return out, nil +} + +// ServedModelFromSDK converts the sdk-go type to the mirror. +func ServedModelFromSDK(v *sdk.ServedModel) (*ServedModel, error) { + if v == nil { + return nil, nil + } + out := &ServedModel{} + out.Name = v.Name + conv168, err := ExternalModelFromSDK(v.ExternalModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServedModel.ExternalModel", err) + } + out.ExternalModel = conv168 + out.EntityName = v.EntityName + out.EntityVersion = v.EntityVersion + out.MinProvisionedThroughput = v.MinProvisionedThroughput + out.MaxProvisionedThroughput = v.MaxProvisionedThroughput + out.MinProvisionedConcurrency = v.MinProvisionedConcurrency + out.MaxProvisionedConcurrency = v.MaxProvisionedConcurrency + out.WorkloadSize = v.WorkloadSize + out.ProvisionedModelUnits = v.ProvisionedModelUnits + out.BurstScalingEnabled = v.BurstScalingEnabled + out.ScaleToZeroEnabled = v.ScaleToZeroEnabled + out.ModelName = v.ModelName + out.ModelVersion = v.ModelVersion + out.EnvironmentVars = v.EnvironmentVars + out.InstanceProfileArn = v.InstanceProfileArn + conv169, err := FoundationModelFromSDK(v.FoundationModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServedModel.FoundationModel", err) + } + out.FoundationModel = conv169 + conv170, err := ServedModelStateFromSDK(v.State) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServedModel.State", err) + } + out.State = conv170 + out.Creator = v.Creator + out.CreationTimestamp = v.CreationTimestamp + return out, nil +} + +// ServedModelLiteToSDK converts the mirror to the sdk-go type. +func ServedModelLiteToSDK(w *ServedModelLite) (*sdk.ServedModelLite, error) { + if w == nil { + return nil, nil + } + out := &sdk.ServedModelLite{} + out.Name = w.Name + out.ModelName = w.ModelName + out.EntityName = w.EntityName + out.ModelVersion = w.ModelVersion + out.EntityVersion = w.EntityVersion + conv171, err := ExternalModelToSDK(w.ExternalModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServedModelLite.ExternalModel", err) + } + out.ExternalModel = conv171 + conv172, err := FoundationModelToSDK(w.FoundationModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServedModelLite.FoundationModel", err) + } + out.FoundationModel = conv172 + return out, nil +} + +// ServedModelLiteFromSDK converts the sdk-go type to the mirror. +func ServedModelLiteFromSDK(v *sdk.ServedModelLite) (*ServedModelLite, error) { + if v == nil { + return nil, nil + } + out := &ServedModelLite{} + out.Name = v.Name + out.ModelName = v.ModelName + out.EntityName = v.EntityName + out.ModelVersion = v.ModelVersion + out.EntityVersion = v.EntityVersion + conv173, err := ExternalModelFromSDK(v.ExternalModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServedModelLite.ExternalModel", err) + } + out.ExternalModel = conv173 + conv174, err := FoundationModelFromSDK(v.FoundationModel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServedModelLite.FoundationModel", err) + } + out.FoundationModel = conv174 + return out, nil +} + +// ServedModelStateToSDK converts the mirror to the sdk-go type. +func ServedModelStateToSDK(w *ServedModelState) (*sdk.ServedModelState, error) { + if w == nil { + return nil, nil + } + out := &sdk.ServedModelState{} + out.Deployment = w.Deployment + out.DeploymentStateMessage = w.DeploymentStateMessage + return out, nil +} + +// ServedModelStateFromSDK converts the sdk-go type to the mirror. +func ServedModelStateFromSDK(v *sdk.ServedModelState) (*ServedModelState, error) { + if v == nil { + return nil, nil + } + out := &ServedModelState{} + out.Deployment = v.Deployment + out.DeploymentStateMessage = v.DeploymentStateMessage + return out, nil +} + +// TelemetryConfigToSDK converts the mirror to the sdk-go type. +func TelemetryConfigToSDK(w *TelemetryConfig) (*sdk.TelemetryConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.TelemetryConfig{} + { + var members []string + if w.TelemetryProfileId != nil { + members = append(members, "telemetry_profile_id") + } + if w.TableNames != nil { + members = append(members, "table_names") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.TelemetryProfileId != nil: + out.TelemetryProfile = &sdk.TelemetryConfig_TelemetryProfile_TelemetryProfileId{TelemetryProfileId: *w.TelemetryProfileId} + case w.TableNames != nil: + conv175, err := UnityCatalogTableNamesToSDK(w.TableNames) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TelemetryConfig.TelemetryProfile", err) + } + out.TelemetryProfile = &sdk.TelemetryConfig_TelemetryProfile_TableNames{TableNames: *conv175} + } + conv176, err := TelemetryInferenceTableConfigToSDK(w.InferenceTableConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TelemetryConfig.InferenceTableConfig", err) + } + out.InferenceTableConfig = conv176 + out.EnabledTelemetryFeatures = w.EnabledTelemetryFeatures + return out, nil +} + +// TelemetryConfigFromSDK converts the sdk-go type to the mirror. +func TelemetryConfigFromSDK(v *sdk.TelemetryConfig) (*TelemetryConfig, error) { + if v == nil { + return nil, nil + } + out := &TelemetryConfig{} + switch value := v.TelemetryProfile.(type) { + case *sdk.TelemetryConfig_TelemetryProfile_TelemetryProfileId: + if value != nil { + out.TelemetryProfileId = new(value.TelemetryProfileId) + } + case *sdk.TelemetryConfig_TelemetryProfile_TableNames: + if value != nil { + conv177, err := UnityCatalogTableNamesFromSDK(&value.TableNames) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TelemetryConfig.TelemetryProfile", err) + } + out.TableNames = conv177 + } + } + conv178, err := TelemetryInferenceTableConfigFromSDK(v.InferenceTableConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TelemetryConfig.InferenceTableConfig", err) + } + out.InferenceTableConfig = conv178 + out.EnabledTelemetryFeatures = v.EnabledTelemetryFeatures + return out, nil +} + +// TelemetryInferenceTableConfigToSDK converts the mirror to the sdk-go type. +func TelemetryInferenceTableConfigToSDK(w *TelemetryInferenceTableConfig) (*sdk.TelemetryInferenceTableConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.TelemetryInferenceTableConfig{} + out.SamplingFraction = w.SamplingFraction + out.Name = w.Name + return out, nil +} + +// TelemetryInferenceTableConfigFromSDK converts the sdk-go type to the mirror. +func TelemetryInferenceTableConfigFromSDK(v *sdk.TelemetryInferenceTableConfig) (*TelemetryInferenceTableConfig, error) { + if v == nil { + return nil, nil + } + out := &TelemetryInferenceTableConfig{} + out.SamplingFraction = v.SamplingFraction + out.Name = v.Name + return out, nil +} + +// TrafficConfigToSDK converts the mirror to the sdk-go type. +func TrafficConfigToSDK(w *TrafficConfig) (*sdk.TrafficConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.TrafficConfig{} + conv179, err := convertSlice(w.Routes, RouteToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TrafficConfig.Routes", err) + } + out.Routes = conv179 + return out, nil +} + +// TrafficConfigFromSDK converts the sdk-go type to the mirror. +func TrafficConfigFromSDK(v *sdk.TrafficConfig) (*TrafficConfig, error) { + if v == nil { + return nil, nil + } + out := &TrafficConfig{} + conv180, err := convertSlice(v.Routes, RouteFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TrafficConfig.Routes", err) + } + out.Routes = conv180 + return out, nil +} + +// UnityCatalogTableNamesToSDK converts the mirror to the sdk-go type. +func UnityCatalogTableNamesToSDK(w *UnityCatalogTableNames) (*sdk.UnityCatalogTableNames, error) { + if w == nil { + return nil, nil + } + out := &sdk.UnityCatalogTableNames{} + out.LogsTable = w.LogsTable + out.MetricsTable = w.MetricsTable + out.TracesTable = w.TracesTable + out.AnnotationsTable = w.AnnotationsTable + return out, nil +} + +// UnityCatalogTableNamesFromSDK converts the sdk-go type to the mirror. +func UnityCatalogTableNamesFromSDK(v *sdk.UnityCatalogTableNames) (*UnityCatalogTableNames, error) { + if v == nil { + return nil, nil + } + out := &UnityCatalogTableNames{} + out.LogsTable = v.LogsTable + out.MetricsTable = v.MetricsTable + out.TracesTable = v.TracesTable + out.AnnotationsTable = v.AnnotationsTable + return out, nil +} + +// UpdateInferenceEndpointNotificationsRequestToSDK converts the mirror to the sdk-go type. +func UpdateInferenceEndpointNotificationsRequestToSDK(w *UpdateInferenceEndpointNotificationsRequest) (*sdk.UpdateInferenceEndpointNotificationsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateInferenceEndpointNotificationsRequest{} + out.Name = w.Name + conv181, err := EmailNotificationsToSDK(w.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateInferenceEndpointNotificationsRequest.EmailNotifications", err) + } + out.EmailNotifications = conv181 + return out, nil +} + +// UpdateInferenceEndpointNotificationsRequestFromSDK converts the sdk-go type to the mirror. +func UpdateInferenceEndpointNotificationsRequestFromSDK(v *sdk.UpdateInferenceEndpointNotificationsRequest) (*UpdateInferenceEndpointNotificationsRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateInferenceEndpointNotificationsRequest{} + out.Name = v.Name + conv182, err := EmailNotificationsFromSDK(v.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateInferenceEndpointNotificationsRequest.EmailNotifications", err) + } + out.EmailNotifications = conv182 + return out, nil +} + +// UpdateInferenceEndpointNotificationsResponseToSDK converts the mirror to the sdk-go type. +func UpdateInferenceEndpointNotificationsResponseToSDK(w *UpdateInferenceEndpointNotificationsResponse) (*sdk.UpdateInferenceEndpointNotificationsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateInferenceEndpointNotificationsResponse{} + out.Name = w.Name + conv183, err := EmailNotificationsToSDK(w.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateInferenceEndpointNotificationsResponse.EmailNotifications", err) + } + out.EmailNotifications = conv183 + return out, nil +} + +// UpdateInferenceEndpointNotificationsResponseFromSDK converts the sdk-go type to the mirror. +func UpdateInferenceEndpointNotificationsResponseFromSDK(v *sdk.UpdateInferenceEndpointNotificationsResponse) (*UpdateInferenceEndpointNotificationsResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateInferenceEndpointNotificationsResponse{} + out.Name = v.Name + conv184, err := EmailNotificationsFromSDK(v.EmailNotifications) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateInferenceEndpointNotificationsResponse.EmailNotifications", err) + } + out.EmailNotifications = conv184 + return out, nil +} + +// UsageTrackingConfigToSDK converts the mirror to the sdk-go type. +func UsageTrackingConfigToSDK(w *UsageTrackingConfig) (*sdk.UsageTrackingConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.UsageTrackingConfig{} + out.Enabled = w.Enabled + return out, nil +} + +// UsageTrackingConfigFromSDK converts the sdk-go type to the mirror. +func UsageTrackingConfigFromSDK(v *sdk.UsageTrackingConfig) (*UsageTrackingConfig, error) { + if v == nil { + return nil, nil + } + out := &UsageTrackingConfig{} + out.Enabled = v.Enabled + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/modelservingquery/v1/types.generated.go b/libs/sdktypes/modelservingquery/v1/types.generated.go new file mode 100644 index 00000000000..e4a3026532a --- /dev/null +++ b/libs/sdktypes/modelservingquery/v1/types.generated.go @@ -0,0 +1,434 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/modelservingquery/v1. DO NOT EDIT. + +package modelservingquery + +import ( + json "encoding/json" + fmt "fmt" + sdk "github.com/databricks/sdk-go/modelservingquery/v1" +) + +type ( + ChatMessageRole = sdk.ChatMessageRole + EmbeddingsV1ResponseEmbeddingElementObject = sdk.EmbeddingsV1ResponseEmbeddingElementObject + QueryEndpointResponseObject = sdk.QueryEndpointResponseObject +) + +const ( + ChatMessageRole_Unspecified = sdk.ChatMessageRole_Unspecified + ChatMessageRole_System = sdk.ChatMessageRole_System + ChatMessageRole_User = sdk.ChatMessageRole_User + ChatMessageRole_Assistant = sdk.ChatMessageRole_Assistant + EmbeddingsV1ResponseEmbeddingElementObject_Unspecified = sdk.EmbeddingsV1ResponseEmbeddingElementObject_Unspecified + EmbeddingsV1ResponseEmbeddingElementObject_Embedding = sdk.EmbeddingsV1ResponseEmbeddingElementObject_Embedding + QueryEndpointResponseObject_Unspecified = sdk.QueryEndpointResponseObject_Unspecified + QueryEndpointResponseObject_TextCompletion = sdk.QueryEndpointResponseObject_TextCompletion + QueryEndpointResponseObject_ChatCompletion = sdk.QueryEndpointResponseObject_ChatCompletion + QueryEndpointResponseObject_List = sdk.QueryEndpointResponseObject_List +) + +type ChatMessage struct { + // The content of the message. + Content *string `json:"content,omitempty"` + // The role of the message. One of [system, user, assistant]. + Role ChatMessageRole `json:"role,omitempty"` +} + +type DataframeSplitInput struct { + // Columns array for the dataframe + Columns []json.RawMessage `json:"columns,omitempty"` + // Data array for the dataframe + Data []json.RawMessage `json:"data,omitempty"` + // Index array for the dataframe + Index []int `json:"index,omitempty"` +} + +type EmbeddingsV1ResponseEmbeddingElement struct { + // The embedding vector + Embedding []float64 `json:"embedding,omitempty"` + // The index of the embedding in the response. + Index *int `json:"index,omitempty"` + // This will always be 'embedding'. + Object EmbeddingsV1ResponseEmbeddingElementObject `json:"object,omitempty"` +} + +type ExternalModelUsageElement struct { + // The number of tokens in the chat/completions response. + CompletionTokens *int `json:"completion_tokens,omitempty"` + // The number of tokens in the prompt. + PromptTokens *int `json:"prompt_tokens,omitempty"` + // The total number of tokens in the prompt and response. + TotalTokens *int `json:"total_tokens,omitempty"` +} + +type QueryEndpointRequest struct { + // Optional user-provided request identifier that will be recorded in the + // inference table and the usage tracking table. + ClientRequestId *string `json:"client_request_id,omitempty"` + // Pandas Dataframe input in the records orientation. + DataframeRecords []json.RawMessage `json:"dataframe_records,omitempty"` + // Pandas Dataframe input in the split orientation. + DataframeSplit *DataframeSplitInput `json:"dataframe_split,omitempty"` + // The extra parameters field used ONLY for __completions, chat,__ and + // __embeddings external & foundation model__ serving endpoints. This is a map + // of strings and should only be used with other external/foundation model query + // fields. + ExtraParams map[string]string `json:"extra_params,omitempty"` + // The input string (or array of strings) field used ONLY for __embeddings + // external & foundation model__ serving endpoints and is the only field (along + // with extra_params if needed) used by embeddings queries. + Input json.RawMessage `json:"input,omitempty"` + // Tensor-based input in columnar format. + Inputs json.RawMessage `json:"inputs,omitempty"` + // Tensor-based input in row format. + Instances []json.RawMessage `json:"instances,omitempty"` + // The max tokens field used ONLY for __completions__ and __chat external & + // foundation model__ serving endpoints. This is an integer and should only be + // used with other chat/completions query fields. + MaxTokens *int `json:"max_tokens,omitempty"` + // The messages field used ONLY for __chat external & foundation model__ serving + // endpoints. This is an array of ChatMessage objects and should only be used + // with other chat query fields. + Messages []ChatMessage `json:"messages,omitempty"` + // The n (number of candidates) field used ONLY for __completions__ and __chat + // external & foundation model__ serving endpoints. This is an integer between 1 + // and 5 with a default of 1 and should only be used with other chat/completions + // query fields. + N *int `json:"n,omitempty"` + // The name of the serving endpoint. This field is required and is provided via + // the path parameter. + Name *string `json:"name,omitempty"` + // The prompt string (or array of strings) field used ONLY for __completions + // external & foundation model__ serving endpoints and should only be used with + // other completions query fields. + Prompt json.RawMessage `json:"prompt,omitempty"` + // The stop sequences field used ONLY for __completions__ and __chat external & + // foundation model__ serving endpoints. This is a list of strings and should + // only be used with other chat/completions query fields. + Stop []string `json:"stop,omitempty"` + // The stream field used ONLY for __completions__ and __chat external & + // foundation model__ serving endpoints. This is a boolean defaulting to false + // and should only be used with other chat/completions query fields. + Stream *bool `json:"stream,omitempty"` + // The temperature field used ONLY for __completions__ and __chat external & + // foundation model__ serving endpoints. This is a float between 0.0 and 2.0 + // with a default of 1.0 and should only be used with other chat/completions + // query fields. + Temperature *float64 `json:"temperature,omitempty"` + // Optional user-provided context that will be recorded in the usage tracking + // table. + UsageContext map[string]string `json:"usage_context,omitempty"` +} + +type QueryEndpointResponse struct { + // The list of choices returned by the __chat or completions external/foundation + // model__ serving endpoint. + Choices []V1ResponseChoiceElement `json:"choices,omitempty"` + // The timestamp in seconds when the query was created in Unix time returned by + // a __completions or chat external/foundation model__ serving endpoint. + Created *int64 `json:"created,omitempty"` + // The list of the embeddings returned by the __embeddings external/foundation + // model__ serving endpoint. + Data []EmbeddingsV1ResponseEmbeddingElement `json:"data,omitempty"` + // The ID of the query that may be returned by a __completions or chat + // external/foundation model__ serving endpoint. + Id *string `json:"id,omitempty"` + // The name of the __external/foundation model__ used for querying. This is the + // name of the model that was specified in the endpoint config. + Model *string `json:"model,omitempty"` + // The type of object returned by the __external/foundation model__ serving + // endpoint, one of [text_completion, chat.completion, list (of embeddings)]. + Object QueryEndpointResponseObject `json:"object,omitempty"` + // The outputs of the feature serving endpoint. + Outputs []json.RawMessage `json:"outputs,omitempty"` + // The predictions returned by the serving endpoint. + Predictions []json.RawMessage `json:"predictions,omitempty"` + // The usage object that may be returned by the __external/foundation model__ + // serving endpoint. This contains information about the number of tokens used + // in the prompt and response. + Usage *ExternalModelUsageElement `json:"usage,omitempty"` +} + +type V1ResponseChoiceElement struct { + // The finish reason returned by the endpoint. + FinishReason *string `json:"finishReason,omitempty"` + // The index of the choice in the __chat or completions__ response. + Index *int `json:"index,omitempty"` + // The logprobs returned only by the __completions__ endpoint. + Logprobs *int `json:"logprobs,omitempty"` + // The message response from the __chat__ endpoint. + Message *ChatMessage `json:"message,omitempty"` + // The text response from the __completions__ endpoint. + Text *string `json:"text,omitempty"` +} + +// ChatMessageToSDK converts the mirror to the sdk-go type. +func ChatMessageToSDK(w *ChatMessage) (*sdk.ChatMessage, error) { + if w == nil { + return nil, nil + } + out := &sdk.ChatMessage{} + out.Role = w.Role + out.Content = w.Content + return out, nil +} + +// ChatMessageFromSDK converts the sdk-go type to the mirror. +func ChatMessageFromSDK(v *sdk.ChatMessage) (*ChatMessage, error) { + if v == nil { + return nil, nil + } + out := &ChatMessage{} + out.Role = v.Role + out.Content = v.Content + return out, nil +} + +// DataframeSplitInputToSDK converts the mirror to the sdk-go type. +func DataframeSplitInputToSDK(w *DataframeSplitInput) (*sdk.DataframeSplitInput, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataframeSplitInput{} + out.Index = w.Index + out.Columns = w.Columns + out.Data = w.Data + return out, nil +} + +// DataframeSplitInputFromSDK converts the sdk-go type to the mirror. +func DataframeSplitInputFromSDK(v *sdk.DataframeSplitInput) (*DataframeSplitInput, error) { + if v == nil { + return nil, nil + } + out := &DataframeSplitInput{} + out.Index = v.Index + out.Columns = v.Columns + out.Data = v.Data + return out, nil +} + +// EmbeddingsV1ResponseEmbeddingElementToSDK converts the mirror to the sdk-go type. +func EmbeddingsV1ResponseEmbeddingElementToSDK(w *EmbeddingsV1ResponseEmbeddingElement) (*sdk.EmbeddingsV1ResponseEmbeddingElement, error) { + if w == nil { + return nil, nil + } + out := &sdk.EmbeddingsV1ResponseEmbeddingElement{} + out.Embedding = w.Embedding + out.Index = w.Index + out.Object = w.Object + return out, nil +} + +// EmbeddingsV1ResponseEmbeddingElementFromSDK converts the sdk-go type to the mirror. +func EmbeddingsV1ResponseEmbeddingElementFromSDK(v *sdk.EmbeddingsV1ResponseEmbeddingElement) (*EmbeddingsV1ResponseEmbeddingElement, error) { + if v == nil { + return nil, nil + } + out := &EmbeddingsV1ResponseEmbeddingElement{} + out.Embedding = v.Embedding + out.Index = v.Index + out.Object = v.Object + return out, nil +} + +// ExternalModelUsageElementToSDK converts the mirror to the sdk-go type. +func ExternalModelUsageElementToSDK(w *ExternalModelUsageElement) (*sdk.ExternalModelUsageElement, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalModelUsageElement{} + out.PromptTokens = w.PromptTokens + out.CompletionTokens = w.CompletionTokens + out.TotalTokens = w.TotalTokens + return out, nil +} + +// ExternalModelUsageElementFromSDK converts the sdk-go type to the mirror. +func ExternalModelUsageElementFromSDK(v *sdk.ExternalModelUsageElement) (*ExternalModelUsageElement, error) { + if v == nil { + return nil, nil + } + out := &ExternalModelUsageElement{} + out.PromptTokens = v.PromptTokens + out.CompletionTokens = v.CompletionTokens + out.TotalTokens = v.TotalTokens + return out, nil +} + +// QueryEndpointRequestToSDK converts the mirror to the sdk-go type. +func QueryEndpointRequestToSDK(w *QueryEndpointRequest) (*sdk.QueryEndpointRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryEndpointRequest{} + out.Name = w.Name + out.Prompt = w.Prompt + out.Input = w.Input + conv1, err := convertSlice(w.Messages, ChatMessageToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryEndpointRequest.Messages", err) + } + out.Messages = conv1 + out.Temperature = w.Temperature + out.Stop = w.Stop + out.MaxTokens = w.MaxTokens + out.N = w.N + out.Stream = w.Stream + out.ExtraParams = w.ExtraParams + out.DataframeRecords = w.DataframeRecords + conv2, err := DataframeSplitInputToSDK(w.DataframeSplit) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryEndpointRequest.DataframeSplit", err) + } + out.DataframeSplit = conv2 + out.Instances = w.Instances + out.Inputs = w.Inputs + out.ClientRequestId = w.ClientRequestId + out.UsageContext = w.UsageContext + return out, nil +} + +// QueryEndpointRequestFromSDK converts the sdk-go type to the mirror. +func QueryEndpointRequestFromSDK(v *sdk.QueryEndpointRequest) (*QueryEndpointRequest, error) { + if v == nil { + return nil, nil + } + out := &QueryEndpointRequest{} + out.Name = v.Name + out.Prompt = v.Prompt + out.Input = v.Input + conv3, err := convertSlice(v.Messages, ChatMessageFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryEndpointRequest.Messages", err) + } + out.Messages = conv3 + out.Temperature = v.Temperature + out.Stop = v.Stop + out.MaxTokens = v.MaxTokens + out.N = v.N + out.Stream = v.Stream + out.ExtraParams = v.ExtraParams + out.DataframeRecords = v.DataframeRecords + conv4, err := DataframeSplitInputFromSDK(v.DataframeSplit) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryEndpointRequest.DataframeSplit", err) + } + out.DataframeSplit = conv4 + out.Instances = v.Instances + out.Inputs = v.Inputs + out.ClientRequestId = v.ClientRequestId + out.UsageContext = v.UsageContext + return out, nil +} + +// QueryEndpointResponseToSDK converts the mirror to the sdk-go type. +func QueryEndpointResponseToSDK(w *QueryEndpointResponse) (*sdk.QueryEndpointResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryEndpointResponse{} + conv5, err := convertSlice(w.Choices, V1ResponseChoiceElementToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryEndpointResponse.Choices", err) + } + out.Choices = conv5 + conv6, err := convertSlice(w.Data, EmbeddingsV1ResponseEmbeddingElementToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryEndpointResponse.Data", err) + } + out.Data = conv6 + out.Model = w.Model + conv7, err := ExternalModelUsageElementToSDK(w.Usage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryEndpointResponse.Usage", err) + } + out.Usage = conv7 + out.Id = w.Id + out.Created = w.Created + out.Object = w.Object + out.Predictions = w.Predictions + out.Outputs = w.Outputs + return out, nil +} + +// QueryEndpointResponseFromSDK converts the sdk-go type to the mirror. +func QueryEndpointResponseFromSDK(v *sdk.QueryEndpointResponse) (*QueryEndpointResponse, error) { + if v == nil { + return nil, nil + } + out := &QueryEndpointResponse{} + conv8, err := convertSlice(v.Choices, V1ResponseChoiceElementFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryEndpointResponse.Choices", err) + } + out.Choices = conv8 + conv9, err := convertSlice(v.Data, EmbeddingsV1ResponseEmbeddingElementFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryEndpointResponse.Data", err) + } + out.Data = conv9 + out.Model = v.Model + conv10, err := ExternalModelUsageElementFromSDK(v.Usage) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryEndpointResponse.Usage", err) + } + out.Usage = conv10 + out.Id = v.Id + out.Created = v.Created + out.Object = v.Object + out.Predictions = v.Predictions + out.Outputs = v.Outputs + return out, nil +} + +// V1ResponseChoiceElementToSDK converts the mirror to the sdk-go type. +func V1ResponseChoiceElementToSDK(w *V1ResponseChoiceElement) (*sdk.V1ResponseChoiceElement, error) { + if w == nil { + return nil, nil + } + out := &sdk.V1ResponseChoiceElement{} + out.Text = w.Text + conv11, err := ChatMessageToSDK(w.Message) + if err != nil { + return nil, fmt.Errorf("%s: %w", "V1ResponseChoiceElement.Message", err) + } + out.Message = conv11 + out.Index = w.Index + out.FinishReason = w.FinishReason + out.Logprobs = w.Logprobs + return out, nil +} + +// V1ResponseChoiceElementFromSDK converts the sdk-go type to the mirror. +func V1ResponseChoiceElementFromSDK(v *sdk.V1ResponseChoiceElement) (*V1ResponseChoiceElement, error) { + if v == nil { + return nil, nil + } + out := &V1ResponseChoiceElement{} + out.Text = v.Text + conv12, err := ChatMessageFromSDK(v.Message) + if err != nil { + return nil, fmt.Errorf("%s: %w", "V1ResponseChoiceElement.Message", err) + } + out.Message = conv12 + out.Index = v.Index + out.FinishReason = v.FinishReason + out.Logprobs = v.Logprobs + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/networking/v1/types.generated.go b/libs/sdktypes/networking/v1/types.generated.go new file mode 100644 index 00000000000..31b009dc2fc --- /dev/null +++ b/libs/sdktypes/networking/v1/types.generated.go @@ -0,0 +1,4837 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/networking/v1. DO NOT EDIT. + +package networking + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/networking/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + EgressResourceType = sdk.EgressResourceType + EndpointState = sdk.EndpointState + IpAccessListType = sdk.IpAccessListType + PrivateAccessLevel = sdk.PrivateAccessLevel + VpcEndpointUseCase = sdk.VpcEndpointUseCase + VpcStatus = sdk.VpcStatus + AccountIpAccessListType_IpAccessListType = sdk.AccountIpAccessListType_IpAccessListType + EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination_InternetDestinationType = sdk.EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination_InternetDestinationType + EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_DryRunModeProductFilter = sdk.EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_DryRunModeProductFilter + EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_EnforcementMode = sdk.EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_EnforcementMode + EgressNetworkPolicy_NetworkAccessPolicy_RestrictionMode = sdk.EgressNetworkPolicy_NetworkAccessPolicy_RestrictionMode + EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination_StorageDestinationType = sdk.EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination_StorageDestinationType + EndpointUseCase_EndpointUseCase = sdk.EndpointUseCase_EndpointUseCase + IngressNetworkPolicy_ApiScopeQualifier = sdk.IngressNetworkPolicy_ApiScopeQualifier + IngressNetworkPolicy_Authentication_IdentityType = sdk.IngressNetworkPolicy_Authentication_IdentityType + IngressNetworkPolicy_AuthenticationIdentity_PrincipalType = sdk.IngressNetworkPolicy_AuthenticationIdentity_PrincipalType + IngressNetworkPolicy_CrossWorkspaceAccess_RestrictionMode = sdk.IngressNetworkPolicy_CrossWorkspaceAccess_RestrictionMode + IngressNetworkPolicy_PrivateAccess_RestrictionMode = sdk.IngressNetworkPolicy_PrivateAccess_RestrictionMode + IngressNetworkPolicy_PublicAccess_RestrictionMode = sdk.IngressNetworkPolicy_PublicAccess_RestrictionMode + NccPrivateEndpointRule_PrivateLinkConnectionState = sdk.NccPrivateEndpointRule_PrivateLinkConnectionState + NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState = sdk.NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState + NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState = sdk.NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState +) + +const ( + EgressResourceType_Unspecified = sdk.EgressResourceType_Unspecified + EgressResourceType_AzureBlobStorage = sdk.EgressResourceType_AzureBlobStorage + EndpointState_Unspecified = sdk.EndpointState_Unspecified + EndpointState_Pending = sdk.EndpointState_Pending + EndpointState_Approved = sdk.EndpointState_Approved + EndpointState_Failed = sdk.EndpointState_Failed + EndpointState_Disconnected = sdk.EndpointState_Disconnected + IpAccessListType_Unspecified = sdk.IpAccessListType_Unspecified + IpAccessListType_Allow = sdk.IpAccessListType_Allow + IpAccessListType_Block = sdk.IpAccessListType_Block + PrivateAccessLevel_Unspecified = sdk.PrivateAccessLevel_Unspecified + PrivateAccessLevel_Endpoint = sdk.PrivateAccessLevel_Endpoint + PrivateAccessLevel_Account = sdk.PrivateAccessLevel_Account + VpcEndpointUseCase_Unspecified = sdk.VpcEndpointUseCase_Unspecified + VpcEndpointUseCase_WorkspaceAccess = sdk.VpcEndpointUseCase_WorkspaceAccess + VpcEndpointUseCase_DataplaneRelayAccess = sdk.VpcEndpointUseCase_DataplaneRelayAccess + VpcEndpointUseCase_GeneralAccess = sdk.VpcEndpointUseCase_GeneralAccess + VpcStatus_Unspecified = sdk.VpcStatus_Unspecified + VpcStatus_Valid = sdk.VpcStatus_Valid + VpcStatus_Broken = sdk.VpcStatus_Broken + VpcStatus_Unattached = sdk.VpcStatus_Unattached + VpcStatus_Warned = sdk.VpcStatus_Warned + AccountIpAccessListType_IpAccessListType_Unspecified = sdk.AccountIpAccessListType_IpAccessListType_Unspecified + AccountIpAccessListType_IpAccessListType_Allow = sdk.AccountIpAccessListType_IpAccessListType_Allow + AccountIpAccessListType_IpAccessListType_Block = sdk.AccountIpAccessListType_IpAccessListType_Block + EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination_InternetDestinationType_Unspecified = sdk.EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination_InternetDestinationType_Unspecified + EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination_InternetDestinationType_DnsName = sdk.EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination_InternetDestinationType_DnsName + EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_DryRunModeProductFilter_Unspecified = sdk.EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_DryRunModeProductFilter_Unspecified + EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_DryRunModeProductFilter_Dbsql = sdk.EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_DryRunModeProductFilter_Dbsql + EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_DryRunModeProductFilter_MlServing = sdk.EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_DryRunModeProductFilter_MlServing + EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_EnforcementMode_Unspecified = sdk.EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_EnforcementMode_Unspecified + EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_EnforcementMode_Enforced = sdk.EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_EnforcementMode_Enforced + EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_EnforcementMode_DryRun = sdk.EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_EnforcementMode_DryRun + EgressNetworkPolicy_NetworkAccessPolicy_RestrictionMode_Unspecified = sdk.EgressNetworkPolicy_NetworkAccessPolicy_RestrictionMode_Unspecified + EgressNetworkPolicy_NetworkAccessPolicy_RestrictionMode_FullAccess = sdk.EgressNetworkPolicy_NetworkAccessPolicy_RestrictionMode_FullAccess + EgressNetworkPolicy_NetworkAccessPolicy_RestrictionMode_RestrictedAccess = sdk.EgressNetworkPolicy_NetworkAccessPolicy_RestrictionMode_RestrictedAccess + EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination_StorageDestinationType_Unspecified = sdk.EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination_StorageDestinationType_Unspecified + EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination_StorageDestinationType_AwsS3 = sdk.EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination_StorageDestinationType_AwsS3 + EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination_StorageDestinationType_AzureStorage = sdk.EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination_StorageDestinationType_AzureStorage + EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination_StorageDestinationType_GoogleCloudStorage = sdk.EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination_StorageDestinationType_GoogleCloudStorage + EndpointUseCase_EndpointUseCase_Unspecified = sdk.EndpointUseCase_EndpointUseCase_Unspecified + EndpointUseCase_EndpointUseCase_ServiceDirect = sdk.EndpointUseCase_EndpointUseCase_ServiceDirect + IngressNetworkPolicy_ApiScopeQualifier_Unspecified = sdk.IngressNetworkPolicy_ApiScopeQualifier_Unspecified + IngressNetworkPolicy_ApiScopeQualifier_ApiScopeQualifierRead = sdk.IngressNetworkPolicy_ApiScopeQualifier_ApiScopeQualifierRead + IngressNetworkPolicy_ApiScopeQualifier_ApiScopeQualifierAll = sdk.IngressNetworkPolicy_ApiScopeQualifier_ApiScopeQualifierAll + IngressNetworkPolicy_Authentication_IdentityType_Unspecified = sdk.IngressNetworkPolicy_Authentication_IdentityType_Unspecified + IngressNetworkPolicy_Authentication_IdentityType_IdentityTypeAllUsers = sdk.IngressNetworkPolicy_Authentication_IdentityType_IdentityTypeAllUsers + IngressNetworkPolicy_Authentication_IdentityType_IdentityTypeAllServicePrincipals = sdk.IngressNetworkPolicy_Authentication_IdentityType_IdentityTypeAllServicePrincipals + IngressNetworkPolicy_Authentication_IdentityType_IdentityTypeSelectedIdentities = sdk.IngressNetworkPolicy_Authentication_IdentityType_IdentityTypeSelectedIdentities + IngressNetworkPolicy_AuthenticationIdentity_PrincipalType_Unspecified = sdk.IngressNetworkPolicy_AuthenticationIdentity_PrincipalType_Unspecified + IngressNetworkPolicy_AuthenticationIdentity_PrincipalType_PrincipalTypeUser = sdk.IngressNetworkPolicy_AuthenticationIdentity_PrincipalType_PrincipalTypeUser + IngressNetworkPolicy_AuthenticationIdentity_PrincipalType_PrincipalTypeServicePrincipal = sdk.IngressNetworkPolicy_AuthenticationIdentity_PrincipalType_PrincipalTypeServicePrincipal + IngressNetworkPolicy_CrossWorkspaceAccess_RestrictionMode_Unspecified = sdk.IngressNetworkPolicy_CrossWorkspaceAccess_RestrictionMode_Unspecified + IngressNetworkPolicy_CrossWorkspaceAccess_RestrictionMode_FullAccess = sdk.IngressNetworkPolicy_CrossWorkspaceAccess_RestrictionMode_FullAccess + IngressNetworkPolicy_CrossWorkspaceAccess_RestrictionMode_RestrictedAccess = sdk.IngressNetworkPolicy_CrossWorkspaceAccess_RestrictionMode_RestrictedAccess + IngressNetworkPolicy_CrossWorkspaceAccess_RestrictionMode_LegacyMode = sdk.IngressNetworkPolicy_CrossWorkspaceAccess_RestrictionMode_LegacyMode + IngressNetworkPolicy_PrivateAccess_RestrictionMode_Unspecified = sdk.IngressNetworkPolicy_PrivateAccess_RestrictionMode_Unspecified + IngressNetworkPolicy_PrivateAccess_RestrictionMode_AllowAllRegisteredEndpoints = sdk.IngressNetworkPolicy_PrivateAccess_RestrictionMode_AllowAllRegisteredEndpoints + IngressNetworkPolicy_PrivateAccess_RestrictionMode_RestrictedAccess = sdk.IngressNetworkPolicy_PrivateAccess_RestrictionMode_RestrictedAccess + IngressNetworkPolicy_PublicAccess_RestrictionMode_Unspecified = sdk.IngressNetworkPolicy_PublicAccess_RestrictionMode_Unspecified + IngressNetworkPolicy_PublicAccess_RestrictionMode_FullAccess = sdk.IngressNetworkPolicy_PublicAccess_RestrictionMode_FullAccess + IngressNetworkPolicy_PublicAccess_RestrictionMode_RestrictedAccess = sdk.IngressNetworkPolicy_PublicAccess_RestrictionMode_RestrictedAccess + NccPrivateEndpointRule_PrivateLinkConnectionState_Unspecified = sdk.NccPrivateEndpointRule_PrivateLinkConnectionState_Unspecified + NccPrivateEndpointRule_PrivateLinkConnectionState_Established = sdk.NccPrivateEndpointRule_PrivateLinkConnectionState_Established + NccPrivateEndpointRule_PrivateLinkConnectionState_Rejected = sdk.NccPrivateEndpointRule_PrivateLinkConnectionState_Rejected + NccPrivateEndpointRule_PrivateLinkConnectionState_Disconnected = sdk.NccPrivateEndpointRule_PrivateLinkConnectionState_Disconnected + NccPrivateEndpointRule_PrivateLinkConnectionState_Expired = sdk.NccPrivateEndpointRule_PrivateLinkConnectionState_Expired + NccPrivateEndpointRule_PrivateLinkConnectionState_Pending = sdk.NccPrivateEndpointRule_PrivateLinkConnectionState_Pending + NccPrivateEndpointRule_PrivateLinkConnectionState_Creating = sdk.NccPrivateEndpointRule_PrivateLinkConnectionState_Creating + NccPrivateEndpointRule_PrivateLinkConnectionState_CreateFailed = sdk.NccPrivateEndpointRule_PrivateLinkConnectionState_CreateFailed + NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Unspecified = sdk.NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Unspecified + NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Established = sdk.NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Established + NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Rejected = sdk.NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Rejected + NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Disconnected = sdk.NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Disconnected + NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Expired = sdk.NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Expired + NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Pending = sdk.NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Pending + NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Creating = sdk.NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_Creating + NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_CreateFailed = sdk.NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState_CreateFailed + NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Unspecified = sdk.NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Unspecified + NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Init = sdk.NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Init + NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Established = sdk.NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Established + NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Rejected = sdk.NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Rejected + NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Disconnected = sdk.NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Disconnected + NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Expired = sdk.NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Expired + NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Pending = sdk.NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Pending + NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Creating = sdk.NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_Creating + NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_CreateFailed = sdk.NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState_CreateFailed +) + +// Definition of an IP Access list. +type AccountIpAccessList struct { + // Total number of IP or CIDR values. + AddressCount *int `json:"address_count,omitempty"` + // Creation timestamp in milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // The ID of the user that created this list. + CreatedBy *int64 `json:"created_by,omitempty"` + // Specifies whether this IP access list is enabled. + Enabled *bool `json:"enabled,omitempty"` + IpAddresses []string `json:"ip_addresses,omitempty"` + // Label for the IP access list. This **cannot** be empty. + Label *string `json:"label,omitempty"` + // Universally unique identifier (UUID) of the IP access list. + ListId *string `json:"list_id,omitempty"` + ListType AccountIpAccessListType_IpAccessListType `json:"list_type,omitempty"` + // Update timestamp in milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // The ID of the user that last updated this list. + UpdatedBy *int64 `json:"updated_by,omitempty"` +} + +type AccountNetworkPolicy struct { + // The associated account ID for this Network Policy object. + AccountId *string `json:"account_id,omitempty"` + // The network policies applying for egress traffic. + Egress *EgressNetworkPolicy `json:"egress,omitempty"` + // The network policies applying for ingress traffic. + Ingress *IngressNetworkPolicy `json:"ingress,omitempty"` + // The ingress policy for dry run mode. Dry run will always run even if the + // request is allowed by the ingress policy. When this field is set, the policy + // will be evaluated and emit logs only without blocking requests. + IngressDryRun *IngressNetworkPolicy `json:"ingress_dry_run,omitempty"` + // The unique identifier for the network policy. + NetworkPolicyId *string `json:"network_policy_id,omitempty"` +} + +type AwsVpcEndpointInfo struct { + // The AWS account ID in which this VPC endpoint lives. + AwsAccountId *string `json:"aws_account_id,omitempty"` + // The ID of the Databricks VPC endpoint service that this endpoint connects to. + AwsEndpointServiceId *string `json:"aws_endpoint_service_id,omitempty"` + // The ID of the underlying VPC endpoint in AWS. Provided by the customer when + // registering an existing AWS VPC endpoint. + AwsVpcEndpointId *string `json:"aws_vpc_endpoint_id,omitempty"` +} + +type AzurePrivateEndpointInfo struct { + // The name of the Private Endpoint in the Azure subscription. + PrivateEndpointName *string `json:"private_endpoint_name,omitempty"` + // The GUID of the Private Endpoint resource in the Azure subscription. This is + // assigned by Azure when the user sets up the Private Endpoint. + PrivateEndpointResourceGuid *string `json:"private_endpoint_resource_guid,omitempty"` + // The full resource ID of the Private Endpoint. + PrivateEndpointResourceId *string `json:"private_endpoint_resource_id,omitempty"` + // The resource ID of the Databricks Private Link Service that this Private + // Endpoint connects to. + PrivateLinkServiceId *string `json:"private_link_service_id,omitempty"` +} + +// Details required to configure a block list or allow list.. +type CreateAccountIpAccessListRequest struct { + AccountId *string `json:"account_id,omitempty"` + IpAddresses []string `json:"ip_addresses,omitempty"` + Label *string `json:"label,omitempty"` + ListType AccountIpAccessListType_IpAccessListType `json:"list_type,omitempty"` +} + +// An IP access list was successfully created.. +type CreateAccountIpAccessListResponse struct { + IpAccessList *AccountIpAccessList `json:"ip_access_list,omitempty"` +} + +type CreateEndpointRequest struct { + Endpoint *Endpoint `json:"endpoint,omitempty"` + // The parent resource name of the account under which the endpoint is created. + // Format: `accounts/{account_id}`. + Parent *string `json:"parent,omitempty"` +} + +// Details required to configure a block list or allow list.. +type CreateIpAccessListRequest struct { + IpAddresses []string `json:"ip_addresses,omitempty"` + // Label for the IP access list. This **cannot** be empty. + Label *string `json:"label,omitempty"` + ListType IpAccessListType `json:"list_type,omitempty"` +} + +// An IP access list was successfully created.. +type CreateIpAccessListResponse struct { + IpAccessList *IpAccessList `json:"ip_access_list,omitempty"` +} + +// Properties of the new private endpoint rule.. +type CreateNccPrivateEndpointRuleRequest struct { + // Your account ID. You can find your account ID in your + // accounts console. + AccountId *string `json:"account_id,omitempty"` + // Your Network Connectivity Configuration ID. + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + PrivateEndpointRule *CreatePrivateEndpointRule `json:"private_endpoint_rule,omitempty"` +} + +// Properties of the new network connectivity configuration.. +type CreateNetworkConnectivityConfigRequest struct { + // Your account ID. You can find your account ID in your + // accounts console. + AccountId *string `json:"account_id,omitempty"` + NetworkConnectivityConfig *CreateNetworkConnectivityConfiguration `json:"network_connectivity_config,omitempty"` +} + +// Properties of the new network connectivity configuration.. +type CreateNetworkConnectivityConfiguration struct { + // Your account ID. You can find your account ID in your + // accounts console. + AccountId *string `json:"account_id,omitempty"` + // Time in epoch milliseconds when this object was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // The network connectivity rules that apply to network traffic from your + // serverless compute resources. + EgressConfig *CustomerFacingNetworkConnectivityConfigEgressConfig `json:"egress_config,omitempty"` + // The name of the network connectivity configuration. The name can contain + // alphanumeric characters, hyphens, and underscores. The length must be between + // 3 and 30 characters. The name must match the regular expression + // ^[0-9a-zA-Z-_]{3,30}$ + Name *string `json:"name,omitempty"` + // network connectivity configuration ID. + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + // The region for the network connectivity configuration. Only workspaces in the + // same region can be attached to the network connectivity configuration. + Region *string `json:"region,omitempty"` + // Time in epoch milliseconds when this object was updated. + UpdatedTime *int64 `json:"updated_time,omitempty"` +} + +type CreateNetworkPolicyRequest struct { + // Your account ID. You can find your account ID in your + // accounts console. + AccountId *string `json:"account_id,omitempty"` + // Network policy configuration details. + NetworkPolicy *AccountNetworkPolicy `json:"network_policy,omitempty"` +} + +type CreateNetworkRequest struct { + AccountId *string `json:"account_id,omitempty"` + GcpNetworkInfo *GcpNetworkInfo `json:"gcp_network_info,omitempty"` + // The human-readable name of the network configuration. + NetworkName *string `json:"network_name,omitempty"` + // IDs of one to five security groups associated with this network. Security + // group IDs **cannot** be used in multiple network configurations. + SecurityGroupIds []string `json:"security_group_ids,omitempty"` + // IDs of at least two subnets associated with this network. Subnet IDs + // **cannot** be used in multiple network configurations. + SubnetIds []string `json:"subnet_ids,omitempty"` + VpcEndpoints *NetworkVpcEndpoints `json:"vpc_endpoints,omitempty"` + // The ID of the VPC associated with this network configuration. VPC IDs can be + // used in multiple networks. + VpcId *string `json:"vpc_id,omitempty"` +} + +type CreatePrivateAccessSettingsRequest struct { + AccountId *string `json:"account_id,omitempty"` + // An array of Databricks VPC endpoint IDs. This is the ID returned + // when registering the VPC endpoint configuration in your account. + // This is not the ID of the VPC endpoint in AWS. Only used when + // private_access_level is set to ENDPOINT. This is an allow list of VPC + // endpoints registered in your account that can connect to your + // workspace over AWS PrivateLink. Note: If hybrid access to your workspace is + // enabled by setting public_access_enabled to true, this control only works for + // PrivateLink connections. To control how your workspace is accessed via public + // internet, see IP access lists. + AllowedVpcEndpointIds []string `json:"allowed_vpc_endpoint_ids,omitempty"` + // The private access level controls which VPC endpoints can connect to the UI + // or API of any workspace that attaches this private access settings object. + // `ACCOUNT` level access (the default) allows only VPC endpoints that are + // registered in your account connect to your workspace. `ENDPOINT` + // level access allows only specified VPC endpoints connect to your workspace. + // For details, see allowed_vpc_endpoint_ids. + PrivateAccessLevel PrivateAccessLevel `json:"private_access_level,omitempty"` + // The human-readable name of the private access settings object. + PrivateAccessSettingsName *string `json:"private_access_settings_name,omitempty"` + // Determines if the workspace can be accessed over public internet. For fully + // private workspaces, you can optionally specify false, but only if you + // implement both the front-end and the back-end PrivateLink connections. + // Otherwise, specify true, which means that public access is enabled. + PublicAccessEnabled *bool `json:"public_access_enabled,omitempty"` + // The AWS region for workspaces attached to this private access settings + // object. + Region *string `json:"region,omitempty"` +} + +// Properties of the new private endpoint rule. Note that you must approve the +// endpoint in Azure portal after initialization.. +type CreatePrivateEndpointRule struct { + // account ID. You can find your account ID from the Accounts + // Console. + AccountId *string `json:"account_id,omitempty"` + // The current status of this private endpoint. The private endpoint rules are + // effective only if the connection state is ESTABLISHED. Remember that you must + // approve new endpoints on your resources in the Cloud console before they take + // effect. The possible values are: - PENDING: The endpoint has been created and + // pending approval. - ESTABLISHED: The endpoint has been approved and is ready + // to use in your serverless compute resources. - REJECTED: Connection was + // rejected by the private link resource owner. - DISCONNECTED: Connection was + // removed by the private link resource owner, the private endpoint becomes + // informative and should be deleted for clean-up. - EXPIRED: If the endpoint + // was created but not approved in 14 days, it will be EXPIRED. - CREATING: The + // endpoint creation is in progress. Once successfully created, the state will + // transition to PENDING. - CREATE_FAILED: The endpoint creation failed. You can + // check the error_message field for more details. + ConnectionState NccPrivateEndpointRule_PrivateLinkConnectionState `json:"connection_state,omitempty"` + // Time in epoch milliseconds when this object was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // Whether this private endpoint is deactivated. + Deactivated *bool `json:"deactivated,omitempty"` + // Time in epoch milliseconds when this object was deactivated. + DeactivatedAt *int64 `json:"deactivated_at,omitempty"` + // Only used by private endpoints to customer-managed private endpoint services. + // + // Domain names of target private link service. When updating this field, the + // full list of target domain_names must be specified. + DomainNames []string `json:"domain_names,omitempty"` + // Update this field to activate/deactivate this private endpoint to allow + // egress access from serverless compute resources. Only honored for first-party + // services on each cloud (e.g. AWS S3). + Enabled *bool `json:"enabled,omitempty"` + // The name of the Azure private endpoint resource. + EndpointName *string `json:"endpoint_name,omitempty"` + // The full target AWS endpoint service name that connects to the destination + // resources of the private endpoint. + EndpointService *string `json:"endpoint_service,omitempty"` + ErrorMessage *string `json:"error_message,omitempty"` + GcpEndpoint *GcpEndpoint `json:"gcp_endpoint,omitempty"` + // Not used by customer-managed private endpoint services. + // + // The sub-resource type (group ID) of the target resource. Note that to connect + // to workspace root storage (root DBFS), you need two endpoints, one for blob + // and one for dfs. + GroupId *string `json:"group_id,omitempty"` + // The ID of a network connectivity configuration, which is the parent resource + // of this private endpoint rule object. + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + // The Azure resource ID of the target resource. + ResourceId *string `json:"resource_id,omitempty"` + // Only used by private endpoints towards AWS S3 service. + // + // The globally unique S3 bucket names that will be accessed via the VPC + // endpoint. The bucket names must be in the same region as the NCC/endpoint + // service. When updating this field, we perform full update on this field. + // Please ensure a full list of desired resource_names is provided. + ResourceNames []string `json:"resource_names,omitempty"` + // The ID of a private endpoint rule. + RuleId *string `json:"rule_id,omitempty"` + // Time in epoch milliseconds when this object was updated. + UpdatedTime *int64 `json:"updated_time,omitempty"` + // The AWS VPC endpoint ID. You can use this ID to identify the VPC endpoint + // created by . + VpcEndpointId *string `json:"vpc_endpoint_id,omitempty"` +} + +type CreateVpcEndpointRequest struct { + AccountId *string `json:"account_id,omitempty"` + // The ID of the VPC endpoint object in AWS. + AwsVpcEndpointId *string `json:"aws_vpc_endpoint_id,omitempty"` + GcpVpcEndpointInfo *GcpVpcEndpointInfo `json:"gcp_vpc_endpoint_info,omitempty"` + // The region in which this VPC endpoint object exists. + Region *string `json:"region,omitempty"` + // The human-readable name of the storage configuration. + VpcEndpointName *string `json:"vpc_endpoint_name,omitempty"` +} + +type CustomerFacingNetworkConnectivityConfigEgressConfig struct { + // The network connectivity rules that are applied by default without resource + // specific configurations. You can find the stable network information of your + // serverless compute resources here. + DefaultRules *NetworkConnectivityConfigEgressConfig_DefaultRule `json:"default_rules,omitempty"` + // The network connectivity rules that configured for each destinations. These + // rules override default rules. + TargetRules *CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule `json:"target_rules,omitempty"` +} + +// Target rule controls the egress rules that are dedicated to specific +// resources.. +type CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule struct { + // AWS private endpoint rule controls the AWS private endpoint based egress + // rules. + AwsPrivateEndpointRules []NetworkConnectivityConfigAwsPrivateEndpointRule `json:"aws_private_endpoint_rules,omitempty"` + AzurePrivateEndpointRules []NetworkConnectivityConfigAzurePrivateEndpointRule `json:"azure_private_endpoint_rules,omitempty"` +} + +// The network policies applying for egress traffic.. +type EgressNetworkPolicy struct { + // The access policy enforced for egress traffic to the internet. + NetworkAccess *EgressNetworkPolicy_NetworkAccessPolicy `json:"network_access,omitempty"` +} + +type EgressNetworkPolicy_NetworkAccessPolicy struct { + // List of workspace destinations that serverless workloads are + // allowed to access when in RESTRICTED_ACCESS mode. + AllowedDatabricksDestinations []EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestination `json:"allowed_databricks_destinations,omitempty"` + // List of internet destinations that serverless workloads are allowed to access + // when in RESTRICTED_ACCESS mode. + AllowedInternetDestinations []EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination `json:"allowed_internet_destinations,omitempty"` + // List of storage destinations that serverless workloads are allowed to access + // when in RESTRICTED_ACCESS mode. + AllowedStorageDestinations []EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination `json:"allowed_storage_destinations,omitempty"` + // List of internet destinations that serverless workloads are blocked from + // accessing. These destinations are enforced when restriction mode is + // RESTRICTED_ACCESS or DRY_RUN. Currently supports DNS_NAME type only; IP_RANGE + // support is planned. + BlockedInternetDestinations []EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination `json:"blocked_internet_destinations,omitempty"` + // Optional. When policy_enforcement is not provided, we default to + // ENFORCE_MODE_ALL_SERVICES + PolicyEnforcement *EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement `json:"policy_enforcement,omitempty"` + // The restriction mode that controls how serverless workloads can access the + // internet. + RestrictionMode EgressNetworkPolicy_NetworkAccessPolicy_RestrictionMode `json:"restriction_mode,omitempty"` +} + +type EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestination struct { + // The workspace IDs to allow egress traffic to. + WorkspaceIds []int64 `json:"workspace_ids,omitempty"` +} + +// Users can specify accessible internet destinations when outbound access is +// restricted. We only support DNS_NAME (FQDN format) destinations for the time +// being. Going forward we may extend support to host names and IP addresses.. +type EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination struct { + // The internet destination to which access will be allowed. Format dependent on + // the destination type. + Destination *string `json:"destination,omitempty"` + // The type of internet destination. Currently only DNS_NAME is supported. + InternetDestinationType EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination_InternetDestinationType `json:"internet_destination_type,omitempty"` +} + +type EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement struct { + // When empty, it means dry run for all products. When non-empty, it means dry + // run for specific products and for the other products, they will run in + // enforced mode. + DryRunModeProductFilter []EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_DryRunModeProductFilter `json:"dry_run_mode_product_filter,omitempty"` + // The mode of policy enforcement. ENFORCED blocks traffic that violates policy, + // while DRY_RUN only logs violations without blocking. When not specified, + // defaults to ENFORCED. + EnforcementMode EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement_EnforcementMode `json:"enforcement_mode,omitempty"` +} + +// Users can specify accessible storage destinations.. +type EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination struct { + // The Azure storage account name. + AzureStorageAccount *string `json:"azure_storage_account,omitempty"` + // The Azure storage service type (blob, dfs, etc.). + AzureStorageService *string `json:"azure_storage_service,omitempty"` + BucketName *string `json:"bucket_name,omitempty"` + Region *string `json:"region,omitempty"` + // The type of storage destination. + StorageDestinationType EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination_StorageDestinationType `json:"storage_destination_type,omitempty"` +} + +// Endpoint represents a cloud networking resource in a user's cloud account and +// binds it to the account.. +type Endpoint struct { + // The Databricks Account in which the endpoint object exists. + AccountId *string `json:"account_id,omitempty"` + AwsVpcEndpointInfo *AwsVpcEndpointInfo `json:"aws_vpc_endpoint_info,omitempty"` + AzurePrivateEndpointInfo *AzurePrivateEndpointInfo `json:"azure_private_endpoint_info,omitempty"` + // The timestamp when the endpoint was created. The timestamp is in RFC 3339 + // format in UTC timezone. + CreateTime *types.Time `json:"create_time,omitempty"` + // The human-readable display name of this endpoint. The input should conform to + // RFC-1034, which restricts to letters, numbers, and hyphens, with the first + // character a letter, the last a letter or a number, and a 63 character + // maximum. + DisplayName *string `json:"display_name,omitempty"` + // The unique identifier for this endpoint under the account. This field is a + // UUID generated by . + EndpointId *string `json:"endpoint_id,omitempty"` + GcpPscEndpointInfo *GcpPscEndpointInfo `json:"gcp_psc_endpoint_info,omitempty"` + // The resource name of the endpoint, which uniquely identifies the endpoint. + Name *string `json:"name,omitempty"` + // The cloud provider region where this endpoint is located. + Region *string `json:"region,omitempty"` + // The state of the endpoint. The endpoint can only be used if the state is + // `APPROVED`. + State EndpointState `json:"state,omitempty"` + // The use case that determines the type of network connectivity this endpoint + // provides. This field is automatically determined based on the endpoint + // configuration and cloud-specific settings. + UseCase EndpointUseCase_EndpointUseCase `json:"use_case,omitempty"` +} + +type GcpEndpoint struct { + AllVpcScServices *bool `json:"all_vpc_sc_services,omitempty"` + GoogleApiEndpoints *GoogleApiEndpoints `json:"google_api_endpoints,omitempty"` + // Output only. The URI of the created PSC endpoint. + PscEndpointUri *string `json:"psc_endpoint_uri,omitempty"` + ServiceAttachment *string `json:"service_attachment,omitempty"` +} + +type GcpNetworkInfo struct { + // The GCP project ID for network resources. This project is where the VPC and + // subnet resides. + NetworkProjectId *string `json:"network_project_id,omitempty"` + // Name of the secondary range within the subnet that will be used by GKE as Pod + // IP range. This is BYO VPC specific. DB VPC uses + // network.getGcpManagedNetworkConfig.getGkeClusterPodIpRange + PodIpRangeName *string `json:"pod_ip_range_name,omitempty"` + // Name of the secondary range within the subnet that will be used by GKE as + // Service IP range. + ServiceIpRangeName *string `json:"service_ip_range_name,omitempty"` + // The customer-provided Subnet ID that will be available to Clusters in + // Workspaces using this Network. + SubnetId *string `json:"subnet_id,omitempty"` + SubnetRegion *string `json:"subnet_region,omitempty"` + // The customer-provided VPC ID. + VpcId *string `json:"vpc_id,omitempty"` +} + +type GcpPscEndpointInfo struct { + // The GCP region of the PSC connection endpoint. Provided by the customer when + // registering an existing PSC endpoint. GCP supports only same-region PSC, so + // this must match the workspace region. + EndpointRegion *string `json:"endpoint_region,omitempty"` + // The GCP consumer project ID in which this PSC endpoint is created. Provided + // by the customer when registering an existing PSC endpoint. + ProjectId *string `json:"project_id,omitempty"` + // The ID of the underlying Private Service Connect connection in the GCP + // consumer project, assigned by GCP when the PSC connection is created. + PscConnectionId *string `json:"psc_connection_id,omitempty"` + // The name of this PSC connection in the GCP consumer project. Provided by the + // customer when registering an existing PSC endpoint. + PscEndpoint *string `json:"psc_endpoint,omitempty"` + // The ID of the service attachment this PSC endpoint connects to. + ServiceAttachmentId *string `json:"service_attachment_id,omitempty"` +} + +type GcpVpcEndpointInfo struct { + EndpointRegion *string `json:"endpoint_region,omitempty"` + ProjectId *string `json:"project_id,omitempty"` + PscConnectionId *string `json:"psc_connection_id,omitempty"` + PscEndpointName *string `json:"psc_endpoint_name,omitempty"` + ServiceAttachmentId *string `json:"service_attachment_id,omitempty"` +} + +type GetAccountIpAccessListResponse struct { + IpAccessList *AccountIpAccessList `json:"ip_access_list,omitempty"` +} + +// An IP access list was successfully returned.. +type GetIpAccessListResponse struct { + IpAccessList *IpAccessList `json:"ip_access_list,omitempty"` +} + +// Wrapper for a list of Google API hostnames. Wrapped in a message because +// proto3 oneof does not support repeated fields directly.. +type GoogleApiEndpoints struct { + // Google API hostnames, e.g. "storage.googleapis.com", + // "bigquery.googleapis.com". Use "googleapis.com" to cover all Google APIs. + Endpoints []string `json:"endpoints,omitempty"` +} + +// The network policies applying for ingress traffic.. +type IngressNetworkPolicy struct { + CrossWorkspaceAccess *IngressNetworkPolicy_CrossWorkspaceAccess `json:"cross_workspace_access,omitempty"` + // The network policy restrictions for private access. Configures how requests + // arriving over private connectivity are governed. + PrivateAccess *IngressNetworkPolicy_PrivateAccess `json:"private_access,omitempty"` + // The network policy restrictions for public access to the workspace. + // Configures how public internet traffic is allowed or denied access. + PublicAccess *IngressNetworkPolicy_PublicAccess `json:"public_access,omitempty"` +} + +// Matches account-level Databricks API endpoints for an ingress network policy +// rule.. +type IngressNetworkPolicy_AccountApiDestination struct { + // Qualifies the breadth of API access for the listed scopes. See + // ApiScopeQualifier. + ScopeQualifier IngressNetworkPolicy_ApiScopeQualifier `json:"scope_qualifier,omitempty"` + // The API scopes to match. Use "all-apis" to match any account-level API. + Scopes []string `json:"scopes,omitempty"` +} + +type IngressNetworkPolicy_AccountDatabricksOneDestination struct { + // Must be set to true. + AllDestinations *bool `json:"all_destinations,omitempty"` +} + +// The account console UI destination.. +type IngressNetworkPolicy_AccountUiDestination struct { + // Must be set to true. + AllDestinations *bool `json:"all_destinations,omitempty"` +} + +type IngressNetworkPolicy_AppsRuntimeDestination struct { + // Must be set to true. + AllDestinations *bool `json:"all_destinations,omitempty"` +} + +type IngressNetworkPolicy_Authentication struct { + // Valid only when IdentityType is IDENTITY_TYPE_SELECTED_IDENTITIES. + Identities []IngressNetworkPolicy_AuthenticationIdentity `json:"identities,omitempty"` + IdentityType IngressNetworkPolicy_Authentication_IdentityType `json:"identity_type,omitempty"` +} + +type IngressNetworkPolicy_AuthenticationIdentity struct { + PrincipalId *int64 `json:"principal_id,omitempty"` + PrincipalType IngressNetworkPolicy_AuthenticationIdentity_PrincipalType `json:"principal_type,omitempty"` +} + +type IngressNetworkPolicy_CrossWorkspaceAccess struct { + // Allow rules are evaluated after deny rules. A request matching any allow rule + // is allowed; a request matching no rule is denied by default. Only applies + // when restriction_mode is RESTRICTED_ACCESS. + AllowRules []IngressNetworkPolicy_CrossWorkspaceIngressRule `json:"allow_rules,omitempty"` + // Deny rules are evaluated first. A request matching any deny rule is denied, + // regardless of allow rules. Only applies when restriction_mode is + // RESTRICTED_ACCESS. + DenyRules []IngressNetworkPolicy_CrossWorkspaceIngressRule `json:"deny_rules,omitempty"` + // The restriction mode for cross-workspace access. + RestrictionMode IngressNetworkPolicy_CrossWorkspaceAccess_RestrictionMode `json:"restriction_mode,omitempty"` +} + +// An ingress rule is enforced when a request satisfies all specified attributes +// — including request origin, destination, and authentication.. +type IngressNetworkPolicy_CrossWorkspaceIngressRule struct { + // The authenticated identity the request must match. When unset, the rule + // matches all users and service principals. + Authentication *IngressNetworkPolicy_Authentication `json:"authentication,omitempty"` + // The destination the request must match — the resource being accessed, for + // example the workspace UI or workspace APIs. See RequestDestination. + Destination *IngressNetworkPolicy_RequestDestination `json:"destination,omitempty"` + // The label for this ingress rule. + Label *string `json:"label,omitempty"` + // The origin the request must match — the source workspace the request comes + // from, either specific source workspaces or any source workspace in any + // account. See CrossWorkspaceRequestOrigin. + Origin *IngressNetworkPolicy_CrossWorkspaceRequestOrigin `json:"origin,omitempty"` +} + +type IngressNetworkPolicy_CrossWorkspaceRequestOrigin struct { + AllSourceWorkspaces *bool `json:"all_source_workspaces,omitempty"` + SelectedWorkspaces *IngressNetworkPolicy_WorkspaceIdList `json:"selected_workspaces,omitempty"` +} + +// A set of registered endpoints, identified by their endpoint IDs.. +type IngressNetworkPolicy_Endpoints struct { + // The IDs of the registered endpoints. Must contain at least one endpoint ID. + EndpointIds []string `json:"endpoint_ids,omitempty"` +} + +type IngressNetworkPolicy_IpRanges struct { + // We only support IPv4 and IPv4 CIDR notation for now. + IpRanges []string `json:"ip_ranges,omitempty"` +} + +type IngressNetworkPolicy_LakebaseRuntimeDestination struct { + // Must be set to true. + AllDestinations *bool `json:"all_destinations,omitempty"` +} + +// Configures how requests arriving over private connectivity, such as +// registered endpoints, are allowed or denied access.. +type IngressNetworkPolicy_PrivateAccess struct { + // Allow rules are evaluated after deny rules. A request matching any allow rule + // is allowed; a request matching no rule is denied by default. Only applies + // when restriction_mode is RESTRICTED_ACCESS. + AllowRules []IngressNetworkPolicy_PrivateIngressRule `json:"allow_rules,omitempty"` + // Deny rules are evaluated first. A request matching any deny rule is denied, + // regardless of allow rules. Only applies when restriction_mode is + // RESTRICTED_ACCESS. + DenyRules []IngressNetworkPolicy_PrivateIngressRule `json:"deny_rules,omitempty"` + // The restriction mode for private access. + RestrictionMode IngressNetworkPolicy_PrivateAccess_RestrictionMode `json:"restriction_mode,omitempty"` +} + +// An ingress rule is enforced when a request satisfies all specified attributes +// — including request origin, destination, and authentication.. +type IngressNetworkPolicy_PrivateIngressRule struct { + // The authenticated identity the request must match. When unset, the rule + // matches all users and service principals. On the account-level network + // policy, scoping to specific identities is not currently supported, so this + // field must be unset (the rule matches all users and service principals). + Authentication *IngressNetworkPolicy_Authentication `json:"authentication,omitempty"` + // The destination the request must match — the resource being accessed, for + // example the workspace UI, workspace APIs, or account-level APIs. See + // RequestDestination. + Destination *IngressNetworkPolicy_RequestDestination `json:"destination,omitempty"` + // The label for this ingress rule. + Label *string `json:"label,omitempty"` + // The origin the request must match — the private connectivity the request + // arrives through, for example a specific set of registered endpoints or any + // endpoint registered to the account. See PrivateRequestOrigin. + Origin *IngressNetworkPolicy_PrivateRequestOrigin `json:"origin,omitempty"` +} + +// The origin of a private access request, identified by the endpoint through +// which the request arrives.. +type IngressNetworkPolicy_PrivateRequestOrigin struct { + AllPrivateAccess *bool `json:"all_private_access,omitempty"` + AllRegisteredEndpoints *bool `json:"all_registered_endpoints,omitempty"` + AzureWorkspacePrivateLink *bool `json:"azure_workspace_private_link,omitempty"` + Endpoints *IngressNetworkPolicy_Endpoints `json:"endpoints,omitempty"` +} + +type IngressNetworkPolicy_PublicAccess struct { + AllowRules []IngressNetworkPolicy_PublicIngressRule `json:"allow_rules,omitempty"` + DenyRules []IngressNetworkPolicy_PublicIngressRule `json:"deny_rules,omitempty"` + RestrictionMode IngressNetworkPolicy_PublicAccess_RestrictionMode `json:"restriction_mode,omitempty"` +} + +// An ingress rule is enforced when a request satisfies all specified attributes +// — including request origin, destination, and authentication.. +type IngressNetworkPolicy_PublicIngressRule struct { + Authentication *IngressNetworkPolicy_Authentication `json:"authentication,omitempty"` + Destination *IngressNetworkPolicy_RequestDestination `json:"destination,omitempty"` + // The label for this ingress rule. + Label *string `json:"label,omitempty"` + Origin *IngressNetworkPolicy_PublicRequestOrigin `json:"origin,omitempty"` +} + +type IngressNetworkPolicy_PublicRequestOrigin struct { + AllIpRanges *bool `json:"all_ip_ranges,omitempty"` + ExcludedIpRanges *IngressNetworkPolicy_IpRanges `json:"excluded_ip_ranges,omitempty"` + IncludedIpRanges *IngressNetworkPolicy_IpRanges `json:"included_ip_ranges,omitempty"` +} + +type IngressNetworkPolicy_RequestDestination struct { + // Matches requests to account-level APIs. Can only be used in the account-level + // network policy. + AccountApi *IngressNetworkPolicy_AccountApiDestination `json:"account_api,omitempty"` + // Account DatabricksOne destination is not supported. + AccountDatabricksOne *IngressNetworkPolicy_AccountDatabricksOneDestination `json:"account_databricks_one,omitempty"` + // Matches requests to the account console UI. Can only be used in the + // account-level network policy. + AccountUi *IngressNetworkPolicy_AccountUiDestination `json:"account_ui,omitempty"` + // When true, match all destinations, no other destination fields can be set. + // When not set or false, at least one specific destination must be provided. + AllDestinations *bool `json:"all_destinations,omitempty"` + AppsRuntime *IngressNetworkPolicy_AppsRuntimeDestination `json:"apps_runtime,omitempty"` + LakebaseRuntime *IngressNetworkPolicy_LakebaseRuntimeDestination `json:"lakebase_runtime,omitempty"` + WorkspaceApi *IngressNetworkPolicy_WorkspaceApiDestination `json:"workspace_api,omitempty"` + WorkspaceUi *IngressNetworkPolicy_WorkspaceUiDestination `json:"workspace_ui,omitempty"` +} + +// Matches workspace-level Databricks API endpoints for an ingress network +// policy rule.. +type IngressNetworkPolicy_WorkspaceApiDestination struct { + // Inverse of `scopes`: matches every API scope EXCEPT those listed here ("allow + // all except"). Mutually exclusive with `scopes` — a single destination may + // set at most one of the two. + ExcludedScopes []string `json:"excluded_scopes,omitempty"` + // Qualifies the breadth of API access for the listed scopes. See + // ApiScopeQualifier. + ScopeQualifier IngressNetworkPolicy_ApiScopeQualifier `json:"scope_qualifier,omitempty"` + Scopes []string `json:"scopes,omitempty"` +} + +type IngressNetworkPolicy_WorkspaceIdList struct { + WorkspaceIds []int64 `json:"workspace_ids,omitempty"` +} + +type IngressNetworkPolicy_WorkspaceUiDestination struct { + // Must be set to true. + AllDestinations *bool `json:"all_destinations,omitempty"` +} + +// Definition of an IP Access list. +type IpAccessList struct { + // Total number of IP or CIDR values. + AddressCount *int `json:"address_count,omitempty"` + // Creation timestamp in milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // User ID of the user who created this list. + CreatedBy *int64 `json:"created_by,omitempty"` + // Specifies whether this IP access list is enabled. + Enabled *bool `json:"enabled,omitempty"` + IpAddresses []string `json:"ip_addresses,omitempty"` + // Label for the IP access list. This **cannot** be empty. + Label *string `json:"label,omitempty"` + // Universally unique identifier (UUID) of the IP access list. + ListId *string `json:"list_id,omitempty"` + ListType IpAccessListType `json:"list_type,omitempty"` + // Update timestamp in milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // User ID of the user who updated this list. + UpdatedBy *int64 `json:"updated_by,omitempty"` +} + +// IP access lists were successfully returned.. +type ListAccountIpAccessListsResponse struct { + IpAccessLists []AccountIpAccessList `json:"ip_access_lists,omitempty"` +} + +type ListEndpointsRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` + // The parent resource name of the account to list endpoints for. Format: + // `accounts/{account_id}`. + Parent *string `json:"parent,omitempty"` +} + +type ListEndpointsResponse struct { + Items []Endpoint `json:"items,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// IP access lists were successfully returned.. +type ListIpAccessListsResponse struct { + IpAccessLists []IpAccessList `json:"ip_access_lists,omitempty"` +} + +// Gets an array of private endpoint rules.. +type ListNccPrivateEndpointRulesRequest struct { + // Your account ID. You can find your account ID in your + // accounts console. + AccountId *string `json:"account_id,omitempty"` + // Your Network Connectvity Configuration ID. + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + // Pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +// The private endpoint rule list was successfully retrieved.. +type ListNccPrivateEndpointRulesResponse struct { + Items []NccPrivateEndpointRule `json:"items,omitempty"` + // A token that can be used to get the next page of results. If null, there are + // no more results to show. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListNetworkConnectivityConfigsRequest struct { + // Your account ID. You can find your account ID in your + // accounts console. + AccountId *string `json:"account_id,omitempty"` + // Pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +// The network connectivity configuration list was successfully retrieved.. +type ListNetworkConnectivityConfigsResponse struct { + Items []NetworkConnectivityConfig `json:"items,omitempty"` + // A token that can be used to get the next page of results. If null, there are + // no more results to show. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListNetworkPoliciesRequest struct { + // Your account ID. You can find your account ID in your + // accounts console. + AccountId *string `json:"account_id,omitempty"` + // Pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListNetworkPoliciesResponse struct { + // List of network policies. + Items []AccountNetworkPolicy `json:"items,omitempty"` + // A token that can be used to get the next page of results. If null, there are + // no more results to show. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Properties of the new private endpoint rule. Note that you must approve the +// endpoint in Azure portal after initialization.. +type NccPrivateEndpointRule struct { + // account ID. You can find your account ID from the Accounts + // Console. + AccountId *string `json:"account_id,omitempty"` + // The current status of this private endpoint. The private endpoint rules are + // effective only if the connection state is ESTABLISHED. Remember that you must + // approve new endpoints on your resources in the Cloud console before they take + // effect. The possible values are: - PENDING: The endpoint has been created and + // pending approval. - ESTABLISHED: The endpoint has been approved and is ready + // to use in your serverless compute resources. - REJECTED: Connection was + // rejected by the private link resource owner. - DISCONNECTED: Connection was + // removed by the private link resource owner, the private endpoint becomes + // informative and should be deleted for clean-up. - EXPIRED: If the endpoint + // was created but not approved in 14 days, it will be EXPIRED. - CREATING: The + // endpoint creation is in progress. Once successfully created, the state will + // transition to PENDING. - CREATE_FAILED: The endpoint creation failed. You can + // check the error_message field for more details. + ConnectionState NccPrivateEndpointRule_PrivateLinkConnectionState `json:"connection_state,omitempty"` + // Time in epoch milliseconds when this object was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // Whether this private endpoint is deactivated. + Deactivated *bool `json:"deactivated,omitempty"` + // Time in epoch milliseconds when this object was deactivated. + DeactivatedAt *int64 `json:"deactivated_at,omitempty"` + // Only used by private endpoints to customer-managed private endpoint services. + // + // Domain names of target private link service. When updating this field, the + // full list of target domain_names must be specified. + DomainNames []string `json:"domain_names,omitempty"` + // Update this field to activate/deactivate this private endpoint to allow + // egress access from serverless compute resources. Only honored for first-party + // services on each cloud (e.g. AWS S3). + Enabled *bool `json:"enabled,omitempty"` + // The name of the Azure private endpoint resource. + EndpointName *string `json:"endpoint_name,omitempty"` + // The full target AWS endpoint service name that connects to the destination + // resources of the private endpoint. + EndpointService *string `json:"endpoint_service,omitempty"` + ErrorMessage *string `json:"error_message,omitempty"` + GcpEndpoint *GcpEndpoint `json:"gcp_endpoint,omitempty"` + // Not used by customer-managed private endpoint services. + // + // The sub-resource type (group ID) of the target resource. Note that to connect + // to workspace root storage (root DBFS), you need two endpoints, one for blob + // and one for dfs. + GroupId *string `json:"group_id,omitempty"` + // The ID of a network connectivity configuration, which is the parent resource + // of this private endpoint rule object. + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + // The Azure resource ID of the target resource. + ResourceId *string `json:"resource_id,omitempty"` + // Only used by private endpoints towards AWS S3 service. + // + // The globally unique S3 bucket names that will be accessed via the VPC + // endpoint. The bucket names must be in the same region as the NCC/endpoint + // service. When updating this field, we perform full update on this field. + // Please ensure a full list of desired resource_names is provided. + ResourceNames []string `json:"resource_names,omitempty"` + // The ID of a private endpoint rule. + RuleId *string `json:"rule_id,omitempty"` + // Time in epoch milliseconds when this object was updated. + UpdatedTime *int64 `json:"updated_time,omitempty"` + // The AWS VPC endpoint ID. You can use this ID to identify the VPC endpoint + // created by . + VpcEndpointId *string `json:"vpc_endpoint_id,omitempty"` +} + +type Network struct { + // The account ID associated with this network configuration. + AccountId *string `json:"account_id,omitempty"` + // Time in epoch milliseconds when the network was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // Array of error messages about the network configuration. + ErrorMessages []NetworkHealth `json:"error_messages,omitempty"` + GcpNetworkInfo *GcpNetworkInfo `json:"gcp_network_info,omitempty"` + // The network configuration ID. + NetworkId *string `json:"network_id,omitempty"` + // The human-readable name of the network configuration. + NetworkName *string `json:"network_name,omitempty"` + // IDs of one to five security groups associated with this network. Security + // group IDs **cannot** be used in multiple network configurations. + SecurityGroupIds []string `json:"security_group_ids,omitempty"` + // IDs of at least two subnets associated with this network. Subnet IDs + // **cannot** be used in multiple network configurations. + SubnetIds []string `json:"subnet_ids,omitempty"` + VpcEndpoints *NetworkVpcEndpoints `json:"vpc_endpoints,omitempty"` + // The ID of the VPC associated with this network configuration. VPC IDs can be + // used in multiple networks. + VpcId *string `json:"vpc_id,omitempty"` + VpcStatus VpcStatus `json:"vpc_status,omitempty"` + // Array of warning messages about the network configuration. + WarningMessages []NetworkWarning `json:"warning_messages,omitempty"` + // Workspace ID associated with this network configuration. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +// Properties of the new network connectivity configuration.. +type NetworkConnectivityConfig struct { + // Your account ID. You can find your account ID in your + // accounts console. + AccountId *string `json:"account_id,omitempty"` + // Time in epoch milliseconds when this object was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // The network connectivity rules that apply to network traffic from your + // serverless compute resources. + EgressConfig *CustomerFacingNetworkConnectivityConfigEgressConfig `json:"egress_config,omitempty"` + // The name of the network connectivity configuration. The name can contain + // alphanumeric characters, hyphens, and underscores. The length must be between + // 3 and 30 characters. The name must match the regular expression + // ^[0-9a-zA-Z-_]{3,30}$ + Name *string `json:"name,omitempty"` + // network connectivity configuration ID. + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + // The region for the network connectivity configuration. Only workspaces in the + // same region can be attached to the network connectivity configuration. + Region *string `json:"region,omitempty"` + // Time in epoch milliseconds when this object was updated. + UpdatedTime *int64 `json:"updated_time,omitempty"` +} + +// Properties of the new private endpoint rule. Note that for private endpoints +// towards a VPC endpoint service behind a customer-managed NLB, you must +// approve the endpoint in AWS console after initialization.. +type NetworkConnectivityConfigAwsPrivateEndpointRule struct { + // account ID. You can find your account ID from the Accounts + // Console. + AccountId *string `json:"account_id,omitempty"` + // The current status of this private endpoint. The private endpoint rules are + // effective only if the connection state is ESTABLISHED. Remember that you must + // approve new endpoints on your resources in the AWS console before they take + // effect. The possible values are: - PENDING: The endpoint has been created and + // pending approval. - ESTABLISHED: The endpoint has been approved and is ready + // to use in your serverless compute resources. - REJECTED: Connection was + // rejected by the private link resource owner. - DISCONNECTED: Connection was + // removed by the private link resource owner, the private endpoint becomes + // informative and should be deleted for clean-up. - EXPIRED: If the endpoint is + // created but not approved in 14 days, it is EXPIRED. + ConnectionState NetworkConnectivityConfigAwsPrivateEndpointRule_PrivateLinkConnectionState `json:"connection_state,omitempty"` + // Time in epoch milliseconds when this object was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // Whether this private endpoint is deactivated. + Deactivated *bool `json:"deactivated,omitempty"` + // Time in epoch milliseconds when this object was deactivated. + DeactivatedAt *int64 `json:"deactivated_at,omitempty"` + // Only used by private endpoints towards a VPC endpoint service for + // customer-managed VPC endpoint service. + // + // The target AWS resource FQDNs accessible via the VPC endpoint service. When + // updating this field, we perform full update on this field. Please ensure a + // full list of desired domain_names is provided. + DomainNames []string `json:"domain_names,omitempty"` + // Only used by private endpoints towards an AWS S3 service. + // + // Update this field to activate/deactivate this private endpoint to allow + // egress access from serverless compute resources. + Enabled *bool `json:"enabled,omitempty"` + // The full target AWS endpoint service name that connects to the destination + // resources of the private endpoint. + EndpointService *string `json:"endpoint_service,omitempty"` + ErrorMessage *string `json:"error_message,omitempty"` + // The ID of a network connectivity configuration, which is the parent resource + // of this private endpoint rule object. + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + // Only used by private endpoints towards AWS S3 service. + // + // The globally unique S3 bucket names that will be accessed via the VPC + // endpoint. The bucket names must be in the same region as the NCC/endpoint + // service. When updating this field, we perform full update on this field. + // Please ensure a full list of desired resource_names is provided. + ResourceNames []string `json:"resource_names,omitempty"` + // The ID of a private endpoint rule. + RuleId *string `json:"rule_id,omitempty"` + // Time in epoch milliseconds when this object was updated. + UpdatedTime *int64 `json:"updated_time,omitempty"` + // The AWS VPC endpoint ID. You can use this ID to identify VPC endpoint created + // by . + VpcEndpointId *string `json:"vpc_endpoint_id,omitempty"` +} + +// Properties of the new private endpoint rule. Note that you must approve the +// endpoint in Azure portal after initialization.. +type NetworkConnectivityConfigAzurePrivateEndpointRule struct { + // The current status of this private endpoint. The private endpoint rules are + // effective only if the connection state is ESTABLISHED. Remember that you must + // approve new endpoints on your resources in the Azure portal before they take + // effect. The possible values are: - INIT: (deprecated) The endpoint has been + // created and pending approval. - PENDING: The endpoint has been created and + // pending approval. - ESTABLISHED: The endpoint has been approved and is ready + // to use in your serverless compute resources. - REJECTED: Connection was + // rejected by the private link resource owner. - DISCONNECTED: Connection was + // removed by the private link resource owner, the private endpoint becomes + // informative and should be deleted for clean-up. - EXPIRED: If the endpoint + // was created but not approved in 14 days, it will be EXPIRED. + ConnectionState NetworkConnectivityConfigAzurePrivateEndpointRule_PrivateLinkConnectionState `json:"connection_state,omitempty"` + // Time in epoch milliseconds when this object was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // Whether this private endpoint is deactivated. + Deactivated *bool `json:"deactivated,omitempty"` + // Time in epoch milliseconds when this object was deactivated. + DeactivatedAt *int64 `json:"deactivated_at,omitempty"` + // Not used by customer-managed private endpoint services. + // + // Domain names of target private link service. When updating this field, the + // full list of target domain_names must be specified. + DomainNames []string `json:"domain_names,omitempty"` + // The name of the Azure private endpoint resource. + EndpointName *string `json:"endpoint_name,omitempty"` + ErrorMessage *string `json:"error_message,omitempty"` + // Only used by private endpoints to Azure first-party services. + // + // The sub-resource type (group ID) of the target resource. Note that to connect + // to workspace root storage (root DBFS), you need two endpoints, one for blob + // and one for dfs. + GroupId *string `json:"group_id,omitempty"` + // The ID of a network connectivity configuration, which is the parent resource + // of this private endpoint rule object. + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + // The Azure resource ID of the target resource. + ResourceId *string `json:"resource_id,omitempty"` + // The ID of a private endpoint rule. + RuleId *string `json:"rule_id,omitempty"` + // Time in epoch milliseconds when this object was updated. + UpdatedTime *int64 `json:"updated_time,omitempty"` +} + +// Default rules don't have specific targets.. +type NetworkConnectivityConfigEgressConfig_DefaultRule struct { + AwsStableIpRule *NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRule `json:"aws_stable_ip_rule,omitempty"` + AzureServiceEndpointRule *NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRule `json:"azure_service_endpoint_rule,omitempty"` +} + +// The stable AWS IP CIDR blocks. You can use these to configure the firewall of +// your resources to allow traffic from your workspace.. +type NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRule struct { + // The list of stable IP CIDR blocks from which network traffic + // originates when accessing your resources. + CidrBlocks []string `json:"cidr_blocks,omitempty"` +} + +// The stable Azure service endpoints. You can configure the firewall of your +// Azure resources to allow traffic from your serverless compute +// resources.. +type NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRule struct { + // The list of subnets from which network traffic originates when + // accessing your Azure resources. + Subnets []string `json:"subnets,omitempty"` + // The Azure region in which this service endpoint rule applies.. + TargetRegion *string `json:"target_region,omitempty"` + // The Azure services to which this service endpoint rule applies to. + TargetServices []EgressResourceType `json:"target_services,omitempty"` +} + +type NetworkHealth struct { + // Details of the error. + ErrorMessage *string `json:"error_message,omitempty"` + ErrorType *string `json:"error_type,omitempty"` +} + +type NetworkVpcEndpoints struct { + // The VPC endpoint ID used by this network to access the secure + // cluster connectivity relay. + DataplaneRelay []string `json:"dataplane_relay,omitempty"` + // The VPC endpoint ID used by this network to access the Databricks REST API. + RestApi []string `json:"rest_api,omitempty"` +} + +type NetworkWarning struct { + // Details of the warning. + WarningMessage *string `json:"warning_message,omitempty"` + WarningType *string `json:"warning_type,omitempty"` +} + +// *. +type PrivateAccessSettings struct { + // The account ID that hosts the private access settings. + AccountId *string `json:"account_id,omitempty"` + // An array of Databricks VPC endpoint IDs. This is the ID that is + // returned when registering the VPC endpoint configuration in your + // account. This is not the ID of the VPC endpoint in AWS. Only used when + // private_access_level is set to ENDPOINT. This is an allow list of VPC + // endpoints that in your account that can connect to your workspace over AWS + // PrivateLink. If hybrid access to your workspace is enabled by setting + // public_access_enabled to true, this control only works for PrivateLink + // connections. To control how your workspace is accessed via public internet, + // see IP access lists. + AllowedVpcEndpointIds []string `json:"allowed_vpc_endpoint_ids,omitempty"` + // The private access level controls which VPC endpoints can connect to the UI + // or API of any workspace that attaches this private access settings object. + // `ACCOUNT` level access (the default) allows only VPC endpoints that are + // registered in your account connect to your workspace. `ENDPOINT` + // level access allows only specified VPC endpoints connect to your workspace. + // For details, see allowed_vpc_endpoint_ids. + PrivateAccessLevel PrivateAccessLevel `json:"private_access_level,omitempty"` + // private access settings ID. + PrivateAccessSettingsId *string `json:"private_access_settings_id,omitempty"` + // The human-readable name of the private access settings object. + PrivateAccessSettingsName *string `json:"private_access_settings_name,omitempty"` + // Determines if the workspace can be accessed over public internet. For fully + // private workspaces, you can optionally specify false, but only if you + // implement both the front-end and the back-end PrivateLink connections. + // Otherwise, specify true, which means that public access is enabled. + PublicAccessEnabled *bool `json:"public_access_enabled,omitempty"` + // The AWS region for workspaces attached to this private access settings + // object. + Region *string `json:"region,omitempty"` +} + +// Details required to replace an IP access list.. +type ReplaceAccountIpAccessListRequest struct { + AccountId *string `json:"account_id,omitempty"` + // Specifies whether this IP access list is enabled. + Enabled *bool `json:"enabled,omitempty"` + IpAddresses []string `json:"ip_addresses,omitempty"` + // Label for the IP access list. This **cannot** be empty. + Label *string `json:"label,omitempty"` + // The ID for the corresponding IP access list + ListId *string `json:"list_id,omitempty"` + ListType AccountIpAccessListType_IpAccessListType `json:"list_type,omitempty"` +} + +// The IP access list was successfully replaced.. +type ReplaceAccountIpAccessListResponse struct { + IpAccessList *AccountIpAccessList `json:"ip_access_list,omitempty"` +} + +// Details required to replace an IP access list.. +type ReplaceIpAccessListRequest struct { + // Specifies whether this IP access list is enabled. + Enabled *bool `json:"enabled,omitempty"` + IpAddresses []string `json:"ip_addresses,omitempty"` + // Label for the IP access list. This **cannot** be empty. + Label *string `json:"label,omitempty"` + // The ID for the corresponding IP access list + ListId *string `json:"list_id,omitempty"` + ListType IpAccessListType `json:"list_type,omitempty"` +} + +// The IP access list was successfully replaced.. +type ReplaceIpAccessListResponse struct { + IpAccessList *IpAccessList `json:"ip_access_list,omitempty"` +} + +// Details required to update an IP access list.. +type UpdateAccountIpAccessListRequest struct { + AccountId *string `json:"account_id,omitempty"` + // Specifies whether this IP access list is enabled. + Enabled *bool `json:"enabled,omitempty"` + IpAddresses []string `json:"ip_addresses,omitempty"` + // Label for the IP access list. This **cannot** be empty. + Label *string `json:"label,omitempty"` + // The ID for the corresponding IP access list + ListId *string `json:"list_id,omitempty"` + ListType AccountIpAccessListType_IpAccessListType `json:"list_type,omitempty"` +} + +// The IP access list was successfully updated.. +type UpdateAccountIpAccessListResponse struct { + IpAccessList *AccountIpAccessList `json:"ip_access_list,omitempty"` +} + +// Details required to update an IP access list.. +type UpdateIpAccessListRequest struct { + // Specifies whether this IP access list is enabled. + Enabled *bool `json:"enabled,omitempty"` + IpAddresses []string `json:"ip_addresses,omitempty"` + // Label for the IP access list. This **cannot** be empty. + Label *string `json:"label,omitempty"` + // The ID for the corresponding IP access list + ListId *string `json:"list_id,omitempty"` + ListType IpAccessListType `json:"list_type,omitempty"` +} + +// The IP access list was successfully updated.. +type UpdateIpAccessListResponse struct { + IpAccessList *IpAccessList `json:"ip_access_list,omitempty"` +} + +// Your Network Connectivity Configuration ID.. +type UpdateNccPrivateEndpointRuleRequest struct { + // Your account ID. You can find your account ID in your + // accounts console. + AccountId *string `json:"account_id,omitempty"` + // The ID of a network connectivity configuration, which is the parent resource + // of this private endpoint rule object. + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + PrivateEndpointRule *UpdatePrivateEndpointRule `json:"private_endpoint_rule,omitempty"` + // Your private endpoint rule ID. + PrivateEndpointRuleId *string `json:"private_endpoint_rule_id,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateNetworkPolicyRequest struct { + // Your account ID. You can find your account ID in your + // accounts console. + AccountId *string `json:"account_id,omitempty"` + // Updated network policy configuration details. + NetworkPolicy *AccountNetworkPolicy `json:"network_policy,omitempty"` + // The unique identifier for the network policy. + NetworkPolicyId *string `json:"network_policy_id,omitempty"` +} + +type UpdatePrivateAccessSettingsRequest struct { + // Properties of the new private access settings object. + CustomerFacingPrivateAccessSettings *PrivateAccessSettings `json:"customer_facing_private_access_settings,omitempty"` +} + +// Properties of the new private endpoint rule. Note that you must approve the +// endpoint in Azure portal after initialization.. +type UpdatePrivateEndpointRule struct { + // account ID. You can find your account ID from the Accounts + // Console. + AccountId *string `json:"account_id,omitempty"` + // The current status of this private endpoint. The private endpoint rules are + // effective only if the connection state is ESTABLISHED. Remember that you must + // approve new endpoints on your resources in the Cloud console before they take + // effect. The possible values are: - PENDING: The endpoint has been created and + // pending approval. - ESTABLISHED: The endpoint has been approved and is ready + // to use in your serverless compute resources. - REJECTED: Connection was + // rejected by the private link resource owner. - DISCONNECTED: Connection was + // removed by the private link resource owner, the private endpoint becomes + // informative and should be deleted for clean-up. - EXPIRED: If the endpoint + // was created but not approved in 14 days, it will be EXPIRED. - CREATING: The + // endpoint creation is in progress. Once successfully created, the state will + // transition to PENDING. - CREATE_FAILED: The endpoint creation failed. You can + // check the error_message field for more details. + ConnectionState NccPrivateEndpointRule_PrivateLinkConnectionState `json:"connection_state,omitempty"` + // Time in epoch milliseconds when this object was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // Whether this private endpoint is deactivated. + Deactivated *bool `json:"deactivated,omitempty"` + // Time in epoch milliseconds when this object was deactivated. + DeactivatedAt *int64 `json:"deactivated_at,omitempty"` + // Only used by private endpoints to customer-managed private endpoint services. + // + // Domain names of target private link service. When updating this field, the + // full list of target domain_names must be specified. + DomainNames []string `json:"domain_names,omitempty"` + // Update this field to activate/deactivate this private endpoint to allow + // egress access from serverless compute resources. Only honored for first-party + // services on each cloud (e.g. AWS S3). + Enabled *bool `json:"enabled,omitempty"` + // The name of the Azure private endpoint resource. + EndpointName *string `json:"endpoint_name,omitempty"` + // The full target AWS endpoint service name that connects to the destination + // resources of the private endpoint. + EndpointService *string `json:"endpoint_service,omitempty"` + ErrorMessage *string `json:"error_message,omitempty"` + GcpEndpoint *GcpEndpoint `json:"gcp_endpoint,omitempty"` + // Not used by customer-managed private endpoint services. + // + // The sub-resource type (group ID) of the target resource. Note that to connect + // to workspace root storage (root DBFS), you need two endpoints, one for blob + // and one for dfs. + GroupId *string `json:"group_id,omitempty"` + // The ID of a network connectivity configuration, which is the parent resource + // of this private endpoint rule object. + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + // The Azure resource ID of the target resource. + ResourceId *string `json:"resource_id,omitempty"` + // Only used by private endpoints towards AWS S3 service. + // + // The globally unique S3 bucket names that will be accessed via the VPC + // endpoint. The bucket names must be in the same region as the NCC/endpoint + // service. When updating this field, we perform full update on this field. + // Please ensure a full list of desired resource_names is provided. + ResourceNames []string `json:"resource_names,omitempty"` + // The ID of a private endpoint rule. + RuleId *string `json:"rule_id,omitempty"` + // Time in epoch milliseconds when this object was updated. + UpdatedTime *int64 `json:"updated_time,omitempty"` + // The AWS VPC endpoint ID. You can use this ID to identify the VPC endpoint + // created by . + VpcEndpointId *string `json:"vpc_endpoint_id,omitempty"` +} + +type UpdateWorkspaceNetworkOptionRequest struct { + // Your account ID. You can find your account ID in your + // accounts console. + AccountId *string `json:"account_id,omitempty"` + // The workspace ID. + WorkspaceId *int64 `json:"workspace_id,omitempty"` + // The network option details for the workspace. + WorkspaceNetworkOption *WorkspaceNetworkOption `json:"workspace_network_option,omitempty"` +} + +// *. +type VpcEndpoint struct { + // The account ID that hosts the VPC endpoint configuration. + AccountId *string `json:"account_id,omitempty"` + // The AWS Account in which the VPC endpoint object exists. + AwsAccountId *string `json:"aws_account_id,omitempty"` + // The ID of the [endpoint service] that this VPC endpoint is + // connected to. For a list of endpoint service IDs for each supported AWS + // region, see the [Databricks PrivateLink documentation]. + // + // [Databricks PrivateLink documentation]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html + // [endpoint service]: https://docs.aws.amazon.com/vpc/latest/privatelink/endpoint-service.html + AwsEndpointServiceId *string `json:"aws_endpoint_service_id,omitempty"` + // The ID of the VPC endpoint object in AWS. + AwsVpcEndpointId *string `json:"aws_vpc_endpoint_id,omitempty"` + GcpVpcEndpointInfo *GcpVpcEndpointInfo `json:"gcp_vpc_endpoint_info,omitempty"` + // The AWS region in which this VPC endpoint object exists. + Region *string `json:"region,omitempty"` + // The current state (such as `available` or `rejected`) of the VPC endpoint. + // Derived from AWS. For the full set of values, see [AWS DescribeVpcEndpoint + // documentation]. + // + // [AWS DescribeVpcEndpoint documentation]: https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-vpc-endpoints.html + State *string `json:"state,omitempty"` + // This enumeration represents the type of Databricks VPC endpoint service that + // was used when creating this VPC endpoint. If the VPC endpoint connects to the + // control plane for either the front-end connection or the + // back-end REST API connection, the value is GENERAL_ACCESS. If the VPC + // endpoint connects to the workspace for the back-end secure + // cluster connectivity relay, the value is DATAPLANE_RELAY_ACCESS. + UseCase VpcEndpointUseCase `json:"use_case,omitempty"` + // Databricks VPC endpoint ID. This is the -specific name of the VPC + // endpoint. Do not confuse this with the `aws_vpc_endpoint_id`, which is the ID + // within AWS of the VPC endpoint. + VpcEndpointId *string `json:"vpc_endpoint_id,omitempty"` + // The human-readable name of the storage configuration. + VpcEndpointName *string `json:"vpc_endpoint_name,omitempty"` +} + +type WorkspaceNetworkOption struct { + // The network policy ID to apply to the workspace. This controls the network + // access rules for all serverless compute resources in the workspace. Each + // workspace can only be linked to one policy at a time. If no policy is + // explicitly assigned, the workspace will use 'default-policy'. + NetworkPolicyId *string `json:"network_policy_id,omitempty"` + // The workspace ID. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +// AccountIpAccessListToSDK converts the mirror to the sdk-go type. +func AccountIpAccessListToSDK(w *AccountIpAccessList) (*sdk.AccountIpAccessList, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountIpAccessList{} + out.ListId = w.ListId + out.Label = w.Label + out.IpAddresses = w.IpAddresses + out.AddressCount = w.AddressCount + out.ListType = w.ListType + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.Enabled = w.Enabled + return out, nil +} + +// AccountIpAccessListFromSDK converts the sdk-go type to the mirror. +func AccountIpAccessListFromSDK(v *sdk.AccountIpAccessList) (*AccountIpAccessList, error) { + if v == nil { + return nil, nil + } + out := &AccountIpAccessList{} + out.ListId = v.ListId + out.Label = v.Label + out.IpAddresses = v.IpAddresses + out.AddressCount = v.AddressCount + out.ListType = v.ListType + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.Enabled = v.Enabled + return out, nil +} + +// AccountNetworkPolicyToSDK converts the mirror to the sdk-go type. +func AccountNetworkPolicyToSDK(w *AccountNetworkPolicy) (*sdk.AccountNetworkPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountNetworkPolicy{} + out.NetworkPolicyId = w.NetworkPolicyId + out.AccountId = w.AccountId + conv1, err := EgressNetworkPolicyToSDK(w.Egress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountNetworkPolicy.Egress", err) + } + out.Egress = conv1 + conv2, err := IngressNetworkPolicyToSDK(w.Ingress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountNetworkPolicy.Ingress", err) + } + out.Ingress = conv2 + conv3, err := IngressNetworkPolicyToSDK(w.IngressDryRun) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountNetworkPolicy.IngressDryRun", err) + } + out.IngressDryRun = conv3 + return out, nil +} + +// AccountNetworkPolicyFromSDK converts the sdk-go type to the mirror. +func AccountNetworkPolicyFromSDK(v *sdk.AccountNetworkPolicy) (*AccountNetworkPolicy, error) { + if v == nil { + return nil, nil + } + out := &AccountNetworkPolicy{} + out.NetworkPolicyId = v.NetworkPolicyId + out.AccountId = v.AccountId + conv4, err := EgressNetworkPolicyFromSDK(v.Egress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountNetworkPolicy.Egress", err) + } + out.Egress = conv4 + conv5, err := IngressNetworkPolicyFromSDK(v.Ingress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountNetworkPolicy.Ingress", err) + } + out.Ingress = conv5 + conv6, err := IngressNetworkPolicyFromSDK(v.IngressDryRun) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountNetworkPolicy.IngressDryRun", err) + } + out.IngressDryRun = conv6 + return out, nil +} + +// AwsVpcEndpointInfoToSDK converts the mirror to the sdk-go type. +func AwsVpcEndpointInfoToSDK(w *AwsVpcEndpointInfo) (*sdk.AwsVpcEndpointInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.AwsVpcEndpointInfo{} + out.AwsVpcEndpointId = w.AwsVpcEndpointId + out.AwsEndpointServiceId = w.AwsEndpointServiceId + out.AwsAccountId = w.AwsAccountId + return out, nil +} + +// AwsVpcEndpointInfoFromSDK converts the sdk-go type to the mirror. +func AwsVpcEndpointInfoFromSDK(v *sdk.AwsVpcEndpointInfo) (*AwsVpcEndpointInfo, error) { + if v == nil { + return nil, nil + } + out := &AwsVpcEndpointInfo{} + out.AwsVpcEndpointId = v.AwsVpcEndpointId + out.AwsEndpointServiceId = v.AwsEndpointServiceId + out.AwsAccountId = v.AwsAccountId + return out, nil +} + +// AzurePrivateEndpointInfoToSDK converts the mirror to the sdk-go type. +func AzurePrivateEndpointInfoToSDK(w *AzurePrivateEndpointInfo) (*sdk.AzurePrivateEndpointInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.AzurePrivateEndpointInfo{} + out.PrivateEndpointName = w.PrivateEndpointName + out.PrivateEndpointResourceGuid = w.PrivateEndpointResourceGuid + out.PrivateEndpointResourceId = w.PrivateEndpointResourceId + out.PrivateLinkServiceId = w.PrivateLinkServiceId + return out, nil +} + +// AzurePrivateEndpointInfoFromSDK converts the sdk-go type to the mirror. +func AzurePrivateEndpointInfoFromSDK(v *sdk.AzurePrivateEndpointInfo) (*AzurePrivateEndpointInfo, error) { + if v == nil { + return nil, nil + } + out := &AzurePrivateEndpointInfo{} + out.PrivateEndpointName = v.PrivateEndpointName + out.PrivateEndpointResourceGuid = v.PrivateEndpointResourceGuid + out.PrivateEndpointResourceId = v.PrivateEndpointResourceId + out.PrivateLinkServiceId = v.PrivateLinkServiceId + return out, nil +} + +// CreateAccountIpAccessListRequestToSDK converts the mirror to the sdk-go type. +func CreateAccountIpAccessListRequestToSDK(w *CreateAccountIpAccessListRequest) (*sdk.CreateAccountIpAccessListRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAccountIpAccessListRequest{} + out.AccountId = w.AccountId + out.Label = w.Label + out.ListType = w.ListType + out.IpAddresses = w.IpAddresses + return out, nil +} + +// CreateAccountIpAccessListRequestFromSDK converts the sdk-go type to the mirror. +func CreateAccountIpAccessListRequestFromSDK(v *sdk.CreateAccountIpAccessListRequest) (*CreateAccountIpAccessListRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateAccountIpAccessListRequest{} + out.AccountId = v.AccountId + out.Label = v.Label + out.ListType = v.ListType + out.IpAddresses = v.IpAddresses + return out, nil +} + +// CreateAccountIpAccessListResponseToSDK converts the mirror to the sdk-go type. +func CreateAccountIpAccessListResponseToSDK(w *CreateAccountIpAccessListResponse) (*sdk.CreateAccountIpAccessListResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAccountIpAccessListResponse{} + conv7, err := AccountIpAccessListToSDK(w.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv7 + return out, nil +} + +// CreateAccountIpAccessListResponseFromSDK converts the sdk-go type to the mirror. +func CreateAccountIpAccessListResponseFromSDK(v *sdk.CreateAccountIpAccessListResponse) (*CreateAccountIpAccessListResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateAccountIpAccessListResponse{} + conv8, err := AccountIpAccessListFromSDK(v.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv8 + return out, nil +} + +// CreateEndpointRequestToSDK converts the mirror to the sdk-go type. +func CreateEndpointRequestToSDK(w *CreateEndpointRequest) (*sdk.CreateEndpointRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateEndpointRequest{} + out.Parent = w.Parent + conv9, err := EndpointToSDK(w.Endpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateEndpointRequest.Endpoint", err) + } + out.Endpoint = conv9 + return out, nil +} + +// CreateEndpointRequestFromSDK converts the sdk-go type to the mirror. +func CreateEndpointRequestFromSDK(v *sdk.CreateEndpointRequest) (*CreateEndpointRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateEndpointRequest{} + out.Parent = v.Parent + conv10, err := EndpointFromSDK(v.Endpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateEndpointRequest.Endpoint", err) + } + out.Endpoint = conv10 + return out, nil +} + +// CreateIpAccessListRequestToSDK converts the mirror to the sdk-go type. +func CreateIpAccessListRequestToSDK(w *CreateIpAccessListRequest) (*sdk.CreateIpAccessListRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateIpAccessListRequest{} + out.Label = w.Label + out.ListType = w.ListType + out.IpAddresses = w.IpAddresses + return out, nil +} + +// CreateIpAccessListRequestFromSDK converts the sdk-go type to the mirror. +func CreateIpAccessListRequestFromSDK(v *sdk.CreateIpAccessListRequest) (*CreateIpAccessListRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateIpAccessListRequest{} + out.Label = v.Label + out.ListType = v.ListType + out.IpAddresses = v.IpAddresses + return out, nil +} + +// CreateIpAccessListResponseToSDK converts the mirror to the sdk-go type. +func CreateIpAccessListResponseToSDK(w *CreateIpAccessListResponse) (*sdk.CreateIpAccessListResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateIpAccessListResponse{} + conv11, err := IpAccessListToSDK(w.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv11 + return out, nil +} + +// CreateIpAccessListResponseFromSDK converts the sdk-go type to the mirror. +func CreateIpAccessListResponseFromSDK(v *sdk.CreateIpAccessListResponse) (*CreateIpAccessListResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateIpAccessListResponse{} + conv12, err := IpAccessListFromSDK(v.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv12 + return out, nil +} + +// CreateNccPrivateEndpointRuleRequestToSDK converts the mirror to the sdk-go type. +func CreateNccPrivateEndpointRuleRequestToSDK(w *CreateNccPrivateEndpointRuleRequest) (*sdk.CreateNccPrivateEndpointRuleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateNccPrivateEndpointRuleRequest{} + out.NetworkConnectivityConfigId = w.NetworkConnectivityConfigId + out.AccountId = w.AccountId + conv13, err := CreatePrivateEndpointRuleToSDK(w.PrivateEndpointRule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNccPrivateEndpointRuleRequest.PrivateEndpointRule", err) + } + out.PrivateEndpointRule = conv13 + return out, nil +} + +// CreateNccPrivateEndpointRuleRequestFromSDK converts the sdk-go type to the mirror. +func CreateNccPrivateEndpointRuleRequestFromSDK(v *sdk.CreateNccPrivateEndpointRuleRequest) (*CreateNccPrivateEndpointRuleRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateNccPrivateEndpointRuleRequest{} + out.NetworkConnectivityConfigId = v.NetworkConnectivityConfigId + out.AccountId = v.AccountId + conv14, err := CreatePrivateEndpointRuleFromSDK(v.PrivateEndpointRule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNccPrivateEndpointRuleRequest.PrivateEndpointRule", err) + } + out.PrivateEndpointRule = conv14 + return out, nil +} + +// CreateNetworkConnectivityConfigRequestToSDK converts the mirror to the sdk-go type. +func CreateNetworkConnectivityConfigRequestToSDK(w *CreateNetworkConnectivityConfigRequest) (*sdk.CreateNetworkConnectivityConfigRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateNetworkConnectivityConfigRequest{} + out.AccountId = w.AccountId + conv15, err := CreateNetworkConnectivityConfigurationToSDK(w.NetworkConnectivityConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNetworkConnectivityConfigRequest.NetworkConnectivityConfig", err) + } + out.NetworkConnectivityConfig = conv15 + return out, nil +} + +// CreateNetworkConnectivityConfigRequestFromSDK converts the sdk-go type to the mirror. +func CreateNetworkConnectivityConfigRequestFromSDK(v *sdk.CreateNetworkConnectivityConfigRequest) (*CreateNetworkConnectivityConfigRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateNetworkConnectivityConfigRequest{} + out.AccountId = v.AccountId + conv16, err := CreateNetworkConnectivityConfigurationFromSDK(v.NetworkConnectivityConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNetworkConnectivityConfigRequest.NetworkConnectivityConfig", err) + } + out.NetworkConnectivityConfig = conv16 + return out, nil +} + +// CreateNetworkConnectivityConfigurationToSDK converts the mirror to the sdk-go type. +func CreateNetworkConnectivityConfigurationToSDK(w *CreateNetworkConnectivityConfiguration) (*sdk.CreateNetworkConnectivityConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateNetworkConnectivityConfiguration{} + out.NetworkConnectivityConfigId = w.NetworkConnectivityConfigId + out.AccountId = w.AccountId + out.Name = w.Name + out.Region = w.Region + conv17, err := CustomerFacingNetworkConnectivityConfigEgressConfigToSDK(w.EgressConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNetworkConnectivityConfiguration.EgressConfig", err) + } + out.EgressConfig = conv17 + out.UpdatedTime = w.UpdatedTime + out.CreationTime = w.CreationTime + return out, nil +} + +// CreateNetworkConnectivityConfigurationFromSDK converts the sdk-go type to the mirror. +func CreateNetworkConnectivityConfigurationFromSDK(v *sdk.CreateNetworkConnectivityConfiguration) (*CreateNetworkConnectivityConfiguration, error) { + if v == nil { + return nil, nil + } + out := &CreateNetworkConnectivityConfiguration{} + out.NetworkConnectivityConfigId = v.NetworkConnectivityConfigId + out.AccountId = v.AccountId + out.Name = v.Name + out.Region = v.Region + conv18, err := CustomerFacingNetworkConnectivityConfigEgressConfigFromSDK(v.EgressConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNetworkConnectivityConfiguration.EgressConfig", err) + } + out.EgressConfig = conv18 + out.UpdatedTime = v.UpdatedTime + out.CreationTime = v.CreationTime + return out, nil +} + +// CreateNetworkPolicyRequestToSDK converts the mirror to the sdk-go type. +func CreateNetworkPolicyRequestToSDK(w *CreateNetworkPolicyRequest) (*sdk.CreateNetworkPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateNetworkPolicyRequest{} + out.AccountId = w.AccountId + conv19, err := AccountNetworkPolicyToSDK(w.NetworkPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNetworkPolicyRequest.NetworkPolicy", err) + } + out.NetworkPolicy = conv19 + return out, nil +} + +// CreateNetworkPolicyRequestFromSDK converts the sdk-go type to the mirror. +func CreateNetworkPolicyRequestFromSDK(v *sdk.CreateNetworkPolicyRequest) (*CreateNetworkPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateNetworkPolicyRequest{} + out.AccountId = v.AccountId + conv20, err := AccountNetworkPolicyFromSDK(v.NetworkPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNetworkPolicyRequest.NetworkPolicy", err) + } + out.NetworkPolicy = conv20 + return out, nil +} + +// CreateNetworkRequestToSDK converts the mirror to the sdk-go type. +func CreateNetworkRequestToSDK(w *CreateNetworkRequest) (*sdk.CreateNetworkRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateNetworkRequest{} + out.AccountId = w.AccountId + out.NetworkName = w.NetworkName + out.VpcId = w.VpcId + out.SubnetIds = w.SubnetIds + out.SecurityGroupIds = w.SecurityGroupIds + conv21, err := NetworkVpcEndpointsToSDK(w.VpcEndpoints) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNetworkRequest.VpcEndpoints", err) + } + out.VpcEndpoints = conv21 + conv22, err := GcpNetworkInfoToSDK(w.GcpNetworkInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNetworkRequest.GcpNetworkInfo", err) + } + out.GcpNetworkInfo = conv22 + return out, nil +} + +// CreateNetworkRequestFromSDK converts the sdk-go type to the mirror. +func CreateNetworkRequestFromSDK(v *sdk.CreateNetworkRequest) (*CreateNetworkRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateNetworkRequest{} + out.AccountId = v.AccountId + out.NetworkName = v.NetworkName + out.VpcId = v.VpcId + out.SubnetIds = v.SubnetIds + out.SecurityGroupIds = v.SecurityGroupIds + conv23, err := NetworkVpcEndpointsFromSDK(v.VpcEndpoints) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNetworkRequest.VpcEndpoints", err) + } + out.VpcEndpoints = conv23 + conv24, err := GcpNetworkInfoFromSDK(v.GcpNetworkInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNetworkRequest.GcpNetworkInfo", err) + } + out.GcpNetworkInfo = conv24 + return out, nil +} + +// CreatePrivateAccessSettingsRequestToSDK converts the mirror to the sdk-go type. +func CreatePrivateAccessSettingsRequestToSDK(w *CreatePrivateAccessSettingsRequest) (*sdk.CreatePrivateAccessSettingsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreatePrivateAccessSettingsRequest{} + out.AccountId = w.AccountId + out.PrivateAccessSettingsName = w.PrivateAccessSettingsName + out.Region = w.Region + out.PublicAccessEnabled = w.PublicAccessEnabled + out.PrivateAccessLevel = w.PrivateAccessLevel + out.AllowedVpcEndpointIds = w.AllowedVpcEndpointIds + return out, nil +} + +// CreatePrivateAccessSettingsRequestFromSDK converts the sdk-go type to the mirror. +func CreatePrivateAccessSettingsRequestFromSDK(v *sdk.CreatePrivateAccessSettingsRequest) (*CreatePrivateAccessSettingsRequest, error) { + if v == nil { + return nil, nil + } + out := &CreatePrivateAccessSettingsRequest{} + out.AccountId = v.AccountId + out.PrivateAccessSettingsName = v.PrivateAccessSettingsName + out.Region = v.Region + out.PublicAccessEnabled = v.PublicAccessEnabled + out.PrivateAccessLevel = v.PrivateAccessLevel + out.AllowedVpcEndpointIds = v.AllowedVpcEndpointIds + return out, nil +} + +// CreatePrivateEndpointRuleToSDK converts the mirror to the sdk-go type. +func CreatePrivateEndpointRuleToSDK(w *CreatePrivateEndpointRule) (*sdk.CreatePrivateEndpointRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreatePrivateEndpointRule{} + out.RuleId = w.RuleId + out.NetworkConnectivityConfigId = w.NetworkConnectivityConfigId + out.ConnectionState = w.ConnectionState + out.DomainNames = w.DomainNames + out.CreationTime = w.CreationTime + out.UpdatedTime = w.UpdatedTime + out.Deactivated = w.Deactivated + out.DeactivatedAt = w.DeactivatedAt + out.ErrorMessage = w.ErrorMessage + out.ResourceId = w.ResourceId + out.GroupId = w.GroupId + out.EndpointName = w.EndpointName + out.AccountId = w.AccountId + out.EndpointService = w.EndpointService + out.ResourceNames = w.ResourceNames + out.VpcEndpointId = w.VpcEndpointId + out.Enabled = w.Enabled + { + var members []string + if w.GcpEndpoint != nil { + members = append(members, "gcp_endpoint") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.GcpEndpoint != nil: + conv25, err := GcpEndpointToSDK(w.GcpEndpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePrivateEndpointRule.Endpoint", err) + } + out.Endpoint = &sdk.CreatePrivateEndpointRule_Endpoint_GcpEndpoint{GcpEndpoint: *conv25} + } + return out, nil +} + +// CreatePrivateEndpointRuleFromSDK converts the sdk-go type to the mirror. +func CreatePrivateEndpointRuleFromSDK(v *sdk.CreatePrivateEndpointRule) (*CreatePrivateEndpointRule, error) { + if v == nil { + return nil, nil + } + out := &CreatePrivateEndpointRule{} + out.RuleId = v.RuleId + out.NetworkConnectivityConfigId = v.NetworkConnectivityConfigId + out.ConnectionState = v.ConnectionState + out.DomainNames = v.DomainNames + out.CreationTime = v.CreationTime + out.UpdatedTime = v.UpdatedTime + out.Deactivated = v.Deactivated + out.DeactivatedAt = v.DeactivatedAt + out.ErrorMessage = v.ErrorMessage + out.ResourceId = v.ResourceId + out.GroupId = v.GroupId + out.EndpointName = v.EndpointName + out.AccountId = v.AccountId + out.EndpointService = v.EndpointService + out.ResourceNames = v.ResourceNames + out.VpcEndpointId = v.VpcEndpointId + out.Enabled = v.Enabled + switch value := v.Endpoint.(type) { + case *sdk.CreatePrivateEndpointRule_Endpoint_GcpEndpoint: + if value != nil { + conv26, err := GcpEndpointFromSDK(&value.GcpEndpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePrivateEndpointRule.Endpoint", err) + } + out.GcpEndpoint = conv26 + } + } + return out, nil +} + +// CreateVpcEndpointRequestToSDK converts the mirror to the sdk-go type. +func CreateVpcEndpointRequestToSDK(w *CreateVpcEndpointRequest) (*sdk.CreateVpcEndpointRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateVpcEndpointRequest{} + out.AccountId = w.AccountId + out.VpcEndpointName = w.VpcEndpointName + out.Region = w.Region + out.AwsVpcEndpointId = w.AwsVpcEndpointId + { + var members []string + if w.GcpVpcEndpointInfo != nil { + members = append(members, "gcp_vpc_endpoint_info") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.GcpVpcEndpointInfo != nil: + conv27, err := GcpVpcEndpointInfoToSDK(w.GcpVpcEndpointInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateVpcEndpointRequest.VpcEndpointInfo", err) + } + out.VpcEndpointInfo = &sdk.CreateVpcEndpointRequest_VpcEndpointInfo_GcpVpcEndpointInfo{GcpVpcEndpointInfo: *conv27} + } + return out, nil +} + +// CreateVpcEndpointRequestFromSDK converts the sdk-go type to the mirror. +func CreateVpcEndpointRequestFromSDK(v *sdk.CreateVpcEndpointRequest) (*CreateVpcEndpointRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateVpcEndpointRequest{} + out.AccountId = v.AccountId + out.VpcEndpointName = v.VpcEndpointName + out.Region = v.Region + out.AwsVpcEndpointId = v.AwsVpcEndpointId + switch value := v.VpcEndpointInfo.(type) { + case *sdk.CreateVpcEndpointRequest_VpcEndpointInfo_GcpVpcEndpointInfo: + if value != nil { + conv28, err := GcpVpcEndpointInfoFromSDK(&value.GcpVpcEndpointInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateVpcEndpointRequest.VpcEndpointInfo", err) + } + out.GcpVpcEndpointInfo = conv28 + } + } + return out, nil +} + +// CustomerFacingNetworkConnectivityConfigEgressConfigToSDK converts the mirror to the sdk-go type. +func CustomerFacingNetworkConnectivityConfigEgressConfigToSDK(w *CustomerFacingNetworkConnectivityConfigEgressConfig) (*sdk.CustomerFacingNetworkConnectivityConfigEgressConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomerFacingNetworkConnectivityConfigEgressConfig{} + conv29, err := NetworkConnectivityConfigEgressConfig_DefaultRuleToSDK(w.DefaultRules) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerFacingNetworkConnectivityConfigEgressConfig.DefaultRules", err) + } + out.DefaultRules = conv29 + conv30, err := CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRuleToSDK(w.TargetRules) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerFacingNetworkConnectivityConfigEgressConfig.TargetRules", err) + } + out.TargetRules = conv30 + return out, nil +} + +// CustomerFacingNetworkConnectivityConfigEgressConfigFromSDK converts the sdk-go type to the mirror. +func CustomerFacingNetworkConnectivityConfigEgressConfigFromSDK(v *sdk.CustomerFacingNetworkConnectivityConfigEgressConfig) (*CustomerFacingNetworkConnectivityConfigEgressConfig, error) { + if v == nil { + return nil, nil + } + out := &CustomerFacingNetworkConnectivityConfigEgressConfig{} + conv31, err := NetworkConnectivityConfigEgressConfig_DefaultRuleFromSDK(v.DefaultRules) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerFacingNetworkConnectivityConfigEgressConfig.DefaultRules", err) + } + out.DefaultRules = conv31 + conv32, err := CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRuleFromSDK(v.TargetRules) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerFacingNetworkConnectivityConfigEgressConfig.TargetRules", err) + } + out.TargetRules = conv32 + return out, nil +} + +// CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRuleToSDK converts the mirror to the sdk-go type. +func CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRuleToSDK(w *CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule) (*sdk.CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule{} + conv33, err := convertSlice(w.AzurePrivateEndpointRules, NetworkConnectivityConfigAzurePrivateEndpointRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule.AzurePrivateEndpointRules", err) + } + out.AzurePrivateEndpointRules = conv33 + conv34, err := convertSlice(w.AwsPrivateEndpointRules, NetworkConnectivityConfigAwsPrivateEndpointRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule.AwsPrivateEndpointRules", err) + } + out.AwsPrivateEndpointRules = conv34 + return out, nil +} + +// CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRuleFromSDK converts the sdk-go type to the mirror. +func CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRuleFromSDK(v *sdk.CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule) (*CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule, error) { + if v == nil { + return nil, nil + } + out := &CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule{} + conv35, err := convertSlice(v.AzurePrivateEndpointRules, NetworkConnectivityConfigAzurePrivateEndpointRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule.AzurePrivateEndpointRules", err) + } + out.AzurePrivateEndpointRules = conv35 + conv36, err := convertSlice(v.AwsPrivateEndpointRules, NetworkConnectivityConfigAwsPrivateEndpointRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomerFacingNetworkConnectivityConfigEgressConfig_CustomerFacingTargetRule.AwsPrivateEndpointRules", err) + } + out.AwsPrivateEndpointRules = conv36 + return out, nil +} + +// EgressNetworkPolicyToSDK converts the mirror to the sdk-go type. +func EgressNetworkPolicyToSDK(w *EgressNetworkPolicy) (*sdk.EgressNetworkPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.EgressNetworkPolicy{} + conv37, err := EgressNetworkPolicy_NetworkAccessPolicyToSDK(w.NetworkAccess) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy.NetworkAccess", err) + } + out.NetworkAccess = conv37 + return out, nil +} + +// EgressNetworkPolicyFromSDK converts the sdk-go type to the mirror. +func EgressNetworkPolicyFromSDK(v *sdk.EgressNetworkPolicy) (*EgressNetworkPolicy, error) { + if v == nil { + return nil, nil + } + out := &EgressNetworkPolicy{} + conv38, err := EgressNetworkPolicy_NetworkAccessPolicyFromSDK(v.NetworkAccess) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy.NetworkAccess", err) + } + out.NetworkAccess = conv38 + return out, nil +} + +// EgressNetworkPolicy_NetworkAccessPolicyToSDK converts the mirror to the sdk-go type. +func EgressNetworkPolicy_NetworkAccessPolicyToSDK(w *EgressNetworkPolicy_NetworkAccessPolicy) (*sdk.EgressNetworkPolicy_NetworkAccessPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.EgressNetworkPolicy_NetworkAccessPolicy{} + out.RestrictionMode = w.RestrictionMode + conv39, err := convertSlice(w.AllowedInternetDestinations, EgressNetworkPolicy_NetworkAccessPolicy_InternetDestinationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_NetworkAccessPolicy.AllowedInternetDestinations", err) + } + out.AllowedInternetDestinations = conv39 + conv40, err := convertSlice(w.AllowedStorageDestinations, EgressNetworkPolicy_NetworkAccessPolicy_StorageDestinationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_NetworkAccessPolicy.AllowedStorageDestinations", err) + } + out.AllowedStorageDestinations = conv40 + conv41, err := EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcementToSDK(w.PolicyEnforcement) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_NetworkAccessPolicy.PolicyEnforcement", err) + } + out.PolicyEnforcement = conv41 + conv42, err := convertSlice(w.BlockedInternetDestinations, EgressNetworkPolicy_NetworkAccessPolicy_InternetDestinationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_NetworkAccessPolicy.BlockedInternetDestinations", err) + } + out.BlockedInternetDestinations = conv42 + conv43, err := convertSlice(w.AllowedDatabricksDestinations, EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestinationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_NetworkAccessPolicy.AllowedDatabricksDestinations", err) + } + out.AllowedDatabricksDestinations = conv43 + return out, nil +} + +// EgressNetworkPolicy_NetworkAccessPolicyFromSDK converts the sdk-go type to the mirror. +func EgressNetworkPolicy_NetworkAccessPolicyFromSDK(v *sdk.EgressNetworkPolicy_NetworkAccessPolicy) (*EgressNetworkPolicy_NetworkAccessPolicy, error) { + if v == nil { + return nil, nil + } + out := &EgressNetworkPolicy_NetworkAccessPolicy{} + out.RestrictionMode = v.RestrictionMode + conv44, err := convertSlice(v.AllowedInternetDestinations, EgressNetworkPolicy_NetworkAccessPolicy_InternetDestinationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_NetworkAccessPolicy.AllowedInternetDestinations", err) + } + out.AllowedInternetDestinations = conv44 + conv45, err := convertSlice(v.AllowedStorageDestinations, EgressNetworkPolicy_NetworkAccessPolicy_StorageDestinationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_NetworkAccessPolicy.AllowedStorageDestinations", err) + } + out.AllowedStorageDestinations = conv45 + conv46, err := EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcementFromSDK(v.PolicyEnforcement) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_NetworkAccessPolicy.PolicyEnforcement", err) + } + out.PolicyEnforcement = conv46 + conv47, err := convertSlice(v.BlockedInternetDestinations, EgressNetworkPolicy_NetworkAccessPolicy_InternetDestinationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_NetworkAccessPolicy.BlockedInternetDestinations", err) + } + out.BlockedInternetDestinations = conv47 + conv48, err := convertSlice(v.AllowedDatabricksDestinations, EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestinationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EgressNetworkPolicy_NetworkAccessPolicy.AllowedDatabricksDestinations", err) + } + out.AllowedDatabricksDestinations = conv48 + return out, nil +} + +// EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestinationToSDK converts the mirror to the sdk-go type. +func EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestinationToSDK(w *EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestination) (*sdk.EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestination{} + out.WorkspaceIds = w.WorkspaceIds + return out, nil +} + +// EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestinationFromSDK converts the sdk-go type to the mirror. +func EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestinationFromSDK(v *sdk.EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestination) (*EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestination, error) { + if v == nil { + return nil, nil + } + out := &EgressNetworkPolicy_NetworkAccessPolicy_DatabricksDestination{} + out.WorkspaceIds = v.WorkspaceIds + return out, nil +} + +// EgressNetworkPolicy_NetworkAccessPolicy_InternetDestinationToSDK converts the mirror to the sdk-go type. +func EgressNetworkPolicy_NetworkAccessPolicy_InternetDestinationToSDK(w *EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination) (*sdk.EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination{} + out.Destination = w.Destination + out.InternetDestinationType = w.InternetDestinationType + return out, nil +} + +// EgressNetworkPolicy_NetworkAccessPolicy_InternetDestinationFromSDK converts the sdk-go type to the mirror. +func EgressNetworkPolicy_NetworkAccessPolicy_InternetDestinationFromSDK(v *sdk.EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination) (*EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination, error) { + if v == nil { + return nil, nil + } + out := &EgressNetworkPolicy_NetworkAccessPolicy_InternetDestination{} + out.Destination = v.Destination + out.InternetDestinationType = v.InternetDestinationType + return out, nil +} + +// EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcementToSDK converts the mirror to the sdk-go type. +func EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcementToSDK(w *EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement) (*sdk.EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement, error) { + if w == nil { + return nil, nil + } + out := &sdk.EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement{} + out.EnforcementMode = w.EnforcementMode + out.DryRunModeProductFilter = w.DryRunModeProductFilter + return out, nil +} + +// EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcementFromSDK converts the sdk-go type to the mirror. +func EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcementFromSDK(v *sdk.EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement) (*EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement, error) { + if v == nil { + return nil, nil + } + out := &EgressNetworkPolicy_NetworkAccessPolicy_PolicyEnforcement{} + out.EnforcementMode = v.EnforcementMode + out.DryRunModeProductFilter = v.DryRunModeProductFilter + return out, nil +} + +// EgressNetworkPolicy_NetworkAccessPolicy_StorageDestinationToSDK converts the mirror to the sdk-go type. +func EgressNetworkPolicy_NetworkAccessPolicy_StorageDestinationToSDK(w *EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination) (*sdk.EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination{} + out.BucketName = w.BucketName + out.Region = w.Region + out.StorageDestinationType = w.StorageDestinationType + out.AzureStorageAccount = w.AzureStorageAccount + out.AzureStorageService = w.AzureStorageService + return out, nil +} + +// EgressNetworkPolicy_NetworkAccessPolicy_StorageDestinationFromSDK converts the sdk-go type to the mirror. +func EgressNetworkPolicy_NetworkAccessPolicy_StorageDestinationFromSDK(v *sdk.EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination) (*EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination, error) { + if v == nil { + return nil, nil + } + out := &EgressNetworkPolicy_NetworkAccessPolicy_StorageDestination{} + out.BucketName = v.BucketName + out.Region = v.Region + out.StorageDestinationType = v.StorageDestinationType + out.AzureStorageAccount = v.AzureStorageAccount + out.AzureStorageService = v.AzureStorageService + return out, nil +} + +// EndpointToSDK converts the mirror to the sdk-go type. +func EndpointToSDK(w *Endpoint) (*sdk.Endpoint, error) { + if w == nil { + return nil, nil + } + out := &sdk.Endpoint{} + out.Name = w.Name + out.EndpointId = w.EndpointId + out.AccountId = w.AccountId + out.DisplayName = w.DisplayName + out.UseCase = w.UseCase + out.Region = w.Region + out.State = w.State + { + var members []string + if w.AzurePrivateEndpointInfo != nil { + members = append(members, "azure_private_endpoint_info") + } + if w.AwsVpcEndpointInfo != nil { + members = append(members, "aws_vpc_endpoint_info") + } + if w.GcpPscEndpointInfo != nil { + members = append(members, "gcp_psc_endpoint_info") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AzurePrivateEndpointInfo != nil: + conv49, err := AzurePrivateEndpointInfoToSDK(w.AzurePrivateEndpointInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.EndpointInfo", err) + } + out.EndpointInfo = &sdk.Endpoint_EndpointInfo_AzurePrivateEndpointInfo{AzurePrivateEndpointInfo: *conv49} + case w.AwsVpcEndpointInfo != nil: + conv50, err := AwsVpcEndpointInfoToSDK(w.AwsVpcEndpointInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.EndpointInfo", err) + } + out.EndpointInfo = &sdk.Endpoint_EndpointInfo_AwsVpcEndpointInfo{AwsVpcEndpointInfo: *conv50} + case w.GcpPscEndpointInfo != nil: + conv51, err := GcpPscEndpointInfoToSDK(w.GcpPscEndpointInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.EndpointInfo", err) + } + out.EndpointInfo = &sdk.Endpoint_EndpointInfo_GcpPscEndpointInfo{GcpPscEndpointInfo: *conv51} + } + out.CreateTime = w.CreateTime + return out, nil +} + +// EndpointFromSDK converts the sdk-go type to the mirror. +func EndpointFromSDK(v *sdk.Endpoint) (*Endpoint, error) { + if v == nil { + return nil, nil + } + out := &Endpoint{} + out.Name = v.Name + out.EndpointId = v.EndpointId + out.AccountId = v.AccountId + out.DisplayName = v.DisplayName + out.UseCase = v.UseCase + out.Region = v.Region + out.State = v.State + switch value := v.EndpointInfo.(type) { + case *sdk.Endpoint_EndpointInfo_AzurePrivateEndpointInfo: + if value != nil { + conv52, err := AzurePrivateEndpointInfoFromSDK(&value.AzurePrivateEndpointInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.EndpointInfo", err) + } + out.AzurePrivateEndpointInfo = conv52 + } + case *sdk.Endpoint_EndpointInfo_AwsVpcEndpointInfo: + if value != nil { + conv53, err := AwsVpcEndpointInfoFromSDK(&value.AwsVpcEndpointInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.EndpointInfo", err) + } + out.AwsVpcEndpointInfo = conv53 + } + case *sdk.Endpoint_EndpointInfo_GcpPscEndpointInfo: + if value != nil { + conv54, err := GcpPscEndpointInfoFromSDK(&value.GcpPscEndpointInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.EndpointInfo", err) + } + out.GcpPscEndpointInfo = conv54 + } + } + out.CreateTime = v.CreateTime + return out, nil +} + +// GcpEndpointToSDK converts the mirror to the sdk-go type. +func GcpEndpointToSDK(w *GcpEndpoint) (*sdk.GcpEndpoint, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpEndpoint{} + out.PscEndpointUri = w.PscEndpointUri + { + var members []string + if w.ServiceAttachment != nil { + members = append(members, "service_attachment") + } + if w.GoogleApiEndpoints != nil { + members = append(members, "google_api_endpoints") + } + if w.AllVpcScServices != nil { + members = append(members, "all_vpc_sc_services") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ServiceAttachment != nil: + out.TargetServices = &sdk.GcpEndpoint_TargetServices_ServiceAttachment{ServiceAttachment: *w.ServiceAttachment} + case w.GoogleApiEndpoints != nil: + conv55, err := GoogleApiEndpointsToSDK(w.GoogleApiEndpoints) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GcpEndpoint.TargetServices", err) + } + out.TargetServices = &sdk.GcpEndpoint_TargetServices_GoogleApiEndpoints{GoogleApiEndpoints: *conv55} + case w.AllVpcScServices != nil: + out.TargetServices = &sdk.GcpEndpoint_TargetServices_AllVpcScServices{AllVpcScServices: *w.AllVpcScServices} + } + return out, nil +} + +// GcpEndpointFromSDK converts the sdk-go type to the mirror. +func GcpEndpointFromSDK(v *sdk.GcpEndpoint) (*GcpEndpoint, error) { + if v == nil { + return nil, nil + } + out := &GcpEndpoint{} + out.PscEndpointUri = v.PscEndpointUri + switch value := v.TargetServices.(type) { + case *sdk.GcpEndpoint_TargetServices_ServiceAttachment: + if value != nil { + out.ServiceAttachment = new(value.ServiceAttachment) + } + case *sdk.GcpEndpoint_TargetServices_GoogleApiEndpoints: + if value != nil { + conv56, err := GoogleApiEndpointsFromSDK(&value.GoogleApiEndpoints) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GcpEndpoint.TargetServices", err) + } + out.GoogleApiEndpoints = conv56 + } + case *sdk.GcpEndpoint_TargetServices_AllVpcScServices: + if value != nil { + out.AllVpcScServices = new(value.AllVpcScServices) + } + } + return out, nil +} + +// GcpNetworkInfoToSDK converts the mirror to the sdk-go type. +func GcpNetworkInfoToSDK(w *GcpNetworkInfo) (*sdk.GcpNetworkInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpNetworkInfo{} + out.NetworkProjectId = w.NetworkProjectId + out.VpcId = w.VpcId + out.SubnetId = w.SubnetId + out.SubnetRegion = w.SubnetRegion + out.PodIpRangeName = w.PodIpRangeName + out.ServiceIpRangeName = w.ServiceIpRangeName + return out, nil +} + +// GcpNetworkInfoFromSDK converts the sdk-go type to the mirror. +func GcpNetworkInfoFromSDK(v *sdk.GcpNetworkInfo) (*GcpNetworkInfo, error) { + if v == nil { + return nil, nil + } + out := &GcpNetworkInfo{} + out.NetworkProjectId = v.NetworkProjectId + out.VpcId = v.VpcId + out.SubnetId = v.SubnetId + out.SubnetRegion = v.SubnetRegion + out.PodIpRangeName = v.PodIpRangeName + out.ServiceIpRangeName = v.ServiceIpRangeName + return out, nil +} + +// GcpPscEndpointInfoToSDK converts the mirror to the sdk-go type. +func GcpPscEndpointInfoToSDK(w *GcpPscEndpointInfo) (*sdk.GcpPscEndpointInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpPscEndpointInfo{} + out.PscConnectionId = w.PscConnectionId + out.ProjectId = w.ProjectId + out.PscEndpoint = w.PscEndpoint + out.EndpointRegion = w.EndpointRegion + out.ServiceAttachmentId = w.ServiceAttachmentId + return out, nil +} + +// GcpPscEndpointInfoFromSDK converts the sdk-go type to the mirror. +func GcpPscEndpointInfoFromSDK(v *sdk.GcpPscEndpointInfo) (*GcpPscEndpointInfo, error) { + if v == nil { + return nil, nil + } + out := &GcpPscEndpointInfo{} + out.PscConnectionId = v.PscConnectionId + out.ProjectId = v.ProjectId + out.PscEndpoint = v.PscEndpoint + out.EndpointRegion = v.EndpointRegion + out.ServiceAttachmentId = v.ServiceAttachmentId + return out, nil +} + +// GcpVpcEndpointInfoToSDK converts the mirror to the sdk-go type. +func GcpVpcEndpointInfoToSDK(w *GcpVpcEndpointInfo) (*sdk.GcpVpcEndpointInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpVpcEndpointInfo{} + out.PscConnectionId = w.PscConnectionId + out.ProjectId = w.ProjectId + out.PscEndpointName = w.PscEndpointName + out.EndpointRegion = w.EndpointRegion + out.ServiceAttachmentId = w.ServiceAttachmentId + return out, nil +} + +// GcpVpcEndpointInfoFromSDK converts the sdk-go type to the mirror. +func GcpVpcEndpointInfoFromSDK(v *sdk.GcpVpcEndpointInfo) (*GcpVpcEndpointInfo, error) { + if v == nil { + return nil, nil + } + out := &GcpVpcEndpointInfo{} + out.PscConnectionId = v.PscConnectionId + out.ProjectId = v.ProjectId + out.PscEndpointName = v.PscEndpointName + out.EndpointRegion = v.EndpointRegion + out.ServiceAttachmentId = v.ServiceAttachmentId + return out, nil +} + +// GetAccountIpAccessListResponseToSDK converts the mirror to the sdk-go type. +func GetAccountIpAccessListResponseToSDK(w *GetAccountIpAccessListResponse) (*sdk.GetAccountIpAccessListResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetAccountIpAccessListResponse{} + conv57, err := AccountIpAccessListToSDK(w.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetAccountIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv57 + return out, nil +} + +// GetAccountIpAccessListResponseFromSDK converts the sdk-go type to the mirror. +func GetAccountIpAccessListResponseFromSDK(v *sdk.GetAccountIpAccessListResponse) (*GetAccountIpAccessListResponse, error) { + if v == nil { + return nil, nil + } + out := &GetAccountIpAccessListResponse{} + conv58, err := AccountIpAccessListFromSDK(v.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetAccountIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv58 + return out, nil +} + +// GetIpAccessListResponseToSDK converts the mirror to the sdk-go type. +func GetIpAccessListResponseToSDK(w *GetIpAccessListResponse) (*sdk.GetIpAccessListResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetIpAccessListResponse{} + conv59, err := IpAccessListToSDK(w.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv59 + return out, nil +} + +// GetIpAccessListResponseFromSDK converts the sdk-go type to the mirror. +func GetIpAccessListResponseFromSDK(v *sdk.GetIpAccessListResponse) (*GetIpAccessListResponse, error) { + if v == nil { + return nil, nil + } + out := &GetIpAccessListResponse{} + conv60, err := IpAccessListFromSDK(v.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv60 + return out, nil +} + +// GoogleApiEndpointsToSDK converts the mirror to the sdk-go type. +func GoogleApiEndpointsToSDK(w *GoogleApiEndpoints) (*sdk.GoogleApiEndpoints, error) { + if w == nil { + return nil, nil + } + out := &sdk.GoogleApiEndpoints{} + out.Endpoints = w.Endpoints + return out, nil +} + +// GoogleApiEndpointsFromSDK converts the sdk-go type to the mirror. +func GoogleApiEndpointsFromSDK(v *sdk.GoogleApiEndpoints) (*GoogleApiEndpoints, error) { + if v == nil { + return nil, nil + } + out := &GoogleApiEndpoints{} + out.Endpoints = v.Endpoints + return out, nil +} + +// IngressNetworkPolicyToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicyToSDK(w *IngressNetworkPolicy) (*sdk.IngressNetworkPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy{} + conv61, err := IngressNetworkPolicy_PublicAccessToSDK(w.PublicAccess) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy.PublicAccess", err) + } + out.PublicAccess = conv61 + conv62, err := IngressNetworkPolicy_PrivateAccessToSDK(w.PrivateAccess) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy.PrivateAccess", err) + } + out.PrivateAccess = conv62 + conv63, err := IngressNetworkPolicy_CrossWorkspaceAccessToSDK(w.CrossWorkspaceAccess) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy.CrossWorkspaceAccess", err) + } + out.CrossWorkspaceAccess = conv63 + return out, nil +} + +// IngressNetworkPolicyFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicyFromSDK(v *sdk.IngressNetworkPolicy) (*IngressNetworkPolicy, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy{} + conv64, err := IngressNetworkPolicy_PublicAccessFromSDK(v.PublicAccess) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy.PublicAccess", err) + } + out.PublicAccess = conv64 + conv65, err := IngressNetworkPolicy_PrivateAccessFromSDK(v.PrivateAccess) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy.PrivateAccess", err) + } + out.PrivateAccess = conv65 + conv66, err := IngressNetworkPolicy_CrossWorkspaceAccessFromSDK(v.CrossWorkspaceAccess) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy.CrossWorkspaceAccess", err) + } + out.CrossWorkspaceAccess = conv66 + return out, nil +} + +// IngressNetworkPolicy_AccountApiDestinationToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_AccountApiDestinationToSDK(w *IngressNetworkPolicy_AccountApiDestination) (*sdk.IngressNetworkPolicy_AccountApiDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_AccountApiDestination{} + out.Scopes = w.Scopes + out.ScopeQualifier = w.ScopeQualifier + return out, nil +} + +// IngressNetworkPolicy_AccountApiDestinationFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_AccountApiDestinationFromSDK(v *sdk.IngressNetworkPolicy_AccountApiDestination) (*IngressNetworkPolicy_AccountApiDestination, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_AccountApiDestination{} + out.Scopes = v.Scopes + out.ScopeQualifier = v.ScopeQualifier + return out, nil +} + +// IngressNetworkPolicy_AccountDatabricksOneDestinationToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_AccountDatabricksOneDestinationToSDK(w *IngressNetworkPolicy_AccountDatabricksOneDestination) (*sdk.IngressNetworkPolicy_AccountDatabricksOneDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_AccountDatabricksOneDestination{} + out.AllDestinations = w.AllDestinations + return out, nil +} + +// IngressNetworkPolicy_AccountDatabricksOneDestinationFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_AccountDatabricksOneDestinationFromSDK(v *sdk.IngressNetworkPolicy_AccountDatabricksOneDestination) (*IngressNetworkPolicy_AccountDatabricksOneDestination, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_AccountDatabricksOneDestination{} + out.AllDestinations = v.AllDestinations + return out, nil +} + +// IngressNetworkPolicy_AccountUiDestinationToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_AccountUiDestinationToSDK(w *IngressNetworkPolicy_AccountUiDestination) (*sdk.IngressNetworkPolicy_AccountUiDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_AccountUiDestination{} + out.AllDestinations = w.AllDestinations + return out, nil +} + +// IngressNetworkPolicy_AccountUiDestinationFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_AccountUiDestinationFromSDK(v *sdk.IngressNetworkPolicy_AccountUiDestination) (*IngressNetworkPolicy_AccountUiDestination, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_AccountUiDestination{} + out.AllDestinations = v.AllDestinations + return out, nil +} + +// IngressNetworkPolicy_AppsRuntimeDestinationToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_AppsRuntimeDestinationToSDK(w *IngressNetworkPolicy_AppsRuntimeDestination) (*sdk.IngressNetworkPolicy_AppsRuntimeDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_AppsRuntimeDestination{} + out.AllDestinations = w.AllDestinations + return out, nil +} + +// IngressNetworkPolicy_AppsRuntimeDestinationFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_AppsRuntimeDestinationFromSDK(v *sdk.IngressNetworkPolicy_AppsRuntimeDestination) (*IngressNetworkPolicy_AppsRuntimeDestination, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_AppsRuntimeDestination{} + out.AllDestinations = v.AllDestinations + return out, nil +} + +// IngressNetworkPolicy_AuthenticationToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_AuthenticationToSDK(w *IngressNetworkPolicy_Authentication) (*sdk.IngressNetworkPolicy_Authentication, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_Authentication{} + out.IdentityType = w.IdentityType + conv67, err := convertSlice(w.Identities, IngressNetworkPolicy_AuthenticationIdentityToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_Authentication.Identities", err) + } + out.Identities = conv67 + return out, nil +} + +// IngressNetworkPolicy_AuthenticationFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_AuthenticationFromSDK(v *sdk.IngressNetworkPolicy_Authentication) (*IngressNetworkPolicy_Authentication, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_Authentication{} + out.IdentityType = v.IdentityType + conv68, err := convertSlice(v.Identities, IngressNetworkPolicy_AuthenticationIdentityFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_Authentication.Identities", err) + } + out.Identities = conv68 + return out, nil +} + +// IngressNetworkPolicy_AuthenticationIdentityToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_AuthenticationIdentityToSDK(w *IngressNetworkPolicy_AuthenticationIdentity) (*sdk.IngressNetworkPolicy_AuthenticationIdentity, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_AuthenticationIdentity{} + out.PrincipalType = w.PrincipalType + out.PrincipalId = w.PrincipalId + return out, nil +} + +// IngressNetworkPolicy_AuthenticationIdentityFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_AuthenticationIdentityFromSDK(v *sdk.IngressNetworkPolicy_AuthenticationIdentity) (*IngressNetworkPolicy_AuthenticationIdentity, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_AuthenticationIdentity{} + out.PrincipalType = v.PrincipalType + out.PrincipalId = v.PrincipalId + return out, nil +} + +// IngressNetworkPolicy_CrossWorkspaceAccessToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_CrossWorkspaceAccessToSDK(w *IngressNetworkPolicy_CrossWorkspaceAccess) (*sdk.IngressNetworkPolicy_CrossWorkspaceAccess, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_CrossWorkspaceAccess{} + out.RestrictionMode = w.RestrictionMode + conv69, err := convertSlice(w.DenyRules, IngressNetworkPolicy_CrossWorkspaceIngressRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_CrossWorkspaceAccess.DenyRules", err) + } + out.DenyRules = conv69 + conv70, err := convertSlice(w.AllowRules, IngressNetworkPolicy_CrossWorkspaceIngressRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_CrossWorkspaceAccess.AllowRules", err) + } + out.AllowRules = conv70 + return out, nil +} + +// IngressNetworkPolicy_CrossWorkspaceAccessFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_CrossWorkspaceAccessFromSDK(v *sdk.IngressNetworkPolicy_CrossWorkspaceAccess) (*IngressNetworkPolicy_CrossWorkspaceAccess, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_CrossWorkspaceAccess{} + out.RestrictionMode = v.RestrictionMode + conv71, err := convertSlice(v.DenyRules, IngressNetworkPolicy_CrossWorkspaceIngressRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_CrossWorkspaceAccess.DenyRules", err) + } + out.DenyRules = conv71 + conv72, err := convertSlice(v.AllowRules, IngressNetworkPolicy_CrossWorkspaceIngressRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_CrossWorkspaceAccess.AllowRules", err) + } + out.AllowRules = conv72 + return out, nil +} + +// IngressNetworkPolicy_CrossWorkspaceIngressRuleToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_CrossWorkspaceIngressRuleToSDK(w *IngressNetworkPolicy_CrossWorkspaceIngressRule) (*sdk.IngressNetworkPolicy_CrossWorkspaceIngressRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_CrossWorkspaceIngressRule{} + conv73, err := IngressNetworkPolicy_CrossWorkspaceRequestOriginToSDK(w.Origin) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_CrossWorkspaceIngressRule.Origin", err) + } + out.Origin = conv73 + conv74, err := IngressNetworkPolicy_RequestDestinationToSDK(w.Destination) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_CrossWorkspaceIngressRule.Destination", err) + } + out.Destination = conv74 + conv75, err := IngressNetworkPolicy_AuthenticationToSDK(w.Authentication) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_CrossWorkspaceIngressRule.Authentication", err) + } + out.Authentication = conv75 + out.Label = w.Label + return out, nil +} + +// IngressNetworkPolicy_CrossWorkspaceIngressRuleFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_CrossWorkspaceIngressRuleFromSDK(v *sdk.IngressNetworkPolicy_CrossWorkspaceIngressRule) (*IngressNetworkPolicy_CrossWorkspaceIngressRule, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_CrossWorkspaceIngressRule{} + conv76, err := IngressNetworkPolicy_CrossWorkspaceRequestOriginFromSDK(v.Origin) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_CrossWorkspaceIngressRule.Origin", err) + } + out.Origin = conv76 + conv77, err := IngressNetworkPolicy_RequestDestinationFromSDK(v.Destination) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_CrossWorkspaceIngressRule.Destination", err) + } + out.Destination = conv77 + conv78, err := IngressNetworkPolicy_AuthenticationFromSDK(v.Authentication) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_CrossWorkspaceIngressRule.Authentication", err) + } + out.Authentication = conv78 + out.Label = v.Label + return out, nil +} + +// IngressNetworkPolicy_CrossWorkspaceRequestOriginToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_CrossWorkspaceRequestOriginToSDK(w *IngressNetworkPolicy_CrossWorkspaceRequestOrigin) (*sdk.IngressNetworkPolicy_CrossWorkspaceRequestOrigin, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_CrossWorkspaceRequestOrigin{} + { + var members []string + if w.AllSourceWorkspaces != nil { + members = append(members, "all_source_workspaces") + } + if w.SelectedWorkspaces != nil { + members = append(members, "selected_workspaces") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AllSourceWorkspaces != nil: + out.Source = &sdk.IngressNetworkPolicy_CrossWorkspaceRequestOrigin_Source_AllSourceWorkspaces{AllSourceWorkspaces: *w.AllSourceWorkspaces} + case w.SelectedWorkspaces != nil: + conv79, err := IngressNetworkPolicy_WorkspaceIdListToSDK(w.SelectedWorkspaces) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_CrossWorkspaceRequestOrigin.Source", err) + } + out.Source = &sdk.IngressNetworkPolicy_CrossWorkspaceRequestOrigin_Source_SelectedWorkspaces{SelectedWorkspaces: *conv79} + } + return out, nil +} + +// IngressNetworkPolicy_CrossWorkspaceRequestOriginFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_CrossWorkspaceRequestOriginFromSDK(v *sdk.IngressNetworkPolicy_CrossWorkspaceRequestOrigin) (*IngressNetworkPolicy_CrossWorkspaceRequestOrigin, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_CrossWorkspaceRequestOrigin{} + switch value := v.Source.(type) { + case *sdk.IngressNetworkPolicy_CrossWorkspaceRequestOrigin_Source_AllSourceWorkspaces: + if value != nil { + out.AllSourceWorkspaces = new(value.AllSourceWorkspaces) + } + case *sdk.IngressNetworkPolicy_CrossWorkspaceRequestOrigin_Source_SelectedWorkspaces: + if value != nil { + conv80, err := IngressNetworkPolicy_WorkspaceIdListFromSDK(&value.SelectedWorkspaces) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_CrossWorkspaceRequestOrigin.Source", err) + } + out.SelectedWorkspaces = conv80 + } + } + return out, nil +} + +// IngressNetworkPolicy_EndpointsToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_EndpointsToSDK(w *IngressNetworkPolicy_Endpoints) (*sdk.IngressNetworkPolicy_Endpoints, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_Endpoints{} + out.EndpointIds = w.EndpointIds + return out, nil +} + +// IngressNetworkPolicy_EndpointsFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_EndpointsFromSDK(v *sdk.IngressNetworkPolicy_Endpoints) (*IngressNetworkPolicy_Endpoints, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_Endpoints{} + out.EndpointIds = v.EndpointIds + return out, nil +} + +// IngressNetworkPolicy_IpRangesToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_IpRangesToSDK(w *IngressNetworkPolicy_IpRanges) (*sdk.IngressNetworkPolicy_IpRanges, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_IpRanges{} + out.IpRanges = w.IpRanges + return out, nil +} + +// IngressNetworkPolicy_IpRangesFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_IpRangesFromSDK(v *sdk.IngressNetworkPolicy_IpRanges) (*IngressNetworkPolicy_IpRanges, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_IpRanges{} + out.IpRanges = v.IpRanges + return out, nil +} + +// IngressNetworkPolicy_LakebaseRuntimeDestinationToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_LakebaseRuntimeDestinationToSDK(w *IngressNetworkPolicy_LakebaseRuntimeDestination) (*sdk.IngressNetworkPolicy_LakebaseRuntimeDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_LakebaseRuntimeDestination{} + out.AllDestinations = w.AllDestinations + return out, nil +} + +// IngressNetworkPolicy_LakebaseRuntimeDestinationFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_LakebaseRuntimeDestinationFromSDK(v *sdk.IngressNetworkPolicy_LakebaseRuntimeDestination) (*IngressNetworkPolicy_LakebaseRuntimeDestination, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_LakebaseRuntimeDestination{} + out.AllDestinations = v.AllDestinations + return out, nil +} + +// IngressNetworkPolicy_PrivateAccessToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_PrivateAccessToSDK(w *IngressNetworkPolicy_PrivateAccess) (*sdk.IngressNetworkPolicy_PrivateAccess, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_PrivateAccess{} + out.RestrictionMode = w.RestrictionMode + conv81, err := convertSlice(w.DenyRules, IngressNetworkPolicy_PrivateIngressRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PrivateAccess.DenyRules", err) + } + out.DenyRules = conv81 + conv82, err := convertSlice(w.AllowRules, IngressNetworkPolicy_PrivateIngressRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PrivateAccess.AllowRules", err) + } + out.AllowRules = conv82 + return out, nil +} + +// IngressNetworkPolicy_PrivateAccessFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_PrivateAccessFromSDK(v *sdk.IngressNetworkPolicy_PrivateAccess) (*IngressNetworkPolicy_PrivateAccess, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_PrivateAccess{} + out.RestrictionMode = v.RestrictionMode + conv83, err := convertSlice(v.DenyRules, IngressNetworkPolicy_PrivateIngressRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PrivateAccess.DenyRules", err) + } + out.DenyRules = conv83 + conv84, err := convertSlice(v.AllowRules, IngressNetworkPolicy_PrivateIngressRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PrivateAccess.AllowRules", err) + } + out.AllowRules = conv84 + return out, nil +} + +// IngressNetworkPolicy_PrivateIngressRuleToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_PrivateIngressRuleToSDK(w *IngressNetworkPolicy_PrivateIngressRule) (*sdk.IngressNetworkPolicy_PrivateIngressRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_PrivateIngressRule{} + conv85, err := IngressNetworkPolicy_PrivateRequestOriginToSDK(w.Origin) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PrivateIngressRule.Origin", err) + } + out.Origin = conv85 + conv86, err := IngressNetworkPolicy_RequestDestinationToSDK(w.Destination) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PrivateIngressRule.Destination", err) + } + out.Destination = conv86 + conv87, err := IngressNetworkPolicy_AuthenticationToSDK(w.Authentication) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PrivateIngressRule.Authentication", err) + } + out.Authentication = conv87 + out.Label = w.Label + return out, nil +} + +// IngressNetworkPolicy_PrivateIngressRuleFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_PrivateIngressRuleFromSDK(v *sdk.IngressNetworkPolicy_PrivateIngressRule) (*IngressNetworkPolicy_PrivateIngressRule, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_PrivateIngressRule{} + conv88, err := IngressNetworkPolicy_PrivateRequestOriginFromSDK(v.Origin) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PrivateIngressRule.Origin", err) + } + out.Origin = conv88 + conv89, err := IngressNetworkPolicy_RequestDestinationFromSDK(v.Destination) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PrivateIngressRule.Destination", err) + } + out.Destination = conv89 + conv90, err := IngressNetworkPolicy_AuthenticationFromSDK(v.Authentication) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PrivateIngressRule.Authentication", err) + } + out.Authentication = conv90 + out.Label = v.Label + return out, nil +} + +// IngressNetworkPolicy_PrivateRequestOriginToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_PrivateRequestOriginToSDK(w *IngressNetworkPolicy_PrivateRequestOrigin) (*sdk.IngressNetworkPolicy_PrivateRequestOrigin, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_PrivateRequestOrigin{} + { + var members []string + if w.Endpoints != nil { + members = append(members, "endpoints") + } + if w.AllRegisteredEndpoints != nil { + members = append(members, "all_registered_endpoints") + } + if w.AzureWorkspacePrivateLink != nil { + members = append(members, "azure_workspace_private_link") + } + if w.AllPrivateAccess != nil { + members = append(members, "all_private_access") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Endpoints != nil: + conv91, err := IngressNetworkPolicy_EndpointsToSDK(w.Endpoints) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PrivateRequestOrigin.Source", err) + } + out.Source = &sdk.IngressNetworkPolicy_PrivateRequestOrigin_Source_Endpoints{Endpoints: *conv91} + case w.AllRegisteredEndpoints != nil: + out.Source = &sdk.IngressNetworkPolicy_PrivateRequestOrigin_Source_AllRegisteredEndpoints{AllRegisteredEndpoints: *w.AllRegisteredEndpoints} + case w.AzureWorkspacePrivateLink != nil: + out.Source = &sdk.IngressNetworkPolicy_PrivateRequestOrigin_Source_AzureWorkspacePrivateLink{AzureWorkspacePrivateLink: *w.AzureWorkspacePrivateLink} + case w.AllPrivateAccess != nil: + out.Source = &sdk.IngressNetworkPolicy_PrivateRequestOrigin_Source_AllPrivateAccess{AllPrivateAccess: *w.AllPrivateAccess} + } + return out, nil +} + +// IngressNetworkPolicy_PrivateRequestOriginFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_PrivateRequestOriginFromSDK(v *sdk.IngressNetworkPolicy_PrivateRequestOrigin) (*IngressNetworkPolicy_PrivateRequestOrigin, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_PrivateRequestOrigin{} + switch value := v.Source.(type) { + case *sdk.IngressNetworkPolicy_PrivateRequestOrigin_Source_Endpoints: + if value != nil { + conv92, err := IngressNetworkPolicy_EndpointsFromSDK(&value.Endpoints) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PrivateRequestOrigin.Source", err) + } + out.Endpoints = conv92 + } + case *sdk.IngressNetworkPolicy_PrivateRequestOrigin_Source_AllRegisteredEndpoints: + if value != nil { + out.AllRegisteredEndpoints = new(value.AllRegisteredEndpoints) + } + case *sdk.IngressNetworkPolicy_PrivateRequestOrigin_Source_AzureWorkspacePrivateLink: + if value != nil { + out.AzureWorkspacePrivateLink = new(value.AzureWorkspacePrivateLink) + } + case *sdk.IngressNetworkPolicy_PrivateRequestOrigin_Source_AllPrivateAccess: + if value != nil { + out.AllPrivateAccess = new(value.AllPrivateAccess) + } + } + return out, nil +} + +// IngressNetworkPolicy_PublicAccessToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_PublicAccessToSDK(w *IngressNetworkPolicy_PublicAccess) (*sdk.IngressNetworkPolicy_PublicAccess, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_PublicAccess{} + out.RestrictionMode = w.RestrictionMode + conv93, err := convertSlice(w.DenyRules, IngressNetworkPolicy_PublicIngressRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicAccess.DenyRules", err) + } + out.DenyRules = conv93 + conv94, err := convertSlice(w.AllowRules, IngressNetworkPolicy_PublicIngressRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicAccess.AllowRules", err) + } + out.AllowRules = conv94 + return out, nil +} + +// IngressNetworkPolicy_PublicAccessFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_PublicAccessFromSDK(v *sdk.IngressNetworkPolicy_PublicAccess) (*IngressNetworkPolicy_PublicAccess, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_PublicAccess{} + out.RestrictionMode = v.RestrictionMode + conv95, err := convertSlice(v.DenyRules, IngressNetworkPolicy_PublicIngressRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicAccess.DenyRules", err) + } + out.DenyRules = conv95 + conv96, err := convertSlice(v.AllowRules, IngressNetworkPolicy_PublicIngressRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicAccess.AllowRules", err) + } + out.AllowRules = conv96 + return out, nil +} + +// IngressNetworkPolicy_PublicIngressRuleToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_PublicIngressRuleToSDK(w *IngressNetworkPolicy_PublicIngressRule) (*sdk.IngressNetworkPolicy_PublicIngressRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_PublicIngressRule{} + conv97, err := IngressNetworkPolicy_PublicRequestOriginToSDK(w.Origin) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicIngressRule.Origin", err) + } + out.Origin = conv97 + conv98, err := IngressNetworkPolicy_RequestDestinationToSDK(w.Destination) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicIngressRule.Destination", err) + } + out.Destination = conv98 + conv99, err := IngressNetworkPolicy_AuthenticationToSDK(w.Authentication) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicIngressRule.Authentication", err) + } + out.Authentication = conv99 + out.Label = w.Label + return out, nil +} + +// IngressNetworkPolicy_PublicIngressRuleFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_PublicIngressRuleFromSDK(v *sdk.IngressNetworkPolicy_PublicIngressRule) (*IngressNetworkPolicy_PublicIngressRule, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_PublicIngressRule{} + conv100, err := IngressNetworkPolicy_PublicRequestOriginFromSDK(v.Origin) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicIngressRule.Origin", err) + } + out.Origin = conv100 + conv101, err := IngressNetworkPolicy_RequestDestinationFromSDK(v.Destination) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicIngressRule.Destination", err) + } + out.Destination = conv101 + conv102, err := IngressNetworkPolicy_AuthenticationFromSDK(v.Authentication) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicIngressRule.Authentication", err) + } + out.Authentication = conv102 + out.Label = v.Label + return out, nil +} + +// IngressNetworkPolicy_PublicRequestOriginToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_PublicRequestOriginToSDK(w *IngressNetworkPolicy_PublicRequestOrigin) (*sdk.IngressNetworkPolicy_PublicRequestOrigin, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_PublicRequestOrigin{} + { + var members []string + if w.AllIpRanges != nil { + members = append(members, "all_ip_ranges") + } + if w.IncludedIpRanges != nil { + members = append(members, "included_ip_ranges") + } + if w.ExcludedIpRanges != nil { + members = append(members, "excluded_ip_ranges") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AllIpRanges != nil: + out.Source = &sdk.IngressNetworkPolicy_PublicRequestOrigin_Source_AllIpRanges{AllIpRanges: *w.AllIpRanges} + case w.IncludedIpRanges != nil: + conv103, err := IngressNetworkPolicy_IpRangesToSDK(w.IncludedIpRanges) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicRequestOrigin.Source", err) + } + out.Source = &sdk.IngressNetworkPolicy_PublicRequestOrigin_Source_IncludedIpRanges{IncludedIpRanges: *conv103} + case w.ExcludedIpRanges != nil: + conv104, err := IngressNetworkPolicy_IpRangesToSDK(w.ExcludedIpRanges) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicRequestOrigin.Source", err) + } + out.Source = &sdk.IngressNetworkPolicy_PublicRequestOrigin_Source_ExcludedIpRanges{ExcludedIpRanges: *conv104} + } + return out, nil +} + +// IngressNetworkPolicy_PublicRequestOriginFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_PublicRequestOriginFromSDK(v *sdk.IngressNetworkPolicy_PublicRequestOrigin) (*IngressNetworkPolicy_PublicRequestOrigin, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_PublicRequestOrigin{} + switch value := v.Source.(type) { + case *sdk.IngressNetworkPolicy_PublicRequestOrigin_Source_AllIpRanges: + if value != nil { + out.AllIpRanges = new(value.AllIpRanges) + } + case *sdk.IngressNetworkPolicy_PublicRequestOrigin_Source_IncludedIpRanges: + if value != nil { + conv105, err := IngressNetworkPolicy_IpRangesFromSDK(&value.IncludedIpRanges) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicRequestOrigin.Source", err) + } + out.IncludedIpRanges = conv105 + } + case *sdk.IngressNetworkPolicy_PublicRequestOrigin_Source_ExcludedIpRanges: + if value != nil { + conv106, err := IngressNetworkPolicy_IpRangesFromSDK(&value.ExcludedIpRanges) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_PublicRequestOrigin.Source", err) + } + out.ExcludedIpRanges = conv106 + } + } + return out, nil +} + +// IngressNetworkPolicy_RequestDestinationToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_RequestDestinationToSDK(w *IngressNetworkPolicy_RequestDestination) (*sdk.IngressNetworkPolicy_RequestDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_RequestDestination{} + out.AllDestinations = w.AllDestinations + conv107, err := IngressNetworkPolicy_WorkspaceUiDestinationToSDK(w.WorkspaceUi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.WorkspaceUi", err) + } + out.WorkspaceUi = conv107 + conv108, err := IngressNetworkPolicy_WorkspaceApiDestinationToSDK(w.WorkspaceApi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.WorkspaceApi", err) + } + out.WorkspaceApi = conv108 + conv109, err := IngressNetworkPolicy_AppsRuntimeDestinationToSDK(w.AppsRuntime) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.AppsRuntime", err) + } + out.AppsRuntime = conv109 + conv110, err := IngressNetworkPolicy_LakebaseRuntimeDestinationToSDK(w.LakebaseRuntime) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.LakebaseRuntime", err) + } + out.LakebaseRuntime = conv110 + conv111, err := IngressNetworkPolicy_AccountUiDestinationToSDK(w.AccountUi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.AccountUi", err) + } + out.AccountUi = conv111 + conv112, err := IngressNetworkPolicy_AccountApiDestinationToSDK(w.AccountApi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.AccountApi", err) + } + out.AccountApi = conv112 + conv113, err := IngressNetworkPolicy_AccountDatabricksOneDestinationToSDK(w.AccountDatabricksOne) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.AccountDatabricksOne", err) + } + out.AccountDatabricksOne = conv113 + return out, nil +} + +// IngressNetworkPolicy_RequestDestinationFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_RequestDestinationFromSDK(v *sdk.IngressNetworkPolicy_RequestDestination) (*IngressNetworkPolicy_RequestDestination, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_RequestDestination{} + out.AllDestinations = v.AllDestinations + conv114, err := IngressNetworkPolicy_WorkspaceUiDestinationFromSDK(v.WorkspaceUi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.WorkspaceUi", err) + } + out.WorkspaceUi = conv114 + conv115, err := IngressNetworkPolicy_WorkspaceApiDestinationFromSDK(v.WorkspaceApi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.WorkspaceApi", err) + } + out.WorkspaceApi = conv115 + conv116, err := IngressNetworkPolicy_AppsRuntimeDestinationFromSDK(v.AppsRuntime) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.AppsRuntime", err) + } + out.AppsRuntime = conv116 + conv117, err := IngressNetworkPolicy_LakebaseRuntimeDestinationFromSDK(v.LakebaseRuntime) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.LakebaseRuntime", err) + } + out.LakebaseRuntime = conv117 + conv118, err := IngressNetworkPolicy_AccountUiDestinationFromSDK(v.AccountUi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.AccountUi", err) + } + out.AccountUi = conv118 + conv119, err := IngressNetworkPolicy_AccountApiDestinationFromSDK(v.AccountApi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.AccountApi", err) + } + out.AccountApi = conv119 + conv120, err := IngressNetworkPolicy_AccountDatabricksOneDestinationFromSDK(v.AccountDatabricksOne) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngressNetworkPolicy_RequestDestination.AccountDatabricksOne", err) + } + out.AccountDatabricksOne = conv120 + return out, nil +} + +// IngressNetworkPolicy_WorkspaceApiDestinationToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_WorkspaceApiDestinationToSDK(w *IngressNetworkPolicy_WorkspaceApiDestination) (*sdk.IngressNetworkPolicy_WorkspaceApiDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_WorkspaceApiDestination{} + out.Scopes = w.Scopes + out.ScopeQualifier = w.ScopeQualifier + out.ExcludedScopes = w.ExcludedScopes + return out, nil +} + +// IngressNetworkPolicy_WorkspaceApiDestinationFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_WorkspaceApiDestinationFromSDK(v *sdk.IngressNetworkPolicy_WorkspaceApiDestination) (*IngressNetworkPolicy_WorkspaceApiDestination, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_WorkspaceApiDestination{} + out.Scopes = v.Scopes + out.ScopeQualifier = v.ScopeQualifier + out.ExcludedScopes = v.ExcludedScopes + return out, nil +} + +// IngressNetworkPolicy_WorkspaceIdListToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_WorkspaceIdListToSDK(w *IngressNetworkPolicy_WorkspaceIdList) (*sdk.IngressNetworkPolicy_WorkspaceIdList, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_WorkspaceIdList{} + out.WorkspaceIds = w.WorkspaceIds + return out, nil +} + +// IngressNetworkPolicy_WorkspaceIdListFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_WorkspaceIdListFromSDK(v *sdk.IngressNetworkPolicy_WorkspaceIdList) (*IngressNetworkPolicy_WorkspaceIdList, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_WorkspaceIdList{} + out.WorkspaceIds = v.WorkspaceIds + return out, nil +} + +// IngressNetworkPolicy_WorkspaceUiDestinationToSDK converts the mirror to the sdk-go type. +func IngressNetworkPolicy_WorkspaceUiDestinationToSDK(w *IngressNetworkPolicy_WorkspaceUiDestination) (*sdk.IngressNetworkPolicy_WorkspaceUiDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngressNetworkPolicy_WorkspaceUiDestination{} + out.AllDestinations = w.AllDestinations + return out, nil +} + +// IngressNetworkPolicy_WorkspaceUiDestinationFromSDK converts the sdk-go type to the mirror. +func IngressNetworkPolicy_WorkspaceUiDestinationFromSDK(v *sdk.IngressNetworkPolicy_WorkspaceUiDestination) (*IngressNetworkPolicy_WorkspaceUiDestination, error) { + if v == nil { + return nil, nil + } + out := &IngressNetworkPolicy_WorkspaceUiDestination{} + out.AllDestinations = v.AllDestinations + return out, nil +} + +// IpAccessListToSDK converts the mirror to the sdk-go type. +func IpAccessListToSDK(w *IpAccessList) (*sdk.IpAccessList, error) { + if w == nil { + return nil, nil + } + out := &sdk.IpAccessList{} + out.ListId = w.ListId + out.Label = w.Label + out.IpAddresses = w.IpAddresses + out.AddressCount = w.AddressCount + out.ListType = w.ListType + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.Enabled = w.Enabled + return out, nil +} + +// IpAccessListFromSDK converts the sdk-go type to the mirror. +func IpAccessListFromSDK(v *sdk.IpAccessList) (*IpAccessList, error) { + if v == nil { + return nil, nil + } + out := &IpAccessList{} + out.ListId = v.ListId + out.Label = v.Label + out.IpAddresses = v.IpAddresses + out.AddressCount = v.AddressCount + out.ListType = v.ListType + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.Enabled = v.Enabled + return out, nil +} + +// ListAccountIpAccessListsResponseToSDK converts the mirror to the sdk-go type. +func ListAccountIpAccessListsResponseToSDK(w *ListAccountIpAccessListsResponse) (*sdk.ListAccountIpAccessListsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAccountIpAccessListsResponse{} + conv121, err := convertSlice(w.IpAccessLists, AccountIpAccessListToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAccountIpAccessListsResponse.IpAccessLists", err) + } + out.IpAccessLists = conv121 + return out, nil +} + +// ListAccountIpAccessListsResponseFromSDK converts the sdk-go type to the mirror. +func ListAccountIpAccessListsResponseFromSDK(v *sdk.ListAccountIpAccessListsResponse) (*ListAccountIpAccessListsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAccountIpAccessListsResponse{} + conv122, err := convertSlice(v.IpAccessLists, AccountIpAccessListFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAccountIpAccessListsResponse.IpAccessLists", err) + } + out.IpAccessLists = conv122 + return out, nil +} + +// ListEndpointsRequestToSDK converts the mirror to the sdk-go type. +func ListEndpointsRequestToSDK(w *ListEndpointsRequest) (*sdk.ListEndpointsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEndpointsRequest{} + out.Parent = w.Parent + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListEndpointsRequestFromSDK converts the sdk-go type to the mirror. +func ListEndpointsRequestFromSDK(v *sdk.ListEndpointsRequest) (*ListEndpointsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListEndpointsRequest{} + out.Parent = v.Parent + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListEndpointsResponseToSDK converts the mirror to the sdk-go type. +func ListEndpointsResponseToSDK(w *ListEndpointsResponse) (*sdk.ListEndpointsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEndpointsResponse{} + conv123, err := convertSlice(w.Items, EndpointToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListEndpointsResponse.Items", err) + } + out.Items = conv123 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListEndpointsResponseFromSDK converts the sdk-go type to the mirror. +func ListEndpointsResponseFromSDK(v *sdk.ListEndpointsResponse) (*ListEndpointsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListEndpointsResponse{} + conv124, err := convertSlice(v.Items, EndpointFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListEndpointsResponse.Items", err) + } + out.Items = conv124 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListIpAccessListsResponseToSDK converts the mirror to the sdk-go type. +func ListIpAccessListsResponseToSDK(w *ListIpAccessListsResponse) (*sdk.ListIpAccessListsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListIpAccessListsResponse{} + conv125, err := convertSlice(w.IpAccessLists, IpAccessListToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListIpAccessListsResponse.IpAccessLists", err) + } + out.IpAccessLists = conv125 + return out, nil +} + +// ListIpAccessListsResponseFromSDK converts the sdk-go type to the mirror. +func ListIpAccessListsResponseFromSDK(v *sdk.ListIpAccessListsResponse) (*ListIpAccessListsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListIpAccessListsResponse{} + conv126, err := convertSlice(v.IpAccessLists, IpAccessListFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListIpAccessListsResponse.IpAccessLists", err) + } + out.IpAccessLists = conv126 + return out, nil +} + +// ListNccPrivateEndpointRulesRequestToSDK converts the mirror to the sdk-go type. +func ListNccPrivateEndpointRulesRequestToSDK(w *ListNccPrivateEndpointRulesRequest) (*sdk.ListNccPrivateEndpointRulesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListNccPrivateEndpointRulesRequest{} + out.AccountId = w.AccountId + out.NetworkConnectivityConfigId = w.NetworkConnectivityConfigId + out.PageToken = w.PageToken + return out, nil +} + +// ListNccPrivateEndpointRulesRequestFromSDK converts the sdk-go type to the mirror. +func ListNccPrivateEndpointRulesRequestFromSDK(v *sdk.ListNccPrivateEndpointRulesRequest) (*ListNccPrivateEndpointRulesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListNccPrivateEndpointRulesRequest{} + out.AccountId = v.AccountId + out.NetworkConnectivityConfigId = v.NetworkConnectivityConfigId + out.PageToken = v.PageToken + return out, nil +} + +// ListNccPrivateEndpointRulesResponseToSDK converts the mirror to the sdk-go type. +func ListNccPrivateEndpointRulesResponseToSDK(w *ListNccPrivateEndpointRulesResponse) (*sdk.ListNccPrivateEndpointRulesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListNccPrivateEndpointRulesResponse{} + conv127, err := convertSlice(w.Items, NccPrivateEndpointRuleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListNccPrivateEndpointRulesResponse.Items", err) + } + out.Items = conv127 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListNccPrivateEndpointRulesResponseFromSDK converts the sdk-go type to the mirror. +func ListNccPrivateEndpointRulesResponseFromSDK(v *sdk.ListNccPrivateEndpointRulesResponse) (*ListNccPrivateEndpointRulesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListNccPrivateEndpointRulesResponse{} + conv128, err := convertSlice(v.Items, NccPrivateEndpointRuleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListNccPrivateEndpointRulesResponse.Items", err) + } + out.Items = conv128 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListNetworkConnectivityConfigsRequestToSDK converts the mirror to the sdk-go type. +func ListNetworkConnectivityConfigsRequestToSDK(w *ListNetworkConnectivityConfigsRequest) (*sdk.ListNetworkConnectivityConfigsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListNetworkConnectivityConfigsRequest{} + out.AccountId = w.AccountId + out.PageToken = w.PageToken + return out, nil +} + +// ListNetworkConnectivityConfigsRequestFromSDK converts the sdk-go type to the mirror. +func ListNetworkConnectivityConfigsRequestFromSDK(v *sdk.ListNetworkConnectivityConfigsRequest) (*ListNetworkConnectivityConfigsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListNetworkConnectivityConfigsRequest{} + out.AccountId = v.AccountId + out.PageToken = v.PageToken + return out, nil +} + +// ListNetworkConnectivityConfigsResponseToSDK converts the mirror to the sdk-go type. +func ListNetworkConnectivityConfigsResponseToSDK(w *ListNetworkConnectivityConfigsResponse) (*sdk.ListNetworkConnectivityConfigsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListNetworkConnectivityConfigsResponse{} + conv129, err := convertSlice(w.Items, NetworkConnectivityConfigToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListNetworkConnectivityConfigsResponse.Items", err) + } + out.Items = conv129 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListNetworkConnectivityConfigsResponseFromSDK converts the sdk-go type to the mirror. +func ListNetworkConnectivityConfigsResponseFromSDK(v *sdk.ListNetworkConnectivityConfigsResponse) (*ListNetworkConnectivityConfigsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListNetworkConnectivityConfigsResponse{} + conv130, err := convertSlice(v.Items, NetworkConnectivityConfigFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListNetworkConnectivityConfigsResponse.Items", err) + } + out.Items = conv130 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListNetworkPoliciesRequestToSDK converts the mirror to the sdk-go type. +func ListNetworkPoliciesRequestToSDK(w *ListNetworkPoliciesRequest) (*sdk.ListNetworkPoliciesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListNetworkPoliciesRequest{} + out.AccountId = w.AccountId + out.PageToken = w.PageToken + return out, nil +} + +// ListNetworkPoliciesRequestFromSDK converts the sdk-go type to the mirror. +func ListNetworkPoliciesRequestFromSDK(v *sdk.ListNetworkPoliciesRequest) (*ListNetworkPoliciesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListNetworkPoliciesRequest{} + out.AccountId = v.AccountId + out.PageToken = v.PageToken + return out, nil +} + +// ListNetworkPoliciesResponseToSDK converts the mirror to the sdk-go type. +func ListNetworkPoliciesResponseToSDK(w *ListNetworkPoliciesResponse) (*sdk.ListNetworkPoliciesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListNetworkPoliciesResponse{} + conv131, err := convertSlice(w.Items, AccountNetworkPolicyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListNetworkPoliciesResponse.Items", err) + } + out.Items = conv131 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListNetworkPoliciesResponseFromSDK converts the sdk-go type to the mirror. +func ListNetworkPoliciesResponseFromSDK(v *sdk.ListNetworkPoliciesResponse) (*ListNetworkPoliciesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListNetworkPoliciesResponse{} + conv132, err := convertSlice(v.Items, AccountNetworkPolicyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListNetworkPoliciesResponse.Items", err) + } + out.Items = conv132 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// NccPrivateEndpointRuleToSDK converts the mirror to the sdk-go type. +func NccPrivateEndpointRuleToSDK(w *NccPrivateEndpointRule) (*sdk.NccPrivateEndpointRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.NccPrivateEndpointRule{} + out.RuleId = w.RuleId + out.NetworkConnectivityConfigId = w.NetworkConnectivityConfigId + out.ConnectionState = w.ConnectionState + out.DomainNames = w.DomainNames + out.CreationTime = w.CreationTime + out.UpdatedTime = w.UpdatedTime + out.Deactivated = w.Deactivated + out.DeactivatedAt = w.DeactivatedAt + out.ErrorMessage = w.ErrorMessage + out.ResourceId = w.ResourceId + out.GroupId = w.GroupId + out.EndpointName = w.EndpointName + out.AccountId = w.AccountId + out.EndpointService = w.EndpointService + out.ResourceNames = w.ResourceNames + out.VpcEndpointId = w.VpcEndpointId + out.Enabled = w.Enabled + { + var members []string + if w.GcpEndpoint != nil { + members = append(members, "gcp_endpoint") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.GcpEndpoint != nil: + conv133, err := GcpEndpointToSDK(w.GcpEndpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NccPrivateEndpointRule.Endpoint", err) + } + out.Endpoint = &sdk.NccPrivateEndpointRule_Endpoint_GcpEndpoint{GcpEndpoint: *conv133} + } + return out, nil +} + +// NccPrivateEndpointRuleFromSDK converts the sdk-go type to the mirror. +func NccPrivateEndpointRuleFromSDK(v *sdk.NccPrivateEndpointRule) (*NccPrivateEndpointRule, error) { + if v == nil { + return nil, nil + } + out := &NccPrivateEndpointRule{} + out.RuleId = v.RuleId + out.NetworkConnectivityConfigId = v.NetworkConnectivityConfigId + out.ConnectionState = v.ConnectionState + out.DomainNames = v.DomainNames + out.CreationTime = v.CreationTime + out.UpdatedTime = v.UpdatedTime + out.Deactivated = v.Deactivated + out.DeactivatedAt = v.DeactivatedAt + out.ErrorMessage = v.ErrorMessage + out.ResourceId = v.ResourceId + out.GroupId = v.GroupId + out.EndpointName = v.EndpointName + out.AccountId = v.AccountId + out.EndpointService = v.EndpointService + out.ResourceNames = v.ResourceNames + out.VpcEndpointId = v.VpcEndpointId + out.Enabled = v.Enabled + switch value := v.Endpoint.(type) { + case *sdk.NccPrivateEndpointRule_Endpoint_GcpEndpoint: + if value != nil { + conv134, err := GcpEndpointFromSDK(&value.GcpEndpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NccPrivateEndpointRule.Endpoint", err) + } + out.GcpEndpoint = conv134 + } + } + return out, nil +} + +// NetworkToSDK converts the mirror to the sdk-go type. +func NetworkToSDK(w *Network) (*sdk.Network, error) { + if w == nil { + return nil, nil + } + out := &sdk.Network{} + out.NetworkId = w.NetworkId + out.AccountId = w.AccountId + out.WorkspaceId = w.WorkspaceId + out.VpcId = w.VpcId + out.SubnetIds = w.SubnetIds + out.SecurityGroupIds = w.SecurityGroupIds + out.VpcStatus = w.VpcStatus + conv135, err := convertSlice(w.ErrorMessages, NetworkHealthToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Network.ErrorMessages", err) + } + out.ErrorMessages = conv135 + out.NetworkName = w.NetworkName + out.CreationTime = w.CreationTime + conv136, err := convertSlice(w.WarningMessages, NetworkWarningToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Network.WarningMessages", err) + } + out.WarningMessages = conv136 + conv137, err := NetworkVpcEndpointsToSDK(w.VpcEndpoints) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Network.VpcEndpoints", err) + } + out.VpcEndpoints = conv137 + { + var members []string + if w.GcpNetworkInfo != nil { + members = append(members, "gcp_network_info") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.GcpNetworkInfo != nil: + conv138, err := GcpNetworkInfoToSDK(w.GcpNetworkInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Network.NetworkInfo", err) + } + out.NetworkInfo = &sdk.Network_NetworkInfo_GcpNetworkInfo{GcpNetworkInfo: *conv138} + } + return out, nil +} + +// NetworkFromSDK converts the sdk-go type to the mirror. +func NetworkFromSDK(v *sdk.Network) (*Network, error) { + if v == nil { + return nil, nil + } + out := &Network{} + out.NetworkId = v.NetworkId + out.AccountId = v.AccountId + out.WorkspaceId = v.WorkspaceId + out.VpcId = v.VpcId + out.SubnetIds = v.SubnetIds + out.SecurityGroupIds = v.SecurityGroupIds + out.VpcStatus = v.VpcStatus + conv139, err := convertSlice(v.ErrorMessages, NetworkHealthFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Network.ErrorMessages", err) + } + out.ErrorMessages = conv139 + out.NetworkName = v.NetworkName + out.CreationTime = v.CreationTime + conv140, err := convertSlice(v.WarningMessages, NetworkWarningFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Network.WarningMessages", err) + } + out.WarningMessages = conv140 + conv141, err := NetworkVpcEndpointsFromSDK(v.VpcEndpoints) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Network.VpcEndpoints", err) + } + out.VpcEndpoints = conv141 + switch value := v.NetworkInfo.(type) { + case *sdk.Network_NetworkInfo_GcpNetworkInfo: + if value != nil { + conv142, err := GcpNetworkInfoFromSDK(&value.GcpNetworkInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Network.NetworkInfo", err) + } + out.GcpNetworkInfo = conv142 + } + } + return out, nil +} + +// NetworkConnectivityConfigToSDK converts the mirror to the sdk-go type. +func NetworkConnectivityConfigToSDK(w *NetworkConnectivityConfig) (*sdk.NetworkConnectivityConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.NetworkConnectivityConfig{} + out.NetworkConnectivityConfigId = w.NetworkConnectivityConfigId + out.AccountId = w.AccountId + out.Name = w.Name + out.Region = w.Region + conv143, err := CustomerFacingNetworkConnectivityConfigEgressConfigToSDK(w.EgressConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NetworkConnectivityConfig.EgressConfig", err) + } + out.EgressConfig = conv143 + out.UpdatedTime = w.UpdatedTime + out.CreationTime = w.CreationTime + return out, nil +} + +// NetworkConnectivityConfigFromSDK converts the sdk-go type to the mirror. +func NetworkConnectivityConfigFromSDK(v *sdk.NetworkConnectivityConfig) (*NetworkConnectivityConfig, error) { + if v == nil { + return nil, nil + } + out := &NetworkConnectivityConfig{} + out.NetworkConnectivityConfigId = v.NetworkConnectivityConfigId + out.AccountId = v.AccountId + out.Name = v.Name + out.Region = v.Region + conv144, err := CustomerFacingNetworkConnectivityConfigEgressConfigFromSDK(v.EgressConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NetworkConnectivityConfig.EgressConfig", err) + } + out.EgressConfig = conv144 + out.UpdatedTime = v.UpdatedTime + out.CreationTime = v.CreationTime + return out, nil +} + +// NetworkConnectivityConfigAwsPrivateEndpointRuleToSDK converts the mirror to the sdk-go type. +func NetworkConnectivityConfigAwsPrivateEndpointRuleToSDK(w *NetworkConnectivityConfigAwsPrivateEndpointRule) (*sdk.NetworkConnectivityConfigAwsPrivateEndpointRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.NetworkConnectivityConfigAwsPrivateEndpointRule{} + out.RuleId = w.RuleId + out.NetworkConnectivityConfigId = w.NetworkConnectivityConfigId + out.AccountId = w.AccountId + out.EndpointService = w.EndpointService + out.DomainNames = w.DomainNames + out.ResourceNames = w.ResourceNames + out.VpcEndpointId = w.VpcEndpointId + out.ConnectionState = w.ConnectionState + out.CreationTime = w.CreationTime + out.UpdatedTime = w.UpdatedTime + out.Deactivated = w.Deactivated + out.DeactivatedAt = w.DeactivatedAt + out.Enabled = w.Enabled + out.ErrorMessage = w.ErrorMessage + return out, nil +} + +// NetworkConnectivityConfigAwsPrivateEndpointRuleFromSDK converts the sdk-go type to the mirror. +func NetworkConnectivityConfigAwsPrivateEndpointRuleFromSDK(v *sdk.NetworkConnectivityConfigAwsPrivateEndpointRule) (*NetworkConnectivityConfigAwsPrivateEndpointRule, error) { + if v == nil { + return nil, nil + } + out := &NetworkConnectivityConfigAwsPrivateEndpointRule{} + out.RuleId = v.RuleId + out.NetworkConnectivityConfigId = v.NetworkConnectivityConfigId + out.AccountId = v.AccountId + out.EndpointService = v.EndpointService + out.DomainNames = v.DomainNames + out.ResourceNames = v.ResourceNames + out.VpcEndpointId = v.VpcEndpointId + out.ConnectionState = v.ConnectionState + out.CreationTime = v.CreationTime + out.UpdatedTime = v.UpdatedTime + out.Deactivated = v.Deactivated + out.DeactivatedAt = v.DeactivatedAt + out.Enabled = v.Enabled + out.ErrorMessage = v.ErrorMessage + return out, nil +} + +// NetworkConnectivityConfigAzurePrivateEndpointRuleToSDK converts the mirror to the sdk-go type. +func NetworkConnectivityConfigAzurePrivateEndpointRuleToSDK(w *NetworkConnectivityConfigAzurePrivateEndpointRule) (*sdk.NetworkConnectivityConfigAzurePrivateEndpointRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.NetworkConnectivityConfigAzurePrivateEndpointRule{} + out.RuleId = w.RuleId + out.NetworkConnectivityConfigId = w.NetworkConnectivityConfigId + out.ResourceId = w.ResourceId + out.GroupId = w.GroupId + out.EndpointName = w.EndpointName + out.ConnectionState = w.ConnectionState + out.CreationTime = w.CreationTime + out.UpdatedTime = w.UpdatedTime + out.Deactivated = w.Deactivated + out.DeactivatedAt = w.DeactivatedAt + out.DomainNames = w.DomainNames + out.ErrorMessage = w.ErrorMessage + return out, nil +} + +// NetworkConnectivityConfigAzurePrivateEndpointRuleFromSDK converts the sdk-go type to the mirror. +func NetworkConnectivityConfigAzurePrivateEndpointRuleFromSDK(v *sdk.NetworkConnectivityConfigAzurePrivateEndpointRule) (*NetworkConnectivityConfigAzurePrivateEndpointRule, error) { + if v == nil { + return nil, nil + } + out := &NetworkConnectivityConfigAzurePrivateEndpointRule{} + out.RuleId = v.RuleId + out.NetworkConnectivityConfigId = v.NetworkConnectivityConfigId + out.ResourceId = v.ResourceId + out.GroupId = v.GroupId + out.EndpointName = v.EndpointName + out.ConnectionState = v.ConnectionState + out.CreationTime = v.CreationTime + out.UpdatedTime = v.UpdatedTime + out.Deactivated = v.Deactivated + out.DeactivatedAt = v.DeactivatedAt + out.DomainNames = v.DomainNames + out.ErrorMessage = v.ErrorMessage + return out, nil +} + +// NetworkConnectivityConfigEgressConfig_DefaultRuleToSDK converts the mirror to the sdk-go type. +func NetworkConnectivityConfigEgressConfig_DefaultRuleToSDK(w *NetworkConnectivityConfigEgressConfig_DefaultRule) (*sdk.NetworkConnectivityConfigEgressConfig_DefaultRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.NetworkConnectivityConfigEgressConfig_DefaultRule{} + conv145, err := NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRuleToSDK(w.AzureServiceEndpointRule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NetworkConnectivityConfigEgressConfig_DefaultRule.AzureServiceEndpointRule", err) + } + out.AzureServiceEndpointRule = conv145 + conv146, err := NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRuleToSDK(w.AwsStableIpRule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NetworkConnectivityConfigEgressConfig_DefaultRule.AwsStableIpRule", err) + } + out.AwsStableIpRule = conv146 + return out, nil +} + +// NetworkConnectivityConfigEgressConfig_DefaultRuleFromSDK converts the sdk-go type to the mirror. +func NetworkConnectivityConfigEgressConfig_DefaultRuleFromSDK(v *sdk.NetworkConnectivityConfigEgressConfig_DefaultRule) (*NetworkConnectivityConfigEgressConfig_DefaultRule, error) { + if v == nil { + return nil, nil + } + out := &NetworkConnectivityConfigEgressConfig_DefaultRule{} + conv147, err := NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRuleFromSDK(v.AzureServiceEndpointRule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NetworkConnectivityConfigEgressConfig_DefaultRule.AzureServiceEndpointRule", err) + } + out.AzureServiceEndpointRule = conv147 + conv148, err := NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRuleFromSDK(v.AwsStableIpRule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NetworkConnectivityConfigEgressConfig_DefaultRule.AwsStableIpRule", err) + } + out.AwsStableIpRule = conv148 + return out, nil +} + +// NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRuleToSDK converts the mirror to the sdk-go type. +func NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRuleToSDK(w *NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRule) (*sdk.NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRule{} + out.CidrBlocks = w.CidrBlocks + return out, nil +} + +// NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRuleFromSDK converts the sdk-go type to the mirror. +func NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRuleFromSDK(v *sdk.NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRule) (*NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRule, error) { + if v == nil { + return nil, nil + } + out := &NetworkConnectivityConfigEgressConfig_DefaultRule_AwsStableIpRule{} + out.CidrBlocks = v.CidrBlocks + return out, nil +} + +// NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRuleToSDK converts the mirror to the sdk-go type. +func NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRuleToSDK(w *NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRule) (*sdk.NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRule{} + out.TargetRegion = w.TargetRegion + out.TargetServices = w.TargetServices + out.Subnets = w.Subnets + return out, nil +} + +// NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRuleFromSDK converts the sdk-go type to the mirror. +func NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRuleFromSDK(v *sdk.NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRule) (*NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRule, error) { + if v == nil { + return nil, nil + } + out := &NetworkConnectivityConfigEgressConfig_DefaultRule_AzureServiceEndpointRule{} + out.TargetRegion = v.TargetRegion + out.TargetServices = v.TargetServices + out.Subnets = v.Subnets + return out, nil +} + +// NetworkHealthToSDK converts the mirror to the sdk-go type. +func NetworkHealthToSDK(w *NetworkHealth) (*sdk.NetworkHealth, error) { + if w == nil { + return nil, nil + } + out := &sdk.NetworkHealth{} + out.ErrorType = w.ErrorType + out.ErrorMessage = w.ErrorMessage + return out, nil +} + +// NetworkHealthFromSDK converts the sdk-go type to the mirror. +func NetworkHealthFromSDK(v *sdk.NetworkHealth) (*NetworkHealth, error) { + if v == nil { + return nil, nil + } + out := &NetworkHealth{} + out.ErrorType = v.ErrorType + out.ErrorMessage = v.ErrorMessage + return out, nil +} + +// NetworkVpcEndpointsToSDK converts the mirror to the sdk-go type. +func NetworkVpcEndpointsToSDK(w *NetworkVpcEndpoints) (*sdk.NetworkVpcEndpoints, error) { + if w == nil { + return nil, nil + } + out := &sdk.NetworkVpcEndpoints{} + out.RestApi = w.RestApi + out.DataplaneRelay = w.DataplaneRelay + return out, nil +} + +// NetworkVpcEndpointsFromSDK converts the sdk-go type to the mirror. +func NetworkVpcEndpointsFromSDK(v *sdk.NetworkVpcEndpoints) (*NetworkVpcEndpoints, error) { + if v == nil { + return nil, nil + } + out := &NetworkVpcEndpoints{} + out.RestApi = v.RestApi + out.DataplaneRelay = v.DataplaneRelay + return out, nil +} + +// NetworkWarningToSDK converts the mirror to the sdk-go type. +func NetworkWarningToSDK(w *NetworkWarning) (*sdk.NetworkWarning, error) { + if w == nil { + return nil, nil + } + out := &sdk.NetworkWarning{} + out.WarningType = w.WarningType + out.WarningMessage = w.WarningMessage + return out, nil +} + +// NetworkWarningFromSDK converts the sdk-go type to the mirror. +func NetworkWarningFromSDK(v *sdk.NetworkWarning) (*NetworkWarning, error) { + if v == nil { + return nil, nil + } + out := &NetworkWarning{} + out.WarningType = v.WarningType + out.WarningMessage = v.WarningMessage + return out, nil +} + +// PrivateAccessSettingsToSDK converts the mirror to the sdk-go type. +func PrivateAccessSettingsToSDK(w *PrivateAccessSettings) (*sdk.PrivateAccessSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.PrivateAccessSettings{} + out.PrivateAccessSettingsId = w.PrivateAccessSettingsId + out.AccountId = w.AccountId + out.PrivateAccessSettingsName = w.PrivateAccessSettingsName + out.Region = w.Region + out.PublicAccessEnabled = w.PublicAccessEnabled + out.PrivateAccessLevel = w.PrivateAccessLevel + out.AllowedVpcEndpointIds = w.AllowedVpcEndpointIds + return out, nil +} + +// PrivateAccessSettingsFromSDK converts the sdk-go type to the mirror. +func PrivateAccessSettingsFromSDK(v *sdk.PrivateAccessSettings) (*PrivateAccessSettings, error) { + if v == nil { + return nil, nil + } + out := &PrivateAccessSettings{} + out.PrivateAccessSettingsId = v.PrivateAccessSettingsId + out.AccountId = v.AccountId + out.PrivateAccessSettingsName = v.PrivateAccessSettingsName + out.Region = v.Region + out.PublicAccessEnabled = v.PublicAccessEnabled + out.PrivateAccessLevel = v.PrivateAccessLevel + out.AllowedVpcEndpointIds = v.AllowedVpcEndpointIds + return out, nil +} + +// ReplaceAccountIpAccessListRequestToSDK converts the mirror to the sdk-go type. +func ReplaceAccountIpAccessListRequestToSDK(w *ReplaceAccountIpAccessListRequest) (*sdk.ReplaceAccountIpAccessListRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ReplaceAccountIpAccessListRequest{} + out.AccountId = w.AccountId + out.ListId = w.ListId + out.Label = w.Label + out.ListType = w.ListType + out.IpAddresses = w.IpAddresses + out.Enabled = w.Enabled + return out, nil +} + +// ReplaceAccountIpAccessListRequestFromSDK converts the sdk-go type to the mirror. +func ReplaceAccountIpAccessListRequestFromSDK(v *sdk.ReplaceAccountIpAccessListRequest) (*ReplaceAccountIpAccessListRequest, error) { + if v == nil { + return nil, nil + } + out := &ReplaceAccountIpAccessListRequest{} + out.AccountId = v.AccountId + out.ListId = v.ListId + out.Label = v.Label + out.ListType = v.ListType + out.IpAddresses = v.IpAddresses + out.Enabled = v.Enabled + return out, nil +} + +// ReplaceAccountIpAccessListResponseToSDK converts the mirror to the sdk-go type. +func ReplaceAccountIpAccessListResponseToSDK(w *ReplaceAccountIpAccessListResponse) (*sdk.ReplaceAccountIpAccessListResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ReplaceAccountIpAccessListResponse{} + conv149, err := AccountIpAccessListToSDK(w.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ReplaceAccountIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv149 + return out, nil +} + +// ReplaceAccountIpAccessListResponseFromSDK converts the sdk-go type to the mirror. +func ReplaceAccountIpAccessListResponseFromSDK(v *sdk.ReplaceAccountIpAccessListResponse) (*ReplaceAccountIpAccessListResponse, error) { + if v == nil { + return nil, nil + } + out := &ReplaceAccountIpAccessListResponse{} + conv150, err := AccountIpAccessListFromSDK(v.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ReplaceAccountIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv150 + return out, nil +} + +// ReplaceIpAccessListRequestToSDK converts the mirror to the sdk-go type. +func ReplaceIpAccessListRequestToSDK(w *ReplaceIpAccessListRequest) (*sdk.ReplaceIpAccessListRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ReplaceIpAccessListRequest{} + out.ListId = w.ListId + out.Label = w.Label + out.ListType = w.ListType + out.IpAddresses = w.IpAddresses + out.Enabled = w.Enabled + return out, nil +} + +// ReplaceIpAccessListRequestFromSDK converts the sdk-go type to the mirror. +func ReplaceIpAccessListRequestFromSDK(v *sdk.ReplaceIpAccessListRequest) (*ReplaceIpAccessListRequest, error) { + if v == nil { + return nil, nil + } + out := &ReplaceIpAccessListRequest{} + out.ListId = v.ListId + out.Label = v.Label + out.ListType = v.ListType + out.IpAddresses = v.IpAddresses + out.Enabled = v.Enabled + return out, nil +} + +// ReplaceIpAccessListResponseToSDK converts the mirror to the sdk-go type. +func ReplaceIpAccessListResponseToSDK(w *ReplaceIpAccessListResponse) (*sdk.ReplaceIpAccessListResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ReplaceIpAccessListResponse{} + conv151, err := IpAccessListToSDK(w.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ReplaceIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv151 + return out, nil +} + +// ReplaceIpAccessListResponseFromSDK converts the sdk-go type to the mirror. +func ReplaceIpAccessListResponseFromSDK(v *sdk.ReplaceIpAccessListResponse) (*ReplaceIpAccessListResponse, error) { + if v == nil { + return nil, nil + } + out := &ReplaceIpAccessListResponse{} + conv152, err := IpAccessListFromSDK(v.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ReplaceIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv152 + return out, nil +} + +// UpdateAccountIpAccessListRequestToSDK converts the mirror to the sdk-go type. +func UpdateAccountIpAccessListRequestToSDK(w *UpdateAccountIpAccessListRequest) (*sdk.UpdateAccountIpAccessListRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAccountIpAccessListRequest{} + out.AccountId = w.AccountId + out.ListId = w.ListId + out.Label = w.Label + out.ListType = w.ListType + out.IpAddresses = w.IpAddresses + out.Enabled = w.Enabled + return out, nil +} + +// UpdateAccountIpAccessListRequestFromSDK converts the sdk-go type to the mirror. +func UpdateAccountIpAccessListRequestFromSDK(v *sdk.UpdateAccountIpAccessListRequest) (*UpdateAccountIpAccessListRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateAccountIpAccessListRequest{} + out.AccountId = v.AccountId + out.ListId = v.ListId + out.Label = v.Label + out.ListType = v.ListType + out.IpAddresses = v.IpAddresses + out.Enabled = v.Enabled + return out, nil +} + +// UpdateAccountIpAccessListResponseToSDK converts the mirror to the sdk-go type. +func UpdateAccountIpAccessListResponseToSDK(w *UpdateAccountIpAccessListResponse) (*sdk.UpdateAccountIpAccessListResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAccountIpAccessListResponse{} + conv153, err := AccountIpAccessListToSDK(w.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv153 + return out, nil +} + +// UpdateAccountIpAccessListResponseFromSDK converts the sdk-go type to the mirror. +func UpdateAccountIpAccessListResponseFromSDK(v *sdk.UpdateAccountIpAccessListResponse) (*UpdateAccountIpAccessListResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateAccountIpAccessListResponse{} + conv154, err := AccountIpAccessListFromSDK(v.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv154 + return out, nil +} + +// UpdateIpAccessListRequestToSDK converts the mirror to the sdk-go type. +func UpdateIpAccessListRequestToSDK(w *UpdateIpAccessListRequest) (*sdk.UpdateIpAccessListRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateIpAccessListRequest{} + out.ListId = w.ListId + out.Label = w.Label + out.ListType = w.ListType + out.IpAddresses = w.IpAddresses + out.Enabled = w.Enabled + return out, nil +} + +// UpdateIpAccessListRequestFromSDK converts the sdk-go type to the mirror. +func UpdateIpAccessListRequestFromSDK(v *sdk.UpdateIpAccessListRequest) (*UpdateIpAccessListRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateIpAccessListRequest{} + out.ListId = v.ListId + out.Label = v.Label + out.ListType = v.ListType + out.IpAddresses = v.IpAddresses + out.Enabled = v.Enabled + return out, nil +} + +// UpdateIpAccessListResponseToSDK converts the mirror to the sdk-go type. +func UpdateIpAccessListResponseToSDK(w *UpdateIpAccessListResponse) (*sdk.UpdateIpAccessListResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateIpAccessListResponse{} + conv155, err := IpAccessListToSDK(w.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv155 + return out, nil +} + +// UpdateIpAccessListResponseFromSDK converts the sdk-go type to the mirror. +func UpdateIpAccessListResponseFromSDK(v *sdk.UpdateIpAccessListResponse) (*UpdateIpAccessListResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateIpAccessListResponse{} + conv156, err := IpAccessListFromSDK(v.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateIpAccessListResponse.IpAccessList", err) + } + out.IpAccessList = conv156 + return out, nil +} + +// UpdateNccPrivateEndpointRuleRequestToSDK converts the mirror to the sdk-go type. +func UpdateNccPrivateEndpointRuleRequestToSDK(w *UpdateNccPrivateEndpointRuleRequest) (*sdk.UpdateNccPrivateEndpointRuleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateNccPrivateEndpointRuleRequest{} + out.NetworkConnectivityConfigId = w.NetworkConnectivityConfigId + out.AccountId = w.AccountId + out.PrivateEndpointRuleId = w.PrivateEndpointRuleId + conv157, err := UpdatePrivateEndpointRuleToSDK(w.PrivateEndpointRule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateNccPrivateEndpointRuleRequest.PrivateEndpointRule", err) + } + out.PrivateEndpointRule = conv157 + mask158, err := fieldMaskFromString[sdk.UpdatePrivateEndpointRule](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateNccPrivateEndpointRuleRequest.UpdateMask", err) + } + out.UpdateMask = mask158 + return out, nil +} + +// UpdateNccPrivateEndpointRuleRequestFromSDK converts the sdk-go type to the mirror. +func UpdateNccPrivateEndpointRuleRequestFromSDK(v *sdk.UpdateNccPrivateEndpointRuleRequest) (*UpdateNccPrivateEndpointRuleRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateNccPrivateEndpointRuleRequest{} + out.NetworkConnectivityConfigId = v.NetworkConnectivityConfigId + out.AccountId = v.AccountId + out.PrivateEndpointRuleId = v.PrivateEndpointRuleId + conv159, err := UpdatePrivateEndpointRuleFromSDK(v.PrivateEndpointRule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateNccPrivateEndpointRuleRequest.PrivateEndpointRule", err) + } + out.PrivateEndpointRule = conv159 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateNetworkPolicyRequestToSDK converts the mirror to the sdk-go type. +func UpdateNetworkPolicyRequestToSDK(w *UpdateNetworkPolicyRequest) (*sdk.UpdateNetworkPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateNetworkPolicyRequest{} + out.NetworkPolicyId = w.NetworkPolicyId + out.AccountId = w.AccountId + conv160, err := AccountNetworkPolicyToSDK(w.NetworkPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateNetworkPolicyRequest.NetworkPolicy", err) + } + out.NetworkPolicy = conv160 + return out, nil +} + +// UpdateNetworkPolicyRequestFromSDK converts the sdk-go type to the mirror. +func UpdateNetworkPolicyRequestFromSDK(v *sdk.UpdateNetworkPolicyRequest) (*UpdateNetworkPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateNetworkPolicyRequest{} + out.NetworkPolicyId = v.NetworkPolicyId + out.AccountId = v.AccountId + conv161, err := AccountNetworkPolicyFromSDK(v.NetworkPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateNetworkPolicyRequest.NetworkPolicy", err) + } + out.NetworkPolicy = conv161 + return out, nil +} + +// UpdatePrivateAccessSettingsRequestToSDK converts the mirror to the sdk-go type. +func UpdatePrivateAccessSettingsRequestToSDK(w *UpdatePrivateAccessSettingsRequest) (*sdk.UpdatePrivateAccessSettingsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdatePrivateAccessSettingsRequest{} + conv162, err := PrivateAccessSettingsToSDK(w.CustomerFacingPrivateAccessSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePrivateAccessSettingsRequest.CustomerFacingPrivateAccessSettings", err) + } + out.CustomerFacingPrivateAccessSettings = conv162 + return out, nil +} + +// UpdatePrivateAccessSettingsRequestFromSDK converts the sdk-go type to the mirror. +func UpdatePrivateAccessSettingsRequestFromSDK(v *sdk.UpdatePrivateAccessSettingsRequest) (*UpdatePrivateAccessSettingsRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdatePrivateAccessSettingsRequest{} + conv163, err := PrivateAccessSettingsFromSDK(v.CustomerFacingPrivateAccessSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePrivateAccessSettingsRequest.CustomerFacingPrivateAccessSettings", err) + } + out.CustomerFacingPrivateAccessSettings = conv163 + return out, nil +} + +// UpdatePrivateEndpointRuleToSDK converts the mirror to the sdk-go type. +func UpdatePrivateEndpointRuleToSDK(w *UpdatePrivateEndpointRule) (*sdk.UpdatePrivateEndpointRule, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdatePrivateEndpointRule{} + out.RuleId = w.RuleId + out.NetworkConnectivityConfigId = w.NetworkConnectivityConfigId + out.ConnectionState = w.ConnectionState + out.DomainNames = w.DomainNames + out.CreationTime = w.CreationTime + out.UpdatedTime = w.UpdatedTime + out.Deactivated = w.Deactivated + out.DeactivatedAt = w.DeactivatedAt + out.ErrorMessage = w.ErrorMessage + out.ResourceId = w.ResourceId + out.GroupId = w.GroupId + out.EndpointName = w.EndpointName + out.AccountId = w.AccountId + out.EndpointService = w.EndpointService + out.ResourceNames = w.ResourceNames + out.VpcEndpointId = w.VpcEndpointId + out.Enabled = w.Enabled + { + var members []string + if w.GcpEndpoint != nil { + members = append(members, "gcp_endpoint") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.GcpEndpoint != nil: + conv164, err := GcpEndpointToSDK(w.GcpEndpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePrivateEndpointRule.Endpoint", err) + } + out.Endpoint = &sdk.UpdatePrivateEndpointRule_Endpoint_GcpEndpoint{GcpEndpoint: *conv164} + } + return out, nil +} + +// UpdatePrivateEndpointRuleFromSDK converts the sdk-go type to the mirror. +func UpdatePrivateEndpointRuleFromSDK(v *sdk.UpdatePrivateEndpointRule) (*UpdatePrivateEndpointRule, error) { + if v == nil { + return nil, nil + } + out := &UpdatePrivateEndpointRule{} + out.RuleId = v.RuleId + out.NetworkConnectivityConfigId = v.NetworkConnectivityConfigId + out.ConnectionState = v.ConnectionState + out.DomainNames = v.DomainNames + out.CreationTime = v.CreationTime + out.UpdatedTime = v.UpdatedTime + out.Deactivated = v.Deactivated + out.DeactivatedAt = v.DeactivatedAt + out.ErrorMessage = v.ErrorMessage + out.ResourceId = v.ResourceId + out.GroupId = v.GroupId + out.EndpointName = v.EndpointName + out.AccountId = v.AccountId + out.EndpointService = v.EndpointService + out.ResourceNames = v.ResourceNames + out.VpcEndpointId = v.VpcEndpointId + out.Enabled = v.Enabled + switch value := v.Endpoint.(type) { + case *sdk.UpdatePrivateEndpointRule_Endpoint_GcpEndpoint: + if value != nil { + conv165, err := GcpEndpointFromSDK(&value.GcpEndpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePrivateEndpointRule.Endpoint", err) + } + out.GcpEndpoint = conv165 + } + } + return out, nil +} + +// UpdateWorkspaceNetworkOptionRequestToSDK converts the mirror to the sdk-go type. +func UpdateWorkspaceNetworkOptionRequestToSDK(w *UpdateWorkspaceNetworkOptionRequest) (*sdk.UpdateWorkspaceNetworkOptionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateWorkspaceNetworkOptionRequest{} + out.AccountId = w.AccountId + out.WorkspaceId = w.WorkspaceId + conv166, err := WorkspaceNetworkOptionToSDK(w.WorkspaceNetworkOption) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceNetworkOptionRequest.WorkspaceNetworkOption", err) + } + out.WorkspaceNetworkOption = conv166 + return out, nil +} + +// UpdateWorkspaceNetworkOptionRequestFromSDK converts the sdk-go type to the mirror. +func UpdateWorkspaceNetworkOptionRequestFromSDK(v *sdk.UpdateWorkspaceNetworkOptionRequest) (*UpdateWorkspaceNetworkOptionRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateWorkspaceNetworkOptionRequest{} + out.AccountId = v.AccountId + out.WorkspaceId = v.WorkspaceId + conv167, err := WorkspaceNetworkOptionFromSDK(v.WorkspaceNetworkOption) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceNetworkOptionRequest.WorkspaceNetworkOption", err) + } + out.WorkspaceNetworkOption = conv167 + return out, nil +} + +// VpcEndpointToSDK converts the mirror to the sdk-go type. +func VpcEndpointToSDK(w *VpcEndpoint) (*sdk.VpcEndpoint, error) { + if w == nil { + return nil, nil + } + out := &sdk.VpcEndpoint{} + out.VpcEndpointId = w.VpcEndpointId + out.AccountId = w.AccountId + out.VpcEndpointName = w.VpcEndpointName + out.AwsVpcEndpointId = w.AwsVpcEndpointId + out.AwsEndpointServiceId = w.AwsEndpointServiceId + out.UseCase = w.UseCase + out.Region = w.Region + out.AwsAccountId = w.AwsAccountId + out.State = w.State + { + var members []string + if w.GcpVpcEndpointInfo != nil { + members = append(members, "gcp_vpc_endpoint_info") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.GcpVpcEndpointInfo != nil: + conv168, err := GcpVpcEndpointInfoToSDK(w.GcpVpcEndpointInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "VpcEndpoint.VpcEndpointInfo", err) + } + out.VpcEndpointInfo = &sdk.VpcEndpoint_VpcEndpointInfo_GcpVpcEndpointInfo{GcpVpcEndpointInfo: *conv168} + } + return out, nil +} + +// VpcEndpointFromSDK converts the sdk-go type to the mirror. +func VpcEndpointFromSDK(v *sdk.VpcEndpoint) (*VpcEndpoint, error) { + if v == nil { + return nil, nil + } + out := &VpcEndpoint{} + out.VpcEndpointId = v.VpcEndpointId + out.AccountId = v.AccountId + out.VpcEndpointName = v.VpcEndpointName + out.AwsVpcEndpointId = v.AwsVpcEndpointId + out.AwsEndpointServiceId = v.AwsEndpointServiceId + out.UseCase = v.UseCase + out.Region = v.Region + out.AwsAccountId = v.AwsAccountId + out.State = v.State + switch value := v.VpcEndpointInfo.(type) { + case *sdk.VpcEndpoint_VpcEndpointInfo_GcpVpcEndpointInfo: + if value != nil { + conv169, err := GcpVpcEndpointInfoFromSDK(&value.GcpVpcEndpointInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "VpcEndpoint.VpcEndpointInfo", err) + } + out.GcpVpcEndpointInfo = conv169 + } + } + return out, nil +} + +// WorkspaceNetworkOptionToSDK converts the mirror to the sdk-go type. +func WorkspaceNetworkOptionToSDK(w *WorkspaceNetworkOption) (*sdk.WorkspaceNetworkOption, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkspaceNetworkOption{} + out.NetworkPolicyId = w.NetworkPolicyId + out.WorkspaceId = w.WorkspaceId + return out, nil +} + +// WorkspaceNetworkOptionFromSDK converts the sdk-go type to the mirror. +func WorkspaceNetworkOptionFromSDK(v *sdk.WorkspaceNetworkOption) (*WorkspaceNetworkOption, error) { + if v == nil { + return nil, nil + } + out := &WorkspaceNetworkOption{} + out.NetworkPolicyId = v.NetworkPolicyId + out.WorkspaceId = v.WorkspaceId + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/notificationdestinations/v1/types.generated.go b/libs/sdktypes/notificationdestinations/v1/types.generated.go new file mode 100644 index 00000000000..ecc3afd197e --- /dev/null +++ b/libs/sdktypes/notificationdestinations/v1/types.generated.go @@ -0,0 +1,728 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/notificationdestinations/v1. DO NOT EDIT. + +package notificationdestinations + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/notificationdestinations/v1" + + strings "strings" +) + +type ( + DestinationType = sdk.DestinationType +) + +const ( + DestinationType_Unspecified = sdk.DestinationType_Unspecified + DestinationType_Slack = sdk.DestinationType_Slack + DestinationType_Email = sdk.DestinationType_Email + DestinationType_Webhook = sdk.DestinationType_Webhook + DestinationType_Pagerduty = sdk.DestinationType_Pagerduty + DestinationType_MicrosoftTeams = sdk.DestinationType_MicrosoftTeams + DestinationType_DatabricksAppSlack = sdk.DestinationType_DatabricksAppSlack + DestinationType_DatabricksAppTeams = sdk.DestinationType_DatabricksAppTeams +) + +type Config struct { + DatabricksAppSlack *DatabricksAppSlackConfig `json:"databricks_app_slack,omitempty"` + DatabricksAppTeams *DatabricksAppTeamsConfig `json:"databricks_app_teams,omitempty"` + Email *EmailConfig `json:"email,omitempty"` + GenericWebhook *GenericWebhookConfig `json:"generic_webhook,omitempty"` + MicrosoftTeams *MicrosoftTeamsConfig `json:"microsoft_teams,omitempty"` + Pagerduty *PagerdutyConfig `json:"pagerduty,omitempty"` + Slack *SlackConfig `json:"slack,omitempty"` +} + +type CreateNotificationDestinationRequest struct { + // The configuration for the notification destination. Must wrap EXACTLY one of + // the nested configs. + Config *Config `json:"config,omitempty"` + // The display name for the notification destination. + DisplayName *string `json:"display_name,omitempty"` +} + +// Slack channel reached through the Databricks app. The app must already be +// installed in the Slack workspace and connected to this Databricks workspace.. +type DatabricksAppSlackConfig struct { + // [Input-Only] Slack channel ID notifications are posted to. + ChannelId *string `json:"channel_id,omitempty"` + // [Output-Only] Whether channel ID is set. + ChannelIdSet *bool `json:"channel_id_set,omitempty"` + // [Input-Only] Slack workspace (team) ID the Databricks app is installed in. + TeamId *string `json:"team_id,omitempty"` + // [Output-Only] Whether team ID is set. + TeamIdSet *bool `json:"team_id_set,omitempty"` +} + +// Microsoft Teams channel reached through the Databricks app. The app must +// already be installed in the Microsoft 365 tenant and connected to this +// Databricks workspace.. +type DatabricksAppTeamsConfig struct { + // [Input-Only] Teams channel ID notifications are posted to. + ChannelId *string `json:"channel_id,omitempty"` + // [Output-Only] Whether channel ID is set. + ChannelIdSet *bool `json:"channel_id_set,omitempty"` + // [Input-Only] Microsoft Entra group ID of the team that owns the channel. + TeamId *string `json:"team_id,omitempty"` + // [Output-Only] Whether team ID is set. + TeamIdSet *bool `json:"team_id_set,omitempty"` + // [Input-Only] Microsoft Entra tenant ID of the Microsoft 365 tenant the app is + // installed in. + TenantId *string `json:"tenant_id,omitempty"` + // [Output-Only] Whether tenant ID is set. + TenantIdSet *bool `json:"tenant_id_set,omitempty"` +} + +type EmailConfig struct { + // Email addresses to notify. + Addresses []string `json:"addresses,omitempty"` +} + +type GenericWebhookConfig struct { + // [Input-Only][Optional] Password for webhook. + Password *string `json:"password,omitempty"` + // [Output-Only] Whether password is set. + PasswordSet *bool `json:"password_set,omitempty"` + // [Input-Only] URL for webhook. + Url *string `json:"url,omitempty"` + // [Output-Only] Whether URL is set. + UrlSet *bool `json:"url_set,omitempty"` + // [Input-Only][Optional] Username for webhook. + Username *string `json:"username,omitempty"` + // [Output-Only] Whether username is set. + UsernameSet *bool `json:"username_set,omitempty"` +} + +type ListNotificationDestinationsRequest struct { + PageSize *int64 `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListNotificationDestinationsResponse struct { + // Page token for next of results. + NextPageToken *string `json:"next_page_token,omitempty"` + Results []ListNotificationDestinationsResult `json:"results,omitempty"` +} + +type ListNotificationDestinationsResult struct { + // The configuration for the notification destination. Will be exactly one of + // the nested configs. Only returns for users with workspace admin permissions. + Config *Config `json:"config,omitempty"` + // [Output-only] The type of the notification destination. The type can not be + // changed once set. + DestinationType DestinationType `json:"destination_type,omitempty"` + // The display name for the notification destination. + DisplayName *string `json:"display_name,omitempty"` + // UUID identifying notification destination. + Id *string `json:"id,omitempty"` +} + +type MicrosoftTeamsConfig struct { + // [Input-Only] App ID for Microsoft Teams App. + AppId *string `json:"app_id,omitempty"` + // [Output-Only] Whether App ID is set. + AppIdSet *bool `json:"app_id_set,omitempty"` + // [Input-Only] Secret for Microsoft Teams App authentication. + AuthSecret *string `json:"auth_secret,omitempty"` + // [Output-Only] Whether secret is set. + AuthSecretSet *bool `json:"auth_secret_set,omitempty"` + // [Input-Only] Channel URL for Microsoft Teams App. + ChannelUrl *string `json:"channel_url,omitempty"` + // [Output-Only] Whether Channel URL is set. + ChannelUrlSet *bool `json:"channel_url_set,omitempty"` + // [Input-Only] Tenant ID for Microsoft Teams App. + TenantId *string `json:"tenant_id,omitempty"` + // [Output-Only] Whether Tenant ID is set. + TenantIdSet *bool `json:"tenant_id_set,omitempty"` + // [Input-Only] URL for Microsoft Teams webhook. + Url *string `json:"url,omitempty"` + // [Output-Only] Whether URL is set. + UrlSet *bool `json:"url_set,omitempty"` +} + +type NotificationDestination struct { + // The configuration for the notification destination. Will be exactly one of + // the nested configs. Only returns for users with workspace admin permissions. + Config *Config `json:"config,omitempty"` + // [Output-only] The type of the notification destination. The type can not be + // changed once set. + DestinationType DestinationType `json:"destination_type,omitempty"` + // The display name for the notification destination. + DisplayName *string `json:"display_name,omitempty"` + // UUID identifying notification destination. + Id *string `json:"id,omitempty"` +} + +type PagerdutyConfig struct { + // [Input-Only] Integration key for PagerDuty. + IntegrationKey *string `json:"integration_key,omitempty"` + // [Output-Only] Whether integration key is set. + IntegrationKeySet *bool `json:"integration_key_set,omitempty"` +} + +type SlackConfig struct { + // [Input-Only] Slack channel ID for notifications. + ChannelId *string `json:"channel_id,omitempty"` + // [Output-Only] Whether channel ID is set. + ChannelIdSet *bool `json:"channel_id_set,omitempty"` + // [Input-Only] OAuth token for Slack authentication. + OauthToken *string `json:"oauth_token,omitempty"` + // [Output-Only] Whether OAuth token is set. + OauthTokenSet *bool `json:"oauth_token_set,omitempty"` + // [Input-Only] URL for Slack destination. + Url *string `json:"url,omitempty"` + // [Output-Only] Whether URL is set. + UrlSet *bool `json:"url_set,omitempty"` +} + +type UpdateNotificationDestinationRequest struct { + // The configuration for the notification destination. Must wrap EXACTLY one of + // the nested configs. + Config *Config `json:"config,omitempty"` + // The display name for the notification destination. + DisplayName *string `json:"display_name,omitempty"` + // UUID identifying notification destination. + Id *string `json:"id,omitempty"` +} + +// ConfigToSDK converts the mirror to the sdk-go type. +func ConfigToSDK(w *Config) (*sdk.Config, error) { + if w == nil { + return nil, nil + } + out := &sdk.Config{} + { + var members []string + if w.Slack != nil { + members = append(members, "slack") + } + if w.Email != nil { + members = append(members, "email") + } + if w.GenericWebhook != nil { + members = append(members, "generic_webhook") + } + if w.Pagerduty != nil { + members = append(members, "pagerduty") + } + if w.MicrosoftTeams != nil { + members = append(members, "microsoft_teams") + } + if w.DatabricksAppSlack != nil { + members = append(members, "databricks_app_slack") + } + if w.DatabricksAppTeams != nil { + members = append(members, "databricks_app_teams") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Slack != nil: + conv1, err := SlackConfigToSDK(w.Slack) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.Config = &sdk.Config_Config_Slack{Slack: *conv1} + case w.Email != nil: + conv2, err := EmailConfigToSDK(w.Email) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.Config = &sdk.Config_Config_Email{Email: *conv2} + case w.GenericWebhook != nil: + conv3, err := GenericWebhookConfigToSDK(w.GenericWebhook) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.Config = &sdk.Config_Config_GenericWebhook{GenericWebhook: *conv3} + case w.Pagerduty != nil: + conv4, err := PagerdutyConfigToSDK(w.Pagerduty) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.Config = &sdk.Config_Config_Pagerduty{Pagerduty: *conv4} + case w.MicrosoftTeams != nil: + conv5, err := MicrosoftTeamsConfigToSDK(w.MicrosoftTeams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.Config = &sdk.Config_Config_MicrosoftTeams{MicrosoftTeams: *conv5} + case w.DatabricksAppSlack != nil: + conv6, err := DatabricksAppSlackConfigToSDK(w.DatabricksAppSlack) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.Config = &sdk.Config_Config_DatabricksAppSlack{DatabricksAppSlack: *conv6} + case w.DatabricksAppTeams != nil: + conv7, err := DatabricksAppTeamsConfigToSDK(w.DatabricksAppTeams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.Config = &sdk.Config_Config_DatabricksAppTeams{DatabricksAppTeams: *conv7} + } + return out, nil +} + +// ConfigFromSDK converts the sdk-go type to the mirror. +func ConfigFromSDK(v *sdk.Config) (*Config, error) { + if v == nil { + return nil, nil + } + out := &Config{} + switch value := v.Config.(type) { + case *sdk.Config_Config_Slack: + if value != nil { + conv8, err := SlackConfigFromSDK(&value.Slack) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.Slack = conv8 + } + case *sdk.Config_Config_Email: + if value != nil { + conv9, err := EmailConfigFromSDK(&value.Email) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.Email = conv9 + } + case *sdk.Config_Config_GenericWebhook: + if value != nil { + conv10, err := GenericWebhookConfigFromSDK(&value.GenericWebhook) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.GenericWebhook = conv10 + } + case *sdk.Config_Config_Pagerduty: + if value != nil { + conv11, err := PagerdutyConfigFromSDK(&value.Pagerduty) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.Pagerduty = conv11 + } + case *sdk.Config_Config_MicrosoftTeams: + if value != nil { + conv12, err := MicrosoftTeamsConfigFromSDK(&value.MicrosoftTeams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.MicrosoftTeams = conv12 + } + case *sdk.Config_Config_DatabricksAppSlack: + if value != nil { + conv13, err := DatabricksAppSlackConfigFromSDK(&value.DatabricksAppSlack) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.DatabricksAppSlack = conv13 + } + case *sdk.Config_Config_DatabricksAppTeams: + if value != nil { + conv14, err := DatabricksAppTeamsConfigFromSDK(&value.DatabricksAppTeams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Config.Config", err) + } + out.DatabricksAppTeams = conv14 + } + } + return out, nil +} + +// CreateNotificationDestinationRequestToSDK converts the mirror to the sdk-go type. +func CreateNotificationDestinationRequestToSDK(w *CreateNotificationDestinationRequest) (*sdk.CreateNotificationDestinationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateNotificationDestinationRequest{} + out.DisplayName = w.DisplayName + conv15, err := ConfigToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNotificationDestinationRequest.Config", err) + } + out.Config = conv15 + return out, nil +} + +// CreateNotificationDestinationRequestFromSDK converts the sdk-go type to the mirror. +func CreateNotificationDestinationRequestFromSDK(v *sdk.CreateNotificationDestinationRequest) (*CreateNotificationDestinationRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateNotificationDestinationRequest{} + out.DisplayName = v.DisplayName + conv16, err := ConfigFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateNotificationDestinationRequest.Config", err) + } + out.Config = conv16 + return out, nil +} + +// DatabricksAppSlackConfigToSDK converts the mirror to the sdk-go type. +func DatabricksAppSlackConfigToSDK(w *DatabricksAppSlackConfig) (*sdk.DatabricksAppSlackConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabricksAppSlackConfig{} + out.TeamId = w.TeamId + out.TeamIdSet = w.TeamIdSet + out.ChannelId = w.ChannelId + out.ChannelIdSet = w.ChannelIdSet + return out, nil +} + +// DatabricksAppSlackConfigFromSDK converts the sdk-go type to the mirror. +func DatabricksAppSlackConfigFromSDK(v *sdk.DatabricksAppSlackConfig) (*DatabricksAppSlackConfig, error) { + if v == nil { + return nil, nil + } + out := &DatabricksAppSlackConfig{} + out.TeamId = v.TeamId + out.TeamIdSet = v.TeamIdSet + out.ChannelId = v.ChannelId + out.ChannelIdSet = v.ChannelIdSet + return out, nil +} + +// DatabricksAppTeamsConfigToSDK converts the mirror to the sdk-go type. +func DatabricksAppTeamsConfigToSDK(w *DatabricksAppTeamsConfig) (*sdk.DatabricksAppTeamsConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabricksAppTeamsConfig{} + out.TenantId = w.TenantId + out.TenantIdSet = w.TenantIdSet + out.TeamId = w.TeamId + out.TeamIdSet = w.TeamIdSet + out.ChannelId = w.ChannelId + out.ChannelIdSet = w.ChannelIdSet + return out, nil +} + +// DatabricksAppTeamsConfigFromSDK converts the sdk-go type to the mirror. +func DatabricksAppTeamsConfigFromSDK(v *sdk.DatabricksAppTeamsConfig) (*DatabricksAppTeamsConfig, error) { + if v == nil { + return nil, nil + } + out := &DatabricksAppTeamsConfig{} + out.TenantId = v.TenantId + out.TenantIdSet = v.TenantIdSet + out.TeamId = v.TeamId + out.TeamIdSet = v.TeamIdSet + out.ChannelId = v.ChannelId + out.ChannelIdSet = v.ChannelIdSet + return out, nil +} + +// EmailConfigToSDK converts the mirror to the sdk-go type. +func EmailConfigToSDK(w *EmailConfig) (*sdk.EmailConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.EmailConfig{} + out.Addresses = w.Addresses + return out, nil +} + +// EmailConfigFromSDK converts the sdk-go type to the mirror. +func EmailConfigFromSDK(v *sdk.EmailConfig) (*EmailConfig, error) { + if v == nil { + return nil, nil + } + out := &EmailConfig{} + out.Addresses = v.Addresses + return out, nil +} + +// GenericWebhookConfigToSDK converts the mirror to the sdk-go type. +func GenericWebhookConfigToSDK(w *GenericWebhookConfig) (*sdk.GenericWebhookConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenericWebhookConfig{} + out.Url = w.Url + out.UrlSet = w.UrlSet + out.Username = w.Username + out.UsernameSet = w.UsernameSet + out.Password = w.Password + out.PasswordSet = w.PasswordSet + return out, nil +} + +// GenericWebhookConfigFromSDK converts the sdk-go type to the mirror. +func GenericWebhookConfigFromSDK(v *sdk.GenericWebhookConfig) (*GenericWebhookConfig, error) { + if v == nil { + return nil, nil + } + out := &GenericWebhookConfig{} + out.Url = v.Url + out.UrlSet = v.UrlSet + out.Username = v.Username + out.UsernameSet = v.UsernameSet + out.Password = v.Password + out.PasswordSet = v.PasswordSet + return out, nil +} + +// ListNotificationDestinationsRequestToSDK converts the mirror to the sdk-go type. +func ListNotificationDestinationsRequestToSDK(w *ListNotificationDestinationsRequest) (*sdk.ListNotificationDestinationsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListNotificationDestinationsRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListNotificationDestinationsRequestFromSDK converts the sdk-go type to the mirror. +func ListNotificationDestinationsRequestFromSDK(v *sdk.ListNotificationDestinationsRequest) (*ListNotificationDestinationsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListNotificationDestinationsRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListNotificationDestinationsResponseToSDK converts the mirror to the sdk-go type. +func ListNotificationDestinationsResponseToSDK(w *ListNotificationDestinationsResponse) (*sdk.ListNotificationDestinationsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListNotificationDestinationsResponse{} + conv17, err := convertSlice(w.Results, ListNotificationDestinationsResultToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListNotificationDestinationsResponse.Results", err) + } + out.Results = conv17 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListNotificationDestinationsResponseFromSDK converts the sdk-go type to the mirror. +func ListNotificationDestinationsResponseFromSDK(v *sdk.ListNotificationDestinationsResponse) (*ListNotificationDestinationsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListNotificationDestinationsResponse{} + conv18, err := convertSlice(v.Results, ListNotificationDestinationsResultFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListNotificationDestinationsResponse.Results", err) + } + out.Results = conv18 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListNotificationDestinationsResultToSDK converts the mirror to the sdk-go type. +func ListNotificationDestinationsResultToSDK(w *ListNotificationDestinationsResult) (*sdk.ListNotificationDestinationsResult, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListNotificationDestinationsResult{} + out.Id = w.Id + out.DisplayName = w.DisplayName + out.DestinationType = w.DestinationType + conv19, err := ConfigToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListNotificationDestinationsResult.Config", err) + } + out.Config = conv19 + return out, nil +} + +// ListNotificationDestinationsResultFromSDK converts the sdk-go type to the mirror. +func ListNotificationDestinationsResultFromSDK(v *sdk.ListNotificationDestinationsResult) (*ListNotificationDestinationsResult, error) { + if v == nil { + return nil, nil + } + out := &ListNotificationDestinationsResult{} + out.Id = v.Id + out.DisplayName = v.DisplayName + out.DestinationType = v.DestinationType + conv20, err := ConfigFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListNotificationDestinationsResult.Config", err) + } + out.Config = conv20 + return out, nil +} + +// MicrosoftTeamsConfigToSDK converts the mirror to the sdk-go type. +func MicrosoftTeamsConfigToSDK(w *MicrosoftTeamsConfig) (*sdk.MicrosoftTeamsConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.MicrosoftTeamsConfig{} + out.Url = w.Url + out.UrlSet = w.UrlSet + out.AppId = w.AppId + out.AppIdSet = w.AppIdSet + out.AuthSecret = w.AuthSecret + out.AuthSecretSet = w.AuthSecretSet + out.ChannelUrl = w.ChannelUrl + out.ChannelUrlSet = w.ChannelUrlSet + out.TenantId = w.TenantId + out.TenantIdSet = w.TenantIdSet + return out, nil +} + +// MicrosoftTeamsConfigFromSDK converts the sdk-go type to the mirror. +func MicrosoftTeamsConfigFromSDK(v *sdk.MicrosoftTeamsConfig) (*MicrosoftTeamsConfig, error) { + if v == nil { + return nil, nil + } + out := &MicrosoftTeamsConfig{} + out.Url = v.Url + out.UrlSet = v.UrlSet + out.AppId = v.AppId + out.AppIdSet = v.AppIdSet + out.AuthSecret = v.AuthSecret + out.AuthSecretSet = v.AuthSecretSet + out.ChannelUrl = v.ChannelUrl + out.ChannelUrlSet = v.ChannelUrlSet + out.TenantId = v.TenantId + out.TenantIdSet = v.TenantIdSet + return out, nil +} + +// NotificationDestinationToSDK converts the mirror to the sdk-go type. +func NotificationDestinationToSDK(w *NotificationDestination) (*sdk.NotificationDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.NotificationDestination{} + out.Id = w.Id + out.DisplayName = w.DisplayName + out.DestinationType = w.DestinationType + conv21, err := ConfigToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NotificationDestination.Config", err) + } + out.Config = conv21 + return out, nil +} + +// NotificationDestinationFromSDK converts the sdk-go type to the mirror. +func NotificationDestinationFromSDK(v *sdk.NotificationDestination) (*NotificationDestination, error) { + if v == nil { + return nil, nil + } + out := &NotificationDestination{} + out.Id = v.Id + out.DisplayName = v.DisplayName + out.DestinationType = v.DestinationType + conv22, err := ConfigFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NotificationDestination.Config", err) + } + out.Config = conv22 + return out, nil +} + +// PagerdutyConfigToSDK converts the mirror to the sdk-go type. +func PagerdutyConfigToSDK(w *PagerdutyConfig) (*sdk.PagerdutyConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.PagerdutyConfig{} + out.IntegrationKey = w.IntegrationKey + out.IntegrationKeySet = w.IntegrationKeySet + return out, nil +} + +// PagerdutyConfigFromSDK converts the sdk-go type to the mirror. +func PagerdutyConfigFromSDK(v *sdk.PagerdutyConfig) (*PagerdutyConfig, error) { + if v == nil { + return nil, nil + } + out := &PagerdutyConfig{} + out.IntegrationKey = v.IntegrationKey + out.IntegrationKeySet = v.IntegrationKeySet + return out, nil +} + +// SlackConfigToSDK converts the mirror to the sdk-go type. +func SlackConfigToSDK(w *SlackConfig) (*sdk.SlackConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.SlackConfig{} + out.Url = w.Url + out.UrlSet = w.UrlSet + out.OauthToken = w.OauthToken + out.OauthTokenSet = w.OauthTokenSet + out.ChannelId = w.ChannelId + out.ChannelIdSet = w.ChannelIdSet + return out, nil +} + +// SlackConfigFromSDK converts the sdk-go type to the mirror. +func SlackConfigFromSDK(v *sdk.SlackConfig) (*SlackConfig, error) { + if v == nil { + return nil, nil + } + out := &SlackConfig{} + out.Url = v.Url + out.UrlSet = v.UrlSet + out.OauthToken = v.OauthToken + out.OauthTokenSet = v.OauthTokenSet + out.ChannelId = v.ChannelId + out.ChannelIdSet = v.ChannelIdSet + return out, nil +} + +// UpdateNotificationDestinationRequestToSDK converts the mirror to the sdk-go type. +func UpdateNotificationDestinationRequestToSDK(w *UpdateNotificationDestinationRequest) (*sdk.UpdateNotificationDestinationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateNotificationDestinationRequest{} + out.Id = w.Id + out.DisplayName = w.DisplayName + conv23, err := ConfigToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateNotificationDestinationRequest.Config", err) + } + out.Config = conv23 + return out, nil +} + +// UpdateNotificationDestinationRequestFromSDK converts the sdk-go type to the mirror. +func UpdateNotificationDestinationRequestFromSDK(v *sdk.UpdateNotificationDestinationRequest) (*UpdateNotificationDestinationRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateNotificationDestinationRequest{} + out.Id = v.Id + out.DisplayName = v.DisplayName + conv24, err := ConfigFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateNotificationDestinationRequest.Config", err) + } + out.Config = conv24 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/oauth/v1/types.generated.go b/libs/sdktypes/oauth/v1/types.generated.go new file mode 100644 index 00000000000..a1a678b2b33 --- /dev/null +++ b/libs/sdktypes/oauth/v1/types.generated.go @@ -0,0 +1,706 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/oauth/v1. DO NOT EDIT. + +package oauth + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/oauth/v1" +) + +type CreateCustomOAuthAppIntegrationRequest struct { + AccountId *string `json:"account_id,omitempty"` + // This field indicates whether an OAuth client secret is required to + // authenticate this client. + Confidential *bool `json:"confidential,omitempty"` + // Name of the custom OAuth app + Name *string `json:"name,omitempty"` + // List of OAuth redirect urls + RedirectUrls []string `json:"redirect_urls,omitempty"` + // OAuth scopes granted to the application. Supported scopes: all-apis, sql, + // offline_access, openid, profile, email. + Scopes []string `json:"scopes,omitempty"` + // Token access policy + TokenAccessPolicy *TokenAccessPolicy `json:"token_access_policy,omitempty"` + // Scopes that will need to be consented by end user to mint the access token. + // If the user does not authorize the access token will not be minted. Must be a + // subset of scopes. + UserAuthorizedScopes []string `json:"user_authorized_scopes,omitempty"` +} + +type CreatePublishedOAuthAppIntegrationRequest struct { + AccountId *string `json:"account_id,omitempty"` + // App id of the OAuth published app integration. For example power-bi, + // tableau-deskop + AppId *string `json:"app_id,omitempty"` + // Token access policy + TokenAccessPolicy *TokenAccessPolicy `json:"token_access_policy,omitempty"` +} + +type CreatePublishedOAuthAppIntegrationResponse struct { + // Unique integration id for the published OAuth app + IntegrationId *string `json:"integration_id,omitempty"` +} + +type CustomOAuthAppIntegration struct { + // The client id of the custom OAuth app + ClientId *string `json:"client_id,omitempty"` + // This field indicates whether an OAuth client secret is required to + // authenticate this client. + Confidential *bool `json:"confidential,omitempty"` + CreateTime *string `json:"create_time,omitempty"` + CreatedBy *int64 `json:"created_by,omitempty"` + CreatorUsername *string `json:"creator_username,omitempty"` + // ID of this custom app + IntegrationId *string `json:"integration_id,omitempty"` + // The display name of the custom OAuth app + Name *string `json:"name,omitempty"` + // List of OAuth redirect urls + RedirectUrls []string `json:"redirect_urls,omitempty"` + Scopes []string `json:"scopes,omitempty"` + // Token access policy + TokenAccessPolicy *TokenAccessPolicy `json:"token_access_policy,omitempty"` + // Scopes that will need to be consented by end user to mint the access token. + // If the user does not authorize the access token will not be minted. Must be a + // subset of scopes. + UserAuthorizedScopes []string `json:"user_authorized_scopes,omitempty"` +} + +type CustomOAuthAppIntegrationSecret struct { + // OAuth client-id generated by the + ClientId *string `json:"client_id,omitempty"` + // OAuth client-secret generated by the . If this is a confidential + // OAuth app client-secret will be generated. + ClientSecret *string `json:"client_secret,omitempty"` + // Unique integration id for the custom OAuth app + IntegrationId *string `json:"integration_id,omitempty"` +} + +type ListCustomOAuthAppIntegrationsRequest struct { + AccountId *string `json:"account_id,omitempty"` + IncludeCreatorUsername *bool `json:"include_creator_username,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListCustomOAuthAppIntegrationsResponse struct { + // List of Custom OAuth App Integrations defined for the account. + Apps []CustomOAuthAppIntegration `json:"apps,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListPublishedOAuthAppIntegrationsRequest struct { + AccountId *string `json:"account_id,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListPublishedOAuthAppIntegrationsResponse struct { + // List of Published OAuth App Integrations defined for the account. + Apps []PublishedOAuthAppIntegration `json:"apps,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListPublishedOAuthAppsRequest struct { + // The account ID. + AccountId *string `json:"account_id,omitempty"` + // The max number of OAuth published apps to return in one page. + PageSize *int `json:"page_size,omitempty"` + // A token that can be used to get the next page of results. + PageToken *string `json:"page_token,omitempty"` +} + +type ListPublishedOAuthAppsResponse struct { + // List of Published OAuth Apps. + Apps []PublishedOAuthApp `json:"apps,omitempty"` + // A token that can be used to get the next page of results. If not present, + // there are no more results to show. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type PublishedOAuthApp struct { + // Unique ID of the published OAuth app. + AppId *string `json:"app_id,omitempty"` + // Client ID of the published OAuth app. It is the client_id in the OAuth flow + ClientId *string `json:"client_id,omitempty"` + // Description of the published OAuth app. + Description *string `json:"description,omitempty"` + // Whether the published OAuth app is a confidential client. It is always false + // for published OAuth apps. + IsConfidentialClient *bool `json:"is_confidential_client,omitempty"` + // The display name of the published OAuth app. + Name *string `json:"name,omitempty"` + // Redirect URLs of the published OAuth app. + RedirectUrls []string `json:"redirect_urls,omitempty"` + // Required scopes for the published OAuth app. + Scopes []string `json:"scopes,omitempty"` +} + +type PublishedOAuthAppIntegration struct { + // App-id of the published app integration + AppId *string `json:"app_id,omitempty"` + CreateTime *string `json:"create_time,omitempty"` + CreatedBy *int64 `json:"created_by,omitempty"` + // Unique integration id for the published OAuth app + IntegrationId *string `json:"integration_id,omitempty"` + // Display name of the published OAuth app + Name *string `json:"name,omitempty"` + // Token access policy + TokenAccessPolicy *TokenAccessPolicy `json:"token_access_policy,omitempty"` +} + +type TokenAccessPolicy struct { + // Absolute OAuth session TTL in minutes. Effective only when the single-use + // refresh token feature is enabled. This is the absolute TTL of all refresh + // tokens issued in one OAuth session. When a new refresh token is issued during + // refresh token rotation, it will inherit the same absolute TTL as the old + // refresh token. In other words, this represents the maximum amount of time a + // user can stay logged in without re-authenticating. + AbsoluteSessionLifetimeInMinutes *int `json:"absolute_session_lifetime_in_minutes,omitempty"` + // access token time to live in minutes + AccessTokenTtlInMinutes *int `json:"access_token_ttl_in_minutes,omitempty"` + // Whether to enable single-use refresh tokens (refresh token rotation). If this + // feature is enabled, upon successfully getting a new access token using a + // refresh token, will issue a new refresh token along with the + // access token in the response and invalidate the old refresh token. The client + // should use the new refresh token to get access tokens in future requests. + EnableSingleUseRefreshTokens *bool `json:"enable_single_use_refresh_tokens,omitempty"` + // Refresh token time to live in minutes. When single-use refresh tokens are + // enabled, this represents the TTL of an individual refresh token. If the + // refresh token is used before it expires, a new one is issued with a renewed + // individual TTL. + RefreshTokenTtlInMinutes *int `json:"refresh_token_ttl_in_minutes,omitempty"` +} + +type UpdateCustomOAuthAppIntegrationRequest struct { + AccountId *string `json:"account_id,omitempty"` + IntegrationId *string `json:"integration_id,omitempty"` + // List of OAuth redirect urls to be updated in the custom OAuth app integration + RedirectUrls []string `json:"redirect_urls,omitempty"` + // List of OAuth scopes to be updated in the custom OAuth app integration, + // similar to redirect URIs this will fully replace the existing values instead + // of appending + Scopes []string `json:"scopes,omitempty"` + // Token access policy to be updated in the custom OAuth app integration + TokenAccessPolicy *TokenAccessPolicy `json:"token_access_policy,omitempty"` + // Scopes that will need to be consented by end user to mint the access token. + // If the user does not authorize the access token will not be minted. Must be a + // subset of scopes. + UserAuthorizedScopes []string `json:"user_authorized_scopes,omitempty"` +} + +type UpdatePublishedOAuthAppIntegrationRequest struct { + AccountId *string `json:"account_id,omitempty"` + IntegrationId *string `json:"integration_id,omitempty"` + // Token access policy to be updated in the published OAuth app integration + TokenAccessPolicy *TokenAccessPolicy `json:"token_access_policy,omitempty"` +} + +// CreateCustomOAuthAppIntegrationRequestToSDK converts the mirror to the sdk-go type. +func CreateCustomOAuthAppIntegrationRequestToSDK(w *CreateCustomOAuthAppIntegrationRequest) (*sdk.CreateCustomOAuthAppIntegrationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCustomOAuthAppIntegrationRequest{} + out.AccountId = w.AccountId + out.RedirectUrls = w.RedirectUrls + out.Name = w.Name + out.Confidential = w.Confidential + conv1, err := TokenAccessPolicyToSDK(w.TokenAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCustomOAuthAppIntegrationRequest.TokenAccessPolicy", err) + } + out.TokenAccessPolicy = conv1 + out.Scopes = w.Scopes + out.UserAuthorizedScopes = w.UserAuthorizedScopes + return out, nil +} + +// CreateCustomOAuthAppIntegrationRequestFromSDK converts the sdk-go type to the mirror. +func CreateCustomOAuthAppIntegrationRequestFromSDK(v *sdk.CreateCustomOAuthAppIntegrationRequest) (*CreateCustomOAuthAppIntegrationRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCustomOAuthAppIntegrationRequest{} + out.AccountId = v.AccountId + out.RedirectUrls = v.RedirectUrls + out.Name = v.Name + out.Confidential = v.Confidential + conv2, err := TokenAccessPolicyFromSDK(v.TokenAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCustomOAuthAppIntegrationRequest.TokenAccessPolicy", err) + } + out.TokenAccessPolicy = conv2 + out.Scopes = v.Scopes + out.UserAuthorizedScopes = v.UserAuthorizedScopes + return out, nil +} + +// CreatePublishedOAuthAppIntegrationRequestToSDK converts the mirror to the sdk-go type. +func CreatePublishedOAuthAppIntegrationRequestToSDK(w *CreatePublishedOAuthAppIntegrationRequest) (*sdk.CreatePublishedOAuthAppIntegrationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreatePublishedOAuthAppIntegrationRequest{} + out.AccountId = w.AccountId + out.AppId = w.AppId + conv3, err := TokenAccessPolicyToSDK(w.TokenAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePublishedOAuthAppIntegrationRequest.TokenAccessPolicy", err) + } + out.TokenAccessPolicy = conv3 + return out, nil +} + +// CreatePublishedOAuthAppIntegrationRequestFromSDK converts the sdk-go type to the mirror. +func CreatePublishedOAuthAppIntegrationRequestFromSDK(v *sdk.CreatePublishedOAuthAppIntegrationRequest) (*CreatePublishedOAuthAppIntegrationRequest, error) { + if v == nil { + return nil, nil + } + out := &CreatePublishedOAuthAppIntegrationRequest{} + out.AccountId = v.AccountId + out.AppId = v.AppId + conv4, err := TokenAccessPolicyFromSDK(v.TokenAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePublishedOAuthAppIntegrationRequest.TokenAccessPolicy", err) + } + out.TokenAccessPolicy = conv4 + return out, nil +} + +// CreatePublishedOAuthAppIntegrationResponseToSDK converts the mirror to the sdk-go type. +func CreatePublishedOAuthAppIntegrationResponseToSDK(w *CreatePublishedOAuthAppIntegrationResponse) (*sdk.CreatePublishedOAuthAppIntegrationResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreatePublishedOAuthAppIntegrationResponse{} + out.IntegrationId = w.IntegrationId + return out, nil +} + +// CreatePublishedOAuthAppIntegrationResponseFromSDK converts the sdk-go type to the mirror. +func CreatePublishedOAuthAppIntegrationResponseFromSDK(v *sdk.CreatePublishedOAuthAppIntegrationResponse) (*CreatePublishedOAuthAppIntegrationResponse, error) { + if v == nil { + return nil, nil + } + out := &CreatePublishedOAuthAppIntegrationResponse{} + out.IntegrationId = v.IntegrationId + return out, nil +} + +// CustomOAuthAppIntegrationToSDK converts the mirror to the sdk-go type. +func CustomOAuthAppIntegrationToSDK(w *CustomOAuthAppIntegration) (*sdk.CustomOAuthAppIntegration, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomOAuthAppIntegration{} + out.IntegrationId = w.IntegrationId + out.ClientId = w.ClientId + out.RedirectUrls = w.RedirectUrls + out.Name = w.Name + out.Confidential = w.Confidential + conv5, err := TokenAccessPolicyToSDK(w.TokenAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomOAuthAppIntegration.TokenAccessPolicy", err) + } + out.TokenAccessPolicy = conv5 + out.Scopes = w.Scopes + out.CreatedBy = w.CreatedBy + out.CreateTime = w.CreateTime + out.CreatorUsername = w.CreatorUsername + out.UserAuthorizedScopes = w.UserAuthorizedScopes + return out, nil +} + +// CustomOAuthAppIntegrationFromSDK converts the sdk-go type to the mirror. +func CustomOAuthAppIntegrationFromSDK(v *sdk.CustomOAuthAppIntegration) (*CustomOAuthAppIntegration, error) { + if v == nil { + return nil, nil + } + out := &CustomOAuthAppIntegration{} + out.IntegrationId = v.IntegrationId + out.ClientId = v.ClientId + out.RedirectUrls = v.RedirectUrls + out.Name = v.Name + out.Confidential = v.Confidential + conv6, err := TokenAccessPolicyFromSDK(v.TokenAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CustomOAuthAppIntegration.TokenAccessPolicy", err) + } + out.TokenAccessPolicy = conv6 + out.Scopes = v.Scopes + out.CreatedBy = v.CreatedBy + out.CreateTime = v.CreateTime + out.CreatorUsername = v.CreatorUsername + out.UserAuthorizedScopes = v.UserAuthorizedScopes + return out, nil +} + +// CustomOAuthAppIntegrationSecretToSDK converts the mirror to the sdk-go type. +func CustomOAuthAppIntegrationSecretToSDK(w *CustomOAuthAppIntegrationSecret) (*sdk.CustomOAuthAppIntegrationSecret, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomOAuthAppIntegrationSecret{} + out.IntegrationId = w.IntegrationId + out.ClientId = w.ClientId + out.ClientSecret = w.ClientSecret + return out, nil +} + +// CustomOAuthAppIntegrationSecretFromSDK converts the sdk-go type to the mirror. +func CustomOAuthAppIntegrationSecretFromSDK(v *sdk.CustomOAuthAppIntegrationSecret) (*CustomOAuthAppIntegrationSecret, error) { + if v == nil { + return nil, nil + } + out := &CustomOAuthAppIntegrationSecret{} + out.IntegrationId = v.IntegrationId + out.ClientId = v.ClientId + out.ClientSecret = v.ClientSecret + return out, nil +} + +// ListCustomOAuthAppIntegrationsRequestToSDK converts the mirror to the sdk-go type. +func ListCustomOAuthAppIntegrationsRequestToSDK(w *ListCustomOAuthAppIntegrationsRequest) (*sdk.ListCustomOAuthAppIntegrationsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCustomOAuthAppIntegrationsRequest{} + out.AccountId = w.AccountId + out.PageToken = w.PageToken + out.PageSize = w.PageSize + out.IncludeCreatorUsername = w.IncludeCreatorUsername + return out, nil +} + +// ListCustomOAuthAppIntegrationsRequestFromSDK converts the sdk-go type to the mirror. +func ListCustomOAuthAppIntegrationsRequestFromSDK(v *sdk.ListCustomOAuthAppIntegrationsRequest) (*ListCustomOAuthAppIntegrationsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCustomOAuthAppIntegrationsRequest{} + out.AccountId = v.AccountId + out.PageToken = v.PageToken + out.PageSize = v.PageSize + out.IncludeCreatorUsername = v.IncludeCreatorUsername + return out, nil +} + +// ListCustomOAuthAppIntegrationsResponseToSDK converts the mirror to the sdk-go type. +func ListCustomOAuthAppIntegrationsResponseToSDK(w *ListCustomOAuthAppIntegrationsResponse) (*sdk.ListCustomOAuthAppIntegrationsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCustomOAuthAppIntegrationsResponse{} + conv7, err := convertSlice(w.Apps, CustomOAuthAppIntegrationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCustomOAuthAppIntegrationsResponse.Apps", err) + } + out.Apps = conv7 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCustomOAuthAppIntegrationsResponseFromSDK converts the sdk-go type to the mirror. +func ListCustomOAuthAppIntegrationsResponseFromSDK(v *sdk.ListCustomOAuthAppIntegrationsResponse) (*ListCustomOAuthAppIntegrationsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCustomOAuthAppIntegrationsResponse{} + conv8, err := convertSlice(v.Apps, CustomOAuthAppIntegrationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCustomOAuthAppIntegrationsResponse.Apps", err) + } + out.Apps = conv8 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListPublishedOAuthAppIntegrationsRequestToSDK converts the mirror to the sdk-go type. +func ListPublishedOAuthAppIntegrationsRequestToSDK(w *ListPublishedOAuthAppIntegrationsRequest) (*sdk.ListPublishedOAuthAppIntegrationsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPublishedOAuthAppIntegrationsRequest{} + out.AccountId = w.AccountId + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListPublishedOAuthAppIntegrationsRequestFromSDK converts the sdk-go type to the mirror. +func ListPublishedOAuthAppIntegrationsRequestFromSDK(v *sdk.ListPublishedOAuthAppIntegrationsRequest) (*ListPublishedOAuthAppIntegrationsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListPublishedOAuthAppIntegrationsRequest{} + out.AccountId = v.AccountId + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListPublishedOAuthAppIntegrationsResponseToSDK converts the mirror to the sdk-go type. +func ListPublishedOAuthAppIntegrationsResponseToSDK(w *ListPublishedOAuthAppIntegrationsResponse) (*sdk.ListPublishedOAuthAppIntegrationsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPublishedOAuthAppIntegrationsResponse{} + conv9, err := convertSlice(w.Apps, PublishedOAuthAppIntegrationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPublishedOAuthAppIntegrationsResponse.Apps", err) + } + out.Apps = conv9 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListPublishedOAuthAppIntegrationsResponseFromSDK converts the sdk-go type to the mirror. +func ListPublishedOAuthAppIntegrationsResponseFromSDK(v *sdk.ListPublishedOAuthAppIntegrationsResponse) (*ListPublishedOAuthAppIntegrationsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListPublishedOAuthAppIntegrationsResponse{} + conv10, err := convertSlice(v.Apps, PublishedOAuthAppIntegrationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPublishedOAuthAppIntegrationsResponse.Apps", err) + } + out.Apps = conv10 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListPublishedOAuthAppsRequestToSDK converts the mirror to the sdk-go type. +func ListPublishedOAuthAppsRequestToSDK(w *ListPublishedOAuthAppsRequest) (*sdk.ListPublishedOAuthAppsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPublishedOAuthAppsRequest{} + out.AccountId = w.AccountId + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListPublishedOAuthAppsRequestFromSDK converts the sdk-go type to the mirror. +func ListPublishedOAuthAppsRequestFromSDK(v *sdk.ListPublishedOAuthAppsRequest) (*ListPublishedOAuthAppsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListPublishedOAuthAppsRequest{} + out.AccountId = v.AccountId + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListPublishedOAuthAppsResponseToSDK converts the mirror to the sdk-go type. +func ListPublishedOAuthAppsResponseToSDK(w *ListPublishedOAuthAppsResponse) (*sdk.ListPublishedOAuthAppsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPublishedOAuthAppsResponse{} + conv11, err := convertSlice(w.Apps, PublishedOAuthAppToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPublishedOAuthAppsResponse.Apps", err) + } + out.Apps = conv11 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListPublishedOAuthAppsResponseFromSDK converts the sdk-go type to the mirror. +func ListPublishedOAuthAppsResponseFromSDK(v *sdk.ListPublishedOAuthAppsResponse) (*ListPublishedOAuthAppsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListPublishedOAuthAppsResponse{} + conv12, err := convertSlice(v.Apps, PublishedOAuthAppFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPublishedOAuthAppsResponse.Apps", err) + } + out.Apps = conv12 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// PublishedOAuthAppToSDK converts the mirror to the sdk-go type. +func PublishedOAuthAppToSDK(w *PublishedOAuthApp) (*sdk.PublishedOAuthApp, error) { + if w == nil { + return nil, nil + } + out := &sdk.PublishedOAuthApp{} + out.AppId = w.AppId + out.ClientId = w.ClientId + out.Name = w.Name + out.Description = w.Description + out.IsConfidentialClient = w.IsConfidentialClient + out.RedirectUrls = w.RedirectUrls + out.Scopes = w.Scopes + return out, nil +} + +// PublishedOAuthAppFromSDK converts the sdk-go type to the mirror. +func PublishedOAuthAppFromSDK(v *sdk.PublishedOAuthApp) (*PublishedOAuthApp, error) { + if v == nil { + return nil, nil + } + out := &PublishedOAuthApp{} + out.AppId = v.AppId + out.ClientId = v.ClientId + out.Name = v.Name + out.Description = v.Description + out.IsConfidentialClient = v.IsConfidentialClient + out.RedirectUrls = v.RedirectUrls + out.Scopes = v.Scopes + return out, nil +} + +// PublishedOAuthAppIntegrationToSDK converts the mirror to the sdk-go type. +func PublishedOAuthAppIntegrationToSDK(w *PublishedOAuthAppIntegration) (*sdk.PublishedOAuthAppIntegration, error) { + if w == nil { + return nil, nil + } + out := &sdk.PublishedOAuthAppIntegration{} + out.AppId = w.AppId + out.IntegrationId = w.IntegrationId + out.Name = w.Name + conv13, err := TokenAccessPolicyToSDK(w.TokenAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PublishedOAuthAppIntegration.TokenAccessPolicy", err) + } + out.TokenAccessPolicy = conv13 + out.CreatedBy = w.CreatedBy + out.CreateTime = w.CreateTime + return out, nil +} + +// PublishedOAuthAppIntegrationFromSDK converts the sdk-go type to the mirror. +func PublishedOAuthAppIntegrationFromSDK(v *sdk.PublishedOAuthAppIntegration) (*PublishedOAuthAppIntegration, error) { + if v == nil { + return nil, nil + } + out := &PublishedOAuthAppIntegration{} + out.AppId = v.AppId + out.IntegrationId = v.IntegrationId + out.Name = v.Name + conv14, err := TokenAccessPolicyFromSDK(v.TokenAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PublishedOAuthAppIntegration.TokenAccessPolicy", err) + } + out.TokenAccessPolicy = conv14 + out.CreatedBy = v.CreatedBy + out.CreateTime = v.CreateTime + return out, nil +} + +// TokenAccessPolicyToSDK converts the mirror to the sdk-go type. +func TokenAccessPolicyToSDK(w *TokenAccessPolicy) (*sdk.TokenAccessPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.TokenAccessPolicy{} + out.AccessTokenTtlInMinutes = w.AccessTokenTtlInMinutes + out.RefreshTokenTtlInMinutes = w.RefreshTokenTtlInMinutes + out.EnableSingleUseRefreshTokens = w.EnableSingleUseRefreshTokens + out.AbsoluteSessionLifetimeInMinutes = w.AbsoluteSessionLifetimeInMinutes + return out, nil +} + +// TokenAccessPolicyFromSDK converts the sdk-go type to the mirror. +func TokenAccessPolicyFromSDK(v *sdk.TokenAccessPolicy) (*TokenAccessPolicy, error) { + if v == nil { + return nil, nil + } + out := &TokenAccessPolicy{} + out.AccessTokenTtlInMinutes = v.AccessTokenTtlInMinutes + out.RefreshTokenTtlInMinutes = v.RefreshTokenTtlInMinutes + out.EnableSingleUseRefreshTokens = v.EnableSingleUseRefreshTokens + out.AbsoluteSessionLifetimeInMinutes = v.AbsoluteSessionLifetimeInMinutes + return out, nil +} + +// UpdateCustomOAuthAppIntegrationRequestToSDK converts the mirror to the sdk-go type. +func UpdateCustomOAuthAppIntegrationRequestToSDK(w *UpdateCustomOAuthAppIntegrationRequest) (*sdk.UpdateCustomOAuthAppIntegrationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCustomOAuthAppIntegrationRequest{} + out.AccountId = w.AccountId + out.IntegrationId = w.IntegrationId + out.RedirectUrls = w.RedirectUrls + conv15, err := TokenAccessPolicyToSDK(w.TokenAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCustomOAuthAppIntegrationRequest.TokenAccessPolicy", err) + } + out.TokenAccessPolicy = conv15 + out.Scopes = w.Scopes + out.UserAuthorizedScopes = w.UserAuthorizedScopes + return out, nil +} + +// UpdateCustomOAuthAppIntegrationRequestFromSDK converts the sdk-go type to the mirror. +func UpdateCustomOAuthAppIntegrationRequestFromSDK(v *sdk.UpdateCustomOAuthAppIntegrationRequest) (*UpdateCustomOAuthAppIntegrationRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateCustomOAuthAppIntegrationRequest{} + out.AccountId = v.AccountId + out.IntegrationId = v.IntegrationId + out.RedirectUrls = v.RedirectUrls + conv16, err := TokenAccessPolicyFromSDK(v.TokenAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCustomOAuthAppIntegrationRequest.TokenAccessPolicy", err) + } + out.TokenAccessPolicy = conv16 + out.Scopes = v.Scopes + out.UserAuthorizedScopes = v.UserAuthorizedScopes + return out, nil +} + +// UpdatePublishedOAuthAppIntegrationRequestToSDK converts the mirror to the sdk-go type. +func UpdatePublishedOAuthAppIntegrationRequestToSDK(w *UpdatePublishedOAuthAppIntegrationRequest) (*sdk.UpdatePublishedOAuthAppIntegrationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdatePublishedOAuthAppIntegrationRequest{} + out.AccountId = w.AccountId + out.IntegrationId = w.IntegrationId + conv17, err := TokenAccessPolicyToSDK(w.TokenAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePublishedOAuthAppIntegrationRequest.TokenAccessPolicy", err) + } + out.TokenAccessPolicy = conv17 + return out, nil +} + +// UpdatePublishedOAuthAppIntegrationRequestFromSDK converts the sdk-go type to the mirror. +func UpdatePublishedOAuthAppIntegrationRequestFromSDK(v *sdk.UpdatePublishedOAuthAppIntegrationRequest) (*UpdatePublishedOAuthAppIntegrationRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdatePublishedOAuthAppIntegrationRequest{} + out.AccountId = v.AccountId + out.IntegrationId = v.IntegrationId + conv18, err := TokenAccessPolicyFromSDK(v.TokenAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePublishedOAuthAppIntegrationRequest.TokenAccessPolicy", err) + } + out.TokenAccessPolicy = conv18 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/packages.txt b/libs/sdktypes/packages.txt new file mode 100644 index 00000000000..bf7b0645b98 --- /dev/null +++ b/libs/sdktypes/packages.txt @@ -0,0 +1,89 @@ +accessmanagement/v1 accessmanagement +agentkit/v1 agentkit +aifunctions/v1 aifunctions +aigateway/v1 aigateway +aisearch/v1 aisearch +alerts/v1 alerts +alerts/v2 alerts +apps/v1 apps +authentication/v1 authentication +budgetpolicy/v1 budgetpolicy +budgets/v1 budgets +cleanrooms/v1 cleanrooms +clusterlibraries/v2 clusterlibraries +clusterpolicies/v2 clusterpolicies +clusters/v2 clusters +commandexecution/v2 commandexecution +customllms/v1 customllms +database/v1 database +dataclassification/v1 dataclassification +dataquality/v1 dataquality +disasterrecovery/v1 disasterrecovery +domains/v1 domains +environments/v1 environments +experiments/v1 experiments +features/v1 features +featurestore/v1 featurestore +files/v2 files +forecasting/v1 forecasting +genie/v1 genie +gitcredentials/v1 gitcredentials +globalinitscripts/v2 globalinitscripts +instancepools/v2 instancepools +instanceprofiles/v2 instanceprofiles +jobs/v2 jobs +keyconfigurations/v1 keyconfigurations +knowledgeassistants/v1 knowledgeassistants +lakeview/v1 lakeview +logdelivery/v1 logdelivery +marketplaces/v1 marketplaces +modelregistry/v1 modelregistry +modelserving/v1 modelserving +modelservingquery/v1 modelservingquery +networking/v1 networking +notificationdestinations/v1 notificationdestinations +oauth/v1 oauth +pipelines/v2 pipelines +policyfamilies/v2 policyfamilies +postgres/v1 postgres +queries/v1 queries +queryhistory/v1 queryhistory +repos/v1 repos +sandbox/v1 sandbox +scim/v1 scim +secrets/v1 secrets +settings/v2 settings +sharing/v1 sharing +statementexecution/v1 statementexecution +storageconfigurations/v1 storageconfigurations +supervisoragents/v1 supervisoragents +tagassignments/v1 tagassignments +tagpolicies/v1 tagpolicies +tokenmanagement/v1 tokenmanagement +tokens/v1 tokens +uc/abacpolicies/v1 abacpolicies +uc/artifactallowlists/v1 artifactallowlists +uc/catalogs/v1 catalogs +uc/connections/v1 connections +uc/credentials/v1 credentials +uc/entitytagassignments/v1 entitytagassignments +uc/externallineage/v1 externallineage +uc/externallocations/v1 externallocations +uc/externalmetadata/v1 externalmetadata +uc/functions/v1 functions +uc/grants/v1 grants +uc/metastores/v1 metastores +uc/onlinetables/v1 onlinetables +uc/registeredmodels/v1 registeredmodels +uc/resourcequotas/v1 resourcequotas +uc/rfa/v1 rfa +uc/schemas/v1 schemas +uc/secrets/v1 secrets +uc/systemschemas/v1 systemschemas +uc/tables/v1 tables +uc/volumes/v1 volumes +uc/workspacebindings/v1 workspacebindings +usagedashboards/v1 usagedashboards +vectorsearch/v1 vectorsearch +warehouses/v1 warehouses +workspaces/v1 workspaces diff --git a/libs/sdktypes/pipelines/v2/types.generated.go b/libs/sdktypes/pipelines/v2/types.generated.go new file mode 100644 index 00000000000..3afb88c1f5a --- /dev/null +++ b/libs/sdktypes/pipelines/v2/types.generated.go @@ -0,0 +1,6980 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/pipelines/v2. DO NOT EDIT. + +package pipelines + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/pipelines/v2" + + strings "strings" +) + +type ( + CloneMode = sdk.CloneMode + ConnectorType = sdk.ConnectorType + DayOfWeek = sdk.DayOfWeek + DeploymentKind = sdk.DeploymentKind + EventLevel = sdk.EventLevel + IngestionSourceType = sdk.IngestionSourceType + MaturityLevel = sdk.MaturityLevel + OutlookAttachmentMode = sdk.OutlookAttachmentMode + OutlookBodyFormat = sdk.OutlookBodyFormat + ParseMode = sdk.ParseMode + PipelineHealthStatus = sdk.PipelineHealthStatus + PipelinesAwsAvailability = sdk.PipelinesAwsAvailability + PipelinesAzureAvailability = sdk.PipelinesAzureAvailability + PipelinesEbsVolumeType = sdk.PipelinesEbsVolumeType + PipelinesGcpAvailability = sdk.PipelinesGcpAvailability + PublishingMode = sdk.PublishingMode + UpdateCause = sdk.UpdateCause + UpdateMode = sdk.UpdateMode + UpdateState = sdk.UpdateState + FileIngestionOptions_FileFormat = sdk.FileIngestionOptions_FileFormat + FileIngestionOptions_SchemaEvolutionMode = sdk.FileIngestionOptions_SchemaEvolutionMode + GoogleDriveOptions_GoogleDriveEntityType = sdk.GoogleDriveOptions_GoogleDriveEntityType + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity + PipelineState_PipelineState = sdk.PipelineState_PipelineState + ScdType_ScdType = sdk.ScdType_ScdType + SharepointOptions_SharepointEntityType = sdk.SharepointOptions_SharepointEntityType + TikTokAdsOptions_TikTokDataLevel = sdk.TikTokAdsOptions_TikTokDataLevel + TikTokAdsOptions_TikTokReportType = sdk.TikTokAdsOptions_TikTokReportType + Transformer_Format = sdk.Transformer_Format +) + +const ( + CloneMode_Unspecified = sdk.CloneMode_Unspecified + CloneMode_MigrateToUc = sdk.CloneMode_MigrateToUc + ConnectorType_Unspecified = sdk.ConnectorType_Unspecified + ConnectorType_Cdc = sdk.ConnectorType_Cdc + ConnectorType_QueryBased = sdk.ConnectorType_QueryBased + DayOfWeek_Unspecified = sdk.DayOfWeek_Unspecified + DayOfWeek_Monday = sdk.DayOfWeek_Monday + DayOfWeek_Tuesday = sdk.DayOfWeek_Tuesday + DayOfWeek_Wednesday = sdk.DayOfWeek_Wednesday + DayOfWeek_Thursday = sdk.DayOfWeek_Thursday + DayOfWeek_Friday = sdk.DayOfWeek_Friday + DayOfWeek_Saturday = sdk.DayOfWeek_Saturday + DayOfWeek_Sunday = sdk.DayOfWeek_Sunday + DeploymentKind_Unspecified = sdk.DeploymentKind_Unspecified + DeploymentKind_Bundle = sdk.DeploymentKind_Bundle + EventLevel_Unspecified = sdk.EventLevel_Unspecified + EventLevel_Info = sdk.EventLevel_Info + EventLevel_Warn = sdk.EventLevel_Warn + EventLevel_Error = sdk.EventLevel_Error + EventLevel_Metrics = sdk.EventLevel_Metrics + IngestionSourceType_Unspecified = sdk.IngestionSourceType_Unspecified + IngestionSourceType_Mysql = sdk.IngestionSourceType_Mysql + IngestionSourceType_Postgresql = sdk.IngestionSourceType_Postgresql + IngestionSourceType_Sqlserver = sdk.IngestionSourceType_Sqlserver + IngestionSourceType_Salesforce = sdk.IngestionSourceType_Salesforce + IngestionSourceType_Bigquery = sdk.IngestionSourceType_Bigquery + IngestionSourceType_Netsuite = sdk.IngestionSourceType_Netsuite + IngestionSourceType_WorkdayRaas = sdk.IngestionSourceType_WorkdayRaas + IngestionSourceType_Ga4RawData = sdk.IngestionSourceType_Ga4RawData + IngestionSourceType_Servicenow = sdk.IngestionSourceType_Servicenow + IngestionSourceType_ManagedPostgresql = sdk.IngestionSourceType_ManagedPostgresql + IngestionSourceType_Oracle = sdk.IngestionSourceType_Oracle + IngestionSourceType_Teradata = sdk.IngestionSourceType_Teradata + IngestionSourceType_Sharepoint = sdk.IngestionSourceType_Sharepoint + IngestionSourceType_Dynamics365 = sdk.IngestionSourceType_Dynamics365 + IngestionSourceType_GoogleDrive = sdk.IngestionSourceType_GoogleDrive + IngestionSourceType_Jira = sdk.IngestionSourceType_Jira + IngestionSourceType_Confluence = sdk.IngestionSourceType_Confluence + IngestionSourceType_MetaMarketing = sdk.IngestionSourceType_MetaMarketing + IngestionSourceType_TiktokAds = sdk.IngestionSourceType_TiktokAds + IngestionSourceType_Zendesk = sdk.IngestionSourceType_Zendesk + IngestionSourceType_Smartsheet = sdk.IngestionSourceType_Smartsheet + IngestionSourceType_Rabbitmq = sdk.IngestionSourceType_Rabbitmq + IngestionSourceType_ForeignCatalog = sdk.IngestionSourceType_ForeignCatalog + MaturityLevel_Unspecified = sdk.MaturityLevel_Unspecified + MaturityLevel_Evolving = sdk.MaturityLevel_Evolving + MaturityLevel_Deprecated = sdk.MaturityLevel_Deprecated + OutlookAttachmentMode_Unspecified = sdk.OutlookAttachmentMode_Unspecified + OutlookAttachmentMode_All = sdk.OutlookAttachmentMode_All + OutlookAttachmentMode_NonInlineOnly = sdk.OutlookAttachmentMode_NonInlineOnly + OutlookAttachmentMode_InlineOnly = sdk.OutlookAttachmentMode_InlineOnly + OutlookAttachmentMode_None = sdk.OutlookAttachmentMode_None + OutlookBodyFormat_Unspecified = sdk.OutlookBodyFormat_Unspecified + OutlookBodyFormat_TextHtml = sdk.OutlookBodyFormat_TextHtml + OutlookBodyFormat_TextPlain = sdk.OutlookBodyFormat_TextPlain + ParseMode_Unspecified = sdk.ParseMode_Unspecified + ParseMode_Failfast = sdk.ParseMode_Failfast + ParseMode_Permissive = sdk.ParseMode_Permissive + PipelineHealthStatus_Unspecified = sdk.PipelineHealthStatus_Unspecified + PipelineHealthStatus_Healthy = sdk.PipelineHealthStatus_Healthy + PipelineHealthStatus_Unhealthy = sdk.PipelineHealthStatus_Unhealthy + PipelinesAwsAvailability_Unspecified = sdk.PipelinesAwsAvailability_Unspecified + PipelinesAwsAvailability_Spot = sdk.PipelinesAwsAvailability_Spot + PipelinesAwsAvailability_OnDemand = sdk.PipelinesAwsAvailability_OnDemand + PipelinesAwsAvailability_SpotWithFallback = sdk.PipelinesAwsAvailability_SpotWithFallback + PipelinesAzureAvailability_Unspecified = sdk.PipelinesAzureAvailability_Unspecified + PipelinesAzureAvailability_SpotAzure = sdk.PipelinesAzureAvailability_SpotAzure + PipelinesAzureAvailability_OnDemandAzure = sdk.PipelinesAzureAvailability_OnDemandAzure + PipelinesAzureAvailability_SpotWithFallbackAzure = sdk.PipelinesAzureAvailability_SpotWithFallbackAzure + PipelinesEbsVolumeType_Unspecified = sdk.PipelinesEbsVolumeType_Unspecified + PipelinesEbsVolumeType_GeneralPurposeSsd = sdk.PipelinesEbsVolumeType_GeneralPurposeSsd + PipelinesEbsVolumeType_ThroughputOptimizedHdd = sdk.PipelinesEbsVolumeType_ThroughputOptimizedHdd + PipelinesGcpAvailability_Unspecified = sdk.PipelinesGcpAvailability_Unspecified + PipelinesGcpAvailability_PreemptibleGcp = sdk.PipelinesGcpAvailability_PreemptibleGcp + PipelinesGcpAvailability_OnDemandGcp = sdk.PipelinesGcpAvailability_OnDemandGcp + PipelinesGcpAvailability_PreemptibleWithFallbackGcp = sdk.PipelinesGcpAvailability_PreemptibleWithFallbackGcp + PublishingMode_Unspecified = sdk.PublishingMode_Unspecified + PublishingMode_LegacyPublishingMode = sdk.PublishingMode_LegacyPublishingMode + PublishingMode_DefaultPublishingMode = sdk.PublishingMode_DefaultPublishingMode + UpdateCause_Unspecified = sdk.UpdateCause_Unspecified + UpdateCause_ApiCall = sdk.UpdateCause_ApiCall + UpdateCause_RetryOnFailure = sdk.UpdateCause_RetryOnFailure + UpdateCause_ServiceUpgrade = sdk.UpdateCause_ServiceUpgrade + UpdateCause_SchemaChange = sdk.UpdateCause_SchemaChange + UpdateCause_JobTask = sdk.UpdateCause_JobTask + UpdateCause_UserAction = sdk.UpdateCause_UserAction + UpdateCause_InfrastructureMaintenance = sdk.UpdateCause_InfrastructureMaintenance + UpdateMode_Unspecified = sdk.UpdateMode_Unspecified + UpdateMode_Continuous = sdk.UpdateMode_Continuous + UpdateState_Unspecified = sdk.UpdateState_Unspecified + UpdateState_Queued = sdk.UpdateState_Queued + UpdateState_Created = sdk.UpdateState_Created + UpdateState_WaitingForResources = sdk.UpdateState_WaitingForResources + UpdateState_Initializing = sdk.UpdateState_Initializing + UpdateState_Resetting = sdk.UpdateState_Resetting + UpdateState_SettingUpTables = sdk.UpdateState_SettingUpTables + UpdateState_Running = sdk.UpdateState_Running + UpdateState_Stopping = sdk.UpdateState_Stopping + UpdateState_Completed = sdk.UpdateState_Completed + UpdateState_Failed = sdk.UpdateState_Failed + UpdateState_Canceled = sdk.UpdateState_Canceled + FileIngestionOptions_FileFormat_Unspecified = sdk.FileIngestionOptions_FileFormat_Unspecified + FileIngestionOptions_FileFormat_Binaryfile = sdk.FileIngestionOptions_FileFormat_Binaryfile + FileIngestionOptions_FileFormat_Json = sdk.FileIngestionOptions_FileFormat_Json + FileIngestionOptions_FileFormat_Csv = sdk.FileIngestionOptions_FileFormat_Csv + FileIngestionOptions_FileFormat_Xml = sdk.FileIngestionOptions_FileFormat_Xml + FileIngestionOptions_FileFormat_Excel = sdk.FileIngestionOptions_FileFormat_Excel + FileIngestionOptions_FileFormat_Parquet = sdk.FileIngestionOptions_FileFormat_Parquet + FileIngestionOptions_FileFormat_Avro = sdk.FileIngestionOptions_FileFormat_Avro + FileIngestionOptions_FileFormat_Orc = sdk.FileIngestionOptions_FileFormat_Orc + FileIngestionOptions_SchemaEvolutionMode_Unspecified = sdk.FileIngestionOptions_SchemaEvolutionMode_Unspecified + FileIngestionOptions_SchemaEvolutionMode_AddNewColumnsWithTypeWidening = sdk.FileIngestionOptions_SchemaEvolutionMode_AddNewColumnsWithTypeWidening + FileIngestionOptions_SchemaEvolutionMode_AddNewColumns = sdk.FileIngestionOptions_SchemaEvolutionMode_AddNewColumns + FileIngestionOptions_SchemaEvolutionMode_Rescue = sdk.FileIngestionOptions_SchemaEvolutionMode_Rescue + FileIngestionOptions_SchemaEvolutionMode_FailOnNewColumns = sdk.FileIngestionOptions_SchemaEvolutionMode_FailOnNewColumns + FileIngestionOptions_SchemaEvolutionMode_None = sdk.FileIngestionOptions_SchemaEvolutionMode_None + GoogleDriveOptions_GoogleDriveEntityType_Unspecified = sdk.GoogleDriveOptions_GoogleDriveEntityType_Unspecified + GoogleDriveOptions_GoogleDriveEntityType_File = sdk.GoogleDriveOptions_GoogleDriveEntityType_File + GoogleDriveOptions_GoogleDriveEntityType_FileMetadata = sdk.GoogleDriveOptions_GoogleDriveEntityType_FileMetadata + GoogleDriveOptions_GoogleDriveEntityType_Permission = sdk.GoogleDriveOptions_GoogleDriveEntityType_Permission + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity_Unspecified = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity_Unspecified + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity_Campaign = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity_Campaign + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity_Creative = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity_Creative + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity_CampaignGroup = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity_CampaignGroup + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder_Unspecified = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder_Unspecified + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder_Analytics = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder_Analytics + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder_Statistics = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder_Statistics + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder_AttributedRevenueMetrics = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder_AttributedRevenueMetrics + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity_Unspecified = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity_Unspecified + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity_All = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity_All + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity_Daily = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity_Daily + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity_Monthly = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity_Monthly + LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity_Yearly = sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity_Yearly + PipelineState_PipelineState_Unspecified = sdk.PipelineState_PipelineState_Unspecified + PipelineState_PipelineState_Deploying = sdk.PipelineState_PipelineState_Deploying + PipelineState_PipelineState_Starting = sdk.PipelineState_PipelineState_Starting + PipelineState_PipelineState_Running = sdk.PipelineState_PipelineState_Running + PipelineState_PipelineState_Stopping = sdk.PipelineState_PipelineState_Stopping + PipelineState_PipelineState_Deleted = sdk.PipelineState_PipelineState_Deleted + PipelineState_PipelineState_Recovering = sdk.PipelineState_PipelineState_Recovering + PipelineState_PipelineState_Failed = sdk.PipelineState_PipelineState_Failed + PipelineState_PipelineState_Resetting = sdk.PipelineState_PipelineState_Resetting + PipelineState_PipelineState_Idle = sdk.PipelineState_PipelineState_Idle + ScdType_ScdType_Unspecified = sdk.ScdType_ScdType_Unspecified + ScdType_ScdType_ScdType1 = sdk.ScdType_ScdType_ScdType1 + ScdType_ScdType_ScdType2 = sdk.ScdType_ScdType_ScdType2 + ScdType_ScdType_AppendOnly = sdk.ScdType_ScdType_AppendOnly + SharepointOptions_SharepointEntityType_Unspecified = sdk.SharepointOptions_SharepointEntityType_Unspecified + SharepointOptions_SharepointEntityType_File = sdk.SharepointOptions_SharepointEntityType_File + SharepointOptions_SharepointEntityType_FileMetadata = sdk.SharepointOptions_SharepointEntityType_FileMetadata + SharepointOptions_SharepointEntityType_Permission = sdk.SharepointOptions_SharepointEntityType_Permission + SharepointOptions_SharepointEntityType_List = sdk.SharepointOptions_SharepointEntityType_List + TikTokAdsOptions_TikTokDataLevel_Unspecified = sdk.TikTokAdsOptions_TikTokDataLevel_Unspecified + TikTokAdsOptions_TikTokDataLevel_AuctionAdvertiser = sdk.TikTokAdsOptions_TikTokDataLevel_AuctionAdvertiser + TikTokAdsOptions_TikTokDataLevel_AuctionCampaign = sdk.TikTokAdsOptions_TikTokDataLevel_AuctionCampaign + TikTokAdsOptions_TikTokDataLevel_AuctionAdgroup = sdk.TikTokAdsOptions_TikTokDataLevel_AuctionAdgroup + TikTokAdsOptions_TikTokDataLevel_AuctionAd = sdk.TikTokAdsOptions_TikTokDataLevel_AuctionAd + TikTokAdsOptions_TikTokReportType_Unspecified = sdk.TikTokAdsOptions_TikTokReportType_Unspecified + TikTokAdsOptions_TikTokReportType_Basic = sdk.TikTokAdsOptions_TikTokReportType_Basic + TikTokAdsOptions_TikTokReportType_Audience = sdk.TikTokAdsOptions_TikTokReportType_Audience + TikTokAdsOptions_TikTokReportType_PlayableAd = sdk.TikTokAdsOptions_TikTokReportType_PlayableAd + TikTokAdsOptions_TikTokReportType_Dsa = sdk.TikTokAdsOptions_TikTokReportType_Dsa + TikTokAdsOptions_TikTokReportType_BusinessCenter = sdk.TikTokAdsOptions_TikTokReportType_BusinessCenter + TikTokAdsOptions_TikTokReportType_GmvMax = sdk.TikTokAdsOptions_TikTokReportType_GmvMax + Transformer_Format_Unspecified = sdk.Transformer_Format_Unspecified + Transformer_Format_String = sdk.Transformer_Format_String + Transformer_Format_Json = sdk.Transformer_Format_Json + Transformer_Format_Avro = sdk.Transformer_Format_Avro + Transformer_Format_Protobuf = sdk.Transformer_Format_Protobuf +) + +// Top-level configuration for API Source connectors with arbitrary +// configuration.. +type ApiSourceConnectorConfig struct { + // Arbitrary key-value configuration values for the API Source connector. + Configs map[string]string `json:"configs,omitempty"` +} + +// Options for API Source connectors with arbitrary configuration.. +type ApiSourceConnectorOptions struct { + // Arbitrary key-value configuration options for the API Source connector. + Options map[string]string `json:"options,omitempty"` +} + +type ApplyEnvironmentRequest struct { + PipelineId *string `json:"pipeline_id,omitempty"` +} + +// Policy for auto full refresh.. +type AutoFullRefreshPolicy struct { + // (Required, Mutable) Whether to enable auto full refresh or not. + Enabled *bool `json:"enabled,omitempty"` + // (Optional, Mutable) Specify the minimum interval in hours between the + // timestamp at which a table was last full refreshed and the current timestamp + // for triggering auto full If unspecified and autoFullRefresh is enabled then + // by default min_interval_hours is 24 hours. + MinIntervalHours *int `json:"min_interval_hours,omitempty"` +} + +type AvroTransformerOptions struct { + // (Optional) Parse mode for Avro data. Valid values: FAILFAST, PERMISSIVE. + // Defaults to PERMISSIVE. + ParseMode ParseMode `json:"parse_mode,omitempty"` + // Inline Avro JSON schema string. + Schema *string `json:"schema,omitempty"` + // Path to a schema file (.avsc). + SchemaFilePath *string `json:"schema_file_path,omitempty"` + // (Optional) Schema registry to resolve the Avro schema at runtime instead of + // providing it inline or via a file path. + SchemaRegistry *SchemaRegistryConfig `json:"schema_registry,omitempty"` +} + +type ClonePipelineRequest struct { + // If false, deployment will fail if name conflicts with that of another + // pipeline. + AllowDuplicateNames *bool `json:"allow_duplicate_names,omitempty"` + // Budget policy of this pipeline. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // A catalog in Unity Catalog to publish data from this pipeline to. If `target` + // is specified, tables in this pipeline are published to a `target` schema + // inside `catalog` (for example, `catalog`.`target`.`table`). If `target` is + // not specified, no data is published to Unity Catalog. + Catalog *string `json:"catalog,omitempty"` + // SDP Release Channel that specifies which version to use. + Channel *string `json:"channel,omitempty"` + // The type of clone to perform. Currently, only deep copies are supported + CloneMode CloneMode `json:"clone_mode,omitempty"` + // Cluster settings for this pipeline deployment. Applies to classic + // (non-serverless) pipelines. Omit this field when `serverless` is `true`. + Clusters []PipelineCluster `json:"clusters,omitempty"` + // String-String configuration for this pipeline execution. + Configuration map[string]string `json:"configuration,omitempty"` + // Whether the pipeline is continuous or triggered. This replaces `trigger`. + // + // Deprecated: wrap the pipeline in a continuous job instead, which also lets + // you take advantage of job-level settings such as performance mode. When the + // pipeline is started by a continuous job, the job's setting takes precedence + // and this field is ignored. + Continuous *bool `json:"continuous,omitempty"` + // Deployment type of this pipeline. + Deployment *PipelineDeployment `json:"deployment,omitempty"` + // Whether the pipeline is in Development mode. Defaults to false. + // + // Deprecated: set development mode for each update instead. + Development *bool `json:"development,omitempty"` + // Pipeline product edition. + Edition *string `json:"edition,omitempty"` + // Environment specification for this pipeline used to install dependencies. + Environment *PipelinesEnvironment `json:"environment,omitempty"` + // Event log configuration for this pipeline + EventLog *EventLogSpec `json:"event_log,omitempty"` + // If present, the last-modified time of the pipeline settings before the clone. + // If the settings were modified after that time, then the request will fail + // with a conflict. + ExpectedLastModified *int64 `json:"expected_last_modified,omitempty"` + // Filters on which Pipeline packages to include in the deployed graph. + Filters *Filters `json:"filters,omitempty"` + // The definition of a gateway pipeline to support change data capture. + GatewayDefinition *IngestionGatewayPipelineDefinition `json:"gateway_definition,omitempty"` + // Unique identifier for this pipeline. + Id *string `json:"id,omitempty"` + // The configuration for a managed ingestion pipeline. These settings cannot be + // used with the 'libraries', 'schema', 'target', or 'catalog' settings. + IngestionDefinition *IngestionPipelineDefinition `json:"ingestion_definition,omitempty"` + // Libraries or code needed by this deployment. + Libraries []PipelineLibrary `json:"libraries,omitempty"` + // Friendly identifier for this pipeline. + Name *string `json:"name,omitempty"` + // List of notification settings for this pipeline. + Notifications []Notifications `json:"notifications,omitempty"` + // Path of the pipeline parent folder in workspace file tree. + // + // If absent, the pipeline doesn't have a workspace object. + ParentPath *string `json:"parent_path,omitempty"` + // Whether Photon is enabled for this pipeline. + Photon *bool `json:"photon,omitempty"` + // Source pipeline to clone from + PipelineId *string `json:"pipeline_id,omitempty"` + // Restart window of this pipeline. + RestartWindow *RestartWindow `json:"restart_window,omitempty"` + // Root path for this pipeline. This is used as the root directory when editing + // the pipeline in the user interface and it is added to sys.path + // when executing Python sources during pipeline execution. + RootPath *string `json:"root_path,omitempty"` + // The default schema (database) where tables are read from or published to. + Schema *string `json:"schema,omitempty"` + // Whether serverless compute is enabled for this pipeline. Serverless is the + // recommended compute for new pipelines; set this to `true` to run the pipeline + // on serverless. For notebook/file pipelines, omitting this field uses classic + // compute configured through the `clusters` field. When `true`, omit + // `clusters`; Photon is always enabled. + Serverless *bool `json:"serverless,omitempty"` + // Serverless compute ID specified by the user for serverless pipelines. + ServerlessComputeId *string `json:"serverless_compute_id,omitempty"` + // DBFS root directory for storing checkpoints and tables. + Storage *string `json:"storage,omitempty"` + // A map of tags associated with the pipeline. These are forwarded to the + // cluster as cluster tags, and are therefore subject to the same limitations. A + // maximum of 25 tags can be added to the pipeline. + Tags map[string]string `json:"tags,omitempty"` + // Target schema (database) to add tables in this pipeline to. Exactly one of + // `schema` or `target` must be specified. To publish to Unity Catalog, also + // specify `catalog`. This legacy field is deprecated for pipeline creation in + // favor of the `schema` field. + Target *string `json:"target,omitempty"` + // Which pipeline trigger to use. Deprecated: Use `continuous` instead. + Trigger *PipelineTrigger `json:"trigger,omitempty"` + // Usage policy of this pipeline. + UsagePolicyId *string `json:"usage_policy_id,omitempty"` +} + +type ClonePipelineResponse struct { + // The pipeline id of the cloned pipeline + PipelineId *string `json:"pipeline_id,omitempty"` +} + +// Confluence specific options for ingestion. +type ConfluenceConnectorOptions struct { + // (Optional) Spaces to filter Confluence data on + IncludeConfluenceSpaces []string `json:"include_confluence_spaces,omitempty"` +} + +type ConfluentSchemaRegistryOptions struct { + // Required: subject name to resolve in the registry. + Subject *string `json:"subject,omitempty"` +} + +type ConnectionParameters struct { + // Source catalog for initial connection. This is necessary for schema + // exploration in some database systems like Oracle, and optional but + // nice-to-have in some other database systems like Postgres. For Oracle + // databases, this maps to a service name. + SourceCatalog *string `json:"source_catalog,omitempty"` +} + +// Wrapper message for source-specific options to support multiple connector +// types. +type ConnectorOptions struct { + ApiSourceConnectorOptions *ApiSourceConnectorOptions `json:"api_source_connector_options,omitempty"` + ConfluenceOptions *ConfluenceConnectorOptions `json:"confluence_options,omitempty"` + GdriveOptions *GoogleDriveOptions `json:"gdrive_options,omitempty"` + GoogleAdsOptions *GoogleAdsOptions `json:"google_ads_options,omitempty"` + JiraOptions *JiraConnectorOptions `json:"jira_options,omitempty"` + KafkaOptions *KafkaOptions `json:"kafka_options,omitempty"` + LinkedinAdsOptions *LinkedInAdsOptions `json:"linkedin_ads_options,omitempty"` + MarketoOptions *MarketoOptions `json:"marketo_options,omitempty"` + MetaAdsOptions *MetaMarketingOptions `json:"meta_ads_options,omitempty"` + OutlookOptions *OutlookOptions `json:"outlook_options,omitempty"` + RabbitmqOptions *RabbitmqOptions `json:"rabbitmq_options,omitempty"` + RedditAdsOptions *RedditAdsOptions `json:"reddit_ads_options,omitempty"` + SharepointOptions *SharepointOptions `json:"sharepoint_options,omitempty"` + SmartsheetOptions *SmartsheetOptions `json:"smartsheet_options,omitempty"` + TiktokAdsOptions *TikTokAdsOptions `json:"tiktok_ads_options,omitempty"` + ZendeskSupportOptions *ZendeskSupportOptions `json:"zendesk_support_options,omitempty"` +} + +type CreatePipelineRequest struct { + // If false, deployment will fail if name conflicts with that of another + // pipeline. + AllowDuplicateNames *bool `json:"allow_duplicate_names,omitempty"` + // Budget policy of this pipeline. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // A catalog in Unity Catalog to publish data from this pipeline to. If `target` + // is specified, tables in this pipeline are published to a `target` schema + // inside `catalog` (for example, `catalog`.`target`.`table`). If `target` is + // not specified, no data is published to Unity Catalog. + Catalog *string `json:"catalog,omitempty"` + // SDP Release Channel that specifies which version to use. + Channel *string `json:"channel,omitempty"` + // Cluster settings for this pipeline deployment. Applies to classic + // (non-serverless) pipelines. Omit this field when `serverless` is `true`. + Clusters []PipelineCluster `json:"clusters,omitempty"` + // String-String configuration for this pipeline execution. + Configuration map[string]string `json:"configuration,omitempty"` + // Whether the pipeline is continuous or triggered. This replaces `trigger`. + // + // Deprecated: wrap the pipeline in a continuous job instead, which also lets + // you take advantage of job-level settings such as performance mode. When the + // pipeline is started by a continuous job, the job's setting takes precedence + // and this field is ignored. + Continuous *bool `json:"continuous,omitempty"` + // Deployment type of this pipeline. + Deployment *PipelineDeployment `json:"deployment,omitempty"` + // Whether the pipeline is in Development mode. Defaults to false. + // + // Deprecated: set development mode for each update instead. + Development *bool `json:"development,omitempty"` + DryRun *bool `json:"dry_run,omitempty"` + // Pipeline product edition. + Edition *string `json:"edition,omitempty"` + // Environment specification for this pipeline used to install dependencies. + Environment *PipelinesEnvironment `json:"environment,omitempty"` + // Event log configuration for this pipeline + EventLog *EventLogSpec `json:"event_log,omitempty"` + // Filters on which Pipeline packages to include in the deployed graph. + Filters *Filters `json:"filters,omitempty"` + // The definition of a gateway pipeline to support change data capture. + GatewayDefinition *IngestionGatewayPipelineDefinition `json:"gateway_definition,omitempty"` + // Unique identifier for this pipeline. + Id *string `json:"id,omitempty"` + // The configuration for a managed ingestion pipeline. These settings cannot be + // used with the 'libraries', 'schema', 'target', or 'catalog' settings. + IngestionDefinition *IngestionPipelineDefinition `json:"ingestion_definition,omitempty"` + // Libraries or code needed by this deployment. + Libraries []PipelineLibrary `json:"libraries,omitempty"` + // Friendly identifier for this pipeline. + Name *string `json:"name,omitempty"` + // List of notification settings for this pipeline. + Notifications []Notifications `json:"notifications,omitempty"` + // Key/value map of default parameters to use for pipeline execution. Maximum + // total size: 10k characters (JSON format) + Parameters map[string]string `json:"parameters,omitempty"` + // Path of the pipeline parent folder in workspace file tree. + // + // If absent, the pipeline doesn't have a workspace object. + ParentPath *string `json:"parent_path,omitempty"` + // Whether Photon is enabled for this pipeline. + Photon *bool `json:"photon,omitempty"` + // Restart window of this pipeline. + RestartWindow *RestartWindow `json:"restart_window,omitempty"` + // Root path for this pipeline. This is used as the root directory when editing + // the pipeline in the user interface and it is added to sys.path + // when executing Python sources during pipeline execution. + RootPath *string `json:"root_path,omitempty"` + RunAs *PipelinesJobRunAs `json:"run_as,omitempty"` + // The default schema (database) where tables are read from or published to. + Schema *string `json:"schema,omitempty"` + // Whether serverless compute is enabled for this pipeline. Serverless is the + // recommended compute for new pipelines; set this to `true` to run the pipeline + // on serverless. For notebook/file pipelines, omitting this field uses classic + // compute configured through the `clusters` field. When `true`, omit + // `clusters`; Photon is always enabled. + Serverless *bool `json:"serverless,omitempty"` + // Serverless compute ID specified by the user for serverless pipelines. + ServerlessComputeId *string `json:"serverless_compute_id,omitempty"` + // DBFS root directory for storing checkpoints and tables. + Storage *string `json:"storage,omitempty"` + // A map of tags associated with the pipeline. These are forwarded to the + // cluster as cluster tags, and are therefore subject to the same limitations. A + // maximum of 25 tags can be added to the pipeline. + Tags map[string]string `json:"tags,omitempty"` + // Target schema (database) to add tables in this pipeline to. Exactly one of + // `schema` or `target` must be specified. To publish to Unity Catalog, also + // specify `catalog`. This legacy field is deprecated for pipeline creation in + // favor of the `schema` field. + Target *string `json:"target,omitempty"` + // Which pipeline trigger to use. Deprecated: Use `continuous` instead. + Trigger *PipelineTrigger `json:"trigger,omitempty"` + // Usage policy of this pipeline. + UsagePolicyId *string `json:"usage_policy_id,omitempty"` +} + +type CreatePipelineResponse struct { + // Only returned when dry_run is true. + EffectiveSettings *PipelineSpec `json:"effective_settings,omitempty"` + // The unique identifier for the newly created pipeline. Only returned when + // dry_run is false. + PipelineId *string `json:"pipeline_id,omitempty"` +} + +type CronTrigger struct { + QuartzCronSchedule *string `json:"quartz_cron_schedule,omitempty"` + TimezoneId *string `json:"timezone_id,omitempty"` +} + +type DataPlaneId struct { + // The instance name of the data plane emitting an event. + Instance *string `json:"instance,omitempty"` + // A sequence number, unique and increasing within the data plane instance. + SeqNo *int64 `json:"seq_no,omitempty"` +} + +// Location of staged data storage. +type DataStagingOptions struct { + // (Required, Immutable) The name of the catalog for the connector's staging + // storage location. + CatalogName *string `json:"catalog_name,omitempty"` + // (Required, Immutable) The name of the schema for the connector's staging + // storage location. + SchemaName *string `json:"schema_name,omitempty"` + // (Optional) The Unity Catalog-compatible name for the storage location. This + // is the volume to use for the data that is extracted by the connector. Spark + // Declarative Pipelines system will automatically create the volume under the + // catalog and schema. For Combined Cdc Managed Ingestion pipelines default name + // for the volume would be : + // __databricks_ingestion_gateway_staging_data-$pipelineId + VolumeName *string `json:"volume_name,omitempty"` +} + +type DeletePipelineRequest struct { + // If false, pipeline deletion will not cascade to its datasets (MVs, STs, + // Views). By default, this parameter will be true and all tables will be + // deleted with the pipeline. + Cascade *bool `json:"cascade,omitempty"` + // If true, deletion will proceed even if resource cleanup fails. By default, + // deletion will fail if resources cleanup is required but fails. + Force *bool `json:"force,omitempty"` + PipelineId *string `json:"pipeline_id,omitempty"` +} + +type EditPipelineRequest struct { + // If false, deployment will fail if name has changed and conflicts the name of + // another pipeline. + AllowDuplicateNames *bool `json:"allow_duplicate_names,omitempty"` + // Budget policy of this pipeline. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // A catalog in Unity Catalog to publish data from this pipeline to. If `target` + // is specified, tables in this pipeline are published to a `target` schema + // inside `catalog` (for example, `catalog`.`target`.`table`). If `target` is + // not specified, no data is published to Unity Catalog. + Catalog *string `json:"catalog,omitempty"` + // SDP Release Channel that specifies which version to use. + Channel *string `json:"channel,omitempty"` + // Cluster settings for this pipeline deployment. Applies to classic + // (non-serverless) pipelines. Omit this field when `serverless` is `true`. + Clusters []PipelineCluster `json:"clusters,omitempty"` + // String-String configuration for this pipeline execution. + Configuration map[string]string `json:"configuration,omitempty"` + // Whether the pipeline is continuous or triggered. This replaces `trigger`. + // + // Deprecated: wrap the pipeline in a continuous job instead, which also lets + // you take advantage of job-level settings such as performance mode. When the + // pipeline is started by a continuous job, the job's setting takes precedence + // and this field is ignored. + Continuous *bool `json:"continuous,omitempty"` + // Deployment type of this pipeline. + Deployment *PipelineDeployment `json:"deployment,omitempty"` + // Whether the pipeline is in Development mode. Defaults to false. + // + // Deprecated: set development mode for each update instead. + Development *bool `json:"development,omitempty"` + // Pipeline product edition. + Edition *string `json:"edition,omitempty"` + // Environment specification for this pipeline used to install dependencies. + Environment *PipelinesEnvironment `json:"environment,omitempty"` + // Event log configuration for this pipeline + EventLog *EventLogSpec `json:"event_log,omitempty"` + // If present, the last-modified time of the pipeline settings before the edit. + // If the settings were modified after that time, then the request will fail + // with a conflict. + ExpectedLastModified *int64 `json:"expected_last_modified,omitempty"` + // Filters on which Pipeline packages to include in the deployed graph. + Filters *Filters `json:"filters,omitempty"` + // The definition of a gateway pipeline to support change data capture. + GatewayDefinition *IngestionGatewayPipelineDefinition `json:"gateway_definition,omitempty"` + // Unique identifier for this pipeline. + Id *string `json:"id,omitempty"` + // The configuration for a managed ingestion pipeline. These settings cannot be + // used with the 'libraries', 'schema', 'target', or 'catalog' settings. + IngestionDefinition *IngestionPipelineDefinition `json:"ingestion_definition,omitempty"` + // Libraries or code needed by this deployment. + Libraries []PipelineLibrary `json:"libraries,omitempty"` + // Friendly identifier for this pipeline. + Name *string `json:"name,omitempty"` + // List of notification settings for this pipeline. + Notifications []Notifications `json:"notifications,omitempty"` + // Key/value map of default parameters to use for pipeline execution. Maximum + // total size: 10k characters (JSON format) + Parameters map[string]string `json:"parameters,omitempty"` + // Path of the pipeline parent folder in workspace file tree. + // + // If absent, the pipeline doesn't have a workspace object. + ParentPath *string `json:"parent_path,omitempty"` + // Whether Photon is enabled for this pipeline. + Photon *bool `json:"photon,omitempty"` + // Unique identifier for this pipeline. + PipelineId *string `json:"pipeline_id,omitempty"` + // Restart window of this pipeline. + RestartWindow *RestartWindow `json:"restart_window,omitempty"` + // Root path for this pipeline. This is used as the root directory when editing + // the pipeline in the user interface and it is added to sys.path + // when executing Python sources during pipeline execution. + RootPath *string `json:"root_path,omitempty"` + RunAs *PipelinesJobRunAs `json:"run_as,omitempty"` + // The default schema (database) where tables are read from or published to. + Schema *string `json:"schema,omitempty"` + // Whether serverless compute is enabled for this pipeline. Serverless is the + // recommended compute for new pipelines; set this to `true` to run the pipeline + // on serverless. For notebook/file pipelines, omitting this field uses classic + // compute configured through the `clusters` field. When `true`, omit + // `clusters`; Photon is always enabled. + Serverless *bool `json:"serverless,omitempty"` + // Serverless compute ID specified by the user for serverless pipelines. + ServerlessComputeId *string `json:"serverless_compute_id,omitempty"` + // DBFS root directory for storing checkpoints and tables. + Storage *string `json:"storage,omitempty"` + // A map of tags associated with the pipeline. These are forwarded to the + // cluster as cluster tags, and are therefore subject to the same limitations. A + // maximum of 25 tags can be added to the pipeline. + Tags map[string]string `json:"tags,omitempty"` + // Target schema (database) to add tables in this pipeline to. Exactly one of + // `schema` or `target` must be specified. To publish to Unity Catalog, also + // specify `catalog`. This legacy field is deprecated for pipeline creation in + // favor of the `schema` field. + Target *string `json:"target,omitempty"` + // Which pipeline trigger to use. Deprecated: Use `continuous` instead. + Trigger *PipelineTrigger `json:"trigger,omitempty"` + // Usage policy of this pipeline. + UsagePolicyId *string `json:"usage_policy_id,omitempty"` +} + +type ErrorDetail struct { + // The exception thrown for this error, with its chain of cause. + Exceptions []SerializedException `json:"exceptions,omitempty"` + // Whether this error is considered fatal, that is, unrecoverable. + Fatal *bool `json:"fatal,omitempty"` +} + +// Configurable event log parameters.. +type EventLogSpec struct { + // The UC catalog the event log is published under. + Catalog *string `json:"catalog,omitempty"` + // The name the event log is published to in UC. + Name *string `json:"name,omitempty"` + // The UC schema the event log is published under. + Schema *string `json:"schema,omitempty"` +} + +type FileFilter struct { + ModifiedAfter *string `json:"modified_after,omitempty"` + ModifiedBefore *string `json:"modified_before,omitempty"` + PathFilter *string `json:"path_filter,omitempty"` +} + +type FileIngestionOptions struct { + CorruptRecordColumn *string `json:"corrupt_record_column,omitempty"` + // Generic options + FileFilters []FileFilter `json:"file_filters,omitempty"` + // required for TableSpec + Format FileIngestionOptions_FileFormat `json:"format,omitempty"` + // Format-specific options Based on + // https://docs.databricks.com/aws/en/ingestion/cloud-object-storage/auto-loader/options#file-format-options + FormatOptions map[string]string `json:"format_options,omitempty"` + IgnoreCorruptFiles *bool `json:"ignore_corrupt_files,omitempty"` + InferColumnTypes *bool `json:"infer_column_types,omitempty"` + // Column name case sensitivity + // https://docs.databricks.com/aws/en/ingestion/cloud-object-storage/auto-loader/schema#change-case-sensitive-behavior + ReaderCaseSensitive *bool `json:"reader_case_sensitive,omitempty"` + RescuedDataColumn *string `json:"rescued_data_column,omitempty"` + SchemaEvolutionMode FileIngestionOptions_SchemaEvolutionMode `json:"schema_evolution_mode,omitempty"` + // Override inferred schema of specific columns Based on + // https://docs.databricks.com/aws/en/ingestion/cloud-object-storage/auto-loader/schema#override-schema-inference-with-schema-hints + SchemaHints *string `json:"schema_hints,omitempty"` + SingleVariantColumn *string `json:"single_variant_column,omitempty"` +} + +type Filters struct { + // Paths to exclude. + Exclude []string `json:"exclude,omitempty"` + // Paths to include. + Include []string `json:"include,omitempty"` +} + +type GetPipelineResponse struct { + // An optional message detailing the cause of the pipeline state. + Cause *string `json:"cause,omitempty"` + // The ID of the cluster that the pipeline is running on. + ClusterId *string `json:"cluster_id,omitempty"` + // The username of the pipeline creator. + CreatorUserName *string `json:"creator_user_name,omitempty"` + // Serverless budget policy ID of this pipeline. + EffectiveBudgetPolicyId *string `json:"effective_budget_policy_id,omitempty"` + // Publishing mode of the pipeline + EffectivePublishingMode PublishingMode `json:"effective_publishing_mode,omitempty"` + // Serverless compute ID resolved for the pipeline. + EffectiveServerlessComputeId *string `json:"effective_serverless_compute_id,omitempty"` + // The health of a pipeline. + Health PipelineHealthStatus `json:"health,omitempty"` + // The last time the pipeline settings were modified or created. + LastModified *int64 `json:"last_modified,omitempty"` + // Status of the latest updates for the pipeline. Ordered with the newest update + // first. + LatestUpdates []UpdateStateInfo `json:"latest_updates,omitempty"` + // A human friendly identifier for the pipeline, taken from the `spec`. + Name *string `json:"name,omitempty"` + // Key/value map of default parameters to use for pipeline execution. Maximum + // total size: 10k characters (JSON format) + Parameters map[string]string `json:"parameters,omitempty"` + // The ID of the pipeline. + PipelineId *string `json:"pipeline_id,omitempty"` + // The user or service principal that the pipeline runs as, if specified in the + // request. This field indicates the explicit configuration of `run_as` for the + // pipeline. To find the value in all cases, explicit or implicit, use + // `run_as_user_name`. + RunAs *PipelinesJobRunAs `json:"run_as,omitempty"` + // Username of the user that the pipeline will run on behalf of. + RunAsUserName *string `json:"run_as_user_name,omitempty"` + // The pipeline specification. This field is not returned when called by + // `ListPipelines`. + Spec *PipelineSpec `json:"spec,omitempty"` + // The pipeline state. + State PipelineState_PipelineState `json:"state,omitempty"` +} + +type GetUpdateResponse struct { + // The current update info. + Update *UpdateInfo `json:"update,omitempty"` +} + +type GoogleAdsConfig struct { + // (Required) Manager Account ID (also called MCC Account ID) used to list and + // access customer accounts under this manager account. This is required for + // fetching the list of customer accounts during source selection. If the same + // field is also set in the object-level GoogleAdsOptions (connector_options), + // the object-level value takes precedence over this top-level config. + ManagerAccountId *string `json:"manager_account_id,omitempty"` +} + +// User-defined custom report for the Google Ads connector. Mirrors the resource +// + fields + segments + metrics model that Google Ads GAQL exposes. The +// customer account this report runs against is supplied by the source schema +// (namespace), not by this message. The whole message is gated by the parent +// GoogleAdsOptions.custom_report_options stage; per-field stage annotations are +// intentionally omitted. Only supported on table-type objects: a custom report +// requires a destination table, so it cannot be specified at the schema/source +// level.. +type GoogleAdsCustomReportOptions struct { + // (Optional) Metric fields to select (e.g. "metrics.clicks", + // "metrics.cost_micros"). Multiple values are joined into the GAQL SELECT + // clause. + Metrics []string `json:"metrics,omitempty"` + // (Required) Google Ads resource to query (e.g. "ad_group_ad", "keyword_view", + // "search_term_view"). Must be a resource that has metrics. Values are + // validated against Google Ads' field-service catalog at pipeline plan time. + Resource *string `json:"resource,omitempty"` + // (Optional) Resource fields to select, in fully-qualified GAQL form (e.g. + // "ad_group_ad.ad.id", "ad_group_ad.status"). Multiple values are joined into + // the GAQL SELECT clause. + ResourceFields []string `json:"resource_fields,omitempty"` + // (Optional) Segment fields to select (e.g. "segments.date", + // "segments.device"). Must include at least one of segments.date, + // segments.week, or segments.month — that segment is used as the incremental + // cursor for the table. + Segments []string `json:"segments,omitempty"` +} + +// Google Ads specific options for ingestion (object-level). When set, these +// values override the corresponding fields in GoogleAdsConfig +// (source_configurations).. +type GoogleAdsOptions struct { + // (Optional) Custom report definition. When set, the table is treated as a + // user-defined Google Ads custom report: the connector synthesizes a GAQL query + // from the resource, fields, segments, and metrics specified here. When unset, + // the table must match one of the connector's prebuilt sources. + CustomReportOptions *GoogleAdsCustomReportOptions `json:"custom_report_options,omitempty"` + // (Optional) Number of days to look back for report tables to capture + // late-arriving data. If not specified, defaults to 30 days. + LookbackWindowDays *int `json:"lookback_window_days,omitempty"` + // (Optional at this level) Manager Account ID (also called MCC Account ID) used + // to list and access customer accounts under this manager account. Overrides + // GoogleAdsConfig.manager_account_id from source_configurations when set. + ManagerAccountId *string `json:"manager_account_id,omitempty"` + // (Optional) Start date for the initial sync of report tables in YYYY-MM-DD + // format. This determines the earliest date from which to sync historical data. + // If not specified, defaults to 2 years of historical data. + SyncStartDate *string `json:"sync_start_date,omitempty"` +} + +type GoogleDriveOptions struct { + EntityType GoogleDriveOptions_GoogleDriveEntityType `json:"entity_type,omitempty"` + FileIngestionOptions *FileIngestionOptions `json:"file_ingestion_options,omitempty"` + // Google Drive URL. + Url *string `json:"url,omitempty"` +} + +type IngestionGatewayPipelineDefinition struct { + // [Deprecated, use connection_name instead] Immutable. The Unity Catalog + // connection that this gateway pipeline uses to communicate with the source. + ConnectionId *string `json:"connection_id,omitempty"` + // Immutable. The Unity Catalog connection that this gateway pipeline uses to + // communicate with the source. + ConnectionName *string `json:"connection_name,omitempty"` + // Optional, Internal. Parameters required to establish an initial connection + // with the source. + ConnectionParameters *ConnectionParameters `json:"connection_parameters,omitempty"` + // Required, Immutable. The name of the catalog for the gateway pipeline's + // storage location. + GatewayStorageCatalog *string `json:"gateway_storage_catalog,omitempty"` + // Optional. The Unity Catalog-compatible name for the gateway storage location. + // This is the destination to use for the data that is extracted by the gateway. + // Spark Declarative Pipelines system will automatically create the storage + // location under the catalog and schema. + GatewayStorageName *string `json:"gateway_storage_name,omitempty"` + // Required, Immutable. The name of the schema for the gateway pipelines's + // storage location. + GatewayStorageSchema *string `json:"gateway_storage_schema,omitempty"` +} + +type IngestionPipelineDefinition struct { + ConnectionName *string `json:"connection_name,omitempty"` + // (Optional) Connector Type for sources. Ex: CDC, Query Based. + ConnectorType ConnectorType `json:"connector_type,omitempty"` + // (Optional) Location of staged data storage. This is required for migration + // from Cdc Managed Ingestion Pipeline with Gateway pipeline to Combined Cdc + // Managed Ingestion Pipeline. If not specified, the volume for staged data will + // be created in catalog and schema/target specified in the top level pipeline + // definition. + DataStagingOptions *DataStagingOptions `json:"data_staging_options,omitempty"` + // (Optional) A window that specifies a set of time ranges for snapshot queries + // in CDC. + FullRefreshWindow *OperationTimeWindow `json:"full_refresh_window,omitempty"` + IngestFromUcForeignCatalog *bool `json:"ingest_from_uc_foreign_catalog,omitempty"` + IngestionGatewayId *string `json:"ingestion_gateway_id,omitempty"` + // Netsuite only configuration. When the field is set for a netsuite connector, + // the jar stored in the field will be validated and added to the classpath of + // pipeline's cluster. + NetsuiteJarPath *string `json:"netsuite_jar_path,omitempty"` + // Required. Settings specifying tables to replicate and the destination for the + // replicated tables. + Objects []IngestionPipelineDefinition_IngestionConfig `json:"objects,omitempty"` + // Top-level source configurations + SourceConfigurations []SourceConfig `json:"source_configurations,omitempty"` + // The type of the foreign source. The source type will be inferred from the + // source connection or ingestion gateway. This field is output only and will be + // ignored if provided. + SourceType IngestionSourceType `json:"source_type,omitempty"` + // Configuration settings to control the ingestion of tables. These settings are + // applied to all tables in the pipeline. + TableConfiguration *IngestionPipelineDefinition_TableSpecificConfig `json:"table_configuration,omitempty"` +} + +// Fanout configuration for multi-table routing from streaming sources. Routes +// each input record to a destination table based on a routing key derived from +// the record. The key value becomes the table name suffix: +// {destination_catalog}.{destination_schema}.{key_value}.. +type IngestionPipelineDefinition_FanoutOptions struct { + // Column path or SQL expression whose value determines the destination table. + // Supports dotted paths (e.g. "value.event_name") and expressions (e.g. + // "value:event_name::string"). + FanoutBy *string `json:"fanout_by,omitempty"` + // Optional transforms applied to each route's DataFrame before writing to the + // destination table. + Transforms []Transformer `json:"transforms,omitempty"` +} + +type IngestionPipelineDefinition_IngestionConfig struct { + Report *IngestionPipelineDefinition_ReportSpec `json:"report,omitempty"` + Schema *IngestionPipelineDefinition_SchemaSpec `json:"schema,omitempty"` + Table *IngestionPipelineDefinition_TableSpec `json:"table,omitempty"` +} + +type IngestionPipelineDefinition_ReportSpec struct { + // Required. Destination catalog to store table. + DestinationCatalog *string `json:"destination_catalog,omitempty"` + // Required. Destination schema to store table. + DestinationSchema *string `json:"destination_schema,omitempty"` + // Required. Destination table name. The pipeline fails if a table with that + // name already exists. + DestinationTable *string `json:"destination_table,omitempty"` + // Required. Report URL in the source system. + SourceUrl *string `json:"source_url,omitempty"` + // Configuration settings to control the ingestion of tables. These settings + // override the table_configuration defined in the IngestionPipelineDefinition + // object. + TableConfiguration *IngestionPipelineDefinition_TableSpecificConfig `json:"table_configuration,omitempty"` +} + +type IngestionPipelineDefinition_SchemaSpec struct { + // (Optional) Source Specific Connector Options + ConnectorOptions *ConnectorOptions `json:"connector_options,omitempty"` + // Required. Destination catalog to store tables. + DestinationCatalog *string `json:"destination_catalog,omitempty"` + // Required. Destination schema to store tables in. Tables with the same name as + // the source tables are created in this destination schema. The pipeline fails + // If a table with the same name already exists. + DestinationSchema *string `json:"destination_schema,omitempty"` + // Fanout options for multi-table routing from streaming sources. When set, + // records are routed to destination tables based on a per-record routing key. + // The key value becomes the table name: + // {destination_catalog}.{destination_schema}.{key_value}. + FanoutOptions *IngestionPipelineDefinition_FanoutOptions `json:"fanout_options,omitempty"` + // The source catalog name. Might be optional depending on the type of source. + SourceCatalog *string `json:"source_catalog,omitempty"` + // Schema name in the source database. Optional: some source types (for example + // streaming or message-bus connectors) do not use it, so it may be absent from + // a pipeline's definition. Clients that assume it is always present should + // handle its absence. + SourceSchema *string `json:"source_schema,omitempty"` + // Configuration settings to control the ingestion of tables. These settings are + // applied to all tables in this schema and override the table_configuration + // defined in the IngestionPipelineDefinition object. + TableConfiguration *IngestionPipelineDefinition_TableSpecificConfig `json:"table_configuration,omitempty"` +} + +type IngestionPipelineDefinition_TableSpec struct { + // (Optional) Source Specific Connector Options + ConnectorOptions *ConnectorOptions `json:"connector_options,omitempty"` + // Required. Destination catalog to store table. + DestinationCatalog *string `json:"destination_catalog,omitempty"` + // Required. Destination schema to store table. + DestinationSchema *string `json:"destination_schema,omitempty"` + // Optional. Destination table name. The pipeline fails if a table with that + // name already exists. If not set, the source table name is used. + DestinationTable *string `json:"destination_table,omitempty"` + // Source catalog name. Might be optional depending on the type of source. + SourceCatalog *string `json:"source_catalog,omitempty"` + // Schema name in the source database. Might be optional depending on the type + // of source. + SourceSchema *string `json:"source_schema,omitempty"` + // Table name in the source database. Optional: some source types (for example + // streaming or message-bus connectors) do not use it, so it may be absent from + // a pipeline's definition. Clients that assume it is always present should + // handle its absence. + SourceTable *string `json:"source_table,omitempty"` + // Configuration settings to control the ingestion of tables. These settings + // override the table_configuration defined in the IngestionPipelineDefinition + // object and the SchemaSpec. + TableConfiguration *IngestionPipelineDefinition_TableSpecificConfig `json:"table_configuration,omitempty"` +} + +type IngestionPipelineDefinition_TableSpecificConfig struct { + // (Optional, Mutable) Policy for auto full refresh, if enabled pipeline will + // automatically try to fix issues by doing a full refresh on the table in the + // retry run. auto_full_refresh_policy in table configuration will override the + // above level auto_full_refresh_policy. For example, { + // "auto_full_refresh_policy": { "enabled": true, "min_interval_hours": 23, } } + // If unspecified, auto full refresh is disabled. + AutoFullRefreshPolicy *AutoFullRefreshPolicy `json:"auto_full_refresh_policy,omitempty"` + // List of column names to use for clustering the destination table. When + // specified, the destination Delta table will be clustered by these columns. + // This can improve query performance when filtering on these columns. Note: + // clustering_columns in table specific configuration will override the pipeline + // definition. Note: we can only provide enable_auto_clustering or + // clustering_columns, added as separate fields as we cannot have repeated field + // in oneof. + ClusteringColumns []string `json:"clustering_columns,omitempty"` + // Whether to enable auto clustering on the destination table. When enabled, + // Delta will automatically optimize the data layout based on the clustering + // columns for improved query performance. Note: enable_auto_clustering in table + // specific configuration will override the pipeline definition. Note: we can + // only provide enable_auto_clustering or clustering_columns, added as separate + // fields as we cannot have repeated field in oneof. + EnableAutoClustering *bool `json:"enable_auto_clustering,omitempty"` + // A list of column names to be excluded for the ingestion. When not specified, + // include_columns fully controls what columns to be ingested. When specified, + // all other columns including future ones will be automatically included for + // ingestion. This field in mutually exclusive with `include_columns`. + ExcludeColumns []string `json:"exclude_columns,omitempty"` + // A list of column names to be included for the ingestion. When not specified, + // all columns except ones in exclude_columns will be included. Future columns + // will be automatically included. When specified, all other future columns will + // be automatically excluded from ingestion. This field in mutually exclusive + // with `exclude_columns`. + IncludeColumns []string `json:"include_columns,omitempty"` + // The primary key of the table used to apply changes. + PrimaryKeys []string `json:"primary_keys,omitempty"` + QueryBasedConnectorConfig *IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig `json:"query_based_connector_config,omitempty"` + // (Optional, Immutable) The row filter condition to be applied to the table. It + // must not contain the WHERE keyword, only the actual filter condition. It must + // be in DBSQL format. + RowFilter *string `json:"row_filter,omitempty"` + // If true, formula fields defined in the table are included in the ingestion. + // This setting is only valid for the Salesforce connector + SalesforceIncludeFormulaFields *bool `json:"salesforce_include_formula_fields,omitempty"` + ScdType ScdType_ScdType `json:"scd_type,omitempty"` + // The column names specifying the logical order of events in the source data. + // Spark Declarative Pipelines uses this sequencing to handle change events that + // arrive out of order. + SequenceBy []string `json:"sequence_by,omitempty"` + // (Optional) Name of the struct column added to each ingested record to hold + // per row source metadata. + SourceMetadataColumn *string `json:"source_metadata_column,omitempty"` + // Table properties to set on the destination table. These are key-value pairs + // that configure various Delta table behaviors or any user defined properties. + // Example: {"delta.feature.variantType": "supported", + // "delta.enableTypeWidening": "true"} Note: table_properties in table specific + // configuration will override the table_properties of the pipeline definition. + TableProperties map[string]string `json:"table_properties,omitempty"` + // (Optional) Additional custom parameters for Workday Report + WorkdayReportParameters *IngestionPipelineDefinition_WorkdayReportParameters `json:"workday_report_parameters,omitempty"` +} + +// Configurations that are only applicable for query-based ingestion connectors.. +type IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig struct { + // The names of the monotonically increasing columns in the source table that + // are used to enable the table to be read and ingested incrementally through + // structured streaming. The columns are allowed to have repeated values but + // have to be non-decreasing. If the source data is merged into the destination + // (e.g., using SCD Type 1 or Type 2), these columns will implicitly define the + // `sequence_by` behavior. You can still explicitly set `sequence_by` to + // override this default. + CursorColumns []string `json:"cursor_columns,omitempty"` + // Specifies a SQL WHERE condition that specifies that the source row has been + // deleted. This is sometimes referred to as "soft-deletes". For example: + // "Operation = 'DELETE'" or "is_deleted = true". This field is orthogonal to + // `hard_deletion_sync_interval_in_seconds`, one for soft-deletes and the other + // for hard-deletes. See also the hard_deletion_sync_min_interval_in_seconds + // field for handling of "hard deletes" where the source rows are physically + // removed from the table. + DeletionCondition *string `json:"deletion_condition,omitempty"` + // Specifies the minimum interval (in seconds) between snapshots on primary keys + // for detecting and synchronizing hard deletions—i.e., rows that have been + // physically removed from the source table. This interval acts as a lower + // bound. If ingestion runs less frequently than this value, hard deletion + // synchronization will align with the actual ingestion frequency instead of + // happening more often. If not set, hard deletion synchronization via snapshots + // is disabled. This field is mutable and can be updated without triggering a + // full snapshot. + HardDeletionSyncMinIntervalInSeconds *int64 `json:"hard_deletion_sync_min_interval_in_seconds,omitempty"` +} + +type IngestionPipelineDefinition_WorkdayReportParameters struct { + // (Optional) Marks the report as incremental. This field is deprecated and + // should not be used. Use `parameters` instead. The incremental behavior is now + // controlled by the `parameters` field. + Incremental *bool `json:"incremental,omitempty"` + // Parameters for the Workday report. Each key represents the parameter name + // (e.g., "start_date", "end_date"), and the corresponding value is a SQL-like + // expression used to compute the parameter value at runtime. Example: { + // "start_date": "{ coalesce(current_offset(), date(\"2025-02-01\")) }", + // "end_date": "{ current_date() - INTERVAL 1 DAY }" } + Parameters map[string]string `json:"parameters,omitempty"` + // (Optional) Additional custom parameters for Workday Report This field is + // deprecated and should not be used. Use `parameters` instead. + ReportParameters []IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue `json:"report_parameters,omitempty"` +} + +type IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue struct { + // Key for the report parameter, can be a column name or other metadata + Key *string `json:"key,omitempty"` + // Value for the report parameter. Possible values it can take are these sql + // functions: 1. coalesce(current_offset(), date("YYYY-MM-DD")) -> if + // current_offset() is null, then the passed date, else current_offset() 2. + // current_date() 3. date_sub(current_date(), x) -> subtract x (some + // non-negative integer) days from current date + Value *string `json:"value,omitempty"` +} + +// Jira specific options for ingestion. +type JiraConnectorOptions struct { + // (Optional) Projects to filter Jira data on + IncludeJiraSpaces []string `json:"include_jira_spaces,omitempty"` +} + +type JsonTransformerOptions struct { + // Parse the entire value as a single Variant column. + AsVariant *bool `json:"as_variant,omitempty"` + // Inline schema string for JSON parsing (Spark DDL format). + Schema *string `json:"schema,omitempty"` + // (Optional) Schema evolution mode for schema inference. + SchemaEvolutionMode FileIngestionOptions_SchemaEvolutionMode `json:"schema_evolution_mode,omitempty"` + // Path to a schema file (.ddl). + SchemaFilePath *string `json:"schema_file_path,omitempty"` + // (Optional) Schema hints as a comma-separated string of "column_name type" + // pairs. + SchemaHints *string `json:"schema_hints,omitempty"` +} + +type KafkaOptions struct { + // Undocumented backdoor mechanism for overriding parameters to pass to the + // Kafka client. This is not supported and may break at any time. + ClientConfig map[string]string `json:"client_config,omitempty"` + // (Optional) Transformer for the message key. If not specified, the key is left + // as raw bytes. + KeyTransformer *Transformer `json:"key_transformer,omitempty"` + // Internal option to control the maximum number of offsets to process per + // trigger. + MaxOffsetsPerTrigger *int64 `json:"max_offsets_per_trigger,omitempty"` + // (Optional) Where to begin reading when no checkpoint exists. Valid values: + // "latest" and "earliest". Defaults to "latest". + StartingOffset *string `json:"starting_offset,omitempty"` + // Java regex pattern to subscribe to matching topics. Only one of topics or + // topic_pattern must be specified. + TopicPattern *string `json:"topic_pattern,omitempty"` + // Topics to subscribe to. Only one of topics or topic_pattern must be + // specified. + Topics []string `json:"topics,omitempty"` + // (Optional) Transformer for the message value. If not specified, the value is + // left as raw bytes. + ValueTransformer *Transformer `json:"value_transformer,omitempty"` +} + +// LinkedIn Ads specific options for ingestion. sync_start_date and +// lookback_window_days apply to both the prebuilt analytics tables and custom +// reports. custom_report_options defines a custom (user-defined) adAnalytics +// report and is only valid on a table object.. +type LinkedInAdsOptions struct { + // (Optional) Custom report definition. Only valid on a table object. When set, + // the table is synthesized from /rest/adAnalytics using the finder, pivots, + // time granularity and metrics here. When unset, the table must match one of + // the connector's prebuilt sources. + CustomReportOptions *LinkedInAdsOptions_LinkedInAdsCustomReportOptions `json:"custom_report_options,omitempty"` + // (Optional) Days to look back during incremental sync for late-arriving data. + // If not specified, defaults to 30 days. + LookbackWindowDays *int `json:"lookback_window_days,omitempty"` + // (Optional) Start date for the initial sync of report tables, YYYY-MM-DD. + // Earliest date from which to sync historical data; overrides the default when + // set. For finder attributedRevenueMetrics, this must be between 30 and 366 + // days before today. If not specified, defaults to 1 year of history. + SyncStartDate *string `json:"sync_start_date,omitempty"` +} + +// User-defined custom report for the LinkedIn Ads connector. The destination +// table name comes from the enclosing TableSpec.destination_table, the start +// date from the enclosing LinkedInAdsOptions.sync_start_date, and the account +// it runs against from the source schema (namespace) -- none are repeated here.. +type LinkedInAdsOptions_LinkedInAdsCustomReportOptions struct { + // (Required) Entity pivots to group by; count/constraints depend on finder. + EntityGranularity []LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsEntityGranularity `json:"entity_granularity,omitempty"` + // (Required) adAnalytics finder. See LinkedInAdsFinder. + Finder LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsFinder `json:"finder,omitempty"` + // (Optional) LinkedIn metric names for the report. Open vocabulary (not an + // enum): the valid set is large (~100) and evolves with the LinkedIn + // adAnalytics API, so values are passed through verbatim. If empty, a + // pivot-safe default core set is ingested: impressions, clicks, + // costInLocalCurrency, externalWebsiteConversions (valid for every pivot). + // Ignored for attributedRevenueMetrics (always returns the full + // RevenueAttributionMetrics struct). + Metrics []string `json:"metrics,omitempty"` + // (Optional) Time aggregation. Defaults to DAILY when unspecified. Used by + // analytics/statistics; ignored for attributedRevenueMetrics. + TimeGranularity LinkedInAdsOptions_LinkedInAdsCustomReportOptions_LinkedInAdsTimeGranularity `json:"time_granularity,omitempty"` +} + +// The request/response messages for the ListPipelines API. The default behavior +// is to return the 25 newest events in timestamp descending order for the given +// pipeline.. +type ListPipelineEventsRequest struct { + // Criteria to select a subset of results, expressed using a SQL-like syntax. + // The supported filters are: 1. level='INFO' (or WARN or ERROR) 2. level in + // ('INFO', 'WARN') 3. id='[event-id]' 4. timestamp > 'TIMESTAMP' (or >=,<,<=,=) + // + // Composite expressions are supported, for example: level in ('ERROR', 'WARN') + // AND timestamp> '2021-07-22T06:37:33.083Z' + Filter *string `json:"filter,omitempty"` + // Max number of entries to return in a single page. The system may return fewer + // than max_results events in a response, even if there are more events + // available. + MaxResults *int `json:"max_results,omitempty"` + // A string indicating a sort order by timestamp for the results, for example, + // ["timestamp asc"]. The sort order can be ascending or descending. By default, + // events are returned in descending order by timestamp. + OrderBy []string `json:"order_by,omitempty"` + // Page token returned by previous call. This field is mutually exclusive with + // all fields in this request except max_results. An error is returned if any + // fields other than max_results are set when this field is set. + PageToken *string `json:"page_token,omitempty"` + // The pipeline to return events for. + PipelineId *string `json:"pipeline_id,omitempty"` +} + +type ListPipelineEventsResponse struct { + // The list of events matching the request criteria. + Events []PipelineEvent `json:"events,omitempty"` + // If present, a token to fetch the next page of events. + NextPageToken *string `json:"next_page_token,omitempty"` + // If present, a token to fetch the previous page of events. + PrevPageToken *string `json:"prev_page_token,omitempty"` +} + +// The request/response messages for the ListPipelines API. The default behavior +// is to return the 25 first pipelines in ascending order of pipeline id.. +type ListPipelinesRequest struct { + // Select a subset of results based on the specified criteria. The supported + // filters are: + // + // * `notebook=''` to select pipelines that reference the provided + // notebook path. * `name LIKE '[pattern]'` to select pipelines with a name that + // matches pattern. Wildcards are supported, for example: `name LIKE + // '%shopping%'` + // + // Composite filters are not supported. This field is optional. + Filter *string `json:"filter,omitempty"` + // The maximum number of entries to return in a single page. The system may + // return fewer than max_results pipelines in a response, even if there are more + // pipelines available. This field is optional. The default value is 25. The + // maximum value is 100. An error is returned if the value of max_results is + // greater than 100. + MaxResults *int `json:"max_results,omitempty"` + // A list of strings specifying the order of results. Supported order_by fields + // are id and name. The default is id asc. This field is optional. + OrderBy []string `json:"order_by,omitempty"` + // Page token returned by previous call + PageToken *string `json:"page_token,omitempty"` +} + +type ListPipelinesResponse struct { + // If present, a token to fetch the next page of pipelines. + NextPageToken *string `json:"next_page_token,omitempty"` + // The list of pipelines matching the request criteria. + Statuses []PipelineStateInfo `json:"statuses,omitempty"` +} + +// The request/response messages for the ListUpdates API. The default behavior +// is to return the 25 most recent updates in timestamp descending order for the +// given pipeline. No custom sorting or filtering is supported.. +type ListUpdatesRequest struct { + // Max number of entries to return in a single page. + MaxResults *int `json:"max_results,omitempty"` + // Page token returned by previous call + PageToken *string `json:"page_token,omitempty"` + // The pipeline to return updates for. + PipelineId *string `json:"pipeline_id,omitempty"` + // If present, returns updates until and including this update_id. + UntilUpdateId *string `json:"until_update_id,omitempty"` +} + +type ListUpdatesResponse struct { + // If present, then there are more results, and this a token to be used in a + // subsequent request to fetch the next page. + NextPageToken *string `json:"next_page_token,omitempty"` + // If present, then this token can be used in a subsequent request to fetch the + // previous page. + PrevPageToken *string `json:"prev_page_token,omitempty"` + Updates []UpdateInfo `json:"updates,omitempty"` +} + +type ManualTrigger struct { +} + +// Marketo specific options for ingestion. +type MarketoOptions struct { + // (Optional) Start date for the initial sync in YYYY-MM-DD format. This + // determines the earliest date from which to sync historical data. If not + // specified, complete history is ingested. + SyncStartDate *string `json:"sync_start_date,omitempty"` +} + +// Meta Marketing (Meta Ads) specific options for ingestion. +type MetaMarketingOptions struct { + // (Optional, DEPRECATED — use + // custom_report_options.action_attribution_windows) Action attribution windows + // for insights reporting (e.g. "28d_click", "1d_view") + ActionAttributionWindows []string `json:"action_attribution_windows,omitempty"` + // (Optional, DEPRECATED — use custom_report_options.action_breakdowns) Action + // breakdowns + ActionBreakdowns []string `json:"action_breakdowns,omitempty"` + // (Optional, DEPRECATED — use custom_report_options.action_report_time) + // Timing used to report action statistics (impression, conversion, mixed, or + // lifetime) + ActionReportTime *string `json:"action_report_time,omitempty"` + // (Optional, DEPRECATED — use custom_report_options.breakdowns) Breakdowns to + // configure + Breakdowns []string `json:"breakdowns,omitempty"` + // (Optional) Window in days to revisit data during sync to capture updated + // conversion data from the API, shared by prebuilt and custom reports. + CustomInsightsLookbackWindow *int `json:"custom_insights_lookback_window,omitempty"` + // (Optional) Per-table custom report definition. When set, defines the shape of + // the insights call for this table + // (level/fields/breakdowns/action_breakdowns/etc.). Supersedes the deprecated + // flat report-shape fields above. + CustomReportOptions *MetaMarketingOptions_MetaMarketingCustomReportOptions `json:"custom_report_options,omitempty"` + // (Optional, DEPRECATED — use custom_report_options.level) Granularity of + // data to pull (account, ad, adset, campaign) + Level *string `json:"level,omitempty"` + // (Optional) Start date in yyyy-MM-dd format (e.g. 2025-01-15). Data added + // after this date will be ingested, shared by prebuilt and custom reports. + StartDate *string `json:"start_date,omitempty"` + // (Optional, DEPRECATED — use custom_report_options.time_increment) Value in + // string by which to aggregate statistics (can take all_days, monthly or number + // of days) + TimeIncrement *string `json:"time_increment,omitempty"` +} + +// Defines the shape of a single Meta Ads custom report (one /insights call +// shape). start_date, custom_insights_lookback_window live on +// MetaMarketingOptions, not here. Metrics are not customer-selectable; the +// connector returns a fixed standard metric set.. +type MetaMarketingOptions_MetaMarketingCustomReportOptions struct { + // (Optional) Action attribution windows for insights reporting (e.g. + // "28d_click", "1d_view") + ActionAttributionWindows []string `json:"action_attribution_windows,omitempty"` + // (Optional) Action breakdowns to configure for data aggregation + ActionBreakdowns []string `json:"action_breakdowns,omitempty"` + // (Optional) Timing used to report action statistics (impression, conversion, + // mixed, or lifetime) + ActionReportTime *string `json:"action_report_time,omitempty"` + // (Optional) Breakdowns to configure for data aggregation + Breakdowns []string `json:"breakdowns,omitempty"` + // (Optional) Granularity of data to pull (account, ad, adset, campaign) + Level *string `json:"level,omitempty"` + // (Optional) Value in string by which to aggregate statistics (all_days, + // monthly or number of days) + TimeIncrement *string `json:"time_increment,omitempty"` +} + +type NotebookLibrary struct { + // The absolute path of the source code. + Path *string `json:"path,omitempty"` +} + +type Notifications struct { + // A list of alerts that trigger the sending of notifications to the configured + // destinations. The supported alerts are: + // + // * `on-update-success`: A pipeline update completes successfully. * + // `on-update-failure`: Each time a pipeline update fails. * + // `on-update-fatal-failure`: A pipeline update fails with a non-retryable + // (fatal) error. * `on-flow-failure`: A single data flow fails. + Alerts []string `json:"alerts,omitempty"` + // A list of email addresses notified when a configured alert is triggered. + EmailRecipients []string `json:"email_recipients,omitempty"` +} + +// Proto representing a window. +type OperationTimeWindow struct { + // Days of week in which the window is allowed to happen If not specified all + // days of the week will be used. + DaysOfWeek []DayOfWeek `json:"days_of_week,omitempty"` + // An integer between 0 and 23 denoting the start hour for the window in the + // 24-hour day. + StartHour *int `json:"start_hour,omitempty"` + // Time zone id of window. See + // https://docs.databricks.com/sql/language-manual/sql-ref-syntax-aux-conf-mgmt-set-timezone.html + // for details. If not specified, UTC will be used. + TimeZoneId *string `json:"time_zone_id,omitempty"` +} + +type Origin struct { + // The id of a batch. Unique within a flow. + BatchId *int64 `json:"batch_id,omitempty"` + // The cloud provider, e.g., AWS or Azure. + Cloud *string `json:"cloud,omitempty"` + // The id of the cluster where an execution happens. Unique within a region. + ClusterId *string `json:"cluster_id,omitempty"` + // The name of a dataset. Unique within a pipeline. + DatasetName *string `json:"dataset_name,omitempty"` + // The id of the flow. Globally unique. Incremental queries will generally reuse + // the same id while complete queries will have a new id per update. + FlowId *string `json:"flow_id,omitempty"` + // The name of the flow. Not unique. + FlowName *string `json:"flow_name,omitempty"` + // The optional host name where the event was triggered + Host *string `json:"host,omitempty"` + // The name of the source catalog name (if known) from whose data ingestion is + // described by this event. + IngestionSourceCatalogName *string `json:"ingestion_source_catalog_name,omitempty"` + // The name of the source UC connection (if known) from whose data ingestion is + // described by this event. + IngestionSourceConnectionName *string `json:"ingestion_source_connection_name,omitempty"` + // The name of the source schema name (if known) from whose data ingestion is + // described by this event. + IngestionSourceSchemaName *string `json:"ingestion_source_schema_name,omitempty"` + // The name of the source table name (if known) from whose data ingestion is + // described by this event. + IngestionSourceTableName *string `json:"ingestion_source_table_name,omitempty"` + // An optional implementation-defined source table version of a dataset being + // (re)ingested. + IngestionSourceTableVersion *string `json:"ingestion_source_table_version,omitempty"` + // The id of a maintenance run. Globally unique. + MaintenanceId *string `json:"maintenance_id,omitempty"` + // Materialization name. + MaterializationName *string `json:"materialization_name,omitempty"` + // The org id of the user. Unique within a cloud. + OrgId *int64 `json:"org_id,omitempty"` + // The id of the pipeline. Globally unique. + PipelineId *string `json:"pipeline_id,omitempty"` + // The name of the pipeline. Not unique. + PipelineName *string `json:"pipeline_name,omitempty"` + // The cloud region. + Region *string `json:"region,omitempty"` + // The id of the request that caused an update. + RequestId *string `json:"request_id,omitempty"` + // The id of a (delta) table. Globally unique. + TableId *string `json:"table_id,omitempty"` + // The Unity Catalog id of the MV or ST being updated. + UcResourceId *string `json:"uc_resource_id,omitempty"` + // The id of an execution. Globally unique. + UpdateId *string `json:"update_id,omitempty"` +} + +// Outlook specific options for ingestion. +type OutlookOptions struct { + // (Optional) Controls which attachments to ingest. If not specified, defaults + // to ALL. + AttachmentMode OutlookAttachmentMode `json:"attachment_mode,omitempty"` + // (Optional) Defines how the body_content column is populated. TEXT_HTML: + // Preserves full formatting, links, and styling. TEXT_PLAIN: Converts body to + // plain text. Recommended for AI/RAG pipelines to reduce token usage and noise. + BodyFormat OutlookBodyFormat `json:"body_format,omitempty"` + // Deprecated. Use include_folders instead. + FolderFilter []string `json:"folder_filter,omitempty"` + // (Optional) Filter mail folders to include in the sync. If not specified, all + // folders will be synced. Examples: Inbox, Sent Items, Custom_Folder Filter + // semantics: OR between different folders. + IncludeFolders []string `json:"include_folders,omitempty"` + // (Optional) List of mailboxes to sync (e.g. mailbox email addresses or + // identifiers). If not specified, all accessible mailboxes are ingested. Filter + // semantics: OR between different mailboxes. + IncludeMailboxes []string `json:"include_mailboxes,omitempty"` + // (Optional) Filter emails by sender address. Uses exact email match. Examples: + // user@vendor.com, alerts@system.io, noreply@company.com If not specified, + // emails from all senders will be synced. Filter semantics: OR between + // different senders. + IncludeSenders []string `json:"include_senders,omitempty"` + // (Optional) Filter emails by subject line. Values ending with "*" use prefix + // match (subject starts with the part before "*"); otherwise substring match + // (subject contains the value). Examples: "Invoice" (substring), "Re:*" + // (prefix), "Support Ticket", "URGENT*" If not specified, emails with all + // subjects will be synced. Filter semantics: OR between different subjects. + IncludeSubjects []string `json:"include_subjects,omitempty"` + // Deprecated. Use include_senders instead. + SenderFilter []string `json:"sender_filter,omitempty"` + // (Optional) Start date for the initial sync in YYYY-MM-DD format. Format: + // YYYY-MM-DD (e.g., 2024-01-01) This determines the earliest date from which to + // sync historical data. If not specified, complete history is ingested. + StartDate *string `json:"start_date,omitempty"` + // Deprecated. Use include_subjects instead. + SubjectFilter []string `json:"subject_filter,omitempty"` +} + +type PathPattern struct { + // The source code to include for pipelines + Include *string `json:"include,omitempty"` +} + +type PipelineCluster struct { + // Note: This field won't be persisted. Only API users will check this field. + ApplyPolicyDefaultValues *bool `json:"apply_policy_default_values,omitempty"` + Autoscale *PipelinesAutoScale `json:"autoscale,omitempty"` + // Attributes related to clusters running on Amazon Web Services. If not + // specified at cluster creation, a set of default values will be used. + AwsAttributes *PipelinesAwsAttributes `json:"aws_attributes,omitempty"` + // Attributes related to clusters running on Microsoft Azure. If not specified + // at cluster creation, a set of default values will be used. + AzureAttributes *PipelinesAzureAttributes `json:"azure_attributes,omitempty"` + // The configuration for delivering spark logs to a long-term storage + // destination. Only dbfs destinations are supported. Only one destination can + // be specified for one cluster. If the conf is given, the logs will be + // delivered to the destination every `5 mins`. The destination of driver logs + // is `$destination/$clusterId/driver`, while the destination of executor logs + // is `$destination/$clusterId/executor`. + ClusterLogConf *PipelinesClusterLogConf `json:"cluster_log_conf,omitempty"` + // Additional tags for cluster resources. will tag all cluster + // resources (e.g., AWS instances and EBS volumes) with these tags in addition + // to `default_tags`. Notes: + // + // - Currently, allows at most 45 custom tags + // + // - Clusters can only reuse cloud resources if the resources' tags are a subset + // of the cluster tags + CustomTags map[string]string `json:"custom_tags,omitempty"` + // The optional ID of the instance pool for the driver of the cluster belongs. + // The pool cluster uses the instance pool with id (instance_pool_id) if the + // driver pool is not assigned. + DriverInstancePoolId *string `json:"driver_instance_pool_id,omitempty"` + // The node type of the Spark driver. Note that this field is optional; if + // unset, the driver node type will be set as the same value as `node_type_id` + // defined above. + DriverNodeTypeId *string `json:"driver_node_type_id,omitempty"` + // Whether to enable local disk encryption for the cluster. + EnableLocalDiskEncryption *bool `json:"enable_local_disk_encryption,omitempty"` + // Attributes related to clusters running on Google Cloud Platform. If not + // specified at cluster creation, a set of default values will be used. + GcpAttributes *PipelinesGcpAttributes `json:"gcp_attributes,omitempty"` + // The configuration for storing init scripts. Any number of destinations can be + // specified. The scripts are executed sequentially in the order provided. If + // `cluster_log_conf` is specified, init script logs are sent to + // `//init_scripts`. + InitScripts []PipelinesInitScriptInfo `json:"init_scripts,omitempty"` + // The optional ID of the instance pool to which the cluster belongs. + InstancePoolId *string `json:"instance_pool_id,omitempty"` + // A label for the cluster specification, either `default` to configure the + // default cluster settings applied to both the update and maintenance clusters, + // `updates` to configure the update cluster, or `maintenance` to configure the + // maintenance cluster. This field is optional. The default value is `default`. + Label *string `json:"label,omitempty"` + // This field encodes, through a single value, the resources available to each + // of the Spark nodes in this cluster. For example, the Spark nodes can be + // provisioned and optimized for memory or compute intensive workloads. A list + // of available node types can be retrieved by using the + // :method:clusters/listNodeTypes API call. + NodeTypeId *string `json:"node_type_id,omitempty"` + NumWorkers *int `json:"num_workers,omitempty"` + // The ID of the cluster policy used to create the cluster if applicable. + PolicyId *string `json:"policy_id,omitempty"` + // An object containing a set of optional, user-specified Spark configuration + // key-value pairs. See :method:clusters/create for more details. + SparkConf map[string]string `json:"spark_conf,omitempty"` + // An object containing a set of optional, user-specified environment variable + // key-value pairs. Please note that key-value pair of the form (X,Y) will be + // exported as is (i.e., `export X='Y'`) while launching the driver and workers. + // + // In order to specify an additional set of `SPARK_DAEMON_JAVA_OPTS`, we + // recommend appending them to `$SPARK_DAEMON_JAVA_OPTS` as shown in the example + // below. This ensures that all default databricks managed environmental + // variables are included as well. + // + // Example Spark environment variables: `{"SPARK_WORKER_MEMORY": "28000m", + // "SPARK_LOCAL_DIRS": "/local_disk0"}` or `{"SPARK_DAEMON_JAVA_OPTS": + // "$SPARK_DAEMON_JAVA_OPTS -Dspark.shuffle.service.enabled=true"}` + SparkEnvVars map[string]string `json:"spark_env_vars,omitempty"` + // SSH public key contents that will be added to each Spark node in this + // cluster. The corresponding private keys can be used to login with the user + // name `ubuntu` on port `2200`. Up to 10 keys can be specified. + SshPublicKeys []string `json:"ssh_public_keys,omitempty"` +} + +type PipelineDeployment struct { + // ID of the deployment that manages this pipeline. Only set when `kind` is + // `BUNDLE`. Used to look up deployment metadata from the Deployment Metadata + // service. + DeploymentId *string `json:"deployment_id,omitempty"` + // The deployment method that manages the pipeline. + Kind DeploymentKind `json:"kind,omitempty"` + // The path to the file containing metadata about the deployment. + MetadataFilePath *string `json:"metadata_file_path,omitempty"` + // ID of the version of the deployment that produced this pipeline. Only set + // when `kind` is `BUNDLE`. Identifies a specific snapshot of the deployment in + // the Deployment Metadata service. + VersionId *string `json:"version_id,omitempty"` +} + +type PipelineEvent struct { + // Information about an error captured by the event. + Error *ErrorDetail `json:"error,omitempty"` + // The event type. Should always correspond to the details + EventType *string `json:"event_type,omitempty"` + // A time-based, globally unique id. + Id *string `json:"id,omitempty"` + // The severity level of the event. + Level EventLevel `json:"level,omitempty"` + // Maturity level for event_type. + MaturityLevel MaturityLevel `json:"maturity_level,omitempty"` + // The display message associated with the event. + Message *string `json:"message,omitempty"` + // Describes where the event originates from. + Origin *Origin `json:"origin,omitempty"` + // A sequencing object to identify and order events. + Sequence *Sequencing `json:"sequence,omitempty"` + // The time of the event. + Timestamp *string `json:"timestamp,omitempty"` + // Information about which fields were truncated from this event due to size + // constraints. If empty or absent, no truncation occurred. See + // https://docs.databricks.com/en/ldp/monitor-event-logs for information on + // retrieving complete event data. + Truncation *Truncation `json:"truncation,omitempty"` +} + +type PipelineLibrary struct { + File *NotebookLibrary `json:"file,omitempty"` + Glob *PathPattern `json:"glob,omitempty"` + Jar *string `json:"jar,omitempty"` + Maven *PipelinesMavenLibrary `json:"maven,omitempty"` + Notebook *NotebookLibrary `json:"notebook,omitempty"` + Whl *string `json:"whl,omitempty"` +} + +type PipelineSpec struct { + // Budget policy of this pipeline. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // A catalog in Unity Catalog to publish data from this pipeline to. If `target` + // is specified, tables in this pipeline are published to a `target` schema + // inside `catalog` (for example, `catalog`.`target`.`table`). If `target` is + // not specified, no data is published to Unity Catalog. + Catalog *string `json:"catalog,omitempty"` + // SDP Release Channel that specifies which version to use. + Channel *string `json:"channel,omitempty"` + // Cluster settings for this pipeline deployment. Applies to classic + // (non-serverless) pipelines. Omit this field when `serverless` is `true`. + Clusters []PipelineCluster `json:"clusters,omitempty"` + // String-String configuration for this pipeline execution. + Configuration map[string]string `json:"configuration,omitempty"` + // Whether the pipeline is continuous or triggered. This replaces `trigger`. + // + // Deprecated: wrap the pipeline in a continuous job instead, which also lets + // you take advantage of job-level settings such as performance mode. When the + // pipeline is started by a continuous job, the job's setting takes precedence + // and this field is ignored. + Continuous *bool `json:"continuous,omitempty"` + // Deployment type of this pipeline. + Deployment *PipelineDeployment `json:"deployment,omitempty"` + // Whether the pipeline is in Development mode. Defaults to false. + // + // Deprecated: set development mode for each update instead. + Development *bool `json:"development,omitempty"` + // Pipeline product edition. + Edition *string `json:"edition,omitempty"` + // Environment specification for this pipeline used to install dependencies. + Environment *PipelinesEnvironment `json:"environment,omitempty"` + // Event log configuration for this pipeline + EventLog *EventLogSpec `json:"event_log,omitempty"` + // Filters on which Pipeline packages to include in the deployed graph. + Filters *Filters `json:"filters,omitempty"` + // The definition of a gateway pipeline to support change data capture. + GatewayDefinition *IngestionGatewayPipelineDefinition `json:"gateway_definition,omitempty"` + // Unique identifier for this pipeline. + Id *string `json:"id,omitempty"` + // The configuration for a managed ingestion pipeline. These settings cannot be + // used with the 'libraries', 'schema', 'target', or 'catalog' settings. + IngestionDefinition *IngestionPipelineDefinition `json:"ingestion_definition,omitempty"` + // Libraries or code needed by this deployment. + Libraries []PipelineLibrary `json:"libraries,omitempty"` + // Friendly identifier for this pipeline. + Name *string `json:"name,omitempty"` + // List of notification settings for this pipeline. + Notifications []Notifications `json:"notifications,omitempty"` + // Path of the pipeline parent folder in workspace file tree. + // + // If absent, the pipeline doesn't have a workspace object. + ParentPath *string `json:"parent_path,omitempty"` + // Whether Photon is enabled for this pipeline. + Photon *bool `json:"photon,omitempty"` + // Restart window of this pipeline. + RestartWindow *RestartWindow `json:"restart_window,omitempty"` + // Root path for this pipeline. This is used as the root directory when editing + // the pipeline in the user interface and it is added to sys.path + // when executing Python sources during pipeline execution. + RootPath *string `json:"root_path,omitempty"` + // The default schema (database) where tables are read from or published to. + Schema *string `json:"schema,omitempty"` + // Whether serverless compute is enabled for this pipeline. Serverless is the + // recommended compute for new pipelines; set this to `true` to run the pipeline + // on serverless. For notebook/file pipelines, omitting this field uses classic + // compute configured through the `clusters` field. When `true`, omit + // `clusters`; Photon is always enabled. + Serverless *bool `json:"serverless,omitempty"` + // Serverless compute ID specified by the user for serverless pipelines. + ServerlessComputeId *string `json:"serverless_compute_id,omitempty"` + // DBFS root directory for storing checkpoints and tables. + Storage *string `json:"storage,omitempty"` + // A map of tags associated with the pipeline. These are forwarded to the + // cluster as cluster tags, and are therefore subject to the same limitations. A + // maximum of 25 tags can be added to the pipeline. + Tags map[string]string `json:"tags,omitempty"` + // Target schema (database) to add tables in this pipeline to. Exactly one of + // `schema` or `target` must be specified. To publish to Unity Catalog, also + // specify `catalog`. This legacy field is deprecated for pipeline creation in + // favor of the `schema` field. + Target *string `json:"target,omitempty"` + // Which pipeline trigger to use. Deprecated: Use `continuous` instead. + Trigger *PipelineTrigger `json:"trigger,omitempty"` + // Usage policy of this pipeline. + UsagePolicyId *string `json:"usage_policy_id,omitempty"` +} + +type PipelineStateInfo struct { + // The unique identifier of the cluster running the pipeline. + ClusterId *string `json:"cluster_id,omitempty"` + // The username of the pipeline creator. + CreatorUserName *string `json:"creator_user_name,omitempty"` + // The health of a pipeline. + Health PipelineHealthStatus `json:"health,omitempty"` + // Status of the latest updates for the pipeline. Ordered with the newest update + // first. + LatestUpdates []UpdateStateInfo `json:"latest_updates,omitempty"` + // The user-friendly name of the pipeline. + Name *string `json:"name,omitempty"` + // The unique identifier of the pipeline. + PipelineId *string `json:"pipeline_id,omitempty"` + // The username that the pipeline runs as. This is a read only value derived + // from the pipeline owner. + RunAsUserName *string `json:"run_as_user_name,omitempty"` + State PipelineState_PipelineState `json:"state,omitempty"` +} + +type PipelineTrigger struct { + Cron *CronTrigger `json:"cron,omitempty"` + Manual *ManualTrigger `json:"manual,omitempty"` +} + +type PipelinesAutoScale struct { + // The maximum number of workers to which the cluster can scale up when + // overloaded. `max_workers` must be strictly greater than `min_workers`. + MaxWorkers *int `json:"max_workers,omitempty"` + // The minimum number of workers the cluster can scale down to when + // underutilized. It is also the initial number of workers the cluster will have + // after creation. + MinWorkers *int `json:"min_workers,omitempty"` + // Databricks Enhanced Autoscaling optimizes cluster utilization by + // automatically allocating cluster resources based on workload volume, with + // minimal impact to the data processing latency of your pipelines. Enhanced + // Autoscaling is available for `updates` clusters only. The legacy autoscaling + // feature is used for `maintenance` clusters. + Mode *string `json:"mode,omitempty"` +} + +// Attributes set during cluster creation which are related to Amazon Web +// Services.. +type PipelinesAwsAttributes struct { + // Availability type used for all subsequent nodes past the ``first_on_demand`` + // ones. Note: If ``first_on_demand`` is zero, this availability type will be + // used for the entire cluster. + Availability PipelinesAwsAvailability `json:"availability,omitempty"` + // The number of volumes launched for each instance. Users can choose up to 10 + // volumes. This feature is only enabled for supported node types. Legacy node + // types cannot specify custom EBS volumes. For node types with no instance + // store, at least one EBS volume needs to be specified; otherwise, cluster + // creation will fail. + // + // These EBS volumes will be mounted at ``/ebs0``, ``/ebs1``, and etc. Instance + // store volumes will be mounted at ``/local_disk0``, ``/local_disk1``, and etc. + // + // If EBS volumes are attached, will configure Spark to use only + // the EBS volumes for scratch storage because heterogeneously sized scratch + // devices can lead to inefficient disk utilization. If no EBS volumes are + // attached, will configure Spark to use instance store volumes. + // + // Please note that if EBS volumes are specified, then the Spark configuration + // ``spark.local.dir`` will be overridden. + EbsVolumeCount *int `json:"ebs_volume_count,omitempty"` + EbsVolumeIops *int `json:"ebs_volume_iops,omitempty"` + // The size of each EBS volume (in GiB) launched for each instance. For general + // purpose SSD, this value must be within the range 100 - 4096. For throughput + // optimized HDD, this value must be within the range 500 - 4096. + EbsVolumeSize *int `json:"ebs_volume_size,omitempty"` + EbsVolumeThroughput *int `json:"ebs_volume_throughput,omitempty"` + // The type of EBS volumes that will be launched with this cluster. + EbsVolumeType PipelinesEbsVolumeType `json:"ebs_volume_type,omitempty"` + // The first ``first_on_demand`` nodes of the cluster will be placed on + // on-demand instances. If this value is greater than 0, the cluster driver node + // in particular will be placed on an on-demand instance. If this value is + // greater than or equal to the current cluster size, all nodes will be placed + // on on-demand instances. If this value is less than the current cluster size, + // ``first_on_demand`` nodes will be placed on on-demand instances and the + // remainder will be placed on ``availability`` instances. Note that this value + // does not affect cluster size and cannot currently be mutated over the + // lifetime of a cluster. + FirstOnDemand *int `json:"first_on_demand,omitempty"` + // Nodes for this cluster will only be placed on AWS instances with this + // instance profile. If omitted, nodes will be placed on instances without an + // IAM instance profile. The instance profile must have previously been added to + // the environment by an account administrator. + // + // This feature may only be available to certain customer plans. + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // The bid price for AWS spot instances, as a percentage of the corresponding + // instance type's on-demand price. For example, if this field is set to 50, and + // the cluster needs a new ``r3.xlarge`` spot instance, then the bid price is + // half of the price of on-demand ``r3.xlarge`` instances. Similarly, if this + // field is set to 200, the bid price is twice the price of on-demand + // ``r3.xlarge`` instances. If not specified, the default value is 100. When + // spot instances are requested for this cluster, only spot instances whose bid + // price percentage matches this field will be considered. Note that, for + // safety, we enforce this field to be no more than 10000. + SpotBidPricePercent *int `json:"spot_bid_price_percent,omitempty"` + // Identifier for the availability zone/datacenter in which the cluster resides. + // This string will be of a form like "us-west-2a". The provided availability + // zone must be in the same region as the deployment. For example, + // "us-west-2a" is not a valid zone id if the deployment resides in + // the "us-east-1" region. This is an optional field at cluster creation, and if + // not specified, a default zone will be used. If the zone specified is "auto", + // will try to place cluster in a zone with high availability, and will retry + // placement in a different AZ if there is not enough capacity. The list of + // available zones as well as the default value can be found by using the `List + // Zones` method. + ZoneId *string `json:"zone_id,omitempty"` +} + +// Attributes set during cluster creation which are related to Azure.. +type PipelinesAzureAttributes struct { + // Availability type used for all subsequent nodes past the ``first_on_demand`` + // ones. Note: If ``first_on_demand`` is zero (which only happens on pool + // clusters), this availability type will be used for the entire cluster. + Availability PipelinesAzureAvailability `json:"availability,omitempty"` + // The first ``first_on_demand`` nodes of the cluster will be placed on + // on-demand instances. This value should be greater than 0, to make sure the + // cluster driver node is placed on an on-demand instance. If this value is + // greater than or equal to the current cluster size, all nodes will be placed + // on on-demand instances. If this value is less than the current cluster size, + // ``first_on_demand`` nodes will be placed on on-demand instances and the + // remainder will be placed on ``availability`` instances. Note that this value + // does not affect cluster size and cannot currently be mutated over the + // lifetime of a cluster. + FirstOnDemand *int `json:"first_on_demand,omitempty"` + // The max bid price to be used for Azure spot instances. The Max price for the + // bid cannot be higher than the on-demand price of the instance. If not + // specified, the default value is -1, which specifies that the instance cannot + // be evicted on the basis of price, and only on the basis of availability. + // Further, the value should > 0 or -1. + SpotBidMaxPrice *float64 `json:"spot_bid_max_price,omitempty"` +} + +// Cluster log delivery config. +type PipelinesClusterLogConf struct { + Dbfs *PipelinesDbfsStorageInfo `json:"dbfs,omitempty"` +} + +// A storage location in DBFS. +type PipelinesDbfsStorageInfo struct { + // dbfs destination, e.g. ``dbfs:/my/path`` + Destination *string `json:"destination,omitempty"` +} + +// The environment entity used to preserve serverless environment side panel, +// jobs' environment for non-notebook task, and SDP's environment for classic +// and serverless pipelines. In this minimal environment spec, only pip +// dependencies are supported.. +type PipelinesEnvironment struct { + // List of pip dependencies, as supported by the version of pip in this + // environment. Each dependency is a pip requirement file line + // https://pip.pypa.io/en/stable/reference/requirements-file-format/ Allowed + // dependency could be , , (WSFS or Volumes in ), + Dependencies []string `json:"dependencies,omitempty"` + // The environment version of the serverless Python environment used to execute + // customer Python code. Each environment version includes a specific Python + // version and a curated set of pre-installed libraries with defined versions, + // providing a stable and reproducible execution environment. + // + // supports a three-year lifecycle for each environment version. + // For available versions and their included packages, see + // https://docs.databricks.com/aws/en/release-notes/serverless/environment-version/ + // + // The value should be a string representing the environment version number, for + // example: `"4"`. + EnvironmentVersion *string `json:"environment_version,omitempty"` +} + +// Attributes set during cluster creation which are related to Gcp.. +type PipelinesGcpAttributes struct { + // This field determines whether the spark executors will be scheduled to run on + // preemptible VMs, on-demand VMs, or preemptible VMs with a fallback to + // on-demand VMs if the former is unavailable. + Availability PipelinesGcpAvailability `json:"availability,omitempty"` + // boot disk size in GB + BootDiskSize *int `json:"boot_disk_size,omitempty"` + // If provided, the cluster will impersonate the google service account when + // accessing gcloud services (like GCS). The google service account must have + // previously been added to the environment by an account + // administrator. + GoogleServiceAccount *string `json:"google_service_account,omitempty"` + // The number of local SSDs to attach to each worker and driver for this + // cluster. If left unspecified, the default number of local SSDs for the node + // type will be used. + // + // NOTE: Each instance type can only support a certain number of attached local + // SSDs. The value specified in local_ssd_count must be valid for BOTH the + // driver and worker instance type. See GCP docs here: + // https://cloud.google.com/compute/docs/disks#local_ssd_machine_type_restrictions + // + // Validation is performed at the RPC layer and the RPC will be rejected if the + // specified local_ssd_count is invalid. + LocalSsdCount *int `json:"local_ssd_count,omitempty"` + // Identifier for the availability zone in which the cluster resides. This can + // be one of the following: - "HA" => High availability, spread nodes across + // availability zones for a deployment region [default]. - "AUTO" + // => picks an availability zone to schedule the cluster on. - A + // GCP availability zone => Pick One of the available zones for (machine type + + // region) from https://cloud.google.com/compute/docs/regions-zones. + ZoneId *string `json:"zone_id,omitempty"` +} + +// Config for an individual init script. +type PipelinesInitScriptInfo struct { + Dbfs *PipelinesDbfsStorageInfo `json:"dbfs,omitempty"` + S3 *PipelinesS3StorageInfo `json:"s3,omitempty"` +} + +// Write-only setting, available only in Create/Update calls. Specifies the user +// or service principal that the pipeline runs as. If not specified, the +// pipeline runs as the user who created the pipeline. +// +// Only `user_name` or `service_principal_name` can be specified. If both are +// specified, an error is thrown.. +type PipelinesJobRunAs struct { + GroupName *string `json:"group_name,omitempty"` + ServicePrincipalName *string `json:"service_principal_name,omitempty"` + UserName *string `json:"user_name,omitempty"` +} + +type PipelinesMavenLibrary struct { + // Gradle-style maven coordinates. For example: "org.jsoup:jsoup:1.7.2". + Coordinates *string `json:"coordinates,omitempty"` + // List of dependencies to exclude. For example: `["slf4j:slf4j", + // "*:hadoop-client"]`. + // + // Maven dependency exclusions: + // https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html. + Exclusions []string `json:"exclusions,omitempty"` + // Maven repo to install the Maven package from. If omitted, both Maven Central + // Repository and Spark Packages are searched. + Repo *string `json:"repo,omitempty"` +} + +// A storage location in Amazon S3. +type PipelinesS3StorageInfo struct { + // Set canned access control list for the logs, e.g. + // ``bucket-owner-full-control``. If ``canned_cal`` is set, please make sure the + // cluster iam role has ``s3:PutObjectAcl`` permission on the destination bucket + // and prefix. The full list of possible canned acl can be found at + // http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl. + // Please also note that by default only the object owner gets full controls. If + // you are using cross account role for writing data, you may want to set + // ``bucket-owner-full-control`` to make bucket owner able to read the logs. + CannedAcl *string `json:"canned_acl,omitempty"` + // S3 destination, e.g. ``s3://my-bucket/some-prefix`` Note that logs will be + // delivered using cluster iam role, please make sure you set cluster iam role + // and the role has write access to the destination. Please also note that you + // cannot use AWS keys to deliver logs. + Destination *string `json:"destination,omitempty"` + // Flag to enable server side encryption, ``false`` by default. + EnableEncryption *bool `json:"enable_encryption,omitempty"` + // The encryption type, it could be ``sse-s3`` or ``sse-kms``. It will be used + // only when encryption is enabled and the default type is ``sse-s3``. + EncryptionType *string `json:"encryption_type,omitempty"` + // S3 endpoint, e.g. ``https://s3-us-west-2.amazonaws.com``. Either region or + // endpoint needs to be set. If both are set, endpoint will be used. + Endpoint *string `json:"endpoint,omitempty"` + // Kms key which will be used if encryption is enabled and encryption type is + // set to ``sse-kms``. + KmsKey *string `json:"kms_key,omitempty"` + // S3 region, e.g. ``us-west-2``. Either region or endpoint needs to be set. If + // both are set, endpoint will be used. + Region *string `json:"region,omitempty"` +} + +// PG-specific catalog-level configuration parameters. +type PostgresCatalogConfig struct { + // Optional. The Postgres slot configuration to use for logical replication + SlotConfig *PostgresSlotConfig `json:"slot_config,omitempty"` +} + +// PostgresSlotConfig contains the configuration for a Postgres logical +// replication slot. +type PostgresSlotConfig struct { + // The name of the publication to use for the Postgres source + PublicationName *string `json:"publication_name,omitempty"` + // The name of the logical replication slot to use for the Postgres source + SlotName *string `json:"slot_name,omitempty"` +} + +type ProtobufTransformerOptions struct { + // Required: path to the .desc file (dbfs:/... or /Volumes/...). + DescFilePath *string `json:"desc_file_path,omitempty"` + // Required: fully-qualified message type name. + MessageName *string `json:"message_name,omitempty"` + // (Optional) Parse mode for Protobuf data. Valid values: FAILFAST, PERMISSIVE. + // Defaults to PERMISSIVE. + ParseMode ParseMode `json:"parse_mode,omitempty"` + // (Optional) Maximum expansion depth for recursive protobuf fields. Spark SQL + // does not natively support recursive types, so recursive fields are expanded + // up to this depth and truncated beyond it. Valid values: -1 (disallow + // recursive fields), 0 (drop), 1-10. + RecursiveFieldsMaxDepth *int `json:"recursive_fields_max_depth,omitempty"` + // (Optional) Schema registry to resolve the Protobuf schema at runtime instead + // of providing it via desc_file_path. + SchemaRegistry *SchemaRegistryConfig `json:"schema_registry,omitempty"` +} + +// RabbitMQ specific options for ingestion. Performance tuning options +// (consumers_per_task, max_messages_per_fetch, etc.) are intentionally not +// exposed in the public API. The managed connector uses sensible defaults +// internally. These can be added later if user demand arises.. +type RabbitmqOptions struct { + // (Required) RabbitMQ queue name to consume from. + Queue *string `json:"queue,omitempty"` +} + +// Reddit Ads specific options for ingestion. +type RedditAdsOptions struct { + // (Optional) Custom report definition. When set, the table is treated as a + // user-defined Reddit Ads custom report. When unset, the table must match one + // of the connector's prebuilt sources. + CustomReportOptions *RedditAdsOptions_RedditAdsCustomReportOptions `json:"custom_report_options,omitempty"` + // (Optional) Number of days to look back for report tables during incremental + // sync to capture late-arriving conversions and attribution data. If not + // specified, defaults to 30 days. + LookbackWindowDays *int `json:"lookback_window_days,omitempty"` + // (Optional) Start date for the initial sync of report tables in YYYY-MM-DD + // format. This determines the earliest date from which to sync historical data. + // If not specified, defaults to 2 years ago. + SyncStartDate *string `json:"sync_start_date,omitempty"` +} + +// User-defined custom report for the Reddit Ads connector. Applies only to the +// custom_report table — prebuilt tables ignore this.. +type RedditAdsOptions_RedditAdsCustomReportOptions struct { + // (Optional) Breakdown dimensions to group report data by. Examples: + // CAMPAIGN_ID, DATE, COUNTRY, REGION, AD_ID. Must include at least one time + // dimension (DATE or HOUR). + Breakdowns []string `json:"breakdowns,omitempty"` + // (Optional) Fields to include in the report (maps to the Reddit Ads API + // `fields` parameter). Examples: IMPRESSIONS, CLICKS, SPEND, CPC, CTR. + Fields []string `json:"fields,omitempty"` +} + +// Specifies a replace_where predicate override for a replace where flow.. +type ReplaceWhereOverride struct { + // Name of the flow to apply this override to. + FlowName *string `json:"flow_name,omitempty"` + // SQL predicate string to use as replace_where condition. Example: `date = + // '2024-10-10' AND city = 'xyz'` + PredicateOverride *string `json:"predicate_override,omitempty"` +} + +type RestartWindow struct { + // Days of week in which the restart is allowed to happen (within a five-hour + // window starting at start_hour). If not specified all days of the week will be + // used. + DaysOfWeek []DayOfWeek `json:"days_of_week,omitempty"` + // An integer between 0 and 23 denoting the start hour for the restart window in + // the 24-hour day. Continuous pipeline restart is triggered only within a + // five-hour window starting at this hour. + StartHour *int `json:"start_hour,omitempty"` + // Time zone id of restart window. See + // https://docs.databricks.com/sql/language-manual/sql-ref-syntax-aux-conf-mgmt-set-timezone.html + // for details. If not specified, UTC will be used. + TimeZoneId *string `json:"time_zone_id,omitempty"` +} + +// Configuration for rewinding a specific dataset.. +type RewindDatasetSpec struct { + // Whether to cascade the rewind to dependent datasets. Must be specified. + Cascade *bool `json:"cascade,omitempty"` + // The identifier of the dataset (e.g., "main.foo.tbl1"). + Identifier *string `json:"identifier,omitempty"` + // Whether to reset checkpoints for this dataset. + ResetCheckpoints *bool `json:"reset_checkpoints,omitempty"` +} + +// Information about a rewind being requested for this pipeline or some of the +// datasets in it.. +type RewindSpec struct { + // List of datasets to rewind with specific configuration for each. When not + // specified, all datasets will be rewound with cascade = true and + // reset_checkpoints = true. + Datasets []RewindDatasetSpec `json:"datasets,omitempty"` + // If true, this is a dry run and we should emit the RewindSummary but not + // perform the rewind. + DryRun *bool `json:"dry_run,omitempty"` + // The base timestamp to rewind to. Exactly one of rewind_timestamp or + // rewind_point_id must be specified. + RewindTimestamp *string `json:"rewind_timestamp,omitempty"` +} + +type SchemaRegistryConfig struct { + // Required: Confluent-compatible schema registry options. + ConfluentOptions *ConfluentSchemaRegistryOptions `json:"confluent_options,omitempty"` + // (Optional) UC connection for registry authentication. Specify if different + // from the top-level source connection. + ConnectionName *string `json:"connection_name,omitempty"` + // (Optional, Protobuf only) Selects a specific message from a schema that + // defines multiple Protobuf messages. Simple ("Location") or fully-qualified + // ("com.example.protos.Location"). Defaults to the first message. + ProtobufMessageName *string `json:"protobuf_message_name,omitempty"` +} + +type Sequencing struct { + // A sequence number, unique and increasing per pipeline. + ControlPlaneSeqNo *int64 `json:"control_plane_seq_no,omitempty"` + // the ID assigned by the data plane. + DataPlaneId *DataPlaneId `json:"data_plane_id,omitempty"` +} + +type SerializedException struct { + // Runtime class of the exception + ClassName *string `json:"class_name,omitempty"` + // Exception message + Message *string `json:"message,omitempty"` + // Stack trace consisting of a list of stack frames + Stack []StackFrame `json:"stack,omitempty"` +} + +type SharepointOptions struct { + // (Optional) The type of SharePoint entity to ingest. If not specified, + // defaults to FILE. + EntityType SharepointOptions_SharepointEntityType `json:"entity_type,omitempty"` + // (Optional) File ingestion options for processing files. + FileIngestionOptions *FileIngestionOptions `json:"file_ingestion_options,omitempty"` + // Required. The SharePoint URL. + Url *string `json:"url,omitempty"` +} + +// Smartsheet specific options for ingestion. +type SmartsheetOptions struct { + // (Optional) When true, maps each column to its Smartsheet-declared type + // (Text/Number/Date/ Checkbox/etc.). Cells that do not conform to the declared + // type are set to NULL. When false, all columns land as STRING. Use false for + // sheets with irregular data or columns that frequently violate their own + // declared type. If not specified, defaults to true. + EnforceSchema *bool `json:"enforce_schema,omitempty"` +} + +// SourceCatalogConfig contains catalog-level custom configuration parameters +// for each source. +type SourceCatalogConfig struct { + Postgres *PostgresCatalogConfig `json:"postgres,omitempty"` + // Source catalog name + SourceCatalog *string `json:"source_catalog,omitempty"` +} + +type SourceConfig struct { + ApiSourceConnectorConfig *ApiSourceConnectorConfig `json:"api_source_connector_config,omitempty"` + // Catalog-level source configuration parameters + Catalog *SourceCatalogConfig `json:"catalog,omitempty"` + GoogleAdsConfig *GoogleAdsConfig `json:"google_ads_config,omitempty"` +} + +type StackFrame struct { + // Class from which the method call originated + DeclaringClass *string `json:"declaring_class,omitempty"` + // File where the method is defined + FileName *string `json:"file_name,omitempty"` + // Line from which the method was called + LineNumber *int `json:"line_number,omitempty"` + // Name of the method which was called + MethodName *string `json:"method_name,omitempty"` +} + +type StartUpdateRequest struct { + Cause UpdateCause `json:"cause,omitempty"` + // Whether the update is started in the development mode. This is recommended + // for interactive development and testing. Reuses compute for faster iteration + // and disables automatic retries. Not recommended for production. + Development *bool `json:"development,omitempty"` + // If true, this update will reset all tables before running. + FullRefresh *bool `json:"full_refresh,omitempty"` + // A list of tables to update with fullRefresh. If both refresh_selection and + // full_refresh_selection are empty, this is a full graph update. Full Refresh + // on a table means that the states of the table will be reset before the + // refresh. + FullRefreshSelection []string `json:"full_refresh_selection,omitempty"` + // Key/value map of parameters to pass to the pipeline execution + Parameters map[string]string `json:"parameters,omitempty"` + PipelineId *string `json:"pipeline_id,omitempty"` + // A list of tables to update without fullRefresh. If both refresh_selection and + // full_refresh_selection are empty, this is a full graph update. Full Refresh + // on a table means that the states of the table will be reset before the + // refresh. + RefreshSelection []string `json:"refresh_selection,omitempty"` + // A list of predicate overrides for replace_where flows in this update. Only + // replace_where flows may be specified. Flows not listed use their original + // predicate. + ReplaceWhereOverrides []ReplaceWhereOverride `json:"replace_where_overrides,omitempty"` + // A list of flows for which this update should reset the streaming checkpoint. + // This selection will not clear the data in the flow's target table. Flows in + // this list may also appear in refresh_selection and full_refresh_selection. + ResetCheckpointSelection []string `json:"reset_checkpoint_selection,omitempty"` + // The information about the requested rewind operation. If specified this is a + // rewind mode update. + RewindSpec *RewindSpec `json:"rewind_spec,omitempty"` + // If true, this update only validates the correctness of pipeline source code + // but does not materialize or publish any datasets. + ValidateOnly *bool `json:"validate_only,omitempty"` +} + +type StartUpdateResponse struct { + UpdateId *string `json:"update_id,omitempty"` +} + +type StopPipelineRequest struct { + PipelineId *string `json:"pipeline_id,omitempty"` +} + +// TikTok Ads specific options for ingestion. +type TikTokAdsOptions struct { + // (Optional) Custom report definition. When set, the table is treated as a + // user-defined TikTok Ads custom report: the connector synthesizes a report + // request from the dimensions, metrics, report type, and data level specified + // here. Supersedes the deprecated top-level dimensions/metrics/report_type/ + // data_level/query_lifetime fields above. + CustomReportOptions *TikTokAdsOptions_TikTokAdsCustomReportOptions `json:"custom_report_options,omitempty"` + // Deprecated. Use custom_report_options.data_level instead. + DataLevel TikTokAdsOptions_TikTokDataLevel `json:"data_level,omitempty"` + // Deprecated. Use custom_report_options.dimensions instead. + Dimensions []string `json:"dimensions,omitempty"` + // (Optional) Number of days to look back for report tables during incremental + // sync to capture late-arriving conversions and attribution data. + LookbackWindowDays *int `json:"lookback_window_days,omitempty"` + // Deprecated. Use custom_report_options.metrics instead. + Metrics []string `json:"metrics,omitempty"` + // Deprecated. Use custom_report_options.query_lifetime instead. + QueryLifetime *bool `json:"query_lifetime,omitempty"` + // Deprecated. Use custom_report_options.report_type instead. + ReportType TikTokAdsOptions_TikTokReportType `json:"report_type,omitempty"` + // (Optional) Start date for the initial sync of report tables in YYYY-MM-DD + // format. This determines the earliest date from which to sync historical data. + SyncStartDate *string `json:"sync_start_date,omitempty"` +} + +// User-defined custom report for the TikTok Ads connector. Groups the +// dimensions + metrics + report type + data level that define a TikTok Ads +// custom report request.. +type TikTokAdsOptions_TikTokAdsCustomReportOptions struct { + // (Optional) Data level for the report. If not specified, defaults to + // AUCTION_CAMPAIGN. + DataLevel TikTokAdsOptions_TikTokDataLevel `json:"data_level,omitempty"` + // (Optional) Dimensions to include in the report (e.g. "campaign_id", + // "adgroup_id", "ad_id", "stat_time_day", "stat_time_hour"). + Dimensions []string `json:"dimensions,omitempty"` + // (Optional) Metrics to include in the report (e.g. "spend", "impressions", + // "clicks", "conversion", "cpc"). + Metrics []string `json:"metrics,omitempty"` + // (Optional) Whether to request lifetime metrics (all-time aggregated data). + // When true, the report returns all-time data. If not specified, defaults to + // false. + QueryLifetime *bool `json:"query_lifetime,omitempty"` + // (Optional) Report type for the TikTok Ads API. If not specified, defaults to + // BASIC. + ReportType TikTokAdsOptions_TikTokReportType `json:"report_type,omitempty"` +} + +// Specifies how to transform binary data into structured data.. +type Transformer struct { + AvroOptions *AvroTransformerOptions `json:"avro_options,omitempty"` + // Required: the wire format of the data. + Format Transformer_Format `json:"format,omitempty"` + // Optional input column to transform. When set, the transformer reads from this + // column instead of the default source column. + InputColumn *string `json:"input_column,omitempty"` + JsonOptions *JsonTransformerOptions `json:"json_options,omitempty"` + // Optional output column name. When set, the transformed result is written to + // this column instead of replacing the input column. + OutputColumn *string `json:"output_column,omitempty"` + ProtobufOptions *ProtobufTransformerOptions `json:"protobuf_options,omitempty"` +} + +// Information about truncations applied to this event.. +type Truncation struct { + // List of fields that were truncated from this event. If empty or absent, no + // truncation occurred. + TruncatedFields []Truncation_TruncationDetail `json:"truncated_fields,omitempty"` +} + +// Details about a specific field that was truncated.. +type Truncation_TruncationDetail struct { + // The name of the truncated field (e.g., "error"). Corresponds to field names + // in PipelineEvent. + FieldName *string `json:"field_name,omitempty"` +} + +type UpdateInfo struct { + // What triggered this update. + Cause UpdateCause `json:"cause,omitempty"` + // The ID of the cluster that the update is running on. + ClusterId *string `json:"cluster_id,omitempty"` + // The pipeline configuration with system defaults applied where unspecified by + // the user. Not returned by ListUpdates. + Config *PipelineSpec `json:"config,omitempty"` + // The time when this update was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // If true, this update will reset all tables before running. + FullRefresh *bool `json:"full_refresh,omitempty"` + // A list of tables to update with fullRefresh. If both refresh_selection and + // full_refresh_selection are empty, this is a full graph update. Full Refresh + // on a table means that the states of the table will be reset before the + // refresh. + FullRefreshSelection []string `json:"full_refresh_selection,omitempty"` + // Indicates whether the update is either part of a continuous job run, or + // running in legacy continuous pipeline mode. Returned only for GetUpdate; not + // populated in ListUpdates responses. + Mode UpdateMode `json:"mode,omitempty"` + // Key/value map of parameters used to initiate the update + Parameters map[string]string `json:"parameters,omitempty"` + // The ID of the pipeline. + PipelineId *string `json:"pipeline_id,omitempty"` + // A list of tables to update without fullRefresh. If both refresh_selection and + // full_refresh_selection are empty, this is a full graph update. Full Refresh + // on a table means that the states of the table will be reset before the + // refresh. + RefreshSelection []string `json:"refresh_selection,omitempty"` + // The update state. + State UpdateState `json:"state,omitempty"` + // The ID of this update. + UpdateId *string `json:"update_id,omitempty"` + // If true, this update only validates the correctness of pipeline source code + // but does not materialize or publish any datasets. + ValidateOnly *bool `json:"validate_only,omitempty"` +} + +type UpdateStateInfo struct { + CreationTime *string `json:"creation_time,omitempty"` + State UpdateState `json:"state,omitempty"` + UpdateId *string `json:"update_id,omitempty"` +} + +// Zendesk Support specific options for ingestion. +type ZendeskSupportOptions struct { + // (Optional) Start date in YYYY-MM-DD format for the initial sync. This + // determines the earliest date from which to sync historical data. + StartDate *string `json:"start_date,omitempty"` +} + +// ApiSourceConnectorConfigToSDK converts the mirror to the sdk-go type. +func ApiSourceConnectorConfigToSDK(w *ApiSourceConnectorConfig) (*sdk.ApiSourceConnectorConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApiSourceConnectorConfig{} + out.Configs = w.Configs + return out, nil +} + +// ApiSourceConnectorConfigFromSDK converts the sdk-go type to the mirror. +func ApiSourceConnectorConfigFromSDK(v *sdk.ApiSourceConnectorConfig) (*ApiSourceConnectorConfig, error) { + if v == nil { + return nil, nil + } + out := &ApiSourceConnectorConfig{} + out.Configs = v.Configs + return out, nil +} + +// ApiSourceConnectorOptionsToSDK converts the mirror to the sdk-go type. +func ApiSourceConnectorOptionsToSDK(w *ApiSourceConnectorOptions) (*sdk.ApiSourceConnectorOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApiSourceConnectorOptions{} + out.Options = w.Options + return out, nil +} + +// ApiSourceConnectorOptionsFromSDK converts the sdk-go type to the mirror. +func ApiSourceConnectorOptionsFromSDK(v *sdk.ApiSourceConnectorOptions) (*ApiSourceConnectorOptions, error) { + if v == nil { + return nil, nil + } + out := &ApiSourceConnectorOptions{} + out.Options = v.Options + return out, nil +} + +// ApplyEnvironmentRequestToSDK converts the mirror to the sdk-go type. +func ApplyEnvironmentRequestToSDK(w *ApplyEnvironmentRequest) (*sdk.ApplyEnvironmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApplyEnvironmentRequest{} + out.PipelineId = w.PipelineId + return out, nil +} + +// ApplyEnvironmentRequestFromSDK converts the sdk-go type to the mirror. +func ApplyEnvironmentRequestFromSDK(v *sdk.ApplyEnvironmentRequest) (*ApplyEnvironmentRequest, error) { + if v == nil { + return nil, nil + } + out := &ApplyEnvironmentRequest{} + out.PipelineId = v.PipelineId + return out, nil +} + +// AutoFullRefreshPolicyToSDK converts the mirror to the sdk-go type. +func AutoFullRefreshPolicyToSDK(w *AutoFullRefreshPolicy) (*sdk.AutoFullRefreshPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.AutoFullRefreshPolicy{} + out.Enabled = w.Enabled + out.MinIntervalHours = w.MinIntervalHours + return out, nil +} + +// AutoFullRefreshPolicyFromSDK converts the sdk-go type to the mirror. +func AutoFullRefreshPolicyFromSDK(v *sdk.AutoFullRefreshPolicy) (*AutoFullRefreshPolicy, error) { + if v == nil { + return nil, nil + } + out := &AutoFullRefreshPolicy{} + out.Enabled = v.Enabled + out.MinIntervalHours = v.MinIntervalHours + return out, nil +} + +// AvroTransformerOptionsToSDK converts the mirror to the sdk-go type. +func AvroTransformerOptionsToSDK(w *AvroTransformerOptions) (*sdk.AvroTransformerOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.AvroTransformerOptions{} + out.Schema = w.Schema + out.SchemaFilePath = w.SchemaFilePath + out.ParseMode = w.ParseMode + conv1, err := SchemaRegistryConfigToSDK(w.SchemaRegistry) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AvroTransformerOptions.SchemaRegistry", err) + } + out.SchemaRegistry = conv1 + return out, nil +} + +// AvroTransformerOptionsFromSDK converts the sdk-go type to the mirror. +func AvroTransformerOptionsFromSDK(v *sdk.AvroTransformerOptions) (*AvroTransformerOptions, error) { + if v == nil { + return nil, nil + } + out := &AvroTransformerOptions{} + out.Schema = v.Schema + out.SchemaFilePath = v.SchemaFilePath + out.ParseMode = v.ParseMode + conv2, err := SchemaRegistryConfigFromSDK(v.SchemaRegistry) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AvroTransformerOptions.SchemaRegistry", err) + } + out.SchemaRegistry = conv2 + return out, nil +} + +// ClonePipelineRequestToSDK converts the mirror to the sdk-go type. +func ClonePipelineRequestToSDK(w *ClonePipelineRequest) (*sdk.ClonePipelineRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClonePipelineRequest{} + out.PipelineId = w.PipelineId + out.ExpectedLastModified = w.ExpectedLastModified + out.AllowDuplicateNames = w.AllowDuplicateNames + out.Id = w.Id + out.Name = w.Name + out.Storage = w.Storage + out.Configuration = w.Configuration + conv3, err := convertSlice(w.Clusters, PipelineClusterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Clusters", err) + } + out.Clusters = conv3 + conv4, err := convertSlice(w.Libraries, PipelineLibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Libraries", err) + } + out.Libraries = conv4 + conv5, err := IngestionPipelineDefinitionToSDK(w.IngestionDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.IngestionDefinition", err) + } + out.IngestionDefinition = conv5 + conv6, err := IngestionGatewayPipelineDefinitionToSDK(w.GatewayDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.GatewayDefinition", err) + } + out.GatewayDefinition = conv6 + conv7, err := PipelineTriggerToSDK(w.Trigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Trigger", err) + } + out.Trigger = conv7 + out.Target = w.Target + out.Schema = w.Schema + conv8, err := FiltersToSDK(w.Filters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Filters", err) + } + out.Filters = conv8 + out.Continuous = w.Continuous + out.Development = w.Development + out.Photon = w.Photon + out.Edition = w.Edition + out.Channel = w.Channel + out.Catalog = w.Catalog + conv9, err := convertSlice(w.Notifications, NotificationsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Notifications", err) + } + out.Notifications = conv9 + out.Serverless = w.Serverless + conv10, err := PipelineDeploymentToSDK(w.Deployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Deployment", err) + } + out.Deployment = conv10 + conv11, err := RestartWindowToSDK(w.RestartWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.RestartWindow", err) + } + out.RestartWindow = conv11 + out.BudgetPolicyId = w.BudgetPolicyId + out.Tags = w.Tags + conv12, err := EventLogSpecToSDK(w.EventLog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.EventLog", err) + } + out.EventLog = conv12 + out.RootPath = w.RootPath + conv13, err := PipelinesEnvironmentToSDK(w.Environment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Environment", err) + } + out.Environment = conv13 + out.ParentPath = w.ParentPath + out.UsagePolicyId = w.UsagePolicyId + out.ServerlessComputeId = w.ServerlessComputeId + out.CloneMode = w.CloneMode + return out, nil +} + +// ClonePipelineRequestFromSDK converts the sdk-go type to the mirror. +func ClonePipelineRequestFromSDK(v *sdk.ClonePipelineRequest) (*ClonePipelineRequest, error) { + if v == nil { + return nil, nil + } + out := &ClonePipelineRequest{} + out.PipelineId = v.PipelineId + out.ExpectedLastModified = v.ExpectedLastModified + out.AllowDuplicateNames = v.AllowDuplicateNames + out.Id = v.Id + out.Name = v.Name + out.Storage = v.Storage + out.Configuration = v.Configuration + conv14, err := convertSlice(v.Clusters, PipelineClusterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Clusters", err) + } + out.Clusters = conv14 + conv15, err := convertSlice(v.Libraries, PipelineLibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Libraries", err) + } + out.Libraries = conv15 + conv16, err := IngestionPipelineDefinitionFromSDK(v.IngestionDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.IngestionDefinition", err) + } + out.IngestionDefinition = conv16 + conv17, err := IngestionGatewayPipelineDefinitionFromSDK(v.GatewayDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.GatewayDefinition", err) + } + out.GatewayDefinition = conv17 + conv18, err := PipelineTriggerFromSDK(v.Trigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Trigger", err) + } + out.Trigger = conv18 + out.Target = v.Target + out.Schema = v.Schema + conv19, err := FiltersFromSDK(v.Filters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Filters", err) + } + out.Filters = conv19 + out.Continuous = v.Continuous + out.Development = v.Development + out.Photon = v.Photon + out.Edition = v.Edition + out.Channel = v.Channel + out.Catalog = v.Catalog + conv20, err := convertSlice(v.Notifications, NotificationsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Notifications", err) + } + out.Notifications = conv20 + out.Serverless = v.Serverless + conv21, err := PipelineDeploymentFromSDK(v.Deployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Deployment", err) + } + out.Deployment = conv21 + conv22, err := RestartWindowFromSDK(v.RestartWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.RestartWindow", err) + } + out.RestartWindow = conv22 + out.BudgetPolicyId = v.BudgetPolicyId + out.Tags = v.Tags + conv23, err := EventLogSpecFromSDK(v.EventLog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.EventLog", err) + } + out.EventLog = conv23 + out.RootPath = v.RootPath + conv24, err := PipelinesEnvironmentFromSDK(v.Environment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClonePipelineRequest.Environment", err) + } + out.Environment = conv24 + out.ParentPath = v.ParentPath + out.UsagePolicyId = v.UsagePolicyId + out.ServerlessComputeId = v.ServerlessComputeId + out.CloneMode = v.CloneMode + return out, nil +} + +// ClonePipelineResponseToSDK converts the mirror to the sdk-go type. +func ClonePipelineResponseToSDK(w *ClonePipelineResponse) (*sdk.ClonePipelineResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClonePipelineResponse{} + out.PipelineId = w.PipelineId + return out, nil +} + +// ClonePipelineResponseFromSDK converts the sdk-go type to the mirror. +func ClonePipelineResponseFromSDK(v *sdk.ClonePipelineResponse) (*ClonePipelineResponse, error) { + if v == nil { + return nil, nil + } + out := &ClonePipelineResponse{} + out.PipelineId = v.PipelineId + return out, nil +} + +// ConfluenceConnectorOptionsToSDK converts the mirror to the sdk-go type. +func ConfluenceConnectorOptionsToSDK(w *ConfluenceConnectorOptions) (*sdk.ConfluenceConnectorOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.ConfluenceConnectorOptions{} + out.IncludeConfluenceSpaces = w.IncludeConfluenceSpaces + return out, nil +} + +// ConfluenceConnectorOptionsFromSDK converts the sdk-go type to the mirror. +func ConfluenceConnectorOptionsFromSDK(v *sdk.ConfluenceConnectorOptions) (*ConfluenceConnectorOptions, error) { + if v == nil { + return nil, nil + } + out := &ConfluenceConnectorOptions{} + out.IncludeConfluenceSpaces = v.IncludeConfluenceSpaces + return out, nil +} + +// ConfluentSchemaRegistryOptionsToSDK converts the mirror to the sdk-go type. +func ConfluentSchemaRegistryOptionsToSDK(w *ConfluentSchemaRegistryOptions) (*sdk.ConfluentSchemaRegistryOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.ConfluentSchemaRegistryOptions{} + out.Subject = w.Subject + return out, nil +} + +// ConfluentSchemaRegistryOptionsFromSDK converts the sdk-go type to the mirror. +func ConfluentSchemaRegistryOptionsFromSDK(v *sdk.ConfluentSchemaRegistryOptions) (*ConfluentSchemaRegistryOptions, error) { + if v == nil { + return nil, nil + } + out := &ConfluentSchemaRegistryOptions{} + out.Subject = v.Subject + return out, nil +} + +// ConnectionParametersToSDK converts the mirror to the sdk-go type. +func ConnectionParametersToSDK(w *ConnectionParameters) (*sdk.ConnectionParameters, error) { + if w == nil { + return nil, nil + } + out := &sdk.ConnectionParameters{} + out.SourceCatalog = w.SourceCatalog + return out, nil +} + +// ConnectionParametersFromSDK converts the sdk-go type to the mirror. +func ConnectionParametersFromSDK(v *sdk.ConnectionParameters) (*ConnectionParameters, error) { + if v == nil { + return nil, nil + } + out := &ConnectionParameters{} + out.SourceCatalog = v.SourceCatalog + return out, nil +} + +// ConnectorOptionsToSDK converts the mirror to the sdk-go type. +func ConnectorOptionsToSDK(w *ConnectorOptions) (*sdk.ConnectorOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.ConnectorOptions{} + { + var members []string + if w.GoogleAdsOptions != nil { + members = append(members, "google_ads_options") + } + if w.TiktokAdsOptions != nil { + members = append(members, "tiktok_ads_options") + } + if w.SharepointOptions != nil { + members = append(members, "sharepoint_options") + } + if w.GdriveOptions != nil { + members = append(members, "gdrive_options") + } + if w.OutlookOptions != nil { + members = append(members, "outlook_options") + } + if w.SmartsheetOptions != nil { + members = append(members, "smartsheet_options") + } + if w.JiraOptions != nil { + members = append(members, "jira_options") + } + if w.ConfluenceOptions != nil { + members = append(members, "confluence_options") + } + if w.MetaAdsOptions != nil { + members = append(members, "meta_ads_options") + } + if w.ZendeskSupportOptions != nil { + members = append(members, "zendesk_support_options") + } + if w.KafkaOptions != nil { + members = append(members, "kafka_options") + } + if w.RabbitmqOptions != nil { + members = append(members, "rabbitmq_options") + } + if w.MarketoOptions != nil { + members = append(members, "marketo_options") + } + if w.LinkedinAdsOptions != nil { + members = append(members, "linkedin_ads_options") + } + if w.RedditAdsOptions != nil { + members = append(members, "reddit_ads_options") + } + if w.ApiSourceConnectorOptions != nil { + members = append(members, "api_source_connector_options") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.GoogleAdsOptions != nil: + conv25, err := GoogleAdsOptionsToSDK(w.GoogleAdsOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_GoogleAdsOptions{GoogleAdsOptions: *conv25} + case w.TiktokAdsOptions != nil: + conv26, err := TikTokAdsOptionsToSDK(w.TiktokAdsOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_TiktokAdsOptions{TiktokAdsOptions: *conv26} + case w.SharepointOptions != nil: + conv27, err := SharepointOptionsToSDK(w.SharepointOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_SharepointOptions{SharepointOptions: *conv27} + case w.GdriveOptions != nil: + conv28, err := GoogleDriveOptionsToSDK(w.GdriveOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_GdriveOptions{GdriveOptions: *conv28} + case w.OutlookOptions != nil: + conv29, err := OutlookOptionsToSDK(w.OutlookOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_OutlookOptions{OutlookOptions: *conv29} + case w.SmartsheetOptions != nil: + conv30, err := SmartsheetOptionsToSDK(w.SmartsheetOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_SmartsheetOptions{SmartsheetOptions: *conv30} + case w.JiraOptions != nil: + conv31, err := JiraConnectorOptionsToSDK(w.JiraOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_JiraOptions{JiraOptions: *conv31} + case w.ConfluenceOptions != nil: + conv32, err := ConfluenceConnectorOptionsToSDK(w.ConfluenceOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_ConfluenceOptions{ConfluenceOptions: *conv32} + case w.MetaAdsOptions != nil: + conv33, err := MetaMarketingOptionsToSDK(w.MetaAdsOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_MetaAdsOptions{MetaAdsOptions: *conv33} + case w.ZendeskSupportOptions != nil: + conv34, err := ZendeskSupportOptionsToSDK(w.ZendeskSupportOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_ZendeskSupportOptions{ZendeskSupportOptions: *conv34} + case w.KafkaOptions != nil: + conv35, err := KafkaOptionsToSDK(w.KafkaOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_KafkaOptions{KafkaOptions: *conv35} + case w.RabbitmqOptions != nil: + conv36, err := RabbitmqOptionsToSDK(w.RabbitmqOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_RabbitmqOptions{RabbitmqOptions: *conv36} + case w.MarketoOptions != nil: + conv37, err := MarketoOptionsToSDK(w.MarketoOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_MarketoOptions{MarketoOptions: *conv37} + case w.LinkedinAdsOptions != nil: + conv38, err := LinkedInAdsOptionsToSDK(w.LinkedinAdsOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_LinkedinAdsOptions{LinkedinAdsOptions: *conv38} + case w.RedditAdsOptions != nil: + conv39, err := RedditAdsOptionsToSDK(w.RedditAdsOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_RedditAdsOptions{RedditAdsOptions: *conv39} + case w.ApiSourceConnectorOptions != nil: + conv40, err := ApiSourceConnectorOptionsToSDK(w.ApiSourceConnectorOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConnectorOptions = &sdk.ConnectorOptions_ConnectorOptions_ApiSourceConnectorOptions{ApiSourceConnectorOptions: *conv40} + } + return out, nil +} + +// ConnectorOptionsFromSDK converts the sdk-go type to the mirror. +func ConnectorOptionsFromSDK(v *sdk.ConnectorOptions) (*ConnectorOptions, error) { + if v == nil { + return nil, nil + } + out := &ConnectorOptions{} + switch value := v.ConnectorOptions.(type) { + case *sdk.ConnectorOptions_ConnectorOptions_GoogleAdsOptions: + if value != nil { + conv41, err := GoogleAdsOptionsFromSDK(&value.GoogleAdsOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.GoogleAdsOptions = conv41 + } + case *sdk.ConnectorOptions_ConnectorOptions_TiktokAdsOptions: + if value != nil { + conv42, err := TikTokAdsOptionsFromSDK(&value.TiktokAdsOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.TiktokAdsOptions = conv42 + } + case *sdk.ConnectorOptions_ConnectorOptions_SharepointOptions: + if value != nil { + conv43, err := SharepointOptionsFromSDK(&value.SharepointOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.SharepointOptions = conv43 + } + case *sdk.ConnectorOptions_ConnectorOptions_GdriveOptions: + if value != nil { + conv44, err := GoogleDriveOptionsFromSDK(&value.GdriveOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.GdriveOptions = conv44 + } + case *sdk.ConnectorOptions_ConnectorOptions_OutlookOptions: + if value != nil { + conv45, err := OutlookOptionsFromSDK(&value.OutlookOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.OutlookOptions = conv45 + } + case *sdk.ConnectorOptions_ConnectorOptions_SmartsheetOptions: + if value != nil { + conv46, err := SmartsheetOptionsFromSDK(&value.SmartsheetOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.SmartsheetOptions = conv46 + } + case *sdk.ConnectorOptions_ConnectorOptions_JiraOptions: + if value != nil { + conv47, err := JiraConnectorOptionsFromSDK(&value.JiraOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.JiraOptions = conv47 + } + case *sdk.ConnectorOptions_ConnectorOptions_ConfluenceOptions: + if value != nil { + conv48, err := ConfluenceConnectorOptionsFromSDK(&value.ConfluenceOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ConfluenceOptions = conv48 + } + case *sdk.ConnectorOptions_ConnectorOptions_MetaAdsOptions: + if value != nil { + conv49, err := MetaMarketingOptionsFromSDK(&value.MetaAdsOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.MetaAdsOptions = conv49 + } + case *sdk.ConnectorOptions_ConnectorOptions_ZendeskSupportOptions: + if value != nil { + conv50, err := ZendeskSupportOptionsFromSDK(&value.ZendeskSupportOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ZendeskSupportOptions = conv50 + } + case *sdk.ConnectorOptions_ConnectorOptions_KafkaOptions: + if value != nil { + conv51, err := KafkaOptionsFromSDK(&value.KafkaOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.KafkaOptions = conv51 + } + case *sdk.ConnectorOptions_ConnectorOptions_RabbitmqOptions: + if value != nil { + conv52, err := RabbitmqOptionsFromSDK(&value.RabbitmqOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.RabbitmqOptions = conv52 + } + case *sdk.ConnectorOptions_ConnectorOptions_MarketoOptions: + if value != nil { + conv53, err := MarketoOptionsFromSDK(&value.MarketoOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.MarketoOptions = conv53 + } + case *sdk.ConnectorOptions_ConnectorOptions_LinkedinAdsOptions: + if value != nil { + conv54, err := LinkedInAdsOptionsFromSDK(&value.LinkedinAdsOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.LinkedinAdsOptions = conv54 + } + case *sdk.ConnectorOptions_ConnectorOptions_RedditAdsOptions: + if value != nil { + conv55, err := RedditAdsOptionsFromSDK(&value.RedditAdsOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.RedditAdsOptions = conv55 + } + case *sdk.ConnectorOptions_ConnectorOptions_ApiSourceConnectorOptions: + if value != nil { + conv56, err := ApiSourceConnectorOptionsFromSDK(&value.ApiSourceConnectorOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectorOptions.ConnectorOptions", err) + } + out.ApiSourceConnectorOptions = conv56 + } + } + return out, nil +} + +// CreatePipelineRequestToSDK converts the mirror to the sdk-go type. +func CreatePipelineRequestToSDK(w *CreatePipelineRequest) (*sdk.CreatePipelineRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreatePipelineRequest{} + out.AllowDuplicateNames = w.AllowDuplicateNames + out.DryRun = w.DryRun + conv57, err := PipelinesJobRunAsToSDK(w.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.RunAs", err) + } + out.RunAs = conv57 + out.Parameters = w.Parameters + out.Id = w.Id + out.Name = w.Name + out.Storage = w.Storage + out.Configuration = w.Configuration + conv58, err := convertSlice(w.Clusters, PipelineClusterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Clusters", err) + } + out.Clusters = conv58 + conv59, err := convertSlice(w.Libraries, PipelineLibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Libraries", err) + } + out.Libraries = conv59 + conv60, err := IngestionPipelineDefinitionToSDK(w.IngestionDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.IngestionDefinition", err) + } + out.IngestionDefinition = conv60 + conv61, err := IngestionGatewayPipelineDefinitionToSDK(w.GatewayDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.GatewayDefinition", err) + } + out.GatewayDefinition = conv61 + conv62, err := PipelineTriggerToSDK(w.Trigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Trigger", err) + } + out.Trigger = conv62 + out.Target = w.Target + out.Schema = w.Schema + conv63, err := FiltersToSDK(w.Filters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Filters", err) + } + out.Filters = conv63 + out.Continuous = w.Continuous + out.Development = w.Development + out.Photon = w.Photon + out.Edition = w.Edition + out.Channel = w.Channel + out.Catalog = w.Catalog + conv64, err := convertSlice(w.Notifications, NotificationsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Notifications", err) + } + out.Notifications = conv64 + out.Serverless = w.Serverless + conv65, err := PipelineDeploymentToSDK(w.Deployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Deployment", err) + } + out.Deployment = conv65 + conv66, err := RestartWindowToSDK(w.RestartWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.RestartWindow", err) + } + out.RestartWindow = conv66 + out.BudgetPolicyId = w.BudgetPolicyId + out.Tags = w.Tags + conv67, err := EventLogSpecToSDK(w.EventLog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.EventLog", err) + } + out.EventLog = conv67 + out.RootPath = w.RootPath + conv68, err := PipelinesEnvironmentToSDK(w.Environment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Environment", err) + } + out.Environment = conv68 + out.ParentPath = w.ParentPath + out.UsagePolicyId = w.UsagePolicyId + out.ServerlessComputeId = w.ServerlessComputeId + return out, nil +} + +// CreatePipelineRequestFromSDK converts the sdk-go type to the mirror. +func CreatePipelineRequestFromSDK(v *sdk.CreatePipelineRequest) (*CreatePipelineRequest, error) { + if v == nil { + return nil, nil + } + out := &CreatePipelineRequest{} + out.AllowDuplicateNames = v.AllowDuplicateNames + out.DryRun = v.DryRun + conv69, err := PipelinesJobRunAsFromSDK(v.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.RunAs", err) + } + out.RunAs = conv69 + out.Parameters = v.Parameters + out.Id = v.Id + out.Name = v.Name + out.Storage = v.Storage + out.Configuration = v.Configuration + conv70, err := convertSlice(v.Clusters, PipelineClusterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Clusters", err) + } + out.Clusters = conv70 + conv71, err := convertSlice(v.Libraries, PipelineLibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Libraries", err) + } + out.Libraries = conv71 + conv72, err := IngestionPipelineDefinitionFromSDK(v.IngestionDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.IngestionDefinition", err) + } + out.IngestionDefinition = conv72 + conv73, err := IngestionGatewayPipelineDefinitionFromSDK(v.GatewayDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.GatewayDefinition", err) + } + out.GatewayDefinition = conv73 + conv74, err := PipelineTriggerFromSDK(v.Trigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Trigger", err) + } + out.Trigger = conv74 + out.Target = v.Target + out.Schema = v.Schema + conv75, err := FiltersFromSDK(v.Filters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Filters", err) + } + out.Filters = conv75 + out.Continuous = v.Continuous + out.Development = v.Development + out.Photon = v.Photon + out.Edition = v.Edition + out.Channel = v.Channel + out.Catalog = v.Catalog + conv76, err := convertSlice(v.Notifications, NotificationsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Notifications", err) + } + out.Notifications = conv76 + out.Serverless = v.Serverless + conv77, err := PipelineDeploymentFromSDK(v.Deployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Deployment", err) + } + out.Deployment = conv77 + conv78, err := RestartWindowFromSDK(v.RestartWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.RestartWindow", err) + } + out.RestartWindow = conv78 + out.BudgetPolicyId = v.BudgetPolicyId + out.Tags = v.Tags + conv79, err := EventLogSpecFromSDK(v.EventLog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.EventLog", err) + } + out.EventLog = conv79 + out.RootPath = v.RootPath + conv80, err := PipelinesEnvironmentFromSDK(v.Environment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineRequest.Environment", err) + } + out.Environment = conv80 + out.ParentPath = v.ParentPath + out.UsagePolicyId = v.UsagePolicyId + out.ServerlessComputeId = v.ServerlessComputeId + return out, nil +} + +// CreatePipelineResponseToSDK converts the mirror to the sdk-go type. +func CreatePipelineResponseToSDK(w *CreatePipelineResponse) (*sdk.CreatePipelineResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreatePipelineResponse{} + out.PipelineId = w.PipelineId + conv81, err := PipelineSpecToSDK(w.EffectiveSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineResponse.EffectiveSettings", err) + } + out.EffectiveSettings = conv81 + return out, nil +} + +// CreatePipelineResponseFromSDK converts the sdk-go type to the mirror. +func CreatePipelineResponseFromSDK(v *sdk.CreatePipelineResponse) (*CreatePipelineResponse, error) { + if v == nil { + return nil, nil + } + out := &CreatePipelineResponse{} + out.PipelineId = v.PipelineId + conv82, err := PipelineSpecFromSDK(v.EffectiveSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePipelineResponse.EffectiveSettings", err) + } + out.EffectiveSettings = conv82 + return out, nil +} + +// CronTriggerToSDK converts the mirror to the sdk-go type. +func CronTriggerToSDK(w *CronTrigger) (*sdk.CronTrigger, error) { + if w == nil { + return nil, nil + } + out := &sdk.CronTrigger{} + out.QuartzCronSchedule = w.QuartzCronSchedule + out.TimezoneId = w.TimezoneId + return out, nil +} + +// CronTriggerFromSDK converts the sdk-go type to the mirror. +func CronTriggerFromSDK(v *sdk.CronTrigger) (*CronTrigger, error) { + if v == nil { + return nil, nil + } + out := &CronTrigger{} + out.QuartzCronSchedule = v.QuartzCronSchedule + out.TimezoneId = v.TimezoneId + return out, nil +} + +// DataPlaneIdToSDK converts the mirror to the sdk-go type. +func DataPlaneIdToSDK(w *DataPlaneId) (*sdk.DataPlaneId, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataPlaneId{} + out.Instance = w.Instance + out.SeqNo = w.SeqNo + return out, nil +} + +// DataPlaneIdFromSDK converts the sdk-go type to the mirror. +func DataPlaneIdFromSDK(v *sdk.DataPlaneId) (*DataPlaneId, error) { + if v == nil { + return nil, nil + } + out := &DataPlaneId{} + out.Instance = v.Instance + out.SeqNo = v.SeqNo + return out, nil +} + +// DataStagingOptionsToSDK converts the mirror to the sdk-go type. +func DataStagingOptionsToSDK(w *DataStagingOptions) (*sdk.DataStagingOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataStagingOptions{} + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.VolumeName = w.VolumeName + return out, nil +} + +// DataStagingOptionsFromSDK converts the sdk-go type to the mirror. +func DataStagingOptionsFromSDK(v *sdk.DataStagingOptions) (*DataStagingOptions, error) { + if v == nil { + return nil, nil + } + out := &DataStagingOptions{} + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.VolumeName = v.VolumeName + return out, nil +} + +// DeletePipelineRequestToSDK converts the mirror to the sdk-go type. +func DeletePipelineRequestToSDK(w *DeletePipelineRequest) (*sdk.DeletePipelineRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeletePipelineRequest{} + out.PipelineId = w.PipelineId + out.Force = w.Force + out.Cascade = w.Cascade + return out, nil +} + +// DeletePipelineRequestFromSDK converts the sdk-go type to the mirror. +func DeletePipelineRequestFromSDK(v *sdk.DeletePipelineRequest) (*DeletePipelineRequest, error) { + if v == nil { + return nil, nil + } + out := &DeletePipelineRequest{} + out.PipelineId = v.PipelineId + out.Force = v.Force + out.Cascade = v.Cascade + return out, nil +} + +// EditPipelineRequestToSDK converts the mirror to the sdk-go type. +func EditPipelineRequestToSDK(w *EditPipelineRequest) (*sdk.EditPipelineRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.EditPipelineRequest{} + out.PipelineId = w.PipelineId + out.AllowDuplicateNames = w.AllowDuplicateNames + out.ExpectedLastModified = w.ExpectedLastModified + conv83, err := PipelinesJobRunAsToSDK(w.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.RunAs", err) + } + out.RunAs = conv83 + out.Parameters = w.Parameters + out.Id = w.Id + out.Name = w.Name + out.Storage = w.Storage + out.Configuration = w.Configuration + conv84, err := convertSlice(w.Clusters, PipelineClusterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Clusters", err) + } + out.Clusters = conv84 + conv85, err := convertSlice(w.Libraries, PipelineLibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Libraries", err) + } + out.Libraries = conv85 + conv86, err := IngestionPipelineDefinitionToSDK(w.IngestionDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.IngestionDefinition", err) + } + out.IngestionDefinition = conv86 + conv87, err := IngestionGatewayPipelineDefinitionToSDK(w.GatewayDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.GatewayDefinition", err) + } + out.GatewayDefinition = conv87 + conv88, err := PipelineTriggerToSDK(w.Trigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Trigger", err) + } + out.Trigger = conv88 + out.Target = w.Target + out.Schema = w.Schema + conv89, err := FiltersToSDK(w.Filters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Filters", err) + } + out.Filters = conv89 + out.Continuous = w.Continuous + out.Development = w.Development + out.Photon = w.Photon + out.Edition = w.Edition + out.Channel = w.Channel + out.Catalog = w.Catalog + conv90, err := convertSlice(w.Notifications, NotificationsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Notifications", err) + } + out.Notifications = conv90 + out.Serverless = w.Serverless + conv91, err := PipelineDeploymentToSDK(w.Deployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Deployment", err) + } + out.Deployment = conv91 + conv92, err := RestartWindowToSDK(w.RestartWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.RestartWindow", err) + } + out.RestartWindow = conv92 + out.BudgetPolicyId = w.BudgetPolicyId + out.Tags = w.Tags + conv93, err := EventLogSpecToSDK(w.EventLog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.EventLog", err) + } + out.EventLog = conv93 + out.RootPath = w.RootPath + conv94, err := PipelinesEnvironmentToSDK(w.Environment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Environment", err) + } + out.Environment = conv94 + out.ParentPath = w.ParentPath + out.UsagePolicyId = w.UsagePolicyId + out.ServerlessComputeId = w.ServerlessComputeId + return out, nil +} + +// EditPipelineRequestFromSDK converts the sdk-go type to the mirror. +func EditPipelineRequestFromSDK(v *sdk.EditPipelineRequest) (*EditPipelineRequest, error) { + if v == nil { + return nil, nil + } + out := &EditPipelineRequest{} + out.PipelineId = v.PipelineId + out.AllowDuplicateNames = v.AllowDuplicateNames + out.ExpectedLastModified = v.ExpectedLastModified + conv95, err := PipelinesJobRunAsFromSDK(v.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.RunAs", err) + } + out.RunAs = conv95 + out.Parameters = v.Parameters + out.Id = v.Id + out.Name = v.Name + out.Storage = v.Storage + out.Configuration = v.Configuration + conv96, err := convertSlice(v.Clusters, PipelineClusterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Clusters", err) + } + out.Clusters = conv96 + conv97, err := convertSlice(v.Libraries, PipelineLibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Libraries", err) + } + out.Libraries = conv97 + conv98, err := IngestionPipelineDefinitionFromSDK(v.IngestionDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.IngestionDefinition", err) + } + out.IngestionDefinition = conv98 + conv99, err := IngestionGatewayPipelineDefinitionFromSDK(v.GatewayDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.GatewayDefinition", err) + } + out.GatewayDefinition = conv99 + conv100, err := PipelineTriggerFromSDK(v.Trigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Trigger", err) + } + out.Trigger = conv100 + out.Target = v.Target + out.Schema = v.Schema + conv101, err := FiltersFromSDK(v.Filters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Filters", err) + } + out.Filters = conv101 + out.Continuous = v.Continuous + out.Development = v.Development + out.Photon = v.Photon + out.Edition = v.Edition + out.Channel = v.Channel + out.Catalog = v.Catalog + conv102, err := convertSlice(v.Notifications, NotificationsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Notifications", err) + } + out.Notifications = conv102 + out.Serverless = v.Serverless + conv103, err := PipelineDeploymentFromSDK(v.Deployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Deployment", err) + } + out.Deployment = conv103 + conv104, err := RestartWindowFromSDK(v.RestartWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.RestartWindow", err) + } + out.RestartWindow = conv104 + out.BudgetPolicyId = v.BudgetPolicyId + out.Tags = v.Tags + conv105, err := EventLogSpecFromSDK(v.EventLog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.EventLog", err) + } + out.EventLog = conv105 + out.RootPath = v.RootPath + conv106, err := PipelinesEnvironmentFromSDK(v.Environment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditPipelineRequest.Environment", err) + } + out.Environment = conv106 + out.ParentPath = v.ParentPath + out.UsagePolicyId = v.UsagePolicyId + out.ServerlessComputeId = v.ServerlessComputeId + return out, nil +} + +// ErrorDetailToSDK converts the mirror to the sdk-go type. +func ErrorDetailToSDK(w *ErrorDetail) (*sdk.ErrorDetail, error) { + if w == nil { + return nil, nil + } + out := &sdk.ErrorDetail{} + conv107, err := convertSlice(w.Exceptions, SerializedExceptionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ErrorDetail.Exceptions", err) + } + out.Exceptions = conv107 + out.Fatal = w.Fatal + return out, nil +} + +// ErrorDetailFromSDK converts the sdk-go type to the mirror. +func ErrorDetailFromSDK(v *sdk.ErrorDetail) (*ErrorDetail, error) { + if v == nil { + return nil, nil + } + out := &ErrorDetail{} + conv108, err := convertSlice(v.Exceptions, SerializedExceptionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ErrorDetail.Exceptions", err) + } + out.Exceptions = conv108 + out.Fatal = v.Fatal + return out, nil +} + +// EventLogSpecToSDK converts the mirror to the sdk-go type. +func EventLogSpecToSDK(w *EventLogSpec) (*sdk.EventLogSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.EventLogSpec{} + out.Name = w.Name + out.Schema = w.Schema + out.Catalog = w.Catalog + return out, nil +} + +// EventLogSpecFromSDK converts the sdk-go type to the mirror. +func EventLogSpecFromSDK(v *sdk.EventLogSpec) (*EventLogSpec, error) { + if v == nil { + return nil, nil + } + out := &EventLogSpec{} + out.Name = v.Name + out.Schema = v.Schema + out.Catalog = v.Catalog + return out, nil +} + +// FileFilterToSDK converts the mirror to the sdk-go type. +func FileFilterToSDK(w *FileFilter) (*sdk.FileFilter, error) { + if w == nil { + return nil, nil + } + out := &sdk.FileFilter{} + { + var members []string + if w.PathFilter != nil { + members = append(members, "path_filter") + } + if w.ModifiedBefore != nil { + members = append(members, "modified_before") + } + if w.ModifiedAfter != nil { + members = append(members, "modified_after") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.PathFilter != nil: + out.Filter = &sdk.FileFilter_Filter_PathFilter{PathFilter: *w.PathFilter} + case w.ModifiedBefore != nil: + out.Filter = &sdk.FileFilter_Filter_ModifiedBefore{ModifiedBefore: *w.ModifiedBefore} + case w.ModifiedAfter != nil: + out.Filter = &sdk.FileFilter_Filter_ModifiedAfter{ModifiedAfter: *w.ModifiedAfter} + } + return out, nil +} + +// FileFilterFromSDK converts the sdk-go type to the mirror. +func FileFilterFromSDK(v *sdk.FileFilter) (*FileFilter, error) { + if v == nil { + return nil, nil + } + out := &FileFilter{} + switch value := v.Filter.(type) { + case *sdk.FileFilter_Filter_PathFilter: + if value != nil { + out.PathFilter = new(value.PathFilter) + } + case *sdk.FileFilter_Filter_ModifiedBefore: + if value != nil { + out.ModifiedBefore = new(value.ModifiedBefore) + } + case *sdk.FileFilter_Filter_ModifiedAfter: + if value != nil { + out.ModifiedAfter = new(value.ModifiedAfter) + } + } + return out, nil +} + +// FileIngestionOptionsToSDK converts the mirror to the sdk-go type. +func FileIngestionOptionsToSDK(w *FileIngestionOptions) (*sdk.FileIngestionOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.FileIngestionOptions{} + out.Format = w.Format + conv109, err := convertSlice(w.FileFilters, FileFilterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileIngestionOptions.FileFilters", err) + } + out.FileFilters = conv109 + out.InferColumnTypes = w.InferColumnTypes + out.SchemaEvolutionMode = w.SchemaEvolutionMode + out.SchemaHints = w.SchemaHints + out.IgnoreCorruptFiles = w.IgnoreCorruptFiles + out.CorruptRecordColumn = w.CorruptRecordColumn + out.RescuedDataColumn = w.RescuedDataColumn + out.SingleVariantColumn = w.SingleVariantColumn + out.ReaderCaseSensitive = w.ReaderCaseSensitive + out.FormatOptions = w.FormatOptions + return out, nil +} + +// FileIngestionOptionsFromSDK converts the sdk-go type to the mirror. +func FileIngestionOptionsFromSDK(v *sdk.FileIngestionOptions) (*FileIngestionOptions, error) { + if v == nil { + return nil, nil + } + out := &FileIngestionOptions{} + out.Format = v.Format + conv110, err := convertSlice(v.FileFilters, FileFilterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileIngestionOptions.FileFilters", err) + } + out.FileFilters = conv110 + out.InferColumnTypes = v.InferColumnTypes + out.SchemaEvolutionMode = v.SchemaEvolutionMode + out.SchemaHints = v.SchemaHints + out.IgnoreCorruptFiles = v.IgnoreCorruptFiles + out.CorruptRecordColumn = v.CorruptRecordColumn + out.RescuedDataColumn = v.RescuedDataColumn + out.SingleVariantColumn = v.SingleVariantColumn + out.ReaderCaseSensitive = v.ReaderCaseSensitive + out.FormatOptions = v.FormatOptions + return out, nil +} + +// FiltersToSDK converts the mirror to the sdk-go type. +func FiltersToSDK(w *Filters) (*sdk.Filters, error) { + if w == nil { + return nil, nil + } + out := &sdk.Filters{} + out.Include = w.Include + out.Exclude = w.Exclude + return out, nil +} + +// FiltersFromSDK converts the sdk-go type to the mirror. +func FiltersFromSDK(v *sdk.Filters) (*Filters, error) { + if v == nil { + return nil, nil + } + out := &Filters{} + out.Include = v.Include + out.Exclude = v.Exclude + return out, nil +} + +// GetPipelineResponseToSDK converts the mirror to the sdk-go type. +func GetPipelineResponseToSDK(w *GetPipelineResponse) (*sdk.GetPipelineResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPipelineResponse{} + out.PipelineId = w.PipelineId + conv111, err := PipelineSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPipelineResponse.Spec", err) + } + out.Spec = conv111 + out.State = w.State + out.Cause = w.Cause + out.ClusterId = w.ClusterId + out.Name = w.Name + out.Health = w.Health + out.CreatorUserName = w.CreatorUserName + conv112, err := convertSlice(w.LatestUpdates, UpdateStateInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPipelineResponse.LatestUpdates", err) + } + out.LatestUpdates = conv112 + out.LastModified = w.LastModified + out.RunAsUserName = w.RunAsUserName + out.EffectiveBudgetPolicyId = w.EffectiveBudgetPolicyId + out.EffectivePublishingMode = w.EffectivePublishingMode + conv113, err := PipelinesJobRunAsToSDK(w.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPipelineResponse.RunAs", err) + } + out.RunAs = conv113 + out.Parameters = w.Parameters + out.EffectiveServerlessComputeId = w.EffectiveServerlessComputeId + return out, nil +} + +// GetPipelineResponseFromSDK converts the sdk-go type to the mirror. +func GetPipelineResponseFromSDK(v *sdk.GetPipelineResponse) (*GetPipelineResponse, error) { + if v == nil { + return nil, nil + } + out := &GetPipelineResponse{} + out.PipelineId = v.PipelineId + conv114, err := PipelineSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPipelineResponse.Spec", err) + } + out.Spec = conv114 + out.State = v.State + out.Cause = v.Cause + out.ClusterId = v.ClusterId + out.Name = v.Name + out.Health = v.Health + out.CreatorUserName = v.CreatorUserName + conv115, err := convertSlice(v.LatestUpdates, UpdateStateInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPipelineResponse.LatestUpdates", err) + } + out.LatestUpdates = conv115 + out.LastModified = v.LastModified + out.RunAsUserName = v.RunAsUserName + out.EffectiveBudgetPolicyId = v.EffectiveBudgetPolicyId + out.EffectivePublishingMode = v.EffectivePublishingMode + conv116, err := PipelinesJobRunAsFromSDK(v.RunAs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPipelineResponse.RunAs", err) + } + out.RunAs = conv116 + out.Parameters = v.Parameters + out.EffectiveServerlessComputeId = v.EffectiveServerlessComputeId + return out, nil +} + +// GetUpdateResponseToSDK converts the mirror to the sdk-go type. +func GetUpdateResponseToSDK(w *GetUpdateResponse) (*sdk.GetUpdateResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetUpdateResponse{} + conv117, err := UpdateInfoToSDK(w.Update) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetUpdateResponse.Update", err) + } + out.Update = conv117 + return out, nil +} + +// GetUpdateResponseFromSDK converts the sdk-go type to the mirror. +func GetUpdateResponseFromSDK(v *sdk.GetUpdateResponse) (*GetUpdateResponse, error) { + if v == nil { + return nil, nil + } + out := &GetUpdateResponse{} + conv118, err := UpdateInfoFromSDK(v.Update) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetUpdateResponse.Update", err) + } + out.Update = conv118 + return out, nil +} + +// GoogleAdsConfigToSDK converts the mirror to the sdk-go type. +func GoogleAdsConfigToSDK(w *GoogleAdsConfig) (*sdk.GoogleAdsConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.GoogleAdsConfig{} + out.ManagerAccountId = w.ManagerAccountId + return out, nil +} + +// GoogleAdsConfigFromSDK converts the sdk-go type to the mirror. +func GoogleAdsConfigFromSDK(v *sdk.GoogleAdsConfig) (*GoogleAdsConfig, error) { + if v == nil { + return nil, nil + } + out := &GoogleAdsConfig{} + out.ManagerAccountId = v.ManagerAccountId + return out, nil +} + +// GoogleAdsCustomReportOptionsToSDK converts the mirror to the sdk-go type. +func GoogleAdsCustomReportOptionsToSDK(w *GoogleAdsCustomReportOptions) (*sdk.GoogleAdsCustomReportOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.GoogleAdsCustomReportOptions{} + out.Resource = w.Resource + out.ResourceFields = w.ResourceFields + out.Segments = w.Segments + out.Metrics = w.Metrics + return out, nil +} + +// GoogleAdsCustomReportOptionsFromSDK converts the sdk-go type to the mirror. +func GoogleAdsCustomReportOptionsFromSDK(v *sdk.GoogleAdsCustomReportOptions) (*GoogleAdsCustomReportOptions, error) { + if v == nil { + return nil, nil + } + out := &GoogleAdsCustomReportOptions{} + out.Resource = v.Resource + out.ResourceFields = v.ResourceFields + out.Segments = v.Segments + out.Metrics = v.Metrics + return out, nil +} + +// GoogleAdsOptionsToSDK converts the mirror to the sdk-go type. +func GoogleAdsOptionsToSDK(w *GoogleAdsOptions) (*sdk.GoogleAdsOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.GoogleAdsOptions{} + out.ManagerAccountId = w.ManagerAccountId + out.LookbackWindowDays = w.LookbackWindowDays + out.SyncStartDate = w.SyncStartDate + conv119, err := GoogleAdsCustomReportOptionsToSDK(w.CustomReportOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GoogleAdsOptions.CustomReportOptions", err) + } + out.CustomReportOptions = conv119 + return out, nil +} + +// GoogleAdsOptionsFromSDK converts the sdk-go type to the mirror. +func GoogleAdsOptionsFromSDK(v *sdk.GoogleAdsOptions) (*GoogleAdsOptions, error) { + if v == nil { + return nil, nil + } + out := &GoogleAdsOptions{} + out.ManagerAccountId = v.ManagerAccountId + out.LookbackWindowDays = v.LookbackWindowDays + out.SyncStartDate = v.SyncStartDate + conv120, err := GoogleAdsCustomReportOptionsFromSDK(v.CustomReportOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GoogleAdsOptions.CustomReportOptions", err) + } + out.CustomReportOptions = conv120 + return out, nil +} + +// GoogleDriveOptionsToSDK converts the mirror to the sdk-go type. +func GoogleDriveOptionsToSDK(w *GoogleDriveOptions) (*sdk.GoogleDriveOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.GoogleDriveOptions{} + out.Url = w.Url + out.EntityType = w.EntityType + conv121, err := FileIngestionOptionsToSDK(w.FileIngestionOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GoogleDriveOptions.FileIngestionOptions", err) + } + out.FileIngestionOptions = conv121 + return out, nil +} + +// GoogleDriveOptionsFromSDK converts the sdk-go type to the mirror. +func GoogleDriveOptionsFromSDK(v *sdk.GoogleDriveOptions) (*GoogleDriveOptions, error) { + if v == nil { + return nil, nil + } + out := &GoogleDriveOptions{} + out.Url = v.Url + out.EntityType = v.EntityType + conv122, err := FileIngestionOptionsFromSDK(v.FileIngestionOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GoogleDriveOptions.FileIngestionOptions", err) + } + out.FileIngestionOptions = conv122 + return out, nil +} + +// IngestionGatewayPipelineDefinitionToSDK converts the mirror to the sdk-go type. +func IngestionGatewayPipelineDefinitionToSDK(w *IngestionGatewayPipelineDefinition) (*sdk.IngestionGatewayPipelineDefinition, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionGatewayPipelineDefinition{} + out.ConnectionName = w.ConnectionName + out.ConnectionId = w.ConnectionId + out.GatewayStorageCatalog = w.GatewayStorageCatalog + out.GatewayStorageSchema = w.GatewayStorageSchema + out.GatewayStorageName = w.GatewayStorageName + conv123, err := ConnectionParametersToSDK(w.ConnectionParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionGatewayPipelineDefinition.ConnectionParameters", err) + } + out.ConnectionParameters = conv123 + return out, nil +} + +// IngestionGatewayPipelineDefinitionFromSDK converts the sdk-go type to the mirror. +func IngestionGatewayPipelineDefinitionFromSDK(v *sdk.IngestionGatewayPipelineDefinition) (*IngestionGatewayPipelineDefinition, error) { + if v == nil { + return nil, nil + } + out := &IngestionGatewayPipelineDefinition{} + out.ConnectionName = v.ConnectionName + out.ConnectionId = v.ConnectionId + out.GatewayStorageCatalog = v.GatewayStorageCatalog + out.GatewayStorageSchema = v.GatewayStorageSchema + out.GatewayStorageName = v.GatewayStorageName + conv124, err := ConnectionParametersFromSDK(v.ConnectionParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionGatewayPipelineDefinition.ConnectionParameters", err) + } + out.ConnectionParameters = conv124 + return out, nil +} + +// IngestionPipelineDefinitionToSDK converts the mirror to the sdk-go type. +func IngestionPipelineDefinitionToSDK(w *IngestionPipelineDefinition) (*sdk.IngestionPipelineDefinition, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionPipelineDefinition{} + { + var members []string + if w.ConnectionName != nil { + members = append(members, "connection_name") + } + if w.IngestionGatewayId != nil { + members = append(members, "ingestion_gateway_id") + } + if w.IngestFromUcForeignCatalog != nil { + members = append(members, "ingest_from_uc_foreign_catalog") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ConnectionName != nil: + out.Source = &sdk.IngestionPipelineDefinition_Source_ConnectionName{ConnectionName: *w.ConnectionName} + case w.IngestionGatewayId != nil: + out.Source = &sdk.IngestionPipelineDefinition_Source_IngestionGatewayId{IngestionGatewayId: *w.IngestionGatewayId} + case w.IngestFromUcForeignCatalog != nil: + out.Source = &sdk.IngestionPipelineDefinition_Source_IngestFromUcForeignCatalog{IngestFromUcForeignCatalog: *w.IngestFromUcForeignCatalog} + } + conv125, err := convertSlice(w.Objects, IngestionPipelineDefinition_IngestionConfigToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition.Objects", err) + } + out.Objects = conv125 + out.SourceType = w.SourceType + conv126, err := IngestionPipelineDefinition_TableSpecificConfigToSDK(w.TableConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition.TableConfiguration", err) + } + out.TableConfiguration = conv126 + out.NetsuiteJarPath = w.NetsuiteJarPath + conv127, err := convertSlice(w.SourceConfigurations, SourceConfigToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition.SourceConfigurations", err) + } + out.SourceConfigurations = conv127 + conv128, err := OperationTimeWindowToSDK(w.FullRefreshWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition.FullRefreshWindow", err) + } + out.FullRefreshWindow = conv128 + out.ConnectorType = w.ConnectorType + conv129, err := DataStagingOptionsToSDK(w.DataStagingOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition.DataStagingOptions", err) + } + out.DataStagingOptions = conv129 + return out, nil +} + +// IngestionPipelineDefinitionFromSDK converts the sdk-go type to the mirror. +func IngestionPipelineDefinitionFromSDK(v *sdk.IngestionPipelineDefinition) (*IngestionPipelineDefinition, error) { + if v == nil { + return nil, nil + } + out := &IngestionPipelineDefinition{} + switch value := v.Source.(type) { + case *sdk.IngestionPipelineDefinition_Source_ConnectionName: + if value != nil { + out.ConnectionName = new(value.ConnectionName) + } + case *sdk.IngestionPipelineDefinition_Source_IngestionGatewayId: + if value != nil { + out.IngestionGatewayId = new(value.IngestionGatewayId) + } + case *sdk.IngestionPipelineDefinition_Source_IngestFromUcForeignCatalog: + if value != nil { + out.IngestFromUcForeignCatalog = new(value.IngestFromUcForeignCatalog) + } + } + conv130, err := convertSlice(v.Objects, IngestionPipelineDefinition_IngestionConfigFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition.Objects", err) + } + out.Objects = conv130 + out.SourceType = v.SourceType + conv131, err := IngestionPipelineDefinition_TableSpecificConfigFromSDK(v.TableConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition.TableConfiguration", err) + } + out.TableConfiguration = conv131 + out.NetsuiteJarPath = v.NetsuiteJarPath + conv132, err := convertSlice(v.SourceConfigurations, SourceConfigFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition.SourceConfigurations", err) + } + out.SourceConfigurations = conv132 + conv133, err := OperationTimeWindowFromSDK(v.FullRefreshWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition.FullRefreshWindow", err) + } + out.FullRefreshWindow = conv133 + out.ConnectorType = v.ConnectorType + conv134, err := DataStagingOptionsFromSDK(v.DataStagingOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition.DataStagingOptions", err) + } + out.DataStagingOptions = conv134 + return out, nil +} + +// IngestionPipelineDefinition_FanoutOptionsToSDK converts the mirror to the sdk-go type. +func IngestionPipelineDefinition_FanoutOptionsToSDK(w *IngestionPipelineDefinition_FanoutOptions) (*sdk.IngestionPipelineDefinition_FanoutOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionPipelineDefinition_FanoutOptions{} + out.FanoutBy = w.FanoutBy + conv135, err := convertSlice(w.Transforms, TransformerToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_FanoutOptions.Transforms", err) + } + out.Transforms = conv135 + return out, nil +} + +// IngestionPipelineDefinition_FanoutOptionsFromSDK converts the sdk-go type to the mirror. +func IngestionPipelineDefinition_FanoutOptionsFromSDK(v *sdk.IngestionPipelineDefinition_FanoutOptions) (*IngestionPipelineDefinition_FanoutOptions, error) { + if v == nil { + return nil, nil + } + out := &IngestionPipelineDefinition_FanoutOptions{} + out.FanoutBy = v.FanoutBy + conv136, err := convertSlice(v.Transforms, TransformerFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_FanoutOptions.Transforms", err) + } + out.Transforms = conv136 + return out, nil +} + +// IngestionPipelineDefinition_IngestionConfigToSDK converts the mirror to the sdk-go type. +func IngestionPipelineDefinition_IngestionConfigToSDK(w *IngestionPipelineDefinition_IngestionConfig) (*sdk.IngestionPipelineDefinition_IngestionConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionPipelineDefinition_IngestionConfig{} + { + var members []string + if w.Schema != nil { + members = append(members, "schema") + } + if w.Table != nil { + members = append(members, "table") + } + if w.Report != nil { + members = append(members, "report") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Schema != nil: + conv137, err := IngestionPipelineDefinition_SchemaSpecToSDK(w.Schema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_IngestionConfig.SourceTables", err) + } + out.SourceTables = &sdk.IngestionPipelineDefinition_IngestionConfig_SourceTables_Schema{Schema: *conv137} + case w.Table != nil: + conv138, err := IngestionPipelineDefinition_TableSpecToSDK(w.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_IngestionConfig.SourceTables", err) + } + out.SourceTables = &sdk.IngestionPipelineDefinition_IngestionConfig_SourceTables_Table{Table: *conv138} + case w.Report != nil: + conv139, err := IngestionPipelineDefinition_ReportSpecToSDK(w.Report) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_IngestionConfig.SourceTables", err) + } + out.SourceTables = &sdk.IngestionPipelineDefinition_IngestionConfig_SourceTables_Report{Report: *conv139} + } + return out, nil +} + +// IngestionPipelineDefinition_IngestionConfigFromSDK converts the sdk-go type to the mirror. +func IngestionPipelineDefinition_IngestionConfigFromSDK(v *sdk.IngestionPipelineDefinition_IngestionConfig) (*IngestionPipelineDefinition_IngestionConfig, error) { + if v == nil { + return nil, nil + } + out := &IngestionPipelineDefinition_IngestionConfig{} + switch value := v.SourceTables.(type) { + case *sdk.IngestionPipelineDefinition_IngestionConfig_SourceTables_Schema: + if value != nil { + conv140, err := IngestionPipelineDefinition_SchemaSpecFromSDK(&value.Schema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_IngestionConfig.SourceTables", err) + } + out.Schema = conv140 + } + case *sdk.IngestionPipelineDefinition_IngestionConfig_SourceTables_Table: + if value != nil { + conv141, err := IngestionPipelineDefinition_TableSpecFromSDK(&value.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_IngestionConfig.SourceTables", err) + } + out.Table = conv141 + } + case *sdk.IngestionPipelineDefinition_IngestionConfig_SourceTables_Report: + if value != nil { + conv142, err := IngestionPipelineDefinition_ReportSpecFromSDK(&value.Report) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_IngestionConfig.SourceTables", err) + } + out.Report = conv142 + } + } + return out, nil +} + +// IngestionPipelineDefinition_ReportSpecToSDK converts the mirror to the sdk-go type. +func IngestionPipelineDefinition_ReportSpecToSDK(w *IngestionPipelineDefinition_ReportSpec) (*sdk.IngestionPipelineDefinition_ReportSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionPipelineDefinition_ReportSpec{} + out.SourceUrl = w.SourceUrl + out.DestinationCatalog = w.DestinationCatalog + out.DestinationSchema = w.DestinationSchema + out.DestinationTable = w.DestinationTable + conv143, err := IngestionPipelineDefinition_TableSpecificConfigToSDK(w.TableConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_ReportSpec.TableConfiguration", err) + } + out.TableConfiguration = conv143 + return out, nil +} + +// IngestionPipelineDefinition_ReportSpecFromSDK converts the sdk-go type to the mirror. +func IngestionPipelineDefinition_ReportSpecFromSDK(v *sdk.IngestionPipelineDefinition_ReportSpec) (*IngestionPipelineDefinition_ReportSpec, error) { + if v == nil { + return nil, nil + } + out := &IngestionPipelineDefinition_ReportSpec{} + out.SourceUrl = v.SourceUrl + out.DestinationCatalog = v.DestinationCatalog + out.DestinationSchema = v.DestinationSchema + out.DestinationTable = v.DestinationTable + conv144, err := IngestionPipelineDefinition_TableSpecificConfigFromSDK(v.TableConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_ReportSpec.TableConfiguration", err) + } + out.TableConfiguration = conv144 + return out, nil +} + +// IngestionPipelineDefinition_SchemaSpecToSDK converts the mirror to the sdk-go type. +func IngestionPipelineDefinition_SchemaSpecToSDK(w *IngestionPipelineDefinition_SchemaSpec) (*sdk.IngestionPipelineDefinition_SchemaSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionPipelineDefinition_SchemaSpec{} + out.SourceCatalog = w.SourceCatalog + out.SourceSchema = w.SourceSchema + out.DestinationCatalog = w.DestinationCatalog + out.DestinationSchema = w.DestinationSchema + conv145, err := IngestionPipelineDefinition_TableSpecificConfigToSDK(w.TableConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_SchemaSpec.TableConfiguration", err) + } + out.TableConfiguration = conv145 + conv146, err := ConnectorOptionsToSDK(w.ConnectorOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_SchemaSpec.ConnectorOptions", err) + } + out.ConnectorOptions = conv146 + conv147, err := IngestionPipelineDefinition_FanoutOptionsToSDK(w.FanoutOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_SchemaSpec.FanoutOptions", err) + } + out.FanoutOptions = conv147 + return out, nil +} + +// IngestionPipelineDefinition_SchemaSpecFromSDK converts the sdk-go type to the mirror. +func IngestionPipelineDefinition_SchemaSpecFromSDK(v *sdk.IngestionPipelineDefinition_SchemaSpec) (*IngestionPipelineDefinition_SchemaSpec, error) { + if v == nil { + return nil, nil + } + out := &IngestionPipelineDefinition_SchemaSpec{} + out.SourceCatalog = v.SourceCatalog + out.SourceSchema = v.SourceSchema + out.DestinationCatalog = v.DestinationCatalog + out.DestinationSchema = v.DestinationSchema + conv148, err := IngestionPipelineDefinition_TableSpecificConfigFromSDK(v.TableConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_SchemaSpec.TableConfiguration", err) + } + out.TableConfiguration = conv148 + conv149, err := ConnectorOptionsFromSDK(v.ConnectorOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_SchemaSpec.ConnectorOptions", err) + } + out.ConnectorOptions = conv149 + conv150, err := IngestionPipelineDefinition_FanoutOptionsFromSDK(v.FanoutOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_SchemaSpec.FanoutOptions", err) + } + out.FanoutOptions = conv150 + return out, nil +} + +// IngestionPipelineDefinition_TableSpecToSDK converts the mirror to the sdk-go type. +func IngestionPipelineDefinition_TableSpecToSDK(w *IngestionPipelineDefinition_TableSpec) (*sdk.IngestionPipelineDefinition_TableSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionPipelineDefinition_TableSpec{} + out.SourceCatalog = w.SourceCatalog + out.SourceSchema = w.SourceSchema + out.SourceTable = w.SourceTable + out.DestinationCatalog = w.DestinationCatalog + out.DestinationSchema = w.DestinationSchema + out.DestinationTable = w.DestinationTable + conv151, err := IngestionPipelineDefinition_TableSpecificConfigToSDK(w.TableConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_TableSpec.TableConfiguration", err) + } + out.TableConfiguration = conv151 + conv152, err := ConnectorOptionsToSDK(w.ConnectorOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_TableSpec.ConnectorOptions", err) + } + out.ConnectorOptions = conv152 + return out, nil +} + +// IngestionPipelineDefinition_TableSpecFromSDK converts the sdk-go type to the mirror. +func IngestionPipelineDefinition_TableSpecFromSDK(v *sdk.IngestionPipelineDefinition_TableSpec) (*IngestionPipelineDefinition_TableSpec, error) { + if v == nil { + return nil, nil + } + out := &IngestionPipelineDefinition_TableSpec{} + out.SourceCatalog = v.SourceCatalog + out.SourceSchema = v.SourceSchema + out.SourceTable = v.SourceTable + out.DestinationCatalog = v.DestinationCatalog + out.DestinationSchema = v.DestinationSchema + out.DestinationTable = v.DestinationTable + conv153, err := IngestionPipelineDefinition_TableSpecificConfigFromSDK(v.TableConfiguration) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_TableSpec.TableConfiguration", err) + } + out.TableConfiguration = conv153 + conv154, err := ConnectorOptionsFromSDK(v.ConnectorOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_TableSpec.ConnectorOptions", err) + } + out.ConnectorOptions = conv154 + return out, nil +} + +// IngestionPipelineDefinition_TableSpecificConfigToSDK converts the mirror to the sdk-go type. +func IngestionPipelineDefinition_TableSpecificConfigToSDK(w *IngestionPipelineDefinition_TableSpecificConfig) (*sdk.IngestionPipelineDefinition_TableSpecificConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionPipelineDefinition_TableSpecificConfig{} + out.ScdType = w.ScdType + out.PrimaryKeys = w.PrimaryKeys + out.SequenceBy = w.SequenceBy + out.IncludeColumns = w.IncludeColumns + out.ExcludeColumns = w.ExcludeColumns + out.SalesforceIncludeFormulaFields = w.SalesforceIncludeFormulaFields + conv155, err := IngestionPipelineDefinition_WorkdayReportParametersToSDK(w.WorkdayReportParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_TableSpecificConfig.WorkdayReportParameters", err) + } + out.WorkdayReportParameters = conv155 + out.RowFilter = w.RowFilter + conv156, err := IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfigToSDK(w.QueryBasedConnectorConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_TableSpecificConfig.QueryBasedConnectorConfig", err) + } + out.QueryBasedConnectorConfig = conv156 + conv157, err := AutoFullRefreshPolicyToSDK(w.AutoFullRefreshPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_TableSpecificConfig.AutoFullRefreshPolicy", err) + } + out.AutoFullRefreshPolicy = conv157 + out.TableProperties = w.TableProperties + out.EnableAutoClustering = w.EnableAutoClustering + out.ClusteringColumns = w.ClusteringColumns + out.SourceMetadataColumn = w.SourceMetadataColumn + return out, nil +} + +// IngestionPipelineDefinition_TableSpecificConfigFromSDK converts the sdk-go type to the mirror. +func IngestionPipelineDefinition_TableSpecificConfigFromSDK(v *sdk.IngestionPipelineDefinition_TableSpecificConfig) (*IngestionPipelineDefinition_TableSpecificConfig, error) { + if v == nil { + return nil, nil + } + out := &IngestionPipelineDefinition_TableSpecificConfig{} + out.ScdType = v.ScdType + out.PrimaryKeys = v.PrimaryKeys + out.SequenceBy = v.SequenceBy + out.IncludeColumns = v.IncludeColumns + out.ExcludeColumns = v.ExcludeColumns + out.SalesforceIncludeFormulaFields = v.SalesforceIncludeFormulaFields + conv158, err := IngestionPipelineDefinition_WorkdayReportParametersFromSDK(v.WorkdayReportParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_TableSpecificConfig.WorkdayReportParameters", err) + } + out.WorkdayReportParameters = conv158 + out.RowFilter = v.RowFilter + conv159, err := IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfigFromSDK(v.QueryBasedConnectorConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_TableSpecificConfig.QueryBasedConnectorConfig", err) + } + out.QueryBasedConnectorConfig = conv159 + conv160, err := AutoFullRefreshPolicyFromSDK(v.AutoFullRefreshPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_TableSpecificConfig.AutoFullRefreshPolicy", err) + } + out.AutoFullRefreshPolicy = conv160 + out.TableProperties = v.TableProperties + out.EnableAutoClustering = v.EnableAutoClustering + out.ClusteringColumns = v.ClusteringColumns + out.SourceMetadataColumn = v.SourceMetadataColumn + return out, nil +} + +// IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfigToSDK converts the mirror to the sdk-go type. +func IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfigToSDK(w *IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig) (*sdk.IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig{} + out.CursorColumns = w.CursorColumns + out.DeletionCondition = w.DeletionCondition + out.HardDeletionSyncMinIntervalInSeconds = w.HardDeletionSyncMinIntervalInSeconds + return out, nil +} + +// IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfigFromSDK converts the sdk-go type to the mirror. +func IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfigFromSDK(v *sdk.IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig) (*IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig, error) { + if v == nil { + return nil, nil + } + out := &IngestionPipelineDefinition_TableSpecificConfig_QueryBasedConnectorConfig{} + out.CursorColumns = v.CursorColumns + out.DeletionCondition = v.DeletionCondition + out.HardDeletionSyncMinIntervalInSeconds = v.HardDeletionSyncMinIntervalInSeconds + return out, nil +} + +// IngestionPipelineDefinition_WorkdayReportParametersToSDK converts the mirror to the sdk-go type. +func IngestionPipelineDefinition_WorkdayReportParametersToSDK(w *IngestionPipelineDefinition_WorkdayReportParameters) (*sdk.IngestionPipelineDefinition_WorkdayReportParameters, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionPipelineDefinition_WorkdayReportParameters{} + out.Incremental = w.Incremental + conv161, err := convertSlice(w.ReportParameters, IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_WorkdayReportParameters.ReportParameters", err) + } + out.ReportParameters = conv161 + out.Parameters = w.Parameters + return out, nil +} + +// IngestionPipelineDefinition_WorkdayReportParametersFromSDK converts the sdk-go type to the mirror. +func IngestionPipelineDefinition_WorkdayReportParametersFromSDK(v *sdk.IngestionPipelineDefinition_WorkdayReportParameters) (*IngestionPipelineDefinition_WorkdayReportParameters, error) { + if v == nil { + return nil, nil + } + out := &IngestionPipelineDefinition_WorkdayReportParameters{} + out.Incremental = v.Incremental + conv162, err := convertSlice(v.ReportParameters, IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "IngestionPipelineDefinition_WorkdayReportParameters.ReportParameters", err) + } + out.ReportParameters = conv162 + out.Parameters = v.Parameters + return out, nil +} + +// IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValueToSDK converts the mirror to the sdk-go type. +func IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValueToSDK(w *IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue) (*sdk.IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValueFromSDK converts the sdk-go type to the mirror. +func IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValueFromSDK(v *sdk.IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue) (*IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue, error) { + if v == nil { + return nil, nil + } + out := &IngestionPipelineDefinition_WorkdayReportParameters_QueryKeyValue{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// JiraConnectorOptionsToSDK converts the mirror to the sdk-go type. +func JiraConnectorOptionsToSDK(w *JiraConnectorOptions) (*sdk.JiraConnectorOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.JiraConnectorOptions{} + out.IncludeJiraSpaces = w.IncludeJiraSpaces + return out, nil +} + +// JiraConnectorOptionsFromSDK converts the sdk-go type to the mirror. +func JiraConnectorOptionsFromSDK(v *sdk.JiraConnectorOptions) (*JiraConnectorOptions, error) { + if v == nil { + return nil, nil + } + out := &JiraConnectorOptions{} + out.IncludeJiraSpaces = v.IncludeJiraSpaces + return out, nil +} + +// JsonTransformerOptionsToSDK converts the mirror to the sdk-go type. +func JsonTransformerOptionsToSDK(w *JsonTransformerOptions) (*sdk.JsonTransformerOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.JsonTransformerOptions{} + out.AsVariant = w.AsVariant + out.Schema = w.Schema + out.SchemaFilePath = w.SchemaFilePath + out.SchemaEvolutionMode = w.SchemaEvolutionMode + out.SchemaHints = w.SchemaHints + return out, nil +} + +// JsonTransformerOptionsFromSDK converts the sdk-go type to the mirror. +func JsonTransformerOptionsFromSDK(v *sdk.JsonTransformerOptions) (*JsonTransformerOptions, error) { + if v == nil { + return nil, nil + } + out := &JsonTransformerOptions{} + out.AsVariant = v.AsVariant + out.Schema = v.Schema + out.SchemaFilePath = v.SchemaFilePath + out.SchemaEvolutionMode = v.SchemaEvolutionMode + out.SchemaHints = v.SchemaHints + return out, nil +} + +// KafkaOptionsToSDK converts the mirror to the sdk-go type. +func KafkaOptionsToSDK(w *KafkaOptions) (*sdk.KafkaOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.KafkaOptions{} + out.Topics = w.Topics + out.TopicPattern = w.TopicPattern + conv163, err := TransformerToSDK(w.KeyTransformer) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaOptions.KeyTransformer", err) + } + out.KeyTransformer = conv163 + conv164, err := TransformerToSDK(w.ValueTransformer) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaOptions.ValueTransformer", err) + } + out.ValueTransformer = conv164 + out.StartingOffset = w.StartingOffset + out.MaxOffsetsPerTrigger = w.MaxOffsetsPerTrigger + out.ClientConfig = w.ClientConfig + return out, nil +} + +// KafkaOptionsFromSDK converts the sdk-go type to the mirror. +func KafkaOptionsFromSDK(v *sdk.KafkaOptions) (*KafkaOptions, error) { + if v == nil { + return nil, nil + } + out := &KafkaOptions{} + out.Topics = v.Topics + out.TopicPattern = v.TopicPattern + conv165, err := TransformerFromSDK(v.KeyTransformer) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaOptions.KeyTransformer", err) + } + out.KeyTransformer = conv165 + conv166, err := TransformerFromSDK(v.ValueTransformer) + if err != nil { + return nil, fmt.Errorf("%s: %w", "KafkaOptions.ValueTransformer", err) + } + out.ValueTransformer = conv166 + out.StartingOffset = v.StartingOffset + out.MaxOffsetsPerTrigger = v.MaxOffsetsPerTrigger + out.ClientConfig = v.ClientConfig + return out, nil +} + +// LinkedInAdsOptionsToSDK converts the mirror to the sdk-go type. +func LinkedInAdsOptionsToSDK(w *LinkedInAdsOptions) (*sdk.LinkedInAdsOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.LinkedInAdsOptions{} + out.SyncStartDate = w.SyncStartDate + out.LookbackWindowDays = w.LookbackWindowDays + conv167, err := LinkedInAdsOptions_LinkedInAdsCustomReportOptionsToSDK(w.CustomReportOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LinkedInAdsOptions.CustomReportOptions", err) + } + out.CustomReportOptions = conv167 + return out, nil +} + +// LinkedInAdsOptionsFromSDK converts the sdk-go type to the mirror. +func LinkedInAdsOptionsFromSDK(v *sdk.LinkedInAdsOptions) (*LinkedInAdsOptions, error) { + if v == nil { + return nil, nil + } + out := &LinkedInAdsOptions{} + out.SyncStartDate = v.SyncStartDate + out.LookbackWindowDays = v.LookbackWindowDays + conv168, err := LinkedInAdsOptions_LinkedInAdsCustomReportOptionsFromSDK(v.CustomReportOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "LinkedInAdsOptions.CustomReportOptions", err) + } + out.CustomReportOptions = conv168 + return out, nil +} + +// LinkedInAdsOptions_LinkedInAdsCustomReportOptionsToSDK converts the mirror to the sdk-go type. +func LinkedInAdsOptions_LinkedInAdsCustomReportOptionsToSDK(w *LinkedInAdsOptions_LinkedInAdsCustomReportOptions) (*sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions{} + out.Finder = w.Finder + out.EntityGranularity = w.EntityGranularity + out.TimeGranularity = w.TimeGranularity + out.Metrics = w.Metrics + return out, nil +} + +// LinkedInAdsOptions_LinkedInAdsCustomReportOptionsFromSDK converts the sdk-go type to the mirror. +func LinkedInAdsOptions_LinkedInAdsCustomReportOptionsFromSDK(v *sdk.LinkedInAdsOptions_LinkedInAdsCustomReportOptions) (*LinkedInAdsOptions_LinkedInAdsCustomReportOptions, error) { + if v == nil { + return nil, nil + } + out := &LinkedInAdsOptions_LinkedInAdsCustomReportOptions{} + out.Finder = v.Finder + out.EntityGranularity = v.EntityGranularity + out.TimeGranularity = v.TimeGranularity + out.Metrics = v.Metrics + return out, nil +} + +// ListPipelineEventsRequestToSDK converts the mirror to the sdk-go type. +func ListPipelineEventsRequestToSDK(w *ListPipelineEventsRequest) (*sdk.ListPipelineEventsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPipelineEventsRequest{} + out.PipelineId = w.PipelineId + out.PageToken = w.PageToken + out.MaxResults = w.MaxResults + out.OrderBy = w.OrderBy + out.Filter = w.Filter + return out, nil +} + +// ListPipelineEventsRequestFromSDK converts the sdk-go type to the mirror. +func ListPipelineEventsRequestFromSDK(v *sdk.ListPipelineEventsRequest) (*ListPipelineEventsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListPipelineEventsRequest{} + out.PipelineId = v.PipelineId + out.PageToken = v.PageToken + out.MaxResults = v.MaxResults + out.OrderBy = v.OrderBy + out.Filter = v.Filter + return out, nil +} + +// ListPipelineEventsResponseToSDK converts the mirror to the sdk-go type. +func ListPipelineEventsResponseToSDK(w *ListPipelineEventsResponse) (*sdk.ListPipelineEventsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPipelineEventsResponse{} + conv169, err := convertSlice(w.Events, PipelineEventToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPipelineEventsResponse.Events", err) + } + out.Events = conv169 + out.NextPageToken = w.NextPageToken + out.PrevPageToken = w.PrevPageToken + return out, nil +} + +// ListPipelineEventsResponseFromSDK converts the sdk-go type to the mirror. +func ListPipelineEventsResponseFromSDK(v *sdk.ListPipelineEventsResponse) (*ListPipelineEventsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListPipelineEventsResponse{} + conv170, err := convertSlice(v.Events, PipelineEventFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPipelineEventsResponse.Events", err) + } + out.Events = conv170 + out.NextPageToken = v.NextPageToken + out.PrevPageToken = v.PrevPageToken + return out, nil +} + +// ListPipelinesRequestToSDK converts the mirror to the sdk-go type. +func ListPipelinesRequestToSDK(w *ListPipelinesRequest) (*sdk.ListPipelinesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPipelinesRequest{} + out.PageToken = w.PageToken + out.MaxResults = w.MaxResults + out.OrderBy = w.OrderBy + out.Filter = w.Filter + return out, nil +} + +// ListPipelinesRequestFromSDK converts the sdk-go type to the mirror. +func ListPipelinesRequestFromSDK(v *sdk.ListPipelinesRequest) (*ListPipelinesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListPipelinesRequest{} + out.PageToken = v.PageToken + out.MaxResults = v.MaxResults + out.OrderBy = v.OrderBy + out.Filter = v.Filter + return out, nil +} + +// ListPipelinesResponseToSDK converts the mirror to the sdk-go type. +func ListPipelinesResponseToSDK(w *ListPipelinesResponse) (*sdk.ListPipelinesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPipelinesResponse{} + conv171, err := convertSlice(w.Statuses, PipelineStateInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPipelinesResponse.Statuses", err) + } + out.Statuses = conv171 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListPipelinesResponseFromSDK converts the sdk-go type to the mirror. +func ListPipelinesResponseFromSDK(v *sdk.ListPipelinesResponse) (*ListPipelinesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListPipelinesResponse{} + conv172, err := convertSlice(v.Statuses, PipelineStateInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPipelinesResponse.Statuses", err) + } + out.Statuses = conv172 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListUpdatesRequestToSDK converts the mirror to the sdk-go type. +func ListUpdatesRequestToSDK(w *ListUpdatesRequest) (*sdk.ListUpdatesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListUpdatesRequest{} + out.PipelineId = w.PipelineId + out.PageToken = w.PageToken + out.MaxResults = w.MaxResults + out.UntilUpdateId = w.UntilUpdateId + return out, nil +} + +// ListUpdatesRequestFromSDK converts the sdk-go type to the mirror. +func ListUpdatesRequestFromSDK(v *sdk.ListUpdatesRequest) (*ListUpdatesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListUpdatesRequest{} + out.PipelineId = v.PipelineId + out.PageToken = v.PageToken + out.MaxResults = v.MaxResults + out.UntilUpdateId = v.UntilUpdateId + return out, nil +} + +// ListUpdatesResponseToSDK converts the mirror to the sdk-go type. +func ListUpdatesResponseToSDK(w *ListUpdatesResponse) (*sdk.ListUpdatesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListUpdatesResponse{} + conv173, err := convertSlice(w.Updates, UpdateInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListUpdatesResponse.Updates", err) + } + out.Updates = conv173 + out.NextPageToken = w.NextPageToken + out.PrevPageToken = w.PrevPageToken + return out, nil +} + +// ListUpdatesResponseFromSDK converts the sdk-go type to the mirror. +func ListUpdatesResponseFromSDK(v *sdk.ListUpdatesResponse) (*ListUpdatesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListUpdatesResponse{} + conv174, err := convertSlice(v.Updates, UpdateInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListUpdatesResponse.Updates", err) + } + out.Updates = conv174 + out.NextPageToken = v.NextPageToken + out.PrevPageToken = v.PrevPageToken + return out, nil +} + +// ManualTriggerToSDK converts the mirror to the sdk-go type. +func ManualTriggerToSDK(w *ManualTrigger) (*sdk.ManualTrigger, error) { + if w == nil { + return nil, nil + } + out := &sdk.ManualTrigger{} + return out, nil +} + +// ManualTriggerFromSDK converts the sdk-go type to the mirror. +func ManualTriggerFromSDK(v *sdk.ManualTrigger) (*ManualTrigger, error) { + if v == nil { + return nil, nil + } + out := &ManualTrigger{} + return out, nil +} + +// MarketoOptionsToSDK converts the mirror to the sdk-go type. +func MarketoOptionsToSDK(w *MarketoOptions) (*sdk.MarketoOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.MarketoOptions{} + out.SyncStartDate = w.SyncStartDate + return out, nil +} + +// MarketoOptionsFromSDK converts the sdk-go type to the mirror. +func MarketoOptionsFromSDK(v *sdk.MarketoOptions) (*MarketoOptions, error) { + if v == nil { + return nil, nil + } + out := &MarketoOptions{} + out.SyncStartDate = v.SyncStartDate + return out, nil +} + +// MetaMarketingOptionsToSDK converts the mirror to the sdk-go type. +func MetaMarketingOptionsToSDK(w *MetaMarketingOptions) (*sdk.MetaMarketingOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.MetaMarketingOptions{} + out.Level = w.Level + out.Breakdowns = w.Breakdowns + out.ActionBreakdowns = w.ActionBreakdowns + out.ActionReportTime = w.ActionReportTime + out.StartDate = w.StartDate + out.CustomInsightsLookbackWindow = w.CustomInsightsLookbackWindow + out.TimeIncrement = w.TimeIncrement + out.ActionAttributionWindows = w.ActionAttributionWindows + conv175, err := MetaMarketingOptions_MetaMarketingCustomReportOptionsToSDK(w.CustomReportOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MetaMarketingOptions.CustomReportOptions", err) + } + out.CustomReportOptions = conv175 + return out, nil +} + +// MetaMarketingOptionsFromSDK converts the sdk-go type to the mirror. +func MetaMarketingOptionsFromSDK(v *sdk.MetaMarketingOptions) (*MetaMarketingOptions, error) { + if v == nil { + return nil, nil + } + out := &MetaMarketingOptions{} + out.Level = v.Level + out.Breakdowns = v.Breakdowns + out.ActionBreakdowns = v.ActionBreakdowns + out.ActionReportTime = v.ActionReportTime + out.StartDate = v.StartDate + out.CustomInsightsLookbackWindow = v.CustomInsightsLookbackWindow + out.TimeIncrement = v.TimeIncrement + out.ActionAttributionWindows = v.ActionAttributionWindows + conv176, err := MetaMarketingOptions_MetaMarketingCustomReportOptionsFromSDK(v.CustomReportOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MetaMarketingOptions.CustomReportOptions", err) + } + out.CustomReportOptions = conv176 + return out, nil +} + +// MetaMarketingOptions_MetaMarketingCustomReportOptionsToSDK converts the mirror to the sdk-go type. +func MetaMarketingOptions_MetaMarketingCustomReportOptionsToSDK(w *MetaMarketingOptions_MetaMarketingCustomReportOptions) (*sdk.MetaMarketingOptions_MetaMarketingCustomReportOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.MetaMarketingOptions_MetaMarketingCustomReportOptions{} + out.Level = w.Level + out.Breakdowns = w.Breakdowns + out.ActionBreakdowns = w.ActionBreakdowns + out.ActionReportTime = w.ActionReportTime + out.TimeIncrement = w.TimeIncrement + out.ActionAttributionWindows = w.ActionAttributionWindows + return out, nil +} + +// MetaMarketingOptions_MetaMarketingCustomReportOptionsFromSDK converts the sdk-go type to the mirror. +func MetaMarketingOptions_MetaMarketingCustomReportOptionsFromSDK(v *sdk.MetaMarketingOptions_MetaMarketingCustomReportOptions) (*MetaMarketingOptions_MetaMarketingCustomReportOptions, error) { + if v == nil { + return nil, nil + } + out := &MetaMarketingOptions_MetaMarketingCustomReportOptions{} + out.Level = v.Level + out.Breakdowns = v.Breakdowns + out.ActionBreakdowns = v.ActionBreakdowns + out.ActionReportTime = v.ActionReportTime + out.TimeIncrement = v.TimeIncrement + out.ActionAttributionWindows = v.ActionAttributionWindows + return out, nil +} + +// NotebookLibraryToSDK converts the mirror to the sdk-go type. +func NotebookLibraryToSDK(w *NotebookLibrary) (*sdk.NotebookLibrary, error) { + if w == nil { + return nil, nil + } + out := &sdk.NotebookLibrary{} + out.Path = w.Path + return out, nil +} + +// NotebookLibraryFromSDK converts the sdk-go type to the mirror. +func NotebookLibraryFromSDK(v *sdk.NotebookLibrary) (*NotebookLibrary, error) { + if v == nil { + return nil, nil + } + out := &NotebookLibrary{} + out.Path = v.Path + return out, nil +} + +// NotificationsToSDK converts the mirror to the sdk-go type. +func NotificationsToSDK(w *Notifications) (*sdk.Notifications, error) { + if w == nil { + return nil, nil + } + out := &sdk.Notifications{} + out.EmailRecipients = w.EmailRecipients + out.Alerts = w.Alerts + return out, nil +} + +// NotificationsFromSDK converts the sdk-go type to the mirror. +func NotificationsFromSDK(v *sdk.Notifications) (*Notifications, error) { + if v == nil { + return nil, nil + } + out := &Notifications{} + out.EmailRecipients = v.EmailRecipients + out.Alerts = v.Alerts + return out, nil +} + +// OperationTimeWindowToSDK converts the mirror to the sdk-go type. +func OperationTimeWindowToSDK(w *OperationTimeWindow) (*sdk.OperationTimeWindow, error) { + if w == nil { + return nil, nil + } + out := &sdk.OperationTimeWindow{} + out.StartHour = w.StartHour + out.DaysOfWeek = w.DaysOfWeek + out.TimeZoneId = w.TimeZoneId + return out, nil +} + +// OperationTimeWindowFromSDK converts the sdk-go type to the mirror. +func OperationTimeWindowFromSDK(v *sdk.OperationTimeWindow) (*OperationTimeWindow, error) { + if v == nil { + return nil, nil + } + out := &OperationTimeWindow{} + out.StartHour = v.StartHour + out.DaysOfWeek = v.DaysOfWeek + out.TimeZoneId = v.TimeZoneId + return out, nil +} + +// OriginToSDK converts the mirror to the sdk-go type. +func OriginToSDK(w *Origin) (*sdk.Origin, error) { + if w == nil { + return nil, nil + } + out := &sdk.Origin{} + out.Cloud = w.Cloud + out.Region = w.Region + out.OrgId = w.OrgId + out.PipelineId = w.PipelineId + out.PipelineName = w.PipelineName + out.ClusterId = w.ClusterId + out.UpdateId = w.UpdateId + out.MaintenanceId = w.MaintenanceId + out.TableId = w.TableId + out.DatasetName = w.DatasetName + out.FlowId = w.FlowId + out.FlowName = w.FlowName + out.BatchId = w.BatchId + out.RequestId = w.RequestId + out.UcResourceId = w.UcResourceId + out.Host = w.Host + out.MaterializationName = w.MaterializationName + out.IngestionSourceConnectionName = w.IngestionSourceConnectionName + out.IngestionSourceCatalogName = w.IngestionSourceCatalogName + out.IngestionSourceSchemaName = w.IngestionSourceSchemaName + out.IngestionSourceTableName = w.IngestionSourceTableName + out.IngestionSourceTableVersion = w.IngestionSourceTableVersion + return out, nil +} + +// OriginFromSDK converts the sdk-go type to the mirror. +func OriginFromSDK(v *sdk.Origin) (*Origin, error) { + if v == nil { + return nil, nil + } + out := &Origin{} + out.Cloud = v.Cloud + out.Region = v.Region + out.OrgId = v.OrgId + out.PipelineId = v.PipelineId + out.PipelineName = v.PipelineName + out.ClusterId = v.ClusterId + out.UpdateId = v.UpdateId + out.MaintenanceId = v.MaintenanceId + out.TableId = v.TableId + out.DatasetName = v.DatasetName + out.FlowId = v.FlowId + out.FlowName = v.FlowName + out.BatchId = v.BatchId + out.RequestId = v.RequestId + out.UcResourceId = v.UcResourceId + out.Host = v.Host + out.MaterializationName = v.MaterializationName + out.IngestionSourceConnectionName = v.IngestionSourceConnectionName + out.IngestionSourceCatalogName = v.IngestionSourceCatalogName + out.IngestionSourceSchemaName = v.IngestionSourceSchemaName + out.IngestionSourceTableName = v.IngestionSourceTableName + out.IngestionSourceTableVersion = v.IngestionSourceTableVersion + return out, nil +} + +// OutlookOptionsToSDK converts the mirror to the sdk-go type. +func OutlookOptionsToSDK(w *OutlookOptions) (*sdk.OutlookOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.OutlookOptions{} + out.FolderFilter = w.FolderFilter + out.SenderFilter = w.SenderFilter + out.SubjectFilter = w.SubjectFilter + out.StartDate = w.StartDate + out.BodyFormat = w.BodyFormat + out.AttachmentMode = w.AttachmentMode + out.IncludeMailboxes = w.IncludeMailboxes + out.IncludeFolders = w.IncludeFolders + out.IncludeSenders = w.IncludeSenders + out.IncludeSubjects = w.IncludeSubjects + return out, nil +} + +// OutlookOptionsFromSDK converts the sdk-go type to the mirror. +func OutlookOptionsFromSDK(v *sdk.OutlookOptions) (*OutlookOptions, error) { + if v == nil { + return nil, nil + } + out := &OutlookOptions{} + out.FolderFilter = v.FolderFilter + out.SenderFilter = v.SenderFilter + out.SubjectFilter = v.SubjectFilter + out.StartDate = v.StartDate + out.BodyFormat = v.BodyFormat + out.AttachmentMode = v.AttachmentMode + out.IncludeMailboxes = v.IncludeMailboxes + out.IncludeFolders = v.IncludeFolders + out.IncludeSenders = v.IncludeSenders + out.IncludeSubjects = v.IncludeSubjects + return out, nil +} + +// PathPatternToSDK converts the mirror to the sdk-go type. +func PathPatternToSDK(w *PathPattern) (*sdk.PathPattern, error) { + if w == nil { + return nil, nil + } + out := &sdk.PathPattern{} + out.Include = w.Include + return out, nil +} + +// PathPatternFromSDK converts the sdk-go type to the mirror. +func PathPatternFromSDK(v *sdk.PathPattern) (*PathPattern, error) { + if v == nil { + return nil, nil + } + out := &PathPattern{} + out.Include = v.Include + return out, nil +} + +// PipelineClusterToSDK converts the mirror to the sdk-go type. +func PipelineClusterToSDK(w *PipelineCluster) (*sdk.PipelineCluster, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelineCluster{} + out.Label = w.Label + out.ApplyPolicyDefaultValues = w.ApplyPolicyDefaultValues + out.SparkConf = w.SparkConf + conv177, err := PipelinesAwsAttributesToSDK(w.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineCluster.AwsAttributes", err) + } + out.AwsAttributes = conv177 + conv178, err := PipelinesAzureAttributesToSDK(w.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineCluster.AzureAttributes", err) + } + out.AzureAttributes = conv178 + conv179, err := PipelinesGcpAttributesToSDK(w.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineCluster.GcpAttributes", err) + } + out.GcpAttributes = conv179 + out.NodeTypeId = w.NodeTypeId + out.DriverNodeTypeId = w.DriverNodeTypeId + out.SshPublicKeys = w.SshPublicKeys + out.CustomTags = w.CustomTags + conv180, err := PipelinesClusterLogConfToSDK(w.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineCluster.ClusterLogConf", err) + } + out.ClusterLogConf = conv180 + out.SparkEnvVars = w.SparkEnvVars + conv181, err := convertSlice(w.InitScripts, PipelinesInitScriptInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineCluster.InitScripts", err) + } + out.InitScripts = conv181 + out.InstancePoolId = w.InstancePoolId + out.PolicyId = w.PolicyId + out.EnableLocalDiskEncryption = w.EnableLocalDiskEncryption + out.DriverInstancePoolId = w.DriverInstancePoolId + { + var members []string + if w.NumWorkers != nil { + members = append(members, "num_workers") + } + if w.Autoscale != nil { + members = append(members, "autoscale") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NumWorkers != nil: + out.Size = &sdk.PipelineCluster_Size_NumWorkers{NumWorkers: *w.NumWorkers} + case w.Autoscale != nil: + conv182, err := PipelinesAutoScaleToSDK(w.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineCluster.Size", err) + } + out.Size = &sdk.PipelineCluster_Size_Autoscale{Autoscale: *conv182} + } + return out, nil +} + +// PipelineClusterFromSDK converts the sdk-go type to the mirror. +func PipelineClusterFromSDK(v *sdk.PipelineCluster) (*PipelineCluster, error) { + if v == nil { + return nil, nil + } + out := &PipelineCluster{} + out.Label = v.Label + out.ApplyPolicyDefaultValues = v.ApplyPolicyDefaultValues + out.SparkConf = v.SparkConf + conv183, err := PipelinesAwsAttributesFromSDK(v.AwsAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineCluster.AwsAttributes", err) + } + out.AwsAttributes = conv183 + conv184, err := PipelinesAzureAttributesFromSDK(v.AzureAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineCluster.AzureAttributes", err) + } + out.AzureAttributes = conv184 + conv185, err := PipelinesGcpAttributesFromSDK(v.GcpAttributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineCluster.GcpAttributes", err) + } + out.GcpAttributes = conv185 + out.NodeTypeId = v.NodeTypeId + out.DriverNodeTypeId = v.DriverNodeTypeId + out.SshPublicKeys = v.SshPublicKeys + out.CustomTags = v.CustomTags + conv186, err := PipelinesClusterLogConfFromSDK(v.ClusterLogConf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineCluster.ClusterLogConf", err) + } + out.ClusterLogConf = conv186 + out.SparkEnvVars = v.SparkEnvVars + conv187, err := convertSlice(v.InitScripts, PipelinesInitScriptInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineCluster.InitScripts", err) + } + out.InitScripts = conv187 + out.InstancePoolId = v.InstancePoolId + out.PolicyId = v.PolicyId + out.EnableLocalDiskEncryption = v.EnableLocalDiskEncryption + out.DriverInstancePoolId = v.DriverInstancePoolId + switch value := v.Size.(type) { + case *sdk.PipelineCluster_Size_NumWorkers: + if value != nil { + out.NumWorkers = new(value.NumWorkers) + } + case *sdk.PipelineCluster_Size_Autoscale: + if value != nil { + conv188, err := PipelinesAutoScaleFromSDK(&value.Autoscale) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineCluster.Size", err) + } + out.Autoscale = conv188 + } + } + return out, nil +} + +// PipelineDeploymentToSDK converts the mirror to the sdk-go type. +func PipelineDeploymentToSDK(w *PipelineDeployment) (*sdk.PipelineDeployment, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelineDeployment{} + out.Kind = w.Kind + out.MetadataFilePath = w.MetadataFilePath + out.DeploymentId = w.DeploymentId + out.VersionId = w.VersionId + return out, nil +} + +// PipelineDeploymentFromSDK converts the sdk-go type to the mirror. +func PipelineDeploymentFromSDK(v *sdk.PipelineDeployment) (*PipelineDeployment, error) { + if v == nil { + return nil, nil + } + out := &PipelineDeployment{} + out.Kind = v.Kind + out.MetadataFilePath = v.MetadataFilePath + out.DeploymentId = v.DeploymentId + out.VersionId = v.VersionId + return out, nil +} + +// PipelineEventToSDK converts the mirror to the sdk-go type. +func PipelineEventToSDK(w *PipelineEvent) (*sdk.PipelineEvent, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelineEvent{} + out.Id = w.Id + conv189, err := SequencingToSDK(w.Sequence) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineEvent.Sequence", err) + } + out.Sequence = conv189 + conv190, err := OriginToSDK(w.Origin) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineEvent.Origin", err) + } + out.Origin = conv190 + out.Timestamp = w.Timestamp + out.Message = w.Message + out.Level = w.Level + conv191, err := ErrorDetailToSDK(w.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineEvent.Error", err) + } + out.Error = conv191 + out.EventType = w.EventType + out.MaturityLevel = w.MaturityLevel + conv192, err := TruncationToSDK(w.Truncation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineEvent.Truncation", err) + } + out.Truncation = conv192 + return out, nil +} + +// PipelineEventFromSDK converts the sdk-go type to the mirror. +func PipelineEventFromSDK(v *sdk.PipelineEvent) (*PipelineEvent, error) { + if v == nil { + return nil, nil + } + out := &PipelineEvent{} + out.Id = v.Id + conv193, err := SequencingFromSDK(v.Sequence) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineEvent.Sequence", err) + } + out.Sequence = conv193 + conv194, err := OriginFromSDK(v.Origin) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineEvent.Origin", err) + } + out.Origin = conv194 + out.Timestamp = v.Timestamp + out.Message = v.Message + out.Level = v.Level + conv195, err := ErrorDetailFromSDK(v.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineEvent.Error", err) + } + out.Error = conv195 + out.EventType = v.EventType + out.MaturityLevel = v.MaturityLevel + conv196, err := TruncationFromSDK(v.Truncation) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineEvent.Truncation", err) + } + out.Truncation = conv196 + return out, nil +} + +// PipelineLibraryToSDK converts the mirror to the sdk-go type. +func PipelineLibraryToSDK(w *PipelineLibrary) (*sdk.PipelineLibrary, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelineLibrary{} + { + var members []string + if w.Jar != nil { + members = append(members, "jar") + } + if w.Maven != nil { + members = append(members, "maven") + } + if w.Whl != nil { + members = append(members, "whl") + } + if w.Notebook != nil { + members = append(members, "notebook") + } + if w.File != nil { + members = append(members, "file") + } + if w.Glob != nil { + members = append(members, "glob") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Jar != nil: + out.Lib = &sdk.PipelineLibrary_Lib_Jar{Jar: *w.Jar} + case w.Maven != nil: + conv197, err := PipelinesMavenLibraryToSDK(w.Maven) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineLibrary.Lib", err) + } + out.Lib = &sdk.PipelineLibrary_Lib_Maven{Maven: *conv197} + case w.Whl != nil: + out.Lib = &sdk.PipelineLibrary_Lib_Whl{Whl: *w.Whl} + case w.Notebook != nil: + conv198, err := NotebookLibraryToSDK(w.Notebook) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineLibrary.Lib", err) + } + out.Lib = &sdk.PipelineLibrary_Lib_Notebook{Notebook: *conv198} + case w.File != nil: + conv199, err := NotebookLibraryToSDK(w.File) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineLibrary.Lib", err) + } + out.Lib = &sdk.PipelineLibrary_Lib_File{File: *conv199} + case w.Glob != nil: + conv200, err := PathPatternToSDK(w.Glob) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineLibrary.Lib", err) + } + out.Lib = &sdk.PipelineLibrary_Lib_Glob{Glob: *conv200} + } + return out, nil +} + +// PipelineLibraryFromSDK converts the sdk-go type to the mirror. +func PipelineLibraryFromSDK(v *sdk.PipelineLibrary) (*PipelineLibrary, error) { + if v == nil { + return nil, nil + } + out := &PipelineLibrary{} + switch value := v.Lib.(type) { + case *sdk.PipelineLibrary_Lib_Jar: + if value != nil { + out.Jar = new(value.Jar) + } + case *sdk.PipelineLibrary_Lib_Maven: + if value != nil { + conv201, err := PipelinesMavenLibraryFromSDK(&value.Maven) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineLibrary.Lib", err) + } + out.Maven = conv201 + } + case *sdk.PipelineLibrary_Lib_Whl: + if value != nil { + out.Whl = new(value.Whl) + } + case *sdk.PipelineLibrary_Lib_Notebook: + if value != nil { + conv202, err := NotebookLibraryFromSDK(&value.Notebook) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineLibrary.Lib", err) + } + out.Notebook = conv202 + } + case *sdk.PipelineLibrary_Lib_File: + if value != nil { + conv203, err := NotebookLibraryFromSDK(&value.File) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineLibrary.Lib", err) + } + out.File = conv203 + } + case *sdk.PipelineLibrary_Lib_Glob: + if value != nil { + conv204, err := PathPatternFromSDK(&value.Glob) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineLibrary.Lib", err) + } + out.Glob = conv204 + } + } + return out, nil +} + +// PipelineSpecToSDK converts the mirror to the sdk-go type. +func PipelineSpecToSDK(w *PipelineSpec) (*sdk.PipelineSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelineSpec{} + out.Id = w.Id + out.Name = w.Name + out.Storage = w.Storage + out.Configuration = w.Configuration + conv205, err := convertSlice(w.Clusters, PipelineClusterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Clusters", err) + } + out.Clusters = conv205 + conv206, err := convertSlice(w.Libraries, PipelineLibraryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Libraries", err) + } + out.Libraries = conv206 + conv207, err := IngestionPipelineDefinitionToSDK(w.IngestionDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.IngestionDefinition", err) + } + out.IngestionDefinition = conv207 + conv208, err := IngestionGatewayPipelineDefinitionToSDK(w.GatewayDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.GatewayDefinition", err) + } + out.GatewayDefinition = conv208 + conv209, err := PipelineTriggerToSDK(w.Trigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Trigger", err) + } + out.Trigger = conv209 + out.Target = w.Target + out.Schema = w.Schema + conv210, err := FiltersToSDK(w.Filters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Filters", err) + } + out.Filters = conv210 + out.Continuous = w.Continuous + out.Development = w.Development + out.Photon = w.Photon + out.Edition = w.Edition + out.Channel = w.Channel + out.Catalog = w.Catalog + conv211, err := convertSlice(w.Notifications, NotificationsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Notifications", err) + } + out.Notifications = conv211 + out.Serverless = w.Serverless + conv212, err := PipelineDeploymentToSDK(w.Deployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Deployment", err) + } + out.Deployment = conv212 + conv213, err := RestartWindowToSDK(w.RestartWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.RestartWindow", err) + } + out.RestartWindow = conv213 + out.BudgetPolicyId = w.BudgetPolicyId + out.Tags = w.Tags + conv214, err := EventLogSpecToSDK(w.EventLog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.EventLog", err) + } + out.EventLog = conv214 + out.RootPath = w.RootPath + conv215, err := PipelinesEnvironmentToSDK(w.Environment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Environment", err) + } + out.Environment = conv215 + out.ParentPath = w.ParentPath + out.UsagePolicyId = w.UsagePolicyId + out.ServerlessComputeId = w.ServerlessComputeId + return out, nil +} + +// PipelineSpecFromSDK converts the sdk-go type to the mirror. +func PipelineSpecFromSDK(v *sdk.PipelineSpec) (*PipelineSpec, error) { + if v == nil { + return nil, nil + } + out := &PipelineSpec{} + out.Id = v.Id + out.Name = v.Name + out.Storage = v.Storage + out.Configuration = v.Configuration + conv216, err := convertSlice(v.Clusters, PipelineClusterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Clusters", err) + } + out.Clusters = conv216 + conv217, err := convertSlice(v.Libraries, PipelineLibraryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Libraries", err) + } + out.Libraries = conv217 + conv218, err := IngestionPipelineDefinitionFromSDK(v.IngestionDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.IngestionDefinition", err) + } + out.IngestionDefinition = conv218 + conv219, err := IngestionGatewayPipelineDefinitionFromSDK(v.GatewayDefinition) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.GatewayDefinition", err) + } + out.GatewayDefinition = conv219 + conv220, err := PipelineTriggerFromSDK(v.Trigger) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Trigger", err) + } + out.Trigger = conv220 + out.Target = v.Target + out.Schema = v.Schema + conv221, err := FiltersFromSDK(v.Filters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Filters", err) + } + out.Filters = conv221 + out.Continuous = v.Continuous + out.Development = v.Development + out.Photon = v.Photon + out.Edition = v.Edition + out.Channel = v.Channel + out.Catalog = v.Catalog + conv222, err := convertSlice(v.Notifications, NotificationsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Notifications", err) + } + out.Notifications = conv222 + out.Serverless = v.Serverless + conv223, err := PipelineDeploymentFromSDK(v.Deployment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Deployment", err) + } + out.Deployment = conv223 + conv224, err := RestartWindowFromSDK(v.RestartWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.RestartWindow", err) + } + out.RestartWindow = conv224 + out.BudgetPolicyId = v.BudgetPolicyId + out.Tags = v.Tags + conv225, err := EventLogSpecFromSDK(v.EventLog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.EventLog", err) + } + out.EventLog = conv225 + out.RootPath = v.RootPath + conv226, err := PipelinesEnvironmentFromSDK(v.Environment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineSpec.Environment", err) + } + out.Environment = conv226 + out.ParentPath = v.ParentPath + out.UsagePolicyId = v.UsagePolicyId + out.ServerlessComputeId = v.ServerlessComputeId + return out, nil +} + +// PipelineStateInfoToSDK converts the mirror to the sdk-go type. +func PipelineStateInfoToSDK(w *PipelineStateInfo) (*sdk.PipelineStateInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelineStateInfo{} + out.PipelineId = w.PipelineId + out.State = w.State + out.ClusterId = w.ClusterId + out.Name = w.Name + conv227, err := convertSlice(w.LatestUpdates, UpdateStateInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineStateInfo.LatestUpdates", err) + } + out.LatestUpdates = conv227 + out.CreatorUserName = w.CreatorUserName + out.RunAsUserName = w.RunAsUserName + out.Health = w.Health + return out, nil +} + +// PipelineStateInfoFromSDK converts the sdk-go type to the mirror. +func PipelineStateInfoFromSDK(v *sdk.PipelineStateInfo) (*PipelineStateInfo, error) { + if v == nil { + return nil, nil + } + out := &PipelineStateInfo{} + out.PipelineId = v.PipelineId + out.State = v.State + out.ClusterId = v.ClusterId + out.Name = v.Name + conv228, err := convertSlice(v.LatestUpdates, UpdateStateInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineStateInfo.LatestUpdates", err) + } + out.LatestUpdates = conv228 + out.CreatorUserName = v.CreatorUserName + out.RunAsUserName = v.RunAsUserName + out.Health = v.Health + return out, nil +} + +// PipelineTriggerToSDK converts the mirror to the sdk-go type. +func PipelineTriggerToSDK(w *PipelineTrigger) (*sdk.PipelineTrigger, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelineTrigger{} + { + var members []string + if w.Manual != nil { + members = append(members, "manual") + } + if w.Cron != nil { + members = append(members, "cron") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Manual != nil: + conv229, err := ManualTriggerToSDK(w.Manual) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineTrigger.Trigger", err) + } + out.Trigger = &sdk.PipelineTrigger_Trigger_Manual{Manual: *conv229} + case w.Cron != nil: + conv230, err := CronTriggerToSDK(w.Cron) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineTrigger.Trigger", err) + } + out.Trigger = &sdk.PipelineTrigger_Trigger_Cron{Cron: *conv230} + } + return out, nil +} + +// PipelineTriggerFromSDK converts the sdk-go type to the mirror. +func PipelineTriggerFromSDK(v *sdk.PipelineTrigger) (*PipelineTrigger, error) { + if v == nil { + return nil, nil + } + out := &PipelineTrigger{} + switch value := v.Trigger.(type) { + case *sdk.PipelineTrigger_Trigger_Manual: + if value != nil { + conv231, err := ManualTriggerFromSDK(&value.Manual) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineTrigger.Trigger", err) + } + out.Manual = conv231 + } + case *sdk.PipelineTrigger_Trigger_Cron: + if value != nil { + conv232, err := CronTriggerFromSDK(&value.Cron) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelineTrigger.Trigger", err) + } + out.Cron = conv232 + } + } + return out, nil +} + +// PipelinesAutoScaleToSDK converts the mirror to the sdk-go type. +func PipelinesAutoScaleToSDK(w *PipelinesAutoScale) (*sdk.PipelinesAutoScale, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelinesAutoScale{} + out.MinWorkers = w.MinWorkers + out.MaxWorkers = w.MaxWorkers + out.Mode = w.Mode + return out, nil +} + +// PipelinesAutoScaleFromSDK converts the sdk-go type to the mirror. +func PipelinesAutoScaleFromSDK(v *sdk.PipelinesAutoScale) (*PipelinesAutoScale, error) { + if v == nil { + return nil, nil + } + out := &PipelinesAutoScale{} + out.MinWorkers = v.MinWorkers + out.MaxWorkers = v.MaxWorkers + out.Mode = v.Mode + return out, nil +} + +// PipelinesAwsAttributesToSDK converts the mirror to the sdk-go type. +func PipelinesAwsAttributesToSDK(w *PipelinesAwsAttributes) (*sdk.PipelinesAwsAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelinesAwsAttributes{} + out.FirstOnDemand = w.FirstOnDemand + out.Availability = w.Availability + out.ZoneId = w.ZoneId + out.InstanceProfileArn = w.InstanceProfileArn + out.SpotBidPricePercent = w.SpotBidPricePercent + out.EbsVolumeType = w.EbsVolumeType + out.EbsVolumeCount = w.EbsVolumeCount + out.EbsVolumeSize = w.EbsVolumeSize + out.EbsVolumeIops = w.EbsVolumeIops + out.EbsVolumeThroughput = w.EbsVolumeThroughput + return out, nil +} + +// PipelinesAwsAttributesFromSDK converts the sdk-go type to the mirror. +func PipelinesAwsAttributesFromSDK(v *sdk.PipelinesAwsAttributes) (*PipelinesAwsAttributes, error) { + if v == nil { + return nil, nil + } + out := &PipelinesAwsAttributes{} + out.FirstOnDemand = v.FirstOnDemand + out.Availability = v.Availability + out.ZoneId = v.ZoneId + out.InstanceProfileArn = v.InstanceProfileArn + out.SpotBidPricePercent = v.SpotBidPricePercent + out.EbsVolumeType = v.EbsVolumeType + out.EbsVolumeCount = v.EbsVolumeCount + out.EbsVolumeSize = v.EbsVolumeSize + out.EbsVolumeIops = v.EbsVolumeIops + out.EbsVolumeThroughput = v.EbsVolumeThroughput + return out, nil +} + +// PipelinesAzureAttributesToSDK converts the mirror to the sdk-go type. +func PipelinesAzureAttributesToSDK(w *PipelinesAzureAttributes) (*sdk.PipelinesAzureAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelinesAzureAttributes{} + out.FirstOnDemand = w.FirstOnDemand + out.Availability = w.Availability + out.SpotBidMaxPrice = w.SpotBidMaxPrice + return out, nil +} + +// PipelinesAzureAttributesFromSDK converts the sdk-go type to the mirror. +func PipelinesAzureAttributesFromSDK(v *sdk.PipelinesAzureAttributes) (*PipelinesAzureAttributes, error) { + if v == nil { + return nil, nil + } + out := &PipelinesAzureAttributes{} + out.FirstOnDemand = v.FirstOnDemand + out.Availability = v.Availability + out.SpotBidMaxPrice = v.SpotBidMaxPrice + return out, nil +} + +// PipelinesClusterLogConfToSDK converts the mirror to the sdk-go type. +func PipelinesClusterLogConfToSDK(w *PipelinesClusterLogConf) (*sdk.PipelinesClusterLogConf, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelinesClusterLogConf{} + { + var members []string + if w.Dbfs != nil { + members = append(members, "dbfs") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Dbfs != nil: + conv233, err := PipelinesDbfsStorageInfoToSDK(w.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelinesClusterLogConf.StorageInfo", err) + } + out.StorageInfo = &sdk.PipelinesClusterLogConf_StorageInfo_Dbfs{Dbfs: *conv233} + } + return out, nil +} + +// PipelinesClusterLogConfFromSDK converts the sdk-go type to the mirror. +func PipelinesClusterLogConfFromSDK(v *sdk.PipelinesClusterLogConf) (*PipelinesClusterLogConf, error) { + if v == nil { + return nil, nil + } + out := &PipelinesClusterLogConf{} + switch value := v.StorageInfo.(type) { + case *sdk.PipelinesClusterLogConf_StorageInfo_Dbfs: + if value != nil { + conv234, err := PipelinesDbfsStorageInfoFromSDK(&value.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelinesClusterLogConf.StorageInfo", err) + } + out.Dbfs = conv234 + } + } + return out, nil +} + +// PipelinesDbfsStorageInfoToSDK converts the mirror to the sdk-go type. +func PipelinesDbfsStorageInfoToSDK(w *PipelinesDbfsStorageInfo) (*sdk.PipelinesDbfsStorageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelinesDbfsStorageInfo{} + out.Destination = w.Destination + return out, nil +} + +// PipelinesDbfsStorageInfoFromSDK converts the sdk-go type to the mirror. +func PipelinesDbfsStorageInfoFromSDK(v *sdk.PipelinesDbfsStorageInfo) (*PipelinesDbfsStorageInfo, error) { + if v == nil { + return nil, nil + } + out := &PipelinesDbfsStorageInfo{} + out.Destination = v.Destination + return out, nil +} + +// PipelinesEnvironmentToSDK converts the mirror to the sdk-go type. +func PipelinesEnvironmentToSDK(w *PipelinesEnvironment) (*sdk.PipelinesEnvironment, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelinesEnvironment{} + out.Dependencies = w.Dependencies + out.EnvironmentVersion = w.EnvironmentVersion + return out, nil +} + +// PipelinesEnvironmentFromSDK converts the sdk-go type to the mirror. +func PipelinesEnvironmentFromSDK(v *sdk.PipelinesEnvironment) (*PipelinesEnvironment, error) { + if v == nil { + return nil, nil + } + out := &PipelinesEnvironment{} + out.Dependencies = v.Dependencies + out.EnvironmentVersion = v.EnvironmentVersion + return out, nil +} + +// PipelinesGcpAttributesToSDK converts the mirror to the sdk-go type. +func PipelinesGcpAttributesToSDK(w *PipelinesGcpAttributes) (*sdk.PipelinesGcpAttributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelinesGcpAttributes{} + out.GoogleServiceAccount = w.GoogleServiceAccount + out.BootDiskSize = w.BootDiskSize + out.Availability = w.Availability + out.ZoneId = w.ZoneId + out.LocalSsdCount = w.LocalSsdCount + return out, nil +} + +// PipelinesGcpAttributesFromSDK converts the sdk-go type to the mirror. +func PipelinesGcpAttributesFromSDK(v *sdk.PipelinesGcpAttributes) (*PipelinesGcpAttributes, error) { + if v == nil { + return nil, nil + } + out := &PipelinesGcpAttributes{} + out.GoogleServiceAccount = v.GoogleServiceAccount + out.BootDiskSize = v.BootDiskSize + out.Availability = v.Availability + out.ZoneId = v.ZoneId + out.LocalSsdCount = v.LocalSsdCount + return out, nil +} + +// PipelinesInitScriptInfoToSDK converts the mirror to the sdk-go type. +func PipelinesInitScriptInfoToSDK(w *PipelinesInitScriptInfo) (*sdk.PipelinesInitScriptInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelinesInitScriptInfo{} + { + var members []string + if w.Dbfs != nil { + members = append(members, "dbfs") + } + if w.S3 != nil { + members = append(members, "s3") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Dbfs != nil: + conv235, err := PipelinesDbfsStorageInfoToSDK(w.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelinesInitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.PipelinesInitScriptInfo_StorageInfo_Dbfs{Dbfs: *conv235} + case w.S3 != nil: + conv236, err := PipelinesS3StorageInfoToSDK(w.S3) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelinesInitScriptInfo.StorageInfo", err) + } + out.StorageInfo = &sdk.PipelinesInitScriptInfo_StorageInfo_S3{S3: *conv236} + } + return out, nil +} + +// PipelinesInitScriptInfoFromSDK converts the sdk-go type to the mirror. +func PipelinesInitScriptInfoFromSDK(v *sdk.PipelinesInitScriptInfo) (*PipelinesInitScriptInfo, error) { + if v == nil { + return nil, nil + } + out := &PipelinesInitScriptInfo{} + switch value := v.StorageInfo.(type) { + case *sdk.PipelinesInitScriptInfo_StorageInfo_Dbfs: + if value != nil { + conv237, err := PipelinesDbfsStorageInfoFromSDK(&value.Dbfs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelinesInitScriptInfo.StorageInfo", err) + } + out.Dbfs = conv237 + } + case *sdk.PipelinesInitScriptInfo_StorageInfo_S3: + if value != nil { + conv238, err := PipelinesS3StorageInfoFromSDK(&value.S3) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PipelinesInitScriptInfo.StorageInfo", err) + } + out.S3 = conv238 + } + } + return out, nil +} + +// PipelinesJobRunAsToSDK converts the mirror to the sdk-go type. +func PipelinesJobRunAsToSDK(w *PipelinesJobRunAs) (*sdk.PipelinesJobRunAs, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelinesJobRunAs{} + { + var members []string + if w.UserName != nil { + members = append(members, "user_name") + } + if w.ServicePrincipalName != nil { + members = append(members, "service_principal_name") + } + if w.GroupName != nil { + members = append(members, "group_name") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.UserName != nil: + out.Identity = &sdk.PipelinesJobRunAs_Identity_UserName{UserName: *w.UserName} + case w.ServicePrincipalName != nil: + out.Identity = &sdk.PipelinesJobRunAs_Identity_ServicePrincipalName{ServicePrincipalName: *w.ServicePrincipalName} + case w.GroupName != nil: + out.Identity = &sdk.PipelinesJobRunAs_Identity_GroupName{GroupName: *w.GroupName} + } + return out, nil +} + +// PipelinesJobRunAsFromSDK converts the sdk-go type to the mirror. +func PipelinesJobRunAsFromSDK(v *sdk.PipelinesJobRunAs) (*PipelinesJobRunAs, error) { + if v == nil { + return nil, nil + } + out := &PipelinesJobRunAs{} + switch value := v.Identity.(type) { + case *sdk.PipelinesJobRunAs_Identity_UserName: + if value != nil { + out.UserName = new(value.UserName) + } + case *sdk.PipelinesJobRunAs_Identity_ServicePrincipalName: + if value != nil { + out.ServicePrincipalName = new(value.ServicePrincipalName) + } + case *sdk.PipelinesJobRunAs_Identity_GroupName: + if value != nil { + out.GroupName = new(value.GroupName) + } + } + return out, nil +} + +// PipelinesMavenLibraryToSDK converts the mirror to the sdk-go type. +func PipelinesMavenLibraryToSDK(w *PipelinesMavenLibrary) (*sdk.PipelinesMavenLibrary, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelinesMavenLibrary{} + out.Coordinates = w.Coordinates + out.Repo = w.Repo + out.Exclusions = w.Exclusions + return out, nil +} + +// PipelinesMavenLibraryFromSDK converts the sdk-go type to the mirror. +func PipelinesMavenLibraryFromSDK(v *sdk.PipelinesMavenLibrary) (*PipelinesMavenLibrary, error) { + if v == nil { + return nil, nil + } + out := &PipelinesMavenLibrary{} + out.Coordinates = v.Coordinates + out.Repo = v.Repo + out.Exclusions = v.Exclusions + return out, nil +} + +// PipelinesS3StorageInfoToSDK converts the mirror to the sdk-go type. +func PipelinesS3StorageInfoToSDK(w *PipelinesS3StorageInfo) (*sdk.PipelinesS3StorageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelinesS3StorageInfo{} + out.Destination = w.Destination + out.Region = w.Region + out.Endpoint = w.Endpoint + out.EnableEncryption = w.EnableEncryption + out.EncryptionType = w.EncryptionType + out.KmsKey = w.KmsKey + out.CannedAcl = w.CannedAcl + return out, nil +} + +// PipelinesS3StorageInfoFromSDK converts the sdk-go type to the mirror. +func PipelinesS3StorageInfoFromSDK(v *sdk.PipelinesS3StorageInfo) (*PipelinesS3StorageInfo, error) { + if v == nil { + return nil, nil + } + out := &PipelinesS3StorageInfo{} + out.Destination = v.Destination + out.Region = v.Region + out.Endpoint = v.Endpoint + out.EnableEncryption = v.EnableEncryption + out.EncryptionType = v.EncryptionType + out.KmsKey = v.KmsKey + out.CannedAcl = v.CannedAcl + return out, nil +} + +// PostgresCatalogConfigToSDK converts the mirror to the sdk-go type. +func PostgresCatalogConfigToSDK(w *PostgresCatalogConfig) (*sdk.PostgresCatalogConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.PostgresCatalogConfig{} + conv239, err := PostgresSlotConfigToSDK(w.SlotConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PostgresCatalogConfig.SlotConfig", err) + } + out.SlotConfig = conv239 + return out, nil +} + +// PostgresCatalogConfigFromSDK converts the sdk-go type to the mirror. +func PostgresCatalogConfigFromSDK(v *sdk.PostgresCatalogConfig) (*PostgresCatalogConfig, error) { + if v == nil { + return nil, nil + } + out := &PostgresCatalogConfig{} + conv240, err := PostgresSlotConfigFromSDK(v.SlotConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PostgresCatalogConfig.SlotConfig", err) + } + out.SlotConfig = conv240 + return out, nil +} + +// PostgresSlotConfigToSDK converts the mirror to the sdk-go type. +func PostgresSlotConfigToSDK(w *PostgresSlotConfig) (*sdk.PostgresSlotConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.PostgresSlotConfig{} + out.SlotName = w.SlotName + out.PublicationName = w.PublicationName + return out, nil +} + +// PostgresSlotConfigFromSDK converts the sdk-go type to the mirror. +func PostgresSlotConfigFromSDK(v *sdk.PostgresSlotConfig) (*PostgresSlotConfig, error) { + if v == nil { + return nil, nil + } + out := &PostgresSlotConfig{} + out.SlotName = v.SlotName + out.PublicationName = v.PublicationName + return out, nil +} + +// ProtobufTransformerOptionsToSDK converts the mirror to the sdk-go type. +func ProtobufTransformerOptionsToSDK(w *ProtobufTransformerOptions) (*sdk.ProtobufTransformerOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProtobufTransformerOptions{} + out.DescFilePath = w.DescFilePath + out.MessageName = w.MessageName + out.RecursiveFieldsMaxDepth = w.RecursiveFieldsMaxDepth + out.ParseMode = w.ParseMode + conv241, err := SchemaRegistryConfigToSDK(w.SchemaRegistry) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProtobufTransformerOptions.SchemaRegistry", err) + } + out.SchemaRegistry = conv241 + return out, nil +} + +// ProtobufTransformerOptionsFromSDK converts the sdk-go type to the mirror. +func ProtobufTransformerOptionsFromSDK(v *sdk.ProtobufTransformerOptions) (*ProtobufTransformerOptions, error) { + if v == nil { + return nil, nil + } + out := &ProtobufTransformerOptions{} + out.DescFilePath = v.DescFilePath + out.MessageName = v.MessageName + out.RecursiveFieldsMaxDepth = v.RecursiveFieldsMaxDepth + out.ParseMode = v.ParseMode + conv242, err := SchemaRegistryConfigFromSDK(v.SchemaRegistry) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProtobufTransformerOptions.SchemaRegistry", err) + } + out.SchemaRegistry = conv242 + return out, nil +} + +// RabbitmqOptionsToSDK converts the mirror to the sdk-go type. +func RabbitmqOptionsToSDK(w *RabbitmqOptions) (*sdk.RabbitmqOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.RabbitmqOptions{} + out.Queue = w.Queue + return out, nil +} + +// RabbitmqOptionsFromSDK converts the sdk-go type to the mirror. +func RabbitmqOptionsFromSDK(v *sdk.RabbitmqOptions) (*RabbitmqOptions, error) { + if v == nil { + return nil, nil + } + out := &RabbitmqOptions{} + out.Queue = v.Queue + return out, nil +} + +// RedditAdsOptionsToSDK converts the mirror to the sdk-go type. +func RedditAdsOptionsToSDK(w *RedditAdsOptions) (*sdk.RedditAdsOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.RedditAdsOptions{} + out.SyncStartDate = w.SyncStartDate + out.LookbackWindowDays = w.LookbackWindowDays + conv243, err := RedditAdsOptions_RedditAdsCustomReportOptionsToSDK(w.CustomReportOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RedditAdsOptions.CustomReportOptions", err) + } + out.CustomReportOptions = conv243 + return out, nil +} + +// RedditAdsOptionsFromSDK converts the sdk-go type to the mirror. +func RedditAdsOptionsFromSDK(v *sdk.RedditAdsOptions) (*RedditAdsOptions, error) { + if v == nil { + return nil, nil + } + out := &RedditAdsOptions{} + out.SyncStartDate = v.SyncStartDate + out.LookbackWindowDays = v.LookbackWindowDays + conv244, err := RedditAdsOptions_RedditAdsCustomReportOptionsFromSDK(v.CustomReportOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RedditAdsOptions.CustomReportOptions", err) + } + out.CustomReportOptions = conv244 + return out, nil +} + +// RedditAdsOptions_RedditAdsCustomReportOptionsToSDK converts the mirror to the sdk-go type. +func RedditAdsOptions_RedditAdsCustomReportOptionsToSDK(w *RedditAdsOptions_RedditAdsCustomReportOptions) (*sdk.RedditAdsOptions_RedditAdsCustomReportOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.RedditAdsOptions_RedditAdsCustomReportOptions{} + out.Fields = w.Fields + out.Breakdowns = w.Breakdowns + return out, nil +} + +// RedditAdsOptions_RedditAdsCustomReportOptionsFromSDK converts the sdk-go type to the mirror. +func RedditAdsOptions_RedditAdsCustomReportOptionsFromSDK(v *sdk.RedditAdsOptions_RedditAdsCustomReportOptions) (*RedditAdsOptions_RedditAdsCustomReportOptions, error) { + if v == nil { + return nil, nil + } + out := &RedditAdsOptions_RedditAdsCustomReportOptions{} + out.Fields = v.Fields + out.Breakdowns = v.Breakdowns + return out, nil +} + +// ReplaceWhereOverrideToSDK converts the mirror to the sdk-go type. +func ReplaceWhereOverrideToSDK(w *ReplaceWhereOverride) (*sdk.ReplaceWhereOverride, error) { + if w == nil { + return nil, nil + } + out := &sdk.ReplaceWhereOverride{} + out.FlowName = w.FlowName + out.PredicateOverride = w.PredicateOverride + return out, nil +} + +// ReplaceWhereOverrideFromSDK converts the sdk-go type to the mirror. +func ReplaceWhereOverrideFromSDK(v *sdk.ReplaceWhereOverride) (*ReplaceWhereOverride, error) { + if v == nil { + return nil, nil + } + out := &ReplaceWhereOverride{} + out.FlowName = v.FlowName + out.PredicateOverride = v.PredicateOverride + return out, nil +} + +// RestartWindowToSDK converts the mirror to the sdk-go type. +func RestartWindowToSDK(w *RestartWindow) (*sdk.RestartWindow, error) { + if w == nil { + return nil, nil + } + out := &sdk.RestartWindow{} + out.StartHour = w.StartHour + out.DaysOfWeek = w.DaysOfWeek + out.TimeZoneId = w.TimeZoneId + return out, nil +} + +// RestartWindowFromSDK converts the sdk-go type to the mirror. +func RestartWindowFromSDK(v *sdk.RestartWindow) (*RestartWindow, error) { + if v == nil { + return nil, nil + } + out := &RestartWindow{} + out.StartHour = v.StartHour + out.DaysOfWeek = v.DaysOfWeek + out.TimeZoneId = v.TimeZoneId + return out, nil +} + +// RewindDatasetSpecToSDK converts the mirror to the sdk-go type. +func RewindDatasetSpecToSDK(w *RewindDatasetSpec) (*sdk.RewindDatasetSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.RewindDatasetSpec{} + out.Identifier = w.Identifier + out.Cascade = w.Cascade + out.ResetCheckpoints = w.ResetCheckpoints + return out, nil +} + +// RewindDatasetSpecFromSDK converts the sdk-go type to the mirror. +func RewindDatasetSpecFromSDK(v *sdk.RewindDatasetSpec) (*RewindDatasetSpec, error) { + if v == nil { + return nil, nil + } + out := &RewindDatasetSpec{} + out.Identifier = v.Identifier + out.Cascade = v.Cascade + out.ResetCheckpoints = v.ResetCheckpoints + return out, nil +} + +// RewindSpecToSDK converts the mirror to the sdk-go type. +func RewindSpecToSDK(w *RewindSpec) (*sdk.RewindSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.RewindSpec{} + out.RewindTimestamp = w.RewindTimestamp + out.DryRun = w.DryRun + conv245, err := convertSlice(w.Datasets, RewindDatasetSpecToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RewindSpec.Datasets", err) + } + out.Datasets = conv245 + return out, nil +} + +// RewindSpecFromSDK converts the sdk-go type to the mirror. +func RewindSpecFromSDK(v *sdk.RewindSpec) (*RewindSpec, error) { + if v == nil { + return nil, nil + } + out := &RewindSpec{} + out.RewindTimestamp = v.RewindTimestamp + out.DryRun = v.DryRun + conv246, err := convertSlice(v.Datasets, RewindDatasetSpecFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RewindSpec.Datasets", err) + } + out.Datasets = conv246 + return out, nil +} + +// SchemaRegistryConfigToSDK converts the mirror to the sdk-go type. +func SchemaRegistryConfigToSDK(w *SchemaRegistryConfig) (*sdk.SchemaRegistryConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.SchemaRegistryConfig{} + conv247, err := ConfluentSchemaRegistryOptionsToSDK(w.ConfluentOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaRegistryConfig.ConfluentOptions", err) + } + out.ConfluentOptions = conv247 + out.ProtobufMessageName = w.ProtobufMessageName + out.ConnectionName = w.ConnectionName + return out, nil +} + +// SchemaRegistryConfigFromSDK converts the sdk-go type to the mirror. +func SchemaRegistryConfigFromSDK(v *sdk.SchemaRegistryConfig) (*SchemaRegistryConfig, error) { + if v == nil { + return nil, nil + } + out := &SchemaRegistryConfig{} + conv248, err := ConfluentSchemaRegistryOptionsFromSDK(v.ConfluentOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaRegistryConfig.ConfluentOptions", err) + } + out.ConfluentOptions = conv248 + out.ProtobufMessageName = v.ProtobufMessageName + out.ConnectionName = v.ConnectionName + return out, nil +} + +// SequencingToSDK converts the mirror to the sdk-go type. +func SequencingToSDK(w *Sequencing) (*sdk.Sequencing, error) { + if w == nil { + return nil, nil + } + out := &sdk.Sequencing{} + conv249, err := DataPlaneIdToSDK(w.DataPlaneId) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Sequencing.DataPlaneId", err) + } + out.DataPlaneId = conv249 + out.ControlPlaneSeqNo = w.ControlPlaneSeqNo + return out, nil +} + +// SequencingFromSDK converts the sdk-go type to the mirror. +func SequencingFromSDK(v *sdk.Sequencing) (*Sequencing, error) { + if v == nil { + return nil, nil + } + out := &Sequencing{} + conv250, err := DataPlaneIdFromSDK(v.DataPlaneId) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Sequencing.DataPlaneId", err) + } + out.DataPlaneId = conv250 + out.ControlPlaneSeqNo = v.ControlPlaneSeqNo + return out, nil +} + +// SerializedExceptionToSDK converts the mirror to the sdk-go type. +func SerializedExceptionToSDK(w *SerializedException) (*sdk.SerializedException, error) { + if w == nil { + return nil, nil + } + out := &sdk.SerializedException{} + out.ClassName = w.ClassName + out.Message = w.Message + conv251, err := convertSlice(w.Stack, StackFrameToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SerializedException.Stack", err) + } + out.Stack = conv251 + return out, nil +} + +// SerializedExceptionFromSDK converts the sdk-go type to the mirror. +func SerializedExceptionFromSDK(v *sdk.SerializedException) (*SerializedException, error) { + if v == nil { + return nil, nil + } + out := &SerializedException{} + out.ClassName = v.ClassName + out.Message = v.Message + conv252, err := convertSlice(v.Stack, StackFrameFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SerializedException.Stack", err) + } + out.Stack = conv252 + return out, nil +} + +// SharepointOptionsToSDK converts the mirror to the sdk-go type. +func SharepointOptionsToSDK(w *SharepointOptions) (*sdk.SharepointOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.SharepointOptions{} + out.Url = w.Url + out.EntityType = w.EntityType + conv253, err := FileIngestionOptionsToSDK(w.FileIngestionOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SharepointOptions.FileIngestionOptions", err) + } + out.FileIngestionOptions = conv253 + return out, nil +} + +// SharepointOptionsFromSDK converts the sdk-go type to the mirror. +func SharepointOptionsFromSDK(v *sdk.SharepointOptions) (*SharepointOptions, error) { + if v == nil { + return nil, nil + } + out := &SharepointOptions{} + out.Url = v.Url + out.EntityType = v.EntityType + conv254, err := FileIngestionOptionsFromSDK(v.FileIngestionOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SharepointOptions.FileIngestionOptions", err) + } + out.FileIngestionOptions = conv254 + return out, nil +} + +// SmartsheetOptionsToSDK converts the mirror to the sdk-go type. +func SmartsheetOptionsToSDK(w *SmartsheetOptions) (*sdk.SmartsheetOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.SmartsheetOptions{} + out.EnforceSchema = w.EnforceSchema + return out, nil +} + +// SmartsheetOptionsFromSDK converts the sdk-go type to the mirror. +func SmartsheetOptionsFromSDK(v *sdk.SmartsheetOptions) (*SmartsheetOptions, error) { + if v == nil { + return nil, nil + } + out := &SmartsheetOptions{} + out.EnforceSchema = v.EnforceSchema + return out, nil +} + +// SourceCatalogConfigToSDK converts the mirror to the sdk-go type. +func SourceCatalogConfigToSDK(w *SourceCatalogConfig) (*sdk.SourceCatalogConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.SourceCatalogConfig{} + out.SourceCatalog = w.SourceCatalog + { + var members []string + if w.Postgres != nil { + members = append(members, "postgres") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Postgres != nil: + conv255, err := PostgresCatalogConfigToSDK(w.Postgres) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SourceCatalogConfig.Options", err) + } + out.Options = &sdk.SourceCatalogConfig_Options_Postgres{Postgres: *conv255} + } + return out, nil +} + +// SourceCatalogConfigFromSDK converts the sdk-go type to the mirror. +func SourceCatalogConfigFromSDK(v *sdk.SourceCatalogConfig) (*SourceCatalogConfig, error) { + if v == nil { + return nil, nil + } + out := &SourceCatalogConfig{} + out.SourceCatalog = v.SourceCatalog + switch value := v.Options.(type) { + case *sdk.SourceCatalogConfig_Options_Postgres: + if value != nil { + conv256, err := PostgresCatalogConfigFromSDK(&value.Postgres) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SourceCatalogConfig.Options", err) + } + out.Postgres = conv256 + } + } + return out, nil +} + +// SourceConfigToSDK converts the mirror to the sdk-go type. +func SourceConfigToSDK(w *SourceConfig) (*sdk.SourceConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.SourceConfig{} + conv257, err := SourceCatalogConfigToSDK(w.Catalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SourceConfig.Catalog", err) + } + out.Catalog = conv257 + { + var members []string + if w.GoogleAdsConfig != nil { + members = append(members, "google_ads_config") + } + if w.ApiSourceConnectorConfig != nil { + members = append(members, "api_source_connector_config") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.GoogleAdsConfig != nil: + conv258, err := GoogleAdsConfigToSDK(w.GoogleAdsConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SourceConfig.ConnectorConfig", err) + } + out.ConnectorConfig = &sdk.SourceConfig_ConnectorConfig_GoogleAdsConfig{GoogleAdsConfig: *conv258} + case w.ApiSourceConnectorConfig != nil: + conv259, err := ApiSourceConnectorConfigToSDK(w.ApiSourceConnectorConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SourceConfig.ConnectorConfig", err) + } + out.ConnectorConfig = &sdk.SourceConfig_ConnectorConfig_ApiSourceConnectorConfig{ApiSourceConnectorConfig: *conv259} + } + return out, nil +} + +// SourceConfigFromSDK converts the sdk-go type to the mirror. +func SourceConfigFromSDK(v *sdk.SourceConfig) (*SourceConfig, error) { + if v == nil { + return nil, nil + } + out := &SourceConfig{} + conv260, err := SourceCatalogConfigFromSDK(v.Catalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SourceConfig.Catalog", err) + } + out.Catalog = conv260 + switch value := v.ConnectorConfig.(type) { + case *sdk.SourceConfig_ConnectorConfig_GoogleAdsConfig: + if value != nil { + conv261, err := GoogleAdsConfigFromSDK(&value.GoogleAdsConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SourceConfig.ConnectorConfig", err) + } + out.GoogleAdsConfig = conv261 + } + case *sdk.SourceConfig_ConnectorConfig_ApiSourceConnectorConfig: + if value != nil { + conv262, err := ApiSourceConnectorConfigFromSDK(&value.ApiSourceConnectorConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SourceConfig.ConnectorConfig", err) + } + out.ApiSourceConnectorConfig = conv262 + } + } + return out, nil +} + +// StackFrameToSDK converts the mirror to the sdk-go type. +func StackFrameToSDK(w *StackFrame) (*sdk.StackFrame, error) { + if w == nil { + return nil, nil + } + out := &sdk.StackFrame{} + out.DeclaringClass = w.DeclaringClass + out.MethodName = w.MethodName + out.FileName = w.FileName + out.LineNumber = w.LineNumber + return out, nil +} + +// StackFrameFromSDK converts the sdk-go type to the mirror. +func StackFrameFromSDK(v *sdk.StackFrame) (*StackFrame, error) { + if v == nil { + return nil, nil + } + out := &StackFrame{} + out.DeclaringClass = v.DeclaringClass + out.MethodName = v.MethodName + out.FileName = v.FileName + out.LineNumber = v.LineNumber + return out, nil +} + +// StartUpdateRequestToSDK converts the mirror to the sdk-go type. +func StartUpdateRequestToSDK(w *StartUpdateRequest) (*sdk.StartUpdateRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.StartUpdateRequest{} + out.PipelineId = w.PipelineId + out.FullRefresh = w.FullRefresh + out.Cause = w.Cause + out.RefreshSelection = w.RefreshSelection + out.FullRefreshSelection = w.FullRefreshSelection + out.ResetCheckpointSelection = w.ResetCheckpointSelection + out.ValidateOnly = w.ValidateOnly + out.Development = w.Development + conv263, err := RewindSpecToSDK(w.RewindSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StartUpdateRequest.RewindSpec", err) + } + out.RewindSpec = conv263 + out.Parameters = w.Parameters + conv264, err := convertSlice(w.ReplaceWhereOverrides, ReplaceWhereOverrideToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StartUpdateRequest.ReplaceWhereOverrides", err) + } + out.ReplaceWhereOverrides = conv264 + return out, nil +} + +// StartUpdateRequestFromSDK converts the sdk-go type to the mirror. +func StartUpdateRequestFromSDK(v *sdk.StartUpdateRequest) (*StartUpdateRequest, error) { + if v == nil { + return nil, nil + } + out := &StartUpdateRequest{} + out.PipelineId = v.PipelineId + out.FullRefresh = v.FullRefresh + out.Cause = v.Cause + out.RefreshSelection = v.RefreshSelection + out.FullRefreshSelection = v.FullRefreshSelection + out.ResetCheckpointSelection = v.ResetCheckpointSelection + out.ValidateOnly = v.ValidateOnly + out.Development = v.Development + conv265, err := RewindSpecFromSDK(v.RewindSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StartUpdateRequest.RewindSpec", err) + } + out.RewindSpec = conv265 + out.Parameters = v.Parameters + conv266, err := convertSlice(v.ReplaceWhereOverrides, ReplaceWhereOverrideFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StartUpdateRequest.ReplaceWhereOverrides", err) + } + out.ReplaceWhereOverrides = conv266 + return out, nil +} + +// StartUpdateResponseToSDK converts the mirror to the sdk-go type. +func StartUpdateResponseToSDK(w *StartUpdateResponse) (*sdk.StartUpdateResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.StartUpdateResponse{} + out.UpdateId = w.UpdateId + return out, nil +} + +// StartUpdateResponseFromSDK converts the sdk-go type to the mirror. +func StartUpdateResponseFromSDK(v *sdk.StartUpdateResponse) (*StartUpdateResponse, error) { + if v == nil { + return nil, nil + } + out := &StartUpdateResponse{} + out.UpdateId = v.UpdateId + return out, nil +} + +// StopPipelineRequestToSDK converts the mirror to the sdk-go type. +func StopPipelineRequestToSDK(w *StopPipelineRequest) (*sdk.StopPipelineRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.StopPipelineRequest{} + out.PipelineId = w.PipelineId + return out, nil +} + +// StopPipelineRequestFromSDK converts the sdk-go type to the mirror. +func StopPipelineRequestFromSDK(v *sdk.StopPipelineRequest) (*StopPipelineRequest, error) { + if v == nil { + return nil, nil + } + out := &StopPipelineRequest{} + out.PipelineId = v.PipelineId + return out, nil +} + +// TikTokAdsOptionsToSDK converts the mirror to the sdk-go type. +func TikTokAdsOptionsToSDK(w *TikTokAdsOptions) (*sdk.TikTokAdsOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.TikTokAdsOptions{} + out.LookbackWindowDays = w.LookbackWindowDays + out.SyncStartDate = w.SyncStartDate + out.Dimensions = w.Dimensions + out.Metrics = w.Metrics + out.ReportType = w.ReportType + out.DataLevel = w.DataLevel + out.QueryLifetime = w.QueryLifetime + conv267, err := TikTokAdsOptions_TikTokAdsCustomReportOptionsToSDK(w.CustomReportOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TikTokAdsOptions.CustomReportOptions", err) + } + out.CustomReportOptions = conv267 + return out, nil +} + +// TikTokAdsOptionsFromSDK converts the sdk-go type to the mirror. +func TikTokAdsOptionsFromSDK(v *sdk.TikTokAdsOptions) (*TikTokAdsOptions, error) { + if v == nil { + return nil, nil + } + out := &TikTokAdsOptions{} + out.LookbackWindowDays = v.LookbackWindowDays + out.SyncStartDate = v.SyncStartDate + out.Dimensions = v.Dimensions + out.Metrics = v.Metrics + out.ReportType = v.ReportType + out.DataLevel = v.DataLevel + out.QueryLifetime = v.QueryLifetime + conv268, err := TikTokAdsOptions_TikTokAdsCustomReportOptionsFromSDK(v.CustomReportOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TikTokAdsOptions.CustomReportOptions", err) + } + out.CustomReportOptions = conv268 + return out, nil +} + +// TikTokAdsOptions_TikTokAdsCustomReportOptionsToSDK converts the mirror to the sdk-go type. +func TikTokAdsOptions_TikTokAdsCustomReportOptionsToSDK(w *TikTokAdsOptions_TikTokAdsCustomReportOptions) (*sdk.TikTokAdsOptions_TikTokAdsCustomReportOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.TikTokAdsOptions_TikTokAdsCustomReportOptions{} + out.Dimensions = w.Dimensions + out.Metrics = w.Metrics + out.ReportType = w.ReportType + out.DataLevel = w.DataLevel + out.QueryLifetime = w.QueryLifetime + return out, nil +} + +// TikTokAdsOptions_TikTokAdsCustomReportOptionsFromSDK converts the sdk-go type to the mirror. +func TikTokAdsOptions_TikTokAdsCustomReportOptionsFromSDK(v *sdk.TikTokAdsOptions_TikTokAdsCustomReportOptions) (*TikTokAdsOptions_TikTokAdsCustomReportOptions, error) { + if v == nil { + return nil, nil + } + out := &TikTokAdsOptions_TikTokAdsCustomReportOptions{} + out.Dimensions = v.Dimensions + out.Metrics = v.Metrics + out.ReportType = v.ReportType + out.DataLevel = v.DataLevel + out.QueryLifetime = v.QueryLifetime + return out, nil +} + +// TransformerToSDK converts the mirror to the sdk-go type. +func TransformerToSDK(w *Transformer) (*sdk.Transformer, error) { + if w == nil { + return nil, nil + } + out := &sdk.Transformer{} + out.Format = w.Format + { + var members []string + if w.JsonOptions != nil { + members = append(members, "json_options") + } + if w.AvroOptions != nil { + members = append(members, "avro_options") + } + if w.ProtobufOptions != nil { + members = append(members, "protobuf_options") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.JsonOptions != nil: + conv269, err := JsonTransformerOptionsToSDK(w.JsonOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Transformer.Config", err) + } + out.Config = &sdk.Transformer_Config_JsonOptions{JsonOptions: *conv269} + case w.AvroOptions != nil: + conv270, err := AvroTransformerOptionsToSDK(w.AvroOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Transformer.Config", err) + } + out.Config = &sdk.Transformer_Config_AvroOptions{AvroOptions: *conv270} + case w.ProtobufOptions != nil: + conv271, err := ProtobufTransformerOptionsToSDK(w.ProtobufOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Transformer.Config", err) + } + out.Config = &sdk.Transformer_Config_ProtobufOptions{ProtobufOptions: *conv271} + } + out.InputColumn = w.InputColumn + out.OutputColumn = w.OutputColumn + return out, nil +} + +// TransformerFromSDK converts the sdk-go type to the mirror. +func TransformerFromSDK(v *sdk.Transformer) (*Transformer, error) { + if v == nil { + return nil, nil + } + out := &Transformer{} + out.Format = v.Format + switch value := v.Config.(type) { + case *sdk.Transformer_Config_JsonOptions: + if value != nil { + conv272, err := JsonTransformerOptionsFromSDK(&value.JsonOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Transformer.Config", err) + } + out.JsonOptions = conv272 + } + case *sdk.Transformer_Config_AvroOptions: + if value != nil { + conv273, err := AvroTransformerOptionsFromSDK(&value.AvroOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Transformer.Config", err) + } + out.AvroOptions = conv273 + } + case *sdk.Transformer_Config_ProtobufOptions: + if value != nil { + conv274, err := ProtobufTransformerOptionsFromSDK(&value.ProtobufOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Transformer.Config", err) + } + out.ProtobufOptions = conv274 + } + } + out.InputColumn = v.InputColumn + out.OutputColumn = v.OutputColumn + return out, nil +} + +// TruncationToSDK converts the mirror to the sdk-go type. +func TruncationToSDK(w *Truncation) (*sdk.Truncation, error) { + if w == nil { + return nil, nil + } + out := &sdk.Truncation{} + conv275, err := convertSlice(w.TruncatedFields, Truncation_TruncationDetailToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Truncation.TruncatedFields", err) + } + out.TruncatedFields = conv275 + return out, nil +} + +// TruncationFromSDK converts the sdk-go type to the mirror. +func TruncationFromSDK(v *sdk.Truncation) (*Truncation, error) { + if v == nil { + return nil, nil + } + out := &Truncation{} + conv276, err := convertSlice(v.TruncatedFields, Truncation_TruncationDetailFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Truncation.TruncatedFields", err) + } + out.TruncatedFields = conv276 + return out, nil +} + +// Truncation_TruncationDetailToSDK converts the mirror to the sdk-go type. +func Truncation_TruncationDetailToSDK(w *Truncation_TruncationDetail) (*sdk.Truncation_TruncationDetail, error) { + if w == nil { + return nil, nil + } + out := &sdk.Truncation_TruncationDetail{} + out.FieldName = w.FieldName + return out, nil +} + +// Truncation_TruncationDetailFromSDK converts the sdk-go type to the mirror. +func Truncation_TruncationDetailFromSDK(v *sdk.Truncation_TruncationDetail) (*Truncation_TruncationDetail, error) { + if v == nil { + return nil, nil + } + out := &Truncation_TruncationDetail{} + out.FieldName = v.FieldName + return out, nil +} + +// UpdateInfoToSDK converts the mirror to the sdk-go type. +func UpdateInfoToSDK(w *UpdateInfo) (*sdk.UpdateInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateInfo{} + out.PipelineId = w.PipelineId + out.UpdateId = w.UpdateId + conv277, err := PipelineSpecToSDK(w.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateInfo.Config", err) + } + out.Config = conv277 + out.Cause = w.Cause + out.State = w.State + out.ClusterId = w.ClusterId + out.CreationTime = w.CreationTime + out.FullRefresh = w.FullRefresh + out.RefreshSelection = w.RefreshSelection + out.FullRefreshSelection = w.FullRefreshSelection + out.ValidateOnly = w.ValidateOnly + out.Mode = w.Mode + out.Parameters = w.Parameters + return out, nil +} + +// UpdateInfoFromSDK converts the sdk-go type to the mirror. +func UpdateInfoFromSDK(v *sdk.UpdateInfo) (*UpdateInfo, error) { + if v == nil { + return nil, nil + } + out := &UpdateInfo{} + out.PipelineId = v.PipelineId + out.UpdateId = v.UpdateId + conv278, err := PipelineSpecFromSDK(v.Config) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateInfo.Config", err) + } + out.Config = conv278 + out.Cause = v.Cause + out.State = v.State + out.ClusterId = v.ClusterId + out.CreationTime = v.CreationTime + out.FullRefresh = v.FullRefresh + out.RefreshSelection = v.RefreshSelection + out.FullRefreshSelection = v.FullRefreshSelection + out.ValidateOnly = v.ValidateOnly + out.Mode = v.Mode + out.Parameters = v.Parameters + return out, nil +} + +// UpdateStateInfoToSDK converts the mirror to the sdk-go type. +func UpdateStateInfoToSDK(w *UpdateStateInfo) (*sdk.UpdateStateInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateStateInfo{} + out.UpdateId = w.UpdateId + out.State = w.State + out.CreationTime = w.CreationTime + return out, nil +} + +// UpdateStateInfoFromSDK converts the sdk-go type to the mirror. +func UpdateStateInfoFromSDK(v *sdk.UpdateStateInfo) (*UpdateStateInfo, error) { + if v == nil { + return nil, nil + } + out := &UpdateStateInfo{} + out.UpdateId = v.UpdateId + out.State = v.State + out.CreationTime = v.CreationTime + return out, nil +} + +// ZendeskSupportOptionsToSDK converts the mirror to the sdk-go type. +func ZendeskSupportOptionsToSDK(w *ZendeskSupportOptions) (*sdk.ZendeskSupportOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.ZendeskSupportOptions{} + out.StartDate = w.StartDate + return out, nil +} + +// ZendeskSupportOptionsFromSDK converts the sdk-go type to the mirror. +func ZendeskSupportOptionsFromSDK(v *sdk.ZendeskSupportOptions) (*ZendeskSupportOptions, error) { + if v == nil { + return nil, nil + } + out := &ZendeskSupportOptions{} + out.StartDate = v.StartDate + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/policyfamilies/v2/types.generated.go b/libs/sdktypes/policyfamilies/v2/types.generated.go new file mode 100644 index 00000000000..1607939dead --- /dev/null +++ b/libs/sdktypes/policyfamilies/v2/types.generated.go @@ -0,0 +1,162 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/policyfamilies/v2. DO NOT EDIT. + +package policyfamilies + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/policyfamilies/v2" +) + +// Returns the details of a policy family at a specific version. +type GetPolicyFamilyRequest struct { + // The family ID about which to retrieve information. + PolicyFamilyId *string `json:"policy_family_id,omitempty"` + // The version number for the family to fetch. Defaults to the latest version. + Version *int64 `json:"version,omitempty"` +} + +// Returns the list of policy families available to use at their latest version. +type ListPolicyFamiliesRequest struct { + // Maximum number of policy families to return. + MaxResults *int64 `json:"max_results,omitempty"` + // A token that can be used to get the next page of results. + PageToken *string `json:"page_token,omitempty"` +} + +type ListPolicyFamiliesResponse struct { + // A token that can be used to get the next page of results. If not present, + // there are no more results to show. + NextPageToken *string `json:"next_page_token,omitempty"` + // List of policy families. + PolicyFamilies []PolicyFamily `json:"policy_families,omitempty"` +} + +type PolicyFamily struct { + // Policy definition document expressed in [Databricks Cluster Policy Definition + // Language]. + // + // [Databricks Cluster Policy Definition Language]: https://docs.databricks.com/administration-guide/clusters/policy-definition.html + Definition *string `json:"definition,omitempty"` + // Human-readable description of the purpose of the policy family. + Description *string `json:"description,omitempty"` + // Name of the policy family. + Name *string `json:"name,omitempty"` + // Unique identifier for the policy family. + PolicyFamilyId *string `json:"policy_family_id,omitempty"` +} + +// GetPolicyFamilyRequestToSDK converts the mirror to the sdk-go type. +func GetPolicyFamilyRequestToSDK(w *GetPolicyFamilyRequest) (*sdk.GetPolicyFamilyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPolicyFamilyRequest{} + out.PolicyFamilyId = w.PolicyFamilyId + out.Version = w.Version + return out, nil +} + +// GetPolicyFamilyRequestFromSDK converts the sdk-go type to the mirror. +func GetPolicyFamilyRequestFromSDK(v *sdk.GetPolicyFamilyRequest) (*GetPolicyFamilyRequest, error) { + if v == nil { + return nil, nil + } + out := &GetPolicyFamilyRequest{} + out.PolicyFamilyId = v.PolicyFamilyId + out.Version = v.Version + return out, nil +} + +// ListPolicyFamiliesRequestToSDK converts the mirror to the sdk-go type. +func ListPolicyFamiliesRequestToSDK(w *ListPolicyFamiliesRequest) (*sdk.ListPolicyFamiliesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPolicyFamiliesRequest{} + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListPolicyFamiliesRequestFromSDK converts the sdk-go type to the mirror. +func ListPolicyFamiliesRequestFromSDK(v *sdk.ListPolicyFamiliesRequest) (*ListPolicyFamiliesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListPolicyFamiliesRequest{} + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListPolicyFamiliesResponseToSDK converts the mirror to the sdk-go type. +func ListPolicyFamiliesResponseToSDK(w *ListPolicyFamiliesResponse) (*sdk.ListPolicyFamiliesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPolicyFamiliesResponse{} + conv1, err := convertSlice(w.PolicyFamilies, PolicyFamilyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPolicyFamiliesResponse.PolicyFamilies", err) + } + out.PolicyFamilies = conv1 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListPolicyFamiliesResponseFromSDK converts the sdk-go type to the mirror. +func ListPolicyFamiliesResponseFromSDK(v *sdk.ListPolicyFamiliesResponse) (*ListPolicyFamiliesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListPolicyFamiliesResponse{} + conv2, err := convertSlice(v.PolicyFamilies, PolicyFamilyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPolicyFamiliesResponse.PolicyFamilies", err) + } + out.PolicyFamilies = conv2 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// PolicyFamilyToSDK converts the mirror to the sdk-go type. +func PolicyFamilyToSDK(w *PolicyFamily) (*sdk.PolicyFamily, error) { + if w == nil { + return nil, nil + } + out := &sdk.PolicyFamily{} + out.PolicyFamilyId = w.PolicyFamilyId + out.Name = w.Name + out.Description = w.Description + out.Definition = w.Definition + return out, nil +} + +// PolicyFamilyFromSDK converts the sdk-go type to the mirror. +func PolicyFamilyFromSDK(v *sdk.PolicyFamily) (*PolicyFamily, error) { + if v == nil { + return nil, nil + } + out := &PolicyFamily{} + out.PolicyFamilyId = v.PolicyFamilyId + out.Name = v.Name + out.Description = v.Description + out.Definition = v.Definition + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/postgres/v1/types.generated.go b/libs/sdktypes/postgres/v1/types.generated.go new file mode 100644 index 00000000000..d2274f8b71d --- /dev/null +++ b/libs/sdktypes/postgres/v1/types.generated.go @@ -0,0 +1,5307 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/postgres/v1. DO NOT EDIT. + +package postgres + +import ( + json "encoding/json" + fmt "fmt" + sdk "github.com/databricks/sdk-go/postgres/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + CdfState = sdk.CdfState + DayOfWeek = sdk.DayOfWeek + EndpointType = sdk.EndpointType + ErrorCode = sdk.ErrorCode + OpenApiMode = sdk.OpenApiMode + ProvisioningPhase = sdk.ProvisioningPhase + SyncedTableState = sdk.SyncedTableState + BranchStatus_State = sdk.BranchStatus_State + EndpointStatus_State = sdk.EndpointStatus_State + NewPipelineSpec_PipelineChannel = sdk.NewPipelineSpec_PipelineChannel + ProvisioningInfo_State = sdk.ProvisioningInfo_State + RequestedClaims_PermissionSet = sdk.RequestedClaims_PermissionSet + Role_AuthMethod = sdk.Role_AuthMethod + Role_IdentityType = sdk.Role_IdentityType + Role_MembershipRole = sdk.Role_MembershipRole + SyncedTable_SyncedTableSpec_ExtraColumn_Maintenance = sdk.SyncedTable_SyncedTableSpec_ExtraColumn_Maintenance + SyncedTable_SyncedTableSpec_PgSpecificType = sdk.SyncedTable_SyncedTableSpec_PgSpecificType + SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy = sdk.SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy +) + +const ( + CdfState_Unspecified = sdk.CdfState_Unspecified + CdfState_CdfStateSnapshotting = sdk.CdfState_CdfStateSnapshotting + CdfState_CdfStateStreaming = sdk.CdfState_CdfStateStreaming + CdfState_CdfStateTerminated = sdk.CdfState_CdfStateTerminated + CdfState_CdfStateSkipped = sdk.CdfState_CdfStateSkipped + DayOfWeek_Unspecified = sdk.DayOfWeek_Unspecified + DayOfWeek_Monday = sdk.DayOfWeek_Monday + DayOfWeek_Tuesday = sdk.DayOfWeek_Tuesday + DayOfWeek_Wednesday = sdk.DayOfWeek_Wednesday + DayOfWeek_Thursday = sdk.DayOfWeek_Thursday + DayOfWeek_Friday = sdk.DayOfWeek_Friday + DayOfWeek_Saturday = sdk.DayOfWeek_Saturday + DayOfWeek_Sunday = sdk.DayOfWeek_Sunday + EndpointType_Unspecified = sdk.EndpointType_Unspecified + EndpointType_EndpointTypeReadWrite = sdk.EndpointType_EndpointTypeReadWrite + EndpointType_EndpointTypeReadOnly = sdk.EndpointType_EndpointTypeReadOnly + ErrorCode_Unspecified = sdk.ErrorCode_Unspecified + ErrorCode_InternalError = sdk.ErrorCode_InternalError + ErrorCode_TemporarilyUnavailable = sdk.ErrorCode_TemporarilyUnavailable + ErrorCode_IoError = sdk.ErrorCode_IoError + ErrorCode_BadRequest = sdk.ErrorCode_BadRequest + ErrorCode_ServiceUnderMaintenance = sdk.ErrorCode_ServiceUnderMaintenance + ErrorCode_WorkspaceTemporarilyUnavailable = sdk.ErrorCode_WorkspaceTemporarilyUnavailable + ErrorCode_DeadlineExceeded = sdk.ErrorCode_DeadlineExceeded + ErrorCode_Cancelled = sdk.ErrorCode_Cancelled + ErrorCode_ResourceExhausted = sdk.ErrorCode_ResourceExhausted + ErrorCode_Aborted = sdk.ErrorCode_Aborted + ErrorCode_NotFound = sdk.ErrorCode_NotFound + ErrorCode_AlreadyExists = sdk.ErrorCode_AlreadyExists + ErrorCode_Unauthenticated = sdk.ErrorCode_Unauthenticated + ErrorCode_Unavailable = sdk.ErrorCode_Unavailable + ErrorCode_InvalidParameterValue = sdk.ErrorCode_InvalidParameterValue + ErrorCode_EndpointNotFound = sdk.ErrorCode_EndpointNotFound + ErrorCode_MalformedRequest = sdk.ErrorCode_MalformedRequest + ErrorCode_InvalidState = sdk.ErrorCode_InvalidState + ErrorCode_PermissionDenied = sdk.ErrorCode_PermissionDenied + ErrorCode_FeatureDisabled = sdk.ErrorCode_FeatureDisabled + ErrorCode_CustomerUnauthorized = sdk.ErrorCode_CustomerUnauthorized + ErrorCode_RequestLimitExceeded = sdk.ErrorCode_RequestLimitExceeded + ErrorCode_ResourceConflict = sdk.ErrorCode_ResourceConflict + ErrorCode_UnparseableHttpError = sdk.ErrorCode_UnparseableHttpError + ErrorCode_NotImplemented = sdk.ErrorCode_NotImplemented + ErrorCode_DataLoss = sdk.ErrorCode_DataLoss + ErrorCode_InvalidStateTransition = sdk.ErrorCode_InvalidStateTransition + ErrorCode_CouldNotAcquireLock = sdk.ErrorCode_CouldNotAcquireLock + ErrorCode_ResourceAlreadyExists = sdk.ErrorCode_ResourceAlreadyExists + ErrorCode_ResourceDoesNotExist = sdk.ErrorCode_ResourceDoesNotExist + ErrorCode_QuotaExceeded = sdk.ErrorCode_QuotaExceeded + ErrorCode_MaxBlockSizeExceeded = sdk.ErrorCode_MaxBlockSizeExceeded + ErrorCode_MaxReadSizeExceeded = sdk.ErrorCode_MaxReadSizeExceeded + ErrorCode_PartialDelete = sdk.ErrorCode_PartialDelete + ErrorCode_MaxListSizeExceeded = sdk.ErrorCode_MaxListSizeExceeded + ErrorCode_DryRunFailed = sdk.ErrorCode_DryRunFailed + ErrorCode_ResourceLimitExceeded = sdk.ErrorCode_ResourceLimitExceeded + ErrorCode_DirectoryNotEmpty = sdk.ErrorCode_DirectoryNotEmpty + ErrorCode_DirectoryProtected = sdk.ErrorCode_DirectoryProtected + ErrorCode_MaxNotebookSizeExceeded = sdk.ErrorCode_MaxNotebookSizeExceeded + ErrorCode_MaxChildNodeSizeExceeded = sdk.ErrorCode_MaxChildNodeSizeExceeded + ErrorCode_SearchQueryTooLong = sdk.ErrorCode_SearchQueryTooLong + ErrorCode_SearchQueryTooShort = sdk.ErrorCode_SearchQueryTooShort + ErrorCode_ManagedResourceGroupDoesNotExist = sdk.ErrorCode_ManagedResourceGroupDoesNotExist + ErrorCode_PermissionNotPropagated = sdk.ErrorCode_PermissionNotPropagated + ErrorCode_DeploymentTimeout = sdk.ErrorCode_DeploymentTimeout + ErrorCode_GitConflict = sdk.ErrorCode_GitConflict + ErrorCode_GitUnknownRef = sdk.ErrorCode_GitUnknownRef + ErrorCode_GitSensitiveTokenDetected = sdk.ErrorCode_GitSensitiveTokenDetected + ErrorCode_GitUrlNotOnAllowList = sdk.ErrorCode_GitUrlNotOnAllowList + ErrorCode_GitRemoteError = sdk.ErrorCode_GitRemoteError + ErrorCode_ProjectsOperationTimeout = sdk.ErrorCode_ProjectsOperationTimeout + ErrorCode_IpynbFileInRepo = sdk.ErrorCode_IpynbFileInRepo + ErrorCode_InsecurePartnerResponse = sdk.ErrorCode_InsecurePartnerResponse + ErrorCode_MalformedPartnerResponse = sdk.ErrorCode_MalformedPartnerResponse + ErrorCode_MetastoreDoesNotExist = sdk.ErrorCode_MetastoreDoesNotExist + ErrorCode_DacDoesNotExist = sdk.ErrorCode_DacDoesNotExist + ErrorCode_CatalogDoesNotExist = sdk.ErrorCode_CatalogDoesNotExist + ErrorCode_SchemaDoesNotExist = sdk.ErrorCode_SchemaDoesNotExist + ErrorCode_TableDoesNotExist = sdk.ErrorCode_TableDoesNotExist + ErrorCode_ShareDoesNotExist = sdk.ErrorCode_ShareDoesNotExist + ErrorCode_RecipientDoesNotExist = sdk.ErrorCode_RecipientDoesNotExist + ErrorCode_StorageCredentialDoesNotExist = sdk.ErrorCode_StorageCredentialDoesNotExist + ErrorCode_ExternalLocationDoesNotExist = sdk.ErrorCode_ExternalLocationDoesNotExist + ErrorCode_PrincipalDoesNotExist = sdk.ErrorCode_PrincipalDoesNotExist + ErrorCode_ProviderDoesNotExist = sdk.ErrorCode_ProviderDoesNotExist + ErrorCode_MetastoreAlreadyExists = sdk.ErrorCode_MetastoreAlreadyExists + ErrorCode_DacAlreadyExists = sdk.ErrorCode_DacAlreadyExists + ErrorCode_CatalogAlreadyExists = sdk.ErrorCode_CatalogAlreadyExists + ErrorCode_SchemaAlreadyExists = sdk.ErrorCode_SchemaAlreadyExists + ErrorCode_TableAlreadyExists = sdk.ErrorCode_TableAlreadyExists + ErrorCode_ShareAlreadyExists = sdk.ErrorCode_ShareAlreadyExists + ErrorCode_RecipientAlreadyExists = sdk.ErrorCode_RecipientAlreadyExists + ErrorCode_StorageCredentialAlreadyExists = sdk.ErrorCode_StorageCredentialAlreadyExists + ErrorCode_ExternalLocationAlreadyExists = sdk.ErrorCode_ExternalLocationAlreadyExists + ErrorCode_ProviderAlreadyExists = sdk.ErrorCode_ProviderAlreadyExists + ErrorCode_CatalogNotEmpty = sdk.ErrorCode_CatalogNotEmpty + ErrorCode_SchemaNotEmpty = sdk.ErrorCode_SchemaNotEmpty + ErrorCode_MetastoreNotEmpty = sdk.ErrorCode_MetastoreNotEmpty + ErrorCode_ProviderShareNotAccessible = sdk.ErrorCode_ProviderShareNotAccessible + OpenApiMode_Unspecified = sdk.OpenApiMode_Unspecified + OpenApiMode_OpenApiModeIgnorePrivileges = sdk.OpenApiMode_OpenApiModeIgnorePrivileges + OpenApiMode_OpenApiModeDisabled = sdk.OpenApiMode_OpenApiModeDisabled + ProvisioningPhase_Unspecified = sdk.ProvisioningPhase_Unspecified + ProvisioningPhase_ProvisioningPhaseMain = sdk.ProvisioningPhase_ProvisioningPhaseMain + ProvisioningPhase_ProvisioningPhaseIndexScan = sdk.ProvisioningPhase_ProvisioningPhaseIndexScan + ProvisioningPhase_ProvisioningPhaseIndexSort = sdk.ProvisioningPhase_ProvisioningPhaseIndexSort + SyncedTableState_Unspecified = sdk.SyncedTableState_Unspecified + SyncedTableState_SyncedTableProvisioning = sdk.SyncedTableState_SyncedTableProvisioning + SyncedTableState_SyncedTableProvisioningPipelineResources = sdk.SyncedTableState_SyncedTableProvisioningPipelineResources + SyncedTableState_SyncedTableProvisioningInitialSnapshot = sdk.SyncedTableState_SyncedTableProvisioningInitialSnapshot + SyncedTableState_SyncedTableOnline = sdk.SyncedTableState_SyncedTableOnline + SyncedTableState_SyncedTableOnlineContinuousUpdate = sdk.SyncedTableState_SyncedTableOnlineContinuousUpdate + SyncedTableState_SyncedTableOnlineTriggeredUpdate = sdk.SyncedTableState_SyncedTableOnlineTriggeredUpdate + SyncedTableState_SyncedTableOnlineNoPendingUpdate = sdk.SyncedTableState_SyncedTableOnlineNoPendingUpdate + SyncedTableState_SyncedTableOffline = sdk.SyncedTableState_SyncedTableOffline + SyncedTableState_SyncedTableOfflineFailed = sdk.SyncedTableState_SyncedTableOfflineFailed + SyncedTableState_SyncedTableOnlinePipelineFailed = sdk.SyncedTableState_SyncedTableOnlinePipelineFailed + SyncedTableState_SyncedTableOnlineUpdatingPipelineResources = sdk.SyncedTableState_SyncedTableOnlineUpdatingPipelineResources + BranchStatus_State_Unspecified = sdk.BranchStatus_State_Unspecified + BranchStatus_State_Init = sdk.BranchStatus_State_Init + BranchStatus_State_Importing = sdk.BranchStatus_State_Importing + BranchStatus_State_Resetting = sdk.BranchStatus_State_Resetting + BranchStatus_State_Ready = sdk.BranchStatus_State_Ready + BranchStatus_State_Archived = sdk.BranchStatus_State_Archived + BranchStatus_State_Deleted = sdk.BranchStatus_State_Deleted + EndpointStatus_State_Unspecified = sdk.EndpointStatus_State_Unspecified + EndpointStatus_State_Init = sdk.EndpointStatus_State_Init + EndpointStatus_State_Active = sdk.EndpointStatus_State_Active + EndpointStatus_State_Idle = sdk.EndpointStatus_State_Idle + EndpointStatus_State_Degraded = sdk.EndpointStatus_State_Degraded + NewPipelineSpec_PipelineChannel_Unspecified = sdk.NewPipelineSpec_PipelineChannel_Unspecified + NewPipelineSpec_PipelineChannel_Current = sdk.NewPipelineSpec_PipelineChannel_Current + NewPipelineSpec_PipelineChannel_Preview = sdk.NewPipelineSpec_PipelineChannel_Preview + ProvisioningInfo_State_Unspecified = sdk.ProvisioningInfo_State_Unspecified + ProvisioningInfo_State_Provisioning = sdk.ProvisioningInfo_State_Provisioning + ProvisioningInfo_State_Active = sdk.ProvisioningInfo_State_Active + ProvisioningInfo_State_Failed = sdk.ProvisioningInfo_State_Failed + ProvisioningInfo_State_Deleting = sdk.ProvisioningInfo_State_Deleting + ProvisioningInfo_State_Updating = sdk.ProvisioningInfo_State_Updating + ProvisioningInfo_State_Degraded = sdk.ProvisioningInfo_State_Degraded + RequestedClaims_PermissionSet_Unspecified = sdk.RequestedClaims_PermissionSet_Unspecified + RequestedClaims_PermissionSet_ReadOnly = sdk.RequestedClaims_PermissionSet_ReadOnly + Role_AuthMethod_Unspecified = sdk.Role_AuthMethod_Unspecified + Role_AuthMethod_NoLogin = sdk.Role_AuthMethod_NoLogin + Role_AuthMethod_PgPasswordScramSha256 = sdk.Role_AuthMethod_PgPasswordScramSha256 + Role_AuthMethod_LakebaseOauthV1 = sdk.Role_AuthMethod_LakebaseOauthV1 + Role_IdentityType_Unspecified = sdk.Role_IdentityType_Unspecified + Role_IdentityType_User = sdk.Role_IdentityType_User + Role_IdentityType_ServicePrincipal = sdk.Role_IdentityType_ServicePrincipal + Role_IdentityType_Group = sdk.Role_IdentityType_Group + Role_MembershipRole_Unspecified = sdk.Role_MembershipRole_Unspecified + Role_MembershipRole_DatabricksSuperuser = sdk.Role_MembershipRole_DatabricksSuperuser + SyncedTable_SyncedTableSpec_ExtraColumn_Maintenance_Unspecified = sdk.SyncedTable_SyncedTableSpec_ExtraColumn_Maintenance_Unspecified + SyncedTable_SyncedTableSpec_ExtraColumn_Maintenance_StoredGenerated = sdk.SyncedTable_SyncedTableSpec_ExtraColumn_Maintenance_StoredGenerated + SyncedTable_SyncedTableSpec_PgSpecificType_Unspecified = sdk.SyncedTable_SyncedTableSpec_PgSpecificType_Unspecified + SyncedTable_SyncedTableSpec_PgSpecificType_PgSpecificTypeVector = sdk.SyncedTable_SyncedTableSpec_PgSpecificType_PgSpecificTypeVector + SyncedTable_SyncedTableSpec_PgSpecificType_PgSpecificTypeHalfvec = sdk.SyncedTable_SyncedTableSpec_PgSpecificType_PgSpecificTypeHalfvec + SyncedTable_SyncedTableSpec_PgSpecificType_PgSpecificTypeVarchar = sdk.SyncedTable_SyncedTableSpec_PgSpecificType_PgSpecificTypeVarchar + SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy_Unspecified = sdk.SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy_Unspecified + SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy_Continuous = sdk.SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy_Continuous + SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy_Triggered = sdk.SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy_Triggered + SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy_Snapshot = sdk.SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy_Snapshot +) + +// Databricks Error that is returned by all Databricks APIs.. +type ApiError struct { + Details []json.RawMessage `json:"details,omitempty"` + ErrorCode ErrorCode `json:"error_code,omitempty"` + Message *string `json:"message,omitempty"` + StackTrace *string `json:"stack_trace,omitempty"` +} + +type Branch struct { + // The part of the name, chosen by the user when the resource was created. + BranchId *string `json:"branch_id,omitempty"` + // A timestamp indicating when the branch was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Output only. The full resource path of the branch. Format: + // projects/{project_id}/branches/{branch_id} + Name *string `json:"name,omitempty"` + // The project containing this branch (API resource hierarchy). Format: + // projects/{project_id} + // + // Note: This field indicates where the branch exists in the resource hierarchy. + // For point-in-time branching from another branch, see `status.source_branch`. + Parent *string `json:"parent,omitempty"` + // The spec contains the branch configuration. + Spec *BranchSpec `json:"spec,omitempty"` + // The current status of a Branch. + Status *BranchStatus `json:"status,omitempty"` + // System-generated unique ID for the branch. + Uid *string `json:"uid,omitempty"` + // A timestamp indicating when the branch was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +type BranchOperationMetadata struct { +} + +type BranchSpec struct { + ExpireTime *types.Time `json:"expire_time,omitempty"` + // When set to true, protects the branch from deletion and reset. Associated + // compute endpoints and the project cannot be deleted while the branch is + // protected. + IsProtected *bool `json:"is_protected,omitempty"` + NoExpiry *bool `json:"no_expiry,omitempty"` + // The name of the source branch from which this branch was created (data + // lineage for point-in-time recovery). If not specified, defaults to the + // project's default branch. Format: projects/{project_id}/branches/{branch_id} + SourceBranch *string `json:"source_branch,omitempty"` + // The Log Sequence Number (LSN) on the source branch from which this branch was + // created. + SourceBranchLsn *string `json:"source_branch_lsn,omitempty"` + // The point in time on the source branch from which this branch was created. + SourceBranchTime *types.Time `json:"source_branch_time,omitempty"` + // The snapshot this branch was created from. When set, the branch's data comes + // from the snapshot rather than a source branch, so source_branch, + // source_branch_lsn, and source_branch_time must be empty. The snapshot must be + // AVAILABLE and belong to this branch's project. Format: + // projects/{project_id}/snapshots/{snapshot_id} + SourceSnapshot *string `json:"source_snapshot,omitempty"` + Ttl *types.Duration `json:"ttl,omitempty"` +} + +type BranchStatus struct { + // Part of the resource name. + BranchId *string `json:"branch_id,omitempty"` + // The branch's state, indicating if it is initializing, ready for use, or + // archived. + CurrentState BranchStatus_State `json:"current_state,omitempty"` + // Whether the branch is the project's default branch. + Default *bool `json:"default,omitempty"` + // A timestamp indicating when the branch was deleted. Empty if the branch is + // not deleted. + DeleteTime *types.Time `json:"delete_time,omitempty"` + // Absolute expiration time for the branch. Empty if expiration is disabled. + ExpireTime *types.Time `json:"expire_time,omitempty"` + // Whether the branch is protected. + IsProtected *bool `json:"is_protected,omitempty"` + // The logical size of the branch. + LogicalSizeBytes *int64 `json:"logical_size_bytes,omitempty"` + // The pending state of the branch, if a state transition is in progress. + PendingState BranchStatus_State `json:"pending_state,omitempty"` + // A timestamp indicating when the branch is scheduled to be purged. Empty if + // the branch is not deleted, otherwise set to a timestamp in the future. + PurgeTime *types.Time `json:"purge_time,omitempty"` + // The name of the source branch from which this branch was created. Format: + // projects/{project_id}/branches/{branch_id} + SourceBranch *string `json:"source_branch,omitempty"` + // The Log Sequence Number (LSN) on the source branch from which this branch was + // created. + SourceBranchLsn *string `json:"source_branch_lsn,omitempty"` + // The point in time on the source branch from which this branch was created. + SourceBranchTime *types.Time `json:"source_branch_time,omitempty"` + // The snapshot this branch was restored from. Set only for branches created by + // restoring a snapshot; unset for all other branches. Format: + // projects/{project_id}/snapshots/{snapshot_id} + SourceSnapshot *string `json:"source_snapshot,omitempty"` + // A timestamp indicating when the `current_state` began. + StateChangeTime *types.Time `json:"state_change_time,omitempty"` +} + +type Catalog struct { + // The part of the name, chosen by the user when the resource was created. + CatalogId *string `json:"catalog_id,omitempty"` + // A timestamp indicating when the catalog was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Output only. The full resource path of the catalog. + // + // Format: "catalogs/{catalog_id}". + Name *string `json:"name,omitempty"` + // The desired state of the Catalog. + Spec *Catalog_CatalogSpec `json:"spec,omitempty"` + // The observed state of the Catalog. + Status *Catalog_CatalogStatus `json:"status,omitempty"` + // System-generated unique identifier for the catalog. + Uid *string `json:"uid,omitempty"` + // A timestamp indicating when the catalog was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +// The desired state of the Catalog.. +type Catalog_CatalogSpec struct { + // The resource path of the branch associated with the catalog. + // + // Format: projects/{project_id}/branches/{branch_id}. + Branch *string `json:"branch,omitempty"` + // If set to true, the specified postgres_database is created on behalf of the + // calling user if it does not already exist. In this case, the calling user has + // a role created for them in Postgres if they do not already have one. + // + // Defaults to false, meaning that the request fails if the specified + // postgres_database does not already exist. + CreateDatabaseIfMissing *bool `json:"create_database_if_missing,omitempty"` + // The name of the Postgres database inside the specified Lakebase project and + // branch to be associated with the UC catalog. This database must already + // exist, unless create_database_if_missing is set to true on creation. + // + // A database can only be registered with one UC catalog at a time. To + // re-register a database with a different catalog, the existing catalog must be + // deleted first. + // + // A child branch inherits the fact of parent's registration. This means the + // same-named database in a child branch cannot be registered with a second + // catalog while the parent's registration exists. To allow registering the + // database of a child branch, drop and recreate the database on the child + // branch. This removes the fact of parent's registration from this branch only. + // + // Doing Point In Time Restore (PITR) prior to the moment before the Postgres DB + // was registered in the Catalog drops the fact of registration of the database. + // So the user should avoid doing so. + PostgresDatabase *string `json:"postgres_database,omitempty"` +} + +// The observed state of the Catalog.. +type Catalog_CatalogStatus struct { + // The resource path of the branch associated with the catalog. + // + // Format: projects/{project_id}/branches/{branch_id}. + Branch *string `json:"branch,omitempty"` + // The name of the Postgres database associated with the catalog. + PostgresDatabase *string `json:"postgres_database,omitempty"` + // The resource path of the project associated with the catalog. + // + // Format: projects/{project_id}. + Project *string `json:"project,omitempty"` +} + +type CatalogOperationMetadata struct { +} + +// A Lakebase CDF configuration (CdfConfig): one per Postgres schema per +// database, replicating that schema's tables into a Unity Catalog schema. +// Immutable once created.. +type CdfConfig struct { + // The Unity Catalog catalog that replicated tables are written into. Set at + // creation; the CdfConfig is immutable. + Catalog *string `json:"catalog,omitempty"` + // The user-specified id; equals the final segment of `name`. Defaults to the + // Postgres schema name for configs without an explicit id. + CdfConfigId *string `json:"cdf_config_id,omitempty"` + // When the CdfConfig was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Output only. The full resource name of the CdfConfig. Format: + // projects/{project}/branches/{branch}/databases/{database}/cdf-configs/{cdf_config} + Name *string `json:"name,omitempty"` + // The Postgres schema this CdfConfig replicates from. Unique within the parent + // database. Set at creation; the CdfConfig is immutable. + PostgresSchema *string `json:"postgres_schema,omitempty"` + // The Unity Catalog schema that replicated tables are written into. Set at + // creation; the CdfConfig is immutable. + Schema *string `json:"schema,omitempty"` +} + +// Metadata for CdfConfig long-running operations. Intentionally empty today; +// fields (e.g. progress) may be added as the operation contract grows.. +type CdfConfigOperationMetadata struct { +} + +// The read-only replication status of a single Postgres table replicated under +// a CdfConfig. One status exists per replicated table. It is created +// automatically and cannot be modified.. +type CdfStatus struct { + // The high-watermark Log Sequence Number (LSN) committed to Delta Lake. + CommittedLsn *string `json:"committed_lsn,omitempty"` + // When replication for this table was first established. + CreateTime *types.Time `json:"create_time,omitempty"` + // The last time changes for this table were written to Delta Lake. + LastSyncTime *types.Time `json:"last_sync_time,omitempty"` + // Output only. The full resource name of the CdfStatus. Format: + // projects/{project}/branches/{branch}/databases/{database}/cdf-configs/{cdf_config}/cdf-statuses/{cdf_status} + // The {cdf_status} segment is the Postgres table name. + Name *string `json:"name,omitempty"` + // The Postgres table being replicated. + PostgresTable *string `json:"postgres_table,omitempty"` + // The current replication state of this table. + State CdfState `json:"state,omitempty"` + // Human-readable detail for the current state (e.g. the skip/error reason). + // Empty for healthy states. + StatusDetail *string `json:"status_detail,omitempty"` + // The Unity Catalog table receiving replicated data. + UcTable *string `json:"uc_table,omitempty"` +} + +type CreateBranchRequest struct { + // The Branch to create. + Branch *Branch `json:"branch,omitempty"` + // The ID to use for the Branch. This becomes the final component of the + // branch's resource name. The ID is required and must be 1-63 characters long, + // start with a lowercase letter, and contain only lowercase letters, numbers, + // and hyphens. For example, `development` becomes + // `projects/my-app/branches/development`. + BranchId *string `json:"branch_id,omitempty"` + // The Project where this Branch will be created. Format: projects/{project_id} + Parent *string `json:"parent,omitempty"` + // If true, update the branch if it already exists instead of returning an + // error. + ReplaceExisting *bool `json:"replace_existing,omitempty"` +} + +type CreateCatalogRequest struct { + Catalog *Catalog `json:"catalog,omitempty"` + // The ID in the Unity Catalog. It becomes the full resource name, for example + // "my_catalog" becomes "catalogs/my_catalog". + CatalogId *string `json:"catalog_id,omitempty"` +} + +// Request to create a Lakebase CDF configuration (CdfConfig).. +type CreateCdfConfigRequest struct { + // The CdfConfig to create. The catalog, schema, and postgres_schema fields are + // required; service_principal is optional. All other fields are output only and + // ignored on input. + CdfConfig *CdfConfig `json:"cdf_config,omitempty"` + // The user-specified id for the CdfConfig, forming the final segment of its + // resource name. Must match the pattern `[a-z][a-z0-9_]{0,62}`. Defaults to the + // Postgres schema name when omitted. + CdfConfigId *string `json:"cdf_config_id,omitempty"` + // The parent database under which to create the CdfConfig. Format: + // projects/{project}/branches/{branch}/databases/{database} + Parent *string `json:"parent,omitempty"` +} + +// Enable Data API for a database.. +type CreateDataApiRequest struct { + // The Data API configuration to create. + DataApi *DataApi `json:"data_api,omitempty"` + // Parent database: + // projects/{project_id}/branches/{branch_id}/databases/{database_id} + Parent *string `json:"parent,omitempty"` +} + +type CreateDatabaseRequest struct { + // The desired specification of a Database. + Database *Database `json:"database,omitempty"` + // The ID to use for the Database, which will become the final component of the + // database's resource name. This ID becomes the database name in postgres. + // + // This value should be 4-63 characters, and only use characters available in + // DNS names, as defined by RFC-1123 + // + // If database_id is not specified in the request, it is generated + // automatically. + DatabaseId *string `json:"database_id,omitempty"` + // The Branch where this Database will be created. Format: + // projects/{project_id}/branches/{branch_id} + Parent *string `json:"parent,omitempty"` + // If true, update the database if it already exists instead of returning an + // error. + ReplaceExisting *bool `json:"replace_existing,omitempty"` +} + +type CreateEndpointRequest struct { + // The Endpoint to create. + Endpoint *Endpoint `json:"endpoint,omitempty"` + // The ID to use for the Endpoint. This becomes the final component of the + // endpoint's resource name. The ID is required and must be 1-63 characters + // long, start with a lowercase letter, and contain only lowercase letters, + // numbers, and hyphens. For example, `primary` becomes + // `projects/my-app/branches/development/endpoints/primary`. + EndpointId *string `json:"endpoint_id,omitempty"` + // The Branch where this Endpoint will be created. Format: + // projects/{project_id}/branches/{branch_id} + Parent *string `json:"parent,omitempty"` + // If true, update the endpoint if it already exists instead of returning an + // error. + ReplaceExisting *bool `json:"replace_existing,omitempty"` +} + +type CreateProjectRequest struct { + // The Project to create. + Project *Project `json:"project,omitempty"` + // The ID to use for the Project. This becomes the final component of the + // project's resource name. The ID is required and must be 1-63 characters long, + // start with a lowercase letter, and contain only lowercase letters, numbers, + // and hyphens. For example, `my-app` becomes `projects/my-app`. + ProjectId *string `json:"project_id,omitempty"` +} + +type CreateRoleRequest struct { + // The Branch where this Role is created. Format: + // projects/{project_id}/branches/{branch_id} + Parent *string `json:"parent,omitempty"` + // If true, update the role if it already exists instead of returning an error. + // + // When the role already exists, the provided `role` spec fully replaces the + // existing one: `membership_roles` is overwritten, not merged. Leaving + // `membership_roles` empty clears all of the role's existing memberships, + // including `DATABRICKS_SUPERUSER`. Always send the complete desired list of + // memberships when using this field. + ReplaceExisting *bool `json:"replace_existing,omitempty"` + // The desired specification of a Role. + Role *Role `json:"role,omitempty"` + // The ID to use for the Role, which will become the final component of the + // role's resource name. This ID becomes the role in Postgres. + // + // This value should be 4-63 characters, and valid characters are lowercase + // letters, numbers, and hyphens, as defined by RFC 1123. + // + // If role_id is not specified in the request, it is generated automatically. + RoleId *string `json:"role_id,omitempty"` +} + +type CreateSnapshotRequest struct { + // The project in which to create the snapshot. Format: projects/{project_id} + Parent *string `json:"parent,omitempty"` + // The snapshot to create. + Snapshot *Snapshot `json:"snapshot,omitempty"` + // Client-chosen ID for the snapshot. It becomes the final segment of the + // snapshot resource name and cannot be changed after creation. + SnapshotId *string `json:"snapshot_id,omitempty"` +} + +// Establish a synchronisation to the Postgres database for Reverse ETL for the +// source table selected from the Unity Catalog.. +type CreateSyncedTableRequest struct { + SyncedTable *SyncedTable `json:"synced_table,omitempty"` + // The ID to use for the Synced Table. This becomes the final component of the + // SyncedTable's resource name. ID is required and is the synced table name, + // containing (catalog, schema, table) tuple. Elements of the tuple are the UC + // entity names. + // + // Example: "{catalog}.{schema}.{table}" + // + // synced_table_id represents both of the following: + // + // 1. An online VIEW virtual table in the Unity Catalog accessible via the + // Lakehouse Federation. 2. Postgres table named "{table}" in schema "{schema}" + // in the connected Postgres database + SyncedTableId *string `json:"synced_table_id,omitempty"` +} + +// Take a snapshot once per day, at the configured hour.. +type DailySchedule struct { + // The hour of the day, in UTC, at which to take the snapshot, in [0, 23]. + Hour *int `json:"hour,omitempty"` +} + +// DataApi represents the Data API (PostgREST) configuration for a Database. At +// most one DataApi per database. Create enables Data API, Delete disables it.. +type DataApi struct { + // A timestamp indicating when the Data API was first enabled. + CreateTime *types.Time `json:"create_time,omitempty"` + // Resource name: + // projects/{project_id}/branches/{branch_id}/databases/{database_id}/data-api + Name *string `json:"name,omitempty"` + // The database containing this Data API configuration. Format: + // projects/{project_id}/branches/{branch_id}/databases/{database_id} + Parent *string `json:"parent,omitempty"` + // The desired Data API configuration. + Spec *DataApi_DataApiSpec `json:"spec,omitempty"` + // The observed Data API state (read-only). + Status *DataApi_DataApiStatus `json:"status,omitempty"` + // A timestamp indicating when the Data API configuration was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +// Desired PostgREST configuration (input).. +type DataApi_DataApiSpec struct { + // Enable aggregate functions (count, sum, avg, etc.) in Data API responses. + // Default: true. + DbAggregatesEnabled *bool `json:"db_aggregates_enabled,omitempty"` + // Additional schemas to include in the PostgreSQL search path. Each entry must + // be a valid PostgreSQL schema name. + DbExtraSearchPath []string `json:"db_extra_search_path,omitempty"` + // Maximum number of rows returned in a single Data API response. Must be a + // positive integer. + DbMaxRows *int `json:"db_max_rows,omitempty"` + // Database schemas exposed through the Data API. Each entry must be a valid + // PostgreSQL schema name (1-63 chars, [a-zA-Z_][a-zA-Z0-9_$]*). Maximum 100 + // entries. Default: ["public"]. + DbSchemas []string `json:"db_schemas,omitempty"` + // Maximum lifetime for cached JWT tokens. Zero duration disables caching. + JwtCacheMaxLifetime *types.Duration `json:"jwt_cache_max_lifetime,omitempty"` + // JSON path to the role claim in JWT tokens (e.g., ".sub"). Default: ".sub". + JwtRoleClaimKey *string `json:"jwt_role_claim_key,omitempty"` + // OpenAPI documentation mode for the Data API endpoint. + OpenapiMode OpenApiMode `json:"openapi_mode,omitempty"` + // Allowed origins for CORS requests. Each entry should be a valid origin URL, + // or use "*" to allow all origins. + ServerCorsAllowedOrigins []string `json:"server_cors_allowed_origins,omitempty"` + // Enable the Server-Timing header in Data API responses. + ServerTimingEnabled *bool `json:"server_timing_enabled,omitempty"` +} + +// Observed state (output-only).. +type DataApi_DataApiStatus struct { + // Schemas available in the database (for reference when configuring + // db_schemas). + AvailableSchemas []string `json:"available_schemas,omitempty"` + // Actual aggregate function setting read from the database. + DbAggregatesEnabled *bool `json:"db_aggregates_enabled,omitempty"` + // Actual extra search path schemas read from the database. + DbExtraSearchPath []string `json:"db_extra_search_path,omitempty"` + // Actual max rows setting read from the database. + DbMaxRows *int `json:"db_max_rows,omitempty"` + // Actual exposed schemas read from the database. + DbSchemas []string `json:"db_schemas,omitempty"` + // Actual JWT cache max lifetime read from the database. + JwtCacheMaxLifetime *types.Duration `json:"jwt_cache_max_lifetime,omitempty"` + // Actual JWT role claim key read from the database. + JwtRoleClaimKey *string `json:"jwt_role_claim_key,omitempty"` + // Actual OpenAPI mode read from the database. + OpenapiMode OpenApiMode `json:"openapi_mode,omitempty"` + // Actual CORS allowed origins read from the database. + ServerCorsAllowedOrigins []string `json:"server_cors_allowed_origins,omitempty"` + // Actual Server-Timing header setting read from the database. + ServerTimingEnabled *bool `json:"server_timing_enabled,omitempty"` + // Data API endpoint URL. + Url *string `json:"url,omitempty"` +} + +type DataApiOperationMetadata struct { +} + +// Database represents a Postgres database within a Branch.. +type Database struct { + // A timestamp indicating when the database was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // The part of the name, chosen by the user when the resource was created. + DatabaseId *string `json:"database_id,omitempty"` + // The resource name of the database. Format: + // projects/{project_id}/branches/{branch_id}/databases/{database_id} + Name *string `json:"name,omitempty"` + // The branch containing this database. Format: + // projects/{project_id}/branches/{branch_id} + Parent *string `json:"parent,omitempty"` + // The desired state of the Database. + Spec *Database_DatabaseSpec `json:"spec,omitempty"` + // The observed state of the Database. + Status *Database_DatabaseStatus `json:"status,omitempty"` + // A timestamp indicating when the database was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +type Database_DatabaseSpec struct { + // The name of the Postgres database. + // + // This expects a valid Postgres identifier as specified in the link below. + // https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS + // Required when creating the Database. + // + // To rename, pass a valid postgres identifier when updating the Database. + PostgresDatabase *string `json:"postgres_database,omitempty"` + // The name of the role that owns the database. Format: + // projects/{project_id}/branches/{branch_id}/roles/{role_id} + // + // To change the owner, pass valid existing Role name when updating the Database + // + // A database always has an owner. + Role *string `json:"role,omitempty"` +} + +type Database_DatabaseStatus struct { + // Part of the resource name. + DatabaseId *string `json:"database_id,omitempty"` + // The name of the Postgres database. + PostgresDatabase *string `json:"postgres_database,omitempty"` + // The name of the role that owns the database. Format: + // projects/{project_id}/branches/{branch_id}/roles/{role_id} + Role *string `json:"role,omitempty"` +} + +type DatabaseCredential struct { + // Timestamp in UTC of when this credential expires. + ExpireTime *types.Time `json:"expire_time,omitempty"` + // The OAuth token that can be used as a password when connecting to a database. + Token *string `json:"token,omitempty"` +} + +type DatabaseOperationMetadata struct { +} + +type DeleteBranchRequest struct { + // The full resource path of the branch to delete. Format: + // projects/{project_id}/branches/{branch_id} + Name *string `json:"name,omitempty"` + // If true, permanently delete the branch; if false, soft delete. + Purge *bool `json:"purge,omitempty"` +} + +// Request to delete a Lakebase CDF configuration (CdfConfig).. +type DeleteCdfConfigRequest struct { + // When true, also drops the replicated Delta tables in Unity Catalog. When + // false (the default), the replicated tables are preserved at their last synced + // state. + Force *bool `json:"force,omitempty"` + // The resource name of the CdfConfig to delete. Format: + // projects/{project}/branches/{branch}/databases/{database}/cdf-configs/{cdf_config} + Name *string `json:"name,omitempty"` +} + +type DeleteProjectRequest struct { + // The full resource path of the project to delete. Format: + // projects/{project_id} + Name *string `json:"name,omitempty"` + // If true, permanently deletes the project (hard delete). If false or unset, + // performs a soft delete. + Purge *bool `json:"purge,omitempty"` +} + +type DeleteRoleRequest struct { + // The full resource path of the role to delete. Format: + // projects/{project_id}/branches/{branch_id}/roles/{role_id} + Name *string `json:"name,omitempty"` + // Reassign objects. If this is set, all objects owned by the role are + // reassigned to the role specified in this parameter. + // + // NOTE: setting this requires spinning up a compute to succeed, since it + // involves running SQL queries. + ReassignOwnedTo *string `json:"reassign_owned_to,omitempty"` +} + +type DeltaTableSyncInfo struct { + // The timestamp when the above Delta version was committed in the source Delta + // table. Note: This is the Delta commit time, not the time the data was written + // to the synced table. + DeltaCommitTime *types.Time `json:"delta_commit_time,omitempty"` + // The Delta Lake commit version that was last successfully synced. + DeltaCommitVersion *int64 `json:"delta_commit_version,omitempty"` +} + +type Endpoint struct { + // A timestamp indicating when the compute endpoint was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // The part of the name, chosen by the user when the resource was created. + EndpointId *string `json:"endpoint_id,omitempty"` + // Output only. The full resource path of the endpoint. Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Name *string `json:"name,omitempty"` + // The branch containing this endpoint (API resource hierarchy). Format: + // projects/{project_id}/branches/{branch_id} + Parent *string `json:"parent,omitempty"` + // The spec contains the compute endpoint configuration, including autoscaling + // limits, suspend timeout, and disabled state. + Spec *EndpointSpec `json:"spec,omitempty"` + // Current operational status of the compute endpoint. + Status *EndpointStatus `json:"status,omitempty"` + // System-generated unique ID for the endpoint. + Uid *string `json:"uid,omitempty"` + // A timestamp indicating when the compute endpoint was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +type EndpointGroupSpec struct { + // Whether to allow read-only connections to read-write endpoints. Only relevant + // for read-write endpoints where size.max > 1. + EnableReadableSecondaries *bool `json:"enable_readable_secondaries,omitempty"` + // The maximum number of computes in the endpoint group. Currently, this must be + // equal to min. Set to 1 for single compute endpoints, to disable HA. To + // manually suspend all computes in an endpoint group, set disabled to true on + // the EndpointSpec. + Max *int `json:"max,omitempty"` + // The minimum number of computes in the endpoint group. Currently, this must be + // equal to max. This must be greater than or equal to 1. + Min *int `json:"min,omitempty"` +} + +type EndpointGroupStatus struct { + // Whether read-only connections to read-write endpoints are allowed. Only + // relevant if read replicas are configured by specifying size.max > 1. + EnableReadableSecondaries *bool `json:"enable_readable_secondaries,omitempty"` + // The maximum number of computes in the endpoint group. Currently, this must be + // equal to min. Set to 1 for single compute endpoints, to disable HA. To + // manually suspend all computes in an endpoint group, set disabled to true on + // the EndpointSpec. + Max *int `json:"max,omitempty"` + // The minimum number of computes in the endpoint group. Currently, this must be + // equal to max. This must be greater than or equal to 1. + Min *int `json:"min,omitempty"` +} + +// Encapsulates various hostnames (r/w or r/o, pooled or not) for an endpoint.. +type EndpointHosts struct { + // The hostname to connect to this endpoint. For read-write endpoints, this is a + // read-write hostname which connects to the primary compute. For read-only + // endpoints, this is a read-only hostname which allows read-only operations. + Host *string `json:"host,omitempty"` + // An optionally defined read-only host for the endpoint, without pooling. For + // read-only endpoints, this attribute is always defined and is equivalent to + // host. For read-write endpoints, this attribute is defined if the enclosing + // endpoint is a group with greater than 1 computes configured, and has readable + // secondaries enabled. + ReadOnlyHost *string `json:"read_only_host,omitempty"` + // The read-only hostname of the compute endpoint, with pooling. This attribute + // is always defined for read-only endpoints, and may be defined for read-write + // endpoints if configured with read replicas and allow read-only connections. + ReadOnlyPooledHost *string `json:"read_only_pooled_host,omitempty"` + // The read-write hostname of the compute endpoint, with pooling. This attribute + // is only defined for read-write endpoints. + ReadWritePooledHost *string `json:"read_write_pooled_host,omitempty"` +} + +type EndpointOperationMetadata struct { +} + +// A collection of settings for a compute endpoint.. +type EndpointSettings struct { + // A raw representation of Postgres settings. + PgSettings map[string]string `json:"pg_settings,omitempty"` +} + +type EndpointSpec struct { + // The maximum number of Compute Units. The maximum value is 64. The difference + // between the minimum and maximum Compute Units (max - min) must not exceed 16. + AutoscalingLimitMaxCu *float64 `json:"autoscaling_limit_max_cu,omitempty"` + // The minimum number of Compute Units. Minimum value is 0.5. + AutoscalingLimitMinCu *float64 `json:"autoscaling_limit_min_cu,omitempty"` + // Whether to restrict connections to the compute endpoint. Enabling this option + // schedules a suspend compute operation. A disabled compute endpoint cannot be + // enabled by a connection or console action. + Disabled *bool `json:"disabled,omitempty"` + // The endpoint type. A branch can only have one READ_WRITE endpoint. + EndpointType EndpointType `json:"endpoint_type,omitempty"` + // Settings for optional HA configuration of the endpoint. If unspecified, the + // endpoint defaults to non HA settings, with a single compute backing the + // endpoint (and no readable secondaries for Read/Write endpoints). + Group *EndpointGroupSpec `json:"group,omitempty"` + NoSuspension *bool `json:"no_suspension,omitempty"` + Settings *EndpointSettings `json:"settings,omitempty"` + SuspendTimeoutDuration *types.Duration `json:"suspend_timeout_duration,omitempty"` +} + +type EndpointStatus struct { + // The maximum number of Compute Units. The maximum value is 64. The difference + // between the minimum and maximum Compute Units (max - min) must not exceed 16. + AutoscalingLimitMaxCu *float64 `json:"autoscaling_limit_max_cu,omitempty"` + // The minimum number of Compute Units. + AutoscalingLimitMinCu *float64 `json:"autoscaling_limit_min_cu,omitempty"` + CurrentState EndpointStatus_State `json:"current_state,omitempty"` + // Whether to restrict connections to the compute endpoint. Enabling this option + // schedules a suspend compute operation. A disabled compute endpoint cannot be + // enabled by a connection or console action. + Disabled *bool `json:"disabled,omitempty"` + // Part of the resource name. + EndpointId *string `json:"endpoint_id,omitempty"` + // The endpoint type. A branch can only have one READ_WRITE endpoint. + EndpointType EndpointType `json:"endpoint_type,omitempty"` + // Details on the HA configuration of the endpoint. + Group *EndpointGroupStatus `json:"group,omitempty"` + // Contains host information for connecting to the endpoint. + Hosts *EndpointHosts `json:"hosts,omitempty"` + // A timestamp indicating when the compute endpoint was last active. + LastActiveTime *types.Time `json:"last_active_time,omitempty"` + PendingState EndpointStatus_State `json:"pending_state,omitempty"` + Settings *EndpointSettings `json:"settings,omitempty"` + // Duration of inactivity after which the compute endpoint is automatically + // suspended. + SuspendTimeoutDuration *types.Duration `json:"suspend_timeout_duration,omitempty"` +} + +type GenerateDatabaseCredentialRequest struct { + // The returned token will be scoped to UC tables with the specified + // permissions. + Claims []RequestedClaims `json:"claims,omitempty"` + // The endpoint resource name for which this credential will be generated. + // Format: projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Endpoint *string `json:"endpoint,omitempty"` + ExpireTime *types.Time `json:"expire_time,omitempty"` + Ttl *types.Duration `json:"ttl,omitempty"` +} + +// Configuration for the initial default branch created during project creation.. +type InitialBranchSpec struct { + // Whether the initial default branch should be protected from deletion. + IsProtected *bool `json:"is_protected,omitempty"` +} + +// Configuration for the initial Read/Write endpoint created during project +// creation.. +type InitialEndpointSpec struct { + // The maximum number of Compute Units for the initial endpoint. + AutoscalingLimitMaxCu *float64 `json:"autoscaling_limit_max_cu,omitempty"` + // The minimum number of Compute Units for the initial endpoint. + AutoscalingLimitMinCu *float64 `json:"autoscaling_limit_min_cu,omitempty"` + // Settings for HA configuration of the endpoint. + Group *EndpointGroupSpec `json:"group,omitempty"` + NoSuspension *bool `json:"no_suspension,omitempty"` + SuspendTimeoutDuration *types.Duration `json:"suspend_timeout_duration,omitempty"` +} + +type ListBranchesRequest struct { + // Upper bound for items returned. Cannot be negative. + PageSize *int `json:"page_size,omitempty"` + // Page token from a previous response. If not provided, returns the first page. + PageToken *string `json:"page_token,omitempty"` + // The Project that owns this collection of branches. Format: + // projects/{project_id} + Parent *string `json:"parent,omitempty"` + // Whether to include soft-deleted branches in the response. When true, deleted + // branches are included alongside active branches. Purged branches are never + // returned. + ShowDeleted *bool `json:"show_deleted,omitempty"` +} + +type ListBranchesResponse struct { + // List of branches in the project. + Branches []Branch `json:"branches,omitempty"` + // Token to request the next page of branches. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to list the Lakebase CDF configurations (CdfConfigs) under a +// database.. +type ListCdfConfigsRequest struct { + // Maximum number of CdfConfigs to return. + PageSize *int `json:"page_size,omitempty"` + // Pagination token returned by a previous ListCdfConfigs call. Empty on the + // first page. + PageToken *string `json:"page_token,omitempty"` + // The parent database to list CdfConfigs for. Format: + // projects/{project}/branches/{branch}/databases/{database} + Parent *string `json:"parent,omitempty"` +} + +// Response to a ListCdfConfigs request, containing a page of CdfConfigs and a +// token for fetching the next page.. +type ListCdfConfigsResponse struct { + // The CdfConfigs under the parent database. + CdfConfigs []CdfConfig `json:"cdf_configs,omitempty"` + // Token to retrieve the next page of results; empty when there are no more. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Request to list the statuses of all tables replicated under a Lakebase CDF +// configuration (CdfConfig).. +type ListCdfStatusesRequest struct { + // Maximum number of CdfStatuses to return. + PageSize *int `json:"page_size,omitempty"` + // Pagination token returned by a previous ListCdfStatuses call. Empty on the + // first page. + PageToken *string `json:"page_token,omitempty"` + // The parent CdfConfig to list CdfStatuses for. Format: + // projects/{project}/branches/{branch}/databases/{database}/cdf-configs/{cdf_config} + Parent *string `json:"parent,omitempty"` +} + +// Response to a ListCdfStatuses request, containing a page of replicated table +// statuses and a token for fetching the next page.. +type ListCdfStatusesResponse struct { + // The replicated tables under the parent CdfConfig. + CdfStatuses []CdfStatus `json:"cdf_statuses,omitempty"` + // Token to retrieve the next page of results; empty when there are no more. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// List Databases.. +type ListDatabasesRequest struct { + // Upper bound for items returned. + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page of Databases. Requests first page if + // absent. + PageToken *string `json:"page_token,omitempty"` + // The Branch that owns this collection of databases. Format: + // projects/{project_id}/branches/{branch_id} + Parent *string `json:"parent,omitempty"` +} + +type ListDatabasesResponse struct { + // List of databases. + Databases []Database `json:"databases,omitempty"` + // Pagination token to request the next page of databases. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListEndpointsRequest struct { + // Upper bound for items returned. Cannot be negative. + PageSize *int `json:"page_size,omitempty"` + // Page token from a previous response. If not provided, returns the first page. + PageToken *string `json:"page_token,omitempty"` + // The Branch that owns this collection of endpoints. Format: + // projects/{project_id}/branches/{branch_id} + Parent *string `json:"parent,omitempty"` +} + +type ListEndpointsResponse struct { + // List of compute endpoints in the branch. + Endpoints []Endpoint `json:"endpoints,omitempty"` + // Token to request the next page of compute endpoints. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListProjectsRequest struct { + // Upper bound for items returned. Cannot be negative. The maximum value is 100. + PageSize *int `json:"page_size,omitempty"` + // Page token from a previous response. If not provided, returns the first page. + PageToken *string `json:"page_token,omitempty"` + // Whether to include soft-deleted projects in the response. When true, + // soft-deleted projects are included alongside active projects. Hard-deleted + // and already-purged projects are never returned. + ShowDeleted *bool `json:"show_deleted,omitempty"` +} + +type ListProjectsResponse struct { + // Token to request the next page of projects. + NextPageToken *string `json:"next_page_token,omitempty"` + // List of all projects in the workspace that the user has permission to access. + Projects []Project `json:"projects,omitempty"` +} + +type ListRolesRequest struct { + // Upper bound for items returned. Cannot be negative. + PageSize *int `json:"page_size,omitempty"` + // Page token from a previous response. If not provided, returns the first page. + PageToken *string `json:"page_token,omitempty"` + // The Branch that owns this collection of roles. Format: + // projects/{project_id}/branches/{branch_id} + Parent *string `json:"parent,omitempty"` +} + +type ListRolesResponse struct { + // Token to request the next page of Postgres roles. + NextPageToken *string `json:"next_page_token,omitempty"` + // List of Postgres roles in the branch. + Roles []Role `json:"roles,omitempty"` +} + +type ListSnapshotsRequest struct { + // Maximum number of snapshots to return per page. + PageSize *int `json:"page_size,omitempty"` + // Page token from a previous response; omit for the first page. + PageToken *string `json:"page_token,omitempty"` + // The project that owns the snapshots. Format: projects/{project_id} + Parent *string `json:"parent,omitempty"` +} + +type ListSnapshotsResponse struct { + // Token to retrieve the next page; empty if there are no more pages. + NextPageToken *string `json:"next_page_token,omitempty"` + // The snapshots in the project. + Snapshots []Snapshot `json:"snapshots,omitempty"` +} + +// Take a snapshot once per month, on the configured day at the configured hour.. +type MonthlySchedule struct { + // The day of the month on which to take the snapshot, in [1, 31]. In shorter + // months the snapshot is taken on the last day instead (day 31 runs on Feb 28 + // or 29, and on Apr 30), so every month gets exactly one snapshot. + Day *int `json:"day,omitempty"` + // The hour of the day, in UTC, at which to take the snapshot, in [0, 23]. + Hour *int `json:"hour,omitempty"` +} + +type NewPipelineSpec struct { + // Budget policy to set on the newly created pipeline. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // Release channel of the underlying pipeline's runtime. Some source table + // configurations (e.g., read-time CDF) require PREVIEW. Defaults to CURRENT if + // not specified. + PipelineChannel NewPipelineSpec_PipelineChannel `json:"pipeline_channel,omitempty"` + // UC catalog for the pipeline to store intermediate files (checkpoints, event + // logs etc). This needs to be a standard catalog where the user has permissions + // to create Delta tables. + StorageCatalog *string `json:"storage_catalog,omitempty"` + // UC schema for the pipeline to store intermediate files (checkpoints, event + // logs etc). This needs to be in the standard catalog where the user has + // permissions to create Delta tables. + StorageSchema *string `json:"storage_schema,omitempty"` +} + +// This resource represents a long-running operation that is the result of a +// network API call.. +type Operation struct { + // If the value is `false`, it means the operation is still in progress. If + // `true`, the operation is completed, and either `error` or `response` is + // available. + Done *bool `json:"done,omitempty"` + Error *ApiError `json:"error,omitempty"` + // Service-specific metadata associated with the operation. It typically + // contains progress information and common metadata such as create time. Some + // services might not provide such metadata. + Metadata json.RawMessage `json:"metadata,omitempty"` + // The server-assigned name, which is only unique within the same service that + // originally returns it. If you use the default HTTP mapping, the `name` should + // be a resource name ending with `operations/{unique_id}`. + Name *string `json:"name,omitempty"` + Response json.RawMessage `json:"response,omitempty"` +} + +type Project struct { + // A timestamp indicating when the project was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // A timestamp indicating when the project was soft-deleted. Empty if the + // project is not deleted, otherwise set to a timestamp in the past. + DeleteTime *types.Time `json:"delete_time,omitempty"` + // Configuration for the initial default branch created as part of project + // creation. Allows overriding branch protection. These settings only apply at + // creation time and do not affect resources created after project creation. + InitialBranchSpec *InitialBranchSpec `json:"initial_branch_spec,omitempty"` + // Configuration settings for the initial Read/Write endpoint created inside the + // initial branch for a newly created project. If omitted, the initial endpoint + // created will have default settings, without high availability configured. + // This field does not apply to any endpoints created after project creation. + // Use spec.default_endpoint_settings to configure default settings for + // endpoints created after project creation. + InitialEndpointSpec *InitialEndpointSpec `json:"initial_endpoint_spec,omitempty"` + // Output only. The full resource path of the project. Format: + // projects/{project_id} + Name *string `json:"name,omitempty"` + // The part of the name, chosen by the user when the resource was created. + ProjectId *string `json:"project_id,omitempty"` + // A timestamp indicating when the project is scheduled for permanent deletion. + // Empty if the project is not deleted, otherwise set to a timestamp in the + // future. + PurgeTime *types.Time `json:"purge_time,omitempty"` + // The spec contains the project configuration, including display_name, + // pg_version (Postgres version), history_retention_duration, and + // default_endpoint_settings. + Spec *ProjectSpec `json:"spec,omitempty"` + // The current status of a Project. + Status *ProjectStatus `json:"status,omitempty"` + // System-generated unique ID for the project. + Uid *string `json:"uid,omitempty"` + // A timestamp indicating when the project was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +type ProjectCustomTag struct { + // The key of the custom tag. + Key *string `json:"key,omitempty"` + // The value of the custom tag. + Value *string `json:"value,omitempty"` +} + +// A collection of settings for a compute endpoint.. +type ProjectDefaultEndpointSettings struct { + // The maximum number of Compute Units. Minimum value is 0.5. + AutoscalingLimitMaxCu *float64 `json:"autoscaling_limit_max_cu,omitempty"` + // The minimum number of Compute Units. Minimum value is 0.5. + AutoscalingLimitMinCu *float64 `json:"autoscaling_limit_min_cu,omitempty"` + NoSuspension *bool `json:"no_suspension,omitempty"` + // A raw representation of Postgres settings. + PgSettings map[string]string `json:"pg_settings,omitempty"` + SuspendTimeoutDuration *types.Duration `json:"suspend_timeout_duration,omitempty"` +} + +type ProjectOperationMetadata struct { +} + +type ProjectSpec struct { + // The desired budget policy to associate with the project. See + // status.budget_policy_id for the policy that is actually applied to the + // project. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // Custom tags to associate with the project. Forwarded to LBM for billing and + // cost tracking. To update tags, provide the new tag list and include + // "spec.custom_tags" in the update_mask. To clear all tags, provide an empty + // list and include "spec.custom_tags" in the update_mask. To preserve existing + // tags, omit this field from the update_mask (or use wildcard "*" which + // auto-excludes empty tags). + CustomTags []ProjectCustomTag `json:"custom_tags,omitempty"` + // The full resource path for the default branch of the project Format: + // projects/{project_id}/branches/{branch_id} + DefaultBranch *string `json:"default_branch,omitempty"` + DefaultEndpointSettings *ProjectDefaultEndpointSettings `json:"default_endpoint_settings,omitempty"` + // Human-readable project name. Length should be between 1 and 256 characters. + DisplayName *string `json:"display_name,omitempty"` + // Whether to enable PG native password login on all endpoints in this project. + // Defaults to false. + EnablePgNativeLogin *bool `json:"enable_pg_native_login,omitempty"` + // The number of seconds to retain the shared history for point in time recovery + // for all branches in this project. Value should be between 172800s (2 days) + // and 3024000s (35 days). + HistoryRetentionDuration *types.Duration `json:"history_retention_duration,omitempty"` + // The major Postgres version number. The set of supported versions may vary; + // consult the API documentation for currently accepted values. + PgVersion *int `json:"pg_version,omitempty"` +} + +type ProjectStatus struct { + // The logical size limit for a branch. + BranchLogicalSizeLimitBytes *int64 `json:"branch_logical_size_limit_bytes,omitempty"` + // The budget policy that is applied to the project. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // The most recent time when any endpoint of this project was active. + ComputeLastActiveTime *types.Time `json:"compute_last_active_time,omitempty"` + // The effective custom tags associated with the project. + CustomTags []ProjectCustomTag `json:"custom_tags,omitempty"` + // The full resource path of the default branch of the project + DefaultBranch *string `json:"default_branch,omitempty"` + // The effective default endpoint settings. + DefaultEndpointSettings *ProjectDefaultEndpointSettings `json:"default_endpoint_settings,omitempty"` + // The effective human-readable project name. + DisplayName *string `json:"display_name,omitempty"` + // Whether to enable PG native password login on all endpoints in this project. + EnablePgNativeLogin *bool `json:"enable_pg_native_login,omitempty"` + // The effective number of seconds to retain the shared history for point in + // time recovery. + HistoryRetentionDuration *types.Duration `json:"history_retention_duration,omitempty"` + // The email of the project owner. + Owner *string `json:"owner,omitempty"` + // The effective major Postgres version number. + PgVersion *int `json:"pg_version,omitempty"` + // Part of the resource name. + ProjectId *string `json:"project_id,omitempty"` + // The current space occupied by the project in storage. + SyntheticStorageSizeBytes *int64 `json:"synthetic_storage_size_bytes,omitempty"` +} + +type RequestedClaims struct { + PermissionSet RequestedClaims_PermissionSet `json:"permission_set,omitempty"` + Resources []RequestedResource `json:"resources,omitempty"` +} + +type RequestedResource struct { + TableName *string `json:"table_name,omitempty"` +} + +// Request to reveal the current password for a password-authenticated Postgres +// role.. +type RevealRolePasswordRequest struct { + // The full resource path of the role whose password should be revealed. Format: + // projects/{project_id}/branches/{branch_id}/roles/{role_id} + Name *string `json:"name,omitempty"` +} + +// Response containing the password for a password-authenticated Postgres role.. +type RevealRolePasswordResponse struct { + // The current password for the Postgres role. + Password *string `json:"password,omitempty"` +} + +// Role represents a Postgres role within a Branch.. +type Role struct { + CreateTime *types.Time `json:"create_time,omitempty"` + // Output only. The full resource path of the role. Format: + // projects/{project_id}/branches/{branch_id}/roles/{role_id} + Name *string `json:"name,omitempty"` + // The Branch where this Role exists. Format: + // projects/{project_id}/branches/{branch_id} + Parent *string `json:"parent,omitempty"` + // The part of the name, chosen by the user when the resource was created. + RoleId *string `json:"role_id,omitempty"` + // The spec contains the role configuration, including identity type, + // authentication method, and role attributes. + Spec *Role_RoleSpec `json:"spec,omitempty"` + // Current status of the role, including its identity type, authentication + // method, and role attributes. + Status *Role_RoleStatus `json:"status,omitempty"` + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +// Attributes that can be granted to a Postgres role. We are only implementing a +// subset for now, see xref: +// https://www.postgresql.org/docs/16/sql-createrole.html The values follow +// Postgres keyword naming e.g. CREATEDB, BYPASSRLS, etc. which is why they +// don't include typical underscores between words.. +type Role_Attributes struct { + Bypassrls *bool `json:"bypassrls,omitempty"` + Createdb *bool `json:"createdb,omitempty"` + Createrole *bool `json:"createrole,omitempty"` +} + +type Role_RoleSpec struct { + // The desired API-exposed Postgres role attribute to associate with the role. + // Optional. + Attributes *Role_Attributes `json:"attributes,omitempty"` + // Controls how the Postgres role authenticates when a client opens a database + // connection. Supported values: + // + // * LAKEBASE_OAUTH_V1: the role authenticates by presenting a Databricks OAuth + // access token derived from the backing managed identity (the + // user, service principal, or group named by the role's `postgres_role`). No + // static password exists for roles using this method. * + // PG_PASSWORD_SCRAM_SHA_256: the role authenticates with a Postgres password + // verified server-side using the SCRAM-SHA-256 mechanism. Lakebase generates a + // password for the role. * NO_LOGIN: the role cannot open a Postgres session at + // all. Useful for roles that exist only to own objects or to aggregate + // privileges that are then granted to other, loginable roles. + // + // If auth_method is left unspecified, a meaningful authentication method is + // derived from the identity_type: * For the managed identities, OAUTH is used. + // * For the regular postgres roles, authentication based on postgres passwords + // is used. + // + // NOTE: for the identity type GROUP, LAKEBASE_OAUTH_V1 is the + // default auth method (group can login as well). + AuthMethod Role_AuthMethod `json:"auth_method,omitempty"` + // The type of role. When specifying a managed-identity, the chosen role_id must + // be a valid: + // + // * application ID for SERVICE_PRINCIPAL * user email for USER * group name for + // GROUP + IdentityType Role_IdentityType `json:"identity_type,omitempty"` + // An enum value for a standard role that this role is a member of. + MembershipRoles []Role_MembershipRole `json:"membership_roles,omitempty"` + // The name of the Postgres role. + // + // This expects a valid Postgres identifier as specified in the link below. + // https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS + // + // Required when creating the Role. + // + // If you wish to create a Postgres Role backed by a managed + // identity, then postgres_role must be one of the following: + // + // 1. user email for IdentityType.USER 2. app ID for + // IdentityType.SERVICE_PRINCIPAL 2. group name for IdentityType.GROUP + PostgresRole *string `json:"postgres_role,omitempty"` +} + +type Role_RoleStatus struct { + // The PG role attributes associated with the role. + Attributes *Role_Attributes `json:"attributes,omitempty"` + AuthMethod Role_AuthMethod `json:"auth_method,omitempty"` + // The type of the role. + IdentityType Role_IdentityType `json:"identity_type,omitempty"` + // An enum value for a standard role that this role is a member of. + MembershipRoles []Role_MembershipRole `json:"membership_roles,omitempty"` + // The name of the Postgres role. + PostgresRole *string `json:"postgres_role,omitempty"` + // Part of the resource name. + RoleId *string `json:"role_id,omitempty"` +} + +type RoleOperationMetadata struct { +} + +// One cadence at which automatic snapshots are taken.. +type ScheduleCadence struct { + DailySchedule *DailySchedule `json:"daily_schedule,omitempty"` + MonthlySchedule *MonthlySchedule `json:"monthly_schedule,omitempty"` + // How long snapshots from this cadence are kept before automatic deletion. Must + // be at least 1 hour. Applied when a snapshot is taken; not retroactive, so + // changing it affects only later snapshots. + Retention *types.Duration `json:"retention,omitempty"` + WeeklySchedule *WeeklySchedule `json:"weekly_schedule,omitempty"` +} + +// An immutable, point-in-time copy of a branch's data within a project. It +// remains available after the source branch is deleted.. +type Snapshot struct { + // When the snapshot was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // The resource name of the snapshot. Format: + // projects/{project_id}/snapshots/{snapshot_id} + Name *string `json:"name,omitempty"` + // The user-chosen ID; the final segment of `name`. + SnapshotId *string `json:"snapshot_id,omitempty"` + // Client-provided configuration of the snapshot. + Spec *SnapshotSpec `json:"spec,omitempty"` + // Server-observed state of the snapshot. + Status *SnapshotStatus `json:"status,omitempty"` + // Unique system-generated ID for the snapshot. + Uid *string `json:"uid,omitempty"` +} + +// Metadata for the long-running snapshot Create and Delete operations.. +type SnapshotOperationMetadata struct { +} + +// The automatic snapshot cadences for a branch. There is exactly one schedule +// per branch (singleton); it is configured in place, not created or deleted. +// +// Name: projects/{project_id}/branches/{branch_id}/snapshot-schedule. +type SnapshotSchedule struct { + // The resource name of the branch's snapshot schedule. Format: + // projects/{project_id}/branches/{branch_id}/snapshot-schedule + Name *string `json:"name,omitempty"` + // The cadences at which automatic snapshots are taken. Update replaces the + // whole set; an empty set disables automatic snapshots. Order is not + // significant. When several cadences fire together, one snapshot is taken, + // retained for the longest of their retentions. + Schedule []ScheduleCadence `json:"schedule,omitempty"` +} + +// Metadata for the long-running snapshot schedule Update operation.. +type SnapshotScheduleOperationMetadata struct { +} + +// Client-provided configuration of the snapshot.. +type SnapshotSpec struct { + ExpireTime *types.Time `json:"expire_time,omitempty"` + NoExpiry *bool `json:"no_expiry,omitempty"` + // The source branch to snapshot. Format: + // projects/{project_id}/branches/{branch_id} + SourceBranch *string `json:"source_branch,omitempty"` + SourceBranchLsn *string `json:"source_branch_lsn,omitempty"` + SourceBranchTime *types.Time `json:"source_branch_time,omitempty"` + Ttl *types.Duration `json:"ttl,omitempty"` +} + +// Server-observed state of a snapshot.. +type SnapshotStatus struct { + // Incremental storage size in bytes since the previous snapshot. Unset when the + // snapshot is not billed on incremental usage. + DiffSizeBytes *int64 `json:"diff_size_bytes,omitempty"` + ExpireTime *types.Time `json:"expire_time,omitempty"` + // Full logical size of the snapshot, in bytes. + FullSizeBytes *int64 `json:"full_size_bytes,omitempty"` + NoExpiry *bool `json:"no_expiry,omitempty"` + // The source branch the snapshot was taken from. Format: + // projects/{project_id}/branches/{branch_id} + SourceBranch *string `json:"source_branch,omitempty"` +} + +type SyncedTable struct { + CreateTime *types.Time `json:"create_time,omitempty"` + // Output only. The Full resource name of the synced table in Postgres where + // (catalog, schema, table) are the UC entity names. + // + // Format "synced_tables/{catalog}.{schema}.{table}" + // + // For the corresponding source table in the Unity catalog look for the + // "source_table_full_name" attribute. + Name *string `json:"name,omitempty"` + // Configuration details of the synced table, such as the source table, + // scheduling policy, etc. This attribute is specified at creation time and most + // fields are returned as is on subsequent queries. + Spec *SyncedTable_SyncedTableSpec `json:"spec,omitempty"` + // Synced Table data synchronization status. + Status *SyncedTable_SyncedTableStatus `json:"status,omitempty"` + // The part of the name, chosen by the user when the resource was created. + SyncedTableId *string `json:"synced_table_id,omitempty"` + // The Unity Catalog table ID for this synced table. + Uid *string `json:"uid,omitempty"` +} + +type SyncedTable_SyncedTableSpec struct { + // When true, enables accelerated sync mode for the initial data load. This + // significantly improves performance for large tables. Requires workspace-level + // enablement through Lakebase Accelerated Sync preview. + AcceleratedSync *bool `json:"accelerated_sync,omitempty"` + // The full resource name the branch associated with the table. + // + // Format: "projects/{project_id}/branches/{branch_id}". + Branch *string `json:"branch,omitempty"` + // If true, the synced table's logical database and schema resources in PG will + // be created if they do not already exist. The request will fail if this is + // false and the database/schema do not exist. + // + // Defaults to true if omitted. + CreateDatabaseObjectsIfMissing *bool `json:"create_database_objects_if_missing,omitempty"` + // ID of an existing pipeline to bin-pack this synced table into. At most one of + // existing_pipeline_id and new_pipeline_spec should be defined. + // + // The pipeline used for the synced table is returned via the top level + // pipeline_id attribute. + ExistingPipelineId *string `json:"existing_pipeline_id,omitempty"` + // Extra PostgreSQL-only columns to add to the synced table. + ExtraColumns []SyncedTable_SyncedTableSpec_ExtraColumn `json:"extra_columns,omitempty"` + // Specification for creating a new pipeline. At most one of + // existing_pipeline_id and new_pipeline_spec should be defined. + // + // The pipeline used for the synced table is returned via the top level + // pipeline_id attribute. + NewPipelineSpec *NewPipelineSpec `json:"new_pipeline_spec,omitempty"` + // The Postgres database name where the synced table will be created in. + // + // If this synced table is created inside a Lakebase Catalog, this attribute can + // be omitted on creation and is inferred from the postgres_database associated + // with the Lakebase Catalog. If specified when inside a Lakebase Catalog, the + // value must match. + // + // A value must be specified when creating a synced table inside a Standard + // Catalog. + PostgresDatabase *string `json:"postgres_database,omitempty"` + // Primary Key columns to be used for data insert/update in the destination. + PrimaryKeyColumns []string `json:"primary_key_columns,omitempty"` + // Scheduling policy of the underlying pipeline. + SchedulingPolicy SyncedTable_SyncedTableSpec_SyncedTableSchedulingPolicy `json:"scheduling_policy,omitempty"` + // Three-part (catalog, schema, table) name of the source Delta table. + // + // For the corresponding destination table, use any of the two: + // + // * synced_table_id used at the creation of the SyncedTable * "name" consisting + // of "synced_tables/" prefix and the full name of the destination table. + SourceTableFullName *string `json:"source_table_full_name,omitempty"` + // Time series key to deduplicate (tie-break) rows with the same primary key. + TimeseriesKey *string `json:"timeseries_key,omitempty"` + // Override the default Delta->PG type mapping for specific columns. A + // TypeOverride with PG_SPECIFIC_TYPE_UNSPECIFIED is rejected; a valid pg_type + // must be set. + TypeOverrides []SyncedTable_SyncedTableSpec_TypeOverride `json:"type_overrides,omitempty"` +} + +// An extra PostgreSQL column to add to the synced table.. +type SyncedTable_SyncedTableSpec_ExtraColumn struct { + // Name of the column. + ColumnName *string `json:"column_name,omitempty"` + // PostgreSQL type of the column, for example "tsvector" or "vector(1024)". + ColumnType *string `json:"column_type,omitempty"` + // SQL expression used to compute the column's value, for example + // "to_tsvector('english', content)". + Compute *string `json:"compute,omitempty"` + Maintenance SyncedTable_SyncedTableSpec_ExtraColumn_Maintenance `json:"maintenance,omitempty"` +} + +// Overrides the default Delta-to-PostgreSQL type mapping for a single column.. +type SyncedTable_SyncedTableSpec_TypeOverride struct { + // Name of the source column whose target PostgreSQL type should be overridden. + ColumnName *string `json:"column_name,omitempty"` + // PostgreSQL-specific target type to use for the column. + PgType SyncedTable_SyncedTableSpec_PgSpecificType `json:"pg_type,omitempty"` + // Size parameter for the target type, for types that take one (e.g. vector + // dimension, varchar length). Required when the chosen pg_type needs a size. + Size *int `json:"size,omitempty"` +} + +type SyncedTable_SyncedTableStatus struct { + // The state of the synced table. + DetailedState SyncedTableState `json:"detailed_state,omitempty"` + // The last source table Delta version that was successfully synced to the + // synced table. + LastProcessedCommitVersion *int64 `json:"last_processed_commit_version,omitempty"` + // Summary of the last successful synchronization from source to destination. + LastSync *SyncedTablePosition `json:"last_sync,omitempty"` + // The end timestamp of the last time any data was synchronized from the source + // table to the synced table. This is when the data is available in the synced + // table. + LastSyncTime *types.Time `json:"last_sync_time,omitempty"` + // A text description of the current state of the synced table. + Message *string `json:"message,omitempty"` + OngoingSyncProgress *SyncedTablePipelineProgress `json:"ongoing_sync_progress,omitempty"` + // ID of the associated pipeline. + PipelineId *string `json:"pipeline_id,omitempty"` + // The full resource name of the project associated with the table. + // + // Format: "projects/{project_id}". + Project *string `json:"project,omitempty"` + // The current phase of the data synchronization pipeline. + ProvisioningPhase ProvisioningPhase `json:"provisioning_phase,omitempty"` + // The provisioning state of the synced table entity in Unity Catalog. + UnityCatalogProvisioningState ProvisioningInfo_State `json:"unity_catalog_provisioning_state,omitempty"` +} + +// Metadata for SyncedTable long-running operations.. +type SyncedTableOperationMetadata struct { +} + +// Progress information of the Synced Table data synchronization pipeline.. +type SyncedTablePipelineProgress struct { + // The estimated time remaining to complete this update in seconds. + EstimatedCompletionTimeSeconds *float64 `json:"estimated_completion_time_seconds,omitempty"` + // The source table Delta version that was last processed by the pipeline. The + // pipeline may not have completely processed this version yet. + LatestVersionCurrentlyProcessing *int64 `json:"latest_version_currently_processing,omitempty"` + // The completion ratio of this update. This is a number between 0 and 1. + SyncProgressCompletion *float64 `json:"sync_progress_completion,omitempty"` + // The number of rows that have been synced in this update. + SyncedRowCount *int64 `json:"synced_row_count,omitempty"` + // The total number of rows that need to be synced in this update. This number + // may be an estimate. + TotalRowCount *int64 `json:"total_row_count,omitempty"` +} + +type SyncedTablePosition struct { + DeltaTableSyncInfo *DeltaTableSyncInfo `json:"delta_table_sync_info,omitempty"` + // The end timestamp of the most recent successful synchronization. This is the + // time when the data is available in the synced table. + SyncEndTime *types.Time `json:"sync_end_time,omitempty"` + // The starting timestamp of the most recent successful synchronization from the + // source table to the destination (synced) table. Note this is the starting + // timestamp of the sync operation, not the end time. E.g., for a batch, this is + // the time when the sync operation started. + SyncStartTime *types.Time `json:"sync_start_time,omitempty"` +} + +type UndeleteBranchRequest struct { + // The full resource path of the branch to undelete. Format: + // projects/{project_id}/branches/{branch_id} + Name *string `json:"name,omitempty"` +} + +// Request to restore a soft-deleted project within its retention period.. +type UndeleteProjectRequest struct { + // The full resource path of the project to undelete. Format: + // projects/{project_id} + Name *string `json:"name,omitempty"` +} + +type UpdateBranchRequest struct { + // The Branch to update. + // + // The branch's `name` field is used to identify the branch to update. Format: + // projects/{project_id}/branches/{branch_id} + Branch *Branch `json:"branch,omitempty"` + // The list of fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Update Data API configuration for a database.. +type UpdateDataApiRequest struct { + // The Data API configuration to update. The data_api's `name` field identifies + // the resource. + DataApi *DataApi `json:"data_api,omitempty"` + // The list of fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateDatabaseRequest struct { + // The Database to update. + // + // The database's `name` field is used to identify the database to update. + // Format: projects/{project_id}/branches/{branch_id}/databases/{database_id} + Database *Database `json:"database,omitempty"` + // The list of fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateEndpointRequest struct { + // The Endpoint to update. + // + // The endpoint's `name` field is used to identify the endpoint to update. + // Format: projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Endpoint *Endpoint `json:"endpoint,omitempty"` + // The list of fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateProjectRequest struct { + // The Project to update. + // + // The project's `name` field is used to identify the project to update. Format: + // projects/{project_id} + Project *Project `json:"project,omitempty"` + // The list of fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateRoleRequest struct { + // The Postgres Role to update. + // + // The role's `name` field is used to identify the role to update. Format: + // projects/{project_id}/branches/{branch_id}/roles/{role_id} + Role *Role `json:"role,omitempty"` + // The list of fields to update. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Request to set the snapshot schedule for a branch. Returns a completed +// long-running operation whose response is the persisted snapshot schedule.. +type UpdateSnapshotScheduleRequest struct { + // The snapshot schedule to set. Its `name` identifies the branch. Format: + // projects/{project_id}/branches/{branch_id}/snapshot-schedule + SnapshotSchedule *SnapshotSchedule `json:"snapshot_schedule,omitempty"` + // Fields to update. The only updatable path is `schedule`, which replaces the + // entire set of cadences. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// Take a snapshot once per week, on the configured day at the configured hour.. +type WeeklySchedule struct { + // The day of the week on which to take the snapshot. + DayOfWeek DayOfWeek `json:"day_of_week,omitempty"` + // The hour of the day, in UTC, at which to take the snapshot, in [0, 23]. + Hour *int `json:"hour,omitempty"` +} + +// ApiErrorToSDK converts the mirror to the sdk-go type. +func ApiErrorToSDK(w *ApiError) (*sdk.ApiError, error) { + if w == nil { + return nil, nil + } + out := &sdk.ApiError{} + out.ErrorCode = w.ErrorCode + out.Message = w.Message + out.StackTrace = w.StackTrace + out.Details = w.Details + return out, nil +} + +// ApiErrorFromSDK converts the sdk-go type to the mirror. +func ApiErrorFromSDK(v *sdk.ApiError) (*ApiError, error) { + if v == nil { + return nil, nil + } + out := &ApiError{} + out.ErrorCode = v.ErrorCode + out.Message = v.Message + out.StackTrace = v.StackTrace + out.Details = v.Details + return out, nil +} + +// BranchToSDK converts the mirror to the sdk-go type. +func BranchToSDK(w *Branch) (*sdk.Branch, error) { + if w == nil { + return nil, nil + } + out := &sdk.Branch{} + out.Name = w.Name + out.Uid = w.Uid + out.Parent = w.Parent + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + conv1, err := BranchSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Branch.Spec", err) + } + out.Spec = conv1 + conv2, err := BranchStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Branch.Status", err) + } + out.Status = conv2 + out.BranchId = w.BranchId + return out, nil +} + +// BranchFromSDK converts the sdk-go type to the mirror. +func BranchFromSDK(v *sdk.Branch) (*Branch, error) { + if v == nil { + return nil, nil + } + out := &Branch{} + out.Name = v.Name + out.Uid = v.Uid + out.Parent = v.Parent + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + conv3, err := BranchSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Branch.Spec", err) + } + out.Spec = conv3 + conv4, err := BranchStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Branch.Status", err) + } + out.Status = conv4 + out.BranchId = v.BranchId + return out, nil +} + +// BranchOperationMetadataToSDK converts the mirror to the sdk-go type. +func BranchOperationMetadataToSDK(w *BranchOperationMetadata) (*sdk.BranchOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.BranchOperationMetadata{} + return out, nil +} + +// BranchOperationMetadataFromSDK converts the sdk-go type to the mirror. +func BranchOperationMetadataFromSDK(v *sdk.BranchOperationMetadata) (*BranchOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &BranchOperationMetadata{} + return out, nil +} + +// BranchSpecToSDK converts the mirror to the sdk-go type. +func BranchSpecToSDK(w *BranchSpec) (*sdk.BranchSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.BranchSpec{} + out.SourceBranch = w.SourceBranch + out.SourceBranchLsn = w.SourceBranchLsn + out.SourceBranchTime = w.SourceBranchTime + out.IsProtected = w.IsProtected + { + var members []string + if w.ExpireTime != nil { + members = append(members, "expire_time") + } + if w.Ttl != nil { + members = append(members, "ttl") + } + if w.NoExpiry != nil { + members = append(members, "no_expiry") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ExpireTime != nil: + out.Expiration = &sdk.BranchSpec_Expiration_ExpireTime{ExpireTime: *w.ExpireTime} + case w.Ttl != nil: + out.Expiration = &sdk.BranchSpec_Expiration_Ttl{Ttl: *w.Ttl} + case w.NoExpiry != nil: + out.Expiration = &sdk.BranchSpec_Expiration_NoExpiry{NoExpiry: *w.NoExpiry} + } + out.SourceSnapshot = w.SourceSnapshot + return out, nil +} + +// BranchSpecFromSDK converts the sdk-go type to the mirror. +func BranchSpecFromSDK(v *sdk.BranchSpec) (*BranchSpec, error) { + if v == nil { + return nil, nil + } + out := &BranchSpec{} + out.SourceBranch = v.SourceBranch + out.SourceBranchLsn = v.SourceBranchLsn + out.SourceBranchTime = v.SourceBranchTime + out.IsProtected = v.IsProtected + switch value := v.Expiration.(type) { + case *sdk.BranchSpec_Expiration_ExpireTime: + if value != nil { + out.ExpireTime = new(value.ExpireTime) + } + case *sdk.BranchSpec_Expiration_Ttl: + if value != nil { + out.Ttl = new(value.Ttl) + } + case *sdk.BranchSpec_Expiration_NoExpiry: + if value != nil { + out.NoExpiry = new(value.NoExpiry) + } + } + out.SourceSnapshot = v.SourceSnapshot + return out, nil +} + +// BranchStatusToSDK converts the mirror to the sdk-go type. +func BranchStatusToSDK(w *BranchStatus) (*sdk.BranchStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.BranchStatus{} + out.SourceBranch = w.SourceBranch + out.SourceBranchLsn = w.SourceBranchLsn + out.SourceBranchTime = w.SourceBranchTime + out.Default = w.Default + out.IsProtected = w.IsProtected + out.CurrentState = w.CurrentState + out.PendingState = w.PendingState + out.StateChangeTime = w.StateChangeTime + out.LogicalSizeBytes = w.LogicalSizeBytes + out.ExpireTime = w.ExpireTime + out.BranchId = w.BranchId + out.DeleteTime = w.DeleteTime + out.PurgeTime = w.PurgeTime + out.SourceSnapshot = w.SourceSnapshot + return out, nil +} + +// BranchStatusFromSDK converts the sdk-go type to the mirror. +func BranchStatusFromSDK(v *sdk.BranchStatus) (*BranchStatus, error) { + if v == nil { + return nil, nil + } + out := &BranchStatus{} + out.SourceBranch = v.SourceBranch + out.SourceBranchLsn = v.SourceBranchLsn + out.SourceBranchTime = v.SourceBranchTime + out.Default = v.Default + out.IsProtected = v.IsProtected + out.CurrentState = v.CurrentState + out.PendingState = v.PendingState + out.StateChangeTime = v.StateChangeTime + out.LogicalSizeBytes = v.LogicalSizeBytes + out.ExpireTime = v.ExpireTime + out.BranchId = v.BranchId + out.DeleteTime = v.DeleteTime + out.PurgeTime = v.PurgeTime + out.SourceSnapshot = v.SourceSnapshot + return out, nil +} + +// CatalogToSDK converts the mirror to the sdk-go type. +func CatalogToSDK(w *Catalog) (*sdk.Catalog, error) { + if w == nil { + return nil, nil + } + out := &sdk.Catalog{} + out.Name = w.Name + out.Uid = w.Uid + conv5, err := Catalog_CatalogSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Catalog.Spec", err) + } + out.Spec = conv5 + conv6, err := Catalog_CatalogStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Catalog.Status", err) + } + out.Status = conv6 + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.CatalogId = w.CatalogId + return out, nil +} + +// CatalogFromSDK converts the sdk-go type to the mirror. +func CatalogFromSDK(v *sdk.Catalog) (*Catalog, error) { + if v == nil { + return nil, nil + } + out := &Catalog{} + out.Name = v.Name + out.Uid = v.Uid + conv7, err := Catalog_CatalogSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Catalog.Spec", err) + } + out.Spec = conv7 + conv8, err := Catalog_CatalogStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Catalog.Status", err) + } + out.Status = conv8 + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.CatalogId = v.CatalogId + return out, nil +} + +// CatalogOperationMetadataToSDK converts the mirror to the sdk-go type. +func CatalogOperationMetadataToSDK(w *CatalogOperationMetadata) (*sdk.CatalogOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.CatalogOperationMetadata{} + return out, nil +} + +// CatalogOperationMetadataFromSDK converts the sdk-go type to the mirror. +func CatalogOperationMetadataFromSDK(v *sdk.CatalogOperationMetadata) (*CatalogOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &CatalogOperationMetadata{} + return out, nil +} + +// Catalog_CatalogSpecToSDK converts the mirror to the sdk-go type. +func Catalog_CatalogSpecToSDK(w *Catalog_CatalogSpec) (*sdk.Catalog_CatalogSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.Catalog_CatalogSpec{} + out.PostgresDatabase = w.PostgresDatabase + out.CreateDatabaseIfMissing = w.CreateDatabaseIfMissing + out.Branch = w.Branch + return out, nil +} + +// Catalog_CatalogSpecFromSDK converts the sdk-go type to the mirror. +func Catalog_CatalogSpecFromSDK(v *sdk.Catalog_CatalogSpec) (*Catalog_CatalogSpec, error) { + if v == nil { + return nil, nil + } + out := &Catalog_CatalogSpec{} + out.PostgresDatabase = v.PostgresDatabase + out.CreateDatabaseIfMissing = v.CreateDatabaseIfMissing + out.Branch = v.Branch + return out, nil +} + +// Catalog_CatalogStatusToSDK converts the mirror to the sdk-go type. +func Catalog_CatalogStatusToSDK(w *Catalog_CatalogStatus) (*sdk.Catalog_CatalogStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.Catalog_CatalogStatus{} + out.PostgresDatabase = w.PostgresDatabase + out.Project = w.Project + out.Branch = w.Branch + return out, nil +} + +// Catalog_CatalogStatusFromSDK converts the sdk-go type to the mirror. +func Catalog_CatalogStatusFromSDK(v *sdk.Catalog_CatalogStatus) (*Catalog_CatalogStatus, error) { + if v == nil { + return nil, nil + } + out := &Catalog_CatalogStatus{} + out.PostgresDatabase = v.PostgresDatabase + out.Project = v.Project + out.Branch = v.Branch + return out, nil +} + +// CdfConfigToSDK converts the mirror to the sdk-go type. +func CdfConfigToSDK(w *CdfConfig) (*sdk.CdfConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.CdfConfig{} + out.Name = w.Name + out.Catalog = w.Catalog + out.Schema = w.Schema + out.CreateTime = w.CreateTime + out.CdfConfigId = w.CdfConfigId + out.PostgresSchema = w.PostgresSchema + return out, nil +} + +// CdfConfigFromSDK converts the sdk-go type to the mirror. +func CdfConfigFromSDK(v *sdk.CdfConfig) (*CdfConfig, error) { + if v == nil { + return nil, nil + } + out := &CdfConfig{} + out.Name = v.Name + out.Catalog = v.Catalog + out.Schema = v.Schema + out.CreateTime = v.CreateTime + out.CdfConfigId = v.CdfConfigId + out.PostgresSchema = v.PostgresSchema + return out, nil +} + +// CdfConfigOperationMetadataToSDK converts the mirror to the sdk-go type. +func CdfConfigOperationMetadataToSDK(w *CdfConfigOperationMetadata) (*sdk.CdfConfigOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.CdfConfigOperationMetadata{} + return out, nil +} + +// CdfConfigOperationMetadataFromSDK converts the sdk-go type to the mirror. +func CdfConfigOperationMetadataFromSDK(v *sdk.CdfConfigOperationMetadata) (*CdfConfigOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &CdfConfigOperationMetadata{} + return out, nil +} + +// CdfStatusToSDK converts the mirror to the sdk-go type. +func CdfStatusToSDK(w *CdfStatus) (*sdk.CdfStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.CdfStatus{} + out.Name = w.Name + out.PostgresTable = w.PostgresTable + out.UcTable = w.UcTable + out.State = w.State + out.CommittedLsn = w.CommittedLsn + out.LastSyncTime = w.LastSyncTime + out.CreateTime = w.CreateTime + out.StatusDetail = w.StatusDetail + return out, nil +} + +// CdfStatusFromSDK converts the sdk-go type to the mirror. +func CdfStatusFromSDK(v *sdk.CdfStatus) (*CdfStatus, error) { + if v == nil { + return nil, nil + } + out := &CdfStatus{} + out.Name = v.Name + out.PostgresTable = v.PostgresTable + out.UcTable = v.UcTable + out.State = v.State + out.CommittedLsn = v.CommittedLsn + out.LastSyncTime = v.LastSyncTime + out.CreateTime = v.CreateTime + out.StatusDetail = v.StatusDetail + return out, nil +} + +// CreateBranchRequestToSDK converts the mirror to the sdk-go type. +func CreateBranchRequestToSDK(w *CreateBranchRequest) (*sdk.CreateBranchRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateBranchRequest{} + out.Parent = w.Parent + out.BranchId = w.BranchId + conv9, err := BranchToSDK(w.Branch) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBranchRequest.Branch", err) + } + out.Branch = conv9 + out.ReplaceExisting = w.ReplaceExisting + return out, nil +} + +// CreateBranchRequestFromSDK converts the sdk-go type to the mirror. +func CreateBranchRequestFromSDK(v *sdk.CreateBranchRequest) (*CreateBranchRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateBranchRequest{} + out.Parent = v.Parent + out.BranchId = v.BranchId + conv10, err := BranchFromSDK(v.Branch) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateBranchRequest.Branch", err) + } + out.Branch = conv10 + out.ReplaceExisting = v.ReplaceExisting + return out, nil +} + +// CreateCatalogRequestToSDK converts the mirror to the sdk-go type. +func CreateCatalogRequestToSDK(w *CreateCatalogRequest) (*sdk.CreateCatalogRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCatalogRequest{} + out.CatalogId = w.CatalogId + conv11, err := CatalogToSDK(w.Catalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCatalogRequest.Catalog", err) + } + out.Catalog = conv11 + return out, nil +} + +// CreateCatalogRequestFromSDK converts the sdk-go type to the mirror. +func CreateCatalogRequestFromSDK(v *sdk.CreateCatalogRequest) (*CreateCatalogRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCatalogRequest{} + out.CatalogId = v.CatalogId + conv12, err := CatalogFromSDK(v.Catalog) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCatalogRequest.Catalog", err) + } + out.Catalog = conv12 + return out, nil +} + +// CreateCdfConfigRequestToSDK converts the mirror to the sdk-go type. +func CreateCdfConfigRequestToSDK(w *CreateCdfConfigRequest) (*sdk.CreateCdfConfigRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCdfConfigRequest{} + out.Parent = w.Parent + conv13, err := CdfConfigToSDK(w.CdfConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCdfConfigRequest.CdfConfig", err) + } + out.CdfConfig = conv13 + out.CdfConfigId = w.CdfConfigId + return out, nil +} + +// CreateCdfConfigRequestFromSDK converts the sdk-go type to the mirror. +func CreateCdfConfigRequestFromSDK(v *sdk.CreateCdfConfigRequest) (*CreateCdfConfigRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCdfConfigRequest{} + out.Parent = v.Parent + conv14, err := CdfConfigFromSDK(v.CdfConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCdfConfigRequest.CdfConfig", err) + } + out.CdfConfig = conv14 + out.CdfConfigId = v.CdfConfigId + return out, nil +} + +// CreateDataApiRequestToSDK converts the mirror to the sdk-go type. +func CreateDataApiRequestToSDK(w *CreateDataApiRequest) (*sdk.CreateDataApiRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateDataApiRequest{} + out.Parent = w.Parent + conv15, err := DataApiToSDK(w.DataApi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDataApiRequest.DataApi", err) + } + out.DataApi = conv15 + return out, nil +} + +// CreateDataApiRequestFromSDK converts the sdk-go type to the mirror. +func CreateDataApiRequestFromSDK(v *sdk.CreateDataApiRequest) (*CreateDataApiRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateDataApiRequest{} + out.Parent = v.Parent + conv16, err := DataApiFromSDK(v.DataApi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDataApiRequest.DataApi", err) + } + out.DataApi = conv16 + return out, nil +} + +// CreateDatabaseRequestToSDK converts the mirror to the sdk-go type. +func CreateDatabaseRequestToSDK(w *CreateDatabaseRequest) (*sdk.CreateDatabaseRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateDatabaseRequest{} + out.Parent = w.Parent + out.DatabaseId = w.DatabaseId + conv17, err := DatabaseToSDK(w.Database) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDatabaseRequest.Database", err) + } + out.Database = conv17 + out.ReplaceExisting = w.ReplaceExisting + return out, nil +} + +// CreateDatabaseRequestFromSDK converts the sdk-go type to the mirror. +func CreateDatabaseRequestFromSDK(v *sdk.CreateDatabaseRequest) (*CreateDatabaseRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateDatabaseRequest{} + out.Parent = v.Parent + out.DatabaseId = v.DatabaseId + conv18, err := DatabaseFromSDK(v.Database) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDatabaseRequest.Database", err) + } + out.Database = conv18 + out.ReplaceExisting = v.ReplaceExisting + return out, nil +} + +// CreateEndpointRequestToSDK converts the mirror to the sdk-go type. +func CreateEndpointRequestToSDK(w *CreateEndpointRequest) (*sdk.CreateEndpointRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateEndpointRequest{} + out.Parent = w.Parent + out.EndpointId = w.EndpointId + conv19, err := EndpointToSDK(w.Endpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateEndpointRequest.Endpoint", err) + } + out.Endpoint = conv19 + out.ReplaceExisting = w.ReplaceExisting + return out, nil +} + +// CreateEndpointRequestFromSDK converts the sdk-go type to the mirror. +func CreateEndpointRequestFromSDK(v *sdk.CreateEndpointRequest) (*CreateEndpointRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateEndpointRequest{} + out.Parent = v.Parent + out.EndpointId = v.EndpointId + conv20, err := EndpointFromSDK(v.Endpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateEndpointRequest.Endpoint", err) + } + out.Endpoint = conv20 + out.ReplaceExisting = v.ReplaceExisting + return out, nil +} + +// CreateProjectRequestToSDK converts the mirror to the sdk-go type. +func CreateProjectRequestToSDK(w *CreateProjectRequest) (*sdk.CreateProjectRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateProjectRequest{} + out.ProjectId = w.ProjectId + conv21, err := ProjectToSDK(w.Project) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateProjectRequest.Project", err) + } + out.Project = conv21 + return out, nil +} + +// CreateProjectRequestFromSDK converts the sdk-go type to the mirror. +func CreateProjectRequestFromSDK(v *sdk.CreateProjectRequest) (*CreateProjectRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateProjectRequest{} + out.ProjectId = v.ProjectId + conv22, err := ProjectFromSDK(v.Project) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateProjectRequest.Project", err) + } + out.Project = conv22 + return out, nil +} + +// CreateRoleRequestToSDK converts the mirror to the sdk-go type. +func CreateRoleRequestToSDK(w *CreateRoleRequest) (*sdk.CreateRoleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRoleRequest{} + out.Parent = w.Parent + out.RoleId = w.RoleId + conv23, err := RoleToSDK(w.Role) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRoleRequest.Role", err) + } + out.Role = conv23 + out.ReplaceExisting = w.ReplaceExisting + return out, nil +} + +// CreateRoleRequestFromSDK converts the sdk-go type to the mirror. +func CreateRoleRequestFromSDK(v *sdk.CreateRoleRequest) (*CreateRoleRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateRoleRequest{} + out.Parent = v.Parent + out.RoleId = v.RoleId + conv24, err := RoleFromSDK(v.Role) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRoleRequest.Role", err) + } + out.Role = conv24 + out.ReplaceExisting = v.ReplaceExisting + return out, nil +} + +// CreateSnapshotRequestToSDK converts the mirror to the sdk-go type. +func CreateSnapshotRequestToSDK(w *CreateSnapshotRequest) (*sdk.CreateSnapshotRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateSnapshotRequest{} + out.Parent = w.Parent + conv25, err := SnapshotToSDK(w.Snapshot) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSnapshotRequest.Snapshot", err) + } + out.Snapshot = conv25 + out.SnapshotId = w.SnapshotId + return out, nil +} + +// CreateSnapshotRequestFromSDK converts the sdk-go type to the mirror. +func CreateSnapshotRequestFromSDK(v *sdk.CreateSnapshotRequest) (*CreateSnapshotRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateSnapshotRequest{} + out.Parent = v.Parent + conv26, err := SnapshotFromSDK(v.Snapshot) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSnapshotRequest.Snapshot", err) + } + out.Snapshot = conv26 + out.SnapshotId = v.SnapshotId + return out, nil +} + +// CreateSyncedTableRequestToSDK converts the mirror to the sdk-go type. +func CreateSyncedTableRequestToSDK(w *CreateSyncedTableRequest) (*sdk.CreateSyncedTableRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateSyncedTableRequest{} + out.SyncedTableId = w.SyncedTableId + conv27, err := SyncedTableToSDK(w.SyncedTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSyncedTableRequest.SyncedTable", err) + } + out.SyncedTable = conv27 + return out, nil +} + +// CreateSyncedTableRequestFromSDK converts the sdk-go type to the mirror. +func CreateSyncedTableRequestFromSDK(v *sdk.CreateSyncedTableRequest) (*CreateSyncedTableRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateSyncedTableRequest{} + out.SyncedTableId = v.SyncedTableId + conv28, err := SyncedTableFromSDK(v.SyncedTable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSyncedTableRequest.SyncedTable", err) + } + out.SyncedTable = conv28 + return out, nil +} + +// DailyScheduleToSDK converts the mirror to the sdk-go type. +func DailyScheduleToSDK(w *DailySchedule) (*sdk.DailySchedule, error) { + if w == nil { + return nil, nil + } + out := &sdk.DailySchedule{} + out.Hour = w.Hour + return out, nil +} + +// DailyScheduleFromSDK converts the sdk-go type to the mirror. +func DailyScheduleFromSDK(v *sdk.DailySchedule) (*DailySchedule, error) { + if v == nil { + return nil, nil + } + out := &DailySchedule{} + out.Hour = v.Hour + return out, nil +} + +// DataApiToSDK converts the mirror to the sdk-go type. +func DataApiToSDK(w *DataApi) (*sdk.DataApi, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataApi{} + out.Name = w.Name + out.Parent = w.Parent + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + conv29, err := DataApi_DataApiSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataApi.Spec", err) + } + out.Spec = conv29 + conv30, err := DataApi_DataApiStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataApi.Status", err) + } + out.Status = conv30 + return out, nil +} + +// DataApiFromSDK converts the sdk-go type to the mirror. +func DataApiFromSDK(v *sdk.DataApi) (*DataApi, error) { + if v == nil { + return nil, nil + } + out := &DataApi{} + out.Name = v.Name + out.Parent = v.Parent + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + conv31, err := DataApi_DataApiSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataApi.Spec", err) + } + out.Spec = conv31 + conv32, err := DataApi_DataApiStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DataApi.Status", err) + } + out.Status = conv32 + return out, nil +} + +// DataApiOperationMetadataToSDK converts the mirror to the sdk-go type. +func DataApiOperationMetadataToSDK(w *DataApiOperationMetadata) (*sdk.DataApiOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataApiOperationMetadata{} + return out, nil +} + +// DataApiOperationMetadataFromSDK converts the sdk-go type to the mirror. +func DataApiOperationMetadataFromSDK(v *sdk.DataApiOperationMetadata) (*DataApiOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &DataApiOperationMetadata{} + return out, nil +} + +// DataApi_DataApiSpecToSDK converts the mirror to the sdk-go type. +func DataApi_DataApiSpecToSDK(w *DataApi_DataApiSpec) (*sdk.DataApi_DataApiSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataApi_DataApiSpec{} + out.DbAggregatesEnabled = w.DbAggregatesEnabled + out.DbExtraSearchPath = w.DbExtraSearchPath + out.DbMaxRows = w.DbMaxRows + out.DbSchemas = w.DbSchemas + out.JwtRoleClaimKey = w.JwtRoleClaimKey + out.JwtCacheMaxLifetime = w.JwtCacheMaxLifetime + out.OpenapiMode = w.OpenapiMode + out.ServerCorsAllowedOrigins = w.ServerCorsAllowedOrigins + out.ServerTimingEnabled = w.ServerTimingEnabled + return out, nil +} + +// DataApi_DataApiSpecFromSDK converts the sdk-go type to the mirror. +func DataApi_DataApiSpecFromSDK(v *sdk.DataApi_DataApiSpec) (*DataApi_DataApiSpec, error) { + if v == nil { + return nil, nil + } + out := &DataApi_DataApiSpec{} + out.DbAggregatesEnabled = v.DbAggregatesEnabled + out.DbExtraSearchPath = v.DbExtraSearchPath + out.DbMaxRows = v.DbMaxRows + out.DbSchemas = v.DbSchemas + out.JwtRoleClaimKey = v.JwtRoleClaimKey + out.JwtCacheMaxLifetime = v.JwtCacheMaxLifetime + out.OpenapiMode = v.OpenapiMode + out.ServerCorsAllowedOrigins = v.ServerCorsAllowedOrigins + out.ServerTimingEnabled = v.ServerTimingEnabled + return out, nil +} + +// DataApi_DataApiStatusToSDK converts the mirror to the sdk-go type. +func DataApi_DataApiStatusToSDK(w *DataApi_DataApiStatus) (*sdk.DataApi_DataApiStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.DataApi_DataApiStatus{} + out.DbAggregatesEnabled = w.DbAggregatesEnabled + out.DbExtraSearchPath = w.DbExtraSearchPath + out.DbMaxRows = w.DbMaxRows + out.DbSchemas = w.DbSchemas + out.JwtRoleClaimKey = w.JwtRoleClaimKey + out.JwtCacheMaxLifetime = w.JwtCacheMaxLifetime + out.OpenapiMode = w.OpenapiMode + out.ServerCorsAllowedOrigins = w.ServerCorsAllowedOrigins + out.ServerTimingEnabled = w.ServerTimingEnabled + out.Url = w.Url + out.AvailableSchemas = w.AvailableSchemas + return out, nil +} + +// DataApi_DataApiStatusFromSDK converts the sdk-go type to the mirror. +func DataApi_DataApiStatusFromSDK(v *sdk.DataApi_DataApiStatus) (*DataApi_DataApiStatus, error) { + if v == nil { + return nil, nil + } + out := &DataApi_DataApiStatus{} + out.DbAggregatesEnabled = v.DbAggregatesEnabled + out.DbExtraSearchPath = v.DbExtraSearchPath + out.DbMaxRows = v.DbMaxRows + out.DbSchemas = v.DbSchemas + out.JwtRoleClaimKey = v.JwtRoleClaimKey + out.JwtCacheMaxLifetime = v.JwtCacheMaxLifetime + out.OpenapiMode = v.OpenapiMode + out.ServerCorsAllowedOrigins = v.ServerCorsAllowedOrigins + out.ServerTimingEnabled = v.ServerTimingEnabled + out.Url = v.Url + out.AvailableSchemas = v.AvailableSchemas + return out, nil +} + +// DatabaseToSDK converts the mirror to the sdk-go type. +func DatabaseToSDK(w *Database) (*sdk.Database, error) { + if w == nil { + return nil, nil + } + out := &sdk.Database{} + out.Name = w.Name + out.Parent = w.Parent + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + conv33, err := Database_DatabaseSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Database.Spec", err) + } + out.Spec = conv33 + conv34, err := Database_DatabaseStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Database.Status", err) + } + out.Status = conv34 + out.DatabaseId = w.DatabaseId + return out, nil +} + +// DatabaseFromSDK converts the sdk-go type to the mirror. +func DatabaseFromSDK(v *sdk.Database) (*Database, error) { + if v == nil { + return nil, nil + } + out := &Database{} + out.Name = v.Name + out.Parent = v.Parent + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + conv35, err := Database_DatabaseSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Database.Spec", err) + } + out.Spec = conv35 + conv36, err := Database_DatabaseStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Database.Status", err) + } + out.Status = conv36 + out.DatabaseId = v.DatabaseId + return out, nil +} + +// DatabaseCredentialToSDK converts the mirror to the sdk-go type. +func DatabaseCredentialToSDK(w *DatabaseCredential) (*sdk.DatabaseCredential, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabaseCredential{} + out.Token = w.Token + out.ExpireTime = w.ExpireTime + return out, nil +} + +// DatabaseCredentialFromSDK converts the sdk-go type to the mirror. +func DatabaseCredentialFromSDK(v *sdk.DatabaseCredential) (*DatabaseCredential, error) { + if v == nil { + return nil, nil + } + out := &DatabaseCredential{} + out.Token = v.Token + out.ExpireTime = v.ExpireTime + return out, nil +} + +// DatabaseOperationMetadataToSDK converts the mirror to the sdk-go type. +func DatabaseOperationMetadataToSDK(w *DatabaseOperationMetadata) (*sdk.DatabaseOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabaseOperationMetadata{} + return out, nil +} + +// DatabaseOperationMetadataFromSDK converts the sdk-go type to the mirror. +func DatabaseOperationMetadataFromSDK(v *sdk.DatabaseOperationMetadata) (*DatabaseOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &DatabaseOperationMetadata{} + return out, nil +} + +// Database_DatabaseSpecToSDK converts the mirror to the sdk-go type. +func Database_DatabaseSpecToSDK(w *Database_DatabaseSpec) (*sdk.Database_DatabaseSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.Database_DatabaseSpec{} + out.Role = w.Role + out.PostgresDatabase = w.PostgresDatabase + return out, nil +} + +// Database_DatabaseSpecFromSDK converts the sdk-go type to the mirror. +func Database_DatabaseSpecFromSDK(v *sdk.Database_DatabaseSpec) (*Database_DatabaseSpec, error) { + if v == nil { + return nil, nil + } + out := &Database_DatabaseSpec{} + out.Role = v.Role + out.PostgresDatabase = v.PostgresDatabase + return out, nil +} + +// Database_DatabaseStatusToSDK converts the mirror to the sdk-go type. +func Database_DatabaseStatusToSDK(w *Database_DatabaseStatus) (*sdk.Database_DatabaseStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.Database_DatabaseStatus{} + out.Role = w.Role + out.PostgresDatabase = w.PostgresDatabase + out.DatabaseId = w.DatabaseId + return out, nil +} + +// Database_DatabaseStatusFromSDK converts the sdk-go type to the mirror. +func Database_DatabaseStatusFromSDK(v *sdk.Database_DatabaseStatus) (*Database_DatabaseStatus, error) { + if v == nil { + return nil, nil + } + out := &Database_DatabaseStatus{} + out.Role = v.Role + out.PostgresDatabase = v.PostgresDatabase + out.DatabaseId = v.DatabaseId + return out, nil +} + +// DeleteBranchRequestToSDK converts the mirror to the sdk-go type. +func DeleteBranchRequestToSDK(w *DeleteBranchRequest) (*sdk.DeleteBranchRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteBranchRequest{} + out.Name = w.Name + out.Purge = w.Purge + return out, nil +} + +// DeleteBranchRequestFromSDK converts the sdk-go type to the mirror. +func DeleteBranchRequestFromSDK(v *sdk.DeleteBranchRequest) (*DeleteBranchRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteBranchRequest{} + out.Name = v.Name + out.Purge = v.Purge + return out, nil +} + +// DeleteCdfConfigRequestToSDK converts the mirror to the sdk-go type. +func DeleteCdfConfigRequestToSDK(w *DeleteCdfConfigRequest) (*sdk.DeleteCdfConfigRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteCdfConfigRequest{} + out.Name = w.Name + out.Force = w.Force + return out, nil +} + +// DeleteCdfConfigRequestFromSDK converts the sdk-go type to the mirror. +func DeleteCdfConfigRequestFromSDK(v *sdk.DeleteCdfConfigRequest) (*DeleteCdfConfigRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteCdfConfigRequest{} + out.Name = v.Name + out.Force = v.Force + return out, nil +} + +// DeleteProjectRequestToSDK converts the mirror to the sdk-go type. +func DeleteProjectRequestToSDK(w *DeleteProjectRequest) (*sdk.DeleteProjectRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteProjectRequest{} + out.Name = w.Name + out.Purge = w.Purge + return out, nil +} + +// DeleteProjectRequestFromSDK converts the sdk-go type to the mirror. +func DeleteProjectRequestFromSDK(v *sdk.DeleteProjectRequest) (*DeleteProjectRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteProjectRequest{} + out.Name = v.Name + out.Purge = v.Purge + return out, nil +} + +// DeleteRoleRequestToSDK converts the mirror to the sdk-go type. +func DeleteRoleRequestToSDK(w *DeleteRoleRequest) (*sdk.DeleteRoleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteRoleRequest{} + out.Name = w.Name + out.ReassignOwnedTo = w.ReassignOwnedTo + return out, nil +} + +// DeleteRoleRequestFromSDK converts the sdk-go type to the mirror. +func DeleteRoleRequestFromSDK(v *sdk.DeleteRoleRequest) (*DeleteRoleRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteRoleRequest{} + out.Name = v.Name + out.ReassignOwnedTo = v.ReassignOwnedTo + return out, nil +} + +// DeltaTableSyncInfoToSDK converts the mirror to the sdk-go type. +func DeltaTableSyncInfoToSDK(w *DeltaTableSyncInfo) (*sdk.DeltaTableSyncInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeltaTableSyncInfo{} + out.DeltaCommitVersion = w.DeltaCommitVersion + out.DeltaCommitTime = w.DeltaCommitTime + return out, nil +} + +// DeltaTableSyncInfoFromSDK converts the sdk-go type to the mirror. +func DeltaTableSyncInfoFromSDK(v *sdk.DeltaTableSyncInfo) (*DeltaTableSyncInfo, error) { + if v == nil { + return nil, nil + } + out := &DeltaTableSyncInfo{} + out.DeltaCommitVersion = v.DeltaCommitVersion + out.DeltaCommitTime = v.DeltaCommitTime + return out, nil +} + +// EndpointToSDK converts the mirror to the sdk-go type. +func EndpointToSDK(w *Endpoint) (*sdk.Endpoint, error) { + if w == nil { + return nil, nil + } + out := &sdk.Endpoint{} + out.Name = w.Name + out.Uid = w.Uid + out.Parent = w.Parent + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + conv37, err := EndpointSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.Spec", err) + } + out.Spec = conv37 + conv38, err := EndpointStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.Status", err) + } + out.Status = conv38 + out.EndpointId = w.EndpointId + return out, nil +} + +// EndpointFromSDK converts the sdk-go type to the mirror. +func EndpointFromSDK(v *sdk.Endpoint) (*Endpoint, error) { + if v == nil { + return nil, nil + } + out := &Endpoint{} + out.Name = v.Name + out.Uid = v.Uid + out.Parent = v.Parent + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + conv39, err := EndpointSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.Spec", err) + } + out.Spec = conv39 + conv40, err := EndpointStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.Status", err) + } + out.Status = conv40 + out.EndpointId = v.EndpointId + return out, nil +} + +// EndpointGroupSpecToSDK converts the mirror to the sdk-go type. +func EndpointGroupSpecToSDK(w *EndpointGroupSpec) (*sdk.EndpointGroupSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointGroupSpec{} + out.Min = w.Min + out.Max = w.Max + out.EnableReadableSecondaries = w.EnableReadableSecondaries + return out, nil +} + +// EndpointGroupSpecFromSDK converts the sdk-go type to the mirror. +func EndpointGroupSpecFromSDK(v *sdk.EndpointGroupSpec) (*EndpointGroupSpec, error) { + if v == nil { + return nil, nil + } + out := &EndpointGroupSpec{} + out.Min = v.Min + out.Max = v.Max + out.EnableReadableSecondaries = v.EnableReadableSecondaries + return out, nil +} + +// EndpointGroupStatusToSDK converts the mirror to the sdk-go type. +func EndpointGroupStatusToSDK(w *EndpointGroupStatus) (*sdk.EndpointGroupStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointGroupStatus{} + out.Min = w.Min + out.Max = w.Max + out.EnableReadableSecondaries = w.EnableReadableSecondaries + return out, nil +} + +// EndpointGroupStatusFromSDK converts the sdk-go type to the mirror. +func EndpointGroupStatusFromSDK(v *sdk.EndpointGroupStatus) (*EndpointGroupStatus, error) { + if v == nil { + return nil, nil + } + out := &EndpointGroupStatus{} + out.Min = v.Min + out.Max = v.Max + out.EnableReadableSecondaries = v.EnableReadableSecondaries + return out, nil +} + +// EndpointHostsToSDK converts the mirror to the sdk-go type. +func EndpointHostsToSDK(w *EndpointHosts) (*sdk.EndpointHosts, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointHosts{} + out.Host = w.Host + out.ReadOnlyHost = w.ReadOnlyHost + out.ReadWritePooledHost = w.ReadWritePooledHost + out.ReadOnlyPooledHost = w.ReadOnlyPooledHost + return out, nil +} + +// EndpointHostsFromSDK converts the sdk-go type to the mirror. +func EndpointHostsFromSDK(v *sdk.EndpointHosts) (*EndpointHosts, error) { + if v == nil { + return nil, nil + } + out := &EndpointHosts{} + out.Host = v.Host + out.ReadOnlyHost = v.ReadOnlyHost + out.ReadWritePooledHost = v.ReadWritePooledHost + out.ReadOnlyPooledHost = v.ReadOnlyPooledHost + return out, nil +} + +// EndpointOperationMetadataToSDK converts the mirror to the sdk-go type. +func EndpointOperationMetadataToSDK(w *EndpointOperationMetadata) (*sdk.EndpointOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointOperationMetadata{} + return out, nil +} + +// EndpointOperationMetadataFromSDK converts the sdk-go type to the mirror. +func EndpointOperationMetadataFromSDK(v *sdk.EndpointOperationMetadata) (*EndpointOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &EndpointOperationMetadata{} + return out, nil +} + +// EndpointSettingsToSDK converts the mirror to the sdk-go type. +func EndpointSettingsToSDK(w *EndpointSettings) (*sdk.EndpointSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointSettings{} + out.PgSettings = w.PgSettings + return out, nil +} + +// EndpointSettingsFromSDK converts the sdk-go type to the mirror. +func EndpointSettingsFromSDK(v *sdk.EndpointSettings) (*EndpointSettings, error) { + if v == nil { + return nil, nil + } + out := &EndpointSettings{} + out.PgSettings = v.PgSettings + return out, nil +} + +// EndpointSpecToSDK converts the mirror to the sdk-go type. +func EndpointSpecToSDK(w *EndpointSpec) (*sdk.EndpointSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointSpec{} + out.EndpointType = w.EndpointType + out.AutoscalingLimitMinCu = w.AutoscalingLimitMinCu + out.AutoscalingLimitMaxCu = w.AutoscalingLimitMaxCu + out.Disabled = w.Disabled + { + var members []string + if w.SuspendTimeoutDuration != nil { + members = append(members, "suspend_timeout_duration") + } + if w.NoSuspension != nil { + members = append(members, "no_suspension") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.SuspendTimeoutDuration != nil: + out.Suspension = &sdk.EndpointSpec_Suspension_SuspendTimeoutDuration{SuspendTimeoutDuration: *w.SuspendTimeoutDuration} + case w.NoSuspension != nil: + out.Suspension = &sdk.EndpointSpec_Suspension_NoSuspension{NoSuspension: *w.NoSuspension} + } + conv41, err := EndpointSettingsToSDK(w.Settings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointSpec.Settings", err) + } + out.Settings = conv41 + conv42, err := EndpointGroupSpecToSDK(w.Group) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointSpec.Group", err) + } + out.Group = conv42 + return out, nil +} + +// EndpointSpecFromSDK converts the sdk-go type to the mirror. +func EndpointSpecFromSDK(v *sdk.EndpointSpec) (*EndpointSpec, error) { + if v == nil { + return nil, nil + } + out := &EndpointSpec{} + out.EndpointType = v.EndpointType + out.AutoscalingLimitMinCu = v.AutoscalingLimitMinCu + out.AutoscalingLimitMaxCu = v.AutoscalingLimitMaxCu + out.Disabled = v.Disabled + switch value := v.Suspension.(type) { + case *sdk.EndpointSpec_Suspension_SuspendTimeoutDuration: + if value != nil { + out.SuspendTimeoutDuration = new(value.SuspendTimeoutDuration) + } + case *sdk.EndpointSpec_Suspension_NoSuspension: + if value != nil { + out.NoSuspension = new(value.NoSuspension) + } + } + conv43, err := EndpointSettingsFromSDK(v.Settings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointSpec.Settings", err) + } + out.Settings = conv43 + conv44, err := EndpointGroupSpecFromSDK(v.Group) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointSpec.Group", err) + } + out.Group = conv44 + return out, nil +} + +// EndpointStatusToSDK converts the mirror to the sdk-go type. +func EndpointStatusToSDK(w *EndpointStatus) (*sdk.EndpointStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointStatus{} + out.EndpointType = w.EndpointType + conv45, err := EndpointHostsToSDK(w.Hosts) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointStatus.Hosts", err) + } + out.Hosts = conv45 + out.LastActiveTime = w.LastActiveTime + out.AutoscalingLimitMinCu = w.AutoscalingLimitMinCu + out.AutoscalingLimitMaxCu = w.AutoscalingLimitMaxCu + out.CurrentState = w.CurrentState + out.PendingState = w.PendingState + out.Disabled = w.Disabled + out.SuspendTimeoutDuration = w.SuspendTimeoutDuration + conv46, err := EndpointSettingsToSDK(w.Settings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointStatus.Settings", err) + } + out.Settings = conv46 + conv47, err := EndpointGroupStatusToSDK(w.Group) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointStatus.Group", err) + } + out.Group = conv47 + out.EndpointId = w.EndpointId + return out, nil +} + +// EndpointStatusFromSDK converts the sdk-go type to the mirror. +func EndpointStatusFromSDK(v *sdk.EndpointStatus) (*EndpointStatus, error) { + if v == nil { + return nil, nil + } + out := &EndpointStatus{} + out.EndpointType = v.EndpointType + conv48, err := EndpointHostsFromSDK(v.Hosts) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointStatus.Hosts", err) + } + out.Hosts = conv48 + out.LastActiveTime = v.LastActiveTime + out.AutoscalingLimitMinCu = v.AutoscalingLimitMinCu + out.AutoscalingLimitMaxCu = v.AutoscalingLimitMaxCu + out.CurrentState = v.CurrentState + out.PendingState = v.PendingState + out.Disabled = v.Disabled + out.SuspendTimeoutDuration = v.SuspendTimeoutDuration + conv49, err := EndpointSettingsFromSDK(v.Settings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointStatus.Settings", err) + } + out.Settings = conv49 + conv50, err := EndpointGroupStatusFromSDK(v.Group) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointStatus.Group", err) + } + out.Group = conv50 + out.EndpointId = v.EndpointId + return out, nil +} + +// GenerateDatabaseCredentialRequestToSDK converts the mirror to the sdk-go type. +func GenerateDatabaseCredentialRequestToSDK(w *GenerateDatabaseCredentialRequest) (*sdk.GenerateDatabaseCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenerateDatabaseCredentialRequest{} + conv51, err := convertSlice(w.Claims, RequestedClaimsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateDatabaseCredentialRequest.Claims", err) + } + out.Claims = conv51 + out.Endpoint = w.Endpoint + { + var members []string + if w.Ttl != nil { + members = append(members, "ttl") + } + if w.ExpireTime != nil { + members = append(members, "expire_time") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Ttl != nil: + out.Expiration = &sdk.GenerateDatabaseCredentialRequest_Expiration_Ttl{Ttl: *w.Ttl} + case w.ExpireTime != nil: + out.Expiration = &sdk.GenerateDatabaseCredentialRequest_Expiration_ExpireTime{ExpireTime: *w.ExpireTime} + } + return out, nil +} + +// GenerateDatabaseCredentialRequestFromSDK converts the sdk-go type to the mirror. +func GenerateDatabaseCredentialRequestFromSDK(v *sdk.GenerateDatabaseCredentialRequest) (*GenerateDatabaseCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &GenerateDatabaseCredentialRequest{} + conv52, err := convertSlice(v.Claims, RequestedClaimsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateDatabaseCredentialRequest.Claims", err) + } + out.Claims = conv52 + out.Endpoint = v.Endpoint + switch value := v.Expiration.(type) { + case *sdk.GenerateDatabaseCredentialRequest_Expiration_Ttl: + if value != nil { + out.Ttl = new(value.Ttl) + } + case *sdk.GenerateDatabaseCredentialRequest_Expiration_ExpireTime: + if value != nil { + out.ExpireTime = new(value.ExpireTime) + } + } + return out, nil +} + +// InitialBranchSpecToSDK converts the mirror to the sdk-go type. +func InitialBranchSpecToSDK(w *InitialBranchSpec) (*sdk.InitialBranchSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.InitialBranchSpec{} + out.IsProtected = w.IsProtected + return out, nil +} + +// InitialBranchSpecFromSDK converts the sdk-go type to the mirror. +func InitialBranchSpecFromSDK(v *sdk.InitialBranchSpec) (*InitialBranchSpec, error) { + if v == nil { + return nil, nil + } + out := &InitialBranchSpec{} + out.IsProtected = v.IsProtected + return out, nil +} + +// InitialEndpointSpecToSDK converts the mirror to the sdk-go type. +func InitialEndpointSpecToSDK(w *InitialEndpointSpec) (*sdk.InitialEndpointSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.InitialEndpointSpec{} + conv53, err := EndpointGroupSpecToSDK(w.Group) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitialEndpointSpec.Group", err) + } + out.Group = conv53 + out.AutoscalingLimitMinCu = w.AutoscalingLimitMinCu + out.AutoscalingLimitMaxCu = w.AutoscalingLimitMaxCu + { + var members []string + if w.SuspendTimeoutDuration != nil { + members = append(members, "suspend_timeout_duration") + } + if w.NoSuspension != nil { + members = append(members, "no_suspension") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.SuspendTimeoutDuration != nil: + out.Suspension = &sdk.InitialEndpointSpec_Suspension_SuspendTimeoutDuration{SuspendTimeoutDuration: *w.SuspendTimeoutDuration} + case w.NoSuspension != nil: + out.Suspension = &sdk.InitialEndpointSpec_Suspension_NoSuspension{NoSuspension: *w.NoSuspension} + } + return out, nil +} + +// InitialEndpointSpecFromSDK converts the sdk-go type to the mirror. +func InitialEndpointSpecFromSDK(v *sdk.InitialEndpointSpec) (*InitialEndpointSpec, error) { + if v == nil { + return nil, nil + } + out := &InitialEndpointSpec{} + conv54, err := EndpointGroupSpecFromSDK(v.Group) + if err != nil { + return nil, fmt.Errorf("%s: %w", "InitialEndpointSpec.Group", err) + } + out.Group = conv54 + out.AutoscalingLimitMinCu = v.AutoscalingLimitMinCu + out.AutoscalingLimitMaxCu = v.AutoscalingLimitMaxCu + switch value := v.Suspension.(type) { + case *sdk.InitialEndpointSpec_Suspension_SuspendTimeoutDuration: + if value != nil { + out.SuspendTimeoutDuration = new(value.SuspendTimeoutDuration) + } + case *sdk.InitialEndpointSpec_Suspension_NoSuspension: + if value != nil { + out.NoSuspension = new(value.NoSuspension) + } + } + return out, nil +} + +// ListBranchesRequestToSDK converts the mirror to the sdk-go type. +func ListBranchesRequestToSDK(w *ListBranchesRequest) (*sdk.ListBranchesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListBranchesRequest{} + out.Parent = w.Parent + out.PageToken = w.PageToken + out.PageSize = w.PageSize + out.ShowDeleted = w.ShowDeleted + return out, nil +} + +// ListBranchesRequestFromSDK converts the sdk-go type to the mirror. +func ListBranchesRequestFromSDK(v *sdk.ListBranchesRequest) (*ListBranchesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListBranchesRequest{} + out.Parent = v.Parent + out.PageToken = v.PageToken + out.PageSize = v.PageSize + out.ShowDeleted = v.ShowDeleted + return out, nil +} + +// ListBranchesResponseToSDK converts the mirror to the sdk-go type. +func ListBranchesResponseToSDK(w *ListBranchesResponse) (*sdk.ListBranchesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListBranchesResponse{} + conv55, err := convertSlice(w.Branches, BranchToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListBranchesResponse.Branches", err) + } + out.Branches = conv55 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListBranchesResponseFromSDK converts the sdk-go type to the mirror. +func ListBranchesResponseFromSDK(v *sdk.ListBranchesResponse) (*ListBranchesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListBranchesResponse{} + conv56, err := convertSlice(v.Branches, BranchFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListBranchesResponse.Branches", err) + } + out.Branches = conv56 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListCdfConfigsRequestToSDK converts the mirror to the sdk-go type. +func ListCdfConfigsRequestToSDK(w *ListCdfConfigsRequest) (*sdk.ListCdfConfigsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCdfConfigsRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListCdfConfigsRequestFromSDK converts the sdk-go type to the mirror. +func ListCdfConfigsRequestFromSDK(v *sdk.ListCdfConfigsRequest) (*ListCdfConfigsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCdfConfigsRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListCdfConfigsResponseToSDK converts the mirror to the sdk-go type. +func ListCdfConfigsResponseToSDK(w *ListCdfConfigsResponse) (*sdk.ListCdfConfigsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCdfConfigsResponse{} + conv57, err := convertSlice(w.CdfConfigs, CdfConfigToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCdfConfigsResponse.CdfConfigs", err) + } + out.CdfConfigs = conv57 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCdfConfigsResponseFromSDK converts the sdk-go type to the mirror. +func ListCdfConfigsResponseFromSDK(v *sdk.ListCdfConfigsResponse) (*ListCdfConfigsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCdfConfigsResponse{} + conv58, err := convertSlice(v.CdfConfigs, CdfConfigFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCdfConfigsResponse.CdfConfigs", err) + } + out.CdfConfigs = conv58 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListCdfStatusesRequestToSDK converts the mirror to the sdk-go type. +func ListCdfStatusesRequestToSDK(w *ListCdfStatusesRequest) (*sdk.ListCdfStatusesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCdfStatusesRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListCdfStatusesRequestFromSDK converts the sdk-go type to the mirror. +func ListCdfStatusesRequestFromSDK(v *sdk.ListCdfStatusesRequest) (*ListCdfStatusesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCdfStatusesRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListCdfStatusesResponseToSDK converts the mirror to the sdk-go type. +func ListCdfStatusesResponseToSDK(w *ListCdfStatusesResponse) (*sdk.ListCdfStatusesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCdfStatusesResponse{} + conv59, err := convertSlice(w.CdfStatuses, CdfStatusToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCdfStatusesResponse.CdfStatuses", err) + } + out.CdfStatuses = conv59 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCdfStatusesResponseFromSDK converts the sdk-go type to the mirror. +func ListCdfStatusesResponseFromSDK(v *sdk.ListCdfStatusesResponse) (*ListCdfStatusesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCdfStatusesResponse{} + conv60, err := convertSlice(v.CdfStatuses, CdfStatusFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCdfStatusesResponse.CdfStatuses", err) + } + out.CdfStatuses = conv60 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListDatabasesRequestToSDK converts the mirror to the sdk-go type. +func ListDatabasesRequestToSDK(w *ListDatabasesRequest) (*sdk.ListDatabasesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDatabasesRequest{} + out.Parent = w.Parent + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListDatabasesRequestFromSDK converts the sdk-go type to the mirror. +func ListDatabasesRequestFromSDK(v *sdk.ListDatabasesRequest) (*ListDatabasesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListDatabasesRequest{} + out.Parent = v.Parent + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListDatabasesResponseToSDK converts the mirror to the sdk-go type. +func ListDatabasesResponseToSDK(w *ListDatabasesResponse) (*sdk.ListDatabasesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDatabasesResponse{} + conv61, err := convertSlice(w.Databases, DatabaseToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDatabasesResponse.Databases", err) + } + out.Databases = conv61 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListDatabasesResponseFromSDK converts the sdk-go type to the mirror. +func ListDatabasesResponseFromSDK(v *sdk.ListDatabasesResponse) (*ListDatabasesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListDatabasesResponse{} + conv62, err := convertSlice(v.Databases, DatabaseFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDatabasesResponse.Databases", err) + } + out.Databases = conv62 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListEndpointsRequestToSDK converts the mirror to the sdk-go type. +func ListEndpointsRequestToSDK(w *ListEndpointsRequest) (*sdk.ListEndpointsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEndpointsRequest{} + out.Parent = w.Parent + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListEndpointsRequestFromSDK converts the sdk-go type to the mirror. +func ListEndpointsRequestFromSDK(v *sdk.ListEndpointsRequest) (*ListEndpointsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListEndpointsRequest{} + out.Parent = v.Parent + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListEndpointsResponseToSDK converts the mirror to the sdk-go type. +func ListEndpointsResponseToSDK(w *ListEndpointsResponse) (*sdk.ListEndpointsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEndpointsResponse{} + conv63, err := convertSlice(w.Endpoints, EndpointToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListEndpointsResponse.Endpoints", err) + } + out.Endpoints = conv63 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListEndpointsResponseFromSDK converts the sdk-go type to the mirror. +func ListEndpointsResponseFromSDK(v *sdk.ListEndpointsResponse) (*ListEndpointsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListEndpointsResponse{} + conv64, err := convertSlice(v.Endpoints, EndpointFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListEndpointsResponse.Endpoints", err) + } + out.Endpoints = conv64 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListProjectsRequestToSDK converts the mirror to the sdk-go type. +func ListProjectsRequestToSDK(w *ListProjectsRequest) (*sdk.ListProjectsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListProjectsRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + out.ShowDeleted = w.ShowDeleted + return out, nil +} + +// ListProjectsRequestFromSDK converts the sdk-go type to the mirror. +func ListProjectsRequestFromSDK(v *sdk.ListProjectsRequest) (*ListProjectsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListProjectsRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + out.ShowDeleted = v.ShowDeleted + return out, nil +} + +// ListProjectsResponseToSDK converts the mirror to the sdk-go type. +func ListProjectsResponseToSDK(w *ListProjectsResponse) (*sdk.ListProjectsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListProjectsResponse{} + conv65, err := convertSlice(w.Projects, ProjectToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProjectsResponse.Projects", err) + } + out.Projects = conv65 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListProjectsResponseFromSDK converts the sdk-go type to the mirror. +func ListProjectsResponseFromSDK(v *sdk.ListProjectsResponse) (*ListProjectsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListProjectsResponse{} + conv66, err := convertSlice(v.Projects, ProjectFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProjectsResponse.Projects", err) + } + out.Projects = conv66 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListRolesRequestToSDK converts the mirror to the sdk-go type. +func ListRolesRequestToSDK(w *ListRolesRequest) (*sdk.ListRolesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRolesRequest{} + out.Parent = w.Parent + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListRolesRequestFromSDK converts the sdk-go type to the mirror. +func ListRolesRequestFromSDK(v *sdk.ListRolesRequest) (*ListRolesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListRolesRequest{} + out.Parent = v.Parent + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListRolesResponseToSDK converts the mirror to the sdk-go type. +func ListRolesResponseToSDK(w *ListRolesResponse) (*sdk.ListRolesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRolesResponse{} + conv67, err := convertSlice(w.Roles, RoleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRolesResponse.Roles", err) + } + out.Roles = conv67 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListRolesResponseFromSDK converts the sdk-go type to the mirror. +func ListRolesResponseFromSDK(v *sdk.ListRolesResponse) (*ListRolesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListRolesResponse{} + conv68, err := convertSlice(v.Roles, RoleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRolesResponse.Roles", err) + } + out.Roles = conv68 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListSnapshotsRequestToSDK converts the mirror to the sdk-go type. +func ListSnapshotsRequestToSDK(w *ListSnapshotsRequest) (*sdk.ListSnapshotsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSnapshotsRequest{} + out.Parent = w.Parent + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListSnapshotsRequestFromSDK converts the sdk-go type to the mirror. +func ListSnapshotsRequestFromSDK(v *sdk.ListSnapshotsRequest) (*ListSnapshotsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSnapshotsRequest{} + out.Parent = v.Parent + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListSnapshotsResponseToSDK converts the mirror to the sdk-go type. +func ListSnapshotsResponseToSDK(w *ListSnapshotsResponse) (*sdk.ListSnapshotsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSnapshotsResponse{} + conv69, err := convertSlice(w.Snapshots, SnapshotToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSnapshotsResponse.Snapshots", err) + } + out.Snapshots = conv69 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSnapshotsResponseFromSDK converts the sdk-go type to the mirror. +func ListSnapshotsResponseFromSDK(v *sdk.ListSnapshotsResponse) (*ListSnapshotsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSnapshotsResponse{} + conv70, err := convertSlice(v.Snapshots, SnapshotFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSnapshotsResponse.Snapshots", err) + } + out.Snapshots = conv70 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// MonthlyScheduleToSDK converts the mirror to the sdk-go type. +func MonthlyScheduleToSDK(w *MonthlySchedule) (*sdk.MonthlySchedule, error) { + if w == nil { + return nil, nil + } + out := &sdk.MonthlySchedule{} + out.Day = w.Day + out.Hour = w.Hour + return out, nil +} + +// MonthlyScheduleFromSDK converts the sdk-go type to the mirror. +func MonthlyScheduleFromSDK(v *sdk.MonthlySchedule) (*MonthlySchedule, error) { + if v == nil { + return nil, nil + } + out := &MonthlySchedule{} + out.Day = v.Day + out.Hour = v.Hour + return out, nil +} + +// NewPipelineSpecToSDK converts the mirror to the sdk-go type. +func NewPipelineSpecToSDK(w *NewPipelineSpec) (*sdk.NewPipelineSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.NewPipelineSpec{} + out.StorageCatalog = w.StorageCatalog + out.StorageSchema = w.StorageSchema + out.BudgetPolicyId = w.BudgetPolicyId + out.PipelineChannel = w.PipelineChannel + return out, nil +} + +// NewPipelineSpecFromSDK converts the sdk-go type to the mirror. +func NewPipelineSpecFromSDK(v *sdk.NewPipelineSpec) (*NewPipelineSpec, error) { + if v == nil { + return nil, nil + } + out := &NewPipelineSpec{} + out.StorageCatalog = v.StorageCatalog + out.StorageSchema = v.StorageSchema + out.BudgetPolicyId = v.BudgetPolicyId + out.PipelineChannel = v.PipelineChannel + return out, nil +} + +// OperationToSDK converts the mirror to the sdk-go type. +func OperationToSDK(w *Operation) (*sdk.Operation, error) { + if w == nil { + return nil, nil + } + out := &sdk.Operation{} + out.Name = w.Name + out.Metadata = w.Metadata + out.Done = w.Done + { + var members []string + if w.Error != nil { + members = append(members, "error") + } + if w.Response != nil { + members = append(members, "response") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Error != nil: + conv71, err := ApiErrorToSDK(w.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Operation.Result", err) + } + out.Result = &sdk.Operation_Result_Error{Error: *conv71} + case w.Response != nil: + out.Result = &sdk.Operation_Result_Response{Response: w.Response} + } + return out, nil +} + +// OperationFromSDK converts the sdk-go type to the mirror. +func OperationFromSDK(v *sdk.Operation) (*Operation, error) { + if v == nil { + return nil, nil + } + out := &Operation{} + out.Name = v.Name + out.Metadata = v.Metadata + out.Done = v.Done + switch value := v.Result.(type) { + case *sdk.Operation_Result_Error: + if value != nil { + conv72, err := ApiErrorFromSDK(&value.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Operation.Result", err) + } + out.Error = conv72 + } + case *sdk.Operation_Result_Response: + if value != nil { + out.Response = value.Response + } + } + return out, nil +} + +// ProjectToSDK converts the mirror to the sdk-go type. +func ProjectToSDK(w *Project) (*sdk.Project, error) { + if w == nil { + return nil, nil + } + out := &sdk.Project{} + out.Name = w.Name + out.Uid = w.Uid + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + conv73, err := ProjectSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Project.Spec", err) + } + out.Spec = conv73 + conv74, err := ProjectStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Project.Status", err) + } + out.Status = conv74 + conv75, err := InitialEndpointSpecToSDK(w.InitialEndpointSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Project.InitialEndpointSpec", err) + } + out.InitialEndpointSpec = conv75 + out.DeleteTime = w.DeleteTime + out.PurgeTime = w.PurgeTime + conv76, err := InitialBranchSpecToSDK(w.InitialBranchSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Project.InitialBranchSpec", err) + } + out.InitialBranchSpec = conv76 + out.ProjectId = w.ProjectId + return out, nil +} + +// ProjectFromSDK converts the sdk-go type to the mirror. +func ProjectFromSDK(v *sdk.Project) (*Project, error) { + if v == nil { + return nil, nil + } + out := &Project{} + out.Name = v.Name + out.Uid = v.Uid + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + conv77, err := ProjectSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Project.Spec", err) + } + out.Spec = conv77 + conv78, err := ProjectStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Project.Status", err) + } + out.Status = conv78 + conv79, err := InitialEndpointSpecFromSDK(v.InitialEndpointSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Project.InitialEndpointSpec", err) + } + out.InitialEndpointSpec = conv79 + out.DeleteTime = v.DeleteTime + out.PurgeTime = v.PurgeTime + conv80, err := InitialBranchSpecFromSDK(v.InitialBranchSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Project.InitialBranchSpec", err) + } + out.InitialBranchSpec = conv80 + out.ProjectId = v.ProjectId + return out, nil +} + +// ProjectCustomTagToSDK converts the mirror to the sdk-go type. +func ProjectCustomTagToSDK(w *ProjectCustomTag) (*sdk.ProjectCustomTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProjectCustomTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// ProjectCustomTagFromSDK converts the sdk-go type to the mirror. +func ProjectCustomTagFromSDK(v *sdk.ProjectCustomTag) (*ProjectCustomTag, error) { + if v == nil { + return nil, nil + } + out := &ProjectCustomTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// ProjectDefaultEndpointSettingsToSDK converts the mirror to the sdk-go type. +func ProjectDefaultEndpointSettingsToSDK(w *ProjectDefaultEndpointSettings) (*sdk.ProjectDefaultEndpointSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProjectDefaultEndpointSettings{} + out.AutoscalingLimitMinCu = w.AutoscalingLimitMinCu + out.AutoscalingLimitMaxCu = w.AutoscalingLimitMaxCu + { + var members []string + if w.SuspendTimeoutDuration != nil { + members = append(members, "suspend_timeout_duration") + } + if w.NoSuspension != nil { + members = append(members, "no_suspension") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.SuspendTimeoutDuration != nil: + out.Suspension = &sdk.ProjectDefaultEndpointSettings_Suspension_SuspendTimeoutDuration{SuspendTimeoutDuration: *w.SuspendTimeoutDuration} + case w.NoSuspension != nil: + out.Suspension = &sdk.ProjectDefaultEndpointSettings_Suspension_NoSuspension{NoSuspension: *w.NoSuspension} + } + out.PgSettings = w.PgSettings + return out, nil +} + +// ProjectDefaultEndpointSettingsFromSDK converts the sdk-go type to the mirror. +func ProjectDefaultEndpointSettingsFromSDK(v *sdk.ProjectDefaultEndpointSettings) (*ProjectDefaultEndpointSettings, error) { + if v == nil { + return nil, nil + } + out := &ProjectDefaultEndpointSettings{} + out.AutoscalingLimitMinCu = v.AutoscalingLimitMinCu + out.AutoscalingLimitMaxCu = v.AutoscalingLimitMaxCu + switch value := v.Suspension.(type) { + case *sdk.ProjectDefaultEndpointSettings_Suspension_SuspendTimeoutDuration: + if value != nil { + out.SuspendTimeoutDuration = new(value.SuspendTimeoutDuration) + } + case *sdk.ProjectDefaultEndpointSettings_Suspension_NoSuspension: + if value != nil { + out.NoSuspension = new(value.NoSuspension) + } + } + out.PgSettings = v.PgSettings + return out, nil +} + +// ProjectOperationMetadataToSDK converts the mirror to the sdk-go type. +func ProjectOperationMetadataToSDK(w *ProjectOperationMetadata) (*sdk.ProjectOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProjectOperationMetadata{} + return out, nil +} + +// ProjectOperationMetadataFromSDK converts the sdk-go type to the mirror. +func ProjectOperationMetadataFromSDK(v *sdk.ProjectOperationMetadata) (*ProjectOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &ProjectOperationMetadata{} + return out, nil +} + +// ProjectSpecToSDK converts the mirror to the sdk-go type. +func ProjectSpecToSDK(w *ProjectSpec) (*sdk.ProjectSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProjectSpec{} + out.DisplayName = w.DisplayName + out.PgVersion = w.PgVersion + out.HistoryRetentionDuration = w.HistoryRetentionDuration + conv81, err := ProjectDefaultEndpointSettingsToSDK(w.DefaultEndpointSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProjectSpec.DefaultEndpointSettings", err) + } + out.DefaultEndpointSettings = conv81 + out.BudgetPolicyId = w.BudgetPolicyId + conv82, err := convertSlice(w.CustomTags, ProjectCustomTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProjectSpec.CustomTags", err) + } + out.CustomTags = conv82 + out.EnablePgNativeLogin = w.EnablePgNativeLogin + out.DefaultBranch = w.DefaultBranch + return out, nil +} + +// ProjectSpecFromSDK converts the sdk-go type to the mirror. +func ProjectSpecFromSDK(v *sdk.ProjectSpec) (*ProjectSpec, error) { + if v == nil { + return nil, nil + } + out := &ProjectSpec{} + out.DisplayName = v.DisplayName + out.PgVersion = v.PgVersion + out.HistoryRetentionDuration = v.HistoryRetentionDuration + conv83, err := ProjectDefaultEndpointSettingsFromSDK(v.DefaultEndpointSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProjectSpec.DefaultEndpointSettings", err) + } + out.DefaultEndpointSettings = conv83 + out.BudgetPolicyId = v.BudgetPolicyId + conv84, err := convertSlice(v.CustomTags, ProjectCustomTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProjectSpec.CustomTags", err) + } + out.CustomTags = conv84 + out.EnablePgNativeLogin = v.EnablePgNativeLogin + out.DefaultBranch = v.DefaultBranch + return out, nil +} + +// ProjectStatusToSDK converts the mirror to the sdk-go type. +func ProjectStatusToSDK(w *ProjectStatus) (*sdk.ProjectStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProjectStatus{} + out.DisplayName = w.DisplayName + out.PgVersion = w.PgVersion + out.HistoryRetentionDuration = w.HistoryRetentionDuration + conv85, err := ProjectDefaultEndpointSettingsToSDK(w.DefaultEndpointSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProjectStatus.DefaultEndpointSettings", err) + } + out.DefaultEndpointSettings = conv85 + out.BranchLogicalSizeLimitBytes = w.BranchLogicalSizeLimitBytes + out.SyntheticStorageSizeBytes = w.SyntheticStorageSizeBytes + out.ComputeLastActiveTime = w.ComputeLastActiveTime + out.BudgetPolicyId = w.BudgetPolicyId + conv86, err := convertSlice(w.CustomTags, ProjectCustomTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProjectStatus.CustomTags", err) + } + out.CustomTags = conv86 + out.Owner = w.Owner + out.EnablePgNativeLogin = w.EnablePgNativeLogin + out.DefaultBranch = w.DefaultBranch + out.ProjectId = w.ProjectId + return out, nil +} + +// ProjectStatusFromSDK converts the sdk-go type to the mirror. +func ProjectStatusFromSDK(v *sdk.ProjectStatus) (*ProjectStatus, error) { + if v == nil { + return nil, nil + } + out := &ProjectStatus{} + out.DisplayName = v.DisplayName + out.PgVersion = v.PgVersion + out.HistoryRetentionDuration = v.HistoryRetentionDuration + conv87, err := ProjectDefaultEndpointSettingsFromSDK(v.DefaultEndpointSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProjectStatus.DefaultEndpointSettings", err) + } + out.DefaultEndpointSettings = conv87 + out.BranchLogicalSizeLimitBytes = v.BranchLogicalSizeLimitBytes + out.SyntheticStorageSizeBytes = v.SyntheticStorageSizeBytes + out.ComputeLastActiveTime = v.ComputeLastActiveTime + out.BudgetPolicyId = v.BudgetPolicyId + conv88, err := convertSlice(v.CustomTags, ProjectCustomTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProjectStatus.CustomTags", err) + } + out.CustomTags = conv88 + out.Owner = v.Owner + out.EnablePgNativeLogin = v.EnablePgNativeLogin + out.DefaultBranch = v.DefaultBranch + out.ProjectId = v.ProjectId + return out, nil +} + +// RequestedClaimsToSDK converts the mirror to the sdk-go type. +func RequestedClaimsToSDK(w *RequestedClaims) (*sdk.RequestedClaims, error) { + if w == nil { + return nil, nil + } + out := &sdk.RequestedClaims{} + out.PermissionSet = w.PermissionSet + conv89, err := convertSlice(w.Resources, RequestedResourceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RequestedClaims.Resources", err) + } + out.Resources = conv89 + return out, nil +} + +// RequestedClaimsFromSDK converts the sdk-go type to the mirror. +func RequestedClaimsFromSDK(v *sdk.RequestedClaims) (*RequestedClaims, error) { + if v == nil { + return nil, nil + } + out := &RequestedClaims{} + out.PermissionSet = v.PermissionSet + conv90, err := convertSlice(v.Resources, RequestedResourceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RequestedClaims.Resources", err) + } + out.Resources = conv90 + return out, nil +} + +// RequestedResourceToSDK converts the mirror to the sdk-go type. +func RequestedResourceToSDK(w *RequestedResource) (*sdk.RequestedResource, error) { + if w == nil { + return nil, nil + } + out := &sdk.RequestedResource{} + { + var members []string + if w.TableName != nil { + members = append(members, "table_name") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.TableName != nil: + out.ResourceName = &sdk.RequestedResource_ResourceName_TableName{TableName: *w.TableName} + } + return out, nil +} + +// RequestedResourceFromSDK converts the sdk-go type to the mirror. +func RequestedResourceFromSDK(v *sdk.RequestedResource) (*RequestedResource, error) { + if v == nil { + return nil, nil + } + out := &RequestedResource{} + switch value := v.ResourceName.(type) { + case *sdk.RequestedResource_ResourceName_TableName: + if value != nil { + out.TableName = new(value.TableName) + } + } + return out, nil +} + +// RevealRolePasswordRequestToSDK converts the mirror to the sdk-go type. +func RevealRolePasswordRequestToSDK(w *RevealRolePasswordRequest) (*sdk.RevealRolePasswordRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RevealRolePasswordRequest{} + out.Name = w.Name + return out, nil +} + +// RevealRolePasswordRequestFromSDK converts the sdk-go type to the mirror. +func RevealRolePasswordRequestFromSDK(v *sdk.RevealRolePasswordRequest) (*RevealRolePasswordRequest, error) { + if v == nil { + return nil, nil + } + out := &RevealRolePasswordRequest{} + out.Name = v.Name + return out, nil +} + +// RevealRolePasswordResponseToSDK converts the mirror to the sdk-go type. +func RevealRolePasswordResponseToSDK(w *RevealRolePasswordResponse) (*sdk.RevealRolePasswordResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.RevealRolePasswordResponse{} + out.Password = w.Password + return out, nil +} + +// RevealRolePasswordResponseFromSDK converts the sdk-go type to the mirror. +func RevealRolePasswordResponseFromSDK(v *sdk.RevealRolePasswordResponse) (*RevealRolePasswordResponse, error) { + if v == nil { + return nil, nil + } + out := &RevealRolePasswordResponse{} + out.Password = v.Password + return out, nil +} + +// RoleToSDK converts the mirror to the sdk-go type. +func RoleToSDK(w *Role) (*sdk.Role, error) { + if w == nil { + return nil, nil + } + out := &sdk.Role{} + out.Name = w.Name + out.Parent = w.Parent + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + conv91, err := Role_RoleSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Role.Spec", err) + } + out.Spec = conv91 + conv92, err := Role_RoleStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Role.Status", err) + } + out.Status = conv92 + out.RoleId = w.RoleId + return out, nil +} + +// RoleFromSDK converts the sdk-go type to the mirror. +func RoleFromSDK(v *sdk.Role) (*Role, error) { + if v == nil { + return nil, nil + } + out := &Role{} + out.Name = v.Name + out.Parent = v.Parent + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + conv93, err := Role_RoleSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Role.Spec", err) + } + out.Spec = conv93 + conv94, err := Role_RoleStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Role.Status", err) + } + out.Status = conv94 + out.RoleId = v.RoleId + return out, nil +} + +// RoleOperationMetadataToSDK converts the mirror to the sdk-go type. +func RoleOperationMetadataToSDK(w *RoleOperationMetadata) (*sdk.RoleOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.RoleOperationMetadata{} + return out, nil +} + +// RoleOperationMetadataFromSDK converts the sdk-go type to the mirror. +func RoleOperationMetadataFromSDK(v *sdk.RoleOperationMetadata) (*RoleOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &RoleOperationMetadata{} + return out, nil +} + +// Role_AttributesToSDK converts the mirror to the sdk-go type. +func Role_AttributesToSDK(w *Role_Attributes) (*sdk.Role_Attributes, error) { + if w == nil { + return nil, nil + } + out := &sdk.Role_Attributes{} + out.Createdb = w.Createdb + out.Createrole = w.Createrole + out.Bypassrls = w.Bypassrls + return out, nil +} + +// Role_AttributesFromSDK converts the sdk-go type to the mirror. +func Role_AttributesFromSDK(v *sdk.Role_Attributes) (*Role_Attributes, error) { + if v == nil { + return nil, nil + } + out := &Role_Attributes{} + out.Createdb = v.Createdb + out.Createrole = v.Createrole + out.Bypassrls = v.Bypassrls + return out, nil +} + +// Role_RoleSpecToSDK converts the mirror to the sdk-go type. +func Role_RoleSpecToSDK(w *Role_RoleSpec) (*sdk.Role_RoleSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.Role_RoleSpec{} + out.MembershipRoles = w.MembershipRoles + out.IdentityType = w.IdentityType + conv95, err := Role_AttributesToSDK(w.Attributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Role_RoleSpec.Attributes", err) + } + out.Attributes = conv95 + out.AuthMethod = w.AuthMethod + out.PostgresRole = w.PostgresRole + return out, nil +} + +// Role_RoleSpecFromSDK converts the sdk-go type to the mirror. +func Role_RoleSpecFromSDK(v *sdk.Role_RoleSpec) (*Role_RoleSpec, error) { + if v == nil { + return nil, nil + } + out := &Role_RoleSpec{} + out.MembershipRoles = v.MembershipRoles + out.IdentityType = v.IdentityType + conv96, err := Role_AttributesFromSDK(v.Attributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Role_RoleSpec.Attributes", err) + } + out.Attributes = conv96 + out.AuthMethod = v.AuthMethod + out.PostgresRole = v.PostgresRole + return out, nil +} + +// Role_RoleStatusToSDK converts the mirror to the sdk-go type. +func Role_RoleStatusToSDK(w *Role_RoleStatus) (*sdk.Role_RoleStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.Role_RoleStatus{} + out.MembershipRoles = w.MembershipRoles + out.IdentityType = w.IdentityType + conv97, err := Role_AttributesToSDK(w.Attributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Role_RoleStatus.Attributes", err) + } + out.Attributes = conv97 + out.AuthMethod = w.AuthMethod + out.PostgresRole = w.PostgresRole + out.RoleId = w.RoleId + return out, nil +} + +// Role_RoleStatusFromSDK converts the sdk-go type to the mirror. +func Role_RoleStatusFromSDK(v *sdk.Role_RoleStatus) (*Role_RoleStatus, error) { + if v == nil { + return nil, nil + } + out := &Role_RoleStatus{} + out.MembershipRoles = v.MembershipRoles + out.IdentityType = v.IdentityType + conv98, err := Role_AttributesFromSDK(v.Attributes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Role_RoleStatus.Attributes", err) + } + out.Attributes = conv98 + out.AuthMethod = v.AuthMethod + out.PostgresRole = v.PostgresRole + out.RoleId = v.RoleId + return out, nil +} + +// ScheduleCadenceToSDK converts the mirror to the sdk-go type. +func ScheduleCadenceToSDK(w *ScheduleCadence) (*sdk.ScheduleCadence, error) { + if w == nil { + return nil, nil + } + out := &sdk.ScheduleCadence{} + { + var members []string + if w.DailySchedule != nil { + members = append(members, "daily_schedule") + } + if w.WeeklySchedule != nil { + members = append(members, "weekly_schedule") + } + if w.MonthlySchedule != nil { + members = append(members, "monthly_schedule") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DailySchedule != nil: + conv99, err := DailyScheduleToSDK(w.DailySchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ScheduleCadence.Schedule", err) + } + out.Schedule = &sdk.ScheduleCadence_Schedule_DailySchedule{DailySchedule: *conv99} + case w.WeeklySchedule != nil: + conv100, err := WeeklyScheduleToSDK(w.WeeklySchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ScheduleCadence.Schedule", err) + } + out.Schedule = &sdk.ScheduleCadence_Schedule_WeeklySchedule{WeeklySchedule: *conv100} + case w.MonthlySchedule != nil: + conv101, err := MonthlyScheduleToSDK(w.MonthlySchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ScheduleCadence.Schedule", err) + } + out.Schedule = &sdk.ScheduleCadence_Schedule_MonthlySchedule{MonthlySchedule: *conv101} + } + out.Retention = w.Retention + return out, nil +} + +// ScheduleCadenceFromSDK converts the sdk-go type to the mirror. +func ScheduleCadenceFromSDK(v *sdk.ScheduleCadence) (*ScheduleCadence, error) { + if v == nil { + return nil, nil + } + out := &ScheduleCadence{} + switch value := v.Schedule.(type) { + case *sdk.ScheduleCadence_Schedule_DailySchedule: + if value != nil { + conv102, err := DailyScheduleFromSDK(&value.DailySchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ScheduleCadence.Schedule", err) + } + out.DailySchedule = conv102 + } + case *sdk.ScheduleCadence_Schedule_WeeklySchedule: + if value != nil { + conv103, err := WeeklyScheduleFromSDK(&value.WeeklySchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ScheduleCadence.Schedule", err) + } + out.WeeklySchedule = conv103 + } + case *sdk.ScheduleCadence_Schedule_MonthlySchedule: + if value != nil { + conv104, err := MonthlyScheduleFromSDK(&value.MonthlySchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ScheduleCadence.Schedule", err) + } + out.MonthlySchedule = conv104 + } + } + out.Retention = v.Retention + return out, nil +} + +// SnapshotToSDK converts the mirror to the sdk-go type. +func SnapshotToSDK(w *Snapshot) (*sdk.Snapshot, error) { + if w == nil { + return nil, nil + } + out := &sdk.Snapshot{} + out.Name = w.Name + out.Uid = w.Uid + out.CreateTime = w.CreateTime + conv105, err := SnapshotSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Snapshot.Spec", err) + } + out.Spec = conv105 + conv106, err := SnapshotStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Snapshot.Status", err) + } + out.Status = conv106 + out.SnapshotId = w.SnapshotId + return out, nil +} + +// SnapshotFromSDK converts the sdk-go type to the mirror. +func SnapshotFromSDK(v *sdk.Snapshot) (*Snapshot, error) { + if v == nil { + return nil, nil + } + out := &Snapshot{} + out.Name = v.Name + out.Uid = v.Uid + out.CreateTime = v.CreateTime + conv107, err := SnapshotSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Snapshot.Spec", err) + } + out.Spec = conv107 + conv108, err := SnapshotStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Snapshot.Status", err) + } + out.Status = conv108 + out.SnapshotId = v.SnapshotId + return out, nil +} + +// SnapshotOperationMetadataToSDK converts the mirror to the sdk-go type. +func SnapshotOperationMetadataToSDK(w *SnapshotOperationMetadata) (*sdk.SnapshotOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.SnapshotOperationMetadata{} + return out, nil +} + +// SnapshotOperationMetadataFromSDK converts the sdk-go type to the mirror. +func SnapshotOperationMetadataFromSDK(v *sdk.SnapshotOperationMetadata) (*SnapshotOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &SnapshotOperationMetadata{} + return out, nil +} + +// SnapshotScheduleToSDK converts the mirror to the sdk-go type. +func SnapshotScheduleToSDK(w *SnapshotSchedule) (*sdk.SnapshotSchedule, error) { + if w == nil { + return nil, nil + } + out := &sdk.SnapshotSchedule{} + out.Name = w.Name + conv109, err := convertSlice(w.Schedule, ScheduleCadenceToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SnapshotSchedule.Schedule", err) + } + out.Schedule = conv109 + return out, nil +} + +// SnapshotScheduleFromSDK converts the sdk-go type to the mirror. +func SnapshotScheduleFromSDK(v *sdk.SnapshotSchedule) (*SnapshotSchedule, error) { + if v == nil { + return nil, nil + } + out := &SnapshotSchedule{} + out.Name = v.Name + conv110, err := convertSlice(v.Schedule, ScheduleCadenceFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SnapshotSchedule.Schedule", err) + } + out.Schedule = conv110 + return out, nil +} + +// SnapshotScheduleOperationMetadataToSDK converts the mirror to the sdk-go type. +func SnapshotScheduleOperationMetadataToSDK(w *SnapshotScheduleOperationMetadata) (*sdk.SnapshotScheduleOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.SnapshotScheduleOperationMetadata{} + return out, nil +} + +// SnapshotScheduleOperationMetadataFromSDK converts the sdk-go type to the mirror. +func SnapshotScheduleOperationMetadataFromSDK(v *sdk.SnapshotScheduleOperationMetadata) (*SnapshotScheduleOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &SnapshotScheduleOperationMetadata{} + return out, nil +} + +// SnapshotSpecToSDK converts the mirror to the sdk-go type. +func SnapshotSpecToSDK(w *SnapshotSpec) (*sdk.SnapshotSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.SnapshotSpec{} + out.SourceBranch = w.SourceBranch + { + var members []string + if w.SourceBranchLsn != nil { + members = append(members, "source_branch_lsn") + } + if w.SourceBranchTime != nil { + members = append(members, "source_branch_time") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.SourceBranchLsn != nil: + out.PointInTime = &sdk.SnapshotSpec_PointInTime_SourceBranchLsn{SourceBranchLsn: *w.SourceBranchLsn} + case w.SourceBranchTime != nil: + out.PointInTime = &sdk.SnapshotSpec_PointInTime_SourceBranchTime{SourceBranchTime: *w.SourceBranchTime} + } + { + var members []string + if w.ExpireTime != nil { + members = append(members, "expire_time") + } + if w.Ttl != nil { + members = append(members, "ttl") + } + if w.NoExpiry != nil { + members = append(members, "no_expiry") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ExpireTime != nil: + out.Expiration = &sdk.SnapshotSpec_Expiration_ExpireTime{ExpireTime: *w.ExpireTime} + case w.Ttl != nil: + out.Expiration = &sdk.SnapshotSpec_Expiration_Ttl{Ttl: *w.Ttl} + case w.NoExpiry != nil: + out.Expiration = &sdk.SnapshotSpec_Expiration_NoExpiry{NoExpiry: *w.NoExpiry} + } + return out, nil +} + +// SnapshotSpecFromSDK converts the sdk-go type to the mirror. +func SnapshotSpecFromSDK(v *sdk.SnapshotSpec) (*SnapshotSpec, error) { + if v == nil { + return nil, nil + } + out := &SnapshotSpec{} + out.SourceBranch = v.SourceBranch + switch value := v.PointInTime.(type) { + case *sdk.SnapshotSpec_PointInTime_SourceBranchLsn: + if value != nil { + out.SourceBranchLsn = new(value.SourceBranchLsn) + } + case *sdk.SnapshotSpec_PointInTime_SourceBranchTime: + if value != nil { + out.SourceBranchTime = new(value.SourceBranchTime) + } + } + switch value := v.Expiration.(type) { + case *sdk.SnapshotSpec_Expiration_ExpireTime: + if value != nil { + out.ExpireTime = new(value.ExpireTime) + } + case *sdk.SnapshotSpec_Expiration_Ttl: + if value != nil { + out.Ttl = new(value.Ttl) + } + case *sdk.SnapshotSpec_Expiration_NoExpiry: + if value != nil { + out.NoExpiry = new(value.NoExpiry) + } + } + return out, nil +} + +// SnapshotStatusToSDK converts the mirror to the sdk-go type. +func SnapshotStatusToSDK(w *SnapshotStatus) (*sdk.SnapshotStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.SnapshotStatus{} + out.SourceBranch = w.SourceBranch + { + var members []string + if w.ExpireTime != nil { + members = append(members, "expire_time") + } + if w.NoExpiry != nil { + members = append(members, "no_expiry") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ExpireTime != nil: + out.Expiration = &sdk.SnapshotStatus_Expiration_ExpireTime{ExpireTime: *w.ExpireTime} + case w.NoExpiry != nil: + out.Expiration = &sdk.SnapshotStatus_Expiration_NoExpiry{NoExpiry: *w.NoExpiry} + } + out.FullSizeBytes = w.FullSizeBytes + out.DiffSizeBytes = w.DiffSizeBytes + return out, nil +} + +// SnapshotStatusFromSDK converts the sdk-go type to the mirror. +func SnapshotStatusFromSDK(v *sdk.SnapshotStatus) (*SnapshotStatus, error) { + if v == nil { + return nil, nil + } + out := &SnapshotStatus{} + out.SourceBranch = v.SourceBranch + switch value := v.Expiration.(type) { + case *sdk.SnapshotStatus_Expiration_ExpireTime: + if value != nil { + out.ExpireTime = new(value.ExpireTime) + } + case *sdk.SnapshotStatus_Expiration_NoExpiry: + if value != nil { + out.NoExpiry = new(value.NoExpiry) + } + } + out.FullSizeBytes = v.FullSizeBytes + out.DiffSizeBytes = v.DiffSizeBytes + return out, nil +} + +// SyncedTableToSDK converts the mirror to the sdk-go type. +func SyncedTableToSDK(w *SyncedTable) (*sdk.SyncedTable, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTable{} + out.Name = w.Name + out.Uid = w.Uid + conv111, err := SyncedTable_SyncedTableSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable.Spec", err) + } + out.Spec = conv111 + conv112, err := SyncedTable_SyncedTableStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable.Status", err) + } + out.Status = conv112 + out.CreateTime = w.CreateTime + out.SyncedTableId = w.SyncedTableId + return out, nil +} + +// SyncedTableFromSDK converts the sdk-go type to the mirror. +func SyncedTableFromSDK(v *sdk.SyncedTable) (*SyncedTable, error) { + if v == nil { + return nil, nil + } + out := &SyncedTable{} + out.Name = v.Name + out.Uid = v.Uid + conv113, err := SyncedTable_SyncedTableSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable.Spec", err) + } + out.Spec = conv113 + conv114, err := SyncedTable_SyncedTableStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable.Status", err) + } + out.Status = conv114 + out.CreateTime = v.CreateTime + out.SyncedTableId = v.SyncedTableId + return out, nil +} + +// SyncedTableOperationMetadataToSDK converts the mirror to the sdk-go type. +func SyncedTableOperationMetadataToSDK(w *SyncedTableOperationMetadata) (*sdk.SyncedTableOperationMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTableOperationMetadata{} + return out, nil +} + +// SyncedTableOperationMetadataFromSDK converts the sdk-go type to the mirror. +func SyncedTableOperationMetadataFromSDK(v *sdk.SyncedTableOperationMetadata) (*SyncedTableOperationMetadata, error) { + if v == nil { + return nil, nil + } + out := &SyncedTableOperationMetadata{} + return out, nil +} + +// SyncedTablePipelineProgressToSDK converts the mirror to the sdk-go type. +func SyncedTablePipelineProgressToSDK(w *SyncedTablePipelineProgress) (*sdk.SyncedTablePipelineProgress, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTablePipelineProgress{} + out.LatestVersionCurrentlyProcessing = w.LatestVersionCurrentlyProcessing + out.SyncedRowCount = w.SyncedRowCount + out.TotalRowCount = w.TotalRowCount + out.SyncProgressCompletion = w.SyncProgressCompletion + out.EstimatedCompletionTimeSeconds = w.EstimatedCompletionTimeSeconds + return out, nil +} + +// SyncedTablePipelineProgressFromSDK converts the sdk-go type to the mirror. +func SyncedTablePipelineProgressFromSDK(v *sdk.SyncedTablePipelineProgress) (*SyncedTablePipelineProgress, error) { + if v == nil { + return nil, nil + } + out := &SyncedTablePipelineProgress{} + out.LatestVersionCurrentlyProcessing = v.LatestVersionCurrentlyProcessing + out.SyncedRowCount = v.SyncedRowCount + out.TotalRowCount = v.TotalRowCount + out.SyncProgressCompletion = v.SyncProgressCompletion + out.EstimatedCompletionTimeSeconds = v.EstimatedCompletionTimeSeconds + return out, nil +} + +// SyncedTablePositionToSDK converts the mirror to the sdk-go type. +func SyncedTablePositionToSDK(w *SyncedTablePosition) (*sdk.SyncedTablePosition, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTablePosition{} + out.SyncStartTime = w.SyncStartTime + out.SyncEndTime = w.SyncEndTime + { + var members []string + if w.DeltaTableSyncInfo != nil { + members = append(members, "delta_table_sync_info") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DeltaTableSyncInfo != nil: + conv115, err := DeltaTableSyncInfoToSDK(w.DeltaTableSyncInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTablePosition.SourceSyncInfo", err) + } + out.SourceSyncInfo = &sdk.SyncedTablePosition_SourceSyncInfo_DeltaTableSyncInfo{DeltaTableSyncInfo: *conv115} + } + return out, nil +} + +// SyncedTablePositionFromSDK converts the sdk-go type to the mirror. +func SyncedTablePositionFromSDK(v *sdk.SyncedTablePosition) (*SyncedTablePosition, error) { + if v == nil { + return nil, nil + } + out := &SyncedTablePosition{} + out.SyncStartTime = v.SyncStartTime + out.SyncEndTime = v.SyncEndTime + switch value := v.SourceSyncInfo.(type) { + case *sdk.SyncedTablePosition_SourceSyncInfo_DeltaTableSyncInfo: + if value != nil { + conv116, err := DeltaTableSyncInfoFromSDK(&value.DeltaTableSyncInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTablePosition.SourceSyncInfo", err) + } + out.DeltaTableSyncInfo = conv116 + } + } + return out, nil +} + +// SyncedTable_SyncedTableSpecToSDK converts the mirror to the sdk-go type. +func SyncedTable_SyncedTableSpecToSDK(w *SyncedTable_SyncedTableSpec) (*sdk.SyncedTable_SyncedTableSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTable_SyncedTableSpec{} + out.PostgresDatabase = w.PostgresDatabase + out.Branch = w.Branch + out.SchedulingPolicy = w.SchedulingPolicy + out.SourceTableFullName = w.SourceTableFullName + out.PrimaryKeyColumns = w.PrimaryKeyColumns + out.TimeseriesKey = w.TimeseriesKey + out.ExistingPipelineId = w.ExistingPipelineId + out.CreateDatabaseObjectsIfMissing = w.CreateDatabaseObjectsIfMissing + conv117, err := NewPipelineSpecToSDK(w.NewPipelineSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable_SyncedTableSpec.NewPipelineSpec", err) + } + out.NewPipelineSpec = conv117 + out.AcceleratedSync = w.AcceleratedSync + conv118, err := convertSlice(w.TypeOverrides, SyncedTable_SyncedTableSpec_TypeOverrideToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable_SyncedTableSpec.TypeOverrides", err) + } + out.TypeOverrides = conv118 + conv119, err := convertSlice(w.ExtraColumns, SyncedTable_SyncedTableSpec_ExtraColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable_SyncedTableSpec.ExtraColumns", err) + } + out.ExtraColumns = conv119 + return out, nil +} + +// SyncedTable_SyncedTableSpecFromSDK converts the sdk-go type to the mirror. +func SyncedTable_SyncedTableSpecFromSDK(v *sdk.SyncedTable_SyncedTableSpec) (*SyncedTable_SyncedTableSpec, error) { + if v == nil { + return nil, nil + } + out := &SyncedTable_SyncedTableSpec{} + out.PostgresDatabase = v.PostgresDatabase + out.Branch = v.Branch + out.SchedulingPolicy = v.SchedulingPolicy + out.SourceTableFullName = v.SourceTableFullName + out.PrimaryKeyColumns = v.PrimaryKeyColumns + out.TimeseriesKey = v.TimeseriesKey + out.ExistingPipelineId = v.ExistingPipelineId + out.CreateDatabaseObjectsIfMissing = v.CreateDatabaseObjectsIfMissing + conv120, err := NewPipelineSpecFromSDK(v.NewPipelineSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable_SyncedTableSpec.NewPipelineSpec", err) + } + out.NewPipelineSpec = conv120 + out.AcceleratedSync = v.AcceleratedSync + conv121, err := convertSlice(v.TypeOverrides, SyncedTable_SyncedTableSpec_TypeOverrideFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable_SyncedTableSpec.TypeOverrides", err) + } + out.TypeOverrides = conv121 + conv122, err := convertSlice(v.ExtraColumns, SyncedTable_SyncedTableSpec_ExtraColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable_SyncedTableSpec.ExtraColumns", err) + } + out.ExtraColumns = conv122 + return out, nil +} + +// SyncedTable_SyncedTableSpec_ExtraColumnToSDK converts the mirror to the sdk-go type. +func SyncedTable_SyncedTableSpec_ExtraColumnToSDK(w *SyncedTable_SyncedTableSpec_ExtraColumn) (*sdk.SyncedTable_SyncedTableSpec_ExtraColumn, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTable_SyncedTableSpec_ExtraColumn{} + out.ColumnName = w.ColumnName + out.ColumnType = w.ColumnType + out.Maintenance = w.Maintenance + out.Compute = w.Compute + return out, nil +} + +// SyncedTable_SyncedTableSpec_ExtraColumnFromSDK converts the sdk-go type to the mirror. +func SyncedTable_SyncedTableSpec_ExtraColumnFromSDK(v *sdk.SyncedTable_SyncedTableSpec_ExtraColumn) (*SyncedTable_SyncedTableSpec_ExtraColumn, error) { + if v == nil { + return nil, nil + } + out := &SyncedTable_SyncedTableSpec_ExtraColumn{} + out.ColumnName = v.ColumnName + out.ColumnType = v.ColumnType + out.Maintenance = v.Maintenance + out.Compute = v.Compute + return out, nil +} + +// SyncedTable_SyncedTableSpec_TypeOverrideToSDK converts the mirror to the sdk-go type. +func SyncedTable_SyncedTableSpec_TypeOverrideToSDK(w *SyncedTable_SyncedTableSpec_TypeOverride) (*sdk.SyncedTable_SyncedTableSpec_TypeOverride, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTable_SyncedTableSpec_TypeOverride{} + out.ColumnName = w.ColumnName + out.PgType = w.PgType + out.Size = w.Size + return out, nil +} + +// SyncedTable_SyncedTableSpec_TypeOverrideFromSDK converts the sdk-go type to the mirror. +func SyncedTable_SyncedTableSpec_TypeOverrideFromSDK(v *sdk.SyncedTable_SyncedTableSpec_TypeOverride) (*SyncedTable_SyncedTableSpec_TypeOverride, error) { + if v == nil { + return nil, nil + } + out := &SyncedTable_SyncedTableSpec_TypeOverride{} + out.ColumnName = v.ColumnName + out.PgType = v.PgType + out.Size = v.Size + return out, nil +} + +// SyncedTable_SyncedTableStatusToSDK converts the mirror to the sdk-go type. +func SyncedTable_SyncedTableStatusToSDK(w *SyncedTable_SyncedTableStatus) (*sdk.SyncedTable_SyncedTableStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncedTable_SyncedTableStatus{} + out.Message = w.Message + out.DetailedState = w.DetailedState + conv123, err := SyncedTablePositionToSDK(w.LastSync) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable_SyncedTableStatus.LastSync", err) + } + out.LastSync = conv123 + conv124, err := SyncedTablePipelineProgressToSDK(w.OngoingSyncProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable_SyncedTableStatus.OngoingSyncProgress", err) + } + out.OngoingSyncProgress = conv124 + out.ProvisioningPhase = w.ProvisioningPhase + out.LastProcessedCommitVersion = w.LastProcessedCommitVersion + out.LastSyncTime = w.LastSyncTime + out.PipelineId = w.PipelineId + out.UnityCatalogProvisioningState = w.UnityCatalogProvisioningState + out.Project = w.Project + return out, nil +} + +// SyncedTable_SyncedTableStatusFromSDK converts the sdk-go type to the mirror. +func SyncedTable_SyncedTableStatusFromSDK(v *sdk.SyncedTable_SyncedTableStatus) (*SyncedTable_SyncedTableStatus, error) { + if v == nil { + return nil, nil + } + out := &SyncedTable_SyncedTableStatus{} + out.Message = v.Message + out.DetailedState = v.DetailedState + conv125, err := SyncedTablePositionFromSDK(v.LastSync) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable_SyncedTableStatus.LastSync", err) + } + out.LastSync = conv125 + conv126, err := SyncedTablePipelineProgressFromSDK(v.OngoingSyncProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SyncedTable_SyncedTableStatus.OngoingSyncProgress", err) + } + out.OngoingSyncProgress = conv126 + out.ProvisioningPhase = v.ProvisioningPhase + out.LastProcessedCommitVersion = v.LastProcessedCommitVersion + out.LastSyncTime = v.LastSyncTime + out.PipelineId = v.PipelineId + out.UnityCatalogProvisioningState = v.UnityCatalogProvisioningState + out.Project = v.Project + return out, nil +} + +// UndeleteBranchRequestToSDK converts the mirror to the sdk-go type. +func UndeleteBranchRequestToSDK(w *UndeleteBranchRequest) (*sdk.UndeleteBranchRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UndeleteBranchRequest{} + out.Name = w.Name + return out, nil +} + +// UndeleteBranchRequestFromSDK converts the sdk-go type to the mirror. +func UndeleteBranchRequestFromSDK(v *sdk.UndeleteBranchRequest) (*UndeleteBranchRequest, error) { + if v == nil { + return nil, nil + } + out := &UndeleteBranchRequest{} + out.Name = v.Name + return out, nil +} + +// UndeleteProjectRequestToSDK converts the mirror to the sdk-go type. +func UndeleteProjectRequestToSDK(w *UndeleteProjectRequest) (*sdk.UndeleteProjectRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UndeleteProjectRequest{} + out.Name = w.Name + return out, nil +} + +// UndeleteProjectRequestFromSDK converts the sdk-go type to the mirror. +func UndeleteProjectRequestFromSDK(v *sdk.UndeleteProjectRequest) (*UndeleteProjectRequest, error) { + if v == nil { + return nil, nil + } + out := &UndeleteProjectRequest{} + out.Name = v.Name + return out, nil +} + +// UpdateBranchRequestToSDK converts the mirror to the sdk-go type. +func UpdateBranchRequestToSDK(w *UpdateBranchRequest) (*sdk.UpdateBranchRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateBranchRequest{} + conv127, err := BranchToSDK(w.Branch) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBranchRequest.Branch", err) + } + out.Branch = conv127 + mask128, err := fieldMaskFromString[sdk.Branch](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBranchRequest.UpdateMask", err) + } + out.UpdateMask = mask128 + return out, nil +} + +// UpdateBranchRequestFromSDK converts the sdk-go type to the mirror. +func UpdateBranchRequestFromSDK(v *sdk.UpdateBranchRequest) (*UpdateBranchRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateBranchRequest{} + conv129, err := BranchFromSDK(v.Branch) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateBranchRequest.Branch", err) + } + out.Branch = conv129 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateDataApiRequestToSDK converts the mirror to the sdk-go type. +func UpdateDataApiRequestToSDK(w *UpdateDataApiRequest) (*sdk.UpdateDataApiRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateDataApiRequest{} + conv130, err := DataApiToSDK(w.DataApi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDataApiRequest.DataApi", err) + } + out.DataApi = conv130 + mask131, err := fieldMaskFromString[sdk.DataApi](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDataApiRequest.UpdateMask", err) + } + out.UpdateMask = mask131 + return out, nil +} + +// UpdateDataApiRequestFromSDK converts the sdk-go type to the mirror. +func UpdateDataApiRequestFromSDK(v *sdk.UpdateDataApiRequest) (*UpdateDataApiRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateDataApiRequest{} + conv132, err := DataApiFromSDK(v.DataApi) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDataApiRequest.DataApi", err) + } + out.DataApi = conv132 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateDatabaseRequestToSDK converts the mirror to the sdk-go type. +func UpdateDatabaseRequestToSDK(w *UpdateDatabaseRequest) (*sdk.UpdateDatabaseRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateDatabaseRequest{} + conv133, err := DatabaseToSDK(w.Database) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDatabaseRequest.Database", err) + } + out.Database = conv133 + mask134, err := fieldMaskFromString[sdk.Database](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDatabaseRequest.UpdateMask", err) + } + out.UpdateMask = mask134 + return out, nil +} + +// UpdateDatabaseRequestFromSDK converts the sdk-go type to the mirror. +func UpdateDatabaseRequestFromSDK(v *sdk.UpdateDatabaseRequest) (*UpdateDatabaseRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateDatabaseRequest{} + conv135, err := DatabaseFromSDK(v.Database) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDatabaseRequest.Database", err) + } + out.Database = conv135 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateEndpointRequestToSDK converts the mirror to the sdk-go type. +func UpdateEndpointRequestToSDK(w *UpdateEndpointRequest) (*sdk.UpdateEndpointRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateEndpointRequest{} + conv136, err := EndpointToSDK(w.Endpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEndpointRequest.Endpoint", err) + } + out.Endpoint = conv136 + mask137, err := fieldMaskFromString[sdk.Endpoint](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEndpointRequest.UpdateMask", err) + } + out.UpdateMask = mask137 + return out, nil +} + +// UpdateEndpointRequestFromSDK converts the sdk-go type to the mirror. +func UpdateEndpointRequestFromSDK(v *sdk.UpdateEndpointRequest) (*UpdateEndpointRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateEndpointRequest{} + conv138, err := EndpointFromSDK(v.Endpoint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEndpointRequest.Endpoint", err) + } + out.Endpoint = conv138 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateProjectRequestToSDK converts the mirror to the sdk-go type. +func UpdateProjectRequestToSDK(w *UpdateProjectRequest) (*sdk.UpdateProjectRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateProjectRequest{} + conv139, err := ProjectToSDK(w.Project) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateProjectRequest.Project", err) + } + out.Project = conv139 + mask140, err := fieldMaskFromString[sdk.Project](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateProjectRequest.UpdateMask", err) + } + out.UpdateMask = mask140 + return out, nil +} + +// UpdateProjectRequestFromSDK converts the sdk-go type to the mirror. +func UpdateProjectRequestFromSDK(v *sdk.UpdateProjectRequest) (*UpdateProjectRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateProjectRequest{} + conv141, err := ProjectFromSDK(v.Project) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateProjectRequest.Project", err) + } + out.Project = conv141 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateRoleRequestToSDK converts the mirror to the sdk-go type. +func UpdateRoleRequestToSDK(w *UpdateRoleRequest) (*sdk.UpdateRoleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRoleRequest{} + conv142, err := RoleToSDK(w.Role) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRoleRequest.Role", err) + } + out.Role = conv142 + mask143, err := fieldMaskFromString[sdk.Role](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRoleRequest.UpdateMask", err) + } + out.UpdateMask = mask143 + return out, nil +} + +// UpdateRoleRequestFromSDK converts the sdk-go type to the mirror. +func UpdateRoleRequestFromSDK(v *sdk.UpdateRoleRequest) (*UpdateRoleRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateRoleRequest{} + conv144, err := RoleFromSDK(v.Role) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRoleRequest.Role", err) + } + out.Role = conv144 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateSnapshotScheduleRequestToSDK converts the mirror to the sdk-go type. +func UpdateSnapshotScheduleRequestToSDK(w *UpdateSnapshotScheduleRequest) (*sdk.UpdateSnapshotScheduleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateSnapshotScheduleRequest{} + conv145, err := SnapshotScheduleToSDK(w.SnapshotSchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSnapshotScheduleRequest.SnapshotSchedule", err) + } + out.SnapshotSchedule = conv145 + mask146, err := fieldMaskFromString[sdk.SnapshotSchedule](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSnapshotScheduleRequest.UpdateMask", err) + } + out.UpdateMask = mask146 + return out, nil +} + +// UpdateSnapshotScheduleRequestFromSDK converts the sdk-go type to the mirror. +func UpdateSnapshotScheduleRequestFromSDK(v *sdk.UpdateSnapshotScheduleRequest) (*UpdateSnapshotScheduleRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateSnapshotScheduleRequest{} + conv147, err := SnapshotScheduleFromSDK(v.SnapshotSchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSnapshotScheduleRequest.SnapshotSchedule", err) + } + out.SnapshotSchedule = conv147 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// WeeklyScheduleToSDK converts the mirror to the sdk-go type. +func WeeklyScheduleToSDK(w *WeeklySchedule) (*sdk.WeeklySchedule, error) { + if w == nil { + return nil, nil + } + out := &sdk.WeeklySchedule{} + out.DayOfWeek = w.DayOfWeek + out.Hour = w.Hour + return out, nil +} + +// WeeklyScheduleFromSDK converts the sdk-go type to the mirror. +func WeeklyScheduleFromSDK(v *sdk.WeeklySchedule) (*WeeklySchedule, error) { + if v == nil { + return nil, nil + } + out := &WeeklySchedule{} + out.DayOfWeek = v.DayOfWeek + out.Hour = v.Hour + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/queries/v1/types.generated.go b/libs/sdktypes/queries/v1/types.generated.go new file mode 100644 index 00000000000..3da2f43d853 --- /dev/null +++ b/libs/sdktypes/queries/v1/types.generated.go @@ -0,0 +1,1157 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/queries/v1. DO NOT EDIT. + +package queries + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/queries/v1" + strings "strings" +) + +type ( + DatePrecision = sdk.DatePrecision + LifecycleState = sdk.LifecycleState + RunAsMode = sdk.RunAsMode + DateRangeValue_DynamicDateRange = sdk.DateRangeValue_DynamicDateRange + DateValue_DynamicDate = sdk.DateValue_DynamicDate +) + +const ( + DatePrecision_Unspecified = sdk.DatePrecision_Unspecified + DatePrecision_DayPrecision = sdk.DatePrecision_DayPrecision + DatePrecision_MinutePrecision = sdk.DatePrecision_MinutePrecision + DatePrecision_SecondPrecision = sdk.DatePrecision_SecondPrecision + LifecycleState_Unspecified = sdk.LifecycleState_Unspecified + LifecycleState_Active = sdk.LifecycleState_Active + LifecycleState_Trashed = sdk.LifecycleState_Trashed + RunAsMode_Unspecified = sdk.RunAsMode_Unspecified + RunAsMode_Owner = sdk.RunAsMode_Owner + RunAsMode_Viewer = sdk.RunAsMode_Viewer + DateRangeValue_DynamicDateRange_Unspecified = sdk.DateRangeValue_DynamicDateRange_Unspecified + DateRangeValue_DynamicDateRange_Today = sdk.DateRangeValue_DynamicDateRange_Today + DateRangeValue_DynamicDateRange_Yesterday = sdk.DateRangeValue_DynamicDateRange_Yesterday + DateRangeValue_DynamicDateRange_ThisWeek = sdk.DateRangeValue_DynamicDateRange_ThisWeek + DateRangeValue_DynamicDateRange_ThisMonth = sdk.DateRangeValue_DynamicDateRange_ThisMonth + DateRangeValue_DynamicDateRange_ThisYear = sdk.DateRangeValue_DynamicDateRange_ThisYear + DateRangeValue_DynamicDateRange_LastWeek = sdk.DateRangeValue_DynamicDateRange_LastWeek + DateRangeValue_DynamicDateRange_LastMonth = sdk.DateRangeValue_DynamicDateRange_LastMonth + DateRangeValue_DynamicDateRange_LastYear = sdk.DateRangeValue_DynamicDateRange_LastYear + DateRangeValue_DynamicDateRange_LastHour = sdk.DateRangeValue_DynamicDateRange_LastHour + DateRangeValue_DynamicDateRange_Last8Hours = sdk.DateRangeValue_DynamicDateRange_Last8Hours + DateRangeValue_DynamicDateRange_Last24Hours = sdk.DateRangeValue_DynamicDateRange_Last24Hours + DateRangeValue_DynamicDateRange_Last7Days = sdk.DateRangeValue_DynamicDateRange_Last7Days + DateRangeValue_DynamicDateRange_Last14Days = sdk.DateRangeValue_DynamicDateRange_Last14Days + DateRangeValue_DynamicDateRange_Last30Days = sdk.DateRangeValue_DynamicDateRange_Last30Days + DateRangeValue_DynamicDateRange_Last60Days = sdk.DateRangeValue_DynamicDateRange_Last60Days + DateRangeValue_DynamicDateRange_Last90Days = sdk.DateRangeValue_DynamicDateRange_Last90Days + DateRangeValue_DynamicDateRange_Last12Months = sdk.DateRangeValue_DynamicDateRange_Last12Months + DateValue_DynamicDate_Unspecified = sdk.DateValue_DynamicDate_Unspecified + DateValue_DynamicDate_Now = sdk.DateValue_DynamicDate_Now + DateValue_DynamicDate_Yesterday = sdk.DateValue_DynamicDate_Yesterday +) + +type CreateQueryRequest struct { + // If true, automatically resolve query display name conflicts. Otherwise, fail + // the request if the query's display name conflicts with an existing query's + // display name. + AutoResolveDisplayName *bool `json:"auto_resolve_display_name,omitempty"` + Query *CreateQueryRequestQuery `json:"query,omitempty"` +} + +type CreateQueryRequestQuery struct { + // Whether to apply a 1000 row limit to the query result. + ApplyAutoLimit *bool `json:"apply_auto_limit,omitempty"` + // Name of the catalog where this query will be executed. + Catalog *string `json:"catalog,omitempty"` + // General description that conveys additional information about this query such + // as usage notes. + Description *string `json:"description,omitempty"` + // Display name of the query that appears in list views, widget headings, and on + // the query page. + DisplayName *string `json:"display_name,omitempty"` + // List of query parameter definitions. + Parameters []QueryParameter `json:"parameters,omitempty"` + // Workspace path of the workspace folder containing the object. + ParentPath *string `json:"parent_path,omitempty"` + // Text of the query to be run. + QueryText *string `json:"query_text,omitempty"` + // Sets the "Run as" role for the object. + RunAsMode RunAsMode `json:"run_as_mode,omitempty"` + // Name of the schema where this query will be executed. + Schema *string `json:"schema,omitempty"` + Tags []string `json:"tags,omitempty"` + // ID of the SQL warehouse attached to the query. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type DateRange struct { + End *string `json:"end,omitempty"` + Start *string `json:"start,omitempty"` +} + +type DateRangeValue struct { + DateRangeValue *DateRange `json:"date_range_value,omitempty"` + DynamicDateRangeValue DateRangeValue_DynamicDateRange `json:"dynamic_date_range_value,omitempty"` + // Date-time precision to format the value into when the query is run. Defaults + // to DAY_PRECISION (YYYY-MM-DD). + Precision DatePrecision `json:"precision,omitempty"` + StartDayOfWeek *int `json:"start_day_of_week,omitempty"` +} + +type DateValue struct { + DateValue *string `json:"date_value,omitempty"` + DynamicDateValue DateValue_DynamicDate `json:"dynamic_date_value,omitempty"` + // Date-time precision to format the value into when the query is run. Defaults + // to DAY_PRECISION (YYYY-MM-DD). + Precision DatePrecision `json:"precision,omitempty"` +} + +type EnumValue struct { + // List of valid query parameter values, newline delimited. + EnumOptions *string `json:"enum_options,omitempty"` + // If specified, allows multiple values to be selected for this parameter. + MultiValuesOptions *MultiValuesOptions `json:"multi_values_options,omitempty"` + // List of selected query parameter values. + Values []string `json:"values,omitempty"` +} + +type ListQueriesRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListQueriesResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + Results []ListQueryObjectsResponseQuery `json:"results,omitempty"` +} + +type ListQueryObjectsResponseQuery struct { + // Whether to apply a 1000 row limit to the query result. + ApplyAutoLimit *bool `json:"apply_auto_limit,omitempty"` + // Name of the catalog where this query will be executed. + Catalog *string `json:"catalog,omitempty"` + // Timestamp when this query was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // General description that conveys additional information about this query such + // as usage notes. + Description *string `json:"description,omitempty"` + // Display name of the query that appears in list views, widget headings, and on + // the query page. + DisplayName *string `json:"display_name,omitempty"` + // UUID identifying the query. + Id *string `json:"id,omitempty"` + // Username of the user who last saved changes to this query. + LastModifierUserName *string `json:"last_modifier_user_name,omitempty"` + // Indicates whether the query is trashed. + LifecycleState LifecycleState `json:"lifecycle_state,omitempty"` + // Username of the user that owns the query. + OwnerUserName *string `json:"owner_user_name,omitempty"` + // List of query parameter definitions. + Parameters []QueryParameter `json:"parameters,omitempty"` + // Text of the query to be run. + QueryText *string `json:"query_text,omitempty"` + // Sets the "Run as" role for the object. + RunAsMode RunAsMode `json:"run_as_mode,omitempty"` + // Name of the schema where this query will be executed. + Schema *string `json:"schema,omitempty"` + Tags []string `json:"tags,omitempty"` + // Timestamp when this query was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` + // ID of the SQL warehouse attached to the query. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type ListVisualizationsForQueryRequest struct { + Id *string `json:"id,omitempty"` + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +type ListVisualizationsForQueryResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + Results []Visualization `json:"results,omitempty"` +} + +type MultiValuesOptions struct { + // Character that prefixes each selected parameter value. + Prefix *string `json:"prefix,omitempty"` + // Character that separates each selected parameter value. Defaults to a comma. + Separator *string `json:"separator,omitempty"` + // Character that suffixes each selected parameter value. + Suffix *string `json:"suffix,omitempty"` +} + +type NumericValue struct { + Value *float64 `json:"value,omitempty"` +} + +type Query struct { + // Whether to apply a 1000 row limit to the query result. + ApplyAutoLimit *bool `json:"apply_auto_limit,omitempty"` + // Name of the catalog where this query will be executed. + Catalog *string `json:"catalog,omitempty"` + // Timestamp when this query was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // General description that conveys additional information about this query such + // as usage notes. + Description *string `json:"description,omitempty"` + // Display name of the query that appears in list views, widget headings, and on + // the query page. + DisplayName *string `json:"display_name,omitempty"` + // UUID identifying the query. + Id *string `json:"id,omitempty"` + // Username of the user who last saved changes to this query. + LastModifierUserName *string `json:"last_modifier_user_name,omitempty"` + // Indicates whether the query is trashed. + LifecycleState LifecycleState `json:"lifecycle_state,omitempty"` + // Username of the user that owns the query. + OwnerUserName *string `json:"owner_user_name,omitempty"` + // List of query parameter definitions. + Parameters []QueryParameter `json:"parameters,omitempty"` + // Workspace path of the workspace folder containing the object. + ParentPath *string `json:"parent_path,omitempty"` + // Text of the query to be run. + QueryText *string `json:"query_text,omitempty"` + // Sets the "Run as" role for the object. + RunAsMode RunAsMode `json:"run_as_mode,omitempty"` + // Name of the schema where this query will be executed. + Schema *string `json:"schema,omitempty"` + Tags []string `json:"tags,omitempty"` + // Timestamp when this query was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` + // ID of the SQL warehouse attached to the query. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type QueryBackedValue struct { + // If specified, allows multiple values to be selected for this parameter. + MultiValuesOptions *MultiValuesOptions `json:"multi_values_options,omitempty"` + // UUID of the query that provides the parameter values. + QueryId *string `json:"query_id,omitempty"` + // List of selected query parameter values. + Values []string `json:"values,omitempty"` +} + +type QueryParameter struct { + DateRangeValue *DateRangeValue `json:"date_range_value,omitempty"` + DateValue *DateValue `json:"date_value,omitempty"` + EnumValue *EnumValue `json:"enum_value,omitempty"` + // Literal parameter marker that appears between double curly braces in the + // query text. + Name *string `json:"name,omitempty"` + NumericValue *NumericValue `json:"numeric_value,omitempty"` + QueryBackedValue *QueryBackedValue `json:"query_backed_value,omitempty"` + TextValue *TextValue `json:"text_value,omitempty"` + // Text displayed in the user-facing parameter widget in the UI. + Title *string `json:"title,omitempty"` +} + +type TextValue struct { + Value *string `json:"value,omitempty"` +} + +type UpdateQueryRequest struct { + // If true, automatically resolve alert display name conflicts. Otherwise, fail + // the request if the alert's display name conflicts with an existing alert's + // display name. + AutoResolveDisplayName *bool `json:"auto_resolve_display_name,omitempty"` + Id *string `json:"id,omitempty"` + Query *UpdateQueryRequestQuery `json:"query,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateQueryRequestQuery struct { + // Whether to apply a 1000 row limit to the query result. + ApplyAutoLimit *bool `json:"apply_auto_limit,omitempty"` + // Name of the catalog where this query will be executed. + Catalog *string `json:"catalog,omitempty"` + // General description that conveys additional information about this query such + // as usage notes. + Description *string `json:"description,omitempty"` + // Display name of the query that appears in list views, widget headings, and on + // the query page. + DisplayName *string `json:"display_name,omitempty"` + // Username of the user that owns the query. + OwnerUserName *string `json:"owner_user_name,omitempty"` + // List of query parameter definitions. + Parameters []QueryParameter `json:"parameters,omitempty"` + // Text of the query to be run. + QueryText *string `json:"query_text,omitempty"` + // Sets the "Run as" role for the object. + RunAsMode RunAsMode `json:"run_as_mode,omitempty"` + // Name of the schema where this query will be executed. + Schema *string `json:"schema,omitempty"` + Tags []string `json:"tags,omitempty"` + // ID of the SQL warehouse attached to the query. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type Visualization struct { + // The timestamp indicating when the visualization was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // The display name of the visualization. + DisplayName *string `json:"display_name,omitempty"` + // UUID identifying the visualization. + Id *string `json:"id,omitempty"` + // UUID of the query that the visualization is attached to. + QueryId *string `json:"query_id,omitempty"` + // The visualization options varies widely from one visualization type to the + // next and is unsupported. Databricks does not recommend modifying + // visualization options directly. + SerializedOptions *string `json:"serialized_options,omitempty"` + // The visualization query plan varies widely from one visualization type to the + // next and is unsupported. Databricks does not recommend modifying the + // visualization query plan directly. + SerializedQueryPlan *string `json:"serialized_query_plan,omitempty"` + // The type of visualization: counter, table, funnel, and so on. + Type *string `json:"type,omitempty"` + // The timestamp indicating when the visualization was updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +// CreateQueryRequestToSDK converts the mirror to the sdk-go type. +func CreateQueryRequestToSDK(w *CreateQueryRequest) (*sdk.CreateQueryRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateQueryRequest{} + conv1, err := CreateQueryRequestQueryToSDK(w.Query) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateQueryRequest.Query", err) + } + out.Query = conv1 + out.AutoResolveDisplayName = w.AutoResolveDisplayName + return out, nil +} + +// CreateQueryRequestFromSDK converts the sdk-go type to the mirror. +func CreateQueryRequestFromSDK(v *sdk.CreateQueryRequest) (*CreateQueryRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateQueryRequest{} + conv2, err := CreateQueryRequestQueryFromSDK(v.Query) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateQueryRequest.Query", err) + } + out.Query = conv2 + out.AutoResolveDisplayName = v.AutoResolveDisplayName + return out, nil +} + +// CreateQueryRequestQueryToSDK converts the mirror to the sdk-go type. +func CreateQueryRequestQueryToSDK(w *CreateQueryRequestQuery) (*sdk.CreateQueryRequestQuery, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateQueryRequestQuery{} + out.DisplayName = w.DisplayName + out.Description = w.Description + out.WarehouseId = w.WarehouseId + out.QueryText = w.QueryText + out.RunAsMode = w.RunAsMode + out.ParentPath = w.ParentPath + out.Tags = w.Tags + conv3, err := convertSlice(w.Parameters, QueryParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateQueryRequestQuery.Parameters", err) + } + out.Parameters = conv3 + out.ApplyAutoLimit = w.ApplyAutoLimit + out.Catalog = w.Catalog + out.Schema = w.Schema + return out, nil +} + +// CreateQueryRequestQueryFromSDK converts the sdk-go type to the mirror. +func CreateQueryRequestQueryFromSDK(v *sdk.CreateQueryRequestQuery) (*CreateQueryRequestQuery, error) { + if v == nil { + return nil, nil + } + out := &CreateQueryRequestQuery{} + out.DisplayName = v.DisplayName + out.Description = v.Description + out.WarehouseId = v.WarehouseId + out.QueryText = v.QueryText + out.RunAsMode = v.RunAsMode + out.ParentPath = v.ParentPath + out.Tags = v.Tags + conv4, err := convertSlice(v.Parameters, QueryParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateQueryRequestQuery.Parameters", err) + } + out.Parameters = conv4 + out.ApplyAutoLimit = v.ApplyAutoLimit + out.Catalog = v.Catalog + out.Schema = v.Schema + return out, nil +} + +// DateRangeToSDK converts the mirror to the sdk-go type. +func DateRangeToSDK(w *DateRange) (*sdk.DateRange, error) { + if w == nil { + return nil, nil + } + out := &sdk.DateRange{} + out.Start = w.Start + out.End = w.End + return out, nil +} + +// DateRangeFromSDK converts the sdk-go type to the mirror. +func DateRangeFromSDK(v *sdk.DateRange) (*DateRange, error) { + if v == nil { + return nil, nil + } + out := &DateRange{} + out.Start = v.Start + out.End = v.End + return out, nil +} + +// DateRangeValueToSDK converts the mirror to the sdk-go type. +func DateRangeValueToSDK(w *DateRangeValue) (*sdk.DateRangeValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.DateRangeValue{} + { + var members []string + if w.DynamicDateRangeValue != "" { + members = append(members, "dynamic_date_range_value") + } + if w.DateRangeValue != nil { + members = append(members, "date_range_value") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DynamicDateRangeValue != "": + out.Value = &sdk.DateRangeValue_Value_DynamicDateRangeValue{DynamicDateRangeValue: w.DynamicDateRangeValue} + case w.DateRangeValue != nil: + conv5, err := DateRangeToSDK(w.DateRangeValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DateRangeValue.Value", err) + } + out.Value = &sdk.DateRangeValue_Value_DateRangeValue{DateRangeValue: *conv5} + } + out.Precision = w.Precision + out.StartDayOfWeek = w.StartDayOfWeek + return out, nil +} + +// DateRangeValueFromSDK converts the sdk-go type to the mirror. +func DateRangeValueFromSDK(v *sdk.DateRangeValue) (*DateRangeValue, error) { + if v == nil { + return nil, nil + } + out := &DateRangeValue{} + switch value := v.Value.(type) { + case *sdk.DateRangeValue_Value_DynamicDateRangeValue: + if value != nil { + out.DynamicDateRangeValue = value.DynamicDateRangeValue + } + case *sdk.DateRangeValue_Value_DateRangeValue: + if value != nil { + conv6, err := DateRangeFromSDK(&value.DateRangeValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DateRangeValue.Value", err) + } + out.DateRangeValue = conv6 + } + } + out.Precision = v.Precision + out.StartDayOfWeek = v.StartDayOfWeek + return out, nil +} + +// DateValueToSDK converts the mirror to the sdk-go type. +func DateValueToSDK(w *DateValue) (*sdk.DateValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.DateValue{} + { + var members []string + if w.DynamicDateValue != "" { + members = append(members, "dynamic_date_value") + } + if w.DateValue != nil { + members = append(members, "date_value") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DynamicDateValue != "": + out.Value = &sdk.DateValue_Value_DynamicDateValue{DynamicDateValue: w.DynamicDateValue} + case w.DateValue != nil: + out.Value = &sdk.DateValue_Value_DateValue{DateValue: *w.DateValue} + } + out.Precision = w.Precision + return out, nil +} + +// DateValueFromSDK converts the sdk-go type to the mirror. +func DateValueFromSDK(v *sdk.DateValue) (*DateValue, error) { + if v == nil { + return nil, nil + } + out := &DateValue{} + switch value := v.Value.(type) { + case *sdk.DateValue_Value_DynamicDateValue: + if value != nil { + out.DynamicDateValue = value.DynamicDateValue + } + case *sdk.DateValue_Value_DateValue: + if value != nil { + out.DateValue = new(value.DateValue) + } + } + out.Precision = v.Precision + return out, nil +} + +// EnumValueToSDK converts the mirror to the sdk-go type. +func EnumValueToSDK(w *EnumValue) (*sdk.EnumValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnumValue{} + out.Values = w.Values + out.EnumOptions = w.EnumOptions + conv7, err := MultiValuesOptionsToSDK(w.MultiValuesOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnumValue.MultiValuesOptions", err) + } + out.MultiValuesOptions = conv7 + return out, nil +} + +// EnumValueFromSDK converts the sdk-go type to the mirror. +func EnumValueFromSDK(v *sdk.EnumValue) (*EnumValue, error) { + if v == nil { + return nil, nil + } + out := &EnumValue{} + out.Values = v.Values + out.EnumOptions = v.EnumOptions + conv8, err := MultiValuesOptionsFromSDK(v.MultiValuesOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EnumValue.MultiValuesOptions", err) + } + out.MultiValuesOptions = conv8 + return out, nil +} + +// ListQueriesRequestToSDK converts the mirror to the sdk-go type. +func ListQueriesRequestToSDK(w *ListQueriesRequest) (*sdk.ListQueriesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListQueriesRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListQueriesRequestFromSDK converts the sdk-go type to the mirror. +func ListQueriesRequestFromSDK(v *sdk.ListQueriesRequest) (*ListQueriesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListQueriesRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListQueriesResponseToSDK converts the mirror to the sdk-go type. +func ListQueriesResponseToSDK(w *ListQueriesResponse) (*sdk.ListQueriesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListQueriesResponse{} + conv9, err := convertSlice(w.Results, ListQueryObjectsResponseQueryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListQueriesResponse.Results", err) + } + out.Results = conv9 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListQueriesResponseFromSDK converts the sdk-go type to the mirror. +func ListQueriesResponseFromSDK(v *sdk.ListQueriesResponse) (*ListQueriesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListQueriesResponse{} + conv10, err := convertSlice(v.Results, ListQueryObjectsResponseQueryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListQueriesResponse.Results", err) + } + out.Results = conv10 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListQueryObjectsResponseQueryToSDK converts the mirror to the sdk-go type. +func ListQueryObjectsResponseQueryToSDK(w *ListQueryObjectsResponseQuery) (*sdk.ListQueryObjectsResponseQuery, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListQueryObjectsResponseQuery{} + out.Id = w.Id + out.DisplayName = w.DisplayName + out.Description = w.Description + out.OwnerUserName = w.OwnerUserName + out.WarehouseId = w.WarehouseId + out.QueryText = w.QueryText + out.RunAsMode = w.RunAsMode + out.LifecycleState = w.LifecycleState + out.LastModifierUserName = w.LastModifierUserName + out.Tags = w.Tags + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + conv11, err := convertSlice(w.Parameters, QueryParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListQueryObjectsResponseQuery.Parameters", err) + } + out.Parameters = conv11 + out.ApplyAutoLimit = w.ApplyAutoLimit + out.Catalog = w.Catalog + out.Schema = w.Schema + return out, nil +} + +// ListQueryObjectsResponseQueryFromSDK converts the sdk-go type to the mirror. +func ListQueryObjectsResponseQueryFromSDK(v *sdk.ListQueryObjectsResponseQuery) (*ListQueryObjectsResponseQuery, error) { + if v == nil { + return nil, nil + } + out := &ListQueryObjectsResponseQuery{} + out.Id = v.Id + out.DisplayName = v.DisplayName + out.Description = v.Description + out.OwnerUserName = v.OwnerUserName + out.WarehouseId = v.WarehouseId + out.QueryText = v.QueryText + out.RunAsMode = v.RunAsMode + out.LifecycleState = v.LifecycleState + out.LastModifierUserName = v.LastModifierUserName + out.Tags = v.Tags + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + conv12, err := convertSlice(v.Parameters, QueryParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListQueryObjectsResponseQuery.Parameters", err) + } + out.Parameters = conv12 + out.ApplyAutoLimit = v.ApplyAutoLimit + out.Catalog = v.Catalog + out.Schema = v.Schema + return out, nil +} + +// ListVisualizationsForQueryRequestToSDK converts the mirror to the sdk-go type. +func ListVisualizationsForQueryRequestToSDK(w *ListVisualizationsForQueryRequest) (*sdk.ListVisualizationsForQueryRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListVisualizationsForQueryRequest{} + out.Id = w.Id + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListVisualizationsForQueryRequestFromSDK converts the sdk-go type to the mirror. +func ListVisualizationsForQueryRequestFromSDK(v *sdk.ListVisualizationsForQueryRequest) (*ListVisualizationsForQueryRequest, error) { + if v == nil { + return nil, nil + } + out := &ListVisualizationsForQueryRequest{} + out.Id = v.Id + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListVisualizationsForQueryResponseToSDK converts the mirror to the sdk-go type. +func ListVisualizationsForQueryResponseToSDK(w *ListVisualizationsForQueryResponse) (*sdk.ListVisualizationsForQueryResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListVisualizationsForQueryResponse{} + conv13, err := convertSlice(w.Results, VisualizationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListVisualizationsForQueryResponse.Results", err) + } + out.Results = conv13 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListVisualizationsForQueryResponseFromSDK converts the sdk-go type to the mirror. +func ListVisualizationsForQueryResponseFromSDK(v *sdk.ListVisualizationsForQueryResponse) (*ListVisualizationsForQueryResponse, error) { + if v == nil { + return nil, nil + } + out := &ListVisualizationsForQueryResponse{} + conv14, err := convertSlice(v.Results, VisualizationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListVisualizationsForQueryResponse.Results", err) + } + out.Results = conv14 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// MultiValuesOptionsToSDK converts the mirror to the sdk-go type. +func MultiValuesOptionsToSDK(w *MultiValuesOptions) (*sdk.MultiValuesOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.MultiValuesOptions{} + out.Prefix = w.Prefix + out.Separator = w.Separator + out.Suffix = w.Suffix + return out, nil +} + +// MultiValuesOptionsFromSDK converts the sdk-go type to the mirror. +func MultiValuesOptionsFromSDK(v *sdk.MultiValuesOptions) (*MultiValuesOptions, error) { + if v == nil { + return nil, nil + } + out := &MultiValuesOptions{} + out.Prefix = v.Prefix + out.Separator = v.Separator + out.Suffix = v.Suffix + return out, nil +} + +// NumericValueToSDK converts the mirror to the sdk-go type. +func NumericValueToSDK(w *NumericValue) (*sdk.NumericValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.NumericValue{} + out.Value = w.Value + return out, nil +} + +// NumericValueFromSDK converts the sdk-go type to the mirror. +func NumericValueFromSDK(v *sdk.NumericValue) (*NumericValue, error) { + if v == nil { + return nil, nil + } + out := &NumericValue{} + out.Value = v.Value + return out, nil +} + +// QueryToSDK converts the mirror to the sdk-go type. +func QueryToSDK(w *Query) (*sdk.Query, error) { + if w == nil { + return nil, nil + } + out := &sdk.Query{} + out.Id = w.Id + out.DisplayName = w.DisplayName + out.Description = w.Description + out.OwnerUserName = w.OwnerUserName + out.WarehouseId = w.WarehouseId + out.QueryText = w.QueryText + out.RunAsMode = w.RunAsMode + out.LifecycleState = w.LifecycleState + out.LastModifierUserName = w.LastModifierUserName + out.ParentPath = w.ParentPath + out.Tags = w.Tags + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + conv15, err := convertSlice(w.Parameters, QueryParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Query.Parameters", err) + } + out.Parameters = conv15 + out.ApplyAutoLimit = w.ApplyAutoLimit + out.Catalog = w.Catalog + out.Schema = w.Schema + return out, nil +} + +// QueryFromSDK converts the sdk-go type to the mirror. +func QueryFromSDK(v *sdk.Query) (*Query, error) { + if v == nil { + return nil, nil + } + out := &Query{} + out.Id = v.Id + out.DisplayName = v.DisplayName + out.Description = v.Description + out.OwnerUserName = v.OwnerUserName + out.WarehouseId = v.WarehouseId + out.QueryText = v.QueryText + out.RunAsMode = v.RunAsMode + out.LifecycleState = v.LifecycleState + out.LastModifierUserName = v.LastModifierUserName + out.ParentPath = v.ParentPath + out.Tags = v.Tags + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + conv16, err := convertSlice(v.Parameters, QueryParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Query.Parameters", err) + } + out.Parameters = conv16 + out.ApplyAutoLimit = v.ApplyAutoLimit + out.Catalog = v.Catalog + out.Schema = v.Schema + return out, nil +} + +// QueryBackedValueToSDK converts the mirror to the sdk-go type. +func QueryBackedValueToSDK(w *QueryBackedValue) (*sdk.QueryBackedValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryBackedValue{} + out.Values = w.Values + out.QueryId = w.QueryId + conv17, err := MultiValuesOptionsToSDK(w.MultiValuesOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryBackedValue.MultiValuesOptions", err) + } + out.MultiValuesOptions = conv17 + return out, nil +} + +// QueryBackedValueFromSDK converts the sdk-go type to the mirror. +func QueryBackedValueFromSDK(v *sdk.QueryBackedValue) (*QueryBackedValue, error) { + if v == nil { + return nil, nil + } + out := &QueryBackedValue{} + out.Values = v.Values + out.QueryId = v.QueryId + conv18, err := MultiValuesOptionsFromSDK(v.MultiValuesOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryBackedValue.MultiValuesOptions", err) + } + out.MultiValuesOptions = conv18 + return out, nil +} + +// QueryParameterToSDK converts the mirror to the sdk-go type. +func QueryParameterToSDK(w *QueryParameter) (*sdk.QueryParameter, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryParameter{} + out.Title = w.Title + out.Name = w.Name + { + var members []string + if w.TextValue != nil { + members = append(members, "text_value") + } + if w.NumericValue != nil { + members = append(members, "numeric_value") + } + if w.EnumValue != nil { + members = append(members, "enum_value") + } + if w.DateValue != nil { + members = append(members, "date_value") + } + if w.DateRangeValue != nil { + members = append(members, "date_range_value") + } + if w.QueryBackedValue != nil { + members = append(members, "query_backed_value") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.TextValue != nil: + conv19, err := TextValueToSDK(w.TextValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryParameter.ParameterValue", err) + } + out.ParameterValue = &sdk.QueryParameter_ParameterValue_TextValue{TextValue: *conv19} + case w.NumericValue != nil: + conv20, err := NumericValueToSDK(w.NumericValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryParameter.ParameterValue", err) + } + out.ParameterValue = &sdk.QueryParameter_ParameterValue_NumericValue{NumericValue: *conv20} + case w.EnumValue != nil: + conv21, err := EnumValueToSDK(w.EnumValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryParameter.ParameterValue", err) + } + out.ParameterValue = &sdk.QueryParameter_ParameterValue_EnumValue{EnumValue: *conv21} + case w.DateValue != nil: + conv22, err := DateValueToSDK(w.DateValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryParameter.ParameterValue", err) + } + out.ParameterValue = &sdk.QueryParameter_ParameterValue_DateValue{DateValue: *conv22} + case w.DateRangeValue != nil: + conv23, err := DateRangeValueToSDK(w.DateRangeValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryParameter.ParameterValue", err) + } + out.ParameterValue = &sdk.QueryParameter_ParameterValue_DateRangeValue{DateRangeValue: *conv23} + case w.QueryBackedValue != nil: + conv24, err := QueryBackedValueToSDK(w.QueryBackedValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryParameter.ParameterValue", err) + } + out.ParameterValue = &sdk.QueryParameter_ParameterValue_QueryBackedValue{QueryBackedValue: *conv24} + } + return out, nil +} + +// QueryParameterFromSDK converts the sdk-go type to the mirror. +func QueryParameterFromSDK(v *sdk.QueryParameter) (*QueryParameter, error) { + if v == nil { + return nil, nil + } + out := &QueryParameter{} + out.Title = v.Title + out.Name = v.Name + switch value := v.ParameterValue.(type) { + case *sdk.QueryParameter_ParameterValue_TextValue: + if value != nil { + conv25, err := TextValueFromSDK(&value.TextValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryParameter.ParameterValue", err) + } + out.TextValue = conv25 + } + case *sdk.QueryParameter_ParameterValue_NumericValue: + if value != nil { + conv26, err := NumericValueFromSDK(&value.NumericValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryParameter.ParameterValue", err) + } + out.NumericValue = conv26 + } + case *sdk.QueryParameter_ParameterValue_EnumValue: + if value != nil { + conv27, err := EnumValueFromSDK(&value.EnumValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryParameter.ParameterValue", err) + } + out.EnumValue = conv27 + } + case *sdk.QueryParameter_ParameterValue_DateValue: + if value != nil { + conv28, err := DateValueFromSDK(&value.DateValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryParameter.ParameterValue", err) + } + out.DateValue = conv28 + } + case *sdk.QueryParameter_ParameterValue_DateRangeValue: + if value != nil { + conv29, err := DateRangeValueFromSDK(&value.DateRangeValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryParameter.ParameterValue", err) + } + out.DateRangeValue = conv29 + } + case *sdk.QueryParameter_ParameterValue_QueryBackedValue: + if value != nil { + conv30, err := QueryBackedValueFromSDK(&value.QueryBackedValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryParameter.ParameterValue", err) + } + out.QueryBackedValue = conv30 + } + } + return out, nil +} + +// TextValueToSDK converts the mirror to the sdk-go type. +func TextValueToSDK(w *TextValue) (*sdk.TextValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.TextValue{} + out.Value = w.Value + return out, nil +} + +// TextValueFromSDK converts the sdk-go type to the mirror. +func TextValueFromSDK(v *sdk.TextValue) (*TextValue, error) { + if v == nil { + return nil, nil + } + out := &TextValue{} + out.Value = v.Value + return out, nil +} + +// UpdateQueryRequestToSDK converts the mirror to the sdk-go type. +func UpdateQueryRequestToSDK(w *UpdateQueryRequest) (*sdk.UpdateQueryRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateQueryRequest{} + conv31, err := UpdateQueryRequestQueryToSDK(w.Query) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateQueryRequest.Query", err) + } + out.Query = conv31 + mask32, err := fieldMaskFromString[sdk.UpdateQueryRequestQuery](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateQueryRequest.UpdateMask", err) + } + out.UpdateMask = mask32 + out.Id = w.Id + out.AutoResolveDisplayName = w.AutoResolveDisplayName + return out, nil +} + +// UpdateQueryRequestFromSDK converts the sdk-go type to the mirror. +func UpdateQueryRequestFromSDK(v *sdk.UpdateQueryRequest) (*UpdateQueryRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateQueryRequest{} + conv33, err := UpdateQueryRequestQueryFromSDK(v.Query) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateQueryRequest.Query", err) + } + out.Query = conv33 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + out.Id = v.Id + out.AutoResolveDisplayName = v.AutoResolveDisplayName + return out, nil +} + +// UpdateQueryRequestQueryToSDK converts the mirror to the sdk-go type. +func UpdateQueryRequestQueryToSDK(w *UpdateQueryRequestQuery) (*sdk.UpdateQueryRequestQuery, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateQueryRequestQuery{} + out.DisplayName = w.DisplayName + out.Description = w.Description + out.OwnerUserName = w.OwnerUserName + out.WarehouseId = w.WarehouseId + out.QueryText = w.QueryText + out.RunAsMode = w.RunAsMode + out.Tags = w.Tags + conv34, err := convertSlice(w.Parameters, QueryParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateQueryRequestQuery.Parameters", err) + } + out.Parameters = conv34 + out.ApplyAutoLimit = w.ApplyAutoLimit + out.Catalog = w.Catalog + out.Schema = w.Schema + return out, nil +} + +// UpdateQueryRequestQueryFromSDK converts the sdk-go type to the mirror. +func UpdateQueryRequestQueryFromSDK(v *sdk.UpdateQueryRequestQuery) (*UpdateQueryRequestQuery, error) { + if v == nil { + return nil, nil + } + out := &UpdateQueryRequestQuery{} + out.DisplayName = v.DisplayName + out.Description = v.Description + out.OwnerUserName = v.OwnerUserName + out.WarehouseId = v.WarehouseId + out.QueryText = v.QueryText + out.RunAsMode = v.RunAsMode + out.Tags = v.Tags + conv35, err := convertSlice(v.Parameters, QueryParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateQueryRequestQuery.Parameters", err) + } + out.Parameters = conv35 + out.ApplyAutoLimit = v.ApplyAutoLimit + out.Catalog = v.Catalog + out.Schema = v.Schema + return out, nil +} + +// VisualizationToSDK converts the mirror to the sdk-go type. +func VisualizationToSDK(w *Visualization) (*sdk.Visualization, error) { + if w == nil { + return nil, nil + } + out := &sdk.Visualization{} + out.Id = w.Id + out.DisplayName = w.DisplayName + out.Type = w.Type + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.SerializedQueryPlan = w.SerializedQueryPlan + out.SerializedOptions = w.SerializedOptions + out.QueryId = w.QueryId + return out, nil +} + +// VisualizationFromSDK converts the sdk-go type to the mirror. +func VisualizationFromSDK(v *sdk.Visualization) (*Visualization, error) { + if v == nil { + return nil, nil + } + out := &Visualization{} + out.Id = v.Id + out.DisplayName = v.DisplayName + out.Type = v.Type + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.SerializedQueryPlan = v.SerializedQueryPlan + out.SerializedOptions = v.SerializedOptions + out.QueryId = v.QueryId + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/queryhistory/v1/types.generated.go b/libs/sdktypes/queryhistory/v1/types.generated.go new file mode 100644 index 00000000000..645f4265023 --- /dev/null +++ b/libs/sdktypes/queryhistory/v1/types.generated.go @@ -0,0 +1,809 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/queryhistory/v1. DO NOT EDIT. + +package queryhistory + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/queryhistory/v1" +) + +type ( + ChannelName = sdk.ChannelName + PlansState = sdk.PlansState + QueryStatementType = sdk.QueryStatementType + QueryStatus = sdk.QueryStatus +) + +const ( + ChannelName_Unspecified = sdk.ChannelName_Unspecified + ChannelName_ChannelNamePreview = sdk.ChannelName_ChannelNamePreview + ChannelName_ChannelNameCurrent = sdk.ChannelName_ChannelNameCurrent + ChannelName_ChannelNamePrevious = sdk.ChannelName_ChannelNamePrevious + ChannelName_ChannelNameCustom = sdk.ChannelName_ChannelNameCustom + PlansState_Unspecified = sdk.PlansState_Unspecified + PlansState_IgnoredSmallDuration = sdk.PlansState_IgnoredSmallDuration + PlansState_IgnoredLargePlansSize = sdk.PlansState_IgnoredLargePlansSize + PlansState_Exists = sdk.PlansState_Exists + PlansState_Unknown = sdk.PlansState_Unknown + PlansState_Empty = sdk.PlansState_Empty + PlansState_IgnoredSparkPlanType = sdk.PlansState_IgnoredSparkPlanType + QueryStatementType_Unspecified = sdk.QueryStatementType_Unspecified + QueryStatementType_Alter = sdk.QueryStatementType_Alter + QueryStatementType_Analyze = sdk.QueryStatementType_Analyze + QueryStatementType_Copy = sdk.QueryStatementType_Copy + QueryStatementType_Create = sdk.QueryStatementType_Create + QueryStatementType_Delete = sdk.QueryStatementType_Delete + QueryStatementType_Describe = sdk.QueryStatementType_Describe + QueryStatementType_Drop = sdk.QueryStatementType_Drop + QueryStatementType_Explain = sdk.QueryStatementType_Explain + QueryStatementType_Grant = sdk.QueryStatementType_Grant + QueryStatementType_Insert = sdk.QueryStatementType_Insert + QueryStatementType_Merge = sdk.QueryStatementType_Merge + QueryStatementType_Optimize = sdk.QueryStatementType_Optimize + QueryStatementType_Refresh = sdk.QueryStatementType_Refresh + QueryStatementType_Replace = sdk.QueryStatementType_Replace + QueryStatementType_Revoke = sdk.QueryStatementType_Revoke + QueryStatementType_Select = sdk.QueryStatementType_Select + QueryStatementType_Set = sdk.QueryStatementType_Set + QueryStatementType_Show = sdk.QueryStatementType_Show + QueryStatementType_Truncate = sdk.QueryStatementType_Truncate + QueryStatementType_Update = sdk.QueryStatementType_Update + QueryStatementType_Use = sdk.QueryStatementType_Use + QueryStatus_Unspecified = sdk.QueryStatus_Unspecified + QueryStatus_Queued = sdk.QueryStatus_Queued + QueryStatus_Started = sdk.QueryStatus_Started + QueryStatus_Compiling = sdk.QueryStatus_Compiling + QueryStatus_Compiled = sdk.QueryStatus_Compiled + QueryStatus_Running = sdk.QueryStatus_Running + QueryStatus_Canceled = sdk.QueryStatus_Canceled + QueryStatus_Failed = sdk.QueryStatus_Failed + QueryStatus_Finished = sdk.QueryStatus_Finished +) + +// Details about a Channel.. +type ChannelInfo struct { + // DB SQL Version the Channel is mapped to. + DbsqlVersion *string `json:"dbsql_version,omitempty"` + // Name of the channel + Name ChannelName `json:"name,omitempty"` +} + +type ExternalQuerySource struct { + // The canonical identifier for this SQL alert + AlertId *string `json:"alert_id,omitempty"` + // The canonical identifier for this Lakeview dashboard + DashboardId *string `json:"dashboard_id,omitempty"` + // The canonical identifier for this Genie space + GenieSpaceId *string `json:"genie_space_id,omitempty"` + JobInfo *ExternalQuerySource_JobInfo `json:"job_info,omitempty"` + // The canonical identifier for this legacy dashboard + LegacyDashboardId *string `json:"legacy_dashboard_id,omitempty"` + // The canonical identifier for this notebook + NotebookId *string `json:"notebook_id,omitempty"` + // The canonical identifier for this SQL query + SqlQueryId *string `json:"sql_query_id,omitempty"` +} + +type ExternalQuerySource_JobInfo struct { + // The canonical identifier for this job. + JobId *string `json:"job_id,omitempty"` + // The canonical identifier of the run. This ID is unique across all runs of all + // jobs. + JobRunId *string `json:"job_run_id,omitempty"` + // The canonical identifier of the task run. + JobTaskRunId *string `json:"job_task_run_id,omitempty"` +} + +// Fetches a list of queries conforming to the provided set of query filters. +// +// If the number of queries to return takes > 10 seconds, the request will +// timeout. In that case, please reduce the time range to ensure ListQueries +// conforms to the 10 second max query time limit.. +type ListQueriesRequest struct { + // An optional filter object to limit query history results. Accepts parameters + // such as user IDs, endpoint IDs, and statuses to narrow the returned data. In + // a URL, the parameters of this filter are specified with dot notation. For + // example: `filter_by.statement_ids`. + FilterBy *QueryFilter `json:"filter_by,omitempty"` + // Whether to include the query metrics with each query. Only use this for a + // small subset of queries (max_results). Defaults to false. + IncludeMetrics *bool `json:"include_metrics,omitempty"` + // Limit the number of results returned in one page. Must be less than 1000 and + // the default is 100. + MaxResults *int `json:"max_results,omitempty"` + // A token that can be used to get the next page of results. The token can + // contains characters that need to be encoded before using it in a URL. For + // example, the character '+' needs to be replaced by %2B. This field is + // optional. + PageToken *string `json:"page_token,omitempty"` +} + +type ListQueriesResponse struct { + // Whether there is another page of results. + HasNextPage *bool `json:"has_next_page,omitempty"` + // A token that can be used to get the next page of results. + NextPageToken *string `json:"next_page_token,omitempty"` + Res []QueryInfo `json:"res,omitempty"` +} + +type QueryFilter struct { + // A range filter for query submitted time. The time range must be less than or + // equal to 30 days. + QueryStartTimeRange *TimeRange `json:"query_start_time_range,omitempty"` + // A list of statement IDs. + StatementIds []string `json:"statement_ids,omitempty"` + // A list of statuses (QUEUED, RUNNING, CANCELED, FAILED, FINISHED) to match + // query results. Corresponds to the `status` field in the response. Filtering + // for multiple statuses is not recommended. Instead, opt to filter by a single + // status multiple times and then combine the results. + Statuses []QueryStatus `json:"statuses,omitempty"` + // A list of user IDs who ran the queries. + UserIds []int64 `json:"user_ids,omitempty"` + // A list of warehouse IDs. + WarehouseIds []string `json:"warehouse_ids,omitempty"` +} + +type QueryInfo struct { + // The ID of the cached query if this result retrieved from cache + CacheQueryId *string `json:"cache_query_id,omitempty"` + // SQL Warehouse channel information at the time of query execution + ChannelUsed *ChannelInfo `json:"channel_used,omitempty"` + // Client application that ran the statement. For example: Databricks SQL + // Editor, Tableau, and Power BI. This field is derived from information + // provided by client applications. While values are expected to remain static + // over time, this cannot be guaranteed. + ClientApplication *string `json:"client_application,omitempty"` + // Total time of the statement execution. This value does not include the time + // taken to retrieve the results, which can result in a discrepancy between this + // value and the start-to-finish wall-clock time. + Duration *int64 `json:"duration,omitempty"` + // Alias for `warehouse_id`. + EndpointId *string `json:"endpoint_id,omitempty"` + // Message describing why the query could not complete. + ErrorMessage *string `json:"error_message,omitempty"` + // The ID of the user whose credentials were used to run the query. + ExecutedAsUserId *int64 `json:"executed_as_user_id,omitempty"` + // The email address or username of the user whose credentials were used to run + // the query. + ExecutedAsUserName *string `json:"executed_as_user_name,omitempty"` + // The time execution of the query ended. + ExecutionEndTimeMs *int64 `json:"execution_end_time_ms,omitempty"` + // Whether more updates for the query are expected. + IsFinal *bool `json:"is_final,omitempty"` + // A key that can be used to look up query details. + LookupKey *string `json:"lookup_key,omitempty"` + // Metrics about query execution. + Metrics *QueryMetrics `json:"metrics,omitempty"` + // Whether plans exist for the execution, or the reason why they are missing + PlansState PlansState `json:"plans_state,omitempty"` + // The time the query ended. + QueryEndTimeMs *int64 `json:"query_end_time_ms,omitempty"` + // The query ID. + QueryId *string `json:"query_id,omitempty"` + // A struct that contains key-value pairs representing entities + // that were involved in the execution of this statement, such as jobs, + // notebooks, or dashboards. This field only records entities. + QuerySource *ExternalQuerySource `json:"query_source,omitempty"` + // The time the query started. + QueryStartTimeMs *int64 `json:"query_start_time_ms,omitempty"` + // A query execution can be optionally annotated with query tags + QueryTags []QueryTag `json:"query_tags,omitempty"` + // The text of the query. + QueryText *string `json:"query_text,omitempty"` + // The number of results returned by the query. + RowsProduced *int64 `json:"rows_produced,omitempty"` + // The spark session UUID that query ran on. This is either the Spark Connect, + // DBSQL, or SDP session ID. + SessionId *string `json:"session_id,omitempty"` + // URL to the Spark UI query plan. + SparkUiUrl *string `json:"spark_ui_url,omitempty"` + // Type of statement for this query + StatementType QueryStatementType `json:"statement_type,omitempty"` + // Query status with one the following values: - `QUEUED`: Query has been + // received and queued. - `RUNNING`: Query has started. - `CANCELED`: Query has + // been cancelled by the user. - `FAILED`: Query has failed. - `FINISHED`: Query + // has completed. + Status QueryStatus `json:"status,omitempty"` + // The ID of the user who ran the query. + UserId *int64 `json:"user_id,omitempty"` + // The email address or username of the user who ran the query. + UserName *string `json:"user_name,omitempty"` + // Warehouse ID. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +// A query metric that encapsulates a set of measurements for a single query. +// Metrics come from the driver and are stored in the history service database.. +type QueryMetrics struct { + // Time spent loading metadata and optimizing the query, in milliseconds. + CompilationTimeMs *int64 `json:"compilation_time_ms,omitempty"` + // Time spent executing the query, in milliseconds. + ExecutionTimeMs *int64 `json:"execution_time_ms,omitempty"` + // Total amount of data sent over the network between executor nodes during + // shuffle, in bytes. + NetworkSentBytes *int64 `json:"network_sent_bytes,omitempty"` + // Timestamp of when the query was enqueued waiting while the warehouse was at + // max load. This field is optional and will not appear if the query skipped the + // overloading queue. + OverloadingQueueStartTimestamp *int64 `json:"overloading_queue_start_timestamp,omitempty"` + // Total execution time for all individual Photon query engine tasks in the + // query, in milliseconds. + PhotonTotalTimeMs *int64 `json:"photon_total_time_ms,omitempty"` + // projected remaining work to be done aggregated across all stages in the + // query, in milliseconds + ProjectedRemainingTaskTotalTimeMs *int64 `json:"projected_remaining_task_total_time_ms,omitempty"` + // projected lower bound on remaining total task time based on + // projected_remaining_task_total_time_ms / maximum concurrency + ProjectedRemainingWallclockTimeMs *int64 `json:"projected_remaining_wallclock_time_ms,omitempty"` + // Timestamp of when the query was enqueued waiting for a cluster to be + // provisioned for the warehouse. This field is optional and will not appear if + // the query skipped the provisioning queue. + ProvisioningQueueStartTimestamp *int64 `json:"provisioning_queue_start_timestamp,omitempty"` + // Total number of file bytes in all tables not read due to pruning + PrunedBytes *int64 `json:"pruned_bytes,omitempty"` + // Total number of files from all tables not read due to pruning + PrunedFilesCount *int64 `json:"pruned_files_count,omitempty"` + // Timestamp of when the underlying compute started compilation of the query. + QueryCompilationStartTimestamp *int64 `json:"query_compilation_start_timestamp,omitempty"` + // Total size of data read by the query, in bytes. + ReadBytes *int64 `json:"read_bytes,omitempty"` + // Size of persistent data read from the cache, in bytes. + ReadCacheBytes *int64 `json:"read_cache_bytes,omitempty"` + // Total number of file bytes in all tables read + ReadFilesBytes *int64 `json:"read_files_bytes,omitempty"` + // Number of files read after pruning + ReadFilesCount *int64 `json:"read_files_count,omitempty"` + // Number of partitions read after pruning. + ReadPartitionsCount *int64 `json:"read_partitions_count,omitempty"` + // Size of persistent data read from cloud object storage on your cloud tenant, + // in bytes. + ReadRemoteBytes *int64 `json:"read_remote_bytes,omitempty"` + // number of remaining tasks to complete this is based on the current status and + // could be bigger or smaller in the future based on future updates + RemainingTaskCount *int64 `json:"remaining_task_count,omitempty"` + // Time spent fetching the query results after the execution finished, in + // milliseconds. + ResultFetchTimeMs *int64 `json:"result_fetch_time_ms,omitempty"` + // `true` if the query result was fetched from cache, `false` otherwise. + ResultFromCache *bool `json:"result_from_cache,omitempty"` + // Total number of rows returned by the query. + RowsProducedCount *int64 `json:"rows_produced_count,omitempty"` + // Total number of rows read by the query. + RowsReadCount *int64 `json:"rows_read_count,omitempty"` + // number of remaining tasks to complete, calculated by autoscaler + // StatementAnalysis.scala deprecated: use remaining_task_count instead + RunnableTasks *int64 `json:"runnable_tasks,omitempty"` + // Size of data temporarily written to disk while executing the query, in bytes. + SpillToDiskBytes *int64 `json:"spill_to_disk_bytes,omitempty"` + // sum of task times completed in a range of wall clock time, approximated to a + // configurable number of points aggregated over all stages and jobs in the + // query (based on task_total_time_ms) + TaskTimeOverTimeRange *TaskTimeOverRange `json:"task_time_over_time_range,omitempty"` + // Sum of execution time for all of the query’s tasks, in milliseconds. + TaskTotalTimeMs *int64 `json:"task_total_time_ms,omitempty"` + // Total execution time of the query from the client’s point of view, in + // milliseconds. + TotalTimeMs *int64 `json:"total_time_ms,omitempty"` + // remaining work to be done across all stages in the query, calculated by + // autoscaler StatementAnalysis.scala, in milliseconds deprecated: using + // projected_remaining_task_total_time_ms instead + WorkToBeDone *int64 `json:"work_to_be_done,omitempty"` + // Size pf persistent data written to cloud object storage in your cloud tenant, + // in bytes. + WriteRemoteBytes *int64 `json:"write_remote_bytes,omitempty"` +} + +// * A query execution can be annotated with an optional key-value pair to allow +// users to attribute the executions by key and optional value to filter by. +// QueryTag is the user-facing representation.. +type QueryTag struct { + Key *string `json:"key,omitempty"` + Value *string `json:"value,omitempty"` +} + +type TaskTimeOverRange struct { + Entries []TaskTimeOverRangeEntry `json:"entries,omitempty"` + // interval length for all entries (difference in start time and end time of an + // entry range) the same for all entries start time of first interval is + // query_start_time_ms + Interval *int64 `json:"interval,omitempty"` +} + +type TaskTimeOverRangeEntry struct { + // total task completion time in this time range, aggregated over all stages and + // jobs in the query + TaskCompletedTimeMs *int64 `json:"task_completed_time_ms,omitempty"` +} + +type TimeRange struct { + // The end time in milliseconds. + EndTimeMs *int64 `json:"end_time_ms,omitempty"` + // The start time in milliseconds. + StartTimeMs *int64 `json:"start_time_ms,omitempty"` +} + +// ChannelInfoToSDK converts the mirror to the sdk-go type. +func ChannelInfoToSDK(w *ChannelInfo) (*sdk.ChannelInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ChannelInfo{} + out.Name = w.Name + out.DbsqlVersion = w.DbsqlVersion + return out, nil +} + +// ChannelInfoFromSDK converts the sdk-go type to the mirror. +func ChannelInfoFromSDK(v *sdk.ChannelInfo) (*ChannelInfo, error) { + if v == nil { + return nil, nil + } + out := &ChannelInfo{} + out.Name = v.Name + out.DbsqlVersion = v.DbsqlVersion + return out, nil +} + +// ExternalQuerySourceToSDK converts the mirror to the sdk-go type. +func ExternalQuerySourceToSDK(w *ExternalQuerySource) (*sdk.ExternalQuerySource, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalQuerySource{} + out.DashboardId = w.DashboardId + out.LegacyDashboardId = w.LegacyDashboardId + out.AlertId = w.AlertId + out.NotebookId = w.NotebookId + out.SqlQueryId = w.SqlQueryId + conv1, err := ExternalQuerySource_JobInfoToSDK(w.JobInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalQuerySource.JobInfo", err) + } + out.JobInfo = conv1 + out.GenieSpaceId = w.GenieSpaceId + return out, nil +} + +// ExternalQuerySourceFromSDK converts the sdk-go type to the mirror. +func ExternalQuerySourceFromSDK(v *sdk.ExternalQuerySource) (*ExternalQuerySource, error) { + if v == nil { + return nil, nil + } + out := &ExternalQuerySource{} + out.DashboardId = v.DashboardId + out.LegacyDashboardId = v.LegacyDashboardId + out.AlertId = v.AlertId + out.NotebookId = v.NotebookId + out.SqlQueryId = v.SqlQueryId + conv2, err := ExternalQuerySource_JobInfoFromSDK(v.JobInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalQuerySource.JobInfo", err) + } + out.JobInfo = conv2 + out.GenieSpaceId = v.GenieSpaceId + return out, nil +} + +// ExternalQuerySource_JobInfoToSDK converts the mirror to the sdk-go type. +func ExternalQuerySource_JobInfoToSDK(w *ExternalQuerySource_JobInfo) (*sdk.ExternalQuerySource_JobInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalQuerySource_JobInfo{} + out.JobId = w.JobId + out.JobRunId = w.JobRunId + out.JobTaskRunId = w.JobTaskRunId + return out, nil +} + +// ExternalQuerySource_JobInfoFromSDK converts the sdk-go type to the mirror. +func ExternalQuerySource_JobInfoFromSDK(v *sdk.ExternalQuerySource_JobInfo) (*ExternalQuerySource_JobInfo, error) { + if v == nil { + return nil, nil + } + out := &ExternalQuerySource_JobInfo{} + out.JobId = v.JobId + out.JobRunId = v.JobRunId + out.JobTaskRunId = v.JobTaskRunId + return out, nil +} + +// ListQueriesRequestToSDK converts the mirror to the sdk-go type. +func ListQueriesRequestToSDK(w *ListQueriesRequest) (*sdk.ListQueriesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListQueriesRequest{} + conv3, err := QueryFilterToSDK(w.FilterBy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListQueriesRequest.FilterBy", err) + } + out.FilterBy = conv3 + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + out.IncludeMetrics = w.IncludeMetrics + return out, nil +} + +// ListQueriesRequestFromSDK converts the sdk-go type to the mirror. +func ListQueriesRequestFromSDK(v *sdk.ListQueriesRequest) (*ListQueriesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListQueriesRequest{} + conv4, err := QueryFilterFromSDK(v.FilterBy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListQueriesRequest.FilterBy", err) + } + out.FilterBy = conv4 + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + out.IncludeMetrics = v.IncludeMetrics + return out, nil +} + +// ListQueriesResponseToSDK converts the mirror to the sdk-go type. +func ListQueriesResponseToSDK(w *ListQueriesResponse) (*sdk.ListQueriesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListQueriesResponse{} + out.NextPageToken = w.NextPageToken + out.HasNextPage = w.HasNextPage + conv5, err := convertSlice(w.Res, QueryInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListQueriesResponse.Res", err) + } + out.Res = conv5 + return out, nil +} + +// ListQueriesResponseFromSDK converts the sdk-go type to the mirror. +func ListQueriesResponseFromSDK(v *sdk.ListQueriesResponse) (*ListQueriesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListQueriesResponse{} + out.NextPageToken = v.NextPageToken + out.HasNextPage = v.HasNextPage + conv6, err := convertSlice(v.Res, QueryInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListQueriesResponse.Res", err) + } + out.Res = conv6 + return out, nil +} + +// QueryFilterToSDK converts the mirror to the sdk-go type. +func QueryFilterToSDK(w *QueryFilter) (*sdk.QueryFilter, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryFilter{} + conv7, err := TimeRangeToSDK(w.QueryStartTimeRange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryFilter.QueryStartTimeRange", err) + } + out.QueryStartTimeRange = conv7 + out.UserIds = w.UserIds + out.Statuses = w.Statuses + out.WarehouseIds = w.WarehouseIds + out.StatementIds = w.StatementIds + return out, nil +} + +// QueryFilterFromSDK converts the sdk-go type to the mirror. +func QueryFilterFromSDK(v *sdk.QueryFilter) (*QueryFilter, error) { + if v == nil { + return nil, nil + } + out := &QueryFilter{} + conv8, err := TimeRangeFromSDK(v.QueryStartTimeRange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryFilter.QueryStartTimeRange", err) + } + out.QueryStartTimeRange = conv8 + out.UserIds = v.UserIds + out.Statuses = v.Statuses + out.WarehouseIds = v.WarehouseIds + out.StatementIds = v.StatementIds + return out, nil +} + +// QueryInfoToSDK converts the mirror to the sdk-go type. +func QueryInfoToSDK(w *QueryInfo) (*sdk.QueryInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryInfo{} + out.QueryId = w.QueryId + out.Status = w.Status + out.QueryText = w.QueryText + out.QueryStartTimeMs = w.QueryStartTimeMs + out.ExecutionEndTimeMs = w.ExecutionEndTimeMs + out.QueryEndTimeMs = w.QueryEndTimeMs + out.UserId = w.UserId + out.UserName = w.UserName + out.SparkUiUrl = w.SparkUiUrl + out.EndpointId = w.EndpointId + out.RowsProduced = w.RowsProduced + out.ErrorMessage = w.ErrorMessage + out.LookupKey = w.LookupKey + conv9, err := QueryMetricsToSDK(w.Metrics) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryInfo.Metrics", err) + } + out.Metrics = conv9 + out.ExecutedAsUserId = w.ExecutedAsUserId + out.ExecutedAsUserName = w.ExecutedAsUserName + out.SessionId = w.SessionId + out.IsFinal = w.IsFinal + conv10, err := ChannelInfoToSDK(w.ChannelUsed) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryInfo.ChannelUsed", err) + } + out.ChannelUsed = conv10 + out.PlansState = w.PlansState + out.StatementType = w.StatementType + out.WarehouseId = w.WarehouseId + out.Duration = w.Duration + out.ClientApplication = w.ClientApplication + conv11, err := ExternalQuerySourceToSDK(w.QuerySource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryInfo.QuerySource", err) + } + out.QuerySource = conv11 + out.CacheQueryId = w.CacheQueryId + conv12, err := convertSlice(w.QueryTags, QueryTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryInfo.QueryTags", err) + } + out.QueryTags = conv12 + return out, nil +} + +// QueryInfoFromSDK converts the sdk-go type to the mirror. +func QueryInfoFromSDK(v *sdk.QueryInfo) (*QueryInfo, error) { + if v == nil { + return nil, nil + } + out := &QueryInfo{} + out.QueryId = v.QueryId + out.Status = v.Status + out.QueryText = v.QueryText + out.QueryStartTimeMs = v.QueryStartTimeMs + out.ExecutionEndTimeMs = v.ExecutionEndTimeMs + out.QueryEndTimeMs = v.QueryEndTimeMs + out.UserId = v.UserId + out.UserName = v.UserName + out.SparkUiUrl = v.SparkUiUrl + out.EndpointId = v.EndpointId + out.RowsProduced = v.RowsProduced + out.ErrorMessage = v.ErrorMessage + out.LookupKey = v.LookupKey + conv13, err := QueryMetricsFromSDK(v.Metrics) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryInfo.Metrics", err) + } + out.Metrics = conv13 + out.ExecutedAsUserId = v.ExecutedAsUserId + out.ExecutedAsUserName = v.ExecutedAsUserName + out.SessionId = v.SessionId + out.IsFinal = v.IsFinal + conv14, err := ChannelInfoFromSDK(v.ChannelUsed) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryInfo.ChannelUsed", err) + } + out.ChannelUsed = conv14 + out.PlansState = v.PlansState + out.StatementType = v.StatementType + out.WarehouseId = v.WarehouseId + out.Duration = v.Duration + out.ClientApplication = v.ClientApplication + conv15, err := ExternalQuerySourceFromSDK(v.QuerySource) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryInfo.QuerySource", err) + } + out.QuerySource = conv15 + out.CacheQueryId = v.CacheQueryId + conv16, err := convertSlice(v.QueryTags, QueryTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryInfo.QueryTags", err) + } + out.QueryTags = conv16 + return out, nil +} + +// QueryMetricsToSDK converts the mirror to the sdk-go type. +func QueryMetricsToSDK(w *QueryMetrics) (*sdk.QueryMetrics, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryMetrics{} + out.TotalTimeMs = w.TotalTimeMs + out.ReadBytes = w.ReadBytes + out.RowsProducedCount = w.RowsProducedCount + out.CompilationTimeMs = w.CompilationTimeMs + out.ExecutionTimeMs = w.ExecutionTimeMs + out.ReadRemoteBytes = w.ReadRemoteBytes + out.WriteRemoteBytes = w.WriteRemoteBytes + out.ReadCacheBytes = w.ReadCacheBytes + out.SpillToDiskBytes = w.SpillToDiskBytes + out.TaskTotalTimeMs = w.TaskTotalTimeMs + out.ReadFilesCount = w.ReadFilesCount + out.ReadPartitionsCount = w.ReadPartitionsCount + out.PhotonTotalTimeMs = w.PhotonTotalTimeMs + out.RowsReadCount = w.RowsReadCount + out.ResultFetchTimeMs = w.ResultFetchTimeMs + out.NetworkSentBytes = w.NetworkSentBytes + out.ResultFromCache = w.ResultFromCache + out.PrunedBytes = w.PrunedBytes + out.PrunedFilesCount = w.PrunedFilesCount + out.ProvisioningQueueStartTimestamp = w.ProvisioningQueueStartTimestamp + out.OverloadingQueueStartTimestamp = w.OverloadingQueueStartTimestamp + out.QueryCompilationStartTimestamp = w.QueryCompilationStartTimestamp + conv17, err := TaskTimeOverRangeToSDK(w.TaskTimeOverTimeRange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryMetrics.TaskTimeOverTimeRange", err) + } + out.TaskTimeOverTimeRange = conv17 + out.WorkToBeDone = w.WorkToBeDone + out.RunnableTasks = w.RunnableTasks + out.ProjectedRemainingTaskTotalTimeMs = w.ProjectedRemainingTaskTotalTimeMs + out.RemainingTaskCount = w.RemainingTaskCount + out.ProjectedRemainingWallclockTimeMs = w.ProjectedRemainingWallclockTimeMs + out.ReadFilesBytes = w.ReadFilesBytes + return out, nil +} + +// QueryMetricsFromSDK converts the sdk-go type to the mirror. +func QueryMetricsFromSDK(v *sdk.QueryMetrics) (*QueryMetrics, error) { + if v == nil { + return nil, nil + } + out := &QueryMetrics{} + out.TotalTimeMs = v.TotalTimeMs + out.ReadBytes = v.ReadBytes + out.RowsProducedCount = v.RowsProducedCount + out.CompilationTimeMs = v.CompilationTimeMs + out.ExecutionTimeMs = v.ExecutionTimeMs + out.ReadRemoteBytes = v.ReadRemoteBytes + out.WriteRemoteBytes = v.WriteRemoteBytes + out.ReadCacheBytes = v.ReadCacheBytes + out.SpillToDiskBytes = v.SpillToDiskBytes + out.TaskTotalTimeMs = v.TaskTotalTimeMs + out.ReadFilesCount = v.ReadFilesCount + out.ReadPartitionsCount = v.ReadPartitionsCount + out.PhotonTotalTimeMs = v.PhotonTotalTimeMs + out.RowsReadCount = v.RowsReadCount + out.ResultFetchTimeMs = v.ResultFetchTimeMs + out.NetworkSentBytes = v.NetworkSentBytes + out.ResultFromCache = v.ResultFromCache + out.PrunedBytes = v.PrunedBytes + out.PrunedFilesCount = v.PrunedFilesCount + out.ProvisioningQueueStartTimestamp = v.ProvisioningQueueStartTimestamp + out.OverloadingQueueStartTimestamp = v.OverloadingQueueStartTimestamp + out.QueryCompilationStartTimestamp = v.QueryCompilationStartTimestamp + conv18, err := TaskTimeOverRangeFromSDK(v.TaskTimeOverTimeRange) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryMetrics.TaskTimeOverTimeRange", err) + } + out.TaskTimeOverTimeRange = conv18 + out.WorkToBeDone = v.WorkToBeDone + out.RunnableTasks = v.RunnableTasks + out.ProjectedRemainingTaskTotalTimeMs = v.ProjectedRemainingTaskTotalTimeMs + out.RemainingTaskCount = v.RemainingTaskCount + out.ProjectedRemainingWallclockTimeMs = v.ProjectedRemainingWallclockTimeMs + out.ReadFilesBytes = v.ReadFilesBytes + return out, nil +} + +// QueryTagToSDK converts the mirror to the sdk-go type. +func QueryTagToSDK(w *QueryTag) (*sdk.QueryTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// QueryTagFromSDK converts the sdk-go type to the mirror. +func QueryTagFromSDK(v *sdk.QueryTag) (*QueryTag, error) { + if v == nil { + return nil, nil + } + out := &QueryTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// TaskTimeOverRangeToSDK converts the mirror to the sdk-go type. +func TaskTimeOverRangeToSDK(w *TaskTimeOverRange) (*sdk.TaskTimeOverRange, error) { + if w == nil { + return nil, nil + } + out := &sdk.TaskTimeOverRange{} + conv19, err := convertSlice(w.Entries, TaskTimeOverRangeEntryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskTimeOverRange.Entries", err) + } + out.Entries = conv19 + out.Interval = w.Interval + return out, nil +} + +// TaskTimeOverRangeFromSDK converts the sdk-go type to the mirror. +func TaskTimeOverRangeFromSDK(v *sdk.TaskTimeOverRange) (*TaskTimeOverRange, error) { + if v == nil { + return nil, nil + } + out := &TaskTimeOverRange{} + conv20, err := convertSlice(v.Entries, TaskTimeOverRangeEntryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TaskTimeOverRange.Entries", err) + } + out.Entries = conv20 + out.Interval = v.Interval + return out, nil +} + +// TaskTimeOverRangeEntryToSDK converts the mirror to the sdk-go type. +func TaskTimeOverRangeEntryToSDK(w *TaskTimeOverRangeEntry) (*sdk.TaskTimeOverRangeEntry, error) { + if w == nil { + return nil, nil + } + out := &sdk.TaskTimeOverRangeEntry{} + out.TaskCompletedTimeMs = w.TaskCompletedTimeMs + return out, nil +} + +// TaskTimeOverRangeEntryFromSDK converts the sdk-go type to the mirror. +func TaskTimeOverRangeEntryFromSDK(v *sdk.TaskTimeOverRangeEntry) (*TaskTimeOverRangeEntry, error) { + if v == nil { + return nil, nil + } + out := &TaskTimeOverRangeEntry{} + out.TaskCompletedTimeMs = v.TaskCompletedTimeMs + return out, nil +} + +// TimeRangeToSDK converts the mirror to the sdk-go type. +func TimeRangeToSDK(w *TimeRange) (*sdk.TimeRange, error) { + if w == nil { + return nil, nil + } + out := &sdk.TimeRange{} + out.StartTimeMs = w.StartTimeMs + out.EndTimeMs = w.EndTimeMs + return out, nil +} + +// TimeRangeFromSDK converts the sdk-go type to the mirror. +func TimeRangeFromSDK(v *sdk.TimeRange) (*TimeRange, error) { + if v == nil { + return nil, nil + } + out := &TimeRange{} + out.StartTimeMs = v.StartTimeMs + out.EndTimeMs = v.EndTimeMs + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/repos/v1/types.generated.go b/libs/sdktypes/repos/v1/types.generated.go new file mode 100644 index 00000000000..6f8fce708b0 --- /dev/null +++ b/libs/sdktypes/repos/v1/types.generated.go @@ -0,0 +1,459 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/repos/v1. DO NOT EDIT. + +package repos + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/repos/v1" +) + +type CreateRepoRequest struct { + // Git credential ID to use when cloning the repository. The Git credential must + // be configured for the current user. + GitCredentialId *int64 `json:"git_credential_id,omitempty"` + // Desired path for the repo in the workspace. Almost any path in the workspace + // can be chosen. If repo is created in `/Repos`, path must be in the format + // `/Repos/{folder}/{repo-name}`. + Path *string `json:"path,omitempty"` + // Git provider. This field is case-insensitive. The available Git providers are + // `gitHub`, `bitbucketCloud`, `gitLab`, `azureDevOpsServices` (Azure DevOps + // Services, including Microsoft Entra ID authentication), `gitHubEnterprise`, + // `bitbucketServer` (Bitbucket Data Center), `gitLabEnterpriseEdition` (GitLab + // Self-Managed), and `awsCodeCommit`. + Provider *string `json:"provider,omitempty"` + // If specified, the repo will be created with sparse checkout enabled. You + // cannot enable/disable sparse checkout after the repo is created. + SparseCheckout *SparseCheckout `json:"sparse_checkout,omitempty"` + // URL of the Git repository to be linked. + Url *string `json:"url,omitempty"` +} + +type CreateRepoResponse struct { + // Branch that the Git folder (repo) is checked out to. + Branch *string `json:"branch,omitempty"` + // SHA-1 hash representing the commit ID of the current HEAD of the Git folder + // (repo). + HeadCommitId *string `json:"head_commit_id,omitempty"` + // ID of the Git folder (repo) object in the workspace. + Id *int64 `json:"id,omitempty"` + // Path of the Git folder (repo) in the workspace. + Path *string `json:"path,omitempty"` + // Git provider of the linked Git repository, e.g. `gitHub`, + // `azureDevOpsServices`, `bitbucketServer` (Bitbucket Data Center), + // `gitLabEnterpriseEdition` (GitLab Self-Managed), or `awsCodeCommit`. + Provider *string `json:"provider,omitempty"` + // Sparse checkout settings for the Git folder (repo). + SparseCheckout *SparseCheckout `json:"sparse_checkout,omitempty"` + // URL of the linked Git repository. + Url *string `json:"url,omitempty"` +} + +type GetRepoResponse struct { + // Branch that the local version of the repo is checked out to. + Branch *string `json:"branch,omitempty"` + // Whether the Git CLI is enabled for this Git folder (repo). When true, Git + // commands can be run directly against this Git folder using the Git CLI. + GitCliEnabled *bool `json:"git_cli_enabled,omitempty"` + // SHA-1 hash representing the commit ID of the current HEAD of the repo. + HeadCommitId *string `json:"head_commit_id,omitempty"` + // ID of the Git folder (repo) object in the workspace. + Id *int64 `json:"id,omitempty"` + // Path of the Git folder (repo) in the workspace. + Path *string `json:"path,omitempty"` + // Git provider of the linked Git repository, e.g. `gitHub`, + // `azureDevOpsServices`, `bitbucketServer` (Bitbucket Data Center), + // `gitLabEnterpriseEdition` (GitLab Self-Managed), or `awsCodeCommit`. + Provider *string `json:"provider,omitempty"` + // Sparse checkout settings for the Git folder (repo). + SparseCheckout *SparseCheckout `json:"sparse_checkout,omitempty"` + // URL of the linked Git repository. + Url *string `json:"url,omitempty"` +} + +type ListReposRequest struct { + // Token used to get the next page of results. If not specified, returns the + // first page of results as well as a next page token if there are more results. + NextPageToken *string `json:"next_page_token,omitempty"` + // Filters repos that have paths starting with the given path prefix. If not + // provided or when provided an effectively empty prefix (`/` or `/Workspace`) + // Git folders (repos) from `/Workspace/Repos` will be served. + PathPrefix *string `json:"path_prefix,omitempty"` +} + +type ListReposResponse struct { + // Token that can be specified as a query parameter to the `GET /repos` endpoint + // to retrieve the next page of results. + NextPageToken *string `json:"next_page_token,omitempty"` + // List of Git folders (repos). + Repos []RepoInfo `json:"repos,omitempty"` +} + +// Git folder (repo) information.. +type RepoInfo struct { + // Name of the current git branch of the git folder (repo). + Branch *string `json:"branch,omitempty"` + // Current git commit id of the git folder (repo). + HeadCommitId *string `json:"head_commit_id,omitempty"` + // Id of the git folder (repo) in the Workspace. + Id *int64 `json:"id,omitempty"` + // Root path of the git folder (repo) in the Workspace. + Path *string `json:"path,omitempty"` + // Git provider of the remote git repository, e.g. `gitHub`, + // `azureDevOpsServices`, `bitbucketServer` (Bitbucket Data Center), + // `gitLabEnterpriseEdition` (GitLab Self-Managed), or `awsCodeCommit`. + Provider *string `json:"provider,omitempty"` + // Sparse checkout config for the git folder (repo). + SparseCheckout *SparseCheckout `json:"sparse_checkout,omitempty"` + // URL of the remote git repository. + Url *string `json:"url,omitempty"` +} + +// Sparse checkout configuration, it contains options like cone patterns.. +type SparseCheckout struct { + // List of sparse checkout cone patterns, see [cone mode handling] for details. + // + // [cone mode handling]: https://git-scm.com/docs/git-sparse-checkout#_internalscone_mode_handling + Patterns []string `json:"patterns,omitempty"` +} + +// Sparse checkout configuration, it contains options like cone patterns.. +type SparseCheckoutUpdate struct { + // List of sparse checkout cone patterns, see [cone mode handling] for details. + // + // [cone mode handling]: https://git-scm.com/docs/git-sparse-checkout#_internalscone_mode_handling + Patterns []string `json:"patterns,omitempty"` +} + +type UpdateRepoRequest struct { + // Branch that the local version of the repo is checked out to. + Branch *string `json:"branch,omitempty"` + // WARNING: DESTRUCTIVE AND IRREVERSIBLE. If true, permanently deletes ALL + // uncommitted changes in the Git folder — staged, unstaged, and untracked + // files — before updating. Lost data CANNOT be recovered. + // + // NEVER use this on Git folders where users author or edit files. This flag is + // intended ONLY for automated jobs that treat the Git folder as a read-only + // mirror of a remote branch and need to force-sync it. If any user has + // uncommitted work in the Git folder, that work will be permanently destroyed + // without warning. + // + // Local commits that have been made but not yet pushed to the remote are + // preserved. + DangerouslyForceDiscardAll *bool `json:"dangerously_force_discard_all,omitempty"` + // Git credential ID to use for this update operation. The Git credential must + // be configured for the current user. + GitCredentialId *int64 `json:"git_credential_id,omitempty"` + // ID of the Git folder (repo) object in the workspace. + Id *int64 `json:"id,omitempty"` + // If specified, update the sparse checkout settings. The update will fail if + // sparse checkout is not enabled for the repo. + SparseCheckout *SparseCheckoutUpdate `json:"sparse_checkout,omitempty"` + // Tag that the local version of the repo is checked out to. Updating the repo + // to a tag puts the repo in a detached HEAD state. Before committing new + // changes, you must update the repo to a branch instead of the detached HEAD. + Tag *string `json:"tag,omitempty"` +} + +// CreateRepoRequestToSDK converts the mirror to the sdk-go type. +func CreateRepoRequestToSDK(w *CreateRepoRequest) (*sdk.CreateRepoRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRepoRequest{} + out.Url = w.Url + out.Provider = w.Provider + out.Path = w.Path + conv1, err := SparseCheckoutToSDK(w.SparseCheckout) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRepoRequest.SparseCheckout", err) + } + out.SparseCheckout = conv1 + out.GitCredentialId = w.GitCredentialId + return out, nil +} + +// CreateRepoRequestFromSDK converts the sdk-go type to the mirror. +func CreateRepoRequestFromSDK(v *sdk.CreateRepoRequest) (*CreateRepoRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateRepoRequest{} + out.Url = v.Url + out.Provider = v.Provider + out.Path = v.Path + conv2, err := SparseCheckoutFromSDK(v.SparseCheckout) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRepoRequest.SparseCheckout", err) + } + out.SparseCheckout = conv2 + out.GitCredentialId = v.GitCredentialId + return out, nil +} + +// CreateRepoResponseToSDK converts the mirror to the sdk-go type. +func CreateRepoResponseToSDK(w *CreateRepoResponse) (*sdk.CreateRepoResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRepoResponse{} + out.Id = w.Id + out.Path = w.Path + out.Url = w.Url + out.Provider = w.Provider + out.Branch = w.Branch + out.HeadCommitId = w.HeadCommitId + conv3, err := SparseCheckoutToSDK(w.SparseCheckout) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRepoResponse.SparseCheckout", err) + } + out.SparseCheckout = conv3 + return out, nil +} + +// CreateRepoResponseFromSDK converts the sdk-go type to the mirror. +func CreateRepoResponseFromSDK(v *sdk.CreateRepoResponse) (*CreateRepoResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateRepoResponse{} + out.Id = v.Id + out.Path = v.Path + out.Url = v.Url + out.Provider = v.Provider + out.Branch = v.Branch + out.HeadCommitId = v.HeadCommitId + conv4, err := SparseCheckoutFromSDK(v.SparseCheckout) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRepoResponse.SparseCheckout", err) + } + out.SparseCheckout = conv4 + return out, nil +} + +// GetRepoResponseToSDK converts the mirror to the sdk-go type. +func GetRepoResponseToSDK(w *GetRepoResponse) (*sdk.GetRepoResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetRepoResponse{} + out.Id = w.Id + out.Path = w.Path + out.Url = w.Url + out.Provider = w.Provider + out.Branch = w.Branch + out.HeadCommitId = w.HeadCommitId + conv5, err := SparseCheckoutToSDK(w.SparseCheckout) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRepoResponse.SparseCheckout", err) + } + out.SparseCheckout = conv5 + out.GitCliEnabled = w.GitCliEnabled + return out, nil +} + +// GetRepoResponseFromSDK converts the sdk-go type to the mirror. +func GetRepoResponseFromSDK(v *sdk.GetRepoResponse) (*GetRepoResponse, error) { + if v == nil { + return nil, nil + } + out := &GetRepoResponse{} + out.Id = v.Id + out.Path = v.Path + out.Url = v.Url + out.Provider = v.Provider + out.Branch = v.Branch + out.HeadCommitId = v.HeadCommitId + conv6, err := SparseCheckoutFromSDK(v.SparseCheckout) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRepoResponse.SparseCheckout", err) + } + out.SparseCheckout = conv6 + out.GitCliEnabled = v.GitCliEnabled + return out, nil +} + +// ListReposRequestToSDK converts the mirror to the sdk-go type. +func ListReposRequestToSDK(w *ListReposRequest) (*sdk.ListReposRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListReposRequest{} + out.PathPrefix = w.PathPrefix + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListReposRequestFromSDK converts the sdk-go type to the mirror. +func ListReposRequestFromSDK(v *sdk.ListReposRequest) (*ListReposRequest, error) { + if v == nil { + return nil, nil + } + out := &ListReposRequest{} + out.PathPrefix = v.PathPrefix + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListReposResponseToSDK converts the mirror to the sdk-go type. +func ListReposResponseToSDK(w *ListReposResponse) (*sdk.ListReposResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListReposResponse{} + conv7, err := convertSlice(w.Repos, RepoInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListReposResponse.Repos", err) + } + out.Repos = conv7 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListReposResponseFromSDK converts the sdk-go type to the mirror. +func ListReposResponseFromSDK(v *sdk.ListReposResponse) (*ListReposResponse, error) { + if v == nil { + return nil, nil + } + out := &ListReposResponse{} + conv8, err := convertSlice(v.Repos, RepoInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListReposResponse.Repos", err) + } + out.Repos = conv8 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// RepoInfoToSDK converts the mirror to the sdk-go type. +func RepoInfoToSDK(w *RepoInfo) (*sdk.RepoInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.RepoInfo{} + out.Id = w.Id + out.Path = w.Path + out.Url = w.Url + out.Provider = w.Provider + out.Branch = w.Branch + out.HeadCommitId = w.HeadCommitId + conv9, err := SparseCheckoutToSDK(w.SparseCheckout) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RepoInfo.SparseCheckout", err) + } + out.SparseCheckout = conv9 + return out, nil +} + +// RepoInfoFromSDK converts the sdk-go type to the mirror. +func RepoInfoFromSDK(v *sdk.RepoInfo) (*RepoInfo, error) { + if v == nil { + return nil, nil + } + out := &RepoInfo{} + out.Id = v.Id + out.Path = v.Path + out.Url = v.Url + out.Provider = v.Provider + out.Branch = v.Branch + out.HeadCommitId = v.HeadCommitId + conv10, err := SparseCheckoutFromSDK(v.SparseCheckout) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RepoInfo.SparseCheckout", err) + } + out.SparseCheckout = conv10 + return out, nil +} + +// SparseCheckoutToSDK converts the mirror to the sdk-go type. +func SparseCheckoutToSDK(w *SparseCheckout) (*sdk.SparseCheckout, error) { + if w == nil { + return nil, nil + } + out := &sdk.SparseCheckout{} + out.Patterns = w.Patterns + return out, nil +} + +// SparseCheckoutFromSDK converts the sdk-go type to the mirror. +func SparseCheckoutFromSDK(v *sdk.SparseCheckout) (*SparseCheckout, error) { + if v == nil { + return nil, nil + } + out := &SparseCheckout{} + out.Patterns = v.Patterns + return out, nil +} + +// SparseCheckoutUpdateToSDK converts the mirror to the sdk-go type. +func SparseCheckoutUpdateToSDK(w *SparseCheckoutUpdate) (*sdk.SparseCheckoutUpdate, error) { + if w == nil { + return nil, nil + } + out := &sdk.SparseCheckoutUpdate{} + out.Patterns = w.Patterns + return out, nil +} + +// SparseCheckoutUpdateFromSDK converts the sdk-go type to the mirror. +func SparseCheckoutUpdateFromSDK(v *sdk.SparseCheckoutUpdate) (*SparseCheckoutUpdate, error) { + if v == nil { + return nil, nil + } + out := &SparseCheckoutUpdate{} + out.Patterns = v.Patterns + return out, nil +} + +// UpdateRepoRequestToSDK converts the mirror to the sdk-go type. +func UpdateRepoRequestToSDK(w *UpdateRepoRequest) (*sdk.UpdateRepoRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRepoRequest{} + out.Id = w.Id + out.Branch = w.Branch + out.Tag = w.Tag + conv11, err := SparseCheckoutUpdateToSDK(w.SparseCheckout) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRepoRequest.SparseCheckout", err) + } + out.SparseCheckout = conv11 + out.DangerouslyForceDiscardAll = w.DangerouslyForceDiscardAll + out.GitCredentialId = w.GitCredentialId + return out, nil +} + +// UpdateRepoRequestFromSDK converts the sdk-go type to the mirror. +func UpdateRepoRequestFromSDK(v *sdk.UpdateRepoRequest) (*UpdateRepoRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateRepoRequest{} + out.Id = v.Id + out.Branch = v.Branch + out.Tag = v.Tag + conv12, err := SparseCheckoutUpdateFromSDK(v.SparseCheckout) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRepoRequest.SparseCheckout", err) + } + out.SparseCheckout = conv12 + out.DangerouslyForceDiscardAll = v.DangerouslyForceDiscardAll + out.GitCredentialId = v.GitCredentialId + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/sandbox/v1/types.generated.go b/libs/sdktypes/sandbox/v1/types.generated.go new file mode 100644 index 00000000000..969a3bf422f --- /dev/null +++ b/libs/sdktypes/sandbox/v1/types.generated.go @@ -0,0 +1,674 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/sandbox/v1. DO NOT EDIT. + +package sandbox + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/sandbox/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + ExecuteCommandStatus = sdk.ExecuteCommandStatus + SandboxState = sdk.SandboxState +) + +const ( + ExecuteCommandStatus_Unspecified = sdk.ExecuteCommandStatus_Unspecified + ExecuteCommandStatus_ExecuteCommandStatusCompleted = sdk.ExecuteCommandStatus_ExecuteCommandStatusCompleted + ExecuteCommandStatus_ExecuteCommandStatusTimedOut = sdk.ExecuteCommandStatus_ExecuteCommandStatusTimedOut + ExecuteCommandStatus_ExecuteCommandStatusFailed = sdk.ExecuteCommandStatus_ExecuteCommandStatusFailed + SandboxState_Unspecified = sdk.SandboxState_Unspecified + SandboxState_SandboxStatePending = sdk.SandboxState_SandboxStatePending + SandboxState_SandboxStateRunning = sdk.SandboxState_SandboxStateRunning + SandboxState_SandboxStateStopped = sdk.SandboxState_SandboxStateStopped + SandboxState_SandboxStateStopping = sdk.SandboxState_SandboxStateStopping +) + +// A single command execution.. +type Command struct { + // Arguments passed to the program. + Args []string `json:"args,omitempty"` + // The program that was executed. + Cmd *string `json:"cmd,omitempty"` + // Stable identifier for this command. + CommandId *string `json:"command_id,omitempty"` + // Process exit code. Only present when finished is true and the process exited + // normally (not killed by signal or failed to start). + ExitCode *int `json:"exit_code,omitempty"` + // Whether the command has finished executing. + Finished *bool `json:"finished,omitempty"` + // PID of the spawned process. Absent if the process failed to start. + Pid *int64 `json:"pid,omitempty"` +} + +type ComputeSpec struct { + // Idle duration after which the sandbox is automatically terminated. + InactivityTimeout *types.Duration `json:"inactivity_timeout,omitempty"` +} + +// A request to create a Sandbox.. +type CreateSandboxRequest struct { + // The sandbox to create. + Sandbox *Sandbox `json:"sandbox,omitempty"` + // Client-supplied ID that becomes the final path segment of the resource name. + SandboxId *string `json:"sandbox_id,omitempty"` +} + +type EnvironmentSpec struct { + // A Unity Catalog container artifact (e.g. `catalog.schema.folder.image:tag`) + // to run as the sandbox environment. When set, this image is used as the + // environment instead of resolving a managed image from `environment_version`. + ImageUri *string `json:"image_uri,omitempty"` +} + +// Request to run a command in the given sandbox and wait for it to finish.. +type ExecuteCommandSyncRequest struct { + // Arguments passed to `cmd`. + Args []string `json:"args,omitempty"` + // Executable or command to run (e.g. `/bin/echo`, `python3`). + Cmd *string `json:"cmd,omitempty"` + // Extra environment variables for the command's process, merged over the + // sandbox's default environment. + Envs map[string]string `json:"envs,omitempty"` + // Maximum time to wait for the command to finish. When it elapses the command + // is terminated and the response carries status `TIMED_OUT`. The server applies + // a default when unset and clamps to an upper bound; negative or otherwise + // invalid durations are rejected with `INVALID_ARGUMENT`. + ExecutionTimeout *types.Duration `json:"execution_timeout,omitempty"` + // Resource name of the sandbox to run the command in, in the form + // `sandboxes/{sandbox_id}`. Bound from the URL path. + Name *string `json:"name,omitempty"` +} + +// Result of a completed unary command execution: captured output, exit code, +// and terminal status.. +type ExecuteCommandSyncResponse struct { + // Daemon-generated identifier for this command execution, for correlation (for + // example in `ListCommands`). + CommandId *string `json:"command_id,omitempty"` + // Process exit code. Unset when the process was terminated by a signal (e.g. on + // `TIMED_OUT`) or never started (`FAILED`) rather than exiting normally. + ExitCode *int `json:"exit_code,omitempty"` + // Terminal status of the command execution. Always set on a successful + // response; never `EXECUTE_COMMAND_STATUS_UNSPECIFIED`. + Status ExecuteCommandStatus `json:"status,omitempty"` + // Captured standard error, with the same UTF-8 semantics as `stdout`. + Stderr *string `json:"stderr,omitempty"` + // Captured standard output as UTF-8 text. Invalid UTF-8 bytes are replaced with + // the Unicode replacement character (U+FFFD). + Stdout *string `json:"stdout,omitempty"` + // True when `stdout` / `stderr` were truncated because the captured output + // exceeded the server's per-response size cap. The dropped output is not + // included in this response and is not recoverable through this unary API. + Truncated *bool `json:"truncated,omitempty"` +} + +// Request to list tracked command executions.. +type ListCommandsRequest struct { + // Maximum number of commands to return. The server may return fewer. If + // unspecified, the server returns all commands. + PageSize *int `json:"page_size,omitempty"` + // Page token returned by a previous ListCommands call. Use this to retrieve the + // next page of results. + PageToken *string `json:"page_token,omitempty"` + // The sandbox whose commands to list, in the form `sandboxes/{sandbox_id}`. + Parent *string `json:"parent,omitempty"` +} + +// Response listing tracked command executions.. +type ListCommandsResponse struct { + // Commands in this page of results. + Commands []Command `json:"commands,omitempty"` + // Token to retrieve the next page. Empty when there are no more results. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// A request to list Sandboxes.. +type ListSandboxesRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` +} + +// A list of Sandboxes.. +type ListSandboxesResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + Sandboxes []Sandbox `json:"sandboxes,omitempty"` +} + +// A Sandbox resource representing an execution environment.. +type Sandbox struct { + // Output only. The creation time of the sandbox. + CreateTime *types.Time `json:"create_time,omitempty"` + // Human-readable display label for the sandbox. At most 256 characters. + DisplayName *string `json:"display_name,omitempty"` + // The sandbox resource name, in the form `sandboxes/{sandbox_id}`. Derived from + // `sandbox_id`; any value supplied in a create or update request body is + // ignored. + Name *string `json:"name,omitempty"` + // The desired configuration of the sandbox, supplied by the caller at creation + // time. + Spec *SandboxSpec `json:"spec,omitempty"` + // The observed runtime state of the sandbox, populated by the server. + Status *SandboxStatus `json:"status,omitempty"` + // Output only. The last update time of the sandbox metadata and spec. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +type SandboxSpec struct { + // Compute configuration (size, inactivity timeout) requested for the sandbox. + Compute *ComputeSpec `json:"compute,omitempty"` + // The execution environment to use for the sandbox. + Environment *EnvironmentSpec `json:"environment,omitempty"` +} + +type SandboxStatus struct { + // Lifecycle state of the sandbox. + State SandboxState `json:"state,omitempty"` +} + +// A request to start a Sandbox.. +type StartSandboxRequest struct { + // Resource name of the sandbox to start, in the form `sandboxes/{sandbox_id}`. + Name *string `json:"name,omitempty"` +} + +// A request to stop a Sandbox.. +type StopSandboxRequest struct { + // Resource name of the sandbox to stop, in the form `sandboxes/{sandbox_id}`. + Name *string `json:"name,omitempty"` +} + +// A request to update mutable fields on a Sandbox.. +type UpdateSandboxRequest struct { + // Resource name of the sandbox to update, in the form `sandboxes/{sandbox_id}`. + Name *string `json:"name,omitempty"` + // The Sandbox resource carrying new field values. Only fields named in + // `update_mask` are read; unmasked fields are ignored. + Sandbox *Sandbox `json:"sandbox,omitempty"` + // Field paths to update. Must be a non-empty subset of: - display_name - + // spec.compute.inactivity_timeout Any other path returns + // INVALID_PARAMETER_VALUE. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CommandToSDK converts the mirror to the sdk-go type. +func CommandToSDK(w *Command) (*sdk.Command, error) { + if w == nil { + return nil, nil + } + out := &sdk.Command{} + out.CommandId = w.CommandId + out.Cmd = w.Cmd + out.Args = w.Args + out.Pid = w.Pid + out.Finished = w.Finished + out.ExitCode = w.ExitCode + return out, nil +} + +// CommandFromSDK converts the sdk-go type to the mirror. +func CommandFromSDK(v *sdk.Command) (*Command, error) { + if v == nil { + return nil, nil + } + out := &Command{} + out.CommandId = v.CommandId + out.Cmd = v.Cmd + out.Args = v.Args + out.Pid = v.Pid + out.Finished = v.Finished + out.ExitCode = v.ExitCode + return out, nil +} + +// ComputeSpecToSDK converts the mirror to the sdk-go type. +func ComputeSpecToSDK(w *ComputeSpec) (*sdk.ComputeSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.ComputeSpec{} + out.InactivityTimeout = w.InactivityTimeout + return out, nil +} + +// ComputeSpecFromSDK converts the sdk-go type to the mirror. +func ComputeSpecFromSDK(v *sdk.ComputeSpec) (*ComputeSpec, error) { + if v == nil { + return nil, nil + } + out := &ComputeSpec{} + out.InactivityTimeout = v.InactivityTimeout + return out, nil +} + +// CreateSandboxRequestToSDK converts the mirror to the sdk-go type. +func CreateSandboxRequestToSDK(w *CreateSandboxRequest) (*sdk.CreateSandboxRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateSandboxRequest{} + conv1, err := SandboxToSDK(w.Sandbox) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSandboxRequest.Sandbox", err) + } + out.Sandbox = conv1 + out.SandboxId = w.SandboxId + return out, nil +} + +// CreateSandboxRequestFromSDK converts the sdk-go type to the mirror. +func CreateSandboxRequestFromSDK(v *sdk.CreateSandboxRequest) (*CreateSandboxRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateSandboxRequest{} + conv2, err := SandboxFromSDK(v.Sandbox) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSandboxRequest.Sandbox", err) + } + out.Sandbox = conv2 + out.SandboxId = v.SandboxId + return out, nil +} + +// EnvironmentSpecToSDK converts the mirror to the sdk-go type. +func EnvironmentSpecToSDK(w *EnvironmentSpec) (*sdk.EnvironmentSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnvironmentSpec{} + out.ImageUri = w.ImageUri + return out, nil +} + +// EnvironmentSpecFromSDK converts the sdk-go type to the mirror. +func EnvironmentSpecFromSDK(v *sdk.EnvironmentSpec) (*EnvironmentSpec, error) { + if v == nil { + return nil, nil + } + out := &EnvironmentSpec{} + out.ImageUri = v.ImageUri + return out, nil +} + +// ExecuteCommandSyncRequestToSDK converts the mirror to the sdk-go type. +func ExecuteCommandSyncRequestToSDK(w *ExecuteCommandSyncRequest) (*sdk.ExecuteCommandSyncRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExecuteCommandSyncRequest{} + out.Name = w.Name + out.Cmd = w.Cmd + out.Args = w.Args + out.Envs = w.Envs + out.ExecutionTimeout = w.ExecutionTimeout + return out, nil +} + +// ExecuteCommandSyncRequestFromSDK converts the sdk-go type to the mirror. +func ExecuteCommandSyncRequestFromSDK(v *sdk.ExecuteCommandSyncRequest) (*ExecuteCommandSyncRequest, error) { + if v == nil { + return nil, nil + } + out := &ExecuteCommandSyncRequest{} + out.Name = v.Name + out.Cmd = v.Cmd + out.Args = v.Args + out.Envs = v.Envs + out.ExecutionTimeout = v.ExecutionTimeout + return out, nil +} + +// ExecuteCommandSyncResponseToSDK converts the mirror to the sdk-go type. +func ExecuteCommandSyncResponseToSDK(w *ExecuteCommandSyncResponse) (*sdk.ExecuteCommandSyncResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExecuteCommandSyncResponse{} + out.ExitCode = w.ExitCode + out.Status = w.Status + out.Stdout = w.Stdout + out.Stderr = w.Stderr + out.CommandId = w.CommandId + out.Truncated = w.Truncated + return out, nil +} + +// ExecuteCommandSyncResponseFromSDK converts the sdk-go type to the mirror. +func ExecuteCommandSyncResponseFromSDK(v *sdk.ExecuteCommandSyncResponse) (*ExecuteCommandSyncResponse, error) { + if v == nil { + return nil, nil + } + out := &ExecuteCommandSyncResponse{} + out.ExitCode = v.ExitCode + out.Status = v.Status + out.Stdout = v.Stdout + out.Stderr = v.Stderr + out.CommandId = v.CommandId + out.Truncated = v.Truncated + return out, nil +} + +// ListCommandsRequestToSDK converts the mirror to the sdk-go type. +func ListCommandsRequestToSDK(w *ListCommandsRequest) (*sdk.ListCommandsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCommandsRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + out.Parent = w.Parent + return out, nil +} + +// ListCommandsRequestFromSDK converts the sdk-go type to the mirror. +func ListCommandsRequestFromSDK(v *sdk.ListCommandsRequest) (*ListCommandsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCommandsRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + out.Parent = v.Parent + return out, nil +} + +// ListCommandsResponseToSDK converts the mirror to the sdk-go type. +func ListCommandsResponseToSDK(w *ListCommandsResponse) (*sdk.ListCommandsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCommandsResponse{} + conv3, err := convertSlice(w.Commands, CommandToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCommandsResponse.Commands", err) + } + out.Commands = conv3 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCommandsResponseFromSDK converts the sdk-go type to the mirror. +func ListCommandsResponseFromSDK(v *sdk.ListCommandsResponse) (*ListCommandsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCommandsResponse{} + conv4, err := convertSlice(v.Commands, CommandFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCommandsResponse.Commands", err) + } + out.Commands = conv4 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListSandboxesRequestToSDK converts the mirror to the sdk-go type. +func ListSandboxesRequestToSDK(w *ListSandboxesRequest) (*sdk.ListSandboxesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSandboxesRequest{} + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListSandboxesRequestFromSDK converts the sdk-go type to the mirror. +func ListSandboxesRequestFromSDK(v *sdk.ListSandboxesRequest) (*ListSandboxesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSandboxesRequest{} + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListSandboxesResponseToSDK converts the mirror to the sdk-go type. +func ListSandboxesResponseToSDK(w *ListSandboxesResponse) (*sdk.ListSandboxesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSandboxesResponse{} + conv5, err := convertSlice(w.Sandboxes, SandboxToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSandboxesResponse.Sandboxes", err) + } + out.Sandboxes = conv5 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSandboxesResponseFromSDK converts the sdk-go type to the mirror. +func ListSandboxesResponseFromSDK(v *sdk.ListSandboxesResponse) (*ListSandboxesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSandboxesResponse{} + conv6, err := convertSlice(v.Sandboxes, SandboxFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSandboxesResponse.Sandboxes", err) + } + out.Sandboxes = conv6 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SandboxToSDK converts the mirror to the sdk-go type. +func SandboxToSDK(w *Sandbox) (*sdk.Sandbox, error) { + if w == nil { + return nil, nil + } + out := &sdk.Sandbox{} + conv7, err := SandboxSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Sandbox.Spec", err) + } + out.Spec = conv7 + conv8, err := SandboxStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Sandbox.Status", err) + } + out.Status = conv8 + out.Name = w.Name + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + out.DisplayName = w.DisplayName + return out, nil +} + +// SandboxFromSDK converts the sdk-go type to the mirror. +func SandboxFromSDK(v *sdk.Sandbox) (*Sandbox, error) { + if v == nil { + return nil, nil + } + out := &Sandbox{} + conv9, err := SandboxSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Sandbox.Spec", err) + } + out.Spec = conv9 + conv10, err := SandboxStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Sandbox.Status", err) + } + out.Status = conv10 + out.Name = v.Name + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + out.DisplayName = v.DisplayName + return out, nil +} + +// SandboxSpecToSDK converts the mirror to the sdk-go type. +func SandboxSpecToSDK(w *SandboxSpec) (*sdk.SandboxSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.SandboxSpec{} + conv11, err := ComputeSpecToSDK(w.Compute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SandboxSpec.Compute", err) + } + out.Compute = conv11 + conv12, err := EnvironmentSpecToSDK(w.Environment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SandboxSpec.Environment", err) + } + out.Environment = conv12 + return out, nil +} + +// SandboxSpecFromSDK converts the sdk-go type to the mirror. +func SandboxSpecFromSDK(v *sdk.SandboxSpec) (*SandboxSpec, error) { + if v == nil { + return nil, nil + } + out := &SandboxSpec{} + conv13, err := ComputeSpecFromSDK(v.Compute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SandboxSpec.Compute", err) + } + out.Compute = conv13 + conv14, err := EnvironmentSpecFromSDK(v.Environment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SandboxSpec.Environment", err) + } + out.Environment = conv14 + return out, nil +} + +// SandboxStatusToSDK converts the mirror to the sdk-go type. +func SandboxStatusToSDK(w *SandboxStatus) (*sdk.SandboxStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.SandboxStatus{} + out.State = w.State + return out, nil +} + +// SandboxStatusFromSDK converts the sdk-go type to the mirror. +func SandboxStatusFromSDK(v *sdk.SandboxStatus) (*SandboxStatus, error) { + if v == nil { + return nil, nil + } + out := &SandboxStatus{} + out.State = v.State + return out, nil +} + +// StartSandboxRequestToSDK converts the mirror to the sdk-go type. +func StartSandboxRequestToSDK(w *StartSandboxRequest) (*sdk.StartSandboxRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.StartSandboxRequest{} + out.Name = w.Name + return out, nil +} + +// StartSandboxRequestFromSDK converts the sdk-go type to the mirror. +func StartSandboxRequestFromSDK(v *sdk.StartSandboxRequest) (*StartSandboxRequest, error) { + if v == nil { + return nil, nil + } + out := &StartSandboxRequest{} + out.Name = v.Name + return out, nil +} + +// StopSandboxRequestToSDK converts the mirror to the sdk-go type. +func StopSandboxRequestToSDK(w *StopSandboxRequest) (*sdk.StopSandboxRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.StopSandboxRequest{} + out.Name = w.Name + return out, nil +} + +// StopSandboxRequestFromSDK converts the sdk-go type to the mirror. +func StopSandboxRequestFromSDK(v *sdk.StopSandboxRequest) (*StopSandboxRequest, error) { + if v == nil { + return nil, nil + } + out := &StopSandboxRequest{} + out.Name = v.Name + return out, nil +} + +// UpdateSandboxRequestToSDK converts the mirror to the sdk-go type. +func UpdateSandboxRequestToSDK(w *UpdateSandboxRequest) (*sdk.UpdateSandboxRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateSandboxRequest{} + out.Name = w.Name + conv15, err := SandboxToSDK(w.Sandbox) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSandboxRequest.Sandbox", err) + } + out.Sandbox = conv15 + mask16, err := fieldMaskFromString[sdk.Sandbox](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSandboxRequest.UpdateMask", err) + } + out.UpdateMask = mask16 + return out, nil +} + +// UpdateSandboxRequestFromSDK converts the sdk-go type to the mirror. +func UpdateSandboxRequestFromSDK(v *sdk.UpdateSandboxRequest) (*UpdateSandboxRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateSandboxRequest{} + out.Name = v.Name + conv17, err := SandboxFromSDK(v.Sandbox) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSandboxRequest.Sandbox", err) + } + out.Sandbox = conv17 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/scim/v1/types.generated.go b/libs/sdktypes/scim/v1/types.generated.go new file mode 100644 index 00000000000..ace11f1bbbd --- /dev/null +++ b/libs/sdktypes/scim/v1/types.generated.go @@ -0,0 +1,3133 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/scim/v1. DO NOT EDIT. + +package scim + +import ( + json "encoding/json" + fmt "fmt" + sdk "github.com/databricks/sdk-go/scim/v1" +) + +type ( + GetSortOrder = sdk.GetSortOrder + GroupSchema = sdk.GroupSchema + ListResponseSchema = sdk.ListResponseSchema + PatchOp = sdk.PatchOp + PatchSchema = sdk.PatchSchema + ServicePrincipalSchema = sdk.ServicePrincipalSchema + UserSchema = sdk.UserSchema + AccountGetSortOrder_GetSortOrder = sdk.AccountGetSortOrder_GetSortOrder + AccountListSort_Order = sdk.AccountListSort_Order + AccountPatchOp_PatchOp = sdk.AccountPatchOp_PatchOp + AccountPatchSchema_PatchSchema = sdk.AccountPatchSchema_PatchSchema + ListSort_Order = sdk.ListSort_Order + PasswordPermission_Level = sdk.PasswordPermission_Level +) + +const ( + GetSortOrder_Unspecified = sdk.GetSortOrder_Unspecified + GetSortOrder_Ascending = sdk.GetSortOrder_Ascending + GetSortOrder_Descending = sdk.GetSortOrder_Descending + GroupSchema_Unspecified = sdk.GroupSchema_Unspecified + GroupSchema_UrnIetfParamsScimSchemasCore20Group = sdk.GroupSchema_UrnIetfParamsScimSchemasCore20Group + ListResponseSchema_Unspecified = sdk.ListResponseSchema_Unspecified + ListResponseSchema_UrnIetfParamsScimApiMessages20ListResponse = sdk.ListResponseSchema_UrnIetfParamsScimApiMessages20ListResponse + PatchOp_Unspecified = sdk.PatchOp_Unspecified + PatchOp_Add = sdk.PatchOp_Add + PatchOp_Remove = sdk.PatchOp_Remove + PatchOp_Replace = sdk.PatchOp_Replace + PatchSchema_Unspecified = sdk.PatchSchema_Unspecified + PatchSchema_UrnIetfParamsScimApiMessages20PatchOp = sdk.PatchSchema_UrnIetfParamsScimApiMessages20PatchOp + ServicePrincipalSchema_Unspecified = sdk.ServicePrincipalSchema_Unspecified + ServicePrincipalSchema_UrnIetfParamsScimSchemasCore20ServicePrincipal = sdk.ServicePrincipalSchema_UrnIetfParamsScimSchemasCore20ServicePrincipal + UserSchema_Unspecified = sdk.UserSchema_Unspecified + UserSchema_UrnIetfParamsScimSchemasCore20User = sdk.UserSchema_UrnIetfParamsScimSchemasCore20User + UserSchema_UrnIetfParamsScimSchemasExtensionWorkspace20User = sdk.UserSchema_UrnIetfParamsScimSchemasExtensionWorkspace20User + AccountGetSortOrder_GetSortOrder_Unspecified = sdk.AccountGetSortOrder_GetSortOrder_Unspecified + AccountGetSortOrder_GetSortOrder_Ascending = sdk.AccountGetSortOrder_GetSortOrder_Ascending + AccountGetSortOrder_GetSortOrder_Descending = sdk.AccountGetSortOrder_GetSortOrder_Descending + AccountListSort_Order_Unspecified = sdk.AccountListSort_Order_Unspecified + AccountListSort_Order_Ascending = sdk.AccountListSort_Order_Ascending + AccountListSort_Order_Descending = sdk.AccountListSort_Order_Descending + AccountPatchOp_PatchOp_Unspecified = sdk.AccountPatchOp_PatchOp_Unspecified + AccountPatchOp_PatchOp_Add = sdk.AccountPatchOp_PatchOp_Add + AccountPatchOp_PatchOp_Remove = sdk.AccountPatchOp_PatchOp_Remove + AccountPatchOp_PatchOp_Replace = sdk.AccountPatchOp_PatchOp_Replace + AccountPatchSchema_PatchSchema_Unspecified = sdk.AccountPatchSchema_PatchSchema_Unspecified + AccountPatchSchema_PatchSchema_UrnIetfParamsScimApiMessages20PatchOp = sdk.AccountPatchSchema_PatchSchema_UrnIetfParamsScimApiMessages20PatchOp + ListSort_Order_Unspecified = sdk.ListSort_Order_Unspecified + ListSort_Order_Ascending = sdk.ListSort_Order_Ascending + ListSort_Order_Descending = sdk.ListSort_Order_Descending + PasswordPermission_Level_Unspecified = sdk.PasswordPermission_Level_Unspecified + PasswordPermission_Level_CanUse = sdk.PasswordPermission_Level_CanUse +) + +type AccountComplexValue struct { + Ref *string `json:"$ref,omitempty"` + Display *string `json:"display,omitempty"` + Primary *bool `json:"primary,omitempty"` + Type *string `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +type AccountGroup struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // String that represents a human-readable group name + DisplayName *string `json:"displayName,omitempty"` + // external_id should be unique for identifying groups + ExternalId *string `json:"externalId,omitempty"` + // group ID + Id *string `json:"id,omitempty"` + Members []AccountComplexValue `json:"members,omitempty"` + // Container for the group identifier. Workspace local versus account. + Meta *AccountResourceMeta `json:"meta,omitempty"` + // Indicates if the group has the admin role. + Roles []AccountComplexValue `json:"roles,omitempty"` +} + +type AccountName struct { + // Family name of the user. + FamilyName *string `json:"familyName,omitempty"` + // Given name of the user. + GivenName *string `json:"givenName,omitempty"` +} + +type AccountPatch struct { + // Type of patch operation. + Op AccountPatchOp_PatchOp `json:"op,omitempty"` + // Selection of patch operation + Path *string `json:"path,omitempty"` + // Value to modify + Value json.RawMessage `json:"value,omitempty"` +} + +type AccountResourceMeta struct { + // Identifier for group type. Can be local workspace group (`WorkspaceGroup`) or + // account group (`Group`). + ResourceType *string `json:"resourceType,omitempty"` +} + +type AccountServicePrincipal struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // If this user is active + Active *bool `json:"active,omitempty"` + // UUID relating to the service principal + ApplicationId *string `json:"applicationId,omitempty"` + // String that represents a concatenation of given and family names. + DisplayName *string `json:"displayName,omitempty"` + ExternalId *string `json:"externalId,omitempty"` + // service principal ID. + Id *string `json:"id,omitempty"` + // Indicates if the group has the admin role. + Roles []AccountComplexValue `json:"roles,omitempty"` +} + +type AccountUser struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // If this user is active + Active *bool `json:"active,omitempty"` + // String that represents a concatenation of given and family names. For example + // `John Smith`. + DisplayName *string `json:"displayName,omitempty"` + // All the emails associated with the user. This attribute cannot + // be updated through the SCIM PATCH or PUT APIs; any supplied change is + // ignored. + Emails []AccountComplexValue `json:"emails,omitempty"` + // External ID is not currently supported. It is reserved for future use. + ExternalId *string `json:"externalId,omitempty"` + // user ID. + Id *string `json:"id,omitempty"` + Name *AccountName `json:"name,omitempty"` + // Indicates if the group has the admin role. + Roles []AccountComplexValue `json:"roles,omitempty"` + // Email address of the user. This attribute cannot be updated + // through the SCIM PATCH or PUT APIs; any supplied change is ignored. + UserName *string `json:"userName,omitempty"` +} + +type ComplexValue struct { + Ref *string `json:"$ref,omitempty"` + Display *string `json:"display,omitempty"` + Primary *bool `json:"primary,omitempty"` + Type *string `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +type CreateAccountGroupRequest struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // String that represents a human-readable group name + DisplayName *string `json:"displayName,omitempty"` + ExternalId *string `json:"externalId,omitempty"` + // group ID + Id *string `json:"id,omitempty"` + Members []AccountComplexValue `json:"members,omitempty"` + // Container for the group identifier. Workspace local versus account. + Meta *AccountResourceMeta `json:"meta,omitempty"` + // Indicates if the group has the admin role. + Roles []AccountComplexValue `json:"roles,omitempty"` +} + +type CreateAccountServicePrincipalRequest struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // If this user is active + Active *bool `json:"active,omitempty"` + // UUID relating to the service principal + ApplicationId *string `json:"applicationId,omitempty"` + // String that represents a concatenation of given and family names. + DisplayName *string `json:"displayName,omitempty"` + ExternalId *string `json:"externalId,omitempty"` + // service principal ID. + Id *string `json:"id,omitempty"` + // Indicates if the group has the admin role. + Roles []AccountComplexValue `json:"roles,omitempty"` +} + +type CreateAccountUserRequest struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // If this user is active + Active *bool `json:"active,omitempty"` + // String that represents a concatenation of given and family names. For example + // `John Smith`. + DisplayName *string `json:"displayName,omitempty"` + // All the emails associated with the user. + Emails []AccountComplexValue `json:"emails,omitempty"` + // External ID is not currently supported. It is reserved for future use. + ExternalId *string `json:"externalId,omitempty"` + // user ID. + Id *string `json:"id,omitempty"` + Name *AccountName `json:"name,omitempty"` + // Indicates if the group has the admin role. + Roles []AccountComplexValue `json:"roles,omitempty"` + // Email address of the user. + UserName *string `json:"userName,omitempty"` +} + +type CreateGroupRequest struct { + // String that represents a human-readable group name + DisplayName *string `json:"displayName,omitempty"` + // Entitlements assigned to the group. See [assigning entitlements] for a full + // list of supported values. + // + // [assigning entitlements]: https://docs.databricks.com/administration-guide/users-groups/index.html#assigning-entitlements + Entitlements []ComplexValue `json:"entitlements,omitempty"` + ExternalId *string `json:"externalId,omitempty"` + Groups []ComplexValue `json:"groups,omitempty"` + // group ID + Id *string `json:"id,omitempty"` + Members []ComplexValue `json:"members,omitempty"` + // Container for the group identifier. Workspace local versus account. + Meta *ResourceMeta `json:"meta,omitempty"` + // Corresponds to AWS instance profile/arn role. + Roles []ComplexValue `json:"roles,omitempty"` + // The schema of the group. + Schemas []GroupSchema `json:"schemas,omitempty"` +} + +type CreateServicePrincipalRequest struct { + // If this user is active + Active *bool `json:"active,omitempty"` + // UUID relating to the service principal + ApplicationId *string `json:"applicationId,omitempty"` + // String that represents a concatenation of given and family names. + DisplayName *string `json:"displayName,omitempty"` + // Entitlements assigned to the service principal. See [assigning entitlements] + // for a full list of supported values. + // + // [assigning entitlements]: https://docs.databricks.com/administration-guide/users-groups/index.html#assigning-entitlements + Entitlements []ComplexValue `json:"entitlements,omitempty"` + ExternalId *string `json:"externalId,omitempty"` + Groups []ComplexValue `json:"groups,omitempty"` + // service principal ID. + Id *string `json:"id,omitempty"` + // Corresponds to AWS instance profile/arn role. + Roles []ComplexValue `json:"roles,omitempty"` + // The schema of the List response. + Schemas []ServicePrincipalSchema `json:"schemas,omitempty"` +} + +type CreateUserRequest struct { + // If this user is active + Active *bool `json:"active,omitempty"` + // String that represents a concatenation of given and family names. For example + // `John Smith`. This field cannot be updated through the Workspace SCIM APIs + // when [identity federation is enabled]. Use Account SCIM APIs to update + // `displayName`. + // + // [identity federation is enabled]: https://docs.databricks.com/administration-guide/users-groups/best-practices.html#enable-identity-federation + DisplayName *string `json:"displayName,omitempty"` + // All the emails associated with the user. + Emails []ComplexValue `json:"emails,omitempty"` + // Entitlements assigned to the user. See [assigning entitlements] for a full + // list of supported values. + // + // [assigning entitlements]: https://docs.databricks.com/administration-guide/users-groups/index.html#assigning-entitlements + Entitlements []ComplexValue `json:"entitlements,omitempty"` + // External ID is not currently supported. It is reserved for future use. + ExternalId *string `json:"externalId,omitempty"` + Groups []ComplexValue `json:"groups,omitempty"` + // user ID. + Id *string `json:"id,omitempty"` + Name *Name `json:"name,omitempty"` + // Corresponds to AWS instance profile/arn role. + Roles []ComplexValue `json:"roles,omitempty"` + // The schema of the user. + Schemas []UserSchema `json:"schemas,omitempty"` + // Email address of the user. + UserName *string `json:"userName,omitempty"` +} + +// Get user details. +type GetAccountUserRequest struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // Comma-separated list of attributes to return in response. + Attributes *string `json:"attributes,omitempty"` + // Desired number of results per page. Default is 10000. + Count *int `json:"count,omitempty"` + // Comma-separated list of attributes to exclude in response. + ExcludedAttributes *string `json:"excludedAttributes,omitempty"` + // Query by which the results have to be filtered. Supported operators are + // equals(`eq`), contains(`co`), starts with(`sw`) and not equals(`ne`). + // Additionally, simple expressions can be formed using logical operators - + // `and` and `or`. The [SCIM RFC] has more details but we currently only support + // simple expressions. + // + // [SCIM RFC]: https://tools.ietf.org/html/rfc7644#section-3.4.2.2 + Filter *string `json:"filter,omitempty"` + // Unique ID for a user in the account. + Id *string `json:"id,omitempty"` + // Attribute to sort the results. Multi-part paths are supported. For example, + // `userName`, `name.givenName`, and `emails`. + SortBy *string `json:"sortBy,omitempty"` + // The order to sort the results. + SortOrder AccountGetSortOrder_GetSortOrder `json:"sortOrder,omitempty"` + // Specifies the index of the first result. First item is number 1. + StartIndex *int `json:"startIndex,omitempty"` +} + +type GetPasswordPermissionLevelsResponse struct { + // Specific permission levels + PermissionLevels []PasswordPermissionsDescription `json:"permission_levels,omitempty"` +} + +// Get user details. +type GetUserRequest struct { + // Comma-separated list of attributes to return in response. + Attributes *string `json:"attributes,omitempty"` + // Desired number of results per page. + Count *int `json:"count,omitempty"` + // Comma-separated list of attributes to exclude in response. + ExcludedAttributes *string `json:"excludedAttributes,omitempty"` + // Query by which the results have to be filtered. Supported operators are + // equals(`eq`), contains(`co`), starts with(`sw`) and not equals(`ne`). + // Additionally, simple expressions can be formed using logical operators - + // `and` and `or`. The [SCIM RFC] has more details but we currently only support + // simple expressions. + // + // [SCIM RFC]: https://tools.ietf.org/html/rfc7644#section-3.4.2.2 + Filter *string `json:"filter,omitempty"` + // Unique ID for a user in the workspace. + Id *string `json:"id,omitempty"` + // Attribute to sort the results. Multi-part paths are supported. For example, + // `userName`, `name.givenName`, and `emails`. + SortBy *string `json:"sortBy,omitempty"` + // The order to sort the results. + SortOrder GetSortOrder `json:"sortOrder,omitempty"` + // Specifies the index of the first result. First item is number 1. + StartIndex *int `json:"startIndex,omitempty"` +} + +type Group struct { + // String that represents a human-readable group name + DisplayName *string `json:"displayName,omitempty"` + // Entitlements assigned to the group. See [assigning entitlements] for a full + // list of supported values. + // + // [assigning entitlements]: https://docs.databricks.com/administration-guide/users-groups/index.html#assigning-entitlements + Entitlements []ComplexValue `json:"entitlements,omitempty"` + // external_id should be unique for identifying groups + ExternalId *string `json:"externalId,omitempty"` + Groups []ComplexValue `json:"groups,omitempty"` + // group ID + Id *string `json:"id,omitempty"` + Members []ComplexValue `json:"members,omitempty"` + // Container for the group identifier. Workspace local versus account. + Meta *ResourceMeta `json:"meta,omitempty"` + // Corresponds to AWS instance profile/arn role. + Roles []ComplexValue `json:"roles,omitempty"` + // The schema of the group. + Schemas []GroupSchema `json:"schemas,omitempty"` +} + +// List group details. +type ListAccountGroupsRequest struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // Comma-separated list of attributes to return in response. + Attributes *string `json:"attributes,omitempty"` + // Desired number of results per page. Default is 10000. + Count *int64 `json:"count,omitempty"` + // Comma-separated list of attributes to exclude in response. + ExcludedAttributes *string `json:"excludedAttributes,omitempty"` + // Query by which the results have to be filtered. Supported operators are + // equals(`eq`), contains(`co`), starts with(`sw`) and not equals(`ne`). + // Additionally, simple expressions can be formed using logical operators - + // `and` and `or`. The [SCIM RFC] has more details but we currently only support + // simple expressions. + // + // [SCIM RFC]: https://tools.ietf.org/html/rfc7644#section-3.4.2.2 + Filter *string `json:"filter,omitempty"` + // Attribute to sort the results. + SortBy *string `json:"sortBy,omitempty"` + // The order to sort the results. + SortOrder AccountListSort_Order `json:"sortOrder,omitempty"` + // Specifies the index of the first result. First item is number 1. + StartIndex *int64 `json:"startIndex,omitempty"` +} + +type ListAccountGroupsResponse struct { + // User objects returned in the response. + Resources []AccountGroup `json:"Resources,omitempty"` + // Total results returned in the response. + ItemsPerPage *int `json:"itemsPerPage,omitempty"` + // Starting index of all the results that matched the request filters. First + // item is number 1. + StartIndex *int64 `json:"startIndex,omitempty"` + // Total results that match the request filters. + TotalResults *int `json:"totalResults,omitempty"` +} + +// List service principals. +type ListAccountServicePrincipalsRequest struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // Comma-separated list of attributes to return in response. + Attributes *string `json:"attributes,omitempty"` + // Desired number of results per page. Default is 10000. + Count *int64 `json:"count,omitempty"` + // Comma-separated list of attributes to exclude in response. + ExcludedAttributes *string `json:"excludedAttributes,omitempty"` + // Query by which the results have to be filtered. Supported operators are + // equals(`eq`), contains(`co`), starts with(`sw`) and not equals(`ne`). + // Additionally, simple expressions can be formed using logical operators - + // `and` and `or`. The [SCIM RFC] has more details but we currently only support + // simple expressions. + // + // [SCIM RFC]: https://tools.ietf.org/html/rfc7644#section-3.4.2.2 + Filter *string `json:"filter,omitempty"` + // Attribute to sort the results. + SortBy *string `json:"sortBy,omitempty"` + // The order to sort the results. + SortOrder AccountListSort_Order `json:"sortOrder,omitempty"` + // Specifies the index of the first result. First item is number 1. + StartIndex *int64 `json:"startIndex,omitempty"` +} + +type ListAccountServicePrincipalsResponse struct { + // User objects returned in the response. + Resources []AccountServicePrincipal `json:"Resources,omitempty"` + // Total results returned in the response. + ItemsPerPage *int `json:"itemsPerPage,omitempty"` + // Starting index of all the results that matched the request filters. First + // item is number 1. + StartIndex *int64 `json:"startIndex,omitempty"` + // Total results that match the request filters. + TotalResults *int `json:"totalResults,omitempty"` +} + +// List users. +type ListAccountUsersRequest struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // Comma-separated list of attributes to return in response. + Attributes *string `json:"attributes,omitempty"` + // Desired number of results per page. Default is 10000. + Count *int64 `json:"count,omitempty"` + // Comma-separated list of attributes to exclude in response. + ExcludedAttributes *string `json:"excludedAttributes,omitempty"` + // Query by which the results have to be filtered. Supported operators are + // equals(`eq`), contains(`co`), starts with(`sw`) and not equals(`ne`). + // Additionally, simple expressions can be formed using logical operators - + // `and` and `or`. The [SCIM RFC] has more details but we currently only support + // simple expressions. + // + // [SCIM RFC]: https://tools.ietf.org/html/rfc7644#section-3.4.2.2 + Filter *string `json:"filter,omitempty"` + // Attribute to sort the results. Multi-part paths are supported. For example, + // `userName`, `name.givenName`, and `emails`. + SortBy *string `json:"sortBy,omitempty"` + // The order to sort the results. + SortOrder AccountListSort_Order `json:"sortOrder,omitempty"` + // Specifies the index of the first result. First item is number 1. + StartIndex *int64 `json:"startIndex,omitempty"` +} + +type ListAccountUsersResponse struct { + // User objects returned in the response. + Resources []AccountUser `json:"Resources,omitempty"` + // Total results returned in the response. + ItemsPerPage *int `json:"itemsPerPage,omitempty"` + // Starting index of all the results that matched the request filters. First + // item is number 1. + StartIndex *int64 `json:"startIndex,omitempty"` + // Total results that match the request filters. + TotalResults *int `json:"totalResults,omitempty"` +} + +// List group details. +type ListGroupsRequest struct { + // Comma-separated list of attributes to return in response. + Attributes *string `json:"attributes,omitempty"` + // Desired number of results per page. + Count *int64 `json:"count,omitempty"` + // Comma-separated list of attributes to exclude in response. + ExcludedAttributes *string `json:"excludedAttributes,omitempty"` + // Query by which the results have to be filtered. Supported operators are + // equals(`eq`), contains(`co`), starts with(`sw`) and not equals(`ne`). + // Additionally, simple expressions can be formed using logical operators - + // `and` and `or`. The [SCIM RFC] has more details but we currently only support + // simple expressions. + // + // [SCIM RFC]: https://tools.ietf.org/html/rfc7644#section-3.4.2.2 + Filter *string `json:"filter,omitempty"` + // Attribute to sort the results. + SortBy *string `json:"sortBy,omitempty"` + // The order to sort the results. + SortOrder ListSort_Order `json:"sortOrder,omitempty"` + // Specifies the index of the first result. First item is number 1. + StartIndex *int64 `json:"startIndex,omitempty"` +} + +type ListGroupsResponse struct { + // User objects returned in the response. + Resources []Group `json:"Resources,omitempty"` + // Total results returned in the response. + ItemsPerPage *int `json:"itemsPerPage,omitempty"` + // The schema of the service principal. + Schemas []ListResponseSchema `json:"schemas,omitempty"` + // Starting index of all the results that matched the request filters. First + // item is number 1. + StartIndex *int64 `json:"startIndex,omitempty"` + // Total results that match the request filters. + TotalResults *int `json:"totalResults,omitempty"` +} + +type ListServicePrincipalResponse struct { + // User objects returned in the response. + Resources []ServicePrincipal `json:"Resources,omitempty"` + // Total results returned in the response. + ItemsPerPage *int `json:"itemsPerPage,omitempty"` + // The schema of the List response. + Schemas []ListResponseSchema `json:"schemas,omitempty"` + // Starting index of all the results that matched the request filters. First + // item is number 1. + StartIndex *int64 `json:"startIndex,omitempty"` + // Total results that match the request filters. + TotalResults *int `json:"totalResults,omitempty"` +} + +// List service principals. +type ListServicePrincipalsRequest struct { + // Comma-separated list of attributes to return in response. + Attributes *string `json:"attributes,omitempty"` + // Desired number of results per page. + Count *int64 `json:"count,omitempty"` + // Comma-separated list of attributes to exclude in response. + ExcludedAttributes *string `json:"excludedAttributes,omitempty"` + // Query by which the results have to be filtered. Supported operators are + // equals(`eq`), contains(`co`), starts with(`sw`) and not equals(`ne`). + // Additionally, simple expressions can be formed using logical operators - + // `and` and `or`. The [SCIM RFC] has more details but we currently only support + // simple expressions. + // + // [SCIM RFC]: https://tools.ietf.org/html/rfc7644#section-3.4.2.2 + Filter *string `json:"filter,omitempty"` + // Attribute to sort the results. + SortBy *string `json:"sortBy,omitempty"` + // The order to sort the results. + SortOrder ListSort_Order `json:"sortOrder,omitempty"` + // Specifies the index of the first result. First item is number 1. + StartIndex *int64 `json:"startIndex,omitempty"` +} + +// List users. +type ListUsersRequest struct { + // Comma-separated list of attributes to return in response. + Attributes *string `json:"attributes,omitempty"` + // Desired number of results per page. + Count *int64 `json:"count,omitempty"` + // Comma-separated list of attributes to exclude in response. + ExcludedAttributes *string `json:"excludedAttributes,omitempty"` + // Query by which the results have to be filtered. Supported operators are + // equals(`eq`), contains(`co`), starts with(`sw`) and not equals(`ne`). + // Additionally, simple expressions can be formed using logical operators - + // `and` and `or`. The [SCIM RFC] has more details but we currently only support + // simple expressions. + // + // [SCIM RFC]: https://tools.ietf.org/html/rfc7644#section-3.4.2.2 + Filter *string `json:"filter,omitempty"` + // Attribute to sort the results. Multi-part paths are supported. For example, + // `userName`, `name.givenName`, and `emails`. + SortBy *string `json:"sortBy,omitempty"` + // The order to sort the results. + SortOrder ListSort_Order `json:"sortOrder,omitempty"` + // Specifies the index of the first result. First item is number 1. + StartIndex *int64 `json:"startIndex,omitempty"` +} + +type ListUsersResponse struct { + // User objects returned in the response. + Resources []User `json:"Resources,omitempty"` + // Total results returned in the response. + ItemsPerPage *int `json:"itemsPerPage,omitempty"` + // The schema of the List response. + Schemas []ListResponseSchema `json:"schemas,omitempty"` + // Starting index of all the results that matched the request filters. First + // item is number 1. + StartIndex *int64 `json:"startIndex,omitempty"` + // Total results that match the request filters. + TotalResults *int `json:"totalResults,omitempty"` +} + +type MeRequest struct { + // Comma-separated list of attributes to return in response. + Attributes *string `json:"attributes,omitempty"` + // Comma-separated list of attributes to exclude in response. + ExcludedAttributes *string `json:"excludedAttributes,omitempty"` +} + +type Name struct { + // Family name of the user. + FamilyName *string `json:"familyName,omitempty"` + // Given name of the user. + GivenName *string `json:"givenName,omitempty"` +} + +type PasswordAccessControlRequest struct { + // name of the group + GroupName *string `json:"group_name,omitempty"` + // Permission level + PermissionLevel PasswordPermission_Level `json:"permission_level,omitempty"` + // application ID of a service principal + ServicePrincipalName *string `json:"service_principal_name,omitempty"` + // name of the user + UserName *string `json:"user_name,omitempty"` +} + +type PasswordAccessControlResponse struct { + // All permissions. + AllPermissions []PasswordPermission `json:"all_permissions,omitempty"` + // Display name of the user or service principal. + DisplayName *string `json:"display_name,omitempty"` + // name of the group + GroupName *string `json:"group_name,omitempty"` + // Name of the service principal. + ServicePrincipalName *string `json:"service_principal_name,omitempty"` + // name of the user + UserName *string `json:"user_name,omitempty"` +} + +type PasswordPermission struct { + Inherited *bool `json:"inherited,omitempty"` + InheritedFromObject []string `json:"inherited_from_object,omitempty"` + // Permission level + PermissionLevel PasswordPermission_Level `json:"permission_level,omitempty"` +} + +type PasswordPermissions struct { + AccessControlList []PasswordAccessControlResponse `json:"access_control_list,omitempty"` + ObjectId *string `json:"object_id,omitempty"` + ObjectType *string `json:"object_type,omitempty"` +} + +type PasswordPermissionsDescription struct { + Description *string `json:"description,omitempty"` + // Permission level + PermissionLevel PasswordPermission_Level `json:"permission_level,omitempty"` +} + +type PasswordPermissionsRequest struct { + AccessControlList []PasswordAccessControlRequest `json:"access_control_list,omitempty"` +} + +type Patch struct { + // Type of patch operation. + Op PatchOp `json:"op,omitempty"` + // Selection of patch operation + Path *string `json:"path,omitempty"` + // Value to modify + Value json.RawMessage `json:"value,omitempty"` +} + +type PatchAccountGroupRequest struct { + Operations []AccountPatch `json:"Operations,omitempty"` + // account ID + AccountId *string `json:"account_id,omitempty"` + // Unique ID in the workspace. + Id *string `json:"id,omitempty"` + // The schema of the patch request. Must be + // ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]. + Schemas []AccountPatchSchema_PatchSchema `json:"schemas,omitempty"` +} + +type PatchAccountServicePrincipalRequest struct { + Operations []AccountPatch `json:"Operations,omitempty"` + // account ID + AccountId *string `json:"account_id,omitempty"` + // Unique ID in the workspace. + Id *string `json:"id,omitempty"` + // The schema of the patch request. Must be + // ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]. + Schemas []AccountPatchSchema_PatchSchema `json:"schemas,omitempty"` +} + +type PatchAccountUserRequest struct { + Operations []AccountPatch `json:"Operations,omitempty"` + // account ID + AccountId *string `json:"account_id,omitempty"` + // Unique ID in the workspace. + Id *string `json:"id,omitempty"` + // The schema of the patch request. Must be + // ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]. + Schemas []AccountPatchSchema_PatchSchema `json:"schemas,omitempty"` +} + +type PatchGroupRequest struct { + Operations []Patch `json:"Operations,omitempty"` + // Unique ID in the workspace. + Id *string `json:"id,omitempty"` + // The schema of the patch request. Must be + // ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]. + Schemas []PatchSchema `json:"schemas,omitempty"` +} + +type PatchServicePrincipalRequest struct { + Operations []Patch `json:"Operations,omitempty"` + // Unique ID in the workspace. + Id *string `json:"id,omitempty"` + // The schema of the patch request. Must be + // ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]. + Schemas []PatchSchema `json:"schemas,omitempty"` +} + +type PatchUserRequest struct { + Operations []Patch `json:"Operations,omitempty"` + // Unique ID in the workspace. + Id *string `json:"id,omitempty"` + // The schema of the patch request. Must be + // ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]. + Schemas []PatchSchema `json:"schemas,omitempty"` +} + +type ResourceMeta struct { + // Identifier for group type. Can be local workspace group (`WorkspaceGroup`) or + // account group (`Group`). + ResourceType *string `json:"resourceType,omitempty"` +} + +type ServicePrincipal struct { + // If this user is active + Active *bool `json:"active,omitempty"` + // UUID relating to the service principal + ApplicationId *string `json:"applicationId,omitempty"` + // String that represents a concatenation of given and family names. + DisplayName *string `json:"displayName,omitempty"` + // Entitlements assigned to the service principal. See [assigning entitlements] + // for a full list of supported values. + // + // [assigning entitlements]: https://docs.databricks.com/administration-guide/users-groups/index.html#assigning-entitlements + Entitlements []ComplexValue `json:"entitlements,omitempty"` + ExternalId *string `json:"externalId,omitempty"` + Groups []ComplexValue `json:"groups,omitempty"` + // service principal ID. + Id *string `json:"id,omitempty"` + // Corresponds to AWS instance profile/arn role. + Roles []ComplexValue `json:"roles,omitempty"` + // The schema of the List response. + Schemas []ServicePrincipalSchema `json:"schemas,omitempty"` +} + +type UpdateAccountGroupRequest struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // String that represents a human-readable group name + DisplayName *string `json:"displayName,omitempty"` + ExternalId *string `json:"externalId,omitempty"` + // group ID + Id *string `json:"id,omitempty"` + Members []AccountComplexValue `json:"members,omitempty"` + // Container for the group identifier. Workspace local versus account. + Meta *AccountResourceMeta `json:"meta,omitempty"` + // Indicates if the group has the admin role. + Roles []AccountComplexValue `json:"roles,omitempty"` +} + +type UpdateAccountServicePrincipalRequest struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // If this user is active + Active *bool `json:"active,omitempty"` + // UUID relating to the service principal + ApplicationId *string `json:"applicationId,omitempty"` + // String that represents a concatenation of given and family names. + DisplayName *string `json:"displayName,omitempty"` + ExternalId *string `json:"externalId,omitempty"` + // service principal ID. + Id *string `json:"id,omitempty"` + // Indicates if the group has the admin role. + Roles []AccountComplexValue `json:"roles,omitempty"` +} + +type UpdateAccountUserRequest struct { + // account ID + AccountId *string `json:"account_id,omitempty"` + // If this user is active + Active *bool `json:"active,omitempty"` + // String that represents a concatenation of given and family names. For example + // `John Smith`. + DisplayName *string `json:"displayName,omitempty"` + // All the emails associated with the user. This attribute cannot + // be updated through the SCIM PATCH or PUT APIs; any supplied change is + // ignored. + Emails []AccountComplexValue `json:"emails,omitempty"` + // External ID is not currently supported. It is reserved for future use. + ExternalId *string `json:"externalId,omitempty"` + // user ID. + Id *string `json:"id,omitempty"` + Name *AccountName `json:"name,omitempty"` + // Indicates if the group has the admin role. + Roles []AccountComplexValue `json:"roles,omitempty"` + // Email address of the user. This attribute cannot be updated + // through the SCIM PATCH or PUT APIs; any supplied change is ignored. + UserName *string `json:"userName,omitempty"` +} + +type UpdateGroupRequest struct { + // String that represents a human-readable group name + DisplayName *string `json:"displayName,omitempty"` + // Entitlements assigned to the group. See [assigning entitlements] for a full + // list of supported values. + // + // [assigning entitlements]: https://docs.databricks.com/administration-guide/users-groups/index.html#assigning-entitlements + Entitlements []ComplexValue `json:"entitlements,omitempty"` + ExternalId *string `json:"externalId,omitempty"` + Groups []ComplexValue `json:"groups,omitempty"` + // group ID + Id *string `json:"id,omitempty"` + Members []ComplexValue `json:"members,omitempty"` + // Container for the group identifier. Workspace local versus account. + Meta *ResourceMeta `json:"meta,omitempty"` + // Corresponds to AWS instance profile/arn role. + Roles []ComplexValue `json:"roles,omitempty"` + // The schema of the group. + Schemas []GroupSchema `json:"schemas,omitempty"` +} + +type UpdateServicePrincipalRequest struct { + // If this user is active + Active *bool `json:"active,omitempty"` + // UUID relating to the service principal + ApplicationId *string `json:"applicationId,omitempty"` + // String that represents a concatenation of given and family names. + DisplayName *string `json:"displayName,omitempty"` + // Entitlements assigned to the service principal. See [assigning entitlements] + // for a full list of supported values. + // + // [assigning entitlements]: https://docs.databricks.com/administration-guide/users-groups/index.html#assigning-entitlements + Entitlements []ComplexValue `json:"entitlements,omitempty"` + ExternalId *string `json:"externalId,omitempty"` + Groups []ComplexValue `json:"groups,omitempty"` + // service principal ID. + Id *string `json:"id,omitempty"` + // Corresponds to AWS instance profile/arn role. + Roles []ComplexValue `json:"roles,omitempty"` + // The schema of the List response. + Schemas []ServicePrincipalSchema `json:"schemas,omitempty"` +} + +type UpdateUserRequest struct { + // If this user is active + Active *bool `json:"active,omitempty"` + // String that represents a concatenation of given and family names. For example + // `John Smith`. This field cannot be updated through the Workspace SCIM APIs + // when [identity federation is enabled]. Use Account SCIM APIs to update + // `displayName`. + // + // [identity federation is enabled]: https://docs.databricks.com/administration-guide/users-groups/best-practices.html#enable-identity-federation + DisplayName *string `json:"displayName,omitempty"` + // All the emails associated with the user. This attribute cannot + // be updated through the SCIM PATCH or PUT APIs; any supplied change is + // ignored. + Emails []ComplexValue `json:"emails,omitempty"` + // Entitlements assigned to the user. See [assigning entitlements] for a full + // list of supported values. + // + // [assigning entitlements]: https://docs.databricks.com/administration-guide/users-groups/index.html#assigning-entitlements + Entitlements []ComplexValue `json:"entitlements,omitempty"` + // External ID is not currently supported. It is reserved for future use. + ExternalId *string `json:"externalId,omitempty"` + Groups []ComplexValue `json:"groups,omitempty"` + // user ID. + Id *string `json:"id,omitempty"` + Name *Name `json:"name,omitempty"` + // Corresponds to AWS instance profile/arn role. + Roles []ComplexValue `json:"roles,omitempty"` + // The schema of the user. + Schemas []UserSchema `json:"schemas,omitempty"` + // Email address of the user. This attribute cannot be updated + // through the SCIM PATCH or PUT APIs; any supplied change is ignored. + UserName *string `json:"userName,omitempty"` +} + +type User struct { + // If this user is active + Active *bool `json:"active,omitempty"` + // String that represents a concatenation of given and family names. For example + // `John Smith`. This field cannot be updated through the Workspace SCIM APIs + // when [identity federation is enabled]. Use Account SCIM APIs to update + // `displayName`. + // + // [identity federation is enabled]: https://docs.databricks.com/administration-guide/users-groups/best-practices.html#enable-identity-federation + DisplayName *string `json:"displayName,omitempty"` + // All the emails associated with the user. This attribute cannot + // be updated through the SCIM PATCH or PUT APIs; any supplied change is + // ignored. + Emails []ComplexValue `json:"emails,omitempty"` + // Entitlements assigned to the user. See [assigning entitlements] for a full + // list of supported values. + // + // [assigning entitlements]: https://docs.databricks.com/administration-guide/users-groups/index.html#assigning-entitlements + Entitlements []ComplexValue `json:"entitlements,omitempty"` + // External ID is not currently supported. It is reserved for future use. + ExternalId *string `json:"externalId,omitempty"` + Groups []ComplexValue `json:"groups,omitempty"` + // user ID. + Id *string `json:"id,omitempty"` + Name *Name `json:"name,omitempty"` + // Corresponds to AWS instance profile/arn role. + Roles []ComplexValue `json:"roles,omitempty"` + // The schema of the user. + Schemas []UserSchema `json:"schemas,omitempty"` + // Email address of the user. This attribute cannot be updated + // through the SCIM PATCH or PUT APIs; any supplied change is ignored. + UserName *string `json:"userName,omitempty"` +} + +// AccountComplexValueToSDK converts the mirror to the sdk-go type. +func AccountComplexValueToSDK(w *AccountComplexValue) (*sdk.AccountComplexValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountComplexValue{} + out.Display = w.Display + out.Primary = w.Primary + out.Ref = w.Ref + out.Type = w.Type + out.Value = w.Value + return out, nil +} + +// AccountComplexValueFromSDK converts the sdk-go type to the mirror. +func AccountComplexValueFromSDK(v *sdk.AccountComplexValue) (*AccountComplexValue, error) { + if v == nil { + return nil, nil + } + out := &AccountComplexValue{} + out.Display = v.Display + out.Primary = v.Primary + out.Ref = v.Ref + out.Type = v.Type + out.Value = v.Value + return out, nil +} + +// AccountGroupToSDK converts the mirror to the sdk-go type. +func AccountGroupToSDK(w *AccountGroup) (*sdk.AccountGroup, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountGroup{} + out.DisplayName = w.DisplayName + out.ExternalId = w.ExternalId + out.Id = w.Id + conv1, err := convertSlice(w.Members, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountGroup.Members", err) + } + out.Members = conv1 + conv2, err := AccountResourceMetaToSDK(w.Meta) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountGroup.Meta", err) + } + out.Meta = conv2 + conv3, err := convertSlice(w.Roles, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountGroup.Roles", err) + } + out.Roles = conv3 + out.AccountId = w.AccountId + return out, nil +} + +// AccountGroupFromSDK converts the sdk-go type to the mirror. +func AccountGroupFromSDK(v *sdk.AccountGroup) (*AccountGroup, error) { + if v == nil { + return nil, nil + } + out := &AccountGroup{} + out.DisplayName = v.DisplayName + out.ExternalId = v.ExternalId + out.Id = v.Id + conv4, err := convertSlice(v.Members, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountGroup.Members", err) + } + out.Members = conv4 + conv5, err := AccountResourceMetaFromSDK(v.Meta) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountGroup.Meta", err) + } + out.Meta = conv5 + conv6, err := convertSlice(v.Roles, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountGroup.Roles", err) + } + out.Roles = conv6 + out.AccountId = v.AccountId + return out, nil +} + +// AccountNameToSDK converts the mirror to the sdk-go type. +func AccountNameToSDK(w *AccountName) (*sdk.AccountName, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountName{} + out.FamilyName = w.FamilyName + out.GivenName = w.GivenName + return out, nil +} + +// AccountNameFromSDK converts the sdk-go type to the mirror. +func AccountNameFromSDK(v *sdk.AccountName) (*AccountName, error) { + if v == nil { + return nil, nil + } + out := &AccountName{} + out.FamilyName = v.FamilyName + out.GivenName = v.GivenName + return out, nil +} + +// AccountPatchToSDK converts the mirror to the sdk-go type. +func AccountPatchToSDK(w *AccountPatch) (*sdk.AccountPatch, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountPatch{} + out.Op = w.Op + out.Path = w.Path + out.Value = w.Value + return out, nil +} + +// AccountPatchFromSDK converts the sdk-go type to the mirror. +func AccountPatchFromSDK(v *sdk.AccountPatch) (*AccountPatch, error) { + if v == nil { + return nil, nil + } + out := &AccountPatch{} + out.Op = v.Op + out.Path = v.Path + out.Value = v.Value + return out, nil +} + +// AccountResourceMetaToSDK converts the mirror to the sdk-go type. +func AccountResourceMetaToSDK(w *AccountResourceMeta) (*sdk.AccountResourceMeta, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountResourceMeta{} + out.ResourceType = w.ResourceType + return out, nil +} + +// AccountResourceMetaFromSDK converts the sdk-go type to the mirror. +func AccountResourceMetaFromSDK(v *sdk.AccountResourceMeta) (*AccountResourceMeta, error) { + if v == nil { + return nil, nil + } + out := &AccountResourceMeta{} + out.ResourceType = v.ResourceType + return out, nil +} + +// AccountServicePrincipalToSDK converts the mirror to the sdk-go type. +func AccountServicePrincipalToSDK(w *AccountServicePrincipal) (*sdk.AccountServicePrincipal, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountServicePrincipal{} + out.Active = w.Active + out.ApplicationId = w.ApplicationId + out.DisplayName = w.DisplayName + out.ExternalId = w.ExternalId + out.Id = w.Id + conv7, err := convertSlice(w.Roles, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountServicePrincipal.Roles", err) + } + out.Roles = conv7 + out.AccountId = w.AccountId + return out, nil +} + +// AccountServicePrincipalFromSDK converts the sdk-go type to the mirror. +func AccountServicePrincipalFromSDK(v *sdk.AccountServicePrincipal) (*AccountServicePrincipal, error) { + if v == nil { + return nil, nil + } + out := &AccountServicePrincipal{} + out.Active = v.Active + out.ApplicationId = v.ApplicationId + out.DisplayName = v.DisplayName + out.ExternalId = v.ExternalId + out.Id = v.Id + conv8, err := convertSlice(v.Roles, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountServicePrincipal.Roles", err) + } + out.Roles = conv8 + out.AccountId = v.AccountId + return out, nil +} + +// AccountUserToSDK converts the mirror to the sdk-go type. +func AccountUserToSDK(w *AccountUser) (*sdk.AccountUser, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountUser{} + out.Active = w.Active + out.DisplayName = w.DisplayName + conv9, err := convertSlice(w.Emails, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountUser.Emails", err) + } + out.Emails = conv9 + out.ExternalId = w.ExternalId + out.Id = w.Id + conv10, err := AccountNameToSDK(w.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountUser.Name", err) + } + out.Name = conv10 + conv11, err := convertSlice(w.Roles, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountUser.Roles", err) + } + out.Roles = conv11 + out.UserName = w.UserName + out.AccountId = w.AccountId + return out, nil +} + +// AccountUserFromSDK converts the sdk-go type to the mirror. +func AccountUserFromSDK(v *sdk.AccountUser) (*AccountUser, error) { + if v == nil { + return nil, nil + } + out := &AccountUser{} + out.Active = v.Active + out.DisplayName = v.DisplayName + conv12, err := convertSlice(v.Emails, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountUser.Emails", err) + } + out.Emails = conv12 + out.ExternalId = v.ExternalId + out.Id = v.Id + conv13, err := AccountNameFromSDK(v.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountUser.Name", err) + } + out.Name = conv13 + conv14, err := convertSlice(v.Roles, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountUser.Roles", err) + } + out.Roles = conv14 + out.UserName = v.UserName + out.AccountId = v.AccountId + return out, nil +} + +// ComplexValueToSDK converts the mirror to the sdk-go type. +func ComplexValueToSDK(w *ComplexValue) (*sdk.ComplexValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.ComplexValue{} + out.Display = w.Display + out.Primary = w.Primary + out.Ref = w.Ref + out.Type = w.Type + out.Value = w.Value + return out, nil +} + +// ComplexValueFromSDK converts the sdk-go type to the mirror. +func ComplexValueFromSDK(v *sdk.ComplexValue) (*ComplexValue, error) { + if v == nil { + return nil, nil + } + out := &ComplexValue{} + out.Display = v.Display + out.Primary = v.Primary + out.Ref = v.Ref + out.Type = v.Type + out.Value = v.Value + return out, nil +} + +// CreateAccountGroupRequestToSDK converts the mirror to the sdk-go type. +func CreateAccountGroupRequestToSDK(w *CreateAccountGroupRequest) (*sdk.CreateAccountGroupRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAccountGroupRequest{} + out.DisplayName = w.DisplayName + out.ExternalId = w.ExternalId + out.Id = w.Id + conv15, err := convertSlice(w.Members, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountGroupRequest.Members", err) + } + out.Members = conv15 + conv16, err := AccountResourceMetaToSDK(w.Meta) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountGroupRequest.Meta", err) + } + out.Meta = conv16 + conv17, err := convertSlice(w.Roles, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountGroupRequest.Roles", err) + } + out.Roles = conv17 + out.AccountId = w.AccountId + return out, nil +} + +// CreateAccountGroupRequestFromSDK converts the sdk-go type to the mirror. +func CreateAccountGroupRequestFromSDK(v *sdk.CreateAccountGroupRequest) (*CreateAccountGroupRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateAccountGroupRequest{} + out.DisplayName = v.DisplayName + out.ExternalId = v.ExternalId + out.Id = v.Id + conv18, err := convertSlice(v.Members, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountGroupRequest.Members", err) + } + out.Members = conv18 + conv19, err := AccountResourceMetaFromSDK(v.Meta) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountGroupRequest.Meta", err) + } + out.Meta = conv19 + conv20, err := convertSlice(v.Roles, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountGroupRequest.Roles", err) + } + out.Roles = conv20 + out.AccountId = v.AccountId + return out, nil +} + +// CreateAccountServicePrincipalRequestToSDK converts the mirror to the sdk-go type. +func CreateAccountServicePrincipalRequestToSDK(w *CreateAccountServicePrincipalRequest) (*sdk.CreateAccountServicePrincipalRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAccountServicePrincipalRequest{} + out.Active = w.Active + out.ApplicationId = w.ApplicationId + out.DisplayName = w.DisplayName + out.ExternalId = w.ExternalId + out.Id = w.Id + conv21, err := convertSlice(w.Roles, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountServicePrincipalRequest.Roles", err) + } + out.Roles = conv21 + out.AccountId = w.AccountId + return out, nil +} + +// CreateAccountServicePrincipalRequestFromSDK converts the sdk-go type to the mirror. +func CreateAccountServicePrincipalRequestFromSDK(v *sdk.CreateAccountServicePrincipalRequest) (*CreateAccountServicePrincipalRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateAccountServicePrincipalRequest{} + out.Active = v.Active + out.ApplicationId = v.ApplicationId + out.DisplayName = v.DisplayName + out.ExternalId = v.ExternalId + out.Id = v.Id + conv22, err := convertSlice(v.Roles, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountServicePrincipalRequest.Roles", err) + } + out.Roles = conv22 + out.AccountId = v.AccountId + return out, nil +} + +// CreateAccountUserRequestToSDK converts the mirror to the sdk-go type. +func CreateAccountUserRequestToSDK(w *CreateAccountUserRequest) (*sdk.CreateAccountUserRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAccountUserRequest{} + out.Active = w.Active + out.DisplayName = w.DisplayName + conv23, err := convertSlice(w.Emails, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountUserRequest.Emails", err) + } + out.Emails = conv23 + out.ExternalId = w.ExternalId + out.Id = w.Id + conv24, err := AccountNameToSDK(w.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountUserRequest.Name", err) + } + out.Name = conv24 + conv25, err := convertSlice(w.Roles, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountUserRequest.Roles", err) + } + out.Roles = conv25 + out.UserName = w.UserName + out.AccountId = w.AccountId + return out, nil +} + +// CreateAccountUserRequestFromSDK converts the sdk-go type to the mirror. +func CreateAccountUserRequestFromSDK(v *sdk.CreateAccountUserRequest) (*CreateAccountUserRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateAccountUserRequest{} + out.Active = v.Active + out.DisplayName = v.DisplayName + conv26, err := convertSlice(v.Emails, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountUserRequest.Emails", err) + } + out.Emails = conv26 + out.ExternalId = v.ExternalId + out.Id = v.Id + conv27, err := AccountNameFromSDK(v.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountUserRequest.Name", err) + } + out.Name = conv27 + conv28, err := convertSlice(v.Roles, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountUserRequest.Roles", err) + } + out.Roles = conv28 + out.UserName = v.UserName + out.AccountId = v.AccountId + return out, nil +} + +// CreateGroupRequestToSDK converts the mirror to the sdk-go type. +func CreateGroupRequestToSDK(w *CreateGroupRequest) (*sdk.CreateGroupRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateGroupRequest{} + out.DisplayName = w.DisplayName + conv29, err := convertSlice(w.Entitlements, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGroupRequest.Entitlements", err) + } + out.Entitlements = conv29 + out.ExternalId = w.ExternalId + conv30, err := convertSlice(w.Groups, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGroupRequest.Groups", err) + } + out.Groups = conv30 + out.Id = w.Id + conv31, err := convertSlice(w.Members, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGroupRequest.Members", err) + } + out.Members = conv31 + conv32, err := ResourceMetaToSDK(w.Meta) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGroupRequest.Meta", err) + } + out.Meta = conv32 + conv33, err := convertSlice(w.Roles, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGroupRequest.Roles", err) + } + out.Roles = conv33 + out.Schemas = w.Schemas + return out, nil +} + +// CreateGroupRequestFromSDK converts the sdk-go type to the mirror. +func CreateGroupRequestFromSDK(v *sdk.CreateGroupRequest) (*CreateGroupRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateGroupRequest{} + out.DisplayName = v.DisplayName + conv34, err := convertSlice(v.Entitlements, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGroupRequest.Entitlements", err) + } + out.Entitlements = conv34 + out.ExternalId = v.ExternalId + conv35, err := convertSlice(v.Groups, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGroupRequest.Groups", err) + } + out.Groups = conv35 + out.Id = v.Id + conv36, err := convertSlice(v.Members, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGroupRequest.Members", err) + } + out.Members = conv36 + conv37, err := ResourceMetaFromSDK(v.Meta) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGroupRequest.Meta", err) + } + out.Meta = conv37 + conv38, err := convertSlice(v.Roles, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateGroupRequest.Roles", err) + } + out.Roles = conv38 + out.Schemas = v.Schemas + return out, nil +} + +// CreateServicePrincipalRequestToSDK converts the mirror to the sdk-go type. +func CreateServicePrincipalRequestToSDK(w *CreateServicePrincipalRequest) (*sdk.CreateServicePrincipalRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateServicePrincipalRequest{} + out.Active = w.Active + out.ApplicationId = w.ApplicationId + out.DisplayName = w.DisplayName + conv39, err := convertSlice(w.Entitlements, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateServicePrincipalRequest.Entitlements", err) + } + out.Entitlements = conv39 + out.ExternalId = w.ExternalId + conv40, err := convertSlice(w.Groups, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateServicePrincipalRequest.Groups", err) + } + out.Groups = conv40 + out.Id = w.Id + conv41, err := convertSlice(w.Roles, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateServicePrincipalRequest.Roles", err) + } + out.Roles = conv41 + out.Schemas = w.Schemas + return out, nil +} + +// CreateServicePrincipalRequestFromSDK converts the sdk-go type to the mirror. +func CreateServicePrincipalRequestFromSDK(v *sdk.CreateServicePrincipalRequest) (*CreateServicePrincipalRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateServicePrincipalRequest{} + out.Active = v.Active + out.ApplicationId = v.ApplicationId + out.DisplayName = v.DisplayName + conv42, err := convertSlice(v.Entitlements, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateServicePrincipalRequest.Entitlements", err) + } + out.Entitlements = conv42 + out.ExternalId = v.ExternalId + conv43, err := convertSlice(v.Groups, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateServicePrincipalRequest.Groups", err) + } + out.Groups = conv43 + out.Id = v.Id + conv44, err := convertSlice(v.Roles, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateServicePrincipalRequest.Roles", err) + } + out.Roles = conv44 + out.Schemas = v.Schemas + return out, nil +} + +// CreateUserRequestToSDK converts the mirror to the sdk-go type. +func CreateUserRequestToSDK(w *CreateUserRequest) (*sdk.CreateUserRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateUserRequest{} + out.Active = w.Active + out.DisplayName = w.DisplayName + conv45, err := convertSlice(w.Emails, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateUserRequest.Emails", err) + } + out.Emails = conv45 + conv46, err := convertSlice(w.Entitlements, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateUserRequest.Entitlements", err) + } + out.Entitlements = conv46 + out.ExternalId = w.ExternalId + conv47, err := convertSlice(w.Groups, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateUserRequest.Groups", err) + } + out.Groups = conv47 + out.Id = w.Id + conv48, err := NameToSDK(w.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateUserRequest.Name", err) + } + out.Name = conv48 + conv49, err := convertSlice(w.Roles, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateUserRequest.Roles", err) + } + out.Roles = conv49 + out.Schemas = w.Schemas + out.UserName = w.UserName + return out, nil +} + +// CreateUserRequestFromSDK converts the sdk-go type to the mirror. +func CreateUserRequestFromSDK(v *sdk.CreateUserRequest) (*CreateUserRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateUserRequest{} + out.Active = v.Active + out.DisplayName = v.DisplayName + conv50, err := convertSlice(v.Emails, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateUserRequest.Emails", err) + } + out.Emails = conv50 + conv51, err := convertSlice(v.Entitlements, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateUserRequest.Entitlements", err) + } + out.Entitlements = conv51 + out.ExternalId = v.ExternalId + conv52, err := convertSlice(v.Groups, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateUserRequest.Groups", err) + } + out.Groups = conv52 + out.Id = v.Id + conv53, err := NameFromSDK(v.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateUserRequest.Name", err) + } + out.Name = conv53 + conv54, err := convertSlice(v.Roles, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateUserRequest.Roles", err) + } + out.Roles = conv54 + out.Schemas = v.Schemas + out.UserName = v.UserName + return out, nil +} + +// GetAccountUserRequestToSDK converts the mirror to the sdk-go type. +func GetAccountUserRequestToSDK(w *GetAccountUserRequest) (*sdk.GetAccountUserRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetAccountUserRequest{} + out.Attributes = w.Attributes + out.Count = w.Count + out.ExcludedAttributes = w.ExcludedAttributes + out.Filter = w.Filter + out.Id = w.Id + out.SortBy = w.SortBy + out.SortOrder = w.SortOrder + out.StartIndex = w.StartIndex + out.AccountId = w.AccountId + return out, nil +} + +// GetAccountUserRequestFromSDK converts the sdk-go type to the mirror. +func GetAccountUserRequestFromSDK(v *sdk.GetAccountUserRequest) (*GetAccountUserRequest, error) { + if v == nil { + return nil, nil + } + out := &GetAccountUserRequest{} + out.Attributes = v.Attributes + out.Count = v.Count + out.ExcludedAttributes = v.ExcludedAttributes + out.Filter = v.Filter + out.Id = v.Id + out.SortBy = v.SortBy + out.SortOrder = v.SortOrder + out.StartIndex = v.StartIndex + out.AccountId = v.AccountId + return out, nil +} + +// GetPasswordPermissionLevelsResponseToSDK converts the mirror to the sdk-go type. +func GetPasswordPermissionLevelsResponseToSDK(w *GetPasswordPermissionLevelsResponse) (*sdk.GetPasswordPermissionLevelsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPasswordPermissionLevelsResponse{} + conv55, err := convertSlice(w.PermissionLevels, PasswordPermissionsDescriptionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPasswordPermissionLevelsResponse.PermissionLevels", err) + } + out.PermissionLevels = conv55 + return out, nil +} + +// GetPasswordPermissionLevelsResponseFromSDK converts the sdk-go type to the mirror. +func GetPasswordPermissionLevelsResponseFromSDK(v *sdk.GetPasswordPermissionLevelsResponse) (*GetPasswordPermissionLevelsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetPasswordPermissionLevelsResponse{} + conv56, err := convertSlice(v.PermissionLevels, PasswordPermissionsDescriptionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPasswordPermissionLevelsResponse.PermissionLevels", err) + } + out.PermissionLevels = conv56 + return out, nil +} + +// GetUserRequestToSDK converts the mirror to the sdk-go type. +func GetUserRequestToSDK(w *GetUserRequest) (*sdk.GetUserRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetUserRequest{} + out.Attributes = w.Attributes + out.Count = w.Count + out.ExcludedAttributes = w.ExcludedAttributes + out.Filter = w.Filter + out.Id = w.Id + out.SortBy = w.SortBy + out.SortOrder = w.SortOrder + out.StartIndex = w.StartIndex + return out, nil +} + +// GetUserRequestFromSDK converts the sdk-go type to the mirror. +func GetUserRequestFromSDK(v *sdk.GetUserRequest) (*GetUserRequest, error) { + if v == nil { + return nil, nil + } + out := &GetUserRequest{} + out.Attributes = v.Attributes + out.Count = v.Count + out.ExcludedAttributes = v.ExcludedAttributes + out.Filter = v.Filter + out.Id = v.Id + out.SortBy = v.SortBy + out.SortOrder = v.SortOrder + out.StartIndex = v.StartIndex + return out, nil +} + +// GroupToSDK converts the mirror to the sdk-go type. +func GroupToSDK(w *Group) (*sdk.Group, error) { + if w == nil { + return nil, nil + } + out := &sdk.Group{} + out.DisplayName = w.DisplayName + conv57, err := convertSlice(w.Entitlements, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Group.Entitlements", err) + } + out.Entitlements = conv57 + out.ExternalId = w.ExternalId + conv58, err := convertSlice(w.Groups, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Group.Groups", err) + } + out.Groups = conv58 + out.Id = w.Id + conv59, err := convertSlice(w.Members, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Group.Members", err) + } + out.Members = conv59 + conv60, err := ResourceMetaToSDK(w.Meta) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Group.Meta", err) + } + out.Meta = conv60 + conv61, err := convertSlice(w.Roles, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Group.Roles", err) + } + out.Roles = conv61 + out.Schemas = w.Schemas + return out, nil +} + +// GroupFromSDK converts the sdk-go type to the mirror. +func GroupFromSDK(v *sdk.Group) (*Group, error) { + if v == nil { + return nil, nil + } + out := &Group{} + out.DisplayName = v.DisplayName + conv62, err := convertSlice(v.Entitlements, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Group.Entitlements", err) + } + out.Entitlements = conv62 + out.ExternalId = v.ExternalId + conv63, err := convertSlice(v.Groups, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Group.Groups", err) + } + out.Groups = conv63 + out.Id = v.Id + conv64, err := convertSlice(v.Members, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Group.Members", err) + } + out.Members = conv64 + conv65, err := ResourceMetaFromSDK(v.Meta) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Group.Meta", err) + } + out.Meta = conv65 + conv66, err := convertSlice(v.Roles, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Group.Roles", err) + } + out.Roles = conv66 + out.Schemas = v.Schemas + return out, nil +} + +// ListAccountGroupsRequestToSDK converts the mirror to the sdk-go type. +func ListAccountGroupsRequestToSDK(w *ListAccountGroupsRequest) (*sdk.ListAccountGroupsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAccountGroupsRequest{} + out.AccountId = w.AccountId + out.Filter = w.Filter + out.Attributes = w.Attributes + out.ExcludedAttributes = w.ExcludedAttributes + out.StartIndex = w.StartIndex + out.Count = w.Count + out.SortBy = w.SortBy + out.SortOrder = w.SortOrder + return out, nil +} + +// ListAccountGroupsRequestFromSDK converts the sdk-go type to the mirror. +func ListAccountGroupsRequestFromSDK(v *sdk.ListAccountGroupsRequest) (*ListAccountGroupsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListAccountGroupsRequest{} + out.AccountId = v.AccountId + out.Filter = v.Filter + out.Attributes = v.Attributes + out.ExcludedAttributes = v.ExcludedAttributes + out.StartIndex = v.StartIndex + out.Count = v.Count + out.SortBy = v.SortBy + out.SortOrder = v.SortOrder + return out, nil +} + +// ListAccountGroupsResponseToSDK converts the mirror to the sdk-go type. +func ListAccountGroupsResponseToSDK(w *ListAccountGroupsResponse) (*sdk.ListAccountGroupsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAccountGroupsResponse{} + out.ItemsPerPage = w.ItemsPerPage + conv67, err := convertSlice(w.Resources, AccountGroupToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAccountGroupsResponse.Resources", err) + } + out.Resources = conv67 + out.StartIndex = w.StartIndex + out.TotalResults = w.TotalResults + return out, nil +} + +// ListAccountGroupsResponseFromSDK converts the sdk-go type to the mirror. +func ListAccountGroupsResponseFromSDK(v *sdk.ListAccountGroupsResponse) (*ListAccountGroupsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAccountGroupsResponse{} + out.ItemsPerPage = v.ItemsPerPage + conv68, err := convertSlice(v.Resources, AccountGroupFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAccountGroupsResponse.Resources", err) + } + out.Resources = conv68 + out.StartIndex = v.StartIndex + out.TotalResults = v.TotalResults + return out, nil +} + +// ListAccountServicePrincipalsRequestToSDK converts the mirror to the sdk-go type. +func ListAccountServicePrincipalsRequestToSDK(w *ListAccountServicePrincipalsRequest) (*sdk.ListAccountServicePrincipalsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAccountServicePrincipalsRequest{} + out.Attributes = w.Attributes + out.Count = w.Count + out.ExcludedAttributes = w.ExcludedAttributes + out.Filter = w.Filter + out.SortBy = w.SortBy + out.SortOrder = w.SortOrder + out.StartIndex = w.StartIndex + out.AccountId = w.AccountId + return out, nil +} + +// ListAccountServicePrincipalsRequestFromSDK converts the sdk-go type to the mirror. +func ListAccountServicePrincipalsRequestFromSDK(v *sdk.ListAccountServicePrincipalsRequest) (*ListAccountServicePrincipalsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListAccountServicePrincipalsRequest{} + out.Attributes = v.Attributes + out.Count = v.Count + out.ExcludedAttributes = v.ExcludedAttributes + out.Filter = v.Filter + out.SortBy = v.SortBy + out.SortOrder = v.SortOrder + out.StartIndex = v.StartIndex + out.AccountId = v.AccountId + return out, nil +} + +// ListAccountServicePrincipalsResponseToSDK converts the mirror to the sdk-go type. +func ListAccountServicePrincipalsResponseToSDK(w *ListAccountServicePrincipalsResponse) (*sdk.ListAccountServicePrincipalsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAccountServicePrincipalsResponse{} + out.ItemsPerPage = w.ItemsPerPage + conv69, err := convertSlice(w.Resources, AccountServicePrincipalToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAccountServicePrincipalsResponse.Resources", err) + } + out.Resources = conv69 + out.StartIndex = w.StartIndex + out.TotalResults = w.TotalResults + return out, nil +} + +// ListAccountServicePrincipalsResponseFromSDK converts the sdk-go type to the mirror. +func ListAccountServicePrincipalsResponseFromSDK(v *sdk.ListAccountServicePrincipalsResponse) (*ListAccountServicePrincipalsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAccountServicePrincipalsResponse{} + out.ItemsPerPage = v.ItemsPerPage + conv70, err := convertSlice(v.Resources, AccountServicePrincipalFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAccountServicePrincipalsResponse.Resources", err) + } + out.Resources = conv70 + out.StartIndex = v.StartIndex + out.TotalResults = v.TotalResults + return out, nil +} + +// ListAccountUsersRequestToSDK converts the mirror to the sdk-go type. +func ListAccountUsersRequestToSDK(w *ListAccountUsersRequest) (*sdk.ListAccountUsersRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAccountUsersRequest{} + out.Attributes = w.Attributes + out.Count = w.Count + out.ExcludedAttributes = w.ExcludedAttributes + out.Filter = w.Filter + out.SortBy = w.SortBy + out.SortOrder = w.SortOrder + out.StartIndex = w.StartIndex + out.AccountId = w.AccountId + return out, nil +} + +// ListAccountUsersRequestFromSDK converts the sdk-go type to the mirror. +func ListAccountUsersRequestFromSDK(v *sdk.ListAccountUsersRequest) (*ListAccountUsersRequest, error) { + if v == nil { + return nil, nil + } + out := &ListAccountUsersRequest{} + out.Attributes = v.Attributes + out.Count = v.Count + out.ExcludedAttributes = v.ExcludedAttributes + out.Filter = v.Filter + out.SortBy = v.SortBy + out.SortOrder = v.SortOrder + out.StartIndex = v.StartIndex + out.AccountId = v.AccountId + return out, nil +} + +// ListAccountUsersResponseToSDK converts the mirror to the sdk-go type. +func ListAccountUsersResponseToSDK(w *ListAccountUsersResponse) (*sdk.ListAccountUsersResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAccountUsersResponse{} + out.ItemsPerPage = w.ItemsPerPage + conv71, err := convertSlice(w.Resources, AccountUserToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAccountUsersResponse.Resources", err) + } + out.Resources = conv71 + out.StartIndex = w.StartIndex + out.TotalResults = w.TotalResults + return out, nil +} + +// ListAccountUsersResponseFromSDK converts the sdk-go type to the mirror. +func ListAccountUsersResponseFromSDK(v *sdk.ListAccountUsersResponse) (*ListAccountUsersResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAccountUsersResponse{} + out.ItemsPerPage = v.ItemsPerPage + conv72, err := convertSlice(v.Resources, AccountUserFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAccountUsersResponse.Resources", err) + } + out.Resources = conv72 + out.StartIndex = v.StartIndex + out.TotalResults = v.TotalResults + return out, nil +} + +// ListGroupsRequestToSDK converts the mirror to the sdk-go type. +func ListGroupsRequestToSDK(w *ListGroupsRequest) (*sdk.ListGroupsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListGroupsRequest{} + out.Filter = w.Filter + out.Attributes = w.Attributes + out.ExcludedAttributes = w.ExcludedAttributes + out.StartIndex = w.StartIndex + out.Count = w.Count + out.SortBy = w.SortBy + out.SortOrder = w.SortOrder + return out, nil +} + +// ListGroupsRequestFromSDK converts the sdk-go type to the mirror. +func ListGroupsRequestFromSDK(v *sdk.ListGroupsRequest) (*ListGroupsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListGroupsRequest{} + out.Filter = v.Filter + out.Attributes = v.Attributes + out.ExcludedAttributes = v.ExcludedAttributes + out.StartIndex = v.StartIndex + out.Count = v.Count + out.SortBy = v.SortBy + out.SortOrder = v.SortOrder + return out, nil +} + +// ListGroupsResponseToSDK converts the mirror to the sdk-go type. +func ListGroupsResponseToSDK(w *ListGroupsResponse) (*sdk.ListGroupsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListGroupsResponse{} + out.ItemsPerPage = w.ItemsPerPage + conv73, err := convertSlice(w.Resources, GroupToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListGroupsResponse.Resources", err) + } + out.Resources = conv73 + out.Schemas = w.Schemas + out.StartIndex = w.StartIndex + out.TotalResults = w.TotalResults + return out, nil +} + +// ListGroupsResponseFromSDK converts the sdk-go type to the mirror. +func ListGroupsResponseFromSDK(v *sdk.ListGroupsResponse) (*ListGroupsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListGroupsResponse{} + out.ItemsPerPage = v.ItemsPerPage + conv74, err := convertSlice(v.Resources, GroupFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListGroupsResponse.Resources", err) + } + out.Resources = conv74 + out.Schemas = v.Schemas + out.StartIndex = v.StartIndex + out.TotalResults = v.TotalResults + return out, nil +} + +// ListServicePrincipalResponseToSDK converts the mirror to the sdk-go type. +func ListServicePrincipalResponseToSDK(w *ListServicePrincipalResponse) (*sdk.ListServicePrincipalResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListServicePrincipalResponse{} + out.ItemsPerPage = w.ItemsPerPage + conv75, err := convertSlice(w.Resources, ServicePrincipalToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListServicePrincipalResponse.Resources", err) + } + out.Resources = conv75 + out.Schemas = w.Schemas + out.StartIndex = w.StartIndex + out.TotalResults = w.TotalResults + return out, nil +} + +// ListServicePrincipalResponseFromSDK converts the sdk-go type to the mirror. +func ListServicePrincipalResponseFromSDK(v *sdk.ListServicePrincipalResponse) (*ListServicePrincipalResponse, error) { + if v == nil { + return nil, nil + } + out := &ListServicePrincipalResponse{} + out.ItemsPerPage = v.ItemsPerPage + conv76, err := convertSlice(v.Resources, ServicePrincipalFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListServicePrincipalResponse.Resources", err) + } + out.Resources = conv76 + out.Schemas = v.Schemas + out.StartIndex = v.StartIndex + out.TotalResults = v.TotalResults + return out, nil +} + +// ListServicePrincipalsRequestToSDK converts the mirror to the sdk-go type. +func ListServicePrincipalsRequestToSDK(w *ListServicePrincipalsRequest) (*sdk.ListServicePrincipalsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListServicePrincipalsRequest{} + out.Attributes = w.Attributes + out.Count = w.Count + out.ExcludedAttributes = w.ExcludedAttributes + out.Filter = w.Filter + out.SortBy = w.SortBy + out.SortOrder = w.SortOrder + out.StartIndex = w.StartIndex + return out, nil +} + +// ListServicePrincipalsRequestFromSDK converts the sdk-go type to the mirror. +func ListServicePrincipalsRequestFromSDK(v *sdk.ListServicePrincipalsRequest) (*ListServicePrincipalsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListServicePrincipalsRequest{} + out.Attributes = v.Attributes + out.Count = v.Count + out.ExcludedAttributes = v.ExcludedAttributes + out.Filter = v.Filter + out.SortBy = v.SortBy + out.SortOrder = v.SortOrder + out.StartIndex = v.StartIndex + return out, nil +} + +// ListUsersRequestToSDK converts the mirror to the sdk-go type. +func ListUsersRequestToSDK(w *ListUsersRequest) (*sdk.ListUsersRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListUsersRequest{} + out.Attributes = w.Attributes + out.Count = w.Count + out.ExcludedAttributes = w.ExcludedAttributes + out.Filter = w.Filter + out.SortBy = w.SortBy + out.SortOrder = w.SortOrder + out.StartIndex = w.StartIndex + return out, nil +} + +// ListUsersRequestFromSDK converts the sdk-go type to the mirror. +func ListUsersRequestFromSDK(v *sdk.ListUsersRequest) (*ListUsersRequest, error) { + if v == nil { + return nil, nil + } + out := &ListUsersRequest{} + out.Attributes = v.Attributes + out.Count = v.Count + out.ExcludedAttributes = v.ExcludedAttributes + out.Filter = v.Filter + out.SortBy = v.SortBy + out.SortOrder = v.SortOrder + out.StartIndex = v.StartIndex + return out, nil +} + +// ListUsersResponseToSDK converts the mirror to the sdk-go type. +func ListUsersResponseToSDK(w *ListUsersResponse) (*sdk.ListUsersResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListUsersResponse{} + out.ItemsPerPage = w.ItemsPerPage + conv77, err := convertSlice(w.Resources, UserToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListUsersResponse.Resources", err) + } + out.Resources = conv77 + out.Schemas = w.Schemas + out.StartIndex = w.StartIndex + out.TotalResults = w.TotalResults + return out, nil +} + +// ListUsersResponseFromSDK converts the sdk-go type to the mirror. +func ListUsersResponseFromSDK(v *sdk.ListUsersResponse) (*ListUsersResponse, error) { + if v == nil { + return nil, nil + } + out := &ListUsersResponse{} + out.ItemsPerPage = v.ItemsPerPage + conv78, err := convertSlice(v.Resources, UserFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListUsersResponse.Resources", err) + } + out.Resources = conv78 + out.Schemas = v.Schemas + out.StartIndex = v.StartIndex + out.TotalResults = v.TotalResults + return out, nil +} + +// MeRequestToSDK converts the mirror to the sdk-go type. +func MeRequestToSDK(w *MeRequest) (*sdk.MeRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.MeRequest{} + out.Attributes = w.Attributes + out.ExcludedAttributes = w.ExcludedAttributes + return out, nil +} + +// MeRequestFromSDK converts the sdk-go type to the mirror. +func MeRequestFromSDK(v *sdk.MeRequest) (*MeRequest, error) { + if v == nil { + return nil, nil + } + out := &MeRequest{} + out.Attributes = v.Attributes + out.ExcludedAttributes = v.ExcludedAttributes + return out, nil +} + +// NameToSDK converts the mirror to the sdk-go type. +func NameToSDK(w *Name) (*sdk.Name, error) { + if w == nil { + return nil, nil + } + out := &sdk.Name{} + out.FamilyName = w.FamilyName + out.GivenName = w.GivenName + return out, nil +} + +// NameFromSDK converts the sdk-go type to the mirror. +func NameFromSDK(v *sdk.Name) (*Name, error) { + if v == nil { + return nil, nil + } + out := &Name{} + out.FamilyName = v.FamilyName + out.GivenName = v.GivenName + return out, nil +} + +// PasswordAccessControlRequestToSDK converts the mirror to the sdk-go type. +func PasswordAccessControlRequestToSDK(w *PasswordAccessControlRequest) (*sdk.PasswordAccessControlRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PasswordAccessControlRequest{} + out.GroupName = w.GroupName + out.PermissionLevel = w.PermissionLevel + out.ServicePrincipalName = w.ServicePrincipalName + out.UserName = w.UserName + return out, nil +} + +// PasswordAccessControlRequestFromSDK converts the sdk-go type to the mirror. +func PasswordAccessControlRequestFromSDK(v *sdk.PasswordAccessControlRequest) (*PasswordAccessControlRequest, error) { + if v == nil { + return nil, nil + } + out := &PasswordAccessControlRequest{} + out.GroupName = v.GroupName + out.PermissionLevel = v.PermissionLevel + out.ServicePrincipalName = v.ServicePrincipalName + out.UserName = v.UserName + return out, nil +} + +// PasswordAccessControlResponseToSDK converts the mirror to the sdk-go type. +func PasswordAccessControlResponseToSDK(w *PasswordAccessControlResponse) (*sdk.PasswordAccessControlResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.PasswordAccessControlResponse{} + conv79, err := convertSlice(w.AllPermissions, PasswordPermissionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PasswordAccessControlResponse.AllPermissions", err) + } + out.AllPermissions = conv79 + out.DisplayName = w.DisplayName + out.GroupName = w.GroupName + out.ServicePrincipalName = w.ServicePrincipalName + out.UserName = w.UserName + return out, nil +} + +// PasswordAccessControlResponseFromSDK converts the sdk-go type to the mirror. +func PasswordAccessControlResponseFromSDK(v *sdk.PasswordAccessControlResponse) (*PasswordAccessControlResponse, error) { + if v == nil { + return nil, nil + } + out := &PasswordAccessControlResponse{} + conv80, err := convertSlice(v.AllPermissions, PasswordPermissionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PasswordAccessControlResponse.AllPermissions", err) + } + out.AllPermissions = conv80 + out.DisplayName = v.DisplayName + out.GroupName = v.GroupName + out.ServicePrincipalName = v.ServicePrincipalName + out.UserName = v.UserName + return out, nil +} + +// PasswordPermissionToSDK converts the mirror to the sdk-go type. +func PasswordPermissionToSDK(w *PasswordPermission) (*sdk.PasswordPermission, error) { + if w == nil { + return nil, nil + } + out := &sdk.PasswordPermission{} + out.Inherited = w.Inherited + out.InheritedFromObject = w.InheritedFromObject + out.PermissionLevel = w.PermissionLevel + return out, nil +} + +// PasswordPermissionFromSDK converts the sdk-go type to the mirror. +func PasswordPermissionFromSDK(v *sdk.PasswordPermission) (*PasswordPermission, error) { + if v == nil { + return nil, nil + } + out := &PasswordPermission{} + out.Inherited = v.Inherited + out.InheritedFromObject = v.InheritedFromObject + out.PermissionLevel = v.PermissionLevel + return out, nil +} + +// PasswordPermissionsToSDK converts the mirror to the sdk-go type. +func PasswordPermissionsToSDK(w *PasswordPermissions) (*sdk.PasswordPermissions, error) { + if w == nil { + return nil, nil + } + out := &sdk.PasswordPermissions{} + conv81, err := convertSlice(w.AccessControlList, PasswordAccessControlResponseToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PasswordPermissions.AccessControlList", err) + } + out.AccessControlList = conv81 + out.ObjectId = w.ObjectId + out.ObjectType = w.ObjectType + return out, nil +} + +// PasswordPermissionsFromSDK converts the sdk-go type to the mirror. +func PasswordPermissionsFromSDK(v *sdk.PasswordPermissions) (*PasswordPermissions, error) { + if v == nil { + return nil, nil + } + out := &PasswordPermissions{} + conv82, err := convertSlice(v.AccessControlList, PasswordAccessControlResponseFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PasswordPermissions.AccessControlList", err) + } + out.AccessControlList = conv82 + out.ObjectId = v.ObjectId + out.ObjectType = v.ObjectType + return out, nil +} + +// PasswordPermissionsDescriptionToSDK converts the mirror to the sdk-go type. +func PasswordPermissionsDescriptionToSDK(w *PasswordPermissionsDescription) (*sdk.PasswordPermissionsDescription, error) { + if w == nil { + return nil, nil + } + out := &sdk.PasswordPermissionsDescription{} + out.Description = w.Description + out.PermissionLevel = w.PermissionLevel + return out, nil +} + +// PasswordPermissionsDescriptionFromSDK converts the sdk-go type to the mirror. +func PasswordPermissionsDescriptionFromSDK(v *sdk.PasswordPermissionsDescription) (*PasswordPermissionsDescription, error) { + if v == nil { + return nil, nil + } + out := &PasswordPermissionsDescription{} + out.Description = v.Description + out.PermissionLevel = v.PermissionLevel + return out, nil +} + +// PasswordPermissionsRequestToSDK converts the mirror to the sdk-go type. +func PasswordPermissionsRequestToSDK(w *PasswordPermissionsRequest) (*sdk.PasswordPermissionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PasswordPermissionsRequest{} + conv83, err := convertSlice(w.AccessControlList, PasswordAccessControlRequestToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PasswordPermissionsRequest.AccessControlList", err) + } + out.AccessControlList = conv83 + return out, nil +} + +// PasswordPermissionsRequestFromSDK converts the sdk-go type to the mirror. +func PasswordPermissionsRequestFromSDK(v *sdk.PasswordPermissionsRequest) (*PasswordPermissionsRequest, error) { + if v == nil { + return nil, nil + } + out := &PasswordPermissionsRequest{} + conv84, err := convertSlice(v.AccessControlList, PasswordAccessControlRequestFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PasswordPermissionsRequest.AccessControlList", err) + } + out.AccessControlList = conv84 + return out, nil +} + +// PatchToSDK converts the mirror to the sdk-go type. +func PatchToSDK(w *Patch) (*sdk.Patch, error) { + if w == nil { + return nil, nil + } + out := &sdk.Patch{} + out.Op = w.Op + out.Path = w.Path + out.Value = w.Value + return out, nil +} + +// PatchFromSDK converts the sdk-go type to the mirror. +func PatchFromSDK(v *sdk.Patch) (*Patch, error) { + if v == nil { + return nil, nil + } + out := &Patch{} + out.Op = v.Op + out.Path = v.Path + out.Value = v.Value + return out, nil +} + +// PatchAccountGroupRequestToSDK converts the mirror to the sdk-go type. +func PatchAccountGroupRequestToSDK(w *PatchAccountGroupRequest) (*sdk.PatchAccountGroupRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchAccountGroupRequest{} + out.Id = w.Id + conv85, err := convertSlice(w.Operations, AccountPatchToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchAccountGroupRequest.Operations", err) + } + out.Operations = conv85 + out.Schemas = w.Schemas + out.AccountId = w.AccountId + return out, nil +} + +// PatchAccountGroupRequestFromSDK converts the sdk-go type to the mirror. +func PatchAccountGroupRequestFromSDK(v *sdk.PatchAccountGroupRequest) (*PatchAccountGroupRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchAccountGroupRequest{} + out.Id = v.Id + conv86, err := convertSlice(v.Operations, AccountPatchFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchAccountGroupRequest.Operations", err) + } + out.Operations = conv86 + out.Schemas = v.Schemas + out.AccountId = v.AccountId + return out, nil +} + +// PatchAccountServicePrincipalRequestToSDK converts the mirror to the sdk-go type. +func PatchAccountServicePrincipalRequestToSDK(w *PatchAccountServicePrincipalRequest) (*sdk.PatchAccountServicePrincipalRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchAccountServicePrincipalRequest{} + out.Id = w.Id + conv87, err := convertSlice(w.Operations, AccountPatchToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchAccountServicePrincipalRequest.Operations", err) + } + out.Operations = conv87 + out.Schemas = w.Schemas + out.AccountId = w.AccountId + return out, nil +} + +// PatchAccountServicePrincipalRequestFromSDK converts the sdk-go type to the mirror. +func PatchAccountServicePrincipalRequestFromSDK(v *sdk.PatchAccountServicePrincipalRequest) (*PatchAccountServicePrincipalRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchAccountServicePrincipalRequest{} + out.Id = v.Id + conv88, err := convertSlice(v.Operations, AccountPatchFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchAccountServicePrincipalRequest.Operations", err) + } + out.Operations = conv88 + out.Schemas = v.Schemas + out.AccountId = v.AccountId + return out, nil +} + +// PatchAccountUserRequestToSDK converts the mirror to the sdk-go type. +func PatchAccountUserRequestToSDK(w *PatchAccountUserRequest) (*sdk.PatchAccountUserRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchAccountUserRequest{} + out.Id = w.Id + conv89, err := convertSlice(w.Operations, AccountPatchToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchAccountUserRequest.Operations", err) + } + out.Operations = conv89 + out.Schemas = w.Schemas + out.AccountId = w.AccountId + return out, nil +} + +// PatchAccountUserRequestFromSDK converts the sdk-go type to the mirror. +func PatchAccountUserRequestFromSDK(v *sdk.PatchAccountUserRequest) (*PatchAccountUserRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchAccountUserRequest{} + out.Id = v.Id + conv90, err := convertSlice(v.Operations, AccountPatchFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchAccountUserRequest.Operations", err) + } + out.Operations = conv90 + out.Schemas = v.Schemas + out.AccountId = v.AccountId + return out, nil +} + +// PatchGroupRequestToSDK converts the mirror to the sdk-go type. +func PatchGroupRequestToSDK(w *PatchGroupRequest) (*sdk.PatchGroupRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchGroupRequest{} + out.Id = w.Id + conv91, err := convertSlice(w.Operations, PatchToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchGroupRequest.Operations", err) + } + out.Operations = conv91 + out.Schemas = w.Schemas + return out, nil +} + +// PatchGroupRequestFromSDK converts the sdk-go type to the mirror. +func PatchGroupRequestFromSDK(v *sdk.PatchGroupRequest) (*PatchGroupRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchGroupRequest{} + out.Id = v.Id + conv92, err := convertSlice(v.Operations, PatchFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchGroupRequest.Operations", err) + } + out.Operations = conv92 + out.Schemas = v.Schemas + return out, nil +} + +// PatchServicePrincipalRequestToSDK converts the mirror to the sdk-go type. +func PatchServicePrincipalRequestToSDK(w *PatchServicePrincipalRequest) (*sdk.PatchServicePrincipalRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchServicePrincipalRequest{} + out.Id = w.Id + conv93, err := convertSlice(w.Operations, PatchToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchServicePrincipalRequest.Operations", err) + } + out.Operations = conv93 + out.Schemas = w.Schemas + return out, nil +} + +// PatchServicePrincipalRequestFromSDK converts the sdk-go type to the mirror. +func PatchServicePrincipalRequestFromSDK(v *sdk.PatchServicePrincipalRequest) (*PatchServicePrincipalRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchServicePrincipalRequest{} + out.Id = v.Id + conv94, err := convertSlice(v.Operations, PatchFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchServicePrincipalRequest.Operations", err) + } + out.Operations = conv94 + out.Schemas = v.Schemas + return out, nil +} + +// PatchUserRequestToSDK converts the mirror to the sdk-go type. +func PatchUserRequestToSDK(w *PatchUserRequest) (*sdk.PatchUserRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchUserRequest{} + out.Id = w.Id + conv95, err := convertSlice(w.Operations, PatchToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchUserRequest.Operations", err) + } + out.Operations = conv95 + out.Schemas = w.Schemas + return out, nil +} + +// PatchUserRequestFromSDK converts the sdk-go type to the mirror. +func PatchUserRequestFromSDK(v *sdk.PatchUserRequest) (*PatchUserRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchUserRequest{} + out.Id = v.Id + conv96, err := convertSlice(v.Operations, PatchFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchUserRequest.Operations", err) + } + out.Operations = conv96 + out.Schemas = v.Schemas + return out, nil +} + +// ResourceMetaToSDK converts the mirror to the sdk-go type. +func ResourceMetaToSDK(w *ResourceMeta) (*sdk.ResourceMeta, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResourceMeta{} + out.ResourceType = w.ResourceType + return out, nil +} + +// ResourceMetaFromSDK converts the sdk-go type to the mirror. +func ResourceMetaFromSDK(v *sdk.ResourceMeta) (*ResourceMeta, error) { + if v == nil { + return nil, nil + } + out := &ResourceMeta{} + out.ResourceType = v.ResourceType + return out, nil +} + +// ServicePrincipalToSDK converts the mirror to the sdk-go type. +func ServicePrincipalToSDK(w *ServicePrincipal) (*sdk.ServicePrincipal, error) { + if w == nil { + return nil, nil + } + out := &sdk.ServicePrincipal{} + out.Active = w.Active + out.ApplicationId = w.ApplicationId + out.DisplayName = w.DisplayName + conv97, err := convertSlice(w.Entitlements, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServicePrincipal.Entitlements", err) + } + out.Entitlements = conv97 + out.ExternalId = w.ExternalId + conv98, err := convertSlice(w.Groups, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServicePrincipal.Groups", err) + } + out.Groups = conv98 + out.Id = w.Id + conv99, err := convertSlice(w.Roles, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServicePrincipal.Roles", err) + } + out.Roles = conv99 + out.Schemas = w.Schemas + return out, nil +} + +// ServicePrincipalFromSDK converts the sdk-go type to the mirror. +func ServicePrincipalFromSDK(v *sdk.ServicePrincipal) (*ServicePrincipal, error) { + if v == nil { + return nil, nil + } + out := &ServicePrincipal{} + out.Active = v.Active + out.ApplicationId = v.ApplicationId + out.DisplayName = v.DisplayName + conv100, err := convertSlice(v.Entitlements, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServicePrincipal.Entitlements", err) + } + out.Entitlements = conv100 + out.ExternalId = v.ExternalId + conv101, err := convertSlice(v.Groups, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServicePrincipal.Groups", err) + } + out.Groups = conv101 + out.Id = v.Id + conv102, err := convertSlice(v.Roles, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ServicePrincipal.Roles", err) + } + out.Roles = conv102 + out.Schemas = v.Schemas + return out, nil +} + +// UpdateAccountGroupRequestToSDK converts the mirror to the sdk-go type. +func UpdateAccountGroupRequestToSDK(w *UpdateAccountGroupRequest) (*sdk.UpdateAccountGroupRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAccountGroupRequest{} + out.DisplayName = w.DisplayName + out.ExternalId = w.ExternalId + out.Id = w.Id + conv103, err := convertSlice(w.Members, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountGroupRequest.Members", err) + } + out.Members = conv103 + conv104, err := AccountResourceMetaToSDK(w.Meta) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountGroupRequest.Meta", err) + } + out.Meta = conv104 + conv105, err := convertSlice(w.Roles, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountGroupRequest.Roles", err) + } + out.Roles = conv105 + out.AccountId = w.AccountId + return out, nil +} + +// UpdateAccountGroupRequestFromSDK converts the sdk-go type to the mirror. +func UpdateAccountGroupRequestFromSDK(v *sdk.UpdateAccountGroupRequest) (*UpdateAccountGroupRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateAccountGroupRequest{} + out.DisplayName = v.DisplayName + out.ExternalId = v.ExternalId + out.Id = v.Id + conv106, err := convertSlice(v.Members, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountGroupRequest.Members", err) + } + out.Members = conv106 + conv107, err := AccountResourceMetaFromSDK(v.Meta) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountGroupRequest.Meta", err) + } + out.Meta = conv107 + conv108, err := convertSlice(v.Roles, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountGroupRequest.Roles", err) + } + out.Roles = conv108 + out.AccountId = v.AccountId + return out, nil +} + +// UpdateAccountServicePrincipalRequestToSDK converts the mirror to the sdk-go type. +func UpdateAccountServicePrincipalRequestToSDK(w *UpdateAccountServicePrincipalRequest) (*sdk.UpdateAccountServicePrincipalRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAccountServicePrincipalRequest{} + out.Active = w.Active + out.ApplicationId = w.ApplicationId + out.DisplayName = w.DisplayName + out.ExternalId = w.ExternalId + out.Id = w.Id + conv109, err := convertSlice(w.Roles, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountServicePrincipalRequest.Roles", err) + } + out.Roles = conv109 + out.AccountId = w.AccountId + return out, nil +} + +// UpdateAccountServicePrincipalRequestFromSDK converts the sdk-go type to the mirror. +func UpdateAccountServicePrincipalRequestFromSDK(v *sdk.UpdateAccountServicePrincipalRequest) (*UpdateAccountServicePrincipalRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateAccountServicePrincipalRequest{} + out.Active = v.Active + out.ApplicationId = v.ApplicationId + out.DisplayName = v.DisplayName + out.ExternalId = v.ExternalId + out.Id = v.Id + conv110, err := convertSlice(v.Roles, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountServicePrincipalRequest.Roles", err) + } + out.Roles = conv110 + out.AccountId = v.AccountId + return out, nil +} + +// UpdateAccountUserRequestToSDK converts the mirror to the sdk-go type. +func UpdateAccountUserRequestToSDK(w *UpdateAccountUserRequest) (*sdk.UpdateAccountUserRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAccountUserRequest{} + out.Active = w.Active + out.DisplayName = w.DisplayName + conv111, err := convertSlice(w.Emails, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountUserRequest.Emails", err) + } + out.Emails = conv111 + out.ExternalId = w.ExternalId + out.Id = w.Id + conv112, err := AccountNameToSDK(w.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountUserRequest.Name", err) + } + out.Name = conv112 + conv113, err := convertSlice(w.Roles, AccountComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountUserRequest.Roles", err) + } + out.Roles = conv113 + out.UserName = w.UserName + out.AccountId = w.AccountId + return out, nil +} + +// UpdateAccountUserRequestFromSDK converts the sdk-go type to the mirror. +func UpdateAccountUserRequestFromSDK(v *sdk.UpdateAccountUserRequest) (*UpdateAccountUserRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateAccountUserRequest{} + out.Active = v.Active + out.DisplayName = v.DisplayName + conv114, err := convertSlice(v.Emails, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountUserRequest.Emails", err) + } + out.Emails = conv114 + out.ExternalId = v.ExternalId + out.Id = v.Id + conv115, err := AccountNameFromSDK(v.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountUserRequest.Name", err) + } + out.Name = conv115 + conv116, err := convertSlice(v.Roles, AccountComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountUserRequest.Roles", err) + } + out.Roles = conv116 + out.UserName = v.UserName + out.AccountId = v.AccountId + return out, nil +} + +// UpdateGroupRequestToSDK converts the mirror to the sdk-go type. +func UpdateGroupRequestToSDK(w *UpdateGroupRequest) (*sdk.UpdateGroupRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateGroupRequest{} + out.DisplayName = w.DisplayName + conv117, err := convertSlice(w.Entitlements, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateGroupRequest.Entitlements", err) + } + out.Entitlements = conv117 + out.ExternalId = w.ExternalId + conv118, err := convertSlice(w.Groups, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateGroupRequest.Groups", err) + } + out.Groups = conv118 + out.Id = w.Id + conv119, err := convertSlice(w.Members, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateGroupRequest.Members", err) + } + out.Members = conv119 + conv120, err := ResourceMetaToSDK(w.Meta) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateGroupRequest.Meta", err) + } + out.Meta = conv120 + conv121, err := convertSlice(w.Roles, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateGroupRequest.Roles", err) + } + out.Roles = conv121 + out.Schemas = w.Schemas + return out, nil +} + +// UpdateGroupRequestFromSDK converts the sdk-go type to the mirror. +func UpdateGroupRequestFromSDK(v *sdk.UpdateGroupRequest) (*UpdateGroupRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateGroupRequest{} + out.DisplayName = v.DisplayName + conv122, err := convertSlice(v.Entitlements, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateGroupRequest.Entitlements", err) + } + out.Entitlements = conv122 + out.ExternalId = v.ExternalId + conv123, err := convertSlice(v.Groups, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateGroupRequest.Groups", err) + } + out.Groups = conv123 + out.Id = v.Id + conv124, err := convertSlice(v.Members, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateGroupRequest.Members", err) + } + out.Members = conv124 + conv125, err := ResourceMetaFromSDK(v.Meta) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateGroupRequest.Meta", err) + } + out.Meta = conv125 + conv126, err := convertSlice(v.Roles, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateGroupRequest.Roles", err) + } + out.Roles = conv126 + out.Schemas = v.Schemas + return out, nil +} + +// UpdateServicePrincipalRequestToSDK converts the mirror to the sdk-go type. +func UpdateServicePrincipalRequestToSDK(w *UpdateServicePrincipalRequest) (*sdk.UpdateServicePrincipalRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateServicePrincipalRequest{} + out.Active = w.Active + out.ApplicationId = w.ApplicationId + out.DisplayName = w.DisplayName + conv127, err := convertSlice(w.Entitlements, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateServicePrincipalRequest.Entitlements", err) + } + out.Entitlements = conv127 + out.ExternalId = w.ExternalId + conv128, err := convertSlice(w.Groups, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateServicePrincipalRequest.Groups", err) + } + out.Groups = conv128 + out.Id = w.Id + conv129, err := convertSlice(w.Roles, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateServicePrincipalRequest.Roles", err) + } + out.Roles = conv129 + out.Schemas = w.Schemas + return out, nil +} + +// UpdateServicePrincipalRequestFromSDK converts the sdk-go type to the mirror. +func UpdateServicePrincipalRequestFromSDK(v *sdk.UpdateServicePrincipalRequest) (*UpdateServicePrincipalRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateServicePrincipalRequest{} + out.Active = v.Active + out.ApplicationId = v.ApplicationId + out.DisplayName = v.DisplayName + conv130, err := convertSlice(v.Entitlements, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateServicePrincipalRequest.Entitlements", err) + } + out.Entitlements = conv130 + out.ExternalId = v.ExternalId + conv131, err := convertSlice(v.Groups, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateServicePrincipalRequest.Groups", err) + } + out.Groups = conv131 + out.Id = v.Id + conv132, err := convertSlice(v.Roles, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateServicePrincipalRequest.Roles", err) + } + out.Roles = conv132 + out.Schemas = v.Schemas + return out, nil +} + +// UpdateUserRequestToSDK converts the mirror to the sdk-go type. +func UpdateUserRequestToSDK(w *UpdateUserRequest) (*sdk.UpdateUserRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateUserRequest{} + out.Active = w.Active + out.DisplayName = w.DisplayName + conv133, err := convertSlice(w.Emails, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateUserRequest.Emails", err) + } + out.Emails = conv133 + conv134, err := convertSlice(w.Entitlements, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateUserRequest.Entitlements", err) + } + out.Entitlements = conv134 + out.ExternalId = w.ExternalId + conv135, err := convertSlice(w.Groups, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateUserRequest.Groups", err) + } + out.Groups = conv135 + out.Id = w.Id + conv136, err := NameToSDK(w.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateUserRequest.Name", err) + } + out.Name = conv136 + conv137, err := convertSlice(w.Roles, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateUserRequest.Roles", err) + } + out.Roles = conv137 + out.Schemas = w.Schemas + out.UserName = w.UserName + return out, nil +} + +// UpdateUserRequestFromSDK converts the sdk-go type to the mirror. +func UpdateUserRequestFromSDK(v *sdk.UpdateUserRequest) (*UpdateUserRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateUserRequest{} + out.Active = v.Active + out.DisplayName = v.DisplayName + conv138, err := convertSlice(v.Emails, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateUserRequest.Emails", err) + } + out.Emails = conv138 + conv139, err := convertSlice(v.Entitlements, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateUserRequest.Entitlements", err) + } + out.Entitlements = conv139 + out.ExternalId = v.ExternalId + conv140, err := convertSlice(v.Groups, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateUserRequest.Groups", err) + } + out.Groups = conv140 + out.Id = v.Id + conv141, err := NameFromSDK(v.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateUserRequest.Name", err) + } + out.Name = conv141 + conv142, err := convertSlice(v.Roles, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateUserRequest.Roles", err) + } + out.Roles = conv142 + out.Schemas = v.Schemas + out.UserName = v.UserName + return out, nil +} + +// UserToSDK converts the mirror to the sdk-go type. +func UserToSDK(w *User) (*sdk.User, error) { + if w == nil { + return nil, nil + } + out := &sdk.User{} + out.Active = w.Active + out.DisplayName = w.DisplayName + conv143, err := convertSlice(w.Emails, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "User.Emails", err) + } + out.Emails = conv143 + conv144, err := convertSlice(w.Entitlements, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "User.Entitlements", err) + } + out.Entitlements = conv144 + out.ExternalId = w.ExternalId + conv145, err := convertSlice(w.Groups, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "User.Groups", err) + } + out.Groups = conv145 + out.Id = w.Id + conv146, err := NameToSDK(w.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", "User.Name", err) + } + out.Name = conv146 + conv147, err := convertSlice(w.Roles, ComplexValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "User.Roles", err) + } + out.Roles = conv147 + out.Schemas = w.Schemas + out.UserName = w.UserName + return out, nil +} + +// UserFromSDK converts the sdk-go type to the mirror. +func UserFromSDK(v *sdk.User) (*User, error) { + if v == nil { + return nil, nil + } + out := &User{} + out.Active = v.Active + out.DisplayName = v.DisplayName + conv148, err := convertSlice(v.Emails, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "User.Emails", err) + } + out.Emails = conv148 + conv149, err := convertSlice(v.Entitlements, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "User.Entitlements", err) + } + out.Entitlements = conv149 + out.ExternalId = v.ExternalId + conv150, err := convertSlice(v.Groups, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "User.Groups", err) + } + out.Groups = conv150 + out.Id = v.Id + conv151, err := NameFromSDK(v.Name) + if err != nil { + return nil, fmt.Errorf("%s: %w", "User.Name", err) + } + out.Name = conv151 + conv152, err := convertSlice(v.Roles, ComplexValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "User.Roles", err) + } + out.Roles = conv152 + out.Schemas = v.Schemas + out.UserName = v.UserName + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/sdkconv/oneofs.generated.go b/libs/sdktypes/sdkconv/oneofs.generated.go new file mode 100644 index 00000000000..2d6a7aef4e7 --- /dev/null +++ b/libs/sdktypes/sdkconv/oneofs.generated.go @@ -0,0 +1,773 @@ +// Code generated by internal/sdkconvgen. DO NOT EDIT. + +package sdkconv + +import ( + accessmanagementv1 "github.com/databricks/sdk-go/accessmanagement/v1" + aigatewayv1 "github.com/databricks/sdk-go/aigateway/v1" + aisearchv1 "github.com/databricks/sdk-go/aisearch/v1" + alertsv1 "github.com/databricks/sdk-go/alerts/v1" + alertsv2 "github.com/databricks/sdk-go/alerts/v2" + appsv1 "github.com/databricks/sdk-go/apps/v1" + authenticationv1 "github.com/databricks/sdk-go/authentication/v1" + cleanroomsv1 "github.com/databricks/sdk-go/cleanrooms/v1" + clusterlibrariesv2 "github.com/databricks/sdk-go/clusterlibraries/v2" + clusterpoliciesv2 "github.com/databricks/sdk-go/clusterpolicies/v2" + clustersv2 "github.com/databricks/sdk-go/clusters/v2" + databasev1 "github.com/databricks/sdk-go/database/v1" + dataclassificationv1 "github.com/databricks/sdk-go/dataclassification/v1" + dataqualityv1 "github.com/databricks/sdk-go/dataquality/v1" + environmentsv1 "github.com/databricks/sdk-go/environments/v1" + experimentsv1 "github.com/databricks/sdk-go/experiments/v1" + featuresv1 "github.com/databricks/sdk-go/features/v1" + geniev1 "github.com/databricks/sdk-go/genie/v1" + instancepoolsv2 "github.com/databricks/sdk-go/instancepools/v2" + jobsv2 "github.com/databricks/sdk-go/jobs/v2" + keyconfigurationsv1 "github.com/databricks/sdk-go/keyconfigurations/v1" + knowledgeassistantsv1 "github.com/databricks/sdk-go/knowledgeassistants/v1" + modelservingv1 "github.com/databricks/sdk-go/modelserving/v1" + networkingv1 "github.com/databricks/sdk-go/networking/v1" + notificationdestinationsv1 "github.com/databricks/sdk-go/notificationdestinations/v1" + pipelinesv2 "github.com/databricks/sdk-go/pipelines/v2" + postgresv1 "github.com/databricks/sdk-go/postgres/v1" + queriesv1 "github.com/databricks/sdk-go/queries/v1" + secretsv1 "github.com/databricks/sdk-go/secrets/v1" + settingsv2 "github.com/databricks/sdk-go/settings/v2" + sharingv1 "github.com/databricks/sdk-go/sharing/v1" + supervisoragentsv1 "github.com/databricks/sdk-go/supervisoragents/v1" + ucabacpoliciesv1 "github.com/databricks/sdk-go/uc/abacpolicies/v1" + uccredentialsv1 "github.com/databricks/sdk-go/uc/credentials/v1" + ucexternallineagev1 "github.com/databricks/sdk-go/uc/externallineage/v1" + ucexternallocationsv1 "github.com/databricks/sdk-go/uc/externallocations/v1" + ucfunctionsv1 "github.com/databricks/sdk-go/uc/functions/v1" + uconlinetablesv1 "github.com/databricks/sdk-go/uc/onlinetables/v1" + ucregisteredmodelsv1 "github.com/databricks/sdk-go/uc/registeredmodels/v1" + uctablesv1 "github.com/databricks/sdk-go/uc/tables/v1" + ucvolumesv1 "github.com/databricks/sdk-go/uc/volumes/v1" + vectorsearchv1 "github.com/databricks/sdk-go/vectorsearch/v1" + workspacesv1 "github.com/databricks/sdk-go/workspaces/v1" +) + +// oneofWrappers lists the oneof wrapper types of every sdk-go package. +var oneofWrappers = []any{ + (*accessmanagementv1.AccessControlRequest_PrincipalName_GroupName)(nil), + (*accessmanagementv1.AccessControlRequest_PrincipalName_ServicePrincipalName)(nil), + (*accessmanagementv1.AccessControlRequest_PrincipalName_UserName)(nil), + (*accessmanagementv1.AccessControlResponse_PrincipalName_GroupName)(nil), + (*accessmanagementv1.AccessControlResponse_PrincipalName_ServicePrincipalName)(nil), + (*accessmanagementv1.AccessControlResponse_PrincipalName_UserName)(nil), + (*accessmanagementv1.Actor_Kind_ActorId)(nil), + (*accessmanagementv1.PrincipalOutput_PrincipalName_GroupName)(nil), + (*accessmanagementv1.PrincipalOutput_PrincipalName_ServicePrincipalName)(nil), + (*accessmanagementv1.PrincipalOutput_PrincipalName_UserName)(nil), + (*aigatewayv1.McpServiceConfig_Source_SourceConnection)(nil), + (*aigatewayv1.ModelProviderServiceConfig_AmazonBedrockProviderConfig_ProviderMode_Direct)(nil), + (*aigatewayv1.ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig_AuthMode_AwsAccessKey)(nil), + (*aigatewayv1.ModelProviderServiceConfig_AmazonBedrockProviderDirectConfig_AuthMode_ServiceCredential)(nil), + (*aigatewayv1.ModelProviderServiceConfig_AnthropicProviderConfig_ProviderMode_Direct)(nil), + (*aigatewayv1.ModelProviderServiceConfig_AnthropicProviderConfig_ProviderMode_Relayed)(nil), + (*aigatewayv1.ModelProviderServiceConfig_AnthropicProviderDirectConfig_AuthMode_ApiKey)(nil), + (*aigatewayv1.ModelProviderServiceConfig_AzureOpenAiProviderConfig_ProviderMode_Direct)(nil), + (*aigatewayv1.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig_AuthMode_ApiKey)(nil), + (*aigatewayv1.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig_AuthMode_EntraServicePrincipal)(nil), + (*aigatewayv1.ModelProviderServiceConfig_AzureOpenAiProviderDirectConfig_AuthMode_ServiceCredential)(nil), + (*aigatewayv1.ModelProviderServiceConfig_CustomProviderConfig_ProviderMode_Direct)(nil), + (*aigatewayv1.ModelProviderServiceConfig_CustomProviderDirectConfig_AuthMode_ApiKey)(nil), + (*aigatewayv1.ModelProviderServiceConfig_CustomProviderDirectConfig_AuthMode_HeaderAuth)(nil), + (*aigatewayv1.ModelProviderServiceConfig_EntraServicePrincipal_Credential_ClientSecret)(nil), + (*aigatewayv1.ModelProviderServiceConfig_GeminiEnterpriseProviderConfig_ProviderMode_Direct)(nil), + (*aigatewayv1.ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig_AuthMode_ApiKey)(nil), + (*aigatewayv1.ModelProviderServiceConfig_GeminiEnterpriseProviderDirectConfig_AuthMode_ServiceCredential)(nil), + (*aigatewayv1.ModelProviderServiceConfig_MicrosoftFoundryProviderConfig_ProviderMode_Direct)(nil), + (*aigatewayv1.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig_AuthMode_ApiKey)(nil), + (*aigatewayv1.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig_AuthMode_EntraServicePrincipal)(nil), + (*aigatewayv1.ModelProviderServiceConfig_MicrosoftFoundryProviderDirectConfig_AuthMode_ServiceCredential)(nil), + (*aigatewayv1.ModelProviderServiceConfig_OpenAiProviderConfig_ProviderMode_Direct)(nil), + (*aigatewayv1.ModelProviderServiceConfig_OpenAiProviderDirectConfig_AuthMode_ApiKey)(nil), + (*aigatewayv1.ModelProviderServiceConfig_ProviderSecret_Value_Plaintext)(nil), + (*aigatewayv1.ModelProviderServiceConfig_ProviderSecret_Value_SecretReference)(nil), + (*aigatewayv1.ModelProviderServiceConfig_Provider_AmazonBedrock)(nil), + (*aigatewayv1.ModelProviderServiceConfig_Provider_Anthropic)(nil), + (*aigatewayv1.ModelProviderServiceConfig_Provider_AzureOpenai)(nil), + (*aigatewayv1.ModelProviderServiceConfig_Provider_BedrockMantle)(nil), + (*aigatewayv1.ModelProviderServiceConfig_Provider_Custom)(nil), + (*aigatewayv1.ModelProviderServiceConfig_Provider_GeminiEnterprise)(nil), + (*aigatewayv1.ModelProviderServiceConfig_Provider_MicrosoftFoundry)(nil), + (*aigatewayv1.ModelProviderServiceConfig_Provider_Openai)(nil), + (*aigatewayv1.ModelServiceConfig_DestinationConfig_TypeConfig_ExternalModelConfig)(nil), + (*aigatewayv1.ModelServiceConfig_DestinationConfig_TypeConfig_PayPerTokenConfig)(nil), + (*aigatewayv1.ModelServiceConfig_DestinationConfig_TypeConfig_ProvisionedThroughputConfig)(nil), + (*aisearchv1.Index_IndexSpec_DeltaSyncIndexSpec)(nil), + (*aisearchv1.Index_IndexSpec_DirectAccessIndexSpec)(nil), + (*alertsv1.AlertOperandValue_ThresholdValue_BoolValue)(nil), + (*alertsv1.AlertOperandValue_ThresholdValue_DoubleValue)(nil), + (*alertsv1.AlertOperandValue_ThresholdValue_StringValue)(nil), + (*alertsv1.AlertOperand_Operand_Column)(nil), + (*alertsv1.AlertOperand_Operand_Value)(nil), + (*alertsv2.AlertOperandValue_Value_BoolValue)(nil), + (*alertsv2.AlertOperandValue_Value_DoubleValue)(nil), + (*alertsv2.AlertOperandValue_Value_StringValue)(nil), + (*alertsv2.AlertOperand_Operand_Column)(nil), + (*alertsv2.AlertOperand_Operand_Value)(nil), + (*alertsv2.AlertRunAs_Identity_ServicePrincipalName)(nil), + (*alertsv2.AlertRunAs_Identity_UserName)(nil), + (*alertsv2.AlertSubscription_SubscriptionType_DestinationId)(nil), + (*alertsv2.AlertSubscription_SubscriptionType_UserEmail)(nil), + (*appsv1.AppManifest_AppResourceSpec_Resource_ExperimentSpec)(nil), + (*appsv1.AppManifest_AppResourceSpec_Resource_JobSpec)(nil), + (*appsv1.AppManifest_AppResourceSpec_Resource_SecretSpec)(nil), + (*appsv1.AppManifest_AppResourceSpec_Resource_ServingEndpointSpec)(nil), + (*appsv1.AppManifest_AppResourceSpec_Resource_SqlWarehouseSpec)(nil), + (*appsv1.AppManifest_AppResourceSpec_Resource_UcSecurableSpec)(nil), + (*appsv1.AppResource_Resource_App)(nil), + (*appsv1.AppResource_Resource_Database)(nil), + (*appsv1.AppResource_Resource_Experiment)(nil), + (*appsv1.AppResource_Resource_GenieSpace)(nil), + (*appsv1.AppResource_Resource_Job)(nil), + (*appsv1.AppResource_Resource_Postgres)(nil), + (*appsv1.AppResource_Resource_Secret)(nil), + (*appsv1.AppResource_Resource_ServingEndpoint)(nil), + (*appsv1.AppResource_Resource_SqlWarehouse)(nil), + (*appsv1.AppResource_Resource_UcSecurable)(nil), + (*appsv1.App_DeploymentSource_GitSource)(nil), + (*appsv1.App_DeploymentSource_SourceCodePath)(nil), + (*appsv1.EnvVar_Source_Value)(nil), + (*appsv1.EnvVar_Source_ValueFrom)(nil), + (*appsv1.GitSource_Reference_Branch)(nil), + (*appsv1.GitSource_Reference_Commit)(nil), + (*appsv1.GitSource_Reference_Tag)(nil), + (*appsv1.Operation_Result_Error)(nil), + (*appsv1.Operation_Result_Response)(nil), + (*appsv1.TelemetryExportDestination_Destination_UnityCatalog)(nil), + (*authenticationv1.FederationPolicy_Policy_OidcPolicy)(nil), + (*cleanroomsv1.CleanRoomAsset_Details_ForeignTable)(nil), + (*cleanroomsv1.CleanRoomAsset_Details_JarAnalysis)(nil), + (*cleanroomsv1.CleanRoomAsset_Details_Notebook)(nil), + (*cleanroomsv1.CleanRoomAsset_Details_Table)(nil), + (*cleanroomsv1.CleanRoomAsset_Details_View)(nil), + (*cleanroomsv1.CleanRoomAsset_LocalDetails_ForeignTableLocalDetails)(nil), + (*cleanroomsv1.CleanRoomAsset_LocalDetails_TableLocalDetails)(nil), + (*cleanroomsv1.CleanRoomAsset_LocalDetails_ViewLocalDetails)(nil), + (*cleanroomsv1.CleanRoomAsset_LocalDetails_VolumeLocalDetails)(nil), + (*cleanroomsv1.CleanRoomAutoApprovalRule_Authors_AuthorCollaboratorAlias)(nil), + (*cleanroomsv1.CleanRoomAutoApprovalRule_Authors_AuthorScope)(nil), + (*cleanroomsv1.CleanRoomAutoApprovalRule_Runners_RunnerCollaboratorAlias)(nil), + (*cleanroomsv1.CreateCleanRoomAssetReviewRequest_Review_JarAnalysisReview)(nil), + (*cleanroomsv1.CreateCleanRoomAssetReviewRequest_Review_NotebookReview)(nil), + (*cleanroomsv1.CreateCleanRoomAssetReviewResponse_ReviewState_JarAnalysisReviewState)(nil), + (*cleanroomsv1.CreateCleanRoomAssetReviewResponse_ReviewState_NotebookReviewState)(nil), + (*cleanroomsv1.PolicyFunctionArgument_Arg_Column)(nil), + (*cleanroomsv1.PolicyFunctionArgument_Arg_Constant)(nil), + (*clusterlibrariesv2.Library_Lib_Cran)(nil), + (*clusterlibrariesv2.Library_Lib_Egg)(nil), + (*clusterlibrariesv2.Library_Lib_Jar)(nil), + (*clusterlibrariesv2.Library_Lib_Maven)(nil), + (*clusterlibrariesv2.Library_Lib_Pypi)(nil), + (*clusterlibrariesv2.Library_Lib_Requirements)(nil), + (*clusterlibrariesv2.Library_Lib_Whl)(nil), + (*clusterpoliciesv2.Library_Lib_Cran)(nil), + (*clusterpoliciesv2.Library_Lib_Egg)(nil), + (*clusterpoliciesv2.Library_Lib_Jar)(nil), + (*clusterpoliciesv2.Library_Lib_Maven)(nil), + (*clusterpoliciesv2.Library_Lib_Pypi)(nil), + (*clusterpoliciesv2.Library_Lib_Requirements)(nil), + (*clusterpoliciesv2.Library_Lib_Whl)(nil), + (*clustersv2.ClusterInfo_ComputeSpec_Size_Autoscale)(nil), + (*clustersv2.ClusterInfo_ComputeSpec_Size_NumWorkers)(nil), + (*clustersv2.ClusterInfo_Size_Autoscale)(nil), + (*clustersv2.ClusterInfo_Size_NumWorkers)(nil), + (*clustersv2.ClusterLogConf_StorageInfo_Dbfs)(nil), + (*clustersv2.ClusterLogConf_StorageInfo_S3)(nil), + (*clustersv2.ClusterLogConf_StorageInfo_Volumes)(nil), + (*clustersv2.ClusterSize_Size_Autoscale)(nil), + (*clustersv2.ClusterSize_Size_NumWorkers)(nil), + (*clustersv2.CreateClusterRequest_Size_Autoscale)(nil), + (*clustersv2.CreateClusterRequest_Size_NumWorkers)(nil), + (*clustersv2.DockerImage_CredsOneof_BasicAuth)(nil), + (*clustersv2.EditClusterRequest_Size_Autoscale)(nil), + (*clustersv2.EditClusterRequest_Size_NumWorkers)(nil), + (*clustersv2.EnforcePolicyComplianceForClusterResponse_ClusterSettings_Size_Autoscale)(nil), + (*clustersv2.EnforcePolicyComplianceForClusterResponse_ClusterSettings_Size_NumWorkers)(nil), + (*clustersv2.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Abfss)(nil), + (*clustersv2.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Dbfs)(nil), + (*clustersv2.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_File)(nil), + (*clustersv2.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Gcs)(nil), + (*clustersv2.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_S3)(nil), + (*clustersv2.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Volumes)(nil), + (*clustersv2.InitScriptEventDetails_InitScriptInfoAndExecutionDetails_StorageInfo_Workspace)(nil), + (*clustersv2.InitScriptInfo_StorageInfo_Abfss)(nil), + (*clustersv2.InitScriptInfo_StorageInfo_Dbfs)(nil), + (*clustersv2.InitScriptInfo_StorageInfo_File)(nil), + (*clustersv2.InitScriptInfo_StorageInfo_Gcs)(nil), + (*clustersv2.InitScriptInfo_StorageInfo_S3)(nil), + (*clustersv2.InitScriptInfo_StorageInfo_Volumes)(nil), + (*clustersv2.InitScriptInfo_StorageInfo_Workspace)(nil), + (*clustersv2.ResizeClusterRequest_Size_Autoscale)(nil), + (*clustersv2.ResizeClusterRequest_Size_NumWorkers)(nil), + (*clustersv2.UpdateClusterRequest_UpdateClusterResource_Size_Autoscale)(nil), + (*clustersv2.UpdateClusterRequest_UpdateClusterResource_Size_NumWorkers)(nil), + (*databasev1.RequestedResource_ResourceName_TableName)(nil), + (*databasev1.RequestedResource_ResourceName_UnspecifiedResourceName)(nil), + (*databasev1.SyncedTablePosition_SourceSyncInfo_DeltaTableSyncInfo)(nil), + (*databasev1.SyncedTableStatus_DetailedStatus_ContinuousUpdateStatus)(nil), + (*databasev1.SyncedTableStatus_DetailedStatus_FailedStatus)(nil), + (*databasev1.SyncedTableStatus_DetailedStatus_ProvisioningStatus)(nil), + (*databasev1.SyncedTableStatus_DetailedStatus_TriggeredUpdateStatus)(nil), + (*dataclassificationv1.CatalogConfig_SelectedSchemas_ExcludedSchemas)(nil), + (*dataclassificationv1.CatalogConfig_SelectedSchemas_IncludedSchemas)(nil), + (*dataqualityv1.DataProfilingConfig_AnalysisConfig_InferenceLog)(nil), + (*dataqualityv1.DataProfilingConfig_AnalysisConfig_Snapshot)(nil), + (*dataqualityv1.DataProfilingConfig_AnalysisConfig_TimeSeries)(nil), + (*environmentsv1.Operation_Result_Error)(nil), + (*environmentsv1.Operation_Result_Response)(nil), + (*experimentsv1.ExperimentTraceLocation_Location_UcTraceLocation)(nil), + (*featuresv1.AggregationFunction_Operation_ApproxCountDistinct)(nil), + (*featuresv1.AggregationFunction_Operation_ApproxPercentile)(nil), + (*featuresv1.AggregationFunction_Operation_Avg)(nil), + (*featuresv1.AggregationFunction_Operation_CountFunction)(nil), + (*featuresv1.AggregationFunction_Operation_First)(nil), + (*featuresv1.AggregationFunction_Operation_FirstDistinct)(nil), + (*featuresv1.AggregationFunction_Operation_FirstN)(nil), + (*featuresv1.AggregationFunction_Operation_Last)(nil), + (*featuresv1.AggregationFunction_Operation_LastDistinct)(nil), + (*featuresv1.AggregationFunction_Operation_LastN)(nil), + (*featuresv1.AggregationFunction_Operation_Max)(nil), + (*featuresv1.AggregationFunction_Operation_Min)(nil), + (*featuresv1.AggregationFunction_Operation_StddevPop)(nil), + (*featuresv1.AggregationFunction_Operation_StddevSamp)(nil), + (*featuresv1.AggregationFunction_Operation_Sum)(nil), + (*featuresv1.AggregationFunction_Operation_VarPop)(nil), + (*featuresv1.AggregationFunction_Operation_VarSamp)(nil), + (*featuresv1.AuthConfig_AuthConfig_MtlsConfig)(nil), + (*featuresv1.AuthConfig_AuthConfig_UcServiceCredentialName)(nil), + (*featuresv1.BackfillSource_BackfillSource_DeltaTableName)(nil), + (*featuresv1.BackfillSource_BackfillSource_DeltaTableSource)(nil), + (*featuresv1.DataSource_DataSource_DeltaTableSource)(nil), + (*featuresv1.DataSource_DataSource_FeatureViewSource)(nil), + (*featuresv1.DataSource_DataSource_KafkaSource)(nil), + (*featuresv1.DataSource_DataSource_RequestSource)(nil), + (*featuresv1.DataSource_DataSource_StreamSource)(nil), + (*featuresv1.Function_Function_AggregationFunction)(nil), + (*featuresv1.Function_Function_ColumnSelection)(nil), + (*featuresv1.Function_Function_CustomUdf)(nil), + (*featuresv1.IngestionDestination_IngestionDestination_DeltaTableName)(nil), + (*featuresv1.KafkaSubscriptionMode_SubscriptionMode_Assign)(nil), + (*featuresv1.KafkaSubscriptionMode_SubscriptionMode_Subscribe)(nil), + (*featuresv1.KafkaSubscriptionMode_SubscriptionMode_SubscribePattern)(nil), + (*featuresv1.KinesisStreamConfig_StreamIdentifier_StreamArns)(nil), + (*featuresv1.KinesisStreamConfig_StreamIdentifier_StreamNames)(nil), + (*featuresv1.MaterializedFeature_Destination_OfflineStoreConfig)(nil), + (*featuresv1.MaterializedFeature_Destination_OnlineStoreConfig)(nil), + (*featuresv1.MaterializedFeature_Trigger_CronScheduleTrigger)(nil), + (*featuresv1.MaterializedFeature_Trigger_StreamingMode)(nil), + (*featuresv1.MaterializedFeature_Trigger_TableTrigger)(nil), + (*featuresv1.Operation_Result_Error)(nil), + (*featuresv1.Operation_Result_Response)(nil), + (*featuresv1.PurgeFeatureEntitiesRequest_Entities_EntitiesTable)(nil), + (*featuresv1.RequestSource_Schema_DataframeSchema)(nil), + (*featuresv1.RequestSource_Schema_FlatSchema)(nil), + (*featuresv1.SchemaConfig_Schema_AvroSchema)(nil), + (*featuresv1.SchemaConfig_Schema_JsonSchema)(nil), + (*featuresv1.SchemaConfig_Schema_ProtoSchema)(nil), + (*featuresv1.SchemaLocator_RegistrySchema_ConfluentSchema)(nil), + (*featuresv1.StreamConnectionConfig_ConnectionConfig_DirectMtlsConfig)(nil), + (*featuresv1.StreamConnectionConfig_ConnectionConfig_UcConnectionName)(nil), + (*featuresv1.StreamSchemaConfig_SchemaConfig_DirectSchemas)(nil), + (*featuresv1.StreamSchemaConfig_SchemaConfig_SchemaRegistryConfig)(nil), + (*featuresv1.StreamSourceConfig_SourceConfig_KafkaStreamConfig)(nil), + (*featuresv1.StreamSourceConfig_SourceConfig_KinesisStreamConfig)(nil), + (*featuresv1.SubscriptionMode_SubscriptionMode_Assign)(nil), + (*featuresv1.SubscriptionMode_SubscriptionMode_Subscribe)(nil), + (*featuresv1.SubscriptionMode_SubscriptionMode_SubscribePattern)(nil), + (*featuresv1.TimeWindow_WindowType_Continuous)(nil), + (*featuresv1.TimeWindow_WindowType_Rolling)(nil), + (*featuresv1.TimeWindow_WindowType_Sawtooth)(nil), + (*featuresv1.TimeWindow_WindowType_Sliding)(nil), + (*featuresv1.TimeWindow_WindowType_Tumbling)(nil), + (*geniev1.GenieAttachment_Attachment_Query)(nil), + (*geniev1.GenieAttachment_Attachment_SuggestedQuestions)(nil), + (*geniev1.GenieAttachment_Attachment_Text)(nil), + (*geniev1.GenieAttachment_Attachment_Viz)(nil), + (*geniev1.PolicyFunctionArgument_Arg_Column)(nil), + (*geniev1.PolicyFunctionArgument_Arg_Constant)(nil), + (*geniev1.Value_Kind_BoolValue)(nil), + (*geniev1.Value_Kind_ListValue)(nil), + (*geniev1.Value_Kind_NullValue)(nil), + (*geniev1.Value_Kind_NumberValue)(nil), + (*geniev1.Value_Kind_StringValue)(nil), + (*geniev1.Value_Kind_StructValue)(nil), + (*instancepoolsv2.DiskType_RemoteVolumeType_AzureDiskVolumeType)(nil), + (*instancepoolsv2.DiskType_RemoteVolumeType_EbsVolumeType)(nil), + (*instancepoolsv2.DockerImage_CredsOneof_BasicAuth)(nil), + (*jobsv2.AccessControlRequest_PrincipalName_GroupName)(nil), + (*jobsv2.AccessControlRequest_PrincipalName_ServicePrincipalName)(nil), + (*jobsv2.AccessControlRequest_PrincipalName_UserName)(nil), + (*jobsv2.AlertTaskSubscriber_SubscriberType_DestinationId)(nil), + (*jobsv2.AlertTaskSubscriber_SubscriberType_UserName)(nil), + (*jobsv2.ClusterLogConf_StorageInfo_Dbfs)(nil), + (*jobsv2.ClusterLogConf_StorageInfo_S3)(nil), + (*jobsv2.ClusterLogConf_StorageInfo_Volumes)(nil), + (*jobsv2.ClusterSpec_NewCluster_Size_Autoscale)(nil), + (*jobsv2.ClusterSpec_NewCluster_Size_NumWorkers)(nil), + (*jobsv2.ClusterSpec_Spec_ExistingClusterId)(nil), + (*jobsv2.ClusterSpec_Spec_JobClusterKey)(nil), + (*jobsv2.ClusterSpec_Spec_NewCluster)(nil), + (*jobsv2.DockerImage_CredsOneof_BasicAuth)(nil), + (*jobsv2.GetRunOutputResponse_Result_AiRuntimeTaskOutput)(nil), + (*jobsv2.GetRunOutputResponse_Result_AlertOutput)(nil), + (*jobsv2.GetRunOutputResponse_Result_CleanRoomsNotebookOutput)(nil), + (*jobsv2.GetRunOutputResponse_Result_DashboardOutput)(nil), + (*jobsv2.GetRunOutputResponse_Result_DbtCloudOutput)(nil), + (*jobsv2.GetRunOutputResponse_Result_DbtOutput)(nil), + (*jobsv2.GetRunOutputResponse_Result_DbtPlatformOutput)(nil), + (*jobsv2.GetRunOutputResponse_Result_NotebookOutput)(nil), + (*jobsv2.GetRunOutputResponse_Result_RunJobOutput)(nil), + (*jobsv2.GetRunOutputResponse_Result_SqlOutput)(nil), + (*jobsv2.GitSource_GitReference_GitBranch)(nil), + (*jobsv2.GitSource_GitReference_GitCommit)(nil), + (*jobsv2.GitSource_GitReference_GitTag)(nil), + (*jobsv2.InitScriptInfo_StorageInfo_Abfss)(nil), + (*jobsv2.InitScriptInfo_StorageInfo_Dbfs)(nil), + (*jobsv2.InitScriptInfo_StorageInfo_File)(nil), + (*jobsv2.InitScriptInfo_StorageInfo_Gcs)(nil), + (*jobsv2.InitScriptInfo_StorageInfo_S3)(nil), + (*jobsv2.InitScriptInfo_StorageInfo_Volumes)(nil), + (*jobsv2.InitScriptInfo_StorageInfo_Workspace)(nil), + (*jobsv2.JobRunAs_Identity_GroupName)(nil), + (*jobsv2.JobRunAs_Identity_ServicePrincipalName)(nil), + (*jobsv2.JobRunAs_Identity_UserName)(nil), + (*jobsv2.JobSource_ImportFromGitReference_ImportFromGitBranch)(nil), + (*jobsv2.Library_Lib_Cran)(nil), + (*jobsv2.Library_Lib_Egg)(nil), + (*jobsv2.Library_Lib_Jar)(nil), + (*jobsv2.Library_Lib_Maven)(nil), + (*jobsv2.Library_Lib_Pypi)(nil), + (*jobsv2.Library_Lib_Requirements)(nil), + (*jobsv2.Library_Lib_Whl)(nil), + (*jobsv2.ListRunsRequest_StateConstraint_ActiveOnly)(nil), + (*jobsv2.ListRunsRequest_StateConstraint_CompletedOnly)(nil), + (*jobsv2.PerTriggerState_TriggerType_Continuous)(nil), + (*jobsv2.PerTriggerState_TriggerType_FileArrival)(nil), + (*jobsv2.PerTriggerState_TriggerType_Model)(nil), + (*jobsv2.PerTriggerState_TriggerType_Periodic)(nil), + (*jobsv2.PerTriggerState_TriggerType_Schedule)(nil), + (*jobsv2.PerTriggerState_TriggerType_TableUpdate)(nil), + (*jobsv2.ResolvedValues_Resolved_AiRuntimeTask)(nil), + (*jobsv2.ResolvedValues_Resolved_ConditionTask)(nil), + (*jobsv2.ResolvedValues_Resolved_DbtTask)(nil), + (*jobsv2.ResolvedValues_Resolved_NotebookTask)(nil), + (*jobsv2.ResolvedValues_Resolved_PipelineTask)(nil), + (*jobsv2.ResolvedValues_Resolved_PythonWheelTask)(nil), + (*jobsv2.ResolvedValues_Resolved_RunJobTask)(nil), + (*jobsv2.ResolvedValues_Resolved_SimulationTask)(nil), + (*jobsv2.ResolvedValues_Resolved_SparkJarTask)(nil), + (*jobsv2.ResolvedValues_Resolved_SparkPythonTask)(nil), + (*jobsv2.ResolvedValues_Resolved_SparkSubmitTask)(nil), + (*jobsv2.ResolvedValues_Resolved_SqlTask)(nil), + (*jobsv2.RunTaskSettings_EnvironmentRef_EnvironmentKey)(nil), + (*jobsv2.RunTaskSettings_Spec_ExistingClusterId)(nil), + (*jobsv2.RunTaskSettings_Spec_JobClusterKey)(nil), + (*jobsv2.RunTaskSettings_Spec_NewCluster)(nil), + (*jobsv2.RunTaskSettings_Task_AiRuntimeTask)(nil), + (*jobsv2.RunTaskSettings_Task_AlertTask)(nil), + (*jobsv2.RunTaskSettings_Task_CleanRoomsNotebookTask)(nil), + (*jobsv2.RunTaskSettings_Task_ConditionTask)(nil), + (*jobsv2.RunTaskSettings_Task_DashboardTask)(nil), + (*jobsv2.RunTaskSettings_Task_DbtCloudTask)(nil), + (*jobsv2.RunTaskSettings_Task_DbtPlatformTask)(nil), + (*jobsv2.RunTaskSettings_Task_DbtTask)(nil), + (*jobsv2.RunTaskSettings_Task_ForEachTask)(nil), + (*jobsv2.RunTaskSettings_Task_GenAiComputeTask)(nil), + (*jobsv2.RunTaskSettings_Task_NotebookTask)(nil), + (*jobsv2.RunTaskSettings_Task_PipelineTask)(nil), + (*jobsv2.RunTaskSettings_Task_PowerBiTask)(nil), + (*jobsv2.RunTaskSettings_Task_PythonOperatorTask)(nil), + (*jobsv2.RunTaskSettings_Task_PythonWheelTask)(nil), + (*jobsv2.RunTaskSettings_Task_RunJobTask)(nil), + (*jobsv2.RunTaskSettings_Task_SparkJarTask)(nil), + (*jobsv2.RunTaskSettings_Task_SparkPythonTask)(nil), + (*jobsv2.RunTaskSettings_Task_SparkSubmitTask)(nil), + (*jobsv2.RunTaskSettings_Task_SqlTask)(nil), + (*jobsv2.RunTask_EnvironmentRef_EnvironmentKey)(nil), + (*jobsv2.RunTask_Spec_ExistingClusterId)(nil), + (*jobsv2.RunTask_Spec_JobClusterKey)(nil), + (*jobsv2.RunTask_Spec_NewCluster)(nil), + (*jobsv2.RunTask_Task_AiRuntimeTask)(nil), + (*jobsv2.RunTask_Task_AlertTask)(nil), + (*jobsv2.RunTask_Task_CleanRoomsNotebookTask)(nil), + (*jobsv2.RunTask_Task_ConditionTask)(nil), + (*jobsv2.RunTask_Task_DashboardTask)(nil), + (*jobsv2.RunTask_Task_DbtCloudTask)(nil), + (*jobsv2.RunTask_Task_DbtPlatformTask)(nil), + (*jobsv2.RunTask_Task_DbtTask)(nil), + (*jobsv2.RunTask_Task_ForEachTask)(nil), + (*jobsv2.RunTask_Task_GenAiComputeTask)(nil), + (*jobsv2.RunTask_Task_NotebookTask)(nil), + (*jobsv2.RunTask_Task_PipelineTask)(nil), + (*jobsv2.RunTask_Task_PowerBiTask)(nil), + (*jobsv2.RunTask_Task_PythonOperatorTask)(nil), + (*jobsv2.RunTask_Task_PythonWheelTask)(nil), + (*jobsv2.RunTask_Task_RunJobTask)(nil), + (*jobsv2.RunTask_Task_SparkJarTask)(nil), + (*jobsv2.RunTask_Task_SparkPythonTask)(nil), + (*jobsv2.RunTask_Task_SparkSubmitTask)(nil), + (*jobsv2.RunTask_Task_SqlTask)(nil), + (*jobsv2.SqlTaskQuery_QueryType_QueryId)(nil), + (*jobsv2.SqlTaskSubscription_SubscriptionType_DestinationId)(nil), + (*jobsv2.SqlTaskSubscription_SubscriptionType_UserName)(nil), + (*jobsv2.SqlTask_SqlOutput_SqlOutputType_AlertOutput)(nil), + (*jobsv2.SqlTask_SqlOutput_SqlOutputType_DashboardOutput)(nil), + (*jobsv2.SqlTask_SqlOutput_SqlOutputType_QueryOutput)(nil), + (*jobsv2.SqlTask_SqlTaskType_Alert)(nil), + (*jobsv2.SqlTask_SqlTaskType_Dashboard)(nil), + (*jobsv2.SqlTask_SqlTaskType_File)(nil), + (*jobsv2.SqlTask_SqlTaskType_Query)(nil), + (*jobsv2.Subscription_Subscriber_SubscriptionType_DestinationId)(nil), + (*jobsv2.Subscription_Subscriber_SubscriptionType_UserName)(nil), + (*jobsv2.TaskSettings_EnvironmentRef_EnvironmentKey)(nil), + (*jobsv2.TaskSettings_Spec_ExistingClusterId)(nil), + (*jobsv2.TaskSettings_Spec_JobClusterKey)(nil), + (*jobsv2.TaskSettings_Spec_NewCluster)(nil), + (*jobsv2.TaskSettings_Task_AiRuntimeTask)(nil), + (*jobsv2.TaskSettings_Task_AlertTask)(nil), + (*jobsv2.TaskSettings_Task_CleanRoomsNotebookTask)(nil), + (*jobsv2.TaskSettings_Task_ConditionTask)(nil), + (*jobsv2.TaskSettings_Task_DashboardTask)(nil), + (*jobsv2.TaskSettings_Task_DbtCloudTask)(nil), + (*jobsv2.TaskSettings_Task_DbtPlatformTask)(nil), + (*jobsv2.TaskSettings_Task_DbtTask)(nil), + (*jobsv2.TaskSettings_Task_ForEachTask)(nil), + (*jobsv2.TaskSettings_Task_GenAiComputeTask)(nil), + (*jobsv2.TaskSettings_Task_NotebookTask)(nil), + (*jobsv2.TaskSettings_Task_PipelineTask)(nil), + (*jobsv2.TaskSettings_Task_PowerBiTask)(nil), + (*jobsv2.TaskSettings_Task_PythonOperatorTask)(nil), + (*jobsv2.TaskSettings_Task_PythonWheelTask)(nil), + (*jobsv2.TaskSettings_Task_RunJobTask)(nil), + (*jobsv2.TaskSettings_Task_SparkJarTask)(nil), + (*jobsv2.TaskSettings_Task_SparkPythonTask)(nil), + (*jobsv2.TaskSettings_Task_SparkSubmitTask)(nil), + (*jobsv2.TaskSettings_Task_SqlTask)(nil), + (*jobsv2.TriggerSettings_Configuration_FileArrival)(nil), + (*jobsv2.TriggerSettings_Configuration_Model)(nil), + (*jobsv2.TriggerSettings_Configuration_Periodic)(nil), + (*jobsv2.TriggerSettings_Configuration_TableUpdate)(nil), + (*jobsv2.TriggerState_TriggerType_FileArrival)(nil), + (*jobsv2.TriggerState_TriggerType_Table)(nil), + (*keyconfigurationsv1.CreateCustomerManagedKeyRequest_KeyInfo_AwsKeyInfo)(nil), + (*keyconfigurationsv1.CreateCustomerManagedKeyRequest_KeyInfo_AzureKeyInfo)(nil), + (*keyconfigurationsv1.CreateCustomerManagedKeyRequest_KeyInfo_GcpKeyInfo)(nil), + (*keyconfigurationsv1.CustomerManagedKey_KeyInfo_AwsKeyInfo)(nil), + (*keyconfigurationsv1.CustomerManagedKey_KeyInfo_AzureKeyInfo)(nil), + (*keyconfigurationsv1.CustomerManagedKey_KeyInfo_GcpKeyInfo)(nil), + (*knowledgeassistantsv1.KnowledgeSource_Spec_FileTable)(nil), + (*knowledgeassistantsv1.KnowledgeSource_Spec_Files)(nil), + (*knowledgeassistantsv1.KnowledgeSource_Spec_Index)(nil), + (*modelservingv1.ExternalModel_Config_Ai21labsConfig)(nil), + (*modelservingv1.ExternalModel_Config_AmazonBedrockConfig)(nil), + (*modelservingv1.ExternalModel_Config_AnthropicConfig)(nil), + (*modelservingv1.ExternalModel_Config_CohereConfig)(nil), + (*modelservingv1.ExternalModel_Config_CustomProviderConfig)(nil), + (*modelservingv1.ExternalModel_Config_DatabricksModelServingConfig)(nil), + (*modelservingv1.ExternalModel_Config_GoogleCloudVertexAiConfig)(nil), + (*modelservingv1.ExternalModel_Config_OpenaiConfig)(nil), + (*modelservingv1.ExternalModel_Config_PalmConfig)(nil), + (*modelservingv1.TelemetryConfig_TelemetryProfile_TableNames)(nil), + (*modelservingv1.TelemetryConfig_TelemetryProfile_TelemetryProfileId)(nil), + (*networkingv1.CreatePrivateEndpointRule_Endpoint_GcpEndpoint)(nil), + (*networkingv1.CreateVpcEndpointRequest_VpcEndpointInfo_GcpVpcEndpointInfo)(nil), + (*networkingv1.Endpoint_EndpointInfo_AwsVpcEndpointInfo)(nil), + (*networkingv1.Endpoint_EndpointInfo_AzurePrivateEndpointInfo)(nil), + (*networkingv1.Endpoint_EndpointInfo_GcpPscEndpointInfo)(nil), + (*networkingv1.GcpEndpoint_TargetServices_AllVpcScServices)(nil), + (*networkingv1.GcpEndpoint_TargetServices_GoogleApiEndpoints)(nil), + (*networkingv1.GcpEndpoint_TargetServices_ServiceAttachment)(nil), + (*networkingv1.IngressNetworkPolicy_CrossWorkspaceRequestOrigin_Source_AllSourceWorkspaces)(nil), + (*networkingv1.IngressNetworkPolicy_CrossWorkspaceRequestOrigin_Source_SelectedWorkspaces)(nil), + (*networkingv1.IngressNetworkPolicy_PrivateRequestOrigin_Source_AllPrivateAccess)(nil), + (*networkingv1.IngressNetworkPolicy_PrivateRequestOrigin_Source_AllRegisteredEndpoints)(nil), + (*networkingv1.IngressNetworkPolicy_PrivateRequestOrigin_Source_AzureWorkspacePrivateLink)(nil), + (*networkingv1.IngressNetworkPolicy_PrivateRequestOrigin_Source_Endpoints)(nil), + (*networkingv1.IngressNetworkPolicy_PublicRequestOrigin_Source_AllIpRanges)(nil), + (*networkingv1.IngressNetworkPolicy_PublicRequestOrigin_Source_ExcludedIpRanges)(nil), + (*networkingv1.IngressNetworkPolicy_PublicRequestOrigin_Source_IncludedIpRanges)(nil), + (*networkingv1.NccPrivateEndpointRule_Endpoint_GcpEndpoint)(nil), + (*networkingv1.Network_NetworkInfo_GcpNetworkInfo)(nil), + (*networkingv1.UpdatePrivateEndpointRule_Endpoint_GcpEndpoint)(nil), + (*networkingv1.VpcEndpoint_VpcEndpointInfo_GcpVpcEndpointInfo)(nil), + (*notificationdestinationsv1.Config_Config_DatabricksAppSlack)(nil), + (*notificationdestinationsv1.Config_Config_DatabricksAppTeams)(nil), + (*notificationdestinationsv1.Config_Config_Email)(nil), + (*notificationdestinationsv1.Config_Config_GenericWebhook)(nil), + (*notificationdestinationsv1.Config_Config_MicrosoftTeams)(nil), + (*notificationdestinationsv1.Config_Config_Pagerduty)(nil), + (*notificationdestinationsv1.Config_Config_Slack)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_ApiSourceConnectorOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_ConfluenceOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_GdriveOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_GoogleAdsOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_JiraOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_KafkaOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_LinkedinAdsOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_MarketoOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_MetaAdsOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_OutlookOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_RabbitmqOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_RedditAdsOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_SharepointOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_SmartsheetOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_TiktokAdsOptions)(nil), + (*pipelinesv2.ConnectorOptions_ConnectorOptions_ZendeskSupportOptions)(nil), + (*pipelinesv2.FileFilter_Filter_ModifiedAfter)(nil), + (*pipelinesv2.FileFilter_Filter_ModifiedBefore)(nil), + (*pipelinesv2.FileFilter_Filter_PathFilter)(nil), + (*pipelinesv2.IngestionPipelineDefinition_IngestionConfig_SourceTables_Report)(nil), + (*pipelinesv2.IngestionPipelineDefinition_IngestionConfig_SourceTables_Schema)(nil), + (*pipelinesv2.IngestionPipelineDefinition_IngestionConfig_SourceTables_Table)(nil), + (*pipelinesv2.IngestionPipelineDefinition_Source_ConnectionName)(nil), + (*pipelinesv2.IngestionPipelineDefinition_Source_IngestFromUcForeignCatalog)(nil), + (*pipelinesv2.IngestionPipelineDefinition_Source_IngestionGatewayId)(nil), + (*pipelinesv2.PipelineCluster_Size_Autoscale)(nil), + (*pipelinesv2.PipelineCluster_Size_NumWorkers)(nil), + (*pipelinesv2.PipelineLibrary_Lib_File)(nil), + (*pipelinesv2.PipelineLibrary_Lib_Glob)(nil), + (*pipelinesv2.PipelineLibrary_Lib_Jar)(nil), + (*pipelinesv2.PipelineLibrary_Lib_Maven)(nil), + (*pipelinesv2.PipelineLibrary_Lib_Notebook)(nil), + (*pipelinesv2.PipelineLibrary_Lib_Whl)(nil), + (*pipelinesv2.PipelineTrigger_Trigger_Cron)(nil), + (*pipelinesv2.PipelineTrigger_Trigger_Manual)(nil), + (*pipelinesv2.PipelinesClusterLogConf_StorageInfo_Dbfs)(nil), + (*pipelinesv2.PipelinesInitScriptInfo_StorageInfo_Dbfs)(nil), + (*pipelinesv2.PipelinesInitScriptInfo_StorageInfo_S3)(nil), + (*pipelinesv2.PipelinesJobRunAs_Identity_GroupName)(nil), + (*pipelinesv2.PipelinesJobRunAs_Identity_ServicePrincipalName)(nil), + (*pipelinesv2.PipelinesJobRunAs_Identity_UserName)(nil), + (*pipelinesv2.SourceCatalogConfig_Options_Postgres)(nil), + (*pipelinesv2.SourceConfig_ConnectorConfig_ApiSourceConnectorConfig)(nil), + (*pipelinesv2.SourceConfig_ConnectorConfig_GoogleAdsConfig)(nil), + (*pipelinesv2.Transformer_Config_AvroOptions)(nil), + (*pipelinesv2.Transformer_Config_JsonOptions)(nil), + (*pipelinesv2.Transformer_Config_ProtobufOptions)(nil), + (*postgresv1.BranchSpec_Expiration_ExpireTime)(nil), + (*postgresv1.BranchSpec_Expiration_NoExpiry)(nil), + (*postgresv1.BranchSpec_Expiration_Ttl)(nil), + (*postgresv1.EndpointSpec_Suspension_NoSuspension)(nil), + (*postgresv1.EndpointSpec_Suspension_SuspendTimeoutDuration)(nil), + (*postgresv1.GenerateDatabaseCredentialRequest_Expiration_ExpireTime)(nil), + (*postgresv1.GenerateDatabaseCredentialRequest_Expiration_Ttl)(nil), + (*postgresv1.InitialEndpointSpec_Suspension_NoSuspension)(nil), + (*postgresv1.InitialEndpointSpec_Suspension_SuspendTimeoutDuration)(nil), + (*postgresv1.Operation_Result_Error)(nil), + (*postgresv1.Operation_Result_Response)(nil), + (*postgresv1.ProjectDefaultEndpointSettings_Suspension_NoSuspension)(nil), + (*postgresv1.ProjectDefaultEndpointSettings_Suspension_SuspendTimeoutDuration)(nil), + (*postgresv1.RequestedResource_ResourceName_TableName)(nil), + (*postgresv1.ScheduleCadence_Schedule_DailySchedule)(nil), + (*postgresv1.ScheduleCadence_Schedule_MonthlySchedule)(nil), + (*postgresv1.ScheduleCadence_Schedule_WeeklySchedule)(nil), + (*postgresv1.SnapshotSpec_Expiration_ExpireTime)(nil), + (*postgresv1.SnapshotSpec_Expiration_NoExpiry)(nil), + (*postgresv1.SnapshotSpec_Expiration_Ttl)(nil), + (*postgresv1.SnapshotSpec_PointInTime_SourceBranchLsn)(nil), + (*postgresv1.SnapshotSpec_PointInTime_SourceBranchTime)(nil), + (*postgresv1.SnapshotStatus_Expiration_ExpireTime)(nil), + (*postgresv1.SnapshotStatus_Expiration_NoExpiry)(nil), + (*postgresv1.SyncedTablePosition_SourceSyncInfo_DeltaTableSyncInfo)(nil), + (*queriesv1.DateRangeValue_Value_DateRangeValue)(nil), + (*queriesv1.DateRangeValue_Value_DynamicDateRangeValue)(nil), + (*queriesv1.DateValue_Value_DateValue)(nil), + (*queriesv1.DateValue_Value_DynamicDateValue)(nil), + (*queriesv1.QueryParameter_ParameterValue_DateRangeValue)(nil), + (*queriesv1.QueryParameter_ParameterValue_DateValue)(nil), + (*queriesv1.QueryParameter_ParameterValue_EnumValue)(nil), + (*queriesv1.QueryParameter_ParameterValue_NumericValue)(nil), + (*queriesv1.QueryParameter_ParameterValue_QueryBackedValue)(nil), + (*queriesv1.QueryParameter_ParameterValue_TextValue)(nil), + (*secretsv1.PutSecretRequest_Value_BytesValue)(nil), + (*secretsv1.PutSecretRequest_Value_StringValue)(nil), + (*settingsv2.Setting_EffectiveValue_EffectiveAibiDashboardEmbeddingAccessPolicy)(nil), + (*settingsv2.Setting_EffectiveValue_EffectiveAibiDashboardEmbeddingApprovedDomains)(nil), + (*settingsv2.Setting_EffectiveValue_EffectiveAllowedAppsUserApiScopes)(nil), + (*settingsv2.Setting_EffectiveValue_EffectiveAutomaticClusterUpdateWorkspace)(nil), + (*settingsv2.Setting_EffectiveValue_EffectiveBooleanVal)(nil), + (*settingsv2.Setting_EffectiveValue_EffectiveCollaborationPlatformConnectivity)(nil), + (*settingsv2.Setting_EffectiveValue_EffectiveIntegerVal)(nil), + (*settingsv2.Setting_EffectiveValue_EffectiveOperationalEmailCustomRecipient)(nil), + (*settingsv2.Setting_EffectiveValue_EffectivePersonalCompute)(nil), + (*settingsv2.Setting_EffectiveValue_EffectiveRestrictWorkspaceAdmins)(nil), + (*settingsv2.Setting_EffectiveValue_EffectiveStringVal)(nil), + (*settingsv2.Setting_EffectiveValue_EffectiveWorkspaceLabel)(nil), + (*settingsv2.Setting_Value_AibiDashboardEmbeddingAccessPolicy)(nil), + (*settingsv2.Setting_Value_AibiDashboardEmbeddingApprovedDomains)(nil), + (*settingsv2.Setting_Value_AllowedAppsUserApiScopes)(nil), + (*settingsv2.Setting_Value_AutomaticClusterUpdateWorkspace)(nil), + (*settingsv2.Setting_Value_BooleanVal)(nil), + (*settingsv2.Setting_Value_CollaborationPlatformConnectivity)(nil), + (*settingsv2.Setting_Value_IntegerVal)(nil), + (*settingsv2.Setting_Value_OperationalEmailCustomRecipient)(nil), + (*settingsv2.Setting_Value_PersonalCompute)(nil), + (*settingsv2.Setting_Value_RestrictWorkspaceAdmins)(nil), + (*settingsv2.Setting_Value_StringVal)(nil), + (*settingsv2.Setting_Value_WorkspaceLabel)(nil), + (*settingsv2.UserPreference_EffectiveValue_EffectiveBooleanVal)(nil), + (*settingsv2.UserPreference_EffectiveValue_EffectiveStringVal)(nil), + (*settingsv2.UserPreference_Value_BooleanVal)(nil), + (*settingsv2.UserPreference_Value_StringVal)(nil), + (*sharingv1.Dependency_Value_Function)(nil), + (*sharingv1.Dependency_Value_Table)(nil), + (*sharingv1.FederationPolicy_Policy_OidcPolicy)(nil), + (*supervisoragentsv1.Tool_Spec_App)(nil), + (*supervisoragentsv1.Tool_Spec_GenieSpace)(nil), + (*supervisoragentsv1.Tool_Spec_KnowledgeAssistant)(nil), + (*supervisoragentsv1.Tool_Spec_UcConnection)(nil), + (*supervisoragentsv1.Tool_Spec_UcFunction)(nil), + (*supervisoragentsv1.Tool_Spec_Volume)(nil), + (*ucabacpoliciesv1.FunctionArgExpression_Expr_TagIntrospection)(nil), + (*ucabacpoliciesv1.FunctionArgument_Arg_Alias)(nil), + (*ucabacpoliciesv1.FunctionArgument_Arg_Constant)(nil), + (*ucabacpoliciesv1.FunctionArgument_Arg_FunctionArgExpression)(nil), + (*ucabacpoliciesv1.PolicyInfo_Options_ColumnMask)(nil), + (*ucabacpoliciesv1.PolicyInfo_Options_Deny)(nil), + (*ucabacpoliciesv1.PolicyInfo_Options_Grant)(nil), + (*ucabacpoliciesv1.PolicyInfo_Options_RowFilter)(nil), + (*ucabacpoliciesv1.TagIntrospectionExpression_Expr_ColumnTagValue)(nil), + (*ucabacpoliciesv1.TagIntrospectionExpression_Expr_TagValue)(nil), + (*uccredentialsv1.AwsCredentials_Creds_StsRole)(nil), + (*uccredentialsv1.CreateAccountsStorageCredential_Credential_AwsIamRole)(nil), + (*uccredentialsv1.CreateAccountsStorageCredential_Credential_AzureManagedIdentity)(nil), + (*uccredentialsv1.CreateAccountsStorageCredential_Credential_AzureServicePrincipal)(nil), + (*uccredentialsv1.CreateAccountsStorageCredential_Credential_CloudflareApiToken)(nil), + (*uccredentialsv1.CreateAccountsStorageCredential_Credential_DatabricksGcpServiceAccount)(nil), + (*uccredentialsv1.CreateAccountsStorageCredential_Credential_GcpServiceAccountKey)(nil), + (*uccredentialsv1.CreateCredentialAwsCredentials_Creds_StsRole)(nil), + (*uccredentialsv1.CreateCredentialRequest_Credential_AwsIamRole)(nil), + (*uccredentialsv1.CreateCredentialRequest_Credential_AzureManagedIdentity)(nil), + (*uccredentialsv1.CreateCredentialRequest_Credential_AzureServicePrincipal)(nil), + (*uccredentialsv1.CreateCredentialRequest_Credential_CloudflareApiToken)(nil), + (*uccredentialsv1.CreateCredentialRequest_Credential_DatabricksGcpServiceAccount)(nil), + (*uccredentialsv1.CreateCredentialRequest_Credential_GcpServiceAccountKey)(nil), + (*uccredentialsv1.CreateCredentialsRequest_CloudCredentials_AwsCredentials)(nil), + (*uccredentialsv1.CreateStorageCredentialRequest_Credential_AwsIamRole)(nil), + (*uccredentialsv1.CreateStorageCredentialRequest_Credential_AzureManagedIdentity)(nil), + (*uccredentialsv1.CreateStorageCredentialRequest_Credential_AzureServicePrincipal)(nil), + (*uccredentialsv1.CreateStorageCredentialRequest_Credential_CloudflareApiToken)(nil), + (*uccredentialsv1.CreateStorageCredentialRequest_Credential_DatabricksGcpServiceAccount)(nil), + (*uccredentialsv1.CreateStorageCredentialRequest_Credential_GcpServiceAccountKey)(nil), + (*uccredentialsv1.CredentialInfo_Credential_AwsIamRole)(nil), + (*uccredentialsv1.CredentialInfo_Credential_AzureManagedIdentity)(nil), + (*uccredentialsv1.CredentialInfo_Credential_AzureServicePrincipal)(nil), + (*uccredentialsv1.CredentialInfo_Credential_CloudflareApiToken)(nil), + (*uccredentialsv1.CredentialInfo_Credential_DatabricksGcpServiceAccount)(nil), + (*uccredentialsv1.CredentialInfo_Credential_GcpServiceAccountKey)(nil), + (*uccredentialsv1.Credentials_CloudCredentials_AwsCredentials)(nil), + (*uccredentialsv1.GenerateTemporaryPathCredentialResponse_Credentials_AwsTempCredentials)(nil), + (*uccredentialsv1.GenerateTemporaryPathCredentialResponse_Credentials_AzureAad)(nil), + (*uccredentialsv1.GenerateTemporaryPathCredentialResponse_Credentials_AzureUserDelegationSas)(nil), + (*uccredentialsv1.GenerateTemporaryPathCredentialResponse_Credentials_GcpOauthToken)(nil), + (*uccredentialsv1.GenerateTemporaryPathCredentialResponse_Credentials_R2TempCredentials)(nil), + (*uccredentialsv1.GenerateTemporaryServiceCredentialRequest_Options_AzureOptions)(nil), + (*uccredentialsv1.GenerateTemporaryServiceCredentialRequest_Options_GcpOptions)(nil), + (*uccredentialsv1.GenerateTemporaryTableCredentialResponse_Credentials_AwsTempCredentials)(nil), + (*uccredentialsv1.GenerateTemporaryTableCredentialResponse_Credentials_AzureAad)(nil), + (*uccredentialsv1.GenerateTemporaryTableCredentialResponse_Credentials_AzureUserDelegationSas)(nil), + (*uccredentialsv1.GenerateTemporaryTableCredentialResponse_Credentials_GcpOauthToken)(nil), + (*uccredentialsv1.GenerateTemporaryTableCredentialResponse_Credentials_R2TempCredentials)(nil), + (*uccredentialsv1.GenerateTemporaryVolumeCredentialResponse_Credentials_AwsTempCredentials)(nil), + (*uccredentialsv1.GenerateTemporaryVolumeCredentialResponse_Credentials_AzureAad)(nil), + (*uccredentialsv1.GenerateTemporaryVolumeCredentialResponse_Credentials_AzureUserDelegationSas)(nil), + (*uccredentialsv1.GenerateTemporaryVolumeCredentialResponse_Credentials_GcpOauthToken)(nil), + (*uccredentialsv1.GenerateTemporaryVolumeCredentialResponse_Credentials_R2TempCredentials)(nil), + (*uccredentialsv1.StorageCredentialInfo_Credential_AwsIamRole)(nil), + (*uccredentialsv1.StorageCredentialInfo_Credential_AzureManagedIdentity)(nil), + (*uccredentialsv1.StorageCredentialInfo_Credential_AzureServicePrincipal)(nil), + (*uccredentialsv1.StorageCredentialInfo_Credential_CloudflareApiToken)(nil), + (*uccredentialsv1.StorageCredentialInfo_Credential_DatabricksGcpServiceAccount)(nil), + (*uccredentialsv1.StorageCredentialInfo_Credential_GcpServiceAccountKey)(nil), + (*uccredentialsv1.TemporaryCredentials_Credentials_AwsTempCredentials)(nil), + (*uccredentialsv1.TemporaryCredentials_Credentials_AzureAad)(nil), + (*uccredentialsv1.TemporaryCredentials_Credentials_AzureUserDelegationSas)(nil), + (*uccredentialsv1.TemporaryCredentials_Credentials_GcpOauthToken)(nil), + (*uccredentialsv1.TemporaryCredentials_Credentials_R2TempCredentials)(nil), + (*uccredentialsv1.UpdateAccountsStorageCredential_Credential_AwsIamRole)(nil), + (*uccredentialsv1.UpdateAccountsStorageCredential_Credential_AzureManagedIdentity)(nil), + (*uccredentialsv1.UpdateAccountsStorageCredential_Credential_AzureServicePrincipal)(nil), + (*uccredentialsv1.UpdateAccountsStorageCredential_Credential_CloudflareApiToken)(nil), + (*uccredentialsv1.UpdateAccountsStorageCredential_Credential_DatabricksGcpServiceAccount)(nil), + (*uccredentialsv1.UpdateAccountsStorageCredential_Credential_GcpServiceAccountKey)(nil), + (*uccredentialsv1.UpdateCredentialRequest_Credential_AwsIamRole)(nil), + (*uccredentialsv1.UpdateCredentialRequest_Credential_AzureManagedIdentity)(nil), + (*uccredentialsv1.UpdateCredentialRequest_Credential_AzureServicePrincipal)(nil), + (*uccredentialsv1.UpdateCredentialRequest_Credential_CloudflareApiToken)(nil), + (*uccredentialsv1.UpdateCredentialRequest_Credential_DatabricksGcpServiceAccount)(nil), + (*uccredentialsv1.UpdateCredentialRequest_Credential_GcpServiceAccountKey)(nil), + (*uccredentialsv1.UpdateStorageCredentialRequest_Credential_AwsIamRole)(nil), + (*uccredentialsv1.UpdateStorageCredentialRequest_Credential_AzureManagedIdentity)(nil), + (*uccredentialsv1.UpdateStorageCredentialRequest_Credential_AzureServicePrincipal)(nil), + (*uccredentialsv1.UpdateStorageCredentialRequest_Credential_CloudflareApiToken)(nil), + (*uccredentialsv1.UpdateStorageCredentialRequest_Credential_DatabricksGcpServiceAccount)(nil), + (*uccredentialsv1.UpdateStorageCredentialRequest_Credential_GcpServiceAccountKey)(nil), + (*uccredentialsv1.ValidateCredentialRequest_Credential_AwsIamRole)(nil), + (*uccredentialsv1.ValidateCredentialRequest_Credential_AzureManagedIdentity)(nil), + (*uccredentialsv1.ValidateCredentialRequest_Credential_CredentialName)(nil), + (*uccredentialsv1.ValidateCredentialRequest_Credential_DatabricksGcpServiceAccount)(nil), + (*uccredentialsv1.ValidateStorageCredentialRequest_Credential_AwsIamRole)(nil), + (*uccredentialsv1.ValidateStorageCredentialRequest_Credential_AzureManagedIdentity)(nil), + (*uccredentialsv1.ValidateStorageCredentialRequest_Credential_AzureServicePrincipal)(nil), + (*uccredentialsv1.ValidateStorageCredentialRequest_Credential_CloudflareApiToken)(nil), + (*uccredentialsv1.ValidateStorageCredentialRequest_Credential_DatabricksGcpServiceAccount)(nil), + (*uccredentialsv1.ValidateStorageCredentialRequest_Credential_StorageCredentialName)(nil), + (*ucexternallineagev1.ExternalLineageRelationshipObject_Tpe_ExternalMetadata)(nil), + (*ucexternallineagev1.ExternalLineageRelationshipObject_Tpe_ModelVersion)(nil), + (*ucexternallineagev1.ExternalLineageRelationshipObject_Tpe_Path)(nil), + (*ucexternallineagev1.ExternalLineageRelationshipObject_Tpe_Table)(nil), + (*ucexternallocationsv1.EncryptionDetails_EncryptionDetailsType_SseEncryptionDetails)(nil), + (*ucexternallocationsv1.FileEventQueue_Managed_ManagedAqs)(nil), + (*ucexternallocationsv1.FileEventQueue_Managed_ManagedPubsub)(nil), + (*ucexternallocationsv1.FileEventQueue_Managed_ManagedSqs)(nil), + (*ucexternallocationsv1.FileEventQueue_Provided_ProvidedAqs)(nil), + (*ucexternallocationsv1.FileEventQueue_Provided_ProvidedPubsub)(nil), + (*ucexternallocationsv1.FileEventQueue_Provided_ProvidedSqs)(nil), + (*ucfunctionsv1.Dependency_Value_Connection)(nil), + (*ucfunctionsv1.Dependency_Value_Credential)(nil), + (*ucfunctionsv1.Dependency_Value_Function)(nil), + (*ucfunctionsv1.Dependency_Value_Table)(nil), + (*uconlinetablesv1.OnlineTableSpec_SchedulingPolicy_RunContinuously)(nil), + (*uconlinetablesv1.OnlineTableSpec_SchedulingPolicy_RunTriggered)(nil), + (*uconlinetablesv1.OnlineTableStatus_DetailedStatus_ContinuousUpdateStatus)(nil), + (*uconlinetablesv1.OnlineTableStatus_DetailedStatus_FailedStatus)(nil), + (*uconlinetablesv1.OnlineTableStatus_DetailedStatus_ProvisioningStatus)(nil), + (*uconlinetablesv1.OnlineTableStatus_DetailedStatus_TriggeredUpdateStatus)(nil), + (*ucregisteredmodelsv1.Dependency_Value_Connection)(nil), + (*ucregisteredmodelsv1.Dependency_Value_Credential)(nil), + (*ucregisteredmodelsv1.Dependency_Value_Function)(nil), + (*ucregisteredmodelsv1.Dependency_Value_Table)(nil), + (*uctablesv1.Dependency_Value_Connection)(nil), + (*uctablesv1.Dependency_Value_Credential)(nil), + (*uctablesv1.Dependency_Value_Function)(nil), + (*uctablesv1.Dependency_Value_Table)(nil), + (*uctablesv1.EncryptionDetails_EncryptionDetailsType_SseEncryptionDetails)(nil), + (*uctablesv1.PolicyFunctionArgument_Arg_Column)(nil), + (*uctablesv1.PolicyFunctionArgument_Arg_Constant)(nil), + (*uctablesv1.TableConstraint_Constraint_ForeignKeyConstraint)(nil), + (*uctablesv1.TableConstraint_Constraint_NamedTableConstraint)(nil), + (*uctablesv1.TableConstraint_Constraint_PrimaryKeyConstraint)(nil), + (*ucvolumesv1.EncryptionDetails_EncryptionDetailsType_SseEncryptionDetails)(nil), + (*vectorsearchv1.CreateVectorIndexRequest_IndexSpec_DeltaSyncIndexSpec)(nil), + (*vectorsearchv1.CreateVectorIndexRequest_IndexSpec_DirectAccessIndexSpec)(nil), + (*vectorsearchv1.EmbeddingSourceColumn_EmbeddingConfig_EmbeddingModelEndpointName)(nil), + (*vectorsearchv1.MiniVectorIndex_IndexSpec_DeltaSyncIndexSpec)(nil), + (*vectorsearchv1.MiniVectorIndex_IndexSpec_DirectAccessIndexSpec)(nil), + (*vectorsearchv1.Value_Kind_BoolValue)(nil), + (*vectorsearchv1.Value_Kind_ListValue)(nil), + (*vectorsearchv1.Value_Kind_NumberValue)(nil), + (*vectorsearchv1.Value_Kind_StringValue)(nil), + (*vectorsearchv1.Value_Kind_StructValue)(nil), + (*vectorsearchv1.VectorIndex_IndexSpec_DeltaSyncIndexSpec)(nil), + (*vectorsearchv1.VectorIndex_IndexSpec_DirectAccessIndexSpec)(nil), + (*workspacesv1.CloudResourceContainer_CloudResourceContainer_Gcp)(nil), + (*workspacesv1.WorkspaceNetwork_Network_GcpManagedNetworkConfig)(nil), + (*workspacesv1.WorkspaceNetwork_Network_NetworkId)(nil), + (*workspacesv1.Workspace_NetworkConfig_GcpManagedNetworkConfig)(nil), + (*workspacesv1.Workspace_NetworkConfig_NetworkId)(nil), +} diff --git a/libs/sdktypes/sdkconv/sdkconv.go b/libs/sdktypes/sdkconv/sdkconv.go new file mode 100644 index 00000000000..1bf1cfb33df --- /dev/null +++ b/libs/sdktypes/sdkconv/sdkconv.go @@ -0,0 +1,247 @@ +// Package sdkconv converts between sdk-go model types and their JSON mirrors +// in libs/sdktypes. +// +// The generated ToSDK / FromSDK functions only exist in the +// directions sdk-go itself needs (requests are only encoded, responses only +// decoded). This package converts any mirror/model pair in either direction +// by matching fields by Go name; oneof members, which the mirrors flatten +// into their parent, are matched through the wrapper types registered in +// oneofs.generated.go. +package sdkconv + +import ( + "encoding/json" + "fmt" + "reflect" + "sync" +) + +// FromSDK converts an sdk-go value (or pointer to one) into a new mirror of +// type M. A nil pointer yields nil. +func FromSDK[M any](src any) (*M, error) { + return convertTo[M](src) +} + +// ToSDK converts a mirror value (or pointer to one) into a new sdk-go value +// of type S. A nil pointer yields nil. +func ToSDK[S any](src any) (*S, error) { + return convertTo[S](src) +} + +func convertTo[T any](src any) (*T, error) { + sv := reflect.ValueOf(src) + if !sv.IsValid() || (sv.Kind() == reflect.Pointer && sv.IsNil()) { + return nil, nil + } + var dst T + if err := convert(reflect.ValueOf(&dst).Elem(), sv); err != nil { + return nil, err + } + return &dst, nil +} + +// Convert sets *dst to the converted value of src. dst must be a non-nil pointer. +func Convert(dst, src any) error { + dv := reflect.ValueOf(dst) + if dv.Kind() != reflect.Pointer || dv.IsNil() { + return fmt.Errorf("sdkconv: dst must be a non-nil pointer, got %T", dst) + } + return convert(dv.Elem(), reflect.ValueOf(src)) +} + +var wrapperTypes = sync.OnceValue(func() []reflect.Type { + result := make([]reflect.Type, len(oneofWrappers)) + for i, w := range oneofWrappers { + result[i] = reflect.TypeOf(w) + } + return result +}) + +var wrappersByInterface sync.Map // reflect.Type -> []reflect.Type + +// implementations returns the wrapper pointer types implementing a oneof interface. +func implementations(iface reflect.Type) []reflect.Type { + if v, ok := wrappersByInterface.Load(iface); ok { + return v.([]reflect.Type) + } + var result []reflect.Type + for _, w := range wrapperTypes() { + if w.Implements(iface) { + result = append(result, w) + } + } + wrappersByInterface.Store(iface, result) + return result +} + +func convert(dst, src reflect.Value) error { + if !src.IsValid() { + return nil + } + if src.Kind() == reflect.Pointer { + if src.IsNil() { + return nil + } + if dst.Kind() == reflect.Pointer { + if dst.Type() == src.Type() { + dst.Set(src) + return nil + } + elem := reflect.New(dst.Type().Elem()) + if err := convert(elem.Elem(), src.Elem()); err != nil { + return err + } + dst.Set(elem) + return nil + } + return convert(dst, src.Elem()) + } + if dst.Kind() == reflect.Pointer { + elem := reflect.New(dst.Type().Elem()) + if err := convert(elem.Elem(), src); err != nil { + return err + } + dst.Set(elem) + return nil + } + + if src.Type() == dst.Type() { + dst.Set(src) + return nil + } + + switch { + case isBasic(src.Kind()) && isBasic(dst.Kind()) && src.Type().ConvertibleTo(dst.Type()): + dst.Set(src.Convert(dst.Type())) + return nil + case src.Kind() == reflect.Struct && dst.Kind() == reflect.Struct: + return convertStruct(dst, src) + case src.Kind() == reflect.Slice && dst.Kind() == reflect.Slice: + if src.IsNil() { + return nil + } + out := reflect.MakeSlice(dst.Type(), src.Len(), src.Len()) + for i := range src.Len() { + if err := convert(out.Index(i), src.Index(i)); err != nil { + return fmt.Errorf("[%d]: %w", i, err) + } + } + dst.Set(out) + return nil + case src.Kind() == reflect.Map && dst.Kind() == reflect.Map: + if src.IsNil() { + return nil + } + out := reflect.MakeMapWithSize(dst.Type(), src.Len()) + iter := src.MapRange() + for iter.Next() { + k := reflect.New(dst.Type().Key()).Elem() + if err := convert(k, iter.Key()); err != nil { + return err + } + v := reflect.New(dst.Type().Elem()).Elem() + if err := convert(v, iter.Value()); err != nil { + return fmt.Errorf("[%v]: %w", iter.Key(), err) + } + out.SetMapIndex(k, v) + } + dst.Set(out) + return nil + } + + // Types with a custom JSON encoding, e.g. types.FieldMask (a string on the + // wire) or json.RawMessage, convert through their JSON form. + data, err := json.Marshal(src.Interface()) + if err != nil { + return fmt.Errorf("cannot convert %s to %s: %w", src.Type(), dst.Type(), err) + } + if err := json.Unmarshal(data, dst.Addr().Interface()); err != nil { + return fmt.Errorf("cannot convert %s to %s: %w", src.Type(), dst.Type(), err) + } + return nil +} + +func isBasic(k reflect.Kind) bool { + switch k { + case reflect.Bool, reflect.String, + reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + reflect.Float32, reflect.Float64: + return true + default: + return false + } +} + +func convertStruct(dst, src reflect.Value) error { + dt, st := dst.Type(), src.Type() + consumed := map[string]bool{} + + // Mirror -> sdk-go: fill each oneof interface field of dst from whichever + // flattened member of src is set. + for i := range dt.NumField() { + f := dt.Field(i) + if !f.IsExported() || f.Type.Kind() != reflect.Interface { + continue + } + for _, w := range implementations(f.Type) { + member := w.Elem().Field(0).Name + sv := src.FieldByName(member) + consumed[member] = true + if !sv.IsValid() || sv.IsZero() { + continue + } + if !dst.Field(i).IsNil() { + return fmt.Errorf("%s.%s: multiple oneof members set", dt.Name(), f.Name) + } + wv := reflect.New(w.Elem()) + if err := convert(wv.Elem().Field(0), sv); err != nil { + return fmt.Errorf("%s: %w", member, err) + } + dst.Field(i).Set(wv) + } + } + + for i := range st.NumField() { + f := st.Field(i) + if !f.IsExported() { + continue + } + sv := src.Field(i) + + // sdk-go -> mirror: a oneof interface holds *Wrapper{Member: value}; + // the mirror has Member as a field of the parent. + if f.Type.Kind() == reflect.Interface { + if sv.IsNil() || sv.Elem().IsNil() { + continue + } + w := sv.Elem().Elem() + for j := range w.NumField() { + name := w.Type().Field(j).Name + df := dst.FieldByName(name) + if !df.IsValid() { + return fmt.Errorf("%s has no field %s for oneof %s.%s", dt.Name(), name, st.Name(), f.Name) + } + if err := convert(df, w.Field(j)); err != nil { + return fmt.Errorf("%s: %w", name, err) + } + } + continue + } + + if consumed[f.Name] { + continue + } + df := dst.FieldByName(f.Name) + if !df.IsValid() { + if sv.IsZero() { + continue + } + return fmt.Errorf("%s has no field %s (from %s)", dt.Name(), f.Name, st.Name()) + } + if err := convert(df, sv); err != nil { + return fmt.Errorf("%s: %w", f.Name, err) + } + } + return nil +} diff --git a/libs/sdktypes/sdkconv/sdkconv_test.go b/libs/sdktypes/sdkconv/sdkconv_test.go new file mode 100644 index 00000000000..994a7831172 --- /dev/null +++ b/libs/sdktypes/sdkconv/sdkconv_test.go @@ -0,0 +1,45 @@ +package sdkconv_test + +import ( + "encoding/json" + "testing" + + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/sdktypes/sdkconv" + sdkjobs "github.com/databricks/sdk-go/jobs/v2" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +const jobJSON = `{"job_id":123,"settings":{"name":"x","max_concurrent_runs":0,"tasks":[{"task_key":"a","notebook_task":{"notebook_path":"/p"},"existing_cluster_id":"c1","environment_key":"e"}],"run_as":{"service_principal_name":"sp"},"format":"MULTI_TASK"}}` + +func TestRoundTripMatchesGenerated(t *testing.T) { + var m jobs.GetJobResponse + require.NoError(t, json.Unmarshal([]byte(jobJSON), &m)) + + // ToSDK exists for Job (it is decoded from responses); compare with sdkconv. + want, err := jobs.GetJobResponseToSDK(&m) + require.NoError(t, err) + got, err := sdkconv.ToSDK[sdkjobs.GetJobResponse](&m) + require.NoError(t, err) + assert.Equal(t, want, got) + + // FromSDK does not exist for Job; sdkconv provides it. + back, err := sdkconv.FromSDK[jobs.GetJobResponse](got) + require.NoError(t, err) + out, err := json.Marshal(back) + require.NoError(t, err) + assert.JSONEq(t, jobJSON, string(out)) +} + +func TestMultipleOneofMembers(t *testing.T) { + m := jobs.JobRunAs{UserName: new("u"), ServicePrincipalName: new("sp")} + _, err := sdkconv.ToSDK[sdkjobs.JobRunAs](&m) + assert.ErrorContains(t, err, "multiple oneof members set") +} + +func TestNil(t *testing.T) { + got, err := sdkconv.FromSDK[jobs.GetJobResponse]((*sdkjobs.GetJobResponse)(nil)) + require.NoError(t, err) + assert.Nil(t, got) +} diff --git a/libs/sdktypes/secrets/v1/types.generated.go b/libs/sdktypes/secrets/v1/types.generated.go new file mode 100644 index 00000000000..f0561ede9d4 --- /dev/null +++ b/libs/sdktypes/secrets/v1/types.generated.go @@ -0,0 +1,637 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/secrets/v1. DO NOT EDIT. + +package secrets + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/secrets/v1" + + strings "strings" +) + +type ( + AclPermission = sdk.AclPermission + ScopeBackendType = sdk.ScopeBackendType +) + +const ( + AclPermission_Unspecified = sdk.AclPermission_Unspecified + AclPermission_Read = sdk.AclPermission_Read + AclPermission_Write = sdk.AclPermission_Write + AclPermission_Manage = sdk.AclPermission_Manage + ScopeBackendType_Unspecified = sdk.ScopeBackendType_Unspecified + ScopeBackendType_Databricks = sdk.ScopeBackendType_Databricks + ScopeBackendType_AzureKeyvault = sdk.ScopeBackendType_AzureKeyvault +) + +// An item representing an ACL rule applied to the given principal (user or +// group) on the associated scope point.. +type AclItem struct { + // The permission level applied to the principal. + Permission AclPermission `json:"permission,omitempty"` + // The principal in which the permission is applied. + Principal *string `json:"principal,omitempty"` +} + +// The metadata of the Azure KeyVault for a secret scope of type +// `AZURE_KEYVAULT`. +type AzureKeyVaultSecretScopeMetadata struct { + // The DNS of the KeyVault + DnsName *string `json:"dns_name,omitempty"` + // The resource id of the azure KeyVault that user wants to associate the scope + // with. + ResourceId *string `json:"resource_id,omitempty"` +} + +type CreateScopeRequest struct { + // The metadata for the secret scope if the type is ``AZURE_KEYVAULT`` + BackendAzureKeyvault *AzureKeyVaultSecretScopeMetadata `json:"backend_azure_keyvault,omitempty"` + // The principal that is initially granted ``MANAGE`` permission to the created + // scope. + InitialManagePrincipal *string `json:"initial_manage_principal,omitempty"` + // Scope name requested by the user. Scope names are unique. + Scope *string `json:"scope,omitempty"` + // The backend type the scope will be created with. If not specified, will + // default to ``DATABRICKS`` + ScopeBackendType ScopeBackendType `json:"scope_backend_type,omitempty"` +} + +type DeleteAclRequest struct { + // The principal to remove an existing ACL from. + Principal *string `json:"principal,omitempty"` + // The name of the scope to remove permissions from. + Scope *string `json:"scope,omitempty"` +} + +type DeleteScopeRequest struct { + // Name of the scope to delete. + Scope *string `json:"scope,omitempty"` +} + +type DeleteSecretRequest struct { + // Name of the secret to delete. + Key *string `json:"key,omitempty"` + // The name of the scope that contains the secret to delete. + Scope *string `json:"scope,omitempty"` +} + +type GetAclRequest struct { + // The principal to fetch ACL information for. + Principal *string `json:"principal,omitempty"` + // The name of the scope to fetch ACL information from. + Scope *string `json:"scope,omitempty"` +} + +type GetSecretRequest struct { + // Name of the secret to fetch value information. + Key *string `json:"key,omitempty"` + // The name of the scope that contains the secret. + Scope *string `json:"scope,omitempty"` +} + +type GetSecretResponse struct { + // A unique name to identify the secret. + Key *string `json:"key,omitempty"` + // The value of the secret in its byte representation. + Value []byte `json:"value,omitempty"` +} + +type ListAclsRequest struct { + // The name of the scope to fetch ACL information from. + Scope *string `json:"scope,omitempty"` +} + +type ListAclsResponse struct { + // The associated ACLs rule applied to principals in the given scope. + Items []AclItem `json:"items,omitempty"` +} + +type ListScopesResponse struct { + // The available secret scopes. + Scopes []SecretScope `json:"scopes,omitempty"` +} + +type ListSecretsRequest struct { + // The name of the scope to list secrets within. + Scope *string `json:"scope,omitempty"` +} + +type ListSecretsResponse struct { + // Metadata information of all secrets contained within the given scope. + Secrets []SecretMetadata `json:"secrets,omitempty"` +} + +type PutAclRequest struct { + // The permission level applied to the principal. + Permission AclPermission `json:"permission,omitempty"` + // The principal in which the permission is applied. + Principal *string `json:"principal,omitempty"` + // The name of the scope to apply permissions to. + Scope *string `json:"scope,omitempty"` +} + +type PutSecretRequest struct { + BytesValue []byte `json:"bytes_value,omitempty"` + // A unique name to identify the secret. + Key *string `json:"key,omitempty"` + // The name of the scope to which the secret will be associated with. + Scope *string `json:"scope,omitempty"` + StringValue *string `json:"string_value,omitempty"` +} + +// The metadata about a secret. Returned when listing secrets. Does not contain +// the actual secret value.. +type SecretMetadata struct { + // A unique name to identify the secret. + Key *string `json:"key,omitempty"` + // The last updated timestamp (in milliseconds) for the secret. + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` +} + +// An organizational resource for storing secrets. Secret scopes can be +// different types (Databricks-managed, Azure KeyVault backed, etc), and ACLs +// can be applied to control permissions for all secrets within a scope.. +type SecretScope struct { + // The type of secret scope backend. + BackendType ScopeBackendType `json:"backend_type,omitempty"` + // The metadata for the secret scope if the type is ``AZURE_KEYVAULT`` + KeyvaultMetadata *AzureKeyVaultSecretScopeMetadata `json:"keyvault_metadata,omitempty"` + // A unique name to identify the secret scope. + Name *string `json:"name,omitempty"` +} + +// AclItemToSDK converts the mirror to the sdk-go type. +func AclItemToSDK(w *AclItem) (*sdk.AclItem, error) { + if w == nil { + return nil, nil + } + out := &sdk.AclItem{} + out.Principal = w.Principal + out.Permission = w.Permission + return out, nil +} + +// AclItemFromSDK converts the sdk-go type to the mirror. +func AclItemFromSDK(v *sdk.AclItem) (*AclItem, error) { + if v == nil { + return nil, nil + } + out := &AclItem{} + out.Principal = v.Principal + out.Permission = v.Permission + return out, nil +} + +// AzureKeyVaultSecretScopeMetadataToSDK converts the mirror to the sdk-go type. +func AzureKeyVaultSecretScopeMetadataToSDK(w *AzureKeyVaultSecretScopeMetadata) (*sdk.AzureKeyVaultSecretScopeMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.AzureKeyVaultSecretScopeMetadata{} + out.ResourceId = w.ResourceId + out.DnsName = w.DnsName + return out, nil +} + +// AzureKeyVaultSecretScopeMetadataFromSDK converts the sdk-go type to the mirror. +func AzureKeyVaultSecretScopeMetadataFromSDK(v *sdk.AzureKeyVaultSecretScopeMetadata) (*AzureKeyVaultSecretScopeMetadata, error) { + if v == nil { + return nil, nil + } + out := &AzureKeyVaultSecretScopeMetadata{} + out.ResourceId = v.ResourceId + out.DnsName = v.DnsName + return out, nil +} + +// CreateScopeRequestToSDK converts the mirror to the sdk-go type. +func CreateScopeRequestToSDK(w *CreateScopeRequest) (*sdk.CreateScopeRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateScopeRequest{} + out.Scope = w.Scope + out.InitialManagePrincipal = w.InitialManagePrincipal + out.ScopeBackendType = w.ScopeBackendType + conv1, err := AzureKeyVaultSecretScopeMetadataToSDK(w.BackendAzureKeyvault) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateScopeRequest.BackendAzureKeyvault", err) + } + out.BackendAzureKeyvault = conv1 + return out, nil +} + +// CreateScopeRequestFromSDK converts the sdk-go type to the mirror. +func CreateScopeRequestFromSDK(v *sdk.CreateScopeRequest) (*CreateScopeRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateScopeRequest{} + out.Scope = v.Scope + out.InitialManagePrincipal = v.InitialManagePrincipal + out.ScopeBackendType = v.ScopeBackendType + conv2, err := AzureKeyVaultSecretScopeMetadataFromSDK(v.BackendAzureKeyvault) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateScopeRequest.BackendAzureKeyvault", err) + } + out.BackendAzureKeyvault = conv2 + return out, nil +} + +// DeleteAclRequestToSDK converts the mirror to the sdk-go type. +func DeleteAclRequestToSDK(w *DeleteAclRequest) (*sdk.DeleteAclRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteAclRequest{} + out.Scope = w.Scope + out.Principal = w.Principal + return out, nil +} + +// DeleteAclRequestFromSDK converts the sdk-go type to the mirror. +func DeleteAclRequestFromSDK(v *sdk.DeleteAclRequest) (*DeleteAclRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteAclRequest{} + out.Scope = v.Scope + out.Principal = v.Principal + return out, nil +} + +// DeleteScopeRequestToSDK converts the mirror to the sdk-go type. +func DeleteScopeRequestToSDK(w *DeleteScopeRequest) (*sdk.DeleteScopeRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteScopeRequest{} + out.Scope = w.Scope + return out, nil +} + +// DeleteScopeRequestFromSDK converts the sdk-go type to the mirror. +func DeleteScopeRequestFromSDK(v *sdk.DeleteScopeRequest) (*DeleteScopeRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteScopeRequest{} + out.Scope = v.Scope + return out, nil +} + +// DeleteSecretRequestToSDK converts the mirror to the sdk-go type. +func DeleteSecretRequestToSDK(w *DeleteSecretRequest) (*sdk.DeleteSecretRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteSecretRequest{} + out.Scope = w.Scope + out.Key = w.Key + return out, nil +} + +// DeleteSecretRequestFromSDK converts the sdk-go type to the mirror. +func DeleteSecretRequestFromSDK(v *sdk.DeleteSecretRequest) (*DeleteSecretRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteSecretRequest{} + out.Scope = v.Scope + out.Key = v.Key + return out, nil +} + +// GetAclRequestToSDK converts the mirror to the sdk-go type. +func GetAclRequestToSDK(w *GetAclRequest) (*sdk.GetAclRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetAclRequest{} + out.Scope = w.Scope + out.Principal = w.Principal + return out, nil +} + +// GetAclRequestFromSDK converts the sdk-go type to the mirror. +func GetAclRequestFromSDK(v *sdk.GetAclRequest) (*GetAclRequest, error) { + if v == nil { + return nil, nil + } + out := &GetAclRequest{} + out.Scope = v.Scope + out.Principal = v.Principal + return out, nil +} + +// GetSecretRequestToSDK converts the mirror to the sdk-go type. +func GetSecretRequestToSDK(w *GetSecretRequest) (*sdk.GetSecretRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetSecretRequest{} + out.Scope = w.Scope + out.Key = w.Key + return out, nil +} + +// GetSecretRequestFromSDK converts the sdk-go type to the mirror. +func GetSecretRequestFromSDK(v *sdk.GetSecretRequest) (*GetSecretRequest, error) { + if v == nil { + return nil, nil + } + out := &GetSecretRequest{} + out.Scope = v.Scope + out.Key = v.Key + return out, nil +} + +// GetSecretResponseToSDK converts the mirror to the sdk-go type. +func GetSecretResponseToSDK(w *GetSecretResponse) (*sdk.GetSecretResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetSecretResponse{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// GetSecretResponseFromSDK converts the sdk-go type to the mirror. +func GetSecretResponseFromSDK(v *sdk.GetSecretResponse) (*GetSecretResponse, error) { + if v == nil { + return nil, nil + } + out := &GetSecretResponse{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// ListAclsRequestToSDK converts the mirror to the sdk-go type. +func ListAclsRequestToSDK(w *ListAclsRequest) (*sdk.ListAclsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAclsRequest{} + out.Scope = w.Scope + return out, nil +} + +// ListAclsRequestFromSDK converts the sdk-go type to the mirror. +func ListAclsRequestFromSDK(v *sdk.ListAclsRequest) (*ListAclsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListAclsRequest{} + out.Scope = v.Scope + return out, nil +} + +// ListAclsResponseToSDK converts the mirror to the sdk-go type. +func ListAclsResponseToSDK(w *ListAclsResponse) (*sdk.ListAclsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAclsResponse{} + conv3, err := convertSlice(w.Items, AclItemToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAclsResponse.Items", err) + } + out.Items = conv3 + return out, nil +} + +// ListAclsResponseFromSDK converts the sdk-go type to the mirror. +func ListAclsResponseFromSDK(v *sdk.ListAclsResponse) (*ListAclsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAclsResponse{} + conv4, err := convertSlice(v.Items, AclItemFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAclsResponse.Items", err) + } + out.Items = conv4 + return out, nil +} + +// ListScopesResponseToSDK converts the mirror to the sdk-go type. +func ListScopesResponseToSDK(w *ListScopesResponse) (*sdk.ListScopesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListScopesResponse{} + conv5, err := convertSlice(w.Scopes, SecretScopeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListScopesResponse.Scopes", err) + } + out.Scopes = conv5 + return out, nil +} + +// ListScopesResponseFromSDK converts the sdk-go type to the mirror. +func ListScopesResponseFromSDK(v *sdk.ListScopesResponse) (*ListScopesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListScopesResponse{} + conv6, err := convertSlice(v.Scopes, SecretScopeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListScopesResponse.Scopes", err) + } + out.Scopes = conv6 + return out, nil +} + +// ListSecretsRequestToSDK converts the mirror to the sdk-go type. +func ListSecretsRequestToSDK(w *ListSecretsRequest) (*sdk.ListSecretsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSecretsRequest{} + out.Scope = w.Scope + return out, nil +} + +// ListSecretsRequestFromSDK converts the sdk-go type to the mirror. +func ListSecretsRequestFromSDK(v *sdk.ListSecretsRequest) (*ListSecretsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSecretsRequest{} + out.Scope = v.Scope + return out, nil +} + +// ListSecretsResponseToSDK converts the mirror to the sdk-go type. +func ListSecretsResponseToSDK(w *ListSecretsResponse) (*sdk.ListSecretsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSecretsResponse{} + conv7, err := convertSlice(w.Secrets, SecretMetadataToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSecretsResponse.Secrets", err) + } + out.Secrets = conv7 + return out, nil +} + +// ListSecretsResponseFromSDK converts the sdk-go type to the mirror. +func ListSecretsResponseFromSDK(v *sdk.ListSecretsResponse) (*ListSecretsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSecretsResponse{} + conv8, err := convertSlice(v.Secrets, SecretMetadataFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSecretsResponse.Secrets", err) + } + out.Secrets = conv8 + return out, nil +} + +// PutAclRequestToSDK converts the mirror to the sdk-go type. +func PutAclRequestToSDK(w *PutAclRequest) (*sdk.PutAclRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PutAclRequest{} + out.Scope = w.Scope + out.Principal = w.Principal + out.Permission = w.Permission + return out, nil +} + +// PutAclRequestFromSDK converts the sdk-go type to the mirror. +func PutAclRequestFromSDK(v *sdk.PutAclRequest) (*PutAclRequest, error) { + if v == nil { + return nil, nil + } + out := &PutAclRequest{} + out.Scope = v.Scope + out.Principal = v.Principal + out.Permission = v.Permission + return out, nil +} + +// PutSecretRequestToSDK converts the mirror to the sdk-go type. +func PutSecretRequestToSDK(w *PutSecretRequest) (*sdk.PutSecretRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PutSecretRequest{} + out.Scope = w.Scope + out.Key = w.Key + { + var members []string + if w.StringValue != nil { + members = append(members, "string_value") + } + if w.BytesValue != nil { + members = append(members, "bytes_value") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.StringValue != nil: + out.Value = &sdk.PutSecretRequest_Value_StringValue{StringValue: *w.StringValue} + case w.BytesValue != nil: + out.Value = &sdk.PutSecretRequest_Value_BytesValue{BytesValue: w.BytesValue} + } + return out, nil +} + +// PutSecretRequestFromSDK converts the sdk-go type to the mirror. +func PutSecretRequestFromSDK(v *sdk.PutSecretRequest) (*PutSecretRequest, error) { + if v == nil { + return nil, nil + } + out := &PutSecretRequest{} + out.Scope = v.Scope + out.Key = v.Key + switch value := v.Value.(type) { + case *sdk.PutSecretRequest_Value_StringValue: + if value != nil { + out.StringValue = new(value.StringValue) + } + case *sdk.PutSecretRequest_Value_BytesValue: + if value != nil { + out.BytesValue = value.BytesValue + } + } + return out, nil +} + +// SecretMetadataToSDK converts the mirror to the sdk-go type. +func SecretMetadataToSDK(w *SecretMetadata) (*sdk.SecretMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.SecretMetadata{} + out.Key = w.Key + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + return out, nil +} + +// SecretMetadataFromSDK converts the sdk-go type to the mirror. +func SecretMetadataFromSDK(v *sdk.SecretMetadata) (*SecretMetadata, error) { + if v == nil { + return nil, nil + } + out := &SecretMetadata{} + out.Key = v.Key + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + return out, nil +} + +// SecretScopeToSDK converts the mirror to the sdk-go type. +func SecretScopeToSDK(w *SecretScope) (*sdk.SecretScope, error) { + if w == nil { + return nil, nil + } + out := &sdk.SecretScope{} + out.Name = w.Name + out.BackendType = w.BackendType + conv9, err := AzureKeyVaultSecretScopeMetadataToSDK(w.KeyvaultMetadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SecretScope.KeyvaultMetadata", err) + } + out.KeyvaultMetadata = conv9 + return out, nil +} + +// SecretScopeFromSDK converts the sdk-go type to the mirror. +func SecretScopeFromSDK(v *sdk.SecretScope) (*SecretScope, error) { + if v == nil { + return nil, nil + } + out := &SecretScope{} + out.Name = v.Name + out.BackendType = v.BackendType + conv10, err := AzureKeyVaultSecretScopeMetadataFromSDK(v.KeyvaultMetadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SecretScope.KeyvaultMetadata", err) + } + out.KeyvaultMetadata = conv10 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/settings/v2/types.generated.go b/libs/sdktypes/settings/v2/types.generated.go new file mode 100644 index 00000000000..15c10d8bf3c --- /dev/null +++ b/libs/sdktypes/settings/v2/types.generated.go @@ -0,0 +1,1542 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/settings/v2. DO NOT EDIT. + +package settings + +import ( + fmt "fmt" + sdk "github.com/databricks/sdk-go/settings/v2" + strings "strings" +) + +type ( + PreviewPhase = sdk.PreviewPhase + AibiDashboardEmbeddingAccessPolicy_AccessPolicyType = sdk.AibiDashboardEmbeddingAccessPolicy_AccessPolicyType + ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek = sdk.ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek + ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency = sdk.ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency + CollaborationPlatformConnectivityMessage_Connectivity = sdk.CollaborationPlatformConnectivityMessage_Connectivity + PersonalComputeMessage_PersonalComputeMessageEnum = sdk.PersonalComputeMessage_PersonalComputeMessageEnum + RestrictWorkspaceAdminsMessage_Status = sdk.RestrictWorkspaceAdminsMessage_Status +) + +const ( + PreviewPhase_Unspecified = sdk.PreviewPhase_Unspecified + PreviewPhase_PrivatePreview = sdk.PreviewPhase_PrivatePreview + PreviewPhase_PublicPreview = sdk.PreviewPhase_PublicPreview + PreviewPhase_Beta = sdk.PreviewPhase_Beta + PreviewPhase_GaSoon = sdk.PreviewPhase_GaSoon + PreviewPhase_Ga = sdk.PreviewPhase_Ga + AibiDashboardEmbeddingAccessPolicy_AccessPolicyType_Unspecified = sdk.AibiDashboardEmbeddingAccessPolicy_AccessPolicyType_Unspecified + AibiDashboardEmbeddingAccessPolicy_AccessPolicyType_AllowAllDomains = sdk.AibiDashboardEmbeddingAccessPolicy_AccessPolicyType_AllowAllDomains + AibiDashboardEmbeddingAccessPolicy_AccessPolicyType_AllowApprovedDomains = sdk.AibiDashboardEmbeddingAccessPolicy_AccessPolicyType_AllowApprovedDomains + AibiDashboardEmbeddingAccessPolicy_AccessPolicyType_DenyAllDomains = sdk.AibiDashboardEmbeddingAccessPolicy_AccessPolicyType_DenyAllDomains + ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Unspecified = sdk.ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Unspecified + ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Monday = sdk.ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Monday + ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Tuesday = sdk.ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Tuesday + ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Wednesday = sdk.ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Wednesday + ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Thursday = sdk.ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Thursday + ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Friday = sdk.ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Friday + ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Saturday = sdk.ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Saturday + ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Sunday = sdk.ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek_Sunday + ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_Unspecified = sdk.ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_Unspecified + ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_FirstOfMonth = sdk.ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_FirstOfMonth + ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_SecondOfMonth = sdk.ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_SecondOfMonth + ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_ThirdOfMonth = sdk.ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_ThirdOfMonth + ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_FourthOfMonth = sdk.ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_FourthOfMonth + ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_FirstAndThirdOfMonth = sdk.ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_FirstAndThirdOfMonth + ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_SecondAndFourthOfMonth = sdk.ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_SecondAndFourthOfMonth + ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_EveryWeek = sdk.ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency_EveryWeek + CollaborationPlatformConnectivityMessage_Connectivity_Unspecified = sdk.CollaborationPlatformConnectivityMessage_Connectivity_Unspecified + CollaborationPlatformConnectivityMessage_Connectivity_AllowAll = sdk.CollaborationPlatformConnectivityMessage_Connectivity_AllowAll + CollaborationPlatformConnectivityMessage_Connectivity_AllowTeams = sdk.CollaborationPlatformConnectivityMessage_Connectivity_AllowTeams + CollaborationPlatformConnectivityMessage_Connectivity_AllowSlack = sdk.CollaborationPlatformConnectivityMessage_Connectivity_AllowSlack + CollaborationPlatformConnectivityMessage_Connectivity_DenyAll = sdk.CollaborationPlatformConnectivityMessage_Connectivity_DenyAll + PersonalComputeMessage_PersonalComputeMessageEnum_Unspecified = sdk.PersonalComputeMessage_PersonalComputeMessageEnum_Unspecified + PersonalComputeMessage_PersonalComputeMessageEnum_On = sdk.PersonalComputeMessage_PersonalComputeMessageEnum_On + PersonalComputeMessage_PersonalComputeMessageEnum_Delegate = sdk.PersonalComputeMessage_PersonalComputeMessageEnum_Delegate + RestrictWorkspaceAdminsMessage_Status_Unspecified = sdk.RestrictWorkspaceAdminsMessage_Status_Unspecified + RestrictWorkspaceAdminsMessage_Status_AllowAll = sdk.RestrictWorkspaceAdminsMessage_Status_AllowAll + RestrictWorkspaceAdminsMessage_Status_RestrictTokensAndJobRunAs = sdk.RestrictWorkspaceAdminsMessage_Status_RestrictTokensAndJobRunAs +) + +type AibiDashboardEmbeddingAccessPolicy struct { + AccessPolicyType AibiDashboardEmbeddingAccessPolicy_AccessPolicyType `json:"access_policy_type,omitempty"` +} + +type AibiDashboardEmbeddingApprovedDomains struct { + ApprovedDomains []string `json:"approved_domains,omitempty"` +} + +type AllowedAppsUserApiScopesMessage struct { + AllowedScopes []string `json:"allowed_scopes,omitempty"` +} + +type BooleanMessage struct { + Value *bool `json:"value,omitempty"` +} + +type ClusterAutoRestartMessage struct { + CanToggle *bool `json:"can_toggle,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnablementDetails *ClusterAutoRestartMessage_EnablementDetails `json:"enablement_details,omitempty"` + MaintenanceWindow *ClusterAutoRestartMessage_MaintenanceWindow `json:"maintenance_window,omitempty"` + RestartEvenIfNoUpdatesAvailable *bool `json:"restart_even_if_no_updates_available,omitempty"` +} + +// Contains an information about the enablement status judging (e.g. whether the +// enterprise tier is enabled) This is only additional information that MUST NOT +// be used to decide whether the setting is enabled or not. This is intended to +// use only for purposes like showing an error message to the customer with the +// additional details. For example, using these details we can check why exactly +// the feature is disabled for this customer.. +type ClusterAutoRestartMessage_EnablementDetails struct { + // The feature is force enabled if compliance mode is active + ForcedForComplianceMode *bool `json:"forced_for_compliance_mode,omitempty"` + // The feature is unavailable if the corresponding entitlement disabled (see + // getShieldEntitlementEnable) + UnavailableForDisabledEntitlement *bool `json:"unavailable_for_disabled_entitlement,omitempty"` + // The feature is unavailable if the customer doesn't have enterprise tier + UnavailableForNonEnterpriseTier *bool `json:"unavailable_for_non_enterprise_tier,omitempty"` +} + +type ClusterAutoRestartMessage_MaintenanceWindow struct { + WeekDayBasedSchedule *ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule `json:"week_day_based_schedule,omitempty"` +} + +type ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule struct { + DayOfWeek ClusterAutoRestartMessage_MaintenanceWindow_DayOfWeek `json:"day_of_week,omitempty"` + Frequency ClusterAutoRestartMessage_MaintenanceWindow_WeekDayFrequency `json:"frequency,omitempty"` + WindowStartTime *ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTime `json:"window_start_time,omitempty"` +} + +type ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTime struct { + Hours *int `json:"hours,omitempty"` + Minutes *int `json:"minutes,omitempty"` +} + +// Controls which external collaboration platforms (Slack, Microsoft Teams) can +// connect to a workspace. Defaults to ALLOW_ALL.. +type CollaborationPlatformConnectivityMessage struct { + Connectivity CollaborationPlatformConnectivityMessage_Connectivity `json:"connectivity,omitempty"` +} + +type IntegerMessage struct { + Value *int `json:"value,omitempty"` +} + +type ListAccountSettingsMetadataRequest struct { + // account ID of the account being managed. + AccountId *string `json:"account_id,omitempty"` + // The maximum number of settings to return. The service may return fewer than + // this value. If unspecified, at most 200 settings will be returned. The + // maximum value is 1000; values above 1000 will be coerced to 1000. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous `ListAccountSettingsMetadataRequest` + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // `ListAccountSettingsMetadataRequest` must match the call that provided the + // page token. + PageToken *string `json:"page_token,omitempty"` +} + +type ListAccountSettingsMetadataResponse struct { + // A token that can be sent as `page_token` to retrieve the next page. If this + // field is omitted, there are no subsequent pages. + NextPageToken *string `json:"next_page_token,omitempty"` + // List of all settings available via public APIs and their metadata + SettingsMetadata []SettingsMetadata `json:"settings_metadata,omitempty"` +} + +type ListAccountUserPreferencesMetadataRequest struct { + // account ID of the account being managed. + AccountId *string `json:"account_id,omitempty"` + // The maximum number of settings to return. The service may return fewer than + // this value. If unspecified, at most 200 settings will be returned. The + // maximum value is 1000; values above 1000 will be coerced to 1000. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous + // `ListAccountUserPreferencesMetadataRequest` call. Provide this to retrieve + // the subsequent page. + // + // When paginating, all other parameters provided to + // `ListAccountUserPreferencesMetadataRequest` must match the call that provided + // the page token. + PageToken *string `json:"page_token,omitempty"` + // User ID of the user whose settings metadata is being retrieved. + UserId *string `json:"user_id,omitempty"` +} + +type ListAccountUserPreferencesMetadataResponse struct { + // A token that can be sent as `page_token` to retrieve the next page. If this + // field is omitted, there are no subsequent pages. + NextPageToken *string `json:"next_page_token,omitempty"` + // List of all settings available via public APIs and their metadata + SettingsMetadata []SettingsMetadata `json:"settings_metadata,omitempty"` +} + +type ListWorkspaceSettingsMetadataRequest struct { + // The maximum number of settings to return. The service may return fewer than + // this value. If unspecified, at most 200 settings will be returned. The + // maximum value is 1000; values above 1000 will be coerced to 1000. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous `ListWorkspaceSettingsMetadataRequest` + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // `ListWorkspaceSettingsMetadataRequest` must match the call that provided the + // page token. + PageToken *string `json:"page_token,omitempty"` +} + +type ListWorkspaceSettingsMetadataResponse struct { + // A token that can be sent as `page_token` to retrieve the next page. If this + // field is omitted, there are no subsequent pages. + NextPageToken *string `json:"next_page_token,omitempty"` + // List of all settings available via public APIs and their metadata + SettingsMetadata []SettingsMetadata `json:"settings_metadata,omitempty"` +} + +type OperationalEmailCustomRecipientMessage struct { + Email *string `json:"email,omitempty"` +} + +type PatchPublicAccountSettingRequest struct { + // account ID of the account being managed. + AccountId *string `json:"account_id,omitempty"` + Name *string `json:"name,omitempty"` + Setting *Setting `json:"setting,omitempty"` +} + +type PatchPublicAccountUserPreferenceRequest struct { + // account ID of the account being managed. + AccountId *string `json:"account_id,omitempty"` + Name *string `json:"name,omitempty"` + Setting *UserPreference `json:"setting,omitempty"` + // User ID of the user whose setting is being updated. + UserId *string `json:"user_id,omitempty"` +} + +type PatchPublicWorkspaceSettingRequest struct { + // Name of the setting + Name *string `json:"name,omitempty"` + Setting *Setting `json:"setting,omitempty"` +} + +type PersonalComputeMessage struct { + Value PersonalComputeMessage_PersonalComputeMessageEnum `json:"value,omitempty"` +} + +type RestrictWorkspaceAdminsMessage struct { + // When true, workspace admins cannot create governance tags. ALLOW_ALL status + // does not override this; they are independent. + DisableGovTagCreation *bool `json:"disable_gov_tag_creation,omitempty"` + Status RestrictWorkspaceAdminsMessage_Status `json:"status,omitempty"` +} + +type Setting struct { + AibiDashboardEmbeddingAccessPolicy *AibiDashboardEmbeddingAccessPolicy `json:"aibi_dashboard_embedding_access_policy,omitempty"` + AibiDashboardEmbeddingApprovedDomains *AibiDashboardEmbeddingApprovedDomains `json:"aibi_dashboard_embedding_approved_domains,omitempty"` + AllowedAppsUserApiScopes *AllowedAppsUserApiScopesMessage `json:"allowed_apps_user_api_scopes,omitempty"` + AutomaticClusterUpdateWorkspace *ClusterAutoRestartMessage `json:"automatic_cluster_update_workspace,omitempty"` + BooleanVal *BooleanMessage `json:"boolean_val,omitempty"` + CollaborationPlatformConnectivity *CollaborationPlatformConnectivityMessage `json:"collaboration_platform_connectivity,omitempty"` + EffectiveAibiDashboardEmbeddingAccessPolicy *AibiDashboardEmbeddingAccessPolicy `json:"effective_aibi_dashboard_embedding_access_policy,omitempty"` + EffectiveAibiDashboardEmbeddingApprovedDomains *AibiDashboardEmbeddingApprovedDomains `json:"effective_aibi_dashboard_embedding_approved_domains,omitempty"` + EffectiveAllowedAppsUserApiScopes *AllowedAppsUserApiScopesMessage `json:"effective_allowed_apps_user_api_scopes,omitempty"` + EffectiveAutomaticClusterUpdateWorkspace *ClusterAutoRestartMessage `json:"effective_automatic_cluster_update_workspace,omitempty"` + EffectiveBooleanVal *BooleanMessage `json:"effective_boolean_val,omitempty"` + EffectiveCollaborationPlatformConnectivity *CollaborationPlatformConnectivityMessage `json:"effective_collaboration_platform_connectivity,omitempty"` + EffectiveIntegerVal *IntegerMessage `json:"effective_integer_val,omitempty"` + EffectiveOperationalEmailCustomRecipient *OperationalEmailCustomRecipientMessage `json:"effective_operational_email_custom_recipient,omitempty"` + EffectivePersonalCompute *PersonalComputeMessage `json:"effective_personal_compute,omitempty"` + EffectiveRestrictWorkspaceAdmins *RestrictWorkspaceAdminsMessage `json:"effective_restrict_workspace_admins,omitempty"` + EffectiveStringVal *StringMessage `json:"effective_string_val,omitempty"` + EffectiveWorkspaceLabel *WorkspaceLabelMessage `json:"effective_workspace_label,omitempty"` + IntegerVal *IntegerMessage `json:"integer_val,omitempty"` + // Name of the setting. + Name *string `json:"name,omitempty"` + OperationalEmailCustomRecipient *OperationalEmailCustomRecipientMessage `json:"operational_email_custom_recipient,omitempty"` + PersonalCompute *PersonalComputeMessage `json:"personal_compute,omitempty"` + RestrictWorkspaceAdmins *RestrictWorkspaceAdminsMessage `json:"restrict_workspace_admins,omitempty"` + StringVal *StringMessage `json:"string_val,omitempty"` + WorkspaceLabel *WorkspaceLabelMessage `json:"workspace_label,omitempty"` +} + +type SettingsMetadata struct { + // Setting description for what this setting controls + Description *string `json:"description,omitempty"` + // Human-readable display name for the setting or feature preview. This field + // may be unset if no display name is available. + DisplayName *string `json:"display_name,omitempty"` + // Link to databricks documentation for the setting + DocsLink *string `json:"docs_link,omitempty"` + // Name of the setting. + Name *string `json:"name,omitempty"` + // Preview phase for feature preview settings. This field is not set for + // non-preview settings. + PreviewPhase PreviewPhase `json:"preview_phase,omitempty"` + // Sample message depicting the type of the setting. To set this setting, the + // value sent must match this type. + Type *string `json:"type,omitempty"` +} + +type StringMessage struct { + // Represents a generic string value. + Value *string `json:"value,omitempty"` +} + +// User Preference represents a user-specific setting scoped to an individual +// user within an account. Unlike workspace or account settings that apply to +// all users, user preferences allow personal customization (e.g., UI theme, +// editor preferences) without affecting other users.. +type UserPreference struct { + BooleanVal *BooleanMessage `json:"boolean_val,omitempty"` + EffectiveBooleanVal *BooleanMessage `json:"effective_boolean_val,omitempty"` + EffectiveStringVal *StringMessage `json:"effective_string_val,omitempty"` + // Name of the setting. + Name *string `json:"name,omitempty"` + StringVal *StringMessage `json:"string_val,omitempty"` + // User ID of the user. + UserId *string `json:"user_id,omitempty"` +} + +// Workspace label and color for display (e.g. in account console).. +type WorkspaceLabelMessage struct { + Color *string `json:"color,omitempty"` + Label *string `json:"label,omitempty"` +} + +// AibiDashboardEmbeddingAccessPolicyToSDK converts the mirror to the sdk-go type. +func AibiDashboardEmbeddingAccessPolicyToSDK(w *AibiDashboardEmbeddingAccessPolicy) (*sdk.AibiDashboardEmbeddingAccessPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.AibiDashboardEmbeddingAccessPolicy{} + out.AccessPolicyType = w.AccessPolicyType + return out, nil +} + +// AibiDashboardEmbeddingAccessPolicyFromSDK converts the sdk-go type to the mirror. +func AibiDashboardEmbeddingAccessPolicyFromSDK(v *sdk.AibiDashboardEmbeddingAccessPolicy) (*AibiDashboardEmbeddingAccessPolicy, error) { + if v == nil { + return nil, nil + } + out := &AibiDashboardEmbeddingAccessPolicy{} + out.AccessPolicyType = v.AccessPolicyType + return out, nil +} + +// AibiDashboardEmbeddingApprovedDomainsToSDK converts the mirror to the sdk-go type. +func AibiDashboardEmbeddingApprovedDomainsToSDK(w *AibiDashboardEmbeddingApprovedDomains) (*sdk.AibiDashboardEmbeddingApprovedDomains, error) { + if w == nil { + return nil, nil + } + out := &sdk.AibiDashboardEmbeddingApprovedDomains{} + out.ApprovedDomains = w.ApprovedDomains + return out, nil +} + +// AibiDashboardEmbeddingApprovedDomainsFromSDK converts the sdk-go type to the mirror. +func AibiDashboardEmbeddingApprovedDomainsFromSDK(v *sdk.AibiDashboardEmbeddingApprovedDomains) (*AibiDashboardEmbeddingApprovedDomains, error) { + if v == nil { + return nil, nil + } + out := &AibiDashboardEmbeddingApprovedDomains{} + out.ApprovedDomains = v.ApprovedDomains + return out, nil +} + +// AllowedAppsUserApiScopesMessageToSDK converts the mirror to the sdk-go type. +func AllowedAppsUserApiScopesMessageToSDK(w *AllowedAppsUserApiScopesMessage) (*sdk.AllowedAppsUserApiScopesMessage, error) { + if w == nil { + return nil, nil + } + out := &sdk.AllowedAppsUserApiScopesMessage{} + out.AllowedScopes = w.AllowedScopes + return out, nil +} + +// AllowedAppsUserApiScopesMessageFromSDK converts the sdk-go type to the mirror. +func AllowedAppsUserApiScopesMessageFromSDK(v *sdk.AllowedAppsUserApiScopesMessage) (*AllowedAppsUserApiScopesMessage, error) { + if v == nil { + return nil, nil + } + out := &AllowedAppsUserApiScopesMessage{} + out.AllowedScopes = v.AllowedScopes + return out, nil +} + +// BooleanMessageToSDK converts the mirror to the sdk-go type. +func BooleanMessageToSDK(w *BooleanMessage) (*sdk.BooleanMessage, error) { + if w == nil { + return nil, nil + } + out := &sdk.BooleanMessage{} + out.Value = w.Value + return out, nil +} + +// BooleanMessageFromSDK converts the sdk-go type to the mirror. +func BooleanMessageFromSDK(v *sdk.BooleanMessage) (*BooleanMessage, error) { + if v == nil { + return nil, nil + } + out := &BooleanMessage{} + out.Value = v.Value + return out, nil +} + +// ClusterAutoRestartMessageToSDK converts the mirror to the sdk-go type. +func ClusterAutoRestartMessageToSDK(w *ClusterAutoRestartMessage) (*sdk.ClusterAutoRestartMessage, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterAutoRestartMessage{} + out.Enabled = w.Enabled + out.CanToggle = w.CanToggle + conv1, err := ClusterAutoRestartMessage_MaintenanceWindowToSDK(w.MaintenanceWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAutoRestartMessage.MaintenanceWindow", err) + } + out.MaintenanceWindow = conv1 + conv2, err := ClusterAutoRestartMessage_EnablementDetailsToSDK(w.EnablementDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAutoRestartMessage.EnablementDetails", err) + } + out.EnablementDetails = conv2 + out.RestartEvenIfNoUpdatesAvailable = w.RestartEvenIfNoUpdatesAvailable + return out, nil +} + +// ClusterAutoRestartMessageFromSDK converts the sdk-go type to the mirror. +func ClusterAutoRestartMessageFromSDK(v *sdk.ClusterAutoRestartMessage) (*ClusterAutoRestartMessage, error) { + if v == nil { + return nil, nil + } + out := &ClusterAutoRestartMessage{} + out.Enabled = v.Enabled + out.CanToggle = v.CanToggle + conv3, err := ClusterAutoRestartMessage_MaintenanceWindowFromSDK(v.MaintenanceWindow) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAutoRestartMessage.MaintenanceWindow", err) + } + out.MaintenanceWindow = conv3 + conv4, err := ClusterAutoRestartMessage_EnablementDetailsFromSDK(v.EnablementDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAutoRestartMessage.EnablementDetails", err) + } + out.EnablementDetails = conv4 + out.RestartEvenIfNoUpdatesAvailable = v.RestartEvenIfNoUpdatesAvailable + return out, nil +} + +// ClusterAutoRestartMessage_EnablementDetailsToSDK converts the mirror to the sdk-go type. +func ClusterAutoRestartMessage_EnablementDetailsToSDK(w *ClusterAutoRestartMessage_EnablementDetails) (*sdk.ClusterAutoRestartMessage_EnablementDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterAutoRestartMessage_EnablementDetails{} + out.UnavailableForNonEnterpriseTier = w.UnavailableForNonEnterpriseTier + out.UnavailableForDisabledEntitlement = w.UnavailableForDisabledEntitlement + out.ForcedForComplianceMode = w.ForcedForComplianceMode + return out, nil +} + +// ClusterAutoRestartMessage_EnablementDetailsFromSDK converts the sdk-go type to the mirror. +func ClusterAutoRestartMessage_EnablementDetailsFromSDK(v *sdk.ClusterAutoRestartMessage_EnablementDetails) (*ClusterAutoRestartMessage_EnablementDetails, error) { + if v == nil { + return nil, nil + } + out := &ClusterAutoRestartMessage_EnablementDetails{} + out.UnavailableForNonEnterpriseTier = v.UnavailableForNonEnterpriseTier + out.UnavailableForDisabledEntitlement = v.UnavailableForDisabledEntitlement + out.ForcedForComplianceMode = v.ForcedForComplianceMode + return out, nil +} + +// ClusterAutoRestartMessage_MaintenanceWindowToSDK converts the mirror to the sdk-go type. +func ClusterAutoRestartMessage_MaintenanceWindowToSDK(w *ClusterAutoRestartMessage_MaintenanceWindow) (*sdk.ClusterAutoRestartMessage_MaintenanceWindow, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterAutoRestartMessage_MaintenanceWindow{} + conv5, err := ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleToSDK(w.WeekDayBasedSchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAutoRestartMessage_MaintenanceWindow.WeekDayBasedSchedule", err) + } + out.WeekDayBasedSchedule = conv5 + return out, nil +} + +// ClusterAutoRestartMessage_MaintenanceWindowFromSDK converts the sdk-go type to the mirror. +func ClusterAutoRestartMessage_MaintenanceWindowFromSDK(v *sdk.ClusterAutoRestartMessage_MaintenanceWindow) (*ClusterAutoRestartMessage_MaintenanceWindow, error) { + if v == nil { + return nil, nil + } + out := &ClusterAutoRestartMessage_MaintenanceWindow{} + conv6, err := ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleFromSDK(v.WeekDayBasedSchedule) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAutoRestartMessage_MaintenanceWindow.WeekDayBasedSchedule", err) + } + out.WeekDayBasedSchedule = conv6 + return out, nil +} + +// ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleToSDK converts the mirror to the sdk-go type. +func ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleToSDK(w *ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule) (*sdk.ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule{} + out.Frequency = w.Frequency + out.DayOfWeek = w.DayOfWeek + conv7, err := ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeToSDK(w.WindowStartTime) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule.WindowStartTime", err) + } + out.WindowStartTime = conv7 + return out, nil +} + +// ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleFromSDK converts the sdk-go type to the mirror. +func ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedScheduleFromSDK(v *sdk.ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule) (*ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule, error) { + if v == nil { + return nil, nil + } + out := &ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule{} + out.Frequency = v.Frequency + out.DayOfWeek = v.DayOfWeek + conv8, err := ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeFromSDK(v.WindowStartTime) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ClusterAutoRestartMessage_MaintenanceWindow_WeekDayBasedSchedule.WindowStartTime", err) + } + out.WindowStartTime = conv8 + return out, nil +} + +// ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeToSDK converts the mirror to the sdk-go type. +func ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeToSDK(w *ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTime) (*sdk.ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTime, error) { + if w == nil { + return nil, nil + } + out := &sdk.ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTime{} + out.Hours = w.Hours + out.Minutes = w.Minutes + return out, nil +} + +// ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeFromSDK converts the sdk-go type to the mirror. +func ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTimeFromSDK(v *sdk.ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTime) (*ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTime, error) { + if v == nil { + return nil, nil + } + out := &ClusterAutoRestartMessage_MaintenanceWindow_WindowStartTime{} + out.Hours = v.Hours + out.Minutes = v.Minutes + return out, nil +} + +// CollaborationPlatformConnectivityMessageToSDK converts the mirror to the sdk-go type. +func CollaborationPlatformConnectivityMessageToSDK(w *CollaborationPlatformConnectivityMessage) (*sdk.CollaborationPlatformConnectivityMessage, error) { + if w == nil { + return nil, nil + } + out := &sdk.CollaborationPlatformConnectivityMessage{} + out.Connectivity = w.Connectivity + return out, nil +} + +// CollaborationPlatformConnectivityMessageFromSDK converts the sdk-go type to the mirror. +func CollaborationPlatformConnectivityMessageFromSDK(v *sdk.CollaborationPlatformConnectivityMessage) (*CollaborationPlatformConnectivityMessage, error) { + if v == nil { + return nil, nil + } + out := &CollaborationPlatformConnectivityMessage{} + out.Connectivity = v.Connectivity + return out, nil +} + +// IntegerMessageToSDK converts the mirror to the sdk-go type. +func IntegerMessageToSDK(w *IntegerMessage) (*sdk.IntegerMessage, error) { + if w == nil { + return nil, nil + } + out := &sdk.IntegerMessage{} + out.Value = w.Value + return out, nil +} + +// IntegerMessageFromSDK converts the sdk-go type to the mirror. +func IntegerMessageFromSDK(v *sdk.IntegerMessage) (*IntegerMessage, error) { + if v == nil { + return nil, nil + } + out := &IntegerMessage{} + out.Value = v.Value + return out, nil +} + +// ListAccountSettingsMetadataRequestToSDK converts the mirror to the sdk-go type. +func ListAccountSettingsMetadataRequestToSDK(w *ListAccountSettingsMetadataRequest) (*sdk.ListAccountSettingsMetadataRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAccountSettingsMetadataRequest{} + out.AccountId = w.AccountId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListAccountSettingsMetadataRequestFromSDK converts the sdk-go type to the mirror. +func ListAccountSettingsMetadataRequestFromSDK(v *sdk.ListAccountSettingsMetadataRequest) (*ListAccountSettingsMetadataRequest, error) { + if v == nil { + return nil, nil + } + out := &ListAccountSettingsMetadataRequest{} + out.AccountId = v.AccountId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListAccountSettingsMetadataResponseToSDK converts the mirror to the sdk-go type. +func ListAccountSettingsMetadataResponseToSDK(w *ListAccountSettingsMetadataResponse) (*sdk.ListAccountSettingsMetadataResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAccountSettingsMetadataResponse{} + conv9, err := convertSlice(w.SettingsMetadata, SettingsMetadataToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAccountSettingsMetadataResponse.SettingsMetadata", err) + } + out.SettingsMetadata = conv9 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListAccountSettingsMetadataResponseFromSDK converts the sdk-go type to the mirror. +func ListAccountSettingsMetadataResponseFromSDK(v *sdk.ListAccountSettingsMetadataResponse) (*ListAccountSettingsMetadataResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAccountSettingsMetadataResponse{} + conv10, err := convertSlice(v.SettingsMetadata, SettingsMetadataFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAccountSettingsMetadataResponse.SettingsMetadata", err) + } + out.SettingsMetadata = conv10 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListAccountUserPreferencesMetadataRequestToSDK converts the mirror to the sdk-go type. +func ListAccountUserPreferencesMetadataRequestToSDK(w *ListAccountUserPreferencesMetadataRequest) (*sdk.ListAccountUserPreferencesMetadataRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAccountUserPreferencesMetadataRequest{} + out.AccountId = w.AccountId + out.UserId = w.UserId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListAccountUserPreferencesMetadataRequestFromSDK converts the sdk-go type to the mirror. +func ListAccountUserPreferencesMetadataRequestFromSDK(v *sdk.ListAccountUserPreferencesMetadataRequest) (*ListAccountUserPreferencesMetadataRequest, error) { + if v == nil { + return nil, nil + } + out := &ListAccountUserPreferencesMetadataRequest{} + out.AccountId = v.AccountId + out.UserId = v.UserId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListAccountUserPreferencesMetadataResponseToSDK converts the mirror to the sdk-go type. +func ListAccountUserPreferencesMetadataResponseToSDK(w *ListAccountUserPreferencesMetadataResponse) (*sdk.ListAccountUserPreferencesMetadataResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListAccountUserPreferencesMetadataResponse{} + conv11, err := convertSlice(w.SettingsMetadata, SettingsMetadataToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAccountUserPreferencesMetadataResponse.SettingsMetadata", err) + } + out.SettingsMetadata = conv11 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListAccountUserPreferencesMetadataResponseFromSDK converts the sdk-go type to the mirror. +func ListAccountUserPreferencesMetadataResponseFromSDK(v *sdk.ListAccountUserPreferencesMetadataResponse) (*ListAccountUserPreferencesMetadataResponse, error) { + if v == nil { + return nil, nil + } + out := &ListAccountUserPreferencesMetadataResponse{} + conv12, err := convertSlice(v.SettingsMetadata, SettingsMetadataFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListAccountUserPreferencesMetadataResponse.SettingsMetadata", err) + } + out.SettingsMetadata = conv12 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListWorkspaceSettingsMetadataRequestToSDK converts the mirror to the sdk-go type. +func ListWorkspaceSettingsMetadataRequestToSDK(w *ListWorkspaceSettingsMetadataRequest) (*sdk.ListWorkspaceSettingsMetadataRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListWorkspaceSettingsMetadataRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListWorkspaceSettingsMetadataRequestFromSDK converts the sdk-go type to the mirror. +func ListWorkspaceSettingsMetadataRequestFromSDK(v *sdk.ListWorkspaceSettingsMetadataRequest) (*ListWorkspaceSettingsMetadataRequest, error) { + if v == nil { + return nil, nil + } + out := &ListWorkspaceSettingsMetadataRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListWorkspaceSettingsMetadataResponseToSDK converts the mirror to the sdk-go type. +func ListWorkspaceSettingsMetadataResponseToSDK(w *ListWorkspaceSettingsMetadataResponse) (*sdk.ListWorkspaceSettingsMetadataResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListWorkspaceSettingsMetadataResponse{} + conv13, err := convertSlice(w.SettingsMetadata, SettingsMetadataToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListWorkspaceSettingsMetadataResponse.SettingsMetadata", err) + } + out.SettingsMetadata = conv13 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListWorkspaceSettingsMetadataResponseFromSDK converts the sdk-go type to the mirror. +func ListWorkspaceSettingsMetadataResponseFromSDK(v *sdk.ListWorkspaceSettingsMetadataResponse) (*ListWorkspaceSettingsMetadataResponse, error) { + if v == nil { + return nil, nil + } + out := &ListWorkspaceSettingsMetadataResponse{} + conv14, err := convertSlice(v.SettingsMetadata, SettingsMetadataFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListWorkspaceSettingsMetadataResponse.SettingsMetadata", err) + } + out.SettingsMetadata = conv14 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// OperationalEmailCustomRecipientMessageToSDK converts the mirror to the sdk-go type. +func OperationalEmailCustomRecipientMessageToSDK(w *OperationalEmailCustomRecipientMessage) (*sdk.OperationalEmailCustomRecipientMessage, error) { + if w == nil { + return nil, nil + } + out := &sdk.OperationalEmailCustomRecipientMessage{} + out.Email = w.Email + return out, nil +} + +// OperationalEmailCustomRecipientMessageFromSDK converts the sdk-go type to the mirror. +func OperationalEmailCustomRecipientMessageFromSDK(v *sdk.OperationalEmailCustomRecipientMessage) (*OperationalEmailCustomRecipientMessage, error) { + if v == nil { + return nil, nil + } + out := &OperationalEmailCustomRecipientMessage{} + out.Email = v.Email + return out, nil +} + +// PatchPublicAccountSettingRequestToSDK converts the mirror to the sdk-go type. +func PatchPublicAccountSettingRequestToSDK(w *PatchPublicAccountSettingRequest) (*sdk.PatchPublicAccountSettingRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchPublicAccountSettingRequest{} + out.AccountId = w.AccountId + out.Name = w.Name + conv15, err := SettingToSDK(w.Setting) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchPublicAccountSettingRequest.Setting", err) + } + out.Setting = conv15 + return out, nil +} + +// PatchPublicAccountSettingRequestFromSDK converts the sdk-go type to the mirror. +func PatchPublicAccountSettingRequestFromSDK(v *sdk.PatchPublicAccountSettingRequest) (*PatchPublicAccountSettingRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchPublicAccountSettingRequest{} + out.AccountId = v.AccountId + out.Name = v.Name + conv16, err := SettingFromSDK(v.Setting) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchPublicAccountSettingRequest.Setting", err) + } + out.Setting = conv16 + return out, nil +} + +// PatchPublicAccountUserPreferenceRequestToSDK converts the mirror to the sdk-go type. +func PatchPublicAccountUserPreferenceRequestToSDK(w *PatchPublicAccountUserPreferenceRequest) (*sdk.PatchPublicAccountUserPreferenceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchPublicAccountUserPreferenceRequest{} + out.AccountId = w.AccountId + out.UserId = w.UserId + out.Name = w.Name + conv17, err := UserPreferenceToSDK(w.Setting) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchPublicAccountUserPreferenceRequest.Setting", err) + } + out.Setting = conv17 + return out, nil +} + +// PatchPublicAccountUserPreferenceRequestFromSDK converts the sdk-go type to the mirror. +func PatchPublicAccountUserPreferenceRequestFromSDK(v *sdk.PatchPublicAccountUserPreferenceRequest) (*PatchPublicAccountUserPreferenceRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchPublicAccountUserPreferenceRequest{} + out.AccountId = v.AccountId + out.UserId = v.UserId + out.Name = v.Name + conv18, err := UserPreferenceFromSDK(v.Setting) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchPublicAccountUserPreferenceRequest.Setting", err) + } + out.Setting = conv18 + return out, nil +} + +// PatchPublicWorkspaceSettingRequestToSDK converts the mirror to the sdk-go type. +func PatchPublicWorkspaceSettingRequestToSDK(w *PatchPublicWorkspaceSettingRequest) (*sdk.PatchPublicWorkspaceSettingRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchPublicWorkspaceSettingRequest{} + out.Name = w.Name + conv19, err := SettingToSDK(w.Setting) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchPublicWorkspaceSettingRequest.Setting", err) + } + out.Setting = conv19 + return out, nil +} + +// PatchPublicWorkspaceSettingRequestFromSDK converts the sdk-go type to the mirror. +func PatchPublicWorkspaceSettingRequestFromSDK(v *sdk.PatchPublicWorkspaceSettingRequest) (*PatchPublicWorkspaceSettingRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchPublicWorkspaceSettingRequest{} + out.Name = v.Name + conv20, err := SettingFromSDK(v.Setting) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PatchPublicWorkspaceSettingRequest.Setting", err) + } + out.Setting = conv20 + return out, nil +} + +// PersonalComputeMessageToSDK converts the mirror to the sdk-go type. +func PersonalComputeMessageToSDK(w *PersonalComputeMessage) (*sdk.PersonalComputeMessage, error) { + if w == nil { + return nil, nil + } + out := &sdk.PersonalComputeMessage{} + out.Value = w.Value + return out, nil +} + +// PersonalComputeMessageFromSDK converts the sdk-go type to the mirror. +func PersonalComputeMessageFromSDK(v *sdk.PersonalComputeMessage) (*PersonalComputeMessage, error) { + if v == nil { + return nil, nil + } + out := &PersonalComputeMessage{} + out.Value = v.Value + return out, nil +} + +// RestrictWorkspaceAdminsMessageToSDK converts the mirror to the sdk-go type. +func RestrictWorkspaceAdminsMessageToSDK(w *RestrictWorkspaceAdminsMessage) (*sdk.RestrictWorkspaceAdminsMessage, error) { + if w == nil { + return nil, nil + } + out := &sdk.RestrictWorkspaceAdminsMessage{} + out.Status = w.Status + out.DisableGovTagCreation = w.DisableGovTagCreation + return out, nil +} + +// RestrictWorkspaceAdminsMessageFromSDK converts the sdk-go type to the mirror. +func RestrictWorkspaceAdminsMessageFromSDK(v *sdk.RestrictWorkspaceAdminsMessage) (*RestrictWorkspaceAdminsMessage, error) { + if v == nil { + return nil, nil + } + out := &RestrictWorkspaceAdminsMessage{} + out.Status = v.Status + out.DisableGovTagCreation = v.DisableGovTagCreation + return out, nil +} + +// SettingToSDK converts the mirror to the sdk-go type. +func SettingToSDK(w *Setting) (*sdk.Setting, error) { + if w == nil { + return nil, nil + } + out := &sdk.Setting{} + out.Name = w.Name + { + var members []string + if w.BooleanVal != nil { + members = append(members, "boolean_val") + } + if w.StringVal != nil { + members = append(members, "string_val") + } + if w.IntegerVal != nil { + members = append(members, "integer_val") + } + if w.AutomaticClusterUpdateWorkspace != nil { + members = append(members, "automatic_cluster_update_workspace") + } + if w.AibiDashboardEmbeddingApprovedDomains != nil { + members = append(members, "aibi_dashboard_embedding_approved_domains") + } + if w.AibiDashboardEmbeddingAccessPolicy != nil { + members = append(members, "aibi_dashboard_embedding_access_policy") + } + if w.RestrictWorkspaceAdmins != nil { + members = append(members, "restrict_workspace_admins") + } + if w.PersonalCompute != nil { + members = append(members, "personal_compute") + } + if w.WorkspaceLabel != nil { + members = append(members, "workspace_label") + } + if w.AllowedAppsUserApiScopes != nil { + members = append(members, "allowed_apps_user_api_scopes") + } + if w.OperationalEmailCustomRecipient != nil { + members = append(members, "operational_email_custom_recipient") + } + if w.CollaborationPlatformConnectivity != nil { + members = append(members, "collaboration_platform_connectivity") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.BooleanVal != nil: + conv21, err := BooleanMessageToSDK(w.BooleanVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.Value = &sdk.Setting_Value_BooleanVal{BooleanVal: *conv21} + case w.StringVal != nil: + conv22, err := StringMessageToSDK(w.StringVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.Value = &sdk.Setting_Value_StringVal{StringVal: *conv22} + case w.IntegerVal != nil: + conv23, err := IntegerMessageToSDK(w.IntegerVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.Value = &sdk.Setting_Value_IntegerVal{IntegerVal: *conv23} + case w.AutomaticClusterUpdateWorkspace != nil: + conv24, err := ClusterAutoRestartMessageToSDK(w.AutomaticClusterUpdateWorkspace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.Value = &sdk.Setting_Value_AutomaticClusterUpdateWorkspace{AutomaticClusterUpdateWorkspace: *conv24} + case w.AibiDashboardEmbeddingApprovedDomains != nil: + conv25, err := AibiDashboardEmbeddingApprovedDomainsToSDK(w.AibiDashboardEmbeddingApprovedDomains) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.Value = &sdk.Setting_Value_AibiDashboardEmbeddingApprovedDomains{AibiDashboardEmbeddingApprovedDomains: *conv25} + case w.AibiDashboardEmbeddingAccessPolicy != nil: + conv26, err := AibiDashboardEmbeddingAccessPolicyToSDK(w.AibiDashboardEmbeddingAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.Value = &sdk.Setting_Value_AibiDashboardEmbeddingAccessPolicy{AibiDashboardEmbeddingAccessPolicy: *conv26} + case w.RestrictWorkspaceAdmins != nil: + conv27, err := RestrictWorkspaceAdminsMessageToSDK(w.RestrictWorkspaceAdmins) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.Value = &sdk.Setting_Value_RestrictWorkspaceAdmins{RestrictWorkspaceAdmins: *conv27} + case w.PersonalCompute != nil: + conv28, err := PersonalComputeMessageToSDK(w.PersonalCompute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.Value = &sdk.Setting_Value_PersonalCompute{PersonalCompute: *conv28} + case w.WorkspaceLabel != nil: + conv29, err := WorkspaceLabelMessageToSDK(w.WorkspaceLabel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.Value = &sdk.Setting_Value_WorkspaceLabel{WorkspaceLabel: *conv29} + case w.AllowedAppsUserApiScopes != nil: + conv30, err := AllowedAppsUserApiScopesMessageToSDK(w.AllowedAppsUserApiScopes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.Value = &sdk.Setting_Value_AllowedAppsUserApiScopes{AllowedAppsUserApiScopes: *conv30} + case w.OperationalEmailCustomRecipient != nil: + conv31, err := OperationalEmailCustomRecipientMessageToSDK(w.OperationalEmailCustomRecipient) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.Value = &sdk.Setting_Value_OperationalEmailCustomRecipient{OperationalEmailCustomRecipient: *conv31} + case w.CollaborationPlatformConnectivity != nil: + conv32, err := CollaborationPlatformConnectivityMessageToSDK(w.CollaborationPlatformConnectivity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.Value = &sdk.Setting_Value_CollaborationPlatformConnectivity{CollaborationPlatformConnectivity: *conv32} + } + { + var members []string + if w.EffectiveBooleanVal != nil { + members = append(members, "effective_boolean_val") + } + if w.EffectiveStringVal != nil { + members = append(members, "effective_string_val") + } + if w.EffectiveIntegerVal != nil { + members = append(members, "effective_integer_val") + } + if w.EffectiveAutomaticClusterUpdateWorkspace != nil { + members = append(members, "effective_automatic_cluster_update_workspace") + } + if w.EffectiveAibiDashboardEmbeddingApprovedDomains != nil { + members = append(members, "effective_aibi_dashboard_embedding_approved_domains") + } + if w.EffectiveAibiDashboardEmbeddingAccessPolicy != nil { + members = append(members, "effective_aibi_dashboard_embedding_access_policy") + } + if w.EffectiveRestrictWorkspaceAdmins != nil { + members = append(members, "effective_restrict_workspace_admins") + } + if w.EffectivePersonalCompute != nil { + members = append(members, "effective_personal_compute") + } + if w.EffectiveWorkspaceLabel != nil { + members = append(members, "effective_workspace_label") + } + if w.EffectiveAllowedAppsUserApiScopes != nil { + members = append(members, "effective_allowed_apps_user_api_scopes") + } + if w.EffectiveOperationalEmailCustomRecipient != nil { + members = append(members, "effective_operational_email_custom_recipient") + } + if w.EffectiveCollaborationPlatformConnectivity != nil { + members = append(members, "effective_collaboration_platform_connectivity") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.EffectiveBooleanVal != nil: + conv33, err := BooleanMessageToSDK(w.EffectiveBooleanVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveValue = &sdk.Setting_EffectiveValue_EffectiveBooleanVal{EffectiveBooleanVal: *conv33} + case w.EffectiveStringVal != nil: + conv34, err := StringMessageToSDK(w.EffectiveStringVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveValue = &sdk.Setting_EffectiveValue_EffectiveStringVal{EffectiveStringVal: *conv34} + case w.EffectiveIntegerVal != nil: + conv35, err := IntegerMessageToSDK(w.EffectiveIntegerVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveValue = &sdk.Setting_EffectiveValue_EffectiveIntegerVal{EffectiveIntegerVal: *conv35} + case w.EffectiveAutomaticClusterUpdateWorkspace != nil: + conv36, err := ClusterAutoRestartMessageToSDK(w.EffectiveAutomaticClusterUpdateWorkspace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveValue = &sdk.Setting_EffectiveValue_EffectiveAutomaticClusterUpdateWorkspace{EffectiveAutomaticClusterUpdateWorkspace: *conv36} + case w.EffectiveAibiDashboardEmbeddingApprovedDomains != nil: + conv37, err := AibiDashboardEmbeddingApprovedDomainsToSDK(w.EffectiveAibiDashboardEmbeddingApprovedDomains) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveValue = &sdk.Setting_EffectiveValue_EffectiveAibiDashboardEmbeddingApprovedDomains{EffectiveAibiDashboardEmbeddingApprovedDomains: *conv37} + case w.EffectiveAibiDashboardEmbeddingAccessPolicy != nil: + conv38, err := AibiDashboardEmbeddingAccessPolicyToSDK(w.EffectiveAibiDashboardEmbeddingAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveValue = &sdk.Setting_EffectiveValue_EffectiveAibiDashboardEmbeddingAccessPolicy{EffectiveAibiDashboardEmbeddingAccessPolicy: *conv38} + case w.EffectiveRestrictWorkspaceAdmins != nil: + conv39, err := RestrictWorkspaceAdminsMessageToSDK(w.EffectiveRestrictWorkspaceAdmins) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveValue = &sdk.Setting_EffectiveValue_EffectiveRestrictWorkspaceAdmins{EffectiveRestrictWorkspaceAdmins: *conv39} + case w.EffectivePersonalCompute != nil: + conv40, err := PersonalComputeMessageToSDK(w.EffectivePersonalCompute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveValue = &sdk.Setting_EffectiveValue_EffectivePersonalCompute{EffectivePersonalCompute: *conv40} + case w.EffectiveWorkspaceLabel != nil: + conv41, err := WorkspaceLabelMessageToSDK(w.EffectiveWorkspaceLabel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveValue = &sdk.Setting_EffectiveValue_EffectiveWorkspaceLabel{EffectiveWorkspaceLabel: *conv41} + case w.EffectiveAllowedAppsUserApiScopes != nil: + conv42, err := AllowedAppsUserApiScopesMessageToSDK(w.EffectiveAllowedAppsUserApiScopes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveValue = &sdk.Setting_EffectiveValue_EffectiveAllowedAppsUserApiScopes{EffectiveAllowedAppsUserApiScopes: *conv42} + case w.EffectiveOperationalEmailCustomRecipient != nil: + conv43, err := OperationalEmailCustomRecipientMessageToSDK(w.EffectiveOperationalEmailCustomRecipient) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveValue = &sdk.Setting_EffectiveValue_EffectiveOperationalEmailCustomRecipient{EffectiveOperationalEmailCustomRecipient: *conv43} + case w.EffectiveCollaborationPlatformConnectivity != nil: + conv44, err := CollaborationPlatformConnectivityMessageToSDK(w.EffectiveCollaborationPlatformConnectivity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveValue = &sdk.Setting_EffectiveValue_EffectiveCollaborationPlatformConnectivity{EffectiveCollaborationPlatformConnectivity: *conv44} + } + return out, nil +} + +// SettingFromSDK converts the sdk-go type to the mirror. +func SettingFromSDK(v *sdk.Setting) (*Setting, error) { + if v == nil { + return nil, nil + } + out := &Setting{} + out.Name = v.Name + switch value := v.Value.(type) { + case *sdk.Setting_Value_BooleanVal: + if value != nil { + conv45, err := BooleanMessageFromSDK(&value.BooleanVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.BooleanVal = conv45 + } + case *sdk.Setting_Value_StringVal: + if value != nil { + conv46, err := StringMessageFromSDK(&value.StringVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.StringVal = conv46 + } + case *sdk.Setting_Value_IntegerVal: + if value != nil { + conv47, err := IntegerMessageFromSDK(&value.IntegerVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.IntegerVal = conv47 + } + case *sdk.Setting_Value_AutomaticClusterUpdateWorkspace: + if value != nil { + conv48, err := ClusterAutoRestartMessageFromSDK(&value.AutomaticClusterUpdateWorkspace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.AutomaticClusterUpdateWorkspace = conv48 + } + case *sdk.Setting_Value_AibiDashboardEmbeddingApprovedDomains: + if value != nil { + conv49, err := AibiDashboardEmbeddingApprovedDomainsFromSDK(&value.AibiDashboardEmbeddingApprovedDomains) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.AibiDashboardEmbeddingApprovedDomains = conv49 + } + case *sdk.Setting_Value_AibiDashboardEmbeddingAccessPolicy: + if value != nil { + conv50, err := AibiDashboardEmbeddingAccessPolicyFromSDK(&value.AibiDashboardEmbeddingAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.AibiDashboardEmbeddingAccessPolicy = conv50 + } + case *sdk.Setting_Value_RestrictWorkspaceAdmins: + if value != nil { + conv51, err := RestrictWorkspaceAdminsMessageFromSDK(&value.RestrictWorkspaceAdmins) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.RestrictWorkspaceAdmins = conv51 + } + case *sdk.Setting_Value_PersonalCompute: + if value != nil { + conv52, err := PersonalComputeMessageFromSDK(&value.PersonalCompute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.PersonalCompute = conv52 + } + case *sdk.Setting_Value_WorkspaceLabel: + if value != nil { + conv53, err := WorkspaceLabelMessageFromSDK(&value.WorkspaceLabel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.WorkspaceLabel = conv53 + } + case *sdk.Setting_Value_AllowedAppsUserApiScopes: + if value != nil { + conv54, err := AllowedAppsUserApiScopesMessageFromSDK(&value.AllowedAppsUserApiScopes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.AllowedAppsUserApiScopes = conv54 + } + case *sdk.Setting_Value_OperationalEmailCustomRecipient: + if value != nil { + conv55, err := OperationalEmailCustomRecipientMessageFromSDK(&value.OperationalEmailCustomRecipient) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.OperationalEmailCustomRecipient = conv55 + } + case *sdk.Setting_Value_CollaborationPlatformConnectivity: + if value != nil { + conv56, err := CollaborationPlatformConnectivityMessageFromSDK(&value.CollaborationPlatformConnectivity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.Value", err) + } + out.CollaborationPlatformConnectivity = conv56 + } + } + switch value := v.EffectiveValue.(type) { + case *sdk.Setting_EffectiveValue_EffectiveBooleanVal: + if value != nil { + conv57, err := BooleanMessageFromSDK(&value.EffectiveBooleanVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveBooleanVal = conv57 + } + case *sdk.Setting_EffectiveValue_EffectiveStringVal: + if value != nil { + conv58, err := StringMessageFromSDK(&value.EffectiveStringVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveStringVal = conv58 + } + case *sdk.Setting_EffectiveValue_EffectiveIntegerVal: + if value != nil { + conv59, err := IntegerMessageFromSDK(&value.EffectiveIntegerVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveIntegerVal = conv59 + } + case *sdk.Setting_EffectiveValue_EffectiveAutomaticClusterUpdateWorkspace: + if value != nil { + conv60, err := ClusterAutoRestartMessageFromSDK(&value.EffectiveAutomaticClusterUpdateWorkspace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveAutomaticClusterUpdateWorkspace = conv60 + } + case *sdk.Setting_EffectiveValue_EffectiveAibiDashboardEmbeddingApprovedDomains: + if value != nil { + conv61, err := AibiDashboardEmbeddingApprovedDomainsFromSDK(&value.EffectiveAibiDashboardEmbeddingApprovedDomains) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveAibiDashboardEmbeddingApprovedDomains = conv61 + } + case *sdk.Setting_EffectiveValue_EffectiveAibiDashboardEmbeddingAccessPolicy: + if value != nil { + conv62, err := AibiDashboardEmbeddingAccessPolicyFromSDK(&value.EffectiveAibiDashboardEmbeddingAccessPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveAibiDashboardEmbeddingAccessPolicy = conv62 + } + case *sdk.Setting_EffectiveValue_EffectiveRestrictWorkspaceAdmins: + if value != nil { + conv63, err := RestrictWorkspaceAdminsMessageFromSDK(&value.EffectiveRestrictWorkspaceAdmins) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveRestrictWorkspaceAdmins = conv63 + } + case *sdk.Setting_EffectiveValue_EffectivePersonalCompute: + if value != nil { + conv64, err := PersonalComputeMessageFromSDK(&value.EffectivePersonalCompute) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectivePersonalCompute = conv64 + } + case *sdk.Setting_EffectiveValue_EffectiveWorkspaceLabel: + if value != nil { + conv65, err := WorkspaceLabelMessageFromSDK(&value.EffectiveWorkspaceLabel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveWorkspaceLabel = conv65 + } + case *sdk.Setting_EffectiveValue_EffectiveAllowedAppsUserApiScopes: + if value != nil { + conv66, err := AllowedAppsUserApiScopesMessageFromSDK(&value.EffectiveAllowedAppsUserApiScopes) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveAllowedAppsUserApiScopes = conv66 + } + case *sdk.Setting_EffectiveValue_EffectiveOperationalEmailCustomRecipient: + if value != nil { + conv67, err := OperationalEmailCustomRecipientMessageFromSDK(&value.EffectiveOperationalEmailCustomRecipient) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveOperationalEmailCustomRecipient = conv67 + } + case *sdk.Setting_EffectiveValue_EffectiveCollaborationPlatformConnectivity: + if value != nil { + conv68, err := CollaborationPlatformConnectivityMessageFromSDK(&value.EffectiveCollaborationPlatformConnectivity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Setting.EffectiveValue", err) + } + out.EffectiveCollaborationPlatformConnectivity = conv68 + } + } + return out, nil +} + +// SettingsMetadataToSDK converts the mirror to the sdk-go type. +func SettingsMetadataToSDK(w *SettingsMetadata) (*sdk.SettingsMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.SettingsMetadata{} + out.Name = w.Name + out.Description = w.Description + out.Type = w.Type + out.DocsLink = w.DocsLink + out.PreviewPhase = w.PreviewPhase + out.DisplayName = w.DisplayName + return out, nil +} + +// SettingsMetadataFromSDK converts the sdk-go type to the mirror. +func SettingsMetadataFromSDK(v *sdk.SettingsMetadata) (*SettingsMetadata, error) { + if v == nil { + return nil, nil + } + out := &SettingsMetadata{} + out.Name = v.Name + out.Description = v.Description + out.Type = v.Type + out.DocsLink = v.DocsLink + out.PreviewPhase = v.PreviewPhase + out.DisplayName = v.DisplayName + return out, nil +} + +// StringMessageToSDK converts the mirror to the sdk-go type. +func StringMessageToSDK(w *StringMessage) (*sdk.StringMessage, error) { + if w == nil { + return nil, nil + } + out := &sdk.StringMessage{} + out.Value = w.Value + return out, nil +} + +// StringMessageFromSDK converts the sdk-go type to the mirror. +func StringMessageFromSDK(v *sdk.StringMessage) (*StringMessage, error) { + if v == nil { + return nil, nil + } + out := &StringMessage{} + out.Value = v.Value + return out, nil +} + +// UserPreferenceToSDK converts the mirror to the sdk-go type. +func UserPreferenceToSDK(w *UserPreference) (*sdk.UserPreference, error) { + if w == nil { + return nil, nil + } + out := &sdk.UserPreference{} + out.Name = w.Name + out.UserId = w.UserId + { + var members []string + if w.BooleanVal != nil { + members = append(members, "boolean_val") + } + if w.StringVal != nil { + members = append(members, "string_val") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.BooleanVal != nil: + conv69, err := BooleanMessageToSDK(w.BooleanVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UserPreference.Value", err) + } + out.Value = &sdk.UserPreference_Value_BooleanVal{BooleanVal: *conv69} + case w.StringVal != nil: + conv70, err := StringMessageToSDK(w.StringVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UserPreference.Value", err) + } + out.Value = &sdk.UserPreference_Value_StringVal{StringVal: *conv70} + } + { + var members []string + if w.EffectiveBooleanVal != nil { + members = append(members, "effective_boolean_val") + } + if w.EffectiveStringVal != nil { + members = append(members, "effective_string_val") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.EffectiveBooleanVal != nil: + conv71, err := BooleanMessageToSDK(w.EffectiveBooleanVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UserPreference.EffectiveValue", err) + } + out.EffectiveValue = &sdk.UserPreference_EffectiveValue_EffectiveBooleanVal{EffectiveBooleanVal: *conv71} + case w.EffectiveStringVal != nil: + conv72, err := StringMessageToSDK(w.EffectiveStringVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UserPreference.EffectiveValue", err) + } + out.EffectiveValue = &sdk.UserPreference_EffectiveValue_EffectiveStringVal{EffectiveStringVal: *conv72} + } + return out, nil +} + +// UserPreferenceFromSDK converts the sdk-go type to the mirror. +func UserPreferenceFromSDK(v *sdk.UserPreference) (*UserPreference, error) { + if v == nil { + return nil, nil + } + out := &UserPreference{} + out.Name = v.Name + out.UserId = v.UserId + switch value := v.Value.(type) { + case *sdk.UserPreference_Value_BooleanVal: + if value != nil { + conv73, err := BooleanMessageFromSDK(&value.BooleanVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UserPreference.Value", err) + } + out.BooleanVal = conv73 + } + case *sdk.UserPreference_Value_StringVal: + if value != nil { + conv74, err := StringMessageFromSDK(&value.StringVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UserPreference.Value", err) + } + out.StringVal = conv74 + } + } + switch value := v.EffectiveValue.(type) { + case *sdk.UserPreference_EffectiveValue_EffectiveBooleanVal: + if value != nil { + conv75, err := BooleanMessageFromSDK(&value.EffectiveBooleanVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UserPreference.EffectiveValue", err) + } + out.EffectiveBooleanVal = conv75 + } + case *sdk.UserPreference_EffectiveValue_EffectiveStringVal: + if value != nil { + conv76, err := StringMessageFromSDK(&value.EffectiveStringVal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UserPreference.EffectiveValue", err) + } + out.EffectiveStringVal = conv76 + } + } + return out, nil +} + +// WorkspaceLabelMessageToSDK converts the mirror to the sdk-go type. +func WorkspaceLabelMessageToSDK(w *WorkspaceLabelMessage) (*sdk.WorkspaceLabelMessage, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkspaceLabelMessage{} + out.Label = w.Label + out.Color = w.Color + return out, nil +} + +// WorkspaceLabelMessageFromSDK converts the sdk-go type to the mirror. +func WorkspaceLabelMessageFromSDK(v *sdk.WorkspaceLabelMessage) (*WorkspaceLabelMessage, error) { + if v == nil { + return nil, nil + } + out := &WorkspaceLabelMessage{} + out.Label = v.Label + out.Color = v.Color + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/sharing/v1/types.generated.go b/libs/sdktypes/sharing/v1/types.generated.go new file mode 100644 index 00000000000..aae07c0c474 --- /dev/null +++ b/libs/sdktypes/sharing/v1/types.generated.go @@ -0,0 +1,3246 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/sharing/v1. DO NOT EDIT. + +package sharing + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/sharing/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + ColumnTypeName = sdk.ColumnTypeName + DeltaSharingAuthenticationType = sdk.DeltaSharingAuthenticationType + FunctionParameterMode = sdk.FunctionParameterMode + FunctionParameterType = sdk.FunctionParameterType + SharedSecurableKind = sdk.SharedSecurableKind + PartitionSpecification_Partition_PartitionValue_PartitionValueOp = sdk.PartitionSpecification_Partition_PartitionValue_PartitionValueOp + SharedDataObject_HistoryDataSharingStatus_Enum = sdk.SharedDataObject_HistoryDataSharingStatus_Enum + SharedDataObject_Status_Enum = sdk.SharedDataObject_Status_Enum + UpdateShareRequest_SharedDataObjectUpdate_Action = sdk.UpdateShareRequest_SharedDataObjectUpdate_Action +) + +const ( + ColumnTypeName_Unspecified = sdk.ColumnTypeName_Unspecified + ColumnTypeName_Boolean = sdk.ColumnTypeName_Boolean + ColumnTypeName_Byte = sdk.ColumnTypeName_Byte + ColumnTypeName_Short = sdk.ColumnTypeName_Short + ColumnTypeName_Int = sdk.ColumnTypeName_Int + ColumnTypeName_Long = sdk.ColumnTypeName_Long + ColumnTypeName_Float = sdk.ColumnTypeName_Float + ColumnTypeName_Double = sdk.ColumnTypeName_Double + ColumnTypeName_Date = sdk.ColumnTypeName_Date + ColumnTypeName_Timestamp = sdk.ColumnTypeName_Timestamp + ColumnTypeName_String = sdk.ColumnTypeName_String + ColumnTypeName_Binary = sdk.ColumnTypeName_Binary + ColumnTypeName_Decimal = sdk.ColumnTypeName_Decimal + ColumnTypeName_Interval = sdk.ColumnTypeName_Interval + ColumnTypeName_Array = sdk.ColumnTypeName_Array + ColumnTypeName_Struct = sdk.ColumnTypeName_Struct + ColumnTypeName_Map = sdk.ColumnTypeName_Map + ColumnTypeName_Char = sdk.ColumnTypeName_Char + ColumnTypeName_Null = sdk.ColumnTypeName_Null + ColumnTypeName_UserDefinedType = sdk.ColumnTypeName_UserDefinedType + ColumnTypeName_TimestampNtz = sdk.ColumnTypeName_TimestampNtz + ColumnTypeName_Variant = sdk.ColumnTypeName_Variant + ColumnTypeName_TableType = sdk.ColumnTypeName_TableType + DeltaSharingAuthenticationType_Unspecified = sdk.DeltaSharingAuthenticationType_Unspecified + DeltaSharingAuthenticationType_Token = sdk.DeltaSharingAuthenticationType_Token + DeltaSharingAuthenticationType_Databricks = sdk.DeltaSharingAuthenticationType_Databricks + DeltaSharingAuthenticationType_OidcFederation = sdk.DeltaSharingAuthenticationType_OidcFederation + DeltaSharingAuthenticationType_OauthClientCredentials = sdk.DeltaSharingAuthenticationType_OauthClientCredentials + FunctionParameterMode_Unspecified = sdk.FunctionParameterMode_Unspecified + FunctionParameterMode_In = sdk.FunctionParameterMode_In + FunctionParameterMode_Out = sdk.FunctionParameterMode_Out + FunctionParameterMode_Inout = sdk.FunctionParameterMode_Inout + FunctionParameterType_Unspecified = sdk.FunctionParameterType_Unspecified + FunctionParameterType_Param = sdk.FunctionParameterType_Param + FunctionParameterType_Column = sdk.FunctionParameterType_Column + SharedSecurableKind_Unspecified = sdk.SharedSecurableKind_Unspecified + SharedSecurableKind_FunctionStandard = sdk.SharedSecurableKind_FunctionStandard + SharedSecurableKind_FunctionRegisteredModel = sdk.SharedSecurableKind_FunctionRegisteredModel + SharedSecurableKind_FunctionFeatureSpec = sdk.SharedSecurableKind_FunctionFeatureSpec + PartitionSpecification_Partition_PartitionValue_PartitionValueOp_Unspecified = sdk.PartitionSpecification_Partition_PartitionValue_PartitionValueOp_Unspecified + PartitionSpecification_Partition_PartitionValue_PartitionValueOp_Like = sdk.PartitionSpecification_Partition_PartitionValue_PartitionValueOp_Like + SharedDataObject_HistoryDataSharingStatus_Enum_Unspecified = sdk.SharedDataObject_HistoryDataSharingStatus_Enum_Unspecified + SharedDataObject_HistoryDataSharingStatus_Enum_Disabled = sdk.SharedDataObject_HistoryDataSharingStatus_Enum_Disabled + SharedDataObject_HistoryDataSharingStatus_Enum_Enabled = sdk.SharedDataObject_HistoryDataSharingStatus_Enum_Enabled + SharedDataObject_Status_Enum_Unspecified = sdk.SharedDataObject_Status_Enum_Unspecified + SharedDataObject_Status_Enum_Active = sdk.SharedDataObject_Status_Enum_Active + SharedDataObject_Status_Enum_PermissionDenied = sdk.SharedDataObject_Status_Enum_PermissionDenied + UpdateShareRequest_SharedDataObjectUpdate_Action_Unspecified = sdk.UpdateShareRequest_SharedDataObjectUpdate_Action_Unspecified + UpdateShareRequest_SharedDataObjectUpdate_Action_Remove = sdk.UpdateShareRequest_SharedDataObjectUpdate_Action_Remove + UpdateShareRequest_SharedDataObjectUpdate_Action_Update = sdk.UpdateShareRequest_SharedDataObjectUpdate_Action_Update +) + +type CreateFederationPolicyRequest struct { + // Name of the policy. This is the name of the policy to be created. + Policy *FederationPolicy `json:"policy,omitempty"` + // Name of the recipient. This is the name of the recipient for which the policy + // is being created. + RecipientName *string `json:"recipient_name,omitempty"` +} + +type CreateProviderRequest struct { + AuthenticationType DeltaSharingAuthenticationType `json:"authentication_type,omitempty"` + // Cloud vendor of the provider's UC metastore. This field is only present when + // the __authentication_type__ is **DATABRICKS**. + Cloud *string `json:"cloud,omitempty"` + // Description about the provider. + Comment *string `json:"comment,omitempty"` + // Time at which this Provider was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of Provider creator. + CreatedBy *string `json:"created_by,omitempty"` + // The global UC metastore id of the data provider. This field is only present + // when the __authentication_type__ is **DATABRICKS**. The identifier is of + // format __cloud__:__region__:__metastore-uuid__. + DataProviderGlobalMetastoreId *string `json:"data_provider_global_metastore_id,omitempty"` + // UUID of the provider's UC metastore. This field is only present when the + // __authentication_type__ is **DATABRICKS**. + MetastoreId *string `json:"metastore_id,omitempty"` + // The name of the Provider. + Name *string `json:"name,omitempty"` + // Username of Provider owner. + Owner *string `json:"owner,omitempty"` + // The recipient profile. This field is only present when the + // authentication_type is `TOKEN` or `OAUTH_CLIENT_CREDENTIALS`. + RecipientProfile *RecipientProfile `json:"recipient_profile,omitempty"` + // This field is required when the __authentication_type__ is **TOKEN**, + // **OAUTH_CLIENT_CREDENTIALS** or not provided. + RecipientProfileStr *string `json:"recipient_profile_str,omitempty"` + // Cloud region of the provider's UC metastore. This field is only present when + // the __authentication_type__ is **DATABRICKS**. + Region *string `json:"region,omitempty"` + // Time at which this Provider was created, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified Provider. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type CreateRecipientRequest struct { + // A boolean status field showing whether the Recipient's activation URL has + // been exercised or not. + Activated *bool `json:"activated,omitempty"` + // Full activation url to retrieve the access token. It will be empty if the + // token is already retrieved. + ActivationUrl *string `json:"activation_url,omitempty"` + AuthenticationType DeltaSharingAuthenticationType `json:"authentication_type,omitempty"` + // Cloud vendor of the recipient's Unity Catalog Metastore. This field is only + // present when the __authentication_type__ is **DATABRICKS**. + Cloud *string `json:"cloud,omitempty"` + // Description about the recipient. + Comment *string `json:"comment,omitempty"` + // Time at which this recipient was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of recipient creator. + CreatedBy *string `json:"created_by,omitempty"` + // The global Unity Catalog metastore id provided by the data recipient. This + // field is only present when the __authentication_type__ is **DATABRICKS**. The + // identifier is of format __cloud__:__region__:__metastore-uuid__. + DataRecipientGlobalMetastoreId *string `json:"data_recipient_global_metastore_id,omitempty"` + // Expiration timestamp of the token, in epoch milliseconds. + ExpirationTime *int64 `json:"expiration_time,omitempty"` + // [Create,Update:IGN] common - id of the recipient + Id *string `json:"id,omitempty"` + // IP Access List + IpAccessList *IpAccessList `json:"ip_access_list,omitempty"` + // Unique identifier of recipient's Unity Catalog Metastore. This field is only + // present when the __authentication_type__ is **DATABRICKS**. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of Recipient. + Name *string `json:"name,omitempty"` + // Username of the recipient owner. + Owner *string `json:"owner,omitempty"` + // Recipient properties as map of string key-value pairs. When provided in + // update request, the specified properties will override the existing + // properties. To add and remove properties, one would need to perform a + // read-modify-write. + PropertiesKvpairs *PropertiesKvPairs `json:"properties_kvpairs,omitempty"` + // Cloud region of the recipient's Unity Catalog Metastore. This field is only + // present when the __authentication_type__ is **DATABRICKS**. + Region *string `json:"region,omitempty"` + // The one-time sharing code provided by the data recipient. This field is only + // present when the __authentication_type__ is **DATABRICKS**. + SharingCode *string `json:"sharing_code,omitempty"` + // This field is only present when the __authentication_type__ is **TOKEN**. + Tokens []RecipientTokenInfo `json:"tokens,omitempty"` + // Time at which the recipient was updated, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of recipient updater. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type CreateShareRequest struct { + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this share was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of share creator. + CreatedBy *string `json:"created_by,omitempty"` + // Name of the share. + Name *string `json:"name,omitempty"` + // A list of shared data objects within the share. + Objects []SharedDataObject `json:"objects,omitempty"` + // Username of current owner of share. + Owner *string `json:"owner,omitempty"` + // Configuration for share replication. + ReplicationConfig *ReplicationConfig `json:"replication_config,omitempty"` + // Storage Location URL (full path) for the share. + StorageLocation *string `json:"storage_location,omitempty"` + // Storage root URL for the share. + StorageRoot *string `json:"storage_root,omitempty"` + // Time at which this share was updated, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of share updater. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// Represents a UC dependency.. +type Dependency struct { + Function *FunctionDependency `json:"function,omitempty"` + Table *TableDependency `json:"table,omitempty"` +} + +// Represents a list of dependencies.. +type DependencyList struct { + // An array of Dependency. + Dependencies []Dependency `json:"dependencies,omitempty"` +} + +type FederationPolicy struct { + // Description of the policy. This is a user-provided description. + Comment *string `json:"comment,omitempty"` + // System-generated timestamp indicating when the policy was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Unique, immutable system-generated identifier for the federation policy. + Id *string `json:"id,omitempty"` + // Name of the federation policy. A recipient can have multiple policies with + // different names. The name must contain only lowercase alphanumeric + // characters, numbers, and hyphens. + Name *string `json:"name,omitempty"` + OidcPolicy *OidcFederationPolicy `json:"oidc_policy,omitempty"` + // System-generated timestamp indicating when the policy was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` +} + +type Function struct { + // The aliass of registered model. + Aliases []RegisteredModelAlias `json:"aliases,omitempty"` + // The comment of the function. + Comment *string `json:"comment,omitempty"` + // The data type of the function. + DataType ColumnTypeName `json:"data_type,omitempty"` + // The dependency list of the function. + DependencyList *DependencyList `json:"dependency_list,omitempty"` + // The full data type of the function. + FullDataType *string `json:"full_data_type,omitempty"` + // The id of the function. + Id *string `json:"id,omitempty"` + // The function parameter information. + InputParams *FunctionParameterInfos `json:"input_params,omitempty"` + // The name of the function. + Name *string `json:"name,omitempty"` + // The properties of the function. + Properties *string `json:"properties,omitempty"` + // The routine definition of the function. + RoutineDefinition *string `json:"routine_definition,omitempty"` + // The name of the schema that the function belongs to. + Schema *string `json:"schema,omitempty"` + // The securable kind of the function. + SecurableKind SharedSecurableKind `json:"securable_kind,omitempty"` + // The name of the share that the function belongs to. + Share *string `json:"share,omitempty"` + // The id of the share that the function belongs to. + ShareId *string `json:"share_id,omitempty"` + // The storage location of the function. + StorageLocation *string `json:"storage_location,omitempty"` + // The tags of the function. + Tags []TagKeyValue `json:"tags,omitempty"` +} + +// A Function in UC as a dependency.. +type FunctionDependency struct { + FunctionName *string `json:"function_name,omitempty"` + SchemaName *string `json:"schema_name,omitempty"` +} + +// Represents a parameter of a function. The same message is used for both input +// and output columns.. +type FunctionParameterInfo struct { + // The comment of the parameter. + Comment *string `json:"comment,omitempty"` + // The name of the parameter. + Name *string `json:"name,omitempty"` + // The default value of the parameter. + ParameterDefault *string `json:"parameter_default,omitempty"` + // The mode of the function parameter. + ParameterMode FunctionParameterMode `json:"parameter_mode,omitempty"` + // The type of the function parameter. + ParameterType FunctionParameterType `json:"parameter_type,omitempty"` + // The position of the parameter. + Position *int `json:"position,omitempty"` + // The interval type of the parameter type. + TypeIntervalType *string `json:"type_interval_type,omitempty"` + // The type of the parameter in JSON format. + TypeJson *string `json:"type_json,omitempty"` + // The type of the parameter in Enum format. + TypeName ColumnTypeName `json:"type_name,omitempty"` + // The precision of the parameter type. + TypePrecision *int `json:"type_precision,omitempty"` + // The scale of the parameter type. + TypeScale *int `json:"type_scale,omitempty"` + // The type of the parameter in text format. + TypeText *string `json:"type_text,omitempty"` +} + +type FunctionParameterInfos struct { + // The list of parameters of the function. + Parameters []FunctionParameterInfo `json:"parameters,omitempty"` +} + +type GetRecipientSharePermissionsResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // An array of data share permissions for a recipient. + PermissionsOut []ShareToPrivilegeAssignment `json:"permissions_out,omitempty"` +} + +type GetSharePermissionsResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // The privileges assigned to each principal + PrivilegeAssignments []PrivilegeAssignment `json:"privilege_assignments,omitempty"` +} + +type GetShareRequest struct { + // Query for data to include in the share. + IncludeSharedData *bool `json:"include_shared_data,omitempty"` + // The name of the share. + Name *string `json:"name,omitempty"` +} + +type IpAccessList struct { + // Allowed IP Addresses in CIDR notation. Limit of 100. + AllowedIpAddresses []string `json:"allowed_ip_addresses,omitempty"` +} + +type ListFederationPoliciesRequest struct { + MaxResults *int `json:"max_results,omitempty"` + PageToken *string `json:"page_token,omitempty"` + // Name of the recipient. This is the name of the recipient for which the + // policies are being listed. + RecipientName *string `json:"recipient_name,omitempty"` +} + +type ListFederationPoliciesResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + Policies []FederationPolicy `json:"policies,omitempty"` +} + +// Request to fetch the list of assets of a share that is shared with the +// recipient.. +type ListProviderShareAssetsRequest struct { + // Maximum number of functions to return. + FunctionMaxResults *int `json:"function_max_results,omitempty"` + // Maximum number of notebooks to return. + NotebookMaxResults *int `json:"notebook_max_results,omitempty"` + // The name of the provider who owns the share. + ProviderNameArg *string `json:"provider_name_arg,omitempty"` + // The name of the share. + ShareNameArg *string `json:"share_name_arg,omitempty"` + // Maximum number of tables to return. + TableMaxResults *int `json:"table_max_results,omitempty"` + // Maximum number of volumes to return. + VolumeMaxResults *int `json:"volume_max_results,omitempty"` +} + +// Response to ListProviderShareAssets, which contains the list of assets of a +// share.. +type ListProviderShareAssetsResponse struct { + // The list of functions in the share. + Functions []Function `json:"functions,omitempty"` + // The list of notebooks in the share. + Notebooks []NotebookFile `json:"notebooks,omitempty"` + // The metadata of the share. + Share *Share `json:"share,omitempty"` + // The list of tables in the share. + Tables []Table `json:"tables,omitempty"` + // The list of volumes in the share. + Volumes []Volume `json:"volumes,omitempty"` +} + +type ListProviderSharesRequest struct { + // Maximum number of shares to return. - when set to 0, the page length is set + // to a server configured value (recommended); - when set to a value greater + // than 0, the page length is the minimum of this value and a server configured + // value; - when set to a value less than 0, an invalid parameter error is + // returned; - If not set, all valid shares are returned (not recommended). - + // Note: The number of returned shares might be less than the specified + // max_results size, even zero. The only definitive indication that no further + // shares can be fetched is when the next_page_token is unset from the response. + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` + // Name of the provider in which to list shares. + ProviderNameArg *string `json:"provider_name_arg,omitempty"` +} + +type ListProviderSharesResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // An array of provider shares. + Shares []ProviderShare `json:"shares,omitempty"` +} + +type ListProvidersRequest struct { + // If not provided, all providers will be returned. If no providers exist with + // this ID, no results will be returned. + DataProviderGlobalMetastoreId *string `json:"data_provider_global_metastore_id,omitempty"` + // Maximum number of providers to return. - when set to 0, the page length is + // set to a server configured value (recommended); - when set to a value greater + // than 0, the page length is the minimum of this value and a server configured + // value; - when set to a value less than 0, an invalid parameter error is + // returned; - If not set, all valid providers are returned (not recommended). - + // Note: The number of returned providers might be less than the specified + // max_results size, even zero. The only definitive indication that no further + // providers can be fetched is when the next_page_token is unset from the + // response. + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListProvidersResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // An array of provider information objects. + Providers []ProviderInfo `json:"providers,omitempty"` +} + +type ListRecipientSharePermissionsRequest struct { + // Maximum number of permissions to return. - when set to 0, the page length is + // set to a server configured value (recommended); - when set to a value greater + // than 0, the page length is the minimum of this value and a server configured + // value; - when set to a value less than 0, an invalid parameter error is + // returned; - If not set, all valid permissions are returned (not recommended). + // - Note: The number of returned permissions might be less than the specified + // max_results size, even zero. The only definitive indication that no further + // permissions can be fetched is when the next_page_token is unset from the + // response. + MaxResults *int `json:"max_results,omitempty"` + // The name of the Recipient. + Name *string `json:"name,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListRecipientsRequest struct { + // If not provided, all recipients will be returned. If no recipients exist with + // this ID, no results will be returned. + DataRecipientGlobalMetastoreId *string `json:"data_recipient_global_metastore_id,omitempty"` + // Maximum number of recipients to return. - when set to 0, the page length is + // set to a server configured value (recommended); - when set to a value greater + // than 0, the page length is the minimum of this value and a server configured + // value; - when set to a value less than 0, an invalid parameter error is + // returned; - If not set, all valid recipients are returned (not recommended). + // - Note: The number of returned recipients might be less than the specified + // max_results size, even zero. The only definitive indication that no further + // recipients can be fetched is when the next_page_token is unset from the + // response. + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListRecipientsResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // An array of recipient information objects. + Recipients []RecipientInfo `json:"recipients,omitempty"` +} + +type ListSharePermissionsRequest struct { + // Maximum number of permissions to return. - when set to 0, the page length is + // set to a server configured value (recommended); - when set to a value greater + // than 0, the page length is the minimum of this value and a server configured + // value; - when set to a value less than 0, an invalid parameter error is + // returned; - If not set, all valid permissions are returned (not recommended). + // - Note: The number of returned permissions might be less than the specified + // max_results size, even zero. The only definitive indication that no further + // permissions can be fetched is when the next_page_token is unset from the + // response. + MaxResults *int `json:"max_results,omitempty"` + // The name of the share. + Name *string `json:"name,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListSharesRequest struct { + // Maximum number of shares to return. - when set to 0, the page length is set + // to a server configured value (recommended); - when set to a value greater + // than 0, the page length is the minimum of this value and a server configured + // value; - when set to a value less than 0, an invalid parameter error is + // returned; - If not set, all valid shares are returned (not recommended). - + // Note: The number of returned shares might be less than the specified + // max_results size, even zero. The only definitive indication that no further + // shares can be fetched is when the next_page_token is unset from the response. + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListSharesResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // An array of data share information objects. + Shares []ShareInfo `json:"shares,omitempty"` +} + +type NotebookFile struct { + // The comment of the notebook file. + Comment *string `json:"comment,omitempty"` + // The id of the notebook file. + Id *string `json:"id,omitempty"` + // Name of the notebook file. + Name *string `json:"name,omitempty"` + // The name of the share that the notebook file belongs to. + Share *string `json:"share,omitempty"` + // The id of the share that the notebook file belongs to. + ShareId *string `json:"share_id,omitempty"` + // The tags of the notebook file. + Tags []TagKeyValue `json:"tags,omitempty"` +} + +// Specifies the policy to use for validating OIDC claims in your federated +// tokens from Delta Sharing Clients. Refer to +// https://docs.databricks.com/en/delta-sharing/create-recipient-oidc-fed for +// more details.. +type OidcFederationPolicy struct { + // The allowed token audiences, as specified in the 'aud' claim of federated + // tokens. The audience identifier is intended to represent the recipient of the + // token. Can be any non-empty string value. As long as the audience in the + // token matches at least one audience in the policy, + Audiences []string `json:"audiences,omitempty"` + // The required token issuer, as specified in the 'iss' claim of federated + // tokens. + Issuer *string `json:"issuer,omitempty"` + // The required token subject, as specified in the subject claim of federated + // tokens. The subject claim identifies the identity of the user or machine + // accessing the resource. Examples for Entra ID (AAD): - U2M flow (group + // access): If the subject claim is `groups`, this must be the Object ID of the + // group in Entra ID. - U2M flow (user access): If the subject claim is `oid`, + // this must be the Object ID of the user in Entra ID. - M2M flow (OAuth App + // access): If the subject claim is `azp`, this must be the client ID of the + // OAuth app registered in Entra ID. + Subject *string `json:"subject,omitempty"` + // The claim that contains the subject of the token. Depending on the identity + // provider and the use case (U2M or M2M), this can vary: - For Entra ID (AAD): + // * U2M flow (group access): Use `groups`. * U2M flow (user access): Use `oid`. + // * M2M flow (OAuth App access): Use `azp`. - For other IdPs, refer to the + // specific IdP documentation. + // + // Supported `subject_claim` values are: - `oid`: Object ID of the user. - + // `azp`: Client ID of the OAuth app. - `groups`: Object ID of the group. - + // `sub`: Subject identifier for other use cases. + SubjectClaim *string `json:"subject_claim,omitempty"` +} + +type PartitionSpecification_Partition struct { + // An array of partition values. + Values []PartitionSpecification_Partition_PartitionValue `json:"values,omitempty"` +} + +type PartitionSpecification_Partition_PartitionValue struct { + // The name of the partition column. + Name *string `json:"name,omitempty"` + // The operator to apply for the value. + Op PartitionSpecification_Partition_PartitionValue_PartitionValueOp `json:"op,omitempty"` + // The key of a Delta Sharing recipient's property. For example + // "databricks-account-id". When this field is set, field `value` can not be + // set. + RecipientPropertyKey *string `json:"recipient_property_key,omitempty"` + // The value of the partition column. When this value is not set, it means + // `null` value. When this field is set, field `recipient_property_key` can not + // be set. + Value *string `json:"value,omitempty"` +} + +type PermissionsChange struct { + // The set of privileges to add. + Add []string `json:"add,omitempty"` + // The principal whose privileges we are changing. Only one of principal or + // principal_id should be specified, never both at the same time. + Principal *string `json:"principal,omitempty"` + // The set of privileges to remove. + Remove []string `json:"remove,omitempty"` +} + +type PrivilegeAssignment struct { + // The principal (user email address or group name). For deleted principals, + // `principal` is empty while `principal_id` is populated. + Principal *string `json:"principal,omitempty"` + // The privileges assigned to the principal. + Privileges []string `json:"privileges,omitempty"` +} + +// An object with __properties__ containing map of key-value properties attached +// to the securable.. +type PropertiesKvPairs struct { + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` +} + +type ProviderInfo struct { + AuthenticationType DeltaSharingAuthenticationType `json:"authentication_type,omitempty"` + // Cloud vendor of the provider's UC metastore. This field is only present when + // the __authentication_type__ is **DATABRICKS**. + Cloud *string `json:"cloud,omitempty"` + // Description about the provider. + Comment *string `json:"comment,omitempty"` + // Time at which this Provider was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of Provider creator. + CreatedBy *string `json:"created_by,omitempty"` + // The global UC metastore id of the data provider. This field is only present + // when the __authentication_type__ is **DATABRICKS**. The identifier is of + // format __cloud__:__region__:__metastore-uuid__. + DataProviderGlobalMetastoreId *string `json:"data_provider_global_metastore_id,omitempty"` + // UUID of the provider's UC metastore. This field is only present when the + // __authentication_type__ is **DATABRICKS**. + MetastoreId *string `json:"metastore_id,omitempty"` + // The name of the Provider. + Name *string `json:"name,omitempty"` + // Username of Provider owner. + Owner *string `json:"owner,omitempty"` + // The recipient profile. This field is only present when the + // authentication_type is `TOKEN` or `OAUTH_CLIENT_CREDENTIALS`. + RecipientProfile *RecipientProfile `json:"recipient_profile,omitempty"` + // This field is required when the __authentication_type__ is **TOKEN**, + // **OAUTH_CLIENT_CREDENTIALS** or not provided. + RecipientProfileStr *string `json:"recipient_profile_str,omitempty"` + // Cloud region of the provider's UC metastore. This field is only present when + // the __authentication_type__ is **DATABRICKS**. + Region *string `json:"region,omitempty"` + // Time at which this Provider was created, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified Provider. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type ProviderShare struct { + // The name of the Provider Share. + Name *string `json:"name,omitempty"` +} + +type RecipientInfo struct { + // A boolean status field showing whether the Recipient's activation URL has + // been exercised or not. + Activated *bool `json:"activated,omitempty"` + // Full activation url to retrieve the access token. It will be empty if the + // token is already retrieved. + ActivationUrl *string `json:"activation_url,omitempty"` + AuthenticationType DeltaSharingAuthenticationType `json:"authentication_type,omitempty"` + // Cloud vendor of the recipient's Unity Catalog Metastore. This field is only + // present when the __authentication_type__ is **DATABRICKS**. + Cloud *string `json:"cloud,omitempty"` + // Description about the recipient. + Comment *string `json:"comment,omitempty"` + // Time at which this recipient was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of recipient creator. + CreatedBy *string `json:"created_by,omitempty"` + // The global Unity Catalog metastore id provided by the data recipient. This + // field is only present when the __authentication_type__ is **DATABRICKS**. The + // identifier is of format __cloud__:__region__:__metastore-uuid__. + DataRecipientGlobalMetastoreId *string `json:"data_recipient_global_metastore_id,omitempty"` + // Expiration timestamp of the token, in epoch milliseconds. + ExpirationTime *int64 `json:"expiration_time,omitempty"` + // [Create,Update:IGN] common - id of the recipient + Id *string `json:"id,omitempty"` + // IP Access List + IpAccessList *IpAccessList `json:"ip_access_list,omitempty"` + // Unique identifier of recipient's Unity Catalog Metastore. This field is only + // present when the __authentication_type__ is **DATABRICKS**. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of Recipient. + Name *string `json:"name,omitempty"` + // Username of the recipient owner. + Owner *string `json:"owner,omitempty"` + // Recipient properties as map of string key-value pairs. When provided in + // update request, the specified properties will override the existing + // properties. To add and remove properties, one would need to perform a + // read-modify-write. + PropertiesKvpairs *PropertiesKvPairs `json:"properties_kvpairs,omitempty"` + // Cloud region of the recipient's Unity Catalog Metastore. This field is only + // present when the __authentication_type__ is **DATABRICKS**. + Region *string `json:"region,omitempty"` + // The one-time sharing code provided by the data recipient. This field is only + // present when the __authentication_type__ is **DATABRICKS**. + SharingCode *string `json:"sharing_code,omitempty"` + // This field is only present when the __authentication_type__ is **TOKEN**. + Tokens []RecipientTokenInfo `json:"tokens,omitempty"` + // Time at which the recipient was updated, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of recipient updater. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type RecipientProfile struct { + // The token used to authorize the recipient. + BearerToken *string `json:"bearer_token,omitempty"` + // The endpoint for the share to be used by the recipient. + Endpoint *string `json:"endpoint,omitempty"` + // The version number of the recipient's credentials on a share. + ShareCredentialsVersion *int `json:"share_credentials_version,omitempty"` +} + +type RecipientTokenInfo struct { + // Full activation URL to retrieve the access token. It will be empty if the + // token is already retrieved. + ActivationUrl *string `json:"activation_url,omitempty"` + // Time at which this recipient token was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of recipient token creator. + CreatedBy *string `json:"created_by,omitempty"` + // Expiration timestamp of the token in epoch milliseconds. + ExpirationTime *int64 `json:"expiration_time,omitempty"` + // Unique ID of the recipient token. + Id *string `json:"id,omitempty"` + // Time at which this recipient token was updated, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of recipient token updater. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type RegisteredModelAlias struct { + // Name of the alias. + AliasName *string `json:"alias_name,omitempty"` + // Numeric model version that alias will reference. + VersionNum *int64 `json:"version_num,omitempty"` +} + +// Configuration for Delta Sharing replication on a share. When enabled, the +// share's data is copied into each recipient's region so recipients can query +// the share locally.. +type ReplicationConfig struct { + // Whether replication is enabled for the share. + Enabled *bool `json:"enabled,omitempty"` +} + +type RetrieveTokenResponse struct { + // The token used to authorize the recipient. + BearerToken *string `json:"bearerToken,omitempty"` + // The endpoint for the share to be used by the recipient. + Endpoint *string `json:"endpoint,omitempty"` + // Expiration timestamp of the token in epoch milliseconds. + ExpirationTime *string `json:"expirationTime,omitempty"` + // These field names must follow the delta sharing protocol. + ShareCredentialsVersion *int `json:"shareCredentialsVersion,omitempty"` +} + +type RotateRecipientTokenRequest struct { + // The expiration time of the bearer token in ISO 8601 format. This will set the + // expiration_time of existing token only to a smaller timestamp, it cannot + // extend the expiration_time. Use 0 to expire the existing token immediately, + // negative number will return an error. + ExistingTokenExpireInSeconds *int64 `json:"existing_token_expire_in_seconds,omitempty"` + // The name of the Recipient. + Name *string `json:"name,omitempty"` +} + +type Share struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +type ShareInfo struct { + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this share was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of share creator. + CreatedBy *string `json:"created_by,omitempty"` + // Name of the share. + Name *string `json:"name,omitempty"` + // A list of shared data objects within the share. + Objects []SharedDataObject `json:"objects,omitempty"` + // Username of current owner of share. + Owner *string `json:"owner,omitempty"` + // Configuration for share replication. + ReplicationConfig *ReplicationConfig `json:"replication_config,omitempty"` + // Storage Location URL (full path) for the share. + StorageLocation *string `json:"storage_location,omitempty"` + // Storage root URL for the share. + StorageRoot *string `json:"storage_root,omitempty"` + // Time at which this share was updated, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of share updater. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type ShareToPrivilegeAssignment struct { + // The privileges assigned to the principal. + PrivilegeAssignments []PrivilegeAssignment `json:"privilege_assignments,omitempty"` + // The share name. + ShareName *string `json:"share_name,omitempty"` +} + +type SharedDataObject struct { + // The time when this data object is added to the share, in epoch milliseconds. + AddedAt *int64 `json:"added_at,omitempty"` + // Username of the sharer. + AddedBy *string `json:"added_by,omitempty"` + // Whether to enable cdf or indicate if cdf is enabled on the shared object. + CdfEnabled *bool `json:"cdf_enabled,omitempty"` + // A user-provided comment when adding the data object to the share. + Comment *string `json:"comment,omitempty"` + // The content of the notebook file when the data object type is NOTEBOOK_FILE. + // This should be base64 encoded. Required for adding a NOTEBOOK_FILE, optional + // for updating, ignored for other types. + Content *string `json:"content,omitempty"` + // The type of the data object. + DataObjectType *string `json:"data_object_type,omitempty"` + // Whether to enable or disable sharing of data history. If not specified, the + // default is **DISABLED**. + HistoryDataSharingStatus SharedDataObject_HistoryDataSharingStatus_Enum `json:"history_data_sharing_status,omitempty"` + // A fully qualified name that uniquely identifies a data object. For example, a + // table's fully qualified name is in the format of + // `..`, + Name *string `json:"name,omitempty"` + // Array of partitions for the shared data. + Partitions []PartitionSpecification_Partition `json:"partitions,omitempty"` + // A user-provided alias name for table-like data objects within the share. + // + // Use this field for table-like objects (for example: TABLE, VIEW, + // MATERIALIZED_VIEW, STREAMING_TABLE, FOREIGN_TABLE). For non-table objects + // (for example: VOLUME, MODEL, NOTEBOOK_FILE, FUNCTION), use `string_shared_as` + // instead. + // + // Important: For non-table objects, this field must be omitted entirely. + // + // Format: Must be a 2-part name `.` (e.g., + // "sales_schema.orders_table") - Both schema and table names must contain only + // alphanumeric characters and underscores - No periods, spaces, forward + // slashes, or control characters are allowed within each part - Do not include + // the catalog name (use 2 parts, not 3) + // + // Behavior: - If not provided, the service automatically generates the alias as + // `.
` from the object's original name - If you don't want to + // specify this field, omit it entirely from the request (do not pass an empty + // string) - The `shared_as` name must be unique within the share + // + // Examples: - Valid: "analytics_schema.customer_view" - Invalid: + // "catalog.analytics_schema.customer_view" (3 parts not allowed) - Invalid: + // "analytics-schema.customer-view" (hyphens not allowed) + SharedAs *string `json:"shared_as,omitempty"` + // The start version associated with the object. This allows data providers to + // control the lowest object version that is accessible by clients. If + // specified, clients can query snapshots or changes for versions >= + // start_version. If not specified, clients can only query starting from the + // version of the object at the time it was added to the share. + // + // NOTE: The start_version should be <= the `current` version of the object. + StartVersion *int64 `json:"start_version,omitempty"` + // One of: **ACTIVE**, **PERMISSION_DENIED**. + Status SharedDataObject_Status_Enum `json:"status,omitempty"` + // A user-provided alias name for non-table data objects within the share. + // + // Use this field for non-table objects (for example: VOLUME, MODEL, + // NOTEBOOK_FILE, FUNCTION). For table-like objects (for example: TABLE, VIEW, + // MATERIALIZED_VIEW, STREAMING_TABLE, FOREIGN_TABLE), use `shared_as` instead. + // + // Important: For table-like objects, this field must be omitted entirely. + // + // Format: - For VOLUME: Must be a 2-part name `.` + // (e.g., "data_schema.ml_models") - For FUNCTION: Must be a 2-part name + // `.` (e.g., "udf_schema.calculate_tax") - For + // MODEL: Must be a 2-part name `.` (e.g., + // "models.prediction_model") - For NOTEBOOK_FILE: Should be the notebook file + // name (e.g., "analysis_notebook.py") - All names must contain only + // alphanumeric characters and underscores - No periods, spaces, forward + // slashes, or control characters are allowed within each part + // + // Behavior: - If not provided, the service automatically generates the alias + // from the object's original name - If you don't want to specify this field, + // omit it entirely from the request (do not pass an empty string) - The + // `string_shared_as` name must be unique for objects of the same type within + // the share + // + // Examples: - Valid for VOLUME: "data_schema.training_data" - Valid for + // FUNCTION: "analytics.calculate_revenue" - Invalid: + // "catalog.data_schema.training_data" (3 parts not allowed for volumes) - + // Invalid: "data-schema.training-data" (hyphens not allowed) + StringSharedAs *string `json:"string_shared_as,omitempty"` +} + +type Table struct { + // The comment of the table. + Comment *string `json:"comment,omitempty"` + // The id of the table. + Id *string `json:"id,omitempty"` + // The catalog and schema of the materialized table + MaterializationNamespace *string `json:"materialization_namespace,omitempty"` + // The name of a materialized table. + MaterializedTableName *string `json:"materialized_table_name,omitempty"` + // The name of the table. + Name *string `json:"name,omitempty"` + // The name of the schema that the table belongs to. + Schema *string `json:"schema,omitempty"` + // The name of the share that the table belongs to. + Share *string `json:"share,omitempty"` + // The id of the share that the table belongs to. + ShareId *string `json:"share_id,omitempty"` + // The Tags of the table. + Tags []TagKeyValue `json:"tags,omitempty"` +} + +// A Table in UC as a dependency.. +type TableDependency struct { + SchemaName *string `json:"schema_name,omitempty"` + TableName *string `json:"table_name,omitempty"` +} + +type TagKeyValue struct { + // name of the tag + Key *string `json:"key,omitempty"` + // value of the tag associated with the key, could be optional + Value *string `json:"value,omitempty"` +} + +type UpdateProviderRequest struct { + AuthenticationType DeltaSharingAuthenticationType `json:"authentication_type,omitempty"` + // Cloud vendor of the provider's UC metastore. This field is only present when + // the __authentication_type__ is **DATABRICKS**. + Cloud *string `json:"cloud,omitempty"` + // Description about the provider. + Comment *string `json:"comment,omitempty"` + // Time at which this Provider was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of Provider creator. + CreatedBy *string `json:"created_by,omitempty"` + // The global UC metastore id of the data provider. This field is only present + // when the __authentication_type__ is **DATABRICKS**. The identifier is of + // format __cloud__:__region__:__metastore-uuid__. + DataProviderGlobalMetastoreId *string `json:"data_provider_global_metastore_id,omitempty"` + // UUID of the provider's UC metastore. This field is only present when the + // __authentication_type__ is **DATABRICKS**. + MetastoreId *string `json:"metastore_id,omitempty"` + // The name of the Provider. + Name *string `json:"name,omitempty"` + // Name of the provider. + NameArg *string `json:"name_arg,omitempty"` + // New name for the provider. + NewName *string `json:"new_name,omitempty"` + // Username of Provider owner. + Owner *string `json:"owner,omitempty"` + // The recipient profile. This field is only present when the + // authentication_type is `TOKEN` or `OAUTH_CLIENT_CREDENTIALS`. + RecipientProfile *RecipientProfile `json:"recipient_profile,omitempty"` + // This field is required when the __authentication_type__ is **TOKEN**, + // **OAUTH_CLIENT_CREDENTIALS** or not provided. + RecipientProfileStr *string `json:"recipient_profile_str,omitempty"` + // Cloud region of the provider's UC metastore. This field is only present when + // the __authentication_type__ is **DATABRICKS**. + Region *string `json:"region,omitempty"` + // Time at which this Provider was created, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified Provider. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type UpdateRecipientRequest struct { + // A boolean status field showing whether the Recipient's activation URL has + // been exercised or not. + Activated *bool `json:"activated,omitempty"` + // Full activation url to retrieve the access token. It will be empty if the + // token is already retrieved. + ActivationUrl *string `json:"activation_url,omitempty"` + AuthenticationType DeltaSharingAuthenticationType `json:"authentication_type,omitempty"` + // Cloud vendor of the recipient's Unity Catalog Metastore. This field is only + // present when the __authentication_type__ is **DATABRICKS**. + Cloud *string `json:"cloud,omitempty"` + // Description about the recipient. + Comment *string `json:"comment,omitempty"` + // Time at which this recipient was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of recipient creator. + CreatedBy *string `json:"created_by,omitempty"` + // The global Unity Catalog metastore id provided by the data recipient. This + // field is only present when the __authentication_type__ is **DATABRICKS**. The + // identifier is of format __cloud__:__region__:__metastore-uuid__. + DataRecipientGlobalMetastoreId *string `json:"data_recipient_global_metastore_id,omitempty"` + // Expiration timestamp of the token, in epoch milliseconds. + ExpirationTime *int64 `json:"expiration_time,omitempty"` + // [Create,Update:IGN] common - id of the recipient + Id *string `json:"id,omitempty"` + // IP Access List + IpAccessList *IpAccessList `json:"ip_access_list,omitempty"` + // Unique identifier of recipient's Unity Catalog Metastore. This field is only + // present when the __authentication_type__ is **DATABRICKS**. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of Recipient. + Name *string `json:"name,omitempty"` + // Name of the recipient. + NameArg *string `json:"name_arg,omitempty"` + // New name for the recipient. . + NewName *string `json:"new_name,omitempty"` + // Username of the recipient owner. + Owner *string `json:"owner,omitempty"` + // Recipient properties as map of string key-value pairs. When provided in + // update request, the specified properties will override the existing + // properties. To add and remove properties, one would need to perform a + // read-modify-write. + PropertiesKvpairs *PropertiesKvPairs `json:"properties_kvpairs,omitempty"` + // Cloud region of the recipient's Unity Catalog Metastore. This field is only + // present when the __authentication_type__ is **DATABRICKS**. + Region *string `json:"region,omitempty"` + // The one-time sharing code provided by the data recipient. This field is only + // present when the __authentication_type__ is **DATABRICKS**. + SharingCode *string `json:"sharing_code,omitempty"` + // This field is only present when the __authentication_type__ is **TOKEN**. + Tokens []RecipientTokenInfo `json:"tokens,omitempty"` + // Time at which the recipient was updated, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of recipient updater. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type UpdateSharePermissionsRequest struct { + // Array of permissions change objects. + Changes []PermissionsChange `json:"changes,omitempty"` + // The name of the share. + Name *string `json:"name,omitempty"` + // Optional. Whether to return the latest permissions list of the share in the + // response. + OmitPermissionsList *bool `json:"omit_permissions_list,omitempty"` +} + +type UpdateSharePermissionsResponse struct { + // The privileges assigned to each principal + PrivilegeAssignments []PrivilegeAssignment `json:"privilege_assignments,omitempty"` +} + +type UpdateShareRequest struct { + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this share was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of share creator. + CreatedBy *string `json:"created_by,omitempty"` + // Name of the share. + Name *string `json:"name,omitempty"` + // The name of the share. + NameArg *string `json:"name_arg,omitempty"` + // New name for the share. + NewName *string `json:"new_name,omitempty"` + // A list of shared data objects within the share. + Objects []SharedDataObject `json:"objects,omitempty"` + // Username of current owner of share. + Owner *string `json:"owner,omitempty"` + // Configuration for share replication. + ReplicationConfig *ReplicationConfig `json:"replication_config,omitempty"` + // Storage Location URL (full path) for the share. + StorageLocation *string `json:"storage_location,omitempty"` + // Storage root URL for the share. + StorageRoot *string `json:"storage_root,omitempty"` + // Time at which this share was updated, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of share updater. + UpdatedBy *string `json:"updated_by,omitempty"` + // Array of shared data object updates. + Updates []UpdateShareRequest_SharedDataObjectUpdate `json:"updates,omitempty"` +} + +type UpdateShareRequest_SharedDataObjectUpdate struct { + // One of: **ADD**, **REMOVE**, **UPDATE**. + Action UpdateShareRequest_SharedDataObjectUpdate_Action `json:"action,omitempty"` + // The data object that is being added, removed, or updated. The maximum number + // update data objects allowed is a 100. + DataObject *SharedDataObject `json:"data_object,omitempty"` +} + +type Volume struct { + // The comment of the volume. + Comment *string `json:"comment,omitempty"` + // This id maps to the shared_volume_id in database Recipient needs + // shared_volume_id for recon to check if this volume is already in recipient's + // DB or not. + Id *string `json:"id,omitempty"` + // The name of the volume. + Name *string `json:"name,omitempty"` + // The name of the schema that the volume belongs to. + Schema *string `json:"schema,omitempty"` + // The name of the share that the volume belongs to. + Share *string `json:"share,omitempty"` + // / The id of the share that the volume belongs to. + ShareId *string `json:"share_id,omitempty"` + // The tags of the volume. + Tags []TagKeyValue `json:"tags,omitempty"` +} + +// CreateFederationPolicyRequestToSDK converts the mirror to the sdk-go type. +func CreateFederationPolicyRequestToSDK(w *CreateFederationPolicyRequest) (*sdk.CreateFederationPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateFederationPolicyRequest{} + out.RecipientName = w.RecipientName + conv1, err := FederationPolicyToSDK(w.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFederationPolicyRequest.Policy", err) + } + out.Policy = conv1 + return out, nil +} + +// CreateFederationPolicyRequestFromSDK converts the sdk-go type to the mirror. +func CreateFederationPolicyRequestFromSDK(v *sdk.CreateFederationPolicyRequest) (*CreateFederationPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateFederationPolicyRequest{} + out.RecipientName = v.RecipientName + conv2, err := FederationPolicyFromSDK(v.Policy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFederationPolicyRequest.Policy", err) + } + out.Policy = conv2 + return out, nil +} + +// CreateProviderRequestToSDK converts the mirror to the sdk-go type. +func CreateProviderRequestToSDK(w *CreateProviderRequest) (*sdk.CreateProviderRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateProviderRequest{} + out.Name = w.Name + out.AuthenticationType = w.AuthenticationType + out.RecipientProfileStr = w.RecipientProfileStr + out.Comment = w.Comment + out.Owner = w.Owner + conv3, err := RecipientProfileToSDK(w.RecipientProfile) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateProviderRequest.RecipientProfile", err) + } + out.RecipientProfile = conv3 + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.Cloud = w.Cloud + out.Region = w.Region + out.MetastoreId = w.MetastoreId + out.DataProviderGlobalMetastoreId = w.DataProviderGlobalMetastoreId + return out, nil +} + +// CreateProviderRequestFromSDK converts the sdk-go type to the mirror. +func CreateProviderRequestFromSDK(v *sdk.CreateProviderRequest) (*CreateProviderRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateProviderRequest{} + out.Name = v.Name + out.AuthenticationType = v.AuthenticationType + out.RecipientProfileStr = v.RecipientProfileStr + out.Comment = v.Comment + out.Owner = v.Owner + conv4, err := RecipientProfileFromSDK(v.RecipientProfile) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateProviderRequest.RecipientProfile", err) + } + out.RecipientProfile = conv4 + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.Cloud = v.Cloud + out.Region = v.Region + out.MetastoreId = v.MetastoreId + out.DataProviderGlobalMetastoreId = v.DataProviderGlobalMetastoreId + return out, nil +} + +// CreateRecipientRequestToSDK converts the mirror to the sdk-go type. +func CreateRecipientRequestToSDK(w *CreateRecipientRequest) (*sdk.CreateRecipientRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRecipientRequest{} + out.Name = w.Name + out.AuthenticationType = w.AuthenticationType + out.SharingCode = w.SharingCode + out.DataRecipientGlobalMetastoreId = w.DataRecipientGlobalMetastoreId + out.Owner = w.Owner + out.Comment = w.Comment + conv5, err := IpAccessListToSDK(w.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRecipientRequest.IpAccessList", err) + } + out.IpAccessList = conv5 + conv6, err := PropertiesKvPairsToSDK(w.PropertiesKvpairs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRecipientRequest.PropertiesKvpairs", err) + } + out.PropertiesKvpairs = conv6 + out.ExpirationTime = w.ExpirationTime + out.ActivationUrl = w.ActivationUrl + out.Activated = w.Activated + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + conv7, err := convertSlice(w.Tokens, RecipientTokenInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRecipientRequest.Tokens", err) + } + out.Tokens = conv7 + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.Cloud = w.Cloud + out.Region = w.Region + out.MetastoreId = w.MetastoreId + out.Id = w.Id + return out, nil +} + +// CreateRecipientRequestFromSDK converts the sdk-go type to the mirror. +func CreateRecipientRequestFromSDK(v *sdk.CreateRecipientRequest) (*CreateRecipientRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateRecipientRequest{} + out.Name = v.Name + out.AuthenticationType = v.AuthenticationType + out.SharingCode = v.SharingCode + out.DataRecipientGlobalMetastoreId = v.DataRecipientGlobalMetastoreId + out.Owner = v.Owner + out.Comment = v.Comment + conv8, err := IpAccessListFromSDK(v.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRecipientRequest.IpAccessList", err) + } + out.IpAccessList = conv8 + conv9, err := PropertiesKvPairsFromSDK(v.PropertiesKvpairs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRecipientRequest.PropertiesKvpairs", err) + } + out.PropertiesKvpairs = conv9 + out.ExpirationTime = v.ExpirationTime + out.ActivationUrl = v.ActivationUrl + out.Activated = v.Activated + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + conv10, err := convertSlice(v.Tokens, RecipientTokenInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRecipientRequest.Tokens", err) + } + out.Tokens = conv10 + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.Cloud = v.Cloud + out.Region = v.Region + out.MetastoreId = v.MetastoreId + out.Id = v.Id + return out, nil +} + +// CreateShareRequestToSDK converts the mirror to the sdk-go type. +func CreateShareRequestToSDK(w *CreateShareRequest) (*sdk.CreateShareRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateShareRequest{} + out.Name = w.Name + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageRoot = w.StorageRoot + conv11, err := ReplicationConfigToSDK(w.ReplicationConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateShareRequest.ReplicationConfig", err) + } + out.ReplicationConfig = conv11 + conv12, err := convertSlice(w.Objects, SharedDataObjectToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateShareRequest.Objects", err) + } + out.Objects = conv12 + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.StorageLocation = w.StorageLocation + return out, nil +} + +// CreateShareRequestFromSDK converts the sdk-go type to the mirror. +func CreateShareRequestFromSDK(v *sdk.CreateShareRequest) (*CreateShareRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateShareRequest{} + out.Name = v.Name + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageRoot = v.StorageRoot + conv13, err := ReplicationConfigFromSDK(v.ReplicationConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateShareRequest.ReplicationConfig", err) + } + out.ReplicationConfig = conv13 + conv14, err := convertSlice(v.Objects, SharedDataObjectFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateShareRequest.Objects", err) + } + out.Objects = conv14 + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.StorageLocation = v.StorageLocation + return out, nil +} + +// DependencyToSDK converts the mirror to the sdk-go type. +func DependencyToSDK(w *Dependency) (*sdk.Dependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.Dependency{} + { + var members []string + if w.Table != nil { + members = append(members, "table") + } + if w.Function != nil { + members = append(members, "function") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Table != nil: + conv15, err := TableDependencyToSDK(w.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Table{Table: *conv15} + case w.Function != nil: + conv16, err := FunctionDependencyToSDK(w.Function) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Function{Function: *conv16} + } + return out, nil +} + +// DependencyFromSDK converts the sdk-go type to the mirror. +func DependencyFromSDK(v *sdk.Dependency) (*Dependency, error) { + if v == nil { + return nil, nil + } + out := &Dependency{} + switch value := v.Value.(type) { + case *sdk.Dependency_Value_Table: + if value != nil { + conv17, err := TableDependencyFromSDK(&value.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Table = conv17 + } + case *sdk.Dependency_Value_Function: + if value != nil { + conv18, err := FunctionDependencyFromSDK(&value.Function) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Function = conv18 + } + } + return out, nil +} + +// DependencyListToSDK converts the mirror to the sdk-go type. +func DependencyListToSDK(w *DependencyList) (*sdk.DependencyList, error) { + if w == nil { + return nil, nil + } + out := &sdk.DependencyList{} + conv19, err := convertSlice(w.Dependencies, DependencyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DependencyList.Dependencies", err) + } + out.Dependencies = conv19 + return out, nil +} + +// DependencyListFromSDK converts the sdk-go type to the mirror. +func DependencyListFromSDK(v *sdk.DependencyList) (*DependencyList, error) { + if v == nil { + return nil, nil + } + out := &DependencyList{} + conv20, err := convertSlice(v.Dependencies, DependencyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DependencyList.Dependencies", err) + } + out.Dependencies = conv20 + return out, nil +} + +// FederationPolicyToSDK converts the mirror to the sdk-go type. +func FederationPolicyToSDK(w *FederationPolicy) (*sdk.FederationPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.FederationPolicy{} + out.Name = w.Name + { + var members []string + if w.OidcPolicy != nil { + members = append(members, "oidc_policy") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.OidcPolicy != nil: + conv21, err := OidcFederationPolicyToSDK(w.OidcPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FederationPolicy.Policy", err) + } + out.Policy = &sdk.FederationPolicy_Policy_OidcPolicy{OidcPolicy: *conv21} + } + out.CreateTime = w.CreateTime + out.Comment = w.Comment + out.UpdateTime = w.UpdateTime + out.Id = w.Id + return out, nil +} + +// FederationPolicyFromSDK converts the sdk-go type to the mirror. +func FederationPolicyFromSDK(v *sdk.FederationPolicy) (*FederationPolicy, error) { + if v == nil { + return nil, nil + } + out := &FederationPolicy{} + out.Name = v.Name + switch value := v.Policy.(type) { + case *sdk.FederationPolicy_Policy_OidcPolicy: + if value != nil { + conv22, err := OidcFederationPolicyFromSDK(&value.OidcPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FederationPolicy.Policy", err) + } + out.OidcPolicy = conv22 + } + } + out.CreateTime = v.CreateTime + out.Comment = v.Comment + out.UpdateTime = v.UpdateTime + out.Id = v.Id + return out, nil +} + +// FunctionToSDK converts the mirror to the sdk-go type. +func FunctionToSDK(w *Function) (*sdk.Function, error) { + if w == nil { + return nil, nil + } + out := &sdk.Function{} + out.Name = w.Name + out.Schema = w.Schema + out.Share = w.Share + out.ShareId = w.ShareId + out.Id = w.Id + out.StorageLocation = w.StorageLocation + out.Comment = w.Comment + conv23, err := convertSlice(w.Aliases, RegisteredModelAliasToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.Aliases", err) + } + out.Aliases = conv23 + conv24, err := convertSlice(w.Tags, TagKeyValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.Tags", err) + } + out.Tags = conv24 + out.SecurableKind = w.SecurableKind + out.FullDataType = w.FullDataType + out.DataType = w.DataType + out.RoutineDefinition = w.RoutineDefinition + conv25, err := FunctionParameterInfosToSDK(w.InputParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.InputParams", err) + } + out.InputParams = conv25 + conv26, err := DependencyListToSDK(w.DependencyList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.DependencyList", err) + } + out.DependencyList = conv26 + out.Properties = w.Properties + return out, nil +} + +// FunctionFromSDK converts the sdk-go type to the mirror. +func FunctionFromSDK(v *sdk.Function) (*Function, error) { + if v == nil { + return nil, nil + } + out := &Function{} + out.Name = v.Name + out.Schema = v.Schema + out.Share = v.Share + out.ShareId = v.ShareId + out.Id = v.Id + out.StorageLocation = v.StorageLocation + out.Comment = v.Comment + conv27, err := convertSlice(v.Aliases, RegisteredModelAliasFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.Aliases", err) + } + out.Aliases = conv27 + conv28, err := convertSlice(v.Tags, TagKeyValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.Tags", err) + } + out.Tags = conv28 + out.SecurableKind = v.SecurableKind + out.FullDataType = v.FullDataType + out.DataType = v.DataType + out.RoutineDefinition = v.RoutineDefinition + conv29, err := FunctionParameterInfosFromSDK(v.InputParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.InputParams", err) + } + out.InputParams = conv29 + conv30, err := DependencyListFromSDK(v.DependencyList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Function.DependencyList", err) + } + out.DependencyList = conv30 + out.Properties = v.Properties + return out, nil +} + +// FunctionDependencyToSDK converts the mirror to the sdk-go type. +func FunctionDependencyToSDK(w *FunctionDependency) (*sdk.FunctionDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.FunctionDependency{} + out.SchemaName = w.SchemaName + out.FunctionName = w.FunctionName + return out, nil +} + +// FunctionDependencyFromSDK converts the sdk-go type to the mirror. +func FunctionDependencyFromSDK(v *sdk.FunctionDependency) (*FunctionDependency, error) { + if v == nil { + return nil, nil + } + out := &FunctionDependency{} + out.SchemaName = v.SchemaName + out.FunctionName = v.FunctionName + return out, nil +} + +// FunctionParameterInfoToSDK converts the mirror to the sdk-go type. +func FunctionParameterInfoToSDK(w *FunctionParameterInfo) (*sdk.FunctionParameterInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.FunctionParameterInfo{} + out.Name = w.Name + out.TypeText = w.TypeText + out.TypeJson = w.TypeJson + out.TypeName = w.TypeName + out.TypePrecision = w.TypePrecision + out.TypeScale = w.TypeScale + out.TypeIntervalType = w.TypeIntervalType + out.Position = w.Position + out.ParameterMode = w.ParameterMode + out.ParameterType = w.ParameterType + out.ParameterDefault = w.ParameterDefault + out.Comment = w.Comment + return out, nil +} + +// FunctionParameterInfoFromSDK converts the sdk-go type to the mirror. +func FunctionParameterInfoFromSDK(v *sdk.FunctionParameterInfo) (*FunctionParameterInfo, error) { + if v == nil { + return nil, nil + } + out := &FunctionParameterInfo{} + out.Name = v.Name + out.TypeText = v.TypeText + out.TypeJson = v.TypeJson + out.TypeName = v.TypeName + out.TypePrecision = v.TypePrecision + out.TypeScale = v.TypeScale + out.TypeIntervalType = v.TypeIntervalType + out.Position = v.Position + out.ParameterMode = v.ParameterMode + out.ParameterType = v.ParameterType + out.ParameterDefault = v.ParameterDefault + out.Comment = v.Comment + return out, nil +} + +// FunctionParameterInfosToSDK converts the mirror to the sdk-go type. +func FunctionParameterInfosToSDK(w *FunctionParameterInfos) (*sdk.FunctionParameterInfos, error) { + if w == nil { + return nil, nil + } + out := &sdk.FunctionParameterInfos{} + conv31, err := convertSlice(w.Parameters, FunctionParameterInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionParameterInfos.Parameters", err) + } + out.Parameters = conv31 + return out, nil +} + +// FunctionParameterInfosFromSDK converts the sdk-go type to the mirror. +func FunctionParameterInfosFromSDK(v *sdk.FunctionParameterInfos) (*FunctionParameterInfos, error) { + if v == nil { + return nil, nil + } + out := &FunctionParameterInfos{} + conv32, err := convertSlice(v.Parameters, FunctionParameterInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionParameterInfos.Parameters", err) + } + out.Parameters = conv32 + return out, nil +} + +// GetRecipientSharePermissionsResponseToSDK converts the mirror to the sdk-go type. +func GetRecipientSharePermissionsResponseToSDK(w *GetRecipientSharePermissionsResponse) (*sdk.GetRecipientSharePermissionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetRecipientSharePermissionsResponse{} + conv33, err := convertSlice(w.PermissionsOut, ShareToPrivilegeAssignmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRecipientSharePermissionsResponse.PermissionsOut", err) + } + out.PermissionsOut = conv33 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GetRecipientSharePermissionsResponseFromSDK converts the sdk-go type to the mirror. +func GetRecipientSharePermissionsResponseFromSDK(v *sdk.GetRecipientSharePermissionsResponse) (*GetRecipientSharePermissionsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetRecipientSharePermissionsResponse{} + conv34, err := convertSlice(v.PermissionsOut, ShareToPrivilegeAssignmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetRecipientSharePermissionsResponse.PermissionsOut", err) + } + out.PermissionsOut = conv34 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// GetSharePermissionsResponseToSDK converts the mirror to the sdk-go type. +func GetSharePermissionsResponseToSDK(w *GetSharePermissionsResponse) (*sdk.GetSharePermissionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetSharePermissionsResponse{} + out.NextPageToken = w.NextPageToken + conv35, err := convertSlice(w.PrivilegeAssignments, PrivilegeAssignmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetSharePermissionsResponse.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv35 + return out, nil +} + +// GetSharePermissionsResponseFromSDK converts the sdk-go type to the mirror. +func GetSharePermissionsResponseFromSDK(v *sdk.GetSharePermissionsResponse) (*GetSharePermissionsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetSharePermissionsResponse{} + out.NextPageToken = v.NextPageToken + conv36, err := convertSlice(v.PrivilegeAssignments, PrivilegeAssignmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetSharePermissionsResponse.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv36 + return out, nil +} + +// GetShareRequestToSDK converts the mirror to the sdk-go type. +func GetShareRequestToSDK(w *GetShareRequest) (*sdk.GetShareRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetShareRequest{} + out.Name = w.Name + out.IncludeSharedData = w.IncludeSharedData + return out, nil +} + +// GetShareRequestFromSDK converts the sdk-go type to the mirror. +func GetShareRequestFromSDK(v *sdk.GetShareRequest) (*GetShareRequest, error) { + if v == nil { + return nil, nil + } + out := &GetShareRequest{} + out.Name = v.Name + out.IncludeSharedData = v.IncludeSharedData + return out, nil +} + +// IpAccessListToSDK converts the mirror to the sdk-go type. +func IpAccessListToSDK(w *IpAccessList) (*sdk.IpAccessList, error) { + if w == nil { + return nil, nil + } + out := &sdk.IpAccessList{} + out.AllowedIpAddresses = w.AllowedIpAddresses + return out, nil +} + +// IpAccessListFromSDK converts the sdk-go type to the mirror. +func IpAccessListFromSDK(v *sdk.IpAccessList) (*IpAccessList, error) { + if v == nil { + return nil, nil + } + out := &IpAccessList{} + out.AllowedIpAddresses = v.AllowedIpAddresses + return out, nil +} + +// ListFederationPoliciesRequestToSDK converts the mirror to the sdk-go type. +func ListFederationPoliciesRequestToSDK(w *ListFederationPoliciesRequest) (*sdk.ListFederationPoliciesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListFederationPoliciesRequest{} + out.RecipientName = w.RecipientName + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListFederationPoliciesRequestFromSDK converts the sdk-go type to the mirror. +func ListFederationPoliciesRequestFromSDK(v *sdk.ListFederationPoliciesRequest) (*ListFederationPoliciesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListFederationPoliciesRequest{} + out.RecipientName = v.RecipientName + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListFederationPoliciesResponseToSDK converts the mirror to the sdk-go type. +func ListFederationPoliciesResponseToSDK(w *ListFederationPoliciesResponse) (*sdk.ListFederationPoliciesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListFederationPoliciesResponse{} + conv37, err := convertSlice(w.Policies, FederationPolicyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFederationPoliciesResponse.Policies", err) + } + out.Policies = conv37 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListFederationPoliciesResponseFromSDK converts the sdk-go type to the mirror. +func ListFederationPoliciesResponseFromSDK(v *sdk.ListFederationPoliciesResponse) (*ListFederationPoliciesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListFederationPoliciesResponse{} + conv38, err := convertSlice(v.Policies, FederationPolicyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFederationPoliciesResponse.Policies", err) + } + out.Policies = conv38 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListProviderShareAssetsRequestToSDK converts the mirror to the sdk-go type. +func ListProviderShareAssetsRequestToSDK(w *ListProviderShareAssetsRequest) (*sdk.ListProviderShareAssetsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListProviderShareAssetsRequest{} + out.ProviderNameArg = w.ProviderNameArg + out.ShareNameArg = w.ShareNameArg + out.TableMaxResults = w.TableMaxResults + out.FunctionMaxResults = w.FunctionMaxResults + out.VolumeMaxResults = w.VolumeMaxResults + out.NotebookMaxResults = w.NotebookMaxResults + return out, nil +} + +// ListProviderShareAssetsRequestFromSDK converts the sdk-go type to the mirror. +func ListProviderShareAssetsRequestFromSDK(v *sdk.ListProviderShareAssetsRequest) (*ListProviderShareAssetsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListProviderShareAssetsRequest{} + out.ProviderNameArg = v.ProviderNameArg + out.ShareNameArg = v.ShareNameArg + out.TableMaxResults = v.TableMaxResults + out.FunctionMaxResults = v.FunctionMaxResults + out.VolumeMaxResults = v.VolumeMaxResults + out.NotebookMaxResults = v.NotebookMaxResults + return out, nil +} + +// ListProviderShareAssetsResponseToSDK converts the mirror to the sdk-go type. +func ListProviderShareAssetsResponseToSDK(w *ListProviderShareAssetsResponse) (*sdk.ListProviderShareAssetsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListProviderShareAssetsResponse{} + conv39, err := convertSlice(w.Tables, TableToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProviderShareAssetsResponse.Tables", err) + } + out.Tables = conv39 + conv40, err := convertSlice(w.Functions, FunctionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProviderShareAssetsResponse.Functions", err) + } + out.Functions = conv40 + conv41, err := convertSlice(w.Notebooks, NotebookFileToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProviderShareAssetsResponse.Notebooks", err) + } + out.Notebooks = conv41 + conv42, err := convertSlice(w.Volumes, VolumeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProviderShareAssetsResponse.Volumes", err) + } + out.Volumes = conv42 + conv43, err := ShareToSDK(w.Share) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProviderShareAssetsResponse.Share", err) + } + out.Share = conv43 + return out, nil +} + +// ListProviderShareAssetsResponseFromSDK converts the sdk-go type to the mirror. +func ListProviderShareAssetsResponseFromSDK(v *sdk.ListProviderShareAssetsResponse) (*ListProviderShareAssetsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListProviderShareAssetsResponse{} + conv44, err := convertSlice(v.Tables, TableFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProviderShareAssetsResponse.Tables", err) + } + out.Tables = conv44 + conv45, err := convertSlice(v.Functions, FunctionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProviderShareAssetsResponse.Functions", err) + } + out.Functions = conv45 + conv46, err := convertSlice(v.Notebooks, NotebookFileFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProviderShareAssetsResponse.Notebooks", err) + } + out.Notebooks = conv46 + conv47, err := convertSlice(v.Volumes, VolumeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProviderShareAssetsResponse.Volumes", err) + } + out.Volumes = conv47 + conv48, err := ShareFromSDK(v.Share) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProviderShareAssetsResponse.Share", err) + } + out.Share = conv48 + return out, nil +} + +// ListProviderSharesRequestToSDK converts the mirror to the sdk-go type. +func ListProviderSharesRequestToSDK(w *ListProviderSharesRequest) (*sdk.ListProviderSharesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListProviderSharesRequest{} + out.ProviderNameArg = w.ProviderNameArg + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListProviderSharesRequestFromSDK converts the sdk-go type to the mirror. +func ListProviderSharesRequestFromSDK(v *sdk.ListProviderSharesRequest) (*ListProviderSharesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListProviderSharesRequest{} + out.ProviderNameArg = v.ProviderNameArg + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListProviderSharesResponseToSDK converts the mirror to the sdk-go type. +func ListProviderSharesResponseToSDK(w *ListProviderSharesResponse) (*sdk.ListProviderSharesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListProviderSharesResponse{} + conv49, err := convertSlice(w.Shares, ProviderShareToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProviderSharesResponse.Shares", err) + } + out.Shares = conv49 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListProviderSharesResponseFromSDK converts the sdk-go type to the mirror. +func ListProviderSharesResponseFromSDK(v *sdk.ListProviderSharesResponse) (*ListProviderSharesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListProviderSharesResponse{} + conv50, err := convertSlice(v.Shares, ProviderShareFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProviderSharesResponse.Shares", err) + } + out.Shares = conv50 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListProvidersRequestToSDK converts the mirror to the sdk-go type. +func ListProvidersRequestToSDK(w *ListProvidersRequest) (*sdk.ListProvidersRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListProvidersRequest{} + out.DataProviderGlobalMetastoreId = w.DataProviderGlobalMetastoreId + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListProvidersRequestFromSDK converts the sdk-go type to the mirror. +func ListProvidersRequestFromSDK(v *sdk.ListProvidersRequest) (*ListProvidersRequest, error) { + if v == nil { + return nil, nil + } + out := &ListProvidersRequest{} + out.DataProviderGlobalMetastoreId = v.DataProviderGlobalMetastoreId + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListProvidersResponseToSDK converts the mirror to the sdk-go type. +func ListProvidersResponseToSDK(w *ListProvidersResponse) (*sdk.ListProvidersResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListProvidersResponse{} + conv51, err := convertSlice(w.Providers, ProviderInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProvidersResponse.Providers", err) + } + out.Providers = conv51 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListProvidersResponseFromSDK converts the sdk-go type to the mirror. +func ListProvidersResponseFromSDK(v *sdk.ListProvidersResponse) (*ListProvidersResponse, error) { + if v == nil { + return nil, nil + } + out := &ListProvidersResponse{} + conv52, err := convertSlice(v.Providers, ProviderInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListProvidersResponse.Providers", err) + } + out.Providers = conv52 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListRecipientSharePermissionsRequestToSDK converts the mirror to the sdk-go type. +func ListRecipientSharePermissionsRequestToSDK(w *ListRecipientSharePermissionsRequest) (*sdk.ListRecipientSharePermissionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRecipientSharePermissionsRequest{} + out.Name = w.Name + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListRecipientSharePermissionsRequestFromSDK converts the sdk-go type to the mirror. +func ListRecipientSharePermissionsRequestFromSDK(v *sdk.ListRecipientSharePermissionsRequest) (*ListRecipientSharePermissionsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListRecipientSharePermissionsRequest{} + out.Name = v.Name + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListRecipientsRequestToSDK converts the mirror to the sdk-go type. +func ListRecipientsRequestToSDK(w *ListRecipientsRequest) (*sdk.ListRecipientsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRecipientsRequest{} + out.DataRecipientGlobalMetastoreId = w.DataRecipientGlobalMetastoreId + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListRecipientsRequestFromSDK converts the sdk-go type to the mirror. +func ListRecipientsRequestFromSDK(v *sdk.ListRecipientsRequest) (*ListRecipientsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListRecipientsRequest{} + out.DataRecipientGlobalMetastoreId = v.DataRecipientGlobalMetastoreId + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListRecipientsResponseToSDK converts the mirror to the sdk-go type. +func ListRecipientsResponseToSDK(w *ListRecipientsResponse) (*sdk.ListRecipientsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRecipientsResponse{} + conv53, err := convertSlice(w.Recipients, RecipientInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRecipientsResponse.Recipients", err) + } + out.Recipients = conv53 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListRecipientsResponseFromSDK converts the sdk-go type to the mirror. +func ListRecipientsResponseFromSDK(v *sdk.ListRecipientsResponse) (*ListRecipientsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListRecipientsResponse{} + conv54, err := convertSlice(v.Recipients, RecipientInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRecipientsResponse.Recipients", err) + } + out.Recipients = conv54 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListSharePermissionsRequestToSDK converts the mirror to the sdk-go type. +func ListSharePermissionsRequestToSDK(w *ListSharePermissionsRequest) (*sdk.ListSharePermissionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSharePermissionsRequest{} + out.Name = w.Name + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListSharePermissionsRequestFromSDK converts the sdk-go type to the mirror. +func ListSharePermissionsRequestFromSDK(v *sdk.ListSharePermissionsRequest) (*ListSharePermissionsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSharePermissionsRequest{} + out.Name = v.Name + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListSharesRequestToSDK converts the mirror to the sdk-go type. +func ListSharesRequestToSDK(w *ListSharesRequest) (*sdk.ListSharesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSharesRequest{} + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListSharesRequestFromSDK converts the sdk-go type to the mirror. +func ListSharesRequestFromSDK(v *sdk.ListSharesRequest) (*ListSharesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSharesRequest{} + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListSharesResponseToSDK converts the mirror to the sdk-go type. +func ListSharesResponseToSDK(w *ListSharesResponse) (*sdk.ListSharesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSharesResponse{} + conv55, err := convertSlice(w.Shares, ShareInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSharesResponse.Shares", err) + } + out.Shares = conv55 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSharesResponseFromSDK converts the sdk-go type to the mirror. +func ListSharesResponseFromSDK(v *sdk.ListSharesResponse) (*ListSharesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSharesResponse{} + conv56, err := convertSlice(v.Shares, ShareInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSharesResponse.Shares", err) + } + out.Shares = conv56 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// NotebookFileToSDK converts the mirror to the sdk-go type. +func NotebookFileToSDK(w *NotebookFile) (*sdk.NotebookFile, error) { + if w == nil { + return nil, nil + } + out := &sdk.NotebookFile{} + out.Name = w.Name + out.Share = w.Share + out.ShareId = w.ShareId + out.Id = w.Id + out.Comment = w.Comment + conv57, err := convertSlice(w.Tags, TagKeyValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NotebookFile.Tags", err) + } + out.Tags = conv57 + return out, nil +} + +// NotebookFileFromSDK converts the sdk-go type to the mirror. +func NotebookFileFromSDK(v *sdk.NotebookFile) (*NotebookFile, error) { + if v == nil { + return nil, nil + } + out := &NotebookFile{} + out.Name = v.Name + out.Share = v.Share + out.ShareId = v.ShareId + out.Id = v.Id + out.Comment = v.Comment + conv58, err := convertSlice(v.Tags, TagKeyValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "NotebookFile.Tags", err) + } + out.Tags = conv58 + return out, nil +} + +// OidcFederationPolicyToSDK converts the mirror to the sdk-go type. +func OidcFederationPolicyToSDK(w *OidcFederationPolicy) (*sdk.OidcFederationPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.OidcFederationPolicy{} + out.Issuer = w.Issuer + out.SubjectClaim = w.SubjectClaim + out.Subject = w.Subject + out.Audiences = w.Audiences + return out, nil +} + +// OidcFederationPolicyFromSDK converts the sdk-go type to the mirror. +func OidcFederationPolicyFromSDK(v *sdk.OidcFederationPolicy) (*OidcFederationPolicy, error) { + if v == nil { + return nil, nil + } + out := &OidcFederationPolicy{} + out.Issuer = v.Issuer + out.SubjectClaim = v.SubjectClaim + out.Subject = v.Subject + out.Audiences = v.Audiences + return out, nil +} + +// PartitionSpecification_PartitionToSDK converts the mirror to the sdk-go type. +func PartitionSpecification_PartitionToSDK(w *PartitionSpecification_Partition) (*sdk.PartitionSpecification_Partition, error) { + if w == nil { + return nil, nil + } + out := &sdk.PartitionSpecification_Partition{} + conv59, err := convertSlice(w.Values, PartitionSpecification_Partition_PartitionValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PartitionSpecification_Partition.Values", err) + } + out.Values = conv59 + return out, nil +} + +// PartitionSpecification_PartitionFromSDK converts the sdk-go type to the mirror. +func PartitionSpecification_PartitionFromSDK(v *sdk.PartitionSpecification_Partition) (*PartitionSpecification_Partition, error) { + if v == nil { + return nil, nil + } + out := &PartitionSpecification_Partition{} + conv60, err := convertSlice(v.Values, PartitionSpecification_Partition_PartitionValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PartitionSpecification_Partition.Values", err) + } + out.Values = conv60 + return out, nil +} + +// PartitionSpecification_Partition_PartitionValueToSDK converts the mirror to the sdk-go type. +func PartitionSpecification_Partition_PartitionValueToSDK(w *PartitionSpecification_Partition_PartitionValue) (*sdk.PartitionSpecification_Partition_PartitionValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.PartitionSpecification_Partition_PartitionValue{} + out.Name = w.Name + out.Value = w.Value + out.RecipientPropertyKey = w.RecipientPropertyKey + out.Op = w.Op + return out, nil +} + +// PartitionSpecification_Partition_PartitionValueFromSDK converts the sdk-go type to the mirror. +func PartitionSpecification_Partition_PartitionValueFromSDK(v *sdk.PartitionSpecification_Partition_PartitionValue) (*PartitionSpecification_Partition_PartitionValue, error) { + if v == nil { + return nil, nil + } + out := &PartitionSpecification_Partition_PartitionValue{} + out.Name = v.Name + out.Value = v.Value + out.RecipientPropertyKey = v.RecipientPropertyKey + out.Op = v.Op + return out, nil +} + +// PermissionsChangeToSDK converts the mirror to the sdk-go type. +func PermissionsChangeToSDK(w *PermissionsChange) (*sdk.PermissionsChange, error) { + if w == nil { + return nil, nil + } + out := &sdk.PermissionsChange{} + out.Principal = w.Principal + out.Add = w.Add + out.Remove = w.Remove + return out, nil +} + +// PermissionsChangeFromSDK converts the sdk-go type to the mirror. +func PermissionsChangeFromSDK(v *sdk.PermissionsChange) (*PermissionsChange, error) { + if v == nil { + return nil, nil + } + out := &PermissionsChange{} + out.Principal = v.Principal + out.Add = v.Add + out.Remove = v.Remove + return out, nil +} + +// PrivilegeAssignmentToSDK converts the mirror to the sdk-go type. +func PrivilegeAssignmentToSDK(w *PrivilegeAssignment) (*sdk.PrivilegeAssignment, error) { + if w == nil { + return nil, nil + } + out := &sdk.PrivilegeAssignment{} + out.Principal = w.Principal + out.Privileges = w.Privileges + return out, nil +} + +// PrivilegeAssignmentFromSDK converts the sdk-go type to the mirror. +func PrivilegeAssignmentFromSDK(v *sdk.PrivilegeAssignment) (*PrivilegeAssignment, error) { + if v == nil { + return nil, nil + } + out := &PrivilegeAssignment{} + out.Principal = v.Principal + out.Privileges = v.Privileges + return out, nil +} + +// PropertiesKvPairsToSDK converts the mirror to the sdk-go type. +func PropertiesKvPairsToSDK(w *PropertiesKvPairs) (*sdk.PropertiesKvPairs, error) { + if w == nil { + return nil, nil + } + out := &sdk.PropertiesKvPairs{} + out.Properties = w.Properties + return out, nil +} + +// PropertiesKvPairsFromSDK converts the sdk-go type to the mirror. +func PropertiesKvPairsFromSDK(v *sdk.PropertiesKvPairs) (*PropertiesKvPairs, error) { + if v == nil { + return nil, nil + } + out := &PropertiesKvPairs{} + out.Properties = v.Properties + return out, nil +} + +// ProviderInfoToSDK converts the mirror to the sdk-go type. +func ProviderInfoToSDK(w *ProviderInfo) (*sdk.ProviderInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProviderInfo{} + out.Name = w.Name + out.AuthenticationType = w.AuthenticationType + out.RecipientProfileStr = w.RecipientProfileStr + out.Comment = w.Comment + out.Owner = w.Owner + conv61, err := RecipientProfileToSDK(w.RecipientProfile) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProviderInfo.RecipientProfile", err) + } + out.RecipientProfile = conv61 + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.Cloud = w.Cloud + out.Region = w.Region + out.MetastoreId = w.MetastoreId + out.DataProviderGlobalMetastoreId = w.DataProviderGlobalMetastoreId + return out, nil +} + +// ProviderInfoFromSDK converts the sdk-go type to the mirror. +func ProviderInfoFromSDK(v *sdk.ProviderInfo) (*ProviderInfo, error) { + if v == nil { + return nil, nil + } + out := &ProviderInfo{} + out.Name = v.Name + out.AuthenticationType = v.AuthenticationType + out.RecipientProfileStr = v.RecipientProfileStr + out.Comment = v.Comment + out.Owner = v.Owner + conv62, err := RecipientProfileFromSDK(v.RecipientProfile) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProviderInfo.RecipientProfile", err) + } + out.RecipientProfile = conv62 + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.Cloud = v.Cloud + out.Region = v.Region + out.MetastoreId = v.MetastoreId + out.DataProviderGlobalMetastoreId = v.DataProviderGlobalMetastoreId + return out, nil +} + +// ProviderShareToSDK converts the mirror to the sdk-go type. +func ProviderShareToSDK(w *ProviderShare) (*sdk.ProviderShare, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProviderShare{} + out.Name = w.Name + return out, nil +} + +// ProviderShareFromSDK converts the sdk-go type to the mirror. +func ProviderShareFromSDK(v *sdk.ProviderShare) (*ProviderShare, error) { + if v == nil { + return nil, nil + } + out := &ProviderShare{} + out.Name = v.Name + return out, nil +} + +// RecipientInfoToSDK converts the mirror to the sdk-go type. +func RecipientInfoToSDK(w *RecipientInfo) (*sdk.RecipientInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.RecipientInfo{} + out.Name = w.Name + out.AuthenticationType = w.AuthenticationType + out.SharingCode = w.SharingCode + out.DataRecipientGlobalMetastoreId = w.DataRecipientGlobalMetastoreId + out.Owner = w.Owner + out.Comment = w.Comment + conv63, err := IpAccessListToSDK(w.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RecipientInfo.IpAccessList", err) + } + out.IpAccessList = conv63 + conv64, err := PropertiesKvPairsToSDK(w.PropertiesKvpairs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RecipientInfo.PropertiesKvpairs", err) + } + out.PropertiesKvpairs = conv64 + out.ExpirationTime = w.ExpirationTime + out.ActivationUrl = w.ActivationUrl + out.Activated = w.Activated + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + conv65, err := convertSlice(w.Tokens, RecipientTokenInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RecipientInfo.Tokens", err) + } + out.Tokens = conv65 + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.Cloud = w.Cloud + out.Region = w.Region + out.MetastoreId = w.MetastoreId + out.Id = w.Id + return out, nil +} + +// RecipientInfoFromSDK converts the sdk-go type to the mirror. +func RecipientInfoFromSDK(v *sdk.RecipientInfo) (*RecipientInfo, error) { + if v == nil { + return nil, nil + } + out := &RecipientInfo{} + out.Name = v.Name + out.AuthenticationType = v.AuthenticationType + out.SharingCode = v.SharingCode + out.DataRecipientGlobalMetastoreId = v.DataRecipientGlobalMetastoreId + out.Owner = v.Owner + out.Comment = v.Comment + conv66, err := IpAccessListFromSDK(v.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RecipientInfo.IpAccessList", err) + } + out.IpAccessList = conv66 + conv67, err := PropertiesKvPairsFromSDK(v.PropertiesKvpairs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RecipientInfo.PropertiesKvpairs", err) + } + out.PropertiesKvpairs = conv67 + out.ExpirationTime = v.ExpirationTime + out.ActivationUrl = v.ActivationUrl + out.Activated = v.Activated + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + conv68, err := convertSlice(v.Tokens, RecipientTokenInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RecipientInfo.Tokens", err) + } + out.Tokens = conv68 + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.Cloud = v.Cloud + out.Region = v.Region + out.MetastoreId = v.MetastoreId + out.Id = v.Id + return out, nil +} + +// RecipientProfileToSDK converts the mirror to the sdk-go type. +func RecipientProfileToSDK(w *RecipientProfile) (*sdk.RecipientProfile, error) { + if w == nil { + return nil, nil + } + out := &sdk.RecipientProfile{} + out.ShareCredentialsVersion = w.ShareCredentialsVersion + out.Endpoint = w.Endpoint + out.BearerToken = w.BearerToken + return out, nil +} + +// RecipientProfileFromSDK converts the sdk-go type to the mirror. +func RecipientProfileFromSDK(v *sdk.RecipientProfile) (*RecipientProfile, error) { + if v == nil { + return nil, nil + } + out := &RecipientProfile{} + out.ShareCredentialsVersion = v.ShareCredentialsVersion + out.Endpoint = v.Endpoint + out.BearerToken = v.BearerToken + return out, nil +} + +// RecipientTokenInfoToSDK converts the mirror to the sdk-go type. +func RecipientTokenInfoToSDK(w *RecipientTokenInfo) (*sdk.RecipientTokenInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.RecipientTokenInfo{} + out.Id = w.Id + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.ActivationUrl = w.ActivationUrl + out.ExpirationTime = w.ExpirationTime + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + return out, nil +} + +// RecipientTokenInfoFromSDK converts the sdk-go type to the mirror. +func RecipientTokenInfoFromSDK(v *sdk.RecipientTokenInfo) (*RecipientTokenInfo, error) { + if v == nil { + return nil, nil + } + out := &RecipientTokenInfo{} + out.Id = v.Id + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.ActivationUrl = v.ActivationUrl + out.ExpirationTime = v.ExpirationTime + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + return out, nil +} + +// RegisteredModelAliasToSDK converts the mirror to the sdk-go type. +func RegisteredModelAliasToSDK(w *RegisteredModelAlias) (*sdk.RegisteredModelAlias, error) { + if w == nil { + return nil, nil + } + out := &sdk.RegisteredModelAlias{} + out.AliasName = w.AliasName + out.VersionNum = w.VersionNum + return out, nil +} + +// RegisteredModelAliasFromSDK converts the sdk-go type to the mirror. +func RegisteredModelAliasFromSDK(v *sdk.RegisteredModelAlias) (*RegisteredModelAlias, error) { + if v == nil { + return nil, nil + } + out := &RegisteredModelAlias{} + out.AliasName = v.AliasName + out.VersionNum = v.VersionNum + return out, nil +} + +// ReplicationConfigToSDK converts the mirror to the sdk-go type. +func ReplicationConfigToSDK(w *ReplicationConfig) (*sdk.ReplicationConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.ReplicationConfig{} + out.Enabled = w.Enabled + return out, nil +} + +// ReplicationConfigFromSDK converts the sdk-go type to the mirror. +func ReplicationConfigFromSDK(v *sdk.ReplicationConfig) (*ReplicationConfig, error) { + if v == nil { + return nil, nil + } + out := &ReplicationConfig{} + out.Enabled = v.Enabled + return out, nil +} + +// RetrieveTokenResponseToSDK converts the mirror to the sdk-go type. +func RetrieveTokenResponseToSDK(w *RetrieveTokenResponse) (*sdk.RetrieveTokenResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.RetrieveTokenResponse{} + out.ShareCredentialsVersion = w.ShareCredentialsVersion + out.BearerToken = w.BearerToken + out.Endpoint = w.Endpoint + out.ExpirationTime = w.ExpirationTime + return out, nil +} + +// RetrieveTokenResponseFromSDK converts the sdk-go type to the mirror. +func RetrieveTokenResponseFromSDK(v *sdk.RetrieveTokenResponse) (*RetrieveTokenResponse, error) { + if v == nil { + return nil, nil + } + out := &RetrieveTokenResponse{} + out.ShareCredentialsVersion = v.ShareCredentialsVersion + out.BearerToken = v.BearerToken + out.Endpoint = v.Endpoint + out.ExpirationTime = v.ExpirationTime + return out, nil +} + +// RotateRecipientTokenRequestToSDK converts the mirror to the sdk-go type. +func RotateRecipientTokenRequestToSDK(w *RotateRecipientTokenRequest) (*sdk.RotateRecipientTokenRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RotateRecipientTokenRequest{} + out.Name = w.Name + out.ExistingTokenExpireInSeconds = w.ExistingTokenExpireInSeconds + return out, nil +} + +// RotateRecipientTokenRequestFromSDK converts the sdk-go type to the mirror. +func RotateRecipientTokenRequestFromSDK(v *sdk.RotateRecipientTokenRequest) (*RotateRecipientTokenRequest, error) { + if v == nil { + return nil, nil + } + out := &RotateRecipientTokenRequest{} + out.Name = v.Name + out.ExistingTokenExpireInSeconds = v.ExistingTokenExpireInSeconds + return out, nil +} + +// ShareToSDK converts the mirror to the sdk-go type. +func ShareToSDK(w *Share) (*sdk.Share, error) { + if w == nil { + return nil, nil + } + out := &sdk.Share{} + out.Name = w.Name + out.Id = w.Id + return out, nil +} + +// ShareFromSDK converts the sdk-go type to the mirror. +func ShareFromSDK(v *sdk.Share) (*Share, error) { + if v == nil { + return nil, nil + } + out := &Share{} + out.Name = v.Name + out.Id = v.Id + return out, nil +} + +// ShareInfoToSDK converts the mirror to the sdk-go type. +func ShareInfoToSDK(w *ShareInfo) (*sdk.ShareInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ShareInfo{} + out.Name = w.Name + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageRoot = w.StorageRoot + conv69, err := ReplicationConfigToSDK(w.ReplicationConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ShareInfo.ReplicationConfig", err) + } + out.ReplicationConfig = conv69 + conv70, err := convertSlice(w.Objects, SharedDataObjectToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ShareInfo.Objects", err) + } + out.Objects = conv70 + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.StorageLocation = w.StorageLocation + return out, nil +} + +// ShareInfoFromSDK converts the sdk-go type to the mirror. +func ShareInfoFromSDK(v *sdk.ShareInfo) (*ShareInfo, error) { + if v == nil { + return nil, nil + } + out := &ShareInfo{} + out.Name = v.Name + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageRoot = v.StorageRoot + conv71, err := ReplicationConfigFromSDK(v.ReplicationConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ShareInfo.ReplicationConfig", err) + } + out.ReplicationConfig = conv71 + conv72, err := convertSlice(v.Objects, SharedDataObjectFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ShareInfo.Objects", err) + } + out.Objects = conv72 + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.StorageLocation = v.StorageLocation + return out, nil +} + +// ShareToPrivilegeAssignmentToSDK converts the mirror to the sdk-go type. +func ShareToPrivilegeAssignmentToSDK(w *ShareToPrivilegeAssignment) (*sdk.ShareToPrivilegeAssignment, error) { + if w == nil { + return nil, nil + } + out := &sdk.ShareToPrivilegeAssignment{} + out.ShareName = w.ShareName + conv73, err := convertSlice(w.PrivilegeAssignments, PrivilegeAssignmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ShareToPrivilegeAssignment.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv73 + return out, nil +} + +// ShareToPrivilegeAssignmentFromSDK converts the sdk-go type to the mirror. +func ShareToPrivilegeAssignmentFromSDK(v *sdk.ShareToPrivilegeAssignment) (*ShareToPrivilegeAssignment, error) { + if v == nil { + return nil, nil + } + out := &ShareToPrivilegeAssignment{} + out.ShareName = v.ShareName + conv74, err := convertSlice(v.PrivilegeAssignments, PrivilegeAssignmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ShareToPrivilegeAssignment.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv74 + return out, nil +} + +// SharedDataObjectToSDK converts the mirror to the sdk-go type. +func SharedDataObjectToSDK(w *SharedDataObject) (*sdk.SharedDataObject, error) { + if w == nil { + return nil, nil + } + out := &sdk.SharedDataObject{} + out.Name = w.Name + out.DataObjectType = w.DataObjectType + out.AddedAt = w.AddedAt + out.AddedBy = w.AddedBy + out.Comment = w.Comment + out.SharedAs = w.SharedAs + out.CdfEnabled = w.CdfEnabled + out.HistoryDataSharingStatus = w.HistoryDataSharingStatus + out.StartVersion = w.StartVersion + out.Status = w.Status + out.Content = w.Content + out.StringSharedAs = w.StringSharedAs + conv75, err := convertSlice(w.Partitions, PartitionSpecification_PartitionToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SharedDataObject.Partitions", err) + } + out.Partitions = conv75 + return out, nil +} + +// SharedDataObjectFromSDK converts the sdk-go type to the mirror. +func SharedDataObjectFromSDK(v *sdk.SharedDataObject) (*SharedDataObject, error) { + if v == nil { + return nil, nil + } + out := &SharedDataObject{} + out.Name = v.Name + out.DataObjectType = v.DataObjectType + out.AddedAt = v.AddedAt + out.AddedBy = v.AddedBy + out.Comment = v.Comment + out.SharedAs = v.SharedAs + out.CdfEnabled = v.CdfEnabled + out.HistoryDataSharingStatus = v.HistoryDataSharingStatus + out.StartVersion = v.StartVersion + out.Status = v.Status + out.Content = v.Content + out.StringSharedAs = v.StringSharedAs + conv76, err := convertSlice(v.Partitions, PartitionSpecification_PartitionFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SharedDataObject.Partitions", err) + } + out.Partitions = conv76 + return out, nil +} + +// TableToSDK converts the mirror to the sdk-go type. +func TableToSDK(w *Table) (*sdk.Table, error) { + if w == nil { + return nil, nil + } + out := &sdk.Table{} + out.Name = w.Name + out.Schema = w.Schema + out.Share = w.Share + out.ShareId = w.ShareId + out.Id = w.Id + out.Comment = w.Comment + conv77, err := convertSlice(w.Tags, TagKeyValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Table.Tags", err) + } + out.Tags = conv77 + out.MaterializedTableName = w.MaterializedTableName + out.MaterializationNamespace = w.MaterializationNamespace + return out, nil +} + +// TableFromSDK converts the sdk-go type to the mirror. +func TableFromSDK(v *sdk.Table) (*Table, error) { + if v == nil { + return nil, nil + } + out := &Table{} + out.Name = v.Name + out.Schema = v.Schema + out.Share = v.Share + out.ShareId = v.ShareId + out.Id = v.Id + out.Comment = v.Comment + conv78, err := convertSlice(v.Tags, TagKeyValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Table.Tags", err) + } + out.Tags = conv78 + out.MaterializedTableName = v.MaterializedTableName + out.MaterializationNamespace = v.MaterializationNamespace + return out, nil +} + +// TableDependencyToSDK converts the mirror to the sdk-go type. +func TableDependencyToSDK(w *TableDependency) (*sdk.TableDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.TableDependency{} + out.SchemaName = w.SchemaName + out.TableName = w.TableName + return out, nil +} + +// TableDependencyFromSDK converts the sdk-go type to the mirror. +func TableDependencyFromSDK(v *sdk.TableDependency) (*TableDependency, error) { + if v == nil { + return nil, nil + } + out := &TableDependency{} + out.SchemaName = v.SchemaName + out.TableName = v.TableName + return out, nil +} + +// TagKeyValueToSDK converts the mirror to the sdk-go type. +func TagKeyValueToSDK(w *TagKeyValue) (*sdk.TagKeyValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.TagKeyValue{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// TagKeyValueFromSDK converts the sdk-go type to the mirror. +func TagKeyValueFromSDK(v *sdk.TagKeyValue) (*TagKeyValue, error) { + if v == nil { + return nil, nil + } + out := &TagKeyValue{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// UpdateProviderRequestToSDK converts the mirror to the sdk-go type. +func UpdateProviderRequestToSDK(w *UpdateProviderRequest) (*sdk.UpdateProviderRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateProviderRequest{} + out.NameArg = w.NameArg + out.NewName = w.NewName + out.Name = w.Name + out.AuthenticationType = w.AuthenticationType + out.RecipientProfileStr = w.RecipientProfileStr + out.Comment = w.Comment + out.Owner = w.Owner + conv79, err := RecipientProfileToSDK(w.RecipientProfile) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateProviderRequest.RecipientProfile", err) + } + out.RecipientProfile = conv79 + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.Cloud = w.Cloud + out.Region = w.Region + out.MetastoreId = w.MetastoreId + out.DataProviderGlobalMetastoreId = w.DataProviderGlobalMetastoreId + return out, nil +} + +// UpdateProviderRequestFromSDK converts the sdk-go type to the mirror. +func UpdateProviderRequestFromSDK(v *sdk.UpdateProviderRequest) (*UpdateProviderRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateProviderRequest{} + out.NameArg = v.NameArg + out.NewName = v.NewName + out.Name = v.Name + out.AuthenticationType = v.AuthenticationType + out.RecipientProfileStr = v.RecipientProfileStr + out.Comment = v.Comment + out.Owner = v.Owner + conv80, err := RecipientProfileFromSDK(v.RecipientProfile) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateProviderRequest.RecipientProfile", err) + } + out.RecipientProfile = conv80 + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.Cloud = v.Cloud + out.Region = v.Region + out.MetastoreId = v.MetastoreId + out.DataProviderGlobalMetastoreId = v.DataProviderGlobalMetastoreId + return out, nil +} + +// UpdateRecipientRequestToSDK converts the mirror to the sdk-go type. +func UpdateRecipientRequestToSDK(w *UpdateRecipientRequest) (*sdk.UpdateRecipientRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRecipientRequest{} + out.NameArg = w.NameArg + out.NewName = w.NewName + out.Name = w.Name + out.AuthenticationType = w.AuthenticationType + out.SharingCode = w.SharingCode + out.DataRecipientGlobalMetastoreId = w.DataRecipientGlobalMetastoreId + out.Owner = w.Owner + out.Comment = w.Comment + conv81, err := IpAccessListToSDK(w.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRecipientRequest.IpAccessList", err) + } + out.IpAccessList = conv81 + conv82, err := PropertiesKvPairsToSDK(w.PropertiesKvpairs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRecipientRequest.PropertiesKvpairs", err) + } + out.PropertiesKvpairs = conv82 + out.ExpirationTime = w.ExpirationTime + out.ActivationUrl = w.ActivationUrl + out.Activated = w.Activated + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + conv83, err := convertSlice(w.Tokens, RecipientTokenInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRecipientRequest.Tokens", err) + } + out.Tokens = conv83 + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.Cloud = w.Cloud + out.Region = w.Region + out.MetastoreId = w.MetastoreId + out.Id = w.Id + return out, nil +} + +// UpdateRecipientRequestFromSDK converts the sdk-go type to the mirror. +func UpdateRecipientRequestFromSDK(v *sdk.UpdateRecipientRequest) (*UpdateRecipientRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateRecipientRequest{} + out.NameArg = v.NameArg + out.NewName = v.NewName + out.Name = v.Name + out.AuthenticationType = v.AuthenticationType + out.SharingCode = v.SharingCode + out.DataRecipientGlobalMetastoreId = v.DataRecipientGlobalMetastoreId + out.Owner = v.Owner + out.Comment = v.Comment + conv84, err := IpAccessListFromSDK(v.IpAccessList) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRecipientRequest.IpAccessList", err) + } + out.IpAccessList = conv84 + conv85, err := PropertiesKvPairsFromSDK(v.PropertiesKvpairs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRecipientRequest.PropertiesKvpairs", err) + } + out.PropertiesKvpairs = conv85 + out.ExpirationTime = v.ExpirationTime + out.ActivationUrl = v.ActivationUrl + out.Activated = v.Activated + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + conv86, err := convertSlice(v.Tokens, RecipientTokenInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRecipientRequest.Tokens", err) + } + out.Tokens = conv86 + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.Cloud = v.Cloud + out.Region = v.Region + out.MetastoreId = v.MetastoreId + out.Id = v.Id + return out, nil +} + +// UpdateSharePermissionsRequestToSDK converts the mirror to the sdk-go type. +func UpdateSharePermissionsRequestToSDK(w *UpdateSharePermissionsRequest) (*sdk.UpdateSharePermissionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateSharePermissionsRequest{} + out.Name = w.Name + out.OmitPermissionsList = w.OmitPermissionsList + conv87, err := convertSlice(w.Changes, PermissionsChangeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSharePermissionsRequest.Changes", err) + } + out.Changes = conv87 + return out, nil +} + +// UpdateSharePermissionsRequestFromSDK converts the sdk-go type to the mirror. +func UpdateSharePermissionsRequestFromSDK(v *sdk.UpdateSharePermissionsRequest) (*UpdateSharePermissionsRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateSharePermissionsRequest{} + out.Name = v.Name + out.OmitPermissionsList = v.OmitPermissionsList + conv88, err := convertSlice(v.Changes, PermissionsChangeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSharePermissionsRequest.Changes", err) + } + out.Changes = conv88 + return out, nil +} + +// UpdateSharePermissionsResponseToSDK converts the mirror to the sdk-go type. +func UpdateSharePermissionsResponseToSDK(w *UpdateSharePermissionsResponse) (*sdk.UpdateSharePermissionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateSharePermissionsResponse{} + conv89, err := convertSlice(w.PrivilegeAssignments, PrivilegeAssignmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSharePermissionsResponse.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv89 + return out, nil +} + +// UpdateSharePermissionsResponseFromSDK converts the sdk-go type to the mirror. +func UpdateSharePermissionsResponseFromSDK(v *sdk.UpdateSharePermissionsResponse) (*UpdateSharePermissionsResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateSharePermissionsResponse{} + conv90, err := convertSlice(v.PrivilegeAssignments, PrivilegeAssignmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSharePermissionsResponse.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv90 + return out, nil +} + +// UpdateShareRequestToSDK converts the mirror to the sdk-go type. +func UpdateShareRequestToSDK(w *UpdateShareRequest) (*sdk.UpdateShareRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateShareRequest{} + out.NameArg = w.NameArg + out.NewName = w.NewName + conv91, err := convertSlice(w.Updates, UpdateShareRequest_SharedDataObjectUpdateToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateShareRequest.Updates", err) + } + out.Updates = conv91 + out.Name = w.Name + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageRoot = w.StorageRoot + conv92, err := ReplicationConfigToSDK(w.ReplicationConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateShareRequest.ReplicationConfig", err) + } + out.ReplicationConfig = conv92 + conv93, err := convertSlice(w.Objects, SharedDataObjectToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateShareRequest.Objects", err) + } + out.Objects = conv93 + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.StorageLocation = w.StorageLocation + return out, nil +} + +// UpdateShareRequestFromSDK converts the sdk-go type to the mirror. +func UpdateShareRequestFromSDK(v *sdk.UpdateShareRequest) (*UpdateShareRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateShareRequest{} + out.NameArg = v.NameArg + out.NewName = v.NewName + conv94, err := convertSlice(v.Updates, UpdateShareRequest_SharedDataObjectUpdateFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateShareRequest.Updates", err) + } + out.Updates = conv94 + out.Name = v.Name + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageRoot = v.StorageRoot + conv95, err := ReplicationConfigFromSDK(v.ReplicationConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateShareRequest.ReplicationConfig", err) + } + out.ReplicationConfig = conv95 + conv96, err := convertSlice(v.Objects, SharedDataObjectFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateShareRequest.Objects", err) + } + out.Objects = conv96 + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.StorageLocation = v.StorageLocation + return out, nil +} + +// UpdateShareRequest_SharedDataObjectUpdateToSDK converts the mirror to the sdk-go type. +func UpdateShareRequest_SharedDataObjectUpdateToSDK(w *UpdateShareRequest_SharedDataObjectUpdate) (*sdk.UpdateShareRequest_SharedDataObjectUpdate, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateShareRequest_SharedDataObjectUpdate{} + out.Action = w.Action + conv97, err := SharedDataObjectToSDK(w.DataObject) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateShareRequest_SharedDataObjectUpdate.DataObject", err) + } + out.DataObject = conv97 + return out, nil +} + +// UpdateShareRequest_SharedDataObjectUpdateFromSDK converts the sdk-go type to the mirror. +func UpdateShareRequest_SharedDataObjectUpdateFromSDK(v *sdk.UpdateShareRequest_SharedDataObjectUpdate) (*UpdateShareRequest_SharedDataObjectUpdate, error) { + if v == nil { + return nil, nil + } + out := &UpdateShareRequest_SharedDataObjectUpdate{} + out.Action = v.Action + conv98, err := SharedDataObjectFromSDK(v.DataObject) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateShareRequest_SharedDataObjectUpdate.DataObject", err) + } + out.DataObject = conv98 + return out, nil +} + +// VolumeToSDK converts the mirror to the sdk-go type. +func VolumeToSDK(w *Volume) (*sdk.Volume, error) { + if w == nil { + return nil, nil + } + out := &sdk.Volume{} + out.Name = w.Name + out.Id = w.Id + out.Schema = w.Schema + out.Share = w.Share + out.ShareId = w.ShareId + out.Comment = w.Comment + conv99, err := convertSlice(w.Tags, TagKeyValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Volume.Tags", err) + } + out.Tags = conv99 + return out, nil +} + +// VolumeFromSDK converts the sdk-go type to the mirror. +func VolumeFromSDK(v *sdk.Volume) (*Volume, error) { + if v == nil { + return nil, nil + } + out := &Volume{} + out.Name = v.Name + out.Id = v.Id + out.Schema = v.Schema + out.Share = v.Share + out.ShareId = v.ShareId + out.Comment = v.Comment + conv100, err := convertSlice(v.Tags, TagKeyValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Volume.Tags", err) + } + out.Tags = conv100 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/statementexecution/v1/types.generated.go b/libs/sdktypes/statementexecution/v1/types.generated.go new file mode 100644 index 00000000000..725363015ba --- /dev/null +++ b/libs/sdktypes/statementexecution/v1/types.generated.go @@ -0,0 +1,953 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/statementexecution/v1. DO NOT EDIT. + +package statementexecution + +import ( + json "encoding/json" + fmt "fmt" + sdk "github.com/databricks/sdk-go/statementexecution/v1" +) + +type ( + ColumnTypeName = sdk.ColumnTypeName + Disposition = sdk.Disposition + Format = sdk.Format + ServiceErrorCode = sdk.ServiceErrorCode + TimeoutAction = sdk.TimeoutAction + StatementStatus_State = sdk.StatementStatus_State +) + +const ( + ColumnTypeName_Unspecified = sdk.ColumnTypeName_Unspecified + ColumnTypeName_Boolean = sdk.ColumnTypeName_Boolean + ColumnTypeName_Byte = sdk.ColumnTypeName_Byte + ColumnTypeName_Short = sdk.ColumnTypeName_Short + ColumnTypeName_Int = sdk.ColumnTypeName_Int + ColumnTypeName_Long = sdk.ColumnTypeName_Long + ColumnTypeName_Float = sdk.ColumnTypeName_Float + ColumnTypeName_Double = sdk.ColumnTypeName_Double + ColumnTypeName_Date = sdk.ColumnTypeName_Date + ColumnTypeName_Timestamp = sdk.ColumnTypeName_Timestamp + ColumnTypeName_String = sdk.ColumnTypeName_String + ColumnTypeName_Binary = sdk.ColumnTypeName_Binary + ColumnTypeName_Decimal = sdk.ColumnTypeName_Decimal + ColumnTypeName_Interval = sdk.ColumnTypeName_Interval + ColumnTypeName_Array = sdk.ColumnTypeName_Array + ColumnTypeName_Struct = sdk.ColumnTypeName_Struct + ColumnTypeName_Map = sdk.ColumnTypeName_Map + ColumnTypeName_Char = sdk.ColumnTypeName_Char + ColumnTypeName_Null = sdk.ColumnTypeName_Null + ColumnTypeName_UserDefinedType = sdk.ColumnTypeName_UserDefinedType + Disposition_Unspecified = sdk.Disposition_Unspecified + Disposition_Inline = sdk.Disposition_Inline + Disposition_ExternalLinks = sdk.Disposition_ExternalLinks + Format_Unspecified = sdk.Format_Unspecified + Format_JsonArray = sdk.Format_JsonArray + Format_ArrowStream = sdk.Format_ArrowStream + Format_Csv = sdk.Format_Csv + ServiceErrorCode_Unspecified = sdk.ServiceErrorCode_Unspecified + ServiceErrorCode_Unknown = sdk.ServiceErrorCode_Unknown + ServiceErrorCode_InternalError = sdk.ServiceErrorCode_InternalError + ServiceErrorCode_TemporarilyUnavailable = sdk.ServiceErrorCode_TemporarilyUnavailable + ServiceErrorCode_IoError = sdk.ServiceErrorCode_IoError + ServiceErrorCode_BadRequest = sdk.ServiceErrorCode_BadRequest + ServiceErrorCode_ServiceUnderMaintenance = sdk.ServiceErrorCode_ServiceUnderMaintenance + ServiceErrorCode_WorkspaceTemporarilyUnavailable = sdk.ServiceErrorCode_WorkspaceTemporarilyUnavailable + ServiceErrorCode_DeadlineExceeded = sdk.ServiceErrorCode_DeadlineExceeded + ServiceErrorCode_Cancelled = sdk.ServiceErrorCode_Cancelled + ServiceErrorCode_ResourceExhausted = sdk.ServiceErrorCode_ResourceExhausted + ServiceErrorCode_Aborted = sdk.ServiceErrorCode_Aborted + ServiceErrorCode_NotFound = sdk.ServiceErrorCode_NotFound + ServiceErrorCode_AlreadyExists = sdk.ServiceErrorCode_AlreadyExists + ServiceErrorCode_Unauthenticated = sdk.ServiceErrorCode_Unauthenticated + TimeoutAction_Unspecified = sdk.TimeoutAction_Unspecified + TimeoutAction_Continue = sdk.TimeoutAction_Continue + TimeoutAction_Cancel = sdk.TimeoutAction_Cancel + StatementStatus_State_Unspecified = sdk.StatementStatus_State_Unspecified + StatementStatus_State_Pending = sdk.StatementStatus_State_Pending + StatementStatus_State_Running = sdk.StatementStatus_State_Running + StatementStatus_State_Succeeded = sdk.StatementStatus_State_Succeeded + StatementStatus_State_Failed = sdk.StatementStatus_State_Failed + StatementStatus_State_Canceled = sdk.StatementStatus_State_Canceled + StatementStatus_State_Closed = sdk.StatementStatus_State_Closed +) + +type CancelStatementRequest struct { + // The statement ID is returned upon successfully submitting a SQL statement, + // and is a required reference for all subsequent calls. + StatementId *string `json:"statement_id,omitempty"` + // For warehouse statement URLs, this field contains the warehouse_id path + // parameter. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type ChunkInfo struct { + // The number of bytes in the result chunk. This field is not available when + // using `INLINE` disposition. + ByteCount *int64 `json:"byte_count,omitempty"` + // The position within the sequence of result set chunks. + ChunkIndex *int `json:"chunk_index,omitempty"` + // When fetching, provides the `chunk_index` for the _next_ chunk. If absent, + // indicates there are no more chunks. The next chunk can be fetched with a + // :method:statementexecution/getstatementresultchunkn request. + NextChunkIndex *int `json:"next_chunk_index,omitempty"` + // When fetching, provides a link to fetch the _next_ chunk. If absent, + // indicates there are no more chunks. This link is an absolute `path` to be + // joined with your `$DATABRICKS_HOST`, and should be treated as an opaque link. + // This is an alternative to using `next_chunk_index`. + NextChunkInternalLink *string `json:"next_chunk_internal_link,omitempty"` + // The number of rows within the result chunk. + RowCount *int64 `json:"row_count,omitempty"` + // The starting row offset within the result set. + RowOffset *int64 `json:"row_offset,omitempty"` +} + +type ColumnInfo struct { + // The name of the column. + Name *string `json:"name,omitempty"` + // The ordinal position of the column (starting at position 0). + Position *int `json:"position,omitempty"` + // The format of the interval type. + TypeIntervalType *string `json:"type_interval_type,omitempty"` + // The name of the base data type. This doesn't include details for complex + // types such as STRUCT, MAP or ARRAY. + TypeName ColumnTypeName `json:"type_name,omitempty"` + // Specifies the number of digits in a number. This applies to the DECIMAL type. + TypePrecision *int `json:"type_precision,omitempty"` + // Specifies the number of digits to the right of the decimal point in a number. + // This applies to the DECIMAL type. + TypeScale *int `json:"type_scale,omitempty"` + // The full SQL type specification. + TypeText *string `json:"type_text,omitempty"` +} + +type ExecuteStatementRequest struct { + // Applies the given byte limit to the statement's result size. Byte counts are + // based on internal data representations and might not match the final size in + // the requested `format`. If the result was truncated due to the byte limit, + // then `truncated` in the response is set to `true`. When using + // `EXTERNAL_LINKS` disposition, a default `byte_limit` of 100 GiB is applied if + // `byte_limit` is not explicitly set. + ByteLimit *int64 `json:"byte_limit,omitempty"` + // Sets default catalog for statement execution, similar to [`USE CATALOG`] in + // SQL. + // + // [`USE CATALOG`]: https://docs.databricks.com/sql/language-manual/sql-ref-syntax-ddl-use-catalog.html + Catalog *string `json:"catalog,omitempty"` + // The fetch disposition provides two modes of fetching results: `INLINE` and + // `EXTERNAL_LINKS`. + // + // Statements executed with `INLINE` disposition will return result data inline, + // in `JSON_ARRAY` format, in a series of chunks. If a given statement produces + // a result set with a size larger than 25 MiB, that statement execution is + // aborted, and no result set will be available. + // + // **NOTE** Byte limits are computed based upon internal representations of the + // result set data, and might not match the sizes visible in JSON responses. + // + // Statements executed with `EXTERNAL_LINKS` disposition will return result data + // as external links: URLs that point to cloud storage internal to the + // workspace. Using `EXTERNAL_LINKS` disposition allows statements to generate + // arbitrarily sized result sets for fetching up to 100 GiB. The resulting links + // have two important properties: + // + // 1. They point to resources _external_ to the compute; therefore + // any associated authentication information (typically a personal access token, + // OAuth token, or similar) _must be removed_ when fetching from these links. + // + // 2. These are short-lived cloud-storage URLs with a specific expiration, + // indicated in the response. The behavior when attempting to use an expired + // link is cloud specific. + Disposition Disposition `json:"disposition,omitempty"` + // Statement execution supports three result formats: `JSON_ARRAY` (default), + // `ARROW_STREAM`, and `CSV`. + // + // Important: The formats `ARROW_STREAM` and `CSV` are supported only with + // `EXTERNAL_LINKS` disposition. `JSON_ARRAY` is supported in `INLINE` and + // `EXTERNAL_LINKS` disposition. + // + // When specifying `format=JSON_ARRAY`, result data will be formatted as an + // array of arrays of values, where each value is either the *string + // representation* of a value, or `null`. For example, the output of `SELECT + // concat('id-', id) AS strCol, id AS intCol, null AS nullCol FROM range(3)` + // would look like this: + // + // ``` [ [ "id-1", "1", null ], [ "id-2", "2", null ], [ "id-3", "3", null ], ] + // ``` + // + // When specifying `format=JSON_ARRAY` and `disposition=EXTERNAL_LINKS`, each + // chunk in the result contains compact JSON with no indentation or extra + // whitespace. + // + // When specifying `format=ARROW_STREAM` and `disposition=EXTERNAL_LINKS`, each + // chunk in the result will be formatted as Apache Arrow Stream. See the [Apache + // Arrow streaming format]. + // + // When specifying `format=CSV` and `disposition=EXTERNAL_LINKS`, each chunk in + // the result will be a CSV according to [RFC 4180] standard. All the columns + // values will have *string representation* similar to the `JSON_ARRAY` format, + // and `null` values will be encoded as “null”. Only the first chunk in the + // result would contain a header row with column names. For example, the output + // of `SELECT concat('id-', id) AS strCol, id AS intCol, null as nullCol FROM + // range(3)` would look like this: + // + // ``` strCol,intCol,nullCol id-1,1,null id-2,2,null id-3,3,null ``` + // + // [Apache Arrow streaming format]: https://arrow.apache.org/docs/format/Columnar.html#ipc-streaming-format + // [RFC 4180]: https://www.rfc-editor.org/rfc/rfc4180 + Format Format `json:"format,omitempty"` + // When `wait_timeout > 0s`, the call will block up to the specified time. If + // the statement execution doesn't finish within this time, `on_wait_timeout` + // determines whether the execution should continue or be canceled. When set to + // `CONTINUE`, the statement execution continues asynchronously and the call + // returns a statement ID which can be used for polling with + // :method:statementexecution/getStatement. When set to `CANCEL`, the statement + // execution is canceled and the call returns with a `CANCELED` state. + OnWaitTimeout TimeoutAction `json:"on_wait_timeout,omitempty"` + // A list of parameters to pass into a SQL statement containing parameter + // markers. A parameter consists of a name, a value, and optionally a type. To + // represent a NULL value, the `value` field may be omitted or set to `null` + // explicitly. If the `type` field is omitted, the value is interpreted as a + // string. + // + // If the type is given, parameters will be checked for type correctness + // according to the given type. A value is correct if the provided string can be + // converted to the requested type using the `cast` function. The exact + // semantics are described in the section [`cast` function] of the SQL language + // reference. + // + // For example, the following statement contains two parameters, `my_name` and + // `my_date`: + // + // ``` SELECT * FROM my_table WHERE name = :my_name AND date = :my_date ``` + // + // The parameters can be passed in the request body as follows: + // + // ` { ..., "statement": "SELECT * FROM my_table WHERE name = :my_name AND date + // = :my_date", "parameters": [ { "name": "my_name", "value": "the name" }, { + // "name": "my_date", "value": "2020-01-01", "type": "DATE" } ] } ` + // + // Currently, positional parameters denoted by a `?` marker are not supported by + // the Databricks SQL Statement Execution API. + // + // Also see the section [Parameter markers] of the SQL language reference. + // + // [Parameter markers]: https://docs.databricks.com/sql/language-manual/sql-ref-parameter-marker.html + // [`cast` function]: https://docs.databricks.com/sql/language-manual/functions/cast.html + Parameters []StatementParameter `json:"parameters,omitempty"` + // An array of query tags to annotate a SQL statement. A query tag consists of a + // non-empty key and, optionally, a value. To represent a NULL value, either + // omit the `value` field or manually set it to `null` or white space. Refer to + // the SQL language reference for the format specification of query tags. + // There's no significance to the order of tags. Only one value per key will be + // recorded. A sequence in excess of 20 query tags will be coerced to 20. + // Example: + // + // { ..., "query_tags": [ { "key": "team", "value": "eng" }, { "key": "some key + // only tag" } ] } + QueryTags []QueryTag `json:"query_tags,omitempty"` + // Applies the given row limit to the statement's result set, but unlike the + // `LIMIT` clause in SQL, it also sets the `truncated` field in the response to + // indicate whether the result was trimmed due to the limit or not. + RowLimit *int64 `json:"row_limit,omitempty"` + // Sets default schema for statement execution, similar to [`USE SCHEMA`] in + // SQL. + // + // [`USE SCHEMA`]: https://docs.databricks.com/sql/language-manual/sql-ref-syntax-ddl-use-schema.html + Schema *string `json:"schema,omitempty"` + // The SQL statement to execute. The statement can optionally be parameterized, + // see `parameters`. The maximum query text size is 16 MiB. + Statement *string `json:"statement,omitempty"` + // The time in seconds the call will wait for the statement's result set as + // `Ns`, where `N` can be set to 0 or to a value between 5 and 50. + // + // When set to `0s`, the statement will execute in asynchronous mode and the + // call will not wait for the execution to finish. In this case, the call + // returns directly with `PENDING` state and a statement ID which can be used + // for polling with :method:statementexecution/getStatement. + // + // When set between 5 and 50 seconds, the call will behave synchronously up to + // this timeout and wait for the statement execution to finish. If the execution + // finishes within this time, the call returns immediately with a manifest and + // result data (or a `FAILED` state in case of an execution error). If the + // statement takes longer to execute, `on_wait_timeout` determines what should + // happen after the timeout is reached. + WaitTimeout *string `json:"wait_timeout,omitempty"` + // Warehouse upon which to execute a statement. See also [What are SQL + // warehouses?] + // + // [What are SQL warehouses?]: https://docs.databricks.com/sql/admin/warehouse-type.html + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type ExternalLink struct { + // The number of bytes in the result chunk. This field is not available when + // using `INLINE` disposition. + ByteCount *int64 `json:"byte_count,omitempty"` + // The position within the sequence of result set chunks. + ChunkIndex *int `json:"chunk_index,omitempty"` + // Indicates the date-time that the given external link will expire and becomes + // invalid, after which point a new `external_link` must be requested. + Expiration *string `json:"expiration,omitempty"` + // A short-lived cloud-storage URL pointing to a chunk of result data, hosted by + // an external service, with a short expiration time (<= 15 minutes). As this + // URL contains a temporary credential, it should be considered sensitive and + // the client should not expose this URL in a log. + ExternalLink *string `json:"external_link,omitempty"` + // HTTP headers that must be included with a GET request to the `external_link`. + // Each header is provided as a key-value pair. Headers are typically used to + // pass a decryption key to the external service. The values of these headers + // should be considered sensitive and the client should not expose these values + // in a log. + HttpHeaders map[string]string `json:"http_headers,omitempty"` + // When fetching, provides the `chunk_index` for the _next_ chunk. If absent, + // indicates there are no more chunks. The next chunk can be fetched with a + // :method:statementexecution/getstatementresultchunkn request. + NextChunkIndex *int `json:"next_chunk_index,omitempty"` + // When fetching, provides a link to fetch the _next_ chunk. If absent, + // indicates there are no more chunks. This link is an absolute `path` to be + // joined with your `$DATABRICKS_HOST`, and should be treated as an opaque link. + // This is an alternative to using `next_chunk_index`. + NextChunkInternalLink *string `json:"next_chunk_internal_link,omitempty"` + // The number of rows within the result chunk. + RowCount *int64 `json:"row_count,omitempty"` + // The starting row offset within the result set. + RowOffset *int64 `json:"row_offset,omitempty"` +} + +type GetResultDataRequest struct { + ChunkIndex *int `json:"chunk_index,omitempty"` + // The statement ID is returned upon successfully submitting a SQL statement, + // and is a required reference for all subsequent calls. + StatementId *string `json:"statement_id,omitempty"` + // For warehouse statement URLs, this field contains the warehouse_id path + // parameter. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +type GetStatementResultRequest struct { + // The statement ID is returned upon successfully submitting a SQL statement, + // and is a required reference for all subsequent calls. + StatementId *string `json:"statement_id,omitempty"` + // For warehouse statement URLs, this field contains the warehouse_id path + // parameter. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +// * A query execution can be annotated with an optional key-value pair to allow +// users to attribute the executions by key and optional value to filter by. +// QueryTag is the user-facing representation.. +type QueryTag struct { + Key *string `json:"key,omitempty"` + Value *string `json:"value,omitempty"` +} + +// Contains the result data of a single chunk when using `INLINE` disposition. +// When using `EXTERNAL_LINKS` disposition, the array `external_links` is used +// instead to provide short-lived cloud-storage URLs to the result data in cloud +// storage. Exactly one of these alternatives is used. (While the +// `external_links` array prepares the API to return multiple links in a single +// response. Currently only a single link is returned.). +type ResultData struct { + // The number of bytes in the result chunk. This field is not available when + // using `INLINE` disposition. + ByteCount *int64 `json:"byte_count,omitempty"` + // The position within the sequence of result set chunks. + ChunkIndex *int `json:"chunk_index,omitempty"` + // The `JSON_ARRAY` format is an array of arrays of values, where each non-null + // value is formatted as a string. Null values are encoded as JSON `null`. + DataArray [][]json.RawMessage `json:"data_array,omitempty"` + ExternalLinks []ExternalLink `json:"external_links,omitempty"` + // When fetching, provides the `chunk_index` for the _next_ chunk. If absent, + // indicates there are no more chunks. The next chunk can be fetched with a + // :method:statementexecution/getstatementresultchunkn request. + NextChunkIndex *int `json:"next_chunk_index,omitempty"` + // When fetching, provides a link to fetch the _next_ chunk. If absent, + // indicates there are no more chunks. This link is an absolute `path` to be + // joined with your `$DATABRICKS_HOST`, and should be treated as an opaque link. + // This is an alternative to using `next_chunk_index`. + NextChunkInternalLink *string `json:"next_chunk_internal_link,omitempty"` + // The number of rows within the result chunk. + RowCount *int64 `json:"row_count,omitempty"` + // The starting row offset within the result set. + RowOffset *int64 `json:"row_offset,omitempty"` +} + +// The result manifest provides schema and metadata for the result set.. +type ResultManifest struct { + // Array of result set chunk metadata. + Chunks []ChunkInfo `json:"chunks,omitempty"` + Format Format `json:"format,omitempty"` + Schema *Schema `json:"schema,omitempty"` + // The total number of bytes in the result set. This field is not available when + // using `INLINE` disposition. + TotalByteCount *int64 `json:"total_byte_count,omitempty"` + // The total number of chunks that the result set has been divided into. + TotalChunkCount *int `json:"total_chunk_count,omitempty"` + // The total number of rows in the result set. + TotalRowCount *int64 `json:"total_row_count,omitempty"` + // Indicates whether the result is truncated due to `row_limit` or `byte_limit`. + Truncated *bool `json:"truncated,omitempty"` +} + +// The schema is an ordered list of column descriptions.. +type Schema struct { + ColumnCount *int `json:"column_count,omitempty"` + Columns []ColumnInfo `json:"columns,omitempty"` +} + +type ServiceError struct { + ErrorCode ServiceErrorCode `json:"error_code,omitempty"` + // A brief summary of the error condition. + Message *string `json:"message,omitempty"` +} + +type StatementParameter struct { + // The name of a parameter marker to be substituted in the statement. + Name *string `json:"name,omitempty"` + // The data type, given as a string. For example: `INT`, `STRING`, + // `DECIMAL(10,2)`. If no type is given the type is assumed to be `STRING`. + // Complex types, such as `ARRAY`, `MAP`, and `STRUCT` are not supported. For + // valid types, refer to the section [Data types] of the SQL language reference. + // + // [Data types]: https://docs.databricks.com/sql/language-manual/functions/cast.html + Type *string `json:"type,omitempty"` + // The value to substitute, represented as a string. If omitted, the value is + // interpreted as NULL. + Value *string `json:"value,omitempty"` +} + +type StatementResponse struct { + Manifest *ResultManifest `json:"manifest,omitempty"` + Result *ResultData `json:"result,omitempty"` + // The statement ID is returned upon successfully submitting a SQL statement, + // and is a required reference for all subsequent calls. + StatementId *string `json:"statement_id,omitempty"` + Status *StatementStatus `json:"status,omitempty"` +} + +// The status response includes execution state and if relevant, error +// information.. +type StatementStatus struct { + Error *ServiceError `json:"error,omitempty"` + // SQLSTATE error code returned when the statement execution fails. Only + // populated when the statement status is `FAILED`. + SqlState *string `json:"sql_state,omitempty"` + // Statement execution state: - `PENDING`: waiting for warehouse - `RUNNING`: + // running - `SUCCEEDED`: execution was successful, result data available for + // fetch - `FAILED`: execution failed; reason for failure described in + // accompanying error message - `CANCELED`: user canceled; can come from + // explicit cancel call, or timeout with `on_wait_timeout=CANCEL` - `CLOSED`: + // execution successful, and statement closed; result no longer available for + // fetch + State StatementStatus_State `json:"state,omitempty"` +} + +// CancelStatementRequestToSDK converts the mirror to the sdk-go type. +func CancelStatementRequestToSDK(w *CancelStatementRequest) (*sdk.CancelStatementRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CancelStatementRequest{} + out.StatementId = w.StatementId + out.WarehouseId = w.WarehouseId + return out, nil +} + +// CancelStatementRequestFromSDK converts the sdk-go type to the mirror. +func CancelStatementRequestFromSDK(v *sdk.CancelStatementRequest) (*CancelStatementRequest, error) { + if v == nil { + return nil, nil + } + out := &CancelStatementRequest{} + out.StatementId = v.StatementId + out.WarehouseId = v.WarehouseId + return out, nil +} + +// ChunkInfoToSDK converts the mirror to the sdk-go type. +func ChunkInfoToSDK(w *ChunkInfo) (*sdk.ChunkInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ChunkInfo{} + out.ChunkIndex = w.ChunkIndex + out.RowOffset = w.RowOffset + out.RowCount = w.RowCount + out.ByteCount = w.ByteCount + out.NextChunkIndex = w.NextChunkIndex + out.NextChunkInternalLink = w.NextChunkInternalLink + return out, nil +} + +// ChunkInfoFromSDK converts the sdk-go type to the mirror. +func ChunkInfoFromSDK(v *sdk.ChunkInfo) (*ChunkInfo, error) { + if v == nil { + return nil, nil + } + out := &ChunkInfo{} + out.ChunkIndex = v.ChunkIndex + out.RowOffset = v.RowOffset + out.RowCount = v.RowCount + out.ByteCount = v.ByteCount + out.NextChunkIndex = v.NextChunkIndex + out.NextChunkInternalLink = v.NextChunkInternalLink + return out, nil +} + +// ColumnInfoToSDK converts the mirror to the sdk-go type. +func ColumnInfoToSDK(w *ColumnInfo) (*sdk.ColumnInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnInfo{} + out.Name = w.Name + out.TypeText = w.TypeText + out.TypeName = w.TypeName + out.Position = w.Position + out.TypePrecision = w.TypePrecision + out.TypeScale = w.TypeScale + out.TypeIntervalType = w.TypeIntervalType + return out, nil +} + +// ColumnInfoFromSDK converts the sdk-go type to the mirror. +func ColumnInfoFromSDK(v *sdk.ColumnInfo) (*ColumnInfo, error) { + if v == nil { + return nil, nil + } + out := &ColumnInfo{} + out.Name = v.Name + out.TypeText = v.TypeText + out.TypeName = v.TypeName + out.Position = v.Position + out.TypePrecision = v.TypePrecision + out.TypeScale = v.TypeScale + out.TypeIntervalType = v.TypeIntervalType + return out, nil +} + +// ExecuteStatementRequestToSDK converts the mirror to the sdk-go type. +func ExecuteStatementRequestToSDK(w *ExecuteStatementRequest) (*sdk.ExecuteStatementRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExecuteStatementRequest{} + out.Statement = w.Statement + out.WarehouseId = w.WarehouseId + out.Catalog = w.Catalog + out.Schema = w.Schema + out.RowLimit = w.RowLimit + out.ByteLimit = w.ByteLimit + out.Format = w.Format + out.Disposition = w.Disposition + out.WaitTimeout = w.WaitTimeout + out.OnWaitTimeout = w.OnWaitTimeout + conv1, err := convertSlice(w.Parameters, StatementParameterToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExecuteStatementRequest.Parameters", err) + } + out.Parameters = conv1 + conv2, err := convertSlice(w.QueryTags, QueryTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExecuteStatementRequest.QueryTags", err) + } + out.QueryTags = conv2 + return out, nil +} + +// ExecuteStatementRequestFromSDK converts the sdk-go type to the mirror. +func ExecuteStatementRequestFromSDK(v *sdk.ExecuteStatementRequest) (*ExecuteStatementRequest, error) { + if v == nil { + return nil, nil + } + out := &ExecuteStatementRequest{} + out.Statement = v.Statement + out.WarehouseId = v.WarehouseId + out.Catalog = v.Catalog + out.Schema = v.Schema + out.RowLimit = v.RowLimit + out.ByteLimit = v.ByteLimit + out.Format = v.Format + out.Disposition = v.Disposition + out.WaitTimeout = v.WaitTimeout + out.OnWaitTimeout = v.OnWaitTimeout + conv3, err := convertSlice(v.Parameters, StatementParameterFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExecuteStatementRequest.Parameters", err) + } + out.Parameters = conv3 + conv4, err := convertSlice(v.QueryTags, QueryTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExecuteStatementRequest.QueryTags", err) + } + out.QueryTags = conv4 + return out, nil +} + +// ExternalLinkToSDK converts the mirror to the sdk-go type. +func ExternalLinkToSDK(w *ExternalLink) (*sdk.ExternalLink, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalLink{} + out.ExternalLink = w.ExternalLink + out.Expiration = w.Expiration + out.HttpHeaders = w.HttpHeaders + out.ChunkIndex = w.ChunkIndex + out.RowOffset = w.RowOffset + out.RowCount = w.RowCount + out.ByteCount = w.ByteCount + out.NextChunkIndex = w.NextChunkIndex + out.NextChunkInternalLink = w.NextChunkInternalLink + return out, nil +} + +// ExternalLinkFromSDK converts the sdk-go type to the mirror. +func ExternalLinkFromSDK(v *sdk.ExternalLink) (*ExternalLink, error) { + if v == nil { + return nil, nil + } + out := &ExternalLink{} + out.ExternalLink = v.ExternalLink + out.Expiration = v.Expiration + out.HttpHeaders = v.HttpHeaders + out.ChunkIndex = v.ChunkIndex + out.RowOffset = v.RowOffset + out.RowCount = v.RowCount + out.ByteCount = v.ByteCount + out.NextChunkIndex = v.NextChunkIndex + out.NextChunkInternalLink = v.NextChunkInternalLink + return out, nil +} + +// GetResultDataRequestToSDK converts the mirror to the sdk-go type. +func GetResultDataRequestToSDK(w *GetResultDataRequest) (*sdk.GetResultDataRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetResultDataRequest{} + out.StatementId = w.StatementId + out.ChunkIndex = w.ChunkIndex + out.WarehouseId = w.WarehouseId + return out, nil +} + +// GetResultDataRequestFromSDK converts the sdk-go type to the mirror. +func GetResultDataRequestFromSDK(v *sdk.GetResultDataRequest) (*GetResultDataRequest, error) { + if v == nil { + return nil, nil + } + out := &GetResultDataRequest{} + out.StatementId = v.StatementId + out.ChunkIndex = v.ChunkIndex + out.WarehouseId = v.WarehouseId + return out, nil +} + +// GetStatementResultRequestToSDK converts the mirror to the sdk-go type. +func GetStatementResultRequestToSDK(w *GetStatementResultRequest) (*sdk.GetStatementResultRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetStatementResultRequest{} + out.StatementId = w.StatementId + out.WarehouseId = w.WarehouseId + return out, nil +} + +// GetStatementResultRequestFromSDK converts the sdk-go type to the mirror. +func GetStatementResultRequestFromSDK(v *sdk.GetStatementResultRequest) (*GetStatementResultRequest, error) { + if v == nil { + return nil, nil + } + out := &GetStatementResultRequest{} + out.StatementId = v.StatementId + out.WarehouseId = v.WarehouseId + return out, nil +} + +// QueryTagToSDK converts the mirror to the sdk-go type. +func QueryTagToSDK(w *QueryTag) (*sdk.QueryTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// QueryTagFromSDK converts the sdk-go type to the mirror. +func QueryTagFromSDK(v *sdk.QueryTag) (*QueryTag, error) { + if v == nil { + return nil, nil + } + out := &QueryTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// ResultDataToSDK converts the mirror to the sdk-go type. +func ResultDataToSDK(w *ResultData) (*sdk.ResultData, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResultData{} + conv5, err := convertSlice(w.ExternalLinks, ExternalLinkToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultData.ExternalLinks", err) + } + out.ExternalLinks = conv5 + out.DataArray = w.DataArray + out.ChunkIndex = w.ChunkIndex + out.RowOffset = w.RowOffset + out.RowCount = w.RowCount + out.ByteCount = w.ByteCount + out.NextChunkIndex = w.NextChunkIndex + out.NextChunkInternalLink = w.NextChunkInternalLink + return out, nil +} + +// ResultDataFromSDK converts the sdk-go type to the mirror. +func ResultDataFromSDK(v *sdk.ResultData) (*ResultData, error) { + if v == nil { + return nil, nil + } + out := &ResultData{} + conv6, err := convertSlice(v.ExternalLinks, ExternalLinkFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultData.ExternalLinks", err) + } + out.ExternalLinks = conv6 + out.DataArray = v.DataArray + out.ChunkIndex = v.ChunkIndex + out.RowOffset = v.RowOffset + out.RowCount = v.RowCount + out.ByteCount = v.ByteCount + out.NextChunkIndex = v.NextChunkIndex + out.NextChunkInternalLink = v.NextChunkInternalLink + return out, nil +} + +// ResultManifestToSDK converts the mirror to the sdk-go type. +func ResultManifestToSDK(w *ResultManifest) (*sdk.ResultManifest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResultManifest{} + out.Format = w.Format + conv7, err := SchemaToSDK(w.Schema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.Schema", err) + } + out.Schema = conv7 + out.TotalChunkCount = w.TotalChunkCount + conv8, err := convertSlice(w.Chunks, ChunkInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.Chunks", err) + } + out.Chunks = conv8 + out.TotalRowCount = w.TotalRowCount + out.TotalByteCount = w.TotalByteCount + out.Truncated = w.Truncated + return out, nil +} + +// ResultManifestFromSDK converts the sdk-go type to the mirror. +func ResultManifestFromSDK(v *sdk.ResultManifest) (*ResultManifest, error) { + if v == nil { + return nil, nil + } + out := &ResultManifest{} + out.Format = v.Format + conv9, err := SchemaFromSDK(v.Schema) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.Schema", err) + } + out.Schema = conv9 + out.TotalChunkCount = v.TotalChunkCount + conv10, err := convertSlice(v.Chunks, ChunkInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.Chunks", err) + } + out.Chunks = conv10 + out.TotalRowCount = v.TotalRowCount + out.TotalByteCount = v.TotalByteCount + out.Truncated = v.Truncated + return out, nil +} + +// SchemaToSDK converts the mirror to the sdk-go type. +func SchemaToSDK(w *Schema) (*sdk.Schema, error) { + if w == nil { + return nil, nil + } + out := &sdk.Schema{} + out.ColumnCount = w.ColumnCount + conv11, err := convertSlice(w.Columns, ColumnInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Schema.Columns", err) + } + out.Columns = conv11 + return out, nil +} + +// SchemaFromSDK converts the sdk-go type to the mirror. +func SchemaFromSDK(v *sdk.Schema) (*Schema, error) { + if v == nil { + return nil, nil + } + out := &Schema{} + out.ColumnCount = v.ColumnCount + conv12, err := convertSlice(v.Columns, ColumnInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Schema.Columns", err) + } + out.Columns = conv12 + return out, nil +} + +// ServiceErrorToSDK converts the mirror to the sdk-go type. +func ServiceErrorToSDK(w *ServiceError) (*sdk.ServiceError, error) { + if w == nil { + return nil, nil + } + out := &sdk.ServiceError{} + out.ErrorCode = w.ErrorCode + out.Message = w.Message + return out, nil +} + +// ServiceErrorFromSDK converts the sdk-go type to the mirror. +func ServiceErrorFromSDK(v *sdk.ServiceError) (*ServiceError, error) { + if v == nil { + return nil, nil + } + out := &ServiceError{} + out.ErrorCode = v.ErrorCode + out.Message = v.Message + return out, nil +} + +// StatementParameterToSDK converts the mirror to the sdk-go type. +func StatementParameterToSDK(w *StatementParameter) (*sdk.StatementParameter, error) { + if w == nil { + return nil, nil + } + out := &sdk.StatementParameter{} + out.Name = w.Name + out.Value = w.Value + out.Type = w.Type + return out, nil +} + +// StatementParameterFromSDK converts the sdk-go type to the mirror. +func StatementParameterFromSDK(v *sdk.StatementParameter) (*StatementParameter, error) { + if v == nil { + return nil, nil + } + out := &StatementParameter{} + out.Name = v.Name + out.Value = v.Value + out.Type = v.Type + return out, nil +} + +// StatementResponseToSDK converts the mirror to the sdk-go type. +func StatementResponseToSDK(w *StatementResponse) (*sdk.StatementResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.StatementResponse{} + out.StatementId = w.StatementId + conv13, err := StatementStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementResponse.Status", err) + } + out.Status = conv13 + conv14, err := ResultManifestToSDK(w.Manifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementResponse.Manifest", err) + } + out.Manifest = conv14 + conv15, err := ResultDataToSDK(w.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementResponse.Result", err) + } + out.Result = conv15 + return out, nil +} + +// StatementResponseFromSDK converts the sdk-go type to the mirror. +func StatementResponseFromSDK(v *sdk.StatementResponse) (*StatementResponse, error) { + if v == nil { + return nil, nil + } + out := &StatementResponse{} + out.StatementId = v.StatementId + conv16, err := StatementStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementResponse.Status", err) + } + out.Status = conv16 + conv17, err := ResultManifestFromSDK(v.Manifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementResponse.Manifest", err) + } + out.Manifest = conv17 + conv18, err := ResultDataFromSDK(v.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementResponse.Result", err) + } + out.Result = conv18 + return out, nil +} + +// StatementStatusToSDK converts the mirror to the sdk-go type. +func StatementStatusToSDK(w *StatementStatus) (*sdk.StatementStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.StatementStatus{} + out.State = w.State + conv19, err := ServiceErrorToSDK(w.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementStatus.Error", err) + } + out.Error = conv19 + out.SqlState = w.SqlState + return out, nil +} + +// StatementStatusFromSDK converts the sdk-go type to the mirror. +func StatementStatusFromSDK(v *sdk.StatementStatus) (*StatementStatus, error) { + if v == nil { + return nil, nil + } + out := &StatementStatus{} + out.State = v.State + conv20, err := ServiceErrorFromSDK(v.Error) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StatementStatus.Error", err) + } + out.Error = conv20 + out.SqlState = v.SqlState + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/storageconfigurations/v1/types.generated.go b/libs/sdktypes/storageconfigurations/v1/types.generated.go new file mode 100644 index 00000000000..386b737aa5a --- /dev/null +++ b/libs/sdktypes/storageconfigurations/v1/types.generated.go @@ -0,0 +1,141 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/storageconfigurations/v1. DO NOT EDIT. + +package storageconfigurations + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/storageconfigurations/v1" +) + +type CreateStorageConfigurationRequest struct { + AccountId *string `json:"account_id,omitempty"` + // Optional IAM role that is used to access the workspace catalog which is + // created during workspace creation for UC by Default. If a storage + // configuration with this field populated is used to create a workspace, then a + // workspace catalog is created together with the workspace. The workspace + // catalog shares the root bucket with internal workspace storage (including + // DBFS root) but uses a dedicated bucket path prefix. + RoleArn *string `json:"role_arn,omitempty"` + // Root S3 bucket information. + RootBucketInfo *RootBucketInfo `json:"root_bucket_info,omitempty"` + // The human-readable name of the storage configuration. + StorageConfigurationName *string `json:"storage_configuration_name,omitempty"` +} + +type RootBucketInfo struct { + // Name of the S3 bucket + BucketName *string `json:"bucket_name,omitempty"` +} + +type StorageConfiguration struct { + // The account ID associated with this storage configuration. + AccountId *string `json:"account_id,omitempty"` + // Time in epoch milliseconds when the storage configuration was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // Optional IAM role that is used to access the workspace catalog which is + // created during workspace creation for UC by Default. If a storage + // configuration with this field populated is used to create a workspace, then a + // workspace catalog is created together with the workspace. The workspace + // catalog shares the root bucket with internal workspace storage (including + // DBFS root) but uses a dedicated bucket path prefix. + RoleArn *string `json:"role_arn,omitempty"` + // The root bucket information for the storage configuration. + RootBucketInfo *RootBucketInfo `json:"root_bucket_info,omitempty"` + // storage configuration ID. + StorageConfigurationId *string `json:"storage_configuration_id,omitempty"` + // The human-readable name of the storage configuration. + StorageConfigurationName *string `json:"storage_configuration_name,omitempty"` +} + +// CreateStorageConfigurationRequestToSDK converts the mirror to the sdk-go type. +func CreateStorageConfigurationRequestToSDK(w *CreateStorageConfigurationRequest) (*sdk.CreateStorageConfigurationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateStorageConfigurationRequest{} + out.AccountId = w.AccountId + out.StorageConfigurationName = w.StorageConfigurationName + conv1, err := RootBucketInfoToSDK(w.RootBucketInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageConfigurationRequest.RootBucketInfo", err) + } + out.RootBucketInfo = conv1 + out.RoleArn = w.RoleArn + return out, nil +} + +// CreateStorageConfigurationRequestFromSDK converts the sdk-go type to the mirror. +func CreateStorageConfigurationRequestFromSDK(v *sdk.CreateStorageConfigurationRequest) (*CreateStorageConfigurationRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateStorageConfigurationRequest{} + out.AccountId = v.AccountId + out.StorageConfigurationName = v.StorageConfigurationName + conv2, err := RootBucketInfoFromSDK(v.RootBucketInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageConfigurationRequest.RootBucketInfo", err) + } + out.RootBucketInfo = conv2 + out.RoleArn = v.RoleArn + return out, nil +} + +// RootBucketInfoToSDK converts the mirror to the sdk-go type. +func RootBucketInfoToSDK(w *RootBucketInfo) (*sdk.RootBucketInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.RootBucketInfo{} + out.BucketName = w.BucketName + return out, nil +} + +// RootBucketInfoFromSDK converts the sdk-go type to the mirror. +func RootBucketInfoFromSDK(v *sdk.RootBucketInfo) (*RootBucketInfo, error) { + if v == nil { + return nil, nil + } + out := &RootBucketInfo{} + out.BucketName = v.BucketName + return out, nil +} + +// StorageConfigurationToSDK converts the mirror to the sdk-go type. +func StorageConfigurationToSDK(w *StorageConfiguration) (*sdk.StorageConfiguration, error) { + if w == nil { + return nil, nil + } + out := &sdk.StorageConfiguration{} + out.StorageConfigurationId = w.StorageConfigurationId + out.AccountId = w.AccountId + conv3, err := RootBucketInfoToSDK(w.RootBucketInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageConfiguration.RootBucketInfo", err) + } + out.RootBucketInfo = conv3 + out.StorageConfigurationName = w.StorageConfigurationName + out.CreationTime = w.CreationTime + out.RoleArn = w.RoleArn + return out, nil +} + +// StorageConfigurationFromSDK converts the sdk-go type to the mirror. +func StorageConfigurationFromSDK(v *sdk.StorageConfiguration) (*StorageConfiguration, error) { + if v == nil { + return nil, nil + } + out := &StorageConfiguration{} + out.StorageConfigurationId = v.StorageConfigurationId + out.AccountId = v.AccountId + conv4, err := RootBucketInfoFromSDK(v.RootBucketInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageConfiguration.RootBucketInfo", err) + } + out.RootBucketInfo = conv4 + out.StorageConfigurationName = v.StorageConfigurationName + out.CreationTime = v.CreationTime + out.RoleArn = v.RoleArn + return out, nil +} diff --git a/libs/sdktypes/supervisoragents/v1/types.generated.go b/libs/sdktypes/supervisoragents/v1/types.generated.go new file mode 100644 index 00000000000..2a5c3926037 --- /dev/null +++ b/libs/sdktypes/supervisoragents/v1/types.generated.go @@ -0,0 +1,921 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/supervisoragents/v1. DO NOT EDIT. + +package supervisoragents + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/supervisoragents/v1" + strings "strings" +) + +// app. Supported app: custom mcp, custom agent.. +type App struct { + // App name + Name *string `json:"name,omitempty"` +} + +// Create an example.. +type CreateExampleRequest struct { + // The example to create under the parent Supervisor Agent. + Example *Example `json:"example,omitempty"` + // Parent resource where this example will be created. Format: + // supervisor-agents/{supervisor_agent_id} + Parent *string `json:"parent,omitempty"` +} + +type CreateSupervisorAgentRequest struct { + // The Supervisor Agent to create. + SupervisorAgent *SupervisorAgent `json:"supervisor_agent,omitempty"` +} + +type CreateToolRequest struct { + // Parent resource where this tool will be created. Format: + // supervisor-agents/{supervisor_agent_id} + Parent *string `json:"parent,omitempty"` + Tool *Tool `json:"tool,omitempty"` + // The ID to use for the tool, which will become the final component of the + // tool's resource name. + ToolId *string `json:"tool_id,omitempty"` +} + +// An example associated with a Supervisor Agent. Contains a question and +// guidelines for how the agent should respond.. +type Example struct { + // The universally unique identifier (UUID) of the example. + ExampleId *string `json:"example_id,omitempty"` + // Guidelines for answering the question. + Guidelines []string `json:"guidelines,omitempty"` + // Full resource name: + // supervisor-agents/{supervisor_agent_id}/examples/{example_id} + Name *string `json:"name,omitempty"` + // The example question. + Question *string `json:"question,omitempty"` +} + +type GenieSpace struct { + // Deprecated: use space_id instead. Still REQUIRED for backward compatibility + // until a future API version removes it. + Id *string `json:"id,omitempty"` +} + +type KnowledgeAssistant struct { + // The ID of the knowledge assistant. + KnowledgeAssistantId *string `json:"knowledge_assistant_id,omitempty"` + // Deprecated: use knowledge_assistant_id instead. + ServingEndpointName *string `json:"serving_endpoint_name,omitempty"` +} + +// List examples.. +type ListExamplesRequest struct { + // The maximum number of examples to return. If unspecified, at most 100 + // examples will be returned. The maximum value is 100; values above 100 will be + // coerced to 100. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous `ListExamples` call. Provide this to + // retrieve the subsequent page. If unspecified, the first page will be + // returned. + PageToken *string `json:"page_token,omitempty"` + // Parent resource to list from. Format: supervisor-agents/{supervisor_agent_id} + Parent *string `json:"parent,omitempty"` +} + +// A list of Supervisor Agent examples.. +type ListExamplesResponse struct { + Examples []Example `json:"examples,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListSupervisorAgentsRequest struct { + // The maximum number of supervisor agents to return. If unspecified, at most + // 100 supervisor agents will be returned. The maximum value is 100; values + // above 100 will be coerced to 100. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous `ListSupervisorAgents` call. Provide + // this to retrieve the subsequent page. If unspecified, the first page will be + // returned. + PageToken *string `json:"page_token,omitempty"` +} + +type ListSupervisorAgentsResponse struct { + // A token that can be sent as `page_token` to retrieve the next page. If this + // field is omitted, there are no subsequent pages. + NextPageToken *string `json:"next_page_token,omitempty"` + SupervisorAgents []SupervisorAgent `json:"supervisor_agents,omitempty"` +} + +type ListToolsRequest struct { + PageSize *int `json:"page_size,omitempty"` + PageToken *string `json:"page_token,omitempty"` + // Parent resource to list from. Format: supervisor-agents/{supervisor_agent_id} + Parent *string `json:"parent,omitempty"` +} + +type ListToolsResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + Tools []Tool `json:"tools,omitempty"` +} + +type SupervisorAgent struct { + // Creation timestamp. + CreateTime *types.Time `json:"create_time,omitempty"` + // The creator of the Supervisor Agent. + Creator *string `json:"creator,omitempty"` + // Description of what this agent can do (user-facing). + Description *string `json:"description,omitempty"` + // The display name of the Supervisor Agent, unique at workspace level. + DisplayName *string `json:"display_name,omitempty"` + // The name of the supervisor agent's serving endpoint. + EndpointName *string `json:"endpoint_name,omitempty"` + // The MLflow experiment ID. + ExperimentId *string `json:"experiment_id,omitempty"` + // Deprecated: Use supervisor_agent_id instead. + Id *string `json:"id,omitempty"` + // Optional natural-language instructions for the supervisor agent. + Instructions *string `json:"instructions,omitempty"` + // The resource name of the SupervisorAgent. Format: + // supervisor-agents/{supervisor_agent_id} + Name *string `json:"name,omitempty"` + // The universally unique identifier (UUID) of the Supervisor Agent. + SupervisorAgentId *string `json:"supervisor_agent_id,omitempty"` +} + +type Tool struct { + App *App `json:"app,omitempty"` + // Description of what this tool does (user-facing). + Description *string `json:"description,omitempty"` + GenieSpace *GenieSpace `json:"genie_space,omitempty"` + // Deprecated: Use tool_id instead. + Id *string `json:"id,omitempty"` + KnowledgeAssistant *KnowledgeAssistant `json:"knowledge_assistant,omitempty"` + // Full resource name: supervisor-agents/{supervisor_agent_id}/tools/{tool_id} + Name *string `json:"name,omitempty"` + // User specified id of the Tool. + ToolId *string `json:"tool_id,omitempty"` + // Tool type. Must be one of: "genie_space", "knowledge_assistant", + // "uc_function", "uc_connection", "uc_mcp", "app", "volume", "dashboard", + // "serving_endpoint", "table", "vector_search_index", "catalog", "schema", + // "supervisor_agent", "databricks_web_search", "skill". The legacy values + // "lakeview_dashboard", "uc_table", and "web_search" are also accepted and + // remain equivalent to "dashboard", "table", and "databricks_web_search" + // respectively. The "databricks_web_search" tool_type maps to the `web_search` + // spec field. + ToolType *string `json:"tool_type,omitempty"` + UcConnection *UcConnection `json:"uc_connection,omitempty"` + UcFunction *UcFunction `json:"uc_function,omitempty"` + Volume *Volume `json:"volume,omitempty"` +} + +// Databricks UC connection. Supported connection: external mcp server.. +type UcConnection struct { + Name *string `json:"name,omitempty"` +} + +type UcFunction struct { + // Full uc function name + Name *string `json:"name,omitempty"` +} + +// Update an example.. +type UpdateExampleRequest struct { + Example *Example `json:"example,omitempty"` + // The resource name of the example to update. Format: + // supervisor-agents/{supervisor_agent_id}/examples/{example_id} + Name *string `json:"name,omitempty"` + // Comma-delimited list of fields to update on the example. Allowed values: + // `question`, `guidelines`. Examples: - `question` - `question,guidelines` + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateSupervisorAgentRequest struct { + // The SupervisorAgent to update. + SupervisorAgent *SupervisorAgent `json:"supervisor_agent,omitempty"` + // Field mask for fields to be updated. + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateToolRequest struct { + // The Tool to update. + Tool *Tool `json:"tool,omitempty"` + // Field mask for fields to be updated. + UpdateMask *string `json:"update_mask,omitempty"` +} + +type Volume struct { + // Full uc volume name + Name *string `json:"name,omitempty"` +} + +// AppToSDK converts the mirror to the sdk-go type. +func AppToSDK(w *App) (*sdk.App, error) { + if w == nil { + return nil, nil + } + out := &sdk.App{} + out.Name = w.Name + return out, nil +} + +// AppFromSDK converts the sdk-go type to the mirror. +func AppFromSDK(v *sdk.App) (*App, error) { + if v == nil { + return nil, nil + } + out := &App{} + out.Name = v.Name + return out, nil +} + +// CreateExampleRequestToSDK converts the mirror to the sdk-go type. +func CreateExampleRequestToSDK(w *CreateExampleRequest) (*sdk.CreateExampleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateExampleRequest{} + out.Parent = w.Parent + conv1, err := ExampleToSDK(w.Example) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExampleRequest.Example", err) + } + out.Example = conv1 + return out, nil +} + +// CreateExampleRequestFromSDK converts the sdk-go type to the mirror. +func CreateExampleRequestFromSDK(v *sdk.CreateExampleRequest) (*CreateExampleRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateExampleRequest{} + out.Parent = v.Parent + conv2, err := ExampleFromSDK(v.Example) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExampleRequest.Example", err) + } + out.Example = conv2 + return out, nil +} + +// CreateSupervisorAgentRequestToSDK converts the mirror to the sdk-go type. +func CreateSupervisorAgentRequestToSDK(w *CreateSupervisorAgentRequest) (*sdk.CreateSupervisorAgentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateSupervisorAgentRequest{} + conv3, err := SupervisorAgentToSDK(w.SupervisorAgent) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSupervisorAgentRequest.SupervisorAgent", err) + } + out.SupervisorAgent = conv3 + return out, nil +} + +// CreateSupervisorAgentRequestFromSDK converts the sdk-go type to the mirror. +func CreateSupervisorAgentRequestFromSDK(v *sdk.CreateSupervisorAgentRequest) (*CreateSupervisorAgentRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateSupervisorAgentRequest{} + conv4, err := SupervisorAgentFromSDK(v.SupervisorAgent) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSupervisorAgentRequest.SupervisorAgent", err) + } + out.SupervisorAgent = conv4 + return out, nil +} + +// CreateToolRequestToSDK converts the mirror to the sdk-go type. +func CreateToolRequestToSDK(w *CreateToolRequest) (*sdk.CreateToolRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateToolRequest{} + out.Parent = w.Parent + conv5, err := ToolToSDK(w.Tool) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateToolRequest.Tool", err) + } + out.Tool = conv5 + out.ToolId = w.ToolId + return out, nil +} + +// CreateToolRequestFromSDK converts the sdk-go type to the mirror. +func CreateToolRequestFromSDK(v *sdk.CreateToolRequest) (*CreateToolRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateToolRequest{} + out.Parent = v.Parent + conv6, err := ToolFromSDK(v.Tool) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateToolRequest.Tool", err) + } + out.Tool = conv6 + out.ToolId = v.ToolId + return out, nil +} + +// ExampleToSDK converts the mirror to the sdk-go type. +func ExampleToSDK(w *Example) (*sdk.Example, error) { + if w == nil { + return nil, nil + } + out := &sdk.Example{} + out.Name = w.Name + out.Question = w.Question + out.Guidelines = w.Guidelines + out.ExampleId = w.ExampleId + return out, nil +} + +// ExampleFromSDK converts the sdk-go type to the mirror. +func ExampleFromSDK(v *sdk.Example) (*Example, error) { + if v == nil { + return nil, nil + } + out := &Example{} + out.Name = v.Name + out.Question = v.Question + out.Guidelines = v.Guidelines + out.ExampleId = v.ExampleId + return out, nil +} + +// GenieSpaceToSDK converts the mirror to the sdk-go type. +func GenieSpaceToSDK(w *GenieSpace) (*sdk.GenieSpace, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenieSpace{} + out.Id = w.Id + return out, nil +} + +// GenieSpaceFromSDK converts the sdk-go type to the mirror. +func GenieSpaceFromSDK(v *sdk.GenieSpace) (*GenieSpace, error) { + if v == nil { + return nil, nil + } + out := &GenieSpace{} + out.Id = v.Id + return out, nil +} + +// KnowledgeAssistantToSDK converts the mirror to the sdk-go type. +func KnowledgeAssistantToSDK(w *KnowledgeAssistant) (*sdk.KnowledgeAssistant, error) { + if w == nil { + return nil, nil + } + out := &sdk.KnowledgeAssistant{} + out.ServingEndpointName = w.ServingEndpointName + out.KnowledgeAssistantId = w.KnowledgeAssistantId + return out, nil +} + +// KnowledgeAssistantFromSDK converts the sdk-go type to the mirror. +func KnowledgeAssistantFromSDK(v *sdk.KnowledgeAssistant) (*KnowledgeAssistant, error) { + if v == nil { + return nil, nil + } + out := &KnowledgeAssistant{} + out.ServingEndpointName = v.ServingEndpointName + out.KnowledgeAssistantId = v.KnowledgeAssistantId + return out, nil +} + +// ListExamplesRequestToSDK converts the mirror to the sdk-go type. +func ListExamplesRequestToSDK(w *ListExamplesRequest) (*sdk.ListExamplesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExamplesRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListExamplesRequestFromSDK converts the sdk-go type to the mirror. +func ListExamplesRequestFromSDK(v *sdk.ListExamplesRequest) (*ListExamplesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListExamplesRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListExamplesResponseToSDK converts the mirror to the sdk-go type. +func ListExamplesResponseToSDK(w *ListExamplesResponse) (*sdk.ListExamplesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExamplesResponse{} + conv7, err := convertSlice(w.Examples, ExampleToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExamplesResponse.Examples", err) + } + out.Examples = conv7 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListExamplesResponseFromSDK converts the sdk-go type to the mirror. +func ListExamplesResponseFromSDK(v *sdk.ListExamplesResponse) (*ListExamplesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListExamplesResponse{} + conv8, err := convertSlice(v.Examples, ExampleFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExamplesResponse.Examples", err) + } + out.Examples = conv8 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListSupervisorAgentsRequestToSDK converts the mirror to the sdk-go type. +func ListSupervisorAgentsRequestToSDK(w *ListSupervisorAgentsRequest) (*sdk.ListSupervisorAgentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSupervisorAgentsRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListSupervisorAgentsRequestFromSDK converts the sdk-go type to the mirror. +func ListSupervisorAgentsRequestFromSDK(v *sdk.ListSupervisorAgentsRequest) (*ListSupervisorAgentsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSupervisorAgentsRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListSupervisorAgentsResponseToSDK converts the mirror to the sdk-go type. +func ListSupervisorAgentsResponseToSDK(w *ListSupervisorAgentsResponse) (*sdk.ListSupervisorAgentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSupervisorAgentsResponse{} + conv9, err := convertSlice(w.SupervisorAgents, SupervisorAgentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSupervisorAgentsResponse.SupervisorAgents", err) + } + out.SupervisorAgents = conv9 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSupervisorAgentsResponseFromSDK converts the sdk-go type to the mirror. +func ListSupervisorAgentsResponseFromSDK(v *sdk.ListSupervisorAgentsResponse) (*ListSupervisorAgentsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSupervisorAgentsResponse{} + conv10, err := convertSlice(v.SupervisorAgents, SupervisorAgentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSupervisorAgentsResponse.SupervisorAgents", err) + } + out.SupervisorAgents = conv10 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListToolsRequestToSDK converts the mirror to the sdk-go type. +func ListToolsRequestToSDK(w *ListToolsRequest) (*sdk.ListToolsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListToolsRequest{} + out.Parent = w.Parent + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListToolsRequestFromSDK converts the sdk-go type to the mirror. +func ListToolsRequestFromSDK(v *sdk.ListToolsRequest) (*ListToolsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListToolsRequest{} + out.Parent = v.Parent + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListToolsResponseToSDK converts the mirror to the sdk-go type. +func ListToolsResponseToSDK(w *ListToolsResponse) (*sdk.ListToolsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListToolsResponse{} + conv11, err := convertSlice(w.Tools, ToolToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListToolsResponse.Tools", err) + } + out.Tools = conv11 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListToolsResponseFromSDK converts the sdk-go type to the mirror. +func ListToolsResponseFromSDK(v *sdk.ListToolsResponse) (*ListToolsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListToolsResponse{} + conv12, err := convertSlice(v.Tools, ToolFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListToolsResponse.Tools", err) + } + out.Tools = conv12 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SupervisorAgentToSDK converts the mirror to the sdk-go type. +func SupervisorAgentToSDK(w *SupervisorAgent) (*sdk.SupervisorAgent, error) { + if w == nil { + return nil, nil + } + out := &sdk.SupervisorAgent{} + out.Name = w.Name + out.DisplayName = w.DisplayName + out.Description = w.Description + out.Instructions = w.Instructions + out.Id = w.Id + out.SupervisorAgentId = w.SupervisorAgentId + out.Creator = w.Creator + out.CreateTime = w.CreateTime + out.EndpointName = w.EndpointName + out.ExperimentId = w.ExperimentId + return out, nil +} + +// SupervisorAgentFromSDK converts the sdk-go type to the mirror. +func SupervisorAgentFromSDK(v *sdk.SupervisorAgent) (*SupervisorAgent, error) { + if v == nil { + return nil, nil + } + out := &SupervisorAgent{} + out.Name = v.Name + out.DisplayName = v.DisplayName + out.Description = v.Description + out.Instructions = v.Instructions + out.Id = v.Id + out.SupervisorAgentId = v.SupervisorAgentId + out.Creator = v.Creator + out.CreateTime = v.CreateTime + out.EndpointName = v.EndpointName + out.ExperimentId = v.ExperimentId + return out, nil +} + +// ToolToSDK converts the mirror to the sdk-go type. +func ToolToSDK(w *Tool) (*sdk.Tool, error) { + if w == nil { + return nil, nil + } + out := &sdk.Tool{} + out.Name = w.Name + out.Id = w.Id + out.ToolType = w.ToolType + { + var members []string + if w.GenieSpace != nil { + members = append(members, "genie_space") + } + if w.KnowledgeAssistant != nil { + members = append(members, "knowledge_assistant") + } + if w.UcFunction != nil { + members = append(members, "uc_function") + } + if w.App != nil { + members = append(members, "app") + } + if w.Volume != nil { + members = append(members, "volume") + } + if w.UcConnection != nil { + members = append(members, "uc_connection") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.GenieSpace != nil: + conv13, err := GenieSpaceToSDK(w.GenieSpace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Tool.Spec", err) + } + out.Spec = &sdk.Tool_Spec_GenieSpace{GenieSpace: *conv13} + case w.KnowledgeAssistant != nil: + conv14, err := KnowledgeAssistantToSDK(w.KnowledgeAssistant) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Tool.Spec", err) + } + out.Spec = &sdk.Tool_Spec_KnowledgeAssistant{KnowledgeAssistant: *conv14} + case w.UcFunction != nil: + conv15, err := UcFunctionToSDK(w.UcFunction) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Tool.Spec", err) + } + out.Spec = &sdk.Tool_Spec_UcFunction{UcFunction: *conv15} + case w.App != nil: + conv16, err := AppToSDK(w.App) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Tool.Spec", err) + } + out.Spec = &sdk.Tool_Spec_App{App: *conv16} + case w.Volume != nil: + conv17, err := VolumeToSDK(w.Volume) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Tool.Spec", err) + } + out.Spec = &sdk.Tool_Spec_Volume{Volume: *conv17} + case w.UcConnection != nil: + conv18, err := UcConnectionToSDK(w.UcConnection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Tool.Spec", err) + } + out.Spec = &sdk.Tool_Spec_UcConnection{UcConnection: *conv18} + } + out.Description = w.Description + out.ToolId = w.ToolId + return out, nil +} + +// ToolFromSDK converts the sdk-go type to the mirror. +func ToolFromSDK(v *sdk.Tool) (*Tool, error) { + if v == nil { + return nil, nil + } + out := &Tool{} + out.Name = v.Name + out.Id = v.Id + out.ToolType = v.ToolType + switch value := v.Spec.(type) { + case *sdk.Tool_Spec_GenieSpace: + if value != nil { + conv19, err := GenieSpaceFromSDK(&value.GenieSpace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Tool.Spec", err) + } + out.GenieSpace = conv19 + } + case *sdk.Tool_Spec_KnowledgeAssistant: + if value != nil { + conv20, err := KnowledgeAssistantFromSDK(&value.KnowledgeAssistant) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Tool.Spec", err) + } + out.KnowledgeAssistant = conv20 + } + case *sdk.Tool_Spec_UcFunction: + if value != nil { + conv21, err := UcFunctionFromSDK(&value.UcFunction) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Tool.Spec", err) + } + out.UcFunction = conv21 + } + case *sdk.Tool_Spec_App: + if value != nil { + conv22, err := AppFromSDK(&value.App) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Tool.Spec", err) + } + out.App = conv22 + } + case *sdk.Tool_Spec_Volume: + if value != nil { + conv23, err := VolumeFromSDK(&value.Volume) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Tool.Spec", err) + } + out.Volume = conv23 + } + case *sdk.Tool_Spec_UcConnection: + if value != nil { + conv24, err := UcConnectionFromSDK(&value.UcConnection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Tool.Spec", err) + } + out.UcConnection = conv24 + } + } + out.Description = v.Description + out.ToolId = v.ToolId + return out, nil +} + +// UcConnectionToSDK converts the mirror to the sdk-go type. +func UcConnectionToSDK(w *UcConnection) (*sdk.UcConnection, error) { + if w == nil { + return nil, nil + } + out := &sdk.UcConnection{} + out.Name = w.Name + return out, nil +} + +// UcConnectionFromSDK converts the sdk-go type to the mirror. +func UcConnectionFromSDK(v *sdk.UcConnection) (*UcConnection, error) { + if v == nil { + return nil, nil + } + out := &UcConnection{} + out.Name = v.Name + return out, nil +} + +// UcFunctionToSDK converts the mirror to the sdk-go type. +func UcFunctionToSDK(w *UcFunction) (*sdk.UcFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.UcFunction{} + out.Name = w.Name + return out, nil +} + +// UcFunctionFromSDK converts the sdk-go type to the mirror. +func UcFunctionFromSDK(v *sdk.UcFunction) (*UcFunction, error) { + if v == nil { + return nil, nil + } + out := &UcFunction{} + out.Name = v.Name + return out, nil +} + +// UpdateExampleRequestToSDK converts the mirror to the sdk-go type. +func UpdateExampleRequestToSDK(w *UpdateExampleRequest) (*sdk.UpdateExampleRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateExampleRequest{} + out.Name = w.Name + conv25, err := ExampleToSDK(w.Example) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExampleRequest.Example", err) + } + out.Example = conv25 + mask26, err := fieldMaskFromString[sdk.Example](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExampleRequest.UpdateMask", err) + } + out.UpdateMask = mask26 + return out, nil +} + +// UpdateExampleRequestFromSDK converts the sdk-go type to the mirror. +func UpdateExampleRequestFromSDK(v *sdk.UpdateExampleRequest) (*UpdateExampleRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateExampleRequest{} + out.Name = v.Name + conv27, err := ExampleFromSDK(v.Example) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExampleRequest.Example", err) + } + out.Example = conv27 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateSupervisorAgentRequestToSDK converts the mirror to the sdk-go type. +func UpdateSupervisorAgentRequestToSDK(w *UpdateSupervisorAgentRequest) (*sdk.UpdateSupervisorAgentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateSupervisorAgentRequest{} + conv28, err := SupervisorAgentToSDK(w.SupervisorAgent) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSupervisorAgentRequest.SupervisorAgent", err) + } + out.SupervisorAgent = conv28 + mask29, err := fieldMaskFromString[sdk.SupervisorAgent](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSupervisorAgentRequest.UpdateMask", err) + } + out.UpdateMask = mask29 + return out, nil +} + +// UpdateSupervisorAgentRequestFromSDK converts the sdk-go type to the mirror. +func UpdateSupervisorAgentRequestFromSDK(v *sdk.UpdateSupervisorAgentRequest) (*UpdateSupervisorAgentRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateSupervisorAgentRequest{} + conv30, err := SupervisorAgentFromSDK(v.SupervisorAgent) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSupervisorAgentRequest.SupervisorAgent", err) + } + out.SupervisorAgent = conv30 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateToolRequestToSDK converts the mirror to the sdk-go type. +func UpdateToolRequestToSDK(w *UpdateToolRequest) (*sdk.UpdateToolRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateToolRequest{} + conv31, err := ToolToSDK(w.Tool) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateToolRequest.Tool", err) + } + out.Tool = conv31 + mask32, err := fieldMaskFromString[sdk.Tool](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateToolRequest.UpdateMask", err) + } + out.UpdateMask = mask32 + return out, nil +} + +// UpdateToolRequestFromSDK converts the sdk-go type to the mirror. +func UpdateToolRequestFromSDK(v *sdk.UpdateToolRequest) (*UpdateToolRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateToolRequest{} + conv33, err := ToolFromSDK(v.Tool) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateToolRequest.Tool", err) + } + out.Tool = conv33 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// VolumeToSDK converts the mirror to the sdk-go type. +func VolumeToSDK(w *Volume) (*sdk.Volume, error) { + if w == nil { + return nil, nil + } + out := &sdk.Volume{} + out.Name = w.Name + return out, nil +} + +// VolumeFromSDK converts the sdk-go type to the mirror. +func VolumeFromSDK(v *sdk.Volume) (*Volume, error) { + if v == nil { + return nil, nil + } + out := &Volume{} + out.Name = v.Name + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/tagassignments/v1/types.generated.go b/libs/sdktypes/tagassignments/v1/types.generated.go new file mode 100644 index 00000000000..7db5db93aef --- /dev/null +++ b/libs/sdktypes/tagassignments/v1/types.generated.go @@ -0,0 +1,231 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/tagassignments/v1. DO NOT EDIT. + +package tagassignments + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/tagassignments/v1" + strings "strings" +) + +type CreateTagAssignmentRequest struct { + TagAssignment *TagAssignment `json:"tag_assignment,omitempty"` +} + +type ListTagAssignmentsRequest struct { + // The identifier of the entity to which the tag is assigned. For apps, the + // entity_id is the app name + EntityId *string `json:"entity_id,omitempty"` + // The type of entity to which the tag is assigned. Allowed values are apps, + // dashboards, geniespaces, notebooks + EntityType *string `json:"entity_type,omitempty"` + // Optional. Maximum number of tag assignments to return in a single page + PageSize *int `json:"page_size,omitempty"` + // Pagination token to go to the next page of tag assignments. Requests first + // page if absent. + PageToken *string `json:"page_token,omitempty"` +} + +type ListTagAssignmentsResponse struct { + // Pagination token to request the next page of tag assignments + NextPageToken *string `json:"next_page_token,omitempty"` + TagAssignments []TagAssignment `json:"tag_assignments,omitempty"` +} + +type TagAssignment struct { + // The identifier of the entity to which the tag is assigned. For apps, the + // entity_id is the app name + EntityId *string `json:"entity_id,omitempty"` + // The type of entity to which the tag is assigned. Allowed values are apps, + // dashboards, geniespaces, notebooks + EntityType *string `json:"entity_type,omitempty"` + // The key of the tag. The characters , . : / - = and leading/trailing spaces + // are not allowed + TagKey *string `json:"tag_key,omitempty"` + // The value of the tag + TagValue *string `json:"tag_value,omitempty"` +} + +type UpdateTagAssignmentRequest struct { + TagAssignment *TagAssignment `json:"tag_assignment,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CreateTagAssignmentRequestToSDK converts the mirror to the sdk-go type. +func CreateTagAssignmentRequestToSDK(w *CreateTagAssignmentRequest) (*sdk.CreateTagAssignmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateTagAssignmentRequest{} + conv1, err := TagAssignmentToSDK(w.TagAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTagAssignmentRequest.TagAssignment", err) + } + out.TagAssignment = conv1 + return out, nil +} + +// CreateTagAssignmentRequestFromSDK converts the sdk-go type to the mirror. +func CreateTagAssignmentRequestFromSDK(v *sdk.CreateTagAssignmentRequest) (*CreateTagAssignmentRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateTagAssignmentRequest{} + conv2, err := TagAssignmentFromSDK(v.TagAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTagAssignmentRequest.TagAssignment", err) + } + out.TagAssignment = conv2 + return out, nil +} + +// ListTagAssignmentsRequestToSDK converts the mirror to the sdk-go type. +func ListTagAssignmentsRequestToSDK(w *ListTagAssignmentsRequest) (*sdk.ListTagAssignmentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTagAssignmentsRequest{} + out.EntityType = w.EntityType + out.EntityId = w.EntityId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListTagAssignmentsRequestFromSDK converts the sdk-go type to the mirror. +func ListTagAssignmentsRequestFromSDK(v *sdk.ListTagAssignmentsRequest) (*ListTagAssignmentsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListTagAssignmentsRequest{} + out.EntityType = v.EntityType + out.EntityId = v.EntityId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListTagAssignmentsResponseToSDK converts the mirror to the sdk-go type. +func ListTagAssignmentsResponseToSDK(w *ListTagAssignmentsResponse) (*sdk.ListTagAssignmentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTagAssignmentsResponse{} + conv3, err := convertSlice(w.TagAssignments, TagAssignmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTagAssignmentsResponse.TagAssignments", err) + } + out.TagAssignments = conv3 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListTagAssignmentsResponseFromSDK converts the sdk-go type to the mirror. +func ListTagAssignmentsResponseFromSDK(v *sdk.ListTagAssignmentsResponse) (*ListTagAssignmentsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListTagAssignmentsResponse{} + conv4, err := convertSlice(v.TagAssignments, TagAssignmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTagAssignmentsResponse.TagAssignments", err) + } + out.TagAssignments = conv4 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// TagAssignmentToSDK converts the mirror to the sdk-go type. +func TagAssignmentToSDK(w *TagAssignment) (*sdk.TagAssignment, error) { + if w == nil { + return nil, nil + } + out := &sdk.TagAssignment{} + out.EntityType = w.EntityType + out.EntityId = w.EntityId + out.TagKey = w.TagKey + out.TagValue = w.TagValue + return out, nil +} + +// TagAssignmentFromSDK converts the sdk-go type to the mirror. +func TagAssignmentFromSDK(v *sdk.TagAssignment) (*TagAssignment, error) { + if v == nil { + return nil, nil + } + out := &TagAssignment{} + out.EntityType = v.EntityType + out.EntityId = v.EntityId + out.TagKey = v.TagKey + out.TagValue = v.TagValue + return out, nil +} + +// UpdateTagAssignmentRequestToSDK converts the mirror to the sdk-go type. +func UpdateTagAssignmentRequestToSDK(w *UpdateTagAssignmentRequest) (*sdk.UpdateTagAssignmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateTagAssignmentRequest{} + conv5, err := TagAssignmentToSDK(w.TagAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTagAssignmentRequest.TagAssignment", err) + } + out.TagAssignment = conv5 + mask6, err := fieldMaskFromString[sdk.TagAssignment](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTagAssignmentRequest.UpdateMask", err) + } + out.UpdateMask = mask6 + return out, nil +} + +// UpdateTagAssignmentRequestFromSDK converts the sdk-go type to the mirror. +func UpdateTagAssignmentRequestFromSDK(v *sdk.UpdateTagAssignmentRequest) (*UpdateTagAssignmentRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateTagAssignmentRequest{} + conv7, err := TagAssignmentFromSDK(v.TagAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTagAssignmentRequest.TagAssignment", err) + } + out.TagAssignment = conv7 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/tagpolicies/v1/types.generated.go b/libs/sdktypes/tagpolicies/v1/types.generated.go new file mode 100644 index 00000000000..07c4d22708a --- /dev/null +++ b/libs/sdktypes/tagpolicies/v1/types.generated.go @@ -0,0 +1,254 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/tagpolicies/v1. DO NOT EDIT. + +package tagpolicies + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/tagpolicies/v1" + strings "strings" +) + +type CreateTagPolicyRequest struct { + TagPolicy *TagPolicy `json:"tag_policy,omitempty"` +} + +type ListTagPoliciesRequest struct { + // The maximum number of results to return in this request. Fewer results may be + // returned than requested. If unspecified or set to 0, this defaults to 1000. + // The maximum value is 1000; values above 1000 will be coerced down to 1000. + PageSize *int `json:"page_size,omitempty"` + // An optional page token received from a previous list tag policies call. + PageToken *string `json:"page_token,omitempty"` +} + +type ListTagPoliciesResponse struct { + NextPageToken *string `json:"next_page_token,omitempty"` + TagPolicies []TagPolicy `json:"tag_policies,omitempty"` +} + +type TagPolicy struct { + // Timestamp when the tag policy was created + CreateTime *types.Time `json:"create_time,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + TagKey *string `json:"tag_key,omitempty"` + // Timestamp when the tag policy was last updated + UpdateTime *types.Time `json:"update_time,omitempty"` + Values []Value `json:"values,omitempty"` +} + +type UpdateTagPolicyRequest struct { + TagPolicy *TagPolicy `json:"tag_policy,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +type Value struct { + Name *string `json:"name,omitempty"` +} + +// CreateTagPolicyRequestToSDK converts the mirror to the sdk-go type. +func CreateTagPolicyRequestToSDK(w *CreateTagPolicyRequest) (*sdk.CreateTagPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateTagPolicyRequest{} + conv1, err := TagPolicyToSDK(w.TagPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTagPolicyRequest.TagPolicy", err) + } + out.TagPolicy = conv1 + return out, nil +} + +// CreateTagPolicyRequestFromSDK converts the sdk-go type to the mirror. +func CreateTagPolicyRequestFromSDK(v *sdk.CreateTagPolicyRequest) (*CreateTagPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateTagPolicyRequest{} + conv2, err := TagPolicyFromSDK(v.TagPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTagPolicyRequest.TagPolicy", err) + } + out.TagPolicy = conv2 + return out, nil +} + +// ListTagPoliciesRequestToSDK converts the mirror to the sdk-go type. +func ListTagPoliciesRequestToSDK(w *ListTagPoliciesRequest) (*sdk.ListTagPoliciesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTagPoliciesRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListTagPoliciesRequestFromSDK converts the sdk-go type to the mirror. +func ListTagPoliciesRequestFromSDK(v *sdk.ListTagPoliciesRequest) (*ListTagPoliciesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListTagPoliciesRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListTagPoliciesResponseToSDK converts the mirror to the sdk-go type. +func ListTagPoliciesResponseToSDK(w *ListTagPoliciesResponse) (*sdk.ListTagPoliciesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTagPoliciesResponse{} + conv3, err := convertSlice(w.TagPolicies, TagPolicyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTagPoliciesResponse.TagPolicies", err) + } + out.TagPolicies = conv3 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListTagPoliciesResponseFromSDK converts the sdk-go type to the mirror. +func ListTagPoliciesResponseFromSDK(v *sdk.ListTagPoliciesResponse) (*ListTagPoliciesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListTagPoliciesResponse{} + conv4, err := convertSlice(v.TagPolicies, TagPolicyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTagPoliciesResponse.TagPolicies", err) + } + out.TagPolicies = conv4 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// TagPolicyToSDK converts the mirror to the sdk-go type. +func TagPolicyToSDK(w *TagPolicy) (*sdk.TagPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.TagPolicy{} + out.TagKey = w.TagKey + out.Id = w.Id + out.Description = w.Description + conv5, err := convertSlice(w.Values, ValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TagPolicy.Values", err) + } + out.Values = conv5 + out.CreateTime = w.CreateTime + out.UpdateTime = w.UpdateTime + return out, nil +} + +// TagPolicyFromSDK converts the sdk-go type to the mirror. +func TagPolicyFromSDK(v *sdk.TagPolicy) (*TagPolicy, error) { + if v == nil { + return nil, nil + } + out := &TagPolicy{} + out.TagKey = v.TagKey + out.Id = v.Id + out.Description = v.Description + conv6, err := convertSlice(v.Values, ValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TagPolicy.Values", err) + } + out.Values = conv6 + out.CreateTime = v.CreateTime + out.UpdateTime = v.UpdateTime + return out, nil +} + +// UpdateTagPolicyRequestToSDK converts the mirror to the sdk-go type. +func UpdateTagPolicyRequestToSDK(w *UpdateTagPolicyRequest) (*sdk.UpdateTagPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateTagPolicyRequest{} + conv7, err := TagPolicyToSDK(w.TagPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTagPolicyRequest.TagPolicy", err) + } + out.TagPolicy = conv7 + mask8, err := fieldMaskFromString[sdk.TagPolicy](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTagPolicyRequest.UpdateMask", err) + } + out.UpdateMask = mask8 + return out, nil +} + +// UpdateTagPolicyRequestFromSDK converts the sdk-go type to the mirror. +func UpdateTagPolicyRequestFromSDK(v *sdk.UpdateTagPolicyRequest) (*UpdateTagPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateTagPolicyRequest{} + conv9, err := TagPolicyFromSDK(v.TagPolicy) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTagPolicyRequest.TagPolicy", err) + } + out.TagPolicy = conv9 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// ValueToSDK converts the mirror to the sdk-go type. +func ValueToSDK(w *Value) (*sdk.Value, error) { + if w == nil { + return nil, nil + } + out := &sdk.Value{} + out.Name = w.Name + return out, nil +} + +// ValueFromSDK converts the sdk-go type to the mirror. +func ValueFromSDK(v *sdk.Value) (*Value, error) { + if v == nil { + return nil, nil + } + out := &Value{} + out.Name = v.Name + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/tokenmanagement/v1/types.generated.go b/libs/sdktypes/tokenmanagement/v1/types.generated.go new file mode 100644 index 00000000000..95cf08f44c1 --- /dev/null +++ b/libs/sdktypes/tokenmanagement/v1/types.generated.go @@ -0,0 +1,359 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/tokenmanagement/v1. DO NOT EDIT. + +package tokenmanagement + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/tokenmanagement/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + AutoscopeState = sdk.AutoscopeState +) + +const ( + AutoscopeState_Unspecified = sdk.AutoscopeState_Unspecified + AutoscopeState_AutoscopeStateDisabled = sdk.AutoscopeState_AutoscopeStateDisabled + AutoscopeState_AutoscopeStateRunning = sdk.AutoscopeState_AutoscopeStateRunning + AutoscopeState_AutoscopeStateCompleted = sdk.AutoscopeState_AutoscopeStateCompleted + AutoscopeState_AutoscopeStateBackfilled = sdk.AutoscopeState_AutoscopeStateBackfilled + AutoscopeState_AutoscopeStateUserSelected = sdk.AutoscopeState_AutoscopeStateUserSelected + AutoscopeState_AutoscopeStateApiNotCovered = sdk.AutoscopeState_AutoscopeStateApiNotCovered +) + +type AdminTokenInfo struct { + // Output only. The autoscope state of this token. + AutoscopeState AutoscopeState `json:"autoscope_state,omitempty"` + // Output only. Scopes inferred from offline backfill processing. + BackfillScopes []string `json:"backfill_scopes,omitempty"` + // Comment that describes the purpose of the token, specified by the token + // creator. + Comment *string `json:"comment,omitempty"` + // User ID of the user that created the token. + CreatedById *int64 `json:"created_by_id,omitempty"` + // Username of the user that created the token. + CreatedByUsername *string `json:"created_by_username,omitempty"` + // Timestamp when the token was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // Timestamp when the token expires. + ExpiryTime *int64 `json:"expiry_time,omitempty"` + // Output only. Inferred API path scopes collected for this token when autoscope + // is enabled. + InferredScopes []string `json:"inferred_scopes,omitempty"` + // Approximate timestamp for the day the token was last used. Accurate up to 1 + // day. + LastUsedDay *int64 `json:"last_used_day,omitempty"` + // User ID of the user that owns the token. + OwnerId *int64 `json:"owner_id,omitempty"` + // Scope of the token was created with, if applicable. + Scopes []string `json:"scopes,omitempty"` + // ID of the token. + TokenId *string `json:"token_id,omitempty"` + // If applicable, the ID of the workspace that the token was created in. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +// Configuration details for creating on-behalf tokens.. +type CreateOnBehalfOfTokenRequest struct { + // Application ID of the service principal. + ApplicationId *string `json:"application_id,omitempty"` + // Whether to enable autoscoping for this token. + AutoscopeEnabled *bool `json:"autoscope_enabled,omitempty"` + // Comment that describes the purpose of the token. + Comment *string `json:"comment,omitempty"` + // The number of seconds before the token expires. + LifetimeSeconds *int64 `json:"lifetime_seconds,omitempty"` + Scopes []string `json:"scopes,omitempty"` +} + +// An on-behalf token was successfully created for the service principal.. +type CreateOnBehalfOfTokenResponse struct { + TokenInfo *AdminTokenInfo `json:"token_info,omitempty"` + // Value of the token. + TokenValue *string `json:"token_value,omitempty"` +} + +// Token with specified Token ID was successfully returned.. +type GetTokenResponse struct { + TokenInfo *AdminTokenInfo `json:"token_info,omitempty"` +} + +// !! KEEP THIS IN-SYNC WITH THE ACCOUNT PROTO DEFINITIONS IN +// ACCOUNT_SERVICE.PROTO !! +// +// The only differences should be: 1. The OpenAPI labels. 2. The account_id +// request parameter. 3. The string filter parameter instead of hard-coded +// filters.. +type ListTokensRequest struct { + // User ID of the user that created the token. + CreatedById *int64 `json:"created_by_id,omitempty"` + // Username of the user that created the token. + CreatedByUsername *string `json:"created_by_username,omitempty"` +} + +// Tokens were successfully returned.. +type ListTokensResponse struct { + // Token metadata of each user-created token in the workspace + TokenInfos []AdminTokenInfo `json:"token_infos,omitempty"` +} + +// For the list of supported token scopes, see +// https://docs.databricks.com/api/workspace/api/scopes.. +type UpdateTokenRequest struct { + Token *AdminTokenInfo `json:"token,omitempty"` + // A list of field name under token, For example, {"update_mask": + // "comment,scopes"} + UpdateMask *string `json:"update_mask,omitempty"` +} + +// AdminTokenInfoToSDK converts the mirror to the sdk-go type. +func AdminTokenInfoToSDK(w *AdminTokenInfo) (*sdk.AdminTokenInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.AdminTokenInfo{} + out.TokenId = w.TokenId + out.CreationTime = w.CreationTime + out.ExpiryTime = w.ExpiryTime + out.Comment = w.Comment + out.CreatedById = w.CreatedById + out.CreatedByUsername = w.CreatedByUsername + out.OwnerId = w.OwnerId + out.WorkspaceId = w.WorkspaceId + out.LastUsedDay = w.LastUsedDay + out.Scopes = w.Scopes + out.AutoscopeState = w.AutoscopeState + out.InferredScopes = w.InferredScopes + out.BackfillScopes = w.BackfillScopes + return out, nil +} + +// AdminTokenInfoFromSDK converts the sdk-go type to the mirror. +func AdminTokenInfoFromSDK(v *sdk.AdminTokenInfo) (*AdminTokenInfo, error) { + if v == nil { + return nil, nil + } + out := &AdminTokenInfo{} + out.TokenId = v.TokenId + out.CreationTime = v.CreationTime + out.ExpiryTime = v.ExpiryTime + out.Comment = v.Comment + out.CreatedById = v.CreatedById + out.CreatedByUsername = v.CreatedByUsername + out.OwnerId = v.OwnerId + out.WorkspaceId = v.WorkspaceId + out.LastUsedDay = v.LastUsedDay + out.Scopes = v.Scopes + out.AutoscopeState = v.AutoscopeState + out.InferredScopes = v.InferredScopes + out.BackfillScopes = v.BackfillScopes + return out, nil +} + +// CreateOnBehalfOfTokenRequestToSDK converts the mirror to the sdk-go type. +func CreateOnBehalfOfTokenRequestToSDK(w *CreateOnBehalfOfTokenRequest) (*sdk.CreateOnBehalfOfTokenRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateOnBehalfOfTokenRequest{} + out.ApplicationId = w.ApplicationId + out.LifetimeSeconds = w.LifetimeSeconds + out.Comment = w.Comment + out.Scopes = w.Scopes + out.AutoscopeEnabled = w.AutoscopeEnabled + return out, nil +} + +// CreateOnBehalfOfTokenRequestFromSDK converts the sdk-go type to the mirror. +func CreateOnBehalfOfTokenRequestFromSDK(v *sdk.CreateOnBehalfOfTokenRequest) (*CreateOnBehalfOfTokenRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateOnBehalfOfTokenRequest{} + out.ApplicationId = v.ApplicationId + out.LifetimeSeconds = v.LifetimeSeconds + out.Comment = v.Comment + out.Scopes = v.Scopes + out.AutoscopeEnabled = v.AutoscopeEnabled + return out, nil +} + +// CreateOnBehalfOfTokenResponseToSDK converts the mirror to the sdk-go type. +func CreateOnBehalfOfTokenResponseToSDK(w *CreateOnBehalfOfTokenResponse) (*sdk.CreateOnBehalfOfTokenResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateOnBehalfOfTokenResponse{} + out.TokenValue = w.TokenValue + conv1, err := AdminTokenInfoToSDK(w.TokenInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateOnBehalfOfTokenResponse.TokenInfo", err) + } + out.TokenInfo = conv1 + return out, nil +} + +// CreateOnBehalfOfTokenResponseFromSDK converts the sdk-go type to the mirror. +func CreateOnBehalfOfTokenResponseFromSDK(v *sdk.CreateOnBehalfOfTokenResponse) (*CreateOnBehalfOfTokenResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateOnBehalfOfTokenResponse{} + out.TokenValue = v.TokenValue + conv2, err := AdminTokenInfoFromSDK(v.TokenInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateOnBehalfOfTokenResponse.TokenInfo", err) + } + out.TokenInfo = conv2 + return out, nil +} + +// GetTokenResponseToSDK converts the mirror to the sdk-go type. +func GetTokenResponseToSDK(w *GetTokenResponse) (*sdk.GetTokenResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetTokenResponse{} + conv3, err := AdminTokenInfoToSDK(w.TokenInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetTokenResponse.TokenInfo", err) + } + out.TokenInfo = conv3 + return out, nil +} + +// GetTokenResponseFromSDK converts the sdk-go type to the mirror. +func GetTokenResponseFromSDK(v *sdk.GetTokenResponse) (*GetTokenResponse, error) { + if v == nil { + return nil, nil + } + out := &GetTokenResponse{} + conv4, err := AdminTokenInfoFromSDK(v.TokenInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetTokenResponse.TokenInfo", err) + } + out.TokenInfo = conv4 + return out, nil +} + +// ListTokensRequestToSDK converts the mirror to the sdk-go type. +func ListTokensRequestToSDK(w *ListTokensRequest) (*sdk.ListTokensRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTokensRequest{} + out.CreatedById = w.CreatedById + out.CreatedByUsername = w.CreatedByUsername + return out, nil +} + +// ListTokensRequestFromSDK converts the sdk-go type to the mirror. +func ListTokensRequestFromSDK(v *sdk.ListTokensRequest) (*ListTokensRequest, error) { + if v == nil { + return nil, nil + } + out := &ListTokensRequest{} + out.CreatedById = v.CreatedById + out.CreatedByUsername = v.CreatedByUsername + return out, nil +} + +// ListTokensResponseToSDK converts the mirror to the sdk-go type. +func ListTokensResponseToSDK(w *ListTokensResponse) (*sdk.ListTokensResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTokensResponse{} + conv5, err := convertSlice(w.TokenInfos, AdminTokenInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTokensResponse.TokenInfos", err) + } + out.TokenInfos = conv5 + return out, nil +} + +// ListTokensResponseFromSDK converts the sdk-go type to the mirror. +func ListTokensResponseFromSDK(v *sdk.ListTokensResponse) (*ListTokensResponse, error) { + if v == nil { + return nil, nil + } + out := &ListTokensResponse{} + conv6, err := convertSlice(v.TokenInfos, AdminTokenInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTokensResponse.TokenInfos", err) + } + out.TokenInfos = conv6 + return out, nil +} + +// UpdateTokenRequestToSDK converts the mirror to the sdk-go type. +func UpdateTokenRequestToSDK(w *UpdateTokenRequest) (*sdk.UpdateTokenRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateTokenRequest{} + conv7, err := AdminTokenInfoToSDK(w.Token) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTokenRequest.Token", err) + } + out.Token = conv7 + mask8, err := fieldMaskFromString[sdk.AdminTokenInfo](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTokenRequest.UpdateMask", err) + } + out.UpdateMask = mask8 + return out, nil +} + +// UpdateTokenRequestFromSDK converts the sdk-go type to the mirror. +func UpdateTokenRequestFromSDK(v *sdk.UpdateTokenRequest) (*UpdateTokenRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateTokenRequest{} + conv9, err := AdminTokenInfoFromSDK(v.Token) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTokenRequest.Token", err) + } + out.Token = conv9 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/tokens/v1/types.generated.go b/libs/sdktypes/tokens/v1/types.generated.go new file mode 100644 index 00000000000..dcb91d41afb --- /dev/null +++ b/libs/sdktypes/tokens/v1/types.generated.go @@ -0,0 +1,297 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/tokens/v1. DO NOT EDIT. + +package tokens + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/tokens/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + AutoscopeState = sdk.AutoscopeState +) + +const ( + AutoscopeState_Unspecified = sdk.AutoscopeState_Unspecified + AutoscopeState_AutoscopeStateDisabled = sdk.AutoscopeState_AutoscopeStateDisabled + AutoscopeState_AutoscopeStateRunning = sdk.AutoscopeState_AutoscopeStateRunning + AutoscopeState_AutoscopeStateCompleted = sdk.AutoscopeState_AutoscopeStateCompleted + AutoscopeState_AutoscopeStateBackfilled = sdk.AutoscopeState_AutoscopeStateBackfilled + AutoscopeState_AutoscopeStateUserSelected = sdk.AutoscopeState_AutoscopeStateUserSelected + AutoscopeState_AutoscopeStateApiNotCovered = sdk.AutoscopeState_AutoscopeStateApiNotCovered +) + +type CreateTokenRequest struct { + // Whether to enable autoscoping for this token. When true, the token will + // automatically collect inferred API path scopes as it is used. + AutoscopeEnabled *bool `json:"autoscope_enabled,omitempty"` + // Optional description to attach to the token. + Comment *string `json:"comment,omitempty"` + // The lifetime of the token, in seconds. + // + // If the lifetime is not specified, this token remains valid for 2 years. + LifetimeSeconds *int64 `json:"lifetime_seconds,omitempty"` + // Optional scopes of the token. + Scopes []string `json:"scopes,omitempty"` +} + +type CreateTokenResponse struct { + // The information for the new token. + TokenInfo *PublicTokenInfo `json:"token_info,omitempty"` + // The value of the new token. + TokenValue *string `json:"token_value,omitempty"` +} + +type ListTokensResponse struct { + // The information for each token. + TokenInfos []PublicTokenInfo `json:"token_infos,omitempty"` +} + +type PublicTokenInfo struct { + // Output only. The autoscope state of this token. + AutoscopeState AutoscopeState `json:"autoscope_state,omitempty"` + // Output only. Scopes inferred from offline backfill processing. + BackfillScopes []string `json:"backfill_scopes,omitempty"` + // Comment the token was created with, if applicable. + Comment *string `json:"comment,omitempty"` + // Server time (in epoch milliseconds) when the token was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // Server time (in epoch milliseconds) when the token will expire, or -1 if not + // applicable. + ExpiryTime *int64 `json:"expiry_time,omitempty"` + // Output only. Inferred API path scopes collected for this token when autoscope + // is enabled. + InferredScopes []string `json:"inferred_scopes,omitempty"` + // Scope of the token was created with, if applicable. + Scopes []string `json:"scopes,omitempty"` + // The ID of this token. + TokenId *string `json:"token_id,omitempty"` +} + +type RevokeTokenRequest struct { + // The ID of the token to be revoked. + TokenId *string `json:"token_id,omitempty"` +} + +// For the list of supported token scopes, see +// https://docs.databricks.com/api/workspace/api/scopes.. +type UpdateTokenRequest struct { + Token *PublicTokenInfo `json:"token,omitempty"` + // The SHA-256 hash of the token to be updated. + TokenId *string `json:"token_id,omitempty"` + // A list of field name under token, For example, {"update_mask": + // "comment,scopes"} + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CreateTokenRequestToSDK converts the mirror to the sdk-go type. +func CreateTokenRequestToSDK(w *CreateTokenRequest) (*sdk.CreateTokenRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateTokenRequest{} + out.LifetimeSeconds = w.LifetimeSeconds + out.Comment = w.Comment + out.Scopes = w.Scopes + out.AutoscopeEnabled = w.AutoscopeEnabled + return out, nil +} + +// CreateTokenRequestFromSDK converts the sdk-go type to the mirror. +func CreateTokenRequestFromSDK(v *sdk.CreateTokenRequest) (*CreateTokenRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateTokenRequest{} + out.LifetimeSeconds = v.LifetimeSeconds + out.Comment = v.Comment + out.Scopes = v.Scopes + out.AutoscopeEnabled = v.AutoscopeEnabled + return out, nil +} + +// CreateTokenResponseToSDK converts the mirror to the sdk-go type. +func CreateTokenResponseToSDK(w *CreateTokenResponse) (*sdk.CreateTokenResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateTokenResponse{} + out.TokenValue = w.TokenValue + conv1, err := PublicTokenInfoToSDK(w.TokenInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTokenResponse.TokenInfo", err) + } + out.TokenInfo = conv1 + return out, nil +} + +// CreateTokenResponseFromSDK converts the sdk-go type to the mirror. +func CreateTokenResponseFromSDK(v *sdk.CreateTokenResponse) (*CreateTokenResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateTokenResponse{} + out.TokenValue = v.TokenValue + conv2, err := PublicTokenInfoFromSDK(v.TokenInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTokenResponse.TokenInfo", err) + } + out.TokenInfo = conv2 + return out, nil +} + +// ListTokensResponseToSDK converts the mirror to the sdk-go type. +func ListTokensResponseToSDK(w *ListTokensResponse) (*sdk.ListTokensResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTokensResponse{} + conv3, err := convertSlice(w.TokenInfos, PublicTokenInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTokensResponse.TokenInfos", err) + } + out.TokenInfos = conv3 + return out, nil +} + +// ListTokensResponseFromSDK converts the sdk-go type to the mirror. +func ListTokensResponseFromSDK(v *sdk.ListTokensResponse) (*ListTokensResponse, error) { + if v == nil { + return nil, nil + } + out := &ListTokensResponse{} + conv4, err := convertSlice(v.TokenInfos, PublicTokenInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTokensResponse.TokenInfos", err) + } + out.TokenInfos = conv4 + return out, nil +} + +// PublicTokenInfoToSDK converts the mirror to the sdk-go type. +func PublicTokenInfoToSDK(w *PublicTokenInfo) (*sdk.PublicTokenInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.PublicTokenInfo{} + out.TokenId = w.TokenId + out.CreationTime = w.CreationTime + out.ExpiryTime = w.ExpiryTime + out.Comment = w.Comment + out.Scopes = w.Scopes + out.AutoscopeState = w.AutoscopeState + out.InferredScopes = w.InferredScopes + out.BackfillScopes = w.BackfillScopes + return out, nil +} + +// PublicTokenInfoFromSDK converts the sdk-go type to the mirror. +func PublicTokenInfoFromSDK(v *sdk.PublicTokenInfo) (*PublicTokenInfo, error) { + if v == nil { + return nil, nil + } + out := &PublicTokenInfo{} + out.TokenId = v.TokenId + out.CreationTime = v.CreationTime + out.ExpiryTime = v.ExpiryTime + out.Comment = v.Comment + out.Scopes = v.Scopes + out.AutoscopeState = v.AutoscopeState + out.InferredScopes = v.InferredScopes + out.BackfillScopes = v.BackfillScopes + return out, nil +} + +// RevokeTokenRequestToSDK converts the mirror to the sdk-go type. +func RevokeTokenRequestToSDK(w *RevokeTokenRequest) (*sdk.RevokeTokenRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RevokeTokenRequest{} + out.TokenId = w.TokenId + return out, nil +} + +// RevokeTokenRequestFromSDK converts the sdk-go type to the mirror. +func RevokeTokenRequestFromSDK(v *sdk.RevokeTokenRequest) (*RevokeTokenRequest, error) { + if v == nil { + return nil, nil + } + out := &RevokeTokenRequest{} + out.TokenId = v.TokenId + return out, nil +} + +// UpdateTokenRequestToSDK converts the mirror to the sdk-go type. +func UpdateTokenRequestToSDK(w *UpdateTokenRequest) (*sdk.UpdateTokenRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateTokenRequest{} + out.TokenId = w.TokenId + conv5, err := PublicTokenInfoToSDK(w.Token) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTokenRequest.Token", err) + } + out.Token = conv5 + mask6, err := fieldMaskFromString[sdk.PublicTokenInfo](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTokenRequest.UpdateMask", err) + } + out.UpdateMask = mask6 + return out, nil +} + +// UpdateTokenRequestFromSDK converts the sdk-go type to the mirror. +func UpdateTokenRequestFromSDK(v *sdk.UpdateTokenRequest) (*UpdateTokenRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateTokenRequest{} + out.TokenId = v.TokenId + conv7, err := PublicTokenInfoFromSDK(v.Token) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTokenRequest.Token", err) + } + out.Token = conv7 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/uc/abacpolicies/v1/types.generated.go b/libs/sdktypes/uc/abacpolicies/v1/types.generated.go new file mode 100644 index 00000000000..43008bd2cb5 --- /dev/null +++ b/libs/sdktypes/uc/abacpolicies/v1/types.generated.go @@ -0,0 +1,857 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/abacpolicies/v1. DO NOT EDIT. + +package abacpolicies + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/abacpolicies/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + PolicyType = sdk.PolicyType + SecurableType = sdk.SecurableType +) + +const ( + PolicyType_Unspecified = sdk.PolicyType_Unspecified + PolicyType_PolicyTypeRowFilter = sdk.PolicyType_PolicyTypeRowFilter + PolicyType_PolicyTypeColumnMask = sdk.PolicyType_PolicyTypeColumnMask + PolicyType_PolicyTypeDeny = sdk.PolicyType_PolicyTypeDeny + PolicyType_PolicyTypeGrant = sdk.PolicyType_PolicyTypeGrant + SecurableType_Unspecified = sdk.SecurableType_Unspecified + SecurableType_Catalog = sdk.SecurableType_Catalog + SecurableType_Schema = sdk.SecurableType_Schema + SecurableType_Table = sdk.SecurableType_Table + SecurableType_StorageCredential = sdk.SecurableType_StorageCredential + SecurableType_ExternalLocation = sdk.SecurableType_ExternalLocation + SecurableType_Function = sdk.SecurableType_Function + SecurableType_Share = sdk.SecurableType_Share + SecurableType_Provider = sdk.SecurableType_Provider + SecurableType_Recipient = sdk.SecurableType_Recipient + SecurableType_CleanRoom = sdk.SecurableType_CleanRoom + SecurableType_Metastore = sdk.SecurableType_Metastore + SecurableType_Pipeline = sdk.SecurableType_Pipeline + SecurableType_Volume = sdk.SecurableType_Volume + SecurableType_Connection = sdk.SecurableType_Connection + SecurableType_Credential = sdk.SecurableType_Credential + SecurableType_ExternalMetadata = sdk.SecurableType_ExternalMetadata + SecurableType_StagingTable = sdk.SecurableType_StagingTable + SecurableType_Model = sdk.SecurableType_Model + SecurableType_ModelService = sdk.SecurableType_ModelService + SecurableType_McpService = sdk.SecurableType_McpService + SecurableType_ModelProviderService = sdk.SecurableType_ModelProviderService + SecurableType_AgentService = sdk.SecurableType_AgentService + SecurableType_Skill = sdk.SecurableType_Skill +) + +type ColumnMaskOptions struct { + // The fully qualified name of the column mask function. The function is called + // on each row of the target table. The function's first argument and its return + // type should match the type of the masked column. Required on create and + // update. + FunctionName *string `json:"function_name,omitempty"` + // The alias of the column to be masked. The alias must refer to one of matched + // columns. The values of the column is passed to the column mask function as + // the first argument. Required on create and update. + OnColumn *string `json:"on_column,omitempty"` + // Optional list of column aliases or constant literals to be passed as + // additional arguments to the column mask function. The type of each column + // should match the positional argument of the column mask function. + Using []FunctionArgument `json:"using,omitempty"` +} + +// Extracts the value of a column-level tag: get_column_tag_value(col, +// "tagKey").. +type ColumnTagValueExtraction struct { + // The alias from MATCH COLUMNS that identifies the column. + ColumnAlias *string `json:"column_alias,omitempty"` + // 1024 matches the max_length on FunctionArgument.constant above. + TagKey *string `json:"tag_key,omitempty"` +} + +type CreatePolicyRequest struct { + // Required. The policy to create. + PolicyInfo *PolicyInfo `json:"policy_info,omitempty"` +} + +type DenyOptions struct { + // List of privileges to deny. When any of these privileges are requested, the + // policy will deny access if the principal and condition match. Required on + // create and update. + Privileges []string `json:"privileges,omitempty"` +} + +// An expression that is evaluated at query time against per-request context. +// New variants (e.g., identity attributes) are added as additional oneof cases.. +type FunctionArgExpression struct { + TagIntrospection *TagIntrospectionExpression `json:"tag_introspection,omitempty"` +} + +type FunctionArgument struct { + Alias *string `json:"alias,omitempty"` + Constant *string `json:"constant,omitempty"` + FunctionArgExpression *FunctionArgExpression `json:"function_arg_expression,omitempty"` +} + +type GrantOptions struct { + // List of privileges to grant. When any of these privileges are requested, the + // policy will grant access if the principal and condition match. Required on + // create and update. + Privileges []string `json:"privileges,omitempty"` +} + +type ListPoliciesRequest struct { + // Optional. Whether to include policies defined on parent securables. By + // default, the inherited policies are not included. + IncludeInherited *bool `json:"include_inherited,omitempty"` + // Optional. Maximum number of policies to return on a single page (page + // length). - When not set or set to 0, the page length is set to a server + // configured value (recommended); - When set to a value greater than 0, the + // page length is the minimum of this value and a server configured value; + MaxResults *int `json:"max_results,omitempty"` + // Required. The fully qualified name of securable to list policies for. + OnSecurableFullname *string `json:"on_securable_fullname,omitempty"` + // Required. The type of the securable to list policies for. + OnSecurableType *string `json:"on_securable_type,omitempty"` + // Optional. Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListPoliciesResponse struct { + // Optional opaque token for continuing pagination. `page_token` should be set + // to this value for the next request to retrieve the next page of results. + NextPageToken *string `json:"next_page_token,omitempty"` + // The list of retrieved policies. + Policies []PolicyInfo `json:"policies,omitempty"` +} + +type MatchColumn struct { + // Optional alias of the matched column. + Alias *string `json:"alias,omitempty"` + // The condition expression used to match a table column. + Condition *string `json:"condition,omitempty"` +} + +type PolicyInfo struct { + ColumnMask *ColumnMaskOptions `json:"column_mask,omitempty"` + // Optional description of the policy. + Comment *string `json:"comment,omitempty"` + // Time at which the policy was created, in epoch milliseconds. Output only. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of the user who created the policy. Output only. + CreatedBy *string `json:"created_by,omitempty"` + Deny *DenyOptions `json:"deny,omitempty"` + // Optional list of user or group names that should be excluded from the policy. + ExceptPrincipals []string `json:"except_principals,omitempty"` + // Type of securables that the policy should take effect on. Required on create + // and optional on update. + ForSecurableType SecurableType `json:"for_securable_type,omitempty"` + Grant *GrantOptions `json:"grant,omitempty"` + // Unique identifier of the policy. This field is output only and is generated + // by the system. + Id *string `json:"id,omitempty"` + // Optional list of condition expressions used to match table columns. Only + // valid when `for_securable_type` is `TABLE`. When specified, the policy only + // applies to tables whose columns satisfy all match conditions. + MatchColumns []MatchColumn `json:"match_columns,omitempty"` + // Name of the policy. Required on create and optional on update. To rename the + // policy, set `name` to a different value on update. + Name *string `json:"name,omitempty"` + // Full name of the securable on which the policy is defined. Required on + // create. + OnSecurableFullname *string `json:"on_securable_fullname,omitempty"` + // Type of the securable on which the policy is defined. Only `CATALOG`, + // `SCHEMA` and `TABLE` are supported at this moment. Required on create. + OnSecurableType SecurableType `json:"on_securable_type,omitempty"` + // Type of the policy. Required on create. + PolicyType PolicyType `json:"policy_type,omitempty"` + RowFilter *RowFilterOptions `json:"row_filter,omitempty"` + // List of user or group names that the policy applies to. Required on create + // and optional on update. + ToPrincipals []string `json:"to_principals,omitempty"` + // Time at which the policy was last modified, in epoch milliseconds. Output + // only. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of the user who last modified the policy. Output only. + UpdatedBy *string `json:"updated_by,omitempty"` + // Optional condition when the policy should take effect. + WhenCondition *string `json:"when_condition,omitempty"` +} + +type RowFilterOptions struct { + // The fully qualified name of the row filter function. The function is called + // on each row of the target table. It should return a boolean value indicating + // whether the row should be visible to the user. Required on create and update. + FunctionName *string `json:"function_name,omitempty"` + // Optional list of column aliases or constant literals to be passed as + // arguments to the row filter function. The type of each column should match + // the positional argument of the row filter function. + Using []FunctionArgument `json:"using,omitempty"` +} + +// An expression that introspects tags at query time.. +type TagIntrospectionExpression struct { + ColumnTagValue *ColumnTagValueExtraction `json:"column_tag_value,omitempty"` + TagValue *TagValueExtraction `json:"tag_value,omitempty"` +} + +// Extracts the value of a securable-level tag: get_tag_value("tagKey").. +type TagValueExtraction struct { + // 1024 matches the max_length on FunctionArgument.constant above. + TagKey *string `json:"tag_key,omitempty"` +} + +type UpdatePolicyRequest struct { + // Required. The name of the policy to update. + Name *string `json:"name,omitempty"` + // Required. The fully qualified name of the securable to update the policy for. + OnSecurableFullname *string `json:"on_securable_fullname,omitempty"` + // Required. The type of the securable to update the policy for. + OnSecurableType *string `json:"on_securable_type,omitempty"` + // Optional fields to update. This is the request body for updating a policy. + // Use `update_mask` field to specify which fields in the request is to be + // updated. - If `update_mask` is empty or "*", all specified fields will be + // updated. - If `update_mask` is specified, only the fields specified in the + // `update_mask` will be updated. If a field is specified in `update_mask` and + // not set in the request, the field will be cleared. Users can use the update + // mask to explicitly unset optional fields such as `exception_principals` and + // `when_condition`. + PolicyInfo *PolicyInfo `json:"policy_info,omitempty"` + // Optional. The update mask field for specifying user intentions on which + // fields to update in the request. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// ColumnMaskOptionsToSDK converts the mirror to the sdk-go type. +func ColumnMaskOptionsToSDK(w *ColumnMaskOptions) (*sdk.ColumnMaskOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnMaskOptions{} + out.FunctionName = w.FunctionName + out.OnColumn = w.OnColumn + conv1, err := convertSlice(w.Using, FunctionArgumentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnMaskOptions.Using", err) + } + out.Using = conv1 + return out, nil +} + +// ColumnMaskOptionsFromSDK converts the sdk-go type to the mirror. +func ColumnMaskOptionsFromSDK(v *sdk.ColumnMaskOptions) (*ColumnMaskOptions, error) { + if v == nil { + return nil, nil + } + out := &ColumnMaskOptions{} + out.FunctionName = v.FunctionName + out.OnColumn = v.OnColumn + conv2, err := convertSlice(v.Using, FunctionArgumentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnMaskOptions.Using", err) + } + out.Using = conv2 + return out, nil +} + +// ColumnTagValueExtractionToSDK converts the mirror to the sdk-go type. +func ColumnTagValueExtractionToSDK(w *ColumnTagValueExtraction) (*sdk.ColumnTagValueExtraction, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnTagValueExtraction{} + out.ColumnAlias = w.ColumnAlias + out.TagKey = w.TagKey + return out, nil +} + +// ColumnTagValueExtractionFromSDK converts the sdk-go type to the mirror. +func ColumnTagValueExtractionFromSDK(v *sdk.ColumnTagValueExtraction) (*ColumnTagValueExtraction, error) { + if v == nil { + return nil, nil + } + out := &ColumnTagValueExtraction{} + out.ColumnAlias = v.ColumnAlias + out.TagKey = v.TagKey + return out, nil +} + +// CreatePolicyRequestToSDK converts the mirror to the sdk-go type. +func CreatePolicyRequestToSDK(w *CreatePolicyRequest) (*sdk.CreatePolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreatePolicyRequest{} + conv3, err := PolicyInfoToSDK(w.PolicyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePolicyRequest.PolicyInfo", err) + } + out.PolicyInfo = conv3 + return out, nil +} + +// CreatePolicyRequestFromSDK converts the sdk-go type to the mirror. +func CreatePolicyRequestFromSDK(v *sdk.CreatePolicyRequest) (*CreatePolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &CreatePolicyRequest{} + conv4, err := PolicyInfoFromSDK(v.PolicyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreatePolicyRequest.PolicyInfo", err) + } + out.PolicyInfo = conv4 + return out, nil +} + +// DenyOptionsToSDK converts the mirror to the sdk-go type. +func DenyOptionsToSDK(w *DenyOptions) (*sdk.DenyOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.DenyOptions{} + out.Privileges = w.Privileges + return out, nil +} + +// DenyOptionsFromSDK converts the sdk-go type to the mirror. +func DenyOptionsFromSDK(v *sdk.DenyOptions) (*DenyOptions, error) { + if v == nil { + return nil, nil + } + out := &DenyOptions{} + out.Privileges = v.Privileges + return out, nil +} + +// FunctionArgExpressionToSDK converts the mirror to the sdk-go type. +func FunctionArgExpressionToSDK(w *FunctionArgExpression) (*sdk.FunctionArgExpression, error) { + if w == nil { + return nil, nil + } + out := &sdk.FunctionArgExpression{} + { + var members []string + if w.TagIntrospection != nil { + members = append(members, "tag_introspection") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.TagIntrospection != nil: + conv5, err := TagIntrospectionExpressionToSDK(w.TagIntrospection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionArgExpression.Expr", err) + } + out.Expr = &sdk.FunctionArgExpression_Expr_TagIntrospection{TagIntrospection: *conv5} + } + return out, nil +} + +// FunctionArgExpressionFromSDK converts the sdk-go type to the mirror. +func FunctionArgExpressionFromSDK(v *sdk.FunctionArgExpression) (*FunctionArgExpression, error) { + if v == nil { + return nil, nil + } + out := &FunctionArgExpression{} + switch value := v.Expr.(type) { + case *sdk.FunctionArgExpression_Expr_TagIntrospection: + if value != nil { + conv6, err := TagIntrospectionExpressionFromSDK(&value.TagIntrospection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionArgExpression.Expr", err) + } + out.TagIntrospection = conv6 + } + } + return out, nil +} + +// FunctionArgumentToSDK converts the mirror to the sdk-go type. +func FunctionArgumentToSDK(w *FunctionArgument) (*sdk.FunctionArgument, error) { + if w == nil { + return nil, nil + } + out := &sdk.FunctionArgument{} + { + var members []string + if w.Alias != nil { + members = append(members, "alias") + } + if w.Constant != nil { + members = append(members, "constant") + } + if w.FunctionArgExpression != nil { + members = append(members, "function_arg_expression") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Alias != nil: + out.Arg = &sdk.FunctionArgument_Arg_Alias{Alias: *w.Alias} + case w.Constant != nil: + out.Arg = &sdk.FunctionArgument_Arg_Constant{Constant: *w.Constant} + case w.FunctionArgExpression != nil: + conv7, err := FunctionArgExpressionToSDK(w.FunctionArgExpression) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionArgument.Arg", err) + } + out.Arg = &sdk.FunctionArgument_Arg_FunctionArgExpression{FunctionArgExpression: *conv7} + } + return out, nil +} + +// FunctionArgumentFromSDK converts the sdk-go type to the mirror. +func FunctionArgumentFromSDK(v *sdk.FunctionArgument) (*FunctionArgument, error) { + if v == nil { + return nil, nil + } + out := &FunctionArgument{} + switch value := v.Arg.(type) { + case *sdk.FunctionArgument_Arg_Alias: + if value != nil { + out.Alias = new(value.Alias) + } + case *sdk.FunctionArgument_Arg_Constant: + if value != nil { + out.Constant = new(value.Constant) + } + case *sdk.FunctionArgument_Arg_FunctionArgExpression: + if value != nil { + conv8, err := FunctionArgExpressionFromSDK(&value.FunctionArgExpression) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionArgument.Arg", err) + } + out.FunctionArgExpression = conv8 + } + } + return out, nil +} + +// GrantOptionsToSDK converts the mirror to the sdk-go type. +func GrantOptionsToSDK(w *GrantOptions) (*sdk.GrantOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.GrantOptions{} + out.Privileges = w.Privileges + return out, nil +} + +// GrantOptionsFromSDK converts the sdk-go type to the mirror. +func GrantOptionsFromSDK(v *sdk.GrantOptions) (*GrantOptions, error) { + if v == nil { + return nil, nil + } + out := &GrantOptions{} + out.Privileges = v.Privileges + return out, nil +} + +// ListPoliciesRequestToSDK converts the mirror to the sdk-go type. +func ListPoliciesRequestToSDK(w *ListPoliciesRequest) (*sdk.ListPoliciesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPoliciesRequest{} + out.OnSecurableType = w.OnSecurableType + out.OnSecurableFullname = w.OnSecurableFullname + out.IncludeInherited = w.IncludeInherited + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListPoliciesRequestFromSDK converts the sdk-go type to the mirror. +func ListPoliciesRequestFromSDK(v *sdk.ListPoliciesRequest) (*ListPoliciesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListPoliciesRequest{} + out.OnSecurableType = v.OnSecurableType + out.OnSecurableFullname = v.OnSecurableFullname + out.IncludeInherited = v.IncludeInherited + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListPoliciesResponseToSDK converts the mirror to the sdk-go type. +func ListPoliciesResponseToSDK(w *ListPoliciesResponse) (*sdk.ListPoliciesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPoliciesResponse{} + conv9, err := convertSlice(w.Policies, PolicyInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPoliciesResponse.Policies", err) + } + out.Policies = conv9 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListPoliciesResponseFromSDK converts the sdk-go type to the mirror. +func ListPoliciesResponseFromSDK(v *sdk.ListPoliciesResponse) (*ListPoliciesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListPoliciesResponse{} + conv10, err := convertSlice(v.Policies, PolicyInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPoliciesResponse.Policies", err) + } + out.Policies = conv10 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// MatchColumnToSDK converts the mirror to the sdk-go type. +func MatchColumnToSDK(w *MatchColumn) (*sdk.MatchColumn, error) { + if w == nil { + return nil, nil + } + out := &sdk.MatchColumn{} + out.Condition = w.Condition + out.Alias = w.Alias + return out, nil +} + +// MatchColumnFromSDK converts the sdk-go type to the mirror. +func MatchColumnFromSDK(v *sdk.MatchColumn) (*MatchColumn, error) { + if v == nil { + return nil, nil + } + out := &MatchColumn{} + out.Condition = v.Condition + out.Alias = v.Alias + return out, nil +} + +// PolicyInfoToSDK converts the mirror to the sdk-go type. +func PolicyInfoToSDK(w *PolicyInfo) (*sdk.PolicyInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.PolicyInfo{} + out.Id = w.Id + out.OnSecurableType = w.OnSecurableType + out.OnSecurableFullname = w.OnSecurableFullname + out.Name = w.Name + out.Comment = w.Comment + out.ToPrincipals = w.ToPrincipals + out.ExceptPrincipals = w.ExceptPrincipals + out.ForSecurableType = w.ForSecurableType + out.WhenCondition = w.WhenCondition + out.PolicyType = w.PolicyType + { + var members []string + if w.RowFilter != nil { + members = append(members, "row_filter") + } + if w.ColumnMask != nil { + members = append(members, "column_mask") + } + if w.Deny != nil { + members = append(members, "deny") + } + if w.Grant != nil { + members = append(members, "grant") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.RowFilter != nil: + conv11, err := RowFilterOptionsToSDK(w.RowFilter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PolicyInfo.Options", err) + } + out.Options = &sdk.PolicyInfo_Options_RowFilter{RowFilter: *conv11} + case w.ColumnMask != nil: + conv12, err := ColumnMaskOptionsToSDK(w.ColumnMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PolicyInfo.Options", err) + } + out.Options = &sdk.PolicyInfo_Options_ColumnMask{ColumnMask: *conv12} + case w.Deny != nil: + conv13, err := DenyOptionsToSDK(w.Deny) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PolicyInfo.Options", err) + } + out.Options = &sdk.PolicyInfo_Options_Deny{Deny: *conv13} + case w.Grant != nil: + conv14, err := GrantOptionsToSDK(w.Grant) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PolicyInfo.Options", err) + } + out.Options = &sdk.PolicyInfo_Options_Grant{Grant: *conv14} + } + conv15, err := convertSlice(w.MatchColumns, MatchColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PolicyInfo.MatchColumns", err) + } + out.MatchColumns = conv15 + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + return out, nil +} + +// PolicyInfoFromSDK converts the sdk-go type to the mirror. +func PolicyInfoFromSDK(v *sdk.PolicyInfo) (*PolicyInfo, error) { + if v == nil { + return nil, nil + } + out := &PolicyInfo{} + out.Id = v.Id + out.OnSecurableType = v.OnSecurableType + out.OnSecurableFullname = v.OnSecurableFullname + out.Name = v.Name + out.Comment = v.Comment + out.ToPrincipals = v.ToPrincipals + out.ExceptPrincipals = v.ExceptPrincipals + out.ForSecurableType = v.ForSecurableType + out.WhenCondition = v.WhenCondition + out.PolicyType = v.PolicyType + switch value := v.Options.(type) { + case *sdk.PolicyInfo_Options_RowFilter: + if value != nil { + conv16, err := RowFilterOptionsFromSDK(&value.RowFilter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PolicyInfo.Options", err) + } + out.RowFilter = conv16 + } + case *sdk.PolicyInfo_Options_ColumnMask: + if value != nil { + conv17, err := ColumnMaskOptionsFromSDK(&value.ColumnMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PolicyInfo.Options", err) + } + out.ColumnMask = conv17 + } + case *sdk.PolicyInfo_Options_Deny: + if value != nil { + conv18, err := DenyOptionsFromSDK(&value.Deny) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PolicyInfo.Options", err) + } + out.Deny = conv18 + } + case *sdk.PolicyInfo_Options_Grant: + if value != nil { + conv19, err := GrantOptionsFromSDK(&value.Grant) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PolicyInfo.Options", err) + } + out.Grant = conv19 + } + } + conv20, err := convertSlice(v.MatchColumns, MatchColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "PolicyInfo.MatchColumns", err) + } + out.MatchColumns = conv20 + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + return out, nil +} + +// RowFilterOptionsToSDK converts the mirror to the sdk-go type. +func RowFilterOptionsToSDK(w *RowFilterOptions) (*sdk.RowFilterOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.RowFilterOptions{} + out.FunctionName = w.FunctionName + conv21, err := convertSlice(w.Using, FunctionArgumentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RowFilterOptions.Using", err) + } + out.Using = conv21 + return out, nil +} + +// RowFilterOptionsFromSDK converts the sdk-go type to the mirror. +func RowFilterOptionsFromSDK(v *sdk.RowFilterOptions) (*RowFilterOptions, error) { + if v == nil { + return nil, nil + } + out := &RowFilterOptions{} + out.FunctionName = v.FunctionName + conv22, err := convertSlice(v.Using, FunctionArgumentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RowFilterOptions.Using", err) + } + out.Using = conv22 + return out, nil +} + +// TagIntrospectionExpressionToSDK converts the mirror to the sdk-go type. +func TagIntrospectionExpressionToSDK(w *TagIntrospectionExpression) (*sdk.TagIntrospectionExpression, error) { + if w == nil { + return nil, nil + } + out := &sdk.TagIntrospectionExpression{} + { + var members []string + if w.TagValue != nil { + members = append(members, "tag_value") + } + if w.ColumnTagValue != nil { + members = append(members, "column_tag_value") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.TagValue != nil: + conv23, err := TagValueExtractionToSDK(w.TagValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TagIntrospectionExpression.Expr", err) + } + out.Expr = &sdk.TagIntrospectionExpression_Expr_TagValue{TagValue: *conv23} + case w.ColumnTagValue != nil: + conv24, err := ColumnTagValueExtractionToSDK(w.ColumnTagValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TagIntrospectionExpression.Expr", err) + } + out.Expr = &sdk.TagIntrospectionExpression_Expr_ColumnTagValue{ColumnTagValue: *conv24} + } + return out, nil +} + +// TagIntrospectionExpressionFromSDK converts the sdk-go type to the mirror. +func TagIntrospectionExpressionFromSDK(v *sdk.TagIntrospectionExpression) (*TagIntrospectionExpression, error) { + if v == nil { + return nil, nil + } + out := &TagIntrospectionExpression{} + switch value := v.Expr.(type) { + case *sdk.TagIntrospectionExpression_Expr_TagValue: + if value != nil { + conv25, err := TagValueExtractionFromSDK(&value.TagValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TagIntrospectionExpression.Expr", err) + } + out.TagValue = conv25 + } + case *sdk.TagIntrospectionExpression_Expr_ColumnTagValue: + if value != nil { + conv26, err := ColumnTagValueExtractionFromSDK(&value.ColumnTagValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TagIntrospectionExpression.Expr", err) + } + out.ColumnTagValue = conv26 + } + } + return out, nil +} + +// TagValueExtractionToSDK converts the mirror to the sdk-go type. +func TagValueExtractionToSDK(w *TagValueExtraction) (*sdk.TagValueExtraction, error) { + if w == nil { + return nil, nil + } + out := &sdk.TagValueExtraction{} + out.TagKey = w.TagKey + return out, nil +} + +// TagValueExtractionFromSDK converts the sdk-go type to the mirror. +func TagValueExtractionFromSDK(v *sdk.TagValueExtraction) (*TagValueExtraction, error) { + if v == nil { + return nil, nil + } + out := &TagValueExtraction{} + out.TagKey = v.TagKey + return out, nil +} + +// UpdatePolicyRequestToSDK converts the mirror to the sdk-go type. +func UpdatePolicyRequestToSDK(w *UpdatePolicyRequest) (*sdk.UpdatePolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdatePolicyRequest{} + out.OnSecurableType = w.OnSecurableType + out.OnSecurableFullname = w.OnSecurableFullname + out.Name = w.Name + conv27, err := PolicyInfoToSDK(w.PolicyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePolicyRequest.PolicyInfo", err) + } + out.PolicyInfo = conv27 + mask28, err := fieldMaskFromString[sdk.PolicyInfo](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePolicyRequest.UpdateMask", err) + } + out.UpdateMask = mask28 + return out, nil +} + +// UpdatePolicyRequestFromSDK converts the sdk-go type to the mirror. +func UpdatePolicyRequestFromSDK(v *sdk.UpdatePolicyRequest) (*UpdatePolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdatePolicyRequest{} + out.OnSecurableType = v.OnSecurableType + out.OnSecurableFullname = v.OnSecurableFullname + out.Name = v.Name + conv29, err := PolicyInfoFromSDK(v.PolicyInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePolicyRequest.PolicyInfo", err) + } + out.PolicyInfo = conv29 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/uc/artifactallowlists/v1/types.generated.go b/libs/sdktypes/uc/artifactallowlists/v1/types.generated.go new file mode 100644 index 00000000000..7ec18f40ae9 --- /dev/null +++ b/libs/sdktypes/uc/artifactallowlists/v1/types.generated.go @@ -0,0 +1,161 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/artifactallowlists/v1. DO NOT EDIT. + +package artifactallowlists + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/artifactallowlists/v1" +) + +type ( + ArtifactType = sdk.ArtifactType + ArtifactMatcher_MatchType = sdk.ArtifactMatcher_MatchType +) + +const ( + ArtifactType_Unspecified = sdk.ArtifactType_Unspecified + ArtifactType_InitScript = sdk.ArtifactType_InitScript + ArtifactType_LibraryJar = sdk.ArtifactType_LibraryJar + ArtifactType_LibraryMaven = sdk.ArtifactType_LibraryMaven + ArtifactMatcher_MatchType_Unspecified = sdk.ArtifactMatcher_MatchType_Unspecified + ArtifactMatcher_MatchType_PrefixMatch = sdk.ArtifactMatcher_MatchType_PrefixMatch +) + +type ArtifactAllowlistInfo struct { + // A list of allowed artifact match patterns. + ArtifactMatchers []ArtifactMatcher `json:"artifact_matchers,omitempty"` + // Time at which this artifact allowlist was set, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of the user who set the artifact allowlist. + CreatedBy *string `json:"created_by,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` +} + +type ArtifactMatcher struct { + // The artifact path or maven coordinate + Artifact *string `json:"artifact,omitempty"` + // The pattern matching type of the artifact + MatchType ArtifactMatcher_MatchType `json:"match_type,omitempty"` +} + +type SetArtifactAllowlistRequest struct { + // A list of allowed artifact match patterns. + ArtifactMatchers []ArtifactMatcher `json:"artifact_matchers,omitempty"` + // The artifact type of the allowlist. + ArtifactType ArtifactType `json:"artifact_type,omitempty"` + // Time at which this artifact allowlist was set, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of the user who set the artifact allowlist. + CreatedBy *string `json:"created_by,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` +} + +// ArtifactAllowlistInfoToSDK converts the mirror to the sdk-go type. +func ArtifactAllowlistInfoToSDK(w *ArtifactAllowlistInfo) (*sdk.ArtifactAllowlistInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ArtifactAllowlistInfo{} + conv1, err := convertSlice(w.ArtifactMatchers, ArtifactMatcherToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ArtifactAllowlistInfo.ArtifactMatchers", err) + } + out.ArtifactMatchers = conv1 + out.MetastoreId = w.MetastoreId + out.CreatedBy = w.CreatedBy + out.CreatedAt = w.CreatedAt + return out, nil +} + +// ArtifactAllowlistInfoFromSDK converts the sdk-go type to the mirror. +func ArtifactAllowlistInfoFromSDK(v *sdk.ArtifactAllowlistInfo) (*ArtifactAllowlistInfo, error) { + if v == nil { + return nil, nil + } + out := &ArtifactAllowlistInfo{} + conv2, err := convertSlice(v.ArtifactMatchers, ArtifactMatcherFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ArtifactAllowlistInfo.ArtifactMatchers", err) + } + out.ArtifactMatchers = conv2 + out.MetastoreId = v.MetastoreId + out.CreatedBy = v.CreatedBy + out.CreatedAt = v.CreatedAt + return out, nil +} + +// ArtifactMatcherToSDK converts the mirror to the sdk-go type. +func ArtifactMatcherToSDK(w *ArtifactMatcher) (*sdk.ArtifactMatcher, error) { + if w == nil { + return nil, nil + } + out := &sdk.ArtifactMatcher{} + out.Artifact = w.Artifact + out.MatchType = w.MatchType + return out, nil +} + +// ArtifactMatcherFromSDK converts the sdk-go type to the mirror. +func ArtifactMatcherFromSDK(v *sdk.ArtifactMatcher) (*ArtifactMatcher, error) { + if v == nil { + return nil, nil + } + out := &ArtifactMatcher{} + out.Artifact = v.Artifact + out.MatchType = v.MatchType + return out, nil +} + +// SetArtifactAllowlistRequestToSDK converts the mirror to the sdk-go type. +func SetArtifactAllowlistRequestToSDK(w *SetArtifactAllowlistRequest) (*sdk.SetArtifactAllowlistRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SetArtifactAllowlistRequest{} + out.ArtifactType = w.ArtifactType + conv3, err := convertSlice(w.ArtifactMatchers, ArtifactMatcherToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetArtifactAllowlistRequest.ArtifactMatchers", err) + } + out.ArtifactMatchers = conv3 + out.MetastoreId = w.MetastoreId + out.CreatedBy = w.CreatedBy + out.CreatedAt = w.CreatedAt + return out, nil +} + +// SetArtifactAllowlistRequestFromSDK converts the sdk-go type to the mirror. +func SetArtifactAllowlistRequestFromSDK(v *sdk.SetArtifactAllowlistRequest) (*SetArtifactAllowlistRequest, error) { + if v == nil { + return nil, nil + } + out := &SetArtifactAllowlistRequest{} + out.ArtifactType = v.ArtifactType + conv4, err := convertSlice(v.ArtifactMatchers, ArtifactMatcherFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetArtifactAllowlistRequest.ArtifactMatchers", err) + } + out.ArtifactMatchers = conv4 + out.MetastoreId = v.MetastoreId + out.CreatedBy = v.CreatedBy + out.CreatedAt = v.CreatedAt + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/catalogs/v1/types.generated.go b/libs/sdktypes/uc/catalogs/v1/types.generated.go new file mode 100644 index 00000000000..bbf7fc3778f --- /dev/null +++ b/libs/sdktypes/uc/catalogs/v1/types.generated.go @@ -0,0 +1,808 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/catalogs/v1. DO NOT EDIT. + +package catalogs + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/catalogs/v1" +) + +type ( + CatalogIsolationMode = sdk.CatalogIsolationMode + CatalogType = sdk.CatalogType + SecurableType = sdk.SecurableType + ProvisioningInfo_State = sdk.ProvisioningInfo_State +) + +const ( + CatalogIsolationMode_Unspecified = sdk.CatalogIsolationMode_Unspecified + CatalogIsolationMode_Open = sdk.CatalogIsolationMode_Open + CatalogIsolationMode_Isolated = sdk.CatalogIsolationMode_Isolated + CatalogType_Unspecified = sdk.CatalogType_Unspecified + CatalogType_ManagedCatalog = sdk.CatalogType_ManagedCatalog + CatalogType_DeltasharingCatalog = sdk.CatalogType_DeltasharingCatalog + CatalogType_SystemCatalog = sdk.CatalogType_SystemCatalog + CatalogType_InternalCatalog = sdk.CatalogType_InternalCatalog + CatalogType_ForeignCatalog = sdk.CatalogType_ForeignCatalog + CatalogType_ManagedOnlineCatalog = sdk.CatalogType_ManagedOnlineCatalog + SecurableType_Unspecified = sdk.SecurableType_Unspecified + SecurableType_Catalog = sdk.SecurableType_Catalog + SecurableType_Schema = sdk.SecurableType_Schema + SecurableType_Table = sdk.SecurableType_Table + SecurableType_StorageCredential = sdk.SecurableType_StorageCredential + SecurableType_ExternalLocation = sdk.SecurableType_ExternalLocation + SecurableType_Function = sdk.SecurableType_Function + SecurableType_Share = sdk.SecurableType_Share + SecurableType_Provider = sdk.SecurableType_Provider + SecurableType_Recipient = sdk.SecurableType_Recipient + SecurableType_CleanRoom = sdk.SecurableType_CleanRoom + SecurableType_Metastore = sdk.SecurableType_Metastore + SecurableType_Pipeline = sdk.SecurableType_Pipeline + SecurableType_Volume = sdk.SecurableType_Volume + SecurableType_Connection = sdk.SecurableType_Connection + SecurableType_Credential = sdk.SecurableType_Credential + SecurableType_ExternalMetadata = sdk.SecurableType_ExternalMetadata + SecurableType_StagingTable = sdk.SecurableType_StagingTable + SecurableType_Model = sdk.SecurableType_Model + SecurableType_ModelService = sdk.SecurableType_ModelService + SecurableType_McpService = sdk.SecurableType_McpService + SecurableType_ModelProviderService = sdk.SecurableType_ModelProviderService + SecurableType_AgentService = sdk.SecurableType_AgentService + SecurableType_Skill = sdk.SecurableType_Skill + ProvisioningInfo_State_Unspecified = sdk.ProvisioningInfo_State_Unspecified + ProvisioningInfo_State_Provisioning = sdk.ProvisioningInfo_State_Provisioning + ProvisioningInfo_State_Active = sdk.ProvisioningInfo_State_Active + ProvisioningInfo_State_Failed = sdk.ProvisioningInfo_State_Failed + ProvisioningInfo_State_Deleting = sdk.ProvisioningInfo_State_Deleting + ProvisioningInfo_State_Updating = sdk.ProvisioningInfo_State_Updating + ProvisioningInfo_State_Degraded = sdk.ProvisioningInfo_State_Degraded +) + +type AzureEncryptionSettings struct { + AzureCmkAccessConnectorId *string `json:"azure_cmk_access_connector_id,omitempty"` + AzureCmkManagedIdentityId *string `json:"azure_cmk_managed_identity_id,omitempty"` + AzureTenantId *string `json:"azure_tenant_id,omitempty"` +} + +type CatalogInfo struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + CatalogType CatalogType `json:"catalog_type,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // The name of the connection to an external data source. + ConnectionName *string `json:"connection_name,omitempty"` + // Time at which this catalog was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of catalog creator. + CreatedBy *string `json:"created_by,omitempty"` + // Custom maximum retention period in hours for the catalog + CustomMaxRetentionHours *int64 `json:"custom_max_retention_hours,omitempty"` + EffectivePredictiveOptimizationFlag *EffectivePredictiveOptimizationFlag `json:"effective_predictive_optimization_flag,omitempty"` + // Whether predictive optimization should be enabled for this object and objects + // under it. + EnablePredictiveOptimization *string `json:"enable_predictive_optimization,omitempty"` + // The full name of the catalog. Corresponds with the name field. + FullName *string `json:"full_name,omitempty"` + // Whether the current securable is accessible from all workspaces or a specific + // set of workspaces. + IsolationMode CatalogIsolationMode `json:"isolation_mode,omitempty"` + // Control CMK encryption for managed catalog data + ManagedEncryptionSettings *EncryptionSettings `json:"managed_encryption_settings,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of catalog. + Name *string `json:"name,omitempty"` + // A map of key-value properties attached to the securable. + Options map[string]string `json:"options,omitempty"` + // Username of current owner of catalog. + Owner *string `json:"owner,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + // The name of delta sharing provider. + // + // A Delta Sharing catalog is a catalog that is based on a Delta share on a + // remote sharing server. + ProviderName *string `json:"provider_name,omitempty"` + ProvisioningInfo *ProvisioningInfo `json:"provisioning_info,omitempty"` + SecurableType SecurableType `json:"securable_type,omitempty"` + // The name of the share under the share provider. + ShareName *string `json:"share_name,omitempty"` + // Storage Location URL (full path) for managed tables within catalog. + StorageLocation *string `json:"storage_location,omitempty"` + // Storage root URL for managed tables within catalog. + StorageRoot *string `json:"storage_root,omitempty"` + // Time at which this catalog was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified catalog. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type CreateCatalogRequest struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + CatalogType CatalogType `json:"catalog_type,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // The name of the connection to an external data source. + ConnectionName *string `json:"connection_name,omitempty"` + // Time at which this catalog was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of catalog creator. + CreatedBy *string `json:"created_by,omitempty"` + // Custom maximum retention period in hours for the catalog + CustomMaxRetentionHours *int64 `json:"custom_max_retention_hours,omitempty"` + EffectivePredictiveOptimizationFlag *EffectivePredictiveOptimizationFlag `json:"effective_predictive_optimization_flag,omitempty"` + // Whether predictive optimization should be enabled for this object and objects + // under it. + EnablePredictiveOptimization *string `json:"enable_predictive_optimization,omitempty"` + // The full name of the catalog. Corresponds with the name field. + FullName *string `json:"full_name,omitempty"` + // Whether the current securable is accessible from all workspaces or a specific + // set of workspaces. + IsolationMode CatalogIsolationMode `json:"isolation_mode,omitempty"` + // Control CMK encryption for managed catalog data + ManagedEncryptionSettings *EncryptionSettings `json:"managed_encryption_settings,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of catalog. + Name *string `json:"name,omitempty"` + // A map of key-value properties attached to the securable. + Options map[string]string `json:"options,omitempty"` + // Username of current owner of catalog. + Owner *string `json:"owner,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + // The name of delta sharing provider. + // + // A Delta Sharing catalog is a catalog that is based on a Delta share on a + // remote sharing server. + ProviderName *string `json:"provider_name,omitempty"` + ProvisioningInfo *ProvisioningInfo `json:"provisioning_info,omitempty"` + SecurableType SecurableType `json:"securable_type,omitempty"` + // The name of the share under the share provider. + ShareName *string `json:"share_name,omitempty"` + // Storage Location URL (full path) for managed tables within catalog. + StorageLocation *string `json:"storage_location,omitempty"` + // Storage root URL for managed tables within catalog. + StorageRoot *string `json:"storage_root,omitempty"` + // Time at which this catalog was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified catalog. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type DeleteCatalogRequest struct { + // Force deletion even if the catalog is not empty. + Force *bool `json:"force,omitempty"` + // The name of the catalog. + NameArg *string `json:"name_arg,omitempty"` +} + +type EffectivePredictiveOptimizationFlag struct { + // The name of the object from which the flag was inherited. If there was no + // inheritance, this field is left blank. + InheritedFromName *string `json:"inherited_from_name,omitempty"` + // The type of the object from which the flag was inherited. If there was no + // inheritance, this field is left blank. + InheritedFromType *string `json:"inherited_from_type,omitempty"` + // Whether predictive optimization should be enabled for this object and objects + // under it. + Value *string `json:"value,omitempty"` +} + +// Encryption Settings are used to carry metadata for securable encryption at +// rest. Currently used for catalogs, we can use the information supplied here +// to interact with a CMK.. +type EncryptionSettings struct { + // optional Azure settings - only required if an Azure CMK is used. + AzureEncryptionSettings *AzureEncryptionSettings `json:"azure_encryption_settings,omitempty"` + // the AKV URL in Azure, null otherwise. + AzureKeyVaultKeyId *string `json:"azure_key_vault_key_id,omitempty"` + // the CMK uuid in AWS and GCP, null otherwise. + CustomerManagedKeyId *string `json:"customer_managed_key_id,omitempty"` +} + +type GetCatalogRequest struct { + // Whether to include catalogs in the response for which the principal can only + // access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` + // The name of the catalog. + NameArg *string `json:"name_arg,omitempty"` +} + +type ListCatalogsRequest struct { + // Whether to include catalogs in the response for which the principal can only + // access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` + // Whether to include catalogs not bound to the workspace. Effective only if the + // user has permission to update the catalog–workspace binding. + IncludeUnbound *bool `json:"include_unbound,omitempty"` + // Maximum number of catalogs to return. - when set to 0, the page length is set + // to a server configured value (recommended); - when set to a value greater + // than 0, the page length is the minimum of this value and a server configured + // value; - when set to a value less than 0, an invalid parameter error is + // returned; - If not set, all valid catalogs are returned (not recommended). - + // Note: The number of returned catalogs might be less than the specified + // max_results size, even zero. The only definitive indication that no further + // catalogs can be fetched is when the next_page_token is unset from the + // response. + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListCatalogsResponse struct { + // An array of catalog information objects. + Catalogs []CatalogInfo `json:"catalogs,omitempty"` + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Status of an asynchronously provisioned resource.. +type ProvisioningInfo struct { + // The provisioning state of the resource. + State ProvisioningInfo_State `json:"state,omitempty"` +} + +type UpdateCatalogRequest struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + CatalogType CatalogType `json:"catalog_type,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // The name of the connection to an external data source. + ConnectionName *string `json:"connection_name,omitempty"` + // Time at which this catalog was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of catalog creator. + CreatedBy *string `json:"created_by,omitempty"` + // Custom maximum retention period in hours for the catalog + CustomMaxRetentionHours *int64 `json:"custom_max_retention_hours,omitempty"` + EffectivePredictiveOptimizationFlag *EffectivePredictiveOptimizationFlag `json:"effective_predictive_optimization_flag,omitempty"` + // Whether predictive optimization should be enabled for this object and objects + // under it. + EnablePredictiveOptimization *string `json:"enable_predictive_optimization,omitempty"` + // The full name of the catalog. Corresponds with the name field. + FullName *string `json:"full_name,omitempty"` + // Whether the current securable is accessible from all workspaces or a specific + // set of workspaces. + IsolationMode CatalogIsolationMode `json:"isolation_mode,omitempty"` + // Control CMK encryption for managed catalog data + ManagedEncryptionSettings *EncryptionSettings `json:"managed_encryption_settings,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of catalog. + Name *string `json:"name,omitempty"` + // The name of the catalog. + NameArg *string `json:"name_arg,omitempty"` + // New name for the catalog. + NewName *string `json:"new_name,omitempty"` + // A map of key-value properties attached to the securable. + Options map[string]string `json:"options,omitempty"` + // Username of current owner of catalog. + Owner *string `json:"owner,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + // The name of delta sharing provider. + // + // A Delta Sharing catalog is a catalog that is based on a Delta share on a + // remote sharing server. + ProviderName *string `json:"provider_name,omitempty"` + ProvisioningInfo *ProvisioningInfo `json:"provisioning_info,omitempty"` + SecurableType SecurableType `json:"securable_type,omitempty"` + // The name of the share under the share provider. + ShareName *string `json:"share_name,omitempty"` + // Storage Location URL (full path) for managed tables within catalog. + StorageLocation *string `json:"storage_location,omitempty"` + // Storage root URL for managed tables within catalog. + StorageRoot *string `json:"storage_root,omitempty"` + // Time at which this catalog was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified catalog. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// AzureEncryptionSettingsToSDK converts the mirror to the sdk-go type. +func AzureEncryptionSettingsToSDK(w *AzureEncryptionSettings) (*sdk.AzureEncryptionSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.AzureEncryptionSettings{} + out.AzureTenantId = w.AzureTenantId + out.AzureCmkAccessConnectorId = w.AzureCmkAccessConnectorId + out.AzureCmkManagedIdentityId = w.AzureCmkManagedIdentityId + return out, nil +} + +// AzureEncryptionSettingsFromSDK converts the sdk-go type to the mirror. +func AzureEncryptionSettingsFromSDK(v *sdk.AzureEncryptionSettings) (*AzureEncryptionSettings, error) { + if v == nil { + return nil, nil + } + out := &AzureEncryptionSettings{} + out.AzureTenantId = v.AzureTenantId + out.AzureCmkAccessConnectorId = v.AzureCmkAccessConnectorId + out.AzureCmkManagedIdentityId = v.AzureCmkManagedIdentityId + return out, nil +} + +// CatalogInfoToSDK converts the mirror to the sdk-go type. +func CatalogInfoToSDK(w *CatalogInfo) (*sdk.CatalogInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.CatalogInfo{} + out.Name = w.Name + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageRoot = w.StorageRoot + out.EnablePredictiveOptimization = w.EnablePredictiveOptimization + out.CatalogType = w.CatalogType + out.ProviderName = w.ProviderName + out.ShareName = w.ShareName + out.ConnectionName = w.ConnectionName + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.StorageLocation = w.StorageLocation + out.IsolationMode = w.IsolationMode + conv1, err := EffectivePredictiveOptimizationFlagToSDK(w.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CatalogInfo.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv1 + out.BrowseOnly = w.BrowseOnly + conv2, err := ProvisioningInfoToSDK(w.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CatalogInfo.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv2 + out.FullName = w.FullName + out.SecurableType = w.SecurableType + out.CustomMaxRetentionHours = w.CustomMaxRetentionHours + conv3, err := EncryptionSettingsToSDK(w.ManagedEncryptionSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CatalogInfo.ManagedEncryptionSettings", err) + } + out.ManagedEncryptionSettings = conv3 + out.Properties = w.Properties + out.Options = w.Options + return out, nil +} + +// CatalogInfoFromSDK converts the sdk-go type to the mirror. +func CatalogInfoFromSDK(v *sdk.CatalogInfo) (*CatalogInfo, error) { + if v == nil { + return nil, nil + } + out := &CatalogInfo{} + out.Name = v.Name + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageRoot = v.StorageRoot + out.EnablePredictiveOptimization = v.EnablePredictiveOptimization + out.CatalogType = v.CatalogType + out.ProviderName = v.ProviderName + out.ShareName = v.ShareName + out.ConnectionName = v.ConnectionName + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.StorageLocation = v.StorageLocation + out.IsolationMode = v.IsolationMode + conv4, err := EffectivePredictiveOptimizationFlagFromSDK(v.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CatalogInfo.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv4 + out.BrowseOnly = v.BrowseOnly + conv5, err := ProvisioningInfoFromSDK(v.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CatalogInfo.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv5 + out.FullName = v.FullName + out.SecurableType = v.SecurableType + out.CustomMaxRetentionHours = v.CustomMaxRetentionHours + conv6, err := EncryptionSettingsFromSDK(v.ManagedEncryptionSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CatalogInfo.ManagedEncryptionSettings", err) + } + out.ManagedEncryptionSettings = conv6 + out.Properties = v.Properties + out.Options = v.Options + return out, nil +} + +// CreateCatalogRequestToSDK converts the mirror to the sdk-go type. +func CreateCatalogRequestToSDK(w *CreateCatalogRequest) (*sdk.CreateCatalogRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCatalogRequest{} + out.Name = w.Name + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageRoot = w.StorageRoot + out.EnablePredictiveOptimization = w.EnablePredictiveOptimization + out.CatalogType = w.CatalogType + out.ProviderName = w.ProviderName + out.ShareName = w.ShareName + out.ConnectionName = w.ConnectionName + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.StorageLocation = w.StorageLocation + out.IsolationMode = w.IsolationMode + conv7, err := EffectivePredictiveOptimizationFlagToSDK(w.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCatalogRequest.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv7 + out.BrowseOnly = w.BrowseOnly + conv8, err := ProvisioningInfoToSDK(w.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCatalogRequest.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv8 + out.FullName = w.FullName + out.SecurableType = w.SecurableType + out.CustomMaxRetentionHours = w.CustomMaxRetentionHours + conv9, err := EncryptionSettingsToSDK(w.ManagedEncryptionSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCatalogRequest.ManagedEncryptionSettings", err) + } + out.ManagedEncryptionSettings = conv9 + out.Properties = w.Properties + out.Options = w.Options + return out, nil +} + +// CreateCatalogRequestFromSDK converts the sdk-go type to the mirror. +func CreateCatalogRequestFromSDK(v *sdk.CreateCatalogRequest) (*CreateCatalogRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCatalogRequest{} + out.Name = v.Name + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageRoot = v.StorageRoot + out.EnablePredictiveOptimization = v.EnablePredictiveOptimization + out.CatalogType = v.CatalogType + out.ProviderName = v.ProviderName + out.ShareName = v.ShareName + out.ConnectionName = v.ConnectionName + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.StorageLocation = v.StorageLocation + out.IsolationMode = v.IsolationMode + conv10, err := EffectivePredictiveOptimizationFlagFromSDK(v.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCatalogRequest.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv10 + out.BrowseOnly = v.BrowseOnly + conv11, err := ProvisioningInfoFromSDK(v.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCatalogRequest.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv11 + out.FullName = v.FullName + out.SecurableType = v.SecurableType + out.CustomMaxRetentionHours = v.CustomMaxRetentionHours + conv12, err := EncryptionSettingsFromSDK(v.ManagedEncryptionSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCatalogRequest.ManagedEncryptionSettings", err) + } + out.ManagedEncryptionSettings = conv12 + out.Properties = v.Properties + out.Options = v.Options + return out, nil +} + +// DeleteCatalogRequestToSDK converts the mirror to the sdk-go type. +func DeleteCatalogRequestToSDK(w *DeleteCatalogRequest) (*sdk.DeleteCatalogRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteCatalogRequest{} + out.NameArg = w.NameArg + out.Force = w.Force + return out, nil +} + +// DeleteCatalogRequestFromSDK converts the sdk-go type to the mirror. +func DeleteCatalogRequestFromSDK(v *sdk.DeleteCatalogRequest) (*DeleteCatalogRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteCatalogRequest{} + out.NameArg = v.NameArg + out.Force = v.Force + return out, nil +} + +// EffectivePredictiveOptimizationFlagToSDK converts the mirror to the sdk-go type. +func EffectivePredictiveOptimizationFlagToSDK(w *EffectivePredictiveOptimizationFlag) (*sdk.EffectivePredictiveOptimizationFlag, error) { + if w == nil { + return nil, nil + } + out := &sdk.EffectivePredictiveOptimizationFlag{} + out.Value = w.Value + out.InheritedFromType = w.InheritedFromType + out.InheritedFromName = w.InheritedFromName + return out, nil +} + +// EffectivePredictiveOptimizationFlagFromSDK converts the sdk-go type to the mirror. +func EffectivePredictiveOptimizationFlagFromSDK(v *sdk.EffectivePredictiveOptimizationFlag) (*EffectivePredictiveOptimizationFlag, error) { + if v == nil { + return nil, nil + } + out := &EffectivePredictiveOptimizationFlag{} + out.Value = v.Value + out.InheritedFromType = v.InheritedFromType + out.InheritedFromName = v.InheritedFromName + return out, nil +} + +// EncryptionSettingsToSDK converts the mirror to the sdk-go type. +func EncryptionSettingsToSDK(w *EncryptionSettings) (*sdk.EncryptionSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.EncryptionSettings{} + out.CustomerManagedKeyId = w.CustomerManagedKeyId + out.AzureKeyVaultKeyId = w.AzureKeyVaultKeyId + conv13, err := AzureEncryptionSettingsToSDK(w.AzureEncryptionSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EncryptionSettings.AzureEncryptionSettings", err) + } + out.AzureEncryptionSettings = conv13 + return out, nil +} + +// EncryptionSettingsFromSDK converts the sdk-go type to the mirror. +func EncryptionSettingsFromSDK(v *sdk.EncryptionSettings) (*EncryptionSettings, error) { + if v == nil { + return nil, nil + } + out := &EncryptionSettings{} + out.CustomerManagedKeyId = v.CustomerManagedKeyId + out.AzureKeyVaultKeyId = v.AzureKeyVaultKeyId + conv14, err := AzureEncryptionSettingsFromSDK(v.AzureEncryptionSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EncryptionSettings.AzureEncryptionSettings", err) + } + out.AzureEncryptionSettings = conv14 + return out, nil +} + +// GetCatalogRequestToSDK converts the mirror to the sdk-go type. +func GetCatalogRequestToSDK(w *GetCatalogRequest) (*sdk.GetCatalogRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetCatalogRequest{} + out.NameArg = w.NameArg + out.IncludeBrowse = w.IncludeBrowse + return out, nil +} + +// GetCatalogRequestFromSDK converts the sdk-go type to the mirror. +func GetCatalogRequestFromSDK(v *sdk.GetCatalogRequest) (*GetCatalogRequest, error) { + if v == nil { + return nil, nil + } + out := &GetCatalogRequest{} + out.NameArg = v.NameArg + out.IncludeBrowse = v.IncludeBrowse + return out, nil +} + +// ListCatalogsRequestToSDK converts the mirror to the sdk-go type. +func ListCatalogsRequestToSDK(w *ListCatalogsRequest) (*sdk.ListCatalogsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCatalogsRequest{} + out.IncludeBrowse = w.IncludeBrowse + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + out.IncludeUnbound = w.IncludeUnbound + return out, nil +} + +// ListCatalogsRequestFromSDK converts the sdk-go type to the mirror. +func ListCatalogsRequestFromSDK(v *sdk.ListCatalogsRequest) (*ListCatalogsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCatalogsRequest{} + out.IncludeBrowse = v.IncludeBrowse + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + out.IncludeUnbound = v.IncludeUnbound + return out, nil +} + +// ListCatalogsResponseToSDK converts the mirror to the sdk-go type. +func ListCatalogsResponseToSDK(w *ListCatalogsResponse) (*sdk.ListCatalogsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCatalogsResponse{} + conv15, err := convertSlice(w.Catalogs, CatalogInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCatalogsResponse.Catalogs", err) + } + out.Catalogs = conv15 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCatalogsResponseFromSDK converts the sdk-go type to the mirror. +func ListCatalogsResponseFromSDK(v *sdk.ListCatalogsResponse) (*ListCatalogsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListCatalogsResponse{} + conv16, err := convertSlice(v.Catalogs, CatalogInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCatalogsResponse.Catalogs", err) + } + out.Catalogs = conv16 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ProvisioningInfoToSDK converts the mirror to the sdk-go type. +func ProvisioningInfoToSDK(w *ProvisioningInfo) (*sdk.ProvisioningInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProvisioningInfo{} + out.State = w.State + return out, nil +} + +// ProvisioningInfoFromSDK converts the sdk-go type to the mirror. +func ProvisioningInfoFromSDK(v *sdk.ProvisioningInfo) (*ProvisioningInfo, error) { + if v == nil { + return nil, nil + } + out := &ProvisioningInfo{} + out.State = v.State + return out, nil +} + +// UpdateCatalogRequestToSDK converts the mirror to the sdk-go type. +func UpdateCatalogRequestToSDK(w *UpdateCatalogRequest) (*sdk.UpdateCatalogRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCatalogRequest{} + out.NameArg = w.NameArg + out.NewName = w.NewName + out.Name = w.Name + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageRoot = w.StorageRoot + out.EnablePredictiveOptimization = w.EnablePredictiveOptimization + out.CatalogType = w.CatalogType + out.ProviderName = w.ProviderName + out.ShareName = w.ShareName + out.ConnectionName = w.ConnectionName + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.StorageLocation = w.StorageLocation + out.IsolationMode = w.IsolationMode + conv17, err := EffectivePredictiveOptimizationFlagToSDK(w.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCatalogRequest.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv17 + out.BrowseOnly = w.BrowseOnly + conv18, err := ProvisioningInfoToSDK(w.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCatalogRequest.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv18 + out.FullName = w.FullName + out.SecurableType = w.SecurableType + out.CustomMaxRetentionHours = w.CustomMaxRetentionHours + conv19, err := EncryptionSettingsToSDK(w.ManagedEncryptionSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCatalogRequest.ManagedEncryptionSettings", err) + } + out.ManagedEncryptionSettings = conv19 + out.Properties = w.Properties + out.Options = w.Options + return out, nil +} + +// UpdateCatalogRequestFromSDK converts the sdk-go type to the mirror. +func UpdateCatalogRequestFromSDK(v *sdk.UpdateCatalogRequest) (*UpdateCatalogRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateCatalogRequest{} + out.NameArg = v.NameArg + out.NewName = v.NewName + out.Name = v.Name + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageRoot = v.StorageRoot + out.EnablePredictiveOptimization = v.EnablePredictiveOptimization + out.CatalogType = v.CatalogType + out.ProviderName = v.ProviderName + out.ShareName = v.ShareName + out.ConnectionName = v.ConnectionName + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.StorageLocation = v.StorageLocation + out.IsolationMode = v.IsolationMode + conv20, err := EffectivePredictiveOptimizationFlagFromSDK(v.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCatalogRequest.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv20 + out.BrowseOnly = v.BrowseOnly + conv21, err := ProvisioningInfoFromSDK(v.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCatalogRequest.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv21 + out.FullName = v.FullName + out.SecurableType = v.SecurableType + out.CustomMaxRetentionHours = v.CustomMaxRetentionHours + conv22, err := EncryptionSettingsFromSDK(v.ManagedEncryptionSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCatalogRequest.ManagedEncryptionSettings", err) + } + out.ManagedEncryptionSettings = conv22 + out.Properties = v.Properties + out.Options = v.Options + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/connections/v1/types.generated.go b/libs/sdktypes/uc/connections/v1/types.generated.go new file mode 100644 index 00000000000..592df3c6640 --- /dev/null +++ b/libs/sdktypes/uc/connections/v1/types.generated.go @@ -0,0 +1,593 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/connections/v1. DO NOT EDIT. + +package connections + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/connections/v1" +) + +type ( + ConnectionType = sdk.ConnectionType + CredentialType = sdk.CredentialType + SecurableType = sdk.SecurableType + ProvisioningInfo_State = sdk.ProvisioningInfo_State +) + +const ( + ConnectionType_Unspecified = sdk.ConnectionType_Unspecified + ConnectionType_Mysql = sdk.ConnectionType_Mysql + ConnectionType_Postgresql = sdk.ConnectionType_Postgresql + ConnectionType_Snowflake = sdk.ConnectionType_Snowflake + ConnectionType_Redshift = sdk.ConnectionType_Redshift + ConnectionType_Sqldw = sdk.ConnectionType_Sqldw + ConnectionType_Sqlserver = sdk.ConnectionType_Sqlserver + ConnectionType_Databricks = sdk.ConnectionType_Databricks + ConnectionType_Salesforce = sdk.ConnectionType_Salesforce + ConnectionType_Bigquery = sdk.ConnectionType_Bigquery + ConnectionType_Netsuite = sdk.ConnectionType_Netsuite + ConnectionType_WorkdayRaas = sdk.ConnectionType_WorkdayRaas + ConnectionType_HiveMetastore = sdk.ConnectionType_HiveMetastore + ConnectionType_Ga4RawData = sdk.ConnectionType_Ga4RawData + ConnectionType_Servicenow = sdk.ConnectionType_Servicenow + ConnectionType_SalesforceDataCloud = sdk.ConnectionType_SalesforceDataCloud + ConnectionType_Glue = sdk.ConnectionType_Glue + ConnectionType_Oracle = sdk.ConnectionType_Oracle + ConnectionType_Teradata = sdk.ConnectionType_Teradata + ConnectionType_Http = sdk.ConnectionType_Http + ConnectionType_PowerBi = sdk.ConnectionType_PowerBi + ConnectionType_Dynamics365 = sdk.ConnectionType_Dynamics365 + ConnectionType_Confluence = sdk.ConnectionType_Confluence + ConnectionType_Jdbc = sdk.ConnectionType_Jdbc + ConnectionType_MetaMarketing = sdk.ConnectionType_MetaMarketing + ConnectionType_TiktokAds = sdk.ConnectionType_TiktokAds + ConnectionType_Hubspot = sdk.ConnectionType_Hubspot + ConnectionType_Zendesk = sdk.ConnectionType_Zendesk + ConnectionType_AwsSecretsManager = sdk.ConnectionType_AwsSecretsManager + ConnectionType_AzureKeyVault = sdk.ConnectionType_AzureKeyVault + ConnectionType_Github = sdk.ConnectionType_Github + ConnectionType_Outlook = sdk.ConnectionType_Outlook + ConnectionType_Smartsheet = sdk.ConnectionType_Smartsheet + CredentialType_Unspecified = sdk.CredentialType_Unspecified + CredentialType_UsernamePassword = sdk.CredentialType_UsernamePassword + CredentialType_OauthU2m = sdk.CredentialType_OauthU2m + CredentialType_OauthM2m = sdk.CredentialType_OauthM2m + CredentialType_OauthRefreshToken = sdk.CredentialType_OauthRefreshToken + CredentialType_OauthAccessToken = sdk.CredentialType_OauthAccessToken + CredentialType_OauthResourceOwnerPassword = sdk.CredentialType_OauthResourceOwnerPassword + CredentialType_ServiceCredential = sdk.CredentialType_ServiceCredential + CredentialType_BearerToken = sdk.CredentialType_BearerToken + CredentialType_OidcToken = sdk.CredentialType_OidcToken + CredentialType_PemPrivateKey = sdk.CredentialType_PemPrivateKey + CredentialType_OauthU2mMapping = sdk.CredentialType_OauthU2mMapping + CredentialType_AnyStaticCredential = sdk.CredentialType_AnyStaticCredential + CredentialType_OauthMtls = sdk.CredentialType_OauthMtls + CredentialType_SswsToken = sdk.CredentialType_SswsToken + CredentialType_EdgegridAkamai = sdk.CredentialType_EdgegridAkamai + SecurableType_Unspecified = sdk.SecurableType_Unspecified + SecurableType_Catalog = sdk.SecurableType_Catalog + SecurableType_Schema = sdk.SecurableType_Schema + SecurableType_Table = sdk.SecurableType_Table + SecurableType_StorageCredential = sdk.SecurableType_StorageCredential + SecurableType_ExternalLocation = sdk.SecurableType_ExternalLocation + SecurableType_Function = sdk.SecurableType_Function + SecurableType_Share = sdk.SecurableType_Share + SecurableType_Provider = sdk.SecurableType_Provider + SecurableType_Recipient = sdk.SecurableType_Recipient + SecurableType_CleanRoom = sdk.SecurableType_CleanRoom + SecurableType_Metastore = sdk.SecurableType_Metastore + SecurableType_Pipeline = sdk.SecurableType_Pipeline + SecurableType_Volume = sdk.SecurableType_Volume + SecurableType_Connection = sdk.SecurableType_Connection + SecurableType_Credential = sdk.SecurableType_Credential + SecurableType_ExternalMetadata = sdk.SecurableType_ExternalMetadata + SecurableType_StagingTable = sdk.SecurableType_StagingTable + SecurableType_Model = sdk.SecurableType_Model + SecurableType_ModelService = sdk.SecurableType_ModelService + SecurableType_McpService = sdk.SecurableType_McpService + SecurableType_ModelProviderService = sdk.SecurableType_ModelProviderService + SecurableType_AgentService = sdk.SecurableType_AgentService + SecurableType_Skill = sdk.SecurableType_Skill + ProvisioningInfo_State_Unspecified = sdk.ProvisioningInfo_State_Unspecified + ProvisioningInfo_State_Provisioning = sdk.ProvisioningInfo_State_Provisioning + ProvisioningInfo_State_Active = sdk.ProvisioningInfo_State_Active + ProvisioningInfo_State_Failed = sdk.ProvisioningInfo_State_Failed + ProvisioningInfo_State_Deleting = sdk.ProvisioningInfo_State_Deleting + ProvisioningInfo_State_Updating = sdk.ProvisioningInfo_State_Updating + ProvisioningInfo_State_Degraded = sdk.ProvisioningInfo_State_Degraded +) + +type ConnectionInfo struct { + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Unique identifier of the Connection. + ConnectionId *string `json:"connection_id,omitempty"` + // The type of connection. + ConnectionType ConnectionType `json:"connection_type,omitempty"` + // Time at which this connection was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of connection creator. + CreatedBy *string `json:"created_by,omitempty"` + // The type of credential. + CredentialType CredentialType `json:"credential_type,omitempty"` + // [Create,Update:OPT] Connection environment settings as EnvironmentSettings + // object. + EnvironmentSettings *EnvironmentSettings `json:"environment_settings,omitempty"` + // Full name of connection. + FullName *string `json:"full_name,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of the connection. + Name *string `json:"name,omitempty"` + // A map of key-value properties attached to the securable. + Options map[string]string `json:"options,omitempty"` + // Username of current owner of the connection. + Owner *string `json:"owner,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + ProvisioningInfo *ProvisioningInfo `json:"provisioning_info,omitempty"` + // If the connection is read only. + ReadOnly *bool `json:"read_only,omitempty"` + SecurableType SecurableType `json:"securable_type,omitempty"` + // Time at which this connection was updated, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified connection. + UpdatedBy *string `json:"updated_by,omitempty"` + // URL of the remote data source, extracted from options. + Url *string `json:"url,omitempty"` +} + +type CreateConnectionRequest struct { + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Unique identifier of the Connection. + ConnectionId *string `json:"connection_id,omitempty"` + // The type of connection. + ConnectionType ConnectionType `json:"connection_type,omitempty"` + // Time at which this connection was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of connection creator. + CreatedBy *string `json:"created_by,omitempty"` + // The type of credential. + CredentialType CredentialType `json:"credential_type,omitempty"` + // [Create,Update:OPT] Connection environment settings as EnvironmentSettings + // object. + EnvironmentSettings *EnvironmentSettings `json:"environment_settings,omitempty"` + // Full name of connection. + FullName *string `json:"full_name,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of the connection. + Name *string `json:"name,omitempty"` + // A map of key-value properties attached to the securable. + Options map[string]string `json:"options,omitempty"` + // Username of current owner of the connection. + Owner *string `json:"owner,omitempty"` + // Parent schema for schema-level connections, in format + // "schemas/{catalog}.{schema}". Absent for metastore-level (L1) connections. + Parent *string `json:"parent,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + ProvisioningInfo *ProvisioningInfo `json:"provisioning_info,omitempty"` + // If the connection is read only. + ReadOnly *bool `json:"read_only,omitempty"` + SecurableType SecurableType `json:"securable_type,omitempty"` + // Time at which this connection was updated, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified connection. + UpdatedBy *string `json:"updated_by,omitempty"` + // URL of the remote data source, extracted from options. + Url *string `json:"url,omitempty"` +} + +type EnvironmentSettings struct { + EnvironmentVersion *string `json:"environment_version,omitempty"` + JavaDependencies []string `json:"java_dependencies,omitempty"` +} + +type ListConnectionsRequest struct { + // Maximum number of connections to return. - If not set, all connections are + // returned (not recommended). - when set to a value greater than 0, the page + // length is the minimum of this value and a server configured value; - when set + // to 0, the page length is set to a server configured value (recommended); - + // when set to a value less than 0, an invalid parameter error is returned; + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` + // Optional. Parent schema filter for listing schema-level connections, in + // format "schemas/{catalog}.{schema}". + Parent *string `json:"parent,omitempty"` +} + +type ListConnectionsResponse struct { + // An array of connection information objects. + Connections []ConnectionInfo `json:"connections,omitempty"` + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Status of an asynchronously provisioned resource.. +type ProvisioningInfo struct { + // The provisioning state of the resource. + State ProvisioningInfo_State `json:"state,omitempty"` +} + +type UpdateConnectionRequest struct { + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Unique identifier of the Connection. + ConnectionId *string `json:"connection_id,omitempty"` + // The type of connection. + ConnectionType ConnectionType `json:"connection_type,omitempty"` + // Time at which this connection was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of connection creator. + CreatedBy *string `json:"created_by,omitempty"` + // The type of credential. + CredentialType CredentialType `json:"credential_type,omitempty"` + // [Create,Update:OPT] Connection environment settings as EnvironmentSettings + // object. + EnvironmentSettings *EnvironmentSettings `json:"environment_settings,omitempty"` + // Full name of connection. + FullName *string `json:"full_name,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of the connection. + Name *string `json:"name,omitempty"` + // Name of the connection. + NameArg *string `json:"name_arg,omitempty"` + // New name for the connection. + NewName *string `json:"new_name,omitempty"` + // A map of key-value properties attached to the securable. + Options map[string]string `json:"options,omitempty"` + // Username of current owner of the connection. + Owner *string `json:"owner,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + ProvisioningInfo *ProvisioningInfo `json:"provisioning_info,omitempty"` + // If the connection is read only. + ReadOnly *bool `json:"read_only,omitempty"` + SecurableType SecurableType `json:"securable_type,omitempty"` + // Time at which this connection was updated, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified connection. + UpdatedBy *string `json:"updated_by,omitempty"` + // URL of the remote data source, extracted from options. + Url *string `json:"url,omitempty"` +} + +// ConnectionInfoToSDK converts the mirror to the sdk-go type. +func ConnectionInfoToSDK(w *ConnectionInfo) (*sdk.ConnectionInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ConnectionInfo{} + out.Name = w.Name + out.ConnectionType = w.ConnectionType + out.Owner = w.Owner + out.ReadOnly = w.ReadOnly + out.Comment = w.Comment + conv1, err := EnvironmentSettingsToSDK(w.EnvironmentSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectionInfo.EnvironmentSettings", err) + } + out.EnvironmentSettings = conv1 + out.FullName = w.FullName + out.Url = w.Url + out.CredentialType = w.CredentialType + out.ConnectionId = w.ConnectionId + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.SecurableType = w.SecurableType + conv2, err := ProvisioningInfoToSDK(w.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectionInfo.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv2 + out.Options = w.Options + out.Properties = w.Properties + return out, nil +} + +// ConnectionInfoFromSDK converts the sdk-go type to the mirror. +func ConnectionInfoFromSDK(v *sdk.ConnectionInfo) (*ConnectionInfo, error) { + if v == nil { + return nil, nil + } + out := &ConnectionInfo{} + out.Name = v.Name + out.ConnectionType = v.ConnectionType + out.Owner = v.Owner + out.ReadOnly = v.ReadOnly + out.Comment = v.Comment + conv3, err := EnvironmentSettingsFromSDK(v.EnvironmentSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectionInfo.EnvironmentSettings", err) + } + out.EnvironmentSettings = conv3 + out.FullName = v.FullName + out.Url = v.Url + out.CredentialType = v.CredentialType + out.ConnectionId = v.ConnectionId + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.SecurableType = v.SecurableType + conv4, err := ProvisioningInfoFromSDK(v.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ConnectionInfo.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv4 + out.Options = v.Options + out.Properties = v.Properties + return out, nil +} + +// CreateConnectionRequestToSDK converts the mirror to the sdk-go type. +func CreateConnectionRequestToSDK(w *CreateConnectionRequest) (*sdk.CreateConnectionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateConnectionRequest{} + out.Parent = w.Parent + out.Name = w.Name + out.ConnectionType = w.ConnectionType + out.Owner = w.Owner + out.ReadOnly = w.ReadOnly + out.Comment = w.Comment + conv5, err := EnvironmentSettingsToSDK(w.EnvironmentSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateConnectionRequest.EnvironmentSettings", err) + } + out.EnvironmentSettings = conv5 + out.FullName = w.FullName + out.Url = w.Url + out.CredentialType = w.CredentialType + out.ConnectionId = w.ConnectionId + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.SecurableType = w.SecurableType + conv6, err := ProvisioningInfoToSDK(w.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateConnectionRequest.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv6 + out.Options = w.Options + out.Properties = w.Properties + return out, nil +} + +// CreateConnectionRequestFromSDK converts the sdk-go type to the mirror. +func CreateConnectionRequestFromSDK(v *sdk.CreateConnectionRequest) (*CreateConnectionRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateConnectionRequest{} + out.Parent = v.Parent + out.Name = v.Name + out.ConnectionType = v.ConnectionType + out.Owner = v.Owner + out.ReadOnly = v.ReadOnly + out.Comment = v.Comment + conv7, err := EnvironmentSettingsFromSDK(v.EnvironmentSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateConnectionRequest.EnvironmentSettings", err) + } + out.EnvironmentSettings = conv7 + out.FullName = v.FullName + out.Url = v.Url + out.CredentialType = v.CredentialType + out.ConnectionId = v.ConnectionId + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.SecurableType = v.SecurableType + conv8, err := ProvisioningInfoFromSDK(v.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateConnectionRequest.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv8 + out.Options = v.Options + out.Properties = v.Properties + return out, nil +} + +// EnvironmentSettingsToSDK converts the mirror to the sdk-go type. +func EnvironmentSettingsToSDK(w *EnvironmentSettings) (*sdk.EnvironmentSettings, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnvironmentSettings{} + out.JavaDependencies = w.JavaDependencies + out.EnvironmentVersion = w.EnvironmentVersion + return out, nil +} + +// EnvironmentSettingsFromSDK converts the sdk-go type to the mirror. +func EnvironmentSettingsFromSDK(v *sdk.EnvironmentSettings) (*EnvironmentSettings, error) { + if v == nil { + return nil, nil + } + out := &EnvironmentSettings{} + out.JavaDependencies = v.JavaDependencies + out.EnvironmentVersion = v.EnvironmentVersion + return out, nil +} + +// ListConnectionsRequestToSDK converts the mirror to the sdk-go type. +func ListConnectionsRequestToSDK(w *ListConnectionsRequest) (*sdk.ListConnectionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListConnectionsRequest{} + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + out.Parent = w.Parent + return out, nil +} + +// ListConnectionsRequestFromSDK converts the sdk-go type to the mirror. +func ListConnectionsRequestFromSDK(v *sdk.ListConnectionsRequest) (*ListConnectionsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListConnectionsRequest{} + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + out.Parent = v.Parent + return out, nil +} + +// ListConnectionsResponseToSDK converts the mirror to the sdk-go type. +func ListConnectionsResponseToSDK(w *ListConnectionsResponse) (*sdk.ListConnectionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListConnectionsResponse{} + conv9, err := convertSlice(w.Connections, ConnectionInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListConnectionsResponse.Connections", err) + } + out.Connections = conv9 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListConnectionsResponseFromSDK converts the sdk-go type to the mirror. +func ListConnectionsResponseFromSDK(v *sdk.ListConnectionsResponse) (*ListConnectionsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListConnectionsResponse{} + conv10, err := convertSlice(v.Connections, ConnectionInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListConnectionsResponse.Connections", err) + } + out.Connections = conv10 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ProvisioningInfoToSDK converts the mirror to the sdk-go type. +func ProvisioningInfoToSDK(w *ProvisioningInfo) (*sdk.ProvisioningInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProvisioningInfo{} + out.State = w.State + return out, nil +} + +// ProvisioningInfoFromSDK converts the sdk-go type to the mirror. +func ProvisioningInfoFromSDK(v *sdk.ProvisioningInfo) (*ProvisioningInfo, error) { + if v == nil { + return nil, nil + } + out := &ProvisioningInfo{} + out.State = v.State + return out, nil +} + +// UpdateConnectionRequestToSDK converts the mirror to the sdk-go type. +func UpdateConnectionRequestToSDK(w *UpdateConnectionRequest) (*sdk.UpdateConnectionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateConnectionRequest{} + out.NameArg = w.NameArg + out.NewName = w.NewName + out.Name = w.Name + out.ConnectionType = w.ConnectionType + out.Owner = w.Owner + out.ReadOnly = w.ReadOnly + out.Comment = w.Comment + conv11, err := EnvironmentSettingsToSDK(w.EnvironmentSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateConnectionRequest.EnvironmentSettings", err) + } + out.EnvironmentSettings = conv11 + out.FullName = w.FullName + out.Url = w.Url + out.CredentialType = w.CredentialType + out.ConnectionId = w.ConnectionId + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.SecurableType = w.SecurableType + conv12, err := ProvisioningInfoToSDK(w.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateConnectionRequest.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv12 + out.Options = w.Options + out.Properties = w.Properties + return out, nil +} + +// UpdateConnectionRequestFromSDK converts the sdk-go type to the mirror. +func UpdateConnectionRequestFromSDK(v *sdk.UpdateConnectionRequest) (*UpdateConnectionRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateConnectionRequest{} + out.NameArg = v.NameArg + out.NewName = v.NewName + out.Name = v.Name + out.ConnectionType = v.ConnectionType + out.Owner = v.Owner + out.ReadOnly = v.ReadOnly + out.Comment = v.Comment + conv13, err := EnvironmentSettingsFromSDK(v.EnvironmentSettings) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateConnectionRequest.EnvironmentSettings", err) + } + out.EnvironmentSettings = conv13 + out.FullName = v.FullName + out.Url = v.Url + out.CredentialType = v.CredentialType + out.ConnectionId = v.ConnectionId + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.SecurableType = v.SecurableType + conv14, err := ProvisioningInfoFromSDK(v.ProvisioningInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateConnectionRequest.ProvisioningInfo", err) + } + out.ProvisioningInfo = conv14 + out.Options = v.Options + out.Properties = v.Properties + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/credentials/v1/types.generated.go b/libs/sdktypes/uc/credentials/v1/types.generated.go new file mode 100644 index 00000000000..0479c54d813 --- /dev/null +++ b/libs/sdktypes/uc/credentials/v1/types.generated.go @@ -0,0 +1,3919 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/credentials/v1. DO NOT EDIT. + +package credentials + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/credentials/v1" + + strings "strings" +) + +type ( + IsolationMode = sdk.IsolationMode + PathOperation = sdk.PathOperation + TableOperation = sdk.TableOperation + VolumeOperation = sdk.VolumeOperation + ValidateCredentialRequest_Result = sdk.ValidateCredentialRequest_Result + ValidateStorageCredentialRequest_FileOperation = sdk.ValidateStorageCredentialRequest_FileOperation + ValidateStorageCredentialRequest_Result = sdk.ValidateStorageCredentialRequest_Result +) + +const ( + IsolationMode_Unspecified = sdk.IsolationMode_Unspecified + IsolationMode_IsolationModeOpen = sdk.IsolationMode_IsolationModeOpen + IsolationMode_IsolationModeIsolated = sdk.IsolationMode_IsolationModeIsolated + PathOperation_Unspecified = sdk.PathOperation_Unspecified + PathOperation_PathRead = sdk.PathOperation_PathRead + PathOperation_PathReadWrite = sdk.PathOperation_PathReadWrite + PathOperation_PathCreateTable = sdk.PathOperation_PathCreateTable + TableOperation_Unspecified = sdk.TableOperation_Unspecified + TableOperation_Read = sdk.TableOperation_Read + TableOperation_ReadWrite = sdk.TableOperation_ReadWrite + VolumeOperation_Unspecified = sdk.VolumeOperation_Unspecified + VolumeOperation_ReadVolume = sdk.VolumeOperation_ReadVolume + VolumeOperation_WriteVolume = sdk.VolumeOperation_WriteVolume + ValidateCredentialRequest_Result_Unspecified = sdk.ValidateCredentialRequest_Result_Unspecified + ValidateCredentialRequest_Result_Pass = sdk.ValidateCredentialRequest_Result_Pass + ValidateCredentialRequest_Result_Fail = sdk.ValidateCredentialRequest_Result_Fail + ValidateCredentialRequest_Result_Skip = sdk.ValidateCredentialRequest_Result_Skip + ValidateStorageCredentialRequest_FileOperation_Unspecified = sdk.ValidateStorageCredentialRequest_FileOperation_Unspecified + ValidateStorageCredentialRequest_FileOperation_Read = sdk.ValidateStorageCredentialRequest_FileOperation_Read + ValidateStorageCredentialRequest_FileOperation_Write = sdk.ValidateStorageCredentialRequest_FileOperation_Write + ValidateStorageCredentialRequest_FileOperation_Delete = sdk.ValidateStorageCredentialRequest_FileOperation_Delete + ValidateStorageCredentialRequest_FileOperation_PathExists = sdk.ValidateStorageCredentialRequest_FileOperation_PathExists + ValidateStorageCredentialRequest_Result_Unspecified = sdk.ValidateStorageCredentialRequest_Result_Unspecified + ValidateStorageCredentialRequest_Result_Fail = sdk.ValidateStorageCredentialRequest_Result_Fail + ValidateStorageCredentialRequest_Result_Skip = sdk.ValidateStorageCredentialRequest_Result_Skip +) + +type AccountsCreateStorageCredentialRequest struct { + // account ID of any type. For non-E2 account types, get your + // account ID from the [Accounts Console] + // + // [Accounts Console]: https://docs.databricks.com/administration-guide/account-settings/usage.html + AccountId *string `json:"account_id,omitempty"` + CredentialInfo *CreateAccountsStorageCredential `json:"credential_info,omitempty"` + // Unity Catalog metastore ID + MetastoreId *string `json:"metastore_id,omitempty"` + // Optional, default false. Supplying true to this argument skips validation of + // the created set of credentials. + SkipValidation *bool `json:"skip_validation,omitempty"` +} + +type AccountsCreateStorageCredentialResponse struct { + CredentialInfo *StorageCredentialInfo `json:"credential_info,omitempty"` +} + +// Deletes a storage credential for an account. +type AccountsDeleteStorageCredentialRequest struct { + // account ID of any type. For non-E2 account types, get your + // account ID from the [Accounts Console] + // + // [Accounts Console]: https://docs.databricks.com/administration-guide/account-settings/usage.html + AccountId *string `json:"account_id,omitempty"` + // Force deletion even if the Storage Credential is not empty. Default is false. + Force *bool `json:"force,omitempty"` + // Unity Catalog metastore ID + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of the storage credential. + NameArg *string `json:"name_arg,omitempty"` +} + +// The storage credential was successfully retrieved.. +type AccountsGetStorageCredentialResponse struct { + CredentialInfo *StorageCredentialInfo `json:"credential_info,omitempty"` +} + +// The metastore storage credentials were successfully returned.. +type AccountsListStorageCredentialsResponse struct { + // An array of metastore storage credentials. + StorageCredentials []StorageCredentialInfo `json:"storage_credentials,omitempty"` +} + +// The storage credential to update.. +type AccountsUpdateStorageCredentialRequest struct { + // account ID of any type. For non-E2 account types, get your + // account ID from the [Accounts Console] + // + // [Accounts Console]: https://docs.databricks.com/administration-guide/account-settings/usage.html + AccountId *string `json:"account_id,omitempty"` + CredentialInfo *UpdateAccountsStorageCredential `json:"credential_info,omitempty"` + // Unity Catalog metastore ID + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of the storage credential. + NameArg *string `json:"name_arg,omitempty"` + // Optional. Supplying true to this argument skips validation of the updated set + // of credentials. + SkipValidation *bool `json:"skip_validation,omitempty"` +} + +// The storage credential was successfully updated.. +type AccountsUpdateStorageCredentialResponse struct { + CredentialInfo *StorageCredentialInfo `json:"credential_info,omitempty"` +} + +type AwsCredentials struct { + StsRole *AwsCredentials_StsRole `json:"sts_role,omitempty"` +} + +type AwsCredentials_StsRole struct { + // The Amazon Resource Name (ARN) of the cross account IAM role. + RoleArn *string `json:"role_arn,omitempty"` +} + +// The AWS IAM role configuration. +type AwsIamRole struct { + // The external ID used in role assumption to prevent the confused deputy + // problem. + ExternalId *string `json:"external_id,omitempty"` + // The Amazon Resource Name (ARN) of the AWS IAM role used to vend temporary + // credentials. + RoleArn *string `json:"role_arn,omitempty"` + // The Amazon Resource Name (ARN) of the AWS IAM user managed by . + // This is the identity that is going to assume the AWS IAM role. + UnityCatalogIamArn *string `json:"unity_catalog_iam_arn,omitempty"` +} + +// Azure Active Directory token, essentially the Oauth token for Azure Service +// Principal or Managed Identity. Read more at +// https://learn.microsoft.com/en-us/azure/databricks/dev-tools/api/latest/aad/service-prin-aad-token. +type AzureActiveDirectoryToken struct { + // Opaque token that contains claims that you can use in Azure Active Directory + // to access cloud services. + AadToken *string `json:"aad_token,omitempty"` +} + +// The Azure managed identity configuration.. +type AzureManagedIdentity struct { + // The Azure resource ID of the Azure Databricks Access Connector. Use the + // format + // `/subscriptions/{guid}/resourceGroups/{rg-name}/providers/Microsoft.Databricks/accessConnectors/{connector-name}`. + AccessConnectorId *string `json:"access_connector_id,omitempty"` + // The internal ID that represents this managed identity. + CredentialId *string `json:"credential_id,omitempty"` + // The Azure resource ID of the managed identity. Use the format, + // `/subscriptions/{guid}/resourceGroups/{rg-name}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identity-name}` + // This is only available for user-assgined identities. For system-assigned + // identities, the access_connector_id is used to identify the identity. If this + // field is not provided, then we assume the AzureManagedIdentity is using the + // system-assigned identity. + ManagedIdentityId *string `json:"managed_identity_id,omitempty"` +} + +// The Azure service principal configuration. Only applicable when purpose is +// **STORAGE**.. +type AzureServicePrincipal struct { + // The application ID of the application registration within the referenced AAD + // tenant. + ApplicationId *string `json:"application_id,omitempty"` + // The client secret generated for the above app ID in AAD. + ClientSecret *string `json:"client_secret,omitempty"` + // The directory ID corresponding to the Azure Active Directory (AAD) tenant of + // the application. + DirectoryId *string `json:"directory_id,omitempty"` +} + +// Azure temporary credentials for API authentication. Read more at +// https://docs.microsoft.com/en-us/rest/api/storageservices/create-user-delegation-sas. +type AzureUserDelegationSas struct { + // The signed URI (SAS Token) used to access blob services for a given path + SasToken *string `json:"sas_token,omitempty"` +} + +// The Cloudflare API token configuration. Read more at +// https://developers.cloudflare.com/r2/api/s3/tokens/. +type CloudflareApiToken struct { + // The access key ID associated with the API token. + AccessKeyId *string `json:"access_key_id,omitempty"` + // The ID of the account associated with the API token. + AccountId *string `json:"account_id,omitempty"` + // The secret access token generated for the above access key ID. + SecretAccessKey *string `json:"secret_access_key,omitempty"` +} + +type CreateAccountsStorageCredential struct { + AwsIamRole *AwsIamRole `json:"aws_iam_role,omitempty"` + AzureManagedIdentity *AzureManagedIdentity `json:"azure_managed_identity,omitempty"` + AzureServicePrincipal *AzureServicePrincipal `json:"azure_service_principal,omitempty"` + CloudflareApiToken *CloudflareApiToken `json:"cloudflare_api_token,omitempty"` + // Comment associated with the credential. + Comment *string `json:"comment,omitempty"` + // Time at which this credential was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of credential creator. + CreatedBy *string `json:"created_by,omitempty"` + DatabricksGcpServiceAccount *DatabricksGcpServiceAccount `json:"databricks_gcp_service_account,omitempty"` + // The full name of the credential. + FullName *string `json:"full_name,omitempty"` + GcpServiceAccountKey *GcpServiceAccountKey `json:"gcp_service_account_key,omitempty"` + // The unique identifier of the credential. + Id *string `json:"id,omitempty"` + // Whether the current securable is accessible from all workspaces or a specific + // set of workspaces. + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + // Unique identifier of the parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The credential name. The name must be unique among storage and service + // credentials within the metastore. + Name *string `json:"name,omitempty"` + // Username of current owner of credential. + Owner *string `json:"owner,omitempty"` + // Whether the credential is usable only for read operations. Only applicable + // when purpose is **STORAGE**. + ReadOnly *bool `json:"read_only,omitempty"` + // Time at which this credential was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the credential. + UpdatedBy *string `json:"updated_by,omitempty"` + // Whether this credential is the current metastore's root storage credential. + // Only applicable when purpose is **STORAGE**. + UsedForManagedStorage *bool `json:"used_for_managed_storage,omitempty"` +} + +type CreateCredentialAwsCredentials struct { + StsRole *AwsCredentials_StsRole `json:"sts_role,omitempty"` +} + +type CreateCredentialRequest struct { + AwsIamRole *AwsIamRole `json:"aws_iam_role,omitempty"` + AzureManagedIdentity *AzureManagedIdentity `json:"azure_managed_identity,omitempty"` + AzureServicePrincipal *AzureServicePrincipal `json:"azure_service_principal,omitempty"` + CloudflareApiToken *CloudflareApiToken `json:"cloudflare_api_token,omitempty"` + // Comment associated with the credential. + Comment *string `json:"comment,omitempty"` + // Time at which this credential was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of credential creator. + CreatedBy *string `json:"created_by,omitempty"` + DatabricksGcpServiceAccount *DatabricksGcpServiceAccount `json:"databricks_gcp_service_account,omitempty"` + // The full name of the credential. + FullName *string `json:"full_name,omitempty"` + GcpServiceAccountKey *GcpServiceAccountKey `json:"gcp_service_account_key,omitempty"` + // The unique identifier of the credential. + Id *string `json:"id,omitempty"` + // Whether the current securable is accessible from all workspaces or a specific + // set of workspaces. + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + // Unique identifier of the parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The credential name. The name must be unique among storage and service + // credentials within the metastore. + Name *string `json:"name,omitempty"` + // Username of current owner of credential. + Owner *string `json:"owner,omitempty"` + // Whether the credential is usable only for read operations. Only applicable + // when purpose is **STORAGE**. + ReadOnly *bool `json:"read_only,omitempty"` + // Optional. Supplying true to this argument skips validation of the created set + // of credentials. + SkipValidation *bool `json:"skip_validation,omitempty"` + // Time at which this credential was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the credential. + UpdatedBy *string `json:"updated_by,omitempty"` + // Whether this credential is the current metastore's root storage credential. + // Only applicable when purpose is **STORAGE**. + UsedForManagedStorage *bool `json:"used_for_managed_storage,omitempty"` +} + +type CreateCredentialsRequest struct { + AccountId *string `json:"account_id,omitempty"` + AwsCredentials *CreateCredentialAwsCredentials `json:"aws_credentials,omitempty"` + // The human-readable name of the credential configuration object. + CredentialsName *string `json:"credentials_name,omitempty"` +} + +type CreateStorageCredentialRequest struct { + AwsIamRole *AwsIamRole `json:"aws_iam_role,omitempty"` + AzureManagedIdentity *AzureManagedIdentity `json:"azure_managed_identity,omitempty"` + AzureServicePrincipal *AzureServicePrincipal `json:"azure_service_principal,omitempty"` + CloudflareApiToken *CloudflareApiToken `json:"cloudflare_api_token,omitempty"` + // Comment associated with the credential. + Comment *string `json:"comment,omitempty"` + // Time at which this credential was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of credential creator. + CreatedBy *string `json:"created_by,omitempty"` + DatabricksGcpServiceAccount *DatabricksGcpServiceAccount `json:"databricks_gcp_service_account,omitempty"` + // The full name of the credential. + FullName *string `json:"full_name,omitempty"` + GcpServiceAccountKey *GcpServiceAccountKey `json:"gcp_service_account_key,omitempty"` + // The unique identifier of the credential. + Id *string `json:"id,omitempty"` + // Whether the current securable is accessible from all workspaces or a specific + // set of workspaces. + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + // Unique identifier of the parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The credential name. The name must be unique among storage and service + // credentials within the metastore. + Name *string `json:"name,omitempty"` + // Username of current owner of credential. + Owner *string `json:"owner,omitempty"` + // Whether the credential is usable only for read operations. Only applicable + // when purpose is **STORAGE**. + ReadOnly *bool `json:"read_only,omitempty"` + // Supplying true to this argument skips validation of the created credential. + SkipValidation *bool `json:"skip_validation,omitempty"` + // Time at which this credential was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the credential. + UpdatedBy *string `json:"updated_by,omitempty"` + // Whether this credential is the current metastore's root storage credential. + // Only applicable when purpose is **STORAGE**. + UsedForManagedStorage *bool `json:"used_for_managed_storage,omitempty"` +} + +type CredentialInfo struct { + AwsIamRole *AwsIamRole `json:"aws_iam_role,omitempty"` + AzureManagedIdentity *AzureManagedIdentity `json:"azure_managed_identity,omitempty"` + AzureServicePrincipal *AzureServicePrincipal `json:"azure_service_principal,omitempty"` + CloudflareApiToken *CloudflareApiToken `json:"cloudflare_api_token,omitempty"` + // Comment associated with the credential. + Comment *string `json:"comment,omitempty"` + // Time at which this credential was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of credential creator. + CreatedBy *string `json:"created_by,omitempty"` + DatabricksGcpServiceAccount *DatabricksGcpServiceAccount `json:"databricks_gcp_service_account,omitempty"` + // The full name of the credential. + FullName *string `json:"full_name,omitempty"` + GcpServiceAccountKey *GcpServiceAccountKey `json:"gcp_service_account_key,omitempty"` + // The unique identifier of the credential. + Id *string `json:"id,omitempty"` + // Whether the current securable is accessible from all workspaces or a specific + // set of workspaces. + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + // Unique identifier of the parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The credential name. The name must be unique among storage and service + // credentials within the metastore. + Name *string `json:"name,omitempty"` + // Username of current owner of credential. + Owner *string `json:"owner,omitempty"` + // Whether the credential is usable only for read operations. Only applicable + // when purpose is **STORAGE**. + ReadOnly *bool `json:"read_only,omitempty"` + // Time at which this credential was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the credential. + UpdatedBy *string `json:"updated_by,omitempty"` + // Whether this credential is the current metastore's root storage credential. + // Only applicable when purpose is **STORAGE**. + UsedForManagedStorage *bool `json:"used_for_managed_storage,omitempty"` +} + +type Credentials struct { + // The account ID that hosts the credential. + AccountId *string `json:"account_id,omitempty"` + AwsCredentials *AwsCredentials `json:"aws_credentials,omitempty"` + // Time in epoch milliseconds when the credential was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // credential configuration ID. + CredentialsId *string `json:"credentials_id,omitempty"` + // The human-readable name of the credential configuration object. + CredentialsName *string `json:"credentials_name,omitempty"` +} + +// GCP long-lived credential. -created Google Cloud Storage service +// account.. +type DatabricksGcpServiceAccount struct { + // The internal ID that represents this managed identity. + CredentialId *string `json:"credential_id,omitempty"` + // The email of the service account. + Email *string `json:"email,omitempty"` + // The ID that represents the private key for this Service Account + PrivateKeyId *string `json:"private_key_id,omitempty"` +} + +type DeleteCredentialRequest struct { + // Force an update even if there are dependent services (when purpose is + // **SERVICE**) or dependent external locations and external tables (when + // purpose is **STORAGE**). + Force *bool `json:"force,omitempty"` + // Name of the credential. + NameArg *string `json:"name_arg,omitempty"` +} + +type DeleteStorageCredentialRequest struct { + // Force an update even if there are dependent external locations or external + // tables (when purpose is **STORAGE**) or dependent services (when purpose is + // **SERVICE**). + Force *bool `json:"force,omitempty"` + // Name of the storage credential. + NameArg *string `json:"name_arg,omitempty"` +} + +// GCP temporary credentials for API authentication. Read more at +// https://developers.google.com/identity/protocols/oauth2/service-account. +type GcpOauthToken struct { + OauthToken *string `json:"oauth_token,omitempty"` +} + +// GCP long-lived credential. GCP Service Account.. +type GcpServiceAccountKey struct { + // The email of the service account. + Email *string `json:"email,omitempty"` + // The service account's RSA private key. + PrivateKey *string `json:"private_key,omitempty"` + // The ID of the service account's private key. + PrivateKeyId *string `json:"private_key_id,omitempty"` +} + +type GenerateTemporaryPathCredentialRequest struct { + // Optional. When set to true, the service will not validate that the generated + // credentials can perform write operations, therefore no new paths will be + // created and the response will not contain valid credentials. Defaults to + // false. + DryRun *bool `json:"dry_run,omitempty"` + // The operation being performed on the path. + Operation PathOperation `json:"operation,omitempty"` + // URL for path-based access. + Url *string `json:"url,omitempty"` +} + +type GenerateTemporaryPathCredentialResponse struct { + AwsTempCredentials *TemporaryAwsCredentials `json:"aws_temp_credentials,omitempty"` + AzureAad *AzureActiveDirectoryToken `json:"azure_aad,omitempty"` + AzureUserDelegationSas *AzureUserDelegationSas `json:"azure_user_delegation_sas,omitempty"` + // Server time when the credential will expire, in epoch milliseconds. The API + // client is advised to cache the credential given this expiration time. + ExpirationTime *int64 `json:"expiration_time,omitempty"` + GcpOauthToken *GcpOauthToken `json:"gcp_oauth_token,omitempty"` + R2TempCredentials *R2Credentials `json:"r2_temp_credentials,omitempty"` + // The URL of the storage path accessible by the temporary credential. + Url *string `json:"url,omitempty"` +} + +type GenerateTemporaryServiceCredentialRequest struct { + AzureOptions *GenerateTemporaryServiceCredentialRequest_AzureOptions `json:"azure_options,omitempty"` + // The name of the service credential used to generate a temporary credential + CredentialName *string `json:"credential_name,omitempty"` + GcpOptions *GenerateTemporaryServiceCredentialRequest_GcpOptions `json:"gcp_options,omitempty"` +} + +// The Azure cloud options to customize the requested temporary credential. +type GenerateTemporaryServiceCredentialRequest_AzureOptions struct { + // The resources to which the temporary Azure credential should apply. These + // resources are the scopes that are passed to the token provider (see + // https://learn.microsoft.com/python/api/azure-core/azure.core.credentials.tokencredential?view=azure-python) + Resources []string `json:"resources,omitempty"` +} + +// The GCP cloud options to customize the requested temporary credential. +type GenerateTemporaryServiceCredentialRequest_GcpOptions struct { + // The scopes to which the temporary GCP credential should apply. These + // resources are the scopes that are passed to the token provider (see + // https://google-auth.readthedocs.io/en/latest/reference/google.auth.html#google.auth.credentials.Credentials) + Scopes []string `json:"scopes,omitempty"` +} + +type GenerateTemporaryTableCredentialRequest struct { + // The operation performed against the table data, either READ or READ_WRITE. If + // READ_WRITE is specified, the credentials returned will have write + // permissions, otherwise, it will be read only. + Operation TableOperation `json:"operation,omitempty"` + // UUID of the table to read or write. + TableId *string `json:"table_id,omitempty"` +} + +type GenerateTemporaryTableCredentialResponse struct { + AwsTempCredentials *TemporaryAwsCredentials `json:"aws_temp_credentials,omitempty"` + AzureAad *AzureActiveDirectoryToken `json:"azure_aad,omitempty"` + AzureUserDelegationSas *AzureUserDelegationSas `json:"azure_user_delegation_sas,omitempty"` + // Server time when the credential will expire, in epoch milliseconds. The API + // client is advised to cache the credential given this expiration time. + ExpirationTime *int64 `json:"expiration_time,omitempty"` + GcpOauthToken *GcpOauthToken `json:"gcp_oauth_token,omitempty"` + R2TempCredentials *R2Credentials `json:"r2_temp_credentials,omitempty"` + // The URL of the storage path accessible by the temporary credential. + Url *string `json:"url,omitempty"` +} + +// Generate volume credentials RPC. +type GenerateTemporaryVolumeCredentialRequest struct { + // The operation performed against the volume data, either READ_VOLUME or + // WRITE_VOLUME. If WRITE_VOLUME is specified, the credentials returned will + // have write permissions, otherwise, it will be read only. + Operation VolumeOperation `json:"operation,omitempty"` + // Id of the volume to read or write. + VolumeId *string `json:"volume_id,omitempty"` +} + +type GenerateTemporaryVolumeCredentialResponse struct { + AwsTempCredentials *TemporaryAwsCredentials `json:"aws_temp_credentials,omitempty"` + AzureAad *AzureActiveDirectoryToken `json:"azure_aad,omitempty"` + AzureUserDelegationSas *AzureUserDelegationSas `json:"azure_user_delegation_sas,omitempty"` + // Server time when the credential will expire, in epoch milliseconds. The API + // client is advised to cache the credential given this expiration time. + ExpirationTime *int64 `json:"expiration_time,omitempty"` + GcpOauthToken *GcpOauthToken `json:"gcp_oauth_token,omitempty"` + R2TempCredentials *R2Credentials `json:"r2_temp_credentials,omitempty"` + // The URL of the storage path accessible by the temporary credential. + Url *string `json:"url,omitempty"` +} + +// ListCredentialsRequest is used to list credentials in the metastore. Returns +// an array of credentials (as CredentialInfo objects). The array is limited to +// the credentials that the caller has permission to access. If the caller is a +// metastore admin, retrieval of credentials is unrestricted. +// +// There is no guarantee of a specific ordering of the elements in the array.. +type ListCredentialsRequest struct { + // Whether to include credentials not bound to the workspace. Effective only if + // the user has permission to update the credential–workspace binding. + IncludeUnbound *bool `json:"include_unbound,omitempty"` + // Maximum number of credentials to return. - If not set, the default max page + // size is used. - When set to a value greater than 0, the page length is the + // minimum of this value and a server-configured value. - When set to 0, the + // page length is set to a server-configured value (recommended). - When set to + // a value less than 0, an invalid parameter error is returned. + MaxResults *int `json:"max_results,omitempty"` + // Opaque token to retrieve the next page of results. + PageToken *string `json:"page_token,omitempty"` +} + +type ListCredentialsRequest_Response struct { + Credentials []CredentialInfo `json:"credentials,omitempty"` + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListStorageCredentialsRequest struct { + // Whether to include credentials not bound to the workspace. Effective only if + // the user has permission to update the credential–workspace binding. + IncludeUnbound *bool `json:"include_unbound,omitempty"` + // Maximum number of storage credentials to return. If not set, all the storage + // credentials are returned (not recommended). - when set to a value greater + // than 0, the page length is the minimum of this value and a server configured + // value; - when set to 0, the page length is set to a server configured value + // (recommended); - when set to a value less than 0, an invalid parameter error + // is returned; + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListStorageCredentialsResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + StorageCredentials []StorageCredentialInfo `json:"storage_credentials,omitempty"` +} + +// R2 temporary credentials for API authentication. Read more at +// https://developers.cloudflare.com/r2/api/s3/tokens/.. +type R2Credentials struct { + // The access key ID that identifies the temporary credentials. + AccessKeyId *string `json:"access_key_id,omitempty"` + // The secret access key associated with the access key. + SecretAccessKey *string `json:"secret_access_key,omitempty"` + // The generated JWT that users must pass to use the temporary credentials. + SessionToken *string `json:"session_token,omitempty"` +} + +type StorageCredentialInfo struct { + AwsIamRole *AwsIamRole `json:"aws_iam_role,omitempty"` + AzureManagedIdentity *AzureManagedIdentity `json:"azure_managed_identity,omitempty"` + AzureServicePrincipal *AzureServicePrincipal `json:"azure_service_principal,omitempty"` + CloudflareApiToken *CloudflareApiToken `json:"cloudflare_api_token,omitempty"` + // Comment associated with the credential. + Comment *string `json:"comment,omitempty"` + // Time at which this credential was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of credential creator. + CreatedBy *string `json:"created_by,omitempty"` + DatabricksGcpServiceAccount *DatabricksGcpServiceAccount `json:"databricks_gcp_service_account,omitempty"` + // The full name of the credential. + FullName *string `json:"full_name,omitempty"` + GcpServiceAccountKey *GcpServiceAccountKey `json:"gcp_service_account_key,omitempty"` + // The unique identifier of the credential. + Id *string `json:"id,omitempty"` + // Whether the current securable is accessible from all workspaces or a specific + // set of workspaces. + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + // Unique identifier of the parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The credential name. The name must be unique among storage and service + // credentials within the metastore. + Name *string `json:"name,omitempty"` + // Username of current owner of credential. + Owner *string `json:"owner,omitempty"` + // Whether the credential is usable only for read operations. Only applicable + // when purpose is **STORAGE**. + ReadOnly *bool `json:"read_only,omitempty"` + // Time at which this credential was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the credential. + UpdatedBy *string `json:"updated_by,omitempty"` + // Whether this credential is the current metastore's root storage credential. + // Only applicable when purpose is **STORAGE**. + UsedForManagedStorage *bool `json:"used_for_managed_storage,omitempty"` +} + +// AWS temporary credentials for API authentication. Read more at +// https://docs.aws.amazon.com/STS/latest/APIReference/API_Credentials.html.. +type TemporaryAwsCredentials struct { + // The access key ID that identifies the temporary credentials. + AccessKeyId *string `json:"access_key_id,omitempty"` + // The Amazon Resource Name (ARN) of the S3 access point for temporary + // credentials related the external location. + AccessPoint *string `json:"access_point,omitempty"` + // The secret access key that can be used to sign AWS API requests. + SecretAccessKey *string `json:"secret_access_key,omitempty"` + // The token that users must pass to AWS API to use the temporary credentials. + SessionToken *string `json:"session_token,omitempty"` +} + +type TemporaryCredentials struct { + AwsTempCredentials *TemporaryAwsCredentials `json:"aws_temp_credentials,omitempty"` + AzureAad *AzureActiveDirectoryToken `json:"azure_aad,omitempty"` + AzureUserDelegationSas *AzureUserDelegationSas `json:"azure_user_delegation_sas,omitempty"` + // Server time when the credential will expire, in epoch milliseconds. The API + // client is advised to cache the credential given this expiration time. + ExpirationTime *int64 `json:"expiration_time,omitempty"` + GcpOauthToken *GcpOauthToken `json:"gcp_oauth_token,omitempty"` + R2TempCredentials *R2Credentials `json:"r2_temp_credentials,omitempty"` + // The URL of the storage path accessible by the temporary credential. + Url *string `json:"url,omitempty"` +} + +type UpdateAccountsStorageCredential struct { + AwsIamRole *AwsIamRole `json:"aws_iam_role,omitempty"` + AzureManagedIdentity *AzureManagedIdentity `json:"azure_managed_identity,omitempty"` + AzureServicePrincipal *AzureServicePrincipal `json:"azure_service_principal,omitempty"` + CloudflareApiToken *CloudflareApiToken `json:"cloudflare_api_token,omitempty"` + // Comment associated with the credential. + Comment *string `json:"comment,omitempty"` + // Time at which this credential was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of credential creator. + CreatedBy *string `json:"created_by,omitempty"` + DatabricksGcpServiceAccount *DatabricksGcpServiceAccount `json:"databricks_gcp_service_account,omitempty"` + // The full name of the credential. + FullName *string `json:"full_name,omitempty"` + GcpServiceAccountKey *GcpServiceAccountKey `json:"gcp_service_account_key,omitempty"` + // The unique identifier of the credential. + Id *string `json:"id,omitempty"` + // Whether the current securable is accessible from all workspaces or a specific + // set of workspaces. + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + // Unique identifier of the parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The credential name. The name must be unique among storage and service + // credentials within the metastore. + Name *string `json:"name,omitempty"` + // Username of current owner of credential. + Owner *string `json:"owner,omitempty"` + // Whether the credential is usable only for read operations. Only applicable + // when purpose is **STORAGE**. + ReadOnly *bool `json:"read_only,omitempty"` + // Time at which this credential was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the credential. + UpdatedBy *string `json:"updated_by,omitempty"` + // Whether this credential is the current metastore's root storage credential. + // Only applicable when purpose is **STORAGE**. + UsedForManagedStorage *bool `json:"used_for_managed_storage,omitempty"` +} + +type UpdateCredentialRequest struct { + AwsIamRole *AwsIamRole `json:"aws_iam_role,omitempty"` + AzureManagedIdentity *AzureManagedIdentity `json:"azure_managed_identity,omitempty"` + AzureServicePrincipal *AzureServicePrincipal `json:"azure_service_principal,omitempty"` + CloudflareApiToken *CloudflareApiToken `json:"cloudflare_api_token,omitempty"` + // Comment associated with the credential. + Comment *string `json:"comment,omitempty"` + // Time at which this credential was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of credential creator. + CreatedBy *string `json:"created_by,omitempty"` + DatabricksGcpServiceAccount *DatabricksGcpServiceAccount `json:"databricks_gcp_service_account,omitempty"` + // Force an update even if there are dependent services (when purpose is + // **SERVICE**) or dependent external locations and external tables (when + // purpose is **STORAGE**). + Force *bool `json:"force,omitempty"` + // The full name of the credential. + FullName *string `json:"full_name,omitempty"` + GcpServiceAccountKey *GcpServiceAccountKey `json:"gcp_service_account_key,omitempty"` + // The unique identifier of the credential. + Id *string `json:"id,omitempty"` + // Whether the current securable is accessible from all workspaces or a specific + // set of workspaces. + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + // Unique identifier of the parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The credential name. The name must be unique among storage and service + // credentials within the metastore. + Name *string `json:"name,omitempty"` + // Name of the credential. + NameArg *string `json:"name_arg,omitempty"` + // New name of credential. + NewName *string `json:"new_name,omitempty"` + // Username of current owner of credential. + Owner *string `json:"owner,omitempty"` + // Whether the credential is usable only for read operations. Only applicable + // when purpose is **STORAGE**. + ReadOnly *bool `json:"read_only,omitempty"` + // Supply true to this argument to skip validation of the updated credential. + SkipValidation *bool `json:"skip_validation,omitempty"` + // Time at which this credential was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the credential. + UpdatedBy *string `json:"updated_by,omitempty"` + // Whether this credential is the current metastore's root storage credential. + // Only applicable when purpose is **STORAGE**. + UsedForManagedStorage *bool `json:"used_for_managed_storage,omitempty"` +} + +type UpdateStorageCredentialRequest struct { + AwsIamRole *AwsIamRole `json:"aws_iam_role,omitempty"` + AzureManagedIdentity *AzureManagedIdentity `json:"azure_managed_identity,omitempty"` + AzureServicePrincipal *AzureServicePrincipal `json:"azure_service_principal,omitempty"` + CloudflareApiToken *CloudflareApiToken `json:"cloudflare_api_token,omitempty"` + // Comment associated with the credential. + Comment *string `json:"comment,omitempty"` + // Time at which this credential was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of credential creator. + CreatedBy *string `json:"created_by,omitempty"` + DatabricksGcpServiceAccount *DatabricksGcpServiceAccount `json:"databricks_gcp_service_account,omitempty"` + // Force update even if there are dependent external locations or external + // tables. + Force *bool `json:"force,omitempty"` + // The full name of the credential. + FullName *string `json:"full_name,omitempty"` + GcpServiceAccountKey *GcpServiceAccountKey `json:"gcp_service_account_key,omitempty"` + // The unique identifier of the credential. + Id *string `json:"id,omitempty"` + // Whether the current securable is accessible from all workspaces or a specific + // set of workspaces. + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + // Unique identifier of the parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The credential name. The name must be unique among storage and service + // credentials within the metastore. + Name *string `json:"name,omitempty"` + // Name of the storage credential. + NameArg *string `json:"name_arg,omitempty"` + // New name for the storage credential. + NewName *string `json:"new_name,omitempty"` + // Username of current owner of credential. + Owner *string `json:"owner,omitempty"` + // Whether the credential is usable only for read operations. Only applicable + // when purpose is **STORAGE**. + ReadOnly *bool `json:"read_only,omitempty"` + // Supplying true to this argument skips validation of the updated credential. + SkipValidation *bool `json:"skip_validation,omitempty"` + // Time at which this credential was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the credential. + UpdatedBy *string `json:"updated_by,omitempty"` + // Whether this credential is the current metastore's root storage credential. + // Only applicable when purpose is **STORAGE**. + UsedForManagedStorage *bool `json:"used_for_managed_storage,omitempty"` +} + +type ValidateCredentialRequest struct { + AwsIamRole *AwsIamRole `json:"aws_iam_role,omitempty"` + AzureManagedIdentity *AzureManagedIdentity `json:"azure_managed_identity,omitempty"` + CredentialName *string `json:"credential_name,omitempty"` + DatabricksGcpServiceAccount *DatabricksGcpServiceAccount `json:"databricks_gcp_service_account,omitempty"` + // The name of an existing external location to validate. Only applicable for + // storage credentials (purpose is **STORAGE**.) + ExternalLocationName *string `json:"external_location_name,omitempty"` + // Whether the credential is only usable for read operations. Only applicable + // for storage credentials (purpose is **STORAGE**.) + ReadOnly *bool `json:"read_only,omitempty"` + // The external location url to validate. Only applicable when purpose is + // **STORAGE**. + Url *string `json:"url,omitempty"` +} + +type ValidateCredentialRequest_ValidationResult struct { + // Error message would exist when the result does not equal to **PASS**. + Message *string `json:"message,omitempty"` + // The results of the tested operation. + Result ValidateCredentialRequest_Result `json:"result,omitempty"` +} + +type ValidateCredentialResponse struct { + // Whether the tested location is a directory in cloud storage. Only applicable + // for when purpose is **STORAGE**. + IsDir *bool `json:"isDir,omitempty"` + // The results of the validation check. + Results []ValidateCredentialRequest_ValidationResult `json:"results,omitempty"` +} + +type ValidateStorageCredentialRequest struct { + AwsIamRole *AwsIamRole `json:"aws_iam_role,omitempty"` + AzureManagedIdentity *AzureManagedIdentity `json:"azure_managed_identity,omitempty"` + AzureServicePrincipal *AzureServicePrincipal `json:"azure_service_principal,omitempty"` + CloudflareApiToken *CloudflareApiToken `json:"cloudflare_api_token,omitempty"` + DatabricksGcpServiceAccount *DatabricksGcpServiceAccount `json:"databricks_gcp_service_account,omitempty"` + // The name of an existing external location to validate. + ExternalLocationName *string `json:"external_location_name,omitempty"` + // Whether the storage credential is only usable for read operations. + ReadOnly *bool `json:"read_only,omitempty"` + StorageCredentialName *string `json:"storage_credential_name,omitempty"` + // The external location url to validate. + Url *string `json:"url,omitempty"` +} + +type ValidateStorageCredentialRequest_ValidationResult struct { + // Error message would exist when the result does not equal to **PASS**. + Message *string `json:"message,omitempty"` + // The operation tested. + Operation ValidateStorageCredentialRequest_FileOperation `json:"operation,omitempty"` + // The results of the tested operation. + Result ValidateStorageCredentialRequest_Result `json:"result,omitempty"` +} + +type ValidateStorageCredentialResponse struct { + // Whether the tested location is a directory in cloud storage. + IsDir *bool `json:"isDir,omitempty"` + // The results of the validation check. + Results []ValidateStorageCredentialRequest_ValidationResult `json:"results,omitempty"` +} + +// AccountsCreateStorageCredentialRequestToSDK converts the mirror to the sdk-go type. +func AccountsCreateStorageCredentialRequestToSDK(w *AccountsCreateStorageCredentialRequest) (*sdk.AccountsCreateStorageCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsCreateStorageCredentialRequest{} + out.AccountId = w.AccountId + out.MetastoreId = w.MetastoreId + conv1, err := CreateAccountsStorageCredentialToSDK(w.CredentialInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsCreateStorageCredentialRequest.CredentialInfo", err) + } + out.CredentialInfo = conv1 + out.SkipValidation = w.SkipValidation + return out, nil +} + +// AccountsCreateStorageCredentialRequestFromSDK converts the sdk-go type to the mirror. +func AccountsCreateStorageCredentialRequestFromSDK(v *sdk.AccountsCreateStorageCredentialRequest) (*AccountsCreateStorageCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &AccountsCreateStorageCredentialRequest{} + out.AccountId = v.AccountId + out.MetastoreId = v.MetastoreId + conv2, err := CreateAccountsStorageCredentialFromSDK(v.CredentialInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsCreateStorageCredentialRequest.CredentialInfo", err) + } + out.CredentialInfo = conv2 + out.SkipValidation = v.SkipValidation + return out, nil +} + +// AccountsCreateStorageCredentialResponseToSDK converts the mirror to the sdk-go type. +func AccountsCreateStorageCredentialResponseToSDK(w *AccountsCreateStorageCredentialResponse) (*sdk.AccountsCreateStorageCredentialResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsCreateStorageCredentialResponse{} + conv3, err := StorageCredentialInfoToSDK(w.CredentialInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsCreateStorageCredentialResponse.CredentialInfo", err) + } + out.CredentialInfo = conv3 + return out, nil +} + +// AccountsCreateStorageCredentialResponseFromSDK converts the sdk-go type to the mirror. +func AccountsCreateStorageCredentialResponseFromSDK(v *sdk.AccountsCreateStorageCredentialResponse) (*AccountsCreateStorageCredentialResponse, error) { + if v == nil { + return nil, nil + } + out := &AccountsCreateStorageCredentialResponse{} + conv4, err := StorageCredentialInfoFromSDK(v.CredentialInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsCreateStorageCredentialResponse.CredentialInfo", err) + } + out.CredentialInfo = conv4 + return out, nil +} + +// AccountsDeleteStorageCredentialRequestToSDK converts the mirror to the sdk-go type. +func AccountsDeleteStorageCredentialRequestToSDK(w *AccountsDeleteStorageCredentialRequest) (*sdk.AccountsDeleteStorageCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsDeleteStorageCredentialRequest{} + out.AccountId = w.AccountId + out.MetastoreId = w.MetastoreId + out.NameArg = w.NameArg + out.Force = w.Force + return out, nil +} + +// AccountsDeleteStorageCredentialRequestFromSDK converts the sdk-go type to the mirror. +func AccountsDeleteStorageCredentialRequestFromSDK(v *sdk.AccountsDeleteStorageCredentialRequest) (*AccountsDeleteStorageCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &AccountsDeleteStorageCredentialRequest{} + out.AccountId = v.AccountId + out.MetastoreId = v.MetastoreId + out.NameArg = v.NameArg + out.Force = v.Force + return out, nil +} + +// AccountsGetStorageCredentialResponseToSDK converts the mirror to the sdk-go type. +func AccountsGetStorageCredentialResponseToSDK(w *AccountsGetStorageCredentialResponse) (*sdk.AccountsGetStorageCredentialResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsGetStorageCredentialResponse{} + conv5, err := StorageCredentialInfoToSDK(w.CredentialInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsGetStorageCredentialResponse.CredentialInfo", err) + } + out.CredentialInfo = conv5 + return out, nil +} + +// AccountsGetStorageCredentialResponseFromSDK converts the sdk-go type to the mirror. +func AccountsGetStorageCredentialResponseFromSDK(v *sdk.AccountsGetStorageCredentialResponse) (*AccountsGetStorageCredentialResponse, error) { + if v == nil { + return nil, nil + } + out := &AccountsGetStorageCredentialResponse{} + conv6, err := StorageCredentialInfoFromSDK(v.CredentialInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsGetStorageCredentialResponse.CredentialInfo", err) + } + out.CredentialInfo = conv6 + return out, nil +} + +// AccountsListStorageCredentialsResponseToSDK converts the mirror to the sdk-go type. +func AccountsListStorageCredentialsResponseToSDK(w *AccountsListStorageCredentialsResponse) (*sdk.AccountsListStorageCredentialsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsListStorageCredentialsResponse{} + conv7, err := convertSlice(w.StorageCredentials, StorageCredentialInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsListStorageCredentialsResponse.StorageCredentials", err) + } + out.StorageCredentials = conv7 + return out, nil +} + +// AccountsListStorageCredentialsResponseFromSDK converts the sdk-go type to the mirror. +func AccountsListStorageCredentialsResponseFromSDK(v *sdk.AccountsListStorageCredentialsResponse) (*AccountsListStorageCredentialsResponse, error) { + if v == nil { + return nil, nil + } + out := &AccountsListStorageCredentialsResponse{} + conv8, err := convertSlice(v.StorageCredentials, StorageCredentialInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsListStorageCredentialsResponse.StorageCredentials", err) + } + out.StorageCredentials = conv8 + return out, nil +} + +// AccountsUpdateStorageCredentialRequestToSDK converts the mirror to the sdk-go type. +func AccountsUpdateStorageCredentialRequestToSDK(w *AccountsUpdateStorageCredentialRequest) (*sdk.AccountsUpdateStorageCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsUpdateStorageCredentialRequest{} + out.AccountId = w.AccountId + out.MetastoreId = w.MetastoreId + out.NameArg = w.NameArg + conv9, err := UpdateAccountsStorageCredentialToSDK(w.CredentialInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsUpdateStorageCredentialRequest.CredentialInfo", err) + } + out.CredentialInfo = conv9 + out.SkipValidation = w.SkipValidation + return out, nil +} + +// AccountsUpdateStorageCredentialRequestFromSDK converts the sdk-go type to the mirror. +func AccountsUpdateStorageCredentialRequestFromSDK(v *sdk.AccountsUpdateStorageCredentialRequest) (*AccountsUpdateStorageCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &AccountsUpdateStorageCredentialRequest{} + out.AccountId = v.AccountId + out.MetastoreId = v.MetastoreId + out.NameArg = v.NameArg + conv10, err := UpdateAccountsStorageCredentialFromSDK(v.CredentialInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsUpdateStorageCredentialRequest.CredentialInfo", err) + } + out.CredentialInfo = conv10 + out.SkipValidation = v.SkipValidation + return out, nil +} + +// AccountsUpdateStorageCredentialResponseToSDK converts the mirror to the sdk-go type. +func AccountsUpdateStorageCredentialResponseToSDK(w *AccountsUpdateStorageCredentialResponse) (*sdk.AccountsUpdateStorageCredentialResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsUpdateStorageCredentialResponse{} + conv11, err := StorageCredentialInfoToSDK(w.CredentialInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsUpdateStorageCredentialResponse.CredentialInfo", err) + } + out.CredentialInfo = conv11 + return out, nil +} + +// AccountsUpdateStorageCredentialResponseFromSDK converts the sdk-go type to the mirror. +func AccountsUpdateStorageCredentialResponseFromSDK(v *sdk.AccountsUpdateStorageCredentialResponse) (*AccountsUpdateStorageCredentialResponse, error) { + if v == nil { + return nil, nil + } + out := &AccountsUpdateStorageCredentialResponse{} + conv12, err := StorageCredentialInfoFromSDK(v.CredentialInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsUpdateStorageCredentialResponse.CredentialInfo", err) + } + out.CredentialInfo = conv12 + return out, nil +} + +// AwsCredentialsToSDK converts the mirror to the sdk-go type. +func AwsCredentialsToSDK(w *AwsCredentials) (*sdk.AwsCredentials, error) { + if w == nil { + return nil, nil + } + out := &sdk.AwsCredentials{} + { + var members []string + if w.StsRole != nil { + members = append(members, "sts_role") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.StsRole != nil: + conv13, err := AwsCredentials_StsRoleToSDK(w.StsRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AwsCredentials.Creds", err) + } + out.Creds = &sdk.AwsCredentials_Creds_StsRole{StsRole: *conv13} + } + return out, nil +} + +// AwsCredentialsFromSDK converts the sdk-go type to the mirror. +func AwsCredentialsFromSDK(v *sdk.AwsCredentials) (*AwsCredentials, error) { + if v == nil { + return nil, nil + } + out := &AwsCredentials{} + switch value := v.Creds.(type) { + case *sdk.AwsCredentials_Creds_StsRole: + if value != nil { + conv14, err := AwsCredentials_StsRoleFromSDK(&value.StsRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AwsCredentials.Creds", err) + } + out.StsRole = conv14 + } + } + return out, nil +} + +// AwsCredentials_StsRoleToSDK converts the mirror to the sdk-go type. +func AwsCredentials_StsRoleToSDK(w *AwsCredentials_StsRole) (*sdk.AwsCredentials_StsRole, error) { + if w == nil { + return nil, nil + } + out := &sdk.AwsCredentials_StsRole{} + out.RoleArn = w.RoleArn + return out, nil +} + +// AwsCredentials_StsRoleFromSDK converts the sdk-go type to the mirror. +func AwsCredentials_StsRoleFromSDK(v *sdk.AwsCredentials_StsRole) (*AwsCredentials_StsRole, error) { + if v == nil { + return nil, nil + } + out := &AwsCredentials_StsRole{} + out.RoleArn = v.RoleArn + return out, nil +} + +// AwsIamRoleToSDK converts the mirror to the sdk-go type. +func AwsIamRoleToSDK(w *AwsIamRole) (*sdk.AwsIamRole, error) { + if w == nil { + return nil, nil + } + out := &sdk.AwsIamRole{} + out.RoleArn = w.RoleArn + out.UnityCatalogIamArn = w.UnityCatalogIamArn + out.ExternalId = w.ExternalId + return out, nil +} + +// AwsIamRoleFromSDK converts the sdk-go type to the mirror. +func AwsIamRoleFromSDK(v *sdk.AwsIamRole) (*AwsIamRole, error) { + if v == nil { + return nil, nil + } + out := &AwsIamRole{} + out.RoleArn = v.RoleArn + out.UnityCatalogIamArn = v.UnityCatalogIamArn + out.ExternalId = v.ExternalId + return out, nil +} + +// AzureActiveDirectoryTokenToSDK converts the mirror to the sdk-go type. +func AzureActiveDirectoryTokenToSDK(w *AzureActiveDirectoryToken) (*sdk.AzureActiveDirectoryToken, error) { + if w == nil { + return nil, nil + } + out := &sdk.AzureActiveDirectoryToken{} + out.AadToken = w.AadToken + return out, nil +} + +// AzureActiveDirectoryTokenFromSDK converts the sdk-go type to the mirror. +func AzureActiveDirectoryTokenFromSDK(v *sdk.AzureActiveDirectoryToken) (*AzureActiveDirectoryToken, error) { + if v == nil { + return nil, nil + } + out := &AzureActiveDirectoryToken{} + out.AadToken = v.AadToken + return out, nil +} + +// AzureManagedIdentityToSDK converts the mirror to the sdk-go type. +func AzureManagedIdentityToSDK(w *AzureManagedIdentity) (*sdk.AzureManagedIdentity, error) { + if w == nil { + return nil, nil + } + out := &sdk.AzureManagedIdentity{} + out.AccessConnectorId = w.AccessConnectorId + out.ManagedIdentityId = w.ManagedIdentityId + out.CredentialId = w.CredentialId + return out, nil +} + +// AzureManagedIdentityFromSDK converts the sdk-go type to the mirror. +func AzureManagedIdentityFromSDK(v *sdk.AzureManagedIdentity) (*AzureManagedIdentity, error) { + if v == nil { + return nil, nil + } + out := &AzureManagedIdentity{} + out.AccessConnectorId = v.AccessConnectorId + out.ManagedIdentityId = v.ManagedIdentityId + out.CredentialId = v.CredentialId + return out, nil +} + +// AzureServicePrincipalToSDK converts the mirror to the sdk-go type. +func AzureServicePrincipalToSDK(w *AzureServicePrincipal) (*sdk.AzureServicePrincipal, error) { + if w == nil { + return nil, nil + } + out := &sdk.AzureServicePrincipal{} + out.DirectoryId = w.DirectoryId + out.ApplicationId = w.ApplicationId + out.ClientSecret = w.ClientSecret + return out, nil +} + +// AzureServicePrincipalFromSDK converts the sdk-go type to the mirror. +func AzureServicePrincipalFromSDK(v *sdk.AzureServicePrincipal) (*AzureServicePrincipal, error) { + if v == nil { + return nil, nil + } + out := &AzureServicePrincipal{} + out.DirectoryId = v.DirectoryId + out.ApplicationId = v.ApplicationId + out.ClientSecret = v.ClientSecret + return out, nil +} + +// AzureUserDelegationSasToSDK converts the mirror to the sdk-go type. +func AzureUserDelegationSasToSDK(w *AzureUserDelegationSas) (*sdk.AzureUserDelegationSas, error) { + if w == nil { + return nil, nil + } + out := &sdk.AzureUserDelegationSas{} + out.SasToken = w.SasToken + return out, nil +} + +// AzureUserDelegationSasFromSDK converts the sdk-go type to the mirror. +func AzureUserDelegationSasFromSDK(v *sdk.AzureUserDelegationSas) (*AzureUserDelegationSas, error) { + if v == nil { + return nil, nil + } + out := &AzureUserDelegationSas{} + out.SasToken = v.SasToken + return out, nil +} + +// CloudflareApiTokenToSDK converts the mirror to the sdk-go type. +func CloudflareApiTokenToSDK(w *CloudflareApiToken) (*sdk.CloudflareApiToken, error) { + if w == nil { + return nil, nil + } + out := &sdk.CloudflareApiToken{} + out.AccessKeyId = w.AccessKeyId + out.SecretAccessKey = w.SecretAccessKey + out.AccountId = w.AccountId + return out, nil +} + +// CloudflareApiTokenFromSDK converts the sdk-go type to the mirror. +func CloudflareApiTokenFromSDK(v *sdk.CloudflareApiToken) (*CloudflareApiToken, error) { + if v == nil { + return nil, nil + } + out := &CloudflareApiToken{} + out.AccessKeyId = v.AccessKeyId + out.SecretAccessKey = v.SecretAccessKey + out.AccountId = v.AccountId + return out, nil +} + +// CreateAccountsStorageCredentialToSDK converts the mirror to the sdk-go type. +func CreateAccountsStorageCredentialToSDK(w *CreateAccountsStorageCredential) (*sdk.CreateAccountsStorageCredential, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAccountsStorageCredential{} + out.Name = w.Name + { + var members []string + if w.AwsIamRole != nil { + members = append(members, "aws_iam_role") + } + if w.AzureServicePrincipal != nil { + members = append(members, "azure_service_principal") + } + if w.GcpServiceAccountKey != nil { + members = append(members, "gcp_service_account_key") + } + if w.AzureManagedIdentity != nil { + members = append(members, "azure_managed_identity") + } + if w.DatabricksGcpServiceAccount != nil { + members = append(members, "databricks_gcp_service_account") + } + if w.CloudflareApiToken != nil { + members = append(members, "cloudflare_api_token") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsIamRole != nil: + conv15, err := AwsIamRoleToSDK(w.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountsStorageCredential.Credential", err) + } + out.Credential = &sdk.CreateAccountsStorageCredential_Credential_AwsIamRole{AwsIamRole: *conv15} + case w.AzureServicePrincipal != nil: + conv16, err := AzureServicePrincipalToSDK(w.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountsStorageCredential.Credential", err) + } + out.Credential = &sdk.CreateAccountsStorageCredential_Credential_AzureServicePrincipal{AzureServicePrincipal: *conv16} + case w.GcpServiceAccountKey != nil: + conv17, err := GcpServiceAccountKeyToSDK(w.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountsStorageCredential.Credential", err) + } + out.Credential = &sdk.CreateAccountsStorageCredential_Credential_GcpServiceAccountKey{GcpServiceAccountKey: *conv17} + case w.AzureManagedIdentity != nil: + conv18, err := AzureManagedIdentityToSDK(w.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountsStorageCredential.Credential", err) + } + out.Credential = &sdk.CreateAccountsStorageCredential_Credential_AzureManagedIdentity{AzureManagedIdentity: *conv18} + case w.DatabricksGcpServiceAccount != nil: + conv19, err := DatabricksGcpServiceAccountToSDK(w.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountsStorageCredential.Credential", err) + } + out.Credential = &sdk.CreateAccountsStorageCredential_Credential_DatabricksGcpServiceAccount{DatabricksGcpServiceAccount: *conv19} + case w.CloudflareApiToken != nil: + conv20, err := CloudflareApiTokenToSDK(w.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountsStorageCredential.Credential", err) + } + out.Credential = &sdk.CreateAccountsStorageCredential_Credential_CloudflareApiToken{CloudflareApiToken: *conv20} + } + out.Comment = w.Comment + out.ReadOnly = w.ReadOnly + out.Owner = w.Owner + out.Id = w.Id + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.UsedForManagedStorage = w.UsedForManagedStorage + out.FullName = w.FullName + out.IsolationMode = w.IsolationMode + return out, nil +} + +// CreateAccountsStorageCredentialFromSDK converts the sdk-go type to the mirror. +func CreateAccountsStorageCredentialFromSDK(v *sdk.CreateAccountsStorageCredential) (*CreateAccountsStorageCredential, error) { + if v == nil { + return nil, nil + } + out := &CreateAccountsStorageCredential{} + out.Name = v.Name + switch value := v.Credential.(type) { + case *sdk.CreateAccountsStorageCredential_Credential_AwsIamRole: + if value != nil { + conv21, err := AwsIamRoleFromSDK(&value.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountsStorageCredential.Credential", err) + } + out.AwsIamRole = conv21 + } + case *sdk.CreateAccountsStorageCredential_Credential_AzureServicePrincipal: + if value != nil { + conv22, err := AzureServicePrincipalFromSDK(&value.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountsStorageCredential.Credential", err) + } + out.AzureServicePrincipal = conv22 + } + case *sdk.CreateAccountsStorageCredential_Credential_GcpServiceAccountKey: + if value != nil { + conv23, err := GcpServiceAccountKeyFromSDK(&value.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountsStorageCredential.Credential", err) + } + out.GcpServiceAccountKey = conv23 + } + case *sdk.CreateAccountsStorageCredential_Credential_AzureManagedIdentity: + if value != nil { + conv24, err := AzureManagedIdentityFromSDK(&value.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountsStorageCredential.Credential", err) + } + out.AzureManagedIdentity = conv24 + } + case *sdk.CreateAccountsStorageCredential_Credential_DatabricksGcpServiceAccount: + if value != nil { + conv25, err := DatabricksGcpServiceAccountFromSDK(&value.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountsStorageCredential.Credential", err) + } + out.DatabricksGcpServiceAccount = conv25 + } + case *sdk.CreateAccountsStorageCredential_Credential_CloudflareApiToken: + if value != nil { + conv26, err := CloudflareApiTokenFromSDK(&value.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccountsStorageCredential.Credential", err) + } + out.CloudflareApiToken = conv26 + } + } + out.Comment = v.Comment + out.ReadOnly = v.ReadOnly + out.Owner = v.Owner + out.Id = v.Id + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.UsedForManagedStorage = v.UsedForManagedStorage + out.FullName = v.FullName + out.IsolationMode = v.IsolationMode + return out, nil +} + +// CreateCredentialAwsCredentialsToSDK converts the mirror to the sdk-go type. +func CreateCredentialAwsCredentialsToSDK(w *CreateCredentialAwsCredentials) (*sdk.CreateCredentialAwsCredentials, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCredentialAwsCredentials{} + { + var members []string + if w.StsRole != nil { + members = append(members, "sts_role") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.StsRole != nil: + conv27, err := AwsCredentials_StsRoleToSDK(w.StsRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialAwsCredentials.Creds", err) + } + out.Creds = &sdk.CreateCredentialAwsCredentials_Creds_StsRole{StsRole: *conv27} + } + return out, nil +} + +// CreateCredentialAwsCredentialsFromSDK converts the sdk-go type to the mirror. +func CreateCredentialAwsCredentialsFromSDK(v *sdk.CreateCredentialAwsCredentials) (*CreateCredentialAwsCredentials, error) { + if v == nil { + return nil, nil + } + out := &CreateCredentialAwsCredentials{} + switch value := v.Creds.(type) { + case *sdk.CreateCredentialAwsCredentials_Creds_StsRole: + if value != nil { + conv28, err := AwsCredentials_StsRoleFromSDK(&value.StsRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialAwsCredentials.Creds", err) + } + out.StsRole = conv28 + } + } + return out, nil +} + +// CreateCredentialRequestToSDK converts the mirror to the sdk-go type. +func CreateCredentialRequestToSDK(w *CreateCredentialRequest) (*sdk.CreateCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCredentialRequest{} + out.SkipValidation = w.SkipValidation + out.Name = w.Name + { + var members []string + if w.AwsIamRole != nil { + members = append(members, "aws_iam_role") + } + if w.AzureServicePrincipal != nil { + members = append(members, "azure_service_principal") + } + if w.GcpServiceAccountKey != nil { + members = append(members, "gcp_service_account_key") + } + if w.AzureManagedIdentity != nil { + members = append(members, "azure_managed_identity") + } + if w.DatabricksGcpServiceAccount != nil { + members = append(members, "databricks_gcp_service_account") + } + if w.CloudflareApiToken != nil { + members = append(members, "cloudflare_api_token") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsIamRole != nil: + conv29, err := AwsIamRoleToSDK(w.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialRequest.Credential", err) + } + out.Credential = &sdk.CreateCredentialRequest_Credential_AwsIamRole{AwsIamRole: *conv29} + case w.AzureServicePrincipal != nil: + conv30, err := AzureServicePrincipalToSDK(w.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialRequest.Credential", err) + } + out.Credential = &sdk.CreateCredentialRequest_Credential_AzureServicePrincipal{AzureServicePrincipal: *conv30} + case w.GcpServiceAccountKey != nil: + conv31, err := GcpServiceAccountKeyToSDK(w.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialRequest.Credential", err) + } + out.Credential = &sdk.CreateCredentialRequest_Credential_GcpServiceAccountKey{GcpServiceAccountKey: *conv31} + case w.AzureManagedIdentity != nil: + conv32, err := AzureManagedIdentityToSDK(w.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialRequest.Credential", err) + } + out.Credential = &sdk.CreateCredentialRequest_Credential_AzureManagedIdentity{AzureManagedIdentity: *conv32} + case w.DatabricksGcpServiceAccount != nil: + conv33, err := DatabricksGcpServiceAccountToSDK(w.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialRequest.Credential", err) + } + out.Credential = &sdk.CreateCredentialRequest_Credential_DatabricksGcpServiceAccount{DatabricksGcpServiceAccount: *conv33} + case w.CloudflareApiToken != nil: + conv34, err := CloudflareApiTokenToSDK(w.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialRequest.Credential", err) + } + out.Credential = &sdk.CreateCredentialRequest_Credential_CloudflareApiToken{CloudflareApiToken: *conv34} + } + out.Comment = w.Comment + out.ReadOnly = w.ReadOnly + out.Owner = w.Owner + out.Id = w.Id + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.UsedForManagedStorage = w.UsedForManagedStorage + out.FullName = w.FullName + out.IsolationMode = w.IsolationMode + return out, nil +} + +// CreateCredentialRequestFromSDK converts the sdk-go type to the mirror. +func CreateCredentialRequestFromSDK(v *sdk.CreateCredentialRequest) (*CreateCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCredentialRequest{} + out.SkipValidation = v.SkipValidation + out.Name = v.Name + switch value := v.Credential.(type) { + case *sdk.CreateCredentialRequest_Credential_AwsIamRole: + if value != nil { + conv35, err := AwsIamRoleFromSDK(&value.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialRequest.Credential", err) + } + out.AwsIamRole = conv35 + } + case *sdk.CreateCredentialRequest_Credential_AzureServicePrincipal: + if value != nil { + conv36, err := AzureServicePrincipalFromSDK(&value.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialRequest.Credential", err) + } + out.AzureServicePrincipal = conv36 + } + case *sdk.CreateCredentialRequest_Credential_GcpServiceAccountKey: + if value != nil { + conv37, err := GcpServiceAccountKeyFromSDK(&value.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialRequest.Credential", err) + } + out.GcpServiceAccountKey = conv37 + } + case *sdk.CreateCredentialRequest_Credential_AzureManagedIdentity: + if value != nil { + conv38, err := AzureManagedIdentityFromSDK(&value.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialRequest.Credential", err) + } + out.AzureManagedIdentity = conv38 + } + case *sdk.CreateCredentialRequest_Credential_DatabricksGcpServiceAccount: + if value != nil { + conv39, err := DatabricksGcpServiceAccountFromSDK(&value.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialRequest.Credential", err) + } + out.DatabricksGcpServiceAccount = conv39 + } + case *sdk.CreateCredentialRequest_Credential_CloudflareApiToken: + if value != nil { + conv40, err := CloudflareApiTokenFromSDK(&value.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialRequest.Credential", err) + } + out.CloudflareApiToken = conv40 + } + } + out.Comment = v.Comment + out.ReadOnly = v.ReadOnly + out.Owner = v.Owner + out.Id = v.Id + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.UsedForManagedStorage = v.UsedForManagedStorage + out.FullName = v.FullName + out.IsolationMode = v.IsolationMode + return out, nil +} + +// CreateCredentialsRequestToSDK converts the mirror to the sdk-go type. +func CreateCredentialsRequestToSDK(w *CreateCredentialsRequest) (*sdk.CreateCredentialsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateCredentialsRequest{} + out.AccountId = w.AccountId + out.CredentialsName = w.CredentialsName + { + var members []string + if w.AwsCredentials != nil { + members = append(members, "aws_credentials") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsCredentials != nil: + conv41, err := CreateCredentialAwsCredentialsToSDK(w.AwsCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialsRequest.CloudCredentials", err) + } + out.CloudCredentials = &sdk.CreateCredentialsRequest_CloudCredentials_AwsCredentials{AwsCredentials: *conv41} + } + return out, nil +} + +// CreateCredentialsRequestFromSDK converts the sdk-go type to the mirror. +func CreateCredentialsRequestFromSDK(v *sdk.CreateCredentialsRequest) (*CreateCredentialsRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateCredentialsRequest{} + out.AccountId = v.AccountId + out.CredentialsName = v.CredentialsName + switch value := v.CloudCredentials.(type) { + case *sdk.CreateCredentialsRequest_CloudCredentials_AwsCredentials: + if value != nil { + conv42, err := CreateCredentialAwsCredentialsFromSDK(&value.AwsCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateCredentialsRequest.CloudCredentials", err) + } + out.AwsCredentials = conv42 + } + } + return out, nil +} + +// CreateStorageCredentialRequestToSDK converts the mirror to the sdk-go type. +func CreateStorageCredentialRequestToSDK(w *CreateStorageCredentialRequest) (*sdk.CreateStorageCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateStorageCredentialRequest{} + out.SkipValidation = w.SkipValidation + out.Name = w.Name + { + var members []string + if w.AwsIamRole != nil { + members = append(members, "aws_iam_role") + } + if w.AzureServicePrincipal != nil { + members = append(members, "azure_service_principal") + } + if w.GcpServiceAccountKey != nil { + members = append(members, "gcp_service_account_key") + } + if w.AzureManagedIdentity != nil { + members = append(members, "azure_managed_identity") + } + if w.DatabricksGcpServiceAccount != nil { + members = append(members, "databricks_gcp_service_account") + } + if w.CloudflareApiToken != nil { + members = append(members, "cloudflare_api_token") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsIamRole != nil: + conv43, err := AwsIamRoleToSDK(w.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.CreateStorageCredentialRequest_Credential_AwsIamRole{AwsIamRole: *conv43} + case w.AzureServicePrincipal != nil: + conv44, err := AzureServicePrincipalToSDK(w.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.CreateStorageCredentialRequest_Credential_AzureServicePrincipal{AzureServicePrincipal: *conv44} + case w.GcpServiceAccountKey != nil: + conv45, err := GcpServiceAccountKeyToSDK(w.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.CreateStorageCredentialRequest_Credential_GcpServiceAccountKey{GcpServiceAccountKey: *conv45} + case w.AzureManagedIdentity != nil: + conv46, err := AzureManagedIdentityToSDK(w.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.CreateStorageCredentialRequest_Credential_AzureManagedIdentity{AzureManagedIdentity: *conv46} + case w.DatabricksGcpServiceAccount != nil: + conv47, err := DatabricksGcpServiceAccountToSDK(w.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.CreateStorageCredentialRequest_Credential_DatabricksGcpServiceAccount{DatabricksGcpServiceAccount: *conv47} + case w.CloudflareApiToken != nil: + conv48, err := CloudflareApiTokenToSDK(w.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.CreateStorageCredentialRequest_Credential_CloudflareApiToken{CloudflareApiToken: *conv48} + } + out.Comment = w.Comment + out.ReadOnly = w.ReadOnly + out.Owner = w.Owner + out.Id = w.Id + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.UsedForManagedStorage = w.UsedForManagedStorage + out.FullName = w.FullName + out.IsolationMode = w.IsolationMode + return out, nil +} + +// CreateStorageCredentialRequestFromSDK converts the sdk-go type to the mirror. +func CreateStorageCredentialRequestFromSDK(v *sdk.CreateStorageCredentialRequest) (*CreateStorageCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateStorageCredentialRequest{} + out.SkipValidation = v.SkipValidation + out.Name = v.Name + switch value := v.Credential.(type) { + case *sdk.CreateStorageCredentialRequest_Credential_AwsIamRole: + if value != nil { + conv49, err := AwsIamRoleFromSDK(&value.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageCredentialRequest.Credential", err) + } + out.AwsIamRole = conv49 + } + case *sdk.CreateStorageCredentialRequest_Credential_AzureServicePrincipal: + if value != nil { + conv50, err := AzureServicePrincipalFromSDK(&value.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageCredentialRequest.Credential", err) + } + out.AzureServicePrincipal = conv50 + } + case *sdk.CreateStorageCredentialRequest_Credential_GcpServiceAccountKey: + if value != nil { + conv51, err := GcpServiceAccountKeyFromSDK(&value.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageCredentialRequest.Credential", err) + } + out.GcpServiceAccountKey = conv51 + } + case *sdk.CreateStorageCredentialRequest_Credential_AzureManagedIdentity: + if value != nil { + conv52, err := AzureManagedIdentityFromSDK(&value.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageCredentialRequest.Credential", err) + } + out.AzureManagedIdentity = conv52 + } + case *sdk.CreateStorageCredentialRequest_Credential_DatabricksGcpServiceAccount: + if value != nil { + conv53, err := DatabricksGcpServiceAccountFromSDK(&value.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageCredentialRequest.Credential", err) + } + out.DatabricksGcpServiceAccount = conv53 + } + case *sdk.CreateStorageCredentialRequest_Credential_CloudflareApiToken: + if value != nil { + conv54, err := CloudflareApiTokenFromSDK(&value.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateStorageCredentialRequest.Credential", err) + } + out.CloudflareApiToken = conv54 + } + } + out.Comment = v.Comment + out.ReadOnly = v.ReadOnly + out.Owner = v.Owner + out.Id = v.Id + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.UsedForManagedStorage = v.UsedForManagedStorage + out.FullName = v.FullName + out.IsolationMode = v.IsolationMode + return out, nil +} + +// CredentialInfoToSDK converts the mirror to the sdk-go type. +func CredentialInfoToSDK(w *CredentialInfo) (*sdk.CredentialInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.CredentialInfo{} + out.Name = w.Name + { + var members []string + if w.AwsIamRole != nil { + members = append(members, "aws_iam_role") + } + if w.AzureServicePrincipal != nil { + members = append(members, "azure_service_principal") + } + if w.GcpServiceAccountKey != nil { + members = append(members, "gcp_service_account_key") + } + if w.AzureManagedIdentity != nil { + members = append(members, "azure_managed_identity") + } + if w.DatabricksGcpServiceAccount != nil { + members = append(members, "databricks_gcp_service_account") + } + if w.CloudflareApiToken != nil { + members = append(members, "cloudflare_api_token") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsIamRole != nil: + conv55, err := AwsIamRoleToSDK(w.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CredentialInfo.Credential", err) + } + out.Credential = &sdk.CredentialInfo_Credential_AwsIamRole{AwsIamRole: *conv55} + case w.AzureServicePrincipal != nil: + conv56, err := AzureServicePrincipalToSDK(w.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CredentialInfo.Credential", err) + } + out.Credential = &sdk.CredentialInfo_Credential_AzureServicePrincipal{AzureServicePrincipal: *conv56} + case w.GcpServiceAccountKey != nil: + conv57, err := GcpServiceAccountKeyToSDK(w.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CredentialInfo.Credential", err) + } + out.Credential = &sdk.CredentialInfo_Credential_GcpServiceAccountKey{GcpServiceAccountKey: *conv57} + case w.AzureManagedIdentity != nil: + conv58, err := AzureManagedIdentityToSDK(w.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CredentialInfo.Credential", err) + } + out.Credential = &sdk.CredentialInfo_Credential_AzureManagedIdentity{AzureManagedIdentity: *conv58} + case w.DatabricksGcpServiceAccount != nil: + conv59, err := DatabricksGcpServiceAccountToSDK(w.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CredentialInfo.Credential", err) + } + out.Credential = &sdk.CredentialInfo_Credential_DatabricksGcpServiceAccount{DatabricksGcpServiceAccount: *conv59} + case w.CloudflareApiToken != nil: + conv60, err := CloudflareApiTokenToSDK(w.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CredentialInfo.Credential", err) + } + out.Credential = &sdk.CredentialInfo_Credential_CloudflareApiToken{CloudflareApiToken: *conv60} + } + out.Comment = w.Comment + out.ReadOnly = w.ReadOnly + out.Owner = w.Owner + out.Id = w.Id + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.UsedForManagedStorage = w.UsedForManagedStorage + out.FullName = w.FullName + out.IsolationMode = w.IsolationMode + return out, nil +} + +// CredentialInfoFromSDK converts the sdk-go type to the mirror. +func CredentialInfoFromSDK(v *sdk.CredentialInfo) (*CredentialInfo, error) { + if v == nil { + return nil, nil + } + out := &CredentialInfo{} + out.Name = v.Name + switch value := v.Credential.(type) { + case *sdk.CredentialInfo_Credential_AwsIamRole: + if value != nil { + conv61, err := AwsIamRoleFromSDK(&value.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CredentialInfo.Credential", err) + } + out.AwsIamRole = conv61 + } + case *sdk.CredentialInfo_Credential_AzureServicePrincipal: + if value != nil { + conv62, err := AzureServicePrincipalFromSDK(&value.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CredentialInfo.Credential", err) + } + out.AzureServicePrincipal = conv62 + } + case *sdk.CredentialInfo_Credential_GcpServiceAccountKey: + if value != nil { + conv63, err := GcpServiceAccountKeyFromSDK(&value.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CredentialInfo.Credential", err) + } + out.GcpServiceAccountKey = conv63 + } + case *sdk.CredentialInfo_Credential_AzureManagedIdentity: + if value != nil { + conv64, err := AzureManagedIdentityFromSDK(&value.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CredentialInfo.Credential", err) + } + out.AzureManagedIdentity = conv64 + } + case *sdk.CredentialInfo_Credential_DatabricksGcpServiceAccount: + if value != nil { + conv65, err := DatabricksGcpServiceAccountFromSDK(&value.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CredentialInfo.Credential", err) + } + out.DatabricksGcpServiceAccount = conv65 + } + case *sdk.CredentialInfo_Credential_CloudflareApiToken: + if value != nil { + conv66, err := CloudflareApiTokenFromSDK(&value.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CredentialInfo.Credential", err) + } + out.CloudflareApiToken = conv66 + } + } + out.Comment = v.Comment + out.ReadOnly = v.ReadOnly + out.Owner = v.Owner + out.Id = v.Id + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.UsedForManagedStorage = v.UsedForManagedStorage + out.FullName = v.FullName + out.IsolationMode = v.IsolationMode + return out, nil +} + +// CredentialsToSDK converts the mirror to the sdk-go type. +func CredentialsToSDK(w *Credentials) (*sdk.Credentials, error) { + if w == nil { + return nil, nil + } + out := &sdk.Credentials{} + out.CredentialsId = w.CredentialsId + out.AccountId = w.AccountId + { + var members []string + if w.AwsCredentials != nil { + members = append(members, "aws_credentials") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsCredentials != nil: + conv67, err := AwsCredentialsToSDK(w.AwsCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Credentials.CloudCredentials", err) + } + out.CloudCredentials = &sdk.Credentials_CloudCredentials_AwsCredentials{AwsCredentials: *conv67} + } + out.CredentialsName = w.CredentialsName + out.CreationTime = w.CreationTime + return out, nil +} + +// CredentialsFromSDK converts the sdk-go type to the mirror. +func CredentialsFromSDK(v *sdk.Credentials) (*Credentials, error) { + if v == nil { + return nil, nil + } + out := &Credentials{} + out.CredentialsId = v.CredentialsId + out.AccountId = v.AccountId + switch value := v.CloudCredentials.(type) { + case *sdk.Credentials_CloudCredentials_AwsCredentials: + if value != nil { + conv68, err := AwsCredentialsFromSDK(&value.AwsCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Credentials.CloudCredentials", err) + } + out.AwsCredentials = conv68 + } + } + out.CredentialsName = v.CredentialsName + out.CreationTime = v.CreationTime + return out, nil +} + +// DatabricksGcpServiceAccountToSDK converts the mirror to the sdk-go type. +func DatabricksGcpServiceAccountToSDK(w *DatabricksGcpServiceAccount) (*sdk.DatabricksGcpServiceAccount, error) { + if w == nil { + return nil, nil + } + out := &sdk.DatabricksGcpServiceAccount{} + out.Email = w.Email + out.PrivateKeyId = w.PrivateKeyId + out.CredentialId = w.CredentialId + return out, nil +} + +// DatabricksGcpServiceAccountFromSDK converts the sdk-go type to the mirror. +func DatabricksGcpServiceAccountFromSDK(v *sdk.DatabricksGcpServiceAccount) (*DatabricksGcpServiceAccount, error) { + if v == nil { + return nil, nil + } + out := &DatabricksGcpServiceAccount{} + out.Email = v.Email + out.PrivateKeyId = v.PrivateKeyId + out.CredentialId = v.CredentialId + return out, nil +} + +// DeleteCredentialRequestToSDK converts the mirror to the sdk-go type. +func DeleteCredentialRequestToSDK(w *DeleteCredentialRequest) (*sdk.DeleteCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteCredentialRequest{} + out.NameArg = w.NameArg + out.Force = w.Force + return out, nil +} + +// DeleteCredentialRequestFromSDK converts the sdk-go type to the mirror. +func DeleteCredentialRequestFromSDK(v *sdk.DeleteCredentialRequest) (*DeleteCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteCredentialRequest{} + out.NameArg = v.NameArg + out.Force = v.Force + return out, nil +} + +// DeleteStorageCredentialRequestToSDK converts the mirror to the sdk-go type. +func DeleteStorageCredentialRequestToSDK(w *DeleteStorageCredentialRequest) (*sdk.DeleteStorageCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteStorageCredentialRequest{} + out.NameArg = w.NameArg + out.Force = w.Force + return out, nil +} + +// DeleteStorageCredentialRequestFromSDK converts the sdk-go type to the mirror. +func DeleteStorageCredentialRequestFromSDK(v *sdk.DeleteStorageCredentialRequest) (*DeleteStorageCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteStorageCredentialRequest{} + out.NameArg = v.NameArg + out.Force = v.Force + return out, nil +} + +// GcpOauthTokenToSDK converts the mirror to the sdk-go type. +func GcpOauthTokenToSDK(w *GcpOauthToken) (*sdk.GcpOauthToken, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpOauthToken{} + out.OauthToken = w.OauthToken + return out, nil +} + +// GcpOauthTokenFromSDK converts the sdk-go type to the mirror. +func GcpOauthTokenFromSDK(v *sdk.GcpOauthToken) (*GcpOauthToken, error) { + if v == nil { + return nil, nil + } + out := &GcpOauthToken{} + out.OauthToken = v.OauthToken + return out, nil +} + +// GcpServiceAccountKeyToSDK converts the mirror to the sdk-go type. +func GcpServiceAccountKeyToSDK(w *GcpServiceAccountKey) (*sdk.GcpServiceAccountKey, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpServiceAccountKey{} + out.Email = w.Email + out.PrivateKeyId = w.PrivateKeyId + out.PrivateKey = w.PrivateKey + return out, nil +} + +// GcpServiceAccountKeyFromSDK converts the sdk-go type to the mirror. +func GcpServiceAccountKeyFromSDK(v *sdk.GcpServiceAccountKey) (*GcpServiceAccountKey, error) { + if v == nil { + return nil, nil + } + out := &GcpServiceAccountKey{} + out.Email = v.Email + out.PrivateKeyId = v.PrivateKeyId + out.PrivateKey = v.PrivateKey + return out, nil +} + +// GenerateTemporaryPathCredentialRequestToSDK converts the mirror to the sdk-go type. +func GenerateTemporaryPathCredentialRequestToSDK(w *GenerateTemporaryPathCredentialRequest) (*sdk.GenerateTemporaryPathCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenerateTemporaryPathCredentialRequest{} + out.Url = w.Url + out.Operation = w.Operation + out.DryRun = w.DryRun + return out, nil +} + +// GenerateTemporaryPathCredentialRequestFromSDK converts the sdk-go type to the mirror. +func GenerateTemporaryPathCredentialRequestFromSDK(v *sdk.GenerateTemporaryPathCredentialRequest) (*GenerateTemporaryPathCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &GenerateTemporaryPathCredentialRequest{} + out.Url = v.Url + out.Operation = v.Operation + out.DryRun = v.DryRun + return out, nil +} + +// GenerateTemporaryPathCredentialResponseToSDK converts the mirror to the sdk-go type. +func GenerateTemporaryPathCredentialResponseToSDK(w *GenerateTemporaryPathCredentialResponse) (*sdk.GenerateTemporaryPathCredentialResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenerateTemporaryPathCredentialResponse{} + { + var members []string + if w.AwsTempCredentials != nil { + members = append(members, "aws_temp_credentials") + } + if w.AzureUserDelegationSas != nil { + members = append(members, "azure_user_delegation_sas") + } + if w.GcpOauthToken != nil { + members = append(members, "gcp_oauth_token") + } + if w.AzureAad != nil { + members = append(members, "azure_aad") + } + if w.R2TempCredentials != nil { + members = append(members, "r2_temp_credentials") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsTempCredentials != nil: + conv69, err := TemporaryAwsCredentialsToSDK(w.AwsTempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryPathCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryPathCredentialResponse_Credentials_AwsTempCredentials{AwsTempCredentials: *conv69} + case w.AzureUserDelegationSas != nil: + conv70, err := AzureUserDelegationSasToSDK(w.AzureUserDelegationSas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryPathCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryPathCredentialResponse_Credentials_AzureUserDelegationSas{AzureUserDelegationSas: *conv70} + case w.GcpOauthToken != nil: + conv71, err := GcpOauthTokenToSDK(w.GcpOauthToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryPathCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryPathCredentialResponse_Credentials_GcpOauthToken{GcpOauthToken: *conv71} + case w.AzureAad != nil: + conv72, err := AzureActiveDirectoryTokenToSDK(w.AzureAad) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryPathCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryPathCredentialResponse_Credentials_AzureAad{AzureAad: *conv72} + case w.R2TempCredentials != nil: + conv73, err := R2CredentialsToSDK(w.R2TempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryPathCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryPathCredentialResponse_Credentials_R2TempCredentials{R2TempCredentials: *conv73} + } + out.ExpirationTime = w.ExpirationTime + out.Url = w.Url + return out, nil +} + +// GenerateTemporaryPathCredentialResponseFromSDK converts the sdk-go type to the mirror. +func GenerateTemporaryPathCredentialResponseFromSDK(v *sdk.GenerateTemporaryPathCredentialResponse) (*GenerateTemporaryPathCredentialResponse, error) { + if v == nil { + return nil, nil + } + out := &GenerateTemporaryPathCredentialResponse{} + switch value := v.Credentials.(type) { + case *sdk.GenerateTemporaryPathCredentialResponse_Credentials_AwsTempCredentials: + if value != nil { + conv74, err := TemporaryAwsCredentialsFromSDK(&value.AwsTempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryPathCredentialResponse.Credentials", err) + } + out.AwsTempCredentials = conv74 + } + case *sdk.GenerateTemporaryPathCredentialResponse_Credentials_AzureUserDelegationSas: + if value != nil { + conv75, err := AzureUserDelegationSasFromSDK(&value.AzureUserDelegationSas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryPathCredentialResponse.Credentials", err) + } + out.AzureUserDelegationSas = conv75 + } + case *sdk.GenerateTemporaryPathCredentialResponse_Credentials_GcpOauthToken: + if value != nil { + conv76, err := GcpOauthTokenFromSDK(&value.GcpOauthToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryPathCredentialResponse.Credentials", err) + } + out.GcpOauthToken = conv76 + } + case *sdk.GenerateTemporaryPathCredentialResponse_Credentials_AzureAad: + if value != nil { + conv77, err := AzureActiveDirectoryTokenFromSDK(&value.AzureAad) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryPathCredentialResponse.Credentials", err) + } + out.AzureAad = conv77 + } + case *sdk.GenerateTemporaryPathCredentialResponse_Credentials_R2TempCredentials: + if value != nil { + conv78, err := R2CredentialsFromSDK(&value.R2TempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryPathCredentialResponse.Credentials", err) + } + out.R2TempCredentials = conv78 + } + } + out.ExpirationTime = v.ExpirationTime + out.Url = v.Url + return out, nil +} + +// GenerateTemporaryServiceCredentialRequestToSDK converts the mirror to the sdk-go type. +func GenerateTemporaryServiceCredentialRequestToSDK(w *GenerateTemporaryServiceCredentialRequest) (*sdk.GenerateTemporaryServiceCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenerateTemporaryServiceCredentialRequest{} + out.CredentialName = w.CredentialName + { + var members []string + if w.AzureOptions != nil { + members = append(members, "azure_options") + } + if w.GcpOptions != nil { + members = append(members, "gcp_options") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AzureOptions != nil: + conv79, err := GenerateTemporaryServiceCredentialRequest_AzureOptionsToSDK(w.AzureOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryServiceCredentialRequest.Options", err) + } + out.Options = &sdk.GenerateTemporaryServiceCredentialRequest_Options_AzureOptions{AzureOptions: *conv79} + case w.GcpOptions != nil: + conv80, err := GenerateTemporaryServiceCredentialRequest_GcpOptionsToSDK(w.GcpOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryServiceCredentialRequest.Options", err) + } + out.Options = &sdk.GenerateTemporaryServiceCredentialRequest_Options_GcpOptions{GcpOptions: *conv80} + } + return out, nil +} + +// GenerateTemporaryServiceCredentialRequestFromSDK converts the sdk-go type to the mirror. +func GenerateTemporaryServiceCredentialRequestFromSDK(v *sdk.GenerateTemporaryServiceCredentialRequest) (*GenerateTemporaryServiceCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &GenerateTemporaryServiceCredentialRequest{} + out.CredentialName = v.CredentialName + switch value := v.Options.(type) { + case *sdk.GenerateTemporaryServiceCredentialRequest_Options_AzureOptions: + if value != nil { + conv81, err := GenerateTemporaryServiceCredentialRequest_AzureOptionsFromSDK(&value.AzureOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryServiceCredentialRequest.Options", err) + } + out.AzureOptions = conv81 + } + case *sdk.GenerateTemporaryServiceCredentialRequest_Options_GcpOptions: + if value != nil { + conv82, err := GenerateTemporaryServiceCredentialRequest_GcpOptionsFromSDK(&value.GcpOptions) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryServiceCredentialRequest.Options", err) + } + out.GcpOptions = conv82 + } + } + return out, nil +} + +// GenerateTemporaryServiceCredentialRequest_AzureOptionsToSDK converts the mirror to the sdk-go type. +func GenerateTemporaryServiceCredentialRequest_AzureOptionsToSDK(w *GenerateTemporaryServiceCredentialRequest_AzureOptions) (*sdk.GenerateTemporaryServiceCredentialRequest_AzureOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenerateTemporaryServiceCredentialRequest_AzureOptions{} + out.Resources = w.Resources + return out, nil +} + +// GenerateTemporaryServiceCredentialRequest_AzureOptionsFromSDK converts the sdk-go type to the mirror. +func GenerateTemporaryServiceCredentialRequest_AzureOptionsFromSDK(v *sdk.GenerateTemporaryServiceCredentialRequest_AzureOptions) (*GenerateTemporaryServiceCredentialRequest_AzureOptions, error) { + if v == nil { + return nil, nil + } + out := &GenerateTemporaryServiceCredentialRequest_AzureOptions{} + out.Resources = v.Resources + return out, nil +} + +// GenerateTemporaryServiceCredentialRequest_GcpOptionsToSDK converts the mirror to the sdk-go type. +func GenerateTemporaryServiceCredentialRequest_GcpOptionsToSDK(w *GenerateTemporaryServiceCredentialRequest_GcpOptions) (*sdk.GenerateTemporaryServiceCredentialRequest_GcpOptions, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenerateTemporaryServiceCredentialRequest_GcpOptions{} + out.Scopes = w.Scopes + return out, nil +} + +// GenerateTemporaryServiceCredentialRequest_GcpOptionsFromSDK converts the sdk-go type to the mirror. +func GenerateTemporaryServiceCredentialRequest_GcpOptionsFromSDK(v *sdk.GenerateTemporaryServiceCredentialRequest_GcpOptions) (*GenerateTemporaryServiceCredentialRequest_GcpOptions, error) { + if v == nil { + return nil, nil + } + out := &GenerateTemporaryServiceCredentialRequest_GcpOptions{} + out.Scopes = v.Scopes + return out, nil +} + +// GenerateTemporaryTableCredentialRequestToSDK converts the mirror to the sdk-go type. +func GenerateTemporaryTableCredentialRequestToSDK(w *GenerateTemporaryTableCredentialRequest) (*sdk.GenerateTemporaryTableCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenerateTemporaryTableCredentialRequest{} + out.TableId = w.TableId + out.Operation = w.Operation + return out, nil +} + +// GenerateTemporaryTableCredentialRequestFromSDK converts the sdk-go type to the mirror. +func GenerateTemporaryTableCredentialRequestFromSDK(v *sdk.GenerateTemporaryTableCredentialRequest) (*GenerateTemporaryTableCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &GenerateTemporaryTableCredentialRequest{} + out.TableId = v.TableId + out.Operation = v.Operation + return out, nil +} + +// GenerateTemporaryTableCredentialResponseToSDK converts the mirror to the sdk-go type. +func GenerateTemporaryTableCredentialResponseToSDK(w *GenerateTemporaryTableCredentialResponse) (*sdk.GenerateTemporaryTableCredentialResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenerateTemporaryTableCredentialResponse{} + { + var members []string + if w.AwsTempCredentials != nil { + members = append(members, "aws_temp_credentials") + } + if w.AzureUserDelegationSas != nil { + members = append(members, "azure_user_delegation_sas") + } + if w.GcpOauthToken != nil { + members = append(members, "gcp_oauth_token") + } + if w.AzureAad != nil { + members = append(members, "azure_aad") + } + if w.R2TempCredentials != nil { + members = append(members, "r2_temp_credentials") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsTempCredentials != nil: + conv83, err := TemporaryAwsCredentialsToSDK(w.AwsTempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryTableCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryTableCredentialResponse_Credentials_AwsTempCredentials{AwsTempCredentials: *conv83} + case w.AzureUserDelegationSas != nil: + conv84, err := AzureUserDelegationSasToSDK(w.AzureUserDelegationSas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryTableCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryTableCredentialResponse_Credentials_AzureUserDelegationSas{AzureUserDelegationSas: *conv84} + case w.GcpOauthToken != nil: + conv85, err := GcpOauthTokenToSDK(w.GcpOauthToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryTableCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryTableCredentialResponse_Credentials_GcpOauthToken{GcpOauthToken: *conv85} + case w.AzureAad != nil: + conv86, err := AzureActiveDirectoryTokenToSDK(w.AzureAad) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryTableCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryTableCredentialResponse_Credentials_AzureAad{AzureAad: *conv86} + case w.R2TempCredentials != nil: + conv87, err := R2CredentialsToSDK(w.R2TempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryTableCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryTableCredentialResponse_Credentials_R2TempCredentials{R2TempCredentials: *conv87} + } + out.ExpirationTime = w.ExpirationTime + out.Url = w.Url + return out, nil +} + +// GenerateTemporaryTableCredentialResponseFromSDK converts the sdk-go type to the mirror. +func GenerateTemporaryTableCredentialResponseFromSDK(v *sdk.GenerateTemporaryTableCredentialResponse) (*GenerateTemporaryTableCredentialResponse, error) { + if v == nil { + return nil, nil + } + out := &GenerateTemporaryTableCredentialResponse{} + switch value := v.Credentials.(type) { + case *sdk.GenerateTemporaryTableCredentialResponse_Credentials_AwsTempCredentials: + if value != nil { + conv88, err := TemporaryAwsCredentialsFromSDK(&value.AwsTempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryTableCredentialResponse.Credentials", err) + } + out.AwsTempCredentials = conv88 + } + case *sdk.GenerateTemporaryTableCredentialResponse_Credentials_AzureUserDelegationSas: + if value != nil { + conv89, err := AzureUserDelegationSasFromSDK(&value.AzureUserDelegationSas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryTableCredentialResponse.Credentials", err) + } + out.AzureUserDelegationSas = conv89 + } + case *sdk.GenerateTemporaryTableCredentialResponse_Credentials_GcpOauthToken: + if value != nil { + conv90, err := GcpOauthTokenFromSDK(&value.GcpOauthToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryTableCredentialResponse.Credentials", err) + } + out.GcpOauthToken = conv90 + } + case *sdk.GenerateTemporaryTableCredentialResponse_Credentials_AzureAad: + if value != nil { + conv91, err := AzureActiveDirectoryTokenFromSDK(&value.AzureAad) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryTableCredentialResponse.Credentials", err) + } + out.AzureAad = conv91 + } + case *sdk.GenerateTemporaryTableCredentialResponse_Credentials_R2TempCredentials: + if value != nil { + conv92, err := R2CredentialsFromSDK(&value.R2TempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryTableCredentialResponse.Credentials", err) + } + out.R2TempCredentials = conv92 + } + } + out.ExpirationTime = v.ExpirationTime + out.Url = v.Url + return out, nil +} + +// GenerateTemporaryVolumeCredentialRequestToSDK converts the mirror to the sdk-go type. +func GenerateTemporaryVolumeCredentialRequestToSDK(w *GenerateTemporaryVolumeCredentialRequest) (*sdk.GenerateTemporaryVolumeCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenerateTemporaryVolumeCredentialRequest{} + out.VolumeId = w.VolumeId + out.Operation = w.Operation + return out, nil +} + +// GenerateTemporaryVolumeCredentialRequestFromSDK converts the sdk-go type to the mirror. +func GenerateTemporaryVolumeCredentialRequestFromSDK(v *sdk.GenerateTemporaryVolumeCredentialRequest) (*GenerateTemporaryVolumeCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &GenerateTemporaryVolumeCredentialRequest{} + out.VolumeId = v.VolumeId + out.Operation = v.Operation + return out, nil +} + +// GenerateTemporaryVolumeCredentialResponseToSDK converts the mirror to the sdk-go type. +func GenerateTemporaryVolumeCredentialResponseToSDK(w *GenerateTemporaryVolumeCredentialResponse) (*sdk.GenerateTemporaryVolumeCredentialResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GenerateTemporaryVolumeCredentialResponse{} + { + var members []string + if w.AwsTempCredentials != nil { + members = append(members, "aws_temp_credentials") + } + if w.AzureUserDelegationSas != nil { + members = append(members, "azure_user_delegation_sas") + } + if w.GcpOauthToken != nil { + members = append(members, "gcp_oauth_token") + } + if w.AzureAad != nil { + members = append(members, "azure_aad") + } + if w.R2TempCredentials != nil { + members = append(members, "r2_temp_credentials") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsTempCredentials != nil: + conv93, err := TemporaryAwsCredentialsToSDK(w.AwsTempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryVolumeCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryVolumeCredentialResponse_Credentials_AwsTempCredentials{AwsTempCredentials: *conv93} + case w.AzureUserDelegationSas != nil: + conv94, err := AzureUserDelegationSasToSDK(w.AzureUserDelegationSas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryVolumeCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryVolumeCredentialResponse_Credentials_AzureUserDelegationSas{AzureUserDelegationSas: *conv94} + case w.GcpOauthToken != nil: + conv95, err := GcpOauthTokenToSDK(w.GcpOauthToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryVolumeCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryVolumeCredentialResponse_Credentials_GcpOauthToken{GcpOauthToken: *conv95} + case w.AzureAad != nil: + conv96, err := AzureActiveDirectoryTokenToSDK(w.AzureAad) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryVolumeCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryVolumeCredentialResponse_Credentials_AzureAad{AzureAad: *conv96} + case w.R2TempCredentials != nil: + conv97, err := R2CredentialsToSDK(w.R2TempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryVolumeCredentialResponse.Credentials", err) + } + out.Credentials = &sdk.GenerateTemporaryVolumeCredentialResponse_Credentials_R2TempCredentials{R2TempCredentials: *conv97} + } + out.ExpirationTime = w.ExpirationTime + out.Url = w.Url + return out, nil +} + +// GenerateTemporaryVolumeCredentialResponseFromSDK converts the sdk-go type to the mirror. +func GenerateTemporaryVolumeCredentialResponseFromSDK(v *sdk.GenerateTemporaryVolumeCredentialResponse) (*GenerateTemporaryVolumeCredentialResponse, error) { + if v == nil { + return nil, nil + } + out := &GenerateTemporaryVolumeCredentialResponse{} + switch value := v.Credentials.(type) { + case *sdk.GenerateTemporaryVolumeCredentialResponse_Credentials_AwsTempCredentials: + if value != nil { + conv98, err := TemporaryAwsCredentialsFromSDK(&value.AwsTempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryVolumeCredentialResponse.Credentials", err) + } + out.AwsTempCredentials = conv98 + } + case *sdk.GenerateTemporaryVolumeCredentialResponse_Credentials_AzureUserDelegationSas: + if value != nil { + conv99, err := AzureUserDelegationSasFromSDK(&value.AzureUserDelegationSas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryVolumeCredentialResponse.Credentials", err) + } + out.AzureUserDelegationSas = conv99 + } + case *sdk.GenerateTemporaryVolumeCredentialResponse_Credentials_GcpOauthToken: + if value != nil { + conv100, err := GcpOauthTokenFromSDK(&value.GcpOauthToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryVolumeCredentialResponse.Credentials", err) + } + out.GcpOauthToken = conv100 + } + case *sdk.GenerateTemporaryVolumeCredentialResponse_Credentials_AzureAad: + if value != nil { + conv101, err := AzureActiveDirectoryTokenFromSDK(&value.AzureAad) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryVolumeCredentialResponse.Credentials", err) + } + out.AzureAad = conv101 + } + case *sdk.GenerateTemporaryVolumeCredentialResponse_Credentials_R2TempCredentials: + if value != nil { + conv102, err := R2CredentialsFromSDK(&value.R2TempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GenerateTemporaryVolumeCredentialResponse.Credentials", err) + } + out.R2TempCredentials = conv102 + } + } + out.ExpirationTime = v.ExpirationTime + out.Url = v.Url + return out, nil +} + +// ListCredentialsRequestToSDK converts the mirror to the sdk-go type. +func ListCredentialsRequestToSDK(w *ListCredentialsRequest) (*sdk.ListCredentialsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCredentialsRequest{} + out.IncludeUnbound = w.IncludeUnbound + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListCredentialsRequestFromSDK converts the sdk-go type to the mirror. +func ListCredentialsRequestFromSDK(v *sdk.ListCredentialsRequest) (*ListCredentialsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListCredentialsRequest{} + out.IncludeUnbound = v.IncludeUnbound + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListCredentialsRequest_ResponseToSDK converts the mirror to the sdk-go type. +func ListCredentialsRequest_ResponseToSDK(w *ListCredentialsRequest_Response) (*sdk.ListCredentialsRequest_Response, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListCredentialsRequest_Response{} + conv103, err := convertSlice(w.Credentials, CredentialInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCredentialsRequest_Response.Credentials", err) + } + out.Credentials = conv103 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListCredentialsRequest_ResponseFromSDK converts the sdk-go type to the mirror. +func ListCredentialsRequest_ResponseFromSDK(v *sdk.ListCredentialsRequest_Response) (*ListCredentialsRequest_Response, error) { + if v == nil { + return nil, nil + } + out := &ListCredentialsRequest_Response{} + conv104, err := convertSlice(v.Credentials, CredentialInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListCredentialsRequest_Response.Credentials", err) + } + out.Credentials = conv104 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListStorageCredentialsRequestToSDK converts the mirror to the sdk-go type. +func ListStorageCredentialsRequestToSDK(w *ListStorageCredentialsRequest) (*sdk.ListStorageCredentialsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListStorageCredentialsRequest{} + out.IncludeUnbound = w.IncludeUnbound + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListStorageCredentialsRequestFromSDK converts the sdk-go type to the mirror. +func ListStorageCredentialsRequestFromSDK(v *sdk.ListStorageCredentialsRequest) (*ListStorageCredentialsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListStorageCredentialsRequest{} + out.IncludeUnbound = v.IncludeUnbound + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListStorageCredentialsResponseToSDK converts the mirror to the sdk-go type. +func ListStorageCredentialsResponseToSDK(w *ListStorageCredentialsResponse) (*sdk.ListStorageCredentialsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListStorageCredentialsResponse{} + conv105, err := convertSlice(w.StorageCredentials, StorageCredentialInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListStorageCredentialsResponse.StorageCredentials", err) + } + out.StorageCredentials = conv105 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListStorageCredentialsResponseFromSDK converts the sdk-go type to the mirror. +func ListStorageCredentialsResponseFromSDK(v *sdk.ListStorageCredentialsResponse) (*ListStorageCredentialsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListStorageCredentialsResponse{} + conv106, err := convertSlice(v.StorageCredentials, StorageCredentialInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListStorageCredentialsResponse.StorageCredentials", err) + } + out.StorageCredentials = conv106 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// R2CredentialsToSDK converts the mirror to the sdk-go type. +func R2CredentialsToSDK(w *R2Credentials) (*sdk.R2Credentials, error) { + if w == nil { + return nil, nil + } + out := &sdk.R2Credentials{} + out.AccessKeyId = w.AccessKeyId + out.SecretAccessKey = w.SecretAccessKey + out.SessionToken = w.SessionToken + return out, nil +} + +// R2CredentialsFromSDK converts the sdk-go type to the mirror. +func R2CredentialsFromSDK(v *sdk.R2Credentials) (*R2Credentials, error) { + if v == nil { + return nil, nil + } + out := &R2Credentials{} + out.AccessKeyId = v.AccessKeyId + out.SecretAccessKey = v.SecretAccessKey + out.SessionToken = v.SessionToken + return out, nil +} + +// StorageCredentialInfoToSDK converts the mirror to the sdk-go type. +func StorageCredentialInfoToSDK(w *StorageCredentialInfo) (*sdk.StorageCredentialInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.StorageCredentialInfo{} + out.Name = w.Name + { + var members []string + if w.AwsIamRole != nil { + members = append(members, "aws_iam_role") + } + if w.AzureServicePrincipal != nil { + members = append(members, "azure_service_principal") + } + if w.GcpServiceAccountKey != nil { + members = append(members, "gcp_service_account_key") + } + if w.AzureManagedIdentity != nil { + members = append(members, "azure_managed_identity") + } + if w.DatabricksGcpServiceAccount != nil { + members = append(members, "databricks_gcp_service_account") + } + if w.CloudflareApiToken != nil { + members = append(members, "cloudflare_api_token") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsIamRole != nil: + conv107, err := AwsIamRoleToSDK(w.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageCredentialInfo.Credential", err) + } + out.Credential = &sdk.StorageCredentialInfo_Credential_AwsIamRole{AwsIamRole: *conv107} + case w.AzureServicePrincipal != nil: + conv108, err := AzureServicePrincipalToSDK(w.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageCredentialInfo.Credential", err) + } + out.Credential = &sdk.StorageCredentialInfo_Credential_AzureServicePrincipal{AzureServicePrincipal: *conv108} + case w.GcpServiceAccountKey != nil: + conv109, err := GcpServiceAccountKeyToSDK(w.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageCredentialInfo.Credential", err) + } + out.Credential = &sdk.StorageCredentialInfo_Credential_GcpServiceAccountKey{GcpServiceAccountKey: *conv109} + case w.AzureManagedIdentity != nil: + conv110, err := AzureManagedIdentityToSDK(w.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageCredentialInfo.Credential", err) + } + out.Credential = &sdk.StorageCredentialInfo_Credential_AzureManagedIdentity{AzureManagedIdentity: *conv110} + case w.DatabricksGcpServiceAccount != nil: + conv111, err := DatabricksGcpServiceAccountToSDK(w.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageCredentialInfo.Credential", err) + } + out.Credential = &sdk.StorageCredentialInfo_Credential_DatabricksGcpServiceAccount{DatabricksGcpServiceAccount: *conv111} + case w.CloudflareApiToken != nil: + conv112, err := CloudflareApiTokenToSDK(w.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageCredentialInfo.Credential", err) + } + out.Credential = &sdk.StorageCredentialInfo_Credential_CloudflareApiToken{CloudflareApiToken: *conv112} + } + out.Comment = w.Comment + out.ReadOnly = w.ReadOnly + out.Owner = w.Owner + out.Id = w.Id + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.UsedForManagedStorage = w.UsedForManagedStorage + out.FullName = w.FullName + out.IsolationMode = w.IsolationMode + return out, nil +} + +// StorageCredentialInfoFromSDK converts the sdk-go type to the mirror. +func StorageCredentialInfoFromSDK(v *sdk.StorageCredentialInfo) (*StorageCredentialInfo, error) { + if v == nil { + return nil, nil + } + out := &StorageCredentialInfo{} + out.Name = v.Name + switch value := v.Credential.(type) { + case *sdk.StorageCredentialInfo_Credential_AwsIamRole: + if value != nil { + conv113, err := AwsIamRoleFromSDK(&value.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageCredentialInfo.Credential", err) + } + out.AwsIamRole = conv113 + } + case *sdk.StorageCredentialInfo_Credential_AzureServicePrincipal: + if value != nil { + conv114, err := AzureServicePrincipalFromSDK(&value.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageCredentialInfo.Credential", err) + } + out.AzureServicePrincipal = conv114 + } + case *sdk.StorageCredentialInfo_Credential_GcpServiceAccountKey: + if value != nil { + conv115, err := GcpServiceAccountKeyFromSDK(&value.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageCredentialInfo.Credential", err) + } + out.GcpServiceAccountKey = conv115 + } + case *sdk.StorageCredentialInfo_Credential_AzureManagedIdentity: + if value != nil { + conv116, err := AzureManagedIdentityFromSDK(&value.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageCredentialInfo.Credential", err) + } + out.AzureManagedIdentity = conv116 + } + case *sdk.StorageCredentialInfo_Credential_DatabricksGcpServiceAccount: + if value != nil { + conv117, err := DatabricksGcpServiceAccountFromSDK(&value.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageCredentialInfo.Credential", err) + } + out.DatabricksGcpServiceAccount = conv117 + } + case *sdk.StorageCredentialInfo_Credential_CloudflareApiToken: + if value != nil { + conv118, err := CloudflareApiTokenFromSDK(&value.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "StorageCredentialInfo.Credential", err) + } + out.CloudflareApiToken = conv118 + } + } + out.Comment = v.Comment + out.ReadOnly = v.ReadOnly + out.Owner = v.Owner + out.Id = v.Id + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.UsedForManagedStorage = v.UsedForManagedStorage + out.FullName = v.FullName + out.IsolationMode = v.IsolationMode + return out, nil +} + +// TemporaryAwsCredentialsToSDK converts the mirror to the sdk-go type. +func TemporaryAwsCredentialsToSDK(w *TemporaryAwsCredentials) (*sdk.TemporaryAwsCredentials, error) { + if w == nil { + return nil, nil + } + out := &sdk.TemporaryAwsCredentials{} + out.AccessKeyId = w.AccessKeyId + out.SecretAccessKey = w.SecretAccessKey + out.SessionToken = w.SessionToken + out.AccessPoint = w.AccessPoint + return out, nil +} + +// TemporaryAwsCredentialsFromSDK converts the sdk-go type to the mirror. +func TemporaryAwsCredentialsFromSDK(v *sdk.TemporaryAwsCredentials) (*TemporaryAwsCredentials, error) { + if v == nil { + return nil, nil + } + out := &TemporaryAwsCredentials{} + out.AccessKeyId = v.AccessKeyId + out.SecretAccessKey = v.SecretAccessKey + out.SessionToken = v.SessionToken + out.AccessPoint = v.AccessPoint + return out, nil +} + +// TemporaryCredentialsToSDK converts the mirror to the sdk-go type. +func TemporaryCredentialsToSDK(w *TemporaryCredentials) (*sdk.TemporaryCredentials, error) { + if w == nil { + return nil, nil + } + out := &sdk.TemporaryCredentials{} + { + var members []string + if w.AwsTempCredentials != nil { + members = append(members, "aws_temp_credentials") + } + if w.AzureUserDelegationSas != nil { + members = append(members, "azure_user_delegation_sas") + } + if w.GcpOauthToken != nil { + members = append(members, "gcp_oauth_token") + } + if w.AzureAad != nil { + members = append(members, "azure_aad") + } + if w.R2TempCredentials != nil { + members = append(members, "r2_temp_credentials") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsTempCredentials != nil: + conv119, err := TemporaryAwsCredentialsToSDK(w.AwsTempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TemporaryCredentials.Credentials", err) + } + out.Credentials = &sdk.TemporaryCredentials_Credentials_AwsTempCredentials{AwsTempCredentials: *conv119} + case w.AzureUserDelegationSas != nil: + conv120, err := AzureUserDelegationSasToSDK(w.AzureUserDelegationSas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TemporaryCredentials.Credentials", err) + } + out.Credentials = &sdk.TemporaryCredentials_Credentials_AzureUserDelegationSas{AzureUserDelegationSas: *conv120} + case w.GcpOauthToken != nil: + conv121, err := GcpOauthTokenToSDK(w.GcpOauthToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TemporaryCredentials.Credentials", err) + } + out.Credentials = &sdk.TemporaryCredentials_Credentials_GcpOauthToken{GcpOauthToken: *conv121} + case w.AzureAad != nil: + conv122, err := AzureActiveDirectoryTokenToSDK(w.AzureAad) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TemporaryCredentials.Credentials", err) + } + out.Credentials = &sdk.TemporaryCredentials_Credentials_AzureAad{AzureAad: *conv122} + case w.R2TempCredentials != nil: + conv123, err := R2CredentialsToSDK(w.R2TempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TemporaryCredentials.Credentials", err) + } + out.Credentials = &sdk.TemporaryCredentials_Credentials_R2TempCredentials{R2TempCredentials: *conv123} + } + out.ExpirationTime = w.ExpirationTime + out.Url = w.Url + return out, nil +} + +// TemporaryCredentialsFromSDK converts the sdk-go type to the mirror. +func TemporaryCredentialsFromSDK(v *sdk.TemporaryCredentials) (*TemporaryCredentials, error) { + if v == nil { + return nil, nil + } + out := &TemporaryCredentials{} + switch value := v.Credentials.(type) { + case *sdk.TemporaryCredentials_Credentials_AwsTempCredentials: + if value != nil { + conv124, err := TemporaryAwsCredentialsFromSDK(&value.AwsTempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TemporaryCredentials.Credentials", err) + } + out.AwsTempCredentials = conv124 + } + case *sdk.TemporaryCredentials_Credentials_AzureUserDelegationSas: + if value != nil { + conv125, err := AzureUserDelegationSasFromSDK(&value.AzureUserDelegationSas) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TemporaryCredentials.Credentials", err) + } + out.AzureUserDelegationSas = conv125 + } + case *sdk.TemporaryCredentials_Credentials_GcpOauthToken: + if value != nil { + conv126, err := GcpOauthTokenFromSDK(&value.GcpOauthToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TemporaryCredentials.Credentials", err) + } + out.GcpOauthToken = conv126 + } + case *sdk.TemporaryCredentials_Credentials_AzureAad: + if value != nil { + conv127, err := AzureActiveDirectoryTokenFromSDK(&value.AzureAad) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TemporaryCredentials.Credentials", err) + } + out.AzureAad = conv127 + } + case *sdk.TemporaryCredentials_Credentials_R2TempCredentials: + if value != nil { + conv128, err := R2CredentialsFromSDK(&value.R2TempCredentials) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TemporaryCredentials.Credentials", err) + } + out.R2TempCredentials = conv128 + } + } + out.ExpirationTime = v.ExpirationTime + out.Url = v.Url + return out, nil +} + +// UpdateAccountsStorageCredentialToSDK converts the mirror to the sdk-go type. +func UpdateAccountsStorageCredentialToSDK(w *UpdateAccountsStorageCredential) (*sdk.UpdateAccountsStorageCredential, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAccountsStorageCredential{} + out.Name = w.Name + { + var members []string + if w.AwsIamRole != nil { + members = append(members, "aws_iam_role") + } + if w.AzureServicePrincipal != nil { + members = append(members, "azure_service_principal") + } + if w.GcpServiceAccountKey != nil { + members = append(members, "gcp_service_account_key") + } + if w.AzureManagedIdentity != nil { + members = append(members, "azure_managed_identity") + } + if w.DatabricksGcpServiceAccount != nil { + members = append(members, "databricks_gcp_service_account") + } + if w.CloudflareApiToken != nil { + members = append(members, "cloudflare_api_token") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsIamRole != nil: + conv129, err := AwsIamRoleToSDK(w.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountsStorageCredential.Credential", err) + } + out.Credential = &sdk.UpdateAccountsStorageCredential_Credential_AwsIamRole{AwsIamRole: *conv129} + case w.AzureServicePrincipal != nil: + conv130, err := AzureServicePrincipalToSDK(w.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountsStorageCredential.Credential", err) + } + out.Credential = &sdk.UpdateAccountsStorageCredential_Credential_AzureServicePrincipal{AzureServicePrincipal: *conv130} + case w.GcpServiceAccountKey != nil: + conv131, err := GcpServiceAccountKeyToSDK(w.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountsStorageCredential.Credential", err) + } + out.Credential = &sdk.UpdateAccountsStorageCredential_Credential_GcpServiceAccountKey{GcpServiceAccountKey: *conv131} + case w.AzureManagedIdentity != nil: + conv132, err := AzureManagedIdentityToSDK(w.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountsStorageCredential.Credential", err) + } + out.Credential = &sdk.UpdateAccountsStorageCredential_Credential_AzureManagedIdentity{AzureManagedIdentity: *conv132} + case w.DatabricksGcpServiceAccount != nil: + conv133, err := DatabricksGcpServiceAccountToSDK(w.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountsStorageCredential.Credential", err) + } + out.Credential = &sdk.UpdateAccountsStorageCredential_Credential_DatabricksGcpServiceAccount{DatabricksGcpServiceAccount: *conv133} + case w.CloudflareApiToken != nil: + conv134, err := CloudflareApiTokenToSDK(w.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountsStorageCredential.Credential", err) + } + out.Credential = &sdk.UpdateAccountsStorageCredential_Credential_CloudflareApiToken{CloudflareApiToken: *conv134} + } + out.Comment = w.Comment + out.ReadOnly = w.ReadOnly + out.Owner = w.Owner + out.Id = w.Id + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.UsedForManagedStorage = w.UsedForManagedStorage + out.FullName = w.FullName + out.IsolationMode = w.IsolationMode + return out, nil +} + +// UpdateAccountsStorageCredentialFromSDK converts the sdk-go type to the mirror. +func UpdateAccountsStorageCredentialFromSDK(v *sdk.UpdateAccountsStorageCredential) (*UpdateAccountsStorageCredential, error) { + if v == nil { + return nil, nil + } + out := &UpdateAccountsStorageCredential{} + out.Name = v.Name + switch value := v.Credential.(type) { + case *sdk.UpdateAccountsStorageCredential_Credential_AwsIamRole: + if value != nil { + conv135, err := AwsIamRoleFromSDK(&value.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountsStorageCredential.Credential", err) + } + out.AwsIamRole = conv135 + } + case *sdk.UpdateAccountsStorageCredential_Credential_AzureServicePrincipal: + if value != nil { + conv136, err := AzureServicePrincipalFromSDK(&value.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountsStorageCredential.Credential", err) + } + out.AzureServicePrincipal = conv136 + } + case *sdk.UpdateAccountsStorageCredential_Credential_GcpServiceAccountKey: + if value != nil { + conv137, err := GcpServiceAccountKeyFromSDK(&value.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountsStorageCredential.Credential", err) + } + out.GcpServiceAccountKey = conv137 + } + case *sdk.UpdateAccountsStorageCredential_Credential_AzureManagedIdentity: + if value != nil { + conv138, err := AzureManagedIdentityFromSDK(&value.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountsStorageCredential.Credential", err) + } + out.AzureManagedIdentity = conv138 + } + case *sdk.UpdateAccountsStorageCredential_Credential_DatabricksGcpServiceAccount: + if value != nil { + conv139, err := DatabricksGcpServiceAccountFromSDK(&value.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountsStorageCredential.Credential", err) + } + out.DatabricksGcpServiceAccount = conv139 + } + case *sdk.UpdateAccountsStorageCredential_Credential_CloudflareApiToken: + if value != nil { + conv140, err := CloudflareApiTokenFromSDK(&value.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccountsStorageCredential.Credential", err) + } + out.CloudflareApiToken = conv140 + } + } + out.Comment = v.Comment + out.ReadOnly = v.ReadOnly + out.Owner = v.Owner + out.Id = v.Id + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.UsedForManagedStorage = v.UsedForManagedStorage + out.FullName = v.FullName + out.IsolationMode = v.IsolationMode + return out, nil +} + +// UpdateCredentialRequestToSDK converts the mirror to the sdk-go type. +func UpdateCredentialRequestToSDK(w *UpdateCredentialRequest) (*sdk.UpdateCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCredentialRequest{} + out.NameArg = w.NameArg + out.NewName = w.NewName + out.SkipValidation = w.SkipValidation + out.Force = w.Force + out.Name = w.Name + { + var members []string + if w.AwsIamRole != nil { + members = append(members, "aws_iam_role") + } + if w.AzureServicePrincipal != nil { + members = append(members, "azure_service_principal") + } + if w.GcpServiceAccountKey != nil { + members = append(members, "gcp_service_account_key") + } + if w.AzureManagedIdentity != nil { + members = append(members, "azure_managed_identity") + } + if w.DatabricksGcpServiceAccount != nil { + members = append(members, "databricks_gcp_service_account") + } + if w.CloudflareApiToken != nil { + members = append(members, "cloudflare_api_token") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsIamRole != nil: + conv141, err := AwsIamRoleToSDK(w.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCredentialRequest.Credential", err) + } + out.Credential = &sdk.UpdateCredentialRequest_Credential_AwsIamRole{AwsIamRole: *conv141} + case w.AzureServicePrincipal != nil: + conv142, err := AzureServicePrincipalToSDK(w.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCredentialRequest.Credential", err) + } + out.Credential = &sdk.UpdateCredentialRequest_Credential_AzureServicePrincipal{AzureServicePrincipal: *conv142} + case w.GcpServiceAccountKey != nil: + conv143, err := GcpServiceAccountKeyToSDK(w.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCredentialRequest.Credential", err) + } + out.Credential = &sdk.UpdateCredentialRequest_Credential_GcpServiceAccountKey{GcpServiceAccountKey: *conv143} + case w.AzureManagedIdentity != nil: + conv144, err := AzureManagedIdentityToSDK(w.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCredentialRequest.Credential", err) + } + out.Credential = &sdk.UpdateCredentialRequest_Credential_AzureManagedIdentity{AzureManagedIdentity: *conv144} + case w.DatabricksGcpServiceAccount != nil: + conv145, err := DatabricksGcpServiceAccountToSDK(w.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCredentialRequest.Credential", err) + } + out.Credential = &sdk.UpdateCredentialRequest_Credential_DatabricksGcpServiceAccount{DatabricksGcpServiceAccount: *conv145} + case w.CloudflareApiToken != nil: + conv146, err := CloudflareApiTokenToSDK(w.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCredentialRequest.Credential", err) + } + out.Credential = &sdk.UpdateCredentialRequest_Credential_CloudflareApiToken{CloudflareApiToken: *conv146} + } + out.Comment = w.Comment + out.ReadOnly = w.ReadOnly + out.Owner = w.Owner + out.Id = w.Id + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.UsedForManagedStorage = w.UsedForManagedStorage + out.FullName = w.FullName + out.IsolationMode = w.IsolationMode + return out, nil +} + +// UpdateCredentialRequestFromSDK converts the sdk-go type to the mirror. +func UpdateCredentialRequestFromSDK(v *sdk.UpdateCredentialRequest) (*UpdateCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateCredentialRequest{} + out.NameArg = v.NameArg + out.NewName = v.NewName + out.SkipValidation = v.SkipValidation + out.Force = v.Force + out.Name = v.Name + switch value := v.Credential.(type) { + case *sdk.UpdateCredentialRequest_Credential_AwsIamRole: + if value != nil { + conv147, err := AwsIamRoleFromSDK(&value.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCredentialRequest.Credential", err) + } + out.AwsIamRole = conv147 + } + case *sdk.UpdateCredentialRequest_Credential_AzureServicePrincipal: + if value != nil { + conv148, err := AzureServicePrincipalFromSDK(&value.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCredentialRequest.Credential", err) + } + out.AzureServicePrincipal = conv148 + } + case *sdk.UpdateCredentialRequest_Credential_GcpServiceAccountKey: + if value != nil { + conv149, err := GcpServiceAccountKeyFromSDK(&value.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCredentialRequest.Credential", err) + } + out.GcpServiceAccountKey = conv149 + } + case *sdk.UpdateCredentialRequest_Credential_AzureManagedIdentity: + if value != nil { + conv150, err := AzureManagedIdentityFromSDK(&value.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCredentialRequest.Credential", err) + } + out.AzureManagedIdentity = conv150 + } + case *sdk.UpdateCredentialRequest_Credential_DatabricksGcpServiceAccount: + if value != nil { + conv151, err := DatabricksGcpServiceAccountFromSDK(&value.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCredentialRequest.Credential", err) + } + out.DatabricksGcpServiceAccount = conv151 + } + case *sdk.UpdateCredentialRequest_Credential_CloudflareApiToken: + if value != nil { + conv152, err := CloudflareApiTokenFromSDK(&value.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateCredentialRequest.Credential", err) + } + out.CloudflareApiToken = conv152 + } + } + out.Comment = v.Comment + out.ReadOnly = v.ReadOnly + out.Owner = v.Owner + out.Id = v.Id + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.UsedForManagedStorage = v.UsedForManagedStorage + out.FullName = v.FullName + out.IsolationMode = v.IsolationMode + return out, nil +} + +// UpdateStorageCredentialRequestToSDK converts the mirror to the sdk-go type. +func UpdateStorageCredentialRequestToSDK(w *UpdateStorageCredentialRequest) (*sdk.UpdateStorageCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateStorageCredentialRequest{} + out.NameArg = w.NameArg + out.NewName = w.NewName + out.SkipValidation = w.SkipValidation + out.Force = w.Force + out.Name = w.Name + { + var members []string + if w.AwsIamRole != nil { + members = append(members, "aws_iam_role") + } + if w.AzureServicePrincipal != nil { + members = append(members, "azure_service_principal") + } + if w.GcpServiceAccountKey != nil { + members = append(members, "gcp_service_account_key") + } + if w.AzureManagedIdentity != nil { + members = append(members, "azure_managed_identity") + } + if w.DatabricksGcpServiceAccount != nil { + members = append(members, "databricks_gcp_service_account") + } + if w.CloudflareApiToken != nil { + members = append(members, "cloudflare_api_token") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.AwsIamRole != nil: + conv153, err := AwsIamRoleToSDK(w.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.UpdateStorageCredentialRequest_Credential_AwsIamRole{AwsIamRole: *conv153} + case w.AzureServicePrincipal != nil: + conv154, err := AzureServicePrincipalToSDK(w.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.UpdateStorageCredentialRequest_Credential_AzureServicePrincipal{AzureServicePrincipal: *conv154} + case w.GcpServiceAccountKey != nil: + conv155, err := GcpServiceAccountKeyToSDK(w.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.UpdateStorageCredentialRequest_Credential_GcpServiceAccountKey{GcpServiceAccountKey: *conv155} + case w.AzureManagedIdentity != nil: + conv156, err := AzureManagedIdentityToSDK(w.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.UpdateStorageCredentialRequest_Credential_AzureManagedIdentity{AzureManagedIdentity: *conv156} + case w.DatabricksGcpServiceAccount != nil: + conv157, err := DatabricksGcpServiceAccountToSDK(w.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.UpdateStorageCredentialRequest_Credential_DatabricksGcpServiceAccount{DatabricksGcpServiceAccount: *conv157} + case w.CloudflareApiToken != nil: + conv158, err := CloudflareApiTokenToSDK(w.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.UpdateStorageCredentialRequest_Credential_CloudflareApiToken{CloudflareApiToken: *conv158} + } + out.Comment = w.Comment + out.ReadOnly = w.ReadOnly + out.Owner = w.Owner + out.Id = w.Id + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.UsedForManagedStorage = w.UsedForManagedStorage + out.FullName = w.FullName + out.IsolationMode = w.IsolationMode + return out, nil +} + +// UpdateStorageCredentialRequestFromSDK converts the sdk-go type to the mirror. +func UpdateStorageCredentialRequestFromSDK(v *sdk.UpdateStorageCredentialRequest) (*UpdateStorageCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateStorageCredentialRequest{} + out.NameArg = v.NameArg + out.NewName = v.NewName + out.SkipValidation = v.SkipValidation + out.Force = v.Force + out.Name = v.Name + switch value := v.Credential.(type) { + case *sdk.UpdateStorageCredentialRequest_Credential_AwsIamRole: + if value != nil { + conv159, err := AwsIamRoleFromSDK(&value.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStorageCredentialRequest.Credential", err) + } + out.AwsIamRole = conv159 + } + case *sdk.UpdateStorageCredentialRequest_Credential_AzureServicePrincipal: + if value != nil { + conv160, err := AzureServicePrincipalFromSDK(&value.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStorageCredentialRequest.Credential", err) + } + out.AzureServicePrincipal = conv160 + } + case *sdk.UpdateStorageCredentialRequest_Credential_GcpServiceAccountKey: + if value != nil { + conv161, err := GcpServiceAccountKeyFromSDK(&value.GcpServiceAccountKey) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStorageCredentialRequest.Credential", err) + } + out.GcpServiceAccountKey = conv161 + } + case *sdk.UpdateStorageCredentialRequest_Credential_AzureManagedIdentity: + if value != nil { + conv162, err := AzureManagedIdentityFromSDK(&value.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStorageCredentialRequest.Credential", err) + } + out.AzureManagedIdentity = conv162 + } + case *sdk.UpdateStorageCredentialRequest_Credential_DatabricksGcpServiceAccount: + if value != nil { + conv163, err := DatabricksGcpServiceAccountFromSDK(&value.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStorageCredentialRequest.Credential", err) + } + out.DatabricksGcpServiceAccount = conv163 + } + case *sdk.UpdateStorageCredentialRequest_Credential_CloudflareApiToken: + if value != nil { + conv164, err := CloudflareApiTokenFromSDK(&value.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateStorageCredentialRequest.Credential", err) + } + out.CloudflareApiToken = conv164 + } + } + out.Comment = v.Comment + out.ReadOnly = v.ReadOnly + out.Owner = v.Owner + out.Id = v.Id + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.UsedForManagedStorage = v.UsedForManagedStorage + out.FullName = v.FullName + out.IsolationMode = v.IsolationMode + return out, nil +} + +// ValidateCredentialRequestToSDK converts the mirror to the sdk-go type. +func ValidateCredentialRequestToSDK(w *ValidateCredentialRequest) (*sdk.ValidateCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ValidateCredentialRequest{} + { + var members []string + if w.CredentialName != nil { + members = append(members, "credential_name") + } + if w.AwsIamRole != nil { + members = append(members, "aws_iam_role") + } + if w.AzureManagedIdentity != nil { + members = append(members, "azure_managed_identity") + } + if w.DatabricksGcpServiceAccount != nil { + members = append(members, "databricks_gcp_service_account") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.CredentialName != nil: + out.Credential = &sdk.ValidateCredentialRequest_Credential_CredentialName{CredentialName: *w.CredentialName} + case w.AwsIamRole != nil: + conv165, err := AwsIamRoleToSDK(w.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateCredentialRequest.Credential", err) + } + out.Credential = &sdk.ValidateCredentialRequest_Credential_AwsIamRole{AwsIamRole: *conv165} + case w.AzureManagedIdentity != nil: + conv166, err := AzureManagedIdentityToSDK(w.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateCredentialRequest.Credential", err) + } + out.Credential = &sdk.ValidateCredentialRequest_Credential_AzureManagedIdentity{AzureManagedIdentity: *conv166} + case w.DatabricksGcpServiceAccount != nil: + conv167, err := DatabricksGcpServiceAccountToSDK(w.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateCredentialRequest.Credential", err) + } + out.Credential = &sdk.ValidateCredentialRequest_Credential_DatabricksGcpServiceAccount{DatabricksGcpServiceAccount: *conv167} + } + out.ExternalLocationName = w.ExternalLocationName + out.Url = w.Url + out.ReadOnly = w.ReadOnly + return out, nil +} + +// ValidateCredentialRequestFromSDK converts the sdk-go type to the mirror. +func ValidateCredentialRequestFromSDK(v *sdk.ValidateCredentialRequest) (*ValidateCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &ValidateCredentialRequest{} + switch value := v.Credential.(type) { + case *sdk.ValidateCredentialRequest_Credential_CredentialName: + if value != nil { + out.CredentialName = new(value.CredentialName) + } + case *sdk.ValidateCredentialRequest_Credential_AwsIamRole: + if value != nil { + conv168, err := AwsIamRoleFromSDK(&value.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateCredentialRequest.Credential", err) + } + out.AwsIamRole = conv168 + } + case *sdk.ValidateCredentialRequest_Credential_AzureManagedIdentity: + if value != nil { + conv169, err := AzureManagedIdentityFromSDK(&value.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateCredentialRequest.Credential", err) + } + out.AzureManagedIdentity = conv169 + } + case *sdk.ValidateCredentialRequest_Credential_DatabricksGcpServiceAccount: + if value != nil { + conv170, err := DatabricksGcpServiceAccountFromSDK(&value.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateCredentialRequest.Credential", err) + } + out.DatabricksGcpServiceAccount = conv170 + } + } + out.ExternalLocationName = v.ExternalLocationName + out.Url = v.Url + out.ReadOnly = v.ReadOnly + return out, nil +} + +// ValidateCredentialRequest_ValidationResultToSDK converts the mirror to the sdk-go type. +func ValidateCredentialRequest_ValidationResultToSDK(w *ValidateCredentialRequest_ValidationResult) (*sdk.ValidateCredentialRequest_ValidationResult, error) { + if w == nil { + return nil, nil + } + out := &sdk.ValidateCredentialRequest_ValidationResult{} + out.Result = w.Result + out.Message = w.Message + return out, nil +} + +// ValidateCredentialRequest_ValidationResultFromSDK converts the sdk-go type to the mirror. +func ValidateCredentialRequest_ValidationResultFromSDK(v *sdk.ValidateCredentialRequest_ValidationResult) (*ValidateCredentialRequest_ValidationResult, error) { + if v == nil { + return nil, nil + } + out := &ValidateCredentialRequest_ValidationResult{} + out.Result = v.Result + out.Message = v.Message + return out, nil +} + +// ValidateCredentialResponseToSDK converts the mirror to the sdk-go type. +func ValidateCredentialResponseToSDK(w *ValidateCredentialResponse) (*sdk.ValidateCredentialResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ValidateCredentialResponse{} + conv171, err := convertSlice(w.Results, ValidateCredentialRequest_ValidationResultToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateCredentialResponse.Results", err) + } + out.Results = conv171 + out.IsDir = w.IsDir + return out, nil +} + +// ValidateCredentialResponseFromSDK converts the sdk-go type to the mirror. +func ValidateCredentialResponseFromSDK(v *sdk.ValidateCredentialResponse) (*ValidateCredentialResponse, error) { + if v == nil { + return nil, nil + } + out := &ValidateCredentialResponse{} + conv172, err := convertSlice(v.Results, ValidateCredentialRequest_ValidationResultFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateCredentialResponse.Results", err) + } + out.Results = conv172 + out.IsDir = v.IsDir + return out, nil +} + +// ValidateStorageCredentialRequestToSDK converts the mirror to the sdk-go type. +func ValidateStorageCredentialRequestToSDK(w *ValidateStorageCredentialRequest) (*sdk.ValidateStorageCredentialRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ValidateStorageCredentialRequest{} + { + var members []string + if w.StorageCredentialName != nil { + members = append(members, "storage_credential_name") + } + if w.AwsIamRole != nil { + members = append(members, "aws_iam_role") + } + if w.AzureServicePrincipal != nil { + members = append(members, "azure_service_principal") + } + if w.AzureManagedIdentity != nil { + members = append(members, "azure_managed_identity") + } + if w.DatabricksGcpServiceAccount != nil { + members = append(members, "databricks_gcp_service_account") + } + if w.CloudflareApiToken != nil { + members = append(members, "cloudflare_api_token") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.StorageCredentialName != nil: + out.Credential = &sdk.ValidateStorageCredentialRequest_Credential_StorageCredentialName{StorageCredentialName: *w.StorageCredentialName} + case w.AwsIamRole != nil: + conv173, err := AwsIamRoleToSDK(w.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.ValidateStorageCredentialRequest_Credential_AwsIamRole{AwsIamRole: *conv173} + case w.AzureServicePrincipal != nil: + conv174, err := AzureServicePrincipalToSDK(w.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.ValidateStorageCredentialRequest_Credential_AzureServicePrincipal{AzureServicePrincipal: *conv174} + case w.AzureManagedIdentity != nil: + conv175, err := AzureManagedIdentityToSDK(w.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.ValidateStorageCredentialRequest_Credential_AzureManagedIdentity{AzureManagedIdentity: *conv175} + case w.DatabricksGcpServiceAccount != nil: + conv176, err := DatabricksGcpServiceAccountToSDK(w.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.ValidateStorageCredentialRequest_Credential_DatabricksGcpServiceAccount{DatabricksGcpServiceAccount: *conv176} + case w.CloudflareApiToken != nil: + conv177, err := CloudflareApiTokenToSDK(w.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateStorageCredentialRequest.Credential", err) + } + out.Credential = &sdk.ValidateStorageCredentialRequest_Credential_CloudflareApiToken{CloudflareApiToken: *conv177} + } + out.ExternalLocationName = w.ExternalLocationName + out.Url = w.Url + out.ReadOnly = w.ReadOnly + return out, nil +} + +// ValidateStorageCredentialRequestFromSDK converts the sdk-go type to the mirror. +func ValidateStorageCredentialRequestFromSDK(v *sdk.ValidateStorageCredentialRequest) (*ValidateStorageCredentialRequest, error) { + if v == nil { + return nil, nil + } + out := &ValidateStorageCredentialRequest{} + switch value := v.Credential.(type) { + case *sdk.ValidateStorageCredentialRequest_Credential_StorageCredentialName: + if value != nil { + out.StorageCredentialName = new(value.StorageCredentialName) + } + case *sdk.ValidateStorageCredentialRequest_Credential_AwsIamRole: + if value != nil { + conv178, err := AwsIamRoleFromSDK(&value.AwsIamRole) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateStorageCredentialRequest.Credential", err) + } + out.AwsIamRole = conv178 + } + case *sdk.ValidateStorageCredentialRequest_Credential_AzureServicePrincipal: + if value != nil { + conv179, err := AzureServicePrincipalFromSDK(&value.AzureServicePrincipal) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateStorageCredentialRequest.Credential", err) + } + out.AzureServicePrincipal = conv179 + } + case *sdk.ValidateStorageCredentialRequest_Credential_AzureManagedIdentity: + if value != nil { + conv180, err := AzureManagedIdentityFromSDK(&value.AzureManagedIdentity) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateStorageCredentialRequest.Credential", err) + } + out.AzureManagedIdentity = conv180 + } + case *sdk.ValidateStorageCredentialRequest_Credential_DatabricksGcpServiceAccount: + if value != nil { + conv181, err := DatabricksGcpServiceAccountFromSDK(&value.DatabricksGcpServiceAccount) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateStorageCredentialRequest.Credential", err) + } + out.DatabricksGcpServiceAccount = conv181 + } + case *sdk.ValidateStorageCredentialRequest_Credential_CloudflareApiToken: + if value != nil { + conv182, err := CloudflareApiTokenFromSDK(&value.CloudflareApiToken) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateStorageCredentialRequest.Credential", err) + } + out.CloudflareApiToken = conv182 + } + } + out.ExternalLocationName = v.ExternalLocationName + out.Url = v.Url + out.ReadOnly = v.ReadOnly + return out, nil +} + +// ValidateStorageCredentialRequest_ValidationResultToSDK converts the mirror to the sdk-go type. +func ValidateStorageCredentialRequest_ValidationResultToSDK(w *ValidateStorageCredentialRequest_ValidationResult) (*sdk.ValidateStorageCredentialRequest_ValidationResult, error) { + if w == nil { + return nil, nil + } + out := &sdk.ValidateStorageCredentialRequest_ValidationResult{} + out.Operation = w.Operation + out.Result = w.Result + out.Message = w.Message + return out, nil +} + +// ValidateStorageCredentialRequest_ValidationResultFromSDK converts the sdk-go type to the mirror. +func ValidateStorageCredentialRequest_ValidationResultFromSDK(v *sdk.ValidateStorageCredentialRequest_ValidationResult) (*ValidateStorageCredentialRequest_ValidationResult, error) { + if v == nil { + return nil, nil + } + out := &ValidateStorageCredentialRequest_ValidationResult{} + out.Operation = v.Operation + out.Result = v.Result + out.Message = v.Message + return out, nil +} + +// ValidateStorageCredentialResponseToSDK converts the mirror to the sdk-go type. +func ValidateStorageCredentialResponseToSDK(w *ValidateStorageCredentialResponse) (*sdk.ValidateStorageCredentialResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ValidateStorageCredentialResponse{} + out.IsDir = w.IsDir + conv183, err := convertSlice(w.Results, ValidateStorageCredentialRequest_ValidationResultToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateStorageCredentialResponse.Results", err) + } + out.Results = conv183 + return out, nil +} + +// ValidateStorageCredentialResponseFromSDK converts the sdk-go type to the mirror. +func ValidateStorageCredentialResponseFromSDK(v *sdk.ValidateStorageCredentialResponse) (*ValidateStorageCredentialResponse, error) { + if v == nil { + return nil, nil + } + out := &ValidateStorageCredentialResponse{} + out.IsDir = v.IsDir + conv184, err := convertSlice(v.Results, ValidateStorageCredentialRequest_ValidationResultFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ValidateStorageCredentialResponse.Results", err) + } + out.Results = conv184 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/entitytagassignments/v1/types.generated.go b/libs/sdktypes/uc/entitytagassignments/v1/types.generated.go new file mode 100644 index 00000000000..f3194c858a2 --- /dev/null +++ b/libs/sdktypes/uc/entitytagassignments/v1/types.generated.go @@ -0,0 +1,251 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/entitytagassignments/v1. DO NOT EDIT. + +package entitytagassignments + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/uc/entitytagassignments/v1" + strings "strings" +) + +type ( + TagAssignmentSourceType = sdk.TagAssignmentSourceType +) + +const ( + TagAssignmentSourceType_Unspecified = sdk.TagAssignmentSourceType_Unspecified + TagAssignmentSourceType_TagAssignmentSourceTypeSystemDataClassification = sdk.TagAssignmentSourceType_TagAssignmentSourceTypeSystemDataClassification +) + +// Request to create a new entity tag assignment. +type CreateEntityTagAssignmentRequest struct { + TagAssignment *EntityTagAssignment `json:"tag_assignment,omitempty"` +} + +// Represents a tag assignment to an entity. +type EntityTagAssignment struct { + // The fully qualified name of the entity to which the tag is assigned + EntityName *string `json:"entity_name,omitempty"` + // The type of the entity to which the tag is assigned. + EntityType *string `json:"entity_type,omitempty"` + // The source type of the tag assignment, e.g., user-assigned or system-assigned + SourceType TagAssignmentSourceType `json:"source_type,omitempty"` + // The key of the tag + TagKey *string `json:"tag_key,omitempty"` + // The value of the tag + TagValue *string `json:"tag_value,omitempty"` + // The timestamp when the tag assignment was last updated + UpdateTime *types.Time `json:"update_time,omitempty"` + // The user or principal who updated the tag assignment + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// Request to list entity tag assignments. +type ListEntityTagAssignmentsRequest struct { + // The fully qualified name of the entity to which the tag is assigned + EntityName *string `json:"entity_name,omitempty"` + // The type of the entity to which the tag is assigned. + EntityType *string `json:"entity_type,omitempty"` + // Optional. Maximum number of tag assignments to return in a single page + MaxResults *int `json:"max_results,omitempty"` + // Optional. Pagination token to retrieve the next page of results + PageToken *string `json:"page_token,omitempty"` +} + +type ListEntityTagAssignmentsResponse struct { + // Optional. Pagination token for retrieving the next page of results + NextPageToken *string `json:"next_page_token,omitempty"` + // The list of tag assignments + TagAssignments []EntityTagAssignment `json:"tag_assignments,omitempty"` +} + +// Request to update an entity tag assignment. +type UpdateEntityTagAssignmentRequest struct { + TagAssignment *EntityTagAssignment `json:"tag_assignment,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CreateEntityTagAssignmentRequestToSDK converts the mirror to the sdk-go type. +func CreateEntityTagAssignmentRequestToSDK(w *CreateEntityTagAssignmentRequest) (*sdk.CreateEntityTagAssignmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateEntityTagAssignmentRequest{} + conv1, err := EntityTagAssignmentToSDK(w.TagAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateEntityTagAssignmentRequest.TagAssignment", err) + } + out.TagAssignment = conv1 + return out, nil +} + +// CreateEntityTagAssignmentRequestFromSDK converts the sdk-go type to the mirror. +func CreateEntityTagAssignmentRequestFromSDK(v *sdk.CreateEntityTagAssignmentRequest) (*CreateEntityTagAssignmentRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateEntityTagAssignmentRequest{} + conv2, err := EntityTagAssignmentFromSDK(v.TagAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateEntityTagAssignmentRequest.TagAssignment", err) + } + out.TagAssignment = conv2 + return out, nil +} + +// EntityTagAssignmentToSDK converts the mirror to the sdk-go type. +func EntityTagAssignmentToSDK(w *EntityTagAssignment) (*sdk.EntityTagAssignment, error) { + if w == nil { + return nil, nil + } + out := &sdk.EntityTagAssignment{} + out.EntityName = w.EntityName + out.TagKey = w.TagKey + out.TagValue = w.TagValue + out.EntityType = w.EntityType + out.UpdateTime = w.UpdateTime + out.UpdatedBy = w.UpdatedBy + out.SourceType = w.SourceType + return out, nil +} + +// EntityTagAssignmentFromSDK converts the sdk-go type to the mirror. +func EntityTagAssignmentFromSDK(v *sdk.EntityTagAssignment) (*EntityTagAssignment, error) { + if v == nil { + return nil, nil + } + out := &EntityTagAssignment{} + out.EntityName = v.EntityName + out.TagKey = v.TagKey + out.TagValue = v.TagValue + out.EntityType = v.EntityType + out.UpdateTime = v.UpdateTime + out.UpdatedBy = v.UpdatedBy + out.SourceType = v.SourceType + return out, nil +} + +// ListEntityTagAssignmentsRequestToSDK converts the mirror to the sdk-go type. +func ListEntityTagAssignmentsRequestToSDK(w *ListEntityTagAssignmentsRequest) (*sdk.ListEntityTagAssignmentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEntityTagAssignmentsRequest{} + out.EntityName = w.EntityName + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + out.EntityType = w.EntityType + return out, nil +} + +// ListEntityTagAssignmentsRequestFromSDK converts the sdk-go type to the mirror. +func ListEntityTagAssignmentsRequestFromSDK(v *sdk.ListEntityTagAssignmentsRequest) (*ListEntityTagAssignmentsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListEntityTagAssignmentsRequest{} + out.EntityName = v.EntityName + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + out.EntityType = v.EntityType + return out, nil +} + +// ListEntityTagAssignmentsResponseToSDK converts the mirror to the sdk-go type. +func ListEntityTagAssignmentsResponseToSDK(w *ListEntityTagAssignmentsResponse) (*sdk.ListEntityTagAssignmentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEntityTagAssignmentsResponse{} + conv3, err := convertSlice(w.TagAssignments, EntityTagAssignmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListEntityTagAssignmentsResponse.TagAssignments", err) + } + out.TagAssignments = conv3 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListEntityTagAssignmentsResponseFromSDK converts the sdk-go type to the mirror. +func ListEntityTagAssignmentsResponseFromSDK(v *sdk.ListEntityTagAssignmentsResponse) (*ListEntityTagAssignmentsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListEntityTagAssignmentsResponse{} + conv4, err := convertSlice(v.TagAssignments, EntityTagAssignmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListEntityTagAssignmentsResponse.TagAssignments", err) + } + out.TagAssignments = conv4 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// UpdateEntityTagAssignmentRequestToSDK converts the mirror to the sdk-go type. +func UpdateEntityTagAssignmentRequestToSDK(w *UpdateEntityTagAssignmentRequest) (*sdk.UpdateEntityTagAssignmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateEntityTagAssignmentRequest{} + conv5, err := EntityTagAssignmentToSDK(w.TagAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEntityTagAssignmentRequest.TagAssignment", err) + } + out.TagAssignment = conv5 + mask6, err := fieldMaskFromString[sdk.EntityTagAssignment](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEntityTagAssignmentRequest.UpdateMask", err) + } + out.UpdateMask = mask6 + return out, nil +} + +// UpdateEntityTagAssignmentRequestFromSDK converts the sdk-go type to the mirror. +func UpdateEntityTagAssignmentRequestFromSDK(v *sdk.UpdateEntityTagAssignmentRequest) (*UpdateEntityTagAssignmentRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateEntityTagAssignmentRequest{} + conv7, err := EntityTagAssignmentFromSDK(v.TagAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEntityTagAssignmentRequest.TagAssignment", err) + } + out.TagAssignment = conv7 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/uc/externallineage/v1/types.generated.go b/libs/sdktypes/uc/externallineage/v1/types.generated.go new file mode 100644 index 00000000000..3eb4b0106a0 --- /dev/null +++ b/libs/sdktypes/uc/externallineage/v1/types.generated.go @@ -0,0 +1,991 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/externallineage/v1. DO NOT EDIT. + +package externallineage + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/externallineage/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + SystemType = sdk.SystemType + Direction_LineageDirection = sdk.Direction_LineageDirection +) + +const ( + SystemType_Unspecified = sdk.SystemType_Unspecified + SystemType_Other = sdk.SystemType_Other + SystemType_Tableau = sdk.SystemType_Tableau + SystemType_PowerBi = sdk.SystemType_PowerBi + SystemType_Looker = sdk.SystemType_Looker + SystemType_Kafka = sdk.SystemType_Kafka + SystemType_Sap = sdk.SystemType_Sap + SystemType_Oracle = sdk.SystemType_Oracle + SystemType_Salesforce = sdk.SystemType_Salesforce + SystemType_Workday = sdk.SystemType_Workday + SystemType_Mysql = sdk.SystemType_Mysql + SystemType_Postgresql = sdk.SystemType_Postgresql + SystemType_MicrosoftSqlServer = sdk.SystemType_MicrosoftSqlServer + SystemType_Servicenow = sdk.SystemType_Servicenow + SystemType_AmazonRedshift = sdk.SystemType_AmazonRedshift + SystemType_AzureSynapse = sdk.SystemType_AzureSynapse + SystemType_Snowflake = sdk.SystemType_Snowflake + SystemType_GoogleBigquery = sdk.SystemType_GoogleBigquery + SystemType_MicrosoftFabric = sdk.SystemType_MicrosoftFabric + SystemType_Mongodb = sdk.SystemType_Mongodb + SystemType_Teradata = sdk.SystemType_Teradata + SystemType_Confluent = sdk.SystemType_Confluent + SystemType_Databricks = sdk.SystemType_Databricks + SystemType_StreamNative = sdk.SystemType_StreamNative + Direction_LineageDirection_Unspecified = sdk.Direction_LineageDirection_Unspecified + Direction_LineageDirection_Upstream = sdk.Direction_LineageDirection_Upstream + Direction_LineageDirection_Downstream = sdk.Direction_LineageDirection_Downstream +) + +type ColumnRelationship struct { + Source *string `json:"source,omitempty"` + Target *string `json:"target,omitempty"` +} + +type CreateExternalLineageRelationshipRequest struct { + ExternalLineageRelationship *CreateRequestExternalLineage `json:"external_lineage_relationship,omitempty"` +} + +type CreateRequestExternalLineage struct { + // List of column relationships between source and target objects. + Columns []ColumnRelationship `json:"columns,omitempty"` + // Unique identifier of the external lineage relationship. + Id *string `json:"id,omitempty"` + // Key-value properties associated with the external lineage relationship. + Properties map[string]string `json:"properties,omitempty"` + // Source object of the external lineage relationship. + Source *ExternalLineageRelationshipObject `json:"source,omitempty"` + // Target object of the external lineage relationship. + Target *ExternalLineageRelationshipObject `json:"target,omitempty"` +} + +type DeleteExternalLineageRelationshipRequest struct { + ExternalLineageRelationship *DeleteRequestExternalLineage `json:"external_lineage_relationship,omitempty"` +} + +type DeleteRequestExternalLineage struct { + // List of column relationships between source and target objects. + Columns []ColumnRelationship `json:"columns,omitempty"` + // Unique identifier of the external lineage relationship. + Id *string `json:"id,omitempty"` + // Key-value properties associated with the external lineage relationship. + Properties map[string]string `json:"properties,omitempty"` + // Source object of the external lineage relationship. + Source *ExternalLineageRelationshipObject `json:"source,omitempty"` + // Target object of the external lineage relationship. + Target *ExternalLineageRelationshipObject `json:"target,omitempty"` +} + +// Lineage response containing lineage information of a data asset.. +type ExternalLineageInfo struct { + // Information about the edge metadata of the external lineage relationship. + ExternalLineageInfo *ExternalLineageRelationship `json:"external_lineage_info,omitempty"` + // Information about external metadata involved in the lineage relationship. + ExternalMetadataInfo *LineageExternalMetadataInfo `json:"external_metadata_info,omitempty"` + // Information about the file involved in the lineage relationship. + FileInfo *LineageFileInfo `json:"file_info,omitempty"` + // Information about the model version involved in the lineage relationship. + ModelInfo *LineageModelVersionInfo `json:"model_info,omitempty"` + // Information about the table involved in the lineage relationship. + TableInfo *LineageTableInfo `json:"table_info,omitempty"` +} + +type ExternalLineageRelationship struct { + // List of column relationships between source and target objects. + Columns []ColumnRelationship `json:"columns,omitempty"` + // Unique identifier of the external lineage relationship. + Id *string `json:"id,omitempty"` + // Key-value properties associated with the external lineage relationship. + Properties map[string]string `json:"properties,omitempty"` + // Source object of the external lineage relationship. + Source *ExternalLineageRelationshipObject `json:"source,omitempty"` + // Target object of the external lineage relationship. + Target *ExternalLineageRelationshipObject `json:"target,omitempty"` +} + +type ExternalLineageRelationshipExternalMetadata struct { + Name *string `json:"name,omitempty"` +} + +type ExternalLineageRelationshipModelVersion struct { + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +type ExternalLineageRelationshipObject struct { + ExternalMetadata *ExternalLineageRelationshipExternalMetadata `json:"external_metadata,omitempty"` + ModelVersion *ExternalLineageRelationshipModelVersion `json:"model_version,omitempty"` + Path *ExternalLineageRelationshipPath `json:"path,omitempty"` + Table *ExternalLineageRelationshipTable `json:"table,omitempty"` +} + +type ExternalLineageRelationshipPath struct { + Url *string `json:"url,omitempty"` +} + +type ExternalLineageRelationshipTable struct { + Name *string `json:"name,omitempty"` +} + +// Represents the external metadata object in the lineage event.. +type LineageExternalMetadataInfo struct { + // Type of entity represented by the external metadata object. + EntityType *string `json:"entity_type,omitempty"` + // Timestamp of the lineage event. + EventTime *types.Time `json:"event_time,omitempty"` + // Name of the external metadata object. + Name *string `json:"name,omitempty"` + // Type of external system. + SystemType SystemType `json:"system_type,omitempty"` +} + +// Represents the path information in the lineage event.. +type LineageFileInfo struct { + // Timestamp of the lineage event. + EventTime *types.Time `json:"event_time,omitempty"` + // URL of the path. + Path *string `json:"path,omitempty"` + // The full name of the securable on the path. + SecurableName *string `json:"securable_name,omitempty"` + // The securable type of the securable on the path. + SecurableType *string `json:"securable_type,omitempty"` + // The storage location associated with securable on the path. + StorageLocation *string `json:"storage_location,omitempty"` +} + +// Represents the model version information in the lineage event.. +type LineageModelVersionInfo struct { + // Timestamp of the lineage event. + EventTime *types.Time `json:"event_time,omitempty"` + // Name of the model. + ModelName *string `json:"model_name,omitempty"` + // Version number of the model. + Version *int64 `json:"version,omitempty"` +} + +// Represents the table information in the lineage event.. +type LineageTableInfo struct { + // Name of Catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // Timestamp of the lineage event. + EventTime *types.Time `json:"event_time,omitempty"` + // Name of Table. + Name *string `json:"name,omitempty"` + // Name of Schema. + SchemaName *string `json:"schema_name,omitempty"` +} + +type ListExternalLineageRelationshipsRequest struct { + // The lineage direction to filter on. + LineageDirection Direction_LineageDirection `json:"lineage_direction,omitempty"` + // The object to query external lineage relationships for. Since this field is a + // query parameter, please flatten the nested fields. For example, if the object + // is a table, the query parameter should look like: + // `object_info.table.name=main.sales.customers` + ObjectInfo *ExternalLineageRelationshipObject `json:"object_info,omitempty"` + // Specifies the maximum number of external lineage relationships to return in a + // single response. The value must be less than or equal to 1000. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListExternalLineageRelationshipsResponse struct { + ExternalLineageRelationships []ExternalLineageInfo `json:"external_lineage_relationships,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type UpdateExternalLineageRelationshipRequest struct { + ExternalLineageRelationship *UpdateRequestExternalLineage `json:"external_lineage_relationship,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +type UpdateRequestExternalLineage struct { + // List of column relationships between source and target objects. + Columns []ColumnRelationship `json:"columns,omitempty"` + // Unique identifier of the external lineage relationship. + Id *string `json:"id,omitempty"` + // Key-value properties associated with the external lineage relationship. + Properties map[string]string `json:"properties,omitempty"` + // Source object of the external lineage relationship. + Source *ExternalLineageRelationshipObject `json:"source,omitempty"` + // Target object of the external lineage relationship. + Target *ExternalLineageRelationshipObject `json:"target,omitempty"` +} + +// ColumnRelationshipToSDK converts the mirror to the sdk-go type. +func ColumnRelationshipToSDK(w *ColumnRelationship) (*sdk.ColumnRelationship, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnRelationship{} + out.Source = w.Source + out.Target = w.Target + return out, nil +} + +// ColumnRelationshipFromSDK converts the sdk-go type to the mirror. +func ColumnRelationshipFromSDK(v *sdk.ColumnRelationship) (*ColumnRelationship, error) { + if v == nil { + return nil, nil + } + out := &ColumnRelationship{} + out.Source = v.Source + out.Target = v.Target + return out, nil +} + +// CreateExternalLineageRelationshipRequestToSDK converts the mirror to the sdk-go type. +func CreateExternalLineageRelationshipRequestToSDK(w *CreateExternalLineageRelationshipRequest) (*sdk.CreateExternalLineageRelationshipRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateExternalLineageRelationshipRequest{} + conv1, err := CreateRequestExternalLineageToSDK(w.ExternalLineageRelationship) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExternalLineageRelationshipRequest.ExternalLineageRelationship", err) + } + out.ExternalLineageRelationship = conv1 + return out, nil +} + +// CreateExternalLineageRelationshipRequestFromSDK converts the sdk-go type to the mirror. +func CreateExternalLineageRelationshipRequestFromSDK(v *sdk.CreateExternalLineageRelationshipRequest) (*CreateExternalLineageRelationshipRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateExternalLineageRelationshipRequest{} + conv2, err := CreateRequestExternalLineageFromSDK(v.ExternalLineageRelationship) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExternalLineageRelationshipRequest.ExternalLineageRelationship", err) + } + out.ExternalLineageRelationship = conv2 + return out, nil +} + +// CreateRequestExternalLineageToSDK converts the mirror to the sdk-go type. +func CreateRequestExternalLineageToSDK(w *CreateRequestExternalLineage) (*sdk.CreateRequestExternalLineage, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRequestExternalLineage{} + out.Id = w.Id + conv3, err := ExternalLineageRelationshipObjectToSDK(w.Source) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRequestExternalLineage.Source", err) + } + out.Source = conv3 + conv4, err := ExternalLineageRelationshipObjectToSDK(w.Target) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRequestExternalLineage.Target", err) + } + out.Target = conv4 + conv5, err := convertSlice(w.Columns, ColumnRelationshipToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRequestExternalLineage.Columns", err) + } + out.Columns = conv5 + out.Properties = w.Properties + return out, nil +} + +// CreateRequestExternalLineageFromSDK converts the sdk-go type to the mirror. +func CreateRequestExternalLineageFromSDK(v *sdk.CreateRequestExternalLineage) (*CreateRequestExternalLineage, error) { + if v == nil { + return nil, nil + } + out := &CreateRequestExternalLineage{} + out.Id = v.Id + conv6, err := ExternalLineageRelationshipObjectFromSDK(v.Source) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRequestExternalLineage.Source", err) + } + out.Source = conv6 + conv7, err := ExternalLineageRelationshipObjectFromSDK(v.Target) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRequestExternalLineage.Target", err) + } + out.Target = conv7 + conv8, err := convertSlice(v.Columns, ColumnRelationshipFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRequestExternalLineage.Columns", err) + } + out.Columns = conv8 + out.Properties = v.Properties + return out, nil +} + +// DeleteExternalLineageRelationshipRequestToSDK converts the mirror to the sdk-go type. +func DeleteExternalLineageRelationshipRequestToSDK(w *DeleteExternalLineageRelationshipRequest) (*sdk.DeleteExternalLineageRelationshipRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteExternalLineageRelationshipRequest{} + conv9, err := DeleteRequestExternalLineageToSDK(w.ExternalLineageRelationship) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeleteExternalLineageRelationshipRequest.ExternalLineageRelationship", err) + } + out.ExternalLineageRelationship = conv9 + return out, nil +} + +// DeleteExternalLineageRelationshipRequestFromSDK converts the sdk-go type to the mirror. +func DeleteExternalLineageRelationshipRequestFromSDK(v *sdk.DeleteExternalLineageRelationshipRequest) (*DeleteExternalLineageRelationshipRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteExternalLineageRelationshipRequest{} + conv10, err := DeleteRequestExternalLineageFromSDK(v.ExternalLineageRelationship) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeleteExternalLineageRelationshipRequest.ExternalLineageRelationship", err) + } + out.ExternalLineageRelationship = conv10 + return out, nil +} + +// DeleteRequestExternalLineageToSDK converts the mirror to the sdk-go type. +func DeleteRequestExternalLineageToSDK(w *DeleteRequestExternalLineage) (*sdk.DeleteRequestExternalLineage, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteRequestExternalLineage{} + out.Id = w.Id + conv11, err := ExternalLineageRelationshipObjectToSDK(w.Source) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeleteRequestExternalLineage.Source", err) + } + out.Source = conv11 + conv12, err := ExternalLineageRelationshipObjectToSDK(w.Target) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeleteRequestExternalLineage.Target", err) + } + out.Target = conv12 + conv13, err := convertSlice(w.Columns, ColumnRelationshipToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeleteRequestExternalLineage.Columns", err) + } + out.Columns = conv13 + out.Properties = w.Properties + return out, nil +} + +// DeleteRequestExternalLineageFromSDK converts the sdk-go type to the mirror. +func DeleteRequestExternalLineageFromSDK(v *sdk.DeleteRequestExternalLineage) (*DeleteRequestExternalLineage, error) { + if v == nil { + return nil, nil + } + out := &DeleteRequestExternalLineage{} + out.Id = v.Id + conv14, err := ExternalLineageRelationshipObjectFromSDK(v.Source) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeleteRequestExternalLineage.Source", err) + } + out.Source = conv14 + conv15, err := ExternalLineageRelationshipObjectFromSDK(v.Target) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeleteRequestExternalLineage.Target", err) + } + out.Target = conv15 + conv16, err := convertSlice(v.Columns, ColumnRelationshipFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeleteRequestExternalLineage.Columns", err) + } + out.Columns = conv16 + out.Properties = v.Properties + return out, nil +} + +// ExternalLineageInfoToSDK converts the mirror to the sdk-go type. +func ExternalLineageInfoToSDK(w *ExternalLineageInfo) (*sdk.ExternalLineageInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalLineageInfo{} + conv17, err := LineageTableInfoToSDK(w.TableInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageInfo.TableInfo", err) + } + out.TableInfo = conv17 + conv18, err := LineageFileInfoToSDK(w.FileInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageInfo.FileInfo", err) + } + out.FileInfo = conv18 + conv19, err := LineageModelVersionInfoToSDK(w.ModelInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageInfo.ModelInfo", err) + } + out.ModelInfo = conv19 + conv20, err := LineageExternalMetadataInfoToSDK(w.ExternalMetadataInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageInfo.ExternalMetadataInfo", err) + } + out.ExternalMetadataInfo = conv20 + conv21, err := ExternalLineageRelationshipToSDK(w.ExternalLineageInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageInfo.ExternalLineageInfo", err) + } + out.ExternalLineageInfo = conv21 + return out, nil +} + +// ExternalLineageInfoFromSDK converts the sdk-go type to the mirror. +func ExternalLineageInfoFromSDK(v *sdk.ExternalLineageInfo) (*ExternalLineageInfo, error) { + if v == nil { + return nil, nil + } + out := &ExternalLineageInfo{} + conv22, err := LineageTableInfoFromSDK(v.TableInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageInfo.TableInfo", err) + } + out.TableInfo = conv22 + conv23, err := LineageFileInfoFromSDK(v.FileInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageInfo.FileInfo", err) + } + out.FileInfo = conv23 + conv24, err := LineageModelVersionInfoFromSDK(v.ModelInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageInfo.ModelInfo", err) + } + out.ModelInfo = conv24 + conv25, err := LineageExternalMetadataInfoFromSDK(v.ExternalMetadataInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageInfo.ExternalMetadataInfo", err) + } + out.ExternalMetadataInfo = conv25 + conv26, err := ExternalLineageRelationshipFromSDK(v.ExternalLineageInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageInfo.ExternalLineageInfo", err) + } + out.ExternalLineageInfo = conv26 + return out, nil +} + +// ExternalLineageRelationshipToSDK converts the mirror to the sdk-go type. +func ExternalLineageRelationshipToSDK(w *ExternalLineageRelationship) (*sdk.ExternalLineageRelationship, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalLineageRelationship{} + out.Id = w.Id + conv27, err := ExternalLineageRelationshipObjectToSDK(w.Source) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationship.Source", err) + } + out.Source = conv27 + conv28, err := ExternalLineageRelationshipObjectToSDK(w.Target) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationship.Target", err) + } + out.Target = conv28 + conv29, err := convertSlice(w.Columns, ColumnRelationshipToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationship.Columns", err) + } + out.Columns = conv29 + out.Properties = w.Properties + return out, nil +} + +// ExternalLineageRelationshipFromSDK converts the sdk-go type to the mirror. +func ExternalLineageRelationshipFromSDK(v *sdk.ExternalLineageRelationship) (*ExternalLineageRelationship, error) { + if v == nil { + return nil, nil + } + out := &ExternalLineageRelationship{} + out.Id = v.Id + conv30, err := ExternalLineageRelationshipObjectFromSDK(v.Source) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationship.Source", err) + } + out.Source = conv30 + conv31, err := ExternalLineageRelationshipObjectFromSDK(v.Target) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationship.Target", err) + } + out.Target = conv31 + conv32, err := convertSlice(v.Columns, ColumnRelationshipFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationship.Columns", err) + } + out.Columns = conv32 + out.Properties = v.Properties + return out, nil +} + +// ExternalLineageRelationshipExternalMetadataToSDK converts the mirror to the sdk-go type. +func ExternalLineageRelationshipExternalMetadataToSDK(w *ExternalLineageRelationshipExternalMetadata) (*sdk.ExternalLineageRelationshipExternalMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalLineageRelationshipExternalMetadata{} + out.Name = w.Name + return out, nil +} + +// ExternalLineageRelationshipExternalMetadataFromSDK converts the sdk-go type to the mirror. +func ExternalLineageRelationshipExternalMetadataFromSDK(v *sdk.ExternalLineageRelationshipExternalMetadata) (*ExternalLineageRelationshipExternalMetadata, error) { + if v == nil { + return nil, nil + } + out := &ExternalLineageRelationshipExternalMetadata{} + out.Name = v.Name + return out, nil +} + +// ExternalLineageRelationshipModelVersionToSDK converts the mirror to the sdk-go type. +func ExternalLineageRelationshipModelVersionToSDK(w *ExternalLineageRelationshipModelVersion) (*sdk.ExternalLineageRelationshipModelVersion, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalLineageRelationshipModelVersion{} + out.Name = w.Name + out.Version = w.Version + return out, nil +} + +// ExternalLineageRelationshipModelVersionFromSDK converts the sdk-go type to the mirror. +func ExternalLineageRelationshipModelVersionFromSDK(v *sdk.ExternalLineageRelationshipModelVersion) (*ExternalLineageRelationshipModelVersion, error) { + if v == nil { + return nil, nil + } + out := &ExternalLineageRelationshipModelVersion{} + out.Name = v.Name + out.Version = v.Version + return out, nil +} + +// ExternalLineageRelationshipObjectToSDK converts the mirror to the sdk-go type. +func ExternalLineageRelationshipObjectToSDK(w *ExternalLineageRelationshipObject) (*sdk.ExternalLineageRelationshipObject, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalLineageRelationshipObject{} + { + var members []string + if w.Table != nil { + members = append(members, "table") + } + if w.Path != nil { + members = append(members, "path") + } + if w.ModelVersion != nil { + members = append(members, "model_version") + } + if w.ExternalMetadata != nil { + members = append(members, "external_metadata") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Table != nil: + conv33, err := ExternalLineageRelationshipTableToSDK(w.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationshipObject.Tpe", err) + } + out.Tpe = &sdk.ExternalLineageRelationshipObject_Tpe_Table{Table: *conv33} + case w.Path != nil: + conv34, err := ExternalLineageRelationshipPathToSDK(w.Path) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationshipObject.Tpe", err) + } + out.Tpe = &sdk.ExternalLineageRelationshipObject_Tpe_Path{Path: *conv34} + case w.ModelVersion != nil: + conv35, err := ExternalLineageRelationshipModelVersionToSDK(w.ModelVersion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationshipObject.Tpe", err) + } + out.Tpe = &sdk.ExternalLineageRelationshipObject_Tpe_ModelVersion{ModelVersion: *conv35} + case w.ExternalMetadata != nil: + conv36, err := ExternalLineageRelationshipExternalMetadataToSDK(w.ExternalMetadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationshipObject.Tpe", err) + } + out.Tpe = &sdk.ExternalLineageRelationshipObject_Tpe_ExternalMetadata{ExternalMetadata: *conv36} + } + return out, nil +} + +// ExternalLineageRelationshipObjectFromSDK converts the sdk-go type to the mirror. +func ExternalLineageRelationshipObjectFromSDK(v *sdk.ExternalLineageRelationshipObject) (*ExternalLineageRelationshipObject, error) { + if v == nil { + return nil, nil + } + out := &ExternalLineageRelationshipObject{} + switch value := v.Tpe.(type) { + case *sdk.ExternalLineageRelationshipObject_Tpe_Table: + if value != nil { + conv37, err := ExternalLineageRelationshipTableFromSDK(&value.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationshipObject.Tpe", err) + } + out.Table = conv37 + } + case *sdk.ExternalLineageRelationshipObject_Tpe_Path: + if value != nil { + conv38, err := ExternalLineageRelationshipPathFromSDK(&value.Path) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationshipObject.Tpe", err) + } + out.Path = conv38 + } + case *sdk.ExternalLineageRelationshipObject_Tpe_ModelVersion: + if value != nil { + conv39, err := ExternalLineageRelationshipModelVersionFromSDK(&value.ModelVersion) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationshipObject.Tpe", err) + } + out.ModelVersion = conv39 + } + case *sdk.ExternalLineageRelationshipObject_Tpe_ExternalMetadata: + if value != nil { + conv40, err := ExternalLineageRelationshipExternalMetadataFromSDK(&value.ExternalMetadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLineageRelationshipObject.Tpe", err) + } + out.ExternalMetadata = conv40 + } + } + return out, nil +} + +// ExternalLineageRelationshipPathToSDK converts the mirror to the sdk-go type. +func ExternalLineageRelationshipPathToSDK(w *ExternalLineageRelationshipPath) (*sdk.ExternalLineageRelationshipPath, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalLineageRelationshipPath{} + out.Url = w.Url + return out, nil +} + +// ExternalLineageRelationshipPathFromSDK converts the sdk-go type to the mirror. +func ExternalLineageRelationshipPathFromSDK(v *sdk.ExternalLineageRelationshipPath) (*ExternalLineageRelationshipPath, error) { + if v == nil { + return nil, nil + } + out := &ExternalLineageRelationshipPath{} + out.Url = v.Url + return out, nil +} + +// ExternalLineageRelationshipTableToSDK converts the mirror to the sdk-go type. +func ExternalLineageRelationshipTableToSDK(w *ExternalLineageRelationshipTable) (*sdk.ExternalLineageRelationshipTable, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalLineageRelationshipTable{} + out.Name = w.Name + return out, nil +} + +// ExternalLineageRelationshipTableFromSDK converts the sdk-go type to the mirror. +func ExternalLineageRelationshipTableFromSDK(v *sdk.ExternalLineageRelationshipTable) (*ExternalLineageRelationshipTable, error) { + if v == nil { + return nil, nil + } + out := &ExternalLineageRelationshipTable{} + out.Name = v.Name + return out, nil +} + +// LineageExternalMetadataInfoToSDK converts the mirror to the sdk-go type. +func LineageExternalMetadataInfoToSDK(w *LineageExternalMetadataInfo) (*sdk.LineageExternalMetadataInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.LineageExternalMetadataInfo{} + out.Name = w.Name + out.SystemType = w.SystemType + out.EntityType = w.EntityType + out.EventTime = w.EventTime + return out, nil +} + +// LineageExternalMetadataInfoFromSDK converts the sdk-go type to the mirror. +func LineageExternalMetadataInfoFromSDK(v *sdk.LineageExternalMetadataInfo) (*LineageExternalMetadataInfo, error) { + if v == nil { + return nil, nil + } + out := &LineageExternalMetadataInfo{} + out.Name = v.Name + out.SystemType = v.SystemType + out.EntityType = v.EntityType + out.EventTime = v.EventTime + return out, nil +} + +// LineageFileInfoToSDK converts the mirror to the sdk-go type. +func LineageFileInfoToSDK(w *LineageFileInfo) (*sdk.LineageFileInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.LineageFileInfo{} + out.Path = w.Path + out.SecurableName = w.SecurableName + out.StorageLocation = w.StorageLocation + out.SecurableType = w.SecurableType + out.EventTime = w.EventTime + return out, nil +} + +// LineageFileInfoFromSDK converts the sdk-go type to the mirror. +func LineageFileInfoFromSDK(v *sdk.LineageFileInfo) (*LineageFileInfo, error) { + if v == nil { + return nil, nil + } + out := &LineageFileInfo{} + out.Path = v.Path + out.SecurableName = v.SecurableName + out.StorageLocation = v.StorageLocation + out.SecurableType = v.SecurableType + out.EventTime = v.EventTime + return out, nil +} + +// LineageModelVersionInfoToSDK converts the mirror to the sdk-go type. +func LineageModelVersionInfoToSDK(w *LineageModelVersionInfo) (*sdk.LineageModelVersionInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.LineageModelVersionInfo{} + out.ModelName = w.ModelName + out.Version = w.Version + out.EventTime = w.EventTime + return out, nil +} + +// LineageModelVersionInfoFromSDK converts the sdk-go type to the mirror. +func LineageModelVersionInfoFromSDK(v *sdk.LineageModelVersionInfo) (*LineageModelVersionInfo, error) { + if v == nil { + return nil, nil + } + out := &LineageModelVersionInfo{} + out.ModelName = v.ModelName + out.Version = v.Version + out.EventTime = v.EventTime + return out, nil +} + +// LineageTableInfoToSDK converts the mirror to the sdk-go type. +func LineageTableInfoToSDK(w *LineageTableInfo) (*sdk.LineageTableInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.LineageTableInfo{} + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.EventTime = w.EventTime + return out, nil +} + +// LineageTableInfoFromSDK converts the sdk-go type to the mirror. +func LineageTableInfoFromSDK(v *sdk.LineageTableInfo) (*LineageTableInfo, error) { + if v == nil { + return nil, nil + } + out := &LineageTableInfo{} + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.EventTime = v.EventTime + return out, nil +} + +// ListExternalLineageRelationshipsRequestToSDK converts the mirror to the sdk-go type. +func ListExternalLineageRelationshipsRequestToSDK(w *ListExternalLineageRelationshipsRequest) (*sdk.ListExternalLineageRelationshipsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExternalLineageRelationshipsRequest{} + conv41, err := ExternalLineageRelationshipObjectToSDK(w.ObjectInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExternalLineageRelationshipsRequest.ObjectInfo", err) + } + out.ObjectInfo = conv41 + out.LineageDirection = w.LineageDirection + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListExternalLineageRelationshipsRequestFromSDK converts the sdk-go type to the mirror. +func ListExternalLineageRelationshipsRequestFromSDK(v *sdk.ListExternalLineageRelationshipsRequest) (*ListExternalLineageRelationshipsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListExternalLineageRelationshipsRequest{} + conv42, err := ExternalLineageRelationshipObjectFromSDK(v.ObjectInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExternalLineageRelationshipsRequest.ObjectInfo", err) + } + out.ObjectInfo = conv42 + out.LineageDirection = v.LineageDirection + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListExternalLineageRelationshipsResponseToSDK converts the mirror to the sdk-go type. +func ListExternalLineageRelationshipsResponseToSDK(w *ListExternalLineageRelationshipsResponse) (*sdk.ListExternalLineageRelationshipsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExternalLineageRelationshipsResponse{} + conv43, err := convertSlice(w.ExternalLineageRelationships, ExternalLineageInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExternalLineageRelationshipsResponse.ExternalLineageRelationships", err) + } + out.ExternalLineageRelationships = conv43 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListExternalLineageRelationshipsResponseFromSDK converts the sdk-go type to the mirror. +func ListExternalLineageRelationshipsResponseFromSDK(v *sdk.ListExternalLineageRelationshipsResponse) (*ListExternalLineageRelationshipsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListExternalLineageRelationshipsResponse{} + conv44, err := convertSlice(v.ExternalLineageRelationships, ExternalLineageInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExternalLineageRelationshipsResponse.ExternalLineageRelationships", err) + } + out.ExternalLineageRelationships = conv44 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// UpdateExternalLineageRelationshipRequestToSDK converts the mirror to the sdk-go type. +func UpdateExternalLineageRelationshipRequestToSDK(w *UpdateExternalLineageRelationshipRequest) (*sdk.UpdateExternalLineageRelationshipRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateExternalLineageRelationshipRequest{} + conv45, err := UpdateRequestExternalLineageToSDK(w.ExternalLineageRelationship) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExternalLineageRelationshipRequest.ExternalLineageRelationship", err) + } + out.ExternalLineageRelationship = conv45 + mask46, err := fieldMaskFromString[sdk.UpdateRequestExternalLineage](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExternalLineageRelationshipRequest.UpdateMask", err) + } + out.UpdateMask = mask46 + return out, nil +} + +// UpdateExternalLineageRelationshipRequestFromSDK converts the sdk-go type to the mirror. +func UpdateExternalLineageRelationshipRequestFromSDK(v *sdk.UpdateExternalLineageRelationshipRequest) (*UpdateExternalLineageRelationshipRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateExternalLineageRelationshipRequest{} + conv47, err := UpdateRequestExternalLineageFromSDK(v.ExternalLineageRelationship) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExternalLineageRelationshipRequest.ExternalLineageRelationship", err) + } + out.ExternalLineageRelationship = conv47 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// UpdateRequestExternalLineageToSDK converts the mirror to the sdk-go type. +func UpdateRequestExternalLineageToSDK(w *UpdateRequestExternalLineage) (*sdk.UpdateRequestExternalLineage, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRequestExternalLineage{} + out.Id = w.Id + conv48, err := ExternalLineageRelationshipObjectToSDK(w.Source) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRequestExternalLineage.Source", err) + } + out.Source = conv48 + conv49, err := ExternalLineageRelationshipObjectToSDK(w.Target) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRequestExternalLineage.Target", err) + } + out.Target = conv49 + conv50, err := convertSlice(w.Columns, ColumnRelationshipToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRequestExternalLineage.Columns", err) + } + out.Columns = conv50 + out.Properties = w.Properties + return out, nil +} + +// UpdateRequestExternalLineageFromSDK converts the sdk-go type to the mirror. +func UpdateRequestExternalLineageFromSDK(v *sdk.UpdateRequestExternalLineage) (*UpdateRequestExternalLineage, error) { + if v == nil { + return nil, nil + } + out := &UpdateRequestExternalLineage{} + out.Id = v.Id + conv51, err := ExternalLineageRelationshipObjectFromSDK(v.Source) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRequestExternalLineage.Source", err) + } + out.Source = conv51 + conv52, err := ExternalLineageRelationshipObjectFromSDK(v.Target) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRequestExternalLineage.Target", err) + } + out.Target = conv52 + conv53, err := convertSlice(v.Columns, ColumnRelationshipFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRequestExternalLineage.Columns", err) + } + out.Columns = conv53 + out.Properties = v.Properties + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/uc/externallocations/v1/types.generated.go b/libs/sdktypes/uc/externallocations/v1/types.generated.go new file mode 100644 index 00000000000..60db769de64 --- /dev/null +++ b/libs/sdktypes/uc/externallocations/v1/types.generated.go @@ -0,0 +1,950 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/externallocations/v1. DO NOT EDIT. + +package externallocations + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/externallocations/v1" + + strings "strings" +) + +type ( + IsolationMode = sdk.IsolationMode + SseEncryptionAlgorithm = sdk.SseEncryptionAlgorithm +) + +const ( + IsolationMode_Unspecified = sdk.IsolationMode_Unspecified + IsolationMode_IsolationModeOpen = sdk.IsolationMode_IsolationModeOpen + IsolationMode_IsolationModeIsolated = sdk.IsolationMode_IsolationModeIsolated + SseEncryptionAlgorithm_Unspecified = sdk.SseEncryptionAlgorithm_Unspecified + SseEncryptionAlgorithm_AwsSseS3 = sdk.SseEncryptionAlgorithm_AwsSseS3 + SseEncryptionAlgorithm_AwsSseKms = sdk.SseEncryptionAlgorithm_AwsSseKms +) + +type AwsSqsQueue struct { + // Unique identifier included in the name of file events managed cloud + // resources. + ManagedResourceId *string `json:"managed_resource_id,omitempty"` + // The AQS queue url in the format https://sqs.{region}.amazonaws.com/{account + // id}/{queue name}. Only required for provided_sqs. + QueueUrl *string `json:"queue_url,omitempty"` +} + +type AzureQueueStorage struct { + // Unique identifier included in the name of file events managed cloud + // resources. + ManagedResourceId *string `json:"managed_resource_id,omitempty"` + // The AQS queue url in the format https://{storage + // account}.queue.core.windows.net/{queue name} Only required for provided_aqs. + QueueUrl *string `json:"queue_url,omitempty"` + // Optional resource group for the queue, event grid subscription, and external + // location storage account. Only required for locations with a service + // principal storage credential + ResourceGroup *string `json:"resource_group,omitempty"` + // Optional subscription id for the queue, event grid subscription, and external + // location storage account. Required for locations with a service principal + // storage credential + SubscriptionId *string `json:"subscription_id,omitempty"` +} + +type CreateExternalLocationRequest struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this external location was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of external location creator. + CreatedBy *string `json:"created_by,omitempty"` + // Unique ID of the location's storage credential. + CredentialId *string `json:"credential_id,omitempty"` + // Name of the storage credential used with this location. + CredentialName *string `json:"credential_name,omitempty"` + // The effective value of `enable_file_events` after applying server-side + // defaults. + EffectiveEnableFileEvents *bool `json:"effective_enable_file_events,omitempty"` + // The effective file event queue configuration after applying server-side + // defaults. Always populated when a queue is provisioned, regardless of whether + // the user explicitly set `enable_file_events`. Use this field instead of + // `file_event_queue` for reading the actual queue state. + EffectiveFileEventQueue *FileEventQueue `json:"effective_file_event_queue,omitempty"` + // Whether to enable file events on this external location. Default to `true`. + // Set to `false` to disable file events. The actual applied value may differ + // due to server-side defaults; check `effective_enable_file_events` for the + // effective state. + EnableFileEvents *bool `json:"enable_file_events,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryption_details,omitempty"` + // Indicates whether fallback mode is enabled for this external location. When + // fallback mode is enabled, the access to the location falls back to cluster + // credentials if UC credentials are not sufficient. + Fallback *bool `json:"fallback,omitempty"` + // File event queue settings. If `enable_file_events` is not `false`, must be + // defined and have exactly one of the documented properties. + FileEventQueue *FileEventQueue `json:"file_event_queue,omitempty"` + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + // Unique identifier of metastore hosting the external location. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of the external location. + Name *string `json:"name,omitempty"` + // The owner of the external location. + Owner *string `json:"owner,omitempty"` + // Indicates whether the external location is read-only. + ReadOnly *bool `json:"read_only,omitempty"` + // Skips validation of the storage credential associated with the external + // location. + SkipValidation *bool `json:"skip_validation,omitempty"` + // Time at which external location this was last modified, in epoch + // milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the external location. + UpdatedBy *string `json:"updated_by,omitempty"` + // Path URL of the external location. + Url *string `json:"url,omitempty"` +} + +type DeleteExternalLocationRequest struct { + // Force deletion even if there are dependent external tables or mounts. + Force *bool `json:"force,omitempty"` + // Name of the external location. + NameArg *string `json:"name_arg,omitempty"` +} + +// Encryption options that apply to clients connecting to cloud storage.. +type EncryptionDetails struct { + SseEncryptionDetails *SseEncryptionDetails `json:"sse_encryption_details,omitempty"` +} + +type ExternalLocationInfo struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this external location was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of external location creator. + CreatedBy *string `json:"created_by,omitempty"` + // Unique ID of the location's storage credential. + CredentialId *string `json:"credential_id,omitempty"` + // Name of the storage credential used with this location. + CredentialName *string `json:"credential_name,omitempty"` + // The effective value of `enable_file_events` after applying server-side + // defaults. + EffectiveEnableFileEvents *bool `json:"effective_enable_file_events,omitempty"` + // The effective file event queue configuration after applying server-side + // defaults. Always populated when a queue is provisioned, regardless of whether + // the user explicitly set `enable_file_events`. Use this field instead of + // `file_event_queue` for reading the actual queue state. + EffectiveFileEventQueue *FileEventQueue `json:"effective_file_event_queue,omitempty"` + // Whether to enable file events on this external location. Default to `true`. + // Set to `false` to disable file events. The actual applied value may differ + // due to server-side defaults; check `effective_enable_file_events` for the + // effective state. + EnableFileEvents *bool `json:"enable_file_events,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryption_details,omitempty"` + // Indicates whether fallback mode is enabled for this external location. When + // fallback mode is enabled, the access to the location falls back to cluster + // credentials if UC credentials are not sufficient. + Fallback *bool `json:"fallback,omitempty"` + // File event queue settings. If `enable_file_events` is not `false`, must be + // defined and have exactly one of the documented properties. + FileEventQueue *FileEventQueue `json:"file_event_queue,omitempty"` + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + // Unique identifier of metastore hosting the external location. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of the external location. + Name *string `json:"name,omitempty"` + // The owner of the external location. + Owner *string `json:"owner,omitempty"` + // Indicates whether the external location is read-only. + ReadOnly *bool `json:"read_only,omitempty"` + // Time at which external location this was last modified, in epoch + // milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the external location. + UpdatedBy *string `json:"updated_by,omitempty"` + // Path URL of the external location. + Url *string `json:"url,omitempty"` +} + +type FileEventQueue struct { + ManagedAqs *AzureQueueStorage `json:"managed_aqs,omitempty"` + ManagedPubsub *GcpPubsub `json:"managed_pubsub,omitempty"` + ManagedSqs *AwsSqsQueue `json:"managed_sqs,omitempty"` + ProvidedAqs *AzureQueueStorage `json:"provided_aqs,omitempty"` + ProvidedPubsub *GcpPubsub `json:"provided_pubsub,omitempty"` + ProvidedSqs *AwsSqsQueue `json:"provided_sqs,omitempty"` +} + +type GcpPubsub struct { + // Unique identifier included in the name of file events managed cloud + // resources. + ManagedResourceId *string `json:"managed_resource_id,omitempty"` + // The Pub/Sub subscription name in the format + // projects/{project}/subscriptions/{subscription name}. Only required for + // provided_pubsub. + SubscriptionName *string `json:"subscription_name,omitempty"` +} + +type GetExternalLocationRequest struct { + // Whether to include external locations in the response for which the principal + // can only access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` + // Name of the external location. + NameArg *string `json:"name_arg,omitempty"` +} + +type ListExternalLocationsRequest struct { + // Whether to include external locations in the response for which the principal + // can only access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` + // Whether to include external locations not bound to the workspace. Effective + // only if the user has permission to update the location–workspace binding. + IncludeUnbound *bool `json:"include_unbound,omitempty"` + // Maximum number of external locations to return. If not set, all the external + // locations are returned (not recommended). - when set to a value greater than + // 0, the page length is the minimum of this value and a server configured + // value; - when set to 0, the page length is set to a server configured value + // (recommended); - when set to a value less than 0, an invalid parameter error + // is returned; + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListExternalLocationsResponse struct { + // An array of external locations. + ExternalLocations []ExternalLocationInfo `json:"external_locations,omitempty"` + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// Server-Side Encryption properties for clients communicating with AWS s3.. +type SseEncryptionDetails struct { + // Sets the value of the 'x-amz-server-side-encryption' header in S3 request. + Algorithm SseEncryptionAlgorithm `json:"algorithm,omitempty"` + // Optional. The ARN of the SSE-KMS key used with the S3 location, when + // algorithm = "SSE-KMS". Sets the value of the + // 'x-amz-server-side-encryption-aws-kms-key-id' header. + AwsKmsKeyArn *string `json:"aws_kms_key_arn,omitempty"` +} + +type UpdateExternalLocationRequest struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this external location was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of external location creator. + CreatedBy *string `json:"created_by,omitempty"` + // Unique ID of the location's storage credential. + CredentialId *string `json:"credential_id,omitempty"` + // Name of the storage credential used with this location. + CredentialName *string `json:"credential_name,omitempty"` + // The effective value of `enable_file_events` after applying server-side + // defaults. + EffectiveEnableFileEvents *bool `json:"effective_enable_file_events,omitempty"` + // The effective file event queue configuration after applying server-side + // defaults. Always populated when a queue is provisioned, regardless of whether + // the user explicitly set `enable_file_events`. Use this field instead of + // `file_event_queue` for reading the actual queue state. + EffectiveFileEventQueue *FileEventQueue `json:"effective_file_event_queue,omitempty"` + // Whether to enable file events on this external location. Default to `true`. + // Set to `false` to disable file events. The actual applied value may differ + // due to server-side defaults; check `effective_enable_file_events` for the + // effective state. + EnableFileEvents *bool `json:"enable_file_events,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryption_details,omitempty"` + // Indicates whether fallback mode is enabled for this external location. When + // fallback mode is enabled, the access to the location falls back to cluster + // credentials if UC credentials are not sufficient. + Fallback *bool `json:"fallback,omitempty"` + // File event queue settings. If `enable_file_events` is not `false`, must be + // defined and have exactly one of the documented properties. + FileEventQueue *FileEventQueue `json:"file_event_queue,omitempty"` + // Force update even if changing url invalidates dependent external tables or + // mounts. + Force *bool `json:"force,omitempty"` + IsolationMode IsolationMode `json:"isolation_mode,omitempty"` + // Unique identifier of metastore hosting the external location. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of the external location. + Name *string `json:"name,omitempty"` + // Name of the external location. + NameArg *string `json:"name_arg,omitempty"` + // New name for the external location. + NewName *string `json:"new_name,omitempty"` + // The owner of the external location. + Owner *string `json:"owner,omitempty"` + // Indicates whether the external location is read-only. + ReadOnly *bool `json:"read_only,omitempty"` + // Skips validation of the storage credential associated with the external + // location. + SkipValidation *bool `json:"skip_validation,omitempty"` + // Time at which external location this was last modified, in epoch + // milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the external location. + UpdatedBy *string `json:"updated_by,omitempty"` + // Path URL of the external location. + Url *string `json:"url,omitempty"` +} + +// AwsSqsQueueToSDK converts the mirror to the sdk-go type. +func AwsSqsQueueToSDK(w *AwsSqsQueue) (*sdk.AwsSqsQueue, error) { + if w == nil { + return nil, nil + } + out := &sdk.AwsSqsQueue{} + out.QueueUrl = w.QueueUrl + out.ManagedResourceId = w.ManagedResourceId + return out, nil +} + +// AwsSqsQueueFromSDK converts the sdk-go type to the mirror. +func AwsSqsQueueFromSDK(v *sdk.AwsSqsQueue) (*AwsSqsQueue, error) { + if v == nil { + return nil, nil + } + out := &AwsSqsQueue{} + out.QueueUrl = v.QueueUrl + out.ManagedResourceId = v.ManagedResourceId + return out, nil +} + +// AzureQueueStorageToSDK converts the mirror to the sdk-go type. +func AzureQueueStorageToSDK(w *AzureQueueStorage) (*sdk.AzureQueueStorage, error) { + if w == nil { + return nil, nil + } + out := &sdk.AzureQueueStorage{} + out.QueueUrl = w.QueueUrl + out.SubscriptionId = w.SubscriptionId + out.ResourceGroup = w.ResourceGroup + out.ManagedResourceId = w.ManagedResourceId + return out, nil +} + +// AzureQueueStorageFromSDK converts the sdk-go type to the mirror. +func AzureQueueStorageFromSDK(v *sdk.AzureQueueStorage) (*AzureQueueStorage, error) { + if v == nil { + return nil, nil + } + out := &AzureQueueStorage{} + out.QueueUrl = v.QueueUrl + out.SubscriptionId = v.SubscriptionId + out.ResourceGroup = v.ResourceGroup + out.ManagedResourceId = v.ManagedResourceId + return out, nil +} + +// CreateExternalLocationRequestToSDK converts the mirror to the sdk-go type. +func CreateExternalLocationRequestToSDK(w *CreateExternalLocationRequest) (*sdk.CreateExternalLocationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateExternalLocationRequest{} + out.SkipValidation = w.SkipValidation + out.Name = w.Name + out.Url = w.Url + out.CredentialName = w.CredentialName + out.ReadOnly = w.ReadOnly + out.Comment = w.Comment + out.EnableFileEvents = w.EnableFileEvents + conv1, err := FileEventQueueToSDK(w.FileEventQueue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExternalLocationRequest.FileEventQueue", err) + } + out.FileEventQueue = conv1 + out.Owner = w.Owner + conv2, err := EncryptionDetailsToSDK(w.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExternalLocationRequest.EncryptionDetails", err) + } + out.EncryptionDetails = conv2 + out.MetastoreId = w.MetastoreId + out.CredentialId = w.CredentialId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.BrowseOnly = w.BrowseOnly + out.IsolationMode = w.IsolationMode + out.Fallback = w.Fallback + out.EffectiveEnableFileEvents = w.EffectiveEnableFileEvents + conv3, err := FileEventQueueToSDK(w.EffectiveFileEventQueue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExternalLocationRequest.EffectiveFileEventQueue", err) + } + out.EffectiveFileEventQueue = conv3 + return out, nil +} + +// CreateExternalLocationRequestFromSDK converts the sdk-go type to the mirror. +func CreateExternalLocationRequestFromSDK(v *sdk.CreateExternalLocationRequest) (*CreateExternalLocationRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateExternalLocationRequest{} + out.SkipValidation = v.SkipValidation + out.Name = v.Name + out.Url = v.Url + out.CredentialName = v.CredentialName + out.ReadOnly = v.ReadOnly + out.Comment = v.Comment + out.EnableFileEvents = v.EnableFileEvents + conv4, err := FileEventQueueFromSDK(v.FileEventQueue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExternalLocationRequest.FileEventQueue", err) + } + out.FileEventQueue = conv4 + out.Owner = v.Owner + conv5, err := EncryptionDetailsFromSDK(v.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExternalLocationRequest.EncryptionDetails", err) + } + out.EncryptionDetails = conv5 + out.MetastoreId = v.MetastoreId + out.CredentialId = v.CredentialId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.BrowseOnly = v.BrowseOnly + out.IsolationMode = v.IsolationMode + out.Fallback = v.Fallback + out.EffectiveEnableFileEvents = v.EffectiveEnableFileEvents + conv6, err := FileEventQueueFromSDK(v.EffectiveFileEventQueue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExternalLocationRequest.EffectiveFileEventQueue", err) + } + out.EffectiveFileEventQueue = conv6 + return out, nil +} + +// DeleteExternalLocationRequestToSDK converts the mirror to the sdk-go type. +func DeleteExternalLocationRequestToSDK(w *DeleteExternalLocationRequest) (*sdk.DeleteExternalLocationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteExternalLocationRequest{} + out.NameArg = w.NameArg + out.Force = w.Force + return out, nil +} + +// DeleteExternalLocationRequestFromSDK converts the sdk-go type to the mirror. +func DeleteExternalLocationRequestFromSDK(v *sdk.DeleteExternalLocationRequest) (*DeleteExternalLocationRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteExternalLocationRequest{} + out.NameArg = v.NameArg + out.Force = v.Force + return out, nil +} + +// EncryptionDetailsToSDK converts the mirror to the sdk-go type. +func EncryptionDetailsToSDK(w *EncryptionDetails) (*sdk.EncryptionDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.EncryptionDetails{} + { + var members []string + if w.SseEncryptionDetails != nil { + members = append(members, "sse_encryption_details") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.SseEncryptionDetails != nil: + conv7, err := SseEncryptionDetailsToSDK(w.SseEncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EncryptionDetails.EncryptionDetailsType", err) + } + out.EncryptionDetailsType = &sdk.EncryptionDetails_EncryptionDetailsType_SseEncryptionDetails{SseEncryptionDetails: *conv7} + } + return out, nil +} + +// EncryptionDetailsFromSDK converts the sdk-go type to the mirror. +func EncryptionDetailsFromSDK(v *sdk.EncryptionDetails) (*EncryptionDetails, error) { + if v == nil { + return nil, nil + } + out := &EncryptionDetails{} + switch value := v.EncryptionDetailsType.(type) { + case *sdk.EncryptionDetails_EncryptionDetailsType_SseEncryptionDetails: + if value != nil { + conv8, err := SseEncryptionDetailsFromSDK(&value.SseEncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EncryptionDetails.EncryptionDetailsType", err) + } + out.SseEncryptionDetails = conv8 + } + } + return out, nil +} + +// ExternalLocationInfoToSDK converts the mirror to the sdk-go type. +func ExternalLocationInfoToSDK(w *ExternalLocationInfo) (*sdk.ExternalLocationInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalLocationInfo{} + out.Name = w.Name + out.Url = w.Url + out.CredentialName = w.CredentialName + out.ReadOnly = w.ReadOnly + out.Comment = w.Comment + out.EnableFileEvents = w.EnableFileEvents + conv9, err := FileEventQueueToSDK(w.FileEventQueue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLocationInfo.FileEventQueue", err) + } + out.FileEventQueue = conv9 + out.Owner = w.Owner + conv10, err := EncryptionDetailsToSDK(w.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLocationInfo.EncryptionDetails", err) + } + out.EncryptionDetails = conv10 + out.MetastoreId = w.MetastoreId + out.CredentialId = w.CredentialId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.BrowseOnly = w.BrowseOnly + out.IsolationMode = w.IsolationMode + out.Fallback = w.Fallback + out.EffectiveEnableFileEvents = w.EffectiveEnableFileEvents + conv11, err := FileEventQueueToSDK(w.EffectiveFileEventQueue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLocationInfo.EffectiveFileEventQueue", err) + } + out.EffectiveFileEventQueue = conv11 + return out, nil +} + +// ExternalLocationInfoFromSDK converts the sdk-go type to the mirror. +func ExternalLocationInfoFromSDK(v *sdk.ExternalLocationInfo) (*ExternalLocationInfo, error) { + if v == nil { + return nil, nil + } + out := &ExternalLocationInfo{} + out.Name = v.Name + out.Url = v.Url + out.CredentialName = v.CredentialName + out.ReadOnly = v.ReadOnly + out.Comment = v.Comment + out.EnableFileEvents = v.EnableFileEvents + conv12, err := FileEventQueueFromSDK(v.FileEventQueue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLocationInfo.FileEventQueue", err) + } + out.FileEventQueue = conv12 + out.Owner = v.Owner + conv13, err := EncryptionDetailsFromSDK(v.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLocationInfo.EncryptionDetails", err) + } + out.EncryptionDetails = conv13 + out.MetastoreId = v.MetastoreId + out.CredentialId = v.CredentialId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.BrowseOnly = v.BrowseOnly + out.IsolationMode = v.IsolationMode + out.Fallback = v.Fallback + out.EffectiveEnableFileEvents = v.EffectiveEnableFileEvents + conv14, err := FileEventQueueFromSDK(v.EffectiveFileEventQueue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ExternalLocationInfo.EffectiveFileEventQueue", err) + } + out.EffectiveFileEventQueue = conv14 + return out, nil +} + +// FileEventQueueToSDK converts the mirror to the sdk-go type. +func FileEventQueueToSDK(w *FileEventQueue) (*sdk.FileEventQueue, error) { + if w == nil { + return nil, nil + } + out := &sdk.FileEventQueue{} + { + var members []string + if w.ProvidedAqs != nil { + members = append(members, "provided_aqs") + } + if w.ProvidedSqs != nil { + members = append(members, "provided_sqs") + } + if w.ProvidedPubsub != nil { + members = append(members, "provided_pubsub") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ProvidedAqs != nil: + conv15, err := AzureQueueStorageToSDK(w.ProvidedAqs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileEventQueue.Provided", err) + } + out.Provided = &sdk.FileEventQueue_Provided_ProvidedAqs{ProvidedAqs: *conv15} + case w.ProvidedSqs != nil: + conv16, err := AwsSqsQueueToSDK(w.ProvidedSqs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileEventQueue.Provided", err) + } + out.Provided = &sdk.FileEventQueue_Provided_ProvidedSqs{ProvidedSqs: *conv16} + case w.ProvidedPubsub != nil: + conv17, err := GcpPubsubToSDK(w.ProvidedPubsub) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileEventQueue.Provided", err) + } + out.Provided = &sdk.FileEventQueue_Provided_ProvidedPubsub{ProvidedPubsub: *conv17} + } + { + var members []string + if w.ManagedAqs != nil { + members = append(members, "managed_aqs") + } + if w.ManagedSqs != nil { + members = append(members, "managed_sqs") + } + if w.ManagedPubsub != nil { + members = append(members, "managed_pubsub") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ManagedAqs != nil: + conv18, err := AzureQueueStorageToSDK(w.ManagedAqs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileEventQueue.Managed", err) + } + out.Managed = &sdk.FileEventQueue_Managed_ManagedAqs{ManagedAqs: *conv18} + case w.ManagedSqs != nil: + conv19, err := AwsSqsQueueToSDK(w.ManagedSqs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileEventQueue.Managed", err) + } + out.Managed = &sdk.FileEventQueue_Managed_ManagedSqs{ManagedSqs: *conv19} + case w.ManagedPubsub != nil: + conv20, err := GcpPubsubToSDK(w.ManagedPubsub) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileEventQueue.Managed", err) + } + out.Managed = &sdk.FileEventQueue_Managed_ManagedPubsub{ManagedPubsub: *conv20} + } + return out, nil +} + +// FileEventQueueFromSDK converts the sdk-go type to the mirror. +func FileEventQueueFromSDK(v *sdk.FileEventQueue) (*FileEventQueue, error) { + if v == nil { + return nil, nil + } + out := &FileEventQueue{} + switch value := v.Provided.(type) { + case *sdk.FileEventQueue_Provided_ProvidedAqs: + if value != nil { + conv21, err := AzureQueueStorageFromSDK(&value.ProvidedAqs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileEventQueue.Provided", err) + } + out.ProvidedAqs = conv21 + } + case *sdk.FileEventQueue_Provided_ProvidedSqs: + if value != nil { + conv22, err := AwsSqsQueueFromSDK(&value.ProvidedSqs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileEventQueue.Provided", err) + } + out.ProvidedSqs = conv22 + } + case *sdk.FileEventQueue_Provided_ProvidedPubsub: + if value != nil { + conv23, err := GcpPubsubFromSDK(&value.ProvidedPubsub) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileEventQueue.Provided", err) + } + out.ProvidedPubsub = conv23 + } + } + switch value := v.Managed.(type) { + case *sdk.FileEventQueue_Managed_ManagedAqs: + if value != nil { + conv24, err := AzureQueueStorageFromSDK(&value.ManagedAqs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileEventQueue.Managed", err) + } + out.ManagedAqs = conv24 + } + case *sdk.FileEventQueue_Managed_ManagedSqs: + if value != nil { + conv25, err := AwsSqsQueueFromSDK(&value.ManagedSqs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileEventQueue.Managed", err) + } + out.ManagedSqs = conv25 + } + case *sdk.FileEventQueue_Managed_ManagedPubsub: + if value != nil { + conv26, err := GcpPubsubFromSDK(&value.ManagedPubsub) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FileEventQueue.Managed", err) + } + out.ManagedPubsub = conv26 + } + } + return out, nil +} + +// GcpPubsubToSDK converts the mirror to the sdk-go type. +func GcpPubsubToSDK(w *GcpPubsub) (*sdk.GcpPubsub, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpPubsub{} + out.SubscriptionName = w.SubscriptionName + out.ManagedResourceId = w.ManagedResourceId + return out, nil +} + +// GcpPubsubFromSDK converts the sdk-go type to the mirror. +func GcpPubsubFromSDK(v *sdk.GcpPubsub) (*GcpPubsub, error) { + if v == nil { + return nil, nil + } + out := &GcpPubsub{} + out.SubscriptionName = v.SubscriptionName + out.ManagedResourceId = v.ManagedResourceId + return out, nil +} + +// GetExternalLocationRequestToSDK converts the mirror to the sdk-go type. +func GetExternalLocationRequestToSDK(w *GetExternalLocationRequest) (*sdk.GetExternalLocationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetExternalLocationRequest{} + out.NameArg = w.NameArg + out.IncludeBrowse = w.IncludeBrowse + return out, nil +} + +// GetExternalLocationRequestFromSDK converts the sdk-go type to the mirror. +func GetExternalLocationRequestFromSDK(v *sdk.GetExternalLocationRequest) (*GetExternalLocationRequest, error) { + if v == nil { + return nil, nil + } + out := &GetExternalLocationRequest{} + out.NameArg = v.NameArg + out.IncludeBrowse = v.IncludeBrowse + return out, nil +} + +// ListExternalLocationsRequestToSDK converts the mirror to the sdk-go type. +func ListExternalLocationsRequestToSDK(w *ListExternalLocationsRequest) (*sdk.ListExternalLocationsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExternalLocationsRequest{} + out.IncludeBrowse = w.IncludeBrowse + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + out.IncludeUnbound = w.IncludeUnbound + return out, nil +} + +// ListExternalLocationsRequestFromSDK converts the sdk-go type to the mirror. +func ListExternalLocationsRequestFromSDK(v *sdk.ListExternalLocationsRequest) (*ListExternalLocationsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListExternalLocationsRequest{} + out.IncludeBrowse = v.IncludeBrowse + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + out.IncludeUnbound = v.IncludeUnbound + return out, nil +} + +// ListExternalLocationsResponseToSDK converts the mirror to the sdk-go type. +func ListExternalLocationsResponseToSDK(w *ListExternalLocationsResponse) (*sdk.ListExternalLocationsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExternalLocationsResponse{} + conv27, err := convertSlice(w.ExternalLocations, ExternalLocationInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExternalLocationsResponse.ExternalLocations", err) + } + out.ExternalLocations = conv27 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListExternalLocationsResponseFromSDK converts the sdk-go type to the mirror. +func ListExternalLocationsResponseFromSDK(v *sdk.ListExternalLocationsResponse) (*ListExternalLocationsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListExternalLocationsResponse{} + conv28, err := convertSlice(v.ExternalLocations, ExternalLocationInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExternalLocationsResponse.ExternalLocations", err) + } + out.ExternalLocations = conv28 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SseEncryptionDetailsToSDK converts the mirror to the sdk-go type. +func SseEncryptionDetailsToSDK(w *SseEncryptionDetails) (*sdk.SseEncryptionDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.SseEncryptionDetails{} + out.Algorithm = w.Algorithm + out.AwsKmsKeyArn = w.AwsKmsKeyArn + return out, nil +} + +// SseEncryptionDetailsFromSDK converts the sdk-go type to the mirror. +func SseEncryptionDetailsFromSDK(v *sdk.SseEncryptionDetails) (*SseEncryptionDetails, error) { + if v == nil { + return nil, nil + } + out := &SseEncryptionDetails{} + out.Algorithm = v.Algorithm + out.AwsKmsKeyArn = v.AwsKmsKeyArn + return out, nil +} + +// UpdateExternalLocationRequestToSDK converts the mirror to the sdk-go type. +func UpdateExternalLocationRequestToSDK(w *UpdateExternalLocationRequest) (*sdk.UpdateExternalLocationRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateExternalLocationRequest{} + out.NameArg = w.NameArg + out.NewName = w.NewName + out.Force = w.Force + out.SkipValidation = w.SkipValidation + out.Name = w.Name + out.Url = w.Url + out.CredentialName = w.CredentialName + out.ReadOnly = w.ReadOnly + out.Comment = w.Comment + out.EnableFileEvents = w.EnableFileEvents + conv29, err := FileEventQueueToSDK(w.FileEventQueue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExternalLocationRequest.FileEventQueue", err) + } + out.FileEventQueue = conv29 + out.Owner = w.Owner + conv30, err := EncryptionDetailsToSDK(w.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExternalLocationRequest.EncryptionDetails", err) + } + out.EncryptionDetails = conv30 + out.MetastoreId = w.MetastoreId + out.CredentialId = w.CredentialId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.BrowseOnly = w.BrowseOnly + out.IsolationMode = w.IsolationMode + out.Fallback = w.Fallback + out.EffectiveEnableFileEvents = w.EffectiveEnableFileEvents + conv31, err := FileEventQueueToSDK(w.EffectiveFileEventQueue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExternalLocationRequest.EffectiveFileEventQueue", err) + } + out.EffectiveFileEventQueue = conv31 + return out, nil +} + +// UpdateExternalLocationRequestFromSDK converts the sdk-go type to the mirror. +func UpdateExternalLocationRequestFromSDK(v *sdk.UpdateExternalLocationRequest) (*UpdateExternalLocationRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateExternalLocationRequest{} + out.NameArg = v.NameArg + out.NewName = v.NewName + out.Force = v.Force + out.SkipValidation = v.SkipValidation + out.Name = v.Name + out.Url = v.Url + out.CredentialName = v.CredentialName + out.ReadOnly = v.ReadOnly + out.Comment = v.Comment + out.EnableFileEvents = v.EnableFileEvents + conv32, err := FileEventQueueFromSDK(v.FileEventQueue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExternalLocationRequest.FileEventQueue", err) + } + out.FileEventQueue = conv32 + out.Owner = v.Owner + conv33, err := EncryptionDetailsFromSDK(v.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExternalLocationRequest.EncryptionDetails", err) + } + out.EncryptionDetails = conv33 + out.MetastoreId = v.MetastoreId + out.CredentialId = v.CredentialId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.BrowseOnly = v.BrowseOnly + out.IsolationMode = v.IsolationMode + out.Fallback = v.Fallback + out.EffectiveEnableFileEvents = v.EffectiveEnableFileEvents + conv34, err := FileEventQueueFromSDK(v.EffectiveFileEventQueue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExternalLocationRequest.EffectiveFileEventQueue", err) + } + out.EffectiveFileEventQueue = conv34 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/externalmetadata/v1/types.generated.go b/libs/sdktypes/uc/externalmetadata/v1/types.generated.go new file mode 100644 index 00000000000..a723ae5a75a --- /dev/null +++ b/libs/sdktypes/uc/externalmetadata/v1/types.generated.go @@ -0,0 +1,288 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/externalmetadata/v1. DO NOT EDIT. + +package externalmetadata + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/uc/externalmetadata/v1" + strings "strings" +) + +type ( + SystemType = sdk.SystemType +) + +const ( + SystemType_Unspecified = sdk.SystemType_Unspecified + SystemType_Other = sdk.SystemType_Other + SystemType_Tableau = sdk.SystemType_Tableau + SystemType_PowerBi = sdk.SystemType_PowerBi + SystemType_Looker = sdk.SystemType_Looker + SystemType_Kafka = sdk.SystemType_Kafka + SystemType_Sap = sdk.SystemType_Sap + SystemType_Oracle = sdk.SystemType_Oracle + SystemType_Salesforce = sdk.SystemType_Salesforce + SystemType_Workday = sdk.SystemType_Workday + SystemType_Mysql = sdk.SystemType_Mysql + SystemType_Postgresql = sdk.SystemType_Postgresql + SystemType_MicrosoftSqlServer = sdk.SystemType_MicrosoftSqlServer + SystemType_Servicenow = sdk.SystemType_Servicenow + SystemType_AmazonRedshift = sdk.SystemType_AmazonRedshift + SystemType_AzureSynapse = sdk.SystemType_AzureSynapse + SystemType_Snowflake = sdk.SystemType_Snowflake + SystemType_GoogleBigquery = sdk.SystemType_GoogleBigquery + SystemType_MicrosoftFabric = sdk.SystemType_MicrosoftFabric + SystemType_Mongodb = sdk.SystemType_Mongodb + SystemType_Teradata = sdk.SystemType_Teradata + SystemType_Confluent = sdk.SystemType_Confluent + SystemType_Databricks = sdk.SystemType_Databricks + SystemType_StreamNative = sdk.SystemType_StreamNative +) + +type CreateExternalMetadataRequest struct { + ExternalMetadata *ExternalMetadata `json:"external_metadata,omitempty"` +} + +type ExternalMetadata struct { + // List of columns associated with the external metadata object. + Columns []string `json:"columns,omitempty"` + // Time at which this external metadata object was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // Username of external metadata object creator. + CreatedBy *string `json:"created_by,omitempty"` + // User-provided free-form text description. + Description *string `json:"description,omitempty"` + // Type of entity within the external system. + EntityType *string `json:"entity_type,omitempty"` + // Unique identifier of the external metadata object. + Id *string `json:"id,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of the external metadata object. + Name *string `json:"name,omitempty"` + // Owner of the external metadata object. + Owner *string `json:"owner,omitempty"` + // A map of key-value properties attached to the external metadata object. + Properties map[string]string `json:"properties,omitempty"` + // Type of external system. + SystemType SystemType `json:"system_type,omitempty"` + // Time at which this external metadata object was last modified. + UpdateTime *types.Time `json:"update_time,omitempty"` + // Username of user who last modified external metadata object. + UpdatedBy *string `json:"updated_by,omitempty"` + // URL associated with the external metadata object. + Url *string `json:"url,omitempty"` +} + +type ListExternalMetadataRequest struct { + // Specifies the maximum number of external metadata objects to return in a + // single response. The value must be less than or equal to 1000. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListExternalMetadataResponseV2 struct { + ExternalMetadata []ExternalMetadata `json:"external_metadata,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type UpdateExternalMetadataRequest struct { + ExternalMetadata *ExternalMetadata `json:"external_metadata,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CreateExternalMetadataRequestToSDK converts the mirror to the sdk-go type. +func CreateExternalMetadataRequestToSDK(w *CreateExternalMetadataRequest) (*sdk.CreateExternalMetadataRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateExternalMetadataRequest{} + conv1, err := ExternalMetadataToSDK(w.ExternalMetadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExternalMetadataRequest.ExternalMetadata", err) + } + out.ExternalMetadata = conv1 + return out, nil +} + +// CreateExternalMetadataRequestFromSDK converts the sdk-go type to the mirror. +func CreateExternalMetadataRequestFromSDK(v *sdk.CreateExternalMetadataRequest) (*CreateExternalMetadataRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateExternalMetadataRequest{} + conv2, err := ExternalMetadataFromSDK(v.ExternalMetadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateExternalMetadataRequest.ExternalMetadata", err) + } + out.ExternalMetadata = conv2 + return out, nil +} + +// ExternalMetadataToSDK converts the mirror to the sdk-go type. +func ExternalMetadataToSDK(w *ExternalMetadata) (*sdk.ExternalMetadata, error) { + if w == nil { + return nil, nil + } + out := &sdk.ExternalMetadata{} + out.Name = w.Name + out.SystemType = w.SystemType + out.EntityType = w.EntityType + out.Url = w.Url + out.Description = w.Description + out.Columns = w.Columns + out.Properties = w.Properties + out.Owner = w.Owner + out.MetastoreId = w.MetastoreId + out.CreateTime = w.CreateTime + out.CreatedBy = w.CreatedBy + out.UpdateTime = w.UpdateTime + out.UpdatedBy = w.UpdatedBy + out.Id = w.Id + return out, nil +} + +// ExternalMetadataFromSDK converts the sdk-go type to the mirror. +func ExternalMetadataFromSDK(v *sdk.ExternalMetadata) (*ExternalMetadata, error) { + if v == nil { + return nil, nil + } + out := &ExternalMetadata{} + out.Name = v.Name + out.SystemType = v.SystemType + out.EntityType = v.EntityType + out.Url = v.Url + out.Description = v.Description + out.Columns = v.Columns + out.Properties = v.Properties + out.Owner = v.Owner + out.MetastoreId = v.MetastoreId + out.CreateTime = v.CreateTime + out.CreatedBy = v.CreatedBy + out.UpdateTime = v.UpdateTime + out.UpdatedBy = v.UpdatedBy + out.Id = v.Id + return out, nil +} + +// ListExternalMetadataRequestToSDK converts the mirror to the sdk-go type. +func ListExternalMetadataRequestToSDK(w *ListExternalMetadataRequest) (*sdk.ListExternalMetadataRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExternalMetadataRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListExternalMetadataRequestFromSDK converts the sdk-go type to the mirror. +func ListExternalMetadataRequestFromSDK(v *sdk.ListExternalMetadataRequest) (*ListExternalMetadataRequest, error) { + if v == nil { + return nil, nil + } + out := &ListExternalMetadataRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListExternalMetadataResponseV2ToSDK converts the mirror to the sdk-go type. +func ListExternalMetadataResponseV2ToSDK(w *ListExternalMetadataResponseV2) (*sdk.ListExternalMetadataResponseV2, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListExternalMetadataResponseV2{} + conv3, err := convertSlice(w.ExternalMetadata, ExternalMetadataToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExternalMetadataResponseV2.ExternalMetadata", err) + } + out.ExternalMetadata = conv3 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListExternalMetadataResponseV2FromSDK converts the sdk-go type to the mirror. +func ListExternalMetadataResponseV2FromSDK(v *sdk.ListExternalMetadataResponseV2) (*ListExternalMetadataResponseV2, error) { + if v == nil { + return nil, nil + } + out := &ListExternalMetadataResponseV2{} + conv4, err := convertSlice(v.ExternalMetadata, ExternalMetadataFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListExternalMetadataResponseV2.ExternalMetadata", err) + } + out.ExternalMetadata = conv4 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// UpdateExternalMetadataRequestToSDK converts the mirror to the sdk-go type. +func UpdateExternalMetadataRequestToSDK(w *UpdateExternalMetadataRequest) (*sdk.UpdateExternalMetadataRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateExternalMetadataRequest{} + conv5, err := ExternalMetadataToSDK(w.ExternalMetadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExternalMetadataRequest.ExternalMetadata", err) + } + out.ExternalMetadata = conv5 + mask6, err := fieldMaskFromString[sdk.ExternalMetadata](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExternalMetadataRequest.UpdateMask", err) + } + out.UpdateMask = mask6 + return out, nil +} + +// UpdateExternalMetadataRequestFromSDK converts the sdk-go type to the mirror. +func UpdateExternalMetadataRequestFromSDK(v *sdk.UpdateExternalMetadataRequest) (*UpdateExternalMetadataRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateExternalMetadataRequest{} + conv7, err := ExternalMetadataFromSDK(v.ExternalMetadata) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateExternalMetadataRequest.ExternalMetadata", err) + } + out.ExternalMetadata = conv7 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/uc/functions/v1/types.generated.go b/libs/sdktypes/uc/functions/v1/types.generated.go new file mode 100644 index 00000000000..49d5ecf7810 --- /dev/null +++ b/libs/sdktypes/uc/functions/v1/types.generated.go @@ -0,0 +1,1127 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/functions/v1. DO NOT EDIT. + +package functions + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/functions/v1" + + strings "strings" +) + +type ( + ColumnTypeName = sdk.ColumnTypeName + FunctionParameterMode = sdk.FunctionParameterMode + FunctionParameterType = sdk.FunctionParameterType + FunctionInfo_ParameterStyle = sdk.FunctionInfo_ParameterStyle + FunctionInfo_RoutineBody = sdk.FunctionInfo_RoutineBody + FunctionInfo_SecurityType = sdk.FunctionInfo_SecurityType + FunctionInfo_SqlDataAccess = sdk.FunctionInfo_SqlDataAccess +) + +const ( + ColumnTypeName_Unspecified = sdk.ColumnTypeName_Unspecified + ColumnTypeName_Boolean = sdk.ColumnTypeName_Boolean + ColumnTypeName_Byte = sdk.ColumnTypeName_Byte + ColumnTypeName_Short = sdk.ColumnTypeName_Short + ColumnTypeName_Int = sdk.ColumnTypeName_Int + ColumnTypeName_Long = sdk.ColumnTypeName_Long + ColumnTypeName_Float = sdk.ColumnTypeName_Float + ColumnTypeName_Double = sdk.ColumnTypeName_Double + ColumnTypeName_Date = sdk.ColumnTypeName_Date + ColumnTypeName_Timestamp = sdk.ColumnTypeName_Timestamp + ColumnTypeName_String = sdk.ColumnTypeName_String + ColumnTypeName_Binary = sdk.ColumnTypeName_Binary + ColumnTypeName_Decimal = sdk.ColumnTypeName_Decimal + ColumnTypeName_Interval = sdk.ColumnTypeName_Interval + ColumnTypeName_Array = sdk.ColumnTypeName_Array + ColumnTypeName_Struct = sdk.ColumnTypeName_Struct + ColumnTypeName_Map = sdk.ColumnTypeName_Map + ColumnTypeName_Char = sdk.ColumnTypeName_Char + ColumnTypeName_Null = sdk.ColumnTypeName_Null + ColumnTypeName_UserDefinedType = sdk.ColumnTypeName_UserDefinedType + ColumnTypeName_TimestampNtz = sdk.ColumnTypeName_TimestampNtz + ColumnTypeName_Variant = sdk.ColumnTypeName_Variant + ColumnTypeName_Geometry = sdk.ColumnTypeName_Geometry + ColumnTypeName_Geography = sdk.ColumnTypeName_Geography + ColumnTypeName_TableType = sdk.ColumnTypeName_TableType + FunctionParameterMode_Unspecified = sdk.FunctionParameterMode_Unspecified + FunctionParameterMode_In = sdk.FunctionParameterMode_In + FunctionParameterType_Unspecified = sdk.FunctionParameterType_Unspecified + FunctionParameterType_Param = sdk.FunctionParameterType_Param + FunctionParameterType_Column = sdk.FunctionParameterType_Column + FunctionInfo_ParameterStyle_Unspecified = sdk.FunctionInfo_ParameterStyle_Unspecified + FunctionInfo_ParameterStyle_S = sdk.FunctionInfo_ParameterStyle_S + FunctionInfo_RoutineBody_Unspecified = sdk.FunctionInfo_RoutineBody_Unspecified + FunctionInfo_RoutineBody_Sql = sdk.FunctionInfo_RoutineBody_Sql + FunctionInfo_RoutineBody_External = sdk.FunctionInfo_RoutineBody_External + FunctionInfo_SecurityType_Unspecified = sdk.FunctionInfo_SecurityType_Unspecified + FunctionInfo_SecurityType_Definer = sdk.FunctionInfo_SecurityType_Definer + FunctionInfo_SqlDataAccess_Unspecified = sdk.FunctionInfo_SqlDataAccess_Unspecified + FunctionInfo_SqlDataAccess_ContainsSql = sdk.FunctionInfo_SqlDataAccess_ContainsSql + FunctionInfo_SqlDataAccess_ReadsSqlData = sdk.FunctionInfo_SqlDataAccess_ReadsSqlData + FunctionInfo_SqlDataAccess_NoSql = sdk.FunctionInfo_SqlDataAccess_NoSql +) + +// A connection that is dependent on a SQL object.. +type ConnectionDependency struct { + // Full name of the dependent connection, in the form of __connection_name__. + ConnectionName *string `json:"connection_name,omitempty"` +} + +type CreateFunction struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // Name of parent Catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this function was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of function creator. + CreatedBy *string `json:"created_by,omitempty"` + // Scalar function return data type. + DataType ColumnTypeName `json:"data_type,omitempty"` + // External function language. + ExternalLanguage *string `json:"external_language,omitempty"` + // External function name. + ExternalName *string `json:"external_name,omitempty"` + // Pretty printed function data type. + FullDataType *string `json:"full_data_type,omitempty"` + // Full name of Function, in form of + // **catalog_name**.**schema_name**.**function_name** + FullName *string `json:"full_name,omitempty"` + // Id of Function, relative to parent schema. + FunctionId *string `json:"function_id,omitempty"` + // Function input parameters. + InputParams *FunctionParameterInfos `json:"input_params,omitempty"` + // Whether the function is deterministic. + IsDeterministic *bool `json:"is_deterministic,omitempty"` + // Function null call. + IsNullCall *bool `json:"is_null_call,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of function, relative to parent schema. + Name *string `json:"name,omitempty"` + // Username of current owner of the function. + Owner *string `json:"owner,omitempty"` + // Function parameter style. **S** is the value for SQL. + ParameterStyle FunctionInfo_ParameterStyle `json:"parameter_style,omitempty"` + // JSON-serialized key-value pair map, encoded (escaped) as a string. + Properties *string `json:"properties,omitempty"` + // Table function return parameters. + ReturnParams *FunctionParameterInfos `json:"return_params,omitempty"` + // Function language. When **EXTERNAL** is used, the language of the routine + // function should be specified in the **external_language** field, and the + // **return_params** of the function cannot be used (as **TABLE** return type is + // not supported), and the **sql_data_access** field must be **NO_SQL**. + RoutineBody FunctionInfo_RoutineBody `json:"routine_body,omitempty"` + // Function body. + RoutineDefinition *string `json:"routine_definition,omitempty"` + // Function dependencies. For external UDFs, dependencies may contain only + // credential, secret, or volume objects. + RoutineDependencies *DependencyList `json:"routine_dependencies,omitempty"` + // Name of parent Schema relative to its parent Catalog. + SchemaName *string `json:"schema_name,omitempty"` + // Function security type. + SecurityType FunctionInfo_SecurityType `json:"security_type,omitempty"` + // Specific name of the function; Reserved for future use. + SpecificName *string `json:"specific_name,omitempty"` + // Function SQL data access. + SqlDataAccess FunctionInfo_SqlDataAccess `json:"sql_data_access,omitempty"` + // List of schemes whose objects can be referenced without qualification. + SqlPath *string `json:"sql_path,omitempty"` + // Time at which this function was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the function. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type CreateFunctionRequest struct { + // Partial __FunctionInfo__ specifying the function to be created. + FunctionInfo *CreateFunction `json:"function_info,omitempty"` +} + +// A credential that is dependent on a SQL object.. +type CredentialDependency struct { + // Full name of the dependent credential, in the form of __credential_name__. + CredentialName *string `json:"credential_name,omitempty"` +} + +type DeleteFunctionRequest struct { + // Force deletion even if the function is notempty. + Force *bool `json:"force,omitempty"` + // The fully-qualified name of the function (of the form + // __catalog_name__.__schema_name__.__function__name__) . + FullNameArg *string `json:"full_name_arg,omitempty"` +} + +// A dependency of a SQL object. One of the following fields must be defined: +// __table__, __function__, __connection__, __credential__, __volume__, or +// __secret__.. +type Dependency struct { + Connection *ConnectionDependency `json:"connection,omitempty"` + Credential *CredentialDependency `json:"credential,omitempty"` + Function *FunctionDependency `json:"function,omitempty"` + Table *TableDependency `json:"table,omitempty"` +} + +// A list of dependencies.. +type DependencyList struct { + // Array of dependencies. + Dependencies []Dependency `json:"dependencies,omitempty"` +} + +// A function that is dependent on a SQL object.. +type FunctionDependency struct { + // Full name of the dependent function, in the form of + // __catalog_name__.__schema_name__.__function_name__. + FunctionFullName *string `json:"function_full_name,omitempty"` +} + +type FunctionInfo struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // Name of parent Catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this function was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of function creator. + CreatedBy *string `json:"created_by,omitempty"` + // Scalar function return data type. + DataType ColumnTypeName `json:"data_type,omitempty"` + // External function language. + ExternalLanguage *string `json:"external_language,omitempty"` + // External function name. + ExternalName *string `json:"external_name,omitempty"` + // Pretty printed function data type. + FullDataType *string `json:"full_data_type,omitempty"` + // Full name of Function, in form of + // **catalog_name**.**schema_name**.**function_name** + FullName *string `json:"full_name,omitempty"` + // Id of Function, relative to parent schema. + FunctionId *string `json:"function_id,omitempty"` + // Function input parameters. + InputParams *FunctionParameterInfos `json:"input_params,omitempty"` + // Whether the function is deterministic. + IsDeterministic *bool `json:"is_deterministic,omitempty"` + // Function null call. + IsNullCall *bool `json:"is_null_call,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of function, relative to parent schema. + Name *string `json:"name,omitempty"` + // Username of current owner of the function. + Owner *string `json:"owner,omitempty"` + // Function parameter style. **S** is the value for SQL. + ParameterStyle FunctionInfo_ParameterStyle `json:"parameter_style,omitempty"` + // JSON-serialized key-value pair map, encoded (escaped) as a string. + Properties *string `json:"properties,omitempty"` + // Table function return parameters. + ReturnParams *FunctionParameterInfos `json:"return_params,omitempty"` + // Function language. When **EXTERNAL** is used, the language of the routine + // function should be specified in the **external_language** field, and the + // **return_params** of the function cannot be used (as **TABLE** return type is + // not supported), and the **sql_data_access** field must be **NO_SQL**. + RoutineBody FunctionInfo_RoutineBody `json:"routine_body,omitempty"` + // Function body. + RoutineDefinition *string `json:"routine_definition,omitempty"` + // Function dependencies. For external UDFs, dependencies may contain only + // credential, secret, or volume objects. + RoutineDependencies *DependencyList `json:"routine_dependencies,omitempty"` + // Name of parent Schema relative to its parent Catalog. + SchemaName *string `json:"schema_name,omitempty"` + // Function security type. + SecurityType FunctionInfo_SecurityType `json:"security_type,omitempty"` + // Specific name of the function; Reserved for future use. + SpecificName *string `json:"specific_name,omitempty"` + // Function SQL data access. + SqlDataAccess FunctionInfo_SqlDataAccess `json:"sql_data_access,omitempty"` + // List of schemes whose objects can be referenced without qualification. + SqlPath *string `json:"sql_path,omitempty"` + // Time at which this function was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the function. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type FunctionParameterInfo struct { + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Name of Parameter. + Name *string `json:"name,omitempty"` + // Default value of the parameter. + ParameterDefault *string `json:"parameter_default,omitempty"` + // Function parameter mode. + ParameterMode FunctionParameterMode `json:"parameter_mode,omitempty"` + // Function parameter type. + ParameterType FunctionParameterType `json:"parameter_type,omitempty"` + // Ordinal position of column (starting at position 0). + Position *int `json:"position,omitempty"` + // Format of IntervalType. + TypeIntervalType *string `json:"type_interval_type,omitempty"` + // Full data type spec, JSON-serialized. + TypeJson *string `json:"type_json,omitempty"` + // Name of type (INT, STRUCT, MAP, etc.) + TypeName ColumnTypeName `json:"type_name,omitempty"` + // Digits of precision; required on Create for DecimalTypes. + TypePrecision *int `json:"type_precision,omitempty"` + // Digits to right of decimal; Required on Create for DecimalTypes. + TypeScale *int `json:"type_scale,omitempty"` + // Full data type spec, SQL/catalogString text. + TypeText *string `json:"type_text,omitempty"` +} + +type FunctionParameterInfos struct { + Parameters []FunctionParameterInfo `json:"parameters,omitempty"` +} + +type GetFunctionRequest struct { + // The fully-qualified name of the function (of the form + // __catalog_name__.__schema_name__.__function__name__). + FullNameArg *string `json:"full_name_arg,omitempty"` + // Whether to include functions in the response for which the principal can only + // access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` +} + +type ListFunctionsRequest struct { + // Name of parent catalog for functions of interest. + CatalogName *string `json:"catalog_name,omitempty"` + // Whether to include functions in the response for which the principal can only + // access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` + // Maximum number of functions to return. If not set, all the functions are + // returned (not recommended). - when set to a value greater than 0, the page + // length is the minimum of this value and a server configured value; - when set + // to 0, the page length is set to a server configured value (recommended); - + // when set to a value less than 0, an invalid parameter error is returned; + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` + // Parent schema of functions. + SchemaName *string `json:"schema_name,omitempty"` +} + +type ListFunctionsResponse struct { + // An array of function information objects. + Functions []FunctionInfo `json:"functions,omitempty"` + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` +} + +// A table that is dependent on a SQL object.. +type TableDependency struct { + // Full name of the dependent table, in the form of + // __catalog_name__.__schema_name__.__table_name__. + TableFullName *string `json:"table_full_name,omitempty"` +} + +type UpdateFunctionRequest struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // Name of parent Catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this function was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of function creator. + CreatedBy *string `json:"created_by,omitempty"` + // Scalar function return data type. + DataType ColumnTypeName `json:"data_type,omitempty"` + // External function language. + ExternalLanguage *string `json:"external_language,omitempty"` + // External function name. + ExternalName *string `json:"external_name,omitempty"` + // Pretty printed function data type. + FullDataType *string `json:"full_data_type,omitempty"` + // Full name of Function, in form of + // **catalog_name**.**schema_name**.**function_name** + FullName *string `json:"full_name,omitempty"` + // The fully-qualified name of the function (of the form + // __catalog_name__.__schema_name__.__function__name__). + FullNameArg *string `json:"full_name_arg,omitempty"` + // Id of Function, relative to parent schema. + FunctionId *string `json:"function_id,omitempty"` + // Function input parameters. + InputParams *FunctionParameterInfos `json:"input_params,omitempty"` + // Whether the function is deterministic. + IsDeterministic *bool `json:"is_deterministic,omitempty"` + // Function null call. + IsNullCall *bool `json:"is_null_call,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of function, relative to parent schema. + Name *string `json:"name,omitempty"` + // Username of current owner of the function. + Owner *string `json:"owner,omitempty"` + // Function parameter style. **S** is the value for SQL. + ParameterStyle FunctionInfo_ParameterStyle `json:"parameter_style,omitempty"` + // JSON-serialized key-value pair map, encoded (escaped) as a string. + Properties *string `json:"properties,omitempty"` + // Table function return parameters. + ReturnParams *FunctionParameterInfos `json:"return_params,omitempty"` + // Function language. When **EXTERNAL** is used, the language of the routine + // function should be specified in the **external_language** field, and the + // **return_params** of the function cannot be used (as **TABLE** return type is + // not supported), and the **sql_data_access** field must be **NO_SQL**. + RoutineBody FunctionInfo_RoutineBody `json:"routine_body,omitempty"` + // Function body. + RoutineDefinition *string `json:"routine_definition,omitempty"` + // Function dependencies. For external UDFs, dependencies may contain only + // credential, secret, or volume objects. + RoutineDependencies *DependencyList `json:"routine_dependencies,omitempty"` + // Name of parent Schema relative to its parent Catalog. + SchemaName *string `json:"schema_name,omitempty"` + // Function security type. + SecurityType FunctionInfo_SecurityType `json:"security_type,omitempty"` + // Specific name of the function; Reserved for future use. + SpecificName *string `json:"specific_name,omitempty"` + // Function SQL data access. + SqlDataAccess FunctionInfo_SqlDataAccess `json:"sql_data_access,omitempty"` + // List of schemes whose objects can be referenced without qualification. + SqlPath *string `json:"sql_path,omitempty"` + // Time at which this function was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the function. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// ConnectionDependencyToSDK converts the mirror to the sdk-go type. +func ConnectionDependencyToSDK(w *ConnectionDependency) (*sdk.ConnectionDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.ConnectionDependency{} + out.ConnectionName = w.ConnectionName + return out, nil +} + +// ConnectionDependencyFromSDK converts the sdk-go type to the mirror. +func ConnectionDependencyFromSDK(v *sdk.ConnectionDependency) (*ConnectionDependency, error) { + if v == nil { + return nil, nil + } + out := &ConnectionDependency{} + out.ConnectionName = v.ConnectionName + return out, nil +} + +// CreateFunctionToSDK converts the mirror to the sdk-go type. +func CreateFunctionToSDK(w *CreateFunction) (*sdk.CreateFunction, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateFunction{} + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + conv1, err := FunctionParameterInfosToSDK(w.InputParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFunction.InputParams", err) + } + out.InputParams = conv1 + out.DataType = w.DataType + out.FullDataType = w.FullDataType + out.RoutineBody = w.RoutineBody + out.RoutineDefinition = w.RoutineDefinition + out.ParameterStyle = w.ParameterStyle + out.IsDeterministic = w.IsDeterministic + out.SqlDataAccess = w.SqlDataAccess + out.IsNullCall = w.IsNullCall + out.SecurityType = w.SecurityType + out.SpecificName = w.SpecificName + conv2, err := FunctionParameterInfosToSDK(w.ReturnParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFunction.ReturnParams", err) + } + out.ReturnParams = conv2 + out.ExternalName = w.ExternalName + out.ExternalLanguage = w.ExternalLanguage + out.SqlPath = w.SqlPath + out.Owner = w.Owner + out.Comment = w.Comment + out.Properties = w.Properties + conv3, err := DependencyListToSDK(w.RoutineDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFunction.RoutineDependencies", err) + } + out.RoutineDependencies = conv3 + out.MetastoreId = w.MetastoreId + out.FullName = w.FullName + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.FunctionId = w.FunctionId + out.BrowseOnly = w.BrowseOnly + return out, nil +} + +// CreateFunctionFromSDK converts the sdk-go type to the mirror. +func CreateFunctionFromSDK(v *sdk.CreateFunction) (*CreateFunction, error) { + if v == nil { + return nil, nil + } + out := &CreateFunction{} + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + conv4, err := FunctionParameterInfosFromSDK(v.InputParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFunction.InputParams", err) + } + out.InputParams = conv4 + out.DataType = v.DataType + out.FullDataType = v.FullDataType + out.RoutineBody = v.RoutineBody + out.RoutineDefinition = v.RoutineDefinition + out.ParameterStyle = v.ParameterStyle + out.IsDeterministic = v.IsDeterministic + out.SqlDataAccess = v.SqlDataAccess + out.IsNullCall = v.IsNullCall + out.SecurityType = v.SecurityType + out.SpecificName = v.SpecificName + conv5, err := FunctionParameterInfosFromSDK(v.ReturnParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFunction.ReturnParams", err) + } + out.ReturnParams = conv5 + out.ExternalName = v.ExternalName + out.ExternalLanguage = v.ExternalLanguage + out.SqlPath = v.SqlPath + out.Owner = v.Owner + out.Comment = v.Comment + out.Properties = v.Properties + conv6, err := DependencyListFromSDK(v.RoutineDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFunction.RoutineDependencies", err) + } + out.RoutineDependencies = conv6 + out.MetastoreId = v.MetastoreId + out.FullName = v.FullName + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.FunctionId = v.FunctionId + out.BrowseOnly = v.BrowseOnly + return out, nil +} + +// CreateFunctionRequestToSDK converts the mirror to the sdk-go type. +func CreateFunctionRequestToSDK(w *CreateFunctionRequest) (*sdk.CreateFunctionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateFunctionRequest{} + conv7, err := CreateFunctionToSDK(w.FunctionInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFunctionRequest.FunctionInfo", err) + } + out.FunctionInfo = conv7 + return out, nil +} + +// CreateFunctionRequestFromSDK converts the sdk-go type to the mirror. +func CreateFunctionRequestFromSDK(v *sdk.CreateFunctionRequest) (*CreateFunctionRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateFunctionRequest{} + conv8, err := CreateFunctionFromSDK(v.FunctionInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateFunctionRequest.FunctionInfo", err) + } + out.FunctionInfo = conv8 + return out, nil +} + +// CredentialDependencyToSDK converts the mirror to the sdk-go type. +func CredentialDependencyToSDK(w *CredentialDependency) (*sdk.CredentialDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.CredentialDependency{} + out.CredentialName = w.CredentialName + return out, nil +} + +// CredentialDependencyFromSDK converts the sdk-go type to the mirror. +func CredentialDependencyFromSDK(v *sdk.CredentialDependency) (*CredentialDependency, error) { + if v == nil { + return nil, nil + } + out := &CredentialDependency{} + out.CredentialName = v.CredentialName + return out, nil +} + +// DeleteFunctionRequestToSDK converts the mirror to the sdk-go type. +func DeleteFunctionRequestToSDK(w *DeleteFunctionRequest) (*sdk.DeleteFunctionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteFunctionRequest{} + out.FullNameArg = w.FullNameArg + out.Force = w.Force + return out, nil +} + +// DeleteFunctionRequestFromSDK converts the sdk-go type to the mirror. +func DeleteFunctionRequestFromSDK(v *sdk.DeleteFunctionRequest) (*DeleteFunctionRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteFunctionRequest{} + out.FullNameArg = v.FullNameArg + out.Force = v.Force + return out, nil +} + +// DependencyToSDK converts the mirror to the sdk-go type. +func DependencyToSDK(w *Dependency) (*sdk.Dependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.Dependency{} + { + var members []string + if w.Table != nil { + members = append(members, "table") + } + if w.Function != nil { + members = append(members, "function") + } + if w.Connection != nil { + members = append(members, "connection") + } + if w.Credential != nil { + members = append(members, "credential") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Table != nil: + conv9, err := TableDependencyToSDK(w.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Table{Table: *conv9} + case w.Function != nil: + conv10, err := FunctionDependencyToSDK(w.Function) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Function{Function: *conv10} + case w.Connection != nil: + conv11, err := ConnectionDependencyToSDK(w.Connection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Connection{Connection: *conv11} + case w.Credential != nil: + conv12, err := CredentialDependencyToSDK(w.Credential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Credential{Credential: *conv12} + } + return out, nil +} + +// DependencyFromSDK converts the sdk-go type to the mirror. +func DependencyFromSDK(v *sdk.Dependency) (*Dependency, error) { + if v == nil { + return nil, nil + } + out := &Dependency{} + switch value := v.Value.(type) { + case *sdk.Dependency_Value_Table: + if value != nil { + conv13, err := TableDependencyFromSDK(&value.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Table = conv13 + } + case *sdk.Dependency_Value_Function: + if value != nil { + conv14, err := FunctionDependencyFromSDK(&value.Function) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Function = conv14 + } + case *sdk.Dependency_Value_Connection: + if value != nil { + conv15, err := ConnectionDependencyFromSDK(&value.Connection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Connection = conv15 + } + case *sdk.Dependency_Value_Credential: + if value != nil { + conv16, err := CredentialDependencyFromSDK(&value.Credential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Credential = conv16 + } + } + return out, nil +} + +// DependencyListToSDK converts the mirror to the sdk-go type. +func DependencyListToSDK(w *DependencyList) (*sdk.DependencyList, error) { + if w == nil { + return nil, nil + } + out := &sdk.DependencyList{} + conv17, err := convertSlice(w.Dependencies, DependencyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DependencyList.Dependencies", err) + } + out.Dependencies = conv17 + return out, nil +} + +// DependencyListFromSDK converts the sdk-go type to the mirror. +func DependencyListFromSDK(v *sdk.DependencyList) (*DependencyList, error) { + if v == nil { + return nil, nil + } + out := &DependencyList{} + conv18, err := convertSlice(v.Dependencies, DependencyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DependencyList.Dependencies", err) + } + out.Dependencies = conv18 + return out, nil +} + +// FunctionDependencyToSDK converts the mirror to the sdk-go type. +func FunctionDependencyToSDK(w *FunctionDependency) (*sdk.FunctionDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.FunctionDependency{} + out.FunctionFullName = w.FunctionFullName + return out, nil +} + +// FunctionDependencyFromSDK converts the sdk-go type to the mirror. +func FunctionDependencyFromSDK(v *sdk.FunctionDependency) (*FunctionDependency, error) { + if v == nil { + return nil, nil + } + out := &FunctionDependency{} + out.FunctionFullName = v.FunctionFullName + return out, nil +} + +// FunctionInfoToSDK converts the mirror to the sdk-go type. +func FunctionInfoToSDK(w *FunctionInfo) (*sdk.FunctionInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.FunctionInfo{} + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + conv19, err := FunctionParameterInfosToSDK(w.InputParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionInfo.InputParams", err) + } + out.InputParams = conv19 + out.DataType = w.DataType + out.FullDataType = w.FullDataType + out.RoutineBody = w.RoutineBody + out.RoutineDefinition = w.RoutineDefinition + out.ParameterStyle = w.ParameterStyle + out.IsDeterministic = w.IsDeterministic + out.SqlDataAccess = w.SqlDataAccess + out.IsNullCall = w.IsNullCall + out.SecurityType = w.SecurityType + out.SpecificName = w.SpecificName + conv20, err := FunctionParameterInfosToSDK(w.ReturnParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionInfo.ReturnParams", err) + } + out.ReturnParams = conv20 + out.ExternalName = w.ExternalName + out.ExternalLanguage = w.ExternalLanguage + out.SqlPath = w.SqlPath + out.Owner = w.Owner + out.Comment = w.Comment + out.Properties = w.Properties + conv21, err := DependencyListToSDK(w.RoutineDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionInfo.RoutineDependencies", err) + } + out.RoutineDependencies = conv21 + out.MetastoreId = w.MetastoreId + out.FullName = w.FullName + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.FunctionId = w.FunctionId + out.BrowseOnly = w.BrowseOnly + return out, nil +} + +// FunctionInfoFromSDK converts the sdk-go type to the mirror. +func FunctionInfoFromSDK(v *sdk.FunctionInfo) (*FunctionInfo, error) { + if v == nil { + return nil, nil + } + out := &FunctionInfo{} + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + conv22, err := FunctionParameterInfosFromSDK(v.InputParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionInfo.InputParams", err) + } + out.InputParams = conv22 + out.DataType = v.DataType + out.FullDataType = v.FullDataType + out.RoutineBody = v.RoutineBody + out.RoutineDefinition = v.RoutineDefinition + out.ParameterStyle = v.ParameterStyle + out.IsDeterministic = v.IsDeterministic + out.SqlDataAccess = v.SqlDataAccess + out.IsNullCall = v.IsNullCall + out.SecurityType = v.SecurityType + out.SpecificName = v.SpecificName + conv23, err := FunctionParameterInfosFromSDK(v.ReturnParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionInfo.ReturnParams", err) + } + out.ReturnParams = conv23 + out.ExternalName = v.ExternalName + out.ExternalLanguage = v.ExternalLanguage + out.SqlPath = v.SqlPath + out.Owner = v.Owner + out.Comment = v.Comment + out.Properties = v.Properties + conv24, err := DependencyListFromSDK(v.RoutineDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionInfo.RoutineDependencies", err) + } + out.RoutineDependencies = conv24 + out.MetastoreId = v.MetastoreId + out.FullName = v.FullName + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.FunctionId = v.FunctionId + out.BrowseOnly = v.BrowseOnly + return out, nil +} + +// FunctionParameterInfoToSDK converts the mirror to the sdk-go type. +func FunctionParameterInfoToSDK(w *FunctionParameterInfo) (*sdk.FunctionParameterInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.FunctionParameterInfo{} + out.Name = w.Name + out.TypeText = w.TypeText + out.TypeJson = w.TypeJson + out.TypeName = w.TypeName + out.TypePrecision = w.TypePrecision + out.TypeScale = w.TypeScale + out.TypeIntervalType = w.TypeIntervalType + out.Position = w.Position + out.ParameterMode = w.ParameterMode + out.ParameterType = w.ParameterType + out.ParameterDefault = w.ParameterDefault + out.Comment = w.Comment + return out, nil +} + +// FunctionParameterInfoFromSDK converts the sdk-go type to the mirror. +func FunctionParameterInfoFromSDK(v *sdk.FunctionParameterInfo) (*FunctionParameterInfo, error) { + if v == nil { + return nil, nil + } + out := &FunctionParameterInfo{} + out.Name = v.Name + out.TypeText = v.TypeText + out.TypeJson = v.TypeJson + out.TypeName = v.TypeName + out.TypePrecision = v.TypePrecision + out.TypeScale = v.TypeScale + out.TypeIntervalType = v.TypeIntervalType + out.Position = v.Position + out.ParameterMode = v.ParameterMode + out.ParameterType = v.ParameterType + out.ParameterDefault = v.ParameterDefault + out.Comment = v.Comment + return out, nil +} + +// FunctionParameterInfosToSDK converts the mirror to the sdk-go type. +func FunctionParameterInfosToSDK(w *FunctionParameterInfos) (*sdk.FunctionParameterInfos, error) { + if w == nil { + return nil, nil + } + out := &sdk.FunctionParameterInfos{} + conv25, err := convertSlice(w.Parameters, FunctionParameterInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionParameterInfos.Parameters", err) + } + out.Parameters = conv25 + return out, nil +} + +// FunctionParameterInfosFromSDK converts the sdk-go type to the mirror. +func FunctionParameterInfosFromSDK(v *sdk.FunctionParameterInfos) (*FunctionParameterInfos, error) { + if v == nil { + return nil, nil + } + out := &FunctionParameterInfos{} + conv26, err := convertSlice(v.Parameters, FunctionParameterInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "FunctionParameterInfos.Parameters", err) + } + out.Parameters = conv26 + return out, nil +} + +// GetFunctionRequestToSDK converts the mirror to the sdk-go type. +func GetFunctionRequestToSDK(w *GetFunctionRequest) (*sdk.GetFunctionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetFunctionRequest{} + out.FullNameArg = w.FullNameArg + out.IncludeBrowse = w.IncludeBrowse + return out, nil +} + +// GetFunctionRequestFromSDK converts the sdk-go type to the mirror. +func GetFunctionRequestFromSDK(v *sdk.GetFunctionRequest) (*GetFunctionRequest, error) { + if v == nil { + return nil, nil + } + out := &GetFunctionRequest{} + out.FullNameArg = v.FullNameArg + out.IncludeBrowse = v.IncludeBrowse + return out, nil +} + +// ListFunctionsRequestToSDK converts the mirror to the sdk-go type. +func ListFunctionsRequestToSDK(w *ListFunctionsRequest) (*sdk.ListFunctionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListFunctionsRequest{} + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.IncludeBrowse = w.IncludeBrowse + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListFunctionsRequestFromSDK converts the sdk-go type to the mirror. +func ListFunctionsRequestFromSDK(v *sdk.ListFunctionsRequest) (*ListFunctionsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListFunctionsRequest{} + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.IncludeBrowse = v.IncludeBrowse + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListFunctionsResponseToSDK converts the mirror to the sdk-go type. +func ListFunctionsResponseToSDK(w *ListFunctionsResponse) (*sdk.ListFunctionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListFunctionsResponse{} + conv27, err := convertSlice(w.Functions, FunctionInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFunctionsResponse.Functions", err) + } + out.Functions = conv27 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListFunctionsResponseFromSDK converts the sdk-go type to the mirror. +func ListFunctionsResponseFromSDK(v *sdk.ListFunctionsResponse) (*ListFunctionsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListFunctionsResponse{} + conv28, err := convertSlice(v.Functions, FunctionInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListFunctionsResponse.Functions", err) + } + out.Functions = conv28 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// TableDependencyToSDK converts the mirror to the sdk-go type. +func TableDependencyToSDK(w *TableDependency) (*sdk.TableDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.TableDependency{} + out.TableFullName = w.TableFullName + return out, nil +} + +// TableDependencyFromSDK converts the sdk-go type to the mirror. +func TableDependencyFromSDK(v *sdk.TableDependency) (*TableDependency, error) { + if v == nil { + return nil, nil + } + out := &TableDependency{} + out.TableFullName = v.TableFullName + return out, nil +} + +// UpdateFunctionRequestToSDK converts the mirror to the sdk-go type. +func UpdateFunctionRequestToSDK(w *UpdateFunctionRequest) (*sdk.UpdateFunctionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateFunctionRequest{} + out.FullNameArg = w.FullNameArg + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + conv29, err := FunctionParameterInfosToSDK(w.InputParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateFunctionRequest.InputParams", err) + } + out.InputParams = conv29 + out.DataType = w.DataType + out.FullDataType = w.FullDataType + out.RoutineBody = w.RoutineBody + out.RoutineDefinition = w.RoutineDefinition + out.ParameterStyle = w.ParameterStyle + out.IsDeterministic = w.IsDeterministic + out.SqlDataAccess = w.SqlDataAccess + out.IsNullCall = w.IsNullCall + out.SecurityType = w.SecurityType + out.SpecificName = w.SpecificName + conv30, err := FunctionParameterInfosToSDK(w.ReturnParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateFunctionRequest.ReturnParams", err) + } + out.ReturnParams = conv30 + out.ExternalName = w.ExternalName + out.ExternalLanguage = w.ExternalLanguage + out.SqlPath = w.SqlPath + out.Owner = w.Owner + out.Comment = w.Comment + out.Properties = w.Properties + conv31, err := DependencyListToSDK(w.RoutineDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateFunctionRequest.RoutineDependencies", err) + } + out.RoutineDependencies = conv31 + out.MetastoreId = w.MetastoreId + out.FullName = w.FullName + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.FunctionId = w.FunctionId + out.BrowseOnly = w.BrowseOnly + return out, nil +} + +// UpdateFunctionRequestFromSDK converts the sdk-go type to the mirror. +func UpdateFunctionRequestFromSDK(v *sdk.UpdateFunctionRequest) (*UpdateFunctionRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateFunctionRequest{} + out.FullNameArg = v.FullNameArg + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + conv32, err := FunctionParameterInfosFromSDK(v.InputParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateFunctionRequest.InputParams", err) + } + out.InputParams = conv32 + out.DataType = v.DataType + out.FullDataType = v.FullDataType + out.RoutineBody = v.RoutineBody + out.RoutineDefinition = v.RoutineDefinition + out.ParameterStyle = v.ParameterStyle + out.IsDeterministic = v.IsDeterministic + out.SqlDataAccess = v.SqlDataAccess + out.IsNullCall = v.IsNullCall + out.SecurityType = v.SecurityType + out.SpecificName = v.SpecificName + conv33, err := FunctionParameterInfosFromSDK(v.ReturnParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateFunctionRequest.ReturnParams", err) + } + out.ReturnParams = conv33 + out.ExternalName = v.ExternalName + out.ExternalLanguage = v.ExternalLanguage + out.SqlPath = v.SqlPath + out.Owner = v.Owner + out.Comment = v.Comment + out.Properties = v.Properties + conv34, err := DependencyListFromSDK(v.RoutineDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateFunctionRequest.RoutineDependencies", err) + } + out.RoutineDependencies = conv34 + out.MetastoreId = v.MetastoreId + out.FullName = v.FullName + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.FunctionId = v.FunctionId + out.BrowseOnly = v.BrowseOnly + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/grants/v1/types.generated.go b/libs/sdktypes/uc/grants/v1/types.generated.go new file mode 100644 index 00000000000..5fe8cc30982 --- /dev/null +++ b/libs/sdktypes/uc/grants/v1/types.generated.go @@ -0,0 +1,608 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/grants/v1. DO NOT EDIT. + +package grants + +import ( + fmt "fmt" + sdk "github.com/databricks/sdk-go/uc/grants/v1" +) + +type EffectivePrivilege struct { + // The full name of the object that conveys this privilege via inheritance. This + // field is omitted when privilege is not inherited (it's assigned to the + // securable itself). + InheritedFromName *string `json:"inherited_from_name,omitempty"` + // The type of the object that conveys this privilege via inheritance. This + // field is omitted when privilege is not inherited (it's assigned to the + // securable itself). + InheritedFromType *string `json:"inherited_from_type,omitempty"` + // The privilege assigned to the principal. + Privilege *string `json:"privilege,omitempty"` +} + +type EffectivePrivilegeAssignment struct { + // The principal (user email address or group name). + Principal *string `json:"principal,omitempty"` + // The privileges conveyed to the principal (either directly or via + // inheritance). + Privileges []EffectivePrivilege `json:"privileges,omitempty"` +} + +type GetEffectivePermissionsRequest struct { + // Specifies the maximum number of privileges to return (page length). Every + // EffectivePrivilegeAssignment present in a single page response is guaranteed + // to contain all the effective privileges granted on (or inherited by) the + // requested Securable for the respective principal. + // + // If not set, all the effective permissions are returned. If set to - lesser + // than 0: invalid parameter error - 0: page length is set to a server + // configured value - lesser than 150 but greater than 0: invalid parameter + // error (this is to ensure that server is able to return at least one complete + // EffectivePrivilegeAssignment in a single page response) - greater than (or + // equal to) 150: page length is the minimum of this value and a server + // configured value + MaxResults *int `json:"max_results,omitempty"` + // Opaque token for the next page of results (pagination). + PageToken *string `json:"page_token,omitempty"` + // If provided, only the effective permissions for the specified principal (user + // or group) are returned. + Principal *string `json:"principal,omitempty"` + // Full name of securable. + SecurableFullName *string `json:"securable_full_name,omitempty"` + // Type of securable. + SecurableType *string `json:"securable_type,omitempty"` +} + +type GetEffectivePermissionsResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // The privileges conveyed to each principal (either directly or via + // inheritance) + PrivilegeAssignments []EffectivePrivilegeAssignment `json:"privilege_assignments,omitempty"` +} + +type GetPermissionsRequest struct { + // Specifies the maximum number of privileges to return (page length). Every + // PrivilegeAssignment present in a single page response is guaranteed to + // contain all the privileges granted on the requested Securable for the + // respective principal. + // + // If not set, all the permissions are returned. If set to - lesser than 0: + // invalid parameter error - 0: page length is set to a server configured value + // - lesser than 150 but greater than 0: invalid parameter error (this is to + // ensure that server is able to return at least one complete + // PrivilegeAssignment in a single page response) - greater than (or equal to) + // 150: page length is the minimum of this value and a server configured value + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` + // If provided, only the permissions for the specified principal (user or group) + // are returned. + Principal *string `json:"principal,omitempty"` + // Full name of securable. + SecurableFullName *string `json:"securable_full_name,omitempty"` + // Type of securable. + SecurableType *string `json:"securable_type,omitempty"` +} + +type GetPermissionsResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // The privileges assigned to each principal + PrivilegeAssignments []PrivilegeAssignment `json:"privilege_assignments,omitempty"` +} + +type ListEffectivePrivilegeAssignmentsRequest struct { + // Full name of securable. + FullName *string `json:"full_name,omitempty"` + // Specifies the maximum number of privilege assignments to return (page + // length). Every EffectivePrivilegeAssignment present in a single page response + // is guaranteed to contain all the effective privileges granted on (or + // inherited by) the requested Securable for the respective principal. + // + // If not set, a server-configured default is used. If set to - lesser than 0: + // invalid parameter error - 0: page length is set to a server configured value + // - lesser than 150 but greater than 0: invalid parameter error (this is to + // ensure that server is able to return at least one complete + // EffectivePrivilegeAssignment in a single page response) - greater than (or + // equal to) 150: page length is the minimum of this value and a server + // configured value + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` + // If provided, only the effective permissions for the specified principal (user + // or group) are returned. + Principal *string `json:"principal,omitempty"` + // Type of securable. + SecurableType *string `json:"securable_type,omitempty"` +} + +type ListEffectivePrivilegeAssignmentsResponse struct { + // The effective privilege assignments for the securable (and optional + // principal). + EffectivePrivilegeAssignments []EffectivePrivilegeAssignment `json:"effective_privilege_assignments,omitempty"` + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListPrivilegeAssignmentsRequest struct { + // Full name of securable. + FullName *string `json:"full_name,omitempty"` + // Specifies the maximum number of privilege assignments to return (page + // length). Every PrivilegeAssignment present in a single page response is + // guaranteed to contain all the privileges granted on the requested Securable + // for the respective principal. + // + // If not set, page length is the server configured value. If set to - lesser + // than 0: invalid parameter error - 0: page length is set to a server + // configured value - lesser than 150 but greater than 0: invalid parameter + // error (this is to ensure that server is able to return at least one complete + // PrivilegeAssignment in a single page response) - greater than (or equal to) + // 150: page length is the minimum of this value and a server configured value + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` + // If provided, only the permissions for the specified principal (user or group) + // are returned. + Principal *string `json:"principal,omitempty"` + // Type of securable. + SecurableType *string `json:"securable_type,omitempty"` +} + +type ListPrivilegeAssignmentsResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + PrivilegeAssignments []PrivilegeAssignment `json:"privilege_assignments,omitempty"` +} + +type PermissionsChange struct { + // The set of privileges to add. + Add []string `json:"add,omitempty"` + // The principal whose privileges we are changing. Only one of principal or + // principal_id should be specified, never both at the same time. + Principal *string `json:"principal,omitempty"` + // The set of privileges to remove. + Remove []string `json:"remove,omitempty"` +} + +type PrivilegeAssignment struct { + // The principal (user email address or group name). For deleted principals, + // `principal` is empty while `principal_id` is populated. + Principal *string `json:"principal,omitempty"` + // The privileges assigned to the principal. + Privileges []string `json:"privileges,omitempty"` +} + +type UpdatePermissionsRequest struct { + // Array of permissions change objects. + Changes []PermissionsChange `json:"changes,omitempty"` + // Optional, default false. Specifies whether all the permissions should be + // returned in the response. + OmitPermissionsInResponse *bool `json:"omit_permissions_in_response,omitempty"` + // Full name of securable. + SecurableFullName *string `json:"securable_full_name,omitempty"` + // Type of securable. + SecurableType *string `json:"securable_type,omitempty"` +} + +type UpdatePermissionsResponse struct { + // The privileges assigned to each principal + PrivilegeAssignments []PrivilegeAssignment `json:"privilege_assignments,omitempty"` +} + +// EffectivePrivilegeToSDK converts the mirror to the sdk-go type. +func EffectivePrivilegeToSDK(w *EffectivePrivilege) (*sdk.EffectivePrivilege, error) { + if w == nil { + return nil, nil + } + out := &sdk.EffectivePrivilege{} + out.Privilege = w.Privilege + out.InheritedFromType = w.InheritedFromType + out.InheritedFromName = w.InheritedFromName + return out, nil +} + +// EffectivePrivilegeFromSDK converts the sdk-go type to the mirror. +func EffectivePrivilegeFromSDK(v *sdk.EffectivePrivilege) (*EffectivePrivilege, error) { + if v == nil { + return nil, nil + } + out := &EffectivePrivilege{} + out.Privilege = v.Privilege + out.InheritedFromType = v.InheritedFromType + out.InheritedFromName = v.InheritedFromName + return out, nil +} + +// EffectivePrivilegeAssignmentToSDK converts the mirror to the sdk-go type. +func EffectivePrivilegeAssignmentToSDK(w *EffectivePrivilegeAssignment) (*sdk.EffectivePrivilegeAssignment, error) { + if w == nil { + return nil, nil + } + out := &sdk.EffectivePrivilegeAssignment{} + out.Principal = w.Principal + conv1, err := convertSlice(w.Privileges, EffectivePrivilegeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EffectivePrivilegeAssignment.Privileges", err) + } + out.Privileges = conv1 + return out, nil +} + +// EffectivePrivilegeAssignmentFromSDK converts the sdk-go type to the mirror. +func EffectivePrivilegeAssignmentFromSDK(v *sdk.EffectivePrivilegeAssignment) (*EffectivePrivilegeAssignment, error) { + if v == nil { + return nil, nil + } + out := &EffectivePrivilegeAssignment{} + out.Principal = v.Principal + conv2, err := convertSlice(v.Privileges, EffectivePrivilegeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EffectivePrivilegeAssignment.Privileges", err) + } + out.Privileges = conv2 + return out, nil +} + +// GetEffectivePermissionsRequestToSDK converts the mirror to the sdk-go type. +func GetEffectivePermissionsRequestToSDK(w *GetEffectivePermissionsRequest) (*sdk.GetEffectivePermissionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetEffectivePermissionsRequest{} + out.SecurableType = w.SecurableType + out.SecurableFullName = w.SecurableFullName + out.Principal = w.Principal + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// GetEffectivePermissionsRequestFromSDK converts the sdk-go type to the mirror. +func GetEffectivePermissionsRequestFromSDK(v *sdk.GetEffectivePermissionsRequest) (*GetEffectivePermissionsRequest, error) { + if v == nil { + return nil, nil + } + out := &GetEffectivePermissionsRequest{} + out.SecurableType = v.SecurableType + out.SecurableFullName = v.SecurableFullName + out.Principal = v.Principal + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// GetEffectivePermissionsResponseToSDK converts the mirror to the sdk-go type. +func GetEffectivePermissionsResponseToSDK(w *GetEffectivePermissionsResponse) (*sdk.GetEffectivePermissionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetEffectivePermissionsResponse{} + out.NextPageToken = w.NextPageToken + conv3, err := convertSlice(w.PrivilegeAssignments, EffectivePrivilegeAssignmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetEffectivePermissionsResponse.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv3 + return out, nil +} + +// GetEffectivePermissionsResponseFromSDK converts the sdk-go type to the mirror. +func GetEffectivePermissionsResponseFromSDK(v *sdk.GetEffectivePermissionsResponse) (*GetEffectivePermissionsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetEffectivePermissionsResponse{} + out.NextPageToken = v.NextPageToken + conv4, err := convertSlice(v.PrivilegeAssignments, EffectivePrivilegeAssignmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetEffectivePermissionsResponse.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv4 + return out, nil +} + +// GetPermissionsRequestToSDK converts the mirror to the sdk-go type. +func GetPermissionsRequestToSDK(w *GetPermissionsRequest) (*sdk.GetPermissionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPermissionsRequest{} + out.SecurableType = w.SecurableType + out.SecurableFullName = w.SecurableFullName + out.Principal = w.Principal + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// GetPermissionsRequestFromSDK converts the sdk-go type to the mirror. +func GetPermissionsRequestFromSDK(v *sdk.GetPermissionsRequest) (*GetPermissionsRequest, error) { + if v == nil { + return nil, nil + } + out := &GetPermissionsRequest{} + out.SecurableType = v.SecurableType + out.SecurableFullName = v.SecurableFullName + out.Principal = v.Principal + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// GetPermissionsResponseToSDK converts the mirror to the sdk-go type. +func GetPermissionsResponseToSDK(w *GetPermissionsResponse) (*sdk.GetPermissionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetPermissionsResponse{} + out.NextPageToken = w.NextPageToken + conv5, err := convertSlice(w.PrivilegeAssignments, PrivilegeAssignmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPermissionsResponse.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv5 + return out, nil +} + +// GetPermissionsResponseFromSDK converts the sdk-go type to the mirror. +func GetPermissionsResponseFromSDK(v *sdk.GetPermissionsResponse) (*GetPermissionsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetPermissionsResponse{} + out.NextPageToken = v.NextPageToken + conv6, err := convertSlice(v.PrivilegeAssignments, PrivilegeAssignmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetPermissionsResponse.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv6 + return out, nil +} + +// ListEffectivePrivilegeAssignmentsRequestToSDK converts the mirror to the sdk-go type. +func ListEffectivePrivilegeAssignmentsRequestToSDK(w *ListEffectivePrivilegeAssignmentsRequest) (*sdk.ListEffectivePrivilegeAssignmentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEffectivePrivilegeAssignmentsRequest{} + out.SecurableType = w.SecurableType + out.FullName = w.FullName + out.Principal = w.Principal + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListEffectivePrivilegeAssignmentsRequestFromSDK converts the sdk-go type to the mirror. +func ListEffectivePrivilegeAssignmentsRequestFromSDK(v *sdk.ListEffectivePrivilegeAssignmentsRequest) (*ListEffectivePrivilegeAssignmentsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListEffectivePrivilegeAssignmentsRequest{} + out.SecurableType = v.SecurableType + out.FullName = v.FullName + out.Principal = v.Principal + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListEffectivePrivilegeAssignmentsResponseToSDK converts the mirror to the sdk-go type. +func ListEffectivePrivilegeAssignmentsResponseToSDK(w *ListEffectivePrivilegeAssignmentsResponse) (*sdk.ListEffectivePrivilegeAssignmentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEffectivePrivilegeAssignmentsResponse{} + conv7, err := convertSlice(w.EffectivePrivilegeAssignments, EffectivePrivilegeAssignmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListEffectivePrivilegeAssignmentsResponse.EffectivePrivilegeAssignments", err) + } + out.EffectivePrivilegeAssignments = conv7 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListEffectivePrivilegeAssignmentsResponseFromSDK converts the sdk-go type to the mirror. +func ListEffectivePrivilegeAssignmentsResponseFromSDK(v *sdk.ListEffectivePrivilegeAssignmentsResponse) (*ListEffectivePrivilegeAssignmentsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListEffectivePrivilegeAssignmentsResponse{} + conv8, err := convertSlice(v.EffectivePrivilegeAssignments, EffectivePrivilegeAssignmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListEffectivePrivilegeAssignmentsResponse.EffectivePrivilegeAssignments", err) + } + out.EffectivePrivilegeAssignments = conv8 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListPrivilegeAssignmentsRequestToSDK converts the mirror to the sdk-go type. +func ListPrivilegeAssignmentsRequestToSDK(w *ListPrivilegeAssignmentsRequest) (*sdk.ListPrivilegeAssignmentsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPrivilegeAssignmentsRequest{} + out.SecurableType = w.SecurableType + out.FullName = w.FullName + out.Principal = w.Principal + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListPrivilegeAssignmentsRequestFromSDK converts the sdk-go type to the mirror. +func ListPrivilegeAssignmentsRequestFromSDK(v *sdk.ListPrivilegeAssignmentsRequest) (*ListPrivilegeAssignmentsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListPrivilegeAssignmentsRequest{} + out.SecurableType = v.SecurableType + out.FullName = v.FullName + out.Principal = v.Principal + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListPrivilegeAssignmentsResponseToSDK converts the mirror to the sdk-go type. +func ListPrivilegeAssignmentsResponseToSDK(w *ListPrivilegeAssignmentsResponse) (*sdk.ListPrivilegeAssignmentsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListPrivilegeAssignmentsResponse{} + conv9, err := convertSlice(w.PrivilegeAssignments, PrivilegeAssignmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPrivilegeAssignmentsResponse.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv9 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListPrivilegeAssignmentsResponseFromSDK converts the sdk-go type to the mirror. +func ListPrivilegeAssignmentsResponseFromSDK(v *sdk.ListPrivilegeAssignmentsResponse) (*ListPrivilegeAssignmentsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListPrivilegeAssignmentsResponse{} + conv10, err := convertSlice(v.PrivilegeAssignments, PrivilegeAssignmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListPrivilegeAssignmentsResponse.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv10 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// PermissionsChangeToSDK converts the mirror to the sdk-go type. +func PermissionsChangeToSDK(w *PermissionsChange) (*sdk.PermissionsChange, error) { + if w == nil { + return nil, nil + } + out := &sdk.PermissionsChange{} + out.Principal = w.Principal + out.Add = w.Add + out.Remove = w.Remove + return out, nil +} + +// PermissionsChangeFromSDK converts the sdk-go type to the mirror. +func PermissionsChangeFromSDK(v *sdk.PermissionsChange) (*PermissionsChange, error) { + if v == nil { + return nil, nil + } + out := &PermissionsChange{} + out.Principal = v.Principal + out.Add = v.Add + out.Remove = v.Remove + return out, nil +} + +// PrivilegeAssignmentToSDK converts the mirror to the sdk-go type. +func PrivilegeAssignmentToSDK(w *PrivilegeAssignment) (*sdk.PrivilegeAssignment, error) { + if w == nil { + return nil, nil + } + out := &sdk.PrivilegeAssignment{} + out.Principal = w.Principal + out.Privileges = w.Privileges + return out, nil +} + +// PrivilegeAssignmentFromSDK converts the sdk-go type to the mirror. +func PrivilegeAssignmentFromSDK(v *sdk.PrivilegeAssignment) (*PrivilegeAssignment, error) { + if v == nil { + return nil, nil + } + out := &PrivilegeAssignment{} + out.Principal = v.Principal + out.Privileges = v.Privileges + return out, nil +} + +// UpdatePermissionsRequestToSDK converts the mirror to the sdk-go type. +func UpdatePermissionsRequestToSDK(w *UpdatePermissionsRequest) (*sdk.UpdatePermissionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdatePermissionsRequest{} + out.SecurableType = w.SecurableType + out.SecurableFullName = w.SecurableFullName + out.OmitPermissionsInResponse = w.OmitPermissionsInResponse + conv11, err := convertSlice(w.Changes, PermissionsChangeToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePermissionsRequest.Changes", err) + } + out.Changes = conv11 + return out, nil +} + +// UpdatePermissionsRequestFromSDK converts the sdk-go type to the mirror. +func UpdatePermissionsRequestFromSDK(v *sdk.UpdatePermissionsRequest) (*UpdatePermissionsRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdatePermissionsRequest{} + out.SecurableType = v.SecurableType + out.SecurableFullName = v.SecurableFullName + out.OmitPermissionsInResponse = v.OmitPermissionsInResponse + conv12, err := convertSlice(v.Changes, PermissionsChangeFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePermissionsRequest.Changes", err) + } + out.Changes = conv12 + return out, nil +} + +// UpdatePermissionsResponseToSDK converts the mirror to the sdk-go type. +func UpdatePermissionsResponseToSDK(w *UpdatePermissionsResponse) (*sdk.UpdatePermissionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdatePermissionsResponse{} + conv13, err := convertSlice(w.PrivilegeAssignments, PrivilegeAssignmentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePermissionsResponse.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv13 + return out, nil +} + +// UpdatePermissionsResponseFromSDK converts the sdk-go type to the mirror. +func UpdatePermissionsResponseFromSDK(v *sdk.UpdatePermissionsResponse) (*UpdatePermissionsResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdatePermissionsResponse{} + conv14, err := convertSlice(v.PrivilegeAssignments, PrivilegeAssignmentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdatePermissionsResponse.PrivilegeAssignments", err) + } + out.PrivilegeAssignments = conv14 + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/metastores/v1/types.generated.go b/libs/sdktypes/uc/metastores/v1/types.generated.go new file mode 100644 index 00000000000..3e238fa43da --- /dev/null +++ b/libs/sdktypes/uc/metastores/v1/types.generated.go @@ -0,0 +1,1295 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/metastores/v1. DO NOT EDIT. + +package metastores + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/metastores/v1" +) + +type ( + DeltaSharingScope_Enum = sdk.DeltaSharingScope_Enum +) + +const ( + DeltaSharingScope_Enum_Unspecified = sdk.DeltaSharingScope_Enum_Unspecified + DeltaSharingScope_Enum_Internal = sdk.DeltaSharingScope_Enum_Internal + DeltaSharingScope_Enum_InternalAndExternal = sdk.DeltaSharingScope_Enum_InternalAndExternal +) + +// The mapping from workspace to metastore.. +type AccountsCreateMetastoreAssignmentRequest struct { + // account ID of any type. For non-E2 account types, get your + // account ID from the [Accounts Console] + // + // [Accounts Console]: https://docs.databricks.com/administration-guide/account-settings/usage.html + AccountId *string `json:"account_id,omitempty"` + MetastoreAssignment *MetastoreAssignment `json:"metastore_assignment,omitempty"` + // Unity Catalog metastore ID + MetastoreId *string `json:"metastore_id,omitempty"` + // Workspace ID. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +// Properties of the new metastore.. +type AccountsCreateMetastoreRequest struct { + // account ID of any type. For non-E2 account types, get your + // account ID from the [Accounts Console] + // + // [Accounts Console]: https://docs.databricks.com/administration-guide/account-settings/usage.html + AccountId *string `json:"account_id,omitempty"` + MetastoreInfo *CreateAccountsMetastore `json:"metastore_info,omitempty"` +} + +type AccountsCreateMetastoreResponse struct { + MetastoreInfo *MetastoreInfo `json:"metastore_info,omitempty"` +} + +// Delete a metastore for the given account. +type AccountsDeleteMetastoreRequest struct { + // account ID of any type. For non-E2 account types, get your + // account ID from the [Accounts Console] + // + // [Accounts Console]: https://docs.databricks.com/administration-guide/account-settings/usage.html + AccountId *string `json:"account_id,omitempty"` + // Force deletion even if the metastore is not empty. Default is false. + Force *bool `json:"force,omitempty"` + // Unity Catalog metastore ID + MetastoreId *string `json:"metastore_id,omitempty"` +} + +// The workspace metastore assignment was successfully returned.. +type AccountsGetMetastoreAssignmentResponse struct { + MetastoreAssignment *MetastoreAssignment `json:"metastore_assignment,omitempty"` +} + +// The metastore was successfully returned.. +type AccountsGetMetastoreResponse struct { + MetastoreInfo *MetastoreInfo `json:"metastore_info,omitempty"` +} + +// Metastores were returned successfully.. +type AccountsListMetastoresResponse struct { + // An array of metastore information objects. + Metastores []MetastoreInfo `json:"metastores,omitempty"` +} + +// The metastore assignments were successfully returned.. +type AccountsListWorkspaceIdsForMetastoreResponse struct { + WorkspaceIds []int64 `json:"workspace_ids,omitempty"` +} + +// The metastore assignment to update.. +type AccountsUpdateMetastoreAssignmentRequest struct { + // account ID of any type. For non-E2 account types, get your + // account ID from the [Accounts Console] + // + // [Accounts Console]: https://docs.databricks.com/administration-guide/account-settings/usage.html + AccountId *string `json:"account_id,omitempty"` + MetastoreAssignment *MetastoreAssignment `json:"metastore_assignment,omitempty"` + // Unity Catalog metastore ID + MetastoreId *string `json:"metastore_id,omitempty"` + // Workspace ID. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +// Properties of the metastore to change.. +type AccountsUpdateMetastoreRequest struct { + // account ID of any type. For non-E2 account types, get your + // account ID from the [Accounts Console] + // + // [Accounts Console]: https://docs.databricks.com/administration-guide/account-settings/usage.html + AccountId *string `json:"account_id,omitempty"` + // Unity Catalog metastore ID + MetastoreId *string `json:"metastore_id,omitempty"` + // Properties of the metastore to change. + MetastoreInfo *UpdateAccountsMetastore `json:"metastore_info,omitempty"` +} + +// The metastore update request succeeded.. +type AccountsUpdateMetastoreResponse struct { + MetastoreInfo *MetastoreInfo `json:"metastore_info,omitempty"` +} + +type CreateAccountsMetastore struct { + // Cloud vendor of the metastore home shard (e.g., `aws`, `azure`, `gcp`). + Cloud *string `json:"cloud,omitempty"` + // Time at which this metastore was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of metastore creator. + CreatedBy *string `json:"created_by,omitempty"` + // Unique identifier of the metastore's (Default) Data Access Configuration. + DefaultDataAccessConfigId *string `json:"default_data_access_config_id,omitempty"` + // The organization name of a Delta Sharing entity, to be used in + // Databricks-to-Databricks Delta Sharing as the official name. + DeltaSharingOrganizationName *string `json:"delta_sharing_organization_name,omitempty"` + // The lifetime of delta sharing recipient token in seconds. + DeltaSharingRecipientTokenLifetimeInSeconds *int64 `json:"delta_sharing_recipient_token_lifetime_in_seconds,omitempty"` + // The scope of Delta Sharing enabled for the metastore. + DeltaSharingScope DeltaSharingScope_Enum `json:"delta_sharing_scope,omitempty"` + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled *bool `json:"external_access_enabled,omitempty"` + // Globally unique metastore ID across clouds and regions, of the form + // `cloud:region:metastore_id`. + GlobalMetastoreId *string `json:"global_metastore_id,omitempty"` + // Unique identifier of metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The user-specified name of the metastore. + Name *string `json:"name,omitempty"` + // The owner of the metastore. + Owner *string `json:"owner,omitempty"` + // Privilege model version of the metastore, of the form `major.minor` (e.g., + // `1.0`). + PrivilegeModelVersion *string `json:"privilege_model_version,omitempty"` + // Cloud region which the metastore serves (e.g., `us-west-2`, `westus`). + Region *string `json:"region,omitempty"` + // The storage root URL for metastore + StorageRoot *string `json:"storage_root,omitempty"` + // UUID of storage credential to access the metastore storage_root. + StorageRootCredentialId *string `json:"storage_root_credential_id,omitempty"` + // Name of the storage credential to access the metastore storage_root. + StorageRootCredentialName *string `json:"storage_root_credential_name,omitempty"` + // Time at which the metastore was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the metastore. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type CreateMetastoreAssignmentRequest struct { + // The name of the default catalog in the metastore. This field is deprecated. + // Please use "Default Namespace API" to configure the default catalog for a + // workspace. + DefaultCatalogName *string `json:"default_catalog_name,omitempty"` + // The unique ID of the metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // A workspace ID. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +type CreateMetastoreRequest struct { + // Cloud vendor of the metastore home shard (e.g., `aws`, `azure`, `gcp`). + Cloud *string `json:"cloud,omitempty"` + // Time at which this metastore was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of metastore creator. + CreatedBy *string `json:"created_by,omitempty"` + // Unique identifier of the metastore's (Default) Data Access Configuration. + DefaultDataAccessConfigId *string `json:"default_data_access_config_id,omitempty"` + // The organization name of a Delta Sharing entity, to be used in + // Databricks-to-Databricks Delta Sharing as the official name. + DeltaSharingOrganizationName *string `json:"delta_sharing_organization_name,omitempty"` + // The lifetime of delta sharing recipient token in seconds. + DeltaSharingRecipientTokenLifetimeInSeconds *int64 `json:"delta_sharing_recipient_token_lifetime_in_seconds,omitempty"` + // The scope of Delta Sharing enabled for the metastore. + DeltaSharingScope DeltaSharingScope_Enum `json:"delta_sharing_scope,omitempty"` + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled *bool `json:"external_access_enabled,omitempty"` + // Globally unique metastore ID across clouds and regions, of the form + // `cloud:region:metastore_id`. + GlobalMetastoreId *string `json:"global_metastore_id,omitempty"` + // Unique identifier of metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The user-specified name of the metastore. + Name *string `json:"name,omitempty"` + // The owner of the metastore. + Owner *string `json:"owner,omitempty"` + // Privilege model version of the metastore, of the form `major.minor` (e.g., + // `1.0`). + PrivilegeModelVersion *string `json:"privilege_model_version,omitempty"` + // Cloud region which the metastore serves (e.g., `us-west-2`, `westus`). + Region *string `json:"region,omitempty"` + // The storage root URL for metastore + StorageRoot *string `json:"storage_root,omitempty"` + // UUID of storage credential to access the metastore storage_root. + StorageRootCredentialId *string `json:"storage_root_credential_id,omitempty"` + // Name of the storage credential to access the metastore storage_root. + StorageRootCredentialName *string `json:"storage_root_credential_name,omitempty"` + // Time at which the metastore was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the metastore. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type DeleteMetastoreAssignmentRequest struct { + // Query for the ID of the metastore to delete. + MetastoreId *string `json:"metastore_id,omitempty"` + // A workspace ID. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +type DeleteMetastoreRequest struct { + // Force deletion even if the metastore is not empty. Default is false. + Force *bool `json:"force,omitempty"` + // Unique ID of the metastore. + Id *string `json:"id,omitempty"` +} + +type GetMetastoreSummaryResponse struct { + // Cloud vendor of the metastore home shard (e.g., `aws`, `azure`, `gcp`). + Cloud *string `json:"cloud,omitempty"` + // Time at which this metastore was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of metastore creator. + CreatedBy *string `json:"created_by,omitempty"` + // Unique identifier of the metastore's (Default) Data Access Configuration. + DefaultDataAccessConfigId *string `json:"default_data_access_config_id,omitempty"` + // The organization name of a Delta Sharing entity, to be used in + // Databricks-to-Databricks Delta Sharing as the official name. + DeltaSharingOrganizationName *string `json:"delta_sharing_organization_name,omitempty"` + // The lifetime of delta sharing recipient token in seconds. + DeltaSharingRecipientTokenLifetimeInSeconds *int64 `json:"delta_sharing_recipient_token_lifetime_in_seconds,omitempty"` + // The scope of Delta Sharing enabled for the metastore. + DeltaSharingScope DeltaSharingScope_Enum `json:"delta_sharing_scope,omitempty"` + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled *bool `json:"external_access_enabled,omitempty"` + // Globally unique metastore ID across clouds and regions, of the form + // `cloud:region:metastore_id`. + GlobalMetastoreId *string `json:"global_metastore_id,omitempty"` + // Unique identifier of metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The user-specified name of the metastore. + Name *string `json:"name,omitempty"` + // The owner of the metastore. + Owner *string `json:"owner,omitempty"` + // Privilege model version of the metastore, of the form `major.minor` (e.g., + // `1.0`). + PrivilegeModelVersion *string `json:"privilege_model_version,omitempty"` + // Cloud region which the metastore serves (e.g., `us-west-2`, `westus`). + Region *string `json:"region,omitempty"` + // The storage root URL for metastore + StorageRoot *string `json:"storage_root,omitempty"` + // UUID of storage credential to access the metastore storage_root. + StorageRootCredentialId *string `json:"storage_root_credential_id,omitempty"` + // Name of the storage credential to access the metastore storage_root. + StorageRootCredentialName *string `json:"storage_root_credential_name,omitempty"` + // Time at which the metastore was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the metastore. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type ListMetastoresRequest struct { + // Maximum number of metastores to return. - when set to a value greater than 0, + // the page length is the minimum of this value and a server configured value; - + // when set to 0, the page length is set to a server configured value + // (recommended); - when set to a value less than 0, an invalid parameter error + // is returned; - If not set, all the metastores are returned (not recommended). + // - Note: The number of returned metastores might be less than the specified + // max_results size, even zero. The only definitive indication that no further + // metastores can be fetched is when the next_page_token is unset from the + // response. + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListMetastoresResponse struct { + // An array of metastore information objects. + Metastores []MetastoreInfo `json:"metastores,omitempty"` + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type MetastoreAssignment struct { + // The name of the default catalog in the metastore. This field is deprecated. + // Please use "Default Namespace API" to configure the default catalog for a + // workspace. + DefaultCatalogName *string `json:"default_catalog_name,omitempty"` + // The unique ID of the metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The unique ID of the workspace. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +type MetastoreInfo struct { + // Cloud vendor of the metastore home shard (e.g., `aws`, `azure`, `gcp`). + Cloud *string `json:"cloud,omitempty"` + // Time at which this metastore was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of metastore creator. + CreatedBy *string `json:"created_by,omitempty"` + // Unique identifier of the metastore's (Default) Data Access Configuration. + DefaultDataAccessConfigId *string `json:"default_data_access_config_id,omitempty"` + // The organization name of a Delta Sharing entity, to be used in + // Databricks-to-Databricks Delta Sharing as the official name. + DeltaSharingOrganizationName *string `json:"delta_sharing_organization_name,omitempty"` + // The lifetime of delta sharing recipient token in seconds. + DeltaSharingRecipientTokenLifetimeInSeconds *int64 `json:"delta_sharing_recipient_token_lifetime_in_seconds,omitempty"` + // The scope of Delta Sharing enabled for the metastore. + DeltaSharingScope DeltaSharingScope_Enum `json:"delta_sharing_scope,omitempty"` + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled *bool `json:"external_access_enabled,omitempty"` + // Globally unique metastore ID across clouds and regions, of the form + // `cloud:region:metastore_id`. + GlobalMetastoreId *string `json:"global_metastore_id,omitempty"` + // Unique identifier of metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The user-specified name of the metastore. + Name *string `json:"name,omitempty"` + // The owner of the metastore. + Owner *string `json:"owner,omitempty"` + // Privilege model version of the metastore, of the form `major.minor` (e.g., + // `1.0`). + PrivilegeModelVersion *string `json:"privilege_model_version,omitempty"` + // Cloud region which the metastore serves (e.g., `us-west-2`, `westus`). + Region *string `json:"region,omitempty"` + // The storage root URL for metastore + StorageRoot *string `json:"storage_root,omitempty"` + // UUID of storage credential to access the metastore storage_root. + StorageRootCredentialId *string `json:"storage_root_credential_id,omitempty"` + // Name of the storage credential to access the metastore storage_root. + StorageRootCredentialName *string `json:"storage_root_credential_name,omitempty"` + // Time at which the metastore was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the metastore. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type UpdateAccountsMetastore struct { + // Cloud vendor of the metastore home shard (e.g., `aws`, `azure`, `gcp`). + Cloud *string `json:"cloud,omitempty"` + // Time at which this metastore was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of metastore creator. + CreatedBy *string `json:"created_by,omitempty"` + // Unique identifier of the metastore's (Default) Data Access Configuration. + DefaultDataAccessConfigId *string `json:"default_data_access_config_id,omitempty"` + // The organization name of a Delta Sharing entity, to be used in + // Databricks-to-Databricks Delta Sharing as the official name. + DeltaSharingOrganizationName *string `json:"delta_sharing_organization_name,omitempty"` + // The lifetime of delta sharing recipient token in seconds. + DeltaSharingRecipientTokenLifetimeInSeconds *int64 `json:"delta_sharing_recipient_token_lifetime_in_seconds,omitempty"` + // The scope of Delta Sharing enabled for the metastore. + DeltaSharingScope DeltaSharingScope_Enum `json:"delta_sharing_scope,omitempty"` + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled *bool `json:"external_access_enabled,omitempty"` + // Globally unique metastore ID across clouds and regions, of the form + // `cloud:region:metastore_id`. + GlobalMetastoreId *string `json:"global_metastore_id,omitempty"` + // Unique identifier of metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The user-specified name of the metastore. + Name *string `json:"name,omitempty"` + // The owner of the metastore. + Owner *string `json:"owner,omitempty"` + // Privilege model version of the metastore, of the form `major.minor` (e.g., + // `1.0`). + PrivilegeModelVersion *string `json:"privilege_model_version,omitempty"` + // Cloud region which the metastore serves (e.g., `us-west-2`, `westus`). + Region *string `json:"region,omitempty"` + // The storage root URL for metastore + StorageRoot *string `json:"storage_root,omitempty"` + // UUID of storage credential to access the metastore storage_root. + StorageRootCredentialId *string `json:"storage_root_credential_id,omitempty"` + // Name of the storage credential to access the metastore storage_root. + StorageRootCredentialName *string `json:"storage_root_credential_name,omitempty"` + // Time at which the metastore was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the metastore. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type UpdateMetastoreAssignmentRequest struct { + // The name of the default catalog in the metastore. This field is deprecated. + // Please use "Default Namespace API" to configure the default catalog for a + // workspace. + DefaultCatalogName *string `json:"default_catalog_name,omitempty"` + // The unique ID of the metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // A workspace ID. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +type UpdateMetastoreRequest struct { + // Cloud vendor of the metastore home shard (e.g., `aws`, `azure`, `gcp`). + Cloud *string `json:"cloud,omitempty"` + // Time at which this metastore was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of metastore creator. + CreatedBy *string `json:"created_by,omitempty"` + // Unique identifier of the metastore's (Default) Data Access Configuration. + DefaultDataAccessConfigId *string `json:"default_data_access_config_id,omitempty"` + // The organization name of a Delta Sharing entity, to be used in + // Databricks-to-Databricks Delta Sharing as the official name. + DeltaSharingOrganizationName *string `json:"delta_sharing_organization_name,omitempty"` + // The lifetime of delta sharing recipient token in seconds. + DeltaSharingRecipientTokenLifetimeInSeconds *int64 `json:"delta_sharing_recipient_token_lifetime_in_seconds,omitempty"` + // The scope of Delta Sharing enabled for the metastore. + DeltaSharingScope DeltaSharingScope_Enum `json:"delta_sharing_scope,omitempty"` + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled *bool `json:"external_access_enabled,omitempty"` + // Globally unique metastore ID across clouds and regions, of the form + // `cloud:region:metastore_id`. + GlobalMetastoreId *string `json:"global_metastore_id,omitempty"` + // Unique ID of the metastore. + Id *string `json:"id,omitempty"` + // Unique identifier of metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // The user-specified name of the metastore. + Name *string `json:"name,omitempty"` + // New name for the metastore. + NewName *string `json:"new_name,omitempty"` + // The owner of the metastore. + Owner *string `json:"owner,omitempty"` + // Privilege model version of the metastore, of the form `major.minor` (e.g., + // `1.0`). + PrivilegeModelVersion *string `json:"privilege_model_version,omitempty"` + // Cloud region which the metastore serves (e.g., `us-west-2`, `westus`). + Region *string `json:"region,omitempty"` + // The storage root URL for metastore + StorageRoot *string `json:"storage_root,omitempty"` + // UUID of storage credential to access the metastore storage_root. + StorageRootCredentialId *string `json:"storage_root_credential_id,omitempty"` + // Name of the storage credential to access the metastore storage_root. + StorageRootCredentialName *string `json:"storage_root_credential_name,omitempty"` + // Time at which the metastore was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the metastore. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// AccountsCreateMetastoreAssignmentRequestToSDK converts the mirror to the sdk-go type. +func AccountsCreateMetastoreAssignmentRequestToSDK(w *AccountsCreateMetastoreAssignmentRequest) (*sdk.AccountsCreateMetastoreAssignmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsCreateMetastoreAssignmentRequest{} + out.AccountId = w.AccountId + out.WorkspaceId = w.WorkspaceId + out.MetastoreId = w.MetastoreId + conv1, err := MetastoreAssignmentToSDK(w.MetastoreAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsCreateMetastoreAssignmentRequest.MetastoreAssignment", err) + } + out.MetastoreAssignment = conv1 + return out, nil +} + +// AccountsCreateMetastoreAssignmentRequestFromSDK converts the sdk-go type to the mirror. +func AccountsCreateMetastoreAssignmentRequestFromSDK(v *sdk.AccountsCreateMetastoreAssignmentRequest) (*AccountsCreateMetastoreAssignmentRequest, error) { + if v == nil { + return nil, nil + } + out := &AccountsCreateMetastoreAssignmentRequest{} + out.AccountId = v.AccountId + out.WorkspaceId = v.WorkspaceId + out.MetastoreId = v.MetastoreId + conv2, err := MetastoreAssignmentFromSDK(v.MetastoreAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsCreateMetastoreAssignmentRequest.MetastoreAssignment", err) + } + out.MetastoreAssignment = conv2 + return out, nil +} + +// AccountsCreateMetastoreRequestToSDK converts the mirror to the sdk-go type. +func AccountsCreateMetastoreRequestToSDK(w *AccountsCreateMetastoreRequest) (*sdk.AccountsCreateMetastoreRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsCreateMetastoreRequest{} + out.AccountId = w.AccountId + conv3, err := CreateAccountsMetastoreToSDK(w.MetastoreInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsCreateMetastoreRequest.MetastoreInfo", err) + } + out.MetastoreInfo = conv3 + return out, nil +} + +// AccountsCreateMetastoreRequestFromSDK converts the sdk-go type to the mirror. +func AccountsCreateMetastoreRequestFromSDK(v *sdk.AccountsCreateMetastoreRequest) (*AccountsCreateMetastoreRequest, error) { + if v == nil { + return nil, nil + } + out := &AccountsCreateMetastoreRequest{} + out.AccountId = v.AccountId + conv4, err := CreateAccountsMetastoreFromSDK(v.MetastoreInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsCreateMetastoreRequest.MetastoreInfo", err) + } + out.MetastoreInfo = conv4 + return out, nil +} + +// AccountsCreateMetastoreResponseToSDK converts the mirror to the sdk-go type. +func AccountsCreateMetastoreResponseToSDK(w *AccountsCreateMetastoreResponse) (*sdk.AccountsCreateMetastoreResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsCreateMetastoreResponse{} + conv5, err := MetastoreInfoToSDK(w.MetastoreInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsCreateMetastoreResponse.MetastoreInfo", err) + } + out.MetastoreInfo = conv5 + return out, nil +} + +// AccountsCreateMetastoreResponseFromSDK converts the sdk-go type to the mirror. +func AccountsCreateMetastoreResponseFromSDK(v *sdk.AccountsCreateMetastoreResponse) (*AccountsCreateMetastoreResponse, error) { + if v == nil { + return nil, nil + } + out := &AccountsCreateMetastoreResponse{} + conv6, err := MetastoreInfoFromSDK(v.MetastoreInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsCreateMetastoreResponse.MetastoreInfo", err) + } + out.MetastoreInfo = conv6 + return out, nil +} + +// AccountsDeleteMetastoreRequestToSDK converts the mirror to the sdk-go type. +func AccountsDeleteMetastoreRequestToSDK(w *AccountsDeleteMetastoreRequest) (*sdk.AccountsDeleteMetastoreRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsDeleteMetastoreRequest{} + out.AccountId = w.AccountId + out.MetastoreId = w.MetastoreId + out.Force = w.Force + return out, nil +} + +// AccountsDeleteMetastoreRequestFromSDK converts the sdk-go type to the mirror. +func AccountsDeleteMetastoreRequestFromSDK(v *sdk.AccountsDeleteMetastoreRequest) (*AccountsDeleteMetastoreRequest, error) { + if v == nil { + return nil, nil + } + out := &AccountsDeleteMetastoreRequest{} + out.AccountId = v.AccountId + out.MetastoreId = v.MetastoreId + out.Force = v.Force + return out, nil +} + +// AccountsGetMetastoreAssignmentResponseToSDK converts the mirror to the sdk-go type. +func AccountsGetMetastoreAssignmentResponseToSDK(w *AccountsGetMetastoreAssignmentResponse) (*sdk.AccountsGetMetastoreAssignmentResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsGetMetastoreAssignmentResponse{} + conv7, err := MetastoreAssignmentToSDK(w.MetastoreAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsGetMetastoreAssignmentResponse.MetastoreAssignment", err) + } + out.MetastoreAssignment = conv7 + return out, nil +} + +// AccountsGetMetastoreAssignmentResponseFromSDK converts the sdk-go type to the mirror. +func AccountsGetMetastoreAssignmentResponseFromSDK(v *sdk.AccountsGetMetastoreAssignmentResponse) (*AccountsGetMetastoreAssignmentResponse, error) { + if v == nil { + return nil, nil + } + out := &AccountsGetMetastoreAssignmentResponse{} + conv8, err := MetastoreAssignmentFromSDK(v.MetastoreAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsGetMetastoreAssignmentResponse.MetastoreAssignment", err) + } + out.MetastoreAssignment = conv8 + return out, nil +} + +// AccountsGetMetastoreResponseToSDK converts the mirror to the sdk-go type. +func AccountsGetMetastoreResponseToSDK(w *AccountsGetMetastoreResponse) (*sdk.AccountsGetMetastoreResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsGetMetastoreResponse{} + conv9, err := MetastoreInfoToSDK(w.MetastoreInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsGetMetastoreResponse.MetastoreInfo", err) + } + out.MetastoreInfo = conv9 + return out, nil +} + +// AccountsGetMetastoreResponseFromSDK converts the sdk-go type to the mirror. +func AccountsGetMetastoreResponseFromSDK(v *sdk.AccountsGetMetastoreResponse) (*AccountsGetMetastoreResponse, error) { + if v == nil { + return nil, nil + } + out := &AccountsGetMetastoreResponse{} + conv10, err := MetastoreInfoFromSDK(v.MetastoreInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsGetMetastoreResponse.MetastoreInfo", err) + } + out.MetastoreInfo = conv10 + return out, nil +} + +// AccountsListMetastoresResponseToSDK converts the mirror to the sdk-go type. +func AccountsListMetastoresResponseToSDK(w *AccountsListMetastoresResponse) (*sdk.AccountsListMetastoresResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsListMetastoresResponse{} + conv11, err := convertSlice(w.Metastores, MetastoreInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsListMetastoresResponse.Metastores", err) + } + out.Metastores = conv11 + return out, nil +} + +// AccountsListMetastoresResponseFromSDK converts the sdk-go type to the mirror. +func AccountsListMetastoresResponseFromSDK(v *sdk.AccountsListMetastoresResponse) (*AccountsListMetastoresResponse, error) { + if v == nil { + return nil, nil + } + out := &AccountsListMetastoresResponse{} + conv12, err := convertSlice(v.Metastores, MetastoreInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsListMetastoresResponse.Metastores", err) + } + out.Metastores = conv12 + return out, nil +} + +// AccountsListWorkspaceIdsForMetastoreResponseToSDK converts the mirror to the sdk-go type. +func AccountsListWorkspaceIdsForMetastoreResponseToSDK(w *AccountsListWorkspaceIdsForMetastoreResponse) (*sdk.AccountsListWorkspaceIdsForMetastoreResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsListWorkspaceIdsForMetastoreResponse{} + out.WorkspaceIds = w.WorkspaceIds + return out, nil +} + +// AccountsListWorkspaceIdsForMetastoreResponseFromSDK converts the sdk-go type to the mirror. +func AccountsListWorkspaceIdsForMetastoreResponseFromSDK(v *sdk.AccountsListWorkspaceIdsForMetastoreResponse) (*AccountsListWorkspaceIdsForMetastoreResponse, error) { + if v == nil { + return nil, nil + } + out := &AccountsListWorkspaceIdsForMetastoreResponse{} + out.WorkspaceIds = v.WorkspaceIds + return out, nil +} + +// AccountsUpdateMetastoreAssignmentRequestToSDK converts the mirror to the sdk-go type. +func AccountsUpdateMetastoreAssignmentRequestToSDK(w *AccountsUpdateMetastoreAssignmentRequest) (*sdk.AccountsUpdateMetastoreAssignmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsUpdateMetastoreAssignmentRequest{} + out.AccountId = w.AccountId + out.WorkspaceId = w.WorkspaceId + out.MetastoreId = w.MetastoreId + conv13, err := MetastoreAssignmentToSDK(w.MetastoreAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsUpdateMetastoreAssignmentRequest.MetastoreAssignment", err) + } + out.MetastoreAssignment = conv13 + return out, nil +} + +// AccountsUpdateMetastoreAssignmentRequestFromSDK converts the sdk-go type to the mirror. +func AccountsUpdateMetastoreAssignmentRequestFromSDK(v *sdk.AccountsUpdateMetastoreAssignmentRequest) (*AccountsUpdateMetastoreAssignmentRequest, error) { + if v == nil { + return nil, nil + } + out := &AccountsUpdateMetastoreAssignmentRequest{} + out.AccountId = v.AccountId + out.WorkspaceId = v.WorkspaceId + out.MetastoreId = v.MetastoreId + conv14, err := MetastoreAssignmentFromSDK(v.MetastoreAssignment) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsUpdateMetastoreAssignmentRequest.MetastoreAssignment", err) + } + out.MetastoreAssignment = conv14 + return out, nil +} + +// AccountsUpdateMetastoreRequestToSDK converts the mirror to the sdk-go type. +func AccountsUpdateMetastoreRequestToSDK(w *AccountsUpdateMetastoreRequest) (*sdk.AccountsUpdateMetastoreRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsUpdateMetastoreRequest{} + out.AccountId = w.AccountId + out.MetastoreId = w.MetastoreId + conv15, err := UpdateAccountsMetastoreToSDK(w.MetastoreInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsUpdateMetastoreRequest.MetastoreInfo", err) + } + out.MetastoreInfo = conv15 + return out, nil +} + +// AccountsUpdateMetastoreRequestFromSDK converts the sdk-go type to the mirror. +func AccountsUpdateMetastoreRequestFromSDK(v *sdk.AccountsUpdateMetastoreRequest) (*AccountsUpdateMetastoreRequest, error) { + if v == nil { + return nil, nil + } + out := &AccountsUpdateMetastoreRequest{} + out.AccountId = v.AccountId + out.MetastoreId = v.MetastoreId + conv16, err := UpdateAccountsMetastoreFromSDK(v.MetastoreInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsUpdateMetastoreRequest.MetastoreInfo", err) + } + out.MetastoreInfo = conv16 + return out, nil +} + +// AccountsUpdateMetastoreResponseToSDK converts the mirror to the sdk-go type. +func AccountsUpdateMetastoreResponseToSDK(w *AccountsUpdateMetastoreResponse) (*sdk.AccountsUpdateMetastoreResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccountsUpdateMetastoreResponse{} + conv17, err := MetastoreInfoToSDK(w.MetastoreInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsUpdateMetastoreResponse.MetastoreInfo", err) + } + out.MetastoreInfo = conv17 + return out, nil +} + +// AccountsUpdateMetastoreResponseFromSDK converts the sdk-go type to the mirror. +func AccountsUpdateMetastoreResponseFromSDK(v *sdk.AccountsUpdateMetastoreResponse) (*AccountsUpdateMetastoreResponse, error) { + if v == nil { + return nil, nil + } + out := &AccountsUpdateMetastoreResponse{} + conv18, err := MetastoreInfoFromSDK(v.MetastoreInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccountsUpdateMetastoreResponse.MetastoreInfo", err) + } + out.MetastoreInfo = conv18 + return out, nil +} + +// CreateAccountsMetastoreToSDK converts the mirror to the sdk-go type. +func CreateAccountsMetastoreToSDK(w *CreateAccountsMetastore) (*sdk.CreateAccountsMetastore, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAccountsMetastore{} + out.Name = w.Name + out.StorageRoot = w.StorageRoot + out.DefaultDataAccessConfigId = w.DefaultDataAccessConfigId + out.StorageRootCredentialId = w.StorageRootCredentialId + out.DeltaSharingScope = w.DeltaSharingScope + out.DeltaSharingRecipientTokenLifetimeInSeconds = w.DeltaSharingRecipientTokenLifetimeInSeconds + out.DeltaSharingOrganizationName = w.DeltaSharingOrganizationName + out.Owner = w.Owner + out.PrivilegeModelVersion = w.PrivilegeModelVersion + out.Region = w.Region + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.StorageRootCredentialName = w.StorageRootCredentialName + out.Cloud = w.Cloud + out.GlobalMetastoreId = w.GlobalMetastoreId + out.ExternalAccessEnabled = w.ExternalAccessEnabled + return out, nil +} + +// CreateAccountsMetastoreFromSDK converts the sdk-go type to the mirror. +func CreateAccountsMetastoreFromSDK(v *sdk.CreateAccountsMetastore) (*CreateAccountsMetastore, error) { + if v == nil { + return nil, nil + } + out := &CreateAccountsMetastore{} + out.Name = v.Name + out.StorageRoot = v.StorageRoot + out.DefaultDataAccessConfigId = v.DefaultDataAccessConfigId + out.StorageRootCredentialId = v.StorageRootCredentialId + out.DeltaSharingScope = v.DeltaSharingScope + out.DeltaSharingRecipientTokenLifetimeInSeconds = v.DeltaSharingRecipientTokenLifetimeInSeconds + out.DeltaSharingOrganizationName = v.DeltaSharingOrganizationName + out.Owner = v.Owner + out.PrivilegeModelVersion = v.PrivilegeModelVersion + out.Region = v.Region + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.StorageRootCredentialName = v.StorageRootCredentialName + out.Cloud = v.Cloud + out.GlobalMetastoreId = v.GlobalMetastoreId + out.ExternalAccessEnabled = v.ExternalAccessEnabled + return out, nil +} + +// CreateMetastoreAssignmentRequestToSDK converts the mirror to the sdk-go type. +func CreateMetastoreAssignmentRequestToSDK(w *CreateMetastoreAssignmentRequest) (*sdk.CreateMetastoreAssignmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateMetastoreAssignmentRequest{} + out.WorkspaceId = w.WorkspaceId + out.MetastoreId = w.MetastoreId + out.DefaultCatalogName = w.DefaultCatalogName + return out, nil +} + +// CreateMetastoreAssignmentRequestFromSDK converts the sdk-go type to the mirror. +func CreateMetastoreAssignmentRequestFromSDK(v *sdk.CreateMetastoreAssignmentRequest) (*CreateMetastoreAssignmentRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateMetastoreAssignmentRequest{} + out.WorkspaceId = v.WorkspaceId + out.MetastoreId = v.MetastoreId + out.DefaultCatalogName = v.DefaultCatalogName + return out, nil +} + +// CreateMetastoreRequestToSDK converts the mirror to the sdk-go type. +func CreateMetastoreRequestToSDK(w *CreateMetastoreRequest) (*sdk.CreateMetastoreRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateMetastoreRequest{} + out.Name = w.Name + out.StorageRoot = w.StorageRoot + out.DefaultDataAccessConfigId = w.DefaultDataAccessConfigId + out.StorageRootCredentialId = w.StorageRootCredentialId + out.DeltaSharingScope = w.DeltaSharingScope + out.DeltaSharingRecipientTokenLifetimeInSeconds = w.DeltaSharingRecipientTokenLifetimeInSeconds + out.DeltaSharingOrganizationName = w.DeltaSharingOrganizationName + out.Owner = w.Owner + out.PrivilegeModelVersion = w.PrivilegeModelVersion + out.Region = w.Region + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.StorageRootCredentialName = w.StorageRootCredentialName + out.Cloud = w.Cloud + out.GlobalMetastoreId = w.GlobalMetastoreId + out.ExternalAccessEnabled = w.ExternalAccessEnabled + return out, nil +} + +// CreateMetastoreRequestFromSDK converts the sdk-go type to the mirror. +func CreateMetastoreRequestFromSDK(v *sdk.CreateMetastoreRequest) (*CreateMetastoreRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateMetastoreRequest{} + out.Name = v.Name + out.StorageRoot = v.StorageRoot + out.DefaultDataAccessConfigId = v.DefaultDataAccessConfigId + out.StorageRootCredentialId = v.StorageRootCredentialId + out.DeltaSharingScope = v.DeltaSharingScope + out.DeltaSharingRecipientTokenLifetimeInSeconds = v.DeltaSharingRecipientTokenLifetimeInSeconds + out.DeltaSharingOrganizationName = v.DeltaSharingOrganizationName + out.Owner = v.Owner + out.PrivilegeModelVersion = v.PrivilegeModelVersion + out.Region = v.Region + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.StorageRootCredentialName = v.StorageRootCredentialName + out.Cloud = v.Cloud + out.GlobalMetastoreId = v.GlobalMetastoreId + out.ExternalAccessEnabled = v.ExternalAccessEnabled + return out, nil +} + +// DeleteMetastoreAssignmentRequestToSDK converts the mirror to the sdk-go type. +func DeleteMetastoreAssignmentRequestToSDK(w *DeleteMetastoreAssignmentRequest) (*sdk.DeleteMetastoreAssignmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteMetastoreAssignmentRequest{} + out.WorkspaceId = w.WorkspaceId + out.MetastoreId = w.MetastoreId + return out, nil +} + +// DeleteMetastoreAssignmentRequestFromSDK converts the sdk-go type to the mirror. +func DeleteMetastoreAssignmentRequestFromSDK(v *sdk.DeleteMetastoreAssignmentRequest) (*DeleteMetastoreAssignmentRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteMetastoreAssignmentRequest{} + out.WorkspaceId = v.WorkspaceId + out.MetastoreId = v.MetastoreId + return out, nil +} + +// DeleteMetastoreRequestToSDK converts the mirror to the sdk-go type. +func DeleteMetastoreRequestToSDK(w *DeleteMetastoreRequest) (*sdk.DeleteMetastoreRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteMetastoreRequest{} + out.Id = w.Id + out.Force = w.Force + return out, nil +} + +// DeleteMetastoreRequestFromSDK converts the sdk-go type to the mirror. +func DeleteMetastoreRequestFromSDK(v *sdk.DeleteMetastoreRequest) (*DeleteMetastoreRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteMetastoreRequest{} + out.Id = v.Id + out.Force = v.Force + return out, nil +} + +// GetMetastoreSummaryResponseToSDK converts the mirror to the sdk-go type. +func GetMetastoreSummaryResponseToSDK(w *GetMetastoreSummaryResponse) (*sdk.GetMetastoreSummaryResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetMetastoreSummaryResponse{} + out.MetastoreId = w.MetastoreId + out.Name = w.Name + out.DefaultDataAccessConfigId = w.DefaultDataAccessConfigId + out.StorageRootCredentialId = w.StorageRootCredentialId + out.Cloud = w.Cloud + out.Region = w.Region + out.GlobalMetastoreId = w.GlobalMetastoreId + out.StorageRootCredentialName = w.StorageRootCredentialName + out.PrivilegeModelVersion = w.PrivilegeModelVersion + out.DeltaSharingScope = w.DeltaSharingScope + out.DeltaSharingRecipientTokenLifetimeInSeconds = w.DeltaSharingRecipientTokenLifetimeInSeconds + out.DeltaSharingOrganizationName = w.DeltaSharingOrganizationName + out.StorageRoot = w.StorageRoot + out.Owner = w.Owner + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.ExternalAccessEnabled = w.ExternalAccessEnabled + return out, nil +} + +// GetMetastoreSummaryResponseFromSDK converts the sdk-go type to the mirror. +func GetMetastoreSummaryResponseFromSDK(v *sdk.GetMetastoreSummaryResponse) (*GetMetastoreSummaryResponse, error) { + if v == nil { + return nil, nil + } + out := &GetMetastoreSummaryResponse{} + out.MetastoreId = v.MetastoreId + out.Name = v.Name + out.DefaultDataAccessConfigId = v.DefaultDataAccessConfigId + out.StorageRootCredentialId = v.StorageRootCredentialId + out.Cloud = v.Cloud + out.Region = v.Region + out.GlobalMetastoreId = v.GlobalMetastoreId + out.StorageRootCredentialName = v.StorageRootCredentialName + out.PrivilegeModelVersion = v.PrivilegeModelVersion + out.DeltaSharingScope = v.DeltaSharingScope + out.DeltaSharingRecipientTokenLifetimeInSeconds = v.DeltaSharingRecipientTokenLifetimeInSeconds + out.DeltaSharingOrganizationName = v.DeltaSharingOrganizationName + out.StorageRoot = v.StorageRoot + out.Owner = v.Owner + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.ExternalAccessEnabled = v.ExternalAccessEnabled + return out, nil +} + +// ListMetastoresRequestToSDK converts the mirror to the sdk-go type. +func ListMetastoresRequestToSDK(w *ListMetastoresRequest) (*sdk.ListMetastoresRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListMetastoresRequest{} + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListMetastoresRequestFromSDK converts the sdk-go type to the mirror. +func ListMetastoresRequestFromSDK(v *sdk.ListMetastoresRequest) (*ListMetastoresRequest, error) { + if v == nil { + return nil, nil + } + out := &ListMetastoresRequest{} + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListMetastoresResponseToSDK converts the mirror to the sdk-go type. +func ListMetastoresResponseToSDK(w *ListMetastoresResponse) (*sdk.ListMetastoresResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListMetastoresResponse{} + conv19, err := convertSlice(w.Metastores, MetastoreInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListMetastoresResponse.Metastores", err) + } + out.Metastores = conv19 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListMetastoresResponseFromSDK converts the sdk-go type to the mirror. +func ListMetastoresResponseFromSDK(v *sdk.ListMetastoresResponse) (*ListMetastoresResponse, error) { + if v == nil { + return nil, nil + } + out := &ListMetastoresResponse{} + conv20, err := convertSlice(v.Metastores, MetastoreInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListMetastoresResponse.Metastores", err) + } + out.Metastores = conv20 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// MetastoreAssignmentToSDK converts the mirror to the sdk-go type. +func MetastoreAssignmentToSDK(w *MetastoreAssignment) (*sdk.MetastoreAssignment, error) { + if w == nil { + return nil, nil + } + out := &sdk.MetastoreAssignment{} + out.WorkspaceId = w.WorkspaceId + out.MetastoreId = w.MetastoreId + out.DefaultCatalogName = w.DefaultCatalogName + return out, nil +} + +// MetastoreAssignmentFromSDK converts the sdk-go type to the mirror. +func MetastoreAssignmentFromSDK(v *sdk.MetastoreAssignment) (*MetastoreAssignment, error) { + if v == nil { + return nil, nil + } + out := &MetastoreAssignment{} + out.WorkspaceId = v.WorkspaceId + out.MetastoreId = v.MetastoreId + out.DefaultCatalogName = v.DefaultCatalogName + return out, nil +} + +// MetastoreInfoToSDK converts the mirror to the sdk-go type. +func MetastoreInfoToSDK(w *MetastoreInfo) (*sdk.MetastoreInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.MetastoreInfo{} + out.Name = w.Name + out.StorageRoot = w.StorageRoot + out.DefaultDataAccessConfigId = w.DefaultDataAccessConfigId + out.StorageRootCredentialId = w.StorageRootCredentialId + out.DeltaSharingScope = w.DeltaSharingScope + out.DeltaSharingRecipientTokenLifetimeInSeconds = w.DeltaSharingRecipientTokenLifetimeInSeconds + out.DeltaSharingOrganizationName = w.DeltaSharingOrganizationName + out.Owner = w.Owner + out.PrivilegeModelVersion = w.PrivilegeModelVersion + out.Region = w.Region + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.StorageRootCredentialName = w.StorageRootCredentialName + out.Cloud = w.Cloud + out.GlobalMetastoreId = w.GlobalMetastoreId + out.ExternalAccessEnabled = w.ExternalAccessEnabled + return out, nil +} + +// MetastoreInfoFromSDK converts the sdk-go type to the mirror. +func MetastoreInfoFromSDK(v *sdk.MetastoreInfo) (*MetastoreInfo, error) { + if v == nil { + return nil, nil + } + out := &MetastoreInfo{} + out.Name = v.Name + out.StorageRoot = v.StorageRoot + out.DefaultDataAccessConfigId = v.DefaultDataAccessConfigId + out.StorageRootCredentialId = v.StorageRootCredentialId + out.DeltaSharingScope = v.DeltaSharingScope + out.DeltaSharingRecipientTokenLifetimeInSeconds = v.DeltaSharingRecipientTokenLifetimeInSeconds + out.DeltaSharingOrganizationName = v.DeltaSharingOrganizationName + out.Owner = v.Owner + out.PrivilegeModelVersion = v.PrivilegeModelVersion + out.Region = v.Region + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.StorageRootCredentialName = v.StorageRootCredentialName + out.Cloud = v.Cloud + out.GlobalMetastoreId = v.GlobalMetastoreId + out.ExternalAccessEnabled = v.ExternalAccessEnabled + return out, nil +} + +// UpdateAccountsMetastoreToSDK converts the mirror to the sdk-go type. +func UpdateAccountsMetastoreToSDK(w *UpdateAccountsMetastore) (*sdk.UpdateAccountsMetastore, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAccountsMetastore{} + out.Name = w.Name + out.StorageRoot = w.StorageRoot + out.DefaultDataAccessConfigId = w.DefaultDataAccessConfigId + out.StorageRootCredentialId = w.StorageRootCredentialId + out.DeltaSharingScope = w.DeltaSharingScope + out.DeltaSharingRecipientTokenLifetimeInSeconds = w.DeltaSharingRecipientTokenLifetimeInSeconds + out.DeltaSharingOrganizationName = w.DeltaSharingOrganizationName + out.Owner = w.Owner + out.PrivilegeModelVersion = w.PrivilegeModelVersion + out.Region = w.Region + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.StorageRootCredentialName = w.StorageRootCredentialName + out.Cloud = w.Cloud + out.GlobalMetastoreId = w.GlobalMetastoreId + out.ExternalAccessEnabled = w.ExternalAccessEnabled + return out, nil +} + +// UpdateAccountsMetastoreFromSDK converts the sdk-go type to the mirror. +func UpdateAccountsMetastoreFromSDK(v *sdk.UpdateAccountsMetastore) (*UpdateAccountsMetastore, error) { + if v == nil { + return nil, nil + } + out := &UpdateAccountsMetastore{} + out.Name = v.Name + out.StorageRoot = v.StorageRoot + out.DefaultDataAccessConfigId = v.DefaultDataAccessConfigId + out.StorageRootCredentialId = v.StorageRootCredentialId + out.DeltaSharingScope = v.DeltaSharingScope + out.DeltaSharingRecipientTokenLifetimeInSeconds = v.DeltaSharingRecipientTokenLifetimeInSeconds + out.DeltaSharingOrganizationName = v.DeltaSharingOrganizationName + out.Owner = v.Owner + out.PrivilegeModelVersion = v.PrivilegeModelVersion + out.Region = v.Region + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.StorageRootCredentialName = v.StorageRootCredentialName + out.Cloud = v.Cloud + out.GlobalMetastoreId = v.GlobalMetastoreId + out.ExternalAccessEnabled = v.ExternalAccessEnabled + return out, nil +} + +// UpdateMetastoreAssignmentRequestToSDK converts the mirror to the sdk-go type. +func UpdateMetastoreAssignmentRequestToSDK(w *UpdateMetastoreAssignmentRequest) (*sdk.UpdateMetastoreAssignmentRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateMetastoreAssignmentRequest{} + out.WorkspaceId = w.WorkspaceId + out.MetastoreId = w.MetastoreId + out.DefaultCatalogName = w.DefaultCatalogName + return out, nil +} + +// UpdateMetastoreAssignmentRequestFromSDK converts the sdk-go type to the mirror. +func UpdateMetastoreAssignmentRequestFromSDK(v *sdk.UpdateMetastoreAssignmentRequest) (*UpdateMetastoreAssignmentRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateMetastoreAssignmentRequest{} + out.WorkspaceId = v.WorkspaceId + out.MetastoreId = v.MetastoreId + out.DefaultCatalogName = v.DefaultCatalogName + return out, nil +} + +// UpdateMetastoreRequestToSDK converts the mirror to the sdk-go type. +func UpdateMetastoreRequestToSDK(w *UpdateMetastoreRequest) (*sdk.UpdateMetastoreRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateMetastoreRequest{} + out.Id = w.Id + out.NewName = w.NewName + out.Name = w.Name + out.StorageRoot = w.StorageRoot + out.DefaultDataAccessConfigId = w.DefaultDataAccessConfigId + out.StorageRootCredentialId = w.StorageRootCredentialId + out.DeltaSharingScope = w.DeltaSharingScope + out.DeltaSharingRecipientTokenLifetimeInSeconds = w.DeltaSharingRecipientTokenLifetimeInSeconds + out.DeltaSharingOrganizationName = w.DeltaSharingOrganizationName + out.Owner = w.Owner + out.PrivilegeModelVersion = w.PrivilegeModelVersion + out.Region = w.Region + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.StorageRootCredentialName = w.StorageRootCredentialName + out.Cloud = w.Cloud + out.GlobalMetastoreId = w.GlobalMetastoreId + out.ExternalAccessEnabled = w.ExternalAccessEnabled + return out, nil +} + +// UpdateMetastoreRequestFromSDK converts the sdk-go type to the mirror. +func UpdateMetastoreRequestFromSDK(v *sdk.UpdateMetastoreRequest) (*UpdateMetastoreRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateMetastoreRequest{} + out.Id = v.Id + out.NewName = v.NewName + out.Name = v.Name + out.StorageRoot = v.StorageRoot + out.DefaultDataAccessConfigId = v.DefaultDataAccessConfigId + out.StorageRootCredentialId = v.StorageRootCredentialId + out.DeltaSharingScope = v.DeltaSharingScope + out.DeltaSharingRecipientTokenLifetimeInSeconds = v.DeltaSharingRecipientTokenLifetimeInSeconds + out.DeltaSharingOrganizationName = v.DeltaSharingOrganizationName + out.Owner = v.Owner + out.PrivilegeModelVersion = v.PrivilegeModelVersion + out.Region = v.Region + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.StorageRootCredentialName = v.StorageRootCredentialName + out.Cloud = v.Cloud + out.GlobalMetastoreId = v.GlobalMetastoreId + out.ExternalAccessEnabled = v.ExternalAccessEnabled + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/onlinetables/v1/types.generated.go b/libs/sdktypes/uc/onlinetables/v1/types.generated.go new file mode 100644 index 00000000000..10ee39d1685 --- /dev/null +++ b/libs/sdktypes/uc/onlinetables/v1/types.generated.go @@ -0,0 +1,588 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/onlinetables/v1. DO NOT EDIT. + +package onlinetables + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/onlinetables/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + OnlineTableState = sdk.OnlineTableState + ProvisioningInfo_State = sdk.ProvisioningInfo_State +) + +const ( + OnlineTableState_Unspecified = sdk.OnlineTableState_Unspecified + OnlineTableState_Provisioning = sdk.OnlineTableState_Provisioning + OnlineTableState_ProvisioningPipelineResources = sdk.OnlineTableState_ProvisioningPipelineResources + OnlineTableState_ProvisioningInitialSnapshot = sdk.OnlineTableState_ProvisioningInitialSnapshot + OnlineTableState_Online = sdk.OnlineTableState_Online + OnlineTableState_OnlineContinuousUpdate = sdk.OnlineTableState_OnlineContinuousUpdate + OnlineTableState_OnlineTriggeredUpdate = sdk.OnlineTableState_OnlineTriggeredUpdate + OnlineTableState_OnlineNoPendingUpdate = sdk.OnlineTableState_OnlineNoPendingUpdate + OnlineTableState_Offline = sdk.OnlineTableState_Offline + OnlineTableState_OfflineFailed = sdk.OnlineTableState_OfflineFailed + OnlineTableState_OnlinePipelineFailed = sdk.OnlineTableState_OnlinePipelineFailed + OnlineTableState_OnlineUpdatingPipelineResources = sdk.OnlineTableState_OnlineUpdatingPipelineResources + ProvisioningInfo_State_Unspecified = sdk.ProvisioningInfo_State_Unspecified + ProvisioningInfo_State_Provisioning = sdk.ProvisioningInfo_State_Provisioning + ProvisioningInfo_State_Active = sdk.ProvisioningInfo_State_Active + ProvisioningInfo_State_Failed = sdk.ProvisioningInfo_State_Failed + ProvisioningInfo_State_Deleting = sdk.ProvisioningInfo_State_Deleting + ProvisioningInfo_State_Updating = sdk.ProvisioningInfo_State_Updating + ProvisioningInfo_State_Degraded = sdk.ProvisioningInfo_State_Degraded +) + +// Detailed status of an online table. Shown if the online table is in the +// ONLINE_CONTINUOUS_UPDATE or the ONLINE_UPDATING_PIPELINE_RESOURCES state.. +type ContinuousUpdateStatus struct { + // Progress of the initial data synchronization. + InitialPipelineSyncProgress *PipelineProgress `json:"initial_pipeline_sync_progress,omitempty"` + // The last source table Delta version that was synced to the online table. Note + // that this Delta version may not be completely synced to the online table yet. + LastProcessedCommitVersion *int64 `json:"last_processed_commit_version,omitempty"` + // The timestamp of the last time any data was synchronized from the source + // table to the online table. + Timestamp *types.Time `json:"timestamp,omitempty"` +} + +// Create an online table. +type CreateOnlineTableRequest struct { + // Specification of the online table to be created. + Table *OnlineTable `json:"table,omitempty"` +} + +// Detailed status of an online table. Shown if the online table is in the +// OFFLINE_FAILED or the ONLINE_PIPELINE_FAILED state.. +type FailedStatus struct { + // The last source table Delta version that was synced to the online table. Note + // that this Delta version may only be partially synced to the online table. + // Only populated if the table is still online and available for serving. + LastProcessedCommitVersion *int64 `json:"last_processed_commit_version,omitempty"` + // The timestamp of the last time any data was synchronized from the source + // table to the online table. Only populated if the table is still online and + // available for serving. + Timestamp *types.Time `json:"timestamp,omitempty"` +} + +// Online Table information.. +type OnlineTable struct { + // Full three-part (catalog, schema, table) name of the table. + Name *string `json:"name,omitempty"` + // Specification of the online table. + Spec *OnlineTableSpec `json:"spec,omitempty"` + // Online Table data synchronization status + Status *OnlineTableStatus `json:"status,omitempty"` + // Data serving REST API URL for this table + TableServingUrl *string `json:"table_serving_url,omitempty"` + // The provisioning state of the online table entity in Unity Catalog. This is + // distinct from the state of the data synchronization pipeline (i.e. the table + // may be in "ACTIVE" but the pipeline may be in "PROVISIONING" as it runs + // asynchronously). + UnityCatalogProvisioningState ProvisioningInfo_State `json:"unity_catalog_provisioning_state,omitempty"` +} + +// Specification of an online table.. +type OnlineTableSpec struct { + // Whether to create a full-copy pipeline -- a pipeline that stops after creates + // a full copy of the source table upon initialization and does not process any + // change data feeds (CDFs) afterwards. The pipeline can still be manually + // triggered afterwards, but it always perform a full copy of the source table + // and there are no incremental updates. This mode is useful for syncing views + // or tables without CDFs to online tables. Note that the full-copy pipeline + // only supports "triggered" scheduling policy. + PerformFullCopy *bool `json:"perform_full_copy,omitempty"` + // ID of the associated pipeline. Generated by the server - cannot be set by the + // caller. + PipelineId *string `json:"pipeline_id,omitempty"` + // Primary Key columns to be used for data insert/update in the destination. + PrimaryKeyColumns []string `json:"primary_key_columns,omitempty"` + RunContinuously *OnlineTableSpec_ContinuousSchedulingPolicy `json:"run_continuously,omitempty"` + RunTriggered *OnlineTableSpec_TriggeredSchedulingPolicy `json:"run_triggered,omitempty"` + // Three-part (catalog, schema, table) name of the source Delta table. + SourceTableFullName *string `json:"source_table_full_name,omitempty"` + // Time series key to deduplicate (tie-break) rows with the same primary key. + TimeseriesKey *string `json:"timeseries_key,omitempty"` +} + +type OnlineTableSpec_ContinuousSchedulingPolicy struct { +} + +type OnlineTableSpec_TriggeredSchedulingPolicy struct { +} + +// Status of an online table.. +type OnlineTableStatus struct { + ContinuousUpdateStatus *ContinuousUpdateStatus `json:"continuous_update_status,omitempty"` + // The state of the online table. + DetailedState OnlineTableState `json:"detailed_state,omitempty"` + FailedStatus *FailedStatus `json:"failed_status,omitempty"` + // A text description of the current state of the online table. + Message *string `json:"message,omitempty"` + ProvisioningStatus *ProvisioningStatus `json:"provisioning_status,omitempty"` + TriggeredUpdateStatus *TriggeredUpdateStatus `json:"triggered_update_status,omitempty"` +} + +// Progress information of the Online Table data synchronization pipeline.. +type PipelineProgress struct { + // The estimated time remaining to complete this update in seconds. + EstimatedCompletionTimeSeconds *float64 `json:"estimated_completion_time_seconds,omitempty"` + // The source table Delta version that was last processed by the pipeline. The + // pipeline may not have completely processed this version yet. + LatestVersionCurrentlyProcessing *int64 `json:"latest_version_currently_processing,omitempty"` + // The completion ratio of this update. This is a number between 0 and 1. + SyncProgressCompletion *float64 `json:"sync_progress_completion,omitempty"` + // The number of rows that have been synced in this update. + SyncedRowCount *int64 `json:"synced_row_count,omitempty"` + // The total number of rows that need to be synced in this update. This number + // may be an estimate. + TotalRowCount *int64 `json:"total_row_count,omitempty"` +} + +// Detailed status of an online table. Shown if the online table is in the +// PROVISIONING_PIPELINE_RESOURCES or the PROVISIONING_INITIAL_SNAPSHOT state.. +type ProvisioningStatus struct { + // Details about initial data synchronization. Only populated when in the + // PROVISIONING_INITIAL_SNAPSHOT state. + InitialPipelineSyncProgress *PipelineProgress `json:"initial_pipeline_sync_progress,omitempty"` +} + +// Detailed status of an online table. Shown if the online table is in the +// ONLINE_TRIGGERED_UPDATE or the ONLINE_NO_PENDING_UPDATE state.. +type TriggeredUpdateStatus struct { + // The last source table Delta version that was synced to the online table. Note + // that this Delta version may not be completely synced to the online table yet. + LastProcessedCommitVersion *int64 `json:"last_processed_commit_version,omitempty"` + // The timestamp of the last time any data was synchronized from the source + // table to the online table. + Timestamp *types.Time `json:"timestamp,omitempty"` + // Progress of the active data synchronization pipeline. + TriggeredUpdateProgress *PipelineProgress `json:"triggered_update_progress,omitempty"` +} + +// ContinuousUpdateStatusToSDK converts the mirror to the sdk-go type. +func ContinuousUpdateStatusToSDK(w *ContinuousUpdateStatus) (*sdk.ContinuousUpdateStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.ContinuousUpdateStatus{} + out.LastProcessedCommitVersion = w.LastProcessedCommitVersion + out.Timestamp = w.Timestamp + conv1, err := PipelineProgressToSDK(w.InitialPipelineSyncProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ContinuousUpdateStatus.InitialPipelineSyncProgress", err) + } + out.InitialPipelineSyncProgress = conv1 + return out, nil +} + +// ContinuousUpdateStatusFromSDK converts the sdk-go type to the mirror. +func ContinuousUpdateStatusFromSDK(v *sdk.ContinuousUpdateStatus) (*ContinuousUpdateStatus, error) { + if v == nil { + return nil, nil + } + out := &ContinuousUpdateStatus{} + out.LastProcessedCommitVersion = v.LastProcessedCommitVersion + out.Timestamp = v.Timestamp + conv2, err := PipelineProgressFromSDK(v.InitialPipelineSyncProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ContinuousUpdateStatus.InitialPipelineSyncProgress", err) + } + out.InitialPipelineSyncProgress = conv2 + return out, nil +} + +// CreateOnlineTableRequestToSDK converts the mirror to the sdk-go type. +func CreateOnlineTableRequestToSDK(w *CreateOnlineTableRequest) (*sdk.CreateOnlineTableRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateOnlineTableRequest{} + conv3, err := OnlineTableToSDK(w.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateOnlineTableRequest.Table", err) + } + out.Table = conv3 + return out, nil +} + +// CreateOnlineTableRequestFromSDK converts the sdk-go type to the mirror. +func CreateOnlineTableRequestFromSDK(v *sdk.CreateOnlineTableRequest) (*CreateOnlineTableRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateOnlineTableRequest{} + conv4, err := OnlineTableFromSDK(v.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateOnlineTableRequest.Table", err) + } + out.Table = conv4 + return out, nil +} + +// FailedStatusToSDK converts the mirror to the sdk-go type. +func FailedStatusToSDK(w *FailedStatus) (*sdk.FailedStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.FailedStatus{} + out.LastProcessedCommitVersion = w.LastProcessedCommitVersion + out.Timestamp = w.Timestamp + return out, nil +} + +// FailedStatusFromSDK converts the sdk-go type to the mirror. +func FailedStatusFromSDK(v *sdk.FailedStatus) (*FailedStatus, error) { + if v == nil { + return nil, nil + } + out := &FailedStatus{} + out.LastProcessedCommitVersion = v.LastProcessedCommitVersion + out.Timestamp = v.Timestamp + return out, nil +} + +// OnlineTableToSDK converts the mirror to the sdk-go type. +func OnlineTableToSDK(w *OnlineTable) (*sdk.OnlineTable, error) { + if w == nil { + return nil, nil + } + out := &sdk.OnlineTable{} + out.Name = w.Name + conv5, err := OnlineTableSpecToSDK(w.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTable.Spec", err) + } + out.Spec = conv5 + conv6, err := OnlineTableStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTable.Status", err) + } + out.Status = conv6 + out.TableServingUrl = w.TableServingUrl + out.UnityCatalogProvisioningState = w.UnityCatalogProvisioningState + return out, nil +} + +// OnlineTableFromSDK converts the sdk-go type to the mirror. +func OnlineTableFromSDK(v *sdk.OnlineTable) (*OnlineTable, error) { + if v == nil { + return nil, nil + } + out := &OnlineTable{} + out.Name = v.Name + conv7, err := OnlineTableSpecFromSDK(v.Spec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTable.Spec", err) + } + out.Spec = conv7 + conv8, err := OnlineTableStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTable.Status", err) + } + out.Status = conv8 + out.TableServingUrl = v.TableServingUrl + out.UnityCatalogProvisioningState = v.UnityCatalogProvisioningState + return out, nil +} + +// OnlineTableSpecToSDK converts the mirror to the sdk-go type. +func OnlineTableSpecToSDK(w *OnlineTableSpec) (*sdk.OnlineTableSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.OnlineTableSpec{} + { + var members []string + if w.RunContinuously != nil { + members = append(members, "run_continuously") + } + if w.RunTriggered != nil { + members = append(members, "run_triggered") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.RunContinuously != nil: + conv9, err := OnlineTableSpec_ContinuousSchedulingPolicyToSDK(w.RunContinuously) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTableSpec.SchedulingPolicy", err) + } + out.SchedulingPolicy = &sdk.OnlineTableSpec_SchedulingPolicy_RunContinuously{RunContinuously: *conv9} + case w.RunTriggered != nil: + conv10, err := OnlineTableSpec_TriggeredSchedulingPolicyToSDK(w.RunTriggered) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTableSpec.SchedulingPolicy", err) + } + out.SchedulingPolicy = &sdk.OnlineTableSpec_SchedulingPolicy_RunTriggered{RunTriggered: *conv10} + } + out.SourceTableFullName = w.SourceTableFullName + out.PrimaryKeyColumns = w.PrimaryKeyColumns + out.TimeseriesKey = w.TimeseriesKey + out.PerformFullCopy = w.PerformFullCopy + out.PipelineId = w.PipelineId + return out, nil +} + +// OnlineTableSpecFromSDK converts the sdk-go type to the mirror. +func OnlineTableSpecFromSDK(v *sdk.OnlineTableSpec) (*OnlineTableSpec, error) { + if v == nil { + return nil, nil + } + out := &OnlineTableSpec{} + switch value := v.SchedulingPolicy.(type) { + case *sdk.OnlineTableSpec_SchedulingPolicy_RunContinuously: + if value != nil { + conv11, err := OnlineTableSpec_ContinuousSchedulingPolicyFromSDK(&value.RunContinuously) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTableSpec.SchedulingPolicy", err) + } + out.RunContinuously = conv11 + } + case *sdk.OnlineTableSpec_SchedulingPolicy_RunTriggered: + if value != nil { + conv12, err := OnlineTableSpec_TriggeredSchedulingPolicyFromSDK(&value.RunTriggered) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTableSpec.SchedulingPolicy", err) + } + out.RunTriggered = conv12 + } + } + out.SourceTableFullName = v.SourceTableFullName + out.PrimaryKeyColumns = v.PrimaryKeyColumns + out.TimeseriesKey = v.TimeseriesKey + out.PerformFullCopy = v.PerformFullCopy + out.PipelineId = v.PipelineId + return out, nil +} + +// OnlineTableSpec_ContinuousSchedulingPolicyToSDK converts the mirror to the sdk-go type. +func OnlineTableSpec_ContinuousSchedulingPolicyToSDK(w *OnlineTableSpec_ContinuousSchedulingPolicy) (*sdk.OnlineTableSpec_ContinuousSchedulingPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.OnlineTableSpec_ContinuousSchedulingPolicy{} + return out, nil +} + +// OnlineTableSpec_ContinuousSchedulingPolicyFromSDK converts the sdk-go type to the mirror. +func OnlineTableSpec_ContinuousSchedulingPolicyFromSDK(v *sdk.OnlineTableSpec_ContinuousSchedulingPolicy) (*OnlineTableSpec_ContinuousSchedulingPolicy, error) { + if v == nil { + return nil, nil + } + out := &OnlineTableSpec_ContinuousSchedulingPolicy{} + return out, nil +} + +// OnlineTableSpec_TriggeredSchedulingPolicyToSDK converts the mirror to the sdk-go type. +func OnlineTableSpec_TriggeredSchedulingPolicyToSDK(w *OnlineTableSpec_TriggeredSchedulingPolicy) (*sdk.OnlineTableSpec_TriggeredSchedulingPolicy, error) { + if w == nil { + return nil, nil + } + out := &sdk.OnlineTableSpec_TriggeredSchedulingPolicy{} + return out, nil +} + +// OnlineTableSpec_TriggeredSchedulingPolicyFromSDK converts the sdk-go type to the mirror. +func OnlineTableSpec_TriggeredSchedulingPolicyFromSDK(v *sdk.OnlineTableSpec_TriggeredSchedulingPolicy) (*OnlineTableSpec_TriggeredSchedulingPolicy, error) { + if v == nil { + return nil, nil + } + out := &OnlineTableSpec_TriggeredSchedulingPolicy{} + return out, nil +} + +// OnlineTableStatusToSDK converts the mirror to the sdk-go type. +func OnlineTableStatusToSDK(w *OnlineTableStatus) (*sdk.OnlineTableStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.OnlineTableStatus{} + out.DetailedState = w.DetailedState + out.Message = w.Message + { + var members []string + if w.ProvisioningStatus != nil { + members = append(members, "provisioning_status") + } + if w.ContinuousUpdateStatus != nil { + members = append(members, "continuous_update_status") + } + if w.TriggeredUpdateStatus != nil { + members = append(members, "triggered_update_status") + } + if w.FailedStatus != nil { + members = append(members, "failed_status") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.ProvisioningStatus != nil: + conv13, err := ProvisioningStatusToSDK(w.ProvisioningStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTableStatus.DetailedStatus", err) + } + out.DetailedStatus = &sdk.OnlineTableStatus_DetailedStatus_ProvisioningStatus{ProvisioningStatus: *conv13} + case w.ContinuousUpdateStatus != nil: + conv14, err := ContinuousUpdateStatusToSDK(w.ContinuousUpdateStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTableStatus.DetailedStatus", err) + } + out.DetailedStatus = &sdk.OnlineTableStatus_DetailedStatus_ContinuousUpdateStatus{ContinuousUpdateStatus: *conv14} + case w.TriggeredUpdateStatus != nil: + conv15, err := TriggeredUpdateStatusToSDK(w.TriggeredUpdateStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTableStatus.DetailedStatus", err) + } + out.DetailedStatus = &sdk.OnlineTableStatus_DetailedStatus_TriggeredUpdateStatus{TriggeredUpdateStatus: *conv15} + case w.FailedStatus != nil: + conv16, err := FailedStatusToSDK(w.FailedStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTableStatus.DetailedStatus", err) + } + out.DetailedStatus = &sdk.OnlineTableStatus_DetailedStatus_FailedStatus{FailedStatus: *conv16} + } + return out, nil +} + +// OnlineTableStatusFromSDK converts the sdk-go type to the mirror. +func OnlineTableStatusFromSDK(v *sdk.OnlineTableStatus) (*OnlineTableStatus, error) { + if v == nil { + return nil, nil + } + out := &OnlineTableStatus{} + out.DetailedState = v.DetailedState + out.Message = v.Message + switch value := v.DetailedStatus.(type) { + case *sdk.OnlineTableStatus_DetailedStatus_ProvisioningStatus: + if value != nil { + conv17, err := ProvisioningStatusFromSDK(&value.ProvisioningStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTableStatus.DetailedStatus", err) + } + out.ProvisioningStatus = conv17 + } + case *sdk.OnlineTableStatus_DetailedStatus_ContinuousUpdateStatus: + if value != nil { + conv18, err := ContinuousUpdateStatusFromSDK(&value.ContinuousUpdateStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTableStatus.DetailedStatus", err) + } + out.ContinuousUpdateStatus = conv18 + } + case *sdk.OnlineTableStatus_DetailedStatus_TriggeredUpdateStatus: + if value != nil { + conv19, err := TriggeredUpdateStatusFromSDK(&value.TriggeredUpdateStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTableStatus.DetailedStatus", err) + } + out.TriggeredUpdateStatus = conv19 + } + case *sdk.OnlineTableStatus_DetailedStatus_FailedStatus: + if value != nil { + conv20, err := FailedStatusFromSDK(&value.FailedStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "OnlineTableStatus.DetailedStatus", err) + } + out.FailedStatus = conv20 + } + } + return out, nil +} + +// PipelineProgressToSDK converts the mirror to the sdk-go type. +func PipelineProgressToSDK(w *PipelineProgress) (*sdk.PipelineProgress, error) { + if w == nil { + return nil, nil + } + out := &sdk.PipelineProgress{} + out.LatestVersionCurrentlyProcessing = w.LatestVersionCurrentlyProcessing + out.SyncedRowCount = w.SyncedRowCount + out.TotalRowCount = w.TotalRowCount + out.SyncProgressCompletion = w.SyncProgressCompletion + out.EstimatedCompletionTimeSeconds = w.EstimatedCompletionTimeSeconds + return out, nil +} + +// PipelineProgressFromSDK converts the sdk-go type to the mirror. +func PipelineProgressFromSDK(v *sdk.PipelineProgress) (*PipelineProgress, error) { + if v == nil { + return nil, nil + } + out := &PipelineProgress{} + out.LatestVersionCurrentlyProcessing = v.LatestVersionCurrentlyProcessing + out.SyncedRowCount = v.SyncedRowCount + out.TotalRowCount = v.TotalRowCount + out.SyncProgressCompletion = v.SyncProgressCompletion + out.EstimatedCompletionTimeSeconds = v.EstimatedCompletionTimeSeconds + return out, nil +} + +// ProvisioningStatusToSDK converts the mirror to the sdk-go type. +func ProvisioningStatusToSDK(w *ProvisioningStatus) (*sdk.ProvisioningStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.ProvisioningStatus{} + conv21, err := PipelineProgressToSDK(w.InitialPipelineSyncProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProvisioningStatus.InitialPipelineSyncProgress", err) + } + out.InitialPipelineSyncProgress = conv21 + return out, nil +} + +// ProvisioningStatusFromSDK converts the sdk-go type to the mirror. +func ProvisioningStatusFromSDK(v *sdk.ProvisioningStatus) (*ProvisioningStatus, error) { + if v == nil { + return nil, nil + } + out := &ProvisioningStatus{} + conv22, err := PipelineProgressFromSDK(v.InitialPipelineSyncProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ProvisioningStatus.InitialPipelineSyncProgress", err) + } + out.InitialPipelineSyncProgress = conv22 + return out, nil +} + +// TriggeredUpdateStatusToSDK converts the mirror to the sdk-go type. +func TriggeredUpdateStatusToSDK(w *TriggeredUpdateStatus) (*sdk.TriggeredUpdateStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.TriggeredUpdateStatus{} + out.LastProcessedCommitVersion = w.LastProcessedCommitVersion + out.Timestamp = w.Timestamp + conv23, err := PipelineProgressToSDK(w.TriggeredUpdateProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggeredUpdateStatus.TriggeredUpdateProgress", err) + } + out.TriggeredUpdateProgress = conv23 + return out, nil +} + +// TriggeredUpdateStatusFromSDK converts the sdk-go type to the mirror. +func TriggeredUpdateStatusFromSDK(v *sdk.TriggeredUpdateStatus) (*TriggeredUpdateStatus, error) { + if v == nil { + return nil, nil + } + out := &TriggeredUpdateStatus{} + out.LastProcessedCommitVersion = v.LastProcessedCommitVersion + out.Timestamp = v.Timestamp + conv24, err := PipelineProgressFromSDK(v.TriggeredUpdateProgress) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TriggeredUpdateStatus.TriggeredUpdateProgress", err) + } + out.TriggeredUpdateProgress = conv24 + return out, nil +} diff --git a/libs/sdktypes/uc/registeredmodels/v1/types.generated.go b/libs/sdktypes/uc/registeredmodels/v1/types.generated.go new file mode 100644 index 00000000000..3341cf065bb --- /dev/null +++ b/libs/sdktypes/uc/registeredmodels/v1/types.generated.go @@ -0,0 +1,1163 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/registeredmodels/v1. DO NOT EDIT. + +package registeredmodels + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/registeredmodels/v1" + + strings "strings" +) + +type ( + ModelVersionStatus = sdk.ModelVersionStatus +) + +const ( + ModelVersionStatus_Unspecified = sdk.ModelVersionStatus_Unspecified + ModelVersionStatus_PendingRegistration = sdk.ModelVersionStatus_PendingRegistration + ModelVersionStatus_FailedRegistration = sdk.ModelVersionStatus_FailedRegistration + ModelVersionStatus_Ready = sdk.ModelVersionStatus_Ready +) + +// A connection that is dependent on a SQL object.. +type ConnectionDependency struct { + // Full name of the dependent connection, in the form of __connection_name__. + ConnectionName *string `json:"connection_name,omitempty"` +} + +type CreateRegisteredModelRequest struct { + // List of aliases associated with the registered model + Aliases []RegisteredModelAliasInfo `json:"aliases,omitempty"` + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // The name of the catalog where the schema and the registered model reside + CatalogName *string `json:"catalog_name,omitempty"` + // The comment attached to the registered model + Comment *string `json:"comment,omitempty"` + // Creation timestamp of the registered model in milliseconds since the Unix + // epoch + CreatedAt *int64 `json:"created_at,omitempty"` + // The identifier of the user who created the registered model + CreatedBy *string `json:"created_by,omitempty"` + // The three-level (fully qualified) name of the registered model + FullName *string `json:"full_name,omitempty"` + // The unique identifier of the metastore + MetastoreId *string `json:"metastore_id,omitempty"` + // The name of the registered model + Name *string `json:"name,omitempty"` + // The identifier of the user who owns the registered model + Owner *string `json:"owner,omitempty"` + // The name of the schema where the registered model resides + SchemaName *string `json:"schema_name,omitempty"` + // The storage location on the cloud under which model version data files are + // stored + StorageLocation *string `json:"storage_location,omitempty"` + // Last-update timestamp of the registered model in milliseconds since the Unix + // epoch + UpdatedAt *int64 `json:"updated_at,omitempty"` + // The identifier of the user who updated the registered model last time + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// A credential that is dependent on a SQL object.. +type CredentialDependency struct { + // Full name of the dependent credential, in the form of __credential_name__. + CredentialName *string `json:"credential_name,omitempty"` +} + +// A dependency of a SQL object. One of the following fields must be defined: +// __table__, __function__, __connection__, __credential__, __volume__, or +// __secret__.. +type Dependency struct { + Connection *ConnectionDependency `json:"connection,omitempty"` + Credential *CredentialDependency `json:"credential,omitempty"` + Function *FunctionDependency `json:"function,omitempty"` + Table *TableDependency `json:"table,omitempty"` +} + +// A list of dependencies.. +type DependencyList struct { + // Array of dependencies. + Dependencies []Dependency `json:"dependencies,omitempty"` +} + +// A function that is dependent on a SQL object.. +type FunctionDependency struct { + // Full name of the dependent function, in the form of + // __catalog_name__.__schema_name__.__function_name__. + FunctionFullName *string `json:"function_full_name,omitempty"` +} + +type GetModelVersionByAliasRequest struct { + // The name of the alias + AliasArg *string `json:"alias_arg,omitempty"` + // The three-level (fully qualified) name of the registered model + FullNameArg *string `json:"full_name_arg,omitempty"` + // Whether to include aliases associated with the model version in the response + IncludeAliases *bool `json:"include_aliases,omitempty"` +} + +type GetModelVersionRequest struct { + // The three-level (fully qualified) name of the model version + FullNameArg *string `json:"full_name_arg,omitempty"` + // Whether to include aliases associated with the model version in the response + IncludeAliases *bool `json:"include_aliases,omitempty"` + // Whether to include model versions in the response for which the principal can + // only access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` + // The integer version number of the model version + VersionArg *int64 `json:"version_arg,omitempty"` +} + +type GetRegisteredModelRequest struct { + // The three-level (fully qualified) name of the registered model + FullNameArg *string `json:"full_name_arg,omitempty"` + // Whether to include registered model aliases in the response + IncludeAliases *bool `json:"include_aliases,omitempty"` + // Whether to include registered models in the response for which the principal + // can only access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` +} + +type ListModelVersionsRequest struct { + // The full three-level name of the registered model under which to list model + // versions + FullNameArg *string `json:"full_name_arg,omitempty"` + // Whether to include model versions in the response for which the principal can + // only access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` + // Maximum number of model versions to return. If not set, the page length is + // set to a server configured value (100, as of 1/3/2024). - when set to a value + // greater than 0, the page length is the minimum of this value and a server + // configured value(1000, as of 1/3/2024); - when set to 0, the page length is + // set to a server configured value (100, as of 1/3/2024) (recommended); - when + // set to a value less than 0, an invalid parameter error is returned; + MaxResults *int64 `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListModelVersionsResponse struct { + ModelVersions []ModelVersionInfo `json:"model_versions,omitempty"` + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListRegisteredModelsRequest struct { + // The identifier of the catalog under which to list registered models. If + // specified, schema_name must be specified. + CatalogName *string `json:"catalog_name,omitempty"` + // Whether to include registered models in the response for which the principal + // can only access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` + // Max number of registered models to return. If both catalog and schema are + // specified: - when max_results is not specified, the page length is set to a + // server configured value (10000, as of 4/2/2024). - when set to a value + // greater than 0, the page length is the minimum of this value and a server + // configured value (10000, as of 4/2/2024); - when set to 0, the page length is + // set to a server configured value (10000, as of 4/2/2024); - when set to a + // value less than 0, an invalid parameter error is returned; If neither schema + // nor catalog is specified: - when max_results is not specified, the page + // length is set to a server configured value (100, as of 4/2/2024). - when set + // to a value greater than 0, the page length is the minimum of this value and a + // server configured value (1000, as of 4/2/2024); - when set to 0, the page + // length is set to a server configured value (100, as of 4/2/2024); - when set + // to a value less than 0, an invalid parameter error is returned; + MaxResults *int64 `json:"max_results,omitempty"` + // Opaque token to send for the next page of results (pagination). + PageToken *string `json:"page_token,omitempty"` + // The identifier of the schema under which to list registered models. If + // specified, catalog_name must be specified. + SchemaName *string `json:"schema_name,omitempty"` +} + +type ListRegisteredModelsResponse struct { + // Opaque token for pagination. Omitted if there are no more results. page_token + // should be set to this value for fetching the next page. + NextPageToken *string `json:"next_page_token,omitempty"` + RegisteredModels []RegisteredModelInfo `json:"registered_models,omitempty"` +} + +type ModelVersionInfo struct { + // List of aliases associated with the model version + Aliases []RegisteredModelAliasInfo `json:"aliases,omitempty"` + // The name of the catalog containing the model version + CatalogName *string `json:"catalog_name,omitempty"` + // The comment attached to the model version + Comment *string `json:"comment,omitempty"` + CreatedAt *int64 `json:"created_at,omitempty"` + // The identifier of the user who created the model version + CreatedBy *string `json:"created_by,omitempty"` + // The unique identifier of the model version + Id *string `json:"id,omitempty"` + // The unique identifier of the metastore containing the model version + MetastoreId *string `json:"metastore_id,omitempty"` + // The name of the parent registered model of the model version, relative to + // parent schema + ModelName *string `json:"model_name,omitempty"` + // Model version dependencies, for feature-store packaged models + ModelVersionDependencies *DependencyList `json:"model_version_dependencies,omitempty"` + // MLflow run ID used when creating the model version, if ``source`` was + // generated by an experiment run stored in an MLflow tracking server + RunId *string `json:"run_id,omitempty"` + // ID of the workspace containing the MLflow run that generated + // this model version, if applicable + RunWorkspaceId *int64 `json:"run_workspace_id,omitempty"` + // The name of the schema containing the model version, relative to parent + // catalog + SchemaName *string `json:"schema_name,omitempty"` + // URI indicating the location of the source artifacts (files) for the model + // version + Source *string `json:"source,omitempty"` + // Current status of the model version. Newly created model versions start in + // PENDING_REGISTRATION status, then move to READY status once the model version + // files are uploaded and the model version is finalized. Only model versions in + // READY status can be loaded for inference or served. + Status ModelVersionStatus `json:"status,omitempty"` + // The storage location on the cloud under which model version data files are + // stored + StorageLocation *string `json:"storage_location,omitempty"` + UpdatedAt *int64 `json:"updated_at,omitempty"` + // The identifier of the user who updated the model version last time + UpdatedBy *string `json:"updated_by,omitempty"` + // Integer model version number, used to reference the model version in API + // requests. + Version *int64 `json:"version,omitempty"` +} + +type RegisteredModelAliasInfo struct { + // Name of the alias, e.g. 'champion' or 'latest_stable' + AliasName *string `json:"alias_name,omitempty"` + // The name of the catalog containing the model version + CatalogName *string `json:"catalog_name,omitempty"` + // The unique identifier of the alias + Id *string `json:"id,omitempty"` + // The name of the parent registered model of the model version, relative to + // parent schema + ModelName *string `json:"model_name,omitempty"` + // The name of the schema containing the model version, relative to parent + // catalog + SchemaName *string `json:"schema_name,omitempty"` + // Integer version number of the model version to which this alias points. + VersionNum *int64 `json:"version_num,omitempty"` +} + +type RegisteredModelInfo struct { + // List of aliases associated with the registered model + Aliases []RegisteredModelAliasInfo `json:"aliases,omitempty"` + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // The name of the catalog where the schema and the registered model reside + CatalogName *string `json:"catalog_name,omitempty"` + // The comment attached to the registered model + Comment *string `json:"comment,omitempty"` + // Creation timestamp of the registered model in milliseconds since the Unix + // epoch + CreatedAt *int64 `json:"created_at,omitempty"` + // The identifier of the user who created the registered model + CreatedBy *string `json:"created_by,omitempty"` + // The three-level (fully qualified) name of the registered model + FullName *string `json:"full_name,omitempty"` + // The unique identifier of the metastore + MetastoreId *string `json:"metastore_id,omitempty"` + // The name of the registered model + Name *string `json:"name,omitempty"` + // The identifier of the user who owns the registered model + Owner *string `json:"owner,omitempty"` + // The name of the schema where the registered model resides + SchemaName *string `json:"schema_name,omitempty"` + // The storage location on the cloud under which model version data files are + // stored + StorageLocation *string `json:"storage_location,omitempty"` + // Last-update timestamp of the registered model in milliseconds since the Unix + // epoch + UpdatedAt *int64 `json:"updated_at,omitempty"` + // The identifier of the user who updated the registered model last time + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type SetRegisteredModelAliasRequest struct { + // The name of the alias + AliasArg *string `json:"alias_arg,omitempty"` + // The three-level (fully qualified) name of the registered model + FullNameArg *string `json:"full_name_arg,omitempty"` + // The version number of the model version to which the alias points + VersionNum *int64 `json:"version_num,omitempty"` +} + +// A table that is dependent on a SQL object.. +type TableDependency struct { + // Full name of the dependent table, in the form of + // __catalog_name__.__schema_name__.__table_name__. + TableFullName *string `json:"table_full_name,omitempty"` +} + +type UpdateModelVersionRequest struct { + // List of aliases associated with the model version + Aliases []RegisteredModelAliasInfo `json:"aliases,omitempty"` + // The name of the catalog containing the model version + CatalogName *string `json:"catalog_name,omitempty"` + // The comment attached to the model version + Comment *string `json:"comment,omitempty"` + CreatedAt *int64 `json:"created_at,omitempty"` + // The identifier of the user who created the model version + CreatedBy *string `json:"created_by,omitempty"` + // The three-level (fully qualified) name of the model version + FullNameArg *string `json:"full_name_arg,omitempty"` + // The unique identifier of the model version + Id *string `json:"id,omitempty"` + // The unique identifier of the metastore containing the model version + MetastoreId *string `json:"metastore_id,omitempty"` + // The name of the parent registered model of the model version, relative to + // parent schema + ModelName *string `json:"model_name,omitempty"` + // Model version dependencies, for feature-store packaged models + ModelVersionDependencies *DependencyList `json:"model_version_dependencies,omitempty"` + // MLflow run ID used when creating the model version, if ``source`` was + // generated by an experiment run stored in an MLflow tracking server + RunId *string `json:"run_id,omitempty"` + // ID of the workspace containing the MLflow run that generated + // this model version, if applicable + RunWorkspaceId *int64 `json:"run_workspace_id,omitempty"` + // The name of the schema containing the model version, relative to parent + // catalog + SchemaName *string `json:"schema_name,omitempty"` + // URI indicating the location of the source artifacts (files) for the model + // version + Source *string `json:"source,omitempty"` + // Current status of the model version. Newly created model versions start in + // PENDING_REGISTRATION status, then move to READY status once the model version + // files are uploaded and the model version is finalized. Only model versions in + // READY status can be loaded for inference or served. + Status ModelVersionStatus `json:"status,omitempty"` + // The storage location on the cloud under which model version data files are + // stored + StorageLocation *string `json:"storage_location,omitempty"` + UpdatedAt *int64 `json:"updated_at,omitempty"` + // The identifier of the user who updated the model version last time + UpdatedBy *string `json:"updated_by,omitempty"` + // Integer model version number, used to reference the model version in API + // requests. + Version *int64 `json:"version,omitempty"` + // The integer version number of the model version + VersionArg *int64 `json:"version_arg,omitempty"` +} + +type UpdateRegisteredModelRequest struct { + // List of aliases associated with the registered model + Aliases []RegisteredModelAliasInfo `json:"aliases,omitempty"` + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // The name of the catalog where the schema and the registered model reside + CatalogName *string `json:"catalog_name,omitempty"` + // The comment attached to the registered model + Comment *string `json:"comment,omitempty"` + // Creation timestamp of the registered model in milliseconds since the Unix + // epoch + CreatedAt *int64 `json:"created_at,omitempty"` + // The identifier of the user who created the registered model + CreatedBy *string `json:"created_by,omitempty"` + // The three-level (fully qualified) name of the registered model + FullName *string `json:"full_name,omitempty"` + // The three-level (fully qualified) name of the registered model + FullNameArg *string `json:"full_name_arg,omitempty"` + // The unique identifier of the metastore + MetastoreId *string `json:"metastore_id,omitempty"` + // The name of the registered model + Name *string `json:"name,omitempty"` + // New name for the registered model. + NewName *string `json:"new_name,omitempty"` + // The identifier of the user who owns the registered model + Owner *string `json:"owner,omitempty"` + // The name of the schema where the registered model resides + SchemaName *string `json:"schema_name,omitempty"` + // The storage location on the cloud under which model version data files are + // stored + StorageLocation *string `json:"storage_location,omitempty"` + // Last-update timestamp of the registered model in milliseconds since the Unix + // epoch + UpdatedAt *int64 `json:"updated_at,omitempty"` + // The identifier of the user who updated the registered model last time + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// ConnectionDependencyToSDK converts the mirror to the sdk-go type. +func ConnectionDependencyToSDK(w *ConnectionDependency) (*sdk.ConnectionDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.ConnectionDependency{} + out.ConnectionName = w.ConnectionName + return out, nil +} + +// ConnectionDependencyFromSDK converts the sdk-go type to the mirror. +func ConnectionDependencyFromSDK(v *sdk.ConnectionDependency) (*ConnectionDependency, error) { + if v == nil { + return nil, nil + } + out := &ConnectionDependency{} + out.ConnectionName = v.ConnectionName + return out, nil +} + +// CreateRegisteredModelRequestToSDK converts the mirror to the sdk-go type. +func CreateRegisteredModelRequestToSDK(w *CreateRegisteredModelRequest) (*sdk.CreateRegisteredModelRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateRegisteredModelRequest{} + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageLocation = w.StorageLocation + out.MetastoreId = w.MetastoreId + out.FullName = w.FullName + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + conv1, err := convertSlice(w.Aliases, RegisteredModelAliasInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRegisteredModelRequest.Aliases", err) + } + out.Aliases = conv1 + out.BrowseOnly = w.BrowseOnly + return out, nil +} + +// CreateRegisteredModelRequestFromSDK converts the sdk-go type to the mirror. +func CreateRegisteredModelRequestFromSDK(v *sdk.CreateRegisteredModelRequest) (*CreateRegisteredModelRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateRegisteredModelRequest{} + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageLocation = v.StorageLocation + out.MetastoreId = v.MetastoreId + out.FullName = v.FullName + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + conv2, err := convertSlice(v.Aliases, RegisteredModelAliasInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateRegisteredModelRequest.Aliases", err) + } + out.Aliases = conv2 + out.BrowseOnly = v.BrowseOnly + return out, nil +} + +// CredentialDependencyToSDK converts the mirror to the sdk-go type. +func CredentialDependencyToSDK(w *CredentialDependency) (*sdk.CredentialDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.CredentialDependency{} + out.CredentialName = w.CredentialName + return out, nil +} + +// CredentialDependencyFromSDK converts the sdk-go type to the mirror. +func CredentialDependencyFromSDK(v *sdk.CredentialDependency) (*CredentialDependency, error) { + if v == nil { + return nil, nil + } + out := &CredentialDependency{} + out.CredentialName = v.CredentialName + return out, nil +} + +// DependencyToSDK converts the mirror to the sdk-go type. +func DependencyToSDK(w *Dependency) (*sdk.Dependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.Dependency{} + { + var members []string + if w.Table != nil { + members = append(members, "table") + } + if w.Function != nil { + members = append(members, "function") + } + if w.Connection != nil { + members = append(members, "connection") + } + if w.Credential != nil { + members = append(members, "credential") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Table != nil: + conv3, err := TableDependencyToSDK(w.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Table{Table: *conv3} + case w.Function != nil: + conv4, err := FunctionDependencyToSDK(w.Function) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Function{Function: *conv4} + case w.Connection != nil: + conv5, err := ConnectionDependencyToSDK(w.Connection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Connection{Connection: *conv5} + case w.Credential != nil: + conv6, err := CredentialDependencyToSDK(w.Credential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Credential{Credential: *conv6} + } + return out, nil +} + +// DependencyFromSDK converts the sdk-go type to the mirror. +func DependencyFromSDK(v *sdk.Dependency) (*Dependency, error) { + if v == nil { + return nil, nil + } + out := &Dependency{} + switch value := v.Value.(type) { + case *sdk.Dependency_Value_Table: + if value != nil { + conv7, err := TableDependencyFromSDK(&value.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Table = conv7 + } + case *sdk.Dependency_Value_Function: + if value != nil { + conv8, err := FunctionDependencyFromSDK(&value.Function) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Function = conv8 + } + case *sdk.Dependency_Value_Connection: + if value != nil { + conv9, err := ConnectionDependencyFromSDK(&value.Connection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Connection = conv9 + } + case *sdk.Dependency_Value_Credential: + if value != nil { + conv10, err := CredentialDependencyFromSDK(&value.Credential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Credential = conv10 + } + } + return out, nil +} + +// DependencyListToSDK converts the mirror to the sdk-go type. +func DependencyListToSDK(w *DependencyList) (*sdk.DependencyList, error) { + if w == nil { + return nil, nil + } + out := &sdk.DependencyList{} + conv11, err := convertSlice(w.Dependencies, DependencyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DependencyList.Dependencies", err) + } + out.Dependencies = conv11 + return out, nil +} + +// DependencyListFromSDK converts the sdk-go type to the mirror. +func DependencyListFromSDK(v *sdk.DependencyList) (*DependencyList, error) { + if v == nil { + return nil, nil + } + out := &DependencyList{} + conv12, err := convertSlice(v.Dependencies, DependencyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DependencyList.Dependencies", err) + } + out.Dependencies = conv12 + return out, nil +} + +// FunctionDependencyToSDK converts the mirror to the sdk-go type. +func FunctionDependencyToSDK(w *FunctionDependency) (*sdk.FunctionDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.FunctionDependency{} + out.FunctionFullName = w.FunctionFullName + return out, nil +} + +// FunctionDependencyFromSDK converts the sdk-go type to the mirror. +func FunctionDependencyFromSDK(v *sdk.FunctionDependency) (*FunctionDependency, error) { + if v == nil { + return nil, nil + } + out := &FunctionDependency{} + out.FunctionFullName = v.FunctionFullName + return out, nil +} + +// GetModelVersionByAliasRequestToSDK converts the mirror to the sdk-go type. +func GetModelVersionByAliasRequestToSDK(w *GetModelVersionByAliasRequest) (*sdk.GetModelVersionByAliasRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetModelVersionByAliasRequest{} + out.FullNameArg = w.FullNameArg + out.AliasArg = w.AliasArg + out.IncludeAliases = w.IncludeAliases + return out, nil +} + +// GetModelVersionByAliasRequestFromSDK converts the sdk-go type to the mirror. +func GetModelVersionByAliasRequestFromSDK(v *sdk.GetModelVersionByAliasRequest) (*GetModelVersionByAliasRequest, error) { + if v == nil { + return nil, nil + } + out := &GetModelVersionByAliasRequest{} + out.FullNameArg = v.FullNameArg + out.AliasArg = v.AliasArg + out.IncludeAliases = v.IncludeAliases + return out, nil +} + +// GetModelVersionRequestToSDK converts the mirror to the sdk-go type. +func GetModelVersionRequestToSDK(w *GetModelVersionRequest) (*sdk.GetModelVersionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetModelVersionRequest{} + out.FullNameArg = w.FullNameArg + out.VersionArg = w.VersionArg + out.IncludeAliases = w.IncludeAliases + out.IncludeBrowse = w.IncludeBrowse + return out, nil +} + +// GetModelVersionRequestFromSDK converts the sdk-go type to the mirror. +func GetModelVersionRequestFromSDK(v *sdk.GetModelVersionRequest) (*GetModelVersionRequest, error) { + if v == nil { + return nil, nil + } + out := &GetModelVersionRequest{} + out.FullNameArg = v.FullNameArg + out.VersionArg = v.VersionArg + out.IncludeAliases = v.IncludeAliases + out.IncludeBrowse = v.IncludeBrowse + return out, nil +} + +// GetRegisteredModelRequestToSDK converts the mirror to the sdk-go type. +func GetRegisteredModelRequestToSDK(w *GetRegisteredModelRequest) (*sdk.GetRegisteredModelRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetRegisteredModelRequest{} + out.FullNameArg = w.FullNameArg + out.IncludeAliases = w.IncludeAliases + out.IncludeBrowse = w.IncludeBrowse + return out, nil +} + +// GetRegisteredModelRequestFromSDK converts the sdk-go type to the mirror. +func GetRegisteredModelRequestFromSDK(v *sdk.GetRegisteredModelRequest) (*GetRegisteredModelRequest, error) { + if v == nil { + return nil, nil + } + out := &GetRegisteredModelRequest{} + out.FullNameArg = v.FullNameArg + out.IncludeAliases = v.IncludeAliases + out.IncludeBrowse = v.IncludeBrowse + return out, nil +} + +// ListModelVersionsRequestToSDK converts the mirror to the sdk-go type. +func ListModelVersionsRequestToSDK(w *ListModelVersionsRequest) (*sdk.ListModelVersionsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListModelVersionsRequest{} + out.FullNameArg = w.FullNameArg + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + out.IncludeBrowse = w.IncludeBrowse + return out, nil +} + +// ListModelVersionsRequestFromSDK converts the sdk-go type to the mirror. +func ListModelVersionsRequestFromSDK(v *sdk.ListModelVersionsRequest) (*ListModelVersionsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListModelVersionsRequest{} + out.FullNameArg = v.FullNameArg + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + out.IncludeBrowse = v.IncludeBrowse + return out, nil +} + +// ListModelVersionsResponseToSDK converts the mirror to the sdk-go type. +func ListModelVersionsResponseToSDK(w *ListModelVersionsResponse) (*sdk.ListModelVersionsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListModelVersionsResponse{} + conv13, err := convertSlice(w.ModelVersions, ModelVersionInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListModelVersionsResponse.ModelVersions", err) + } + out.ModelVersions = conv13 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListModelVersionsResponseFromSDK converts the sdk-go type to the mirror. +func ListModelVersionsResponseFromSDK(v *sdk.ListModelVersionsResponse) (*ListModelVersionsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListModelVersionsResponse{} + conv14, err := convertSlice(v.ModelVersions, ModelVersionInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListModelVersionsResponse.ModelVersions", err) + } + out.ModelVersions = conv14 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListRegisteredModelsRequestToSDK converts the mirror to the sdk-go type. +func ListRegisteredModelsRequestToSDK(w *ListRegisteredModelsRequest) (*sdk.ListRegisteredModelsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRegisteredModelsRequest{} + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.IncludeBrowse = w.IncludeBrowse + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListRegisteredModelsRequestFromSDK converts the sdk-go type to the mirror. +func ListRegisteredModelsRequestFromSDK(v *sdk.ListRegisteredModelsRequest) (*ListRegisteredModelsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListRegisteredModelsRequest{} + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.IncludeBrowse = v.IncludeBrowse + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListRegisteredModelsResponseToSDK converts the mirror to the sdk-go type. +func ListRegisteredModelsResponseToSDK(w *ListRegisteredModelsResponse) (*sdk.ListRegisteredModelsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListRegisteredModelsResponse{} + conv15, err := convertSlice(w.RegisteredModels, RegisteredModelInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRegisteredModelsResponse.RegisteredModels", err) + } + out.RegisteredModels = conv15 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListRegisteredModelsResponseFromSDK converts the sdk-go type to the mirror. +func ListRegisteredModelsResponseFromSDK(v *sdk.ListRegisteredModelsResponse) (*ListRegisteredModelsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListRegisteredModelsResponse{} + conv16, err := convertSlice(v.RegisteredModels, RegisteredModelInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListRegisteredModelsResponse.RegisteredModels", err) + } + out.RegisteredModels = conv16 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ModelVersionInfoToSDK converts the mirror to the sdk-go type. +func ModelVersionInfoToSDK(w *ModelVersionInfo) (*sdk.ModelVersionInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ModelVersionInfo{} + out.ModelName = w.ModelName + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.Source = w.Source + out.Comment = w.Comment + out.RunId = w.RunId + out.RunWorkspaceId = w.RunWorkspaceId + conv17, err := DependencyListToSDK(w.ModelVersionDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelVersionInfo.ModelVersionDependencies", err) + } + out.ModelVersionDependencies = conv17 + out.Status = w.Status + out.Version = w.Version + out.StorageLocation = w.StorageLocation + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.Id = w.Id + conv18, err := convertSlice(w.Aliases, RegisteredModelAliasInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelVersionInfo.Aliases", err) + } + out.Aliases = conv18 + return out, nil +} + +// ModelVersionInfoFromSDK converts the sdk-go type to the mirror. +func ModelVersionInfoFromSDK(v *sdk.ModelVersionInfo) (*ModelVersionInfo, error) { + if v == nil { + return nil, nil + } + out := &ModelVersionInfo{} + out.ModelName = v.ModelName + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.Source = v.Source + out.Comment = v.Comment + out.RunId = v.RunId + out.RunWorkspaceId = v.RunWorkspaceId + conv19, err := DependencyListFromSDK(v.ModelVersionDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelVersionInfo.ModelVersionDependencies", err) + } + out.ModelVersionDependencies = conv19 + out.Status = v.Status + out.Version = v.Version + out.StorageLocation = v.StorageLocation + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.Id = v.Id + conv20, err := convertSlice(v.Aliases, RegisteredModelAliasInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ModelVersionInfo.Aliases", err) + } + out.Aliases = conv20 + return out, nil +} + +// RegisteredModelAliasInfoToSDK converts the mirror to the sdk-go type. +func RegisteredModelAliasInfoToSDK(w *RegisteredModelAliasInfo) (*sdk.RegisteredModelAliasInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.RegisteredModelAliasInfo{} + out.AliasName = w.AliasName + out.VersionNum = w.VersionNum + out.Id = w.Id + out.ModelName = w.ModelName + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + return out, nil +} + +// RegisteredModelAliasInfoFromSDK converts the sdk-go type to the mirror. +func RegisteredModelAliasInfoFromSDK(v *sdk.RegisteredModelAliasInfo) (*RegisteredModelAliasInfo, error) { + if v == nil { + return nil, nil + } + out := &RegisteredModelAliasInfo{} + out.AliasName = v.AliasName + out.VersionNum = v.VersionNum + out.Id = v.Id + out.ModelName = v.ModelName + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + return out, nil +} + +// RegisteredModelInfoToSDK converts the mirror to the sdk-go type. +func RegisteredModelInfoToSDK(w *RegisteredModelInfo) (*sdk.RegisteredModelInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.RegisteredModelInfo{} + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageLocation = w.StorageLocation + out.MetastoreId = w.MetastoreId + out.FullName = w.FullName + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + conv21, err := convertSlice(w.Aliases, RegisteredModelAliasInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegisteredModelInfo.Aliases", err) + } + out.Aliases = conv21 + out.BrowseOnly = w.BrowseOnly + return out, nil +} + +// RegisteredModelInfoFromSDK converts the sdk-go type to the mirror. +func RegisteredModelInfoFromSDK(v *sdk.RegisteredModelInfo) (*RegisteredModelInfo, error) { + if v == nil { + return nil, nil + } + out := &RegisteredModelInfo{} + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageLocation = v.StorageLocation + out.MetastoreId = v.MetastoreId + out.FullName = v.FullName + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + conv22, err := convertSlice(v.Aliases, RegisteredModelAliasInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RegisteredModelInfo.Aliases", err) + } + out.Aliases = conv22 + out.BrowseOnly = v.BrowseOnly + return out, nil +} + +// SetRegisteredModelAliasRequestToSDK converts the mirror to the sdk-go type. +func SetRegisteredModelAliasRequestToSDK(w *SetRegisteredModelAliasRequest) (*sdk.SetRegisteredModelAliasRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SetRegisteredModelAliasRequest{} + out.FullNameArg = w.FullNameArg + out.AliasArg = w.AliasArg + out.VersionNum = w.VersionNum + return out, nil +} + +// SetRegisteredModelAliasRequestFromSDK converts the sdk-go type to the mirror. +func SetRegisteredModelAliasRequestFromSDK(v *sdk.SetRegisteredModelAliasRequest) (*SetRegisteredModelAliasRequest, error) { + if v == nil { + return nil, nil + } + out := &SetRegisteredModelAliasRequest{} + out.FullNameArg = v.FullNameArg + out.AliasArg = v.AliasArg + out.VersionNum = v.VersionNum + return out, nil +} + +// TableDependencyToSDK converts the mirror to the sdk-go type. +func TableDependencyToSDK(w *TableDependency) (*sdk.TableDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.TableDependency{} + out.TableFullName = w.TableFullName + return out, nil +} + +// TableDependencyFromSDK converts the sdk-go type to the mirror. +func TableDependencyFromSDK(v *sdk.TableDependency) (*TableDependency, error) { + if v == nil { + return nil, nil + } + out := &TableDependency{} + out.TableFullName = v.TableFullName + return out, nil +} + +// UpdateModelVersionRequestToSDK converts the mirror to the sdk-go type. +func UpdateModelVersionRequestToSDK(w *UpdateModelVersionRequest) (*sdk.UpdateModelVersionRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateModelVersionRequest{} + out.FullNameArg = w.FullNameArg + out.VersionArg = w.VersionArg + out.ModelName = w.ModelName + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.Source = w.Source + out.Comment = w.Comment + out.RunId = w.RunId + out.RunWorkspaceId = w.RunWorkspaceId + conv23, err := DependencyListToSDK(w.ModelVersionDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateModelVersionRequest.ModelVersionDependencies", err) + } + out.ModelVersionDependencies = conv23 + out.Status = w.Status + out.Version = w.Version + out.StorageLocation = w.StorageLocation + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.Id = w.Id + conv24, err := convertSlice(w.Aliases, RegisteredModelAliasInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateModelVersionRequest.Aliases", err) + } + out.Aliases = conv24 + return out, nil +} + +// UpdateModelVersionRequestFromSDK converts the sdk-go type to the mirror. +func UpdateModelVersionRequestFromSDK(v *sdk.UpdateModelVersionRequest) (*UpdateModelVersionRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateModelVersionRequest{} + out.FullNameArg = v.FullNameArg + out.VersionArg = v.VersionArg + out.ModelName = v.ModelName + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.Source = v.Source + out.Comment = v.Comment + out.RunId = v.RunId + out.RunWorkspaceId = v.RunWorkspaceId + conv25, err := DependencyListFromSDK(v.ModelVersionDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateModelVersionRequest.ModelVersionDependencies", err) + } + out.ModelVersionDependencies = conv25 + out.Status = v.Status + out.Version = v.Version + out.StorageLocation = v.StorageLocation + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.Id = v.Id + conv26, err := convertSlice(v.Aliases, RegisteredModelAliasInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateModelVersionRequest.Aliases", err) + } + out.Aliases = conv26 + return out, nil +} + +// UpdateRegisteredModelRequestToSDK converts the mirror to the sdk-go type. +func UpdateRegisteredModelRequestToSDK(w *UpdateRegisteredModelRequest) (*sdk.UpdateRegisteredModelRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateRegisteredModelRequest{} + out.FullNameArg = w.FullNameArg + out.NewName = w.NewName + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageLocation = w.StorageLocation + out.MetastoreId = w.MetastoreId + out.FullName = w.FullName + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + conv27, err := convertSlice(w.Aliases, RegisteredModelAliasInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRegisteredModelRequest.Aliases", err) + } + out.Aliases = conv27 + out.BrowseOnly = w.BrowseOnly + return out, nil +} + +// UpdateRegisteredModelRequestFromSDK converts the sdk-go type to the mirror. +func UpdateRegisteredModelRequestFromSDK(v *sdk.UpdateRegisteredModelRequest) (*UpdateRegisteredModelRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateRegisteredModelRequest{} + out.FullNameArg = v.FullNameArg + out.NewName = v.NewName + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageLocation = v.StorageLocation + out.MetastoreId = v.MetastoreId + out.FullName = v.FullName + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + conv28, err := convertSlice(v.Aliases, RegisteredModelAliasInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateRegisteredModelRequest.Aliases", err) + } + out.Aliases = conv28 + out.BrowseOnly = v.BrowseOnly + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/resourcequotas/v1/types.generated.go b/libs/sdktypes/uc/resourcequotas/v1/types.generated.go new file mode 100644 index 00000000000..2d7a84b544a --- /dev/null +++ b/libs/sdktypes/uc/resourcequotas/v1/types.generated.go @@ -0,0 +1,201 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/resourcequotas/v1. DO NOT EDIT. + +package resourcequotas + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/resourcequotas/v1" +) + +type ( + SecurableType = sdk.SecurableType +) + +const ( + SecurableType_Unspecified = sdk.SecurableType_Unspecified + SecurableType_Catalog = sdk.SecurableType_Catalog + SecurableType_Schema = sdk.SecurableType_Schema + SecurableType_Table = sdk.SecurableType_Table + SecurableType_StorageCredential = sdk.SecurableType_StorageCredential + SecurableType_ExternalLocation = sdk.SecurableType_ExternalLocation + SecurableType_Function = sdk.SecurableType_Function + SecurableType_Share = sdk.SecurableType_Share + SecurableType_Provider = sdk.SecurableType_Provider + SecurableType_Recipient = sdk.SecurableType_Recipient + SecurableType_CleanRoom = sdk.SecurableType_CleanRoom + SecurableType_Metastore = sdk.SecurableType_Metastore + SecurableType_Pipeline = sdk.SecurableType_Pipeline + SecurableType_Volume = sdk.SecurableType_Volume + SecurableType_Connection = sdk.SecurableType_Connection + SecurableType_Credential = sdk.SecurableType_Credential + SecurableType_ExternalMetadata = sdk.SecurableType_ExternalMetadata + SecurableType_StagingTable = sdk.SecurableType_StagingTable + SecurableType_Model = sdk.SecurableType_Model + SecurableType_ModelService = sdk.SecurableType_ModelService + SecurableType_McpService = sdk.SecurableType_McpService + SecurableType_ModelProviderService = sdk.SecurableType_ModelProviderService + SecurableType_AgentService = sdk.SecurableType_AgentService + SecurableType_Skill = sdk.SecurableType_Skill +) + +type GetQuotaResponse struct { + // The returned QuotaInfo. + QuotaInfo *QuotaInfo `json:"quota_info,omitempty"` +} + +type ListQuotasRequest struct { + // The number of quotas to return. + MaxResults *int `json:"max_results,omitempty"` + // Opaque token for the next page of results. + PageToken *string `json:"page_token,omitempty"` +} + +type ListQuotasResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request. + NextPageToken *string `json:"next_page_token,omitempty"` + // An array of returned QuotaInfos. + Quotas []QuotaInfo `json:"quotas,omitempty"` +} + +type QuotaInfo struct { + // The timestamp that indicates when the quota count was last updated. + LastRefreshedAt *int64 `json:"last_refreshed_at,omitempty"` + // Name of the parent resource. Returns metastore ID if the parent is a + // metastore. + ParentFullName *string `json:"parent_full_name,omitempty"` + // The quota parent securable type. + ParentSecurableType SecurableType `json:"parent_securable_type,omitempty"` + // The current usage of the resource quota. + QuotaCount *int `json:"quota_count,omitempty"` + // The current limit of the resource quota. + QuotaLimit *int `json:"quota_limit,omitempty"` + // The name of the quota. + QuotaName *string `json:"quota_name,omitempty"` +} + +// GetQuotaResponseToSDK converts the mirror to the sdk-go type. +func GetQuotaResponseToSDK(w *GetQuotaResponse) (*sdk.GetQuotaResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetQuotaResponse{} + conv1, err := QuotaInfoToSDK(w.QuotaInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetQuotaResponse.QuotaInfo", err) + } + out.QuotaInfo = conv1 + return out, nil +} + +// GetQuotaResponseFromSDK converts the sdk-go type to the mirror. +func GetQuotaResponseFromSDK(v *sdk.GetQuotaResponse) (*GetQuotaResponse, error) { + if v == nil { + return nil, nil + } + out := &GetQuotaResponse{} + conv2, err := QuotaInfoFromSDK(v.QuotaInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetQuotaResponse.QuotaInfo", err) + } + out.QuotaInfo = conv2 + return out, nil +} + +// ListQuotasRequestToSDK converts the mirror to the sdk-go type. +func ListQuotasRequestToSDK(w *ListQuotasRequest) (*sdk.ListQuotasRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListQuotasRequest{} + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListQuotasRequestFromSDK converts the sdk-go type to the mirror. +func ListQuotasRequestFromSDK(v *sdk.ListQuotasRequest) (*ListQuotasRequest, error) { + if v == nil { + return nil, nil + } + out := &ListQuotasRequest{} + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListQuotasResponseToSDK converts the mirror to the sdk-go type. +func ListQuotasResponseToSDK(w *ListQuotasResponse) (*sdk.ListQuotasResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListQuotasResponse{} + conv3, err := convertSlice(w.Quotas, QuotaInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListQuotasResponse.Quotas", err) + } + out.Quotas = conv3 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListQuotasResponseFromSDK converts the sdk-go type to the mirror. +func ListQuotasResponseFromSDK(v *sdk.ListQuotasResponse) (*ListQuotasResponse, error) { + if v == nil { + return nil, nil + } + out := &ListQuotasResponse{} + conv4, err := convertSlice(v.Quotas, QuotaInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListQuotasResponse.Quotas", err) + } + out.Quotas = conv4 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// QuotaInfoToSDK converts the mirror to the sdk-go type. +func QuotaInfoToSDK(w *QuotaInfo) (*sdk.QuotaInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.QuotaInfo{} + out.ParentSecurableType = w.ParentSecurableType + out.ParentFullName = w.ParentFullName + out.QuotaName = w.QuotaName + out.QuotaCount = w.QuotaCount + out.QuotaLimit = w.QuotaLimit + out.LastRefreshedAt = w.LastRefreshedAt + return out, nil +} + +// QuotaInfoFromSDK converts the sdk-go type to the mirror. +func QuotaInfoFromSDK(v *sdk.QuotaInfo) (*QuotaInfo, error) { + if v == nil { + return nil, nil + } + out := &QuotaInfo{} + out.ParentSecurableType = v.ParentSecurableType + out.ParentFullName = v.ParentFullName + out.QuotaName = v.QuotaName + out.QuotaCount = v.QuotaCount + out.QuotaLimit = v.QuotaLimit + out.LastRefreshedAt = v.LastRefreshedAt + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/rfa/v1/types.generated.go b/libs/sdktypes/uc/rfa/v1/types.generated.go new file mode 100644 index 00000000000..ba1e624a680 --- /dev/null +++ b/libs/sdktypes/uc/rfa/v1/types.generated.go @@ -0,0 +1,534 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/rfa/v1. DO NOT EDIT. + +package rfa + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/uc/rfa/v1" + strings "strings" +) + +type ( + DestinationType = sdk.DestinationType + PrincipalType = sdk.PrincipalType + SecurableType = sdk.SecurableType + SpecialDestination = sdk.SpecialDestination +) + +const ( + DestinationType_Unspecified = sdk.DestinationType_Unspecified + DestinationType_Email = sdk.DestinationType_Email + DestinationType_Slack = sdk.DestinationType_Slack + DestinationType_GenericWebhook = sdk.DestinationType_GenericWebhook + DestinationType_MicrosoftTeams = sdk.DestinationType_MicrosoftTeams + DestinationType_Url = sdk.DestinationType_Url + PrincipalType_Unspecified = sdk.PrincipalType_Unspecified + PrincipalType_UserPrincipal = sdk.PrincipalType_UserPrincipal + PrincipalType_GroupPrincipal = sdk.PrincipalType_GroupPrincipal + PrincipalType_ServicePrincipal = sdk.PrincipalType_ServicePrincipal + SecurableType_Unspecified = sdk.SecurableType_Unspecified + SecurableType_Catalog = sdk.SecurableType_Catalog + SecurableType_Schema = sdk.SecurableType_Schema + SecurableType_Table = sdk.SecurableType_Table + SecurableType_StorageCredential = sdk.SecurableType_StorageCredential + SecurableType_ExternalLocation = sdk.SecurableType_ExternalLocation + SecurableType_Function = sdk.SecurableType_Function + SecurableType_Share = sdk.SecurableType_Share + SecurableType_Provider = sdk.SecurableType_Provider + SecurableType_Recipient = sdk.SecurableType_Recipient + SecurableType_CleanRoom = sdk.SecurableType_CleanRoom + SecurableType_Metastore = sdk.SecurableType_Metastore + SecurableType_Pipeline = sdk.SecurableType_Pipeline + SecurableType_Volume = sdk.SecurableType_Volume + SecurableType_Connection = sdk.SecurableType_Connection + SecurableType_Credential = sdk.SecurableType_Credential + SecurableType_ExternalMetadata = sdk.SecurableType_ExternalMetadata + SecurableType_StagingTable = sdk.SecurableType_StagingTable + SecurableType_Model = sdk.SecurableType_Model + SecurableType_ModelService = sdk.SecurableType_ModelService + SecurableType_McpService = sdk.SecurableType_McpService + SecurableType_ModelProviderService = sdk.SecurableType_ModelProviderService + SecurableType_AgentService = sdk.SecurableType_AgentService + SecurableType_Skill = sdk.SecurableType_Skill + SpecialDestination_Unspecified = sdk.SpecialDestination_Unspecified + SpecialDestination_SpecialDestinationCatalogOwner = sdk.SpecialDestination_SpecialDestinationCatalogOwner + SpecialDestination_SpecialDestinationExternalLocationOwner = sdk.SpecialDestination_SpecialDestinationExternalLocationOwner + SpecialDestination_SpecialDestinationConnectionOwner = sdk.SpecialDestination_SpecialDestinationConnectionOwner + SpecialDestination_SpecialDestinationCredentialOwner = sdk.SpecialDestination_SpecialDestinationCredentialOwner + SpecialDestination_SpecialDestinationMetastoreOwner = sdk.SpecialDestination_SpecialDestinationMetastoreOwner + SpecialDestination_SpecialDestinationSchemaOwner = sdk.SpecialDestination_SpecialDestinationSchemaOwner + SpecialDestination_SpecialDestinationTableOwner = sdk.SpecialDestination_SpecialDestinationTableOwner + SpecialDestination_SpecialDestinationVolumeOwner = sdk.SpecialDestination_SpecialDestinationVolumeOwner + SpecialDestination_SpecialDestinationFunctionOwner = sdk.SpecialDestination_SpecialDestinationFunctionOwner + SpecialDestination_SpecialDestinationRegisteredModelOwner = sdk.SpecialDestination_SpecialDestinationRegisteredModelOwner +) + +type AccessRequestDestinations struct { + // Indicates whether any destinations are hidden from the caller due to a lack + // of permissions. This value is true if the caller does not have permission to + // see all destinations. + AreAnyDestinationsHidden *bool `json:"are_any_destinations_hidden,omitempty"` + // The source securable from which the destinations are inherited. Either the + // same value as securable (if destination is set directly on the securable) or + // the nearest parent securable with destinations set. + DestinationSourceSecurable *Securable `json:"destination_source_securable,omitempty"` + // The access request destinations for the securable. + Destinations []NotificationDestination `json:"destinations,omitempty"` + // The full name of the securable. Redundant with the name in the securable + // object, but necessary for Terraform integration + FullName *string `json:"full_name,omitempty"` + // The securable for which the access request destinations are being modified or + // read. + Securable *Securable `json:"securable,omitempty"` + // The type of the securable. Redundant with the type in the securable object, + // but necessary for Terraform integration + SecurableType *string `json:"securable_type,omitempty"` +} + +type BatchCreateAccessRequestsRequest struct { + // A list of individual access requests, where each request corresponds to a set + // of permissions being requested on a list of securables for a specified + // principal. + // + // At most 30 requests per API call. + Requests []CreateAccessRequest `json:"requests,omitempty"` +} + +type BatchCreateAccessRequestsResponse struct { + // The access request destinations for each securable object the principal + // requested. + Responses []CreateAccessRequestResponse `json:"responses,omitempty"` +} + +type CreateAccessRequest struct { + // Optional. The principal this request is for. Empty `behalf_of` defaults to + // the requester's identity. + // + // Principals must be unique across the API call. + BehalfOf *Principal `json:"behalf_of,omitempty"` + // Optional. Comment associated with the request. + // + // At most 200 characters, can only contain lowercase/uppercase letters (a-z, + // A-Z), numbers (0-9), punctuation, and spaces. + Comment *string `json:"comment,omitempty"` + // List of securables and their corresponding requested UC privileges. + // + // At most 30 securables can be requested for a principal per batched call. Each + // securable can only be requested once per principal. + SecurablePermissions []SecurablePermissions `json:"securable_permissions,omitempty"` +} + +type CreateAccessRequestResponse struct { + // The principal the request was made on behalf of. + BehalfOf *Principal `json:"behalf_of,omitempty"` + // The access request destinations for all the securables the principal + // requested. + RequestDestinations []AccessRequestDestinations `json:"request_destinations,omitempty"` +} + +type NotificationDestination struct { + // The identifier for the destination. This is the email address for EMAIL + // destinations, the URL for URL destinations, or the unique + // notification destination ID for all other external destinations. + DestinationId *string `json:"destination_id,omitempty"` + // The type of the destination. + DestinationType DestinationType `json:"destination_type,omitempty"` + // This field is used to denote whether the destination is the email of the + // owner of the securable object. The special destination cannot be assigned to + // a securable and only represents the default destination of the securable. The + // securable types that support default special destinations are: "catalog", + // "external_location", "connection", "credential", and "metastore". The + // **destination_type** of a **special_destination** is always EMAIL. + SpecialDestination SpecialDestination `json:"special_destination,omitempty"` +} + +type Principal struct { + // user, group or service principal ID. + Id *string `json:"id,omitempty"` + PrincipalType PrincipalType `json:"principal_type,omitempty"` +} + +// Generic definition of a securable, which is uniquely defined in a metastore +// by its type and full name.. +type Securable struct { + // Required. The full name of the catalog/schema/table. Optional if + // resource_name is present. + FullName *string `json:"full_name,omitempty"` + // Optional. The name of the Share object that contains the securable when the + // securable is getting shared in D2D Delta Sharing. + ProviderShare *string `json:"provider_share,omitempty"` + // Required. The type of securable (catalog/schema/table). Optional if + // resource_name is present. + Type SecurableType `json:"type,omitempty"` +} + +type SecurablePermissions struct { + // List of requested Unity Catalog permissions. + Permissions []string `json:"permissions,omitempty"` + // The securable for which the access request destinations are being requested. + Securable *Securable `json:"securable,omitempty"` +} + +type UpdateAccessRequestDestinationsRequest struct { + // The access request destinations to assign to the securable. For each + // destination, a **destination_id** and **destination_type** must be defined. + AccessRequestDestinations *AccessRequestDestinations `json:"access_request_destinations,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +// AccessRequestDestinationsToSDK converts the mirror to the sdk-go type. +func AccessRequestDestinationsToSDK(w *AccessRequestDestinations) (*sdk.AccessRequestDestinations, error) { + if w == nil { + return nil, nil + } + out := &sdk.AccessRequestDestinations{} + conv1, err := convertSlice(w.Destinations, NotificationDestinationToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccessRequestDestinations.Destinations", err) + } + out.Destinations = conv1 + conv2, err := SecurableToSDK(w.Securable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccessRequestDestinations.Securable", err) + } + out.Securable = conv2 + out.AreAnyDestinationsHidden = w.AreAnyDestinationsHidden + conv3, err := SecurableToSDK(w.DestinationSourceSecurable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccessRequestDestinations.DestinationSourceSecurable", err) + } + out.DestinationSourceSecurable = conv3 + out.SecurableType = w.SecurableType + out.FullName = w.FullName + return out, nil +} + +// AccessRequestDestinationsFromSDK converts the sdk-go type to the mirror. +func AccessRequestDestinationsFromSDK(v *sdk.AccessRequestDestinations) (*AccessRequestDestinations, error) { + if v == nil { + return nil, nil + } + out := &AccessRequestDestinations{} + conv4, err := convertSlice(v.Destinations, NotificationDestinationFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccessRequestDestinations.Destinations", err) + } + out.Destinations = conv4 + conv5, err := SecurableFromSDK(v.Securable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccessRequestDestinations.Securable", err) + } + out.Securable = conv5 + out.AreAnyDestinationsHidden = v.AreAnyDestinationsHidden + conv6, err := SecurableFromSDK(v.DestinationSourceSecurable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "AccessRequestDestinations.DestinationSourceSecurable", err) + } + out.DestinationSourceSecurable = conv6 + out.SecurableType = v.SecurableType + out.FullName = v.FullName + return out, nil +} + +// BatchCreateAccessRequestsRequestToSDK converts the mirror to the sdk-go type. +func BatchCreateAccessRequestsRequestToSDK(w *BatchCreateAccessRequestsRequest) (*sdk.BatchCreateAccessRequestsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.BatchCreateAccessRequestsRequest{} + conv7, err := convertSlice(w.Requests, CreateAccessRequestToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BatchCreateAccessRequestsRequest.Requests", err) + } + out.Requests = conv7 + return out, nil +} + +// BatchCreateAccessRequestsRequestFromSDK converts the sdk-go type to the mirror. +func BatchCreateAccessRequestsRequestFromSDK(v *sdk.BatchCreateAccessRequestsRequest) (*BatchCreateAccessRequestsRequest, error) { + if v == nil { + return nil, nil + } + out := &BatchCreateAccessRequestsRequest{} + conv8, err := convertSlice(v.Requests, CreateAccessRequestFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BatchCreateAccessRequestsRequest.Requests", err) + } + out.Requests = conv8 + return out, nil +} + +// BatchCreateAccessRequestsResponseToSDK converts the mirror to the sdk-go type. +func BatchCreateAccessRequestsResponseToSDK(w *BatchCreateAccessRequestsResponse) (*sdk.BatchCreateAccessRequestsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.BatchCreateAccessRequestsResponse{} + conv9, err := convertSlice(w.Responses, CreateAccessRequestResponseToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BatchCreateAccessRequestsResponse.Responses", err) + } + out.Responses = conv9 + return out, nil +} + +// BatchCreateAccessRequestsResponseFromSDK converts the sdk-go type to the mirror. +func BatchCreateAccessRequestsResponseFromSDK(v *sdk.BatchCreateAccessRequestsResponse) (*BatchCreateAccessRequestsResponse, error) { + if v == nil { + return nil, nil + } + out := &BatchCreateAccessRequestsResponse{} + conv10, err := convertSlice(v.Responses, CreateAccessRequestResponseFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "BatchCreateAccessRequestsResponse.Responses", err) + } + out.Responses = conv10 + return out, nil +} + +// CreateAccessRequestToSDK converts the mirror to the sdk-go type. +func CreateAccessRequestToSDK(w *CreateAccessRequest) (*sdk.CreateAccessRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAccessRequest{} + conv11, err := PrincipalToSDK(w.BehalfOf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccessRequest.BehalfOf", err) + } + out.BehalfOf = conv11 + out.Comment = w.Comment + conv12, err := convertSlice(w.SecurablePermissions, SecurablePermissionsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccessRequest.SecurablePermissions", err) + } + out.SecurablePermissions = conv12 + return out, nil +} + +// CreateAccessRequestFromSDK converts the sdk-go type to the mirror. +func CreateAccessRequestFromSDK(v *sdk.CreateAccessRequest) (*CreateAccessRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateAccessRequest{} + conv13, err := PrincipalFromSDK(v.BehalfOf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccessRequest.BehalfOf", err) + } + out.BehalfOf = conv13 + out.Comment = v.Comment + conv14, err := convertSlice(v.SecurablePermissions, SecurablePermissionsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccessRequest.SecurablePermissions", err) + } + out.SecurablePermissions = conv14 + return out, nil +} + +// CreateAccessRequestResponseToSDK converts the mirror to the sdk-go type. +func CreateAccessRequestResponseToSDK(w *CreateAccessRequestResponse) (*sdk.CreateAccessRequestResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateAccessRequestResponse{} + conv15, err := PrincipalToSDK(w.BehalfOf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccessRequestResponse.BehalfOf", err) + } + out.BehalfOf = conv15 + conv16, err := convertSlice(w.RequestDestinations, AccessRequestDestinationsToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccessRequestResponse.RequestDestinations", err) + } + out.RequestDestinations = conv16 + return out, nil +} + +// CreateAccessRequestResponseFromSDK converts the sdk-go type to the mirror. +func CreateAccessRequestResponseFromSDK(v *sdk.CreateAccessRequestResponse) (*CreateAccessRequestResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateAccessRequestResponse{} + conv17, err := PrincipalFromSDK(v.BehalfOf) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccessRequestResponse.BehalfOf", err) + } + out.BehalfOf = conv17 + conv18, err := convertSlice(v.RequestDestinations, AccessRequestDestinationsFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateAccessRequestResponse.RequestDestinations", err) + } + out.RequestDestinations = conv18 + return out, nil +} + +// NotificationDestinationToSDK converts the mirror to the sdk-go type. +func NotificationDestinationToSDK(w *NotificationDestination) (*sdk.NotificationDestination, error) { + if w == nil { + return nil, nil + } + out := &sdk.NotificationDestination{} + out.DestinationId = w.DestinationId + out.DestinationType = w.DestinationType + out.SpecialDestination = w.SpecialDestination + return out, nil +} + +// NotificationDestinationFromSDK converts the sdk-go type to the mirror. +func NotificationDestinationFromSDK(v *sdk.NotificationDestination) (*NotificationDestination, error) { + if v == nil { + return nil, nil + } + out := &NotificationDestination{} + out.DestinationId = v.DestinationId + out.DestinationType = v.DestinationType + out.SpecialDestination = v.SpecialDestination + return out, nil +} + +// PrincipalToSDK converts the mirror to the sdk-go type. +func PrincipalToSDK(w *Principal) (*sdk.Principal, error) { + if w == nil { + return nil, nil + } + out := &sdk.Principal{} + out.Id = w.Id + out.PrincipalType = w.PrincipalType + return out, nil +} + +// PrincipalFromSDK converts the sdk-go type to the mirror. +func PrincipalFromSDK(v *sdk.Principal) (*Principal, error) { + if v == nil { + return nil, nil + } + out := &Principal{} + out.Id = v.Id + out.PrincipalType = v.PrincipalType + return out, nil +} + +// SecurableToSDK converts the mirror to the sdk-go type. +func SecurableToSDK(w *Securable) (*sdk.Securable, error) { + if w == nil { + return nil, nil + } + out := &sdk.Securable{} + out.Type = w.Type + out.FullName = w.FullName + out.ProviderShare = w.ProviderShare + return out, nil +} + +// SecurableFromSDK converts the sdk-go type to the mirror. +func SecurableFromSDK(v *sdk.Securable) (*Securable, error) { + if v == nil { + return nil, nil + } + out := &Securable{} + out.Type = v.Type + out.FullName = v.FullName + out.ProviderShare = v.ProviderShare + return out, nil +} + +// SecurablePermissionsToSDK converts the mirror to the sdk-go type. +func SecurablePermissionsToSDK(w *SecurablePermissions) (*sdk.SecurablePermissions, error) { + if w == nil { + return nil, nil + } + out := &sdk.SecurablePermissions{} + conv19, err := SecurableToSDK(w.Securable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SecurablePermissions.Securable", err) + } + out.Securable = conv19 + out.Permissions = w.Permissions + return out, nil +} + +// SecurablePermissionsFromSDK converts the sdk-go type to the mirror. +func SecurablePermissionsFromSDK(v *sdk.SecurablePermissions) (*SecurablePermissions, error) { + if v == nil { + return nil, nil + } + out := &SecurablePermissions{} + conv20, err := SecurableFromSDK(v.Securable) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SecurablePermissions.Securable", err) + } + out.Securable = conv20 + out.Permissions = v.Permissions + return out, nil +} + +// UpdateAccessRequestDestinationsRequestToSDK converts the mirror to the sdk-go type. +func UpdateAccessRequestDestinationsRequestToSDK(w *UpdateAccessRequestDestinationsRequest) (*sdk.UpdateAccessRequestDestinationsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateAccessRequestDestinationsRequest{} + conv21, err := AccessRequestDestinationsToSDK(w.AccessRequestDestinations) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccessRequestDestinationsRequest.AccessRequestDestinations", err) + } + out.AccessRequestDestinations = conv21 + mask22, err := fieldMaskFromString[sdk.AccessRequestDestinations](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccessRequestDestinationsRequest.UpdateMask", err) + } + out.UpdateMask = mask22 + return out, nil +} + +// UpdateAccessRequestDestinationsRequestFromSDK converts the sdk-go type to the mirror. +func UpdateAccessRequestDestinationsRequestFromSDK(v *sdk.UpdateAccessRequestDestinationsRequest) (*UpdateAccessRequestDestinationsRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateAccessRequestDestinationsRequest{} + conv23, err := AccessRequestDestinationsFromSDK(v.AccessRequestDestinations) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateAccessRequestDestinationsRequest.AccessRequestDestinations", err) + } + out.AccessRequestDestinations = conv23 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/uc/schemas/v1/types.generated.go b/libs/sdktypes/uc/schemas/v1/types.generated.go new file mode 100644 index 00000000000..28d9879ba21 --- /dev/null +++ b/libs/sdktypes/uc/schemas/v1/types.generated.go @@ -0,0 +1,555 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/schemas/v1. DO NOT EDIT. + +package schemas + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/schemas/v1" +) + +type ( + CatalogType = sdk.CatalogType +) + +const ( + CatalogType_Unspecified = sdk.CatalogType_Unspecified + CatalogType_ManagedCatalog = sdk.CatalogType_ManagedCatalog + CatalogType_DeltasharingCatalog = sdk.CatalogType_DeltasharingCatalog + CatalogType_SystemCatalog = sdk.CatalogType_SystemCatalog + CatalogType_InternalCatalog = sdk.CatalogType_InternalCatalog + CatalogType_ForeignCatalog = sdk.CatalogType_ForeignCatalog + CatalogType_ManagedOnlineCatalog = sdk.CatalogType_ManagedOnlineCatalog +) + +type CreateSchemaRequest struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // Name of parent catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // The type of the parent catalog. + CatalogType CatalogType `json:"catalog_type,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this schema was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of schema creator. + CreatedBy *string `json:"created_by,omitempty"` + // Custom maximum retention period in hours for the schema. + CustomMaxRetentionHours *int64 `json:"custom_max_retention_hours,omitempty"` + EffectivePredictiveOptimizationFlag *EffectivePredictiveOptimizationFlag `json:"effective_predictive_optimization_flag,omitempty"` + // Whether predictive optimization should be enabled for this object and objects + // under it. + EnablePredictiveOptimization *string `json:"enable_predictive_optimization,omitempty"` + // Full name of schema, in form of __catalog_name__.__schema_name__. + FullName *string `json:"full_name,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of schema, relative to parent catalog. + Name *string `json:"name,omitempty"` + // A map of key-value properties attached to the securable. + Options map[string]string `json:"options,omitempty"` + // Username of current owner of schema. + Owner *string `json:"owner,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + // The unique identifier of the schema. + SchemaId *string `json:"schema_id,omitempty"` + // Storage location for managed tables within schema. + StorageLocation *string `json:"storage_location,omitempty"` + // Storage root URL for managed tables within schema. + StorageRoot *string `json:"storage_root,omitempty"` + // Time at which this schema was created, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified schema. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type DeleteSchemaRequest struct { + // Force deletion even if the schema is not empty. + Force *bool `json:"force,omitempty"` + // Full name of the schema. + FullNameArg *string `json:"full_name_arg,omitempty"` +} + +type EffectivePredictiveOptimizationFlag struct { + // The name of the object from which the flag was inherited. If there was no + // inheritance, this field is left blank. + InheritedFromName *string `json:"inherited_from_name,omitempty"` + // The type of the object from which the flag was inherited. If there was no + // inheritance, this field is left blank. + InheritedFromType *string `json:"inherited_from_type,omitempty"` + // Whether predictive optimization should be enabled for this object and objects + // under it. + Value *string `json:"value,omitempty"` +} + +type GetSchemaRequest struct { + // Full name of the schema. + FullNameArg *string `json:"full_name_arg,omitempty"` + // Whether to include schemas in the response for which the principal can only + // access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` +} + +type ListSchemasRequest struct { + // Parent catalog for schemas of interest. + CatalogName *string `json:"catalog_name,omitempty"` + // Whether to include schemas in the response for which the principal can only + // access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` + // Maximum number of schemas to return. If not set, all the schemas are returned + // (not recommended). - when set to a value greater than 0, the page length is + // the minimum of this value and a server configured value; - when set to 0, the + // page length is set to a server configured value (recommended); - when set to + // a value less than 0, an invalid parameter error is returned; + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListSchemasResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // An array of schema information objects. + Schemas []SchemaInfo `json:"schemas,omitempty"` +} + +type SchemaInfo struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // Name of parent catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // The type of the parent catalog. + CatalogType CatalogType `json:"catalog_type,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this schema was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of schema creator. + CreatedBy *string `json:"created_by,omitempty"` + // Custom maximum retention period in hours for the schema. + CustomMaxRetentionHours *int64 `json:"custom_max_retention_hours,omitempty"` + EffectivePredictiveOptimizationFlag *EffectivePredictiveOptimizationFlag `json:"effective_predictive_optimization_flag,omitempty"` + // Whether predictive optimization should be enabled for this object and objects + // under it. + EnablePredictiveOptimization *string `json:"enable_predictive_optimization,omitempty"` + // Full name of schema, in form of __catalog_name__.__schema_name__. + FullName *string `json:"full_name,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of schema, relative to parent catalog. + Name *string `json:"name,omitempty"` + // A map of key-value properties attached to the securable. + Options map[string]string `json:"options,omitempty"` + // Username of current owner of schema. + Owner *string `json:"owner,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + // The unique identifier of the schema. + SchemaId *string `json:"schema_id,omitempty"` + // Storage location for managed tables within schema. + StorageLocation *string `json:"storage_location,omitempty"` + // Storage root URL for managed tables within schema. + StorageRoot *string `json:"storage_root,omitempty"` + // Time at which this schema was created, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified schema. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +type UpdateSchemaRequest struct { + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // Name of parent catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // The type of the parent catalog. + CatalogType CatalogType `json:"catalog_type,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this schema was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of schema creator. + CreatedBy *string `json:"created_by,omitempty"` + // Custom maximum retention period in hours for the schema. + CustomMaxRetentionHours *int64 `json:"custom_max_retention_hours,omitempty"` + EffectivePredictiveOptimizationFlag *EffectivePredictiveOptimizationFlag `json:"effective_predictive_optimization_flag,omitempty"` + // Whether predictive optimization should be enabled for this object and objects + // under it. + EnablePredictiveOptimization *string `json:"enable_predictive_optimization,omitempty"` + // Full name of schema, in form of __catalog_name__.__schema_name__. + FullName *string `json:"full_name,omitempty"` + // Full name of the schema. + FullNameArg *string `json:"full_name_arg,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of schema, relative to parent catalog. + Name *string `json:"name,omitempty"` + // New name for the schema. + NewName *string `json:"new_name,omitempty"` + // A map of key-value properties attached to the securable. + Options map[string]string `json:"options,omitempty"` + // Username of current owner of schema. + Owner *string `json:"owner,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + // The unique identifier of the schema. + SchemaId *string `json:"schema_id,omitempty"` + // Storage location for managed tables within schema. + StorageLocation *string `json:"storage_location,omitempty"` + // Storage root URL for managed tables within schema. + StorageRoot *string `json:"storage_root,omitempty"` + // Time at which this schema was created, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified schema. + UpdatedBy *string `json:"updated_by,omitempty"` +} + +// CreateSchemaRequestToSDK converts the mirror to the sdk-go type. +func CreateSchemaRequestToSDK(w *CreateSchemaRequest) (*sdk.CreateSchemaRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateSchemaRequest{} + out.Name = w.Name + out.CatalogName = w.CatalogName + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageRoot = w.StorageRoot + out.EnablePredictiveOptimization = w.EnablePredictiveOptimization + out.MetastoreId = w.MetastoreId + out.FullName = w.FullName + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.CatalogType = w.CatalogType + out.StorageLocation = w.StorageLocation + conv1, err := EffectivePredictiveOptimizationFlagToSDK(w.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSchemaRequest.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv1 + out.SchemaId = w.SchemaId + out.BrowseOnly = w.BrowseOnly + out.CustomMaxRetentionHours = w.CustomMaxRetentionHours + out.Properties = w.Properties + out.Options = w.Options + return out, nil +} + +// CreateSchemaRequestFromSDK converts the sdk-go type to the mirror. +func CreateSchemaRequestFromSDK(v *sdk.CreateSchemaRequest) (*CreateSchemaRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateSchemaRequest{} + out.Name = v.Name + out.CatalogName = v.CatalogName + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageRoot = v.StorageRoot + out.EnablePredictiveOptimization = v.EnablePredictiveOptimization + out.MetastoreId = v.MetastoreId + out.FullName = v.FullName + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.CatalogType = v.CatalogType + out.StorageLocation = v.StorageLocation + conv2, err := EffectivePredictiveOptimizationFlagFromSDK(v.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSchemaRequest.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv2 + out.SchemaId = v.SchemaId + out.BrowseOnly = v.BrowseOnly + out.CustomMaxRetentionHours = v.CustomMaxRetentionHours + out.Properties = v.Properties + out.Options = v.Options + return out, nil +} + +// DeleteSchemaRequestToSDK converts the mirror to the sdk-go type. +func DeleteSchemaRequestToSDK(w *DeleteSchemaRequest) (*sdk.DeleteSchemaRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteSchemaRequest{} + out.FullNameArg = w.FullNameArg + out.Force = w.Force + return out, nil +} + +// DeleteSchemaRequestFromSDK converts the sdk-go type to the mirror. +func DeleteSchemaRequestFromSDK(v *sdk.DeleteSchemaRequest) (*DeleteSchemaRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteSchemaRequest{} + out.FullNameArg = v.FullNameArg + out.Force = v.Force + return out, nil +} + +// EffectivePredictiveOptimizationFlagToSDK converts the mirror to the sdk-go type. +func EffectivePredictiveOptimizationFlagToSDK(w *EffectivePredictiveOptimizationFlag) (*sdk.EffectivePredictiveOptimizationFlag, error) { + if w == nil { + return nil, nil + } + out := &sdk.EffectivePredictiveOptimizationFlag{} + out.Value = w.Value + out.InheritedFromType = w.InheritedFromType + out.InheritedFromName = w.InheritedFromName + return out, nil +} + +// EffectivePredictiveOptimizationFlagFromSDK converts the sdk-go type to the mirror. +func EffectivePredictiveOptimizationFlagFromSDK(v *sdk.EffectivePredictiveOptimizationFlag) (*EffectivePredictiveOptimizationFlag, error) { + if v == nil { + return nil, nil + } + out := &EffectivePredictiveOptimizationFlag{} + out.Value = v.Value + out.InheritedFromType = v.InheritedFromType + out.InheritedFromName = v.InheritedFromName + return out, nil +} + +// GetSchemaRequestToSDK converts the mirror to the sdk-go type. +func GetSchemaRequestToSDK(w *GetSchemaRequest) (*sdk.GetSchemaRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetSchemaRequest{} + out.FullNameArg = w.FullNameArg + out.IncludeBrowse = w.IncludeBrowse + return out, nil +} + +// GetSchemaRequestFromSDK converts the sdk-go type to the mirror. +func GetSchemaRequestFromSDK(v *sdk.GetSchemaRequest) (*GetSchemaRequest, error) { + if v == nil { + return nil, nil + } + out := &GetSchemaRequest{} + out.FullNameArg = v.FullNameArg + out.IncludeBrowse = v.IncludeBrowse + return out, nil +} + +// ListSchemasRequestToSDK converts the mirror to the sdk-go type. +func ListSchemasRequestToSDK(w *ListSchemasRequest) (*sdk.ListSchemasRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSchemasRequest{} + out.CatalogName = w.CatalogName + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + out.IncludeBrowse = w.IncludeBrowse + return out, nil +} + +// ListSchemasRequestFromSDK converts the sdk-go type to the mirror. +func ListSchemasRequestFromSDK(v *sdk.ListSchemasRequest) (*ListSchemasRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSchemasRequest{} + out.CatalogName = v.CatalogName + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + out.IncludeBrowse = v.IncludeBrowse + return out, nil +} + +// ListSchemasResponseToSDK converts the mirror to the sdk-go type. +func ListSchemasResponseToSDK(w *ListSchemasResponse) (*sdk.ListSchemasResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSchemasResponse{} + conv3, err := convertSlice(w.Schemas, SchemaInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSchemasResponse.Schemas", err) + } + out.Schemas = conv3 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSchemasResponseFromSDK converts the sdk-go type to the mirror. +func ListSchemasResponseFromSDK(v *sdk.ListSchemasResponse) (*ListSchemasResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSchemasResponse{} + conv4, err := convertSlice(v.Schemas, SchemaInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSchemasResponse.Schemas", err) + } + out.Schemas = conv4 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SchemaInfoToSDK converts the mirror to the sdk-go type. +func SchemaInfoToSDK(w *SchemaInfo) (*sdk.SchemaInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.SchemaInfo{} + out.Name = w.Name + out.CatalogName = w.CatalogName + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageRoot = w.StorageRoot + out.EnablePredictiveOptimization = w.EnablePredictiveOptimization + out.MetastoreId = w.MetastoreId + out.FullName = w.FullName + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.CatalogType = w.CatalogType + out.StorageLocation = w.StorageLocation + conv5, err := EffectivePredictiveOptimizationFlagToSDK(w.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaInfo.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv5 + out.SchemaId = w.SchemaId + out.BrowseOnly = w.BrowseOnly + out.CustomMaxRetentionHours = w.CustomMaxRetentionHours + out.Properties = w.Properties + out.Options = w.Options + return out, nil +} + +// SchemaInfoFromSDK converts the sdk-go type to the mirror. +func SchemaInfoFromSDK(v *sdk.SchemaInfo) (*SchemaInfo, error) { + if v == nil { + return nil, nil + } + out := &SchemaInfo{} + out.Name = v.Name + out.CatalogName = v.CatalogName + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageRoot = v.StorageRoot + out.EnablePredictiveOptimization = v.EnablePredictiveOptimization + out.MetastoreId = v.MetastoreId + out.FullName = v.FullName + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.CatalogType = v.CatalogType + out.StorageLocation = v.StorageLocation + conv6, err := EffectivePredictiveOptimizationFlagFromSDK(v.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SchemaInfo.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv6 + out.SchemaId = v.SchemaId + out.BrowseOnly = v.BrowseOnly + out.CustomMaxRetentionHours = v.CustomMaxRetentionHours + out.Properties = v.Properties + out.Options = v.Options + return out, nil +} + +// UpdateSchemaRequestToSDK converts the mirror to the sdk-go type. +func UpdateSchemaRequestToSDK(w *UpdateSchemaRequest) (*sdk.UpdateSchemaRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateSchemaRequest{} + out.FullNameArg = w.FullNameArg + out.NewName = w.NewName + out.Name = w.Name + out.CatalogName = w.CatalogName + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageRoot = w.StorageRoot + out.EnablePredictiveOptimization = w.EnablePredictiveOptimization + out.MetastoreId = w.MetastoreId + out.FullName = w.FullName + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.CatalogType = w.CatalogType + out.StorageLocation = w.StorageLocation + conv7, err := EffectivePredictiveOptimizationFlagToSDK(w.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSchemaRequest.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv7 + out.SchemaId = w.SchemaId + out.BrowseOnly = w.BrowseOnly + out.CustomMaxRetentionHours = w.CustomMaxRetentionHours + out.Properties = w.Properties + out.Options = w.Options + return out, nil +} + +// UpdateSchemaRequestFromSDK converts the sdk-go type to the mirror. +func UpdateSchemaRequestFromSDK(v *sdk.UpdateSchemaRequest) (*UpdateSchemaRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateSchemaRequest{} + out.FullNameArg = v.FullNameArg + out.NewName = v.NewName + out.Name = v.Name + out.CatalogName = v.CatalogName + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageRoot = v.StorageRoot + out.EnablePredictiveOptimization = v.EnablePredictiveOptimization + out.MetastoreId = v.MetastoreId + out.FullName = v.FullName + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.CatalogType = v.CatalogType + out.StorageLocation = v.StorageLocation + conv8, err := EffectivePredictiveOptimizationFlagFromSDK(v.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSchemaRequest.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv8 + out.SchemaId = v.SchemaId + out.BrowseOnly = v.BrowseOnly + out.CustomMaxRetentionHours = v.CustomMaxRetentionHours + out.Properties = v.Properties + out.Options = v.Options + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/secrets/v1/types.generated.go b/libs/sdktypes/uc/secrets/v1/types.generated.go new file mode 100644 index 00000000000..93dbf33fef3 --- /dev/null +++ b/libs/sdktypes/uc/secrets/v1/types.generated.go @@ -0,0 +1,345 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/secrets/v1. DO NOT EDIT. + +package secrets + +import ( + fmt "fmt" + types "github.com/databricks/sdk-go/core/types" + sdk "github.com/databricks/sdk-go/uc/secrets/v1" + strings "strings" +) + +// Request message for CreateSecret.. +type CreateSecretRequest struct { + // The secret object to create. The **name**, **catalog_name**, **schema_name**, + // and **value** fields are required. + Secret *Secret `json:"secret,omitempty"` +} + +// Request message for GetSecret.. +type GetSecretRequest struct { + // The three-level (fully qualified) name of the secret (for example, + // **catalog_name.schema_name.secret_name**). + FullName *string `json:"full_name,omitempty"` + // Whether to include the secret value in the response. Defaults to false. + // Requires the **READ_SECRET** privilege. + IncludeValue *bool `json:"include_value,omitempty"` +} + +// Request message for ListSecrets.. +type ListSecretsRequest struct { + // The name of the catalog under which to list secrets. Both **catalog_name** + // and **schema_name** must be specified together. + CatalogName *string `json:"catalog_name,omitempty"` + // Maximum number of secrets to return. + // + // - If not specified, at most 1000 secrets are returned. - If set to a value + // greater than 0, the page length is the minimum of this value and 1000. - If + // set to 0, the page length is set to 1000. - If set to a value less than 0, an + // invalid parameter error is returned. + PageSize *int `json:"page_size,omitempty"` + // Opaque pagination token to go to the next page based on previous query. The + // maximum page length is determined by a server configured value. + PageToken *string `json:"page_token,omitempty"` + // The name of the schema under which to list secrets. Both **catalog_name** and + // **schema_name** must be specified together. + SchemaName *string `json:"schema_name,omitempty"` +} + +// Response message for ListSecrets.. +type ListSecretsResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. **page_token** should be set to this value for the next request. + NextPageToken *string `json:"next_page_token,omitempty"` + // An array of secret objects. + Secrets []Secret `json:"secrets,omitempty"` +} + +// A secret stored in Unity Catalog. Secrets are three-level namespace objects +// (catalog.schema.secret) that securely store sensitive credential data such as +// passwords, tokens, and keys.. +type Secret struct { + // The name of the catalog where the schema and the secret reside. + CatalogName *string `json:"catalog_name,omitempty"` + // User-provided free-form text description of the secret. + Comment *string `json:"comment,omitempty"` + // The time at which this secret was created. + CreateTime *types.Time `json:"create_time,omitempty"` + // The principal that created the secret. + CreatedBy *string `json:"created_by,omitempty"` + // The effective owner of the secret, which may differ from the directly-set + // **owner** due to inheritance. + EffectiveOwner *string `json:"effective_owner,omitempty"` + // The secret value. Only populated in responses when you have the + // **READ_SECRET** privilege and **include_value** is set to true in the + // request. The maximum size is 60 KiB. + EffectiveValue *string `json:"effective_value,omitempty"` + // User-provided expiration time of the secret. This field indicates when the + // secret should no longer be used and may be displayed as a warning in the UI. + // It is purely informational and does not trigger any automatic actions or + // affect the secret's lifecycle. + ExpireTime *types.Time `json:"expire_time,omitempty"` + // The three-level (fully qualified) name of the secret, in the form of + // **catalog_name.schema_name.secret_name**. + FullName *string `json:"full_name,omitempty"` + // Unique identifier of the metastore hosting the secret. + MetastoreId *string `json:"metastore_id,omitempty"` + // The name of the secret, relative to its parent schema. + Name *string `json:"name,omitempty"` + // The owner of the secret. Defaults to the creating principal on creation. Can + // be updated to transfer ownership of the secret to another principal. + Owner *string `json:"owner,omitempty"` + // The name of the schema where the secret resides. + SchemaName *string `json:"schema_name,omitempty"` + // The time at which this secret was last updated. + UpdateTime *types.Time `json:"update_time,omitempty"` + // The principal that last updated the secret. + UpdatedBy *string `json:"updated_by,omitempty"` + // The secret value to store. This field is input-only and is not returned in + // responses — use the **effective_value** field (via GetSecret with + // **include_value** set to true) to read the secret value. The maximum size is + // 60 KiB (pre-encryption). Accepted content includes passwords, tokens, keys, + // and other sensitive credential data. + Value *string `json:"value,omitempty"` +} + +// Request message for UpdateSecret.. +type UpdateSecretRequest struct { + // The three-level (fully qualified) name of the secret (for example, + // **catalog_name.schema_name.secret_name**). + FullName *string `json:"full_name,omitempty"` + // The secret object containing the fields to update. Only fields specified in + // **update_mask** will be updated. + Secret *Secret `json:"secret,omitempty"` + // The field mask specifying which fields of the secret to update. - If + // **update_mask** is **"*"**, all fields specified in **secret** are updated. - + // If **update_mask** specifies one or more fields, only those fields are + // updated. Each specified field must be set in **secret**. Supported fields: + // **value**, **comment**, **owner**, **expire_time**. To change the secret + // name, delete and recreate the secret. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// CreateSecretRequestToSDK converts the mirror to the sdk-go type. +func CreateSecretRequestToSDK(w *CreateSecretRequest) (*sdk.CreateSecretRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateSecretRequest{} + conv1, err := SecretToSDK(w.Secret) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSecretRequest.Secret", err) + } + out.Secret = conv1 + return out, nil +} + +// CreateSecretRequestFromSDK converts the sdk-go type to the mirror. +func CreateSecretRequestFromSDK(v *sdk.CreateSecretRequest) (*CreateSecretRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateSecretRequest{} + conv2, err := SecretFromSDK(v.Secret) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateSecretRequest.Secret", err) + } + out.Secret = conv2 + return out, nil +} + +// GetSecretRequestToSDK converts the mirror to the sdk-go type. +func GetSecretRequestToSDK(w *GetSecretRequest) (*sdk.GetSecretRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetSecretRequest{} + out.FullName = w.FullName + out.IncludeValue = w.IncludeValue + return out, nil +} + +// GetSecretRequestFromSDK converts the sdk-go type to the mirror. +func GetSecretRequestFromSDK(v *sdk.GetSecretRequest) (*GetSecretRequest, error) { + if v == nil { + return nil, nil + } + out := &GetSecretRequest{} + out.FullName = v.FullName + out.IncludeValue = v.IncludeValue + return out, nil +} + +// ListSecretsRequestToSDK converts the mirror to the sdk-go type. +func ListSecretsRequestToSDK(w *ListSecretsRequest) (*sdk.ListSecretsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSecretsRequest{} + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.PageToken = w.PageToken + out.PageSize = w.PageSize + return out, nil +} + +// ListSecretsRequestFromSDK converts the sdk-go type to the mirror. +func ListSecretsRequestFromSDK(v *sdk.ListSecretsRequest) (*ListSecretsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSecretsRequest{} + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.PageToken = v.PageToken + out.PageSize = v.PageSize + return out, nil +} + +// ListSecretsResponseToSDK converts the mirror to the sdk-go type. +func ListSecretsResponseToSDK(w *ListSecretsResponse) (*sdk.ListSecretsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSecretsResponse{} + conv3, err := convertSlice(w.Secrets, SecretToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSecretsResponse.Secrets", err) + } + out.Secrets = conv3 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSecretsResponseFromSDK converts the sdk-go type to the mirror. +func ListSecretsResponseFromSDK(v *sdk.ListSecretsResponse) (*ListSecretsResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSecretsResponse{} + conv4, err := convertSlice(v.Secrets, SecretFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSecretsResponse.Secrets", err) + } + out.Secrets = conv4 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SecretToSDK converts the mirror to the sdk-go type. +func SecretToSDK(w *Secret) (*sdk.Secret, error) { + if w == nil { + return nil, nil + } + out := &sdk.Secret{} + out.Name = w.Name + out.Owner = w.Owner + out.EffectiveOwner = w.EffectiveOwner + out.MetastoreId = w.MetastoreId + out.CreateTime = w.CreateTime + out.CreatedBy = w.CreatedBy + out.UpdateTime = w.UpdateTime + out.UpdatedBy = w.UpdatedBy + out.Comment = w.Comment + out.FullName = w.FullName + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.Value = w.Value + out.EffectiveValue = w.EffectiveValue + out.ExpireTime = w.ExpireTime + return out, nil +} + +// SecretFromSDK converts the sdk-go type to the mirror. +func SecretFromSDK(v *sdk.Secret) (*Secret, error) { + if v == nil { + return nil, nil + } + out := &Secret{} + out.Name = v.Name + out.Owner = v.Owner + out.EffectiveOwner = v.EffectiveOwner + out.MetastoreId = v.MetastoreId + out.CreateTime = v.CreateTime + out.CreatedBy = v.CreatedBy + out.UpdateTime = v.UpdateTime + out.UpdatedBy = v.UpdatedBy + out.Comment = v.Comment + out.FullName = v.FullName + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.Value = v.Value + out.EffectiveValue = v.EffectiveValue + out.ExpireTime = v.ExpireTime + return out, nil +} + +// UpdateSecretRequestToSDK converts the mirror to the sdk-go type. +func UpdateSecretRequestToSDK(w *UpdateSecretRequest) (*sdk.UpdateSecretRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateSecretRequest{} + out.FullName = w.FullName + conv5, err := SecretToSDK(w.Secret) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSecretRequest.Secret", err) + } + out.Secret = conv5 + mask6, err := fieldMaskFromString[sdk.Secret](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSecretRequest.UpdateMask", err) + } + out.UpdateMask = mask6 + return out, nil +} + +// UpdateSecretRequestFromSDK converts the sdk-go type to the mirror. +func UpdateSecretRequestFromSDK(v *sdk.UpdateSecretRequest) (*UpdateSecretRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateSecretRequest{} + out.FullName = v.FullName + conv7, err := SecretFromSDK(v.Secret) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateSecretRequest.Secret", err) + } + out.Secret = conv7 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/uc/systemschemas/v1/types.generated.go b/libs/sdktypes/uc/systemschemas/v1/types.generated.go new file mode 100644 index 00000000000..e9964252bcb --- /dev/null +++ b/libs/sdktypes/uc/systemschemas/v1/types.generated.go @@ -0,0 +1,164 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/systemschemas/v1. DO NOT EDIT. + +package systemschemas + +import ( + fmt "fmt" + sdk "github.com/databricks/sdk-go/uc/systemschemas/v1" +) + +type EnableSystemSchemaRequest struct { + // the catalog for which the system schema is to enabled in + CatalogName *string `json:"catalog_name,omitempty"` + // The metastore ID under which the system schema lives. + MetastoreId *string `json:"metastore_id,omitempty"` + // Full name of the system schema. + Schema *string `json:"schema,omitempty"` +} + +type ListSystemSchemasRequest struct { + // Maximum number of schemas to return. - When set to 0, the page length is set + // to a server configured value (recommended); - When set to a value greater + // than 0, the page length is the minimum of this value and a server configured + // value; - When set to a value less than 0, an invalid parameter error is + // returned; - If not set, all the schemas are returned (not recommended). + MaxResults *int `json:"max_results,omitempty"` + // The ID for the metastore in which the system schema resides. + MetastoreId *string `json:"metastore_id,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` +} + +type ListSystemSchemasResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // An array of system schema information objects. + Schemas []SystemSchemaInfo `json:"schemas,omitempty"` +} + +type SystemSchemaInfo struct { + // Name of the system schema. + Schema *string `json:"schema,omitempty"` + // The current state of enablement for the system schema. An empty string means + // the system schema is available and ready for opt-in. Possible values: + // AVAILABLE | ENABLE_INITIALIZED | ENABLE_COMPLETED | DISABLE_INITIALIZED | + // UNAVAILABLE | MANAGED + State *string `json:"state,omitempty"` +} + +// EnableSystemSchemaRequestToSDK converts the mirror to the sdk-go type. +func EnableSystemSchemaRequestToSDK(w *EnableSystemSchemaRequest) (*sdk.EnableSystemSchemaRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.EnableSystemSchemaRequest{} + out.Schema = w.Schema + out.MetastoreId = w.MetastoreId + out.CatalogName = w.CatalogName + return out, nil +} + +// EnableSystemSchemaRequestFromSDK converts the sdk-go type to the mirror. +func EnableSystemSchemaRequestFromSDK(v *sdk.EnableSystemSchemaRequest) (*EnableSystemSchemaRequest, error) { + if v == nil { + return nil, nil + } + out := &EnableSystemSchemaRequest{} + out.Schema = v.Schema + out.MetastoreId = v.MetastoreId + out.CatalogName = v.CatalogName + return out, nil +} + +// ListSystemSchemasRequestToSDK converts the mirror to the sdk-go type. +func ListSystemSchemasRequestToSDK(w *ListSystemSchemasRequest) (*sdk.ListSystemSchemasRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSystemSchemasRequest{} + out.MetastoreId = w.MetastoreId + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListSystemSchemasRequestFromSDK converts the sdk-go type to the mirror. +func ListSystemSchemasRequestFromSDK(v *sdk.ListSystemSchemasRequest) (*ListSystemSchemasRequest, error) { + if v == nil { + return nil, nil + } + out := &ListSystemSchemasRequest{} + out.MetastoreId = v.MetastoreId + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListSystemSchemasResponseToSDK converts the mirror to the sdk-go type. +func ListSystemSchemasResponseToSDK(w *ListSystemSchemasResponse) (*sdk.ListSystemSchemasResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListSystemSchemasResponse{} + conv1, err := convertSlice(w.Schemas, SystemSchemaInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSystemSchemasResponse.Schemas", err) + } + out.Schemas = conv1 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListSystemSchemasResponseFromSDK converts the sdk-go type to the mirror. +func ListSystemSchemasResponseFromSDK(v *sdk.ListSystemSchemasResponse) (*ListSystemSchemasResponse, error) { + if v == nil { + return nil, nil + } + out := &ListSystemSchemasResponse{} + conv2, err := convertSlice(v.Schemas, SystemSchemaInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListSystemSchemasResponse.Schemas", err) + } + out.Schemas = conv2 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SystemSchemaInfoToSDK converts the mirror to the sdk-go type. +func SystemSchemaInfoToSDK(w *SystemSchemaInfo) (*sdk.SystemSchemaInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.SystemSchemaInfo{} + out.Schema = w.Schema + out.State = w.State + return out, nil +} + +// SystemSchemaInfoFromSDK converts the sdk-go type to the mirror. +func SystemSchemaInfoFromSDK(v *sdk.SystemSchemaInfo) (*SystemSchemaInfo, error) { + if v == nil { + return nil, nil + } + out := &SystemSchemaInfo{} + out.Schema = v.Schema + out.State = v.State + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/tables/v1/types.generated.go b/libs/sdktypes/uc/tables/v1/types.generated.go new file mode 100644 index 00000000000..0cc5b0d74c0 --- /dev/null +++ b/libs/sdktypes/uc/tables/v1/types.generated.go @@ -0,0 +1,2191 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/tables/v1. DO NOT EDIT. + +package tables + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/tables/v1" + + strings "strings" +) + +type ( + ColumnTypeName = sdk.ColumnTypeName + DataSourceFormat = sdk.DataSourceFormat + SecurableKind = sdk.SecurableKind + SecurableType = sdk.SecurableType + SseEncryptionAlgorithm = sdk.SseEncryptionAlgorithm + TableType = sdk.TableType + OptionSpec_OauthStage = sdk.OptionSpec_OauthStage + OptionSpec_OptionType = sdk.OptionSpec_OptionType +) + +const ( + ColumnTypeName_Unspecified = sdk.ColumnTypeName_Unspecified + ColumnTypeName_Boolean = sdk.ColumnTypeName_Boolean + ColumnTypeName_Byte = sdk.ColumnTypeName_Byte + ColumnTypeName_Short = sdk.ColumnTypeName_Short + ColumnTypeName_Int = sdk.ColumnTypeName_Int + ColumnTypeName_Long = sdk.ColumnTypeName_Long + ColumnTypeName_Float = sdk.ColumnTypeName_Float + ColumnTypeName_Double = sdk.ColumnTypeName_Double + ColumnTypeName_Date = sdk.ColumnTypeName_Date + ColumnTypeName_Timestamp = sdk.ColumnTypeName_Timestamp + ColumnTypeName_String = sdk.ColumnTypeName_String + ColumnTypeName_Binary = sdk.ColumnTypeName_Binary + ColumnTypeName_Decimal = sdk.ColumnTypeName_Decimal + ColumnTypeName_Interval = sdk.ColumnTypeName_Interval + ColumnTypeName_Array = sdk.ColumnTypeName_Array + ColumnTypeName_Struct = sdk.ColumnTypeName_Struct + ColumnTypeName_Map = sdk.ColumnTypeName_Map + ColumnTypeName_Char = sdk.ColumnTypeName_Char + ColumnTypeName_Null = sdk.ColumnTypeName_Null + ColumnTypeName_UserDefinedType = sdk.ColumnTypeName_UserDefinedType + ColumnTypeName_TimestampNtz = sdk.ColumnTypeName_TimestampNtz + ColumnTypeName_Variant = sdk.ColumnTypeName_Variant + ColumnTypeName_Geometry = sdk.ColumnTypeName_Geometry + ColumnTypeName_Geography = sdk.ColumnTypeName_Geography + ColumnTypeName_TableType = sdk.ColumnTypeName_TableType + DataSourceFormat_Unspecified = sdk.DataSourceFormat_Unspecified + DataSourceFormat_Delta = sdk.DataSourceFormat_Delta + DataSourceFormat_Csv = sdk.DataSourceFormat_Csv + DataSourceFormat_Json = sdk.DataSourceFormat_Json + DataSourceFormat_Avro = sdk.DataSourceFormat_Avro + DataSourceFormat_Parquet = sdk.DataSourceFormat_Parquet + DataSourceFormat_Orc = sdk.DataSourceFormat_Orc + DataSourceFormat_Text = sdk.DataSourceFormat_Text + DataSourceFormat_UnityCatalog = sdk.DataSourceFormat_UnityCatalog + DataSourceFormat_Deltasharing = sdk.DataSourceFormat_Deltasharing + DataSourceFormat_DatabricksFormat = sdk.DataSourceFormat_DatabricksFormat + DataSourceFormat_MysqlFormat = sdk.DataSourceFormat_MysqlFormat + DataSourceFormat_OracleFormat = sdk.DataSourceFormat_OracleFormat + DataSourceFormat_PostgresqlFormat = sdk.DataSourceFormat_PostgresqlFormat + DataSourceFormat_RedshiftFormat = sdk.DataSourceFormat_RedshiftFormat + DataSourceFormat_SnowflakeFormat = sdk.DataSourceFormat_SnowflakeFormat + DataSourceFormat_SqldwFormat = sdk.DataSourceFormat_SqldwFormat + DataSourceFormat_SqlserverFormat = sdk.DataSourceFormat_SqlserverFormat + DataSourceFormat_SalesforceFormat = sdk.DataSourceFormat_SalesforceFormat + DataSourceFormat_SalesforceDataCloudFormat = sdk.DataSourceFormat_SalesforceDataCloudFormat + DataSourceFormat_TeradataFormat = sdk.DataSourceFormat_TeradataFormat + DataSourceFormat_BigqueryFormat = sdk.DataSourceFormat_BigqueryFormat + DataSourceFormat_NetsuiteFormat = sdk.DataSourceFormat_NetsuiteFormat + DataSourceFormat_WorkdayRaasFormat = sdk.DataSourceFormat_WorkdayRaasFormat + DataSourceFormat_MongodbFormat = sdk.DataSourceFormat_MongodbFormat + DataSourceFormat_Hive = sdk.DataSourceFormat_Hive + DataSourceFormat_VectorIndexFormat = sdk.DataSourceFormat_VectorIndexFormat + DataSourceFormat_DatabricksRowStoreFormat = sdk.DataSourceFormat_DatabricksRowStoreFormat + DataSourceFormat_DeltaUniformHudi = sdk.DataSourceFormat_DeltaUniformHudi + DataSourceFormat_DeltaUniformIceberg = sdk.DataSourceFormat_DeltaUniformIceberg + DataSourceFormat_Iceberg = sdk.DataSourceFormat_Iceberg + SecurableKind_Unspecified = sdk.SecurableKind_Unspecified + SecurableKind_TableStandard = sdk.SecurableKind_TableStandard + SecurableKind_TableExternal = sdk.SecurableKind_TableExternal + SecurableKind_TableDelta = sdk.SecurableKind_TableDelta + SecurableKind_TableDeltaExternal = sdk.SecurableKind_TableDeltaExternal + SecurableKind_TableView = sdk.SecurableKind_TableView + SecurableKind_TableMetricView = sdk.SecurableKind_TableMetricView + SecurableKind_TableDeltasharing = sdk.SecurableKind_TableDeltasharing + SecurableKind_TableDeltasharingMutable = sdk.SecurableKind_TableDeltasharingMutable + SecurableKind_TableViewDeltasharing = sdk.SecurableKind_TableViewDeltasharing + SecurableKind_TableMetricViewDeltasharing = sdk.SecurableKind_TableMetricViewDeltasharing + SecurableKind_TableMaterializedViewDeltasharing = sdk.SecurableKind_TableMaterializedViewDeltasharing + SecurableKind_TableStreamingLiveTableDeltasharing = sdk.SecurableKind_TableStreamingLiveTableDeltasharing + SecurableKind_TableForeignDeltasharing = sdk.SecurableKind_TableForeignDeltasharing + SecurableKind_TableDeltaIcebergDeltasharing = sdk.SecurableKind_TableDeltaIcebergDeltasharing + SecurableKind_TableDeltasharingOpenDirBased = sdk.SecurableKind_TableDeltasharingOpenDirBased + SecurableKind_TableForeignDeltaDeltasharing = sdk.SecurableKind_TableForeignDeltaDeltasharing + SecurableKind_TableFeatureStore = sdk.SecurableKind_TableFeatureStore + SecurableKind_TableFeatureStoreExternal = sdk.SecurableKind_TableFeatureStoreExternal + SecurableKind_TableStreamingLiveTable = sdk.SecurableKind_TableStreamingLiveTable + SecurableKind_TableSystem = sdk.SecurableKind_TableSystem + SecurableKind_TableSystemDeltasharing = sdk.SecurableKind_TableSystemDeltasharing + SecurableKind_TableMaterializedView = sdk.SecurableKind_TableMaterializedView + SecurableKind_TableInternal = sdk.SecurableKind_TableInternal + SecurableKind_TableForeignBigquery = sdk.SecurableKind_TableForeignBigquery + SecurableKind_TableForeignMysql = sdk.SecurableKind_TableForeignMysql + SecurableKind_TableForeignOracle = sdk.SecurableKind_TableForeignOracle + SecurableKind_TableForeignPostgresql = sdk.SecurableKind_TableForeignPostgresql + SecurableKind_TableForeignSqldw = sdk.SecurableKind_TableForeignSqldw + SecurableKind_TableForeignRedshift = sdk.SecurableKind_TableForeignRedshift + SecurableKind_TableForeignSnowflake = sdk.SecurableKind_TableForeignSnowflake + SecurableKind_TableForeignSqlserver = sdk.SecurableKind_TableForeignSqlserver + SecurableKind_TableForeignSalesforce = sdk.SecurableKind_TableForeignSalesforce + SecurableKind_TableForeignSalesforceDataCloud = sdk.SecurableKind_TableForeignSalesforceDataCloud + SecurableKind_TableForeignSalesforceDataCloudFileSharing = sdk.SecurableKind_TableForeignSalesforceDataCloudFileSharing + SecurableKind_TableForeignSalesforceDataCloudFileSharingView = sdk.SecurableKind_TableForeignSalesforceDataCloudFileSharingView + SecurableKind_TableForeignTeradata = sdk.SecurableKind_TableForeignTeradata + SecurableKind_TableForeignNetsuite = sdk.SecurableKind_TableForeignNetsuite + SecurableKind_TableForeignDatabricks = sdk.SecurableKind_TableForeignDatabricks + SecurableKind_TableForeignWorkdayRaas = sdk.SecurableKind_TableForeignWorkdayRaas + SecurableKind_TableForeignHiveMetastore = sdk.SecurableKind_TableForeignHiveMetastore + SecurableKind_TableForeignHiveMetastoreManaged = sdk.SecurableKind_TableForeignHiveMetastoreManaged + SecurableKind_TableForeignHiveMetastoreDbfsManaged = sdk.SecurableKind_TableForeignHiveMetastoreDbfsManaged + SecurableKind_TableForeignHiveMetastoreExternal = sdk.SecurableKind_TableForeignHiveMetastoreExternal + SecurableKind_TableForeignHiveMetastoreDbfsExternal = sdk.SecurableKind_TableForeignHiveMetastoreDbfsExternal + SecurableKind_TableForeignHiveMetastoreView = sdk.SecurableKind_TableForeignHiveMetastoreView + SecurableKind_TableForeignHiveMetastoreDbfsView = sdk.SecurableKind_TableForeignHiveMetastoreDbfsView + SecurableKind_TableForeignHiveMetastoreShallowCloneManaged = sdk.SecurableKind_TableForeignHiveMetastoreShallowCloneManaged + SecurableKind_TableForeignHiveMetastoreDbfsShallowCloneManaged = sdk.SecurableKind_TableForeignHiveMetastoreDbfsShallowCloneManaged + SecurableKind_TableForeignHiveMetastoreShallowCloneExternal = sdk.SecurableKind_TableForeignHiveMetastoreShallowCloneExternal + SecurableKind_TableForeignHiveMetastoreDbfsShallowCloneExternal = sdk.SecurableKind_TableForeignHiveMetastoreDbfsShallowCloneExternal + SecurableKind_TableForeignMongodb = sdk.SecurableKind_TableForeignMongodb + SecurableKind_TableDeltaUniformHudiExternal = sdk.SecurableKind_TableDeltaUniformHudiExternal + SecurableKind_TableDeltaUniformIcebergExternal = sdk.SecurableKind_TableDeltaUniformIcebergExternal + SecurableKind_TableDeltaUniformIcebergForeignHiveMetastoreExternal = sdk.SecurableKind_TableDeltaUniformIcebergForeignHiveMetastoreExternal + SecurableKind_TableDeltaUniformIcebergForeignHiveMetastoreManaged = sdk.SecurableKind_TableDeltaUniformIcebergForeignHiveMetastoreManaged + SecurableKind_TableDeltaUniformIcebergForeignSnowflake = sdk.SecurableKind_TableDeltaUniformIcebergForeignSnowflake + SecurableKind_TableDeltaUniformIcebergForeignDeltasharing = sdk.SecurableKind_TableDeltaUniformIcebergForeignDeltasharing + SecurableKind_TableDeltaUniformIcebergExternalDeltasharing = sdk.SecurableKind_TableDeltaUniformIcebergExternalDeltasharing + SecurableKind_TableIcebergUniformManaged = sdk.SecurableKind_TableIcebergUniformManaged + SecurableKind_TableDeltaIcebergManaged = sdk.SecurableKind_TableDeltaIcebergManaged + SecurableKind_TableOnlineVectorIndexReplica = sdk.SecurableKind_TableOnlineVectorIndexReplica + SecurableKind_TableOnlineVectorIndexDirect = sdk.SecurableKind_TableOnlineVectorIndexDirect + SecurableKind_TableOnlineView = sdk.SecurableKind_TableOnlineView + SecurableKind_TableDbStorage = sdk.SecurableKind_TableDbStorage + SecurableKind_TableManagedPostgresql = sdk.SecurableKind_TableManagedPostgresql + SecurableType_Unspecified = sdk.SecurableType_Unspecified + SecurableType_Catalog = sdk.SecurableType_Catalog + SecurableType_Schema = sdk.SecurableType_Schema + SecurableType_Table = sdk.SecurableType_Table + SecurableType_StorageCredential = sdk.SecurableType_StorageCredential + SecurableType_ExternalLocation = sdk.SecurableType_ExternalLocation + SecurableType_Function = sdk.SecurableType_Function + SecurableType_Share = sdk.SecurableType_Share + SecurableType_Provider = sdk.SecurableType_Provider + SecurableType_Recipient = sdk.SecurableType_Recipient + SecurableType_CleanRoom = sdk.SecurableType_CleanRoom + SecurableType_Metastore = sdk.SecurableType_Metastore + SecurableType_Pipeline = sdk.SecurableType_Pipeline + SecurableType_Volume = sdk.SecurableType_Volume + SecurableType_Connection = sdk.SecurableType_Connection + SecurableType_Credential = sdk.SecurableType_Credential + SecurableType_ExternalMetadata = sdk.SecurableType_ExternalMetadata + SecurableType_StagingTable = sdk.SecurableType_StagingTable + SecurableType_Model = sdk.SecurableType_Model + SecurableType_ModelService = sdk.SecurableType_ModelService + SecurableType_McpService = sdk.SecurableType_McpService + SecurableType_ModelProviderService = sdk.SecurableType_ModelProviderService + SecurableType_AgentService = sdk.SecurableType_AgentService + SecurableType_Skill = sdk.SecurableType_Skill + SseEncryptionAlgorithm_Unspecified = sdk.SseEncryptionAlgorithm_Unspecified + SseEncryptionAlgorithm_AwsSseS3 = sdk.SseEncryptionAlgorithm_AwsSseS3 + SseEncryptionAlgorithm_AwsSseKms = sdk.SseEncryptionAlgorithm_AwsSseKms + TableType_Unspecified = sdk.TableType_Unspecified + TableType_Managed = sdk.TableType_Managed + TableType_External = sdk.TableType_External + TableType_View = sdk.TableType_View + TableType_MaterializedView = sdk.TableType_MaterializedView + TableType_StreamingTable = sdk.TableType_StreamingTable + TableType_ManagedShallowClone = sdk.TableType_ManagedShallowClone + TableType_Foreign = sdk.TableType_Foreign + TableType_ExternalShallowClone = sdk.TableType_ExternalShallowClone + TableType_MetricView = sdk.TableType_MetricView + OptionSpec_OauthStage_Unspecified = sdk.OptionSpec_OauthStage_Unspecified + OptionSpec_OauthStage_BeforeAuthorizationCode = sdk.OptionSpec_OauthStage_BeforeAuthorizationCode + OptionSpec_OauthStage_BeforeAccessToken = sdk.OptionSpec_OauthStage_BeforeAccessToken + OptionSpec_OptionType_Unspecified = sdk.OptionSpec_OptionType_Unspecified + OptionSpec_OptionType_OptionBoolean = sdk.OptionSpec_OptionType_OptionBoolean + OptionSpec_OptionType_OptionNumber = sdk.OptionSpec_OptionType_OptionNumber + OptionSpec_OptionType_OptionBigint = sdk.OptionSpec_OptionType_OptionBigint + OptionSpec_OptionType_OptionString = sdk.OptionSpec_OptionType_OptionString + OptionSpec_OptionType_OptionEnum = sdk.OptionSpec_OptionType_OptionEnum + OptionSpec_OptionType_OptionServiceCredential = sdk.OptionSpec_OptionType_OptionServiceCredential + OptionSpec_OptionType_OptionMultilineString = sdk.OptionSpec_OptionType_OptionMultilineString +) + +type ColumnInfo struct { + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + Mask *ColumnMask `json:"mask,omitempty"` + // Name of Column. + Name *string `json:"name,omitempty"` + // Whether field may be Null (default: true). + Nullable *bool `json:"nullable,omitempty"` + // Partition index for column. + PartitionIndex *int `json:"partition_index,omitempty"` + // Ordinal position of column (starting at position 0). + Position *int `json:"position,omitempty"` + // Format of IntervalType. + TypeIntervalType *string `json:"type_interval_type,omitempty"` + // Full data type specification, JSON-serialized. + TypeJson *string `json:"type_json,omitempty"` + TypeName ColumnTypeName `json:"type_name,omitempty"` + // Digits of precision; required for DecimalTypes. + TypePrecision *int `json:"type_precision,omitempty"` + // Digits to right of decimal; Required for DecimalTypes. + TypeScale *int `json:"type_scale,omitempty"` + // Full data type specification as SQL/catalogString text. + TypeText *string `json:"type_text,omitempty"` +} + +type ColumnMask struct { + // The full name of the column mask SQL UDF. + FunctionName *string `json:"function_name,omitempty"` + // The list of table columns or literals to be passed as additional arguments to + // a column mask function, carrying the type (column reference vs constant + // literal) of each argument. Deprecated: use using_column_names instead. + UsingArguments []PolicyFunctionArgument `json:"using_arguments,omitempty"` + // The list of additional table columns to be passed as input to the column mask + // function. The first arg of the mask function should be of the type of the + // column being masked and the types of the rest of the args should match the + // types of columns in 'using_column_names'. + UsingColumnNames []string `json:"using_column_names,omitempty"` +} + +// A connection that is dependent on a SQL object.. +type ConnectionDependency struct { + // Full name of the dependent connection, in the form of __connection_name__. + ConnectionName *string `json:"connection_name,omitempty"` +} + +type CreateTableConstraintRequest struct { + Constraint *TableConstraint `json:"constraint,omitempty"` + // The full name of the table referenced by the constraint. + FullNameArg *string `json:"full_name_arg,omitempty"` +} + +type CreateTableRequest struct { + // The AWS access point to use when accesing s3 for this external location. + AccessPoint *string `json:"access_point,omitempty"` + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // Name of parent catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // The array of __ColumnInfo__ definitions of the table's columns. + Columns []ColumnInfo `json:"columns,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this table was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of table creator. + CreatedBy *string `json:"created_by,omitempty"` + // Unique ID of the Data Access Configuration to use with the table data. + DataAccessConfigurationId *string `json:"data_access_configuration_id,omitempty"` + DataSourceFormat DataSourceFormat `json:"data_source_format,omitempty"` + // Time at which this table was deleted, in epoch milliseconds. Field is omitted + // if table is not deleted. + DeletedAt *int64 `json:"deleted_at,omitempty"` + // Information pertaining to current state of the delta table. + DeltaRuntimePropertiesKvpairs *DeltaRuntimePropertiesKvPairs `json:"delta_runtime_properties_kvpairs,omitempty"` + EffectivePredictiveOptimizationFlag *EffectivePredictiveOptimizationFlag `json:"effective_predictive_optimization_flag,omitempty"` + EnablePredictiveOptimization *string `json:"enable_predictive_optimization,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryption_details,omitempty"` + // Full name of table, in form of + // __catalog_name__.__schema_name__.__table_name__ + FullName *string `json:"full_name,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of table, relative to parent schema. + Name *string `json:"name,omitempty"` + // Username of current owner of table. + Owner *string `json:"owner,omitempty"` + // The pipeline ID of the table. Applicable for tables created by pipelines + // (Materialized View, Streaming Table, etc.). + PipelineId *string `json:"pipeline_id,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + RowFilter *RowFilter `json:"row_filter,omitempty"` + // Name of parent schema relative to its parent catalog. + SchemaName *string `json:"schema_name,omitempty"` + // SecurableKindManifest of table, including capabilities the table has. + SecurableKindManifest *SecurableKindManifest `json:"securable_kind_manifest,omitempty"` + // List of schemes whose objects can be referenced without qualification. + SqlPath *string `json:"sql_path,omitempty"` + // Name of the storage credential, when a storage credential is configured for + // use with this table. + StorageCredentialName *string `json:"storage_credential_name,omitempty"` + // Storage root URL for table (for **MANAGED**, **EXTERNAL** tables). + StorageLocation *string `json:"storage_location,omitempty"` + // List of table constraints. Note: this field is not set in the output of the + // __listTables__ API. + TableConstraints []TableConstraint `json:"table_constraints,omitempty"` + // The unique identifier of the table. + TableId *string `json:"table_id,omitempty"` + TableType TableType `json:"table_type,omitempty"` + // Time at which this table was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the table. + UpdatedBy *string `json:"updated_by,omitempty"` + // View definition SQL (when __table_type__ is **VIEW**, **MATERIALIZED_VIEW**, + // or **STREAMING_TABLE**) + ViewDefinition *string `json:"view_definition,omitempty"` + // View dependencies (when table_type == **VIEW** or **MATERIALIZED_VIEW**, + // **STREAMING_TABLE**) - when DependencyList is None, the dependency is not + // provided; - when DependencyList is an empty list, the dependency is provided + // but is empty; - when DependencyList is not an empty list, dependencies are + // provided and recorded. Note: this field is not set in the output of the + // __listTables__ API. + ViewDependencies *DependencyList `json:"view_dependencies,omitempty"` +} + +// A credential that is dependent on a SQL object.. +type CredentialDependency struct { + // Full name of the dependent credential, in the form of __credential_name__. + CredentialName *string `json:"credential_name,omitempty"` +} + +type DeleteTableConstraintRequest struct { + // If true, try deleting all child constraints of the current constraint. If + // false, reject this operation if the current constraint has any child + // constraints. + Cascade *bool `json:"cascade,omitempty"` + // The name of the constraint to delete. + ConstraintName *string `json:"constraint_name,omitempty"` + // Full name of the table referenced by the constraint. + FullNameArg *string `json:"full_name_arg,omitempty"` +} + +// Properties pertaining to the current state of the delta table as given by the +// commit server. This does not contain **delta.*** (input) properties in +// __TableInfo.properties__.. +type DeltaRuntimePropertiesKvPairs struct { + // A map of key-value properties attached to the securable. + DeltaRuntimeProperties map[string]string `json:"delta_runtime_properties,omitempty"` +} + +// A dependency of a SQL object. One of the following fields must be defined: +// __table__, __function__, __connection__, __credential__, __volume__, or +// __secret__.. +type Dependency struct { + Connection *ConnectionDependency `json:"connection,omitempty"` + Credential *CredentialDependency `json:"credential,omitempty"` + Function *FunctionDependency `json:"function,omitempty"` + Table *TableDependency `json:"table,omitempty"` +} + +// A list of dependencies.. +type DependencyList struct { + // Array of dependencies. + Dependencies []Dependency `json:"dependencies,omitempty"` +} + +type EffectivePredictiveOptimizationFlag struct { + // The name of the object from which the flag was inherited. If there was no + // inheritance, this field is left blank. + InheritedFromName *string `json:"inherited_from_name,omitempty"` + // The type of the object from which the flag was inherited. If there was no + // inheritance, this field is left blank. + InheritedFromType *string `json:"inherited_from_type,omitempty"` + // Whether predictive optimization should be enabled for this object and objects + // under it. + Value *string `json:"value,omitempty"` +} + +// Encryption options that apply to clients connecting to cloud storage.. +type EncryptionDetails struct { + SseEncryptionDetails *SseEncryptionDetails `json:"sse_encryption_details,omitempty"` +} + +type ForeignKeyConstraint struct { + // Column names for this constraint. + ChildColumns []string `json:"child_columns,omitempty"` + // The name of the constraint. + Name *string `json:"name,omitempty"` + // Column names for this constraint. + ParentColumns []string `json:"parent_columns,omitempty"` + // The full name of the parent constraint. + ParentTable *string `json:"parent_table,omitempty"` + // True if the constraint is RELY, false or unset if NORELY. + Rely *bool `json:"rely,omitempty"` +} + +// A function that is dependent on a SQL object.. +type FunctionDependency struct { + // Full name of the dependent function, in the form of + // __catalog_name__.__schema_name__.__function_name__. + FunctionFullName *string `json:"function_full_name,omitempty"` +} + +type GetTableRequest struct { + // Full name of the table. + FullNameArg *string `json:"full_name_arg,omitempty"` + // Whether to include tables in the response for which the principal can only + // access selective metadata for. + IncludeBrowse *bool `json:"include_browse,omitempty"` + // Whether delta metadata should be included in the response. + IncludeDeltaMetadata *bool `json:"include_delta_metadata,omitempty"` + // Whether to include a manifest containing table capabilities in the response. + IncludeManifestCapabilities *bool `json:"include_manifest_capabilities,omitempty"` +} + +type ListTableSummariesRequest struct { + // Name of parent catalog for tables of interest. + CatalogName *string `json:"catalog_name,omitempty"` + // Whether to include a manifest containing table capabilities in the response. + IncludeManifestCapabilities *bool `json:"include_manifest_capabilities,omitempty"` + // Maximum number of summaries for tables to return. If not set, the page length + // is set to a server configured value (10000, as of 1/5/2024). - when set to a + // value greater than 0, the page length is the minimum of this value and a + // server configured value (10000, as of 1/5/2024); - when set to 0, the page + // length is set to a server configured value (10000, as of 1/5/2024) + // (recommended); - when set to a value less than 0, an invalid parameter error + // is returned; + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` + // A sql LIKE pattern (% and _) for schema names. All schemas will be returned + // if not set or empty. + SchemaNamePattern *string `json:"schema_name_pattern,omitempty"` + // A sql LIKE pattern (% and _) for table names. All tables will be returned if + // not set or empty. + TableNamePattern *string `json:"table_name_pattern,omitempty"` +} + +type ListTableSummariesResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // List of table summaries. + Tables []TableSummary `json:"tables,omitempty"` +} + +type ListTablesRequest struct { + // Name of parent catalog for tables of interest. + CatalogName *string `json:"catalog_name,omitempty"` + // Whether to include tables in the response for which the principal can only + // access selective metadata for. + IncludeBrowse *bool `json:"include_browse,omitempty"` + // Whether to include a manifest containing table capabilities in the response. + IncludeManifestCapabilities *bool `json:"include_manifest_capabilities,omitempty"` + // Maximum number of tables to return. If not set, all the tables are returned + // (not recommended). - when set to a value greater than 0, the page length is + // the minimum of this value and a server configured value; - when set to 0, the + // page length is set to a server configured value (recommended); - when set to + // a value less than 0, an invalid parameter error is returned; + MaxResults *int `json:"max_results,omitempty"` + // Whether to omit the columns of the table from the response or not. + OmitColumns *bool `json:"omit_columns,omitempty"` + // Whether to omit the properties of the table from the response or not. + OmitProperties *bool `json:"omit_properties,omitempty"` + // Whether to omit the username of the table (e.g. owner, updated_by, + // created_by) from the response or not. + OmitUsername *bool `json:"omit_username,omitempty"` + // Opaque token to send for the next page of results (pagination). + PageToken *string `json:"page_token,omitempty"` + // Parent schema of tables. + SchemaName *string `json:"schema_name,omitempty"` +} + +type ListTablesResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` + // An array of table information objects. + Tables []TableInfo `json:"tables,omitempty"` +} + +type NamedTableConstraint struct { + // The name of the constraint. + Name *string `json:"name,omitempty"` +} + +// Spec of an allowed option on a securable kind and its attributes. This is +// mostly used by UI to provide user friendly hints and descriptions in order to +// facilitate the securable creation process.. +type OptionSpec struct { + // For drop down / radio button selections, UI will want to know the possible + // input values, it can also be used by other option types to limit input + // selections. + AllowedValues []string `json:"allowed_values,omitempty"` + // The default value of the option, for example, value '443' for 'port' option. + DefaultValue *string `json:"default_value,omitempty"` + // A concise user facing description of what the input value of this option + // should look like. + Description *string `json:"description,omitempty"` + // The hint is used on the UI to suggest what the input value can possibly be + // like, for example: example.com for 'host' option. Unlike default value, it + // will not be applied automatically without user input. + Hint *string `json:"hint,omitempty"` + // Indicates whether an option should be displayed with copy button on the UI. + IsCopiable *bool `json:"is_copiable,omitempty"` + // Indicates whether an option can be provided by users in the create/update + // path of an entity. + IsCreatable *bool `json:"is_creatable,omitempty"` + // Is the option value not user settable and is thus not shown on the UI. + IsHidden *bool `json:"is_hidden,omitempty"` + // Specifies whether this option is safe to log, i.e. no sensitive information. + IsLoggable *bool `json:"is_loggable,omitempty"` + // Is the option required. + IsRequired *bool `json:"is_required,omitempty"` + // Is the option value considered secret and thus redacted on the UI. + IsSecret *bool `json:"is_secret,omitempty"` + // Is the option updatable by users. + IsUpdatable *bool `json:"is_updatable,omitempty"` + // The unique name of the option. + Name *string `json:"name,omitempty"` + // Specifies when the option value is displayed on the UI within the OAuth flow. + OauthStage OptionSpec_OauthStage `json:"oauth_stage,omitempty"` + // The type of the option. + Type OptionSpec_OptionType `json:"type,omitempty"` +} + +// A positional argument passed to a row filter or column mask function. +// Distinguishes between column references and literals.. +type PolicyFunctionArgument struct { + Column *string `json:"column,omitempty"` + Constant *string `json:"constant,omitempty"` +} + +type PrimaryKeyConstraint struct { + // Column names for this constraint. + ChildColumns []string `json:"child_columns,omitempty"` + // The name of the constraint. + Name *string `json:"name,omitempty"` + // True if the constraint is RELY, false or unset if NORELY. + Rely *bool `json:"rely,omitempty"` + // Column names that represent a timeseries. + TimeseriesColumns []string `json:"timeseries_columns,omitempty"` +} + +type RowFilter struct { + // The full name of the row filter SQL UDF. + FunctionName *string `json:"function_name,omitempty"` + // The list of table columns or literals to be passed as additional arguments to + // a row filter function, carrying the type (column reference vs constant + // literal) of each argument. Deprecated: use input_column_names instead. + InputArguments []PolicyFunctionArgument `json:"input_arguments,omitempty"` + // The list of table columns to be passed as input to the row filter function. + // The column types should match the types of the filter function arguments. + InputColumnNames []string `json:"input_column_names,omitempty"` +} + +// Manifest of a specific securable kind.. +type SecurableKindManifest struct { + // Privileges that can be assigned to the securable. + AssignablePrivileges []string `json:"assignable_privileges,omitempty"` + // A list of capabilities in the securable kind. + Capabilities []string `json:"capabilities,omitempty"` + // Detailed specs of allowed options. + Options []OptionSpec `json:"options,omitempty"` + // Securable kind to get manifest of. + SecurableKind SecurableKind `json:"securable_kind,omitempty"` + // Securable Type of the kind. + SecurableType SecurableType `json:"securable_type,omitempty"` +} + +// Server-Side Encryption properties for clients communicating with AWS s3.. +type SseEncryptionDetails struct { + // Sets the value of the 'x-amz-server-side-encryption' header in S3 request. + Algorithm SseEncryptionAlgorithm `json:"algorithm,omitempty"` + // Optional. The ARN of the SSE-KMS key used with the S3 location, when + // algorithm = "SSE-KMS". Sets the value of the + // 'x-amz-server-side-encryption-aws-kms-key-id' header. + AwsKmsKeyArn *string `json:"aws_kms_key_arn,omitempty"` +} + +// A table constraint, as defined by *one* of the following fields being set: +// __primary_key_constraint__, __foreign_key_constraint__, +// __named_table_constraint__.. +type TableConstraint struct { + ForeignKeyConstraint *ForeignKeyConstraint `json:"foreign_key_constraint,omitempty"` + NamedTableConstraint *NamedTableConstraint `json:"named_table_constraint,omitempty"` + PrimaryKeyConstraint *PrimaryKeyConstraint `json:"primary_key_constraint,omitempty"` +} + +// A table that is dependent on a SQL object.. +type TableDependency struct { + // Full name of the dependent table, in the form of + // __catalog_name__.__schema_name__.__table_name__. + TableFullName *string `json:"table_full_name,omitempty"` +} + +type TableExistsResponse struct { + // Whether the table exists or not. + TableExists *bool `json:"table_exists,omitempty"` +} + +type TableInfo struct { + // The AWS access point to use when accesing s3 for this external location. + AccessPoint *string `json:"access_point,omitempty"` + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // Name of parent catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // The array of __ColumnInfo__ definitions of the table's columns. + Columns []ColumnInfo `json:"columns,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this table was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of table creator. + CreatedBy *string `json:"created_by,omitempty"` + // Unique ID of the Data Access Configuration to use with the table data. + DataAccessConfigurationId *string `json:"data_access_configuration_id,omitempty"` + DataSourceFormat DataSourceFormat `json:"data_source_format,omitempty"` + // Time at which this table was deleted, in epoch milliseconds. Field is omitted + // if table is not deleted. + DeletedAt *int64 `json:"deleted_at,omitempty"` + // Information pertaining to current state of the delta table. + DeltaRuntimePropertiesKvpairs *DeltaRuntimePropertiesKvPairs `json:"delta_runtime_properties_kvpairs,omitempty"` + EffectivePredictiveOptimizationFlag *EffectivePredictiveOptimizationFlag `json:"effective_predictive_optimization_flag,omitempty"` + EnablePredictiveOptimization *string `json:"enable_predictive_optimization,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryption_details,omitempty"` + // Full name of table, in form of + // __catalog_name__.__schema_name__.__table_name__ + FullName *string `json:"full_name,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of table, relative to parent schema. + Name *string `json:"name,omitempty"` + // Username of current owner of table. + Owner *string `json:"owner,omitempty"` + // The pipeline ID of the table. Applicable for tables created by pipelines + // (Materialized View, Streaming Table, etc.). + PipelineId *string `json:"pipeline_id,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + RowFilter *RowFilter `json:"row_filter,omitempty"` + // Name of parent schema relative to its parent catalog. + SchemaName *string `json:"schema_name,omitempty"` + // SecurableKindManifest of table, including capabilities the table has. + SecurableKindManifest *SecurableKindManifest `json:"securable_kind_manifest,omitempty"` + // List of schemes whose objects can be referenced without qualification. + SqlPath *string `json:"sql_path,omitempty"` + // Name of the storage credential, when a storage credential is configured for + // use with this table. + StorageCredentialName *string `json:"storage_credential_name,omitempty"` + // Storage root URL for table (for **MANAGED**, **EXTERNAL** tables). + StorageLocation *string `json:"storage_location,omitempty"` + // List of table constraints. Note: this field is not set in the output of the + // __listTables__ API. + TableConstraints []TableConstraint `json:"table_constraints,omitempty"` + // The unique identifier of the table. + TableId *string `json:"table_id,omitempty"` + TableType TableType `json:"table_type,omitempty"` + // Time at which this table was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the table. + UpdatedBy *string `json:"updated_by,omitempty"` + // View definition SQL (when __table_type__ is **VIEW**, **MATERIALIZED_VIEW**, + // or **STREAMING_TABLE**) + ViewDefinition *string `json:"view_definition,omitempty"` + // View dependencies (when table_type == **VIEW** or **MATERIALIZED_VIEW**, + // **STREAMING_TABLE**) - when DependencyList is None, the dependency is not + // provided; - when DependencyList is an empty list, the dependency is provided + // but is empty; - when DependencyList is not an empty list, dependencies are + // provided and recorded. Note: this field is not set in the output of the + // __listTables__ API. + ViewDependencies *DependencyList `json:"view_dependencies,omitempty"` +} + +type TableSummary struct { + // The full name of the table. + FullName *string `json:"full_name,omitempty"` + // SecurableKindManifest of table, including capabilities the table has. + SecurableKindManifest *SecurableKindManifest `json:"securable_kind_manifest,omitempty"` + TableType TableType `json:"table_type,omitempty"` +} + +type UpdateTableRequest struct { + // The AWS access point to use when accesing s3 for this external location. + AccessPoint *string `json:"access_point,omitempty"` + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // Name of parent catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // The array of __ColumnInfo__ definitions of the table's columns. + Columns []ColumnInfo `json:"columns,omitempty"` + // User-provided free-form text description. + Comment *string `json:"comment,omitempty"` + // Time at which this table was created, in epoch milliseconds. + CreatedAt *int64 `json:"created_at,omitempty"` + // Username of table creator. + CreatedBy *string `json:"created_by,omitempty"` + // Unique ID of the Data Access Configuration to use with the table data. + DataAccessConfigurationId *string `json:"data_access_configuration_id,omitempty"` + DataSourceFormat DataSourceFormat `json:"data_source_format,omitempty"` + // Time at which this table was deleted, in epoch milliseconds. Field is omitted + // if table is not deleted. + DeletedAt *int64 `json:"deleted_at,omitempty"` + // Information pertaining to current state of the delta table. + DeltaRuntimePropertiesKvpairs *DeltaRuntimePropertiesKvPairs `json:"delta_runtime_properties_kvpairs,omitempty"` + EffectivePredictiveOptimizationFlag *EffectivePredictiveOptimizationFlag `json:"effective_predictive_optimization_flag,omitempty"` + EnablePredictiveOptimization *string `json:"enable_predictive_optimization,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryption_details,omitempty"` + // Full name of table, in form of + // __catalog_name__.__schema_name__.__table_name__ + FullName *string `json:"full_name,omitempty"` + // Full name of the table. + FullNameArg *string `json:"full_name_arg,omitempty"` + // Unique identifier of parent metastore. + MetastoreId *string `json:"metastore_id,omitempty"` + // Name of table, relative to parent schema. + Name *string `json:"name,omitempty"` + // Username of current owner of table. + Owner *string `json:"owner,omitempty"` + // The pipeline ID of the table. Applicable for tables created by pipelines + // (Materialized View, Streaming Table, etc.). + PipelineId *string `json:"pipeline_id,omitempty"` + // A map of key-value properties attached to the securable. + Properties map[string]string `json:"properties,omitempty"` + RowFilter *RowFilter `json:"row_filter,omitempty"` + // Name of parent schema relative to its parent catalog. + SchemaName *string `json:"schema_name,omitempty"` + // SecurableKindManifest of table, including capabilities the table has. + SecurableKindManifest *SecurableKindManifest `json:"securable_kind_manifest,omitempty"` + // List of schemes whose objects can be referenced without qualification. + SqlPath *string `json:"sql_path,omitempty"` + // Name of the storage credential, when a storage credential is configured for + // use with this table. + StorageCredentialName *string `json:"storage_credential_name,omitempty"` + // Storage root URL for table (for **MANAGED**, **EXTERNAL** tables). + StorageLocation *string `json:"storage_location,omitempty"` + // List of table constraints. Note: this field is not set in the output of the + // __listTables__ API. + TableConstraints []TableConstraint `json:"table_constraints,omitempty"` + // The unique identifier of the table. + TableId *string `json:"table_id,omitempty"` + TableType TableType `json:"table_type,omitempty"` + // Time at which this table was last modified, in epoch milliseconds. + UpdatedAt *int64 `json:"updated_at,omitempty"` + // Username of user who last modified the table. + UpdatedBy *string `json:"updated_by,omitempty"` + // View definition SQL (when __table_type__ is **VIEW**, **MATERIALIZED_VIEW**, + // or **STREAMING_TABLE**) + ViewDefinition *string `json:"view_definition,omitempty"` + // View dependencies (when table_type == **VIEW** or **MATERIALIZED_VIEW**, + // **STREAMING_TABLE**) - when DependencyList is None, the dependency is not + // provided; - when DependencyList is an empty list, the dependency is provided + // but is empty; - when DependencyList is not an empty list, dependencies are + // provided and recorded. Note: this field is not set in the output of the + // __listTables__ API. + ViewDependencies *DependencyList `json:"view_dependencies,omitempty"` +} + +// ColumnInfoToSDK converts the mirror to the sdk-go type. +func ColumnInfoToSDK(w *ColumnInfo) (*sdk.ColumnInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnInfo{} + out.Name = w.Name + out.TypeText = w.TypeText + out.TypeName = w.TypeName + out.Position = w.Position + out.TypePrecision = w.TypePrecision + out.TypeScale = w.TypeScale + out.TypeIntervalType = w.TypeIntervalType + out.TypeJson = w.TypeJson + out.Comment = w.Comment + out.Nullable = w.Nullable + out.PartitionIndex = w.PartitionIndex + conv1, err := ColumnMaskToSDK(w.Mask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnInfo.Mask", err) + } + out.Mask = conv1 + return out, nil +} + +// ColumnInfoFromSDK converts the sdk-go type to the mirror. +func ColumnInfoFromSDK(v *sdk.ColumnInfo) (*ColumnInfo, error) { + if v == nil { + return nil, nil + } + out := &ColumnInfo{} + out.Name = v.Name + out.TypeText = v.TypeText + out.TypeName = v.TypeName + out.Position = v.Position + out.TypePrecision = v.TypePrecision + out.TypeScale = v.TypeScale + out.TypeIntervalType = v.TypeIntervalType + out.TypeJson = v.TypeJson + out.Comment = v.Comment + out.Nullable = v.Nullable + out.PartitionIndex = v.PartitionIndex + conv2, err := ColumnMaskFromSDK(v.Mask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnInfo.Mask", err) + } + out.Mask = conv2 + return out, nil +} + +// ColumnMaskToSDK converts the mirror to the sdk-go type. +func ColumnMaskToSDK(w *ColumnMask) (*sdk.ColumnMask, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnMask{} + out.FunctionName = w.FunctionName + out.UsingColumnNames = w.UsingColumnNames + conv3, err := convertSlice(w.UsingArguments, PolicyFunctionArgumentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnMask.UsingArguments", err) + } + out.UsingArguments = conv3 + return out, nil +} + +// ColumnMaskFromSDK converts the sdk-go type to the mirror. +func ColumnMaskFromSDK(v *sdk.ColumnMask) (*ColumnMask, error) { + if v == nil { + return nil, nil + } + out := &ColumnMask{} + out.FunctionName = v.FunctionName + out.UsingColumnNames = v.UsingColumnNames + conv4, err := convertSlice(v.UsingArguments, PolicyFunctionArgumentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ColumnMask.UsingArguments", err) + } + out.UsingArguments = conv4 + return out, nil +} + +// ConnectionDependencyToSDK converts the mirror to the sdk-go type. +func ConnectionDependencyToSDK(w *ConnectionDependency) (*sdk.ConnectionDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.ConnectionDependency{} + out.ConnectionName = w.ConnectionName + return out, nil +} + +// ConnectionDependencyFromSDK converts the sdk-go type to the mirror. +func ConnectionDependencyFromSDK(v *sdk.ConnectionDependency) (*ConnectionDependency, error) { + if v == nil { + return nil, nil + } + out := &ConnectionDependency{} + out.ConnectionName = v.ConnectionName + return out, nil +} + +// CreateTableConstraintRequestToSDK converts the mirror to the sdk-go type. +func CreateTableConstraintRequestToSDK(w *CreateTableConstraintRequest) (*sdk.CreateTableConstraintRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateTableConstraintRequest{} + out.FullNameArg = w.FullNameArg + conv5, err := TableConstraintToSDK(w.Constraint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableConstraintRequest.Constraint", err) + } + out.Constraint = conv5 + return out, nil +} + +// CreateTableConstraintRequestFromSDK converts the sdk-go type to the mirror. +func CreateTableConstraintRequestFromSDK(v *sdk.CreateTableConstraintRequest) (*CreateTableConstraintRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateTableConstraintRequest{} + out.FullNameArg = v.FullNameArg + conv6, err := TableConstraintFromSDK(v.Constraint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableConstraintRequest.Constraint", err) + } + out.Constraint = conv6 + return out, nil +} + +// CreateTableRequestToSDK converts the mirror to the sdk-go type. +func CreateTableRequestToSDK(w *CreateTableRequest) (*sdk.CreateTableRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateTableRequest{} + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.TableType = w.TableType + out.DataSourceFormat = w.DataSourceFormat + out.StorageLocation = w.StorageLocation + out.ViewDefinition = w.ViewDefinition + conv7, err := DependencyListToSDK(w.ViewDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.ViewDependencies", err) + } + out.ViewDependencies = conv7 + out.SqlPath = w.SqlPath + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageCredentialName = w.StorageCredentialName + conv8, err := convertSlice(w.TableConstraints, TableConstraintToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.TableConstraints", err) + } + out.TableConstraints = conv8 + conv9, err := RowFilterToSDK(w.RowFilter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.RowFilter", err) + } + out.RowFilter = conv9 + out.PipelineId = w.PipelineId + out.EnablePredictiveOptimization = w.EnablePredictiveOptimization + out.MetastoreId = w.MetastoreId + out.FullName = w.FullName + out.DataAccessConfigurationId = w.DataAccessConfigurationId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.TableId = w.TableId + conv10, err := DeltaRuntimePropertiesKvPairsToSDK(w.DeltaRuntimePropertiesKvpairs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.DeltaRuntimePropertiesKvpairs", err) + } + out.DeltaRuntimePropertiesKvpairs = conv10 + out.DeletedAt = w.DeletedAt + conv11, err := EffectivePredictiveOptimizationFlagToSDK(w.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv11 + out.AccessPoint = w.AccessPoint + out.BrowseOnly = w.BrowseOnly + conv12, err := EncryptionDetailsToSDK(w.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.EncryptionDetails", err) + } + out.EncryptionDetails = conv12 + conv13, err := SecurableKindManifestToSDK(w.SecurableKindManifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.SecurableKindManifest", err) + } + out.SecurableKindManifest = conv13 + conv14, err := convertSlice(w.Columns, ColumnInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.Columns", err) + } + out.Columns = conv14 + out.Properties = w.Properties + return out, nil +} + +// CreateTableRequestFromSDK converts the sdk-go type to the mirror. +func CreateTableRequestFromSDK(v *sdk.CreateTableRequest) (*CreateTableRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateTableRequest{} + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.TableType = v.TableType + out.DataSourceFormat = v.DataSourceFormat + out.StorageLocation = v.StorageLocation + out.ViewDefinition = v.ViewDefinition + conv15, err := DependencyListFromSDK(v.ViewDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.ViewDependencies", err) + } + out.ViewDependencies = conv15 + out.SqlPath = v.SqlPath + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageCredentialName = v.StorageCredentialName + conv16, err := convertSlice(v.TableConstraints, TableConstraintFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.TableConstraints", err) + } + out.TableConstraints = conv16 + conv17, err := RowFilterFromSDK(v.RowFilter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.RowFilter", err) + } + out.RowFilter = conv17 + out.PipelineId = v.PipelineId + out.EnablePredictiveOptimization = v.EnablePredictiveOptimization + out.MetastoreId = v.MetastoreId + out.FullName = v.FullName + out.DataAccessConfigurationId = v.DataAccessConfigurationId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.TableId = v.TableId + conv18, err := DeltaRuntimePropertiesKvPairsFromSDK(v.DeltaRuntimePropertiesKvpairs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.DeltaRuntimePropertiesKvpairs", err) + } + out.DeltaRuntimePropertiesKvpairs = conv18 + out.DeletedAt = v.DeletedAt + conv19, err := EffectivePredictiveOptimizationFlagFromSDK(v.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv19 + out.AccessPoint = v.AccessPoint + out.BrowseOnly = v.BrowseOnly + conv20, err := EncryptionDetailsFromSDK(v.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.EncryptionDetails", err) + } + out.EncryptionDetails = conv20 + conv21, err := SecurableKindManifestFromSDK(v.SecurableKindManifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.SecurableKindManifest", err) + } + out.SecurableKindManifest = conv21 + conv22, err := convertSlice(v.Columns, ColumnInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateTableRequest.Columns", err) + } + out.Columns = conv22 + out.Properties = v.Properties + return out, nil +} + +// CredentialDependencyToSDK converts the mirror to the sdk-go type. +func CredentialDependencyToSDK(w *CredentialDependency) (*sdk.CredentialDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.CredentialDependency{} + out.CredentialName = w.CredentialName + return out, nil +} + +// CredentialDependencyFromSDK converts the sdk-go type to the mirror. +func CredentialDependencyFromSDK(v *sdk.CredentialDependency) (*CredentialDependency, error) { + if v == nil { + return nil, nil + } + out := &CredentialDependency{} + out.CredentialName = v.CredentialName + return out, nil +} + +// DeleteTableConstraintRequestToSDK converts the mirror to the sdk-go type. +func DeleteTableConstraintRequestToSDK(w *DeleteTableConstraintRequest) (*sdk.DeleteTableConstraintRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteTableConstraintRequest{} + out.FullNameArg = w.FullNameArg + out.ConstraintName = w.ConstraintName + out.Cascade = w.Cascade + return out, nil +} + +// DeleteTableConstraintRequestFromSDK converts the sdk-go type to the mirror. +func DeleteTableConstraintRequestFromSDK(v *sdk.DeleteTableConstraintRequest) (*DeleteTableConstraintRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteTableConstraintRequest{} + out.FullNameArg = v.FullNameArg + out.ConstraintName = v.ConstraintName + out.Cascade = v.Cascade + return out, nil +} + +// DeltaRuntimePropertiesKvPairsToSDK converts the mirror to the sdk-go type. +func DeltaRuntimePropertiesKvPairsToSDK(w *DeltaRuntimePropertiesKvPairs) (*sdk.DeltaRuntimePropertiesKvPairs, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeltaRuntimePropertiesKvPairs{} + out.DeltaRuntimeProperties = w.DeltaRuntimeProperties + return out, nil +} + +// DeltaRuntimePropertiesKvPairsFromSDK converts the sdk-go type to the mirror. +func DeltaRuntimePropertiesKvPairsFromSDK(v *sdk.DeltaRuntimePropertiesKvPairs) (*DeltaRuntimePropertiesKvPairs, error) { + if v == nil { + return nil, nil + } + out := &DeltaRuntimePropertiesKvPairs{} + out.DeltaRuntimeProperties = v.DeltaRuntimeProperties + return out, nil +} + +// DependencyToSDK converts the mirror to the sdk-go type. +func DependencyToSDK(w *Dependency) (*sdk.Dependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.Dependency{} + { + var members []string + if w.Table != nil { + members = append(members, "table") + } + if w.Function != nil { + members = append(members, "function") + } + if w.Connection != nil { + members = append(members, "connection") + } + if w.Credential != nil { + members = append(members, "credential") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Table != nil: + conv23, err := TableDependencyToSDK(w.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Table{Table: *conv23} + case w.Function != nil: + conv24, err := FunctionDependencyToSDK(w.Function) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Function{Function: *conv24} + case w.Connection != nil: + conv25, err := ConnectionDependencyToSDK(w.Connection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Connection{Connection: *conv25} + case w.Credential != nil: + conv26, err := CredentialDependencyToSDK(w.Credential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Value = &sdk.Dependency_Value_Credential{Credential: *conv26} + } + return out, nil +} + +// DependencyFromSDK converts the sdk-go type to the mirror. +func DependencyFromSDK(v *sdk.Dependency) (*Dependency, error) { + if v == nil { + return nil, nil + } + out := &Dependency{} + switch value := v.Value.(type) { + case *sdk.Dependency_Value_Table: + if value != nil { + conv27, err := TableDependencyFromSDK(&value.Table) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Table = conv27 + } + case *sdk.Dependency_Value_Function: + if value != nil { + conv28, err := FunctionDependencyFromSDK(&value.Function) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Function = conv28 + } + case *sdk.Dependency_Value_Connection: + if value != nil { + conv29, err := ConnectionDependencyFromSDK(&value.Connection) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Connection = conv29 + } + case *sdk.Dependency_Value_Credential: + if value != nil { + conv30, err := CredentialDependencyFromSDK(&value.Credential) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Dependency.Value", err) + } + out.Credential = conv30 + } + } + return out, nil +} + +// DependencyListToSDK converts the mirror to the sdk-go type. +func DependencyListToSDK(w *DependencyList) (*sdk.DependencyList, error) { + if w == nil { + return nil, nil + } + out := &sdk.DependencyList{} + conv31, err := convertSlice(w.Dependencies, DependencyToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DependencyList.Dependencies", err) + } + out.Dependencies = conv31 + return out, nil +} + +// DependencyListFromSDK converts the sdk-go type to the mirror. +func DependencyListFromSDK(v *sdk.DependencyList) (*DependencyList, error) { + if v == nil { + return nil, nil + } + out := &DependencyList{} + conv32, err := convertSlice(v.Dependencies, DependencyFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DependencyList.Dependencies", err) + } + out.Dependencies = conv32 + return out, nil +} + +// EffectivePredictiveOptimizationFlagToSDK converts the mirror to the sdk-go type. +func EffectivePredictiveOptimizationFlagToSDK(w *EffectivePredictiveOptimizationFlag) (*sdk.EffectivePredictiveOptimizationFlag, error) { + if w == nil { + return nil, nil + } + out := &sdk.EffectivePredictiveOptimizationFlag{} + out.Value = w.Value + out.InheritedFromType = w.InheritedFromType + out.InheritedFromName = w.InheritedFromName + return out, nil +} + +// EffectivePredictiveOptimizationFlagFromSDK converts the sdk-go type to the mirror. +func EffectivePredictiveOptimizationFlagFromSDK(v *sdk.EffectivePredictiveOptimizationFlag) (*EffectivePredictiveOptimizationFlag, error) { + if v == nil { + return nil, nil + } + out := &EffectivePredictiveOptimizationFlag{} + out.Value = v.Value + out.InheritedFromType = v.InheritedFromType + out.InheritedFromName = v.InheritedFromName + return out, nil +} + +// EncryptionDetailsToSDK converts the mirror to the sdk-go type. +func EncryptionDetailsToSDK(w *EncryptionDetails) (*sdk.EncryptionDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.EncryptionDetails{} + { + var members []string + if w.SseEncryptionDetails != nil { + members = append(members, "sse_encryption_details") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.SseEncryptionDetails != nil: + conv33, err := SseEncryptionDetailsToSDK(w.SseEncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EncryptionDetails.EncryptionDetailsType", err) + } + out.EncryptionDetailsType = &sdk.EncryptionDetails_EncryptionDetailsType_SseEncryptionDetails{SseEncryptionDetails: *conv33} + } + return out, nil +} + +// EncryptionDetailsFromSDK converts the sdk-go type to the mirror. +func EncryptionDetailsFromSDK(v *sdk.EncryptionDetails) (*EncryptionDetails, error) { + if v == nil { + return nil, nil + } + out := &EncryptionDetails{} + switch value := v.EncryptionDetailsType.(type) { + case *sdk.EncryptionDetails_EncryptionDetailsType_SseEncryptionDetails: + if value != nil { + conv34, err := SseEncryptionDetailsFromSDK(&value.SseEncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EncryptionDetails.EncryptionDetailsType", err) + } + out.SseEncryptionDetails = conv34 + } + } + return out, nil +} + +// ForeignKeyConstraintToSDK converts the mirror to the sdk-go type. +func ForeignKeyConstraintToSDK(w *ForeignKeyConstraint) (*sdk.ForeignKeyConstraint, error) { + if w == nil { + return nil, nil + } + out := &sdk.ForeignKeyConstraint{} + out.Name = w.Name + out.ChildColumns = w.ChildColumns + out.ParentTable = w.ParentTable + out.ParentColumns = w.ParentColumns + out.Rely = w.Rely + return out, nil +} + +// ForeignKeyConstraintFromSDK converts the sdk-go type to the mirror. +func ForeignKeyConstraintFromSDK(v *sdk.ForeignKeyConstraint) (*ForeignKeyConstraint, error) { + if v == nil { + return nil, nil + } + out := &ForeignKeyConstraint{} + out.Name = v.Name + out.ChildColumns = v.ChildColumns + out.ParentTable = v.ParentTable + out.ParentColumns = v.ParentColumns + out.Rely = v.Rely + return out, nil +} + +// FunctionDependencyToSDK converts the mirror to the sdk-go type. +func FunctionDependencyToSDK(w *FunctionDependency) (*sdk.FunctionDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.FunctionDependency{} + out.FunctionFullName = w.FunctionFullName + return out, nil +} + +// FunctionDependencyFromSDK converts the sdk-go type to the mirror. +func FunctionDependencyFromSDK(v *sdk.FunctionDependency) (*FunctionDependency, error) { + if v == nil { + return nil, nil + } + out := &FunctionDependency{} + out.FunctionFullName = v.FunctionFullName + return out, nil +} + +// GetTableRequestToSDK converts the mirror to the sdk-go type. +func GetTableRequestToSDK(w *GetTableRequest) (*sdk.GetTableRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetTableRequest{} + out.FullNameArg = w.FullNameArg + out.IncludeDeltaMetadata = w.IncludeDeltaMetadata + out.IncludeBrowse = w.IncludeBrowse + out.IncludeManifestCapabilities = w.IncludeManifestCapabilities + return out, nil +} + +// GetTableRequestFromSDK converts the sdk-go type to the mirror. +func GetTableRequestFromSDK(v *sdk.GetTableRequest) (*GetTableRequest, error) { + if v == nil { + return nil, nil + } + out := &GetTableRequest{} + out.FullNameArg = v.FullNameArg + out.IncludeDeltaMetadata = v.IncludeDeltaMetadata + out.IncludeBrowse = v.IncludeBrowse + out.IncludeManifestCapabilities = v.IncludeManifestCapabilities + return out, nil +} + +// ListTableSummariesRequestToSDK converts the mirror to the sdk-go type. +func ListTableSummariesRequestToSDK(w *ListTableSummariesRequest) (*sdk.ListTableSummariesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTableSummariesRequest{} + out.CatalogName = w.CatalogName + out.SchemaNamePattern = w.SchemaNamePattern + out.TableNamePattern = w.TableNamePattern + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + out.IncludeManifestCapabilities = w.IncludeManifestCapabilities + return out, nil +} + +// ListTableSummariesRequestFromSDK converts the sdk-go type to the mirror. +func ListTableSummariesRequestFromSDK(v *sdk.ListTableSummariesRequest) (*ListTableSummariesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListTableSummariesRequest{} + out.CatalogName = v.CatalogName + out.SchemaNamePattern = v.SchemaNamePattern + out.TableNamePattern = v.TableNamePattern + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + out.IncludeManifestCapabilities = v.IncludeManifestCapabilities + return out, nil +} + +// ListTableSummariesResponseToSDK converts the mirror to the sdk-go type. +func ListTableSummariesResponseToSDK(w *ListTableSummariesResponse) (*sdk.ListTableSummariesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTableSummariesResponse{} + conv35, err := convertSlice(w.Tables, TableSummaryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTableSummariesResponse.Tables", err) + } + out.Tables = conv35 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListTableSummariesResponseFromSDK converts the sdk-go type to the mirror. +func ListTableSummariesResponseFromSDK(v *sdk.ListTableSummariesResponse) (*ListTableSummariesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListTableSummariesResponse{} + conv36, err := convertSlice(v.Tables, TableSummaryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTableSummariesResponse.Tables", err) + } + out.Tables = conv36 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListTablesRequestToSDK converts the mirror to the sdk-go type. +func ListTablesRequestToSDK(w *ListTablesRequest) (*sdk.ListTablesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTablesRequest{} + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + out.OmitColumns = w.OmitColumns + out.OmitProperties = w.OmitProperties + out.OmitUsername = w.OmitUsername + out.IncludeBrowse = w.IncludeBrowse + out.IncludeManifestCapabilities = w.IncludeManifestCapabilities + return out, nil +} + +// ListTablesRequestFromSDK converts the sdk-go type to the mirror. +func ListTablesRequestFromSDK(v *sdk.ListTablesRequest) (*ListTablesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListTablesRequest{} + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + out.OmitColumns = v.OmitColumns + out.OmitProperties = v.OmitProperties + out.OmitUsername = v.OmitUsername + out.IncludeBrowse = v.IncludeBrowse + out.IncludeManifestCapabilities = v.IncludeManifestCapabilities + return out, nil +} + +// ListTablesResponseToSDK converts the mirror to the sdk-go type. +func ListTablesResponseToSDK(w *ListTablesResponse) (*sdk.ListTablesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListTablesResponse{} + conv37, err := convertSlice(w.Tables, TableInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTablesResponse.Tables", err) + } + out.Tables = conv37 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListTablesResponseFromSDK converts the sdk-go type to the mirror. +func ListTablesResponseFromSDK(v *sdk.ListTablesResponse) (*ListTablesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListTablesResponse{} + conv38, err := convertSlice(v.Tables, TableInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListTablesResponse.Tables", err) + } + out.Tables = conv38 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// NamedTableConstraintToSDK converts the mirror to the sdk-go type. +func NamedTableConstraintToSDK(w *NamedTableConstraint) (*sdk.NamedTableConstraint, error) { + if w == nil { + return nil, nil + } + out := &sdk.NamedTableConstraint{} + out.Name = w.Name + return out, nil +} + +// NamedTableConstraintFromSDK converts the sdk-go type to the mirror. +func NamedTableConstraintFromSDK(v *sdk.NamedTableConstraint) (*NamedTableConstraint, error) { + if v == nil { + return nil, nil + } + out := &NamedTableConstraint{} + out.Name = v.Name + return out, nil +} + +// OptionSpecToSDK converts the mirror to the sdk-go type. +func OptionSpecToSDK(w *OptionSpec) (*sdk.OptionSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.OptionSpec{} + out.Name = w.Name + out.Type = w.Type + out.DefaultValue = w.DefaultValue + out.AllowedValues = w.AllowedValues + out.Hint = w.Hint + out.Description = w.Description + out.IsRequired = w.IsRequired + out.IsSecret = w.IsSecret + out.IsHidden = w.IsHidden + out.IsUpdatable = w.IsUpdatable + out.OauthStage = w.OauthStage + out.IsLoggable = w.IsLoggable + out.IsCreatable = w.IsCreatable + out.IsCopiable = w.IsCopiable + return out, nil +} + +// OptionSpecFromSDK converts the sdk-go type to the mirror. +func OptionSpecFromSDK(v *sdk.OptionSpec) (*OptionSpec, error) { + if v == nil { + return nil, nil + } + out := &OptionSpec{} + out.Name = v.Name + out.Type = v.Type + out.DefaultValue = v.DefaultValue + out.AllowedValues = v.AllowedValues + out.Hint = v.Hint + out.Description = v.Description + out.IsRequired = v.IsRequired + out.IsSecret = v.IsSecret + out.IsHidden = v.IsHidden + out.IsUpdatable = v.IsUpdatable + out.OauthStage = v.OauthStage + out.IsLoggable = v.IsLoggable + out.IsCreatable = v.IsCreatable + out.IsCopiable = v.IsCopiable + return out, nil +} + +// PolicyFunctionArgumentToSDK converts the mirror to the sdk-go type. +func PolicyFunctionArgumentToSDK(w *PolicyFunctionArgument) (*sdk.PolicyFunctionArgument, error) { + if w == nil { + return nil, nil + } + out := &sdk.PolicyFunctionArgument{} + { + var members []string + if w.Column != nil { + members = append(members, "column") + } + if w.Constant != nil { + members = append(members, "constant") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Column != nil: + out.Arg = &sdk.PolicyFunctionArgument_Arg_Column{Column: *w.Column} + case w.Constant != nil: + out.Arg = &sdk.PolicyFunctionArgument_Arg_Constant{Constant: *w.Constant} + } + return out, nil +} + +// PolicyFunctionArgumentFromSDK converts the sdk-go type to the mirror. +func PolicyFunctionArgumentFromSDK(v *sdk.PolicyFunctionArgument) (*PolicyFunctionArgument, error) { + if v == nil { + return nil, nil + } + out := &PolicyFunctionArgument{} + switch value := v.Arg.(type) { + case *sdk.PolicyFunctionArgument_Arg_Column: + if value != nil { + out.Column = new(value.Column) + } + case *sdk.PolicyFunctionArgument_Arg_Constant: + if value != nil { + out.Constant = new(value.Constant) + } + } + return out, nil +} + +// PrimaryKeyConstraintToSDK converts the mirror to the sdk-go type. +func PrimaryKeyConstraintToSDK(w *PrimaryKeyConstraint) (*sdk.PrimaryKeyConstraint, error) { + if w == nil { + return nil, nil + } + out := &sdk.PrimaryKeyConstraint{} + out.Name = w.Name + out.ChildColumns = w.ChildColumns + out.TimeseriesColumns = w.TimeseriesColumns + out.Rely = w.Rely + return out, nil +} + +// PrimaryKeyConstraintFromSDK converts the sdk-go type to the mirror. +func PrimaryKeyConstraintFromSDK(v *sdk.PrimaryKeyConstraint) (*PrimaryKeyConstraint, error) { + if v == nil { + return nil, nil + } + out := &PrimaryKeyConstraint{} + out.Name = v.Name + out.ChildColumns = v.ChildColumns + out.TimeseriesColumns = v.TimeseriesColumns + out.Rely = v.Rely + return out, nil +} + +// RowFilterToSDK converts the mirror to the sdk-go type. +func RowFilterToSDK(w *RowFilter) (*sdk.RowFilter, error) { + if w == nil { + return nil, nil + } + out := &sdk.RowFilter{} + out.FunctionName = w.FunctionName + out.InputColumnNames = w.InputColumnNames + conv39, err := convertSlice(w.InputArguments, PolicyFunctionArgumentToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RowFilter.InputArguments", err) + } + out.InputArguments = conv39 + return out, nil +} + +// RowFilterFromSDK converts the sdk-go type to the mirror. +func RowFilterFromSDK(v *sdk.RowFilter) (*RowFilter, error) { + if v == nil { + return nil, nil + } + out := &RowFilter{} + out.FunctionName = v.FunctionName + out.InputColumnNames = v.InputColumnNames + conv40, err := convertSlice(v.InputArguments, PolicyFunctionArgumentFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RowFilter.InputArguments", err) + } + out.InputArguments = conv40 + return out, nil +} + +// SecurableKindManifestToSDK converts the mirror to the sdk-go type. +func SecurableKindManifestToSDK(w *SecurableKindManifest) (*sdk.SecurableKindManifest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SecurableKindManifest{} + out.SecurableType = w.SecurableType + out.SecurableKind = w.SecurableKind + out.AssignablePrivileges = w.AssignablePrivileges + conv41, err := convertSlice(w.Options, OptionSpecToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SecurableKindManifest.Options", err) + } + out.Options = conv41 + out.Capabilities = w.Capabilities + return out, nil +} + +// SecurableKindManifestFromSDK converts the sdk-go type to the mirror. +func SecurableKindManifestFromSDK(v *sdk.SecurableKindManifest) (*SecurableKindManifest, error) { + if v == nil { + return nil, nil + } + out := &SecurableKindManifest{} + out.SecurableType = v.SecurableType + out.SecurableKind = v.SecurableKind + out.AssignablePrivileges = v.AssignablePrivileges + conv42, err := convertSlice(v.Options, OptionSpecFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SecurableKindManifest.Options", err) + } + out.Options = conv42 + out.Capabilities = v.Capabilities + return out, nil +} + +// SseEncryptionDetailsToSDK converts the mirror to the sdk-go type. +func SseEncryptionDetailsToSDK(w *SseEncryptionDetails) (*sdk.SseEncryptionDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.SseEncryptionDetails{} + out.Algorithm = w.Algorithm + out.AwsKmsKeyArn = w.AwsKmsKeyArn + return out, nil +} + +// SseEncryptionDetailsFromSDK converts the sdk-go type to the mirror. +func SseEncryptionDetailsFromSDK(v *sdk.SseEncryptionDetails) (*SseEncryptionDetails, error) { + if v == nil { + return nil, nil + } + out := &SseEncryptionDetails{} + out.Algorithm = v.Algorithm + out.AwsKmsKeyArn = v.AwsKmsKeyArn + return out, nil +} + +// TableConstraintToSDK converts the mirror to the sdk-go type. +func TableConstraintToSDK(w *TableConstraint) (*sdk.TableConstraint, error) { + if w == nil { + return nil, nil + } + out := &sdk.TableConstraint{} + { + var members []string + if w.PrimaryKeyConstraint != nil { + members = append(members, "primary_key_constraint") + } + if w.ForeignKeyConstraint != nil { + members = append(members, "foreign_key_constraint") + } + if w.NamedTableConstraint != nil { + members = append(members, "named_table_constraint") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.PrimaryKeyConstraint != nil: + conv43, err := PrimaryKeyConstraintToSDK(w.PrimaryKeyConstraint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableConstraint.Constraint", err) + } + out.Constraint = &sdk.TableConstraint_Constraint_PrimaryKeyConstraint{PrimaryKeyConstraint: *conv43} + case w.ForeignKeyConstraint != nil: + conv44, err := ForeignKeyConstraintToSDK(w.ForeignKeyConstraint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableConstraint.Constraint", err) + } + out.Constraint = &sdk.TableConstraint_Constraint_ForeignKeyConstraint{ForeignKeyConstraint: *conv44} + case w.NamedTableConstraint != nil: + conv45, err := NamedTableConstraintToSDK(w.NamedTableConstraint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableConstraint.Constraint", err) + } + out.Constraint = &sdk.TableConstraint_Constraint_NamedTableConstraint{NamedTableConstraint: *conv45} + } + return out, nil +} + +// TableConstraintFromSDK converts the sdk-go type to the mirror. +func TableConstraintFromSDK(v *sdk.TableConstraint) (*TableConstraint, error) { + if v == nil { + return nil, nil + } + out := &TableConstraint{} + switch value := v.Constraint.(type) { + case *sdk.TableConstraint_Constraint_PrimaryKeyConstraint: + if value != nil { + conv46, err := PrimaryKeyConstraintFromSDK(&value.PrimaryKeyConstraint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableConstraint.Constraint", err) + } + out.PrimaryKeyConstraint = conv46 + } + case *sdk.TableConstraint_Constraint_ForeignKeyConstraint: + if value != nil { + conv47, err := ForeignKeyConstraintFromSDK(&value.ForeignKeyConstraint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableConstraint.Constraint", err) + } + out.ForeignKeyConstraint = conv47 + } + case *sdk.TableConstraint_Constraint_NamedTableConstraint: + if value != nil { + conv48, err := NamedTableConstraintFromSDK(&value.NamedTableConstraint) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableConstraint.Constraint", err) + } + out.NamedTableConstraint = conv48 + } + } + return out, nil +} + +// TableDependencyToSDK converts the mirror to the sdk-go type. +func TableDependencyToSDK(w *TableDependency) (*sdk.TableDependency, error) { + if w == nil { + return nil, nil + } + out := &sdk.TableDependency{} + out.TableFullName = w.TableFullName + return out, nil +} + +// TableDependencyFromSDK converts the sdk-go type to the mirror. +func TableDependencyFromSDK(v *sdk.TableDependency) (*TableDependency, error) { + if v == nil { + return nil, nil + } + out := &TableDependency{} + out.TableFullName = v.TableFullName + return out, nil +} + +// TableExistsResponseToSDK converts the mirror to the sdk-go type. +func TableExistsResponseToSDK(w *TableExistsResponse) (*sdk.TableExistsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.TableExistsResponse{} + out.TableExists = w.TableExists + return out, nil +} + +// TableExistsResponseFromSDK converts the sdk-go type to the mirror. +func TableExistsResponseFromSDK(v *sdk.TableExistsResponse) (*TableExistsResponse, error) { + if v == nil { + return nil, nil + } + out := &TableExistsResponse{} + out.TableExists = v.TableExists + return out, nil +} + +// TableInfoToSDK converts the mirror to the sdk-go type. +func TableInfoToSDK(w *TableInfo) (*sdk.TableInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.TableInfo{} + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.TableType = w.TableType + out.DataSourceFormat = w.DataSourceFormat + out.StorageLocation = w.StorageLocation + out.ViewDefinition = w.ViewDefinition + conv49, err := DependencyListToSDK(w.ViewDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.ViewDependencies", err) + } + out.ViewDependencies = conv49 + out.SqlPath = w.SqlPath + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageCredentialName = w.StorageCredentialName + conv50, err := convertSlice(w.TableConstraints, TableConstraintToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.TableConstraints", err) + } + out.TableConstraints = conv50 + conv51, err := RowFilterToSDK(w.RowFilter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.RowFilter", err) + } + out.RowFilter = conv51 + out.PipelineId = w.PipelineId + out.EnablePredictiveOptimization = w.EnablePredictiveOptimization + out.MetastoreId = w.MetastoreId + out.FullName = w.FullName + out.DataAccessConfigurationId = w.DataAccessConfigurationId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.TableId = w.TableId + conv52, err := DeltaRuntimePropertiesKvPairsToSDK(w.DeltaRuntimePropertiesKvpairs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.DeltaRuntimePropertiesKvpairs", err) + } + out.DeltaRuntimePropertiesKvpairs = conv52 + out.DeletedAt = w.DeletedAt + conv53, err := EffectivePredictiveOptimizationFlagToSDK(w.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv53 + out.AccessPoint = w.AccessPoint + out.BrowseOnly = w.BrowseOnly + conv54, err := EncryptionDetailsToSDK(w.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.EncryptionDetails", err) + } + out.EncryptionDetails = conv54 + conv55, err := SecurableKindManifestToSDK(w.SecurableKindManifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.SecurableKindManifest", err) + } + out.SecurableKindManifest = conv55 + conv56, err := convertSlice(w.Columns, ColumnInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.Columns", err) + } + out.Columns = conv56 + out.Properties = w.Properties + return out, nil +} + +// TableInfoFromSDK converts the sdk-go type to the mirror. +func TableInfoFromSDK(v *sdk.TableInfo) (*TableInfo, error) { + if v == nil { + return nil, nil + } + out := &TableInfo{} + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.TableType = v.TableType + out.DataSourceFormat = v.DataSourceFormat + out.StorageLocation = v.StorageLocation + out.ViewDefinition = v.ViewDefinition + conv57, err := DependencyListFromSDK(v.ViewDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.ViewDependencies", err) + } + out.ViewDependencies = conv57 + out.SqlPath = v.SqlPath + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageCredentialName = v.StorageCredentialName + conv58, err := convertSlice(v.TableConstraints, TableConstraintFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.TableConstraints", err) + } + out.TableConstraints = conv58 + conv59, err := RowFilterFromSDK(v.RowFilter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.RowFilter", err) + } + out.RowFilter = conv59 + out.PipelineId = v.PipelineId + out.EnablePredictiveOptimization = v.EnablePredictiveOptimization + out.MetastoreId = v.MetastoreId + out.FullName = v.FullName + out.DataAccessConfigurationId = v.DataAccessConfigurationId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.TableId = v.TableId + conv60, err := DeltaRuntimePropertiesKvPairsFromSDK(v.DeltaRuntimePropertiesKvpairs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.DeltaRuntimePropertiesKvpairs", err) + } + out.DeltaRuntimePropertiesKvpairs = conv60 + out.DeletedAt = v.DeletedAt + conv61, err := EffectivePredictiveOptimizationFlagFromSDK(v.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv61 + out.AccessPoint = v.AccessPoint + out.BrowseOnly = v.BrowseOnly + conv62, err := EncryptionDetailsFromSDK(v.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.EncryptionDetails", err) + } + out.EncryptionDetails = conv62 + conv63, err := SecurableKindManifestFromSDK(v.SecurableKindManifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.SecurableKindManifest", err) + } + out.SecurableKindManifest = conv63 + conv64, err := convertSlice(v.Columns, ColumnInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableInfo.Columns", err) + } + out.Columns = conv64 + out.Properties = v.Properties + return out, nil +} + +// TableSummaryToSDK converts the mirror to the sdk-go type. +func TableSummaryToSDK(w *TableSummary) (*sdk.TableSummary, error) { + if w == nil { + return nil, nil + } + out := &sdk.TableSummary{} + out.FullName = w.FullName + out.TableType = w.TableType + conv65, err := SecurableKindManifestToSDK(w.SecurableKindManifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableSummary.SecurableKindManifest", err) + } + out.SecurableKindManifest = conv65 + return out, nil +} + +// TableSummaryFromSDK converts the sdk-go type to the mirror. +func TableSummaryFromSDK(v *sdk.TableSummary) (*TableSummary, error) { + if v == nil { + return nil, nil + } + out := &TableSummary{} + out.FullName = v.FullName + out.TableType = v.TableType + conv66, err := SecurableKindManifestFromSDK(v.SecurableKindManifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "TableSummary.SecurableKindManifest", err) + } + out.SecurableKindManifest = conv66 + return out, nil +} + +// UpdateTableRequestToSDK converts the mirror to the sdk-go type. +func UpdateTableRequestToSDK(w *UpdateTableRequest) (*sdk.UpdateTableRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateTableRequest{} + out.FullNameArg = w.FullNameArg + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.TableType = w.TableType + out.DataSourceFormat = w.DataSourceFormat + out.StorageLocation = w.StorageLocation + out.ViewDefinition = w.ViewDefinition + conv67, err := DependencyListToSDK(w.ViewDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.ViewDependencies", err) + } + out.ViewDependencies = conv67 + out.SqlPath = w.SqlPath + out.Owner = w.Owner + out.Comment = w.Comment + out.StorageCredentialName = w.StorageCredentialName + conv68, err := convertSlice(w.TableConstraints, TableConstraintToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.TableConstraints", err) + } + out.TableConstraints = conv68 + conv69, err := RowFilterToSDK(w.RowFilter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.RowFilter", err) + } + out.RowFilter = conv69 + out.PipelineId = w.PipelineId + out.EnablePredictiveOptimization = w.EnablePredictiveOptimization + out.MetastoreId = w.MetastoreId + out.FullName = w.FullName + out.DataAccessConfigurationId = w.DataAccessConfigurationId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.TableId = w.TableId + conv70, err := DeltaRuntimePropertiesKvPairsToSDK(w.DeltaRuntimePropertiesKvpairs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.DeltaRuntimePropertiesKvpairs", err) + } + out.DeltaRuntimePropertiesKvpairs = conv70 + out.DeletedAt = w.DeletedAt + conv71, err := EffectivePredictiveOptimizationFlagToSDK(w.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv71 + out.AccessPoint = w.AccessPoint + out.BrowseOnly = w.BrowseOnly + conv72, err := EncryptionDetailsToSDK(w.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.EncryptionDetails", err) + } + out.EncryptionDetails = conv72 + conv73, err := SecurableKindManifestToSDK(w.SecurableKindManifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.SecurableKindManifest", err) + } + out.SecurableKindManifest = conv73 + conv74, err := convertSlice(w.Columns, ColumnInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.Columns", err) + } + out.Columns = conv74 + out.Properties = w.Properties + return out, nil +} + +// UpdateTableRequestFromSDK converts the sdk-go type to the mirror. +func UpdateTableRequestFromSDK(v *sdk.UpdateTableRequest) (*UpdateTableRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateTableRequest{} + out.FullNameArg = v.FullNameArg + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.TableType = v.TableType + out.DataSourceFormat = v.DataSourceFormat + out.StorageLocation = v.StorageLocation + out.ViewDefinition = v.ViewDefinition + conv75, err := DependencyListFromSDK(v.ViewDependencies) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.ViewDependencies", err) + } + out.ViewDependencies = conv75 + out.SqlPath = v.SqlPath + out.Owner = v.Owner + out.Comment = v.Comment + out.StorageCredentialName = v.StorageCredentialName + conv76, err := convertSlice(v.TableConstraints, TableConstraintFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.TableConstraints", err) + } + out.TableConstraints = conv76 + conv77, err := RowFilterFromSDK(v.RowFilter) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.RowFilter", err) + } + out.RowFilter = conv77 + out.PipelineId = v.PipelineId + out.EnablePredictiveOptimization = v.EnablePredictiveOptimization + out.MetastoreId = v.MetastoreId + out.FullName = v.FullName + out.DataAccessConfigurationId = v.DataAccessConfigurationId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.TableId = v.TableId + conv78, err := DeltaRuntimePropertiesKvPairsFromSDK(v.DeltaRuntimePropertiesKvpairs) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.DeltaRuntimePropertiesKvpairs", err) + } + out.DeltaRuntimePropertiesKvpairs = conv78 + out.DeletedAt = v.DeletedAt + conv79, err := EffectivePredictiveOptimizationFlagFromSDK(v.EffectivePredictiveOptimizationFlag) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.EffectivePredictiveOptimizationFlag", err) + } + out.EffectivePredictiveOptimizationFlag = conv79 + out.AccessPoint = v.AccessPoint + out.BrowseOnly = v.BrowseOnly + conv80, err := EncryptionDetailsFromSDK(v.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.EncryptionDetails", err) + } + out.EncryptionDetails = conv80 + conv81, err := SecurableKindManifestFromSDK(v.SecurableKindManifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.SecurableKindManifest", err) + } + out.SecurableKindManifest = conv81 + conv82, err := convertSlice(v.Columns, ColumnInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateTableRequest.Columns", err) + } + out.Columns = conv82 + out.Properties = v.Properties + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/volumes/v1/types.generated.go b/libs/sdktypes/uc/volumes/v1/types.generated.go new file mode 100644 index 00000000000..084cc527789 --- /dev/null +++ b/libs/sdktypes/uc/volumes/v1/types.generated.go @@ -0,0 +1,555 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/volumes/v1. DO NOT EDIT. + +package volumes + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/volumes/v1" + + strings "strings" +) + +type ( + SseEncryptionAlgorithm = sdk.SseEncryptionAlgorithm + VolumeType = sdk.VolumeType +) + +const ( + SseEncryptionAlgorithm_Unspecified = sdk.SseEncryptionAlgorithm_Unspecified + SseEncryptionAlgorithm_AwsSseS3 = sdk.SseEncryptionAlgorithm_AwsSseS3 + SseEncryptionAlgorithm_AwsSseKms = sdk.SseEncryptionAlgorithm_AwsSseKms + VolumeType_Unspecified = sdk.VolumeType_Unspecified + VolumeType_Managed = sdk.VolumeType_Managed + VolumeType_External = sdk.VolumeType_External +) + +type CreateVolumeRequest struct { + // The AWS access point to use when accesing s3 for this external location. + AccessPoint *string `json:"access_point,omitempty"` + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // The name of the catalog where the schema and the volume are + CatalogName *string `json:"catalog_name,omitempty"` + // The comment attached to the volume + Comment *string `json:"comment,omitempty"` + CreatedAt *int64 `json:"created_at,omitempty"` + // The identifier of the user who created the volume + CreatedBy *string `json:"created_by,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryption_details,omitempty"` + // The three-level (fully qualified) name of the volume + FullName *string `json:"full_name,omitempty"` + // The unique identifier of the metastore + MetastoreId *string `json:"metastore_id,omitempty"` + // The name of the volume + Name *string `json:"name,omitempty"` + // The identifier of the user who owns the volume + Owner *string `json:"owner,omitempty"` + // The name of the schema where the volume is + SchemaName *string `json:"schema_name,omitempty"` + // The storage location on the cloud + StorageLocation *string `json:"storage_location,omitempty"` + UpdatedAt *int64 `json:"updated_at,omitempty"` + // The identifier of the user who updated the volume last time + UpdatedBy *string `json:"updated_by,omitempty"` + // The unique identifier of the volume + VolumeId *string `json:"volume_id,omitempty"` + // The type of the volume. An external volume is located in the specified + // external location. A managed volume is located in the default location which + // is specified by the parent schema, or the parent catalog, or the Metastore. + // [Learn more] + // + // [Learn more]: https://docs.databricks.com/aws/en/volumes/managed-vs-external + VolumeType VolumeType `json:"volume_type,omitempty"` +} + +// Encryption options that apply to clients connecting to cloud storage.. +type EncryptionDetails struct { + SseEncryptionDetails *SseEncryptionDetails `json:"sse_encryption_details,omitempty"` +} + +type GetVolumeRequest struct { + // The three-level (fully qualified) name of the volume + FullNameArg *string `json:"full_name_arg,omitempty"` + // Whether to include volumes in the response for which the principal can only + // access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` +} + +type ListVolumesRequest struct { + // The identifier of the catalog + CatalogName *string `json:"catalog_name,omitempty"` + // Whether to include volumes in the response for which the principal can only + // access selective metadata for + IncludeBrowse *bool `json:"include_browse,omitempty"` + // Maximum number of volumes to return (page length). + // + // If not set, the page length is set to a server configured value (10000, as of + // 1/29/2024). - when set to a value greater than 0, the page length is the + // minimum of this value and a server configured value (10000, as of 1/29/2024); + // - when set to 0, the page length is set to a server configured value (10000, + // as of 1/29/2024) (recommended); - when set to a value less than 0, an invalid + // parameter error is returned; + // + // Note: this parameter controls only the maximum number of volumes to return. + // The actual number of volumes returned in a page may be smaller than this + // value, including 0, even if there are more pages. + MaxResults *int `json:"max_results,omitempty"` + // Opaque token returned by a previous request. It must be included in the + // request to retrieve the next page of results (pagination). + PageToken *string `json:"page_token,omitempty"` + // The identifier of the schema + SchemaName *string `json:"schema_name,omitempty"` +} + +type ListVolumesResponse struct { + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // to retrieve the next page of results. + NextPageToken *string `json:"next_page_token,omitempty"` + Volumes []VolumeInfo `json:"volumes,omitempty"` +} + +// Server-Side Encryption properties for clients communicating with AWS s3.. +type SseEncryptionDetails struct { + // Sets the value of the 'x-amz-server-side-encryption' header in S3 request. + Algorithm SseEncryptionAlgorithm `json:"algorithm,omitempty"` + // Optional. The ARN of the SSE-KMS key used with the S3 location, when + // algorithm = "SSE-KMS". Sets the value of the + // 'x-amz-server-side-encryption-aws-kms-key-id' header. + AwsKmsKeyArn *string `json:"aws_kms_key_arn,omitempty"` +} + +type UpdateVolumeRequest struct { + // The AWS access point to use when accesing s3 for this external location. + AccessPoint *string `json:"access_point,omitempty"` + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // The name of the catalog where the schema and the volume are + CatalogName *string `json:"catalog_name,omitempty"` + // The comment attached to the volume + Comment *string `json:"comment,omitempty"` + CreatedAt *int64 `json:"created_at,omitempty"` + // The identifier of the user who created the volume + CreatedBy *string `json:"created_by,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryption_details,omitempty"` + // The three-level (fully qualified) name of the volume + FullName *string `json:"full_name,omitempty"` + // The three-level (fully qualified) name of the volume + FullNameArg *string `json:"full_name_arg,omitempty"` + // The unique identifier of the metastore + MetastoreId *string `json:"metastore_id,omitempty"` + // The name of the volume + Name *string `json:"name,omitempty"` + // New name for the volume. + NewName *string `json:"new_name,omitempty"` + // The identifier of the user who owns the volume + Owner *string `json:"owner,omitempty"` + // The name of the schema where the volume is + SchemaName *string `json:"schema_name,omitempty"` + // The storage location on the cloud + StorageLocation *string `json:"storage_location,omitempty"` + UpdatedAt *int64 `json:"updated_at,omitempty"` + // The identifier of the user who updated the volume last time + UpdatedBy *string `json:"updated_by,omitempty"` + // The unique identifier of the volume + VolumeId *string `json:"volume_id,omitempty"` + // The type of the volume. An external volume is located in the specified + // external location. A managed volume is located in the default location which + // is specified by the parent schema, or the parent catalog, or the Metastore. + // [Learn more] + // + // [Learn more]: https://docs.databricks.com/aws/en/volumes/managed-vs-external + VolumeType VolumeType `json:"volume_type,omitempty"` +} + +type VolumeInfo struct { + // The AWS access point to use when accesing s3 for this external location. + AccessPoint *string `json:"access_point,omitempty"` + // Indicates whether the principal is limited to retrieving metadata for the + // associated object through the BROWSE privilege when include_browse is enabled + // in the request. + BrowseOnly *bool `json:"browse_only,omitempty"` + // The name of the catalog where the schema and the volume are + CatalogName *string `json:"catalog_name,omitempty"` + // The comment attached to the volume + Comment *string `json:"comment,omitempty"` + CreatedAt *int64 `json:"created_at,omitempty"` + // The identifier of the user who created the volume + CreatedBy *string `json:"created_by,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryption_details,omitempty"` + // The three-level (fully qualified) name of the volume + FullName *string `json:"full_name,omitempty"` + // The unique identifier of the metastore + MetastoreId *string `json:"metastore_id,omitempty"` + // The name of the volume + Name *string `json:"name,omitempty"` + // The identifier of the user who owns the volume + Owner *string `json:"owner,omitempty"` + // The name of the schema where the volume is + SchemaName *string `json:"schema_name,omitempty"` + // The storage location on the cloud + StorageLocation *string `json:"storage_location,omitempty"` + UpdatedAt *int64 `json:"updated_at,omitempty"` + // The identifier of the user who updated the volume last time + UpdatedBy *string `json:"updated_by,omitempty"` + // The unique identifier of the volume + VolumeId *string `json:"volume_id,omitempty"` + // The type of the volume. An external volume is located in the specified + // external location. A managed volume is located in the default location which + // is specified by the parent schema, or the parent catalog, or the Metastore. + // [Learn more] + // + // [Learn more]: https://docs.databricks.com/aws/en/volumes/managed-vs-external + VolumeType VolumeType `json:"volume_type,omitempty"` +} + +// CreateVolumeRequestToSDK converts the mirror to the sdk-go type. +func CreateVolumeRequestToSDK(w *CreateVolumeRequest) (*sdk.CreateVolumeRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateVolumeRequest{} + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.VolumeType = w.VolumeType + out.StorageLocation = w.StorageLocation + out.Owner = w.Owner + out.Comment = w.Comment + out.FullName = w.FullName + out.VolumeId = w.VolumeId + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.AccessPoint = w.AccessPoint + conv1, err := EncryptionDetailsToSDK(w.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateVolumeRequest.EncryptionDetails", err) + } + out.EncryptionDetails = conv1 + out.BrowseOnly = w.BrowseOnly + return out, nil +} + +// CreateVolumeRequestFromSDK converts the sdk-go type to the mirror. +func CreateVolumeRequestFromSDK(v *sdk.CreateVolumeRequest) (*CreateVolumeRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateVolumeRequest{} + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.VolumeType = v.VolumeType + out.StorageLocation = v.StorageLocation + out.Owner = v.Owner + out.Comment = v.Comment + out.FullName = v.FullName + out.VolumeId = v.VolumeId + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.AccessPoint = v.AccessPoint + conv2, err := EncryptionDetailsFromSDK(v.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateVolumeRequest.EncryptionDetails", err) + } + out.EncryptionDetails = conv2 + out.BrowseOnly = v.BrowseOnly + return out, nil +} + +// EncryptionDetailsToSDK converts the mirror to the sdk-go type. +func EncryptionDetailsToSDK(w *EncryptionDetails) (*sdk.EncryptionDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.EncryptionDetails{} + { + var members []string + if w.SseEncryptionDetails != nil { + members = append(members, "sse_encryption_details") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.SseEncryptionDetails != nil: + conv3, err := SseEncryptionDetailsToSDK(w.SseEncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EncryptionDetails.EncryptionDetailsType", err) + } + out.EncryptionDetailsType = &sdk.EncryptionDetails_EncryptionDetailsType_SseEncryptionDetails{SseEncryptionDetails: *conv3} + } + return out, nil +} + +// EncryptionDetailsFromSDK converts the sdk-go type to the mirror. +func EncryptionDetailsFromSDK(v *sdk.EncryptionDetails) (*EncryptionDetails, error) { + if v == nil { + return nil, nil + } + out := &EncryptionDetails{} + switch value := v.EncryptionDetailsType.(type) { + case *sdk.EncryptionDetails_EncryptionDetailsType_SseEncryptionDetails: + if value != nil { + conv4, err := SseEncryptionDetailsFromSDK(&value.SseEncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EncryptionDetails.EncryptionDetailsType", err) + } + out.SseEncryptionDetails = conv4 + } + } + return out, nil +} + +// GetVolumeRequestToSDK converts the mirror to the sdk-go type. +func GetVolumeRequestToSDK(w *GetVolumeRequest) (*sdk.GetVolumeRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetVolumeRequest{} + out.FullNameArg = w.FullNameArg + out.IncludeBrowse = w.IncludeBrowse + return out, nil +} + +// GetVolumeRequestFromSDK converts the sdk-go type to the mirror. +func GetVolumeRequestFromSDK(v *sdk.GetVolumeRequest) (*GetVolumeRequest, error) { + if v == nil { + return nil, nil + } + out := &GetVolumeRequest{} + out.FullNameArg = v.FullNameArg + out.IncludeBrowse = v.IncludeBrowse + return out, nil +} + +// ListVolumesRequestToSDK converts the mirror to the sdk-go type. +func ListVolumesRequestToSDK(w *ListVolumesRequest) (*sdk.ListVolumesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListVolumesRequest{} + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.IncludeBrowse = w.IncludeBrowse + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// ListVolumesRequestFromSDK converts the sdk-go type to the mirror. +func ListVolumesRequestFromSDK(v *sdk.ListVolumesRequest) (*ListVolumesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListVolumesRequest{} + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.IncludeBrowse = v.IncludeBrowse + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// ListVolumesResponseToSDK converts the mirror to the sdk-go type. +func ListVolumesResponseToSDK(w *ListVolumesResponse) (*sdk.ListVolumesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListVolumesResponse{} + conv5, err := convertSlice(w.Volumes, VolumeInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListVolumesResponse.Volumes", err) + } + out.Volumes = conv5 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListVolumesResponseFromSDK converts the sdk-go type to the mirror. +func ListVolumesResponseFromSDK(v *sdk.ListVolumesResponse) (*ListVolumesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListVolumesResponse{} + conv6, err := convertSlice(v.Volumes, VolumeInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListVolumesResponse.Volumes", err) + } + out.Volumes = conv6 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// SseEncryptionDetailsToSDK converts the mirror to the sdk-go type. +func SseEncryptionDetailsToSDK(w *SseEncryptionDetails) (*sdk.SseEncryptionDetails, error) { + if w == nil { + return nil, nil + } + out := &sdk.SseEncryptionDetails{} + out.Algorithm = w.Algorithm + out.AwsKmsKeyArn = w.AwsKmsKeyArn + return out, nil +} + +// SseEncryptionDetailsFromSDK converts the sdk-go type to the mirror. +func SseEncryptionDetailsFromSDK(v *sdk.SseEncryptionDetails) (*SseEncryptionDetails, error) { + if v == nil { + return nil, nil + } + out := &SseEncryptionDetails{} + out.Algorithm = v.Algorithm + out.AwsKmsKeyArn = v.AwsKmsKeyArn + return out, nil +} + +// UpdateVolumeRequestToSDK converts the mirror to the sdk-go type. +func UpdateVolumeRequestToSDK(w *UpdateVolumeRequest) (*sdk.UpdateVolumeRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateVolumeRequest{} + out.FullNameArg = w.FullNameArg + out.NewName = w.NewName + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.VolumeType = w.VolumeType + out.StorageLocation = w.StorageLocation + out.Owner = w.Owner + out.Comment = w.Comment + out.FullName = w.FullName + out.VolumeId = w.VolumeId + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.AccessPoint = w.AccessPoint + conv7, err := EncryptionDetailsToSDK(w.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateVolumeRequest.EncryptionDetails", err) + } + out.EncryptionDetails = conv7 + out.BrowseOnly = w.BrowseOnly + return out, nil +} + +// UpdateVolumeRequestFromSDK converts the sdk-go type to the mirror. +func UpdateVolumeRequestFromSDK(v *sdk.UpdateVolumeRequest) (*UpdateVolumeRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateVolumeRequest{} + out.FullNameArg = v.FullNameArg + out.NewName = v.NewName + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.VolumeType = v.VolumeType + out.StorageLocation = v.StorageLocation + out.Owner = v.Owner + out.Comment = v.Comment + out.FullName = v.FullName + out.VolumeId = v.VolumeId + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.AccessPoint = v.AccessPoint + conv8, err := EncryptionDetailsFromSDK(v.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateVolumeRequest.EncryptionDetails", err) + } + out.EncryptionDetails = conv8 + out.BrowseOnly = v.BrowseOnly + return out, nil +} + +// VolumeInfoToSDK converts the mirror to the sdk-go type. +func VolumeInfoToSDK(w *VolumeInfo) (*sdk.VolumeInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.VolumeInfo{} + out.Name = w.Name + out.CatalogName = w.CatalogName + out.SchemaName = w.SchemaName + out.VolumeType = w.VolumeType + out.StorageLocation = w.StorageLocation + out.Owner = w.Owner + out.Comment = w.Comment + out.FullName = w.FullName + out.VolumeId = w.VolumeId + out.MetastoreId = w.MetastoreId + out.CreatedAt = w.CreatedAt + out.CreatedBy = w.CreatedBy + out.UpdatedAt = w.UpdatedAt + out.UpdatedBy = w.UpdatedBy + out.AccessPoint = w.AccessPoint + conv9, err := EncryptionDetailsToSDK(w.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "VolumeInfo.EncryptionDetails", err) + } + out.EncryptionDetails = conv9 + out.BrowseOnly = w.BrowseOnly + return out, nil +} + +// VolumeInfoFromSDK converts the sdk-go type to the mirror. +func VolumeInfoFromSDK(v *sdk.VolumeInfo) (*VolumeInfo, error) { + if v == nil { + return nil, nil + } + out := &VolumeInfo{} + out.Name = v.Name + out.CatalogName = v.CatalogName + out.SchemaName = v.SchemaName + out.VolumeType = v.VolumeType + out.StorageLocation = v.StorageLocation + out.Owner = v.Owner + out.Comment = v.Comment + out.FullName = v.FullName + out.VolumeId = v.VolumeId + out.MetastoreId = v.MetastoreId + out.CreatedAt = v.CreatedAt + out.CreatedBy = v.CreatedBy + out.UpdatedAt = v.UpdatedAt + out.UpdatedBy = v.UpdatedBy + out.AccessPoint = v.AccessPoint + conv10, err := EncryptionDetailsFromSDK(v.EncryptionDetails) + if err != nil { + return nil, fmt.Errorf("%s: %w", "VolumeInfo.EncryptionDetails", err) + } + out.EncryptionDetails = conv10 + out.BrowseOnly = v.BrowseOnly + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/uc/workspacebindings/v1/types.generated.go b/libs/sdktypes/uc/workspacebindings/v1/types.generated.go new file mode 100644 index 00000000000..92e9497f6ed --- /dev/null +++ b/libs/sdktypes/uc/workspacebindings/v1/types.generated.go @@ -0,0 +1,318 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/uc/workspacebindings/v1. DO NOT EDIT. + +package workspacebindings + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/uc/workspacebindings/v1" +) + +type ( + BindingType = sdk.BindingType +) + +const ( + BindingType_Unspecified = sdk.BindingType_Unspecified + BindingType_BindingTypeReadWrite = sdk.BindingType_BindingTypeReadWrite + BindingType_BindingTypeReadOnly = sdk.BindingType_BindingTypeReadOnly +) + +type GetCatalogWorkspaceBindingsResponse struct { + // A list of workspace IDs + Workspaces []int64 `json:"workspaces,omitempty"` +} + +type GetWorkspaceBindingsRequest struct { + // Maximum number of workspace bindings to return. - When set to 0, the page + // length is set to a server configured value (recommended); - When set to a + // value greater than 0, the page length is the minimum of this value and a + // server configured value; - When set to a value less than 0, an invalid + // parameter error is returned; - If not set, all the workspace bindings are + // returned (not recommended). + MaxResults *int `json:"max_results,omitempty"` + // Opaque pagination token to go to next page based on previous query. + PageToken *string `json:"page_token,omitempty"` + // The name of the securable. + SecurableFullName *string `json:"securable_full_name,omitempty"` + // The type of the securable to bind to a workspace (catalog, + // storage_credential, credential, or external_location). + SecurableType *string `json:"securable_type,omitempty"` +} + +type GetWorkspaceBindingsResponse struct { + // List of workspace bindings + Bindings []WorkspaceBindingInfo `json:"bindings,omitempty"` + // Opaque token to retrieve the next page of results. Absent if there are no + // more pages. __page_token__ should be set to this value for the next request + // (for the next page of results). + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type UpdateCatalogWorkspaceBindingsRequest struct { + // A list of workspace IDs. + AssignWorkspaces []int64 `json:"assign_workspaces,omitempty"` + // The name of the catalog. + CatalogName *string `json:"catalog_name,omitempty"` + // A list of workspace IDs. + UnassignWorkspaces []int64 `json:"unassign_workspaces,omitempty"` +} + +type UpdateCatalogWorkspaceBindingsResponse struct { + // A list of workspace IDs + Workspaces []int64 `json:"workspaces,omitempty"` +} + +type UpdateWorkspaceBindingsRequest struct { + // List of workspace bindings to add. If a binding for the workspace already + // exists with a different binding_type, adding it again with a new binding_type + // will update the existing binding (e.g., from READ_WRITE to READ_ONLY). + Add []WorkspaceBindingInfo `json:"add,omitempty"` + // List of workspace bindings to remove. + Remove []WorkspaceBindingInfo `json:"remove,omitempty"` + // The name of the securable. + SecurableFullName *string `json:"securable_full_name,omitempty"` + // The type of the securable to bind to a workspace (catalog, + // storage_credential, credential, or external_location). + SecurableType *string `json:"securable_type,omitempty"` +} + +// A list of workspace IDs that are bound to the securable. +type UpdateWorkspaceBindingsResponse struct { + // List of workspace bindings. + Bindings []WorkspaceBindingInfo `json:"bindings,omitempty"` +} + +type WorkspaceBindingInfo struct { + // One of READ_WRITE/READ_ONLY. Default is READ_WRITE. + BindingType BindingType `json:"binding_type,omitempty"` + // Required + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +// GetCatalogWorkspaceBindingsResponseToSDK converts the mirror to the sdk-go type. +func GetCatalogWorkspaceBindingsResponseToSDK(w *GetCatalogWorkspaceBindingsResponse) (*sdk.GetCatalogWorkspaceBindingsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetCatalogWorkspaceBindingsResponse{} + out.Workspaces = w.Workspaces + return out, nil +} + +// GetCatalogWorkspaceBindingsResponseFromSDK converts the sdk-go type to the mirror. +func GetCatalogWorkspaceBindingsResponseFromSDK(v *sdk.GetCatalogWorkspaceBindingsResponse) (*GetCatalogWorkspaceBindingsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetCatalogWorkspaceBindingsResponse{} + out.Workspaces = v.Workspaces + return out, nil +} + +// GetWorkspaceBindingsRequestToSDK converts the mirror to the sdk-go type. +func GetWorkspaceBindingsRequestToSDK(w *GetWorkspaceBindingsRequest) (*sdk.GetWorkspaceBindingsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetWorkspaceBindingsRequest{} + out.SecurableType = w.SecurableType + out.SecurableFullName = w.SecurableFullName + out.MaxResults = w.MaxResults + out.PageToken = w.PageToken + return out, nil +} + +// GetWorkspaceBindingsRequestFromSDK converts the sdk-go type to the mirror. +func GetWorkspaceBindingsRequestFromSDK(v *sdk.GetWorkspaceBindingsRequest) (*GetWorkspaceBindingsRequest, error) { + if v == nil { + return nil, nil + } + out := &GetWorkspaceBindingsRequest{} + out.SecurableType = v.SecurableType + out.SecurableFullName = v.SecurableFullName + out.MaxResults = v.MaxResults + out.PageToken = v.PageToken + return out, nil +} + +// GetWorkspaceBindingsResponseToSDK converts the mirror to the sdk-go type. +func GetWorkspaceBindingsResponseToSDK(w *GetWorkspaceBindingsResponse) (*sdk.GetWorkspaceBindingsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetWorkspaceBindingsResponse{} + conv1, err := convertSlice(w.Bindings, WorkspaceBindingInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceBindingsResponse.Bindings", err) + } + out.Bindings = conv1 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// GetWorkspaceBindingsResponseFromSDK converts the sdk-go type to the mirror. +func GetWorkspaceBindingsResponseFromSDK(v *sdk.GetWorkspaceBindingsResponse) (*GetWorkspaceBindingsResponse, error) { + if v == nil { + return nil, nil + } + out := &GetWorkspaceBindingsResponse{} + conv2, err := convertSlice(v.Bindings, WorkspaceBindingInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceBindingsResponse.Bindings", err) + } + out.Bindings = conv2 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// UpdateCatalogWorkspaceBindingsRequestToSDK converts the mirror to the sdk-go type. +func UpdateCatalogWorkspaceBindingsRequestToSDK(w *UpdateCatalogWorkspaceBindingsRequest) (*sdk.UpdateCatalogWorkspaceBindingsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCatalogWorkspaceBindingsRequest{} + out.CatalogName = w.CatalogName + out.AssignWorkspaces = w.AssignWorkspaces + out.UnassignWorkspaces = w.UnassignWorkspaces + return out, nil +} + +// UpdateCatalogWorkspaceBindingsRequestFromSDK converts the sdk-go type to the mirror. +func UpdateCatalogWorkspaceBindingsRequestFromSDK(v *sdk.UpdateCatalogWorkspaceBindingsRequest) (*UpdateCatalogWorkspaceBindingsRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateCatalogWorkspaceBindingsRequest{} + out.CatalogName = v.CatalogName + out.AssignWorkspaces = v.AssignWorkspaces + out.UnassignWorkspaces = v.UnassignWorkspaces + return out, nil +} + +// UpdateCatalogWorkspaceBindingsResponseToSDK converts the mirror to the sdk-go type. +func UpdateCatalogWorkspaceBindingsResponseToSDK(w *UpdateCatalogWorkspaceBindingsResponse) (*sdk.UpdateCatalogWorkspaceBindingsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateCatalogWorkspaceBindingsResponse{} + out.Workspaces = w.Workspaces + return out, nil +} + +// UpdateCatalogWorkspaceBindingsResponseFromSDK converts the sdk-go type to the mirror. +func UpdateCatalogWorkspaceBindingsResponseFromSDK(v *sdk.UpdateCatalogWorkspaceBindingsResponse) (*UpdateCatalogWorkspaceBindingsResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateCatalogWorkspaceBindingsResponse{} + out.Workspaces = v.Workspaces + return out, nil +} + +// UpdateWorkspaceBindingsRequestToSDK converts the mirror to the sdk-go type. +func UpdateWorkspaceBindingsRequestToSDK(w *UpdateWorkspaceBindingsRequest) (*sdk.UpdateWorkspaceBindingsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateWorkspaceBindingsRequest{} + out.SecurableType = w.SecurableType + out.SecurableFullName = w.SecurableFullName + conv3, err := convertSlice(w.Add, WorkspaceBindingInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceBindingsRequest.Add", err) + } + out.Add = conv3 + conv4, err := convertSlice(w.Remove, WorkspaceBindingInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceBindingsRequest.Remove", err) + } + out.Remove = conv4 + return out, nil +} + +// UpdateWorkspaceBindingsRequestFromSDK converts the sdk-go type to the mirror. +func UpdateWorkspaceBindingsRequestFromSDK(v *sdk.UpdateWorkspaceBindingsRequest) (*UpdateWorkspaceBindingsRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateWorkspaceBindingsRequest{} + out.SecurableType = v.SecurableType + out.SecurableFullName = v.SecurableFullName + conv5, err := convertSlice(v.Add, WorkspaceBindingInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceBindingsRequest.Add", err) + } + out.Add = conv5 + conv6, err := convertSlice(v.Remove, WorkspaceBindingInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceBindingsRequest.Remove", err) + } + out.Remove = conv6 + return out, nil +} + +// UpdateWorkspaceBindingsResponseToSDK converts the mirror to the sdk-go type. +func UpdateWorkspaceBindingsResponseToSDK(w *UpdateWorkspaceBindingsResponse) (*sdk.UpdateWorkspaceBindingsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateWorkspaceBindingsResponse{} + conv7, err := convertSlice(w.Bindings, WorkspaceBindingInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceBindingsResponse.Bindings", err) + } + out.Bindings = conv7 + return out, nil +} + +// UpdateWorkspaceBindingsResponseFromSDK converts the sdk-go type to the mirror. +func UpdateWorkspaceBindingsResponseFromSDK(v *sdk.UpdateWorkspaceBindingsResponse) (*UpdateWorkspaceBindingsResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateWorkspaceBindingsResponse{} + conv8, err := convertSlice(v.Bindings, WorkspaceBindingInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceBindingsResponse.Bindings", err) + } + out.Bindings = conv8 + return out, nil +} + +// WorkspaceBindingInfoToSDK converts the mirror to the sdk-go type. +func WorkspaceBindingInfoToSDK(w *WorkspaceBindingInfo) (*sdk.WorkspaceBindingInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkspaceBindingInfo{} + out.WorkspaceId = w.WorkspaceId + out.BindingType = w.BindingType + return out, nil +} + +// WorkspaceBindingInfoFromSDK converts the sdk-go type to the mirror. +func WorkspaceBindingInfoFromSDK(v *sdk.WorkspaceBindingInfo) (*WorkspaceBindingInfo, error) { + if v == nil { + return nil, nil + } + out := &WorkspaceBindingInfo{} + out.WorkspaceId = v.WorkspaceId + out.BindingType = v.BindingType + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/usagedashboards/v1/types.generated.go b/libs/sdktypes/usagedashboards/v1/types.generated.go new file mode 100644 index 00000000000..cb16d7b67c6 --- /dev/null +++ b/libs/sdktypes/usagedashboards/v1/types.generated.go @@ -0,0 +1,150 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/usagedashboards/v1. DO NOT EDIT. + +package usagedashboards + +import ( + sdk "github.com/databricks/sdk-go/usagedashboards/v1" +) + +type ( + UsageDashboardMajorVersion = sdk.UsageDashboardMajorVersion + UsageDashboardType = sdk.UsageDashboardType +) + +const ( + UsageDashboardMajorVersion_Unspecified = sdk.UsageDashboardMajorVersion_Unspecified + UsageDashboardMajorVersion_UsageDashboardMajorVersion1 = sdk.UsageDashboardMajorVersion_UsageDashboardMajorVersion1 + UsageDashboardMajorVersion_UsageDashboardMajorVersion2 = sdk.UsageDashboardMajorVersion_UsageDashboardMajorVersion2 + UsageDashboardType_Unspecified = sdk.UsageDashboardType_Unspecified + UsageDashboardType_UsageDashboardTypeWorkspace = sdk.UsageDashboardType_UsageDashboardTypeWorkspace + UsageDashboardType_UsageDashboardTypeGlobal = sdk.UsageDashboardType_UsageDashboardTypeGlobal +) + +type CreateBillingUsageDashboardRequest struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + // Workspace level usage dashboard shows usage data for the specified workspace + // ID. Global level usage dashboard shows usage data for all workspaces in the + // account. + DashboardType UsageDashboardType `json:"dashboard_type,omitempty"` + // The major version of the usage dashboard template to use. Defaults to + // VERSION_1. + MajorVersion UsageDashboardMajorVersion `json:"major_version,omitempty"` + // The workspace ID of the workspace in which the usage dashboard is created. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +type CreateBillingUsageDashboardResponse struct { + // The unique id of the usage dashboard. + DashboardId *string `json:"dashboard_id,omitempty"` +} + +type GetBillingUsageDashboardRequest struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + // Workspace level usage dashboard shows usage data for the specified workspace + // ID. Global level usage dashboard shows usage data for all workspaces in the + // account. + DashboardType UsageDashboardType `json:"dashboard_type,omitempty"` + // The workspace ID of the workspace in which the usage dashboard is created. + WorkspaceId *int64 `json:"workspace_id,omitempty"` +} + +type GetBillingUsageDashboardResponse struct { + // The unique id of the usage dashboard. + DashboardId *string `json:"dashboard_id,omitempty"` + // The URL of the usage dashboard. + DashboardUrl *string `json:"dashboard_url,omitempty"` +} + +// CreateBillingUsageDashboardRequestToSDK converts the mirror to the sdk-go type. +func CreateBillingUsageDashboardRequestToSDK(w *CreateBillingUsageDashboardRequest) (*sdk.CreateBillingUsageDashboardRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateBillingUsageDashboardRequest{} + out.WorkspaceId = w.WorkspaceId + out.AccountId = w.AccountId + out.DashboardType = w.DashboardType + out.MajorVersion = w.MajorVersion + return out, nil +} + +// CreateBillingUsageDashboardRequestFromSDK converts the sdk-go type to the mirror. +func CreateBillingUsageDashboardRequestFromSDK(v *sdk.CreateBillingUsageDashboardRequest) (*CreateBillingUsageDashboardRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateBillingUsageDashboardRequest{} + out.WorkspaceId = v.WorkspaceId + out.AccountId = v.AccountId + out.DashboardType = v.DashboardType + out.MajorVersion = v.MajorVersion + return out, nil +} + +// CreateBillingUsageDashboardResponseToSDK converts the mirror to the sdk-go type. +func CreateBillingUsageDashboardResponseToSDK(w *CreateBillingUsageDashboardResponse) (*sdk.CreateBillingUsageDashboardResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateBillingUsageDashboardResponse{} + out.DashboardId = w.DashboardId + return out, nil +} + +// CreateBillingUsageDashboardResponseFromSDK converts the sdk-go type to the mirror. +func CreateBillingUsageDashboardResponseFromSDK(v *sdk.CreateBillingUsageDashboardResponse) (*CreateBillingUsageDashboardResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateBillingUsageDashboardResponse{} + out.DashboardId = v.DashboardId + return out, nil +} + +// GetBillingUsageDashboardRequestToSDK converts the mirror to the sdk-go type. +func GetBillingUsageDashboardRequestToSDK(w *GetBillingUsageDashboardRequest) (*sdk.GetBillingUsageDashboardRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetBillingUsageDashboardRequest{} + out.WorkspaceId = w.WorkspaceId + out.AccountId = w.AccountId + out.DashboardType = w.DashboardType + return out, nil +} + +// GetBillingUsageDashboardRequestFromSDK converts the sdk-go type to the mirror. +func GetBillingUsageDashboardRequestFromSDK(v *sdk.GetBillingUsageDashboardRequest) (*GetBillingUsageDashboardRequest, error) { + if v == nil { + return nil, nil + } + out := &GetBillingUsageDashboardRequest{} + out.WorkspaceId = v.WorkspaceId + out.AccountId = v.AccountId + out.DashboardType = v.DashboardType + return out, nil +} + +// GetBillingUsageDashboardResponseToSDK converts the mirror to the sdk-go type. +func GetBillingUsageDashboardResponseToSDK(w *GetBillingUsageDashboardResponse) (*sdk.GetBillingUsageDashboardResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetBillingUsageDashboardResponse{} + out.DashboardId = w.DashboardId + out.DashboardUrl = w.DashboardUrl + return out, nil +} + +// GetBillingUsageDashboardResponseFromSDK converts the sdk-go type to the mirror. +func GetBillingUsageDashboardResponseFromSDK(v *sdk.GetBillingUsageDashboardResponse) (*GetBillingUsageDashboardResponse, error) { + if v == nil { + return nil, nil + } + out := &GetBillingUsageDashboardResponse{} + out.DashboardId = v.DashboardId + out.DashboardUrl = v.DashboardUrl + return out, nil +} diff --git a/libs/sdktypes/vectorsearch/v1/types.generated.go b/libs/sdktypes/vectorsearch/v1/types.generated.go new file mode 100644 index 00000000000..10a8a1e5890 --- /dev/null +++ b/libs/sdktypes/vectorsearch/v1/types.generated.go @@ -0,0 +1,2355 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/vectorsearch/v1. DO NOT EDIT. + +package vectorsearch + +import ( + json "encoding/json" + fmt "fmt" + sdk "github.com/databricks/sdk-go/vectorsearch/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + EndpointType = sdk.EndpointType + IndexSubtype = sdk.IndexSubtype + PipelineType = sdk.PipelineType + ScalingChangeState = sdk.ScalingChangeState + UpsertDeleteDataStatus = sdk.UpsertDeleteDataStatus + VectorIndexType = sdk.VectorIndexType + EndpointStatus_State = sdk.EndpointStatus_State +) + +const ( + EndpointType_Unspecified = sdk.EndpointType_Unspecified + EndpointType_StorageOptimized = sdk.EndpointType_StorageOptimized + EndpointType_Standard = sdk.EndpointType_Standard + IndexSubtype_Unspecified = sdk.IndexSubtype_Unspecified + IndexSubtype_FullText = sdk.IndexSubtype_FullText + IndexSubtype_Hybrid = sdk.IndexSubtype_Hybrid + PipelineType_Unspecified = sdk.PipelineType_Unspecified + PipelineType_Continuous = sdk.PipelineType_Continuous + ScalingChangeState_Unspecified = sdk.ScalingChangeState_Unspecified + ScalingChangeState_ScalingChangeApplied = sdk.ScalingChangeState_ScalingChangeApplied + ScalingChangeState_ScalingChangeInProgress = sdk.ScalingChangeState_ScalingChangeInProgress + UpsertDeleteDataStatus_Unspecified = sdk.UpsertDeleteDataStatus_Unspecified + UpsertDeleteDataStatus_PartialSuccess = sdk.UpsertDeleteDataStatus_PartialSuccess + UpsertDeleteDataStatus_Failure = sdk.UpsertDeleteDataStatus_Failure + VectorIndexType_Unspecified = sdk.VectorIndexType_Unspecified + VectorIndexType_DirectAccess = sdk.VectorIndexType_DirectAccess + EndpointStatus_State_Unspecified = sdk.EndpointStatus_State_Unspecified + EndpointStatus_State_Online = sdk.EndpointStatus_State_Online + EndpointStatus_State_Offline = sdk.EndpointStatus_State_Offline + EndpointStatus_State_RedState = sdk.EndpointStatus_State_RedState + EndpointStatus_State_YellowState = sdk.EndpointStatus_State_YellowState + EndpointStatus_State_Deleted = sdk.EndpointStatus_State_Deleted +) + +type ColumnInfo struct { + // Name of the column. + Name *string `json:"name,omitempty"` + // Data type of the column (e.g., "string", "int", "array") + TypeText *string `json:"type_text,omitempty"` +} + +type CreateEndpointRequest struct { + // The budget policy id to be applied + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // Type of endpoint + EndpointType EndpointType `json:"endpoint_type,omitempty"` + // Name of the AI Search endpoint + Name *string `json:"name,omitempty"` + // Target QPS for the endpoint. Mutually exclusive with num_replicas. The actual + // replica count is calculated at index creation/sync time based on this value. + // Best-effort target; the system does not guarantee this QPS will be achieved. + TargetQps *int64 `json:"target_qps,omitempty"` + // The usage policy id to be applied once we've migrated to usage policies + UsagePolicyId *string `json:"usage_policy_id,omitempty"` +} + +type CreateVectorIndexRequest struct { + DeltaSyncIndexSpec *DeltaSyncVectorIndexSpecRequest `json:"delta_sync_index_spec,omitempty"` + DirectAccessIndexSpec *DirectAccessVectorIndexSpec `json:"direct_access_index_spec,omitempty"` + // Name of the endpoint to be used for serving the index + EndpointName *string `json:"endpoint_name,omitempty"` + // The subtype of the index. Use `HYBRID` or `FULL_TEXT`. `VECTOR` is not + // supported. + IndexSubtype IndexSubtype `json:"index_subtype,omitempty"` + IndexType VectorIndexType `json:"index_type,omitempty"` + // Name of the index + Name *string `json:"name,omitempty"` + // Primary key of the index + PrimaryKey *string `json:"primary_key,omitempty"` +} + +type CustomTag struct { + // Key field for an AI Search endpoint tag. + Key *string `json:"key,omitempty"` + // [Optional] Value field for an AI Search endpoint tag. + Value *string `json:"value,omitempty"` +} + +// Request payload for deleting data from a vector index.. +type DeleteDataVectorIndexRequest struct { + // Name of the vector index where data is to be deleted. Must be a Direct Vector + // Access Index. + Name *string `json:"name,omitempty"` + // List of primary keys for the data to be deleted. + PrimaryKeys []string `json:"primary_keys,omitempty"` +} + +type DeleteDataVectorIndexResponse struct { + // Result of the upsert or delete operation. + Result *UpsertDeleteDataResult `json:"result,omitempty"` + // Status of the delete operation. + Status UpsertDeleteDataStatus `json:"status,omitempty"` +} + +type DeltaSyncVectorIndexSpec struct { + // [Optional] Alias for columns_to_sync. Select the columns to include in the + // vector index. If you leave this field blank, all columns from the source + // table are included. The primary key column and embedding source column or + // embedding vector column are always included. Only one of columns_to_sync or + // columns_to_index may be specified. + ColumnsToIndex []string `json:"columns_to_index,omitempty"` + // [Optional] Select the columns to sync with the vector index. If you leave + // this field blank, all columns from the source table are synced with the + // index. The primary key column and embedding source column or embedding vector + // column are always synced. + ColumnsToSync []string `json:"columns_to_sync,omitempty"` + // The columns that contain the embedding source. + EmbeddingSourceColumns []EmbeddingSourceColumn `json:"embedding_source_columns,omitempty"` + // The columns that contain the embedding vectors. + EmbeddingVectorColumns []EmbeddingVectorColumn `json:"embedding_vector_columns,omitempty"` + // [Optional] Name of the Delta table to sync the vector index contents and + // computed embeddings to. + EmbeddingWritebackTable *string `json:"embedding_writeback_table,omitempty"` + // The ID of the pipeline that is used to sync the index. + PipelineId *string `json:"pipeline_id,omitempty"` + // Pipeline execution mode. - `TRIGGERED`: If the pipeline uses the triggered + // execution mode, the system stops processing after successfully refreshing the + // source table in the pipeline once, ensuring the table is updated based on the + // data available when the update started. - `CONTINUOUS`: If the pipeline uses + // continuous execution, the pipeline processes new data as it arrives in the + // source table to keep vector index fresh. + PipelineType PipelineType `json:"pipeline_type,omitempty"` + // The name of the source table. + SourceTable *string `json:"source_table,omitempty"` +} + +type DeltaSyncVectorIndexSpecRequest struct { + // [Optional] Alias for columns_to_sync. Select the columns to include in the + // vector index. If you leave this field blank, all columns from the source + // table are included. The primary key column and embedding source column or + // embedding vector column are always included. Only one of columns_to_sync or + // columns_to_index may be specified. + ColumnsToIndex []string `json:"columns_to_index,omitempty"` + // [Optional] Select the columns to sync with the vector index. If you leave + // this field blank, all columns from the source table are synced with the + // index. The primary key column and embedding source column or embedding vector + // column are always synced. + ColumnsToSync []string `json:"columns_to_sync,omitempty"` + // The columns that contain the embedding source. + EmbeddingSourceColumns []EmbeddingSourceColumn `json:"embedding_source_columns,omitempty"` + // The columns that contain the embedding vectors. + EmbeddingVectorColumns []EmbeddingVectorColumn `json:"embedding_vector_columns,omitempty"` + // [Optional] Name of the Delta table to sync the vector index contents and + // computed embeddings to. + EmbeddingWritebackTable *string `json:"embedding_writeback_table,omitempty"` + // The ID of the pipeline that is used to sync the index. + PipelineId *string `json:"pipeline_id,omitempty"` + // Pipeline execution mode. - `TRIGGERED`: If the pipeline uses the triggered + // execution mode, the system stops processing after successfully refreshing the + // source table in the pipeline once, ensuring the table is updated based on the + // data available when the update started. - `CONTINUOUS`: If the pipeline uses + // continuous execution, the pipeline processes new data as it arrives in the + // source table to keep vector index fresh. + PipelineType PipelineType `json:"pipeline_type,omitempty"` + // The name of the source table. + SourceTable *string `json:"source_table,omitempty"` +} + +type DirectAccessVectorIndexSpec struct { + // The columns that contain the embedding source. The format should be + // array[double]. + EmbeddingSourceColumns []EmbeddingSourceColumn `json:"embedding_source_columns,omitempty"` + // The columns that contain the embedding vectors. The format should be + // array[double]. + EmbeddingVectorColumns []EmbeddingVectorColumn `json:"embedding_vector_columns,omitempty"` + // The schema of the index in JSON format. Supported types are `integer`, + // `long`, `float`, `double`, `boolean`, `string`, `date`, `timestamp`. + // Supported types for vector column: `array`, `array`,`. + SchemaJson *string `json:"schema_json,omitempty"` +} + +type EmbeddingSourceColumn struct { + EmbeddingModelEndpointName *string `json:"embedding_model_endpoint_name,omitempty"` + // Name of the embedding model endpoint which, if specified, is used for + // querying (not ingestion). + ModelEndpointNameForQuery *string `json:"model_endpoint_name_for_query,omitempty"` + // Name of the column + Name *string `json:"name,omitempty"` +} + +type EmbeddingVectorColumn struct { + // Dimension of the embedding vector + EmbeddingDimension *int `json:"embedding_dimension,omitempty"` + // Name of the column + Name *string `json:"name,omitempty"` +} + +type Endpoint struct { + // The user-selected budget policy id for the endpoint. + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // Timestamp of endpoint creation + CreationTimestamp *int64 `json:"creation_timestamp,omitempty"` + // Creator of the endpoint + Creator *string `json:"creator,omitempty"` + // The custom tags assigned to the endpoint + CustomTags []CustomTag `json:"custom_tags,omitempty"` + // The budget policy id applied to the endpoint + EffectiveBudgetPolicyId *string `json:"effective_budget_policy_id,omitempty"` + // Current status of the endpoint + EndpointStatus *EndpointStatus `json:"endpoint_status,omitempty"` + // Type of endpoint + EndpointType EndpointType `json:"endpoint_type,omitempty"` + // Unique identifier of the endpoint + Id *string `json:"id,omitempty"` + // Timestamp of last update to the endpoint + LastUpdatedTimestamp *int64 `json:"last_updated_timestamp,omitempty"` + // User who last updated the endpoint + LastUpdatedUser *string `json:"last_updated_user,omitempty"` + // Name of the AI Search endpoint + Name *string `json:"name,omitempty"` + // Number of indexes on the endpoint + NumIndexes *int `json:"num_indexes,omitempty"` + // Scaling information for the endpoint + ScalingInfo *EndpointScalingInfo `json:"scaling_info,omitempty"` +} + +// Scaling information for a Standard endpoint: the current scaling state, the +// requested QPS target, and the progress of an in-progress scaling change.. +type EndpointScalingInfo struct { + // The requested QPS target for the endpoint. Best-effort; the system does not + // guarantee this QPS will be achieved. + RequestedTargetQps *int64 `json:"requested_target_qps,omitempty"` + // The current state of the scaling change request. + State ScalingChangeState `json:"state,omitempty"` +} + +// Status information of an endpoint. +type EndpointStatus struct { + // Additional status message + Message *string `json:"message,omitempty"` + // Current state of the endpoint + State EndpointStatus_State `json:"state,omitempty"` +} + +// Facet aggregation rows returned by a query.. +type FacetResultData struct { + // Facet rows. Each row is `[facet_column_name, value_or_range, count]`. + FacetArray [][]json.RawMessage `json:"facet_array,omitempty"` + // Number of facet rows returned. + FacetRowCount *int `json:"facet_row_count,omitempty"` +} + +type GetVectorIndexRequest struct { + // If true, the URL returned for the index is guaranteed to be compatible with + // the reranker. Currently this means we return the CP URL regardless of how the + // index is being accessed. If not set or set to false, the URL may still be + // compatible with the reranker depending on what URL we return. + EnsureRerankerCompatible *bool `json:"ensure_reranker_compatible,omitempty"` + // Name of the index + Name *string `json:"name,omitempty"` +} + +type ListEndpointResponse struct { + // An array of Endpoint objects + Endpoints []Endpoint `json:"endpoints,omitempty"` + // A token that can be used to get the next page of results. If not present, + // there are no more results to show. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListEndpointsRequest struct { + // Token for pagination + PageToken *string `json:"page_token,omitempty"` +} + +type ListValue struct { + // Repeated field of dynamically typed values. + Values []Value `json:"values,omitempty"` +} + +type ListVectorIndexRequest struct { + // Name of the endpoint + EndpointName *string `json:"endpoint_name,omitempty"` + // Token for pagination + PageToken *string `json:"page_token,omitempty"` +} + +type ListVectorIndexResponse struct { + // A token that can be used to get the next page of results. If not present, + // there are no more results to show. + NextPageToken *string `json:"next_page_token,omitempty"` + VectorIndexes []MiniVectorIndex `json:"vector_indexes,omitempty"` +} + +// Key-value pair.. +type MapStringValueEntry struct { + // Column name. + Key *string `json:"key,omitempty"` + // Column value, nullable. + Value *Value `json:"value,omitempty"` +} + +// Metric specification. +type Metric struct { + // Metric labels + Labels []MetricLabel `json:"labels,omitempty"` + // Metric name + Name *string `json:"name,omitempty"` + // Percentile for the metric + Percentile *float64 `json:"percentile,omitempty"` +} + +// Label for a metric. +type MetricLabel struct { + // Label name + Name *string `json:"name,omitempty"` + // Label value + Value *string `json:"value,omitempty"` +} + +// Single metric value at a specific timestamp. +type MetricValue struct { + // Timestamp of the metric value (milliseconds since epoch) + Timestamp *int64 `json:"timestamp,omitempty"` + // Metric value + Value *float64 `json:"value,omitempty"` +} + +// Collection of metric values for a specific metric. +type MetricValues struct { + // Metric specification + Metric *Metric `json:"metric,omitempty"` + // Time series of metric values + Values []MetricValue `json:"values,omitempty"` +} + +type MiniVectorIndex struct { + // The user who created the index. + Creator *string `json:"creator,omitempty"` + DeltaSyncIndexSpec *DeltaSyncVectorIndexSpec `json:"delta_sync_index_spec,omitempty"` + DirectAccessIndexSpec *DirectAccessVectorIndexSpec `json:"direct_access_index_spec,omitempty"` + // ID of the endpoint associated with the index. + EndpointId *string `json:"endpoint_id,omitempty"` + // Name of the endpoint associated with the index + EndpointName *string `json:"endpoint_name,omitempty"` + // The subtype of the index. + IndexSubtype IndexSubtype `json:"index_subtype,omitempty"` + IndexType VectorIndexType `json:"index_type,omitempty"` + // Name of the index + Name *string `json:"name,omitempty"` + // Primary key of the index + PrimaryKey *string `json:"primary_key,omitempty"` + Status *VectorIndexStatus `json:"status,omitempty"` +} + +type PatchEndpointBudgetPolicyRequest struct { + // The budget policy id to be applied + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // Name of the AI Search endpoint + Name *string `json:"name,omitempty"` +} + +type PatchEndpointBudgetPolicyResponse struct { + BudgetPolicyId *string `json:"budget_policy_id,omitempty"` + // The budget policy applied to the AI Search endpoint. + EffectiveBudgetPolicyId *string `json:"effective_budget_policy_id,omitempty"` +} + +type PatchEndpointRequest struct { + // Name of the AI Search endpoint + Name *string `json:"name,omitempty"` + // Target QPS for the endpoint. Best-effort; the system does not guarantee this + // QPS will be achieved. + TargetQps *int64 `json:"target_qps,omitempty"` +} + +// Request payload for getting next page of results.. +type QueryVectorIndexNextPageRequest struct { + // Name of the endpoint. + EndpointName *string `json:"endpoint_name,omitempty"` + // Name of the vector index to query. + Name *string `json:"name,omitempty"` + // Page token returned from previous `QueryVectorIndex` or + // `QueryVectorIndexNextPage` API. + PageToken *string `json:"page_token,omitempty"` +} + +type QueryVectorIndexRequest struct { + // List of column names to include in the response. + Columns []string `json:"columns,omitempty"` + // Column names used to retrieve data to send to the reranker. + ColumnsToRerank []string `json:"columns_to_rerank,omitempty"` + // Facets to compute over the matched results. Each entry has one of these + // forms: `""` - top 10 distinct values by count `" TOP "` - + // top n distinct values, where n > 0 `" BUCKETS [[from,to],...]"` - + // inclusive numeric ranges `TOP` and `BUCKETS` are case-insensitive. A column + // may appear at most once. + Facets []string `json:"facets,omitempty"` + // JSON string representing query filters. + // + // Example filters: + // + // - `{"id <": 5}`: Filter for id less than 5. - `{"id >": 5}`: Filter for id + // greater than 5. - `{"id <=": 5}`: Filter for id less than equal to 5. - `{"id + // >=": 5}`: Filter for id greater than equal to 5. - `{"id": 5}`: Filter for id + // equal to 5. + FiltersJson *string `json:"filters_json,omitempty"` + // Name of the vector index to query. + Name *string `json:"name,omitempty"` + // Number of results to return. Defaults to 10. + NumResults *int `json:"num_results,omitempty"` + // Text columns to search for `query_text`. When empty, all text columns are + // searched. + QueryColumns []string `json:"query_columns,omitempty"` + // Query text. Required for Delta Sync Index using model endpoint. + QueryText *string `json:"query_text,omitempty"` + // The query type to use. Choices are `ANN` and `HYBRID` and `FULL_TEXT`. + // Defaults to `ANN`. + QueryType *string `json:"query_type,omitempty"` + // Query vector. Required for Direct Vector Access Index and Delta Sync Index + // using self-managed vectors. + QueryVector []float32 `json:"query_vector,omitempty"` + // If set, the top 50 results are reranked with the Databricks Reranker model + // before returning the `num_results` results to the user. The setting + // `columns_to_rerank` selects which columns are used for reranking. For each + // datapoint, the columns selected are concatenated before being sent to the + // reranking model. See + // https://docs.databricks.com/aws/en/vector-search/query-vector-search#rerank + // for more information. + Reranker *RerankerConfig `json:"reranker,omitempty"` + // Threshold for the approximate nearest neighbor search. Defaults to 0.0. + ScoreThreshold *float32 `json:"score_threshold,omitempty"` + // Sort results by column values instead of the default relevance ordering. Each + // clause has the form `" ASC"` or `" DESC"`, for example + // `["rating DESC", "price ASC"]`. + SortColumns []string `json:"sort_columns,omitempty"` +} + +type QueryVectorIndexResponse struct { + // Facet aggregation rows returned by a query. + FacetResult *FacetResultData `json:"facet_result,omitempty"` + // Metadata about the result set. + Manifest *ResultManifest `json:"manifest,omitempty"` + // [Optional] Token that can be used in `QueryVectorIndexNextPage` API to get + // next page of results. If more than 1000 results satisfy the query, they are + // returned in groups of 1000. Empty value means no more results. The maximum + // number of results that can be returned is 10,000. + NextPageToken *string `json:"next_page_token,omitempty"` + // Data returned in the query result. + Result *ResultData `json:"result,omitempty"` +} + +type RerankerConfig struct { + // Reranker identifier: - When model_type=BASE/UNSPECIFIED: must be + // "databricks_reranker". - When model_type=FINETUNED: the Model Serving + // endpoint name hosting a finetuned reranker. + Model *string `json:"model,omitempty"` + // Parameters that control how the reranker processes the query results. + Parameters *RerankerConfig_RerankerParameters `json:"parameters,omitempty"` +} + +type RerankerConfig_RerankerParameters struct { + ColumnsToRerank []string `json:"columns_to_rerank,omitempty"` +} + +// Data returned in the query result.. +type ResultData struct { + // Data rows returned in the query. + DataArray [][]json.RawMessage `json:"data_array,omitempty"` + // Number of rows in the result set. + RowCount *int `json:"row_count,omitempty"` +} + +// Metadata about the result set.. +type ResultManifest struct { + // Number of columns in the result set. + ColumnCount *int `json:"column_count,omitempty"` + // Information about each column in the result set. + Columns []ColumnInfo `json:"columns,omitempty"` + // Number of columns in `facet_result`. + FacetColumnCount *int `json:"facet_column_count,omitempty"` + // Information about each column in `facet_result`. + FacetColumns []ColumnInfo `json:"facet_columns,omitempty"` +} + +// Request to retrieve user-visible metrics. +type RetrieveUserVisibleMetricsRequest struct { + // End time for metrics query + EndTime *types.Time `json:"end_time,omitempty"` + // Granularity in seconds + GranularityInSeconds *int `json:"granularity_in_seconds,omitempty"` + // List of metrics to retrieve + Metrics []Metric `json:"metrics,omitempty"` + // AI Search endpoint name + Name *string `json:"name,omitempty"` + // Token for pagination + PageToken *string `json:"page_token,omitempty"` + // Start time for metrics query + StartTime *types.Time `json:"start_time,omitempty"` +} + +// Response containing user-visible metrics. +type RetrieveUserVisibleMetricsResponse struct { + // Collection of metric values + MetricValues []MetricValues `json:"metric_values,omitempty"` + // A token that can be used to get the next page of results. If not present, + // there are no more results to show. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ScanVectorIndexRequest struct { + // Primary key of the last entry returned in the previous scan. + LastPrimaryKey *string `json:"last_primary_key,omitempty"` + // Name of the vector index to scan. + Name *string `json:"name,omitempty"` + // Number of results to return. Defaults to 10. + NumResults *int `json:"num_results,omitempty"` +} + +// Response to a scan vector index request.. +type ScanVectorIndexResponse struct { + // List of data entries + Data []Struct `json:"data,omitempty"` + // Primary key of the last entry. + LastPrimaryKey *string `json:"last_primary_key,omitempty"` +} + +type Struct struct { + // Data entry, corresponding to a row in a vector index. + Fields []MapStringValueEntry `json:"fields,omitempty"` +} + +type SyncVectorIndexRequest struct { + // Name of the vector index to synchronize. Must be a Delta Sync Index. + Name *string `json:"name,omitempty"` +} + +type UpdateEndpointCustomTagsRequest struct { + // The new custom tags for the AI Search endpoint + CustomTags []CustomTag `json:"custom_tags,omitempty"` + // Name of the AI Search endpoint + Name *string `json:"name,omitempty"` +} + +type UpdateEndpointCustomTagsResponse struct { + // All the custom tags that are applied to the AI Search endpoint. + CustomTags []CustomTag `json:"custom_tags,omitempty"` + // The name of the AI Search endpoint whose custom tags were updated. + Name *string `json:"name,omitempty"` +} + +type UpsertDataVectorIndexRequest struct { + // JSON string representing the data to be upserted. + InputsJson *string `json:"inputs_json,omitempty"` + // Name of the vector index where data is to be upserted. Must be a Direct + // Vector Access Index. + Name *string `json:"name,omitempty"` +} + +type UpsertDataVectorIndexResponse struct { + // Result of the upsert or delete operation. + Result *UpsertDeleteDataResult `json:"result,omitempty"` + // Status of the upsert operation. + Status UpsertDeleteDataStatus `json:"status,omitempty"` +} + +type UpsertDeleteDataResult struct { + // List of primary keys for rows that failed to process. + FailedPrimaryKeys []string `json:"failed_primary_keys,omitempty"` + // Count of successfully processed rows. + SuccessRowCount *int64 `json:"success_row_count,omitempty"` +} + +type Value struct { + BoolValue *bool `json:"bool_value,omitempty"` + ListValue *ListValue `json:"list_value,omitempty"` + NumberValue *float64 `json:"number_value,omitempty"` + StringValue *string `json:"string_value,omitempty"` + StructValue *Struct `json:"struct_value,omitempty"` +} + +type VectorIndex struct { + // The user who created the index. + Creator *string `json:"creator,omitempty"` + DeltaSyncIndexSpec *DeltaSyncVectorIndexSpec `json:"delta_sync_index_spec,omitempty"` + DirectAccessIndexSpec *DirectAccessVectorIndexSpec `json:"direct_access_index_spec,omitempty"` + // ID of the endpoint associated with the index. + EndpointId *string `json:"endpoint_id,omitempty"` + // Name of the endpoint associated with the index + EndpointName *string `json:"endpoint_name,omitempty"` + // The subtype of the index. + IndexSubtype IndexSubtype `json:"index_subtype,omitempty"` + IndexType VectorIndexType `json:"index_type,omitempty"` + // Name of the index + Name *string `json:"name,omitempty"` + // Primary key of the index + PrimaryKey *string `json:"primary_key,omitempty"` + Status *VectorIndexStatus `json:"status,omitempty"` +} + +type VectorIndexStatus struct { + // Index API Url to be used to perform operations on the index + IndexUrl *string `json:"index_url,omitempty"` + // Number of rows indexed + IndexedRowCount *int64 `json:"indexed_row_count,omitempty"` + // Message associated with the index status + Message *string `json:"message,omitempty"` + // Whether the index is ready for search + Ready *bool `json:"ready,omitempty"` +} + +// ColumnInfoToSDK converts the mirror to the sdk-go type. +func ColumnInfoToSDK(w *ColumnInfo) (*sdk.ColumnInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.ColumnInfo{} + out.Name = w.Name + out.TypeText = w.TypeText + return out, nil +} + +// ColumnInfoFromSDK converts the sdk-go type to the mirror. +func ColumnInfoFromSDK(v *sdk.ColumnInfo) (*ColumnInfo, error) { + if v == nil { + return nil, nil + } + out := &ColumnInfo{} + out.Name = v.Name + out.TypeText = v.TypeText + return out, nil +} + +// CreateEndpointRequestToSDK converts the mirror to the sdk-go type. +func CreateEndpointRequestToSDK(w *CreateEndpointRequest) (*sdk.CreateEndpointRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateEndpointRequest{} + out.Name = w.Name + out.EndpointType = w.EndpointType + out.BudgetPolicyId = w.BudgetPolicyId + out.UsagePolicyId = w.UsagePolicyId + out.TargetQps = w.TargetQps + return out, nil +} + +// CreateEndpointRequestFromSDK converts the sdk-go type to the mirror. +func CreateEndpointRequestFromSDK(v *sdk.CreateEndpointRequest) (*CreateEndpointRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateEndpointRequest{} + out.Name = v.Name + out.EndpointType = v.EndpointType + out.BudgetPolicyId = v.BudgetPolicyId + out.UsagePolicyId = v.UsagePolicyId + out.TargetQps = v.TargetQps + return out, nil +} + +// CreateVectorIndexRequestToSDK converts the mirror to the sdk-go type. +func CreateVectorIndexRequestToSDK(w *CreateVectorIndexRequest) (*sdk.CreateVectorIndexRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateVectorIndexRequest{} + out.Name = w.Name + out.EndpointName = w.EndpointName + out.PrimaryKey = w.PrimaryKey + out.IndexType = w.IndexType + { + var members []string + if w.DirectAccessIndexSpec != nil { + members = append(members, "direct_access_index_spec") + } + if w.DeltaSyncIndexSpec != nil { + members = append(members, "delta_sync_index_spec") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DirectAccessIndexSpec != nil: + conv1, err := DirectAccessVectorIndexSpecToSDK(w.DirectAccessIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateVectorIndexRequest.IndexSpec", err) + } + out.IndexSpec = &sdk.CreateVectorIndexRequest_IndexSpec_DirectAccessIndexSpec{DirectAccessIndexSpec: *conv1} + case w.DeltaSyncIndexSpec != nil: + conv2, err := DeltaSyncVectorIndexSpecRequestToSDK(w.DeltaSyncIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateVectorIndexRequest.IndexSpec", err) + } + out.IndexSpec = &sdk.CreateVectorIndexRequest_IndexSpec_DeltaSyncIndexSpec{DeltaSyncIndexSpec: *conv2} + } + out.IndexSubtype = w.IndexSubtype + return out, nil +} + +// CreateVectorIndexRequestFromSDK converts the sdk-go type to the mirror. +func CreateVectorIndexRequestFromSDK(v *sdk.CreateVectorIndexRequest) (*CreateVectorIndexRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateVectorIndexRequest{} + out.Name = v.Name + out.EndpointName = v.EndpointName + out.PrimaryKey = v.PrimaryKey + out.IndexType = v.IndexType + switch value := v.IndexSpec.(type) { + case *sdk.CreateVectorIndexRequest_IndexSpec_DirectAccessIndexSpec: + if value != nil { + conv3, err := DirectAccessVectorIndexSpecFromSDK(&value.DirectAccessIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateVectorIndexRequest.IndexSpec", err) + } + out.DirectAccessIndexSpec = conv3 + } + case *sdk.CreateVectorIndexRequest_IndexSpec_DeltaSyncIndexSpec: + if value != nil { + conv4, err := DeltaSyncVectorIndexSpecRequestFromSDK(&value.DeltaSyncIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateVectorIndexRequest.IndexSpec", err) + } + out.DeltaSyncIndexSpec = conv4 + } + } + out.IndexSubtype = v.IndexSubtype + return out, nil +} + +// CustomTagToSDK converts the mirror to the sdk-go type. +func CustomTagToSDK(w *CustomTag) (*sdk.CustomTag, error) { + if w == nil { + return nil, nil + } + out := &sdk.CustomTag{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// CustomTagFromSDK converts the sdk-go type to the mirror. +func CustomTagFromSDK(v *sdk.CustomTag) (*CustomTag, error) { + if v == nil { + return nil, nil + } + out := &CustomTag{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// DeleteDataVectorIndexRequestToSDK converts the mirror to the sdk-go type. +func DeleteDataVectorIndexRequestToSDK(w *DeleteDataVectorIndexRequest) (*sdk.DeleteDataVectorIndexRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteDataVectorIndexRequest{} + out.Name = w.Name + out.PrimaryKeys = w.PrimaryKeys + return out, nil +} + +// DeleteDataVectorIndexRequestFromSDK converts the sdk-go type to the mirror. +func DeleteDataVectorIndexRequestFromSDK(v *sdk.DeleteDataVectorIndexRequest) (*DeleteDataVectorIndexRequest, error) { + if v == nil { + return nil, nil + } + out := &DeleteDataVectorIndexRequest{} + out.Name = v.Name + out.PrimaryKeys = v.PrimaryKeys + return out, nil +} + +// DeleteDataVectorIndexResponseToSDK converts the mirror to the sdk-go type. +func DeleteDataVectorIndexResponseToSDK(w *DeleteDataVectorIndexResponse) (*sdk.DeleteDataVectorIndexResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeleteDataVectorIndexResponse{} + out.Status = w.Status + conv5, err := UpsertDeleteDataResultToSDK(w.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeleteDataVectorIndexResponse.Result", err) + } + out.Result = conv5 + return out, nil +} + +// DeleteDataVectorIndexResponseFromSDK converts the sdk-go type to the mirror. +func DeleteDataVectorIndexResponseFromSDK(v *sdk.DeleteDataVectorIndexResponse) (*DeleteDataVectorIndexResponse, error) { + if v == nil { + return nil, nil + } + out := &DeleteDataVectorIndexResponse{} + out.Status = v.Status + conv6, err := UpsertDeleteDataResultFromSDK(v.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeleteDataVectorIndexResponse.Result", err) + } + out.Result = conv6 + return out, nil +} + +// DeltaSyncVectorIndexSpecToSDK converts the mirror to the sdk-go type. +func DeltaSyncVectorIndexSpecToSDK(w *DeltaSyncVectorIndexSpec) (*sdk.DeltaSyncVectorIndexSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeltaSyncVectorIndexSpec{} + out.SourceTable = w.SourceTable + conv7, err := convertSlice(w.EmbeddingSourceColumns, EmbeddingSourceColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeltaSyncVectorIndexSpec.EmbeddingSourceColumns", err) + } + out.EmbeddingSourceColumns = conv7 + conv8, err := convertSlice(w.EmbeddingVectorColumns, EmbeddingVectorColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeltaSyncVectorIndexSpec.EmbeddingVectorColumns", err) + } + out.EmbeddingVectorColumns = conv8 + out.PipelineType = w.PipelineType + out.PipelineId = w.PipelineId + out.EmbeddingWritebackTable = w.EmbeddingWritebackTable + out.ColumnsToSync = w.ColumnsToSync + out.ColumnsToIndex = w.ColumnsToIndex + return out, nil +} + +// DeltaSyncVectorIndexSpecFromSDK converts the sdk-go type to the mirror. +func DeltaSyncVectorIndexSpecFromSDK(v *sdk.DeltaSyncVectorIndexSpec) (*DeltaSyncVectorIndexSpec, error) { + if v == nil { + return nil, nil + } + out := &DeltaSyncVectorIndexSpec{} + out.SourceTable = v.SourceTable + conv9, err := convertSlice(v.EmbeddingSourceColumns, EmbeddingSourceColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeltaSyncVectorIndexSpec.EmbeddingSourceColumns", err) + } + out.EmbeddingSourceColumns = conv9 + conv10, err := convertSlice(v.EmbeddingVectorColumns, EmbeddingVectorColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeltaSyncVectorIndexSpec.EmbeddingVectorColumns", err) + } + out.EmbeddingVectorColumns = conv10 + out.PipelineType = v.PipelineType + out.PipelineId = v.PipelineId + out.EmbeddingWritebackTable = v.EmbeddingWritebackTable + out.ColumnsToSync = v.ColumnsToSync + out.ColumnsToIndex = v.ColumnsToIndex + return out, nil +} + +// DeltaSyncVectorIndexSpecRequestToSDK converts the mirror to the sdk-go type. +func DeltaSyncVectorIndexSpecRequestToSDK(w *DeltaSyncVectorIndexSpecRequest) (*sdk.DeltaSyncVectorIndexSpecRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.DeltaSyncVectorIndexSpecRequest{} + out.SourceTable = w.SourceTable + conv11, err := convertSlice(w.EmbeddingSourceColumns, EmbeddingSourceColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeltaSyncVectorIndexSpecRequest.EmbeddingSourceColumns", err) + } + out.EmbeddingSourceColumns = conv11 + conv12, err := convertSlice(w.EmbeddingVectorColumns, EmbeddingVectorColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeltaSyncVectorIndexSpecRequest.EmbeddingVectorColumns", err) + } + out.EmbeddingVectorColumns = conv12 + out.PipelineType = w.PipelineType + out.PipelineId = w.PipelineId + out.EmbeddingWritebackTable = w.EmbeddingWritebackTable + out.ColumnsToSync = w.ColumnsToSync + out.ColumnsToIndex = w.ColumnsToIndex + return out, nil +} + +// DeltaSyncVectorIndexSpecRequestFromSDK converts the sdk-go type to the mirror. +func DeltaSyncVectorIndexSpecRequestFromSDK(v *sdk.DeltaSyncVectorIndexSpecRequest) (*DeltaSyncVectorIndexSpecRequest, error) { + if v == nil { + return nil, nil + } + out := &DeltaSyncVectorIndexSpecRequest{} + out.SourceTable = v.SourceTable + conv13, err := convertSlice(v.EmbeddingSourceColumns, EmbeddingSourceColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeltaSyncVectorIndexSpecRequest.EmbeddingSourceColumns", err) + } + out.EmbeddingSourceColumns = conv13 + conv14, err := convertSlice(v.EmbeddingVectorColumns, EmbeddingVectorColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DeltaSyncVectorIndexSpecRequest.EmbeddingVectorColumns", err) + } + out.EmbeddingVectorColumns = conv14 + out.PipelineType = v.PipelineType + out.PipelineId = v.PipelineId + out.EmbeddingWritebackTable = v.EmbeddingWritebackTable + out.ColumnsToSync = v.ColumnsToSync + out.ColumnsToIndex = v.ColumnsToIndex + return out, nil +} + +// DirectAccessVectorIndexSpecToSDK converts the mirror to the sdk-go type. +func DirectAccessVectorIndexSpecToSDK(w *DirectAccessVectorIndexSpec) (*sdk.DirectAccessVectorIndexSpec, error) { + if w == nil { + return nil, nil + } + out := &sdk.DirectAccessVectorIndexSpec{} + conv15, err := convertSlice(w.EmbeddingVectorColumns, EmbeddingVectorColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectAccessVectorIndexSpec.EmbeddingVectorColumns", err) + } + out.EmbeddingVectorColumns = conv15 + out.SchemaJson = w.SchemaJson + conv16, err := convertSlice(w.EmbeddingSourceColumns, EmbeddingSourceColumnToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectAccessVectorIndexSpec.EmbeddingSourceColumns", err) + } + out.EmbeddingSourceColumns = conv16 + return out, nil +} + +// DirectAccessVectorIndexSpecFromSDK converts the sdk-go type to the mirror. +func DirectAccessVectorIndexSpecFromSDK(v *sdk.DirectAccessVectorIndexSpec) (*DirectAccessVectorIndexSpec, error) { + if v == nil { + return nil, nil + } + out := &DirectAccessVectorIndexSpec{} + conv17, err := convertSlice(v.EmbeddingVectorColumns, EmbeddingVectorColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectAccessVectorIndexSpec.EmbeddingVectorColumns", err) + } + out.EmbeddingVectorColumns = conv17 + out.SchemaJson = v.SchemaJson + conv18, err := convertSlice(v.EmbeddingSourceColumns, EmbeddingSourceColumnFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "DirectAccessVectorIndexSpec.EmbeddingSourceColumns", err) + } + out.EmbeddingSourceColumns = conv18 + return out, nil +} + +// EmbeddingSourceColumnToSDK converts the mirror to the sdk-go type. +func EmbeddingSourceColumnToSDK(w *EmbeddingSourceColumn) (*sdk.EmbeddingSourceColumn, error) { + if w == nil { + return nil, nil + } + out := &sdk.EmbeddingSourceColumn{} + out.Name = w.Name + { + var members []string + if w.EmbeddingModelEndpointName != nil { + members = append(members, "embedding_model_endpoint_name") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.EmbeddingModelEndpointName != nil: + out.EmbeddingConfig = &sdk.EmbeddingSourceColumn_EmbeddingConfig_EmbeddingModelEndpointName{EmbeddingModelEndpointName: *w.EmbeddingModelEndpointName} + } + out.ModelEndpointNameForQuery = w.ModelEndpointNameForQuery + return out, nil +} + +// EmbeddingSourceColumnFromSDK converts the sdk-go type to the mirror. +func EmbeddingSourceColumnFromSDK(v *sdk.EmbeddingSourceColumn) (*EmbeddingSourceColumn, error) { + if v == nil { + return nil, nil + } + out := &EmbeddingSourceColumn{} + out.Name = v.Name + switch value := v.EmbeddingConfig.(type) { + case *sdk.EmbeddingSourceColumn_EmbeddingConfig_EmbeddingModelEndpointName: + if value != nil { + out.EmbeddingModelEndpointName = new(value.EmbeddingModelEndpointName) + } + } + out.ModelEndpointNameForQuery = v.ModelEndpointNameForQuery + return out, nil +} + +// EmbeddingVectorColumnToSDK converts the mirror to the sdk-go type. +func EmbeddingVectorColumnToSDK(w *EmbeddingVectorColumn) (*sdk.EmbeddingVectorColumn, error) { + if w == nil { + return nil, nil + } + out := &sdk.EmbeddingVectorColumn{} + out.Name = w.Name + out.EmbeddingDimension = w.EmbeddingDimension + return out, nil +} + +// EmbeddingVectorColumnFromSDK converts the sdk-go type to the mirror. +func EmbeddingVectorColumnFromSDK(v *sdk.EmbeddingVectorColumn) (*EmbeddingVectorColumn, error) { + if v == nil { + return nil, nil + } + out := &EmbeddingVectorColumn{} + out.Name = v.Name + out.EmbeddingDimension = v.EmbeddingDimension + return out, nil +} + +// EndpointToSDK converts the mirror to the sdk-go type. +func EndpointToSDK(w *Endpoint) (*sdk.Endpoint, error) { + if w == nil { + return nil, nil + } + out := &sdk.Endpoint{} + out.Name = w.Name + out.Creator = w.Creator + out.CreationTimestamp = w.CreationTimestamp + out.LastUpdatedTimestamp = w.LastUpdatedTimestamp + out.EndpointType = w.EndpointType + out.LastUpdatedUser = w.LastUpdatedUser + out.Id = w.Id + conv19, err := EndpointStatusToSDK(w.EndpointStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.EndpointStatus", err) + } + out.EndpointStatus = conv19 + out.NumIndexes = w.NumIndexes + out.BudgetPolicyId = w.BudgetPolicyId + out.EffectiveBudgetPolicyId = w.EffectiveBudgetPolicyId + conv20, err := convertSlice(w.CustomTags, CustomTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.CustomTags", err) + } + out.CustomTags = conv20 + conv21, err := EndpointScalingInfoToSDK(w.ScalingInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.ScalingInfo", err) + } + out.ScalingInfo = conv21 + return out, nil +} + +// EndpointFromSDK converts the sdk-go type to the mirror. +func EndpointFromSDK(v *sdk.Endpoint) (*Endpoint, error) { + if v == nil { + return nil, nil + } + out := &Endpoint{} + out.Name = v.Name + out.Creator = v.Creator + out.CreationTimestamp = v.CreationTimestamp + out.LastUpdatedTimestamp = v.LastUpdatedTimestamp + out.EndpointType = v.EndpointType + out.LastUpdatedUser = v.LastUpdatedUser + out.Id = v.Id + conv22, err := EndpointStatusFromSDK(v.EndpointStatus) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.EndpointStatus", err) + } + out.EndpointStatus = conv22 + out.NumIndexes = v.NumIndexes + out.BudgetPolicyId = v.BudgetPolicyId + out.EffectiveBudgetPolicyId = v.EffectiveBudgetPolicyId + conv23, err := convertSlice(v.CustomTags, CustomTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.CustomTags", err) + } + out.CustomTags = conv23 + conv24, err := EndpointScalingInfoFromSDK(v.ScalingInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Endpoint.ScalingInfo", err) + } + out.ScalingInfo = conv24 + return out, nil +} + +// EndpointScalingInfoToSDK converts the mirror to the sdk-go type. +func EndpointScalingInfoToSDK(w *EndpointScalingInfo) (*sdk.EndpointScalingInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointScalingInfo{} + out.State = w.State + out.RequestedTargetQps = w.RequestedTargetQps + return out, nil +} + +// EndpointScalingInfoFromSDK converts the sdk-go type to the mirror. +func EndpointScalingInfoFromSDK(v *sdk.EndpointScalingInfo) (*EndpointScalingInfo, error) { + if v == nil { + return nil, nil + } + out := &EndpointScalingInfo{} + out.State = v.State + out.RequestedTargetQps = v.RequestedTargetQps + return out, nil +} + +// EndpointStatusToSDK converts the mirror to the sdk-go type. +func EndpointStatusToSDK(w *EndpointStatus) (*sdk.EndpointStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointStatus{} + out.State = w.State + out.Message = w.Message + return out, nil +} + +// EndpointStatusFromSDK converts the sdk-go type to the mirror. +func EndpointStatusFromSDK(v *sdk.EndpointStatus) (*EndpointStatus, error) { + if v == nil { + return nil, nil + } + out := &EndpointStatus{} + out.State = v.State + out.Message = v.Message + return out, nil +} + +// FacetResultDataToSDK converts the mirror to the sdk-go type. +func FacetResultDataToSDK(w *FacetResultData) (*sdk.FacetResultData, error) { + if w == nil { + return nil, nil + } + out := &sdk.FacetResultData{} + out.FacetRowCount = w.FacetRowCount + out.FacetArray = w.FacetArray + return out, nil +} + +// FacetResultDataFromSDK converts the sdk-go type to the mirror. +func FacetResultDataFromSDK(v *sdk.FacetResultData) (*FacetResultData, error) { + if v == nil { + return nil, nil + } + out := &FacetResultData{} + out.FacetRowCount = v.FacetRowCount + out.FacetArray = v.FacetArray + return out, nil +} + +// GetVectorIndexRequestToSDK converts the mirror to the sdk-go type. +func GetVectorIndexRequestToSDK(w *GetVectorIndexRequest) (*sdk.GetVectorIndexRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetVectorIndexRequest{} + out.Name = w.Name + out.EnsureRerankerCompatible = w.EnsureRerankerCompatible + return out, nil +} + +// GetVectorIndexRequestFromSDK converts the sdk-go type to the mirror. +func GetVectorIndexRequestFromSDK(v *sdk.GetVectorIndexRequest) (*GetVectorIndexRequest, error) { + if v == nil { + return nil, nil + } + out := &GetVectorIndexRequest{} + out.Name = v.Name + out.EnsureRerankerCompatible = v.EnsureRerankerCompatible + return out, nil +} + +// ListEndpointResponseToSDK converts the mirror to the sdk-go type. +func ListEndpointResponseToSDK(w *ListEndpointResponse) (*sdk.ListEndpointResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEndpointResponse{} + conv25, err := convertSlice(w.Endpoints, EndpointToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListEndpointResponse.Endpoints", err) + } + out.Endpoints = conv25 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListEndpointResponseFromSDK converts the sdk-go type to the mirror. +func ListEndpointResponseFromSDK(v *sdk.ListEndpointResponse) (*ListEndpointResponse, error) { + if v == nil { + return nil, nil + } + out := &ListEndpointResponse{} + conv26, err := convertSlice(v.Endpoints, EndpointFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListEndpointResponse.Endpoints", err) + } + out.Endpoints = conv26 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListEndpointsRequestToSDK converts the mirror to the sdk-go type. +func ListEndpointsRequestToSDK(w *ListEndpointsRequest) (*sdk.ListEndpointsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListEndpointsRequest{} + out.PageToken = w.PageToken + return out, nil +} + +// ListEndpointsRequestFromSDK converts the sdk-go type to the mirror. +func ListEndpointsRequestFromSDK(v *sdk.ListEndpointsRequest) (*ListEndpointsRequest, error) { + if v == nil { + return nil, nil + } + out := &ListEndpointsRequest{} + out.PageToken = v.PageToken + return out, nil +} + +// ListValueToSDK converts the mirror to the sdk-go type. +func ListValueToSDK(w *ListValue) (*sdk.ListValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListValue{} + conv27, err := convertSlice(w.Values, ValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListValue.Values", err) + } + out.Values = conv27 + return out, nil +} + +// ListValueFromSDK converts the sdk-go type to the mirror. +func ListValueFromSDK(v *sdk.ListValue) (*ListValue, error) { + if v == nil { + return nil, nil + } + out := &ListValue{} + conv28, err := convertSlice(v.Values, ValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListValue.Values", err) + } + out.Values = conv28 + return out, nil +} + +// ListVectorIndexRequestToSDK converts the mirror to the sdk-go type. +func ListVectorIndexRequestToSDK(w *ListVectorIndexRequest) (*sdk.ListVectorIndexRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListVectorIndexRequest{} + out.EndpointName = w.EndpointName + out.PageToken = w.PageToken + return out, nil +} + +// ListVectorIndexRequestFromSDK converts the sdk-go type to the mirror. +func ListVectorIndexRequestFromSDK(v *sdk.ListVectorIndexRequest) (*ListVectorIndexRequest, error) { + if v == nil { + return nil, nil + } + out := &ListVectorIndexRequest{} + out.EndpointName = v.EndpointName + out.PageToken = v.PageToken + return out, nil +} + +// ListVectorIndexResponseToSDK converts the mirror to the sdk-go type. +func ListVectorIndexResponseToSDK(w *ListVectorIndexResponse) (*sdk.ListVectorIndexResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListVectorIndexResponse{} + conv29, err := convertSlice(w.VectorIndexes, MiniVectorIndexToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListVectorIndexResponse.VectorIndexes", err) + } + out.VectorIndexes = conv29 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListVectorIndexResponseFromSDK converts the sdk-go type to the mirror. +func ListVectorIndexResponseFromSDK(v *sdk.ListVectorIndexResponse) (*ListVectorIndexResponse, error) { + if v == nil { + return nil, nil + } + out := &ListVectorIndexResponse{} + conv30, err := convertSlice(v.VectorIndexes, MiniVectorIndexFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListVectorIndexResponse.VectorIndexes", err) + } + out.VectorIndexes = conv30 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// MapStringValueEntryToSDK converts the mirror to the sdk-go type. +func MapStringValueEntryToSDK(w *MapStringValueEntry) (*sdk.MapStringValueEntry, error) { + if w == nil { + return nil, nil + } + out := &sdk.MapStringValueEntry{} + out.Key = w.Key + conv31, err := ValueToSDK(w.Value) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MapStringValueEntry.Value", err) + } + out.Value = conv31 + return out, nil +} + +// MapStringValueEntryFromSDK converts the sdk-go type to the mirror. +func MapStringValueEntryFromSDK(v *sdk.MapStringValueEntry) (*MapStringValueEntry, error) { + if v == nil { + return nil, nil + } + out := &MapStringValueEntry{} + out.Key = v.Key + conv32, err := ValueFromSDK(v.Value) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MapStringValueEntry.Value", err) + } + out.Value = conv32 + return out, nil +} + +// MetricToSDK converts the mirror to the sdk-go type. +func MetricToSDK(w *Metric) (*sdk.Metric, error) { + if w == nil { + return nil, nil + } + out := &sdk.Metric{} + out.Name = w.Name + conv33, err := convertSlice(w.Labels, MetricLabelToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Metric.Labels", err) + } + out.Labels = conv33 + out.Percentile = w.Percentile + return out, nil +} + +// MetricFromSDK converts the sdk-go type to the mirror. +func MetricFromSDK(v *sdk.Metric) (*Metric, error) { + if v == nil { + return nil, nil + } + out := &Metric{} + out.Name = v.Name + conv34, err := convertSlice(v.Labels, MetricLabelFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Metric.Labels", err) + } + out.Labels = conv34 + out.Percentile = v.Percentile + return out, nil +} + +// MetricLabelToSDK converts the mirror to the sdk-go type. +func MetricLabelToSDK(w *MetricLabel) (*sdk.MetricLabel, error) { + if w == nil { + return nil, nil + } + out := &sdk.MetricLabel{} + out.Name = w.Name + out.Value = w.Value + return out, nil +} + +// MetricLabelFromSDK converts the sdk-go type to the mirror. +func MetricLabelFromSDK(v *sdk.MetricLabel) (*MetricLabel, error) { + if v == nil { + return nil, nil + } + out := &MetricLabel{} + out.Name = v.Name + out.Value = v.Value + return out, nil +} + +// MetricValueToSDK converts the mirror to the sdk-go type. +func MetricValueToSDK(w *MetricValue) (*sdk.MetricValue, error) { + if w == nil { + return nil, nil + } + out := &sdk.MetricValue{} + out.Timestamp = w.Timestamp + out.Value = w.Value + return out, nil +} + +// MetricValueFromSDK converts the sdk-go type to the mirror. +func MetricValueFromSDK(v *sdk.MetricValue) (*MetricValue, error) { + if v == nil { + return nil, nil + } + out := &MetricValue{} + out.Timestamp = v.Timestamp + out.Value = v.Value + return out, nil +} + +// MetricValuesToSDK converts the mirror to the sdk-go type. +func MetricValuesToSDK(w *MetricValues) (*sdk.MetricValues, error) { + if w == nil { + return nil, nil + } + out := &sdk.MetricValues{} + conv35, err := MetricToSDK(w.Metric) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MetricValues.Metric", err) + } + out.Metric = conv35 + conv36, err := convertSlice(w.Values, MetricValueToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MetricValues.Values", err) + } + out.Values = conv36 + return out, nil +} + +// MetricValuesFromSDK converts the sdk-go type to the mirror. +func MetricValuesFromSDK(v *sdk.MetricValues) (*MetricValues, error) { + if v == nil { + return nil, nil + } + out := &MetricValues{} + conv37, err := MetricFromSDK(v.Metric) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MetricValues.Metric", err) + } + out.Metric = conv37 + conv38, err := convertSlice(v.Values, MetricValueFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MetricValues.Values", err) + } + out.Values = conv38 + return out, nil +} + +// MiniVectorIndexToSDK converts the mirror to the sdk-go type. +func MiniVectorIndexToSDK(w *MiniVectorIndex) (*sdk.MiniVectorIndex, error) { + if w == nil { + return nil, nil + } + out := &sdk.MiniVectorIndex{} + out.Name = w.Name + out.EndpointName = w.EndpointName + out.PrimaryKey = w.PrimaryKey + out.IndexType = w.IndexType + { + var members []string + if w.DirectAccessIndexSpec != nil { + members = append(members, "direct_access_index_spec") + } + if w.DeltaSyncIndexSpec != nil { + members = append(members, "delta_sync_index_spec") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DirectAccessIndexSpec != nil: + conv39, err := DirectAccessVectorIndexSpecToSDK(w.DirectAccessIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MiniVectorIndex.IndexSpec", err) + } + out.IndexSpec = &sdk.MiniVectorIndex_IndexSpec_DirectAccessIndexSpec{DirectAccessIndexSpec: *conv39} + case w.DeltaSyncIndexSpec != nil: + conv40, err := DeltaSyncVectorIndexSpecToSDK(w.DeltaSyncIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MiniVectorIndex.IndexSpec", err) + } + out.IndexSpec = &sdk.MiniVectorIndex_IndexSpec_DeltaSyncIndexSpec{DeltaSyncIndexSpec: *conv40} + } + conv41, err := VectorIndexStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MiniVectorIndex.Status", err) + } + out.Status = conv41 + out.Creator = w.Creator + out.IndexSubtype = w.IndexSubtype + out.EndpointId = w.EndpointId + return out, nil +} + +// MiniVectorIndexFromSDK converts the sdk-go type to the mirror. +func MiniVectorIndexFromSDK(v *sdk.MiniVectorIndex) (*MiniVectorIndex, error) { + if v == nil { + return nil, nil + } + out := &MiniVectorIndex{} + out.Name = v.Name + out.EndpointName = v.EndpointName + out.PrimaryKey = v.PrimaryKey + out.IndexType = v.IndexType + switch value := v.IndexSpec.(type) { + case *sdk.MiniVectorIndex_IndexSpec_DirectAccessIndexSpec: + if value != nil { + conv42, err := DirectAccessVectorIndexSpecFromSDK(&value.DirectAccessIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MiniVectorIndex.IndexSpec", err) + } + out.DirectAccessIndexSpec = conv42 + } + case *sdk.MiniVectorIndex_IndexSpec_DeltaSyncIndexSpec: + if value != nil { + conv43, err := DeltaSyncVectorIndexSpecFromSDK(&value.DeltaSyncIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MiniVectorIndex.IndexSpec", err) + } + out.DeltaSyncIndexSpec = conv43 + } + } + conv44, err := VectorIndexStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "MiniVectorIndex.Status", err) + } + out.Status = conv44 + out.Creator = v.Creator + out.IndexSubtype = v.IndexSubtype + out.EndpointId = v.EndpointId + return out, nil +} + +// PatchEndpointBudgetPolicyRequestToSDK converts the mirror to the sdk-go type. +func PatchEndpointBudgetPolicyRequestToSDK(w *PatchEndpointBudgetPolicyRequest) (*sdk.PatchEndpointBudgetPolicyRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchEndpointBudgetPolicyRequest{} + out.Name = w.Name + out.BudgetPolicyId = w.BudgetPolicyId + return out, nil +} + +// PatchEndpointBudgetPolicyRequestFromSDK converts the sdk-go type to the mirror. +func PatchEndpointBudgetPolicyRequestFromSDK(v *sdk.PatchEndpointBudgetPolicyRequest) (*PatchEndpointBudgetPolicyRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchEndpointBudgetPolicyRequest{} + out.Name = v.Name + out.BudgetPolicyId = v.BudgetPolicyId + return out, nil +} + +// PatchEndpointBudgetPolicyResponseToSDK converts the mirror to the sdk-go type. +func PatchEndpointBudgetPolicyResponseToSDK(w *PatchEndpointBudgetPolicyResponse) (*sdk.PatchEndpointBudgetPolicyResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchEndpointBudgetPolicyResponse{} + out.BudgetPolicyId = w.BudgetPolicyId + out.EffectiveBudgetPolicyId = w.EffectiveBudgetPolicyId + return out, nil +} + +// PatchEndpointBudgetPolicyResponseFromSDK converts the sdk-go type to the mirror. +func PatchEndpointBudgetPolicyResponseFromSDK(v *sdk.PatchEndpointBudgetPolicyResponse) (*PatchEndpointBudgetPolicyResponse, error) { + if v == nil { + return nil, nil + } + out := &PatchEndpointBudgetPolicyResponse{} + out.BudgetPolicyId = v.BudgetPolicyId + out.EffectiveBudgetPolicyId = v.EffectiveBudgetPolicyId + return out, nil +} + +// PatchEndpointRequestToSDK converts the mirror to the sdk-go type. +func PatchEndpointRequestToSDK(w *PatchEndpointRequest) (*sdk.PatchEndpointRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.PatchEndpointRequest{} + out.Name = w.Name + out.TargetQps = w.TargetQps + return out, nil +} + +// PatchEndpointRequestFromSDK converts the sdk-go type to the mirror. +func PatchEndpointRequestFromSDK(v *sdk.PatchEndpointRequest) (*PatchEndpointRequest, error) { + if v == nil { + return nil, nil + } + out := &PatchEndpointRequest{} + out.Name = v.Name + out.TargetQps = v.TargetQps + return out, nil +} + +// QueryVectorIndexNextPageRequestToSDK converts the mirror to the sdk-go type. +func QueryVectorIndexNextPageRequestToSDK(w *QueryVectorIndexNextPageRequest) (*sdk.QueryVectorIndexNextPageRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryVectorIndexNextPageRequest{} + out.Name = w.Name + out.EndpointName = w.EndpointName + out.PageToken = w.PageToken + return out, nil +} + +// QueryVectorIndexNextPageRequestFromSDK converts the sdk-go type to the mirror. +func QueryVectorIndexNextPageRequestFromSDK(v *sdk.QueryVectorIndexNextPageRequest) (*QueryVectorIndexNextPageRequest, error) { + if v == nil { + return nil, nil + } + out := &QueryVectorIndexNextPageRequest{} + out.Name = v.Name + out.EndpointName = v.EndpointName + out.PageToken = v.PageToken + return out, nil +} + +// QueryVectorIndexRequestToSDK converts the mirror to the sdk-go type. +func QueryVectorIndexRequestToSDK(w *QueryVectorIndexRequest) (*sdk.QueryVectorIndexRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryVectorIndexRequest{} + out.Name = w.Name + out.NumResults = w.NumResults + out.Columns = w.Columns + out.FiltersJson = w.FiltersJson + out.QueryVector = w.QueryVector + out.QueryText = w.QueryText + out.ScoreThreshold = w.ScoreThreshold + out.QueryType = w.QueryType + out.ColumnsToRerank = w.ColumnsToRerank + conv45, err := RerankerConfigToSDK(w.Reranker) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryVectorIndexRequest.Reranker", err) + } + out.Reranker = conv45 + out.QueryColumns = w.QueryColumns + out.SortColumns = w.SortColumns + out.Facets = w.Facets + return out, nil +} + +// QueryVectorIndexRequestFromSDK converts the sdk-go type to the mirror. +func QueryVectorIndexRequestFromSDK(v *sdk.QueryVectorIndexRequest) (*QueryVectorIndexRequest, error) { + if v == nil { + return nil, nil + } + out := &QueryVectorIndexRequest{} + out.Name = v.Name + out.NumResults = v.NumResults + out.Columns = v.Columns + out.FiltersJson = v.FiltersJson + out.QueryVector = v.QueryVector + out.QueryText = v.QueryText + out.ScoreThreshold = v.ScoreThreshold + out.QueryType = v.QueryType + out.ColumnsToRerank = v.ColumnsToRerank + conv46, err := RerankerConfigFromSDK(v.Reranker) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryVectorIndexRequest.Reranker", err) + } + out.Reranker = conv46 + out.QueryColumns = v.QueryColumns + out.SortColumns = v.SortColumns + out.Facets = v.Facets + return out, nil +} + +// QueryVectorIndexResponseToSDK converts the mirror to the sdk-go type. +func QueryVectorIndexResponseToSDK(w *QueryVectorIndexResponse) (*sdk.QueryVectorIndexResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.QueryVectorIndexResponse{} + conv47, err := ResultManifestToSDK(w.Manifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryVectorIndexResponse.Manifest", err) + } + out.Manifest = conv47 + conv48, err := ResultDataToSDK(w.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryVectorIndexResponse.Result", err) + } + out.Result = conv48 + out.NextPageToken = w.NextPageToken + conv49, err := FacetResultDataToSDK(w.FacetResult) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryVectorIndexResponse.FacetResult", err) + } + out.FacetResult = conv49 + return out, nil +} + +// QueryVectorIndexResponseFromSDK converts the sdk-go type to the mirror. +func QueryVectorIndexResponseFromSDK(v *sdk.QueryVectorIndexResponse) (*QueryVectorIndexResponse, error) { + if v == nil { + return nil, nil + } + out := &QueryVectorIndexResponse{} + conv50, err := ResultManifestFromSDK(v.Manifest) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryVectorIndexResponse.Manifest", err) + } + out.Manifest = conv50 + conv51, err := ResultDataFromSDK(v.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryVectorIndexResponse.Result", err) + } + out.Result = conv51 + out.NextPageToken = v.NextPageToken + conv52, err := FacetResultDataFromSDK(v.FacetResult) + if err != nil { + return nil, fmt.Errorf("%s: %w", "QueryVectorIndexResponse.FacetResult", err) + } + out.FacetResult = conv52 + return out, nil +} + +// RerankerConfigToSDK converts the mirror to the sdk-go type. +func RerankerConfigToSDK(w *RerankerConfig) (*sdk.RerankerConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.RerankerConfig{} + out.Model = w.Model + conv53, err := RerankerConfig_RerankerParametersToSDK(w.Parameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RerankerConfig.Parameters", err) + } + out.Parameters = conv53 + return out, nil +} + +// RerankerConfigFromSDK converts the sdk-go type to the mirror. +func RerankerConfigFromSDK(v *sdk.RerankerConfig) (*RerankerConfig, error) { + if v == nil { + return nil, nil + } + out := &RerankerConfig{} + out.Model = v.Model + conv54, err := RerankerConfig_RerankerParametersFromSDK(v.Parameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RerankerConfig.Parameters", err) + } + out.Parameters = conv54 + return out, nil +} + +// RerankerConfig_RerankerParametersToSDK converts the mirror to the sdk-go type. +func RerankerConfig_RerankerParametersToSDK(w *RerankerConfig_RerankerParameters) (*sdk.RerankerConfig_RerankerParameters, error) { + if w == nil { + return nil, nil + } + out := &sdk.RerankerConfig_RerankerParameters{} + out.ColumnsToRerank = w.ColumnsToRerank + return out, nil +} + +// RerankerConfig_RerankerParametersFromSDK converts the sdk-go type to the mirror. +func RerankerConfig_RerankerParametersFromSDK(v *sdk.RerankerConfig_RerankerParameters) (*RerankerConfig_RerankerParameters, error) { + if v == nil { + return nil, nil + } + out := &RerankerConfig_RerankerParameters{} + out.ColumnsToRerank = v.ColumnsToRerank + return out, nil +} + +// ResultDataToSDK converts the mirror to the sdk-go type. +func ResultDataToSDK(w *ResultData) (*sdk.ResultData, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResultData{} + out.RowCount = w.RowCount + out.DataArray = w.DataArray + return out, nil +} + +// ResultDataFromSDK converts the sdk-go type to the mirror. +func ResultDataFromSDK(v *sdk.ResultData) (*ResultData, error) { + if v == nil { + return nil, nil + } + out := &ResultData{} + out.RowCount = v.RowCount + out.DataArray = v.DataArray + return out, nil +} + +// ResultManifestToSDK converts the mirror to the sdk-go type. +func ResultManifestToSDK(w *ResultManifest) (*sdk.ResultManifest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ResultManifest{} + out.ColumnCount = w.ColumnCount + conv55, err := convertSlice(w.Columns, ColumnInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.Columns", err) + } + out.Columns = conv55 + out.FacetColumnCount = w.FacetColumnCount + conv56, err := convertSlice(w.FacetColumns, ColumnInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.FacetColumns", err) + } + out.FacetColumns = conv56 + return out, nil +} + +// ResultManifestFromSDK converts the sdk-go type to the mirror. +func ResultManifestFromSDK(v *sdk.ResultManifest) (*ResultManifest, error) { + if v == nil { + return nil, nil + } + out := &ResultManifest{} + out.ColumnCount = v.ColumnCount + conv57, err := convertSlice(v.Columns, ColumnInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.Columns", err) + } + out.Columns = conv57 + out.FacetColumnCount = v.FacetColumnCount + conv58, err := convertSlice(v.FacetColumns, ColumnInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ResultManifest.FacetColumns", err) + } + out.FacetColumns = conv58 + return out, nil +} + +// RetrieveUserVisibleMetricsRequestToSDK converts the mirror to the sdk-go type. +func RetrieveUserVisibleMetricsRequestToSDK(w *RetrieveUserVisibleMetricsRequest) (*sdk.RetrieveUserVisibleMetricsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.RetrieveUserVisibleMetricsRequest{} + out.Name = w.Name + out.StartTime = w.StartTime + out.EndTime = w.EndTime + out.GranularityInSeconds = w.GranularityInSeconds + conv59, err := convertSlice(w.Metrics, MetricToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RetrieveUserVisibleMetricsRequest.Metrics", err) + } + out.Metrics = conv59 + out.PageToken = w.PageToken + return out, nil +} + +// RetrieveUserVisibleMetricsRequestFromSDK converts the sdk-go type to the mirror. +func RetrieveUserVisibleMetricsRequestFromSDK(v *sdk.RetrieveUserVisibleMetricsRequest) (*RetrieveUserVisibleMetricsRequest, error) { + if v == nil { + return nil, nil + } + out := &RetrieveUserVisibleMetricsRequest{} + out.Name = v.Name + out.StartTime = v.StartTime + out.EndTime = v.EndTime + out.GranularityInSeconds = v.GranularityInSeconds + conv60, err := convertSlice(v.Metrics, MetricFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RetrieveUserVisibleMetricsRequest.Metrics", err) + } + out.Metrics = conv60 + out.PageToken = v.PageToken + return out, nil +} + +// RetrieveUserVisibleMetricsResponseToSDK converts the mirror to the sdk-go type. +func RetrieveUserVisibleMetricsResponseToSDK(w *RetrieveUserVisibleMetricsResponse) (*sdk.RetrieveUserVisibleMetricsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.RetrieveUserVisibleMetricsResponse{} + conv61, err := convertSlice(w.MetricValues, MetricValuesToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RetrieveUserVisibleMetricsResponse.MetricValues", err) + } + out.MetricValues = conv61 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// RetrieveUserVisibleMetricsResponseFromSDK converts the sdk-go type to the mirror. +func RetrieveUserVisibleMetricsResponseFromSDK(v *sdk.RetrieveUserVisibleMetricsResponse) (*RetrieveUserVisibleMetricsResponse, error) { + if v == nil { + return nil, nil + } + out := &RetrieveUserVisibleMetricsResponse{} + conv62, err := convertSlice(v.MetricValues, MetricValuesFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RetrieveUserVisibleMetricsResponse.MetricValues", err) + } + out.MetricValues = conv62 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ScanVectorIndexRequestToSDK converts the mirror to the sdk-go type. +func ScanVectorIndexRequestToSDK(w *ScanVectorIndexRequest) (*sdk.ScanVectorIndexRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ScanVectorIndexRequest{} + out.Name = w.Name + out.NumResults = w.NumResults + out.LastPrimaryKey = w.LastPrimaryKey + return out, nil +} + +// ScanVectorIndexRequestFromSDK converts the sdk-go type to the mirror. +func ScanVectorIndexRequestFromSDK(v *sdk.ScanVectorIndexRequest) (*ScanVectorIndexRequest, error) { + if v == nil { + return nil, nil + } + out := &ScanVectorIndexRequest{} + out.Name = v.Name + out.NumResults = v.NumResults + out.LastPrimaryKey = v.LastPrimaryKey + return out, nil +} + +// ScanVectorIndexResponseToSDK converts the mirror to the sdk-go type. +func ScanVectorIndexResponseToSDK(w *ScanVectorIndexResponse) (*sdk.ScanVectorIndexResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ScanVectorIndexResponse{} + conv63, err := convertSlice(w.Data, StructToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ScanVectorIndexResponse.Data", err) + } + out.Data = conv63 + out.LastPrimaryKey = w.LastPrimaryKey + return out, nil +} + +// ScanVectorIndexResponseFromSDK converts the sdk-go type to the mirror. +func ScanVectorIndexResponseFromSDK(v *sdk.ScanVectorIndexResponse) (*ScanVectorIndexResponse, error) { + if v == nil { + return nil, nil + } + out := &ScanVectorIndexResponse{} + conv64, err := convertSlice(v.Data, StructFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ScanVectorIndexResponse.Data", err) + } + out.Data = conv64 + out.LastPrimaryKey = v.LastPrimaryKey + return out, nil +} + +// StructToSDK converts the mirror to the sdk-go type. +func StructToSDK(w *Struct) (*sdk.Struct, error) { + if w == nil { + return nil, nil + } + out := &sdk.Struct{} + conv65, err := convertSlice(w.Fields, MapStringValueEntryToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Struct.Fields", err) + } + out.Fields = conv65 + return out, nil +} + +// StructFromSDK converts the sdk-go type to the mirror. +func StructFromSDK(v *sdk.Struct) (*Struct, error) { + if v == nil { + return nil, nil + } + out := &Struct{} + conv66, err := convertSlice(v.Fields, MapStringValueEntryFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Struct.Fields", err) + } + out.Fields = conv66 + return out, nil +} + +// SyncVectorIndexRequestToSDK converts the mirror to the sdk-go type. +func SyncVectorIndexRequestToSDK(w *SyncVectorIndexRequest) (*sdk.SyncVectorIndexRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SyncVectorIndexRequest{} + out.Name = w.Name + return out, nil +} + +// SyncVectorIndexRequestFromSDK converts the sdk-go type to the mirror. +func SyncVectorIndexRequestFromSDK(v *sdk.SyncVectorIndexRequest) (*SyncVectorIndexRequest, error) { + if v == nil { + return nil, nil + } + out := &SyncVectorIndexRequest{} + out.Name = v.Name + return out, nil +} + +// UpdateEndpointCustomTagsRequestToSDK converts the mirror to the sdk-go type. +func UpdateEndpointCustomTagsRequestToSDK(w *UpdateEndpointCustomTagsRequest) (*sdk.UpdateEndpointCustomTagsRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateEndpointCustomTagsRequest{} + out.Name = w.Name + conv67, err := convertSlice(w.CustomTags, CustomTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEndpointCustomTagsRequest.CustomTags", err) + } + out.CustomTags = conv67 + return out, nil +} + +// UpdateEndpointCustomTagsRequestFromSDK converts the sdk-go type to the mirror. +func UpdateEndpointCustomTagsRequestFromSDK(v *sdk.UpdateEndpointCustomTagsRequest) (*UpdateEndpointCustomTagsRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateEndpointCustomTagsRequest{} + out.Name = v.Name + conv68, err := convertSlice(v.CustomTags, CustomTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEndpointCustomTagsRequest.CustomTags", err) + } + out.CustomTags = conv68 + return out, nil +} + +// UpdateEndpointCustomTagsResponseToSDK converts the mirror to the sdk-go type. +func UpdateEndpointCustomTagsResponseToSDK(w *UpdateEndpointCustomTagsResponse) (*sdk.UpdateEndpointCustomTagsResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateEndpointCustomTagsResponse{} + out.Name = w.Name + conv69, err := convertSlice(w.CustomTags, CustomTagToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEndpointCustomTagsResponse.CustomTags", err) + } + out.CustomTags = conv69 + return out, nil +} + +// UpdateEndpointCustomTagsResponseFromSDK converts the sdk-go type to the mirror. +func UpdateEndpointCustomTagsResponseFromSDK(v *sdk.UpdateEndpointCustomTagsResponse) (*UpdateEndpointCustomTagsResponse, error) { + if v == nil { + return nil, nil + } + out := &UpdateEndpointCustomTagsResponse{} + out.Name = v.Name + conv70, err := convertSlice(v.CustomTags, CustomTagFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateEndpointCustomTagsResponse.CustomTags", err) + } + out.CustomTags = conv70 + return out, nil +} + +// UpsertDataVectorIndexRequestToSDK converts the mirror to the sdk-go type. +func UpsertDataVectorIndexRequestToSDK(w *UpsertDataVectorIndexRequest) (*sdk.UpsertDataVectorIndexRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpsertDataVectorIndexRequest{} + out.Name = w.Name + out.InputsJson = w.InputsJson + return out, nil +} + +// UpsertDataVectorIndexRequestFromSDK converts the sdk-go type to the mirror. +func UpsertDataVectorIndexRequestFromSDK(v *sdk.UpsertDataVectorIndexRequest) (*UpsertDataVectorIndexRequest, error) { + if v == nil { + return nil, nil + } + out := &UpsertDataVectorIndexRequest{} + out.Name = v.Name + out.InputsJson = v.InputsJson + return out, nil +} + +// UpsertDataVectorIndexResponseToSDK converts the mirror to the sdk-go type. +func UpsertDataVectorIndexResponseToSDK(w *UpsertDataVectorIndexResponse) (*sdk.UpsertDataVectorIndexResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpsertDataVectorIndexResponse{} + out.Status = w.Status + conv71, err := UpsertDeleteDataResultToSDK(w.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpsertDataVectorIndexResponse.Result", err) + } + out.Result = conv71 + return out, nil +} + +// UpsertDataVectorIndexResponseFromSDK converts the sdk-go type to the mirror. +func UpsertDataVectorIndexResponseFromSDK(v *sdk.UpsertDataVectorIndexResponse) (*UpsertDataVectorIndexResponse, error) { + if v == nil { + return nil, nil + } + out := &UpsertDataVectorIndexResponse{} + out.Status = v.Status + conv72, err := UpsertDeleteDataResultFromSDK(v.Result) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpsertDataVectorIndexResponse.Result", err) + } + out.Result = conv72 + return out, nil +} + +// UpsertDeleteDataResultToSDK converts the mirror to the sdk-go type. +func UpsertDeleteDataResultToSDK(w *UpsertDeleteDataResult) (*sdk.UpsertDeleteDataResult, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpsertDeleteDataResult{} + out.SuccessRowCount = w.SuccessRowCount + out.FailedPrimaryKeys = w.FailedPrimaryKeys + return out, nil +} + +// UpsertDeleteDataResultFromSDK converts the sdk-go type to the mirror. +func UpsertDeleteDataResultFromSDK(v *sdk.UpsertDeleteDataResult) (*UpsertDeleteDataResult, error) { + if v == nil { + return nil, nil + } + out := &UpsertDeleteDataResult{} + out.SuccessRowCount = v.SuccessRowCount + out.FailedPrimaryKeys = v.FailedPrimaryKeys + return out, nil +} + +// ValueToSDK converts the mirror to the sdk-go type. +func ValueToSDK(w *Value) (*sdk.Value, error) { + if w == nil { + return nil, nil + } + out := &sdk.Value{} + { + var members []string + if w.NumberValue != nil { + members = append(members, "number_value") + } + if w.StringValue != nil { + members = append(members, "string_value") + } + if w.BoolValue != nil { + members = append(members, "bool_value") + } + if w.StructValue != nil { + members = append(members, "struct_value") + } + if w.ListValue != nil { + members = append(members, "list_value") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NumberValue != nil: + out.Kind = &sdk.Value_Kind_NumberValue{NumberValue: *w.NumberValue} + case w.StringValue != nil: + out.Kind = &sdk.Value_Kind_StringValue{StringValue: *w.StringValue} + case w.BoolValue != nil: + out.Kind = &sdk.Value_Kind_BoolValue{BoolValue: *w.BoolValue} + case w.StructValue != nil: + conv73, err := StructToSDK(w.StructValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Value.Kind", err) + } + out.Kind = &sdk.Value_Kind_StructValue{StructValue: *conv73} + case w.ListValue != nil: + conv74, err := ListValueToSDK(w.ListValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Value.Kind", err) + } + out.Kind = &sdk.Value_Kind_ListValue{ListValue: *conv74} + } + return out, nil +} + +// ValueFromSDK converts the sdk-go type to the mirror. +func ValueFromSDK(v *sdk.Value) (*Value, error) { + if v == nil { + return nil, nil + } + out := &Value{} + switch value := v.Kind.(type) { + case *sdk.Value_Kind_NumberValue: + if value != nil { + out.NumberValue = new(value.NumberValue) + } + case *sdk.Value_Kind_StringValue: + if value != nil { + out.StringValue = new(value.StringValue) + } + case *sdk.Value_Kind_BoolValue: + if value != nil { + out.BoolValue = new(value.BoolValue) + } + case *sdk.Value_Kind_StructValue: + if value != nil { + conv75, err := StructFromSDK(&value.StructValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Value.Kind", err) + } + out.StructValue = conv75 + } + case *sdk.Value_Kind_ListValue: + if value != nil { + conv76, err := ListValueFromSDK(&value.ListValue) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Value.Kind", err) + } + out.ListValue = conv76 + } + } + return out, nil +} + +// VectorIndexToSDK converts the mirror to the sdk-go type. +func VectorIndexToSDK(w *VectorIndex) (*sdk.VectorIndex, error) { + if w == nil { + return nil, nil + } + out := &sdk.VectorIndex{} + out.Name = w.Name + out.EndpointName = w.EndpointName + out.PrimaryKey = w.PrimaryKey + out.IndexType = w.IndexType + { + var members []string + if w.DirectAccessIndexSpec != nil { + members = append(members, "direct_access_index_spec") + } + if w.DeltaSyncIndexSpec != nil { + members = append(members, "delta_sync_index_spec") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.DirectAccessIndexSpec != nil: + conv77, err := DirectAccessVectorIndexSpecToSDK(w.DirectAccessIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "VectorIndex.IndexSpec", err) + } + out.IndexSpec = &sdk.VectorIndex_IndexSpec_DirectAccessIndexSpec{DirectAccessIndexSpec: *conv77} + case w.DeltaSyncIndexSpec != nil: + conv78, err := DeltaSyncVectorIndexSpecToSDK(w.DeltaSyncIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "VectorIndex.IndexSpec", err) + } + out.IndexSpec = &sdk.VectorIndex_IndexSpec_DeltaSyncIndexSpec{DeltaSyncIndexSpec: *conv78} + } + conv79, err := VectorIndexStatusToSDK(w.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "VectorIndex.Status", err) + } + out.Status = conv79 + out.Creator = w.Creator + out.IndexSubtype = w.IndexSubtype + out.EndpointId = w.EndpointId + return out, nil +} + +// VectorIndexFromSDK converts the sdk-go type to the mirror. +func VectorIndexFromSDK(v *sdk.VectorIndex) (*VectorIndex, error) { + if v == nil { + return nil, nil + } + out := &VectorIndex{} + out.Name = v.Name + out.EndpointName = v.EndpointName + out.PrimaryKey = v.PrimaryKey + out.IndexType = v.IndexType + switch value := v.IndexSpec.(type) { + case *sdk.VectorIndex_IndexSpec_DirectAccessIndexSpec: + if value != nil { + conv80, err := DirectAccessVectorIndexSpecFromSDK(&value.DirectAccessIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "VectorIndex.IndexSpec", err) + } + out.DirectAccessIndexSpec = conv80 + } + case *sdk.VectorIndex_IndexSpec_DeltaSyncIndexSpec: + if value != nil { + conv81, err := DeltaSyncVectorIndexSpecFromSDK(&value.DeltaSyncIndexSpec) + if err != nil { + return nil, fmt.Errorf("%s: %w", "VectorIndex.IndexSpec", err) + } + out.DeltaSyncIndexSpec = conv81 + } + } + conv82, err := VectorIndexStatusFromSDK(v.Status) + if err != nil { + return nil, fmt.Errorf("%s: %w", "VectorIndex.Status", err) + } + out.Status = conv82 + out.Creator = v.Creator + out.IndexSubtype = v.IndexSubtype + out.EndpointId = v.EndpointId + return out, nil +} + +// VectorIndexStatusToSDK converts the mirror to the sdk-go type. +func VectorIndexStatusToSDK(w *VectorIndexStatus) (*sdk.VectorIndexStatus, error) { + if w == nil { + return nil, nil + } + out := &sdk.VectorIndexStatus{} + out.Message = w.Message + out.IndexedRowCount = w.IndexedRowCount + out.Ready = w.Ready + out.IndexUrl = w.IndexUrl + return out, nil +} + +// VectorIndexStatusFromSDK converts the sdk-go type to the mirror. +func VectorIndexStatusFromSDK(v *sdk.VectorIndexStatus) (*VectorIndexStatus, error) { + if v == nil { + return nil, nil + } + out := &VectorIndexStatus{} + out.Message = v.Message + out.IndexedRowCount = v.IndexedRowCount + out.Ready = v.Ready + out.IndexUrl = v.IndexUrl + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} diff --git a/libs/sdktypes/warehouses/v1/types.generated.go b/libs/sdktypes/warehouses/v1/types.generated.go new file mode 100644 index 00000000000..7bd093c8a6e --- /dev/null +++ b/libs/sdktypes/warehouses/v1/types.generated.go @@ -0,0 +1,1798 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/warehouses/v1. DO NOT EDIT. + +package warehouses + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/warehouses/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + ChannelName = sdk.ChannelName + DefaultWarehouseOverrideType = sdk.DefaultWarehouseOverrideType + EndpointSecurityPolicy = sdk.EndpointSecurityPolicy + EndpointSpotInstancePolicy = sdk.EndpointSpotInstancePolicy + EndpointState = sdk.EndpointState + TerminationCode = sdk.TerminationCode + TerminationType = sdk.TerminationType + WarehouseType = sdk.WarehouseType + EndpointHealth_Status = sdk.EndpointHealth_Status +) + +const ( + ChannelName_Unspecified = sdk.ChannelName_Unspecified + ChannelName_ChannelNamePreview = sdk.ChannelName_ChannelNamePreview + ChannelName_ChannelNameCurrent = sdk.ChannelName_ChannelNameCurrent + ChannelName_ChannelNamePrevious = sdk.ChannelName_ChannelNamePrevious + ChannelName_ChannelNameCustom = sdk.ChannelName_ChannelNameCustom + DefaultWarehouseOverrideType_Unspecified = sdk.DefaultWarehouseOverrideType_Unspecified + DefaultWarehouseOverrideType_LastSelected = sdk.DefaultWarehouseOverrideType_LastSelected + DefaultWarehouseOverrideType_Custom = sdk.DefaultWarehouseOverrideType_Custom + EndpointSecurityPolicy_Unspecified = sdk.EndpointSecurityPolicy_Unspecified + EndpointSecurityPolicy_None = sdk.EndpointSecurityPolicy_None + EndpointSecurityPolicy_DataAccessControl = sdk.EndpointSecurityPolicy_DataAccessControl + EndpointSecurityPolicy_Passthrough = sdk.EndpointSecurityPolicy_Passthrough + EndpointSpotInstancePolicy_Unspecified = sdk.EndpointSpotInstancePolicy_Unspecified + EndpointSpotInstancePolicy_CostOptimized = sdk.EndpointSpotInstancePolicy_CostOptimized + EndpointSpotInstancePolicy_ReliabilityOptimized = sdk.EndpointSpotInstancePolicy_ReliabilityOptimized + EndpointState_Unspecified = sdk.EndpointState_Unspecified + EndpointState_Starting = sdk.EndpointState_Starting + EndpointState_Running = sdk.EndpointState_Running + EndpointState_Stopping = sdk.EndpointState_Stopping + EndpointState_Stopped = sdk.EndpointState_Stopped + EndpointState_Deleting = sdk.EndpointState_Deleting + EndpointState_Deleted = sdk.EndpointState_Deleted + TerminationCode_Unspecified = sdk.TerminationCode_Unspecified + TerminationCode_UserRequest = sdk.TerminationCode_UserRequest + TerminationCode_JobFinished = sdk.TerminationCode_JobFinished + TerminationCode_Inactivity = sdk.TerminationCode_Inactivity + TerminationCode_CloudProviderShutdown = sdk.TerminationCode_CloudProviderShutdown + TerminationCode_CommunicationLost = sdk.TerminationCode_CommunicationLost + TerminationCode_CloudProviderLaunchFailure = sdk.TerminationCode_CloudProviderLaunchFailure + TerminationCode_InitScriptFailure = sdk.TerminationCode_InitScriptFailure + TerminationCode_SparkStartupFailure = sdk.TerminationCode_SparkStartupFailure + TerminationCode_InvalidArgument = sdk.TerminationCode_InvalidArgument + TerminationCode_UnexpectedLaunchFailure = sdk.TerminationCode_UnexpectedLaunchFailure + TerminationCode_InternalError = sdk.TerminationCode_InternalError + TerminationCode_InstanceUnreachable = sdk.TerminationCode_InstanceUnreachable + TerminationCode_RequestRejected = sdk.TerminationCode_RequestRejected + TerminationCode_TrialExpired = sdk.TerminationCode_TrialExpired + TerminationCode_DriverUnreachable = sdk.TerminationCode_DriverUnreachable + TerminationCode_SparkError = sdk.TerminationCode_SparkError + TerminationCode_DriverUnresponsive = sdk.TerminationCode_DriverUnresponsive + TerminationCode_MetastoreComponentUnhealthy = sdk.TerminationCode_MetastoreComponentUnhealthy + TerminationCode_DbfsComponentUnhealthy = sdk.TerminationCode_DbfsComponentUnhealthy + TerminationCode_ExecutionComponentUnhealthy = sdk.TerminationCode_ExecutionComponentUnhealthy + TerminationCode_AzureResourceManagerThrottling = sdk.TerminationCode_AzureResourceManagerThrottling + TerminationCode_AzureResourceProviderThrottling = sdk.TerminationCode_AzureResourceProviderThrottling + TerminationCode_NetworkConfigurationFailure = sdk.TerminationCode_NetworkConfigurationFailure + TerminationCode_ContainerLaunchFailure = sdk.TerminationCode_ContainerLaunchFailure + TerminationCode_InstancePoolClusterFailure = sdk.TerminationCode_InstancePoolClusterFailure + TerminationCode_SkippedSlowNodes = sdk.TerminationCode_SkippedSlowNodes + TerminationCode_AttachProjectFailure = sdk.TerminationCode_AttachProjectFailure + TerminationCode_UpdateInstanceProfileFailure = sdk.TerminationCode_UpdateInstanceProfileFailure + TerminationCode_DatabaseConnectionFailure = sdk.TerminationCode_DatabaseConnectionFailure + TerminationCode_RequestThrottled = sdk.TerminationCode_RequestThrottled + TerminationCode_SelfBootstrapFailure = sdk.TerminationCode_SelfBootstrapFailure + TerminationCode_GlobalInitScriptFailure = sdk.TerminationCode_GlobalInitScriptFailure + TerminationCode_SlowImageDownload = sdk.TerminationCode_SlowImageDownload + TerminationCode_InvalidSparkImage = sdk.TerminationCode_InvalidSparkImage + TerminationCode_NpipTunnelTokenFailure = sdk.TerminationCode_NpipTunnelTokenFailure + TerminationCode_HiveMetastoreProvisioningFailure = sdk.TerminationCode_HiveMetastoreProvisioningFailure + TerminationCode_AzureInvalidDeploymentTemplate = sdk.TerminationCode_AzureInvalidDeploymentTemplate + TerminationCode_AzureUnexpectedDeploymentTemplateFailure = sdk.TerminationCode_AzureUnexpectedDeploymentTemplateFailure + TerminationCode_SubnetExhaustedFailure = sdk.TerminationCode_SubnetExhaustedFailure + TerminationCode_BootstrapTimeout = sdk.TerminationCode_BootstrapTimeout + TerminationCode_StorageDownloadFailure = sdk.TerminationCode_StorageDownloadFailure + TerminationCode_ControlPlaneRequestFailure = sdk.TerminationCode_ControlPlaneRequestFailure + TerminationCode_BootstrapTimeoutCloudProviderException = sdk.TerminationCode_BootstrapTimeoutCloudProviderException + TerminationCode_AwsInsufficientInstanceCapacityFailure = sdk.TerminationCode_AwsInsufficientInstanceCapacityFailure + TerminationCode_DockerImagePullFailure = sdk.TerminationCode_DockerImagePullFailure + TerminationCode_AzureVnetConfigurationFailure = sdk.TerminationCode_AzureVnetConfigurationFailure + TerminationCode_NpipTunnelSetupFailure = sdk.TerminationCode_NpipTunnelSetupFailure + TerminationCode_AwsAuthorizationFailure = sdk.TerminationCode_AwsAuthorizationFailure + TerminationCode_NephosResourceManagement = sdk.TerminationCode_NephosResourceManagement + TerminationCode_StsClientSetupFailure = sdk.TerminationCode_StsClientSetupFailure + TerminationCode_SecurityDaemonRegistrationException = sdk.TerminationCode_SecurityDaemonRegistrationException + TerminationCode_AwsRequestLimitExceeded = sdk.TerminationCode_AwsRequestLimitExceeded + TerminationCode_AwsInsufficientFreeAddressesInSubnetFailure = sdk.TerminationCode_AwsInsufficientFreeAddressesInSubnetFailure + TerminationCode_AwsUnsupportedFailure = sdk.TerminationCode_AwsUnsupportedFailure + TerminationCode_AzureQuotaExceededException = sdk.TerminationCode_AzureQuotaExceededException + TerminationCode_AzureOperationNotAllowedException = sdk.TerminationCode_AzureOperationNotAllowedException + TerminationCode_NfsMountFailure = sdk.TerminationCode_NfsMountFailure + TerminationCode_K8sAutoscalingFailure = sdk.TerminationCode_K8sAutoscalingFailure + TerminationCode_K8sDbrClusterLaunchTimeout = sdk.TerminationCode_K8sDbrClusterLaunchTimeout + TerminationCode_SparkImageDownloadFailure = sdk.TerminationCode_SparkImageDownloadFailure + TerminationCode_AzureVmExtensionFailure = sdk.TerminationCode_AzureVmExtensionFailure + TerminationCode_WorkspaceCancelledError = sdk.TerminationCode_WorkspaceCancelledError + TerminationCode_AwsMaxSpotInstanceCountExceededFailure = sdk.TerminationCode_AwsMaxSpotInstanceCountExceededFailure + TerminationCode_TemporarilyUnavailable = sdk.TerminationCode_TemporarilyUnavailable + TerminationCode_WorkerSetupFailure = sdk.TerminationCode_WorkerSetupFailure + TerminationCode_IpExhaustionFailure = sdk.TerminationCode_IpExhaustionFailure + TerminationCode_GcpQuotaExceeded = sdk.TerminationCode_GcpQuotaExceeded + TerminationCode_CloudProviderResourceStockout = sdk.TerminationCode_CloudProviderResourceStockout + TerminationCode_GcpServiceAccountDeleted = sdk.TerminationCode_GcpServiceAccountDeleted + TerminationCode_AzureByokKeyPermissionFailure = sdk.TerminationCode_AzureByokKeyPermissionFailure + TerminationCode_SpotInstanceTermination = sdk.TerminationCode_SpotInstanceTermination + TerminationCode_AzureEphemeralDiskFailure = sdk.TerminationCode_AzureEphemeralDiskFailure + TerminationCode_AbuseDetected = sdk.TerminationCode_AbuseDetected + TerminationCode_ImagePullPermissionDenied = sdk.TerminationCode_ImagePullPermissionDenied + TerminationCode_WorkspaceConfigurationError = sdk.TerminationCode_WorkspaceConfigurationError + TerminationCode_SecretResolutionError = sdk.TerminationCode_SecretResolutionError + TerminationCode_UnsupportedInstanceType = sdk.TerminationCode_UnsupportedInstanceType + TerminationCode_CloudProviderDiskSetupFailure = sdk.TerminationCode_CloudProviderDiskSetupFailure + TerminationCode_SshBootstrapFailure = sdk.TerminationCode_SshBootstrapFailure + TerminationCode_AwsInaccessibleKmsKeyFailure = sdk.TerminationCode_AwsInaccessibleKmsKeyFailure + TerminationCode_InitContainerNotFinished = sdk.TerminationCode_InitContainerNotFinished + TerminationCode_SparkImageDownloadThrottled = sdk.TerminationCode_SparkImageDownloadThrottled + TerminationCode_SparkImageNotFound = sdk.TerminationCode_SparkImageNotFound + TerminationCode_ClusterOperationThrottled = sdk.TerminationCode_ClusterOperationThrottled + TerminationCode_ClusterOperationTimeout = sdk.TerminationCode_ClusterOperationTimeout + TerminationCode_ServerlessLongRunningTerminated = sdk.TerminationCode_ServerlessLongRunningTerminated + TerminationCode_AzurePackedDeploymentPartialFailure = sdk.TerminationCode_AzurePackedDeploymentPartialFailure + TerminationCode_InvalidWorkerImageFailure = sdk.TerminationCode_InvalidWorkerImageFailure + TerminationCode_WorkspaceUpdate = sdk.TerminationCode_WorkspaceUpdate + TerminationCode_InvalidAwsParameter = sdk.TerminationCode_InvalidAwsParameter + TerminationCode_DriverOutOfDisk = sdk.TerminationCode_DriverOutOfDisk + TerminationCode_DriverOutOfMemory = sdk.TerminationCode_DriverOutOfMemory + TerminationCode_DriverLaunchTimeout = sdk.TerminationCode_DriverLaunchTimeout + TerminationCode_DriverUnexpectedFailure = sdk.TerminationCode_DriverUnexpectedFailure + TerminationCode_UnexpectedPodRecreation = sdk.TerminationCode_UnexpectedPodRecreation + TerminationCode_GcpInaccessibleKmsKeyFailure = sdk.TerminationCode_GcpInaccessibleKmsKeyFailure + TerminationCode_GcpKmsKeyPermissionDenied = sdk.TerminationCode_GcpKmsKeyPermissionDenied + TerminationCode_DriverEviction = sdk.TerminationCode_DriverEviction + TerminationCode_UserInitiatedVmTermination = sdk.TerminationCode_UserInitiatedVmTermination + TerminationCode_GcpIamTimeout = sdk.TerminationCode_GcpIamTimeout + TerminationCode_AwsResourceQuotaExceeded = sdk.TerminationCode_AwsResourceQuotaExceeded + TerminationCode_CloudAccountSetupFailure = sdk.TerminationCode_CloudAccountSetupFailure + TerminationCode_AwsInvalidKeyPair = sdk.TerminationCode_AwsInvalidKeyPair + TerminationCode_DriverPodCreationFailure = sdk.TerminationCode_DriverPodCreationFailure + TerminationCode_MaintenanceMode = sdk.TerminationCode_MaintenanceMode + TerminationCode_InternalCapacityFailure = sdk.TerminationCode_InternalCapacityFailure + TerminationCode_ExecutorPodUnscheduled = sdk.TerminationCode_ExecutorPodUnscheduled + TerminationCode_StorageDownloadFailureSlow = sdk.TerminationCode_StorageDownloadFailureSlow + TerminationCode_StorageDownloadFailureThrottled = sdk.TerminationCode_StorageDownloadFailureThrottled + TerminationCode_DynamicSparkConfSizeExceeded = sdk.TerminationCode_DynamicSparkConfSizeExceeded + TerminationCode_AwsInstanceProfileUpdateFailure = sdk.TerminationCode_AwsInstanceProfileUpdateFailure + TerminationCode_InstancePoolNotFound = sdk.TerminationCode_InstancePoolNotFound + TerminationCode_InstancePoolMaxCapacityReached = sdk.TerminationCode_InstancePoolMaxCapacityReached + TerminationCode_AwsInvalidKmsKeyState = sdk.TerminationCode_AwsInvalidKmsKeyState + TerminationCode_GcpInsufficientCapacity = sdk.TerminationCode_GcpInsufficientCapacity + TerminationCode_GcpApiRateQuotaExceeded = sdk.TerminationCode_GcpApiRateQuotaExceeded + TerminationCode_GcpResourceQuotaExceeded = sdk.TerminationCode_GcpResourceQuotaExceeded + TerminationCode_GcpIpSpaceExhausted = sdk.TerminationCode_GcpIpSpaceExhausted + TerminationCode_GcpServiceAccountAccessDenied = sdk.TerminationCode_GcpServiceAccountAccessDenied + TerminationCode_GcpServiceAccountNotFound = sdk.TerminationCode_GcpServiceAccountNotFound + TerminationCode_GcpForbidden = sdk.TerminationCode_GcpForbidden + TerminationCode_GcpNotFound = sdk.TerminationCode_GcpNotFound + TerminationCode_ResourceUsageBlocked = sdk.TerminationCode_ResourceUsageBlocked + TerminationCode_DataAccessConfigChanged = sdk.TerminationCode_DataAccessConfigChanged + TerminationCode_AccessTokenFailure = sdk.TerminationCode_AccessTokenFailure + TerminationCode_InvalidInstancePlacementProtocol = sdk.TerminationCode_InvalidInstancePlacementProtocol + TerminationCode_BudgetPolicyResolutionFailure = sdk.TerminationCode_BudgetPolicyResolutionFailure + TerminationCode_InPenaltyBox = sdk.TerminationCode_InPenaltyBox + TerminationCode_DisasterRecoveryReplication = sdk.TerminationCode_DisasterRecoveryReplication + TerminationCode_BootstrapTimeoutDueToMisconfig = sdk.TerminationCode_BootstrapTimeoutDueToMisconfig + TerminationCode_InstanceUnreachableDueToMisconfig = sdk.TerminationCode_InstanceUnreachableDueToMisconfig + TerminationCode_StorageDownloadFailureDueToMisconfig = sdk.TerminationCode_StorageDownloadFailureDueToMisconfig + TerminationCode_ControlPlaneRequestFailureDueToMisconfig = sdk.TerminationCode_ControlPlaneRequestFailureDueToMisconfig + TerminationCode_CloudProviderLaunchFailureDueToMisconfig = sdk.TerminationCode_CloudProviderLaunchFailureDueToMisconfig + TerminationCode_GcpSubnetNotReady = sdk.TerminationCode_GcpSubnetNotReady + TerminationCode_CloudOperationCancelled = sdk.TerminationCode_CloudOperationCancelled + TerminationCode_CloudProviderInstanceNotLaunched = sdk.TerminationCode_CloudProviderInstanceNotLaunched + TerminationCode_GcpTrustedImageProjectsViolated = sdk.TerminationCode_GcpTrustedImageProjectsViolated + TerminationCode_BudgetPolicyLimitEnforcementActivated = sdk.TerminationCode_BudgetPolicyLimitEnforcementActivated + TerminationCode_EosSparkImage = sdk.TerminationCode_EosSparkImage + TerminationCode_NoMatchedK8s = sdk.TerminationCode_NoMatchedK8s + TerminationCode_LazyAllocationTimeout = sdk.TerminationCode_LazyAllocationTimeout + TerminationCode_DriverNodeUnreachable = sdk.TerminationCode_DriverNodeUnreachable + TerminationCode_SecretCreationFailure = sdk.TerminationCode_SecretCreationFailure + TerminationCode_PodSchedulingFailure = sdk.TerminationCode_PodSchedulingFailure + TerminationCode_PodAssignmentFailure = sdk.TerminationCode_PodAssignmentFailure + TerminationCode_AllocationTimeout = sdk.TerminationCode_AllocationTimeout + TerminationCode_AllocationTimeoutNoUnallocatedClusters = sdk.TerminationCode_AllocationTimeoutNoUnallocatedClusters + TerminationCode_AllocationTimeoutNoMatchedClusters = sdk.TerminationCode_AllocationTimeoutNoMatchedClusters + TerminationCode_AllocationTimeoutNoReadyClusters = sdk.TerminationCode_AllocationTimeoutNoReadyClusters + TerminationCode_AllocationTimeoutNoWarmedUpClusters = sdk.TerminationCode_AllocationTimeoutNoWarmedUpClusters + TerminationCode_AllocationTimeoutNodeDaemonNotReady = sdk.TerminationCode_AllocationTimeoutNodeDaemonNotReady + TerminationCode_AllocationTimeoutNoHealthyClusters = sdk.TerminationCode_AllocationTimeoutNoHealthyClusters + TerminationCode_NetvisorSetupTimeout = sdk.TerminationCode_NetvisorSetupTimeout + TerminationCode_NoMatchedK8sTestingTag = sdk.TerminationCode_NoMatchedK8sTestingTag + TerminationCode_CloudProviderResourceStockoutDueToMisconfig = sdk.TerminationCode_CloudProviderResourceStockoutDueToMisconfig + TerminationCode_GkeBasedClusterTermination = sdk.TerminationCode_GkeBasedClusterTermination + TerminationCode_AllocationTimeoutNoHealthyAndWarmedUpClusters = sdk.TerminationCode_AllocationTimeoutNoHealthyAndWarmedUpClusters + TerminationCode_DockerInvalidOsException = sdk.TerminationCode_DockerInvalidOsException + TerminationCode_DockerContainerCreationException = sdk.TerminationCode_DockerContainerCreationException + TerminationCode_DockerImageTooLargeForInstanceException = sdk.TerminationCode_DockerImageTooLargeForInstanceException + TerminationCode_DnsResolutionError = sdk.TerminationCode_DnsResolutionError + TerminationCode_GcpDeniedByOrgPolicy = sdk.TerminationCode_GcpDeniedByOrgPolicy + TerminationCode_SecretPermissionDenied = sdk.TerminationCode_SecretPermissionDenied + TerminationCode_NetworkCheckNicFailure = sdk.TerminationCode_NetworkCheckNicFailure + TerminationCode_NetworkCheckDnsServerFailure = sdk.TerminationCode_NetworkCheckDnsServerFailure + TerminationCode_NetworkCheckStorageFailure = sdk.TerminationCode_NetworkCheckStorageFailure + TerminationCode_NetworkCheckMetadataEndpointFailure = sdk.TerminationCode_NetworkCheckMetadataEndpointFailure + TerminationCode_NetworkCheckControlPlaneFailure = sdk.TerminationCode_NetworkCheckControlPlaneFailure + TerminationCode_NetworkCheckMultipleComponentsFailure = sdk.TerminationCode_NetworkCheckMultipleComponentsFailure + TerminationCode_DriverUnhealthy = sdk.TerminationCode_DriverUnhealthy + TerminationCode_UsagePolicyEntitlementDenied = sdk.TerminationCode_UsagePolicyEntitlementDenied + TerminationCode_K8sActivePodQuotaExceeded = sdk.TerminationCode_K8sActivePodQuotaExceeded + TerminationCode_CloudAccountPodQuotaExceeded = sdk.TerminationCode_CloudAccountPodQuotaExceeded + TerminationCode_NetworkCheckNicFailureDueToMisconfig = sdk.TerminationCode_NetworkCheckNicFailureDueToMisconfig + TerminationCode_NetworkCheckDnsServerFailureDueToMisconfig = sdk.TerminationCode_NetworkCheckDnsServerFailureDueToMisconfig + TerminationCode_NetworkCheckStorageFailureDueToMisconfig = sdk.TerminationCode_NetworkCheckStorageFailureDueToMisconfig + TerminationCode_NetworkCheckMetadataEndpointFailureDueToMisconfig = sdk.TerminationCode_NetworkCheckMetadataEndpointFailureDueToMisconfig + TerminationCode_NetworkCheckControlPlaneFailureDueToMisconfig = sdk.TerminationCode_NetworkCheckControlPlaneFailureDueToMisconfig + TerminationCode_NetworkCheckMultipleComponentsFailureDueToMisconfig = sdk.TerminationCode_NetworkCheckMultipleComponentsFailureDueToMisconfig + TerminationCode_DbrImageResolutionFailure = sdk.TerminationCode_DbrImageResolutionFailure + TerminationCode_ControlPlaneConnectionFailure = sdk.TerminationCode_ControlPlaneConnectionFailure + TerminationCode_ControlPlaneConnectionFailureDueToMisconfig = sdk.TerminationCode_ControlPlaneConnectionFailureDueToMisconfig + TerminationCode_RateLimited = sdk.TerminationCode_RateLimited + TerminationCode_MtlsPortConnectivityFailure = sdk.TerminationCode_MtlsPortConnectivityFailure + TerminationCode_HivemetastoreConnectivityFailure = sdk.TerminationCode_HivemetastoreConnectivityFailure + TerminationType_Unspecified = sdk.TerminationType_Unspecified + TerminationType_Success = sdk.TerminationType_Success + TerminationType_ClientError = sdk.TerminationType_ClientError + TerminationType_ServiceFault = sdk.TerminationType_ServiceFault + TerminationType_CloudFailure = sdk.TerminationType_CloudFailure + WarehouseType_Unspecified = sdk.WarehouseType_Unspecified + WarehouseType_Classic = sdk.WarehouseType_Classic + WarehouseType_Pro = sdk.WarehouseType_Pro + WarehouseType_Realtime = sdk.WarehouseType_Realtime + EndpointHealth_Status_Unspecified = sdk.EndpointHealth_Status_Unspecified + EndpointHealth_Status_Healthy = sdk.EndpointHealth_Status_Healthy + EndpointHealth_Status_Degraded = sdk.EndpointHealth_Status_Degraded + EndpointHealth_Status_Failed = sdk.EndpointHealth_Status_Failed +) + +// Configures the channel name and DBSQL version of the warehouse. +// CHANNEL_NAME_CUSTOM should be chosen only when `dbsql_version` is specified.. +type Channel struct { + DbsqlVersion *string `json:"dbsql_version,omitempty"` + Name ChannelName `json:"name,omitempty"` +} + +// Request message for CreateDefaultWarehouseOverride.. +type CreateDefaultWarehouseOverrideRequest struct { + // Required. The default warehouse override to create. + DefaultWarehouseOverride *DefaultWarehouseOverride `json:"default_warehouse_override,omitempty"` + // Required. The ID to use for the override, which will become the final + // component of the override's resource name. Can be a numeric user ID or the + // literal string "me" for the current user. + DefaultWarehouseOverrideId *string `json:"default_warehouse_override_id,omitempty"` +} + +// Creates a new SQL warehouse.. +type CreateWarehouseRequest struct { + // The amount of time in minutes that a SQL warehouse must be idle (i.e., no + // RUNNING queries) before it is automatically stopped. + // + // Supported values: - Must be == 0 or >= 10 mins - 0 indicates no autostop. + // + // Defaults to 120 mins + AutoStopMins *int `json:"auto_stop_mins,omitempty"` + // Channel Details + Channel *Channel `json:"channel,omitempty"` + // Size of the clusters allocated for this warehouse. Increasing the size of a + // spark cluster allows you to run larger queries on it. If you want to increase + // the number of concurrent queries, please tune max_num_clusters. + // + // Supported values: - 2X-Small - X-Small - Small - Medium - Large - X-Large - + // 2X-Large - 3X-Large - 4X-Large - 5X-Large + ClusterSize *string `json:"cluster_size,omitempty"` + // warehouse creator name + CreatorName *string `json:"creator_name,omitempty"` + // Configures whether the warehouse should use Photon optimized clusters. + // + // Defaults to true. + EnablePhoton *bool `json:"enable_photon,omitempty"` + // Configures whether the warehouse should use serverless compute + EnableServerlessCompute *bool `json:"enable_serverless_compute,omitempty"` + // Deprecated. Instance profile used to pass IAM role to the cluster + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // Maximum number of clusters that the autoscaler will create to handle + // concurrent queries. + // + // Supported values: - Must be >= min_num_clusters - Must be <= 40. + // + // Defaults to min_clusters if unset. + MaxNumClusters *int `json:"max_num_clusters,omitempty"` + // Minimum number of available clusters that will be maintained for this SQL + // warehouse. Increasing this will ensure that a larger number of clusters are + // always running and therefore may reduce the cold start time for new queries. + // This is similar to reserved vs. revocable cores in a resource manager. + // + // Supported values: - Must be > 0 - Must be <= min(max_num_clusters, 30) + // + // Defaults to 1 + MinNumClusters *int `json:"min_num_clusters,omitempty"` + // Logical name for the cluster. + // + // Supported values: - Must be unique within an org. - Must be less than 100 + // characters. + Name *string `json:"name,omitempty"` + // Configurations whether the endpoint should use spot instances. + SpotInstancePolicy EndpointSpotInstancePolicy `json:"spot_instance_policy,omitempty"` + // Warehouse statement timeout in seconds. + StatementTimeout *int `json:"statement_timeout,omitempty"` + // A set of key-value pairs that will be tagged on all resources (e.g., AWS + // instances and EBS volumes) associated with this SQL warehouse. + // + // Supported values: - Number of tags < 45. + Tags *EndpointTags `json:"tags,omitempty"` + // 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`. + WarehouseType WarehouseType `json:"warehouse_type,omitempty"` +} + +type CreateWarehouseResponse struct { + // Id for the SQL warehouse. This value is unique across all SQL warehouses. + Id *string `json:"id,omitempty"` +} + +// Represents a per-user default warehouse override configuration. This resource +// allows users or administrators to customize how a user's default warehouse is +// selected for SQL operations. If no override exists for a user, the workspace +// default warehouse will be used.. +type DefaultWarehouseOverride struct { + // The ID component of the resource name (user ID). + DefaultWarehouseOverrideId *string `json:"default_warehouse_override_id,omitempty"` + // The resource name of the default warehouse override. Format: + // default-warehouse-overrides/{default_warehouse_override_id} + Name *string `json:"name,omitempty"` + // The type of override behavior. + Type DefaultWarehouseOverrideType `json:"type,omitempty"` + // The specific warehouse ID when type is CUSTOM. Not set for LAST_SELECTED + // type. + WarehouseId *string `json:"warehouse_id,omitempty"` +} + +// This is an incremental edit functionality, so all fields except id are +// optional. If a field is set, the corresponding configuration in the SQL +// warehouse is modified. If a field is unset, the existing configuration value +// in the SQL warehouse is retained. Thus, this API is not idempotent.. +type EditWarehouseRequest struct { + // The amount of time in minutes that a SQL warehouse must be idle (i.e., no + // RUNNING queries) before it is automatically stopped. + // + // Supported values: - Must be == 0 or >= 10 mins - 0 indicates no autostop. + // + // Defaults to 120 mins + AutoStopMins *int `json:"auto_stop_mins,omitempty"` + // Channel Details + Channel *Channel `json:"channel,omitempty"` + // Size of the clusters allocated for this warehouse. Increasing the size of a + // spark cluster allows you to run larger queries on it. If you want to increase + // the number of concurrent queries, please tune max_num_clusters. + // + // Supported values: - 2X-Small - X-Small - Small - Medium - Large - X-Large - + // 2X-Large - 3X-Large - 4X-Large - 5X-Large + ClusterSize *string `json:"cluster_size,omitempty"` + // warehouse creator name + CreatorName *string `json:"creator_name,omitempty"` + // Configures whether the warehouse should use Photon optimized clusters. + // + // Defaults to true. + EnablePhoton *bool `json:"enable_photon,omitempty"` + // Configures whether the warehouse should use serverless compute + EnableServerlessCompute *bool `json:"enable_serverless_compute,omitempty"` + // Required. Id of the warehouse to configure. + Id *string `json:"id,omitempty"` + // Deprecated. Instance profile used to pass IAM role to the cluster + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // Maximum number of clusters that the autoscaler will create to handle + // concurrent queries. + // + // Supported values: - Must be >= min_num_clusters - Must be <= 40. + // + // Defaults to min_clusters if unset. + MaxNumClusters *int `json:"max_num_clusters,omitempty"` + // Minimum number of available clusters that will be maintained for this SQL + // warehouse. Increasing this will ensure that a larger number of clusters are + // always running and therefore may reduce the cold start time for new queries. + // This is similar to reserved vs. revocable cores in a resource manager. + // + // Supported values: - Must be > 0 - Must be <= min(max_num_clusters, 30) + // + // Defaults to 1 + MinNumClusters *int `json:"min_num_clusters,omitempty"` + // Logical name for the cluster. + // + // Supported values: - Must be unique within an org. - Must be less than 100 + // characters. + Name *string `json:"name,omitempty"` + // Configurations whether the endpoint should use spot instances. + SpotInstancePolicy EndpointSpotInstancePolicy `json:"spot_instance_policy,omitempty"` + // Warehouse statement timeout in seconds. + StatementTimeout *int `json:"statement_timeout,omitempty"` + // A set of key-value pairs that will be tagged on all resources (e.g., AWS + // instances and EBS volumes) associated with this SQL warehouse. + // + // Supported values: - Number of tags < 45. + Tags *EndpointTags `json:"tags,omitempty"` + // 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`. + WarehouseType WarehouseType `json:"warehouse_type,omitempty"` +} + +type EndpointConfPair struct { + Key *string `json:"key,omitempty"` + Value *string `json:"value,omitempty"` +} + +type EndpointHealth struct { + // Details about errors that are causing current degraded/failed status. + Details *string `json:"details,omitempty"` + // The reason for failure to bring up clusters for this warehouse. This is + // available when status is 'FAILED' and sometimes when it is DEGRADED. + FailureReason *TerminationReason `json:"failure_reason,omitempty"` + // Deprecated. split into summary and details for security + Message *string `json:"message,omitempty"` + // Health status of the endpoint. + Status EndpointHealth_Status `json:"status,omitempty"` + // A short summary of the health status in case of degraded/failed warehouses. + Summary *string `json:"summary,omitempty"` +} + +type EndpointInfo struct { + // The amount of time in minutes that a SQL warehouse must be idle (i.e., no + // RUNNING queries) before it is automatically stopped. + // + // Supported values: - Must be == 0 or >= 10 mins - 0 indicates no autostop. + // + // Defaults to 120 mins + AutoStopMins *int `json:"auto_stop_mins,omitempty"` + // Channel Details + Channel *Channel `json:"channel,omitempty"` + // Size of the clusters allocated for this warehouse. Increasing the size of a + // spark cluster allows you to run larger queries on it. If you want to increase + // the number of concurrent queries, please tune max_num_clusters. + // + // Supported values: - 2X-Small - X-Small - Small - Medium - Large - X-Large - + // 2X-Large - 3X-Large - 4X-Large - 5X-Large + ClusterSize *string `json:"cluster_size,omitempty"` + // warehouse creator name + CreatorName *string `json:"creator_name,omitempty"` + // Configures whether the warehouse should use Photon optimized clusters. + // + // Defaults to true. + EnablePhoton *bool `json:"enable_photon,omitempty"` + // Configures whether the warehouse should use serverless compute + EnableServerlessCompute *bool `json:"enable_serverless_compute,omitempty"` + // Optional health status. Assume the warehouse is healthy if this field is not + // set. + Health *EndpointHealth `json:"health,omitempty"` + // unique identifier for warehouse + Id *string `json:"id,omitempty"` + // Deprecated. Instance profile used to pass IAM role to the cluster + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // the jdbc connection string for this warehouse + JdbcUrl *string `json:"jdbc_url,omitempty"` + // Maximum number of clusters that the autoscaler will create to handle + // concurrent queries. + // + // Supported values: - Must be >= min_num_clusters - Must be <= 40. + // + // Defaults to min_clusters if unset. + MaxNumClusters *int `json:"max_num_clusters,omitempty"` + // Minimum number of available clusters that will be maintained for this SQL + // warehouse. Increasing this will ensure that a larger number of clusters are + // always running and therefore may reduce the cold start time for new queries. + // This is similar to reserved vs. revocable cores in a resource manager. + // + // Supported values: - Must be > 0 - Must be <= min(max_num_clusters, 30) + // + // Defaults to 1 + MinNumClusters *int `json:"min_num_clusters,omitempty"` + // Logical name for the cluster. + // + // Supported values: - Must be unique within an org. - Must be less than 100 + // characters. + Name *string `json:"name,omitempty"` + // Deprecated. current number of active sessions for the warehouse + NumActiveSessions *int64 `json:"num_active_sessions,omitempty"` + // current number of clusters running for the service + NumClusters *int `json:"num_clusters,omitempty"` + // ODBC parameters for the SQL warehouse + OdbcParams *OdbcParams `json:"odbc_params,omitempty"` + // Configurations whether the endpoint should use spot instances. + SpotInstancePolicy EndpointSpotInstancePolicy `json:"spot_instance_policy,omitempty"` + // state of the endpoint + State EndpointState `json:"state,omitempty"` + // Warehouse statement timeout in seconds. + StatementTimeout *int `json:"statement_timeout,omitempty"` + // A set of key-value pairs that will be tagged on all resources (e.g., AWS + // instances and EBS volumes) associated with this SQL warehouse. + // + // Supported values: - Number of tags < 45. + Tags *EndpointTags `json:"tags,omitempty"` + // 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`. + WarehouseType WarehouseType `json:"warehouse_type,omitempty"` +} + +type EndpointTagPair struct { + Key *string `json:"key,omitempty"` + Value *string `json:"value,omitempty"` +} + +type EndpointTags struct { + CustomTags []EndpointTagPair `json:"custom_tags,omitempty"` +} + +type GetWarehouseResponse struct { + // The amount of time in minutes that a SQL warehouse must be idle (i.e., no + // RUNNING queries) before it is automatically stopped. + // + // Supported values: - Must be == 0 or >= 10 mins - 0 indicates no autostop. + // + // Defaults to 120 mins + AutoStopMins *int `json:"auto_stop_mins,omitempty"` + // Channel Details + Channel *Channel `json:"channel,omitempty"` + // Size of the clusters allocated for this warehouse. Increasing the size of a + // spark cluster allows you to run larger queries on it. If you want to increase + // the number of concurrent queries, please tune max_num_clusters. + // + // Supported values: - 2X-Small - X-Small - Small - Medium - Large - X-Large - + // 2X-Large - 3X-Large - 4X-Large - 5X-Large + ClusterSize *string `json:"cluster_size,omitempty"` + // warehouse creator name + CreatorName *string `json:"creator_name,omitempty"` + // Configures whether the warehouse should use Photon optimized clusters. + // + // Defaults to true. + EnablePhoton *bool `json:"enable_photon,omitempty"` + // Configures whether the warehouse should use serverless compute + EnableServerlessCompute *bool `json:"enable_serverless_compute,omitempty"` + // Optional health status. Assume the warehouse is healthy if this field is not + // set. + Health *EndpointHealth `json:"health,omitempty"` + // unique identifier for warehouse + Id *string `json:"id,omitempty"` + // Deprecated. Instance profile used to pass IAM role to the cluster + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // the jdbc connection string for this warehouse + JdbcUrl *string `json:"jdbc_url,omitempty"` + // Maximum number of clusters that the autoscaler will create to handle + // concurrent queries. + // + // Supported values: - Must be >= min_num_clusters - Must be <= 40. + // + // Defaults to min_clusters if unset. + MaxNumClusters *int `json:"max_num_clusters,omitempty"` + // Minimum number of available clusters that will be maintained for this SQL + // warehouse. Increasing this will ensure that a larger number of clusters are + // always running and therefore may reduce the cold start time for new queries. + // This is similar to reserved vs. revocable cores in a resource manager. + // + // Supported values: - Must be > 0 - Must be <= min(max_num_clusters, 30) + // + // Defaults to 1 + MinNumClusters *int `json:"min_num_clusters,omitempty"` + // Logical name for the cluster. + // + // Supported values: - Must be unique within an org. - Must be less than 100 + // characters. + Name *string `json:"name,omitempty"` + // Deprecated. current number of active sessions for the warehouse + NumActiveSessions *int64 `json:"num_active_sessions,omitempty"` + // current number of clusters running for the service + NumClusters *int `json:"num_clusters,omitempty"` + // ODBC parameters for the SQL warehouse + OdbcParams *OdbcParams `json:"odbc_params,omitempty"` + // Configurations whether the endpoint should use spot instances. + SpotInstancePolicy EndpointSpotInstancePolicy `json:"spot_instance_policy,omitempty"` + // state of the endpoint + State EndpointState `json:"state,omitempty"` + // Warehouse statement timeout in seconds. + StatementTimeout *int `json:"statement_timeout,omitempty"` + // A set of key-value pairs that will be tagged on all resources (e.g., AWS + // instances and EBS volumes) associated with this SQL warehouse. + // + // Supported values: - Number of tags < 45. + Tags *EndpointTags `json:"tags,omitempty"` + // 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`. + WarehouseType WarehouseType `json:"warehouse_type,omitempty"` +} + +type GetWorkspaceWarehouseConfigResponse struct { + // Optional: Channel selection details + Channel *Channel `json:"channel,omitempty"` + // Deprecated: Use sql_configuration_parameters + ConfigParam *RepeatedEndpointConfPairs `json:"config_param,omitempty"` + // Spark confs for external hive metastore configuration JSON serialized size + // must be less than <= 512K + DataAccessConfig []EndpointConfPair `json:"data_access_config,omitempty"` + // Deprecated: only setting this to true is allowed. + EnableServerlessCompute *bool `json:"enable_serverless_compute,omitempty"` + // List of Warehouse Types allowed in this workspace (limits allowed value of + // the type field in CreateWarehouse and EditWarehouse). Note: Some types cannot + // be disabled, they don't need to be specified in SetWorkspaceWarehouseConfig. + // Note: Disabling a type may cause existing warehouses to be converted to + // another type. Used by frontend to save specific type availability in the + // warehouse create and edit form UI. + EnabledWarehouseTypes []WarehouseTypePair `json:"enabled_warehouse_types,omitempty"` + // Deprecated: Use sql_configuration_parameters + GlobalParam *RepeatedEndpointConfPairs `json:"global_param,omitempty"` + // GCP only: Google Service Account used to pass to cluster to access Google + // Cloud Storage + GoogleServiceAccount *string `json:"google_service_account,omitempty"` + // AWS Only: The instance profile used to pass an IAM role to the SQL + // warehouses. This configuration is also applied to the workspace's serverless + // compute for notebooks and jobs. + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // Security policy for warehouses + SecurityPolicy EndpointSecurityPolicy `json:"security_policy,omitempty"` + // SQL configuration parameters + SqlConfigurationParameters *RepeatedEndpointConfPairs `json:"sql_configuration_parameters,omitempty"` +} + +// Request message for ListDefaultWarehouseOverrides.. +type ListDefaultWarehouseOverridesRequest struct { + // The maximum number of overrides to return. The service may return fewer than + // this value. If unspecified, at most 100 overrides will be returned. The + // maximum value is 1000; values above 1000 will be coerced to 1000. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous `ListDefaultWarehouseOverrides` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // `ListDefaultWarehouseOverrides` must match the call that provided the page + // token. + PageToken *string `json:"page_token,omitempty"` +} + +// Response message for ListDefaultWarehouseOverrides.. +type ListDefaultWarehouseOverridesResponse struct { + // The default warehouse overrides in the workspace. + DefaultWarehouseOverrides []DefaultWarehouseOverride `json:"default_warehouse_overrides,omitempty"` + // A token, which can be sent as `page_token` to retrieve the next page. If this + // field is omitted, there are no subsequent pages. + NextPageToken *string `json:"next_page_token,omitempty"` +} + +type ListWarehousesResponse struct { + // A token, which can be sent as `page_token` to retrieve the next page. If this + // field is omitted, there are no subsequent pages. + NextPageToken *string `json:"next_page_token,omitempty"` + // A list of warehouses and their configurations. + Warehouses []EndpointInfo `json:"warehouses,omitempty"` +} + +type OdbcParams struct { + Hostname *string `json:"hostname,omitempty"` + Path *string `json:"path,omitempty"` + Port *int `json:"port,omitempty"` + Protocol *string `json:"protocol,omitempty"` +} + +type RepeatedEndpointConfPairs struct { + // Deprecated: Use configuration_pairs + ConfigPair []EndpointConfPair `json:"config_pair,omitempty"` + ConfigurationPairs []EndpointConfPair `json:"configuration_pairs,omitempty"` +} + +// Sets the workspace level warehouse configuration that is shared by all SQL +// warehouses in this workspace. +// +// This is idempotent.. +type SetWorkspaceWarehouseConfigRequest struct { + // Optional: Channel selection details + Channel *Channel `json:"channel,omitempty"` + // Deprecated: Use sql_configuration_parameters + ConfigParam *RepeatedEndpointConfPairs `json:"config_param,omitempty"` + // Spark confs for external hive metastore configuration JSON serialized size + // must be less than <= 512K + DataAccessConfig []EndpointConfPair `json:"data_access_config,omitempty"` + // Deprecated: only setting this to true is allowed. + EnableServerlessCompute *bool `json:"enable_serverless_compute,omitempty"` + // List of Warehouse Types allowed in this workspace (limits allowed value of + // the type field in CreateWarehouse and EditWarehouse). Note: Some types cannot + // be disabled, they don't need to be specified in SetWorkspaceWarehouseConfig. + // Note: Disabling a type may cause existing warehouses to be converted to + // another type. Used by frontend to save specific type availability in the + // warehouse create and edit form UI. + EnabledWarehouseTypes []WarehouseTypePair `json:"enabled_warehouse_types,omitempty"` + // Deprecated: Use sql_configuration_parameters + GlobalParam *RepeatedEndpointConfPairs `json:"global_param,omitempty"` + // GCP only: Google Service Account used to pass to cluster to access Google + // Cloud Storage + GoogleServiceAccount *string `json:"google_service_account,omitempty"` + // AWS Only: The instance profile used to pass an IAM role to the SQL + // warehouses. This configuration is also applied to the workspace's serverless + // compute for notebooks and jobs. + InstanceProfileArn *string `json:"instance_profile_arn,omitempty"` + // Security policy for warehouses + SecurityPolicy EndpointSecurityPolicy `json:"security_policy,omitempty"` + // SQL configuration parameters + SqlConfigurationParameters *RepeatedEndpointConfPairs `json:"sql_configuration_parameters,omitempty"` +} + +type TerminationReason struct { + // status code indicating why the cluster was terminated + Code TerminationCode `json:"code,omitempty"` + // list of parameters that provide additional information about why the cluster + // was terminated + Parameters map[string]string `json:"parameters,omitempty"` + // type of the termination + Type TerminationType `json:"type,omitempty"` +} + +// Request message for UpdateDefaultWarehouseOverride.. +type UpdateDefaultWarehouseOverrideRequest struct { + // If set to true, and the override is not found, a new override will be + // created. In this situation, `update_mask` is ignored and all fields are + // applied. Defaults to false. + AllowMissing *bool `json:"allow_missing,omitempty"` + // Required. The default warehouse override to update. The name field must be + // set in the format: + // default-warehouse-overrides/{default_warehouse_override_id} The + // default_warehouse_override_id can be a numeric user ID or the literal string + // "me" for the current user. + DefaultWarehouseOverride *DefaultWarehouseOverride `json:"default_warehouse_override,omitempty"` + // Required. Field mask specifying which fields to update. Only the fields + // specified in the mask will be updated. Use "*" to update all fields. When + // allow_missing is true, this field is ignored and all fields are applied. + UpdateMask *string `json:"update_mask,omitempty"` +} + +// * Configuration values to enable or disable the access to specific warehouse +// types in the workspace.. +type WarehouseTypePair struct { + // If set to false the specific warehouse type will not be allowed as a value + // for warehouse_type in CreateWarehouse and EditWarehouse + Enabled *bool `json:"enabled,omitempty"` + WarehouseType WarehouseType `json:"warehouse_type,omitempty"` +} + +// Lists all of the SQL warehouses. TODO: consider paginating to limit the +// number of warehouses returned.. +type ListWarehousesRequest struct { + // The max number of warehouses to return. + PageSize *int `json:"page_size,omitempty"` + // A page token, received from a previous `ListWarehouses` call. Provide this to + // retrieve the subsequent page; otherwise the first will be retrieved. + // + // When paginating, all other parameters provided to `ListWarehouses` must match + // the call that provided the page token. + PageToken *string `json:"page_token,omitempty"` + // Deprecated: this field is ignored by the server. Service Principal which will + // be used to fetch the list of endpoints. If not specified, SQL Gateway will + // use the user from the session header. + RunAsUserId *int64 `json:"run_as_user_id,omitempty"` +} + +// Starts a SQL warehouse. This API is idempotent.. +type StartRequest struct { + // Required. Id of the SQL warehouse. + Id *string `json:"id,omitempty"` +} + +// Stops a SQL warehouse. This API is idempotent.. +type StopRequest struct { + // Required. Id of the SQL warehouse. + Id *string `json:"id,omitempty"` +} + +// ChannelToSDK converts the mirror to the sdk-go type. +func ChannelToSDK(w *Channel) (*sdk.Channel, error) { + if w == nil { + return nil, nil + } + out := &sdk.Channel{} + out.Name = w.Name + out.DbsqlVersion = w.DbsqlVersion + return out, nil +} + +// ChannelFromSDK converts the sdk-go type to the mirror. +func ChannelFromSDK(v *sdk.Channel) (*Channel, error) { + if v == nil { + return nil, nil + } + out := &Channel{} + out.Name = v.Name + out.DbsqlVersion = v.DbsqlVersion + return out, nil +} + +// CreateDefaultWarehouseOverrideRequestToSDK converts the mirror to the sdk-go type. +func CreateDefaultWarehouseOverrideRequestToSDK(w *CreateDefaultWarehouseOverrideRequest) (*sdk.CreateDefaultWarehouseOverrideRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateDefaultWarehouseOverrideRequest{} + out.DefaultWarehouseOverrideId = w.DefaultWarehouseOverrideId + conv1, err := DefaultWarehouseOverrideToSDK(w.DefaultWarehouseOverride) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDefaultWarehouseOverrideRequest.DefaultWarehouseOverride", err) + } + out.DefaultWarehouseOverride = conv1 + return out, nil +} + +// CreateDefaultWarehouseOverrideRequestFromSDK converts the sdk-go type to the mirror. +func CreateDefaultWarehouseOverrideRequestFromSDK(v *sdk.CreateDefaultWarehouseOverrideRequest) (*CreateDefaultWarehouseOverrideRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateDefaultWarehouseOverrideRequest{} + out.DefaultWarehouseOverrideId = v.DefaultWarehouseOverrideId + conv2, err := DefaultWarehouseOverrideFromSDK(v.DefaultWarehouseOverride) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateDefaultWarehouseOverrideRequest.DefaultWarehouseOverride", err) + } + out.DefaultWarehouseOverride = conv2 + return out, nil +} + +// CreateWarehouseRequestToSDK converts the mirror to the sdk-go type. +func CreateWarehouseRequestToSDK(w *CreateWarehouseRequest) (*sdk.CreateWarehouseRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateWarehouseRequest{} + out.Name = w.Name + out.ClusterSize = w.ClusterSize + out.MinNumClusters = w.MinNumClusters + out.MaxNumClusters = w.MaxNumClusters + out.AutoStopMins = w.AutoStopMins + out.CreatorName = w.CreatorName + out.InstanceProfileArn = w.InstanceProfileArn + conv3, err := EndpointTagsToSDK(w.Tags) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateWarehouseRequest.Tags", err) + } + out.Tags = conv3 + out.SpotInstancePolicy = w.SpotInstancePolicy + out.EnablePhoton = w.EnablePhoton + conv4, err := ChannelToSDK(w.Channel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateWarehouseRequest.Channel", err) + } + out.Channel = conv4 + out.EnableServerlessCompute = w.EnableServerlessCompute + out.WarehouseType = w.WarehouseType + out.StatementTimeout = w.StatementTimeout + return out, nil +} + +// CreateWarehouseRequestFromSDK converts the sdk-go type to the mirror. +func CreateWarehouseRequestFromSDK(v *sdk.CreateWarehouseRequest) (*CreateWarehouseRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateWarehouseRequest{} + out.Name = v.Name + out.ClusterSize = v.ClusterSize + out.MinNumClusters = v.MinNumClusters + out.MaxNumClusters = v.MaxNumClusters + out.AutoStopMins = v.AutoStopMins + out.CreatorName = v.CreatorName + out.InstanceProfileArn = v.InstanceProfileArn + conv5, err := EndpointTagsFromSDK(v.Tags) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateWarehouseRequest.Tags", err) + } + out.Tags = conv5 + out.SpotInstancePolicy = v.SpotInstancePolicy + out.EnablePhoton = v.EnablePhoton + conv6, err := ChannelFromSDK(v.Channel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateWarehouseRequest.Channel", err) + } + out.Channel = conv6 + out.EnableServerlessCompute = v.EnableServerlessCompute + out.WarehouseType = v.WarehouseType + out.StatementTimeout = v.StatementTimeout + return out, nil +} + +// CreateWarehouseResponseToSDK converts the mirror to the sdk-go type. +func CreateWarehouseResponseToSDK(w *CreateWarehouseResponse) (*sdk.CreateWarehouseResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateWarehouseResponse{} + out.Id = w.Id + return out, nil +} + +// CreateWarehouseResponseFromSDK converts the sdk-go type to the mirror. +func CreateWarehouseResponseFromSDK(v *sdk.CreateWarehouseResponse) (*CreateWarehouseResponse, error) { + if v == nil { + return nil, nil + } + out := &CreateWarehouseResponse{} + out.Id = v.Id + return out, nil +} + +// DefaultWarehouseOverrideToSDK converts the mirror to the sdk-go type. +func DefaultWarehouseOverrideToSDK(w *DefaultWarehouseOverride) (*sdk.DefaultWarehouseOverride, error) { + if w == nil { + return nil, nil + } + out := &sdk.DefaultWarehouseOverride{} + out.Name = w.Name + out.DefaultWarehouseOverrideId = w.DefaultWarehouseOverrideId + out.Type = w.Type + out.WarehouseId = w.WarehouseId + return out, nil +} + +// DefaultWarehouseOverrideFromSDK converts the sdk-go type to the mirror. +func DefaultWarehouseOverrideFromSDK(v *sdk.DefaultWarehouseOverride) (*DefaultWarehouseOverride, error) { + if v == nil { + return nil, nil + } + out := &DefaultWarehouseOverride{} + out.Name = v.Name + out.DefaultWarehouseOverrideId = v.DefaultWarehouseOverrideId + out.Type = v.Type + out.WarehouseId = v.WarehouseId + return out, nil +} + +// EditWarehouseRequestToSDK converts the mirror to the sdk-go type. +func EditWarehouseRequestToSDK(w *EditWarehouseRequest) (*sdk.EditWarehouseRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.EditWarehouseRequest{} + out.Id = w.Id + out.Name = w.Name + out.ClusterSize = w.ClusterSize + out.MinNumClusters = w.MinNumClusters + out.MaxNumClusters = w.MaxNumClusters + out.AutoStopMins = w.AutoStopMins + out.CreatorName = w.CreatorName + out.InstanceProfileArn = w.InstanceProfileArn + conv7, err := EndpointTagsToSDK(w.Tags) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditWarehouseRequest.Tags", err) + } + out.Tags = conv7 + out.SpotInstancePolicy = w.SpotInstancePolicy + out.EnablePhoton = w.EnablePhoton + conv8, err := ChannelToSDK(w.Channel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditWarehouseRequest.Channel", err) + } + out.Channel = conv8 + out.EnableServerlessCompute = w.EnableServerlessCompute + out.WarehouseType = w.WarehouseType + out.StatementTimeout = w.StatementTimeout + return out, nil +} + +// EditWarehouseRequestFromSDK converts the sdk-go type to the mirror. +func EditWarehouseRequestFromSDK(v *sdk.EditWarehouseRequest) (*EditWarehouseRequest, error) { + if v == nil { + return nil, nil + } + out := &EditWarehouseRequest{} + out.Id = v.Id + out.Name = v.Name + out.ClusterSize = v.ClusterSize + out.MinNumClusters = v.MinNumClusters + out.MaxNumClusters = v.MaxNumClusters + out.AutoStopMins = v.AutoStopMins + out.CreatorName = v.CreatorName + out.InstanceProfileArn = v.InstanceProfileArn + conv9, err := EndpointTagsFromSDK(v.Tags) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditWarehouseRequest.Tags", err) + } + out.Tags = conv9 + out.SpotInstancePolicy = v.SpotInstancePolicy + out.EnablePhoton = v.EnablePhoton + conv10, err := ChannelFromSDK(v.Channel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EditWarehouseRequest.Channel", err) + } + out.Channel = conv10 + out.EnableServerlessCompute = v.EnableServerlessCompute + out.WarehouseType = v.WarehouseType + out.StatementTimeout = v.StatementTimeout + return out, nil +} + +// EndpointConfPairToSDK converts the mirror to the sdk-go type. +func EndpointConfPairToSDK(w *EndpointConfPair) (*sdk.EndpointConfPair, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointConfPair{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// EndpointConfPairFromSDK converts the sdk-go type to the mirror. +func EndpointConfPairFromSDK(v *sdk.EndpointConfPair) (*EndpointConfPair, error) { + if v == nil { + return nil, nil + } + out := &EndpointConfPair{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// EndpointHealthToSDK converts the mirror to the sdk-go type. +func EndpointHealthToSDK(w *EndpointHealth) (*sdk.EndpointHealth, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointHealth{} + out.Status = w.Status + out.Message = w.Message + conv11, err := TerminationReasonToSDK(w.FailureReason) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointHealth.FailureReason", err) + } + out.FailureReason = conv11 + out.Summary = w.Summary + out.Details = w.Details + return out, nil +} + +// EndpointHealthFromSDK converts the sdk-go type to the mirror. +func EndpointHealthFromSDK(v *sdk.EndpointHealth) (*EndpointHealth, error) { + if v == nil { + return nil, nil + } + out := &EndpointHealth{} + out.Status = v.Status + out.Message = v.Message + conv12, err := TerminationReasonFromSDK(v.FailureReason) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointHealth.FailureReason", err) + } + out.FailureReason = conv12 + out.Summary = v.Summary + out.Details = v.Details + return out, nil +} + +// EndpointInfoToSDK converts the mirror to the sdk-go type. +func EndpointInfoToSDK(w *EndpointInfo) (*sdk.EndpointInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointInfo{} + out.Id = w.Id + out.Name = w.Name + out.ClusterSize = w.ClusterSize + out.MinNumClusters = w.MinNumClusters + out.MaxNumClusters = w.MaxNumClusters + out.AutoStopMins = w.AutoStopMins + out.CreatorName = w.CreatorName + out.InstanceProfileArn = w.InstanceProfileArn + conv13, err := EndpointTagsToSDK(w.Tags) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointInfo.Tags", err) + } + out.Tags = conv13 + out.SpotInstancePolicy = w.SpotInstancePolicy + out.EnablePhoton = w.EnablePhoton + conv14, err := ChannelToSDK(w.Channel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointInfo.Channel", err) + } + out.Channel = conv14 + out.EnableServerlessCompute = w.EnableServerlessCompute + out.WarehouseType = w.WarehouseType + out.StatementTimeout = w.StatementTimeout + out.NumClusters = w.NumClusters + out.NumActiveSessions = w.NumActiveSessions + out.State = w.State + out.JdbcUrl = w.JdbcUrl + conv15, err := OdbcParamsToSDK(w.OdbcParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointInfo.OdbcParams", err) + } + out.OdbcParams = conv15 + conv16, err := EndpointHealthToSDK(w.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointInfo.Health", err) + } + out.Health = conv16 + return out, nil +} + +// EndpointInfoFromSDK converts the sdk-go type to the mirror. +func EndpointInfoFromSDK(v *sdk.EndpointInfo) (*EndpointInfo, error) { + if v == nil { + return nil, nil + } + out := &EndpointInfo{} + out.Id = v.Id + out.Name = v.Name + out.ClusterSize = v.ClusterSize + out.MinNumClusters = v.MinNumClusters + out.MaxNumClusters = v.MaxNumClusters + out.AutoStopMins = v.AutoStopMins + out.CreatorName = v.CreatorName + out.InstanceProfileArn = v.InstanceProfileArn + conv17, err := EndpointTagsFromSDK(v.Tags) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointInfo.Tags", err) + } + out.Tags = conv17 + out.SpotInstancePolicy = v.SpotInstancePolicy + out.EnablePhoton = v.EnablePhoton + conv18, err := ChannelFromSDK(v.Channel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointInfo.Channel", err) + } + out.Channel = conv18 + out.EnableServerlessCompute = v.EnableServerlessCompute + out.WarehouseType = v.WarehouseType + out.StatementTimeout = v.StatementTimeout + out.NumClusters = v.NumClusters + out.NumActiveSessions = v.NumActiveSessions + out.State = v.State + out.JdbcUrl = v.JdbcUrl + conv19, err := OdbcParamsFromSDK(v.OdbcParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointInfo.OdbcParams", err) + } + out.OdbcParams = conv19 + conv20, err := EndpointHealthFromSDK(v.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointInfo.Health", err) + } + out.Health = conv20 + return out, nil +} + +// EndpointTagPairToSDK converts the mirror to the sdk-go type. +func EndpointTagPairToSDK(w *EndpointTagPair) (*sdk.EndpointTagPair, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointTagPair{} + out.Key = w.Key + out.Value = w.Value + return out, nil +} + +// EndpointTagPairFromSDK converts the sdk-go type to the mirror. +func EndpointTagPairFromSDK(v *sdk.EndpointTagPair) (*EndpointTagPair, error) { + if v == nil { + return nil, nil + } + out := &EndpointTagPair{} + out.Key = v.Key + out.Value = v.Value + return out, nil +} + +// EndpointTagsToSDK converts the mirror to the sdk-go type. +func EndpointTagsToSDK(w *EndpointTags) (*sdk.EndpointTags, error) { + if w == nil { + return nil, nil + } + out := &sdk.EndpointTags{} + conv21, err := convertSlice(w.CustomTags, EndpointTagPairToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointTags.CustomTags", err) + } + out.CustomTags = conv21 + return out, nil +} + +// EndpointTagsFromSDK converts the sdk-go type to the mirror. +func EndpointTagsFromSDK(v *sdk.EndpointTags) (*EndpointTags, error) { + if v == nil { + return nil, nil + } + out := &EndpointTags{} + conv22, err := convertSlice(v.CustomTags, EndpointTagPairFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "EndpointTags.CustomTags", err) + } + out.CustomTags = conv22 + return out, nil +} + +// GetWarehouseResponseToSDK converts the mirror to the sdk-go type. +func GetWarehouseResponseToSDK(w *GetWarehouseResponse) (*sdk.GetWarehouseResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetWarehouseResponse{} + out.Id = w.Id + out.Name = w.Name + out.ClusterSize = w.ClusterSize + out.MinNumClusters = w.MinNumClusters + out.MaxNumClusters = w.MaxNumClusters + out.AutoStopMins = w.AutoStopMins + out.CreatorName = w.CreatorName + out.InstanceProfileArn = w.InstanceProfileArn + conv23, err := EndpointTagsToSDK(w.Tags) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWarehouseResponse.Tags", err) + } + out.Tags = conv23 + out.SpotInstancePolicy = w.SpotInstancePolicy + out.EnablePhoton = w.EnablePhoton + conv24, err := ChannelToSDK(w.Channel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWarehouseResponse.Channel", err) + } + out.Channel = conv24 + out.EnableServerlessCompute = w.EnableServerlessCompute + out.WarehouseType = w.WarehouseType + out.StatementTimeout = w.StatementTimeout + out.NumClusters = w.NumClusters + out.NumActiveSessions = w.NumActiveSessions + out.State = w.State + out.JdbcUrl = w.JdbcUrl + conv25, err := OdbcParamsToSDK(w.OdbcParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWarehouseResponse.OdbcParams", err) + } + out.OdbcParams = conv25 + conv26, err := EndpointHealthToSDK(w.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWarehouseResponse.Health", err) + } + out.Health = conv26 + return out, nil +} + +// GetWarehouseResponseFromSDK converts the sdk-go type to the mirror. +func GetWarehouseResponseFromSDK(v *sdk.GetWarehouseResponse) (*GetWarehouseResponse, error) { + if v == nil { + return nil, nil + } + out := &GetWarehouseResponse{} + out.Id = v.Id + out.Name = v.Name + out.ClusterSize = v.ClusterSize + out.MinNumClusters = v.MinNumClusters + out.MaxNumClusters = v.MaxNumClusters + out.AutoStopMins = v.AutoStopMins + out.CreatorName = v.CreatorName + out.InstanceProfileArn = v.InstanceProfileArn + conv27, err := EndpointTagsFromSDK(v.Tags) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWarehouseResponse.Tags", err) + } + out.Tags = conv27 + out.SpotInstancePolicy = v.SpotInstancePolicy + out.EnablePhoton = v.EnablePhoton + conv28, err := ChannelFromSDK(v.Channel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWarehouseResponse.Channel", err) + } + out.Channel = conv28 + out.EnableServerlessCompute = v.EnableServerlessCompute + out.WarehouseType = v.WarehouseType + out.StatementTimeout = v.StatementTimeout + out.NumClusters = v.NumClusters + out.NumActiveSessions = v.NumActiveSessions + out.State = v.State + out.JdbcUrl = v.JdbcUrl + conv29, err := OdbcParamsFromSDK(v.OdbcParams) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWarehouseResponse.OdbcParams", err) + } + out.OdbcParams = conv29 + conv30, err := EndpointHealthFromSDK(v.Health) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWarehouseResponse.Health", err) + } + out.Health = conv30 + return out, nil +} + +// GetWorkspaceWarehouseConfigResponseToSDK converts the mirror to the sdk-go type. +func GetWorkspaceWarehouseConfigResponseToSDK(w *GetWorkspaceWarehouseConfigResponse) (*sdk.GetWorkspaceWarehouseConfigResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.GetWorkspaceWarehouseConfigResponse{} + out.SecurityPolicy = w.SecurityPolicy + conv31, err := convertSlice(w.DataAccessConfig, EndpointConfPairToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceWarehouseConfigResponse.DataAccessConfig", err) + } + out.DataAccessConfig = conv31 + out.InstanceProfileArn = w.InstanceProfileArn + conv32, err := ChannelToSDK(w.Channel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceWarehouseConfigResponse.Channel", err) + } + out.Channel = conv32 + out.EnableServerlessCompute = w.EnableServerlessCompute + conv33, err := RepeatedEndpointConfPairsToSDK(w.GlobalParam) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceWarehouseConfigResponse.GlobalParam", err) + } + out.GlobalParam = conv33 + conv34, err := RepeatedEndpointConfPairsToSDK(w.ConfigParam) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceWarehouseConfigResponse.ConfigParam", err) + } + out.ConfigParam = conv34 + conv35, err := RepeatedEndpointConfPairsToSDK(w.SqlConfigurationParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceWarehouseConfigResponse.SqlConfigurationParameters", err) + } + out.SqlConfigurationParameters = conv35 + out.GoogleServiceAccount = w.GoogleServiceAccount + conv36, err := convertSlice(w.EnabledWarehouseTypes, WarehouseTypePairToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceWarehouseConfigResponse.EnabledWarehouseTypes", err) + } + out.EnabledWarehouseTypes = conv36 + return out, nil +} + +// GetWorkspaceWarehouseConfigResponseFromSDK converts the sdk-go type to the mirror. +func GetWorkspaceWarehouseConfigResponseFromSDK(v *sdk.GetWorkspaceWarehouseConfigResponse) (*GetWorkspaceWarehouseConfigResponse, error) { + if v == nil { + return nil, nil + } + out := &GetWorkspaceWarehouseConfigResponse{} + out.SecurityPolicy = v.SecurityPolicy + conv37, err := convertSlice(v.DataAccessConfig, EndpointConfPairFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceWarehouseConfigResponse.DataAccessConfig", err) + } + out.DataAccessConfig = conv37 + out.InstanceProfileArn = v.InstanceProfileArn + conv38, err := ChannelFromSDK(v.Channel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceWarehouseConfigResponse.Channel", err) + } + out.Channel = conv38 + out.EnableServerlessCompute = v.EnableServerlessCompute + conv39, err := RepeatedEndpointConfPairsFromSDK(v.GlobalParam) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceWarehouseConfigResponse.GlobalParam", err) + } + out.GlobalParam = conv39 + conv40, err := RepeatedEndpointConfPairsFromSDK(v.ConfigParam) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceWarehouseConfigResponse.ConfigParam", err) + } + out.ConfigParam = conv40 + conv41, err := RepeatedEndpointConfPairsFromSDK(v.SqlConfigurationParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceWarehouseConfigResponse.SqlConfigurationParameters", err) + } + out.SqlConfigurationParameters = conv41 + out.GoogleServiceAccount = v.GoogleServiceAccount + conv42, err := convertSlice(v.EnabledWarehouseTypes, WarehouseTypePairFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "GetWorkspaceWarehouseConfigResponse.EnabledWarehouseTypes", err) + } + out.EnabledWarehouseTypes = conv42 + return out, nil +} + +// ListDefaultWarehouseOverridesRequestToSDK converts the mirror to the sdk-go type. +func ListDefaultWarehouseOverridesRequestToSDK(w *ListDefaultWarehouseOverridesRequest) (*sdk.ListDefaultWarehouseOverridesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDefaultWarehouseOverridesRequest{} + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListDefaultWarehouseOverridesRequestFromSDK converts the sdk-go type to the mirror. +func ListDefaultWarehouseOverridesRequestFromSDK(v *sdk.ListDefaultWarehouseOverridesRequest) (*ListDefaultWarehouseOverridesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListDefaultWarehouseOverridesRequest{} + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListDefaultWarehouseOverridesResponseToSDK converts the mirror to the sdk-go type. +func ListDefaultWarehouseOverridesResponseToSDK(w *ListDefaultWarehouseOverridesResponse) (*sdk.ListDefaultWarehouseOverridesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListDefaultWarehouseOverridesResponse{} + conv43, err := convertSlice(w.DefaultWarehouseOverrides, DefaultWarehouseOverrideToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDefaultWarehouseOverridesResponse.DefaultWarehouseOverrides", err) + } + out.DefaultWarehouseOverrides = conv43 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListDefaultWarehouseOverridesResponseFromSDK converts the sdk-go type to the mirror. +func ListDefaultWarehouseOverridesResponseFromSDK(v *sdk.ListDefaultWarehouseOverridesResponse) (*ListDefaultWarehouseOverridesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListDefaultWarehouseOverridesResponse{} + conv44, err := convertSlice(v.DefaultWarehouseOverrides, DefaultWarehouseOverrideFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListDefaultWarehouseOverridesResponse.DefaultWarehouseOverrides", err) + } + out.DefaultWarehouseOverrides = conv44 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// ListWarehousesRequestToSDK converts the mirror to the sdk-go type. +func ListWarehousesRequestToSDK(w *ListWarehousesRequest) (*sdk.ListWarehousesRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListWarehousesRequest{} + out.RunAsUserId = w.RunAsUserId + out.PageSize = w.PageSize + out.PageToken = w.PageToken + return out, nil +} + +// ListWarehousesRequestFromSDK converts the sdk-go type to the mirror. +func ListWarehousesRequestFromSDK(v *sdk.ListWarehousesRequest) (*ListWarehousesRequest, error) { + if v == nil { + return nil, nil + } + out := &ListWarehousesRequest{} + out.RunAsUserId = v.RunAsUserId + out.PageSize = v.PageSize + out.PageToken = v.PageToken + return out, nil +} + +// ListWarehousesResponseToSDK converts the mirror to the sdk-go type. +func ListWarehousesResponseToSDK(w *ListWarehousesResponse) (*sdk.ListWarehousesResponse, error) { + if w == nil { + return nil, nil + } + out := &sdk.ListWarehousesResponse{} + conv45, err := convertSlice(w.Warehouses, EndpointInfoToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListWarehousesResponse.Warehouses", err) + } + out.Warehouses = conv45 + out.NextPageToken = w.NextPageToken + return out, nil +} + +// ListWarehousesResponseFromSDK converts the sdk-go type to the mirror. +func ListWarehousesResponseFromSDK(v *sdk.ListWarehousesResponse) (*ListWarehousesResponse, error) { + if v == nil { + return nil, nil + } + out := &ListWarehousesResponse{} + conv46, err := convertSlice(v.Warehouses, EndpointInfoFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "ListWarehousesResponse.Warehouses", err) + } + out.Warehouses = conv46 + out.NextPageToken = v.NextPageToken + return out, nil +} + +// OdbcParamsToSDK converts the mirror to the sdk-go type. +func OdbcParamsToSDK(w *OdbcParams) (*sdk.OdbcParams, error) { + if w == nil { + return nil, nil + } + out := &sdk.OdbcParams{} + out.Hostname = w.Hostname + out.Path = w.Path + out.Protocol = w.Protocol + out.Port = w.Port + return out, nil +} + +// OdbcParamsFromSDK converts the sdk-go type to the mirror. +func OdbcParamsFromSDK(v *sdk.OdbcParams) (*OdbcParams, error) { + if v == nil { + return nil, nil + } + out := &OdbcParams{} + out.Hostname = v.Hostname + out.Path = v.Path + out.Protocol = v.Protocol + out.Port = v.Port + return out, nil +} + +// RepeatedEndpointConfPairsToSDK converts the mirror to the sdk-go type. +func RepeatedEndpointConfPairsToSDK(w *RepeatedEndpointConfPairs) (*sdk.RepeatedEndpointConfPairs, error) { + if w == nil { + return nil, nil + } + out := &sdk.RepeatedEndpointConfPairs{} + conv47, err := convertSlice(w.ConfigPair, EndpointConfPairToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RepeatedEndpointConfPairs.ConfigPair", err) + } + out.ConfigPair = conv47 + conv48, err := convertSlice(w.ConfigurationPairs, EndpointConfPairToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RepeatedEndpointConfPairs.ConfigurationPairs", err) + } + out.ConfigurationPairs = conv48 + return out, nil +} + +// RepeatedEndpointConfPairsFromSDK converts the sdk-go type to the mirror. +func RepeatedEndpointConfPairsFromSDK(v *sdk.RepeatedEndpointConfPairs) (*RepeatedEndpointConfPairs, error) { + if v == nil { + return nil, nil + } + out := &RepeatedEndpointConfPairs{} + conv49, err := convertSlice(v.ConfigPair, EndpointConfPairFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RepeatedEndpointConfPairs.ConfigPair", err) + } + out.ConfigPair = conv49 + conv50, err := convertSlice(v.ConfigurationPairs, EndpointConfPairFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "RepeatedEndpointConfPairs.ConfigurationPairs", err) + } + out.ConfigurationPairs = conv50 + return out, nil +} + +// SetWorkspaceWarehouseConfigRequestToSDK converts the mirror to the sdk-go type. +func SetWorkspaceWarehouseConfigRequestToSDK(w *SetWorkspaceWarehouseConfigRequest) (*sdk.SetWorkspaceWarehouseConfigRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.SetWorkspaceWarehouseConfigRequest{} + out.SecurityPolicy = w.SecurityPolicy + conv51, err := convertSlice(w.DataAccessConfig, EndpointConfPairToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetWorkspaceWarehouseConfigRequest.DataAccessConfig", err) + } + out.DataAccessConfig = conv51 + out.InstanceProfileArn = w.InstanceProfileArn + conv52, err := ChannelToSDK(w.Channel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetWorkspaceWarehouseConfigRequest.Channel", err) + } + out.Channel = conv52 + out.EnableServerlessCompute = w.EnableServerlessCompute + conv53, err := RepeatedEndpointConfPairsToSDK(w.GlobalParam) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetWorkspaceWarehouseConfigRequest.GlobalParam", err) + } + out.GlobalParam = conv53 + conv54, err := RepeatedEndpointConfPairsToSDK(w.ConfigParam) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetWorkspaceWarehouseConfigRequest.ConfigParam", err) + } + out.ConfigParam = conv54 + conv55, err := RepeatedEndpointConfPairsToSDK(w.SqlConfigurationParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetWorkspaceWarehouseConfigRequest.SqlConfigurationParameters", err) + } + out.SqlConfigurationParameters = conv55 + out.GoogleServiceAccount = w.GoogleServiceAccount + conv56, err := convertSlice(w.EnabledWarehouseTypes, WarehouseTypePairToSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetWorkspaceWarehouseConfigRequest.EnabledWarehouseTypes", err) + } + out.EnabledWarehouseTypes = conv56 + return out, nil +} + +// SetWorkspaceWarehouseConfigRequestFromSDK converts the sdk-go type to the mirror. +func SetWorkspaceWarehouseConfigRequestFromSDK(v *sdk.SetWorkspaceWarehouseConfigRequest) (*SetWorkspaceWarehouseConfigRequest, error) { + if v == nil { + return nil, nil + } + out := &SetWorkspaceWarehouseConfigRequest{} + out.SecurityPolicy = v.SecurityPolicy + conv57, err := convertSlice(v.DataAccessConfig, EndpointConfPairFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetWorkspaceWarehouseConfigRequest.DataAccessConfig", err) + } + out.DataAccessConfig = conv57 + out.InstanceProfileArn = v.InstanceProfileArn + conv58, err := ChannelFromSDK(v.Channel) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetWorkspaceWarehouseConfigRequest.Channel", err) + } + out.Channel = conv58 + out.EnableServerlessCompute = v.EnableServerlessCompute + conv59, err := RepeatedEndpointConfPairsFromSDK(v.GlobalParam) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetWorkspaceWarehouseConfigRequest.GlobalParam", err) + } + out.GlobalParam = conv59 + conv60, err := RepeatedEndpointConfPairsFromSDK(v.ConfigParam) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetWorkspaceWarehouseConfigRequest.ConfigParam", err) + } + out.ConfigParam = conv60 + conv61, err := RepeatedEndpointConfPairsFromSDK(v.SqlConfigurationParameters) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetWorkspaceWarehouseConfigRequest.SqlConfigurationParameters", err) + } + out.SqlConfigurationParameters = conv61 + out.GoogleServiceAccount = v.GoogleServiceAccount + conv62, err := convertSlice(v.EnabledWarehouseTypes, WarehouseTypePairFromSDK) + if err != nil { + return nil, fmt.Errorf("%s: %w", "SetWorkspaceWarehouseConfigRequest.EnabledWarehouseTypes", err) + } + out.EnabledWarehouseTypes = conv62 + return out, nil +} + +// StartRequestToSDK converts the mirror to the sdk-go type. +func StartRequestToSDK(w *StartRequest) (*sdk.StartRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.StartRequest{} + out.Id = w.Id + return out, nil +} + +// StartRequestFromSDK converts the sdk-go type to the mirror. +func StartRequestFromSDK(v *sdk.StartRequest) (*StartRequest, error) { + if v == nil { + return nil, nil + } + out := &StartRequest{} + out.Id = v.Id + return out, nil +} + +// StopRequestToSDK converts the mirror to the sdk-go type. +func StopRequestToSDK(w *StopRequest) (*sdk.StopRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.StopRequest{} + out.Id = w.Id + return out, nil +} + +// StopRequestFromSDK converts the sdk-go type to the mirror. +func StopRequestFromSDK(v *sdk.StopRequest) (*StopRequest, error) { + if v == nil { + return nil, nil + } + out := &StopRequest{} + out.Id = v.Id + return out, nil +} + +// TerminationReasonToSDK converts the mirror to the sdk-go type. +func TerminationReasonToSDK(w *TerminationReason) (*sdk.TerminationReason, error) { + if w == nil { + return nil, nil + } + out := &sdk.TerminationReason{} + out.Code = w.Code + out.Type = w.Type + out.Parameters = w.Parameters + return out, nil +} + +// TerminationReasonFromSDK converts the sdk-go type to the mirror. +func TerminationReasonFromSDK(v *sdk.TerminationReason) (*TerminationReason, error) { + if v == nil { + return nil, nil + } + out := &TerminationReason{} + out.Code = v.Code + out.Type = v.Type + out.Parameters = v.Parameters + return out, nil +} + +// UpdateDefaultWarehouseOverrideRequestToSDK converts the mirror to the sdk-go type. +func UpdateDefaultWarehouseOverrideRequestToSDK(w *UpdateDefaultWarehouseOverrideRequest) (*sdk.UpdateDefaultWarehouseOverrideRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateDefaultWarehouseOverrideRequest{} + conv63, err := DefaultWarehouseOverrideToSDK(w.DefaultWarehouseOverride) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDefaultWarehouseOverrideRequest.DefaultWarehouseOverride", err) + } + out.DefaultWarehouseOverride = conv63 + mask64, err := fieldMaskFromString[sdk.DefaultWarehouseOverride](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDefaultWarehouseOverrideRequest.UpdateMask", err) + } + out.UpdateMask = mask64 + out.AllowMissing = w.AllowMissing + return out, nil +} + +// UpdateDefaultWarehouseOverrideRequestFromSDK converts the sdk-go type to the mirror. +func UpdateDefaultWarehouseOverrideRequestFromSDK(v *sdk.UpdateDefaultWarehouseOverrideRequest) (*UpdateDefaultWarehouseOverrideRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateDefaultWarehouseOverrideRequest{} + conv65, err := DefaultWarehouseOverrideFromSDK(v.DefaultWarehouseOverride) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateDefaultWarehouseOverrideRequest.DefaultWarehouseOverride", err) + } + out.DefaultWarehouseOverride = conv65 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + out.AllowMissing = v.AllowMissing + return out, nil +} + +// WarehouseTypePairToSDK converts the mirror to the sdk-go type. +func WarehouseTypePairToSDK(w *WarehouseTypePair) (*sdk.WarehouseTypePair, error) { + if w == nil { + return nil, nil + } + out := &sdk.WarehouseTypePair{} + out.WarehouseType = w.WarehouseType + out.Enabled = w.Enabled + return out, nil +} + +// WarehouseTypePairFromSDK converts the sdk-go type to the mirror. +func WarehouseTypePairFromSDK(v *sdk.WarehouseTypePair) (*WarehouseTypePair, error) { + if v == nil { + return nil, nil + } + out := &WarehouseTypePair{} + out.WarehouseType = v.WarehouseType + out.Enabled = v.Enabled + return out, nil +} + +func convertSlice[T, W any](s []T, conv func(*T) (*W, error)) ([]W, error) { + if s == nil { + return nil, nil + } + out := make([]W, len(s)) + for i := range s { + converted, err := conv(&s[i]) + if err != nil { + return nil, fmt.Errorf("element %d: %w", i, err) + } + out[i] = *converted + } + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/sdktypes/workspaces/v1/types.generated.go b/libs/sdktypes/workspaces/v1/types.generated.go new file mode 100644 index 00000000000..690a21acd5c --- /dev/null +++ b/libs/sdktypes/workspaces/v1/types.generated.go @@ -0,0 +1,738 @@ +// Code generated by internal/sdktypesgen from github.com/databricks/sdk-go/workspaces/v1. DO NOT EDIT. + +package workspaces + +import ( + fmt "fmt" + + sdk "github.com/databricks/sdk-go/workspaces/v1" + + types "github.com/databricks/sdk-go/core/types" + strings "strings" +) + +type ( + ComputeMode = sdk.ComputeMode + GkeConnectivityType = sdk.GkeConnectivityType + PricingTier = sdk.PricingTier + StorageMode = sdk.StorageMode + WorkspaceStatus = sdk.WorkspaceStatus +) + +const ( + ComputeMode_Unspecified = sdk.ComputeMode_Unspecified + ComputeMode_Hybrid = sdk.ComputeMode_Hybrid + ComputeMode_Serverless = sdk.ComputeMode_Serverless + GkeConnectivityType_Unspecified = sdk.GkeConnectivityType_Unspecified + GkeConnectivityType_PrivateNodePublicMaster = sdk.GkeConnectivityType_PrivateNodePublicMaster + GkeConnectivityType_PublicNodePublicMaster = sdk.GkeConnectivityType_PublicNodePublicMaster + PricingTier_Unspecified = sdk.PricingTier_Unspecified + PricingTier_CommunityEdition = sdk.PricingTier_CommunityEdition + PricingTier_Standard = sdk.PricingTier_Standard + PricingTier_Premium = sdk.PricingTier_Premium + PricingTier_Enterprise = sdk.PricingTier_Enterprise + PricingTier_Dedicated = sdk.PricingTier_Dedicated + StorageMode_Unspecified = sdk.StorageMode_Unspecified + StorageMode_CustomerHosted = sdk.StorageMode_CustomerHosted + StorageMode_DefaultStorage = sdk.StorageMode_DefaultStorage + WorkspaceStatus_Unspecified = sdk.WorkspaceStatus_Unspecified + WorkspaceStatus_Provisioning = sdk.WorkspaceStatus_Provisioning + WorkspaceStatus_Running = sdk.WorkspaceStatus_Running + WorkspaceStatus_Failed = sdk.WorkspaceStatus_Failed + WorkspaceStatus_Banned = sdk.WorkspaceStatus_Banned + WorkspaceStatus_Cancelling = sdk.WorkspaceStatus_Cancelling +) + +type AzureWorkspaceInfo struct { + // Azure Resource Group name + ResourceGroup *string `json:"resource_group,omitempty"` + // Azure Subscription ID + SubscriptionId *string `json:"subscription_id,omitempty"` +} + +type CloudResourceContainer struct { + Gcp *GcpCloudResourceContainer `json:"gcp,omitempty"` +} + +type CreateWorkspaceRequest struct { + AccountId *string `json:"account_id,omitempty"` + AwsRegion *string `json:"aws_region,omitempty"` + // DEPRECATED: This field is being ignored by the server and will be removed in + // the future. The cloud name. This field always has the value `gcp`. + Cloud *string `json:"cloud,omitempty"` + CloudResourceContainer *CloudResourceContainer `json:"cloud_resource_container,omitempty"` + // If the compute mode is `SERVERLESS`, a serverless workspace is created that + // comes pre-configured with serverless compute and default storage, providing a + // fully-managed, enterprise-ready SaaS experience. This means you don't need to + // provide any resources managed by you, such as credentials, storage, or + // network. If the compute mode is `HYBRID` (which is the default option), a + // classic workspace is created that uses customer-managed resources. + ComputeMode ComputeMode `json:"compute_mode,omitempty"` + // ID of the workspace's credential configuration object. + CredentialsId *string `json:"credentials_id,omitempty"` + // The custom tags key-value pairing that is attached to this workspace. The + // key-value pair is a string of utf-8 characters. The value can be an empty + // string, with maximum length of 255 characters. The key can be of maximum + // length of 127 characters, and cannot be empty. + CustomTags map[string]string `json:"custom_tags,omitempty"` + // The deployment name defines part of the subdomain for the workspace. The + // workspace URL for the web application and REST APIs is + // .cloud.databricks.com. For example, if the + // deployment name is abcsales, your workspace URL will be + // https://abcsales.cloud.databricks.com. Hyphens are allowed. This property + // supports only the set of characters that are allowed in a subdomain. To set + // this value, you must have a deployment name prefix. Contact your + // account team to add an account deployment name prefix to your account. + // Workspace deployment names follow the account prefix and a hyphen. For + // example, if your account's deployment prefix is acme and the workspace + // deployment name is workspace-1, the JSON response for the deployment_name + // field becomes acme-workspace-1. The workspace URL would be + // acme-workspace-1.cloud.databricks.com. You can also set the deployment_name + // to the reserved keyword EMPTY if you want the deployment name to only include + // the deployment prefix. For example, if your account's deployment prefix is + // acme and the workspace deployment name is EMPTY, the deployment_name becomes + // acme only and the workspace URL is acme.cloud.databricks.com. This value must + // be unique across all non-deleted deployments across all AWS regions. If a new + // workspace omits this property, the server generates a unique deployment name + // for you with the pattern dbc-xxxxxxxx-xxxx. + DeploymentName *string `json:"deployment_name,omitempty"` + GcpManagedNetworkConfig *GcpManagedNetworkConfig `json:"gcp_managed_network_config,omitempty"` + GkeConfig *GkeConfig `json:"gke_config,omitempty"` + // The Google Cloud region of the workspace data plane in your Google account + // (for example, `us-east4`). + Location *string `json:"location,omitempty"` + // The ID of the workspace's managed services encryption key configuration + // object. This is used to help protect and control access to the workspace's + // notebooks, secrets, Databricks SQL queries, and query history. The provided + // key configuration object property use_cases must contain MANAGED_SERVICES. + ManagedServicesCustomerManagedKeyId *string `json:"managed_services_customer_managed_key_id,omitempty"` + // The object ID of network connectivity config. Once assigned, the workspace + // serverless compute resources use the same set of stable IP CIDR blocks and + // optional private link to access your resources. + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + // The ID of the workspace's network configuration object. To use AWS + // PrivateLink, this field is required. + NetworkId *string `json:"network_id,omitempty"` + PricingTier PricingTier `json:"pricing_tier,omitempty"` + // ID of the workspace's private access settings object. Only used for + // PrivateLink. You must specify this ID if you are using [AWS PrivateLink] for + // either front-end (user-to-workspace connection), back-end (data plane to + // control plane connection), or both connection types. Before configuring + // PrivateLink, read the [ article about PrivateLink].", + // + // [ article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html + // [AWS PrivateLink]: https://aws.amazon.com/privatelink/ + PrivateAccessSettingsId *string `json:"private_access_settings_id,omitempty"` + // ID of the workspace's storage configuration object. + StorageConfigurationId *string `json:"storage_configuration_id,omitempty"` + // The ID of the workspace's storage encryption key configuration object. This + // is used to encrypt the workspace's root S3 bucket (root DBFS and system data) + // and, optionally, cluster EBS volumes. The provided key configuration object + // property use_cases must contain STORAGE. + StorageCustomerManagedKeyId *string `json:"storage_customer_managed_key_id,omitempty"` + // The human-readable name of the workspace. + WorkspaceName *string `json:"workspace_name,omitempty"` +} + +type GcpCloudResourceContainer struct { + ProjectId *string `json:"project_id,omitempty"` +} + +// The shared network config for GCP workspace. This object has common network +// configurations that are network attributions of a workspace. DEPRECATED. Use +// GkeConfig instead.. +type GcpCommonNetworkConfig struct { + // The IP range that will be used to allocate GKE cluster master resources from. + // This field must not be set if gke_cluster_type=PUBLIC_NODE_PUBLIC_MASTER. + GkeClusterMasterIpRange *string `json:"gke_cluster_master_ip_range,omitempty"` + // The type of network connectivity of the GKE cluster. + GkeConnectivityType GkeConnectivityType `json:"gke_connectivity_type,omitempty"` +} + +// The network configuration for the workspace.. +type GcpManagedNetworkConfig struct { + // The IP range that will be used to allocate GKE cluster Pods from. + GkeClusterPodIpRange *string `json:"gke_cluster_pod_ip_range,omitempty"` + // The IP range that will be used to allocate GKE cluster Services from. + GkeClusterServiceIpRange *string `json:"gke_cluster_service_ip_range,omitempty"` + // The IP range which will be used to allocate GKE cluster nodes from. Note: + // Pods, services and master IP range must be mutually exclusive. + SubnetCidr *string `json:"subnet_cidr,omitempty"` +} + +// The configurations of the GKE cluster used by the GCP workspace.. +type GkeConfig struct { + // The type of network connectivity of the GKE cluster. + ConnectivityType GkeConnectivityType `json:"connectivity_type,omitempty"` + // The IP range that will be used to allocate GKE cluster master resources from. + // This field must not be set if gke_cluster_type=PUBLIC_NODE_PUBLIC_MASTER. + MasterIpRange *string `json:"master_ip_range,omitempty"` +} + +type UpdateWorkspaceRequest struct { + CustomerFacingWorkspace *Workspace `json:"customer_facing_workspace,omitempty"` + UpdateMask *string `json:"update_mask,omitempty"` +} + +type Workspace struct { + // account ID. + AccountId *string `json:"account_id,omitempty"` + AwsRegion *string `json:"aws_region,omitempty"` + AzureWorkspaceInfo *AzureWorkspaceInfo `json:"azure_workspace_info,omitempty"` + // The cloud name. This field can have values like `azure`, `gcp`. + Cloud *string `json:"cloud,omitempty"` + CloudResourceContainer *CloudResourceContainer `json:"cloud_resource_container,omitempty"` + // The compute mode of the workspace. + ComputeMode ComputeMode `json:"compute_mode,omitempty"` + // Time in epoch milliseconds when the workspace was created. + CreationTime *int64 `json:"creation_time,omitempty"` + // ID of the workspace's credential configuration object. + CredentialsId *string `json:"credentials_id,omitempty"` + // The custom tags key-value pairing that is attached to this workspace. The + // key-value pair is a string of utf-8 characters. The value can be an empty + // string, with maximum length of 255 characters. The key can be of maximum + // length of 127 characters, and cannot be empty. + CustomTags map[string]string `json:"custom_tags,omitempty"` + DeploymentName *string `json:"deployment_name,omitempty"` + // A client owned field used to indicate the workspace status that the client + // expects to be in. For now this is only used to unblock Temporal workflow for + // GCP least privileged workspace. + ExpectedWorkspaceStatus WorkspaceStatus `json:"expected_workspace_status,omitempty"` + GcpManagedNetworkConfig *GcpManagedNetworkConfig `json:"gcp_managed_network_config,omitempty"` + GkeConfig *GkeConfig `json:"gke_config,omitempty"` + // The Google Cloud region of the workspace data plane in your Google account + // (for example, `us-east4`). + Location *string `json:"location,omitempty"` + // ID of the key configuration for encrypting managed services. + ManagedServicesCustomerManagedKeyId *string `json:"managed_services_customer_managed_key_id,omitempty"` + // The network configuration for the workspace. DEPRECATED. Use `network_id` + // instead. + Network *WorkspaceNetwork `json:"network,omitempty"` + // The object ID of network connectivity config. + NetworkConnectivityConfigId *string `json:"network_connectivity_config_id,omitempty"` + NetworkId *string `json:"network_id,omitempty"` + PricingTier PricingTier `json:"pricing_tier,omitempty"` + // ID of the workspace's private access settings object. Only used for + // PrivateLink. You must specify this ID if you are using [AWS PrivateLink] for + // either front-end (user-to-workspace connection), back-end (data plane to + // control plane connection), or both connection types. + // + // Before configuring PrivateLink, read the [ article about + // PrivateLink].", + // + // [ article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html + // [AWS PrivateLink]: https://aws.amazon.com/privatelink/ + PrivateAccessSettingsId *string `json:"private_access_settings_id,omitempty"` + // ID of the workspace's storage configuration object. + StorageConfigurationId *string `json:"storage_configuration_id,omitempty"` + // ID of the key configuration for encrypting workspace storage. + StorageCustomerManagedKeyId *string `json:"storage_customer_managed_key_id,omitempty"` + // The storage mode of the workspace. + StorageMode StorageMode `json:"storage_mode,omitempty"` + // A unique integer ID for the workspace + WorkspaceId *int64 `json:"workspace_id,omitempty"` + // The human-readable name of the workspace. + WorkspaceName *string `json:"workspace_name,omitempty"` + // The status of a workspace + WorkspaceStatus WorkspaceStatus `json:"workspace_status,omitempty"` + // Message describing the current workspace status. + WorkspaceStatusMessage *string `json:"workspace_status_message,omitempty"` +} + +// The network configuration for workspaces.. +type WorkspaceNetwork struct { + // The shared network config for GCP workspace. This object has common network + // configurations that are network attributions of a workspace. This object is + // input-only. + GcpCommonNetworkConfig *GcpCommonNetworkConfig `json:"gcp_common_network_config,omitempty"` + GcpManagedNetworkConfig *GcpManagedNetworkConfig `json:"gcp_managed_network_config,omitempty"` + NetworkId *string `json:"network_id,omitempty"` +} + +// AzureWorkspaceInfoToSDK converts the mirror to the sdk-go type. +func AzureWorkspaceInfoToSDK(w *AzureWorkspaceInfo) (*sdk.AzureWorkspaceInfo, error) { + if w == nil { + return nil, nil + } + out := &sdk.AzureWorkspaceInfo{} + out.ResourceGroup = w.ResourceGroup + out.SubscriptionId = w.SubscriptionId + return out, nil +} + +// AzureWorkspaceInfoFromSDK converts the sdk-go type to the mirror. +func AzureWorkspaceInfoFromSDK(v *sdk.AzureWorkspaceInfo) (*AzureWorkspaceInfo, error) { + if v == nil { + return nil, nil + } + out := &AzureWorkspaceInfo{} + out.ResourceGroup = v.ResourceGroup + out.SubscriptionId = v.SubscriptionId + return out, nil +} + +// CloudResourceContainerToSDK converts the mirror to the sdk-go type. +func CloudResourceContainerToSDK(w *CloudResourceContainer) (*sdk.CloudResourceContainer, error) { + if w == nil { + return nil, nil + } + out := &sdk.CloudResourceContainer{} + { + var members []string + if w.Gcp != nil { + members = append(members, "gcp") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.Gcp != nil: + conv1, err := GcpCloudResourceContainerToSDK(w.Gcp) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CloudResourceContainer.CloudResourceContainer", err) + } + out.CloudResourceContainer = &sdk.CloudResourceContainer_CloudResourceContainer_Gcp{Gcp: *conv1} + } + return out, nil +} + +// CloudResourceContainerFromSDK converts the sdk-go type to the mirror. +func CloudResourceContainerFromSDK(v *sdk.CloudResourceContainer) (*CloudResourceContainer, error) { + if v == nil { + return nil, nil + } + out := &CloudResourceContainer{} + switch value := v.CloudResourceContainer.(type) { + case *sdk.CloudResourceContainer_CloudResourceContainer_Gcp: + if value != nil { + conv2, err := GcpCloudResourceContainerFromSDK(&value.Gcp) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CloudResourceContainer.CloudResourceContainer", err) + } + out.Gcp = conv2 + } + } + return out, nil +} + +// CreateWorkspaceRequestToSDK converts the mirror to the sdk-go type. +func CreateWorkspaceRequestToSDK(w *CreateWorkspaceRequest) (*sdk.CreateWorkspaceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.CreateWorkspaceRequest{} + out.AccountId = w.AccountId + out.WorkspaceName = w.WorkspaceName + out.DeploymentName = w.DeploymentName + out.AwsRegion = w.AwsRegion + out.Location = w.Location + out.Cloud = w.Cloud + out.PricingTier = w.PricingTier + conv3, err := CloudResourceContainerToSDK(w.CloudResourceContainer) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateWorkspaceRequest.CloudResourceContainer", err) + } + out.CloudResourceContainer = conv3 + out.CredentialsId = w.CredentialsId + out.StorageConfigurationId = w.StorageConfigurationId + out.NetworkId = w.NetworkId + conv4, err := GcpManagedNetworkConfigToSDK(w.GcpManagedNetworkConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateWorkspaceRequest.GcpManagedNetworkConfig", err) + } + out.GcpManagedNetworkConfig = conv4 + conv5, err := GkeConfigToSDK(w.GkeConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateWorkspaceRequest.GkeConfig", err) + } + out.GkeConfig = conv5 + out.PrivateAccessSettingsId = w.PrivateAccessSettingsId + out.ManagedServicesCustomerManagedKeyId = w.ManagedServicesCustomerManagedKeyId + out.StorageCustomerManagedKeyId = w.StorageCustomerManagedKeyId + out.CustomTags = w.CustomTags + out.ComputeMode = w.ComputeMode + out.NetworkConnectivityConfigId = w.NetworkConnectivityConfigId + return out, nil +} + +// CreateWorkspaceRequestFromSDK converts the sdk-go type to the mirror. +func CreateWorkspaceRequestFromSDK(v *sdk.CreateWorkspaceRequest) (*CreateWorkspaceRequest, error) { + if v == nil { + return nil, nil + } + out := &CreateWorkspaceRequest{} + out.AccountId = v.AccountId + out.WorkspaceName = v.WorkspaceName + out.DeploymentName = v.DeploymentName + out.AwsRegion = v.AwsRegion + out.Location = v.Location + out.Cloud = v.Cloud + out.PricingTier = v.PricingTier + conv6, err := CloudResourceContainerFromSDK(v.CloudResourceContainer) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateWorkspaceRequest.CloudResourceContainer", err) + } + out.CloudResourceContainer = conv6 + out.CredentialsId = v.CredentialsId + out.StorageConfigurationId = v.StorageConfigurationId + out.NetworkId = v.NetworkId + conv7, err := GcpManagedNetworkConfigFromSDK(v.GcpManagedNetworkConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateWorkspaceRequest.GcpManagedNetworkConfig", err) + } + out.GcpManagedNetworkConfig = conv7 + conv8, err := GkeConfigFromSDK(v.GkeConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "CreateWorkspaceRequest.GkeConfig", err) + } + out.GkeConfig = conv8 + out.PrivateAccessSettingsId = v.PrivateAccessSettingsId + out.ManagedServicesCustomerManagedKeyId = v.ManagedServicesCustomerManagedKeyId + out.StorageCustomerManagedKeyId = v.StorageCustomerManagedKeyId + out.CustomTags = v.CustomTags + out.ComputeMode = v.ComputeMode + out.NetworkConnectivityConfigId = v.NetworkConnectivityConfigId + return out, nil +} + +// GcpCloudResourceContainerToSDK converts the mirror to the sdk-go type. +func GcpCloudResourceContainerToSDK(w *GcpCloudResourceContainer) (*sdk.GcpCloudResourceContainer, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpCloudResourceContainer{} + out.ProjectId = w.ProjectId + return out, nil +} + +// GcpCloudResourceContainerFromSDK converts the sdk-go type to the mirror. +func GcpCloudResourceContainerFromSDK(v *sdk.GcpCloudResourceContainer) (*GcpCloudResourceContainer, error) { + if v == nil { + return nil, nil + } + out := &GcpCloudResourceContainer{} + out.ProjectId = v.ProjectId + return out, nil +} + +// GcpCommonNetworkConfigToSDK converts the mirror to the sdk-go type. +func GcpCommonNetworkConfigToSDK(w *GcpCommonNetworkConfig) (*sdk.GcpCommonNetworkConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpCommonNetworkConfig{} + out.GkeConnectivityType = w.GkeConnectivityType + out.GkeClusterMasterIpRange = w.GkeClusterMasterIpRange + return out, nil +} + +// GcpCommonNetworkConfigFromSDK converts the sdk-go type to the mirror. +func GcpCommonNetworkConfigFromSDK(v *sdk.GcpCommonNetworkConfig) (*GcpCommonNetworkConfig, error) { + if v == nil { + return nil, nil + } + out := &GcpCommonNetworkConfig{} + out.GkeConnectivityType = v.GkeConnectivityType + out.GkeClusterMasterIpRange = v.GkeClusterMasterIpRange + return out, nil +} + +// GcpManagedNetworkConfigToSDK converts the mirror to the sdk-go type. +func GcpManagedNetworkConfigToSDK(w *GcpManagedNetworkConfig) (*sdk.GcpManagedNetworkConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.GcpManagedNetworkConfig{} + out.SubnetCidr = w.SubnetCidr + out.GkeClusterPodIpRange = w.GkeClusterPodIpRange + out.GkeClusterServiceIpRange = w.GkeClusterServiceIpRange + return out, nil +} + +// GcpManagedNetworkConfigFromSDK converts the sdk-go type to the mirror. +func GcpManagedNetworkConfigFromSDK(v *sdk.GcpManagedNetworkConfig) (*GcpManagedNetworkConfig, error) { + if v == nil { + return nil, nil + } + out := &GcpManagedNetworkConfig{} + out.SubnetCidr = v.SubnetCidr + out.GkeClusterPodIpRange = v.GkeClusterPodIpRange + out.GkeClusterServiceIpRange = v.GkeClusterServiceIpRange + return out, nil +} + +// GkeConfigToSDK converts the mirror to the sdk-go type. +func GkeConfigToSDK(w *GkeConfig) (*sdk.GkeConfig, error) { + if w == nil { + return nil, nil + } + out := &sdk.GkeConfig{} + out.ConnectivityType = w.ConnectivityType + out.MasterIpRange = w.MasterIpRange + return out, nil +} + +// GkeConfigFromSDK converts the sdk-go type to the mirror. +func GkeConfigFromSDK(v *sdk.GkeConfig) (*GkeConfig, error) { + if v == nil { + return nil, nil + } + out := &GkeConfig{} + out.ConnectivityType = v.ConnectivityType + out.MasterIpRange = v.MasterIpRange + return out, nil +} + +// UpdateWorkspaceRequestToSDK converts the mirror to the sdk-go type. +func UpdateWorkspaceRequestToSDK(w *UpdateWorkspaceRequest) (*sdk.UpdateWorkspaceRequest, error) { + if w == nil { + return nil, nil + } + out := &sdk.UpdateWorkspaceRequest{} + conv9, err := WorkspaceToSDK(w.CustomerFacingWorkspace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceRequest.CustomerFacingWorkspace", err) + } + out.CustomerFacingWorkspace = conv9 + mask10, err := fieldMaskFromString[sdk.Workspace](w.UpdateMask) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceRequest.UpdateMask", err) + } + out.UpdateMask = mask10 + return out, nil +} + +// UpdateWorkspaceRequestFromSDK converts the sdk-go type to the mirror. +func UpdateWorkspaceRequestFromSDK(v *sdk.UpdateWorkspaceRequest) (*UpdateWorkspaceRequest, error) { + if v == nil { + return nil, nil + } + out := &UpdateWorkspaceRequest{} + conv11, err := WorkspaceFromSDK(v.CustomerFacingWorkspace) + if err != nil { + return nil, fmt.Errorf("%s: %w", "UpdateWorkspaceRequest.CustomerFacingWorkspace", err) + } + out.CustomerFacingWorkspace = conv11 + out.UpdateMask = fieldMaskToString(v.UpdateMask) + return out, nil +} + +// WorkspaceToSDK converts the mirror to the sdk-go type. +func WorkspaceToSDK(w *Workspace) (*sdk.Workspace, error) { + if w == nil { + return nil, nil + } + out := &sdk.Workspace{} + out.WorkspaceId = w.WorkspaceId + out.WorkspaceName = w.WorkspaceName + out.AwsRegion = w.AwsRegion + out.CreationTime = w.CreationTime + out.DeploymentName = w.DeploymentName + out.WorkspaceStatus = w.WorkspaceStatus + out.AccountId = w.AccountId + out.CredentialsId = w.CredentialsId + out.StorageConfigurationId = w.StorageConfigurationId + out.WorkspaceStatusMessage = w.WorkspaceStatusMessage + { + var members []string + if w.NetworkId != nil { + members = append(members, "network_id") + } + if w.GcpManagedNetworkConfig != nil { + members = append(members, "gcp_managed_network_config") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.NetworkId != nil: + out.NetworkConfig = &sdk.Workspace_NetworkConfig_NetworkId{NetworkId: *w.NetworkId} + case w.GcpManagedNetworkConfig != nil: + conv12, err := GcpManagedNetworkConfigToSDK(w.GcpManagedNetworkConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Workspace.NetworkConfig", err) + } + out.NetworkConfig = &sdk.Workspace_NetworkConfig_GcpManagedNetworkConfig{GcpManagedNetworkConfig: *conv12} + } + out.PricingTier = w.PricingTier + out.PrivateAccessSettingsId = w.PrivateAccessSettingsId + out.ManagedServicesCustomerManagedKeyId = w.ManagedServicesCustomerManagedKeyId + out.StorageCustomerManagedKeyId = w.StorageCustomerManagedKeyId + out.Location = w.Location + out.Cloud = w.Cloud + conv13, err := WorkspaceNetworkToSDK(w.Network) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Workspace.Network", err) + } + out.Network = conv13 + conv14, err := AzureWorkspaceInfoToSDK(w.AzureWorkspaceInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Workspace.AzureWorkspaceInfo", err) + } + out.AzureWorkspaceInfo = conv14 + conv15, err := GkeConfigToSDK(w.GkeConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Workspace.GkeConfig", err) + } + out.GkeConfig = conv15 + conv16, err := CloudResourceContainerToSDK(w.CloudResourceContainer) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Workspace.CloudResourceContainer", err) + } + out.CloudResourceContainer = conv16 + out.CustomTags = w.CustomTags + out.NetworkConnectivityConfigId = w.NetworkConnectivityConfigId + out.StorageMode = w.StorageMode + out.ComputeMode = w.ComputeMode + out.ExpectedWorkspaceStatus = w.ExpectedWorkspaceStatus + return out, nil +} + +// WorkspaceFromSDK converts the sdk-go type to the mirror. +func WorkspaceFromSDK(v *sdk.Workspace) (*Workspace, error) { + if v == nil { + return nil, nil + } + out := &Workspace{} + out.WorkspaceId = v.WorkspaceId + out.WorkspaceName = v.WorkspaceName + out.AwsRegion = v.AwsRegion + out.CreationTime = v.CreationTime + out.DeploymentName = v.DeploymentName + out.WorkspaceStatus = v.WorkspaceStatus + out.AccountId = v.AccountId + out.CredentialsId = v.CredentialsId + out.StorageConfigurationId = v.StorageConfigurationId + out.WorkspaceStatusMessage = v.WorkspaceStatusMessage + switch value := v.NetworkConfig.(type) { + case *sdk.Workspace_NetworkConfig_NetworkId: + if value != nil { + out.NetworkId = new(value.NetworkId) + } + case *sdk.Workspace_NetworkConfig_GcpManagedNetworkConfig: + if value != nil { + conv17, err := GcpManagedNetworkConfigFromSDK(&value.GcpManagedNetworkConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Workspace.NetworkConfig", err) + } + out.GcpManagedNetworkConfig = conv17 + } + } + out.PricingTier = v.PricingTier + out.PrivateAccessSettingsId = v.PrivateAccessSettingsId + out.ManagedServicesCustomerManagedKeyId = v.ManagedServicesCustomerManagedKeyId + out.StorageCustomerManagedKeyId = v.StorageCustomerManagedKeyId + out.Location = v.Location + out.Cloud = v.Cloud + conv18, err := WorkspaceNetworkFromSDK(v.Network) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Workspace.Network", err) + } + out.Network = conv18 + conv19, err := AzureWorkspaceInfoFromSDK(v.AzureWorkspaceInfo) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Workspace.AzureWorkspaceInfo", err) + } + out.AzureWorkspaceInfo = conv19 + conv20, err := GkeConfigFromSDK(v.GkeConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Workspace.GkeConfig", err) + } + out.GkeConfig = conv20 + conv21, err := CloudResourceContainerFromSDK(v.CloudResourceContainer) + if err != nil { + return nil, fmt.Errorf("%s: %w", "Workspace.CloudResourceContainer", err) + } + out.CloudResourceContainer = conv21 + out.CustomTags = v.CustomTags + out.NetworkConnectivityConfigId = v.NetworkConnectivityConfigId + out.StorageMode = v.StorageMode + out.ComputeMode = v.ComputeMode + out.ExpectedWorkspaceStatus = v.ExpectedWorkspaceStatus + return out, nil +} + +// WorkspaceNetworkToSDK converts the mirror to the sdk-go type. +func WorkspaceNetworkToSDK(w *WorkspaceNetwork) (*sdk.WorkspaceNetwork, error) { + if w == nil { + return nil, nil + } + out := &sdk.WorkspaceNetwork{} + { + var members []string + if w.GcpManagedNetworkConfig != nil { + members = append(members, "gcp_managed_network_config") + } + if w.NetworkId != nil { + members = append(members, "network_id") + } + if len(members) > 1 { + return nil, fmt.Errorf("only one of %s can be set", strings.Join(members, ", ")) + } + } + switch { + case w.GcpManagedNetworkConfig != nil: + conv22, err := GcpManagedNetworkConfigToSDK(w.GcpManagedNetworkConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WorkspaceNetwork.Network", err) + } + out.Network = &sdk.WorkspaceNetwork_Network_GcpManagedNetworkConfig{GcpManagedNetworkConfig: *conv22} + case w.NetworkId != nil: + out.Network = &sdk.WorkspaceNetwork_Network_NetworkId{NetworkId: *w.NetworkId} + } + conv23, err := GcpCommonNetworkConfigToSDK(w.GcpCommonNetworkConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WorkspaceNetwork.GcpCommonNetworkConfig", err) + } + out.GcpCommonNetworkConfig = conv23 + return out, nil +} + +// WorkspaceNetworkFromSDK converts the sdk-go type to the mirror. +func WorkspaceNetworkFromSDK(v *sdk.WorkspaceNetwork) (*WorkspaceNetwork, error) { + if v == nil { + return nil, nil + } + out := &WorkspaceNetwork{} + switch value := v.Network.(type) { + case *sdk.WorkspaceNetwork_Network_GcpManagedNetworkConfig: + if value != nil { + conv24, err := GcpManagedNetworkConfigFromSDK(&value.GcpManagedNetworkConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WorkspaceNetwork.Network", err) + } + out.GcpManagedNetworkConfig = conv24 + } + case *sdk.WorkspaceNetwork_Network_NetworkId: + if value != nil { + out.NetworkId = new(value.NetworkId) + } + } + conv25, err := GcpCommonNetworkConfigFromSDK(v.GcpCommonNetworkConfig) + if err != nil { + return nil, fmt.Errorf("%s: %w", "WorkspaceNetwork.GcpCommonNetworkConfig", err) + } + out.GcpCommonNetworkConfig = conv25 + return out, nil +} + +func fieldMaskToString[T any](mask *types.FieldMask[T]) *string { + if mask == nil { + return nil + } + value := mask.String() + return &value +} + +func fieldMaskFromString[T any](s *string) (*types.FieldMask[T], error) { + if s == nil { + return nil, nil + } + var paths []string + if *s != "" { + paths = strings.Split(*s, ",") + } + return types.NewFieldMask[T](paths...) +} diff --git a/libs/snapshot/client.go b/libs/snapshot/client.go index 8539cf0bda5..e5b7a7c6758 100644 --- a/libs/snapshot/client.go +++ b/libs/snapshot/client.go @@ -10,9 +10,9 @@ import ( "net/textproto" "path" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/auth" - "github.com/databricks/databricks-sdk-go" - databricksclient "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/cli/libs/sdkclients" ) // SnapshotInfo holds the result of a successful snapshot upload. @@ -32,8 +32,8 @@ type ACLEntry struct { // SnapshotClient implements the /api/2.0/repos/snapshots endpoint. type SnapshotClient struct { - workspaceClient *databricks.WorkspaceClient - client *databricksclient.DatabricksClient + workspaceClient *sdkclients.Clients + client *apiclient.Client } // snapshotUploadResponse mirrors the /api/2.0/repos/snapshots response body. @@ -48,8 +48,8 @@ type snapshotRootPathResponse struct { } // NewSnapshotClient creates a SnapshotClient backed by /api/2.0/repos/snapshots. -func NewSnapshotClient(w *databricks.WorkspaceClient) (*SnapshotClient, error) { - c, err := databricksclient.New(w.Config) +func NewSnapshotClient(w *sdkclients.Clients) (*SnapshotClient, error) { + c, err := apiclient.New(w.Config) if err != nil { return nil, err } diff --git a/libs/sqlexec/fake_api_test.go b/libs/sqlexec/fake_api_test.go new file mode 100644 index 00000000000..6c4386d7c7a --- /dev/null +++ b/libs/sqlexec/fake_api_test.go @@ -0,0 +1,66 @@ +package sqlexec + +import ( + "context" + "encoding/json" + + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/options/call" + sql "github.com/databricks/sdk-go/statementexecution/v1" + "github.com/stretchr/testify/mock" +) + +// mockAPI is a testify mock of API. Calls are recorded by the identifiers the +// executor passes (statement ID, chunk index) so expectations stay readable. +type mockAPI struct { + mock.Mock +} + +func newMockAPI(t interface { + mock.TestingT + Cleanup(func()) +}, +) *mockAPI { + m := &mockAPI{} + m.Test(t) + t.Cleanup(func() { m.AssertExpectations(t) }) + return m +} + +func (m *mockAPI) ExecuteStatement(ctx context.Context, req sql.ExecuteStatementRequest, _ ...call.Option) (*sql.StatementResponse, error) { + args := m.Called(ctx, req) + resp, _ := args.Get(0).(*sql.StatementResponse) + return resp, args.Error(1) +} + +func (m *mockAPI) GetStatementResult(ctx context.Context, req sql.GetStatementResultRequest, _ ...call.Option) (*sql.StatementResponse, error) { + args := m.Called(ctx, utils.Deref(req.StatementId)) + resp, _ := args.Get(0).(*sql.StatementResponse) + return resp, args.Error(1) +} + +func (m *mockAPI) GetResultData(ctx context.Context, req sql.GetResultDataRequest, _ ...call.Option) (*sql.ResultData, error) { + args := m.Called(ctx, utils.Deref(req.StatementId), utils.Deref(req.ChunkIndex)) + resp, _ := args.Get(0).(*sql.ResultData) + return resp, args.Error(1) +} + +func (m *mockAPI) CancelStatement(ctx context.Context, req sql.CancelStatementRequest, _ ...call.Option) (*sql.CancelStatementResponse, error) { + args := m.Called(ctx, utils.Deref(req.StatementId)) + return &sql.CancelStatementResponse{}, args.Error(0) +} + +// rows encodes cells the way the API returns JSON_ARRAY results. +func rows(data [][]string) [][]json.RawMessage { + if data == nil { + return nil + } + out := make([][]json.RawMessage, len(data)) + for i, row := range data { + out[i] = make([]json.RawMessage, len(row)) + for j, cell := range row { + out[i][j], _ = json.Marshal(cell) + } + } + return out +} diff --git a/libs/sqlexec/sqlexec.go b/libs/sqlexec/sqlexec.go index 0615c2c5e49..1ec317fd00f 100644 --- a/libs/sqlexec/sqlexec.go +++ b/libs/sqlexec/sqlexec.go @@ -17,12 +17,24 @@ package sqlexec import ( "context" + "encoding/json" "fmt" "time" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/options/call" + sql "github.com/databricks/sdk-go/statementexecution/v1" ) +// API is the subset of the Statement Execution client the executor uses; +// *statementexecution.Client implements it. +type API interface { + ExecuteStatement(ctx context.Context, req sql.ExecuteStatementRequest, opts ...call.Option) (*sql.StatementResponse, error) + GetStatementResult(ctx context.Context, req sql.GetStatementResultRequest, opts ...call.Option) (*sql.StatementResponse, error) + GetResultData(ctx context.Context, req sql.GetResultDataRequest, opts ...call.Option) (*sql.ResultData, error) + CancelStatement(ctx context.Context, req sql.CancelStatementRequest, opts ...call.Option) (*sql.CancelStatementResponse, error) +} + const ( // asyncWaitTimeout is the wait applied to Submit. "0s" makes ExecuteStatement // return immediately with a statement ID (state PENDING) so callers can wire @@ -47,7 +59,7 @@ const ( // Client executes SQL statements against a single SQL warehouse. type Client struct { - api sql.StatementExecutionInterface + api API warehouseID string waitTimeout string @@ -76,7 +88,7 @@ func WithPollInterval(initial, max time.Duration) Option { } // New returns a Client that runs statements on warehouseID via api. -func New(api sql.StatementExecutionInterface, warehouseID string, opts ...Option) *Client { +func New(api API, warehouseID string, opts ...Option) *Client { c := &Client{ api: api, warehouseID: warehouseID, @@ -96,14 +108,14 @@ type RequestOption func(*sql.ExecuteStatementRequest) // WithParameters binds named parameters (`:name` markers) on the statement. // Parameter binding is server-side, so values need no manual quoting or // escaping; prefer it over string interpolation. -func WithParameters(params []sql.StatementParameterListItem) RequestOption { +func WithParameters(params []sql.StatementParameter) RequestOption { return func(req *sql.ExecuteStatementRequest) { req.Parameters = params } } // Statement is a handle to a submitted statement and its latest known state. type Statement struct { ID string - State sql.StatementState + State sql.StatementStatus_State // resp is the most recent response observed for the statement. It carries the // manifest and first result chunk needed by Results. @@ -112,7 +124,7 @@ type Statement struct { // newStatement wraps a response into a Statement handle. func newStatement(resp *sql.StatementResponse) *Statement { - s := &Statement{ID: resp.StatementId, resp: resp} + s := &Statement{ID: utils.Deref(resp.StatementId), resp: resp} if resp.Status != nil { s.State = resp.Status.State } @@ -130,7 +142,7 @@ func (s *Statement) Err() error { return &StatementError{Message: "statement response had no status"} } switch status.State { - case sql.StatementStateFailed, sql.StatementStateCanceled, sql.StatementStateClosed: + case sql.StatementStatus_State_Failed, sql.StatementStatus_State_Canceled, sql.StatementStatus_State_Closed: return newStatementError(status) default: // SUCCEEDED, PENDING, RUNNING: no error. @@ -150,7 +162,7 @@ func (s *Statement) Columns() []string { // FAILED case, an SQLSTATE); CANCELED and CLOSED carry no error object, so the // message is synthesized from the state. type StatementError struct { - State sql.StatementState + State sql.StatementStatus_State Code sql.ServiceErrorCode Message string SQLState string @@ -158,10 +170,10 @@ type StatementError struct { // newStatementError builds a StatementError from a terminal non-success status. func newStatementError(status *sql.StatementStatus) *StatementError { - e := &StatementError{State: status.State, SQLState: status.SqlState} + e := &StatementError{State: status.State, SQLState: utils.Deref(status.SqlState)} if status.Error != nil { e.Code = status.Error.ErrorCode - e.Message = status.Error.Message + e.Message = utils.Deref(status.Error.Message) } else { e.Message = fmt.Sprintf("statement reached terminal state %s", status.State) } @@ -182,10 +194,8 @@ type Result struct { Columns []string // Rows holds every result row with each cell as a string. A SQL NULL and an // empty string are indistinguishable here: the API wire format encodes NULL - // as JSON null (distinct from ""), but the SDK models cells as [][]string, so - // JSON null is decoded as "". The distinction is recoverable only with a - // null-aware cell type (e.g. [][]*string) or the ARROW_STREAM format; no - // caller needs it today, so we keep the simpler string rows. + // as JSON null (distinct from ""), and decodeRows maps it to "". No caller + // needs the distinction today, so we keep the simpler string rows. Rows [][]string } @@ -206,12 +216,12 @@ func (c *Client) Submit(ctx context.Context, statement string, opts ...RequestOp // submit issues ExecuteStatement with the given synchronous wait timeout. func (c *Client) submit(ctx context.Context, statement, waitTimeout string, opts []RequestOption) (*Statement, error) { req := sql.ExecuteStatementRequest{ - WarehouseId: c.warehouseID, - Statement: statement, - WaitTimeout: waitTimeout, - OnWaitTimeout: sql.ExecuteStatementRequestOnWaitTimeoutContinue, - Disposition: sql.DispositionInline, - Format: sql.FormatJsonArray, + WarehouseId: new(c.warehouseID), + Statement: new(statement), + WaitTimeout: new(waitTimeout), + OnWaitTimeout: sql.TimeoutAction_Continue, + Disposition: sql.Disposition_Inline, + Format: sql.Format_JsonArray, } for _, opt := range opts { opt(&req) @@ -240,7 +250,7 @@ func (c *Client) Poll(ctx context.Context, s *Statement) (*Statement, error) { case <-time.After(interval): } - resp, err := c.api.GetStatementByStatementId(ctx, s.ID) + resp, err := c.api.GetStatementResult(ctx, sql.GetStatementResultRequest{StatementId: new(s.ID)}) if err != nil { if ctx.Err() != nil { return nil, ctx.Err() @@ -255,7 +265,7 @@ func (c *Client) Poll(ctx context.Context, s *Statement) (*Statement, error) { // Get returns the current state of a statement with a single GET, no polling. func (c *Client) Get(ctx context.Context, statementID string) (*Statement, error) { - resp, err := c.api.GetStatementByStatementId(ctx, statementID) + resp, err := c.api.GetStatementResult(ctx, sql.GetStatementResultRequest{StatementId: new(statementID)}) if err != nil { return nil, fmt.Errorf("get statement %s: %w", statementID, err) } @@ -266,7 +276,7 @@ func (c *Client) Get(ctx context.Context, statementID string) (*Statement, error // only means the request was accepted; the statement may have already finished. // Poll or Get to observe the resulting state. func (c *Client) Cancel(ctx context.Context, statementID string) error { - if err := c.api.CancelExecution(ctx, sql.CancelExecutionRequest{StatementId: statementID}); err != nil { + if _, err := c.api.CancelStatement(ctx, sql.CancelStatementRequest{StatementId: new(statementID)}); err != nil { return fmt.Errorf("cancel statement %s: %w", statementID, err) } return nil @@ -280,19 +290,27 @@ func (c *Client) Results(ctx context.Context, s *Statement) (*Result, error) { if s.resp.Result == nil { return r, nil } - r.Rows = append(r.Rows, s.resp.Result.DataArray...) + rows, err := decodeRows(s.resp.Result.DataArray) + if err != nil { + return nil, fmt.Errorf("decode result of statement %s: %w", s.ID, err) + } + r.Rows = append(r.Rows, rows...) total := 0 if s.resp.Manifest != nil { - total = s.resp.Manifest.TotalChunkCount + total = utils.Deref(s.resp.Manifest.TotalChunkCount) } // Chunk 0 is already in resp.Result; fetch the rest in order. for chunk := 1; chunk < total; chunk++ { - data, err := c.api.GetStatementResultChunkNByStatementIdAndChunkIndex(ctx, s.ID, chunk) + data, err := c.api.GetResultData(ctx, sql.GetResultDataRequest{StatementId: new(s.ID), ChunkIndex: new(chunk)}) if err != nil { return nil, fmt.Errorf("fetch result chunk %d of statement %s: %w", chunk, s.ID, err) } - r.Rows = append(r.Rows, data.DataArray...) + rows, err := decodeRows(data.DataArray) + if err != nil { + return nil, fmt.Errorf("decode result chunk %d of statement %s: %w", chunk, s.ID, err) + } + r.Rows = append(r.Rows, rows...) } return r, nil } @@ -334,7 +352,7 @@ func isPending(status *sql.StatementStatus) bool { return false } switch status.State { - case sql.StatementStatePending, sql.StatementStateRunning: + case sql.StatementStatus_State_Pending, sql.StatementStatus_State_Running: return true default: return false @@ -349,7 +367,27 @@ func columns(manifest *sql.ResultManifest) []string { } out := make([]string, len(manifest.Schema.Columns)) for i, col := range manifest.Schema.Columns { - out[i] = col.Name + out[i] = utils.Deref(col.Name) } return out } + +// decodeRows converts JSON_ARRAY cells to strings. Every cell is a JSON string +// or null; null becomes "". +func decodeRows(data [][]json.RawMessage) ([][]string, error) { + if data == nil { + return nil, nil + } + rows := make([][]string, len(data)) + for i, row := range data { + rows[i] = make([]string, len(row)) + for j, cell := range row { + var v *string + if err := json.Unmarshal(cell, &v); err != nil { + return nil, fmt.Errorf("row %d, column %d: %w", i, j, err) + } + rows[i][j] = utils.Deref(v) + } + } + return rows, nil +} diff --git a/libs/sqlexec/sqlexec_http_test.go b/libs/sqlexec/sqlexec_http_test.go index 4c88a045367..744bd10f7fa 100644 --- a/libs/sqlexec/sqlexec_http_test.go +++ b/libs/sqlexec/sqlexec_http_test.go @@ -4,11 +4,12 @@ import ( "testing" "time" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/sqlexec" "github.com/databricks/cli/libs/testserver" "github.com/databricks/cli/libs/testserver/testsql" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/databricks-sdk-go/config" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -30,7 +31,7 @@ func newServer(t *testing.T) *testserver.Server { func httpClient(t *testing.T, server *testserver.Server) *sqlexec.Client { t.Helper() - w, err := databricks.NewWorkspaceClient(&databricks.Config{Host: server.URL, Token: "token"}) + w, err := sdkclients.New(t.Context(), &config.Config{Host: server.URL, Token: "token"}) require.NoError(t, err) // Tiny poll interval so the polling tests don't sleep. return sqlexec.New(w.StatementExecution, "wh-1", sqlexec.WithPollInterval(time.Millisecond, time.Millisecond)) @@ -75,14 +76,14 @@ func TestHTTPExecuteFailedReturns200(t *testing.T) { // A failed statement comes back as HTTP 200 with state=FAILED, not an HTTP // error; the engine must inspect the body and surface a *StatementError. server.HandleSQL("SELECT * FROM nope", func(testsql.Request) testsql.Result { - return testsql.Result{Error: &testsql.Error{Code: sql.ServiceErrorCodeBadRequest, Message: "no such table", SQLState: "42P01"}} + return testsql.Result{Error: &testsql.Error{Code: sql.ServiceErrorCode_BadRequest, Message: "no such table", SQLState: "42P01"}} }) _, err := httpClient(t, server).Execute(t.Context(), "SELECT * FROM nope") var se *sqlexec.StatementError require.ErrorAs(t, err, &se) - assert.Equal(t, sql.StatementStateFailed, se.State) - assert.Equal(t, sql.ServiceErrorCodeBadRequest, se.Code) + assert.Equal(t, sql.StatementStatus_State_Failed, se.State) + assert.Equal(t, sql.ServiceErrorCode_BadRequest, se.Code) assert.Equal(t, "no such table", se.Message) assert.Equal(t, "42P01", se.SQLState) } @@ -104,6 +105,6 @@ func TestHTTPSubmitAndCancel(t *testing.T) { stmt, err = c.Poll(ctx, stmt) require.NoError(t, err) - assert.Equal(t, sql.StatementStateCanceled, stmt.State) + assert.Equal(t, sql.StatementStatus_State_Canceled, stmt.State) require.Error(t, stmt.Err()) } diff --git a/libs/sqlexec/sqlexec_test.go b/libs/sqlexec/sqlexec_test.go index ce170d1043e..101d46dbca4 100644 --- a/libs/sqlexec/sqlexec_test.go +++ b/libs/sqlexec/sqlexec_test.go @@ -6,8 +6,7 @@ import ( "testing" "time" - mocksql "github.com/databricks/databricks-sdk-go/experimental/mocks/service/sql" - "github.com/databricks/databricks-sdk-go/service/sql" + sql "github.com/databricks/sdk-go/statementexecution/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -15,30 +14,30 @@ import ( // testClient returns a Client wired to a fresh mock with a near-zero poll // interval so polling tests don't sleep. -func testClient(t *testing.T) (*Client, *mocksql.MockStatementExecutionInterface) { - api := mocksql.NewMockStatementExecutionInterface(t) +func testClient(t *testing.T) (*Client, *mockAPI) { + api := newMockAPI(t) c := New(api, "wh-1", WithPollInterval(time.Millisecond, time.Millisecond)) return c, api } -func statusResp(state sql.StatementState) *sql.StatementResponse { - return &sql.StatementResponse{StatementId: "stmt-1", Status: &sql.StatementStatus{State: state}} +func statusResp(state sql.StatementStatus_State) *sql.StatementResponse { + return &sql.StatementResponse{StatementId: new("stmt-1"), Status: &sql.StatementStatus{State: state}} } func succeededResp(columns []string, dataArray [][]string) *sql.StatementResponse { - var schema *sql.ResultSchema + var schema *sql.Schema if columns != nil { cols := make([]sql.ColumnInfo, len(columns)) for i, name := range columns { - cols[i] = sql.ColumnInfo{Name: name} + cols[i] = sql.ColumnInfo{Name: new(name)} } - schema = &sql.ResultSchema{Columns: cols} + schema = &sql.Schema{Columns: cols} } return &sql.StatementResponse{ - StatementId: "stmt-1", - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, + StatementId: new("stmt-1"), + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, Manifest: &sql.ResultManifest{Schema: schema}, - Result: &sql.ResultData{DataArray: dataArray}, + Result: &sql.ResultData{DataArray: rows(dataArray)}, } } @@ -62,28 +61,28 @@ func TestExecuteScalar(t *testing.T) { { name: "failed surfaces backend code and message", resp: &sql.StatementResponse{ - StatementId: "stmt-1", + StatementId: new("stmt-1"), Status: &sql.StatementStatus{ - State: sql.StatementStateFailed, - SqlState: "42000", - Error: &sql.ServiceError{ErrorCode: sql.ServiceErrorCodeBadRequest, Message: "boom"}, + State: sql.StatementStatus_State_Failed, + SqlState: new("42000"), + Error: &sql.ServiceError{ErrorCode: sql.ServiceErrorCode_BadRequest, Message: new("boom")}, }, }, errSubstr: "boom", }, { name: "canceled is not treated as success", - resp: statusResp(sql.StatementStateCanceled), + resp: statusResp(sql.StatementStatus_State_Canceled), errSubstr: "terminal state CANCELED", }, { name: "closed is not treated as success", - resp: statusResp(sql.StatementStateClosed), + resp: statusResp(sql.StatementStatus_State_Closed), errSubstr: "terminal state CLOSED", }, { name: "missing status surfaces as error", - resp: &sql.StatementResponse{StatementId: "stmt-1"}, + resp: &sql.StatementResponse{StatementId: new("stmt-1")}, errSubstr: "no status", }, } @@ -91,7 +90,7 @@ func TestExecuteScalar(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { c, api := testClient(t) - api.EXPECT().ExecuteStatement(mock.Anything, mock.Anything).Return(tt.resp, nil).Once() + api.On("ExecuteStatement", mock.Anything, mock.Anything).Return(tt.resp, nil).Once() got, err := c.ExecuteScalar(t.Context(), "SELECT 1") if tt.errSubstr != "" { @@ -108,8 +107,8 @@ func TestExecuteScalar(t *testing.T) { func TestExecuteDDLReturnsEmptyResult(t *testing.T) { c, api := testClient(t) // DDL responses carry a status but no manifest or result block. - api.EXPECT().ExecuteStatement(mock.Anything, mock.Anything). - Return(statusResp(sql.StatementStateSucceeded), nil).Once() + api.On("ExecuteStatement", mock.Anything, mock.Anything). + Return(statusResp(sql.StatementStatus_State_Succeeded), nil).Once() r, err := c.Execute(t.Context(), "CREATE VIEW v") require.NoError(t, err) @@ -120,7 +119,7 @@ func TestExecuteDDLReturnsEmptyResult(t *testing.T) { func TestExecuteSubmitTransportError(t *testing.T) { c, api := testClient(t) - api.EXPECT().ExecuteStatement(mock.Anything, mock.Anything). + api.On("ExecuteStatement", mock.Anything, mock.Anything). Return(nil, errors.New("network down")).Once() _, err := c.Execute(t.Context(), "SELECT 1") @@ -131,11 +130,11 @@ func TestExecuteSubmitTransportError(t *testing.T) { func TestExecutePollsUntilTerminal(t *testing.T) { c, api := testClient(t) - api.EXPECT().ExecuteStatement(mock.Anything, mock.Anything). - Return(statusResp(sql.StatementStatePending), nil).Once() - api.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1"). - Return(statusResp(sql.StatementStateRunning), nil).Once() - api.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1"). + api.On("ExecuteStatement", mock.Anything, mock.Anything). + Return(statusResp(sql.StatementStatus_State_Pending), nil).Once() + api.On("GetStatementResult", mock.Anything, "stmt-1"). + Return(statusResp(sql.StatementStatus_State_Running), nil).Once() + api.On("GetStatementResult", mock.Anything, "stmt-1"). Return(succeededResp([]string{"n"}, [][]string{{"polled"}}), nil).Once() got, err := c.ExecuteScalar(t.Context(), "SELECT 1") @@ -144,14 +143,14 @@ func TestExecutePollsUntilTerminal(t *testing.T) { } func TestExecuteUsesSyncWaitTimeout(t *testing.T) { - api := mocksql.NewMockStatementExecutionInterface(t) + api := newMockAPI(t) c := New(api, "wh-1", WithWaitTimeout("25s")) - api.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.WaitTimeout == "25s" && - req.OnWaitTimeout == sql.ExecuteStatementRequestOnWaitTimeoutContinue && - req.Disposition == sql.DispositionInline && - req.Format == sql.FormatJsonArray && - req.WarehouseId == "wh-1" + api.On("ExecuteStatement", mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { + return *req.WaitTimeout == "25s" && + req.OnWaitTimeout == sql.TimeoutAction_Continue && + req.Disposition == sql.Disposition_Inline && + req.Format == sql.Format_JsonArray && + *req.WarehouseId == "wh-1" })).Return(succeededResp(nil, nil), nil).Once() _, err := c.Execute(t.Context(), "SELECT 1") @@ -160,18 +159,18 @@ func TestExecuteUsesSyncWaitTimeout(t *testing.T) { func TestSubmitIsAsyncAndForwardsParameters(t *testing.T) { c, api := testClient(t) - params := []sql.StatementParameterListItem{{Name: "since", Type: "DATE", Value: "2026-01-01"}} + params := []sql.StatementParameter{{Name: new("since"), Type: new("DATE"), Value: new("2026-01-01")}} - api.EXPECT().ExecuteStatement(mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { - return req.WaitTimeout == "0s" && - req.OnWaitTimeout == sql.ExecuteStatementRequestOnWaitTimeoutContinue && + api.On("ExecuteStatement", mock.Anything, mock.MatchedBy(func(req sql.ExecuteStatementRequest) bool { + return *req.WaitTimeout == "0s" && + req.OnWaitTimeout == sql.TimeoutAction_Continue && assert.ObjectsAreEqual(params, req.Parameters) - })).Return(statusResp(sql.StatementStatePending), nil).Once() + })).Return(statusResp(sql.StatementStatus_State_Pending), nil).Once() s, err := c.Submit(t.Context(), "SELECT :since", WithParameters(params)) require.NoError(t, err) assert.Equal(t, "stmt-1", s.ID) - assert.Equal(t, sql.StatementStatePending, s.State) + assert.Equal(t, sql.StatementStatus_State_Pending, s.State) } func TestPollImmediateTerminalDoesNotCallAPI(t *testing.T) { @@ -179,7 +178,7 @@ func TestPollImmediateTerminalDoesNotCallAPI(t *testing.T) { // No GetStatement expectation: a terminal statement must not be polled. s, err := c.Poll(t.Context(), newStatement(succeededResp(nil, nil))) require.NoError(t, err) - assert.Equal(t, sql.StatementStateSucceeded, s.State) + assert.Equal(t, sql.StatementStatus_State_Succeeded, s.State) } func TestPollContextCancellationDoesNotCancelServerSide(t *testing.T) { @@ -189,43 +188,41 @@ func TestPollContextCancellationDoesNotCancelServerSide(t *testing.T) { ctx, cancel := context.WithCancel(t.Context()) cancel() - _, err := c.Poll(ctx, newStatement(statusResp(sql.StatementStatePending))) + _, err := c.Poll(ctx, newStatement(statusResp(sql.StatementStatus_State_Pending))) require.ErrorIs(t, err, context.Canceled) } func TestPollWrapsGetError(t *testing.T) { c, api := testClient(t) - api.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1"). + api.On("GetStatementResult", mock.Anything, "stmt-1"). Return(nil, errors.New("boom")).Once() - _, err := c.Poll(t.Context(), newStatement(statusResp(sql.StatementStatePending))) + _, err := c.Poll(t.Context(), newStatement(statusResp(sql.StatementStatus_State_Pending))) require.Error(t, err) assert.Contains(t, err.Error(), "poll statement stmt-1") assert.Contains(t, err.Error(), "boom") } func TestPollGetErrorAfterCancellationReturnsContextErr(t *testing.T) { - api := mocksql.NewMockStatementExecutionInterface(t) + api := newMockAPI(t) c := New(api, "wh-1", WithPollInterval(time.Millisecond, time.Millisecond)) ctx, cancel := context.WithCancel(t.Context()) // Simulate the context being cancelled while the GET is in flight: the call // fails, but Poll must surface the context error, not the transport error. - api.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1"). - RunAndReturn(func(context.Context, string) (*sql.StatementResponse, error) { - cancel() - return nil, errors.New("cancelled mid-flight") - }).Once() + api.On("GetStatementResult", mock.Anything, "stmt-1"). + Run(func(mock.Arguments) { cancel() }). + Return(nil, errors.New("cancelled mid-flight")).Once() - _, err := c.Poll(ctx, newStatement(statusResp(sql.StatementStatePending))) + _, err := c.Poll(ctx, newStatement(statusResp(sql.StatementStatus_State_Pending))) require.ErrorIs(t, err, context.Canceled) } func TestExecuteReturnsPollError(t *testing.T) { c, api := testClient(t) - api.EXPECT().ExecuteStatement(mock.Anything, mock.Anything). - Return(statusResp(sql.StatementStatePending), nil).Once() - api.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-1"). + api.On("ExecuteStatement", mock.Anything, mock.Anything). + Return(statusResp(sql.StatementStatus_State_Pending), nil).Once() + api.On("GetStatementResult", mock.Anything, "stmt-1"). Return(nil, errors.New("boom")).Once() _, err := c.Execute(t.Context(), "SELECT 1") @@ -236,11 +233,11 @@ func TestExecuteReturnsPollError(t *testing.T) { func TestResultsPaginatesChunks(t *testing.T) { c, api := testClient(t) resp := succeededResp([]string{"n"}, [][]string{{"0"}}) - resp.Manifest.TotalChunkCount = 3 - api.EXPECT().GetStatementResultChunkNByStatementIdAndChunkIndex(mock.Anything, "stmt-1", 1). - Return(&sql.ResultData{DataArray: [][]string{{"1"}}}, nil).Once() - api.EXPECT().GetStatementResultChunkNByStatementIdAndChunkIndex(mock.Anything, "stmt-1", 2). - Return(&sql.ResultData{DataArray: [][]string{{"2"}}}, nil).Once() + resp.Manifest.TotalChunkCount = new(3) + api.On("GetResultData", mock.Anything, "stmt-1", 1). + Return(&sql.ResultData{DataArray: rows([][]string{{"1"}})}, nil).Once() + api.On("GetResultData", mock.Anything, "stmt-1", 2). + Return(&sql.ResultData{DataArray: rows([][]string{{"2"}})}, nil).Once() r, err := c.Results(t.Context(), newStatement(resp)) require.NoError(t, err) @@ -251,8 +248,8 @@ func TestResultsPaginatesChunks(t *testing.T) { func TestResultsChunkFetchError(t *testing.T) { c, api := testClient(t) resp := succeededResp([]string{"n"}, [][]string{{"0"}}) - resp.Manifest.TotalChunkCount = 2 - api.EXPECT().GetStatementResultChunkNByStatementIdAndChunkIndex(mock.Anything, "stmt-1", 1). + resp.Manifest.TotalChunkCount = new(2) + api.On("GetResultData", mock.Anything, "stmt-1", 1). Return(nil, errors.New("throttled")).Once() _, err := c.Results(t.Context(), newStatement(resp)) @@ -263,7 +260,7 @@ func TestResultsChunkFetchError(t *testing.T) { func TestResultsNoResultBlock(t *testing.T) { c, _ := testClient(t) - r, err := c.Results(t.Context(), newStatement(statusResp(sql.StatementStateSucceeded))) + r, err := c.Results(t.Context(), newStatement(statusResp(sql.StatementStatus_State_Succeeded))) require.NoError(t, err) assert.Nil(t, r.Columns) assert.Nil(t, r.Rows) @@ -271,17 +268,17 @@ func TestResultsNoResultBlock(t *testing.T) { func TestGet(t *testing.T) { c, api := testClient(t) - api.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-9"). - Return(statusResp(sql.StatementStateRunning), nil).Once() + api.On("GetStatementResult", mock.Anything, "stmt-9"). + Return(statusResp(sql.StatementStatus_State_Running), nil).Once() s, err := c.Get(t.Context(), "stmt-9") require.NoError(t, err) - assert.Equal(t, sql.StatementStateRunning, s.State) + assert.Equal(t, sql.StatementStatus_State_Running, s.State) } func TestGetWrapsError(t *testing.T) { c, api := testClient(t) - api.EXPECT().GetStatementByStatementId(mock.Anything, "stmt-9"). + api.On("GetStatementResult", mock.Anything, "stmt-9"). Return(nil, errors.New("nope")).Once() _, err := c.Get(t.Context(), "stmt-9") @@ -291,14 +288,14 @@ func TestGetWrapsError(t *testing.T) { func TestCancel(t *testing.T) { c, api := testClient(t) - api.EXPECT().CancelExecution(mock.Anything, sql.CancelExecutionRequest{StatementId: "stmt-1"}). + api.On("CancelStatement", mock.Anything, "stmt-1"). Return(nil).Once() require.NoError(t, c.Cancel(t.Context(), "stmt-1")) } func TestCancelWrapsError(t *testing.T) { c, api := testClient(t) - api.EXPECT().CancelExecution(mock.Anything, mock.Anything).Return(errors.New("gone")).Once() + api.On("CancelStatement", mock.Anything, mock.Anything).Return(errors.New("gone")).Once() err := c.Cancel(t.Context(), "stmt-1") require.Error(t, err) assert.Contains(t, err.Error(), "cancel statement stmt-1") @@ -313,23 +310,23 @@ func TestStatementErr(t *testing.T) { wantCode sql.ServiceErrorCode wantMsg string }{ - {name: "succeeded", resp: statusResp(sql.StatementStateSucceeded)}, - {name: "pending", resp: statusResp(sql.StatementStatePending)}, - {name: "running", resp: statusResp(sql.StatementStateRunning)}, + {name: "succeeded", resp: statusResp(sql.StatementStatus_State_Succeeded)}, + {name: "pending", resp: statusResp(sql.StatementStatus_State_Pending)}, + {name: "running", resp: statusResp(sql.StatementStatus_State_Running)}, { name: "failed with service error", resp: &sql.StatementResponse{Status: &sql.StatementStatus{ - State: sql.StatementStateFailed, - SqlState: "42000", - Error: &sql.ServiceError{ErrorCode: sql.ServiceErrorCodeBadRequest, Message: "bad"}, + State: sql.StatementStatus_State_Failed, + SqlState: new("42000"), + Error: &sql.ServiceError{ErrorCode: sql.ServiceErrorCode_BadRequest, Message: new("bad")}, }}, wantErr: true, - wantCode: sql.ServiceErrorCodeBadRequest, + wantCode: sql.ServiceErrorCode_BadRequest, wantMsg: "bad", }, { name: "canceled without error object", - resp: statusResp(sql.StatementStateCanceled), + resp: statusResp(sql.StatementStatus_State_Canceled), wantErr: true, wantMsg: "statement reached terminal state CANCELED", }, @@ -358,10 +355,10 @@ func TestStatementErr(t *testing.T) { } func TestStatementErrorError(t *testing.T) { - withCode := &StatementError{Code: sql.ServiceErrorCodeBadRequest, Message: "bad"} + withCode := &StatementError{Code: sql.ServiceErrorCode_BadRequest, Message: "bad"} assert.Equal(t, "statement failed: BAD_REQUEST: bad", withCode.Error()) - noCode := &StatementError{State: sql.StatementStateCanceled, Message: "statement reached terminal state CANCELED"} + noCode := &StatementError{State: sql.StatementStatus_State_Canceled, Message: "statement reached terminal state CANCELED"} assert.Equal(t, "statement reached terminal state CANCELED", noCode.Error()) } @@ -374,5 +371,5 @@ func TestResultScalar(t *testing.T) { func TestStatementColumns(t *testing.T) { assert.Equal(t, []string{"a", "b"}, newStatement(succeededResp([]string{"a", "b"}, nil)).Columns()) // No manifest (e.g. a DDL response): no columns. - assert.Nil(t, newStatement(statusResp(sql.StatementStateSucceeded)).Columns()) + assert.Nil(t, newStatement(statusResp(sql.StatementStatus_State_Succeeded)).Columns()) } diff --git a/libs/sqllegacy/client.go b/libs/sqllegacy/client.go new file mode 100644 index 00000000000..6ad5deb1321 --- /dev/null +++ b/libs/sqllegacy/client.go @@ -0,0 +1,61 @@ +// Package sqllegacy is a client for the subset of the legacy Databricks SQL +// API (/api/2.0/preview/sql/...) that the CLI uses outside generated +// commands. sdk-go does not provide these endpoints. +package sqllegacy + +import ( + "context" + "net/http" + + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/listing" +) + +// Client calls the legacy SQL API. +type Client struct { + client *apiclient.Client +} + +func New(c *apiclient.Client) *Client { + return &Client{client: c} +} + +func (a *Client) headers() map[string]string { + headers := map[string]string{"Accept": "application/json"} + a.client.AddWorkspaceIDHeader(headers) + return headers +} + +// ListDashboards pages through legacy dashboards, starting from page 1. +func (a *Client) ListDashboards(ctx context.Context, request ListDashboardsRequest) listing.Iterator[Dashboard] { + request.Page = 1 + getNextPage := func(ctx context.Context, req ListDashboardsRequest) (*ListResponse, error) { + var resp ListResponse + err := a.client.Do(ctx, http.MethodGet, "/api/2.0/preview/sql/dashboards", a.headers(), nil, apiclient.URLQuery(req), &resp) + return &resp, err + } + getItems := func(resp *ListResponse) []Dashboard { + return resp.Results + } + getNextReq := func(resp *ListResponse) *ListDashboardsRequest { + if len(resp.Results) == 0 { + return nil + } + request.Page = resp.Page + 1 + return &request + } + return listing.NewIterator(&request, getNextPage, getItems, getNextReq) +} + +// ListDashboardsAll returns all legacy dashboards, at most PageSize of them +// when it is set. +func (a *Client) ListDashboardsAll(ctx context.Context, request ListDashboardsRequest) ([]Dashboard, error) { + return listing.ToSliceN[Dashboard, int](ctx, a.ListDashboards(ctx, request), request.PageSize) +} + +// ListDataSources returns the SQL warehouses usable as legacy query data sources. +func (a *Client) ListDataSources(ctx context.Context) ([]DataSource, error) { + var dataSources []DataSource + err := a.client.Do(ctx, http.MethodGet, "/api/2.0/preview/sql/data_sources", a.headers(), nil, nil, &dataSources) + return dataSources, err +} diff --git a/libs/sqllegacy/model.go b/libs/sqllegacy/model.go new file mode 100644 index 00000000000..8d29ba16ee9 --- /dev/null +++ b/libs/sqllegacy/model.go @@ -0,0 +1,682 @@ +// Code ported from github.com/databricks/databricks-sdk-go /service/sql/model.go. + +package sqllegacy + +import ( + "fmt" +) + +// A JSON representing a dashboard containing widgets of visualizations and text +// boxes. +type Dashboard struct { + // Whether the authenticated user can edit the query definition. + CanEdit bool `json:"can_edit,omitempty"` + // Timestamp when this dashboard was created. + CreatedAt string `json:"created_at,omitempty"` + // In the web application, query filters that share a name are coupled to a + // single selection box if this value is `true`. + DashboardFiltersEnabled bool `json:"dashboard_filters_enabled,omitempty"` + // The ID for this dashboard. + Id string `json:"id,omitempty"` + // Indicates whether a dashboard is trashed. Trashed dashboards won't appear + // in list views. If this boolean is `true`, the `options` property for this + // dashboard includes a `moved_to_trash_at` timestamp. Items in trash are + // permanently deleted after 30 days. + IsArchived bool `json:"is_archived,omitempty"` + // Whether a dashboard is a draft. Draft dashboards only appear in list + // views for their owners. + IsDraft bool `json:"is_draft,omitempty"` + // Indicates whether this query object appears in the current user's + // favorites list. This flag determines whether the star icon for favorites + // is selected. + IsFavorite bool `json:"is_favorite,omitempty"` + // The title of the dashboard that appears in list views and at the top of + // the dashboard page. + Name string `json:"name,omitempty"` + + Options *DashboardOptions `json:"options,omitempty"` + // The identifier of the workspace folder containing the object. + Parent string `json:"parent,omitempty"` + // * `CAN_VIEW`: Can view the query * `CAN_RUN`: Can run the query * + // `CAN_EDIT`: Can edit the query * `CAN_MANAGE`: Can manage the query + PermissionTier PermissionLevel `json:"permission_tier,omitempty"` + // URL slug. Usually mirrors the query name with dashes (`-`) instead of + // spaces. Appears in the URL for this query. + Slug string `json:"slug,omitempty"` + + Tags []string `json:"tags,omitempty"` + // Timestamp when this dashboard was last updated. + UpdatedAt string `json:"updated_at,omitempty"` + + User *User `json:"user,omitempty"` + // The ID of the user who owns the dashboard. + UserId int `json:"user_id,omitempty"` + + Widgets []Widget `json:"widgets,omitempty"` +} + +type DashboardOptions struct { + // The timestamp when this dashboard was moved to trash. Only present when + // the `is_archived` property is `true`. Trashed items are deleted after + // thirty days. + MovedToTrashAt string `json:"moved_to_trash_at,omitempty"` +} + +// A JSON object representing a DBSQL data source / SQL warehouse. +type DataSource struct { + // Data source ID maps to the ID of the data source used by the resource and + // is distinct from the warehouse ID. [Learn more] + // + // [Learn more]: https://docs.databricks.com/api/workspace/datasources/list + Id string `json:"id,omitempty"` + // The string name of this data source / SQL warehouse as it appears in the + // Databricks SQL web application. + Name string `json:"name,omitempty"` + // Reserved for internal use. + PauseReason string `json:"pause_reason,omitempty"` + // Reserved for internal use. + Paused int `json:"paused,omitempty"` + // Reserved for internal use. + SupportsAutoLimit bool `json:"supports_auto_limit,omitempty"` + // Reserved for internal use. + Syntax string `json:"syntax,omitempty"` + // The type of data source. For SQL warehouses, this will be + // `databricks_internal`. + Type string `json:"type,omitempty"` + // Reserved for internal use. + ViewOnly bool `json:"view_only,omitempty"` + // The ID of the associated SQL warehouse, if this data source is backed by + // a SQL warehouse. + WarehouseId string `json:"warehouse_id,omitempty"` +} + +type DatePrecision string + +const DatePrecisionDayPrecision DatePrecision = `DAY_PRECISION` + +const DatePrecisionMinutePrecision DatePrecision = `MINUTE_PRECISION` + +const DatePrecisionSecondPrecision DatePrecision = `SECOND_PRECISION` + +type DateRange struct { + End string `json:"end"` + + Start string `json:"start"` +} + +type DateRangeValue struct { + // Manually specified date-time range value. + DateRangeValue *DateRange `json:"date_range_value,omitempty"` + // Dynamic date-time range value based on current date-time. + DynamicDateRangeValue DateRangeValueDynamicDateRange `json:"dynamic_date_range_value,omitempty"` + // Date-time precision to format the value into when the query is run. + // Defaults to DAY_PRECISION (YYYY-MM-DD). + Precision DatePrecision `json:"precision,omitempty"` + + StartDayOfWeek int `json:"start_day_of_week,omitempty"` +} + +type DateRangeValueDynamicDateRange string + +const DateRangeValueDynamicDateRangeLast12Months DateRangeValueDynamicDateRange = `LAST_12_MONTHS` + +const DateRangeValueDynamicDateRangeLast14Days DateRangeValueDynamicDateRange = `LAST_14_DAYS` + +const DateRangeValueDynamicDateRangeLast24Hours DateRangeValueDynamicDateRange = `LAST_24_HOURS` + +const DateRangeValueDynamicDateRangeLast30Days DateRangeValueDynamicDateRange = `LAST_30_DAYS` + +const DateRangeValueDynamicDateRangeLast60Days DateRangeValueDynamicDateRange = `LAST_60_DAYS` + +const DateRangeValueDynamicDateRangeLast7Days DateRangeValueDynamicDateRange = `LAST_7_DAYS` + +const DateRangeValueDynamicDateRangeLast8Hours DateRangeValueDynamicDateRange = `LAST_8_HOURS` + +const DateRangeValueDynamicDateRangeLast90Days DateRangeValueDynamicDateRange = `LAST_90_DAYS` + +const DateRangeValueDynamicDateRangeLastHour DateRangeValueDynamicDateRange = `LAST_HOUR` + +const DateRangeValueDynamicDateRangeLastMonth DateRangeValueDynamicDateRange = `LAST_MONTH` + +const DateRangeValueDynamicDateRangeLastWeek DateRangeValueDynamicDateRange = `LAST_WEEK` + +const DateRangeValueDynamicDateRangeLastYear DateRangeValueDynamicDateRange = `LAST_YEAR` + +const DateRangeValueDynamicDateRangeThisMonth DateRangeValueDynamicDateRange = `THIS_MONTH` + +const DateRangeValueDynamicDateRangeThisWeek DateRangeValueDynamicDateRange = `THIS_WEEK` + +const DateRangeValueDynamicDateRangeThisYear DateRangeValueDynamicDateRange = `THIS_YEAR` + +const DateRangeValueDynamicDateRangeToday DateRangeValueDynamicDateRange = `TODAY` + +const DateRangeValueDynamicDateRangeYesterday DateRangeValueDynamicDateRange = `YESTERDAY` + +type DateValue struct { + // Manually specified date-time value. + DateValue string `json:"date_value,omitempty"` + // Dynamic date-time value based on current date-time. + DynamicDateValue DateValueDynamicDate `json:"dynamic_date_value,omitempty"` + // Date-time precision to format the value into when the query is run. + // Defaults to DAY_PRECISION (YYYY-MM-DD). + Precision DatePrecision `json:"precision,omitempty"` +} + +type DateValueDynamicDate string + +const DateValueDynamicDateNow DateValueDynamicDate = `NOW` + +const DateValueDynamicDateYesterday DateValueDynamicDate = `YESTERDAY` + +type EnumValue struct { + // List of valid query parameter values, newline delimited. + EnumOptions string `json:"enum_options,omitempty"` + // If specified, allows multiple values to be selected for this parameter. + MultiValuesOptions *MultiValuesOptions `json:"multi_values_options,omitempty"` + // List of selected query parameter values. + Values []string `json:"values,omitempty"` +} + +type LegacyQuery struct { + // Describes whether the authenticated user is allowed to edit the + // definition of this query. + CanEdit bool `json:"can_edit,omitempty"` + // The timestamp when this query was created. + CreatedAt string `json:"created_at,omitempty"` + // Data source ID maps to the ID of the data source used by the resource and + // is distinct from the warehouse ID. [Learn more] + // + // [Learn more]: https://docs.databricks.com/api/workspace/datasources/list + DataSourceId string `json:"data_source_id,omitempty"` + // General description that conveys additional information about this query + // such as usage notes. + Description string `json:"description,omitempty"` + // Query ID. + Id string `json:"id,omitempty"` + // Indicates whether the query is trashed. Trashed queries can't be used in + // dashboards, or appear in search results. If this boolean is `true`, the + // `options` property for this query includes a `moved_to_trash_at` + // timestamp. Trashed queries are permanently deleted after 30 days. + IsArchived bool `json:"is_archived,omitempty"` + // Whether the query is a draft. Draft queries only appear in list views for + // their owners. Visualizations from draft queries cannot appear on + // dashboards. + IsDraft bool `json:"is_draft,omitempty"` + // Whether this query object appears in the current user's favorites list. + // This flag determines whether the star icon for favorites is selected. + IsFavorite bool `json:"is_favorite,omitempty"` + // Text parameter types are not safe from SQL injection for all types of + // data source. Set this Boolean parameter to `true` if a query either does + // not use any text type parameters or uses a data source type where text + // type parameters are handled safely. + IsSafe bool `json:"is_safe,omitempty"` + + LastModifiedBy *User `json:"last_modified_by,omitempty"` + // The ID of the user who last saved changes to this query. + LastModifiedById int `json:"last_modified_by_id,omitempty"` + // If there is a cached result for this query and user, this field includes + // the query result ID. If this query uses parameters, this field is always + // null. + LatestQueryDataId string `json:"latest_query_data_id,omitempty"` + // The title of this query that appears in list views, widget headings, and + // on the query page. + Name string `json:"name,omitempty"` + + Options *QueryOptions `json:"options,omitempty"` + // The identifier of the workspace folder containing the object. + Parent string `json:"parent,omitempty"` + // * `CAN_VIEW`: Can view the query * `CAN_RUN`: Can run the query * + // `CAN_EDIT`: Can edit the query * `CAN_MANAGE`: Can manage the query + PermissionTier PermissionLevel `json:"permission_tier,omitempty"` + // The text of the query to be run. + Query string `json:"query,omitempty"` + // A SHA-256 hash of the query text along with the authenticated user ID. + QueryHash string `json:"query_hash,omitempty"` + // Sets the **Run as** role for the object. Must be set to one of `"viewer"` + // (signifying "run as viewer" behavior) or `"owner"` (signifying "run as + // owner" behavior) + RunAsRole RunAsRole `json:"run_as_role,omitempty"` + + Tags []string `json:"tags,omitempty"` + // The timestamp at which this query was last updated. + UpdatedAt string `json:"updated_at,omitempty"` + + User *User `json:"user,omitempty"` + // The ID of the user who owns the query. + UserId int `json:"user_id,omitempty"` + + Visualizations []LegacyVisualization `json:"visualizations,omitempty"` +} + +// The visualization description API changes frequently and is unsupported. You +// can duplicate a visualization by copying description objects received _from +// the API_ and then using them to create a new one with a POST request to the +// same endpoint. Databricks does not recommend constructing ad-hoc +// visualizations entirely in JSON. +type LegacyVisualization struct { + CreatedAt string `json:"created_at,omitempty"` + // A short description of this visualization. This is not displayed in the + // UI. + Description string `json:"description,omitempty"` + // The UUID for this visualization. + Id string `json:"id,omitempty"` + // The name of the visualization that appears on dashboards and the query + // screen. + Name string `json:"name,omitempty"` + // The options object varies widely from one visualization type to the next + // and is unsupported. Databricks does not recommend modifying visualization + // settings in JSON. + Options any `json:"options,omitempty"` + + Query *LegacyQuery `json:"query,omitempty"` + // The type of visualization: chart, table, pivot table, and so on. + Type string `json:"type,omitempty"` + + UpdatedAt string `json:"updated_at,omitempty"` +} + +type LifecycleState string + +const LifecycleStateActive LifecycleState = `ACTIVE` + +const LifecycleStateTrashed LifecycleState = `TRASHED` + +type ListDashboardsRequest struct { + // Name of dashboard attribute to order by. + Order ListOrder `json:"-" url:"order,omitempty"` + // Page number to retrieve. + Page int `json:"-" url:"page,omitempty"` + // Number of dashboards to return per page. + PageSize int `json:"-" url:"page_size,omitempty"` + // Full text search term. + Q string `json:"-" url:"q,omitempty"` +} + +type ListOrder string + +const ListOrderCreatedAt ListOrder = `created_at` + +const ListOrderName ListOrder = `name` + +// String representation for [fmt.Print] +func (f *ListOrder) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *ListOrder) Set(v string) error { + switch v { + case `created_at`, `name`: + *f = ListOrder(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "created_at", "name"`, v) + } +} + +// Values returns all possible values for ListOrder. +// +// There is no guarantee on the order of the values in the slice. +func (f *ListOrder) Values() []ListOrder { + return []ListOrder{ + ListOrderCreatedAt, + ListOrderName, + } +} + +// Type always returns ListOrder to satisfy [pflag.Value] interface +func (f *ListOrder) Type() string { + return "ListOrder" +} + +type ListResponse struct { + // The total number of dashboards. + Count int `json:"count,omitempty"` + // The current page being displayed. + Page int `json:"page,omitempty"` + // The number of dashboards per page. + PageSize int `json:"page_size,omitempty"` + // List of dashboards returned. + Results []Dashboard `json:"results,omitempty"` +} + +type MultiValuesOptions struct { + // Character that prefixes each selected parameter value. + Prefix string `json:"prefix,omitempty"` + // Character that separates each selected parameter value. Defaults to a + // comma. + Separator string `json:"separator,omitempty"` + // Character that suffixes each selected parameter value. + Suffix string `json:"suffix,omitempty"` +} + +type NumericValue struct { + Value float64 `json:"value,omitempty"` +} + +type Parameter struct { + // List of valid parameter values, newline delimited. Only applies for + // dropdown list parameters. + EnumOptions string `json:"enumOptions,omitempty"` + // If specified, allows multiple values to be selected for this parameter. + // Only applies to dropdown list and query-based dropdown list parameters. + MultiValuesOptions *MultiValuesOptions `json:"multiValuesOptions,omitempty"` + // The literal parameter marker that appears between double curly braces in + // the query text. + Name string `json:"name,omitempty"` + // The UUID of the query that provides the parameter values. Only applies + // for query-based dropdown list parameters. + QueryId string `json:"queryId,omitempty"` + // The text displayed in a parameter picking widget. + Title string `json:"title,omitempty"` + // Parameters can have several different types. + Type ParameterType `json:"type,omitempty"` + // The default value for this parameter. + Value any `json:"value,omitempty"` +} + +type ParameterType string + +const ParameterTypeDatetime ParameterType = `datetime` + +const ParameterTypeEnum ParameterType = `enum` + +const ParameterTypeNumber ParameterType = `number` + +const ParameterTypeQuery ParameterType = `query` + +const ParameterTypeText ParameterType = `text` + +// String representation for [fmt.Print] +func (f *ParameterType) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *ParameterType) Set(v string) error { + switch v { + case `datetime`, `enum`, `number`, `query`, `text`: + *f = ParameterType(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "datetime", "enum", "number", "query", "text"`, v) + } +} + +// Values returns all possible values for ParameterType. +// +// There is no guarantee on the order of the values in the slice. +func (f *ParameterType) Values() []ParameterType { + return []ParameterType{ + ParameterTypeDatetime, + ParameterTypeEnum, + ParameterTypeNumber, + ParameterTypeQuery, + ParameterTypeText, + } +} + +// Type always returns ParameterType to satisfy [pflag.Value] interface +func (f *ParameterType) Type() string { + return "ParameterType" +} + +// * `CAN_VIEW`: Can view the query * `CAN_RUN`: Can run the query * `CAN_EDIT`: +// Can edit the query * `CAN_MANAGE`: Can manage the query +type PermissionLevel string + +// Can edit the query +const PermissionLevelCanEdit PermissionLevel = `CAN_EDIT` + +// Can manage the query +const PermissionLevelCanManage PermissionLevel = `CAN_MANAGE` + +// Can run the query +const PermissionLevelCanRun PermissionLevel = `CAN_RUN` + +// Can view the query +const PermissionLevelCanView PermissionLevel = `CAN_VIEW` + +// String representation for [fmt.Print] +func (f *PermissionLevel) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *PermissionLevel) Set(v string) error { + switch v { + case `CAN_EDIT`, `CAN_MANAGE`, `CAN_RUN`, `CAN_VIEW`: + *f = PermissionLevel(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "CAN_EDIT", "CAN_MANAGE", "CAN_RUN", "CAN_VIEW"`, v) + } +} + +// Values returns all possible values for PermissionLevel. +// +// There is no guarantee on the order of the values in the slice. +func (f *PermissionLevel) Values() []PermissionLevel { + return []PermissionLevel{ + PermissionLevelCanEdit, + PermissionLevelCanManage, + PermissionLevelCanRun, + PermissionLevelCanView, + } +} + +// Type always returns PermissionLevel to satisfy [pflag.Value] interface +func (f *PermissionLevel) Type() string { + return "PermissionLevel" +} + +type Query struct { + // Whether to apply a 1000 row limit to the query result. + ApplyAutoLimit bool `json:"apply_auto_limit,omitempty"` + // Name of the catalog where this query will be executed. + Catalog string `json:"catalog,omitempty"` + // Timestamp when this query was created. + CreateTime string `json:"create_time,omitempty"` + // General description that conveys additional information about this query + // such as usage notes. + Description string `json:"description,omitempty"` + // Display name of the query that appears in list views, widget headings, + // and on the query page. + DisplayName string `json:"display_name,omitempty"` + // UUID identifying the query. + Id string `json:"id,omitempty"` + // Username of the user who last saved changes to this query. + LastModifierUserName string `json:"last_modifier_user_name,omitempty"` + // Indicates whether the query is trashed. + LifecycleState LifecycleState `json:"lifecycle_state,omitempty"` + // Username of the user that owns the query. + OwnerUserName string `json:"owner_user_name,omitempty"` + // List of query parameter definitions. + Parameters []QueryParameter `json:"parameters,omitempty"` + // Workspace path of the workspace folder containing the object. + ParentPath string `json:"parent_path,omitempty"` + // Text of the query to be run. + QueryText string `json:"query_text,omitempty"` + // Sets the "Run as" role for the object. + RunAsMode RunAsMode `json:"run_as_mode,omitempty"` + // Name of the schema where this query will be executed. + Schema string `json:"schema,omitempty"` + + Tags []string `json:"tags,omitempty"` + // Timestamp when this query was last updated. + UpdateTime string `json:"update_time,omitempty"` + // ID of the SQL warehouse attached to the query. + WarehouseId string `json:"warehouse_id,omitempty"` +} + +type QueryBackedValue struct { + // If specified, allows multiple values to be selected for this parameter. + MultiValuesOptions *MultiValuesOptions `json:"multi_values_options,omitempty"` + // UUID of the query that provides the parameter values. + QueryId string `json:"query_id,omitempty"` + // List of selected query parameter values. + Values []string `json:"values,omitempty"` +} + +type QueryOptions struct { + // The name of the catalog to execute this query in. + Catalog string `json:"catalog,omitempty"` + // The timestamp when this query was moved to trash. Only present when the + // `is_archived` property is `true`. Trashed items are deleted after thirty + // days. + MovedToTrashAt string `json:"moved_to_trash_at,omitempty"` + + Parameters []Parameter `json:"parameters,omitempty"` + // The name of the schema to execute this query in. + Schema string `json:"schema,omitempty"` +} + +type QueryParameter struct { + // Date-range query parameter value. Can only specify one of + // `dynamic_date_range_value` or `date_range_value`. + DateRangeValue *DateRangeValue `json:"date_range_value,omitempty"` + // Date query parameter value. Can only specify one of `dynamic_date_value` + // or `date_value`. + DateValue *DateValue `json:"date_value,omitempty"` + // Dropdown query parameter value. + EnumValue *EnumValue `json:"enum_value,omitempty"` + // Literal parameter marker that appears between double curly braces in the + // query text. + Name string `json:"name,omitempty"` + // Numeric query parameter value. + NumericValue *NumericValue `json:"numeric_value,omitempty"` + // Query-based dropdown query parameter value. + QueryBackedValue *QueryBackedValue `json:"query_backed_value,omitempty"` + // Text query parameter value. + TextValue *TextValue `json:"text_value,omitempty"` + // Text displayed in the user-facing parameter widget in the UI. + Title string `json:"title,omitempty"` +} + +type RunAsMode string + +const RunAsModeOwner RunAsMode = `OWNER` + +const RunAsModeViewer RunAsMode = `VIEWER` + +type RunAsRole string + +const RunAsRoleOwner RunAsRole = `owner` + +const RunAsRoleViewer RunAsRole = `viewer` + +// String representation for [fmt.Print] +func (f *RunAsRole) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *RunAsRole) Set(v string) error { + switch v { + case `owner`, `viewer`: + *f = RunAsRole(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "owner", "viewer"`, v) + } +} + +// Values returns all possible values for RunAsRole. +// +// There is no guarantee on the order of the values in the slice. +func (f *RunAsRole) Values() []RunAsRole { + return []RunAsRole{ + RunAsRoleOwner, + RunAsRoleViewer, + } +} + +// Type always returns RunAsRole to satisfy [pflag.Value] interface +func (f *RunAsRole) Type() string { + return "RunAsRole" +} + +type TextValue struct { + Value string `json:"value,omitempty"` +} + +type User struct { + Email string `json:"email,omitempty"` + + Id int `json:"id,omitempty"` + + Name string `json:"name,omitempty"` +} + +type Visualization struct { + // The timestamp indicating when the visualization was created. + CreateTime string `json:"create_time,omitempty"` + // The display name of the visualization. + DisplayName string `json:"display_name,omitempty"` + // UUID identifying the visualization. + Id string `json:"id,omitempty"` + // UUID of the query that the visualization is attached to. + QueryId string `json:"query_id,omitempty"` + // The visualization options varies widely from one visualization type to + // the next and is unsupported. Databricks does not recommend modifying + // visualization options directly. + SerializedOptions string `json:"serialized_options,omitempty"` + // The visualization query plan varies widely from one visualization type to + // the next and is unsupported. Databricks does not recommend modifying the + // visualization query plan directly. + SerializedQueryPlan string `json:"serialized_query_plan,omitempty"` + // The type of visualization: counter, table, funnel, and so on. + Type string `json:"type,omitempty"` + // The timestamp indicating when the visualization was updated. + UpdateTime string `json:"update_time,omitempty"` +} + +type Widget struct { + // The unique ID for this widget. + Id string `json:"id,omitempty"` + + Options *WidgetOptions `json:"options,omitempty"` + // The visualization description API changes frequently and is unsupported. + // You can duplicate a visualization by copying description objects received + // _from the API_ and then using them to create a new one with a POST + // request to the same endpoint. Databricks does not recommend constructing + // ad-hoc visualizations entirely in JSON. + Visualization *LegacyVisualization `json:"visualization,omitempty"` + // Unused field. + Width int `json:"width,omitempty"` +} + +type WidgetOptions struct { + // Timestamp when this object was created + CreatedAt string `json:"created_at,omitempty"` + // Custom description of the widget + Description string `json:"description,omitempty"` + // Whether this widget is hidden on the dashboard. + IsHidden bool `json:"isHidden,omitempty"` + // How parameters used by the visualization in this widget relate to other + // widgets on the dashboard. Databricks does not recommend modifying this + // definition in JSON. + ParameterMappings any `json:"parameterMappings,omitempty"` + // Coordinates of this widget on a dashboard. This portion of the API + // changes frequently and is unsupported. + Position *WidgetPosition `json:"position,omitempty"` + // Custom title of the widget + Title string `json:"title,omitempty"` + // Timestamp of the last time this object was updated. + UpdatedAt string `json:"updated_at,omitempty"` +} + +// Coordinates of this widget on a dashboard. This portion of the API changes +// frequently and is unsupported. +type WidgetPosition struct { + // reserved for internal use + AutoHeight bool `json:"autoHeight,omitempty"` + // column in the dashboard grid. Values start with 0 + Col int `json:"col,omitempty"` + // row in the dashboard grid. Values start with 0 + Row int `json:"row,omitempty"` + // width of the widget measured in dashboard grid cells + SizeX int `json:"sizeX,omitempty"` + // height of the widget measured in dashboard grid cells + SizeY int `json:"sizeY,omitempty"` +} diff --git a/libs/structs/structaccess/bundle_test.go b/libs/structs/structaccess/bundle_test.go index 4de21ede392..72454b81607 100644 --- a/libs/structs/structaccess/bundle_test.go +++ b/libs/structs/structaccess/bundle_test.go @@ -6,8 +6,8 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/resources" - "github.com/databricks/databricks-sdk-go/service/apps" - "github.com/databricks/databricks-sdk-go/service/jobs" + apps "github.com/databricks/cli/libs/sdktypes/apps/v1" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/require" ) @@ -19,11 +19,11 @@ func TestGet_ConfigRoot_JobTagsAccess(t *testing.T) { ID: "jobid", BaseResource: resources.BaseResource{URL: "joburl"}, JobSettings: jobs.JobSettings{ - Name: "example", - Tasks: []jobs.Task{ + Name: new("example"), + Tasks: []jobs.TaskSettings{ { - TaskKey: "t1", - NotebookTask: &jobs.NotebookTask{NotebookPath: "/Workspace/Users/user@example.com/nb"}, + TaskKey: new("t1"), + NotebookTask: &jobs.NotebookTask{NotebookPath: new("/Workspace/Users/user@example.com/nb")}, }, }, Tags: map[string]string{ @@ -37,7 +37,7 @@ func TestGet_ConfigRoot_JobTagsAccess(t *testing.T) { "my_app": { BaseResource: resources.BaseResource{URL: "app_outer_url"}, App: apps.App{ - Url: "app_inner_url", + Url: new("app_inner_url"), }, }, }, @@ -79,9 +79,7 @@ func TestGet_ConfigRoot_JobTagsAccess(t *testing.T) { } // A bundle resource embeds a config struct that embeds the SDK request struct, so its -// fields sit two levels down. Get, Set and ValidatePath all have to reach them, and -// ForceSendFields belongs to the struct that declares the field -- not to the outer one -// that shadows the name. +// fields sit two levels down. Get, Set and ValidatePath all have to reach them. func TestGetSet_DoublyEmbeddedField(t *testing.T) { project := &resources.PostgresProject{} //exhaustruct:ignore project.ProjectId = "p" @@ -89,16 +87,15 @@ func TestGetSet_DoublyEmbeddedField(t *testing.T) { require.NoError(t, ValidateByString(reflect.TypeOf(project), "budget_policy_id")) require.NoError(t, SetByString(project, "budget_policy_id", "abc")) - require.Equal(t, "abc", project.BudgetPolicyId) + require.Equal(t, new("abc"), project.BudgetPolicyId) value, err := GetByString(project, "budget_policy_id") require.NoError(t, err) require.Equal(t, "abc", value) - // An explicit empty value is recorded on ProjectSpec, which declares the field. + // An explicit empty value is kept behind the pointer. require.NoError(t, SetByString(project, "budget_policy_id", "")) - require.Contains(t, project.ProjectSpec.ForceSendFields, "BudgetPolicyId") - require.NotContains(t, project.ForceSendFields, "BudgetPolicyId") + require.Equal(t, new(""), project.BudgetPolicyId) value, err = GetByString(project, "budget_policy_id") require.NoError(t, err) @@ -107,7 +104,7 @@ func TestGetSet_DoublyEmbeddedField(t *testing.T) { // And dropping it again leaves the field absent. require.NoError(t, SetByString(project, "budget_policy_id", nil)) - require.NotContains(t, project.ProjectSpec.ForceSendFields, "BudgetPolicyId") + require.Nil(t, project.BudgetPolicyId) value, err = GetByString(project, "budget_policy_id") require.NoError(t, err) require.Nil(t, value) diff --git a/libs/structs/structaccess/get.go b/libs/structs/structaccess/get.go index 9bd43bf4603..a362e6b3c08 100644 --- a/libs/structs/structaccess/get.go +++ b/libs/structs/structaccess/get.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "reflect" - "slices" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/structs/structtag" @@ -138,17 +137,14 @@ func Get(v any, path *structpath.PathNode) (any, error) { func accessKey(v reflect.Value, key string, path *structpath.PathNode) (reflect.Value, error) { switch v.Kind() { case reflect.Struct: - fv, sf, owner, ok := findStructFieldByKey(v, key) + fv, sf, ok := findStructFieldByKey(v, key) if !ok { return reflect.Value{}, fmt.Errorf("%s: field %q not found in %s", path.String(), key, v.Type()) } - // ForceSendFields is only managed by the struct that declares the field. - force := forceSendFieldsContains(owner, sf.Name) - - // Honor omitempty: if present and value is empty and not forced, treat as omitted (nil). + // Honor omitempty: if present and value is empty, treat as omitted (nil). jsonTag := structtag.JSONTag(sf.Tag.Get("json")) - if jsonTag.OmitEmpty() && !force { + if jsonTag.OmitEmpty() { if fv.Kind() == reflect.Pointer { if fv.IsNil() { return reflect.Value{}, nil @@ -267,11 +263,11 @@ func findFieldInStruct(v reflect.Value, key string) (reflect.Value, reflect.Stru // It also searches embedded anonymous structs recursively (flattening semantics), which // FindStructFieldByKeyType does too: a bundle resource embeds a config struct that embeds // the SDK request struct, so its fields sit two levels down. -// Returns: fieldValue, structField, owner (the struct value declaring the field), found -func findStructFieldByKey(v reflect.Value, key string) (reflect.Value, reflect.StructField, reflect.Value, bool) { +// Returns: fieldValue, structField, found +func findStructFieldByKey(v reflect.Value, key string) (reflect.Value, reflect.StructField, bool) { // First pass: direct fields if fv, sf, found := findFieldInStruct(v, key); found { - return fv, sf, v, true + return fv, sf, true } // Second pass: search embedded anonymous structs (flattening semantics) breadth-first, one @@ -285,14 +281,14 @@ func findStructFieldByKey(v reflect.Value, key string) (reflect.Value, reflect.S var next []reflect.Value for _, fv := range level { if out, sf, found := findFieldInStruct(fv, key); found { - return out, sf, fv, true + return out, sf, true } next = append(next, embeddedStructs(fv)...) } level = next } - return reflect.Value{}, reflect.StructField{}, reflect.Value{}, false + return reflect.Value{}, reflect.StructField{}, false } // embeddedStructs returns the anonymous struct fields of v, dereferenced, skipping any that @@ -320,37 +316,6 @@ func embeddedStructs(v reflect.Value) []reflect.Value { return out } -// forceSendFields returns the ForceSendFields slice a struct declares itself. A struct that -// embeds another shadows it deliberately -- see resources.PostgresProjectConfig -- so only -// the declaring struct tracks a field of its own. -func forceSendFields(owner reflect.Value) reflect.Value { - if !owner.IsValid() || owner.Kind() != reflect.Struct { - return reflect.Value{} - } - for i := range owner.Type().NumField() { - field := owner.Type().Field(i) - if field.Name == "ForceSendFields" && !field.Anonymous { - return owner.Field(i) - } - } - return reflect.Value{} -} - -// forceSendFieldsContains reports whether a struct forces the named field to be sent. -func forceSendFieldsContains(owner reflect.Value, name string) bool { - fsf := forceSendFields(owner) - if !fsf.IsValid() { - return false - } - fields, ok := reflect.TypeAssert[[]string](fsf) - return ok && containsString(fields, name) -} - -// containsString checks if a slice contains a specific string -func containsString(slice []string, str string) bool { - return slices.Contains(slice, str) -} - // isEmptyForOmitEmpty returns true if the value should be omitted by JSON omitempty. // This matches JSON encoder behavior, which is different from reflect.IsZero() for slices/maps. func isEmptyForOmitEmpty(v reflect.Value) bool { diff --git a/libs/structs/structaccess/get_test.go b/libs/structs/structaccess/get_test.go index 2d7ae4d46b1..6b897958de0 100644 --- a/libs/structs/structaccess/get_test.go +++ b/libs/structs/structaccess/get_test.go @@ -4,8 +4,8 @@ import ( "reflect" "testing" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + pipelines "github.com/databricks/cli/libs/sdktypes/pipelines/v2" "github.com/stretchr/testify/require" ) @@ -54,27 +54,6 @@ type outerNoFSF struct { GoOnly string // no json tag: should NOT be accessible } -type outerWithFSF struct { - Conn *inner `json:"connection"` - ConnNotSet *inner `json:"connection_not_set"` - Items []inner `json:"items"` - Labels map[string]string `json:"labels"` - B bool `json:"b"` - I int `json:"i"` - S string `json:"s"` - BOmit bool `json:"b_omit,omitempty"` - IOmit int `json:"i_omit,omitempty"` - SOmit string `json:"s_omit,omitempty"` - POmit *int `json:"p_omit,omitempty"` - QOmit *inner `json:"q_omit,omitempty"` - MapInt map[int]string `json:"map_int"` - AliasMap map[Key]string `json:"alias_map"` - Ignored string `json:"-"` - GoOnly string // no json tag: should NOT be accessible - // ForceSendFields allows forcing zero-values for specific fields - ForceSendFields []string -} - func makeOuterNoFSF() outerNoFSF { return outerNoFSF{ Conn: &inner{ @@ -95,26 +74,6 @@ func makeOuterNoFSF() outerNoFSF { } } -func makeOuterWithFSF() outerWithFSF { - return outerWithFSF{ - Conn: &inner{ - ID: "abc", - Name: "x", - }, - Items: []inner{ - {ID: "i0", Name: "first"}, - {ID: "i1", Name: "second"}, - }, - Labels: map[string]string{ - "env": "dev", - }, - MapInt: map[int]string{1: "a"}, - AliasMap: map[Key]string{"foo": "bar"}, - Ignored: "x", - GoOnly: "hidden", - } -} - func runCommonTests(t *testing.T, obj any) { t.Helper() @@ -313,24 +272,6 @@ func TestGet_Common_NoFSF(t *testing.T) { runOmitEmptyTests(t, makeOuterNoFSF(), true) // wantNil=true for NoFSF } -func TestGet_Common_WithFSF(t *testing.T) { - obj := makeOuterWithFSF() - obj.ForceSendFields = []string{"BOmit", "IOmit", "SOmit", "POmit", "QOmit"} - // prepare zero pointers for pointer-omitempty fields - zi := 0 - obj.POmit = &zi - obj.QOmit = &inner{} - runCommonTests(t, obj) - runOmitEmptyTests(t, obj, false) // wantNil=false for WithFSF -} - -func TestGet_Common_WithEmptyFSF(t *testing.T) { - obj := makeOuterWithFSF() - // obj.ForceSendFields = []string{} // empty slice - runCommonTests(t, obj) - runOmitEmptyTests(t, obj, true) // wantNil=true for empty FSF (behaves like NoFSF) -} - func runOmitEmptyTests(t *testing.T, obj any, wantNil bool) { t.Helper() @@ -458,172 +399,13 @@ func TestGet_BundleTag_SkipsPromoted(t *testing.T) { require.EqualError(t, ValidateByString(reflect.TypeFor[host](), "hidden"), "hidden: field \"hidden\" not found in structaccess.host") } -func TestGet_EmbeddedStructForceSendFields(t *testing.T) { - type Inner struct { - InnerFieldOmit string `json:"inner_field_omit,omitempty"` - InnerFieldNoOmit string `json:"inner_field_no_omit"` - ForceSendFields []string `json:"-"` - } - - type Outer struct { - OuterFieldOmit string `json:"outer_field_omit,omitempty"` - OuterFieldNoOmit string `json:"outer_field_no_omit"` - Inner - } - - objWithOuterFSF := Outer{ - OuterFieldOmit: "", - OuterFieldNoOmit: "", - InnerFieldOmit: "", - InnerFieldNoOmit: "", - // Presence of "OuterFieldOmit" does not have any effect - // on OuterFieldOmit because it's in the wrong struct - ForceSendFields: []string{"OuterFieldOmit"}, - } - - testGet(t, objWithOuterFSF, "outer_field_omit", nil) - testGet(t, objWithOuterFSF, "outer_field_no_omit", "") - testGet(t, objWithOuterFSF, "inner_field_omit", nil) - testGet(t, objWithOuterFSF, "inner_field_no_omit", "") - - objWithInnerFSF := Outer{ - OuterFieldOmit: "", - OuterFieldNoOmit: "", - InnerFieldOmit: "", - InnerFieldNoOmit: "", - ForceSendFields: []string{"InnerFieldOmit"}, - } - - testGet(t, objWithInnerFSF, "outer_field_omit", nil) - testGet(t, objWithInnerFSF, "outer_field_no_omit", "") - testGet(t, objWithInnerFSF, "inner_field_omit", "") - testGet(t, objWithInnerFSF, "inner_field_no_omit", "") -} - -func TestGet_MultipleEmbeddedStructsForceSendFields(t *testing.T) { - type First struct { - FirstFieldOmit string `json:"first_field_omit,omitempty"` - FirstFieldNoOmit string `json:"first_field_no_omit"` - ForceSendFields []string `json:"-"` - } - - type Second struct { - SecondFieldOmit string `json:"second_field_omit,omitempty"` - SecondFieldNoOmit string `json:"second_field_no_omit"` - ForceSendFields []string `json:"-"` - } - - type Outer struct { - OuterFieldOmit string `json:"outer_field_omit,omitempty"` - OuterFieldNoOmit string `json:"outer_field_no_omit"` - First - Second - } - - objWithFirstFSF := Outer{ - OuterFieldOmit: "", - OuterFieldNoOmit: "", - First: First{ - FirstFieldOmit: "", - FirstFieldNoOmit: "", - ForceSendFields: []string{"FirstFieldOmit"}, - }, - SecondFieldOmit: "", - SecondFieldNoOmit: "", - } - - testGet(t, objWithFirstFSF, "outer_field_omit", nil) - testGet(t, objWithFirstFSF, "outer_field_no_omit", "") - testGet(t, objWithFirstFSF, "first_field_omit", "") - testGet(t, objWithFirstFSF, "first_field_no_omit", "") - testGet(t, objWithFirstFSF, "second_field_omit", nil) - testGet(t, objWithFirstFSF, "second_field_no_omit", "") - - objWithSecondFSF := Outer{ - OuterFieldOmit: "", - OuterFieldNoOmit: "", - FirstFieldOmit: "", - FirstFieldNoOmit: "", - Second: Second{ - SecondFieldOmit: "", - SecondFieldNoOmit: "", - ForceSendFields: []string{"SecondFieldOmit"}, - }, - } - - testGet(t, objWithSecondFSF, "outer_field_omit", nil) - testGet(t, objWithSecondFSF, "outer_field_no_omit", "") - testGet(t, objWithSecondFSF, "first_field_omit", nil) - testGet(t, objWithSecondFSF, "first_field_no_omit", "") - testGet(t, objWithSecondFSF, "second_field_omit", "") - testGet(t, objWithSecondFSF, "second_field_no_omit", "") -} - -func TestGet_MixedForceSendFields(t *testing.T) { - type First struct { - FirstFieldOmit string `json:"first_field_omit,omitempty"` - FirstFieldNoOmit string `json:"first_field_no_omit"` - } - - type Second struct { - SecondFieldOmit string `json:"second_field_omit,omitempty"` - SecondFieldNoOmit string `json:"second_field_no_omit"` - ForceSendFields []string `json:"-"` - } - - type Outer struct { - OuterFieldOmit string `json:"outer_field_omit,omitempty"` - OuterFieldNoOmit string `json:"outer_field_no_omit"` - ForceSendFields []string `json:"-"` - First - Second - } - - objWithOuterFSF := Outer{ - OuterFieldOmit: "", - OuterFieldNoOmit: "", - ForceSendFields: []string{"OuterFieldOmit"}, - FirstFieldOmit: "", - FirstFieldNoOmit: "", - SecondFieldOmit: "", - SecondFieldNoOmit: "", - } - - testGet(t, objWithOuterFSF, "outer_field_omit", "") - testGet(t, objWithOuterFSF, "outer_field_no_omit", "") - testGet(t, objWithOuterFSF, "first_field_omit", nil) - testGet(t, objWithOuterFSF, "first_field_no_omit", "") - testGet(t, objWithOuterFSF, "second_field_omit", nil) - testGet(t, objWithOuterFSF, "second_field_no_omit", "") - - objWithSecondFSF := Outer{ - OuterFieldOmit: "", - OuterFieldNoOmit: "", - FirstFieldOmit: "", - FirstFieldNoOmit: "", - Second: Second{ - SecondFieldOmit: "", - SecondFieldNoOmit: "", - ForceSendFields: []string{"SecondFieldOmit"}, - }, - } - - testGet(t, objWithSecondFSF, "outer_field_omit", nil) - testGet(t, objWithSecondFSF, "outer_field_no_omit", "") - testGet(t, objWithSecondFSF, "first_field_omit", nil) - testGet(t, objWithSecondFSF, "first_field_no_omit", "") - testGet(t, objWithSecondFSF, "second_field_omit", "") - testGet(t, objWithSecondFSF, "second_field_no_omit", "") -} - func TestGet_FieldByNameBugRegressionTest(t *testing.T) { type BaseResource struct { ID string `json:"id,omitempty"` } type JobSettings struct { - Name string `json:"name"` - ForceSendFields []string `json:"-"` + Name string `json:"name"` } type Job struct { @@ -636,7 +418,6 @@ func TestGet_FieldByNameBugRegressionTest(t *testing.T) { objWithNameValue := Job{ ID: "resource_id", Name: "test-job", - ForceSendFields: []string{"Name"}, PermissionsOmit: []string{"read", "write"}, PermissionsNoOmit: []string{"read", "write"}, } @@ -649,7 +430,6 @@ func TestGet_FieldByNameBugRegressionTest(t *testing.T) { objWithEmptyFields := Job{ ID: "", Name: "", - ForceSendFields: []string{"Name"}, PermissionsOmit: []string{}, PermissionsNoOmit: []string{}, } @@ -702,26 +482,25 @@ func TestGet_PointerToStructWithZeroValues(t *testing.T) { func TestGetJobSettings(t *testing.T) { jobSettings := jobs.JobSettings{ - Name: "job foo", - // Tasks []Task `json:"tasks,omitempty"` - Tasks: []jobs.Task{ + Name: new("job foo"), + Tasks: []jobs.TaskSettings{ { - TaskKey: "job_task", - // RunJobTask *RunJobTask `json:"run_job_task,omitempty"` + TaskKey: new("job_task"), RunJobTask: &jobs.RunJobTask{ - // JobId int64 `json:"job_id"` - JobId: 0, + JobId: new(int64(0)), }, }, }, } - testGet(t, &jobSettings, "tasks[0].run_job_task", jobs.RunJobTask{}) + testGet(t, &jobSettings, "name", "job foo") + testGet(t, &jobSettings, "tasks[0].run_job_task", jobs.RunJobTask{JobId: new(int64(0))}) testGet(t, &jobSettings, "tasks[0].run_job_task.job_id", int64(0)) + testGet(t, &jobSettings, "description", nil) } func TestPipeline(t *testing.T) { - p := pipelines.CreatePipeline{} + p := pipelines.CreatePipelineRequest{} v, err := GetByString(&p, "ingestion_definition.connectin_name") require.Error(t, err) @@ -840,3 +619,23 @@ func TestGetKeyValue_NestedMultiple(t *testing.T) { require.NoError(t, err) require.Equal(t, "item3", name) } + +func TestGet_PointerScalars(t *testing.T) { + type S struct { + Str *string `json:"str,omitempty"` + Int *int `json:"int,omitempty"` + Bool *bool `json:"bool,omitempty"` + NilStr *string `json:"nil_str,omitempty"` + NoOmit *string `json:"no_omit"` + } + obj := S{Str: new(""), Int: new(0), Bool: new(false), NoOmit: new("x")} + + // Non-nil pointers to zero values are present and dereferenced. + testGet(t, obj, "str", "") + testGet(t, obj, "int", 0) + testGet(t, obj, "bool", false) + // Nil pointers are absent. + testGet(t, obj, "nil_str", nil) + // Pointers without omitempty are returned as is. + testGet(t, obj, "no_omit", new("x")) +} diff --git a/libs/structs/structaccess/opaque.go b/libs/structs/structaccess/opaque.go new file mode 100644 index 00000000000..9c6c104e791 --- /dev/null +++ b/libs/structs/structaccess/opaque.go @@ -0,0 +1,53 @@ +package structaccess + +import ( + "encoding/json" + "reflect" + "sync" +) + +var ( + jsonMarshalerType = reflect.TypeFor[json.Marshaler]() + + // Keyed by reflect.Type; IsOpaqueStruct is called for every struct visited + // during a diff or walk, so the field scan is done once per type. + opaqueStructCache sync.Map +) + +// sdkTypesPkgPath is the package of the sdk-go native types: types.Time, +// types.Duration and types.FieldMask[T]. They marshal to JSON strings, so their +// Go fields (e.g. Time.Seconds) are not paths in the JSON representation. +const sdkTypesPkgPath = "github.com/databricks/sdk-go/core/types" + +// IsOpaqueStruct reports whether t is a struct that must be treated as a scalar +// rather than walked field by field: the sdk-go native types, and any struct +// whose fields cannot be walked (no exported fields) but that still carries a +// value, marshaling itself through json.Marshaler. Without this, any two of +// their values would compare equal or be reported by their Go fields. +// +// Genuinely empty proto messages (jobs.ScheduleTriggerState, and similar) have +// no exported fields either, but they implement no marshaler and hold nothing, +// so they are not opaque and keep comparing equal. +func IsOpaqueStruct(t reflect.Type) bool { + if cached, ok := opaqueStructCache.Load(t); ok { + return cached.(bool) + } + result := isOpaqueStruct(t) + opaqueStructCache.Store(t, result) + return result +} + +func isOpaqueStruct(t reflect.Type) bool { + if t.Kind() != reflect.Struct { + return false + } + if t.PkgPath() == sdkTypesPkgPath { + return true + } + for sf := range t.Fields() { + if sf.IsExported() { + return false + } + } + return t.Implements(jsonMarshalerType) || reflect.PointerTo(t).Implements(jsonMarshalerType) +} diff --git a/libs/structs/structaccess/set.go b/libs/structs/structaccess/set.go index 02752e456ea..2f763c0b61b 100644 --- a/libs/structs/structaccess/set.go +++ b/libs/structs/structaccess/set.go @@ -4,11 +4,9 @@ import ( "errors" "fmt" "reflect" - "slices" "strconv" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/cli/libs/structs/structtag" ) // Set sets the value at the given path inside the target object. @@ -128,9 +126,9 @@ func setFieldOrMapValue(parentVal reflect.Value, key string, valueVal reflect.Va } } -// setStructField sets a field in a struct and handles ForceSendFields +// setStructField sets a field in a struct func setStructField(parentVal reflect.Value, fieldName string, valueVal reflect.Value) error { - fv, sf, owner, ok := findStructFieldByKey(parentVal, fieldName) + fv, sf, ok := findStructFieldByKey(parentVal, fieldName) if !ok { return fmt.Errorf("field %q not found in %s", fieldName, parentVal.Type()) } @@ -145,19 +143,7 @@ func setStructField(parentVal reflect.Value, fieldName string, valueVal reflect. if err != nil { return err } - if err := assignValue(fv, converted); err != nil { - return err - } - - // ForceSendFields is decided from the converted value, not the caller's: setting an - // omitempty int64 from the string "0" stores 0, which is empty and must be forced, while - // the string "0" is not empty and would have left the field to be omitted. - if !valueVal.IsValid() { - // Setting nil: the field is being made absent, which convertValue renders as the zero - // value. Pass the invalid value through so it is removed from ForceSendFields. - return updateForceSendFields(owner, sf.Name, valueVal, sf) - } - return updateForceSendFields(owner, sf.Name, converted, sf) + return assignValue(fv, converted) } // setMapValue sets a value in a map @@ -207,6 +193,18 @@ func convertValue(valueVal reflect.Value, targetType reflect.Type) (reflect.Valu valueType := valueVal.Type() + // Pointer target from a non-pointer value (e.g. "0" into *int): convert to the + // element type with the same rules and store it behind a new pointer. + if targetType.Kind() == reflect.Pointer && valueType.Kind() != reflect.Pointer { + elem, err := convertValue(valueVal, targetType.Elem()) + if err != nil { + return reflect.Value{}, err + } + ptr := reflect.New(targetType.Elem()) + ptr.Elem().Set(elem) + return ptr, nil + } + // Handle scalar-to-string conversions first (before Go's built-in convertibility). // This is critical because Go's built-in ConvertibleTo/Convert has different behavior: // - Integers (int, uint8, etc.) convert to string as character codes: 42 → "*", 200 → "È" @@ -285,22 +283,6 @@ func convertValue(valueVal reflect.Value, targetType reflect.Type) (reflect.Valu return valueVal.Convert(targetType), nil } - // Handle pointer types - if targetType.Kind() == reflect.Pointer { - elemType := targetType.Elem() - if valueType.AssignableTo(elemType) { - // Create a new pointer and set the value - ptr := reflect.New(elemType) - ptr.Elem().Set(valueVal) - return ptr, nil - } - if valueType.ConvertibleTo(elemType) { - ptr := reflect.New(elemType) - ptr.Elem().Set(valueVal.Convert(elemType)) - return ptr, nil - } - } - // Handle case where value is a pointer but target is not if valueType.Kind() == reflect.Pointer && !valueVal.IsNil() { elemVal := valueVal.Elem() @@ -309,72 +291,3 @@ func convertValue(valueVal reflect.Value, targetType reflect.Type) (reflect.Valu return reflect.Value{}, fmt.Errorf("cannot convert %s to %s", valueType, targetType) } - -// updateForceSendFields handles ForceSendFields when setting values: -// - If setting nil: remove field from ForceSendFields -// - If setting empty value: add field to ForceSendFields (if not already present) -// Only applies to fields with omitempty tag -func updateForceSendFields(owner reflect.Value, fieldName string, valueVal reflect.Value, structField reflect.StructField) error { - isSettingNil := !valueVal.IsValid() - isSettingEmptyValue := valueVal.IsValid() && isEmptyForOmitEmpty(valueVal) - - // Early return if we don't need to modify ForceSendFields - if !isSettingNil && !isSettingEmptyValue { - return nil - } - - // Check if field has omitempty tag - only omitempty fields need ForceSendFields management - jsonTag := structtag.JSONTag(structField.Tag.Get("json")) - if !jsonTag.OmitEmpty() { - // Non-omitempty fields don't need ForceSendFields management - return nil - } - - // Only the struct that declares the field tracks it. - forceSendFieldsSlice := forceSendFields(owner) - if !forceSendFieldsSlice.IsValid() { - // No ForceSendFields to update - return nil - } - - if isSettingNil { - // Remove from ForceSendFields - removeFromForceSendFields(forceSendFieldsSlice, fieldName) - } else if isSettingEmptyValue { - // Add to ForceSendFields if not already present - addToForceSendFields(forceSendFieldsSlice, fieldName) - } - - return nil -} - -// removeFromForceSendFields removes fieldName from the ForceSendFields slice -func removeFromForceSendFields(forceSendFieldsSlice reflect.Value, fieldName string) { - // Get the original []string slice - fields, _ := reflect.TypeAssert[[]string](forceSendFieldsSlice) - - // Find the index of the field to remove - index := slices.Index(fields, fieldName) - if index == -1 { - return // Field not found, nothing to remove - } - - // Remove the field using slices.Delete - newFields := slices.Delete(fields, index, index+1) - forceSendFieldsSlice.Set(reflect.ValueOf(newFields)) -} - -// addToForceSendFields adds fieldName to the ForceSendFields slice if not already present -func addToForceSendFields(forceSendFieldsSlice reflect.Value, fieldName string) { - // Get the original []string slice - fields, _ := reflect.TypeAssert[[]string](forceSendFieldsSlice) - - // Check if already present - if slices.Contains(fields, fieldName) { - return // Already present - } - - // Add the new field - newFields := append(fields, fieldName) - forceSendFieldsSlice.Set(reflect.ValueOf(newFields)) -} diff --git a/libs/structs/structaccess/set_test.go b/libs/structs/structaccess/set_test.go index e1829b8cf3c..fd80335fdea 100644 --- a/libs/structs/structaccess/set_test.go +++ b/libs/structs/structaccess/set_test.go @@ -5,10 +5,10 @@ import ( "reflect" "testing" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/structs/structaccess" "github.com/databricks/cli/libs/structs/structdiff" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -496,26 +496,6 @@ func TestSet(t *testing.T) { } } -// testSet sets a value and gets it back, asserting they're equal (roundtrip) -func testSet(t *testing.T, obj any, path string, value any) { - t.Helper() - err := structaccess.SetByString(obj, path, value) - require.NoError(t, err, "SetByString(%T, %q, %#v)", obj, path, value) - got, err := structaccess.GetByString(obj, path) - require.NoError(t, err, "GetByString(%T, %q)", obj, path) - require.Equal(t, value, got, "SetByString(%T, %q, %#v) then GetByString should return same value", obj, path, value) -} - -// testSetGet sets a value and gets it back, allowing different expected get value -func testSetGet(t *testing.T, obj any, path string, setValue, expectedGetValue any) { - t.Helper() - err := structaccess.SetByString(obj, path, setValue) - require.NoError(t, err, "SetByString(%#v, %q, %#v)", obj, path, setValue) - got, err := structaccess.GetByString(obj, path) - require.NoError(t, err, "GetByString(%#v, %q)", obj, path) - require.Equal(t, expectedGetValue, got, "SetByString(%#v, %q, %#v) then GetByString should return %#v", obj, path, setValue, expectedGetValue) -} - func TestSet_EmbedTag(t *testing.T) { type Item struct { Name string `json:"name"` @@ -553,13 +533,11 @@ func TestSet_EmbedTag(t *testing.T) { func TestSetJobSettings(t *testing.T) { jobSettings := jobs.JobSettings{ - Name: "job foo", - Tasks: []jobs.Task{ + Name: new("job foo"), + Tasks: []jobs.TaskSettings{ { - TaskKey: "job_task", - RunJobTask: &jobs.RunJobTask{ - JobId: 0, // This will be resolved from the reference - }, + TaskKey: new("job_task"), + RunJobTask: &jobs.RunJobTask{}, // JobId will be resolved from the reference }, }, } @@ -568,246 +546,48 @@ func TestSetJobSettings(t *testing.T) { require.NoError(t, err) require.Equal(t, &jobs.JobSettings{ - Name: "job foo", - Tasks: []jobs.Task{ + Name: new("job foo"), + Tasks: []jobs.TaskSettings{ { - TaskKey: "job_task", + TaskKey: new("job_task"), RunJobTask: &jobs.RunJobTask{ - JobId: 123, + JobId: new(int64(123)), }, }, }, }, &jobSettings) } -func TestSet_EmbeddedStructForceSendFields(t *testing.T) { - type Inner struct { - InnerFieldOmit string `json:"inner_field_omit,omitempty"` - InnerFieldNoOmit string `json:"inner_field_no_omit"` - ForceSendFields []string `json:"-"` - } - - type Outer struct { - OuterFieldOmit string `json:"outer_field_omit,omitempty"` - OuterFieldNoOmit string `json:"outer_field_no_omit"` - Inner - } - - t.Run("set nil", func(t *testing.T) { - obj := Outer{ - OuterFieldOmit: "outer_value", - OuterFieldNoOmit: "outer_no_omit", - InnerFieldOmit: "inner_value", - InnerFieldNoOmit: "inner_no_omit", - ForceSendFields: []string{"OuterFieldOmit", "InnerFieldOmit"}, - } - - // Set nil value for outer field - roundtrip nil -> nil - // Outer has no ForceSendFields, so Inner.ForceSendFields unchanged - testSet(t, &obj, "outer_field_omit", nil) - assert.Equal(t, []string{"OuterFieldOmit", "InnerFieldOmit"}, obj.ForceSendFields) - - // Set nil value for outer field no-omit - roundtrip nil -> "" - // Outer has no ForceSendFields, so Inner.ForceSendFields unchanged - testSetGet(t, &obj, "outer_field_no_omit", nil, "") - assert.Equal(t, []string{"OuterFieldOmit", "InnerFieldOmit"}, obj.ForceSendFields) - - // Set nil value for inner field no-omit - roundtrip nil -> "" - // Inner has ForceSendFields but this field has no omitempty, so no change to ForceSendFields - testSetGet(t, &obj, "inner_field_no_omit", nil, "") - assert.Equal(t, []string{"OuterFieldOmit", "InnerFieldOmit"}, obj.ForceSendFields) - - // Set nil value for inner field omit - should clear and remove from Inner.ForceSendFields - testSet(t, &obj, "inner_field_omit", nil) - assert.Equal(t, []string{"OuterFieldOmit"}, obj.ForceSendFields) - - // Repeat - testSet(t, &obj, "inner_field_omit", nil) - assert.Equal(t, []string{"OuterFieldOmit"}, obj.ForceSendFields) - }) - - t.Run("set empty", func(t *testing.T) { - obj := Outer{ - OuterFieldOmit: "outer_value", - OuterFieldNoOmit: "outer_no_omit", - InnerFieldOmit: "inner_value", - InnerFieldNoOmit: "inner_no_omit", - ForceSendFields: []string{}, - } - - // Set empty string for outer field, but get nil back (omitempty, no ForceSendFields) - testSetGet(t, &obj, "outer_field_omit", "", nil) - // Outer has no ForceSendFields, so Inner.ForceSendFields unchanged - assert.Equal(t, []string{}, obj.ForceSendFields) - - // Set empty string for outer field no-omit - roundtrip "" -> "" - testSet(t, &obj, "outer_field_no_omit", "") - // Outer has no ForceSendFields, so Inner.ForceSendFields unchanged - assert.Equal(t, []string{}, obj.ForceSendFields) - - // Set empty string for inner field no-omit - roundtrip "" -> "" - testSet(t, &obj, "inner_field_no_omit", "") - // Inner has ForceSendFields but this field has no omitempty, so no change to ForceSendFields - assert.Equal(t, []string{}, obj.ForceSendFields) - - // Set empty string for inner field omit - should set field and add to Inner.ForceSendFields - testSet(t, &obj, "inner_field_omit", "") - assert.Equal(t, []string{"InnerFieldOmit"}, obj.ForceSendFields) - - // Repeat - should not duplicate in ForceSendFields - testSet(t, &obj, "inner_field_omit", "") - assert.Equal(t, []string{"InnerFieldOmit"}, obj.ForceSendFields) - }) -} - -func TestSet_MixedForceSendFields(t *testing.T) { - type First struct { - FirstFieldOmit string `json:"first_field_omit,omitempty"` - FirstFieldNoOmit string `json:"first_field_no_omit"` - } - - type Second struct { - SecondFieldOmit string `json:"second_field_omit,omitempty"` - SecondFieldNoOmit string `json:"second_field_no_omit"` - ForceSendFields []string `json:"-"` - } - - type Outer struct { - OuterFieldOmit string `json:"outer_field_omit,omitempty"` - OuterFieldNoOmit string `json:"outer_field_no_omit"` - ForceSendFields []string `json:"-"` - First - Second - } - - t.Run("set nil", func(t *testing.T) { - obj := Outer{ - OuterFieldOmit: "outer_value", - OuterFieldNoOmit: "outer_no_omit", - ForceSendFields: []string{"OuterFieldOmit", "FirstFieldOmit"}, - FirstFieldOmit: "first_value", - FirstFieldNoOmit: "first_no_omit", - Second: Second{ - SecondFieldOmit: "second_value", - SecondFieldNoOmit: "second_no_omit", - ForceSendFields: []string{"SecondFieldOmit"}, - }, - } - - // Set nil for outer field - should clear and remove from Outer.ForceSendFields - testSet(t, &obj, "outer_field_omit", nil) - assert.Equal(t, []string{"FirstFieldOmit"}, obj.ForceSendFields) - assert.Equal(t, []string{"SecondFieldOmit"}, obj.Second.ForceSendFields) - - // Set nil for outer field no-omit - roundtrip nil -> "" - testSetGet(t, &obj, "outer_field_no_omit", nil, "") - assert.Equal(t, []string{"FirstFieldOmit"}, obj.ForceSendFields) - assert.Equal(t, []string{"SecondFieldOmit"}, obj.Second.ForceSendFields) - - // Set nil for first field no-omit - roundtrip nil -> "" - testSetGet(t, &obj, "first_field_no_omit", nil, "") - assert.Equal(t, []string{"FirstFieldOmit"}, obj.ForceSendFields) - assert.Equal(t, []string{"SecondFieldOmit"}, obj.Second.ForceSendFields) - - // Set nil for first field omit - should clear field but NOT affect any ForceSendFields - // (First has no ForceSendFields, so nothing to manage there) - testSet(t, &obj, "first_field_omit", nil) - assert.Equal(t, []string{"FirstFieldOmit"}, obj.ForceSendFields) // unchanged - First fields don't belong to Outer's ForceSendFields management - assert.Equal(t, []string{"SecondFieldOmit"}, obj.Second.ForceSendFields) - - // Set nil for second field no-omit - roundtrip nil -> "" - testSetGet(t, &obj, "second_field_no_omit", nil, "") - assert.Equal(t, []string{"FirstFieldOmit"}, obj.ForceSendFields) - assert.Equal(t, []string{"SecondFieldOmit"}, obj.Second.ForceSendFields) - - // Set nil for second field omit - should clear and remove from Second.ForceSendFields - // (Second owns its own fields since it has ForceSendFields) - testSet(t, &obj, "second_field_omit", nil) - assert.Equal(t, []string{"FirstFieldOmit"}, obj.ForceSendFields) // unchanged - assert.Equal(t, []string{}, obj.Second.ForceSendFields) - - // Repeat operations - should be idempotent - testSet(t, &obj, "first_field_omit", nil) - testSet(t, &obj, "second_field_omit", nil) - assert.Equal(t, []string{"FirstFieldOmit"}, obj.ForceSendFields) // unchanged - assert.Equal(t, []string{}, obj.Second.ForceSendFields) - }) - - t.Run("set empty", func(t *testing.T) { - obj := Outer{ - OuterFieldOmit: "outer_value", - OuterFieldNoOmit: "outer_no_omit", - ForceSendFields: []string{}, - FirstFieldOmit: "first_value", - FirstFieldNoOmit: "first_no_omit", - Second: Second{ - SecondFieldOmit: "second_value", - SecondFieldNoOmit: "second_no_omit", - ForceSendFields: []string{}, - }, - } - - // Set empty for outer field omit - should zero and add to Outer.ForceSendFields - testSet(t, &obj, "outer_field_omit", "") - assert.Equal(t, []string{"OuterFieldOmit"}, obj.ForceSendFields) - assert.Equal(t, []string{}, obj.Second.ForceSendFields) - - // Set empty for outer field no-omit - roundtrip "" -> "" - testSet(t, &obj, "outer_field_no_omit", "") - assert.Equal(t, []string{"OuterFieldOmit"}, obj.ForceSendFields) - assert.Equal(t, []string{}, obj.Second.ForceSendFields) - - // Set empty for first field no-omit - roundtrip "" -> "" - testSet(t, &obj, "first_field_no_omit", "") - assert.Equal(t, []string{"OuterFieldOmit"}, obj.ForceSendFields) - assert.Equal(t, []string{}, obj.Second.ForceSendFields) - - // Set empty for first field omit - should zero field but get nil back (no ForceSendFields to manage) - // (First has no ForceSendFields, so empty value won't survive roundtrip) - testSetGet(t, &obj, "first_field_omit", "", nil) - assert.Equal(t, []string{"OuterFieldOmit"}, obj.ForceSendFields) // unchanged - First fields don't belong to Outer's ForceSendFields management - assert.Equal(t, []string{}, obj.Second.ForceSendFields) - - // Set empty for second field no-omit - roundtrip "" -> "" - testSet(t, &obj, "second_field_no_omit", "") - assert.Equal(t, []string{"OuterFieldOmit"}, obj.ForceSendFields) - assert.Equal(t, []string{}, obj.Second.ForceSendFields) - - // Set empty for second field omit - should zero and add to Second.ForceSendFields - // (Second owns its own fields since it has ForceSendFields) - testSet(t, &obj, "second_field_omit", "") - assert.Equal(t, []string{"OuterFieldOmit"}, obj.ForceSendFields) - assert.Equal(t, []string{"SecondFieldOmit"}, obj.Second.ForceSendFields) - - // Repeat operations - should not duplicate - testSet(t, &obj, "second_field_omit", "") - assert.Equal(t, []string{"OuterFieldOmit"}, obj.ForceSendFields) - assert.Equal(t, []string{"SecondFieldOmit"}, obj.Second.ForceSendFields) // no duplicates - }) -} - -// A value that cannot be converted must leave the struct untouched, ForceSendFields included. -func TestSet_FailedConversionLeavesForceSendFields(t *testing.T) { - job := &jobs.JobSettings{Name: "n"} //exhaustruct:ignore +// A value that cannot be converted must leave the struct untouched. +func TestSet_FailedConversionLeavesStruct(t *testing.T) { + job := &jobs.JobSettings{Name: new("n")} //exhaustruct:ignore require.Error(t, structaccess.SetByString(job, "max_concurrent_runs", "")) - assert.Empty(t, job.ForceSendFields) - assert.Equal(t, "n", job.Name) + assert.Nil(t, job.MaxConcurrentRuns) + assert.Equal(t, new("n"), job.Name) } -// ForceSendFields is decided from the value actually stored, not the one the caller passed: -// setting an omitempty numeric field from the string "0" stores zero, which has to be forced -// or the field marshals as absent. -func TestSet_StringZeroIntoOmitemptyNumberIsForced(t *testing.T) { - job := &jobs.JobSettings{Name: "n"} //exhaustruct:ignore +// Setting a pointer-to-scalar field to a zero value allocates the pointer, so the +// zero value is marshaled; setting nil clears it. +func TestSet_PointerScalarZeroValue(t *testing.T) { + job := &jobs.JobSettings{Name: new("n")} //exhaustruct:ignore require.NoError(t, structaccess.SetByString(job, "max_concurrent_runs", "0")) - assert.Equal(t, 0, job.MaxConcurrentRuns) - assert.Contains(t, job.ForceSendFields, "MaxConcurrentRuns") + assert.Equal(t, new(0), job.MaxConcurrentRuns) blob, err := json.Marshal(job) require.NoError(t, err) assert.Contains(t, string(blob), `"max_concurrent_runs":0`) + + require.NoError(t, structaccess.SetByString(job, "description", "")) + assert.Equal(t, new(""), job.Description) + + require.NoError(t, structaccess.SetByString(job, "max_concurrent_runs", nil)) + assert.Nil(t, job.MaxConcurrentRuns) + + got, err := structaccess.GetByString(job, "description") + require.NoError(t, err) + assert.Empty(t, got) } // encoding/json resolves a name declared at two embedding depths in favour of the shallower diff --git a/libs/structs/structdiff/bench_test.go b/libs/structs/structdiff/bench_test.go index 08b386416ef..66d3b14572d 100644 --- a/libs/structs/structdiff/bench_test.go +++ b/libs/structs/structdiff/bench_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/databricks/databricks-sdk-go/service/jobs" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/require" ) diff --git a/libs/structs/structdiff/diff.go b/libs/structs/structdiff/diff.go index 5e7a00cac4f..700680be140 100644 --- a/libs/structs/structdiff/diff.go +++ b/libs/structs/structdiff/diff.go @@ -65,7 +65,6 @@ type diffContext struct { } // GetStructDiff compares two Go structs and returns a list of Changes or an error. -// Respects ForceSendFields if present. // Types of a and b must match exactly, otherwise returns an error. // // The sliceKeys parameter maps path patterns to functions that extract @@ -200,12 +199,9 @@ func deepEqualValues(path *structpath.PathNode, v1, v2 reflect.Value, changes *[ func diffStruct(ctx *diffContext, path *structpath.PathNode, s1, s2 reflect.Value, changes *[]Change) error { t := s1.Type() - forced1 := getForceSendFields(s1) - forced2 := getForceSendFields(s2) - for i := range t.NumField() { sf := t.Field(i) - if !sf.IsExported() || sf.Name == "ForceSendFields" { + if !sf.IsExported() { continue } @@ -242,14 +238,10 @@ func diffStruct(ctx *diffContext, path *structpath.PathNode, s1, s2 reflect.Valu if zero1 || zero2 { if jsonTag.OmitEmpty() { if zero1 { - if !slices.Contains(forced1, sf.Name) { - v1Field = reflect.ValueOf(nil) - } + v1Field = reflect.ValueOf(nil) } if zero2 { - if !slices.Contains(forced2, sf.Name) { - v2Field = reflect.ValueOf(nil) - } + v2Field = reflect.ValueOf(nil) } } } @@ -295,21 +287,6 @@ func diffMapStringKey(ctx *diffContext, path *structpath.PathNode, m1, m2 reflec return nil } -func getForceSendFields(v reflect.Value) []string { - if !v.IsValid() || v.Kind() != reflect.Struct { - return nil - } - fsField := v.FieldByName("ForceSendFields") - if !fsField.IsValid() || fsField.Kind() != reflect.Slice { - return nil - } - result, ok := reflect.TypeAssert[[]string](fsField) - if ok { - return result - } - return nil -} - // findKeyFunc returns the KeyFunc for the given path, or nil if none matches. // Path patterns support [*] to match any slice index. func (ctx *diffContext) findKeyFunc(path *structpath.PathNode) KeyFunc { diff --git a/libs/structs/structdiff/diff_test.go b/libs/structs/structdiff/diff_test.go index 15f90f076f6..515642b956a 100644 --- a/libs/structs/structdiff/diff_test.go +++ b/libs/structs/structdiff/diff_test.go @@ -6,9 +6,8 @@ import ( "testing" "time" - "github.com/databricks/databricks-sdk-go/common/types/duration" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/service/jobs" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/sdk-go/core/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -25,12 +24,13 @@ type A struct { Ignored string `json:"-"` } +// C has optional scalars behind pointers, as sdk-go types do: a nil pointer is +// absent, a non-nil pointer to a zero value is present. type C struct { - Name string `json:"name,omitempty"` - Age int `json:"age,omitempty"` - IsEnabled bool `json:"is_enabled,omitempty"` - Title string `json:"title"` // no omitempty - ForceSendFields []string `json:"-"` + Name *string `json:"name,omitempty"` + Age *int `json:"age,omitempty"` + IsEnabled *bool `json:"is_enabled,omitempty"` + Title string `json:"title"` // no omitempty } type Embedded struct { @@ -48,12 +48,11 @@ type E struct { Name string `json:"name,omitempty"` } -// O holds opaque struct fields: Duration and Timestamp keep their payload in an -// unexported protobuf pointer, while Empty is a proto message that really is -// empty. +// O holds opaque struct fields: Duration and Timestamp keep their payload in +// unexported fields, while Empty is a proto message that really is empty. type O struct { - Duration *duration.Duration `json:"duration,omitempty"` - Timestamp *sdktime.Time `json:"timestamp,omitempty"` + Duration *types.Duration `json:"duration,omitempty"` + Timestamp *types.Time `json:"timestamp,omitempty"` Empty *jobs.ScheduleTriggerState `json:"empty,omitempty"` } @@ -84,10 +83,10 @@ func TestGetStructDiff(t *testing.T) { b1 := &B{S: "one"} b2 := &B{S: "two"} - dur300 := duration.New(300 * time.Second) - dur600 := duration.New(600 * time.Second) - ts1 := sdktime.New(time.Unix(1000, 0)) - ts2 := sdktime.New(time.Unix(2000, 0)) + dur300 := types.NewFromDuration(300 * time.Second) + dur600 := types.NewFromDuration(600 * time.Second) + ts1 := types.NewFromTime(time.Unix(1000, 0)) + ts2 := types.NewFromTime(time.Unix(2000, 0)) // An *invalid* reflect.Value (IsValid() == false) var invalidRV reflect.Value @@ -183,69 +182,49 @@ func TestGetStructDiff(t *testing.T) { want: nil, }, - // ForceSendFields with non-empty fields (omitempty) + // Pointer scalars with non-empty values { - name: "forcesend nonempty 1", - a: C{Name: "Hello", ForceSendFields: []string{"Name"}}, - b: C{Name: "World"}, + name: "pointer nonempty", + a: C{Name: new("Hello")}, + b: C{Name: new("World")}, want: []ResolvedChange{{Field: "name", Old: "Hello", New: "World"}}, }, { - name: "forcesend noneempty 2", - a: C{Name: "Hello", ForceSendFields: []string{"Name"}}, - b: C{Name: "World", ForceSendFields: []string{"Name"}}, - want: []ResolvedChange{{Field: "name", Old: "Hello", New: "World"}}, - }, - { - name: "forcesend noneempty 3", - a: C{Name: "Hello"}, - b: C{Name: "World", ForceSendFields: []string{"Name"}}, - want: []ResolvedChange{{Field: "name", Old: "Hello", New: "World"}}, - }, - - // ForceSendFields with non-empty fields (required) - { - name: "forcesend nonempty required 1", - a: C{Title: "Hello", ForceSendFields: []string{"Title"}}, - b: C{Title: "World"}, - want: []ResolvedChange{{Field: "title", Old: "Hello", New: "World"}}, - }, - { - name: "forcesend noneempty required 2", - a: C{Title: "Hello", ForceSendFields: []string{"Title"}}, - b: C{Title: "World", ForceSendFields: []string{"Title"}}, - want: []ResolvedChange{{Field: "title", Old: "Hello", New: "World"}}, + name: "pointer nonempty vs nil", + a: C{Name: new("Hello")}, + b: C{}, + want: []ResolvedChange{{Field: "name", Old: "Hello", New: nil}}, }, { - name: "forcesend noneempty required 3", + name: "required field", a: C{Title: "Hello"}, - b: C{Title: "World", ForceSendFields: []string{"Title"}}, + b: C{Title: "World"}, want: []ResolvedChange{{Field: "title", Old: "Hello", New: "World"}}, }, - // ForceSendFields with empty fields + // Pointer scalars with zero values are different from nil { - name: "forcesend empty string diff", - a: C{ForceSendFields: []string{"Name"}}, // Name == "" zero, but forced + name: "pointer empty string vs nil", + a: C{Name: new("")}, b: C{}, want: []ResolvedChange{{Field: "name", Old: "", New: nil}}, }, { - name: "forcesend empty int diff", - a: C{ForceSendFields: []string{"Age"}}, + name: "pointer zero int vs nil", + a: C{Age: new(0)}, b: C{}, want: []ResolvedChange{{Field: "age", Old: 0, New: nil}}, }, { - name: "forcesend empty bool diff", - a: C{ForceSendFields: []string{"IsEnabled"}}, + name: "pointer false vs nil", + a: C{IsEnabled: new(false)}, b: C{}, want: []ResolvedChange{{Field: "is_enabled", Old: false, New: nil}}, }, { - name: "forcesend empty all", - a: C{ForceSendFields: []string{"Name", "IsEnabled"}}, - b: C{ForceSendFields: []string{"Age"}}, + name: "pointer zero values both ways", + a: C{Name: new(""), IsEnabled: new(false)}, + b: C{Age: new(0)}, want: []ResolvedChange{ {Field: "name", Old: "", New: nil}, {Field: "age", Old: nil, New: 0}, @@ -253,49 +232,35 @@ func TestGetStructDiff(t *testing.T) { }, }, { - name: "forcesend is different but field is non empty – no diff", - a: C{Name: "name", ForceSendFields: []string{"Name"}}, - b: C{Name: "name"}, - want: nil, - }, - { - name: "forcesend on non-omitempty field – no diff", - a: C{Title: "", ForceSendFields: []string{"Title"}}, - b: C{}, + name: "equal pointer values – no diff", + a: C{Name: new("name"), Age: new(0)}, + b: C{Name: new("name"), Age: new(0)}, want: nil, }, - // ForceSendFields inside slice + // Pointer scalars inside slice { - name: "slice of struct with only ForceSendFields diff", - a: []C{{Name: "hello", ForceSendFields: []string{"Name"}}}, - b: []C{{Name: "hello"}}, - want: nil, - }, - { - name: "slice of struct with empty string and ForceSendFields diff", - a: []C{{Name: "", ForceSendFields: []string{"Name"}}}, - b: []C{{Name: ""}}, + name: "slice of struct with pointer zero value", + a: []C{{Name: new("")}}, + b: []C{{}}, want: []ResolvedChange{{Field: "[0].name", Old: "", New: nil}}, }, - // ForceSendFields inside map value + // Pointer scalars inside map value { - name: "forcesend inside map", - a: map[string]C{"key1": {Title: "title", ForceSendFields: []string{"Name", "IsEnabled", "Title"}}}, - b: map[string]C{"key1": {Title: "title", ForceSendFields: []string{"Age"}}}, + name: "pointer zero values inside map", + a: map[string]C{"key1": {Title: "title", Name: new(""), IsEnabled: new(false)}}, + b: map[string]C{"key1": {Title: "title", Age: new(0)}}, want: []ResolvedChange{ {Field: "['key1'].name", Old: "", New: nil}, {Field: "['key1'].age", Old: nil, New: 0}, {Field: "['key1'].is_enabled", Old: false, New: nil}, }, }, - - // ForceSendFields inside map value pointer { - name: "forcesend inside map", - a: map[string]*C{"key1": {Title: "title", ForceSendFields: []string{"Name", "IsEnabled", "Title"}}}, - b: map[string]*C{"key1": {Title: "title", ForceSendFields: []string{"Age"}}}, + name: "pointer zero values inside map value pointer", + a: map[string]*C{"key1": {Title: "title", Name: new(""), IsEnabled: new(false)}}, + b: map[string]*C{"key1": {Title: "title", Age: new(0)}}, want: []ResolvedChange{ {Field: "['key1'].name", Old: "", New: nil}, {Field: "['key1'].age", Old: nil, New: 0}, diff --git a/libs/structs/structdiff/equal.go b/libs/structs/structdiff/equal.go index 014f6f7af36..7ec0142b833 100644 --- a/libs/structs/structdiff/equal.go +++ b/libs/structs/structdiff/equal.go @@ -2,7 +2,6 @@ package structdiff import ( "reflect" - "slices" "github.com/databricks/cli/libs/structs/structaccess" "github.com/databricks/cli/libs/structs/structtag" @@ -11,9 +10,9 @@ import ( // IsEqual compares two Go structs and returns true if they are equal. // It uses the same comparison logic as GetStructDiff but is more efficient // as it short-circuits on the first difference found. -// Respects ForceSendFields if present. // Types of a and b must match exactly, otherwise returns false. -// Note, reflect.DeepEqual() does not work for SDK structs, because ForceSendFields can contain different sets for the same value. +// Note, unlike reflect.DeepEqual(), omitempty zero values are equal to absent ones and opaque structs +// (e.g. types.Time) are compared by their JSON form. func IsEqual(a, b any) bool { v1 := reflect.ValueOf(a) v2 := reflect.ValueOf(b) @@ -99,12 +98,9 @@ func equalValues(v1, v2 reflect.Value) bool { func equalStruct(s1, s2 reflect.Value) bool { t := s1.Type() - forced1 := getForceSendFields(s1) - forced2 := getForceSendFields(s2) - for i := range t.NumField() { sf := t.Field(i) - if !sf.IsExported() || sf.Name == "ForceSendFields" { + if !sf.IsExported() { continue } @@ -133,14 +129,10 @@ func equalStruct(s1, s2 reflect.Value) bool { if zero1 || zero2 { if jsonTag.OmitEmpty() { if zero1 { - if !slices.Contains(forced1, sf.Name) { - v1Field = reflect.ValueOf(nil) - } + v1Field = reflect.ValueOf(nil) } if zero2 { - if !slices.Contains(forced2, sf.Name) { - v2Field = reflect.ValueOf(nil) - } + v2Field = reflect.ValueOf(nil) } } } diff --git a/libs/structs/structdiff/jobsettings_test.go b/libs/structs/structdiff/jobsettings_test.go index f5de67503a0..0aa2dee38d8 100644 --- a/libs/structs/structdiff/jobsettings_test.go +++ b/libs/structs/structdiff/jobsettings_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/databricks/databricks-sdk-go/service/jobs" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -464,6 +464,17 @@ func TestJobEqual(t *testing.T) { testEqual(t, jobExampleResponseNils) } +func findChange(t *testing.T, changes []Change, path string) Change { + t.Helper() + for _, ch := range changes { + if ch.Path.String() == path { + return ch + } + } + t.Fatalf("no change at %s", path) + return Change{} +} + func TestJobDiff(t *testing.T) { var job, zero, nils jobs.JobSettings @@ -474,54 +485,52 @@ func TestJobDiff(t *testing.T) { changes, err := GetStructDiff(job, zero, nil) require.NoError(t, err) require.GreaterOrEqual(t, len(changes), 75) - assert.Equal(t, "budget_policy_id", changes[0].Path.String()) - assert.Equal(t, "550e8400-e29b-41d4-a716-446655440000", changes[0].Old) - assert.Empty(t, changes[0].New) - // Note: pause_status shows up as nil here because Continuous does not have ForceSendFields field - assert.Equal(t, "continuous.pause_status", changes[1].Path.String()) - assert.Equal(t, jobs.PauseStatus("UNPAUSED"), changes[1].Old) - assert.Nil(t, changes[1].New) - assert.Equal(t, "deployment.kind", changes[2].Path.String()) - assert.Equal(t, jobs.JobDeploymentKind("BUNDLE"), changes[2].Old) - assert.Equal(t, jobs.JobDeploymentKind(""), changes[2].New) - assert.Equal(t, "deployment.metadata_file_path", changes[3].Path.String()) - assert.Equal(t, "string", changes[3].Old) - assert.Empty(t, changes[3].New) + // Explicit zero values are kept behind pointers. + ch := findChange(t, changes, "budget_policy_id") + assert.Equal(t, "550e8400-e29b-41d4-a716-446655440000", ch.Old) + assert.Empty(t, ch.New) + // Enums are not pointers: an empty enum is absent. + ch = findChange(t, changes, "continuous.pause_status") + assert.Equal(t, jobs.SchedulePauseStatus("UNPAUSED"), ch.Old) + assert.Nil(t, ch.New) + ch = findChange(t, changes, "deployment.kind") + assert.Equal(t, jobs.JobDeployment_DeploymentKind("BUNDLE"), ch.Old) + assert.Nil(t, ch.New) + ch = findChange(t, changes, "deployment.metadata_file_path") + assert.Equal(t, "string", ch.Old) + assert.Empty(t, ch.New) changes, err = GetStructDiff(job, nils, nil) require.NoError(t, err) require.GreaterOrEqual(t, len(changes), 77) - assert.Equal(t, "budget_policy_id", changes[0].Path.String()) - assert.Equal(t, "550e8400-e29b-41d4-a716-446655440000", changes[0].Old) - assert.Nil(t, changes[0].New) + ch = findChange(t, changes, "budget_policy_id") + assert.Equal(t, "550e8400-e29b-41d4-a716-446655440000", ch.Old) + assert.Nil(t, ch.New) // continuous is completely deleted from jobExampleResponseNils - assert.Equal(t, "continuous", changes[1].Path.String()) - assert.Equal(t, jobs.Continuous{PauseStatus: "UNPAUSED"}, changes[1].Old) - assert.Nil(t, changes[1].New) + ch = findChange(t, changes, "continuous") + assert.Equal(t, jobs.ContinuousSettings{PauseStatus: "UNPAUSED"}, ch.Old) + assert.Nil(t, ch.New) - // deployment.kind is not omitempty field, so it does not show up as nil here - assert.Equal(t, "deployment.kind", changes[2].Path.String()) - assert.Equal(t, jobs.JobDeploymentKind("BUNDLE"), changes[2].Old) - assert.Equal(t, jobs.JobDeploymentKind(""), changes[2].New) + ch = findChange(t, changes, "deployment.kind") + assert.Equal(t, jobs.JobDeployment_DeploymentKind("BUNDLE"), ch.Old) + assert.Nil(t, ch.New) - assert.Equal(t, "deployment.metadata_file_path", changes[3].Path.String()) - assert.Equal(t, "string", changes[3].Old) - assert.Nil(t, changes[3].New) + ch = findChange(t, changes, "deployment.metadata_file_path") + assert.Equal(t, "string", ch.Old) + assert.Nil(t, ch.New) changes, err = GetStructDiff(zero, nils, nil) require.NoError(t, err) assert.GreaterOrEqual(t, len(changes), 58) - assert.Equal(t, "budget_policy_id", changes[0].Path.String()) - assert.Empty(t, changes[0].Old) - assert.Nil(t, changes[0].New) - assert.Equal(t, "continuous", changes[1].Path.String()) - assert.Equal(t, jobs.Continuous{}, changes[1].Old) - assert.Nil(t, changes[1].New) - - // deployment.kind is "" in both + ch = findChange(t, changes, "budget_policy_id") + assert.Empty(t, ch.Old) + assert.Nil(t, ch.New) + ch = findChange(t, changes, "continuous") + assert.Equal(t, jobs.ContinuousSettings{}, ch.Old) + assert.Nil(t, ch.New) - assert.Equal(t, "deployment.metadata_file_path", changes[2].Path.String()) - assert.Empty(t, changes[2].Old) - assert.Nil(t, changes[2].New) + ch = findChange(t, changes, "deployment.metadata_file_path") + assert.Empty(t, ch.Old) + assert.Nil(t, ch.New) } diff --git a/libs/structs/structdiff/opaque.go b/libs/structs/structdiff/opaque.go index fd7b26d2af2..b107dc25123 100644 --- a/libs/structs/structdiff/opaque.go +++ b/libs/structs/structdiff/opaque.go @@ -4,47 +4,13 @@ import ( "bytes" "encoding/json" "reflect" - "sync" -) - -var ( - jsonMarshalerType = reflect.TypeFor[json.Marshaler]() - // Keyed by reflect.Type; IsOpaqueStruct is called for every struct visited - // during a diff, so the field scan is done once per type. - opaqueStructCache sync.Map + "github.com/databricks/cli/libs/structs/structaccess" ) -// IsOpaqueStruct reports whether t is a struct that diffStruct cannot see into -// (no exported fields to walk) but that still carries a value, marshaling -// itself through json.Marshaler. The SDK's duration.Duration and -// common/types/time.Time are of this shape: each holds a single unexported -// protobuf pointer. Without this, any two of their values compare equal. -// -// Genuinely empty proto messages (jobs.ScheduleTriggerState, and similar) have -// no exported fields either, but they implement no marshaler and hold nothing, -// so they are not opaque and keep comparing equal. +// IsOpaqueStruct is [structaccess.IsOpaqueStruct]. func IsOpaqueStruct(t reflect.Type) bool { - if cached, ok := opaqueStructCache.Load(t); ok { - return cached.(bool) - } - result := isOpaqueStruct(t) - opaqueStructCache.Store(t, result) - return result -} - -func isOpaqueStruct(t reflect.Type) bool { - if t.Kind() != reflect.Struct { - return false - } - for sf := range t.Fields() { - // ForceSendFields is skipped when walking fields, so a struct carrying - // only that is still invisible to the walk. - if sf.IsExported() && sf.Name != "ForceSendFields" { - return false - } - } - return t.Implements(jsonMarshalerType) || reflect.PointerTo(t).Implements(jsonMarshalerType) + return structaccess.IsOpaqueStruct(t) } // equalJSON compares two opaque values through their JSON form, which is the diff --git a/libs/structs/structdiff/opaque_test.go b/libs/structs/structdiff/opaque_test.go index 1ec4cb89abe..9d6ed93b2a8 100644 --- a/libs/structs/structdiff/opaque_test.go +++ b/libs/structs/structdiff/opaque_test.go @@ -5,12 +5,9 @@ import ( "testing" "time" - "github.com/databricks/databricks-sdk-go/common/types/duration" - "github.com/databricks/databricks-sdk-go/common/types/fieldmask" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/pipelines" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + pipelines "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/sdk-go/core/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -20,23 +17,20 @@ func TestIsOpaqueStruct(t *testing.T) { typ reflect.Type want bool }{ - // Payload hidden in an unexported protobuf pointer. - {reflect.TypeFor[duration.Duration](), true}, - {reflect.TypeFor[sdktime.Time](), true}, + // Payload hidden in unexported fields. + {reflect.TypeFor[types.Duration](), true}, + {reflect.TypeFor[types.Time](), true}, + {reflect.TypeFor[types.FieldMask[A]](), true}, // Empty proto messages: no exported fields either, but nothing to hide // and no marshaler of their own. - {reflect.TypeFor[catalog.MonitorSnapshot](), false}, {reflect.TypeFor[jobs.ModelTriggerState](), false}, {reflect.TypeFor[jobs.ScheduleTriggerState](), false}, {reflect.TypeFor[pipelines.ManualTrigger](), false}, - // FieldMask marshals to a string but exposes Paths, so the walk sees it. - {reflect.TypeFor[fieldmask.FieldMask](), false}, - {reflect.TypeFor[A](), false}, {reflect.TypeFor[string](), false}, - {reflect.TypeFor[*duration.Duration](), false}, + {reflect.TypeFor[*types.Duration](), false}, } for _, tt := range tests { @@ -52,8 +46,8 @@ func TestIsOpaqueStruct(t *testing.T) { // struct field. This is the shape the original bug was reported in: two // durations handed straight to GetStructDiff came back equal. func TestGetStructDiffOpaqueAtRoot(t *testing.T) { - a := duration.New(300 * time.Second) - b := duration.New(600 * time.Second) + a := types.NewFromDuration(300 * time.Second) + b := types.NewFromDuration(600 * time.Second) for _, tt := range []struct { name string diff --git a/libs/structs/structdiff/pkg.go b/libs/structs/structdiff/pkg.go index a0523f9df0d..b940a62872c 100644 --- a/libs/structs/structdiff/pkg.go +++ b/libs/structs/structdiff/pkg.go @@ -4,6 +4,7 @@ package structdiff Recursively calculate difference between two structs of the same type. -Respect ForceSendFields if present to distinguish zero values from nils. +Zero values of omitempty fields are treated as absent; optional values that must be +distinguished from absent ones are pointers. */ diff --git a/libs/structs/structvar/structvar_test.go b/libs/structs/structvar/structvar_test.go index 9d4c2532ad6..ac9b5162a21 100644 --- a/libs/structs/structvar/structvar_test.go +++ b/libs/structs/structvar/structvar_test.go @@ -4,8 +4,8 @@ import ( "reflect" "testing" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/structs/structvar" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -212,13 +212,11 @@ func TestResolveRefEscaped(t *testing.T) { func TestResolveRefJobSettings(t *testing.T) { // Create a realistic JobSettings based on the provided YAML config jobSettings := jobs.JobSettings{ - Name: "job foo", - Tasks: []jobs.Task{ + Name: new("job foo"), + Tasks: []jobs.TaskSettings{ { - TaskKey: "job_task", - RunJobTask: &jobs.RunJobTask{ - JobId: 0, // This will be resolved from the reference - }, + TaskKey: new("job_task"), + RunJobTask: &jobs.RunJobTask{}, // JobId will be resolved from the reference }, }, } @@ -236,11 +234,11 @@ func TestResolveRefJobSettings(t *testing.T) { // Verify the job ID was set correctly updatedSettings := sv.Value.(*jobs.JobSettings) - assert.Equal(t, "job foo", updatedSettings.Name) + assert.Equal(t, new("job foo"), updatedSettings.Name) assert.Len(t, updatedSettings.Tasks, 1) - assert.Equal(t, "job_task", updatedSettings.Tasks[0].TaskKey) + assert.Equal(t, new("job_task"), updatedSettings.Tasks[0].TaskKey) assert.NotNil(t, updatedSettings.Tasks[0].RunJobTask) - assert.Equal(t, int64(123), updatedSettings.Tasks[0].RunJobTask.JobId) + assert.Equal(t, new(int64(123)), updatedSettings.Tasks[0].RunJobTask.JobId) // Verify the reference was removed after resolution assert.Empty(t, sv.Refs) diff --git a/libs/structs/structwalk/util_test.go b/libs/structs/structwalk/util_test.go index a20d040da27..87e4dbf1e90 100644 --- a/libs/structs/structwalk/util_test.go +++ b/libs/structs/structwalk/util_test.go @@ -36,16 +36,13 @@ type Types struct { MapPtr map[string]*Simple MapIntKey map[int]*Simple - // Fields with omitempty to test ForceSendFields behaviour + // Fields with omitempty: zero values are absent OmitStr string `json:"omit_str,omitempty"` OmitInt int `json:"omit_int,omitempty"` OmitBool bool `json:"omit_bool,omitempty"` FuncField func() string `json:"-"` ChanField chan string `json:"-"` - - // List of field names to be force-sent even if they hold zero values. - ForceSendFields []string `json:"-"` } type SelfIndirect struct { @@ -67,7 +64,4 @@ type Self struct { SelfIndirect SelfIndirect SelfIndirectPtr *SelfIndirect - - // List of field names to be force-sent even if they hold zero values. - ForceSendFields []string `json:"-"` } diff --git a/libs/structs/structwalk/walk.go b/libs/structs/structwalk/walk.go index 0a1186a4e81..36cf61e62aa 100644 --- a/libs/structs/structwalk/walk.go +++ b/libs/structs/structwalk/walk.go @@ -73,6 +73,11 @@ func walkValue(path *structpath.PathNode, val reflect.Value, field *reflect.Stru walkValue(path, val.Elem(), field, visit) case reflect.Struct: + // Opaque structs (e.g. sdk-go types.Time) are scalars in JSON. + if structaccess.IsOpaqueStruct(val.Type()) { + visit(path, val.Interface(), field) + return + } walkStruct(path, val, visit) case reflect.Slice, reflect.Array: @@ -102,19 +107,12 @@ func walkValue(path *structpath.PathNode, val reflect.Value, field *reflect.Stru } func walkStruct(path *structpath.PathNode, s reflect.Value, visit VisitFunc) { - forced := getForceSendFields(s) - st := s.Type() for i := range st.NumField() { sf := st.Field(i) if sf.PkgPath != "" { continue // unexported } - // Skip the ForceSendFields slice itself from traversal. - if sf.Name == "ForceSendFields" { - continue - } - // Directly walk into embedded structs without adding the key to the path. An // anonymous field carrying a json name is not one of these: encoding/json serializes it // as a nested object, so it is walked as a named field below. @@ -135,8 +133,8 @@ func walkStruct(path *structpath.PathNode, s reflect.Value, visit VisitFunc) { } fieldVal := s.Field(i) - // Skip zero values with omitempty unless field is explicitly forced. - if jsonTag.OmitEmpty() && fieldVal.IsZero() && !slices.Contains(forced, sf.Name) { + // Skip zero values with omitempty. + if jsonTag.OmitEmpty() && fieldVal.IsZero() { continue } @@ -150,18 +148,3 @@ func walkStruct(path *structpath.PathNode, s reflect.Value, visit VisitFunc) { walkValue(node, fieldVal, &sf, visit) } } - -func getForceSendFields(v reflect.Value) []string { - if !v.IsValid() || v.Kind() != reflect.Struct { - return nil - } - fsField := v.FieldByName("ForceSendFields") - if !fsField.IsValid() || fsField.Kind() != reflect.Slice { - return nil - } - result, ok := reflect.TypeAssert[[]string](fsField) - if ok { - return result - } - return nil -} diff --git a/libs/structs/structwalk/walk_test.go b/libs/structs/structwalk/walk_test.go index e8a3bf7c09c..770d6a5c9fe 100644 --- a/libs/structs/structwalk/walk_test.go +++ b/libs/structs/structwalk/walk_test.go @@ -5,10 +5,12 @@ import ( "reflect" "slices" "testing" + "time" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/structs/structpath" "github.com/databricks/cli/libs/structs/structtag" - "github.com/databricks/databricks-sdk-go/service/jobs" + "github.com/databricks/sdk-go/core/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -67,28 +69,37 @@ func TestValueTypesEmpty(t *testing.T) { assert.Equal(t, expected, flatten(t, Types{})) assert.Equal(t, expected, flatten(t, &Types{})) +} - // Variant with ForceSendFields on some omitempty fields - forced := Types{ - ForceSendFields: []string{"OmitStr", "OmitBool"}, +func TestValuePointerScalars(t *testing.T) { + type S struct { + Str *string `json:"str,omitempty"` + Bool *bool `json:"bool,omitempty"` + Int *int `json:"int,omitempty"` + NilStr *string `json:"nil_str,omitempty"` + Time *types.Time `json:"time,omitempty"` + Dur *types.Duration `json:"dur,omitempty"` + NilDur *types.Duration `json:"nil_dur,omitempty"` } - forcedResults := flatten(t, forced) - - // Ensure forced fields are present with zero values - assert.Empty(t, forcedResults["omit_str"]) - assert.Equal(t, false, forcedResults["omit_bool"]) - - // Non-forced omitempty zero field should remain absent - _, ok := forcedResults["omit_int"] - assert.False(t, ok, "omit_int should be absent when not forced") + ts := types.NewFromTime(time.Unix(1000, 0)) + dur := types.NewFromDuration(time.Minute) + // Non-nil pointers to zero values are present, nil pointers absent; sdk-go + // native types are leaves, not walked by their Go fields. + assert.Equal(t, map[string]any{ + "str": "", + "bool": false, + "int": 0, + "time": *ts, + "dur": *dur, + }, flatten(t, S{Str: new(""), Bool: new(false), Int: new(0), Time: ts, Dur: dur})) } func TestValueJobSettings(t *testing.T) { jobSettings := jobs.JobSettings{ - Name: "test-job", - MaxConcurrentRuns: 5, - TimeoutSeconds: 3600, + Name: new("test-job"), + MaxConcurrentRuns: new(5), + TimeoutSeconds: new(3600), Tags: map[string]string{"env": "test", "team": "data"}, } diff --git a/libs/structs/structwalk/walktype.go b/libs/structs/structwalk/walktype.go index 4a485f2c1e9..49fceafd1e9 100644 --- a/libs/structs/structwalk/walktype.go +++ b/libs/structs/structwalk/walktype.go @@ -69,9 +69,10 @@ func walkTypeValue(path *structpath.PatternNode, typ reflect.Type, field *reflec typ = typ.Elem() } - // Return early if we're at a leaf scalar. + // Return early if we're at a leaf scalar. Opaque structs (e.g. sdk-go + // types.Time) are scalars in JSON. kind := typ.Kind() - if isScalar(kind) { + if isScalar(kind) || structaccess.IsOpaqueStruct(typ) { return } diff --git a/libs/structs/structwalk/walktype_bench_test.go b/libs/structs/structwalk/walktype_bench_test.go index 5947ba5ca47..1f07d3b14bf 100644 --- a/libs/structs/structwalk/walktype_bench_test.go +++ b/libs/structs/structwalk/walktype_bench_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/databricks/cli/bundle/config" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/jobs" ) func countFields(typ reflect.Type) (int, error) { diff --git a/libs/structs/structwalk/walktype_native_test.go b/libs/structs/structwalk/walktype_native_test.go new file mode 100644 index 00000000000..caed2afaa93 --- /dev/null +++ b/libs/structs/structwalk/walktype_native_test.go @@ -0,0 +1,32 @@ +package structwalk + +import ( + "reflect" + "testing" + + "github.com/databricks/cli/libs/structs/structpath" + "github.com/databricks/sdk-go/core/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// sdk-go native types are JSON strings, so WalkType must treat them as leaves +// instead of reporting their Go fields (e.g. Time.Seconds) as paths. +func TestWalkTypeSDKNativeTypesAreLeaves(t *testing.T) { + type S struct { + Time *types.Time `json:"time,omitempty"` + Dur types.Duration `json:"dur"` + Mask *types.FieldMask[struct{}] `json:"mask,omitempty"` + Name *string `json:"name,omitempty"` + } + + var paths []string + err := WalkType(reflect.TypeFor[S](), func(path *structpath.PatternNode, typ reflect.Type, field *reflect.StructField) bool { + if path != nil { + paths = append(paths, path.String()) + } + return true + }) + require.NoError(t, err) + assert.Equal(t, []string{"time", "dur", "mask", "name"}, paths) +} diff --git a/libs/structs/structwalk/walktype_test.go b/libs/structs/structwalk/walktype_test.go index 937a5ecb1dc..70c84fab0a6 100644 --- a/libs/structs/structwalk/walktype_test.go +++ b/libs/structs/structwalk/walktype_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/databricks/cli/bundle/config" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" "github.com/databricks/cli/libs/structs/structpath" - "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/libs/sync/path.go b/libs/sync/path.go index d85699cf55c..ae799986e1e 100644 --- a/libs/sync/path.go +++ b/libs/sync/path.go @@ -6,25 +6,27 @@ import ( "path" "strings" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/retry" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/libs/utils" + workspace "github.com/databricks/cli/libs/workspaceapi" + sdkscim "github.com/databricks/sdk-go/scim/v1" ) // getStatusWithRetry returns the workspace object at remotePath, retrying transient failures. // The read has no side effects, so a transient server error or a refused HTTP/2 stream // (https://github.com/databricks/cli/issues/6472) is safe to replay instead of failing the sync. -func getStatusWithRetry(ctx context.Context, wsc *databricks.WorkspaceClient, remotePath string) (*workspace.ObjectInfo, error) { +func getStatusWithRetry(ctx context.Context, wsc *sdkclients.Clients, remotePath string) (*workspace.ObjectInfo, error) { return retry.With(ctx, retry.IsTransientRead, func() (*workspace.ObjectInfo, error) { return wsc.Workspace.GetStatusByPath(ctx, remotePath) }) } -func repoPathForPath(me *iam.User, remotePath string) string { - base := path.Clean("/Repos/" + me.UserName) +func repoPathForPath(me *scim.User, remotePath string) string { + base := path.Clean("/Repos/" + utils.Deref(me.UserName)) remotePath = path.Clean(remotePath) for strings.HasPrefix(path.Dir(remotePath), base) && path.Dir(remotePath) != base { remotePath = path.Dir(remotePath) @@ -35,13 +37,17 @@ func repoPathForPath(me *iam.User, remotePath string) string { // EnsureRemotePathIsUsable checks if the specified path is nested under // expected base paths and if it is a directory or repository. // If dryRun is set, a missing remote directory is not created. -func EnsureRemotePathIsUsable(ctx context.Context, wsc *databricks.WorkspaceClient, remotePath string, me *iam.User, dryRun bool) error { +func EnsureRemotePathIsUsable(ctx context.Context, wsc *sdkclients.Clients, remotePath string, me *scim.User, dryRun bool) error { var err error // TODO: we should cache CurrentUser.Me at the SDK level // for now we let clients pass in any existing user they might already have if me == nil { - me, err = wsc.CurrentUser.Me(ctx, iam.MeRequest{}) + user, err := wsc.Scim.Me(ctx, sdkscim.MeRequest{}) + if err != nil { + return err + } + me, err = scim.UserFromSDK(user) if err != nil { return err } @@ -53,7 +59,7 @@ func EnsureRemotePathIsUsable(ctx context.Context, wsc *databricks.WorkspaceClie info, err := getStatusWithRetry(ctx, wsc, remotePath) if err != nil { // We only deal with 404s below. - if !apierr.IsMissing(err) { + if !apierrs.IsMissing(err) { return err } @@ -61,7 +67,7 @@ func EnsureRemotePathIsUsable(ctx context.Context, wsc *databricks.WorkspaceClie if strings.HasPrefix(remotePath, "/Repos/") { repoPath := repoPathForPath(me, remotePath) _, err = getStatusWithRetry(ctx, wsc, repoPath) - if err != nil && apierr.IsMissing(err) { + if err != nil && apierrs.IsMissing(err) { return fmt.Errorf("%s does not exist; please create it first", repoPath) } } diff --git a/libs/sync/path_test.go b/libs/sync/path_test.go index 2d492251f22..2894621c1e3 100644 --- a/libs/sync/path_test.go +++ b/libs/sync/path_test.go @@ -3,13 +3,13 @@ package sync import ( "testing" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/stretchr/testify/assert" ) func TestPathToRepoPath(t *testing.T) { - me := iam.User{ - UserName: "jane@doe.com", + me := scim.User{ + UserName: new("jane@doe.com"), } assert.Equal(t, "/Repos/jane@doe.com/foo", repoPathForPath(&me, "/Repos/jane@doe.com/foo/bar/qux")) diff --git a/libs/sync/sync.go b/libs/sync/sync.go index 1e31b85481f..5e19505320a 100644 --- a/libs/sync/sync.go +++ b/libs/sync/sync.go @@ -11,9 +11,9 @@ import ( "github.com/databricks/cli/libs/fileset" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/retry" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/databricks/cli/libs/vfs" - "github.com/databricks/databricks-sdk-go" - "github.com/databricks/databricks-sdk-go/service/iam" ) type OutputHandler func(context.Context, <-chan Event) @@ -41,9 +41,9 @@ type SyncOptions struct { PollInterval time.Duration - WorkspaceClient *databricks.WorkspaceClient + WorkspaceClient *sdkclients.Clients - CurrentUser *iam.User + CurrentUser *scim.User Host string diff --git a/libs/telemetry/logger.go b/libs/telemetry/logger.go index 6f366463a7a..ee6a6876805 100644 --- a/libs/telemetry/logger.go +++ b/libs/telemetry/logger.go @@ -9,13 +9,13 @@ import ( "strconv" "time" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/telemetry/protos" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/sdk-go/core/apierr" "github.com/google/uuid" ) @@ -108,7 +108,7 @@ func Upload(ctx context.Context, ec protos.ExecutionContext) error { return nil } - apiClient, err := client.New(cmdctx.ConfigUsed(ctx)) + apiClient, err := apiclient.New(cmdctx.ConfigUsed(ctx)) if err != nil { return fmt.Errorf("failed to create API client: %w", err) } @@ -170,18 +170,16 @@ func Upload(ctx context.Context, ec protos.ExecutionContext) error { return fmt.Errorf("uploading telemetry logs timed out: %w", err) } - // We retry for all 5xx responses. Note that the SDK only retries for 503 and 429 + // We retry for all 5xx responses. Note that the client transport only retries for 503 and 429 // (as of 6th March 2025) so we need some additional logic here to retry for other // 5xx responses. - // Note: We should never see a 503 or 429 here because the SDK default timeout - // of 1 minute is more than the 3 second timeout we set above. - // - // SDK ref: https://github.com/databricks/databricks-sdk-go/blob/cdb28002afacb8b762348534a4c4040a9f19c24b/apierr/errors.go#L91 + // Note: We should never see a 503 or 429 here because the transport retry + // timeout is more than the 3 second timeout we set above. // // The UI infra team (who owns the /telemetry-ext API) recommends retrying for // all 5xx responses. - if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.StatusCode >= 500 { - log.Infof(ctx, "Attempt %d failed due to a server side error. Retrying status code: %d", i+1, apiErr.StatusCode) + if apiErr, ok := errors.AsType[*apierr.APIError](err); ok && apiErr.HTTPStatusCode() >= 500 { + log.Infof(ctx, "Attempt %d failed due to a server side error. Retrying status code: %d", i+1, apiErr.HTTPStatusCode()) remainingTime := time.Until(deadline) if remainingTime < waitBetweenRetries { @@ -197,7 +195,7 @@ func Upload(ctx context.Context, ec protos.ExecutionContext) error { return errors.New("failed to upload telemetry logs after three attempts") } -func attempt(ctx context.Context, apiClient *client.DatabricksClient, protoLogs []string) (*ResponseBody, error) { +func attempt(ctx context.Context, apiClient *apiclient.Client, protoLogs []string) (*ResponseBody, error) { // Without the workspace routing header, telemetry on unified hosts is // recorded in a central shard instead of the user's workspace. resp := &ResponseBody{} diff --git a/libs/telemetry/logger_test.go b/libs/telemetry/logger_test.go index abb7c198073..7bc4878f150 100644 --- a/libs/telemetry/logger_test.go +++ b/libs/telemetry/logger_test.go @@ -6,7 +6,6 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/telemetry/protos" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -65,9 +64,8 @@ func uploadRetriesFor(t *testing.T, statusCode int) { if count == 1 { return testserver.Response{ StatusCode: statusCode, - Body: apierr.APIError{ - StatusCode: statusCode, - Message: "Some error", + Body: map[string]string{ + "message": "Some error", }, } } diff --git a/libs/template/helpers.go b/libs/template/helpers.go index acf651beb85..1af816d6ff4 100644 --- a/libs/template/helpers.go +++ b/libs/template/helpers.go @@ -12,11 +12,16 @@ import ( "strings" "text/template" + "github.com/databricks/cli/libs/apierrs" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/iamutil" - "github.com/databricks/databricks-sdk-go/apierr" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/apierr" + sdkscim "github.com/databricks/sdk-go/scim/v1" + "github.com/databricks/sdk-go/uc/metastores/v1" "github.com/google/uuid" ) @@ -35,7 +40,7 @@ type pair struct { } var ( - cachedUser *iam.User + cachedUser *scim.User cachedIsServicePrincipal *bool cachedCatalog *string ) @@ -129,21 +134,21 @@ func loadHelpers(ctx context.Context) template.FuncMap { "user_name": func() (string, error) { if cachedUser == nil { var err error - cachedUser, err = w.CurrentUser.Me(ctx, iam.MeRequest{}) + cachedUser, err = currentUser(ctx, w) if err != nil { return "", err } } - result := cachedUser.UserName + result := utils.Deref(cachedUser.UserName) if result == "" { - result = cachedUser.Id + result = utils.Deref(cachedUser.Id) } return result, nil }, "short_name": func() (string, error) { if cachedUser == nil { var err error - cachedUser, err = w.CurrentUser.Me(ctx, iam.MeRequest{}) + cachedUser, err = currentUser(ctx, w) if err != nil { return "", err } @@ -154,9 +159,9 @@ func loadHelpers(ctx context.Context) template.FuncMap { // Unity Catalog is not enabled, return an empty string. "default_catalog": func() (string, error) { if cachedCatalog == nil { - metastore, err := w.Metastores.Current(ctx) + metastore, err := w.Metastores.GetCurrentMetastoreAssignment(ctx, metastores.GetCurrentMetastoreAssignmentRequest{}) if err != nil { - if aerr, ok := errors.AsType[*apierr.APIError](err); ok && (slices.Contains(metastoreDisabledErrorCodes, aerr.ErrorCode) || aerr.Message == "Bad Target: /api/2.1/unity-catalog/current-metastore-assignment") { + if aerr, ok := errors.AsType[*apierr.APIError](err); ok && (slices.Contains(metastoreDisabledErrorCodes, apierrs.ErrorCode(aerr)) || aerr.Message() == "Bad Target: /api/2.1/unity-catalog/current-metastore-assignment") { // Ignore: access denied or workspace doesn't have a metastore assigned empty_default := "" cachedCatalog = &empty_default @@ -164,7 +169,7 @@ func loadHelpers(ctx context.Context) template.FuncMap { } return "", err } - cachedCatalog = &metastore.DefaultCatalogName + cachedCatalog = new(utils.Deref(metastore.DefaultCatalogName)) } return *cachedCatalog, nil }, @@ -174,7 +179,7 @@ func loadHelpers(ctx context.Context) template.FuncMap { } if cachedUser == nil { var err error - cachedUser, err = w.CurrentUser.Me(ctx, iam.MeRequest{}) + cachedUser, err = currentUser(ctx, w) if err != nil { return false, err } @@ -195,3 +200,11 @@ func loadHelpers(ctx context.Context) template.FuncMap { }, } } + +func currentUser(ctx context.Context, w *sdkclients.Clients) (*scim.User, error) { + user, err := w.Scim.Me(ctx, sdkscim.MeRequest{}) + if err != nil { + return nil, err + } + return scim.UserFromSDK(user) +} diff --git a/libs/template/helpers_test.go b/libs/template/helpers_test.go index 674dbe7bb34..303b03284d9 100644 --- a/libs/template/helpers_test.go +++ b/libs/template/helpers_test.go @@ -9,7 +9,7 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" workspaceConfig "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -139,7 +139,7 @@ func TestTemplateMapPairFunction(t *testing.T) { func TestWorkspaceHost(t *testing.T) { ctx := t.Context() - w := &databricks.WorkspaceClient{ + w := &sdkclients.Clients{ Config: &workspaceConfig.Config{ Host: "https://myhost.test", }, @@ -164,7 +164,7 @@ func TestWorkspaceHostNotConfigured(t *testing.T) { cmd := cmdio.NewIO(ctx, flags.OutputJSON, strings.NewReader(""), os.Stdout, os.Stderr, "", "template") ctx = cmdio.InContext(ctx, cmd) - w := &databricks.WorkspaceClient{ + w := &sdkclients.Clients{ Config: &workspaceConfig.Config{}, } ctx = cmdctx.SetWorkspaceClient(ctx, w) diff --git a/libs/template/renderer_test.go b/libs/template/renderer_test.go index 27fa44dc9ce..0e178885a44 100644 --- a/libs/template/renderer_test.go +++ b/libs/template/renderer_test.go @@ -19,11 +19,12 @@ import ( "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/dbr" "github.com/databricks/cli/libs/filer" + "github.com/databricks/cli/libs/iamutil" "github.com/databricks/cli/libs/logdiag" + "github.com/databricks/cli/libs/sdkclients" + "github.com/databricks/cli/libs/sdktypes/scim/v1" "github.com/databricks/cli/libs/tags" - "github.com/databricks/databricks-sdk-go" workspaceConfig "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/service/iam" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -34,14 +35,14 @@ func assertBuiltinTemplateValid(t *testing.T, template string, settings map[stri templateFS, err := fs.Sub(builtinTemplates, path.Join("templates", template)) require.NoError(t, err) - w := &databricks.WorkspaceClient{ + w := &sdkclients.Clients{ Config: &workspaceConfig.Config{Host: "https://myhost.test"}, } // Prepare helpers - cachedUser = &iam.User{UserName: "user@domain.com"} + cachedUser = &scim.User{UserName: new("user@domain.com")} if isServicePrincipal { - cachedUser.UserName = "1d410060-a513-496f-a197-23cc82e5f46d" + cachedUser.UserName = new("1d410060-a513-496f-a197-23cc82e5f46d") } cachedIsServicePrincipal = &isServicePrincipal ctx = cmdctx.SetWorkspaceClient(ctx, w) @@ -75,7 +76,10 @@ func assertBuiltinTemplateValid(t *testing.T, template string, settings map[stri // Apply initialize / validation mutators bundle.ApplyFuncContext(ctx, b, func(ctx context.Context, b *bundle.Bundle) { - b.Config.Workspace.CurrentUser = &bundleConfig.User{User: cachedUser} + b.Config.Workspace.CurrentUser = &bundleConfig.User{ + ShortName: iamutil.GetShortUserName(cachedUser), + User: cachedUser, + } }) b.Tagging = tags.ForCloud(w.Config) diff --git a/libs/template/schema_renderer_test.go b/libs/template/schema_renderer_test.go index 9e6c1cc1ca9..904c0a0bbef 100644 --- a/libs/template/schema_renderer_test.go +++ b/libs/template/schema_renderer_test.go @@ -6,7 +6,7 @@ import ( "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/cmdctx" - "github.com/databricks/databricks-sdk-go" + "github.com/databricks/cli/libs/sdkclients" workspaceConfig "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -29,7 +29,7 @@ func TestRenderSchemaWithLocalTemplate(t *testing.T) { testutil.WriteFile(t, inputFile, `{"name": "TestUser"}`) ctx := t.Context() - ctx = cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{}) + ctx = cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{}) reader := NewLocalReader(tmpDir) result, err := RenderSchema(ctx, reader, RenderSchemaInput{ @@ -55,7 +55,7 @@ func TestRenderSchemaWithoutInputFile(t *testing.T) { testutil.WriteFile(t, filepath.Join(tmpDir, "databricks_template_schema.json"), schemaContent) ctx := t.Context() - ctx = cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{}) + ctx = cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{}) reader := NewLocalReader(tmpDir) result, err := RenderSchema(ctx, reader, RenderSchemaInput{}) @@ -76,7 +76,7 @@ func TestRenderSchemaWithMissingVariable(t *testing.T) { testutil.WriteFile(t, inputFile, `{}`) ctx := t.Context() - ctx = cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{}) + ctx = cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{}) reader := NewLocalReader(tmpDir) // Missing variables are rendered as empty strings @@ -94,7 +94,7 @@ func TestRenderSchemaWithInvalidInputFile(t *testing.T) { testutil.WriteFile(t, filepath.Join(tmpDir, "databricks_template_schema.json"), schemaContent) ctx := t.Context() - ctx = cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{}) + ctx = cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{}) reader := NewLocalReader(tmpDir) _, err := RenderSchema(ctx, reader, RenderSchemaInput{ @@ -114,7 +114,7 @@ func TestRenderSchemaWithMalformedInputJson(t *testing.T) { testutil.WriteFile(t, inputFile, `{invalid json}`) ctx := t.Context() - ctx = cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{}) + ctx = cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{}) reader := NewLocalReader(tmpDir) _, err := RenderSchema(ctx, reader, RenderSchemaInput{ @@ -147,7 +147,7 @@ func TestRenderSchemaWithSimpleBuiltinTemplate(t *testing.T) { testutil.WriteFile(t, filepath.Join(tmpDir, "databricks_template_schema.json"), schemaContent) ctx := t.Context() - ctx = cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{ + ctx = cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{ Config: &workspaceConfig.Config{ Host: "https://test.databricks.com", }, diff --git a/libs/template/writer_test.go b/libs/template/writer_test.go index b9cadd65c93..2a0fad3d736 100644 --- a/libs/template/writer_test.go +++ b/libs/template/writer_test.go @@ -8,8 +8,8 @@ import ( "github.com/databricks/cli/libs/dbr" "github.com/databricks/cli/libs/filer" "github.com/databricks/cli/libs/jsonschema" + "github.com/databricks/cli/libs/sdkclients" "github.com/databricks/cli/libs/telemetry/protos" - "github.com/databricks/databricks-sdk-go" workspaceConfig "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -33,7 +33,7 @@ func TestDefaultWriterConfigureOnDBR(t *testing.T) { } ctx := dbr.MockRuntime(t.Context(), dbr.Environment{IsDbr: true, Version: "15.4"}) - ctx = cmdctx.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{ + ctx = cmdctx.SetWorkspaceClient(ctx, &sdkclients.Clients{ Config: &workspaceConfig.Config{Host: "https://myhost.test"}, }) w := &defaultWriter{} diff --git a/libs/testdiff/replacement.go b/libs/testdiff/replacement.go index a8cc18b2fb4..c1c9b4f556d 100644 --- a/libs/testdiff/replacement.go +++ b/libs/testdiff/replacement.go @@ -12,8 +12,9 @@ import ( "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/iamutil" + "github.com/databricks/cli/libs/sdktypes/scim/v1" + "github.com/databricks/cli/libs/utils" "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/service/iam" "golang.org/x/mod/semver" ) @@ -198,32 +199,32 @@ func PrepareReplacementsWorkspaceConfig(t testutil.TestingT, r *ReplacementsCont r.SetPath(cfg.DatabricksCliPath, "[DATABRICKS_CLI_PATH]") } -func PrepareReplacementsUser(t testutil.TestingT, r *ReplacementsContext, u iam.User) { +func PrepareReplacementsUser(t testutil.TestingT, r *ReplacementsContext, u scim.User) { t.Helper() // There could be exact matches or overlap between different name fields, so sort them by length // to ensure we match the largest one first and map them all to the same token - r.Set(u.UserName, testerName) - r.Set(u.DisplayName, testerName) + r.Set(utils.Deref(u.UserName), testerName) + r.Set(utils.Deref(u.DisplayName), testerName) if u.Name != nil { - r.Set(u.Name.FamilyName, testerName) - r.Set(u.Name.GivenName, testerName) + r.Set(utils.Deref(u.Name.FamilyName), testerName) + r.Set(utils.Deref(u.Name.GivenName), testerName) } for _, val := range u.Emails { - r.Set(val.Value, testerName) + r.Set(utils.Deref(val.Value), testerName) } r.Set(iamutil.GetShortUserName(&u), testerName) for _, val := range u.Groups { - r.Set(val.Value, "[USERGROUP]") + r.Set(utils.Deref(val.Value), "[USERGROUP]") } - r.Set(u.Id, "[USERID]") + r.Set(utils.Deref(u.Id), "[USERID]") for _, val := range u.Roles { - r.Set(val.Value, "[USERROLE]") + r.Set(utils.Deref(val.Value), "[USERROLE]") } } diff --git a/libs/testproxy/server.go b/libs/testproxy/server.go index be5bcfd4aa7..017e9ed8ff0 100644 --- a/libs/testproxy/server.go +++ b/libs/testproxy/server.go @@ -2,15 +2,14 @@ package testproxy import ( "bytes" - "errors" + "io" "net/http" "net/http/httptest" "github.com/databricks/cli/internal/testutil" + "github.com/databricks/cli/libs/apiclient" "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/config" - "github.com/databricks/databricks-sdk-go/httpclient" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -20,7 +19,8 @@ type ProxyServer struct { t testutil.TestingT - apiClient *httpclient.ApiClient + upstream *config.Config + httpClient *http.Client RequestCallback func(request *testserver.Request) ResponseCallback func(request *testserver.Request, response *testserver.EncodedResponse) } @@ -40,14 +40,13 @@ type ProxyServer struct { // An upstream with no fields set resolves a real workspace and its auth from the // environment; an explicit host and token point at a testserver instead. func New(t testutil.TestingT, upstream *config.Config) *ProxyServer { + require.NoError(t, upstream.EnsureResolved()) s := &ProxyServer{ - t: t, + t: t, + upstream: upstream, + httpClient: apiclient.HTTPClient(upstream), } - clientCfg, err := config.HTTPClientConfigFromConfig(upstream) - require.NoError(t, err) - s.apiClient = httpclient.NewApiClient(clientCfg) - // Set up the proxy handler as the default handler for all requests. server := httptest.NewServer(http.HandlerFunc(s.proxyToUpstream)) t.Cleanup(server.Close) @@ -56,20 +55,9 @@ func New(t testutil.TestingT, upstream *config.Config) *ProxyServer { return s } -func (s *ProxyServer) reqBody(r testserver.Request) any { - // The SDK expects the query parameters to be specified in the "request body" - // argument for GET, DELETE, and HEAD requests in the .Do method. - if r.Method == http.MethodGet || r.Method == http.MethodDelete || r.Method == http.MethodHead { - queryParams := make(map[string]any) - for k, v := range r.URL.Query() { - queryParams[k] = v[0] - } - return queryParams - } - - // Otherwise, return the raw body. - return r.Body -} +// includeResponseHeaders lists the response headers passed through to the +// client in addition to the status and body. +var includeResponseHeaders = []string{"X-Databricks-Org-Id"} func (s *ProxyServer) proxyToUpstream(w http.ResponseWriter, r *http.Request) { request := testserver.NewRequest(s.t, r, nil) @@ -77,111 +65,67 @@ func (s *ProxyServer) proxyToUpstream(w http.ResponseWriter, r *http.Request) { s.RequestCallback(&request) } - headers := make(map[string]string) - for k, v := range r.Header { - // Authorization headers will be set by the SDK. Do not pass them along here. - if k == "Authorization" { - continue - } - // The default HTTP client in Go sets the Accept-Encoding header to - // "gzip". Since it is originally meant to be read by the server and - // will be set again when the SDK makes the request to the workspace, do - // not pass it along here. - if k == "Accept-Encoding" { - continue + encodedResponse, header := s.forward(r, request.Body) + + for _, k := range includeResponseHeaders { + if v := header.Get(k); v != "" { + w.Header().Set(k, v) } - headers[k] = v[0] } + w.WriteHeader(encodedResponse.StatusCode) - queryParams := make(map[string]any) - for k, v := range r.URL.Query() { - queryParams[k] = v[0] - } + _, err := w.Write(encodedResponse.Body) + assert.NoError(s.t, err) - reqBody := s.reqBody(request) - respBody := bytes.Buffer{} - - // List of response headers to pass through to the client. - // We can extend this code to pass all X-Databricks headers if we introduce a - // more powerful visitor like `WithRequestHeaders` to the SDK. That is left - // as a future exercise for now. - includeResponseHeaders := []string{"X-Databricks-Org-Id"} - responseHeaders := make(map[string]*string) - - visitors := []httpclient.DoOption{ - httpclient.WithRequestHeaders(headers), - httpclient.WithQueryParameters(queryParams), - httpclient.WithRequestData(reqBody), - httpclient.WithResponseUnmarshal(&respBody), + if s.ResponseCallback != nil { + s.ResponseCallback(&request, encodedResponse) } +} - for _, header := range includeResponseHeaders { - responseHeaders[header] = new(string) - visitors = append(visitors, httpclient.WithResponseHeader(header, responseHeaders[header])) +// forward sends the request to the upstream with the upstream's credentials +// and returns its response verbatim, error bodies included, so callers see +// exactly what the workspace returned. +func (s *ProxyServer) forward(r *http.Request, body []byte) (*testserver.EncodedResponse, http.Header) { + upstreamURL := s.upstream.CanonicalHostName() + r.URL.Path + if r.URL.RawQuery != "" { + upstreamURL += "?" + r.URL.RawQuery } - - err := s.apiClient.Do(s.t.Context(), r.Method, r.URL.Path, - visitors..., - ) - - var encodedResponse *testserver.EncodedResponse - - // API errors from the SDK are of type [apierr.APIError]. Forward the raw - // response bytes verbatim — including any error details — so callers see - // exactly what the workspace returned. Re-marshalling from the parsed - // APIError would drop fields the SDK doesn't surface (e.g. metadata in - // details[]) and silently break callers that inspect them. - if apiErr, ok := errors.AsType[*apierr.APIError](err); ok { - rw := apiErr.ResponseWrapper - if rw == nil { - // The SDK populates ResponseWrapper for every APIError produced - // from a real HTTP response. If this ever fires the SDK changed - // shape and we need to revisit how we forward error bodies. - panic("apierr.APIError has no ResponseWrapper") - } - encodedResponse = &testserver.EncodedResponse{ - StatusCode: rw.Response.StatusCode, - Body: rw.DebugBytes, - } - // Visitors registered via WithResponseHeader are not invoked when - // the SDK returns an error, so populate the include list directly - // from the original response headers. - for _, header := range includeResponseHeaders { - if v := rw.Response.Header.Get(header); v != "" { - *responseHeaders[header] = v - } - } + var reqBody io.Reader + if len(body) > 0 { + reqBody = bytes.NewReader(body) } - - // Something else went wrong. - if encodedResponse == nil && err != nil { - encodedResponse = &testserver.EncodedResponse{ - StatusCode: 500, - Body: []byte(err.Error()), - } + req, err := http.NewRequestWithContext(s.t.Context(), r.Method, upstreamURL, reqBody) + if err != nil { + return internalError(err), nil } - - // Successful response - if encodedResponse == nil { - encodedResponse = &testserver.EncodedResponse{ - StatusCode: 200, - Body: respBody.Bytes(), + for k, v := range r.Header { + // Authorization is set from the upstream config below. The default + // HTTP client in Go sets Accept-Encoding to "gzip"; it is meant for + // this proxy and will be set again for the upstream request. + if k == "Authorization" || k == "Accept-Encoding" { + continue } + req.Header.Set(k, v[0]) } - - // Send response to client. - if len(responseHeaders) > 0 { - for k, v := range responseHeaders { - w.Header()[k] = []string{*v} - } + if err := s.upstream.Authenticate(req); err != nil { + return internalError(err), nil } - w.WriteHeader(encodedResponse.StatusCode) - - _, err = w.Write(encodedResponse.Body) - assert.NoError(s.t, err) + resp, err := s.httpClient.Do(req) + if err != nil { + return internalError(err), nil + } + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return internalError(err), nil + } + return &testserver.EncodedResponse{StatusCode: resp.StatusCode, Body: respBody}, resp.Header +} - if s.ResponseCallback != nil { - s.ResponseCallback(&request, encodedResponse) +func internalError(err error) *testserver.EncodedResponse { + return &testserver.EncodedResponse{ + StatusCode: 500, + Body: []byte(err.Error()), } } diff --git a/libs/testserver/alerts.go b/libs/testserver/alerts.go index 48612ad539d..7d27473cefe 100644 --- a/libs/testserver/alerts.go +++ b/libs/testserver/alerts.go @@ -5,12 +5,12 @@ import ( "fmt" "net/http" "path" - "slices" "strconv" "strings" - "github.com/databricks/databricks-sdk-go/service/sql" - "github.com/databricks/databricks-sdk-go/service/workspace" + alerts "github.com/databricks/cli/libs/sdktypes/alerts/v2" + "github.com/databricks/cli/libs/utils" + workspaceapi "github.com/databricks/cli/libs/workspaceapi" ) // alertFile mirrors the schema of a .dbalert.json file. It is the inverse of @@ -20,27 +20,27 @@ import ( type alertFile struct { CustomSummary string `json:"custom_summary,omitempty"` Evaluation *materializedEvaluation `json:"evaluation,omitempty"` - Schedule *sql.CronSchedule `json:"schedule,omitempty"` + Schedule *alerts.CronSchedule `json:"schedule,omitempty"` QueryLines []string `json:"query_lines,omitempty"` CustomDescriptionLines []string `json:"custom_description_lines,omitempty"` } // materializedEvaluation mirrors the field order the alerts backend uses when it -// writes the .dbalert.json file, which differs from sql.AlertV2Evaluation: the +// writes the .dbalert.json file, which differs from alerts.AlertEvaluation: the // backend emits source before comparison_operator and always writes a // notification object (an empty {} when none is configured). type materializedEvaluation struct { - Source sql.AlertV2OperandColumn `json:"source"` - ComparisonOperator sql.ComparisonOperator `json:"comparison_operator"` - Threshold *materializedOperand `json:"threshold,omitempty"` - Notification *sql.AlertV2Notification `json:"notification"` + Source alerts.AlertOperandColumn `json:"source"` + ComparisonOperator alerts.ComparisonOperator `json:"comparison_operator"` + Threshold *materializedOperand `json:"threshold,omitempty"` + Notification *alerts.AlertNotification `json:"notification"` } -// materializedOperand and materializedOperandValue mirror sql.AlertV2Operand but +// materializedOperand and materializedOperandValue mirror alerts.AlertOperand but // format double_value via jsonFloat so it keeps its decimal point in the file. type materializedOperand struct { - Column *sql.AlertV2OperandColumn `json:"column,omitempty"` - Value *materializedOperandValue `json:"value,omitempty"` + Column *alerts.AlertOperandColumn `json:"column,omitempty"` + Value *materializedOperandValue `json:"value,omitempty"` } type materializedOperandValue struct { @@ -63,20 +63,20 @@ func (f jsonFloat) MarshalJSON() ([]byte, error) { } // materializeThreshold converts the SDK threshold into the file representation. -// double_value is emitted whenever the source request set it explicitly (tracked -// via ForceSendFields), even when it is the zero value. -func materializeThreshold(t *sql.AlertV2Operand) *materializedOperand { +// double_value is emitted whenever the source request set it, even when it is +// the zero value. +func materializeThreshold(t *alerts.AlertOperand) *materializedOperand { if t == nil { return nil } out := &materializedOperand{Column: t.Column} if v := t.Value; v != nil { out.Value = &materializedOperandValue{ - BoolValue: v.BoolValue, - StringValue: v.StringValue, + BoolValue: utils.Deref(v.BoolValue), + StringValue: utils.Deref(v.StringValue), } - if v.DoubleValue != 0 || slices.Contains(v.ForceSendFields, "DoubleValue") { - d := jsonFloat(v.DoubleValue) + if v.DoubleValue != nil { + d := jsonFloat(*v.DoubleValue) out.Value.DoubleValue = &d } } @@ -85,8 +85,8 @@ func materializeThreshold(t *sql.AlertV2Operand) *materializedOperand { // alertFilePath returns the workspace path of the .dbalert.json file the backend // materializes for an alert: /.dbalert.json. -func alertFilePath(alert sql.AlertV2) string { - return path.Join(alert.ParentPath, alert.DisplayName+".dbalert.json") +func alertFilePath(alert alerts.Alert) string { + return path.Join(utils.Deref(alert.ParentPath), utils.Deref(alert.DisplayName)+".dbalert.json") } // splitLines reverses the line-joining done in load_dbalert_files.go: each line @@ -101,35 +101,38 @@ func splitLines(s string) []string { // writeAlertFile materializes the .dbalert.json file for an alert. On real cloud // the backend writes this file as a side effect of alert creation/update, which // the `workspace export` round-trip and `bundle generate alert` rely on. -func (s *FakeWorkspace) writeAlertFile(alert sql.AlertV2) error { - if alert.ParentPath == "" || alert.DisplayName == "" { +func (s *FakeWorkspace) writeAlertFile(alert alerts.Alert) error { + if utils.Deref(alert.ParentPath) == "" || utils.Deref(alert.DisplayName) == "" { return nil } - notification := alert.Evaluation.Notification + evaluation := alert.Evaluation + if evaluation == nil { + evaluation = &alerts.AlertEvaluation{} + } + notification := evaluation.Notification if notification != nil { - // The backend always serializes notify_on_ok in the file, even when - // false; the SDK marshaler would otherwise drop the zero value. + // The backend always serializes notify_on_ok in the file, even when false. n := *notification - n.ForceSendFields = append(n.ForceSendFields, "NotifyOnOk") + n.NotifyOnOk = new(utils.Deref(n.NotifyOnOk)) notification = &n } else { // The backend always writes a notification object, materializing an // empty {} when the alert has no notification configured. - notification = &sql.AlertV2Notification{} + notification = &alerts.AlertNotification{} } af := alertFile{ - CustomSummary: alert.CustomSummary, + CustomSummary: utils.Deref(alert.CustomSummary), Evaluation: &materializedEvaluation{ - Source: alert.Evaluation.Source, - ComparisonOperator: alert.Evaluation.ComparisonOperator, - Threshold: materializeThreshold(alert.Evaluation.Threshold), + Source: utils.Deref(evaluation.Source), + ComparisonOperator: evaluation.ComparisonOperator, + Threshold: materializeThreshold(evaluation.Threshold), Notification: notification, }, - Schedule: &alert.Schedule, - QueryLines: splitLines(alert.QueryText), - CustomDescriptionLines: splitLines(alert.CustomDescription), + Schedule: alert.Schedule, + QueryLines: splitLines(utils.Deref(alert.QueryText)), + CustomDescriptionLines: splitLines(utils.Deref(alert.CustomDescription)), } data, err := json.MarshalIndent(af, "", " ") @@ -140,7 +143,7 @@ func (s *FakeWorkspace) writeAlertFile(alert sql.AlertV2) error { filePath := alertFilePath(alert) s.files[filePath] = FileEntry{ - Info: workspace.ObjectInfo{ + Info: workspaceapi.ObjectInfo{ ObjectType: "FILE", Path: filePath, ObjectId: nextTreenodeID(), @@ -151,7 +154,7 @@ func (s *FakeWorkspace) writeAlertFile(alert sql.AlertV2) error { } func (s *FakeWorkspace) AlertsUpsert(req Request, alertId string) Response { - var alert sql.AlertV2 + var alert alerts.Alert if err := json.Unmarshal(req.Body, &alert); err != nil { return Response{ @@ -173,8 +176,8 @@ func (s *FakeWorkspace) AlertsUpsert(req Request, alertId string) Response { alertId = nextUUID() } - alert.Id = alertId - alert.LifecycleState = sql.AlertLifecycleStateActive + alert.Id = utils.NonZero(alertId) + alert.LifecycleState = alerts.AlertLifecycleState_Active s.Alerts[alertId] = alert if err := s.writeAlertFile(alert); err != nil { @@ -205,7 +208,7 @@ func (s *FakeWorkspace) AlertsDelete(alertId string, purge bool) Response { if purge { delete(s.Alerts, alertId) } else { - alert.LifecycleState = sql.AlertLifecycleStateDeleted + alert.LifecycleState = alerts.AlertLifecycleState_Deleted s.Alerts[alertId] = alert } diff --git a/libs/testserver/apps.go b/libs/testserver/apps.go index c70115d060f..739a68e03a9 100644 --- a/libs/testserver/apps.go +++ b/libs/testserver/apps.go @@ -7,8 +7,9 @@ import ( "strconv" "strings" - "github.com/databricks/databricks-sdk-go/service/apps" - "github.com/databricks/databricks-sdk-go/service/iam" + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + apps "github.com/databricks/cli/libs/sdktypes/apps/v1" + "github.com/databricks/cli/libs/utils" ) const ( @@ -22,8 +23,8 @@ const ( // securable types get none. See https://github.com/databricks/cli/issues/6342 func setUcSecurableKinds(app *apps.App) { for _, res := range app.Resources { - if res.UcSecurable != nil && res.UcSecurable.SecurableType == apps.AppResourceUcSecurableUcSecurableTypeTable { - res.UcSecurable.SecurableKind = "TABLE_DELTA" + if res.UcSecurable != nil && res.UcSecurable.SecurableType == apps.AppResourceUcSecurable_UcSecurableType_Table { + res.UcSecurable.SecurableKind = utils.NonZero("TABLE_DELTA") } } } @@ -85,7 +86,7 @@ func (s *FakeWorkspace) AppsCreateUpdate(req Request, name string) Response { return Response{Body: fmt.Sprintf("internal error: %s", err), StatusCode: http.StatusInternalServerError} } - for field := range strings.SplitSeq(updateReq.UpdateMask, ",") { + for field := range strings.SplitSeq(utils.Deref(updateReq.UpdateMask), ",") { if v, ok := updateMap[strings.TrimSpace(field)]; ok { existingMap[strings.TrimSpace(field)] = v } @@ -104,8 +105,8 @@ func (s *FakeWorkspace) AppsCreateUpdate(req Request, name string) Response { return Response{ Body: apps.AppUpdate{ - Status: &apps.AppUpdateUpdateStatus{ - State: apps.AppUpdateUpdateStatusUpdateStateSucceeded, + Status: &apps.AppUpdate_UpdateStatus{ + State: apps.AppUpdate_UpdateStatus_UpdateState_Succeeded, }, }, } @@ -121,8 +122,8 @@ func (s *FakeWorkspace) AppsGetUpdate(_ Request, name string) Response { return Response{ Body: apps.AppUpdate{ - Status: &apps.AppUpdateUpdateStatus{ - State: apps.AppUpdateUpdateStatusUpdateStateSucceeded, + Status: &apps.AppUpdate_UpdateStatus{ + State: apps.AppUpdate_UpdateStatus_UpdateState_Succeeded, }, }, } @@ -141,10 +142,10 @@ func (s *FakeWorkspace) AppsCreateDeployment(req Request, name string) Response return Response{StatusCode: 500, Body: fmt.Sprintf("internal error: %s", err)} } - deployment.DeploymentId = fmt.Sprintf("deploy-%d", nextID()) + deployment.DeploymentId = utils.NonZero(fmt.Sprintf("deploy-%d", nextID())) deployment.Status = &apps.AppDeploymentStatus{ - State: apps.AppDeploymentStateSucceeded, - Message: "Deployment succeeded", + State: apps.AppDeployment_State_Succeeded, + Message: utils.NonZero("Deployment succeeded"), } app.ActiveDeployment = &deployment @@ -162,7 +163,7 @@ func (s *FakeWorkspace) AppsGetDeployment(_ Request, name, deploymentID string) return Response{StatusCode: 404} } - if app.ActiveDeployment == nil || app.ActiveDeployment.DeploymentId != deploymentID { + if app.ActiveDeployment == nil || utils.Deref(app.ActiveDeployment.DeploymentId) != deploymentID { return Response{StatusCode: 404} } @@ -190,13 +191,13 @@ func (s *FakeWorkspace) AppsStart(_ Request, name string) Response { } app.ComputeStatus = &apps.ComputeStatus{ - State: apps.ComputeStateActive, - Message: "App compute is active.", + State: apps.ComputeStatus_ComputeState_Active, + Message: utils.NonZero("App compute is active."), } // Starting the compute brings the application up. app.AppStatus = &apps.ApplicationStatus{ State: "RUNNING", - Message: appStatusRunningMessage, + Message: utils.NonZero(appStatusRunningMessage), } s.Apps[name] = app @@ -212,13 +213,13 @@ func (s *FakeWorkspace) AppsStop(_ Request, name string) Response { } app.ComputeStatus = &apps.ComputeStatus{ - State: apps.ComputeStateStopped, - Message: "Start the app compute to deploy the app.", + State: apps.ComputeStatus_ComputeState_Stopped, + Message: utils.NonZero("Start the app compute to deploy the app."), } // Stopping the compute takes the application down. app.AppStatus = &apps.ApplicationStatus{ State: "UNAVAILABLE", - Message: appStatusUnavailableMessage, + Message: utils.NonZero(appStatusUnavailableMessage), } // The backend clears both deployments on stop for the apps these fixtures use, // so the deploy-only fields read back empty. Match that so drift tests are realistic. @@ -256,7 +257,7 @@ func (s *FakeWorkspace) AppsDelete(name string) Response { return Response{StatusCode: 404} } - if app.ComputeStatus != nil && app.ComputeStatus.State == apps.ComputeStateDeleting { + if app.ComputeStatus != nil && app.ComputeStatus.State == apps.ComputeStatus_ComputeState_Deleting { return Response{ StatusCode: http.StatusBadRequest, Body: map[string]string{ @@ -269,16 +270,16 @@ func (s *FakeWorkspace) AppsDelete(name string) Response { } app.ComputeStatus = &apps.ComputeStatus{ - State: apps.ComputeStateDeleting, - Message: "App is being deleted.", + State: apps.ComputeStatus_ComputeState_Deleting, + Message: utils.NonZero("App is being deleted."), } app.AppStatus = &apps.ApplicationStatus{ State: "UNAVAILABLE", - Message: appStatusUnavailableMessage, + Message: utils.NonZero(appStatusUnavailableMessage), } s.Apps[name] = app - return Response{} + return Response{Body: app} } func (s *FakeWorkspace) AppsUpsert(req Request, name string) Response { @@ -301,7 +302,7 @@ func (s *FakeWorkspace) AppsUpsert(req Request, name string) Response { } } } else { - name = app.Name + name = utils.Deref(app.Name) if name == "" { return Response{ StatusCode: 400, @@ -325,39 +326,39 @@ func (s *FakeWorkspace) AppsUpsert(req Request, name string) Response { if req.URL.Query().Get("no_compute") == "true" { app.AppStatus = &apps.ApplicationStatus{ State: "UNAVAILABLE", - Message: appStatusUnavailableMessage, + Message: utils.NonZero(appStatusUnavailableMessage), } app.ComputeStatus = &apps.ComputeStatus{ - State: apps.ComputeStateStopped, - Message: "App compute is stopped.", + State: apps.ComputeStatus_ComputeState_Stopped, + Message: utils.NonZero("App compute is stopped."), } } else { app.AppStatus = &apps.ApplicationStatus{ State: "RUNNING", - Message: "Application is running.", + Message: utils.NonZero("Application is running."), } app.ComputeStatus = &apps.ComputeStatus{ State: "ACTIVE", - Message: "App compute is active.", + Message: utils.NonZero("App compute is active."), } // Simulate the apps platform side effect: when an app is created, it is deployed with the default source code path. deployment := apps.AppDeployment{ - SourceCodePath: "/Workspace/Users/tester@databricks.com/" + name, + SourceCodePath: utils.NonZero("/Workspace/Users/tester@databricks.com/" + name), } - deployment.DeploymentId = fmt.Sprintf("deploy-%d", nextID()) + deployment.DeploymentId = utils.NonZero(fmt.Sprintf("deploy-%d", nextID())) deployment.Status = &apps.AppDeploymentStatus{ - State: apps.AppDeploymentStateSucceeded, - Message: "Deployment succeeded", + State: apps.AppDeployment_State_Succeeded, + Message: utils.NonZero("Deployment succeeded"), } app.ActiveDeployment = &deployment app.DefaultSourceCodePath = deployment.SourceCodePath } - app.Url = name + "-123.cloud.databricksapps.com" - app.Id = strconv.Itoa(len(s.Apps) + 1000) + app.Url = utils.NonZero(name + "-123.cloud.databricksapps.com") + app.Id = utils.NonZero(strconv.Itoa(len(s.Apps) + 1000)) if app.ComputeSize == "" { app.ComputeSize = "MEDIUM" @@ -365,13 +366,13 @@ func (s *FakeWorkspace) AppsUpsert(req Request, name string) Response { // The platform enables user access token forwarding regardless of what the // request asked for, so the remote always reports true. - app.ForwardUserAccessToken = true + app.ForwardUserAccessToken = utils.NonZero(true) // Assign a service principal to the app, mimicking the real platform. - if app.ServicePrincipalClientId == "" { - app.ServicePrincipalClientId = nextUUID() - app.ServicePrincipalId = nextID() - app.ServicePrincipalName = "app-" + name + if utils.Deref(app.ServicePrincipalClientId) == "" { + app.ServicePrincipalClientId = utils.NonZero(nextUUID()) + app.ServicePrincipalId = utils.NonZero(nextID()) + app.ServicePrincipalName = utils.NonZero("app-" + name) } // Simulate the apps platform side effect: when an app references a job @@ -381,11 +382,11 @@ func (s *FakeWorkspace) AppsUpsert(req Request, name string) Response { if res.Job == nil { continue } - s.upsertPermission("/jobs/"+res.Job.Id, iam.AccessControlResponse{ + s.upsertPermission("/jobs/"+utils.Deref(res.Job.Id), accessmanagement.AccessControlResponse{ ServicePrincipalName: app.ServicePrincipalName, - AllPermissions: []iam.Permission{{ - PermissionLevel: iam.PermissionLevel(res.Job.Permission), - ForceSendFields: []string{"Inherited"}, + AllPermissions: []accessmanagement.Permission{{ + PermissionLevel: accessmanagement.PermissionLevel(res.Job.Permission), + Inherited: new(false), }}, }) } diff --git a/libs/testserver/bundledeployments.go b/libs/testserver/bundledeployments.go index 86aef24d83c..e0a5019f2a3 100644 --- a/libs/testserver/bundledeployments.go +++ b/libs/testserver/bundledeployments.go @@ -9,8 +9,8 @@ import ( "strconv" "strings" - "github.com/databricks/databricks-sdk-go/service/bundledeployments" - "github.com/databricks/databricks-sdk-go/service/workspace" + "github.com/databricks/cli/libs/bundledeployments" + workspaceapi "github.com/databricks/cli/libs/workspaceapi" ) // Handlers for the Deployment Metadata Service (DMS) API under /api/2.0/bundle. @@ -76,7 +76,7 @@ func (s *FakeWorkspace) CreateDeployment(req Request) Response { } objectID := nextTreenodeID() s.files[nodePath] = FileEntry{ - Info: workspace.ObjectInfo{ + Info: workspaceapi.ObjectInfo{ // The service registers its own node type, which get-status reports back; // a plain FILE is what the fake used to claim and the real API never returns. ObjectType: "BUNDLE_DEPLOYMENT", diff --git a/libs/testserver/catalogs.go b/libs/testserver/catalogs.go index 9759b4b1a19..a635666840e 100644 --- a/libs/testserver/catalogs.go +++ b/libs/testserver/catalogs.go @@ -6,7 +6,8 @@ import ( "net/http" "strings" - "github.com/databricks/databricks-sdk-go/service/catalog" + catalogs "github.com/databricks/cli/libs/sdktypes/uc/catalogs/v1" + "github.com/databricks/cli/libs/utils" ) // catalogNameManagedDefaults scopes the managed-property injection to the @@ -17,7 +18,7 @@ const catalogNameManagedDefaults = "catalog_managed_defaults" func (s *FakeWorkspace) CatalogsCreate(req Request) Response { defer s.LockUnlock()() - var createRequest catalog.CreateCatalog + var createRequest catalogs.CreateCatalogRequest if err := json.Unmarshal(req.Body, &createRequest); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -27,7 +28,7 @@ func (s *FakeWorkspace) CatalogsCreate(req Request) Response { // UC rejects an empty name; the fake would otherwise store a catalog under a key // nothing can look up. Message is UC's canned error, which names more than we check. - if createRequest.Name == "" { + if utils.Deref(createRequest.Name) == "" { return Response{ StatusCode: http.StatusBadRequest, Body: map[string]string{ @@ -39,28 +40,28 @@ func (s *FakeWorkspace) CatalogsCreate(req Request) Response { // Echo back every field create accepts: a dropped one makes the next plan see a // phantom change. - catalogInfo := catalog.CatalogInfo{ + catalogInfo := catalogs.CatalogInfo{ Name: createRequest.Name, Comment: createRequest.Comment, ConnectionName: createRequest.ConnectionName, CustomMaxRetentionHours: createRequest.CustomMaxRetentionHours, ManagedEncryptionSettings: createRequest.ManagedEncryptionSettings, // Strip trailing slash to mimic UC API normalization behavior (see volumes.go). - StorageRoot: strings.TrimRight(createRequest.StorageRoot, "/"), + StorageRoot: utils.NonZero(strings.TrimRight(utils.Deref(createRequest.StorageRoot), "/")), ProviderName: createRequest.ProviderName, ShareName: createRequest.ShareName, Options: createRequest.Options, Properties: createRequest.Properties, FullName: createRequest.Name, - CreatedAt: nowMilli(), + CreatedAt: utils.NonZero(nowMilli()), CreatedBy: s.CurrentUser().UserName, UpdatedBy: s.CurrentUser().UserName, - MetastoreId: nextUUID(), + MetastoreId: utils.NonZero(nextUUID()), Owner: s.CurrentUser().UserName, - CatalogType: catalog.CatalogTypeManagedCatalog, + CatalogType: catalogs.CatalogType_ManagedCatalog, } catalogInfo.UpdatedAt = catalogInfo.CreatedAt - if catalogInfo.Properties == nil && createRequest.Name == catalogNameManagedDefaults { + if catalogInfo.Properties == nil && utils.Deref(createRequest.Name) == catalogNameManagedDefaults { // Mirror UC: managed system defaults are populated when the user sets none. catalogInfo.Properties = map[string]string{ "unity.catalog.managed.delta.defaults.delta.enableRowTracking": "true", @@ -73,7 +74,7 @@ func (s *FakeWorkspace) CatalogsCreate(req Request) Response { } } - s.Catalogs[createRequest.Name] = catalogInfo + s.Catalogs[utils.Deref(createRequest.Name)] = catalogInfo return Response{ Body: catalogInfo, } @@ -95,7 +96,7 @@ func (s *FakeWorkspace) CatalogsUpdate(req Request, name string) Response { return *errResponse } - var updateRequest catalog.UpdateCatalog + var updateRequest catalogs.UpdateCatalogRequest if err := json.Unmarshal(req.Body, &updateRequest); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -104,16 +105,16 @@ func (s *FakeWorkspace) CatalogsUpdate(req Request, name string) Response { } applyUpdatedFields(&existing, updateRequest, fields) - if updateRequest.NewName != "" { + if utils.Deref(updateRequest.NewName) != "" { existing.Name = updateRequest.NewName existing.FullName = updateRequest.NewName // Delete the old entry and create with new name delete(s.Catalogs, name) - name = updateRequest.NewName + name = utils.Deref(updateRequest.NewName) } - existing.UpdatedAt = nowMilli() + existing.UpdatedAt = utils.NonZero(nowMilli()) existing.UpdatedBy = s.CurrentUser().UserName s.Catalogs[name] = existing diff --git a/libs/testserver/catalogs_test.go b/libs/testserver/catalogs_test.go index aa98c477479..b39e2f3d191 100644 --- a/libs/testserver/catalogs_test.go +++ b/libs/testserver/catalogs_test.go @@ -6,7 +6,8 @@ import ( "strings" "testing" - "github.com/databricks/databricks-sdk-go/service/catalog" + catalogs "github.com/databricks/cli/libs/sdktypes/uc/catalogs/v1" + "github.com/databricks/cli/libs/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -38,10 +39,10 @@ func TestCatalogsCreate_AllowsNonEmptyName(t *testing.T) { getResponse := MapGet(workspace, workspace.Catalogs, "my_catalog") require.Equal(t, 0, getResponse.StatusCode) - body, ok := getResponse.Body.(catalog.CatalogInfo) + body, ok := getResponse.Body.(catalogs.CatalogInfo) require.True(t, ok) - assert.Equal(t, "my_catalog", body.Name) - assert.Equal(t, "my_catalog", body.FullName) + assert.Equal(t, "my_catalog", utils.Deref(body.Name)) + assert.Equal(t, "my_catalog", utils.Deref(body.FullName)) } // createCatalogRequest sets every field CreateCatalog accepts. Tests below assert @@ -78,20 +79,40 @@ func TestCatalogsCreate_EchoesEveryAcceptedField(t *testing.T) { response := workspace.CatalogsCreate(Request{Body: []byte(createCatalogRequest)}) assert.Equal(t, 0, response.StatusCode) - info, ok := response.Body.(catalog.CatalogInfo) + info, ok := response.Body.(catalogs.CatalogInfo) require.True(t, ok) - assert.Equal(t, "my_catalog", info.Name) - assert.Equal(t, "c", info.Comment) - assert.Equal(t, "my_connection", info.ConnectionName) - assert.Equal(t, int64(48), info.CustomMaxRetentionHours) + assert.Equal(t, "my_catalog", utils.Deref(info.Name)) + assert.Equal(t, "c", utils.Deref(info.Comment)) + assert.Equal(t, "my_connection", utils.Deref(info.ConnectionName)) + assert.Equal(t, int64(48), utils.Deref(info.CustomMaxRetentionHours)) require.NotNil(t, info.ManagedEncryptionSettings) - assert.Equal(t, "key-1", info.ManagedEncryptionSettings.CustomerManagedKeyId) + assert.Equal(t, "key-1", utils.Deref(info.ManagedEncryptionSettings.CustomerManagedKeyId)) assert.Equal(t, map[string]string{"opt": "1"}, info.Options) assert.Equal(t, map[string]string{"prop": "2"}, info.Properties) - assert.Equal(t, "my_provider", info.ProviderName) - assert.Equal(t, "my_share", info.ShareName) - assert.Equal(t, "s3://bucket/root", info.StorageRoot) + assert.Equal(t, "my_provider", utils.Deref(info.ProviderName)) + assert.Equal(t, "my_share", utils.Deref(info.ShareName)) + assert.Equal(t, "s3://bucket/root", utils.Deref(info.StorageRoot)) +} + +// catalogCreateServerFields are CreateCatalogRequest fields the server computes +// or DABs never sends: sdk-go models the create request as a full CatalogInfo. +var catalogCreateServerFields = map[string]bool{ + "owner": true, + "enable_predictive_optimization": true, + "catalog_type": true, + "metastore_id": true, + "created_at": true, + "created_by": true, + "updated_at": true, + "updated_by": true, + "storage_location": true, + "isolation_mode": true, + "effective_predictive_optimization_flag": true, + "browse_only": true, + "provisioning_info": true, + "full_name": true, + "securable_type": true, } // CatalogsCreate builds its response field by field, so a field the SDK adds to @@ -102,7 +123,10 @@ func TestCatalogsCreate_RequestCoversEveryAcceptedField(t *testing.T) { var sent map[string]any require.NoError(t, json.Unmarshal([]byte(createCatalogRequest), &sent)) - for _, name := range jsonFieldNames(reflect.TypeFor[catalog.CreateCatalog]()) { + for _, name := range jsonFieldNames(reflect.TypeFor[catalogs.CreateCatalogRequest]()) { + if catalogCreateServerFields[name] { + continue + } assert.Contains(t, sent, name) } } @@ -123,13 +147,13 @@ func TestCatalogsUpdate_AppliesUpdatableFields(t *testing.T) { }`)}, "my_catalog") assert.Equal(t, 0, response.StatusCode) - info, ok := response.Body.(catalog.CatalogInfo) + info, ok := response.Body.(catalogs.CatalogInfo) require.True(t, ok) - assert.Equal(t, "updated", info.Comment) - assert.Equal(t, int64(72), info.CustomMaxRetentionHours) + assert.Equal(t, "updated", utils.Deref(info.Comment)) + assert.Equal(t, int64(72), utils.Deref(info.CustomMaxRetentionHours)) require.NotNil(t, info.ManagedEncryptionSettings) - assert.Equal(t, "key-2", info.ManagedEncryptionSettings.CustomerManagedKeyId) + assert.Equal(t, "key-2", utils.Deref(info.ManagedEncryptionSettings.CustomerManagedKeyId)) assert.Equal(t, map[string]string{"opt": "3"}, info.Options) assert.Equal(t, map[string]string{"prop": "4"}, info.Properties) } diff --git a/libs/testserver/cluster_policies.go b/libs/testserver/cluster_policies.go index ce29464a9e5..c8b1c40d0a6 100644 --- a/libs/testserver/cluster_policies.go +++ b/libs/testserver/cluster_policies.go @@ -8,8 +8,9 @@ import ( "slices" "strings" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" + clusterpolicies "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" ) // policyFamilyDefinition mimics the real backend: a policy created from a policy @@ -24,13 +25,13 @@ func policyFamilyDefinition(familyID string) string { func (s *FakeWorkspace) ClusterPoliciesCreate(req Request) any { // Unmarshal into the stored (GET) type directly: CreatePolicy and Policy // share JSON field names, so every config field is carried over. - var policy compute.Policy + var policy clusterpolicies.Policy if err := json.Unmarshal(req.Body, &policy); err != nil { return Response{StatusCode: 400, Body: fmt.Sprintf("request parsing error: %s", err)} } // The backend rejects definition and policy_family_id together. - if policy.Definition != "" && policy.PolicyFamilyId != "" { + if utils.Deref(policy.Definition) != "" && utils.Deref(policy.PolicyFamilyId) != "" { return Response{ StatusCode: 400, Body: map[string]string{ @@ -40,17 +41,17 @@ func (s *FakeWorkspace) ClusterPoliciesCreate(req Request) any { } } - if policy.Definition == "" && policy.PolicyFamilyId != "" { - policy.Definition = policyFamilyDefinition(policy.PolicyFamilyId) + if utils.Deref(policy.Definition) == "" && utils.Deref(policy.PolicyFamilyId) != "" { + policy.Definition = utils.NonZero(policyFamilyDefinition(utils.Deref(policy.PolicyFamilyId))) } defer s.LockUnlock()() id := nextUUID() - policy.PolicyId = id + policy.PolicyId = utils.NonZero(id) s.ClusterPolicies[id] = policy - return Response{Body: compute.CreatePolicyResponse{PolicyId: id}} + return Response{Body: clusterpolicies.CreatePolicyResponse{PolicyId: utils.NonZero(id)}} } func (s *FakeWorkspace) ClusterPoliciesList(req Request) any { @@ -62,12 +63,12 @@ func (s *FakeWorkspace) ClusterPoliciesList(req Request) any { } slices.Sort(ids) - policies := make([]compute.Policy, 0, len(ids)) + policies := make([]clusterpolicies.Policy, 0, len(ids)) for _, id := range ids { policies = append(policies, s.ClusterPolicies[id]) } - return Response{Body: compute.ListPoliciesResponse{Policies: policies}} + return Response{Body: clusterpolicies.ListPoliciesResponse{Policies: policies}} } func (s *FakeWorkspace) ClusterPoliciesGet(req Request, policyId string) any { @@ -82,14 +83,14 @@ func (s *FakeWorkspace) ClusterPoliciesGet(req Request, policyId string) any { } func (s *FakeWorkspace) ClusterPoliciesEdit(req Request) any { - var request compute.EditPolicy + var request clusterpolicies.EditPolicyRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{StatusCode: 400, Body: fmt.Sprintf("request parsing error: %s", err)} } defer s.LockUnlock()() - policy, ok := s.ClusterPolicies[request.PolicyId] + policy, ok := s.ClusterPolicies[utils.Deref(request.PolicyId)] if !ok { return Response{StatusCode: 404} } @@ -103,27 +104,27 @@ func (s *FakeWorkspace) ClusterPoliciesEdit(req Request) any { policy.MaxClustersPerUser = request.MaxClustersPerUser policy.PolicyFamilyDefinitionOverrides = request.PolicyFamilyDefinitionOverrides policy.PolicyFamilyId = request.PolicyFamilyId - if policy.Definition == "" && policy.PolicyFamilyId != "" { - policy.Definition = policyFamilyDefinition(policy.PolicyFamilyId) + if utils.Deref(policy.Definition) == "" && utils.Deref(policy.PolicyFamilyId) != "" { + policy.Definition = utils.NonZero(policyFamilyDefinition(utils.Deref(policy.PolicyFamilyId))) } - s.ClusterPolicies[request.PolicyId] = policy + s.ClusterPolicies[utils.Deref(request.PolicyId)] = policy return Response{} } func (s *FakeWorkspace) ClusterPoliciesDelete(req Request) any { - var request compute.DeletePolicy + var request clusterpolicies.DeletePolicyRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{StatusCode: 400, Body: fmt.Sprintf("request parsing error: %s", err)} } defer s.LockUnlock()() - if _, ok := s.ClusterPolicies[request.PolicyId]; !ok { + if _, ok := s.ClusterPolicies[utils.Deref(request.PolicyId)]; !ok { return Response{StatusCode: 404} } - delete(s.ClusterPolicies, request.PolicyId) + delete(s.ClusterPolicies, utils.Deref(request.PolicyId)) return Response{} } @@ -161,7 +162,7 @@ func (s *FakeWorkspace) clusterPolicyValues(policyID string, applyDefaults bool) return nil } var elements map[string]policyElement - if err := json.Unmarshal([]byte(policy.Definition), &elements); err != nil { + if err := json.Unmarshal([]byte(utils.Deref(policy.Definition)), &elements); err != nil { return nil } values := make(map[string]any, len(elements)) @@ -178,8 +179,8 @@ func (s *FakeWorkspace) clusterPolicyValues(policyID string, applyDefaults bool) // "fixed" element, or "" when the spec is acceptable; callers must hold the workspace lock and // surface a non-empty message as a 400. // -// spec is a pointer to any struct with cluster-spec JSON tags (compute.ClusterDetails or -// compute.ClusterSpec); the policy's attribute paths are applied against its JSON shape so +// spec is a pointer to any struct with cluster-spec JSON tags (clusters.ClusterInfo or +// jobs.ClusterSpec_NewCluster); the policy's attribute paths are applied against its JSON shape so // one implementation covers both. func (s *FakeWorkspace) applyClusterPolicy(spec any, policyID string, applyDefaults bool) string { if policyID == "" { @@ -203,9 +204,7 @@ func (s *FakeWorkspace) applyClusterPolicy(spec any, policyID string, applyDefau } // Collect only the attributes the request omitted, then unmarshal just those back onto - // the spec. Unmarshaling the whole document instead would rebuild ForceSendFields from - // every key present, which makes fields the backend omits (e.g. the Jobs API dropping - // apply_policy_default_values) serialize as explicit zeros. + // the spec, leaving everything the request set untouched. patch := map[string]any{} for _, path := range slices.Sorted(maps.Keys(values)) { value := values[path] @@ -237,7 +236,7 @@ func (s *FakeWorkspace) applyClusterPolicy(spec any, policyID string, applyDefau // isFixed reports whether the policy's element at path is a "fixed" element. func (s *FakeWorkspace) isFixed(policyID, path string) bool { var elements map[string]policyElement - if err := json.Unmarshal([]byte(s.ClusterPolicies[policyID].Definition), &elements); err != nil { + if err := json.Unmarshal([]byte(utils.Deref(s.ClusterPolicies[policyID].Definition)), &elements); err != nil { return false } return elements[path].Type == "fixed" @@ -270,9 +269,11 @@ func setPatch(patch map[string]any, path []string, value any) { } // applyPolicyDefaultValues reads apply_policy_default_values from a raw cluster request body. -// compute.ClusterDetails has no such field, so it cannot be read off the decoded request. +// clusters.ClusterInfo has no such field, so it cannot be read off the decoded request. func applyPolicyDefaultValues(body []byte) bool { - var spec compute.ClusterSpec + var spec struct { + ApplyPolicyDefaultValues bool `json:"apply_policy_default_values"` + } if err := json.Unmarshal(body, &spec); err != nil { return false } @@ -297,7 +298,7 @@ func (s *FakeWorkspace) applyJobClusterPolicies(settings *jobs.JobSettings) stri if msg := s.applyClusterSpecPolicy(task.NewCluster); msg != "" { return msg } - if task.ForEachTask != nil { + if task.ForEachTask != nil && task.ForEachTask.Task != nil { if msg := s.applyClusterSpecPolicy(task.ForEachTask.Task.NewCluster); msg != "" { return msg } @@ -306,9 +307,9 @@ func (s *FakeWorkspace) applyJobClusterPolicies(settings *jobs.JobSettings) stri return "" } -func (s *FakeWorkspace) applyClusterSpecPolicy(spec *compute.ClusterSpec) string { +func (s *FakeWorkspace) applyClusterSpecPolicy(spec *jobs.ClusterSpec_NewCluster) string { if spec == nil { return "" } - return s.applyClusterPolicy(spec, spec.PolicyId, spec.ApplyPolicyDefaultValues) + return s.applyClusterPolicy(spec, utils.Deref(spec.PolicyId), utils.Deref(spec.ApplyPolicyDefaultValues)) } diff --git a/libs/testserver/cluster_policies_test.go b/libs/testserver/cluster_policies_test.go index 83ef663d3ed..493a8456fd1 100644 --- a/libs/testserver/cluster_policies_test.go +++ b/libs/testserver/cluster_policies_test.go @@ -4,7 +4,9 @@ import ( "encoding/json" "testing" - "github.com/databricks/databricks-sdk-go/service/compute" + clusterpolicies "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -19,70 +21,65 @@ const testPolicyDefinition = `{ }` func policyWorkspace() *FakeWorkspace { - return &FakeWorkspace{ClusterPolicies: map[string]compute.Policy{ - "p1": {PolicyId: "p1", Definition: testPolicyDefinition}, + return &FakeWorkspace{ClusterPolicies: map[string]clusterpolicies.Policy{ + "p1": {PolicyId: utils.NonZero("p1"), Definition: utils.NonZero(testPolicyDefinition)}, }} } func TestApplyClusterPolicy(t *testing.T) { tests := []struct { - name string - policyID string - spec compute.ClusterSpec - want string - wantForceSend []string - wantErr string + name string + policyID string + spec jobs.ClusterSpec_NewCluster + want string + wantErr string }{ { - name: "fixed applies without apply_policy_default_values, defaultValue does not", - policyID: "p1", - spec: compute.ClusterSpec{PolicyId: "p1"}, - want: `{"custom_tags":{"Fixed":"f"},"policy_id":"p1","spark_version":"policy-version"}`, - wantForceSend: []string{"SparkVersion"}, + name: "fixed applies without apply_policy_default_values, defaultValue does not", + policyID: "p1", + spec: jobs.ClusterSpec_NewCluster{PolicyId: utils.NonZero("p1")}, + want: `{"custom_tags":{"Fixed":"f"},"policy_id":"p1","spark_version":"policy-version"}`, }, { - name: "defaultValue applies with apply_policy_default_values", - policyID: "p1", - spec: compute.ClusterSpec{PolicyId: "p1", ApplyPolicyDefaultValues: true}, - want: `{"apply_policy_default_values":true,"custom_tags":{"Default":"d","Fixed":"f"},"node_type_id":"policy-node","policy_id":"p1","spark_version":"policy-version"}`, - wantForceSend: []string{"NodeTypeId", "SparkVersion"}, + name: "defaultValue applies with apply_policy_default_values", + policyID: "p1", + spec: jobs.ClusterSpec_NewCluster{PolicyId: utils.NonZero("p1"), ApplyPolicyDefaultValues: utils.NonZero(true)}, + want: `{"apply_policy_default_values":true,"custom_tags":{"Default":"d","Fixed":"f"},"node_type_id":"policy-node","policy_id":"p1","spark_version":"policy-version"}`, }, { - name: "a defaultValue does not override what the request supplied", - policyID: "p1", - spec: compute.ClusterSpec{PolicyId: "p1", ApplyPolicyDefaultValues: true, NodeTypeId: "user-node"}, - want: `{"apply_policy_default_values":true,"custom_tags":{"Default":"d","Fixed":"f"},"node_type_id":"user-node","policy_id":"p1","spark_version":"policy-version"}`, - wantForceSend: []string{"SparkVersion"}, + name: "a defaultValue does not override what the request supplied", + policyID: "p1", + spec: jobs.ClusterSpec_NewCluster{PolicyId: utils.NonZero("p1"), ApplyPolicyDefaultValues: utils.NonZero(true), NodeTypeId: utils.NonZero("user-node")}, + want: `{"apply_policy_default_values":true,"custom_tags":{"Default":"d","Fixed":"f"},"node_type_id":"user-node","policy_id":"p1","spark_version":"policy-version"}`, }, { - name: "policy tags merge into tags the request supplied", - policyID: "p1", - spec: compute.ClusterSpec{PolicyId: "p1", CustomTags: map[string]string{"Mine": "yes"}}, - want: `{"custom_tags":{"Fixed":"f","Mine":"yes"},"policy_id":"p1","spark_version":"policy-version"}`, - wantForceSend: []string{"SparkVersion"}, + name: "policy tags merge into tags the request supplied", + policyID: "p1", + spec: jobs.ClusterSpec_NewCluster{PolicyId: utils.NonZero("p1"), CustomTags: map[string]string{"Mine": "yes"}}, + want: `{"custom_tags":{"Fixed":"f","Mine":"yes"},"policy_id":"p1","spark_version":"policy-version"}`, }, { name: "a value contradicting a fixed element is rejected", policyID: "p1", - spec: compute.ClusterSpec{PolicyId: "p1", SparkVersion: "user-version"}, + spec: jobs.ClusterSpec_NewCluster{PolicyId: utils.NonZero("p1"), SparkVersion: utils.NonZero("user-version")}, wantErr: `Cluster validation error: Validation failed for spark_version must be policy-version (is "user-version")`, }, { name: "a tag contradicting a fixed element is rejected", policyID: "p1", - spec: compute.ClusterSpec{PolicyId: "p1", CustomTags: map[string]string{"Fixed": "mine"}}, + spec: jobs.ClusterSpec_NewCluster{PolicyId: utils.NonZero("p1"), CustomTags: map[string]string{"Fixed": "mine"}}, wantErr: `Cluster validation error: Validation failed for custom_tags, Fixed must be f (is "mine")`, }, { name: "no policy attached leaves the spec untouched", policyID: "", - spec: compute.ClusterSpec{SparkVersion: "v"}, + spec: jobs.ClusterSpec_NewCluster{SparkVersion: utils.NonZero("v")}, want: `{"spark_version":"v"}`, }, { name: "unknown policy leaves the spec untouched", policyID: "missing", - spec: compute.ClusterSpec{PolicyId: "missing", SparkVersion: "v"}, + spec: jobs.ClusterSpec_NewCluster{PolicyId: utils.NonZero("missing"), SparkVersion: utils.NonZero("v")}, want: `{"policy_id":"missing","spark_version":"v"}`, }, } @@ -90,7 +87,7 @@ func TestApplyClusterPolicy(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { spec := tt.spec - msg := policyWorkspace().applyClusterPolicy(&spec, tt.policyID, spec.ApplyPolicyDefaultValues) + msg := policyWorkspace().applyClusterPolicy(&spec, tt.policyID, utils.Deref(spec.ApplyPolicyDefaultValues)) if tt.wantErr != "" { assert.Equal(t, tt.wantErr, msg) @@ -101,10 +98,6 @@ func TestApplyClusterPolicy(t *testing.T) { got, err := json.Marshal(&spec) require.NoError(t, err) assert.JSONEq(t, tt.want, string(got)) - // Only attributes the policy actually supplied may become force-sent. Anything - // else would serialize as an explicit zero and break the fake's ability to model - // fields the real API drops (the Jobs API drops apply_policy_default_values). - assert.Equal(t, tt.wantForceSend, spec.ForceSendFields) }) } } diff --git a/libs/testserver/clusters.go b/libs/testserver/clusters.go index e0a046031e6..46aeebdd41b 100644 --- a/libs/testserver/clusters.go +++ b/libs/testserver/clusters.go @@ -5,12 +5,12 @@ import ( "fmt" "os" - "github.com/databricks/cli/libs/structs/structaccess" - "github.com/databricks/databricks-sdk-go/service/compute" + clusters "github.com/databricks/cli/libs/sdktypes/clusters/v2" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) ClustersCreate(req Request) any { - var request compute.ClusterDetails + var request clusters.ClusterInfo if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, @@ -21,20 +21,20 @@ func (s *FakeWorkspace) ClustersCreate(req Request) any { defer s.LockUnlock()() clusterId := nextUUID() - request.ClusterId = clusterId + request.ClusterId = utils.NonZero(clusterId) // Clusters start in PENDING state when created; ClustersGet transitions them to RUNNING. - request.State = compute.StatePending + request.State = clusters.ClusterState_ClusterState_Pending // Match cloud behavior: SINGLE_USER clusters automatically get single_user_name set // to the current user. This enables terraform drift detection when the bundle config // doesn't specify single_user_name. - if request.DataSecurityMode == compute.DataSecurityModeSingleUser && request.SingleUserName == "" { + if request.DataSecurityMode == clusters.DataSecurityMode_SingleUser && utils.Deref(request.SingleUserName) == "" { request.SingleUserName = s.CurrentUser().UserName } // Apply the attached cluster policy before computing defaults, matching the backend: // policy values feed the defaults below (e.g. driver_node_type_id from node_type_id). - if msg := s.applyClusterPolicy(&request, request.PolicyId, applyPolicyDefaultValues(req.Body)); msg != "" { + if msg := s.applyClusterPolicy(&request, utils.Deref(request.PolicyId), applyPolicyDefaultValues(req.Body)); msg != "" { return Response{ StatusCode: 400, Body: map[string]string{ @@ -46,38 +46,34 @@ func (s *FakeWorkspace) ClustersCreate(req Request) any { clusterFixUps(&request) // The cluster GET API returns apply_policy_default_values only under .spec, not at the top - // level (compute.ClusterDetails has no such field, so it is dropped by the unmarshal above). + // level (clusters.ClusterInfo has no such field, so it is dropped by the unmarshal above). // Snapshot it from the raw body so re-reads match cloud. request.Spec = specSnapshot(req.Body) s.Clusters[clusterId] = request return Response{ - Body: compute.ClusterDetails{ - ClusterId: clusterId, + Body: clusters.ClusterInfo{ + ClusterId: utils.NonZero(clusterId), }, } } // specSnapshot mirrors how the cluster GET API returns apply_policy_default_values under .spec -// (it is absent from compute.ClusterDetails and thus invisible at the top level of a re-read). +// (it is absent from clusters.ClusterInfo and thus invisible at the top level of a re-read). // Returns nil when the field is unset so re-reads of clusters that don't use it are unchanged; // a nil .spec reads back as false, which is what the field's absence means anyway. -func specSnapshot(body []byte) *compute.ClusterSpec { - var spec compute.ClusterSpec - if err := json.Unmarshal(body, &spec); err != nil { +func specSnapshot(body []byte) *clusters.ClusterInfo_ComputeSpec { + if !applyPolicyDefaultValues(body) { return nil } - if !spec.ApplyPolicyDefaultValues { - return nil - } - return &compute.ClusterSpec{ - ApplyPolicyDefaultValues: true, + return &clusters.ClusterInfo_ComputeSpec{ + ApplyPolicyDefaultValues: new(true), } } func (s *FakeWorkspace) ClustersResize(req Request) any { - var request compute.ResizeCluster + var request clusters.ResizeClusterRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, @@ -86,13 +82,13 @@ func (s *FakeWorkspace) ClustersResize(req Request) any { } defer s.LockUnlock()() - cluster, ok := s.Clusters[request.ClusterId] + cluster, ok := s.Clusters[utils.Deref(request.ClusterId)] if !ok { return Response{StatusCode: 404} } // Only running clusters can be resized; match the real API behavior. - if cluster.State != compute.StateRunning { + if cluster.State != clusters.ClusterState_ClusterState_Running { return Response{ StatusCode: 400, Body: map[string]string{"error_code": "INVALID_STATE", "message": "Cluster is not running"}, @@ -101,13 +97,13 @@ func (s *FakeWorkspace) ClustersResize(req Request) any { cluster.NumWorkers = request.NumWorkers cluster.Autoscale = request.Autoscale - s.Clusters[request.ClusterId] = cluster + s.Clusters[utils.Deref(request.ClusterId)] = cluster return Response{} } func (s *FakeWorkspace) ClustersEdit(req Request) any { - var request compute.ClusterDetails + var request clusters.ClusterInfo if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, @@ -116,7 +112,7 @@ func (s *FakeWorkspace) ClustersEdit(req Request) any { } defer s.LockUnlock()() - existing, ok := s.Clusters[request.ClusterId] + existing, ok := s.Clusters[utils.Deref(request.ClusterId)] if !ok { return Response{StatusCode: 404} } @@ -126,7 +122,7 @@ func (s *FakeWorkspace) ClustersEdit(req Request) any { request.ClusterId = existing.ClusterId // Apply the attached cluster policy before computing defaults, matching the backend: // policy values feed the defaults below (e.g. driver_node_type_id from node_type_id). - if msg := s.applyClusterPolicy(&request, request.PolicyId, applyPolicyDefaultValues(req.Body)); msg != "" { + if msg := s.applyClusterPolicy(&request, utils.Deref(request.PolicyId), applyPolicyDefaultValues(req.Body)); msg != "" { return Response{ StatusCode: 400, Body: map[string]string{ @@ -138,45 +134,39 @@ func (s *FakeWorkspace) ClustersEdit(req Request) any { clusterFixUps(&request) // Refresh the .spec snapshot from the new settings, matching cloud behavior on edit. request.Spec = specSnapshot(req.Body) - s.Clusters[request.ClusterId] = request + s.Clusters[utils.Deref(request.ClusterId)] = request // Clear venv cache when cluster is edited to match cloud behavior where // cluster edits trigger restarts that clear library caches. - if env, ok := s.clusterVenvs[request.ClusterId]; ok { + if env, ok := s.clusterVenvs[utils.Deref(request.ClusterId)]; ok { os.RemoveAll(env.dir) - delete(s.clusterVenvs, request.ClusterId) + delete(s.clusterVenvs, utils.Deref(request.ClusterId)) } return Response{} } -func setDefault(obj any, path string, value any) { - if val, _ := structaccess.GetByString(obj, path); val == nil { - _ = structaccess.SetByString(obj, path, value) - } -} - // clusterFixUps applies server-side defaults that the real API sets. -func clusterFixUps(cluster *compute.ClusterDetails) { +func clusterFixUps(cluster *clusters.ClusterInfo) { gcp := cluster.GcpAttributes if gcp != nil { - setDefault(gcp, "first_on_demand", 1) - setDefault(gcp, "use_preemptible_executors", false) + if gcp.FirstOnDemand == nil { + gcp.FirstOnDemand = new(1) + } + if gcp.UsePreemptibleExecutors == nil { + gcp.UsePreemptibleExecutors = new(false) + } } else if cluster.AwsAttributes == nil { - cluster.AwsAttributes = &compute.AwsAttributes{ - Availability: compute.AwsAvailabilitySpotWithFallback, - ZoneId: "us-east-1c", + cluster.AwsAttributes = &clusters.AwsAttributes{ + Availability: clusters.AwsAvailability_SpotWithFallback, + ZoneId: new("us-east-1c"), } - cluster.AwsAttributes.ForceSendFields = append( - cluster.AwsAttributes.ForceSendFields, - "Availability", - "ZoneId", - ) } - cluster.ForceSendFields = append(cluster.ForceSendFields, "EnableElasticDisk") + // enable_elastic_disk is always reported, false by default. + cluster.EnableElasticDisk = new(utils.Deref(cluster.EnableElasticDisk)) - if cluster.DriverNodeTypeId == "" && cluster.NodeTypeId != "" { + if utils.Deref(cluster.DriverNodeTypeId) == "" && utils.Deref(cluster.NodeTypeId) != "" { cluster.DriverNodeTypeId = cluster.NodeTypeId } } @@ -191,8 +181,8 @@ func (s *FakeWorkspace) ClustersGet(req Request, clusterId string) any { // Simulate cluster startup: transition PENDING → RUNNING so that WaitGetClusterRunning // resolves without hanging. Real clusters move through these states asynchronously. - if cluster.State == compute.StatePending { - cluster.State = compute.StateRunning + if cluster.State == clusters.ClusterState_ClusterState_Pending { + cluster.State = clusters.ClusterState_ClusterState_Running s.Clusters[clusterId] = cluster } @@ -203,7 +193,7 @@ func (s *FakeWorkspace) ClustersGet(req Request, clusterId string) any { // ClustersDelete terminates a cluster (sets state to TERMINATED without removing it). func (s *FakeWorkspace) ClustersDelete(req Request) any { - var request compute.DeleteCluster + var request clusters.DeleteClusterRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, @@ -212,19 +202,19 @@ func (s *FakeWorkspace) ClustersDelete(req Request) any { } defer s.LockUnlock()() - cluster, ok := s.Clusters[request.ClusterId] + cluster, ok := s.Clusters[utils.Deref(request.ClusterId)] if !ok { return Response{StatusCode: 404} } - cluster.State = compute.StateTerminated - s.Clusters[request.ClusterId] = cluster + cluster.State = clusters.ClusterState_ClusterState_Terminated + s.Clusters[utils.Deref(request.ClusterId)] = cluster return Response{} } func (s *FakeWorkspace) ClustersStart(req Request) any { - var request compute.StartCluster + var request clusters.StartClusterRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, @@ -233,19 +223,19 @@ func (s *FakeWorkspace) ClustersStart(req Request) any { } defer s.LockUnlock()() - cluster, ok := s.Clusters[request.ClusterId] + cluster, ok := s.Clusters[utils.Deref(request.ClusterId)] if !ok { return Response{StatusCode: 404} } - cluster.State = compute.StateRunning - s.Clusters[request.ClusterId] = cluster + cluster.State = clusters.ClusterState_ClusterState_Running + s.Clusters[utils.Deref(request.ClusterId)] = cluster return Response{} } func (s *FakeWorkspace) ClustersPermanentDelete(req Request) any { - var request compute.PermanentDeleteCluster + var request clusters.PermanentDeleteClusterRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, @@ -254,6 +244,6 @@ func (s *FakeWorkspace) ClustersPermanentDelete(req Request) any { } defer s.LockUnlock()() - delete(s.Clusters, request.ClusterId) + delete(s.Clusters, utils.Deref(request.ClusterId)) return Response{} } diff --git a/libs/testserver/dashboards.go b/libs/testserver/dashboards.go index 098f790a229..8ff51f121e3 100644 --- a/libs/testserver/dashboards.go +++ b/libs/testserver/dashboards.go @@ -9,8 +9,9 @@ import ( "strconv" "strings" - "github.com/databricks/databricks-sdk-go/service/dashboards" - "github.com/databricks/databricks-sdk-go/service/workspace" + lakeview "github.com/databricks/cli/libs/sdktypes/lakeview/v1" + "github.com/databricks/cli/libs/utils" + workspaceapi "github.com/databricks/cli/libs/workspaceapi" ) // Generate 32 character hex string for dashboard ID @@ -96,7 +97,7 @@ func (s *FakeWorkspace) DashboardGet(req Request) Response { func (s *FakeWorkspace) DashboardCreate(req Request) Response { defer s.LockUnlock()() - var dashboard dashboards.Dashboard + var dashboard lakeview.Dashboard if err := json.Unmarshal(req.Body, &dashboard); err != nil { return Response{ StatusCode: 400, @@ -104,21 +105,23 @@ func (s *FakeWorkspace) DashboardCreate(req Request) Response { } // Default to user's home directory if parent_path is not provided (matches cloud behavior) - if dashboard.ParentPath == "" { - dashboard.ParentPath = "/Users/" + s.CurrentUser().UserName + if utils.Deref(dashboard.ParentPath) == "" { + dashboard.ParentPath = utils.NonZero("/Users/" + utils.Deref(s.CurrentUser().UserName)) } - if _, ok := s.directories[dashboard.ParentPath]; !ok { + if _, ok := s.directories[utils.Deref(dashboard.ParentPath)]; !ok { return Response{ StatusCode: 404, Body: map[string]string{ - "message": fmt.Sprintf("Path (%s) doesn't exist.", dashboard.ParentPath), + "message": fmt.Sprintf("Path (%s) doesn't exist.", utils.Deref(dashboard.ParentPath)), }, } } var err error - dashboard.DashboardId, err = generateDashboardId() + var dashboardId string + dashboardId, err = generateDashboardId() + dashboard.DashboardId = utils.NonZero(dashboardId) if err != nil { return Response{ StatusCode: 500, @@ -129,19 +132,19 @@ func (s *FakeWorkspace) DashboardCreate(req Request) Response { } // All dashboards are active by default: - dashboard.LifecycleState = dashboards.LifecycleStateActive + dashboard.LifecycleState = lakeview.LifecycleState_Active // Remove /Workspace prefix from parent_path. This matches the remote behavior. - if strings.HasPrefix(dashboard.ParentPath, "/Workspace/") { - dashboard.ParentPath = strings.TrimPrefix(dashboard.ParentPath, "/Workspace") + if strings.HasPrefix(utils.Deref(dashboard.ParentPath), "/Workspace/") { + dashboard.ParentPath = utils.NonZero(strings.TrimPrefix(utils.Deref(dashboard.ParentPath), "/Workspace")) } // Change path field if parent_path is provided - if dashboard.ParentPath != "" { - dashboard.Path = dashboard.ParentPath + "/" + dashboard.DisplayName + ".lvdash.json" + if utils.Deref(dashboard.ParentPath) != "" { + dashboard.Path = utils.NonZero(utils.Deref(dashboard.ParentPath) + "/" + utils.Deref(dashboard.DisplayName) + ".lvdash.json") } - dashboard.CreateTime = nextTimestamp() + dashboard.CreateTime = nextTime() dashboard.UpdateTime = dashboard.CreateTime inputSerializedDashboard := dashboard.SerializedDashboard @@ -151,27 +154,27 @@ func (s *FakeWorkspace) DashboardCreate(req Request) Response { datasetSchema := req.URL.Query().Get("dataset_schema") // Parse serializedDashboard into json and put it back as a string - if dashboard.SerializedDashboard != "" { - dashboard.SerializedDashboard = transformSerializedDashboard(dashboard.SerializedDashboard, datasetCatalog, datasetSchema) + if utils.Deref(dashboard.SerializedDashboard) != "" { + dashboard.SerializedDashboard = utils.NonZero(transformSerializedDashboard(utils.Deref(dashboard.SerializedDashboard), datasetCatalog, datasetSchema)) } - dashboard.Etag = "80611980" + dashboard.Etag = utils.NonZero("80611980") // Write so that, when eventual consistency is enabled, the first GET after this // create returns 404. - s.Dashboards.Write(dashboard.DashboardId, &fakeDashboard{ + s.Dashboards.Write(utils.Deref(dashboard.DashboardId), &fakeDashboard{ Dashboard: dashboard, - InputSerializedDashboard: inputSerializedDashboard, + InputSerializedDashboard: utils.Deref(inputSerializedDashboard), }) - workspacePath := path.Join("/Workspace", dashboard.Path) + workspacePath := path.Join("/Workspace", utils.Deref(dashboard.Path)) s.files[workspacePath] = FileEntry{ - Info: workspace.ObjectInfo{ + Info: workspaceapi.ObjectInfo{ ObjectType: "DASHBOARD", // Include the /Workspace prefix for workspace get-status API. Path: workspacePath, - ResourceId: dashboard.DashboardId, + ResourceId: utils.Deref(dashboard.DashboardId), }, - Data: []byte(dashboard.SerializedDashboard), + Data: []byte(utils.Deref(dashboard.SerializedDashboard)), } return Response{ @@ -182,7 +185,7 @@ func (s *FakeWorkspace) DashboardCreate(req Request) Response { func (s *FakeWorkspace) DashboardUpdate(req Request) Response { defer s.LockUnlock()() - var updateReq dashboards.Dashboard + var updateReq lakeview.Dashboard if err := json.Unmarshal(req.Body, &updateReq); err != nil { return Response{ StatusCode: 400, @@ -199,37 +202,37 @@ func (s *FakeWorkspace) DashboardUpdate(req Request) Response { updated := *dashboard // Bump etag on every write, matching cloud behavior. - prevEtag, err := strconv.Atoi(updated.Etag) + prevEtag, err := strconv.Atoi(utils.Deref(updated.Etag)) if err != nil { return Response{ Body: map[string]string{ - "message": "Invalid etag: " + updated.Etag, + "message": "Invalid etag: " + utils.Deref(updated.Etag), }, StatusCode: 400, } } - updated.Etag = strconv.Itoa(prevEtag + 1) + updated.Etag = utils.NonZero(strconv.Itoa(prevEtag + 1)) - if updateReq.SerializedDashboard != updated.InputSerializedDashboard { - updated.InputSerializedDashboard = updateReq.SerializedDashboard + if utils.Deref(updateReq.SerializedDashboard) != updated.InputSerializedDashboard { + updated.InputSerializedDashboard = utils.Deref(updateReq.SerializedDashboard) } // Update the dashboard. - updated.LifecycleState = dashboards.LifecycleStateActive - if updateReq.DisplayName != "" { + updated.LifecycleState = lakeview.LifecycleState_Active + if utils.Deref(updateReq.DisplayName) != "" { updated.DisplayName = updateReq.DisplayName - dir := path.Dir(updated.Path) - base := updateReq.DisplayName + ".lvdash.json" - updated.Path = path.Join(dir, base) + dir := path.Dir(utils.Deref(updated.Path)) + base := utils.Deref(updateReq.DisplayName) + ".lvdash.json" + updated.Path = utils.NonZero(path.Join(dir, base)) } - if updateReq.SerializedDashboard != "" { + if utils.Deref(updateReq.SerializedDashboard) != "" { // Extract dataset_catalog and dataset_schema from query parameters datasetCatalog := req.URL.Query().Get("dataset_catalog") datasetSchema := req.URL.Query().Get("dataset_schema") - updated.SerializedDashboard = transformSerializedDashboard(updateReq.SerializedDashboard, datasetCatalog, datasetSchema) + updated.SerializedDashboard = utils.NonZero(transformSerializedDashboard(utils.Deref(updateReq.SerializedDashboard), datasetCatalog, datasetSchema)) } updated.WarehouseId = updateReq.WarehouseId - updated.UpdateTime = nextTimestamp() + updated.UpdateTime = nextTime() // Write stages a stale value: like a real backend, the first read after an update // returns the pre-update value. Tests that read right after an update wait for the @@ -244,7 +247,7 @@ func (s *FakeWorkspace) DashboardUpdate(req Request) Response { func (s *FakeWorkspace) DashboardPublish(req Request) Response { defer s.LockUnlock()() - var publishReq dashboards.PublishRequest + var publishReq lakeview.PublishDashboardRequest if err := json.Unmarshal(req.Body, &publishReq); err != nil { return Response{ StatusCode: 400, @@ -259,30 +262,27 @@ func (s *FakeWorkspace) DashboardPublish(req Request) Response { } } - publishedDashboard := dashboards.PublishedDashboard{ + publishedDashboard := lakeview.PublishedDashboard{ WarehouseId: dashboard.WarehouseId, DisplayName: dashboard.DisplayName, EmbedCredentials: publishReq.EmbedCredentials, - RevisionCreateTime: nextTimestamp(), - ForceSendFields: []string{"EmbedCredentials"}, + RevisionCreateTime: nextTime(), } - if publishReq.WarehouseId != "" { + if utils.Deref(publishReq.WarehouseId) != "" { publishedDashboard.WarehouseId = publishReq.WarehouseId } - if publishReq.EmbedCredentials { - publishedDashboard.EmbedCredentials = publishReq.EmbedCredentials - } + // embed_credentials is always reported, false when the request omitted it. + publishedDashboard.EmbedCredentials = new(utils.Deref(publishReq.EmbedCredentials)) s.PublishedDashboards[dashboardId] = publishedDashboard return Response{ - Body: dashboards.PublishedDashboard{ + Body: lakeview.PublishedDashboard{ WarehouseId: publishedDashboard.WarehouseId, DisplayName: publishedDashboard.DisplayName, EmbedCredentials: publishedDashboard.EmbedCredentials, RevisionCreateTime: publishedDashboard.RevisionCreateTime, - ForceSendFields: []string{"EmbedCredentials"}, }, } } @@ -301,9 +301,9 @@ func (s *FakeWorkspace) DashboardTrash(req Request) Response { // The dashboard is marked as trashed and moved to the trash. s.Dashboards.Put(dashboardId, &fakeDashboard{ Etag: dashboard.Etag, - DashboardId: dashboardId, - LifecycleState: dashboards.LifecycleStateTrashed, - ParentPath: path.Join("/Users", s.CurrentUser().UserName, "Trash"), + DashboardId: utils.NonZero(dashboardId), + LifecycleState: lakeview.LifecycleState_Trashed, + ParentPath: utils.NonZero(path.Join("/Users", utils.Deref(s.CurrentUser().UserName), "Trash")), }) // The published dashboard is deleted. diff --git a/libs/testserver/database_catalogs.go b/libs/testserver/database_catalogs.go index d6dbdc49687..2dc3e018e9a 100644 --- a/libs/testserver/database_catalogs.go +++ b/libs/testserver/database_catalogs.go @@ -4,7 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/databricks/databricks-sdk-go/service/database" + database "github.com/databricks/cli/libs/sdktypes/database/v1" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) DatabaseCatalogCreate(req Request) Response { @@ -22,22 +23,22 @@ func (s *FakeWorkspace) DatabaseCatalogCreate(req Request) Response { // check that the instance exists: found := false for _, instance := range s.DatabaseInstances { - if instance.Name == databaseCatalog.DatabaseInstanceName { + if utils.Deref(instance.Name) == utils.Deref(databaseCatalog.DatabaseInstanceName) { found = true break } } if !found { return Response{ - Body: fmt.Sprintf("database instance with name '%s' not found", databaseCatalog.DatabaseInstanceName), + Body: fmt.Sprintf("database instance with name '%s' not found", utils.Deref(databaseCatalog.DatabaseInstanceName)), StatusCode: 404, } } // Assign uid like the real backend does - databaseCatalog.Uid = nextUUID() + databaseCatalog.Uid = utils.NonZero(nextUUID()) - s.DatabaseCatalogs[databaseCatalog.Name] = databaseCatalog + s.DatabaseCatalogs[utils.Deref(databaseCatalog.Name)] = databaseCatalog return Response{ Body: databaseCatalog, @@ -57,7 +58,7 @@ func (s *FakeWorkspace) DatabaseCatalogGet(name string) Response { // create_database_if_not_exists is a write-only field - the real API doesn't return it result := catalog - result.CreateDatabaseIfNotExists = false + result.CreateDatabaseIfNotExists = nil return Response{Body: result} } diff --git a/libs/testserver/database_instances.go b/libs/testserver/database_instances.go index 09254ffd51f..d998bda7d7c 100644 --- a/libs/testserver/database_instances.go +++ b/libs/testserver/database_instances.go @@ -3,16 +3,19 @@ package testserver import ( "encoding/json" "fmt" - "slices" "time" - "github.com/databricks/databricks-sdk-go/service/database" + database "github.com/databricks/cli/libs/sdktypes/database/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/sdk-go/core/types" ) -var ForceSendFields []string = []string{ - "EffectiveEnableReadableSecondaries", - "EffectiveStopped", - "EffectiveEnablePgNativeLogin", +// setEffectiveBools makes the effective_* booleans always serialize, false +// included, as the real API returns them. +func setEffectiveBools(d *database.DatabaseInstance) { + d.EffectiveEnableReadableSecondaries = new(utils.Deref(d.EffectiveEnableReadableSecondaries)) + d.EffectiveStopped = new(utils.Deref(d.EffectiveStopped)) + d.EffectiveEnablePgNativeLogin = new(utils.Deref(d.EffectiveEnablePgNativeLogin)) } func (s *FakeWorkspace) DatabaseInstanceCreate(req Request) Response { @@ -28,21 +31,20 @@ func (s *FakeWorkspace) DatabaseInstanceCreate(req Request) Response { } // set default fields: - databaseInstance.Uid = nextUUID() - databaseInstance.State = database.DatabaseInstanceStateAvailable - databaseInstance.PgVersion = "PG_VERSION_16" - databaseInstance.EffectiveNodeCount = 1 - databaseInstance.EffectiveRetentionWindowInDays = 7 + databaseInstance.Uid = utils.NonZero(nextUUID()) + databaseInstance.State = database.DatabaseInstance_State_Available + databaseInstance.PgVersion = utils.NonZero("PG_VERSION_16") + databaseInstance.EffectiveNodeCount = utils.NonZero(1) + databaseInstance.EffectiveRetentionWindowInDays = utils.NonZero(7) databaseInstance.EffectiveCapacity = databaseInstance.Capacity databaseInstance.Creator = req.Workspace.CurrentUser().UserName - databaseInstance.CreationTime = time.Now().UTC().Format(time.RFC3339) - databaseInstance.EffectiveEnableReadableSecondaries = false - databaseInstance.EffectiveStopped = false - databaseInstance.EffectiveEnablePgNativeLogin = false + databaseInstance.CreationTime = types.NewFromTime(time.Now().UTC().Truncate(time.Second)) + databaseInstance.EffectiveEnableReadableSecondaries = nil + databaseInstance.EffectiveStopped = nil + databaseInstance.EffectiveEnablePgNativeLogin = nil + setEffectiveBools(&databaseInstance) - databaseInstance.ForceSendFields = slices.Clone(ForceSendFields) - - s.DatabaseInstances[databaseInstance.Name] = databaseInstance + s.DatabaseInstances[utils.Deref(databaseInstance.Name)] = databaseInstance return Response{ Body: databaseInstance, @@ -61,7 +63,7 @@ func DatabaseInstanceMapGet(w *FakeWorkspace, collection map[string]database.Dat } } - value.ForceSendFields = slices.Clone(ForceSendFields) + setEffectiveBools(&value) return Response{ Body: value, @@ -91,25 +93,25 @@ func (s *FakeWorkspace) DatabaseInstanceUpdate(req Request, name string) Respons } // Update the instance with new values while preserving system-managed fields - updated := updateReq.DatabaseInstance + updated := utils.Deref(updateReq.DatabaseInstance) updated.Uid = existing.Uid // Preserve UID updated.Creator = existing.Creator // Preserve creator updated.CreationTime = existing.CreationTime // Preserve creation time updated.State = existing.State // Preserve state // Set defaults for effective fields if not specified - if updated.EffectiveNodeCount == 0 { + if utils.Deref(updated.EffectiveNodeCount) == 0 { updated.EffectiveNodeCount = existing.EffectiveNodeCount } - if updated.EffectiveRetentionWindowInDays == 0 { + if utils.Deref(updated.EffectiveRetentionWindowInDays) == 0 { updated.EffectiveRetentionWindowInDays = existing.EffectiveRetentionWindowInDays } - if updated.PgVersion == "" { + if utils.Deref(updated.PgVersion) == "" { updated.PgVersion = existing.PgVersion } - // Set ForceSendFields to ensure consistent serialization with DatabaseInstanceMapGet - updated.ForceSendFields = slices.Clone(ForceSendFields) + // Ensure consistent serialization with DatabaseInstanceMapGet + setEffectiveBools(&updated) // Update the stored instance s.DatabaseInstances[name] = updated diff --git a/libs/testserver/experiments.go b/libs/testserver/experiments.go index c7c3fa6c77d..09fbf2829c7 100644 --- a/libs/testserver/experiments.go +++ b/libs/testserver/experiments.go @@ -7,13 +7,14 @@ import ( "strconv" "strings" - "github.com/databricks/databricks-sdk-go/service/ml" + experiments "github.com/databricks/cli/libs/sdktypes/experiments/v1" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) ExperimentCreate(req Request) Response { defer s.LockUnlock()() - var experiment ml.CreateExperiment + var experiment experiments.CreateExperimentRequest if err := json.Unmarshal(req.Body, &experiment); err != nil { return Response{ Body: fmt.Sprintf("request parsing error: %s", err), @@ -25,63 +26,63 @@ func (s *FakeWorkspace) ExperimentCreate(req Request) Response { // Server appends these tags automatically to experiments. // We replicate that behaviour in the test server as well. - appendTags := []ml.ExperimentTag{ + appendTags := []experiments.ExperimentTag{ { - Key: "mlflow.ownerId", + Key: utils.NonZero("mlflow.ownerId"), Value: testUser.Id, }, { - Key: "mlflow.experiment.sourceName", + Key: utils.NonZero("mlflow.experiment.sourceName"), Value: experiment.Name, }, { - Key: "mlflow.ownerId", + Key: utils.NonZero("mlflow.ownerId"), Value: testUser.Id, }, { - Key: "mlflow.ownerEmail", + Key: utils.NonZero("mlflow.ownerEmail"), Value: testUser.UserName, }, { - Key: "mlflow.experimentType", - Value: "MLFLOW_EXPERIMENT", + Key: utils.NonZero("mlflow.experimentType"), + Value: utils.NonZero("MLFLOW_EXPERIMENT"), }, } experimentId := strconv.FormatInt(nextID(), 10) - if experiment.ArtifactLocation == "" { - experiment.ArtifactLocation = "dbfs:/databricks/mlflow-tracking/" + experimentId + if utils.Deref(experiment.ArtifactLocation) == "" { + experiment.ArtifactLocation = utils.NonZero("dbfs:/databricks/mlflow-tracking/" + experimentId) } // Strip /Workspace prefix from experiment name to match cloud behavior // Input: //Workspace/Users/foo -> Output: /Users/foo experimentName := experiment.Name // Remove double slash used for Windows compatibility - if strings.HasPrefix(experimentName, "//") { - experimentName = strings.TrimPrefix(experimentName, "/") + if strings.HasPrefix(utils.Deref(experimentName), "//") { + experimentName = utils.NonZero(strings.TrimPrefix(utils.Deref(experimentName), "/")) } // Remove /Workspace prefix - experimentName = strings.TrimPrefix(experimentName, "/Workspace") + experimentName = utils.NonZero(strings.TrimPrefix(utils.Deref(experimentName), "/Workspace")) // Create the experiment - exp := ml.Experiment{ - ExperimentId: experimentId, + exp := experiments.Experiment{ + ExperimentId: utils.NonZero(experimentId), Name: experimentName, ArtifactLocation: experiment.ArtifactLocation, Tags: append(experiment.Tags, appendTags...), - LifecycleStage: "active", + LifecycleStage: utils.NonZero("active"), // Echo back like the real GetExperiment; omitting this immutable field triggers a spurious recreate. TraceLocation: experiment.TraceLocation, } - s.Experiments[experimentId] = ml.GetExperimentResponse{ + s.Experiments[experimentId] = experiments.GetExperimentResponse{ Experiment: &exp, } return Response{ - Body: ml.CreateExperimentResponse{ - ExperimentId: experimentId, + Body: experiments.CreateExperimentResponse{ + ExperimentId: utils.NonZero(experimentId), }, } } @@ -89,7 +90,7 @@ func (s *FakeWorkspace) ExperimentCreate(req Request) Response { func (s *FakeWorkspace) ExperimentUpdate(req Request) Response { defer s.LockUnlock()() - var updateReq ml.UpdateExperiment + var updateReq experiments.UpdateExperimentRequest if err := json.Unmarshal(req.Body, &updateReq); err != nil { return Response{ Body: fmt.Sprintf("request parsing error: %s", err), @@ -97,34 +98,34 @@ func (s *FakeWorkspace) ExperimentUpdate(req Request) Response { } } - experiment, exists := s.Experiments[updateReq.ExperimentId] + experiment, exists := s.Experiments[utils.Deref(updateReq.ExperimentId)] if !exists { return Response{ StatusCode: http.StatusNotFound, - Body: map[string]string{"message": fmt.Sprintf("Experiment %s not found", updateReq.ExperimentId)}, + Body: map[string]string{"message": fmt.Sprintf("Experiment %s not found", utils.Deref(updateReq.ExperimentId))}, } } // Update the experiment - if updateReq.NewName != "" { + if utils.Deref(updateReq.NewName) != "" { experiment.Experiment.Name = updateReq.NewName // The server modifies the value of the tag as well. Mimic that behaviour // in the test server as well. for i := range experiment.Experiment.Tags { - if experiment.Experiment.Tags[i].Key == "mlflow.experiment.sourceName" { + if utils.Deref(experiment.Experiment.Tags[i].Key) == "mlflow.experiment.sourceName" { experiment.Experiment.Tags[i].Value = updateReq.NewName } } } - s.Experiments[updateReq.ExperimentId] = experiment + s.Experiments[utils.Deref(updateReq.ExperimentId)] = experiment return Response{} } func (s *FakeWorkspace) ExperimentDelete(req Request) Response { - var deleteReq ml.DeleteExperiment + var deleteReq experiments.DeleteExperimentRequest if err := json.Unmarshal(req.Body, &deleteReq); err != nil { return Response{ Body: fmt.Sprintf("request parsing error: %s", err), @@ -132,5 +133,5 @@ func (s *FakeWorkspace) ExperimentDelete(req Request) Response { } } - return MapDelete(s, s.Experiments, deleteReq.ExperimentId) + return MapDelete(s, s.Experiments, utils.Deref(deleteReq.ExperimentId)) } diff --git a/libs/testserver/external_locations.go b/libs/testserver/external_locations.go index 8fba059804b..8df01f3d26e 100644 --- a/libs/testserver/external_locations.go +++ b/libs/testserver/external_locations.go @@ -5,13 +5,14 @@ import ( "fmt" "net/http" - "github.com/databricks/databricks-sdk-go/service/catalog" + externallocations "github.com/databricks/cli/libs/sdktypes/uc/externallocations/v1" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) ExternalLocationsCreate(req Request) Response { defer s.LockUnlock()() - var createRequest catalog.CreateExternalLocation + var createRequest externallocations.CreateExternalLocationRequest if err := json.Unmarshal(req.Body, &createRequest); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -19,14 +20,14 @@ func (s *FakeWorkspace) ExternalLocationsCreate(req Request) Response { } } - if createRequest.Url == "" { + if utils.Deref(createRequest.Url) == "" { return Response{ Body: "CreateExternalLocation Missing required field: url", StatusCode: http.StatusBadRequest, } } - locationInfo := catalog.ExternalLocationInfo{ + locationInfo := externallocations.ExternalLocationInfo{ Name: createRequest.Name, Url: createRequest.Url, CredentialName: createRequest.CredentialName, @@ -36,15 +37,15 @@ func (s *FakeWorkspace) ExternalLocationsCreate(req Request) Response { Fallback: createRequest.Fallback, EncryptionDetails: createRequest.EncryptionDetails, FileEventQueue: createRequest.FileEventQueue, - CreatedAt: nowMilli(), + CreatedAt: utils.NonZero(nowMilli()), CreatedBy: s.CurrentUser().UserName, UpdatedBy: s.CurrentUser().UserName, - MetastoreId: nextUUID(), + MetastoreId: utils.NonZero(nextUUID()), Owner: s.CurrentUser().UserName, } locationInfo.UpdatedAt = locationInfo.CreatedAt - s.ExternalLocations[createRequest.Name] = locationInfo + s.ExternalLocations[utils.Deref(createRequest.Name)] = locationInfo return Response{ Body: locationInfo, } @@ -66,7 +67,7 @@ func (s *FakeWorkspace) ExternalLocationsUpdate(req Request, name string) Respon return *errResponse } - var updateRequest catalog.UpdateExternalLocation + var updateRequest externallocations.UpdateExternalLocationRequest if err := json.Unmarshal(req.Body, &updateRequest); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -82,15 +83,15 @@ func (s *FakeWorkspace) ExternalLocationsUpdate(req Request, name string) Respon existing.EnableFileEvents = updateRequest.EnableFileEvents existing.Fallback = updateRequest.Fallback - if updateRequest.NewName != "" { + if utils.Deref(updateRequest.NewName) != "" { existing.Name = updateRequest.NewName // Delete the old entry and create with new name delete(s.ExternalLocations, name) - name = updateRequest.NewName + name = utils.Deref(updateRequest.NewName) } - existing.UpdatedAt = nowMilli() + existing.UpdatedAt = utils.NonZero(nowMilli()) existing.UpdatedBy = s.CurrentUser().UserName s.ExternalLocations[name] = existing diff --git a/libs/testserver/fake_workspace.go b/libs/testserver/fake_workspace.go index d55e336e88a..bddb7f38d8f 100644 --- a/libs/testserver/fake_workspace.go +++ b/libs/testserver/fake_workspace.go @@ -19,24 +19,43 @@ import ( "sync/atomic" "time" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/dashboards" - "github.com/databricks/databricks-sdk-go/service/database" - "github.com/databricks/databricks-sdk-go/service/postgres" + qualitymonitors "github.com/databricks/cli/libs/qualitymonitors" + accessmanagement "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" + aigateway "github.com/databricks/cli/libs/sdktypes/aigateway/v1" + alerts "github.com/databricks/cli/libs/sdktypes/alerts/v2" + apps "github.com/databricks/cli/libs/sdktypes/apps/v1" + clusterlibraries "github.com/databricks/cli/libs/sdktypes/clusterlibraries/v2" + clusterpolicies "github.com/databricks/cli/libs/sdktypes/clusterpolicies/v2" + clusters "github.com/databricks/cli/libs/sdktypes/clusters/v2" + database "github.com/databricks/cli/libs/sdktypes/database/v1" + experiments "github.com/databricks/cli/libs/sdktypes/experiments/v1" + files "github.com/databricks/cli/libs/sdktypes/files/v2" + genie "github.com/databricks/cli/libs/sdktypes/genie/v1" + instancepools "github.com/databricks/cli/libs/sdktypes/instancepools/v2" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + lakeview "github.com/databricks/cli/libs/sdktypes/lakeview/v1" + modelregistry "github.com/databricks/cli/libs/sdktypes/modelregistry/v1" + serving "github.com/databricks/cli/libs/sdktypes/modelserving/v1" + pipelines "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + repos "github.com/databricks/cli/libs/sdktypes/repos/v1" + scim "github.com/databricks/cli/libs/sdktypes/scim/v1" + secrets "github.com/databricks/cli/libs/sdktypes/secrets/v1" + catalogs "github.com/databricks/cli/libs/sdktypes/uc/catalogs/v1" + externallocations "github.com/databricks/cli/libs/sdktypes/uc/externallocations/v1" + grants "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + registeredmodels "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1" + schemas "github.com/databricks/cli/libs/sdktypes/uc/schemas/v1" + ucsecrets "github.com/databricks/cli/libs/sdktypes/uc/secrets/v1" + volumes "github.com/databricks/cli/libs/sdktypes/uc/volumes/v1" + vectorsearch "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" + warehouses "github.com/databricks/cli/libs/sdktypes/warehouses/v1" + "github.com/databricks/cli/libs/utils" + workspaceapi "github.com/databricks/cli/libs/workspaceapi" + "github.com/databricks/sdk-go/core/types" "github.com/google/uuid" "github.com/databricks/cli/libs/structs/structtag" - "github.com/databricks/databricks-sdk-go/service/apps" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/files" - "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/ml" - "github.com/databricks/databricks-sdk-go/service/pipelines" - "github.com/databricks/databricks-sdk-go/service/serving" - "github.com/databricks/databricks-sdk-go/service/sql" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" - "github.com/databricks/databricks-sdk-go/service/workspace" ) const ( @@ -57,14 +76,14 @@ const ( TestDefaultInstancePoolId = "0123-456789-pool0" ) -var TestUser = iam.User{ - Id: UserID, - UserName: "tester@databricks.com", +var TestUser = scim.User{ + Id: utils.NonZero(UserID), + UserName: utils.NonZero("tester@databricks.com"), } -var TestUserSP = iam.User{ - Id: UserID, - UserName: "aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee", +var TestUserSP = scim.User{ + Id: utils.NonZero(UserID), + UserName: utils.NonZero("aaaaaaaa-bbbb-4ccc-dddd-eeeeeeeeeeee"), } // guestServicePrincipalDisplayName is reported on /Me for the as-test-sp guest, @@ -79,7 +98,7 @@ func isGuestToken(token string) bool { // userForToken returns the identity behind a token: any service-principal token // (primary or guest) is the SP, otherwise the user. -func userForToken(token string) iam.User { +func userForToken(token string) scim.User { if strings.HasPrefix(token, ServicePrincipalTokenPrefix) || isGuestToken(token) { return TestUserSP } @@ -88,10 +107,10 @@ func userForToken(token string) iam.User { // MeUser returns the /Me identity for a token. Only the guest SP carries a // display name, so single-identity SP tests are unaffected. -func (s *FakeWorkspace) MeUser(token string) iam.User { +func (s *FakeWorkspace) MeUser(token string) scim.User { user := userForToken(token) if isGuestToken(token) { - user.DisplayName = guestServicePrincipalDisplayName + user.DisplayName = utils.NonZero(guestServicePrincipalDisplayName) } return user } @@ -149,8 +168,10 @@ func nowMilli() int64 { // precision. The sub-second component keeps distinct events ordered even within the // same wall-clock second, which the dashboard publish lifecycle relies on to compare // a draft's update_time against a published revision's revision_create_time. -func nextTimestamp() string { - return time.Unix(0, nowNano()).UTC().Format(time.RFC3339Nano) + +// nextTime is the protobuf timestamp version of nextTimestamp. +func nextTime() *types.Time { + return types.NewFromTime(time.Unix(0, nowNano()).UTC()) } func nextUUID() string { @@ -169,12 +190,12 @@ func nextDashboardID() string { } type FileEntry struct { - Info workspace.ObjectInfo + Info workspaceapi.ObjectInfo Data []byte } type fakeDashboard struct { - dashboards.Dashboard + lakeview.Dashboard // Input value of the serialized dashboard provided. This is used // to detect if the etag needs to be updated. @@ -194,41 +215,41 @@ type FakeWorkspace struct { // recreates without polling) keep immediate deletion. eventualConsistency bool - directories map[string]workspace.ObjectInfo + directories map[string]workspaceapi.ObjectInfo files map[string]FileEntry repoIdByPath map[string]int64 - Jobs map[int64]jobs.Job + Jobs map[int64]jobs.GetJobResponse JobRuns map[int64]jobs.Run - JobRunOutputs map[int64]jobs.RunOutput + JobRunOutputs map[int64]jobs.GetRunOutputResponse JobRunIdempotency map[string]int64 Pipelines map[string]pipelines.GetPipelineResponse PipelineUpdates map[string]bool - Monitors map[string]catalog.MonitorInfo + Monitors map[string]qualitymonitors.MonitorInfo Apps map[string]apps.App - Schemas map[string]catalog.SchemaInfo - Grants map[string][]catalog.PrivilegeAssignment - Volumes map[string]catalog.VolumeInfo + Schemas map[string]schemas.SchemaInfo + Grants map[string][]grants.PrivilegeAssignment + Volumes map[string]volumes.VolumeInfo Dashboards *EventualMap[string, *fakeDashboard] - PublishedDashboards map[string]dashboards.PublishedDashboard - GenieSpaces map[string]dashboards.GenieSpace - SqlWarehouses map[string]sql.GetWarehouseResponse - Alerts map[string]sql.AlertV2 - Experiments map[string]ml.GetExperimentResponse - ModelRegistryModels map[string]ml.Model + PublishedDashboards map[string]lakeview.PublishedDashboard + GenieSpaces map[string]genie.GenieSpace + SqlWarehouses map[string]warehouses.GetWarehouseResponse + Alerts map[string]alerts.Alert + Experiments map[string]experiments.GetExperimentResponse + ModelRegistryModels map[string]modelregistry.RegisteredModel ModelRegistryModelIDs map[string]string // model name -> numeric ID - Clusters map[string]compute.ClusterDetails - ClusterLibraries map[string][]compute.Library // cluster id -> installed libraries - InstancePools map[string]compute.GetInstancePool - ClusterPolicies map[string]compute.Policy - Catalogs map[string]catalog.CatalogInfo - ExternalLocations map[string]catalog.ExternalLocationInfo - RegisteredModels map[string]catalog.RegisteredModelInfo - ModelServices map[string]catalog.ModelService - McpServices map[string]catalog.McpService - ModelProviderServices map[string]catalog.ModelProviderService - ServingEndpoints map[string]serving.ServingEndpointDetailed - VectorSearchEndpoints map[string]vectorsearch.EndpointInfo + Clusters map[string]clusters.ClusterInfo + ClusterLibraries map[string][]clusterlibraries.Library // cluster id -> installed libraries + InstancePools map[string]instancepools.GetInstancePoolResponse + ClusterPolicies map[string]clusterpolicies.Policy + Catalogs map[string]catalogs.CatalogInfo + ExternalLocations map[string]externallocations.ExternalLocationInfo + RegisteredModels map[string]registeredmodels.RegisteredModelInfo + ModelServices map[string]aigateway.ModelService + McpServices map[string]aigateway.McpService + ModelProviderServices map[string]aigateway.ModelProviderService + ServingEndpoints map[string]serving.InferenceEndpointDetailed + VectorSearchEndpoints map[string]vectorsearch.Endpoint VectorSearchIndexes map[string]fakeVectorSearchIndex // VectorSearchIndexesPendingDeletion counts how many further CREATEs an @@ -236,17 +257,17 @@ type FakeWorkspace struct { // VectorSearchIndexDelete. VectorSearchIndexesPendingDeletion map[string]int - SecretScopes map[string]workspace.SecretScope + SecretScopes map[string]secrets.SecretScope Secrets map[string]map[string]string // scope -> key -> value - Acls map[string][]workspace.AclItem - UCSecrets map[string]catalog.Secret // full_name -> secret (Unity Catalog secrets) + Acls map[string][]secrets.AclItem + UCSecrets map[string]ucsecrets.Secret // full_name -> secret (Unity Catalog secrets) // Generic permissions storage: key is "{object_type}:{object_id}" - Permissions map[string]iam.ObjectPermissions + Permissions map[string]accessmanagement.PermissionsResponse - Groups map[string]iam.Group + Groups map[string]scim.Group - Repos map[string]workspace.RepoInfo + Repos map[string]repos.RepoInfo DatabaseInstances map[string]database.DatabaseInstance DatabaseCatalogs map[string]database.DatabaseCatalog @@ -342,8 +363,8 @@ func parseUCUpdate(body []byte, operation string) (map[string]json.RawMessage, * } // applyUpdatedFields copies every field the update payload names from update onto -// existing, matched by JSON name, and marks it force-send so a zero value survives the -// response encoding (the stored *Info types are all omitempty). +// existing, matched by JSON name. Optional fields are pointers, so a zero value the +// payload sets survives the response encoding. // // Fields the payload omits are left untouched: a partial-update API changes only what the // caller names, and modelling that is the whole point of these fakes. Fields the payload @@ -366,14 +387,6 @@ func applyUpdatedFields(existing, update any, fields map[string]json.RawMessage) continue } dstField.Set(src.Field(i)) - forceSend := dst.FieldByName("ForceSendFields") - if forceSend.IsValid() && forceSend.CanSet() { - goName := src.Type().Field(i).Name - // Repeated updates would otherwise keep appending the same name. - if !slices.Contains(forceSend.Interface().([]string), goName) { - forceSend.Set(reflect.Append(forceSend, reflect.ValueOf(goName))) - } - } } } @@ -448,7 +461,7 @@ func NewFakeWorkspace(url, token string) *FakeWorkspace { url: url, isServicePrincipal: strings.HasPrefix(token, ServicePrincipalTokenPrefix), eventualConsistency: eventualConsistency, - directories: map[string]workspace.ObjectInfo{ + directories: map[string]workspaceapi.ObjectInfo{ "/Workspace": { ObjectType: "DIRECTORY", Path: "/Workspace", @@ -459,14 +472,14 @@ func NewFakeWorkspace(url, token string) *FakeWorkspace { Path: "/Users", ObjectId: nextTreenodeID(), }, - "/Users/" + TestUser.UserName: { + "/Users/" + utils.Deref(TestUser.UserName): { ObjectType: "DIRECTORY", - Path: "/Users/" + TestUser.UserName, + Path: "/Users/" + utils.Deref(TestUser.UserName), ObjectId: nextTreenodeID(), }, - "/Users/" + TestUserSP.UserName: { + "/Users/" + utils.Deref(TestUserSP.UserName): { ObjectType: "DIRECTORY", - Path: "/Users/" + TestUserSP.UserName, + Path: "/Users/" + utils.Deref(TestUserSP.UserName), ObjectId: nextTreenodeID(), }, // The user home also exists under the /Workspace alias on real @@ -477,56 +490,56 @@ func NewFakeWorkspace(url, token string) *FakeWorkspace { Path: "/Workspace/Users", ObjectId: nextTreenodeID(), }, - "/Workspace/Users/" + TestUser.UserName: { + "/Workspace/Users/" + utils.Deref(TestUser.UserName): { ObjectType: "DIRECTORY", - Path: "/Workspace/Users/" + TestUser.UserName, + Path: "/Workspace/Users/" + utils.Deref(TestUser.UserName), ObjectId: nextTreenodeID(), }, - "/Workspace/Users/" + TestUserSP.UserName: { + "/Workspace/Users/" + utils.Deref(TestUserSP.UserName): { ObjectType: "DIRECTORY", - Path: "/Workspace/Users/" + TestUserSP.UserName, + Path: "/Workspace/Users/" + utils.Deref(TestUserSP.UserName), ObjectId: nextTreenodeID(), }, }, files: make(map[string]FileEntry), repoIdByPath: make(map[string]int64), - Jobs: map[int64]jobs.Job{}, + Jobs: map[int64]jobs.GetJobResponse{}, JobRuns: map[int64]jobs.Run{}, - JobRunOutputs: map[int64]jobs.RunOutput{}, + JobRunOutputs: map[int64]jobs.GetRunOutputResponse{}, JobRunIdempotency: map[string]int64{}, - Grants: map[string][]catalog.PrivilegeAssignment{}, + Grants: map[string][]grants.PrivilegeAssignment{}, Pipelines: map[string]pipelines.GetPipelineResponse{}, PipelineUpdates: map[string]bool{}, - Monitors: map[string]catalog.MonitorInfo{}, + Monitors: map[string]qualitymonitors.MonitorInfo{}, Apps: map[string]apps.App{}, - Catalogs: map[string]catalog.CatalogInfo{}, - ExternalLocations: map[string]catalog.ExternalLocationInfo{}, - Schemas: map[string]catalog.SchemaInfo{}, - RegisteredModels: map[string]catalog.RegisteredModelInfo{}, - ModelServices: map[string]catalog.ModelService{}, - McpServices: map[string]catalog.McpService{}, - ModelProviderServices: map[string]catalog.ModelProviderService{}, - Volumes: map[string]catalog.VolumeInfo{}, + Catalogs: map[string]catalogs.CatalogInfo{}, + ExternalLocations: map[string]externallocations.ExternalLocationInfo{}, + Schemas: map[string]schemas.SchemaInfo{}, + RegisteredModels: map[string]registeredmodels.RegisteredModelInfo{}, + ModelServices: map[string]aigateway.ModelService{}, + McpServices: map[string]aigateway.McpService{}, + ModelProviderServices: map[string]aigateway.ModelProviderService{}, + Volumes: map[string]volumes.VolumeInfo{}, Dashboards: NewEventualMap[string, *fakeDashboard](eventualConsistency), - PublishedDashboards: map[string]dashboards.PublishedDashboard{}, - GenieSpaces: map[string]dashboards.GenieSpace{}, - SqlWarehouses: map[string]sql.GetWarehouseResponse{ + PublishedDashboards: map[string]lakeview.PublishedDashboard{}, + GenieSpaces: map[string]genie.GenieSpace{}, + SqlWarehouses: map[string]warehouses.GetWarehouseResponse{ TestDefaultWarehouseId: { - Id: TestDefaultWarehouseId, - Name: "DEFAULT Test SQL Warehouse", - State: sql.StateRunning, + Id: utils.NonZero(TestDefaultWarehouseId), + Name: utils.NonZero("DEFAULT Test SQL Warehouse"), + State: warehouses.EndpointState_Running, }, }, - ServingEndpoints: map[string]serving.ServingEndpointDetailed{}, - VectorSearchEndpoints: map[string]vectorsearch.EndpointInfo{}, + ServingEndpoints: map[string]serving.InferenceEndpointDetailed{}, + VectorSearchEndpoints: map[string]vectorsearch.Endpoint{}, VectorSearchIndexes: map[string]fakeVectorSearchIndex{}, - Repos: map[string]workspace.RepoInfo{}, - SecretScopes: map[string]workspace.SecretScope{}, + Repos: map[string]repos.RepoInfo{}, + SecretScopes: map[string]secrets.SecretScope{}, Secrets: map[string]map[string]string{}, - Acls: map[string][]workspace.AclItem{}, - Permissions: map[string]iam.ObjectPermissions{}, - Groups: map[string]iam.Group{}, + Acls: map[string][]secrets.AclItem{}, + Permissions: map[string]accessmanagement.PermissionsResponse{}, + Groups: map[string]scim.Group{}, DatabaseInstances: map[string]database.DatabaseInstance{}, DatabaseCatalogs: map[string]database.DatabaseCatalog{}, SyncedDatabaseTables: map[string]database.SyncedDatabaseTable{}, @@ -544,35 +557,35 @@ func NewFakeWorkspace(url, token string) *FakeWorkspace { clusterVenvs: map[string]*clusterEnv{}, DmsDeployments: map[string]*DmsDeployment{}, DmsDeploymentNodes: map[string]string{}, - Alerts: map[string]sql.AlertV2{}, - Experiments: map[string]ml.GetExperimentResponse{}, - ModelRegistryModels: map[string]ml.Model{}, + Alerts: map[string]alerts.Alert{}, + Experiments: map[string]experiments.GetExperimentResponse{}, + ModelRegistryModels: map[string]modelregistry.RegisteredModel{}, ModelRegistryModelIDs: map[string]string{}, - Clusters: map[string]compute.ClusterDetails{ + Clusters: map[string]clusters.ClusterInfo{ // A running dedicated single-user cluster: the shape `ssh connect --cluster` // requires (ValidateClusterAccess rejects anything else), matching the cloud // TEST_DEFAULT_CLUSTER_ID this stands in for. TestDefaultClusterId: { - ClusterId: TestDefaultClusterId, - ClusterName: "DEFAULT Test Cluster", - State: compute.StateRunning, - DataSecurityMode: compute.DataSecurityModeSingleUser, + ClusterId: utils.NonZero(TestDefaultClusterId), + ClusterName: utils.NonZero("DEFAULT Test Cluster"), + State: clusters.ClusterState_ClusterState_Running, + DataSecurityMode: clusters.DataSecurityMode_SingleUser, SingleUserName: TestUser.UserName, }, }, - InstancePools: map[string]compute.GetInstancePool{}, - ClusterLibraries: map[string][]compute.Library{}, - ClusterPolicies: map[string]compute.Policy{ + InstancePools: map[string]instancepools.GetInstancePoolResponse{}, + ClusterLibraries: map[string][]clusterlibraries.Library{}, + ClusterPolicies: map[string]clusterpolicies.Policy{ // Seeded so the stateful list keeps backing the variable-lookup tests // (e.g. acceptance/bundle/variables/env_overrides resolves these by name). - "5678": {PolicyId: "5678", Name: "wrong-cluster-policy"}, - "9876": {PolicyId: "9876", Name: "some-test-cluster-policy"}, + "5678": {PolicyId: utils.NonZero("5678"), Name: utils.NonZero("wrong-cluster-policy")}, + "9876": {PolicyId: utils.NonZero("9876"), Name: utils.NonZero("some-test-cluster-policy")}, }, VectorSearchIndexesPendingDeletion: map[string]int{}, } } -func (s *FakeWorkspace) CurrentUser() iam.User { +func (s *FakeWorkspace) CurrentUser() scim.User { if s != nil && s.isServicePrincipal { return TestUserSP } else { @@ -581,7 +594,7 @@ func (s *FakeWorkspace) CurrentUser() iam.User { } // gitInfoBlock is the git_info block get-status adds for return_git_info=true. -// workspace.ObjectInfo does not model it (the field is undocumented), so it is +// workspaceapi.ObjectInfo does not model it (the field is undocumented), so it is // merged into the response separately, see withGitInfo. // // A Git folder that has Git CLI access does not store the git metadata on the @@ -597,12 +610,12 @@ type gitInfoBlock struct { // withGitInfo returns info as an object with a git_info block added. // -// It cannot be a struct embedding workspace.ObjectInfo: ObjectInfo declares +// It cannot be a struct embedding workspaceapi.ObjectInfo: ObjectInfo declares // MarshalJSON, which gets promoted to the embedding struct, so the outer // git_info field would be dropped from the output without any error. The // intermediate map holds json.RawMessage rather than any, so that large ids do // not lose precision by passing through float64. -func withGitInfo(info workspace.ObjectInfo, gi gitInfoBlock) (any, error) { +func withGitInfo(info workspaceapi.ObjectInfo, gi gitInfoBlock) (any, error) { infoJSON, err := json.Marshal(info) if err != nil { return nil, err @@ -623,7 +636,7 @@ func withGitInfo(info workspace.ObjectInfo, gi gitInfoBlock) (any, error) { // longest registered Git folder path that is a prefix of it. get-status reports // the containing folder's metadata for paths inside a Git folder, not just for // its root. -func (s *FakeWorkspace) gitFolderFor(objectPath string) (workspace.RepoInfo, bool) { +func (s *FakeWorkspace) gitFolderFor(objectPath string) (repos.RepoInfo, bool) { longest := "" for repoPath := range s.repoIdByPath { if objectPath != repoPath && !strings.HasPrefix(objectPath, repoPath+"/") { @@ -634,7 +647,7 @@ func (s *FakeWorkspace) gitFolderFor(objectPath string) (workspace.RepoInfo, boo } } if longest == "" { - return workspace.RepoInfo{}, false + return repos.RepoInfo{}, false } return s.Repos[strconv.FormatInt(s.repoIdByPath[longest], 10)], true } @@ -660,7 +673,7 @@ func (s *FakeWorkspace) WorkspaceGetStatus(requestPath string, returnGitInfo boo // The real API collapses duplicate slashes, so look up the cleaned path. cleaned := path.Clean(requestPath) - var info workspace.ObjectInfo + var info workspaceapi.ObjectInfo // A Git folder root is reported as the repo, before any directory entry for // the same path: mkdirs of a path inside a Git folder seeds its ancestors, // which would otherwise shadow the root and report the wrong object id. @@ -668,11 +681,11 @@ func (s *FakeWorkspace) WorkspaceGetStatus(requestPath string, returnGitInfo boo // Control-plane repos (under /Repos) report the REPO object type, while // Git-CLI-enabled folders elsewhere are materialized as plain DIRECTORY // nodes. Both resolve to a valid repo ID via the repos API. - objectType := workspace.ObjectTypeRepo + objectType := workspaceapi.ObjectTypeRepo if isGitCliFolder(cleaned) { - objectType = workspace.ObjectTypeDirectory + objectType = workspaceapi.ObjectTypeDirectory } - info = workspace.ObjectInfo{ObjectType: objectType, Path: cleaned, ObjectId: repoId} + info = workspaceapi.ObjectInfo{ObjectType: objectType, Path: cleaned, ObjectId: repoId} } else if dirInfo, ok := s.directories[cleaned]; ok { info = dirInfo } else if entry, ok := s.files[cleaned]; ok { @@ -697,13 +710,13 @@ func (s *FakeWorkspace) WorkspaceGetStatus(requestPath string, returnGitInfo boo if repo, ok := s.gitFolderFor(cleaned); ok { // The real API reports the Git folder root without the /Workspace mount // prefix, whichever spelling the folder was created with. - gi := gitInfoBlock{ID: repo.Id, Path: strings.TrimPrefix(repo.Path, "/Workspace")} - if isGitCliFolder(repo.Path) { - info.DirectoryInfo = &workspace.DirectoryInfo{IsGitFolder: true} + gi := gitInfoBlock{ID: utils.Deref(repo.Id), Path: strings.TrimPrefix(utils.Deref(repo.Path), "/Workspace")} + if isGitCliFolder(utils.Deref(repo.Path)) { + info.DirectoryInfo = &workspaceapi.DirectoryInfo{IsGitFolder: true} } else { - gi.Branch = repo.Branch - gi.HeadCommitID = repo.HeadCommitId - gi.URL = repo.Url + gi.Branch = utils.Deref(repo.Branch) + gi.HeadCommitID = utils.Deref(repo.HeadCommitId) + gi.URL = utils.Deref(repo.Url) } body, err := withGitInfo(info, gi) if err != nil { @@ -736,7 +749,7 @@ func (s *FakeWorkspace) WorkspaceList(listPath string) Response { } } - var objects []workspace.ObjectInfo + var objects []workspaceapi.ObjectInfo for filePath, entry := range s.files { if path.Dir(filePath) == cleaned { @@ -749,12 +762,12 @@ func (s *FakeWorkspace) WorkspaceList(listPath string) Response { } } - slices.SortFunc(objects, func(a, b workspace.ObjectInfo) int { + slices.SortFunc(objects, func(a, b workspaceapi.ObjectInfo) int { return strings.Compare(a.Path, b.Path) }) return Response{ - Body: workspace.ListResponse{Objects: objects}, + Body: workspaceapi.ListResponse{Objects: objects}, } } @@ -779,24 +792,24 @@ func (s *FakeWorkspace) FsListDirectory(dirPath string) Response { for filePath, entry := range s.files { if path.Dir(filePath) == dirPath { contents = append(contents, files.DirectoryEntry{ - Name: path.Base(filePath), - Path: filePath, - FileSize: int64(len(entry.Data)), + Name: utils.NonZero(path.Base(filePath)), + Path: utils.NonZero(filePath), + FileSize: utils.NonZero(len(entry.Data)), }) } } for childPath := range s.directories { if childPath != dirPath && path.Dir(childPath) == dirPath { contents = append(contents, files.DirectoryEntry{ - Name: path.Base(childPath), - Path: childPath, - IsDirectory: true, + Name: utils.NonZero(path.Base(childPath)), + Path: utils.NonZero(childPath), + IsDirectory: utils.NonZero(true), }) } } slices.SortFunc(contents, func(a, b files.DirectoryEntry) int { - return strings.Compare(a.Path, b.Path) + return strings.Compare(utils.Deref(a.Path), utils.Deref(b.Path)) }) return Response{ @@ -823,13 +836,13 @@ func (s *FakeWorkspace) FsDeleteFile(filePath string) Response { return Response{} } -func (s *FakeWorkspace) WorkspaceMkdirs(request workspace.Mkdirs) { +func (s *FakeWorkspace) WorkspaceMkdirs(request workspaceapi.Mkdirs) { defer s.LockUnlock()() // The real mkdirs API creates all intermediate directories ("mkdir -p"), // so seed every ancestor up to the root. for dir := request.Path; dir != "/" && dir != "" && dir != "."; dir = path.Dir(dir) { if _, exists := s.directories[dir]; !exists { - s.directories[dir] = workspace.ObjectInfo{ + s.directories[dir] = workspaceapi.ObjectInfo{ ObjectType: "DIRECTORY", Path: dir, ObjectId: nextTreenodeID(), @@ -899,23 +912,23 @@ func (s *FakeWorkspace) hasChildren(dirPath string) bool { // // The extension is lowercased because the real endpoint matches it // case-insensitively, and ".R" is the conventional spelling for R sources. -func detectNotebookLanguage(extension string, body []byte) (workspace.Language, bool) { +func detectNotebookLanguage(extension string, body []byte) (workspaceapi.Language, bool) { switch strings.ToLower(extension) { case ".py": if bytes.HasPrefix(body, []byte("# Databricks notebook source")) { - return workspace.LanguagePython, true + return workspaceapi.LanguagePython, true } case ".sql": if bytes.HasPrefix(body, []byte("-- Databricks notebook source")) { - return workspace.LanguageSql, true + return workspaceapi.LanguageSql, true } case ".scala": if bytes.HasPrefix(body, []byte("// Databricks notebook source")) { - return workspace.LanguageScala, true + return workspaceapi.LanguageScala, true } case ".r": if bytes.HasPrefix(body, []byte("# Databricks notebook source")) { - return workspace.LanguageR, true + return workspaceapi.LanguageR, true } } return "", false @@ -989,11 +1002,11 @@ func (s *FakeWorkspace) WorkspaceImportZipFolder(zipPath string, body []byte, ov return name } - s.WorkspaceMkdirs(workspace.Mkdirs{Path: targetDir}) + s.WorkspaceMkdirs(workspaceapi.Mkdirs{Path: targetDir}) for _, entry := range entries { entryPath := path.Join(baseDir, rebase(entry.Name)) if entry.FileInfo().IsDir() { - s.WorkspaceMkdirs(workspace.Mkdirs{Path: entryPath}) + s.WorkspaceMkdirs(workspaceapi.Mkdirs{Path: entryPath}) continue } data, err := readZipEntry(entry) @@ -1053,7 +1066,7 @@ func (s *FakeWorkspace) importFile(filePath string, body []byte, overwrite, dete // Notebooks are stripped of their extension by the workspace import API. workspacePath = strings.TrimSuffix(filePath, extension) s.files[workspacePath] = FileEntry{ - Info: workspace.ObjectInfo{ + Info: workspaceapi.ObjectInfo{ ObjectType: "NOTEBOOK", Path: workspacePath, Language: lang, @@ -1066,7 +1079,7 @@ func (s *FakeWorkspace) importFile(filePath string, body []byte, overwrite, dete // here as well. // ref: https://docs.databricks.com/api/workspace/workspace/getstatus#language s.files[workspacePath] = FileEntry{ - Info: workspace.ObjectInfo{ + Info: workspaceapi.ObjectInfo{ ObjectType: "FILE", Path: workspacePath, ObjectId: nextTreenodeID(), @@ -1102,7 +1115,7 @@ func (s *FakeWorkspace) requireParentDirectory(objectPath string) (Response, boo // Unlike AUTO format, SOURCE keeps the path as-is (no extension stripping) and // the notebook language is provided explicitly rather than sniffed from a // "# Databricks notebook source" header. -func (s *FakeWorkspace) WorkspaceImportNotebook(filePath string, body []byte, language workspace.Language, overwrite bool) Response { +func (s *FakeWorkspace) WorkspaceImportNotebook(filePath string, body []byte, language workspaceapi.Language, overwrite bool) Response { if !strings.HasPrefix(filePath, "/") { filePath = "/" + filePath } @@ -1123,7 +1136,7 @@ func (s *FakeWorkspace) WorkspaceImportNotebook(filePath string, body []byte, la } s.files[filePath] = FileEntry{ - Info: workspace.ObjectInfo{ + Info: workspaceapi.ObjectInfo{ ObjectType: "NOTEBOOK", Path: filePath, Language: language, diff --git a/libs/testserver/genie_spaces.go b/libs/testserver/genie_spaces.go index 1ca6118427e..7765963326d 100644 --- a/libs/testserver/genie_spaces.go +++ b/libs/testserver/genie_spaces.go @@ -7,7 +7,8 @@ import ( "strconv" "strings" - "github.com/databricks/databricks-sdk-go/service/dashboards" + genie "github.com/databricks/cli/libs/sdktypes/genie/v1" + "github.com/databricks/cli/libs/utils" ) // generateGenieSpaceId returns a random 32-character hex string. @@ -54,7 +55,7 @@ func canonicalizeGenieSerializedSpace(serialized string) string { func (s *FakeWorkspace) GenieSpaceCreate(req Request) Response { defer s.LockUnlock()() - var createReq dashboards.GenieCreateSpaceRequest + var createReq genie.GenieCreateSpaceRequest if err := json.Unmarshal(req.Body, &createReq); err != nil { return Response{ StatusCode: 400, @@ -65,8 +66,8 @@ func (s *FakeWorkspace) GenieSpaceCreate(req Request) Response { } // Default to user's home directory if parent_path is not provided (matches cloud behavior) - if createReq.ParentPath == "" { - createReq.ParentPath = "/Users/" + s.CurrentUser().UserName + if utils.Deref(createReq.ParentPath) == "" { + createReq.ParentPath = utils.NonZero("/Users/" + utils.Deref(s.CurrentUser().UserName)) } spaceId, err := generateGenieSpaceId() @@ -82,20 +83,20 @@ func (s *FakeWorkspace) GenieSpaceCreate(req Request) Response { // Strip the /Workspace prefix from parent_path before storing. This matches // the remote behavior: the GET API returns parent_path without the prefix, // mirroring DashboardCreate. - if strings.HasPrefix(createReq.ParentPath, "/Workspace/") { - createReq.ParentPath = strings.TrimPrefix(createReq.ParentPath, "/Workspace") + if strings.HasPrefix(utils.Deref(createReq.ParentPath), "/Workspace/") { + createReq.ParentPath = utils.NonZero(strings.TrimPrefix(utils.Deref(createReq.ParentPath), "/Workspace")) } - genieSpace := dashboards.GenieSpace{ - SpaceId: spaceId, + genieSpace := genie.GenieSpace{ + SpaceId: utils.NonZero(spaceId), Title: createReq.Title, Description: createReq.Description, ParentPath: createReq.ParentPath, WarehouseId: createReq.WarehouseId, - SerializedSpace: canonicalizeGenieSerializedSpace(createReq.SerializedSpace), + SerializedSpace: utils.NonZero(canonicalizeGenieSerializedSpace(utils.Deref(createReq.SerializedSpace))), // Mirror libs/testserver/dashboards.go: initialize etag to a numeric // string so each subsequent update can bump it monotonically. - Etag: "1", + Etag: utils.NonZero("1"), } s.GenieSpaces[spaceId] = genieSpace @@ -127,7 +128,7 @@ func (s *FakeWorkspace) GenieSpaceGet(req Request) Response { // (include_serialized_space=true). genieSpace is a copy, so clearing the // field here only affects the response. if req.URL.Query().Get("include_serialized_space") != "true" { - genieSpace.Etag = "" + genieSpace.Etag = nil } return Response{ @@ -149,7 +150,7 @@ func (s *FakeWorkspace) GenieSpaceUpdate(req Request) Response { } } - var updateReq dashboards.GenieUpdateSpaceRequest + var updateReq genie.GenieUpdateSpaceRequest if err := json.Unmarshal(req.Body, &updateReq); err != nil { return Response{ StatusCode: 400, @@ -165,51 +166,51 @@ func (s *FakeWorkspace) GenieSpaceUpdate(req Request) Response { // Optimistic concurrency: if the caller sent an etag, it must match the // current one. Empty etag means apply unconditionally. - if updateReq.Etag != "" && updateReq.Etag != genieSpace.Etag { + if utils.Deref(updateReq.Etag) != "" && utils.Deref(updateReq.Etag) != utils.Deref(genieSpace.Etag) { return Response{ StatusCode: 409, Body: map[string]string{ - "message": "Etag mismatch: expected " + genieSpace.Etag + ", got " + updateReq.Etag, + "message": "Etag mismatch: expected " + utils.Deref(genieSpace.Etag) + ", got " + utils.Deref(updateReq.Etag), }, } } prev := genieSpace - if updateReq.Title != "" { + if utils.Deref(updateReq.Title) != "" { genieSpace.Title = updateReq.Title } if _, ok := fields["description"]; ok { genieSpace.Description = updateReq.Description } - if updateReq.WarehouseId != "" { + if utils.Deref(updateReq.WarehouseId) != "" { genieSpace.WarehouseId = updateReq.WarehouseId } - if updateReq.ParentPath != "" { + if utils.Deref(updateReq.ParentPath) != "" { parentPath := updateReq.ParentPath - if strings.HasPrefix(parentPath, "/Workspace/") { - parentPath = strings.TrimPrefix(parentPath, "/Workspace") + if strings.HasPrefix(utils.Deref(parentPath), "/Workspace/") { + parentPath = utils.NonZero(strings.TrimPrefix(utils.Deref(parentPath), "/Workspace")) } genieSpace.ParentPath = parentPath } - if updateReq.SerializedSpace != "" { - genieSpace.SerializedSpace = canonicalizeGenieSerializedSpace(updateReq.SerializedSpace) + if utils.Deref(updateReq.SerializedSpace) != "" { + genieSpace.SerializedSpace = utils.NonZero(canonicalizeGenieSerializedSpace(utils.Deref(updateReq.SerializedSpace))) } // The backend bumps the etag only when serialized_space changes; updates to // other fields (title, description, warehouse_id, parent_path) leave it // unchanged. This mirrors the GET API, which only returns the etag // alongside serialized_space. - if prev.SerializedSpace != genieSpace.SerializedSpace { - prevEtag, err := strconv.Atoi(genieSpace.Etag) + if utils.Deref(prev.SerializedSpace) != utils.Deref(genieSpace.SerializedSpace) { + prevEtag, err := strconv.Atoi(utils.Deref(genieSpace.Etag)) if err != nil { return Response{ StatusCode: 500, Body: map[string]string{ - "message": "Invalid stored etag: " + genieSpace.Etag, + "message": "Invalid stored etag: " + utils.Deref(genieSpace.Etag), }, } } - genieSpace.Etag = strconv.Itoa(prevEtag + 1) + genieSpace.Etag = utils.NonZero(strconv.Itoa(prevEtag + 1)) } s.GenieSpaces[spaceId] = genieSpace diff --git a/libs/testserver/grants.go b/libs/testserver/grants.go index 380b0f80640..b6215ff613d 100644 --- a/libs/testserver/grants.go +++ b/libs/testserver/grants.go @@ -7,16 +7,17 @@ import ( "slices" "strings" - "github.com/databricks/databricks-sdk-go/service/catalog" + grants "github.com/databricks/cli/libs/sdktypes/uc/grants/v1" + "github.com/databricks/cli/libs/utils" ) // notImpliedByAllPrivileges are the privileges UC does not include in // ALL_PRIVILEGES, so granting or revoking ALL_PRIVILEGES never affects them. -var notImpliedByAllPrivileges = map[catalog.Privilege]bool{ - catalog.PrivilegeManage: true, - catalog.PrivilegeReadMetadata: true, - catalog.PrivilegeExternalUseSchema: true, - catalog.PrivilegeExternalUseLocation: true, +var notImpliedByAllPrivileges = map[string]bool{ + "MANAGE": true, + "READ_METADATA": true, + "EXTERNAL_USE_SCHEMA": true, + "EXTERNAL_USE_LOCATION": true, } func grantsKey(securableType, fullName string) string { @@ -24,7 +25,7 @@ func grantsKey(securableType, fullName string) string { } func (s *FakeWorkspace) GrantsUpdate(req Request, securableType, fullName string) Response { - var request catalog.UpdatePermissions + var request grants.UpdatePermissionsRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: http.StatusBadRequest, @@ -37,21 +38,21 @@ func (s *FakeWorkspace) GrantsUpdate(req Request, securableType, fullName string defer s.LockUnlock()() // Build a map of principals to privileges (using Privilege type directly) - principalPrivs := make(map[string]map[catalog.Privilege]bool) + principalPrivs := make(map[string]map[string]bool) // Load current grants for _, assignment := range s.Grants[key] { - if principalPrivs[assignment.Principal] == nil { - principalPrivs[assignment.Principal] = make(map[catalog.Privilege]bool) + if principalPrivs[utils.Deref(assignment.Principal)] == nil { + principalPrivs[utils.Deref(assignment.Principal)] = make(map[string]bool) } for _, privilege := range assignment.Privileges { - principalPrivs[assignment.Principal][privilege] = true + principalPrivs[utils.Deref(assignment.Principal)][privilege] = true } } // Validate: reject duplicate privileges in Add and Remove for the same principal for _, change := range request.Changes { - addSet := make(map[catalog.Privilege]bool, len(change.Add)) + addSet := make(map[string]bool, len(change.Add)) for _, p := range change.Add { addSet[p] = true } @@ -61,7 +62,7 @@ func (s *FakeWorkspace) GrantsUpdate(req Request, securableType, fullName string StatusCode: http.StatusBadRequest, Body: map[string]string{ "error_code": "INVALID_PARAMETER_VALUE", - "message": fmt.Sprintf("Duplicate privileges to add and delete for principal %s.", change.Principal), + "message": fmt.Sprintf("Duplicate privileges to add and delete for principal %s.", utils.Deref(change.Principal)), }, } } @@ -70,34 +71,34 @@ func (s *FakeWorkspace) GrantsUpdate(req Request, securableType, fullName string // Apply changes for _, change := range request.Changes { - if change.Principal == "" { + if utils.Deref(change.Principal) == "" { continue } - if principalPrivs[change.Principal] == nil { - principalPrivs[change.Principal] = make(map[catalog.Privilege]bool) + if principalPrivs[utils.Deref(change.Principal)] == nil { + principalPrivs[utils.Deref(change.Principal)] = make(map[string]bool) } // Remove privileges for _, privilege := range change.Remove { - if privilege == catalog.PrivilegeAllPrivileges { + if privilege == "ALL_PRIVILEGES" { // Removing ALL_PRIVILEGES clears every privilege it implies, but NOT // the ones UC does not include in ALL_PRIVILEGES (MANAGE, // READ_METADATA, EXTERNAL_USE_SCHEMA, EXTERNAL_USE_LOCATION). Those // are granted independently and survive. See // https://docs.databricks.com/aws/en/data-governance/unity-catalog/manage-privileges/privileges - for p := range principalPrivs[change.Principal] { + for p := range principalPrivs[utils.Deref(change.Principal)] { if !notImpliedByAllPrivileges[p] { - delete(principalPrivs[change.Principal], p) + delete(principalPrivs[utils.Deref(change.Principal)], p) } } } else { - delete(principalPrivs[change.Principal], privilege) + delete(principalPrivs[utils.Deref(change.Principal)], privilege) } } // Add privileges for _, privilege := range change.Add { - principalPrivs[change.Principal][privilege] = true + principalPrivs[utils.Deref(change.Principal)][privilege] = true } } @@ -105,23 +106,23 @@ func (s *FakeWorkspace) GrantsUpdate(req Request, securableType, fullName string // Note order of assignments is randomized due to map. This is intentional, azure backend behaves the same way // (deco env run -i -n azure-prod-ucws -- go test ./acceptance -run ^TestAccept$/^bundle$/^resources$/^grants$/^schemas$/^out_of_band_principal$/direct -count=10 -failfast -timeout=1h) - var assignments []catalog.PrivilegeAssignment + var assignments []grants.PrivilegeAssignment for principal, privs := range principalPrivs { if len(privs) == 0 { continue } // Collect and sort privileges directly - privileges := make([]catalog.Privilege, 0, len(privs)) + privileges := make([]string, 0, len(privs)) for priv := range privs { privileges = append(privileges, priv) } - slices.SortFunc(privileges, func(a, b catalog.Privilege) int { - return strings.Compare(string(a), string(b)) + slices.SortFunc(privileges, func(a, b string) int { + return strings.Compare(a, b) }) - assignments = append(assignments, catalog.PrivilegeAssignment{ - Principal: principal, + assignments = append(assignments, grants.PrivilegeAssignment{ + Principal: utils.NonZero(principal), Privileges: privileges, }) } @@ -131,13 +132,13 @@ func (s *FakeWorkspace) GrantsUpdate(req Request, securableType, fullName string if securableType == "schema" { schema, ok := s.Schemas[fullName] if ok { - schema.UpdatedAt = nowMilli() + schema.UpdatedAt = utils.NonZero(nowMilli()) schema.UpdatedBy = s.CurrentUser().UserName s.Schemas[fullName] = schema } } - return Response{Body: catalog.UpdatePermissionsResponse{PrivilegeAssignments: assignments}} + return Response{Body: grants.UpdatePermissionsResponse{PrivilegeAssignments: assignments}} } func (s *FakeWorkspace) GrantsGet(_ Request, securableType, fullName string) Response { @@ -146,5 +147,5 @@ func (s *FakeWorkspace) GrantsGet(_ Request, securableType, fullName string) Res key := grantsKey(securableType, fullName) assignments := s.Grants[key] - return Response{Body: catalog.GetPermissionsResponse{PrivilegeAssignments: assignments}} + return Response{Body: grants.GetPermissionsResponse{PrivilegeAssignments: assignments}} } diff --git a/libs/testserver/groups.go b/libs/testserver/groups.go index 5074708657e..4e96331aaaf 100644 --- a/libs/testserver/groups.go +++ b/libs/testserver/groups.go @@ -5,7 +5,9 @@ import ( "fmt" "strconv" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/utils" + + iam "github.com/databricks/cli/libs/sdktypes/scim/v1" ) func (s *FakeWorkspace) GroupsCreate(req Request) Response { @@ -23,7 +25,7 @@ func (s *FakeWorkspace) GroupsCreate(req Request) Response { groupId := strconv.FormatInt(nextID(), 10) group := iam.Group{ - Id: groupId, + Id: utils.NonZero(groupId), DisplayName: request.DisplayName, } diff --git a/libs/testserver/handlers.go b/libs/testserver/handlers.go index 04455a6be76..ca064b42ad0 100644 --- a/libs/testserver/handlers.go +++ b/libs/testserver/handlers.go @@ -13,21 +13,26 @@ import ( "strconv" "strings" + alerts "github.com/databricks/cli/libs/sdktypes/alerts/v2" + clusters "github.com/databricks/cli/libs/sdktypes/clusters/v2" + instancepools "github.com/databricks/cli/libs/sdktypes/instancepools/v2" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + uccredentials "github.com/databricks/cli/libs/sdktypes/uc/credentials/v1" + metastores "github.com/databricks/cli/libs/sdktypes/uc/metastores/v1" + tables "github.com/databricks/cli/libs/sdktypes/uc/tables/v1" + "github.com/databricks/cli/libs/utils" + workspaceapi "github.com/databricks/cli/libs/workspaceapi" + "github.com/databricks/cli/libs/notebook" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/sql" - "github.com/databricks/databricks-sdk-go/service/workspace" ) // TestWorkspaceID is the id of the fake workspace. const TestWorkspaceID = 900800700600 -var TestMetastore = catalog.MetastoreAssignment{ - DefaultCatalogName: "hive_metastore", - MetastoreId: "120efa64-9b68-46ba-be38-f319458430d2", - WorkspaceId: TestWorkspaceID, +var TestMetastore = metastores.MetastoreAssignment{ + DefaultCatalogName: utils.NonZero("hive_metastore"), + MetastoreId: utils.NonZero("120efa64-9b68-46ba-be38-f319458430d2"), + WorkspaceId: utils.NonZero[int64](TestWorkspaceID), } // Extensions that format=AUTO maps to workspace asset types /workspace/import @@ -71,15 +76,15 @@ func autoImportUnsupported(filePath string) (Response, bool) { func workspaceImport(w *FakeWorkspace, form ImportForm) Response { var resp Response switch form.Format { - case string(workspace.ImportFormatRaw): + case string(workspaceapi.ImportFormatRaw): resp = w.WorkspaceImportRawFile(form.Path, form.Content, form.Overwrite) - case string(workspace.ImportFormatSource): - resp = w.WorkspaceImportNotebook(form.Path, form.Content, workspace.Language(form.Language), form.Overwrite) - case string(workspace.ImportFormatJupyter): + case string(workspaceapi.ImportFormatSource): + resp = w.WorkspaceImportNotebook(form.Path, form.Content, workspaceapi.Language(form.Language), form.Overwrite) + case string(workspaceapi.ImportFormatJupyter): // The real endpoint reads the language from the notebook metadata. _, language, _ := notebook.DetectBytes(form.Path+notebook.ExtensionJupyter, form.Content) resp = w.WorkspaceImportNotebook(form.Path, form.Content, language, form.Overwrite) - case string(workspace.ImportFormatAuto): + case string(workspaceapi.ImportFormatAuto): if strings.HasSuffix(strings.ToLower(form.Path), ".zip") { return w.WorkspaceImportZipFolder(form.Path, form.Content, form.Overwrite) } @@ -172,15 +177,15 @@ func AddDefaultHandlers(server *Server) { }) server.Handle("GET", "/api/2.0/instance-pools/list", func(req Request) any { - return compute.ListInstancePools{ - InstancePools: []compute.InstancePoolAndStats{ + return instancepools.ListInstancePoolsResponse{ + InstancePools: []instancepools.InstancePoolAndStats{ { - InstancePoolName: "DEFAULT Test Instance Pool", - InstancePoolId: TestDefaultInstancePoolId, + InstancePoolName: utils.NonZero("DEFAULT Test Instance Pool"), + InstancePoolId: utils.NonZero(TestDefaultInstancePoolId), }, { - InstancePoolName: "some-test-instance-pool", - InstancePoolId: "1234", + InstancePoolName: utils.NonZero("some-test-instance-pool"), + InstancePoolId: utils.NonZero("1234"), }, }, } @@ -200,15 +205,17 @@ func AddDefaultHandlers(server *Server) { }) server.Handle("GET", "/api/2.1/clusters/list", func(req Request) any { - return compute.ListClustersResponse{ - Clusters: []compute.ClusterDetails{ + return clusters.ListClustersResponse{ + Clusters: []clusters.ClusterInfo{ { - ClusterName: "some-test-cluster", - ClusterId: "4321", + ClusterName: utils.NonZero("some-test-cluster"), + ClusterId: utils.NonZero("4321"), + State: clusters.ClusterState_ClusterState_Running, }, { - ClusterName: "some-other-cluster", - ClusterId: "9876", + ClusterName: utils.NonZero("some-other-cluster"), + ClusterId: utils.NonZero("9876"), + State: clusters.ClusterState_ClusterState_Running, }, }, } @@ -233,7 +240,7 @@ func AddDefaultHandlers(server *Server) { }) server.Handle("POST", "/api/2.0/workspace/mkdirs", func(req Request) any { - var request workspace.Mkdirs + var request workspaceapi.Mkdirs if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -266,14 +273,14 @@ func AddDefaultHandlers(server *Server) { } return Response{ - Body: workspace.ExportResponse{ + Body: workspaceapi.ExportResponse{ Content: base64.StdEncoding.EncodeToString(data), }, } }) server.Handle("POST", "/api/2.0/workspace/delete", func(req Request) any { - var request workspace.Delete + var request workspaceapi.Delete if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -290,8 +297,8 @@ func AddDefaultHandlers(server *Server) { }) server.Handle("POST", "/api/2.0/workspace/import", func(req Request) any { - // /workspace/import accepts both a JSON body (matching workspace.Import) and a - // multipart form body. The multipart variant is what databricks-sdk-go's + // /workspace/import accepts both a JSON body (matching workspaceapi.Import) and a + // multipart form body. The multipart variant is what libs/workspaceapi's // Workspace.Upload uses; the JSON variant is kept for back-compat with anything // that still hits Workspace.Import directly. mediaType, _, _ := mime.ParseMediaType(req.Headers.Get("Content-Type")) @@ -316,7 +323,7 @@ func AddDefaultHandlers(server *Server) { return workspaceImport(req.Workspace, form) } - var request workspace.Import + var request workspaceapi.Import err := json.Unmarshal(req.Body, &request) if err != nil { return Response{ @@ -339,7 +346,7 @@ func AddDefaultHandlers(server *Server) { // and treats empty as SOURCE (see cmd/workspace/workspace/overrides.go). format := string(request.Format) if format == "" { - format = string(workspace.ImportFormatSource) + format = string(workspaceapi.ImportFormatSource) } return workspaceImport(req.Workspace, ImportForm{ Path: request.Path, @@ -402,7 +409,7 @@ func AddDefaultHandlers(server *Server) { // Create directory and all parent directories. for dir := dirPath; dir != "/" && dir != ""; dir = path.Dir(dir) { if _, exists := req.Workspace.directories[dir]; !exists { - req.Workspace.directories[dir] = workspace.ObjectInfo{ + req.Workspace.directories[dir] = workspaceapi.ObjectInfo{ ObjectType: "DIRECTORY", Path: dir, ObjectId: nextTreenodeID(), @@ -441,9 +448,9 @@ func AddDefaultHandlers(server *Server) { }) server.Handle("GET", "/api/2.1/unity-catalog/metastore_summary", func(req Request) any { - return catalog.GetMetastoreSummaryResponse{ + return metastores.GetMetastoreSummaryResponse{ MetastoreId: TestMetastore.MetastoreId, - Region: "us-west-2", + Region: utils.NonZero("us-west-2"), } }) @@ -484,14 +491,14 @@ func AddDefaultHandlers(server *Server) { }) server.Handle("POST", "/api/2.2/jobs/delete", func(req Request) any { - var request jobs.DeleteJob + var request jobs.DeleteJobRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, Body: fmt.Sprintf("request parsing error: %s", err), } } - return req.Workspace.JobsDelete(req, request.JobId) + return req.Workspace.JobsDelete(req, utils.Deref(request.JobId)) }) server.Handle("POST", "/api/2.2/jobs/reset", func(req Request) any { @@ -639,11 +646,11 @@ func AddDefaultHandlers(server *Server) { return Response{StatusCode: 400, Body: "Invalid table name"} } return Response{ - Body: catalog.TableInfo{ - CatalogName: parts[0], - SchemaName: parts[1], - Name: parts[2], - FullName: req.Vars["full_name"], + Body: tables.TableInfo{ + CatalogName: utils.NonZero(parts[0]), + SchemaName: utils.NonZero(parts[1]), + Name: utils.NonZero(parts[2]), + FullName: utils.NonZero(req.Vars["full_name"]), }, } }) @@ -773,12 +780,12 @@ func AddDefaultHandlers(server *Server) { // Storage Credentials: server.Handle("GET", "/api/2.1/unity-catalog/storage-credentials", func(req Request) any { - return catalog.ListStorageCredentialsResponse{ - StorageCredentials: []catalog.StorageCredentialInfo{ + return uccredentials.ListStorageCredentialsResponse{ + StorageCredentials: []uccredentials.StorageCredentialInfo{ { - Name: "some-test-credential", - Id: "1234", - MetastoreId: "abcd", + Name: utils.NonZero("some-test-credential"), + Id: utils.NonZero("1234"), + MetastoreId: utils.NonZero("abcd"), }, }, } @@ -892,7 +899,7 @@ func AddDefaultHandlers(server *Server) { server.Handle("GET", "/api/2.0/repos/snapshots/rootpath", func(req Request) any { return map[string]any{ - "path": "/Workspace/Users/" + TestUserSP.UserName + "/.snapshots/", + "path": "/Workspace/Users/" + utils.Deref(TestUserSP.UserName) + "/.snapshots/", } }) @@ -927,8 +934,8 @@ func AddDefaultHandlers(server *Server) { // The real API uses the workspace user UUID (not email) in the snapshot path, // matching service-principal identities used in cloud acceptance tests. - snapshotPath := fmt.Sprintf("/Workspace/Users/%s/.snapshots/%s/%s", TestUserSP.UserName, bundleID, snapshotID) - req.Workspace.WorkspaceMkdirs(workspace.Mkdirs{Path: snapshotPath}) + snapshotPath := fmt.Sprintf("/Workspace/Users/%s/.snapshots/%s/%s", utils.Deref(TestUserSP.UserName), bundleID, snapshotID) + req.Workspace.WorkspaceMkdirs(workspaceapi.Mkdirs{Path: snapshotPath}) return map[string]any{ "snapshot": map[string]any{ "path": snapshotPath, @@ -988,7 +995,7 @@ func AddDefaultHandlers(server *Server) { id := req.Vars["id"] value, ok := req.Workspace.Alerts[id] - if !ok || value.LifecycleState == sql.AlertLifecycleStateDeleted { + if !ok || value.LifecycleState == alerts.AlertLifecycleState_Deleted { return Response{ StatusCode: 404, Body: map[string]string{"message": "Alert with ID '" + id + "' does not exist."}, diff --git a/libs/testserver/instance_pools.go b/libs/testserver/instance_pools.go index f6279fbfc3f..850728d8e99 100644 --- a/libs/testserver/instance_pools.go +++ b/libs/testserver/instance_pools.go @@ -4,13 +4,14 @@ import ( "encoding/json" "fmt" - "github.com/databricks/databricks-sdk-go/service/compute" + instancepools "github.com/databricks/cli/libs/sdktypes/instancepools/v2" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) InstancePoolsCreate(req Request) any { // Unmarshal into the stored (GET) type directly: CreateInstancePool and // GetInstancePool share JSON field names, so every config field is carried over. - var pool compute.GetInstancePool + var pool instancepools.GetInstancePoolResponse if err := json.Unmarshal(req.Body, &pool); err != nil { return Response{StatusCode: 400, Body: fmt.Sprintf("request parsing error: %s", err)} } @@ -18,10 +19,10 @@ func (s *FakeWorkspace) InstancePoolsCreate(req Request) any { defer s.LockUnlock()() id := nextUUID() - pool.InstancePoolId = id + pool.InstancePoolId = utils.NonZero(id) s.InstancePools[id] = pool - return Response{Body: compute.CreateInstancePoolResponse{InstancePoolId: id}} + return Response{Body: instancepools.CreateInstancePoolResponse{InstancePoolId: utils.NonZero(id)}} } func (s *FakeWorkspace) InstancePoolsGet(req Request, instancePoolId string) any { @@ -36,14 +37,14 @@ func (s *FakeWorkspace) InstancePoolsGet(req Request, instancePoolId string) any } func (s *FakeWorkspace) InstancePoolsEdit(req Request) any { - var request compute.EditInstancePool + var request instancepools.EditInstancePoolRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{StatusCode: 400, Body: fmt.Sprintf("request parsing error: %s", err)} } defer s.LockUnlock()() - pool, ok := s.InstancePools[request.InstancePoolId] + pool, ok := s.InstancePools[utils.Deref(request.InstancePoolId)] if !ok { return Response{StatusCode: 404} } @@ -58,24 +59,24 @@ func (s *FakeWorkspace) InstancePoolsEdit(req Request) any { pool.CustomTags = request.CustomTags pool.RemoteDiskThroughput = request.RemoteDiskThroughput pool.TotalInitialRemoteDiskSize = request.TotalInitialRemoteDiskSize - s.InstancePools[request.InstancePoolId] = pool + s.InstancePools[utils.Deref(request.InstancePoolId)] = pool return Response{} } func (s *FakeWorkspace) InstancePoolsDelete(req Request) any { - var request compute.DeleteInstancePool + var request instancepools.DeleteInstancePoolRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{StatusCode: 400, Body: fmt.Sprintf("request parsing error: %s", err)} } defer s.LockUnlock()() - if _, ok := s.InstancePools[request.InstancePoolId]; !ok { + if _, ok := s.InstancePools[utils.Deref(request.InstancePoolId)]; !ok { return Response{StatusCode: 404} } - delete(s.InstancePools, request.InstancePoolId) + delete(s.InstancePools, utils.Deref(request.InstancePoolId)) return Response{} } diff --git a/libs/testserver/jobs.go b/libs/testserver/jobs.go index 7fd1c359211..6e0859928d6 100644 --- a/libs/testserver/jobs.go +++ b/libs/testserver/jobs.go @@ -14,10 +14,12 @@ import ( "strconv" "strings" + clusterlibraries "github.com/databricks/cli/libs/sdktypes/clusterlibraries/v2" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" + workspaceapi "github.com/databricks/cli/libs/workspaceapi" + "github.com/databricks/cli/libs/patchwheel" - "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/databricks/databricks-sdk-go/service/workspace" ) const missingJobGitProviderMessage = "git_source.git_provider must be one of: github,gitlab,bitbucketcloud,gitlabenterpriseedition,bitbucketserver,azuredevopsservices,githubenterprise,awscodecommit" @@ -64,7 +66,7 @@ func venvPython(venvDir string) string { // validateJobGitSource mirrors Jobs API validation for git_source requests. func validateJobGitSource(gitSource *jobs.GitSource) *Response { - if gitSource == nil || gitSource.GitProvider != "" { + if gitSource == nil || utils.Deref(gitSource.GitProvider) != "" { return nil } @@ -83,12 +85,12 @@ func validateJobGitSource(gitSource *jobs.GitSource) *Response { // when source == GIT is set explicitly (it does not infer it from the job's // git_source), so a bare repo-relative python_file is rejected unless the // task's source is GIT. -func validateSparkPythonTasks(tasks []jobs.Task) *Response { +func validateSparkPythonTasks(tasks []jobs.TaskSettings) *Response { for _, task := range tasks { if response := validateSparkPythonTask(task.SparkPythonTask); response != nil { return response } - if task.ForEachTask != nil { + if task.ForEachTask != nil && task.ForEachTask.Task != nil { if response := validateSparkPythonTask(task.ForEachTask.Task.SparkPythonTask); response != nil { return response } @@ -98,14 +100,14 @@ func validateSparkPythonTasks(tasks []jobs.Task) *Response { } func validateSparkPythonTask(task *jobs.SparkPythonTask) *Response { - if task == nil || task.Source == jobs.SourceGit || !isRelativePythonFile(task.PythonFile) { + if task == nil || task.Source == jobs.Source_Git || !isRelativePythonFile(utils.Deref(task.PythonFile)) { return nil } return &Response{ StatusCode: 400, Body: map[string]string{ "error_code": "INVALID_PARAMETER_VALUE", - "message": fmt.Sprintf("Invalid python file reference: %s. Please visit the Databricks user guide for supported python references", task.PythonFile), + "message": fmt.Sprintf("Invalid python file reference: %s. Please visit the Databricks user guide for supported python references", utils.Deref(task.PythonFile)), }, } } @@ -125,7 +127,7 @@ func isRelativePythonFile(path string) bool { } func (s *FakeWorkspace) JobsCreate(req Request) Response { - var request jobs.CreateJob + var request jobs.CreateJobRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, @@ -165,24 +167,27 @@ func (s *FakeWorkspace) JobsCreate(req Request) Response { // CreatorUserName field is used by TF to check if the resource exists or not. CreatorUserName should be non-empty for the resource to be considered as "exists" // https://github.com/databricks/terraform-provider-databricks/blob/main/permissions/permission_definitions.go#L108 creator := userForToken(req.Token).UserName - s.Jobs[jobId] = jobs.Job{ - JobId: jobId, + s.Jobs[jobId] = jobs.GetJobResponse{ + JobId: utils.NonZero(jobId), Settings: &jobSettings, CreatorUserName: creator, RunAsUserName: creator, - CreatedTime: nowMilli(), + CreatedTime: utils.NonZero(nowMilli()), } - return Response{Body: jobs.CreateResponse{JobId: jobId}} + return Response{Body: jobs.CreateJobResponse{JobId: utils.NonZero(jobId)}} } func (s *FakeWorkspace) JobsReset(req Request) Response { - var request jobs.ResetJob + var request jobs.ResetJobRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, Body: fmt.Sprintf("request parsing error: %s", err), } } + if request.NewSettings == nil { + request.NewSettings = &jobs.JobSettings{} + } if response := validateJobGitSource(request.NewSettings.GitSource); response != nil { return *response } @@ -192,7 +197,7 @@ func (s *FakeWorkspace) JobsReset(req Request) Response { defer s.LockUnlock()() - if msg := s.applyJobClusterPolicies(&request.NewSettings); msg != "" { + if msg := s.applyJobClusterPolicies(request.NewSettings); msg != "" { return Response{ StatusCode: 400, Body: map[string]string{ @@ -201,10 +206,10 @@ func (s *FakeWorkspace) JobsReset(req Request) Response { }, } } - jobFixUps(&request.NewSettings) + jobFixUps(request.NewSettings) jobId := request.JobId - prevjob, ok := s.Jobs[jobId] + prevjob, ok := s.Jobs[utils.Deref(jobId)] if !ok { return Response{StatusCode: 403, Body: "{}"} } @@ -217,12 +222,12 @@ func (s *FakeWorkspace) JobsReset(req Request) Response { request.NewSettings.RunAs = prevjob.Settings.RunAs } - s.Jobs[jobId] = jobs.Job{ + s.Jobs[utils.Deref(jobId)] = jobs.GetJobResponse{ JobId: jobId, CreatorUserName: prevjob.CreatorUserName, RunAsUserName: prevjob.RunAsUserName, CreatedTime: prevjob.CreatedTime, - Settings: &request.NewSettings, + Settings: request.NewSettings, } return Response{Body: ""} } @@ -236,7 +241,8 @@ func jobFixUps(jobSettings *jobs.JobSettings) { jobSettings.WebhookNotifications = &jobs.WebhookNotifications{} } - jobSettings.ForceSendFields = append(jobSettings.ForceSendFields, "TimeoutSeconds") + // timeout_seconds is always reported, 0 by default. + jobSettings.TimeoutSeconds = new(utils.Deref(jobSettings.TimeoutSeconds)) // The real Jobs API accepts trigger.table_update.condition on create/update but // does not return it in GET responses; clear it so testserver matches cloud. @@ -251,46 +257,39 @@ func jobFixUps(jobSettings *jobs.JobSettings) { // Sort depends_on by task_key to simulate the real API which returns // dependencies in a different order than submitted. slices.SortFunc(task.DependsOn, func(a, b jobs.TaskDependency) int { - return cmp.Compare(a.TaskKey, b.TaskKey) + return cmp.Compare(utils.Deref(a.TaskKey), utils.Deref(b.TaskKey)) }) // Set task email notifications to empty struct if not set if task.EmailNotifications == nil { - task.EmailNotifications = &jobs.TaskEmailNotifications{} + task.EmailNotifications = &jobs.JobEmailNotifications{} } // Set RunIf to ALL_SUCCESS (server-side default) if task.RunIf == "" { - task.RunIf = jobs.RunIfAllSuccess - task.ForceSendFields = append(task.ForceSendFields, "RunIf") + task.RunIf = jobs.TaskDependencyType_AllSuccess } // Set TimeoutSeconds to 0 (server-side default) - task.ForceSendFields = append(task.ForceSendFields, "TimeoutSeconds") + task.TimeoutSeconds = new(utils.Deref(task.TimeoutSeconds)) // Add AWS-specific cluster defaults if new_cluster is present if task.NewCluster != nil { // Set AWS attributes with server-side defaults if task.NewCluster.AwsAttributes == nil { - task.NewCluster.AwsAttributes = &compute.AwsAttributes{ - Availability: compute.AwsAvailabilitySpotWithFallback, - ZoneId: "us-east-1c", + task.NewCluster.AwsAttributes = &jobs.AwsAttributes{ + Availability: jobs.AwsAvailability_SpotWithFallback, + ZoneId: new("us-east-1c"), } - task.NewCluster.AwsAttributes.ForceSendFields = append( - task.NewCluster.AwsAttributes.ForceSendFields, - "Availability", - "ZoneId", - ) } // Set data security mode to SINGLE_USER (server-side default) if task.NewCluster.DataSecurityMode == "" { - task.NewCluster.DataSecurityMode = compute.DataSecurityModeSingleUser - task.NewCluster.ForceSendFields = append(task.NewCluster.ForceSendFields, "DataSecurityMode") + task.NewCluster.DataSecurityMode = jobs.DataSecurityMode_SingleUser } // Set enable_elastic_disk to false (server-side default) - task.NewCluster.ForceSendFields = append(task.NewCluster.ForceSendFields, "EnableElasticDisk") + task.NewCluster.EnableElasticDisk = new(utils.Deref(task.NewCluster.EnableElasticDisk)) // The real Jobs API consumes apply_policy_default_values but does not // return it in GET responses; clear it so testserver matches cloud. @@ -298,7 +297,7 @@ func jobFixUps(jobSettings *jobs.JobSettings) { } // Handle for_each_task inner cluster. - if task.ForEachTask != nil && task.ForEachTask.Task.NewCluster != nil { + if task.ForEachTask != nil && task.ForEachTask.Task != nil && task.ForEachTask.Task.NewCluster != nil { // Same as above: not returned in GET responses. clearApplyPolicyDefaultValues(task.ForEachTask.Task.NewCluster) } @@ -311,15 +310,12 @@ func jobFixUps(jobSettings *jobs.JobSettings) { } } -// clearApplyPolicyDefaultValues drops apply_policy_default_values from a job's cluster spec. -// Zeroing the value alone is not enough: decoding the request populates ForceSendFields from -// the keys it carried, so a request that set the flag would still serialize it as an explicit -// false instead of omitting it the way the Jobs API does. -func clearApplyPolicyDefaultValues(spec *compute.ClusterSpec) { - spec.ApplyPolicyDefaultValues = false - spec.ForceSendFields = slices.DeleteFunc(spec.ForceSendFields, func(field string) bool { - return field == "ApplyPolicyDefaultValues" - }) +// clearApplyPolicyDefaultValues drops apply_policy_default_values from a job's cluster spec, +// which the Jobs API omits from GET responses. +func clearApplyPolicyDefaultValues(spec *jobs.ClusterSpec_NewCluster) { + if spec != nil { + spec.ApplyPolicyDefaultValues = nil + } } // jobsGetTasksPageSize matches the real Databricks API limit of 100 tasks per jobs.get response. @@ -340,8 +336,8 @@ func (s *FakeWorkspace) JobsGet(req Request) Response { // The backend checks permissions before existence, so a guest without access // gets a permission error rather than a 404, even after the job is deleted. - if isGuestToken(req.Token) && !s.guestHasJobAccess(jobIdInt, userForToken(req.Token).UserName) { - return jobReadPermissionDenied(userForToken(req.Token).UserName, jobIdInt) + if isGuestToken(req.Token) && !s.guestHasJobAccess(jobIdInt, utils.Deref(userForToken(req.Token).UserName)) { + return jobReadPermissionDenied(utils.Deref(userForToken(req.Token).UserName), jobIdInt) } job, ok := s.Jobs[jobIdInt] @@ -377,8 +373,8 @@ func (s *FakeWorkspace) JobsGet(req Request) Response { job.Settings.Tasks = tasks[offset:end] if end < len(tasks) { - job.HasMore = true - job.NextPageToken = strconv.Itoa(end) + job.HasMore = utils.NonZero(true) + job.NextPageToken = utils.NonZero(strconv.Itoa(end)) } // On subsequent pages the real API returns empty arrays for properties @@ -398,8 +394,8 @@ func (s *FakeWorkspace) JobsGet(req Request) Response { func (s *FakeWorkspace) JobsDelete(req Request, jobId int64) Response { defer s.LockUnlock()() - if isGuestToken(req.Token) && !s.guestHasJobAccess(jobId, userForToken(req.Token).UserName) { - return jobDeletePermissionDenied(userForToken(req.Token).UserName, jobId) + if isGuestToken(req.Token) && !s.guestHasJobAccess(jobId, utils.Deref(userForToken(req.Token).UserName)) { + return jobDeletePermissionDenied(utils.Deref(userForToken(req.Token).UserName), jobId) } if _, ok := s.Jobs[jobId]; !ok { @@ -448,7 +444,7 @@ func (s *FakeWorkspace) JobsList() Response { list = append(list, baseJob) } - slices.SortFunc(list, func(a, b jobs.BaseJob) int { return cmp.Compare(a.JobId, b.JobId) }) + slices.SortFunc(list, func(a, b jobs.BaseJob) int { return cmp.Compare(utils.Deref(a.JobId), utils.Deref(b.JobId)) }) return Response{Body: jobs.ListJobsResponse{Jobs: list}} } @@ -456,21 +452,25 @@ func (s *FakeWorkspace) JobsList() Response { // mirroring the Jobs service, which installs task libraries via the Libraries API when a run starts. // Cluster-status then reports them, matching cloud (where they are cluster-wide, so other jobs and // interactive sessions see them too). Callers must hold the workspace lock. -func (s *FakeWorkspace) installTaskLibrariesOnCluster(task jobs.Task) { - if task.ExistingClusterId == "" || len(task.Libraries) == 0 { +func (s *FakeWorkspace) installTaskLibrariesOnCluster(task jobs.TaskSettings) { + if utils.Deref(task.ExistingClusterId) == "" || len(task.Libraries) == 0 { return } - installed := s.ClusterLibraries[task.ExistingClusterId] - for _, lib := range task.Libraries { + installed := s.ClusterLibraries[utils.Deref(task.ExistingClusterId)] + for _, jobLib := range task.Libraries { + var lib clusterlibraries.Library + if err := jsonConvert(jobLib, &lib); err != nil { + continue + } if !containsLibrary(installed, lib) { installed = append(installed, lib) } } - s.ClusterLibraries[task.ExistingClusterId] = installed + s.ClusterLibraries[utils.Deref(task.ExistingClusterId)] = installed } func (s *FakeWorkspace) JobsRunNow(req Request) Response { - var request jobs.RunNow + var request jobs.RunNowRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, @@ -480,22 +480,22 @@ func (s *FakeWorkspace) JobsRunNow(req Request) Response { defer s.LockUnlock()() - job, ok := s.Jobs[request.JobId] + job, ok := s.Jobs[utils.Deref(request.JobId)] if !ok { return Response{StatusCode: 404} } // A resent request with the same non-empty token returns the run that token started. - if request.IdempotencyToken != "" { - if runId, ok := s.JobRunIdempotency[request.IdempotencyToken]; ok { - return Response{Body: jobs.RunNowResponse{RunId: runId}} + if utils.Deref(request.IdempotencyToken) != "" { + if runId, ok := s.JobRunIdempotency[utils.Deref(request.IdempotencyToken)]; ok { + return Response{Body: jobs.RunNowResponse{RunId: utils.NonZero(runId)}} } } runId := nextID() runName := "run-name" - if job.Settings != nil && job.Settings.Name != "" { - runName = job.Settings.Name + if job.Settings != nil && utils.Deref(job.Settings.Name) != "" { + runName = utils.Deref(job.Settings.Name) } // Build task list with individual RunIds, mirroring cloud behavior. @@ -509,11 +509,11 @@ func (s *FakeWorkspace) JobsRunNow(req Request) Response { taskRunId := nextID() taskRun := jobs.RunTask{ - RunId: taskRunId, + RunId: utils.NonZero(taskRunId), TaskKey: t.TaskKey, State: &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateSuccess, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Success, }, } tasks = append(tasks, taskRun) @@ -538,74 +538,74 @@ func (s *FakeWorkspace) JobsRunNow(req Request) Response { case errors.Is(err, errNoCodeInWorkspace): // Nothing ran, so the task keeps its SUCCESS state. case err != nil: - taskRun.State.ResultState = jobs.RunResultStateFailed - taskRun.State.StateMessage = taskFailureMessage - runOutput := jobs.RunOutput{Error: err.Error()} + taskRun.State.ResultState = jobs.RunResultState_RunResultState_Failed + taskRun.State.StateMessage = utils.NonZero(taskFailureMessage) + runOutput := jobs.GetRunOutputResponse{Error: utils.NonZero(err.Error())} // A task this server could not even start (e.g. uv failed) has no // traceback to report. if failure, ok := errors.AsType[*taskFailure](err); ok { - runOutput.ErrorTrace = failure.trace + runOutput.ErrorTrace = utils.NonZero(failure.trace) } s.JobRunOutputs[taskRunId] = runOutput case logs != "": - s.JobRunOutputs[taskRunId] = jobs.RunOutput{ - Logs: logs, + s.JobRunOutputs[taskRunId] = jobs.GetRunOutputResponse{ + Logs: utils.NonZero(logs), } } } } s.JobRuns[runId] = jobs.Run{ - RunId: runId, + RunId: utils.NonZero(runId), JobId: request.JobId, - State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning}, - RunPageUrl: fmt.Sprintf("%s/?o=%d#job/%d/run/%d", s.url, TestWorkspaceID, request.JobId, runId), - RunType: jobs.RunTypeJobRun, - RunName: runName, + State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running}, + RunPageUrl: utils.NonZero(fmt.Sprintf("%s/?o=%d#job/%d/run/%d", s.url, TestWorkspaceID, utils.Deref(request.JobId), runId)), + RunType: jobs.RunType_JobRun, + RunName: utils.NonZero(runName), Tasks: tasks, JobParameters: runJobParameters(job.Settings, request.JobParameters), OverridingParameters: runOverridingParameters(request), } - if request.IdempotencyToken != "" { - s.JobRunIdempotency[request.IdempotencyToken] = runId + if utils.Deref(request.IdempotencyToken) != "" { + s.JobRunIdempotency[utils.Deref(request.IdempotencyToken)] = runId } - return Response{Body: jobs.RunNowResponse{RunId: runId}} + return Response{Body: jobs.RunNowResponse{RunId: utils.NonZero(runId)}} } // runJobParameters mirrors how GetRun resolves job-level parameters: every // parameter the job defines, with the run's overrides applied on top, sorted by // name for deterministic output. -func runJobParameters(settings *jobs.JobSettings, overrides map[string]string) []jobs.JobParameter { - resolved := map[string]jobs.JobParameter{} +func runJobParameters(settings *jobs.JobSettings, overrides map[string]string) []jobs.Run_JobLevelParameters { + resolved := map[string]jobs.Run_JobLevelParameters{} if settings != nil { for _, p := range settings.Parameters { - resolved[p.Name] = jobs.JobParameter{Name: p.Name, Default: p.Default, Value: p.Default} + resolved[utils.Deref(p.Name)] = jobs.Run_JobLevelParameters{Name: p.Name, Default: p.Default, Value: p.Default} } } for name, value := range overrides { p := resolved[name] - p.Name = name - p.Value = value + p.Name = utils.NonZero(name) + p.Value = utils.NonZero(value) resolved[name] = p } if len(resolved) == 0 { return nil } - result := make([]jobs.JobParameter, 0, len(resolved)) + result := make([]jobs.Run_JobLevelParameters, 0, len(resolved)) for _, p := range resolved { result = append(result, p) } - slices.SortFunc(result, func(a, b jobs.JobParameter) int { - return cmp.Compare(a.Name, b.Name) + slices.SortFunc(result, func(a, b jobs.Run_JobLevelParameters) int { + return cmp.Compare(utils.Deref(a.Name), utils.Deref(b.Name)) }) return result } // runOverridingParameters mirrors how GetRun echoes the run's overriding // parameters. Returns nil when the request set none. -func runOverridingParameters(request jobs.RunNow) *jobs.RunParameters { +func runOverridingParameters(request jobs.RunNowRequest) *jobs.RunParameters { p := jobs.RunParameters{ DbtCommands: request.DbtCommands, JarParams: request.JarParams, @@ -634,7 +634,7 @@ func runOverridingParameters(request jobs.RunNow) *jobs.RunParameters { // bootstrap submits a notebook task that only exists in the workspace, and the // value of this handler for tests is the recorded request, not task output. func (s *FakeWorkspace) JobsSubmit(req Request) Response { - var request jobs.SubmitRun + var request jobs.SubmitRunRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, @@ -650,7 +650,7 @@ func (s *FakeWorkspace) JobsSubmit(req Request) Response { runId := nextID() // The default run name for one-time runs is "Untitled" (Jobs API behavior). - runName := cmp.Or(request.RunName, "Untitled") + runName := cmp.Or(request.RunName, utils.NonZero("Untitled")) // Report each task as RUNNING in both the V1 (state) and V2 (status) shapes. // The generic `jobs submit` waiter polls the V1 run-level state, which @@ -659,33 +659,33 @@ func (s *FakeWorkspace) JobsSubmit(req Request) Response { var tasks []jobs.RunTask for _, t := range request.Tasks { tasks = append(tasks, jobs.RunTask{ - RunId: nextID(), + RunId: utils.NonZero(nextID()), TaskKey: t.TaskKey, State: &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateRunning, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running, }, Status: &jobs.RunStatus{ - State: jobs.RunLifecycleStateV2StateRunning, + State: jobs.RunLifecycleStateV2_State_Running, }, }) } s.JobRuns[runId] = jobs.Run{ - RunId: runId, - State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning}, - RunPageUrl: fmt.Sprintf("%s/?o=%d#job/run/%d", s.url, TestWorkspaceID, runId), - RunType: jobs.RunTypeSubmitRun, + RunId: utils.NonZero(runId), + State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running}, + RunPageUrl: utils.NonZero(fmt.Sprintf("%s/?o=%d#job/run/%d", s.url, TestWorkspaceID, runId)), + RunType: jobs.RunType_SubmitRun, RunName: runName, Tasks: tasks, } // No tunnel server runs locally, so synthesize the metadata.json it would // publish; `ssh connect` polls for it before connecting. - if strings.HasPrefix(runName, sshTunnelBootstrapRunPrefix) { + if strings.HasPrefix(utils.Deref(runName), sshTunnelBootstrapRunPrefix) { s.writeSSHTunnelMetadata(request) } - return Response{Body: jobs.SubmitRunResponse{RunId: runId}} + return Response{Body: jobs.SubmitRunResponse{RunId: utils.NonZero(runId)}} } const ( @@ -698,12 +698,12 @@ const ( // writeSSHTunnelMetadata publishes the metadata.json a real tunnel server would // write next to the bootstrap notebook, and the host key it would publish to the // session's secret scope. Callers must hold the workspace lock. -func (s *FakeWorkspace) writeSSHTunnelMetadata(request jobs.SubmitRun) { +func (s *FakeWorkspace) writeSSHTunnelMetadata(request jobs.SubmitRunRequest) { for _, t := range request.Tasks { if t.NotebookTask == nil { continue } - metadataPath := strings.TrimSuffix(t.NotebookTask.NotebookPath, sshTunnelBootstrapNotebook) + "metadata.json" + metadataPath := strings.TrimSuffix(utils.Deref(t.NotebookTask.NotebookPath), sshTunnelBootstrapNotebook) + "metadata.json" metadata, err := json.Marshal(map[string]any{ "port": sshTunnelServerPort, "cluster_id": sshTunnelClusterID, @@ -712,7 +712,7 @@ func (s *FakeWorkspace) writeSSHTunnelMetadata(request jobs.SubmitRun) { continue } s.files[metadataPath] = FileEntry{ - Info: workspace.ObjectInfo{ObjectType: "FILE", Path: metadataPath}, + Info: workspaceapi.ObjectInfo{ObjectType: "FILE", Path: metadataPath}, Data: metadata, } s.publishSSHTunnelHostKey(t.NotebookTask.BaseParameters["secretScopeName"]) @@ -739,7 +739,7 @@ func (s *FakeWorkspace) publishSSHTunnelHostKey(scope string) { // For tasks using existing_cluster_id, the venv is cached per cluster to match // cloud behavior where libraries are cached on running clusters. // For serverless tasks (environment_key), dependencies are loaded from the environment spec. -func (s *FakeWorkspace) executePythonWheelTask(jobSettings *jobs.JobSettings, task jobs.Task) (string, error) { +func (s *FakeWorkspace) executePythonWheelTask(jobSettings *jobs.JobSettings, task jobs.TaskSettings) (string, error) { env, cleanup, err := s.getOrCreateClusterEnv(task) if err != nil { return "", err @@ -753,14 +753,14 @@ func (s *FakeWorkspace) executePythonWheelTask(jobSettings *jobs.JobSettings, ta if len(task.Libraries) > 0 { // Cluster-based task with libraries for _, lib := range task.Libraries { - if lib.Whl != "" { - whlPaths = append(whlPaths, lib.Whl) + if utils.Deref(lib.Whl) != "" { + whlPaths = append(whlPaths, utils.Deref(lib.Whl)) } } - } else if task.EnvironmentKey != "" && jobSettings != nil { + } else if utils.Deref(task.EnvironmentKey) != "" && jobSettings != nil { // Serverless task with environment_key for _, envItem := range jobSettings.Environments { - if envItem.EnvironmentKey == task.EnvironmentKey && envItem.Spec != nil { + if utils.Deref(envItem.EnvironmentKey) == utils.Deref(task.EnvironmentKey) && envItem.Spec != nil { whlPaths = append(whlPaths, envItem.Spec.Dependencies...) break } @@ -806,7 +806,7 @@ func (s *FakeWorkspace) executePythonWheelTask(jobSettings *jobs.JobSettings, ta // Run the entry point using runpy with sys.argv[0] set to the package name, // matching Databricks cloud behavior. wt := task.PythonWheelTask - script := fmt.Sprintf("import sys; sys.argv[0] = %q; from runpy import run_module; run_module(%q, run_name='__main__')", wt.PackageName, wt.PackageName) + script := fmt.Sprintf("import sys; sys.argv[0] = %q; from runpy import run_module; run_module(%q, run_name='__main__')", utils.Deref(wt.PackageName), utils.Deref(wt.PackageName)) runArgs := []string{"-c", script} runArgs = append(runArgs, wt.Parameters...) @@ -829,24 +829,24 @@ func (s *FakeWorkspace) executePythonWheelTask(jobSettings *jobs.JobSettings, ta // executeNotebookTask executes a notebook task by running the notebook as a Python script. // The wrapper feature transforms python_wheel_task into notebook_task that calls the wheel. -func (s *FakeWorkspace) executeNotebookTask(task jobs.Task, notebookParams map[string]string) (string, error) { +func (s *FakeWorkspace) executeNotebookTask(task jobs.TaskSettings, notebookParams map[string]string) (string, error) { if task.NotebookTask == nil { return "", errors.New("task has no notebook_task") } // Read notebook file from workspace (lock already held by caller) notebookPath := task.NotebookTask.NotebookPath - if !strings.HasPrefix(notebookPath, "/") { - notebookPath = "/" + notebookPath + if !strings.HasPrefix(utils.Deref(notebookPath), "/") { + notebookPath = utils.NonZero("/" + utils.Deref(notebookPath)) } // Try both with and without .py extension (notebooks are stored with .py but referenced without) - notebookData := s.files[notebookPath].Data + notebookData := s.files[utils.Deref(notebookPath)].Data if len(notebookData) == 0 { - notebookData = s.files[notebookPath+".py"].Data + notebookData = s.files[utils.Deref(notebookPath)+".py"].Data } if len(notebookData) == 0 { - return "", fmt.Errorf("%w: notebook not found in workspace: %s (also tried .py)", errNoCodeInWorkspace, notebookPath) + return "", fmt.Errorf("%w: notebook not found in workspace: %s (also tried .py)", errNoCodeInWorkspace, utils.Deref(notebookPath)) } // Create a temporary Python environment for notebook execution @@ -919,20 +919,20 @@ func (s *FakeWorkspace) executeNotebookTask(task jobs.Task, notebookParams map[s // python_file from the workspace and executing it in a uv-created venv. // For tasks using existing_cluster_id, the venv is cached per cluster to match // cloud behavior where libraries are cached on running clusters. -func (s *FakeWorkspace) executeSparkPythonTask(task jobs.Task) (string, error) { +func (s *FakeWorkspace) executeSparkPythonTask(task jobs.TaskSettings) (string, error) { if task.SparkPythonTask == nil { return "", errors.New("task has no spark_python_task") } // Read python file from workspace (lock already held by caller) pythonPath := task.SparkPythonTask.PythonFile - if !strings.HasPrefix(pythonPath, "/") { - pythonPath = "/" + pythonPath + if !strings.HasPrefix(utils.Deref(pythonPath), "/") { + pythonPath = utils.NonZero("/" + utils.Deref(pythonPath)) } - pythonData := s.files[pythonPath].Data + pythonData := s.files[utils.Deref(pythonPath)].Data if len(pythonData) == 0 { - return "", fmt.Errorf("%w: python file not found in workspace: %s", errNoCodeInWorkspace, pythonPath) + return "", fmt.Errorf("%w: python file not found in workspace: %s", errNoCodeInWorkspace, utils.Deref(pythonPath)) } env, cleanup, err := s.getOrCreateClusterEnv(task) @@ -944,7 +944,7 @@ func (s *FakeWorkspace) executeSparkPythonTask(task jobs.Task) (string, error) { } // Write python file into the cluster env so it can be executed by the venv. - pythonFile := filepath.Join(env.dir, filepath.Base(pythonPath)) + pythonFile := filepath.Join(env.dir, filepath.Base(utils.Deref(pythonPath))) if err := os.WriteFile(pythonFile, pythonData, 0o644); err != nil { return "", fmt.Errorf("failed to write python file: %w", err) } @@ -964,11 +964,11 @@ func (s *FakeWorkspace) executeSparkPythonTask(task jobs.Task) (string, error) { // getOrCreateClusterEnv returns a cached venv for existing clusters or creates // a fresh one for new clusters. The cleanup function is non-nil only for new // clusters (whose venvs should be removed after use). -func (s *FakeWorkspace) getOrCreateClusterEnv(task jobs.Task) (*clusterEnv, func(), error) { +func (s *FakeWorkspace) getOrCreateClusterEnv(task jobs.TaskSettings) (*clusterEnv, func(), error) { clusterID := task.ExistingClusterId - if clusterID != "" { - if env, ok := s.clusterVenvs[clusterID]; ok { + if utils.Deref(clusterID) != "" { + if env, ok := s.clusterVenvs[utils.Deref(clusterID)]; ok { return env, nil, nil } } @@ -994,8 +994,8 @@ func (s *FakeWorkspace) getOrCreateClusterEnv(task jobs.Task) (*clusterEnv, func } // Cache venv for existing clusters; use cleanup for new clusters. - if clusterID != "" { - s.clusterVenvs[clusterID] = env + if utils.Deref(clusterID) != "" { + s.clusterVenvs[utils.Deref(clusterID)] = env return env, nil, nil } @@ -1003,10 +1003,10 @@ func (s *FakeWorkspace) getOrCreateClusterEnv(task jobs.Task) (*clusterEnv, func } // sparkVersionToPython maps Databricks Runtime spark_version to Python version. -func sparkVersionToPython(task jobs.Task) string { +func sparkVersionToPython(task jobs.TaskSettings) string { sv := "" if task.NewCluster != nil { - sv = task.NewCluster.SparkVersion + sv = utils.Deref(task.NewCluster.SparkVersion) } // Extract major version from strings like "13.3.x-snapshot-scala2.12" or "15.4.x-scala2.12". @@ -1037,21 +1037,21 @@ func sparkVersionToPython(task jobs.Task) string { func terminateRun(run *jobs.Run) { for i := range run.Tasks { // Tasks that were never executed (jobs/runs/submit) are still running. - if run.Tasks[i].State.LifeCycleState != jobs.RunLifeCycleStateTerminated { - run.Tasks[i].State.LifeCycleState = jobs.RunLifeCycleStateTerminated - run.Tasks[i].State.ResultState = jobs.RunResultStateSuccess + if run.Tasks[i].State.LifeCycleState != jobs.RunLifeCycleState_RunLifeCycleState_Terminated { + run.Tasks[i].State.LifeCycleState = jobs.RunLifeCycleState_RunLifeCycleState_Terminated + run.Tasks[i].State.ResultState = jobs.RunResultState_RunResultState_Success } } run.State = &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateSuccess, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Success, } for _, task := range run.Tasks { - if task.State.ResultState != jobs.RunResultStateSuccess { - run.State.LifeCycleState = jobs.RunLifeCycleStateInternalError + if task.State.ResultState != jobs.RunResultState_RunResultState_Success { + run.State.LifeCycleState = jobs.RunLifeCycleState_RunLifeCycleState_InternalError run.State.ResultState = task.State.ResultState - run.State.StateMessage = fmt.Sprintf("Task %s failed with message: %s.", task.TaskKey, taskFailureMessage) + run.State.StateMessage = utils.NonZero(fmt.Sprintf("Task %s failed with message: %s.", utils.Deref(task.TaskKey), taskFailureMessage)) return } } @@ -1075,7 +1075,7 @@ func (s *FakeWorkspace) JobsGetRun(req Request) Response { } // Simulate cloud behavior: first poll returns RUNNING, next the terminal state. - if run.State.LifeCycleState == jobs.RunLifeCycleStateRunning { + if run.State.LifeCycleState == jobs.RunLifeCycleState_RunLifeCycleState_Running { // Transition stored state to TERMINATED for the next poll. terminateRun(&run) s.JobRuns[runIdInt] = run @@ -1083,7 +1083,7 @@ func (s *FakeWorkspace) JobsGetRun(req Request) Response { // Return RUNNING for this poll (before the transition). runResp := run runResp.State = &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateRunning, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running, } return Response{Body: runResp} } @@ -1094,7 +1094,7 @@ func (s *FakeWorkspace) JobsGetRun(req Request) Response { // JobsCancelRun settles a run that is still going. The real API cancels // asynchronously; the caller polls runs/get either way. func (s *FakeWorkspace) JobsCancelRun(req Request) Response { - var request jobs.CancelRun + var request jobs.CancelRunRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, @@ -1104,32 +1104,32 @@ func (s *FakeWorkspace) JobsCancelRun(req Request) Response { defer s.LockUnlock()() - run, ok := s.JobRuns[request.RunId] + run, ok := s.JobRuns[utils.Deref(request.RunId)] if !ok { return Response{StatusCode: 404} } // A run that already finished keeps the outcome it reached. - if run.State.LifeCycleState == jobs.RunLifeCycleStateRunning { + if run.State.LifeCycleState == jobs.RunLifeCycleState_RunLifeCycleState_Running { run.State = &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, - ResultState: jobs.RunResultStateCanceled, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, + ResultState: jobs.RunResultState_RunResultState_Canceled, } - s.JobRuns[request.RunId] = run + s.JobRuns[utils.Deref(request.RunId)] = run } return Response{} } func (s *FakeWorkspace) JobsDeleteRun(req Request) Response { - var request jobs.DeleteRun + var request jobs.DeleteRunRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, Body: fmt.Sprintf("request parsing error: %s", err), } } - return MapDelete(s, s.JobRuns, request.RunId) + return MapDelete(s, s.JobRuns, utils.Deref(request.RunId)) } func (s *FakeWorkspace) JobsGetRunOutput(req Request) Response { @@ -1155,15 +1155,15 @@ func (s *FakeWorkspace) JobsGetRunOutput(req Request) Response { if ok && len(jobRun.Tasks) > 0 { // For single-task jobs, return the task's output taskRunId := jobRun.Tasks[0].RunId - if taskOutput, ok := s.JobRunOutputs[taskRunId]; ok { + if taskOutput, ok := s.JobRunOutputs[utils.Deref(taskRunId)]; ok { return Response{Body: taskOutput} } } - return Response{Body: jobs.RunOutput{}} + return Response{Body: jobs.GetRunOutputResponse{}} } -func setSourceIfNotSet(job jobs.Job) jobs.Job { +func setSourceIfNotSet(job jobs.GetJobResponse) jobs.GetJobResponse { if job.Settings != nil { source := "WORKSPACE" if job.Settings.GitSource != nil { diff --git a/libs/testserver/jobs_test.go b/libs/testserver/jobs_test.go index a5b04542deb..838666634e0 100644 --- a/libs/testserver/jobs_test.go +++ b/libs/testserver/jobs_test.go @@ -8,12 +8,13 @@ import ( "strings" "testing" - "github.com/databricks/databricks-sdk-go/service/jobs" + jobs "github.com/databricks/cli/libs/sdktypes/jobs/v2" + "github.com/databricks/cli/libs/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func submitRun(t *testing.T, workspace *FakeWorkspace, request jobs.SubmitRun) jobs.SubmitRunResponse { +func submitRun(t *testing.T, workspace *FakeWorkspace, request jobs.SubmitRunRequest) jobs.SubmitRunResponse { t.Helper() body, err := json.Marshal(request) require.NoError(t, err) @@ -41,76 +42,76 @@ func getRun(t *testing.T, workspace *FakeWorkspace, runID int64) jobs.Run { func TestJobsSubmit_RecordsRunAndReportsRunningTasks(t *testing.T) { workspace := NewFakeWorkspace("http://test", "dbapi123") - submitResponse := submitRun(t, workspace, jobs.SubmitRun{ - RunName: "ssh-tunnel", - Tasks: []jobs.SubmitTask{ - {TaskKey: "main", EnvironmentKey: "default"}, + submitResponse := submitRun(t, workspace, jobs.SubmitRunRequest{ + RunName: utils.NonZero("ssh-tunnel"), + Tasks: []jobs.RunTaskSettings{ + {TaskKey: utils.NonZero("main"), EnvironmentKey: utils.NonZero("default")}, }, }) require.NotZero(t, submitResponse.RunId) - run := getRun(t, workspace, submitResponse.RunId) - assert.Equal(t, "ssh-tunnel", run.RunName) - assert.Equal(t, jobs.RunTypeSubmitRun, run.RunType) + run := getRun(t, workspace, utils.Deref(submitResponse.RunId)) + assert.Equal(t, "ssh-tunnel", utils.Deref(run.RunName)) + assert.Equal(t, jobs.RunType_SubmitRun, run.RunType) require.Len(t, run.Tasks, 1) task := run.Tasks[0] - assert.Equal(t, "main", task.TaskKey) + assert.Equal(t, "main", utils.Deref(task.TaskKey)) // ssh connect's waitForJobToStart polls the V2 per-task status. require.NotNil(t, task.Status) - assert.Equal(t, jobs.RunLifecycleStateV2StateRunning, task.Status.State) + assert.Equal(t, jobs.RunLifecycleStateV2_State_Running, task.Status.State) } func TestJobsSubmit_DefaultsRunNameToUntitled(t *testing.T) { workspace := NewFakeWorkspace("http://test", "dbapi123") - submitResponse := submitRun(t, workspace, jobs.SubmitRun{ - Tasks: []jobs.SubmitTask{{TaskKey: "main"}}, + submitResponse := submitRun(t, workspace, jobs.SubmitRunRequest{ + Tasks: []jobs.RunTaskSettings{{TaskKey: utils.NonZero("main")}}, }) - run := getRun(t, workspace, submitResponse.RunId) - assert.Equal(t, "Untitled", run.RunName) + run := getRun(t, workspace, utils.Deref(submitResponse.RunId)) + assert.Equal(t, "Untitled", utils.Deref(run.RunName)) } func TestJobsSubmit_RunReachesTerminalStateOnPoll(t *testing.T) { workspace := NewFakeWorkspace("http://test", "dbapi123") - submitResponse := submitRun(t, workspace, jobs.SubmitRun{ - Tasks: []jobs.SubmitTask{{TaskKey: "main"}}, + submitResponse := submitRun(t, workspace, jobs.SubmitRunRequest{ + Tasks: []jobs.RunTaskSettings{{TaskKey: utils.NonZero("main")}}, }) // The generic `jobs submit` waiter polls the V1 run-level state: RUNNING first, // then TERMINATED/SUCCESS. - first := getRun(t, workspace, submitResponse.RunId) - assert.Equal(t, jobs.RunLifeCycleStateRunning, first.State.LifeCycleState) + first := getRun(t, workspace, utils.Deref(submitResponse.RunId)) + assert.Equal(t, jobs.RunLifeCycleState_RunLifeCycleState_Running, first.State.LifeCycleState) - second := getRun(t, workspace, submitResponse.RunId) - assert.Equal(t, jobs.RunLifeCycleStateTerminated, second.State.LifeCycleState) - assert.Equal(t, jobs.RunResultStateSuccess, second.State.ResultState) + second := getRun(t, workspace, utils.Deref(submitResponse.RunId)) + assert.Equal(t, jobs.RunLifeCycleState_RunLifeCycleState_Terminated, second.State.LifeCycleState) + assert.Equal(t, jobs.RunResultState_RunResultState_Success, second.State.ResultState) } -func createJob(t *testing.T, workspace *FakeWorkspace, tasks ...jobs.Task) int64 { +func createJob(t *testing.T, workspace *FakeWorkspace, tasks ...jobs.TaskSettings) int64 { t.Helper() - body, err := json.Marshal(jobs.CreateJob{Name: "my-job", Tasks: tasks}) + body, err := json.Marshal(jobs.CreateJobRequest{Name: utils.NonZero("my-job"), Tasks: tasks}) require.NoError(t, err) response := workspace.JobsCreate(Request{Body: body}) require.Equal(t, 0, response.StatusCode) - return response.Body.(jobs.CreateResponse).JobId + return utils.Deref(response.Body.(jobs.CreateJobResponse).JobId) } -func runNow(t *testing.T, workspace *FakeWorkspace, request jobs.RunNow) Response { +func runNow(t *testing.T, workspace *FakeWorkspace, request jobs.RunNowRequest) Response { t.Helper() body, err := json.Marshal(request) require.NoError(t, err) return workspace.JobsRunNow(Request{Body: body}) } -func terminatedTask(taskKey string, result jobs.RunResultState) jobs.RunTask { +func terminatedTask(taskKey string, result jobs.RunResultState_RunResultState) jobs.RunTask { return jobs.RunTask{ - TaskKey: taskKey, + TaskKey: utils.NonZero(taskKey), State: &jobs.RunState{ - LifeCycleState: jobs.RunLifeCycleStateTerminated, + LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Terminated, ResultState: result, }, } @@ -118,16 +119,16 @@ func terminatedTask(taskKey string, result jobs.RunResultState) jobs.RunTask { func TestTerminateRun_FailedTaskFailsTheRun(t *testing.T) { run := jobs.Run{Tasks: []jobs.RunTask{ - terminatedTask("first", jobs.RunResultStateSuccess), - terminatedTask("second", jobs.RunResultStateFailed), + terminatedTask("first", jobs.RunResultState_RunResultState_Success), + terminatedTask("second", jobs.RunResultState_RunResultState_Failed), }} terminateRun(&run) // A failed run reports INTERNAL_ERROR, not TERMINATED, in life_cycle_state. - assert.Equal(t, jobs.RunLifeCycleStateInternalError, run.State.LifeCycleState) - assert.Equal(t, jobs.RunResultStateFailed, run.State.ResultState) - assert.Equal(t, "Task second failed with message: Workload failed, see run output for details.", run.State.StateMessage) + assert.Equal(t, jobs.RunLifeCycleState_RunLifeCycleState_InternalError, run.State.LifeCycleState) + assert.Equal(t, jobs.RunResultState_RunResultState_Failed, run.State.ResultState) + assert.Equal(t, "Task second failed with message: Workload failed, see run output for details.", utils.Deref(run.State.StateMessage)) } func TestNewTaskFailure_ReportsTheExceptionAndTheTraceback(t *testing.T) { @@ -155,38 +156,38 @@ func TestNewTaskFailure_SilentFailureIsReportedAsTheExitError(t *testing.T) { func TestTerminateRun_CompletesTasksThatAreStillRunning(t *testing.T) { // jobs/runs/submit records its tasks as running: they are never executed. run := jobs.Run{Tasks: []jobs.RunTask{ - {TaskKey: "main", State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleStateRunning}}, + {TaskKey: utils.NonZero("main"), State: &jobs.RunState{LifeCycleState: jobs.RunLifeCycleState_RunLifeCycleState_Running}}, }} terminateRun(&run) - assert.Equal(t, jobs.RunResultStateSuccess, run.State.ResultState) - assert.Empty(t, run.State.StateMessage) - assert.Equal(t, jobs.RunResultStateSuccess, run.Tasks[0].State.ResultState) + assert.Equal(t, jobs.RunResultState_RunResultState_Success, run.State.ResultState) + assert.Empty(t, utils.Deref(run.State.StateMessage)) + assert.Equal(t, jobs.RunResultState_RunResultState_Success, run.Tasks[0].State.ResultState) } // See errNoCodeInWorkspace: a missing notebook is this server's gap, not a // failure of the job. func TestJobsGetRun_TaskWithoutCodeDoesNotFailTheRun(t *testing.T) { workspace := NewFakeWorkspace("http://test", "dbapi123") - jobID := createJob(t, workspace, jobs.Task{ - TaskKey: "main", - NotebookTask: &jobs.NotebookTask{NotebookPath: "/missing-notebook"}, + jobID := createJob(t, workspace, jobs.TaskSettings{ + TaskKey: utils.NonZero("main"), + NotebookTask: &jobs.NotebookTask{NotebookPath: utils.NonZero("/missing-notebook")}, }) - response := runNow(t, workspace, jobs.RunNow{JobId: jobID}) + response := runNow(t, workspace, jobs.RunNowRequest{JobId: utils.NonZero(jobID)}) require.Equal(t, 0, response.StatusCode) runID := response.Body.(jobs.RunNowResponse).RunId // The first poll reports RUNNING, the second the terminal state. - require.Equal(t, jobs.RunLifeCycleStateRunning, getRun(t, workspace, runID).State.LifeCycleState) - assert.Equal(t, jobs.RunResultStateSuccess, getRun(t, workspace, runID).State.ResultState) + require.Equal(t, jobs.RunLifeCycleState_RunLifeCycleState_Running, getRun(t, workspace, utils.Deref(runID)).State.LifeCycleState) + assert.Equal(t, jobs.RunResultState_RunResultState_Success, getRun(t, workspace, utils.Deref(runID)).State.ResultState) } func TestJobsRunNow_RepeatedTokenReturnsTheSameRun(t *testing.T) { workspace := NewFakeWorkspace("http://test", "dbapi123") - jobID := createJob(t, workspace, jobs.Task{TaskKey: "main"}) - request := jobs.RunNow{JobId: jobID, IdempotencyToken: "token"} + jobID := createJob(t, workspace, jobs.TaskSettings{TaskKey: utils.NonZero("main")}) + request := jobs.RunNowRequest{JobId: utils.NonZero(jobID), IdempotencyToken: utils.NonZero("token")} first := runNow(t, workspace, request).Body.(jobs.RunNowResponse).RunId second := runNow(t, workspace, request).Body.(jobs.RunNowResponse).RunId @@ -198,10 +199,10 @@ func TestJobsRunNow_RepeatedTokenReturnsTheSameRun(t *testing.T) { // Requests without a token are never deduped (`bundle run`, `jobs run-now`). func TestJobsRunNow_WithoutATokenIsNeverDeduped(t *testing.T) { workspace := NewFakeWorkspace("http://test", "dbapi123") - jobID := createJob(t, workspace, jobs.Task{TaskKey: "main"}) + jobID := createJob(t, workspace, jobs.TaskSettings{TaskKey: utils.NonZero("main")}) - first := runNow(t, workspace, jobs.RunNow{JobId: jobID}).Body.(jobs.RunNowResponse).RunId - second := runNow(t, workspace, jobs.RunNow{JobId: jobID}).Body.(jobs.RunNowResponse).RunId + first := runNow(t, workspace, jobs.RunNowRequest{JobId: utils.NonZero(jobID)}).Body.(jobs.RunNowResponse).RunId + second := runNow(t, workspace, jobs.RunNowRequest{JobId: utils.NonZero(jobID)}).Body.(jobs.RunNowResponse).RunId assert.NotEqual(t, first, second) assert.Len(t, workspace.JobRuns, 2) @@ -211,46 +212,46 @@ func TestJobsRunNow_WithoutATokenIsNeverDeduped(t *testing.T) { // deleting it, since jobs/runs/delete rejects an active run. func TestJobsCancelRun_SettlesAnActiveRun(t *testing.T) { workspace := NewFakeWorkspace("http://test", "dbapi123") - jobID := createJob(t, workspace, jobs.Task{ - TaskKey: "main", - NotebookTask: &jobs.NotebookTask{NotebookPath: "/missing-notebook"}, + jobID := createJob(t, workspace, jobs.TaskSettings{ + TaskKey: utils.NonZero("main"), + NotebookTask: &jobs.NotebookTask{NotebookPath: utils.NonZero("/missing-notebook")}, }) - runID := runNow(t, workspace, jobs.RunNow{JobId: jobID}).Body.(jobs.RunNowResponse).RunId + runID := runNow(t, workspace, jobs.RunNowRequest{JobId: utils.NonZero(jobID)}).Body.(jobs.RunNowResponse).RunId - body, err := json.Marshal(jobs.CancelRun{RunId: runID}) + body, err := json.Marshal(jobs.CancelRunRequest{RunId: runID}) require.NoError(t, err) require.Equal(t, 0, workspace.JobsCancelRun(Request{Body: body}).StatusCode) - run := getRun(t, workspace, runID) - assert.Equal(t, jobs.RunLifeCycleStateTerminated, run.State.LifeCycleState) - assert.Equal(t, jobs.RunResultStateCanceled, run.State.ResultState) + run := getRun(t, workspace, utils.Deref(runID)) + assert.Equal(t, jobs.RunLifeCycleState_RunLifeCycleState_Terminated, run.State.LifeCycleState) + assert.Equal(t, jobs.RunResultState_RunResultState_Canceled, run.State.ResultState) } func TestJobsCancelRun_LeavesAFinishedRunAlone(t *testing.T) { workspace := NewFakeWorkspace("http://test", "dbapi123") - jobID := createJob(t, workspace, jobs.Task{ - TaskKey: "main", - NotebookTask: &jobs.NotebookTask{NotebookPath: "/missing-notebook"}, + jobID := createJob(t, workspace, jobs.TaskSettings{ + TaskKey: utils.NonZero("main"), + NotebookTask: &jobs.NotebookTask{NotebookPath: utils.NonZero("/missing-notebook")}, }) - runID := runNow(t, workspace, jobs.RunNow{JobId: jobID}).Body.(jobs.RunNowResponse).RunId + runID := runNow(t, workspace, jobs.RunNowRequest{JobId: utils.NonZero(jobID)}).Body.(jobs.RunNowResponse).RunId // The first poll settles the run, the way a completed deploy leaves it. - getRun(t, workspace, runID) - require.Equal(t, jobs.RunResultStateSuccess, getRun(t, workspace, runID).State.ResultState) + getRun(t, workspace, utils.Deref(runID)) + require.Equal(t, jobs.RunResultState_RunResultState_Success, getRun(t, workspace, utils.Deref(runID)).State.ResultState) - body, err := json.Marshal(jobs.CancelRun{RunId: runID}) + body, err := json.Marshal(jobs.CancelRunRequest{RunId: runID}) require.NoError(t, err) require.Equal(t, 0, workspace.JobsCancelRun(Request{Body: body}).StatusCode) - assert.Equal(t, jobs.RunResultStateSuccess, getRun(t, workspace, runID).State.ResultState) + assert.Equal(t, jobs.RunResultState_RunResultState_Success, getRun(t, workspace, utils.Deref(runID)).State.ResultState) } func TestJobsSubmit_RejectsInvalidGitProvider(t *testing.T) { workspace := NewFakeWorkspace("http://test", "dbapi123") - body, err := json.Marshal(jobs.SubmitRun{ - GitSource: &jobs.GitSource{GitUrl: "https://example.com/repo"}, - Tasks: []jobs.SubmitTask{{TaskKey: "main"}}, + body, err := json.Marshal(jobs.SubmitRunRequest{ + GitSource: &jobs.GitSource{GitUrl: utils.NonZero("https://example.com/repo")}, + Tasks: []jobs.RunTaskSettings{{TaskKey: utils.NonZero("main")}}, }) require.NoError(t, err) diff --git a/libs/testserver/libraries.go b/libs/testserver/libraries.go index 63042ca8e66..b8c381688db 100644 --- a/libs/testserver/libraries.go +++ b/libs/testserver/libraries.go @@ -6,49 +6,50 @@ import ( "net/http" "reflect" - "github.com/databricks/databricks-sdk-go/service/compute" + clusterlibraries "github.com/databricks/cli/libs/sdktypes/clusterlibraries/v2" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) LibrariesInstall(req Request) any { - var request compute.InstallLibraries + var request clusterlibraries.InstallLibrariesRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{StatusCode: http.StatusBadRequest, Body: fmt.Sprintf("request parsing error: %s", err)} } defer s.LockUnlock()() - if _, ok := s.Clusters[request.ClusterId]; !ok { + if _, ok := s.Clusters[utils.Deref(request.ClusterId)]; !ok { return Response{StatusCode: http.StatusNotFound} } // Install is additive and idempotent: installing an already-present library is a no-op. - installed := s.ClusterLibraries[request.ClusterId] + installed := s.ClusterLibraries[utils.Deref(request.ClusterId)] for _, lib := range request.Libraries { if !containsLibrary(installed, lib) { installed = append(installed, lib) } } - s.ClusterLibraries[request.ClusterId] = installed + s.ClusterLibraries[utils.Deref(request.ClusterId)] = installed return Response{} } func (s *FakeWorkspace) LibrariesUninstall(req Request) any { - var request compute.UninstallLibraries + var request clusterlibraries.UninstallLibrariesRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{StatusCode: http.StatusBadRequest, Body: fmt.Sprintf("request parsing error: %s", err)} } defer s.LockUnlock()() - installed := s.ClusterLibraries[request.ClusterId] - remaining := make([]compute.Library, 0, len(installed)) + installed := s.ClusterLibraries[utils.Deref(request.ClusterId)] + remaining := make([]clusterlibraries.Library, 0, len(installed)) for _, lib := range installed { if !containsLibrary(request.Libraries, lib) { remaining = append(remaining, lib) } } - s.ClusterLibraries[request.ClusterId] = remaining + s.ClusterLibraries[utils.Deref(request.ClusterId)] = remaining return Response{} } @@ -61,23 +62,23 @@ func (s *FakeWorkspace) LibrariesClusterStatus(req Request, clusterId string) an } installed := s.ClusterLibraries[clusterId] - statuses := make([]compute.LibraryFullStatus, 0, len(installed)) + statuses := make([]clusterlibraries.LibraryFullStatus, 0, len(installed)) for i := range installed { - statuses = append(statuses, compute.LibraryFullStatus{ + statuses = append(statuses, clusterlibraries.LibraryFullStatus{ Library: &installed[i], - Status: compute.LibraryInstallStatusInstalled, + Status: clusterlibraries.LibraryInstallStatus_Installed, }) } return Response{ - Body: compute.ClusterLibraryStatuses{ - ClusterId: clusterId, + Body: clusterlibraries.ClusterLibraryStatuses{ + ClusterId: utils.NonZero(clusterId), LibraryStatuses: statuses, }, } } -func containsLibrary(libs []compute.Library, target compute.Library) bool { +func containsLibrary(libs []clusterlibraries.Library, target clusterlibraries.Library) bool { for _, l := range libs { if reflect.DeepEqual(l, target) { return true diff --git a/libs/testserver/mcp_services.go b/libs/testserver/mcp_services.go index 41200d06951..bdf8939c9d9 100644 --- a/libs/testserver/mcp_services.go +++ b/libs/testserver/mcp_services.go @@ -6,7 +6,8 @@ import ( "net/http" "strings" - "github.com/databricks/databricks-sdk-go/service/catalog" + aigateway "github.com/databricks/cli/libs/sdktypes/aigateway/v1" + "github.com/databricks/cli/libs/utils" ) // McpServicesCreate fakes POST /api/2.1/unity-catalog/mcp-services. See @@ -16,7 +17,7 @@ import ( func (s *FakeWorkspace) McpServicesCreate(req Request) Response { defer s.LockUnlock()() - var ms catalog.McpService + var ms aigateway.McpService if err := json.Unmarshal(req.Body, &ms); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -27,11 +28,11 @@ func (s *FakeWorkspace) McpServicesCreate(req Request) Response { schema := strings.TrimPrefix(req.URL.Query().Get("parent"), "schemas/") key := schema + "." + req.URL.Query().Get("mcp_service_id") - ms.Name = "mcp-services/" + key + ms.Name = utils.NonZero("mcp-services/" + key) ms.CreatedBy = s.CurrentUser().UserName ms.UpdatedBy = s.CurrentUser().UserName ms.EffectiveOwner = s.CurrentUser().UserName - ms.MetastoreId = nextUUID() + ms.MetastoreId = utils.NonZero(nextUUID()) s.McpServices[key] = ms return Response{ @@ -50,7 +51,7 @@ func (s *FakeWorkspace) McpServicesUpdate(req Request, name string) Response { } } - var incoming catalog.McpService + var incoming aigateway.McpService if err := json.Unmarshal(req.Body, &incoming); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), diff --git a/libs/testserver/model_provider_services.go b/libs/testserver/model_provider_services.go index 622bf75888c..a5f356ed9f8 100644 --- a/libs/testserver/model_provider_services.go +++ b/libs/testserver/model_provider_services.go @@ -6,7 +6,8 @@ import ( "net/http" "strings" - "github.com/databricks/databricks-sdk-go/service/catalog" + aigateway "github.com/databricks/cli/libs/sdktypes/aigateway/v1" + "github.com/databricks/cli/libs/utils" ) // ModelProviderServicesCreate fakes POST @@ -17,7 +18,7 @@ import ( func (s *FakeWorkspace) ModelProviderServicesCreate(req Request) Response { defer s.LockUnlock()() - var ms catalog.ModelProviderService + var ms aigateway.ModelProviderService if err := json.Unmarshal(req.Body, &ms); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -28,11 +29,11 @@ func (s *FakeWorkspace) ModelProviderServicesCreate(req Request) Response { schema := strings.TrimPrefix(req.URL.Query().Get("parent"), "schemas/") key := schema + "." + req.URL.Query().Get("model_provider_service_id") - ms.Name = "model-provider-services/" + key + ms.Name = utils.NonZero("model-provider-services/" + key) ms.CreatedBy = s.CurrentUser().UserName ms.UpdatedBy = s.CurrentUser().UserName ms.EffectiveOwner = s.CurrentUser().UserName - ms.MetastoreId = nextUUID() + ms.MetastoreId = utils.NonZero(nextUUID()) s.ModelProviderServices[key] = ms return Response{ @@ -51,7 +52,7 @@ func (s *FakeWorkspace) ModelProviderServicesUpdate(req Request, name string) Re } } - var incoming catalog.ModelProviderService + var incoming aigateway.ModelProviderService if err := json.Unmarshal(req.Body, &incoming); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), diff --git a/libs/testserver/model_services.go b/libs/testserver/model_services.go index ce653543ac5..bdd5d3b0223 100644 --- a/libs/testserver/model_services.go +++ b/libs/testserver/model_services.go @@ -6,7 +6,8 @@ import ( "net/http" "strings" - "github.com/databricks/databricks-sdk-go/service/catalog" + aigateway "github.com/databricks/cli/libs/sdktypes/aigateway/v1" + "github.com/databricks/cli/libs/utils" ) // ModelServicesCreate fakes POST /api/2.1/unity-catalog/model-services. @@ -22,7 +23,7 @@ func (s *FakeWorkspace) ModelServicesCreate(req Request) Response { // The SDK sends the ModelService body directly (not wrapped in // "model_service"); parent and model_service_id are query parameters. - var ms catalog.ModelService + var ms aigateway.ModelService if err := json.Unmarshal(req.Body, &ms); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -33,11 +34,11 @@ func (s *FakeWorkspace) ModelServicesCreate(req Request) Response { schema := strings.TrimPrefix(req.URL.Query().Get("parent"), "schemas/") key := schema + "." + req.URL.Query().Get("model_service_id") - ms.Name = "model-services/" + key + ms.Name = utils.NonZero("model-services/" + key) ms.CreatedBy = s.CurrentUser().UserName ms.UpdatedBy = s.CurrentUser().UserName ms.EffectiveOwner = s.CurrentUser().UserName - ms.MetastoreId = nextUUID() + ms.MetastoreId = utils.NonZero(nextUUID()) s.ModelServices[key] = ms return Response{ @@ -57,7 +58,7 @@ func (s *FakeWorkspace) ModelServicesUpdate(req Request, name string) Response { } // The SDK sends the ModelService body directly; update_mask is a query param. - var incoming catalog.ModelService + var incoming aigateway.ModelService if err := json.Unmarshal(req.Body, &incoming); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), diff --git a/libs/testserver/models.go b/libs/testserver/models.go index 3314327d8a7..1e60175bad1 100644 --- a/libs/testserver/models.go +++ b/libs/testserver/models.go @@ -5,13 +5,14 @@ import ( "fmt" "strconv" - "github.com/databricks/databricks-sdk-go/service/ml" + modelregistry "github.com/databricks/cli/libs/sdktypes/modelregistry/v1" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) ModelRegistryCreateModel(req Request) any { defer s.LockUnlock()() - var request ml.CreateModelRequest + var request modelregistry.CreateRegisteredModelRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, @@ -21,7 +22,7 @@ func (s *FakeWorkspace) ModelRegistryCreateModel(req Request) any { // MLflow rejects an empty name; the fake would otherwise store a model under a key // nothing can look up. - if request.Name == "" { + if utils.Deref(request.Name) == "" { return Response{ StatusCode: 400, Body: map[string]string{ @@ -33,17 +34,17 @@ func (s *FakeWorkspace) ModelRegistryCreateModel(req Request) any { // Create the model with a numeric ID (matching real API behavior) modelId := strconv.FormatInt(nextID(), 10) - model := ml.Model{ + model := modelregistry.RegisteredModel{ Name: request.Name, Description: request.Description, Tags: request.Tags, } - s.ModelRegistryModels[request.Name] = model - s.ModelRegistryModelIDs[request.Name] = modelId + s.ModelRegistryModels[utils.Deref(request.Name)] = model + s.ModelRegistryModelIDs[utils.Deref(request.Name)] = modelId return Response{ - Body: ml.CreateModelResponse{ + Body: modelregistry.CreateRegisteredModelResponse{ RegisteredModel: &model, }, } @@ -52,7 +53,7 @@ func (s *FakeWorkspace) ModelRegistryCreateModel(req Request) any { func (s *FakeWorkspace) ModelRegistryUpdateModel(req Request) any { defer s.LockUnlock()() - var request ml.UpdateModelRequest + var request modelregistry.UpdateRegisteredModelRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ StatusCode: 400, @@ -60,7 +61,7 @@ func (s *FakeWorkspace) ModelRegistryUpdateModel(req Request) any { } } - existingModel, ok := s.ModelRegistryModels[request.Name] + existingModel, ok := s.ModelRegistryModels[utils.Deref(request.Name)] if !ok { return Response{ StatusCode: 404, @@ -70,10 +71,10 @@ func (s *FakeWorkspace) ModelRegistryUpdateModel(req Request) any { // Update the model existingModel.Description = request.Description - s.ModelRegistryModels[request.Name] = existingModel + s.ModelRegistryModels[utils.Deref(request.Name)] = existingModel return Response{ - Body: ml.UpdateModelResponse{ + Body: modelregistry.UpdateRegisteredModelResponse{ RegisteredModel: &existingModel, }, } @@ -93,13 +94,12 @@ func (s *FakeWorkspace) ModelRegistryGetModel(req Request) any { } return Response{ - Body: ml.GetModelResponse{ - RegisteredModelDatabricks: &ml.ModelDatabricks{ - Id: s.ModelRegistryModelIDs[name], - Name: model.Name, - Description: model.Description, - Tags: model.Tags, - ForceSendFields: model.ForceSendFields, + Body: modelregistry.GetRegisteredModelDatabricksResponse{ + RegisteredModelDatabricks: &modelregistry.RegisteredModelDatabricks{ + Id: utils.NonZero(s.ModelRegistryModelIDs[name]), + Name: model.Name, + Description: model.Description, + Tags: model.Tags, }, }, } diff --git a/libs/testserver/models_test.go b/libs/testserver/models_test.go index e72d4930133..e5b0b12cf3c 100644 --- a/libs/testserver/models_test.go +++ b/libs/testserver/models_test.go @@ -4,7 +4,8 @@ import ( "net/url" "testing" - "github.com/databricks/databricks-sdk-go/service/ml" + modelregistry "github.com/databricks/cli/libs/sdktypes/modelregistry/v1" + "github.com/databricks/cli/libs/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -41,8 +42,8 @@ func TestModelRegistryCreateModel_AllowsNonEmptyName(t *testing.T) { require.True(t, ok) require.Equal(t, 0, getResponse.StatusCode) - body, ok := getResponse.Body.(ml.GetModelResponse) + body, ok := getResponse.Body.(modelregistry.GetRegisteredModelDatabricksResponse) require.True(t, ok) - assert.Equal(t, "my_model", body.RegisteredModelDatabricks.Name) - assert.NotEmpty(t, body.RegisteredModelDatabricks.Id) + assert.Equal(t, "my_model", utils.Deref(body.RegisteredModelDatabricks.Name)) + assert.NotEmpty(t, utils.Deref(body.RegisteredModelDatabricks.Id)) } diff --git a/libs/testserver/permissions.go b/libs/testserver/permissions.go index a3584c1d49a..c1503f6ab5a 100644 --- a/libs/testserver/permissions.go +++ b/libs/testserver/permissions.go @@ -7,7 +7,9 @@ import ( "strconv" "strings" - "github.com/databricks/databricks-sdk-go/service/iam" + "github.com/databricks/cli/libs/utils" + + iam "github.com/databricks/cli/libs/sdktypes/accessmanagement/v1" ) // source: https://github.com/databricks/terraform-provider-databricks/blob/main/permissions/permission_definitions.go @@ -42,12 +44,12 @@ var requestObjectTypeToObjectType = map[string]string{ // aclPrincipalKey returns a unique key identifying the principal in an ACL entry. func aclPrincipalKey(acl iam.AccessControlResponse) string { switch { - case acl.UserName != "": - return "user:" + acl.UserName - case acl.GroupName != "": - return "group:" + acl.GroupName - case acl.ServicePrincipalName != "": - return "sp:" + acl.ServicePrincipalName + case utils.Deref(acl.UserName) != "": + return "user:" + *acl.UserName + case utils.Deref(acl.GroupName) != "": + return "group:" + *acl.GroupName + case utils.Deref(acl.ServicePrincipalName) != "": + return "sp:" + *acl.ServicePrincipalName default: return "" } @@ -55,7 +57,7 @@ func aclPrincipalKey(acl iam.AccessControlResponse) string { // upsertACL adds or replaces an ACL entry by principal key. // Entries with no principal key are ignored. -func upsertACL(perms *iam.ObjectPermissions, entry iam.AccessControlResponse) { +func upsertACL(perms *iam.PermissionsResponse, entry iam.AccessControlResponse) { key := aclPrincipalKey(entry) if key == "" { return @@ -80,14 +82,14 @@ func (s *FakeWorkspace) upsertPermission(objectKey string, entry iam.AccessContr // jobPrincipalHasAccess reports whether the principal has a direct ACL entry // (hasAccess) and whether the ACL names an explicit owner (hasOwner). hasOwner // lets callers grant the creator implicit access only until ownership moves. -func jobPrincipalHasAccess(perms iam.ObjectPermissions, principal string) (hasAccess, hasOwner bool) { +func jobPrincipalHasAccess(perms iam.PermissionsResponse, principal string) (hasAccess, hasOwner bool) { for _, acl := range perms.AccessControlList { for _, p := range acl.AllPermissions { if p.PermissionLevel == "IS_OWNER" { hasOwner = true } } - if len(acl.AllPermissions) > 0 && (acl.UserName == principal || acl.ServicePrincipalName == principal) { + if len(acl.AllPermissions) > 0 && (utils.Deref(acl.UserName) == principal || utils.Deref(acl.ServicePrincipalName) == principal) { hasAccess = true } } @@ -103,7 +105,7 @@ func (s *FakeWorkspace) guestHasJobAccess(jobId int64, principal string) bool { return true } if !hasOwner { - if job, ok := s.Jobs[jobId]; ok && job.CreatorUserName == principal { + if job, ok := s.Jobs[jobId]; ok && utils.Deref(job.CreatorUserName) == principal { return true } } @@ -124,8 +126,8 @@ func (s *FakeWorkspace) GetPermissions(req Request) any { // A guest without manage access cannot read a job's permissions, mirroring // the backend's pre-existence permission check. if requestObjectType == "jobs" && isGuestToken(req.Token) { - if jobId, err := strconv.ParseInt(objectId, 10, 64); err == nil && !s.guestHasJobAccess(jobId, userForToken(req.Token).UserName) { - return jobManagePermissionDenied(userForToken(req.Token).UserName, jobId) + if jobId, err := strconv.ParseInt(objectId, 10, 64); err == nil && !s.guestHasJobAccess(jobId, utils.Deref(userForToken(req.Token).UserName)) { + return jobManagePermissionDenied(utils.Deref(userForToken(req.Token).UserName), jobId) } } @@ -169,9 +171,9 @@ func (s *FakeWorkspace) GetPermissions(req Request) any { if !exists { // Return empty permissions structure if not found - permissions = iam.ObjectPermissions{ - ObjectId: responseObjectID, - ObjectType: objectType, + permissions = iam.PermissionsResponse{ + ObjectId: utils.NonZero(responseObjectID), + ObjectType: utils.NonZero(objectType), AccessControlList: []iam.AccessControlResponse{}, } } @@ -189,7 +191,7 @@ func (s *FakeWorkspace) permissionsParentExists(requestObjectType, objectId stri switch requestObjectType { case "vector-search-endpoints": for _, ep := range s.VectorSearchEndpoints { - if ep.Id == objectId { + if utils.Deref(ep.Id) == objectId { return true } } @@ -230,7 +232,7 @@ func (s *FakeWorkspace) SetPermissions(req Request) any { } } - var updateRequest iam.UpdateObjectPermissions + var updateRequest iam.UpdateObjectPermissionsRequest if err := json.Unmarshal(req.Body, &updateRequest); err != nil { return Response{ StatusCode: 400, @@ -259,9 +261,9 @@ func (s *FakeWorkspace) SetPermissions(req Request) any { // Get existing permissions or create new ones existingPermissions, exists := s.Permissions[responseObjectID] if !exists { - existingPermissions = iam.ObjectPermissions{ - ObjectId: responseObjectID, - ObjectType: objectType, + existingPermissions = iam.PermissionsResponse{ + ObjectId: utils.NonZero(responseObjectID), + ObjectType: utils.NonZero(objectType), AccessControlList: []iam.AccessControlResponse{}, } } @@ -270,7 +272,7 @@ func (s *FakeWorkspace) SetPermissions(req Request) any { existingPermissions.AccessControlList = nil for _, acl := range updateRequest.AccessControlList { display := acl.UserName - if display == "" { + if utils.Deref(display) == "" { display = acl.ServicePrincipalName } @@ -283,9 +285,8 @@ func (s *FakeWorkspace) SetPermissions(req Request) any { if acl.PermissionLevel != "" { response.AllPermissions = []iam.Permission{{ - Inherited: false, + Inherited: new(false), PermissionLevel: acl.PermissionLevel, - ForceSendFields: []string{"Inherited"}, }} } @@ -297,12 +298,12 @@ func (s *FakeWorkspace) SetPermissions(req Request) any { existingPermissions.AccessControlList = append(existingPermissions.AccessControlList, iam.AccessControlResponse{ AllPermissions: []iam.Permission{ { - Inherited: true, + Inherited: utils.NonZero(true), InheritedFromObject: []string{"/jobs/"}, PermissionLevel: "CAN_MANAGE", }, }, - GroupName: "admins", + GroupName: utils.NonZero("admins"), }) } @@ -311,22 +312,22 @@ func (s *FakeWorkspace) SetPermissions(req Request) any { existingPermissions.AccessControlList = append(existingPermissions.AccessControlList, iam.AccessControlResponse{ AllPermissions: []iam.Permission{ { - Inherited: true, + Inherited: utils.NonZero(true), InheritedFromObject: []string{"/directories/4454031293888593"}, PermissionLevel: "CAN_MANAGE", }, }, - UserName: "shreyas.goenka@databricks.com", - DisplayName: "shreyas.goenka@databricks.com", + UserName: utils.NonZero("shreyas.goenka@databricks.com"), + DisplayName: utils.NonZero("shreyas.goenka@databricks.com"), }, iam.AccessControlResponse{ AllPermissions: []iam.Permission{ { - Inherited: true, + Inherited: utils.NonZero(true), InheritedFromObject: []string{"/directories/"}, PermissionLevel: "CAN_MANAGE", }, }, - GroupName: "admins", + GroupName: utils.NonZero("admins"), }) } @@ -367,8 +368,8 @@ func (s *FakeWorkspace) SetPermissions(req Request) any { if owner := s.directoryHomeOwner(objectId); owner != "" { response.AccessControlList = slices.Clone(existingPermissions.AccessControlList) upsertACL(&response, iam.AccessControlResponse{ - UserName: owner, - AllPermissions: []iam.Permission{{PermissionLevel: "CAN_MANAGE", Inherited: true}}, + UserName: utils.NonZero(owner), + AllPermissions: []iam.Permission{{PermissionLevel: "CAN_MANAGE", Inherited: utils.NonZero(true)}}, }) } } diff --git a/libs/testserver/pipelines.go b/libs/testserver/pipelines.go index 0aedc44c5d3..479856d94e4 100644 --- a/libs/testserver/pipelines.go +++ b/libs/testserver/pipelines.go @@ -5,7 +5,8 @@ import ( "fmt" "strings" - "github.com/databricks/databricks-sdk-go/service/pipelines" + pipelines "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) PipelineGet(pipelineId string) Response { @@ -39,12 +40,12 @@ func (s *FakeWorkspace) PipelineCreate(req Request) Response { // dotted catalog.schema value is rejected; the catalog belongs in the separate // catalog field. Only the dot trips this check, but the backend's canned error // also lists dashes and other characters as invalid. - if strings.Contains(spec.Target, ".") { + if strings.Contains(utils.Deref(spec.Target), ".") { return Response{ StatusCode: 400, Body: map[string]string{ "error_code": "INVALID_PARAMETER_VALUE", - "message": fmt.Sprintf("CreatePipeline target_schema_name %q is not a valid name. Valid names must contain only alphanumeric characters and underscores, and cannot contain spaces, periods, forward slashes, or control characters.", spec.Target), + "message": fmt.Sprintf("CreatePipeline target_schema_name %q is not a valid name. Valid names must contain only alphanumeric characters and underscores, and cannot contain spaces, periods, forward slashes, or control characters.", utils.Deref(spec.Target)), }, } } @@ -55,7 +56,7 @@ func (s *FakeWorkspace) PipelineCreate(req Request) Response { // parameters is not on PipelineSpec (only on CreatePipeline), so the decode above // drops it. The backend echoes it on GetPipelineResponse.Parameters; mirror that // here, else a re-read misses it and the CLI plans a perpetual update. - var create pipelines.CreatePipeline + var create pipelines.CreatePipelineRequest if err := json.Unmarshal(req.Body, &create); err != nil { return Response{ Body: fmt.Sprintf("cannot unmarshal request body: %s", err), @@ -65,36 +66,36 @@ func (s *FakeWorkspace) PipelineCreate(req Request) Response { r.Parameters = create.Parameters pipelineId := nextUUID() - r.PipelineId = pipelineId - r.CreatorUserName = "tester@databricks.com" - r.LastModified = nowMilli() + r.PipelineId = utils.NonZero(pipelineId) + r.CreatorUserName = utils.NonZero("tester@databricks.com") + r.LastModified = utils.NonZero(nowMilli()) r.Name = r.Spec.Name // run_as is on CreatePipeline, not PipelineSpec, so the spec decode drops it. The backend // echoes it top-level on GetPipelineResponse.RunAs; mirror that so a re-read is faithful. if create.RunAs != nil { r.RunAs = create.RunAs } - r.RunAsUserName = "tester@databricks.com" + r.RunAsUserName = utils.NonZero("tester@databricks.com") r.State = "IDLE" - r.EffectivePublishingMode = pipelines.PublishingModeDefaultPublishingMode + r.EffectivePublishingMode = pipelines.PublishingMode_DefaultPublishingMode setSpecDefaults(&spec, pipelineId) s.Pipelines[pipelineId] = r return Response{ Body: pipelines.CreatePipelineResponse{ - PipelineId: pipelineId, + PipelineId: utils.NonZero(pipelineId), }, } } func setSpecDefaults(spec *pipelines.PipelineSpec, pipelineId string) { - spec.Id = pipelineId + spec.Id = utils.NonZero(pipelineId) // If the pipeline definition does not specify a catalog, it switches to Hive metastore mode // and if the storage location is not specified, API automatically generates a storage location // (ref: https://docs.databricks.com/gcp/en/dlt/hive-metastore#specify-a-storage-location) - if spec.Storage == "" && spec.Catalog == "" { - spec.Storage = "dbfs:/pipelines/" + pipelineId + if utils.Deref(spec.Storage) == "" && utils.Deref(spec.Catalog) == "" { + spec.Storage = utils.NonZero("dbfs:/pipelines/" + pipelineId) } } @@ -119,7 +120,7 @@ func (s *FakeWorkspace) PipelineUpdate(req Request, pipelineId string) Response // parameters is on EditPipeline, not PipelineSpec; round-trip it like // PipelineCreate does. - var edit pipelines.EditPipeline + var edit pipelines.EditPipelineRequest if err := json.Unmarshal(req.Body, &edit); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -159,7 +160,7 @@ func (s *FakeWorkspace) PipelineStartUpdate(pipelineId string) Response { return Response{ Body: pipelines.StartUpdateResponse{ - UpdateId: updateId, + UpdateId: utils.NonZero(updateId), }, } } @@ -205,8 +206,8 @@ func (s *FakeWorkspace) PipelineGetUpdate(pipelineId, updateId string) Response return Response{ Body: pipelines.GetUpdateResponse{ Update: &pipelines.UpdateInfo{ - UpdateId: updateId, - State: pipelines.UpdateInfoStateCompleted, + UpdateId: utils.NonZero(updateId), + State: pipelines.UpdateState_Completed, }, }, } @@ -225,8 +226,8 @@ func (s *FakeWorkspace) PipelineStop(pipelineId string) Response { return Response{ Body: pipelines.GetPipelineResponse{ - PipelineId: pipelineId, - State: pipelines.PipelineStateIdle, + PipelineId: utils.NonZero(pipelineId), + State: pipelines.PipelineState_PipelineState_Idle, }, } } diff --git a/libs/testserver/pipelines_test.go b/libs/testserver/pipelines_test.go index 39114714082..162afe5746d 100644 --- a/libs/testserver/pipelines_test.go +++ b/libs/testserver/pipelines_test.go @@ -3,7 +3,8 @@ package testserver import ( "testing" - "github.com/databricks/databricks-sdk-go/service/pipelines" + pipelines "github.com/databricks/cli/libs/sdktypes/pipelines/v2" + "github.com/databricks/cli/libs/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -22,7 +23,7 @@ func createTestPipeline(t *testing.T, workspace *FakeWorkspace) string { createPipelineResponse, ok := createResponse.Body.(pipelines.CreatePipelineResponse) require.True(t, ok) - return createPipelineResponse.PipelineId + return utils.Deref(createPipelineResponse.PipelineId) } func TestPipelineCreate_RejectsDottedTargetSchemaName(t *testing.T) { @@ -82,6 +83,6 @@ func TestPipelineStop_AfterUpdate(t *testing.T) { stopBody, ok := stopResponse.Body.(pipelines.GetPipelineResponse) require.True(t, ok) - assert.Equal(t, pipelineId, stopBody.PipelineId) - assert.Equal(t, pipelines.PipelineStateIdle, stopBody.State) + assert.Equal(t, pipelineId, utils.Deref(stopBody.PipelineId)) + assert.Equal(t, pipelines.PipelineState_PipelineState_Idle, stopBody.State) } diff --git a/libs/testserver/postgres.go b/libs/testserver/postgres.go index 2f59389aeb1..30aa4dcb497 100644 --- a/libs/testserver/postgres.go +++ b/libs/testserver/postgres.go @@ -10,13 +10,14 @@ import ( "strings" "time" - "github.com/databricks/databricks-sdk-go/common/types/duration" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/service/postgres" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" + + "github.com/databricks/sdk-go/core/types" ) -func nowTime() *sdktime.Time { - return sdktime.New(time.Now().UTC()) +func nowTime() *types.Time { + return types.NewFromTime(time.Now().UTC()) } // nextTraceID returns a 32-hex-character id shaped like the trace ids the real API puts @@ -117,9 +118,9 @@ func (s *FakeWorkspace) PostgresProjectCreate(req Request, projectID string) Res } now := nowTime() - project.Name = name - project.ProjectId = projectID - project.Uid = nextUUID() + project.Name = utils.NonZero(name) + project.ProjectId = utils.NonZero(projectID) + project.Uid = utils.NonZero(nextUUID()) project.CreateTime = now project.UpdateTime = now @@ -128,33 +129,32 @@ func (s *FakeWorkspace) PostgresProjectCreate(req Request, projectID string) Res // The backend materializes a default retention when the spec omits it. historyRetention := project.Spec.HistoryRetentionDuration if historyRetention == nil { - historyRetention = duration.New(defaultHistoryRetention) + historyRetention = types.NewFromDuration(defaultHistoryRetention) } project.Status = &postgres.ProjectStatus{ - ProjectId: projectID, - DefaultBranch: name + "/branches/production", + ProjectId: utils.NonZero(projectID), + DefaultBranch: utils.NonZero(name + "/branches/production"), DisplayName: project.Spec.DisplayName, PgVersion: project.Spec.PgVersion, HistoryRetentionDuration: historyRetention, - EnablePgNativeLogin: false, + EnablePgNativeLogin: new(false), Owner: TestUser.UserName, - BranchLogicalSizeLimitBytes: 8796093022208, // 8 TB (real API default) - SyntheticStorageSizeBytes: 0, - ForceSendFields: []string{"EnablePgNativeLogin", "SyntheticStorageSizeBytes"}, + BranchLogicalSizeLimitBytes: new(int64(8796093022208)), // 8 TB (real API default) + SyntheticStorageSizeBytes: new(int64(0)), } // The backend materializes default endpoint settings when the spec omits them. project.Status.DefaultEndpointSettings = &postgres.ProjectDefaultEndpointSettings{ - AutoscalingLimitMinCu: defaultAutoscalingLimitMinCu, - AutoscalingLimitMaxCu: defaultAutoscalingLimitMaxCu, - SuspendTimeoutDuration: duration.New(defaultSuspendTimeout), + AutoscalingLimitMinCu: utils.NonZero[float64](defaultAutoscalingLimitMinCu), + AutoscalingLimitMaxCu: utils.NonZero[float64](defaultAutoscalingLimitMaxCu), + SuspendTimeoutDuration: types.NewFromDuration(defaultSuspendTimeout), } if project.Spec.DefaultEndpointSettings != nil { - if project.Spec.DefaultEndpointSettings.AutoscalingLimitMinCu != 0 { + if utils.Deref(project.Spec.DefaultEndpointSettings.AutoscalingLimitMinCu) != 0 { project.Status.DefaultEndpointSettings.AutoscalingLimitMinCu = project.Spec.DefaultEndpointSettings.AutoscalingLimitMinCu } - if project.Spec.DefaultEndpointSettings.AutoscalingLimitMaxCu != 0 { + if utils.Deref(project.Spec.DefaultEndpointSettings.AutoscalingLimitMaxCu) != 0 { project.Status.DefaultEndpointSettings.AutoscalingLimitMaxCu = project.Spec.DefaultEndpointSettings.AutoscalingLimitMaxCu } if project.Spec.DefaultEndpointSettings.SuspendTimeoutDuration != nil { @@ -171,7 +171,7 @@ func (s *FakeWorkspace) PostgresProjectCreate(req Request, projectID string) Res s.createDefaultBranchLocked(name) return Response{ - Body: s.createOperationLocked(project.Name, project), + Body: s.createOperationLocked(utils.Deref(project.Name), project), } } @@ -233,7 +233,7 @@ func (s *FakeWorkspace) PostgresProjectUpdate(req Request, name string) Response if project.Status == nil { project.Status = &postgres.ProjectStatus{} } - if updateProject.Spec.DisplayName != "" { + if utils.Deref(updateProject.Spec.DisplayName) != "" { project.Status.DisplayName = updateProject.Spec.DisplayName } // Verified against a real workspace: dropping the field from config sends a @@ -246,10 +246,10 @@ func (s *FakeWorkspace) PostgresProjectUpdate(req Request, name string) Response if project.Status.DefaultEndpointSettings == nil { project.Status.DefaultEndpointSettings = &postgres.ProjectDefaultEndpointSettings{} } - if updateProject.Spec.DefaultEndpointSettings.AutoscalingLimitMinCu != 0 { + if utils.Deref(updateProject.Spec.DefaultEndpointSettings.AutoscalingLimitMinCu) != 0 { project.Status.DefaultEndpointSettings.AutoscalingLimitMinCu = updateProject.Spec.DefaultEndpointSettings.AutoscalingLimitMinCu } - if updateProject.Spec.DefaultEndpointSettings.AutoscalingLimitMaxCu != 0 { + if utils.Deref(updateProject.Spec.DefaultEndpointSettings.AutoscalingLimitMaxCu) != 0 { project.Status.DefaultEndpointSettings.AutoscalingLimitMaxCu = updateProject.Spec.DefaultEndpointSettings.AutoscalingLimitMaxCu } if updateProject.Spec.DefaultEndpointSettings.SuspendTimeoutDuration != nil { @@ -276,7 +276,7 @@ func (s *FakeWorkspace) PostgresProjectUpdate(req Request, name string) Response } return Response{ - Body: s.createOperationLocked(project.Name, project), + Body: s.createOperationLocked(utils.Deref(project.Name), project), } } @@ -350,7 +350,7 @@ func (s *FakeWorkspace) PostgresBranchCreate(req Request, parent, branchID strin } now := nowTime() - branch.BranchId = branchID + branch.BranchId = utils.NonZero(branchID) if exists { // Preserve identifying / output-only fields; apply incoming spec to status. branch.Name = existing.Name @@ -360,27 +360,26 @@ func (s *FakeWorkspace) PostgresBranchCreate(req Request, parent, branchID strin branch.UpdateTime = now branch.Status = existing.Status } else { - branch.Name = name - branch.Parent = parent - branch.Uid = "br-" + nextUUID()[:20] + branch.Name = utils.NonZero(name) + branch.Parent = utils.NonZero(parent) + branch.Uid = utils.NonZero("br-" + nextUUID()[:20]) branch.CreateTime = now branch.UpdateTime = now branch.Status = &postgres.BranchStatus{ - BranchId: branchID, - CurrentState: postgres.BranchStatusStateReady, + BranchId: utils.NonZero(branchID), + CurrentState: postgres.BranchStatus_State_Ready, StateChangeTime: now, - Default: false, - IsProtected: false, - LogicalSizeBytes: 0, - ForceSendFields: []string{"Default", "IsProtected", "LogicalSizeBytes"}, + Default: new(false), + IsProtected: new(false), + LogicalSizeBytes: new(int64(0)), } // Set source branch info if a default branch exists. prefix := parent + "/branches/" for brName, br := range s.PostgresBranches { - if strings.HasPrefix(brName, prefix) && br.Status != nil && br.Status.Default { + if strings.HasPrefix(brName, prefix) && br.Status != nil && utils.Deref(br.Status.Default) { branch.Status.SourceBranch = br.Name - branch.Status.SourceBranchLsn = "0/0" + branch.Status.SourceBranchLsn = utils.NonZero("0/0") branch.Status.SourceBranchTime = nowTime() break } @@ -389,7 +388,7 @@ func (s *FakeWorkspace) PostgresBranchCreate(req Request, parent, branchID strin // Apply user-provided spec fields to status (where input fields are surfaced). if branch.Spec != nil { - branch.Status.IsProtected = branch.Spec.IsProtected + branch.Status.IsProtected = new(utils.Deref(branch.Spec.IsProtected)) branch.Status.ExpireTime = branch.Spec.ExpireTime } @@ -405,7 +404,7 @@ func (s *FakeWorkspace) PostgresBranchCreate(req Request, parent, branchID strin } return Response{ - Body: s.createOperationLocked(branch.Name, branch), + Body: s.createOperationLocked(utils.Deref(branch.Name), branch), } } @@ -484,7 +483,7 @@ func (s *FakeWorkspace) PostgresBranchUpdate(req Request, name string) Response if branch.Status == nil { branch.Status = &postgres.BranchStatus{} } - branch.Status.IsProtected = updateBranch.Spec.IsProtected + branch.Status.IsProtected = new(utils.Deref(updateBranch.Spec.IsProtected)) if updateBranch.Spec.ExpireTime != nil { branch.Status.ExpireTime = updateBranch.Spec.ExpireTime } @@ -494,7 +493,7 @@ func (s *FakeWorkspace) PostgresBranchUpdate(req Request, name string) Response s.PostgresBranches[name] = branch return Response{ - Body: s.createOperationLocked(branch.Name, branch), + Body: s.createOperationLocked(utils.Deref(branch.Name), branch), } } @@ -510,7 +509,7 @@ func (s *FakeWorkspace) PostgresBranchDelete(name string) Response { return postgresNotFoundResponse("branch") } - if branch.Status != nil && branch.Status.IsProtected { + if branch.Status != nil && utils.Deref(branch.Status.IsProtected) { return postgresErrorResponse(400, "BAD_REQUEST", "cannot delete protected branch") } @@ -555,7 +554,7 @@ func (s *FakeWorkspace) PostgresSnapshotScheduleGet(name string) Response { schedule, exists := s.PostgresSnapshotSchedules[name] if !exists { - schedule = postgres.SnapshotSchedule{Name: name} + schedule = postgres.SnapshotSchedule{Name: utils.NonZero(name)} } return Response{ @@ -581,7 +580,7 @@ func (s *FakeWorkspace) PostgresSnapshotScheduleUpdate(req Request, name string) // Snapshots are only allowed on the root (default) branch; the backend // rejects a schedule on any branch created off another. - if branch.Status == nil || !branch.Status.Default { + if branch.Status == nil || !utils.Deref(branch.Status.Default) { return postgresErrorResponse(400, "BAD_REQUEST", "not allowed to snapshot non-root branch") } @@ -596,7 +595,7 @@ func (s *FakeWorkspace) PostgresSnapshotScheduleUpdate(req Request, name string) } schedule := postgres.SnapshotSchedule{ - Name: name, + Name: utils.NonZero(name), Schedule: updateSchedule.Schedule, } s.PostgresSnapshotSchedules[name] = schedule @@ -644,7 +643,7 @@ func (s *FakeWorkspace) PostgresEndpointCreate(req Request, parent, endpointID s } now := nowTime() - endpoint.EndpointId = endpointID + endpoint.EndpointId = utils.NonZero(endpointID) if exists { endpoint.Name = existing.Name endpoint.Parent = existing.Parent @@ -653,38 +652,37 @@ func (s *FakeWorkspace) PostgresEndpointCreate(req Request, parent, endpointID s endpoint.UpdateTime = now endpoint.Status = existing.Status } else { - endpoint.Name = name - endpoint.Parent = parent - endpoint.Uid = "ep-" + nextUUID()[:20] + endpoint.Name = utils.NonZero(name) + endpoint.Parent = utils.NonZero(parent) + endpoint.Uid = utils.NonZero("ep-" + nextUUID()[:20]) endpoint.CreateTime = now endpoint.UpdateTime = now // Inherit suspend timeout default from the project. - var defaultSuspendTimeout *duration.Duration - if project, ok := s.PostgresProjects[branch.Parent]; ok { + var defaultSuspendTimeout *types.Duration + if project, ok := s.PostgresProjects[utils.Deref(branch.Parent)]; ok { if project.Status != nil && project.Status.DefaultEndpointSettings != nil { defaultSuspendTimeout = project.Status.DefaultEndpointSettings.SuspendTimeoutDuration } } endpoint.Status = &postgres.EndpointStatus{ - EndpointId: endpointID, - CurrentState: postgres.EndpointStatusStateActive, - Disabled: false, + EndpointId: utils.NonZero(endpointID), + CurrentState: postgres.EndpointStatus_State_Active, + Disabled: new(false), Settings: &postgres.EndpointSettings{}, SuspendTimeoutDuration: defaultSuspendTimeout, - ForceSendFields: []string{"Disabled"}, } - host := endpoint.Uid + ".database.us-east-1.cloud.databricks.com" + host := utils.Deref(endpoint.Uid) + ".database.us-east-1.cloud.databricks.com" endpoint.Status.Hosts = &postgres.EndpointHosts{ - Host: host, - ReadOnlyHost: host, + Host: utils.NonZero(host), + ReadOnlyHost: utils.NonZero(host), } endpoint.Status.Group = &postgres.EndpointGroupStatus{ - EnableReadableSecondaries: true, - Max: 1, - Min: 1, + EnableReadableSecondaries: utils.NonZero(true), + Max: utils.NonZero(1), + Min: utils.NonZero(1), } } @@ -705,7 +703,7 @@ func (s *FakeWorkspace) PostgresEndpointCreate(req Request, parent, endpointID s s.PostgresEndpoints[name] = endpoint return Response{ - Body: s.createOperationLocked(endpoint.Name, endpoint), + Body: s.createOperationLocked(utils.Deref(endpoint.Name), endpoint), } } @@ -1014,7 +1012,7 @@ func isNonDefaultEndpointSettings(s *postgres.ProjectDefaultEndpointSettings) bo if s == nil { return false } - if s.AutoscalingLimitMinCu != defaultAutoscalingLimitMinCu || s.AutoscalingLimitMaxCu != defaultAutoscalingLimitMaxCu { + if utils.Deref(s.AutoscalingLimitMinCu) != defaultAutoscalingLimitMinCu || utils.Deref(s.AutoscalingLimitMaxCu) != defaultAutoscalingLimitMaxCu { return true } return s.SuspendTimeoutDuration != nil && s.SuspendTimeoutDuration.AsDuration() != defaultSuspendTimeout @@ -1093,10 +1091,10 @@ func (s *FakeWorkspace) PostgresEndpointUpdate(req Request, name string) Respons if endpoint.Status == nil { endpoint.Status = &postgres.EndpointStatus{} } - if updateEndpoint.Spec.AutoscalingLimitMinCu != 0 { + if utils.Deref(updateEndpoint.Spec.AutoscalingLimitMinCu) != 0 { endpoint.Status.AutoscalingLimitMinCu = updateEndpoint.Spec.AutoscalingLimitMinCu } - if updateEndpoint.Spec.AutoscalingLimitMaxCu != 0 { + if utils.Deref(updateEndpoint.Spec.AutoscalingLimitMaxCu) != 0 { endpoint.Status.AutoscalingLimitMaxCu = updateEndpoint.Spec.AutoscalingLimitMaxCu } if updateEndpoint.Spec.SuspendTimeoutDuration != nil { @@ -1109,7 +1107,7 @@ func (s *FakeWorkspace) PostgresEndpointUpdate(req Request, name string) Respons s.PostgresEndpoints[name] = endpoint return Response{ - Body: s.createOperationLocked(endpoint.Name, endpoint), + Body: s.createOperationLocked(utils.Deref(endpoint.Name), endpoint), } } @@ -1167,7 +1165,7 @@ func (s *FakeWorkspace) PostgresDatabaseCreate(req Request, parent, databaseID s // The real Lakebase API requires the owning role on create and rejects an empty // one with this exact error (verified on aws-ucws 2026-07-13). The fake does // not synthesize a default, matching that behavior. - if database.Spec == nil || database.Spec.Role == "" { + if database.Spec == nil || utils.Deref(database.Spec.Role) == "" { return postgresErrorResponse(400, "INVALID_PARAMETER_VALUE", `Field 'database.spec.role' is required, expected non-default value (not "")!`) } @@ -1184,8 +1182,8 @@ func (s *FakeWorkspace) PostgresDatabaseCreate(req Request, parent, databaseID s now := nowTime() if exists { // Preserve identifying / output-only fields; apply incoming spec to status. - status := &postgres.DatabaseDatabaseStatus{ - DatabaseId: databaseID, + status := &postgres.Database_DatabaseStatus{ + DatabaseId: utils.NonZero(databaseID), PostgresDatabase: database.Spec.PostgresDatabase, Role: database.Spec.Role, } @@ -1195,19 +1193,19 @@ func (s *FakeWorkspace) PostgresDatabaseCreate(req Request, parent, databaseID s s.PostgresDatabases[name] = existing return Response{ - Body: s.createOperationLocked(existing.Name, existing), + Body: s.createOperationLocked(utils.Deref(existing.Name), existing), } } - database.Name = name - database.DatabaseId = databaseID - database.Parent = parent + database.Name = utils.NonZero(name) + database.DatabaseId = utils.NonZero(databaseID) + database.Parent = utils.NonZero(parent) database.CreateTime = now database.UpdateTime = now // Mirror spec onto status; the real API only echoes Status on GET. - status := &postgres.DatabaseDatabaseStatus{ - DatabaseId: databaseID, + status := &postgres.Database_DatabaseStatus{ + DatabaseId: utils.NonZero(databaseID), PostgresDatabase: database.Spec.PostgresDatabase, Role: database.Spec.Role, } @@ -1217,7 +1215,7 @@ func (s *FakeWorkspace) PostgresDatabaseCreate(req Request, parent, databaseID s s.PostgresDatabases[name] = database return Response{ - Body: s.createOperationLocked(database.Name, database), + Body: s.createOperationLocked(utils.Deref(database.Name), database), } } @@ -1298,28 +1296,28 @@ func (s *FakeWorkspace) PostgresDatabaseUpdate(req Request, name string) Respons // Preserve database_id which is derived from the resource name. databaseID := "" if database.Status != nil { - databaseID = database.Status.DatabaseId + databaseID = utils.Deref(database.Status.DatabaseId) } var paths []string if mask := req.URL.Query().Get("update_mask"); mask != "" { paths = strings.Split(mask, ",") } database.Status = applyDatabaseSpecMask(database.Status, databaseStatusFromSpec(updateDatabase.Spec), paths) - database.Status.DatabaseId = databaseID + database.Status.DatabaseId = utils.NonZero(databaseID) } database.UpdateTime = nowTime() s.PostgresDatabases[name] = database return Response{ - Body: s.createOperationLocked(database.Name, database), + Body: s.createOperationLocked(utils.Deref(database.Name), database), } } // databaseStatusFromSpec mirrors the real Postgres Database server's behavior of // echoing the spec onto Status while leaving Spec=nil on GET responses. -func databaseStatusFromSpec(spec *postgres.DatabaseDatabaseSpec) *postgres.DatabaseDatabaseStatus { - status := &postgres.DatabaseDatabaseStatus{} +func databaseStatusFromSpec(spec *postgres.Database_DatabaseSpec) *postgres.Database_DatabaseStatus { + status := &postgres.Database_DatabaseStatus{} if spec == nil { return status } @@ -1332,7 +1330,7 @@ func databaseStatusFromSpec(spec *postgres.DatabaseDatabaseSpec) *postgres.Datab // desired onto existing. Paths are relative to the Database and "spec."-prefixed; // the bare path "spec" replaces the whole subtree, and an empty paths slice // replaces everything. Same shape as applyRoleSpecMask. -func applyDatabaseSpecMask(existing, desired *postgres.DatabaseDatabaseStatus, paths []string) *postgres.DatabaseDatabaseStatus { +func applyDatabaseSpecMask(existing, desired *postgres.Database_DatabaseStatus, paths []string) *postgres.Database_DatabaseStatus { if len(paths) == 0 || existing == nil { return desired } @@ -1393,20 +1391,20 @@ func (s *FakeWorkspace) PostgresCatalogCreate(req Request, catalogID string) Res } now := nowTime() - catalog.Name = name - catalog.CatalogId = catalogID - catalog.Uid = nextUUID() + catalog.Name = utils.NonZero(name) + catalog.CatalogId = utils.NonZero(catalogID) + catalog.Uid = utils.NonZero(nextUUID()) catalog.CreateTime = now catalog.UpdateTime = now - status := &postgres.CatalogCatalogStatus{} + status := &postgres.Catalog_CatalogStatus{} if catalog.Spec != nil { status.Branch = catalog.Spec.Branch status.PostgresDatabase = catalog.Spec.PostgresDatabase // Project portion of the status is "projects/{project_id}", derived // from the branch name "projects/{project_id}/branches/{branch_id}". - if idx := strings.Index(catalog.Spec.Branch, "/branches/"); idx > 0 { - status.Project = catalog.Spec.Branch[:idx] + if idx := strings.Index(utils.Deref(catalog.Spec.Branch), "/branches/"); idx > 0 { + status.Project = utils.NonZero(utils.Deref(catalog.Spec.Branch)[:idx]) } } catalog.Status = status @@ -1449,8 +1447,8 @@ var roleIDPattern = regexp.MustCompile(`^[a-z][a-z0-9-]{3,62}$`) // roleStatusFromSpec mirrors the real Postgres Role server's behavior of echoing // the spec onto Status (plus default-deriving fields the user did not specify) // while leaving Spec=nil on GET responses. -func roleStatusFromSpec(spec *postgres.RoleRoleSpec) *postgres.RoleRoleStatus { - status := &postgres.RoleRoleStatus{} +func roleStatusFromSpec(spec *postgres.Role_RoleSpec) *postgres.Role_RoleStatus { + status := &postgres.Role_RoleStatus{} if spec == nil { return status } @@ -1464,25 +1462,26 @@ func roleStatusFromSpec(spec *postgres.RoleRoleSpec) *postgres.RoleRoleStatus { status.AuthMethod = spec.AuthMethod if status.AuthMethod == "" { // Server derives auth_method from identity_type when the user omits it: - // see SDK comment on postgres.RoleRoleSpec.AuthMethod. + // see SDK comment on postgres.Role_RoleSpec.AuthMethod. switch spec.IdentityType { - case postgres.RoleIdentityTypeGroup: - status.AuthMethod = postgres.RoleAuthMethodNoLogin - case postgres.RoleIdentityTypeUser, postgres.RoleIdentityTypeServicePrincipal: - status.AuthMethod = postgres.RoleAuthMethodLakebaseOauthV1 + case postgres.Role_IdentityType_Group: + status.AuthMethod = postgres.Role_AuthMethod_NoLogin + case postgres.Role_IdentityType_User, postgres.Role_IdentityType_ServicePrincipal: + status.AuthMethod = postgres.Role_AuthMethod_LakebaseOauthV1 default: - status.AuthMethod = postgres.RoleAuthMethodPgPasswordScramSha256 + status.AuthMethod = postgres.Role_AuthMethod_PgPasswordScramSha256 } } // Real server always echoes an attributes block (all-false when unspecified). - attrs := &postgres.RoleAttributes{ - ForceSendFields: []string{"Bypassrls", "Createdb", "Createrole"}, - } + attrs := &postgres.Role_Attributes{} if spec.Attributes != nil { attrs.Bypassrls = spec.Attributes.Bypassrls attrs.Createdb = spec.Attributes.Createdb attrs.Createrole = spec.Attributes.Createrole } + attrs.Bypassrls = new(utils.Deref(attrs.Bypassrls)) + attrs.Createdb = new(utils.Deref(attrs.Createdb)) + attrs.Createrole = new(utils.Deref(attrs.Createrole)) status.Attributes = attrs return status } @@ -1535,29 +1534,29 @@ func (s *FakeWorkspace) PostgresRoleCreate(req Request, parent, roleID string, r // Preserve identifying / output-only fields; apply incoming spec to status. existing.UpdateTime = now existing.Status = roleStatusFromSpec(role.Spec) - existing.Status.RoleId = roleID + existing.Status.RoleId = utils.NonZero(roleID) existing.Spec = nil s.PostgresRoles[name] = existing return Response{ - Body: s.createOperationLocked(existing.Name, existing), + Body: s.createOperationLocked(utils.Deref(existing.Name), existing), } } - role.Name = name - role.RoleId = roleID - role.Parent = parent + role.Name = utils.NonZero(name) + role.RoleId = utils.NonZero(roleID) + role.Parent = utils.NonZero(parent) role.CreateTime = now role.UpdateTime = now role.Status = roleStatusFromSpec(role.Spec) - role.Status.RoleId = roleID + role.Status.RoleId = utils.NonZero(roleID) role.Spec = nil s.PostgresRoles[name] = role return Response{ - Body: s.createOperationLocked(role.Name, role), + Body: s.createOperationLocked(utils.Deref(role.Name), role), } } @@ -1641,21 +1640,21 @@ func (s *FakeWorkspace) PostgresRoleUpdate(req Request, name string) Response { // Preserve role_id which is derived from the resource name. roleID := "" if role.Status != nil { - roleID = role.Status.RoleId + roleID = utils.Deref(role.Status.RoleId) } var paths []string if mask := req.URL.Query().Get("update_mask"); mask != "" { paths = strings.Split(mask, ",") } role.Status = applyRoleSpecMask(role.Status, roleStatusFromSpec(updateRole.Spec), paths) - role.Status.RoleId = roleID + role.Status.RoleId = utils.NonZero(roleID) } role.UpdateTime = nowTime() s.PostgresRoles[name] = role return Response{ - Body: s.createOperationLocked(role.Name, role), + Body: s.createOperationLocked(utils.Deref(role.Name), role), } } @@ -1670,7 +1669,7 @@ func (s *FakeWorkspace) PostgresRoleUpdate(req Request, name string) Response { // dogfood 2026-06-16 — update_mask=spec.attributes.createdb leaves the sibling // attributes untouched), but the direct engine always sends the full spec in the // request body, so the collapsed result is identical for the requests it makes. -func applyRoleSpecMask(existing, desired *postgres.RoleRoleStatus, paths []string) *postgres.RoleRoleStatus { +func applyRoleSpecMask(existing, desired *postgres.Role_RoleStatus, paths []string) *postgres.Role_RoleStatus { if len(paths) == 0 || existing == nil { return desired } @@ -1751,8 +1750,8 @@ func (s *FakeWorkspace) createOperationLocked(resourceName string, response any) } op := postgres.Operation{ - Name: operationName, - Done: true, + Name: utils.NonZero(operationName), + Done: utils.NonZero(true), Metadata: fmt.Appendf(nil, `{"@type":"type.googleapis.com/databricks.postgres.v1.%sOperationMetadata"}`, resourceType), } if response != nil { @@ -1790,15 +1789,15 @@ func (s *FakeWorkspace) PostgresSyncedTableCreate(req Request, syncedTableID str if _, exists := s.PostgresSyncedTables[name]; exists { return postgresErrorResponse(409, "ALREADY_EXISTS", "synced table with such id already exists") } - table.Name = name - table.Uid = nextUUID() + table.Name = utils.NonZero(name) + table.Uid = utils.NonZero(nextUUID()) table.CreateTime = nowTime() // GET on the real API returns only status; clear spec to match. table.Spec = nil - table.Status = &postgres.SyncedTableSyncedTableStatus{ - DetailedState: postgres.SyncedTableStateSyncedTableOnline, - UnityCatalogProvisioningState: postgres.ProvisioningInfoStateActive, + table.Status = &postgres.SyncedTable_SyncedTableStatus{ + DetailedState: postgres.SyncedTableState_SyncedTableOnline, + UnityCatalogProvisioningState: postgres.ProvisioningInfo_State_Active, } s.PostgresSyncedTables[name] = table @@ -1837,10 +1836,10 @@ func (s *FakeWorkspace) PostgresSyncedTableDelete(name string) Response { } if table.Status == nil { - table.Status = &postgres.SyncedTableSyncedTableStatus{} + table.Status = &postgres.SyncedTable_SyncedTableStatus{} } - table.Status.DetailedState = postgres.SyncedTableStateSyncedTableOffline - table.Status.UnityCatalogProvisioningState = postgres.ProvisioningInfoStateDeleting + table.Status.DetailedState = postgres.SyncedTableState_SyncedTableOffline + table.Status.UnityCatalogProvisioningState = postgres.ProvisioningInfo_State_Deleting s.PostgresSyncedTables[name] = table return Response{Body: s.createOperationLocked(name, nil)} @@ -1854,20 +1853,19 @@ func (s *FakeWorkspace) createDefaultBranchLocked(projectName string) { branchName := projectName + "/branches/production" defaultBranch := postgres.Branch{ - Name: branchName, - BranchId: "production", - Parent: projectName, - Uid: branchUID, + Name: utils.NonZero(branchName), + BranchId: utils.NonZero("production"), + Parent: utils.NonZero(projectName), + Uid: utils.NonZero(branchUID), CreateTime: now, UpdateTime: now, Status: &postgres.BranchStatus{ - BranchId: "production", - CurrentState: postgres.BranchStatusStateReady, + BranchId: utils.NonZero("production"), + CurrentState: postgres.BranchStatus_State_Ready, StateChangeTime: now, - Default: true, - IsProtected: false, - LogicalSizeBytes: 0, - ForceSendFields: []string{"Default", "IsProtected", "LogicalSizeBytes"}, + Default: new(true), + IsProtected: new(false), + LogicalSizeBytes: new(int64(0)), }, } @@ -1888,13 +1886,13 @@ func (s *FakeWorkspace) createDefaultEndpointLocked(branchName string) { // Inherit default endpoint settings from the project where available. var ( minCu, maxCu float64 - suspendTimeout *duration.Duration + suspendTimeout *types.Duration projectName = strings.Split(branchName, "/branches/")[0] ) if project, ok := s.PostgresProjects[projectName]; ok { if project.Status != nil && project.Status.DefaultEndpointSettings != nil { - minCu = project.Status.DefaultEndpointSettings.AutoscalingLimitMinCu - maxCu = project.Status.DefaultEndpointSettings.AutoscalingLimitMaxCu + minCu = utils.Deref(project.Status.DefaultEndpointSettings.AutoscalingLimitMinCu) + maxCu = utils.Deref(project.Status.DefaultEndpointSettings.AutoscalingLimitMaxCu) suspendTimeout = project.Status.DefaultEndpointSettings.SuspendTimeoutDuration } } @@ -1903,30 +1901,29 @@ func (s *FakeWorkspace) createDefaultEndpointLocked(branchName string) { host := endpointUID + ".database.us-east-1.cloud.databricks.com" s.PostgresEndpoints[endpointName] = postgres.Endpoint{ - Name: endpointName, - EndpointId: "primary", - Parent: branchName, - Uid: endpointUID, + Name: utils.NonZero(endpointName), + EndpointId: utils.NonZero("primary"), + Parent: utils.NonZero(branchName), + Uid: utils.NonZero(endpointUID), CreateTime: now, UpdateTime: now, Status: &postgres.EndpointStatus{ - EndpointId: "primary", - EndpointType: postgres.EndpointTypeEndpointTypeReadWrite, - CurrentState: postgres.EndpointStatusStateActive, - Disabled: false, + EndpointId: utils.NonZero("primary"), + EndpointType: postgres.EndpointType_EndpointTypeReadWrite, + CurrentState: postgres.EndpointStatus_State_Active, + Disabled: new(false), Settings: &postgres.EndpointSettings{}, - AutoscalingLimitMinCu: minCu, - AutoscalingLimitMaxCu: maxCu, + AutoscalingLimitMinCu: utils.NonZero(minCu), + AutoscalingLimitMaxCu: utils.NonZero(maxCu), SuspendTimeoutDuration: suspendTimeout, // Primary read-write endpoint exposes only the read-write host; // read_only_host is set on read-only endpoints created later. - Hosts: &postgres.EndpointHosts{Host: host}, + Hosts: &postgres.EndpointHosts{Host: utils.NonZero(host)}, Group: &postgres.EndpointGroupStatus{ - Max: 1, - Min: 1, - ForceSendFields: []string{"EnableReadableSecondaries"}, + Max: utils.NonZero(1), + Min: utils.NonZero(1), + EnableReadableSecondaries: new(false), }, - ForceSendFields: []string{"Disabled"}, }, } s.postgresImplicitEndpoints[endpointName] = true diff --git a/libs/testserver/postgres_test.go b/libs/testserver/postgres_test.go index 1a414cf6762..4311126b562 100644 --- a/libs/testserver/postgres_test.go +++ b/libs/testserver/postgres_test.go @@ -6,8 +6,10 @@ import ( "strings" "testing" + postgres "github.com/databricks/cli/libs/sdktypes/postgres/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/testserver" - "github.com/databricks/databricks-sdk-go/service/postgres" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -29,7 +31,7 @@ func TestPostgresProjectCRUD(t *testing.T) { var createOp postgres.Operation require.NoError(t, json.NewDecoder(createResp.Body).Decode(&createOp)) - assert.True(t, createOp.Done) + assert.True(t, utils.Deref(createOp.Done)) createResp.Body.Close() // Get project @@ -41,7 +43,7 @@ func TestPostgresProjectCRUD(t *testing.T) { var project postgres.Project require.NoError(t, json.NewDecoder(getResp.Body).Decode(&project)) - assert.Equal(t, "projects/test-project", project.Name) + assert.Equal(t, "projects/test-project", utils.Deref(project.Name)) getResp.Body.Close() // List projects @@ -144,7 +146,7 @@ func TestPostgresBranchCRUD(t *testing.T) { var branch postgres.Branch require.NoError(t, json.NewDecoder(getBranchResp.Body).Decode(&branch)) - assert.Equal(t, "projects/branch-test-project/branches/main", branch.Name) + assert.Equal(t, "projects/branch-test-project/branches/main", utils.Deref(branch.Name)) getBranchResp.Body.Close() // List branches @@ -225,7 +227,7 @@ func TestPostgresEndpointCRUD(t *testing.T) { var endpoint postgres.Endpoint require.NoError(t, json.NewDecoder(getEpResp.Body).Decode(&endpoint)) - assert.Equal(t, "projects/endpoint-test-project/branches/main/endpoints/rw-endpoint", endpoint.Name) + assert.Equal(t, "projects/endpoint-test-project/branches/main/endpoints/rw-endpoint", utils.Deref(endpoint.Name)) getEpResp.Body.Close() // List endpoints @@ -293,11 +295,11 @@ func TestPostgresDatabaseCRUD(t *testing.T) { var database postgres.Database require.NoError(t, json.NewDecoder(getDbResp.Body).Decode(&database)) - assert.Equal(t, "projects/database-test-project/branches/main/databases/my-db", database.Name) - assert.Equal(t, "projects/database-test-project/branches/main", database.Parent) + assert.Equal(t, "projects/database-test-project/branches/main/databases/my-db", utils.Deref(database.Name)) + assert.Equal(t, "projects/database-test-project/branches/main", utils.Deref(database.Parent)) require.NotNil(t, database.Status) - assert.Equal(t, "my_db", database.Status.PostgresDatabase) - assert.NotEmpty(t, database.Status.Role) + assert.Equal(t, "my_db", utils.Deref(database.Status.PostgresDatabase)) + assert.NotEmpty(t, utils.Deref(database.Status.Role)) getDbResp.Body.Close() // List databases @@ -331,7 +333,7 @@ func TestPostgresDatabaseCRUD(t *testing.T) { var database2 postgres.Database require.NoError(t, json.NewDecoder(getDbResp2.Body).Decode(&database2)) require.NotNil(t, database2.Status) - assert.Equal(t, "my_db_renamed", database2.Status.PostgresDatabase) + assert.Equal(t, "my_db_renamed", utils.Deref(database2.Status.PostgresDatabase)) getDbResp2.Body.Close() // Delete database @@ -405,8 +407,8 @@ func TestPostgresDatabaseUpdateMaskPreservesUnmaskedFields(t *testing.T) { getResp.Body.Close() require.NotNil(t, database.Status) - assert.Equal(t, "renamed_db", database.Status.PostgresDatabase, "masked field should be updated") - assert.Equal(t, "projects/mask-db-project/branches/main/roles/owner", database.Status.Role, "field absent from update_mask should be preserved") + assert.Equal(t, "renamed_db", utils.Deref(database.Status.PostgresDatabase), "masked field should be updated") + assert.Equal(t, "projects/mask-db-project/branches/main/roles/owner", utils.Deref(database.Status.Role), "field absent from update_mask should be preserved") } func TestPostgresDatabaseCreateDuplicateReturns400(t *testing.T) { @@ -506,10 +508,10 @@ func TestPostgresRoleCRUD(t *testing.T) { var role postgres.Role require.NoError(t, json.NewDecoder(getRoleResp.Body).Decode(&role)) - assert.Equal(t, "projects/role-test-project/branches/main/roles/my-role", role.Name) - assert.Equal(t, "projects/role-test-project/branches/main", role.Parent) + assert.Equal(t, "projects/role-test-project/branches/main/roles/my-role", utils.Deref(role.Name)) + assert.Equal(t, "projects/role-test-project/branches/main", utils.Deref(role.Parent)) require.NotNil(t, role.Status) - assert.Equal(t, "my_role", role.Status.PostgresRole) + assert.Equal(t, "my_role", utils.Deref(role.Status.PostgresRole)) getRoleResp.Body.Close() // List roles @@ -543,7 +545,7 @@ func TestPostgresRoleCRUD(t *testing.T) { var role2 postgres.Role require.NoError(t, json.NewDecoder(getRoleResp2.Body).Decode(&role2)) require.NotNil(t, role2.Status) - assert.Equal(t, "my_role_renamed", role2.Status.PostgresRole) + assert.Equal(t, "my_role_renamed", utils.Deref(role2.Status.PostgresRole)) getRoleResp2.Body.Close() // Delete role @@ -594,8 +596,8 @@ func TestPostgresRoleUpdateMaskPreservesUnmaskedFields(t *testing.T) { require.NotNil(t, role.Status) require.NotNil(t, role.Status.Attributes) - assert.True(t, role.Status.Attributes.Createdb, "masked field should be updated") - assert.Equal(t, "app_role", role.Status.PostgresRole, "field absent from update_mask should be preserved") + assert.True(t, utils.Deref(role.Status.Attributes.Createdb), "masked field should be updated") + assert.Equal(t, "app_role", utils.Deref(role.Status.PostgresRole), "field absent from update_mask should be preserved") } func TestPostgresRoleNotFoundWhenBranchNotExists(t *testing.T) { diff --git a/libs/testserver/quality_monitors.go b/libs/testserver/quality_monitors.go index f9d7a0e0135..a59bf208832 100644 --- a/libs/testserver/quality_monitors.go +++ b/libs/testserver/quality_monitors.go @@ -5,12 +5,12 @@ import ( "fmt" "net/http" - "github.com/databricks/databricks-sdk-go/service/catalog" + qualitymonitors "github.com/databricks/cli/libs/qualitymonitors" ) func (s *FakeWorkspace) QualityMonitorUpsert(req Request, tableName string, checkExists bool) Response { - var request catalog.CreateMonitor - var info catalog.MonitorInfo + var request qualitymonitors.CreateMonitor + var info qualitymonitors.MonitorInfo if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ diff --git a/libs/testserver/registered_models.go b/libs/testserver/registered_models.go index b6fb800a623..07e2b25615a 100644 --- a/libs/testserver/registered_models.go +++ b/libs/testserver/registered_models.go @@ -5,7 +5,8 @@ import ( "fmt" "net/http" - "github.com/databricks/databricks-sdk-go/service/catalog" + registeredmodels "github.com/databricks/cli/libs/sdktypes/uc/registeredmodels/v1" + "github.com/databricks/cli/libs/utils" ) // modelNameBrowseOnly scopes the computed browse_only flag to the browse_only @@ -15,7 +16,7 @@ const modelNameBrowseOnly = "model_browse_only" func (s *FakeWorkspace) RegisteredModelsCreate(req Request) Response { defer s.LockUnlock()() - var createRequest catalog.CreateRegisteredModelRequest + var createRequest registeredmodels.CreateRegisteredModelRequest if err := json.Unmarshal(req.Body, &createRequest); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -24,25 +25,25 @@ func (s *FakeWorkspace) RegisteredModelsCreate(req Request) Response { } // Build full name from catalog.schema.name - fullName := createRequest.CatalogName + "." + createRequest.SchemaName + "." + createRequest.Name + fullName := utils.Deref(createRequest.CatalogName) + "." + utils.Deref(createRequest.SchemaName) + "." + utils.Deref(createRequest.Name) - registeredModel := catalog.RegisteredModelInfo{ + registeredModel := registeredmodels.RegisteredModelInfo{ CatalogName: createRequest.CatalogName, Comment: createRequest.Comment, Name: createRequest.Name, SchemaName: createRequest.SchemaName, StorageLocation: createRequest.StorageLocation, - FullName: fullName, - CreatedAt: nowMilli(), + FullName: utils.NonZero(fullName), + CreatedAt: utils.NonZero(nowMilli()), CreatedBy: s.CurrentUser().UserName, UpdatedBy: s.CurrentUser().UserName, - MetastoreId: nextUUID(), + MetastoreId: utils.NonZero(nextUUID()), Owner: s.CurrentUser().UserName, } registeredModel.UpdatedAt = registeredModel.CreatedAt - if createRequest.Name == modelNameBrowseOnly { + if utils.Deref(createRequest.Name) == modelNameBrowseOnly { // Mirror UC, which computes browse_only and echoes it on GET. - registeredModel.BrowseOnly = true + registeredModel.BrowseOnly = utils.NonZero(true) } s.RegisteredModels[fullName] = registeredModel @@ -67,7 +68,7 @@ func (s *FakeWorkspace) RegisteredModelsUpdate(req Request, fullName string) Res return *errResponse } - var updateRequest catalog.UpdateRegisteredModelRequest + var updateRequest registeredmodels.UpdateRegisteredModelRequest if err := json.Unmarshal(req.Body, &updateRequest); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -77,15 +78,15 @@ func (s *FakeWorkspace) RegisteredModelsUpdate(req Request, fullName string) Res applyUpdatedFields(&existing, updateRequest, fields) - if updateRequest.NewName != "" { + if utils.Deref(updateRequest.NewName) != "" { existing.Name = updateRequest.NewName // Delete the old entry and set full name to the new name delete(s.RegisteredModels, fullName) - fullName = existing.CatalogName + "." + existing.SchemaName + "." + updateRequest.NewName + fullName = utils.Deref(existing.CatalogName) + "." + utils.Deref(existing.SchemaName) + "." + utils.Deref(updateRequest.NewName) } - existing.UpdatedAt = nowMilli() + existing.UpdatedAt = utils.NonZero(nowMilli()) s.RegisteredModels[fullName] = existing return Response{ Body: existing, diff --git a/libs/testserver/repos.go b/libs/testserver/repos.go index 30c090b5b41..48ff5e1ddc6 100644 --- a/libs/testserver/repos.go +++ b/libs/testserver/repos.go @@ -6,7 +6,8 @@ import ( "net/http" "strconv" - "github.com/databricks/databricks-sdk-go/service/workspace" + repos "github.com/databricks/cli/libs/sdktypes/repos/v1" + "github.com/databricks/cli/libs/utils" ) // fakeHeadCommitID is the commit the fake reports a clone is checked out to. @@ -17,7 +18,7 @@ const fakeHeadCommitID = "0a1b2c3d4e5f6a7b8e7dadd73e50a69d8ba47d8f" func (s *FakeWorkspace) ReposCreate(req Request) Response { defer s.LockUnlock()() - var repoReq workspace.CreateRepoRequest + var repoReq repos.CreateRepoRequest if err := json.Unmarshal(req.Body, &repoReq); err != nil { return Response{ @@ -29,17 +30,17 @@ func (s *FakeWorkspace) ReposCreate(req Request) Response { repoId := nextTreenodeID() id := strconv.FormatInt(repoId, 10) - repoInfo := workspace.RepoInfo{ - Id: repoId, + repoInfo := repos.RepoInfo{ + Id: utils.NonZero(repoId), Path: repoReq.Path, Provider: repoReq.Provider, Url: repoReq.Url, - Branch: "main", - HeadCommitId: fakeHeadCommitID, + Branch: utils.NonZero("main"), + HeadCommitId: utils.NonZero(fakeHeadCommitID), } s.Repos[id] = repoInfo - s.repoIdByPath[repoReq.Path] = repoId + s.repoIdByPath[utils.Deref(repoReq.Path)] = repoId return Response{ Body: repoInfo, @@ -49,7 +50,7 @@ func (s *FakeWorkspace) ReposCreate(req Request) Response { func (s *FakeWorkspace) ReposUpdate(req Request) Response { defer s.LockUnlock()() - var repoReq workspace.UpdateRepoRequest + var repoReq repos.UpdateRepoRequest if err := json.Unmarshal(req.Body, &repoReq); err != nil { return Response{ @@ -67,7 +68,7 @@ func (s *FakeWorkspace) ReposUpdate(req Request) Response { newRepoInfo := repoInfo - if repoReq.Branch != "" { + if utils.Deref(repoReq.Branch) != "" { newRepoInfo.Branch = repoReq.Branch } @@ -89,6 +90,6 @@ func (s *FakeWorkspace) ReposDelete(req Request) Response { } delete(s.Repos, req.Vars["repo_id"]) - delete(s.repoIdByPath, repoInfo.Path) + delete(s.repoIdByPath, utils.Deref(repoInfo.Path)) return Response{} } diff --git a/libs/testserver/schemas.go b/libs/testserver/schemas.go index 8094c93acc6..f039708cfd5 100644 --- a/libs/testserver/schemas.go +++ b/libs/testserver/schemas.go @@ -6,7 +6,8 @@ import ( "net/http" "strings" - "github.com/databricks/databricks-sdk-go/service/catalog" + schemas "github.com/databricks/cli/libs/sdktypes/uc/schemas/v1" + "github.com/databricks/cli/libs/utils" ) const testMetastoreName = "deco-uc-prod-isolated-aws-us-east-1" @@ -20,7 +21,7 @@ const schemaNameManagedDefaults = "schema_managed_defaults" func (s *FakeWorkspace) SchemasCreate(req Request) Response { defer s.LockUnlock()() - var schema catalog.SchemaInfo + var schema schemas.SchemaInfo if err := json.Unmarshal(req.Body, &schema); err != nil { return Response{ @@ -30,28 +31,28 @@ func (s *FakeWorkspace) SchemasCreate(req Request) Response { } // UC normalizes schema names to lowercase. - schema.Name = strings.ToLower(schema.Name) + schema.Name = utils.NonZero(strings.ToLower(utils.Deref(schema.Name))) // Strip trailing slash to mimic UC API normalization behavior (see volumes.go). - schema.StorageRoot = strings.TrimRight(schema.StorageRoot, "/") - schema.FullName = schema.CatalogName + "." + schema.Name - schema.ForceSendFields = []string{"BrowseOnly"} + schema.StorageRoot = utils.NonZero(strings.TrimRight(utils.Deref(schema.StorageRoot), "/")) + schema.FullName = utils.NonZero(utils.Deref(schema.CatalogName) + "." + utils.Deref(schema.Name)) + schema.BrowseOnly = new(false) schema.CatalogType = "MANAGED_CATALOG" - schema.CreatedAt = nowMilli() + schema.CreatedAt = utils.NonZero(nowMilli()) schema.UpdatedAt = schema.CreatedAt schema.CreatedBy = s.CurrentUser().UserName schema.UpdatedBy = s.CurrentUser().UserName - schema.EffectivePredictiveOptimizationFlag = &catalog.EffectivePredictiveOptimizationFlag{ - InheritedFromName: testMetastoreName, - InheritedFromType: catalog.EffectivePredictiveOptimizationFlagInheritedFromType("METASTORE"), + schema.EffectivePredictiveOptimizationFlag = &schemas.EffectivePredictiveOptimizationFlag{ + InheritedFromName: utils.NonZero(testMetastoreName), + InheritedFromType: new("METASTORE"), // Mirror the real test metastore, which inherits ENABLE, so a single // golden stays valid for both local and cloud runs. - Value: catalog.EnablePredictiveOptimizationEnable, + Value: new("ENABLE"), } - schema.EnablePredictiveOptimization = catalog.EnablePredictiveOptimizationInherit + schema.EnablePredictiveOptimization = new("INHERIT") schema.MetastoreId = TestMetastore.MetastoreId schema.Owner = s.CurrentUser().UserName - schema.SchemaId = nextUUID() - if schema.Properties == nil && schema.Name == schemaNameManagedDefaults { + schema.SchemaId = utils.NonZero(nextUUID()) + if schema.Properties == nil && utils.Deref(schema.Name) == schemaNameManagedDefaults { // Mirror UC behavior: managed system defaults are populated when the user // doesn't specify any properties. Required to cover backend-default drift. schema.Properties = map[string]string{ @@ -64,7 +65,7 @@ func (s *FakeWorkspace) SchemasCreate(req Request) Response { "unity.catalog.managed.delta.defaults.delta.feature.catalogManaged": "supported", } } - s.Schemas[schema.FullName] = schema + s.Schemas[utils.Deref(schema.FullName)] = schema return Response{ Body: schema, @@ -86,7 +87,7 @@ func (s *FakeWorkspace) SchemasUpdate(req Request, name string) Response { return *errResponse } - var schemaUpdate catalog.SchemaInfo + var schemaUpdate schemas.SchemaInfo if err := json.Unmarshal(req.Body, &schemaUpdate); err != nil { return Response{ @@ -97,7 +98,7 @@ func (s *FakeWorkspace) SchemasUpdate(req Request, name string) Response { applyUpdatedFields(&existing, schemaUpdate, fields) - existing.UpdatedAt = nowMilli() + existing.UpdatedAt = utils.NonZero(nowMilli()) existing.UpdatedBy = s.CurrentUser().UserName s.Schemas[name] = existing diff --git a/libs/testserver/secret_scopes.go b/libs/testserver/secret_scopes.go index 8dab8217384..7bc201d5bbd 100644 --- a/libs/testserver/secret_scopes.go +++ b/libs/testserver/secret_scopes.go @@ -4,13 +4,14 @@ import ( "encoding/json" "fmt" - "github.com/databricks/databricks-sdk-go/service/workspace" + secrets "github.com/databricks/cli/libs/sdktypes/secrets/v1" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) SecretsCreateScope(req Request) Response { defer s.LockUnlock()() - var request workspace.CreateScope + var request secrets.CreateScopeRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -19,36 +20,36 @@ func (s *FakeWorkspace) SecretsCreateScope(req Request) Response { } // Check if scope already exists - if _, exists := s.SecretScopes[request.Scope]; exists { + if _, exists := s.SecretScopes[utils.Deref(request.Scope)]; exists { return Response{ StatusCode: 400, - Body: map[string]string{"message": fmt.Sprintf("Scope %s already exists", request.Scope)}, + Body: map[string]string{"message": fmt.Sprintf("Scope %s already exists", utils.Deref(request.Scope))}, } } // Create the scope backendType := request.ScopeBackendType if backendType == "" { - backendType = workspace.ScopeBackendTypeDatabricks + backendType = secrets.ScopeBackendType_Databricks } - scope := workspace.SecretScope{ + scope := secrets.SecretScope{ Name: request.Scope, BackendType: backendType, KeyvaultMetadata: request.BackendAzureKeyvault, } - s.SecretScopes[request.Scope] = scope + s.SecretScopes[utils.Deref(request.Scope)] = scope // Automatically grant MANAGE permission to the creator (current user) // This matches real Databricks behavior if s.Acls == nil { - s.Acls = make(map[string][]workspace.AclItem) + s.Acls = make(map[string][]secrets.AclItem) } - s.Acls[request.Scope] = []workspace.AclItem{ + s.Acls[utils.Deref(request.Scope)] = []secrets.AclItem{ { Principal: s.CurrentUser().UserName, - Permission: workspace.AclPermissionManage, + Permission: secrets.AclPermission_Manage, }, } @@ -58,13 +59,13 @@ func (s *FakeWorkspace) SecretsCreateScope(req Request) Response { func (s *FakeWorkspace) SecretsListScopes(req Request) Response { defer s.LockUnlock()() - scopes := make([]workspace.SecretScope, 0, len(s.SecretScopes)) + scopes := make([]secrets.SecretScope, 0, len(s.SecretScopes)) for _, scope := range s.SecretScopes { scopes = append(scopes, scope) } return Response{ - Body: workspace.ListScopesResponse{ + Body: secrets.ListScopesResponse{ Scopes: scopes, }, } @@ -73,7 +74,7 @@ func (s *FakeWorkspace) SecretsListScopes(req Request) Response { func (s *FakeWorkspace) SecretsDeleteScope(req Request) Response { defer s.LockUnlock()() - var request workspace.DeleteScope + var request secrets.DeleteScopeRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -81,17 +82,17 @@ func (s *FakeWorkspace) SecretsDeleteScope(req Request) Response { } } - if _, exists := s.SecretScopes[request.Scope]; !exists { + if _, exists := s.SecretScopes[utils.Deref(request.Scope)]; !exists { return Response{ StatusCode: 404, - Body: map[string]string{"message": fmt.Sprintf("Scope %s does not exist", request.Scope)}, + Body: map[string]string{"message": fmt.Sprintf("Scope %s does not exist", utils.Deref(request.Scope))}, } } - delete(s.SecretScopes, request.Scope) + delete(s.SecretScopes, utils.Deref(request.Scope)) // Also delete ACLs and secrets for this scope - delete(s.Acls, request.Scope) - delete(s.Secrets, request.Scope) + delete(s.Acls, utils.Deref(request.Scope)) + delete(s.Secrets, utils.Deref(request.Scope)) return Response{} } @@ -111,11 +112,11 @@ func (s *FakeWorkspace) SecretsListAcls(req Request) Response { acls := s.Acls[scope] if acls == nil { - acls = []workspace.AclItem{} + acls = []secrets.AclItem{} } return Response{ - Body: workspace.ListAclsResponse{ + Body: secrets.ListAclsResponse{ Items: acls, }, } diff --git a/libs/testserver/secrets.go b/libs/testserver/secrets.go index c86122c54ec..51fe62a17f9 100644 --- a/libs/testserver/secrets.go +++ b/libs/testserver/secrets.go @@ -6,13 +6,28 @@ import ( "fmt" "slices" - "github.com/databricks/databricks-sdk-go/service/workspace" + secrets "github.com/databricks/cli/libs/sdktypes/secrets/v1" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) SecretsPut(req Request) Response { defer s.LockUnlock()() - var request workspace.PutSecret + // bytes_value arrives base64-encoded; reject malformed input the way the + // API does instead of failing to decode the request. + var raw struct { + BytesValue string `json:"bytes_value"` + } + if err := json.Unmarshal(req.Body, &raw); err == nil && raw.BytesValue != "" { + if _, err := base64.StdEncoding.DecodeString(raw.BytesValue); err != nil { + return Response{ + StatusCode: 400, + Body: map[string]string{"error_code": "INVALID_PARAMETER_VALUE", "message": "bytes_value must be base64-encoded"}, + } + } + } + + var request secrets.PutSecretRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -21,35 +36,28 @@ func (s *FakeWorkspace) SecretsPut(req Request) Response { } // Check if scope exists - if _, exists := s.SecretScopes[request.Scope]; !exists { + if _, exists := s.SecretScopes[utils.Deref(request.Scope)]; !exists { return Response{ StatusCode: 404, - Body: map[string]string{"message": fmt.Sprintf("Scope %s does not exist", request.Scope)}, + Body: map[string]string{"message": fmt.Sprintf("Scope %s does not exist", utils.Deref(request.Scope))}, } } if s.Secrets == nil { s.Secrets = make(map[string]map[string]string) } - if s.Secrets[request.Scope] == nil { - s.Secrets[request.Scope] = make(map[string]string) + if s.Secrets[utils.Deref(request.Scope)] == nil { + s.Secrets[utils.Deref(request.Scope)] = make(map[string]string) } - // Exactly one of string_value / bytes_value is set. bytes_value arrives - // already base64-encoded, and GET returns whatever was stored re-encoded, - // so decode it here to keep the stored form the raw secret in both cases. - value := request.StringValue - if request.BytesValue != "" { - decoded, err := base64.StdEncoding.DecodeString(request.BytesValue) - if err != nil { - return Response{ - StatusCode: 400, - Body: map[string]string{"error_code": "INVALID_PARAMETER_VALUE", "message": "bytes_value must be base64-encoded"}, - } - } - value = string(decoded) + // Exactly one of string_value / bytes_value is set. bytes_value was decoded + // from base64 with the request and GET re-encodes whatever was stored, so the + // stored form is the raw secret in both cases. + value := utils.Deref(request.StringValue) + if len(request.BytesValue) > 0 { + value = string(request.BytesValue) } - s.Secrets[request.Scope][request.Key] = value + s.Secrets[utils.Deref(request.Scope)][utils.Deref(request.Key)] = value return Response{} } @@ -74,14 +82,14 @@ func (s *FakeWorkspace) SecretsList(req Request) Response { } slices.Sort(keys) - secrets := make([]workspace.SecretMetadata, 0, len(keys)) + list := make([]secrets.SecretMetadata, 0, len(keys)) for _, key := range keys { - secrets = append(secrets, workspace.SecretMetadata{Key: key}) + list = append(list, secrets.SecretMetadata{Key: utils.NonZero(key)}) } return Response{ - Body: workspace.ListSecretsResponse{ - Secrets: secrets, + Body: secrets.ListSecretsResponse{ + Secrets: list, }, } } @@ -116,13 +124,11 @@ func (s *FakeWorkspace) SecretsGet(req Request) Response { } } - // Base64 encode the secret value, to match the server side behavior. - encodedValue := base64.StdEncoding.EncodeToString([]byte(secretValue)) - + // encoding/json base64-encodes []byte, matching the server side behavior. return Response{ - Body: workspace.GetSecretResponse{ - Key: key, - Value: encodedValue, + Body: secrets.GetSecretResponse{ + Key: utils.NonZero(key), + Value: []byte(secretValue), }, } } diff --git a/libs/testserver/secrets_acls.go b/libs/testserver/secrets_acls.go index 0d4cb2a5c8d..c89cb6e40dd 100644 --- a/libs/testserver/secrets_acls.go +++ b/libs/testserver/secrets_acls.go @@ -4,7 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/databricks/databricks-sdk-go/service/workspace" + secrets "github.com/databricks/cli/libs/sdktypes/secrets/v1" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) SecretsAclsGet(req Request) Response { @@ -14,7 +15,7 @@ func (s *FakeWorkspace) SecretsAclsGet(req Request) Response { principal := req.URL.Query().Get("principal") for _, acl := range s.Acls[scope] { - if acl.Principal == principal { + if utils.Deref(acl.Principal) == principal { return Response{Body: acl} } } @@ -24,7 +25,7 @@ func (s *FakeWorkspace) SecretsAclsGet(req Request) Response { func (s *FakeWorkspace) SecretsAclsPut(req Request) Response { defer s.LockUnlock()() - var request workspace.PutAcl + var request secrets.PutAclRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -33,10 +34,10 @@ func (s *FakeWorkspace) SecretsAclsPut(req Request) Response { } // If the ACL already exists, update it in place - scopeAcls := s.Acls[request.Scope] + scopeAcls := s.Acls[utils.Deref(request.Scope)] for i, acl := range scopeAcls { - if acl.Principal == request.Principal { - s.Acls[request.Scope][i] = workspace.AclItem{ + if utils.Deref(acl.Principal) == utils.Deref(request.Principal) { + s.Acls[utils.Deref(request.Scope)][i] = secrets.AclItem{ Principal: request.Principal, Permission: request.Permission, } @@ -45,7 +46,7 @@ func (s *FakeWorkspace) SecretsAclsPut(req Request) Response { } // Otherwise, add a new ACL - s.Acls[request.Scope] = append(s.Acls[request.Scope], workspace.AclItem{ + s.Acls[utils.Deref(request.Scope)] = append(s.Acls[utils.Deref(request.Scope)], secrets.AclItem{ Principal: request.Principal, Permission: request.Permission, }) @@ -55,7 +56,7 @@ func (s *FakeWorkspace) SecretsAclsPut(req Request) Response { func (s *FakeWorkspace) SecretsAclsDelete(req Request) Response { defer s.LockUnlock()() - var request workspace.DeleteAcl + var request secrets.DeleteAclRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ Body: fmt.Sprintf("internal error: %s", err), @@ -63,10 +64,10 @@ func (s *FakeWorkspace) SecretsAclsDelete(req Request) Response { } } - scopeAcls := s.Acls[request.Scope] + scopeAcls := s.Acls[utils.Deref(request.Scope)] for i, acl := range scopeAcls { - if acl.Principal == request.Principal { - s.Acls[request.Scope] = append(scopeAcls[:i], scopeAcls[i+1:]...) + if utils.Deref(acl.Principal) == utils.Deref(request.Principal) { + s.Acls[utils.Deref(request.Scope)] = append(scopeAcls[:i], scopeAcls[i+1:]...) return Response{} } } diff --git a/libs/testserver/serving_endpoints.go b/libs/testserver/serving_endpoints.go index efa10d47463..05c223b933e 100644 --- a/libs/testserver/serving_endpoints.go +++ b/libs/testserver/serving_endpoints.go @@ -6,15 +6,16 @@ import ( "maps" "slices" - "github.com/databricks/databricks-sdk-go/service/serving" + serving "github.com/databricks/cli/libs/sdktypes/modelserving/v1" + "github.com/databricks/cli/libs/utils" ) -func servedEntitiesInputToOutput(input []serving.ServedEntityInput) []serving.ServedEntityOutput { - entities := make([]serving.ServedEntityOutput, len(input)) +func servedEntitiesInputToOutput(input []serving.ServedModel) []serving.ServedModel { + entities := make([]serving.ServedModel, len(input)) for i, entity := range input { // Mirror the backend: burst_scaling_enabled is not echoed on GET (not // copied here) and external_model secrets are never returned in plaintext. - entities[i] = serving.ServedEntityOutput{ + entities[i] = serving.ServedModel{ EntityName: entity.EntityName, EntityVersion: entity.EntityVersion, EnvironmentVars: entity.EnvironmentVars, @@ -28,8 +29,6 @@ func servedEntitiesInputToOutput(input []serving.ServedEntityInput) []serving.Se ProvisionedModelUnits: entity.ProvisionedModelUnits, ScaleToZeroEnabled: entity.ScaleToZeroEnabled, WorkloadSize: entity.WorkloadSize, - WorkloadType: entity.WorkloadType, - ForceSendFields: entity.ForceSendFields, } } return entities @@ -40,20 +39,20 @@ func applyTelemetryConfig(previous, config *serving.TelemetryConfig) *serving.Te if config == nil { return nil } - if config.TableNames == nil && config.TelemetryProfileId == "" { + if config.TableNames == nil && utils.Deref(config.TelemetryProfileId) == "" { return previous } applied := serving.TelemetryConfig{TelemetryProfileId: config.TelemetryProfileId} - if applied.TelemetryProfileId == "" { + if utils.Deref(applied.TelemetryProfileId) == "" { // Do not reuse previous: table_names provisions a new profile. - applied.TelemetryProfileId = nextUUID() + applied.TelemetryProfileId = utils.NonZero(nextUUID()) } if config.InferenceTableConfig != nil { inferenceTable := *config.InferenceTableConfig // The backend names the payload table after the logs table it was given. if config.TableNames != nil { - inferenceTable.Name = config.TableNames.LogsTable + "_payload" + inferenceTable.Name = utils.NonZero(utils.Deref(config.TableNames.LogsTable) + "_payload") } applied.InferenceTableConfig = &inferenceTable } @@ -62,12 +61,12 @@ func applyTelemetryConfig(previous, config *serving.TelemetryConfig) *serving.Te } // telemetrySupported returns the unsupported endpoint type when telemetry cannot be applied. -func telemetrySupported(endpoint serving.ServingEndpointDetailed) (string, bool) { +func telemetrySupported(endpoint serving.InferenceEndpointDetailed) (string, bool) { if endpoint.Config == nil || len(endpoint.Config.ServedEntities) == 0 { return "NO_CONFIG", false } for _, entity := range endpoint.Config.ServedEntities { - if entity.ExternalModel == nil && entity.EntityName != "" { + if entity.ExternalModel == nil && utils.Deref(entity.EntityName) != "" { return "", true } } @@ -83,67 +82,67 @@ func clearExternalModelSecrets(em *serving.ExternalModel) *serving.ExternalModel out := *em if c := out.Ai21labsConfig; c != nil { cc := *c - cc.Ai21labsApiKeyPlaintext = "" + cc.Ai21labsApiKeyPlaintext = nil out.Ai21labsConfig = &cc } if c := out.AmazonBedrockConfig; c != nil { cc := *c - cc.AwsAccessKeyIdPlaintext = "" - cc.AwsSecretAccessKeyPlaintext = "" + cc.AwsAccessKeyIdPlaintext = nil + cc.AwsSecretAccessKeyPlaintext = nil out.AmazonBedrockConfig = &cc } if c := out.AnthropicConfig; c != nil { cc := *c - cc.AnthropicApiKeyPlaintext = "" + cc.AnthropicApiKeyPlaintext = nil out.AnthropicConfig = &cc } if c := out.CohereConfig; c != nil { cc := *c - cc.CohereApiKeyPlaintext = "" + cc.CohereApiKeyPlaintext = nil out.CohereConfig = &cc } if c := out.CustomProviderConfig; c != nil { cc := *c if a := cc.ApiKeyAuth; a != nil { aa := *a - aa.ValuePlaintext = "" + aa.ValuePlaintext = nil cc.ApiKeyAuth = &aa } if b := cc.BearerTokenAuth; b != nil { bb := *b - bb.TokenPlaintext = "" + bb.TokenPlaintext = nil cc.BearerTokenAuth = &bb } out.CustomProviderConfig = &cc } if c := out.DatabricksModelServingConfig; c != nil { cc := *c - cc.DatabricksApiTokenPlaintext = "" + cc.DatabricksApiTokenPlaintext = nil out.DatabricksModelServingConfig = &cc } if c := out.GoogleCloudVertexAiConfig; c != nil { cc := *c - cc.PrivateKeyPlaintext = "" + cc.PrivateKeyPlaintext = nil out.GoogleCloudVertexAiConfig = &cc } if c := out.OpenaiConfig; c != nil { cc := *c - cc.OpenaiApiKeyPlaintext = "" - cc.MicrosoftEntraClientSecretPlaintext = "" + cc.OpenaiApiKeyPlaintext = nil + cc.MicrosoftEntraClientSecretPlaintext = nil out.OpenaiConfig = &cc } if c := out.PalmConfig; c != nil { cc := *c - cc.PalmApiKeyPlaintext = "" + cc.PalmApiKeyPlaintext = nil out.PalmConfig = &cc } return &out } -func servedModelsInputToOutput(input []serving.ServedModelInput) []serving.ServedModelOutput { - models := make([]serving.ServedModelOutput, len(input)) +func servedModelsInputToOutput(input []serving.ServedModel) []serving.ServedModel { + models := make([]serving.ServedModel, len(input)) for i, model := range input { - models[i] = serving.ServedModelOutput{ + models[i] = serving.ServedModel{ ModelName: model.ModelName, ModelVersion: model.ModelVersion, EnvironmentVars: model.EnvironmentVars, @@ -153,8 +152,6 @@ func servedModelsInputToOutput(input []serving.ServedModelInput) []serving.Serve ProvisionedModelUnits: model.ProvisionedModelUnits, ScaleToZeroEnabled: model.ScaleToZeroEnabled, WorkloadSize: model.WorkloadSize, - WorkloadType: serving.ServingModelWorkloadType(model.WorkloadType), - ForceSendFields: model.ForceSendFields, } } return models @@ -171,10 +168,10 @@ func defaultTrafficConfig(config *serving.EndpointCoreConfigOutput) { } var names []string for _, e := range config.ServedEntities { - names = append(names, e.Name) + names = append(names, utils.Deref(e.Name)) } for _, m := range config.ServedModels { - names = append(names, m.Name) + names = append(names, utils.Deref(m.Name)) } // The backend requires an explicit traffic_config when there is more than one // served entity, so only the single-entity default is well-defined here. @@ -183,9 +180,9 @@ func defaultTrafficConfig(config *serving.EndpointCoreConfigOutput) { } config.TrafficConfig = &serving.TrafficConfig{ Routes: []serving.Route{{ - ServedEntityName: names[0], - ServedModelName: names[0], - TrafficPercentage: 100, + ServedEntityName: utils.NonZero(names[0]), + ServedModelName: utils.NonZero(names[0]), + TrafficPercentage: utils.NonZero(100), }}, } } @@ -194,20 +191,19 @@ func defaultTrafficConfig(config *serving.EndpointCoreConfigOutput) { // the production conversion until callers migrate to AI Gateway inference tables. // //nolint:staticcheck // SA1019: deprecated AutoCaptureConfig{Input,Output} kept for bundle config compatibility -func autoCaptureConfigInputToOutput(input *serving.AutoCaptureConfigInput) *serving.AutoCaptureConfigOutput { - return &serving.AutoCaptureConfigOutput{ +func autoCaptureConfigInputToOutput(input *serving.AutoCaptureConfig) *serving.AutoCaptureConfig { + return &serving.AutoCaptureConfig{ CatalogName: input.CatalogName, SchemaName: input.SchemaName, TableNamePrefix: input.TableNamePrefix, Enabled: input.Enabled, - ForceSendFields: input.ForceSendFields, } } func (s *FakeWorkspace) ServingEndpointCreate(req Request) Response { defer s.LockUnlock()() - var createReq serving.CreateServingEndpoint + var createReq serving.CreateInferenceEndpointRequest err := json.Unmarshal(req.Body, &createReq) if err != nil { return Response{ @@ -217,10 +213,10 @@ func (s *FakeWorkspace) ServingEndpointCreate(req Request) Response { } // Check if endpoint with this name already exists - if _, exists := s.ServingEndpoints[createReq.Name]; exists { + if _, exists := s.ServingEndpoints[utils.Deref(createReq.Name)]; exists { return Response{ StatusCode: 409, - Body: map[string]string{"error_code": "RESOURCE_ALREADY_EXISTS", "message": fmt.Sprintf("Serving endpoint with name %s already exists", createReq.Name)}, + Body: map[string]string{"error_code": "RESOURCE_ALREADY_EXISTS", "message": fmt.Sprintf("Serving endpoint with name %s already exists", utils.Deref(createReq.Name))}, } } @@ -250,28 +246,27 @@ func (s *FakeWorkspace) ServingEndpointCreate(req Request) Response { } now := nowMilli() - endpoint := serving.ServingEndpointDetailed{ - AiGateway: createReq.AiGateway, - BudgetPolicyId: createReq.BudgetPolicyId, - Config: config, - CreationTimestamp: now, - Creator: s.CurrentUser().UserName, - Description: createReq.Description, + endpoint := serving.InferenceEndpointDetailed{ + AiGateway: createReq.AiGateway, + BudgetPolicyId: createReq.BudgetPolicyId, + Config: config, + CreationTimestamp: utils.NonZero(now), + Creator: s.CurrentUser().UserName, + // The real backend always echoes description (as "" when unset) and + // route_optimized back on GET. + Description: new(utils.Deref(createReq.Description)), EmailNotifications: createReq.EmailNotifications, - Id: nextUUID(), - LastUpdatedTimestamp: now, + Id: utils.NonZero(nextUUID()), + LastUpdatedTimestamp: utils.NonZero(now), Name: createReq.Name, - PermissionLevel: serving.ServingEndpointDetailedPermissionLevelCanManage, - RouteOptimized: createReq.RouteOptimized, + PermissionLevel: serving.ServingEndpointDetailedPermissionLevel_CanManage, + RouteOptimized: new(utils.Deref(createReq.RouteOptimized)), Tags: createReq.Tags, TelemetryConfig: applyTelemetryConfig(nil, createReq.TelemetryConfig), - State: &serving.EndpointState{ - ConfigUpdate: serving.EndpointStateConfigUpdateNotUpdating, - Ready: serving.EndpointStateReadyNotReady, + State: &serving.InferenceEndpointState{ + ConfigUpdate: serving.InferenceEndpointState_ConfigUpdateState_NotUpdating, + Ready: serving.InferenceEndpointState_ReadyState_NotReady, }, - // Force-send Description so an empty value serializes as "", matching the - // real backend which always echoes the field back on GET. - ForceSendFields: append(createReq.ForceSendFields, "PermissionLevel", "RouteOptimized", "Description"), } // Create drops unsupported telemetry, while the telemetry API rejects it. @@ -279,7 +274,7 @@ func (s *FakeWorkspace) ServingEndpointCreate(req Request) Response { endpoint.TelemetryConfig = nil } - s.ServingEndpoints[createReq.Name] = endpoint + s.ServingEndpoints[utils.Deref(createReq.Name)] = endpoint return Response{ Body: endpoint, @@ -301,8 +296,8 @@ func (s *FakeWorkspace) ServingEndpointGet(name string) Response { if endpointUpdating(endpoint) { // This response stays IN_PROGRESS; settle the stored copy for the next read. settled := endpoint - settled.State = &serving.EndpointState{ - ConfigUpdate: serving.EndpointStateConfigUpdateNotUpdating, + settled.State = &serving.InferenceEndpointState{ + ConfigUpdate: serving.InferenceEndpointState_ConfigUpdateState_NotUpdating, Ready: endpoint.State.Ready, } s.ServingEndpoints[name] = settled @@ -312,14 +307,14 @@ func (s *FakeWorkspace) ServingEndpointGet(name string) Response { } // endpointUpdating reports whether a config update is in progress. -func endpointUpdating(endpoint serving.ServingEndpointDetailed) bool { - return endpoint.State != nil && endpoint.State.ConfigUpdate == serving.EndpointStateConfigUpdateInProgress +func endpointUpdating(endpoint serving.InferenceEndpointDetailed) bool { + return endpoint.State != nil && endpoint.State.ConfigUpdate == serving.InferenceEndpointState_ConfigUpdateState_InProgress } func (s *FakeWorkspace) ServingEndpointUpdate(req Request, name string) Response { defer s.LockUnlock()() - var updateReq serving.EndpointCoreConfigInput + var updateReq serving.EndpointCoreConfig err := json.Unmarshal(req.Body, &updateReq) if err != nil { return Response{ @@ -362,11 +357,11 @@ func (s *FakeWorkspace) ServingEndpointUpdate(req Request, name string) Response } endpoint.Config = config - endpoint.LastUpdatedTimestamp = nowMilli() + endpoint.LastUpdatedTimestamp = utils.NonZero(nowMilli()) // Keep the update in progress until GET observes it. - endpoint.State = &serving.EndpointState{ - ConfigUpdate: serving.EndpointStateConfigUpdateInProgress, - Ready: serving.EndpointStateReadyNotReady, + endpoint.State = &serving.InferenceEndpointState{ + ConfigUpdate: serving.InferenceEndpointState_ConfigUpdateState_InProgress, + Ready: serving.InferenceEndpointState_ReadyState_NotReady, } s.ServingEndpoints[name] = endpoint @@ -379,7 +374,7 @@ func (s *FakeWorkspace) ServingEndpointUpdate(req Request, name string) Response func (s *FakeWorkspace) ServingEndpointPutAiGateway(req Request, name string) Response { defer s.LockUnlock()() - var putReq serving.PutAiGatewayRequest + var putReq serving.PutInferenceEndpointAiGatewayRequest err := json.Unmarshal(req.Body, &putReq) if err != nil { return Response{ @@ -420,7 +415,7 @@ func (s *FakeWorkspace) ServingEndpointPutAiGateway(req Request, name string) Re func (s *FakeWorkspace) ServingEndpointUpdateNotifications(req Request, name string) Response { defer s.LockUnlock()() - var updateReq serving.UpdateInferenceEndpointNotifications + var updateReq serving.UpdateInferenceEndpointNotificationsRequest err := json.Unmarshal(req.Body, &updateReq) if err != nil { return Response{ @@ -449,7 +444,7 @@ func (s *FakeWorkspace) ServingEndpointUpdateNotifications(req Request, name str func (s *FakeWorkspace) ServingEndpointPatchTelemetryConfig(req Request, name string) Response { defer s.LockUnlock()() - var patchReq serving.PatchTelemetryConfigRequest + var patchReq serving.PatchInferenceEndpointTelemetryConfigRequest err := json.Unmarshal(req.Body, &patchReq) if err != nil { return Response{ @@ -489,7 +484,7 @@ func (s *FakeWorkspace) ServingEndpointPatchTelemetryConfig(req Request, name st // An omitted telemetry_config removes the configuration from the endpoint. endpoint.TelemetryConfig = applyTelemetryConfig(endpoint.TelemetryConfig, patchReq.TelemetryConfig) - endpoint.LastUpdatedTimestamp = nowMilli() + endpoint.LastUpdatedTimestamp = utils.NonZero(nowMilli()) s.ServingEndpoints[name] = endpoint return Response{ @@ -500,7 +495,7 @@ func (s *FakeWorkspace) ServingEndpointPatchTelemetryConfig(req Request, name st func (s *FakeWorkspace) ServingEndpointPatchTags(req Request, name string) Response { defer s.LockUnlock()() - var patchReq serving.PatchServingEndpointTags + var patchReq serving.PatchInferenceEndpointTagsRequest err := json.Unmarshal(req.Body, &patchReq) if err != nil { return Response{ @@ -520,12 +515,12 @@ func (s *FakeWorkspace) ServingEndpointPatchTags(req Request, name string) Respo // Build map of current tags tagMap := make(map[string]string) for _, tag := range endpoint.Tags { - tagMap[tag.Key] = tag.Value + tagMap[utils.Deref(tag.Key)] = utils.Deref(tag.Value) } // Add or update tags for _, tag := range patchReq.AddTags { - tagMap[tag.Key] = tag.Value + tagMap[utils.Deref(tag.Key)] = utils.Deref(tag.Value) } // Delete tags @@ -537,7 +532,7 @@ func (s *FakeWorkspace) ServingEndpointPatchTags(req Request, name string) Respo tags := make([]serving.EndpointTag, 0, len(tagMap)) keys := slices.Sorted(maps.Keys(tagMap)) for _, key := range keys { - tags = append(tags, serving.EndpointTag{Key: key, Value: tagMap[key]}) + tags = append(tags, serving.EndpointTag{Key: utils.NonZero(key), Value: utils.NonZero(tagMap[key])}) } endpoint.Tags = tags @@ -545,7 +540,7 @@ func (s *FakeWorkspace) ServingEndpointPatchTags(req Request, name string) Respo // Return the tags as EndpointTags struct, not as array return Response{ - Body: serving.EndpointTags{ + Body: serving.PatchInferenceEndpointTagsResponse{ Tags: tags, }, } diff --git a/libs/testserver/sql_warehouses.go b/libs/testserver/sql_warehouses.go index 7f36ace72fc..8b21f933d14 100644 --- a/libs/testserver/sql_warehouses.go +++ b/libs/testserver/sql_warehouses.go @@ -5,26 +5,27 @@ import ( "fmt" "net/http" - "github.com/databricks/databricks-sdk-go/service/sql" + warehouses "github.com/databricks/cli/libs/sdktypes/warehouses/v1" + "github.com/databricks/cli/libs/sqllegacy" + "github.com/databricks/cli/libs/utils" ) -func sqlWarehouseFixUps(warehouse *sql.GetWarehouseResponse, userName string) { - if warehouse.CreatorName == "" { - warehouse.CreatorName = userName +func sqlWarehouseFixUps(warehouse *warehouses.GetWarehouseResponse, userName string) { + if utils.Deref(warehouse.CreatorName) == "" { + warehouse.CreatorName = utils.NonZero(userName) } - if warehouse.MinNumClusters == 0 { - warehouse.MinNumClusters = 1 - warehouse.ForceSendFields = append(warehouse.ForceSendFields, "MinNumClusters") + if utils.Deref(warehouse.MinNumClusters) == 0 { + warehouse.MinNumClusters = new(1) } if warehouse.WarehouseType == "" { - warehouse.WarehouseType = sql.GetWarehouseResponseWarehouseTypeClassic + warehouse.WarehouseType = warehouses.WarehouseType_Classic } } func (s *FakeWorkspace) SqlWarehousesUpsert(req Request, warehouseId string) Response { - var warehouse sql.GetWarehouseResponse + var warehouse warehouses.GetWarehouseResponse if err := json.Unmarshal(req.Body, &warehouse); err != nil { return Response{ @@ -45,12 +46,12 @@ func (s *FakeWorkspace) SqlWarehousesUpsert(req Request, warehouseId string) Res } else { warehouseId = nextUUID() } - warehouse.Id = warehouseId - if warehouse.Name == "" { - warehouse.Name = warehouseId + warehouse.Id = utils.NonZero(warehouseId) + if utils.Deref(warehouse.Name) == "" { + warehouse.Name = utils.NonZero(warehouseId) } - warehouse.State = sql.StateRunning - sqlWarehouseFixUps(&warehouse, s.CurrentUser().UserName) + warehouse.State = warehouses.EndpointState_Running + sqlWarehouseFixUps(&warehouse, utils.Deref(s.CurrentUser().UserName)) s.SqlWarehouses[warehouseId] = warehouse return Response{ @@ -67,7 +68,7 @@ func (s *FakeWorkspace) SqlWarehousesStart(req Request, warehouseId string) Resp return Response{StatusCode: 404} } - warehouse.State = sql.StateRunning + warehouse.State = warehouses.EndpointState_Running s.SqlWarehouses[warehouseId] = warehouse return Response{} @@ -81,35 +82,35 @@ func (s *FakeWorkspace) SqlWarehousesStop(req Request, warehouseId string) Respo return Response{StatusCode: 404} } - warehouse.State = sql.StateStopped + warehouse.State = warehouses.EndpointState_Stopped s.SqlWarehouses[warehouseId] = warehouse return Response{} } func (s *FakeWorkspace) SqlWarehousesList(req Request) Response { - var warehouses []sql.EndpointInfo + var list []warehouses.EndpointInfo for _, warehouse := range s.SqlWarehouses { - warehouses = append(warehouses, sql.EndpointInfo{ + list = append(list, warehouses.EndpointInfo{ Id: warehouse.Id, Name: warehouse.Name, }) } return Response{ StatusCode: 200, - Body: sql.ListWarehousesResponse{ - Warehouses: warehouses, + Body: warehouses.ListWarehousesResponse{ + Warehouses: list, }, } } func (s *FakeWorkspace) SqlDataSourcesList(req Request) Response { - var dataSources []sql.DataSource + var dataSources []sqllegacy.DataSource for key, warehouse := range s.SqlWarehouses { - dataSources = append(dataSources, sql.DataSource{ + dataSources = append(dataSources, sqllegacy.DataSource{ Id: key, Name: "test_data_source", - WarehouseId: warehouse.Id, + WarehouseId: utils.Deref(warehouse.Id), }) } return Response{ diff --git a/libs/testserver/statements.go b/libs/testserver/statements.go index 6389e693a8b..56c12732d67 100644 --- a/libs/testserver/statements.go +++ b/libs/testserver/statements.go @@ -7,8 +7,10 @@ import ( "regexp" "strconv" + statementexecution "github.com/databricks/cli/libs/sdktypes/statementexecution/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/testserver/testsql" - "github.com/databricks/databricks-sdk-go/service/sql" ) // HandleSQL registers a matcher that runs fn when a submitted statement equals @@ -27,11 +29,11 @@ func (s *Server) HandleSQLPattern(re *regexp.Regexp, fn func(testsql.Request) te // terminates as FAILED comes back as HTTP 200 with state=FAILED; the engine // builds that response and this HTTP layer is just transport. func (s *Server) sqlExecuteStatement(req Request) any { - var r sql.ExecuteStatementRequest + var r statementexecution.ExecuteStatementRequest if err := json.Unmarshal(req.Body, &r); err != nil { return Response{StatusCode: http.StatusBadRequest, Body: fmt.Sprintf("invalid execute statement request: %s", err)} } - return s.sqlHandler.Submit(r.Statement, r.WaitTimeout, r.Parameters) + return s.sqlHandler.Submit(utils.Deref(r.Statement), utils.Deref(r.WaitTimeout), r.Parameters) } // sqlGetStatement handles GET /api/2.0/sql/statements/{statement_id}. diff --git a/libs/testserver/statements_test.go b/libs/testserver/statements_test.go index 5552f64f558..9f940eb3e93 100644 --- a/libs/testserver/statements_test.go +++ b/libs/testserver/statements_test.go @@ -5,18 +5,20 @@ import ( "regexp" "testing" + statementexecution "github.com/databricks/cli/libs/sdktypes/statementexecution/v1" + "github.com/databricks/cli/libs/utils" + "github.com/databricks/cli/libs/testserver/testsql" - "github.com/databricks/databricks-sdk-go/service/sql" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) // submitSQL runs a statement through the POST handler and returns the response. -func submitSQL(t *testing.T, server *Server, statement string) *sql.StatementResponse { +func submitSQL(t *testing.T, server *Server, statement string) *statementexecution.StatementResponse { t.Helper() - body, err := json.Marshal(sql.ExecuteStatementRequest{Statement: statement, WaitTimeout: "10s"}) + body, err := json.Marshal(statementexecution.ExecuteStatementRequest{Statement: utils.NonZero(statement), WaitTimeout: utils.NonZero("10s")}) require.NoError(t, err) - resp, ok := server.sqlExecuteStatement(Request{Body: body}).(*sql.StatementResponse) + resp, ok := server.sqlExecuteStatement(Request{Body: body}).(*statementexecution.StatementResponse) require.True(t, ok) return resp } @@ -30,9 +32,9 @@ func TestHandleSQL(t *testing.T) { resp := submitSQL(t, server, "SELECT 1 AS a") require.NotNil(t, resp.Status) - assert.Equal(t, sql.StatementStateSucceeded, resp.Status.State) + assert.Equal(t, statementexecution.StatementStatus_State_Succeeded, resp.Status.State) require.NotNil(t, resp.Result) - assert.Equal(t, [][]string{{"1"}}, resp.Result.DataArray) + assert.Equal(t, [][]string{{"1"}}, sqlRows(resp.Result.DataArray)) } func TestHandleSQLPattern(t *testing.T) { @@ -45,7 +47,18 @@ func TestHandleSQLPattern(t *testing.T) { resp := submitSQL(t, server, "SELECT 42") require.NotNil(t, resp.Status) - assert.Equal(t, sql.StatementStateSucceeded, resp.Status.State) + assert.Equal(t, statementexecution.StatementStatus_State_Succeeded, resp.Status.State) require.NotNil(t, resp.Result) - assert.Equal(t, [][]string{{"42"}}, resp.Result.DataArray) + assert.Equal(t, [][]string{{"42"}}, sqlRows(resp.Result.DataArray)) +} + +func sqlRows(data [][]json.RawMessage) [][]string { + out := make([][]string, len(data)) + for i, row := range data { + out[i] = make([]string, len(row)) + for j, cell := range row { + _ = json.Unmarshal(cell, &out[i][j]) + } + } + return out } diff --git a/libs/testserver/synced_database_tables.go b/libs/testserver/synced_database_tables.go index 13c81539909..7ee0c17c83c 100644 --- a/libs/testserver/synced_database_tables.go +++ b/libs/testserver/synced_database_tables.go @@ -4,7 +4,8 @@ import ( "encoding/json" "fmt" - "github.com/databricks/databricks-sdk-go/service/database" + database "github.com/databricks/cli/libs/sdktypes/database/v1" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) SyncedDatabaseTableCreate(req Request) Response { @@ -20,23 +21,23 @@ func (s *FakeWorkspace) SyncedDatabaseTableCreate(req Request) Response { } // check that the database instance exists if specified: - if syncedDatabaseTable.DatabaseInstanceName != "" { + if utils.Deref(syncedDatabaseTable.DatabaseInstanceName) != "" { found := false for _, instance := range s.DatabaseInstances { - if instance.Name == syncedDatabaseTable.DatabaseInstanceName { + if utils.Deref(instance.Name) == utils.Deref(syncedDatabaseTable.DatabaseInstanceName) { found = true break } } if !found { return Response{ - Body: fmt.Sprintf("database instance with name '%s' not found", syncedDatabaseTable.DatabaseInstanceName), + Body: fmt.Sprintf("database instance with name '%s' not found", utils.Deref(syncedDatabaseTable.DatabaseInstanceName)), StatusCode: 404, } } } - s.SyncedDatabaseTables[syncedDatabaseTable.Name] = syncedDatabaseTable + s.SyncedDatabaseTables[utils.Deref(syncedDatabaseTable.Name)] = syncedDatabaseTable return Response{ Body: syncedDatabaseTable, diff --git a/libs/testserver/testsql/testsql.go b/libs/testserver/testsql/testsql.go index 0d28785f40f..04358a990d8 100644 --- a/libs/testserver/testsql/testsql.go +++ b/libs/testserver/testsql/testsql.go @@ -14,12 +14,15 @@ package testsql import ( + "encoding/json" "fmt" "regexp" "strings" "sync" - "github.com/databricks/databricks-sdk-go/service/sql" + "github.com/databricks/cli/libs/utils" + + sql "github.com/databricks/cli/libs/sdktypes/statementexecution/v1" ) // asyncWaitTimeout is the WaitTimeout value that callers send to submit a @@ -37,7 +40,7 @@ type Request struct { // Handle matcher it is []string{Statement}. Match []string // Parameters are the bound :name parameters from the submit request. - Parameters []sql.StatementParameterListItem + Parameters []sql.StatementParameter } // Result is the declarative plan a matcher returns. The zero value is a @@ -136,7 +139,7 @@ func (h *Handler) HandlePattern(re *regexp.Regexp, fn func(Request) Result) { // and returns the first lifecycle response. A "0s" wait timeout always yields // PENDING; otherwise the response is terminal when the plan has no remaining // polls and PENDING otherwise. -func (h *Handler) Submit(statement, waitTimeout string, params []sql.StatementParameterListItem) *sql.StatementResponse { +func (h *Handler) Submit(statement, waitTimeout string, params []sql.StatementParameter) *sql.StatementResponse { h.mu.Lock() defer h.mu.Unlock() @@ -147,8 +150,8 @@ func (h *Handler) Submit(statement, waitTimeout string, params []sql.StatementPa if waitTimeout == asyncWaitTimeout || stmt.remainingPolls > 0 { return &sql.StatementResponse{ - StatementId: stmt.id, - Status: &sql.StatementStatus{State: sql.StatementStatePending}, + StatementId: &stmt.id, + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Pending}, } } return stmt.terminalResponse() @@ -169,15 +172,15 @@ func (h *Handler) Get(statementID string) *sql.StatementResponse { } if stmt.canceled { return &sql.StatementResponse{ - StatementId: stmt.id, - Status: &sql.StatementStatus{State: sql.StatementStateCanceled}, + StatementId: &stmt.id, + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Canceled}, } } if stmt.remainingPolls > 0 { stmt.remainingPolls-- return &sql.StatementResponse{ - StatementId: stmt.id, - Status: &sql.StatementStatus{State: sql.StatementStateRunning}, + StatementId: &stmt.id, + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Running}, } } return stmt.terminalResponse() @@ -193,7 +196,7 @@ func (h *Handler) Chunk(statementID string, chunkIndex int) *sql.ResultData { if stmt == nil || chunkIndex < 0 || chunkIndex >= len(stmt.chunks) { return nil } - return &sql.ResultData{DataArray: stmt.chunks[chunkIndex]} + return &sql.ResultData{DataArray: dataArray(stmt.chunks[chunkIndex])} } // Cancel marks the statement canceled. An unknown id is a no-op. @@ -210,9 +213,9 @@ func (h *Handler) Cancel(statementID string) { // statement. With no matching matcher the statement terminates as FAILED with // an "unsupported statement" error, mirroring how the real backend rejects a // statement it cannot run. -func (h *Handler) plan(stmt string, params []sql.StatementParameterListItem) *statement { +func (h *Handler) plan(stmt string, params []sql.StatementParameter) *statement { res := Result{Error: &Error{ - Code: sql.ServiceErrorCodeBadRequest, + Code: sql.ServiceErrorCode_BadRequest, Message: "unsupported statement: " + stmt, }} for _, m := range h.matchers { @@ -236,32 +239,32 @@ func (h *Handler) plan(stmt string, params []sql.StatementParameterListItem) *st func (s *statement) terminalResponse() *sql.StatementResponse { if s.err != nil { return &sql.StatementResponse{ - StatementId: s.id, + StatementId: &s.id, Status: &sql.StatementStatus{ - State: sql.StatementStateFailed, - SqlState: s.err.SQLState, - Error: &sql.ServiceError{ErrorCode: s.err.Code, Message: s.err.Message}, + State: sql.StatementStatus_State_Failed, + SqlState: utils.NonZero(s.err.SQLState), + Error: &sql.ServiceError{ErrorCode: s.err.Code, Message: utils.NonZero(s.err.Message)}, }, } } - manifest := &sql.ResultManifest{TotalChunkCount: len(s.chunks)} + manifest := &sql.ResultManifest{TotalChunkCount: utils.NonZero(len(s.chunks))} if len(s.columns) > 0 { cols := make([]sql.ColumnInfo, len(s.columns)) for i, name := range s.columns { - cols[i] = sql.ColumnInfo{Name: name} + cols[i] = sql.ColumnInfo{Name: utils.NonZero(name)} } - manifest.Schema = &sql.ResultSchema{Columns: cols} + manifest.Schema = &sql.Schema{Columns: cols} } // A no-row statement reports an empty result (matching the real API, which // returns "result": {} with no data_array); otherwise chunk 0 is inlined. result := &sql.ResultData{} if len(s.chunks) > 0 { - result.DataArray = s.chunks[0] + result.DataArray = dataArray(s.chunks[0]) } return &sql.StatementResponse{ - StatementId: s.id, - Status: &sql.StatementStatus{State: sql.StatementStateSucceeded}, + StatementId: &s.id, + Status: &sql.StatementStatus{State: sql.StatementStatus_State_Succeeded}, Manifest: manifest, Result: result, } @@ -285,3 +288,15 @@ func splitChunks(rows [][]string, chunks int) [][][]string { } return out } + +// dataArray encodes rows the way the API sends data_array: every cell a JSON string. +func dataArray(rows [][]string) [][]json.RawMessage { + out := make([][]json.RawMessage, len(rows)) + for i, row := range rows { + out[i] = make([]json.RawMessage, len(row)) + for j, cell := range row { + out[i][j], _ = json.Marshal(cell) + } + } + return out +} diff --git a/libs/testserver/testsql/testsql_test.go b/libs/testserver/testsql/testsql_test.go index 7c70d038218..a02d829a35f 100644 --- a/libs/testserver/testsql/testsql_test.go +++ b/libs/testserver/testsql/testsql_test.go @@ -1,11 +1,12 @@ package testsql_test import ( + "encoding/json" "regexp" "testing" + sql "github.com/databricks/cli/libs/sdktypes/statementexecution/v1" "github.com/databricks/cli/libs/testserver/testsql" - "github.com/databricks/databricks-sdk-go/service/sql" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -21,11 +22,11 @@ func TestExactDispatch(t *testing.T) { // Statement is trimmed before matching. resp := e.Submit(" SELECT 1 ", "10s", nil) require.NotNil(t, resp.Status) - assert.Equal(t, sql.StatementStateSucceeded, resp.Status.State) + assert.Equal(t, sql.StatementStatus_State_Succeeded, resp.Status.State) assert.Equal(t, "SELECT 1", seen.Statement) assert.Equal(t, []string{"SELECT 1"}, seen.Match) assert.Equal(t, []string{"a"}, columnNames(resp)) - assert.Equal(t, [][]string{{"1"}}, resp.Result.DataArray) + assert.Equal(t, [][]string{{"1"}}, rowsOf(resp.Result.DataArray)) } func TestPatternDispatchSubmatches(t *testing.T) { @@ -38,7 +39,7 @@ func TestPatternDispatchSubmatches(t *testing.T) { }) resp := e.Submit("CREATE TABLE foo", "10s", nil) - assert.Equal(t, sql.StatementStateSucceeded, resp.Status.State) + assert.Equal(t, sql.StatementStatus_State_Succeeded, resp.Status.State) assert.Equal(t, []string{"CREATE TABLE foo", "foo"}, seen.Match) } @@ -59,21 +60,21 @@ func TestUnsupportedStatement(t *testing.T) { e := testsql.New() resp := e.Submit("SELECT 1", "10s", nil) require.NotNil(t, resp.Status) - assert.Equal(t, sql.StatementStateFailed, resp.Status.State) + assert.Equal(t, sql.StatementStatus_State_Failed, resp.Status.State) require.NotNil(t, resp.Status.Error) - assert.Equal(t, sql.ServiceErrorCodeBadRequest, resp.Status.Error.ErrorCode) - assert.Contains(t, resp.Status.Error.Message, "unsupported statement") - assert.Contains(t, resp.Status.Error.Message, "SELECT 1") + assert.Equal(t, sql.ServiceErrorCode_BadRequest, resp.Status.Error.ErrorCode) + assert.Contains(t, *resp.Status.Error.Message, "unsupported statement") + assert.Contains(t, *resp.Status.Error.Message, "SELECT 1") } func TestWaitTimeout(t *testing.T) { tests := []struct { name string waitTimeout string - want sql.StatementState + want sql.StatementStatus_State }{ - {"async stays pending even without polls", "0s", sql.StatementStatePending}, - {"sync with no polls terminates", "10s", sql.StatementStateSucceeded}, + {"async stays pending even without polls", "0s", sql.StatementStatus_State_Pending}, + {"sync with no polls terminates", "10s", sql.StatementStatus_State_Succeeded}, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { @@ -94,16 +95,16 @@ func TestPollCountdown(t *testing.T) { }) resp := e.Submit("SELECT 1", "10s", nil) - require.Equal(t, sql.StatementStatePending, resp.Status.State) + require.Equal(t, sql.StatementStatus_State_Pending, resp.Status.State) - got := e.Get(resp.StatementId) - assert.Equal(t, sql.StatementStateRunning, got.Status.State) - got = e.Get(resp.StatementId) - assert.Equal(t, sql.StatementStateRunning, got.Status.State) + got := e.Get(*resp.StatementId) + assert.Equal(t, sql.StatementStatus_State_Running, got.Status.State) + got = e.Get(*resp.StatementId) + assert.Equal(t, sql.StatementStatus_State_Running, got.Status.State) - got = e.Get(resp.StatementId) - require.Equal(t, sql.StatementStateSucceeded, got.Status.State) - assert.Equal(t, [][]string{{"done"}}, got.Result.DataArray) + got = e.Get(*resp.StatementId) + require.Equal(t, sql.StatementStatus_State_Succeeded, got.Status.State) + assert.Equal(t, [][]string{{"done"}}, rowsOf(got.Result.DataArray)) } func TestChunkSplitting(t *testing.T) { @@ -114,21 +115,21 @@ func TestChunkSplitting(t *testing.T) { }) resp := e.Submit("SELECT * FROM big", "10s", nil) - require.Equal(t, sql.StatementStateSucceeded, resp.Status.State) + require.Equal(t, sql.StatementStatus_State_Succeeded, resp.Status.State) require.NotNil(t, resp.Manifest) - assert.Equal(t, 3, resp.Manifest.TotalChunkCount) + assert.Equal(t, 3, *resp.Manifest.TotalChunkCount) var all [][]string - all = append(all, resp.Result.DataArray...) - for i := 1; i < resp.Manifest.TotalChunkCount; i++ { - chunk := e.Chunk(resp.StatementId, i) + all = append(all, rowsOf(resp.Result.DataArray)...) + for i := 1; i < *resp.Manifest.TotalChunkCount; i++ { + chunk := e.Chunk(*resp.StatementId, i) require.NotNil(t, chunk) - all = append(all, chunk.DataArray...) + all = append(all, rowsOf(chunk.DataArray)...) } assert.Equal(t, rows, all) - assert.Equal(t, [][]string{{"0"}}, resp.Result.DataArray) - assert.Equal(t, [][]string{{"1"}}, e.Chunk(resp.StatementId, 1).DataArray) - assert.Equal(t, [][]string{{"2"}}, e.Chunk(resp.StatementId, 2).DataArray) + assert.Equal(t, [][]string{{"0"}}, rowsOf(resp.Result.DataArray)) + assert.Equal(t, [][]string{{"1"}}, rowsOf(e.Chunk(*resp.StatementId, 1).DataArray)) + assert.Equal(t, [][]string{{"2"}}, rowsOf(e.Chunk(*resp.StatementId, 2).DataArray)) } func TestNoRowsZeroChunks(t *testing.T) { @@ -140,9 +141,9 @@ func TestNoRowsZeroChunks(t *testing.T) { // A no-row statement reports zero chunks and an empty result, matching the // real API (a 0-row SELECT or a no-result-set DDL returns total_chunk_count=0). resp := e.Submit("CREATE TABLE foo", "10s", nil) - require.Equal(t, sql.StatementStateSucceeded, resp.Status.State) + require.Equal(t, sql.StatementStatus_State_Succeeded, resp.Status.State) require.NotNil(t, resp.Manifest) - assert.Equal(t, 0, resp.Manifest.TotalChunkCount) + assert.Nil(t, resp.Manifest.TotalChunkCount) assert.Nil(t, resp.Manifest.Schema) require.NotNil(t, resp.Result) assert.Empty(t, resp.Result.DataArray) @@ -152,18 +153,18 @@ func TestErrorResult(t *testing.T) { e := testsql.New() e.Handle("SELECT 1", func(testsql.Request) testsql.Result { return testsql.Result{Error: &testsql.Error{ - Code: sql.ServiceErrorCodeBadRequest, + Code: sql.ServiceErrorCode_BadRequest, Message: "no such table", SQLState: "42P01", }} }) resp := e.Submit("SELECT 1", "10s", nil) - require.Equal(t, sql.StatementStateFailed, resp.Status.State) - assert.Equal(t, "42P01", resp.Status.SqlState) + require.Equal(t, sql.StatementStatus_State_Failed, resp.Status.State) + assert.Equal(t, "42P01", *resp.Status.SqlState) require.NotNil(t, resp.Status.Error) - assert.Equal(t, sql.ServiceErrorCodeBadRequest, resp.Status.Error.ErrorCode) - assert.Equal(t, "no such table", resp.Status.Error.Message) + assert.Equal(t, sql.ServiceErrorCode_BadRequest, resp.Status.Error.ErrorCode) + assert.Equal(t, "no such table", *resp.Status.Error.Message) assert.Nil(t, resp.Manifest) assert.Nil(t, resp.Result) } @@ -175,13 +176,13 @@ func TestCancelPrecedence(t *testing.T) { }) resp := e.Submit("SELECT 1", "0s", nil) - require.Equal(t, sql.StatementStatePending, resp.Status.State) + require.Equal(t, sql.StatementStatus_State_Pending, resp.Status.State) - e.Cancel(resp.StatementId) + e.Cancel(*resp.StatementId) // Cancel takes precedence over the remaining polls. - got := e.Get(resp.StatementId) - assert.Equal(t, sql.StatementStateCanceled, got.Status.State) + got := e.Get(*resp.StatementId) + assert.Equal(t, sql.StatementStatus_State_Canceled, got.Status.State) assert.Nil(t, got.Manifest) assert.Nil(t, got.Result) } @@ -196,8 +197,8 @@ func TestUnknownStatement(t *testing.T) { func TestDeterministicIDs(t *testing.T) { e := testsql.New() e.Handle("SELECT 1", func(testsql.Request) testsql.Result { return testsql.Result{} }) - assert.Equal(t, "statement-1", e.Submit("SELECT 1", "10s", nil).StatementId) - assert.Equal(t, "statement-2", e.Submit("SELECT 1", "10s", nil).StatementId) + assert.Equal(t, "statement-1", *e.Submit("SELECT 1", "10s", nil).StatementId) + assert.Equal(t, "statement-2", *e.Submit("SELECT 1", "10s", nil).StatementId) } // TestStatefulMatcher proves the matcher runs exactly once per Submit and that @@ -218,12 +219,12 @@ func TestStatefulMatcher(t *testing.T) { }) create := e.Submit("CREATE v AS body", "10s", nil) - require.Equal(t, sql.StatementStateSucceeded, create.Status.State) + require.Equal(t, sql.StatementStatus_State_Succeeded, create.Status.State) assert.Equal(t, 1, calls, "matcher must run exactly once per Submit") read := e.Submit("READ v", "10s", nil) - require.Equal(t, sql.StatementStateSucceeded, read.Status.State) - assert.Equal(t, [][]string{{"body"}}, read.Result.DataArray) + require.Equal(t, sql.StatementStatus_State_Succeeded, read.Status.State) + assert.Equal(t, [][]string{{"body"}}, rowsOf(read.Result.DataArray)) assert.Equal(t, 1, calls, "create matcher must not run again") } @@ -234,7 +235,18 @@ func columnNames(resp *sql.StatementResponse) []string { } out := make([]string, len(resp.Manifest.Schema.Columns)) for i, c := range resp.Manifest.Schema.Columns { - out[i] = c.Name + out[i] = *c.Name + } + return out +} + +func rowsOf(data [][]json.RawMessage) [][]string { + out := make([][]string, len(data)) + for i, row := range data { + out[i] = make([]string, len(row)) + for j, cell := range row { + _ = json.Unmarshal(cell, &out[i][j]) + } } return out } diff --git a/libs/testserver/uc_secrets.go b/libs/testserver/uc_secrets.go index 28bacf1fbed..01dac0bbf6f 100644 --- a/libs/testserver/uc_secrets.go +++ b/libs/testserver/uc_secrets.go @@ -6,8 +6,10 @@ import ( "strings" "time" - sdktime "github.com/databricks/databricks-sdk-go/common/types/time" - "github.com/databricks/databricks-sdk-go/service/catalog" + ucsecrets "github.com/databricks/cli/libs/sdktypes/uc/secrets/v1" + "github.com/databricks/cli/libs/utils" + + "github.com/databricks/sdk-go/core/types" ) // SecretsUcCreateSecret handles POST /api/2.1/unity-catalog/secrets @@ -15,7 +17,7 @@ func (s *FakeWorkspace) SecretsUcCreateSecret(req Request) Response { defer s.LockUnlock()() // The API accepts flat fields, not wrapped in a "secret" object - var inputSecret catalog.Secret + var inputSecret ucsecrets.Secret if err := json.Unmarshal(req.Body, &inputSecret); err != nil { return Response{ StatusCode: 400, @@ -24,13 +26,13 @@ func (s *FakeWorkspace) SecretsUcCreateSecret(req Request) Response { } if s.UCSecrets == nil { - s.UCSecrets = make(map[string]catalog.Secret) + s.UCSecrets = make(map[string]ucsecrets.Secret) } fullName := fmt.Sprintf("%s.%s.%s", - inputSecret.CatalogName, - inputSecret.SchemaName, - inputSecret.Name) + utils.Deref(inputSecret.CatalogName), + utils.Deref(inputSecret.SchemaName), + utils.Deref(inputSecret.Name)) // Check if secret already exists if _, exists := s.UCSecrets[fullName]; exists { @@ -43,12 +45,12 @@ func (s *FakeWorkspace) SecretsUcCreateSecret(req Request) Response { } } - now := sdktime.New(time.Now()) - secret := catalog.Secret{ + now := types.NewFromTime(time.Now()) + secret := ucsecrets.Secret{ CatalogName: inputSecret.CatalogName, SchemaName: inputSecret.SchemaName, Name: inputSecret.Name, - FullName: fullName, + FullName: utils.NonZero(fullName), Value: inputSecret.Value, EffectiveValue: inputSecret.Value, Comment: inputSecret.Comment, @@ -59,10 +61,10 @@ func (s *FakeWorkspace) SecretsUcCreateSecret(req Request) Response { CreatedBy: s.CurrentUser().UserName, UpdatedBy: s.CurrentUser().UserName, EffectiveOwner: inputSecret.Owner, - MetastoreId: "test-metastore-id", + MetastoreId: utils.NonZero("test-metastore-id"), } - if secret.Owner == "" { + if utils.Deref(secret.Owner) == "" { secret.Owner = s.CurrentUser().UserName secret.EffectiveOwner = s.CurrentUser().UserName } @@ -103,7 +105,7 @@ func (s *FakeWorkspace) SecretsUcGetSecret(req Request) Response { // The real API doesn't return the value unless specifically requested returnSecret := secret returnSecret.EffectiveValue = secret.Value - returnSecret.Value = "" + returnSecret.Value = nil return Response{ Body: returnSecret, @@ -125,7 +127,7 @@ func (s *FakeWorkspace) SecretsUcUpdateSecret(req Request) Response { } // The API accepts flat fields - var updateSecret catalog.Secret + var updateSecret ucsecrets.Secret if err := json.Unmarshal(req.Body, &updateSecret); err != nil { return Response{ StatusCode: 400, @@ -149,13 +151,13 @@ func (s *FakeWorkspace) SecretsUcUpdateSecret(req Request) Response { } // Update fields based on update mask - if updateSecret.Value != "" { + if utils.Deref(updateSecret.Value) != "" { secret.Value = updateSecret.Value } if _, ok := fields["comment"]; ok { secret.Comment = updateSecret.Comment } - if updateSecret.Owner != "" { + if utils.Deref(updateSecret.Owner) != "" { secret.Owner = updateSecret.Owner secret.EffectiveOwner = updateSecret.Owner } @@ -166,7 +168,7 @@ func (s *FakeWorkspace) SecretsUcUpdateSecret(req Request) Response { secret.ExpireTime = updateSecret.ExpireTime } - secret.UpdateTime = sdktime.New(time.Now()) + secret.UpdateTime = types.NewFromTime(time.Now()) secret.UpdatedBy = s.CurrentUser().UserName s.UCSecrets[fullName] = secret diff --git a/libs/testserver/vector_search_endpoints.go b/libs/testserver/vector_search_endpoints.go index c051d599ccc..e8bc39635eb 100644 --- a/libs/testserver/vector_search_endpoints.go +++ b/libs/testserver/vector_search_endpoints.go @@ -5,13 +5,14 @@ import ( "fmt" "net/http" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" + vectorsearch "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" + "github.com/databricks/cli/libs/utils" ) func (s *FakeWorkspace) VectorSearchEndpointCreate(req Request) Response { defer s.LockUnlock()() - var createReq vectorsearch.CreateEndpoint + var createReq vectorsearch.CreateEndpointRequest if err := json.Unmarshal(req.Body, &createReq); err != nil { return Response{ Body: fmt.Sprintf("cannot unmarshal request body: %s", err), @@ -19,24 +20,24 @@ func (s *FakeWorkspace) VectorSearchEndpointCreate(req Request) Response { } } - if _, exists := s.VectorSearchEndpoints[createReq.Name]; exists { + if _, exists := s.VectorSearchEndpoints[utils.Deref(createReq.Name)]; exists { return Response{ StatusCode: http.StatusConflict, - Body: map[string]string{"error_code": "RESOURCE_ALREADY_EXISTS", "message": fmt.Sprintf("Vector search endpoint with name %s already exists", createReq.Name)}, + Body: map[string]string{"error_code": "RESOURCE_ALREADY_EXISTS", "message": fmt.Sprintf("Vector search endpoint with name %s already exists", utils.Deref(createReq.Name))}, } } - endpoint := vectorsearch.EndpointInfo{ + endpoint := vectorsearch.Endpoint{ BudgetPolicyId: createReq.BudgetPolicyId, EffectiveBudgetPolicyId: createReq.BudgetPolicyId, Creator: s.CurrentUser().UserName, - CreationTimestamp: nowMilli(), + CreationTimestamp: utils.NonZero(nowMilli()), EndpointType: createReq.EndpointType, - Id: nextUUID(), + Id: utils.NonZero(nextUUID()), LastUpdatedUser: s.CurrentUser().UserName, Name: createReq.Name, EndpointStatus: &vectorsearch.EndpointStatus{ - State: vectorsearch.EndpointStatusStateOnline, // initial create is no-op, returns ONLINE immediately + State: vectorsearch.EndpointStatus_State_Online, // initial create is no-op, returns ONLINE immediately }, ScalingInfo: &vectorsearch.EndpointScalingInfo{ RequestedTargetQps: createReq.TargetQps, @@ -44,7 +45,7 @@ func (s *FakeWorkspace) VectorSearchEndpointCreate(req Request) Response { } endpoint.LastUpdatedTimestamp = endpoint.CreationTimestamp - s.VectorSearchEndpoints[createReq.Name] = endpoint + s.VectorSearchEndpoints[utils.Deref(createReq.Name)] = endpoint return Response{ Body: endpoint, @@ -72,7 +73,7 @@ func (s *FakeWorkspace) VectorSearchEndpointUpdateBudgetPolicy(req Request, endp endpoint.BudgetPolicyId = patchReq.BudgetPolicyId endpoint.EffectiveBudgetPolicyId = patchReq.BudgetPolicyId // assume it always becomes the effective policy - endpoint.LastUpdatedTimestamp = nowMilli() + endpoint.LastUpdatedTimestamp = utils.NonZero(nowMilli()) endpoint.LastUpdatedUser = s.CurrentUser().UserName s.VectorSearchEndpoints[endpointName] = endpoint @@ -107,7 +108,7 @@ func (s *FakeWorkspace) VectorSearchEndpointUpdate(req Request, endpointName str endpoint.ScalingInfo = &vectorsearch.EndpointScalingInfo{} } endpoint.ScalingInfo.RequestedTargetQps = patchReq.TargetQps - endpoint.LastUpdatedTimestamp = nowMilli() + endpoint.LastUpdatedTimestamp = utils.NonZero(nowMilli()) endpoint.LastUpdatedUser = s.CurrentUser().UserName s.VectorSearchEndpoints[endpointName] = endpoint diff --git a/libs/testserver/vector_search_indexes.go b/libs/testserver/vector_search_indexes.go index 3e437c4d444..27035c47bac 100644 --- a/libs/testserver/vector_search_indexes.go +++ b/libs/testserver/vector_search_indexes.go @@ -8,7 +8,8 @@ import ( "regexp" "strings" - "github.com/databricks/databricks-sdk-go/service/vectorsearch" + vectorsearch "github.com/databricks/cli/libs/sdktypes/vectorsearch/v1" + "github.com/databricks/cli/libs/utils" ) // indexNamePart matches each catalog.schema.table component the real backend @@ -45,7 +46,7 @@ func (s *FakeWorkspace) VectorSearchIndexCreate(req Request) Response { } } - if !isValidIndexName(createReq.Name) { + if !isValidIndexName(utils.Deref(createReq.Name)) { return Response{ StatusCode: http.StatusBadRequest, Body: map[string]string{ @@ -55,29 +56,29 @@ func (s *FakeWorkspace) VectorSearchIndexCreate(req Request) Response { } } - if _, exists := s.VectorSearchIndexes[createReq.Name]; exists { + if _, exists := s.VectorSearchIndexes[utils.Deref(createReq.Name)]; exists { return Response{ StatusCode: http.StatusConflict, - Body: map[string]string{"error_code": "RESOURCE_ALREADY_EXISTS", "message": fmt.Sprintf("Vector search index with name %s already exists", createReq.Name)}, + Body: map[string]string{"error_code": "RESOURCE_ALREADY_EXISTS", "message": fmt.Sprintf("Vector search index with name %s already exists", utils.Deref(createReq.Name))}, } } - if s.VectorSearchIndexesPendingDeletion[createReq.Name] > 0 { - s.VectorSearchIndexesPendingDeletion[createReq.Name]-- + if s.VectorSearchIndexesPendingDeletion[utils.Deref(createReq.Name)] > 0 { + s.VectorSearchIndexesPendingDeletion[utils.Deref(createReq.Name)]-- return Response{ StatusCode: http.StatusBadRequest, Body: map[string]string{ "error_code": "INVALID_PARAMETER_VALUE", - "message": fmt.Sprintf("Index %s is currently pending deletion. Operations on the index are not permitted while the index is being deleted.", createReq.Name), + "message": fmt.Sprintf("Index %s is currently pending deletion. Operations on the index are not permitted while the index is being deleted.", utils.Deref(createReq.Name)), }, } } - endpoint, exists := s.VectorSearchEndpoints[createReq.EndpointName] + endpoint, exists := s.VectorSearchEndpoints[utils.Deref(createReq.EndpointName)] if !exists { return Response{ StatusCode: http.StatusNotFound, Body: map[string]string{ "error_code": "RESOURCE_DOES_NOT_EXIST", - "message": fmt.Sprintf("Vector search endpoint %s not found", createReq.EndpointName), + "message": fmt.Sprintf("Vector search endpoint %s not found", utils.Deref(createReq.EndpointName)), }, } } @@ -85,7 +86,7 @@ func (s *FakeWorkspace) VectorSearchIndexCreate(req Request) Response { // The backend assigns index_subtype when the request omits it (HYBRID by default) indexSubtype := createReq.IndexSubtype if indexSubtype == "" { - indexSubtype = vectorsearch.IndexSubtypeHybrid + indexSubtype = vectorsearch.IndexSubtype_Hybrid } // The backend rewrites schema_json on create: user-facing type names are @@ -93,7 +94,7 @@ func (s *FakeWorkspace) VectorSearchIndexCreate(req Request) Response { // returned in sorted key order rather than the user's original order. // Mirror that here so the create -> get round-trip matches the real API. if createReq.DirectAccessIndexSpec != nil { - createReq.DirectAccessIndexSpec.SchemaJson = normalizeSchemaJSON(createReq.DirectAccessIndexSpec.SchemaJson) + createReq.DirectAccessIndexSpec.SchemaJson = utils.NonZero(normalizeSchemaJSON(utils.Deref(createReq.DirectAccessIndexSpec.SchemaJson))) } index := fakeVectorSearchIndex{ @@ -106,12 +107,12 @@ func (s *FakeWorkspace) VectorSearchIndexCreate(req Request) Response { DeltaSyncIndexSpec: remapDeltaSyncSpec(createReq.DeltaSyncIndexSpec), DirectAccessIndexSpec: createReq.DirectAccessIndexSpec, Status: &vectorsearch.VectorIndexStatus{ - Ready: true, + Ready: utils.NonZero(true), }, - EndpointUuid: endpoint.Id, + EndpointUuid: utils.Deref(endpoint.Id), } - s.VectorSearchIndexes[createReq.Name] = index + s.VectorSearchIndexes[utils.Deref(createReq.Name)] = index return Response{ Body: index, @@ -205,11 +206,11 @@ func normalizeColumnType(columnType string) string { } // remapDeltaSyncSpec converts a request spec to a response spec. -func remapDeltaSyncSpec(req *vectorsearch.DeltaSyncVectorIndexSpecRequest) *vectorsearch.DeltaSyncVectorIndexSpecResponse { +func remapDeltaSyncSpec(req *vectorsearch.DeltaSyncVectorIndexSpecRequest) *vectorsearch.DeltaSyncVectorIndexSpec { if req == nil { return nil } - return &vectorsearch.DeltaSyncVectorIndexSpecResponse{ + return &vectorsearch.DeltaSyncVectorIndexSpec{ ColumnsToIndex: req.ColumnsToIndex, ColumnsToSync: req.ColumnsToSync, EmbeddingSourceColumns: req.EmbeddingSourceColumns, diff --git a/libs/testserver/volumes.go b/libs/testserver/volumes.go index 91f29a94e4e..84526be7af5 100644 --- a/libs/testserver/volumes.go +++ b/libs/testserver/volumes.go @@ -6,12 +6,13 @@ import ( "net/http" "strings" - "github.com/databricks/databricks-sdk-go/service/catalog" - "github.com/databricks/databricks-sdk-go/service/workspace" + volumes "github.com/databricks/cli/libs/sdktypes/uc/volumes/v1" + "github.com/databricks/cli/libs/utils" + workspaceapi "github.com/databricks/cli/libs/workspaceapi" ) func (s *FakeWorkspace) VolumesCreate(req Request) Response { - var volume catalog.VolumeInfo + var volume volumes.VolumeInfo if err := json.Unmarshal(req.Body, &volume); err != nil { return Response{ @@ -21,11 +22,11 @@ func (s *FakeWorkspace) VolumesCreate(req Request) Response { } // UC normalizes schema and volume names to lowercase. - volume.SchemaName = strings.ToLower(volume.SchemaName) - volume.Name = strings.ToLower(volume.Name) - volume.FullName = volume.CatalogName + "." + volume.SchemaName + "." + volume.Name + volume.SchemaName = utils.NonZero(strings.ToLower(utils.Deref(volume.SchemaName))) + volume.Name = utils.NonZero(strings.ToLower(utils.Deref(volume.Name))) + volume.FullName = utils.NonZero(utils.Deref(volume.CatalogName) + "." + utils.Deref(volume.SchemaName) + "." + utils.Deref(volume.Name)) - if volume.StorageLocation != "" && volume.VolumeType != catalog.VolumeTypeExternal { + if utils.Deref(volume.StorageLocation) != "" && volume.VolumeType != volumes.VolumeType_External { return Response{ StatusCode: 400, Body: map[string]string{ @@ -35,28 +36,28 @@ func (s *FakeWorkspace) VolumesCreate(req Request) Response { } } - volume.VolumeId = nextUUID() + volume.VolumeId = utils.NonZero(nextUUID()) - if volume.StorageLocation != "" { + if utils.Deref(volume.StorageLocation) != "" { // Strip trailing slash to mimic UC API normalization behavior. - volume.StorageLocation = strings.TrimRight(volume.StorageLocation, "/") + volume.StorageLocation = utils.NonZero(strings.TrimRight(utils.Deref(volume.StorageLocation), "/")) } else { - volume.StorageLocation = fmt.Sprintf("s3://%s/metastore/%s/volumes/%s", testMetastoreName, TestMetastore.MetastoreId, volume.VolumeId) + volume.StorageLocation = utils.NonZero(fmt.Sprintf("s3://%s/metastore/%s/volumes/%s", testMetastoreName, utils.Deref(TestMetastore.MetastoreId), utils.Deref(volume.VolumeId))) } - volume.CreatedAt = nowMilli() + volume.CreatedAt = utils.NonZero(nowMilli()) volume.UpdatedAt = volume.CreatedAt volume.CreatedBy = s.CurrentUser().UserName volume.Owner = s.CurrentUser().UserName defer s.LockUnlock()() - s.Volumes[volume.FullName] = volume + s.Volumes[utils.Deref(volume.FullName)] = volume // Register the volume path as a directory so that fs cp works without // requiring an explicit mkdir. - volumePath := fmt.Sprintf("/Volumes/%s/%s/%s", volume.CatalogName, volume.SchemaName, volume.Name) - s.directories[volumePath] = workspace.ObjectInfo{ + volumePath := fmt.Sprintf("/Volumes/%s/%s/%s", utils.Deref(volume.CatalogName), utils.Deref(volume.SchemaName), utils.Deref(volume.Name)) + s.directories[volumePath] = workspaceapi.ObjectInfo{ ObjectType: "DIRECTORY", Path: volumePath, } @@ -81,7 +82,7 @@ func (s *FakeWorkspace) VolumesUpdate(req Request, fullname string) Response { return *errResponse } - var request catalog.UpdateVolumeRequestContent + var request volumes.UpdateVolumeRequest if err := json.Unmarshal(req.Body, &request); err != nil { return Response{ @@ -92,16 +93,16 @@ func (s *FakeWorkspace) VolumesUpdate(req Request, fullname string) Response { applyUpdatedFields(&existing, request, fields) - if request.NewName != "" { + if utils.Deref(request.NewName) != "" { delete(s.Volumes, fullname) existing.Name = request.NewName - existing.FullName = existing.CatalogName + "." + existing.SchemaName + "." + request.NewName + existing.FullName = utils.NonZero(utils.Deref(existing.CatalogName) + "." + utils.Deref(existing.SchemaName) + "." + utils.Deref(request.NewName)) } - existing.UpdatedAt = nowMilli() + existing.UpdatedAt = utils.NonZero(nowMilli()) existing.UpdatedBy = s.CurrentUser().UserName - s.Volumes[existing.FullName] = existing + s.Volumes[utils.Deref(existing.FullName)] = existing return Response{ Body: existing, } diff --git a/libs/utils/nonzero.go b/libs/utils/nonzero.go new file mode 100644 index 00000000000..6e5755ba4e1 --- /dev/null +++ b/libs/utils/nonzero.go @@ -0,0 +1,11 @@ +package utils + +// NonZero returns a pointer to v, or nil if v is the zero value of T. It +// mirrors `omitempty` on a value field: zero values are not sent. +func NonZero[T comparable](v T) *T { + var zero T + if v == zero { + return nil + } + return &v +} diff --git a/libs/utils/ptr.go b/libs/utils/ptr.go new file mode 100644 index 00000000000..25580175d38 --- /dev/null +++ b/libs/utils/ptr.go @@ -0,0 +1,10 @@ +package utils + +// Deref returns the value p points to, or the zero value of T if p is nil. +func Deref[T any](p *T) T { + if p == nil { + var zero T + return zero + } + return *p +} diff --git a/libs/utils/utils_test.go b/libs/utils/utils_test.go index e4047687442..78f9e2de913 100644 --- a/libs/utils/utils_test.go +++ b/libs/utils/utils_test.go @@ -3,13 +3,18 @@ package utils import ( "testing" - "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/stretchr/testify/assert" ) func TestFilterFields(t *testing.T) { + type volume struct { + Comment string + NewName string + Owner string + Name string + } fields := []string{"Comment", "NewName", "Owner", "Name", "NotExistingField"} - result := FilterFields[catalog.UpdateVolumeRequestContent](fields, "NewName", "Owner") + result := FilterFields[volume](fields, "NewName", "Owner") expected := []string{"Comment", "Name"} assert.Equal(t, expected, result) } diff --git a/libs/workspaceapi/client.go b/libs/workspaceapi/client.go new file mode 100644 index 00000000000..8634dc41523 --- /dev/null +++ b/libs/workspaceapi/client.go @@ -0,0 +1,285 @@ +// Package workspaceapi is a client for the workspace objects API +// (/api/2.0/workspace/...) and workspace object permissions, which sdk-go does +// not provide. +package workspaceapi + +import ( + "bytes" + "context" + "encoding/base64" + "fmt" + "io" + "mime/multipart" + "strings" + + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/apierrs" + "github.com/databricks/cli/libs/listing" +) + +// WorkspaceInterface is the method set of [Client], for callers that accept +// a fake in tests. +type WorkspaceInterface interface { + Delete(ctx context.Context, request Delete) error + Export(ctx context.Context, request ExportRequest) (*ExportResponse, error) + GetPermissionLevels(ctx context.Context, request GetWorkspaceObjectPermissionLevelsRequest) (*GetWorkspaceObjectPermissionLevelsResponse, error) + GetPermissions(ctx context.Context, request GetWorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error) + GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error) + Import(ctx context.Context, request Import) error + List(ctx context.Context, request ListWorkspaceRequest) listing.Iterator[ObjectInfo] + ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error) + Mkdirs(ctx context.Context, request Mkdirs) error + SetPermissions(ctx context.Context, request WorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error) + UpdatePermissions(ctx context.Context, request WorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error) + + GetStatusByPath(ctx context.Context, path string) (*ObjectInfo, error) + MkdirsByPath(ctx context.Context, path string) error + GetByPath(ctx context.Context, name string) (*ObjectInfo, error) + ObjectInfoPathToObjectIdMap(ctx context.Context, request ListWorkspaceRequest) (map[string]int64, error) + GetPermissionLevelsByWorkspaceObjectTypeAndWorkspaceObjectId(ctx context.Context, workspaceObjectType, workspaceObjectId string) (*GetWorkspaceObjectPermissionLevelsResponse, error) + GetPermissionsByWorkspaceObjectTypeAndWorkspaceObjectId(ctx context.Context, workspaceObjectType, workspaceObjectId string) (*WorkspaceObjectPermissions, error) + RecursiveList(ctx context.Context, path string) ([]ObjectInfo, error) + Upload(ctx context.Context, path string, r io.Reader, opts ...UploadOption) error + WriteFile(ctx context.Context, name string, data []byte) error + Download(ctx context.Context, path string, opts ...DownloadOption) (io.ReadCloser, error) + ReadFile(ctx context.Context, name string) ([]byte, error) +} + +// Client calls the workspace objects API. +type Client struct { + workspaceImpl +} + +var _ WorkspaceInterface = (*Client)(nil) + +func New(c *apiclient.Client) *Client { + return &Client{workspaceImpl{client: c}} +} + +func addWorkspaceID(c *apiclient.Client, headers map[string]string) { + c.AddWorkspaceIDHeader(headers) +} + +var b64 = base64.StdEncoding + +// Bytes returns the decoded content of an export. +func (r *ExportResponse) Bytes() ([]byte, error) { + return b64.DecodeString(r.Content) +} + +func (a *Client) GetPermissionLevelsByWorkspaceObjectTypeAndWorkspaceObjectId(ctx context.Context, workspaceObjectType, workspaceObjectId string) (*GetWorkspaceObjectPermissionLevelsResponse, error) { + return a.GetPermissionLevels(ctx, GetWorkspaceObjectPermissionLevelsRequest{ + WorkspaceObjectType: workspaceObjectType, + WorkspaceObjectId: workspaceObjectId, + }) +} + +func (a *Client) GetPermissionsByWorkspaceObjectTypeAndWorkspaceObjectId(ctx context.Context, workspaceObjectType, workspaceObjectId string) (*WorkspaceObjectPermissions, error) { + return a.GetPermissions(ctx, GetWorkspaceObjectPermissionsRequest{ + WorkspaceObjectType: workspaceObjectType, + WorkspaceObjectId: workspaceObjectId, + }) +} + +// GetStatusByPath gets the status of an object or a directory. +func (a *Client) GetStatusByPath(ctx context.Context, path string) (*ObjectInfo, error) { + return a.GetStatus(ctx, GetStatusRequest{Path: path}) +} + +// MkdirsByPath creates the directory and its missing parents. +func (a *Client) MkdirsByPath(ctx context.Context, path string) error { + return a.Mkdirs(ctx, Mkdirs{Path: path}) +} + +// ObjectInfoPathToObjectIdMap lists objects and maps their paths to IDs. +func (a *Client) ObjectInfoPathToObjectIdMap(ctx context.Context, request ListWorkspaceRequest) (map[string]int64, error) { + mapping := map[string]int64{} + result, err := a.ListAll(ctx, request) + if err != nil { + return nil, err + } + for _, v := range result { + if _, duplicate := mapping[v.Path]; duplicate { + return nil, fmt.Errorf("duplicate .Path: %s", v.Path) + } + mapping[v.Path] = v.ObjectId + } + return mapping, nil +} + +// GetByPath lists the workspace root and returns the object with the given path. +func (a *Client) GetByPath(ctx context.Context, name string) (*ObjectInfo, error) { + result, err := a.ListAll(ctx, ListWorkspaceRequest{}) + if err != nil { + return nil, err + } + var alternatives []ObjectInfo + for _, v := range result { + if v.Path == name { + alternatives = append(alternatives, v) + } + } + if len(alternatives) == 0 { + return nil, fmt.Errorf("ObjectInfo named '%s' does not exist", name) + } + if len(alternatives) > 1 { + return nil, fmt.Errorf("there are %d instances of ObjectInfo named '%s'", len(alternatives), name) + } + return &alternatives[0], nil +} + +// RecursiveList traverses the workspace tree and returns all non-directory +// objects under the path. +func (a *Client) RecursiveList(ctx context.Context, path string) ([]ObjectInfo, error) { + var results []ObjectInfo + queue := []string{path} + for len(queue) > 0 { + path := queue[0] + queue = queue[1:] + batch, err := a.ListAll(ctx, ListWorkspaceRequest{Path: path}) + if apierrs.IsMissing(err) { + // skip on path deleted during iteration + continue + } + if err != nil { + return nil, fmt.Errorf("list %s: %w", path, err) + } + for _, v := range batch { + if v.ObjectType == ObjectTypeDirectory { + queue = append(queue, v.Path) + continue + } + results = append(results, v) + } + } + return results, nil +} + +type UploadOption = func(*Import) + +func UploadOverwrite() UploadOption { + return func(i *Import) { + i.Overwrite = true + } +} + +func UploadLanguage(l Language) UploadOption { + return func(i *Import) { + i.Language = l + } +} + +func UploadFormat(f ImportFormat) UploadOption { + return func(i *Import) { + i.Format = f + } +} + +// Upload imports a workspace object (for example, a notebook or file) or the +// contents of an entire directory (`DBC` format) with a multipart request. +// +// The format defaults to SOURCE; for SOURCE the language is inferred from the +// path's extension unless UploadLanguage is given. +func (a *Client) Upload(ctx context.Context, path string, r io.Reader, opts ...UploadOption) error { + buf := &bytes.Buffer{} + w := multipart.NewWriter(buf) + err := w.WriteField("path", path) + if err != nil { + return fmt.Errorf("write path: %w", err) + } + content, err := w.CreateFormFile("content", "content") + if err != nil { + return fmt.Errorf("write content: %w", err) + } + _, err = io.Copy(content, r) + if err != nil { + return fmt.Errorf("copy io: %w", err) + } + i := &Import{} + for _, v := range opts { + v(i) + } + if i.Format == "" || i.Format == ImportFormatSource { + for sfx, lang := range map[string]Language{ + ".py": LanguagePython, + ".sql": LanguageSql, + ".scala": LanguageScala, + ".R": LanguageR, + } { + if !strings.HasSuffix(path, sfx) { + continue + } + i.Language = lang + } + } + if i.Format != "" { + err = w.WriteField("format", i.Format.String()) + if err != nil { + return fmt.Errorf("write format: %w", err) + } + } + if i.Language != "" { + err = w.WriteField("language", i.Language.String()) + if err != nil { + return fmt.Errorf("write language: %w", err) + } + } + if i.Overwrite { + err = w.WriteField("overwrite", "true") + if err != nil { + return fmt.Errorf("write overwrite: %w", err) + } + } + err = w.Close() + if err != nil { + return fmt.Errorf("write close: %w", err) + } + headers := map[string]string{ + "Content-Type": w.FormDataContentType(), + } + addWorkspaceID(a.client, headers) + return a.client.Do(ctx, "POST", "/api/2.0/workspace/import", headers, nil, buf.Bytes(), nil) +} + +// WriteFile is identical to [os.WriteFile] but for workspace files. It always +// overwrites and uploads a file, not a notebook. +func (a *Client) WriteFile(ctx context.Context, name string, data []byte) error { + return a.Upload(ctx, name, bytes.NewBuffer(data), + UploadFormat(ImportFormatAuto), + UploadOverwrite()) +} + +type DownloadOption = func(q map[string]any) + +func DownloadFormat(f ExportFormat) DownloadOption { + return func(q map[string]any) { + q["format"] = f.String() + } +} + +// Download returns the contents of a notebook or file. The format defaults to +// SOURCE. +func (a *Client) Download(ctx context.Context, path string, opts ...DownloadOption) (io.ReadCloser, error) { + var buf bytes.Buffer + query := map[string]any{"path": path, "direct_download": true} + for _, v := range opts { + v(query) + } + headers := map[string]string{"Content-Type": "application/json"} + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, "GET", "/api/2.0/workspace/export", headers, nil, query, &buf) + if err != nil { + return nil, err + } + return io.NopCloser(&buf), nil +} + +// ReadFile is identical to [os.ReadFile] but for workspace files. +func (a *Client) ReadFile(ctx context.Context, name string) ([]byte, error) { + b, err := a.Download(ctx, name) + if err != nil { + return nil, err + } + defer b.Close() + return io.ReadAll(b) +} diff --git a/libs/workspaceapi/client_test.go b/libs/workspaceapi/client_test.go new file mode 100644 index 00000000000..1a3260cfc3d --- /dev/null +++ b/libs/workspaceapi/client_test.go @@ -0,0 +1,75 @@ +package workspaceapi + +import ( + "encoding/json" + "io" + "net/http" + "strings" + "testing" + + "github.com/databricks/cli/libs/apiclient/apiclienttest" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestUploadSendsMultipart(t *testing.T) { + var fields map[string]string + c := New(apiclienttest.New(t, func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, "/api/2.0/workspace/import", r.URL.Path) + assert.Equal(t, "123", r.Header.Get("X-Databricks-Workspace-Id")) + assert.Equal(t, "Bearer token", r.Header.Get("Authorization")) + assert.NoError(t, r.ParseMultipartForm(1<<20)) + fields = map[string]string{} + for k, v := range r.MultipartForm.Value { + fields[k] = v[0] + } + f, _, err := r.FormFile("content") + assert.NoError(t, err) + data, _ := io.ReadAll(f) + fields["content"] = string(data) + })) + err := c.Upload(t.Context(), "/a/b.py", strings.NewReader("print(1)"), UploadOverwrite()) + require.NoError(t, err) + assert.Equal(t, map[string]string{ + "path": "/a/b.py", + "language": "PYTHON", + "overwrite": "true", + "content": "print(1)", + }, fields) +} + +func TestDownload(t *testing.T) { + c := New(apiclienttest.New(t, func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, "/api/2.0/workspace/export", r.URL.Path) + assert.Equal(t, "/a/b", r.URL.Query().Get("path")) + assert.Equal(t, "true", r.URL.Query().Get("direct_download")) + assert.Equal(t, "JUPYTER", r.URL.Query().Get("format")) + _, _ = w.Write([]byte("raw bytes")) + })) + data, err := c.Download(t.Context(), "/a/b", DownloadFormat(ExportFormatJupyter)) + require.NoError(t, err) + b, _ := io.ReadAll(data) + assert.Equal(t, "raw bytes", string(b)) +} + +func TestGetStatusAndListUseQuery(t *testing.T) { + c := New(apiclienttest.New(t, func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/api/2.0/workspace/get-status": + assert.Equal(t, "path=%2Fa%20b", r.URL.RawQuery) + _ = json.NewEncoder(w).Encode(ObjectInfo{Path: "/a b", ObjectType: ObjectTypeDirectory, ObjectId: 7}) + case "/api/2.0/workspace/list": + assert.Equal(t, "/a b", r.URL.Query().Get("path")) + _ = json.NewEncoder(w).Encode(ListResponse{Objects: []ObjectInfo{{Path: "/a b/x", ObjectType: ObjectTypeFile}}}) + default: + t.Errorf("unexpected %s", r.URL.Path) + } + })) + info, err := c.GetStatusByPath(t.Context(), "/a b") + require.NoError(t, err) + assert.Equal(t, int64(7), info.ObjectId) + + objs, err := c.RecursiveList(t.Context(), "/a b") + require.NoError(t, err) + assert.Equal(t, []ObjectInfo{{Path: "/a b/x", ObjectType: ObjectTypeFile}}, objs) +} diff --git a/libs/workspaceapi/impl.go b/libs/workspaceapi/impl.go new file mode 100644 index 00000000000..a4bc838aa52 --- /dev/null +++ b/libs/workspaceapi/impl.go @@ -0,0 +1,155 @@ +// Code ported from github.com/databricks/databricks-sdk-go. + +package workspaceapi + +import ( + "context" + "fmt" + "net/http" + + "github.com/databricks/cli/libs/apiclient" + "github.com/databricks/cli/libs/listing" +) + +type workspaceImpl struct { + client *apiclient.Client +} + +func (a *workspaceImpl) Delete(ctx context.Context, request Delete) error { + path := "/api/2.0/workspace/delete" + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPost, path, headers, queryParams, request, nil) + return err +} + +func (a *workspaceImpl) Export(ctx context.Context, request ExportRequest) (*ExportResponse, error) { + var exportResponse ExportResponse + path := "/api/2.0/workspace/export" + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &exportResponse) + return &exportResponse, err +} + +func (a *workspaceImpl) GetPermissionLevels(ctx context.Context, request GetWorkspaceObjectPermissionLevelsRequest) (*GetWorkspaceObjectPermissionLevelsResponse, error) { + var getWorkspaceObjectPermissionLevelsResponse GetWorkspaceObjectPermissionLevelsResponse + path := fmt.Sprintf("/api/2.0/permissions/%v/%v/permissionLevels", request.WorkspaceObjectType, request.WorkspaceObjectId) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &getWorkspaceObjectPermissionLevelsResponse) + return &getWorkspaceObjectPermissionLevelsResponse, err +} + +func (a *workspaceImpl) GetPermissions(ctx context.Context, request GetWorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error) { + var workspaceObjectPermissions WorkspaceObjectPermissions + path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.WorkspaceObjectType, request.WorkspaceObjectId) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &workspaceObjectPermissions) + return &workspaceObjectPermissions, err +} + +func (a *workspaceImpl) GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error) { + var objectInfo ObjectInfo + path := "/api/2.0/workspace/get-status" + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &objectInfo) + return &objectInfo, err +} + +func (a *workspaceImpl) Import(ctx context.Context, request Import) error { + path := "/api/2.0/workspace/import" + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPost, path, headers, queryParams, request, nil) + return err +} + +// Lists the contents of a directory, or the object if it is not a directory. If +// the input path does not exist, this call returns an error +// `RESOURCE_DOES_NOT_EXIST`. +func (a *workspaceImpl) List(ctx context.Context, request ListWorkspaceRequest) listing.Iterator[ObjectInfo] { + getNextPage := func(ctx context.Context, req ListWorkspaceRequest) (*ListResponse, error) { + return a.internalList(ctx, req) + } + getItems := func(resp *ListResponse) []ObjectInfo { + return resp.Objects + } + + iterator := listing.NewIterator( + &request, + getNextPage, + getItems, + nil) + return iterator +} + +// Lists the contents of a directory, or the object if it is not a directory. If +// the input path does not exist, this call returns an error +// `RESOURCE_DOES_NOT_EXIST`. +func (a *workspaceImpl) ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error) { + iterator := a.List(ctx, request) + return listing.ToSlice[ObjectInfo](ctx, iterator) +} + +func (a *workspaceImpl) internalList(ctx context.Context, request ListWorkspaceRequest) (*ListResponse, error) { + var listResponse ListResponse + path := "/api/2.0/workspace/list" + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodGet, path, headers, queryParams, apiclient.URLQuery(request), &listResponse) + return &listResponse, err +} + +func (a *workspaceImpl) Mkdirs(ctx context.Context, request Mkdirs) error { + path := "/api/2.0/workspace/mkdirs" + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPost, path, headers, queryParams, request, nil) + return err +} + +func (a *workspaceImpl) SetPermissions(ctx context.Context, request WorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error) { + var workspaceObjectPermissions WorkspaceObjectPermissions + path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.WorkspaceObjectType, request.WorkspaceObjectId) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPut, path, headers, queryParams, request, &workspaceObjectPermissions) + return &workspaceObjectPermissions, err +} + +func (a *workspaceImpl) UpdatePermissions(ctx context.Context, request WorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error) { + var workspaceObjectPermissions WorkspaceObjectPermissions + path := fmt.Sprintf("/api/2.0/permissions/%v/%v", request.WorkspaceObjectType, request.WorkspaceObjectId) + queryParams := make(map[string]any) + headers := make(map[string]string) + headers["Accept"] = "application/json" + headers["Content-Type"] = "application/json" + addWorkspaceID(a.client, headers) + err := a.client.Do(ctx, http.MethodPatch, path, headers, queryParams, request, &workspaceObjectPermissions) + return &workspaceObjectPermissions, err +} diff --git a/libs/workspaceapi/model.go b/libs/workspaceapi/model.go new file mode 100644 index 00000000000..f20be5d1a2a --- /dev/null +++ b/libs/workspaceapi/model.go @@ -0,0 +1,475 @@ +// Code ported from github.com/databricks/databricks-sdk-go /service/workspace/model.go. + +package workspaceapi + +import ( + "fmt" +) + +type Delete struct { + // The absolute path of the notebook or directory. + Path string `json:"path"` + // The flag that specifies whether to delete the object recursively. It is + // `false` by default. Please note this deleting directory is not atomic. If + // it fails in the middle, some of objects under this directory may be + // deleted and cannot be undone. + Recursive bool `json:"recursive,omitempty"` +} + +// Additional metadata about a directory. +type DirectoryInfo struct { + // Whether the directory is a Git folder, whose contents are + // version-controlled by a remote Git repository. How a Git folder is + // represented depends on whether it has Git CLI access: + // + // - A Git folder with Git CLI access has an object type of ``DIRECTORY``, + // with this field set to ``true``. - A standard Git folder, which does not + // have Git CLI access, has an object type of ``REPO`` and does not include + // this field. - A directory that is not Git-backed has this field set to + // ``false``. + // + // Use this field together with ``object_type`` to identify every Git folder + // in a workspace. + IsGitFolder bool `json:"is_git_folder,omitempty"` +} + +// The format for workspace import and export. +type ExportFormat string + +const ExportFormatAuto ExportFormat = `AUTO` + +const ExportFormatDbc ExportFormat = `DBC` + +const ExportFormatHtml ExportFormat = `HTML` + +const ExportFormatJupyter ExportFormat = `JUPYTER` + +const ExportFormatRaw ExportFormat = `RAW` + +const ExportFormatRMarkdown ExportFormat = `R_MARKDOWN` + +const ExportFormatSource ExportFormat = `SOURCE` + +// String representation for [fmt.Print] +func (f *ExportFormat) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *ExportFormat) Set(v string) error { + switch v { + case `AUTO`, `DBC`, `HTML`, `JUPYTER`, `RAW`, `R_MARKDOWN`, `SOURCE`: + *f = ExportFormat(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "AUTO", "DBC", "HTML", "JUPYTER", "RAW", "R_MARKDOWN", "SOURCE"`, v) + } +} + +// Values returns all possible values for ExportFormat. +// +// There is no guarantee on the order of the values in the slice. +func (f *ExportFormat) Values() []ExportFormat { + return []ExportFormat{ + ExportFormatAuto, + ExportFormatDbc, + ExportFormatHtml, + ExportFormatJupyter, + ExportFormatRaw, + ExportFormatRMarkdown, + ExportFormatSource, + } +} + +// Type always returns ExportFormat to satisfy [pflag.Value] interface +func (f *ExportFormat) Type() string { + return "ExportFormat" +} + +type ExportRequest struct { + // This specifies the format of the exported file. By default, this is + // `SOURCE`. + // + // The value is case sensitive. + // + // - `SOURCE`: The notebook is exported as source code. Directory exports + // will not include non-notebook entries. - `HTML`: The notebook is exported + // as an HTML file. - `JUPYTER`: The notebook is exported as a + // Jupyter/IPython Notebook file. - `DBC`: The notebook is exported in + // Databricks archive format. Directory exports will not include + // non-notebook entries. - `R_MARKDOWN`: The notebook is exported to R + // Markdown format. - `AUTO`: The object or directory is exported depending + // on the objects type. Directory exports will include notebooks and + // workspace files. + Format ExportFormat `json:"-" url:"format,omitempty"` + // The absolute path of the object or directory. Exporting a directory is + // only supported for the `DBC`, `SOURCE`, and `AUTO` format. + Path string `json:"-" url:"path"` +} + +// The request field `direct_download` determines whether a JSON response or +// binary contents are returned by this endpoint. +type ExportResponse struct { + // The base64-encoded content. If the limit (10MB) is exceeded, exception + // with error code **MAX_NOTEBOOK_SIZE_EXCEEDED** is thrown. + Content string `json:"content,omitempty"` + // The file type of the exported file. + FileType string `json:"file_type,omitempty"` +} + +type GetStatusRequest struct { + // The absolute path of the notebook or directory. + Path string `json:"-" url:"path"` +} + +type GetWorkspaceObjectPermissionLevelsRequest struct { + // The workspace object for which to get or manage permissions. + WorkspaceObjectId string `json:"-" url:"-"` + // The workspace object type for which to get or manage permissions. Could + // be one of the following: alerts, alertsv2, dashboards, dbsql-dashboards, + // directories, experiments, files, genie, notebooks, queries + WorkspaceObjectType string `json:"-" url:"-"` +} + +type GetWorkspaceObjectPermissionLevelsResponse struct { + // Specific permission levels + PermissionLevels []WorkspaceObjectPermissionsDescription `json:"permission_levels,omitempty"` +} + +type GetWorkspaceObjectPermissionsRequest struct { + // The workspace object for which to get or manage permissions. + WorkspaceObjectId string `json:"-" url:"-"` + // The workspace object type for which to get or manage permissions. Could + // be one of the following: alerts, alertsv2, dashboards, dbsql-dashboards, + // directories, experiments, files, genie, notebooks, queries + WorkspaceObjectType string `json:"-" url:"-"` +} + +type Import struct { + // The base64-encoded content. This has a limit of 10 MB. + // + // If the limit (10MB) is exceeded, exception with error code + // **MAX_NOTEBOOK_SIZE_EXCEEDED** is thrown. This parameter might be absent, + // and instead a posted file is used. + Content string `json:"content,omitempty"` + // This specifies the format of the file to be imported. + // + // The value is case sensitive. + // + // - `AUTO`: The item is imported depending on an analysis of the item's + // extension and the header content provided in the request. If the item is + // imported as a notebook, then the item's extension is automatically + // removed. - `SOURCE`: The notebook or directory is imported as source + // code. - `HTML`: The notebook is imported as an HTML file. - `JUPYTER`: + // The notebook is imported as a Jupyter/IPython Notebook file. - `DBC`: The + // notebook is imported in Databricks archive format. Required for + // directories. - `R_MARKDOWN`: The notebook is imported from R Markdown + // format. + Format ImportFormat `json:"format,omitempty"` + // The language of the object. This value is set only if the object type is + // `NOTEBOOK`. + Language Language `json:"language,omitempty"` + // The flag that specifies whether to overwrite existing object. It is + // `false` by default. For `DBC` format, `overwrite` is not supported since + // it may contain a directory. + Overwrite bool `json:"overwrite,omitempty"` + // The absolute path of the object or directory. Importing a directory is + // only supported for the `DBC` and `SOURCE` formats. + Path string `json:"path"` +} + +// The format for workspace import and export. +type ImportFormat string + +const ImportFormatAuto ImportFormat = `AUTO` + +const ImportFormatDbc ImportFormat = `DBC` + +const ImportFormatHtml ImportFormat = `HTML` + +const ImportFormatJupyter ImportFormat = `JUPYTER` + +const ImportFormatRaw ImportFormat = `RAW` + +const ImportFormatRMarkdown ImportFormat = `R_MARKDOWN` + +const ImportFormatSource ImportFormat = `SOURCE` + +// String representation for [fmt.Print] +func (f *ImportFormat) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *ImportFormat) Set(v string) error { + switch v { + case `AUTO`, `DBC`, `HTML`, `JUPYTER`, `RAW`, `R_MARKDOWN`, `SOURCE`: + *f = ImportFormat(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "AUTO", "DBC", "HTML", "JUPYTER", "RAW", "R_MARKDOWN", "SOURCE"`, v) + } +} + +// Values returns all possible values for ImportFormat. +// +// There is no guarantee on the order of the values in the slice. +func (f *ImportFormat) Values() []ImportFormat { + return []ImportFormat{ + ImportFormatAuto, + ImportFormatDbc, + ImportFormatHtml, + ImportFormatJupyter, + ImportFormatRaw, + ImportFormatRMarkdown, + ImportFormatSource, + } +} + +// Type always returns ImportFormat to satisfy [pflag.Value] interface +func (f *ImportFormat) Type() string { + return "ImportFormat" +} + +// The language of notebook. +type Language string + +const LanguagePython Language = `PYTHON` + +const LanguageR Language = `R` + +const LanguageScala Language = `SCALA` + +const LanguageSql Language = `SQL` + +// String representation for [fmt.Print] +func (f *Language) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *Language) Set(v string) error { + switch v { + case `PYTHON`, `R`, `SCALA`, `SQL`: + *f = Language(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "PYTHON", "R", "SCALA", "SQL"`, v) + } +} + +// Values returns all possible values for Language. +// +// There is no guarantee on the order of the values in the slice. +func (f *Language) Values() []Language { + return []Language{ + LanguagePython, + LanguageR, + LanguageScala, + LanguageSql, + } +} + +// Type always returns Language to satisfy [pflag.Value] interface +func (f *Language) Type() string { + return "Language" +} + +type ListResponse struct { + // List of objects. + Objects []ObjectInfo `json:"objects,omitempty"` +} + +type ListWorkspaceRequest struct { + // UTC timestamp in milliseconds + NotebooksModifiedAfter int64 `json:"-" url:"notebooks_modified_after,omitempty"` + // The absolute path of the notebook or directory. + Path string `json:"-" url:"path"` +} + +type Mkdirs struct { + // The absolute path of the directory. If the parent directories do not + // exist, it will also create them. If the directory already exists, this + // command will do nothing and succeed. + Path string `json:"path"` +} + +// The information of the object in workspace. It will be returned by “list“ +// and “get-status“. +type ObjectInfo struct { + // Only applicable to files. The creation UTC timestamp. + CreatedAt int64 `json:"created_at,omitempty"` + // Additional metadata about the directory. Only set for objects of type + // ``DIRECTORY``. + DirectoryInfo *DirectoryInfo `json:"directory_info,omitempty"` + // The language of the object. This value is set only if the object type is + // ``NOTEBOOK``. For Jupyter (.ipynb) notebooks, this is always ``PYTHON``. + Language Language `json:"language,omitempty"` + // Only applicable to files, the last modified UTC timestamp. + ModifiedAt int64 `json:"modified_at,omitempty"` + // Unique identifier for the object. + ObjectId int64 `json:"object_id,omitempty"` + // The type of the object in workspace. + // + // - `NOTEBOOK`: document that contains runnable code, visualizations, and + // explanatory text. - `DIRECTORY`: directory - `LIBRARY`: library - `FILE`: + // file - `REPO`: repository - `DASHBOARD`: Lakeview dashboard + ObjectType ObjectType `json:"object_type,omitempty"` + // The absolute path of the object. + Path string `json:"path,omitempty"` + // A unique identifier for the object that is consistent across all + // Databricks APIs. + ResourceId string `json:"resource_id,omitempty"` + // Only applicable to files. The file size in bytes can be returned. + Size int64 `json:"size,omitempty"` +} + +// The type of the object in workspace. +type ObjectType string + +const ObjectTypeDashboard ObjectType = `DASHBOARD` + +const ObjectTypeDirectory ObjectType = `DIRECTORY` + +const ObjectTypeFile ObjectType = `FILE` + +const ObjectTypeLibrary ObjectType = `LIBRARY` + +const ObjectTypeNotebook ObjectType = `NOTEBOOK` + +const ObjectTypeRepo ObjectType = `REPO` + +// String representation for [fmt.Print] +func (f *ObjectType) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *ObjectType) Set(v string) error { + switch v { + case `DASHBOARD`, `DIRECTORY`, `FILE`, `LIBRARY`, `NOTEBOOK`, `REPO`: + *f = ObjectType(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "DASHBOARD", "DIRECTORY", "FILE", "LIBRARY", "NOTEBOOK", "REPO"`, v) + } +} + +// Values returns all possible values for ObjectType. +// +// There is no guarantee on the order of the values in the slice. +func (f *ObjectType) Values() []ObjectType { + return []ObjectType{ + ObjectTypeDashboard, + ObjectTypeDirectory, + ObjectTypeFile, + ObjectTypeLibrary, + ObjectTypeNotebook, + ObjectTypeRepo, + } +} + +// Type always returns ObjectType to satisfy [pflag.Value] interface +func (f *ObjectType) Type() string { + return "ObjectType" +} + +type WorkspaceObjectAccessControlRequest struct { + // name of the group + GroupName string `json:"group_name,omitempty"` + + PermissionLevel WorkspaceObjectPermissionLevel `json:"permission_level,omitempty"` + // application ID of a service principal + ServicePrincipalName string `json:"service_principal_name,omitempty"` + // name of the user + UserName string `json:"user_name,omitempty"` +} + +type WorkspaceObjectAccessControlResponse struct { + // All permissions. + AllPermissions []WorkspaceObjectPermission `json:"all_permissions,omitempty"` + // Display name of the user or service principal. + DisplayName string `json:"display_name,omitempty"` + // name of the group + GroupName string `json:"group_name,omitempty"` + // Name of the service principal. + ServicePrincipalName string `json:"service_principal_name,omitempty"` + // name of the user + UserName string `json:"user_name,omitempty"` +} + +type WorkspaceObjectPermission struct { + Inherited bool `json:"inherited,omitempty"` + + InheritedFromObject []string `json:"inherited_from_object,omitempty"` + + PermissionLevel WorkspaceObjectPermissionLevel `json:"permission_level,omitempty"` +} + +// Permission level +type WorkspaceObjectPermissionLevel string + +const WorkspaceObjectPermissionLevelCanEdit WorkspaceObjectPermissionLevel = `CAN_EDIT` + +const WorkspaceObjectPermissionLevelCanManage WorkspaceObjectPermissionLevel = `CAN_MANAGE` + +const WorkspaceObjectPermissionLevelCanRead WorkspaceObjectPermissionLevel = `CAN_READ` + +const WorkspaceObjectPermissionLevelCanRun WorkspaceObjectPermissionLevel = `CAN_RUN` + +// String representation for [fmt.Print] +func (f *WorkspaceObjectPermissionLevel) String() string { + return string(*f) +} + +// Set raw string value and validate it against allowed values +func (f *WorkspaceObjectPermissionLevel) Set(v string) error { + switch v { + case `CAN_EDIT`, `CAN_MANAGE`, `CAN_READ`, `CAN_RUN`: + *f = WorkspaceObjectPermissionLevel(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "CAN_EDIT", "CAN_MANAGE", "CAN_READ", "CAN_RUN"`, v) + } +} + +// Values returns all possible values for WorkspaceObjectPermissionLevel. +// +// There is no guarantee on the order of the values in the slice. +func (f *WorkspaceObjectPermissionLevel) Values() []WorkspaceObjectPermissionLevel { + return []WorkspaceObjectPermissionLevel{ + WorkspaceObjectPermissionLevelCanEdit, + WorkspaceObjectPermissionLevelCanManage, + WorkspaceObjectPermissionLevelCanRead, + WorkspaceObjectPermissionLevelCanRun, + } +} + +// Type always returns WorkspaceObjectPermissionLevel to satisfy [pflag.Value] interface +func (f *WorkspaceObjectPermissionLevel) Type() string { + return "WorkspaceObjectPermissionLevel" +} + +type WorkspaceObjectPermissions struct { + AccessControlList []WorkspaceObjectAccessControlResponse `json:"access_control_list,omitempty"` + + ObjectId string `json:"object_id,omitempty"` + + ObjectType string `json:"object_type,omitempty"` +} + +type WorkspaceObjectPermissionsDescription struct { + Description string `json:"description,omitempty"` + + PermissionLevel WorkspaceObjectPermissionLevel `json:"permission_level,omitempty"` +} + +type WorkspaceObjectPermissionsRequest struct { + AccessControlList []WorkspaceObjectAccessControlRequest `json:"access_control_list,omitempty"` + // The workspace object for which to get or manage permissions. + WorkspaceObjectId string `json:"-" url:"-"` + // The workspace object type for which to get or manage permissions. Could + // be one of the following: alerts, alertsv2, dashboards, dbsql-dashboards, + // directories, experiments, files, genie, notebooks, queries + WorkspaceObjectType string `json:"-" url:"-"` +} diff --git a/python/databricks/bundles/model_serving_endpoints/__init__.py b/python/databricks/bundles/model_serving_endpoints/__init__.py index 0137c5e76b9..d2e1bd672eb 100644 --- a/python/databricks/bundles/model_serving_endpoints/__init__.py +++ b/python/databricks/bundles/model_serving_endpoints/__init__.py @@ -108,12 +108,8 @@ "ServedModelInput", "ServedModelInputDict", "ServedModelInputParam", - "ServedModelInputWorkloadType", - "ServedModelInputWorkloadTypeParam", "ServingEndpointPermissionLevel", "ServingEndpointPermissionLevelParam", - "ServingModelWorkloadType", - "ServingModelWorkloadTypeParam", "TelemetryConfig", "TelemetryConfigDict", "TelemetryConfigParam", @@ -314,18 +310,10 @@ ServedModelInputDict, ServedModelInputParam, ) -from databricks.bundles.model_serving_endpoints._models.served_model_input_workload_type import ( - ServedModelInputWorkloadType, - ServedModelInputWorkloadTypeParam, -) from databricks.bundles.model_serving_endpoints._models.serving_endpoint_permission_level import ( ServingEndpointPermissionLevel, ServingEndpointPermissionLevelParam, ) -from databricks.bundles.model_serving_endpoints._models.serving_model_workload_type import ( - ServingModelWorkloadType, - ServingModelWorkloadTypeParam, -) from databricks.bundles.model_serving_endpoints._models.telemetry_config import ( TelemetryConfig, TelemetryConfigDict, diff --git a/python/databricks/bundles/model_serving_endpoints/_models/served_entity_input.py b/python/databricks/bundles/model_serving_endpoints/_models/served_entity_input.py index e40050ca3e6..2f8f33529a8 100644 --- a/python/databricks/bundles/model_serving_endpoints/_models/served_entity_input.py +++ b/python/databricks/bundles/model_serving_endpoints/_models/served_entity_input.py @@ -10,10 +10,6 @@ ExternalModel, ExternalModelParam, ) -from databricks.bundles.model_serving_endpoints._models.serving_model_workload_type import ( - ServingModelWorkloadType, - ServingModelWorkloadTypeParam, -) if TYPE_CHECKING: from typing_extensions import Self @@ -92,11 +88,6 @@ class ServedEntityInput: The workload size of the served entity. The workload size corresponds to a range of provisioned concurrency that the compute autoscales between. A single unit of provisioned concurrency can process one request at a time. Valid workload sizes are "Small" (4 - 4 provisioned concurrency), "Medium" (8 - 16 provisioned concurrency), and "Large" (16 - 64 provisioned concurrency). Additional custom workload sizes can also be used when available in the workspace. If scale-to-zero is enabled, the lower bound of the provisioned concurrency for each workload size is 0. Do not use if min_provisioned_concurrency and max_provisioned_concurrency are specified. """ - workload_type: VariableOrOptional[ServingModelWorkloadType] = None - """ - The workload type of the served entity. The workload type selects which type of compute to use in the endpoint. The default value for this parameter is "CPU". For deep learning workloads, GPU acceleration is available by selecting workload types like GPU_SMALL and others. See the available [GPU types](https://docs.databricks.com/en/machine-learning/model-serving/create-manage-serving-endpoints.html#gpu-workload-types). - """ - @classmethod def from_dict(cls, value: "ServedEntityInputDict") -> "Self": return _transform(cls, value) @@ -177,10 +168,5 @@ class ServedEntityInputDict(TypedDict, total=False): The workload size of the served entity. The workload size corresponds to a range of provisioned concurrency that the compute autoscales between. A single unit of provisioned concurrency can process one request at a time. Valid workload sizes are "Small" (4 - 4 provisioned concurrency), "Medium" (8 - 16 provisioned concurrency), and "Large" (16 - 64 provisioned concurrency). Additional custom workload sizes can also be used when available in the workspace. If scale-to-zero is enabled, the lower bound of the provisioned concurrency for each workload size is 0. Do not use if min_provisioned_concurrency and max_provisioned_concurrency are specified. """ - workload_type: VariableOrOptional[ServingModelWorkloadTypeParam] - """ - The workload type of the served entity. The workload type selects which type of compute to use in the endpoint. The default value for this parameter is "CPU". For deep learning workloads, GPU acceleration is available by selecting workload types like GPU_SMALL and others. See the available [GPU types](https://docs.databricks.com/en/machine-learning/model-serving/create-manage-serving-endpoints.html#gpu-workload-types). - """ - ServedEntityInputParam = ServedEntityInputDict | ServedEntityInput diff --git a/python/databricks/bundles/model_serving_endpoints/_models/served_model_input.py b/python/databricks/bundles/model_serving_endpoints/_models/served_model_input.py index 90c98757af5..1e3dc2081cd 100644 --- a/python/databricks/bundles/model_serving_endpoints/_models/served_model_input.py +++ b/python/databricks/bundles/model_serving_endpoints/_models/served_model_input.py @@ -10,10 +10,6 @@ VariableOrDict, VariableOrOptional, ) -from databricks.bundles.model_serving_endpoints._models.served_model_input_workload_type import ( - ServedModelInputWorkloadType, - ServedModelInputWorkloadTypeParam, -) if TYPE_CHECKING: from typing_extensions import Self @@ -84,11 +80,6 @@ class ServedModelInput: The workload size of the served entity. The workload size corresponds to a range of provisioned concurrency that the compute autoscales between. A single unit of provisioned concurrency can process one request at a time. Valid workload sizes are "Small" (4 - 4 provisioned concurrency), "Medium" (8 - 16 provisioned concurrency), and "Large" (16 - 64 provisioned concurrency). Additional custom workload sizes can also be used when available in the workspace. If scale-to-zero is enabled, the lower bound of the provisioned concurrency for each workload size is 0. Do not use if min_provisioned_concurrency and max_provisioned_concurrency are specified. """ - workload_type: VariableOrOptional[ServedModelInputWorkloadType] = None - """ - The workload type of the served entity. The workload type selects which type of compute to use in the endpoint. The default value for this parameter is "CPU". For deep learning workloads, GPU acceleration is available by selecting workload types like GPU_SMALL and others. See the available [GPU types](https://docs.databricks.com/en/machine-learning/model-serving/create-manage-serving-endpoints.html#gpu-workload-types). - """ - @classmethod def from_dict(cls, value: "ServedModelInputDict") -> "Self": return _transform(cls, value) @@ -161,10 +152,5 @@ class ServedModelInputDict(TypedDict, total=False): The workload size of the served entity. The workload size corresponds to a range of provisioned concurrency that the compute autoscales between. A single unit of provisioned concurrency can process one request at a time. Valid workload sizes are "Small" (4 - 4 provisioned concurrency), "Medium" (8 - 16 provisioned concurrency), and "Large" (16 - 64 provisioned concurrency). Additional custom workload sizes can also be used when available in the workspace. If scale-to-zero is enabled, the lower bound of the provisioned concurrency for each workload size is 0. Do not use if min_provisioned_concurrency and max_provisioned_concurrency are specified. """ - workload_type: VariableOrOptional[ServedModelInputWorkloadTypeParam] - """ - The workload type of the served entity. The workload type selects which type of compute to use in the endpoint. The default value for this parameter is "CPU". For deep learning workloads, GPU acceleration is available by selecting workload types like GPU_SMALL and others. See the available [GPU types](https://docs.databricks.com/en/machine-learning/model-serving/create-manage-serving-endpoints.html#gpu-workload-types). - """ - ServedModelInputParam = ServedModelInputDict | ServedModelInput diff --git a/python/databricks/bundles/model_serving_endpoints/_models/served_model_input_workload_type.py b/python/databricks/bundles/model_serving_endpoints/_models/served_model_input_workload_type.py deleted file mode 100644 index 87f62c41e34..00000000000 --- a/python/databricks/bundles/model_serving_endpoints/_models/served_model_input_workload_type.py +++ /dev/null @@ -1,36 +0,0 @@ -# Code generated by pydabs-codegen. DO NOT EDIT. - -from enum import Enum -from typing import Literal - - -class ServedModelInputWorkloadType(Enum): - """ - Please keep this in sync with workload types in InferenceEndpointEntities.scala. - """ - - CPU = "CPU" - GPU_MEDIUM = "GPU_MEDIUM" - GPU_SMALL = "GPU_SMALL" - GPU_LARGE = "GPU_LARGE" - MULTIGPU_MEDIUM = "MULTIGPU_MEDIUM" - CPU_LARGE = "CPU_LARGE" - GPU_XLARGE_8 = "GPU_XLARGE_8" - GPU_XLARGE = "GPU_XLARGE" - CPU_MEDIUM = "CPU_MEDIUM" - - -ServedModelInputWorkloadTypeParam = ( - Literal[ - "CPU", - "GPU_MEDIUM", - "GPU_SMALL", - "GPU_LARGE", - "MULTIGPU_MEDIUM", - "CPU_LARGE", - "GPU_XLARGE_8", - "GPU_XLARGE", - "CPU_MEDIUM", - ] - | ServedModelInputWorkloadType -) diff --git a/python/databricks/bundles/model_serving_endpoints/_models/serving_model_workload_type.py b/python/databricks/bundles/model_serving_endpoints/_models/serving_model_workload_type.py deleted file mode 100644 index 04b513e77a7..00000000000 --- a/python/databricks/bundles/model_serving_endpoints/_models/serving_model_workload_type.py +++ /dev/null @@ -1,36 +0,0 @@ -# Code generated by pydabs-codegen. DO NOT EDIT. - -from enum import Enum -from typing import Literal - - -class ServingModelWorkloadType(Enum): - """ - Please keep this in sync with workload types in InferenceEndpointEntities.scala. - """ - - CPU = "CPU" - GPU_MEDIUM = "GPU_MEDIUM" - GPU_SMALL = "GPU_SMALL" - GPU_LARGE = "GPU_LARGE" - MULTIGPU_MEDIUM = "MULTIGPU_MEDIUM" - CPU_LARGE = "CPU_LARGE" - GPU_XLARGE_8 = "GPU_XLARGE_8" - GPU_XLARGE = "GPU_XLARGE" - CPU_MEDIUM = "CPU_MEDIUM" - - -ServingModelWorkloadTypeParam = ( - Literal[ - "CPU", - "GPU_MEDIUM", - "GPU_SMALL", - "GPU_LARGE", - "MULTIGPU_MEDIUM", - "CPU_LARGE", - "GPU_XLARGE_8", - "GPU_XLARGE", - "CPU_MEDIUM", - ] - | ServingModelWorkloadType -) diff --git a/schema b/schema new file mode 100755 index 00000000000..559ed95b6b0 Binary files /dev/null and b/schema differ